Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SAM Coup ROM v3.0 Annotated Disassembly

Download as pdf or txt
Download as pdf or txt
You are on page 1of 269

OVERVIEW OF THE ROM v3.

0 by Andy Wright
NOTES ON THE ROM SOURCE LISTING This disk contains the complete ROM 3.0 source code. Source code is the text that an assembler program reads and converts into machine code, ready to go into a ROM hip. The les on the disk are in a slightly different form than normal source les. They were made by re-directing the output that the assembler would have sent to a printer during assembly to a disk le instead. This gives addresses in the left-hand column, followed by the values at those addresses (both in hexadecimal) followed by the actual source le text. So, for example, near the start of the lower ROM you will see: 0016 C5 BCJUMP: PUSH BC ;16

The rst number gives the address in the ROM, and the second number is the value there, so that PRINT HEX$(PEEK &0016) gives C5. BCJUMP is a Label that is used to refer to this bit of the ROM in other parts of the source listing. PUSH BC is the Assembly Language text that caused the Assembler to generate the C5 machine code equivalent. A semi-colon precedes any REMs by the author - here I just put a 16 to remind myself as I wrote the source (without the benet of the left-hand two columns) where things would be in memory. This doesn't usually matter very much, but the rst part of a ROM used by a Z80 processor is a special case - see the section on RESTARTS below. You will nd the Technical Manual (available via FORMAT) useful for a full understanding of interactions with the hardware. The text of the ROM source has been left just as I wrote it. Some parts are not terribly well documented, since I was writing to explain things to myself rather than an audience. The symbols used may not correspond exactly to the Technical Manual's usage - for example, I started using URPORT and LRPORT (for Upper RAM Port and Lower RAM Port) before Bruce Gordon told me he was using HMPR and LMPR for the same things! Also, to the hardware, the screen MODEs are 0-3, not 1-4, and I think I may have used MODE inconsistently. Some sections have been "commented out" by inserting semicolons; for example, a table of EQUs that allowed me to write e.g. CP BORDERTOK instead of CP 9EH had to be cut when the assembler ran out of symbol space! At one point I changed assemblers, and the new one didn't allow e.g. LD A,'K'. I did a search and change of all single quotes to double quotes; this accounts for the occasional appearance in the text of CAN"T and A" rather than CAN'T and A'. You may think the code is oddly arranged, or contains odd things like DB 0DDH used to jump three bytes. This is because space was very tight, and any trick that saved a byte was needed. This included moving routines into "illogical" positions if this allowed a Label to be reached by a 2-byte JR instead of a 3-byte JP instruction. A NOTE ON HEXADECIMAL NUMBERS I know some people don't like hex, but it does make life much easier if you can get used to it. For example, in the rst part of the lower ROM is the line:

000A C3CE37

JP ERROR2

In any 3-byte Z80 instruction, the rst byte is the code for the operation, or "op code". In this case it is C3, for JP. The next 2 bytes are a value, or address, in reverse order, so they should be read 37 and then CE. In other words, JP to 37CE hex, which you can easily nd in the later part of the lower ROM. (The Label ERROR2 is at 37CE.) A decimal version would not be as easy to use: 0010 195 206 55JP ERROR2 Besides, it takes more room and it isn't as neat. PAGING There is only one actual ROM chip in the SAM, but it is handled in two sections. The lower ROM, also called ROM0 (machine code programmers often start counting at zero!) is usually paged in at 0000 to 3FFF (0 to 16383) whereas the upper ROM, or ROM1, is paged in at C000 to FFFF (49152 to 65535) when required. The lower ROM is ALWAYS paged in unless user-loaded software initiates complex paging operations. The lower ROM pages in the upper ROM as required, for example, to handle oating-point calculations, BEEP or tape operations. RAM page 0 is usually paged in at 4000-7FFF (16384-32767) and holds important system variables and the start of the current Basic program. The upper half of memory, 8000-FFFF, is used to hold the section of RAM that is currently being worked on. The early part of a Basic program would involve RAM page 0 being paged in at 8000 (which automatically means that page 1 follows at C000). It doesn't matter that RAM page 0 is also simultaneously paged in at 4000. As later parts of the Basic program are interpreted, the start of the current line will occur higher and higher in memory, passing from, say, BF85 to C023. While any structure in memory, like a Basic line, starts below C000, it can be 16K long before it will "fall off" the end of the memory map. This simplies the job of the ROM, since it doesn't need to keep checking, for every byte it reads, whether the end of the memory map has been reached. It is sufcient if it checks, say, every line, if the start of the line is above C000; if it is, the paging can be altered so that the same byte of RAM is re-mapped 16K lower (which will be somewhere in the region 8000 to BFFF) and again we have ample room before we fall off the end of the memory map. This system can be extended with up to 32 pages of RAM (the maximum that the ports that page internal RAM can control) allowing for very big programs indeed. The screen is paged in, starting at 8000, when it must be read from or written to. The y in the ointment, in a way, is the upper ROM. When paged in, it covers RAM at C000-FFFF and could obscure the later part of a Basic line or variable, or the later part of the screen. This makes it unsuitable for many kinds of routines. Floating-point calculation routines are ne, because they work on numbers in the "system page" - RAM page 0, paged in at 4000-7FFF. However, graphic routines should not be in the upper ROM because the entire screen could not be paged in at the same time. (Well, it could be paged in at 4000-BFFF, but that would mean paging out the system page, which holds important variables like the PEN colour, screen MODE, the machine stack, information for interrupts, etc.) All this means that too much code cannot be run in the upper ROM. To get round this, I had to do nasty things like copying routines from this ROM to a RAM buffer in the system page for execution. The rst part of the upper ROM consists of such routines, and the addresses given in the left-hand column correspond to the addresses in the RAM buffer where the code is RUN, not to the actual addresses in the upper ROM where the code is

STORED. The routines involved were chosen because their speed is not critical - the copying process obviously imposes a slight delay. Other routines are quite convoluted because of the problem with the upper ROM. The PRINT routines, for example, start in the lower ROM, use the upper ROM where this is feasible for the interpretation of characters, and then use the lower ROM again for actually putting data on the screen. SAMDOS, MasterDOS and MasterBasic all page into 4000-7FFF for execution. They page out the normal machine stack and replace it with one of their own. Special routines are used to read or write the (paged out) system page variables, or to Call ROM routines with the system page temporarily paged in. HOW THE BASIC INTERPRETER WORKS I do not have the time to explain this in detail, but the following rough outline may help. When the SAM is turned on, the start of the ROM, at 0000, is executed. This jumps to an initialisation routine in the upper ROM, which clears RAM, sets up the system variables, screen mode, rainbow start-up screen, copyright message etc. and then waits for you to press any key. It then indirectly enters the interpreter's "main loop", as it would after an error report. The main loop is at 0E84 in the lower ROM. The rst action is a CALL AUTOLIST which would list the current part of the Basic program, if there was one. After clearing various scratch-pad areas (such as the edit line) with CALL SETMIN, the lower screen is selected for input and output with CALL STRM0. Then theEDITOR is called to get input from the user. When the user presses RETURN, the Editor hands back control, and the main loop tokenises any keywords in the input using CALL TOKMAIN. (E.g. print is turned into a single-byte internal form that is shorter and easier to handle.) The modied line is then checked for correct syntax using CALL LINESCAN. This process also inserts invisible forms of numbers in the line. The invisible form is used to speed things up during program execution. If there is an error, the invisible forms are stripped out again at 0EB0, a warning BEEP is produced, and the loop is gone round again, giving the user a chance to modify the line. If there were no errors, MAINE2 at 0EBB is entered. If the line has a line number, a jump back to MAINEADD at 0E7A is made to add the line to the program and then re-enter the main loop. If there is no line number, a check is made to see if the line is just RETURN. (At 0EC0, RST 18H is equivalent to CALL 0018 - this gets the current character in the A register. 0DH is the code for RETURN or ENTER.) If the line is not just a RETURN, it must start with a direct command, such as RUN, PRINT, CLS, etc. The section from 0EC5-0ED8 is to do with clearing the lower screen, deciding whether to clear the upper screen or not, and setting a counter for the the "scroll?" prompt. The instruction at 0EDE is very important; bit 7 of the FLAGS system variable is SET, signalling "running, not syntax checking". Many of the interpreter's routines to handle commands can be run in two states; either with this bit RESET, to check syntax during LINESCAN, or with it SET when the line is to be executed. CALL COMPILE creates LABEL values and inserts information about the location of procedures and functions into the program. CALL LINERUN actually executes the line, including executing all or part of the program, if the line contains e.g. RUN or GOTO. When a report is to be printed, such as "OK" or "BREAK" or "Out of memory", the operations started by LINERUN are terminated and the program returns to MAINER at 0EED. Various "housekeeping" tasks are performed, then, provided ON ERROR is not active, the program goes to MAINER3 at 0F67, prints the "report" via a CALL ERRHAND1, then jumps back into the main loop.

Now to expand a little on the LINERUN/LINESCAN routines. They have a common heart, the "statement loop" at 0D79 that looks along a Basic line, identifying the rst signicant character in each statement. This is usually a command token, which is used to nd an associated address from a table pointed to by the system variable CMDADDRT at 0DBD. The table, which is in the upper ROM at FD65, gives the start addresses of each command. A jump is then made to the appropriate routine at 0DD3. After the statement has been handled, a return is made to NEXTSTAT at 0DD4 and the statement loop is repeated if there are more statements. If not, the routine terminates if it is "syntax time", or goes to the next line in "run time". As an example of the handling of a command, I will use RESTORE. The address table gives the address of the RESTORE routine as 348F. Here we nd a CALL SYNTAX3, which is a routine that evaluates the (optional) expression expected after RESTORE. During syntax checking, the invisible forms of any numbers are inserted after the visible forms, but the SYNTAX3 routine never returns to where it was called from - instead it POPs a return address and then RETs to NEXTSTAT. When a program is running, on the other hand, SYNTAX3 leaves the result of the expression (or zero if there isn't an expression) on the oating-point calculator stack, and does a normal RETurn to the RESTORE routine at CALL GETINT. CALL GETINT removes the result from the FPC stack, compressing it into a double register. The value in the register is used to nd the address of the RESTOREd line number so that the DATA pointer can be set up correctly at RESTORE3. RESTORE is a simple command but illustrates general rules: there is a rst part which is common to syntax checking and running, after which an early return is made to NEXTSTAT during syntax checking, or a further, active part of the routine is executed if the program is running. A nal RET goes back to NEXTSTAT. Numeric and string expressions that may follow a command are stacked on the calculator stack and removed as required during the "active" routine. (The last-evaluated expression will be the rst item removed the radius of a CIRCLE, for example.) THE RESTARTS The Z80 can use a short, fast version of CALL for 8 particular addresses. These RESTART (shortened to RST) instructions take just 1 byte instead of the usual 3 for a CALL, and 11 instead of17 clock tics. The programmer tries to put commonly-used routines at these special addresses. On the SAM (which in this respect is similar to the Spectrum) the special addresses and the associated routines are: 0000 (RST 0) - Well, the computer starts executing here when it is rst turned on, so "start-up" code has to go here, and it is not much use as a RST. 0008 (RST 08H) - Handles errors. At other places in the source code, you will see things like: 0500 CF 0501 16 RST 08H DB 22 ;"END OF FILE"

The RST 08H CALLS 0008, but the return address is never used to RET to 0501 instead, it is used by the error-handler to read the byte at 0501 (i.e. 16H) and generate the associated error message from a list. My REM after the semi-colon reminds me of the message involved. 0010 (RST 10H) - PRINT the character in the A register. 0018 (RST 18H) - Get the current character (pointed to by CHAD) from a Basic line.

0020 (RST 20h) - Get the next character by advancing CHAD. 0028 (RST 28H) - Call the oating point calculator. A series of code bytes for the desired operations will follow the RST 28H instruction. In the source, I have usually used DB CALC as a synonym for RST 28H. The calculator "language" provides a convenient and concise way of calculating e.g. SIN, COS, SQR etc. The calculator is in the rst part of the upper ROM. 0030 (RST 30H) - CALL or JP to the upper ROM. The address to go to follows the RST 30H instruction. 8000 is subtracted from it to give a JP - otherwise, you get a CALL. Some examples occur in the Jump Table starting at 0100. 0038 (RST 38H) - Maskable Interrupts come here, so this is not much use as a RST. (Non-maskable interrupts goto 0066.) EXAMINING YOUR ROMS If you would like to compare the contents of your ROM chip wit hthe values given in the source listing, you can use the EXAM program which is included on this disk to do it.

SAM COUPE ROM 3.0 SOURCE CODE 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001 0004 0004 0005 0006 0006 0008 0008 0008 0008 0009 000A 000D 000D 000E 000F 000F 0010 0010 0010 0010 0013 0013 0013 0013 0016 0016 0017 0018 0018 0018 0018 001B 001C 001F 001F 0020 0020 0020 0020 0023 0024 0025 0028 0028 002B 002B 002D 002D 002F 002F 0030 0030 0033 0033 0034 0035 0035 0037 0037 0038 0038 0039 003A 003C 003D 003F 0040 0041 0043 0045 0048 0049 0049 004D 0050 0053 0054 0056 0057 0058 0059 005A 005B 005B 005C 005C 005E 005F ;SAM COUPE ROM 3.0 SOURCE CODE Copyright Andrew J.A. Wright 1989-90 ;MAIN.SAM ORG 0,0 0000= 0001= 001F= F3 C3B000 E1 E9 FDE9 00 D9 C3CE37 77 C9 1E C39E01 C32702 C5 C9 2A975A C5 C3C100 00 2A975A 23 C5 C3BE00 C3E600 10FE DDE9 00 C3CF01 D5 C9 10FE C9 F5 C5 DBF9 4F DBFA 47 E5 3E5F D3FA 2A705B E9 ED73D25A 31004C CD2DD4 F9 D3FA E1 C1 F1 FB C9 00 D3FB E9 ANYI: DELYB: DELAYB: IXJUMP: NEXTCHAR: PRINTSTR: BCJUMP: NRWRITE: PAGE0 PAGE1 PAGE1F L0000: HLJUMP: IYJUMP: EQU 0 EQU 1 EQU 1FH ORG 0000H,0 DI JP MINITH POP HL JP (HL) JP (IY) NOP EXX JP ERROR2 LD (HL),A RET DB 30 ;RST 10H - PRINT A JP RST102 ;0013H - PRINT BC FROM (DE) JP SOP2 PUSH BC RET LD HL,(CHAD) PUSH BC JP GETCHAR1 DB 0 ;RST 20H - NEXT CHAR LD HL,(CHAD) INC HL PUSH BC JP NEXTCHAR1 JP FPCP2 DJNZ DELAYB JP (IX) DS 1,0 JP RST30L2 PUSH DE RET DJNZ DELYB RET PUSH AF PUSH BC IN A,(STATPORT) LD C,A IN A,(250) LD B,A PUSH HL LD A,PAGE1F+40H OUT (250),A LD HL,(ANYIV) JP (HL) LD (SPSTORE),SP LD SP,INTSTK CALL INTS LD SP,HL OUT (250),A POP HL POP BC POP AF EI RET DB 0 OUT (251),A JP (HL) ;38H INTERRUPTS ;READ IN ABOUT 36Ts (56) 6 (9) USEC ;B=LMPR, C=STATUS ;BOTH ROMS ON, PAGE ZERO IN SECTIO B ;ARRIVE IN ABOUT 113 (139) T 19 (23) ;30 ;33 DEJUMP ;28 FLOATING POINT CALCULATOR ;2B ;2D ;20 ;13 ;16 ;0FH. ROM VERSION NUMBER ;SOME HARDWARE MIGHT LIKE THIS... ;04 FOWIA

;RST 08H - ERRORS

;RST 18 - GET CHAR. SKIP ALL CONTROL CODES EXCEPT CR. GETCHAR: ;18

005F 0060 0061 0062 0064 0064 0065 0065 0066 0066 0066 0066 0067 0068 0068 006A 006B 006D 006F 0070 0073 0077 007A 007D 007E 007F 0082 0082 0086 0089 008B 008C 008D 008F 008F 0091 0092 0092 0094 0095 0095 0097 0098 0098 009A 009B 009B 009D 009E 009E 00A0 00A1 00A1 00A1 00A1 00A2 00A2 00A2 00A2 00A4 00A5 00A5 00A7 00A8 00A9 00AA 00AB 00AB 00AC 00AC 00AD 00AE 00AE 00AF 00B0 00B0 00B2 00B2 00B3 00B4 00B5 00B7 00B7 00B9 00BB 00BE 00BE 00C1 00C1 00C3 00C4 00C6 00C8 00C8 00C9 00CB 00CD 00CD 00CF 00D1 00D2 00D3 00D3

78 B1 0B 20FB C9 00 F5 E5 DBFA 67 3E1F D3FA 7C 32D95A ED73D75A 318851 2AE05A 7C B5 C40500 ED7BD75A 3AD95A D3FA E1 F1 ED45 EDB0 C9 EDB8 C9 EDB1 C9 EDB9 C9 EDB3 C9 EDBB C9 7E FE0E C0 3E06 85 6F 7E D0 24 7E C9 1A C9 06FA 0B 78 B1 20FB 3E5F D3FA C3AEEB 22975A DBFA 47 E6BF D3FA 7E FE21 3806 0EFA ED41 C1 C9 FE0D

DELBC:

LD A,B OR C DEC BC JR NZ,DELBC RET NOP

;NON-MASKABLE INTERRUPT PUSH AF PUSH HL IN A,(250) LD H,A LD A,PAGE1F OUT (250),A LD A,H LD (NMILRP),A LD (NMISP),SP LD SP,NMISTK LD HL,(NMIV) LD A,H OR L CALL NZ,HLJUMP LD SP,(NMISP) LD A,(NMILRP) OUT (250),A POP HL POP AF RETN LDIR RET LDDR RET CPIR RET CPDR RET OTIR RET OTDR RET ;READ, SKIP NUMBER RDCN: NUMBER: LD A,(HL) CP 0EH RET NZ LD A,6 ADD A,L LD L,A LD A,(HL) RET NC INC H NRREAD: RDDE: MINITH: IDEL: LD A,(HL) RET LD A,(DE) RET LD B,250 DEC BC LD A,B OR C JR NZ,IDEL LD A,40H+PAGE1F OUT (250),A JP MNINIT NEXTCHAR1: LD (CHAD),HL GETCHAR1: IN A,(250) LD B,A AND 0BFH OUT (250),A LD A,(HL) CP 21H JR C,GTCH3 LD C,250 OUT (C),B POP BC RET CP 0DH ;FORCE BIT 6 LOW ;ROM1 OFF ;JR IF 00-20H ;ORIG ROM1 STATUS ;SKIP 5-BYTE INVIS. NUMBER IN BASIC LINE. IF SKIP, TAKES ABOUT 34 Ts. vs 54 ZX ;RET IF NOT NUMBER MARKER ;REGS SAVED IN ORIG PAGE - MAY CORRUPT 4 BYTES ;IF EG SP BEING USED TO CLS ;ROM0 ON, ROM1 OFF, PAGE 0 AT 4000H ;SAVE ORIG LRPORT STATUS ;PUT STACK SOMEWHERE SAFE ;NORMALLY SUPER-BREAK

;RET IF HL OK AND A=NEXT CHAR

;DELAY APPROX 1.2 MSEC *B ;ROM1 ON

GTCH1: GTCH2:

GTCH3:

00D5 00D7 00D7 00D8 00DB 00DD 00DD 00E0 00E1 00E4 00E5 00E6 00E6 00E6 00E6 00E6 00E8 00E8 00EC 00EE 00EF 00F1 00F3 00F6 00F7 00F9 00F9 00FD 00FF 0100 0100 0100 0100 0100 0100 0100 0101 0103 0106 0107 0109 010C 010F 0112 0115 0118 011B 011E 0121 0124 0124 0127 0127 012A 012D 012D 012D 0130 0130 0133 0133 0136 0139 013C 013F 0142 0145 0148 014B 014E 0151 0154 0155 0157 0157 0158 015A 015A 015B 015D 015E 0160 0161 0163 0163 0166 0169 016C 016C 016C 016F 016F 016F 0170 0172 0172 0172 0173 0175 0175 0176 0178 0178

28F6 23 22975A 18EB 2A975A 23 22975A 7E C9 NXCHAR:

JR Z,GTCH2 INC HL LD (CHAD),HL JR GTCH1 LD HL,(CHAD) INC HL LD (CHAD),HL LD A,(HL) RET

;RET IF CR ;SKIP SPACES AND CONTROL CODES

;FLOATING-POINT CALCULATOR DDE3 ED43865B DBFA F5 F640 D3FA CDB7C7 F1 DDE3 ED4B865B D3FA C9 LRPOUT: FPCP2: EX (SP),IX LD (BCREG),BC IN A,(250) PUSH AF OR 40H OUT (250),A CALL FPCMAIN POP AF EX (SP),IX LD BC,(BCREG) OUT (250),A RET DS 0100H-$,0 ;JUMP TABLE AT 0100H F7 5652 C35E02 F7 7768 C3801E C31C1E C3AD19 C36311 C3B43D C3E43A C3A13A C3083B C32E1D C3011D C3F01C C3E43E C35E2A C34E2A C3AB29 C31029 C3A422 C39E21 C31421 C36B20 C3CF24 C3B824 C35709 C3AE06 C3B506 F7 5D6E F7 8A53 F7 EB56 F7 0C72 F7 0B72 C3521E C3BD1C C3B11C C30A05 F7 1B6F F7 0866 F7 0E66 F7 JLDVD: MODET: RST 30H DW JSCRN-8000H JP JSVIN RST 30H DW HEAPROOM-8000H JP WKROOM JP MKRBIG JP CALBAS JP SETSTRM JP POMSG JP EXPT1NUM JP EXPTSTR JP EXPTEXPR JP GETINT JP STKFETCH JP STKSTORE JP SBUFFET JP FARLDIR JP FARLDDR JP JPUT JP JGRAB JP JPLOT JP JDRAW JP JDRAWTO JP JCIRCLE JP JFILL JP JBLITZ JP JROLL JP CLSBL JP CLSLOWER RST 30H DW JPALET-8000H RST 30H DW JOPSCR-8000H RST 30H DW MODPT2-8000H RST 30H DW JTCOPY-8000H RST 30H DW JGCOPY-8000H JP RECLAIM2 JP KBFLUSH JP READKEY JP KYIP2 RST 30H DW BEEPP2-8000H RST 30H DW SABYTES-8000H RST 30H DW LDBYTES-8000H RST 30H ;0100 ;0103 ;0106 ;0109 ;010C ;010F ;0112 ;0115 ;0118 ;011B ;011E ;0121 ; ;0124 ; ;0127 ;012A ; ;012D ; ;0130 OPEN ABC AT HL CALL BASIC LINE SET STREAM IN A REG O/P MSG A FROM LIST AT DE EXPECT A NUMERIC EXPR. AT (CHAD) EXPECT A STRING EXPR AT (CHAD) EXPECT AN EXPRESSION AT (CHAD) UNSTACK WORD FROM CALCULATOR STACK TO BC. HL=BC, A=C GET STRING PARAMS. A=START PAGE, DE=START BC=LEN STACK STRING PARAMS UNSTACK STRING PARAMS AND COPY TO BUFFER IN SYS PAGE. ERROR IF >255 BYTES MOVE (PAGCOUNT/MODCOUNT) BYTES FROM PAGE A, HL TO PAGE C, DE, USING LDIR ;SAVE PTR IN USE BY ANY CALLING RST 28H ROUTINE ;MAKE PTR=ADDR AFTER RST 28H ;ORIG PORT STATUS ;BIT FOR ROM1=HI (ACTIVE) ;GET ORIG IX AS PTR, (SP) PTS. PAST EXIT OR EXIT2

;0133 ;0136 ;0139 ;013C ;013F ;0142 ;0145 ;0148 ;014B ;014E CLEAR ENTIRE SCREEN IF A=0, ELSE CLEAR WINDOW ;0151 ;0154 ;A=LINE (OR FFH IF NONE) B/C=COLOURS, E=PAL. ENTRY. ;0157 ;015A ;015D ;0160 TEXT COPY GRAPHICS COPY

;0163 ;0166 ;0169 ;READ KEYBOARD, FLUSH BUFFER (INKEY$). Z, NC=NONE ;CY, NZ IF A=KEY ;016C ** ;WAIT FOR A QUEUED KEY IN A. ;016F ;DO DE-1 CYCLES AT PERIOD HL 8-T UNITS ;0172 ;0175

0179 017B 017B 017E 017E 017F 0181 0181 0182 0184 0184 0184 0184 0185 0187 0187 018A 018A 018B 018D 018D 018E 0190 0190 0190 0190 0190 0193 0193 0196 0199 019B 019B 019D 019E 019E 01A0 01A1 01A2 01A3 01A6 01A9 01AA 01AB 01AC 01AE 01AF 01AF 01B0 01B1 01B4 01B7 01B8 01B9 01BA 01BA 01BB 01BC 01BF 01C0 01C1 01C4 01C5 01C6 01C7 01C7 01C8 01C9 01CA 01CB 01CC 01CC 01CD 01CF 01CF 01D0 01D1 01D2 01D4 01D6 01D6 01DA 01DB 01DC 01DD 01DE 01E0 01E2 01E2 01E4 01E5 01E6 01E8 01E8 01E9 01EA 01EA 01EB 01ED 01EE 01F0 01F2 01F2

A462 C34520 F7 9759 F7 5D68 F7 3072 C36527 F7 B056 F7 DB52 JGTTOK: JPFSTRS: SENDA: ;NEW TO V11

DW LDVD2-8000H JP EDGE2 RST 30H DW PFSTRS-8000H RST 30H DW SNDA2-8000H RST 30H DW IMSCSR-8000H JP GRCOMP

;0178 ;017B ;017E

LOAD (IF CY) OR VERIFY CDE AT HL DISC/TAPE TAPE EDGE TIMER STR$ OF FPCS TO BUFFER

;0181 SEND BYTE IN A TO PRINTER

;0184 SCREEN$ ;0187 GRAPHIC COPY SR

RST 30H DW GETTOKEN-8000H ;018A MATCH FOR A-1 WORDS FROM LIST AT HL+1 RST 30H DW JCLSCR-8000H ;018D

;MODE 1/MODE 2/MODE 3/MODE 4 ;DOES FULL CLS, SETS UP EXPANSION TABLE IF NEEDED CD583A 112204 CD5F1F 18BF 1E30 83 DDE5 E5 D5 C5 2A515C CDC701 C1 D1 E1 DDE1 C9 08 F5 01FD39 CD0802 F1 08 C9 D9 E5 2A515C 23 23 CDC701 E1 D9 C9 5E 23 56 EB E9 F7 005C E3 F5 7C FE40 301C ED43475B 4E 23 46 23 CB78 2006 CBF8 F1 E1 1802 F1 E3 08 DBFA F5 F640 181B F1 RST30L3: R1ONCLBC: OTCD: RST102: MODECMD: CALL SYNTAX6 LD DE,0400H+34 CALL LIMDB JR MODET LD E,30H ADD A,E PUSH IX PUSH HL PUSH DE PUSH BC LD HL,(CURCHL) CALL HLJPI POP BC POP DE POP HL POP IX RET EX AF,AF' PUSH AF LD BC,S16OSR CALL R1OF2 POP AF EX AF,AF' RET EXX PUSH HL LD HL,(CURCHL) INC HL INC HL CALL HLJPI POP HL EXX RET LD E,(HL) INC HL LD D,(HL) EX DE,HL JP (HL) RST 30H DW PROM1-8000H EX (SP),HL PUSH AF LD A,H CP 40H JR NC,RST30L4 LD (BCSTORE),BC LD C,(HL) INC HL LD B,(HL) INC HL BIT 7,B JR NZ,RST30L3 SET 7,B POP AF POP HL JR R1ONCLBC POP AF EX (SP),HL EX AF,AF' IN A,(250) PUSH AF OR 40H JR R1OFON POP AF ;JP MAIN PRINT ROUTINE IN ROM1 ;GET CALLER'S ADDRESS IN HL ;JR IF CALLED FROM OUTSIDE ROM0 - USER ;INSIST ON A NUMBER ;ALLOW ORIG OF 1-4, DEC

S16OP:

;CALL S16 O/P (IN ROM0) WITH ROM1 OFF

INPUTAD:

HLJPI:

PRMAIN: RST30L2:

;JR IF NORMAL 'CALL ROM1' ;ELSE BIT 7 SHOWED 'JP ROM1' ;ORIG HL - JUNK 1 RET ADDR

RST30L4:

01F3 01F4 01F5 01F8 01F9 01FA 01FA 01FA 01FA 01FA 01FB 01FC 01FD 01FE 01FF 0201 0201 0201 0201 0201 0202 0203 0204 0205 0206 0207 0207 0207 0207 0207 0208 0208 020A 020B 020D 020D 020F 0210 0213 0214 0215 0217 0218 0219 0219 021A 021E 021F 021F 021F 021F 021F 0221 0223 0225 0226 0227 0227 0227 0227 0227 0227 0227 0228 022B 022C 022D 022E 022F 0230 0232 0233 0235 0237 0238 023A 023C 023C 023D 023E 023F 0242 0244 0244 0245 0246 0247 0248 024A 024D 024D 024E 024F 0250 0252 0252 0253 0255 0256 0256 0257 025A 025C

E3 E5 2AF25A E3 C9

EX (SP),HL PUSH HL LD HL,(RST30V) EX (SP),HL RET

;'RET' TO VECTOR, ALL REGS INTACT

;CALL PARAM ADDR WITH ROM1 OFF. JUNK CALLING ADDR SO EQUIV. OF 'JUMP' ;(ORIG ROM1 STATUS STILL RESTORED, THOUGH) E3 4E 23 46 E1 1806 R1OFFJP: EX (SP),HL LD C,(HL) INC HL LD B,(HL) POP HL JR R1OFFCLBC

;CALL PARAM ADDR WITH ROM1 OFF. CALL CAN COME FROM ANYWHERE ;ORIG ROM1 STATUS RESTORED AT END E3 4E 23 46 23 E3 R1OFFCL: EX (SP),HL LD C,(HL) INC HL LD B,(HL) INC HL EX (SP),HL

;BC=PARAMETER

;R1OFFCLBC. CALL BC WITH ROM1 OFF. ALL REGS CARRIED IN EXCEPT AF' (CORRUPT) ;ALL REGS CARRIED OUT EXCEPT AF'. ORIG ROM1 STATUS RESTORED AT END 08 DBFA F5 E6BF D3FA 08 CD1902 08 F1 D3FA 08 C9 C5 ED4B475B C9 R1OFFCLBC: EX AF,AF' R1OF2: R1OFON: IN A,(250) PUSH AF AND 0BFH OUT (250),A EX AF,AF' CALL LDBCJP EX AF,AF' POP AF OUT (250),A EX AF,AF' RET PUSH BC LD BC,(BCSTORE) RET ;ORIG URPORT STATUS ;ROM1 BIT OFF ;ROM1 OFF/ON

LDBCJP:

;TURN ROM 1 OFF, JP (BC) DBFA E6BF D3FA C5 C9 R1XJP: IN A,(250) AND 0BFH OUT (250),A PUSH BC RET

;STRING O/P - FROM 0013H ;ENTRY: DE PTS TO DATA, SWITCHED IN. BC=LEN ;ACTION: DO NOTHING IF BC=0, ELSE PRINT BC BYTES FROM (DE) ;EXIT: DE PTS TO JUST PAST LAST BYTE ON EXIT, BC=0, HL CORRUPT D5 2A515C 5E 23 56 EB D1 DBFA F5 E6BF D3FA 7E FE40 2011 23 23 23 CD0500 180E 1A D7 13 7A FEC0 D4EB3F 78 B1 0B 20F2 F1 D3FA C9 C5 CD0102 AC00 C1 SOPL: SOP2: PUSH DE LD HL,(CURCHL) LD E,(HL) INC HL LD D,(HL) EX DE,HL POP DE IN A,(250) PUSH AF AND 0BFH OUT (250),A LD A,(HL) CP 40H JR NZ,SOP3 INC HL INC HL INC HL CALL HLJUMP JR SOP4 LD A,(DE) RST 10H INC DE LD A,D CP 0C0H CALL NC,INCURPDE LD A,B OR C DEC BC JR NZ,SOPL POP AF OUT (250),A RET PUSH BC CALL R1OFFCL DW NRREAD POP BC ;FETCH AN OUTPUT ADDRESS POINTER

;DE=SRC, HL=CHANNEL ;ROM1 OFF ;JR IF SPECIAL STRING OUTPUT NOT PROVIDED BY ;CHANNEL - USE MULTIPLE CALLS OF RST 10H. ;SKIP '40H, JR XX' TO PT TO STRING O/P ROUTINE

SOP3:

SOP4: R1OFRD:

025D 025E 025E 025F 0260 0261 0262 0263 0264 0265 0266 0268 0269 026B 026C 026E 0272 0275 0276 0277 027A 027B 027C 027D 027E 027F 027F 0280 0281 0282 0286 0288 0289 028A 028B 028B 028B 028B 028B 028B 0290 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294

C9 D9 E1 5E 23 56 23 E5 4F DBFA 47 3E1F F3 D3FA ED73D55A 31C04E FB C5 217F02 E5 D5 79 D9 C9 08 F1 F3 ED7BD55A D3FA FB 08 C9 JSVIN:

RET EXX POP HL LD E,(HL) INC HL LD D,(HL) INC HL PUSH HL LD C,A IN A,(250) LD B,A LD A,1FH DI OUT (250),A LD (JVSP),SP LD SP,ISPVAL-40H EI PUSH BC LD HL,JSVIN2 PUSH HL PUSH DE LD A,C EXX RET EX AF,AF' POP AF DI LD SP,(JVSP) OUT (250),A EI EX AF,AF' RET ;RET ADDR

;RET ADDR TO CALLER ;SAVE ENTRY A BRIEFLY ;ENTRY LRPORT ;SYS PAGE IN AT 4000H, ROM0 ON, ROM1 OFF

;RET ADDR TO PT 2 ;PARAM TO CALL ;ENTRY A ;TO PARAM ADDR WITH MAIN REGS INTACT ;THEN 'RET' TO VARSIN2

JSVIN2:

;ORIG

;INITIAL STREAM DISPLACEMENTS 1A1501060B STRMTAB: 01010610 DB 26,21,1,6,11 DB 1,1,6,16 ;B,$,K,S,R (FIXED) FOR STREAMS FB,FC,FD,FE,FF ;K,K,S,P FOR STREAMS 0,1,2,3

;MAIN FILE - MAIN.SAM INCLUDE VARS.SAM ;VARS.SAM 5A00= 5A00= 5A01= 5A03= 5A04= 5A05= 5A06= 5A08= 5A09= 5A0B= 5A0E= 5A0F= 5A10= 5A2F= 5A30= 5A32= 5A33= VAR2 LNCUR KURCHAR BIN1DIG BIN0DIG INSTHASH PSLD EQU 5A00H EQU EQU EQU EQU EQU EQU VAR2+00H VAR2+01H VAR2+03H VAR2+04H VAR2+05H VAR2+06H ;MUST START AT PAGE BOUNDARY ;NEXT 18 BYTES INITED TOGETHER FROM 'CHIT' ;CURRENT LINE CURSOR CHAR (USUALLY '>') ;(2) CURSOR CHARACTERS - LOWER CASE/UPPER CASE ;USED BY BIN$ - USUALLY '1' ; USUALLY '0' ;NORMALLY '#' ;(2) DEVICE LETTER/NUMBER ;NUMBER=TAPE SPEED/DISC NUMBER/NET STATION SPEEDINK EQU VAR2+08H ;INK FLASH COUNTER RELOAD VALUE LINIPTR EQU VAR2+09H ;(2) PTR TO LINE INTERRUPT PAL CHNG TABLE XCMDP EQU VAR2+0BH ;(3) PAGE/ADDR OF FIRST EXTERNAL CMD LIST, OR FFXXXX PRRHS EQU VAR2+0EH ;PRINTER RHS LIMIT - 79 AFTERCR EQU VAR2+0FH ;0A OR NUL ACCORDING TO WHETHER AUTO LF NEEDED LPTPRT1 EQU VAR2+10H ;(2) PRINTER CONTROL PORT/01H STROBE VALUE ;ALL reserved for DUMP TABVAR EQU VAR2+2FH ;0 IF TAB=16, ELSE TAB=8 M23LSC EQU VAR2+30H ;(2) M2/3 LOWER SCREEN COLOURS SOFE EQU VAR2+32H ;FLAG FOR SCREEN OFF ENABLE/DISABLE 0=ON TPROMPTS EQU VAR2+33H ;BIT 0=1 TO SUPPRESS PRINTED NAMES DURING LOAD ;BIT 1=1 TO SUPPRESS PROMPTS DURING SAVE ;START OF BLOCK SAVED WITH SWITCHED-OUT SCREEN 5A34= 5A35= 5A36= 5A38= 5A39= 5A3A= 5A3B= 5A3C= 5A3D= 5A3E= 5A3F= 5A40= 5A41= 5A42= 5A42= 5A44= 5A45= 5A46= 5A47= BGFLG FL6OR8 CSIZE UWRHS UWLHS UWTOP UWBOT LWRHS LWLHS LWTOP LWBOT MODE YCOORD XCOORD RLINE THFATP ATTRP MASKP PFLAGP EQU VAR2+34H ;BLOCK GRAPHICS FLAG EQU VAR2+35H ;00=6 BIT CHARS IN MODE 2, NZ=8 BIT EQU VAR2+36H ;(2) HEIGHT/WIDTH EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU VAR2+38H VAR2+39H VAR2+3AH VAR2+3BH ;STARTS ;STARTS ;STARTS ;STARTS AT AT AT AT 31 0 0 18 (19 LINES IN UPPER, 2 IN LOWER SCR, 9 PIX)

;LOWER WINDOW VAR2+3CH VAR2+3DH VAR2+3EH VAR2+3FH ;STARTS AT 20 VAR2+40H VAR2+41H ;0-191, 0 AT TOP VAR2+42H ;(2) 0-255 (FAT) OR 0-511 (THIN) XCOORD VAR2+44H ;00=THIN, NZ=FAT PIXELS VAR2+45H ;ATTR USED BY MODES 0 AND 1 VAR2+46H VAR2+47H ;BIT 4=PAPER 9, BIT 6=INK 9

;PERMANENT GRAPHICS/PRINT VARS

0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294

5A48= 5A49= 5A4A= 5A4B= 5A4C=

M23PAPP M23INKP OVERP INVERP GOVERP

EQU VAR2+48H ;NIBBLES OR DOUBLE BITS MATCH EQU VAR2+49H ;00-FF. NIBBLES MUST MATCH UNLESS A DOTTED LINE WANTED. ;MUST BE NEXT TO OVER FOR LD DE,(M3INKT) EQU VAR2+4AH ;0-1. NORMAL OR OVER 1 (OR-ING) EQU VAR2+4BH ;00/FF FOR NORMAL/INVERSE ; EQU VAR2+4CH ;0-3. NORMAL, XOR, OR, AND ;THESE 2 LINKED ;(GRAPHICS OVER - USED BY PUT) EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU ;14 EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU VAR2+4DH VAR2+4EH VAR2+4FH VAR2+50H VAR2+51H VAR2+52H VAR2+53H VAR2+54H VAR2+55H VAR2+56H VAR2+57H VAR2+58H VAR2+59H VAR2+5AH VAR2+5CH VAR2+5DH SPARE VAR2+6CH VAR2+6EH VAR2+70H VAR2+72H VAR2+73H VAR2+74H VAR2+75H VAR2+76H VAR2+77H VAR2+78H VAR2+79H VAR2+7AH VAR2+7BH VAR2+7DH VAR2+7FH ;(2) U. WINDOW LOWEST BOTTOM/MAX RHS ;GRAPHICS ORIGIN OFFSET ;LOWER SCREEN BIT OFFSET ** THESE 3 MOVED HERE ;(2) SCREEN POSN (UPPER) WINDLHS, WINDTOP AFTER CLS ;(2) SCREEN POSN (LOWER) 0,19 AFTER CLS ;(2) PRINTER POSN (1 BYTE EXTRA FOR CONVENIENT LD) ;USED BY LPRINT - CURRENT O/P CHAR ;0=US, 1=LS, 2=PRINTER, 3= ;CURRENT CHANNEL LETTER K/S/P/B/T/$ ETC ;LONG/SHORT IF ;Z IF REF VAR BEING WORKED ON ;CURRENT DISPLAY ;CURRENT SCREEN PAGE ;CURRENT UPPER RAM PORT ;CURRENT LOWER RAM PORT (TEMP STORES DURING PAGING) ;(2) CURRENT STATEMENT ADDR ;(2) ;(2) LINE NUMBERS IN EG LIST X TO Y. ALSO USED BY ;ARRAY SLICER ;COPIED FROM THFATP WHEN MODE=2, ELSE SET TO NZ (FAT) ;BIT 4=PAPER 9, BIT 6=INK 9 ;NIBBLES OR DOUBLE BITS MATCH ;00-FF. NIBBLES MUST MATCH UNLESS A DOTTED LINE WANTED ;0-1. NORMAL OR OVER 1 (OR-ING) ;00/FF FOR NORMAL/INVERSE ; ;0-3. NORMAL, XOR, OR, AND ;LINKED

;TEMPORARY GRAPHICS/PRINT VARS 5A4D= 5A4E= 5A4F= 5A50= 5A51= 5A52= 5A53= 5A54= 5A55= 5A56= 5A57= 5A58= 5A59= 5A5A= 5A5C= 5A5D= 5A6C= 5A6E= 5A70= 5A72= 5A73= 5A74= 5A75= 5A76= 5A77= 5A78= 5A79= 5A7A= 5A7B= 5A7D= 5A7F= THFATT ATTRT MASKT PFLAGT M23PAPT M23INKT OVERT INVERT GOVERT WINDRHS WINDLHS WINDTOP WINDBOT WINDMAX ORGOFF LSOFF SPOSNU SPOSNL PRPOSN OPCHAR DEVICE CLET IFTYPE REFFLG CURDISP CUSCRNP CURP CLRP CSA FIRST LAST

;CURRENT WINDOW (TEMP)

;END OF BLOCK SAVED WITH SCREEN

;POINTERS THAT ARE ADJUSTED BY MAKEROOM, RECLAIM: 5A81= 5A82= 5A84= 5A85= 5A87= 5A88= 5A8A= 5A8B= 5A8D= 5A8E= 5A90= 5A91= 5A93= 5A94= 5A96= 5A97= 5A99= 5A9A= 5A9C= 5A9D= 5A9F= 5AA0= 5AA2= 5AA3= 5AA5= 5AA6= 5AA8= 5AA9= 5AAB= 5AAC= 5AAE= 5AAF= SAVARSP SAVARS NUMENDP NUMEND NVARSP NVARS DATADDP DATADD WKENDP WKEND WORKSPP WORKSP ELINEP ELINE CHADP CHAD KCURP KCUR NXTLINEP NXTLINE PROGP PROG XPTRP XPTR DESTP DEST PRPTRP PRPTR DPPTRP DPPTR CLAPG CLA EQU VAR2+81H EQU VAR2+82H ;(2) EQU VAR2+84H EQU VAR2+85H ;(2) EQU VAR2+87H EQU VAR2+88H ;(2) EQU VAR2+8AH EQU VAR2+8BH ;(2) EQU VAR2+8DH EQU VAR2+8EH ;(2) EQU VAR2+90H EQU VAR2+91H ;(2) EQU VAR2+93H EQU VAR2+94H ;(2) EQU VAR2+96H EQU VAR2+97H ;(2) EQU VAR2+99H EQU VAR2+9AH ;(2) EQU VAR2+9CH EQU VAR2+9DH ;(2) ;SAVARS/NUMEND/NVARS MUST BE IN ORDER ;NUMEND/NVARS/DATADD MUST BE IN ORDER

EQU VAR2+09FH EQU VAR2+0A0H ;(2) EQU VAR2+0A2H EQU VAR2+0A3H ;(2) EQU VAR2+0A5H EQU VAR2+0A6H ;(2) EQU VAR2+0A8H EQU VAR2+0A9H ;(2) PROC POINTER EQU VAR2+0ABH EQU VAR2+0ACH ;(2) DEF PROC POINTER EQU VAR2+0AEH EQU VAR2+0AFH ;(2)

;END OF ADJUSTED PTRS

0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294

5AB1= 5AB2= 5AB3= 5AB5= 5AB7= 5AB8= 5AB9= 5ABA= 5ABB= 5ABC= 5ABD= 5ABE= 5ABF= 5AC0= 5AC1= 5AC2= 5AC4= 5AC5= 5AC6= 5AC7= 5AC8= 5ACA= 5ACC= 5ACE= 5ACF= 5AD0= 5AD1= 5AD2= 5AD5= 5AD7= 5AD9= 5ADA= 5ADA= 5ADC= 5ADE= 5AE0= 5AE2= 5AE4= 5AE6= 5AE8= 5AEA= 5AEC= 5AEE= 5AF0= 5AF2= 5AF4= 5AF6= 5AF8= 5AFA= 5AFC= 5AFE= 5B00= 5B20=

DFTFB STRNO LDCO ; OPSTORE DMPFG LISTFLG LSTFT INQUFG SPROMPT OLDSPCS INDOPFG NXTSPCS CURSPCS NXTHSPCS CURTHSPCS KPOS SOFFCT SOFLG SPEEDIC PALFLAG TEMPW1 TEMPW2 TEMPW3 TEMPB1 TEMPB2 TEMPB3 LASTSTAT SPSTORE JVSP NMISP NMILRP VECTBS DMPV SETIYV PRTOKV NMIV FRAMIV LINIV COMSV MIPV MOPV EDITV RST8V RST28V RST30V CMDV EVALUV LPRTV MTOKV MOUSV KURV CEXTAB EXTAB

EQU VAR2+0B1H EQU VAR2+0B2H EQU VAR2+0B3H SPARE EQU VAR2+0B5H EQU VAR2+0B7H EQU VAR2+0B8H EQU VAR2+0B9H EQU VAR2+0BAH

;** ;CURRENT STREAM NO. ;LD ZX CODE OFFSET (PAGES)

;(2) ;IF NZ PRINT O/P DUMPED ;0/1/2 FOR LIST FORMAT 0/1/2 ;TEMPORARY VERSION OF LISTFLG USED BY CHANNEL 'R' ;IN QUOTES FLAG. BIT 0=1 IF IN QUOTES. OUTLINE ZEROS ;BIT SO INITIAL STATE IS 'OUTSIDE' AND TOKENS PRINTED ;EXCEPT IN QUOTES. PRINT SETS TO 1 SO ALWAYS UDGS. EQU VAR2+0BBH ;IF NZ NO 'SCROLL?' PROMPTS EQU VAR2+0BCH ;SPACE STATUS OF PREVIOUS LINE ** EQU VAR2+0BDH ;INDENTED O/P FLAG EQU EQU EQU EQU VAR2+0BEH VAR2+0BFH VAR2+0C0H VAR2+0C1H

EQU VAR2+0C2H ;(2) CURSOR SCREEN POSN EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU VAR2+0C4H VAR2+0C5H VAR2+0C6H VAR2+0C7H VAR2+0C8H VAR2+0CAH VAR2+0CCH VAR2+0CEH VAR2+0CFH VAR2+0D0H ;COUNTER FOR SCREEN OFF ;FLAG FOR 'SCREEN HAS BEEN TURNED OFF' (NZ) OR ON (Z) ;COUNTER FOR FLASHING INKS ;BIT 0 SHOWS WHICH PAL TABLE IN USE. ;(2) ;(2) ;(2) ;USED FOR FINAL FILL PARAM

;NEXT 4 MUST STAY IN ORDER

;SYSTEM PAGE ONLY EQU VAR2+0D1H ;STATPORT VALUE ON LAST INTERRUPT EQU VAR2+0D2H ;(2) SP STORE EXCLUSIVE TO INTERRUPTS EQU VAR2+0D5H ;(2) JSVIN SP STORE EQU VAR2+0D7H ;(2) NMI SP STORE EQU VAR2+0D9H ;(1) LRPORT VALUE WHEN NMI OCCURRED EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU VAR2+0DAH VAR2+0DAH VAR2+0DCH VAR2+0DEH VAR2+0E0H VAR2+0E2H VAR2+0E4H VAR2+0E6H VAR2+0E8H VAR2+0EAH VAR2+0ECH VAR2+0EEH VAR2+0F0H VAR2+0F2H VAR2+0F4H VAR2+0F6H VAR2+0F8H VAR2+0FAH VAR2+0FCH VAR2+0FEH ;VECTOR BASE ADDR (0) USED BY LINK ROUTINE ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2)

EQU VAR2+0100H ;(32) COLOUR IS APPLIED TO THIS DATA, SO EG. F0F0 ;MIGHT BECOME A3A3, OR IF INVERSE, 3A3A. EQU VAR2+0120H ;(32) 16 WORDS OF MODE 3 PRINT NIBBLE->WORD DATA. ;(OR 16 BYTES OF MODE 2 DOUBLED DATA) ;EACH WORD (BYTE) IS THE EXPANSION OF A NIBBLE, SO ;E.G. ENTRY 0A BIN 1010 =1111000011110000 OR 11001100 EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU ;FLAG BITS USED BY LABEL/FN/PROC COMPILER ;NZ IF BREAK BETWEEN STATEMENTS DISABLED ; ;(2) LINE TO GOTO ON ERROR ;BIT 7=TEMP ON, BIT 0=PERM ON ;ON CMD'S STATEMENT NO. ;(2) USED BY RST 30H ;(2) ;(2) ;(2) USED BY POINTERS ;(2) USED BY POINTERS ;1 SPARE EQU VAR2+0152H ;(30) 1 BYTE PRE SCREEN LINE, MARKED IF HAS A ;LINE NUMBER ON IT EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU VAR2+0170H VAR2+0172H VAR2+0174H VAR2+0175H VAR2+0176H VAR2+0181H VAR2+0182H VAR2+0183H VAR2+0184H VAR2+0186H VAR2+0188H VAR2+0189H AUTOSTEP ;ANY INTERRUPT VECTOR ;(2) RENAME STACK PTR (PARPRO) ;CODE OF CMD BEING EXECUTED ;LET/DEFAULT FLAG ;(11) TLBYTE/NAME OF VAR THAT STREAM 16 WRITES TO. ;GRAPHICS RECORD FLAG (0=OFF) ;DOUBLE HEIGHT ADJ. 0 UNLESS BOTTOM OF DH CHAR O/PED ;PAGE COUNTER USED BY FARLDIR ;(2) MOD 16K COUNTER USED BY FARLDIR ;(2) FPC'S BC REG ;(2) ;RENUM STEP VAR2+0140H VAR2+0141H VAR2+0142H VAR2+0143H VAR2+0145H VAR2+0146H VAR2+0147H VAR2+0149H VAR2+014BH VAR2+014DH VAR2+014FH

5B40= 5B41= 5B42= 5B43= 5B45= 5B46= 5B47= 5B49= 5B4B= 5B4D= 5B4F= 5B52= 5B70= 5B72= 5B74= 5B75= 5B76= 5B81= 5B82= 5B83= 5B84= 5B86= 5B88= 5B89= 5B89=

COMPFLG BREAKDI ERRSTAT ERRLN ONERRFLG ONSTORE BCSTORE M3PAPP M3LSC TEMPW4 TEMPW5 LPT ANYIV RNSTKE CURCMD LTDFF STRM16NM GRARF DHADJ PAGCOUNT MODCOUNT BCREG AUTOFLG AUTOSTEP RSTEP

0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294

5B8B= 5B8D= 5B8E= 5B8F= 5B96= 5B98= 5B9A= 5B9B= 5B9D= 5B9E= 5B9F= 5BA0= 5BB0= 5BB5= 5BB6= 5BB7= 5BB9= 5BBA= 5BBC= 5BBE= 5BC0= 5BC2= 5BC3= 5BC4= 5BC6= 5BC8= 5BCA= 5BCC= 5BCE= 5BD0= 5BD2= 5BD4= 5BD6= 5BD8= 5BDA= 5BDC= 5BDE= 5BE0= 5BEE= 5C00= 5C02= 5C03= 5C05= 5C06= 5C08= 5C09= 5C0A= 5C10= 5C36= 5C38= 5C39= 5C3A= 5C3B= 5C3C= 5C3D= 5C3F= 5C42= 5C44= 5C45= 5C47= 5C48= 5C49= 5C4B= 5C4F= 5C51= 5C53= 5C54= 5C56= 5C61= 5C63= 5C65= 5C67= 5C68= 5C6A= 5C6C= 5C6E= 5C70= 5C71= 5C72= 5C76= 5C78=

LSPTR LNPTR MSEDP BUTSTAT MXCRD MYCRD FRACLIM NPRPOS DIGITS EPOWER DECPNTED PRNBUFF BCDBUFF OTHER DCT SLDEV OVERF INSLV STRLOCN TVDATA DOSER DOSFLG DOSCNT BSTKEND BASSTK HEAPEND HPST FPSBOT DKDEF DKLIM PATOUT ERRMSGS UMSGS KBTAB CMDADDRT MNOP MNIP PAGER KBUFF LHM1 ;LASTH KDATA LKPB REPCT LASTKV LASTK REPDEL REPPER STREAMS CHARS RASP PIP ERRNR FLAGS TVFLAG ERRSP LISTSP NEWPPC NSPPC PPC SUBPPC BORDCR EPPC BORDCOL CHANS CURCHL DEFADDP DEFADD NLASTH ZIPLIB ZIPTEMP STKEND KPFLG MEM FLAGS2 SDTOP OLDPPC OSPPC FLAGX STRLEN SEED FRAMES

EQU EQU EQU EQU

VAR2+018BH VAR2+018DH VAR2+018EH VAR2+018FH

;(2) LINE SCAN PTR ;(1) ;(8) 018E-0195 ;MOUSE BUTTON STATUS

EQU VAR2+0196H ;(2) MOUSE X COORD EQU VAR2+0198H ;(2) MOUSE Y COORD EQU EQU EQU EQU EQU EQU ; ;(2) ; MUST ; ALL ; STAY IN THIS ORDER! ;(16) ALLOWS -0.0000123456789 ; OR -1.2345678E-35 EQU VAR2+01B0H ;(5) EQU VAR2+01B5H ;NET DESTINATION STATION NUMBER EQU VAR2+01B6H ;DISC ERROR COUNTER EQU VAR2+01B7H ;(2) DEVICE LETTER/NUMBER (TEMP) ;NUMBER=TAPE SPEED/DISC NUMBER/NET STATION EQU VAR2+01B9H ;'SAVE OVER' FLAG. 0 IF SAVE OVER, ELSE NZ EQU VAR2+01BAH ;(2) EQU VAR2+01BCH ;(2) USED BY LOOKVARS EQU VAR2+01BEH ;(2) EQU VAR2+01C0H ;(2) JUMP AFTER DOS EXECUTION EQU VAR2+01C2H ;Z IF NO DOS LOADED EQU VAR2+01C3H ;BIT 0 IS SET IF DOS IN CONTROL EQU VAR2+01C4H ;(2) EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU VAR2+01C6H VAR2+01C8H VAR2+01CAH VAR2+01CCH VAR2+01CEH VAR2+01D0H VAR2+01D2H VAR2+01D4H VAR2+01D6H VAR2+01D8H VAR2+01DAH VAR2+01DCH VAR2+01DEH ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) ;(2) VAR2+019AH VAR2+019BH VAR2+019DH VAR2+019EH VAR2+019FH VAR2+01A0H

;USED BY PRINTFP:

;NEXT 26 BYTES INITED TOGETHER FROM MAIT

START OF FPCS KEY DEFS LIMIT OF DEF KEY BUFFER ADDR OF 'PRINTABLE CHARS' O/P START OF CMD ADDR TABLE IN ROM0 ADDR OF MAIN O/P ROUTINE ADDR OF MAIN I/P ROUTINE

EQU VAR2+01E0H ;(14) RESERVED FOR PAGING S.R. EQU VAR2+01EEH ;(18) - 2 TABLES OF 72 BITS EQU 5C00H ;USED BY KEYSCAN (AS 'LASTH-1') EQU 5C01H ;LAST KEY HIT. 0 IF NO KEY. STOPS CHANGING IF KEYS ;ARE NOT BEING READ, WHEN BUFFER FILLS. RES 5,(FLAGS) ;IS SEEN AS A READ. EQU 5C02H EQU 5C03H ;(2) EQU 5C05H EQU 5C06H ;(2) EQU 5C08H ;KEY FROM BUFFER QUEUE HEAD. KEEPS LAST KEY VALUE. ;NEEDS PERIODIC RESETS OF BIT 5,(FLAGS) OR BUFFER FILLS. EQU 5C09H EQU 5C0AH ;1 SPARE EQU 5C10H ;(42 - USES 5C0C-5C35 FOR STREAMS -5 TO 15. -4=16) EQU 5C36H ;(2) EQU 5C38H EQU 5C39H EQU 5C3AH EQU 5C3BH EQU 5C3CH EQU 5C3DH ;(2) EQU 5C3FH ;(2) EQU 5C42H EQU 5C44H EQU 5C45H EQU 5C47H EQU 5C48H EQU 5C49H EQU 5C4BH EQU 5C4FH EQU 5C51H EQU 5C53H EQU 5C54H EQU 5C56H ;8 SPARE EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU ;(2) ;(2) ;ATTRIBUTES FOR LOWER SCREEN IN MODES 1/2 ;(2) ;VALUE TO SEND TO BORDER PORT ;(2) ;(2) ;(2) ;(3)

5C61H ;(2) SIMON N. GOODWIN'S 5C63H ;(2) COMPILER VARS 5C65H 5C67H ;FUNCTION KEYS IF EVEN, NUMBER PAD IF ODD 5C68H 5C6AH 5C6CH 5C6EH 5C70H 5C71H 5C72H 5C76H 5C78H ;(3)

0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294

5C7B= 5C7D= 5C7F= 5C82= 5C8C= 5C8D= 5C95= 5C9D= 5C9F= 5CA0= 5CB0= 5CB1= 5CB2= 5CB4= 00C4= 0070= 003B= 0021= 004A= 0030= 0042= 0043= 004C= 0053= 0060= 006C= 0070= 007A= 0080= 0085= 0087= 0088= 008A= 008B= 008C= 008D= 008E= 008F= 0094= 0095= 0096= 0097= 0080= 0081= 0082= 0083= 0084= 0086= 0087= 0088= 0089= 008B= 008C= 008D= 008E= 00E0= 00E1= 00E2= 00E3= 0009= 0059= 0079= 0080=

UDG HUDG FRAMES34 OLDPOS SCRCT KBQB KBQP SCPTR FISCRNP SCLIST LASTPAGE RAMTOPP RAMTOP PRAMTP ;SPARE KEYWNO TSPEED PITOK PI INSTOK INSTR FNTOK BINTOK SCRNTOK SINTOK INTOK CODETOK CHRSTOK MODTOK ANDTOK USINGTOK ATTOK TABTOK WHILETOK UNTILTOK LINETOK THENTOK TOTOK STEPTOK ;FORMATTOK ;ERASETOK SAVETOK LOADTOK MERGETOK VERIFYTOK ;RECORDTOK BTHK FOPHK LDHK VFYHK SVHK OSHK CSHK ALHK DIRHK DVHK EOFHK PTRHK PATHHK COMM TRCK SECT DTRQ DRES STPIN STPOUT DRSEC

EQU EQU EQU EQU EQU

5C7BH 5C7DH 5C7FH 5C82H 5C8CH

;(2) ;(2) ;(2)

EQU 5C8DH ;(8) KEYBOARD QUEUE ** MOVED HERE EQU 5C95H ;(2) KEYBOARD QUEUE POINTERS. LOW=END, HI=HEAD ;6 SPARE EQU 5C9DH ;(2) ADDR OF CURRENT SCREEN IN SCLIST EQU EQU EQU EQU EQU EQU 5C9FH 5CA0H 5CB0H 5CB1H 5CB2H 5CB4H ;PAGE OF SCREEN 1 ;(16) SCREENS LIST. MODE/PAGE OF SCREENS 1-16, OR FFH ;LAST PAGE RESERVED BY BASIC ;(2) ;LAST PAGE PRESENT IN MACHINE

;NOT CLEARED BY NEW:

EQU 0C4H EQU 112 EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU 3BH PITOK-1AH ;SEE BELOW 4AH INSTOK-1AH ;USED TO SEPARATE N/$ IMMED CODES 42H ;USED BY TPRINT 43H ;USED BY TPRINT AND CALC5BY 4CH ;USED BY SAVE/LOAD 53H ;USED BY TPRINT 60H ; 6CH ;USED BY SAVE/LOAD 70H ;USED BY COPY 7AH ;USED BY TPRINT 80H ;USED BY TPRINT 085H 087H 088H 08AH 08BH 08CH 08DH 08EH 08FH

EQU 091H EQU 092H EQU 094H EQU 095H EQU 096H EQU 097H EQU 0EFH EQU 128 ;DOS BOOT (DOS CAN IGNORE, OR INTERPRET AS ALHK) EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU 129 130 131 132 ;DOS ;DOS ;DOS ;DOS OPEN (GET HEADER) LOAD VERIFY SAVE

;IX=HDR, IX+50H=HDL

134 ;DOS OPEN STREAM 135 ;DOS CLOSE STREAM (HDR+1)=LETTER 136 ;DOS LOAD AUTO-LOAD FILE - FOLLOWS BOOT 137 139 140 141 142 ;DOS ;DOS ;DOS ;DOS DVAR EOF PTR PATH$

224 ;DISC PORTS 225 226 227 9 59H 79H 80H

;SAVE/LOAD EQUATES 000F= 001A= 001F= 0050= 000A= 0039= 0043= 004D= 0057= E003= 8000= HFG HDT HDN HDRL NMLEN YOSDISP YRGDISP XOSDISP XRGDISP RSBUFF SBO EQU EQU EQU EQU EQU EQU EQU EQU EQU 15 26 31 80 10 57 67 77 87 ;DISP TO HEADER FLAG ;DISP TO HEADER DATE/TIME ;DISP TO HEADER NUMBERS ;HDR BUFFER LEN ;MAX FILE NAME LEN

EQU 0E003H EQU 8000H

0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0294 0297 029A 029A 029D 029F 029F 02A0 02A3 02A6 02A6 02A9 02AA 02AB 02AE 02AE 02B1 02B2 02B5 02B9 02B9 02BC 02BD 02C1 02C4 02C4 02C7 02C8 02CB 02CC 02CF 02D0 02D2 02D4 02D4 02D6

C000= 4000= 4AFF= 4B00= 4B50= 4C00= 4C00= 4D00= 4D00= 4F00= 4F00= 50C0= 5080= 5100= 5121= 513F= 5140= 5140= 5188= 5188= 5190= 55D8= 5600= 5800= 58E0= FEB0= FEB0= FFD8= 00FF= 00FE= 00FD= 00FC= 00FB= 00FA= 00F9= 00F8=

SBN HPEND BSTACK HDR HDL INTSTK BUFF256 FPSB CDBUFF ISPVAL INSTBUF MSGBUFF FILBUFF ALLOCT MEMVAL TLBYTE NMBUFF FIRLET NMISTK SCRNBUF CHARSVAL PALTAB LINICOLS DKBU KTAB PVBUFF FILLSTK PALBUF SNDPORT KEYPORT MDIPORT VIDPORT URPORT LRPORT STATPORT CLUTPORT ;PIADVAL ;ATADVAL

EQU 0C000H EQU 4000H EQU 4AFFH EQU 4B00H EQU 4B50H EQU EQU EQU EQU 4C00H 4C00H 4D00H 4D00H ;HEAPEND ;ROOM FOR DO/LOOP/PROC STACK ;BASSTK ;HEADER LEN=50H. ALSO USED FOR PARPRO RENAME STK ;ADDRESS OF LOADED HEADER BUFFER ;USES DOWN TO 49EEH NORMALLY ;MUST BE PAGE-ALIGNED ;FPSBOT ;CODE BUFFER FOR E.G. MULTI-LDI. MAX LEN=0181H ;MULTI RRD, RLD, LDD (ROLL, SCROLL, CLS) ;STACK USED DOWN TO 4E98H ;INITIAL SP VALUE ;BUFFER FOR ROM1 XFER CODE, ETC. 0200H

EQU 4F00H EQU 4F00H EQU 5080H EQU 5100H EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU 5121H 513FH 5140H NMBUFF 5188H 5188H 5190H 55D8H 5600H 5800H 58E0H

EQU INSTBUF+01C0H ;MAX=MGT MSG ;MUST START AT PAGE EDGE. 32 BYTES - 1 PER PAGE ;PLUS TERMINATOR

;8 BYTES USED BY SCREEN$ FOR COMP. FORM

EQU 0FEB0H EQU PVBUFF EQU 0FFD8H EQU EQU EQU EQU EQU EQU EQU EQU 0FFH 0FEH 0FDH 0FCH 0FBH 0FAH 0F9H 0F8H

;IN SECOND SCREEN PAGE. HOLDS PRINT VARS OF NON;DISPLAYED SCREEN. BGFLG-SPOSNL AT FEB0-FEEB, ;CEXTAB/EXTAB AT FF7C-FFBB. FEEC-FF7B NOT USED. ;FF7C-FFD7 NOT USED. ;PALETTE OF NON-DISPLAYED SCREEN (ADDRESSED AT ;BFD8H FOR CONVENIENCE)

EQU 80H EQU 98H

;mode 1 screen at 8000H ;mode 1 attributes

INCLUDE EDITOR.SAM ;EDITOR.SAM CDBD05 C26704 CD8804 181A AF 32A45A 323A5C 2AEC5A 7C B5 C40500 2A3D5C E5 CD893D ED53825C 219402 E5 ED733D5C CD7C05 21C402 E5 CD3103 F5 CD9904 F1 FE16 3046 FE07 3842 EDAG: EDCX: EDITOR: EDER: CALL KSCHK JP NZ,ERRCHK CALL WARNBZ JR EDAG XOR A LD (XPTR+1),A LD (ERRNR),A LD HL,(EDITV) LD A,H OR L CALL NZ,HLJUMP LD HL,(ERRSP) PUSH HL CALL POFETCH LD (OLDPOS),DE LD HL,EDER PUSH HL LD (ERRSP),SP CALL AULN LD HL,EDLP PUSH HL CALL EDFK PUSH AF CALL NOISE POP AF CP 16H JR NC,ADCH1 CP 7 JR C,ADCH1 ;Z IF K/S CHANNEL ;BUZZ AND RE-PRESENT LINE IF K OR S CHANNEL

;NEEDED BY "INPUT LINE"

;AUTOMATIC LINE NUMBER ENTERED INTO LINE IF WANTED ;GET A KEY, OR ENTER USER-DEFINED KEY TEXT

EDLP:

;ENTER CHARS >=16H ;ENTER CHARS 00-06H

02D8 02D8 02DA 02DC 02DC 02DC 02DC 02DF 02E0 02E1 02E3 02E4 02E5 02E6 02E7 02EA 02EA 02ED 02F0 02F2 02F2 02F2 02F2 02F4 02F6 02F6 02F9 02FB 02FD 02FD 02FF 0301 0303 0303 0306 0307 0309 030B 030B 030D 030D 030F 030F 0310 0313 0314 0315 0317 0317 0318 031A 031A 031A 031A 031B 031E 031F 0322 0325 0328 0329 032A 032B 032E 0331 0331 0331 0331 0331 0334 0336 0337 0337 0339 033B 033B 033C 033F 0340 0341 0343 0343 0345 0346 0346 0349 034A 034B 034B 034C 034D 034E 034F 0351 0353 0353 0354 0354 0355 0356 0359 035C 035D

FE10 300E 216903 4F 5F 1600 19 5E 19 E5 C32F1F CD1A03 CDF004 1828 FE85 3019 213B5C FE20 280E CB86 FE3A 2017 3AB95A A7 3E3A 280F CBC6 180B 4F 3ABA5A 0F 79 3803 F7 BE5C 47 CD493C C5 CD2F1F 010100 CD111E F1 77 23 229A5A C3423C ADCH1: ADCH07: ADCH05: TWOKYS:

CP 10H JR NC,TWOKYS LD HL,EKPT-7 LD C,A LD E,A LD D,0 ADD HL,DE LD E,(HL) ADD HL,DE PUSH HL JP ADDRKC CALL ADCH1 CALL WAITKEY JR ADCH1 CP 85H JR NC,ADCH07 LD HL,FLAGS CP 20H JR Z,ADCH05 RES 0,(HL) CP ":" JR NZ,ADCH1 LD A,(LSTFT) AND A LD A,":" JR Z,ADCH1 SET 0,(HL) JR ADCH1 LD C,A LD A,(INQUFG) RRCA LD A,C JR C,ADCH1 RST 30H DW PRGR802-8000H LD B,A CALL R1OSR PUSH BC CALL ADDRKC LD BC,1 CALL MKRMCH POP AF LD (HL),A INC HL LD (KCUR),HL JP POPOUT

;JR IF 10H-15H (INK-OVER) ;ED KEY PTR TABLE

;DEAL WITH EDITING KEYS 07-0FH

;INSERT CONTROL CODE ;GET PARAM IN A ;JR TO INSERT PARAM

;CHANNEL "R" - INSERT CHARS AT KCUR, EXPANDING KEYWORDS. USED BY EDKY ADDCHAR:

;INSERT 00-85H (INCLUDES CONTROL CODES) ;"LEADING SPACE NEEDED" ;TEMP LIST FLG

;NO LEADING SPACE NEEDED IF LAST CHAR=SPACE, OR ;LAST CHAR =":" AND PRETTY LISTING ON.

;INSERT CHARS 85H+ IF TOKENS NOT TO BE EXPANDED ;PRINT KEYWORD (85-FE) OR FN (FFXX)

;ENTRY HERE ALLOWS ANYTHING TO BE INSERTED ;ROM1 OFF, URPORT SAVED ;CHAR ;ADDR KCUR ;MAKE ROOM FOR ONE CHAR. ALLOW ALL SPACE TO BE USED ;KEEP KCURP UNCHANGED SO SAME BASE AS ELINE OR WS ;RESTORE PREV LR AND URPORT STATUS

;GET A KEY, AND IF IT IS A DEF KEY, ENTER ASSOCIATED TEXT INTO LINE CDF004 FEC0 D8 FECA 300B 4F 3A675C 1F 79 3003 D690 C9 CDAA05 7A D8 E5 09 2B 7E FE3A 2001 0B F5 C5 CD2F1F CD1B1E EB C1 EDFK2: EDFK1: EDFK: CALL WAITKEY CP 192 RET C CP 202 JR NC,EDFK1 LD C,A LD A,(KPFLG) RRA LD A,C JR NC,EDFK1 SUB 144 RET CALL FNDKYD LD A,D RET C PUSH HL ADD HL,BC DEC HL LD A,(HL) CP ":" JR NZ,EDFK2 DEC BC PUSH AF PUSH BC CALL ADDRKC CALL MAKEROOM EX DE,HL POP BC ;RET IF NOT IN USER-DEFINED KEY RANGE ;JR IF NOT A KEYPAD KEY

;JR IF NUMBER FLAG NOT SET ;192-201 -> "0"-"9" ;LOOK FOR DEFINITION ;A=KEY CODE AGAIN ;RET IF NONE ;DEF. START ;HL=DEF END

;LOP OFF LAST CHAR IF IT IS ":" ;SAVE LAST CHAR ;LEN ;OPEN ROOM FOR DEF KEY TEXT ;DE=ROOM ;LEN

035E 035F 0360 0361 0363 0364 0367 036A 036B 036C 036F 036F 0370 0370 0370 0370 0371 0372 0373 0374 0375 0376 0377 0378 0379 0379 0379 0379 037C 037E 0381 0381 0384 0386 0386 0387 0389 038B 038B 038B 038B 038C 038D 038F 038F 0393 0393 0396 0399 039C 039F 03A0 03A1 03A2 03A2 03A6 03A7 03AA 03AB 03AC 03AE 03B1 03B4 03B7 03B8 03BB 03BD 03BE 03BF 03C0 03C2 03C3 03C6 03C7 03C8 03CB 03CE 03D1 03D2 03D5 03D6 03D9 03D9 03D9 03D9 03DC 03DC 03DD 03DF 03E0 03E1 03E1 03E3 03E3 03E4 03E5 03E6 03E7 03E9 03E9 03E9 03EB 03EB

F1 E1 F5 EDB0 EB 229A5A CD9904 F1 D1 C26504 C9 09 68 79 84 83 D0 EF C8 C2 3A715C E620 C2A504 CD7910 380D DF FE0D 2008 78 B1 2804 ED43495C CDA504 2A495C CD4D1A CDD604 7A B3 C8 ED5B515C D5 3A4A5C F5 E5 3EFF 324A5C CD6311 21B85A 7E 32B95A 3600 E3 2B F7 14F3 E1 3AB95A 77 F1 324A5C 2A945A 010500 09 229A5A E1 C37011 CDC204 2B ED52 19 D8 2810 2B 7E 23 3C 28F3 1808 7E EDRT: EDLT: EDLT2: EDKY2: EDKY1: EKPT:

POP AF POP HL PUSH AF LDIR EX DE,HL LD (KCUR),HL CALL NOISE POP AF POP DE JP NZ,EDENT RET ;ED KEY PTR TABLE DB DB DB DB DB DB DB DB DB EDKY-EKPT EDLT-EKPT-1 EDRT-EKPT-2 EDDN-EKPT-3 EDUP-EKPT-4 EDDLL-EKPT-5 EDENT-EKPT-6 EDDLR-EKPT-7 EDKPX-EKPT-8

;SRC ;CURSOR POSN AFTER DEF KEY TEXT ;RET ADDR ;ENTER LINE IF LAST CHAR WASN"T ":" ;BACK TO EDLP ;7 ;8 ;9 ;10 ;11 ;0C ;0D ;0E ;0F EDIT LEFT RIGHT DOWN UP DEL LEFT ENTER DEL RIGHT KEY PAD TOGGLE

;"PRINT" LINE TO ELINE EDITING BUFFER EDKY: LD A,(FLAGX) AND 20H JP NZ,CLEARSP CALL EVALLINO JR C,EDKY2 RST 18H CP 0DH JR NZ,EDKY2 ;FROM EDIT (CMD) LD A,B OR C JR Z,EDKY2 LD (EPPC),BC CALL CLEARSP LD HL,(EPPC) CALL FNDLINE CALL LNNM LD A,D OR E RET Z LD DE,(CURCHL) PUSH DE LD A,(EPPC+1) PUSH AF PUSH HL LD A,0FFH LD (EPPC+1),A CALL SETSTRM LD HL,LISTFLG LD A,(HL) LD (LSTFT),A LD (HL),0 EX (SP),HL DEC HL RST 30H DW OUTLINE POP HL LD A,(LSTFT) LD (HL),A POP AF LD (EPPC+1),A LD HL,(ELINE) LD BC,5 ADD HL,BC LD (KCUR),HL POP HL JP CHANFLAG CALL SETDE DEC SBC ADD RET HL HL,DE HL,DE C ;E.G. ENTER 123 (EDIT) SETS EPPC TO 123 ;CLEAR ELINE OR INPUT LINE ;GET LINE NUMBER OR ZERO ;DON"T EDIT LINE ZERO ;JP IF INPUT - CLEAR INPUT LINE ;SKIP ELINE NUMBER, GET IN BC. CY IF TOO BIG

;JR IF LINE NEITHER EMPTY NOR JUST LINE NO.

;LSB OF LINE NO ;ENSURE NO ">" IS PRINTED ;"R" O/P ;PUT PRTY LISTING STATUS WHERE CHAN "R" CAN SEE IT. ;PRETTY LISTING OFF - COLONS STAY COLONS! ;PT TO LINE START

;PREV LIST FLAG RESTORED.

;CURSOR ADDR IS AFTER 5-DIGIT LINE NUMBER

;CURSOR LEFT (ALSO CALLED BY DELETE LEFT) ;GET DE=START OF LINE (HL=CURSOR ADDR). NC ;KCUR MOVES LEFT ;RET IF AT LINE START ALREADY (NEW POSN WOULD BE ;FF SAVARS TERMINATOR) ;JR IF NEW POSN WOULD BE START OF LINE ;ELSE LOOK AT PREV. CHAR (*NOT* SAVARS TERM) ;MOVE AGAIN IF CURSOR WOULD POINT TO FN CODE AFTER ;FF PREFIX ;CHANGE KCUR UNLESS ALREADY AT LINE START

JR Z,EDRLC DEC HL LD A,(HL) INC HL INC A JR Z,EDLT2 JR EDRLC LD A,(HL)

03EC 03ED 03EF 03F0 03F0 03F1 03F3 03F3 03F6 03F7 03F7 03F7 03F8 03FB 03FD 03FF 03FF 0402 0403 0405 0406 0409 0409 040C 040E 0410 0410 0411 0412 0412 0413 0416 0419 041C 041D 0420 0422 0424 0424 0427 0427 0428 042B 042E 0431 0435 0435 0438 043A 043A 043A 043A 043D 043E 043F 043F 043F 043F 0440 0442 0444 0444 0445 0445 0445 0445 0448 0449 0449 044C 044D 044E 0450 0450 0450 0450 0451 0452 0453 0454 0456 0458 0458 045A 045C 045C 045D 0460 0461 0462 0462 0465 0465 0465 0466 0467 0467 0468 0468 046B 046E 046F 0470

23 FE0D C8 3C 28F8 229A5A C9 79 21715C CB6E 200A CD351F 7E FE0D 79 CA4308 21C35A FE0B 2802 34 34 35 118504 CD3504 2A915A 2B 3A715C E620 2803 2A8E5A 2B 229A5A CD9904 CD7605 ED5BDC5B 2A4F5C 183F 21675C 34 C9 7E FE0D 2005 C9 CDD903 D8 010200 7E 3C 2812 0D 2B 7E 23 FE16 300A FE10 3806 23 229A5A 2B 2B C3521E F1 F1 E1 223D5C 3A3A5C A7 C8 EDDL3: EDENT: ERRCHK: RESESP: EDDLL: EDDLC: EDUD3: EDUD25: EDUD2: EDRLC: EDDN: EDUP:

INC HL CP 0DH RET Z INC A JR Z,EDRT LD (KCUR),HL RET LD A,C LD HL,FLAGX BIT 5,(HL) JR NZ,EDUD2 CALL ADDRELN LD A,(HL) CP 0DH LD A,C JP Z,FUPDN LD HL,KPOS+1 CP 0BH JR Z,EDUD25 INC (HL) INC (HL) DEC (HL) LD DE,CUOP CALL KOPSET LD HL,(WORKSP) DEC HL LD A,(FLAGX) AND 20H JR Z,EDUD3 LD HL,(WKEND) DEC HL LD (KCUR),HL CALL NOISE CALL EDPRT LD DE,(MNOP) LD HL,(CHANS) JR DETOHL LD HL,KPFLG INC (HL) RET LD A,(HL) CP 0DH JR NZ,EDDLC RET ;EDITOR DELETE LEFT CALL EDLT RET C LD BC,2 LD A,(HL) INC A JR Z,EDDL3 DEC C DEC HL LD A,(HL) INC HL CP 16H JR NC,EDDL3 CP 10H JR C,EDDL3 INC HL LD (KCUR),HL DEC HL DEC HL JP RECLAIM2 POP AF POP AF POP HL LD (ERRSP),HL LD A,(ERRNR) AND A RET Z

;NO MOVE RIGHT IF AT LINE END ;MOVE AGAIN IF HIT FFH FN PREFIX

;A=0A ;KEY 0B/0A ;JR IF INPUT MODE

;JR IF EDIT MODE, ELINE EMPTY - MOVE ">" CURSOR ;CURSOR LINE

;CURSOR LINE ADJUSTED UP ;ALTER CHANNEL K TO SPECIAL O/P

;JR WITH HL=END OF ELINE IF EDIT MODE ;ELSE GET END OF INPUT LINE ;SET KCUR TO END OF LINE IN CASE NO MATCH OCCURS. ;PRINT LINE, SETTING KCUR TO MATCH WITH KPOS ;FBA7 EQU

KOPSET:

;TOGGLE KEYPAD BIT (FUNCTION/NUMBER PAD) EDKPX:

;EDITOR DELETE RIGHT (KEY 0E) EDDLR:

;RET IF HIT LINE END

;RET IF AT START OF LINE ;2 BYTES TO DELETE ;IF FN, DELETE FN PREFIX AND CODE ;ELSE DEL 1 BYTE ;CHAR BEFORE CHAR TO DEL. (PERHAPS FF SAVARS TERM.) ;JR IF >OVER ;JR IF NOT INK-OVER ;PT KCUR PAST PARAM, SO IT WILL BE DELED NEXT TIME ;DELETE CONTROL CODE NOW, NOT PARAM ;RECLAIM AT (HL) ;JUNK EDLP ;JUNK WARNBZ

;CARRIAGE RETURN USED BY LOCAL! CARET:

;RET IF NO ERRORS

0470 0471 0472 0472 0472 0472 0476 0476 0479 0479 047A 047B 047C 047D 047D 0480 0483 0485 0485 0485 0485 0485 0486 0488 0488 0488 0488 048B 048C 048E 048E 048E 048E 0490 0491 0494 0497 0499 0499 0499 0499 049C 049F 049F 04A0 04A2 04A2 04A3 04A5 04A5 04A5 04A5 04A8 04AA 04AA 04AD 04AF 04AF 04B2 04B3 04B3 04B4 04B7 04B7 04B9 04B9 04BB 04BE 04C1 04C2 04C2 04C2 04C2 04C3 04C6 04C8 04CA 04CA 04CD 04CE 04CE 04CF 04D2 04D3 04D3 04D3 04D3 04D4 04D5 04D6 04D6 04D6 04D6 04D6 04D6 04D7 04D8 04DA 04DA 04DB 04DC 04DD 04DE

F9 C9 ED5BB55A 2A515C 73 23 72 C9 11A73D 32BF5B 18F1 RESTOP: POCHNG: DETOHL:

LD SP,HL RET LD DE,(OPSTORE) LD HL,(CURCHL) LD (HL),E INC HL LD (HL),D RET

;ELSE RET TO ERROR HANDLER

;CONTROL CODE PARAM HANDLING ROUTINES

PRERESTOP: LD DE,CCRESTOP LD (TVDATA+1),A JR POCHNG ;SPECIAL PRINT O/P ROUTINE TO CHECK IF LS POSN MATCHES DESIRED CURSOR POSN AS ;EACH CHAR IS PRINTED. IF SO, KCUR IS SET TO ADDR OF THE CHAR IN THE LINE.

F7 1F75 3A735A 3D 20D9 2607 AF 323A5C 3A385C 1806 21FA00 3A395C 5F 1600 F7 1B6F CDC204 2805 2A8E5A 1804 2A915A 2B 2B CD4F1E DBFB E61F 32995A 229A5A C9 E5 3A715C E620 2004 CD351F BF F5 C42B1F EB F1 E1 C9

CUOP:

RST 30H DW CUOPP-8000H LD A,(DEVICE) DEC A JR NZ,ERRCHK LD H,7 XOR A LD (ERRNR),A LD A,(RASP) JR NS2 LD HL,250 LD A,(PIP) LD E,A LD D,0 RST 30H DW BEEPP2-8000H CALL SETDE JR Z,CLRSP2 LD HL,(WKEND) JR CLRSP3

;JP ROM1

;WARNING BUZZ - EDITOR ERRORS WARNBZ: ;REPORT ERROR IF NOT LOWER SCREEN DEVICE

;CALLED BY LINE ENTRY ERRORS RSPNS: ;"NO ERROR"

;PIP NOISE NOISE: NS2: BEEPER:

;RECLAIM ELINE-WORKSP-1 IF EDITING, OR WORKSP-WKEND-1 IF EDITING CLEARSP: ;JR IF EDIT MODE

CLRSP2: CLRSP3: SETKC: SETKC2:

LD HL,(WORKSP) DEC HL DEC HL CALL RECLAIM1 IN A,(URPORT) AND 1FH LD (KCURP),A LD (KCUR),HL RET PUSH HL LD A,(FLAGX) AND 20H JR NZ,SETDE2 CALL ADDRELN CP A

;PT TO 0D IN ELINE (NOT DELETED) ;CLEAR ELINE

;GET DE=START OF ELINE IF IN EDIT MODE (Z), ELSE DE PTS TO INPUT LINE IN WKSPACE SETDE:

SETDE2:

PUSH AF CALL NZ,ADDRWK EX DE,HL POP AF POP HL RET

;USED BY DEF KEYCODE PPRET:

;ENTRY: USUALLY, HL PTS TO LINE NUMBER, DE TO LINE NO OF PREVIOUS LINE, AND ;EXITS WITH DE=LINE NUMBER. HOWEVER, IF HL HIT PROG TERMINATOR, PREVIOUS LINE NO ;IS RETURNED, AND IF NO LINES EXIST, DE=0 7E 3C 2006 EB 7E 3C 57 5F LNNM: LD A,(HL) INC A JR NZ,LNNM2 EX DE,HL LD A,(HL) INC A LD D,A LD E,A ;JR IF NOT PROG TERMINATOR ;LOOK AT PREV LINE.

04DF 04E0 04E0 04E1 04E2 04E3 04E4 04E4 04E4 04E4 04E7 04E7 04E7 04E7 04EA 04ED 04EF 04EF 04F0 04F0 04F3 04F4 04F6 04F8 04F8 04FA 04FA 04FD 04FE 0500 0500 0501 0502 0502 0502 0502 0502 0502 0505 0507 050A 050A 050A 050A 050D 050E 0510 0511 0511 0514 0516 0517 0518 051A 051D 051E 0520 0521 0522 0522 0524 0526 0526 0528 0529 0529 052C 052F 0531 0531 0534 0535 0537 0538 0538 053B 053D 053F 0541 0541 0543 0545 0545 0546 0549 054B 054D 054D 054F 0550 0552 0552 0554 0556 0556 0558 055A 055A 055B 055F 055F 0560 0563

C8 56 23 5E C9 CDBD1C CD5D0E CD0A05 28F8 C9 213C5C 7E E620 2002 CBDE CDBA01 D8 28FA CF 16 WTKY2: WAITKEY: LNNM2:

RET Z LD D,(HL) INC HL LD E,(HL) RET CALL KBFLUSH CALL BRKCR CALL KYIP2 JR Z,WKBR RET LD HL,TVFLAG LD A,(HL) AND 20H JR NZ,WTKY2 SET 3,(HL) CALL INPUTAD RET C JR Z,WTKY2 RST 08H DB 22

;DE=0 IF NULL PROGRAM

;USED BY SCROLL/SAVE TO TAPE GTKBK: WKBR: ;USED BY GET AND CONTROL KEY ENTRY ROUTINE ;CHECK BREAK, STOP IF SO

;JR IF THE LOWER SCREEN IS GOING TO BE CLEARED ;"LINE TO BE PRINTED TO LS" ON 1ST CALL OF INPUTAD ;CALL I/P OF CURRENT CHANNEL - OFTEN KYIP BELOW ;RET IF GOT A KEY IN A ;JR IF NO KEY, AND NO ERRORS ;"END OF FILE"

;KEYBOARD INPUT - KYIP ADDR IS IN CHANNELS THAT ALLOW KB INPUT ;EXIT: CY IF GOT KEY IN A. NC,Z IF NO KEY. NC,NZ IF END OF FILE. 3A3C5C E608 C47605 213B5C A7 CB6E C8 3A085C CBAE F5 23 CB6E C4B506 F1 FE16 3F D8 FE06 2842 FE10 D8 32025C 113105 182E 213B5C 7E E620 C8 3A085C CBAE D630 3833 FE08 302F 47 3A025C FE12 380D FE15 78 2804 FE02 301E FE04 301A 78 ED5BDE5B 37 2A4F5C 23 KYPM5: KYPM6: KYCZ: KYPM: KYIP: LD A,(TVFLAG) AND 08H CALL NZ,EDPRT LD HL,FLAGS AND A BIT 5,(HL) RET Z LD A,(LASTK) RES 5,(HL) PUSH AF INC HL BIT 5,(HL) CALL NZ,CLSLOWER POP AF CP 16H CCF RET C CP 6 JR Z,KYCL CP 10H RET C LD (KDATA),A LD DE,KYPM JR KYCZ LD HL,FLAGS LD A,(HL) AND 20H RET Z LD A,(LASTK) RES 5,(HL) SUB 30H JR C,KYPN CP 8 JR NC,KYPN LD LD CP JR B,A A,(KDATA) 12H C,KYPM6 ;PRINT LINE TO LS IF REQUIRED

;USED BY GET KYIP2: ;NC ;RET IF NO KEY PRESSED

;TVFLAG

;ACCEPT ANYTHING >=16H ;JR IF CAPS LOCK ;ACCEPT 00-0FH ;SAVE CONTROL CODE 10H-15H (INK-OVER) ;RETURN WITH CONTROL CODE, AND ALTER I/P SO NEXT ;KEY IS ADJUSTED AND CHECKED FOR RANGE VS CC. ;RET (NC, Z) IF NO KEY ;"NO KEY" ;ONLY ACCEPT 30H+ ;LIMIT TO 0-7 ;10-15H ;JR IF INK OR PAPER; 0-7 OK ;PARAM ;JR IF OVER ;0/1 ONLY FOR FLASH/BRIGHT/INVERSE ;0-3 ONLY FOR OVER ;RESTORE NORMAL I/P ;KEY I/P CHANNEL ZAP

CP 15H LD A,B JR Z,KYPM5 CP 2 JR NC,KYPN CP 4 JR NC,KYPN LD A,B LD DE,(MNIP) SCF LD HL,(CHANS) INC HL

0564 0565 0568 0568 056B 056C 056E 056F 056F 0572 0574 0574 0575 0576 0576 0576 0576 0577 0579 0579 0579 0579 0579 057A 057C 057C 057C 057C 057F 0581 0582 0582 0585 0586 0587 0587 058A 058B 058D 058E 058E 0591 0595 0596 0597 0599 059A 059A 059B 059D 05A0 05A1 05A2 05A4 05A4 05A5 05A8 05A8 05A8 05A8 05A8 05A8 05A8 05A8 05A8 05A8 05AA 05AA 05AB 05AE 05AE 05AF 05B0 05B1 05B2 05B3 05B4 05B6 05B7 05B7 05B8 05B9 05BA 05BA 05BB 05BD 05BD 05BD 05BD 05BD 05C0 05C2 05C3 05C3 05C5 05C6 05C6 05C6 05C6 05C6 05C9 05CC 05CF

23 C37904 216A5C 7E EE08 77 213C5C CBDE BF C9 F7 9474 KYPN: KYCL:

INC HL JP DETOHL LD HL,FLAGS2 LD A,(HL) XOR 8 LD (HL),A LD HL,TVFLAG SET 3,(HL) CP A RET RST 30H DW EDPTR2-8000H ;REVERSE CAPS LOCK ;"COPY LINE TO SCREEN" ;NC,Z - NO KEY

;PRINT EDIT/INPUT LINE TO LOWER SCREEN EDPRT:

;FORCE NORMAL OUTPUT. USED BY E.G CURSOR OUTPUT TO ENSURE NORMAL OUTPUT EVEN ;IF PRINTING BETWEEN CONTROL CODE AND PARAMETER. F7 1360 3A715C E620 C0 3A885B A7 C8 CD351F 7E FE0D C0 2A495C ED4B895B 09 7C FEFF C8 E5 3EFF CD6311 C1 F7 ABF5 AF C36311 STRM0: FONOP: RST 30H DW FONOP2-8000H LD A,(FLAGX) AND 20H RET NZ LD A,(AUTOFLG) AND A RET Z CALL ADDRELN LD A,(HL) CP 0DH RET NZ LD HL,(EPPC) LD BC,(AUTOSTEP) ADD HL,BC LD A,H CP 0FFH RET Z PUSH HL LD A,0FFH CALL SETSTRM POP BC RST 30H DW PRNUMB1 XOR A JP SETSTRM

;AUTOMATIC LINE NUMBER ENTRY AULN: ;RET IF INPUT MODE ;RET IF AUTO OFF

;RET IF LINE NOT EMPTY

;RET IF LINE NUMBER TOO BIG ;CHANNEL "R"

;FNDKYD - FIND DEF KEY DATA ;ENTRY: A=KEY CODE (192-255) ;EXIT: HL PTS TO START OF DEFINITION, BC=LEN, D=KEY CODE. CY IF NOT FOUND ;USES AF,BC,D,HL ;DEFINITIONS TERMINATED BY FFH ;ENTRY AT DKTR FINDS POSN OF TERMINATOR,+3 3EFF 57 2ACE5B 7E 23 4E 23 46 23 C601 D8 3D BA C8 09 18F1 DKTR: FNDKYD: FDKL: LD A,0FFH LD D,A LD HL,(DKDEF) LD A,(HL) INC HL LD C,(HL) INC HL LD B,(HL) INC HL ADD A,1 RET C DEC A CP D RET Z ADD HL,BC JR FDKL ;CODE ;BC=LEN ;RET IF NOT FOUND - (TERMINATOR) ;RET IF FOUND ;PT TO NEXT DEFINITION

;Z IF K OR S CHANNEL. USED BY EDITOR AND INPUT 3A745A FE4B C8 FE53 C9 ;LIST.SAM CDB506 21495C CD3709 AUTOLIST: KSCHK: LD A,(CLET) CP "K" RET Z CP "S" RET INCLUDE LIST.SAM LIST, CLS CALL CLSLOWER LD HL,EPPC CALL REALN ;AUTOLIST, LIST, SPACAN,

;MAKE SURE EPPC HAS THE NUMBER OF A REAL LINE

05CF 05CF 05CF 05D2 05D5 05D5 05D8 05DA 05DD 05E0 05E2 05E5 05E9 05ED 05EE 05F0 05F1 05F3 05F3 05F6 05F8 05F9 05FA 05FD 0600 0601 0602 0603 0604 0604 0606 0608 0609 060B 060B 060D 060E 0610 0610 0611 0612 0613 0614 0615 0616 0617 061A 061B 061C 061E 061E 061F 0620 0621 0622 0622 0625 0629 062C 062C 062F 0631 0634 0637 0637 0639 063A 063A 063C 063D 0640 0643 0644 0647 0648 064A 064C 064C 064F 064F 0652 0655 0658 0659 0659 065C 065D 0660 0662 0662 0663 0663 0666 0669 066B 066C 066C 066D 066E 0670 0670 0670 0671

;USED BY AUTO 216C5C CD3709 CDF006 3E10 323C5C 216A5C CBC6 2A6C5C ED5B495C ED537F5A A7 ED52 EB 302F CD4D1A DBFB F5 E5 2A6C5C CD4D1A D1 0D 15 F1 0EFB ED40 B8 2005 ED52 19 300E 23 23 4E 23 46 09 F5 CDEF3F F1 23 18E6 56 23 5E EB 226C5C ED733F5C CD8406 213C5C CBA6 01CD08 C31F02 0E03 21 0E02 AF 323C5C CDC63A 79 DC6311 DF FE91 200D CD573A 111E03 CD621F 32B85A C9 CD3211 DF CD6C3A 2001 E7 CD4B3B 213B5C CB7E C8 F5 A7 2004 3D 32805A LIST2: LIST1: AUL25: AULLP: AUL2: LD HL,SDTOP CALL REALN CALL CLSUP LD A,10H LD (TVFLAG),A LD HL,FLAGS2 SET 0,(HL) LD HL,(SDTOP) LD DE,(EPPC) LD (LAST),DE AND A SBC HL,DE EX DE,HL JR NC,AUL4 CALL FNDLINE IN A,(URPORT) PUSH AF PUSH HL LD HL,(SDTOP) CALL FNDLINE POP DE DEC C DEC D POP AF LD IN CP JR C,URPORT B,(C) B NZ,AUL25 ;DITTO FOR SDTOP ;"S" ;"AUTOLIST, UPPER SCREEN" ;"SCREEN IS NOT CLEAR" ;LAST LINE THAT *MUST* BE LISTED IS EPPC ;HL=EPPC ;JR IF EPPC IS ABOVE OR EQU TO TOP LINE IN ;AN AUTOLIST - ALTER SDTOP ;ELSE ENSURE THAT SDTOP IS NOT TOO FAR ABOVE EPPC ;HL SHOULD BE ABOUT 0100 HIGHER THAN ADDR FOR SDTOP ;SO THAT IT APPEARS WITHOUT SCROLLING ;EPPC ADDR ;ADDR IS 512 BEFORE EPPC IN LISTING ;EPPC PAGE ;B=SDTOP PAGE ;JR IF SDTOP AND EPPC PAGES DON"T MATCH ;SBC SDTOP ADDR, EPPC-0200H ;HL=SDTOP ADDR AGAIN ;JR IF DIFF <100H

SBC HL,DE ADD HL,DE JR NC,AUL3 INC HL INC HL LD C,(HL) INC HL LD B,(HL) ADD HL,BC PUSH AF CALL CHKHL POP AF INC HL JR AULLP LD D,(HL) INC HL LD E,(HL) EX DE,HL LD (SDTOP),HL LD (LISTSP),SP CALL LIST5 LD HL,TVFLAG RES 4,(HL) LD BC,IOPOF JP R1XJP LD C,03H DB 21H LD C,02H XOR A LD (TVFLAG),A CALL RUNFLG LD A,C CALL C,SETSTRM RST 18H CP 91H JR NZ,LIST1 CALL SSYNTAX6 LD DE,0300H+30 CALL LIMBYTE LD (LISTFLG),A RET CALL PRHSH1 RST 18H CALL COMMASC JR NZ,LIST2 RST 20H CALL BRKLSSL LD HL,FLAGS BIT 7,(HL) RET Z PUSH AF AND A JR NZ,LIST3 DEC A LD (LAST+1),A

;NEXT POSSIBLE SDTOP ADDR TO CONSIDER

AUL3:

;NEW SDTOP LINE NO. ;SO "SCROLL" CAN ABORT AT END OF SCREEN. ;LIST LINES FROM LINE HL, INDENTED ;ALWAYS COME BACK HERE, EVEN IF "SCROLL" ABORTED ;ENSURE INDENTED OP IS OFF, TURN ROM1 OFF ;"JR+2" ;NON-AUTOLIST (BIT 4=0)

AUL4: AULX:

LLIST: LIST:

;FORMATTOK ;SKIP, GET NUMBER ;0 IF LIST FORMAT 0 - NO INDENT ;POSSIBLE "#" ;COMMA OR SEMICOLON ;SKIP ,/; ;CALL BRACKETLESS SLICER SR - POSSIBLE ST TO FIN ;CY IF ERROR ;RET IF NOT RUNNING ;CY SHOWS ERROR !! ;JR IF NOT 1-NUMBER SLICER ;ELSE TURN EG LIST 10 INTO LIST 10 TO END (BUT ; DELETE KEEPS DELETE 10 AS IS) ;A=FF ;LAST LINE=HIGH NUMBER

0674 0674 0677 0678 0679 067B 067B 067C 067F 067F 0680 0680 0681 0684 0684 0687 068A 068D 068D 068E 0690 0690 0690 0690 0691 0694 0697 0698 0698 0699 069B 069B 069D 069F 069F 06A0 06A2 06A2 06A5 06A5 06A8 06AA 06AD 06AE 06AE 06AE 06AE 06B0 06B2 06B2 06B5 06B5 06B8 06B9 06BA 06BB 06BC 06BE 06BE 06BE 06BE 06BF 06C2 06C3 06C4 06C5 06C6 06C7 06C8 06CB 06CE 06D1 06D4 06D7 06DA 06DD 06E0 06E0 06E3 06E5 06E8 06EB 06EC 06EF 06F0 06F0 06F0 06F2 06F2 06F3 06F3 06F4 06F5 06F6 06F7 06F7 06FA 06FD 06FF 06FF 0700 0702 0702

2A7D5A 7C B5 2805 F1 DA391D F5 F1 22495C CD4D1A 018D06 C3C508 F7 E472 AF 32BE5A 32C05A C9 AF 1813 FE23 2003 F7 7D6D CD503A CD331D 1E06 CD6628 79 FE01 2840 CDF206 213F5A 7E 2B 96 3D 2822 7E 32585A 23 7E 3D 2B 77 3D 32595A 2A3C5A 22565A 2A485A 22515A 3A455A 324E5A CD6D0B CD6111 3E01 323C5C CD4007 24 226E5A C9 3E01 F5 EF E1 E1 33 CD2E20 CD9327 3803 69 2600 22425A

LIST3:

LD LD OR JR

HL,(FIRST) A,H L Z,LIST4

;GET FIRST LINE ;IGNORE OUT OF RANGE CAUSED BY LIST 0 ;CY SHOWS IF OUT OF RANGE

POP AF JP C,IOORERR PUSH AF LIST4: LIST5: LSTLNS: POP AF LD (EPPC),HL CALL FNDLINE LD BC,LSTLNS JP IOPCL RST 30H DW LSTR1-8000H XOR A LD (NXTSPCS),A LD (NXTHSPCS),A RET XOR A JR CLSBL CP "#" JR NZ,CLSNH RST 30H DW CLSHS-8000H CLSNH: CALL SYNTAX3 CALL GETBYTE LD E,6 CALL GRAREC LD A,C ;BLITZ ENTRY CLSBL: CP 1 JR Z,CLU1 CALL CLU1 CLSLOWER: LD HL,LWBOT LD A,(HL) DEC HL SUB (HL) DEC A JR Z,CLSL2 LD A,(HL) LD (WINDTOP),A INC HL LD A,(HL) DEC A DEC HL LD (HL),A DEC A LD (WINDBOT),A LD HL,(LWRHS) LD (WINDRHS),HL LD HL,(M23PAPP) LD (M23PAPT),HL LD A,(ATTRP) LD (ATTRT),A CALL CLSWIND CLSL2: CALL STREAMFD LD A,1 LD (TVFLAG),A CALL CLWC INC H LD (SPOSNL),HL RET LD A,1 PUSH AF DB DB DB DB CALC STKZERO STKZERO EXIT

;NEW EPPC=FIRST LISTED LINE

;CANCEL SPACES SPACAN:

MCLS: CLS:

;28 BYTES FOR CLS #

;0 IF CLEAR ENTIRE SCREEN ;BLITZ CODE FOR "CLS" ;PARAM OR 0

;SUB LWTOP ;JR IF LW IS ONLY 2 LINES HIGH ;DEFINE A WINDOW COVERING LW OVERLAP ONTO UPPER ;WINDOW (ABOVE NORMAL 2-LINE SIZE) ;LWTOP ;LWBOT ;LWTOP IS 1 LESS THAN LWBOT ;RHS AND LHS ;ENSURE UW COLOURS ;TEMP OVERLAP WINDOW CLEARED ;"K" ;LS, DO NOT CLEAR ON KEYSTROKE, NOT AUTOLIST ;CLEAR WINDOW AND RESET CHANNEL ;POSN=LHS, TOP+1 ;"CLEAR WINDOW, NOT ENTIRE SCREEN" ;GRAPHICS COORDS 0,0

CLSUP: CLU1:

CALL SETESP CALL GTFCOORDS JR C,CLU2 LD L,C LD H,0 CLU2: LD (XCOORD),HL

;ENSURE NO ERROR ON CLS EVEN IF XOS ETC ODD ;GET PHYSICAL COORDS FROM XOS ETC AND 0,0 ;JR IF THINPIX - HL=X, B=Y ;HL=X NOW

0705 0706 0709 070A 070D 070E 0711 0714 0715 0718 071B 071C 071D 071F 071F 0722 0725 0726 0726 0729 072C 072F 0731 0731 0731 0731 0734 0736 0737 0737 0738 0739 073B 073B 073C 073F 0740 0740 0743 0743 0747 074A 074D 074F 074F 0752 0753 0753 0753 0753 0756 0758 075A 075A 075C 075E 0761 0762 0765 0766 076A 076C 076F 0770 0772 0772 0774 0777 0779 0779 077B 077F 0782 0782 0785 0786 0787 078B 078D 078E 078E 078F 0790 0791 0792 0793 0794 0795 0796 0798 0798 0799 079B 079B 079F 07A0 07A3 07A3 07A3 07A3 07A3 07A5 07A6

78 32415A E1 223D5C AF 32A45A 323A5C 3C 328C5C CD5E11 F1 A7 2007 CD5307 CD4307 BF C44007 226C5A 216A5C CB86 21525B 061E AF 77 23 10FC 3D 328D5B C9 CD6D0B ED5B515C 21DC5B 010400 EDB0 2A575A C9 3A405A FE02 301F 2698 1E00 010280 F5 CD8207 F1 ED5B455A 26B8 010280 A7 2010 269B 010130 1809 26E0 ED5B485A 010600 CDA83F 53 F3 ED73C85A 2E00 F9 D5 D5 D5 D5 D5 D5 D5 D5 10F6 0D 20F3 ED7BC85A FB C3BF3F CLS1: CLSG: CLSE: CLWC: CLWC2: ZTEL: CLS2:

LD A,B LD (YCOORD),A POP HL LD (ERRSP),HL XOR A LD (XPTR+1),A LD (ERRNR),A INC A LD (SCRCT),A CALL STREAMFE POP AF AND A JR NZ,CLS2 CALL CLSE CALL CLWC2 CP A CALL NZ,CLWC LD (SPOSNU),HL LD HL,FLAGS2 RES 0,(HL) LD HL,LPT LD B,30 XOR A LD (HL),A INC HL DJNZ ZTEL DEC A LD (LNPTR),A RET CALL CLSWIND LD DE,(CURCHL) LD HL,MNOP LD BC,4 LDIR LD HL,(WINDLHS) RET LD A,(MODE) CP 2 JR NC,CLS1 LD H,98H LD E,0 LD BC,8002H PUSH AF CALL CLSG POP AF LD DE,(ATTRP) LD H,0B8H LD BC,8002H AND A JR NZ,CLSG LD H,9BH LD BC,3001H JR CLSG LD H,0E0H LD DE,(M23PAPP) LD BC,0006H CALL SPSSR LD D,E DI LD (TEMPW1),SP LD L,0 LD SP,HL PUSH PUSH PUSH PUSH PUSH PUSH PUSH PUSH DJNZ DE DE DE DE DE DE DE DE CLSLP

;RESET ANY "?" ERROR PTR ;"OK" ;"S"

;CLEAR ENTIRE SCREEN IF CLS OR CLS 0 ;RESET CHANNEL ;Z ;CLEAR WINDOW, RESET CHANNEL ;"SCREEN IS CLEAR"

;ZERO TABLE ENTRIES

;FF SHOWS NO CURSOR LINE

;REFRESH CHANNEL O/P AND I/P ADDRESSES IN CASE ;THEY HAVE BEEN ALTERED E.G. FOR COLOUR I/P ;GET TOP LEFT OF WINDOW (FOR PRINT POSN)

;CLEAR ENTIRE SCREEN - QUICKLY

;END OF MODE 0/1 PATTERN DATA ;CLEAR WITH ZEROS ;DO 1800H BYTES ;CLEAR M0/M1 PATTERN DATA ;MODE ;END OF MODE 1 ATTRS ;DO 1800H BYTES ;JR IF MODE 1 ;END OF MODE 0 ATTRS ;DO 0300H BYTES

;CLEAR DFFF-8000H WITH M3PAPP ;STORE PAGE, SELECT SCREEN

CLSLP:

;DO 16 BYTES AT A TIME AT ABOUT 7 Ts/BYTE ;DO 1000H BYTES ;RESET CURRENT UR PAGE

DEC C JR NZ,CLSLP LD SP,(TEMPW1) EI JP RCURPR ;BASIC"S PRINT COMMAND

0E03 21

LPRINT:

LD C,3 DB 21H

07A6 07A8 07AB 07AC 07AF 07B1 07B4 07B7 07B7 07B8 07BB 07BD 07BD 07C0 07C1 07C1 07C3 07C3 07C6 07C9 07CA 07CC 07CC 07CE 07CF 07CF 07CF 07CF 07CF 07D1 07D1 07D1 07D1 07D4 07D5 07D5 07D6 07D7 07D8 07D8 07D8 07D8 07D8 07D8 07D8 07D9 07DB 07DD 07DD 07DF 07E1 07E3 07E3 07E5 07E6 07E7 07E7 07E9 07E9 07EC 07EC 07ED 07ED 07EF 07F0 07F0 07F2 07F3 07F3 07F5 07F6 07F7 07F8 07F8 07F8 07F9 07FB 07FD 07FD 0800 0800 0803 0804 0806 0808 0808 080A 080C 080C 080F 080F 0812 0813 0816 0817 0818 0819 081A 081A 081A 081A 081B 081B

0E02 CDC63A 79 21BA5A CBC6 DC6311 CD8E11 DF CDED07 280F CDD807 C8 30FA CDF807 CDD807 C8 30F1 FE29 C8

PRINT:

LD C,2 CALL RUNFLG LD A,C LD HL,INQUFG SET 0,(HL) CALL C,SETSTRM CALL TEMPS RST 18H CALL PRTERM JR Z,PRINT3 CALL PRSEPR RET Z JR NC,MPRSEPLP CALL PRITEM CALL PRSEPR RET Z JR NC,MPRSEPLP

;"IN QUOTES" - MEANS KEYWORDS NOT EXPANDED

PRINT2: MPRSEPLP:

;JR IF E.G. PRINT : ;RET IF TERMINATOR FOUND ;LOOP UNTIL A NON-SEPARATOR IS FOUND

PRINT3:

CP ")" RET Z

;AVOID CR AFTER EMBEDDED PRINT ITEMS IN INPUT ;E.G. INPUT "OLD VALUE:";(X);" NEW:";X

;ENTRY FROM INPUT. CR IF RUNNING 0E0D CDC63A D0 79 D7 C9 RUNCR: PRCIFRN: LD C,0DH CALL RUNFLG RET NC LD A,C RST 10H RET ;PRINT SEPARATORS - CONSIDER ;/,/" ;EXIT: Z IF SEPARATOR FOLLOWED BY TERMINATOR, NZ, CY IF NOT SEPARATOR, NZ, NC ;IF SEPARATOR NOT FOLLOWED BY TERMINATOR. DF FE3B 280F 0E06 FE2C 2806 FE27 37 C0 0E0D CDD107 E7 FE29 C8 FE3A C8 FE0D 37 3F C9 DF FE88 200B CD573A CD2E1D 51 3E17 1815 FE87 2017 CD5E3A CD331D F5 CD331D 51 F1 5F FE 57 3E16 ATSR2: ATSR3: PRITEM2: PRITEM: PRSEPR2: PRSEPR3: PRTERM: PRSEPR: RST 18H CP ";" JR Z,PRSEPR3 LD C,6 CP "," JR Z,PRSEPR2 CP "'" SCF RET NZ LD C,0DH CALL PRCIFRN RST 20H CP ")" RET Z CP ":" RET Z CP 0DH SCF CCF RET RST 18H CP TABTOK JR NZ,PRITEM2 CALL SSYNTAX6 CALL GETINT LD D,C LD A,17H JR ATSR4 CP ATTOK JR NZ,PRITEM4 CALL SSYNTAX8 CALL GETBYTE PUSH AF CALL GETBYTE LD D,C POP AF LD E,A DB 0FEH ;PRINT AT LINE A, COL E LD D,A LD A,16H ;"AT" CONTROL CODE ;COL ;C=ROW ;D=ROW, E=COL ;"JR+1" ;NC WITHOUT ALTERING ZERO FLAG ;PRINT C IF RUNNING - CHR$ 6 FOR COMMA, CR FOR """ ;SKIP SEPARATOR ;PRINT C IF RUNNING

081D 081D 081E 081F 0820 0821 0822 0823 0823 0826 0827 0827 0829 082C 082C 082F 0830 0830 0832 0833 0835 0835 0838 0839 0839 083C 083C 083F 0840 0842 0843 0843 0843 0843 0843 0843 0843 0843 0844 0847 0848 084B 084E 084E 0851 0853 0856 0856 0857 0859 085B 085B 085B 085B 085E 085F 0862 0863 0864 0865 0866 0867 086B 086C 086D 086F 0870 0870 0871 0872 0874 0875 0875 0876 0878 0878 0879 087B 087C 087E 087F 0880 0882 0882 0884 0884 0885 0885 0885 0885 0886 0889 088C 088D 0890 0892 0893 0894 0897 0897 0898 089B 089C

D7 7A D7 7B D7 C9 CD6613 D0 FE23 CA3511 CD083B D0 DBFB F5 2004 CDDC3F BF C47E01 CD1300 F1 D3FB C9

ATSR4:

RST 10H LD A,D RST 10H LD A,E RST 10H RET CALL CITEMSR RET NC CP "#" JP Z,PRHSH2 CALL EXPTEXPR RET NC IN A,(URPORT) PUSH AF JR NZ,PRITEM5 CALL GETSTRING CP A ;RET IF NOT RUNNING ;JR IF NUMERIC EXPR. ;UNSTACK STRING, SEL PAGE ;Z ;GET STR$ OF NUMBER AS BC BYTES AT (DE)

PRITEM4:

PRITEM5:

CALL NZ,JPFSTRS CALL PRINTSTR POP AF OUT (URPORT),A RET

;LPT = LINE PTR TABLE ;TABLE OF 30 BYTES, EACH 0 IF NO LINE NUMBER ON THAT LINE, OR FF IF THERE IS. ;LNPTR VAR. HOLDS NO OF LINE WITH CURSOR, OR >3FH IF NONE F5 CD5E11 C1 CD4E08 C3A405 3A8D5B FE40 D2C605 78 FE0B 207A ;CURSOR UP 2A495C E5 CD4D1A 62 6B 46 23 4E ED43495C E1 A7 ED42 C8 D5 F7 5CDE D1 A7 280C 3D C652 6F D652 46 04 107C 18F1 D5 3C 32B75A 2A6C5A E5 2A575A 3E41 91 67 226C5A EB CDBF08 AF 32B75A MWDN: LPUL: LD HL,(EPPC) PUSH HL CALL FNDLINE LD H,D LD L,E LD B,(HL) INC HL LD C,(HL) LD (EPPC),BC POP HL AND A SBC HL,BC RET Z PUSH DE RST 30H DW EROC2 POP DE AND A JR Z,MWDN DEC A ADD A,>LPT LD L,A SUB A,>LPT LD B,(HL) INC B DJNZ LPC JR LPUL PUSH DE INC A LD (DMPFG),A LD HL,(SPOSNU) PUSH HL LD HL,(WINDLHS) LD A,41H SUB C LD H,A LD (SPOSNU),HL EX DE,HL CALL IOUTLNC XOR A LD (DMPFG),A FUPDN: PUSH AF CALL STREAMFE POP BC CALL FUPDN2 JP STRM0 LD A,(LNPTR) CP 40H JP NC,AUTOLIST LD A,B CP 0BH JR NZ,LPD ;DIRECTION CODE - 0BH=UP, 09H=DOWN ;"S" CHANNEL

FUPDN2:

;JP IF THERE IS NO CURSOR ON-SCREEN ;UP ;JR IF DOWN

;HL AND DE PT TO LINE *BEFORE* EPPC. DE USED LATER ;BC=PREV LINE NO ;OLD EPPC ;RET IF AT TOP OF PROG - EPPC UNCHANGED ;GET A/C=LNPTR, H=TABLE MSB, ERASE OLD CURSOR ;JR IF AT WINDOW TOP ALREADY - MOVE WINDOW DOWN ;ADD OFFSET ;HL=ADDR IN TABLE (MUST BE INSIDE A PAGE) ;JR IF FOUND A LINE WITH A LINE NUMBER ;ELSE LOOP ;START OF NEW EPPC ;A=1 ;"DUMP OUTPUT" ;L=LHS ;LINES FROM TOP OF PREV CURSOR POSN ;START AT HI LN, PAST ANY WINDBOT, NO SCROLLING ;PT HL TO FIRST CHAR ;DUMMY PRINT OF LINE TO GET LENGTH

;GET SCREEN LINES TAKEN BY PROGRAM LINE STARTING AT DE (LEN OF NEW EPPC)

089F 08A2 08A5 08A6 08A7 08A8 08AB 08AD 08AE 08B0 08B0 08B1 08B1 08B2 08B5 08B8 08BB 08BE 08BF 08BF 08C2 08C2 08C5 08C5 08C7 08CA 08CD 08CD 08CE 08D1 08D2 08D2 08D3 08D5 08D5 08D5 08D5 08D8 08D9 08DC 08DD 08DE 08E0 08E1 08E1 08E2 08E3 08E7 08E8 08E9 08EA 08EB 08EC 08EE 08EF 08EF 08F0 08F1 08F3 08F3 08F5 08F6 08F8 08F9 08FA 08FB 08FD 08FD 08FE 08FE 08FF 0902 0903 0906 0907 0909 090C 090D 090F 090F 0912 0913 0916 0917 091A 091B 091E 0921 0922 0925 0926 0929 092C 092F 0932 0934 0935 0937 0937 0937 0937 0937 0937

21585A 3A595A 96 3C 67 3A6D5A D640 BC 3801 7C E1 226C5A CD8A0B 2A575A 226C5A E1 CD9006 01D208 3E01 32BD5A CD1600 AF 32BD5A C9 F7 1473 2A495C E5 CD4309 E1 A7 ED52 C8 19 E5 ED5B585A 7A 93 3C F5 F7 5CDE D1 3C BA 301C C652 6F D652 46 04 05 28F2 E1 4F 3A585A 81 328D5B 79 1E05 CD1A08 F7 6475 CD3E09 AF 32535A 5F 218C5C 73 21585A 3A8D5B 96 CD1A08 E1 CD4D1A 3ABC5A 32BE5A CDC208 3E0D D7 188B LPC: LPDL: MWDN2:

LD HL,WINDTOP LD A,(WINDBOT) SUB (HL) INC A LD H,A LD A,(SPOSNU+1) SUB 40H CP H JR C,MWDN2 LD A,H POP HL LD (SPOSNU),HL CALL EDRSADN LD HL,(WINDLHS) LD (SPOSNU),HL POP HL CALL SPACAN LD BC,OUTLINC LD A,1 LD (INDOPFG),A CALL BCJUMP XOR A LD (INDOPFG),A RET RST 30H DW OUTLINE-8000H LD HL,(EPPC) PUSH HL CALL ADVEPPC POP HL AND A SBC HL,DE RET Z ADD HL,DE PUSH HL LD DE,(WINDTOP) LD A,D SUB E INC A PUSH AF RST 30H DW EROC2 POP DE INC A CP D JR NC,MWUP ADD A,>LPT LD L,A SUB A,>LPT LD B,(HL) INC B DEC B JR Z,LPDL POP HL LD C,A LD A,(WINDTOP) ADD A,C LD (LNPTR),A LD A,C LD E,5 CALL ATSR2 RST 30H DW PRLCU-8000H CALL ADVSTOP XOR A LD (OVERT),A LD E,A LD HL,SCRCT LD (HL),E LD HL,WINDTOP LD A,(LNPTR) SUB (HL) CALL ATSR2 POP HL CALL FNDLINE LD A,(OLDSPCS) LD (NXTSPCS),A CALL IOUTLN LD A,0DH RST 10H JR IOUTLN

;END LINE POSN ;A=LINES TAKEN BY PROGRAM LINE ;CP WINDOW HEIGHT ;JR IF LINE <WIND HEIGHT

;SCROLL DOWN "A" LINES ;L=LHS, H=TOP ;PRINT POSN AT 0,0 ;LINE START ;**

IOUTLNC: IOUTLN: IOPCL: IOPOF: OUTLINC:

;CALL BC WITH INDENT O/P ON

;CURSOR DOWN LPD: ;MOVE EPPC DOWN ONE - NEW EPPC IN DE ;RET IF EPPC HASN"T CHANGED - END OF PROG ;OLD EPPC ;BOT ;LINE NUMBER OF BOTTOM LINE+1, REL. TO WINDOW ;GET A/C=LNPTR, H=TABLE MSB, ERASE OLD CURSOR ;D=BOTTOM LINE+1 ;JR IF AT WINDOW BOT ALREADY - MOVE WINDOW UP ;ADD OFFSET ;HL=ADDR IN TABLE (MUST BE INSIDE A PAGE) ;B=0 IF NO LINE NO, OR FF ;LOOP IF NO LINE NO. ON LINE ;JUNK OLD EPPC

;NEW LINE WITH CURSOR

MWUP:

;MOVE TOP OF SCREEN PROG LINE DOWN BY ONE ;OVER 0 SO OVERPRINTING LOOKS OK ;LH COLUMN ;PREVENT SCROLL PROMPT

;OLD EPPC ;** RESET SPACES TO SAME FOR 2ND PRINT ;OLD EPPC MAY OVERLAP SCREEN BOTTOM - SO PRINT IT ;AGAIN, PERHAPS FORCING SCROLLING. ;CR ;PRINT NEW EPPC - IT WILL HAVE A ">" CURSOR

;ENSURE SYS VAR PTED TO BY HL CONTAINS A LINE NUMBER THAT EXISTS. (IF IT DOES ;NOT, REPLACE IT WITH NO. OF FOLLOWING "REAL" LINE) 7E REALN: LD A,(HL)

0938 0939 093A 093B 093C 093E 093E 093E 093E 093E 0941 0943 0943 0946 0946 0947 0948 0949 094A 094B 094C 094C 094F 0952 0953 0954 0955 0956 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0957 0958 095B 095C 095D 095E 095F 0961 0961 0963 0965 0965 0967 0969 0969 096B 096D 096D 096E 0971 0971 0972 0975 0976 0976 0977 0977 097A 097D 097F 0981 0981 0984 0986 0988 0988 098B 098D 098F 098F 0992 0992 0995 0995 0998 0999 099C 099D 099F 099F 09A2 09A5 09A5 09A8 09A9 09AB 09AB

23 E5 66 6F 180E

INC HL PUSH HL LD H,(HL) LD L,A JR ADVAC

;HL=LINE NO

;ADVANCE LINE NUMBER IN SYS. VAR TO NEXT LINE IF POSSIBLE ;EXIT: DE=NEW LINE NUMBER, HL IS UNCHANGED 216C5C 1803 21495C 7E 23 E5 66 6F 23 CD4D1A CDD604 E1 72 2B 73 C9 ADVSTOP: ADVEPPC: ADVAN: LD HL,SDTOP JR ADVAN LD HL,EPPC LD A,(HL) INC HL PUSH HL LD H,(HL) LD L,A INC HL CALL FNDLINE CALL LNNM POP HL LD (HL),D DEC HL LD (HL),E RET ;SCREEN DISPLAY TOP PROGRAM LINE

;HL=LINE NO FROM SYS VAR. ;FIND ADDR OF NEXT LINE, OR PROG END ;GET LINE NO. IN DE (OR PREV LINE NO. IF PROG END)

ADVAC:

INCLUDE ROLL.SAM

;TABSR, CLS, PRINT ;FUPDN, IOUTLN, PRLCU, ZTENTS, LNLEN, ;ATSR, REALN, ADVAN ;CALCPIX, NEXTUP, NXTDOWN, CLSWIND, EDRS, CRTBF

;****************************************************************************** ;ROLL.SAM - EG ROLL DIR,PIX,X,Y,W,L ; ROLL DIR,PIX ; ROLL DIR ; SCROLL IS SIMILAR BUT NO WRAP-ROUND ; SCROLL CLEAR SCROLL PROMPT OFF ; SCROLL RESTORE - SCROLL PROMPT ON ;FROM JUMP TABLE: ;B=PIX, C=DIR (1-4), HL=TOP LHS COORDS, D=LEN, E=W, A=ROLL/SCROLL 1D 32D05A D5 E5 78 F5 1865 3EFF 1812 FEB3 2804 D6BA 2009 47 CD143B 78 32BB5A C9 AF 32D05A CDE43A FE2C 2807 CD153B 3E01 180D CDE33A FE2C 2810 CD153B CD331D 21FFC0 E5 210000 E5 1823 CDD33A CD153B CD331D A7 2833 F5 ROLL5: ROLL4: SCRNINOT: RSCOMM: JROLL: DEC E LD (TEMPB3),A PUSH DE PUSH HL LD A,B PUSH AF JR JROLL2 LD A,0FFH JR RSCOMM CP 0B3H JR Z,SETPROMPT SUB 0BAH JR NZ,SCRNINOT SETPROMPT: LD B,A CALL SABORTER LD A,B LD (SPROMPT),A RET XOR A LD (TEMPB3),A CALL EXPT1NUM CP "," JR Z,ROLL4 CALL CHKEND LD A,1 JR ROLL5 CALL SEXPT1NUM CP "," JR Z,ROLL6 CALL CHKEND CALL GETBYTE LD HL,0C0FFH PUSH HL LD HL,0000H PUSH HL JR ROLL7 CALL SEXPT4NUMS CALL CHKEND CALL GETBYTE AND A JR Z,IOORHP2 PUSH AF ;PIXELS ;LEN=192, W-1=255 ARE DEFAULTS ;Y=0, X=0 (TOP LHS) ARE DEFAULTS ;SKIP X,Y,W,L - SR SHARED WITH GRAB ;L ;LENGTH MUST BE 1-255 INITIALLY ;LENGTH ;ROLL=FF, SCROLL=00 ;DIRECTION ;GET PIX IF SPECIFIED ;ELSE CHECK END AND USE DEFAULT ;OF 1-PIXEL ROLL ; PIXELS ;GET AREA IF SPECIFIED ;CLEARTOK ;JR IF PROMPT TO BE TURNED OFF ;RESTORETOK - ZERO RESULT FOR "PROMPT ON" ;SKIP CLEAR/RESTORE ;0=PROMPTS ON ;ROLL=FF, SCROLL=00

ROLL: SCROLL:

ROLL6:

09AC 09AF 09B1 09B2 09B3 09B4 09B6 09B6 09B7 09B8 09B9 09BC 09BE 09BF 09C2 09C2 09C3 09C6 09C6 09C7 09CA 09CD 09D0 09D1 09D2 09D3 09D4 09D5 09D7 09D7 09D8 09D9 09DA 09DC 09DE 09DE 09DF 09E0 09E0 09E1 09E2 09E4 09E4 09E6 09E8 09E8 09EA 09EC 09EC 09ED 09EE 09EE 09EF 09F0 09F2 09F2 09F3 09F3 09F4 09F5 09F6 09F6 09F7 09F9 09FB 09FC 09FE 09FF 0A00 0A01 0A03 0A06 0A06 0A07 0A09 0A09 0A0A 0A0A 0A0A 0A0A 0A0A 0A0B 0A0D 0A0E 0A10 0A10 0A11 0A12 0A13 0A14 0A16 0A17 0A17 0A1A 0A1B 0A1D 0A1E 0A1E 0A1F 0A20 0A21 0A22 0A23

CD2E1D CB81 0B 78 A7 2028 F1 47 C5 CD8927 CB81 C5 CD331D F5 CD331D C5 CD9512 CDD211 CDA83F C1 F1 E1 D1 A7 2807 47 79 3D FE04 3802 CF 1E 7C 82 38FA FEC1 30F6 CB51 2802 67 25 7D 83 38EC 7A D9 47 D9 37 CB1C CB1D 7B C601 1F 5F 50 CB41 CAD90A 1D 1036 51 NTRDOWN: IOORHP2: ROLL75: ROLL7: JROLL2:

CALL GETINT RES 0,C DEC BC LD A,B AND A JR NZ,IOORHP2 POP AF LD B,A PUSH BC CALL GTFIDFCDS RES 0,C PUSH BC CALL GETBYTE PUSH AF CALL GETBYTE PUSH BC CALL CHKMD23 CALL GRATEMPS CALL SPSSR POP BC POP AF POP HL POP DE AND A JR Z,IOORHP2 LD B,A LD A,C DEC A CP 4 JR C,ROLL75 RST 08H DB 30 LD A,H ADD A,D JR C,IOORHP2 CP 193 JR NC,IOORHP2 BIT 2,C JR Z,NTRDOWN LD H,A DEC H LD A,L ADD A,E JR C,IOORHP2 LD A,D EXX LD B,A EXX SCF RR H RR L LD A,E ADD A,1 RRA LD E,A LD D,B BIT 0,C JP Z,RUPDN DEC E DJNZ RLBYTE LD D,C

;WIDTH. LEGAL=2-256 ;EVEN WIDTHS ONLY ;1-255

;L ;L,W-1 IN B,C ;B=Y, C=X (FAT COORDS FORCED) ;EVEN X ONLY (OR FOR THINPIX, MULTIPLES OF 4 ONLY) ;A=PIX ;DIRECTION TO C ;SET TEMPS FROM PERM LS OR US VARS - USE FOR SCROLL ;STORE PAGE, SELECT SCREEN ;C=DIRECTION ;PIX ;COORDS ;L, W-1 ;PIX ;DIR. 1234=L/U/R/D ;ORIG DIR MUST BE 1-4

;TOP=0, BOT=191

;ERROR IF AREA FALLS OFF BOTTOM

;H=Y IF ROLL DOWN ;ADD X,W-1 ;JR IF OFF SCREEN ON RHS

;B"=LENGTH (1-192)

;HL=SCR ADDR (LHS, TOP IF LT, RT OR UP; BOT IF DN) ;WIDTH=2-256. CY IF 256 ;GET WIDTH IN BYTES (1-128) ;E=WIDTH IN BYTES ;D=PIX ;01=L,10=U,11=R,100=D ;JP IF UP OR DOWN ;E=W-1, IN BYTES (0-127) ;JR IF MOVING MORE THAN 1 PIX - USE BYTES

;LEFT OR RIGHT BY 1 PIXEL (1 NIBBLE IN MODE 3) ;C/D=DIR, E=WIDTH-1 IN BYTES, HL=SCREEN ADDR, B"=LENGTH, A=WIDTH F7 FEE9 15 2007 7D 83 6F 7B ED44 5F 3AD05A 57 0E80 D9 D9 45 7D 83 6F 3A515A NTNRL: RST 30H DW CRBBFN DEC D JR NZ,NTNRL LD A,L ADD A,E LD L,A LD A,E NEG LD E,A LD A,(TEMPB3) LD D,A LD C,128 EXX EXX LD B,L LD A,L ADD A,E LD L,A LD A,(M23PAPT) ;DEC DIR ;JR IF ROLL RIGHT ;HL=RHS IF ROLL LEFT BY 1 PIX ;E=NEGATED WIDTH-1 IF ROLL LEFT. ALLOWS PT TO LHS ;ROLL=FF, SCROLL=00 ;SCAN LEN

NLRLP:

;PT TO OTHER END OF LINE. CY IF E -VE (ROLL LEFT)

0A26 0A27 0A28 0A2A 0A2A 0A2B 0A2D 0A2D 0A2E 0A2F 0A30 0A31 0A31 0A32 0A33 0A36 0A37 0A39 0A3A 0A3B 0A3D 0A3D 0A3F 0A3F 0A3F 0A3F 0A40 0A41 0A42 0A43 0A44 0A45 0A48 0A48 0A49 0A4A 0A4C 0A4D 0A4E 0A50 0A50 0A51 0A52 0A53 0A53 0A54 0A56 0A59 0A5B 0A5C 0A5D 0A5E 0A60 0A60 0A62 0A62 0A62 0A62 0A63 0A64 0A65 0A66 0A69 0A6B 0A6C 0A6F 0A72 0A73 0A74 0A76 0A77 0A79 0A7A 0A7B 0A7D 0A7D 0A80 0A80 0A80 0A80 0A81 0A82 0A83 0A84 0A87 0A89 0A8A 0A8D 0A90 0A91 0A92 0A94 0A95 0A97 0A98 0A99 0A9B 0A9B 0A9D 0A9D 0A9F 0A9F 0A9F

14 15 2807 7E 3004 0F 0F 0F 0F 68 E5 CD004D E1 0600 09 D9 10E1 183E 04 78 1F 57 7B 92 DADE09 3C F7 1CEA 37 0D 2803 7D 83 6F 0C 0600 3AD05A FE01 0D 7A D9 383D 201E D9 4F E5 E5 1103E0 EDB0 D1 CD004D 2103E0 04 4F EDB0 E1 0E80 09 D9 10E5 C3BF3F D9 4F E5 E5 1182E0 EDB8 D1 CD004D 2182E0 04 4F EDB8 E1 0E80 09 D9 10E5 18E0 201C SCROLLLR: RLBMLP: RLBY2: RLBYTE: ROLL8:

INC D DEC D JR Z,ROLL8 LD A,(HL) JR NC,ROLL8 RRCA RRCA RRCA RRCA LD L,B PUSH HL CALL CDBUFF POP HL LD B,0 ADD HL,BC EXX DJNZ NLRLP JR RCURPH ;RIGHT OR LEFT BY BYTES INC B LD A,B RRA LD D,A LD A,E SUB D JP C,IOORHP2 INC A RST 30H DW CRTBF SCF DEC C JR Z,RLBY2 LD A,L ADD A,E LD L,A INC C LD B,0 LD A,(TEMPB3) CP 1 DEC C LD A,D EXX JR C,SCROLLLR JR NZ,RRBMLP ;ROLL LEFT BYTES EXX LD C,A PUSH HL PUSH HL LD DE,RSBUFF LDIR POP DE CALL CDBUFF LD HL,RSBUFF INC B LD C,A LDIR POP HL LD C,128 ADD HL,BC EXX DJNZ RLBMLP JP RCURPR EXX LD C,A PUSH HL PUSH HL LD DE,RSBUFF+127 LDDR POP DE CALL CDBUFF LD HL,RSBUFF+127 INC B LD C,A LDDR POP HL LD C,128 ADD HL,BC EXX DJNZ RRBMLP JR RCURPH JR NZ,SRBYPRE

;JR IF SCROLL - A=BG COLOUR ;GET NIBBLE TO WRAP ROUND ;JR IF ROLL RIGHT ;ELSE GET NIBBLE TO OTHER SIDE OF A

;HL PTS TO ORIG LINE END AGAIN

;DO B" SCANS ;RESET UR PORT ;B=PIX (2+) ;BYTES OF MOVEMENT (1+). CALL IT M ;WIDTH-1 IN BYTES (0-127) ;BYTES OF MOVEMENT (M) ;JR IF M ISN"T LESS THAN WIDTH

;CY=LEFT ;Z IF LEFT, NZ IF RIGHT

;HL PTS TO RHS IF RIGHT AND BYTE MOVING. NC

;C IF SCROLL, NC IF ROLL ;Z IF LEFT, NZ IF RIGHT ;A=M

;BC=M ;SCRN PTR ;SAVE M BYTES FROM LINE START, ADVANCE SRC ;ORIG HL ;COPY THE SCAN ;B=0 ;BC=M ;WRAP BYTES FROM BUFFER ;LINE START ;DROP 1 SCAN

RCURPH: RRBMLP:

;ROLL RIGHT BYTES ;BC=M ;SCRN PTR ;SAVE M BYTES FROM LINE END, MOVE SRC PTR LEFT ;ORIG HL ;MOVE THE SCAN ;BC=M ;WRAP BYTES FROM BUFFER ;LINE START ;DROP 1 SCAN

;JR IF SCROLL RIGHT

;SCROLL LEFT BYTES

0A9F 0AA0 0AA1 0AA2 0AA3 0AA4 0AA5 0AA8 0AA9 0AAA 0AAD 0AAD 0AAE 0AAF 0AB1 0AB1 0AB2 0AB3 0AB5 0AB6 0AB7 0AB9 0AB9 0ABB 0ABB 0ABB 0ABB 0ABC 0ABC 0ABD 0ABE 0ABF 0AC0 0AC1 0AC3 0AC6 0AC7 0AC8 0ACB 0ACB 0ACC 0ACD 0ACF 0ACF 0AD0 0AD1 0AD3 0AD4 0AD5 0AD7 0AD7 0AD9 0AD9 0AD9 0AD9 0AD9 0AD9 0AD9 0ADB 0ADE 0AE0 0AE0 0AE1 0AE1 0AE1 0AE1 0AE2 0AE3 0AE5 0AE6 0AE7 0AE8 0AE8 0AE9 0AEA 0AEB 0AEC 0AED 0AED 0AEE 0AF1 0AF1 0AF2 0AF5 0AF6 0AF9 0AFA 0AFC 0AFC 0AFD 0AFE 0AFF 0AFF 0B00 0B01 0B02 0B02 0B03 0B04 0B06 0B06 0B09 0B0A

D9 4F E5 54 5D 09 CD004D 47 4F 3A515A 12 13 10FC 79 E1 0E80 09 D9 10E6 18C2 A7 D9 4F E5 54 5D ED42 CD004D 47 4F 3A515A 12 1B 10FC 79 E1 0E80 09 D9 10E5 18E0

SLBMLP:

EXX LD C,A PUSH HL LD D,H LD E,L ADD HL,BC CALL CDBUFF LD B,A LD C,A LD A,(M23PAPT) LD (DE),A INC DE DJNZ SLBBLP LD A,C POP HL LD C,128 ADD HL,BC EXX DJNZ SLBMLP

;BC=M ;SCRN PTR ;MOVE SCAN LEFT

SLBBLP:

;BLANK END OF SCAN

;DROP 1 SCAN

RCURH2: SRBYPRE: SRBMLP:

JR RCURPH AND A EXX LD C,A PUSH HL LD D,H LD E,L SBC HL,BC CALL CDBUFF LD B,A LD C,A LD A,(M23PAPT) LD (DE),A DEC DE DJNZ SRBBLP LD A,C POP HL LD C,128 ADD HL,BC EXX DJNZ SRBMLP JR RCURH2 ;NC FOR FIRST SBC ;BC=M ;SCRN PTR ;DE PTS TO RHS. MOVE HL SLIGHTLY (M) BYTES LEFT ;MOVE SCAN RIGHT ;B=M ;SAVE M BRIEFLY ;BLANK LHS (M BYTES) ;A=M ;DROP 1 SCAN. NC

;SCROLL RIGHT BYTES.

SRBBLP:

;******************************************************************************* ;RUPDN - ROLL/SCROLL UP OR DOWN ;ENTRY: E=WIDTH IN BYTES, HL=TOP LHS SCRN ADDR (UP) OR BOT LHS (DOWN) ;B"=LENGTH, D=PIX OF DISP, C=DIR (1-4) CB51 018000 2801 05 7B F7 23EA 7B 08 7A D9 4F 78 41 D9 92 DADE09 F5 3AD05A A7 C43F0B F1 280E D9 47 D9 7A 54 5D 09 3D 20FC CD530C EB ADDDISP: RUPDN2: RUPDN: BIT 2,C LD BC,128 JR Z,RUPDN2 DEC B LD A,E RST 30H DW CRTBFI LD A,E EX AF,AF' LD A,D EXX LD C,A LD A,B LD B,C EXX SUB D JP C,IOORHP2 PUSH AF LD A,(TEMPB3) AND A CALL NZ,RSSTBLK POP AF JR Z,RUPFIN EXX LD B,A EXX LD A,D LD D,H LD E,L ADD HL,BC DEC A JR NZ,ADDDISP CALL RSMOVSR EX DE,HL ;010=UP, 100=DOWN ;BC = DISP TO ROW BELOW IF ROLL UP ;BC=FF80=-128 IF ROLL DOWN

;THIS ENTRY FROM EDRS WITH BC SET UP ;CREATE BUFFER OF A LDI"S ;PIX ;C"=PIX ;GET LENGTH FROM B" ;B"=PIX ;SUB LEN,PIX ;ERROR IF MOVEMENT IS GREATER THAN WIN LEN ;SAVE MAIN BLOCK SCANS, Z IF MOVE=WIND LEN ;STORE WRAPPED AREA IF ROLL ;LINES IN MAIN BLOCK ;JR IF MOVEMENT=LENGTH OF WINDOW (CLS) ;B"=LINES IN MAIN BLOCK (AREA NOT WRAPPED) ;PIX ;DE IS SCREEN DEST ;DEC PIX TO MOVE BY ;MOVE HL UP OR DOWN TO START OF MAIN BLOCK

0B0A 0B0B 0B0E 0B0F 0B11 0B11 0B11 0B14 0B15 0B16 0B16 0B16 0B16 0B17 0B18 0B19 0B1C 0B1D 0B1E 0B1F 0B20 0B21 0B22 0B24 0B24 0B26 0B26 0B26 0B26 0B27 0B2A 0B2B 0B2C 0B2C 0B2D 0B2E 0B2F 0B30 0B31 0B32 0B33 0B36 0B37 0B38 0B39 0B3A 0B3C 0B3C 0B3F 0B3F 0B3F 0B3F 0B3F 0B3F 0B3F 0B40 0B41 0B42 0B43 0B46 0B47 0B48 0B48 0B49 0B4A 0B4C 0B4C 0B4F 0B52 0B53 0B55 0B55 0B56 0B57 0B57 0B57 0B58 0B59 0B5C 0B5D 0B5D 0B5E 0B5F 0B60 0B63 0B64 0B65 0B66 0B67 0B69 0B69 0B6A 0B6B 0B6C 0B6D 0B6D 0B6D 0B6D 0B6D 0B6D 0B70 0B71 0B72

EB 3AD05A A7 2815 2103E0 D9 41 D9 D5 C5 CD004D C1 D1 EB 09 EB D9 10F2 1816 EB 3A515A D9 41 D9 54 5D 1C 77 C5 E5 CD024D E1 C1 09 D9 10F0 C3BF3F

RUPFIN:

EX DE,HL LD A,(TEMPB3) AND A JR Z,SCRUDBLK LD HL,RSBUFF EXX LD B,C

;DE=SCRN DEST ;JR IF SCROLL AND BLANKING OF NEW AREA NEEDED ;ELSE WRAP DATA FROM BUFFER ;B"=PIX

;DE PTS TO BLOCK, BC=SGNED SCAN LEN, B"=SCANS TO DO SCRUDWRAP: EXX PUSH DE PUSH BC CALL CDBUFF POP BC POP DE EX DE,HL ADD HL,BC EX DE,HL EXX DJNZ SCRUDWRAP JR RCUHP ;DE PTS TO BLOCK, BC=SGNED SCAN LEN, C"=SCANS TO DO, M23PAPT=VALUE SCRUDBLK: EX DE,HL LD A,(M23PAPT) EXX LD B,C EXX LD D,H LD E,L INC E LD (HL),A PUSH BC PUSH HL CALL CDBUFF+2 POP HL POP BC ADD HL,BC EXX DJNZ SCRUBOLP JP RCURPR ;HL PTS TO BLOCK TO CLEAR ;B"=PIX ;SCRN DEST ;DISP TO NEXT SCAN ;COPY A SCAN ;MOVE SCRN PTR UP OR DOWN A SCAN ;COPY "PIX" SCANS

SCRUBOLP:

;MOVE UP OR DOWN A SCAN ;BLANK "PIX" SCANS AT TOP OR BOTTOM

RCUHP:

;******************************************************************************* ;RSSTBLK - STORE BLOCK. ALSO USED BY GRAB ;ENTRY: HL=SCRN ADDR (TOP OR BOT), BC=SGNED SCAN LEN, D=PIX, B"=PIX,A"=WIDTH ;EXIT: SAME EXCEPT B"=0. TEMPW2=SPACE D5 E5 08 5F 210000 7A 54 19 3D 20FC 22CA5A 1113E0 19 3002 CF 24 E1 E5 1103E0 D9 D9 C5 E5 CD004D E1 C1 09 D9 10F4 D9 E1 D1 C9 STSTPOK: RSSTBLK: PUSH DE PUSH HL EX AF,AF' LD E,A LD HL,0 LD A,D LD D,H ADD HL,DE DEC A JR NZ,CALCSPLP LD (TEMPW2),HL LD DE,RSBUFF+16 ADD HL,DE JR NC,STSTPOK RST 08H DB 36 POP HL PUSH HL LD DE,RSBUFF EXX EXX PUSH BC PUSH HL CALL CDBUFF POP HL POP BC ADD HL,BC EXX DJNZ STSTPLP EXX POP HL POP DE RET ;SCAN LEN ;SCRN SRC ;PT TO SCAN ABOVE OR BELOW (BC IS SIGNED SCAN LEN) ;WIDTH ;A=PIX ;DE=WIDTH ;CALC WIDTH*PIX=STRIP MEM USE ;SAVE SPACE REQUIRED FOR DATA (FOR GRAB) ;E013H

CALCSPLP:

;"Stored area too big" ;ERROR IF STRIP USES MORE THAN (8K-19 BYTES) ;(16 BYTES FOR PUT STACK, 3 FOR CC,W,L)

STSTPLP:

;SCRN ADDR ;D=PIX

;****************************************************************************** ;CLS AND EDITOR SCROLL ROUTINES. ;CLEAR WINDOW - VARS DEFINE CHAR WINDOW 21595A 7E 2B 96 CLSWIND: LD HL,WINDBOT LD A,(HL) DEC HL SUB (HL)

;SUB WINDTOP

0B73 0B74 0B74 0B76 0B79 0B7C 0B7D 0B7E 0B80 0B80 0B83 0B84 0B85 0B85 0B86 0B87 0B88 0B8A 0B8A 0B8A 0B8A 0B8C 0B8D 0B8E 0B90 0B91 0B93 0B95 0B95 0B95 0B95 0B97 0B98 0B99 0B9B 0B9D 0B9D 0B9F 0B9F 0B9F 0B9F 0B9F 0BA2 0BA2 0BA5 0BA8 0BAA 0BAD 0BAD 0BAF 0BB2 0BB6 0BB8 0BB8 0BBB 0BBF 0BBF 0BC2 0BC3 0BC5 0BC5 0BC6 0BC9 0BCA 0BCB 0BCC 0BCD 0BCE 0BCF 0BD2 0BD3 0BD4 0BD5 0BD6 0BD8 0BD9 0BDA 0BDD 0BE0 0BE3 0BE6 0BE6 0BE6 0BE6 0BE6 0BE7 0BE8 0BEA 0BEB 0BEB 0BEC 0BED 0BEE 0BEE 0BEF 0BF2 0BF2 0BF3 0BF4 0BF5 0BF5 0BF6 0BF7

3C 0E02 CD660C 3A735A A7 7A 2005 3A5D5A 82 57 D9 47 D9 1818 1600 F5 F7 E1F3 F1 0E04 180A 3E01 57 F7 E1F3 3E01 0E02 CLSW1:

INC A LD C,2 CALL EDRSSR LD A,(DEVICE) AND A LD A,D JR NZ,CLSW1 LD A,(LSOFF) ADD A,D LD D,A EXX LD B,A EXX JR EDRSF LD D,0 PUSH AF RST 30H DW STENTS POP AF LD C,4 JR EDRS LD A,1 LD D,A RST 30H DW STENTS LD A,1 LD C,2

;GET ROWS OF WINDOW LEN ;"UP" ;GET B"=LEN, D=DISP (SAME) ;JR IF NOT UPPER SCREEN ;INCLUDE "LEFT OVER" SCANS

;SCROLL WINDOW DOWN BY "A" ROWS EDRSADN: ;SCROLL LPT DOWN ;SCROLL LINE PTR TABLE ;DOWN

;SCROLL WINDOW UP BY 1 ROW EDRS1UP: ;LPT SCROLL BY 1 ROW ;SCROLL LPT UP AS D=1 ;WINDOW SCROLL BY 1 ROW ;UPWARDS

EDRSAUP:

;EDRS - EDITOR"S ROLL/SCROLL ROUTINE ;ENTRY: WINDOW VARS DEFINE CHAR WINDOW, A=ROWS TO SCROLL, C=2 IF UP, 4 IF DN. CD660C CDA83F 3A405A FE02 D2D90A CB51 012000 DD21040D 2807 01E0FF DD21E70C 3A405A A7 2821 AF 32515A C5 D5 E5 D9 C5 D9 CDE10A D9 C1 D9 E1 CBEC D1 C1 3A4E5A 32515A CDA83F C3E10A EDRSM1: EDRS: EDRSF: CALL EDRSSR CALL SPSSR LD A,(MODE) CP 2 JP NC,RUPDN BIT 2,C LD BC,32 LD IX,NEXTDOWN JR Z,EDRSM1 LD BC,-32 LD IX,NEXTUP LD A,(MODE) AND A JR Z,EDRSM0 XOR A LD (M23PAPT),A PUSH BC PUSH DE PUSH HL EXX PUSH BC EXX CALL RUPDN2 EXX POP BC EXX POP HL SET 5,H POP DE POP BC LD A,(ATTRT) LD (M23PAPT),A CALL SPSSR JP RUPDN2 ;STORE PAGE, SELECT SCREEN

;IN CASE MODE 0 ;JR IF UP ;IN CASE MODE 0 ;JR IF MODE 0 ;MAKE "PAPER COLOUR" BLANK PIXEL PATTERN ;SIGNED SCAN LEN ;D=PIX,E=WIDTH ;SCREEN ADDR ;LEN IN SCANS

;ADD 2000H - PT TO MODE 1 ATTR ;SET COLOUR FOR M1 ATTRIBUTE SCROLL

;MODE 0 SCROLL ;D=PIX TO MOVE BY, E=WIDTH, HL=SCRN ADDR, BC=SGNED ATTR ROW LEN, B"=WIND LEN 7B F7 23EA C5 D9 78 D9 92 DADE09 D9 47 D9 7A F5 4B EDRSM0: LD A,E RST 30H DW CRTBFI PUSH BC EXX LD A,B EXX SUB D JP C,IOORHP2 EXX LD B,A EXX LD A,D PUSH AF LD C,E

;+/-32 ;GET PIX OF WINDOW LEN ;SUB WINDOW LEN, PIX TO MOVE BY="MAIN BLOCK" LEN ;ERROR IF MOVED BY MORE THAN WIND LEN ;MAIN BLOCK LEN IN B" ;PIX. Z IF WIND LEN=MOVEMENT (CLS) ;C=WIDTH

0BF8 0BF9 0BFA 0BFB 0BFD 0BFD 0BFD 0C00 0C02 0C02 0C03 0C04 0C05 0C06 0C07 0C07 0C08 0C0A 0C0A 0C0B 0C0C 0C0D 0C0E 0C11 0C12 0C13 0C16 0C17 0C18 0C1B 0C1C 0C1C 0C1E 0C1E 0C1F 0C20 0C20 0C21 0C22 0C24 0C24 0C25 0C26 0C26 0C27 0C28 0C2A 0C2A 0C2B 0C2E 0C2F 0C31 0C31 0C32 0C35 0C36 0C37 0C3A 0C3B 0C3C 0C3D 0C40 0C43 0C46 0C46 0C46 0C46 0C49 0C49 0C49 0C49 0C4A 0C4B 0C4C 0C4D 0C4F 0C51 0C52 0C53 0C53 0C53 0C53 0C54 0C54 0C55 0C56 0C57 0C58 0C5B 0C5C 0C5D 0C5E 0C5F 0C60 0C61 0C62 0C62 0C64 0C64 0C65 0C66 0C66 0C66

42 54 5D 2805 CD2D00 10FB F1 F5 D5 E5 F5 D9 2814 D9 E5 D5 C5 CD004D C1 E1 CD2D00 EB E1 CD2D00 D9 10EC 42 D9 EB D1 1E00 E5 41 73 2C 10FC E1 CD2D00 15 20F3 E1 CD490C EB E1 CD490C EB F1 C1 C4530C 3A4E5A 32515A C3260B 7C 0F 0F 0F E603 F698 67 C9 D9 D9 E5 D5 C5 CD004D C1 E1 09 EB E1 09 D9 10F0 D9 C9 CTAA: EDRSM0DL: EDRSM0BL: EDRSM0L2: EDRSM0LP: EDRSM0P: EDRSM0L1:

LD LD LD JR

B,D D,H E,L Z,EDRSM0L1

;B=PIX ;DE=SCRN DEST ;MOVE UP OR DOWN A SCAN ;PT HL TO SRC ;B=0 SO BC=WIDTH ;PIX. Z/NZ ;PIX ;SAVE FOR ATTR SCROLL ;PIX, Z/NZ

CALL IXJUMP DJNZ EDRSM0P POP AF PUSH AF PUSH DE PUSH HL PUSH AF EXX JR Z,EDRSM0L2 EXX PUSH HL PUSH DE PUSH BC CALL CDBUFF POP BC POP HL CALL IXJUMP EX DE,HL POP HL CALL IXJUMP EXX DJNZ EDRSM0LP LD B,D EXX EX DE,HL POP DE LD E,00H PUSH HL LD B,C LD (HL),E INC L DJNZ EDRSM0BL POP HL CALL IXJUMP DEC D JR NZ,EDRSM0DL POP HL CALL CTAA EX DE,HL POP HL CALL CTAA EX DE,HL POP AF POP BC CALL NZ,RSMOVSR LD A,(ATTRT) LD (M23PAPT),A JP SCRUDBLK

;ADJ DEST PTR ;ADJ SRC PTR ;LOOP FOR ALL SCANS ;B"=ROWS FOR ATTR SCROLL ;HL=SCRN DEST ;D=PIX TO MOVE BY (AND BLANK) ;SCAN START ;USE B AS WIDTH COUNTER

;CONVERT SRC TO ATTR ADDR ;SRC IN DE ;CONVERT DEST ;Z/NZ ;+/-32 ;SET COLOUR FOR M1 ATTRIBUTE SCROLL

;DE PTS TO BLOCK, BC=SGNED SCAN LEN, C"=SCANS TO DO, A"=WIDTH, M23PAPT=VALUE ;CONVERT HL TO ATTR ADDR LD A,H RRCA RRCA RRCA AND 3 OR 98H LD H,A RET EXX EXX PUSH HL PUSH DE PUSH BC CALL CDBUFF POP BC POP HL ADD HL,BC EX DE,HL POP HL ADD HL,BC EXX DJNZ UPDNLP EXX RET ;EDRSSR ;ACTION: GET E=WIDTH IN BYTES, HL=TOP LHS SCRN ADDR (UP) OR BOT LHS (DOWN) ;SCRN SRC PTR ;DEST ;DISP TO ROW ABOVE OR BELOW ;DISP ;DEST ;ADJUST BY SCAN LEN ;SRC IS AJUSTED BY SIGNED SCAN LEN ;DO B" SCANS

;SCROLL M0 ATTRS / MAIN R/S UP/DOWN ROUTINE RSMOVSR: UPDNLP:

0C66 0C66 0C66 0C67 0C68 0C69 0C69 0C6C 0C6D 0C6E 0C71 0C75 0C77 0C79 0C79 0C7C 0C7D 0C7E 0C81 0C84 0C87 0C89 0C8B 0C8B 0C8D 0C8E 0C90 0C90 0C91 0C94 0C95 0C95 0C96 0C96 0C97 0C98 0C98 0C98 0C98 0C9B 0C9E 0C9F 0CA0 0CA1 0CA2 0CA2 0CA3 0CA4 0CA5 0CA6 0CA9 0CAA 0CAB 0CAB 0CAC 0CAD 0CAE 0CAF 0CB0 0CB1 0CB2 0CB3 0CB4 0CB7 0CB9 0CBA 0CBA 0CBC 0CBE 0CBE 0CC1 0CC2 0CC3 0CC5 0CC5 0CC6 0CC8 0CC8 0CC9 0CCA 0CCB 0CCB 0CCC 0CCD 0CCE 0CCF 0CD0 0CD0 0CD1 0CD1 0CD1 0CD1 0CD1 0CD2 0CD3 0CD6 0CD8 0CD9 0CDA 0CDB 0CDC 0CDD 0CDD

;B"=LENGTH, D=PIX OF DISP, KEEP C D9 4F D9 CDD10C F5 AF 32D05A ED5B575A CB49 201F 3A595A 3C 57 CDB73D 3A405A 2180FF FE02 300A 2EE0 3D 2805 EB CDE70C FE 19 EB BF C4B73D 21595A 7E 2B 96 3C D9 91 57 81 CDD10C 47 D9 2B 2B 7E 23 96 3C EB D1 5F 3A405A FE02 D8 FE03 280D 3A355A A7 7B 2003 1C CB3B 83 5F C9 7B 87 87 5F C9 7A EDRS2: EDRS3: EDRS1: EDRS0: EDRSSR: EXX LD C,A EXX CALL CALCPIX PUSH AF XOR A LD (TEMPB3),A LD DE,(WINDLHS) BIT 1,C JR NZ,EDRS1 LD A,(WINDBOT) INC A LD D,A CALL ANYDEADDR LD A,(MODE) LD HL,0FF80H CP 2 JR NC,EDRS0 LD L,0E0H DEC A JR Z,EDRS0 EX DE,HL CALL NEXTUP DB 0FEH ADD HL,DE EX DE,HL CP A ;ENTRY AT EDRS1 IS NZ CALL NZ,ANYDEADDR ;USES DE/A ONLY. GETS DE=SCRN ADDR LD HL,WINDBOT LD A,(HL) DEC HL SUB (HL) ;SUB WINDTOP INC A ;GET ROWS OF WINDOW LEN EXX SUB C LD D,A ADD A,C CALL CALCPIX LD B,A EXX DEC HL DEC HL LD A,(HL) INC HL SUB (HL) INC A EX DE,HL POP DE LD E,A LD A,(MODE) CP 2 RET C CP 3 JR Z,EDRS3 LD A,(FL6OR8) AND A LD A,E JR NZ,EDRS2 INC E SRL E ADD A,E LD E,A RET LD A,E ADD A,A ADD A,A LD E,A RET LD A,D ;A=WIDTH*1.5, ROUNDED UP, WIDTH*2 ;MODE 3 USES 4 BYTES/CHAR ;ROWS TO DO (IN CASE M0 ATTR SCROLL) ;WINDOW LEN IN ROWS ;B"=SCANS OF WINDOW LEN ;DE=DESIRED SCREEN ADDR ;SET Z ;C"=ROWS TO MOVE BY ;SAVE AMOUNT TO MOVE BY, IN SCANS (PIX) ;"SCROLL" ;DE=TOP/LHS ROW ;JR IF SCROLL UP ;ELSE GET BOTTOM ;GET ADDR 1 SCAN (SIC) LOWER THAN NEEDED - NOW ;BACK UP BY 1 ;MINUS SCAN LEN FOR M2 OR M3 ;JR IF M2 OR M3 ;MINUS SCAN LEN FOR M1=FFE0

;IF MODE 0 ;"JR+1"

;WINDRHS ;SUB WINDLHS ;WIDTH IN CHARS. ;HL=SCREEN ADDR ;D=AMOUNT TO MOVE BY IN SCANS ;MODE 0 OR 1 USES 1 BYTE/CHAR

;JR IF 8 PIXEL, 2 BYTE CHARS

CALCPIXD:

;CALCULATE NO. OF PIXELS IN "A" ROWS. RESULT IN A. ADD 8 IF BOTTOM HALF OF ;DOUBLE-HEIGHT CHARACTER C5 4F 3A365A D605 47 79 87 87 81 81 CALCPIX: PUSH BC LD C,A LD A,(CSIZE) SUB 5 LD B,A LD A,C ADD A,A ADD A,A ADD A,C ADD A,C ;C=ROWS ;B=HEIGHT-5 (AT LEAST 1) ;A=ROWS*5

CLPXL:

0CDE 0CE0 0CE0 0CE1 0CE4 0CE4 0CE5 0CE6 0CE7 0CE7 0CE7 0CE7 0CE8 0CE9 0CEB 0CEC 0CED 0CED 0CEE 0CF0 0CF1 0CF2 0CF2 0CF3 0CF5 0CF6 0CF7 0CF7 0CF7 0CF7 0CF7 0CF7 0CFA 0CFB 0CFD 0CFD 0CFF 0D00 0D01 0D02 0D02 0D03 0D04 0D04 0D04 0D04 0D05 0D06 0D08 0D09 0D09 0D0A 0D0C 0D0D 0D0E 0D0E 0D0F 0D11 0D12 0D13 0D13 0D13 0D13 0D13 0D13 0D13 0D13 0D16 0D18 0D19 0D1A 0D1B 0D1E 0D21 0D24 0D27 0D29 0D29 0D2A 0D2B 0D2B 0D2B 0D2B 0D2C 0D2C 0D2F 0D2F 0D2F 0D2F 0D30 0D33 0D33 0D36 0D39 0D3C 0D3D 0D40 0D41 0D44 0D47 0D47 0D47 0D47

10FD 4F 3A825B 81 C1 C9 25 7C F6F8 3C C0 7D D620 6F D8 7C D6F8 67 C9 NEXTUP:

DJNZ CLPXL LD C,A LD A,(DHADJ) ADD A,C POP BC RET ;MODE 0 MOVE HL UP BY 1 SCAN DEC H LD A,H OR 0F8H INC A RET NZ LD A,L SUB 32 LD L,A RET C LD A,H SUB 0F8H LD H,A RET

;A=ROWS*6 IF B=1, ROWS*7 IF B=2 ETC ;8 IF BOTTOM HALF OF DOUBLE-HEIGHT CHAR BEING ;PRINTED, ELSE 0

;GET ADDR OF POSN 1 SCAN BELOW (HL) IN HL, MODES 0/1. USES AF,HL ONLY ;SCREEN$ SR 3A405A A7 2807 3E20 85 6F D0 24 C9 24 7C E607 C0 7D C620 6F D8 7C C6F8 67 C9 ;MAINLP.SAM 213B5C CBBE AF 67 6F 22755A 32475C 323A5C CD7910 3054 CF 1D 79 32445C AF 32B05A 21FFFF 22455C CD9110 EB 2A915A 2B 3A445C C3440E LINESCAN: NEXTDOWN: NXTDOWN: LD A,(MODE) AND A JR Z,NEXTDOWN LD A,20H ADD A,L LD L,A RET NC INC H RET ;USED BY ROLL/SCROLL INC H LD A,H AND 07H RET NZ LD A,L ADD A,32 LD L,A RET C LD A,H ADD A,0F8H LD H,A RET INCLUDE NMNLP.SAM - SAM MAIN LOOP LD HL,FLAGS RES 7,(HL) XOR A LD H,A LD L,A LD (IFTYPE),HL LD (SUBPPC),A LD (ERRNR),A CALL EVALLINO JR NC,STMTLP1 RST 08H DB 29 LD A,C LD (NSPPC),A XOR A LD (CLA+1),A LD HL,0FFFFH LD (PPC),HL CALL AELP EX DE,HL LD HL,(WORKSP) DEC HL LD A,(NSPPC) JP NEXTLINE

;NC=NO CRSSING OF CHAR BORDER

NXTDOWN1:

;RET IF NEW THIRD ;SET CY

;MAIN LOOP

;MAIN PARSER - CHECK LINE FOR SYNTAX ;SIGNAL SYNTAX CHECK ;LONG IF, "REF TYPE" (FN FLAG) NO ;FIRST STATEMENT ;"OK" ERROR ;SKIP ANY LINE NO. ;JR IF LINE NO. IN RANGE

NONSENSE:

;ENTRY POINT FROM LOOP, RETURN ETC, TO ELINE. C=STAT TO GOTO LOOPEL: LOOPEL2: LINERUN:

;ENTRY POINT FOR RUNNING OR CHECKING THE E-LINE ;ELINE SHOWN BY ODD CURRENT LINE ADDR - ALLOWS ;EG RETURN TO RECOGNIZE RET ADDR AS ELINE ;FFFF - PRINT LINE NO. WILL GIVE 0 ;ADDRESS ELINE, SET PAGES ;DE PTS TO ELINE START, HL TO ELINE END

;FINDER ;CALLED BY DO AND DEF PROC WITH D=INTERVENING, E=TARGET, BYTE AFTER CALL=ERROR ;IN CASE NOT FOUND. NO RETURN EVER MADE. SEARCH STARTS FROM CHAD.

0D47 0D47 0D4A 0D4D 0D4D 0D4D 0D4D 0D4D 0D4D 0D4D 0D4D 0D4D 0D4E 0D51 0D51 0D53 0D56 0D59 0D5A 0D5B 0D5D 0D5D 0D5E 0D5F 0D60 0D61 0D65 0D66 0D67 0D68 0D69 0D6A 0D6D 0D6D 0D6E 0D70 0D72 0D72 0D74 0D77 0D77 0D79 0D79 0D79 0D79 0D7A 0D7A 0D7D 0D7D 0D7D 0D7D 0D80 0D83 0D84 0D84 0D84 0D84 0D87 0D87 0D88 0D8A 0D8C 0D8C 0D8E 0D91 0D91 0D92 0D95 0D97 0D97 0D99 0D9B 0D9B 0D9E 0D9E 0D9F 0DA2 0DA5 0DA6 0DA7 0DAA 0DAA 0DAD 0DAF 0DB2 0DB2 0DB4 0DB6 0DB6 0DB7 0DB8 0DBA 0DBD 0DBE 0DC0 0DC2 0DC4 0DC6 0DC7 0DC8 0DC9 0DCA 0DCC

CD9E1D D20800

SEARCH:

CALL SEARCHALL JP NC,0008H

;JP IF NOT FND - USE BYTE AFTER CALL AS ERR CODE ;ELSE CLA AND CHAD HAVE BEEN SET, A=STAT WHERE ;TARGET FOUND (LOOP OR END PROC)

;ENTRY WITH A=STAT, CHAD SET, CLA=LINE START OR 00?? IF ELINE. ;CHAD IS PAST END PROC, LOOP, LELSE, SELSE, END IF, NEXT (VAR SKIPPED). ;LOOP MIGHT HAVE "WHILE" OR "UNTIL" TO SKIP. ;CONTINUE EXECUTION AT CHAD. EXCHAD2 USED BY FOR, LIF D1 32475C DBFB CD9410 2AAF5A 24 25 2810 56 23 5E 23 ED53455C 5E 23 56 23 19 229D5A DF FE8A 3812 FE8C DCF210 180B 23 22975A CD891D 21475C 34 2A975A 7E FE21 300B FE0D CA120E 23 22975A 18F0 FE3A 28DE 11D40D D5 227B5A 2AF45A 24 25 C40500 32745B D690 DADB32 FE67 3059 87 4F 0600 2ADA5B 09 0EFA ED40 CBF0 ED41 5E 23 56 E7 CB7A 2004 ON4ENT: STMTLP3: STMTLP: STMTLP05: ;FROM ELSE STMTLP1: CALL SETWORK LD HL,SUBPPC INC (HL) LD HL,(CHAD) LD A,(HL) CP 21H JR NC,STMTLP3 CP 0DH JP Z,LINEEND INC HL LD (CHAD),HL JR STMTLP25 CP ":" JR Z,STMTLP LD DE,NEXTSTAT PUSH DE LD (CSA),HL LD HL,(CMDV) INC H DEC H CALL NZ,HLJUMP LD (CURCMD),A SUB 90H JP C,PROCS CP 0F7H-90H JR NC,NONSX ADD A,A LD C,A LD B,0 LD HL,(CMDADDRT) ADD HL,BC LD C,LRPORT IN B,(C) SET 6,B OUT (C),B LD E,(HL) INC HL LD D,(HL) RST 20H BIT 7,D JR NZ,R1CMD ;GET WORD DISPLACEMENT ;PT TO WORD IN TABLE OF ROUTINE START ADDRS ;ROM1 ON ;SKIP TO CHAR PAST CMD ;JR IF CMD IN ROM1 ;CMDS RETURN TO NEXT STAT AFTER EXECUTION ;CURRENT STATEMENT ADDR ;ALLOWS ADDING OF EXTRA CMDS ;USED BY SAVE/LOAD ETC ;SKIP 0-20 EXCEPT CR. ;JR IF 21-FF ;INC STATEMENT NO. STMHOP: EXCHAD2: POP DE LD (SUBPPC),A IN A,(URPORT) CALL STPGS LD HL,(CLA) INC H DEC H JR Z,STMHOP LD D,(HL) INC HL LD E,(HL) INC HL LD (PPC),DE LD E,(HL) INC HL LD D,(HL) INC HL ADD HL,DE LD (NXTLINE),HL RST 18H CP WHILETOK JR C,STMTLP2 CP UNTILTOK+1 CALL C,SKIPCSTAT JR STMTLP2 ;THIS PART IS ALSO MAIN RUN-TIME CONTROL INC HL LD (CHAD),HL ;IF WHILE/UNTIL, SKIP STATEMENT ;JUNK RET ADDR ;SET CHADP, NXTLNP, CLAPG ** ;JR IF ELINE - PPC AND NXTLINE CORRECT ;GET LINE NO. ;AND SET SYS VAR ;LINE LEN ;PTR TO NEXT LINE SET

;FROM ELSE (SYNTAX CHECK) STMTLP2: STMTLP25:

0DCE 0DCE 0DD0 0DD2 0DD2 0DD3 0DD4 0DD4 0DD4 0DD7 0DD7 0DDA 0DDD 0DDE 0DE0 0DE0 0DE3 0DE4 0DE7 0DE7 0DE8 0DEB 0DEC 0DEE 0DF1 0DF2 0DF5 0DF7 0DF7 0DF8 0DFB 0DFB 0DFB 0DFC 0DFD 0DFF 0DFF 0E00 0E01 0E01 0E02 0E02 0E04 0E04 0E07 0E07 0E09 0E0B 0E0B 0E0D 0E0F 0E0F 0E10 0E11 0E11 0E12 0E12 0E12 0E15 0E17 0E17 0E17 0E17 0E1A 0E1A 0E1D 0E1E 0E1F 0E21 0E21 0E22 0E22 0E22 0E22 0E24 0E26 0E28 0E2A 0E2A 0E2B 0E2E 0E2E 0E2E 0E2E 0E31 0E32 0E32 0E35 0E36 0E37 0E38 0E39 0E3D 0E3E 0E3F 0E40 0E41 0E42 0E43 0E44 0E44 0E47 0E48

CBB0 ED41 EB E9 CD630E CDD13F 3A445C 3C 2821 2A425C 24 CA2F0D 25 CD351A F5 DBFB CD9410 F1 3A445C 282B A7 C25B0E 4E 0C 2023 CF 00 DF FE3A CA790D FE8D 28F9 FE0D 2803 CF 1D F1 CD153B 1803 CDD13F 2A9D5A 7E 3C 28DE AF FE01 CE00 CB74 2808 F5 CDF23F CD9410 F1 22AF5A 56 23 5E 23 ED53455C 5E 23 56 EB 23 19 13 229D5A EB 57 RLEPI: NONEWCLAPG: LINEUSE: NONSX: REMARK: LINEEND: OKERR: STMTNEXT: STMTNEXT1: STMTLPH: R1CMD: NEXTSTAT: NOBREAK:

RES 6,B OUT (C),B EX DE,HL JP (HL) CALL BRKSTOP CALL R1OCHP LD A,(NSPPC) INC A JR Z,STMTNEXT LD HL,(NEWPPC) INC H JP Z,LINERUN DEC H CALL FNDLNHL PUSH AF IN A,(URPORT) CALL STPGS POP AF LD A,(NSPPC) JR Z,LINEUSE AND A JP NZ,STATLOST LD C,(HL) INC C JR NZ,LINEUSE RST 08H DB 0 RST 18H CP ":" JP Z,STMTLP CP THENTOK JR Z,STMTLPH CP 0DH JR Z,LINEEND RST 08H DB 29 POP AF CALL ABORTER JR LNEND2 CALL R1OCHP LD HL,(NXTLINE) LD A,(HL) INC A JR Z,OKERR XOR A CP 1 ADC A,0 BIT 6,H JR Z,NONEWCLAPG PUSH AF CALL INCURPAGE

;ROM1 OFF ;EXECUTE CMD. CMDS CALL ABORTER FOR EARLY RETURN ;IN SYNTAX TIME. ;ROM1 OFF, SELCHADP ;JR IF NSPPC=FF - NO JUMP TO NEW LINE/STAT ;LINE NUMBER TO JUMP TO ;JR IF LINE FFXX - E LINE ;HL=LINE START

;JR IF LINE FOUND (FLAG FROM FNDLNHL) ;INSIST RETURN AND SUCH ACTUALLY GOTO DESIRED ;STATEMENT - ONLY GOTO/GOSUB AVOID THIS ;GET LINE NO. MSB OR STOPPER ;JR IF NOT AT PROGRAM END ;"OK"

;NEEDED BY 'IF'

;NONSENSE ;JUNK NEXTSTAT ;IGNORE REST OF LINE ;RET IF SYNTAX CHECK

;USED BY 'ON' IN RUNTIME OLNEND: LNEND2: ;ROM1 OFF, SELCHADP ;GET ADDRESS OF FOLLOWING LINE - FOLLOW ON ;JR IF AT PROGRAM END. (FF=STOPPER) ;STAT 0/1. LATER, 0 RATHER THAN 1 SHOWS ;WE ARE DEALING WITH A GOTO (OF A NON-EXISTENT ;LINE) BUT THAT"S IRREL. HERE. ;0 BECOMES 1, REST SAME

;JPED TO WITH A=PAGE, (SP)=STAT, HL=LINE START CALL STPGS POP AF LD (CLA),HL LD D,(HL) INC HL LD E,(HL) INC HL LD (PPC),DE LD E,(HL) INC HL LD D,(HL) EX DE,HL INC HL ADD HL,DE INC DE LD (NXTLINE),HL EX DE,HL LD D,A ;SET CLAPG, CHADP, NXTLINEP ;CUR. LINE ADDR RECORDED FOR GOSUB RETURNS ETC.

;UPDATE PPC ;DE PTS TO LINE LEN MSB. ;HL=TEXT LEN+1 ;HL PTS TO FIRST CHAR OF NEXT LINE ;DE PTS TO FIRST CHAR IN LINE ;HL PTS TO FIRST CHAR IN LINE ;STAT NO.

NEXTLINE:

0E49 0E4B 0E4E 0E4F 0E52 0E55 0E55 0E58 0E5B 0E5B 0E5C 0E5D 0E5D 0E60 0E61 0E61 0E62 0E63 0E63 0E63 0E63 0E66 0E67 0E67 0E68 0E69 0E69 0E69 0E69 0E6B 0E6D 0E6F 0E70 0E70 0E73 0E74 0E75 0E75 0E75 0E75 0E75 0E78 0E7A 0E7A 0E7A 0E7A 0E7D 0E80 0E81 0E84 0E84 0E87 0E87 0E8A 0E8A 0E8D 0E90 0E93 0E96 0E99 0E9A 0E9C 0E9C 0E9E 0EA1 0EA1 0EA4 0EA5 0EA7 0EA7 0EAA 0EAB 0EAD 0EAD 0EB0 0EB3 0EB6 0EB8 0EB8 0EBB 0EBE 0EBE 0EC0 0EC0 0EC1 0EC3 0EC5 0EC5 0EC8 0EC9 0ECC 0ECF 0ED2 0ED3 0ED6 0ED7 0ED8 0EDB 0EDE 0EE0 0EE1 0EE2 0EE3

3EFF 32445C 82 32475C CA7A0D CDF810 CA020E CF 1F CD690E C0 CF 0E CD690E C0 CF 0F 3EF7 DBF9 E620 C0 3A415B A7 C9 BRKTST: STATLOST: BRKCR: BRCERR:

LD A,0FFH LD (NSPPC),A ADD A,D LD (SUBPPC),A JP Z,STMTLP05 CALL SKIPSTATS JP Z,STMTNEXT1 RST 08H DB 31 CALL BRKTST RET NZ RST 08H DB 14 CALL BRKTST RET NZ RST 08H DB 15 LD A,0F7H IN A,(STATPORT) AND 20H RET NZ LD A,(BREAKDI) AND A RET

;SIGNAL NO JUMP ;A=STAT NO.-1 ;JP IF WE WANT FIRST STAT. LD (CHAD),HL ;SKIP D STATS, END WITH CHAD PTING TO :/CR/THEN ;"Statement doesn't exist"

;"BREAK - CONTINUE to repeat"

;CHECK BREAK, STOP IF IT IS PRESSED BRKSTOP: ;RET IF ESC NOT PRESSED ;"BREAK into program"

;Z IF BREAK PRESSED AND BREAKDI=0

;RET IF ESC NOT PRESSED ;NZ IN BREAKDI DISABLES BREAK

;******************************************************************************* ;USED BY AUTO CDCF05 180D CDA010 3A3A5C A7 C2ED0E CDC605 CD711D CDA405 CDA602 CD7238 CD130D 3A475C 17 3005 3E21 323A5C 3A3A5C A7 2811 3A735A 3D 2040 CD351F CD6910 CD8E04 18D2 CD7910 DA290D 20BA DF FE0D 28BF 3A6A5C 1F DCF006 CDB506 3A3A5A 47 3A6D5A 90 3C 328C5C 213B5C CBFE 2B AF 77 3C MAINE2: MAINE1: AULL: CALL AUL2 JR MAINX CALL INSERTLN LD A,(ERRNR) AND A JP NZ,MAINER CALL AUTOLIST CALL SETMIN CALL STRM0 CALL EDITOR CALL TOKMAIN CALL LINESCAN LD A,(SUBPPC) RLA JR NC,MAINE1 LD A,33 LD (ERRNR),A LD A,(ERRNR) AND A JR Z,MAINE2 LD A,(DEVICE) DEC A JR NZ,MAINER CALL ADDRELN CALL REMOVEFP CALL RSPNS JR MAINELP CALL EVALLINO JP C,NONSENSE JR NZ,MAINEADD RST 18H CP 0DH JR Z,MAINEXEC LD A,(FLAGS2) RRA CALL C,CLSUP CALL CLSLOWER LD A,(UWTOP) LD B,A LD A,(SPOSNU+1) SUB B INC A LD (SCRCT),A LD HL,FLAGS SET 7,(HL) DEC HL XOR A LD (HL),A INC A ;TOKENIZE LINE ;CHECK FOR CORRECT SYNTAX/INSERT 5-BYTE FORMS ;JR IF 127 OR LESS STATEMENTS ;ELSE "No room for line" ;AUTO-LIST, AVOIDING EPPC->CLOSEST ;MAIN LOOP, AFTER AUTO-LIST CALL

;MAIN CONTROLLING LOOP FOR ENTIRE INTERPRETER! ENTRY AT MAINEXEC MAINEADD:

;JR IF NO ROOM FOR LINE

MAINEXEC: MAINX: MAINELP:

;JR IF "ERROR"=0 (OK) ;JR UNLESS DEVICE 1 (LOWER SCRN) IN USE - REPORT ;RASP NOISE, CANCEL ERRNR ;GET LINE NUMBER IN BC, ELSE BC=0, Z SET ;ERROR IF TOO BIG ;INSERT LINE IF THERE IS A LINE NO ;JR IF LINE IS JUST <ENTER>

;LINES USED IN US ;"RUNNING" ;ERROR NR=0

0EE4 0EE7 0EEA 0EEA 0EED 0EED 0EF0 0EF1 0EF4 0EF5 0EF6 0EF8 0EF8 0EFB 0EFC 0EFC 0EFF 0F02 0F05 0F06 0F07 0F0A 0F0D 0F10 0F13 0F16 0F16 0F19 0F1B 0F1D 0F1D 0F20 0F23 0F25 0F28 0F2A 0F2C 0F2E 0F2E 0F31 0F34 0F35 0F36 0F38 0F3B 0F3D 0F3F 0F3F 0F42 0F42 0F45 0F46 0F47 0F4A 0F4A 0F4D 0F50 0F52 0F52 0F53 0F54 0F55 0F56 0F59 0F5A 0F5D 0F5E 0F60 0F60 0F63 0F63 0F64 0F64 0F67 0F67 0F6A 0F6D 0F6F 0F70 0F72 0F72 0F75 0F78 0F7B 0F7B 0F7D 0F7F 0F7F 0F7F 0F7F 0F80 0F83 0F83 0F86 0F88 0F89 0F8A 0F8C 0F8E 0F8F 0F92 0F93 0F94

32445C CDDE33 CD2F0D CDD13F FB 21475C 7E A7 2004 3A465B 77 210000 22545C 22A35A 7C 23 22165C 32715C 32885B CDA13B CD711D 3A3A5C E6EF 284A CDBD1C 213B5C CBFE 21455B CB7E CBBE 2839 CD2F10 21ED0E E5 F7 70EB 3A3A5C FE0F 200B CDA519 22455C 15 7A 32475C 2A435B CD351A 200E 23 23 23 23 3A425B 57 CDF810 E7 FEDD C25B0E E7 C3870D CDB506 213C5C CBEE 2B CBBE 3A3A5C CD7B0F C38A0E FE50 2033 AF CDB03D 21345A 3E82 77 D7 3600 3E20 D7 3AB45C 3C 6F 2600 ERRHAND1: MAINER3: STATLH: MAINER2: MAINER1: MAINER:

LD (NSPPC),A CALL COMPILE CALL LINERUN CALL R1OCHP EI LD HL,SUBPPC LD A,(HL) AND A JR NZ,MAINER1 LD A,(ONSTORE) LD (HL),A

;START WITH A JUMP TO STATEMENT 1 ;IF FLAG SAYS SO, CREATE LABELS, COMPILE DEF FNS ;AND DEF PROC ADDRESSES.

;FETCH REAL SUBPPC IF "ON" FIDDLED WITH SYS VAR

LD HL,0 LD (DEFADD),HL LD (XPTR),HL LD A,H INC HL LD (STREAMS+6),HL ;STREAM ZERO POINTS TO CHANNEL K LD (FLAGX),A LD (AUTOFLG),A ;AUTO OFF CALL SETDISP ;DISPLAY 0 CALL SETMIN LD A,(ERRNR) AND 0EFH JR Z,MAINER3 CALL KBFLUSH LD HL,FLAGS SET 7,(HL) LD HL,ONERRFLG BIT 7,(HL) RES 7,(HL) JR Z,MAINER3 CALL ERRHAND2 LD HL,MAINER PUSH HL RST 30H DW SETUPVARS LD A,(ERRNR) CP 15 JR NZ,MAINER2 CALL CONTINUE2 LD (PPC),HL DEC D LD A,D LD (SUBPPC),A LD HL,(ERRLN) CALL FNDLNHL JR NZ,STATLH INC HL INC HL INC HL INC HL LD A,(ERRSTAT) LD D,A CALL SKIPSTATS RST 20H CP 0DDH JP NZ,STATLOST RST 20H JP STMTLP25 CALL CLSLOWER LD HL,TVFLAG SET 5,(HL) DEC HL RES 7,(HL) LD A,(ERRNR) CALL ERRHAND1 JP MAINELP CP 50H JR NZ,EHZ XOR A CALL UTMSG LD HL,BGFLG LD A,82H LD (HL),A RST 10H LD (HL),0 LD A," " RST 10H LD A,(PRAMTP) INC A LD L,A LD H,0 ;SETS CHANNEL K ALSO ;"CLEAR LOWER SCREEN ON KEYSTROKE" ;PT TO FLAGS ;"NOT RUNNING" SO FNDLN DOESN"T USE CLA DURING ;EDITING ;PRINT REPORT, ETC. ;SKIP IT. PT TO E.G. "GOTO 10"/"GOSUB 50"/HANDLER ;CLA/NXTLINE/PPC ETC MATCH LINE WITH ERROR STILL ;NO "ON ERROR" IF "OK" OR 'STOP' (0/10H) ;FLUSH KEYBOARD BUFFER ** ;SET RUNNING IN CASE "VAL" TURNED IT OFF ;BIT 7=TEMP FLAG (OFF). BIT 0=PERM FLAG UNCHANGED ;JR IF TEMP FLAG *WAS* OFF ;SKIP PRINTING PART OF ERRHAND ;ERR HANDLER ADDR ;CREATE LINO, STAT, ERROR ;"BREAK into program" ;CONTINUE GETS THE CORRECT VALUES IF BREAK ;INTERRUPTED A JUMP ;PPC LDED WITH OLDPPC ;SAME STATEMENT FOR RETURN, NOT NEXT ONE

;PT TO "ON ERROR" ;ONERRORTOK

;MGT MESSAGE GIVEN IF "REPORT" 50H ;" ;" MILES GORDON TECHNOLOGY plc" C 1989 SAM Coup"

; e WITH AN ACCENT ;NZ=FOREIGN ON

;16 OR 32

0F96 0F97 0F98 0F99 0F9A 0F9B 0F9C 0F9D 0F9F 0FA1 0FA2 0FA2 0FA5 0FA7 0FA7 0FAA 0FAC 0FAF 0FB2 0FB2 0FB4 0FB4 0FB6 0FB7 0FBA 0FBD 0FC0 0FC1 0FC2 0FC2 0FC5 0FC5 0FC6 0FC7 0FC9 0FCC 0FCD 0FCF 0FD0 0FD2 0FD2 0FD5 0FD8 0FD8 0FD9 0FDC 0FDD 0FDE 0FE0 0FE2 0FE3 0FE4 0FE6 0FE8 0FE8 0FE9 0FEC 0FED 0FEF 0FF0 0FF2 0FF3 0FF4 0FF5 0FF6 0FF7 0FF7 0FF9 0FF9 0FFC 0FFE 1000 1000 1002 1004 1004 1006 1007 1009 100A 100A 100D 100D 100E 1011 1014 1015 1017 1019 1019 101B 101C 101E 101E 101F 1023 1024 1026 1028 1029 102C 102D 102F

29 29 29 29 44 4D F7 ABF5 3E4B D7 CDB11C 28FB CDB506 3EFF 320056 C32F10 380E D651 4F 3AC25B CDDF3F 2A1082 79 DD 2AD45B EB F7 4CDD 3A565A 91 FE0D F5 3006 3A3E5A 326F5A C5 3A3A5C F5 F7 A8F5 3E20 D7 F1 D602 2025 47 213F51 7E E61F 4F CB6E 23 54 5D 09 03 200B 3A3B5C CB77 200A 3624 1806 3628 23 3629 0C CD1300 C1 11C050 CD1300 F1 3E0D 3805 3E2C D7 3E20 D7 ED4B455C F7 ABF5 3E3A D7 3A475C F7 A8F5 EH3: PMV1: EH1: EH0: EH15: EHZ: WTFK:

ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL LD B,H LD C,L RST 30H DW PRNUMB1 LD A,"K" RST 10H CALL READKEY JR Z,WTFK CALL CLSLOWER LD A,0FFH LD (LINICOLS),A JP ERRHAND2 JR C,EH0 SUB 51H LD C,A LD A,(DOSFLG) CALL SELURPG LD HL,(8210H) LD A,C DB 0DDH LD HL,(ERRMSGS) EX DE,HL RST 30H DW POMSR LD A,(WINDRHS) SUB C CP 13 PUSH AF JR NC,EH1 LD A,(LWTOP) LD (SPOSNL+1),A PUSH BC LD A,(ERRNR) PUSH AF RST 30H DW PRAREG LD A," " RST 10H POP AF SUB 2 JR NZ,EH2 LD B,A LD HL,TLBYTE LD A,(HL) AND 1FH LD C,A BIT 5,(HL) INC HL LD D,H LD E,L ADD HL,BC INC BC JR NZ,PMV1 LD A,(FLAGS) BIT 6,A JR NZ,PMV2 LD (HL),"$" JR PMV2 LD (HL),"(" INC HL LD (HL),")" INC C CALL PRINTSTR POP BC LD DE,MSGBUFF CALL PRINTSTR POP AF LD A,0DH JR C,EH3 LD A,"," RST 10H LD A," " RST 10H LD BC,(PPC) RST 30H DW PRNUMB1 LD A,":" RST 10H LD A,(SUBPPC) RST 30H DW PRAREG

;32 OR 64 ;64 OR 128 ;128 OR 256 ;256 OR 512

;WAIT FOR A KEYPRESS ;TURN OFF RAINBOW SCREEN ;JR IF NOT DOS ERR CODE ;RANGE NOW 0+ ;DOS AT 8000H ;DOS ERR MSGS ;"JR+3"

;PRINT MESSAGE TO BUFFER (AND GET BC=LEN) ;A=SPACE APART FROM MESSAGE, -1 ;ALLOW FOR 3, PLUS E.G. ", 12345:11" ;JR IF OK TO PRINT ERROR MSG ON 1 LINE ;PRINT ON TOP LINE

;PRINT ERROR NUMBER AS 1 OR 2 DIGITS

;JR IF NOT "MISSING VARIABLE" ;ELSE PRINT ITS NAME BEFORE " not found"

;BC=LEN OF STR/ARRAY NAME, LEN-1 OF SIMPLE NUM ;NZ IF NUMERIC ARRAY ;PT TO FIRST LETTER ;PT PAST END OF NAME (STR/ARRAY) OR TO END IF NUM ;TRUE LEN OF SIMPLE NUM VAR NAMES, OR EXTRA ROOM ;FOR "$" OR "(" ;JR IF NUMERIC ARRAY ;JR IF A (SIMPLE) NUMERIC VAR

;ALLOW FOR ")" IN LEN ;PRINT VAR NAME ;PRINT ERROR MESSAGE ;JR IF USING 2 LINES

PMV2: EH2:

;PRINT LINE NUMBER

102F 1032 1035 1036 1037 1037 1039 1039 103B 103C 103E 103E 1041 1043 1045 1045 1046 1046 1049 104A 104C 104F 1051 1053 1053 1056 1057 105A 105A 105B 105C 105C 105D 1060 1063 1064 1064 1064 1065 1068 1069 1069 1069 1069 1069 106B 106C 106E 106F 1072 1073 1074 1076 1078 1078 1079 1079 1079 1079 1079 107C 107F 1080 1082 1083 1086 1089 108A 108A 108B 108D 108E 108E 108F 1090 1091 1091 1094 1094 1096 1099 109C 109F 10A0 10A0 10A0 10A0 10A0 10A1 10A1 10A1 10A1 10A1 10A1 10A4 10A4 10A7 10AB 10AC 10AE 10B0 10B0 10B1

CDA504 3A3A5C A7 C8 D610 0600 88 2008 3A745B FEC1 2801 04 21445C 7E 36FF 2A425C CB7F 2807 3A475C 80 2A455C 24 C8 25 226E5C 32705C C9 E3 CD010E E1

ERRHAND2:

CALL CLEARSP LD A,(ERRNR) AND A RET Z SUB 16 LD B,0 ADC A,B JR NZ,ERRHAND3 LD A,(CURCMD) CP 193 JR Z,ERRHAND3 INC B

;NO CONTINUE AFTER "O.K." - RET ;RESULT OF 0 IF "STOP statement", FF IF "BREAK ;into program", AND CY ;NO INC OF SUBPPC IF NEITHER STOP OR BREAK ;NEXT ;B=0 NOW - CONTINUE AFTER BREAK INTO 'NEXT' ;REPEATS STATMENT

ERRHAND3:

LD HL,NSPPC LD A,(HL) LD (HL),0FFH LD HL,(NEWPPC) BIT 7,A JR Z,ERRHAND4 LD A,(SUBPPC) ADD A,B LD HL,(PPC)

;CANCEL ANY JUMP ;JR IF JUMP WAS ABOUT TO HAPPEN ;INCR. SUBPPC BY 1 IF STOP OR BREAK ;RET IF CONT WOULD HAVE BEEN TO E-LINE ;COPY NSPPC/NEW PPC OR SUBPPC/PPC TO OSPPC/OLDPPC ;JUNK NEXT STAT RETURN, STACK PTR TO REST OF LINE ;CHECK SYNTAX FOR REST OF LINE ;REMOVE FLOATING POINT FROM REST OF LINE, RET TO ;MAIN LOOP

ERRHAND4:

INC H RET Z DEC H LD (OLDPPC),HL LD (OSPPC),A RET

DFKNL:

EX (SP),HL CALL STMTNEXT POP HL

;REMOVE INVISIBLE 5-BYTE FORMS FROM (HL) TO 0DH 0E06 7E D60E 47 CC521E 7E 23 FE0D 20F1 C9 REMOVEFP: LD C,6 LD A,(HL) SUB 0EH LD B,A CALL Z,RECLAIM2 LD A,(HL) INC HL CP 0DH JR NZ,REMOVEFP RET ;GET LINE NO AT START OF ELINE TO BC, SET Z IF LN=0. CY IF TOO BIG. CD9110 22975A F7 0BE8 DF CDDE17 CD3B1D D8 78 C601 D8 78 B1 C9 CD351F E61F 32AE5A 32965A 329C5A C9 AELP: STPGS: EVALLINO: CALL AELP LD (CHAD),HL RST 30H DW SMBW RST 18H CALL INTTOFP CALL FPTOBC RET C LD A,B ADD A,1 RET C LD A,B OR C RET CALL ADDRELN AND 1FH LD (CLAPG),A LD (CHADP),A LD (NXTLINEP),A RET ;ADDR ELINE, SET CHADP ETC

;RET IF >64K ;RET IF >65279 ;Z IF BC=0

;******************************************************************************* ;INSERT LINE - INSERT LINE BC FROM ELINE INTO PROGRAM C5 INSERTLN: ; ; ; ; CDC333 2A915A ED4B975A 0A FE20 200B 03 0A PUSH BC LD HL,(INSLV) INC H DEC H CALL NZ,HLJUMP CALL SCOMP LD LD LD CP JR HL,(WORKSP) BC,(CHAD) A,(BC) " " NZ,INSLN3 ;LINE NUMBER

;DEF PROCS/DEF FNS AND LABELS NEED DOING ;ANY PRE-PASS OF LABELS ETC IS OBSOLETE. ;BC PTS AFTER LINE NUMBER

INC BC LD A,(BC)

10B2 10B4 10B6 10B6 10B6 10B7 10B7 10BB 10BB 10BC 10BE 10BF 10C1 10C4 10C4 10C5 10C8 10CB 10CC 10CD 10CE 10CF 10D0 10D0 10D1 10D2 10D3 10D4 10D5 10D5 10D5 10D5 10D5 10D5 10D5 10D5 10D8 10DC 10DD 10DE 10DF 10E0 10E1 10E2 10E3 10E4 10E7 10E8 10E9 10EB 10EC 10EF 10F2 10F2 10F2 10F2 10F2 10F3 10F6 10F8 10F8 10F8 10F8 10F8 10F8 10F8 10F8 10F9 10F9 10F9 10F9 10FA 10FB 10FD 10FD 10FE 10FE 10FF 1101 1104 1104 1106 1108 1108 1109 1109 110B 110D 110D 110F 1111 1111 1113 1115 1115 1116 1117 1119 1119 111B 111D 111D 111E

FE0D 2001 0B ED43975A 37 ED42 7C FE3F D24B3F E3 22495C CD461E C1 79 3D B0 C8 C5 03 03 03 03 ; ; ; ; ; ; CD1B1E ED4B495C 70 23 71 23 C1 71 23 70 CD791F 23 EB DBFB 4F CD3B1F C35E2A INSLN2: INSLN3:

CP 0DH JR NZ,INSLN2 DEC BC LD (CHAD),BC SCF SBC HL,BC LD A,H CP 3FH JP NC,OOMERR EX (SP),HL LD (EPPC),HL CALL FNORECL POP BC LD A,C DEC A OR B RET Z PUSH BC INC BC INC BC INC BC INC BC PUSH BC PUSH HL CALL GAPSZ LD (4020H),HL POP HL POP BC CALL MAKEROOM LD BC,(EPPC) LD (HL),B INC HL LD (HL),C INC HL POP BC LD (HL),C INC HL LD (HL),B CALL SPLITBC INC HL EX DE,HL IN A,(URPORT) LD C,A CALL ADDRCHAD JP FARLDIR

;JR, LEAVING BC INCED, TO INC CHAD AND DELETE ;FIRST SPACE IN A LINE LIKE: 10 test. PREVENTS ;SPACES ACCUMULATING WITH MULTI-EDIT/ENTERS. ;AVOID ANY ACTION IF E.G. 10 (space) CR

;HL=LEN OF TEXT, INCLUDING 0DH ;LIMIT LINE LEN TO 3EFFH ;STACK LEN, GET HL=LINE NO ;FIND/RECLAIM LINE ;TEXT LEN ;RET IF TEXT IS JUST 0DH (LENGTH OF 1) ;TEXT LEN ;GET LEN INCLUDING LN AND LEN BYTES ;!! ;BC BYTES AT (HL) ;ENTER LINE NUMBER ;TEXT LEN

;CDE=POINTS TO ROOM FOR TEXT ;TEXT START IN AHL

;SKIPCSTAT - SKIP CURRENT STATEMENT E.G. DATA, LABEL, DEF FN, LOOP UNTIL ETC. ;ENTRY: CHAD=POSN DF 110001 1806 SKIPCSTAT: RST 18H LD DE,0100H JR SKIPS15 ;1 STAT, NOT IN QUOTES

;SKIPSTATS - FIND D"TH STATMENT FROM POSN. ;ENTRY: D=STATMENTS TO SKIP,+1. HL=POSN ;EXIT: CHAD PTS TO BEFORE REQUIRED STAT - TO ":" OR "THEN" OR CR. ;Z,NC IF OK, Z, CY IF HIT END OF LINE AS STAT COUNTER REACHED ZERO, NZ, CY IF ;HIT END OF LINE BEFORE STAT COUNT REACHED ZERO 2B AF 5F 1820 23 7E FE0E CCA200 FE22 2001 1D FE3A 280C FE8D 2808 FE0D 20E8 15 37 1807 CB43 20E0 15 20DD SKIPS4: SKIPS5: SKIPS2: SKIPSTATS: DEC HL ;FROM "ON" SKIPS0: SKIPS1: SKIPS15: XOR A LD E,A JR SKIPS5 INC HL LD A,(HL) CP 0EH CALL Z,NUMBER CP 22H JR NZ,SKIPS2 DEC E CP ":" JR Z,SKIPS4 CP THENTOK JR Z,SKIPS4 CP 0DH JR NZ,SKIPS1 DEC D SCF JR SKIPS6 BIT 0,E JR NZ,SKIPS1 DEC D JR NZ,SKIPS1 ;Z IF LINE END=DESIRED STAT. ;"HIT LINE END" ;IF ":"/"THEN"INSIDE STRING, JR, GET NEXT CHAR ;DEC "STATS TO SKIP" COUNTER ;"INSIDE STRING" ;"NOT IN QUOTES", NC ;COMP FOR INITIAL INC SO WE DON"T MISS SHORT STATS

1120 1120 1123 1124 1124 1127 1129 1129 112C 112E 112F 112F 1130 1132 1132 1132 1132 1132 1132 1132 1132 1132 1132 1134 1135 1135 1135 1135 1138 1138 113B 113E 1140 1140 1140 1140 1143 1143 1145 1147 1147 1147 1147 1149 114B 114B 114D 114E 114E 1150 1151 1152 1154 1155 1156 1157 1158 1159 115A 115A 115B 115C 115C 115D 115E 115E 1160 1161 1161 1163 1163 1163 1163 1166 1169 1169 116B 116B 116E 116F 1170 1170 1173 1174 1175 1176 1177 1178 117B 117D 117F 1181 1181 1182 1184 1186 1186 1187 1189 118A 118A 118B 118E

22975A C9 CDC63A 38C9 CDED14 FE2C C0 E7 18F7

SKIPS6: DATA: DATA1:

LD (CHAD),HL RET CALL RUNFLG JR C,SKIPCSTAT CALL SCANSR CP "," RET NZ RST 20H JR DATA1

;PT CHAD TO JUST BEFORE DESIRED STATMENT ;SKIP STAT IF RUNNING ;RET IF END OF STAT

INCLUDE MISC1.SAM ;MISC1.SAM ;MODE, TEMPS, DATA, RESTORE ;CITEM, PERMS, SETSTRM ;CALLED BY LIST FE23 C0 CD573A CD331D CD4311 1829 CD331D FE11 3013 FE10 2003 3EFC 4F C60B 87 6F 265C 5E 23 56 7A B3 C9 CF 15 CF 2F 3EFE 21 3EFD 32B25A CD4711 28F1 2A4F5C 19 2B 22515C 23 23 23 23 7E 32745A 0E02 FE50 2809 0D FE4B 2804 0D FE53 C0 79 32735A STSMD: CHANFLAG: STRMINF4: STRMINFO: STRMINF2: PRHSH1: CP "#" RET NZ CALL SSYNTAX6 CALL GETBYTE CALL STRMINF2 JR STSM2

;PRHSH, STRMINFO, SETSTRM, CHANFLAG,

;ENTRY FROM PRINT PRHSH2: ;NUMBER

;ENTRY: FPCS HOLDS STREAM NUMBER. EXIT: DE=STREAM PTR, HL PTS TO STRM-H, C=STRM CALL GETBYTE CP 11H JR NC,INVSTRM CP 10H JR NZ,STRMINF4 LD A,0FCH LD C,A ADD A,0BH ADD A,A LD L,A LD H,5CH LD E,(HL) INC HL LD D,(HL) LD A,D OR E RET RST 08H DB 21 RST 08H DB 47 LD A,0FEH DB 21H LD A,0FDH LD (STRNO),A CALL STRMINF3 JR Z,SNOTOPER LD HL,(CHANS) ADD HL,DE DEC HL LD (CURCHL),HL INC HL INC HL INC HL INC HL LD A,(HL) LD (CLET),A LD C,2 CP "P" JR Z,STSMD DEC C CP "K" JR Z,STSMD DEC C CP "S" RET NZ LD A,C LD (DEVICE),A ;ONLY SET "DEVICE" OR CALL TEMPS FOR K/S/P ;P=2,K=1,S=0 ;KEEP FOR DOS ;JR IF STREAM NOT OPEN ;PT TO 2ND BYTE OF CHANNEL ;TRANSFORM STREAM 16 TO -4 (OUTPUT TO STRING) ;(07, 0B-1A IF FROM ABOVE, OR 06-0E IF FROM SETSTRM ;0EH, 16-34H OR 0CH-1CH ;5C0C-5C34H ;IN A AND C ;STREAMS 0-16 ARE LEGAL

;FROM SETSTRM STRMINF3:

;Z IF CLOSED ;"Invalid stream number" ;"Stream is not open"

INVSTRM: SNOTOPER: STREAMFE: STREAMFD: SETSTRM: STSM2:

;ENTRY: A=FCH-03H

;CHANNEL LETTER ;KEEP IT FOR INPUT TO LOOK AT

118E 118E 118E 118E 118E 1191 1194 1198 119B 119C 119E 119E 11A1 11A5 11A5 11A8 11AC 11AC 11AF 11B1 11B2 11B2 11B4 11B6 11B6 11B8 11B8 11BC 11BF 11C0 11C3 11C4 11C5 11C6 11C7 11C7 11C8 11C9 11CA 11CB 11CC 11CD 11CE 11CF 11D1 11D1 11D2 11D2 11D2 11D2 11D2 11D3 11D6 11D6 11D9 11DC 11DF 11E1 11E4 11E5 11E7 11E7 11E8 11E9 11EC 11EF 11F0 11F3 11F6 11F9 11F9 11FC 11FE 11FF 11FF 1201 1204 1205 1205 1205 1205 1205 1205 1205 1205 1205 1208 120B 120E 1210 1210 1211 1211 1214 1215 1216 1219 121C 121D 121E 121F 1221 1222

;COPY PERMANENT GRAPHIC VARS TO TEMP VARS. ;TEMPS FOR PRINT (COLOUR EXPANSION TABLE IF NEEDED) ;HAVE TO COLOUR TABLE *AFTER* EACH PRINTED INK/PAPER/BRIGHT ALSO - CALL COLEX CDD611 2A385A ED5B3A5A 3A735A 3D 2007 2A3C5A ED5B3E5A 22565A ED53585A 3A405A D602 D8 0620 2002 0610 ED5B515A 21205B D9 21005B D9 7A AB 4F 79 A6 2C AB D9 77 2C D9 10F6 C9 COLEX1: TEMUS: COLEX: TEMPS: CALL GTEMPS LD HL,(UWRHS) LD DE,(UWTOP) LD A,(DEVICE) DEC A JR NZ,TEMUS LD HL,(LWRHS) LD DE,(LWTOP) LD (WINDRHS),HL LD (WINDTOP),DE LD A,(MODE) SUB 2 RET C LD B,32 JR NZ,COLEX1 LD B,16 LD DE,(M23PAPT) LD HL,EXTAB EXX LD HL,CEXTAB EXX LD A,D XOR E LD C,A LD A,C AND (HL) INC L XOR E EXX LD (HL),A INC L EXX DJNZ COLEXLP RET ;GRAPHIC TEMPS LEAVES EXPANSION TABLE ALONE (FOR SPEED) AND SETS "UPPER SCRN" AF 32735A 21445A 114D5A 010900 EDB0 3A735A A7 2812 60 68 22535A 3A485C 6F 224E5A 2A305A 22515A 3A405A FE02 C8 3E01 324D5A C9 TEMPS1: GRATEMPS: GTEMPS: XOR A LD (DEVICE),A LD HL,THFATP LD DE,THFATT LD BC,9 LDIR LD A,(DEVICE) AND A JR Z,TEMPS1 LD LD LD LD LD LD LD LD H,B L,B (OVERT),HL A,(BORDCR) L,A (ATTRT),HL HL,(M23LSC) (M23PAPT),HL ;RET IF M0/M1 ;COLOUR 32 BYTES IF M3 ;JR IF MODE 3 ;MODE 2 O/P NEEDS 16-BYTE COLEX TABLE ;D=M3INKT, E=M3PAPT ;EXPANSION TABLE ;COLOURED EXPANSION TABLE ;C=PAPER XOR INK ;USE EXPANDED NIBBLES AS MASKS TO CHOOSE INK/PAP ;UPPER WINDOW DATA ;JR IF NOT LOWER SCREEN

COLEXLP:

;JR IF UPPER SCREEN, ELSE USE LOWER SCRN COLOURS ;OVER 0, INVERSE 0 ;MASKT WILL BE ZERO ;MODES 2/3 LOWER SCREEN COLOURS ;LD PAPER AND INK

LD A,(MODE) CP 2 RET Z LD A,1 LD (THFATT),A RET ;NZ=FAT UNLESS MODE 2, THEN=COPY OF THFATP

;POKE, DPOKE, CALL, USR, PEEK & DPEEK ALLOW ADDRESSES OF 00000-1FFFF, RELATIVE ;TO THE CONTEXT BASE PAGE. 0000-3FFF WILL BE ROM0, 4000-7FFF WILL BE BASE PAGE, ;8000-BFFF WILL BE THE PAGE ABOVE THE BASE PAGE. 10000-13FFF WILL SWITCH PAGE ;3 ABOVE BASE PAGE INTO 8000H (IRRELEVANT EXCEPT TO NON-RELOCATABLE CALLED OR ;USRED CODE) CDE43A CD853A CD083B 2016 D0 CD011D F5 D5 CD791F CD8C3F 4F 0D EB CBFA E1 F1 POKE: CALL EXPT1NUM CALL INSISCOMA CALL EXPTEXPR JR NZ,POKE2 RET NC CALL STKFETCH PUSH AF PUSH DE CALL SPLITBC CALL UNSTLEN LD C,A DEC C EX DE,HL SET 7,D POP HL POP AF ;EVAL ADDR ;JR IF NUMERIC, ELSE DO POKE N,A$ ;RET IF SYNTAX TIME ;ADE=SRC, BC=LEN

;CDE=DEST ADDR ;AHL=SRC ADDR

1223 1226 1226 1228 1228 1229 122A 122B 122C 122C 122F 1230 1232 1232 1233 1236 1237 1238 123A 123D 123D 123F 1241 1241 1244 1244 1245 1245 1246 1247 1248 1248 124B 124C 124D 124E 124E 124F 1250 1253 1256 1256 1258 1258 125A 125A 125B 125C 125D 125E 125F 1261 1261 1262 1262 1265 1265 1268 126B 126C 126D 126E 126F 126F 126F 126F 126F 126F 126F 126F 126F 126F 1270 1272 1273 1276 1278 1279 1279 1279 1279 1279 127A 127B 127B 127D 127F 127F 1281 1282 1284 1284 1286 1286 1288 1289 128B 128B 128B 128D 128D 128E 128E

C35E2A 3004 EF 06 C8 33 110000 DF 180B D5 CDE33A D1 1C CB6B C2290D FE2C 28F1 CD153B D5 EF D8 33 CD9F3F D1 19 1C E5 D5 CD651D DA391D 2802 ED44 D1 E1 77 2B 1D 20ED C9 CD5F3A CD2E1D CD9F3F 71 23 70 C9 DPOKE: POKE5: PKALP: POKE3: POKENL: POKE2:

JP FARLDIR JR NC,POKE3 DB DB DB DB CALC SWOP STOD0 EXIT ;ADDR,N ;N,ADDR ;N ;EXTRA NUMBERS COUNT ;EXPR COUNT

LD DE,0 RST 18H JR POKE4 PUSH DE CALL SEXPT1NUM POP DE INC E BIT 5,E JP NZ,NONSENSE CP "," JR Z,POKENL CALL CHKEND PUSH DE DB CALC DB RCL0 DB EXIT CALL NPDPS POP DE ADD HL,DE INC E PUSH HL PUSH DE CALL FPTOA JP C,IOORERR JR Z,POKE5 NEG POP DE POP HL LD (HL),A DEC HL DEC E JR NZ,PKALP RET CALL SYNTAX8 CALL GETINT CALL NPDPS LD (HL),C INC HL LD (HL),B RET

;LIMIT EXTRAS TO 31

POKE4:

;N1,N2,N3...Nn,ADDR ;GET ADJUSTED ADDR TO HL, FORMER PAGE TO A ;DE=0 IF ONLY 1 NUMBER ;DEST ADDR FOR TOP NUMBER ON FPCS ;E=NUMBER OF NUMBERS ON FPCS ;JR IF +VE

;EVAL ADDR, NUMBER ;WORD TO POKE TO BC

;PDPSUBR - USED BY POKE, DPOKE, PEEK, DPEEK, CALL ;ENTRY: ADDR ON FPCS. ;EXIT: IF ADDR IS 0-64K, THEN PAGING=ROM0 (OR BASE-1), BASE PAGE, BASE+1, BASE+2 ;IF ADDR>64K, IT IS REDUCED TO 8000-BFFF RANGE AND PAGED IN. E.G. 10000H WOULD ;SWITCH PAGES BASE+3/BASE+4 IN AT 8000-FFFF, HL WOULD BE 8000H ;HL=ADDR, A=ORIG URPAGE. (LRPAGE UNCHANGED) C5 DBFB F5 CD8C3F CBFC 11 PDPSUBR: PUSH BC IN A,(251) PUSH AF CALL UNSTLEN SET 7,H DB 11H ;PRESERVE BC THROUGHOUT ;AHL=ADDR IN PAGE, 8000-BFFF FORM ;"JR+2"

;PDPSR2. USED BY LOAD CODE (EXEC) ;ENTRY: AHL=EXEC ADDR C5 F5 FE04 300F 0E02 B9 2809 3005 CBBC A7 2802 CBF4 79 3D PDPSUBR2: PDPSUBR3: PDPSUBR4: PDPSR2: PDPC: PUSH BC PUSH AF CP 4 JR NC,PDPSUBR4 LD C,2 CP C JR Z,PDPSUBR3 JR NC,PDPSUBR2 RES 7,H AND A JR Z,PDPSUBR3 SET 6,H LD A,C DEC A ;KEEP STACK HAPPY ;JR IF NOT 0000-FFFF ;PAGING WILL BE ROM0,BASE,BASE+1,BASE+2 ;ADDR IS OK IF PAGE IS 2 ;JR IF PAGE 3 - ADD 4000H TO ADDR ;ADDR NOW 0000-3FFF ;JR IF PAGE 0 - ADDR OK ;ELSE ADD 4000H FOR PAGE 1 ADDR ;ADD 4000H TO ADDR

128F 1292 1293 1294 1295 1295 1295 1295 1295 1298 129A 129B 129B 129C 129D 129D 129D 129D 129D 129F 12A0 12A2 12A2 12A5 12A8 12AA 12AD 12AD 12B0 12B3 12B6 12B6 12B7 12BA 12BD 12C0 12C3 12C6 12C7 12C9 12CB 12CB 12CD 12CF 12CF 12CF 12D2 12D4 12D7 12D8 12DB 12DC 12E0 12E2 12E5 12E5 12E7 12E7 12E8 12E9 12E9 12EA 12ED 12ED 12EE 12F0 12F0 12F3 12F5 12F5 12F8 12F9 12F9 12FA 12FC 12FE 12FE 12FF 1300 1301 1303 1303 1306 1309 130A 130B 130E 1310 1310 1311 1312 1314 1315 1316 1319 131A 131B 131E 131F 1320 1323 1326 1326

CDDF3F F1 C1 C9

CALL TSURPG POP AF POP BC RET ;CHECK MODE 2 OR MODE 3

;ORIG URPORT

3A405A FE02 D0 CF 22

CHKMD23: INVMERR: ;READ.

LD A,(MODE) CP 2 RET NC RST 08H DB 34 ;"Invalid screen mode"

E.G. READ A, READ A$, READ LINE A$ CP LINETOK PUSH AF JR NZ,READ2 CALL SSYNTAX1 LD HL,FLAGS BIT 6,(HL) JP NZ,NONSENSE ;Z IF LINE ;SKIP 'LINE', ASSESS VAR FOR ASSIGNMENT ;READ LINE NOT ALLOWED WITH NUMERICS ;SKIP NEXT CALL ;JR IF SYNTAX TIME ;SAVE CHAD IN AUTO-ADJUST VAR SO IF IT PTS TO ;E-LINE THE ASSIGNMENT WON'T BOLIX IT ;ADDRESS DATADD - SWITCH IN ITS PAGE, LD HL ;WITH ADDR PART

FE8C F5 200B CDF62C 213B5C CB76 C2290D C4F72C CDC63A D23C13 DF 22A95A 3A965A 32A85A CD381F 32965A 7E FE20 281E FE2C 281A 22975A 1EB9 2AAF5A E5 CD9C1D D1 ED53AF5A DBFB 32965A 3806 CF 03 23 22975A F1 2805 CDFA2A 1831 01FFFF E5 7E FE22 2005 23 03 BE 20FB CDA200 22975A 23 03 CD753A 20E9 D1 C5 ED52 44 4D CD4D3F EB E5 CD6910 D1 C1 CDE71C CD0F2B DF

READ:

READ2:

CALL NZ,SYNTAX1 CALL RUNFLG JP NC,RJUNKFLG RST 18H LD (PRPTR),HL LD A,(CHADP) LD (PRPTRP),A CALL ADDRDATA LD (CHADP),A LD A,(HL) CP 20H JR Z,READ3 CP "," JR Z,READ3 LD (CHAD),HL LD E,0B9H LD HL,(CLA) PUSH HL CALL SRCHPROG POP DE LD (CLA),DE IN A,(251) LD (CHADP),A ; LD (DATADDP),A JR C,READ4 RST 08H DB 3

;SPACES AND COMMAS ARE OK TO READ FROM. ;OTHERWISE, NEED TO LOOK FOR NEXT DATA STAT. ;NEEDED BY 'SRCHPROG' ;DATATOK ;LOOK FOR 'DATA' FROM CHAD ONWARDS ;CHAD PTS TO JUST AFTER 'DATA' ;ASSUME FOUND... ;** BUG FIX ;JR IF FOUND OK. PAGE MAY BE SWITCHED ;'DATA has all been read'

READ3: READ4:

INC HL LD (CHAD),HL POP JR AF Z,READLN ;JR IF 'READ LINE' ;ASSIGNMENT FOR NON-LINE READ

CALL VALFET1 JR READ7 READLN: READ5: RDSTRL: LD BC,0FFFFH PUSH HL LD A,(HL) CP 22H JR NZ,READ6 INC HL INC BC CP (HL) JR NZ,RDSTRL CALL LD INC INC CALL JR NUMBER (CHAD),HL HL BC COMCRCO NZ,READ5

READ6:

;SKIP FP FORMS ;INC COUNT OF NON-INVISIBLE CHARS ;CHECK IF COMMA, CR OR COLON ;LOOP UNTIL ONE IS FOUND ;LEN WITH NO FP FORMS ;FIND DISTANCE CHAD MOVED ;LEN WITH FP FORMS,+1 ;HL=ROOM START ;FROM (HL) TO 0DH ;FIRST CHAR IN WKSPACE ;NON-INVISIBLE CHAR COUNT ;STORE REGS FOR A STRING ;GET CHAD

POP DE PUSH BC SBC HL,DE LD B,H LD C,L CALL SCOPYWK EX DE,HL PUSH HL CALL REMOVEFP POP DE POP BC CALL STKSTOREP CALL ASSIGN READ7: RST 18H

1327 132A 132C 132F 1332 1335 1338 133B 133C 133C 133D 133E 1340 1341 1341 1342 1345 1345 1345 1345 1345 1345 1348 134A 134A 134B 134E 1351 1354 1355 1357 1358 1359 135B 135B 135C 135C 135F 1360 1360 1361 1364 1366 1366 1366 1366 1366 1368 1369 1369 136B 136C 136D 136D 136E 136F 1370 1370 1370 1372 1373 1376 1377 137A 137B 137B 137C 137F 1380 1381 1381 1381 1381 1381 1381 1381 1381 1381 1381 1381 1381 1382 1384 1387 1388 1389 1389 138C 138E 138E 138F 1392 1395 1395 1398 139B 139E 139E 139E 139E 13A1 13A4 13A4

228B5A DBFB 328A5A 2AA95A 22975A 3AA85A CDCE3F FE F1 DF FE2C C0 E7 C39D12 RJUNKFLG:

LD (DATADD),HL IN A,(251) LD (DATADDP),A LD HL,(PRPTR) LD (CHAD),HL LD A,(PRPTRP) CALL SETCHADP DB 0FEH POP AF RST 18H CP "," RET NZ RST 20H JP READ ;CITEM.SAM - COLOUR ITEMS. ;CALLED BY SYNTAX 9

;UPDATE DATA PTR ;GET REAL CHAD ;'JR +1' ;JUNK F

;SKIP COMMA

CDC63A 3011 AF 32735A CDD211 214F5A 7E F6F8 77 23 CBB6 DF CD6613 D8 DF CD813A 18F6

SYNT9SR:

CALL RUNFLG JR NC,SYN9SR1 XOR A LD (DEVICE),A CALL GRATEMPS LD HL,MASKT LD A,(HL) OR 0F8H LD (HL),A INC HL RES 6,(HL)

;JR IF SYNTAX CHECK ;UPPER SCREEN

;RES 6,PFLAGT=NOT PAPER 9

SYN9SR1: CITEM:

RST 18H CALL CITEMSR RET C RST 18H CALL INSISCSC JR CITEM ;CHECK FOR ,/; THEN SKIP

;CITEMSR - CALLED BY CITEM AND BASIC"S PRINT/INPUT ;EXIT WITH CY IF COLOUR ITEM NOT FOUND FEA1 D8 FEA7 3F D8 4F E7 79 D691 F5 CDE43A C1 CDC63A D0 C5 CD331D 57 F1 CITEMSR: CP 0A1H RET C CP 0A7H CCF RET C LD C,A RST 20H LD A,C ;CALLED BY PERMS COTEMP4: SUB 0A1H-16 PUSH AF CALL EXPT1NUM POP BC CALL RUNFLG RET NC PUSH CALL LD POP BC GETBYTE D,A AF ; INKTOK ;RET IF BELOW "INK" ; OVERTOK+1 ;RET IF ABOVE "OVER" ;SKIP INK/PAPER ETC ;INK. CHANGE TO CONTROL CODE RANGE (16-21) ;PARAM ;CONTROL CODE ;ABORT WITH NC IF SYNTAX TIME ;"COLOUR ITEM DEALT WITH" ;PARAM TO D ;CONTINUE INTO PRCOITEM (ZX USED RST 8)

;CALLED BY PRINT WITH A=CONTROL CODE, D=PARAM ;NOTE: TRANSLATOR ALTERS INK/PAPER 8 OR 9 TO INK/PAPER 17/18. THERE WILL BE ;SOME FAILURES - E.G. INK N. ;INK I; BRIGHT B SELECTS INK I+8*B IN MODE 3 ;BRIGHT IS IGNORED IN MODE 2, ALTHOUGH M0/1 SYS VARS ALTER. ;INK I WITH I>7 SELECTS INK I-8; BRIGHT 1 ;OVER 0/1 ALTERS PFLAG AND OVERT, OVER 0-3 ALSO ALTERS GOVERT TO GIVE GRAB CMD"S ;XOR/AND OPTIONS. F7 2BF0 CDAC11 A7 C9 CDC63A 3007 AF 32735A CD8E11 3A745B CD7013 CD153B 214E5A 11455A PER2: PRCOITEM: RST 30H DW PRCOITEM2 CALL COLEX AND A RET CALL RUNFLG JR NC,PER2 XOR A LD (DEVICE),A CALL TEMPS LD A,(CURCMD) CALL COTEMP4 CALL CHKEND LD HL,ATTRT LD DE,ATTRP ;COLOUR EXPANSION TABLE IF NEEDED ;NC SHOWS COLOUR ITEM DEALT WITH ;JR IF NOT RUNNING ;UPPER SCREEN ;GET CMD VALUE ;ALTER TEMP VALUES ACCORDING TO COLOUR CMDS

PERMS:

;CALLED BY CLS# PER3:

;USED BY SCREEN SCROLL

13A4 13A4 13A7 13A9 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AA 13AB 13AB 13AB 13AB 13AE 13AE 13B2 13B3 13B5 13B8 13B8 13B9 13BA 13BD 13BD 13BE 13C1 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C2 13C5 13C7 13C8 13C9 13CB 13CE 13CF 13D0 13D0 13D1 13D1 13D2 13D3 13D4 13D5 13D6 13D6 13D8 13D8 13DA 13DC 13DC 13DD 13DF 13DF 13E0 13E2 13E2 13E3 13E5 13E6 13E7 13E8 13E8 13EA 13EA 13EB 13EF

010800 EDB0 C9

LDIR8:

LD BC,8 LDIR RET

;COPY TEMP VALUES TO PERMS ;(ATTRT-GOVERT)

;CHLETCHK, TEMPS, DATA, RESTORE, CITEM, PERMS, ;POKE, DPOKE, PDPSR, CHKM23 INCLUDE LOOKVAR.SAM ;SETUP VARS ;LOOKVAR.SAM ;ENTRY: A VARIABLE (STARTS WITH A LETTER) IS EXPECTED AT (CHAD) ;(HL)/A=FIRST LETTER ;ACTION: LOOK IN VARIABLES AREA FOR IT ;EXIT: Z IF VAR NOT FOUND: C=TYPE/LEN BYTE; BITS 4-0=NAME LENGTH, EXCLUDING ; FIRST CHARACTER. BIT 5 IS SET FOR NUMERIC ARRAYS. ; STRINGS: HL PTS TO FF TERMINATOR OF STRING/ARRAY VARS ; NUMBERS: HL PTS TO MSB OF PTR (FF) THAT TERMINATES LIST FOR LETTER. ; NZ IF FOUND. HL POINTS TO VALUE IN VARS. (FOR NUMS, FIRST OF 5 BYTES, ; FOR STRINGS, LEN IN PAGES, FOLLOWED BY LEN MOD 16K AND TEXT) ; C=TYPE/LEN BYTE FROM VARS. NUMS: BIT 6 SET=FOR-NEXT ; STRINGS/ARRAYS: BIT 6 SET=STR ARRY, BIT 5 SET=NUM ARRY ; ;ALWAYS: BIT 6,(FLAGS) IS SET FOR NUMERICS, RES FOR STRINGS ; NAME IS IN BUFFER AT "FIRLET" (FIRST LETTER IS CODED TABLE OFFSET) DF CD8D14 ED53975A 79 E660 C22014 7E 87 F22014 79 323F51 D0 LOOKVARS: LKVARS2: RST 18H CALL NAMTOBUF LD (CHAD),DE LD A,C AND 60H JP NZ,STARYLK LD A,(HL) ADD A,A JP P,STARYLK LD A,C LD (TLBYTE),A RET NC ;MOVE PAST NAME, COPY TO BUFFER, GET C=TYPE/LEN ;HL=FLAGS, A=NAME TERMINATOR ($/(/OTHER) ;PT PAST NAME (AND ANY (/$) IN BASIC LINE ;JP IF AN ARRAY ;FLAGS ;JP IF STRING ;RET IF SYNTAX TIME. NZ="FOUND" (BIT 7=1 FOR MINUS) ;ENTRY FROM EVAL

;LOOK FOR A NUMERIC VARIABLE ROUTINE ;NVARS PTS TO A TABLE OF WORD PTRS. IF THE MSB OF THE PTR IS 0FFH, THERE ; ARE NO MORE VARS STARTING WITH THAT LETTER. (SO TO CLEAR NUM VARS, INIT ; TABLE WITH FFs.) IF PTR MSB<>FF THEN ADD PTR TO GET ADDR. OF ; TYPE/LENGTH BYTE FOR NEXT VAR. NOTE: THERE MAY BE NO SECOND LETTER. ; TYPE | PTR LSB | PTR MSB | SECOND LET | .. | LAST LET | VALUE ; TYPE/LEN BYTE HAS BIT 7 SET FOR HIDDEN, BIT 6="FOR" VAR ; BITS 4-0=LEN-1. (0 FOR 1-LETTER VAR NAME, 31 FOR 32 LETTER MAX) ;ENTRY: ; ;EXIT: ; ; ; ; 3A4051 D661 87 5F 1600 CD1F1F 19 FE E1 79 5E 23 56 19 3829 CB74 202B AE E6BF 23 20EF 79 E61F E5 23 23 2810 47 DD214151 NVSIEN: NUMLOOK: NAME IS IN BUFFER STARTING AT "FIRLET", LETTERS UPPER CASE, NO SPACES C=DESIRED TYPE/LEN BYTE Z IF VAR NOT FOUND, C=TYPE/LEN BYTE. HL PTS TO LSB OF PTR (FFFF) THAT TERMINATES LIST FOR LETTER. NZ IF FOUND. HL POINTS TO VALUE IN VARS, IX-1 PTS TO TYPE BYTE, C=TYPE/LEN FROM VARS, DE=PTR ADDED TO PREV VAR. PTR MSB ADDR TO PT TO THIS VAR"S T/L BYTE LD A,(FIRLET) SUB 61H ADD A,A LD E,A LD D,0 CALL ADDRNV ADD HL,DE DB 0FEH POP HL LD A,C LD E,(HL) INC HL LD D,(HL) ADD HL,DE JR C,NVSPOV BIT 6,H JR NZ,NVSINCP XOR (HL) AND 0BFH INC HL JR NZ,NVMLP LD A,C AND 1FH PUSH HL INC HL INC HL JR Z,NVSFND LD B,A LD IX,FIRLET+1 ;DESIRED TYPE/LEN ;PTR=FFFFH IF NO MORE VARS START WITH REQUIRED ; LETTER. CAUSES CARRY AND CHECK FOR FF IN NVSPOV ;ELSE DE IS A PTR TO NEXT VAR STARTING ; WITH REQUIRED LETTER. ;JR IF SEVERE PAGE OVERFLOW ;KEEP IN 8000-BFFF REGION ;IS IT DESIRED TYPE/NAME LENGTH? IGNORE BIT 6 ;MISMATCH ("FOR" FLAG) ;PT TO PTR LSB ;LOOP TIME=84Ts ;ISOLATE NAME LENGTH ;SAVE PTR TO PTR LSB IN CASE MATCH FAILS ; ;SKIP PTR BYTES. ;HL=PTR TO NAME 2ND. LETTER IN VARS AREA. ;JR IF SINGLE LETTER VAR - ALREADY MATCHED. ;PT TO SECOND LETTER

;LETTER TRANSFORMED TO WORD OFFSET (A=0, B=2..) ;PT. HL AT NUMERIC VARS, PAGED IN ;INDEX INTO TABLE OF WORD PTRS. ;"JR+1"

NVMOLP: NVMLP:

13EF 13F2 13F3 13F5 13F5 13F7 13F8 13FA 13FA 13FC 13FF 13FF 1400 1401 1401 1401 1401 1401 1402 1403 1403 1406 1407 1407 140A 140A 140B 140D 140D 140D 140D 140D 1410 1411 1413 1414 1415 1417 1419 141C 141E 141E 141E 1420 1420 1420 1420 1420 1420 1420 1420 1420 1420 1420 1420 1420 1420 1420 1421 1422 1425 1427 1429 142C 142C 142D 142E 1430 1430 1431 1431 1431 1431 1432 1433 1435 1437 1438 1438 143B 143D 143D 1440 1442 1445 1446 1447 1447 1448 1449 144A 144A 144A 144C 144C 144D 144E 144F 144F 1450 1451 1452 1453

DD7E00 BE 20DB DD23 23 10F5 DDE1 DD4EFF 3C C9

NVMTCHLP:

LD A,(IX+0) CP (HL) JR NZ,NVMOLP INC IX INC HL DJNZ NVMTCHLP

;EXIT IF MATCH FAILS ;LOOP TILL WHOLE NAME MATCHES. HL PTS TO VALUE. ;PTR TO PTR LSB ;C=TYPE/LEN FROM VARS ;NZ STATUS ;PREV. VAR PTR MSB IS AT IX-DE-1

NVSFND: NZST:

POP IX LD C,(IX-1) INC A RET

;PAGE OVERFLOW - MIGHT BE DUE TO LOTS OF VARS, OR PTR MSB=FF (TERMINATOR) 14 C8 CD9D1F BF C4F23F 79 18CF NVSINCP: NVSPOV: INC D RET Z CALL PGOVERF CP A CALL NZ,INCURPAGE LD A,C JR NVSIEN ;FROM PARPRO ;ENTRY: HL POINTS TO NAME ON BSTK, A=T/L BYTE. 114051 47 E60F 4F 78 0600 EDB0 22C45B E66F 1811 LKBSV: LD DE,FIRLET LD B,A AND 0FH LD C,A LD A,B LD B,0 LDIR LD (BSTKEND),HL AND 6FH JR STARYLK2 ;LOOK FOR A STRING OR ARRAY ;ENTRY: NAME IS IN BUFFER AT "FIRLET" ; C=TYPE/LEN BYTE. BIT 5 SET IF NUMERIC ARRAY, BIT 6 SET IF STRING ARRAY ; OR SLICED STRING. (IF BIT 6 AND BIT 5=0, SIMPLE STRING NAME) ;EXIT: Z IF VAR NOT FOUND. C=ORIG TYPE/LEN BYTE, STRLOCN/HL" PT TO STOPPER. ; NZ IF FOUND. HL POINTS TO LEN IN PAGES, C/(DE)=TYPE/LEN IN VARS, ; STRLOCN=TYPE/LEN IN VARS ;VARS AREA HOLDS TYPE/LEN BYTE, FIRST LET,..LAST LET, PADDED TO 10 CHARS, ;LEN IN PAGES, LEN MOD 16K, TEXT. REPEATED UNTIL FF STOPPER ;TYPE/LEN BIT 7=HIDDEN, 6=STRING ARRAY, 5=NUMERIC ARRAY (6 AND 5 LOW=SIMPLE $) ;USES ALL REGS 0C 79 323F51 E61F FE0B D2B214 7E 17 30CF 79 D9 4F 061F 1EBF D9 CD271F DBFB 114051 D3FB 22BC5B 7E D9 67 A9 A3 201E 7C A0 D9 47 23 1A BE 2018 LKSTRLP: STARYLK2: STARYLK: INC C LD A,C LD (TLBYTE),A AND 1FH CP 11 JP NC,INVVARNM LD A,(HL) RLA JR NC,NZST LD A,C ;CALLED BY PROCESS PARAMS EXX LD C,A LD B,1FH LD E,0BFH EXX CALL ADDRSAV IN A,(251) LD DE,FIRLET OUT (251),A LD (STRLOCN),HL LD A,(HL) EXX LD H,A XOR C AND E JR NZ,TLNOMTCH LD A,H AND B EXX LD B,A INC HL LD A,(DE) CP (HL) JR NZ,FLNOMTCH ;B"=1FH. ISOLATE NAME LEN. (SAME FOR DESIRED ;AND CANDIDATE NAME) ;FIRLET ;DO A QUICK CHECK ON FIRST LETTER. ;JR IF FAIL ;C"=DESIRED TYPE/LEN (LEN NOW TRUE NAME LEN) ;B"="LEN" MASK ;E"=MASK TO FORCE BIT 6 LOW ;PT HL AT STR/ARRAY VARS, SWITCHED IN. ;START WITH CURRENT PORT VALUE ;PT TO START OF STORED NAME. ;NO EFFECT ON FIRST PASS, AND MANY OTHERS ;SAVE START OF CURRENT STRING/ARRAY ;GET TYPE (BITS 7-5) AND NAME LEN (BITS 4-0) ;SAVE DATA FROM VARS BRIEFLY ;XOR WITH DESIRED ;AND RESULT WITH BFH. ;(SEE IF TYPE/LEN FROM VARS=DESIRED T/L IN C". ;IGNORE BIT 6 MISMATCH (SIMPLE VS. ARRAY STRINGS) ;NOT FOUND - Z. HL HAS MOVED BACK BY 1 TO PTR LSB ;Z

;BC=NAME LEN ;COPY STORED NAME FROM BSTK TO FIRLET BUFFER ;MASK BIT THAT SHOWS IF A GLOBAL VERSION WAS HIDDEN ;(7) - LOOK FOR "VISIBLE" FORM USED LOCALLY ;ALSO FORCE BIT 4 LOW ;A=DESIRED T/L BYTE

;ISOLATE NAME LEN ;ERROR IF STRING/ARRAY NAME LONGER THAN 10 CHARS ;EXCLUDING $ OR ( ;IF SYNTAX TIME, SET NZ ("FOUND") (A REG COULD NOT ;HAVE HELD FFH)

1455 1455 1457 1457 1458 1459 145A 145B 145D 145D 145F 145F 1462 1463 1464 1467 1468 1469 146A 146A 146B 146C 146C 146D 146D 1470 1473 1474 1476 1477 1478 1479 147A 147B 147C 147D 147F 147F 1481 1483 1483 1485 1485 1486 1488 1488 1489 148B 148D 148D 148D 148D 148D 148D 148D 148D 148D 148D 148D 148D 148D 148D 148F 1492 1495 1497 1498 1498 1499 149A 149C 149E 149E 14A1 14A3 14A3 14A5 14A7 14A7 14A9 14A9 14AB 14AB 14AC 14AD 14AF 14AF 14B2 14B2 14B3 14B4 14B4 14B4 14B4 14B4 14B5 14B8 14BA 14BB 14BC 14BD 14BF 14C1

1806 23 13 1A BE 2010 10F8 2ABC5B 4E EB 210C00 2D 19 C9 24 C8 D9 2ABC5B 010B00 09 DBFB 86 23 4E 23 46 23 09 3809 CB74 28BA CBB4 3C 18B5 3C CBFC 18F8 LKSI: LKSTRPO: FLNOMTCH: TLNOMTCH: STMTCHLP:

JR DCNMLN INC HL INC DE LD A,(DE) CP (HL) JR NZ,FLNOMTCH DJNZ STMTCHLP LD HL,(STRLOCN) LD C,(HL) EX DE,HL LD HL,12 DEC L ADD HL,DE RET INC H RET Z EXX LD HL,(STRLOCN) LD BC,11 ADD HL,BC IN A,(251) ADD A,(HL) INC HL LD C,(HL) INC HL LD B,(HL) INC HL ADD HL,BC JR C,LKSTRPO BIT 6,H JR Z,LKSTRLP RES 6,H INC A JR LKSTRLP INC A SET 7,H JR LKSI

;ELSE CHECK ENTIRE NAME ;B=1-10

DCNMLN:

;T/L BYTE FROM VARS ;NZ ;HL PTS TO LEN IN PAGES, DE PTS TO T/L BYTE ;TEST FOR FF STOPPER ;RET IF IT IS. Z SHOWS NOT FOUND, C=DESIRED T/L

;SKIP NAME, PT TO LEN IN PAGES ;ADD PAGES OF STRING/ARRAY LENGTH

;PTS TO TEXT ;BC (0-3FFF) ADDED TO PT HL TO NEXT T/L BYTE ;DEAL WITH RARE CASE OF STRLOC NEAR PAGE C END, BC ;NEAR 16K ;JR IF HL STILL IN 8000-BFFF REGION ;=SUB 4000H ;INC PAGE TO COMPENSATE ;OVERFLOWED INTO 0000-3FFF - CORRECT BY 2 PAGES ;8000-BFFF AGAIN

;NAME TO BUFFER ;ALTERS HL, DE, BC, A ;ENTRY: HL PTS TO A CHAR, ALSO HELD IN A ;EXIT: DE POINTS TO CHAR PAST NAME ; NAME, COMPRISING ALPHANUMERICS OR UNDERLINE CHARS, COPIED TO BASE PAGE ; BUFFER AT "FIRLET", WITH SPACES REMOVED AND LOWER CASE FORCED. ; HL=FLAGS ADDR ; C BITS 4-0=NAME LEN, EXCLUDING FIRST CHAR. (0-31) ; BIT 6,C SET IF STRING ARRAY OR SLICED STRING ; BIT 5,C SET IF NUMERIC ARRAY ; BIT 6,(FLAGS) SET IF NUMERIC, RES IF STRING 0620 114051 CDEC3A F620 12 23 7E FE20 28FA CD2C3B 3806 FE5F 200D 1802 F620 13 12 10E9 22975A CF 28 INVVARNM: NMTB2: NMTB3: NAMTOBUF: LD B,32 LD DE,FIRLET CALL GETALPH OR 20H LD (DE),A INC HL LD A,(HL) CP 20H JR Z,NMTBL CALL ALPHANUM JR C,NMTB2 CP "_" JR NZ,NAMEND JR NMTB3 OR 20H INC DE LD (DE),A DJNZ NMTBL LD (CHAD),HL RST 08H DB 40 ;FORCE LOWER CASE (NUMS UNAFFECTED) ;LOOP TILL LENGTH ILLEGAL ;(FOR XPTR) ;"Invalid variable name" - USUALLY SPOTTED IN ;SYNTAX CHECK ;MAX LEN+1 FOR A NAME (EXCLUDING 1ST CHAR) ;PT TO NAME BUFFER IN COMMON MEMORY ;FIRST LETTER STORED

NMTBL:

;SKIP SPACES ;SEE IF LETTER, NUMBER OR UNDERLINE ;JR IF ALPANUMERIC

;NAME PROPER HAS NOW ENDED, BUT TYPE CHARACTER MAY FOLLOW EB 213B5C 3E20 90 4F 1A FE24 200B NAMEND: EX DE,HL LD HL,FLAGS LD A,32 SUB B LD C,A LD A,(DE) CP "$" JR NZ,NMEN2

;C=NAME LENGTH-1, RANGE 0-31. ;JR IF NUMERIC VAR

14C1 14C3 14C4 14C5 14C7 14C8 14C8 14C9 14CB 14CC 14CC 14CE 14D0 14D1 14D1 14D2 14D4 14D5 14D5 14D7 14D8 14D9 14DA 14DA 14DD 14DE 14E1 14E2 14E3 14E3 14E3 14E3 14E3 14E3 14E3 14E3 14E6 14E8 14E9 14EC 14ED 14ED 14EF 14F0 14F1 14F1 14F2 14F2 14F3 14F3 14F3 14F3 14F4 14F6 14F6 14F8 14FA 14FA 14FC 14FF 14FF 14FF 14FF 1502 1503 1505 1505 1506 1509 150C 150C 150F 1510 1513 1513 1515 1517 1517 151A 151A 151D 151E 151E 1521 1521 1524 1524 1527 1528 152B 152B 152E 1530 1530 1532 1535 1535 1537 1537 1537 1537 1538 153A

CBB6 13 1A FE28 C0 13 CBF1 C9 CBF6 FE28 C0 13 CBE9 C9 3E20 90 4F C9 CDAA13 08 3A3B5C 87 C9 LVFLAGS: NMEN2:

RES 6,(HL) INC DE LD A,(DE) CP "(" RET NZ INC DE SET 6,C RET SET 6,(HL) CP "(" RET NZ INC DE SET 5,C RET LD A,32 SUB B LD C,A RET

;"STRING"

;"STRING ARRAY" ;"NUMERIC"

;"NUMERIC ARRAY"

;C=NAME LENGTH-1, RANGE 0-31.

CALL LOOKVARS EX AF,AF' ;Z IF NOT FOUND LD A,(FLAGS) ADD A,A RET ;M IF NUM, P IF $, CY IF RUNNING INCLUDE EVAL.SAM ;ROM 0 FNS ;EVAL.SAM - SAM EXPRESSION EVALUATOR (ROM0). EXITS WITH PAGING UNCHANGED. ;ENTRY: CHAD PTS TO FIRST CHAR. EXIT: RESULT ON FPCS IF RUNNING, ELSE SYNTAX ;CHECKED AND 5-BYTES INSERTED IF NEEDED. BIT 6,(FLAGS)=0 IF STRING RESULT, ;ELSE NUMERIC. CHAD PTS TO CHAR THAT CANNOT BE PART OF EXPR. A=CHAR, HL=CHAD ;******************************************************************************* SCANNING: CALL R1OFFCL DW SCANSR LD C,A LD A,(FLAGS) RET LD D,0 RST 18H DB 0FEH RST 20H PUSH DE ;FROM UNARY PLUS WITH HL=CHAD SCANLP: LD E,A AND 0DFH ;CURRENT CHAR ;PRIORITY "STOPPER" ;GET FIRST CHAR. HL=CHAD ;"JR+1" ;NEXT CHAR ;PRIORITY/CODE

CD0102 ED14 4F 3A3B5C C9 1600 DF FE E7 D5 5F E6DF FE5B 303D FE41 DA9915 3A555C A7 2026 7E CDAB13 CA082D 3A3B5C 87 F21715 CB69 280A CD542D 3A3B5C 87 F2F115 DC201D CDD73F DF C3F915 CD6E33 30D5 FE24 CAF415 18ED 1C 2069

SCANSR: SCANPLP:

;LETTERS BECOME UPPER CASE

CP 5BH ;"Z"+1 JR NC,ABOVLETS CP "A" JP C,BELOWLETS ;JR UNLESS WE HAVE A LETTER ;EVALUATE A VARIABLE SLETTER: SLET1: LD A,(DEFADD+1) AND A JR NZ,SLLKFV LD A,(HL) CALL LKVARS2 JP Z,VNFERR LD A,(FLAGS) ADD A,A JP P,SLET2 BIT 5,C JR Z,SLET3 SLET2: CALL STKVAR2 LD A,(FLAGS) ADD A,A JP P,SCONT1 SLET3: SLET4: SLLKFV: CALL SELCHADP RST 18H JP OPERATOR CALL LKFNVAR JR NC,SLET1 CP "$" JP Z,SCONT2 JR SLET4 ;******************************************************************************* ABOVLETS: INC E JR NZ,EVNONSE ;ERROR UNLESS FF FUNCT LEADER FOUND ;JR IF STRING - CHECK FOR SLICER, THEN OPERATOR CALL C,HLTOFPCS ;STACK NUM IF RUNNING ;AN OPERATOR OR A TERMINATOR MUST FOLLOW ;JR IF NOT FOUND OR SYNTAX TIME ;PTS PAST DEF FN "(" IF FN BEING EVALED. ;CHECK DEF FN BRACKETS FOR VAR IF DEFADD-HI NZ ;ERROR IF NOT FOUND ;CY IF RUNNING ;JP IF STRING ;JR IF NOT (NUMERIC) ARRAY ;IF STRING, STACK START AND LEN, IF N ARRAY ;GET HL=START ADDR OF ELEMENT

153A 153B 153C 153E 153F 1542 1542 1545 1546 1547 154A 154A 154C 154E 154E 1550 1552 1554 1554 1556 1558 1558 155A 155D 155E 155F 155F 1561 1561 1561 1561 1561 1562 1564 1566 1567 1569 1569 156A 156D 156D 156D 156D 1570 1571 1573 1573 1573 1573 1573 1573 1573 1573 1573 1573 1573 1573 1575 1577 1577 1578 1579 157B 157E 157F 1580 1581 1582 1585 1587 1589 1589 158C 158C 158D 158F 1592 1592 1593 1594 1594 1597 1599 1599 1599 1599 159A 159C 159F 159F 15A1 15A3 15A3 15A4 15A5 15A5 15A5 15A5 15A5 15A6 15A7 15A7 15AA

23 7E D61A 5F 22975A 2AF65A 24 25 C40500 FE39 3825 16CF FE4F 389D FE5D 304B 1600 214716 19 56 1890 SCANUMEN:

INC HL LD A,(HL) SUB 1AH LD E,A LD (CHAD),HL

;GET FUNCTION CODE ;ADJUST 3B-83H TO 21H-69H ;SKIP "FF"

LD HL,(EVALUV) INC H DEC H CALL NZ,HLJUMP ;IF VECTORED JUMP WITH A=FN CODE. CP SIN JR C,IMMEDCODES LD D,0CFH CP EOF+3 JR C,SCANPLP CP NOT+1 JR NC,EVNONSE ;"PRIORITY 0F, N ARG, N RESULT" ;JR IF SIN-EOF/PTR/POS ;RANGE NOW UDG-NOT

LD D,0 LD HL,FNPRIORT-UDGA ADD HL,DE LD D,(HL) ;FETCH PRIORITY AND INPUT/OUTPUT TYPE. (BIT 7=1/0 ;FOR N/$ RESULT, BIT 6=DITTO FOR ARGUMENT) JR SCANPLP ;STACK DE, GET NEXT CHAR, LOOP

;******************************************************************************* ;INKEY$ - THIS IS MAIN (NON-FPC) ROUTINE E7 FE23 1E5B C1 28EF C5 CD153B CDB11C F7 CE4F IMINKEYS: RST 20H CP "#" LD E,INKEY POP BC JR Z,SCANUMEN PUSH BC CALL ABORTER CALL READKEY RST 30H DW FPINKEN-8000H ;SKIP "INKEY" ;FPC INKEY$ CODE ;RET ADDR (STRCONT) ;STREAM VERSION HANDLED BY FPC. "#" WILL BE SKIPPED ;(WE CANNOT USE THE NORMAL INPUT STREAM FOR INKEY$ ;ON ITS OWN, SINCE THAT WOULD NOT CAUSE A KEYSCAN, ;BUT WOULD JUST FETCH LAST-K ;RETURNS KEY CODE IN A AND CY IF OK ;MAKE 1-CHAR STRING AND STACK PARAMS

;******************************************************************************* ;SOME FUNCTIONS HAVE TO BE HANDLED AT ONCE BECAUSE THEY HAVE NO ARGUMENTS ;(LIKE PI) OR BECAUSE THEY HAVE SEVERAL ARGUMENTS IN BRACKETS (LIKE POINT). ;NUM. RESULT: PI, RND, POINT, FREE, LENGTH, ITEM, ATTR, FN, BIN, HIMEM, XMOUSE, ;YMOUSE, XPEN, YPEN, INARRAY, INSTR. ;STR. RESULT: INKEY$, SCREEN$, MEMORY$, CHAR$, PATH$, STRING$, USING$, SHIFT$ D621 382C 87 5F 1600 21A516 19 4E 23 46 21E915 FE1F 3803 219415 E5 CB78 C2EA01 C5 C9 CD3E2E 185B 7B FE30 DAD516 FE3A 3804 CF 1D EVNONSE: STRCONT: IMMEDNUM: IMMEDCODES: SUB PI JR C,EVNONSE ;RANGE NOW PI-SHIFT$

ADD A,A LD E,A LD D,0 LD HL,IMFNATAB ADD HL,DE LD C,(HL) INC HL LD B,(HL) LD HL,NUMCONT CP 0+(INSTR-PI)*2+1 JR C,IMMEDNUM LD HL,STRCONT PUSH HL BIT 7,B JP NZ,R1ONCLBC PUSH BC RET CALL SLLPEX JR SCONT2 LD A,E CP "0" JP C,BELOWNUM CP 3AH JR C,SDECIMAL RST 08H DB 29 ;"NONSENSE" ;JP TO BC ;SIGNAL STRING RESULT

;******************************************************************************* BELOWLETS:

;******************************************************************************* ;HANDLE LITERAL NUMBER (0-9, DECIMAL PT., BIN OR AMPERSAND F1 DF 3A3B5C 17 IMBIN: SDECIMAL: POP AF RST 18H LD A,(FLAGS) RLA ;JUNK RET TO IMMEDNUM+3 ;GET HL=CHAD

15AB 15AD 15AD 15AE 15AF 15B1 15B3 15B3 15B4 15B7 15BB 15BD 15C1 15C1 15C4 15C6 15C6 15C9 15CC 15CF 15D0 15D3 15D6 15D8 15D9 15DB 15DB 15DB 15DB 15DE 15E0 15E2 15E2 15E3 15E6 15E7 15E9 15E9 15E9 15E9 15EC 15EE 15EF 15F1 15F1 15F4 15F4 15F5 15F5 15F5 15F7 15F9 15F9 15F9 15F9 15FB 15FC 15FE 15FE 15FF 1600 1602 1604 1604 1606 1608 1608 160B 160B 160D 160F 160F 1611 1613 1613 1615 1617 1617 1619 161B 161B 161D 161F 161F 1621 1623 1623 1625 1627 1629 1629 162A 162D 162E 162F 162F 1630 1631 1632 1634 1636 1636 1637

3019 23 7E FE0E 20FA 23 010500 ED5B655C EDB0 ED53655C 22975A 1823 CD5517 2A975A CD6433 EB CD121D 010500 EDB0 EB 18E6 213B5C CB76 204D E7 CD692E E7 180C 213B5C CBF6 DF 1808 CDD73F DF FE28 28E2 1600 3C 2011 23 7E D67A 382B FE0A 3027 22975A C608 181A D62B 381C FE04 2818 FE06 380E FE12 3810 FE15 3806 FE34 3E04 2006 5F 218116 19 56 C1 78 92 E610 2028 B0 CA1800 OPERAT3: OPERAT2: NUMCONT: SCHADNUM: INSERT5B: LK0ELP:

JR NC,INSERT5B ;JR AND INSERT THE INVISIBLE FORM IF SYNTAX TIME INC HL LD A,(HL) CP 0EH JR NZ,LK0ELP ;LOOP TILL NUMBER MARKER FND. INC HL LD BC,5 LD DE,(STKEND) LDIR ;COPY NUMBER TO FPCS LD (STKEND),DE LD (CHAD),HL JR NUMCONT CALL CALC5BY LD HL,(CHAD) CALL MAKESIX EX DE,HL CALL FDELETE LD BC,5 LDIR EX DE,HL JR SCHADNUM LD HL,FLAGS BIT 6,(HL) JR NZ,SLOOP RST 20H CALL SLICING RST 20H JR SLSTRLP LD HL,FLAGS SET 6,(HL) RST 18H JR OPERATOR CALL SELCHADP RST 18H CP "(" JR Z,SSLICER LD D,0 INC A JR NZ,OPERAT2 INC HL LD A,(HL) SUB MODTOK JR C,SLOOP CP 0AH JR NC,SLOOP LD (CHAD),HL ADD A,8 JR OPERAT3 SUB "*"+1 JR C,SLOOP CP 4 JR Z,SLOOP CP 6 JR C,OPERAT3 CP 12H JR C,SLOOP CP 15H JR C,OPERAT3 CP 34H LD A,4 JR NZ,SLOOP ;JR IF "<", "=" OR ">" (NOW 12H-14H) ;POWER-OF ;PRIORITY=0 ;JR IF NOT FF FN CODE LEADER ;FETCH OPERATOR CODE ;STRING EXPRESSIONS CAN BE FOLLOWED BY A SLICER ;EG (STR$ 123)(2) SO CHECK FOR THIS BEFORE LOOKING ;FOR AN OPERATOR OR TERMINATOR ;FIND 5-BYTE FORM OF DEC, HEX OR BIN NUMBER ;MAKE 6 SPACES IN ELINE, PLACE 0EH, INC HL ;HL PTS TO DELETED NUMBER, DE TO ROOM IN ELINE ;COPY 5 BYTES TO ELINE ;SET NUMERIC, SET CHAD

;******************************************************************************* SSLICER: ;NUMBERS CANNOT HAVE A SLICER - TERMINATE ;SKIP "("

;******************************************************************************* ;SIGNAL "NUMERIC"

SCONT1: SCONT2: SLSTRLP:

;DEAL WITH BINARY OPERATORS: +,-,*,/,^,=,>,<,<=,>=,<>,OR,AND,MOD,IDIV,BOR, ETC. OPERATOR:

;RANGE NOW 00-09 FOR MOD TO ">=" ;SKIP FF ;MOD TO ">=" BECOME 08-11H ;MULT IS 0, DIVN IS 5, "<" IS 12H, ">" IS 14H ;JR IF BELOW BINARY OPERATOR RANGE ;EXCLUDE "." ;JR IF WITHIN RANGE FOR * TO /

LD E,A ;E=BIN OPERATOR CODE 00-14H LD HL,OPPRIORT ADD HL,DE LD D,(HL) ;FETCH OPERATOR PRIORITY, OR 0 IF NOT RECOGNISED POP BC LD A,B SUB D AND 10H JR NZ,PRIGRTR OR B JP Z,0018H ;PREV PRIORITY (B) AND OPERATION CODE (C) ;IF PRIORITY NIBBLE IS HIGHER IN D, BIT 4 WILL BE 1 ;JR IF CURRENT PRIORITY HIGHER - WAIT ;ELSE B PRIORITY IS >=D ;EXIT IF BOTH PRIORITIES ARE ZERO

SLOOP:

163A 163A 163B 163E 163F 1640 1642 1642 1643 1644 1644 1644 1645 1648 1648 164A 164A 164B 164C 164C 164D 164E 164F 164F 1650 1653 1653 1654 1655 1657 1658 165A 165A 165C 165E 165E 165E 165E 165F 1662 1663 1666 1666 1666 1666 1667 1667 1667 1667 1669 166B 166D 166D 166F 1670 1672 1674 1674 1676 1678 167B 167B 167D 167E 167E 1681 1681 1681 1681 1681 1682 1683 1684 1685 1686 1687 1688 1689 168A 168B 168C 168D 168E 168F 168F 1690 1691 1692 1693 1694 1695 1696 1696 1696 1696 1696 1696 1697 1698 1699 169A 169B 169C

D5 213B5C 7E 17 3808 78 AE 87 FAA315 1809 C5 41 EF 24 33 C1 213B5C 78 D1 CBF6 17 38D5 CBB6 18D1 C5 3A3B5C 87 FAF114 7B CBBA FE0E 280E CBB2 1C FE01 280A CBFA FE0E DA290D C607 5F C3F114 SCANPLPH: SCANPH2: PRIGRTR: CHKEXECC: EXECOP:

PUSH DE LD HL,FLAGS LD A,(HL) RLA JR C,EXECOP LD A,B XOR (HL) ADD A,A JP M,EVNONSE JR CHKEXECC PUSH BC LD B,C DB CALC DB USEB DB EXIT POP BC LD HL,FLAGS LD A,B POP DE SET 6,(HL) RLA JR C,SLOOP RES 6,(HL) JR SLOOP PUSH BC LD A,(FLAGS) ADD A,A JP M,SCANPLP LD A,E RES 7,D CP 0EH JR Z,SCANPLPH RES 6,D INC E CP 1 JR Z,SCANPH2 SET 7,D CP 0EH JP C,NONSENSE ADD A,7 LD E,A JP SCANPLP

;CURRENT PRIORITY/CODE ;CY IF RUNNING ;PERFORM OPERATION IF RUNNING ;PRIORITY CODE OF FN TO BE CHECKED/EXECUTED ;CHECK THAT FNS THAT WORK ON STRINGS HAVE STRING ;"LAST VALUE"S, AND DITTO FOR NUMERICS. BIT 6 OF ;PRIORITY CODE IS 0 IF FN WORKS ON STRINGS, ELSE 1 ;ERROR IF BIT 6,(FLAGS)<>BIT 6 OF FN CODE

;FN CODE TO EXECUTE

;PRIORITY CODE OF FN JUST CHECKED/EXECUTED ;NEXT PRIORITY/CODE ;"LAST VALUE IS NUMERIC" ;BIT 7 OF THE P. CODE IS SET IF ITS RESULT IS A NUM ;JR IF WE SET FLAGS CORRECTLY ;"LAST VALUE IS STRING"

;******************************************************************************* ;PREV PRIOR/CODE ;LOOP IF NUMERIC - I.E. LEAVE TYPE CODE BITS ;ALONE IF A NUMERIC IS FOLLOWED BY A BINARY ;OPERATOR - THEY ARE SET FOR NUMERIC I/P AND O/P ;CURRENT CODE ;ALL LEGAL $ BINARY OPS EXCEPT "+" WILL GET ;CODES 7 ABOVE THEIR NUMERIC EQUIVALENTS ;RESULT TYPE WILL BE STRING FOR "+" AND "AND" ;CP "AND" " ;IF "AND" LEAVE "INPUT" BIT AS NUMERIC FOR ;"$ AND N" ;ELSE "INPUT" BIT IS STRING E.G. "$+$", "$<$" ;IF "+", E=2 ;CP "+" ;JP WITH STRING INPUT AND OUTPUT FOR "+" ;NUMERIC OUTPUT FOR E.G. "$>$" ;CP "AND" ;E.G. $ MOD $ IS AN ERROR

;JP TO STACK DE AND GET NEXT CHAR

;******************************************************************************* ;BINARY OPERATOR PRIORITY TABLE C8 C6 00 C6 CF C8 00 00 CE CE C2 C2 C3 C2 C3 C5 C5 C5 C5 C5 C5 OPPRIORT: DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB 0C8H 0C6H 0 0C6H 0CFH 0C8H 0 0 0CEH 0CEH 0C2H 0C2H 0C3H 0C2H 0C3H 0C5H 0C5H 0C5H 0C5H 0C5H 0C5H ;0 ;1 ;2 ;3 ;4 ;5 ;6 ;7 ;8 ;9 ;A ;B ;C ;D ;E ;F ;10 ;11 ;12 ;13 ;14 2A 2B 2C 2D 5E 2F * + TO-POWER-OF /

MOD IDIV BOR BXOR BAND .. OR .. .. .. .. 3C 3D 3E AND <> <= >= < = > (ADD 7 FOR $ EQUIV. OF "AND" TO ">")

;******************************************************************************* ;UNARY FUNCTION PRIORITY TABLE (FOR MINORITY OF FNS THAT AREN"T PRI. 16,N,N) ;BIT 7=1 IF NUM RESULT. BIT 6=1 IF NUM ARG. BITS 4-0=PRIORITY 8F 8F 8F 8F 0F 8F 0F FNPRIORT: DB DB DB DB DB DB DB 8FH 8FH 8FH 8FH 0FH 8FH 0FH ;UDG ;NUMBER ;LEN ;CODE ;VAL$ ;VAL ;TRUNC$

169D 169E 169F 16A0 16A1 16A2 16A3 16A3 16A4 16A5 16A5 16A5 16A5 16A5 16A5 16A7 16A9 16AB 16AD 16AF 16B1 16B3 16B5 16B7 16B9 16BB 16BD 16BF 16C1 16C3 16C5 16C5 16C7 16C9 16CB 16CD 16CF 16D1 16D3 16D5 16D5 16D5 16D5 16D5 16D5 16D7 16D9 16D9 16DB 16DD 16DD 16DF 16E1 16E1 16E3 16E5 16E5 16E7 16E7 16EA 16EA 16EC 16EF 16EF 16F0 16F3 16F3 16F5 16F8 16F8 16F9 16FC 16FD 1700 1703 1703 1703 1703 1703 1704 1705 1708 1709 170A 170D 170D 170E 170F 1710 1712 1715 1715 1717 1719 1719 171A 171B 171D 171D 171F 171F 1722 1723

4F 4F 4F 4F 4F 4F C4 C9

DB DB DB DB DB DB

4FH 4FH 4FH 4FH 4FH 4FH

;CHR$ ;STR$ ;BIN$ ;HEX$ ;USR$ ;INKEY$ ;NOT ;NEGATE

DB 0C4H DB 0C9H

;******************************************************************************* ;IMMEDIATE FN ADDRESS TABLE. ALL ARE EVALUATED AT ONCE BECAUSE THEY HAVE NO ;ARGS, OR BRACKETED ARGS, OR #ARG. A718 F6CE 5DCF 3618 16E9 AF18 2ECF 2B31 A515 5018 5918 6118 6F18 2518 290D 95E8 6115 14F2 1318 290D EFCE 8EE9 290D 290D IMFNATAB: DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW IMPI IMRND IMPOINT IMMEM IMLENGTH IMITEM IMATTR IMFN IMBIN IMMOUSEX IMMOUSEY IMPENX IMPENY IMHIMEM NONSENSE IMINSTR IMINKEYS IMSCREENS IMMEMRYS NONSENSE IMPATHS IMSTRINGS NONSENSE NONSENSE ;NUMERIC RESULT

;STRING RESULT

;******************************************************************************* ;BELOW NUMBERS ARE QUOTE, "&", OPEN BRACKET, UNARY PLUS & MINUS, DECIMAL PT. ;(22H,26H,28H,2BH,2DH,2EH) FE22 282A FE26 280A FE28 2817 FE2D 280E FE2E CAA715 FE2B C2290D E7 C3F314 1E5D C35815 E7 CDE314 79 CD953A C3F415 UNARPLU: UNARMIN: SBRACKET: SDECIMALH: BELOWNUM: CP 22H JR Z,SQUOTE CP "&" JR Z,SDECIMALH CP "(" JR Z,SBRACKET CP "-" JR Z,UNARMIN CP "." JP Z,SDECIMAL CP "+" JP NZ,NONSENSE RST 20H JP SCANLP LD E,NEGATE JP SCANUMEN ;JUST SKIP A UNARY PLUS ;UNARY MINUS CODE

RST 20H ;SKIP "(" CALL SCANNING LD A,C CALL INSISCBRK ;INSIST ON ")" JP SCONT2

;******************************************************************************* ;PASS PARAMS OF STRING LITERAL TO FPCS IN RUN TIME 23 E5 3A3B5C 17 08 01FFFF 7E 23 03 FE0D CA290D FE22 20F4 D1 7E FE22 280A 22975A 08 DCE71C SQUOTE: INC HL PUSH HL LD A,(FLAGS) RLA EX AF,AF' LD BC,0FFFFH LD A,(HL) INC HL INC BC CP 0DH JP Z,NONSENSE CP 22H JR NZ,QUTSRLP POP DE LD A,(HL) CP 22H JR Z,SQUOTE2 ;SKIP QUOTE ;STRING TEXT START ;CY IN F" IF RUNNING ;INITIALISE LENGTH ;INC LEN COUNT

QUTSRLP:

;LOOP UNTIL QUOTE FOUND ;START ;CHECK IF DOUBLE QUOTE

;JR IF EMBEDDED QUOTES USED. ELSE STRING IS ;SIMPLE AND CAN STAY IN BASIC LINE. LD (CHAD),HL ;PT PAST CLOSING QUOTE EX AF,AF' CALL C,STKSTOREP ;STACK PARAMS OF STR IN BASIC LINE, IF RUNNING

1726 1726 1729 1729 1729 1729 172C 172E 172F 172F 1730 1731 1733 1735 1735 1736 1737 1739 1739 173A 173B 173B 173C 173D 173F 173F 1740 1741 1741 1742 1743 1745 1747 1747 1749 174A 174E 174F 1750 1753 1755 1755 1755 1755 1755 1755 1755 1755 1756 1758 175A 175A 175B 175D 175D 175F 1762 1762 1765 1765 1766 1768 176A 176A 176C 176D 1770 1770 1772 1774 1776 1776 1777 1778 1778 1778 1778 1778 1778 177A 177C 177C 177D 1780 1783 1783 1784 1785 1786 1786 1788 1788 178B 178D 178F 178F 1790 1793 1795 1795 1796 1797 1798

C39415 21004F 0E00 E5 1A 13 FE22 280C 47 08 3002 70 23 08 0C 20F0 CF 2A 1A 13 FE22 28EE 0600 1B ED53975A E1 08 DC673C 18D1

STRCONTH: SQUOTE2: SQUCOPY:

JP STRCONT LD HL,INSTBUF LD C,0 PUSH HL LD A,(DE) INC DE CP 22H JR Z,SQUCO3 LD B,A EX AF,AF' JR NC,SQUCO2 LD (HL),B INC HL ;ALLOWS 256 BYTES ;BUFFER START ;CHAR FROM BASIC LINE

;EMBEDDED QUOTES - HAVE TO COPY STRING TO BUFFER, OMITTING SOME ALT. QUOTES

SQUCO1:

SQUCO2:

EX AF,AF' INC C JR NZ,SQUCOPY RST 08H DB 42

;LOOP, COPYING CHARS FROM BASIC LINE TO BUFFER ;(MAX OF 255) ;"String too long"

SQUCO3:

LD A,(DE) INC DE CP 22H JR Z,SQUCO1 LD B,0 DEC DE LD (CHAD),DE POP HL EX AF,AF' CALL C,CWKSTK JR STRCONTH

;COPY IN NEXT CHAR IF IT IS A SECOND QUOTE MARK ;PT TO JUST PAST FINAL QUOTE ;BUFFER START ;IF RUNNING, COPY TO WKSPACE, STACK PARAMS.

;CALC5BY.SAM ;******************************************************************************* ;CALCULATE A 5-BYTE FORM FOR A DECIMAL, HEX OR BINARY NUMBER ;ENTRY WITH HL AND CHAD PTING TO FIRST CHAR OF NUMBER (&,.,0-9,BIN) ;EXIT WITH VALUE ON FPCS 7E FE26 2003 F7 C550 FE43 C27817 010000 E7 FE30 2806 FE31 37 C2DD1C CB11 CB10 30EF CF 1C BINDIG: NXBINDIG: NAMP: CALC5BY: LD A,(HL) CP "&" JR NZ,NAMP RST 30H DW AMPERSAND-8000H CP BINTOK JP NZ,DECIMAL LD BC,0 RST 20H CP "0" JR Z,BINDIG CP "1" SCF JP NZ,STACKBC RL C RL B JR NC,NXBINDIG RST 08H DB 28 ;"Number too large" ;INITIALISE RESULT ;SKIP BIN

;STACK RESULT AS SOON AS NON-1, NON-0 FOUND

;******************************************************************************* ;HANDLE EG 0.123, .123, 1.234, 1E4, 1.23E+4, 7.89E-32, 1.E5 FE2E 200C E7 CD303B D2290D EF E1 33 180D CDDE17 FE2E 201F E7 CD303B 3019 EF E6 C8 33 CONVFRAC: DECINT: DECIMAL: CP "." JR NZ,DECINT RST 20H ;SKIP "." CALL NUMERIC JP NC,NONSENSE ;INSIST ON E.G. .1 OR .8 DB CALC DB STKZERO DB EXIT JR CONVFRAC CALL INTTOFP CP "." JR NZ,EFORMAT RST 20H CALL NUMERIC JR NC,EFORMAT DB DB DB DB CALC STKFONE STOD0 EXIT ;JR IF NOT A DIGIT ;MULTIPLIER (M) STARTS AT 1 ;INTEGER PART OF A FRACTION IS ZERO

1799 1799 179A 179C 179C 179E 179F 179F 17A0 17A1 17A2 17A3 17A4 17A5 17A6 17A7 17A8 17A8 17A9 17A9 17AC 17AE 17AE 17B0 17B2 17B3 17B3 17B4 17B6 17B7 17B9 17B9 17BB 17BD 17BD 17BE 17BE 17BF 17BF 17C2 17C5 17C5 17C6 17C9 17CC 17CE 17CE 17CF 17D1 17D1 17D2 17D3 17D3 17D4 17D5 17D7 17D9 17D9 17DB 17DB 17DC 17DE 17DE 17DE 17DE 17DE 17DE 17DF 17DF 17E0 17E1 17E2 17E2 17E3 17E5 17E5 17E7 17E8 17E8 17E9 17EA 17EB 17EC 17ED 17EE 17EE 17F1 17F1 17F4 17F6 17F6 17F7 17F7 17F7 17F7 17F7 17FA 17FB 17FB 17FB 17FB 17FE 17FE

DF 180D D630 47 EF 23 D8 EC 05 D0 00 01 33 E7 CD303B 38EE E6DF FE45 C0 E7 0E2B B9 2805 FE2D 2002 4F E7 CD303B D2290D C5 CDDE17 CD651D 3803 07 3002 CF 1C 0F C1 CB49 2002 ED44 F7 D45B POFTENH: NTLERR: GEXSGN3: GEXSGN1: GEXSGN2: CONVFRAC2: EFORMAT: CONVFRALP:

RST 18H JR CONVFRAC2 SUB 30H LD B,A DB DB DB DB DB DB DB DB DB CALC STKBREG RCL0 STKTEN DIVN STO0 MULT ADDN EXIT

RST 20H CALL NUMERIC JR C,CONVFRALP ;JR IF A DIGIT AND 0DFH CP "E" RET NZ RST 20H LD C,"+" CP C JR Z,GEXSGN1 CP "-" JR NZ,GEXSGN2 LD C,A RST 20H ;SKIP +/CALL NUMERIC JP NC,NONSENSE ;INSIST ON NUMERIC NOW PUSH BC CALL INTTOFP CALL FPTOA JR C,NTLERR RLCA JR NC,GEXSGN3 RST 08H DB 28 RRCA POP BC BIT 1,C JR NZ,POFTENH NEG RST 30H DW POFTEN-8000H ;MULT FPC LAST VALUE BY E+/-A REGISTER ;C=+/;JR IF >255 ;JR IF <=127 ;"Number too large" ;SKIP "E"

;JR IF 0010 1011 (+)

;******************************************************************************* ;GET VALUE OF ASCII INTEGER IN A AND (CHAD+1...) TO FPCS. ZERO IF NO DIGITS. ;EXIT WITH NC AND A=NON-NUMERIC CHAR 47 EF E1 33 78 180C D630 47 EF EC 00 23 01 33 CDDD00 CD303B 38EF C9 INTTOFP3: INTTOFPLP: INTTOFP: LD B,A DB CALC DB STKZERO DB EXIT LD A,B JR INTTOFP3 SUB 30H LD B,A DB DB DB DB DB DB CALC STKTEN MULT STKBREG ADDN EXIT ;B GOES TO BREG ;TOTAL=TOTAL*10 ;TOTAL=0

CALL NXCHAR

;0074 EQU - NEXT CHAR, DON"T SKIP ANYTHING

CALL NUMERIC JR C,INTTOFPLP ;LOOP WHILE NUMERIC ASCII FOUND

RET ;******************************************************************************* ;USR$. E.G. LET A$=USR$ 12345 OR &18000 R0USRS: LD HL,STKSTOS DB 0FDH LD HL,STACKBC PUSH HL ;STACKS DE,BC,A ;"JR+3"

21EB1C FD 21DD1C E5

;USR. E.G. LET X=USR 123456 R0USR: USRCOM:

17FF 17FF 17FF 17FF 1801 1804 1805 1806 1807 180A 180D 180E 1810 1812 1813 1813 1813 1813 1813 1816 1819 181B 181E 181E 1821 1822 1822 1823 1825 1825 1825 1825 1825 1828 1828 182B 182E 182F 182F 182F 182F 1831 1832 1833 1834 1836 1836 1836 1836 1836 1839 1839 183C 183E 183E 183E 183E 1841 1841 1842 1845 1846 1846 1847 1848 1849 184A 184B 184C 184D 184E 184F 1850 1850 1853 1853 1856 1859 1859 185C 185C 185F 1861 1861 1864 1864 1867 1869 186A 186B 186D 186F 186F 1872 1872 1875 1877 1877 1877 1877 187A 187A 187C

;FROM "CALL" DDE5 CD6F12 44 4D F5 3AD05A CD0500 F1 D3FB DDE1 C9 CALLX: PUSH IX CALL PDPSUBR LD B,H LD C,L PUSH AF LD A,(TEMPB3) CALL HLJUMP POP AF OUT (251),A POP IX RET ;SWITCH ADDR IN. HL=ADDR, A=ORIG URPORT ;STACKED IN SECTION B ;JUNK OR NO. OF PARAMS IF CALL ;ORIG URPORT ;TO STACKBC OR STKSTOS OR NEXTSTAT (IF CALL)

;******************************************************************************* ;MEMORY$ E.G. MEM$(N1 TO N2) HANDLE READING ROM? HOW? CD8B3A CDE43A FE8E C2290D CDC03A D0 F7 6F50 IMMEMRYS: CALL SINSISOBRK CALL EXPT1NUM CP TOTOK JP NZ,NONSENSE CALL SEX1NUMCB RET NC RST 30H DW MEMRYSP2-8000H ;******************************************************************************* ;HIMEM - "RAMTOP" CD143B 2AB25C 3AB15C 47 DBFA 4F 78 91 1808 ASBHL: IMHIMEM: CALL SABORTER LD HL,(RAMTOP) LD A,(RAMTOPP) LD B,A IN A,(250) LD C,A LD A,B SUB C JR STKPGFORM ;MAINTAINED IN 8000-BFFF FORM,(UNLIKE OLDRT) ;CHK "(" ;N1 ;"TO" ;SKIP, EXPT "N)", CY IF RUNNING ;RET IF NOT RUNNING

;USED BY TPEEK - ADJUST/STACK BHL

;ADJUST TO RELATIVE PAGE

;******************************************************************************* ;MEM - FREE MEMORY. CD143B CD8C1F 1803 CD2120 F5 CDD61C C1 EF 23 E2 00 E0 05 E0 05 01 34 CD143B 2A965B C3D61C CD143B 3A985B 181B CD143B 01F800 ED78 1F 1F E63F 180D CD143B 01F801 1803 CD2E1D ED78 FPIN: FPIN2: IMPENY: IMPENX: IMMOUSEY: IMMOUSEX: IMMEM: CALL SABORTER CALL GETROOM JR STK19BIT STKPGFORM: CALL AHLNORM STK19BIT: PUSH AF CALL STACKHL POP BC DB DB DB DB DB DB DB DB DB DB CALC STKBREG STK16K MULT STKHALF DIVN STKHALF DIVN ADDN EXIT2 ;LSW ;LSW,MSB ;LSW,MSB*16K ;LSW,MSB*32K ;LSW,MSB*64K ;MSB*64K+LSW ;AHL=19BIT NUMBER

;STACK PAGE FORM IN AHL ON FPCS ;TURN TO 19-BIT NUMBER

CALL SABORTER LD HL,(MXCRD) JP STACKHL CALL SABORTER LD A,(MYCRD) JR STACKAH CALL SABORTER LD BC,CLUTPORT IN A,(C) RRA RRA AND 3FH JR STACKAH CALL SABORTER LD BC,0100H+CLUTPORT ;A8 HIGH GIVES PEN Y, NOT PEN X JR FPIN2 ;A8 IS LOW

;IN (N1) - IN A,(BC) CALL GETINT IN A,(C) ;TO BC

187C 187F 187F 187F 187F 187F 187F 187F 187F 187F 1881 1883 1883 1883 1883 1885 1888 188A 188A 188A 188A 188C 188C 188F 188F 1890 1893 1894 1895 1896 1897 1897 1897 1897 1897 1899 1899 189A 189B 189C 189D 189E 189F 18A0 18A2 18A2 18A6 18A7 18A7 18A7 18A7 18AA 18AA 18AB 18AC 18AD 18AD 18AE 18AF 18AF 18AF 18AF 18AF 18AF 18AF 18AF 18B2 18B2 18B4 18B5 18B8 18BB 18BC 18BE 18C0 18C0 18C2 18C4 18C4 18C5 18C8 18CA 18CC 18CC 18CD 18CE 18D1 18D3 18D3 18D5 18D7 18D7 18D9 18DB 18DB 18DC 18DC 18DD 18DF 18E2 18E2 18E2 18E2

C3DA1C

STACKAH:

JP STACKA

;******************************************************************************* ;SWOPS. CAN BE CALLED, OR USED AS FPC FUNCTIONS ;EXIT: DE=STKEND ;DIRECT CALLS FROM FOR-NEXT, OPEN, ... ;SWOP TOP AND THIRD ENTRIES 0EF6 1809 0EFB 11F6FF 1805 0EFB 11FBFF 42 2A655C 19 54 5D 09 FPSWOP13: LD C,-10 JR SWOPCOM1 LD C,-5 LD DE,-10 JR SWOPCOM2 LD C,-5 LD DE,-5 LD B,D LD HL,(STKEND) ADD HL,DE LD D,H LD E,L ADD HL,BC ;B=FF ;DE=STKEND-5 (SWOP12 AND SWOP13) OR -10 (SWOP23) ;HL=STKEND-10 (SWOP12) OR -15 (SWOP13 AND SWOP23)

;SWOP SECOND AND THIRD ENTRIES FPSWOP23:

;SWOP TOP AND SECOND ENTRIES SWOP12: SWOPCOM1: SWOPCOM2:

;FP "SWOP" ENTERS HERE ;BINARY OP, SO HL AND DE PT TO STKEND-10 AND STKEND-5 0605 1A 4E 77 79 12 23 13 10F7 ED5B655C C9 CD143B EF F0 33 34 C9 IMPI: FPSWOP: FPSWOPLP: LD B,5 LD A,(DE) LD C,(HL) LD (HL),A LD A,C LD (DE),A INC HL INC DE DJNZ FPSWOPLP LD DE,(STKEND) RET ;PI (3.1415 ETC) CALL SABORTER DB CALC DB STKHALFPI DB EXIT INC (HL) RET ;DOUBLE IT ;SKIP "PI", ABORT IF NOT RUNNING ;SWOP 5 BYTES

;******************************************************************************* ;ITEM - RETURN DATA LIST STATUS. ;0=NO DATA LEFT TO READ IN CURRENT DATA STATEMENT ;1=NEXT ITEM IS STRING ;2=NEXT ITEM IS NUMERIC CD143B DBFB F5 CD381F 010000 7E FE20 2804 FE2C 2018 0C CDBC33 FE22 2810 7E 23 CD2C3B 38F9 FE20 28F5 FE24 2801 0C F1 D3FB C3DD1C IMITEM3: IMITEM2: IMITEM: CALL SABORTER IN A,(URPORT) PUSH AF CALL ADDRDATA LD BC,0 LD A,(HL) CP " " JR Z,IMITEM2 CP "," JR NZ,IMITEM3 INC C CALL FORESP CP 22H JR Z,IMITEM3 LD A,(HL) INC HL CALL ALPHANUM JR C,IMITEMLP CP " " JR Z,IMITEMLP CP "$" JR Z,IMITEM3 INC C POP AF OUT (URPORT),A JP STACKBC INCLUDE DO.SAM ;DO, LOOP, LOOP IF, EXIT IF, ON, GOSUB, ;SKIP "ITEM", ABORT IF NOT RUNNING ;USE DATADD AND DATAPG TO LOOK AT DATA PTR ;THERE IS MORE DATA IF DATADD PTS TO A SPACE ;(AFTER "DATA") ;IF NO COMMA, DATA HAS ALL BEEN READ ;BC=1 ("STRING") ;SKIP ANYTHING BELOW "!" ;END IF QUOTE - STRING

IMITEMLP:

;JR IF LETTER OF NUMBER ;SPACE IS ALSO POSSIBLE IN VAR NAMES (_?) ;STRING IF NAME ENDS IN $ ;ELSE NUMERIC

;DO.SAM

18E2 18E5 18E7 18E7 18E7 18E7 18E7 18E8 18EB 18EE 18EF 18EF 18EF 18EF 18EF 18F1 18F1 18F1 18F1 18F1 18F1 18F1 18F4 18F7 18F8 18FC 18FE 1900 1900 1901 1902 1902 1903 1904 1907 1909 190A 190B 190E 1912 1912 1915 1916 1917 1918 1919 191A 191B 191C 191C 191F 191F 1922 1923 1923 1924 1926 1926 1929 1929 192C 192D 192D 1930 1932 1932 1932 1935 1935 1936 1936 1938 193B 193D 193D 193E 193F 193F 1940 1941 1941 1941 1942 1942 1942 1942 1942 1942 1943 1944 1945 1948 1948 1948 194A 194A 194A 194A 194B 194C 194F 1952 1952

CDFD19 3808

DO:

CALL WHUNT JR C,DO3

;WHILE/UNTIL SR - ONLY RET HERE IF RUNNING ;JR IF WANT TO EXECUTE LOOP LINES ;ELSE SKIP TO "LOOP" ;NEXT STAT RET ADDR ;DOTOK/LOOPTOK ;"Missing LOOP"

;ENTRY FOR EXIT IF D1 11D5D4 CD470D 09 DO2: POP DE LD DE,0D4D5H CALL SEARCH DB 9

;STACK A RETURN ADDR AND EXECUTE LINES IN THE DO-LOOP 0680 DO3: LD B,80H ;MASK TO SET BIT 7 OF PAGE - SHOW "DO" DATA ;MAKE BASIC STACK ENTRY (TYPE/PAGE, ADDR (OF LINE START), STAT) ;ENTRY WITH B=TYPE BYTE, FROM GOSUB OR PROC, OR DO (SEE ABOVE) ;BITS 7-5: 100=DO, 010=PROC, 000=GOSUB ;EXIT: HL PTS TO STACKED SUBPPC (GOSUB/PROC INCS IT) 2AC45B 11FCFF 19 ED5BC85B ED52 3002 CF 29 19 23 3AAE5A E61F B0 77 3A475C ED5BAF5A 22C45B 23 73 23 72 23 77 C9 CD583A CD231B C8 37 180F CD583A CD231B C8 CD3519 18B5 CDFD19 08 0680 CD201A 2802 CF 0A 08 D0 08 LOOP2: LOOP: LOOP1: EXITIF: BSTKE: LD HL,(BSTKEND) LD DE,-4 ADD HL,DE LD DE,(HEAPEND) SBC HL,DE JR NC,BSTKOK RST 08H DB 41 ADD HL,DE INC HL LD A,(CLAPG) AND 1FH OR B LD (HL),A LD A,(SUBPPC) LD DE,(CLA) LD (BSTKEND),HL INC HL LD (HL),E INC HL LD (HL),D INC HL LD (HL),A RET CALL SYNTAX6 CALL TRUETST RET Z SCF JR LOOP1 CALL SYNTAX6 CALL TRUETST RET Z CALL LOOP1 JR DO2 CALL WHUNT EX AF,AF' LD B,80H CALL RETLOOP JR Z,LOOP2 RST 08H DB 10 EX AF,AF' RET NC EX AF,AF' ;DISCARD AND TEST TRUE/FALSE. NC ;NEXT STAT IF FALSE ;UNSTACK "DO" RET ADDR, DON"T LOOP ;SKIP TO LOOP ;ASSESS WHILE/UNTIL ;SAVE LOOP/NO LOOP AS C/NC (ALWAYS NC IF "EXIT IF", ;ALWAYS CY IF LOOP IF) ;"DO" TYPE ;GET C=STAT, HL=ADDR, NZ IF ERROR, A=PAGE ;"LOOP without DO" ;RET TO "NEXT STAT" IF "NO LOOP" ;RET IS TO "EXIT IF" IF CALLED FROM THERE. ;PAGE ;DISCARD AND TEST TRUE/FALSE. ;NEXT STAT IF FALSE ;UNSTACK "DO" RET ADDR, LOOP ;SPACE NEEDED ;FIND NEW BSTKEND. CY ;LOWER IN MEM THAN STACK - END OF USER CODE ;END-(LIM+1) - BSTK CANNOT COME AS FAR DOWN AS HEAP ;"BASIC stack full"

BSFERR: BSTKOK:

;MARK FOR TYPE ;TYPE/PAGE ;BSTKEND IS NOW 4 BYTES LOWER

SEDA:

LOOPIF:

;USED BY RETURN, END PROC, LOOP, NEXT. ESSENTIALLY A "GOTO" STAT IN LINE AT AHL. ;ENTRY: A=PAGE, HL=ADDR OR 00XX IF ELINE, C=STAT. D1 24 25 CA2B0D E61F 41 C5 CDDF3F C32E0E RLEPC2: RLEPCOM: POP DE INC H DEC H JP Z,LOOPEL AND 1FH ;FROM PROCS: LD B,C PUSH BC CALL SELURPG JP RLEPI ;B=STAT ;USE HL AS LINE START, A AS CHAD/CLA/NXTLN PAGE, ;(SP) AS STAT ;JUNK NEXT STAT RET ADDR ;JP IF LOOPING BACK TO ELINE (ADDR MSB=0) ;(NSPPC WILL BE SET BY FROM C, ;PAGE WILL BE SET TO ELINEP, CHAD BY SKIP STATS)

1952 1952 1952 1952 1952 1955 1955 1958 1959 195C 195D 195E 195F 1962 1963 1963 1964 1965 1966 1967 196A 196C 196C 196E 1970 1970 1970 1970 1973 1976 1979 197C 197D 1980 1980 1980 1982 1982 1982 1983 1983 1984 1986 1988 1988 198B 198B 198D 1990 1990 1990 1991 1992 1992 1995 1996 1997 1997 199A 199A 199B 199B 199E 19A1 19A2 19A2 19A5 19A5 19A8 19AB 19AD 19AD 19AD 19AD 19AD 19AD 19B0 19B1 19B2 19B5 19B7 19B8 19BB 19BB 19BE 19C1 19C1 19C1 19C2 19C5 19C6 19C8 19CB 19CC 19CD 19CD 19CD 19D0 19D0 19D2 19D5 19D7 19D7

;******************************************************************************* ;ON VALUE: STAT1: STAT2: STAT3 CD583A CD331D 57 21475C 86 77 DF CDF910 D8 DF E5 E7 E1 CD1E3B 3804 FEB5 2013 22975A 2A9D5A 22AF5A 21475C 7E 32465B 36FF C9 D1 FEB4 2803 11170E FE3A C29E0D EB E9 CD2E1D 7C 3C CA391D AF 32445C 22425C C9 CD153B 3A705C 2A6E5C 18EE GOTO2: GTERRHP: GOTO3: GOTO4: CONTINUE: ON4: ON3: ON2: ON: CALL SYNTAX6 CALL GETBYTE LD D,A LD HL,SUBPPC ADD A,(HL) LD (HL),A RST 18H CALL SKIPS0 RET C RST 18H PUSH HL RST 20H POP HL CALL ALPHA JR C,ON2 CP 0B5H JR NZ,ON3 LD LD LD LD LD LD (CHAD),HL HL,(NXTLINE) (CLA),HL HL,SUBPPC A,(HL) (ONSTORE),A

;ADJ SUBPPC BY VALUE ;HL=CHAD ;SKIP D STATS ;RET IF HIT END OF LINE - NEXT STAT ->NXT LINE ;PT TO ":" ;A=FIRST SIGNIF CHAR IN STAT ;":" PTR ;JR IF LETTER - IT"S A PROC ;GOSUBTOK ;JR UNLESS "GOSUB" ;PT TO ":" ;MAKE IT LOOK AS THOUGH WE ARE AT NEXT LINE ;SAVE SUBPPC, WHICH WILL BE ZERO AFTER INCR ;ANY ERRORS WILL GIVE SENSIBLE STAT NO. BECAUSE ;ERROR HANDLER USES (ONSTORE) IF STAT NO=00. THIS ;WILL BE INCED TO ZERO. GOSUB/PROCS WILL THINK ;WE ARE AT A STAT ZERO, NEXT LINE, AND WILL RETURN ;TO STAT 1, NEXT LINE ;TO NEXT STAT ;NEXT STAT ;GOTOTOK ;GOTO KEEPS DE AS NEXT STAT ADDR ;ELSE USE LINEEND SO ONLY 1 STAT EXECUTED ;SEE IF NULL STATEMENT ;PUSHES DE (NEXT STAT OR LINE END),EXECUTES STAT. ;RETURN GOES TO LINE END UNLESS GOTO WAS USED ;NULL STAT (:) JPS TO LINE END

;PROCS AND GOSUBS MUST RETURN TO NEXT LINE AFTER EXECUTING

LD (HL),255 RET POP DE CP 0B4H JR Z,ON4 LD DE,OLNEND CP ":" JP NZ,ON4ENT EX DE,HL JP (HL) CALL GETINT LD A,H INC A JP Z,IOORERR XOR A LD (NSPPC),A LD (NEWPPC),HL RET CALL CHKEND

;RANGE 0-65279 (0000-FEFFH) ;STAT NO. ZERO

CONTINUE2: LD A,(OSPPC) LD HL,(OLDPPC) JR GOTO4 ;CALBAS - CALL BASIC SUBROUTINE FROM MACHINE CODE ;ENTRY: HL=LINE TO CALL. ;EXIT: Z IF OK, ELSE A=ERROR NUMBER

CD9A19 47 3D 32475C DBFB F5 CDF118 CD2E20 CDD40D E1 223D5C F1 D3FB 3A3A5C A7 C9 CD153B 0600 CD201A 2005 0C

CALBAS:

CALL GOTO3 LD B,A DEC A LD (SUBPPC),A IN A,(251) PUSH AF CALL BSTKE CALL SETESP CALL NEXTSTAT POP HL LD (ERRSP),HL POP AF OUT (251),A LD A,(ERRNR) AND A RET

;LD (NEWPPC),HL: ZERO (NSPPC) ;TYPE/PAGE=GOSUB/PAGE 0 ;"STATMENT" FF SHOWS M/C ;STACK RETURN ADDR, STAT FFH. INSTEAD OF DOING A ;BASIC RETURN, "RETURN" CAUSES RET TO ERR HANDLER. ;SET ERRSP SO ERRORS RETURN TO THIS ROUTINE ;RUN LINE. NORMAL BASIC STACK AT "NEXTSTAT" HOLDS ;MAINER ADDR, WITH ERRSP POINTING TO IT. NOW ERRSP ;PTS TO THIS ROUTINE ;RESTORE ORIG. ;ORIG URPAGE

RETURN:

CALL CHKEND LD B,0 CALL RETLOOP JR NZ,RWGERR INC C ;"GOSUB" TYPE ;GET RET ADDR ;HL=LINE ADDR, A=TYPE/PAGE, C=STAT, Z IF TYPE OK ;RETURN TO *NEXT* STAT

19D8 19DA 19DA 19DB 19DC 19DC 19DD 19DE 19DE 19E1 19E1 19E4 19E5 19E6 19E7 19EA 19EB 19EC 19ED 19ED 19ED 19ED 19EE 19F1 19F2 19F4 19F4 19F6 19F6 19F9 19F9 19FA 19FD 19FD 19FD 19FD 19FD 19FF 1A01 1A01 1A03 1A04 1A06 1A06 1A07 1A0A 1A0B 1A0B 1A0C 1A0C 1A0D 1A10 1A13 1A15 1A15 1A18 1A1A 1A1A 1A1B 1A1C 1A1D 1A1D 1A1E 1A1E 1A1F 1A20 1A20 1A20 1A20 1A20 1A20 1A20 1A20 1A20 1A20 1A23 1A24 1A26 1A27 1A28 1A28 1A29 1A2A 1A2B 1A2C 1A2D 1A2E 1A2F 1A30 1A33 1A34 1A35 1A35 1A35 1A35 1A35 1A35 1A35 1A35 1A35 1A35 1A35 1A35

2013 C1 C9 CF 08 CD153B CD2C33 E5 C5 F5 CD0A37 F1 C1 E1 47 3A455B 1F 3005 3E81 32455B 78 C34219 ENDP2: ENDP1: RWGERR: ENDPROC:

JR NZ,ENDP1 POP BC RET RST 08H DB 8 CALL CHKEND CALL DPRA PUSH HL PUSH BC PUSH AF CALL DELOCAL POP AF POP BC POP HL ;FROM RETURN, IF TYPE OK LD B,A LD A,(ONERRFLG) RRA JR NC,ENDP2 LD A,81H LD (ONERRFLG),A LD A,B JP RLEPCOM

;STAT IS ONLY 0FFH IF CALL CAME FROM M/C ;TO ERROR HANDLER (M/C) ;"RETURN without GOSUB" ;GET RET ADDR. C=STAT, HL=ADDR, A=PAGE

;T BIT,000000,P BIT ;JR IF "ON ERROR" PERM OFF ;END PROC/RETURN RESET TEMP ERROR BIT TO PERM ;STATUS SO ERROR PROC OR SR EASY. ;TEMP AND PERM NOW ON ;USE HL AS LINE ADDR, A AS PAGE, C AS STAT

;WHILE/UNTIL SR OF DO AND LOOP COMMANDS FE8A 280B FE8B 37 2806 E1 CDC63A D0 E9 F5 CDE33A CDC63A 3008 CD231B 2804 F1 3F C9 F1 F1 C9 WHUNT3: WHUNT4: WHUNT2: WHUNT: CP WHILETOK JR Z,WHUNT2 CP UNTILTOK SCF JR Z,WHUNT2 POP HL CALL RUNFLG RET NC JP (HL) PUSH AF CALL SEXPT1NUM CALL RUNFLG JR NC,WHUNT3 CALL TRUETST JR Z,WHUNT4 POP AF CCF RET POP AF POP AF RET ;RET ADDR IN DO OR LOOP ROUTINE ;NEXT STAT IF SYNTAX TIME - CHECK "DO" OR "LOOP" ;RET WITH C IF NO QUALIFIERS (NO WHILE OR UNTIL) ;WHILE/UNTIL FLAG ;SKIP WHILE/UNTIL, GET EXPR ;GOTO NEXT STAT NOW IF SYNTAX TIME ;DROP AND TEST EXPR. ;JR IF FALSE ;IF TRUE AND UNTIL, NC ;IF TRUE AND WHILE, C ;ENTRY TO JUNK FLAG, RET ADDR, RET TO NEXT STAT ;IF FALSE AND UNTIL, C ;IF FALSE AND WHILE, NC

;IF CALLED FROM LOOP, C MEANS EXECUTE THE LOOP, ELSE CONTINUE ;IF CALLED FROM DO , C MEANS EXECUTE DO, ELSE FIND LOOP AND JP THERE ;RETURN/LOOP SR. ENTRY: B=DESIRED TYPE OF DATA TO UNSTACK FROM BASIC STACK. ;80H=DO, 40H=PROC, 00=GOSUB ;EXIT: A=STAT NR, HL=ADDR OF LINE, C=TYPE/PAGE ;IF ENTRY WAS AT RETLOOP, NZ=WRONG TYPE/EMPTY STACK, Z=OK 2AC45B 7E E6E0 B8 C0 7E 23 5E 23 56 23 4E 23 22C45B EB C9 RETLOOP: LD HL,(BSTKEND) LD A,(HL) AND 0E0H CP B RET NZ LD A,(HL) INC HL LD E,(HL) INC HL LD D,(HL) INC HL LD C,(HL) INC HL LD (BSTKEND),HL EX DE,HL RET ;TYPE/PAGE ;ISOLATE TYPE BITS ;RET IF WRONG TYPE OR STACK MT (FF STOPPER) ;TYPE/PAGE ;ADDR ;STAT

RETLOOP2:

;FIND LINE NO. "HL" (OR "BC", WITH LATER ENTRY) ;STARTS SEARCH AT PROG, OR IF RUNNING AND TARGET IS AT OR PAST EPPC, SEARCHES ;FROM CURRENT LINE (PPC) ADDRESS. USES HL,DE,BC,AF, *TEMPW1* ;ENTRY:HL=LINE NO. ;EXIT: HL PTS. TO LINE NO. MSB IN PROGRAM, DE PTS TO PREVIOUS LINE. DE IS IN ;8000-BFFF AREA, HL MIGHT HAVE CROSSED IN TO C000 BY A LINE LEN OR SO. ;IF NO PROGRAM, DE=HL ; Z=LINE FOUND ;NZ=FOUND A LATER LINE, OR FF STOPPER

1A35 1A36 1A37 1A37 1A3A 1A3A 1A3C 1A3C 1A3F 1A40 1A41 1A43 1A45 1A45 1A45 1A48 1A4B 1A4D 1A4D 1A4D 1A4D 1A4E 1A4F 1A4F 1A52 1A55 1A55 1A58 1A5B 1A5D 1A5D 1A5F 1A62 1A65 1A66 1A67 1A68 1A69 1A6A 1A6B 1A6C 1A6C 1A6D 1A6E 1A71 1A71 1A73 1A73 1A74 1A75 1A76 1A77 1A7A 1A7A 1A7E 1A7F 1A7F 1A7F 1A7F 1A7F 1A7F 1A7F 1A7F 1A7F 1A7F 1A7F 1A82 1A82 1A83 1A84 1A86 1A88 1A88 1A89 1A8C 1A8D 1A90 1A90 1A90 1A90 1A92 1A93 1A95 1A95 1A97 1A97 1A97 1A97 1A97 1A97 1A9A 1A9A 1A9D 1A9E 1A9E 1A9F 1AA0 1AA2 1AA4 1AA4 1AA5 1AA8 1AA9

44 4D CDC63A 3013 2A455C 2B A7 ED42 300A 2AAF5A 3AAE5A 1808 44 4D 2AA05A 3A9F5A CDDF3F 22C85A 180F CB74 C4F23F 22C85A 23 23 5E 23 56 23 19 7E B8 DA5D1A 2007 23 7E 2B B9 DA5D1A ED5BC85A C9

FNDLNHL: FNDLNBC:

LD B,H LD C,L CALL RUNFLG JR NC,FNDLP LD HL,(PPC) DEC HL AND A SBC HL,BC JR NC,FNDLP LD HL,(CLA) LD A,(CLAPG) JR FNDL0 ;JR IF NOT RUNNING (E.G. EDITING) ;SO CY IF PPC=TARGET ;JR IF DESIRED LINE IS BEFORE CURRENT LINE ;(ALWAYS, IF PPC=FFFF (ELINE)) ;START LOOKING FROM PPC LINE START ;NEEDED? OR USE JR+2

;ENTRY HERE IF WANT TO INSIST ON STARTING AT PROG (RENUM) FNDLINE: FNDLP: FNDL0: FNDL1: LD B,H LD C,L LD HL,(PROG) LD A,(PROGP) CALL TSURPG LD (TEMPW1),HL JR FNDL2 ;SWITCH IN A PROGRAM BLOCK ;KEEP PTR TO LINO MSB

BIT 6,H CALL NZ,INCURPAGE LD (TEMPW1),HL ;KEEP PTR TO LINO MSB INC HL INC HL LD E,(HL) INC HL LD D,(HL) INC HL ADD HL,DE ;ADD LINE LEN TO PT TO NEXT LINE NO. LD A,(HL) CP B JP C,FNDL1 JR NZ,FNDL3 INC HL LD A,(HL) DEC HL CP C JP C,FNDL1 ;GET MSB OF LINE NO. ;CP MSB OF TARGET ;JP IF NOT AT OR PAST TARGET LINE YET ;JR IF MSB SHOWS WE ARE PAST TARGET LINE NO. ;LSB ;JP IF LSB SHOWS WE ARE NOT AT TARGET YET

FNDL2:

FNDL3:

LD DE,(TEMPW1) RET

;IF.SAM - 2.3.89 ;******************************************************************************* ;E.G. IF x=1 THEN PRINT ; IF X=1 THEN PRINT "Y": ELSE PRINT "N" ; IF X=1: PRINT: PRINT: END IF ;BOTH LONG AND SHORT IFS COME HERE 2A975A 2B 7E FE21 38FA E5 CDE43A E1 32755A FE8D 57 2002 36D8 LIF: SIF: SIFLP: LD HL,(CHAD) DEC HL LD A,(HL) CP 21H JR C,SIFLP PUSH HL CALL EXPT1NUM POP HL LD (IFTYPE),A CP THENTOK LD D,A JR NZ,IFL1 LD (HL),0D8H

;PT HL TO CMD CODE

;RECORD LAST IF TYPE AS SHORT/LONG USING ; "THEN"/NON "THEN" ;(IF TYPE IS SET TO "LONG" AT START OF LINE ;SYNTAX CHECK) ;JR IF NOT "THEN" (SHOULD BE ":") ;SIFTOK ;AT LINE ENTRY, I-F IS TOKENISED AS THE "LIF" ;TOKEN BECAUSE IT OCCURS FIRST IN TOKEN LIST ;(LIF TOKEN LISTS AS I-F, LIKE THE IF TOKEN) ;NOW FORCE TOKEN TO "SIF" BECAUSE "THEN" USED. ;IF SYNTAX CHECK, CHECK FOR OD/:/THEN, EXIT ;DROPS EXPR AND TESTS IT ;RET IF TRUE, DO NEXT STATMENT (FPCS IS CLEARED) ;NEXT STAT ;IF SHORT AND NOT TRUE, LOOK FOR ELSE OR CR ;LELSETOK ;WHOLE PROG (OR ELINE), TARGET 2 RELOAD=LELSE

CD153B CD231B C0 C1 7A FE8D 282B D9 01D9FF D9

IFL1:

CALL CHKEND CALL TRUETST RET NZ POP BC LD A,D CP THENTOK JR Z,SHORTIF

EIFLP:

EXX LD BC,0FF00H+0D9H EXX

1AA9 1AAC 1AAF 1AAF 1AB2 1AB4 1AB4 1AB7 1AB8 1AB9 1ABC 1ABC 1ABD 1ABF 1AC2 1AC2 1AC2 1AC5 1AC8 1ACA 1ACA 1ACD 1ACD 1ACE 1ACF 1ACF 1AD0 1AD3 1AD4 1AD4 1AD7 1AD7 1ADA 1ADD 1ADD 1AE0 1AE3 1AE3 1AE3 1AE3 1AE3 1AE4 1AE7 1AE9 1AE9 1AEC 1AEC 1AED 1AEE 1AF0 1AF2 1AF2 1AF5 1AF7 1AF9 1AF9 1AFA 1AFC 1AFE 1B00 1B00 1B03 1B05 1B08 1B0A 1B0B 1B0B 1B0C 1B0D 1B0D 1B0F 1B0F 1B0F 1B11 1B11 1B11 1B11 1B12 1B15 1B18 1B19 1B19 1B19 1B19 1B1C 1B1F 1B1F 1B20 1B23 1B23 1B23 1B23 1B23 1B26 1B27 1B28 1B29 1B2A 1B2B 1B2C 1B2D 1B2E 1B2F

01D901 11DBD7 CDA61D 3019 32475C 08 BB CACA1A DF FED8 C2CA1A CDE33A CD231B 28DA C3510D CF 27 D9 018D00 D9 11DAD8 CDA31D D2120E 32475C C3840D XCHDH: MEIERR: SHORTIF:

LD BC,0100H+0D9H LD DE,0D7DBH CALL SRCHALL3 JR NC,MEIERR LD EX CP JP (SUBPPC),A AF,AF' E Z,XCHDH

;LELSETOK. COUNT=1, TARGET2=LELSE ;LIFTOK/ENDIFTOK ;LOOK FOR LELSE OR ENDIF WITH LIF INTERVENING ;ERROR IF NEITHER WAS FOUND ;STAT ;FINAL TARGET ;WAS IT "END IF"? ;IF IT WAS, CONTINUE AFTER "END IF" ;SIFTOK ;JP IF "LELSE", NOT "LELSE SIF"; CONTINUE AFTER ;"LELSE" ;SKIP "SIF", EVAL CONDITION ;IF FALSE, KEEP LOOKING FOR ENDIF/LELSE ;IF TRUE, CONTINUE AFTER "ELSE IF cond" ;"Missing END IF" ;ONE LINE SRCH, NULL TARGET2 RELOAD ;SIFTOK/ELSETOK ;LOOK FOR "ELSE" WITH SIF "INTERVENING" ;JP TO LINE END IF NO "ELSE" FOUND ;JP TO NEXT STATEMENT, JUST AFTER "ELSE" ;(CHAD, CLA, NXTLINE STILL OK - SAME LINE) ;CHAR AFTER "ELSE" ;JR IF RUNNING A LONG ELSE

RST 18H CP 0D8H JP NZ,XCHDH CALL SEXPT1NUM CALL TRUETST JR Z,EIFLP JP EXCHAD2 RST 08H DB 39 EXX LD BC,THENTOK EXX LD DE,0D8DAH CALL SRCHALL2 JP NC,LINEEND LD (SUBPPC),A JP STMTLP2

;E-L-S-E IS TOKENISED AS LELSE TOKEN BECAUSE IT APPEARS FIRST IN LIST 4F CDC63A 3828 2A975A 2B 7E FE21 38FA 3A755A FE8D 2814 79 D6D8 CE00 201F 2A975A 36D8 CDE33A FE8D C0 CF 1D 36DA 180E D1 11DBD7 CD470D 00 CDC63A DA110E C1 C3840D RLELSE: DNS: NLELS: FELSLP: LELSE: LD C,A CALL RUNFLG JR C,RLELSE LD HL,(CHAD) DEC HL LD A,(HL) CP 21H JR C,FELSLP LD A,(IFTYPE) CP THENTOK JR Z,NLELS LD A,C SUB 0D8H ADC A,0 JR NZ,ELSE2 LD HL,(CHAD) LD (HL),0D8H CALL SEXPT1NUM CP THENTOK RET NZ RST 08H DB 29 LD (HL),0DAH JR ELSE2 POP DE LD DE,0D7DBH CALL SEARCH DB 0 CALL RUNFLG JP C,REMARK POP BC JP STMTLP2

;PT TO CMD CODE ;JR IF "SHORT" STATUS ;SIFTOK ;SIF/LIF BOTH BECOME 0 ;CHECK SYNTAX AFTER "LELSE" ;"LELSE LIF" BECOMES "LELSE SIF" ;EVAL condition ;TO CHECK SYNTAX OF NEXT STATEMENT ;"LELSE SIF cond THEN" NOT ALLOWED AS IT ;WILL WORK IN A CONFUSING WAY ;ELSETOK ;FORCE "SHORT ELSE" IF "SHORT IF" PRECEDED IT. ;(THERE WAS A PRECEDING "SHORT IF" ON THIS LINE) ;CHECK SYNTAX FROM CHAD ON ;JUNK NEXT STAT ** BUG FIX ;LIFTOK/ENDIFTOK ;LOOK FOR "ENDIF" WITH LIF "INTERVENING" ;"OK" IF NOT FOUND

;LONG ELSE REQUIRES A SEARCH FOR ENDIF, WITH LIF INTERVENING

;SHORT ELSE - SHOULD ALWAYS BE RUNNING! ELSE: ELSE2: ;JP, SKIP REST OF LINE IF RUNNING A SHORT ELSE ;NEXT STAT ;CHECK SYNTAX FROM CHAD ONWARDS WITHOUT ;REQUIRING CR/COLON ;PT TO END OF RESULT OF THE EXPRESSION ;MSB IF INTEGER ;LSB ;SGN - PROB NOT NEEDED IF MINUS ZERO EXCLUDED! ;EXP. ;"DISCARD"

;DROP EXPRESSION FROM FPCS, TEST FOR TRUE/FALSE 2A655C 2B 2B 7E 2B B6 2B B6 2B B6 22655C TRUETST: LD HL,(STKEND) DEC HL DEC HL LD A,(HL) DEC HL OR (HL) DEC HL OR (HL) DEC HL OR (HL) LD (STKEND),HL

1B32 1B32 1B32 1B33 1B33 1B33 1B33 1B33 1B33 1B36 1B36 1B37 1B39 1B3B 1B3B 1B3E 1B40 1B43 1B43 1B46 1B48 1B4A 1B4A 1B4D 1B4D 1B4E 1B4F 1B50 1B50 1B51 1B51 1B54 1B54 1B54 1B55 1B56 1B59 1B5C 1B5C 1B5F 1B61 1B64 1B64 1B64 1B64 1B64 1B64 1B67 1B6A 1B6B 1B6D 1B70 1B72 1B73 1B74 1B75 1B76 1B79 1B7B 1B7D 1B7F 1B81 1B81 1B84 1B85 1B86 1B89 1B8A 1B8B 1B8D 1B8D 1B90 1B92 1B92 1B95 1B97 1B97 1B98 1B99 1B9C 1B9D 1B9E 1B9F 1BA0 1BA1 1BA2 1BA3 1BA4 1BA7 1BA8 1BA9 1BAC 1BAC 1BAF 1BB0 1BB0 1BB3 1BB3 1BB5 1BB8 1BBA 1BBA 1BBB

;NZ IF TRUE, DO NEXT STATMENT (FPCS IS CLEARED) C9 ENDIF: RET ;DOES NOTHING - ACTS AS A MARKER ONLY

;FOR.SAM 26.5.89 ;******************************************************************************* CDD32C DF FE3D 20D0 CDE33A FE8E C20B1B CDE33A FE8F 2807 CD153B EF E9 33 14 CC573A DF F5 CD8A18 CD7F18 216051 CBF6 CD372B FORSTEP: FOR2: FOR: CALL SYNTAX4 RST 18H CP "=" JR NZ,DNS CALL SEXPT1NUM CP TOTOK JP NZ,DNS CALL SEXPT1NUM CP STEPTOK JR Z,FORSTEP CALL CHKEND DB CALC DB STKONE DB EXIT INC D CALL Z,SSYNTAX6 RST 18H PUSH AF CALL SWOP12 CALL FPSWOP13 LD HL,TLBYTE+33 SET 6,(HL) CALL ASSISR ;DEFAULT STEP OF 1 ;NZ ;GET THE STEP VALUE ;VALUE/LIMIT/STEP ON FPCS ;CR OR COLON ;V/S/L ;L/S/V ;"FOR-NEXT" TYPE MARKED ON T/L BYTE ;IF NORMAL VAR EXISTS, DEST PTS TO PREV PTR, AND ;FLAGX BIT 0 SHOWS "NEW", SO VAR IS "LINKED OUT" ;ASSIGNS V TO FIRST 5 LOCNS. DE PTS AFTER ;THESE ON EXIT (14 EXTRA LOCATIONS AVAILABLE IF ;"OLD" FOR-NEXT, ELSE NUMEND IS PAST VAR, NEEDS ;MOVING 14 ON) ;ASSESS FOR-VARIABLE ;NONSENSE ;START VALUE ;NONSENSE ;LIMIT ;"STEP"

2A655C 010A00 A7 ED42 22655C EDB0 F1 D5 1B EB 112F51 0E0F EDB8 FE0D 2811 3A475C 3C 4F 3A465C 3C 67 280A 2AAF5A 1805 2A9D5A 0E01 EB E1 3A9C5A 77 23 73 23 72 23 71 23 3A715C 1F EB DCBB2B CD1C1C C0 CDD73F 1EC1 CD9C1D 3802 CF 06 FORMLP: FOR22: FOR25:

LD HL,(STKEND) LD BC,10 AND A SBC HL,BC LD (STKEND),HL LDIR POP AF PUSH DE DEC DE EX DE,HL LD DE,MEMVAL+14 LD C,15 LDDR CP 0DH JR Z,FOR22 LD A,(SUBPPC) INC A LD C,A LD A,(PPC+1) INC A LD H,A JR Z,FOR25 LD HL,(CLA) JR FOR25 LD HL,(NXTLINE) LD C,1 EX DE,HL POP HL LD A,(NXTLINEP) LD (HL),A INC HL LD (HL),E INC HL LD (HL),D INC HL LD (HL),C INC HL LD A,(FLAGX) RRA EX DE,HL CALL C,NELOAD CALL NEXTTEST RET NZ CALL SELCHADP LD E,0C1H CALL SRCHPROG JR C,FOR3 RST 08H DB 6

;DELETE L,S ;COPY TO VARIABLE BUFFER TO GIVE V,L,S ;STAT END CHAR ;SRC=END OF S ;COPY V,L,S TO MEM 0,1,2 FOR NEXTTEST TO USE ;JR IF LOOPING ADDRESS IS ON NEXT LINE

;JR IF ELINE ;ELSE THIS LINE, NEXT STAT ;FIRST STATEMENT ;VARS PTR ;PAGE OF CURRENT LINE (SAME AS CLAPG) ;ORDER CHANGE VS. ROM 1.0** ;LINE ADDRESS ;STAT

;SET NUMEND IF "NEW" VARIABLE ;RET IF A LOOP IS POSSIBLE ;NEXTTOK ;LOOK FOR "NEXT" FROM CHAD ONWARDS ;JR IF ONE FOUND ;"FOR without NEXT"

1BBC 1BBC 1BBF 1BC2 1BC5 1BC7 1BC7 1BCB 1BCC 1BCF 1BCF 1BD0 1BD1 1BD1 1BD1 1BD1 1BD4 1BD7 1BD7 1BDA 1BDA 1BDA 1BDD 1BDF 1BE1 1BE1 1BE1 1BE4 1BE7 1BE9 1BE9 1BEC 1BED 1BF1 1BF4 1BF6 1BF6 1BF7 1BF8 1BF9 1BFA 1BFB 1BFC 1BFC 1BFD 1BFE 1C01 1C03 1C03 1C06 1C07 1C07 1C08 1C08 1C09 1C0A 1C0A 1C0D 1C10 1C11 1C12 1C13 1C14 1C15 1C16 1C16 1C17 1C18 1C19 1C1C 1C1C 1C1C 1C1C 1C1C 1C1D 1C1E 1C1F 1C20 1C21 1C22 1C23 1C23 1C24 1C24 1C25 1C26 1C27 1C28 1C28 1C29 1C2A 1C2B 1C2C 1C2D 1C2D 1C2D 1C2D 1C2D 1C2D 1C2D 1C2E 1C2F 1C30

32475C 116051 CD0A31 38EC ED53975A D1 C3510D CF 05 CDD32C CD153B CD630E 3A725C E640 28EE CD1B1F CD2D1C 281F 2AA65A E5 ED5B685C 010F00 EDB0 EF D8 DA 01 C8 33 EB D1 010500 EDB0 CD1C1C C8 21 A7 C8 110F00 2AA65A 19 7E 23 5E 23 56 23 4E EB C34219

FOR3:

LD (SUBPPC),A LD DE,TLBYTE+33 CALL MATCHFN JR C,FORMLP LD (CHAD),DE POP DE JP EXCHAD2

;STAT ;CHECK (HL) VS (TLBYTE+33) OVER T/L+1 BYTES ;LOOP IF THE WRONG NEXT VARIABLE ;SKIP var - DE PTS TO PAST VAR NAME ;JUNK NEXT STAT ;CONTINUE EXECUTION AFTER "NEXT var" ;"NEXT without FOR" ;ASSESS "FOR" VARIABLE ;TEST FOR BREAK (RLEPCOM BELOW AVOIDS NORMAL ;BETWEEN-STATEMENT TEST) ;TYPE BYTE (FROM NVARS, IF VAR FOUND) ;BIT 6 SET=FOR-NEXT TYPE, FOUND ;5 BYTE VALUE, 5 BYTE LIMIT, 5 BYTE STEP ;2 BYTE ADDRESS, 1 BYTE PAGE, 1 BYTE STAT. NO. ;PT TO VALUE ;JR IF INTEGER MATHS ALREADY DONE

NWFERR:

RST 08H DB 5 CALL SYNTAX4 CALL CHKEND CALL BRKSTOP LD A,(STRLEN) AND 40H JR Z,NWFERR CALL ADDRDEST CALL NEXTSR JR Z,NEXT1 LD HL,(DEST) PUSH HL LD DE,(MEM) LD BC,15 LDIR DB DB DB DB DB DB CALC RCL0 RCL2 ADDN STOD0 EXIT

;******************************************************************************* NEXT:

;COPY VAR TO CALC MEMS 0,1,2 ;V ;V,S ;V+S ;HL PTS TO DROPPED NEW V ;COPY NEW V BACK TO VARS ;RET IF "NO LOOP" ;="JR +2" ;RET IF INTEGER MATHS SHOWS "NO LOOP"

EX DE,HL POP DE LD BC,5 LDIR CALL NEXTTEST RET Z DB 21H NEXT1: AND A RET Z LD DE,15 LD HL,(DEST) ADD HL,DE LD A,(HL) INC HL LD E,(HL) INC HL LD D,(HL) INC HL LD C,(HL) EX DE,HL JP RLEPCOM

;A=PAGE OF LOOPING LINE ** ;DE=ADDR OF LOOPING LINE (8000-BFFF) OR ;00?? IF ELINE IS THE LOOPING LINE ;LOOPING STATMENT NO. ;HL=ADDR, A=PAGE, C=STAT ;GOTO STAT C IN LINE AT AHL

;CHECK TO SEE IF "LIMIT" HAS BEEN EXCEEDED BY "VALUE" EF D8 D9 DA 2E 1E 02 06 03 42 07 33 13 13 1A 3D C9 NEXTTST1: NEXTTEST: DB DB DB DB DB DB DB DB DB DB DB CALC RCL0 RCL1 RCL2 GRTR0 JPTRUE 02H SUBN SGN DROP EXIT

;V,L,S ;V,L,TRUE/FALSE ;TO NEXTTST1 ;SWOP IF STEP IS NEGATIVE ;V-L IF +VE STEP

DB SWOP

INC DE INC DE LD A,(DE) DEC A RET

;DE PTS TO DROPPED SGN(V-L) (OR L-V) SGN BYTE ;SGN IS -1/0/1 SO A=1 IF SGN 1, ELSE 00 OR FF ;NZ IF LOOP POSSIBLE, Z IF NOT (SGN=+VE)

;******************************************************************************* ;NEXT SUBROUTINE ;ENTRY: HL AND TEMPW1 PTS TO FIRST BYTE OF FOR-NEXT VARIABLE ;EXIT: NZ="USE FLOATING POINT". Z=INTEGER MATH DONE. A=00 IF NO LOOP, OR FF AF BE C0 NEXTSR: XOR CP RET A (HL) NZ ;RET IF VALUE=FP

1C30 1C31 1C32 1C33 1C34 1C35 1C36 1C37 1C38 1C39 1C3A 1C3A 1C3B 1C3C 1C3D 1C3E 1C3F 1C40 1C41 1C41 1C42 1C43 1C44 1C45 1C46 1C47 1C48 1C49 1C4A 1C4B 1C4C 1C4D 1C4F 1C50 1C50 1C51 1C52 1C55 1C56 1C57 1C58 1C59 1C5A 1C5B 1C5C 1C5D 1C5E 1C5F 1C60 1C61 1C62 1C63 1C64 1C65 1C66 1C68 1C68 1C69 1C6B 1C6C 1C6C 1C6D 1C6E 1C6F 1C6F 1C70 1C71 1C72 1C73 1C73 1C74 1C77 1C7A 1C7A 1C7B 1C7C 1C7E 1C80 1C80 1C81 1C82 1C84 1C84 1C87 1C8A 1C8D 1C90 1C91 1C94 1C95 1C96 1C98 1C98 1C9A 1C9A 1C9A 1C9D 1C9E 1C9E 1C9E 1C9E 1C9E 1C9E

23 46 23 5E 23 56 23 23 BE C0 23 23 23 23 23 BE C0 23 7E 08 7E 23 4E 23 66 69 19 88 0F CE00 C0 9F EB 2AA65A 23 77 47 23 73 23 72 23 23 23 7E 23 4E 23 66 69 A8 2007 3D ED52 C8 9F 2F 47 08 A8 BF C9 E1 CDC63A D27D0D E5 DF FEB1 2004 E7 AF 1816 2A455C 22435B 3A475C 32425B E5 CDF210 F1 3C 2802 3E81 32455B C9 ONERR3: ONERR2: NEXTSR1:

INC LD INC LD INC LD INC INC CP RET

HL B,(HL) HL E,(HL) HL D,(HL) HL HL (HL) NZ

;DE=VALUE, B=SGN OF VALUE ;RET IF LIMIT=F.P.

INC HL INC HL INC HL INC HL INC HL CP (HL) RET NZ INC LD EX LD INC LD INC LD LD ADD ADC RRCA ADC RET HL A,(HL) AF,AF' A,(HL) HL C,(HL) HL H,(HL) L,C HL,DE A,B A,0 NZ

;RET IF STEP=F.P. ;A AND A"=SGN OF STEP

;HL=STEP ;ADD STEP, VALUE ;ADD SGN STEP,SGN VALUE,CARRY FLAG ;RET IF OVERFLOW OF INTEGER MATHS ;A=SGN OF NEW VALUE ;DE=NEW VALUE ;SKIP 00 ;PLACE SGN ;B=SGN OF NEW VALUE ;PLACE NEW VALUE ;A=SGN OF LIMIT

SBC A,A EX DE,HL LD HL,(DEST) INC HL LD (HL),A LD B,A INC HL LD (HL),E INC HL LD (HL),D INC HL INC HL INC HL LD A,(HL) INC HL LD C,(HL) INC HL LD H,(HL) LD L,C XOR B JR NZ,NEXTSR1 DEC SBC RET SBC CPL LD EX XOR CP RET A HL,DE Z A,A B,A AF,AF' B A

;HL=LIMIT ;XOR SGN OF LIMIT,SGN OF VALUE ;JR IF THEY DO NOT MATCH ;A=FF ("LOOP") ;RET IF LIMIT=VALUE - LOOP ;A=00 IF C, FF IF NC ;B=LOOP/NO LOOP ;A=SGN OF STEP ;REVERSE LOOP/NO LOOP DECISION IF SGN NEWVAL=-VE ;SET Z ("INTEGER MATHS DONE") ;RET WITH LOOP/NO LOOP (FF/00) ;NEXT STAT ;CHECK SYNTAX FROM CHAD ONWARDS ;STOPTOK ;SKIP "STOP" ;"OFF"

ONERROR:

POP HL CALL RUNFLG JP NC,STMTLP1 PUSH HL RST 18H CP 0B1H JR NZ,ONERR2 RST 20H XOR A JR ONERR3 LD HL,(PPC) LD (ERRLN),HL LD A,(SUBPPC) LD (ERRSTAT),A PUSH HL CALL SKIPCSTAT POP AF INC A JR Z,ONERR3 LD A,81H LD (ONERRFLG),A RET

;OFF IF "ON ERROR" USED IN ELINE ;TEMP/PERM BITS ARE "ON" (BITS 7/0) ;IF AN ERROR OCCURS NOW, ERRSTAT/LN ARE USED TO ;FIND "ON ERROR" AND DO WHAT IT SAYS ;RETURN, END PROC, FNDLNHL, IF, ELSE ;CALBAS, FOR, NEXT

INCLUDE TADJM.SAM ;TADJM.SAM

;KEYSCAN, FPSTACK, SETMIN, SEARCH

1C9E 1C9E 1C9E 1CA1 1CA4 1CA5 1CA9 1CAA 1CAB 1CAB 1CAB 1CAB 1CAB 1CAE 1CAF 1CAF 1CB1 1CB1 1CB1 1CB1 1CB2 1CB4 1CB6 1CB6 1CB7 1CB8 1CB8 1CB9 1CBB 1CBC 1CBD 1CBD 1CC0 1CC3 1CC3 1CC6 1CC8 1CC9 1CC9 1CCA 1CCC 1CCF 1CD1 1CD4 1CD6 1CD6 1CD6 1CD6 1CD6 1CD6 1CD6 1CD6 1CD7 1CD8 1CDA 1CDA 1CDC 1CDD 1CDD 1CDE 1CDF 1CDF 1CE0 1CE1 1CE2 1CE2 1CE2 1CE2 1CE5 1CE6 1CE7 1CE7 1CE7 1CE7 1CE9 1CE9 1CE9 1CE9 1CEB 1CEB 1CEE 1CF0 1CF0 1CF3 1CF4 1CF5 1CF6 1CF7 1CF8 1CF9 1CFA 1CFB 1CFC 1CFD 1D00 1D01 1D01 1D04 1D05 1D06 1D07 1D08 1D09

31004F 11ED0E D5 ED733D5C CF 0F

NMISTOP:

LD SP,ISPVAL LD DE,MAINER PUSH DE LD (ERRSP),SP RST 08H DB 15

;"BREAK into program"

;GET KEY FROM BUFFER (ACTUALLY, LASTK). NZ=GOT KEY IN A, ELSE A=0 CDC91C C8 1812 F7 B8D5 2802 AF C9 F7 9AD5 A7 37 210000 22955C 213B5C CBAE C9 F7 10D5 3A3B5C E620 3A085C 18ED RKY2: READKEY: GETKEY: CALL KEYRD RET Z JR KBF2 ;USED BY INKEY$ RST 30H DW TWOKSC JR Z,RKY2 XOR A RET RST 30H DW KYVL AND A SCF LD HL,0 LD (KBQP),HL LD HL,FLAGS RES 5,(HL) RET RST 30H DW KEYRD2 LD A,(FLAGS) AND 20H LD A,(LASTK) JR KBF2 ;JR IF GOT CODES IN DE ;RET IF NO KEY - Z,NC ;USE DE TO GET KEYMAP CODE IN A ;NZ ;"GOT KEY" ;EMPTY QUEUE ;"NO KEY" ;RET IF NO KEY - Z

KBFLUSH: KBF2: KEYRD:

;Z IF NO KEY ;SHOW "NO KEY" IN CASE WE GOT ONE

;FPSTACK.SAM - FPCS SUBROUTINES ;STACKA - STACK "A" REGISTER ON FPCS. EXIT WITH DE=STKEND ;STACKBC - DITTO WITH BC ;STACKHL - DITTO WITH HL 55 4C 1805 0600 4F 51 48 AF 47 5F CDF01C EB C9 DBFB E67F 213B5C CBB6 2A655C 77 23 73 23 72 23 71 23 70 23 22655C C9 2A655C 2B 46 2B 4E 2B 56 STACKHL: STACKA: STACKBC: STACKCM: LD D,L LD C,H JR STACKCM LD B,0 LD C,A LD D,C LD C,B XOR A LD B,A LD E,A ;NC

;ENTRY FROM TRUNC$ STKSTOREX: CALL STKSTORE EX DE,HL RET STKSTOREP: IN A,(251) ;STACK-STORE STKST0: STKSTOS: STKSTORE: AND 7FH LD HL,FLAGS RES 6,(HL) LD HL,(STKEND) LD (HL),A INC HL LD (HL),E INC HL LD (HL),D INC HL LD (HL),C INC HL LD (HL),B INC HL LD (STKEND),HL RET LD HL,(STKEND) DEC HL LD B,(HL) DEC HL LD C,(HL) DEC HL LD D,(HL) ;BIT 7=0 IF ARRAY OR "SLICED". BITS 4-0=START PAGE ;STRING RESULT ;PAGE AND FLAG IF STRING, EXPONENT IF FP NUMBER ;E=SIGN IF SMALL INTEGER ;START IF STRING ;CD=INTEGER IF SMALL INTEGER ;LEN IF STRING ;DE=STKEND

;STORE A STRING. DE=START, BC=LEN. PAGE IS ASSUMED TO BE SWITCHED IN

STKFETCH:

1D0A 1D0B 1D0C 1D0D 1D0E 1D0E 1D11 1D12 1D12 1D12 1D12 1D12 1D15 1D16 1D18 1D19 1D1C 1D1D 1D1D 1D1E 1D20 1D20 1D23 1D27 1D29 1D2D 1D2E 1D2E 1D2E 1D2E 1D31 1D33 1D33 1D33 1D33 1D36 1D36 1D38 1D38 1D39 1D39 1D3A 1D3B 1D3B 1D3B 1D3B 1D3E 1D41 1D42 1D43 1D44 1D46 1D46 1D47 1D48 1D49 1D4A 1D4B 1D4B 1D4E 1D4F 1D50 1D51 1D53 1D54 1D55 1D56 1D57 1D58 1D59 1D5A 1D5B 1D5B 1D5C 1D5C 1D5E 1D60 1D61 1D62 1D63 1D64 1D65 1D65 1D65 1D65 1D68 1D69 1D69 1D6A 1D6B 1D6C 1D6E 1D6E 1D6F 1D6F 1D70 1D71 1D71 1D71 1D71 1D73 1D74 1D77

2B 5E 2B 7E 22655C C9 STSTKE:

DEC HL LD E,(HL) DEC HL LD A,(HL) LD (STKEND),HL RET

;FASTER DELETE-TOP-OF-FPCS. TO BE CALLED! THIS IS NOT A FPCS FUNCTION! ;EXIT: HL PTS TO DELETED NUMBER. 2A655C 7D D605 6F 32655C D0 25 18EE 010500 ED5B655C EDB0 ED53655C C9 CD3B1D 1803 CD651D 3801 C8 CF 1E 2A655C 01FBFF 09 7E A7 2805 EF E0 01 44 33 22655C AF 96 23 CB7E 23 4E 23 46 79 60 69 C8 D8 ED62 ED42 3F 44 4D 79 C9 CD3B1D D8 08 04 08 1001 C9 37 C9 DBFB F5 CD351F CDB904 FPTOA2: FPTOA: FPBCINT: IOORERR: HLTOFPCS: FDELETE: LD HL,(STKEND) LD A,L SUB 5 LD L,A LD (STKEND),A RET NC DEC H JR STSTKE LD BC,5 LD DE,(STKEND) LDIR LD (STKEND),DE RET CALL FPTOBC JR GETIBC CALL FPTOA JR C,IOORERR RET Z RST 08H DB 30 LD HL,(STKEND) LD BC,-5 ADD HL,BC LD A,(HL) AND A JR Z,FPBCINT DB DB DB DB DB CALC STKHALF ADDN INT EXIT ;RET IF +VE ;"Integer out of range"

;ALWAYS RETS ON STANDARD SAM...

;GET FPCS INTEGER TO BC AND HL. A=C. IOOR IF TOO BIG OR -VE GETINT:

;GET FPCS BYTE TO A AND C. IOOR IF TOO BIG OR -VE GETBYTE: GETIBC:

;COMPRESS TOP OF FPCS TO BC AND HL. CY IF TOO BIG, NZ IF -VE. A=C FPTOBC:

;NC

;CHANGES FORM TO INTEGER IF POSSIBLE ;"DELETE" ;NC IF SMALL INTEGER FORM (ELSE IOOR) ;SET NZ IF -VE

LD (STKEND),HL XOR A SUB (HL) INC HL BIT 7,(HL) INC HL LD C,(HL) INC HL LD B,(HL) LD A,C LD H,B LD L,C RET Z RET C SBC HL,HL SBC HL,BC CCF LD B,H LD C,L LD A,C RET CALL FPTOBC RET C EX AF,AF' INC B EX AF,AF' DJNZ FPTOA2 RET SCF RET IN A,(URPORT) PUSH AF CALL ADDRELN CALL SETKC2

;RET IF +VE ;RET IF OUT OF RANGE ;HL=0 ;NEGATE BC. RESULT NZ, CY

;NEGATED RESULT IN HL/BC. C=A. NZ, NC

;COMPRESS TOP OF FPCS TO A (AND C). CY IF TOO BIG, NZ IF -VE.

;INC B WITHOUT ALTERING THE FLAGS ;JR IF B<>0 - SIGNAL OUT OF RANGE (CY)

;CALLED BY MAINER, INIT SETMIN:

;SET KCUR

1D7A 1D7C 1D7D 1D7F 1D80 1D83 1D86 1D87 1D89 1D89 1D8C 1D8F 1D92 1D95 1D95 1D98 1D9B 1D9C 1D9C 1D9C 1D9C 1D9C 1D9C 1D9C 1D9E 1D9E 1D9F 1DA2 1DA3 1DA3 1DA6 1DA6 1DA7 1DAA 1DAC 1DAC 1DAC 1DAC 1DAC 1DAC 1DAC 1DAC 1DAC 1DAD 1DAE 1DAE 1DAF 1DB1 1DB1 1DB2 1DB2 1DB3 1DB4 1DB5 1DB6 1DB6 1DB7 1DB8 1DBA 1DBC 1DBC 1DBE 1DC0 1DC0 1DC2 1DC4 1DC4 1DC6 1DC8 1DC8 1DCA 1DCC 1DCC 1DCE 1DD0 1DD0 1DD1 1DD3 1DD3 1DD3 1DD3 1DD3 1DD3 1DD3 1DD4 1DD6 1DD6 1DD7 1DDA 1DDA 1DDC 1DDC 1DDF 1DE0 1DE1 1DE2 1DE2 1DE4 1DE4 1DE5 1DE6 1DE7 1DE8

360D 23 36FF 23 22915A 32905A F1 D3FB 2A915A 3A905A 228E5A 328D5A 2ACC5B 22655C C9 SETWORK:

LD (HL),0DH INC HL LD (HL),0FFH INC HL LD (WORKSP),HL LD (WORKSPP),A POP AF OUT (URPORT),A LD LD LD LD HL,(WORKSP) A,(WORKSPP) (WKEND),HL (WKENDP),A

;CLEAR ELINE

;CLEAR WORKSPACE ;CLEAR FLOATING POINT CALC STACK

SETSTK:

LD HL,(FPSBOT) LD (STKEND),HL RET

;SEARCH PROGRAM. CALLED TO FIND DEF FN AND DATA. ;ENTRY: E=TARGET, CHAD PTS TO START 168D D9 018DFF D9 018D01 DF 3A475C 1802 SRCHPROG: LD D,THENTOK ;NULL INTERVENING SEARCHALL: EXX LD BC,0FF00H+THENTOK ;ALL PROGRAM/NULL TARGET2 RELOAD EXX SRCHALL2: SRCHALL3: LD BC,0100H+THENTOK RST 18H LD A,(SUBPPC) JR FINDERS ;NO INTERVENING/NULL TARGET2 ;START AT CHAD ;STAT NO FOR A"

;ENTRY AT "FINDER" OR "FINDERS" (WITH A=CURRENT STAT NO) ;B=1 FOR NO INTERVENING TOKENS. ;D=INTERVENING TOKS OR "THEN" FOR NULL, E=TARGET, C=TARGET2 (LESLE OR NULL) ;HL PTS TO START ;C"=TARGET 2 RELOAD, B"=ONE LINE/ALL PROG ;EXIT: CY=FOUND JUST BEFORE HL/(CHAD) AT STAT. A 08 3C 08 1805 23 23 23 23 23 7E 23 FE0E 28F5 FE0D 2832 FEB7 2827 FE22 283D FE3A 28E0 FE8D 28DC BA 2839 FINCSTAT: FINDERS: FSKIP5: FSKIP4: EX AF,AF' INC A EX AF,AF' JR FINDER INC HL INC INC INC INC HL HL HL HL ;INC STATEMENT NO. IN A"

FINDER:

LD A,(HL) INC HL CP 0EH JR Z,FSKIP5 CP 0DH JR Z,FINDER5 CP 0B7H JR Z,FREMARK CP 22H JR Z,FQUOTE CP ":" JR Z,FINCSTAT CP THENTOK JR Z,FINCSTAT CP D JR Z,FINTERV

;SKIP FP FORMS ;JR IF LINE END ;REMTOK ;AVOID PROBLEMS FROM EG SINGE QUOTE IN REMS ;QUOTE ;INC STAT NO ;IF COLON OR "THEN" ;INC "INTERVENING" COUNT IN B IF FOUND ; E.G. "DO" OR "IF" (USE "THEN" AS NULL) ;THEN: JR FINDER4 ;TARGET2 IS NULL UNLESS LELSE/LIF ;SEARCH, AND INTERVENING COUNT SHOWS ;NO NESTED LIF-ENDIF STRUCTURES (B=1)

B9 2806 BB C2B61D 1006 22975A 08 37 C9 1004 D9 79 D9 4F FOUNDY: FINDER4:

CP C JR Z,FOUNDY CP E JP NZ,FINDER DJNZ FOUNDX LD (CHAD),HL EX AF,AF' SCF RET DJNZ FINDN1 EXX LD A,C EXX LD C,A

;JR IF TARGET 2 FOUND ;JR IF NOT TARGET ;JR IF B<>0 - DON"T ACCEPT FIND ;PT CHAD TO TARGET LOCN+1 ;A=STAT NO. ;"FOUND" ;JR IF COUNT WASN"T 1 ;OR, IF IT WAS, PRIME TARGET2 TO BE NON-NULL ;FETCH TARGET 2 RELOAD FROM C"

FOUNDX:

1DE8 1DE9 1DEB 1DEB 1DED 1DED 1DEE 1DEF 1DF2 1DF2 1DF3 1DF4 1DF5 1DF6 1DF7 1DF7 1DF9 1DFC 1DFF 1E01 1E02 1E05 1E05 1E06 1E07 1E0A 1E0A 1E0C 1E0C 1E0D 1E0F 1E11 1E11 1E11 1E11 1E12 1E13 1E16 1E18 1E18 1E18 1E18 1E1B 1E1B 1E1B 1E1B 1E1C 1E1C 1E1C 1E1C 1E1D 1E20 1E23 1E25 1E28 1E28 1E29 1E2A 1E2B 1E2C 1E2E 1E2F 1E30 1E31 1E32 1E33 1E35 1E39 1E3D 1E40 1E41 1E42 1E43 1E44 1E45 1E46 1E46 1E49 1E4A 1E4A 1E4D 1E4F 1E4F 1E4F 1E4F 1E52 1E52 1E52 1E52 1E53 1E53 1E53 1E53 1E55 1E57 1E58 1E59 1E5A 1E5B 1E5B 1E5C 1E5D 1E5E

04 18CB 3E0D BE 23 C2ED1D 7E D9 B8 D9 D0 CB74 C4F23F 22AF5A 3E01 08 C3B21D BE 23 C2051E 18AA 04 0E8D 18C5 AF E5 CD143F 1810 010100 AF E5 CD143F 219600 ED52 D24B3F 50 59 4F 7A E63F 57 E1 D5 E5 F7 92E7 ED5B8E5A ED4B8D5A CD4E2A D1 E1 19 EB 1B C9 CD4D1A C0 CD4E1F 1803 CD571F AF CBB8 CBB0 57 B0 B1 C8 7A 50 59 4F

FINDN1: FREMARK: FREMLP: FINDER5:

INC B JR FINDER LD A,0DH CP (HL) INC HL JP NZ,FREMLP LD A,(HL) EXX CP B EXX RET NC BIT 6,H CALL NZ,INCURPAGE LD (CLA),HL LD A,1 EX AF,AF' JP FSKIP4

;CORRECT INTERVENING COUNTER

;LOOP PAST REMS TO LINE END ;MSB OF NEXT LINE NUMBER, OR FF TERMINATOR ;B"=00 FOR 1 LINE SEARCH OR FF FOR WHOLE PROG ;E-LINE NEEDS AN FF TERMINATOR ;RET IF FINISHED ;INC UPPER RAM PAGE, ADJ HL, IF HL>BFFF ;CURRENT LINE ADDR ;STATEMENT 1 ;IN A" ;DO NEXT LINE ;LOOP PAST LITERAL STRINGS ;HL IS PAST END QUOTE ;INC COUNT OF TARGETS TO SKIP ;TARGET2=NULL

FQUOTE:

CP (HL) INC HL JP NZ,FQUOTE JR FINDER INC B LD C,THENTOK JR FINDER4 XOR A PUSH HL CALL TSTRMBIG JR MKRM2 LD BC,1 XOR A PUSH HL CALL TSTRMBIG LD HL,150 SBC HL,DE JP NC,OOMERR LD D,B LD E,C LD C,A LD A,D AND 3FH LD D,A POP HL PUSH DE PUSH HL RST 30H DW XOINTERS LD DE,(WKEND) LD BC,(WKENDP) CALL FARLDDR POP DE POP HL ADD HL,DE EX DE,HL DEC DE RET CALL FNDLINE RET NZ CALL NEXTONE JR RECLAIM2 CALL DIFFER XOR A RES 7,B RES 6,B LD D,A OR B OR C RET Z LD LD LD LD A,D D,B E,C C,A

FINTERV:

;MAKE ROOM, ALLOWING NO OVERHEAD MKRMCH:

;OPEN 1 BYTE AT HL MKRM1: MAKEROOM: MKRBIG: ;OPEN BC BYTES AT HL. BC MUST BE <4000H ;OPEN ABC BYTES AT HL. A=16K PAGES, BC=MOD 16K ;LOCN ;INSIST ON A 150-BYTE OVERHEAD

MKRM2:

;CDE=ROOM. NC (SIGNALS "MAKEROOM") ;LOCN ;MOD 16K ;LOCN ;EXIT WITH AHL=OLD WORKEND (SRC), MOD/PAGCOUNT SET ;CDE=DEST (NEW WKEND) ;LOCN ;MOD 16K ;HL=LOCN ;DE=END (IF <16K MADE)

FNORECL: NORECL:

;DELETE LINE FROM PROGRAM ;GET BC, SWOP LOCN TO HL

;ENTRY WITH DE=LOCN, HL=END, DE PAGED IN RECLAIM1: RECLAIM2: RECL2BIG: ;ENTRY WITH BC=BYTES TO RECLAIM AT HL (<16K) ;RECLAIM ABC BYTES AT HL. A=16K PAGES, BC=MOD 16K

;CDE=SPACE

1E5F 1E60 1E61 1E62 1E63 1E64 1E66 1E67 1E68 1E69 1E6B 1E6C 1E6D 1E6F 1E71 1E71 1E73 1E74 1E74 1E77 1E78 1E79 1E7A 1E7B 1E7E 1E7F 1E80 1E80 1E80 1E80 1E80 1E80 1E81 1E84 1E85 1E88 1E8B 1E8C 1E8F 1E93 1E96 1E97 1E98 1E99 1E9A 1E9B 1E9C 1E9C 1E9C 1E9C 1E9C 1E9C 1E9D 1E9F 1EA1 1EA1 1EA4 1EA7 1EAA 1EAB 1EAC 1EAE 1EAE 1EAE 1EAE 1EB0 1EB2 1EB2 1EB3 1EB5 1EB5 1EB7 1EB8 1EBA 1EBA 1EBC 1EBC 1EBD 1EBF 1EC0 1EC1 1EC3 1EC3 1EC4 1EC5 1EC9 1ECD 1ECE 1ED0 1ED0 1ED1 1ED4 1ED6 1ED6 1ED7 1EDA 1EDA 1EDB 1EDC 1EDF 1EE2 1EE5 1EE5

C5 D5 E5 37 F7 92E7 E1 D1 C1 DBFB F5 E5 CB74 2803 CBB4 3C CDDE1F D1 C1 48 D5 CD5E2A E1 C9 RECL5:

PUSH BC PUSH DE PUSH HL SCF RST 30H DW XOINTERS POP HL POP DE POP BC IN A,(251) PUSH AF PUSH HL BIT 6,H JR Z,RECL5 RES 6,H INC A CALL ADDAHLCDE POP DE POP BC LD C,B PUSH DE CALL FARLDIR POP HL RET

;PAGES ;MOD 16K ;LOCN ;"RECLAIMING" ;SETS PAG/MODCOUNT TO MOVE ;LOCN ;MOD 16K ;PAGES ;LOCN

;AHL=SRC ;CDE=DEST (LOCN)

;MAKE ROOM AT WKSPACE END, BC BYTES LONG. EXIT WITH BC=ROOM SIZE, DE=START, ;HL=END (IF ROOM <16K), A=UNCHANGED. ROOM PAGE SWITCHED IN. F5 CD243F 57 3A8D5A CDDF3F 7A 328D5A ED5B8E5A 228E5A 62 6B 09 2B F1 C9 WKROOM: PUSH AF CALL TESTROOM LD D,A LD A,(WKENDP) CALL SELURPG LD A,D LD (WKENDP),A LD DE,(WKEND) LD (WKEND),HL LD H,D LD L,E ADD HL,BC DEC HL POP AF RET ;CHECK BC BYTES OK, GET AHL=NEW WKEND ;SWITCH IN OLD WKEND ;NEW WKENDP ;START OF ROOM

;END OF ROOM, IF ROOM<16K (HL MAY BE >C000)

;ADJUST SINGLE "SYS VAR" (ACTUALLY, FOR-NEXT OR DO/GOSUB/PROC ADDR) ;ENTRY: HL POINTS TO SVAR, CDE=LOCN, F'=CY IF RECLAIMING E5 FDE1 0601 FD7E00 FD6E01 FD6602 24 25 2837 CB74 2803 3C CBB4 E61F B9 382B 2007 EB ED52 19 EB 3022 C5 D5 ED4B4D5B ED5B4F5B 08 3806 08 CDDE1F 1804 08 CDE71F D1 C1 FD7700 FD7501 FD7402 FD23 PRECL: PNT3: PADJ: PNT2: ASSV: PNLP: PUSH HL POP IY LD B,1 LD A,(IY+0) LD L,(IY+1) LD H,(IY+2) INC H DEC H JR Z,NPSV BIT 6,H JR Z,PNT2 INC A RES 6,H AND 1FH CP C JR C,NPSV JR NZ,PADJ EX DE,HL SBC HL,DE ADD HL,DE EX DE,HL JR NC,NPSV PUSH BC PUSH DE LD BC,(TEMPW4) LD DE,(TEMPW5) EX AF,AF' JR C,PRECL EX AF,AF' CALL ADDAHLCDE JR PNT3 EX AF,AF' CALL SUBAHLCDE POP DE POP BC LD (IY+0),A LD (IY+1),L LD (IY+2),H INC IY ;AHL=SVAR ;no adj if e.g. eline addr v2.1

;COMPARE AHL AND CDE ;JR IF IN SECTION C ;ELSE ADJUST ;JR IF LOCN PAGE IS HIGHER, SO NO ADJ ;JR IF LOCN PAGE IS LOWER - ADJUST ;ELSE COMPARE OFFSETS - SBC LOCN,SVAR ;DO NOT ADJUST SVAR IF IT IS <= LOCN ;SAVE PTR COUNT AND LOCN PAGE ;CDE=AMOUNT TO ADJ BY ;JR IF RECLAIMING

;PLACE ADJUSTED SYS VAR

NPSV:

1EE7 1EE9 1EEB 1EED 1EED 1EEE 1EEE 1EEE 1EEE 1EEF 1EF0 1EF2 1EF2 1EF3 1EF3 1EF4 1EF5 1EF6 1EF7 1EF9 1EF9 1EFB 1EFD 1EFD 1EFE 1EFF 1F00 1F02 1F04 1F05 1F07 1F08 1F0C 1F0F 1F10 1F11 1F11 1F12 1F14 1F14 1F15 1F16 1F17 1F19 1F19 1F1A 1F1B 1F1B 1F1B 1F1D 1F1F 1F1F 1F21 1F23 1F23 1F25 1F27 1F27 1F29 1F2B 1F2B 1F2D 1F2F 1F2F 1F31 1F32 1F32 1F34 1F35 1F35 1F37 1F38 1F38 1F38 1F38 1F3A 1F3B 1F3B 1F3D 1F3D 1F3E 1F3E 1F3E 1F3E 1F3E 1F40 1F40 1F40 1F40 1F41 1F44 1F45 1F46 1F47 1F48 1F49 1F4B 1F4D 1F4E 1F4E 1F4E 1F4F 1F50

FD23 FD23 10B4 C9 08 4A 061A E5 5E 23 56 19 381B CB76 2814 E5 C5 7E E61F C612 5F 1600 19 ED5BCC5A CD9C1E C1 E1 23 18DF E1 23 23 10D9 08 C9 2EA5 181F 2E87 181B 2E84 1817 2E81 1813 2E90 180F 3E99 21 3E9F 21 3E93 21 3E8A 21 3E96 6F ADDRDEST: ADDRNV: ADDRNE: ADDRSAV: ADDRWK: ADDRKC: ADDRPROG: ADDRELN: AFNF: AFLE: AFLPS: AFML: AFLL:

INC IY INC IY DJNZ PNLP RET ;ADJUST 'FOR' LOOPS IF EX AF,AF' LD C,D LD B,26 PUSH HL LD E,(HL) INC HL LD D,(HL) ADD HL,DE JR C,AFLE BIT 6,(HL) JR Z,AFNF PUSH HL PUSH BC LD A,(HL) AND 1FH ADD A,18 LD E,A LD D,0 ADD HL,DE LD DE,(TEMPW3) CALL ASSV POP BC POP HL INC HL JR AFLL POP HL INC HL INC HL DJNZ AFML EX AF,AF' RET LD L,>(DEST-1) JR ADDRSV LD L,>(NVARS-1) JR ADDRSV LD L,>(NUMEND-1) JR ADDRSV LD L,>(SAVARS-1) JR ADDRSV LD L,>(WORKSP-1) JR ADDRSV LD A,>(KCUR-1) DB 21H LD A,>(PROG-1) DB 21H LD A,>(ELINE-1) DB 21H ;"JR+2" LD A,>(DATADD-1) DB 21H ;"JR+2" LD A,>(CHAD-1) LD L,A ;LOOK AT SYS VAR LOCN. ENTRY: HL PTS TO SYS VAR (PAGE, OFFSET) ;EXIT: PAGE SELECTED, HL=OFFSET (IN SECTION C), A=PAGE LOCN C'D'E' IS BEFORE THEM ;26 LETTER LISTS ;PT TO CURRENT LETTER LIST

;JR IF THIS LIST ENDED ;JR IF NOT FOR-VAR

;NAME LEN-1 ;3 TO SKIP TO START OF VALUE, 15 FOR VLS ;PT TO ADDR ;CDE=LOCN ;ADJUST SINGLE "SYSTEM VAR"

;NEXT VAR OF THIS LETTER ;THIS LIST ENDED NOW ;PT TO NEXT LIST

;USED BY READ AND ITEM ADDRDATA: ADDRCHAD:

265A 7E CDDF3F 23 7E 23 66 6F DBFB E61F C9 E5 23 23

ADDRSV: ASV2:

LD H,VAR2/256 LD A,(HL) CALL SELURPG INC HL LD A,(HL) INC HL LD H,(HL) LD L,A IN A,(251) AND 1FH RET PUSH HL INC HL INC HL

;FROM FN, WITH HL=DEFADDRP

NEXTONE:

1F51 1F52 1F53 1F54 1F55 1F56 1F57 1F57 1F58 1F5A 1F5B 1F5C 1F5D 1F5E 1F5F 1F5F 1F5F 1F5F 1F5F 1F5F 1F61 1F62 1F62 1F62 1F62 1F62 1F62 1F63 1F64 1F65 1F68 1F69 1F6B 1F6B 1F6D 1F6D 1F6E 1F6F 1F70 1F71 1F71 1F74 1F75 1F76 1F79 1F79 1F79 1F79 1F7A 1F7B 1F7D 1F7F 1F83 1F84 1F85 1F87 1F8A 1F8B 1F8C 1F8C 1F8C 1F8C 1F8D 1F8E 1F91 1F91 1F92 1F93 1F96 1F97 1F99 1F9A 1F9B 1F9C 1F9D 1F9D 1F9D 1F9D 1F9D 1F9D 1F9D 1F9F 1FA2 1FA4 1FA4 1FA4 1FA4 1FA6 1FA6 1FA8 1FAA 1FAA 1FAC 1FAD 1FAD 1FAF 1FB1 1FB1 1FB3 1FB3 1FB5 1FB6 1FB6

4E 23 46 23 09 D1 A7 ED52 44 4D 19 EB C9 DIFFER:

LD C,(HL) INC HL LD B,(HL) INC HL ADD HL,BC POP DE AND A SBC HL,DE LD B,H LD C,L ADD HL,DE EX DE,HL RET

;LINE LEN ;DE=OLD START, HL=NEXT LINE START

;ENTRY AS LIMBYTE, BUT FPCS VALUE DECED BEFORE CHECKING, RETURNED DECED. C IS ;NOT DECED 3EFF FE LIMDB: LD A,0FFH DB 0FEH ;"JR+1"

;ENTRY: D=LIMIT (VALUE MUST BE BELOW IT), E=ERROR TO GIVE IF VALUE TOO HIGH. ;VALUE IS ON FPCS ;EXIT: A AND C=VALUE, DE=ORIG AF F5 D5 CD651D D1 3806 2004 F1 81 BA D8 213A5C 73 E5 C30800 F5 78 CBB8 CBB0 ED43845B 07 07 E603 32835B F1 C9 C5 D5 CD1620 4F EB CD0E20 37 ED52 99 D1 C1 C9 ERRORE: LIMBYTE: XOR A PUSH AF PUSH DE CALL FPTOA POP DE JR C,ERRORE JR NZ,ERRORE POP AF ADD A,C CP D RET C LD HL,ERRNR LD (HL),E PUSH HL JP 0008H ;WILL BE POPPED AND USED AS "RET ADDR"

;LIMIT/ERROR ;JR IF >FF ;JR IF -VE

;SET PAGCOUNT/MODCOUNT FROM BC (0000-FFFF) SPLITBC: PUSH AF LD A,B RES 7,B RES 6,B LD (MODCOUNT),BC RLCA RLCA AND 03H LD (PAGCOUNT),A POP AF RET PUSH BC PUSH DE CALL WENORMAL LD C,A EX DE,HL CALL RTNORMAL SCF SBC HL,DE SBC A,C POP DE POP BC RET ;CDE=WKSPACE END ;AHL=RAMTOP (19 BIT)

;LEN MOD 16K ;PAGES (0-3)

;GET ROOM. RETURN FREE MEMORY (UPPER RAMS) IN AHL AS A 19 BIT NO. NZ IF >=64K GETROOM: GRM2:

;AHL=ROOM (19BIT). NZ IF ROOM >=64K

;PAGE OVERFLOW. USED BY INSTRING, S16OP ;CALLED IF ADD HL,RR GIVES CARRY. CORRECTS THE PAGE AND ADDRESS IN HL ;ENTRY: HL=0000-BFFE (BFFE IF HL WAS BFFF+FFFF) DBFB CDA41F 1825 C602 CB74 2803 CBB4 3C CB7C 2802 C602 CBFC C9 PGOA3: PGOA2: PGOVERF: IN A,(URPORT) CALL PGOA JR PGOE ADD A,2 BIT 6,H JR Z,PGOA2 RES 6,H INC A BIT 7,H JR Z,PGOA3 ADD A,2 SET 7,H RET ;IF BIT 7 IS HIGH INC TWICE ;IF THERE WAS A CARRY, ADDR IS AT LEAST 0000 ;SO INC 2 PAGES SO ADDR CAN BE DROPPED 32K ;IF BIT 6 IS HIGH WE CAN INC AGAIN

;CORRECT AHL AFTER PAGE OVERFLOW, BUT DON"T ALTER PAGING PGOA:

;ADDRESS ELINE AND DEC PTR TO PT TO SAVARS END

1FB6 1FB6 1FB9 1FB9 1FB9 1FB9 1FB9 1FB9 1FBA 1FBA 1FBC 1FBD 1FBD 1FBF 1FC0 1FC2 1FC4 1FC6 1FC6 1FC7 1FC7 1FC9 1FC9 1FCB 1FCC 1FCC 1FCC 1FCC 1FCC 1FCC 1FCC 1FCF 1FD0 1FD2 1FD4 1FD4 1FD7 1FD8 1FDA 1FDC 1FDE 1FDE 1FDE 1FDE 1FDE 1FDF 1FE0 1FE3 1FE4 1FE5 1FE7 1FE7 1FE7 1FE7 1FE7 1FE8 1FE9 1FEC 1FED 1FEF 1FF0 1FF0 1FF1 1FF2

CD351F

ADDRELND:

CALL ADDRELN

;ENTRY: HL HOLDS AN ADDRESS. IT IS DECREMENTED, AND ADJUSTED IF IT FALLS ;TOO LOW, SO IT PTS TO 8000-BFFF, PAGING AS NEEDED. IF CALLED FROM SYNTAX4, ;HL MAY BE BELOW 8000H ALREADY. COPES WITH UNDERFLOW OF UP TO 32K 2B CB7C C0 DBFB 3D CBFC CB74 2001 3D CBB4 D3FB C9 DECPT2: PGOE: DECPTR: CHKPTR: DEC HL BIT 7,H RET NZ IN A,(251) DEC A SET 7,H BIT 6,H JR NZ,DECPT2 DEC A RES 6,H OUT (251),A RET ;RET IF STILL AT 8000H OR MORE

;JR IF FALLEN INTO 4000-7FFF - CORRECT BY 1 PAGE ;IF IN 0000-3FFF, 2 PAGES

;ADD ADDR,BC. ADD BC TO AN ADDRESS IN AHL. A=PAGE, HL=8000-BFFF. BC UNCHNGED. ;BC CAN HAVE ANY VALUE ;SUB ADDR,BC. DITTO ;CARRY IF OVERFLOW CD2120 09 CE00 181E CD2120 A7 ED42 DE00 1814 ADDAHLBC: CALL AHLNORM ADD HL,BC ADC A,0 JR PAGEFORM CALL AHLNORM AND A SBC HL,BC SBC A,0 JR PAGEFORM ;GET 19 BIT FORM IN AHL ;ADD AHL,BC

SUBAHLBC:

;SUB AHL,BC

;ADD ADDR IN AHL (PAGE FORM) TO THE ADDRESS IN CDE (PAGE FORM) ;RESULT IN AHL (PAGE FORM). CARRY IF OVERFLOW PAGES. CDE UNCHANGED. C5 D5 CD0120 19 89 1809 ADDAHLCDE: PUSH BC PUSH DE CALL TWOCONV ADD HL,DE ADC A,C JR PPFCOM

;SUBTRACT FROM ADDR IN AHL (PAGE FORM) THE ADDRESS IN CDE (PAGE FORM) ;RESULT IN AHL (PAGE FORM). CARRY IF OVERFLOW. CDE UNCHANGED. C5 D5 CD0120 A7 ED52 99 D1 C1 SUBAHLCDE: PUSH BC PUSH DE CALL TWOCONV AND A SBC HL,DE SBC A,C POP DE POP BC

;SUB AHL,CDE ;CONTINUE INTO PAGEFORM

PPFCOM:

1FF2 1FF2 1FF2 1FF4 1FF5 1FF7 1FF8 1FFA 1FFB 1FFD 1FFF 2000 2001 2001 2001 2001 2004 2004 2004 2004 2005 2006 2007 200A 200B 200C 200D 200E 200E 2011 2014 2016 2016 2019

;TRANSFORM 19-BIT NUMBER IN AHL TO PAGE, ADDR (8000-BFFF) CB14 17 CB14 17 CB1C 37 CB1C FE20 3F C9 CD2120 F5 EB 79 CD2120 EB 4F F1 C9 3AB15C 2AB25C 180B 3A8D5A 2A8E5A PAGEFORM: RL H RLA RL H RLA RR H SCF RR H CP 20H CCF RET CALL AHLNORM PUSH AF EX DE,HL LD A,C CALL AHLNORM EX DE,HL LD C,A POP AF RET LD A,(RAMTOPP) LD HL,(RAMTOP) JR AHLNORM LD A,(WKENDP) LD HL,(WKEND)

;NC. PAGE NOW OK ;ADDR NOW OK IN 8000-BFFF FORM ;SET CARRY IF OVERFLOW

;CONVERT PAGE FORMS IN AHL AND CDE TO 19-BIT. USES B TWOCONV: CDENORM: ;CONVERT PAGE FORM IN CDE TO 19-BIT IN CDE. CHANGES CDE ONLY

RTNORMAL: WENORMAL:

201C 201E 2020 2020 2021 2021 2021 2021 2021 2023 2025 2026 2028 2029 202B 202D 202E 202E 202E 202E 202E 202E 202E 2031 2032 2033 2037 2038 2038 2038 2038 2038 203A 203B 203B 203B 203B 203D 203D 203F 203F 203F 203F 2040 2041 2042 2043 2044 2045 2045 2047 2047 204A 204B 204B 204C 204C 204E 204E 204F 2051 2051 2053 2054 2055 2055 2056 2058 2059 205B 205B 205D 205E 205E 205E 205E 205E 205E 2060 2060 2060 2060 2062 2064 2066 2067 2068 2069 206A 206B 206B 206B 206B 206B 206B 206B 206B 206B 206B 206C 206F 2071 2071

CB74 2801 3C

BIT 6,H JR Z,AHLNORM INC A ;CONVERT PAGE FORM IN AHL TO 19-BIT IN AHL. ;TOP 3 BITS OF ORIG A AND TOP 2 BITS OF HL ARE IRREL.

CB04 CB04 1F CB1C 1F CB1C E607 C9

AHLNORM:

RLC H RLC H RRA RR H RRA RR H AND 07H RET

;SET ERROR STACK PTR. EXITS WITH OLD ERRSP ON STACK. AFTER A ROUTINE HAS CALLED ;HERE, IT CAN CALL OTHER SRS. AND RETURN WILL STILL OCCUR EVEN AFTER AN ERROR. ;USES HL ONLY 2A3D5C E3 E5 ED733D5C C9 SETESP: LD HL,(ERRSP) EX (SP),HL PUSH HL LD (ERRSP),SP RET

;READ LEN FROM "DESIRED" HEADER (TAPE) 2E22 11 2E72 264B 4E 23 5E 23 56 C9 0E00 CD4C20 D0 A7 3E08 3D 20FD DBFE 0C C8 A8 E640 78 28F6 EE67 47 EDGSENS: EWL: EDGLP: RDTHREE: RDRLEN: LD L,>HDR+HDN+3 DB 11H LD L,>HDL+HDN+3 LD H,<HDR ;READ THREE BYTES FROM HL INTO C AND DE LD C,(HL) INC HL LD E,(HL) INC HL LD D,(HL) RET LD C,0 CALL EDGSENS RET NC AND A LD A,8 DEC A JR NZ,EWL IN A,(KEYPORT) INC C RET Z XOR B AND 40H LD A,B JR Z,EDGLP XOR 67H LD B,A ;TIMEOUT - NC, Z ;CP EAR BIT ;WITH LAST EDGE TYPE ;LOOP UNTIL SIGNAL LEVEL CHANGES. 47 Ts PER LOOP ;(LENGTHENED TO NEAR MULTIPLE OF 8) ;FLIP ;FLIP ;KEEP ;KEEP ;KEEP "LAST EDGE TYPE" (BIT 6) BORDER (BITS 2-0) MIC (BIT 3) UNCHANGED (HI) BEEP (BIT 4) UNCHANGED SOF (BIT 7) UNCHANGED ;INIT LOOP COUNTER TO 0 ;FIND AN EDGE ;RET IF BREAK OR TIMEOUT ;NC ;DELAY TO AVOID DOUBLE COUNTS, RELATED TO SPEED ;"JR+2"

;READ LEN FROM LOADED HEADER RDLLEN:

EDGE2: EDGEC:

E61F D3FE 3EF7 DBF9 07 07 07 79 C9

AND 1FH OUT (KEYPORT),A LD A,0F7H IN A,(STATPORT) RLCA RLCA RLCA LD A,C RET INCLUDE GRAPH0.SAM

;SOFF BIT (BIT 7) LOW ;THRO MIDI (BIT 6) LOW ;BORDER MSB (BIT 5) LOW ;ALTER BORDER ;BIT 5 IS LOW IF ESC PRESSED ;A AND C HOLD LENGTH OF PULSE ;CY="OK", NC=ESC. ;CIRCLE, DRAW

;GRAPH0.SAM ;******************************************************************************* ;ENTRY FROM JUMP TABLE WITH A=RADIUS, C,B=COORDS, HL=OFFSET IF THINPIX F5 22C85A 1812 CDF23A JCIRCLE: CIRCLE: PUSH AF LD (TEMPW1),HL JR JCIRC3 CALL SYNTAX9 ;GET COLOURS, X,Y

2074 2077 207A 207A 207D 207D 207D 207E 207F 2080 2082 2082 2083 2083 2087 2088 208A 208B 208D 2090 2091 2094 2097 209A 209C 209C 20A0 20A0 20A1 20A2 20A3 20A3 20A4 20A5 20A6 20A7 20A8 20AA 20AA 20AB 20AF 20B1 20B1 20B1 20B3 20B3 20B6 20B7 20B8 20B9 20BC 20BD 20BE 20BF 20C0 20C3 20C4 20C5 20C5 20C5 20C5 20C5 20C8 20C8 20C9 20CA 20CB 20CD 20CD 20CE 20CF 20CF 20D0 20D1 20D2 20D5 20D5 20D6 20D9 20D9 20DC 20DC 20DC 20DF 20DF 20DF 20E0 20E1 20E2 20E2 20E5 20E5 20E5 20E6 20E7 20E8 20E8 20E9 20EA 20ED 20ED 20EE 20EF

CD853A CD583A CD331D CIRCLEFD: C5 F5 F7 C8E9 F1 DD21FC20 57 CB3F 08 1E03 3A4D5A A7 C46628 CDB13F CDB423 3004 FD21FF20 D9 57 D9 50 59 E1 2C 2D 2007 EB DD21C63F FDE9 2600 CDE820 7D 6C 67 CDED20 E5 AF 94 67 CDED20 E1 2C DOCIRCLE: CIRCTK: JCIRC3:

CALL INSISCOMA CALL SYNTAX6 CALL GETBYTE PUSH BC PUSH AF RST 30H DW CIFILSR POP AF LD IX,CIRCEXT LD D,A SRL A EX AF,AF' LD E,3 LD A,(THFATT) AND A CALL NZ,GRAREC CALL SPSS CALL SETIY JR NC,CIRCTK LD IY,THCIRCSR EXX LD D,A EXX LD D,B LD E,C POP HL INC L DEC L JR NZ,DOCIRCLE EX DE,HL LD IX,TRCURP JP (IY) LD H,0 CALL CIRCP5 LD A,L LD L,H LD H,A CALL CIRC6 PUSH HL XOR A SUB H LD H,A CALL CIRC6 POP HL INC L

;REQUIRE COMMA ;RADIUS (X,Y ALREADY ON FPCS) ;COMPRESS RADIUS INTO A AND C REGS. ;RETURN TO CIRCEXT AFTER PLOT ;RAD IN C ;RAD ;Y COORD IN B, X IN C, POSSIBLE OFFSET IN TEMPW1 ;RET SEE ABOVE ;RADIUS ;RAD/2 PROTECTED TO A" ;BLITZ CODE FOR "CIRCLE" ;CALL IF FAT ;STORE PAGE, SELECT SCREEN ;SET IY TO PLOT ROUTINE

;D"=M3 PLOT INK (OR JUNK IF NOT M3) ;DE=Y/X ;L=RADIUS ;JR IF RADIUS NON-ZERO ;HL=COORDS OF CENTRE ;PLOT POINT, THEN GOTO TRCURP

;FOLLOWING SECTION DEALS WITH FIRST 4. R & L.. ;TOP

;BOTTOM ;START WITH DISP OF 1. OTHERWISE FIRST 4 POINTS ARE ;DONE TWICE (0 ABOVE AND BELOW AXIS ARE THE SAME) ;WHICH MAKES GAPS WITH OVER 1

CDDC20 2C 08 95 3002 84 25 08 7D 94 DAC520 3D C4E220 C3C63F CDDF20 7D 6C 67 CDE520 AF 94 67 7B 85 D4F020 7B 95 D8

;MAIN PLOT A POINT ON EACH SEGMENT LOOP CIRC0: CALL CIRCEX INC L EX AF,AF' SUB L JR NC,CIRC2 ADD A,H DEC H CIRC2: EX AF,AF' LD A,L SUB H JP C,CIRC0 DEC A CALL NZ,CIRCP4 JP TRCURP ;DO 8 POINTS CIRCEX: CALL CIRC3 ;DO 4 POINTS CIRC3: LD A,L LD L,H LD H,A CIRCP4: CALL CIRC4 ;DO 2 POINTS CIRC4: XOR A SUB H LD H,A CIRCP5: CIRC6: LD A,E ADD A,L CALL NC,CIRC5 LD A,E SUB L RET C ;IF ARCS HAVE NOT MET YET, DO 4 POINTS. ;CALL TEMPS, RESET PAGE ;CALL DO 4 POINTS, THEN ENTER IT AGAIN...

;SWOP DISPS ;CALL DO 2 POINTS, THEN ENTER IT AGAIN...

;NEGATE H FOR BOTTOM HALF ;X COORD ;DO RHS UNLESS WRAPPED ROUND (DO 1 POINT) ;RET IF WRAPPED, ELSE DO LHS

20F0 20F0 20F0 20F1 20F2 20F3 20F4 20F5 20F7 20F9 20F9 20FA 20FA 20FC 20FC 20FD 20FE 20FF 20FF 20FF 20FF 20FF 2101 2102 2103 2104 2105 2107 210A 210A 210A 210A 210A 210B 210E 210F 2110 2112 2114 2114 2114 2114 2114 2114 2114 2117 2119 211A 211C 211C 211E 2121 2123 2123 2124 2124 2127 2129 212B 212B 212E 212E 2131 2132 2133 2135 2135 2136 2138 2138 2139 2139 213A 213B 213C 213C 213E 213E 2141 2141 2144 2145 2147 2147 2147 2147 2147 2147 214A 214A 214A 214A 214C 214C 214F 2150 2152 2155 2155 2156 2156 2157 2157

44 4D 6F 7A 84 FEC0 3003 67 FDE9 60 69 C9

;DO 1 POINT CIRC5: LD B,H LD C,L LD L,A LD A,D ADD A,H CP 192 JR NC,CIRCEXT LD H,A CIPLOT: CIRCEXT: JP (IY) LD H,B LD L,C RET

;SAVE DISPS ;X

;PLOT HL, RETURN TO CIRCEXT ;DISPS RESTORED

;ENTRY: H=Y (RANGE OK), C=X DDE5 D5 C5 44 EB 1600 2AC85A THCIRCSR: PUSH IX PUSH DE PUSH BC LD B,H EX DE,HL LD D,0 LD HL,(TEMPW1)

;B=Y ;E=X ;OFFSET OF ZERO IF CIRCLE CENTRE X IS <80H ;OFFSET OF 0100 IF CIRCLE CENTRE X IS >017F ;OFFSET 0-FF OTHERWISE. ;E OF 0-FF+OFFSET 0-0100 IS ALWAYS IN RANGE ;REAL X ;PLOT HL,B WITHOUT ALTERING COORDS SYS VARS ;TO CIRCEXT OR TEMPS

19 CDE322 C1 D1 DDE1 DDE9

ADD HL,DE CALL M2CTPLOT POP BC POP DE POP IX JP (IX)

;******************************************************************************* ;DRAW.SAM. SAM DRAW COMMAND. ;FROM JUMP TABLE WITH X,Y IN C,B OR HL,B 3A4D5A FE01 08 183B D68E 32D05A 2001 E7 CDF23A FE2C 2013 CD573A 21D05A 7E A7 2803 F7 5E6A 74 EF C8 33 1809 CD153B 3AD05A A7 204C DRNOCU: DRNC2: PASTTO: JDRAWTO: LD CP EX JR A,(THFATT) 1 AF,AF' JDRTO3 ;CY IF THIN DRAW ;VAR IS ZERO IF "DRAW TO" USED ;SKIP "TO"

DRAW:

SUB TOTOK LD (TEMPB3),A JR NZ,PASTTO RST 20H CALL SYNTAX9 CP "," JR NZ,DRNOCU CALL SSYNTAX6 LD HL,TEMPB3 LD A,(HL) AND A JR Z,DRNC2 RST 30H DW DRCURVE-8000H LD (HL),H DB CALC DB STOD0 DB EXIT JR DRAWTOFD CALL CHKEND LD A,(TEMPB3) AND A JR NZ,DRAWFD

;GET CURVATURE

;JR IF NOT DRAW X,Y,Z

;TEMPB3=NZ, MEANS "CURVED" ;DELETE CURVATURE SO X,Y CAN BE ACCESSED

;JR IF NOT DRAW TO. ;ELSE DO DRAW TO. TEMPB3=0, MEANS "STRAIGHT"

;NOTE: COORDS SYSTEM WITH XOS, YOS ETC NORMAL IS 0 TO 255/512, AND -16 TO 175 ;Y COORD STORED INVERTED AS 0 (TOP) TO 191 (BOTTOM) CD9327 380A 3AD05A A7 1E02 CC6628 A7 08 FDRNR: DRAWTOFD: CALL GTFCOORDS JR C,FDRNR LD A,(TEMPB3) AND A LD E,2 CALL Z,GRAREC AND A EX AF,AF' ;CY IF THIN ;NOW CONVERT TO SIGNED DISPLACEMENT FROM CURRENT POSN TO NEW ONE ;FIDDLE USING XOS/YOS/XRG/YRG IF "DRAW TO" ;UNSTACK COORDS. ;B=Y, WITH 0 AT TOP. IF THIN PIX, HL=X, CY ;ELSE C=X. RANGES CHECKED ALREADY.

;BLITZ CODE FOR "DRAW TO - FAT" ;CALL IF STRAIGHT (CURVES ARE RECURSIVE ;STRAIGHT LINE DRAWS)

2157 2157 215A 215B 215D 215F 215F 2161 2163 2163 2164 2165 2167 2167 216A 216B 216D 216F 216F 2171 2173 2173 2174 2176 2176 2177 217B 217C 217E 217F 2181 2181 2182 2183 2184 2185 2187 2188 2188 2189 218A 218A 218D 218E 2190 2190 2191 2193 2193 2193 2193 2193 2196 2196 2196 2196 2196 2196 2199 2199 2199 2199 219A 219D 219E 219E 21A1 21A4 21A4 21A7 21A7 21A8 21AC 21AF 21B0 21B1 21B2 21B3 21B3 21B4 21B5 21B6 21B6 21B7 21B8 21BA 21BA 21BB 21BC 21BE 21BE 21BF 21C1 21C1 21C2 21C4 21C4 21C6 21C8 21C8 21C9 21C9 21CA

3A415A 90 16FF 3004 ED44 1601 47 08 380F 3A425A 91 1EFF 3004 ED44 1E01 4F 1814 D5 ED5B425A AF ED52 3C 3007 EB 6F 3D 67 ED52 3D D1 5F 3AD05A A7 280E F7 386A

JDRTO3:

LD A,(YCOORD) SUB B LD D,0FFH JR NC,ADJOK2 NEG LD D,01H

;SUB Y COORD, Y DEST ;ASSUME -VE ;JR IF COORD NEEDS -VE INCREMENT TO REACH DEST

ADJOK2:

LD B,A EX AF,AF' JR C,THINADJ LD A,(XCOORD) SUB C LD E,0FFH JR NC,ADJOK3 NEG LD E,01H

;B=Y DIFF, D=Y DIFF SGN ;CY IF THIN PIX ;SUB X COORD, X DEST ;ASSUME -VE ;JR IF COORD NEEDS -VE INCREMENT TO REACH DEST

ADJOK3: THINADJ:

LD C,A JR ADJOK5 PUSH DE LD DE,(XCOORD) XOR A SBC HL,DE INC A JR NC,ADJOK4 EX DE,HL LD L,A DEC A LD H,A SBC HL,DE DEC A

;C=Y DIFF, E=Y DIFF SGN

;SUB X DEST, X COORD ;ASSUME +VE ;JR IF COORD NEEDS +VE INCREMENT TO REACH DEST ;L=1 ;H=0. HL=1 COMPS FOR CARRY SET HERE ;NEGATE HL. ;A=FF

ADJOK4: ADJOK5:

POP DE LD E,A LD A,(TEMPB3) AND A JR Z,JDRAW ; RST 30H DW DRTCRV-8000H JP DRTCRV CALL DRCOORDFD ;FIDDLE USING XRG/YRG ONLY

;REL. DRAW CDF827 DRAWFD: ;REG USE: HL=LARGER AND SMALLER DIFFS, DE=SGN Y AND X, THEN D=M3 INK ; B=POINT COUNT, C=TRACKING ERROR ; HL"=Y AND X COORDS, DE"=HOR OR VERT STEP, BC"=DIAG STEP CDCC27 1D D46628 1C CDB13F CDB423 DA4A22 08 DD212A22 2A415A 7C 65 6F E5 D9 E1 D9 79 A7 2812 7D 1D 2806 A7 281B 91 1805 FEFF 2814 81 1C 381A CHKYCO: DOXADD: JDRAW: DRAWLINE: ; CALL TWONUMS JR C,JDRAW DEC E CALL NC,GRAREC INC E CALL SPSS CALL SETIY JP C,THINDRAW EX AF,AF' LD IX,PRLABEL LD HL,(YCOORD) LD A,H LD H,L LD L,A PUSH HL EXX POP HL EXX LD A,C AND A JR Z,CHKYCO2 LD A,L DEC E JR Z,DOXADD AND A JR Z,OSERRHP SUB C JR CHKYCO CP 255 JR Z,OSERRHP ADD A,C INC E JR C,RUNOFF ;A"=INK TO USE FOR MODE 3 ;RETURN ADDR FROM PLOT ROUTINE ;H=X COORD, L=Y ;H=Y, L=X ;HL"=COORDS ;B=Y DIFF, C=X DIFF, D=SGN Y, E=SGN X (01/FF) ; OR HL=X AND CY IF THINPIX ;JR IF THIN ;SGN X -> FE/00 (BLITZ CODE FOR FAT REL DRAW) ;NORMAL AGAIN ;SAVE PAGE, SELECT SCREEN ;POINT IY TO APPROPRIATE PLOT ROUTINE. ;A=INK IF M3, CY SET IF THIN PIX M2

;IF X DISP=0 X WON"T RUN OFF. AVOID +/- 0 ;DEC X SGN ;JR AND ADD XCOORD AND DISTANCE IF +VE ;ERROR IF MOVE LEFT AND X IS ZERO ;SUB X,X DISP ;ERROR IF MOVE RIGHT AND X IS AT RHS ;ADD X,X DISP ;JR IF ADD OR SUB CARRIED

21CC 21CC 21CD 21CE 21CF 21D1 21D1 21D2 21D4 21D4 21D5 21D7 21D7 21D8 21DA 21DA 21DC 21DC 21DE 21DE 21DF 21DF 21E0 21E2 21E2 21E4 21E6 21E6 21EA 21EA 21EA 21EA 21EA 21ED 21EE 21EF 21F2 21F2 21F3 21F3 21F4 21F5 21F6 21F8 21F8 21F9 21F9 21FA 21FB 21FB 21FC 21FD 21FF 21FF 2200 2202 2202 2202 2204 2204 2205 2206 2206 2207 2208 220A 220A 220B 220B 220C 220D 220E 2210 2210 2211 2211 2212 2213 2213 2214 2215 2216 2217 2219 2219 221A 221C 221C 221C 221D 221F 221F 221F 221F 221F 2220 2221 2221 2222 2223 2225 2225 2226

78 A7 7C 2811 15 2806 A7 2805 90 1805 FEBF 286A 80 14 3804 FEC0 3804 DD212F22

CHKYCO2:

LD A,B AND A LD A,H JR Z,FINCHK2 DEC D JR Z,DOYADD AND A JR Z,OSERRHP SUB B JR FINCHK

;Y WON"T RUN OFF IF DISP=0 ;INC Y SGN ;JR IF +VE (MOVE DOWN) ;ERROR IF MOVE UP AND Y IS ZERO (AT TOP) ;SUB Y,Y DISP

DOYADD: OSERRHP: FINCHK: FINCHK2: RUNOFF:

CP 191 JR Z,OSERROR ADD A,B INC D JR C,RUNOFF CP 192 JR C,DRMSUBC LD IX,PLOTCHK ;ERROR IF MOVE DOWN AND Y IS AT BOTTOM ;ADD Y,Y DISP ;(D=SGN AGAIN. CY NOT ALTERED) ;JR IF Y COORD IN RANGE ;CHECK AFTER PLOT IF EDGE HAS BEEN REACHED, ;(IF LINE WILL RUN OFF-SCREEN) RATHER THAN ;JUST RETURNING TO DRAW ROUTINE. IF OK, RETS ;TO DRAW, ELSE EXITS WITH ERROR ;GET HL=FINAL COORDS ;SIGNAL "OK" ;U/D AND L/R FLAGS

CDF221 D9 37 C33C22 D5 D9 C1 0C 2001 05 0D D9 79 B8 3005 69 1E00 1806 B0 C8 68 41 1600 D5 D9 D1 1C 2001 15 1D D9 08 57 60 78 CB3F 85 3803 BC 3806

DRMSUBC:

CALL DRMSUB EXX SCF JP DRAWEND PUSH DE EXX POP BC INC C JR NZ,NDHDIAG DEC B

DRMSUB:

NDHDIAG:

DEC C EXX LD CP JR LD LD JR A,C B NC,XGRTR L,C E,0 DRPREL B Z L,B B,C D,0

;IF C WAS FF, THEN ADDING C (-VE X DISP) TO L ; (X COORD) WILL ALWAYS CARRY TO H+B, SO DEC B. ;BC"=DIAG STEP

;JR IF X DIFF >=Y DIFF ;L=ABS X DIFF (LESS THAN Y DIFF) ;WE WILL SOMETIMES NEED TO USE LR=STAY, SINCE X ; DIFF IS LESS THAN Y DIFF. ;B=GREATEST DIFFERENCE (Y) ;RET IF BOTH DIFFS EQUAL - NO LINE! ;L=ABS Y DIFF ( <= X DIFF) ;B=GREATEST DIFFERENCE (X) ;SOMETIMES NEED UP/DOWN=STAY

XGRTR:

OR RET LD LD LD

DRPREL:

PUSH DE EXX POP DE INC E JR NZ,NDHFLAT DEC D

NDHFLAT:

DEC E EXX EX AF,AF' LD D,A LD H,B LD A,B SRL A

;IF E WAS FF, THEN ADDING E (-VE X DISP) TO L ; (X COORD) WILL ALWAYS CARRY TO H+D, SO DEC D. ;DE"=HORIZ OR VERT STEP ;D=M3 INK ;H=GREATEST COORD DIFF ;INITIALISE TRACKING ERROR BYTE. (IT ACCUMULATES ;ERRORS FROM NOT MOVING ALONG LESS-DIF AXIS) ;ADD LESSER COORD DIFF TO TRACKING ERROR ;JR C AND SUB GREATER DIFF, MOVE IN BOTH AXES ;(ERROR IS BOUND TO MOVE BACK INTO RANGE) ;CP GREATER COORD DIFF ;THE ERROR IS NOT OUT OF RANGE SO FAR. IF WE CANNOT ;YET MAKE A MOVE ON THE LESSER-CHANGING AXIS (SMALL ;ADDITIONS TO THE TRACKING ERROR DO NOT YET JUSTIFY ;IT) MOVE JUST ON THE GREATER-CHANGING AXIS (JR) ;SUB GREATER ;SAVE TRACKING ERROR BYTE IN C ;ADD DIAGONAL STEP ;JP TO CORRECT PLOT ROUTINE, THEN TO PRLABEL ;SAVE TRACKING ERROR

DRLOOP:

ADD A,L JR C,TWOMOVE CP H JR C,ONEMOVE

94 4F D9 09 FDE9 4F

TWOMOVE:

SUB H LD C,A EXX ADD HL,BC JP (IY)

ONEMOVE:

LD

C,A

2226 2227 2228 222A 222A 222B 222C 222E 222E 222F 222F 222F 222F 2230 2231 2233 2234 2236 2236 2237 2238 223A 223C 223C 223D 223E 223F 2240 2243 2246 2247 2248 2248 2249 224A 224A 224A 224A 224A 224B 224E 224F 2253 2253 2254 2255 2257 2257 2258 2259 225A 225B 225C 225D 225E 225F 2260 2261 2262 2265 2266 2267 2269 226A 226B 226D 226F 2270 2272 2272 2273 2276 2279 2279 2279 2279 227A 227B 227C 227F 2280 2281 2284 2285 2286 2288 2288 228B 228B 228C 228D 228E 228E 228F 228F 2290 2292 2294 2294 2295 2297 2299 2299

D9 19 FDE9 D9 79 10EB C9 7D 3C FE02 3F 3006 7C 3D FEBE 38EE F5 7C 65 6F 22415A CDC63F F1 D8 CF 20 DRAWEND: PLOTCHK: PRLABEL:

EXX ADD HL,DE JP (IY) EXX LD A,C DJNZ DRLOOP RET LD A,L INC A CP 2 CCF JR NC,DRAWEND LD A,H DEC A CP 190 JR C,PRLABEL

;ADD HORIZ OR VERT MOVE ;JP TO CORRECT PLOT ROUTINE, THEN TO PRLABEL ;GET TRACKING ERROR BACK ;LOOP FOR GREATER AXIS DIFF. OF POINTS ;RETURN WITH HL"=COORDS, DE", BC"=DIR FLAGS

;POST-CHECK ROUTINE USED AFTER PLOT IF LINE WILL RUN OFF-SCREEN

;JR IF X COORD=255 OR 0 ;0->255,191->190 ;STILL OK - SO BACK TO DRAW LOOP

PUSH AF ;SAVE NC IF HIT EDGE LD A,H LD H,L LD L,A LD (YCOORD),HL CALL TRCURP ;TEMPS, RESET PAGE POP AF ;NC IF HIT EDGE, C IF OK RET C RST 08H DB 32 ;"Off screen"

OSERROR:

;THIN PIXEL DRAW ;ENTRY: B=Y DIFF,HL=X DIFF, D=SGN Y, E=SGN X (01/FF) D9 210000 D9 FD217922 7C A7 281B 1F 7D 1F 4F F5 78 A7 1F 47 F5 D5 CDF221 D1 F1 CE00 47 F1 2601 CE00 6F 38E1 4D CDF221 C3C63F C5 D5 EB 3A415A 82 47 2A425A 7B A7 2811 F28E22 04 2B 2B 23 7C FE02 30B4 78 FEC0 30AF CDDC22 TPNCHNG: TPINC: EASYTHIN: THINDRAW: EXX LD HL,0 EXX LD IY,THINDR2 LD A,H AND A JR Z,EASYTHIN RRA LD A,L RRA LD C,A PUSH AF LD A,B AND A RRA LD B,A PUSH AF PUSH DE CALL DRMSUB POP DE POP AF ADC A,0 LD B,A POP AF LD H,1 ADC A,0 LD L,A JR C,DUBT LD C,L CALL DRMSUB JP TRCURP PUSH BC PUSH DE EX DE,HL LD A,(YCOORD) ADD A,D LD B,A LD HL,(XCOORD) LD A,E AND A JR Z,TPNCHNG JP P,TPINC INC B DEC HL DEC HL INC HL LD A,H CP 2 JR NC,OSERROR LD A,B CP 192 JR NC,OSERROR CALL TDPLOT ;ERROR IF X INCED TO 0200H OR DECED TO FFFFH ;COMPENSATE FOR FIDDLED DIR FLAGS ;DEC X ;COMP FOR NEXT INSTR ;HALVE X DIFF ;A=HALF X DIFF ;SAVE HALF X DIFF AND CY IF DIFF IS ODD ;"COORDS"=0

DUBT:

;SAVE HALF Y DIFF AND CY IF DIFF IS ODD ;SGN FLAGS ;Y/2 ;INC IF WAS ODD ;X/2 ;INC IF WAS ODD - COULD NOW BE ZERO IF ORIG=1FF ;JR WITH HL=0100 IF DOUBLE NEEDED AGAIN

;THIN DRAW KEEPS SETTING DRAW"S COORDS IN HL TO 0000, SO HL WILL EQUAL BC OR DE THINDR2:

229C 229F 22A0 22A1 22A4 22A4 22A4 22A4 22A4 22A4 22A4 22A7 22A8 22AA 22AA 22AC 22AC 22AF 22B2 22B2 22B2 22B2 22B5 22B8 22B8 22BA 22BD 22BD 22C0 22C1 22C2 22C5 22C6 22C7 22CA 22CB 22CC 22CD 22D1 22D3 22D3 22D3 22D3 22D3 22D6 22D9 22DC 22DC 22DF 22E0 22E3 22E3 22E5 22E6 22E7 22E8 22E9 22EB 22ED 22EE 22F0 22F1 22F2 22F3 22F5 22F7 22F9 22F9 22FA 22FB 22FD 22FD 22FE 2302 2305 2306 2308 2308 230B 230B 230C 230D 230F 230F 2310 2311 2312 2313 2315 2315 2316 2318 2318 2319 231A 231B 231B 231C 231E 231E 231E 231E 231E

210000 D1 C1 C32A22 ;GRAPH1.SAM ;PLOT.SAM 3A4D5A A7 2013 1827 CDF23A CD153B CD9327 DAD322 1E01 CD6628 CDB13F 61 68 22415A 60 69 CDB423 D9 57 D9 DD21C63F FDE9 JPLOT3: PLOT: JPLOT:

LD HL,0 POP DE POP BC JP PRLABEL INCLUDE GRAPH1.SAM ;DRAW CURVE, PLOT

LD A,(THFATT) AND A JR NZ,JPLOT3 JR THINPLOT CALL SYNTAX9 CALL CHKEND CALL GTFCOORDS JP C,THINPLOT LD E,1 CALL GRAREC CALL SPSS LD H,C LD L,B LD (YCOORD),HL LD H,B LD L,C CALL SETIY EXX LD D,A EXX LD IX,TRCURP JP (IY)

;JR IF FAT

;ENTRY POINT FOR BLITZ PLOTFD: ;CORRECT Y SO 0 AT TOP, 191 AT BOT. CHECK X AND Y ;JR IF THIN PLOT - HL=X, B=Y. ELSE C=X, B=Y ;BLITZ CODE FOR PLOT (FAT) ;SAVE PAGE, SELECT SCREEN ;UPDATE Y COORD AND X COORD LSB ;H=Y WITH 0 AT TOP ;L=X ;INK TO D'

;******************************************************************************* ;THIN PIXEL PLOT. PLOT HL,B. HL CHECKED ALREADY, 00-01FF CDB13F CDDC22 C3C63F 22425A 78 32415A DDE1 E5 D5 C5 7D CB1C CB1D 60 E603 3C 47 37 CB1C CB1D 3EFC 0F 0F 10FC 4F ED5B535A 3A525A 14 2003 3A515A 47 1D 2806 7E A8 A1 A8 1806 15 2030 79 2F AE 77 182A M2TPC: M2TPOV1: M2TPIN0: THINPLOT: TDPLOT: M2CTPLOT: CALL SPSS CALL TDPLOT JP TRCURP LD (XCOORD),HL LD A,B LD (YCOORD),A POP IX PUSH HL PUSH DE PUSH BC LD A,L RR H RR L LD H,B AND 03H INC A LD B,A SCF RR H RR L LD A,0FCH RRCA RRCA DJNZ P80RLP LD C,A LD DE,(OVERT) LD A,(M23INKT) INC D JR NZ,M2TPIN0 LD A,(M23PAPT) LD B,A DEC E JR Z,M2TPOV1 LD A,(HL) XOR B AND C XOR B JR M2TPC DEC D JR NZ,DRPLEND2 LD A,C CPL XOR (HL) LD (HL),A JR DRPLEND2 ;JR IF OVER 1 ;FORCE PIXEL TO INK OR PAPER COLOUR ;E=00/01 FOR OVER 0/1, D=00/FF FOR INVERSE 0/1 ;JR IF INVERSE 0 ;USED BY PLOT ;USED BY DRAW - AVOIDS PAGING SCREEN IN AND OUT ;USED BY CIRCLE - AVOIDS ALTERING COORD VARS. ;A=X ;L=X/2 ;H=Y ;ISOLATE BIT OFFSET ;B COUNTS TIMES TO ROTATE MASK ;HL=Y/2+X/4+8000H=ADDRESS ;BIT MASK

P80RLP:

;DO NOTHING IF INVERSE 1, OVER 1 ;REVERSE PIXEL

;******************************************************************************* ;MODE 0 PLOT - USED BY DRAW. PLOT L,H E5 M0DPLOT: PUSH HL

231F 2320 2321 2322 2323 2326 2327 2329 2329 2329 2329 2329 232A 232B 232C 232F 232F 2331 2332 2332 2333 2335 2335 2335 2335 2335 2335 2335 2336 233A 233B 233C 233E 233E 233F 233F 2340 2342 2342 2343 2344 2344 2345 2348 2348 2349 234A 234B 234D 234D 234D 234D 234D 234D 234D 234E 2350 2352 2353 2354 2356 2356 2357 2359 235A 235B 235C 235D 235F 235F 2360 2362 2363 2364 2365 2366 2367 2369 2369 2369 2369 2369 236A 236C 236E 236F 2370 2371 2373 2373 2375 2376 2377 2378 237A 237A 237C 237D 237E 237F 2380 2380 2382

D5 C5 44 4D CD3B3E 47 1806

PUSH DE PUSH BC LD B,H LD C,L CALL M0PIXAD LD B,A JR M01DPCOM ;****************************************************************************** ;MODE 1 PLOT - USED BY DRAW. PLOT L,H

E5 D5 C5 CD583E 3EFE 04 0F 10FD

M1DPLOT:

PUSH PUSH PUSH CALL

HL DE BC M1PIXAD

;HL=Y/8+X/8+8000H=ADDRESS, B=BIT OFFSET (0-7)

M01DPCOM: DPM2FLP: ;OVER ;OVER ;OVER ;OVER

LD A,0FEH INC B RRCA DJNZ DPM2FLP 0=FORCE PIXEL HIGH 0=REVERSE PIXEL 1=FORCE PIXEL LOW 1=NO EFFECT ;E=0 IF OVER 0, D= 00/FF FOR INVERSE 0/1 ;JR IF OVER 1

0,INVERSE 1,INVERSE 0,INVERSE 1,INVERSE

4F ED5B535A 7E 1D 2801 A1 14 2802 A9 2F 77 CD6C3E C1 D1 E1 DDE9 DRPLEND: DRPLEND2: DYOVER1:

LD C,A LD DE,(OVERT) LD A,(HL) DEC E JR Z,DYOVER1 AND C INC D JR Z,DRPLEND XOR C CPL LD (HL),A CALL POATTR01 POP BC POP DE POP HL JP (IX)

;JR IF INVERSE 1

;CALL ATTR SETTER FOR MODES 0,1

;************************************************************************** ;MODE 2 OR 3 PLOTS FOR DRAW. ALL PLOT H,L ;ENTRY: HL=COORDS (Y,X), IX=RETURN ADDR, D'=INK COLOUR ;OVER 0: 37 CB1C CB1D 7E D9 3809 AA E60F AA D9 77 29 DDE9 AA E6F0 AA D9 77 29 2C DDE9 M3DPOV0: SCF RR H RR L LD A,(HL) EXX JR C,M3DPOV0OD XOR D AND 0FH XOR D EXX LD (HL),A ADD HL,HL JP (IX) M3DPOV0OD: XOR D AND 0F0H XOR D EXX LD (HL),A ADD HL,HL INC L JP (IX) ;HL=Y/2+X/2+8000H=ADDR

;RESTORE HL

;RESTORE HL

;MODE 2 OR 3 ROUTINE FOR OVER 1 - XOR INK WITH WHAT IS THERE ALREADY ;HL=Y/X, D'=INK 37 CB1C CB1D D9 7A D9 3807 E6F0 AE 77 29 DDE9 E60F AE 77 29 2C DDE9 M3DPOV1: SCF RR H RR L EXX LD A,D EXX JR C,M3DPOV1OD AND 0F0H XOR (HL) LD (HL),A ADD HL,HL JP (IX) M3DPOV1OD: AND 0FH XOR (HL) LD (HL),A ADD HL,HL INC L M3DPNUL: JP (IX) ;HL=Y/2+X/2+8000H=ADDR ;JR IF ODD PIXEL ;NO EFFECT ON RHS BITS (ODD PIX) ;RESTORE HL ;NO EFFECT ON LHS BITS (EVEN PIX) ;RESTORE HL ;INVERSE 1, OVER 1 ROUTINE DOES NOTHING

2382 2382 2382 2382 2383 2385 2387 2388 2389 238A 238C 238C 238E 238F 2390 2391 2393 2393 2395 2396 2397 2398 2399 239B 239B 239B 239B 239B 239C 239E 23A0 23A1 23A2 23A3 23A5 23A5 23A7 23A8 23A9 23AA 23AC 23AC 23AE 23AF 23B0 23B1 23B2 23B4 23B4 23B4 23B4 23B4 23B4 23B7 23B8 23BB 23BD 23BD 23C1 23C2 23C3 23C3 23C7 23C8 23C9 23C9 23CA 23CC 23CC 23CF 23D0 23D1 23D2 23D2 23D5 23D9 23DA 23DC 23DC 23DD 23DF 23DF 23E3 23E4 23E6 23E6 23EA 23EA 23ED 23EE 23EE 23F1 23F2 23F2 23F5 23F6 23F6 23F6 23F6 23FA 23FD 23FE 2400

;MODE 2 OR 3 ROUTINE FOR OVER 2 - OR INK WITH WHAT'S THERE ALREADY ;HL=Y/X, D'=INK 37 CB1C CB1D D9 7A D9 3807 E6F0 B6 77 29 DDE9 E60F B6 77 29 2C DDE9 M3DPOV2: SCF RR H RR L EXX LD A,D EXX JR C,M3DPOV2OD AND 0F0H OR (HL) LD (HL),A ADD HL,HL JP (IX) M3DPOV2OD: AND 0FH OR (HL) LD (HL),A ADD HL,HL INC L JP (IX) ;HL=Y/2+X/2+8000H=ADDR ;FETCH INK ;JR IF ODD PIXEL ;NO EFFECT ON RHS BITS (ODD PIX) ;OR INK WITH SCREEN ;RESTORE HL

;RESTORE HL

;MODE 2 OR 3 ROUTINE FOR OVER 3 - 'AND' INK WITH WHAT'S THERE ALREADY ;HL=Y/X, D'=INK 37 CB1C CB1D D9 7A D9 3807 F60F A6 77 29 DDE9 F6F0 A6 77 29 2C DDE9 M3DPOV3: SCF RR H RR L EXX LD A,D EXX JR C,M3DPOV3OD OR 0FH AND (HL) LD (HL),A ADD HL,HL JP (IX) M3DPOV3OD: OR 0F0H AND (HL) LD (HL),A ADD HL,HL INC L JP (IX) ;HL=Y/2+X/2+8000H=ADDR ;FETCH INK ;JR IF ODD PIXEL ;SO NO EFFECT ON RHS BITS (ODD PIX) ;AND INK WITH SCREEN ;RESTORE HL

;RESTORE HL

;******************************************************************************* ;SET IY TO APPROPRIATE PLOT ROUTINE. A=INK TO USE IF MODE 2 OR 3. CY IF MODE 2 ;THIN PLOT, IY NOT SET 3ADD5A A7 3A405A 2048 FD211E23 A7 C8 FD212923 3D C8 3D 2006 3A4D5A A7 37 C8 3A555A FD214D23 A7 280E 3D 2817 FD218223 3D 2804 FD219B23 3A545A A7 3A525A C8 3A515A C9 ;OVER 1 FD216923 3A545A A7 28EE STIY5: LD IY,M3DPOV1 LD A,(INVERT) AND A JR Z,STIY4 ;ROUTINE TO XOR INK WITH SCREEN ;XOR INK TO SCREEN IF OVER 1,INVERSE 0 STIY3: STIY4: STIY1: SETIY: LD A,(SETIYV+1) AND A LD A,(MODE) JR NZ,STIY6 LD IY,M0DPLOT AND A RET Z LD IY,M1DPLOT DEC A RET Z DEC A JR NZ,STIY1 LD A,(THFATT) AND A SCF RET Z LD A,(GOVERT) LD IY,M3DPOV0 AND A JR Z,STIY3 DEC A JR Z,STIY5 LD IY,M3DPOV2 DEC A JR Z,STIY3 LD IY,M3DPOV3 LD A,(INVERT) AND A LD A,(M23INKT) RET Z LD A,(M23PAPT) RET ;RET WITH A=INK IF INVERSE 0 ;ELSE A=PAPER ;RET IF MODE 0 ;RET IF MODE 1 ;JR IF NOT MODE 2 ;'THIN PLOT' ;RET IF THIN PLOT, ELSE USE M2/M3 ROUTINES

;JR IF OVER 0 ;JR IF OVER 1 ;ORING ROUTINE ;JR IF OVER 2 ;ANDING ROUTINE

2400 2404 2405 2405 2405 2406 2409 240C 240D 240E 240F 240F 240F 240F 240F 240F 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 241B 241D 241D 241F 2421 2421 2422 2423 2424 2424 2426 2426 2427 2428 2429 242A 242D 2430 2431 2433 2434 2435 2436 2437 2439 2439 243A 243B 243B 243E 243F 2441 2441 2442 2445 2447 2447 2448 244A 244A 244D 244E 244E 2451 2453 2455 2455 2456 2458 2458 2459 245B 245B 245C 245E 245E 245F 2461 2461 2462 2464 2465 2467 2469 2469 246A 246D 246F 2471 2471 2472 2475 2478 2479 247B 247C 247D

FD218023 C9 E5 2ADC5A CD0500 E1 A7 C9 ;VECTORED STIY6:

LD IY,M3DPNUL RET PUSH HL LD HL,(SETIYV) CALL HLJUMP POP HL AND A RET

;DO NOTHING IF INVERSE 1,OVER 1

;NC - NO THIN PIX ;BLITZ, FILL, TRANSCR, CRDFID

INCLUDE GRAPH2.SAM ;GRAPH2.SAM ;BLITZ MAIN LOOP EB D5 E5 7E 5F 23 56 23 46 3C FE02 386B D604 2003 23 7E 37 302F 08 AF 5F 4B CDF01C 3A5C5A 57 3EBF 90 92 57 7B 3002 1D 0D CDF01C 08 2006 4F CD7D20 1854 3C 2004 CD4721 BF C4B222 0E03 1848 3D 2827 3D 2816 3D 280B 3D 206C 4A 0600 F7 0EF0 181B 7A CDAE06 0E02 182C 7A 32525A 214E5A AE E607 AE 77 1805 FDPAU: FDPLOT: FDATTRS: FDNTRAD: FDPOS: FDNTCIR: FDMAINLP: EX DE,HL PUSH DE PUSH HL LD A,(HL) LD E,A INC HL LD D,(HL) INC HL LD B,(HL) INC A CP 2 JR C,DRCL SUB 4 JR NZ,FDNTCIR INC HL LD A,(HL) SCF JR NC,FDATTRS EX AF,AF' XOR A LD E,A LD C,E CALL STKSTORE LD A,(ORGOFF) LD D,A LD A,191 SUB B SUB D LD D,A LD A,E JR NC,FDPOS DEC E DEC C CALL STKSTORE EX AF,AF' JR NZ,FDNTRAD LD C,A CALL CIRCLEFD JR MNLP4B INC A JR NZ,FDPLOT CALL DRAWTOFD CP A CALL NZ,PLOTFD LD C,3 JR MAINLPH DEC A JR Z,FDOVER DEC A JR Z,FDINK DEC A JR Z,FDCLS DEC A JR NZ,FDINVERR LD C,D LD B,0 RST 30H DW PAU1 JR FD1PARAM LD A,D CALL CLSBL LD C,2 JR MAINLPH LD A,D LD (M23INKT),A LD HL,ATTRT XOR (HL) AND 07H XOR (HL) LD (HL),A JR FD1PARAM

;LENGTH ;POSN ;SGN X OR CMD CODE ;ABS X OR SINGLE PARAM ;SGN Y, OR ABS Y IF PLOT/DRAW TO/CIRCLE ;SGN=00 OR 01, PLOT CODE=02, DRAW TO=03 ;JR IF 00 OR 01 (REL. DRAW) ;2-> -2 (PLOT), 3-> -1 (DRAWTO), 4->0 (CIRCLE) ;JR IF CMD WAS NOT CIRCLE ;GET RADIUS ;JR IF 5 OR MORE (CODE NOW 1 OR MORE) ;SAVE RADIUS AND Z FLAG, OR NZ AND -1/-2 (DTO/PLT) ;'INTEGER' ;E (SGN) =00 (POS) ;MSB=00 ;STACK AEDC - 00 00 X 00. ;A=Y WITH 191 AT TOP, 0 AT BOT ;SUB ORGOFF ;A=0 ;SGN=-VE ** ;MSB=FF ;STACK AEDC - 00 SGN ;RADIUS Y 00

;DRAW TO COORDS ON FPCS ;SET Z ;PLOT THE COORDS ON FPC STACK

;** BLITZ PAUSE BUG FIX

FDCLS:

;CLEAR WINDOW OR ALL SCREEN

FDINK:

247F 247F 2480 2481 2484 2484 2486 2488 2488 2489 248A 248A 248B 248C 248D 2490 2491 2492 2493 2494 2495 2498 249B 249B 249D 249D 249E 249F 24A0 24A1 24A2 24A3 24A6 24A7 24A8 24A8 24AA 24AD 24AD 24AE 24B1 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B2 24B5 24B5 24B8 24B8 24B9 24BA 24BD 24BE 24BF 24C2 24C3 24C4 24C5 24C6 24C7 24C8 24CB 24CB 24CD 24CD 24CE 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24CF 24D2 24D3 24D5 24D8 24DA 24DA 24DC 24DE 24DE 24E1

7A 23 32555A 0E02 1815 23 7E 08 AF 4B CDF01C 08 58 57 AF 4B CDF01C CD9321 0E04 AF 47 E1 09 7C 3C CCF23F EB E1 ED42 D20F24 F1 32815B C9

FDOVER: FD1PARAM: DRCL:

LD A,D INC HL LD (GOVERT),A LD C,2 JR MAINLPH INC HL LD A,(HL) EX AF,AF' XOR A LD C,E CALL STKSTORE EX AF,AF' LD E,B LD D,A XOR A LD C,E CALL STKSTORE CALL DRAWFD ;ABS Y . NOW E/D=SGN X/X, B/A=SGN Y,Y ;(SGN=00 OR FF) ;SAVE Y ;'INTEGER' ;MSB MATCHES SGN ;STACK AEDC

;STACK AEDC

MNLP4B: MAINLPH:

LD C,4 XOR A LD B,A POP HL ADD HL,BC LD A,H INC A CALL Z,INCURPAGE EX DE,HL POP HL SBC HL,BC JP NC,FDMAINLP POP AF LD (GRARF),A RET ;POSN ;ADVANCE POSN, NC ;ONLY IF ADDR IS FFXX IS THERE A NEED TO INC PAGE ;LENGTH ;SUB BYTES PROCESSED IN LAST GRAPHICS CMD ;JR TILL PAST END

FDLNTST:

;FAST DRAW AND PLOT COMPILER (DRAW A STRING) ;STRING HAS EITHER: ; ; ; ; ; ; ; ; CD663A CDDC3F D5 C5 CDD211 C1 D1 21815B 7E F5 AF 77 60 69 010100 18DB CF 23 FDINVERR: JBLITZ: SGN 01, 02, 03, 04, 05, 06, 07, X (00/FF), X, SGN Y (00/FF), Y X, Y - PLOT X, Y - DRAW TO X,Y,R - CIRCLE O - OVER O I - INK I C - CLS C (IF C=0, CLEAR ENTIRE SCREEN. IF 1, CLEAR WINDOW) N - PAUSE N CALL SYNTAXA CALL GETSTRING PUSH DE PUSH BC CALL GRATEMPS POP BC POP DE LD HL,GRARF LD A,(HL) PUSH AF XOR A LD (HL),A LD H,B LD L,C LD BC,1 JR FDLNTST RST 08H DB 35 ;INVALID BLITZ CODE ;DE=START, BC=LEN, PAGED IN

BLITZ:

;NC ;GR. RECORD OFF, BUT CURRENT STATUS REPLACED AT END ;HL=LENGTH, DE=POSN ;AT START,SUB 1 FROM LEN, EXIT IF LEN WAS 0. ALSO ;ALLOWS LATER LEN TEST TO BE ON CY/NC, NOT CY+Z

;FILL.SAM ;*************************************************************************** ;TEXTURED FILL COMMAND ; EG FILL X,Y ;USES CURRENT INK ; EG FILL USING A$,X,Y ;USES INKS CODED IN PATTERN STRING ; EG FILL INK 3,X,Y ; EG FILL USING A$,INK 3,X,Y GIVES SOLID FILL, IGNORES A$ ;FROM JUMP TABLE: ;IF DE=0 DO SOLID FILL. ELSE USE 128 BYTES FROM DE AS PATTERN. IF A=0 MAKE ;CHECK SCREEN. 22C85A C5 0601 32CE5A 1842 FE85 2007 CDA03A CD813A JFILL: LD (TEMPW1),HL PUSH BC LD B,1 LD (TEMPB1),A JR JFILL2 CP USINGTOK JR NZ,PASTUSNG CALL SEXPTSTR CALL INSISCSC ;REQUIRE COMMA OR SEMICOLON ;BYTE OFFSET IF MODE 2 ;START COORDS ;USE 128 BYTES SINCE BC<>131

FILL:

24E4 24E5 24E5 24E8 24E8 24EB 24ED 24EF 24EF 24F2 24F2 24F2 24F5 24F8 24FA 24FA 24FD 24FE 24FE 2501 2504 2505 2507 2509 2509 250A 250C 250D 250E 2510 2513 2514 2516 2517 2518 2518 2519 251C 251C 251F 2520 2521 2523 2523 2526 2527 2528 2529 252A 252D 252F 252F 2530 2531 2533 2533 2534 2536 2538 2538 2538 2539 253A 253B 253B 253C 253F 253F 2541 2541 2544 2547 2548 2549 254A 254D 254D 254E 2552 2555 2558 255C 255F 255F 2561 2562 2563 2563 2564 2565 2567 2568 2568 256A 256C 256C 256C 256D 256E 2570 2571 2573 2574

BF C4FC3A CDF23A FE2C 200B CD573A 111E02 CD621F 1804 CD153B AF 32D05A CD9512 F7 C8E9 300F 7D CB1C 1F 1F E67E 32C85A 7D E607 81 4F C5 CDDC3F 218050 7A B3 200C 3A525A 77 54 5D 13 017F00 1810 78 A7 2008 79 FE83 2003 13 13 13 EB 018000 EDB0 CDB13F 3AD05A A7 E1 E5 CCA826 C1 ED73CC5A 31B0FE CD5F25 ED7BCC5A C3C63F 3EFE F5 C5 C1 78 FEFE C8 FEC0 30F7 69 1F CB1D 1F CB1D 1F CB1D FILLMN: UNSTK: DEFPAT1: SOLIDEN: DEFPAT: FILLX4: JFILL2: FCKE: FSCY: PASTUSNG:

CP A CALL SYNTAX9 CP "," JR NZ,FCKE CALL SSYNTAX6 LD DE,0200H+30 CALL LIMBYTE JR FSCY CALL CHKEND XOR A LD (TEMPB3),A CALL CHKMD23 RST 30H DW CIFILSR JR NC,FILLX4 LD A,L RR H RRA RRA AND 7EH LD (TEMPW1),A LD A,L AND 7 ADD A,C LD C,A PUSH BC CALL GETSTRING LD LD OR JR HL,FILBUFF A,D E NZ,DEFPAT

;SET ZERO FLAG ;CHECK FOR COLOURS, X,Y ;0 OR DEFAULT MEANS 'COPY TO CHK SCRN', 1 MEANS ;'SUPRESS COPYING' ;ACCEPT 0 OR 1 ONLY

CALL NZ,CONDSTK0 ;STACK 0 IF NO 'USING' AND RUNNING

;INSIST ON MODE 2 OR 3 ;COORDS TO BC, OFFSET IF MODE 2 TO TEMPW1 ;JR IF MODE 3 ELSE HL=PIX OFFSET

;A=OFFSET/4 (BYTE) ;OFFSET 0,2,4 ETC

;COORDS TO START AT ;SWITCHES IT IN, GETS DE=START, BC=LEN (<4000) ;STORES PATTERN

LD A,(M23INKT) LD (HL),A LD D,H LD E,L INC DE LD BC,127 JR SOLIDEN LD A,B AND A JR NZ,DEFPAT1 LD A,C CP 131 JR NZ,DEFPAT1 INC DE INC DE INC DE EX DE,HL LD BC,128 LDIR CALL SPSS LD A,(TEMPB3) AND A POP HL PUSH HL CALL Z,TRANSCR POP BC LD (TEMPW3),SP LD SP,FILLSTK CALL FILLMN LD SP,(TEMPW3) JP TRCURP LD A,0FEH PUSH AF PUSH BC POP BC LD A,B CP 0FEH RET Z CP JR 0C0H NC,UNSTK

;IF NO 'USING', USE SOLID CURRENT INK ;STRING START OF 0 MEANS USE SOLID PATTERN ;DE=BUFFER START+1 ;BUFFER WILL BE FILLED WITH SOLID INK

;JR IF LEN NOT THAT OF A 2*2 GET BLOCK ;(CONTROL CODE, WIDTH, LENGTH, 128 BYTES) ;POINT TO DATA

;COPY STRING TO BUFFER ;SAVE PAGE,SELECT SCREEN (NO USE OF HL) ;START COORDS ;NOW COPY SCREEN TO CHECK SCREEN ;START COORDS ;END OF SCREEN GIVES MORE SPACE FOR STACK ;RESET PAGE AND TEMP COLOURS ;STOPPER TO STACK, START COORDS TO HL ;START COORDS

;EXIT IF STOPPER ;LOOP IF OFF-SCREEN (FF IF TOO LOW, B0 IF TOO HI) ;CARRY ALWAYS SET HERE ;NOW GET CHK SCREEN ADDRESS FROM COORDS ;A=B

LD L,C RRA RR L RRA RR L RRA RR L

2576 2578 2579 2579 257A 257C 257D 257E 2580 2580 2581 2582 2584 2584 2585 2586 2588 2588 2589 258B 258B 258D 258E 258F 2591 2591 2592 2593 2595 2595 2596 2598 2598 2599 2599 259B 259D 259D 259E 259E 25A1 25A2 25A4 25A7 25A9 25AB 25AB 25AD 25AD 25AE 25AF 25AF 25B0 25B1 25B2 25B3 25B4 25B5 25B7 25B8 25BA 25BB 25BB 25BD 25BD 25BE 25C0 25C0 25C2 25C5 25C5 25C8 25C9 25CA 25CC 25CC 25CD 25CE 25CF 25D0 25D0 25D1 25D2 25D3 25D4 25D5 25D5 25D6 25D8 25D8 25D9 25DA 25DC 25DC 25DD 25DF 25E1 25E1 25E3 25E5 25E5 25E7 25E9

F6E0 67 79 E607 5F 1C 3E01 0F 1D 20FC 57 A6 20DB A6 200D CB02 0D 7A 30F7 2D 0C 2804 0D 18F0 0C CB0A 3001 2C 22CA5A E5 DDE1 3A405A D603 2802 3E80 5F C5 D9 C1 78 87 87 87 F680 4F 2650 D9 1808 0C 28A3 CB0A DC3E26 2ACA5A 7A A6 2097 7A B6 77 78 D9 37 1F 57 D9 79 CB7B D9 1F 2009 5F 060F 3024 06F0 1820 CB2F E6BF 5F FILLM2: FILLC: FILLB: FILLFLGS: NBACK: FOUNDEDG: FOUNDEDG1: FINDEDG: FRTMASK:

OR 0E0H LD H,A LD A,C AND 07H LD E,A INC E LD A,01H RRCA DEC E JR NZ,FRTMASK LD AND JR AND JR D,A (HL) NZ,UNSTK (HL) NZ,FOUNDEDG

;HL=Y/8+X/8+FILL CHK SCRN (MUST BE ON 8K PAGE) ;BIT OFFSET

;JR IF POINT IS FILLED ALREADY

RLC D DEC C LD A,D JR NC,FINDEDG DEC L INC C JR Z,FOUNDEDG1 DEC C JR FINDEDG INC C RRC JR INC D NC,NBACK L

;MOVE BIT MASK LEFT - CARRY IF OVERFLOW ;MOVE X COORD LEFT ;JR UNLESS NEED TO ALTER ADDR ;1 BYTE LEFT ;JR IF WE FELL OFF LHS SCREEN EDGE

;MAKE CURRENT POSN ONE ; PIXEL RIGHT OF BLOCKAGE ;JR IF NO ADDRESS CHANGE NEEDED

LD (TEMPW2),HL PUSH HL POP IX LD A,(MODE) SUB 3 JR Z,FILLFLGS LD A,80H LD E,A PUSH BC

;POSN ALSO IN IX

;INIT FLAGS. BIT 7=1 IF MODE 2 ;XY

EXX POP BC LD A,B ;A=Y ADD A,A ADD A,A ADD A,A OR 80H ;A=80-F8 (8*Y MOD 16) LD C,A LD H,FILBUFF/256 EXX JR FILLC ;JP IF X COORD PAST RHS ;ROTATE MASK ;CALL IF TIME TO MOVE 1 BYTE RIGHT INC C JR Z,UNSTK RRC D CALL C,MVRGT LD LD AND JR

HL,(TEMPW2) A,D (HL) NZ,UNSTK ;JR IF PIXEL FILLED ;ELSE ;FILL ;PIXEL IN CHECK SCREEN ;Y

LD A,D OR (HL) LD (HL),A LD A,B EXX SCF RRA LD D,A EXX LD A,C BIT 7,E EXX RRA JR NZ,FILLM2 LD E,A LD B,0FH JR NC,FILLOEC LD B,0F0H JR FILLOEC SRA A AND 0BFH LD E,A

;X COORD

;JR IF MODE 2 (NZ SET BY BIT 7,E) ;DE'=REAL SCREEN ADDR ;JR IF EVEN X COORD

;KEEP BIT 7 THE SAME ;1011 1111. BIT 7 FROM Y IS KEPT, BITS 5-0=X/4

25EA 25ED 25EE 25EF 25F0 25F0 25F1 25F1 25F2 25F4 25F6 25F8 25F8 25FA 25FB 25FD 25FD 25FF 2600 2602 2602 2604 2604 2605 2605 2607 2608 2609 260A 260B 260C 260D 260E 260F 260F 2612 2614 2616 2616 2617 2619 2619 261A 261B 261C 261E 2620 2620 2621 2623 2623 2625 2625 2628 262A 262C 262C 262D 262F 262F 2630 2631 2632 2634 2636 2636 2637 2639 2639 263B 263B 263E 263E 263E 263E 263E 2642 2644 2648 2648 264B 264D 264F 264F 2650 2652 2652 2653 2653 2654 2655 2655 2658 2658 265A 265C 265C 265D 265F 265F 2660 2660 2661

3AC85A 83 5F D9 79 D9 063F E603 280C 06CF 3D 2807 06F3 3D 2802 06FC 7B E607 B1 6F 1A AE A0 AE 12 D9 DD7EE0 CB43 200A A2 200C 05 C5 04 CBC3 1805 A2 2802 CB83 DD7E20 CB4B 200A A2 208E 04 C5 05 CBCB 1887 A2 2802 CB8B C3BD25 FILBH: FILLG: FILLF: FILLE: FILLM2M: FILLOEC:

LD A,(TEMPW1) ADD A,E LD E,A EXX LD A,C EXX LD B,3FH AND 3 JR Z,FILLM2M LD B,0CFH DEC A JR Z,FILLM2M LD B,0F3H DEC A JR Z,FILLM2M LD B,0FCH LD A,E AND 07H OR C LD L,A LD A,(DE) XOR (HL) AND B XOR (HL) LD (DE),A EXX LD BIT JR AND JR DEC PUSH INC SET JR AND JR RES LD BIT JR AND JR INC PUSH DEC SET JR AND JR RES JP A,(IX-32) 0,E NZ,FILLE D NZ,FILLF B BC B 0,E FILLF D Z,FILLF 0,E A,(IX+32) 1,E NZ,FILLG D NZ,FILLB B BC B 1,E FILLB D Z,FILBH 1,E FILLB

;OFFSET FROM LHS ;DE'=REAL SCREEN ADDR ;X COORD ;MASK FOR BITS TO ZERO

;A=PHYSICAL SCREEN COLUMN MOD 8 ;GET BITS DETERMINED BY Y COORD ;HL' IS NOW COMPLETE FILBUFF ADDR ;MIX BITS FROM FILBUFF PATTERN AND SCREEN ; ACCORDING TO MASK B ;A=BYTE ABOVE

;JR IF BIT FILLED ;GET Y OF LOCATION ABOVE ;SAVE COORDS OF PLACE ABOVE ;'ABOVE IS FILLED' ;JR IF ABOVE NOT FILLED ;'ABOVE NOT FILLED' ;GET BYTE BELOW

;JR IF BELOW IS FILLED ;INC Y ;SAVE COORDS OF PLACE BELOW ;'BELOW IS FILLED' ;JR IF NOT FILLED BELOW ;'BELOW IS NOT FILLED'

;***************************************************************************** ;FILL SR MOVE RIGHT DD2ACA5A DD23 DD22CA5A DD7E20 CB4B 2004 3C 2803 C9 A7 C0 DD7EE0 CB43 2004 3C 2803 C9 A7 C0 MVRGT3: MVRGT1: MVRGT2: MVRGT: LD INC LD LD BIT JR INC JR RET AND RET LD BIT JR INC JR RET AND RET A NZ A NZ A,(IX-32) 0,E NZ,MVRGT3 A Z,MVRGT4 IX,(TEMPW2) IX (TEMPW2),IX A,(IX+32) 1,E NZ,MVRGT1 A Z,MVRGT2 ;MOVE 1 COL RIGHT IN CHECK SCREEN ;BYTE BELOW

2662 2662 2665 2666 2667 2668 2668 266A 266A 266B 266B 266C 266D 266E 266F 2670 2670 2671 2672 2674 2674 2675 2676 2678 2678 267A 267C 267D 2680 2681 2681 2682 2684 2685 2686 2688 2688 2689 268B 268C 268D 268D 268E 268F 2690 2691 2691 2692 2693 2694 2695 2695 2696 2697 2698 2699 2699 269A 269B 269C 269C 269D 269F 26A1 26A1 26A2 26A4 26A4 26A5 26A8 26A8 26A8 26A8 26A8 26A8 26A8 26A8 26A8 26A8 26A9 26AA 26AC 26AE 26B1 26B3 26B5 26B5 26B6 26B8 26BA 26BB 26BE 26BF 26C0 26C1 26C3 26C4 26C5 26C6 26C6 26C7 26C8 26CA

2ACA5A 7E A7 C0 36FF 78 D9 37 1F 57 D9 79 3C CB7B D9 1F 2810 CB2F E6BF 5F 3AC85A 83 5F E607 B1 6F 180D 5F E607 B1 6F 7E 12 1C 2C 7E 12 1C 2C 7E 12 1C 2C 7E 12 D9 79 C608 2803 4F 189A E1 C36325

MVRGT4:

LD LD AND RET LD

HL,(TEMPW2) A,(HL) A NZ ;RET IF NOT SIMPLE BLANK IN CHK SCREEN (HL),0FFH ;ELSE FILL 8 PIX AT ONCE

LD A,B EXX SCF RRA LD D,A EXX LD A,C INC A BIT 7,E EXX RRA JR Z,FILLM3B SRA A AND 0BFH LD E,A LD A,(TEMPW1) ADD A,E LD E,A AND 07H OR C LD L,A JR FILLBC FILLM3B: LD E,A AND 07H OR C LD L,A LD A,(HL) LD (DE),A INC E INC L LD A,(HL) LD (DE),A INC E INC L FILLBC: LD A,(HL) LD (DE),A INC E INC L LD A,(HL) LD (DE),A EXX LD A,C ADD A,8 JR Z,MVRGT5 LD JR MVRGT5: POP JP C,A MVRGT HL UNSTK ;JUNK RET ADDR ;COPY 8 PIXELS ;KEEP BIT 7 THE SAME ;1011 1111. BIT 7 FROM Y IS KEPT, BITS 5-0=X/4 ;OFFSET FROM LHS ;DE'=REAL SCREEN ADDR ;A=PHYSICAL SCREEN COLUMN MOD 8 ;GET BITS DETERMINED BY Y COORD ;HL' IS NOW COMPLETE FILBUFF ADDR ;COPY 2 BYTES FROM PATTERN IN MODE 2 ;DE'=REAL SCREEN ADDR ;A=PHYSICAL SCREEN COLUMN MOD 8 ;GET BITS DETERMINED BY Y COORD ;HL' IS NOW COMPLETE FILBUFF ADDR ;COPY 4 BYTES FROM FILLBUF PATTERN IN M3 ;X ;MOVE RIGHT ONTO 1ST. PIXEL OF 8-PIX BLOCK

;JR IF AT RHS OF SCREEN

;******************************************************************************* ;TRANSCR - COPY MODE 3 SCREEN TO CHECK SCREEN (8000-DFFF -> E000-F800) ; OR - COPY PART OF MODE 2 SCREEN TO CHECK SCREEN ;SET BITS IN CHECK SCREEN THAT DON'T MATCH FILL ORIGIN COLOUR ;ENTRY: HL=COORDS OF FILL ORIGIN ;TRANSODD ALSO USED AS ENTRY BY COPY, WITH A=BACKGROUND COLOUR ;USES HL,DE,BC,HL',DE',BC' 37 4D CB1C CB1D 3A405A FE03 2817 7D CB2F E6BF 6F 3AC85A 85 6F 79 E603 3C 47 7E 07 07 10FC TRAM2RLP: TRANSCR: SCF LD C,L RR H RR L LD A,(MODE) CP 3 JR Z,TRANSL1 LD A,L SRA A AND 0BFH LD L,A LD A,(TEMPW1) ADD A,L LD L,A LD A,C AND 3 INC A LD B,A LD A,(HL) RLCA RLCA DJNZ TRAM2RLP ;X

;KEEP BIT 7 THE SAME ;1011 1111. BIT 7 FROM Y IS KEPT, BITS 5-0=X/4 ;OFFSET FROM LHS ;HL=M2 SCREEN ADDR ;X

26CA 26CC 26CC 26CD 26CF 26D1 26D1 26D2 26D3 26D4 26D5 26D5 26D5 26D5 26D6 26D9 26DC 26DD 26DD 26E0 26E0 26E2 26E3 26E4 26E5 26E6 26E7 26E8 26EB 26ED 26EF 26EF 26F2 26F3 26F4 26F6 26F7 26F7 26F8 26F8 26F9 26F9 26FB 26FB 26FC 26FD 26FF 26FF 2700 2701 2702 2703 2705 2706 2708 270A 270C 270C 270D 270E 270F 2711 2711 2712 2713 2714 2715 2717 2717 2718 271B 271C 271D 271D 271E 2720 2720 2721 2721 2722 2722 2724 2725 2725 2726 2726 2727 2728 2728 2729 272B 272C 272D 272F 2730 2731 2733 2734 2735 2737 273A 273A 273B

1809 7E CB41 2004 07 07 07 07 D9 2100E0 1120C0 D9 210080 E60F 57 07 07 07 07 5F 3A405A FE03 2833 3AC85A 6F 7A E603 57 D9 4B 0602 D9 5E 0604 7B 07 07 5F E603 92 FE01 CB11 10F3 23 79 D9 10EA 2F 77 23 0D 20E2 D9 014000 09 D9 15 20D8 D9 C9 0601 D9 4B D9 48 7E E6F0 93 B8 CB11 7E 23 E60F 92 B8 CB11 D22827 79 2F TRANSM3: TRANSDLP: TRANSCLP: TRANSBLP: TRAM2DLP: TRAM2CLP: TRAM2OLP: TRAM2ILP: CHARCOMP2: TRANSODD: TRANSL1:

JR TRANSODD LD A,(HL) BIT 0,C JR NZ,TRANSODD RLCA RLCA RLCA RLCA ;ENTRY USED BY MODE 2/3 SCREEN DUMP WITH A=BACKGROUND COLOUR EXX LD HL,0E000H LD DE,0C020H EXX LD HL,8000H AND 0FH LD D,A RLCA RLCA RLCA RLCA LD E,A LD A,(MODE) CP 3 JR Z,TRANSM3 LD A,(TEMPW1) LD L,A LD A,D AND 3 LD D,A EXX LD C,E LD B,2 EXX LD E,(HL) LD B,4 LD A,E RLCA RLCA LD E,A AND 3 SUB D CP 1 RL C DJNZ TRAM2ILP INC HL LD A,C EXX DJNZ TRAM2OLP CPL LD (HL),A INC HL DEC C JR NZ,TRAM2CLP EXX LD BC,64 ADD HL,BC EXX DEC D JR NZ,TRAM2DLP EXX RET LD B,1 EXX LD C,E EXX LD C,B LD A,(HL) AND 0F0H SUB E CP B RL C LD A,(HL) INC HL AND 0FH SUB D CP B RL C JP NC,TRANSBLP LD A,C CPL ;CP WITH THIS TO SET CY IF A=0 ;RELOAD BYTES/SCAN COUNTER C' ;C=1. CY WHEN BIT ROTATED OUT AFTER 8 ROTS. ;GET A=ZERO IF PIXEL MATCHES ORIGIN INK ;SET CARRY IF A=0 ;E=DATA FROM M2 SCRN ;4 DOUBLE BITS/BYTE ;RELOAD BYTES/SCAN COUNTER C' ;HL' IS DEST SCREEN PTR FOR FILL CHECKING ;D'=192 SCANS, E'=32 BYTES/SCAN IN CHECK SCREEN ;REAL SCREEN START ;GET COLOUR TO SET TO ZEROS IN CHECK SCREEN

;GET DESIRED INK IN MS NIBBLE

;OFFSET REAL SCREEN ADDR

;BITS IN C SHOW IF PIXEL IN M2 SCRN IS 'INK' ;NEXT M2 SCREEN BYTE ;GET DATA IN CASE THIS IS SECOND BYTE ;DO 2 (B') M2 SCREEN BYTES/CHECK SCREEN BYTE ;PIX THAT MATCH ORIGIN=0 ;DO REQUIRED BYTES ACROSS (1 OR 32) ;DROP TO NEXT SCAN IF FILL, IRREL IF CHARCOMP ;DO D' SCANS

;PIX THAT MATCH ORIGIN=0

273C 273C 273D 273E 273F 2740 2742 2742 2743 2745 2745 2746 2747 2747 2747 2747 2747 2747 2747 2748 274B 274C 274D 274F 274F 2750 2752 2752 2753 2754 2756 2756 2759 275B 275C 275E 275E 275F 2760 2760 2761 2762 2762 2763 2764 2765 2765 2765 2765 2766 2769 276A 276C 276C 276D 276E 2771 2771 2772 2773 2776 2776 2779 277A 277B 277D 277E 2780 2780 2781 2781 2782 2783 2784 2786 2786 2789 2789 2789 2789 2789 2789 2789 2789 278C 278D 278D 278F 2791 2792 2793 2793 2793 2793 2796 2796 2796 2796 2796 2796 2796 2796 2796

D9 77 23 0D 20E4 15 20E0 D9 C9

EXX LD (HL),A INC HL DEC C JR NZ,TRANSCLP DEC D JR NZ,TRANSDLP EXX RET

;MOVE TO CHECK SCREEN AT (HL') ;DO C' BYTES/SCAN IN CHECK SCREEN ;AND D' SCANS

;******************************************************************************* ;THIS ROUTINE USED BY SCREEN$ TO COMPRESS A MODE 2/3 CHARACTER TO STANDARD FORM ;IN SCRNBUF. ENTRY: HL PTS TO POSN IN M2/3 SCREEN, DE PTS TO 8-BYTE BUFFER, ;CY=6-BIT CHARS, NZ/Z=ODD/EVEN. USES AF,HL,DE,BC,HL',DE',BC' F5 CDA83F F1 D5 3007 7E 280E 0F 0F 180C 3A405A FE02 7E 2802 07 07 07 07 D9 E1 37 47 D4A83F 78 0608 C5 F5 110101 D9 E5 22C85A CDE026 E1 7D C680 6F 3001 24 D9 F1 C1 10E6 C3BF3F CHARCNINC: CHCM3: CHCM4: CHCM2: CHARCOMP: PUSH AF CALL SPSSR POP AF PUSH DE JR NC,CHCM2 LD A,(HL) JR Z,CHCM3 RRCA RRCA JR CHCM4 LD CP LD JR A,(MODE) 2 A,(HL) Z,CHCM3 ;SELECT SCREEN, ROM1 OFF ;JR IF NOT 6-PIX CHARS ;SCREEN DATA ;JR IF EVEN COLUMN - TOP LHS PIX IN BITS 7,6 ;ELSE DATA IN BITS 3,2 ;NOW IN 1,0 ;SCREEN DATA ;JR IF MODE 2 - TOP LHS PIXEL DATA IS BITS 7,6 ;ELSE IT IS BITS 7,6,5,4 ;DATA NOW IN RH 2 OR 4 BITS ;A=BACKGROUND COLOUR - (TOP LHS PIXEL COLOUR) ;BUFFER FOR 8-BYTE COMPRESSED FORM FOR SCREEN$

RLCA RLCA RLCA RLCA EXX POP HL SCF LD B,A CALL NC,SPSSR LD A,B LD B,8 PUSH BC PUSH AF LD DE,0101H EXX PUSH HL LD (TEMPW1),HL CALL CHARCOMP2 POP HL LD A,L ADD A,128 LD L,A JR NC,CHARCNINC INC H EXX POP AF POP BC DJNZ CHARCLP JP RCURPR

;CALLED BY GRAPHICS COPY WITH NC GRCOMP: ;SELECT SCREEN ;8 SCANS ;BG COLOUR ;1 SCAN AT A TIME, 1 BYTE ACROSS IN RESULT ;OFFSET FOR SCREEN SOURCE ADDR (USED BY MODE 2 ;FILL, AND CHARCOMP2 NEEDS IT) ;DO A SCAN ;NOW DROP TO NEXT SCAN ;SCAN LEN

CHARCLP:

;BG COLOUR

;CRDFID.SAM ;GET FIDDLED COORDS - FORCE FATPIX ;GET FIDDLED FAT COORDS - USED BY GET, ROLL/SCROLL CD9327 D0 CB1C CB1D 4D C9 CDFB27 GTFCOORDS: GTFIDFCDS: CALL GTFCOORDS RET NC RR H RR L LD C,L RET ;GET FIDDLED COORDS CALL COORDFID ;APPLY OFFSETS AND RANGES ;UNSTACK COORDS. ;ENTRY: X,Y ON FPCS ;EXIT: IF THIN PIX, HL=X COORD, CHECK FOR 0-511, ELSE C=X, CHECKED FOR 0-255. ;B IS ALWAYS THE Y COORD, CORRECTED FROM -16 TO 175 ON FPCS TO 0-191, THEN ;INVERTED SO 0 AT THE TOP. CY SET IF THIN PIX CDB027 USCOORDS: CALL USYCOORD ;RET IF FAT PIX ;HALVE X, MOVE TO C

2799 279A 279D 27A0 27A3 27A4 27A5 27A6 27A8 27A8 27AA 27AB 27AB 27AB 27AC 27AD 27AE 27AE 27B0 27B0 27B0 27B0 27B0 27B3 27B5 27B5 27B8 27BA 27BA 27BB 27BD 27BD 27BE 27BF 27BF 27C0 27C2 27C2 27C3 27C5 27C6 27C8 27C8 27CB 27CC 27CC 27CC 27CC 27CC 27CC 27CF 27D1 27D1 27D3 27D5 27D5 27D7 27D7 27D8 27DB 27DD 27DD 27DF 27E1 27E1 27E3 27E3 27E4 27E7 27E8 27E9 27EA 27EB 27ED 27ED 27EE 27F0 27F0 27F1 27F1 27F2 27F3 27F5 27F7 27F7 27F8 27F8 27F8 27F8 27F8 27F8 27F8 27F9 27FB 27FB 27FB 27FB 27FC 27FD 27FE 27FF 2801 2804

F5 CD2E1D 22CA5A 3A4D5A A7 7C C1 2003 FE02 D8 4D A7 C8 180D THCKCHK:

PUSH AF CALL GETINT LD (TEMPW2),HL LD A,(THFATT) AND A LD A,H POP BC JR NZ,THCKCHK CP 2 RET C LD C,L AND A RET Z JR IOORERR1

;Y ;HL=X COORD. BC=HL ;SAVE FOR 'RECORD' TO USE ;A=0 IF THIN PIX ;A=X MSB ;B=Y ;CHECK X MSB VS 2 - MUST BE ZERO OR 1 ;CY SIGNALS THIN PIX ;A MUST BE 2-FF HERE ;C=X ;NC ;X MSB MUST BE 0 UNLESS THIN PIX

;UNSTACK Y COORD TO A, CHECK AND CONVERT TO 0-191 SCALE CD651D 3808 3A5C5A 2005 81 3005 CF 1E 91 38FB 47 3EBF 90 38F5 32CE5A C9 IOORERR1: ADJNEG: ADJOK1: USYCOORD: CALL FPTOA JR C,IOORERR1 LD A,(ORGOFF) JR NZ,ADJNEG ADD A,C JR NC,ADJOK1 RST 08H DB 30 SUB C JR C,IOORERR1 LD B,A LD A,191 SUB B JR C,IOORERR1 LD (TEMPB1),A RET ;A=0-191. SAVE FOR 'RECORD' TO USE ;(16 IF HEIGHT=8)-ABS Y ;IF Y IS NEGATIVE, ABS Y MUST BE <=ORGOFF ;-1 TO -16 NOW 15 TO 0 ;A (AND C)=ABS Y. Z IF POSITIVE ;16 IF HEIGHT=8 ;JR IF Y IS -VE ;ADD 16 SO 0-175 BECOME 16-191

;TWONUMS ;UNSTACK X AND Y DISPS. B=Y DISP, C=X DISP, D=SGN Y, E=SGN X (SGN = 01/FF) ; OR IF CY, THIN PIX AND HL=X DISP CD651D 38EC 06FF 2802 0601 C5 CD3B1D 38E0 2601 2802 26FF D1 3A4D5A A7 78 43 5C 2804 A7 20CD C9 69 67 FE02 30C6 C9 THINNUMS: POSINT: POSBYTE: TWONUMS: CALL FPTOA JR C,IOORERR1 LD B,0FFH JR Z,POSBYTE LD B,01H PUSH BC CALL FPTOBC JR C,IOORERR1 LD H,1 JR Z,POSINT LD H,0FFH POP DE LD A,(THFATT) AND A LD A,B LD B,E LD E,H JR Z,THINNUMS AND A JR NZ,IOORERR1 RET LD LD CP JR RET L,C H,A 2 NC,IOORERR1 ;ERROR IF ABS Y>255 ;-VE. REVERSE SGN BECAUSE Y COORD REVERSES ;+VE ;B=SGN Y, C=Y ;BC=X. Z IF +VE. CY IF OOR ;+VE ;-VE. H=SGN X ;D=SGN Y, E=Y ;THIN/FAT TEMP. ONLY SAYS THIN IF MODE 2. ;X MSB ;B=Y ;E=SGN X ;X MSB MUST BE ZERO IF FAT PIX IN USE ;B=Y, C=X, D=SGN Y, E=SGN X. NC ;HL=X ;HL=X, E=SGN X, D=SGN Y, B=Y. CY SHOWS THIN STATUS ;BC MUST BE 01FF OR LESS

;COORDINATE FIDDLE FOR PLOT, DRAW TO, CIRCLE, PUT,GRAB. ENTRY WITH X,Y ON FPCS ;DRAW RANGE FIDDLE ONLY 37 180A AF 47 4F 08 1E39 CD3228 AF DRCOORDFD: SCF JR RGFIDEN COORDFID: XOR A LD B,A LD C,A EX AF,AF' LD E,YOSDISP CALL PSEUDOSR XOR A ;'DON'T APPLY XOS'

;RANGE AND OFFSET FIDDLE. USED BY E.G. PLOT. ;NC='OFFSET' ;BC=0=NORMAL YOS ;ADD YOS IF NON-NORMAL (<>ZERO) ;NC='APPLY XOS'

2805 2805 2806 2807 2808 280A 280D 2810 2813 2814 2816 2816 2817 2818 2819 281B 281E 281F 281F 2820 2823 2826 2827 2829 2829 282A 282A 282C 282F 2832 2832 2832 2832 2832 2832 2832 2834 2835 2838 283A 283B 283C 283D 2840 2843 2843 2844 2845 2848 2849 284A 284C 284D 284F 284F 2850 2851 2852 2852 2855 2855 2856 2857 2858 2859 285A 285A 285A 285B 285C 285D 285E 285E 285F 2860 2861 2862 2862 2863 2864 2865 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2866 2869 286A 286B 286B 286E 2870

F5 37 08 1E43 01C000 CD3228 CD8A18 F1 3809 47 4F 08 1E4D CD3228 37 08 010002 3A4D5A A7 2801 05 1E57 CD3228 C38A18

RGFIDEN:

PUSH AF SCF EX AF,AF' LD E,YRGDISP LD BC,192 CALL PSEUDOSR CALL SWOP12 POP AF JR C,DOXRG LD B,A LD C,A EX AF,AF' LD E,XOSDISP CALL PSEUDOSR SCF

;'RANGE' ;APPLY YRG UNLESS IT IS 192 ;GET X COORD TO STACK TOP ;NC MEANS APPLY XOS. A=0

;ADD XOS IF NON-NORMAL (<>ZERO) ;'RANGE'

DOXRG:

EX AF,AF' LD BC,512 LD A,(THFATT) AND A JR Z,GXRANGE DEC B LD E,XRGDISP CALL PSEUDOSR JP SWOP12

;RANGE=512 IF THIN ;BC=256 ;APPLY XRG UNLESS IT IS NORMAL ;GET Y TO TOP OF FPCS

GXRANGE:

;PSEUDO VARIABLE SUBROUTINE ;ENTRY: E=OFFSET TO PSEUDO-VAR XOS/YOS/XRG/YRG. F'=CY IF RANGE, NC IF OFFSET ;BC=NORMAL VALUE OF VAR. ;ACTION: APPLY PS IF NON-NORMAL DBFB F5 CD1F1F 1600 19 54 5D CD5A28 CA453C C5 EB CD201D C1 F1 D3FB 08 3803 EF 01 34 CDDD1C EF 06 05 00 34 7E 23 B6 C0 23 79 BE C0 23 78 BE C9 CHECKPS: APPLYRG: PSEUDOSR: IN A,(URPORT) PUSH AF CALL ADDRNV LD D,0 ADD HL,DE LD D,H LD E,L CALL CHECKPS JP Z,PPORT PUSH BC EX DE,HL CALL HLTOFPCS POP BC POP AF OUT (URPORT),A EX AF,AF' JR C,APPLYRG DB CALC DB ADDN DB EXIT2 CALL STACKBC DB DB DB DB DB CALC SWOP DIVN MULT EXIT2 ;NORM/RG ;COORD*NORM/RG

;DE PTS TO PS START ;SEE IF PSEUDO VAR=BC (NORMAL) ;JR IF PSEUDO VAR=NORMAL, DON'T APPLY IT. ;(POP AF, OUT, RET) ;NORMAL VALUE ;ELSE STACK PSEUDO-VAR

;ADD OFFSET

LD A,(HL) INC HL OR (HL) RET NZ INC HL LD A,C CP (HL) RET NZ INC HL LD A,B CP (HL) RET

;NORMAL VALUES ALWAYS START 00 00

;GRAPHICS RECORD ;PLOT, DRAW TO, CIRCLE: CALL HERE WITH CMD CODE IN E, TEMPB1=Y, TEMPW2=X ;CIRCLE HAS RADIUS IN B REG. REL. DRAW USES E,C,D,B FOR SGN X,X,SGN Y,Y. ;PEN, OVER, PAUSE, CLS USE E,C FOR CMD CODE, PARAM ;E=FE/00 IF FAT REL. DRAW ;E=1 FAT PLOT ;E=2 FAT DRAW TO ;E=3 CIRCLE ;E=4 OVER ;E=5 PEN ;E=6 CLS ;E=7 PAUSE 3A815B A7 C8 3A745B FEBB C8 GRAREC: LD A,(GRARF) AND A RET Z LD A,(CURCMD) CP 187 RET Z ;RET IF RECORD OFF ;PRINT ;AVOID RECORD OF E.G. PRINT PEN 5;

2871 2871 2872 2873 2874 2875 2878 2879 287B 287D 287D 287E 2880 2880 2881 2882 2883 2884 2884 2885 2887 2887 2889 288A 288B 288C 288C 288D 288E 288F 2890 2892 2894 2894 2896 2898 2898 289B 289C 289F 28A0 28A0 28A1 28A1 28A2 28A3 28A4 28A5 28A6 28A7 28A8 28A9 28AB 28AD 28AF 28AF 28B1 28B3 28B3 28B5 28B5 28B8 28B9 28BA 28BC 28BF 28C0 28C2 28C5 28C8 28C9 28CC 28CD 28CE 28CF 28D0 28D0 28D0 28D0 28D0 28D0 28D3 28D6 28D8 28DA 28DA 28DB 28DD 28DD 28E0 28E0 28E3 28E6 28E6 28E9 28EC 28EF 28F0 28F1 28F4 28F5 28F6 28F7

E5 D5 C5 7B 21004F 3D FEFD 3817 3C 2804 1C AF 91 4F 14 2805 16FF AF 90 47 73 78 42 57 1E03 180D FE03 3008 3ACA5A 4F 3ACE5A 47 73 23 71 23 70 23 72 7B 3D 0E03 FE02 3806 0E04 2802 0E02 2A515C E5 C5 3E10 CD6311 C1 0600 11004F CD1300 E1 22515C C1 D1 E1 C9 GRAR7: GRAR5: GRAR4:

PUSH HL PUSH DE PUSH BC LD A,E LD HL,INSTBUF DEC A CP 0FDH JR C,GRAR6 INC A JR Z,GRAR4 INC E XOR A SUB C LD C,A INC D JR Z,GRAR5 LD D,0FFH XOR A SUB B LD B,A LD LD LD LD LD JR (HL),E A,B B,D D,A E,3 GRAR66

;SGN FE/00 GOES TO FD/FF ;JR IF NOT REL. DRAW ;JR IF +VE X SGN (E=0) ;E=FF ;NEGATE X DISP ;Y SGN ;JR IF -VE Y SGN.. Y IS REALLY +VE - FIDDLED BY ;TWONUMS BECAUSE OF Y AXIS REVERSAL ;NEGATE Y DISP

;SWOP B AND D ;PRETEND 'CIRCLE'

GRAR6: GRAR62:

CP 3 JR NC,GRAR65 LD LD LD LD A,(TEMPW2) C,A A,(TEMPB1) B,A ;X ;Y ;COORDS TAKEN FROM STORES USED BY CRDFID ;BLITZ CODE

GRAR65: GRAR66:

LD (HL),E INC HL LD (HL),C INC HL LD (HL),B INC HL LD (HL),D LD A,E DEC A LD C,3 CP 2 JR C,GRAR7 LD C,4 JR Z,GRAR7 LD C,2 LD HL,(CURCHL) PUSH HL PUSH BC LD A,16 CALL SETSTRM POP BC LD B,0 LD DE,INSTBUF CALL PRINTSTR POP HL LD (CURCHL),HL POP BC POP DE POP HL RET

;MAY BE JUNK ;MAY BE JUNK

;JR IF PLOT OR DRAWTO - 3 BYTES ;JR IF CIRCLE OR REL DRAW - 4 BYTES

;STREAM 16 - TO STRING ;O/P BC FROM DE TO STRING ;STREAM 16 DOESN'T SET ANY FLAGS, SO NO NEED ;TO CALL CHAN-FLAG TO RESET THEM.

INCLUDE GRABPUT.SAM ;GRAB.SAM - GRAB A$,X,Y,W,L CDF72C 213B5C CB76 2003 DF FE2C C2290D CDD33A CD153B CD9512 111EC0 CD5F1F 3C F5 CD2E1D 0B 78 A7 C2391D GNONSH: GRAB: CALL SYNTAX1 LD HL,FLAGS BIT 6,(HL) JR NZ,GNONSH RST 18H CP "," JP NZ,NONSENSE CALL SEXPT4NUMS CALL CHKEND CALL CHKMD23 LD DE,0C000H+30 CALL LIMDB INC A PUSH AF CALL GETINT DEC BC LD A,B AND A JP NZ,IOORERR

;GRAB, PUT, FARLDIR, STRMOV

;ASSESS VAR FOR ASSIGNMENT ;ERROR IF NUMERIC TYPE

;SKIP, EXPECT 4 NUMBERS ;INSIST ON MODE 2 OR 3 ;LEN TO A, DECED (0-191) (ORIG MUST BE 1-192) ;A=LEN ;0->FFFF, 256->255 ;INSIST ON WIDTH OF 1-256

28FA 28FA 28FB 28FC 28FC 28FE 2900 2901 2902 2903 2906 2907 290A 290D 2910 2910 2910 2910 2910 2913 2916 2918 2919 291A 291B 291C 291F 2920 2921 2923 2924 2925 2928 292B 292F 2930 2931 2932 2934 2937 2937 2937 2937 2937 2937 2938 2939 293A 293C 293C 293E 293F 293F 2941 2941 2943 2944 2945 2946 2947 2947 2947 2947 2947 2948 2949 294C 294D 294D 294E 294F 2950 2950 2951 2952 2953 2955 2957 295A 295B 295B 295B 295B 295B 295B 295B 295E 2961 2963 2965 2965 2968 2968 296B 296E 2970 2972 2972 2975 2975 2976 2976 2977

03 03 CB38 CB19 D1 59 D5 CD8927 D1 CD1029 CDEB1C C30F2B

INC BC INC BC SRL B RR C POP DE LD E,C PUSH DE CALL GTFIDFCDS POP DE CALL JGRAB CALL STKSTOS JP ASSIGN

;BC=1-256 ;IF BC IS EVEN, SET BIT 0 (WHICH WILL BE LOST) ;IF BC IS ODD,ROUND UP E.G. WIDTH 1->2 ;B=0 ;C=1-128 ;D=LEN ;WID ;LEN/WID ;UNSTK X,Y TO CB. CHECK FOR LEGALITY ;LEN/WID ;STACK REGISTERS - STRING

;D=LEN (PIX), E=WIDTH (BYTES), B=Y, C=X ;EXIT: DE=START (IN CUSCRNP), BC=LEN (INCLUDES 3 LEADER BYTES) CDB13F 2100E0 3600 23 73 23 72 CD4729 7B F7 23EA 7B 08 CD3F0B 1100E0 ED4BCA5A 03 03 03 DBFB C3C63F JGRAB: CALL SPSS LD HL,RSBUFF-3 LD (HL),0 INC HL LD (HL),E INC HL LD (HL),D CALL GPVARS LD A,E RST 30H DW CRTBFI LD A,E EX AF,AF' CALL RSSTBLK LD DE,RSBUFF-3 LD BC,(TEMPW2) INC BC INC BC INC BC IN A,(251) JP RCURP ;GET CURRENT SCREEN AT 8000+ ;E000H ;CONTROL CODE ;WID ;LEN ;GET A'=WID,D/B'=LEN, HL=SCRN ADDR, BC=128

;(A' WAS CORRUPTED BY RST 30) ;STORE ROLL/SCROLL STORE BLOCK SR ;PT TO CC,W,L ;LEN OF DATA ;ALLOW FOR CC,W,L

;******************************************************************************* ;SR TO TRUNCATE LENGTH OF A BLOCK IF HANGING OFF BOTTOM OF SCREEN ;ENTRY: D=BLOCK LENGTH, B=Y COORD 7A 3D 80 3805 D6C0 D8 D640 C640 2F 82 57 C9 GPTRUNC2: GPTRUNC: LD A,D DEC A ADD A,B JR C,GPTRUNC2 SUB 192 RET C SUB 40H ADD A,40H CPL ADD A,D LD D,A RET ;LENGTH-1 ;ADD Y COORD ;ALLOW UP TO 191 ;RET IF WONT FALL OFF BOTTOM ;COMPENSATE FOR FOLLOWING 'ADD' ;GET 'NUMBER OF SCANS HANGING OFF' - 40H+ ;ELSE A=0-3FH ->FF-C0 ;ADJUST LENGTH

;GET/PUT VARS SETTER. ENTRY: E=WID, D=LEN, BC=YX COORDS. ;EXIT: A'/E=WIDTH, D/B'=LEN, HL=SCRN ADDR, BC=128 7B 08 CD3729 7A D9 47 D9 60 69 37 CB1C CB1D 018000 C9 GPVARS: LD A,E EX AF,AF' CALL GPTRUNC LD A,D EXX LD B,A EXX LD H,B LD L,C SCF RR H RR L LD BC,128 RET ;A'=WIDTH ;SHORTEN D IF NEEDED. ;B'=LENGTH ;Y ;X ;GET SCREEN ADDR IN 8000 AREA IN HL

;PUT.SAM ;****************************************************************************** ;E.G. PUT X,Y,A$. OVER 0-3 ALLOWED, ALSO INVERSE ; PUT X,Y,A$,M$ USES M$ AS A MASK FOR 'CLIPPING'. CDF23A CD9B3A FE2C 200D CD653A 2100F0 CD2B2A 3E05 1804 CD153B AF F5 2100E0 PUTLC: PUTL1: PUT: CALL SYNTAX9 CALL EXPTCSTR CP "," JR NZ,PUTL1 CALL SSYNTAXA ;INK/PAPER IRREL, PUT OVER/INVERSE WORK ;COMMA, STRING ;SKIP, EXPECT STRING

LD HL,RSBUFF+0FFDH ;E003+0FFD= F000H CALL PSCHKMHL ;CHECK MASK STRING AND MOVE TO 2ND HALF OF BUFFER LD A,5 ;'MASKED' JR PUTLC CALL CHKEND XOR A PUSH AF LD HL,RSBUFF-3 ;0=NO MASK, 5=MASKED ;E000H

297A 297D 2980 2983 2984 2985 2987 2987 2988 298B 298C 298C 298F 2993 2995 2997 2997 2998 2999 2999 299D 299E 299F 29A1 29A3 29A3 29A4 29A6 29A6 29A9 29AB 29AB 29AB 29AB 29AB 29AC 29AF 29B0 29B0 29B1 29B2 29B3 29B4 29B5 29B6 29B8 29BC 29BE 29BE 29BF 29C0 29C1 29C2 29C3 29C6 29C7 29C8 29C9 29CD 29CD 29CE 29CF 29D2 29D3 29D4 29D4 29D5 29D5 29D5 29D5 29D5 29D5 29D5 29D5 29D6 29D7 29D8 29DA 29DA 29DA 29DB 29DC 29DC 29DD 29DE 29DF 29DF 29E0 29E1 29E1 29E2 29E3 29E5 29E5 29E8 29E8 29E8 29E8 29E8 29E8 29E8 29E8 29E8

CD2B2A CD8927 CDB13F F1 A7 2812 D9 2103F0 D9 2A01E0 ED5B01F0 ED52 280F CF 26 ED5B545A 7B B2 3E04 2803 7A E603 2101E0 1805 PUT05: PUTL2:

CALL PSCHKMHL CALL GTFIDFCDS CALL SPSS POP AF AND A JR Z,PUTL2

;CHECK STRING AND MOVE TO RSBUFF ;B=Y,C=X. ;JR IF NOT MASKED PUT. NC

EXX LD HL,RSBUFF+1000H ;HL'= F003H - PTR TO MASK STRING EXX LD HL,(RSBUFF-2) ;E001/E002 LD DE,(RSBUFF+0FFEH) ;F001/F002 SBC HL,DE JR Z,PUT05 ;A=5 STILL... JR IF W,L THE SAME FOR BOTH STRINGS RST 08H DB 38 LD LD OR LD JR DE,(INVERT) A,E D A,4 Z,PUT05 ;'PUT mask mismatch' ;E=INVERT, D=GOVERT ;0-3 ;OVER 0, INVERSE 0 USES SPECIAL ROUTINE NO. 4 ;NEUROT... ;STR PTR (E001H)

LD A,D AND 3 LD HL,RSBUFF-2 JR PUT06

;A=PUT TYPE 0-5, B=Y, C=X, HL PTS TO W (BYTES), LEN (PIX), HL' TO MASK DATA ;BLOCK TRUNCATED IF HANGS OFF SCREEN BOTTOM 5F CDB13F 7B 87 5F 87 87 83 5F 1600 FD21E829 FD19 5E 23 56 23 E5 CD4729 79 93 D1 DD21DA29 D9 5F 3A545A 08 4F D9 PUTSCLP: JPUT: PUT06: LD E,A CALL SPSS LD A,E ADD A,A LD E,A ADD A,A ADD A,A ADD A,E LD E,A LD D,0 LD IY,PUTSRTAB ADD IY,DE LD E,(HL) INC HL LD D,(HL) INC HL PUSH HL CALL GPVARS LD A,C SUB E POP DE LD IX,PUTRET EXX LD E,A LD A,(INVERT) EX AF,AF' LD C,A EXX ;**

;*8 ;*10 ;IY=ADDR OF SUBROUTINE FOR 'OVER' VARIATIONS ;GET WIDTH FROM STRING (BYTES) ;LEN ;GET A'/E=WID,D/B'=LEN, HL=SCRN ADDR, BC=128 ;SCAN LEN-WIDTH=DISP TO NXT SCAN ;STRING PTR ;SET UP IX TO AVOID CALL OVERHEADS ;E'=DISP ;INVERSE MASK 00/FF TO A' ;A=WIDTH ;C'=BLOCK WIDTH

;AT THIS POINT: ;HL=SCRN PTR, DE=DATA SRC, A=WIDTH ;B'=LEN, C'=WIDTH, E'=DISP TO NEXT SCAN, A'=INVERSE MASK ;HL' CAN PT TO MASK STRING ;B IS USED AS A WIDTH COUNTER, AND C AS AN INVERSE MASK 47 08 4F FDE9 79 08 D9 7B D9 4F 09 D9 79 10EF C3C63F PUTRET: LD EX LD JP B,A AF,AF' C,A (IY) ;BLOCK WIDTH COUNTER SET UP ;INVERSE MASK ;JUMP TO XOR, OR, LD or AND LOOP ;ENTRY WITH DE=SRC, HL=SCRN DEST, B=BYTES, C=INVER ;EXIT WITH B=0 ;INVERSE ;PROTECT INVERSE MASK IN A' ;DISP TO NEXT SCAN FROM E' ;BC=DISP TO NEXT SCAN (SCAN LEN-BLOCK WIDTH) ;DROP 1 SCAN ;GET WIDTH VALUE FROM C' ;DEC LENGTH COUNTER, LOOP TILL ALL SCANS DONE

LD A,C EX AF,AF' EXX LD A,E EXX LD C,A ADD HL,BC EXX LD A,C DJNZ PUTSCLP JP RCURP

;****************************************************************************** ;PUT SUBROUTINES FOR OVER 0,1,2,3. ;ENTRY WITH DE PTING TO DATA SRC, HL TO SCRN, B=BYTES TO DO, C=INVERSE MASK ;IX='RET' ADDR ;EXIT WITH B=0. PUTSRTAB:

29E8 29E9 29EA 29EB 29EC 29ED 29EF 29F1 29F2 29F2 29F3 29F4 29F5 29F6 29F7 29F8 29FA 29FC 29FC 29FD 29FE 29FF 2A00 2A01 2A02 2A04 2A06 2A06 2A07 2A08 2A09 2A0A 2A0B 2A0C 2A0E 2A10 2A10 2A10 2A10 2A11 2A12 2A14 2A16 2A17 2A19 2A1A 2A1A 2A1A 2A1A 2A1A 2A1A 2A1A 2A1B 2A1C 2A1D 2A1E 2A1F 2A20 2A21 2A22 2A23 2A24 2A25 2A27 2A29 2A29 2A2A 2A2B 2A2B 2A2B 2A2B 2A2B 2A2E 2A31 2A31 2A34 2A35 2A36 2A38 2A38 2A39 2A3A 2A3C 2A3C 2A3C 2A3C 2A3C 2A3C 2A3C 2A3C 2A3F 2A40 2A42 2A42 2A45 2A48 2A49 2A4B 2A4C 2A4E 2A4E 2A50 2A52

1A A9 77 13 23 10F9 DDE9 00 1A A9 AE 77 13 23 10F8 DDE9 1A A9 B6 77 13 23 10F8 DDE9 1A A9 A6 77 13 23 10F8 DDE9 EB 48 0600 EDB0 EB DDE9 00

OVER0LP:

LD A,(DE) XOR C LD (HL),A INC DE INC HL DJNZ OVER0LP JP (IX) NOP LD A,(DE) XOR C XOR (HL) LD (HL),A INC DE INC HL DJNZ OVER1LP JP (IX) LD A,(DE) XOR C OR (HL) LD (HL),A INC DE INC HL DJNZ OVER2LP JP (IX) LD A,(DE) XOR C AND (HL) LD (HL),A INC DE INC HL DJNZ OVER3LP JP (IX) EX DE,HL LD C,B LD B,0 LDIR EX DE,HL JP (IX) NOP

;DATA FROM STRING ;INVERSE MASK

;MAKE ALL SRs HAVE LENGTH OF 10 ;DATA FROM STRING ;INVERSE MASK ;OVER 1

OVER1LP:

OVER2LP:

;DATA FROM STRING ;INVERSE MASK ;OVER 2

OVER3LP:

;DATA FROM STRING ;INVERSE MASK ;OVER 3 ;ABOUT 64 T'S PER BYTE (USE INC L,=56)

;FASTER VERSION FOR WHEN INVERSE 0, OVER 0 NOINVER:

;32 T'S PER BYTE

;USE 'VALID DATA' MASK PTED TO BY HL'. 1'S=VALID ;MAKE MASK BY: FILL INK 0, BORDER AREA: GRAB A$: FILL INK 15, BORDER AREA ;PUT OVER 1, A$. (MAKES BORDER 1'S, FIGURE 0'S). GRAB A$: PUT INVERSE 1, A$ ;GRAB A$. GIVES BORDER 0'S, FIGURE 1'S. 1A A9 AE D9 A6 23 D9 13 AE 77 23 10F3 DDE9 CF 25 PMASKLP: LD A,(DE) XOR C XOR (HL) EXX AND (HL) INC HL EXX INC DE XOR (HL) LD (HL),A INC HL DJNZ PMASKLP JP (IX) ;DATA FROM STRING ;INVERSE MASK ;XOR SCRN ;AND MASK

;ABOUT 96 T'S PER BYTE ;'Invalid PUT block'.

PUTBLKERR: RST 08H DB 37

;PUT STRING CHECK/MOVE TO (HL) ;CHECK PUT STRING STARTS WITH CHR$ 0, LEN <>0. COPY TO (HL) IN SCRN MEM 22C85A CD9512 CDDC3F 78 B1 28F1 1A A7 20ED PSCHKMHL: ; LD (TEMPW1),HL CALL CHKMD23 CALL SPSS CALL GETSTRING LD A,B OR C JR Z,PUTBLKERR LD A,(DE) AND A JR NZ,PUTBLKERR ; CALL SCRMOV ; JP RCURP ;SCRNMOV - COPY BC BYTES FROM (DE) TO (TEMPW1) IN SPARE SCRN MEMORY ;USES HL,DE,BC,AF,AF' 2AC85A 09 38E7 CD791F 3A785A 4F DBFB 37 1815 CB74 2003 FARLDDR: SCRMOV: LD HL,(TEMPW1) ADD HL,BC JR C,PUTBLKERR CALL SPLITBC LD A,(CUSCRNP) LD C,A IN A,(251) SCF JR SFLDIR BIT 6,H JR NZ,FLD3 ;JR IF STRING WILL NOT FIT ;C:(TEMPW1)=DEST ;ADE=SRC ;DEST ;GET CURRENT SCREEN AT 8000+ ;DE=STRING ADDR, BC=LEN, PAGE IS SELECTED ;!!!SPSS ACTION NEGATED!! ;REQUIRE NON-ZERO LENGTH ;REQUIRE CHR$ 0 AS 1ST. CHAR

;JR IF SRC ALREADY IN SECT D

2A52 2A53 2A55 2A55 2A57 2A59 2A59 2A5A 2A5C 2A5C 2A5D 2A5E 2A5E 2A5E 2A5E 2A5E 2A5E 2A5E 2A5F 2A5F 2A60 2A63 2A63 2A63 2A63 2A64 2A65 2A68 2A68 2A68 2A68 2A68 2A68 2A69 2A6C 2A6D 2A70 2A73 2A74 2A76 2A76 2A77 2A7A 2A7D 2A7E 2A7F 2A81 2A81 2A85 2A88 2A8B 2A8B 2A8B 2A8B 2A8B 2A8B 2A8B 2A8B 2A8B 2A8C 2A8D 2A8E 2A8E 2A91 2A92 2A93 2A96 2A96 2A97 2A98 2A98 2A9B 2A9C 2A9D 2A9F 2A9F 2AA0 2AA1 2AA1 2AA2 2AA3 2AA4 2AA7 2AA8 2AAA 2AAA 2AAB 2AAC 2AAE 2AAF 2AB1 2AB4 2AB6 2AB6 2AB7 2AB9 2ABA 2ABD 2ABD 2ABE 2AC0 2AC1 2AC4

3D CBF4 CB72 2003 0D CBF2 A7 06 FLD4: FLD3:

DEC A SET 6,H BIT 6,D JR NZ,FLD4 DEC C SET 6,D AND A DB 06H

;PAGE IN SRC AT C000-FFFF

;DITTO DEST ;'LDDR' ;'JR +1'

;LDIR (PAGCOUNT) PAGES AND (MODCOUNT) BYTES FROM AHL TO CDE. MODCOUNT<=3FFF. ;PAGCOUNT OR MODCOUNT CAN BE ZERO WITHOUT PROBLEMS. PAGING UNCHANGED ON EXIT. ;EXIT WITH TEMPW1=PAST DEST, TEMPB2=PAGE OF PAST DEST, DE=PAST SRC END ;HL OR DE CAN BE ABOVE COOOH ON ENTRY WITHOUT PROBLEMS 37 EB 22C85A 67 79 32CF5A SFLDIR: FARLDIR: SCF EX DE,HL LD (TEMPW1),HL ;C/(TEMPW1) =DEST, ADE=SRC LD H,A LD A,C LD (TEMPB2),A ;DEST ADDR

;ENTRY: HDE=SRC, TEMPB2/TEMPW1=DEST. USED IF FARLDIR HAS MOVED SOME DATA ALREADY ;FROM CONCATENATE 08 CD493C 7C CDDF3F 3A835B A7 280B F5 010040 CD8E2A F1 3D 20F5 ED4B845B CD8B2A C3423C FARLDIR2: EX AF,AF' CALL R1OSR LD A,H CALL TSURPG LD A,(PAGCOUNT) AND A JR Z,FLDIE PUSH AF LD BC,4000H CALL STRMOV1 POP AF DEC A JR NZ,FARLDILP LD BC,(MODCOUNT) CALL STRMOV JP POPOUT ;CY' IF LDIR ;ROM1 OFF, SAVE PORT STATUSES (STATI?) ;SRC PAGE

FARLDILP:

;DO PAGCOUNT 16K MOVES

FLDIE:

;STRMOV: MOVE BC BYTES FROM (DE) IN CURRENT UR PAGE TO (TEMPW1) IN ;PAGE (TEMPB2), VIA SYS PAGE. WORKS WITH 0000 TO FFFF BYTES ;CY' IF LDIR, NC' IF LDDR ;EXIT WITH DE=PAST SRC END, PAGE SWITCHED IN, (TEMPW1)=PAST DEST END, ;(TEMPB2)=PAGE OF THE LATTER. HL=0 ;USED BY FARLDIR 78 B1 C8 2ABA5B 24 25 C20500 60 69 010001 7C A7 2002 44 4D E5 C5 EB 11004C 08 380C 08 1D EDB8 C1 CB74 CCF93F 1807 08 EDB0 C1 CDEF3F E5 DBFB F5 3ACF5A CDDF3F DLDIR: STRMOV2: STRMOVL: STRMOV: STRMOV1: LD A,B OR C RET Z LD HL,(INSLV) INC H DEC H JP NZ,HLJUMP LD H,B LD L,C LD BC,0100H LD A,H AND A JR NZ,STRMOV2 LD B,H LD C,L PUSH HL PUSH BC EX DE,HL LD DE,BUFF256 EX AF,AF' JR C,DLDIR EX AF,AF' DEC E LDDR POP BC BIT 6,H CALL Z,DECURPAGE JR STRM32 EX AF,AF' LDIR POP BC CALL CHKHL PUSH HL IN A,(251) PUSH AF LD A,(TEMPB2) CALL TSURPG ;HL=BYTES REMAINING TO DO

;JR IF 256 OR MORE TO DO STILL ;COUNT=REMAINING. EXIT AFTER THIS MOVE ;BYTES REMAINING

;JR IF LDIR ;DEST=256 BYTE BUFFER, HL=SRC, BC=256 (USUALLY) ;PT TO OTHER END OF BUFFER (E=255) ;IF SRC FALLEN INTO SECTION C, DEC PAGE AND SET 6,H ;COPY BYTES TO BASE PAGE ;SRC PTR (8000-BFFF OR C000-FFFF IF LDDR) ;SAVE SRC PAGE ;GET DEST AT 8000+

STRM32:

2AC7 2ACB 2ACC 2ACD 2AD0 2AD2 2AD2 2AD3 2AD4 2AD6 2AD7 2AD9 2ADC 2ADC 2ADE 2ADE 2ADF 2AE1 2AE2 2AE5 2AE5 2AE7 2AEA 2AEA 2AED 2AEE 2AEF 2AF0 2AF2 2AF3 2AF4 2AF5 2AF7 2AF9 2AF9 2AFA 2AFA 2AFA 2AFA 2AFA 2AFD 2AFD 2AFE 2B01 2B04 2B05 2B06 2B07 2B09 2B0C 2B0C 2B0D 2B0E 2B0F 2B0F 2B0F 2B0F 2B12 2B15 2B15 2B16 2B19 2B1A 2B1A 2B1B 2B1C 2B1D 2B1E 2B1F 2B20 2B20 2B21 2B22 2B23 2B23 2B24 2B25 2B25 2B26 2B28 2B28 2B28 2B28 2B28 2B2B 2B2B 2B2B 2B2B 2B2C 2B2F 2B31 2B31 2B34 2B37 2B37 2B3A 2B3A 2B3A 2B3A 2B3D 2B3E 2B41 2B44

ED5BC85A C5 08 21004C 380C 08 2D EDB8 EB CB74 CCF93F 1807 08 EDB0 EB CDEF3F DBFB 32CF5A 22C85A EB C1 F1 D3FB D1 E1 A7 ED42 209F C9 ;ASSIGN.SAM 3A3B5C F5 CDE314 3A3B5C 57 F1 AA E640 C2290D 7A 17 D0 CD372B C3D73F E5 CD201D 47 EF 26 02 23 1F 04 05 20 02 00 33 D1 1820 ASSIGN: CGXRG: VALFET1: VALFET2: STRM34:

LD DE,(TEMPW1) PUSH BC EX AF,AF' LD HL,BUFF256 JR C,STRM34 EX AF,AF' DEC L LDDR EX DE,HL BIT 6,H CALL Z,DECURPAGE JR STRM38 EX AF,AF' LDIR EX DE,HL CALL CHKHL IN A,(URPORT) LD (TEMPB2),A LD (TEMPW1),HL EX DE,HL POP BC POP AF OUT (251),A POP DE POP HL AND A SBC HL,BC JR NZ,STRMOVL RET INCLUDE ASSIGN.SAM LD A,(FLAGS) PUSH AF CALL SCANNING LD A,(FLAGS) LD D,A POP AF XOR D AND 40H JP NZ,NONSENSE LD A,D RLA RET NC ;RUN TIME ROUTINE CALL ASSISR JP SELCHADP PUSH HL CALL HLTOFPCS LD B,A DB DB DB DB DB DB CALC ONELIT 2 STKBREG JPFALSE 4

;DEST PTR ;BYTE COUNT

;POINT TO OTHER END OF BUFFER

;COPY BYTES FROM SYS PAGE TO DEST

STRM38: STRMOV4:

;POSSIBLY NEW DEST PAGE (BITS 7-5 MAY BE HI) ;NEW DEST ADDR (SECTION C IF LDIR, D IF LDDR) ;BYTE COUNT ;RESTORE SRC PAGE ;SRC PTR ;BYTES REMAINING TO MOVE

;STKVAR, ASSIGN, SYNTAX1, DIM, SLICER

;RET IF SYNTAX TIME

;XRG ;XRG,2 ;XRG,2,(0/29H) ;JP IF ZERO, MULT ;XRG/2 ;JP EXIT ;XRG*2 ;DELETE VALUE, COPY TO VARS

DB DIVN DB JUMP DB 2 DB MULT DB EXIT POP DE JR ASENV ;FROM PARPRO

3A3F51 4F 213B5C CBF6 CDC213 CDFA2C CD1B1F 3A3B5C 87 3A715C F2CD2B

CRTVAR35: CRTVAR4:

LD A,(TLBYTE) LD C,A LD HL,FLAGS SET 6,(HL) CALL NUMLOOK CALL SYN14C

;CALLED BY MERGE, SETUPVARS ;'NUMERIC'

ASSISR:

CALL ADDRDEST LD A,(FLAGS) ADD A,A LD A,(FLAGX) JP P,ASSTR

;ADDR ;ADDR ;ADDR ;ADDR

OF OF OF OF

LAST PTR LSB IF NEW NUMERIC VAR 1ST BYTE OF 5 IF EXISTING NUMBER SAVARS TERMINATOR IF NEW STRING (NOT USED) FIRST CHAR IF EXISTING STRING

;JR IF STRING

2B44 2B45 2B46 2B48 2B48 2B48 2B48 2B4B 2B4B 2B4E 2B50 2B51 2B51 2B51 2B51 2B51 2B54 2B56 2B57 2B5A 2B5D 2B5E 2B60 2B60 2B63 2B63 2B64 2B65 2B67 2B67 2B68 2B68 2B6A 2B6A 2B6B 2B6C 2B6C 2B6C 2B6F 2B70 2B73 2B76 2B77 2B79 2B79 2B7B 2B7B 2B7F 2B81 2B82 2B82 2B83 2B84 2B86 2B86 2B87 2B89 2B8B 2B8B 2B8B 2B8E 2B91 2B94 2B97 2B9A 2B9A 2B9A 2B9A 2B9B 2B9C 2B9D 2B9E 2B9E 2BA1 2BA4 2BA5 2BA6 2BA8 2BA9 2BAA 2BAB 2BAC 2BAD 2BB0 2BB2 2BB4 2BB4 2BB5 2BB6 2BB8 2BB8 2BBB 2BBB 2BBF 2BC1 2BC2 2BC2 2BC4 2BC7 2BC8 2BCB 2BCD 2BCD

EB 1F 3809 CD121D 010500 EDB0 C9 ASENV: LDI5:

EX DE,HL RRA JR C,ASNN CALL FDELETE LD BC,5 LDIR RET

;JR IF NUMBER IS 'NEW' ;DELETE FPC DATA, LEAVE HL PTING TO IT ;COPY OVER OLD VALUE

;ASSIGN TO EXISTING NUMERIC VAR. DE PTS TO EXISTING VALUE IN NVARS.

;ASSIGN NEW NUMBER. DE PTS TO LSB OF LAST LINK PTR. CALCULATE NEW VALUE TO POINT ;TO NUMEND, WHERE NEW VARIABLE WILL BE PLACED 3AA55A E61F 4F 2A855A 3A845A 91 2808 010040 09 3D 20FC A7 ED52 2B E5 3A845A 4F 2A825A 3A815A B9 2802 CBF4 ED4B855A ED42 EB 7A A7 2014 7B FE3C 300F CD271F CDB91F 010002 CD1B1E CD1B1F D1 73 23 72 CD231F 3A6051 77 23 06FF 70 23 70 23 EB 216251 E61F 2804 4F 04 EDB0 CD482B ED53855A CB72 C8 CBB2 3A845A 3C 32845A 18EE ASNCL: NELOAD: ANOK: ABSP: ANSP: ANSPL: ASNN: LD A,(DESTP) AND 1FH LD C,A LD HL,(NUMEND) LD A,(NUMENDP) SUB C JR Z,ANSP LD BC,4000H ADD HL,BC DEC A JR NZ,ANSPL AND A SBC HL,DE DEC HL PUSH HL LD LD LD LD CP JR A,(NUMENDP) C,A HL,(SAVARS) A,(SAVARSP) C Z,ABSP ;ADJUST ADDR OF NUMEND UP TILL BOTH NUMBERS ;ARE 'NORMALISED' WITH EACH OTHER. (WRAP-ROUND ;DOESN'T MATTER TILL >64K) ;GET DISP FROM LSB OF PTR TO FIRST FREE BYTE IN ;NUMS-SAVARS GAP ;GET DISP FROM *MSB*. ;SAVE DISP VALUE ;(WE CAN'T ALTER THE LINK YET - THERE MAY NOT BE ;ENOUGH MEMORY TO CREATE THE VARIABLE)

;JR IF SAME PAGE (USUAL CASE) ELSE A=1,2,3 ETC

SET 6,H LD BC,(NUMEND) SBC HL,BC EX DE,HL LD A,D AND A JR NZ,ANOK LD A,E CP 60 JR NC,ANOK CALL ADDRSAV CALL DECPTR LD BC,0200H CALL MAKEROOM CALL ADDRDEST ;OK TO CREATE NEW NUMERIC POP DE LD (HL),E INC HL LD (HL),D CALL ADDRNE LD A,(TLBYTE+33) LD (HL),A INC HL LD B,0FFH LD (HL),B INC HL LD (HL),B INC HL EX DE,HL LD HL,FIRLET+34 AND 1FH JR Z,ASNCL LD C,A INC B LDIR CALL ASENV LD (NUMEND),DE BIT 6,D RET Z RES 6,D LD A,(NUMENDP) INC A LD (NUMENDP),A JR NELOAD ;ASSIGN A STRING

;Z,NC OR NZ,NC (SAVARS *ALWAYS* HIGHER) ;JR IF (AS UNUSUAL) NUMEND AND SAVARS-START ARE ;IN SAME PAGE ;ELSE SAVARS ARE JUST 1 PAGE HIGHER - ADD 4000H ;TO HL SO BOTH NUMBERS 'NORMALISED' ;DE=FREE GAP BETWEEN NUMS AND STR/ARRAYS ;HL=LSB OF PTR ADDR ;JR IF AT LEAST 256 BYTES FREE ;JR IF AT LEAST 60 BYTES FREE (ENOUGH FOR ;LARGEST NUMERIC VARIABLE)

;OPEN 512 BYTES BEFORE SAVARS ;HL=PTR LSB ;DISP ;MAKE LINK OF PREVIOUS LAST-VAR-OF-THIS-LETTER ;PT TO NEW LAST VAR. ;PT HL TO NUMEND (LOCN OF NEW VAR.

;PTR=FFFF (LAST VAR OF THIS FIRST LETTER) ;PT TO SECOND LETTER OF NAME ;JR IF SINGLE-LET VAR ;BC=LEN OF NAME (LESS FIRST LETTER) ;COPY TO VARS ;COPY FPC VALUE TO VARS ;NUMEND IS PAST LAST BYTE OF VALUE ;RET IF STILL 8000-BFFF

2BCD 2BCD 2BCE 2BD1 2BD1 2BD1 2BD1 2BD5 2BD8 2BD9 2BDB 2BDB 2BDC 2BDD 2BDE 2BDE 2BDF 2BE0 2BE3 2BE4 2BE6 2BE8 2BE8 2BE9 2BEA 2BEB 2BEE 2BEE 2BEF 2BF0 2BF1 2BF4 2BF6 2BF7 2BF8 2BFB 2BFC 2BFD 2BFE 2BFF 2BFF 2C02 2C05 2C08 2C09 2C0A 2C0B 2C0C 2C0D 2C0F 2C0F 2C10 2C11 2C13 2C13 2C14 2C15 2C15 2C18 2C1A 2C1A 2C1A 2C1A 2C1C 2C1E 2C1E 2C1F 2C22 2C23 2C24 2C24 2C26 2C28 2C28 2C29 2C2C 2C2F 2C2F 2C31 2C31 2C33 2C34 2C34 2C35 2C36 2C36 2C37 2C3A 2C3A 2C3D 2C40 2C40 2C41 2C44 2C47 2C49 2C49 2C49 2C49 2C4C 2C4F 2C52 2C53

1F DA7B2C ED4B725C 3AA55A 17 386E 78 B1 C8 E5 C5 CD011D E1 ED42 3006 09 44 4D 210000 E3 EB 08 CD791F DBFB 4F 08 CD5E2A C1 78 B1 C8 3ACF5A CDDF3F 2AC85A AF B9 88 41 4F 3E20 77 23 10FC 0D C8 CDEF3F 18F5 FEB1 2006 AF 32815B E7 C9 FE8E 200C E7 CDDA14 FA290D 3805 CB71 C8 CF 1D 08 C45B2C 11765B CD432D 7A 32815B CD402D 1852 CD7B2C CD1B1F 11F2FF 19 CDBA1F

ASSTR:

RRA JP C,ASNST LD BC,(STRLEN) LD A,(DESTP) RLA JR C,ASDEL LD A,B OR C RET Z PUSH HL PUSH BC CALL STKFETCH POP HL SBC HL,BC JR NC,AES1 ADD HL,BC LD B,H LD C,L LD HL,0

;TEST BIT 0,(FLAGX) ;JP IF IT IS A NEW STRING ;LENGTH OF DESTINATION ;JR IF UNSLICED SIMPLE STRING - DELETE OLD VERSION ;RET IF E.G. LET A$(4 TO 3)="TEST" - DEST LEN=0 ;DEST ADDR ;DEST SIZE ;ADE/BC =STRING START/LEN ;DEST SIZE ;DEST SIZE-SRC SIZE (NC HERE) ;JR IF TRUNC NOT NEEDED ;HL=DEST SIZE AGAIN ;BC=TRUNCATED SRC LEN NEEDED TO FILL DEST ;'PADS' NEEDED=0 ;PADS NEEDED TO STACK, DEST ADDR TO HL ;DE=DEST, HL=SRC ;LD PAGCOUNT/MODCOUNT WITH BC ;CDE=DEST ;AHL=SRC ;COPY STRING TO DEST ;PADS

;ASSIGN TO EXISTING STRING VAR

AES1:

EX (SP),HL EX DE,HL EX AF,AF' CALL SPLITBC IN A,(251) LD C,A EX AF,AF' CALL FARLDIR POP BC LD A,B OR C RET Z LD A,(TEMPB2) CALL TSURPG LD HL,(TEMPW1) XOR A CP C ADC A,B LD B,C LD C,A LD A,20H

;PT TO PAST LAST BYTE FARLDIRED EARLIER ;NC ONLY IF C=0 ;A=B+1 UNLESS C WAS ZERO, WHEN A=B

ASPSL:

LD (HL),A INC HL DJNZ ASPSL DEC C RET Z CALL CHKHL JR ASPSL

;E.G. RECORD TO A$ OR: RECORD: CP 0B1H JR NZ,RECORD2 XOR A LD (GRARF),A RST 20H RET RECORD2: CP TOTOK JR NZ,RCNONS RST 20H CALL LVFLAGS JP M,NONSENSE JR C,RECORD3 BIT 6,C RET Z RCNONS: RECORD3: RST 08H DB 29

RECORD STOP ;IS IT 'RECORD STOP'? STOPTOK ;GRAPHICS RECORD FLAG 0 (OFF) ;SKIP 'RECORD'

;ERROR IF NUMERIC ;JR IN RUN TIME (ALLOWS STR ARRAYS TO BE DELETED) ;RET IF SIMPLE STRING, ELSE ERROR IF E.G. A$(3)

EX AF,AF' CALL NZ,ASDEL2 LD DE,STRM16NM CALL SCOPN1 LD A,D LD (GRARF),A CALL SCOPNM JR ASNS1

;IF FOUND, DELETE VAR PTED TO BY STRLOC ;COPY NAME TO STRM16NM.( MAY COPY 12 BYTES, ;HITTING GRARF - BUT IRREL) ;GRAPHICS RECORD FLAG=NZ (ON) ;EXIT WITH BC=0 (NULL LEN) ;ASSIGN NULL STRING TO NAME ;CREATE NEW VERSION FIRST SO E.G. LET A$=A$ WORKS ;HL PTS TO TEXT OF OLD STRING ;PT TO TLBYTE IN VARS

;ASSIGN STRING, THEN DELETE OLD STRING. E.G. LET A$=A$ OR LET A$=A$+"X" ASDEL: CALL ASNST CALL ADDRDEST LD DE,-14 ADD HL,DE CALL CHKPTR

2C56 2C58 2C58 2C58 2C58 2C5B 2C5B 2C5B 2C5B 2C5B 2C5E 2C5E 2C5F 2C62 2C63 2C66 2C67 2C68 2C69 2C6C 2C6C 2C6C 2C6C 2C6D 2C6E 2C6F 2C70 2C71 2C72 2C75 2C76 2C78 2C79 2C79 2C7A 2C7B 2C7B 2C7B 2C7B 2C7E 2C7E 2C80 2C81 2C84 2C85 2C86 2C87 2C89 2C89 2C8B 2C8B 2C8E 2C90 2C92 2C92 2C96 2C99 2C9B 2C9B 2C9B 2C9B 2C9C 2C9D 2CA1 2CA4 2CA6 2CA7 2CA8 2CAA 2CAA 2CAB 2CAE 2CAE 2CAF 2CB0 2CB1 2CB3 2CB6 2CB7 2CBA 2CBC 2CBD 2CBE 2CBF 2CC2 2CC5 2CC7 2CC7 2CCA 2CCD 2CCD 2CD0 2CD3 2CD3 2CD3 2CD3 2CD3 2CD6 2CD9 2CD9 2CDB 2CDE 2CDE

1806 CDDF3F ASDL1:

JR ASDEL3 ;CALLED BY DIM TO DELETE EXISTING ARRAYS OR STRINGS, WITH A=PAGE CALL SELURPG ;CALLED BY END PROC TO DELETE LOCAL STRINGS/ARRAYS, RECORD TO DELETE EXISTING ;STRING/ARRAY. ENTRY WITH STRLOCN PAGED IN

2ABC5B E5 010B00 09 CD6C2C 44 4D E1 C3531E 7E 23 5E 23 56 EB 010E00 09 CB74 C8 3C C9 CD011D E61F 67 3A8D5A 6F 7C BD 3812 2007 2A8E5A ED52 3009 ED537D5A 327F5A 3EFF F5 C5 ED53A35A 32A25A 3E0E 81 4F 3004 04 CA283A 78 07 07 E603 CD8E2F C1 CD433A DBFB 4F F1 3C 3AA25A 2AA35A 2006 3A7F5A 2A7D5A 32A45A C35E2A

ASDEL2: ASDEL3:

LD HL,(STRLOCN) PUSH HL LD BC,11 ADD HL,BC CALL ADD14 LD B,H LD C,L POP HL JP RECL2BIG LD A,(HL) INC HL LD E,(HL) INC HL LD D,(HL) EX DE,HL LD BC,14 ADD HL,BC BIT 6,H RET Z INC A RET ;PTR TO TLBYTE ;PT TO LEN (PAGES) ;PTR TO TLBYTE ;DELETE STR/ARRAY AND 14-BYTE HEADER (ABC AT HL)

;CALLED BY TAPEMN ADD14: ;LEN MOD 16K ;AHL=LEN (PAGES, LEN MOD 16K) ;ADD 14 TO GET LEN INCLUDING HDR ;RET IF MOD <16K

;ASSIGN A NEW STRING ASNST: CALL STKFETCH AND 1FH LD H,A LD A,(WKENDP) LD L,A LD A,H CP L JR C,ASNS1 JR NZ,ASNS0 LD HL,(WKEND) SBC HL,DE JR NC,ASNS1 ASNS0: LD (FIRST),DE LD (LAST),A LD A,0FFH PUSH AF PUSH BC LD (XPTR),DE LD (XPTRP),A LD A,14 ADD A,C LD C,A JR NC,ASNS2 INC B JP Z,STLERR ASNS2: LD A,B RLCA RLCA AND 03H CALL SAROOM POP BC CALL MBC IN A,(251) LD C,A POP AF INC A LD A,(XPTRP) LD HL,(XPTR) JR NZ,ASNS3 LD A,(LAST) LD HL,(FIRST) ASNS3: LD (XPTR+1),A JP FARLDIR ;PAGE SHOULD HAVE BIT 7 LOW - CANCEL XPTR ;LDIR PAGCOUNT/MODCOUNT BYTES ;DATA FOR STRING ASSIGNMENT

;JR IF SRC PAGE LOWER THAN WKEND ;JR IF SRC PAGE HIGHER ;JR IF SRC <=WKEND ;ELSE SRC>WKEND AND SHOULD NOT BE AUTO-ADJUSTED ;SIGNAL 'XPTR NOT USED'

;CALLED BY 'RECORD' TO CREATE NULL STRING ASNS1: ;STRING LEN ;SAVE START IN AUTO-ADJ VAR (MAKEROOM MAY MOVE IT) ;ALLOW FOR TYPE/NAME LEN (1) NAME (10), TXT LEN (3) ;ADD TO TEXT LEN TO GET ROOM NEEDED

;TOTAL LEN MUST NOT EXCEED FFFFH

;STRING LEN ;COPY PAG/MOD COUNT TO VARS ;CDE=DEST

;JR IF XPTR NOT USED

;ASSESS FOR-NEXT VAR (USED BY 'FOR' AND 'NEXT') CDDA14 F2290D CB69 C2290D 3013 SYNTAX4: CALL LVFLAGS JP P,NONSENSE BIT 5,C JP NZ,NONSENSE JR NC,SYNT41 ;ERROR IF STRING ;OR NUMERIC ARRAY NAME ;JR IF SYNTAX TIME

2CE0 2CE0 2CE1 2CE1 2CE3 2CE3 2CE5 2CE7 2CE7 2CE9 2CEA 2CEE 2CEE 2CF1 2CF3 2CF3 2CF3 2CF3 2CF3 2CF4 2CF4 2CF6 2CF6 2CF7 2CF7 2CF7 2CF7 2CFA 2CFA 2CFB 2CFB 2CFB 2CFB 2CFE 2D00 2D02 2D02 2D02 2D02 2D02 2D03 2D03 2D04 2D06 2D08 2D08 2D08 2D08 2D09 2D0A 2D0A 2D0A 2D0A 2D0D 2D0E 2D11 2D11 2D13 2D15 2D15 2D15 2D18 2D18 2D18 2D1B 2D1C 2D1F 2D1F 2D22 2D23 2D25 2D25 2D26 2D26 2D26 2D26 2D26 2D26 2D26 2D28 2D2A 2D2A 2D2E 2D31 2D34 2D35 2D36 2D37 2D38 2D39 2D3A 2D3B 2D3C 2D3D 2D40 2D40 2D40 2D40 2D43 2D43 2D43 2D43 2D46

08 2817 CB71 2013 DDE5 E1 DDCBFFEE CDD113 18EE ; ; 08 1804 E7 CDAA13 EB 21715C 3600 2008 SSYNTAX1: SYNTAX1: SYN14C: SYN1PP: SYNT41: ; SYN42:

EX AF,AF' JR Z,SYN14C BIT 6,C JR NZ,SYN14C PUSH IX POP HL SET 5,(IX-1) LD C,0FFH CALL NVMLP JR SYN42 LD C,0 DB 3EH EX AF,AF' JR SYN14C RST 20H CALL LOOKVARS EX DE,HL LD HL,FLAGX LD (HL),0 JR NZ,TSYNT12 ;IF FND, C=T/L FROM VARS, ELSE C=DESIRED T/L ;IF FND, DE PTS TO START OF NUMBER, OR LEN INFO OF ;STRINGS/ARRAYS (PAGE/LEN MOD 16K) ;VAR NOT NEW (BIT 0=0) ;JR IF VAR EXISTS, OR SYNTAX TIME ;ELSE C='DESIRED' TYPE, BITS 6 AND 5 ARE 0 ;IF SIMPLE UNSLICED STRING, OR A SIMPLE NUMBER ;USED BY LET/READ/INPUT TO ASSESS VAR ABOUT TO BE ASSIGNED TO. ;JR IF DOESN'T EXIST ;C IS FROM VARS ;JR IF (EXISTING) FOR-NEXT VAR ;ADDR OF PTR LSB ;TYPE BYTE MARKED AS 'UNUSED' ** BUG FIX ;'INVIS' AND 'UNUSED' - DON'T EXIST ;LOOP FOR ALL COPIES ;NON-ARRAY TYPE ;'JR+1'

;FROM PARAM PROCESSING

34 79 E660 281D CF 02 3A3B5C 87 F2152D CB69 2810 CD532D 3A3B5C 87 FA262D DC011D EB 1805 EB TSYNT14: TSYNT13: VNFERR:

INC (HL) LD A,C AND 60H JR Z,TSYNT14 RST 08H DB 2 LD A,(FLAGS) ADD A,A JP P,TSYNT13 BIT 5,C JR Z,TSYNT14 CALL STKVAR LD A,(FLAGS) ADD A,A JP M,TSYNT15 CALL C,STKFETCH EX DE,HL JR TSYN16 EX DE,HL

;'NEW VARIABLE' ;DESTP BIT 7 WILL BE 0 ('KEEP OLD VALUE') ;ERROR IF TRYING TO USE AN UNDIMED ARRAY, OR SLICE ;A NEW STRING.

;VAR EXISTS, OR SYNTAX TIME TSYNT12: ;P IF STRING, CY IF RUNNING ;JP IF STRING ;JR IF A SIMPLE NUMBER, NOT AN ARRAY ;ELSE STKVAR HANDLES NUMERIC ARRAYS ;PASS ARRAY/STRING DATA TO FPCS. EXIT WITH HL ;PTING TO VALUE, IF NUMERIC ARRAY, ELSE FPCS ;HOLDS STRING DETAILS ;CY IF RUNNING, -VE IF NUMERIC ;JP IF NUMERIC - HL PTS TO VALUE, PAGED IN ;GET DE=START, BC=LEN, A=PAGE (IN VARS). BIT 7=1 ;IF 'OLD COPY TO BE DELETED' AS IN 'LET A$="SS"'

;FOR NUMERICS AND NEW STRING/ARRAY VARS, STRLEN=TYPE/LEN FROM VARS AND JUNK; ;FOR EXISTING STRING/ARRAY VARS, STRLEN=LENGTH ; IF 'OLD COPY TO BE DELETED' BIT 7 OF DESTP=1 ; TLBYTE=REQUESTED TYPE/LEN, FIRLET=NAME DBFB E61F ED43725C 22A65A 32A55A 46 23 7E 3C B0 23 B6 23 B6 32B15A 116051 213F51 7E TSYNT15: TSYN16: IN A,(251) AND 1FH LD (STRLEN),BC LD (DEST),HL LD (DESTP),A LD B,(HL) INC HL LD A,(HL) INC A OR B INC HL OR (HL) INC HL OR (HL) LD (DFTFB),A LD DE,TLBYTE+33 LD HL,TLBYTE LD A,(HL) ;ADDRESS OF NUMERIC OR STRING VALUE, OR PTR/STOPPER ;PAGE OF STRING START, OR CURRENT PAGE IF NUMBER

;IF VAR STARTS 00 FF 00 00, A=0 ;IRREL IF NVAR NON-EXISTENT

;CALLED BY 'DIM' SCOPNM: SCOPN1: ;CALLED BY 'RECORD TO'

2D47 2D49 2D4B 2D4C 2D4C 2D4C 2D4C 2D4E 2D50 2D53 2D53 2D53 2D53 2D53 2D53 2D53 2D54 2D54 2D56 2D56 2D58 2D5A 2D5A 2D5C 2D5D 2D5D 2D5E 2D5E 2D5F 2D5F 2D5F 2D5F 2D62 2D64 2D66 2D66 2D69 2D69 2D69 2D69 2D69 2D6A 2D6C 2D6E 2D6E 2D6F 2D6F 2D70 2D70 2D72 2D74 2D74 2D77 2D79 2D7B 2D7B 2D7D 2D7F 2D7F 2D82 2D84 2D84 2D85 2D87 2D89 2D89 2D8C 2D8D 2D8D 2D8E 2D8E 2D91 2D91 2D91 2D91 2D91 2D92 2D94 2D96 2D96 2D96 2D97 2D98 2D99 2D9A 2D9B 2D9C 2D9D 2D9E 2DA0 2DA0 2DA1 2DA2 2DA4 2DA6 2DA8 2DA8 2DAA 2DAB 2DAB 2DAD 2DAE 2DAE

E61F C602 4F 0600 EDB0 C3D73F SCOPN2:

AND 1FH ADD A,2 LD C,A ;CALLED BY LENGTH SR LD B,0 LDIR JP SELCHADP

;NAME LEN-1 IF NUMERIC, TRUE NAME LEN IF STR/ARRAY ;ALLOW FOR TLBYTE AND (PERHAPS) ANOTHER LETTER

;COPY NAME TO BUFFER THAT WON'T BE USED BY EVAL

;FIND START AND LEN OF AN EXISTING STRING, OR START OF A NUMBER IN AN ARRAY ;ON ENTRY: DE PTS TO PAGES OF VAR LEN, THEN LENGTH MOD 16K. C=T/L. CY IF RUNNING ;CHAD POINTS PAST '$' OR '(' (UNLESS ERROR) EB 383B CB71 200F CB69 C8 FE E7 CDE43A FE2C 28F8 C3953A SVDSL: SVDSK: SVIBH: STKVAR: STKVAR2: EX DE,HL JR C,SVRUNT BIT 6,C JR NZ,SVSSL BIT 5,C RET Z DB 0FEH RST 20H N,N,...N) CALL EXPT1NUM CP "," JR Z,SVDSL JP INSISCBRK ;')' ;HL PTS TO PAGES OF LEN IF RUNNING ;JR IF RUNNING ;JR IF STRING ARRAY OR SLICED STRING ;RET IF SIMPLE UNSLICED STRING - NO ACTION ;CONTINUE WITH NUMERIC ARRAYS ;'JR+1'

;CALLED BY 'DIM' SYNTAX CHECK - CHECK

;CHECK STRING ARRAY SYNTAX; E.G. ), N,X TO Y) OR N,N,TO Y) OR N,N,Y TO) DF FE29 281F FE E7 FE8E 2810 CDE43A FE2C 28F4 FE8E 2805 CD953A 180A E7 FE29 2804 CD923A FE E7 C33E2E SVSL3: SLPXHP: SVSL2: SVSSLP: SVSSL: RST 18H CP ")" JR Z,SVSL3 DB 0FEH RST 20H CP TOTOK JR Z,SVSL2 CALL EXPT1NUM CP "," JR Z,SVSSLP CP TOTOK JR Z,SVSL2 CALL INSISCBRK JR SLPXHP RST 20H CP ")" JR Z,SVSL3 CALL EX1NUMCB DB 0FEH RST 20H JP SLLPEX ;SKIP 'TO' ;SKIP ')' IF IT IS ONE ;ELSE ACCEPT 'N)' ;'JR+1' ;SKIP ')' ;SET 'STRING' STATUS (DISTURBED BY 'EXPT1NUM') ;ALLOW '()' ;'JR+1'

;******************************************************************************* ;STACK VAR - RUN TIME 79 E660 2027 7E 23 4E 23 0F 0F B6 47 1680 EB 13 DBFB CB72 2803 CBB2 3C E61F B4 CDF01C SVSS2: SVSIMPLE: SVRUNT: LD A,C AND 60H JR NZ,SVARRAYS LD A,(HL) INC HL LD C,(HL) INC HL RRCA RRCA OR (HL) LD B,A LD D,80H EX DE,HL INC DE IN A,(251) BIT 6,D JR Z,SVSS2 RES 6,D INC A AND 1FH OR H CALL STKSTORE ;BIT 7 SET (DELETE OLD COPY) IF SIMPLE STRING ;BIT 7 RES (OVERWRITE) IF 1-DIM STRING ARRAY ;DE=ST, BC=LEN, A=START PAGE ;JR IF ARRAY, ELSE HANDLE SIMPLE STRING BY ;CONVERTING THE PAGE/LEN MOD 16K DATA IN VARS TO 2 ;BYTES (SIMPLE STRINGS HAVE LEN 0000-FFFF) ;PAGES (0-3)

;??00 0000 ;BC=LEN ;PT TO TEXT ;JR UNLESS STR. STARTED AT E.G. BFFF, PTR NOW C001

2DB1 2DB1 2DB4 2DB7 2DB9 2DBA 2DBA 2DBD 2DBD 2DBE 2DBF 2DC0 2DC1 2DC3 2DC5 2DC5 2DC7 2DC7 2DC8 2DC9 2DCA 2DCB 2DCC 2DCE 2DCE 2DD1 2DD3 2DD5 2DD5 2DD7 2DD8 2DD9 2DDA 2DDB 2DDC 2DDF 2DE0 2DE1 2DE1 2DE2 2DE3 2DE5 2DE6 2DE7 2DE8 2DE9 2DEA 2DEB 2DEC 2DEF 2DF2 2DF3 2DF6 2DF6 2DF9 2DF9 2DFC 2DFC 2DFD 2DFE 2DFF 2E00 2E01 2E01 2E02 2E03 2E04 2E05 2E07 2E07 2E09 2E0B 2E0B 2E0C 2E0D 2E0F 2E0F 2E0F 2E0F 2E11 2E13 2E13 2E14 2E16 2E17 2E18 2E19 2E1A 2E1B 2E1C 2E1D 2E20 2E21 2E22 2E25 2E28 2E29 2E2B 2E2D 2E2D 2E2F 2E31 2E31

;BIT 6,(FLAGS) IS CORRECT ALREADY CDD73F 3A3F51 CB77 C8 C3392E 23 23 23 46 CB69 2010 1007 50 23 4E 23 46 18D2 3A3F51 E640 2821 DBFB F5 C5 23 E5 AF CDDA1C E1 C1 F1 F5 D3FB C5 4E 23 46 23 E5 C5 CDD73F CDDD1C C1 CDA02F D2312E CDD61C EF 1C 00 01 33 D1 C1 DF 05 2808 FE2C 2026 E7 EB 18D2 CB69 2031 F1 D3FB EB 4E 23 46 23 EB C5 CD532E C1 EB CDE91C CDD73F DF FE29 2806 FE2C 2807 CF SWER2: SVEXLP: SVCKS: SVCDIS: SVARRAYS: CALL SELCHADP LD A,(TLBYTE) BIT 6,A RET Z JP SLCL2 INC HL INC HL INC HL LD B,(HL) BIT 5,C JR NZ,SVCDIS DJNZ SVCKS LD D,B INC HL LD C,(HL) INC HL LD B,(HL) JR SVSIMPLE LD A,(TLBYTE) AND 40H JR Z,SWERHP IN A,(URPORT) PUSH AF PUSH BC INC HL PUSH HL XOR A CALL STACKA POP HL POP BC POP AF PUSH AF OUT (URPORT),A PUSH BC LD C,(HL) INC HL LD B,(HL) INC HL PUSH HL PUSH BC CALL SELCHADP CALL STACKBC POP BC CALL GETSUBS JP NC,SWER2 CALL STACKHL DB DB DB DB DB CALC SWOP13 MULT ADDN EXIT ;TOTAL,DIM SIZE,SUBS VAL ;SUBS VAL,DIM SIZE,TOTAL ;TOTAL*DIM SIZE+SUBS VALUE ;ARRAY DATA PTR ;DIM COUNTER ;JR IF ALL DIMS DONE ;INSIST ON A COMMA NOW ;SKIP ',' ;HL PTS TO DIMN. DATA ;RET IF NO BRACKET AFTER NAME - NO SLICING

;NO. OF DIMS ;JR IF NUMERIC ARRAY ;JR IF MULTI-DIM STRING ARRAY (B=DIMS-1) ;D=0 SO BIT 7,A LEFT AS ZERO (SIGNALS 'OVERWRITE') ;BC=LEN OF SINGLE DIMENSION ($) ;HANDLE LIKE A SIMPLE STRING ;CHECK THAT SLICING WAS USED TO REFER TO MULTI-DIM ;STRING ARRAY ;ERROR IF NOT. ;PAGE OF ARRAY DIM DATA ;B=DIM COUNT (EXCLUDING FINAL DIM IF STRING) ;PT TO FIRST DIM SIZE ;ZERO TOTAL OF FPCS ;PTR TO DIMN. DATA IN BUFFER. ;B=DIMS (1 OR MORE, EXCLUDING LAST DIM IF STRING) ;PAGE IN DIMS ;DIM COUNTER IN B ;BC=NEXT DIM SIZE=LIMIT VALUE FOR SUBSCRIPT ;PTR TO DIMN. DATA ;DIM SIZE ;PAGE IN SUBSCRIPT ;DIM SIZE ;BC=DIM SIZE AGAIN ;GET SUBSCRIPT IN HL, CHECKING IT'S >0 AND <=LIMIT, ;THEN DECING IT. ;ERROR IF OUTSIDE LIMITS

SVLOOP:

SWERHP:

POP DE POP BC RST 18H DEC B JR Z,SVEXLP CP "," JR NZ,SWER2 RST 20H EX DE,HL JR SVLOOP BIT 5,C JR NZ,SVNUMER POP AF OUT (URPORT),A EX DE,HL LD C,(HL) INC HL LD B,(HL) INC HL EX DE,HL PUSH BC CALL SVSR POP BC EX DE,HL CALL STKST0 CALL SELCHADP RST 18H CP ")" JR Z,SVDIM CP "," JR Z,SLCL RST 08H

;PAGE OF ARRAY START IS ON STACK, DE=ADDR OF ARRAY START ;JR IF NUMERIC ARRAY ;PAGE IN DIMS ;ALLOW LAST SUBSCRIPT OR SLICER, FOR STRINGS

;DE PTS TO ARRAY START ;LAST SUBSCRIPT LEN ;GET START ADDR OF DESIRED STRING IN AHL ;STORE STRING ADDR, BIT 7,A=0 ('DON'T ERASE OLD') ;JR IF NO SLICE OF STRING SO FAR. E.G. A$(3) ;OK TO HAVE E.G. A$(3,2 TO 5) ;ANYTHING ELSE IS AN ERROR

2E32 2E33 2E33 2E34 2E36 2E38 2E38 2E39 2E39 2E3C 2E3E 2E3E 2E41 2E43 2E44 2E44 2E44 2E44 2E44 2E46 2E48 2E48 2E49 2E4C 2E4D 2E50 2E53 2E53 2E53 2E53 2E53 2E54 2E55 2E58 2E58 2E59 2E5A 2E5B 2E5B 2E5E 2E5F 2E60 2E61 2E63 2E65 2E65 2E66 2E66 2E69 2E69 2E69 2E6C 2E6F 2E6F 2E70 2E71 2E72 2E74 2E76 2E76 2E79 2E7A 2E7B 2E7E 2E80 2E82 2E82 2E85 2E86 2E87 2E89 2E8B 2E8B 2E8D 2E8D 2E8F 2E8F 2E90 2E91 2E93 2E93 2E94 2E96 2E97 2E98 2E99 2E9B 2E9B 2E9C 2E9F 2EA0 2EA2 2EA2 2EA3 2EA4 2EA6 2EA6 2EA7 2EA8 2EA9 2EAB 2EAD 2EAD

04 E7 FE28 2006 E7 CD692E 18F5 213B5C CBB6 C9 SVDIM: SLCL: SLCL2: SLLPEX:

DB 4 RST 20H CP "(" JR NZ,SLLPEX RST 20H CALL SLICING JR SVDIM LD HL,FLAGS RES 6,(HL) RET

;'Subscript wrong'

;SKIP '(' OR ','

;'STRING'

;END OF NUMERIC ARRAY FE29 20E9 E7 010500 F1 CD532E C3DF3F SVNUMER: CP ")" JR NZ,SWER2 RST 20H LD BC,5 POP AF CALL SVSR JP TSURPG ;SKIP ')' ;PAGE

;STACK BC (LAST DIMN. LEN, OR 5 FOR NUMBERS), MULT, ADD ARRAY 'TEXT' START ;EXIT WITH AHL=ADDR OF ELEMENT F5 D5 CDDD1C EF 00 33 CD8C3F D1 C1 48 CB72 2801 0C C3DE1F CDC63A DC011D F5 DF E1 FE29 2857 32CF5A D5 E5 110000 FE8E 2811 CDA02F EB DF FE8E 2808 FE29 20A2 62 6B 181A E7 FE29 60 69 2B 2812 D5 CDA02F D1 3804 7C B5 2816 E5 DF E1 FE29 20E0 ED52 SLSE2: SLSEC: NONSH: SVSR2: SLICING: SVSR: PUSH AF PUSH DE CALL STACKBC DB CALC DB MULT DB EXIT CALL UNSTLEN POP DE POP BC LD C,B BIT 6,D JR Z,SVSR2 INC C JP ADDAHLCDE CALL RUNFLG CALL C,STKFETCH PUSH AF RST 18H POP HL CP ")" JR Z,SLSTORE LD (TEMPB2),A PUSH DE PUSH HL LD DE,0 CP TOTOK JR Z,SLSEC CALL GETSUBS EX DE,HL RST 18H CP TOTOK JR Z,SLSEC CP ")" JR NZ,SWER2 LD H,D LD L,E JR SLDEF RST 20H CP ")" LD H,B LD L,C DEC HL JR Z,SLDEF PUSH DE CALL GETSUBS POP DE JR C,SLSE2 LD A,H OR L JR Z,SLND PUSH HL RST 18H POP HL CP ")" JR NZ,NONSH SBC HL,DE ;WAS NONS ;LAST NUMB=FIRST NUMB IF EG (5) ;JR WITH NUMBERS IN HL AND DE ;GET ADE=START, BC=LEN, IF RUNNING ;PAGE ;H=PAGE ;JR IF SLICE WAS () (ENTIRE STRING) ;NZ SHOWS NO ERROR IN SUBSCRIPT YET ;STRING START ;H=PAGE OF START ;DEFAULT SLICER START ;JR IF E.G: ( TO X) - USE DE=1 ;ELSE EVAL E.G. S OF (S TO T) USING BC AS LIMIT ;DE=SUBS. VAL, CHECKED >0 AND <=LEN, THEN DECED ;WE HAVE FIRST NUMBER IN DE - JR IF 'TO' FOLLOWS IT ;PAGE OF ARRAY START ;ARRAY START ;TOTAL, LAST DIM SIZE ;DISP TO ELEMENT WANTED ;AHL=PAGES/ MOD 16K FORM ;CDE=ADDR OF TEXT START (8000-C???) ;JR IF PAGE OK ;ELSE INC PAGE (ADDAHLCDE IGNORES BIT 6)

;HL=LEN-1 (VALUES ALL USE 'DECED' FORM) ;JR IF EG (X TO ) OR ( TO ) - USE LEN AS 2ND NUMB. ;FIRST NUM ;EVAL SECOND NUMBER, CHECKING >0, <=LEN, DECING ;FIRST NUMBER ;JR IF IN RANGE OR SYNTAX TIME ;NULL STRING, NOT ERROR, IF E.G. (2 TO 0) ;SECOND NUMB IN HL, FIRST IN DE ;SUB 2ND,1ST (NC HERE)

SLDEF:

2EAF 2EB2 2EB4 2EB4 2EB7 2EB8 2EBB 2EBB 2EBC 2EBC 2EBD 2EBE 2EBE 2EBF 2EC0 2EC1 2EC4 2EC6 2EC8 2EC8 2ECA 2ECB 2ECB 2ECC 2ECD 2ECD 2ED0 2ED2 2ED5 2ED6 2ED7 2ED7 2ED8 2EDB 2EDB 2EDB 2EDB 2EDE 2EE0 2EE1 2EE2 2EE5 2EE6 2EE9 2EEB 2EEE 2EEE 2EF1 2EF3 2EF3 2EF6 2EF6 2EF8 2EF9 2EF9 2EFA 2EFC 2EFC 2EFD 2EFE 2F01 2F01 2F04 2F05 2F07 2F0A 2F0C 2F0C 2F0E 2F0E 2F11 2F12 2F12 2F13 2F13 2F16 2F17 2F18 2F19 2F1C 2F1C 2F1D 2F1E 2F1F 2F1F 2F20 2F21 2F22 2F24 2F26 2F26 2F29 2F29 2F2A 2F2B 2F2D 2F2E 2F2F 2F32 2F32 2F33 2F34 2F35

010000 380A 3ACF5A A7 CA312E 23 44 4D F1 E1 19 DCA41F CB74 2803 CBB4 3C EB 67 3A3B5C E6BF 323B5C 17 D0 7C C3E91C ;DIM.SAM CDAA13 DBFB 08 C5 CD402D C1 3A3F51 E660 CA290D CDC63A 3809 CD5F2D FE2C C0 E7 18DF 08 C5 C4582C CDD73F C1 CB69 010100 2802 0E05 CDDD1C FE E7 CDA02F 23 E5 C5 CDD61C EF 00 33 C1 04 DF FE2C 28EC CD953A C5 68 2600 29 23 CDD61C EF 06 25 1C DIM4: DIMSZLP: DIMRUN: DIM2: DIM: SLDF2: SLSTORE: SLND: SLNUL:

LD BC,0 JR C,SLNUL LD A,(TEMPB2) AND A JP Z,SWER2 INC HL LD B,H LD C,L POP AF POP HL ADD HL,DE CALL C,PGOA BIT 6,H JR Z,SLDF2 RES 6,H INC A EX DE,HL LD H,A LD A,(FLAGS) AND 0BFH LD (FLAGS),A RLA RET NC LD A,H JP STKST0 CALL LOOKVARS IN A,(URPORT) EX AF,AF' PUSH BC CALL SCOPNM POP BC LD A,(TLBYTE) AND 60H JP Z,NONSENSE CALL RUNFLG JR C,DIMRUN CALL SVDSK CP "," RET NZ RST 20H JR DIM EX AF,AF' PUSH BC CALL NZ,ASDL1 CALL SELCHADP POP BC BIT 5,C LD BC,1 JR Z,DIM4 LD C,5 CALL STACKBC DB 0FEH RST 20H CALL GETSUBS INC HL PUSH HL PUSH BC CALL STACKHL DB CALC DB MULT DB EXIT POP BC INC B RST 18H CP "," JR Z,DIMSZLP CALL INSISCBRK PUSH BC LD L,B LD H,0 ADD HL,HL INC HL CALL STACKHL DB DB DB DB CALC SWOP DUP SWOP13

;NUL LEN IF EG (5 TO 2)

;BC=STR LEN ;STRING START IN AHL (HL=8000-BFFF) ;ADD START, FIRST SLICER NUMBER-1 (DEFAULT=0) ;ADJUST FOR PAGE OVER FLOW IF NEEDED

;ADE=SLICER START, BC=LEN

;'STRING' ;RET IF NOT RUNNING ;PAGE ;STACK STRING, 'NO DELETE OF OLD'

;PAGE OF STRING/ARRAY IF FOUND ;SAVE NZ IF FOUND ;CHADP BACK IN NOW ;C=TYPE BYTE OF ARRAY ;TYPE BYTE FOR DIM NAME (VARS MAY HOLD STRING) ;ERROR IF NO OPENING BRACKET USED ;JR IF RUNNING ;CHECK N,N,...N) ;RET UNLESS ANOTHER ARRAY FOLLOWS ;SKIP ',' ;ALLOW 'DIM A(8),B(6,5),A$(2)' ETC. ;PAGE OF STRLOCN ;TYPE BYTE SAVED IN C ;DELETE ARRAY POINTED TO BY STRLOCN IF IT EXISTS ;C=TYPE/LEN BYTE ;JR IF A STRING ARRAY OR STRING FOUND IN VARS ;ON EXIT B STILL=0...DIM COUNT ;'JR+1' ;SKIP ',' ;GET SUBS-1 IN HL ;STACK DIM SIZE ON MACHINE STACK BEHIND DIM COUNTER ;AND ON FPCS ;GET E.G. 5*DIM1*DIM2 OR 1*DIM1 ;INC DIM COUNTER

;')' ;B=DIMS ;HL=DIMS ;GET SPACE NEEDED BY WORD DIM SIZE INFO, PLUS 1 ;FOR NO. OF DIMS ;'TEXT' SIZE, DIM INFO SIZE ;DIM INFO SIZE, 'TEXT' SIZE ;DIS, TS, TS ;TS, TS, DIS

2F36 2F37 2F38 2F39 2F3A 2F3B 2F3C 2F3C 2F3F 2F42 2F42 2F43 2F46 2F47 2F48 2F49 2F4A 2F4B 2F4C 2F4D 2F4E 2F4F 2F50 2F51 2F53 2F54 2F55 2F56 2F57 2F57 2F58 2F59 2F5A 2F5B 2F5C 2F5D 2F5F 2F5F 2F60 2F63 2F66 2F67 2F68 2F69 2F6A 2F6B 2F6C 2F6D 2F6E 2F70 2F70 2F71 2F71 2F74 2F76 2F78 2F7A 2F7A 2F7B 2F7B 2F7E 2F7E 2F7F 2F80 2F82 2F82 2F83 2F84 2F85 2F87 2F87 2F8A 2F8B 2F8E 2F8E 2F8E 2F8F 2F92 2F93 2F96 2F97 2F9A 2F9D 2F9F 2FA0 2FA0 2FA0 2FA0 2FA1 2FA4 2FA6 2FA6 2FA7 2FA8 2FA8 2FA8 2FA8 2FA8 2FA8 2FA8 2FA8 2FA8 2FAB

01 25 26 0E 01 33 CD8C3F CD8E2F D5 CD8C3F EB E1 77 23 73 23 72 23 F1 77 5F 1600 19 19 54 5D C1 70 2B 71 2B 3D 20F8 D5 CD8C3F CD2120 D1 EB 23 43 5A 57 78 A7 2801 13 3A6051 E640 0E20 2001 4F CDEF3F 71 23 10FC 1B 7A B3 20F4 CDD73F DF C3F62E F5 CDB61F F1 CD1C1E EB 216051 010B00 EDB0 C9 C5 CDE43A 3802 C1 C9 SAROOM: GARC: DIMCLP: DIMNAC: DIMENTLP:

DB DB DB DB DB DB

ADDN DUP ONELIT 14 ADDN EXIT

;TS, TS+DIS ;TS, TS+DIS, TS+DIS ;TS, TS+DIS, TS+DIS, 14 ;TS, TS+DIS, TS+DIS+14 ;ARRAY 'TEXT' SIZE, SIZE LESS HDR, TOTAL ARRAY SIZE ;GET ABC=TOTAL LEN (PAGE FORM) ;OPEN ABC BYTES AT END OF SAVARS, LDIR T/L BYTE, ;NAME TO START, EXIT WITH DE PTING TO PAST NAME ;SIZE EXCLUDING 14-BYTE HEADER ;ADE=SIZE INFO FOR AFTER 14-BYTE HDR ;PAGES ;LEN MOD 16K ;DIM COUNT ;PT TO LOCN FOR MSB OF LAST DIM ;SAVE IT IN DE TOO ;POP A DIM SIZE ;ENTER IT IN ARRAY HEADER ;(DIM SIZES COME OFF STACK IN REVERSE ORDER)

CALL UNSTLEN CALL SAROOM PUSH DE CALL UNSTLEN EX DE,HL POP HL LD (HL),A INC HL LD (HL),E INC HL LD (HL),D INC HL POP AF LD (HL),A LD E,A LD D,0 ADD HL,DE ADD HL,DE LD D,H LD E,L POP BC LD (HL),B DEC HL LD (HL),C DEC HL DEC A JR NZ,DIMENTLP PUSH DE CALL UNSTLEN CALL AHLNORM POP DE EX DE,HL INC HL LD B,E LD E,D LD D,A LD A,B AND A JR Z,DIMNAC INC DE LD A,(TLBYTE+33) AND 40H LD C," " JR NZ,GARC LD C,A CALL CHKHL LD (HL),C INC HL DJNZ DIMCLP DEC DE LD A,D OR E JR NZ,GARC CALL SELCHADP RST 18H JP DIM2 PUSH AF CALL ADDRELND POP AF CALL MKRBIG EX DE,HL LD HL,TLBYTE+33 LD BC,11 LDIR RET PUSH BC CALL EXPT1NUM JR C,GTSBC POP BC RET

;GET LEN-TO-CLEAR AS 19-BIT NUMBER ;ADE=19 BIT NO. ;HL PTS TO START OF AREA TO CLEAR ;B=LEN MOD 256 ;DE=256-BYTE PAGES

;INC DE (UNLESS B=0). ALLOWS B AND DE TO ACT AS ;SEPARATE COUNTERS. DE IS *NEVER* ZERO ;Z IF NUMERIC ;JR IF STR ARRAY, C=' ' FOR CLEARING ARRAY ;USE ZERO TO CLEAR NUMERIC ARRAYS ;CHECK WE ARE IN 8000-BFFF AREA

;ADDRESS ELINE AND DEC PTR - PT TO END OF SAVARS ;OPEN ABC BYTES (PAGE FORM) AT (HL) ;DE PTS TO ROOM ;COPY TYPE/LEN AND NAME TO SAVARS

;ENTRY: CHAD PTS TO A SUBSCRIPT VALUE. BC=LIMIT GETSUBS:

;JUST CHECK FOR A NUMBER IN SYNTAX TIME

;ENTRY: CHAD PTS TO A SUBSCRIPT VALUE. RUN TIME! ;ACTION: GET A SUBSCRIPT VALUE IN HL, CHECKING IT IS <= LIMIT IN BC, AND <>0 ;BC AND DE UNCHANGED. HL DECED BEFORE RETURN ;GTSUBS: ; CD2E1D C1 GTSBC: PUSH BC CALL EXPT1NUM CALL GETINT POP BC ;IN HL, A=L ;LIMIT VALUE

2FAC 2FAD 2FAF 2FAF 2FB0 2FB2 2FB3 2FB4 2FB4 2FB5 2FB8 2FB9 2FB9 2FB9 2FB9 2FB9 2FB9 2FBC 2FBE 2FBF 2FBF 2FC2 2FC2 2FC5 2FC5 2FC7 2FCA 2FCB 2FCB 2FCC 2FCF 2FD0 2FD2 2FD2 2FD2 2FD2 2FD2 2FD2 2FD5 2FD8 2FDB 2FDC 2FDD 2FDE 2FDE 2FDF 2FE0 2FE1 2FE1 2FE2 2FE5 2FE5 2FE7 2FEA 2FEC 2FEC 2FED 2FEE 2FF1 2FF4 2FF5 2FF7 2FF7 2FF9 2FFB 2FFC 2FFD 2FFE 2FFF 3000 3001 3004 3005 3007 3007 3007 3007 3008 3009 3009 300C 300C 300E 3011 3012 3012 3013 3016 3017 3019 3019 3019 301C 301D 301F 301F 3022 3023 3024 3025 3028 302B 302D

B4 2805 2B ED42 09 D8 AF 32CF5A C9 SWSIG:

OR H JR Z,SWSIG DEC SBC ADD RET HL HL,BC HL,BC C

;SUBSCRIPT 0 IS ALWAYS AN ERROR ;REDUCE BY 1 TO GIVE ALLOWED RANGE 0 TO LIMIT-1 ;IF BC=FFFF, 1-FFFF IS OK

XOR A LD (TEMPB2),A RET ;DEF FN, FN, COMPILE, DEF PROC, LOCAL, PROC

INCLUDE FN.SAM ;FN.SAM ;COMPILE DEF PROCS 3A765A FE01 3F DCD22F CD1930 16FD CD4C30 D8 C5 CDCC30 C1 18F3 ELCOMAL: COMALL: COMDP: CMDPL: LD A,(REFFLG) CP 1 CCF CALL C,COMDF CALL COMLEN LD D,0FDH CALL LKCALL RET C PUSH BC CALL LOOKDP POP BC JR CMDPL

;CY IF ZERO ;CY IF NZ (FN USED) ;COMPILE FNS ;SWITCH IN PROG, GET BC AND B' AS PROG OR ELINE LEN ;LOOK FOR PROC CALLING BUFFER FROM HL ONWARDS ;RET IF NO MORE ;ELSE HL POINTS TO BUFFER, PAGED IN ;BYTES LEFT ;LOOK FOR DEF PROC name, ALTER CALLING BUFFER TO ;PAGE/ADDR IF FOUND, ELSE FLAG AS 'NO DEF PROC'

;COMPILE DEF FNS ;FIRST, DO A PASS TO MAKE A TABLE OF ALL DEF FNS AS PAGE/ADDR; LOOKING ;THROUGH THE PROGRAM EACH TIME IS TOO SLOW. 21004F 22C85A CD321F 7E 3C C8 23 23 23 23 22975A 1EC8 CD9C1D 301D EB 1B 2AC85A 0103AF 09 3810 ED42 DBFB 77 23 73 23 72 23 22C85A EB 18DA CF 34 CD1930 16FE CD4C30 D8 C5 CDAA30 C1 18F3 3A405B 17 380E CD351F E5 EB 4F 2A915A 3A905A 180C COMLEN: TMDERR: CMDF2: CMDFL: DFPPL: COMDF: LD HL,INSTBUF LD (TEMPW1),HL CALL ADDRPROG LD A,(HL) INC A RET Z INC HL INC HL INC HL INC HL LD (CHAD),HL LD E,0C8H CALL SRCHPROG JR NC,CMDF2 ;CHAD STARTS AT 1ST CHAR OF FIRST LINE, LATER ;IS RESET TO JUST AFTER EACH DEF FN FOUND ;DEFFNTOK ;LOOK FOR DEF FN FROM CHAD ON ;JR IF ALL DONE ;ELSE HL POINTS PAST 'DEF FN' ;INIT PTR TO TABLE STORE ;SWITCH IN PROG ;RET IF NO PROGRAM

EX DE,HL DEC DE ;DE PTS TO 'DEF FN' LD HL,(TEMPW1) LD BC,-INSTBUF-509 ADD HL,BC JR C,TMDERR ;'Too many definitions' IF PTR >=INSTBUF+509 ;ALLOWS UP TO 170 DEF FNS. SBC HL,BC IN A,(251) LD (HL),A INC HL LD (HL),E INC HL LD (HL),D INC HL LD (TEMPW1),HL EX DE,HL JR DFPPL ;USED BY 'DEF FN' COMPILER AND 'DEF KEYCODE' RST 08H DB 52 CALL COMLEN LD D,0FEH CALL LKCALL RET C PUSH BC CALL LOOKDF POP BC JR CMDFL LD A,(COMPFLG) RLA JR C,PRGLEN CALL ADDRELN PUSH HL EX DE,HL LD C,A LD HL,(WORKSP) LD A,(WORKSPP) JR CPLENC ;'Too many definitions' ;SWITCH IN PROG, GET BC AND B' AS PROG OR ELINE LEN ;LOOK FOR CALLING BUFFER FROM HL ONWARDS ;RET IF NO MORE ;ELSE HL POINTS TO BUFFER, PAGED IN ;PROG LEN LEFT (MOD 16K) ;LOOK FOR DEF FN name, ALTER CALLING ;BUFFER TO PAGE/ADDR IF FOUND, OR FLAG 'NO DEF FN'

;JR IF PROGRAM BEING COMPILED ;ELSE IT IS ELINE ;ELINE ;CDE=ELINE

302D 302D 302D 3030 3031 3032 3033 3036 3039 3039 303C 303D 303E 303F 3040 3041 3042 3043 3044 3045 3046 3047 3049 304A 304B 304C 304C 304C 304C 304C 304C 304C 304C 304C 304C 304C 304C 304C 304D 304E 3050 3050 3051 3053 3055 3055 3056 3058 3058 3059 305A 305C 305D 305F 305F 3060 3061 3063 3063 3064 3065 3066 3067 3068 306A 306A 306B 306C 306D 306E 3070 3070 3070 3071 3072 3073 3074 3077 3077 3078 3079 307A 307C 307E 307E 3081 3083 3083 3083 3084 3086 3086 3087 3089 308B 308B 308C 308D 308D 308E 3091 3092 3093

;SWITCH IN PROG, GET B'=8K BLOCKS IN PROG LEN, PLUS 1, BC=LEN MOD 8K CD321F E5 EB 4F 2A885A 3A875A CDE71F E5 29 29 29 17 D9 3C 47 D9 C1 78 E61F 47 E1 C9 PRGLEN: CALL ADDRPROG PUSH HL EX DE,HL LD C,A LD HL,(NVARS) LD A,(NVARSP) CALL SUBAHLCDE PUSH HL ADD HL,HL ADD HL,HL ADD HL,HL RLA EXX INC A LD B,A EXX POP BC LD A,B AND 1FH LD B,A POP HL RET ;PROG ;CDE=PROG ;GET PROG LEN (PAGE FORM)

CPLENC:

;A=8K BLOCKS

;BC=LEN MOD 8K ;PROG

;LKCALL - LOOK FOR PROC OR FN CALL BUFFER ;BY CHECKING FOR NOT-0E 0E FD/FE FD/FE PG+80H/ADDR/LETTER. ;NO CONFUSION WITH NORMAL 0E FORMS BECAUSE THOSE ARE NOT FOLLOWED BY A LETTER, ;OR PRECEDED BY 0EH. ;NO CONFUSION WITH LINE NUMBERS BECAUSE 0E FE FE 80 = LINE LEN >32768! ;ENTRY: HL=START OF SEARCH, D=TARGET (FD/FE=PROC/FN), BC=LEN TO SEARCH, MOD 8K ;B'=8K BLOCKS (ALLOWS ROOM AFTER TARGET FOUND, TO INCREMENT PTRS) ;EXIT: HL POINTS TO LOCN FOR 'PAGE' IN CALLING BUFFER, BUFFER HOLDS LEN/NAME ;OF CALLING NAME, IF NC, ELSE CY SHOWS NO TARGETS FOUND. 78 B1 284E 7A EDB1 2049 BE 20F4 2B 2B 3E0E BE 2804 23 23 18E9 2B BE 23 23 23 28E2 23 7E 2B 17 30DC E5 C5 2B 2B 01FF00 2B 0C 7E FE24 28F9 CD413B 38F4 3C 2007 7A FEFD 2802 23 0D 23 114051 79 3D E61F LPC4: FDFLP: LPC2: LPC3: LKCALL: LD A,B OR C JR Z,LPC5 LD A,D CPIR JR NZ,LPC5 CP (HL) JR NZ,LKCALL DEC HL DEC HL LD A,0EH CP (HL) JR Z,LPC3 INC HL INC HL JR LKCALL DEC HL CP (HL) INC HL INC HL INC HL JR Z,LKCALL INC HL LD A,(HL) DEC HL RLA JR NC,LKCALL PUSH HL PUSH BC DEC HL DEC HL LD BC,00FFH DEC HL INC C LD A,(HL) CP "$" JR Z,FDFLP CALL ALNUMUND JR C,FDFLP INC A JR NZ,LPC4 LD A,D CP 0FDH JR Z,LPC4 INC HL DEC C INC HL LD DE,NMBUFF LD A,C DEC A AND 1FH ;JR IF TIME FOR NEXT BLOCK ;FE IF FN BUFFER WANTED, FD IF PROC CALL BUFFER ;JR IF FD/FE NOT FOUND (BC=0) ;CHECK FOR SECOND FDH/FEH ;KEEP LOOKING IF RED HERRING

;THERE SHOULD BE A PRECEDING 0EH

;IF THERE IS NOT, CONTINUE SEARCH ;THERE SHOULD ONLY BE *ONE* PRECEDING 0EH ;(EXCLUDE SPURIOUS 0E 0E FE FE 80 41, SAY) ;LOOP BACK IF SPURIOUS (JUST AN ODD NUMBER) ;PT TO PROBABLE PAGE ;TO SECOND FD/FE AGAIN ;JR IF NOT 0E FE FE (>=80H). ;(AT SYNTAX CHECK, CALLING BUFFER IS CREATED WITH ;'PAGE' FD OR FEH) ;PTR TO SECOND FD/FE ;LEN LEFT TO SEARCH FOR OTHER BUFFERS ;FIRST FD/FE ;0EH ;NAME LEN WILL INC TO ZERO START VALUE. B=0 ;NAME LEN ;NAME CAN END IN '$' ;CHECK FOR VALID NAME CHARS (ALPHA-NUMERICS OR '_') ;LOOP BACK PAST THE NAME, TO THE FFH FN LEADER, ;SPACE, CC, MSB OF LINE LEN OR ':', OR FFH AT ;SAVARS END (IF PROC) ;JR IF NOT FF 42 ('FN') ;JR IF PROC ;SKIP FFH ;DEC LEN BECAUSE OF FALSE INCLUSION OF 42H ;PT TO FIRST NAME CHAR ;** ;**

3095 3096 3097 3098 3099 309B 309C 309D 309E 309E 30A0 30A3 30A4 30A5 30A6 30A8 30A9 30AA 30AA 30AA 30AA 30AA 30AB 30AD 30AE 30B1 30B1 30B5 30B6 30B8 30B9 30BB 30BB 30BC 30BD 30BE 30BF 30C0 30C1 30C3 30C4 30C7 30C8 30CA 30CA 30CC 30CC 30CC 30CC 30CC 30CC 30CC 30CC 30CC 30CD 30CF 30D0 30D3 30D4 30D4 30D5 30D5 30D8 30DB 30DD 30DD 30DD 30DD 30DE 30DF 30E3 30E6 30E7 30E8 30EA 30EA 30EB 30EC 30ED 30EE 30EF 30EF 30F1 30F1 30F3 30F5 30F6 30F7 30F8 30F8 30FA 30FA 30FB 30FD 30FE 30FF 3100 3101 3102 3103 3104 3105 3106

3C 4F 12 13 EDB0 C1 E1 C9 0620 CDEF3F D9 05 D9 20A4 37 C9 LPC5:

INC A LD C,A LD (DE),A INC DE LDIR POP BC POP HL RET LD B,20H CALL CHKHL EXX DEC B EXX JR NZ,LKCALL SCF RET

;** LIMIT LDIR LEN ;** ;LEN AT BUFFER START ;COPY NAME TO BUFFER+1 ;BYTES LEFT ;PTR TO SECOND FD/FE (WHERE CPIR HALTED) ;C=0. DO ANOTHER 8K. (IF BLOCKS NOT ZERO YET)

;DO B' BLOCKS ;NO MORE CALLING BUFFERS

;LOOK DEF FN ;LOOK FOR 'DEF FN' FOLLOWED BY A SPECIFIC NAME, AND PATCH FN CALL BUFFER E5 DBFB F5 21004F ED4BC85A A7 ED42 09 303D 7E 23 5E 23 56 23 D3FB E5 CD1331 E1 38E7 1823 LOOKDF: PUSH HL IN A,(251) PUSH AF LD HL,INSTBUF LD BC,(TEMPW1) AND A SBC HL,BC ADD HL,BC JR NC,LKDP4 LD A,(HL) INC HL LD E,(HL) INC HL LD D,(HL) INC HL OUT (251),A PUSH HL CALL MATCHER POP HL JR C,LKDFLP JR LKDP3 ;CALLING BUFFER ADDR (SECOND FD/FE) ;CALLING BUFFER PAGE ;START OF TABLE OF PAGE/ADDR FOR EACH DEF FN ;END OF TABLE (PAST LAST ENTRY) ;NC IF PTR HAS REACHED END ;JR IF ALL TABLE ENTRIES TRIED WITHOUT SUCCESS. ;MARK BUFFER 'NO DEF FN' ;PORT VALUE

LKDFLP:

;MATCH DE+1 VS. BUFFER ;LOOP IF MATCH FAILED ;ELSE JR AND PATCH BUFFER

;LOOK DEF PROC ;LOOK FOR 'DEF PROC' FOLLOWED BY A SPECIFIC NAME, AND PATCH PROC CALL BUFFER ;AT HL WITH PAGE/ADDR OF ADDR AFTER NAME, OR PAGE FFH IF NOT FOUND ;ENTRY: NAME LEN IS IN BUFFER, FOLLOWED BY NAME. HL POINTS TO PROC CALL BUFFER, ;SWITCHED IN E5 DBFB F5 CD321F FE 19 01CA21 CD3C34 381B D5 E5 ED5B975A CD1331 E1 D1 38EA 2B 2B 2B 2B EB 0680 DBFB E61F B0 47 21 06FF F1 D3FB E1 E5 23 70 23 73 23 72 E1 C9 LKDP3: LKDP35: LOOKDP: PUSH HL IN A,(251) PUSH AF CALL ADDRPROG DB 0FEH ADD HL,DE LD BC,2100H+0CAH CALL LKFC JR C,LKDP4 PUSH DE PUSH HL LD DE,(CHAD) CALL MATCHER POP HL POP DE JR C,LKDPLP DEC HL DEC HL DEC HL DEC HL EX DE,HL LD B,80H IN A,(251) AND 1FH OR B LD B,A DB 21H LD B,0FFH POP AF OUT (251),A POP HL PUSH HL INC HL LD (HL),B INC HL LD (HL),E INC HL LD (HL),D POP HL RET ;CALLING BUFFER ADDR ;CALLING BUFFER PAGE ;START AT (PROG) ;'JR +1' ;PT TO START OF NEXT LINE ;DEFPROCTOK ;LOOK FOR A DEF PROC AT LINE STARTS ;JR IF NONE FOUND - MARK BUFFER 'NO DEF PROC' ;ELSE HL PTS TO FIRST CHAR IN LINE, ;CHAD PTS TO 'DEF PROC' ;LEN OF TEXT ;START OF TEXT IN THIS LINE ;MATCH (DE+1) VS. (BUFFER+1) ;JR IF FAILED TO MATCH

LKDPLP:

;ELSE PT DE TO LINE START

;B=PAGE WITH DEF PROC NAME, BIT 7 SET ;'JR+2' ;'NO DEF PROC/DEF FN' ;BACK TO PROC CALL PAGE ;PAGE ;ADDR OF PAST NAME OR LINE START (OR JUNK IF B=FF) ;PTR TO SECOND FD/FE (WHERE CPIR STOPPED)

LKDP4:

3107 3107 3107 3107 3107 310A 310A 310A 310A 310B 310C 310E 310F 3110 3111 3113 3113 3113 3113 3113 3113 3113 3113 3116 3117 3118 3118 3119 3119 311A 311C 311E 311E 311F 3120 3122 3123 3124 3124 3126 3126 3127 3128 312B 312B 312B 312B 312B 312B 312B 312E 3131 3131 3132 3134 3134 3135 3136 3138 3138 3139 313A 313B 313D 313F 313F 3140 3141 3142 3143 3146 3147 3149 314B 314B 314E 3150 3152 3152 3153 3154 3154 3155 3155 3156 3157 3158 315B 315B 315C 315E 3160 3160 3161 3162 3164 3164 3165 3166 3166 3167 3168 3168

;MATCH (HL) VS (FIRLET) OVER T/L+1 BYTES (NAMELEN) ;EXIT AS MATCHER - NOTE *DE* PTS PAST NAME 113F51 EB 7E E61F 3C 47 23 1806 MATCHERF: MATCHFN: LD DE,TLBYTE EX DE,HL LD A,(HL) AND 1FH INC A LD B,A INC HL JR MTCCM ;CALLED BY FOR WITH DE=TLBYTE+33

;B=NAME LEN

;MATCH NAME AT (DE+1) VS NAME AT BUFFER+1 OVER (BUFFER) BYTES. SPACES IN ;(DE+1) NAME IRRELEVANT (BUT PROC AND FN NAMES HAVE NO SPACES). SPACES ;SHOULD NOT BE PRESENT IN BUFFER NAME. ;EXIT: NC IF MATCHED OK, DE PTS PAST CANDIDATE NAME, HL PAST BUFFER NAME ;USES HL, B, A. MOVES DE 214051 46 23 13 1A FE20 28FA AE 23 E6DF 37 C0 10F2 13 1A C3413B MATCHER: MSKIP: MTCCM: LD HL,NMBUFF LD B,(HL) INC HL INC DE LD A,(DE) CP 20H JR Z,MSKIP XOR INC AND SCF RET (HL) HL 0DFH NZ ;SKIP ANY SPACES IN CANDIDATE NAME ;MIGHT BE USED BY PROC SRS??!! ;IGNORE CASE MISMATCH. ;RET IF FAILED (CY) ;MATCH B SIGNIF. CHARS ;WE MATCHED OK SO FAR - BUT CANDIDATE NAME MUST ;END NOW - GET CY IF NOT TERMINATED ;NAME WE ARE LOOKING FOR IS AT BUFFER+1 ;NAME LEN

DJNZ MSKIP INC DE LD A,(DE) JP ALNUMUND

;FN HANDLING (CALLED BY EVALUATOR) ;E.G. PRINT FN OCTAL(345) ; PRINT FN OCTAL 0E FE FE PG+80H ADDRL ADDRH (345 0E 1 2 3 4 5) ; PAGE AND ADDR ARE PTR TO '(' OR '=' IN DEF FN CDC63A D2FF31 E7 3E0E BE 23 20FC 23 23 46 CB68 2027 23 5E 23 56 22975A E7 FE28 200A CDBC33 FE29 2002 E7 E7 BF 08 EB 78 CDDF3F 7E D63D 2008 F5 08 205D CF 1A CF 07 08 PARAMERR: MDFERR: FNBC: FNBF: FNBF2: FNRL: IMFN: CALL RUNFLG JP NC,FNSYN RST 20H LD A,0EH CP (HL) INC HL JR NZ,FNRL INC HL INC HL LD B,(HL) BIT 5,B JR NZ,MDFERR INC HL LD E,(HL) INC HL LD D,(HL) LD (CHAD),HL RST 20H CP "(" JR NZ,FNBF2 CALL FORESP CP ")" JR NZ,FNBF RST 20H RST 20H CP A EX AF,AF' EX DE,HL LD A,B CALL TSURPG LD A,(HL) SUB "=" JR NZ,FNBC PUSH AF EX AF,AF' JR NZ,FNR6 RST 08H DB 26 RST 08H DB 7 EX AF,AF' ;DEFADD=00XX ;EVAL RESULT OF NO-PARAM DEF FN IF FN HAS NO ;BRACKETS EITHER. ELSE ERROR ;'Parameter error' ;'FN without DEF FN' ;JR IF NOT RUNNING ;SKIP 'FN'

;LOOP TILL 0EH FOUND ;SKIP FEH ;SKIP FEH ;PAGE OF DEF FN, +80H ;ERROR IF NO DEF FN

;ADDR OF PAST NAME IN DEF FN ;PT CHAD TO END OF BUFFER

;GET SIGNIF CHAR AFTER '(' ;JR IF NO '()' TO SKIP ;SKIP '(' ;SKIP ')' ;Z ;Z IF FN HAS BRACKETS (IF EMPTY, CHAD PTS PAST) ;HL POINTS TO '(' OR '=' IN DEF FN E.G. ;DEF FN TEST=123 OR DEF FN TEST(A,B)=A*B

3169 316B 316B 316E 3170 3171 3173 3173 3174 3175 3175 3176 3177 3179 317B 317B 317D 317E 317F 3180 3182 3183 3184 3185 3186 3189 318C 318D 318E 3190 3190 3192 3192 3194 3194 3196 3198 3198 3199 319A 319B 319B 319C 319D 319F 31A2 31A5 31A7 31A8 31AB 31AC 31AD 31AE 31B0 31B0 31B2 31B4 31B4 31B6 31B8 31B8 31B9 31BA 31BC 31BE 31BE 31C1 31C1 31C5 31C8 31C9 31CC 31CD 31D0 31D3 31D4 31D7 31D9 31DC 31DF 31E0 31E1 31E1 31E1 31E1 31E4 31E7 31E8 31E9 31EC 31ED 31EE 31F1 31F2 31F3 31F6 31F7 31FA 31FA 31FB 31FB 31FC 31FF

20F9 CDBC33 D629 F5 2845 F1 E5 23 7E FE0E 20FA DBFB F5 2B 7E D623 23 23 F5 E5 CDD73F CD073B D1 C1 2802 1002 10D0 FE29 2003 08 E7 08 08 F1 D3FB CD121D 010500 EDB0 EB CDBD33 47 08 B8 20B4 FE2C 28C1 FE29 20AC 23 7E FE3D 20FA 010100 ED5B975A 3A965A 47 3A535C 4F 22975A 2A545C E3 22545C DBFB 32535C 32965A D5 C5 CDDF3F CD073B C1 79 32535C 78 F5 CDCE3F F1 E1 22975A E1 22545C C0 C1 C39415 FNTYP: FNR6: FNRLE: FNR5: FNR3: FNR4: FNRLA:

JR NZ,PARAMERR CALL FORESP SUB ")" PUSH AF JR Z,FNRLE POP AF PUSH HL INC HL LD A,(HL) CP 0EH JR NZ,FNRLA IN A,(251) PUSH AF DEC HL LD A,(HL) SUB "$"-1 INC HL INC HL PUSH AF PUSH HL CALL SELCHADP CALL SEXPTEXPR POP DE POP BC JR Z,FNR3 DJNZ FNR4 DJNZ PARAMERR CP ")" JR NZ,FNR5 EX AF,AF' RST 20H EX AF,AF' EX AF,AF' POP AF OUT (251),A CALL FDELETE LD BC,5 LDIR EX DE,HL CALL FORESP1 LD B,A EX AF,AF' CP B JR NZ,PARAMERR CP "," JR Z,FNRLA CP ")" JR NZ,PARAMERR INC HL LD A,(HL) CP "=" JR NZ,FNRLE LD BC,1 LD DE,(CHAD) LD A,(CHADP) LD B,A LD A,(DEFADDP) LD C,A LD (CHAD),HL LD HL,(DEFADD) EX (SP),HL LD (DEFADD),HL IN A,(251) LD (DEFADDP),A LD (CHADP),A PUSH DE PUSH BC CALL TSURPG CALL SEXPTEXPR POP BC LD A,C LD (DEFADDP),A LD A,B PUSH AF CALL SETCHADP POP AF POP HL LD (CHAD),HL POP HL LD (DEFADD),HL RET NZ POP BC JP STRCONT

;IF DEF FN HAS BRACKETS, FN MUST TOO ;SKIP '(', GET NEXT SIGNIF CHAR ;JR IF NO PARAMS IN DEF FN - DEFADD=00XX ;ADDR USED FOR DEFADD ;INITIALLY, SKIP VAR LETTER ;LOOP TILL 0EH MARKER OF PARAM BUFFER IN DEF FN FND ;PAGE OF DEF FN ;'$' OR NUMERIC VAR LETTER PRECEDES 0EH BUFFER ;PT TO 5-BYTE BUFFER ;A=1 IF '$' ;LOOK AT CHAD (FN '(' OR ',') ;EVAL FN ARG. Z IF STRING ;5 BYTE BUFFER IN DEF FN ;B=1 IF STRING VALUE EXPECTED ;JR IF STRING VALUE ;JR IF TYPE OK ;JR IF TYPE MISMATCH

;SKIP FINAL ')' IF WE REACHED IT ;SAVE CHAR AFTER FN EXPR. ;DEF FN PAGE SELECTED ;DEL. EXPR (FROM FN PARAM). HL PTS TO IT ON EXIT. ;COPY TO DEF FN BUFFER ;HL POINTS PAST 5 BYTES IN DEF FN BRACKETS ;LOOK FOR SIGNIFICANT CHAR IN DEF FN - ')' OR ',' ;CHAR AFTER FN EXPR - ')' OR ','

;JR IF ANOTHER PARAM SHOULD FOLLOW

;LOOP TILL DEF FN '=' FOUND ;INC CHAD TO SKIP FINAL FN ')'

;PT CHAD TO '=' IN DEF FN ;PT DEFADD TO DEF FN BRACKETS ;CHAD ;SAVE CHAD (POINTER TO ')' AFTER FN, OR SOME OTHER ;CHAR IF NO PARAMS. SAVE DEFADD TO ALLOW FN CALLING ;FN. ;SKIP '=', EVAL

;$/N FLAG

;RET IF NUMERIC - 'FN' IS NOMINALLY NUMERIC, SO ;RET SETS FLAGS OK ;ELSE JUNK RET, ;GOTO STRING FLAG SETTER

31FF 31FF 31FF 3200 3203 3206 3207 3209 320C 320E 3210 3210 3211 3213 3215 3215 3218 3219 321B 321D 321D 3220 3222 3222 3223 3223 3224 3225 3227 3227 3227 3227 3227 3227 3227 322A 322A 322B 322C 322F 3231 3231 3233 3235 3235 3236 3236 3237 3238 3238 3238 323B 323D 323F 323F 3240 3243 3246 3249 324C 324F 3252 3255 3256 3257 3258 325B 325E 3261 3262 3263 3264 3265 3266 3267 3268 3269 326C 326C 326F 3271 3271 3272 3275 3275 3278 3279 3279 327A 327D 327D 327E 327F 3282 3284 3284 3287 3288 328A 328C 328C 328D 328E

;CHECK FN SYNTAX E7 32765A CD2732 F5 3EFE CD5333 FE28 2013 E7 FE29 280D CDE314 79 FE29 2805 CD853A 18F3 E7 F1 3D 18D3 FNSY4: FNSY5: FNARL: FNSYN: RST 20H LD (REFFLG),A CALL FNNAME PUSH AF LD A,0FEH CALL MKCLBF CP "(" JR NZ,FNSY5 RST 20H CP ")" JR Z,FNSY4 CALL SCANNING LD A,C CP ")" JR Z,FNSY4 CALL INSISCOMA JR FNARL RST 20H POP AF DEC A JR FNTYP ;SKIP ')' ;Z IF STRING ;IF NOT STRING, RET TO SET NUMERIC RESULT ;ELSE JUNK RET ADDR FOR NUMERIC IMMED FNS ;FN NAME ENDED '$'; SET FLAG FOR STRING ;SKIP 'FN' ;NZ SHOWS FN USED IN THIS LINE (FOR COMPILER) ;A=1 IF STRING ;JR IF NO PARAMS E.G. FN TEST ;SKIP '(' ;JR IF NO PARAMS E.G. FN TEST () ;ALLOW NUMERIC OR STRING EXPR

;CHECK FN NAME (CALLED BY FN AND DEF FN) CDEC3A 23 7E CD413B 38F9 D624 2001 23 3C C9 CDC63A 1620 3055 AF 32A85A 215004 22A95A CD3B1F 32AB5A 22AC5A CD2C33 47 C5 E5 CD7334 CDB437 2AC45B 2B 2B 2B 2B D1 C1 70 79 C31219 CDC63A 3008 D1 11CB8D CD470D 0D DF CDEC3A 23 7E CD413B 38F9 22975A DF FEB9 2002 E7 C9 DPROC2: DPNMLP: DEFPROC: FNN2: LOCAL: FNNAME: DFNLP: CALL GETALPH INC HL LD A,(HL) CALL ALNUMUND JR C,DFNLP SUB "$" JR NZ,FNN2 INC HL INC A RET CALL RUNFLG LD D," " JR NC,DPSY2 XOR A LD (PRPTRP),A LD HL,CARET LD (PRPTR),HL CALL ADDRCHAD LD (DPPTRP),A LD (DPPTR),HL CALL DPRA LD B,A PUSH BC PUSH HL CALL PROP2 CALL PTTODP LD HL,(BSTKEND) DEC HL DEC HL DEC HL DEC HL POP DE POP BC LD (HL),B LD A,C JP SEDA CALL RUNFLG JR NC,DPROC2 POP DE ;NEXT STAT RET ADDR LD DE,THENTOK*256+0CBH ;ENDPROCTOK ;(THENTOK=NULL) CALL SEARCH ;CONTINUE AFTER END PROC, OR ERROR DB 13 ;'No END PROC' RST 18H CALL GETALPH INC HL LD A,(HL) CALL ALNUMUND JR C,DPNMLP LD (CHAD),HL RST 18H CP 0B9H JR NZ,DPSY1 RST 20H RET ;DATATOK ;SKIP 'DATA' ;INSIST ON A LETTER AS FIRST CHAR OF DEF PROC NAME ;SKIP '$' ;A=1 IF STRING-TYPE NAME ;INSIST NAME STARTS WITH A LETTER

;NAME MAY CONTINUE WITH LETTERS, NUMBERS OR '_'

;NULL PREVENTS 'LOCAL REF X' BEING ACCEPTED ;JR IF SYNTAX TIME

;PT HL SO LOW THAT IT STAYS ON CR IN ROM ;GET PROC RET ADDR IN HL, PAGE/TYPE IN A, STAT IN C ;PROPAR, WITHOUT PLACING TERMINATOR ;**

;ADDR ;TYPE/PAGE ;STACK STAT, ADDR

328E 3291 3292 3292 3294 3294 3294 3294 3295 3297 3297 3298 3298 3299 329C 329F 32A2 32A3 32A4 32A4 32A7 32A9 32A9 32A9 32A9 32A9 32A9 32A9 32A9 32AA 32AD 32AE 32AE 32AF 32B2 32B2 32B3 32B4 32B7 32B9 32B9 32BB 32BD 32BD 32BE 32BE 32BF 32C0 32C1 32C4 32C5 32C6 32C7 32C7 32C7 32C7 32C7 32C7 32C7 32CA 32CB 32CC 32CC 32CE 32CF 32CF 32D2 32D4 32D5 32D5 32D8 32D9 32DA 32DB 32DB 32DB 32DB 32DB 32DD 32E0 32E1 32E4 32E6 32E6 32E8 32E8 32E9 32EA 32EC 32EC 32ED 32EE 32EF 32F1 32F3 32F3 32F4 32F5 32F6 32F7 32F8 32FB 32FD

CD7A3A C8 16CE BA 2001 E7 D5 CDC732 C4AA13 CD793A D1 C8 CD853A 18EB

DPSY1:

CALL CRCOLON RET Z LD D,0CEH

;RET IF PARAMS FINISHED ;REFTOK ;'REF' IF DEF PROC, NULL IF LOCAL ;IF D IS NULL, *ALWAYS* JR ;SKIP 'REF' ;CHECK FOR '()' FORMS ;CALL IF NOT ONE ;RST 18, CRCOLON ;RET IF PARAMS FINISHED

;'LOCAL' SYNTAX CHECK ENTERS HERE WITH D=NULL (SPACE) DPSY2: CP D JR NZ,DPSY3 RST 20H DPSY3: PUSH DE CALL VARAR CALL NZ,LOOKVARS CALL RCRC POP DE RET Z CALL INSISCOMA JR DPSY2 ;CHECK FOR VAR NAME SUCH AS frogs, price of bread, name$, abc2 ;ENTRY: CHAD PTS TO NAME START. ;EXIT: CHECK FOR LEN OK FOR SPECIAL FORM E.G. TEST$(), ALPHA() ;C=LEN (EXCLUDING SPACES). CY IF OK, NC IF TOO LONG, OR NOT A VAR NAME. DF CD1E3B D0 E5 01000B E7 0C CD413B 38F9 FE24 2001 E7 79 B8 E3 22975A E1 7E C9 VNM2: VNMLP: VARNAME: RST 18H CALL ALPHA RET NC PUSH HL LD BC,0B00H RST 20H INC C CALL ALNUMUND JR C,VNMLP CP "$" JR NZ,VNM2 RST 20H LD A,C CP B EX (SP),HL LD (CHAD),HL POP HL LD A,(HL) RET ;SKIP '$' ;NAME LEN ;ORIG CHAD ;A=CHAR AFTER NAME ;CY IF LEN OK ;RET WITH NC IF NOT LEGAL FIRST CHAR ;NAME LEN MAX (STR/ARRAY) OF 10. INIT LEN=0 ;LEN

;CHECK FOR ODD FORM SUCH AS FRED$(), DOGSARRAY(). ;USED BY 'LOCAL' AND 'DEF PROC' ;IF NOT SPECIAL FORM, CHAD IS UNCHANGED, NZ. ELSE CHAD/HL POINT PAST, A=CHAR CDA932 3D D0 FE27 C0 CDBC33 FE29 C0 22975A E7 BF C9 VARAR: CALL VARNAME DEC A RET NC CP "("-1 RET NZ CALL FORESP CP ")" RET NZ LD (CHAD),HL RST 20H CP A RET ;NZ - A IS A SIGNIF CHAR. ;RET WITH ORIG CHAD IF NOT LEGAL FOR '()' FORM ;RET IF NORMAL VAR. ;RET IF E.G. ALPHA(8) - EXPRESSION ;SKIP ')' ;Z=SPECIAL FORM SKIPPED

;PROCEDURES ;ENTRY: CHAR BETWEEN 0-8FH FOUND WHEN CMD EXPECTED C690 CDEC3A DF CDC63A 304E 3E0E BE 23 20FC 23 23 46 CB68 203F 23 5E 23 56 23 22A95A DBFB 32A85A PRRL: PROCS: ADD A,90H CALL GETALPH RST 18H CALL RUNFLG JR NC,PROCSY LD A,0EH CP (HL) INC HL JR NZ,PRRL INC HL INC HL LD B,(HL) BIT 5,B JR NZ,MDPERR INC HL LD E,(HL) INC HL LD D,(HL) INC HL LD (PRPTR),HL IN A,(251) LD (PRPTRP),A ;LOOP TILL CALLING BUFFER FOUND ;SKIP FD ;SKIP FD ;PAGE ;(BIT 7 IS ALWAYS SET, BIT 6=EXTERNAL CMD, BIT 5 ;IS SET IF 'NO DEF PROC') ;ADDR OF DEF PROC LINE OR EXEC CODE ;SET UP PROC PTR ;CORRECT FOR PREVIOUS SUB 90H ;JR IF SYNTAX CHECK

3300 3301 3304 3307 330A 330B 330E 330E 330F 3310 3313 3315 3315 3318 3319 331C 331E 3321 3322 3323 3324 3327 3329 332C 332C 332C 332C 332E 3331 3332 3332 3333 3334 3334 3335 3336 3339 333B 333B 333D 3340 3343 3344 3344 3347 334A 334D 334E 334E 3351 3353 3353 3353 3353 3353 3354 3357 3357 3358 3359 335A 335B 335C 335D 335E 335F 3362 3363 3364 3364 3367 336A 336C 336D 336E 336E 336E 336E 336E 336E 336E 336E 3371 3372 3372 3373 3374 3375 3377 3379 337B 337B 337C 337D 337D 3380 3382 3382 3385 3388 3388 3389 338A

78 32AB5A CDDF3F 210500 19 CDBD33 23 7E CD413B 38F9 22AC5A D5 CD6834 0640 CDF118 34 E1 D1 3AAB5A 0E02 C34A19 0640 CD201A C8 CF 0C 23 7E CD413B 38F9 3EFD CD5333 CD7A3A C8 CDC732 C4E314 CD793A C8 CD853A 18F1 PCSYL: DPRA: MDPERR: PROCSY: PRPNM:

LD A,B LD (DPPTRP),A CALL TSURPG LD HL,5 ADD HL,DE CALL FORESP1 INC HL LD A,(HL) CALL ALNUMUND JR C,PRPNM LD (DPPTR),HL PUSH DE CALL PROPAR LD B,40H CALL BSTKE INC (HL) POP HL POP DE LD A,(DPPTRP) LD C,2 JP RLEPC2 LD B,40H CALL RETLOOP RET Z RST 08H DB 12 INC HL LD A,(HL) CALL ALNUMUND JR C,PROCSY LD A,0FDH CALL MKCLBF CALL CRCOLON RET Z CALL VARAR CALL NZ,SCANNING CALL RCRC RET Z CALL INSISCOMA JR PCSYL

;DEF PROC PTR PAGE ;SELECT DEF PROC OR EXEC CODE PAGE ;SKIP TO FIRST POSSIBLE DEF PROC NAME START POSN ;SKIP ANY SPACES/CC

;LOOP PAST DEF PROC NAME ;PAST NAME ;DEF PROC LINE ADDR ;PROCESS PARAMETERS ;STACK A 'PROC-TYPE' RET ADDR ;RET TO *NEXT* STATEMENT ;DEF PROC LINE ADDR ;JUNK NEXT STAT ;STAT 2

;UNSTACK PROC RETURN ADDR, OR ERROR ;'PROC' TYPE ;GET C=STAT, HL=ADDR, NZ IF ERROR, A=PAGE ;'Missing DEF PROC'

;MAKE BUFFER AFTER NAME ;RET IF NO PARAMS ;CHECK FOR '()' FORMS, SKIP IF SEEN ;IF NOT '()' FORM ,EVAL ;RST 18, CRCOLON

;MAKE CALLING BUFFER AT HL (0E A A A ? ?), PT CHAD AFTER IT TO SIGNIF CHAR, GET ;IT IN A. ENTRY: A=BYTE TO FILL FIRST 3 LOCNS WITH. F5 CD6433 F1 77 23 77 23 77 23 23 22975A E7 C9 010600 CD1B1E 360E 23 C9 MAKESIX: MKCLBF: PUSH AF CALL MAKESIX POP AF LD (HL),A INC HL LD (HL),A INC HL LD (HL),A INC HL INC HL LD (CHAD),HL RST 20H RET LD BC,6 CALL MAKEROOM LD (HL),0EH INC HL RET ;OPEN 6 BYTES AFTER NAME FOR ADDRESS BUFFER, ;START WITH 0EH

;BUFFER= 0E FE FE FE ?? ?? ;PT CHAD TO PAST BUFFER

;LOOK FOR A FN VARIABLE ;CALLED FROM EVAL WHEN DEFADD IS SET DURING EVAL (OF DEF FN RESULT) ;ENTRY: HL PTS TO FIRST CHAR OF NAME ;RETS WITH NC IF NOT FOUND, HL SAME - CONTINUE SEARCH IN NORMAL VARS AREA. ;ELSE CY, VAR ALREADY STACKED, NAME SKIPPED, STR/NUM SET, A='$' IF STRING CDC63A D0 E5 46 E7 FE24 0E0E 2002 4F E7 CD413B 3824 21535C CD401F 23 7E FE0E LKFV1: LKFV0: LKFNVAR: CALL RUNFLG RET NC PUSH HL LD B,(HL) RST 20H CP "$" LD C,0EH JR NZ,LKFV0 LD C,A RST 20H CALL ALNUMUND JR C,LKFVF LD HL,DEFADD-1 CALL ASV2 INC HL LD A,(HL) CP 0EH ;RET TO CALLER (EVAL) WITH NC IF SYNTAX TIME ;IN CASE VAR NOT FOUND ;VAR LETTER

;C='$' ;NO SEARCH FOR E.G. 'TEST', 'X1', 'ABC$' - JUST ;SINGLE LETTER VARS ;PT TO PAST '(' IN DEF FN

338C 338E 338E 338F 3390 3391 3393 3393 3394 3395 3396 3396 3397 3399 339B 339B 339E 339F 33A2 33A4 33A6 33A6 33A7 33A8 33A9 33A9 33AA 33AB 33AC 33AF 33B0 33B3 33B5 33B7 33B8 33B9 33B9 33BB 33BC 33BC 33BC 33BC 33BD 33BD 33BD 33BD 33BE 33C0 33C1 33C1 33C3 33C3 33C3 33C3 33C5 33C8 33C9 33C9 33C9 33C9 33CC 33CF 33D0 33D0 33D0 33D0 33D1 33D2 33D2 33D2 33D2 33D3 33D6 33D8 33DB 33DB 33DE 33DE 33DE 33DE 33DE 33E1 33E4 33E7 33EA 33ED 33EE 33F1 33F2 33F5 33F6 33F8 33F8 33F8 33FB 33FB 33FE 3401 3403 3403 3405 3408 3409

20FA 2B 7E B9 2003 2B 7E 23 A8 E6DF 280E 110700 19 CDBD33 FE2C 28E2 E1 A7 C9 23 23 79 CD201D C1 213B5C CBB6 FE24 37 C8 CBF6 C9 23 7E FE21 D0 18F9 3EFF 32405B C9 3A475C 2A455C 11 F1 E1 3C CD9B19 3EFF 32465C CDC333 DOCOMP: SCOMP: FORESP: FORESP1: LKFVF: LKFVM: LKFV2:

JR NZ,LKFV1 DEC HL LD A,(HL) CP C JR NZ,LKFV2 DEC HL LD A,(HL) INC HL XOR B AND 0DFH JR Z,LKFVM LD DE,7 ADD HL,DE CALL FORESP1 CP "," JR Z,LKFV1 POP HL AND A RET INC HL INC HL LD A,C CALL HLTOFPCS POP BC LD HL,FLAGS RES 6,(HL) CP "$" SCF RET Z SET 6,(HL) RET

;LOOK FOR A BUFFER MARKER ;C='$' IF STRING WANTED, OR 0EH FOR NULL ;JR IF A NUMERIC BUFFER FOUND ;STRING LETTER ;DESIRED LETTER ;JR IF MATCHED ;PT PAST 5-BYTE BUFFER ;KEEP CHECKING IF MORE BUFFERS FOLLOW ;ORIG HL ;NC - SEARCH FAILED ;PT TO 0EH ;PT TO BUFFER ;STACK BUFFER DATA ;ORIG HL

;CY SHOWS FOUND

;INC PTR HL AND RET WHEN IT POINTS TO SIGNIF CHAR INC HL LD A,(HL) CP 21H RET NC JR FORESP ;CALLED BY LOAD, DELETE, KEYIN, RENUM LD A,0FFH LD (COMPFLG),A RET LD A,(SUBPPC) LD HL,(PPC) DB 11H POP AF POP HL INC A CALL GOTO4 LD A,0FFH LD (PPC+1),A CALL SCOMP ;AVOIDS INITIAL INC

;FROM DELETE/MERGE GT4R: ;'JR+2' ;STAT ;LINE

;FROM RENUM/KEYIN GT4P:

;ENTRY: A=STAT-1 TO GO TO, HL=LINE

;ENSURE "GOTO" SEARCHES PROG FROM START

;CALLED AS ELINE IS EXECUTED, AND BY CLEAR/RUN. CHAD IS AUTO-ADJUSTED BECAUSE ;VAR CREATION MIGHT MOVE IT 3A965A 32995A 2A975A 229A5A 2AAF5A E5 3AAE5A F5 3A405B A7 282C CD321F 01EA21 CD3C34 381A DBFB 32965A E5 19 DOLBLP: COMPILE: LD A,(CHADP) LD (KCURP),A LD HL,(CHAD) LD (KCUR),HL LD HL,(CLA) PUSH HL LD A,(CLAPG) PUSH AF LD A,(COMPFLG) AND A JR Z,COMPILEL CALL ADDRPROG LD BC,2100H+0EAH CALL LKFC JR C,LABSD IN A,(251) LD (CHADP),A PUSH HL ADD HL,DE

;NEEDS AUTO-ADJUST

;JR IF ONLY ELINE NEEDS COMPILE ;START AT (PROG) ;LABELTOK ;FIND A LABEL ;END IF ALL LABELS PROCESSED ;ELSE HL POINTS TO FIRST CHAR IN LINE, CHAD ;PTS TO 'LABEL', DE=LINE LEN ;KEEP CHAD UP TO DATE FOR ASSIGN ETC.?!!? ;PTR TO NEXT LINE

;DO LABELS

340A 340B 340C 340D 340E 340F 3410 3411 3414 3417 341A 341B 341D 341D 341D 3420 3420 3421 3424 3424 3427 3427 3428 342B 342C 342F 3432 3435 3438 343B 343B 343B 343B 343B 343B 343B 343B 343C 343C 343C 343C 343D 343F 3440 3440 3443 3444 3445 3446 3447 3448 3449 344A 344A 344B 344D 344D 344E 3450 3450 3451 3451 3453 3455 3455 3456 3457 3458 345A 345A 345D 345E 345F 3460 3460 3461 3461 3462 3464 3464 3467 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468

E3 2B 2B 2B 4E 2B 46 CDDD1C CDEA38 CD0F2B E1 18DE LABSD: CDBF2F AF 32405B CDB92F F1 32AE5A E1 22AF5A 2A9A5A 22975A 3A995A C3CE3F COMPILEL:

EX (SP),HL DEC HL DEC HL DEC HL LD C,(HL) DEC HL LD B,(HL) CALL STACKBC CALL SVNUMV CALL ASSIGN POP HL JR DOLBLP CALL COMALL XOR A LD (COMPFLG),A CALL ELCOMAL POP AF LD (CLAPG),A POP HL LD (CLA),HL LD HL,(KCUR) LD (CHAD),HL LD A,(KCURP) JP SETCHADP

;BC=LINE NUMBER OF LINE WITH LABEL ;ASSESS NUMERIC VARIABLE ;ASSIGN FPC VALUE TO VAR ;CONTINUE SEARCH AT NEXT LINE ;'COMPILING PROGRAM'SHOWN BY BIT 7 COMPFLG HI ;COMPILE PROCS/FN (CY HERE) ;'COMPILING ELINE'SHOWN BY BIT 7 LOW ;*ALWAYS* COMPILE ELINE FOR PROCS, AND FNS ;IF NEEDED.

;LKFC.SAM - LOOK FIRST CHAR ;LOOK FOR CHAR IN C, AT START OF LINES, SKIPPING ANY PRECEDING CC/SPACES ;ENTRY: B=21H FOR CC/SPACE SKIP, C=CHAR, HL=START ;EXIT: NC IF FOUND, HL=FIRST CHAR IN LINE (MAY NOT BE C) (CHAD)=TARGET ; CY IF SEARCHED PROG AND FAILED. 19 7E C601 D8 CDEF3F 23 23 5E 23 56 23 7E B9 2817 B8 30EB E5 FE0D 280C 23 7E B8 38F7 22975A E1 B9 C8 E5 E1 18D7 22975A C9 LKFC4: LKFC5: LKFCSK: LKFC2: LKFCLP: LKFC: ADD HL,DE LD A,(HL) ADD A,1 RET C CALL CHKHL INC HL INC HL LD E,(HL) INC HL LD D,(HL) INC HL LD A,(HL) CP C JR Z,LKFC5 CP B JR NC,LKFCLP PUSH HL CP 0DH JR Z,LKFC4 INC HL LD A,(HL) CP B JR C,LKFCSK LD (CHAD),HL POP HL CP C RET Z PUSH HL POP HL JR LKFCLP LD (CHAD),HL RET ;FIRST CHAR IN LINE PTR ;ENTRY POINT ;RET IF END OF PROGRAM ;KEEP LINE START IN SECTION C

;DE=LINE LNE ;FIRST CHAR - QUICK CHECK FOR MOST COMMON CASE ;(NO PRECEDING JUNK) ;JR IF GOT IT - BUT MIGHT NEED TO SKIP CC/SPACE ;CP 21H ;LOOP IF CHAR WAS SIGNIF - THIS LINE WON'T DO ;SAVE LINE START ;STOP TRYING IF LINE ENDS ;SKIP CC/SPACE ;CP 21H ;SKIP ALL CC/SPACES ;ALTER CHAD IN CASE WE HAVE A MATCH ;FIRST CHAR IN LINE PTR ;CP FIRST SIGNIF CHAR IN LINE WITH DESIRED.

INCLUDE NPARPRO.SAM ;PARPRO.SAM ;PARAM PROCESSING ;E.G. TEST 1,A,C,2 ;DEF PROC TEST A,B,C,D ;CHECK DEF PROC. ;IF NON-REF NUMERIC: ; LOOK FOR VAR: ; IF NOT FOUND: ; GOTO STEP 2 ; IF FOUND: ; 1.SAVE ADDR OF TYPE/LEN BYTE SO IT CAN BE MADE "INVISIBLE" WHEN ALL PARAMS ; HAVE BEEN PROCESSED, AND "REVEALED" AGAIN AT END PROC TIME. ; KEEP LOOKING SO LAST LINK IN LETTER"S "CHAIN" FOUND. ; 2.CREATE NEW VARIABLE WITH SAME NAME, USING VALUE FROM PROC CALL. THIS IS ; "INVIS" TILL ALL PARAMS PROCESSED, SINCE BIT 7 SET ON TLBYTE. ; KEEP PTR TO NEW VARIABLE SO IT CAN BE MARKED "UNUSED" (BIT 5 SET) AT END ; PROC TIME. PROCS USE SPECIAL ASSIGN ROUTINE THAT LOOKS FOR AN "UNUSED" ; VAR OF THE SAME TYPE (FOR-NEXT/NORMAL) AND NAME LEN IN THE LETTER LIST

3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 3468 346B 346C 346D 346E 346F 3470 3473 3473 3474 3475 3478 3479 347C 347F 3482 3482 3484 3486 3486 3487 348A 348D 348F 348F 348F 348F 3492 3492 3495 3495 3498 3499 349B 349B 349E 34A1 34A2 34A2 34A2 34A2 34A5 34A7 34A7 34A7 34AA 34AD 34AD 34B0 34B3 34B4 34B8 34BA 34BA 34BD 34BD 34BF 34C2 34C4 34C4 34C5 34C5 34C8 34C9 34CC

; ; ;

AND DOES A NORMAL ASSIGN IF THERE ISN"T ONE, OR OVERWRITES THE NAME AND VALUE OF THE UNUSED VAR AND RESETS BIT 5 TO SHOW "USED". THIS AVOIDS ACCUMULATION OF "UNUSED" VARS.

;IF REF NUMERIC: ; TREAT LIKE NON-REF NUMERIC, EXCEPT THAT DURING ASSIGNMENT OF LOCAL VERSION, ; THE "VALUE" SUPPLIED BY THE PROC LIST MUST BE A VARIABLE NAME. IT IS MADE ; INVISIBLE WHEN PARAMS HAVE BEEN PROCESSED, AND ITS ADDR IS STORED SO THAT AT ; END PROC IT CAN BE "REVEALED" AND ITS VALUE RESET FROM THE LOCAL VERSION. ;IF NON-REF STRING: ; LOOK FOR VAR: ; IF NOT FOUND: ; FLAG "NO INVIS VERSION" ; GOTO STEP 2 ; IF FOUND: ; 1.SAVE ADDR OF TYPE/LEN BYTE SO IT CAN BE MADE "INVISIBLE" WHEN ALL PARAMS ; HAVE BEEN PROCESSED, AND FLAG "INVIS EXISTS". ; 2.CREATE NEW VARIABLE WITH SAME NAME, USING VALUE FROM PROC CALL. THIS WILL ; BE IGNORED IF VAR. USED LATER IN PROC CALL LIST (IT IS AT SAVARS END). ; KEEP NAME OF NEW VARIABLE SO IT CAN BE DELETED AT END PROC TIME, IF IT ; EXISTS, AND SO A SEARCH CAN BE MADE FOR ANY "INVIS" VERSION IF FLAG ; SAYS ONE EXISTS ;IF REF STRING/ARRAY: ; LOOK FOR VAR: ; IF NOT FOUND: ; GOTO STEP 2 ; IF FOUND: ; 1.SAVE ADDR OF TYPE/LEN BYTE SO IT CAN BE MADE "INVISIBLE" WHEN ALL PARAMS ; HAVE BEEN PROCESSED, AND FLAG "INVIS EXISTS". ; 2.LOOK FOR VAR NAMED IN PROC CALL. COPY TLBYTE AND NAME TO STORE. COPY ; NAME GIVEN IN DEF PROC TO TLBYTE. (RENAME). ; AT END PROC, FIND VAR, COPY ORIG NAME BACK FROM STORE. ;PROCESS PARAMS ;ENTRY: PRPTR PTS TO PROC PARAMS, DPPTR PTS TO DEF PROC PARAMS 2AC45B 2B AF 77 2B 77 22C45B AF F5 21004B 77 22725B CDB437 CA5936 FEB9 2027 F1 2AA95A 3AA85A 180C CD503A CD2E1D CD4D1A 2B DBFB 228B5A 328A5A C9 210000 18EE CDB437 CA5936 2AC45B 11E9FF 19 ED5BC85B ED52 DA0019 D6CE 32765A 2001 E7 CDDA14 EB 2A975A 22AC5A PPNREF: RESTORE2: RESTORE3: RESTORE: PROPAR: LD HL,(BSTKEND) DEC HL XOR A LD (HL),A DEC HL LD (HL),A LD (BSTKEND),HL XOR A PUSH AF LD HL,HDR LD (HL),A LD (RNSTKE),HL CALL PTTODP JP Z,PPM2 CP 0B9H JR NZ,PPML POP AF LD HL,(PRPTR) LD A,(PRPTRP) JR RESTORE3 ;RESTORE CMD STUCK IN HERE TO ALLOW JR! CALL SYNTAX3 CALL GETINT CALL FNDLINE DEC HL IN A,(251) LD (DATADD),HL LD (DATADDP),A RET LD HL,0 JR RESTORE2 CALL PTTODP JP Z,PPM2 LD HL,(BSTKEND) LD DE,-23 ADD HL,DE LD DE,(HEAPEND) SBC HL,DE JP C,BSFERR SUB 0CEH LD (REFFLG),A JR NZ,PPNREF RST 20H CALL LVFLAGS EX DE,HL LD HL,(CHAD) LD (DPPTR),HL ;POINT TO DEF PROC LIST ;JP IF LIST ENDED ;MAX SPACE NEEDED BY 1 PARAM ;FIND NEW BSTKEND. CY ;LOWER IN MEM THAN BSTKEND ;BSTKEND-(HEAPEND+1) - BSTK CANNOT COME AS FAR DOWN ;HEAPEND. ;ERROR IF STACK SPACE TOO SMALL ;REFTOK ;Z IF REF VAR ;SKIP "REF" ;LOOK FOR VAR IN DEF PROC LIST ;PROTECT ADDR OF PREV LINK (IF NOT FND) ;(DPPTRP IS OK STILL) ;RETURNS ADDR OF LINE BC. PAGE MAY BE SWITCHED ;EXPT1NUM OR USE ZERO IF CR/COLON

;BSTK TERMINATOR ;MACHINE STACK TERMINATOR ;USE TAPE HDR AREA AS RENAME STACK ;POINT TO DEF PROC LIST ;JP IF NO LIST ;DATATOK

PROP2:

;RESTORE-ZERO. USED BY CLEAR AND LOAD (PROGRAM) RESTOREZ: PPLOOP: PPML:

34CF 34D2 34D2 34D4 34D7 34D7 34D8 34DA 34DA 34DC 34DD 34DE 34DF 34E1 34E3 34E4 34E5 34E5 34E8 34EA 34EA 34EC 34EF 34F0 34F1 34F2 34F4 34F5 34F6 34F7 34F8 34F9 34F9 34FA 34FA 34FA 34FB 34FC 34FC 34FF 3502 3505 3505 3505 3505 3505 3509 350A 350B 350D 350D 350F 3510 3512 3515 3517 3518 3519 3519 351A 351B 351C 351D 351D 351F 351F 351F 351F 3522 3523 3524 3525 3527 3527 3528 3529 352A 352C 352D 352E 352F 3531 3533 3533 3534 3537 3538 353A 353C 353D 353D 3540 3541 3542 3544 3546 3549 354B 354C 354D 3550 3551 3551

F2A235 CB69 C2A235 08 2822 DDE5 E1 2B E5 DBFB F6E0 F5 23 CDD113 2810 3E00 324051 E5 77 23 36FF 23 77 23 77 D1 21 4A EB CDFB2C CDBC37 CA2036 ; PPA15: PPA2: PPNLP:

JP P,PPAS BIT 5,C JP NZ,PPAS EX AF,AF' JR Z,PPA2 PUSH IX POP HL DEC HL PUSH HL IN A,(URPORT) OR 0E0H PUSH AF INC HL CALL NVMLP JR Z,PPA15 LD A,0 LD (FIRLET),A PUSH HL LD (HL),A INC HL LD (HL),0FFH INC HL LD (HL),A INC HL LD (HL),A POP DE JR PPA2 DB 21H LD C,D EX DE,HL CALL SYN1PP CALL PTTOPR JP Z,PPD2

;JP IF STRING ;BIT 5=1 IF NUMERIC ARRAY ;JP IF NUMERIC ARRAY ;JR IF NVAR IN DEF PROC LIST DOESN"T EXIST ;PT TO TLBYTE OF VAR ;SAVE ADDR OF VAR TO MAKE "INVIS" ;BIT 7 SET SO "ADDR TO REVEAL" STORED. 111xxxxx ;KEEP LOOKING. C IS TLBYTE ;JR IF NO SECOND COPY (D=0)

;SECOND COPY=MINUS ZERO ;VALUE LOCN ;VARIABLE EXISTS. IF ASSIGNMENT IS MADE FROM ;PROC VALUE, MINUS ZERO OVERWRITTEN. IF NOT, ;DEFAULT RECOGNISES MINUS ZERO AS "NON-EXISTENT" ;SIGNAL SIMPLE NUMERIC (F-N BIT SEEN AS ARRAY) ;SET UP FOR ASSIGNMENT - SETS "NEW VAR" FLAG ;POINT TO PROC LIST ;JP IF PROC LIST ENDED

;LOOK FOR "UNUSED" NUMERIC VAR ;ENTRY: TLBYTE/FIRLET SET ED4B3F51 78 87 2844 D6C2 5F 1600 CD1F1F CBE9 79 19 5E 23 56 19 3832 ; ; CDEF3F 79 BE 23 20F2 2B E5 7E CBFE 23 23 23 E61F 280A EB 214151 4F 0600 EDB0 EB 22A65A E1 E5 DBFB E61F 32A55A F620 F5 AF 32715C DD 2A855A PPA25: UNVLP: UNVLK: LD BC,(TLBYTE) LD A,B ADD A,A JR Z,PPA3 SUB 61H*2 LD E,A LD D,0 CALL ADDRNV SET 5,C LD A,C ADD HL,DE LD E,(HL) INC HL LD D,(HL) ADD HL,DE JR C,PPA3 ;C=TLBYTE, B=FIRLET ;JR IF SEARCH NOT WANTED COS 2ND COPY EXISTS ;LETTER TRANSFORMED TO WORD OFFSET (A=0, B=2..) ;PT. HL AT NUMERIC VARS, PAGED IN ;"UNUSED" ;DESIRED TYPE/LEN ;INDEX INTO TABLE OF WORD PTRS. ;PTR=FFFFH IF NO MORE VARS START WITH REQUIRED ; LETTER. CAUSES CARRY AND CHECK FOR FF IN NVSPOV ;ELSE DE IS A PTR TO NEXT VAR STARTING ; WITH REQUIRED LETTER. ;RET IF LIST ENDED OR SEVERE PAGE OVERFLOW

BIT 6,H CALL NZ,INCURPAGE CALL CHKHL LD A,C ;IN CASE CALL WAS MADE CP (HL) INC HL ;PT TO PTR LSB JR NZ,UNVLP DEC HL PUSH HL LD A,(HL) SET 7,(HL) INC HL INC HL INC HL AND 1FH JR Z,PPA25 EX DE,HL LD HL,FIRLET+1 LD C,A LD B,0 LDIR EX DE,HL LD (DEST),HL POP HL PUSH HL IN A,(URPORT) AND 1FH LD (DESTP),A OR 20H PUSH AF XOR A LD (FLAGX),A DB 0DDH LD HL,(NUMEND) ;PT TO TLBYTE OF UNUSED VAR ;hidden** SO NOT USED TWICE! ;PT TO OTHER LETTERS OF NAME (OR VALUE) ;JR IF PTING TO VALUE (1-LET VAR)

;COPY NAME TO "UNUSED" VAR NAME AREA ;PTR TO VALUE AREA OF REUSED VAR ;TLBYTE PTR ;ADDR OF VAR TO MARK "USED" ;001XXXXX ;PAGE, AND BITS FOR "MARK AS USED" ;"VAR EXISTS" (BIT 0) ;"JR+3" ;VAR WILL BE CREATED HERE SINCE AN "UNUSED" VAR

PPA3:

3554 3554 3554 3556 3556 3559 3559 355C 355F 3560 3562 3562 3562 3565 3568 3568 3569 356B 356B 356C 356D 356E 356F 356F 3572 3572 3572 3575 3575 3575 3575 3578 3579 357C 357D 357D 357E 3580 3582 3584 3586 3587 3589 358A 358B 358E 3590 3591 3594 3594 3594 3594 3594 3594 3595 3596 3599 359C 359D 359D 359D 359D 359D 359D 359D 359D 359D 359D 359D 359D 359D 359D 35A0 35A0 35A2 35A2 35A2 35A2 35A4 35A5 35A7 35A7 35A9 35A9 35AC 35AD 35AF 35B1 35B3 35B4 35B4 35B7 35BA 35BC 35BC 35BF 35C2 35C3 35C5 35C5 35C5 35C5 35C8

;AREA IS NOT BEING RE-USED. 0640 CDCF36 CDBC37 3A765A A7 203B CDDA14 F29036 08 2012 EF E1 25 33 CD372B CD282B 3A3F51 4F CDC213 AF 08 DD2B DDE5 DBFB F6E0 F5 06A0 E5 EB 2AC45B CBEE EB CDCF36 PPRNE: PPA4: LD B,40H CALL RUAHL CALL PTTOPR LD A,(REFFLG) AND A JR NZ,PPA5 CALL LVFLAGS JP P,PARERR EX AF,AF' JR NZ,PPRNE DB DB DB DB CALC STKZERO DUP EXIT ;IF PROC VAR DOES NOT EXIST CREATE DP VAR ;WITH VALUE ZERO USING NAME AT T/L+33. C=0 ;LOOK FOR NON-EXISTENT PROC VAR AGAIN. ;SO NO MATCH. ;SET UP FOR ASSIGN TO PROC VAR. ;CREATE PROC VAR WITH VALUE ZERO ;POINT TO (NOW EXISTING) PROC VAR ;Z ;SAVE Z IF ASSIGN TO DP VAR ALREADY MADE ;PT TO TLBYTE OF PROC VAR BEING REFFED ;SAVE ADDR OF VAR TO MAKE "INVIS" ;BIT 7 SET SO "ADDR TO REVEAL" STORED. 111xxxxx ;SET BITS 5 AND 7 OF PAGE TO SHOW "REF" AND "PROC" ;SET BIT 5 OF PREVIOUS "VAR TO MARK UNUSED" TO SHOW ;"REF". BIT 7 BEING RES SHOWS "DEF PROC" ;RECORD ADDR OF VALUE BEING ASSIGNED *FROM* SO IT ;CAN BE ASSIGNED BACK *TO* AT END PROC E.G. ; TEST Z ; DEF PROC TEST REF X ; VALUE OF Z HAS BEEN ASSIGNED TO X. END PROC ; ASSIGNS X'S VALUE TO Z, MARKS X "UNUSED" ;PTR TO VALUE ;(NO CHANGE TO Z FLAG) ;Z JR PPD1H ;ENSURE SEARCH OF VARS HASN'T ALTERED PAGE ** ;RST 18H, CALL CRCOLON ;BIT 7 OF PAGE WILL BE RESET. BIT 6 SET SO NOT ;SEEN AS "TERMINATOR" ;RECORD ADDR OF VAR ASSIGNED TO, ALLOWING ;MARKING AS "UNUSED" BY END PROC ;PT TO PROC ;JR UNLESS VAR BEING "ASSIGNED" TO IS REF-TYPE ;NZ NEEDED HERE!!! ;INSIST PROC SUPPLIES A VAR NAME ;ERROR IF STRING ;JR IF VAR EXISTS

CALL ASSISR CALL CRTVAR35 LD A,(TLBYTE) LD C,A CALL NUMLOOK XOR A EX AF,AF' DEC IX PUSH IX IN A,(URPORT) OR 0E0H PUSH AF LD B,0A0H PUSH HL EX DE,HL LD HL,(BSTKEND) SET 5,(HL) EX DE,HL CALL RUAHL

E1 08 C4201D C40F2B BF ;PPA5: ;PPA5: ; ; ; ; ; ; ; C4FA2A 187A 0610 08 280D 0690 2ABC5B E5 DBFB E61F F660 F5 CDED36 CDBC37 2864 CD402D 3A765A A7 2045 3A3B5C F5 PAS2: PPA5: PPD1H: PPAS:

POP HL EX AF,AF' CALL NZ,HLTOFPCS CALL NZ,ASSIGN CP A CALL SELCHADP CALL RCRC JR NZ,PPA55 DB CALC DB STKZERO DB EXIT INC HL DEC (HL) JR PPA45 CALL NZ,VALFET1 JR PPD1 LD B,10H EX AF,AF' JR Z,PAS2 LD B,90H LD HL,(STRLOCN) PUSH HL IN A,(URPORT) AND 1FH OR 60H PUSH AF CALL PPSUB CALL PTTOPR JR Z,PPD2 CALL SCOPNM LD A,(REFFLG) AND A JR NZ,PPD0 ;REF STRINGS/ARRAYS LD A,(FLAGS) PUSH AF

;NZ FLAG, VALUE=MINUS ZERO ;ASSIGN VALUE FROM PROC LIST TO VAR FROM DEF PROC ;EXITS WITH DEST PAGED IN

;STRINGS/ARRAYS ;BIT 7 RES=NO VAR TO REVEAL, BIT 4 SET=STRING ;JR IF DEF PROC STRING/ARRAY DOESN"T EXIST ;BIT 7 SET SO "GLOBAL S/A TO REVEAL" SHOWN ;BIT 4 SET=STRING/ARRAY ;PTS TO TLBYTE OF S/A JUST FOUND ;SAVE ADDR OF DEF PROC S/A TO MAKE "INVIS" ;BIT 7 RES SO NO RECORD MADE OF ADDR TO REVEAL ;SET BIT 5 - ENSURE NOT ZERO. 011xxxxx ;RECORD DEF PROC NAME ON BSTK, WITH FLAG BITS ;POINT TO PROC LIST ;JR IF PROC LIST ENDED ;COPY DEF PROC NAME TO TLBYTE+33 ;JR IF NOT A REF VAR

35C9 35CC 35CF 35CF 35D0 35D2 35D3 35D4 35D5 35D5 35D6 35D6 35D8 35DB 35DB 35DC 35DE 35DE 35E1 35E5 35E6 35E7 35E8 35E9 35ED 35EE 35EF 35F0 35F1 35F3 35F5 35F6 35F7 35FA 35FA 35FC 35FF 35FF 35FF 3602 3603 3605 3608 360A 360A 360A 360A 360D 360E 3611 3611 3614 3616 3616 3619 361C 361C 361F 3620 3620 3623 3625 3627 3627 3628 362B 362B 362D 362F 362F 3630 3633 3633 3636 3638 363A 363A 363B 363B 363D 363F 363F 3640 3643 3643 3643 3643 3643 3643 3643 3643 3643 3644 3647 3648 3648 3648 3649 3649 3649 364A 364C 364F

CDDA14 F2D535 F1 CB11 A1 2F 0E F1 E640 C29036 08 281C 2A725B ED5BC45B 23 73 23 72 ED5BBC5B 23 73 23 72 DBFB F680 23 77 22725B 0600 CDED36 2AC45B 2B 36FF 22C45B 1812 3A3B5C 87 FA9036 216051 CBB6 CDA13A CD7B2C CDD73F DF 22A95A FE29 2004 E7 22A95A FE2C 2004 E7 22A95A CDB437 FE29 2001 E7 FE2C 201A E7 C3AD34 ; ; ; ; ; F5 CDDF3F F1 87 E1 CBBE F25736 PPMIL: PPD5: PPD4: PPD35: PPD3: PPD1: PPD2: PPD0: PAS3: REFSTR:

CALL LVFLAGS JP P,REFSTR POP AF RL C AND C CPL DB 0EH POP AF AND 40H JP NZ,PARERR EX AF,AF' JR Z,PAS3 LD HL,(RNSTKE) LD DE,(BSTKEND) INC HL LD (HL),E INC HL LD (HL),D LD DE,(STRLOCN) INC HL LD (HL),E INC HL LD (HL),D IN A,(URPORT) OR 80H INC HL LD (HL),A LD (RNSTKE),HL LD B,0 CALL PPSUB LD HL,(BSTKEND) DEC HL LD (HL),0FFH LD (BSTKEND),HL JR PPD1 ;NON-REF STRINGS/ARRAYS LD A,(FLAGS) ADD A,A JP M,PARERR LD HL,TLBYTE+33 RES 6,(HL) CALL EXPTSTR CALL ASNST CALL SELCHADP RST 18H LD (PRPTR),HL CP ")" JR NZ,PPD3 RST 20H LD (PRPTR),HL CP "," JR NZ,PPD35 RST 20H LD (PRPTR),HL CALL PTTODP CP ")" JR NZ,PPD4 RST 20H CP "," JR NZ,PPM2 RST 20H JP PPML LD A,(REFFLG) AND A JR NZ,PARERR RST 20H JR PPD2 PUSH AF CALL SELURPG POP AF ADD A,A POP HL RES 7,(HL) JP P,PPM3

;LOOK FOR PROC NAME ;JP IF PROC VAR=STRING ;BIT 6,A=1 IF DP NAME=NUMERIC ;BIT 6,C=1 IF PROC VAR=ARRAY ;BIT 6=1 IF NUM ARRAYS ;"JR+1"

;JR IF VAR DOESN'T EXIST ;PTR TO DEF PROC NAME IN BSTK

;TLBYTE OF PROC NAME JUST FOUND

;ENSURE NOT ZERO

;KEEP ORIG TLBYTE ;RECORD ORIGINAL PROC VAR NAME SO IT CAN ;BE RESTORED AT END PROC TIME. ;NAME "UNDER" IT MUST BE DEF PROC NAME ;PRECEDE NAME WITH FF

;ERROR IF NUMERIC ARRAY ;ENSURE THAT THE TYPE IS NOT ARRAY EVEN IF DP NAME ;IS E.G. A$(). ;CREATE STRING AT END OF SAVARS

;UPDATE PROC PTR ;SKIP CLOSING BRACKET OF E.G. "NUM()" ;JR IF NO MORE PROC PARAMS ** BUG FIX ;SKIP "," IN PROC LIST

;SKIP CLOSING BRACKET OF E.G. "NUM()" ;EXIT IF NO MORE DEF PROC VARS ** ;SKIP "," IN DEF PROC LIST ;LOOP UNTIL PROC PARAMS FINISHED ;ERROR IF NO VALUE AND "REF" - VAR NAME REQUIRED ;SKIP COMMA, GET HL=CHAD

;011xxxxx IF STRING/ARRAY, NO ADDR TO REVEAL ;111XXXXX IF NUMBER, ADDR TO REVEAL ;001XXXXX IF NUMBER, ADDR TO MAKE "USED" ;CY IF NUMERIC WITH DISP TO STORE ;P IF NEED TO MAKE USED AND NO NEED TO MAKE ;INVISIBLE ;VISIBLE**

364F 3651 3653 3656 3657 3657 3659 3659 365A 365B 365D 365D 3660 3661 3662 3664 3664 3667 3668 3669 366A 366B 366C 366D 366E 366F 3670 3671 3674 3675 3676 3677 3679 367A 367B 367D 367E 367F 3680 3681 3684 3684 3684 3684 3684 3685 3687 368A 368C 368C 368F 3690 3690 3691 3692 3692 3692 3692 3692 3693 3694 3695 3698 3698 3699 369A 369C 369C 369E 36A0 36A0 36A2 36A4 36A4 36A6 36A8 36A8 36A9 36AA 36AA 36AC 36AD 36AE 36AF 36B0 36B2 36B4 36B4 36B4 36B4 36B6 36B7 36B9 36B9 36BA 36BB 36BC 36BC 36BD 36BE 36BF 36C0 36C2

CBFE 0680 DCCF36 21 CBAE F1 A7 20E6 2A725B 7E A7 2828 CDDF3F 2B 56 2B 5E D5 2B 56 2B 5E 2B 22725B EB D1 7E E60F 4F 1A E670 B1 47 1A 17 DC9236 PPM3: PPM2: RNMLP:

SET 7,(HL) LD B,80H CALL C,RUAHL DB 21H RES 5,(HL) POP AF AND A JR NZ,PPMIL LD HL,(RNSTKE) LD A,(HL) AND A JR Z,RNMF CALL SELURPG DEC HL LD D,(HL) DEC HL LD E,(HL) PUSH DE DEC HL LD D,(HL) DEC HL LD E,(HL) DEC HL LD (RNSTKE),HL EX DE,HL POP DE LD A,(HL) AND 0FH LD C,A LD A,(DE) AND 70H OR C LD B,A LD A,(DE) RLA CALL C,NEGVTR

;EXISTING NUM/STR VAR MADE "INVISIBLE" ;RECORD DISP FROM NVARS OF A "NUMBER TO REVEAL" ;"JR+2" ;"USED" ;LOOP TILL STACKED ADDRS TO MARK "INVIS" ALL DONE

;VARS PTR

;HL=BSTK PTR TO DP NAME, DE=VARS PTR ;C=LEN (OF DP NAME) ;"VISIBLE" ;UPPER BITS (TYPE) FROM VARS, LEN FROM D.P. NAME ;NEW TLYBTE ;IF VAR HAD BEEN MADE INVISIBLE, REVERSE "VAR TO ;REVEAL" BIT ON D.P. NAME IN BSTK. (HAPPENS IF ;ANY PROC VAR PASSED BY REFERENCE HAS SAME NAME ;AS AS A DEF PROC VAR. VARS THAT ARE RENAMED NEED ;NOT AND SHOULD NOT BE INVIS) ;OVERWRITE NAME OF PROC VAR WITH NAME OF DEF PROC ;RET IF PROC LIST ENDED ;"Parameter error"

78 0600 CD0437 18D1 CDBC37 C8 CF 1A RNMF: PARERR:

LD A,B LD B,0 CALL ILDISR JR RNMLP CALL PTTOPR RET Z RST 08H DB 26

;LOOK FOR A PARTICULAR BSTK ENTRY SPECIFYING "VAR TO REVEAL" AND RESET BIT ;ENTRY: DE PTS TO TLBYTE OF VAR NAME IN VARS THAT IS ABOUT TO BE RENAMED C5 D5 E5 2AC45B 7E A7 28F4 CB67 2004 0E03 1810 FEFF 2002 23 7E E60F 4F 1A AE 23 E6AF 2805 0600 09 18DF E5 D5 41 13 1A BE 23 2002 FDPN3: FDPN2: NEGVTR: PUSH BC PUSH DE PUSH HL LD HL,(BSTKEND) LD A,(HL) AND A JR Z,PARERR BIT 4,A JR NZ,FDPN2 LD C,3 JR FDPN4 CP 0FFH JR NZ,FDPN3 INC HL LD A,(HL) AND 0FH LD C,A LD A,(DE) XOR (HL) INC HL AND 0AFH JR Z,FDPN5 LD B,0 ADD HL,BC JR FDPNL PUSH HL PUSH DE LD B,C INC DE LD A,(DE) CP (HL) INC HL JR NZ,FDPN6 ;JR IF NOT REF NAME ;SKIP FF ;B=NEW TLBYTE, C=LEN OF DP NAME ;VARS PTR

FDPNL:

;ERROR IF NOT FOUND ;JR IF STRING, ELSE SKIP NUMERIC DISP

;JR IF MATCH ON "VAR TO REVEAL" BIT, TYPE BITS ;AND LEN BITS - IGNORE BIT 4 MISMATCH (ALWAYS ;ZERO IN VARS AREA) AND BIT 6 ($/$ ARRAY) ;SKIP STRING NAME

FDPN4: FDPN5: FDPBL:

;LEN TO MATCH ON

36C2 36C4 36C4 36C5 36C6 36C8 36C8 36C9 36CB 36CC 36CD 36CE 36CF 36CF 36CF 36CF 36CF 36CF 36CF 36D2 36D3 36D7 36D9 36DC 36DD 36E0 36E1 36E2 36E3 36E4 36E5 36E7 36E8 36E8 36E9 36E9 36EC 36ED 36ED 36ED 36ED 36ED 36F0 36F3 36F4 36F6 36F7 36F8 36FA 36FA 36FB 36FB 36FD 36FF 3700 3703 3704 3704 3705 3706 3707 3709 370A 370A 370A 370A 370A 370A 370D 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370E 370F 3710 3711 3713 3713 3714 3716 3718 3718 3719 371A 371B 371C 371D 3720

10F8 D1 E1 20EC 2B CBBE E1 D1 C1 C9 FDPN6:

DJNZ FDPBL POP DE POP HL JR NZ,FDPN4 DEC RES POP POP POP RET HL 7,(HL) HL DE BC ;DP NAME PTR ;BSTK SRCH PTR ;JR IF MATCH FAILED ;RESET "VAR TO REVEAL" BIT ;HL=DP NAME PTR ;VARS PTR.

;CALCULATE DISP FROM NVARS TO CURRENT PAGE/HL, STORE IN BSTK IN PAGE/MOD 16K ;FORM, WITH BIT 7 OF PAGE SET IF VAR TO MARK UNUSED, RES IF TO MAKE VISIBLE. ;(USED LATER BY END PROC) 3A875A 4F ED5B885A DBFB CDE71F EB 2AC45B 2B 72 2B 73 2B E60F B0 77 22C45B C9 BSSET: RUAHL: LD A,(NVARSP) LD C,A LD DE,(NVARS) IN A,(URPORT) CALL SUBAHLCDE EX DE,HL LD HL,(BSTKEND) DEC HL LD (HL),D DEC HL LD (HL),E DEC HL AND 0FH OR B LD (HL),A LD (BSTKEND),HL RET ;CDE=NVARS ;AHL=TLBYTE ;ADE=DISP FROM NVARS (PAGEFORM)

;BIT 4 LOW SHOWS NUMERIC ;SHOW "DISP TO VAR TO MARK "UNUSED"" AT END PROC ;(BIT 7 SET) OR "DISP TO VAR TO REVEAL" (BIT 7 RES)

;RECORD TLBYTE AND NAME ON BSTK, USING B REG TO SET BITS 7 AND 4 OF TLBYTE ;EXIT: BC=0 113F51 2AC45B 1A E60F 4F 1A E66F B0 0600 ED42 2B 22C45B EB 12 13 23 EDB0 C9 ILDISR: PPSUB: LD DE,TLBYTE LD HL,(BSTKEND) LD A,(DE) AND 0FH LD C,A LD A,(DE) AND 6FH OR B LD B,0 SBC HL,BC DEC HL LD (BSTKEND),HL EX DE,HL LD (DE),A INC DE INC HL LDIR RET ;TLBYTE OF VAR NAME LOOKED FOR

;** ;BIT 4 ALWAYS SET TO SHOW STRING NAME, BIT 7 SET ;IF "GLOBAL TO REVEAL" ;BC=NAME LEN ;ALLOW SPACE FOR TLBYTE (NON-STANDARD FORM)

;COPY NAME TO BSTK

;SUBROUTINE USED BY END PROC AND POP (PROC ADDR) ;ACTION: FOR NUMERICS, MARKS VAR (DISP ON BSTK) "UNUSED" OR "REVEALS" IT. ;FOR STR/ARRS, DELETE, AND REVEAL LAST INVIS VERSION IF ONE WAS HIDDEN BY PROC. 2AC45B 7E DELOCAL: LD HL,(BSTKEND) LD A,(HL) ;0000=TERMINATOR ;FF= ORIG NAME OF A REF VAR FOLLOWS. LOOK FOR ; NEW NAME (FOLLOWS ORIG), RENAME. KEEP ; NEW NAME ON BSTK TO ALLOW DELOCAL. ;BIT 4 SET IF STRING/ARRAY NAME ; BIT 7 SET IF GLOBAL VERSION TO REVEAL, ; AS WELL AS LOCAL VERSION TO DELETE. ;BIT 4 RES IF DISP OF NUMBER FROM NVARS ; BIT 7 SET IF IT IS A GLOBAL VERSION TO ; REVEAL. ; BIT 7 RES IF IT IS LOCAL VAR TO MARK ; "UNUSED". ; BITS 7/5 SET IF VALUE OF LOCAL VAR ; IS POINTED TO. COPY TO BUFFER. ; BIT 7 RES, 5 SET IF BUFFER VALUE ; TO BE COPIED TO VAR (ADDR=TLBYTE) ; AND TLBYTE TO BE MARKED "UNUSED" 23 23 A7 28D6 2B CB67 2046 F5 5E 23 56 23 22C45B E60F INC HL INC HL AND A JR Z,BSSET DEC HL BIT 4,A JR NZ,DLOCS PUSH AF LD E,(HL) INC HL LD D,(HL) INC HL LD (BSTKEND),HL AND 0FH ;JR IF TERMINATOR OF DATA USED BY END PROC ;NO NEED TO CHECK FOR 2 ZEROS HERE ;JR IF STRING/ARRAY NAME

3722 3723 3726 3729 372A 372C 372E 372E 372F 3731 3731 3731 3733 3734 3735 3737 3737 3739 373A 373C 373E 373F 3741 3742 3745 3747 3749 374A 374B 374C 374D 374F 3751 3753 3755 3755 3756 3758 375A 375A 375C 375E 375E 3760 3762 3762 3763 3765 3766 3767 3769 376A 376B 376C 376C 376D 376E 3770 3770 3771 3774 3777 3777 3778 3779 377A 377B 377D 377E 377F 3782 3783 3785 3786 3787 3788 378A 378A 378B 378C 378E 3790 3790 3790 3790 3790 3792 3793 3796 3796 3799 3799 379A 379A 379C 379F 379F 37A1 37A1 37A1 37A1 37A2 37A4

4F CD1F1F CDDE1F F1 CB6F 2827 17 3006 DBFB F5 E5 18D3 CBEE 7E E61F C607 4F 0600 09 11CC5A 0E05 EDB8 13 EB D1 F1 D3FB 0E05 EDB0 18B5 17 CBBE 38B0 CBEE 18AC FEFF 202E 7E E60F 3C 4F 0600 E5 09 4E C5 79 E66F 23 CD0D14 CA082D C1 D1 C5 1A E60F 4F 0C 2ABC5B AE E60F AE EB 77 EDB0 C1 79 E6EF 180A DLOCS: DLOC2:

LD C,A CALL ADDRNV CALL ADDAHLCDE POP AF BIT 5,A JR Z,DLOC3 RLA JR NC,DLOC2 IN A,(URPORT) PUSH AF PUSH HL JR DELOCAL SET 5,(HL) LD A,(HL) AND 1FH ADD A,7 LD C,A LD B,0 ADD HL,BC LD DE,TEMPW1+4 LD C,5 LDDR INC DE EX DE,HL POP DE POP AF OUT (URPORT),A LD C,5 LDIR JR DELOCAL RLA RES 7,(HL) JR C,DELOCAL SET 5,(HL) JR DELOCAL CP 0FFH JR NZ,DLCS2 LD A,(HL) AND 0FH INC A LD C,A LD B,0 PUSH HL ADD HL,BC LD C,(HL) PUSH BC LD A,C AND 6FH INC HL CALL LKBSV JP Z,VNFERR POP BC POP DE PUSH BC LD A,(DE) AND 0FH LD C,A INC C LD HL,(STRLOCN) XOR (HL) AND 0FH XOR (HL) EX DE,HL LD (HL),A LDIR POP BC LD A,C AND 0EFH JR DLCS3

;CDE=DISP (PAGE FORM)

;JR IF NOT ADDR OF REF VALUE/DP VAR TLBYTE ;JR IF HL POINTS TO DEF PROC VAR TLBYTE ;(ALWAYS FOLLOWS REF VALUE ADDR) ;WE DON"T NEED THIS REF VALUE ADDR YET - SAVE ;PAGE ;AND ADDR. ;VAR THAT WAS LOCAL MARKED "UNUSED"

;PT TO VALUE OF LOCAL VAR (LAST BYTE) ;USE TEMP AREA AS BUFFER ;COPY LOCAL VAR VALUE TO BUFFER ;HL PTS TO TEMPW1 ;DE PTS TO VALUE AREA OF REF VAR

DLOC3:

;"VISIBLE" (IN CASE GLOBAL VAR NEEDS IT) ;JR IF IT WAS ;VAR THAT WAS LOCAL MARKED "UNUSED" ;JR IF NOT A REF STRING/ARRAY ;ORIG TLBYTE

;PT TO DEF PROC NAME FOLLOWING ORIG NAME. ;DEF PROC CODE BYTE (BIT 7 HOLDS EXTRA ;DATA, BIT 4 IS SET) ;NORMAL T/L BYTE FOR DP NAME ;(SIMPLE $ VS ARRAY $ IRREL. TO SEARCH ROUTINE) ;LOOK FOR DEF PROC NAME ;B=0, C=CODED BYTE ;DE PTS TO ORIG NAME ;CODE BYTE IN C ;BC=ORIG NAME LEN, INC T/L BYTE ;ADDR OF T/L BYTE IN VARS ;TYPE FROM VARS, NAME LEN FROM ORIG ;COPY ORIG TLBYTE/NAME BACK TO VAR, BUT USE ;ACTUAL VAR'S TYPE BITS. ($ ARRAY VS $) ;RES 4,A ** ;THERE"S NEVER A VERSION TO ERASE - RENAMED INSTEAD

;LOOK FOR STRING/ARRAY AND ERASE IT IF FOUND; ALSO, IF A GLOBAL VERSION WAS ;HIDDEN, LOOK FOR IT (LAST "INVIS" VERSION OF VAR) AND REVEAL IT. E6EF F5 CD0D14 C45B2C F1 CB7F C43114 2810 D5 DBFB F5 DLOCL: DLCS3: DLCS2: AND 0EFH PUSH AF CALL LKBSV CALL NZ,ASDEL2 POP AF BIT 7,A CALL NZ,STARYLK2 JR Z,DELCLH ;FIND LAST INVISIBLE VERSION PUSH DE IN A,(URPORT) PUSH AF ;PTR TO T/L BYTE IN VARS ;RES BIT 4 (VARS FORM ALWAYS HAS BIT 4 RESET) ;LOOK FOR VAR NAMED ON BSTK. NZ=FND ;DELETE STRING/ARRAY WITH PAGE/LEN AT HL IF IT ;WAS FOUND ;LOOK FOR INVIS VERSION IF THERE WAS A GLOBAL ;VERSION ;JR IF NONE (SHOULD BE AT LEAST ONE...)

37A5 37A8 37A9 37AA 37AC 37AC 37AD 37AF 37B1 37B1 37B4 37B4 37B4 37B4 37B4 37B4 37B7 37BA 37BC 37BC 37BF 37C2 37C2 37C5 37C8 37CB 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37CE 37D1 37D4 37D5 37D8 37DB 37DC 37DD 37DE 37DF 37E0 37E3 37E4 37E5 37E8 37E8 37EB 37EC 37ED 37EF 37EF 37F2 37F3 37F4 37F6 37F6 37F8 37FA 37FA 37FC 37FC 37FF 3802 3804 3808 380B 380B 380B 380B 380C 380E 380E 380F 3811 3813 3816 3817 381A 381B 381C 381E 3821 3822 3823 3824 3825 3827 3829 3829 382C 382D 382D

CD6D14 C1 E1 20F5 78 D3FB CBBE C30A37 DELCLH:

CALL FLNOMTCH POP BC POP HL JR NZ,DLOCL LD A,B OUT (URPORT),A RES 7,(HL) JP DELOCAL

;BHL=ADDR OF PREVIOUS "FOUND" VAR (T/L BYTE) ;JR IF WE JUST FOUND ANOTHER ;PT TO LAST INVIS VERSION ;MAKE VISIBLE

;POINT CHAD TO DEF PROC PARAMETER LIST OR PROC PARAMETER LIST ;EXIT: Z IF CHAD POINTS TO CR/COLON. A COMMA WILL BE SKIPPED. 2AAC5A 3AAB5A 1806 2AA95A 3AA85A 22975A 32965A CDDF3F C3793A PTTODP: PTTOPR: PTTOC: ; ; ; ; ; LD HL,(DPPTR) LD A,(DPPTRP) JR PTTOC LD HL,(PRPTR) LD A,(PRPTRP) LD (CHAD),HL LD (CHADP),A CALL SELURPG JP RCRC RST 18H CP 0DH RET Z CP ":" RET

INCLUDE MISC2.SAM ;BOOT, ERRORS, BUFMV AND STUBS FOR BUFF CMDS, ;MISC2.SAM RENUM, GET, AUTO, DELETE, LET, ;OPEN, CLOSE, DEF KEYCODE, LABEL, RUN, CLEAR ;FROM RST 08H 2A975A 22A35A 08 3A965A 32A25A D1 1A 13 D5 1B 2AEE5A 24 25 C40500 3AC35B 0F 1A 380D 3AC25B A7 1A 2015 FE80 3802 3E35 323A5C 21C35B CB86 ED7B3D5C C3951D A7 28EE 5F 0EFA ED40 210000 39 3AC25B 3D F3 D3FA 310080 FB C5 E5 7B FE80 3004 CD0342 37 D40042 DOSHK: NODOS: NORMERR: ERROR2: LD HL,(CHAD) LD (XPTR),HL EX AF,AF' LD A,(CHADP) LD (XPTRP),A POP DE LD A,(DE) INC DE PUSH DE DEC DE LD HL,(RST8V) INC H DEC H CALL NZ,HLJUMP LD A,(DOSCNT) RRCA LD A,(DE) JR C,NORMERR LD A,(DOSFLG) AND A LD A,(DE) JR NZ,PTDOS CP 128 JR C,NORMERR LD A,53 LD (ERRNR),A LD HL,DOSCNT RES 0,(HL) LD SP,(ERRSP) JP SETSTK AND A JR Z,NORMERR LD E,A LD C,250 IN B,(C) LD HL,0 ADD HL,SP LD A,(DOSFLG) DEC A DI OUT (250),A LD SP,8000H EI PUSH BC PUSH HL LD A,E CP 128 JR NC,DOSHK CALL 4203H SCF CALL NC,4200H ;ERROR NUMBER ;B=LRPORT ;0 OR DOS PAGE (1-1FH) ;GET PAGE NO. FOR SECTION A (DOS IN SECTION B) ;DOS PAGED IN AT 4000H, ROM0 ON, ROM1 OFF ;STACK NOW OK ;B=PREV LRPORT ;PREV STACK PTR ;HOOK CODE ;JR WITH HOOK CODES ;HANDLE ERROR CODE, RATHER THAN HOOK CODE ;'COMING FROM ERROR' ;HANDLE HOOK CODE IN A ;0 IF DOS NOT IN CONTROL, 1 IF DOS IN CONTROL ;ERROR NUMBER ;JR IF DOS RUNNING - DON'T RECURSE!

;JR IF DOS BOOTED ;JR IF NOT A DOS HOOK CODE ;'NO DOS' ;'DOS NOT IN CONTROL'

;PASS TO DOS PTDOS:

3830 3830 3830 3831 3832 3833 3835 3836 3837 3837 383A 383B 383C 383E 383E 3840 3840 3843 3844 3845 3846 3846 3847 3849 3849 384A 384D 384D 384E 3851 3851 3852 3855 3855 3856 3856 3857 3857 3857 3857 3857 3857 385A 385B 385B 385E 385F 385F 3862 3865 3867 3867 3867 3867 386A 386D 386D 386D 3870 3872 3872 3875 3875 3875 3875 3876 3879 387C 387F 3881 3881 3881 3881 3884 3885 3885 3885 3885 3885 3888 3889 3889 388C 388D 388D 3890 3891 3891 3894 3897 3897 389A 389A 389B 389C 389E 38A0 38A2 38A4 38A6 38A7 38A8 38A8

;'COMING FROM HOOK' MUST SET NC! E1 C1 F3 ED41 F9 FB 2AC05B 24 25 2018 3006 2A3D5C 2B 2B F9 A7 20B3 1D CAFDE1 1D CADBE4 1D CAFAE1 C9 E9 DHLJ: MEPROG: 21D4C5 DD 211DC3 DD 2100C0 010002 1830 2192C2 11004B 015100 1828 CDC204 D9 2133C5 11804D 01A100 1819 2100C2 DD TOKMAIN: TOKDE: LD HL,0C000H+RENLN+GETLN+DELLN+KEYLN+POPLN+INPLN+DKLN+RDLN+DFNLN+TOKLN DB 0DDH ;'JR+3' INPUT: RENUM: ;KEYIN A$ KEYIN: LD HL,0C000H+RENLN+GETLN+DELLN LD DE,HDR ;SO OTHER CMDS DON'T CORRUPT KEYIN, EXCEPT ;LOAD/SAVE EXEC. WILL CORRUPT FIRST PART ;(HARMLESSLY) LD BC,KEYLN JR BUFMV2 CALL SETDE ;GET DE=WKSP OR ELINE START LD HL,0C000H+RENLN+GETLN+DELLN+KEYLN+POPLN DB 0DDH ;'JR+3' LD HL,0C000H LD BC,RENLN JR BUFMV ;PART 2 OF RENUM DOSNC: DOSC: POP HL POP BC DI OUT (C),B LD SP,HL EI LD HL,(DOSER) INC H DEC H JR NZ,DHLJ JR NC,DOSNC LD HL,(ERRSP) DEC HL DEC HL LD SP,HL AND A JR NZ,NORMERR DEC E JP Z,LDFL DEC E JP Z,SVFL DEC E JP Z,LKTH RET JP (HL) ;PREV STACK PTR ;PREV LRPORT RESTORED ;PREV STACK

;JP TO VECTOR IF WANTED ;NC/CY FROM 4200/4203 - JR IF WAS HOOK CODE

;CLEAR STACK IF WAS ERROR ENTRY ;JR IF ERROR (NORMAL ERROR, OR DOS ERROR (81-127D) ;JP IF E WAS 1 - LOAD MAIN BODY OF FILE ;JP IF E WAS 2 - SAVE ENTIRE FILE ;JP IF E WAS 3 - LOAD ENTIRE FILE ** NEW JUMP ;RET IF NO ERRORS - TO NEXT STAT IF VIA ERROR ENTRY

;STUBS OF ROUTINES THAT COPY FROM ROM1 TO BUFFER FOR EXECUTION:

;ENTRY FROM VAL FUNCTION EXX LD HL,0C000H+RENLN+GETLN+DELLN+KEYLN+POPLN+INPLN+DKLN+RDLN+DFNLN LD DE,CDBUFF+80H ; (4D80-4E24) LD BC,TOKLN JR BUFMV2 LD HL,0C000H+RENLN DB 0DDH ;'JR+3'

;GET X OR GET X$ GET: ;POP <X> ;DELETE N TO M - DELETE PROGRAM LINES 2130C2 DD 21E3C2 DD 216EC4 DD 21EFC4 019100 11004F D5 F5 3E5F D3FA EDB0 3E1F D3FA F1 C9 3EFF DELETE: POP: DEFKEY: DEFFN: BUFMV: BUFMV2: LD HL,0C000H+RENLN+GETLN DB 0DDH ;'JR+3' LD HL,0C000H+RENLN+GETLN+DELLN+KEYLN DB 0DDH ;'JR+3' LD HL,0C000H+RENLN+GETLN+DELLN+KEYLN+POPLN+INPLN DB 0DDH ;'JR+3' LD HL,0C000H+RENLN+GETLN+DELLN+KEYLN+POPLN+INPLN+DKLN+RDLN LD BC,91H ;(DEF KEY LEN =90H) LD DE,INSTBUF PUSH DE PUSH AF LD A,5FH OUT (250),A LDIR LD A,1FH OUT (250),A POP AF RET LD A,0FFH

;ROM1 ON ;ROM1 OFF ;TO INSTBUF

DEFAULT:

38AA 38AB 38AB 38AC 38AC 38AF 38B0 38B0 38B1 38B1 38B4 38B5 38B7 38BA 38BA 38BB 38BE 38BF 38C1 38C1 38C4 38C6 38C6 38C9 38CA 38CC 38CC 38CC 38CC 38CC 38CC 38CF 38D0 38D2 38D2 38D5 38D5 38D8 38DA 38DA 38DD 38DD 38DE 38E0 38E2 38E2 38E3 38E3 38E3 38E3 38E6 38E9 38E9 38EA 38EA 38EA 38EA 38EA 38EB 38EB 38EB 38EB 38EE 38F1 38F3 38F4 38F4 38F5 38F6 38F6 38F6 38F6 38F6 38F9 38FC 38FF 3901 3901 3904 3907 3908 3909 390A 390B 390D 390F 390F 3912 3915 3916 3916 3917 3918 391B 391C 391D 3920 3923 3926 3929 392C 392D 392E

FE AF 32755B FE E7 CDF72C DF FE3D C2290D E7 3A755B 3C 2019 CDC63A 3014 3A715C 1F 380E ; ; ; 3AB15A A7 2808 CD083B CD121D 1803 CDFA2A DF FE2C 28CE C9 CDC63A DAF210 FE LABEL: LET3: LET4: LET2: LETLP: LET:

DB 0FEH XOR A LD (LTDFF),A DB 0FEH RST 20H CALL SYNTAX1 RST 18H CP "=" JP NZ,NONSENSE RST 20H LD A,(LTDFF) INC A JR NZ,LET3 CALL RUNFLG JR NC,LET3 LD A,(FLAGX) RRA JR C,LET3 LD HL,FLAGS BIT 6,(HL) JR Z,LET2 LD A,(DFTFB) AND A JR Z,LET3 CALL EXPTEXPR CALL FDELETE JR LET4 CALL VALFET1 RST 18H CP "," JR Z,LETLP RET ;E.G. LABEL heaven: CALL RUNFLG JP C,SKIPCSTAT DB 0FEH

;'JR+1'

;'JR+1' ;CHECK VALID VAR

;JR IF 'LET', CONTINUE WITH 'DEFAULT' ;EVEN IF 'DEFAULT', ;ALWAYS CHECK ASSIGNED VALUE IF SYNTAX TIME ;JR IF VAR DOESN'T EXIST - CREATE IT, LIKE 'LET' ;JR IF STRING

;EVAL ASSIGNED VALUE IN ORDER TO SKIP IT. (SLOW, ;BUT SAVES USE OF SPECIAL SKIPEXPR ROUTINE)

;JUST SKIP STATEMENT IF RUNNING ;'JR+1'

;SKIP, CHECK FOR VALID NUMERIC VARIABLE ;USED BY COMPILE, LABEL E7 CDF72C 213B5C CB76 C0 CF 1D SVNUMV: VNUMV: RST 20H CALL SYNTAX1 LD HL,FLAGS BIT 6,(HL) RET NZ RST 08H DB 29 ;TCLR.SAM - CLEAR, RUN CD503A CD9219 CDA234 180E CD503A CD8C3F 4F 0D B4 B5 CBFC 2007 3AB15C 2AB25C 4F C5 E5 CD1F1F EB 4F 2A945A 3A935A CDE71F 015D02 CDD41F 44 4D 2A885A RUN: CALL SYNTAX3 CALL GOTO2 CALL RESTOREZ JR CLR1 CALL SYNTAX3 CALL UNSTLEN LD C,A DEC C OR H OR L SET 7,H JR NZ,CLR3 LD A,(RAMTOPP) LD HL,(RAMTOP) LD C,A PUSH BC PUSH HL CALL ADDRNV EX DE,HL LD C,A LD HL,(ELINE) LD A,(ELINEP) CALL SUBAHLCDE LD BC,025DH CALL SUBAHLBC LD B,H LD C,L LD HL,(NVARS) ;SET NEWPPC AND NSPPC FOR JUMP ;DO RESTORE 0. SWITCHES IN PROGP ;NOW DO CLEAR 0 ;NUMBER OR ZERO ;VALID VAR ;RET IF NUMERIC ;'SYNTAX ERROR' ;FROM POP, LABEL

CLEAR:

;JR IF A CLEAR PARAM USED

CLR1: CLR3:

;CDE=NVARS ;GET ELINE-NVARS IN AHL (AT LEAST 025DH) ;AHL=SPACE TO RECLAIM

3931 3934 3937 393A 393D 3940 3943 3946 3949 394A 394B 394E 3950 3950 3953 3954 3956 3956 3957 3958 3958 3958 3958 3959 395C 3960 3961 3962 3965 3966 396A 396B 396B 396B 396B 396B 396E 3971 3974 3977 3979 397C 397F 3981 3981 3983 3984 3986 3986 3987 398A 398C 398E 3991 3993 3995 3996 3999 399A 399B 399E 39A0 39A1 39A2 39A3 39A4 39A5 39A6 39A7 39A9 39AC 39AD 39AE 39AE 39AF 39B0 39B0 39B4 39B6 39B6 39BA 39BA 39BA 39BA 39BA 39BB 39BD 39BF 39C2 39C5 39C8 39C9 39CB 39CC 39CC 39D0 39D3 39D4 39D4 39D4 39D4 39D6 39D6

CD531E CD6B39 CDDB33 CD9806 2A8E5A 3A8D5A 01B400 CDCC1F D1 C1 CDE71F 3006 3AB05C B9 3002 CF 30 79 32B15C ED53B25C E1 C1 31004F C5 ED733D5C E9 RTERR:

CALL RECL2BIG CALL CLRSR CALL DOCOMP CALL MCLS LD HL,(WKEND) LD A,(WKENDP) LD BC,180 CALL ADDAHLBC POP DE POP BC CALL SUBAHLCDE JR NC,RTERR LD A,(LASTPAGE) CP C JR NC,CLR4 RST 08H DB 48 LD A,C LD (RAMTOPP),A LD (RAMTOP),DE POP HL POP BC LD SP,ISPVAL PUSH BC LD (ERRSP),SP JP (HL)

;RECLAIM ABC AT HL ;COMPILE ;CLEAR ENTIRE SCREEN ;** ;AHL=WKEND+180 ;CDE=CLEAR PARAM, OR RAMTOP ;JR IF RAMTOP WILL BE TOO CLOSE TO WKEND ;OK IF RAMTOP PAGE <= LAST ALLOCATED PAGE ;'Invalid CLEAR address'

;CLEAR MACHINE STACK (SHOULDN'T NEED IT!) CLR4:

;NEXT STAT ;ERR HANDLER

;CLEAR FPCS, BASIC STACK, NUMERIC AND STRING VARS, TURNS 'RECORD' OFF ;SOUND CHIP OFF, ON ERROR OFF CDD439 32815B 32455B 2AC65B 36FF 22C45B CD1F1F 062E 36FF 23 10FB EB 21E339 0E1A EDB0 21E939 0E14 EDB0 EB CDB639 24 24 CDB039 36FF 25 25 2B 2B 2B 70 23 3601 3A4D5A A7 C0 34 C9 FD21815A 1804 FD21845A SETSAV: SETNE: CLRSR: CALL CLSND LD (GRARF),A LD (ONERRFLG),A LD HL,(BASSTK) LD (HL),0FFH LD (BSTKEND),HL CALL ADDRNV LD B,46 LD (HL),0FFH INC HL DJNZ CLNVP EX DE,HL LD HL,PSVTAB LD C,26 LDIR LD HL,PSVT2 LD C,20 LDIR EX DE,HL CALL SETNE INC H INC H CALL SETSAV LD (HL),0FFH DEC H DEC H DEC HL DEC HL DEC HL LD (HL),B INC HL LD (HL),1 LD A,(THFATT) AND A RET NZ INC (HL) RET LD IY,SAVARSP JR SETSYS LD IY,NUMENDP ;CLEAR SOUND CHIP, A=0 ;GRAPHICS RECORDING OFF ;ON ERROR OFF ;CLEAR DO/GOSUB/ETC STACK

CLNVP:

;INIT 23 LETTER PTRS

;COPY 3 PTRS AND YOS/YRG ;COPY YOS/YRG AGAIN

;FF TERMINATOR OF SAVARS

;CHANGE 192 YRG TO 0 ;NOW 256

;IF MODE 2 THIN PIX, MAKE XRG=512

;SET SYS VAR TO CURRENT PAGE AND ADDR IN HL. ADJUST IF NEEDED TO 8000-BFFF, BUT ;KEEP HL THE SAME. ONLY F AND IY ALTERED F5 DBFB E61F FD7700 FD7501 FD7402 F1 CB74 C8 FDCB02B6 FD3400 C9 3E20 01FF01 CLSND: CSRL: SETSYS: PUSH AF IN A,(251) AND 1FH LD (IY+0),A LD (IY+1),L LD (IY+2),H POP AF BIT 6,H RET Z RES 6,(IY+2) INC (IY+0) RET LD A,32 ;CLEAR 32 REGISTERS

LD BC,SNDPORT+0100H ;SOUND REG ADDR

39D9 39DA 39DC 39DD 39DF 39E0 39E2 39E2 39E3 39E3 39E5 39E7 39E9 39E9 39EA 39EC 39EE 39F3 39F3 39F4 39F6 39F8 39FD 39FD 39FD 39FD 39FD 39FD 39FD 39FD 39FD 39FD 39FD 39FD 39FE 3A00 3A01 3A02 3A05 3A08 3A0B 3A0C 3A0E 3A0F 3A12 3A15 3A15 3A16 3A18 3A19 3A1A 3A1B 3A1C 3A1D 3A1E 3A1F 3A20 3A21 3A22 3A23 3A24 3A25 3A26 3A28 3A28 3A29 3A2A 3A2A 3A2B 3A2C 3A2F 3A32 3A35 3A36 3A37 3A38 3A39 3A3A 3A3C 3A3F 3A40 3A42 3A43 3A43 3A46 3A49 3A4C 3A4E 3A4F 3A4F 3A50 3A50 3A50 3A50 3A51 3A54 3A55 3A55 3A56 3A57 3A57 3A58 3A58

3D ED79 05 ED41 A7 20F4 C9 1900 0300 FFFF PSVTAB:

DEC A OUT (C),A DEC B OUT (C),B AND A JR NZ,CSRL RET DW 0019H DW 0003H DW 0FFFFH DB DW DB DB DB DW DB DB 2 8 "os" 0,0,0,0,0 2 0FFFFH "rg" 0,0,192,0,0

;BC=DATA PORT

;X VARS ;Y VARS ;Z VARS

02 PSVT2: 0800 6F73 0000000000 02 FFFF 7267 0000C00000

;YOS

;YRG

;STREAM 16 IS CONVERTED TO STREAM -4 INTERNALLY ;CLOSE #16 AND OPEN #16 NOT ALLOWED ;E.G. RECORD TO A$: LET A$="": PRINT #16;"TESTING" ADDS "TESTING (CR)" TO A$ ;O/P TO STREAM 16 LOOKS FOR STRING NAME IN (STRM16NM), AND 'PRINTS' CHARS ;TO THE END OF THE STRING. ;ALLOWS 'SERIAL FILES', TOKEN EXPANSION, CAT TO A STRING, RECORDING OF GRAPHICS ;COMMANDS, ETC. CALLED WITH ROM1 OFF 47 DBFB F5 C5 21765B 113F51 010B00 7E EDB0 4F CD3114 CA082D C1 DBFB F5 E5 C5 7E 23 4E 23 0F 0F B6 47 03 78 3C 2002 CF 2A C5 09 DC9D1F CDEF3F CD181E C1 F1 77 D1 F1 D3FB CD433A F1 D3FB C9 CD791F 21835B 010300 EDB0 C9 E7 DF CDF73A D8 F1 C9 E7 SSYNTAX6: STLERR: S16OK: S16OSR: LD B,A IN A,(URPORT) PUSH AF PUSH BC LD HL,STRM16NM LD DE,TLBYTE LD BC,11 LD A,(HL) LDIR LD C,A CALL STARYLK2 JP Z,VNFERR POP BC IN A,(URPORT) PUSH AF PUSH HL PUSH BC LD A,(HL) INC HL LD C,(HL) INC HL RRCA RRCA OR (HL) LD B,A INC BC LD A,B INC A JR NZ,S16OK RST 08H DB 42 PUSH BC ADD HL,BC CALL C,PGOVERF CALL CHKHL CALL MKRM1 POP BC POP AF LD (HL),A POP DE POP AF OUT (URPORT),A CALL MBC POP AF OUT (URPORT),A RET CALL SPLITBC LD HL,PAGCOUNT LD BC,3 LDIR RET RST 20H RST 18H CALL FETCHNUM RET C POP AF RET RST 20H ;SYNTAX 6 - INSIST ON NUMBER ;CHAR TO O/P ;SAVE URPORT STATUS AND RESTORE AT END ;STORED TLBYTE AND NAME OF STRING

;B=DATA ;SAVE ADDR OF $ LEN DATA

;BC=LEN ;NEW LEN ;OK UNLESS STRING LEN >FEFF ;'String too long' ;HL PTS TO LAST BYTE ;OPEN 1 SPACE AT END OF STRING ;NEW LEN ;A=DATA ;ADD CHAR TO END ;PAGE IN STRING HEADER AT DE

MBC:

;COPY PAGE/LEN TO STRING

SSYNTAX3: SYNTAX3:

;SYNTAX 3 - NUMBER, OR USE 0 ;RET IF RUNNING ;JUNK RET ADDR

3A58 3A58 3A5B 3A5C 3A5C 3A5D 3A5E 3A5E 3A5F 3A5F 3A5F 3A5F 3A62 3A63 3A63 3A64 3A65 3A65 3A66 3A66 3A66 3A66 3A69 3A6A 3A6A 3A6B 3A6C 3A6C 3A6C 3A6C 3A6C 3A6E 3A6F 3A6F 3A71 3A72 3A72 3A72 3A74 3A75 3A75 3A75 3A75 3A77 3A78 3A78 3A79 3A79 3A7A 3A7A 3A7A 3A7A 3A7C 3A7D 3A7D 3A7F 3A80 3A80 3A81 3A81 3A81 3A81 3A83 3A85 3A85 3A87 3A89 3A89 3A8A 3A8B 3A8B 3A8B 3A8B 3A8C 3A8C 3A8C 3A8C 3A8E 3A90 3A90 3A91 3A92 3A92 3A92 3A92 3A95 3A95 3A95 3A95 3A97 3A99 3A99 3A9A 3A9B 3A9B 3A9B 3A9B 3A9C 3A9E 3AA0 3AA0 3AA0 3AA0

CDE43A D8 F1 C9 E7 CDDC3A D8 F1 C9 E7 CDA13A D8 F1 C9

SYNTAX6:

CALL EXPT1NUM RET C POP AF RET

SSYNTAX8: SYNTAX8:

RST 20H CALL EXPT2NUMS RET C POP AF RET

;SYNTAX 8 - INSIST ON NUMBER,NUMBER

SSYNTAXA: SYNTAXA:

RST 20H CALL EXPTSTR RET C POP AF RET

;SYNTAX A - INSIST ON A STRING

;COMMA/SEMICOLON RETURN Z FE2C C8 FE3B C9 FE8E C8 FE2C C8 FE DF FE3A C8 FE0D C9 DF FE3B 2804 FE2C 201E E7 C9 E7 FE28 2017 E7 C9 CDE43A FE29 200E E7 C9 DF FE2C 2007 E7 EXPTCSTR: EX1NUMCB: INSISCBRK: RICSC: INSISCSC: INSISCOMA: INSCOMN: RCRC: CRCOLON: COCRCOTO: COMMASC: CP "," RET Z CP ";" RET CP TOTOK RET Z CP "," RET Z DB 0FEH RST 18H CP ":" RET Z CP 0DH RET RST 18H CP ";" JR Z,INSCOMN CP "," JR NZ,SYNONS RST 20H RET RST 20H CP "(" JR NZ,SYNONS RST 20H RET ;EXPECT NUMBER, THEN CLOSING BRACKET CALL EXPT1NUM CP ")" JR NZ,SYNONS RST 20H RET ;EXPECT COMMA, THEN STRING RST 18H CP "," JR NZ,SYNONS RST 20H ;INSIST ON A CLOSING BRACKET ;INSIST ON A COMMA OR SEMI-COLON, SKIP ;CR/COLON RETURN Z ;'JR+1'

;COMMA/CR/COLON RETURN Z COMCRCO:

;SKIP, INSIST ON OPENING BRACKET SINSISOBRK: INSISOBRK: ;INSIST ON AN OPENING BRACKET

;SKIP, EXPECT STRING SEXPTSTR:

3AA1 3AA1 3AA1 3AA1 3AA4 3AA5 3AA6 3AA7 3AA7 3AA8 3AA9 3AA9 3AA9 3AA9 3AAC 3AAE 3AAE 3AAE 3AAE 3AB1 3AB4 3AB6 3AB6 3AB6 3AB6 3AB9 3ABC 3ABE 3AC0 3AC0 3AC3 3AC3 3AC6 3AC6 3AC9 3ACA 3ACB 3ACB 3ACB 3ACB 3ACE 3AD1 3AD3 3AD3 3AD3 3AD3 3AD4 3AD4 3AD7 3AD9 3ADB 3ADB 3ADB 3ADB 3ADC 3ADC 3ADC 3ADC 3ADF 3ADF 3ADF 3ADF 3AE1 3AE3 3AE3 3AE3 3AE3 3AE3 3AE4 3AE4 3AE4 3AE4 3AE7 3AE8 3AE9 3AEA 3AEA 3AEC 3AEC 3AEC 3AEC 3AEF 3AF0 3AF0 3AF2 3AF2 3AF2 3AF2 3AF2 3AF5 3AF7 3AF7 3AF7 3AF7 3AFA 3AFC 3AFC 3AFF 3B00 3B01 3B01 3B02 3B05

;EXPECT STRING CDE314 87 79 F0 CF 1D CD9B3A 1815 CD8B3A CDDC3A 180D CD8B3A CDA13A FE2C 20E7 CDE33A CD953A 3A3B5C 87 C9 CD8B3A CDE43A 18D6 E7 CDDC3A FE2C 20CC E7 CDE43A FE2C 20C4 EXPTSTR: CALL SCANNING ADD A,A LD A,C RET P RST 08H DB 29 CALL EXPTCSTR JR EXCBRF CALL SINSISOBRK CALL EXPT2NUMS JR EXCBRF CALL SINSISOBRK CALL EXPTSTR CP "," JR NZ,SYNONS CALL SEXPT1NUM CALL INSISCBRK LD A,(FLAGS) ADD A,A RET CALL SINSISOBRK CALL EXPT1NUM JR EXPTCSTRB RST 20H CALL EXPT2NUMS CP "," JR NZ,SYNONS RST 20H CALL EXPT1NUM CP "," JR NZ,SYNONS ;CY IF RUNNING ;CURRENT CHAR ;RET IF STRING ;'SYNTAX ERROR'

SYNONS:

;EXPECT COMMA, STRING, CLOSING BRACKET EXPTCSTRB: ;CHECK ')', RUN FLAG ;SKIP, '(' ;N,N ;CHECK ')', RUN FLAG ;'(' ;A$ ;SKIP, GET N. CY IF RUNNING ;')' . CY IF RUNNING ;C IF RUNNING, P IF STRING, M IF NUMBER

;EXPECT '(N,N)'. SET CY IF RUNNING EXB2NUMB:

;EXPECT Bracket, String, Comma, Number, Bracket. '(a$,n)'. CY IF RUNNING EXBSCNB:

SEX1NUMCB: EXCBRF: RUNFLG:

;EXPECT Bracket, Number, Comma, String, Bracket. '(n,a$)'. CY IF RUNNING EXBNCSB: ;'(' ;N ;',A$)'

;SKIP, EXPECT N,N,N,N SEXPT4NUMS: EXPT4NUMS:

;SKIP, EXPECT N,N SEXPT2NUMS: ;EXPECT N,N EXPT2NUMS: ;EXPECT ,N EXPTCNUM:

;SKIP, EXPECT NUMBER E7 CDE314 87 79 F8 18BB CD1E3B D8 18B5 GETALPH: SEXPT1NUM: ;EXPECT NUMBER EXPT1NUM: CALL SCANNING ADD A,A LD A,C RET M JR SYNONS ;INSIST A=LETTER CALL ALPHA RET C JR SYNONS ;SYNTAX9 - DEAL WITH COLOUR ITEMS, COORDS ; EG INK 3,PAPER 1;X,Y. USED BY PLOT, CIRCLE, FILL CD4513 18E5 CD7A3A 20E8 3A3B5C 17 D0 AF CDDA1C 37 SYNTAX9: CALL SYNT9SR JR EXPT2NUMS CALL CRCOLON JR NZ,EXPT1NUM LD A,(FLAGS) RLA RET NC XOR A CALL STACKA SCF ;'RUNNING' ;CY IF RUNNING ;RET IF NUMERIC RST 20H

;EXPECT N OR CR/COLON. RETURN WITH CY IF RUNNING FETCHNUM: CONDSTK0: ;EXITS WITH CY IF RUNNING

3B06 3B07 3B07 3B08 3B08 3B08 3B08 3B0B 3B0C 3B0E 3B0F 3B10 3B10 3B10 3B10 3B13 3B14 3B14 3B14 3B14 3B15 3B15 3B15 3B15 3B15 3B16 3B19 3B1A 3B1B 3B1C 3B1C 3B1D 3B1E 3B1E 3B1E 3B1E 3B20 3B21 3B22 3B22 3B24 3B25 3B25 3B27 3B28 3B28 3B2A 3B2B 3B2C 3B2C 3B2C 3B2C 3B2F 3B30 3B30 3B30 3B30 3B32 3B33 3B33 3B35 3B36 3B37 3B37 3B37 3B37 3B37 3B37 3B3A 3B3B 3B3B 3B3D 3B3E 3B3F 3B3F 3B41 3B41 3B41 3B41 3B41 3B44 3B45 3B45 3B47 3B48 3B49 3B49 3B4A 3B4B 3B4B 3B4B 3B4B 3B4B 3B4B 3B4B 3B4E 3B51 3B54 3B58 3B5A 3B5C 3B5C 3B5F

C9 E7 CDE314 17 CB7F 79 C9 CDD73F FE E7 SEXPTEXPR: EXPTEXPR:

RET RST 20H CALL SCANNING RLA BIT 7,A LD A,C RET CALL SELCHADP DB 0FEH RST 20H ;EXPECT AN EXPRESSION, SET Z IF STRING, NZ IF NUMERIC ;CY IF RUNNING

;USED BY INPUT,.. CHKENDCP: ;"JR+1"

;SKIP, ABORT IF SYNTAX TIME. USED BY E.G. PI, HIMEM, FREE. SABORTER: CHKEND: ABORTER: ;JUST RETURN IF RUNNING, ELSE JUNK A RET ADDR, RET TO NEXT LEVEL. 4F 3A3B5C 17 79 D8 F1 C9 FE41 3F D0 FE7B D0 FE5B D8 FE61 3F C9 CD1E3B D8 FE3A D0 FE30 3F C9 ALPHANUM: ALPHA: LD C,A LD A,(FLAGS) RLA LD A,C RET C POP AF RET ;CY IF A=LETTER, ELSE NC CP "A" CCF RET NC CP "z"+1 RET NC CP "Z"+1 RET C CP "a" CCF RET ;CY IF A=LETTER OR DIGIT CALL ALPHA RET C CP "9"+1 RET NC CP "0" CCF RET ;CY IF LETTER OR UNDERLINE OR '$' ;(SO E.G. printer, print_out, print$ ARE NOT TOKENISED, BUT print1, print: ARE) CD1E3B D8 FE24 37 C8 1804 ALDU: CALL ALPHA RET C CP "$" SCF RET Z JR CKUND ;CY IF LETTER, DIGIT OR UNDERLINE CD2C3B D8 FE5F 37 C8 A7 C9 ALNUMUND: CKUND: CALL ALPHANUM RET C CP "_" SCF RET Z AND A RET ;EVAL. BRACKETLESS SLICER E.G. 10 TO 30, TO 100, 100 TO, TO ;ENTRY: CHAD PTS TO POSSIBLE SLICER, A=(CHAD) ;EXIT: SYS VARS SET UP, WITH VALUE, IF GIVEN, OR DEFAULT. CHAD PTS. TO NON-ALPHA ;NUMERIC CHAR, NOT 'TO'. IF RUNNING, CY=OUT OF RANGE. A=0 IF SLICER IS 1 NUMBER 210100 11FFFE 227D5A ED537F5A FE8E 281A CD2C3B D0 BRKLSSL: LD LD LD LD CP JR HL,1 DE,0FEFFH (FIRST),HL (LAST),DE TOTOK Z,BRL2 ;MIN ;MAX (LINE NUMBERS) ;NC IF TOO HIGH ;RET IF TOO LOW ;RET IF TOO HI ;RET IF UC

;CY IF A DIGIT NUMERIC:

CALL ALPHANUM RET NC

;NC='IN RANGE' IF EG LIST

3B60 3B60 3B63 3B65 3B65 3B69 3B6B 3B6C 3B6F 3B70 3B70 3B72 3B74 3B76 3B76 3B76 3B77 3B7A 3B7B 3B7B 3B7E 3B7F 3B80 3B80 3B83 3B85 3B86 3B86 3B87 3B88 3B88 3B8B 3B8C 3B8D 3B8D 3B8D 3B8D 3B8D 3B8D 3B8D 3B8D 3B8E 3B8E 3B91 3B92 3B93 3B93 3B96 3B97 3B98 3B99 3B9A 3B9B 3B9B 3B9B 3B9B 3B9B 3B9B 3B9E 3B9E 3BA1 3BA1 3BA4 3BA5 3BA7 3BA7 3BA8 3BAA 3BAC 3BAC 3BAD 3BAE 3BAE 3BAE 3BAE 3BB1 3BB1 3BB1 3BB2 3BB4 3BB4 3BB5 3BB5 3BB6 3BB7 3BBA 3BBA 3BBA 3BBB 3BBD 3BBE 3BBE 3BBF 3BC1 3BC2 3BC3 3BC4 3BC5 3BC8 3BCB 3BCE 3BCF 3BD1

CD8E3B 380B ED4B7D5A ED42 09 227D5A D8 FE8E 3E00 2012 E7 CD2C3B D0 CD8E3B 3F D0 2A7F5A ED42 D8 60 69 227F5A A7 C9 BRL3: BRL1:

CALL GIR2 JR C,BRL1 LD BC,(FIRST) SBC HL,BC ADD HL,BC LD (FIRST),HL RET C CP TOTOK LD A,0 JR NZ,BRL3 RST 20H CALL ALPHANUM RET NC CALL GIR2 CCF RET NC LD HL,(LAST) SBC HL,BC RET C LD H,B LD L,C LD (LAST),HL AND A RET

;GET INT IN BC AND HL IF RUNNING, NC IF RUNNING ;JR IF NOT RUNNING ;MIN ;RET IF MIN>VALUE ;CANNOT USE XOR A! ;JR WITH A=0 (FLAG) IF SLICER = 1 NUMBER ;LAST=FIRST ;'IN RANGE' IF EG LIST 10 TO ;END WITH NC IF SYNTAX TIME AND EG LIST 10 TO 20 ;MAX ;RET IF VALUE>MAX

BRL2:

;GET IF RUNNING - AUTO, DELETE, BRACKETLESS SLICER SR. ;ENTRY: CHAD PTS TO EXPR (GIR2) OR IS BEFORE EXPR (GIR). ;EXIT: CHAD PTS PAST EXPR, A=(CHAD), BC AND HL=INT (IF RUNNING) ;CY IF RUNNING E7 CDE43A 3F D8 CD2E1D DF 60 69 A7 C9 GIR: GIR2: RST 20H CALL EXPT1NUM CCF RET C CALL GETINT RST 18H LD H,B LD L,C AND A RET ;DISPLAY (SCREEN) CD503A CD331D 32775A A7 2807 F7 82D2 2005 CF 2B 3A785A F7 2CE5 C8 D5 A7 CDBE3B F1 D3FC 37 08 DBFB F5 08 F5 3C CDDF3F 21D8BF 11D855 F1 3801 SDISR: ISCRERR: SETDISP: DISPLAY: CALL SYNTAX3 CALL GETBYTE LD (CURDISP),A AND A JR Z,DEFDISP RST 30H DW SCRNTLK2 JR NZ,VIDSEL RST 08H DB 43 LD A,(CUSCRNP) RST 30H DW CUS2 RET Z PUSH DE AND A CALL SDISR POP AF OUT (VIDPORT),A SCF ;IN A AND C ;'DISPLAY 0' MEANS DISPLAY CURRENT SCREEN ;GET MODE/PAGE FOR SCREEN C, Z IF UNUSED ;'INVALID SCREEN NUMBER' (ERRORS SET CURDISP TO 0) ;PAGE BEING USED FOR PRINT, PLOT, ETC.(CURRENT) ;CONTAINS MODE TOO. ;SEE IF DISPLAYED=CURRENT ;RET IF NO CHANGE IN DISPLAYED SCREEN. ;NEW DISPLAY PAGE IN D ;NC ;SWITCH PREV DISPLAYED SCREEN IN AT 8000H ;AND COPY WORKING PALTAB TO IT FOR LATER USE IF ;IT IS RE-DISPLAYED ;MODE/PAGE SENT TO HARDWARE - NEW DISPLAY ;RET IF NOT RUNNING

;INT IN BC AND HL, NC

;DEFAULT DISPLAY (USED BY 'DISPLAY' AND REPORTS) DEFDISP: VIDSEL:

EX AF,AF' IN A,(251) PUSH AF EX AF,AF' PUSH AF INC A ;SO SECOND PAGE OF SCREEN AT 8000H CALL TSURPG LD HL,PALBUF-4000H ;END OF SECOND SCREEN PAGE LD DE,PALTAB POP AF JR C,SDIS2

3BD1 3BD2 3BD2 3BD5 3BD7 3BD7 3BDA 3BDA 3BDD 3BDD 3BDD 3BDD 3BDE 3BDF 3BDF 3BDF 3BDF 3BE0 3BE0 3BE3 3BE6 3BE8 3BE8 3BE9 3BE9 3BEC 3BEF 3BF1 3BF3 3BF4 3BF5 3BF6 3BF7 3BF9 3BFB 3BFE 3BFE 3BFE 3BFE 3BFF 3C00 3C01 3C04 3C04 3C05 3C05 3C06 3C07 3C08 3C0A 3C0D 3C0D 3C0E 3C0F 3C0F 3C10 3C10 3C11 3C12 3C14 3C14 3C15 3C16 3C17 3C18 3C1A 3C1A 3C1B 3C1C 3C1D 3C1D 3C1F 3C1F 3C22 3C23 3C24 3C26 3C26 3C26 3C27 3C28 3C29 3C2A 3C2C 3C2C 3C2D 3C2E 3C2F 3C30 3C31 3C31 3C31 3C31 3C31 3C32 3C32 3C33 3C33 3C34 3C34 3C37 3C38 3C39

EB 012800 EDB0 C3453C 32785A 37 26 A7 21345A 11B0FE 3001 EB CDA83F 013C00 EDB0 0E90 09 EB 09 EB 0E40 EDB0 C3BF3F C5 42 4B 11004F C5 F5 08 1A EDB1 E2313C E5 3E 23 08 3D 2812 08 13 1A BE 28F5 D9 B9 D9 28F0 11004F E1 F1 18DF E1 E1 E1 A7 ED42 C1 09 44 4D C9 FOUND: CHKNXTC: LOOKLP: SSVRC: PRSVARS: RSVARS: SDIS2:

EX DE,HL LD BC,28H LDIR JP PPORT LD (CUSCRNP),A SCF DB 26H AND A LD HL,BGFLG LD DE,PVBUFF JR NC,SSVRC EX DE,HL CALL SPSSR LD BC,PRPOSN-BGFLG LDIR LD C,CEXTAB-PRPOSN ADD HL,BC EX DE,HL ADD HL,BC EX DE,HL ;SRC AND DEST ADVANCED TO COPY CEXTAB LD C,40H LDIR JP RCURPR PUSH BC LD B,D LD C,E LD DE,INSTBUF PUSH BC PUSH AF EX AF,AF' LD A,(DE) CPIR JP PO,NOTFND0 PUSH HL DB 3EH INC HL EX DEC JR EX INC LD CP JR EXX CP C EXX JR Z,CHKNXTC LD DE,INSTBUF POP HL POP AF JR LOOKLP POP HL POP HL POP HL AND A SBC HL,BC POP ADD LD LD RET BC HL,BC B,H C,L AF,AF' A Z,FOUND AF,AF' DE A,(DE) (HL) Z,CHKNXTC ;GET TARGET$ LEN COUNTER ;FOUND IF ALL CHARS MATCHED ;NEXT TARGET$ CHAR ;CP NEXT SEARCH$ CHAR ;C' IS USUALLY '#' ;HASH ALWAYS MATCHES ;MATCH FAILS - RESTORE T$ PTR ;S$ PTR ;REFRESH TARGET$ LEN COUNTER ;SEARCH$ PTR ;T$ LEN ;BYTES TO CHECK ;SBC BYTES TO CHECK, BYTES LEFT TO CHECK ;TO GET BYTES CHECKED ;START POSN ;BC=TARGET$ POSN IN SEARCH$. NC ;START POSN ;BC=BYTES TO CHECK ;HL=START-OF-SEARCH PTR, (SP)=START POSN ;DE=T$ START, A=T$ LEN ;BYTES TO CHECK ;TARGET$ LEN ;A'=TARGET$ LEN COUNTER ;GET FIRST TARGET$ CHARACTER ;LOOK FOR IT IN SEARCH$ USING HL AS PTR ;JR IF NOT FOUND - BC=0000 ;SEARCH$ PTR ;'JR +1' - HL IS AT SECOND CHAR ALREADY ;POSN, INK ETC. ATTACHED TO SCREEN ;COPY PALETTE TO/FROM DISPLAYED SCREEN ;AND PALTAB IN SYS VARS ;POP AF, OUT 251,RET

;RESTORE SCREEN VARS FROM SCREEN PAGE ;'JR+1'

;SAVE SCREEN VARS TO SCREEN PAGE SSVARS:

;ROM 0 INSTRING R0INST:

;ENTRY IF 1ST CHAR NEVER FOUND - HL IS PAST LAST POSN LOOKED AT F1 F1 D1 010000 37 C9 NOTFND2: NOTFND3: NOTFND0: ; POP AF EX AF,AF' POP AF POP LD SCF RET DE BC,0000H ;T$ LEN ;JUNK BYTES TO CHECK ;START POSN

3C39 3C39 3C39 3C39 3C39 3C39 3C39 3C39 3C39 3C39 3C3C 3C3F 3C42 3C42 3C43 3C45 3C45 3C46 3C48 3C49 3C49 3C4B 3C4D 3C4E 3C50 3C51 3C53 3C55 3C57 3C57 3C57 3C57 3C58 3C59 3C5B 3C5C 3C5F 3C60 3C61 3C62 3C65 3C67 3C67 3C67 3C67 3C67 3C67 3C6A 3C6B 3C6E 3C6F 3C70 3C71 3C73 3C74 3C75 3C78 3C79 3C7B 3C7B 3C7B 3C7E 3C7F 3C80 3C81 3C83 3C85 3C85 3C87 3C87 3C88 3C89 3C8C 3C8E 3C90 3C90 3C93 3C93 3C94 3C96 3C96 3C96 3C96 3C96 3C99 3C9A 3C9B 3C9B 3C9C 3C9D 3C9E 3C9F 3CA0 3CA1 3CA2 3CA3 3CA4 3CA6 3CA8 3CA8 3CA9 3CAC 3CAD

;LET/DEFAULT, LABEL, RUN, CLEAR, S16OP, SYNTAX ;SRS, DISPLAY, SCREEN, SETSV INCLUDE ENDPRINT.SAM ;END PRINT, ANY DE ADDR, PIXADDR, POATTR, NET ;ENDPRINT.SAM - FINAL SCREEN OUTPUT ROUTINES FOR MODES 0-3 PRINTABLE CHARS. ;ENTRY: DE=SCREEN ROW/COL, HL PTS TO CHAR DATA, B=OVER AND C=INVERSE MASK ;CALLED FROM ROM1 CD493C CDB63F CD7B3C F1 D3FA F1 D3FB C9 FDE1 DBFB F5 DBFA F5 E6BF D3FA FDE9 EB 23 DBFB F5 CD4D1A 56 23 5E 2A7D5A 18DE EPSUB: POPOUT: PPORT: R1OSR: CALL R1OSR CALL SELSCRN CALL EPSSR POP AF OUT (250),A POP AF OUT (251),A RET POP IY IN A,(251) PUSH AF IN A,(250) PUSH AF AND 0BFH OUT (250),A JP (IY) EX DE,HL INC HL IN A,(251) PUSH AF CALL FNDLINE LD D,(HL) INC HL LD E,(HL) LD HL,(FIRST) JR PPORT

;ROM1 OFF

;USED BY RENUM GTRLNN:

;GET LINE NUMBER

;COPY STRING FROM COMMON MEMORY TO WORKSPACE, STACK PARAMS ON FPCS. ;MOVE BC BYTES FROM (HL) TO WKSPACE. USED BY E.G. HEX$, CHR$, STR$. ;FOR STRINGS LEN 1-16K. EXIT: DE=STKEND, PAGING UNCHANGED. CD493C E5 CD801E E1 D5 C5 EDB0 C1 D1 CDE71C EB 18C7 3A365A E5 D9 D1 FE08 3802 3E08 47 D9 3A405A FE02 284C D2513D 3D 281F HPL2: CWKSTK: CALL R1OSR PUSH HL CALL WKROOM POP HL PUSH DE PUSH BC LDIR POP BC POP DE CALL STKSTOREP EX DE,HL JR POPOUT LD A,(CSIZE) PUSH HL EXX POP DE CP 8 JR C,HPL2 LD A,8 LD B,A EXX LD A,(MODE) CP 2 JR Z,M2PRINT JP NC,M3PRINT DEC A JR Z,M1PRINT ;******************************************************************************* ;MODE 0 PRINT. ENTRY: DE=SCREEN ROW/COL, HL=CHAR DATA, B=OVER AND C=INVERSE MASK CDE43D D5 D9 D9 1A A0 AE A9 12 23 14 7A E607 2005 EB CD090D EB M0PRINT: M0PRLP: CALL M0DEADDR PUSH DE EXX EXX LD A,(DE) AND B XOR (HL) XOR C LD (DE),A INC HL INC D LD A,D AND 07H JR NZ,M0PRNT2 EX DE,HL CALL NXTDOWN1 EX DE,HL ;GET DE=SCREEN ADDR ;SCAN COUNTER IN B' ;SCREEN DATA ;OVER MASK ;XOR SCRN ;XOR INVERSE MASK ;** BUG FIX - LIMIT O/P SCANS TO 8 ;DE=DEST, BC UNCHANGED

;DE=STKEND ;HEIGHT ** ;DE'=DATA PTR IF MODE 3/4

EPSSR:

;JR IF NOT CROSSING CHAR BOUNDARY

3CAD 3CAE 3CB0 3CB0 3CB1 3CB2 3CB5 3CB5 3CB5 3CB5 3CB5 3CB8 3CB9 3CB9 3CBA 3CBB 3CBC 3CBD 3CBE 3CBF 3CC0 3CC1 3CC3 3CC4 3CC4 3CC6 3CC6 3CC7 3CC7 3CC8 3CCA 3CCA 3CCB 3CCE 3CCF 3CD2 3CD2 3CD4 3CD7 3CD7 3CD8 3CD9 3CDB 3CDB 3CDC 3CDC 3CDC 3CDC 3CDC 3CDF 3CE1 3CE2 3CE3 3CE4 3CE6 3CE6 3CE9 3CE9 3CEA 3CEA 3CEB 3CEC 3CED 3CEE 3CEF 3CF1 3CF1 3CF2 3CF5 3CF6 3CF7 3CF9 3CF9 3CF9 3CF9 3CF9 3CFA 3CFB 3CFD 3CFD 3CFF 3D00 3D00 3D01 3D01 3D02 3D03 3D04 3D05 3D05 3D06 3D07 3D08 3D09 3D0B 3D0C 3D0C 3D0D 3D0E 3D0F 3D10 3D11 3D11

D9 10EB E1 BF C3733E

M0PRNT2:

EXX DJNZ M0PRLP POP HL CP A JP POATTR0

;******************************************************************************* ;MODE 1 PRINT. ENTRY: DE=SCREEN ROW/COL, HL=CHAR DATA, B=OVER AND C=INVERSE MASK CDD03D D9 D9 1A A0 AE A9 12 23 7B C620 5F 3001 14 D9 10EF D9 21001F 19 CD773E 0607 112000 19 77 10FC C9 M1PRATTR: M1PRNC: M1PRINT: M1PRLP: CALL M1DEADDR EXX EXX LD A,(DE) AND B XOR (HL) XOR C LD (DE),A INC HL LD A,E ADD A,32 LD E,A JR NC,M1PRNC INC D EXX DJNZ M1PRLP EXX LD HL,1F00H ADD HL,DE CALL SETATTR LD B,7 LD DE,32 ADD HL,DE LD (HL),A DJNZ M1PRATTR RET ;******************************************************************************* ;MODE 2 PRINT. ENTRY: DE=SCREEN ROW/COL, HL=CHAR DATA, B=OVER AND C=INVERSE MASK CDF53D 265B 79 D9 4F 3813 212151 C5 1A 0F 77 23 13 10F9 C1 112151 D9 48 1807 P64AL: M2PRINT: CALL M2DEADDR LD H,CEXTAB/256 LD A,C EXX LD C,A JR C,PR80COL LD HL,MEMVAL PUSH BC LD A,(DE) RRCA LD (HL),A INC HL INC DE DJNZ P64AL POP BC LD DE,MEMVAL EXX LD C,B JR PR80EVEN ;** ;NEW CHAR LOCN. ;MAKE RHS OVER MASK=LHS OVER MASK ;CY SET IF 6-PIX CHARS, Z/NZ=EVEN/ODD ;H IS EXPANSION TABLE MSB ;C"=INVERSE MASK ;IF 64-COL, MUST ROTATE CHAR DATA FOR CORRECT ;ALIGNMENT WHEN USING 85-COL O/P ROUTINE ;** ;LOOP FOR 8 SCANS ;DISP TO ATTR AREA (TOP ROW) ;USE ATTRT TO CHANGE ATTR AT (HL). HL PRESERVED, A= ;NEW ATTR ;7 MORE TO CHANGE ;DROP TO ATTR FOR NEXT CHAR ROW ;GET ADDR OF ROW/COL DE IN DE ;FETCH SCREEN DATA ;AND 0 IF OVER 0, AND FF IF OVER 1 OR 2 ;XOR CHAR DATA ;INVERSE MASK USED ;PLACE ON SCREEN ;NEXT CHAR DATUM ;DROP DE BY 1 SCAN.

;85-COLUMN PRINT ;ENTRY: NZ IF ODD COLUMN, Z IF EVEN COLUMN. D9 78 202A F60F 4F D9 1A A9 13 D9 F5 0F 0F 0F E60F 6F 1A AE A0 AE 12 1C PR80EVEN: M2PREVLP: PR80COL: EXX LD A,B JR NZ,PR80ODD OR 0FH LD C,A EXX LD A,(DE) XOR C INC DE EXX PUSH AF RRCA RRCA RRCA AND 0FH LD L,A LD A,(DE) XOR (HL) AND B XOR (HL) LD (DE),A INC E ;OVER MASK ;RHS OVER MASK FOR EVEN COLS=0F OR FF ;LHS OVER MASK FOR EVEN COLS=00 OR FF ;GET CHAR DATA FROM (DE") ;INVERSE MASK

;01234560->00123456 ; ->60012345 ; ->56001234 ;GET VALUE OF HIGHER CHAR NIBBLE ;HL PTS TO ENTRY IN 16-BYTE TABLE CONTAINING ;COLOURED EXPANDED DATA ;SCREEN DATA ;LHS OVER MASK ;EXPANDED CHAR DATA ;NEXT SCREEN COLUMN

3D12 3D13 3D14 3D16 3D17 3D17 3D18 3D19 3D1A 3D1B 3D1C 3D1D 3D1F 3D20 3D22 3D22 3D23 3D23 3D24 3D26 3D26 3D27 3D27 3D29 3D2A 3D2B 3D2B 3D2C 3D2D 3D2E 3D2F 3D2F 3D30 3D31 3D32 3D33 3D35 3D36 3D36 3D37 3D38 3D39 3D3A 3D3B 3D3B 3D3C 3D3D 3D3E 3D40 3D41 3D41 3D42 3D43 3D44 3D45 3D46 3D47 3D49 3D4A 3D4C 3D4C 3D4D 3D4D 3D4E 3D50 3D50 3D51 3D51 3D51 3D51 3D51 3D51 3D51 3D54 3D56 3D57 3D57 3D58 3D59 3D59 3D5A 3D5B 3D5C 3D5D 3D5D 3D5E 3D5F 3D60 3D61 3D63 3D64 3D64 3D65 3D66 3D67 3D68 3D69 3D6A 3D6A 3D6B 3D6C 3D6D 3D6E

F1 07 E60F 6F 1A AE A1 AE 12 7B C67F 5F 3001 14 D9 10DB C9 F6F0 4F D9 1A A9 13 D9 F5 07 07 07 E60F 6F 1A AE A1 AE 12 1C F1 0F E60F 6F 1A AE A0 AE 12 7B C67F 5F 3001 14 D9 10DB C9 M2PRNCO: PR80ODD: M2PRODLP: M2PRNCE:

POP AF RLCA AND 0FH LD L,A LD A,(DE) XOR (HL) AND C XOR (HL) LD (DE),A LD A,E ADD A,127 LD E,A JR NC,M2PRNCE INC D EXX DJNZ M2PREVLP RET OR 0F0H LD C,A EXX LD A,(DE) XOR C INC DE EXX PUSH AF RLCA RLCA RLCA AND 0FH LD L,A LD A,(DE) XOR (HL) AND C XOR (HL) LD (DE),A INC E POP AF RRCA AND 0FH LD L,A LD A,(DE) XOR (HL) AND B XOR (HL) LD (DE),A LD A,E ADD A,127 LD E,A JR NC,M2PRNCO INC D EXX DJNZ M2PRODLP RET

;01234560 ;12345600 ;GET VALUE OF LOWER CHAR NIBBLE. ;HL PTS TO ENTRY IN 16-BYTE TABLE CONTAINING ;COLOURED EXPANDED DATA ;RHS OVER MASK

;DROP DE TO NEXT SCAN, BACK UP 1 BYTE

;LHS OVER MASK FOR ODD COLS=F0 OR FF ;RHS OVER MASK FOR ODD COLS=00 OR FF ;GET CHAR DATA; 01234560 ;INVERSE MASK

;12345600 ;23456001 ;34560012 ;GET VALUE OF HIGHER CHAR NIBBLE. ;HL PTS TO ENTRY IN 16-BYTE TABLE CONTAINING ;COLOURED EXPANDED DATA ;SCREEN DATA ;LHS OVER MASK ;EXPANDED CHAR DATA ;NEXT SCREEN COLUMN ;GET ORIG CHAR DATUM AGAIN ;00123456 ;GET VALUE OF LOWER CHAR NIBBLE. ;HL PTS TO ENTRY IN 16-BYTE TABLE CONTAINING ;COLOURED EXPANDED DATA ;RHS OVER MASK

;DROP DE TO NEXT SCAN, BACK UP 1 BYTE

;******************************************************************************* ;MODE 3 PRINT. ENTRY: DE=SCREEN ROW/COL, HL=CHAR DATA, B=OVER AND C=INVERSE MASK ;USES HL,DE,BC, DE",BC" ;TAKES ABOUT 294*8 Ts vs. POSSIBLE 218*8 FOR OVER 0 ONLY ROUTINE USING LDI CDC33D 265B 79 D9 4F 1A A9 13 D9 4F 1F 1F 1F E61E 6F 1A A0 AE 12 2C 1C 1A A0 AE 12 1C M3PRLP: M3PRINT: CALL M3DEADDR LD H,CEXTAB/256 LD A,C EXX LD C,A LD A,(DE) XOR C INC DE EXX LD C,A RRA RRA RRA AND 1EH LD L,A LD A,(DE) AND B XOR (HL) LD (DE),A INC L INC E LD A,(DE) AND B XOR (HL) LD (DE),A INC E ;H IS EXPANSION TABLE MSB ;C"=INVERSE MASK ;GET CHAR DATA ;INVERSE MASK

;GET VALUE OF HIGHER CHAR NIBBLE,*2 ;HL PTS TO ENTRY IN 16-WORD TABLE CONTAINING ;COLOURED EXPANDED DATA ;SCREEN DATA ;OVER MASK ;EXPANDED CHAR DATA ;NEXT EXPANDED DATUM ;NEXT SCREEN COLUMN ;OVER MASK ;NEXT SCREEN COLUMN

3D6F 3D6F 3D70 3D70 3D71 3D73 3D74 3D74 3D75 3D76 3D77 3D78 3D79 3D7A 3D7A 3D7B 3D7C 3D7D 3D7E 3D7F 3D81 3D82 3D84 3D84 3D85 3D85 3D86 3D88 3D88 3D89 3D89 3D89 3D89 3D89 3D8C 3D8D 3D8F 3D8F 3D93 3D94 3D96 3D96 3D9A 3D9D 3D9E 3D9F 3D9F 3DA3 3DA3 3DA6 3DA7 3DA7 3DAA 3DAB 3DAD 3DAD 3DAE 3DB0 3DB0 3DB0 3DB0 3DB4 3DB4 3DB4 3DB4 3DB5 3DB7 3DB7 3DB7 3DB7 3DB7 3DB7 3DBA 3DBB 3DBD 3DBD 3DBE 3DC0 3DC0 3DC1 3DC3 3DC3 3DC3 3DC3 3DC6 3DC7 3DC8 3DC9 3DCA 3DCB 3DCD 3DCE 3DCF 3DD0 3DD0 3DD0 3DD0 3DD3 3DD4 3DD5 3DD6 3DD7 3DD8

79 17 E61E 6F 1A A0 AE 12 2C 1C 1A A0 AE 12 7B C67D 5F 3001 14 D9 10D1 C9 ;POFETCH 3A735A A7 2810 ED5B6E5A 3D 280D ED5B705A 3A0E5A 37 C9 ED5B6C5A 3A565A C9 CD7204 F7 F35E F7 EE5C ED5BD65B F7 1B5D POF2: POF3: CCRESTOP: POSTFF: POFETCH: M3PRNC:

LD A,C RLA AND 1EH LD L,A LD A,(DE) AND B XOR (HL) LD (DE),A INC L INC E LD A,(DE) AND B XOR (HL) LD (DE),A LD A,E ADD A,125 LD E,A JR NC,M3PRNC INC D EXX DJNZ M3PRLP RET

;GET ORIG CHAR DATUM AGAIN ;GET VALUE OF LOWER CHAR NIBBLE,*2 ;HL PTS TO ENTRY IN 16-WORD TABLE CONTAINING ;COLOURED EXPANDED DATA ;OVER MASK ;NEXT EXPANDED DATUM ;NEXT SCREEN COLUMN ;OVER MASK

;DROP DE TO NEXT SCAN, BACK UP 3 BYTES

GET D=ROW, E=COL, A=RHS LIMIT, CY IF PRINTER OR OTHER LD A,(DEVICE) AND A JR Z,POF2 LD DE,(SPOSNL) DEC A JR Z,POF3 LD DE,(PRPOSN) LD A,(PRRHS) SCF RET LD DE,(SPOSNU) LD A,(WINDRHS) RET CALL RESTOP RST 30H DW CCRP2-8000H RST 30H DW PSTFF2-8000H LD DE,(UMSGS) RST 30H DW POMSPX-8000H ;JP TO ROM1 TO DEAL WITH TAB, AT, PAPER, ETC. ;JP TO ROM1 TO DEAL WITH FN NAME ;0=UPPER SCREEN, 1=LOWER, 2=PRINTER OR OTHER ;NC, TEST FOR ZERO ;JR IF UPPER SCREEN ;JR IF LOWER SCREEN ;RHS LIMIT (LINE LEN-1) ;"PRINTER"

;UTILITY MESSAGES. ENTRY WITH A=NUMBER UTMSG: POMSG: ;PRINT MSG "A" FROM LIST AT DE

;******************************************************************************* ;ANYDEADDR - GET IN DE ADDR OF ROW D, COL E FOR ANY MODE ;EXIT WITH CY IF MODE 2 6-PIX CHARS, Z/NZ =EVEN/ODD 3A405A A7 2827 3D 2810 3D 2832 CD123E 7B 87 87 87 37 CB1A 1F 5F C9 CD123E 7A 0F 0F 0F 57 AB M3DEADDR: ANYDEADDR: LD A,(MODE) AND A JR Z,M0DEADDR DEC A JR Z,M1DEADDR DEC A JR Z,M2DEADDR ;GET IN DE ADDR OF ROW D, COL E FOR MODE 3 (8000H+ROW*CSIZEH*80H+COL*4) CALL CLCPO LD A,E ADD A,A ADD A,A ADD A,A SCF RR D RRA LD E,A RET CALL CLCPO LD A,D RRCA RRCA RRCA LD D,A XOR E

;0-248

;GET IN DE ADDR OF ROW D, COL E FOR MODE 1 (8000H+ROW*CSIZEH*20H+COL) M1DEADDR: ;SAY A=256*PIX ;128* ;64* ;32*

3DD9 3DDB 3DDC 3DDD 3DDE 3DE0 3DE2 3DE3 3DE4 3DE4 3DE4 3DE4 3DE7 3DE8 3DE9 3DEA 3DEB 3DEC 3DED 3DEE 3DEF 3DF2 3DF3 3DF4 3DF5 3DF5 3DF5 3DF5 3DF5 3DF5 3DF8 3DFB 3DFC 3DFD 3DFF 3DFF 3E00 3E01 3E02 3E04 3E05 3E06 3E07 3E07 3E08 3E09 3E0A 3E0C 3E0D 3E0F 3E10 3E11 3E12 3E12 3E12 3E12 3E15 3E16 3E19 3E1A 3E1B 3E1B 3E1E 3E1F 3E20 3E21 3E21 3E21 3E21 3E21 3E21 3E21 3E24 3E25 3E27 3E27 3E28 3E2A 3E2C 3E2D 3E2D 3E2E 3E2E 3E2F 3E32 3E33 3E35 3E35 3E36 3E38 3E38 3E39 3E3B 3E3B 3E3B 3E3B 3E3B 3E3C 3E3D 3E3E 3E3F 3E40 3E41

E6E0 AB 5F 7A E61F F680 57 C9 CD123E C5 42 7B 87 87 87 4F EB CD3B3E EB C1 C9 M0DEADDR:

AND 0E0H XOR E LD E,A LD A,D AND 1FH OR 80H LD D,A RET CALL CLCPO PUSH BC LD B,D LD A,E ADD A,A ADD A,A ADD A,A LD C,A EX DE,HL CALL M0PIXAD EX DE,HL POP BC RET

;COMBINE LOWER 3 BITS OF SCAN LINE AND COL ;UPPER 5 BITS OF SCAN LINE

;GET IN DE ADDR OF ROW D, COL E FOR MODE 0

;BC=PIX COORDS

;GET IN DE ADDR OF ROW D, COL E FOR MODE 2 (8000H+ROW*CSIZEH*80H+COL*2) ; OR (8000H+ROW*CSIZEH*80H+COL*3/2) ;EXIT WITH NC IF 8-PIX CHARS, OR CY AND Z/NZ=EVEN/ODD COL CD123E 3A355A A7 7B 2808 87 87 37 CB1A 1F 5F C9 87 83 37 CB1A 1F CB43 5F 37 C9 CDD00C 57 3A735A A7 C8 3A5D5A 82 57 C9 M2DEADDR: CALL CLCPO LD A,(FL6OR8) AND A LD A,E JR Z,M2DEADDR2 ADD A,A ADD A,A SCF RR D RRA LD E,A RET M2DEADDR2: ADD A,A ADD A,E SCF RR D RRA BIT 0,E LD E,A SCF RET CLCPO: CALL CALCPIXD LD D,A LD A,(DEVICE) AND A RET Z LD A,(LSOFF) ADD A,D LD D,A RET ;******************************************************************************* ;ANY MODE PIXEL ADDRESS FOR PT. B,C (OR POINT B,HL IF THIN PIX) ;EXIT: HL=ADDR (8000+) A=X MOD 8 ;IF MODE 3, CY IF ODD PIXEL 3A4D5A A7 2006 4D CB1C CB1D FE 69 60 3A405A A7 2806 3D 2820 79 1828 ANYPIXAD: LD A,(THFATT) AND A JR NZ,NTTHINPIX LD RR RR DB C,L H L 0FEH ;SAVE ORIG X LSB ;HALVE X IF THIN PIX ;"JR+1"

;JR IF 6-PIX CHARS ;0-126 ;0-252 ;NC=8-PIX CHARS

;A=ORIG COL*3 (0-252) ;(0-126 - OFFSET FROM LHS) ;Z IF ORIG COL=EVEN ;SIGNAL 6-PIX, Z/NZ=EVEN/ODD

;CALC PIX IN D ROWS, ADD OFFSET IF LOWER SCREEN

;RET IF UPPER SCREEN

NTTHINPIX: LD L,C LD H,B LD A,(MODE) AND A JR Z,M0PIXAD DEC A JR Z,M1PIXAD LD A,C JR M1PIXAD2 ;GET PIXEL ADDR OF POINT C,B IN HL. MODE 0. (Y AXIS HAS ZERO AT TOP) ;ALTERS HL AND A. ADDR=8000-97FF. A=PIX OFFSET

68 78 B7 1F 1F 37 1F

M0PIXAD:

LD L,B LD A,B OR A RRA RRA SCF RRA

3E42 3E44 3E45 3E47 3E48 3E49 3E4A 3E4B 3E4C 3E4D 3E4E 3E50 3E51 3E52 3E53 3E54 3E55 3E57 3E58 3E58 3E58 3E58 3E58 3E59 3E5A 3E5C 3E5E 3E5F 3E61 3E63 3E63 3E63 3E65 3E66 3E67 3E69 3E6B 3E6C 3E6C 3E6C 3E6C 3E6C 3E6C 3E6C 3E6C 3E6C 3E6F 3E70 3E71 3E73 3E73 3E73 3E73 3E76 3E76 3E77 3E77 3E77 3E77 3E7B 3E7C 3E7D 3E7E 3E7F 3E83 3E85 3E87 3E87 3E89 3E8B 3E8D 3E8D 3E8F 3E8F 3E91 3E93 3E93 3E95 3E97 3E99 3E99 3E9B 3E9B 3E9C 3E9D 3E9D 3E9D 3E9D 3E9D 3E9D 3EA0 3EA1 3EA4 3EA5 3EA6 3EA7 3EAA 3EAB 3EAC 3EAE 3EAF 3EB1 3EB1

E69F AD E6F8 AD 67 79 07 07 07 AD E6C7 AD 07 07 6F 79 E607 C9

AND 9FH XOR L AND 0F8H XOR L LD H,A LD A,C RLCA RLCA RLCA XOR L AND 0C7H XOR L RLCA RLCA LD L,A LD A,C AND 07H RET ;GET MODE 1 PIXEL ADDR. ENTRY: L=X, H=Y ;EXIT: HL=ADDR, B=PIXEL OFFSET (0-7), A=B

7D A7 CB1C CB1D A7 CB1C CB1D E607 47 37 CB1C CB1D C9

M1PIXAD:

LD A,L AND A RR H RR L AND A RR H RR L AND 07H LD B,A SCF RR H RR L RET

;NC ROTATED IN

M1PIXAD2:

;HL=Y/8+X/8+8000H=ADDRESS

;POATTR.SAM ;******************************************************************************* ;POATTR01. SET ATTR OF PATTERN DATA AT (HL) FOR MODE 0 OR 1 ;ENTRY: HL=SCREEN ADDR. USES HL, BC AND AF 3A405A A7 7C CBEF CC490C 67 ED4B4E5A 7E A9 A0 A9 ED4B505A CB61 2808 F607 CB6F 2802 EE07 CB71 2808 F638 CB57 2802 EE38 77 C9 POATTR2: POATTR1: SETATTR: POATTR01: LD A,(MODE) AND A LD A,H SET 5,A CALL Z,CTAA LD H,A ;ENTRY POINT IF HL ALREADY PTS TO ATTR LD BC,(ATTRT) LD A,(HL) XOR C AND B XOR C LD BC,(PFLAGT) BIT 4,C JR Z,POATTR1 OR 07H BIT 5,A JR Z,POATTR1 XOR 7 BIT 6,C JR Z,POATTR2 OR 38H BIT 2,A JR Z,POATTR2 XOR 38H LD (HL),A RET ;JR IF NOT PAPER 9

;ADD 2000H FOR USE IF MODE 1

;THIS ENTRY CAN BE USED DIRECTLY BY MODE 0 POATTR0:

;JR IF NOT INK 9

;COMPARE TWO STRINGS FROM STACK (OVER <16K). PAGING UNALTERED ON RETURN. ;EXIT: Z IF STRINGS MATCH, CY IF S1<S2, NZ,NC IF S1>S2. HL=S1 PTR ;USES HL,BC,AF, HL" DE", BC" AF" CD493C E5 CD073F D5 F5 C5 CD073F E1 A7 ED42 09 3002 44 STRCOMP: CALL R1OSR PUSH HL CALL UNSTKPRT PUSH DE PUSH AF PUSH BC CALL UNSTKPRT POP HL AND A SBC HL,BC ADD HL,BC JR NC,STRCOMP2 LD B,H ;S1 PTR ;BC=S2 LEN, DE=S2 ST, A=PORT VALUE ;S2 ST ;S2 PORT VALUE ;S2 LEN ;BC=S1 LEN, DE=S1 ST, A=PORT ;S2 LEN ;S2 LEN-S1 LEN ;JR IF BC<=HL

3EB2 3EB3 3EB3 3EB4 3EB5 3EB6 3EB8 3EBB 3EBB 3EBC 3EBD 3EBE 3EC0 3EC0 3EC1 3EC2 3EC3 3EC5 3EC5 3EC6 3EC8 3EC9 3ECA 3ECC 3ECC 3ECD 3ECE 3ED0 3ED0 3ED1 3ED2 3ED2 3ED3 3ED4 3ED6 3ED6 3ED7 3ED9 3ED9 3EDA 3EDA 3EDA 3EDB 3EDB 3EDC 3EDD 3EDF 3EE0 3EE2 3EE3 3EE4 3EE4 3EE4 3EE4 3EE4 3EE4 3EE7 3EE8 3EE8 3EE9 3EEA 3EEA 3EEA 3EEA 3EEC 3EEC 3EED 3EF0 3EF3 3EF4 3EF5 3EF7 3EF7 3EF8 3EF9 3EFB 3EFB 3EFC 3EFF 3F00 3F01 3F03 3F04 3F05 3F07 3F07 3F07 3F07 3F0A 3F0B 3F0D 3F0E 3F10 3F11 3F12 3F12 3F12 3F12 3F13 3F14 3F14 3F14 3F14

4D 6F 08 78 FE40 D2283A F1 67 C5 0EFB D9 C1 E1 180D D9 ED69 1A 13 ED61 D9 BE 200A 23 0B 78 B1 20EF 08 2801 3F E1 08 F1 D3FA F1 D3FB 08 C9 SCOMPEX: SCOMPC: SCOMPBG: SCOMPLP: STRCOMP2:

LD C,L LD EX LD CP JP L,A AF,AF' A,B 40H NC,STLERR

;MAKE BC=SHORTEST LEN ;L=S1 PORT ;SAVE Z IF LENS EQUAL, CY IF S1 LEN GRTR. ;ONLY DEAL WITH STRINGS<16K ;H=S2 PORT

POP AF LD H,A PUSH BC LD C,251 EXX POP BC POP HL JR SCOMPBG EXX OUT (C),L LD A,(DE) INC DE OUT (C),H EXX CP (HL) JR NZ,SCOMPEX INC HL DEC BC LD A,B OR C JR NZ,SCOMPLP EX AF,AF' JR Z,SCOMPEX CCF POP HL EX AF,AF' POP AF OUT (250),A POP AF OUT (251),A EX AF,AF' RET

;BC"=SHORTEST LEN ;HL"=S2 ST ;S1 PAGE SEL ;S1 CHAR ;S2 PAGE SEL ;S2 CHAR ;JR WITH CY IF S2 GRTR; NZ,NC IF S1 GRTR

;LOOP UNTIL STRINGS MATCH OVER BC CHARS ;Z IF LENS EQUAL - STRINGS MATCH ;** COMPARISON BUG FIX ;CY IF S2 STRING LONGER - IE GREATER ;NZ,NC IF S1 STRING LONGER - IE GREATER ;S1 PTR

;STRING BUFFER FETCH. COPY STRING ON FPCS TO "INSTBUF" IN COMMON MEM. ERROR IF ;LEN >255 OR 0. ON EXIT, BC AND A=LEN, DE=START, PAGING UNALTERED. CDEA3E C0 CF 1B 3EFF 08 CD493C CDDC3F 08 80 38F1 78 B1 28E0 EB 11004F C5 D5 EDB0 D1 C1 18D4 CD011D 67 DBFB AC E6E0 AC C9 CF 14 F5 UNSTKPRT: SBUFFET: INVARG: CALL SBFSR RET NZ RST 08H DB 27 LD A,0FFH EX AF,AF' CALL R1OSR CALL GETSTRING EX AF,AF' ADD A,B JR C,INVARG LD A,B OR C JR Z,SCOMPC EX DE,HL LD DE,INSTBUF PUSH BC PUSH DE LDIR POP DE POP BC JR SCOMPC CALL STKFETCH LD H,A IN A,(251) XOR H AND 0E0H XOR H RET RST 08H DB 20 PUSH AF ;AND SELECT PAGE ;ADD FF OR FE, LEN MSB ;ERROR IF T$ LEN >FF OR >01FF ;RET IF LEN=0 ;A=LEN. ;256 BYTES IN PAGE 0 ;COPY T$ TO PAGE 0 ;BC=LEN, A=C. NC ;NZ HERE FROM 'OR C' - SCOMPC PRESERVES IT TOO ;A=PAGE, DE=START, BC=LEN ;USE UPPER 3 BITS FROM PORT ;A=PORT VALUE

;AS SBUFFET, BUT LEN ZERO GIVES Z FLAG, NOT AN ERROR MSG SBFSR: SBFSR2:

;UNSTACK STRING AND GET PORT VALUE NEEDED TO SWITCH IT IN

;ADDRESS OF IDERR GOES INTO SOME CHANNELS IDERR: ;"Invalid device"

;CHECK IF OK TO USE ABC BYTES (PAGE FORM). EXITS WITH ABC, DE CHANGED. TSTRMBIG:

3F15 3F16 3F19 3F1A 3F1B 3F1C 3F1C 3F1C 3F1C 3F1C 3F1D 3F1E 3F1E 3F21 3F22 3F23 3F24 3F24 3F24 3F24 3F24 3F25 3F25 3F26 3F27 3F2A 3F2B 3F2C 3F2F 3F30 3F31 3F32 3F33 3F36 3F39 3F3C 3F3E 3F3E 3F41 3F42 3F43 3F45 3F45 3F47 3F47 3F48 3F49 3F4A 3F4B 3F4B 3F4C 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D 3F4D

C5 CD1C3F C1 F1 C9

PUSH BC CALL TSTRMABC POP BC POP AF RET ;CHECK IF OK TO USE ABC BYTES (PAGE FORM). EXITS WITH DE CHANGED. NC. AHL= ;PAGE FORM OF NEW WKEND

60 69 CD2120 44 4D FE

TSTRMABC: TSTRMAHL:

LD H,B LD L,C CALL AHLNORM LD B,H LD C,L DB 0FEH ;ABC=19-BIT SPACE ;"JR+1"

;CHECK IF OK TO USE BC BYTES (0-FFFF). ERROR IF NOT. EXITS WITH BC UNCHANGED, NC ;AHL=PAGE FORM OF NEW WKEND, DE=FREE, OR A HIGH VALUE IF FREE>=64K AF C5 57 CD1620 09 8A CDF21F F5 E5 EB 4F 3AB15C 2AB25C CDE71F 380D CD2120 EB A7 2802 CBFA E1 F1 C1 C9 CF 01 TRM2: TESTROOM: XOR A PUSH BC LD D,A CALL WENORMAL ADD HL,BC ADC A,D CALL PAGEFORM PUSH AF PUSH HL EX DE,HL LD C,A LD A,(RAMTOPP) LD HL,(RAMTOP) CALL SUBAHLCDE JR C,OOMERR CALL AHLNORM EX DE,HL AND A JR Z,TRM2 SET 7,D POP HL POP AF POP BC RET RST 08H DB 1 ;DBC=SPACE ;GET AHL=WKEND (19 BIT) ;AHL=NEW VALUE AFTER BC USED ;AHL=PAGE FORM OF NEW WKEND

;AHL=RAMTOP ;AHL=ROOM ;ERROR IF NEW WKEND PAGE WOULD BE ABOVE RAMTOP ;AHL=19 BIT ROOM

;IF >64K FREE, MAKE DE A HI VALUE ;AHL=NEW WKEND ;SPACE ;"OUT OF MEMORY"

OOMERR:

;COPY STRING FROM (DE), LEN BC, PORT VALUE A, TO WKSPACE. SOURCE CAN BE ANYWHERE ;AND NEED NOT BE SWITCHED IN ON ENTRY. LEN TRUNCATED TO <=255 WITHOUT ANY MSG. ;LEN 0 WILL CRASH! ROM1 MUST BE SWITCHED OFF ON ENTRY! ;EXIT: HL=PAST ROOM END, DE=ROOM START, DE"=PAST STRING END, B"=0, C"=URPORT, ;H"=SRC PORT VALUE, L"=WKSPACE PORT. WORKSPACE IS SWITCHED IN. ;NOTE: REASONABLY FAST FOR SHORT STRINGS ;USED BY READ AND VAL ONLY ;SCOPYWK: ; ; ; ; ;SCOPYWK2: ; ; ; ; ; ; ; ; ; ; ; ; ;STRMVLP: ; ; ; ; ; ; ; ; ; ; PUSH DE INC B DEC B JR Z,SCOPYWK2 LD BC,0FFH CALL WKROOM LD B,C LD H,A IN A,(251) LD L,A PUSH DE EXX POP HL LD D,H LD E,L EXX POP DE LD C,251 OUT (C),H LD A,(DE) INC DE OUT (C),L EXX LD (HL),A INC HL EXX DJNZ STRMVLP EXX ;SRC PAGE ;SRC BYTE ;DEST PAGE ;TO WKSPACE AT HL" ;ABOUT 80 Ts/BYTE ;RET WITH REGS SWAPPED ;SRC ;JR IF LEN<=256 ;ELSE TRUNCATE - STRMOVE ONLY ALLOWS SHORT STRINGS ;DE=ROOM, HL=END BYTE, BC AND A UNCHANGED ;LEN COUNTER ;H=STRING PORT VALUE ;L=WKSPACE PORT VALUE ;WKSPACE ;DEST TO HL" ;KEEP A COPY OF THE START IN DE ;SRC

;;MOVE B BYTES FROM (DE) PORT VALUE H TO (HL") PORT VALUE L. EXIT WITH ALT REGS.

;COPY BC BYTES FROM DE TO WKSPACE

3F4D 3F4E 3F4F 3F51 3F51 3F54 3F54 3F57 3F58 3F5B 3F5C 3F5D 3F5F 3F60 3F61 3F64 3F65 3F66 3F67 3F69 3F6A 3F6B 3F6C 3F6E 3F6F 3F71 3F72 3F73 3F73 3F73 3F73 3F76 3F77 3F78 3F79 3F7C 3F7E 3F81 3F82 3F83 3F85 3F88 3F89 3F8A 3F8B 3F8C 3F8C 3F8C 3F8C 3F8C 3F8C 3F8C 3F8C 3F8C 3F8C 3F8D 3F8E 3F8F 3F90 3F91 3F91 3F94 3F96 3F99 3F99 3F9A 3F9D 3F9E 3F9F 3F9F 3F9F 3F9F 3FA2 3FA3 3FA5 3FA6 3FA6 3FA8 3FA8 3FA8 3FA8 3FAA 3FAD 3FAF 3FB1 3FB1 3FB1 3FB1 3FB3 3FB6 3FB6 3FB9 3FBB 3FBB 3FBB 3FBB 3FBE 3FBF 3FBF 3FC0 3FC3 3FC5 3FC6

04 05 2803 01FF00 CD493C EB 11004F D5 C5 EDB0 C1 C5 CD801E C1 E1 D5 EDB0 EB D1 2B 360D F1 D3FA F1 C9 CDAA13 F5 C5 D5 222151 DBFB 112351 12 13 0E07 CD4C2D D1 C1 F1 C9

SCOPYWK:

INC B DEC B JR Z,SCOPYWK2 LD BC,0FFH CALL R1OSR EX DE,HL LD DE,INSTBUF PUSH DE PUSH BC LDIR POP BC PUSH BC CALL WKROOM POP BC POP HL PUSH DE LDIR EX DE,HL POP DE DEC HL LD (HL),0DH POP AF OUT (250),A POP AF RET CALL LOOKVARS PUSH AF PUSH BC PUSH DE LD (MEMVAL),HL IN A,(URPORT) LD DE,MEMVAL+2 LD (DE),A INC DE LD C,7 CALL SCOPN2 POP DE POP BC POP AF RET DS 3F8CH-$,0

;JR IF LEN<=256 ;ELSE TRUNCATE ;SRC TO HL

SCOPYWK2:

;HL=PAST END ;START

;CALLED BY LENGTH FN AND TAPEMN LENGSR: ;HL POINTS TO NUMERIC VALUE, OR STRING LEN DATA ;FOUND/NOT FOUND FLAG

;LDIR 7 BYTES, SELCHADP ;TYPE ;FLAGS

;FIXED ROUTINES ;***************************************************************************** ;UNSTACK A 5-BYTE NUMBER TO AN ADDRESS IN A (PAGE) AND HL (8000-BFFF) ;(RES 7,H IF 5-BYTE IS A LENGTH, TO GIVE PAGE, +0000-3FFFH). GIVES IOOR ERROR ; IF NUMBER IS NEGATIVE OR >07FFFF EF E2 08 DB 33 CD331D FE21 D2391D F5 CD2E1D F1 C9 CD6F12 7C FEC0 D8 184A DBFA 327A5A E6BF D3FA DBFB 32795A 3A785A 1824 CDA83F 7E 08 3A7A5A D3FA 3E SPSSR: NPDPS: UNSTLEN: DB DB DB DB DB CALC STK16K MOD RCL3 EXIT ;N ;N,16K ;N MOD 16K ;N MOD 16K,INT(N/16K) (PLACED BY MOD)

CALL GETBYTE CP 21H JP NC,IOORERR PUSH AF CALL GETINT POP AF RET ;NEW POKE/DPOKE SR CALL PDPSUBR LD A,H CP 0C0H RET C JR INCURPAGE ;SELECT SCREEN, ROM1 OFF IN A,(250) LD (CLRP),A AND 0BFH OUT (250),A IN A,(251) LD (CURP),A LD A,(CUSCRNP) JR SELURPG CALL SPSSR LD A,(HL) EX AF,AF' LD A,(CLRP) OUT (250),A DB 3EH

;PAGE MUST BE 00-20H (0=ROM, 1-20=RAM) ;TO HL AND BC ;A=PAGE

;ROM1 OFF

;STORE PAGE SCREEN SELECT SPSS: SELSCRN:

;SCREEN PAGE

;READ BYTE FROM SCREEN AT HL, FORCING SCREEN ON, ROM1 OFF SREAD: RCURPR: ;SELECT SCREEN, ROM1 OFF

;'JR+1'

3FC6 3FC6 3FC7 3FC7 3FCA 3FCC 3FCD 3FCE 3FCE 3FCE 3FCE 3FD1 3FD1 3FD1 3FD1 3FD3 3FD5 3FD7 3FD7 3FD7 3FD7 3FDA 3FDC 3FDC 3FDC 3FDC 3FDC 3FDF 3FDF 3FDF 3FDF 3FDF 3FE0 3FE1 3FE3 3FE4 3FE6 3FE7 3FE9 3FEA 3FEB 3FEB 3FEB 3FEB 3FEB 3FED 3FEF 3FEF 3FEF 3FEF 3FF1 3FF2 3FF2 3FF2 3FF2 3FF2 3FF4 3FF4 3FF6 3FF7 3FF9 3FF9 3FFB 3FFD 3FFE 4000 4000 4000 C000 C000 C000 C000 C000 4F00 4F00 4F00 4F00 4F03 4F06 4F09 4F0C 4F0D 4F10 4F12 4F15 4F18 4F1A 4F1D 4F20 4F20 4F22 4F25 4F28 4F28 4F2B 4F2F 4F32 4F32 4F33 4F36 4F37 4F3A 4F3A

08 3A795A D3FB 08 C9 32965A DBFA E6BF D3FA 3A965A 1803

TRCURP: RCURP: RCUR2:

EX AF,AF' LD A,(CURP) OUT (251),A EX AF,AF' RET LD (CHADP),A IN A,(250) AND 0BFH OUT (250),A LD A,(CHADP) JR TSURPG

;SET CHADP VAR AND SWITCH IT IN SETCHADP: R1OCHP: ;ROM1 OFF, SELCHADP ;ROM1 OFF ;CHAD PAGE

;SWITCH IN CHADP SELCHADP:

;UNSTACK A STRING AND SELECT IT"S PAGE. DE=START (8000-BFFF), BC=LEN CD011D TGTSTR: GETSTRING: SELURPG: TSURPG: CALL STKFETCH ;A=PAGE, DE=START, BC=LEN

;SELECT UPPER RAM PAGE E5 67 DBFB AC E6E0 AC D3FB E1 C9 PUSH HL LD H,A IN A,(251) XOR H AND 0E0H XOR H OUT (251),A POP HL RET

;KEEP TOP 3 BITS FROM PORT

;INCREMENT UPPER RAM PAGE, ENSURE DE IS NOT IN C000-FFFF AREA ;USES A, ALTERS D CBB2 1805 CB74 C8 INCURPDE: RES 6,D JR INCURCOM BIT 6,H RET Z

;INC PAGE AND ADJUST HL POINTER IF NEEDED CHKHL:

;INCREMENT UPPER RAM PAGE, ENSURE HL IS NO IN C000-FFFF AREA ;USES A, ALTERS H CBB4 DBFB 3C 18E6 CBF4 DBFB 3D 18DF INCURPAGE: INCURCOM: DECURPAGE: RES 6,H IN A,(251) INC A JR SELURPG SET 6,H IN A,(251) DEC A JR SELURPG

INCLUDE TMISCX1.SAM ;BUFFER CODE: RENUM, GET, DELETE, KEYIN, POP, ORG 0C000H ;MISCX1.SAM - START OF UPPER ROM. FIRST PART IS SECTIONS THAT ARE COPIED ;TO A RAM BUFFER FOR EXECUTION SO THE UPPER ROM CAN BE PAGED OUT AND ;THE BASIC PROGRAM GOT AT. ORG INSTBUF ;MOVED TO INSTBUF FOR EXECUTION 210A00 22425A 22895B CD4B3B DF 21425A FE8C CCB550 21895B FE8F CCB550 CD153B 0618 CD243F CDB13F 2A425A ED4B895B 1102C0 D9 210080 E5 110000 E1 MKTBLP: RNMP2: LD HL,10 LD (RLINE),HL LD (RSTEP),HL CALL BRKLSSL RST 18H LD HL,RLINE CP LINETOK CALL Z,REVAL LD HL,RSTEP CP STEPTOK CALL Z,REVAL CALL CHKEND LD B,24 CALL TESTROOM CALL SPSS MAKETABLE: LD LD LD HL,(RLINE) BC,(RSTEP) DE,SBN+2

;ASSESS <N> TO <M>

;ABORT IF <6K FREE

EXX LD HL,SBO PUSH HL LD DE,0000H POP HL ;SBO

4F3B 4F3C 4F3D 4F3E 4F3F 4F40 4F43 4F45 4F47 4F47 4F4A 4F4B 4F4D 4F4F 4F4F 4F50 4F51 4F52 4F53 4F53 4F54 4F55 4F56 4F57 4F58 4F59 4F5A 4F5C 4F5C 4F5D 4F5E 4F5F 4F61 4F61 4F62 4F63 4F63 4F64 4F66 4F66 4F67 4F68 4F68 4F69 4F6C 4F6F 4F72 4F75 4F78 4F79 4F7C 4F7D 4F7D 4F7E 4F7F 4F81 4F81 4F82 4F82 4F83 4F84 4F85 4F86 4F88 4F8A 4F8C 4F8E 4F8E 4F91 4F92 4F93 4F96 4F98 4F9A 4F9A 4F9D 4F9D 4F9D 4F9D 4FA0 4FA3 4FA3 4FA4 4FA5 4FA6 4FA7 4FAA 4FAB 4FAD 4FAD 4FAE 4FAF 4FB0 4FB1 4FB2 4FB3 4FB4 4FB5 4FB6 4FB7 4FBA 4FBC 4FBC

72 23 73 2B E5 2A7F5A ED52 3821 CD573C 37 ED52 30EB E1 23 23 E5 D9 EB 72 23 73 23 24 280A 25 EB 09 3805 7C D9 3C 20D4 CF 21 C1 2A0080 22C85A CDC63F 21455C CDC550 C5 3A475C F5 7A 3C 2001 5F AF D5 D9 D1 ED42 ED42 ED52 30D8 2AC85A 55 5C 2A425A ED52 38CC CDD64F 2A7D5A CD4D1A 46 23 4E E5 CDD250 E1 380F 71 2B 70 23 23 4E 23 46 23 09 CDEF3F 18E7 21495C REN5: CHGLL: REN3: NRFLERR: RENUM3:

LD (HL),D INC HL LD (HL),E DEC HL PUSH HL LD HL,(LAST) SBC HL,DE JR C,RENUM3 CALL GTRLNN SCF SBC HL,DE JR NC,MKTBLP POP INC INC PUSH HL HL HL HL

;SBO ;FEFF IF END OF PROG WANTED ;JR IF LINE NUMBER JUST PLACED IS PAST BLOCK END ;(COULD BE FF?? PROG TERMINATOR)

EXX EX DE,HL LD (HL),D INC HL LD (HL),E INC HL INC H JR Z,NRFLERR DEC H EX DE,HL ADD HL,BC JR C,NRFLERR LD A,H EXX INC JR A NZ,MKTBLP ;LOOP UNLESS LINE NUMBERS TOO HIGH (>FEFF) ;'No room for line' ;SAVE IT SO IT CAN BE READ WHEN SCREEN SWITCHED OUT ;ADD LINE,STEP TO GET NEXT NEW LINE NO.

RST 08H DB 33 POP BC LD HL,(SBO) LD (TEMPW1),HL CALL RCURP LD HL,PPC CALL TRANSHL PUSH BC LD A,(SUBPPC) PUSH AF LD A,D INC A JR NZ,REN3 LD E,A XOR A PUSH DE EXX POP DE SBC HL,BC SBC HL,BC SBC HL,DE JR NC,NRFLERR LD HL,(TEMPW1) LD D,L LD E,H LD HL,(RLINE) SBC HL,DE JR C,NRFLERR CALL CHGREF

;JR IF DE IS A REAL LINE NUMBER ;ELSE DE=FF00, MAX LINE+1 ;NC

;ERROR IF MOVING LINES ONTO OTHERS

;CHANGE LINE NUMBERS LD HL,(FIRST) CALL FNDLINE LD B,(HL) INC HL LD C,(HL) PUSH HL CALL TRANSFORM POP HL JR C,REN5 LD DEC LD INC INC LD INC LD INC ADD CALL JR (HL),C HL (HL),B HL HL C,(HL) HL B,(HL) HL HL,BC CHKHL CHGLL

;JR IF FINISHED BLOCK ;ALTER LINE NUMBER

;BC=LINE LEN ;PT TO NEXT LINE

LD HL,EPPC

4FBF 4FC2 4FC4 4FC7 4FCA 4FCD 4FCD 4FCD 4FCD 4FD0 4FD0 4FD1 4FD2 4FD3 4FD6 4FD6 4FDA 4FDA 4FDC 4FDF 4FE0 4FE1 4FE2 4FE2 4FE5 4FE6 4FE7 4FE8 4FE9 4FEC 4FEC 4FEF 4FF0 4FF1 4FF1 4FF2 4FF5 4FF7 4FF7 4FFA 4FFC 4FFF 5002 5004 5006 5006 5007 5008 5009 500B 500D 500D 500F 5011 5011 5012 5012 5014 5016 5016 5017 5017 5018 501A 501C 501E 501E 501F 5021 5023 5023 5024 5025 5026 5027 5027 5028 5029 5029 502C 502D 502F 502F 5030 5030 5031 5032 5034 5036 5036 5037 5039 503B 503B 503E 5041 5044 5045 5048 504A 504A 504D 504F

CDC550 2E6C CDC550 CD9806 C3D033 CD121D C1 C1 C1 C39B50 DD21AA50 DD23 CD321F 7E 3C C8 22AF5A 23 23 23 23 22975A DD7E00 A7 C8 5F CD9C1D 30E3 32475C DBFB 32965A DD7E00 FE8C 200B 2B 2B 7E FE24 2804 FE22 20DB DF FE8E 2001 E7 E5 06FF FEDE 200B E7 FE3B 20FB E7 D1 E5 11 23 7E CD303B 04 38F8 C5 7E 23 FE20 28FA E5 FE0E 2095 CD201D 22975A CD2E1D DF CD723A 2083 CDD250 3881 CHGR6: CHGR4: CHGR5: CHGR2: CHGRY: CHGR1: RLOOP: FAILED: NBLKL:

CALL TRANSHL LD L,>SDTOP CALL TRANSHL CALL MCLS JP GT4P CALL FDELETE POP BC POP BC POP BC JP CHGR7 LD IX,RENTAB-1 INC IX CALL ADDRPROG LD A,(HL) INC A RET Z LD INC INC INC INC LD LD AND RET (CLA),HL HL HL HL HL (CHAD),HL A,(IX+0) A Z

;CLEAR ENTIRE SCREEN ;UNSTACK STAT, PPC, SET UP FOR GOTO NEXT, COMP

;CHANGE REFERENCES TO LINE NUMBERS

CHGREF: RENCL:

LD E,A CALL SRCHPROG JR NC,RENCL LD (SUBPPC),A IN A,(251) LD (CHADP),A LD A,(IX+0) CP LINETOK JR NZ,CHGRY DEC HL DEC HL LD A,(HL) CP "$" JR Z,CHGRY CP 22H JR NZ,RLOOP RST CP JR RST PUSH LD CP JR RST CP JR 18H TOTOK NZ,CHGR2 20H HL B,0FFH 0DEH NZ,CHGR5 20H ";" NZ,CHGR3 ;ONTOK ;PT TO BYTE BEFORE "LINE" ;RENUM E.G. SAVE ASD$ LINE 10 ;NO RENUM UNLESS E.G. SAVE "NAME" LINE 10

CHGR3:

RST 20H POP DE PUSH HL DB 11H INC HL LD A,(HL) CALL NUMERIC INC B JR C,CHGR4 PUSH BC LD A,(HL) INC HL CP " " JR Z,CHGR6 PUSH HL CP 0EH JR NZ,NBLKL CALL HLTOFPCS LD (CHAD),HL CALL GETINT RST 18H CALL COCRCOTO JR NZ,FAILED CALL TRANSFORM JR C,NBLKL

;'JR+2'

;CHECK FOR CR/:/TO/,

504F 5052 5055 5056 5057 505A 505D 505E 505F 5062 5062 5062 5062 5062 5062 5063 5065 5065 5066 5067 5068 5069 506A 506B 506C 506D 506F 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 507A 507B 507D 507F 507F 5081 5082 5083 5086 5088 5088 5089 508A 508D 508D 508E 508F 508F 5092 5094 5095 5097 5098 509B 509B 509E 50A1 50A1 50A4 50A7 50A7 50A8 50AB 50AB 50AC 50AD 50AE 50AF 50B0 50B1 50B2 50B3 50B4 50B5 50B5 50B6 50B9 50BA 50BB 50BB 50BC 50BD 50C0 50C0 50C1 50C2 50C3 50C4 50C5 50C5 50C6 50C7 50C8 50C9 50CC 50CD

CDDD1C 21FBFF 19 D1 CD4B2B CD7E01 F1 D1 2AAF5A

CALL STACKBC LD HL,-5 ADD HL,DE POP DE CALL LDI5 CALL JPFSTRS POP AF POP DE LD HL,(CLA)

;EXITS WITH DE=STKEND ;POINT TO TOP ITEM ON FPCS ;COPY TO 5-BYTE BUFFER IN LINE ;BC=NEW LEN OF NUMBER (DIGITS) ;ORIG NUMBER OF DIGITS

;ADJUST LINE LEN ;ENTRY: HL PTS TO START OF BASIC LINE, DE PTS TO SPACE TO OPEN OR CLOSE IN THE ;LINE, BC=NEW LENGTH OF SPACE, A=OLD LENGTH. 91 282A 23 23 C5 F5 4E 23 46 E5 ED44 6F 17 9F 67 09 44 4D E1 70 2B 71 F1 0600 3009 ED44 4F EB CD1B1E 1805 4F EB CD521E EB C1 21A05B EDB0 EB 0E06 09 22975A CD793A CAEC4F CD723A C2EC4F E7 C31250 CD DD 8C BE BD BA B4 B5 B0 00 E5 CD8D3B E1 D8 78 B1 CA391D 71 23 70 DF C9 4E 23 46 E5 CDD250 E1 D8 TRANSHL: RENTAB: ADJL2: ADJL3: ADLNO: ADJLINE: SUB C JR Z,ADLNO INC INC PUSH PUSH LD INC LD PUSH NEG LD RLA SBC LD ADD LD LD POP LD DEC LD POP LD JR NEG LD EX CALL JR HL HL BC AF C,(HL) HL B,(HL) HL L,A A,A H,A HL,BC B,H C,L HL (HL),B HL (HL),C AF B,0 NC,ADJL2 C,A DE,HL MAKEROOM ADJL3 ;JR IF LENS THE SAME

;CURRENT LINE LEN

;NEW LINE LEN ;JR IF CLOSEING UP SPACE

LD C,A EX DE,HL CALL RECLAIM2 EX DE,HL POP BC LD HL,PRNBUFF LDIR EX DE,HL LD C,6 ADD HL,BC LD (CHAD),HL CALL RCRC JP Z,RLOOP CALL COCRCOTO JP NZ,RLOOP RST 20H JP CHGR1 DB DB DB DB DB DB DB DB DB DB 0CDH 0DDH 08CH 0BEH 0BDH 0BAH 0B4H 0B5H 0B0H 0 ;DELETETOK ;ONERRORTOK ;LINETOK ;LLISTTOK ;LISTTOK ;RESTORETOK ;GOTOTOK ;GOSUBTOK ;RUNTOK ;RST 18, CRCOLON ;Z IF TO/,

CHGR7:

REVAL:

PUSH HL CALL GIR POP HL RET C LD A,B OR C JP Z,IOORERR LD (HL),C INC HL LD (HL),B RST 18H RET LD C,(HL) INC HL LD B,(HL) PUSH HL CALL TRANSFORM POP HL RET C

;RET IF NOT IN BLOCK

50CE 50CE 50CF 50D0 50D1 50D2 50D2 50D5 50D6 50D8 50D9 50D9 50DC 50DE 50E0 50E0 50E1 50E2 50E2 50E5 50E8 50E8 50E9 50EA 50EC 50EC 50ED 50EE 50EF 50F0 50F0 50F2 50F2 50F3 50F4 50F6 50F6 50F7 50F9 50FA 50FB 50FC 50FD 5100 5100 5100 5100 4F00 4F00 4F03 4F06 4F06 4F09 4F0A 4F0C 4F0F 4F10 4F12 4F14 4F14 4F17 4F17 4F18 4F19 4F1A 4F1A 4F1C 4F1C 4F1F 4F21 4F21 4F23 4F25 4F25 4F27 4F2A 4F2A 4F2D 4F30 4F30 4F30 4F00 4F00 4F00 4F03 4F06 4F07 4F09 4F0B 4F0B 4F0E 4F11 4F11 4F12 4F14 4F17 4F17 4F18 4F1B 4F1E 4F21 4F21 4F24

70 2B 71 C9 2A7F5A A7 ED42 D8 2A7D5A ED42 2802 3F D8 CDB13F 210280 7E B8 2004 23 7E 2B B9 3004 23 23 18F2 7C C640 67 46 23 4E C3C63F 0200= CDF72C CD153B 213B5C E5 CBAE CDE704 E1 CB76 2008 CDDA1C EF 56 33 180E CD303B 3804 E6DF D607 D630 CDDA1C CD9904 C30F2B 0030= 210100 CD514F DF FE8E 280C CD8E3B D4514F DF FE8E C2290D E7 CD7A3A 21FFFE C48E3B CDC63A 3009 DL2: GT3: GT4: GETLN DELPT2: GT2: TRANS5: TRANS4: TRANS2: TRANS3:

LD (HL),B DEC HL LD (HL),C RET TRANSFORM: LD AND SBC RET LD SBC JR CCF RET HL,(LAST) A HL,BC C HL,(FIRST) HL,BC Z,TRANS2 C

CALL SPSS LD HL,SBO+2 LD A,(HL) CP B JR NZ,TRANS4 INC HL LD A,(HL) DEC HL CP C JR INC INC JR LD ADD LD LD INC LD JP NC,TRANS5 HL HL TRANS3 A,H A,0+(SBN-SBO)/256 H,A B,(HL) HL C,(HL) RCURP ;NC

TRANSF: RENLN GETP2:

EQU TRANSF+3-RNMP2 ORG INSTBUF CALL SYNTAX1 CALL CHKEND LD HL,FLAGS PUSH HL RES 5,(HL) CALL WKBR POP HL BIT 6,(HL) JR NZ,GT2 CALL STACKA DB CALC DB CHRS DB EXIT JR GT4 CALL NUMERIC JR C,GT3 AND 0DFH SUB 7 SUB 30H CALL STACKA CALL NOISE JP ASSIGN EQU GT4+6-GETP2 ORG $,INSTBUF LD HL,1 CALL DELSR RST 18H CP TOTOK JR Z,DL2 CALL GIR2 CALL NC,DELSR RST 18H CP TOTOK JP NZ,NONSENSE RST 20H CALL CRCOLON LD HL,0FEFFH CALL NZ,GIR2 CALL RUNFLG JR NC,DL4 ;SKIP 'TO' ;LAST LEGAL LINE NUMBER ;GET LAST LINE NUM ;JR IF SYNTAX TIME ;CHAR AFTER 'DELETE' ;EVAL NUM, GET TO HL IF RUNNING. SCF IF SYNTAX ;CALL IF RUNNING ;JR IF '0' TO '9' ;FORCE U.C ;'0'->0, 'A'->10D ETC. ;ASSSIGN STACKED VALUE TO VARIABLE ;CONVERT KEY VALUE TO STRING ;VALID VARIABLE

;'NO KEY' ;GET KEY WITH BREAK OPTION ;FLAGS ;JR IF NUMERIC VALUE WANTED

4F26 4F26 4F29 4F2B 4F2B 4F2E 4F2F 4F2F 4F32 4F34 4F35 4F38 4F38 4F3B 4F3C 4F3F 4F40 4F44 4F47 4F48 4F48 4F49 4F4A 4F4B 4F4E 4F51 4F51 4F54 4F57 4F5A 4F5C 4F5F 4F62 4F62 4F62 4F62 4B00 4B00 4B03 4B03 4B05 4B08 4B09 4B09 4B0C 4B0D 4B10 4B11 4B12 4B13 4B16 4B17 4B18 4B1B 4B1E 4B1F 4B20 4B21 4B23 4B23 4B26 4B26 4B29 4B2C 4B2F 4B30 4B32 4B32 4B35 4B37 4B3A 4B3D 4B3D 4B3F 4B3F 4B40 4B43 4B44 4B44 4B47 4B47 4B48 4B4B 4B4E 4B51 4B51 4B51 4B51 4B51 4F00 4F00 4F03 4F03 4F06 4F06 4F07 4F0A 4F0A 4F0B 4F0C 4F0F 4F10 4F11

CD4D1A 2004 CD4E1F EB CDEF3F DBFB 57 CD103B 3A7F5A 4F CDDF3F 7A ED5B7D5A CDE71F D8 44 4D EB CD531E C3C933 CD4D1A CDEF3F 227D5A DBFB 327F5A C3D73F 0062= CD663A 3EFE CDEC3E C8 2A455C E5 3A475C F5 D5 C5 CDA504 C1 C5 CD351F CD1B1E EB C1 E1 EDB0 CD2E20 CD7238 CD130D 3A3A5C A7 2015 213B5C CBFE CD7910 DA290D 2005 0C CD2B0D 37 D4A010 E1 CD6804 CDA504 C3D033 0051= CD7A3A C4EB38 08 CD153B 08 F5 2AC45B 7E 3C 2002 POP1: KI2: KI3: KEYFIN: KEYLN POPP2: DELSR: DL4:

CALL FNDLINE JR NZ,DL4 CALL NEXTONE EX DE,HL CALL CHKHL IN A,(251) LD D,A CALL CHKENDCP LD A,(LAST) LD C,A CALL TSURPG LD A,D LD DE,(FIRST) CALL SUBAHLCDE RET C LD B,H LD C,L EX DE,HL CALL RECL2BIG JP GT4R CALL FNDLINE CALL CHKHL LD (FIRST),HL IN A,(251) LD (LAST),A JP SELCHADP ORG HDR KEYP2: CALL SYNTAXA LD A,0FEH CALL SBFSR2 RET Z LD HL,(PPC) PUSH HL LD A,(SUBPPC) PUSH AF PUSH DE PUSH BC CALL CLEARSP POP BC PUSH BC CALL ADDRELN CALL MAKEROOM EX DE,HL POP BC POP HL LDIR CALL SETESP CALL TOKMAIN CALL LINESCAN LD A,(ERRNR) AND A JR NZ,KI3 LD HL,FLAGS SET 7,(HL) CALL EVALLINO JP C,NONSENSE JR NZ,KI2 INC C CALL LOOPEL SCF CALL NC,INSERTLN POP HL CALL RESESP CALL CLEARSP JP GT4P EQU KEYFIN+3-KEYP2 ORG INSTBUF CALL CRCOLON CALL NZ,VNUMV EX AF,AF' CALL CHKEND EX AF,AF' PUSH AF LD HL,(BSTKEND) LD A,(HL) INC A JR NZ,POP2

;IF NOT USED, HL IS START OF NEXT LINE ;IF LINE IN USE, GET ADDR OF END+1 IN DE ; THEN HL

;SWITCH IN START ;AHL=END ADDR ;CDE=START ADDR ;RET IF START HIGHER THAN END E.G. DELETE 2 TO 1 ;ABC=LEN TO CLOSE ;HL=START ;CLOSE UP ABC AT (HL) ;'GOTO' NEXT STATEMENT SO NXTLINE ETC. SET UP AGAIN ;DEFAULT LINE IS LINE 1 OR FIRST AFTER IT

DELFIN: DELLN

EQU DELFIN+3-DELPT2

;COPY STRING TO BUFFER. LEN 0-511 OK ;RET IF LEN Z

;SAVE LINE/STAT FOR LATER 'GOTO' ;STRING START ;STRING LEN ;CLEAR ELINE

;DE PTS TO ROOM ;STRING START ;COPY STRING TO ELINE (INDIRECT METHOD MEANS ;EVEN DIRECT KEYIN OF LITERAL STRING WORKS) ;ERRORS WILL RETURN TO THIS ROUTINE NOW. ;OLD ERRSP IS ON STACK ;TOKENIZE ELINE ;CHECK SYNTAX ;JR IF ERROR OCCURRED ;'RUNNING' ;CY IF IOOR, Z IF 0 ;JR IF THERE WAS A LINE NUMBER ;STAT 1 ;RUN ELINE

;OLD ERRSP ;RESET ERRSP, RESPOND TO ANY ERRORS ;CLEAR ELINE ;SET UP SO GOTO HAPPENS. MEANS LINE CAN BE KEYED ;IN BEFORE LINE BEING EXECUTED.

;EVAL NUM VARIABLE, SET NZ ;Z IF NO VAR

;JR IF NOT THE STACK TERMINATOR

4F13 4F13 4F14 4F15 4F15 4F18 4F18 4F19 4F1A 4F1B 4F1D 4F1D 4F1E 4F1F 4F20 4F21 4F23 4F23 4F24 4F27 4F28 4F29 4F2A 4F2A 4F2B 4F2E 4F31 4F31 4F32 4F34 4F36 4F39 4F39 4F3A 4F3A 4F3A 4F3A 4F00 4F00 4F03 4F06 4F09 4F0A 4F0D 4F10 4F11 4F14 4F17 4F17 4F1A 4F1D 4F20 4F21 4F22 4F25 4F25 4F26 4F26 4F27 4F2A 4F2C 4F2C 4F2F 4F30 4F30 4F33 4F35 4F35 4F38 4F39 4F3C 4F3C 4F3D 4F3D 4F3F 4F41 4F41 4F42 4F45 4F46 4F49 4F49 4F4B 4F4D 4F4D 4F50 4F53 4F53 4F56 4F59 4F5B 4F5D 4F5D 4F60 4F63 4F66 4F66 4F69 4F6B 4F6B 4F6E 4F6E 4F6F

CF 0B CD281A 47 F1 C5 2814 24 25 54 5C 2807 78 CDDF3F 56 23 5E EB CDD61C CD0F2B F1 E6E0 FE40 CA0A37 C9 003A= CDC63A DCB506 CD9006 3C 323C5C CD264F AF 32715C CD103B CDB506 3A6D5A 213A5A 96 3C 328C5C C9 DF CDED07 2809 CDD807 C8 DC3D4F 18F1 3A735A A7 CACF07 C9 FE28 2008 E7 CDB707 DF C3953A FE8C 2810 CD1E3B D2F807 CDF72C 21715C CBBE 180E CDF62C CDC63A FA290D 21715C CBFE CD153B E5 CD891D INP5: INP4: INP2: IPITEM: IP2CR: INPSL: POP3: POP4: POP2:

RST 08H DB 11 CALL RETLOOP2 LD B,A POP AF PUSH BC JR Z,POP4 INC H DEC H LD D,H LD E,H JR Z,POP3 LD A,B CALL TSURPG LD D,(HL) INC HL LD E,(HL) EX DE,HL CALL STACKHL CALL ASSIGN POP AF AND 0E0H CP 40H JP Z,DELOCAL RET EQU POP5-POPP2+1 ORG INSTBUF INPP2: CALL RUNFLG CALL C,CLSLOWER CALL SPACAN INC A LD (TVFLAG),A CALL INPSL XOR A LD (FLAGX),A CALL CHKENDCP CALL CLSLOWER LD A,(SPOSNU+1) LD HL,UWTOP SUB (HL) INC A LD (SCRCT),A RET RST 18H CALL PRTERM JR Z,IP2CR CALL PRSEPR RET Z CALL C,IPITEM JR INPSL LD A,(DEVICE) AND A JP Z,RUNCR RET CP "(" JR NZ,INP2 RST 20H CALL PRINT2 RST 18H JP INSISCBRK CP LINETOK JR Z,INP4 CALL ALPHA JP NC,PRITEM CALL SYNTAX1 LD HL,FLAGX RES 7,(HL) JR INP5 CALL SSYNTAX1 CALL RUNFLG JP M,NONSENSE LD HL,FLAGX SET 7,(HL) CALL ABORTER PUSH HL CALL SETWORK

;'No POP data' ;ACCEPT ANY TYPE OF RET ADDR - DO/GOSUB/PROC ;HL=LINE, A=TYPE/PAGE ;TYPE/PAGE ;RET IF NO VARIABLE TO POP INTO

;JR IF ELINE - USE LINE OF 0

;DE=LINE NUMBER ;FPCS TO VAR ;TYPE/PAGE ;IF 'PROC' TYPE, CLEAR LOCAL VARS TOO

POP5: POPLN

;CLS AND SELECT CHANNEL 'K' IF RUNNING ;NO INDENT ** ;A=1 ;'NOT INPUT LINE' SO LISTING OK

;EVERYTHING ON SCREEN DOWN TO SPOSN HAS BEEN SEEN, ;SO WE CAN SCROLL THOSE LINES OFF BEFORE 'SCROLL?'

;JR IF CR/COLON/CLOSE BRACK. ;RET IF TERMINATOR FOUND AFTER ;/,/' ;CALL INPUT ITEM SR IF NON-SEPARATOR FOUND

;CR IF RUNNING IF UPPER SCREEN IN USE

;JR IF NOT AN EMBEDDED PRINT ITEM ;SKIP '(' ;HANDLE PRINT ITEM ;CHECK/SKIP ')'

;JR IF NOT A LETTER ;EXITS WITH DE=FLAGX ;'NOT INPUT LINE' ;SKIP 'LINE', EVAL VAR ;ERROR IF NUMERIC VARIABLE ;"USING INPUT LINE"

;CLEAR WORKSPACE

4F72 4F73 4F75 4F77 4F7A 4F7D 4F80 4F80 4F82 4F84 4F86 4F86 4F88 4F88 4F8B 4F8D 4F8E 4F90 4F90 4F91 4F93 4F94 4F95 4F95 4F98 4F9A 4F9D 4FA0 4FA1 4FA3 4FA3 4FA6 4FA7 4FAA 4FAB 4FAE 4FAF 4FAF 4FB2 4FB3 4FB4 4FB7 4FBA 4FBC 4FBC 4FC0 4FC0 4FC3 4FC6 4FC9 4FCC 4FCF 4FD1 4FD4 4FD5 4FD5 4FD8 4FD8 4FDB 4FDD 4FDD 4FE0 4FE3 4FE6 4FE9 4FEC 4FEC 4FEF 4FF0 4FF2 4FF4 4FF5 4FF7 4FF7 4FFA 4FFB 4FFC 4FFF 4FFF 5000 5001 5002 5004 5006 5006 5009 500C 500C 500D 500E 5011 5012 5015 5016 5019 501C 501E 5021 5024 5027 502A 502D 502E

E1 CBEE CBF6 010100 CDC63A FA884F CBB6 CB7E 2002 0E03 CD801E 360D 0D 2805 2B 3E22 77 12 229A5A DBFB 32995A 3A715C 17 3832 3A965A F5 2A975A E5 2A3D5C E5 21AF4F E5 AF 323A5C CDBD05 2004 ED733D5C CD2B1F CD6910 CDA602 CD7238 213B5C CBBE CD2E50 A7 DC9F02 CDBD05 200F 329B5A CD7605 2A825C 0162DC CDEA01 21715C 7E CBBE CBAE 17 3015 CD2B1F 54 5D 01FFFF 7E 23 03 FE0D 20F9 CDE71C C30F2B F1 E1 223D5C E1 22A95A F1 32A85A 213B5C CBFE CD2E50 3AA85A CDCE3F 2AA95A 22975A C9 INPC: INPBL: INPA: INP8: INPERR: INP7: INP6:

POP HL SET 5,(HL) SET 6,(HL) LD BC,1 CALL RUNFLG JP M,INP6 RES 6,(HL) BIT 7,(HL) JR NZ,INP6 LD C,3 CALL WKROOM LD (HL),0DH DEC C JR Z,INP7 DEC HL LD A,22H LD (HL),A LD (DE),A LD (KCUR),HL IN A,(URPORT) LD (KCURP),A LD A,(FLAGX) RLA JR C,INP9 LD A,(CHADP) PUSH AF LD HL,(CHAD) PUSH HL LD HL,(ERRSP) PUSH HL LD HL,INPERR PUSH HL XOR A LD (ERRNR),A CALL KSCHK JR NZ,INP8 LD (ERRSP),SP CALL ADDRWK CALL REMOVEFP CALL EDITOR CALL TOKMAIN LD HL,FLAGS RES 7,(HL) CALL INPAS AND A CALL C,EDCX CALL KSCHK JR NZ,INPA LD (KCUR+1),A CALL EDPRT LD HL,(OLDPOS) LD BC,POSTORE CALL R1ONCLBC LD HL,FLAGX LD A,(HL) RES 7,(HL) RES 5,(HL) RLA JR NC,INPC CALL ADDRWK LD D,H LD E,L LD BC,0FFFFH LD A,(HL) INC HL INC BC CP 0DH JR NZ,INPBL CALL STKSTOREP JP ASSIGN POP AF POP HL LD (ERRSP),HL POP HL LD (PRPTR),HL POP AF LD (PRPTRP),A LD HL,FLAGS SET 7,(HL) CALL INPAS LD A,(PRPTRP) CALL SETCHADP LD HL,(PRPTR) LD (CHAD),HL RET

;FLAGX ;'INPUT MODE' ;'NUMERIC RESULT' ;JP IF NUMERIC - USE 1 SPACE ;STRING RESULT ;JR IF INPUT LINE - USE 1 SPACE

;LAST LOCN ;JR IF JUST ONE SPACE ;SECOND LOCN ;FIRST LOCN ;KCUR PTS TO CR, OR 2ND QUOTE

;JR IF INPUT LINE - NO SYNTAX CHECK ON INPUT

;'NO ERROR' ;JR IF NOT 'K' OR 'S' CHANNEL ;ONLY SET ERRSP FOR K/S ;PT TO WORKSPACE

;SYNTAX TIME ;SKIP NEXT INSTR. ;EDITOR ;JR IF NOT 'K' OR 'S' CHANNEL ;NO CURSOR WANTED ;PRINT INPUT LINE ;SCREEN POSN=PAST END OF PRINTED INPUT LINE ;'NOT INPUT LINE' ;'NOT INPUT MODE' ;JR IF NOT INPUT LINE ;DE=START

INP9:

;COUNT LEN TILL 0D TERMINATOR

;JUNK INPERR

;ORIG CHAD IN AUTO-ADJUST SYS VAR

502E 5031 5034 5037 503A 503B 503D 503F 503F 5042 5043 5043 5044 5045 5045 5048 504B 504C 504E 504F 504F 5050 5051 5051 5051 5051 5051 5051 5051 5051 4F00 4F00 4F03 4F03 4F03 4F03 4F03 4F06 4F08 4F08 4F0B 4F0E 4F0E 4F0F 4F12 4F13 4F15 4F16 4F17 4F17 4F18 4F19 4F1C 4F1D 4F1F 4F1F 4F22 4F22 4F25 4F25 4F26 4F27 4F2A 4F2B 4F2D 4F30 4F30 4F31 4F32 4F35 4F37 4F37 4F37 4F37 4F37 4F37 4F38 4F39 4F3A 4F3B 4F3C 4F3D 4F40 4F41 4F42 4F44 4F45 4F46 4F47 4F48 4F49 4F4A 4F4B 4F4C 4F4D 4F4E 4F4F 4F51 4F51 4F52 4F53 4F54 4F55

2A915A 22975A 3A905A CDCE3F DF FEB1 2006 CDC63A D0 CF 11 3A715C CDFD2A DF FE0D C8 CF 1D 0151=

INPAS:

LD HL,(WORKSP) LD (CHAD),HL LD A,(WORKSPP) CALL SETCHADP RST 18H CP 0B1H JR NZ,INPA2 CALL RUNFLG RET NC RST 08H DB 17

;STOPTOK

;'STOP in INPUT'

INPA2:

LD A,(FLAGX) CALL VALFET2 RST 18H CP 0DH RET Z RST 08H DB 29 EQU INPFIN+1-INPP2 INCLUDE TMISCX2.SAM ;INPUT ;DEF KEYCODE, READ, DEF FN, TOKEN. ;'NONSENSE'

INPFIN: INPLN ;MISCX2.SAM

ORG INSTBUF CDE43A DKP2: CALL EXPT1NUM ;NUMBER OF KEY CODE TO DEFINE ;(KEYBOARD HAS 69 KEYS WITH 3 SHIFTS (CAPS, SYM, ;CONTROL) GIVING 276 BYTES IN KEY MAP, ANY OF WHICH ;CAN BE PROGRAMMED TO GIVE ANY KEY CODE. KEY CODES ;ABOVE 168? CAN BE DEFINED ;SEE IF COMMA OR SEMI-COLON ;JR IF STRING DEFINITION SHOULD FOLLOW ;JP IF SYNTAX TIME - CHECK, STRIP FP FORMS ;DE=CHAD

CD6C3A 2817 CDC63A D26410 EB 2A9D5A 37 ED52 44 4D 0B 13 21120E E3 1806 CD653A CDDC3F D5 C5 CD331D 3C FEC1 DA391D 3D F5 CDAA05 381A DFK5: DFK4:

CALL COMMASC JR Z,DFK4 CALL RUNFLG JP NC,DFKNL EX DE,HL LD HL,(NXTLINE) SCF SBC HL,DE LD B,H LD C,L DEC BC INC DE LD HL,LINEEND EX (SP),HL JR DFK5 CALL SSYNTAXA CALL GETSTRING PUSH DE PUSH BC CALL GETBYTE INC A CP 193 JP C,IOORERR DEC A PUSH AF CALL FNDKYD JR C,DFK55

;ASSUMING NXTLINE HAS SAME PAGE PART AS CHAD, ;BC=LEN OF REST OF LINE ;DEC BECAUSE WE DON'T USE ':' SEPARATOR ;SKIP ':' ;JUNK NEXT STAT, STACK LINEEND SO WE DON'T ;EXECUTE THE REST OF THIS LINE ;DEFINITION STRING ;BC=LEN, DE=ST, PAGED IN ;KEY CODE ;255->0 ;ONLY KEY CODES 192-254 ARE DEFINABLE

;FIND ANY EXISTING KEY DATA ;JR IF DOESNT EXIST, ELSE CLOSE IT UP

;DEF KEY CLOSE ;CLOSES BC+3 BYTES AT HL-3 (I.E. ENTRY WITH HL PTING TO TEXT, BC=TEXT LEN, ;ERASES ENTIRE DEFINITION) 03 03 03 E5 09 E5 CDA805 D1 A7 ED52 23 44 4D EB 2B 2B 2B D1 1B 1B 1B EDB0 F1 C1 F5 78 FEFF DFK55: INC BC INC BC INC BC PUSH HL ADD HL,BC PUSH HL CALL DKTR POP DE AND A SBC HL,DE INC HL LD B,H LD C,L EX DE,HL DEC HL DEC HL DEC HL POP DE DEC DE DEC DE DEC DE LDIR POP AF POP BC PUSH AF LD A,B CP 0FFH

;DEF TEXT START ;PT TO PAST END OF DEFINITION,+3 ;GET HL PTING TO TERMINATOR+3

;BC=BYTES TO MOVE (PAST END TO TERMINATOR, PLUS 1) ;PT TO PAST DEF END ;PT TO DEF START ;KEY CODE ;DEF$ LEN

4F57 4F59 4F59 4F5A 4F5A 4F5D 4F5D 4F5D 4F5D 4F5D 4F5D 4F5E 4F61 4F62 4F63 4F64 4F65 4F68 4F6A 4F6D 4F6D 4F6E 4F70 4F71 4F72 4F73 4F74 4F74 4F75 4F76 4F77 4F78 4F79 4F7A 4F7B 4F7C 4F7D 4F7E 4F80 4F81 4F81 4F81 4F81 4F81 4F81 4F81 4F81 4F81 4F00 4F00 4F03 4F06 4F06 4F07 4F0A 4F0B 4F0E 4F0F 4F11 4F13 4F13 4F14 4F16 4F18 4F18 4F1B 4F1C 4F1D 4F1F 4F21 4F21 4F22 4F22 4F25 4F29 4F2A 4F2C 4F2E 4F2E 4F31 4F33 4F33 4F34 4F34 4F36 4F38 4F38 4F3B 4F3C 4F3E 4F3E 4F3F 4F40 4F40 4F41 4F42 4F42 4F43 4F44 4F44 4F44 4D80 4D80

2801 B1 CAD304 DFK6:

JR Z,DFK6 OR C JP Z,PPRET

;ABORT IF WAS E.G. DEF KEY 1 (CR). LEN IS FFFFH ;ALSO ABORT IF LEN 0 ;POP POP RET - JUNK KEY, SRC, ABORT

;DEF KEY OPEN ;ENTRY: BC=TEXT LEN (BC+3 IS OPENED TO ALLOW FOR KEY CODE AND LEN) ;EXIT: DE PTS TO SPACE, BC IS UNCHANGED C5 CDA805 C1 E5 09 EB 2AD05B ED52 DA0730 EB 36FF D1 1B 1B 1B F1 E1 12 13 79 12 13 78 12 13 EDB0 C9 0081= 0000= PUSH BC CALL DKTR POP BC PUSH HL ADD HL,BC EX DE,HL LD HL,(DKLIM) SBC HL,DE JP C,TMDERR EX DE,HL LD (HL),0FFH POP DE DEC DE DEC DE DEC DE POP AF POP HL LD (DE),A INC DE LD A,C LD (DE),A INC DE LD A,B LD (DE),A INC DE LDIR RET EQU DKFIN+1-DKP2 EQU 0 ;RDFIN+3-RDP2 ;HL=TERMINATOR ADDR+3 ;HL=NEW POSN FOR TERMINATOR. NC ;ERROR IF TERMINATOR PAST LIMIT ;ALLOWS TERMINATOR TO BE AT LIMIT... ;NEW TERMINATOR (OLD WILL BE OVER-WRITTEN) ;PT TO OLD TERMINATOR ;KEY CODE ;SRC

;LEN IN PLACE

DKFIN: DKLN RDLN

;DEF FN COMMAND (OR MARKER - DOES NOTHING EXCEPT CHECK SYNTAX) ORG INSTBUF CDC63A DAF210 DF CD2732 F5 22975A DF FE28 2021 E7 FE29 281B CDEC3A 23 7E FE24 2001 23 CD6433 ED53975A E7 FE29 2805 CD853A 18E5 E7 FE3D 200A CD073B C1 2802 05 C0 05 C8 CF 1D 0044= D9 DFN6: DFNNS: DFNLN TOKPT2: DFN4: DFN5: DFN3: DFNPL: DFNP2: CALL RUNFLG JP C,SKIPCSTAT RST 18H CALL FNNAME PUSH AF LD (CHAD),HL RST 18H CP "(" JR NZ,DFN5 RST 20H CP ")" JR Z,DFN4 CALL GETALPH INC HL LD A,(HL) CP "$" JR NZ,DFN3 INC HL CALL MAKESIX LD (CHAD),DE RST 20H CP ")" JR Z,DFN4 CALL INSISCOMA JR DFNPL RST 20H CP "=" JR NZ,DFNNS CALL SEXPTEXPR POP BC JR Z,DFN6 DEC B RET NZ DEC B RET Z RST 08H DM 29 EQU DFNNS+2-DFNP2 ORG CDBUFF+80H EXX ;JR IF EXPR ASSIGNED TO DEF FN IS STRING ;RET IF B WAS NOT 1 ;ERROR IF B<>1 (NAME<>STRING TYPE) ;'Syntax error' ;SKIP STATEMENT IF RUNNING ;A=1 IF STRING DEF FN

;SKIP '(' ;INSIST ON A LETTER ;SKIP VAR LETTER

;SKIP '$' ;PT TO LAST OF 5-BYTES

4D81 4D82 4D82 4D83 4D85 4D85 4D86 4D87 4D88 4D8A 4D8C 4D8C 4D8D 4D8D 4D8E 4D8F 4D92 4D94 4D94 4D96 4D96 4D98 4D98 4D9B 4D9C 4D9C 4D9D 4D9E 4DA0 4DA1 4DA1 4DA4 4DA6 4DA6 4DA8 4DAA 4DAA 4DAC 4DAE 4DAE 4DAF 4DB1 4DB3 4DB3 4DB4 4DB6 4DB8 4DB8 4DB9 4DBA 4DBC 4DBD 4DBD 4DBF 4DC1 4DC1 4DC2 4DC3 4DC4 4DC6 4DC6 4DC7 4DC8 4DCB 4DCE 4DCF 4DD1 4DD2 4DD5 4DD7 4DDA 4DDC 4DDC 4DDF 4DE0 4DE1 4DE4 4DE4 4DE6 4DE6 4DE7 4DE8 4DEA 4DEB 4DEC 4DED 4DED 4DEF 4DF1 4DF1 4DF3 4DF5 4DF6 4DF8 4DF8 4DFA 4DFC 4DFE 4DFE 4E00 4E00 4E01 4E02

EB 7E 1813 E1 7E 23 FE41 380C FE 23 7E CD1E3B 38F9 FE5F 28F5 22975A FE E7 EB FE0D C8 CD1E3B 3820 FE3C 281C FE3E 2818 13 FEFF 280E 1B FE22 20E4 13 1A FE0D C8 FE22 20F7 13 EB 7E 18D2 D5 EB 11234E 010F00 D5 EDB0 D1 21C7F8 3EC5 CD8A01 200A 2AFA5A 24 25 C40500 289F EB A7 ED52 D1 19 EB FE4A 3007 C63A 36FF 23 1811 C63B FEFF 2002 3EA1 2B 08 7E TOK43: TOK42: YGOTM: FNTS: QUOTELP: TOKQUEN: TOKMLP: LKNONALP: TOKRST: LOOKNA:

EX DE,HL LD A,(HL) JR TOKQUEN POP HL LD A,(HL) INC HL CP "A" JR C,TOKQUEN DB 0FEH INC HL LD A,(HL) CALL ALPHA JR C,LKNONALP CP "_" JR Z,LKNONALP LD (CHAD),HL DB 0FEH RST 20H EX DE,HL CP 0DH RET Z CALL ALPHA JR C,POSFIRST CP "<" JR Z,POSFIRST CP ">" JR Z,POSFIRST INC DE CP 0FFH JR Z,FNTS DEC DE CP 22H JR NZ,TOKMLP INC DE LD A,(DE) CP 0DH RET Z CP 22H JR NZ,QUOTELP INC DE EX DE,HL LD A,(HL) JR TOKQUEN PUSH DE EX DE,HL LD DE,TOKFIN+3 LD BC,15 PUSH DE LDIR POP DE LD HL,KEYWTAB-1 LD A,KEYWNO+1 CALL JGTTOK JR NZ,YGOTM LD HL,(MTOKV) INC H DEC H CALL NZ,HLJUMP JR Z,LOOKNA EX DE,HL AND A SBC HL,DE POP DE ADD HL,DE EX DE,HL CP 4AH JR NC,TOK42 ADD A,3AH LD (HL),0FFH INC HL JR TOK55 ADD A,3BH CP 0FFH JR NZ,TOK43 LD A,0A1H DEC HL EX AF,AF' LD A,(HL)

;E-LINE START OR WKSPACE START, OR OTHER, ;JR TO PT CHAD TO LINE START

TO HL

;JR IF WE JUST CONSIDERED '>' OR '<' ;'JR+1'

;LOOP WHILE LETTER ;CHECK FOR LETTER, UNDERLINE OR DOLLAR ;LOOP WHILE UNDERLINE ;RESET CHAD ;'JR+1'

;RET IF END MARKER FOUND ;JR IF A POSSIBLE FIRST LETTER FOUND ;COULD BE '<=' OR '<>' ;COULD BE '>=' ;JR WITH (DE)=FN LETTER IF FN LDR ;QUOTE

POSFIRST:

;END OF THIS ROUTINE, IN CDBUFF ;MAX LEN TO TOKENIZE

;WORDS TO CHECK, PLUS 1 ;GET A=1 TO KEYWNUMBER, IF MATCHED

;JR IF NO MATCH FOUND, OR MTOKV ZERO ;ELSE HL=WORD START, DE=PAST END (IN BUFFER) ;HL=LEN ;ELINE PTR ;HL PTS TO START, DE TO PAST END, IN ELINE ;JR IF IN RANGE OF CMDS ;ELSE GET FN CODE 3BH-83H ;OVERWRITE FIRST LETTER WITH FN LEADER ;CONVERT LIST ENTRY TO TOKEN CODE 85H;'INK' ;PENTOK - ALLOW 'PEN' TO BE ENTERED AS 'INK' ;PT TO BEFORE WORD IN INPUT ;SAVE TOKEN

4E03 4E05 4E07 4E07 4E08 4E08 4E09 4E09 4E0A 4E0B 4E0C 4E0D 4E0F 4E11 4E11 4E12 4E12 4E13 4E16 4E17 4E18 4E19 4E1A 4E1B 4E1D 4E20 4E20 4E21 4E21 4E21 4E21 4F00 4F00 4F03 4F06 4F09 4F09 4F0B 4F0C 4F0F 4F10 4F11 4F12 4F13 4F14 4F15 4F18 4F19 4F1A 4F1B 4F1E 4F21 4F24 4F27 4F2A 4F2B 4F2C 4F2E 4F31 4F32 4F33 4F34 4F35 4F38 4F3B 4F3E 4F3F 4F40 4F43 4F44 4F45 4F48 4F48 4F48 4F48 4F48 4F4B 4F4C 4F4D 4F50 4F50 4F53 4F55 4F56 4F58 4F59 4F5B 4F5E 4F61 4F61 4F64 4F67 4F68 4F69 4F6A 4F6B 4F6C 4F6D 4F6E 4F70 4F73 4F74 4F75

FE20 2801 23 08 77 23 EB 7E FE20 2001 23 D5 CD4F1E D1 62 6B 1B 1A FEB7 C2824D C9 00A1= CD891D 010100 CD801E 36FF E5 CD3B20 E1 C5 D5 79 42 4B CD1C1E D1 C1 37 CD7801 CD9D4F CDDC4F 21604B CD3F20 C5 D5 2E66 CD3F20 79 EB D1 C1 CDE71F 010100 CDCC1F F5 E5 CD2B1F C1 F1 CD531E TOK6: TOK5: TOK55:

CP " " JR Z,TOK5 INC HL EX AF,AF' LD (HL),A INC HL EX DE,HL LD A,(HL) CP " " JR NZ,TOK6 INC HL PUSH DE CALL RECLAIM1 POP DE LD H,D LD L,E DEC DE LD A,(DE) CP 0B7H JP NZ,TOKRST RET

;AVOID INC IF THERE IS A LEADING SPACE - SO IT ;WILL BE OVER-WRITTEN BY TOKEN ;PT TO FIRST LETTER ;RESTORE TOKEN ;PLACE AT START OF SPELLED-OUT FORM ;HL PTS TO FIRST BYTE TO DELETE ;JR IF NO TRAILING SPACE, ELSE INC HL TO INCLUDE ;SPACE IN 'CLOSED UP' REGION ;CLOSE UP (DE) <- (HL) ;KEEP LOOKING FROM HL ONWARDS

;REMTOK. DON'T TOKENIZE REM STATEMENTS ;KEEP TOKENISING FROM HL ONWARDS

TOKFIN: TOKLN MEPRO2:

EQU TOKFIN+1-TOKPT2 ORG INSTBUF CALL SETWORK LD BC,1 CALL WKROOM LD (HL),0FFH PUSH HL CALL RDLLEN POP HL PUSH BC PUSH DE LD A,C LD B,D LD C,E CALL MKRBIG POP DE POP BC SCF CALL JLDVD CALL MBASLNS CALL MNUMS LD HL,HDL+16 CALL RDTHREE PUSH BC PUSH DE LD L,>(HDL+22) CALL RDTHREE LD A,C EX DE,HL POP DE POP BC CALL SUBAHLCDE LD BC,1 CALL ADDAHLBC PUSH AF PUSH HL CALL ADDRWK POP BC POP AF CALL RECL2BIG ;CLEAR WORKSP IN CASE E.G. MERGE A$+B$ ;OPEN 1 BYTE IN WORKROOM (NOTE: ENSURES WKEND MOVED ;BY MKRBIG) ;TERMINATOR ;CDE=FILE LEN TO LOAD

;OPEN ABC BYTES ;'LOAD' NOT 'VERIFY' ;LOAD CDE TO (HL) ;CDE=LEN OF PROG ALONE ;CDE=LEN OF PROG+NVARS+GAP ;AHL=DITTO ;AHL=LEN OF NVARS+GAP ;ALLOW FOR BASIC PROG TERMINATOR

;DELETE LOADED NVARS+GAP

;MERGE STRINGS/ARRAYS (PART OF PROGRAM FILE) ;ENTRY: DEST PTS TO LOADED DATA CD2B1F 7E 3C CAC933 113F51 E60F 4F 0600 7E EDB0 CD3114 C45B2C CD2B1F 010B00 09 7E 23 5E 23 56 EB 0E0E CDCC1F F5 E5 CDB61F MSTAR: CALL ADDRWK LD A,(HL) INC A JP Z,GT4R LD DE,TLBYTE AND 0FH LD C,A LD B,0 LD A,(HL) LDIR CALL STARYLK2 CALL NZ,ASDEL2 CALL ADDRWK LD BC,11 ADD HL,BC LD A,(HL) INC HL LD E,(HL) INC HL LD D,(HL) EX DE,HL LD C,14 CALL ADDAHLBC PUSH AF PUSH HL CALL ADDRELND ;PT TO SRC (TLBYTE OR VAR, OR FF) ;END IF ALL DONE - TERMINATOR HIT

;COPY TLBYTE AND NAME TO BUFFER ;CALL WITH A=DESIRED T/L ;DELETE STRING/ARRAY AT (STRLOCN) IF IT WAS FOUND ;SRC ;PT TO LEN DATA

;AHL=TOTAL LEN OF STR/ARRAY (PAGEFORM)

4F78 4F79 4F7A 4F7B 4F7C 4F7F 4F80 4F82 4F83 4F84 4F86 4F89 4F8A 4F8D 4F90 4F92 4F95 4F98 4F9B 4F9D 4F9D 4F9D 4F9D 4FA0 4FA0 4FA1 4FA2 4FA3 4FA4 4FA5 4FA5 4FA6 4FA9 4FAA 4FAC 4FAD 4FB0 4FB0 4FB3 4FB4 4FB5 4FB6 4FB7 4FB8 4FB9 4FBA 4FBB 4FBC 4FBD 4FBE 4FBF 4FC0 4FC1 4FC4 4FC7 4FCA 4FCB 4FCE 4FCF 4FD0 4FD1 4FD4 4FD7 4FDA 4FDC 4FDC 4FDC 4FDC 4FDE 4FDE 4FE1 4FE2 4FE3 4FE4 4FE5 4FE8 4FE8 4FE9 4FEC 4FED 4FEF 4FF1 4FF1 4FF2 4FF2 4FF3 4FF3 4FF4 4FF5 4FF6 4FF8 4FFA 4FFA 4FFC 4FFD 4FFE 4FFF 5001 5002 5003 5005 5008 5009

C1 F1 F5 C5 CD1C1E EB DBFB 4F E1 CBBC 22845B F1 32835B CD2B1F DBFB CD5E2A CD2B1F CD5E2C 18AB CD2B1F 46 23 78 3C C8 4E CD4F1A E5 DBFB F5 CC4A1E CD2B1F 23 23 4E 23 46 03 03 03 03 F1 E1 E5 F5 C5 CDDF3F CD1B1E CD2B1F C1 CD791F C1 48 D1 CD5E2A CD2B1F CD4A1E 18C4 3E61 324051 5E 23 56 14 C4F24F 23 3A4051 3C FE7B 38ED C9 E5 15 19 7E E6A0 2024 DBFB F5 E5 7E E61F 4F 7E CBB7 323F51 23 23 MNUMSR: MNSRL: MNUMS: MNUML: MBASLNS: MPRG1:

POP BC POP AF PUSH AF PUSH BC CALL MKRBIG EX DE,HL IN A,(251) LD C,A POP HL RES 7,H LD (MODCOUNT),HL POP AF LD (PAGCOUNT),A CALL ADDRWK IN A,(251) CALL FARLDIR CALL ADDRWK CALL ASDEL3 JR MSTAR ;MERGE BASIC LINES CALL ADDRWK LD B,(HL) INC HL LD A,B INC A RET Z LD C,(HL) CALL FNDLP PUSH HL IN A,(251) PUSH AF CALL Z,NORECL CALL ADDRWK INC HL INC HL LD C,(HL) INC HL LD B,(HL) INC BC INC BC INC BC INC BC POP AF POP HL PUSH HL PUSH AF PUSH BC CALL TSURPG CALL MAKEROOM CALL ADDRWK POP BC CALL SPLITBC POP BC LD C,B POP DE CALL FARLDIR CALL ADDRWK CALL NORECL JR MPRG1 LD A,"a" LD (FIRLET),A LD E,(HL) INC HL LD D,(HL) INC D CALL NZ,MNUMSR INC HL LD A,(FIRLET) INC A CP "z"+1 JR C,MNUML RET PUSH HL DEC D ADD HL,DE LD A,(HL) AND 0A0H JR NZ,MNSR3 IN A,(251) PUSH AF PUSH HL LD A,(HL) AND 1FH LD C,A LD A,(HL) RES 6,A LD (TLBYTE),A INC HL INC HL

;MAKE ABC BYTES AT HL FOR STR/ARRAY ;ROOM IS AT CDE

;PT TO SRC ;AHL=SRC, CDE=DEST ;COPY TO DEST ;DELETE SRC

;PT TO LOADED BLOCK (SRC)

;RET IF ALL LINES DONE ;FIND LINE BC, STARTING FROM PROG ;DESTINATION VARS ;RECLAIM IF IT EXISTS ;PT TO SRC

;BC=TOTAL SRC LINE LEN

;MAKE ROOM FOR LINE ;AHL=SRC ;LEN ;CDE=DEST ;COPY TO PROGRAM ;PT TO SRC ;DELETE LINE FROM WORKSP

;MERGE NUMBERS - WORKS WITH 16K OR LESS OF NUMERIC VARS.

;CALL IF LETTER LIST HAS BEEN USED

;SRC PTRS LIST POSN

;MASK ALL EXCEPT 'HIDDEN' AND 'UNUSED' BITS ;DO NOT DEAL WITH SUCH VARS

;'NOT A FOR-TYPE VARIABLE'**

500A 500B 500D 500D 500F 5012 5014 5014 5017 501A 501A 501B 501C 501E 501E 501F 5020 5021 5022 5023 5025 5025 5026 5027 5027 5027 5027 C6FB C6FB C6FB C6FB C6FB C6FB C6FB C6FB C6FB C6FD C6FF C701 C703 C705 C707 C707 C709 C70B C70B C70D C70F C711 C713 C715 C715 C717 C717 C717 C717 C717 C717 C717 C717 C717 C717 C717 C717 C717 C717 C719 C71B C71D C71F C721 C723 C725 C725 C727 C729 C72B C72D C72F C731 C733 C733 C733 C733 C735 C737 C739 C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B C73B

23 2807 0600 114151 EDB0 CD201D CD2B2B E1 F1 D3FB 23 5E 23 56 14 20CE E1 C9 0127= MNSR3: MNSR2:

INC HL JR Z,MNSR2 LD B,0 LD DE,FIRLET+1 LDIR CALL HLTOFPCS CALL CRTVAR4 POP HL POP AF OUT (251),A INC HL LD E,(HL) INC HL LD D,(HL) INC D JR NZ,MNSRL POP HL RET EQU MEEND+1-MEPRO2

;PT TO NAME SECOND LET, OR VALUE ;JR IF 1-LET NUMBER ;COPY REST OF NAME TO BUFFER ;CREATE NUMERIC VAR WITH VALUE ON FPCS, NAME IN ;BUFFER, TYPE IN A ;TLBYTE OF SRC VAR JUST DEALT WITH

;JR IF MORE VARS IN LIST ;LIST POSN

MEEND: MELN

ORG 0C000H+RENLN+GETLN+DELLN+KEYLN+POPLN+INPLN+DKLN+RDLN+DFNLN+TOKLN+MELN ;MERGE, EOF, PTR, PATH$, FN STUBS, LINK INCLUDE FPCMAIN.SAM ;CALCVARS, FPCMAIN ;FPCMAIN.SAM ;FLOATING POINT CALCULATOR CODES AND ADDRESSES 9FCB 3ECD 8DD0 37CD 49CA C2CC 9718 58C8 5DC9 69C9 6DC9 290D 76C9 02C9 0000= 0001= 0002= 0003= 0004= 0005= 0006= 0007= 0008= 0009= 000D= FCC8 4CC9 44C9 48C9 3CC9 38C9 40C9 08C9 31C9 24C9 2BC9 18C9 13C9 1DC9 7F18 8318 77C8 72C8 000E= 000F= 0010= 0011= 0012= 0013= 0014= 0015= 0016= 0017= 0018= 0019= 001A= 001B= NUAND NNOTE NLESE NGRTE NLESS NEQUAL NGRTR SAND SNOTE SLESE SGRTE SLESS SEQUAL SGRTR EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU MULT ADDN CONCAT SUBN POWER DIVN SWOP DROP MOD IDIV NUOR EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU ;BINARY FPATAB: DW DW DW DW DW DW FPMULT FPADDN FPCONCAT FPSUBN FPPOWER FPDIVN ;00 ;01 ;02 ;03 ;04 ;05 MULT ADDN (NUMBERS) ADDN (STRINGS) SUBN TO-POWER-OF DIVN

DW FPSWOP DW FPDROP DW DW DW DW DW FPMOD FPIDIV FPBOR NONSENSE FPBAND

;06 SWOP ;07 DROP ;08 ;09 ;0A ;0B ;0C MOD IDIV BOR BXOR BAND

DW FPOR 00H 01H 02H 03H 04H 05H 06H 07H 08H 09H 0DH DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW FPAND FPNNOTE FPNLESE FPNGRTE FPNLESS FPNEQUAL FPNGRTR FPSAND FPSNOTE FPSLESE FPSGRTE FPSLESS FPSEQUAL FPSGRTR FPSWOP13 FPSWOP23 FPJPTR FPJPFL

;0D OR

;0E ;0F ;10 ;11 ;12 ;13 ;14 ;15 ;16 ;17 ;18 ;19 ;1A ;1B ;1C ;1D ;1E ;1F

N AND N N<>N N<=N N>=N N<N N=N N>N $ AND N $<>$ $<=$ $>=$ $<$ $=$ $>$ SWOP13 SWOP23 JPTRUE JPFALSE

;BINARY INTERNAL OPERATIONS (ALSO DROP, SWOP ABOVE)

0EH 0FH 10H 11H 12H 13H 14H 15H 16H 17H 18H 19H 1AH 1BH

C73B C73B C73B C73B C73B C73B C73B C73B C73B C73D C73F C741 C743 C745 C747 C749 C74B C74D C74F C751 C753 C755 C757 C759 C75B C75D C75F C761 C763 C765 C767 C769 C76B C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76D C76F C771 C773 C775 C777 C779 C77B C77D C77D C77D C77D C77D C77D C77D C77D C77D C77D C77D C77F C781 C783 C785 C785 C787 C789 C78B C78D C78F C791 C793 C795 C797 C799 C799 C799 C799 C799 C799 C799 C799 C799

001C= 001D= 001E= 001F= 68C8 59C8 5FC8 AEC8 05C8 53C8 B4C8 87C8 81C8 93C8 98C8 C1C9 E2C8 DCC8 C1C8 BBC8 D6D1 3ECE EEC9 49C8 4BC8 4BC8 4BC8 4BC8 4BC8 0020= 0021= 0022= 0023= 0024= 0025= 0026= 0027= 0028= 0029= 002A= 002B= 002C= 002D= 002E= 002F= 0030= 0031= 0032= 0033= 0034=

SWOP13 SWOP23 JPTRUE JPFALSE

EQU EQU EQU EQU

1CH 1DH 1EH 1FH DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW FPJUMP FPLDBREG FPDECB FPSTKBR FPUSEB FPDUP FP1LIT FP5LIT FPSOMELIT FPLKADDRB FPLKADDRW FPREDARG FPLESS0 FPLESE0 FPGRTR0 FPGRTE0 FPTRUNCT FPFORM FPPOWR2 FPEXIT FPEXIT2 FPEXIT2 FPEXIT2 FPEXIT2 FPEXIT2 ;20 ;21 ;22 ;23 ;24 ;25 ;26 ;27 ;28 ;29 ;2A ;2B ;2C ;2D ;2E ;2F ;30 ;31 ;32 ;33 ;34 ;35 ;36 ;37 ;38 JUMP LDBREG DECB STKBREG USEB DUP ONELIT FIVELIT SOMELIT LKADDRB LKADDRW REDARG LESS0 LESE0 GRTR0 GRTE0 TRUNC RESTACK POWR2 EXIT EXIT2 SPARE SPARE SPARE SPARE

;UNARY INTERNAL OPERATIONS

JUMP LDBREG DECB STKBREG USEB DUP ONELIT FIVELIT SOMELIT LKADDRB LKADDRW REDARG LESS0 LESE0 GRTR0 GRTE0 TRUNC RESTACK POWR2 EXIT EXIT2

EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU

20H 21H 22H 23H 24H 25H 26H 27H 28H 29H 2AH 2BH 2CH 2DH 2EH 2FH 30H 31H 32H 33H 34H

;OPERATIONS USED BY BASIC. ;PRIORITY 16,NUMERIC ARG, NUMERIC RESULT 8AC9 B5C9 BAC9 5FCB 6ECB EACA 6BCA E3C9 0039= 003A= 003B= 003C= 003D= 003E= 003F= 0040= 82D1 B0D1 62D1 C2D1 11D1 7718 16D1 1DD1 E5CE ECCF D4CF E8CE EBCE 290D 0041= 0042= 0043= 0044= 0046= 0047= 004C= ABS SGN SQR INT INP PEEK EOF EQU EQU EQU EQU EQU EQU EQU SIN COS TAN ASN ACS ATN LOGN EXP EQU EQU EQU EQU EQU EQU EQU EQU DW DW DW DW DW DW DW DW FPSIN FPCOS FPTAN FPARCSIN FPARCCOS FPARCTAN FPLOGN FPEXP ;39 ;3A ;3B ;3C ;3D ;3E ;3F ;40 SIN COS TAN ASN ACS ATN LOGN EXP

39H 3AH 3BH 3CH 3DH 3EH 3FH 40H DW DW DW DW DW DW DW DW DW DW DW DW DW DW FPABS FPSGN FPSQR FPINT FPUSR FPIN FPPEEK FPDPEEK FPDVAR FPSVAR FPBUTTON FPEOF FPPTR NONSENSE ;41 ;42 ;43 ;44 ;45 ;46 ;47 ;48 ;49 ;4A ;4B ;4C ;4D ;4E ABS SGN SQR INT USR IN PEEK DPEEK DVAR SVAR BUTTON EOF PTR - DISC USE UNUSED

41H 42H 43H 44H 46H 47H 4CH

C799 C799 C799 C79B C79D C79F C7A1 C7A1 C7A1 C7A1 C7A3 C7A3 C7A3 C7A3 C7A5 C7A5 C7A5 C7A5 C7A7 C7A7 C7A7 C7A7 C7A7 C7A7 C7A7 C7A7 C7A7 C7A7 C7A9 C7AB C7AD C7AF C7B1 C7B3 C7B3 C7B3 C7B3 C7B3 C7B3 C7B3 C7B3 C7B5 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7B7 C7BB C7BB C7BE C7BF C7C3 C7C3 C7C3 C7C3 C7C6 C7C8 C7C8 C7C8 C7C8 C7CB C7CC C7CD C7D0 C7D0 C7D0 C7D0 C7D0 C7D2 C7D4

;PRIORITY 15, STRING ARG, NUMERIC RESULT 28D2 290D 5DD1 4CD1 85CE 84CE 34D1 004F= 0051= 0052= 0053= 0054= F2CF 45D1 02D0 25D0 0CD1 B8CF 0056= 0057= 005B= D4C8 8FD1 005C= 005D= 00EF= 00C8= 00C9= 00CA= 00CB= 00CC= 00D0= 00D1= 00D2= 00D3= 00D4= 00D5= 00D8= 00D9= 00DA= 00DB= 00DC= 00DD= 00E0= 00E1= 00E2= 00E6= 00E9= 00EC= 00F0= NOT NEGATE CALC STOD0 STOD1 STOD2 STOD3 STOD4 STO0 STO1 STO2 STO3 STO4 STO5 RCL0 RCL1 RCL2 RCL3 RCL4 RCL5 STKHALF STKZERO STK16K STKFONE STKONE STKTEN STKHALFPI CHRS STRS INKEY UDGA LEN CODE VALS VAL EQU EQU EQU EQU EQU DW DW DW DW FPUDG NONSENSE FPLEN FPCODE ;4F ;50 ;51 ;52 UDG ADDRESS NUMBER LEN CODE

;PRIORITY 15, STRING ARG, STRING RESULT DW FPVALS DW FPVAL DW FPTRUSTR 4FH 51H 52H 53H 54H DW DW DW DW DW DW FPCHRS FPSTRS FPBINS FPHEXS FPUSRS FPINKEY ;56 ;57 ;58 ;59 ;5A ;5B CHR$ STR$ BIN$ HEX$ USR$ INKEY$ ;53 VAL$ ;54 VAL ;55 TRUNC$ ;PRIORITY 15, STRING ARG, NUMERIC RESULT ;PRIORITY 15, STRING ARG, STRING RESULT

;PRIORITY 16, NUMERIC ARG, STRING RESULT

EQU 56H EQU 57H EQU 5BH DW FPNOT DW FPNEGAT EQU 5CH EQU 5DH EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU 0EFH 0C8H 0C9H 0CAH 0CBH 0CCH 0D0H 0D1H 0D2H 0D3H 0D4H 0D5H 0D8H 0D9H 0DAH 0DBH 0DCH 0DDH 0E0H 0E1H 0E2H 0E6H 0E9H 0ECH 0F0H ;5C NOT ;5D NEGATE PRIORITY 4 PRIORITY 9

;ODD PRIORITY, N ARG, N RESULT

;USED BY DRCURVE

;USED BY DRCURVE ;USED BY DRCURVE

;USED BY DRCURVE ;USED BY DRCURVE

;FPCMAIN.SAM - FLOATING POINT CALCULATOR CONTROL ;ENTRY FROM RST 28H. B=JUNK OR VALUE FOR LOOP COUNTER OR CALC CODE FOR USEB ED5B655C 01BBC7 C5 ED53655C DD7E00 DD23 2AF05A 24 25 C40500 BREGEN: FPCMAIN: FPCLP: LD DE,(STKEND) LD BC,FPCLP PUSH BC LD (STKEND),DE LD A,(IX+0) INC IX LD HL,(RST28V) INC H DEC H CALL NZ,HLJUMP ;'RET' WILL LOOP BACK HERE AT END OF A ROUTINE ;RESET STKEND IN CASE A BINARY OPERATION HAS ;COMBINED TWO VALUES INTO ONE, OR VALUE HAS BEEN ;STACKED ;GET A PARAMETER ;PT TO NEXT ONE

;ENTRY POINT IF 'A' REGISTER ALREADY HAS CALC CODE.

;CALL WITH A=CODE, IX PAST CODE, DE=STKEND ;ALLOWS DIRECT TRANSLATION OF ALL ZX FPC CODES ;EXCEPT 34H (STK LITERAL) USING A LOOK-UP TABLE. ;SEE FILES FOR 34H METHOD. ;USED LATER.. ;JR IF BINARY OPERATOR (00-1FH)

0600 FE20 381A

LD B,0 CP 20H JR C,FPCBIN

C7D6 C7D6 C7D8 C7DA C7DA C7DC C7DE C7DE C7E0 C7E2 C7E2 C7E5 C7E6 C7E8 C7EA C7EA C7EC C7EE C7EE C7EF C7F0 C7F0 C7F0 C7F0 C7F3 C7F4 C7F5 C7F5 C7F5 C7F5 C7F6 C7F8 C7FB C7FC C7FD C7FE C7FF C800 C803 C804 C804 C805 C805 C805 C805 C805 C808 C80A C80A C80A C80A C80A C80B C80C C80C C80C C80C C80D C80D C80E C811 C812 C812 C814 C815 C816 C816 C816 C816 C819 C81B C81C C81C C81F C81F C820 C821 C822 C823 C824 C826 C827 C829 C82A C82A C82B C82E C82F C831 C833 C834 C834 C835 C836 C837 C838 C839 C83A C83B C83C C83D C83E C83F

FE60 381B C620 384C C608 3834 21FBFF 19 C608 3822 C608 381C CF 33 21FBFF 19 EB 4F CB01 21FBC6 09 4E 23 46 C5 21FBFF 19 C9 FPCBIN:

CP 60H JR C,FPCUNA ADD A,20H JR C,FPCONST ADD A,8 JR C,FPRCL LD HL,-5 ADD HL,DE ADD A,8 JR C,FPSTO ADD A,8 JR C,FPSTOD RST 08H DB 51 ;HANDLE BINARY FPC OPERATION LD HL,-5 ADD HL,DE EX DE,HL LD C,A RLC C LD HL,FPATAB ADD HL,BC LD C,(HL) INC HL LD B,(HL) PUSH BC LD HL,-5 ADD HL,DE RET

;JR IF UNARY OPERATOR (20-5FH) ;E0-FF ->00-1F ;D8-DF ->00-07 ;HL=STKEND-5 (SRC FOR STORED VALUE) ;D0-D7 ->00-07 ;C8-CF ->00-07 ;'FPC error'

;BACK DE UP TO PT TO STKEND-5

;HANDLE UNARY FPC OPERATION FPCUNA: ;BC=PARAM*2 - WORD INDEX

;ROUTINE ADDR ;IF UNARY OP, HL=STKEND-5, DE=STKEND ;IF BINARY OP, HL=STKEND-10, DE=STKEND-5 ;TO ROUTINE. CY SET

;USE (BCREG) SYS VAR AS SOURCE OF CALCULATOR CODE. USED BY EXPR. EVALUATOR ;UNARY 3A875B 18BE FPUSEB: LD A,(BCREG+1) JR BREGEN

;STORE-WITH-DELETE USED ABOUT 27 TIMES, SO COMBINE ;STOD0, STOD1, ETC E5 FE D5 EB CD1CC8 EB EDB0 D1 C9 CD1CC8 EDB0 C9 2A685C 4F 87 87 81 4F 0600 09 0E05 C9 4F 2134C8 09 0E05 EDB0 C9 80 00 00 00 00 40 81 00 00 00 00 01 FPRCL: LOCMEM1: LOCMEM2: FPSTOD: PUSH HL DB 0FEH PUSH DE EX DE,HL CALL LOCMEM1 EX DE,HL LDIR POP DE RET ;RECALL A MEMORY CALL LOCMEM1 LDIR RET LD HL,(MEM) LD C,A ADD A,A ADD A,A ADD A,C LD C,A LD B,0 ADD HL,BC LD C,5 RET LD C,A LD HL,FPCTAB ADD HL,BC LD C,5 LDIR RET DB DB DB DB DB DB DB DB DB DB DB DB 80H 0 0 0 0 40H 81H 0 0 0 0 1 ;FIND CALC MEM ADDR, GET BC=5 ;COPY MEMORY TO STKEND ;'JR+1' ;STKEND ;CALC MEM ADDR TO DE, BC=5 ;COPY TOP STACK ENTRY TO CALC MEMORY ;STKEND OR STKEND-5 IF DELETE WANTED

;STORE TO A MEMORY (NO DELETE) FPSTO:

;*5

FPCONST:

;C=00-1F. MANY VALUES OF C MAKE NO SENSE. ;PT TO A CONSTANT. DE=STKEND ;TO FPCLP WITH DE=NEW STKEND ;DISP 0 - 0.5 ;DISP 1 - ZERO ;DISP 2 - 16384 ;DISP 6 - FP ONE ;DISP 9 - INTEGER ONE

FPCTAB:

C840 C841 C842 C843 C844 C844 C849 C849 C849 C849 C84A C84B C84B C84B C84B C84C C84D C84E C850 C853 C853 C853 C853 C856 C858 C858 C859 C859 C85C C85D C85F C85F C85F C85F C862 C863 C863 C866 C868 C868 C868 C868 C86B C86C C86D C86E C86F C871 C872 C872 C872 C872 C875 C877 C877 C877 C877 C878 C879 C87A C87B C87C C87C C87E C87E C880 C881 C881 C881 C881 C884 C886 C887 C887 C887 C887 C889 C889 C88C C88D C88F C890 C892 C892 C893 C893 C893 C893 C896 C898 C898 C898 C898 C89B C89E C89E C89F C8A2 C8A4 C8A7 C8A9 C8AA C8AB

00 00 0A 00 81490FDAA2 C1 C9 C1 C1 F1 DDE1 C3F900 010500 EDB0 C9 DD7E00 BF 1804 3A875B 3D 32875B 2816 DD7E00 4F 17 9F 47 DD09 C9 CD51C9 1805 62 6B 23 23 35 28EA DD23 C9 DD4600 DD23 21 0605 DD7E00 12 DD23 13 10F7 C9 CD9EC8 1857 CD9EC8 C3DD1C EB DD5E00 DD23 DD5600 DD23 EB 4E 23 FPEXIT:

DB DB DB DB

0 0 10 0

;DISP 0C - TEN

DB 81H,49H,0FH,0DAH,0A2H ;TERMINATE FPC PARAM LIST POP BC RET POP BC POP BC POP AF POP IX JP LRPOUT LD BC,5 LDIR RET LD A,(IX+0) CP A JR FPLDDCC LD A,(BCREG+1) DEC A LD (BCREG+1),A JR Z,FPPSKIP LD A,(IX+0) LD C,A RLA SBC A,A LD B,A ADD IX,BC RET CALL TSTZERO JR FPJPTF LD H,D LD L,E INC HL INC HL DEC (HL) JR Z,FPJUMP INC IX RET

;DISP 10H - PI/2

;JUNK FPC LOOPING ADDRESS ;RET TO ROM0'S RST 28H ROUTINE ;FPC LOOPING ADDR ;ROM0 RST 28H RET ADDR ;PORT STATUS ;ORIG IX

;TERMINATE FPC PARAM LIST AND JUNK A RET ADDR (REPLACES DB EXIT: RET) FPEXIT2:

;DUPLICATE LAST ENTRY. UNARY OP FPDUP: FPDROP: FPLDBREG:

;EXIT IS A UNARY OP SO HL=STKEND-5, DE=STKEND ;DELETE (DROP) IS BINARY SO DE=STKEND-5 - DROP. ;SET ZERO

;USE (BCREG) SYS VAR AS A COUNTER. DEC AND JR NZ. UNARY FPDECB: FPLDDCC:

;UNCONDITIONAL JUMP OF PARAM PTR BY (IX) BYTES. UNARY FPJUMP:

;B=FF OR 00 ACCORDING TO C ;ADJUST IX UP OR DOWN

;JUMP IF ZERO. BINARY OPERATOR. DE=STKEND-5 SO 'LAST VALUE' DROPPED FPJPFL: ;Z IF VALUE AT (DE) (IE N2) IS ZERO

;JUMP IF TRUE. BINARY OPERATOR. DE=STKEND-5 FPJPTR:

;PT TO 1/0 ON FPCS ;SET ZERO IF TRUE (1) ;SKIP BYTES TO JUMP BY

FPJPTF: FPPSKIP:

;STACK SOME LITERALS FROM PARAM LIST FPSOMELIT: LD B,(IX+0) INC IX DB 21H FP5LIT: FIVLTLP: LD B,5 LD A,(IX+0) LD (DE),A INC IX INC DE DJNZ FIVLTLP RET FPLKADDRB: CALL LKADDRSR JR STACKC ;'DPEEK' USING ADDRESS IN PARAM LIST FPLKADDRW: CALL LKADDRSR JP STACKBC LKADDRSR: EX DE,HL LD E,(IX+0) INC IX LD D,(IX+0) INC IX EX DE,HL LD C,(HL) INC HL ;SRC=PARAM LIST ;FETCH NUMBER OF LITERAL BYTES (5,10,15,20 ETC) ;"JR+2"

;STACK 5-BYTE LITERAL FROM PARAM LIST

;DE=NEW STKEND

;'PEEK' USING ADDRESS IN PARAM LIST

;STKEND TO DE AGAIN

C8AC C8AD C8AE C8AE C8AE C8AE C8B1 C8B2 C8B4 C8B4 C8B4 C8B4 C8B7 C8B9 C8BB C8BB C8BB C8BB C8BE C8BF C8C1 C8C1 C8C1 C8C1 C8C2 C8C3 C8C4 C8C5 C8C7 C8C7 C8C8 C8C9 C8CA C8CB C8CC C8CD C8CE C8CF C8D0 C8D2 C8D2 C8D4 C8D4 C8D4 C8D4 C8D7 C8D8 C8D8 C8D8 C8D8 C8DA C8DA C8DC C8DC C8DC C8DC C8DF C8E0 C8E2 C8E2 C8E2 C8E2 C8E3 C8E4 C8E5 C8E6 C8E6 C8E6 C8E6 C8E8 C8E8 C8E8 C8E8 C8EA C8EB C8EB C8EB C8EB C8EB C8ED C8EE C8EF C8EF C8EF C8EF C8F0 C8F1 C8F2 C8F3 C8F4 C8F5 C8F6 C8F7 C8F8 C8F9 C8FA C8FB C8FC C8FC C8FC C8FC C8FF C901

46 C9 3A875B 4F 183B DD4E00 DD23 1834 CD52C9 EB 2827 23 7E 17 2B 3824 23 23 23 7E 2B B6 2B 2B B6 2819 1814 CD52C9 EB 280E 180F CD52C9 EB 2806 23 7E 2B 17 3003 0E01 FE FPLESE0: FPNOT: FPSTKBR:

LD B,(HL) RET ;STACK BCREG+1 SYSTEM VAR (HOLDS B REGISTER ENTRY VALUE) LD A,(BCREG+1) LD C,A JR STACKC LD C,(IX+0) INC IX JR STACKC CALL TSTZERO2 EX DE,HL JR Z,SETTRUE INC HL LD A,(HL) RLA DEC HL JR C,SETFALSE INC HL INC HL INC HL LD A,(HL) DEC HL OR (HL) DEC HL DEC HL OR (HL) JR Z,SETFALSE JR SETTRUE ;SET LAST VALUE TO TRUE (1) IF IT IS 0. UNARY CALL TSTZERO2 EX DE,HL JR Z,SETTRUE JR SETFALSE ;SET LAST VALUE TO TRUE (1) IF IT IS <=0. UNARY CALL TSTZERO2 EX DE,HL JR Z,SETTRUE INC HL LD A,(HL) DEC HL RLA JR NC,SETFALSE LD C,1 DB 0FEH ;REVERSE EX AT END OF TSTZERO

;STACK 1-BYTE LITERAL FROM PARAM LIST. ENTRY: DE=STKEND FP1LIT: ;STACK 00 00 C 00 ;SEE IF (HL) NUMBER IS ZERO

;SET LAST VALUE TO TRUE (1) IF IT IS >=0 (+VE). UNARY FPGRTE0:

;SET LAST VALUE TO TRUE (1) IF IT IS >0 (+VE AND NON-ZERO). UNARY FPGRTR0: ;CY IF -VE

;MSB ;LSB ;EXP

;SET TRUE IF ZERO, FLASE IF NZ ZTRUE:

;SET LAST VALUE TO TRUE (1) IF IT IS <0 (-VE). UNARY FPLESS0:

;CY IF -VE

;SET TRUE IF CY, FALSE IF NC CYTRUE: SETTRUE: ;SET LAST VALUE TO 'TRUE' (1). ENTRY: HL PTS TO LAST VALUE ;'JR+1'

;SET LAST VALUE TO 'FALSE' (0). ENTRY: HL PTS TO LAST VALUE. ;EXIT: HL UNCHANGED, DE=HL+5, A=0 0E00 54 5D AF 12 13 12 13 79 12 AF 13 12 13 13 C9 CD51C9 28EA SETFALSE: LD C,00H LD D,H LD E,L XOR A LD (DE),A INC DE LD (DE),A INC DE LD A,C LD (DE),A XOR A INC DE LD (DE),A INC DE INC DE RET CALL TSTZERO JR Z,SETFALSE

;STACK C TO (DE) AS 00 00 C 00 XX STACKC: ;'INTEGER' ;'+VE' ;LSB FROM PARAM LIST ;MSB IS ZERO

;N1 AND N2 - BINARY OPERATION FPAND: ;SET RESULT TO 0 IF N2 WAS ZERO

C901 C902 C902 C902 C902 C905 C907 C907 C908 C908 C908 C908 C90B C90C C90C C90D C90E C90F C910 C911 C912 C913 C913 C913 C913 C913 C913 C913 C913 C913 C913 C916 C918 C918 C918 C918 C91B C91D C91D C91D C91D C920 C922 C922 C924 C924 C924 C924 C927 C929 C929 C92B C92B C92B C92B C92E C92E C92F C931 C931 C931 C931 C934 C934 C936 C936 C938 C938 C938 C938 C938 C938 C939 C93A C93B C93C C93C C93C C93C C93D C93E C93F C940 C940 C940 C940 C941 C942 C943 C944 C944 C944 C944 C945 C946 C947 C948 C948 C948 C948 C948 C949 C94A

C9 CD51C9 20E1 C9 CD51C9 C0 1B 12 1B 12 13 13 C9 FPSAND: FPOR:

RET ;N1 OR N2 - BINARY OPERATION CALL TSTZERO JR NZ,SETTRUE RET ;A$ AND N2 - BINARY OPERATION CALL TSTZERO RET NZ DEC DE LD (DE),A DEC DE LD (DE),A INC DE INC DE RET

;ELSE LAST VALUE=N1

;SET RESULT TO 1 IF N2 WAS NON-ZERO ;ELSE LAST VALUE=N1

;RETURN A$ IF N2 WAS NON-ZERO

;MAKE STRING LEN=0

;******************************************************************************* ;STRING COMPARISONS. BINARY ;NOTE: S1<S2 IS TRUE WHEN S1 WOULD APPEAR HIGHER IN AN ALPHABETIC LIST. ;ENTRY: S1,S2 ON STACK. BINARY OP. EXIT FROM STRCOMP WITH HL=S1 PTR, SET TRUE/ ;FALSE OVERWRITES S1 WITH 0/1, EXITS WITH DE=NEW STKEND ;S1=S2 CD9D3E 18C0 CD9D3E 18C9 CD9D3E 28C9 180A ;S1<=S2 CD9D3E 28BF 18BB ;S1>=S2 CD9D3E 3F 18B5 CD9D3E 28B5 18B0 FPSGRTE: NCTRUE: ;S1<>S2 FPSNOTE: NZTRUE: CALL STRCOMP JR Z,SETFALSE JR SETTRUE ;NUMERIC COMPARISONS. BINARY. N1,N2 -> TRUE/FALSE ;NUMERIC N1=N2 EF 03 5C 34 EF 03 2C 34 EF 03 2E 34 EF 03 2D 34 FPNEQUAL: DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC SUBN NOT EXIT2 CALC SUBN LESS0 EXIT2 CALC SUBN GRTR0 EXIT2 CALC SUBN LESE0 EXIT2 ;SET TRUE IF ZERO CALL STRCOMP CCF JR CYTRUE ;SET TRUE ON NC FPSLESE: CALL STRCOMP JR Z,SETTRUE JR CYTRUE ;SET TRUE ON CY FPSEQUAL: ;S1<S2 FPSLESS: ;S1>S2 FPSGRTR: CALL STRCOMP JR Z,SETFALSE JR NCTRUE ;SET TRUE ON NC CALL STRCOMP JR CYTRUE ;SET TRUE ON CY CALL STRCOMP JR ZTRUE ;SET TRUE ON Z, ELSE FALSE

;NUMERIC N1<N2 FPNLESS: ;SET TRUE IF N1-N2 GIVES -VE

;NUMERIC N1>N2 FPNGRTR: ;SET TRUE IF N1-N2 GIVES +VE, NON-ZERO

;NUMERIC N1<=N2 FPNLESE: ;SET TRUE IF N1-N2 GIVES -VE OR ZERO

;NUMERIC N1>=N2 EF 03 2F FPNGRTE: DB CALC DB SUBN DB GRTE0 ;SET TRUE IF N1-N2 GIVES +VE

C94B C94C C94C C94C C94C C94D C94E C94F C950 C951 C951 C951 C951 C952 C952 C953 C954 C955 C956 C957 C958 C959 C95A C95B C95C C95D C95D C95D C95D C95E C95F C960 C961 C962 C963 C964 C965 C966 C967 C968 C969 C969 C969 C969 C96A C96B C96C C96D C96D C96D C96D C96D C970 C971 C972 C973 C974 C976 C976 C976 C976 C979 C97A C97B C97C C97D C97D C97E C981 C981 C981 C981 C984 C985 C988 C989 C98A C98A C98A C98A C98A C98A C98A C98B C98C C98D C98E C98F C990 C991 C992 C993 C993 C998 C99D C9A2 C9A7 C9AC C9AC C9AD C9AE C9AE C9AF

34 EF 03 5C 5C 34 EB 7E 23 23 B6 23 B6 2B 2B 2B EB C9 EF 25 1C 25 1C 05 44 D3 1D 00 03 34 EF 05 44 34 FPNNOTE:

DB EXIT2 ;NUMERIC N1<>N2 DB DB DB DB DB CALC SUBN NOT NOT EXIT2 ;SET TRUE IF N1=N2 ;SET TRUE IF N1<>N2

;TEST IF ZERO AT (DE). Z IF ZERO, ELSE NZ. HL UNCHANGED TSTZERO: TSTZERO2: EX DE,HL LD A,(HL) INC HL INC HL OR (HL) INC HL OR (HL) DEC HL DEC HL DEC HL EX DE,HL RET DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC DUP SWOP13 DUP SWOP13 DIVN INT STO3 SWOP23 MULT SUBN EXIT2 CALC DIVN INT EXIT2 ;EXP ;LSB ;MSB

;N1 MOD N2. RETURNS N1-N2*INT(N1/N2). BINARY FPMOD: ;N1,N2 ;N1,N2,N2 ;N2,N2,N1 ;N2,N2,N1,N1 ;N2,N1,N1,N2 ;N2,N1,INT(N1/N2) ;COMES IN HANDY FOR UNSTADDR ;N1,N2,INT(N1/N2) ;N1,N2*INT(N1/N2) ;N1-N2*INT(N1/N2)

;INTEGER DIVIDE. RETURNS INT (N1/N2). BINARY FPIDIV: ;N1,N2 ;N1/N2 ;INT(N1/N2)

;N1 BOR N2 (BIT-WISE OR). BINARY CD81C9 B5 4F 78 B4 1807 CD81C9 A5 4F 78 A4 47 C3DD1C CD2E1D C5 CD2E1D E1 C9 FPBOR: CALL GETHLBC OR L LD C,A LD A,B OR H JR BSTKBCH CALL GETHLBC AND L LD C,A LD A,B AND H LD B,A JP STACKBC CALL GETINT PUSH BC CALL GETINT POP HL RET INCLUDE TRANSEND.SAM ;SIN, COS, EXP, ETC

;N1 BAND N2 (BIT-WISE AND). BINARY FPBAND:

BSTKBCH:

;GET 2 NUMBERS FROM FPCS AS INTEGERS IN BC (N1) AND HL (N2). A=C GETHLBC:

;TRANSEND.SAM - TRANSCENDENTAL FUNCTIONS, AND ARITHMETIC ;W.E. THOMSON FASTER SINE/COSE EF 2B 25 25 00 C8 F0 28 19 80A55DE72A 7D2335E036 79996897AE 74280A109E 6EE64F4819 21 05 D8 00 SINELP: FPSIN: DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC REDARG DUP DUP MULT STOD0 STKHALFPI SOMELIT 25 ;X ;W ;W,W*W ;W ;W, FIRST TERM ;25 BYTES FOLLOW (5 CONSTS)

80H,0A5H,5DH,0E7H,2AH 7DH,23H,35H,0E0H,36H 79H,99H,68H,97H,0AEH 74H,28H,0AH,10H,9EH 6EH,0E6H,4FH,48H,19H ;COUNTER

DB LDBREG DB 05H DB RCL0 DB MULT

C9B0 C9B1 C9B2 C9B3 C9B3 C9B4 C9B5 C9B5 C9B5 C9B5 C9B6 C9B7 C9B8 C9B9 C9BA C9BA C9BA C9BA C9BB C9BC C9BD C9BE C9BF C9C0 C9C1 C9C1 C9C1 C9C1 C9C2 C9C3 C9C6 C9C8 C9C9 C9CA C9CB C9CC C9CD C9CE C9CF C9D0 C9D1 C9D2 C9D3 C9D4 C9D5 C9D6 C9D7 C9D8 C9D9 C9D9 C9DA C9DB C9DB C9DC C9DD C9DE C9DF C9E0 C9E1 C9E2 C9E2 C9E3 C9E3 C9E3 C9E3 C9E3 C9E3 C9E4 C9E4 C9E5 C9E6 C9E8 C9EB C9EB C9EC C9ED C9ED C9EE C9EE C9EE C9EE C9EF C9EF C9F0 C9F1 C9F2 C9F3 C9F3 C9F4 C9F4 C9F4 C9F5 C9F6 C9F7 C9F8 C9F8 C9FD CA02 CA07 CA0C CA11 CA16 CA1B

01 22 FC 00 34 EF F0 01 39 34 EF 25 39 06 3A 05 34 EF 27 7E22F9 836E 00 25 E0 01 44 03 26 04 00 25 41 E6 03 25 2E 1E 03 07 34 E6 03 06 2C 1E 02 5D 34 REDARG2: FPCOS:

DB ADDN DB DECB DB 0FCH DB MULT DB EXIT2 ;COSINE=SINE(ANGLE+PI/2) DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC STKHALFPI ADDN SIN EXIT2 CALC DUP SIN SWOP COS DIVN EXIT2 CALC FIVELIT 7EH,22H,0F9H 83H,6EH MULT DUP STKHALF ADDN INT SUBN ONELIT 04H MULT DUP ABS STKFONE SUBN DUP GRTR0 JPTRUE 3

;LOOP TO SINELP, 5 TIMES

;TAN=SIN X/COS X FPTAN:

;REDARG - REDUCE ANGLE ARGUMENT TO -180 TO +180 DEGREE RANGE FPREDARG:

;1/(2*PI) ;X/(2*PI)=X IN 360 DEGREE UNITS ;HALF =180 DEGREES IN THIS CONTEXT ;X IN 360 DEGREE UNITS, INT 360 DEGREE UNITS+.5 ;X REDUCED TO -180 TO +180 DEGREES ;REDUCED X*4

;TO REDARG2

DB DROP DB EXIT2 DB DB DB DB DB DB DB STKFONE SUBN SWOP LESS0 JPTRUE 2 NEGATE ;(FLOATING PT) ;TO REDARG3

REDARG3:

DB EXIT2

;EXPONENTIAL - FPC UNARY FUNCTION. (W.E.T.) ;EXP(N)=e^X E5 EF 27 8138 AA3B29 00 33 E1 E5 EF 25 44 D1 03 C8 E6 28 23 8031721816 7E75FDE5E7 7C6359854A 7A1D821142 7730071F00 7415F05192 7135A06F0B FPPOWR2: FPEXP: PUSH HL DB DB DB DB CALC FIVELIT 81H,38H 0AAH,3BH,29H ;PTR TO EXP. OF X ;X ;X,1/LN 2 ;X/LN 2=Y. NOW 2^Y IS REQUIRED RESULT

DB MULT DB EXIT POP HL ;CALCULATE 2^Y PUSH HL DB DB DB DB CALC DUP INT STO1

;PTR TO EXP. OF TOP ENTRY ;Y,INT Y ;THE INTEGER PART OF THE POWER CAN JUST ;BE ADDED TO EXP OF X (LATER). ;Y-INT Y=W. NOW DO CLEVER THINGS WITH THE ;FRACTIONAL PART OF THE POWER ;(M0=W) ;FIRST CONST IS 1 (FP FORM) ;35 BYTES FOLLOW (7 CONSTS)

DB SUBN DB DB DB DB DB DB DB DB DB DB DB STOD0 STKFONE SOMELIT 35

80H,31H,72H,18H,16H 7EH,75H,0FDH,0E5H,0E7H 7CH,63H,59H,85H,4AH 7AH,1DH,82H,11H,42H 77H,30H,07H,1FH,00H 74H,15H,0F0H,51H,92H 71H,35H,0A0H,6FH,0BH

CA1B CA1C CA1D CA1D CA1E CA1F CA20 CA21 CA22 CA22 CA23 CA24 CA24 CA27 CA29 CA29 CA2B CA2B CA2C CA2C CA2F CA2F CA31 CA32 CA33 CA33 CA34 CA35 CA37 CA38 CA39 CA3A CA3B CA3D CA3D CA3E CA41 CA41 CA42 CA43 CA45 CA45 CA46 CA49 CA49 CA49 CA49 CA49 CA49 CA4A CA4B CA4C CA4E CA4F CA4F CA50 CA51 CA52 CA53 CA54 CA55 CA55 CA56 CA57 CA58 CA59 CA59 CA5A CA5B CA5C CA5D CA5D CA5D CA5D CA5E CA5F CA60 CA60 CA60 CA60 CA61 CA62 CA63 CA64 CA65 CA66 CA66 CA67 CA68 CA69 CA6A CA6A CA6B CA6B CA6B CA6B CA6B CA6C CA6D CA6E CA6F CA70 CA71

21 07 D8 00 01 22 FC D9 33 CD651D 280A 3004 E1 C3EBC8 ED44 4F 05 E1 5E 1600 EB 09 EB 14 28EF 15 C2D117 7B A7 28E7 77 C3DECE SETFALSH: FPEXP2: FPEXP3: EXPLP:

DB LDBREG DB 07H DB DB DB DB DB RCL0 MULT ADDN DECB 0FCH

;COUNTER

;LOOP TO EXPLP, 7 TIMES ;2^W,INT Y ;GET INTEGER PART OF POWER. CY IF >FF, Z IF +VE. ;JR IF +VE (BC HOLDS RESULT) ;JR IF IN RANGE (-255 TO -1 AS FF TO 01) ;SET ZERO IF UNDERFLOW

DB RCL1 DB EXIT CALL FPTOA JR Z,FPEXP3 JR NC,FPEXP2 POP HL JP SETFALSE NEG LD C,A DEC B POP HL LD E,(HL) LD D,0 EX DE,HL ADD HL,BC EX DE,HL INC D JR Z,SETFALSH DEC D JP NZ,NTLERR LD A,E AND A JR Z,SETFALSH LD (HL),A JP SETUPDE

;NEGATE BC IF -VE ;PTR TO 2**W ;DE=EXP OF 2^W ;HL=EXP ;ADD POWER TO GET NEW EXPONENT ;DE=NEW EXP, HL PTS TO LAST VALUE ;ZERO RESULT IF UNDERFLOW ;ERROR IF OVERFLOW

;TO POWER - N1**N2. BINARY ;SPECIAL CASES: N1**0=1, 0**NZ=0 13 13 1A E63F 47 EF 25 23 03 1F 0C 06 25 1F 05 3F 00 40 34 06 07 34 07 C8 E9 23 1F 05 D8 00 22 FD 34 ZPOWER: FPPOWER: INC DE INC DE LD A,(DE) AND 3FH LD B,A DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC DUP STKBREG SUBN JPFALSE 0CH SWOP DUP JPFALSE 05H LOGN MULT EXP EXIT2

;IF N2=0-3FH, B=N2 ;N1,N2 ;N1,N2,N2 ;N1,N2,N2,BREG ;N1,N2,N2-BREG ;JP TO IPOWER IF BREG=N2 ;N2,N1 ;N2,N1,N1 ;JP TO ZPOWER IF N1=ZERO ;N2,LN N1 ;N2*LN N1 ;E**(N2*LN N1)

;ZERO TO A NON-ZERO POWER DB SWOP DB DROP DB EXIT2 DB DB DB DB DB DB DB DB DB DB DROP STOD0 STKONE STKBREG JPFALSE 05H RCL0 MULT DECB 0FDH ;0,N2 ;0 ;0 TO ANY POWER GIVES RESULT 0 ;N1 ;(MEM0=N1) ;1 ;1,BREG ;1 ;JP IF N1 TO POWER 0 - RESULT=1 ;T,N1 ;NEW T ;LOOP, DOING N1*N1*N1*N1...BREG TIMES

;N1 TO POWER 0-3FH IPOWER:

DB EXIT2 ;******************************************************************************* ;LOGN - NATURAL LOG

EF 31 25 2D 07 33

FPLOGN:

DB DB DB DB DB DB

CALC RESTACK DUP LESE0 DROP EXIT

;X ;X,X ;X,1/0 ;X

CA71 CA72 CA73 CA74 CA75 CA78 CA78 CA79 CA7B CA7C CA7C CA7D CA7E CA7F CA80 CA81 CA82 CA83 CA84 CA87 CA89 CA8A CA8B CA8C CA8D CA8E CA8E CA8F CA90 CA91 CA92 CA93 CA94 CA94 CA95 CA98 CA9A CA9B CA9C CA9D CA9E CA9F CAA0 CAA3 CAA5 CAA6 CAA7 CAA8 CAA9 CAAA CAAB CAAB CAB0 CAB5 CABA CABF CAC4 CAC9 CACE CAD3 CAD8 CADD CAE2 CAE7 CAE7 CAE8 CAE8 CAEA CAEA CAEA CAEA CAEA CAEB CAEC CAED CAEE CAEF CAF0 CAF1 CAF2 CAF3 CAF3 CAF4 CAF5 CAF6 CAF7 CAF8 CAF9 CAFA CAFB CAFC CAFC CAFD CAFD CAFE CAFF CB00 CB01 CB02 CB03 CB04 CB05 CB06

13 13 1A A7 C2E83E 7E 3680 47 EF 23 26 80 03 06 25 27 80CCCC CCCD 01 2E 1D 1E 07 E6 03 06 E0 05 06 27 803172 17F8 00 06 E6 03 25 27 822000 0000 00 E0 03 C8 28 3C 806E238093 7DA79C7E5E 7A1B43CA36 77A0FE5CFC 74319FB400 71CBDA9600 6E706F6100 6C90AA0000 6930C50000 66DAA50000 6409000000 61AC000000 33 185B LOGN3:

INC DE INC DE LD A,(DE) AND A JP NZ,INVARG LD A,(HL) LD (HL),80H LD B,A DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC STKBREG ONELIT 80H SUBN SWOP DUP FIVELIT 80H,0CCH,0CCH 0CCH,0CDH ADDN GRTR0 SWOP23 JPTRUE 07H STKFONE SUBN SWOP STKHALF DIVN SWOP FIVELIT 80H,31H,72H 17H,0F8H MULT SWOP STKFONE SUBN DUP FIVELIT 82H,20H,00H 00H,00H MULT STKHALF SUBN STOD0 SOMELIT 60

;INVALID ARG IF X IS ZERO OR -VE ;A=EXPONENT OF X ;X REDUCED TO 0.5-0.999999 RANGE ;NX,EXP ;NX,EXP,80H ;NX,TRUE EXP (PERHAPS -VE) ;TE,NX ;TE,NX,NX ;TE,NX,NX,-0.8 ;TE,NX,NX-0.8 ;TE,NX,1/0 ;NX,TE,1/0 ;TO LOGN3 ;NX,TE,1 ;NX,TE-1 ;TE-1,NX ;TE-1,NX,0.5 ;TE-1,2*NX ;2*NX,TE-1 ;NX (OR 2*NX), TE (OR TE-1), LN2 ;NX,TE*LN 2 ;TE*LN 2-1,NX,1 ;TE*LN 2-1,NX-1 ;TE*LN 2-1,NX-1,NX-1,2.5 ; ; ; ;12 CONSTANTS ,(NX-1)*2.5 ,2.5*NX-3

80H,6EH,23H,80H,93H 7DH,0A7H,9CH,7EH,5EH 7AH,1BH,43H,0CAH,36H 77H,0A0H,0FEH,5CH,0FCH 74H,31H,9FH,0B4H,00H 71H,0CBH,0DAH,96H,00H 6EH,70H,6FH,61H,00H 6CH,90H,0AAH,00H,00H 69H,30H,0C5H,00H,00H 66H,0DAH,0A5H,00H,00H 64H,09H,00H,00H,00H 61H,0ACH,00H,00H,00H

DB EXIT JR SERIES ;******************************************************************************* ;ARCTAN

EF 25 41 E6 03 2F 25 1F 0B 06 05 5D 25 F0 06 2C 1E 02 5D 06 25 25 00 E0 05 E6 03 C8

FPARCTAN:

DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB

CALC DUP ABS STKFONE SUBN GRTE0 DUP JPFALSE 0BH SWOP DIVN NEGATE DUP STKHALFPI SWOP LESS0 JPTRUE 02H SWOP DUP DUP MULT STKHALF DIVN STKFONE SUBN STOD0

;X,X ;X,ABS X ** ;X,ABS X,1 ;X,ABS X-1 ;X,1/0 ;X,1/0,1/0 (1 IF ABS X>=1, ELSE 0) ;JP IF ABS X<1, ARCTAN2, WITH X,0 ON FPCS ;1,X ;1/X ;-1/X ;-1/X,-1/X ;-1/X,-1/X,PI/2 ;-1/X,PI/2,-1/X ;-1/X,PI/2,1/0 ;JP IF -1/X IS -VE, ARCTAN2. (-1/X, PI/2 ON FPCS) ;NEGATE PI/2 IF -1/X IS -VE ;(+/-PI/2 OR 0),V ; V,V ; V,V,V ; V,V*V ; V,V*V,0.5 ; V,2*V*V ; V,2*V*V,1 ;(+/-PI/2 OR 0),V,2*V*V-1 ;(+/-PI/2 OR 0),V

DB NEGATE ARCTAN2: DB DB DB DB DB DB DB DB DB

CB06 CB07 CB08 CB08 CB0D CB12 CB17 CB1C CB21 CB26 CB2B CB30 CB35 CB3A CB3F CB44 CB44 CB45 CB45 CB47 CB47 CB48 CB49 CB49 CB4A CB4B CB4C CB4D CB4E CB4E CB4F CB50 CB51 CB52 CB53 CB54 CB55 CB56 CB57 CB58 CB59 CB5A CB5A CB5B CB5C CB5D CB5E CB5F CB5F CB5F CB5F CB60 CB61 CB62 CB63 CB64 CB65 CB66 CB67 CB68 CB69 CB6A CB6B CB6C CB6D CB6E CB6E CB6E CB6E CB6F CB70 CB71 CB72 CB73 CB74 CB74 CB74 CB74 CB74 CB74 CB74 CB74 CB74 CB74 CB75 CB77 CB78 CB79 CB7B CB7B CB7C CB7D CB7E CB7E CB7F CB82 CB84 CB84 CB85 CB87 CB87 CB88 CB8A

28 3C 8061A1B30C 7CD8DE63BE 7936731B5D 76B50936BE 7342C40000 70DBE8B400 6E00367500 6B98FD0000 6839BC0000 65E48D0000 630E000000 60B2000000 33 060C EF D8 E0 05 C8 E1 D1 25 D8 00 D9 D2 03 1D 01 06 C9 22 F5 DA 03 00 01 34 ;ARCSIN EF 25 25 00 E6 06 03 43 E6 01 05 3E E0 05 34 EF 3C F0 06 03 34 FPARCSIN: SERILP: SERIES:

DB SOMELIT DB 60 DB DB DB DB DB DB DB DB DB DB DB DB

;12 CONSTANTS

80H,61H,0A1H,0B3H,0CH 7CH,0D8H,0DEH,63H,0BEH 79H,36H,73H,1BH,5DH 76H,0B5H,09H,36H,0BEH 73H,42H,0C4H,00H,00H 70H,0DBH,0E8H,0B4H,00H 6EH,00H,36H,75H,00H 6BH,98H,0FDH,00H,00H 68H,39H,0BCH,00H,00H 65H,0E4H,8DH,00H,00H 63H,0EH,00H,00H,00H 60H,0B2H,00H,00H,00H ;LOOP COUNTER ;(+/-PI/2 OR 0),V,12 CONSTS,2*V*V-1 ;IGNORE ALL EXCEPT CONSTS AND 2*V*V-1 (CALL IT X) ;C,C,..C,X,0.5 ; ,2*X ; ;0 ;0 (INITIAL N) ; ; ; ; N,N N,N,M0 N,N*M0 N,N*M0,M1

DB EXIT LD B,12 DB CALC DB RCL0 DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB STKHALF DIVN STOD0 STKZERO STO1 DUP RCL0 MULT RCL1 STO2 SUBN SWOP23 ADDN SWOP STOD1 DECB 0F5H RCL2 SUBN MULT ADDN EXIT2 CALC DUP DUP MULT STKFONE SWOP SUBN SQR STKFONE ADDN DIVN ATN STKHALF DIVN EXIT2 CALC ASN STKHALFPI SWOP SUBN EXIT2 ;ARITHMETIC ;X ;X,X ;X,X,X ;X,X*X ;X,1-(X*X) ;X,SQR(1-(X*X))+1 ;TAN

;,C,N,N*M0-M1 ;,N,C,N*M0-M1 ;,N,C+N*M0-M1 ;,C+N*M0-M1,N ;,C+N*M0-M1 ;DEC BREG, JR NZ, TO SERILP

;ARCCOS. (ACS X=PI/2-ASN X) FPARCCOS:

INCLUDE MULT.SAM

;MULT.SAM - MULTIPLY, DIVIDE, SUBTRACT, ADD ;******************************************************************************* ;QMULT - MULTIPLY HL*DE. RESULT IN HL. FASTER IF EITHER NUMBER IS ONE BYTE. ;USES HL,AF. CY IF OVERFLOW OF 16 BITS. C5 0608 7C A7 2803 EB 7C A7 4D 210000 280D 29 3816 17 3003 QMULT2: QHLLP2: QMULT: PUSH BC LD B,8 LD A,H AND A JR Z,QMULT2 EX DE,HL LD A,H AND A LD C,L LD HL,0 JR Z,SHORTMUL ADD HL,HL JR C,QOVERFL RLA JR NC,NOQADN ;DOUBLE RESULT ;TEST NEXT BIT OF ORIG H ;BITS TO DO ;JR IF HL NUMBER IS ONLY 8 BITS - QUICK MULT OK ;SWOP NUMBERS AND SEE IF ORIG DE IS 8 BIT

CB8A CB8B CB8D CB8D CB8F CB8F CB91 CB91 CB92 CB92 CB93 CB95 CB95 CB96 CB98 CB98 CB99 CB9B CB9B CB9D CB9D CB9E CB9F CB9F CB9F CB9F CBA0 CBA1 CBA3 CBA3 CBA4 CBA5 CBA8 CBA9 CBAA CBAB CBAC CBAF CBB0 CBB1 CBB2 CBB3 CBB6 CBB7 CBB8 CBBA CBBA CBBC CBBC CBBC CBBC CBBE CBC0 CBC1 CBC2 CBC3 CBC3 CBC4 CBC5 CBC7 CBC7 CBC8 CBC8 CBC8 CBC8 CBC8 CBCA CBCB CBCC CBCD CBCE CBD0 CBD0 CBD1 CBD2 CBD3 CBD4 CBD5 CBD6 CBD7 CBD7 CBD8 CBD9 CBDA CBDB CBDC CBDC CBDC CBDC CBDC CBDD CBDE CBDF CBE0 CBE1 CBE2 CBE3 CBE4 CBE5 CBE5 CBE6 CBE6 CBE7

19 3810 10F5 0608 79 29 3808 17 3003 19 3802 10F5 C1 C9 1A B6 2054 D5 E5 CDDCCB D5 41 23 23 CDDCCB E1 79 A8 4F CD74CB D1 EB 383C 1807 FE02 DE00 2F 4F D5 7A B3 2001 4F STORADE: NOQADDIN: QOVERFL: SHORTMUL: QHLLOOP: NOQADN:

ADD HL,DE JR C,QOVERFL DJNZ QHLLP2 LD B,8 LD A,C ADD HL,HL JR C,QOVERFL RLA JR NC,NOQADDIN ADD HL,DE JR C,QOVERFL DJNZ QHLLOOP POP BC RET ; RESULT IS IN HL IF NC SIGNALS 'OK' ;******************************************************************************* ;FPC MULTIPLY. BINARY OP WITH HL AND DE PTING TO N1,N2 FPMULT: LD A,(DE) OR (HL) JR NZ,FPMULT2 PUSH DE PUSH HL CALL FETCHI PUSH DE LD B,C INC HL INC HL CALL FETCHI POP HL LD A,C XOR B LD C,A CALL QMULT POP DE EX DE,HL JR C,QMOVERF JR STICZ ;LOAD (HL) WITH INTEGER DE, SGN A CP 2 SBC A,0 CPL LD C,A PUSH DE LD A,D OR E JR NZ,STOREI LD C,A ;ENSURE SGN OF ZERO IS +VE ;01->00, FF->FF ;01->FF, FF->00 ;C=SGN ;JUST TO BALANCE STACK ** ;JR IF EITHER NUMBER IS FLOATING-POINT ;N2 PTR ;N1 PTR ;GET N1 IN DE, SGN IN C ;PT TO N2 ;N1 ;HL=N1, DE=N2, C=SGN OF RESULT ;HL=HL*DE ;N1 PTR ;HL=N1 PTR, DE=RESULT ;JR IF OVERFLOW OF 16 BITS ;A=ORIG L ;DOUBLE RESULT ;TEST NEXT BIT OF ORIG HL

STICZ:

;******************************************************************************* ;STORE INTEGER TO (HL). DE=INTEGER, C=SGN. ENTRY WITH STKEND ON STACK 3600 23 71 23 0C 2007 7B 2F 5F 7A 2F 57 13 73 23 72 D1 C9 STORPI: STOREI: LD (HL),0 INC HL LD (HL),C INC HL INC C JR NZ,STORPI LD A,E CPL LD E,A LD A,D CPL LD D,A INC DE LD (HL),E INC HL LD (HL),D POP DE RET ;'INTEGER' ;SGN

;NEGATE DE IF SGN IS -VE

;NEW STKEND

;******************************************************************************* ;FETCH INTEGER FROM (HL). DE=INTEGER, C=SGN 23 4E 23 5E 23 56 0D 0C C8 1B 7B 2F FETCHI: INC HL LD C,(HL) INC HL LD E,(HL) INC HL LD D,(HL) DEC C INC C RET Z DEC DE LD A,E CPL ;NEGATE DE, SINCE SGN IS -VE

;RET IF +VE

NEGDE: CPLDE:

CBE8 CBE9 CBEA CBEB CBEC CBED CBEE CBEE CBF1 CBF2 CBF4 CBF4 CBF6 CBF6 CBF6 CBF6 CBF6 CBF7 CBF7 CBF7 CBF7 CBF7 CBFA CBFA CBFB CBFB CBFC CBFE CBFE CBFF CC00 CC02 CC02 CC03 CC05 CC05 CC05 CC05 CC05 CC05 CC06 CC07 CC09 CC0A CC0B CC0C CC0F CC0F CC0F CC0F CC10 CC11 CC13 CC13 CC14 CC17 CC17 CC18 CC19 CC1B CC1B CC1C CC1D CC1F CC1F CC20 CC21 CC22 CC23 CC24 CC26 CC26 CC27 CC28 CC29 CC29 CC2A CC2A CC2D CC2D CC30 CC30 CC30 CC31 CC34 CC35 CC38 CC39 CC39 CC39 CC39 CC39 CC39 CC3B CC3B CC3D CC3E CC40 CC40 CC41 CC42 CC42 CC43

5F 7A 2F 57 B3 C9 CDE5CB D9 20F2 18EF NEGDEDE:

LD E,A LD A,D CPL LD D,A OR E RET CALL NEGDE EXX JR NZ,CPLDE JR NEGDE

;Z IF DE=0 ;EXIT WITH REGS SWITCHED ;CPL MSW UNLESS Z SHOWS

;DEAL WITH INTEGER MULTIPLY OVERFLOW D1 QMOVERF: POP DE ;N2 PTR ;******************************************************************************* ;FLOATING POINT MULTIPLY OF 2 NUMBERS. N1, N2 ARE ON FPCS AT (HL) AND (DE) CD39CE D8 08 382C E5 08 2803 08 2028 FPMULT2: CALL DFPFORM RET C EX AF,AF' JR C,MSETZ2 PUSH HL EX AF,AF' JR Z,FPQM1 EX AF,AF' JR NZ,FPMULT3 ;GET FP FORMS ON FPCS. EXIT WITH Z IF N1 IS A ;POWER OF TWO, CY IF IT IS ZERO. F'=DITTO FOR N2 ;IF N1=0, RET (BIN. OP MEANS ONLY 0 LEFT ON FPCS) ;JR IF N2 IS ZERO - SET ZERO RESULT ** ;N1 PTR ;JR IF N1 IS A POWER OF TWO ;JR IF N2 ISN'T A POWER OF TWO

;SPECIAL CASE - EITHER NUMBER (OR BOTH) IS A POWER OF TWO, I.E. EXP 80 00 00 00 ;OR EXP 00 00 00 00. XOR WILL GIVE CORRECT SGN BIT AND COPY NON-ZERO MANTISSA ;BITS. THEN EXPS CAN BE ADDED. 1A 4F 0600 6E 60 09 017FFF 09 24 2816 25 C2D117 7D A7 280E E1 77 0604 23 13 1A AE 77 10F9 23 EB C9 E1 C3EBC8 CD0BCE C5 210000 D9 210000 D9 MSETZERO: MSETZ2: FPMULT3: FPQMULP: FPQM1: LD A,(DE) LD C,A LD B,0 LD L,(HL) LD H,B ADD HL,BC LD BC,-129 ADD HL,BC INC H JR Z,MSETZERO DEC H JP NZ,NTLERR LD A,L AND A JR Z,MSETZERO POP HL LD (HL),A LD B,4 INC HL INC DE LD A,(DE) XOR (HL) LD (HL),A DJNZ FPQMULP INC HL EX DE,HL RET POP HL JP SETFALSE CALL MUDIADSR PUSH BC LD HL,0 EXX LD HL,0 EXX ;MULTIPLIER IS IN A',B',C',A ;RESULT IS IN HL'HL ;MULTIPLICAND IS IN DE'DE 0E04 0608 A7 200B 45 6C D9 7D FPMULCLP: LD C,4 ;4 BYTES IN MULTIPLIER LD B,8 ;8 BITS PER MULTIPLIER BYTE AND A JR NZ,FPMULBLP ;JR IF ANY BIT IN MULTIPLIER IS HIGH LD B,L LD L,H EXX LD A,L ;EXTRA BITS TO B ;GET N1 IN B DE'DE, N2 IN C A'B'C'A, PUT ;RESULT SIGN ON STACK, SET TRUE NUMERIC BITS ;EXP BYTES ;ZERO RESULT LSW ;ZERO RESULT MSW ;DE=NEW STKEND

;ENTRY FROM QUICK DIVIDE FPQMDC: ;SET ZERO IF UNDERFLOW ;ERROR IF OVERFLOW ;EXP OF RESULT ;N1 PTR ;4 MANT BYTES

CC44 CC45 CC47 CC48 CC48 CC49 CC49 CC4B CC4B CC4C CC4E CC4E CC4F CC50 CC52 CC53 CC53 CC54 CC56 CC58 CC59 CC5B CC5D CC5F CC5F CC60 CC61 CC61 CC62 CC63 CC64 CC65 CC66 CC67 CC68 CC68 CC69 CC6B CC6B CC6C CC6D CC6E CC6F CC70 CC71 CC72 CC75 CC75 CC75 CC75 CC75 CC75 CC76 CC76 CC76 CC77 CC79 CC7B CC7B CC7C CC7D CC7D CC7E CC80 CC82 CC83 CC83 CC85 CC85 CC86 CC87 CC87 CC87 CC87 CC87 CC89 CC89 CC8A CC8C CC8C CC8D CC8F CC8F CC90 CC91 CC92 CC94 CC94 CC95 CC96 CC97 CC99 CC99 CC9A CC9B CC9D CC9E CC9E CC9F CC9F CC9F CC9F CCA0

6C 2600 D9 67 1816 1F 3005 19 D9 ED5A D9 D9 CB1C CB1D D9 CB1C CB1D 10EC 1F 47 D9 79 48 08 47 08 D9 0D 20D0 78 41 EB E1 4C 60 09 0180FF NXMBYTE: FPMULT25: FPMULBLP:

LD L,H LD H,0 EXX LD H,A JR NXMBYTE ;0->H'->L'->H->L->B. SHIFT RESULT RIGHT 8 TIMES ;THIS IS ALL THAT HAPPENS IF ALL MULTIPLIER BITS=0 ;GET NEXT MULTIPLIER BYTE

RRA ;TEST EACH BIT IN MULTIPLIER, FROM RHS TO LHS JR NC,FPMULT25 ;JR IF NO ADD OF MULTIPLICAND ADD HL,DE EXX ADC HL,DE EXX EXX RR H RR L EXX RR H RR L DJNZ FPMULBLP RRA LD B,A EXX LD A,C LD C,B EX AF,AF' LD B,A EX AF,AF' EXX DEC C JR NZ,FPMULCLP LD A,B LD B,C EX DE,HL POP HL LD C,H LD H,B ADD HL,BC LD BC,-80H ;A=EXTRA BITS (7 AND 6 MATTER) ;B=0 ;PROTECT RESULT LSW IN DE ;EXP BYTES (BOTH NON-ZERO) ;BC=N1 EXP (B IS 0) ;HL=N2 EXP ;HL=EXP SUM+80H+80H ;ELSE ADD HL'HL,DE'DE

;HALVE RESULT IN HL'HL ;HALVE HL' ;HALVE HL ;SAVE BITS THAT 'FELL OFF' HL'HL IN CASE THIS IS ;FINAL BYTE OF MULTIPLIER.

;A'->B'->C'->A. A IS NEXT MULTIPLIER BYTE

;ENTRY USED BY DIVIDE ;RESULT IS IN HL'DE, EXTRA BITS IN A. BC=+/-80H. BIT 7 OF STACKED AF=RESULT SGN ;HL=COMBINED EXP. BELOW SGN ON STACK IS N1 PTR 09 D9 CB7C 200A D9 2B 17 CB13 CB12 D9 ED6A D9 17 MULNORM: DIVISE: ADD HL,BC EXX BIT 7,H JR NZ,MULNORM EXX DEC HL RLA RL E RL D EXX ADC HL,HL EXX RLA ;SUBTRACT 80H FROM COMBINED EXP TO CORRECT FOR 2 ;+80Hs AS A RESULT OF ADDING 2 EXP BYTES. ;(OR VV. IF DIVIS - ADD 80H TO COMP FOR 80H-80H) ;H' ;IF NO LEADING ZERO BITS, OK ;DEC COMBINED EXP. ;MOVE RESULT TO THE LEFT. ADD IN A 'LOST' ;BIT THAT HAS BEEN IN 'A' ;SINCE LAST HALVING OF RESULT. ;SMALLEST MULT IS .1000*.1000 GIVES .01 SO ;1 MOVE IS ALWAYS ENOUGH TO NORMALISE RESULT. ;(DITTO FOR DIV) ;LOOK AT A 'LOST' BIT FOR FINAL ROUNDING

;ENTRY FROM FPADDN WITH CY IF NEEDS ROUND UP, HL'DE=RESULT, HL=EXP, SGN AND N1 ;PTR ON STACK 3015 1C 2012 14 200F D9 2C D9 200A D9 24 D9 2005 23 D9 2680 D9 F1 24 CA29CC RNDDONE: FPSUBNEN: FPADDNEN: JR NC,RNDDONE INC E JR NZ,RNDDONE INC D JR NZ,RNDDONE EXX INC L EXX JR NZ,RNDDONE EXX INC H EXX JR NZ,RNDDONE INC HL EXX LD H,80H EXX POP AF INC H JP Z,MSETZERO ;ONLY IF ROUNDING RIPPLES RIGHT FORWARDS INC EXP ;AND MAKE MANTISSA .1000000 ;BIT 7=SGN BIT ;JR IF NO NEED TO ROUND UP

;ENTRY FROM FPSUBN WITH BIT 7,A=SGN, HL'DE=MANT, HL=EXP, (SP)=N1 PTR ;IF EXP UNDERFLOWED, USE ZERO

CCA3 CCA3 CCA4 CCA7 CCA7 CCA8 CCA9 CCAC CCAC CCAD CCAE CCAF CCAF CCB0 CCB1 CCB3 CCB4 CCB5 CCB5 CCB6 CCB7 CCB8 CCB9 CCBA CCBB CCBC CCBD CCBE CCBF CCC0 CCC1 CCC2 CCC2 CCC2 CCC2 CCC2 CCC2 CCC2 CCC2 CCC5 CCC5 CCC6 CCC6 CCC7 CCC8 CCCB CCCB CCCD CCCD CCCD CCCD CCCD CCCE CCCF CCD1 CCD2 CCD3 CCD5 CCD8 CCDB CCDB CCDE CCDF CCE0 CCE1 CCE2 CCE2 CCE5 CCE6 CCE6 CCE7 CCE7 CCEA CCEA CCEA CCEC CCEC CCEE CCEE CCEF CCF0 CCF1 CCF2 CCF3 CCF4 CCF5 CCF5 CCF6 CCF7 CCF9 CCFA CCFC CCFC CCFD CCFE CD00 CD01 CD03 CD03 CD04 CD05 CD07 CD09

25 C2D117 2C 2D CA29CC D9 E5 D9 C1 A8 E680 A8 45 E1 70 23 77 23 71 23 72 23 73 23 EB C9 LDMRSLT:

DEC H JP NZ,NTLERR INC L DEC L JP Z,MSETZERO EXX PUSH HL EXX POP BC XOR B AND 80H XOR B LD B,L POP HL LD (HL),B INC HL LD (HL),A INC HL LD (HL),C INC HL LD (HL),D INC HL LD (HL),E INC HL EX DE,HL RET

;ZERO UNLESS OVERFLOW ;H MUST BE ZERO NOW, SINCE WE ONLY USE 1 BYTE EXPS! ;RESULT NOW IN L HL'DE ;JR IF EXP IS ZERO ;GET RESULT MSW FROM HL' ;RESULT MSW ;USE BIT 7 FROM A, REST FROM B. A=SGNED MANT 1 ;N1 PTR

;DE PTS TO N2 (WILL BE STKEND)

;DIVISION ;34-BIT DIVISION. MANTISSAS COULD BE 0.999/0.5=1.999 OR 0.5/0.999=0.5 ;RANGE OF RESULTS=0.5-1.999 BUT METHOD GIVES HALF THIS (0.25-0.999). ALWAYS ;INC EXPONENT TO DOUBLE VALUE. A 33RD BIT MAY BE NEEDED TO NORMALISE RESULT ;TO 0.5-0.999, AND A FINAL BIT IS NEEDED FOR ROUNDING. (SHARED WITH MULTIPLY) CD39CE D8 E5 08 DAD117 200E FPDIVN: CALL DFPFORM RET C PUSH HL EX AF,AF' JP C,NTLERR JR NZ,FPDIVN2 ;GET FP FORMS ON FPCS. EXIT WITH Z IF N1 IS A ;POWER OF TWO, Z/C IF IT IS ZERO. F'=DITTO FOR N2 ;IF N1=0, RET (BIN. OP MEANS ONLY 0 LEFT ON FPCS ;N1 PTR ;JP IF N2 IS ZERO - OVERFLOW FROM DIVN BY ZERO ;JR IF N2 ISN'T A POWER OF TWO

;SPECIAL CASE - N2 IS A POWER OF TWO, E.G. EXP 80 00 00 00 OR EXP 00 00 00 00. ;THIS ALLOWS A SIMPLE EXP SUBTRACTION. 1A 4F 0600 6E 60 ED42 018100 C30FCC CD0BCE EB D9 EB D9 CDEECB D9 C5 01FC08 1817 0608 D9 08 78 08 41 4F D9 29 D9 ED6A D9 3007 19 D9 ED5A 37 180C 19 D9 ED5A 3806 FPDIVE: FPDIVLP: FPDIV3: FPQD1: LD A,(DE) LD C,A LD B,0 LD L,(HL) LD H,B SBC HL,BC LD BC,129 JP FPQMDC CALL MUDIADSR EX DE,HL EXX EX DE,HL EXX CALL NEGDEDE EXX PUSH BC LD BC,08FCH JR FPDIVE LD B,8 EXX EX AF,AF' LD A,B EX AF,AF' LD B,C LD C,A EXX ADD HL,HL EXX ADC HL,HL EXX JR NC,FPDIVE ADD HL,DE EXX ADC HL,DE SCF JR FPDIV4 ADD HL,DE EXX ADC HL,DE JR C,FPDIV4 ;8 BITS PER BYTE

;NC HERE ;SUB N1 EXP,N2 EXP

FPDIVN2:

;GET DIVISOR IN DE'DE, DIVIDEND IN HL'HL ;SGN OF RESULT TO STACK, SET TRUE NUM. BITS ;NEGATE DIVISOR IN DE'DE. COMP FOR EXX IN NEGDEDE ;EXP BYTES ;8 BITS PER BYTE OF RESULT. ;C GOES FD,FE,FF,00 FOR 4 BYTES OF RESULT, ;SAVES 33RD BIT AS CY ON FINAL LOOP WITH C=0

;A'<- B'<- C'<-A. MOVE RESULT BYTES

;MOVE DIVIDEND LEFT ;IF CY, ADD NEG DIVISOR, SCF

;ADD NEGATED DIVISOR IN DE'DE TO DIVIDEND IN HL'HL ;MSW ;JR IF OK, ELSE REVERSE

CD09 CD0A CD0C CD0D CD0F CD0F CD10 CD11 CD13 CD13 CD14 CD17 CD17 CD18 CD18 CD1A CD1C CD1C CD1D CD1E CD1F CD20 CD21 CD22 CD23 CD24 CD25 CD26 CD27 CD28 CD29 CD2A CD2A CD2B CD2C CD2E CD2F CD30 CD32 CD34 CD34 CD34 CD34 CD34 CD37 CD37 CD37 CD37 CD37 CD38 CD39 CD3C CD3D CD3E CD3E CD3F CD40 CD42 CD42 CD43 CD44 CD45 CD46 CD47 CD48 CD49 CD4A CD4B CD4C CD4D CD4E CD4F CD50 CD51 CD52 CD53 CD55 CD56 CD57 CD58 CD59 CD5A CD5C CD5C CD5D CD5E CD5E CD5F CD60 CD62 CD62 CD63 CD64 CD66 CD66 CD67 CD69 CD6A CD6C CD6C CD6D CD6E CD6F

D9 ED52 D9 ED52 D9 17 10E2 0C FAECCC F5 0602 28D9 D9 79 D9 57 D9 68 08 67 D9 F1 0F 0F E1 5C C1 68 2600 44 A7 ED42 0E81 FPDIV4:

EXX SBC HL,DE EXX SBC HL,DE EXX RLA DJNZ FPDIVLP INC C JP M,FPDIV3 PUSH AF LD B,2 JR Z,FPDIVLP EXX LD A,C EXX LD D,A EXX LD L,B EX AF,AF' LD H,A EXX POP AF RRCA RRCA POP HL LD E,H POP BC LD L,B LD H,0 LD B,H AND A SBC HL,BC LD C,81H

;MSW. NC ;SHIFT RESULT BIT IN ;JP IF C=FD/FE/FF ;SAVE LAST WHOLE RESULT BYTE, OR 33RD AND 34TH BITS ;JR IF STILL GOT 33RD AND 34TH BITS TO DO ;RESULT FROM A'B'C'A TO HL' DE ;D ;L' ;H' ;33/34 ;33/34 BITS TO BITS 7 AND 6 ;E ;EXP BYTES ;HL=N1 EXP, BC=N2 EXP ;80H TO BE ADDED TO COMP FOR 80H-80H IN EXP SBC, ;PLUS 1 TO COMP FOR RESULT IN 0.25-0.999 RANGE ;NORMALISE (SHARED WITH MULIPLY)

;HL'DE=MANT, EXTRA BITS IN A. BC=81H. BIT 7 OF STACKED AF=SGN. (SP+2)=N1 PTR C375CC JP DIVISE ;ADDITION/SUBTRACTION ;FPC BINARY OPERATION. EB E5 CD8FD1 E1 EB 1A B6 2034 D5 23 E5 23 4E 23 46 23 23 23 7E 23 5E 23 56 EB 09 0600 EB E1 8E 0F 88 2018 9F 77 7A B3 200A 7E 3C 2006 2B 3691 23 3680 23 73 23 72 MIN0OK: FPSUBN: EX DE,HL PUSH HL CALL FPNEGAT POP HL EX DE,HL LD A,(DE) OR (HL) JR NZ,FPADDN2 PUSH DE INC HL PUSH HL INC HL LD C,(HL) INC HL LD B,(HL) INC HL INC HL INC HL LD A,(HL) INC HL LD E,(HL) INC HL LD D,(HL) EX DE,HL ADD HL,BC LD B,0 EX DE,HL POP HL ADC A,(HL) RRCA ADC A,B JR NZ,ADDNOVERF SBC A,A LD (HL),A LD A,D OR E JR NZ,MIN0OK LD A,(HL) INC A JR NZ,MIN0OK DEC HL LD (HL),91H INC HL LD (HL),80H INC HL LD (HL),E INC HL LD (HL),D ;FOR SUBTRACTION, NEGATE N2, THEN ADD

FPADDN:

;JR IF EITHER NUMBER IS FLOATING-POINT ;N2 PTR ;PTR TO SGN N1 ;BC=N1 ;SGN N2 ;DE=N2 ;HL=N2 ;DE=N1+N2 ;PTR TO N1 SGN

;SIGN ;DEAL WITH MINUS ZERO ;JR IF CANNOT BE 00 FF 00 00 ;DITTO ;EXP ;MAKE RESULT=65536

CD70 CD71 CD72 CD73 CD74 CD74 CD74 CD75 CD76 CD76 CD76 CD77 CD7A CD7D CD7D CD7E CD7F CD81 CD81 CD82 CD84 CD85 CD86 CD87 CD87 CD88 CD8B CD8D CD8D CD90 CD91 CD92 CD93 CD94 CD96 CD96 CD97 CD98 CD9A CD9A CD9B CD9B CD9C CD9E CD9F CD9F CDA0 CDA1 CDA2 CDA3 CDA5 CDA5 CDA6 CDA6 CDA7 CDA9 CDAB CDAC CDAC CDAE CDB0 CDB0 CDB0 CDB0 CDB1 CDB2 CDB3 CDB4 CDB7 CDB7 CDB7 CDB7 CDB7 CDB8 CDBA CDBB CDBD CDBF CDBF CDC0 CDC1 CDC2 CDC3 CDC4 CDC4 CDC7 CDC7 CDC8 CDC8 CDC8 CDC8 CDC9 CDCA CDCB CDCC CDCE CDCE CDD0 CDD1 CDD2 CDD3 CDD4 CDD7

23 70 D1 C9 D1 2B E5 CD39CE CD0BCE 79 90 300C 48 ED44 EB D9 EB D9 CDEFCD 1809 C4EFCD EB D9 EB D9 0600 F1 17 381D 19 D9 ED5A D9 EB E1 E5 23 300B 03 D9 CB1C CB1D D9 CB1A CB1B 7E F5 60 69 C387CC FPADD4: FPADD2:

INC HL LD (HL),B POP DE RET

;ZERO MANT 4 IN CASE RESULT IS 65536 ;DE=NEW STKEND

;******************************************************************************* ADDNOVERF: POP DE DEC HL ;GET N1 AND N2 PTRS CORRECT ;N1+N2 FPADDN2: PUSH HL CALL DFPFORM CALL MUDIADSR LD A,C SUB B JR NC,FPADD2 LD C,B NEG EX DE,HL EXX EX DE,HL EXX CALL ADDALIGN JR FPADD3 ;N1 PTR ;USE FULL FP FORMS ;N1 IN DE'DE, N2 IN HL'HL, EXPS IN BC ;TRUE NUMERIC BITS, XORED SGNS ON STACK ;SUB N2 EXP, N1 EXP. CY IF N1 EXP >N2 EXP ;JR IF MAX EXP IN C ALREADY ;A=EXP DIFF. ;SWOP MANTISSAS OF N1 AND N2 SO THAT HL'HL ;IS THE NUMBER WITH THE LARGER EXP. AND DE'DE ;IS THE NUMBER WITH LOWER EXP (NEEDING SHIFT) ;B=0

CALL NZ,ADDALIGN ;CALL UNLESS EXPS MATCH - NO NEED TO SHIFT EX DE,HL EXX EX DE,HL EXX LD B,0 ;BC=COMMON EXP POP AF RLA JR C,FPSUBN2 ADD HL,DE EXX ADC HL,DE EXX EX DE,HL POP HL PUSH HL INC HL JR NC,FPADD4 INC BC EXX RR H RR L EXX RR D RR E LD A,(HL) PUSH AF LD H,B LD L,C JP FPADDNEN ;RESULT IN HL'DE ;N1 PTR ;PT TO SGN OF RESULT ;JR IF EXP OK AS IT IS ;INC MAX (COMMON) EXP ;BIT 7 BECOMES 1 ;SGNS DO/DONT MATCH FLAG. N1 IN HL'HL NOW ;SUBTRACT IF SIGNS MISMATCH - SUBTRACT

FPADD3:

;NORMALIZE MANTISSA. CY IF NEEDS ROUNDING ;NOTE: -VE NUMBERS ARE ROUNDED IN THE SAM WAY, ;AS WITH MULT AND DIVN, SO BECOME MORE -VE. ;SGN OF RESULT ;HL=EXP, HL'DE=RESULT, SGN AND N1 PTR ON STACK ;CY IF NEEDS ROUNDING UP

;SGN DON'T MATCH SO SUBTRACT. E.G. N1+(-N2) OR -N1+N2. BC=COMMON EXP A7 ED52 D9 ED52 2009 08 D9 7C B5 D9 CA29CC 08 D1 D5 13 1A 3016 EE80 08 EB D9 EB CDEECB EB FPSUBN3: FPSUBN2: AND A SBC HL,DE EXX SBC HL,DE JR NZ,FPSUBN3 EX AF,AF' EXX LD A,H OR L EXX JP Z,MSETZERO EX AF,AF' POP DE PUSH DE INC DE LD A,(DE) JR NC,FPSUBN4 XOR 80H EX AF,AF' EX DE,HL EXX EX DE,HL CALL NEGDEDE EX DE,HL

;MSW ;JR IF MSB OF RESULT IS NZ ;PROTECT CY (Z,CY POSSIBLE)**

;JP IF LSW OF RESULT IS ALSO ZERO - ZERO RESULT ;** SUBN BUG FIX

;HL'HL=RESULT (NON-ZERO). CY WILL SHOW IF SGN NEEDS REVERSAL ;N1 PTR ;JR IF NO NEED TO REVERSE ORIG SGN AND NEG RESULT ;FLIP SGN BIT OF ORIG N1 ;MSW ;LSW. RESULT IN DE'DE ;NEGATE DE'DE, EXIT WITH DE' SELECTED ;MSW

CDD8 CDD9 CDDA CDDB CDDC CDDE CDDE CDDF CDE0 CDE1 CDE2 CDE4 CDE4 CDE6 CDE8 CDE8 CDE9 CDEA CDEB CDEC CDEF CDEF CDEF CDEF CDEF CDEF CDF0 CDF2 CDF4 CDF4 CDF6 CDF6 CDF7 CDF9 CDFB CDFC CDFE CE00 CE02 CE02 CE03 CE03 CE04 CE05 CE05 CE06 CE07 CE07 CE08 CE09 CE0A CE0B CE0B CE0B CE0B CE0B CE0B CE0B CE0C CE0D CE0E CE0F CE10 CE11 CE12 CE13 CE14 CE16 CE17 CE18 CE19 CE1A CE1B CE1C CE1D CE1E CE1F CE20 CE21 CE22 CE24 CE25 CE26 CE27 CE28 CE28 CE29 CE2A CE2B CE2C CE2D CE2E CE2F CE2F CE30 CE31 CE31 CE32 CE33 CE34 CE35 CE35 CE36

D9 EB D9 08 1806 D9 0B 29 D9 ED6A CB7C 28F6 D9 EB 60 69 C39FCC FPSUBNLP:

EXX EX DE,HL EXX EX AF,AF' JR FPSUBN4 EXX DEC BC ADD HL,HL EXX ADC HL,HL BIT 7,H JR Z,FPSUBNLP EXX EX DE,HL LD H,B LD L,C JP FPSUBNEN

;LSW. RESULT IN HL'HL

;EXP ;SHIFT HL'HL LEFT ;H' ;LOOP UNTIL NUMBER IS NORMALIZED ;RESULT IN HL'DE ;BIT 7,A=RESULT SGN, HL'DE=MANT, HL=EXP ;(SP)=N1 PTR

FPSUBN4:

;ADDALIGN SR. ENTRY:DE'DE=MANT, A=BITS 47 FE21 3802 0621 D9 CB3A CB1B D9 CB1A CB1B 10F4 D0 1C C0 14 C0 D9 13 D9 C9 ADDALILP: ADDALIGN: LD B,A CP 33 JR C,ADDALILP LD B,33 EXX SRL D RR E EXX RR D RR E DJNZ ADDALILP RET NC INC E RET NZ INC D RET NZ EXX INC DE EXX RET ;NEVER CARRIES BECAUSE BIT 7 STARTS AS 0 ;CP BITS TO ROTATE (EXP DIFF) ;JR IF LESSER WON'T BE SHIFTED TO ZERO ;ENSURE DE'DE IS ROTATED TO ZERO ;MSW ;LSW ;LOOP UNTIL NUMBERS ALIGNED FOR COMMON EXP. B=0 ;RET IF NO NEED TO ROUND UP: ALWAYS TRUE IF ZERO

;MULT/DIV/ADD SR ;ENTRY: HL PTS TO FIRST OF TWO NUMBERS, DE TO SECOND. THEY ARE UNSTACKED TO: ;D'E'DE=(N1 MANTISSA) H'L'HL AND A'B'C'A=(N2 MANTISSA) B/C=(N1/N2 EXP) ;(SP)=SGN OF RESULT (BIT 7). D' AND H' HAVE TRUE NUMERIC BITS SET 13 1A 46 23 AE D1 F5 D5 56 CBFA 23 5E 23 D5 56 23 5E 23 4E 23 08 7E F680 08 23 7E 23 D9 47 6F 08 67 08 D9 7E 23 D9 4F D1 D9 6E 67 MUDIADSR: INC DE LD A,(DE) LD B,(HL) INC HL XOR (HL) POP DE PUSH AF PUSH DE LD D,(HL) SET 7,D INC HL LD E,(HL) INC HL PUSH DE LD D,(HL) INC HL LD E,(HL) INC HL LD C,(HL) INC HL EX AF,AF' LD A,(HL) OR 80H EX AF,AF' INC HL LD A,(HL) INC HL EXX LD B,A LD L,A EX AF,AF' LD H,A EX AF,AF' EXX LD A,(HL) INC HL EXX LD C,A POP DE EXX LD L,(HL) LD H,A ;BC'=N2 MANT 2 AND 3 ;DE'=N1 MANT 1 AND 2 ;L=N2 MANT 4 ;H=N2 MANT 3 ;N2 SGN ;N1 EXP ;PT TO N1 SGN ;BIT 7 IS XORED SGN BITS - UNLIKE=1 ;RET ADDR ;RET ADDR ;N1 MANT 1 ;TRUE NUMERIC BIT SET ;N1 MANT 1 AND 2 ;DE=N1 MANT 3 AND 4 ;BC=N1/N2 EXP ;A'=N2 MANT 1

;B'=N2 MANT 2 ;L'=N2 MANT 2 ALSO ;H'=N2 MANT 1

CE37 CE38 CE39 CE39 CE39 CE39 CE39 CE39 CE3C CE3D CE3D CE3E CE3E CE3E CE3E CE3E CE3F CE40 CE42 CE42 CE43 CE44 CE45 CE47 CE48 CE48 CE49 CE4A CE4B CE4C CE4D CE4E CE4F CE50 CE51 CE52 CE52 CE53 CE56 CE57 CE58 CE59 CE5A CE5B CE5C CE5D CE5E CE60 CE61 CE63 CE63 CE64 CE66 CE66 CE68 CE6A CE6A CE6B CE6B CE6D CE6E CE70 CE70 CE72 CE73 CE75 CE76 CE77 CE78 CE79 CE7A CE7B CE7D CE7E CE7F CE80 CE80 CE81 CE82 CE83 CE84 CE84 CE84 CE84 CE84 CE84 CE84 CE85 CE85 CE86 CE88 CE8C CE8D CE90 CE91 CE92 CE93 CE93 CE96 CE97 CE97 CE97 CE9A

7D C9

LD A,L RET

;A=N2 MANT 4

;DOUBLE FPFORM. EQU TO EX DE,HL:CALL FPFORM:EX AF,AF':EX DE,HL: JP FPFORM ;EXIT: NUMBER AT HL AND NUMBER AT DE ARE IN FP FORM. F'=Z IF DE NUMBER IS ;A POWER OF TWO, Z IF HL NUMBER IS. CD3DCE 08 EB DFPFORM: FPFORMX: CALL FPFORMX EX AF,AF' EX DE,HL

;CHANGE NUMBER AT (HL) TO FP FORM IF NEEDED ;EXIT: HL AND DE UNCHANGED, A, BC CORRUPT, Z IF NUMBER IS A POWER OF 2, CY IF 0 7E A7 2810 23 7E 2B E67F C0 E5 23 23 B6 23 B6 23 B6 E1 C9 D5 CDDCCB AF 23 77 2B 77 2B 2B 7A 0E90 A7 2008 B3 281A 1E00 0E89 0D CB13 17 30FA CB16 1F CB1B 77 23 73 2B 2B 71 E67F B3 D1 C9 2B D1 37 C9 FPFORM4: FPFORMLP: FPFORM3: FPFORM2: FPFORM: LD A,(HL) AND A JR Z,FPFORM2 INC HL LD A,(HL) DEC HL AND 7FH RET NZ PUSH HL INC HL INC HL OR (HL) INC HL OR (HL) INC HL OR (HL) POP HL RET PUSH DE CALL FETCHI XOR A INC HL LD (HL),A DEC HL LD (HL),A DEC HL DEC HL LD A,D LD C,90H AND A JR NZ,FPFORM3 OR E JR Z,FPFORM4 LD E,0 LD C,89H DEC C RL E RLA JR NC,FPFORMLP RL (HL) RRA RR E LD (HL),A INC HL LD (HL),E DEC HL DEC HL LD (HL),C AND 7FH OR E POP DE RET DEC HL POP DE SCF RET ;NC INITIALLY AND LATER... ;SHIFT INTEGER TILL IT OVERFLOWS ON THE LHS ;SGN TO CY ;ROT. SGN BIT INTO AB - REPLACES TRUE NUMERIC BIT ;JR IF INTEGER

;TEST MANT 1, IGNORING SGN BIT ;RET IF NOT A POWER OF TWO ;NOW DO A LONGER TEST FOR POWERS OF 2. OTHER MANT ;BYTES MUST BE ZERO ;TEST MANT 2 ;MANT 3 ;MANT 4 ;Z MEANS NUMBER IS AN EXACT POWER OF TWO ;INTEGER IN DE, HL PTS TO MANT 3 ;MANT 4 ;MANT 3 AND 4 WILL BE ZERO ;PT TO MANT 1 ;JR IF INT IS >8 BITS ;RET IF INT IS ZERO. ELSE A=E ;LS PART OF NUMBER ;INIT EXP

;PLACE EXPONENT ;IGNORE SGN BIT ;Z IF POWER OF TWO

;'ZERO'

INCLUDE ROM1FNS.SAM ;POINT ;ROM1FNS.SAM. CODE, LEN, INKEY$, BUTTON, SVAR, CHR$, BIN$, HEX$, MEM$, STR$, ;CONCAT, SQR, ABS, NEGATE, SGN, INT, TRUNCATE, ATTR, POINT ;******************************************************************************* 3E AF DDE5 ED4B955A C5 2A975A E5 A7 F5 CDDC3F 03 CD4D3F ; FPVAL: FPVALS: DB 3EH XOR A PUSH IX LD BC,(CHADP-1) PUSH BC LD HL,(CHAD) PUSH HL AND A PUSH AF ; CALL UNSTKPRT CALL GETSTRING INC BC ; LD (BCSTORE),BC CALL R1OFFCL CALL SCOPYWK ; DEC HL ;'LD A,0AFH' ;** BUG FIX ;B=CHADP

;A=0 IF VAL$, NZ IF VAL ;DE=START, BC=LEN, A=PORT ;LEN OF AT LEAST 1; ROOM FOR TERMINATOR ;** ;COPY STRING PLUS 1 BYTE OF JUNK TO WKSPACE ;TERMINATE WITH 0DH

CE9A CE9A CE9E CEA0 CEA3 CEA4 CEA7 CEA9 CEAA CEAD CEAE CEB1 CEB3 CEB6 CEB7 CEB8 CEBA CEBC CEBC CEBD CEBE CEC0 CEC0 CEC1 CEC3 CEC3 CEC4 CEC6 CEC6 CEC9 CECC CECE CED1 CED2 CED5 CED6 CED9 CEDC CEDE CEDE CEE2 CEE3 CEE3 CEE4 CEE5 CEE5 CEE6 CEE7 CEE8 CEE8 CEE9 CEEA CEEB CEEB CEEC CEED CEEF CEEF CEF2 CEF2 CEF3 CEF4 CEF4 CEF6 CEF6 CEF6 CEF7 CEFA CEFC CEFC CEFE CF01 CF03 CF04 CF05 CF06 CF07 CF08 CF0A CF0B CF0C CF0E CF10 CF10 CF11 CF11 CF14 CF17 CF17 CF18 CF19 CF1A CF1A CF1B CF1D CF1F CF1F CF20 CF20 CF21 CF23 CF24 CF24

; ED53975A DBFB 32965A D5 CD0102 7538 E1 22975A E5 213B5C CBBE CD083B 08 7E FE0D 2027 E1 F1 2003 08 2803 08 281D 22975A 213B5C CBFE CDE314 E1 22975A F1 32965A CDDF3F DDE1 ED5B655C C9 CF 1D CF 8B 21 CF 8C 21 CF 8D 1805 CD143B CF 8E 18E8 E7 CDC63A 3024 0600 2A765C 1EFD 55 7C 29 98 EB ED52 98 4F ED42 3001 23 22765C CDD61C EF 31 33 7E D610 3801 77 DF FE28 C0 CDC03A IMRND4: IMRND1: SUDH: IMRND: FPVAL2: FPVALOK:

LD (HL),0DH LD (CHAD),DE IN A,(URPORT) LD (CHADP),A PUSH DE CALL R1OFFCL DW TOKDE POP HL LD (CHAD),HL PUSH HL LD HL,FLAGS RES 7,(HL) CALL EXPTEXPR EX AF,AF' LD A,(HL) CP 0DH JR NZ,VALNONS POP HL POP AF JR NZ,FPVAL2 EX AF,AF' JR Z,FPVALOK EX AF,AF' JR Z,VALNONS LD (CHAD),HL LD HL,FLAGS SET 7,(HL) CALL SCANNING POP HL LD (CHAD),HL POP AF LD (CHADP),A CALL SELURPG POP IX LD DE,(STKEND) RET RST 08H DB 29 RST 08H DB DVHK DB 21H RST 08H DB EOFHK DB 21H RST 08H DB PTRHK JR SUDH CALL SABORTER RST 08H DB PATHHK JR SETUPDE RST 20H CALL RUNFLG JR NC,IMRND4 LD B,0 LD HL,(SEED) LD E,0FDH LD D,L LD A,H ADD HL,HL SBC A,B EX DE,HL SBC HL,DE SBC A,B LD C,A SBC HL,BC JR NC,IMRND1 INC HL LD (SEED),HL CALL STACKHL DB CALC DB RESTACK DB EXIT LD A,(HL) SUB 10H JR C,IMRND4 LD (HL),A RST 18H CP "(" RET NZ CALL SEX1NUMCB

;TERMINATE STRING COPY IN WKSPACE

;TOKENISE FROM DE ON

;'SYNTAX CHECK' SO FP FORMS INSERTED ;RETURN WITH Z FOR STRING, NZ FOR NUM. ;TERMINATOR ;CHECK FOR TERMINATOR ;STRING START IN WKSPACE ;VAL/VAL$ FLAG ;JR IF VAL ;IF VAL$, STRING RESULT IS OK. ELSE EX AF, AF' ;GIVES Z, THEN ERROR ;IF VAL, STRING EXPR IS AN ERROR ;'RUNNING' ;GET EXPR TO FPC STACK ;ORIGINAL CHAD ;** BUG FIX

SETUPDE: VALNONS: FPDVAR: FPEOF: FPPTR: IMPATHS:

;LET DOS STACK ADDR OF ITS VARS ;'JR+2' ;DOS EOF ;'JR+2' ;DOS PTR

;SKIP 'RND' ;JR IF NOT RUNNING

;EXP WILL BE 00 IF ZERO, ELSE 81-90H ;DIVIDE BY 65536 ;LEAVE IT ALONE IF ZERO ;NEW EXP

;SKIP, GET 'N)', PASS CLOSING BRACKET

CF27 CF28 CF28 CF29 CF2A CF2B CF2C CF2D CF2E CF2E CF2E CF2E CF31 CF32 CF32 CF35 CF38 CF3B CF3D CF40 CF40 CF41 CF43 CF43 CF46 CF47 CF49 CF4B CF4B CF4E CF4F CF50 CF51 CF52 CF54 CF56 CF56 CF57 CF58 CF5B CF5D CF5D CF5D CF5D CF60 CF61 CF61 CF64 CF67 CF68 CF69 CF6C CF6D CF6F CF72 CF74 CF76 CF76 CF78 CF7A CF7A CF7C CF7D CF7E CF80 CF81 CF83 CF84 CF85 CF85 CF88 CF89 CF8B CF8B CF8C CF8D CF8E CF8F CF90 CF91 CF91 CF92 CF92 CF93 CF95 CF95 CF97 CF97 CF98 CF9A CF9C CF9E CF9E CF9F CF9F CFA2 CFA4 CFA4 CFA4 CFA4 CFA4 CFA5 CFA8

D0 EF E9 01 00 30 34 ;ATTR(L,C) CDAE3A D0 212018 CDA4CF 3A405A FE02 D29B12 A7 2808 CDD03D 7A C620 180B CDE43D 7A 0F 0F 0F E603 F698 57 EB CDBB3F 1842 CDAE3A D0 CD9327 CD213E 3C 47 CDBB3F 5F 1601 3A405A FE02 381B 160F 201D 1603 7B 17 CB1B AB E6AA AB 5F 3A4D5A A7 200C 78 3D A2 3C 87 47 7B 07 10FD 1807 7B 0604 CB41 28F4 A2 CDC63F 1845 M3POINT: DPOINTC: POINLP: DOATT2: IMATTR:

RET NC DB DB DB DB DB DB CALC STKONE ADDN MULT TRUNC EXIT2

;RET IF NOT RUNNING ;RND,PARAM ;RND,P,1 ;RND,P+1 ;RND*(P+1) ;EXIT WITH INTEGER BETWEEN 0 AND PARAM ;CHECK (X,Y). CY IF RUNNING ;LINE/COL LIMITS (PLUS 1) ;GET CHAR POSITION WITHIN LIMITS, IN DE ;INVALID MODE UNLESS 0 OR 1 ;JR IF MODE 0 ;GET CHAR ADDR ;GET ATTR ADDR (ADD 8K)

CALL EXB2NUMB RET NC LD HL,1820H CALL GETCP LD A,(MODE) CP 2 JP NC,INVMERR AND A JR Z,DOATT2 CALL M1DEADDR LD A,D ADD A,20H JR DOATT3 CALL M0DEADDR LD A,D RRCA RRCA RRCA AND 03H OR 98H LD D,A EX DE,HL CALL SREAD JR POATC CALL EXB2NUMB RET NC CALL GTFCOORDS CALL ANYPIXAD INC A LD B,A CALL SREAD LD E,A LD D,01H LD A,(MODE) CP 2 JR C,DPOINTC LD D,0FH JR NZ,M3POINT LD D,3 LD A,E RLA RR E XOR E AND 0AAH XOR E LD E,A LD A,(THFATT) AND A JR NZ,M3POINT LD A,B DEC A AND D INC A ADD A,A LD B,A LD A,E RLCA DJNZ POINLP JR M3ODPT LD A,E LD B,4 BIT 0,C JR Z,POINLP AND D CALL RCURP JR STKAB

;FORM ATTR ADDR IN AE

DOATT3:

;POINT(X,Y) IMPOINT: ;CHECK (X,Y). CY IF RUNNING ;GET COORDS IN B,C OR B,HL (THIN) AND CY ;GET ADDRESS IN HL, PIXEL OFFSET IN A ;B=X MOD 8+1 ;E=SCREEN BYTE ;MODE 0/1 MASK ;JR IF MODE 0/1 ;MODE 3 MASK ;JR IF MODE 3 ;MODE 2 MASK

;SWAP ODD/EVEN BITS IN MODE 2 ;DO MODE 3 POINT IF FATPIX 1 ;AND 3 ;IF THIN PIX, A=2/4/6/8 FOR PIX 0/1/2/3

;SEE IF X IS ODD

M3ODPT: POATC:

;ATTR OR POINT

;GET CHAR POSITION LESS THAN LIMITS H/L (LINE/COL) IN DE (LINE/COL) E5 CD331D E1 GETCP: PUSH HL CALL GETBYTE POP HL ;LINE/COL MAX ;COL

CFA9 CFAA CFAC CFAC CFAD CFAE CFB1 CFB2 CFB3 CFB4 CFB5 CFB6 CFB6 CFB7 CFB8 CFB8 CFB8 CFB8 CFB8 CFB8 CFBB CFBE CFBE CFC1 CFC2 CFC5 CFC8 CFC9 CFCA CFCD CFCE CFCE CFCF CFD1 CFD1 CFD2 CFD4 CFD4 CFD4 CFD4 CFD4 CFD7 CFDA CFDC CFDE CFE0 CFE0 CFE1 CFE1 CFE4 CFE5 CFE7 CFE7 CFE9 CFE9 CFEC CFEC CFEC CFEC CFED CFEE CFF0 CFF1 CFF2 CFF2 CFF2 CFF2 CFF2 CFF5 CFF6 CFF6 CFF9 CFF9 CFFC CFFD CFFE CFFF D002 D002 D002 D002 D002 D002 D005 D006 D007 D009 D00A D00C D00C D00E D00E D011 D012 D012 D013 D015 D017 D01A D01C D01C D01F D01F

BD 300A C5 E5 CD331D E1 D1 57 BC D8 CF 20 OSERR:

CP L JR NC,OSERR PUSH BC PUSH HL CALL GETBYTE POP HL POP DE LD D,A CP H RET C RST 08H DB 32 ;LINE

;'Off screen'

;******************************************************************************* ;INKEY$ #N 111E11 CD621F 2A515C E5 CD6311 CDBA01 E1 F5 CD7011 F1 57 3825 AF 1815 FPINKEN: FPINKEY: LD DE,1100H+30 CALL LIMBYTE LD HL,(CURCHL) PUSH HL CALL SETSTRM CALL INPUTAD POP HL PUSH AF CALL CHANFLAG POP AF LD D,A JR C,CHRINKC XOR A JR STKAB ;LIMIT <17

;SET STREAM 'A' ;SCAN INPUT STREAM WITHOUT WAITING ;PREV. CHANNEL ;INKEY VALUE ;RESTORE ORIG CHANNEL ;IF GOT KEY, D=BYTE. COPY TO WKSPACE ;IF NO INPUT - NULL STRING

;MOUSE BUTTON N (1/2/3) RETURNS 1 IF PRESSED, 0 IF NOT 111E04 CD621F FE03 DEFF 2001 2F 218F5B A6 2802 3E01 C3DA1C EF 2A 44FE 01 34 STKAB: FPSVAR: FPBT2: FPBUTTON: LD DE,0400H+30 CALL LIMBYTE CP 3 SBC A,0FFH JR NZ,FPBT2 CPL LD HL,BUTSTAT AND (HL) JR Z,STKAB LD A,1 JP STACKA DB DB DW DB DB CALC LKADDRW VVAR2 ADDN EXIT2 ;SVAR JUST ADDS BASE ADDR OF SYSTEM VARS TO ARGUMENT ;LIMIT TO 0-3 ;CY IF 0/1/2, NC IF 3 ;00,01,02,04 ;'BUTTON 0' TEST ALL 3 ;HAS BITS 2-0 SET FOR BUTTONS 3-1

;******************************************************************************* ;CHR$ - CREATE 1 CHAR STRING IN WKSPACE, PARAMS ON FPCS CD331D 55 010100 21C95A 73 2B 72 C3673C FPCHRS: CHRINKC: INKYEN: CALL GETBYTE LD D,L LD BC,1 LD HL,TEMPW1+1 LD (HL),E DEC HL LD (HL),D JP CWKSTK ;B=0, L=BYTE ;LEN=1

;COPY BC FROM (HL) TO WKSPACE, PARAMS TO FPCS ;EXITS WITH DE=STKEND

;******************************************************************************* ;BIN$ N. RETURN BINARY STRING 8 OR 16 DIGITS LONG CD2E1D EB 7A 0E08 A7 2802 0E10 213151 41 2B CB3A CB1B 3A035A 3803 3A045A 77 BINS4: BINS2: BINSLP: FPBINS: CALL GETINT EX DE,HL LD A,D LD C,8 AND A JR Z,BINS2 LD C,16 LD HL,MEMVAL+16 LD B,C DEC HL SRL D RR E LD A,(BIN1DIG) JR C,BINS4 LD A,(BIN0DIG) LD (HL),A ;INT IN DE ;ASSUME LEN 8 FOR RESULT STRING ;USE 16 IF NEEDED ;GET HL POINTING TEMP $ BUFFER IN MEMS

;SHIFT LS BITS OUT FIRST ;LEAVE IT IF CY

D020 D022 D022 D025 D025 D025 D025 D025 D028 D029 D02A D02B D02C D02E D02F D030 D032 D033 D035 D035 D036 D038 D03A D03A D03B D03C D03D D03E D041 D042 D043 D043 D046 D046 D047 D04A D04B D04D D050 D051 D051 D052 D053 D054 D056 D056 D058 D058 D058 D058 D058 D059 D05A D05B D05D D05E D05F D060 D061 D062 D062 D064 D066 D068 D069 D06A D06B D06C D06E D06E D06F D06F D06F D06F D06F D070 D071 D072 D073 D074 D075 D076 D077 D078 D079 D079 D07A D07B D07B D07C D07D D07D D080 D082 D083 D084 D085 D088 D089 D08A D08D D08D D08D

10F0 C3673C BCWKHP:

DJNZ BINSLP JP CWKSTK ;HL=START, BC=LEN ;COPY BC FROM (HL) TO WKSPACE, PARAMS TO FPCS ;******************************************************************************* ;HEX$ N. RETURN HEX VERSION OF N, 2, 4 OR 6 DIGITS LONG, ACCORDING TO MAGNITUDE

CD8C3F 0F 0F 67 A8 E6C0 A8 47 1E00 B4 2811 7C E60F 2809 08 78 08 47 CD58D0 08 47 CD58D0 41 CD58D0 4B 0600 212751 41 2B F1 77 10FB 18CA

FPHEXS:

CALL UNSTLEN RRCA RRCA LD H,A XOR B AND 0C0H XOR B LD B,A LD E,0 OR H JR Z,HEX2DIG LD A,H AND 0FH JR Z,HEX4DIG EX AF,AF' LD A,B EX AF,AF' LD B,A CALL HEXASCSR EX AF,AF' LD B,A

;ABC=PAGE/'ADDR' ** ;LS 2 BITS TO POSN 7,6

;HBC=20-BIT NUMBER ;INIT DIGIT COUNTER ;JR IF MS 2 BYTES (OF 3)=0 ;JR IF MSB=0 ;SAVE MIDDLE BYTE IN A' ;B=MS BYTE ;MIDDLE BYTE ;DERIVE 2 DIGITS FROM B, STACK THEM ;LS BYTE ;TEMP BUFFER ;UNSTACK AN ASCII DIGIT ;HL=START-1, BC=LEN ;STACK STRING FROM HL ON FPCS

HEX4DIG: HEX2DIG:

CALL HEXASCSR LD B,C CALL HEXASCSR LD C,E LD B,0 LD HL,MEMVAL+6 LD B,C DEC HL POP AF LD (HL),A DJNZ HEXPUTLP JR BCWKHP

HEXPUTLP:

;HEX$ ASCII SR TO CONVERT VALUE IN B TO 2 ASCII HEX DIGITS ON STACK 1C 1C 78 1602 E1 0F 0F 0F 0F E60F FE0A DE69 27 F5 78 15 20F4 E9 HEXASCSR: INC E INC E LD A,B LD D,2 POP HL RRCA RRCA RRCA RRCA AND 0FH CP 0AH SBC A,69H DAA PUSH AF LD A,B DEC D JR NZ,HEXSRLP JP (HL) ;COUNT OF DIGITS ON STACK=COUNT+2 ;2 DIGITS ;RET ADDR ;MS NIBBLE FIRST

HEXSRLP:

; ;A STRANGE TWIDDLE THAT GIVES THE RIGHT ANSWER! ;SAVE ASCII 0-9, A-F

;RETURN

;******************************************************************************* ;PT 2 OF MEMORY$ EF 06 D0 03 E9 01 25 2C 1F 03 07 E1 D8 33 CD8C3F CBFC 3D F5 E5 CD2E1D D1 F1 C3EB1C MEMRYSP2: DB DB DB DB DB DB DB DB DB DB CALC SWOP STO0 SUBN STKONE ADDN DUP LESS0 JPFALSE 03H ;N2,N1 ;N2-N1 ;ALLOW FOR INCLUSIVE CHAR. ;LEN ;LEN, 1/0 ;JP IF LEN <0 ;NULL STRING IF LEN <0 ;LEN,N1 ;GET AHL=START ;PAGE FORM ;GET BC=LEN ;ADDR

DB DROP DB STKZERO DB RCL0 DB EXIT CALL UNSTLEN SET 7,H DEC A PUSH AF PUSH HL CALL GETINT POP DE POP AF JP STKSTOS

;******************************************************************************* ;S1+S2. PRODUCE A CONCATENATED STRING IN WKSPACE, PARAMS ON FPCS

D08D D08D D08D D08F D090 D091 D094 D095 D096 D097 D098 D09B D09C D09D D0A0 D0A0 D0A1 D0A2 D0A3 D0A4 D0A5 D0A8 D0AB D0AB D0AC D0AF D0B1 D0B2 D0B3 D0B4 D0B7 D0B8 D0BB D0BC D0BD D0BE D0C1 D0C2 D0C5 D0C5 D0C5 D0C5 D0C5 D0C6 D0C7 D0C8 D0C9 D0C9 D0CA D0CB D0CC D0CE D0D0 D0D0 D0D2 D0D4 D0D4 D0D6 D0D8 D0DA D0DC D0DC D0DE D0E0 D0E0 D0E2 D0E2 D0E4 D0E5 D0E5 D0E6 D0E7 D0EA D0EA D0EC D0EC D0ED D0EE D0EF D0F1 D0F1 D0F2 D0F3 D0F4 D0F5 D0F7 D0F7 D0F9 D0F9 D0FB D0FD D0FD D0FE D0FF D101 D101 D103 D104 D105 D106 D107 D109 D10C

;BINARY - ALTHOUGH ONLY RELEVANT FOR ENTRY DE DBFB F5 D5 CD011D F5 D5 C5 C5 CD011D E1 09 DA283A F5 D5 C5 44 4D CD801E CDE71C C1 CD791F DBFB 4F E1 F1 CD5E2A C1 CD791F D1 E1 37 CD682A D1 C3453C FPCONCAT: IN A,(URPORT) PUSH AF PUSH DE CALL STKFETCH PUSH AF PUSH DE PUSH BC PUSH BC CALL STKFETCH POP HL ADD HL,BC JP C,STLERR PUSH AF PUSH DE PUSH BC LD B,H LD C,L CALL WKROOM CALL STKSTOREP POP BC CALL SPLITBC IN A,(251) LD C,A POP HL POP AF CALL FARLDIR POP BC CALL SPLITBC POP DE POP HL SCF CALL FARLDIR2 POP DE JP PPORT ;S2 PTR WILL BE NEW STKEND ;ADE=S2 START, BC=S2 LEN ;S2 LEN ;S2 LEN ;TOTAL LEN ;** BUG FIX ;PAGE OF S1 ;START OF S1 ;LEN OF S1 ;BC=TOTAL LEN ;GET DE=START, BC=TOTAL LEN, PAGED IN ;PARAMS OF STRING TO BE CREATED TO FPCS ;LEN OF S1 ;SET UP PAGCOUNT/MODCOUNT ;DEST=CDE ;START OF S1 ;PAGE OF S1 ;LEN OF S2 ;START OF S2 ;H=PAGE OF S2 ;ENTRY PT 2 BECAUSE TEMPW1 AND TEMPB2 = DEST ;NEW STKEND

;AMPERSAND-PREFACED HEX, E.G. &FC0D OR &12345 (6 DIGITS OK) ;VALUE EVALUATED DURING SYNTAX CHECK AND INSERTED AS A 5-BYTE FORM. AF 67 6F 08 EB E7 EB D630 3821 FE0A 380E C630 F620 FE61 3815 FE67 3011 D657 0604 08 29 17 DAD117 10F9 08 B5 6F 18D8 44 4D 08 A7 283A 0698 CB7F 2004 29 17 10F8 E67F 5F 54 4D 78 0600 C3F01C AMPFP: AMPALLP: AMPEND: AMPVALID: AMPERLP: AMPERSAND: XOR A LD H,A LD L,A EX AF,AF' AMPDILP: EX DE,HL RST 20H EX DE,HL SUB 30H JR C,AMPEND CP 0AH JR C,AMPVALID ADD A,30H OR 20H CP "a" JR C,AMPEND CP "g" JR NC,AMPEND SUB 57H LD B,4 EX AF,AF' ADD HL,HL RLA JP C,NTLERR DJNZ AMPERLP EX OR LD JR AF,AF' L L,A AMPDILP ;ADD IN NEW HEX DIGIT ;NUM. TOO LARGE (ONLY SEE MSG WITH EG VAL("&"+A$)) ;a-f->0A-0F ;INIT RESULT TO ZERO ; IN A'HL ;HL=RESULT ;NUMS NOW 00-09, LETS 11-2A, 31-4A ;JR IF DIGIT ;LETS NOW 61-7A

LD B,H LD C,L EX AF,AF' AND A JR Z,STACKBCH LD B,98H BIT 7,A JR NZ,AMPFP ADD HL,HL RLA DJNZ AMPALLP AND 7FH LD E,A LD D,H LD C,L LD A,B LD B,0 JP STKSTORE

;JR IF SMALL INTEGER ;EXP FOR FF FF FF

;ALIGN MANTISSA IN AHL ;B NEVER HITS ZERO! ;+VE SIGN BIT ;EXP ;FP NUM IN A E D C B

D10C D10F D111 D111 D114 D116 D116 D116 D119 D11A D11B D11D D11D D11D D11F D120 D123 D124 D127 D128 D129 D129 D12A D12D D12E D12F D12F D131 D131 D134 D134 D134 D134 D134 D134 D134 D137 D137 D138 D139 D13A D13C D13C D13D D13E D140 D140 D141 D143 D143 D145 D145 D145 D148 D148 D148 D148 D149 D14C D14C D14C D14C D14E D14F D152 D153 D154 D156 D156 D157 D158 D15A D15A D15B D15D D15D D15D D15D D15D D160 D162 D162 D162 D162 D163 D164 D165 D166 D166 D167 D168 D169 D169 D16B D16C D16D D16E D16F D170 D173 D173 D175 D177

CDFA01 F717 CDFA01 FB17 CD6F12 57 AF 180C DBFB F5 CD9F3F 23 CD5602 2B D1 47 CD5602 4F 7A D3FB C3DD1C

FPUSRS: FPUSR: ;UNARY FPPEEK:

CALL R1OFFJP DW R0USRS CALL R1OFFJP DW R0USR CALL PDPSUBR LD D,A XOR A JR FPPDPC IN A,(URPORT) PUSH AF CALL NPDPS INC HL CALL R1OFRD DEC HL POP DE LD B,A CALL R1OFRD LD C,A LD A,D OUT (251),A JP STACKBC

;JP TO MAIN ROUTINE IN ROM 0 WITH ROM1 OFF

;GET HL=ADDR (PAGED IN), A=ORIG URPORT

;UNARY FPDPEEK:

;GET HL=ADDR

FPPDPC:

OSBC: STACKBCH:

;******************************************************************************* ;TRUNC$ - RETURN STRING STRIPPED OF TRAILING SPACES (E.G. FROM ARRAYS) ; E.G. LET A$=TRUNC$ B$(34) ;ENTRY WITH STRING ON FPCS CDE43E 62 6B 09 3E20 2B BE 2008 0D 20F9 18EC CD97D9 EB C3673C DBFB F5 CDDC3F 78 B1 2804 1A 4F 0600 F1 18D2 FPCODE2: ;STR$ FPSTRS: FPSTRS2: TRUNCSLP: FPTRUSTR: CALL SBUFFET LD H,D LD L,E ADD HL,BC LD A," " DEC HL CP (HL) JR NZ,FPSTRS2 DEC C JR NZ,TRUNCSLP JR STACKBCH CALL PFSTRS EX DE,HL JP CWKSTK IN A,(251) PUSH AF CALL GETSTRING LD A,B OR C JR Z,FPCODE2 LD A,(DE) LD C,A LD B,0 POP AF JR OSBC ;GET NUMBER AS BC DIGITS AT (DE) IN COMMON MEM ;DE=START, A AND BC=LEN, PAGING UNCHANGED ;LEN 1-255 ;PT PAST END OF STRING

;JR WITH DE=START, BC=LEN ;TRUNC$ OF ALL-SPACES STRING=NULL STRING

;FROM TRUNC$

;CODE RETURNS ASCII CODE OF FIRST CHAR OF STRING ON FPCS, OR 0 IF STRING IS NULL FPCODE: ;UNSTACK STRING. DE=START, BC=LEN, PAGED IN ;JR IF NUL STRING

;LEN RETURNS STRING LENGTH CD011D 18CF EF 31 D0 33 7E A7 C8 C680 1F 77 23 7E 17 DAE83E 367F 0605 FPLEN: CALL STKFETCH JR STACKBCH DB DB DB DB CALC RESTACK STO0 EXIT ;BC=LEN, NO PAGING

;SQUARE ROOT (W.E. THOMSON) FPSQR: ;USE FULL F.P. FORMS

LD A,(HL) AND A RET Z ADD A,80H RRA LD (HL),A INC HL LD A,(HL) RLA JP C,INVARG LD (HL),7FH LD B,5

;RET IF SQR(0) WITH ZERO ON FPCS, DE=STKEND ;GET TRUE EXPONENT. CY IF WAS >=80H ;/2, WITH BIT 7 AS ORIGINAL ;FETCH SGN BIT ;ERROR IF SQR OF -VE NUMBER ;MANTISSA STARTS AT ABOUT ONE ;5 ITERATIONS

D177 D178 D179 D17A D17B D17C D17D D17E D17E D17F D181 D181 D182 D182 D182 D182 D182 D183 D184 D185 D187 D187 D188 D189 D18A D18A D18C D18C D18E D18F D18F D18F D18F D18F D18F D190 D191 D192 D194 D194 D195 D196 D197 D198 D199 D199 D19A D19B D19C D19D D19D D19E D19F D1A0 D1A1 D1A2 D1A3 D1A4 D1A5 D1A6 D1A7 D1A8 D1A9 D1AA D1AB D1AB D1AD D1AE D1AF D1B0 D1B0 D1B0 D1B0 D1B0 D1B3 D1B4 D1B5 D1B5 D1B6 D1B7 D1B8 D1B9 D1BA D1BA D1BB D1BC D1BF D1C2 D1C2 D1C2 D1C2 D1C2 D1C2 D1C3 D1C4 D1C5 D1C5 D1C6 D1C7 D1C8 D1C9 D1CA D1CA

EF 25 D8 06 05 01 33 35 10F6 C9

SQURLP:

DB DB DB DB DB DB DB

CALC DUP RCL0 SWOP DIVN ADDN EXIT

;X,X ;X,X,N ;X,N,X ;X,N/X ;X+N/X ;DEC EXPONENT (HALVE VALUE) ;DE=STKEND

DEC (HL) DJNZ SQURLP RET

;******************************************************************************* ;ABS FPCS TOP ENTRY - UNARY FPCS FUNCTION. 7E 23 A7 2005 7E 3C C0 1811 CBBE C9 FPABS2: FPABS: LD A,(HL) INC HL AND A JR NZ,FPABS2 LD A,(HL) INC A RET NZ JR NEGABSC RES 7,(HL) RET ;SIGN=POS.

;JR IF FP ;SGN BYTE ;RET IF SIGN WAS 0 (+VE), OK ;ELSE SIGN WAS FF, NOW A=0

;******************************************************************************* ;NEGATE FPCS TOP ENTRY. UNARY FPCS FUNCTION. 7E 23 A7 2017 23 B6 23 B6 C8 2B 2B 7E 2F 77 23 7E 2F 4F 23 7E 2F 47 03 70 2B 71 C9 3E80 AE 77 C9 NEGABSC: FPNEGAT: LD A,(HL) INC HL AND A JR NZ,FPNEGAT2 INC HL OR (HL) INC HL OR (HL) RET Z DEC HL DEC HL LD A,(HL) CPL LD (HL),A INC HL LD A,(HL) CPL LD C,A INC HL LD A,(HL) CPL LD B,A INC BC LD (HL),B DEC HL LD (HL),C RET LD A,80H XOR (HL) LD (HL),A RET

;JR IF FP

;TEST FOR INTEGER=0 ;DO NOTHING IF SO ;SGN ;REVERSE SIGN (OR MAKE +VE IF ABS)

;NEGATE INTEGER ;LOAD IT BACK ;REVERSE SIGN BIT

FPNEGAT2:

;******************************************************************************* ;RETURN SGN N1 (-1, 0 OR 1). UNARY CD52C9 EB C8 D5 23 7E 17 2B 9F 4F 110100 C3C8CB FPSGN: CALL TSTZERO2 EX DE,HL RET Z PUSH DE INC HL LD A,(HL) RLA DEC HL SBC A,A LD C,A LD DE,0001H JP STOREI ;-VE=FF, +VE=00 ;STORE SIGNED INTEGER, POP DE, RET ;SGN ZERO=0

;******************************************************************************* ;INT - EQUIVALENT TO TRUNCATE (ZERO BITS AFTER BINARY POINT) IF +VE ;FOR -VE, TRUNC E.G. -5.9=-5.0, SO SUB 1 TO GET -6.9 -> 6.0 7E A7 C8 EF 25 2E 1E 0B 25 FPINT: LD A,(HL) AND A RET Z DB DB DB DB DB CALC DUP GRTR0 JPTRUE 0BH ;RET IF INTEGER ALREADY (OR ZERO) ;N1,N1 ;N1,(0 OR 1) ;JP IF +VE, FPINTP ;** BUG FIX ;N,N

DB DUP

D1CB D1CC D1CD D1CE D1CF D1D0 D1D1 D1D1 D1D2 D1D3 D1D4 D1D4 D1D5 D1D6 D1D6 D1D6 D1D6 D1D6 D1D6 D1D7 D1D8 D1D9 D1D9 D1DB D1DD D1DF D1DF D1E1 D1E3 D1E3 D1E4 D1E5 D1E6 D1E7 D1E8 D1E9 D1EA D1EC D1EE D1F0 D1F0 D1F2 D1F3 D1F3 D1F4 D1F6 D1F7 D1F8 D1FA D1FA D1FB D1FD D1FE D1FE D200 D200 D201 D201 D203 D205 D207 D207 D20A D20A D20C D20D D20D D20E D20F D210 D210 D210 D210 D212 D212 D213 D214 D215 D215 D217 D217 D218 D219 D21B D21B D21C D21E D21E D21F D220 D220 D221 D223 D223 D224 D225 D225 D226 D227 D228 D228 D228 D228

30 25 1C 03 1F 03 E9 03 34 30 34 FPINTP:

DB DB DB DB DB DB

TRUNC DUP SWOP13 SUBN JPFALSE 03H

;N,TRUNC N ;N,TRUNC N,TRUNC N ;TRUNC N,TRUNC N,N ;TRUNC N,0 IF N WAS A WHOLE NUMBER ;TRUNC N. JP IF VALUE WAS INTEGER, TO EXIT2 ;TRUNC N,1 ;TRUNC N-1 ;INT(N)

DB STKONE DB SUBN DB EXIT2 DB TRUNC DB EXIT2

;******************************************************************************* ;TRUNCATE - ZERO THE BITS AFTER BINARY POINT, FORCE INTEGER FORM IF POSSIBLE. ;UNARY 7E A7 C8 0608 FE81 3831 FE91 3027 D5 23 56 23 5E 2B 2B 0EFF CB7A 2003 CBFA 0C 2F C691 90 80 3804 5A 1600 90 2807 47 CB3A CB1B 10FA C3C8CB C660 F0 2F 3C 22 ;NIL-BYTES. 3E28 D5 EB 22 3600 2B 90 30FA 80 2807 47 9F 87 10FD A6 77 EB D1 C9 NILBYEND: NILBMASK: TRUNC0: NILBYTES: NILBYLP: NILBYT2: LD A,28H PUSH DE EX DE,HL DB 22H LD (HL),0 DEC HL SUB B JR NC,NILBYLP ADD A,B JR Z,NILBYEND LD B,A SBC A,A ADD A,A DJNZ NILBMASK AND (HL) LD (HL),A EX DE,HL POP DE RET ;B=8 ;CY SET ;A=FF ;MASK FOR RHS BITS PRODUCED ;DO THE MASKING ;ZERO 40 BITS - ALL OF THEM! ;PT TO AFTER LAST BYTE OF NUMBER ;"JR+2" TRUNCI4: TRUNCI5: TRUNCLG: TRUNCI3: TRUNCI2: FPTRUNCT: LD A,(HL) AND A RET Z LD B,8 CP 81H JR C,TRUNC0 CP 91H JR NC,TRUNCLG PUSH DE INC HL LD D,(HL) INC HL LD E,(HL) DEC HL DEC HL LD C,0FFH BIT 7,D JR NZ,TRUNCI2 SET 7,D INC C CPL ADD A,91H SUB B ADD A,B JR C,TRUNCI3 LD E,D LD D,0 SUB B JR Z,TRUNCI5 LD B,A SRL D RR E DJNZ TRUNCI4 JP STOREI ADD A,60H RET P CPL INC A DB 22H ;NEG ;"JR+2" ;RET IF INTEGER ;FOR LATER ;JR IF LESS THAN 1 ;JR IF >=65536

;JR IF -VE WITH C=SIGN BYTE FOR SMALL INTEGER ;TRUE NUMERIC BIT ;SIGN BYTE FOR +VE=0 ;B=8

;******************************************************************************* ;UDG A$. UDG ADDR. E.G. UDG "A". TRANSLATOR CHANGES USR "A" TO UDG "(CHR$ 144)"

D228 D228 D228 D22B D22C D22C D22F D22F D230 D232 D234 D234 D237 D239 D23B D23B D23E D241 D242 D244 D246 D246 D248 D24B D24B D24C D24D D24F D250 D251 D252 D253 D256 D256 D256 D256 D256 D256 D256 D256 D259 D25B D25B D25B D25B D25E D25E D261 D261 D263 D263 D266 D26A D26B D26E D26F D270 D273 D274 D277 D27A D27B D27E D27E D27F D27F D27F D282 D282 D282 D282 D282 D283 D284 D286 D286 D289 D289 D28C D28E D28F D290 D292 D293 D293 D293 D293 D293 D293 D293 D295 D297 D297 D29A D29A D29D D29E D29E D29F D2A2 D2A4 D2A4 D2A5

;UNARY. ENTRY WITH STRING ON FPCS AT (HL) CDE43E 3D C2E83E 1A FE20 38F8 2A365C FE80 3810 2A7B5C 1180FB 19 FEA9 3805 D6A9 2A7D5C EB 6F 2600 29 29 29 19 C3D61C FPUDG3: FPUDG: IAHOP: CALL SBUFFET DEC A JP NZ,INVARG LD A,(DE) CP 20H JR C,IAHOP LD HL,(CHARS) CP 80H JR C,FPUDG3 LD HL,(UDG) LD DE,-144*8 ADD HL,DE CP 169 JR C,FPUDG3 SUB 169 LD HL,(HUDG) EX DE,HL LD L,A LD H,0 ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,DE JP STACKHL ;LEN MUST BE 1 ;READ CHAR FROM BUFFER

;JR IF RANGE 20H-7FH ;ALLOW FOR UDG VAR. POINTING TO CHR$ 144 ;JR IF CHR$ 80H-A8H (LOW UDGS)

;STACK CHAR PATTERN ADDR

INCLUDE SCRSEL1.SAM ;OPEN/CLOSE SCREEN/PAGES, INTS, BOOTEX, SOUND, ;SCRSEL1.SAM. SCREEN, OPEN SCREEN, CLOSE SCREEN, SOUND ;SELECT SCREEN C CD82D2 1806 CD583A CD7FD2 2823 3A785A ED5B9D5C 12 229D5C 7E F5 CDDF3B F1 CDDA3B 3A775A A7 CAAE3B C9 CD331D SCRNTLK1: JSCR2: JSCRN: CALL SCRNTLK2 JR JSCR2 CALL SYNTAX6 CALL SCRNTLK1 JR Z,ISCEH LD A,(CUSCRNP) LD DE,(SCPTR) LD (DE),A LD (SCPTR),HL LD A,(HL) PUSH AF CALL SSVARS POP AF CALL PRSVARS LD A,(CURDISP) AND A JP Z,DEFDISP RET CALL GETBYTE ;GET MODE/PAGE FOR SCREEN C, Z IF UNUSED ;'INVALID SCREEN NUMBER' IF NOT OPEN ;UPDATE SCLIST MODE AS WE SWITCH OUT THIS SCREEN ;SAVE SCREEN VARS TO STORE IN SCREEN PAGE ;COPY VARS FROM SELECTED SCREEN TO SYS VARS

;SCREEN N - PRINT/PLOT ETC ON SCREEN N, DISPLAY PAGE N IF (CURDISP)=0 SCREEN:

;RET - DISPLAY FIXED ON A GIVEN SCREEN ;GET SCREEN NUMBER FROM FPCS

;GET MODE/PAGE FOR SCREEN C FROM LIST. RETURN NZ IF OPEN, Z AND A=FF IF CLOSED ;EXIT WITH HL POINTING TO ENTRY FOR SCREEN. SCREEN NUMBER 1-16 OR ERROR MSG. 0D 79 FE10 D2AC3B 21A05C 0600 09 7E FEFF C9 SCRNTLK2: ISCEH: DEC C LD A,C CP 10H JP NC,ISCRERR LD HL,SCLIST LD B,0 ADD HL,BC LD A,(HL) CP 0FFH RET ;LIMIT SCREENS TO ORIG. OF 1-16

;BIT 7=0, BITS 6-5=MODE, BITS 4-0=PAGE (BIT 0=0) ;Z IF FF (CLOSED)

;******************************************************************************* ;CLOSE SCREEN N ;CLOSE #N ;CLOSE N - CLOSE N PAGES FE23 2022 CD573A CD4011 C8 E5 CD12D4 2804 D1 CF CLSCRN: CP "#" JR NZ,CLNCH CALL SSYNTAX6 CALL STRMINFO RET Z PUSH HL CALL CHLTCHK JR Z,CLOS1 POP DE RST 08H ;JR IF NOT A STREAM CLOSE ;CLOSE #S ;RET IF CLOSED ;OK IF K, S, P, $ OR B ** ;HL=PTR TO LETTER IN CHANNEL, A=LETTER ;STREAM PTR ;CLOSE A NON-K/S/P STREAM.

D2A6 D2A7 D2A8 D2A8 D2AB D2AC D2AE D2B1 D2B1 D2B2 D2B5 D2B6 D2B9 D2B9 D2BB D2BD D2BD D2BD D2BD D2C0 D2C0 D2C3 D2C3 D2C6 D2C7 D2C8 D2C9 D2CA D2CC D2CC D2CD D2CD D2D0 D2D0 D2D1 D2D1 D2D2 D2D3 D2D5 D2D5 D2D6 D2D7 D2DA D2DB D2DB D2DE D2E0 D2E0 D2E3 D2E3 D2E6 D2E6 D2E7 D2E7 D2E8 D2E9 D2EC D2EC D2EE D2EF D2F2 D2F4 D2F5 D2F7 D2F7 D2F8 D2F9 D2F9 D2FB D2FC D2FE D2FF D300 D301 D302 D303 D303 D303 D303 D303 D303 D303 D305 D308 D308 D308 D308 D30B D30E D311 D311 D314 D317 D318 D31A D31A D31D D31F D31F D321 D321 D322 D323

87 C9 110000 79 FE04 D240D3 5F 219002 19 C33FD3 FEE7 2823 CD583A CD00D4 3AB15C 3C 5F 7D 91 3801 BB DA4B3F AF 2B 77 10FC 2B 7D 32B05C C9 CD82D2 1806 CD573A CD7FD2 C8 0C 0D CAAC3B E61F 47 3A785A E61F B8 2002 CF 2E 36FF 68 2651 AF 77 23 77 C9 CNCS: JCS2: CLPL1: SETLPG: OMH: CLTO: CLNCH: CLOS1:

DB CSHK RET LD LD CP JP DE,0 A,C 4 NC,OLT4

;DOS CLOSE. ;VALUE FOR STRM PTR IF CLOSING 4-15

LD E,A LD HL,STRMTAB+5 ADD HL,DE JP OPEN2 CP 0E7H JR Z,CLSC0 CALL SYNTAX6 CALL OCPSR LD A,(RAMTOPP) INC A LD E,A LD A,L SUB C JR C,OMH CP E JP C,OOMERR XOR A DEC HL LD (HL),A DJNZ CLPL1 DEC HL LD A,L LD (LASTPAGE),A RET CALL SCRNTLK2 JR JCS2 CALL SSYNTAX6 CALL SCRNTLK1 RET Z INC C DEC C JP Z,ISCRERR AND 1FH LD B,A LD A,(CUSCRNP) AND 1FH CP B JR NZ,CNCS RST 08H DB 46 LD (HL),0FFH LD L,B LD H,ALLOCT/256 XOR A LD (HL),A INC HL LD (HL),A RET

;PT HL TO INITIAL VALUE FOR STREAMS 0-3 ;SCREENTOK

;CLOSE N PAGES ;NUMBER OF PAGES TO CLOSE ;GET L=PAGES USED NOW, HL PTING TO PAST LAST ;ENTRY IN ALLOCT, B/C=PAGES TO CLOSE ;NO. OF PAGES THAT *MUST* BE USED BY BASIC ;(UNLESS RAMTOP MOVED) ;PAGES THAT WILL BE LEFT AFTER CLOSE

;MUST BE >=MINIMUM NO.

;FREE PAGE

JCLSCR: CLSC0:

;N ;END IF NOT USED YET ;Z IF ORIG SCREEN NUMBER WAS 1 (C=0) ;CANNOT CLOSE SCREEN 1! ;ISOLATE PAGE USED BY SCREEN TO CLOSE

;CANNOT CLOSE CURRENT SCREEN ;'Current screen' ;MARK SCREEN ENTRY AS CLOSED ;HL WILL PT TO ALLOC TABLE ENTRY FOR SCRN PAGE

;******************************************************************************* ;OPEN SCREEN N,M<,C> (NUMBER, MODE) ;OPEN #N,A$ (OPEN A STREAM TO A CHANNEL) ;OPEN N (OPEN A NUMBER OF PAGES FOR USE) FE23 C250D3 CDE33A CD813A CD663A CD8A18 CD4011 E5 2809 CD12D4 2002 3002 CF 2D SAOERR: OPSCRN: CP "#" JP NZ,OPNCH CALL SEXPT1NUM CALL INSISCSC CALL SYNTAXA CALL SWOP12 CALL STRMINFO PUSH HL JR Z,OPEN1 CALL CHLTCHK JR NZ,SAOERR JR NC,OPEN1 RST 08H DB 45 ;JR IF NOT 'OPEN TO A CHANNEL'

;CHECK FOR OPEN #S;A$ OR OPEN #S,A$ ;',/;' ;GIVES NAME,STREAM ;Z IF CLOSED. HL PTS TO STRM PTR MSB ;JR IF CHANNEL IS CLOSED ;ERROR IF NOT OPEN TO K/S/P/$/B/N ALREADY ;JR IF OPEN TO K/S/P, ERROR IF OPEN TO $/B/N ;'Stream is already open'

D323 D326 D329 D329 D32A D32C D32C D32D D32F D332 D334 D334 D335 D336 D338 D338 D339 D33B D33B D33C D33C D33D D33E D33F D33F D340 D340 D341 D343 D344 D345 D346 D346 D348 D34A D34C D34E D350 D350 D352 D354 D354 D354 D354 D356 D358 D358 D35B D35B D35E D35F D362 D363 D364 D364 D366 D366 D369 D36C D36C D36E D371 D372 D372 D372 D372 D375 D375 D378 D378 D378 D379 D37A D37D D37D D37E D380 D380 D381 D384 D384 D386 D387 D389 D389 D38A D38A D38B D38E D390 D390 D390 D390 D393 D393 D396 D399 D39A D39D D39D D39F D39F D3A0

CDEA3E CA5CE0 3D 200F 1A F620 2146D3 0605 BE 23 2807 23 10F9 E1 CF 86 C9 5E E1 3600 2B 73 C9 6B01 7306 7010 2415 621A FEE7 283C FE8E 201A CD573A CD331D 0D 3AB05C 91 C8 3806 CDDA1C C3C0D2 ED44 CDDA1C BF C4583A CD00D4 34 35 C24B3F 23 10F8 41 CDD5D2 3640 2B 10FB C9 C5 CD82D2 180D CD5E3A 112204 CD5F1F F5 CD7FD2 2802 CF 2C

OPEN1:

CALL SBFSR JP Z,IFNER DEC A JR NZ,INVCHP LD OR LD LD A,(DE) 20H HL,CLTAB B,5

;COPY FILE NAME TO BUFFER. DE=START, A/C=LEN ;JP IF LEN ZERO ;ERROR (OR DOS) IF NAME LONGER THAN 1. E.G. ;OPEN #4;"S" IS OK BUT OPEN #4;"FILE" JUMPS ;LETTERS BECOME L.C. AND '$' UNCHANGED ;CHECK 5 CHANNEL TYPES

OPCL:

CP (HL) INC HL JR Z,OPEN2 INC HL DJNZ OPCL

INVCHP:

POP HL RST 08H DB OSHK RET

;PTR TO STREAM PTR MSB ;DE POINTS TO NAME, C=LEN ;OPEN #S,A$ WITH A$ NOT K, S, P, $, OR B OR LEN>1 ;DOS OPEN ;GET DISPLACEMENT FROM TABLE

OPEN2: OLT4:

LD E,(HL) POP HL LD (HL),0 DEC HL LD (HL),E RET DB DB DB DB DB "k",1 "s",6 "p",16 "$",21 "b",26

CLTAB:

OPNCH:

CP 0E7H JR Z,OPSCR0 CP TOTOK JR NZ,NOTP CALL SSYNTAX6 CALL GETBYTE DEC C LD A,(LASTPAGE) SUB C RET Z JR C,TOPO CALL STACKA JP CLTO

; SCREENTOK

;OPEN N PAGES

OR OPEN TO PAGE N

;E.G. OPEN TO 1 DOES NOTHING IF LASTPAGE=0 ;RET IF OPEN TO CORRECT PAGE ALREADY

TOPO:

NEG CALL STACKA CP A CALL NZ,SYNTAX6 CALL OCPSR

;GET PAGES TO OPEN

;OPEN N PAGES - NZ ON ENTRY NOTP: ;NUMBER OF PAGES TO OPEN ;GET HL PTING TO PAST LAST CURRENT PAGE ;ENTRY IN ALLOCT, B/C=PAGES TO CLOSE ;ERROR IF NOT ENOUGH FREE PAGES ABOVE CONTEXT'S ;CURRENT PAGES

OPL1:

INC (HL) DEC (HL) JP NZ,OOMERR INC HL DJNZ OPL1 LD B,C CALL SETLPG

;DEC HL, SET LAST PAGE ;RESERVE PAGE

OPL4:

LD (HL),40H DEC HL DJNZ OPL4 RET PUSH BC CALL SCRNTLK2 JR JOPS2 CALL SSYNTAX8 LD DE,0400H+34 CALL LIMDB PUSH AF CALL SCRNTLK1

JOPSCR:

;MODE IN B ;CHECK SCREEN C

;OPEN SCREEN N,M OPSCR0:

(NUMBER, MODE) ;N,M ;MODE 0-3 FROM ORIG OF 1-4 ;MODE ;GET N FROM FPCS, LOOK IN TABLE FOR SCREEN N ;OK IF NOT USED YET ;'Screen already open'

JOPS2:

JR Z,OPSCR4 RST 08H DB 44

D3A1 D3A1 D3A2 D3A5 D3A5 D3A6 D3A7 D3A8 D3AB D3AB D3AC D3AE D3AE D3AF D3B0 D3B1 D3B1 D3B1 D3B1 D3B1 D3B3 D3B4 D3B6 D3B7 D3B8 D3B9 D3BB D3BC D3BE D3BF D3C0 D3C1 D3C4 D3C7 D3CA D3CB D3CC D3CD D3CE D3CF D3D0 D3D3 D3D4 D3D6 D3D7 D3D8 D3DB D3DB D3DB D3DE D3DF D3E2 D3E5 D3E6 D3E9 D3EA D3EB D3EB D3EC D3EC D3EF D3F2 D3F2 D3F2 D3F2 D3F2 D3F4 D3F7 D3F7 D3F8 D3F9 D3FB D3FC D3FD D3FD D3FF D400 D400 D400 D400 D403 D406 D407 D40A D40A D40B D40C D40E D410 D410 D411 D412 D412 D412 D412 D412 D412 D412 D415 D416 D417 D418 D419

E5 212051 2D 7E 2D CA4B3F B6 20F7 D1 F1 F5

OPSCR4: OPSCRLP:

PUSH HL LD HL,ALLOCT+20H DEC L LD A,(HL) DEC L JP Z,OOMERR OR (HL) JR NZ,OPSCRLP POP DE POP AF PUSH AF

;SCREEN LIST PTR ;HL PTS TO ALLOCT TERMINATOR

;OUT OF MEMORY IF NO SPACE FOR NEW SCREEN ;Z IF 2 PAGES UNUSED (0) ;LOOP UNTIL FOUND A FREE 32K BLOCK, EVEN START PAGE ;SCLIST PTR ;MODE TO OPEN IN

;A=MODE, HL PTS TO ALLOCT ENTRY, DE TO SCLIST ENTRY ;MARK ALLOCT, SCLIST 36C0 23 36C0 2B 0F 0F CB3F AD E6E0 AD 12 F5 CDDF3B CDEBD3 21785A 46 F1 77 D1 C5 D5 21445A 46 3601 F1 C5 CDEBD6 CDEBD3 F1 32445A CDDF3B F1 CDDA3B 37 3E A7 3A785A C3BE3B SDISRC: LD (HL),0C0H INC HL LD (HL),0C0H DEC HL RRCA RRCA SRL A XOR L AND 0E0H XOR L LD (DE),A PUSH AF CALL SSVARS CALL SDISRC LD HL,CUSCRNP LD B,(HL) POP AF LD (HL),A POP DE PUSH BC PUSH DE LD HL,THFATP LD B,(HL) LD (HL),1 POP AF PUSH BC CALL MODPT2 CALL SDISRC POP AF LD (THFATP),A CALL SSVARS POP AF CALL PRSVARS SCF DB 3EH AND A LD A,(CUSCRNP) JP SDISR ;SEE IF PAGE L IS IN USE AS A SCREEN PAGE 0610 11A05C 1A 13 E61F BD C8 10F8 C9 111E1E CD5F1F 41 210051 23 7E FE40 28FA 55 C9 OCPSR: SPGLOOK: SPGLKLP: LD B,10H LD DE,SCLIST LD A,(DE) INC DE AND 1FH CP L RET Z DJNZ SPGLKLP RET ;OPEN/CLOSE PAGE SR LD DE,1E00H+30 CALL LIMDB LD B,C LD HL,ALLOCT INC HL LD A,(HL) CP 40H JR Z,OCL1 LD D,L RET ;ALLOW ONLY 1-30 ;B AND C=PAGES TO OPEN ;RESERVE PAGES IN SYSTEM PAGE ALLOC TABLE ;L=PAGE NUMBER 02-1EH ;0MMX XXXX ;0MM FROM A, PAGE FROM L ;MODE/PAGE DATA TO SCRN LIST ;MODE/PAGE FOR NEW SCREEN ;STORE CURRENT SCREEN VARS SINCE WE ARE FIDDLING... ;STORE CURRENT PALTAB ;NEW MODE/PAGE ;D=MODE FOR NEW SCREEN ;B=NORMAL CUSCRNP ;MODE ;ENSURE NO XRG CHANGE ;MODE ;CLEAR NEW SCREEN IN DESIRED MODE, SET UP EXPAN. ;TABLES, ETC ;COPY PALTAB TO NEW SCREEN AREA ;ORIG STATUS ;SET UP VARS IN NEW SCREEN PAGE ;ORIG CUSCRNP ;RESTORE SCREEN VARS ;"RESTORE PALTAB" ;"JR+1" ;NC - "SAVE PALTAB"

;RET IF THIS CONTEXT USES PG L AS A SCREEN ALREADY ;NZ IF UNUSED

OCL1:

;LOOK PAST LAST PAGE RESERVED BY BASIC ;NUMBER OF PAGES CURRENTLY USED

;CHANNEL LETTER CHECK. ;ENTRY: DE=DISP FROM CHANS TO CHANNEL. ;EXIT: HL POINTS TO CHANNEL LETTER, Z,NC IF K/S/P. Z,CY IF $/B 2A4F5C 19 23 23 23 7E CHLTCHK: LD HL,(CHANS) ADD HL,DE INC HL INC HL INC HL LD A,(HL) ;PT TO 2ND BYTE OF CHANNEL

D41A D41C D41D D41D D41F D420 D420 D422 D423 D423 D425 D426 D427 D427 D429 D42A D42B D42B D42C D42D D42D D42D D42D D42D D42E D431 D432 D433 D434 D437 D437 D438 D43A D43A D43B D43D D43D D43E D440 D440 D440 D440 D443 D445 D445 D445 D445 D448 D44A D44A D44A D44A D44D D44F D44F D450 D451 D454 D454 D457 D457 D45A D45B D45C D45F D45F D462 D465 D465 D466 D468 D468 D46B D46E D46F D471 D471 D473 D473 D476 D478 D478 D47B D47C D47E D47E D47F D480 D483 D484 D485 D488 D48A D48A D48B D48C D48D D48E D48F D490 D491 D492 D493

FE4B C8 FE53 C8 FE50 C8 FE24 37 C8 FE42 37 C8 A7 C9

CP "K" RET Z CP "S" RET Z CP "P" RET Z CP "$" SCF RET Z CP "B" SCF RET Z AND A RET ;INTERRUPTS. ENTRY VIA RST 38H

79 32D15A C5 D5 1F D2E2D4 1F 300B 1F 300D 1F 3017 2AEA5A 180A 2AE65A 1805 2AE85A DBFD 24 25 C40500 C30AD5 2AE25A 7C B5 C40500 210056 22095A 7E D3F9 3AC75A 21E755 1F 3002 2EFB 01F810 EDBB 21C65A 35 201A 23 34 3A085A 2B 77 210056 180A 23 23 7E 23 46 77 2B 70 23 23

INTS:

LD A,C LD (LASTSTAT),A PUSH BC PUSH DE RRA JP NC,LINEINT RRA JR NC,COMINT RRA JR NC,MIPINT RRA JR NC,FRAMINT

;HMPR/STAT

;MIDI OUTPUT (OR OTHER) INTERRUPT LD HL,(MOPV) JR CMMDIC ;COMS (EX MOUSE) INTERRUPT COMINT: LD HL,(COMSV) JR CMMDIC LD HL,(MIPV) IN A,(MDIPORT) INC H DEC H CALL NZ,HLJUMP JP INTEND FRAMINT: LD HL,(FRAMIV) LD A,H OR L CALL NZ,HLJUMP LD HL,LINICOLS LD (LINIPTR),HL LD A,(HL) OUT (STATPORT),A LD A,(PALFLAG) LD HL,PALTAB+15 RRA JR NC,FRMI3 LD L,>(PALTAB+35) FRMI3: LD BC,16*256+CLUTPORT OTDR LD HL,SPEEDIC DEC (HL) JR NZ,FRMI5 INC HL INC (HL) LD A,(SPEEDINK) DEC HL LD (HL),A LD HL,LINICOLS JR FRMI4 FISCL: INC HL INC HL LD A,(HL) INC HL LD B,(HL) LD (HL),A DEC HL LD (HL),B INC HL INC HL ;COL 1 ;COL 2 ;SET UP PALETTE MEMORIES ;COUNTER FOR DELAY BETWEEN SWAPPING INKS ;PT TO PALETTE FLAG ;FLIP BIT 0 OF PALFLAG - USE OTHER PALET ;RELOAD COUNTER TILL NEXT FLASH ;RESET LINE INT COL CHANGE LIST PTR ;TO START ;LINE TO INT ON, ;OR FF FOR 'NEVER INTERRUPT'

;MIDI INPUT INTERRUPT MIPINT: CMMDIC: ;READ MIDI INPUT BYTE (AUTOMATIC INT CANCEL?)

;NEXT LINE

D494 D494 D495 D496 D498 D498 D49B D49C D49E D49E D4A1 D4A2 D4A5 D4A7 D4A7 D4AA D4AB D4AD D4AD D4AF D4B1 D4B4 D4B4 D4B5 D4B6 D4B8 D4B8 D4B9 D4BA D4BC D4BC D4BF D4C0 D4C3 D4C3 D4C6 D4C7 D4C8 D4C9 D4CB D4CB D4CD D4D0 D4D2 D4D2 D4D4 D4D6 D4D7 D4D8 D4DA D4DA D4DD D4DD D4E0 D4E2 D4E2 D4E2 D4E2 D4E2 D4E2 D4E2 D4E5 D4E5 D4E6 D4E9 D4EB D4ED D4EF D4EF D4F1 D4F2 D4F4 D4F4 D4F5 D4F6 D4F7 D4F8 D4FA D4FB D4FC D4FD D4FE D500 D500 D500 D500 D500 D500 D500 D500 D500 D500 D502 D504 D504 D505 D508 D50A D50A D50D D50E D50F D510

7E 3C 20F2 21785C 34 2025 3AC45A 3D 32C45A 200D 3A325A A7 2007 3E80 D3FE 32C55A 23 34 200B 23 34 2007 2A7F5C 23 227F5C 2AFC5A 25 7C 24 200F DBFE 218E5B 0608 3EFF DBFE 77 23 10F8 C40500 CD10D5 1828

FRMI4: FRMI5:

LD A,(HL) INC A JR NZ,FISCL LD HL,FRAMES INC (HL) JR NZ,INTS3 LD A,(SOFFCT) DEC A LD (SOFFCT),A JR NZ,INTS2 LD A,(SOFE) AND A JR NZ,INTS2 LD A,80H OUT (KEYPORT),A LD (SOFLG),A ;DECED EVERY 5.1 SECS OR SO, SET TO 0 BY KEYBD USE. ;IF DECED TO ZERO, KYBD NOT USED FOR ABOUT 22 MINS. ;JR IF USED WITHIN LAST 22 MINS. ;JR IF 'SCREEN OFF' DISABLED ;'SCREEN OFF' ;INC SECOND BYTE OF FRAMES ;AND THIRD ;FOURTH AND FIFTH

INTS2:

INC HL INC (HL) JR NZ,INTS3 INC HL INC (HL) JR NZ,INTS3 LD HL,(FRAMES34) INC HL LD (FRAMES34),HL

INTS3:

LD HL,(MOUSV) DEC H LD A,H INC H JR NZ,INTS4 IN A,(KEYPORT) LD HL,MSEDP LD B,8

;IF JR NOT TAKEN, A=FF ;READ MOUSE 9 TIMES TO CANCEL IT

MSDML:

LD A,0FFH IN A,(KEYPORT) LD (HL),A INC HL DJNZ MSDML CALL NZ,HLJUMP CALL KEYRD2 JR INTEND

;ALWAYS Z HERE

INTS4: INTS5:

;ENTRY: ;LINIPTR POINTS TO SCAN LINE VALUE IN 4-BYTE CURRENT ENTRY (SCAN/PAL/INK1/INK2) ;BORDER TIME HAS FINISHED BEFORE WE GET HERE 2A095A 56 01F801 DBFE E620 2005 ED78 BA 28FB 23 46 23 7E ED79 23 23 7E 92 28F4 LINEINT: LNINSCAN: LD HL,(LINIPTR) LD D,(HL) LD BC,0100H+CLUTPORT IN A,(KEYPORT) AND 20H JR NZ,LINILP IN A,(C) CP D JR Z,LNWAITLP INC HL LD B,(HL) INC HL LD A,(HL) OUT (C),A INC HL INC HL LD A,(HL) SUB D JR Z,LINILP ;D=SCAN LINE IN LINICOL ENTRY ;PORT BC READS PEN Y (SCAN LINE) ;JR IF LIGHT PEN KEEPS PEN Y FROZEN ;WAIT FOR NEXT SCAN'S BORDER ;PALETTE MEMORY NO. ;NEW VALUE ;OUT (BC) WRITES DESIRED PAL. MEM. ;SKIP ALTERNATE VALUE FOR FLASHING ;NEXT SCAN VALUE (MIGHT BE THE SAME) ;DO MORE CHANGES FOR THIS SCAN (SCAN D+1) ;TAKES ABOUT 32 T'S FOR FIRST COLOUR, ;THEN ABOUT 80 T'S PER LOOP, SO SHOULD ;GET 2 CHANGES IN BORDER TIME, AND ABOUT ;3 IN MIDDLE PART. ;(IF WE USE TOO MANY CHANGES, WE MIGHT ;MISS A CLOSE-FOLLOWING LINE INT CHANGE ;AND THEN MISS ALL LATER CHANGES COS ;LINE INT REG NOT SET UP.) ;IS NEXT ENTRY FOR NEXT SCAN? ;IF SO, WAIT FOR IT ;IF A>191, NO MORE COLOUR CHANGES

LNWAITLP: LINILP:

FE01 28E1 82 22095A D3F9 2AD25A D1 F1 C9 INTEND:

CP 1 JR Z,LNINSCAN ADD A,D LD (LINIPTR),HL OUT (STATPORT),A

LD HL,(SPSTORE) POP DE POP AF ;A=FORMER HMPR RET

D510 D510 D510 D510 D513 D516 D516 D516 D516 D517 D518 D519 D519 D51C D51E D51F D51F D521 D522 D524 D525 D527 D52A D52D D52E D52F D532 D533 D533 D536 D538 D53A D53A D53A D53D D53E D53F D541 D541 D542 D543 D545 D545 D547 D549 D549 D54A D54B D54B D54C D54F D550 D553 D554 D556 D556 D557 D558 D558 D559 D55C D55F D560 D561 D562 D563 D563 D563 D564 D565 D567 D567 D568 D569 D569 D56A D56D D56F D570 D570 D570 D573 D575 D575 D578 D578 D579 D579 D579 D57C D57C D57C D57C D57C D57D D57E D580 D581 D582 D582 D585 D587 D58A

;FROM INTS CD33D5 2A955C 7C BD C8 213B5C CB6E C0 CBEE 6F 2600 3C E607 32965C 118D5C 19 7E 32085C C9 CDBCD5 3E00 2055 21565C 7B BE 280A 23 BE 2806 FE41 2002 23 BE F5 CD9AD5 4F 21055C F1 201F 35 C0 E5 11F65B 2A035C 7C 83 5F 1A 07 2D 20FC E1 D8 34 3A3B5C E620 C0 3A0A5C 1803 3A095C 77 2A955C KBDI: KBRK: KBXL: KBCR: KINTER: KEYRD2: CALL KINTER LD HL,(KBQP) LD A,H CP L RET Z LD HL,FLAGS BIT 5,(HL) RET NZ SET 5,(HL) LD L,A LD H,0 INC A AND 07H LD (KBQP+1),A LD DE,KBQB ADD HL,DE LD A,(HL) LD (LASTK),A RET CALL KEYSCAN LD A,0 JR NZ,LDLH LD LD CP JR HL,NLASTH A,E (HL) Z,KBCR ;SCAN KEYBD, PLACE CHAR IN BUFFER IF THERE IS ONE. ;L=KEY BUFFER QUEUE END (POSN TO PLACE CHAR AT) ;H=QUEUE HEAD (PTS TO NEXT CHAR TO BE READ) ;BOTH ARE DISPLACEMENTS FROM KBQB (BUFFER START) ;IF H=L, BUFFER IS EMPTY. ;RET IF NO CHARS IN BUFFER ;RET IF LAST KEY NOT READ YET (KEY AVAILABLE) ;'KEY PRESSED'

;NEW HEAD POSN REFLECTS CHAR TRANSFER TO COME ;PT TO HEAD ;TRANSFER TO LASTK

;JR IF NO KEY PRESSED ;(NLASTH=0 IF NO KEY OR JUST A SHIFT KEY. USED BY ;AUTO-REPEAT) ;UNSHIFTED KEY CODE ;JR IF SAME KEY AS LAST TIME ;OR TIME BEFORE ;CODE FOR ENTER KEY - PRONE TO STUTTER ;EXTRA CHECK FOR ENTER KEY ONLY ;TIME-BEFORE-TIME BEFORE ;GET A=CHAR, USING D AND E ;JR IF NOT SAME KEY AS LAST TIME, OR TIME BEFORE ;RET IF NOT TIME TO REPEAT KEY ;ELSE CHECK IT IS STILL HELD DOWN (NOT SOME OTHER ;KEY) ;A=1 FOR PORT FE, 9 FOR FF ;A=BYTE FOR DESIRED PORT FROM KBUFF BIT MAP ;'CURRENT' DATA ;L=1 FOR BIT 7, 8 FOR BIT 0 ;GET DESIRED KEY BIT TO CARRY ;NO AUTO-REPEAT IF KEY NO LONGER HELD DOWN

INC HL CP (HL) JR Z,KBCR CP 65 JR NZ,KBCR INC HL CP (HL) PUSH AF CALL KYVL LD C,A LD HL,REPCT POP AF JR NZ,KBDI DEC (HL) RET NZ PUSH HL LD DE,KBUFF+8 LD HL,(LKPB) LD A,H ADD A,E LD E,A LD A,(DE) RLCA DEC L JR NZ,KBXL POP HL RET C INC (HL) LD A,(FLAGS) AND 20H RET NZ LD A,(REPPER) JR KBRK LD A,(REPDEL) LD (HL),A LD HL,(KBQP)

;RET IF STILL KEYS IN BUFFER (DO NOT ACCUMULATE ;AUTO-REPEATING KEYS) ;RELOAD REPCT FROM REPPER (DELAY BETWEEN REPEATS)

;NEW KEY - SET UP REPCT FOR INITIAL DELAY BEFORE ;AUTO-REPEAT ;L=KEY BUFFER QUEUE END (POSN TO PLACE CHAR AT) ;H=QUEUE HEAD (PTS TO NEXT CHAR TO BE READ) ;BOTH ARE DISPLACEMENTS FROM KBQB (BUFFER START) ;IF H=L, BUFFER IS EMPTY. IF *NEW* POSN OF H=L, ;BUFFER IS FULL

7D 3C E607 BC C8 32955C 2600 118D5C 19

LD A,L INC A AND 07H CP H RET Z LD (KBQP),A LD H,0 LD DE,KBQB ADD HL,DE

;RET IF BUFFER FULL (WRAPPED SO END=HEAD)

;PT TO END

D58B D58C D58F D58F D592 D593 D594 D595 D596 D597 D598 D599 D59A D59A D59A D59A D59D D59E D5A0 D5A1 D5A2 D5A4 D5A4 D5A6 D5A6 D5A7 D5A8 D5AA D5AA D5AD D5AF D5B0 D5B1 D5B1 D5B4 D5B5 D5B5 D5B7 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5B8 D5BB D5BC D5BC D5BF D5C0 D5C3 D5C3 D5C3 D5C5 D5C5 D5C7 D5C8 D5CA D5CB D5CC D5CD D5CE D5D0 D5D0 D5D1 D5D2 D5D3 D5D5 D5D7 D5D7 D5D9 D5DB D5DB D5DD D5DE D5DF D5E0 D5E1 D5E3 D5E4 D5E5 D5E6 D5E8 D5E9 D5EA D5EB D5EC D5EE D5EF D5F0 D5F2 D5F2 D5F3

71 3A065C 21565C 4E 77 23 46 71 23 70 C9 2AD85B 7A 1600 19 A7 2806 1E46 19 3D 20FC 3A6A5C E608 7E C8 CD1E3B D0 E6DF C9 KYVLP: KINT4: LDLH:

LD (HL),C LD A,(LASTKV) LD HL,NLASTH LD C,(HL) LD (HL),A INC HL LD B,(HL) LD (HL),C INC HL LD (HL),B RET LD HL,(KBTAB) LD A,D LD D,0 ADD HL,DE AND A JR Z,KINT4 LD E,70 ADD HL,DE DEC A JR NZ,KYVLP LD A,(FLAGS2) AND 08H LD A,(HL) RET Z CALL ALPHA RET NC AND 0DFH RET

;PLACE CHAR IN BUFFER

;GET KEY CODE FROM MAP USING E AND D (SHIFT) KYVL: ;00 IF NO SHIFT, OR 1/2/3 FOR CAPS/SYM/CNTRL ;JR IF NO SHIFT USED ;PT TO CAPS SHIFT/SYM/CNTRL TABLE

;Z=CAPS LOCK OFF

;RET IF NOT A LETTER ;FORCE LOWER CASE LETTERS TO UPPER CASE

;KEYSCAN. ;ACTION: LOOK FOR CHANGED BITS IN KEYBOARD STATE SINCE LAST SCAN, SO THAT ;SEVERAL KEYS CAN BE PRESSED DOWN AND A NEW KEY WILL STILL BE NOTICED. IGNORE ;KEY RELEASES. IF THERE HAVE BEEN NO NEW PRESSES, RETURN THE SAME KEYSCAN ;CODES AS LAST TIME, UNLESS ALL KEYS ARE RELEASED - THEN RETURN NULL CODE. ;ENTRY: NO CONDITIONS ;EXIT: IF NZ, NO KEY PRESSED AND DE=FFFF ; IF Z, E=KEY VALUE ; IF D=0, NO SHIFT, ELSE D=1 (CAPS SH.) 2 (SYM. SH.) OR 3 (CONTROL) ;ENTER AT KEYSCAN+3 WITH HL=DIFFERENT 18-BYTE KBUFF IF DESIRED ;USED BY INKEY$ - 2 SCANS IN CASE OF INTERRUPT CDBCD5 C8 21EE5B E5 01FEFE 16E0 ED58 78 DBF9 AB A2 AB 04 280B 77 05 23 CB00 38EE 06FF 18EA F6E1 77 E1 54 5D CBC6 23 23 23 CBEE 23 23 23 23 CBCE 23 23 0609 1A 4E KBEL: KBSL: TWOKSC: KEYSCAN: CALL KEYSCAN RET Z LD HL,KBUFF ;18-BYTE STORE PUSH HL LD BC,0FE00H+KEYPORT ;C HAS PORT FOR BITS 4-0, B STARTS ;WITH A8 LOW FOR 1ST KEY ROW LD D,0E0H ;MASK TO KEEP BITS 7-5 OF A, USE 4-0 OF E IN E,(C) LD A,B IN A,(STATPORT) XOR E AND D XOR E INC B JR Z,KBEL LD (HL),A DEC B INC HL RLC B JR C,KBSL LD B,0FFH JR KBSL OR 0E1H LD (HL),A POP HL LD D,H LD E,L SET 0,(HL) INC HL INC HL INC HL SET 5,(HL) INC HL INC HL INC HL INC HL SET 1,(HL) INC HL INC HL LD B,9 LD A,(DE) LD C,(HL) ;ONLY BITS 4-0 VALID FOR PORT FFFE, AND FORCE ;BIT 0 (CONTROL KEY BIT) HI TOO ;KBUFF ;'NO CAPS SHIFT' (SCAN SEPARATELY FOR IT) ;'NO ESC' ;READ BITS 4-0 ;A WILL BE ON HI ADDR LINES DURING PORT READ ;READ BITS 7-5

;JR IF WE JUST DID 'SPECIAL' PORT FFFEH

;NEXT PORT (FEFE, FDFE, FBFE...7FFE) ;LOOP UNTIL BACK TO PORT FEFE AGAIN

;'NO SYM. SHIFT' (SCAN SEPARATELY FOR IT) ;PT TO LAST SCAN DATA (BYTES 10-18) ;(HL=KBUFF+9, DE=KBUFF) ;THIS SCAN DATA ;LAST SCAN DATA

KBCL:

D5F4 D5F5 D5F5 D5F6 D5F7 D5F8 D5F9 D5FA D5FB D5FD D5FD D5FF D5FF D600 D601 D602 D604 D604 D606 D606 D606 D606 D608 D60C D60C D60D D60E D60F D611 D611 D613 D613 D614 D615 D615 D616 D618 D618 D619 D61A D61C D61C D620 D620 D620 D621 D622 D623 D624 D625 D626 D627 D62A D62B D62C D62D D62E D630 D630 D631 D632 D635 D637 D63A D63C D63C D63F D641 D643 D644 D646 D646 D647 D649 D64A D64C D64E D64E D64F D651 D653 D654 D656 D656 D657 D658 D658 D65C D65D D65D D65D D65D D65D D65D D660 D661 D661 D664 D664 D665 D667 D669 D669

77 A9 2F B6 12 23 13 10F5 0609 1B 1A 3C 2011 10F9 0609 ED5B065C 2B 7E 3C 202B 10F9 04 C9 3D 0E09 0D 1F 38FC ED43035C 79 87 87 87 81 90 5F 21C45A AF 77 23 86 280C AF 77 3A4B5C E67F 324B5C D3FE 01FEFE ED78 1601 A2 2812 04 ED78 A2 1603 280A 15 067F ED78 A2 2802 15 15 ED53065C C9 KBLD: KBSH: KBYK: KBBL: KBAKL: KBDL:

LD (HL),A XOR C CPL OR (HL) LD (DE),A INC HL INC DE DJNZ KBCL LD B,9 DEC DE LD A,(DE) INC A JR NZ,KBYK DJNZ KBDL

;LAST SCAN DATA UPDATED WITH NEW DATA - BUT WE ;HAVE IT IN C NOW ;GET ALTERED BITS SINCE LAST SCAN AS 0'S ;KEEP AS 0'S IF CHANGE WAS 1->0 (PRESSED) ;'CHANGED' DATA TO KBUFF

;JR IF ANY BIT RESET

;NO NEW PRESSES SINCE LAST SCAN. HL=KBUFF+18 LD B,9 LD DE,(LASTKV) DEC HL LD A,(HL) INC A JR NZ,KBSH DJNZ KBAKL INC B RET DEC A LD C,9 DEC C RRA JR C,KBBL LD (LKPB),BC LD A,C ADD A,A ADD A,A ADD A,A ADD A,C SUB B LD E,A LD HL,SOFFCT XOR A LD (HL),A INC HL ADD A,(HL) JR Z,KBSH XOR A LD (HL),A LD A,(BORDCOL) AND 7FH LD (BORDCOL),A OUT (KEYPORT),A LD BC,0FEFEH IN A,(C) LD D,1 AND D JR Z,KBLD INC B IN A,(C) AND D LD D,3 JR Z,KBLD DEC D LD B,7FH IN A,(C) AND D JR Z,KBLD DEC D DEC D LD (LASTKV),DE RET ;KEYRD2 INCLUDE SCRSEL2.SAM ;SCRSEL2.SAM. 219ED6 DD 219219 E5 FEDE 2808 CDE43A GOSUB: GOTO: GSUBTOC: LD HL,GOSUB2 DB 0DDH LD HL,GOTO2 PUSH HL CP 0DEH JR Z,GOTON CALL EXPT1NUM ;ONTOK ;LINE NUMBER ; GOTO, CONT, GETTOKEN, MODPT2, AUTO ;CHANGE BIT POSN TO NUMBER IN C (1-8) ;LAST KEY PORT/BIT SAVED FOR AUTO-REPEAT CHECKING ;B=1 IF LAST PORT = FEFE, 9 IF FFFE. C=8 FOR BIT ;0, 1 FOR BIT 7 ;*2 ;*4 ;*8 ;*9 (09-48H) ;SUB 1-9 TO GET 00-47H ;SCAN CODE TO E ;ZERO SCREEN OFF COUNTER - KEYBOARD USED ;SOFLG ;JR IF SCREEN NOT TURNED OFF BY NO KEY USE ;'ON' ;NZ ;E=LAST VALUE

;JR IF KBUFF SHOWS ANY KEY PRESSED APART FROM SHIFT ;USE LAST VALUE, PLUS CURRENT SHIFT STATUS

;JR IF CAPS SHIFT - D=1 ;ELSE D=1

;JR IF CONTROL - D=3

;JR IF SYM SHIFT - D=2 ;Z=KEY OBTAINED. D=0 FOR NO SHIFT

;"JR+3"

D66C D66D D670 D670 D671 D671 D671 D671 D674 D675 D677 D67A D67A D67B D67D D67D D67E D67E D681 D683 D685 D685 D686 D686 D689 D689 D68A D68C D68C D68D D68D D68E D691 D692 D693 D694 D694 D697 D698 D69A D69C D69C D69D D69E D69E D6A1 D6A2 D6A3 D6A6 D6A6 D6A8 D6A9 D6AC D6AD D6B0 D6B0 D6B0 D6B0 D6B1 D6B2 D6B2 D6B3 D6B3 D6B5 D6B7 D6B7 D6B7 D6B8 D6B9 D6B9 D6BA D6BB D6BC D6BE D6C0 D6C0 D6C0 D6C1 D6C2 D6C2 D6C3 D6C4 D6C6 D6C7 D6C8 D6CA D6CA D6CB D6CD D6CD D6CE D6CE D6CF D6D1 D6D3 D6D3 D6D5 D6D7 D6D7 D6D8 D6D9 D6DB D6DB

E1 CD153B E9 CDE33A F5 FE3B C2290D F1 3809 E1 CDE33A FE2C 28F9 C9 CD651D 9F 2801 4F C5 CDE33A C1 0D C8 CD121D DF FE2C 28F1 D1 C9 CD2E1D 7C 3C CA391D 0600 E5 CDF118 E1 C39A19 4F 08 23 CB7E 28FB 0D C8 23 1A AE E6DF 20F3 D5 13 23 7E FE20 1A 13 2004 BE 28F5 23 AE E6DF 28EF E67F 2004 7E 07 3803 D1 GTTOK5: GTTOK4: GTTOK3: GETTOKEN: GTTOK1: GTTOK2: GOSUB2: GOTONRL: GOTON2: GOTONSL: GOTON:

POP HL CALL CHKEND JP (HL)

;ADDR OF GOTO OR GOSUB ROUTINE

;E.G. GOSUB (OR GOTO) ON X;100,234,400 CALL SEXPT1NUM PUSH AF CP ";" JP NZ,NONSENSE POP AF JR C,GOTON2 POP HL CALL SEXPT1NUM CP "," JR Z,GOTONSL RET CALL FPTOA SBC A,A JR Z,GOTONRL LD C,A PUSH BC CALL SEXPT1NUM POP BC DEC C RET Z CALL FDELETE RST 18H CP "," JR Z,GOTONRL POP DE RET CALL GETINT LD A,H INC A JP Z,IOORERR LD B,00H PUSH HL CALL BSTKE POP HL JP GOTO3 LD C,A EX AF,AF' INC HL BIT 7,(HL) JR Z,GTTOK1 DEC C RET Z INC HL LD A,(DE) XOR (HL) AND 0DFH JR NZ,GTTOK2 PUSH DE INC DE INC HL LD A,(HL) CP " " LD A,(DE) INC DE JR NZ,GTTOK4 CP (HL) JR Z,GTTOK3 INC HL XOR (HL) AND 0DFH JR Z,GTTOK3 AND 7FH JR NZ,GTTOK5 LD A,(HL) RLCA JR C,GTTOK6 POP DE ;LOOP TILL WE FIND THE END OF A KEYWORD ;32 TS PER LOOP ;RET IF WE HAVE CHECKED THEM ALL - Z=FAILED ;DE=FIRST LETTER OF ELINE WORD COPY ;'GOSUB' TYPE ;LINE NO. ;STACK RETURN ADDR ;SKIP 'ON', EVAL NUMBER

;JR IF RUNNING ;GOTO/GOSUB ADDR ;SKIP E.G. 100,200,400 ;TO NEXT STAT ;GET NUMBER AFTER 'ON' IN C AND A ;CY IF >255 ;A=255 IF OUT OF RANGE, ELSE 0 ;C IS OK IF A=0 ;ELSE LET C=255 ;C=EXPR NUMBER ;RET TO GOTO OR GOSUB IF THIS IS DESIRED EXPR ;DISCARD EXPR FROM FPCS ;LOOP IF THERE ARE MORE LINE NOS TO SKIP ;GOTO/GOSUB ADDR ;TO NEXT STAT - LINE NOS RAN OUT.

;GET TOKEN SR - VIA JUMP TABLE ;NO OF WORDS TO CHECK,+1

;LOOP BACK AND CHECK ANOTHER WORD IF MATCH FAILS ;ABOUT 80 TS PER LOOP IF NO MATCH. ABOUT 35USEC ;PER 5-LETTER WORD OR 5.3MSEC FOR 150 WORDS. ;PTR TO FIRST LETTER IN ELINE WORD

;JR IF NO EMBEDDED SPACE IN KEYWORD IN LIST ;ELSE ACCEPT ONE IN INPUT ;BUT DON'T INSIST - SKIP LIST PTR IF NO SP IN INPUT ;LOOP IF STILL MATCHING OK ;JR IF INPUT AND LIST WORDS DON'T END NOW ;OK IF LIST WORD HAS FINISHED

D6DC D6DE D6DE D6E0 D6E1 D6E2 D6E5 D6E5 D6E7 D6E7 D6E8 D6E9 D6EA D6EB D6EB D6EB D6ED D6F0 D6F1 D6F2 D6F3 D6F5 D6F6 D6F9 D6F9 D6FA D6FB D6FC D6FD D6FE D6FF D702 D703 D704 D706 D707 D708 D70A D70B D70D D70F D70F D710 D712 D712 D713 D714 D715 D717 D718 D71B D71C D71D D71E D71E D721 D721 D724 D726 D726 D728 D72A D72A D72A D72A D72A D72D D730 D733 D736 D737 D739 D739 D739 D739 D73B D73D D73D D740 D743 D746 D747 D748 D74B D74C D74D D74E D751 D754 D757 D75A D75C D75C D75F D760 D761 D764 D764 D767 D767 D76A D76C D76C

18D5 FE7E 3F 1A DC373B 38F4 E1 08 91 C9 E603 21405A 4E C5 77 FE02 F5 D41AD8 F1 F5 0F 0F 0F 4F 21785A 7E A9 E69F A9 77 DBFC AE E61F 2003 7E D3FC F1 C1 F5 FE01 9F 210908 85 6F F1 CD6CD7 3ACE5A 2813 FE02 203D MDL2: MODPT2: GTTOK6:

JR GTTOK2 CP 7EH CCF LD A,(DE) CALL C,ALDU JR C,GTTOK5 POP HL EX AF,AF' SUB C RET AND 03H LD HL,MODE LD C,(HL) PUSH BC LD (HL),A CP 2 PUSH AF CALL NC,SUET POP AF PUSH AF RRCA RRCA RRCA LD C,A LD HL,CUSCRNP LD A,(HL) XOR C AND 9FH XOR C LD (HL),A IN A,(VIDPORT) XOR (HL) AND 1FH JR NZ,MDL2 LD A,(HL) OUT (VIDPORT),A POP AF POP BC PUSH AF CP 1 SBC A,A LD HL,0809H ADD A,L LD L,A POP AF CALL MDSR LD A,(TEMPB1) JR Z,M2ST CP 2 JR NZ,ECLS ;OLD MODE ;JR IF MODE 2 BEING SET ;JR IF NOT MODE 2 NOW, AND NOT CHANGING TO MODE 2 ;('=' TERMINATOR =7B AFTER RLCA, '>'=7DH, '$'=49H) ;NC IF '=' OR '>' OR '$' ;INPUT CHAR AFTER MATCHED WORD ;CALL TO INSIST ON NON-LETTER AFTER E.G. PRINTx ;BUT NOT AFTER <>,>= OR <= OR CHR$a ;('=' AND '>' NEVER CALL ALPHA OR JR HERE) ;FIRST LETTER OF ELINE WORD COPY ;A=1 IF FIRST WORD MATCHES, ETC.

;SAVE PREVIOUS MODE ;NEW MODE ;SET UP EXPANSION TABLE IF NEEDED ;MODE ;MODE BITS TO BITS 6 AND 5 ;KEEP CURRENT VID PAGE, ;BUT ;USE BITS 6 AND 5 OF C TO SET MODE

;JR IF WE ARE NOT DISPLAYING THIS SCREEN - AVOID ;ALTERING HARDWARE MODE ;NEW MODE ;C=PREV MODE ;NEW MODE ;CY IF MODE 0 ;MODE 0=FF, REST=0 ;CHAR WIDTH/HEIGHT FOR MODES 1-3 ;DEC HEIGHT TO 8 IF MODE 0, TO FIT ATTR

;ELSE IF CHANGING FROM MODE 2 TO ANOTHER MODE, SAVE M2 PALTAB ; 0-3, GET BACK NON-MODE-2 COLOURS 2A495B 22485A 2A4B5B 22305A 4F 1823 FE02 282A 2A485A 22495B CD80F1 F5 6C CD80F1 65 F1 6F 22485A 2A305A 224B5B CD7BF1 0E00 3A445A A7 79 CCCBD7 CDBBED CDFA01 9806 ECLS: M2ST2: M2ST: LD LD LD LD LD JR HL,(M3PAPP) (M23PAPP),HL HL,(M3LSC) (M23LSC),HL C,A M2ST2

;C=NZ - 'HALVE'

;MODE 2 BEING SET CP 2 JR Z,ECLS LD HL,(M23PAPP) LD (M3PAPP),HL CALL M3TO2 PUSH AF LD L,H CALL M3TO2 LD H,L POP AF LD L,A LD (M23PAPP),HL LD HL,(M23LSC) LD (M3LSC),HL CALL CVLSP LD C,0 LD A,(THFATP) AND A LD A,C CALL Z,SETFP CALL PALSW CALL R1OFFJP DW MCLS ;TURN ROM 1 OFF, JP MCLS ;JR IF MODE 2 ALREADY ;CONVERT L ;CONVERT H ;PREVENTS STRIPED INKS AFTER MODE 2 SET. ;CONVERT LS PAPER ;C='HALVE' ;WE ARE CHANGING TO/FROM MODE 2 ;'THIN' PIXEL STATUS WILL CHANGE, ;FIDDLE XCOORD/XRG IF

;CALLED FROM CSIZE WITH A AND C=MODE, HL=CSIZE

D76C D76C D76D D76E D771 D774 D776 D778 D778 D779 D77A D77C D77C D77D D780 D780 D781 D782 D785 D787 D788 D789 D78B D78B D78D D790 D791 D793 D793 D795 D797 D79A D79A D79D D79E D79F D7A0 D7A1 D7A2 D7A3 D7A4 D7A5 D7A6 D7A7 D7AB D7AC D7AD D7AE D7AF D7B0 D7B1 D7B2 D7B3 D7B4 D7B5 D7B5 D7B5 D7B5 D7B8 D7B8 D7BB D7BE D7BE D7C1 D7C2 D7C3 D7C3 D7C4 D7C7 D7C9 D7CA D7CA D7CB D7CB D7CE D7CF D7D1 D7D1 D7D3 D7D5 D7D6 D7D6 D7D7 D7D7 D7DA D7DA D7DB D7DE D7DF D7E2 D7E3 D7E6 D7E8 D7E8 D7E9 D7EA D7EA D7EA D7EA D7EA D7EA D7ED D7ED

F5 79 32CE5A 22365A 3EC0 1EFC 1C 95 30FC 85 325D5A 7D 87 325C5A 161F F1 F5 200F 163F 3A355A A7 2007 1654 3E06 32375A 21385A 72 23 AF 77 23 77 23 73 23 72 ED535A5A 23 77 23 1C 73 23 1C 73 F1 C9 CD583A 111E02 CD621F 21445A BE C8 77 3A405A FE02 C0 7E 2A425A A7 2805 CB3C CB1D 3E 29 22425A F5 CD1F1F F1 115700 19 CDFA01 152B CF 1E

MDSR:

PUSH AF LD A,C LD (TEMPB1),A LD (CSIZE),HL LD A,192 LD E,0FCH INC E SUB L JR NC,MDSL ADD A,L LD (LSOFF),A LD A,L ADD A,A LD (ORGOFF),A LD D,31 POP AF PUSH AF JR NZ,MDSR3 LD D,63 LD A,(FL6OR8) AND A JR NZ,MDSR3 LD D,84 LD A,6 LD (CSIZE+1),A

;NEW MODE ;PREV MODE (SAME IF CALLED FROM CSIZE) ;H=WIDTH, L=HEIGHT

MDSL:

;SUB CHAR HEIGHT ;CALC SCREEN HEIGHT IN LINES, MINUS 3 ;(UW BOT) ;'LEFT OVER' PIXELS ;LOWER SCREEN OFFSET - SO LEFT-OVER PIX BETWEEN ;UPPER SCREEN AND LOWER SCREEN ;DISP OF GRAPHICS ORIGIN FROM SCREEN BOTTOM IS ;2 CHAR HEIGHTS ;RHS FOR MODES 0, 1 AND 3 ;MODE ;JR IF NOT MODE 2 ;RHS FOR MODE 2 64-COL MODE ;JR IF 8-BIT ;RHS FOR MODE 2 85-COL MODE ;WIDTH ;UWRHS ;UWLHS ;UWTOP ;UWBOT ;LWRHS ;LWLHS ;LWTOP=UWBOT+1 ;LWBOT=LWTOP+1 ;Z IF MODE 2

MDSR3:

LD HL,UWRHS LD (HL),D INC HL XOR A LD (HL),A INC HL LD (HL),A INC HL LD (HL),E INC HL LD (HL),D LD (WINDMAX),DE INC HL LD (HL),A INC HL INC E LD (HL),E INC HL INC E LD (HL),E POP AF RET CALL SYNTAX6 LD DE,0200H+30 CALL LIMBYTE LD HL,THFATP CP (HL) RET Z LD (HL),A LD A,(MODE) CP 2 RET NZ LD A,(HL)

;FATPIX 0=USE THIN PIXELS IN MODE 2. 1=USE FAT PIXELS FATPIX: ;LIMIT TO <2 OR IOOR

;RET IF NO CHANGE IN FATPIX STATUS

;DON'T FIDDLE XCOORD AND XRG UNLESS MODE 2

SETFP:

LD HL,(XCOORD) AND A JR Z,FPX2 SRL H RR L DB 3EH

;JR IF CHANGED FROM 1 TO 0 (FAT TO THIN) ;HALVE X ;'JR+1' ;DOUBLE X COORD TO KEEP SAME SCREEN POSN ;A=0 FOR DOUBLE, 29H FOR HALVE

FPX2:

ADD HL,HL LD (XCOORD),HL PUSH AF CALL ADDRNV POP AF LD DE,87 ADD HL,DE CALL R1OFFJP DW CGXRG

;PT TO XRG ;CHANGE XRG WITH ROM1 OFF ** ;IOOR

PXIOOR:

RST 08H DB 30

;CSIZE W,H ;WIDTH CAN BE 6 OR 8 BUT 6 ONLY EFFECTIVE IN MODE 2 ;HEIGHT CAN BE 6-32, DOUBLE HEIGHT USED IF 16 OR MORE. CD5F3A CD331D WIDTH: CALL SYNTAX8 CALL GETBYTE ;H

D7F0 D7F1 D7F4 D7F6 D7F8 D7F8 D7FA D7FC D7FC D7FD D7FE D7FF D801 D803 D803 D805 D807 D807 D808 D809 D80B D80E D811 D812 D814 D815 D818 D819 D81A D81A D81A D81A D81A D81A D81A D81D D81F D821 D821 D822 D825 D826 D827 D828 D829 D82A D82B D82D D82F D82F D830 D830 D831 D834 D835 D836 D837 D838 D83A D83C D83C D83D D83D D83D D83D D840 D841 D841 D841 D841 D843 D843 D844 D846 D848 D849 D84A D84C D84E D850 D850 D851 D851 D851 D851 D854 D856 D856 D859 D85C D85E D860 D860 D861 D864 D865 D867 D867 D86A D86D D86E D86E D871

C5 CD331D FE06 2804 FE08 20EC D1 57 7B FE06 38E5 FE21 30E1 EB 7C D606 32355A 3A405A 4F FE02 F5 CD6CD7 F1 C0 CSZ2:

PUSH BC CALL GETBYTE CP 6 JR Z,CSZ2 CP 8 JR NZ,PXIOOR POP DE LD D,A LD A,E CP 6 JR C,PXIOOR CP 33 JR NC,PXIOOR EX DE,HL LD A,H SUB 6 LD (FL6OR8),A LD A,(MODE) LD C,A CP 2 PUSH AF CALL MDSR POP AF RET NZ

;W

;E=H ;D=W ;HEIGHTS OF 0-5 ARE CRAZY - BUT 6-7 MIGHT BE OK ;WITH THE RIGHT CHARACTER SET. ;HEIGHTS OF 6-32 ARE ALLOWED ;WIDTH ;0 IF WIDTH 6, ELSE NZ ;'PREVIOUS MODE' NEEDED BY MDST2 ;SET Z IF MODE 2 ;MODE - SET WIDOWS, CSIZE. HL=CSIZE ;RET IF NOT MODE 2 ;ELSE SET UP EXPANSION TABLE IF MODE 2, IN CASE ;SWITCHING BETWEEN M2/M3 O/P TYPES

;SET UP EXPANSION TABLE. ENTRY: A=MODE 2/3, Z IF 2 21205B 0E00 280F 79 CD3DD8 72 23 73 23 0C 79 FE10 38F2 C9 79 CD41D8 73 23 0C 79 FE10 38F4 C9 CD41D8 7B 0608 0F CB1A CB1B 07 0F CB1A CB1B 10F3 C9 CD7A3A 2811 CD8E3B 010A00 FE2C 200E E5 CD8D3B E1 1807 2A495C 010A00 09 CDC63A D0 AO1: AO2: AUTO: QUADBITS: DBTABCLP: SUET: QUADTCLP: LD HL,EXTAB LD C,0 JR Z,DBTABCLP LD A,C CALL QUADBITS LD (HL),D INC HL LD (HL),E INC HL INC C LD A,C CP 16 JR C,QUADTCLP RET LD A,C CALL DBBITS LD (HL),E INC HL INC C LD A,C CP 16 JR C,DBTABCLP RET ;A->DE, QUADED BITS CALL DBBITS LD A,E LD B,8 RRCA RR D RR E RLCA RRCA RR D RR E DJNZ DBBITSLP RET ;AUTO <LINE><,STEP> CALL CRCOLON JR Z,AO1 CALL GIR2 LD BC,10 CP "," JR NZ,AO2 PUSH HL CALL GIR POP HL JR AO2 LD HL,(EPPC) LD BC,10 ADD HL,BC CALL RUNFLG RET NC ;JR IF JUST 'AUTO', USE BOTH DEFAULTS ;GET LINE VALUE IN HL AND BC ;DEFAULT STEP IS 10 ;JR IF NO STEP ;SAVE LINE VALUE ;GET STEP VALUE IN HL,BC ;BITS TO DO ;DE HAS DOUBLED BITS ;A->E, DOUBLED BITS ;PT TO EXPANSION TABLE ;FIRST VALUE TO EXPAND ;JR IF MODE 2 ;A->DE, QUADED BITS

;QUAD 00-0FH

;DOUBLE 00-0FH

;A->DE WITH ALL BITS DOUBLED DBBITS: DBBITSLP:

;DEFAULT LINE VALUE IS EPPC+10 ;CANNOT USE CHKEND - NEED C

D872 D872 D873 D875 D876 D877 D87A D87B D87B D87E D882 D883 D884 D887 D88A D88A D88D D88D D88E D891 D892 D894 D894 D895 D898 D899 D89C D89F D8A0 D8A1 D8A2 D8A3 D8A4 D8A5 D8A6 D8A9 D8A9 D8AA D8AC D8AE D8AE D8AF D8B1 D8B1 D8B4 D8B4 D8B6 D8B7 D8BA D8BD D8BF D8BF D8C1 D8C2 D8C4 D8C5 D8C5 D8C6 D8C7 D8C8 D8C9 D8CA D8CC D8CC D8CD D8CD D8CD D8CD D8CD D8CD D8D0 D8D0 D8D3 D8D4 D8D6 D8D6 D8D9 D8DA D8DC D8DC D8DD D8DE D8DF D8DF D8E2 D8E2 D8E3 D8E4 D8E5 D8E5 D8E8 D8E8 D8E9 D8EA D8EC D8EC D8EE D8F0 D8F0 D8F1 D8F3 D8F3 D8F4

AF ED42 3F 8F 32885B C8 22495C ED43895B D1 D1 01750E C31F02 11004F D5 CDDC3A D1 3015 D5 CD331D F5 111E20 CD621F C1 D1 12 1C 78 12 1C CA664F DF FE3B 2003 E7 18DC CD153B 3EFF 12 01FF01 21004F 1806 ED51 05 ED59 04 56 2C 5E 2C BA 20F3 C9 SNDOPL: SND2: SND1: SOUND: SNDLP:

XOR A SBC HL,BC CCF ADC A,A LD (AUTOFLG),A RET Z LD (EPPC),HL LD (AUTOSTEP),BC POP DE POP DE LD BC,AULL JP R1XJP LD DE,INSTBUF PUSH DE CALL EXPT2NUMS POP DE JR NC,SND1 PUSH DE CALL GETBYTE PUSH AF LD DE,2000H+30 CALL LIMBYTE POP BC POP DE LD (DE),A INC E LD A,B LD (DE),A INC E JP Z,NRFLERR RST 18H CP ";" JR NZ,SND2 RST 20H JR SNDLP CALL CHKEND LD LD LD LD JR OUT DEC OUT INC

;A=O IF STEP>LINE, ELSE A=1 ;0=OFF, NZ=ON ;RET IF OFF ;INITIAL EPPC=LINE-STEP ;NEXT STAT ;ERROR HANDLER ;TURN ROM1 OFF, JP MAINX

;ALLOW 0-31

;LIMIT TO 254 VALUES IN INSTBUF (127 PAIRS)

;SKIP ';'

A,0FFH (DE),A ;TERMINATE LIST BC,256+SNDPORT ;SOUND ADDRESS REG PORT HL,INSTBUF ;HOLDS AT LEAST ONE PAIR SND3 (C),D B (C),E B ;SET REG ;SOUND DATA REG PORT ;SEND DATA

SND3:

LD D,(HL) INC L LD E,(HL) INC L CP D JR NZ,SNDOPL RET

;LOOP UNTIL TERMINATOR HIT

;PERFORM BOOT ACTION ;FIND A PAGE FOR DOS AND MARK IT. CD503A CD331D A7 200F 3AC25B A7 2803 CF 88 C9 CDE5D8 CF 80 C9 211F51 7E A7 2809 FE60 2805 2D 20F5 CF 01 BOOTEX: FDPL: BOOTNR: BOOT: CALL SYNTAX3 CALL GETBYTE AND A JR NZ,BOOTEX LD A,(DOSFLG) AND A JR Z,BOOTNR RST 08H DB ALHK RET CALL BOOTEX RST 08H DB BTHK RET LD HL,ALLOCT+1FH LD A,(HL) AND A JR Z,GDP CP 60H JR Z,GDP DEC L JR NZ,FDPL RST 08H DB 1 ;'OUT OF MEMORY' IF NO FREE PAGE FOR DOS ;JR IF FREE PAGE ;JR IF RE-BOOTING TO A DOS PAGE ;DO AUTO-LOAD, BUT NO ERROR IF NONE ;E.G. BOOT 1 FORCES BOOT OR RE-BOOT ;NO AUTO-LOAD ;JR IF DOS NOT RESIDENT - ELSE AUTOLOAD ONLY ; DO AUTO-LOAD

D8F5 D8F5 D8F6 D8F9 D8F9 D8F9 D8F9 D8FB D8FE D901 D901 D901 D901 D903 D904 D906 D906 D907 D908 D909 D90B D90B D90C D90E D90E D90F D910 D910 D912 D913 D914 D916 D918 D918 D919 D91B D91B D91E D921 D921 D921 D921 D922 D923 D923 D924 D926 D926 D929 D92B D92C D92E D92E D930 D932 D932 D934 D934 D937 D939 D939 D93A D93C D93F D942 D945 D946 D946 D948 D948 D94A D94C D94E D94E D94F D951 D951 D952 D952 D952 D952 D954 D956 D956 D957 D958 D95A D95B D95E D95F D961 D964 D964 D965 D967 D967 D96A D96D D96F D96F D970 D971 D972

7D CDDF3F 0ED0 CD81D9 CD89D9 26FE 5C 0606 2B 7C B5 2005 1C 2002 CF 37 DBE0 57 A9 E602 28EE 4A 10EB CD89D9 110104 AF 08 7B D3E2 CD8ED9 DBE1 BA 280B 0E79 3002 0E59 CD7ED9 18ED F3 0E80 CD7ED9 210080 01E300 FE EDA2 DBE0 CB4F 20F8 0F 38F7 FB E60E 2811 08 3C FE05 F5 CC89D9 F1 FE0A D2BEE2 08 18BC 11FF80 2194FB 0604 13 1A AE E65F

GDP:

LD A,L CALL SELURPG LD C,0D0H CALL SDCX CALL REST LD H,0FEH LD E,H LD B,6

;DOS PAGE IN AT 8000H ;START OF BRUCE GORDONS CODE ;LOAD STUFF NOW ;RESET CHIP ;EXITS WITH B=0

;TEST FOR INDEX HOLE ;HL=FEXX ;E COUNTS 2 OUTER LOOPS

BOOT2:

DEC HL LD A,H OR L JR NZ,BOOT3 INC E JR NZ,BOOT3 RST 08H DB 55 ;'Missing disc'

BOOT3:

IN A,(COMM) LD D,A XOR C AND 2 JR Z,BOOT2 LD C,D DJNZ BOOT2 CALL REST LD DE,0401H

;LOOP UNTIL HOLE SIGNAL CHANGES

;TRACK/SECTOR

;READ SECTOR AT TRACK D, SECTOR E RSAD: RSA1: RSA2: XOR A EX AF,AF' LD A,E OUT (SECT),A CALL BUSY IN A,(TRCK) CP D JR Z,RSA4 LD C,STPOUT JR NC,RSA3 LD C,STPIN RSA3: RSA4: CALL SADC JR RSA2 DI LD C,DRSEC CALL SADC LD HL,8000H LD BC,DTRQ DB 0FEH INI IN A,(COMM) BIT 1,A JR NZ,RSA5 RRCA JR C,RSA6 EI ;CHECK DISC ERROR COUNT AND 0EH JR Z,BTNOE EX AF,AF' INC A CP 5 PUSH AF CALL Z,REST POP AF CP 10 JP NC,TERROR EX AF,AF' JR RSA1 BTNOE: BTCK: LD DE,80FFH LD HL,BTWD LD B,4 INC DE LD A,(DE) XOR (HL) AND 5FH ;JR IF NO ERRORS

;"JR+2" (CP EDH: AND D)

RSA5: RSA6:

;IGNORE MISMATCH ON BITS 7 OR 5

D974 D976 D976 D977 D978 D978 D979 D97B D97B D97E D97E D981 D981 D982 D984 D986 D986 D988 D988 D989 D989 D989 D989 D98B D98E D98E D98E D98E D990 D991 D992 D992 D995 D997 D997 D997 D997 D997 D997 D997 D997 D997 D999 D999 D99C D99F D9A2 D9A3 D9A5 D9A5 D9A8 D9A9 D9AC D9AD D9AF D9B1 D9B1 D9B3 D9B3 D9B4 D9B5 D9B7 D9B9 D9B9 D9BA D9BC D9BE D9BE D9BE D9BF D9BF D9C2 D9C5 D9C6 D9C8 D9C9 D9CA D9CB D9CC D9CC D9CD D9CE D9D1 D9D2 D9D4 D9D4 D9D7 D9D8 D9DA D9DA D9DB D9DC D9DD D9DF D9E1 D9E1 D9E2 D9E4 D9E6 D9E6 D9E6 D9E7 D9E7

2802 CF 35 23 10F4 C30980 CD8ED9 79 D3E0 0600 10FE C9 0E09 CD7ED9 DBE0 0F D0 CD5D0E 18F7 REST: SADC: SDCX: SDC1: BTLY:

JR Z,BTLY RST 08H DB 53 INC HL DJNZ BTCK JP 8009H CALL BUSY LD A,C OUT (COMM),A LD B,0 DJNZ SDC1 RET ;RESTORE DRIVE TO ZERO LD C,DRES CALL SADC IN A,(COMM) RRCA RET NC CALL BRKCR JR BUSY INCLUDE PRINTFP.SAM ;PRINTFP.SAM - PRINT A NUMBER ;******************************************************************************* ;RETURN STR$ OF NUMBER ON FPCS AS BC BYTES AT (DE) IN BUFFER ;DOS INITIALISE ;'NO DOS' IF NOT 'BOOT'

;TEST FOR CHIP BUSY BUSY:

3E06 329A5B CDC5DA 3A9D5B A7 201A 2A9B5B 2B 229B5B 7E FE35 380E 3630 2B 7E FE2E 28FA 3C FE3A 30F3 77 2A9B5B 11A05B A7 ED52 4D 44 2D C8 19 23 3A9F5B A7 2006 3A9E5B A7 280D 0D 2B 7E FE30 28F9 7E FE2E 28EE 0C 1A

PFSTRS: PFSTRSC:

LD A,6 LD (FRACLIM),A CALL PRFPBUF LD A,(DIGITS) AND A JR NZ,PFNRND LD HL,(NPRPOS) DEC HL LD (NPRPOS),HL LD A,(HL) CP "5" JR C,PFNRND ;UP TO 4 LEADING ZEROS IN FRACTIONS BEFORE EFORM ;IS USED ;JR IF LESS THAN 9 CHARS - RESULT IS EXACT ;ELSE ROUND UP ON 9TH. DIGIT. (NOT A DEC. PT) ;IGNORE 9TH. DIGIT OTHER THAN FOR ROUNDING ;NO ROUND IF E.G. 12345678.4

PFRNDLP: PFPSLP:

LD (HL),"0" DEC HL LD A,(HL) CP "." JR Z,PFPSLP INC A CP "9"+1 JR NC,PFRNDLP LD (HL),A ;JR IF OVERFLOWED - 0 THIS DIGIT AND KEEP ROUNDING ;EXTREME CASE IS ROUND RIGHT BACK TO FIRST ZERO ;BEFORE EXITING LOOP

PFNRND:

LD HL,(NPRPOS) LD DE,PRNBUFF AND A SBC HL,DE LD C,L LD B,H DEC L RET Z ADD HL,DE INC HL LD A,(DECPNTED) AND A JR NZ,MTRZDLP

;IF ONLY 1 CHAR, MUST BE ZERO - LEN 1, AT (DE) ;HL=NPRPOS ;DELETE TRAILING ZEROS IF DEC PT USED E.G. 1.2300 ;JR IF NOT EFORM - LEAVE TRAILING ZEROS

EFCHECK: MTRZDLP:

LD A,(EPOWER) AND A JR Z,PFNPNT DEC C DEC HL LD A,(HL) CP "0" JR Z,MTRZDLP LD A,(HL) CP "." JR Z,EFCHECK INC C

;DELETE TRAILING ZEROS ;KEEP "." DELETED AND GOTO PFNPNT IF NOT EFORM ;ELSE PNT IS NOT REAL - DELETE MORE ZEROS IF NEEDED ;ELSE "UNDELETE" LAST NON-"0"/NON-"." CHAR

PFNPNT:

LD A,(DE)

D9E8 D9EA D9EC D9EC D9ED D9EE D9EE D9F0 D9F2 D9F2 D9F5 D9F6 D9F8 D9FA D9FC D9FE D9FE DA01 DA01 DA01 DA02 DA03 DA06 DA07 DA0A DA0A DA0B DA0C DA0D DA0F DA11 DA12 DA12 DA15 DA18 DA1B DA1C DA1D DA20 DA21 DA22 DA23 DA25 DA25 DA25 DA25 DA26 DA27 DA27 DA28 DA2B DA2D DA2D DA2E DA30 DA30 DA30 DA30 DA30 DA30 DA31 DA31 DA34 DA35 DA36 DA38 DA3A DA3A DA3B DA3D DA3D DA3F DA41 DA41 DA42 DA42 DA44 DA44 DA45 DA47 DA49 DA49 DA4B DA4C DA4D DA4E DA50 DA51 DA53 DA55 DA57 DA57 DA59 DA59 DA5A DA5B DA5D DA5F DA5F DA60 DA61 DA62 DA62

FE2D 2002 13 1A FE30 2020 3A9E5B 3D FE80 CE01 FE08 2803 329E5B 0D 79 2A9B5B 2B 229B5B 62 6B 23 0E0A EDB0 4F 11A05B 3A9D5B 219F5B B6 6F 3A9E5B 67 A7 7D 2008 A7 C0 3D 329E5B 1892 A7 2801 PFEFORM: PFEXIT: PFNEZ: PFNMIN:

CP "-" JR NZ,PFNMIN INC DE LD A,(DE) CP "0" JR NZ,PFEXIT LD A,(EPOWER) DEC A CP 80H ADC A,1 CP 8 JR Z,PFNEZ LD (EPOWER),A DEC C LD A,C LD HL,(NPRPOS) DEC HL LD (NPRPOS),HL LD H,D LD L,E INC HL LD C,10 LDIR LD C,A LD DE,PRNBUFF LD A,(DIGITS) LD HL,DECPNTED OR (HL) LD L,A LD A,(EPOWER) LD H,A AND A LD A,L JR NZ,PFEFORM AND A RET NZ DEC A LD (EPOWER),A JR PFNRND AND A JR Z,PFPOWOK

;SKIP A FIRST "-" IF NEEDED

;JR IF FIRST CHAR USED IN ROUNDING ;(=div by 10 if fract: 0998->999 but 0999->1000) ;0->FF ;CY IF +VE, NZ EPOWER (FRACTION) (80H NOT CRITICAL) ;A=ORIG IF 0 OR -VE, ELSE A=A+1 ;JR IF FRACTION ROUNDED UP TO 1 ;CAN PUT IN AN EXTRA LEAD ZERO TO COMP FOR ;"MISSED" DIV COS FIRST ZERO NOT DELETED. ;COMPENSATE LEN FOR LEADING ZERO TO BE LOST ;COMPENSATE NPRPOS IN CASE 9-DIGIT INTEGER LOOP ;USED (SEE LATER)

;ALIGN TO LHS E.G. 01.23 -> 1.23

;L=0 IF NINE DIGIT INTEGER

;JR IF EFORM (FRACTIONS ARE ALWAYS NOMINALLY EFORM)

;NOW CHECK FOR 9-DIGIT INTEGERS WHICH SHOULD BE EFORM TOO ;RET IF NOT 9 DIGIT INTEGER ;POWER FF IS CORRECT FOR E+8 ;PRINT EFORMAT NUMBER ;IF A 9-DIGIT INTEGER WAS PRODUCED ;BY MULTIPLYING BY A POWER - JUMP. IF NOT, FORM ;IS EG 12345678.9 OR 12345678, BECAUSE POWER ;CHOSEN WAS TOO -VE (IN THE CASE OF BIG NUMBERS) ;OR TOO SMALL (IN THE CASE OF SMALL NUMBERS) ;IN WHICH CASE RESULT IS EFFECTIVELY 0.XE+/-H ;CHANGE TO X.XE+/-H ;NORMALLY 6, TO ALLOW UP TO 4 LEADING ZEROS ;JR IF ROUNDING MEANS *NO* LEADING ZEROS ;(0.999999->1) ;JR WITH 1 FOR 0.1, 2 FOR 0.01,... 5 FOR 0.00001

24 3A9A5B 6F 7C D608 283A BD 3845 CB7C 2801 2F 2E2F 2C D60A 30FB C63A F5 EB 09 3645 23 362B CB7A 2002 362D 23 7B FE30 2803 0C 73 23 F1 POWL10: POWSOK: NEGEFORM: CALCELP: PFPOWOK:

INC H LD A,(FRACLIM) LD L,A LD A,H SUB 8 JR Z,PFSPBH CP L JR C,PFFRACT BIT 7,H JR Z,NEGEFORM CPL LD L,2FH INC L SUB 10 JR NC,CALCELP ADD A,3AH PUSH AF EX DE,HL ADD HL,BC LD (HL),"E" INC HL LD (HL),"+" BIT 7,D JR NZ,POWSOK LD (HL),"-" INC HL LD A,E CP "0" JR Z,POWL10 INC C LD (HL),E INC HL POP AF

;"0"-1

;RESULT IN EA (POWER AS ASCII) ;HL=PRNBUFF, BC=LEN - GET PAST END

;LEN IS GREATER BECAUSE "E"+/- 2 DIGITS

DA63 DA64 DA65 DA66 DA67 DA6A DA6B DA6D DA6F DA6F DA70 DA70 DA71 DA72 DA74 DA74 DA76 DA76 DA77 DA79 DA7C DA7C DA7D DA7E DA80 DA82 DA82 DA82 DA82 DA83 DA85 DA87 DA87 DA89 DA89 DA8A DA8A DA8D DA8E DA8F DA90 DA92 DA94 DA94 DA96 DA96 DA97 DA99 DA9B DA9D DA9D DA9E DAA0 DAA0 DAA1 DAA3 DAA3 DAA6 DAA7 DAA7 DAA7 DAA7 DAA7 DAA8 DAAA DAAC DAAD DAAE DAB1 DAB2 DAB2 DAB3 DAB4 DAB5 DAB8 DABA DABC DABC DABD DABD DAC0 DAC1 DAC3 DAC4 DAC5 DAC5 DAC5 DAC5 DAC5 DAC5 DAC5 DAC5 DAC5 DAC5 DAC8 DACA DACB DACC DACD DACE DACF DAD0 DAD3

77 0C 0C 0C 21A05B 7E FE2D 2001 23 23 7E FE45 282D 0C 3E01 CDA7DA 23 23 362E 1821 3C FE14 3802 3E13 47 CDA7DA 23 79 80 FE16 3802 3E15 4F 3630 3E2E 1803 77 3E30 23 10FA 11A05B C9 PFFRACT3: PFFRACT2: PFFRACT: NOMINUS2: PFSPBH:

LD (HL),A INC C INC C INC C LD HL,PRNBUFF LD A,(HL) CP "-" JR NZ,NOMINUS2 INC HL INC HL LD A,(HL) CP "E" JR Z,PFSETPRB INC C LD A,1 CALL PFSPACE INC HL INC HL LD (HL),"." JR PFSETPRB INC A CP 20 JR C,PFFRACT2 LD A,19 LD B,A CALL PFSPACE INC HL LD A,C ADD A,B CP 22 JR C,PFFRACT3 LD A,21 LD LD LD JR C,A (HL),"0" A,"." FRACLPEN

;ALLOW FOR E(SGN)1 DIGIT

;SKIP "-" ;SKIP FIRST DIGIT ;END NOW IF E.G. 1E+7 - NO PT. INSERTION ;ALLOW FOR GREATER LEN ;MAKE 1 SPACE AFTER ANY MINUS (CAN BE CONSIDERED ;AS SPACE 1 AFTER THIS, AS LOCNS MATCH) ;PT TO FIRST DIGIT ;PT TO SPACE AFTER 1ST DIGIT

;PRINT FRACTION - INSERT LEADING 0./0.0/0.00 ETC. ;LIMIT TO 17 LEADING ZEROS (FOR PRINT USING)

;B=2-6, C=LEN ;2=0.1, 8=0.0000001 ;PT TO SPACE

;NEW LEN (MAX=21) ;DECIMAL PT. ON FIRST LOOP ONLY

FRACLZLP: FRACLPEN: PFSETPRB:

LD (HL),A LD A,"0" INC HL DJNZ FRACLZLP LD DE,PRNBUFF RET ;BC=LEN

;ENTRY: A=SPACE TO OPEN AFTER ANY MINUS SIGN IN PRNBUFF. (1-19D BYTES) ;EXIT: HL=BEFORE SPACE. BC SAVED C5 26FF ED44 6F E5 011500 09 44 4D E1 3AA05B FE2D 2001 0D 11B45B 19 EDB8 C1 C9 PFSKMIN: PFSPACE: PUSH BC LD H,0FFH NEG LD L,A PUSH HL LD BC,21 ADD HL,BC LD B,H LD C,L POP HL LD A,(PRNBUFF) CP "-" JR NZ,PFSKMIN DEC C LD DE,PRNBUFF+20 ADD HL,DE LDDR POP BC RET ;1 LESS IF LEADING MINUS - LEAVE IT ALONE ;DEST=END OF BUFFER ;SRC IS SOME BYTES BEFORE

;HL=-SPACE ;BUFF LEN (ACTUALLY, OVERLAPS BCD BUFF, BUT OK) ;MAX TO MOVE IS 15; LESS IF BIGGER GAP WANTED ;MIN IS 1

;******************************************************************************* ;PRFPBUF - "PRINT" A NUMBER (ON FPCS) TO PRNBUFF IN "RAW" STATE. (NO ROUNDING ;OR LEADING ZEROS, NO E+/-, ETC.) ;EXIT: (9-DIGITS)=SIGNIF DIGS IN PRNBUFF. EPOWER=POWER OF 10 USED IF EFORM ;NO DECIMAL PT IF EFORM. ;LEADING MINUS IF -VE, ALWAYS 1 LEADING ZERO. ;E.G. -0.123 OR 01234.5 OR 01.2345 219D5B 360A 23 AF 77 23 77 23 229B5B PRFPBUF: LD HL,DIGITS LD (HL),10 INC HL XOR A LD (HL),A INC HL LD (HL),A INC HL LD (NPRPOS),HL ;DIGITS ALLOWED ;POWER=0 "NOT EFORMAT" ;"NO DECIMAL PT USED YET" ;PRINT POSN=BUFFER START

DAD3 DAD4 DAD5 DAD6 DAD7 DAD7 DADA DADB DADB DADC DADD DADF DAE0 DAE0 DAE2 DAE5 DAE8 DAE9 DAEA DAEB DAEB DAED DAEF DAEF DAF1 DAF3 DAF5 DAF5 DAF6 DAF7 DAF9 DAFA DAFB DAFC DAFD DAFE DAFF DB00 DB01 DB02 DB03 DB04 DB07 DB08 DB0B DB0C DB0D DB0D DB0E DB0F DB10 DB11 DB12 DB13 DB13 DB13 DB13 DB13 DB13 DB13 DB16 DB17 DB18 DB19 DB19 DB1A DB1D DB1E DB1F DB22 DB23 DB24 DB27 DB29 DB29 DB2A DB2A DB2A DB2A DB2B DB2E DB2F DB30 DB30 DB30 DB30 DB31 DB33 DB34 DB35 DB36 DB37 DB38 DB39 DB3A DB3B DB3C DB3C DB3C DB3C DB3C DB40 DB42

EF 31 07 33 210500 19 EB 23 CB7E 2B 3E2D C473DB CD67DB 7E A7 C8 FE81 384D D680 FE1E 3047 23 56 CBFA 23 5E 23 D5 D9 E1 D9 56 23 5E EB CD95DB EB CDB5DB EB D8 7C B5 D9 B4 B5 C8 PRMEDN:

DB DB DB DB

CALC RESTACK DROP EXIT

;DE=DROPPED NUMBER

LD HL,5 ADD HL,DE EX DE,HL INC HL BIT 7,(HL) DEC HL LD A,"-" CALL NZ,NPRINT CALL NPRZERO LD A,(HL) AND A RET Z CP 81H JR C,PRBORS SUB 80H CP 30 JR NC,PRBORS INC HL LD D,(HL) SET 7,D INC HL LD E,(HL) INC HL PUSH DE EXX POP HL EXX LD D,(HL) INC HL LD E,(HL) EX DE,HL CALL DECIMIZE EX DE,HL CALL PRBCD EX DE,HL RET C LD A,H OR L EXX OR H OR L RET Z ;HL=NUMBER, DE=OLD STKEND ;NZ IF -VE ;MINUS PRINTED BEFORE -VE NUMBERS ;LEADING ZERO IS USEFUL FOR ROUNDING UP LATER ;EXIT WITH "0" IF ZERO ;JR IF NO BITS BEFORE BINARY POINT (<1) ;=BITS BEFORE BINARY POINT (1-7F) ;IF MORE THAN 29 BITS - MIGHT NOT FIT IN 9 DIG. BCD ;TRUE NUMERIC BIT

;MSW TO HL"

;LSW TO HL ;CONVERT "A" BITS OF HL"HL TO BCD ;PROTECT LSW ;PRINT BCD TO PRINT BUFFER ;RET IF BUFFER FULL

;RET IF NO SIGNIF BITS LEFT

;BITS REMAINING IN HL"HL ARE THE BITS AFTER THE BINARY POINT, EXP 80H FORM ;EXCEPT THERE MAY BE LEADING ZERO BITS. ;NOW PRINT HL"HL BY MULTIPLYING REPEATEDLY BY 10 TILL BUFFER FULL CD60DB EB D9 EB AF CD2ADB 55 D9 CD2ADB 55 D9 CD68DB 30F0 C9 4B CD30DB 5D 4A 69 2600 44 29 29 09 29 4F 09 7C C9 TENX PRFRACT: CALL NPRPNT EX DE,HL EXX EX DE,HL XOR A CALL TENX LD D,L EXX CALL TENX LD D,L EXX CALL NPRINTC JR NC,PRFRLP RET ;LE=DE*10+A. CY IN A LD C,E CALL TENMUL LD E,L LD C,D LD L,C LD H,0 LD B,H ADD HL,HL ADD HL,HL ADD HL,BC ADD HL,HL LD C,A ADD HL,BC LD A,H RET ;"." ;TRANSFER NUMBER TO DE"DE ;START WITH CARRY OF ZERO ;LE=DE*10+A ;DE=DE*10. A=CY ;LE=DE*10+A ;DE=DE*10. A=CY ;LOOP UNTIL BUFFER FULL

PRFRLP:

;HL=C*10+A. TENMUL:

;*5 ;*10 ;A=CARRY FOR NEXT TIME, L=RESULT

;NUMBERS LESS THAN 1 HAVE EXPONENTS OF 1-80H. EXP 80H MEANS THAT THERE ARE ;NO ZERO BITS AFTER THE BINARY POINT, EXP 71H MEANS THERE ARE 15 BITS, ETC. ED53655C 3007 PRBORS: LD (STKEND),DE JR NC,PRBIGN ;PUT NUMBER BACK ON FPCS ;JR IF BIG

DB42 DB45 DB47 DB49 DB49 DB49 DB49 DB49 DB4C DB4E DB4F DB4F DB50 DB53 DB54 DB57 DB57 DB5A DB5B DB5D DB60 DB60 DB62 DB65 DB67 DB67 DB68 DB68 DB68 DB68 DB6A DB6B DB6E DB6F DB71 DB71 DB72 DB73 DB73 DB73 DB73 DB74 DB74 DB75 DB75 DB78 DB79 DB7A DB7D DB7E DB7F DB7F DB7F DB7F DB7F DB7F DB7F DB80 DB82 DB83 DB83 DB86 DB86 DB87 DB88 DB8B DB8D DB8E DB8F DB90 DB91 DB91 DB92 DB93 DB94 DB95 DB95 DB95 DB95 DB96 DB96 DB97 DB99 DB9C DB9C DB9D DB9E DBA0 DBA0 DBA1 DBA2 DBA4 DBA5 DBA5 DBA8 DBAA DBAA DBAB DBAC DBAC DBAD DBAE DBAF

CD7FDB C609 1806

CALL DECDIGN ADD A,9 JR SHIFTDEC

;GET MAX LEADING ZEROS (DECIMAL). 0 OR MORE ;GET AN INTEGER OF 8 OR 9 DIGITS

;NUMBER WITH EXP 9E-FFH (NOW 1E-7FH) - AT LEAST 9 DEC DIGITS CD83DB D609 2F 3D 329E5B 3C CDD4DB CD121D 7E D680 C3F5DA 3E2E 329F5B 180C AF C630 E5 219D5B 35 2003 37 21 E5 A7 2A9B5B 77 23 229B5B E1 C9 NPRINT: NPRINT2: NPRINT3: NPRPNT: NPRZERO: NPRINTC: PRBIGN: SHIFTDEC: CALL DECDIGP SUB 9 CPL DEC A LD (EPOWER),A INC A CALL POFTEN CALL FDELETE LD A,(HL) SUB 80H JP PRMEDN LD A,"." LD (DECPNTED),A JR NPRINT XOR A ADD A,30H PUSH HL LD HL,DIGITS DEC (HL) JR NZ,NPRINT2 SCF DB 21H PUSH HL AND A LD HL,(NPRPOS) LD (HL),A INC HL LD (NPRPOS),HL POP HL RET ;NC ;FIND MAX DIGITS BEFORE DEC PT, -1. (9 OR MORE) ;0 OR MORE. ;-1 OR LESS. GET AN INTEGER OF 8 OR 9 DIGITS ;..FE=E+9,FF=E+8. GAP=0. 9=E-1,10=E-2... ;GET N1**A (SIGNED). EXIT WITH RESULT ON FPCS ;A=EXP OF DELETED RESULT ;HL PTS TO DROPPED NUMBER (NOW LARGE INTEGER) ;SHOW NON-INTEGER

;PRINT "A" AND DEC "DIGITS TO COME". CY IF BUFFER FULL (CHAR STILL ENTERED, THO)

;JR IF SPACE OK ;CY=BUFFER FULL ;"JR+2"

;THIS ENTRY FOR CHARS THAT DON"T COUNT - LIKE "-" AND "."

;FIND HOW MANY DECIMAL DIGITS-1 THERE ARE IN A POWER OF TWO (MAXIMUM) ;ENTRY WITH A=POWER OF 2 (-VE IF ENTRY AT DECDIGN) ;EXIT WITH A=DECIMAL DIGITS BEFORE POINT-1 IF DECDIGP OR ZEROS AFTER ;PT. IF DECDIGN 4F 3E80 91 CDDA1C EF 27 7F1A20 9A85 00 30 07 33 13 13 1A C9 4F AF 0605 11B05B 12 13 10FC 29 D9 ED6A D9 11B45B 0605 1A 8F 27 12 1B 10F9 DECIMBLP: ZBCDBLP: DECIMCLP: DECIMIZE: DECDIGN: DECDIGP: LD C,A LD A,80H SUB C CALL STACKA DB DB DB DB DB DB DB DB CALC FIVELIT 7FH,1AH,20H 9AH,85H MULT TRUNC DROP EXIT ;1-80H->7F-00H

;0.30103

INC DE INC DE LD A,(DE) RET ;CONVERT A BITS IN HL"HL TO ASCI IN PRNBUFF. RESULT MAY HAVE UP TO 10 BCD DIGITS LD C,A XOR A LD B,5 LD DE,BCDBUFF LD (DE),A INC DE DJNZ ZBCDBLP ADD HL,HL EXX ADC HL,HL EXX LD DE,BCDBUFF+4 LD B,5 LD A,(DE) ADC A,A DAA LD (DE),A DEC DE DJNZ DECIMBLP ;ZERO 5-BYTE BCD BUFFER.

;SHIFT LEFT BITS IN HL"HL, TO CY ;PT TO RHS BYTE IN BCD BUFFER ;FOR FIRST BYTE, ADD IN CY FROM HL"HL SHIFT ;FOR LATER BYTES, ADD IN CY FROM PREVIOUS DAA

DBB1 DBB1 DBB2 DBB4 DBB4 DBB5 DBB5 DBB5 DBB5 DBB5 DBB5 DBB5 DBB7 DBB9 DBB9 DBBB DBBE DBBE DBC0 DBC0 DBC1 DBC3 DBC3 DBC5 DBC5 DBC6 DBC8 DBC8 DBC9 DBCB DBCD DBCE DBCE DBD1 DBD3 DBD3 DBD4 DBD4 DBD4 DBD4 DBD5 DBD7 DBD9 DBD9 DBDB DBDB DBDC DBDC DBDD DBDE DBDF DBDF DBE1 DBE1 DBE2 DBE3 DBE4 DBE4 DBE5 DBE5 DBE7 DBE9 DBE9 DBEB DBED DBED DBEE DBEF DBF0 DBF1 DBF2 DBF2 DBF4 DBF4 DBF5 DBF6 DBF7 DBF8 DBF9 DBF9 DBFA DBFC DBFC DBFF DC00 DC00 DC00 DC00 DC00 DC00 DC02 DC05 DC05 DC07 DC0A DC0A DC0E DC11 DC13 DC15 DC17 DC17 DC19

0D 20EC C9

DEC C JR NZ,DECIMCLP RET

;SHIFT C BITS

;PRINT CONTENTS OF 10-DIGIT BCD BUFFER TO PRINT BUFFER AS ASCII. ;EXITS IF ALL BCD DIGITS USED (NC), OR, IF PRINT BUFFER IS PART-FILLED ON ENTRY, ;WHEN DIGIT COUNT REACHES 00 (CY) ;USES HL,BC,AF 0E01 3E0F 0605 21B45B ED6F 2B 10FB 2003 B1 20F1 48 E60F FE0A D0 CD68DB 30E6 C9 4F CB79 2802 ED44 47 EF EC 33 1804 EF 25 00 33 CB38 3010 CB79 2007 EF D0 00 D8 33 1805 EF D0 05 D8 33 04 10E5 22655C C9 POF10L2: POF10LPE: POF10LP: POF10L1: POFTEN: PRDIGIT: PRBCD: BCDDIG: BCDROTL: LD C,1 LD A,0FH LD B,5 LD HL,BCDBUFF+4 RLD DEC HL DJNZ BCDROTL JR NZ,PRDIGIT OR C JR NZ,BCDDIG LD C,B AND 0FH CP 0AH RET NC CALL NPRINTC JR NC,BCDDIG RET ;POWER-OF-TEN. MULT. TOP OF FPCS BY 10**"A" REG. WORKS WITH -VE POWERS (A>80H) LD C,A BIT 7,C JR Z,POF10L1 NEG LD B,A DB CALC DB STKTEN DB EXIT JR POF10LPE DB CALC DB DUP DB MULT DB EXIT SRL B JR NC,POF10L3 BIT 7,C JR NZ,POF10L2 DB DB DB DB DB DB DB DB DB DB CALC STO0 MULT RCL0 EXIT CALC STO0 DIVN RCL0 EXIT ;JR IF NO MULT/DIV ON THIS BIT ;JR IF -VE POWER - USE DIV ;N1,P ;N1*P ;N1*P,P ;B=ABSOLUTE POWER (CORRUPTS!) BC IS SAVED BY SAM ;FPCS ;N1,10 (CURRENT POWER. CALL IT P) ;JUMP INTO THE LOOP ;N1*P,P,P ;N1*P,P*P. DOUBLE POWER (WE ARE MOVING MORE SIGNIF ;BITS RIGHT IN B) ;BIT 7, C=1 IF -VE POWER ;JR IF LAST RLD GAVE A REG A NZ DIGIT ;NZ IF "LEADING ZERO" STATUS ;IGNORE ANY. ELSE A=0 FOR NON-LEADING ZERO ;C=0 - NO LEADING ZEROS NOW ;RET IF TERMINATOR HIT ;LOOP UNTIL DIGIT COUNT SHOWS FULL ;NZ C SIGNALS "LEADING ZEROS - IGNORE" ;CLEAR LHS OF A, AND MARK RHS WITH NON-BCD DIGIT ;BCD ROTATE OF 5 BYTES ;RHS NIBBLE OF (HL) TO A, LHS NIBBLE TO RHS, ;RHS NIBBLE OF A TO RHS OF (HL)

JR POF10L3 ;N1,P ;N1/P ;N1/P,P ;JUMP IF B NOT SHIFTED TO ZERO YET ;HL PTS TO LAST VALUE (HL IS SET BY "EXIT") ;DELETE LAST POWER, LEAVE N1**A ON FPCS

POF10L3:

INC B DJNZ POF10LP LD (STKEND),HL RET

INCLUDE TPRINT.SAM ;TPRINT.SAM - PRINT ASCII AND CR. FE20 DAC4DD FE80 D2ABDC ED5B365C 213B5C CBC6 FE20 2802 CB86 PRASCII: PROM1: CP 20H JP C,PRCRLCDS CP 80H JP NC,PRGR80 LD DE,(CHARS) LD HL,FLAGS SET 0,(HL) CP 20H JR Z,PRINTMN1 RES 0,(HL) ;'SPACE WAS LAST CHAR' ;'LAST CHAR WAS NOT SPACE'

DC19 DC1A DC1C DC1D DC1E DC1F DC20 DC20 DC23 DC24 DC24 DC24 DC24 DC27 DC28 DC2A DC2A DC2B DC2C DC2D DC2E DC30 DC33 DC35 DC36 DC39 DC3A DC3B DC3E DC3F DC41 DC41 DC42 DC43 DC45 DC45 DC46 DC49 DC4A DC4B DC4C DC4C DC4D DC50 DC52 DC53 DC54 DC55 DC58 DC59 DC5D DC60 DC61 DC62 DC62 DC65 DC66 DC68 DC68 DC69 DC6B DC6B DC6E DC6F DC6F DC72 DC73 DC73 DC76 DC77 DC77 DC7A DC7B DC7C DC7C DC7F DC81 DC83 DC83 DC86 DC88 DC8B DC8B DC8E DC8F DC90 DC93 DC95 DC98 DC99 DC9A DC9D DCA0 DCA1 DCA4 DCA5 DCA5 DCA8 DCAB DCAB DCAB DCAB DCAC

6F 2600 29 29 29 19 32725A 47 CD893D BB 3022 1D 93 4F C5 1EFF 3A735A C6FE E5 CDA2DE E1 C1 3ABD5A A7 28E3 79 A7 20DF C5 CD6AF4 F1 D7 C9 D5 3A535A FE01 9F 2F 47 3A545A 4F DD2AD25B CD2D00 E1 2C 3A735A A7 280B 3D 2804 22705A C9 226E5A C9 226C5A C9 3AB75A A7 C0 3A735A FE02 2822 3A365A FE10 DA393C CDEDDF C5 D5 CD393C 3E08 32825B D1 C1 213151 CD393C AF 32825B C9 3A725A C3D1DE 4F 3ABA5A

PRINTMN1:

LD L,A LD H,0 ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,DE LD (OPCHAR),A LD B,A CALL POFETCH CP E JR NC,PRNONWLN DEC E SUB E LD C,A PUSH BC LD E,0FFH LD A,(DEVICE) ADD A,0FEH PUSH HL CALL PRENTER POP HL POP BC LD A,(INDOPFG) AND A JR Z,NLENTRY LD A,C AND A JR NZ,NLENTRY PUSH BC CALL INDOPEN POP AF RST 10H RET

;HL PTS TO CHAR DATA ;USED BY LPRINT

IOPENT:

;FROM POUDGS, AND AFTER CR NLENTRY: ;GET DE=COL/ROW, A=RHS LIMIT ;CURRENT COL ;JR IF COL=LESS THAN OR EQUAL TO RHS LIMIT ;Z IF JUST 1 PAST RHS LIMIT - LINE FULL; ELSE CR ;WAS USED JUST BEFORE ;COL FF SHOWS 'RECURSIVE' CR ;CY IF PRINTER ;GET CHAR PATTERN BACK ;B=CHAR CODE ;JR IF NO INDENT O/P WANTED - NOT LISTING.

;O/P SPACES IF POSN WAS JUST 1 PAST RHS LIMIT ;LINE WAS FULL. ELSE CR WAS USED. ;CURRENT PRINT POSN ;0-3 ;0->CY ;0->FF ;0->00, 1,2,3->FF ;0=INVERSE 0, FF=INVERSE 1 ;USUALLY=ENDOUTP ;POSN ;MOVE RIGHT ;0=UPPER SCREEN, 1=LOWER, 2=PRINTER OR OTHER

PRNONWLN:

PUSH DE LD A,(OVERT) CP 1 SBC A,A CPL LD B,A LD A,(INVERT) LD C,A LD IX,(PATOUT) CALL IXJUMP POP HL INC L LD A,(DEVICE) AND A JR Z,POSUSCRN DEC A JR Z,POSLSCRN LD (PRPOSN),HL RET

POSTORE:

;L=PRINTER COL

POSLSCRN: POSUSCRN: ENDOUTP:

LD (SPOSNL),HL RET LD (SPOSNU),HL RET LD A,(DMPFG) AND A RET NZ LD A,(DEVICE) CP 2 JR Z,ENDOP2 LD A,(CSIZE) CP 16 JP C,EPSUB CALL DBCHAR PUSH BC PUSH DE CALL EPSUB LD A,8 LD (DHADJ),A POP DE POP BC LD HL,MEMVAL+16 CALL EPSUB XOR A LD (DHADJ),A RET ;JR IF PRINTER ;JR IF NOT DOUBLE HEIGHT ;EXITS WITH HL PTING TO DOUBLE HEIGHT CHAR MATRIX ;PRINT TOP HALF ;ADJUST ADDRESSES TO PRINT 8 SCANS LOWER ;PTR TO BOTTOM HALF

ENDOP2:

LD A,(OPCHAR) JP CHBOP LD C,A LD A,(INQUFG)

;SEND CHAR ON 'B' CHANNEL

;******************************************************************************* PRGR80: ;BIT 0=1 IF IN QUOTES

DCAF DCB0 DCB1 DCB4 DCB5 DCB6 DCB8 DCB8 DCB9 DCBB DCBB DCBE DCBE DCBE DCBE DCC1 DCC4 DCC4 DCC5 DCC8 DCC8 DCCA DCCD DCCF DCD1 DCD1 DCD3 DCD5 DCD8 DCD9 DCDB DCDB DCDC DCDF DCE0 DCE2 DCE2 DCE3 DCE6 DCE8 DCE8 DCE8 DCE8 DCE8 DCEB DCEE DCEE DCF1 DCF3 DCF5 DCF7 DCF7 DCF9 DCFB DCFB DCFE DD00 DD02 DD02 DD04 DD04 DD04 DD07 DD09 DD0B DD0B DD0D DD0F DD0F DD11 DD11 DD13 DD16 DD16 DD17 DD18 DD19 DD1B DD1B DD1C DD1D DD1E DD21 DD24 DD26 DD26 DD27 DD28 DD28 DD29 DD29 DD2A DD2A DD2B DD2E DD2E DD2F DD31 DD31 DD34 DD35 DD37 DD3A

0F 67 3A715C B4 17 3803 79 FE85 DA7DDD 2ADE5A CD10F2 3C CAE8DC D686 11BCF9 FE1B 3857 D61B 2620 112FFA BC 384D 94 11CBFA BC 3846 94 1167FB 1840 POUDGH: PRGR802:

RRCA LD H,A LD A,(FLAGX) OR H RLA JR C,POUDGH LD A,C CP 85H JP C,POUDG LD HL,(PRTOKV) CALL JPOPT INC A JP Z,POFN SUB 86H LD DE,KWDS85 CP 1BH JR C,POBTL SUB 1BH LD H,20H LD DE,KWDSA0 CP H JR C,POBTL SUB H LD DE,KWDSC0 CP H JR C,POBTL SUB H LD DE,KWDSE0 JR POBTL ;USED BY CHANNEL 'R'

;BIT 7=1 IF INPUT LINE ;JR IF IN QUOTES, OR INPUT LINE - PRINT UDGS, ;NOT TOKENS ;80-84H ARE ALWAYS UDGS

;JP IF FF FN LEADER ;(PLUS 1 TO COMPENSATE FOR INC) ;SPLIT CMDS LIST INTO 4 SUB-LISTS FOR SPEED ;85-9FH ;A0-BF

;C0-DF

;E0-FE

;******************************************************************************* ;ROUTINES FOR PRINTING ERROR MSGS, CMDS, FNS, MSGS 11AD3D C3EBDE CD7204 D63B FE18 380D D63F 3816 11A3F9 FE07 3826 1822 11C9F8 FE07 280B FE08 2807 1815 C627 112AF9 A7 F5 37 180F 37 F5 F5 21CB50 CD4FDD 1808 37 26 A7 F5 F5 CD4CDD F1 3809 3A3B5C 1F 3E20 D41000 POFPCFN: POTRNL: POIMFN: POFN: PSTFF2: LD DE,POSTFF JP SVSETOP CALL RESTOP SUB PITOK CP SINTOK-PITOK JR C,POIMFN SUB MODTOK-PITOK JR C,POFPCFN ;SAVE CURRENT O/P ADDR AND SET O/P ADDR TO DE ;RESTORE O/P ADDR. A= CHAR PRINTED AFTER FF ;JR IF IMMEDIATE FN ;JR IF FPC FN

LD DE,BINFNTL ;BINARY FN TOKEN LIST CP ANDTOK-MODTOK+1 JR C,POBTL ;MOD-AND (BIN OPS) HAVE LEADING AND TRAILING SPACE JR POMSP2 LD DE,IMFNTL CP FNTOK-PITOK JR Z,POTRNL CP BINTOK-PITOK JR Z,POTRNL JR POMSP2 ;<>, >=, <= HAVE NO SPACES ;IMMEDIATE FN TOKEN LIST

;FN AND BIN HAVE TRAILING BUT NO LEADING SPACES ;REST HAVE NEITHER

ADD A,MODTOK-SINTOK LD DE,FPCFNTL ;FPC FN TOKEN LIST AND A PUSH AF SCF JR POGEN1 SCF PUSH AF PUSH AF LD HL,MSGBUFF+11 CALL POMSR2 JR POGEN2 SCF DB 26H AND A PUSH AF PUSH AF CALL POMSR POP AF JR C,POMSG3 LD A,(FLAGS) RRA LD A," " CALL NC,0010H ;NO LEADING OR TRAILING SPACES ;"JR+1". FOR MSGS OR E.G. PI/ITEM/POINT ;BOTH TRAILING AND LEADING SPACES ;TRAILING STATUS ;LEADING STATUS ;GET MSG TO BUFFER ;LEADING STATUS ;NO LEADING SPACE FOR MSG OR FNS (EXCEPT AND/OR) ;TRAILING SPACE ;NO LEADING SPACE

POMSPX:

POMSP2: POBTL: POGEN: POGEN1: POGEN2:

;PRINT LEADING SPACE IF PREVIOUS CHAR WASN'T ONE

DD3A DD3D DD3E DD3F DD3F DD40 DD41 DD43 DD45 DD45 DD47 DD48 DD48 DD4A DD4B DD4C DD4C DD4C DD4C DD4F DD4F DD50 DD53 DD54 DD55 DD57 DD58 DD59 DD5A DD5A DD5B DD5C DD5E DD5E DD5F DD60 DD61 DD63 DD63 DD65 DD65 DD66 DD68 DD6A DD6C DD6C DD6D DD70 DD73 DD74 DD75 DD75 DD76 DD77 DD77 DD78 DD79 DD7A DD7C DD7C DD7C DD7D DD7D DD7D DD7D DD7D DD80 DD82 DD84 DD84 DD85 DD88 DD8B DD8E DD8E DD91 DD92 DD93 DD95 DD95 DD97 DD99 DD99 DD9C DD9F DDA0 DDA2 DDA2 DDA3 DDA4 DDA6 DDA6 DDA8 DDA8 DDA9 DDAA DDAC DDAC DDAD DDAE DDB1 DDB1 DDB4

CD1300 F1 D8 1B 1A FE41 3003 FE24 C0 3E20 D7 C9 21C050 E5 CD5ADD D1 A7 ED52 44 4D C9 47 04 1805 1A 13 17 30FB 10F9 1A E67F FE20 3009 D5 1119F8 CD5ADD D1 01 77 23 1A 13 17 30E9 C9

POMSG3:

CALL PRINTSTR POP AF RET C DEC DE LD A,(DE) CP "A" JR NC,POMSG4 CP "$" RET NZ

;OUTPUT BC FROM (DE) ;RET IF NO TRAILING SPACE WANTED ;LAST CHAR ;JR IF LETTER - DO TRAILING SPACE ;'$' IS ALSO FOLLOWED BY A SPACE, BUT NOT =/>/#

POMSG4:

LD A," " RST 10H RET LD HL,MSGBUFF PUSH HL CALL POMSR3 POP DE AND A SBC HL,DE LD B,H LD C,L RET LD B,A INC B JR POMSR4 LD A,(DE) INC DE RLA JR NC,LKHIBTLP DJNZ LKHIBTLP LD A,(DE) AND 7FH CP 20H JR NC,MVWORD2 PUSH DE LD DE,COMPLIST CALL POMSR3 POP DE DB 01H ;WITH ABOUT 4 CHARS/TOKEN, TAKES ABOUT 0.7 MS ;(ON SAM) TO FIND 30TH WORD. ;BUFFER START ;BUFFER ST ;LEN

;A=MSG NUMBER 00->, DE=START OF MSG LIST POMSR: POMSR2:

POMSR3: LKHIBTLP:

POMSR4: MVWORDLP:

;JR WITH ALL EXCEPT COMPRESSION CODES 00-1F ;SAVE MAIN MSG PTR ;LIST OF COMPRESSION CODED WORDS ;RECURSIVE CALL ;MAIN MSG PTR ;'JR+2'

MVWORD2: MVWORD3:

LD (HL),A INC HL LD A,(DE) INC DE RLA JR NC,MVWORDLP RET

;MAIN MSG CAN HAVE COMP CODES AND ASCII. BIT 7 IS ;HI IN LAST CHAR. COMPRESSED WORD CANNOT HAVE COMP ;CODES.

;******************************************************************************* 3A735A FE02 200A 79 32725A 2AF85A CD10F2 3A345A A7 79 201C FE90 3018 CD3DD8 212151 E5 0604 73 23 10FC 0604 72 23 10FC E1 41 C324DC 2A7D5C D6A9 POFUDG: BKGRL2: BKGRL1: PUDGS: POUDG: LD A,(DEVICE) CP 2 JR NZ,PUDGS LD A,C LD (OPCHAR),A LD HL,(LPRTV) CALL JPOPT LD A,(BGFLG) AND A LD A,C JR NZ,POFUDG CP 90H JR NC,POFUDG CALL QUADBITS LD HL,MEMVAL PUSH HL LD B,4 LD (HL),E INC HL DJNZ BKGRL1 LD B,4 LD (HL),D INC HL DJNZ BKGRL2 POP HL LD B,C JP NLENTRY LD HL,(HUDG) SUB 0A9H ;HI UDG FOR CHARS. >A8H ;JR IF NOT PRINTER ;USED BY LPRINT ;BLOCK GRAPHICS FLAG ;JR IF FOREIGN SET/UDGS WANTED, NOT BLOCKS ;>=90H ARE FOREIGN/UDGS ANYWAY ;GET LOWER 4 BITS OF A INTO DE, QUADRUPLED

DDB6 DDB8 DDB8 DDB9 DDBC DDBF DDC0 DDC0 DDC1 DDC4 DDC4 DDC4 DDC4 DDC4 DDC4 DDC6 DDC8 DDC8 DDCA DDCC DDCC DDCD DDCF DDD2 DDD3 DDD4 DDD5 DDD6 DDD9 DDDA DDDA DDDA DDDA DDDA DDDA DDDA DDDA DDDA DDDA DDDB DDDC DDDD DDDE DDDF DDE0 DDE1 DDE2 DDE3 DDE4 DDE5 DDE6 DDE7 DDE8 DDE9 DDEA DDEB DDEC DDEC DDEC DDEC DDEC DDED DDF0 DDF1 DDF2 DDF5 DDF6 DDF9 DDFB DDFB DDFE DDFE DE01 DE02 DE04 DE04 DE05 DE06 DE07 DE08 DE09 DE0A DE0C DE0C DE0D DE0E DE0E DE0F DE0F DE10 DE10 DE11 DE11 DE13 DE14 DE16 DE16 DE17 DE17 DE18 DE19 DE1B DE1B

3008 79 1180FB 2A7B5C 19 EB C319DC POUDG1:

JR NC,POUDG1 LD A,C LD DE,0FB80H LD HL,(UDG) ADD HL,DE EX DE,HL JP PRINTMN1

;JR IF HI UDG ;COMP. FOR A BEING 80H-A8H AND UDG VAR PTING ;TO CHR$ 144

;PRINT CONTROL CODES ;******************************************************************************* ;ENTRY: JR FROM MAIN PRINT ROUTINE. A=00-1FH FE18 3053 FE06 384F 5F 1600 21D4DD 19 5E 19 4F CD893D E9 CCPTB: ; ; ; ; 12 40 43 64 BA 58 70 C1 92 38 F7 F6 F5 F4 F3 F2 F6 F5 ; ; DB PRQUERY-CCPT DB PRQUERY-CCPT-1 DB PRQUERY-CCPT-2 DB PRQUERY-CCPT-3 DB PRQUERY-CCPT-4 DB PRQUERY-CCPT-5 DB PRCOMMA-CCPTB DB PRQUERY-CCPTB-1 DB CURLF-CCPTB-2 DB CURRT-CCPTB-3 DB CURDN-CCPTB-4 DB CURUP-CCPTB-5 DB PRDELL-CCPTB-6 DB PRENTER-CCPTB-7 DB PRDELR-CCPTB-8 DB PRQUERY-CCPTB-9 DB CC1OP-CCPTB-10 DB CC1OP-CCPTB-11 DB CC1OP-CCPTB-12 DB CC1OP-CCPTB-13 DB CC1OP-CCPTB-14 DB CC1OP-CCPTB-15 DB CC2OPS-CCPTB-16 DB CC2OPS-CCPTB-17 ;0 ;1 ;2 ;3 ;4 ;5 ;6 ;7 ;8 ;9 ;10 ;11 ;12 ;13 ;14 ;15 ;16 ;17 ;18 ;19 ;20 ;21 ;22 ;23 PRCRLCDS: CP 24 JR NC,PRQUERY CP 6 JR C,PRQUERY LD E,A LD D,0 LD HL,CCPTB-6 ADD HL,DE LD E,(HL) ADD HL,DE LD C,A CALL POFETCH JP (HL) ;CONTROL CODE PTR TABLE

;D=ROW, E=COL, A=RHS MAX, CY IF LPRINTING

CLS? PRINT COMMA (EDIT) CURSOR LEFT CURSOR RIGHT CURSOR DOWN CURSOR UP DELETE LEFT ENTER DELETE RIGHT INK PAPER FLASH BRIGHT INVERSE OVER AT TAB

;******************************************************************************* ;D=LINE, E=COL 7B 21575A 96 F5 3A2F5A A7 0110F0 2803 0108F8 3A565A BB 3813 F1 A0 81 86 2B BE 3802 7E 3C 93 C8 47 3E20 D7 10FB C9 F1 41 18F6 PC25: PCOM3: OPAORZ: OPSPLP: PCOM2: PRCOMMA: LD A,E LD HL,WINDLHS SUB (HL) PUSH AF LD A,(TABVAR) AND A LD BC,0F010H JR Z,PCOM2 LD BC,0F808H LD A,(WINDRHS) CP E JR C,PC25 POP AF AND B ADD A,C ADD A,(HL) DEC HL CP (HL) JR C,PCOM3 LD A,(HL) INC A SUB E RET Z LD A," " RST 10H DJNZ OPSPLP RET POP AF LD B,C JR OPSPLP ;COL ;A=DIST FROM WIND LHS ;FOR 16-COLUMN TAB ;FOR 8-COLUMN TAB ;JR IF LINE FULL ;GET DIST DIV 16 OR DIV 8 ;ADD 16 OR 8 ;ABS DESIRED COLUMN ;PT TO RHS ;JR IF NEW POSN WOULD NOT REACH RHS MAX

OPASPACES: LD B,A

DE1B DE1D DE1E DE1F DE1F DE1F DE1F DE1F DE22 DE23 DE26 DE28 DE28 DE29 DE2A DE2C DE2C DE2D DE2D DE2E DE31 DE31 DE31 DE32 DE35 DE37 DE37 DE39 DE39 DE3C DE3D DE3E DE3E DE3F DE41 DE41 DE41 DE44 DE45 DE48 DE49 DE4C DE4E DE50 DE50 DE50 DE50 DE52 DE52 DE54 DE55 DE58 DE5A DE5B DE5C DE5C DE5C DE5C DE5F DE60 DE63 DE64 DE66 DE66 DE67 DE67 DE68 DE6A DE6D DE70 DE71 DE73 DE74 DE74 DE74 DE74 DE74 DE74 DE74 DE74 DE76 DE76 DE76 DE76 DE79 DE7A DE7D DE7E DE81 DE84 DE87 DE87 DE8A DE8A DE8C DE8D DE8F DE8F DE90 DE93 DE94 DE97 DE98

3E3F D7 C9

PRQUERY:

LD A,"?" RST 10H RET

;******************************************************************************* ;CURSOR LEFT/UP/RIGHT 3A575A BB 3A565A 2809 1D BB 3001 5F EB C362DC 5F 3A735A C6FE 38E2 3A585A BA C8 15 18EC 2A535A E5 3A515A F5 210100 0601 1837 38C9 3E08 D7 CD74DE 3E08 D7 C9 3A585A 4F 3A8D5B 91 3001 AF 4F 1E05 CD1A08 CD74DE 79 265B C9 EROC3: EROC2: CURRT: POSTOREH: CURLF2: CURUP: CURLF: LD CP LD JR A,(WINDLHS) E A,(WINDRHS) Z,CURLF2

;JR IF AT LHS OF WINDOW ;DEC COL. ;JR IF NOT PAST RHS ('LINE FULL') ;ELSE COL=RHS

DEC E CP E JR NC,POSTOREH LD E,A EX DE,HL JP POSTORE LD E,A LD A,(DEVICE) ADD A,0FEH JR C,PRQUERY LD A,(WINDTOP) CP D RET Z DEC D JR POSTOREH LD HL,(OVERT) PUSH HL LD A,(M23PAPT) PUSH AF LD HL,0001H LD B,1 JR SPOX JR C,PRQUERY LD A,8 RST 10H CALL SPO0 LD A,8 RST 10H RET LD A,(WINDTOP) LD C,A LD A,(LNPTR) SUB C JR NC,EROC3 XOR A LD C,A LD E,5 CALL ATSR2 CALL SPO0 LD A,C LD H,LPT/256 RET

;COL=RHS ;CY IF PRINTER (DEVICE 2) ;PRINT '?' IF LPRINTING - POSN UNCHANGED ;RET IF WE ARE AT TOP OF WINDOW ;UP A ROW. C=RHS+1 ;OVERT/INVERT ;OVER 1;INVERSE 0

;DELETE LEFT PRDELL: ;JR IF LPRINTING ;BACKSPACE ;PRINT OVER 0;' '; ;BACKSPACE

;ERASE OLD CURSOR, GET H=TABLE MSB, GET C=LNPTR ;ALLOW FOR WINDOW

;PRINT AT A,5; ;ERASE OLD CURSOR

;DELETE RIGHT=SPACE (OVER 0) PRDELR: ;PRINT OVER 0;INVERSE 0;" "; (IN PERMANENT PAPER IF MODES 2 AND 3) 0601 2A535A E5 3A515A F5 3A485A 32515A 210000 22535A 3E20 D7 10FB F1 32515A E1 22535A C9 SPO0: OPBSP: LD B,1 LD HL,(OVERT) PUSH HL LD A,(M23PAPT) PUSH AF LD A,(M23PAPP) LD (M23PAPT),A LD HL,0000H LD (OVERT),HL LD A,20H RST 10H DJNZ OPSL POP AF LD (M23PAPT),A POP HL LD (OVERT),HL RET ;PRINT SPACE ;1 SPACE ;OVERT/INVERT ;O/P B SPACES (OVER 0;INVERSE 0)

;PERM PAPER ;OVER 0, INVERSE 0

SPOX: OPSL:

DE98 DE99 DE9B DE9E DE9F DEA0 DEA2 DEA2 DEA4 DEA4 DEA5 DEA7 DEA9 DEA9 DEAC DEAD DEAF DEAF DEB0 DEB3 DEB4 DEB5 DEB5 DEB6 DEB7 DEBA DEBC DEBC DEBC DEBE DEBE DEBF DEC0 DEC0 DEC3 DEC3 DEC5 DEC8 DEC9 DECC DECF DED0 DED1 DED1 DED4 DED7 DED8 DEDB DEDB DEDB DEDB DEDB DEDB DEDB DEDB DEDB DEDB DEDE DEE0 DEE0 DEE0 DEE0 DEE3 DEE3 DEE6 DEE7 DEEA DEEB DEEB DEEB DEEB DEEC DEEF DEF0 DEF3 DEF3 DEF6 DEF6 DEF7 DEF8 DEFA DEFD DEFD DEFF DEFF DEFF DEFF DF02 DF03 DF04 DF05 DF07 DF07 DF0A DF0B DF0C DF0D DF0D DF0F DF0F DF10 DF11 DF12

D5 1EFE CDA2DE D1 6B 181E 381F 7B FEFE 3813 3A595A BA 2006 D5 CD51DF D1 15 14 1C 3A575A 2802 3EFE 5F EB C362DC 3E0D CDD1DE AF 32705A 3A0F5A A7 C8 2A4F5C 111900 19 C3C701

CURDN:

PUSH DE LD E,0FEH CALL PRENTER POP DE LD L,E JR PRENT5 JR C,LPRENT LD A,E CP 0FEH JR C,PRENT3 LD A,(WINDBOT) CP D JR NZ,PRENT2 PUSH DE CALL SCRLSCR POP DE DEC D

;SAVE COL. ;FORCE ACTUAL MOVE DOWN ;EXIT WITH HL=POSN ;UNCHANGED COL. ;JR IF LPRINT ;COL ;IF PREVIOUS CHAR WAS NOT CR, JUST SET COL 0FEH. ;('LINE FULL') ELSE DROP DOWN A LINE ;JR IF NOT ON BOTTOM LINE ALREADY ;SCROLL WINDOW UP ;LINE VALUE WILL END AS BOTTOM LINE STILL ;DOWN A LINE ;Z IF COL WAS FF (RECURSIVE) ;JR IF WAS RECURSIVE CR FROM 'LINE FULL' - LHS COL ;FOR CHAR COMING NEXT ;'LINE FULL, NOT RECURSIVE'

PRENTER:

PRENT2:

INC D INC E LD A,(WINDLHS) JR Z,PRENT4 LD A,0FEH LD E,A EX DE,HL JP POSTORE LD A,0DH CALL CHBOP XOR A LD (PRPOSN),A LD A,(AFTERCR) AND A RET Z LD HL,(CHANS) LD DE,25 ADD HL,DE JP HLJPI LD E,(HL) INC HL LD D,(HL) EX DE,HL JP (HL)

PRENT3: PRENT4: PRENT5: LPRENT:

;O/P CR ON CHANNEL 'B'

;ELSE LPRINT LF IF (AFTERCR)= 0AH CHBOP: ; ; ; ; ; ;PT TO CHANNEL B

;HL=O/P ADDR (USUALLY 'SENDA')

;CONTROL CODES WITH OPERANDS ;ONE OPERAND - INK, PAPER, OVER, INVERSE, BRIGHT, FLASH 11A73D 1803 117D04 CDEBDE 79 32BE5B C9 D5 CD46DF D1 C37604 2ABE5B 57 7D FE16 DA8113 2817 CD893D 4F BB 7C 380B 3A575A 84 93 C8 3003 7C 89 93 CC1OP: LD DE,CCRESTOP JR SETADCOM LD DE,PRERESTOP CALL SVSETOP LD A,C LD (TVDATA),A RET PUSH DE CALL SVCUROP POP DE JP POCHNG LD HL,(TVDATA) LD LD CP JP D,A A,L 16H C,PRCOITEM ;H=1ST OPERAND (IF 2),L=CONTROL CODE ;LAST OPERAND (ONLY OPERAND IF 1, ELSE 2ND) ;CONTROL CODE ;JR IF 'AT' ;D=ROW, E=COL, A=RHS MAX, CY IF LPRINTING ;PARAM ;JR IF LINE FULL ;ABS TAB POSN ;FIND SPACES REQUIRED TO REACH TAB POSN. ;JR IF NOT ALREADY PAST TAB POSN ;CALCULATE SPACES NEEDED TO FILL LINE ;AND REACH TAB POSN. ;CONTROL CODE

;TWO OPERANDS - TAB OR 'AT' (TAB JUNKS THE SECOND OPERAND!) CC2OPS: SETADCOM:

;SAVE CURRENT O/P ADDR AND SET IT TO DE SVSETOP:

CCRP2:

JR Z,POATCC CALL POFETCH LD C,A CP E LD A,H JR C,TAB2 LD A,(WINDLHS) ADD A,H SUB E RET Z JR NC,TAB2 LD A,H ADC A,C SUB E

;DEAL WITH TAB. H=ONLY RELEVANT OPERAND (FIRST - COLUMN)

DF12 DF13 DF16 DF16 DF16 DF16 DF16 DF17 DF18 DF1B DF1C DF1D DF1E DF1F DF20 DF21 DF23 DF23 DF24 DF25 DF26 DF27 DF28 DF29 DF2A DF2B DF2D DF2D DF2F DF30 DF33 DF34 DF36 DF36 DF37 DF38 DF38 DF39 DF3C DF3D DF3F DF3F DF40 DF40 DF41 DF44 DF44 DF45 DF46 DF46 DF46 DF46 DF49 DF4A DF4B DF4C DF50 DF51 DF51 DF51 DF51 DF54 DF56 DF58 DF58 DF5B DF5C DF5E DF5E DF61 DF65 DF68 DF68 DF6B DF6C DF6E DF6E DF71 DF74 DF75 DF77 DF77 DF7A DF7B DF7D DF7D DF80 DF83 DF86 DF87 DF88 DF89 DF8B DF8E DF8F DF90 DF92 DF94 DF94 DF96 DF98 DF98 DF9B

A7 C30FDE

TAB2:

AND A JP OPAORZ

;******************************************************************************* ;'AT' ROUTINE EB 5C 21575A 7E 83 5F 2B 7E BB 3821 23 23 7E 82 57 23 7E 92 3013 ED44 47 3A735A A7 280E 56 D5 C5 CDB8DF C1 10F9 D1 EB C362DC CF 20 2A515C 5E 23 56 ED53B55A C9 3A3C5C E610 2810 3A865B 3D 204D CD6311 ED7B3F5C C32C06 3A735A 3D 284A CD5D0E 3ABB5A A7 2034 218C5C 35 202E CDAEDF CDE0DF 2A515C E5 D9 D5 3E01 CD01E0 D1 D9 FE20 2804 E6DF FE4E CCCD08 CA610E BRCH: SCRLSCR2: POSTORH: PATER: SLSLP: POATCC: EX DE,HL LD E,H LD HL,WINDLHS LD A,(HL) ADD A,E LD E,A DEC HL LD A,(HL) CP E JR C,PATER INC HL INC HL LD A,(HL) ADD A,D LD D,A INC HL LD A,(HL) SUB D JR NC,POSTORH NEG LD B,A LD A,(DEVICE) AND A JR Z,PATER LD D,(HL) PUSH DE PUSH BC CALL SCRLS POP BC DJNZ SLSLP POP DE EX DE,HL JP POSTORE RST 08H DB 32 LD HL,(CURCHL) LD E,(HL) INC HL LD D,(HL) LD (OPSTORE),DE RET LD A,(TVFLAG) AND 10H JR Z,SCRLSCR2 LD A,(BCREG) DEC A JR NZ,DOSCRL CALL SETSTRM LD SP,(LISTSP) JP AULX LD A,(DEVICE) DEC A JR Z,SCRLS CALL BRKCR LD A,(SPROMPT) AND A JR NZ,DOSCRL LD HL,SCRCT DEC (HL) JR NZ,DOSCRL CALL SETSCRCT CALL SVTEMPS LD HL,(CURCHL) PUSH HL EXX PUSH DE LD A,1 CALL WTBRK POP DE EXX CP " " JR Z,BRCH AND 0DFH CP "N" CALL Z,IOPOF JP Z,BRCERR ;INDENT O/P OFF. EXIT WITH Z ;'OFF SCREEN' ;D=1ST OPERAND (ROW), E=2ND (COLUMN) ;ADD COL ;ABS SCREEN COL ;WINDRHS ;ERROR IF TOO FAR RIGHT ;WINDLHS ;WINDTOP ;ABS SCREEN ROW ;WINDBOT ;JR IF 'AT' NOT OFF BOTTOM ;NUMBER OF EXTRA ROWS NEEDED IN LS ;ERROR IF UPPER SCREEN, BUT LS CAN INCREASE SIZE ;D=WINDBOT, E=ABS 'AT' COLUMN

;SCROLL LS UP 'B' TIMES TILL POSN IS ON RIGHT ROW ;(I.E. ADD ROWS TO TOP OF LOWER SCREEN)

;SAVE CURRENT O/P ADDR SVCUROP:

;SCROLL SCREEN SCRLSCR: ;JR IF NOT AUTO-LIST ;JR IF CURRENT LINE NOT PRINTED YET ;(STREAM ZERO) ;CLEAR STACK ;JP TO SET 'AUTOLIST FINISHED' ;JR IF USING LOWER SCREEN

;JR IF PROMPTS TURNED OFF ;JR IF NOT TIME FOR PROMPT YET ;SAVE TEMPORARY ATTRIBUTES ETC ;PROBABLY CHANNEL 'S' ;'Scroll?'

DF9E DF9E DF9F DFA2 DFA5 DFA8 DFAB DFAB DFAE DFAE DFB1 DFB2 DFB3 DFB4 DFB7 DFB8 DFB8 DFB8 DFB8 DFB8 DFB8 DFBB DFBC DFBD DFBF DFBF DFC0 DFC3 DFC6 DFC7 DFCA DFCB DFCD DFCD DFCE DFCF DFD2 DFD3 DFD6 DFD9 DFDC DFDE DFDE DFDF DFE0 DFE0 DFE1 DFE4 DFE7 DFE9 DFE9 DFEA DFEA DFED DFED DFED DFED DFED DFED DFEE DFEF DFF2 DFF3 DFF5 DFF5 DFF6 DFF7 DFF8 DFF9 DFFA DFFB DFFD DFFD DFFE DFFF E000 E001 E001 E001 E001 E001 E004 E007 E00A E00D E00D E00E E011 E012 E013 E013 E013 E013 E017 E018 E019 E019 E019 E019 E019 E019 E019 E019

E1 22515C CD7011 CDDEDF CDAC11 C3950B 2A585A 7C 95 3C 328C5C C9 DOSCRL: SETSCRCT:

POP HL LD (CURCHL),HL CALL CHANFLAG CALL RSTTEMPS CALL COLEX JP EDRS1UP LD HL,(WINDTOP) LD A,H SUB L INC A LD (SCRCT),A RET

;RESTORE TEMPORARY ATTRIBUTES

;A=WINDOW HEIGHT

;SCROLL LOWER SCREEN. IF THE TOP OF THE LOWER SCREEN HITS UPPER SCREEN PRINT ;POSN THEN THE UPPER SCREEN HAS TO BE SCROLLED AS WELL, FROM TOP TO PRINT POSN 213E5A 7E 3D 2885 77 32585A 21C35A 35 216D5A BE 20DE F5 35 CD5E11 F1 32595A CD950B CD6111 18CD A7 26 37 214D5A 11C85A 3801 EB C3A413 RSTTEMPS: SVTEMPS: SCRLS: LD HL,LWTOP LD A,(HL) DEC A JR Z,PATER LD (HL),A LD (WINDTOP),A LD HL,KPOS+1 DEC (HL) LD HL,SPOSNU+1 CP (HL) JR NZ,DOSCRL PUSH AF DEC (HL) CALL STREAMFE POP AF LD (WINDBOT),A CALL EDRS1UP CALL STREAMFD JR DOSCRL AND A DB 26H SCF LD HL,THFATT LD DE,TEMPW1 JR C,SVRSTTMPS EX DE,HL SVRSTTMPS: JP LDIR8 ;LD BC,8:LDIR:RET ;LS TOP WILL MOVE UP BY ONE LINE ;OFF SCREEN ERROR IF WINDOW HIT SCREEN TOP ;NEW LWTOP ;ALSO RECORD NEW TOP FOR CURRENT (TEMP) WINDOW (LS) ;CURSOR LINE KEPT UP-TO-DATE ;JR IF NO CLASH WITH UPPER SCREEN PRINT POSN ;(JR ALSO IF WINDTOP IS ABOVE US PRINT POSN - SIC) ;US PRINT POSN MOVES UP ONE LINE ;MAIN WINDOW ;WIND BOT=FORMER PRINT POSN ;SCROLL MAIN WINDOW UP ONE ;LOWER WINDOW ;SCROLL LS ;'JR +1' ;8 BYTES OF TEMP STORE AVAILABLE HERE

;COPY 8 BYTES FROM HL TO MEM1 AND MEM2, DOUBLING ;EXIT WITH HL PTING TO MEM1 C5 D5 112951 D5 0608 7E 23 12 13 12 13 10F8 E1 D1 C1 C9 DBCHAR: PUSH BC PUSH DE LD DE,MEMVAL+8 PUSH DE LD B,8 LD A,(HL) INC HL LD (DE),A INC DE LD (DE),A INC DE DJNZ DHLP POP HL POP DE POP BC RET ;(MEMVAL+0 MIGHT BE IN USE)

DHLP:

;LOOP DOUBLES CHARACTER BYTES ;PTR TO TOP HALF OF CHAR PAT

;USED TO GIVE 'START TAPE..' PROMPT TO LOWER SCREEN, AND ;TO GIVE 'SCOLL?' PROMPT. ON ENTRY, A=UTMSG NUMBER CD0DE0 CDB03D CDB11C CDE404 F5 CDB506 F1 C9 ED4BDC5B C5 C9 WTBRK: CALL CALL CALL CALL WTB2 UTMSG READKEY GTKBK ;CLEAR BUFFER

WTB2:

PUSH AF CALL CLSLOWER POP AF RET LD BC,(MNOP) PUSH BC RET

;USED TO PRINT CURSOR FONOP2:

INCLUDE TAPEMN.SAM ;SAVE, LOAD, MERGE, VERIFY ;TAPEMN.SAM - SAVE/LOAD/MERGE/VERIFY CONTROL ;SYNTAX CHECK FOR ALL TAPE COMMANDS STARTS AT SLMVC ;THERE ARE 2 BUFFERS - HDR (HEADER - REQUESTED) AND HDL (HEADER - LOADED) ;HEADER BUFFER FORMAT:

E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E019 E01B E01E E020 E020 E021 E021 E024 E027 E02A E02C E02C E02F E031 E031 E033 E034 E036 E036 E038 E038 E03A E03B E03D E03D E040 E042 E045 E047 E047 E049 E049 E04A E04B E04D E04D E050 E052 E053 E056 E058 E058 E05A E05C E05C E05D E05E E05E E060 E062 E062 E063 E065 E067 E067 E067 E06A E06B E06C E06E E06E E06F E071 E071 E072 E074 E076 E076 E078 E07B E07B E07E E080 E083 E083 E086 E088

;0 ;1-10 ;11-14 ;15 ;16-26 ;16 ;16-18 ;19-21 ;22-24 ;27 ;28-30 ;31-33 ; ;34-36 ; ;37-39 ; ; ;40-79 D6A6 32B95B 2001 E7 2A065A 22B75B CDA13A 3045 21014B 0619 3620 23 10FB 060E 36FF 23 10FB CDEA3E 260B CD26E5 2802 260F 79 BC 300F 21014B 36FF A7 3A745B 2006 FE94 2015 CF 12 FE94 200C 1A FE04 3007 320F4B 13 0D 2803 EB EDB0 DF FEFF 2870 FE8C C279E1 3A745B FE97 CA290D CDE33A 300C MVTNM: HDR2: HDR3: IFNER: TNMOK: NLTP: HDCLP2: HDCLP: NOVE: SLMVC:

(16=BAS, 17=NUM ARRAY, 18=STR ARRAY, 19=CODE, 20=SCREEN$) FILE NAME, PADDED WITH SPACES IF NEEDED ALLOWS LONGER FILE NAME IF SLDEV<>T FLAGS. BIT 0=INVIS. NAME, BIT 1=PROTECTED CODE IF TYPE 17 OR 18=ARRAY/STRING TLBYTE/NAME (11) IF TYPE 20 =SCREEN MODE IF TYPE 16 =PROG LEN EXCLUDING VARS (3) IF TYPE 16 =PROG LEN PLUS NVARS, EXCLUDING GAP AND SAVARS (3) IF TYPE 16 =PROG LEN PLUS NVARS, EXCLUDING SAVARS (3) (1) DIRE - DIRECTORY ENTRY NUMBER (HDR ONLY) NOT USED - (4) SPARE - (3) - (3) - (3) REL PAGE FORM START ADDR IF CODE, ACTUAL ADDR IF PROG OR DATA. (OR FFXXXX IF ARRAY DOESN'T EXIST) DATA LENGTH (PAGEFORM) OR FFFFFF IF E.G. LOAD "" CODE PROG+VARS LENGTH, OR ARRAY LEN (OR FFXXXX IF NON-EXISTENT) EXECUTE ADDR. IF CODE, REL PAGE FORM, OR FFXXXX IF NO EXEC. IF BAS AND NO AUTO-RUN, FIRST BYTE=FF, ELSE FIRST=0 AND THE AUTO-RUN LINE NUMBER IS IN THE NEXT TWO BYTES. COMMENT. NOT INITIALISED - CAN BE POKED, PEEKED. SUB 0A6H LD (OVERF),A JR NZ,NOVE RST 20H LD HL,(PSLD) LD (SLDEV),HL CALL EXPTSTR JR NC,HDR2 LD HL,HDR+1 LD B,25 LD (HL),20H INC HL DJNZ HDCLP LD B,14 LD (HL),0FFH INC HL DJNZ HDCLP2 CALL SBFSR LD H,NMLEN+1 CALL TCHK JR Z,NLTP LD H,NMLEN+5 LD A,C CP H JR NC,IFNER LD HL,HDR+1 LD (HL),0FFH AND A LD A,(CURCMD) JR NZ,TNMOK CP SAVETOK JR NZ,HDR2 RST 08H DB 18 CP SAVETOK JR NZ,MVTNM LD A,(DE) CP 4 JR NC,MVTNM LD (HDR+HFG),A INC DE DEC C JR Z,HDR2 EX DE,HL LDIR RST 18H CP 0FFH JR Z,HDR4 CP LINETOK JP NZ,HDR6 LD A,(CURCMD) CP VERIFYTOK JP Z,NONSENSE CALL SEXPT1NUM JR NC,HDRLNOK ;FIRST ;0 FOR ;1 FOR ;2 FOR ;3 FOR CHAR OF SAVE NAME CAN BE NOT INVIS, NOT PROT INVIS, NOT PROT NOT INVIS, PROT INVIS, PROT ;CLEAR REST WITH FFH ;BC=NAME LEN, DE=START, IN SYS PAGE BUFFER ** ;OVERTOK ;SKIP "OVER" ;PERM DEVICE TO TEMP ;NAME ;JR IF NOT RUNNING ;HEADER BUFFER ADDR ;CLEAR NAMES AREAS WITH SPACES

TYPE (10) (4) (1) (11)

;DISP OF HDN FROM BUFFER START:

;SAVE, LOAD, VERIFY, MERGE ALL ENTER HERE

;ALLOW EXTRA CHARS IF NON-T ;LIMIT NAME LEN ;DEST FOR FIRST NAME CHAR ;ASSUME NAME IS NULL ;JR IF NAME LEN IS 1-MAX CHARS LONG ;JR IF NOT SAVE (WITH A NULL NAME) ;'Invalid file name'

;(INVIS. MEANS NAME NOT PRINTED DURING LOADING, ;PROT. MEANS AUTO-RUN CODE FILE CANNOT BE STOPPED) ;FIRST CHAR IS NOT INCLUDED IN NAME PROPER. ;COPY NAME TO BUFFER ;JR IF FN LEADER FOUND (SHOULD BE SCREEN$ OR CODE) ;IF NOT 'LINE', CHECK FOR 'DATA', OR CR/COLON ;VERIFY "NAME" LINE n NOT ALLOWED ;JR IF NOT RUNNING

E088 E08B E08E E090 E091 E092 E093 E094 E094 E094 E094 E097 E097 E09A E09D E0A0 E0A1 E0A2 E0A5 E0A6 E0A8 E0AA E0AA E0AB E0AB E0AE E0B1 E0B4 E0B4 E0B6 E0BA E0BE E0BE E0C1 E0C3 E0C6 E0C8 E0CB E0CD E0D0 E0D3 E0D5 E0D8 E0DA E0DD E0DF E0E1 E0E1 E0E1 E0E1 E0E3 E0E6 E0E6 E0E7 E0E9 E0EB E0EB E0EB E0EB E0EE E0F0 E0F0 E0F1 E0F4 E0F6 E0F6 E0F9 E0FB E0FD E0FD E0FF E0FF E100 E100 E103 E103 E104 E104 E105 E106 E109 E10B E10B E10E E10F E110 E111 E112 E113 E114 E116 E117 E118 E119 E119 E11A E11B E11C E11E E120 E120 E123 E125

CD2E1D 21254B 3600 23 71 23 70 CD153B CD321F 321F4B 22204B EB 4F CD351F 2B CB7C 2001 3D CDE71F 32224B 22234B 0603 DD21895A FD21104B DD6600 DD2B DD6E00 DD2B DD7E00 DD2B CDE71F FD7700 FD23 FD7500 FD23 FD7400 FD23 10DD 3E10 C3E2E1 E7 FE6C 2049 111F4B 0603 E7 CD7A3A 200E 3A745B FE94 2803 182D 05 CA290D E7 C5 D5 CDE43A 300E CD8C3F D1 EB 77 23 73 23 CBFA 72 23 E5 D1 C1 DF FE2C 28DF 3A745B FE94 2005 HDRN1: HDRNMS: HDRNLP: HDNSHP: HDR4: RNTVL: HDRPLC: HDRLNOK:

CALL GETINT LD HL,HDR+HDN+6 LD (HL),0 INC HL LD (HL),C INC HL LD (HL),B ;S/L/V/M "NAME": CALL CHKEND CALL ADDRPROG LD (HDR+HDN),A LD (HDR+HDN+1),HL EX DE,HL LD C,A CALL ADDRELN DEC HL BIT 7,H JR NZ,HDRPLC DEC A

;LINE ;PTR TO AUTO-RUN LINE AREA ;FLAG 'AUTORUN' ;PLACE LINE NO.

ENTERS HERE, AND S/L/M "NAME" LINE n

;START ;CDE=PROG ;DEC AHL SO PROG LEN-1 USED. END OF SAVARS MARKER ;NOT SAVED. (SO ELINE NEVER = PROG WHEN PROG ;SPACE IS RECLAIMED, MAKEROOM AT (PROG) ALWAYS OK)

CALL SUBAHLCDE ;GET AHL=PAGE FORM OF DIFFERENCE LD (HDR+HDN+3),A LD (HDR+HDN+4),HL ;FILE LEN=ELINE-PROG LD B,3 LD IX,NVARS+1 LD IY,HDR+16 LD H,(IX+0) DEC IX LD L,(IX+0) DEC IX LD A,(IX+0) DEC IX CALL SUBAHLCDE LD (IY+0),A INC IY LD (IY+0),L INC IY LD (IY+0),H INC IY DJNZ RNTVL LD A,16 JP SLVMC RST 20H CP CODETOK JR NZ,HDR5 LD DE,HDR+HDN LD B,3 RST 20H CALL CRCOLON JR NZ,HDRNMS LD A,(CURCMD) CP SAVETOK JR Z,HDNSHP JR HDRNOK DEC B JP Z,NONSENSE RST 20H PUSH BC PUSH DE CALL EXPT1NUM JR NC,HDRN1 CALL UNSTLEN POP DE EX DE,HL LD (HL),A INC HL LD (HL),E INC HL SET 7,D LD (HL),D INC HL PUSH HL POP DE POP BC RST 18H CP "," JR Z,HDRNLP LD A,(CURCMD) CP SAVETOK JR NZ,HDRNOK ;COUNT ;PTR ;JR IF NOT RUNNING ;GET NUMBER IN AHL IN PAGE/ADDR FORM ;HL=PTR, ADE=ADDR ;JR IF MORE THAN 3 NUMBERS USED ;DO NVARS, NUMEND, SAVARS ;STORE IN HDR+16/+19/+22

;PROGRAM (EX. STR/ARRAYS AND GAP) LEN ;PROGRAM (EX. STR/ARRAYS) LEN ;TYPE=PROG ;JP TO COMMON ROUTINE ;SKIP FFH

;HANDLE "NAME" CODE <START><,LENGTH><,EXECUTION ADDR> ;PT TO HDR AREA FOR NUMBERS ;MAX OF 3 NUMS FOLLOW 'CODE' ;SKIP 'CODE' ;JR IF NOT JUST "NAME" CODE ;SAVE "NAME" CODE NEEDS PARAMS

;PTR ;NO. COUNT ;LOOP FOR ANOTHER NO. IF A COMMA FOLLOWED THE LAST

E127 E127 E128 E12A E12C E12C E12F E12F E12F E12F E131 E134 E134 E136 E139 E139 E13C E13C E13F E142 E143 E146 E149 E14C E14D E14E E14F E150 E151 E154 E157 E158 E159 E15B E15C E15E E15F E160 E161 E162 E163 E164 E165 E167 E168 E169 E16B E16B E16C E16C E16D E170 E173 E175 E177 E179 E179 E17B E17E E17E E181 E183 E185 E185 E186 E189 E18B E18C E18E E191 E192 E195 E195 E197 E197 E198 E19A E19C E19C E19D E19F E19F E1A1 E1A3 E1A3 E1A5 E1A5 E1A6 E1A8 E1A8 E1AB E1AB E1AC E1AF E1AF E1B0 E1B1 E1B3 E1B3 E1B6 E1B9 E1BD E1C0

78 FE03 28D4 CD153B 3E13 C3E2E1 FE4C C2290D CD143B CDB2EE 212800 09 3A405A 32104B CD0CE5 4F E5 D5 19 EB 211F4B 3A785A 77 23 3600 23 3680 23 71 23 73 23 72 D1 CBFA 0C 0D 2801 3C C1 21D855 CDDF3F EDB0 3E14 1869 FEB9 C294E0 3A745B FE96 2823 E7 CD0102 733F F5 0612 3A3B5C 87 FAA5E1 3008 DF FE29 2013 E7 1810 CB71 280C 1806 05 CB69 CA290D DF CD953A F1 C5 2818 3A2351 321F4B ED53204B 212451 CD6C2C SVDNU: SVDNH: SVNSC: SVDTT: SVDS1: HDRSC2: HDR5: HDRNOK:

LD A,B CP 3 JR Z,HDNSHP CALL CHKEND LD A,19 JP SLVMC CP SCRNTOK JP NZ,NONSENSE CALL SABORTER CALL FLITE LD HL,0028H ADD HL,BC LD A,(MODE) LD (HDR+16),A CALL SCRLEN LD C,A PUSH HL PUSH DE ADD HL,DE EX DE,HL LD HL,HDR+HDN LD A,(CUSCRNP) LD (HL),A INC HL LD (HL),0 INC HL LD (HL),80H INC HL LD (HL),C INC HL LD (HL),E INC HL LD (HL),D POP DE SET 7,D INC C DEC C JR Z,HDRSC2 INC A POP BC LD HL,PALTAB CALL TSURPG LDIR LD A,20 JR SLVMC CP 0B9H JP NZ,HDRLNOK LD A,(CURCMD) CP MERGETOK JR Z,SVDNH RST 20H CALL R1OFFCL DW LENGSR PUSH AF LD B,18 LD A,(FLAGS) ADD A,A JP M,SVDNU JR NC,SVDS1 RST 18H CP ")" JR NZ,SVDTT RST 20H JR SVDTT BIT 6,C JR Z,SVDTT JR SVNSC DEC B BIT 5,C JP Z,NONSENSE RST 18H CALL INSISCBRK POP AF PUSH BC JR Z,SVNWAR

;SAVE CANNOT HAVE JUST SAVE "NAME" START

;EXECUTION ROUTINE FOR SAVE/LOAD/VERIFY "NAME" CODE ETC. ;TYPE=CODE ;JP TO COMMON ROUTINE

;SKIP 'SCREEN$' ;GET BC=LINE INT TABLE LEN ;ALLOW FOR PALTAB ;MODE ;GET SCREEN LEN FOR MODE IN ADE ;LEN OF PALTAB AND LINITAB ;SCREEN LEN ;ADE=TOT LEN

;START IS AT 8000H IN SCREEN PAGE ;LEN MSB ;LEN ;DE=SCREEN END IF M0/1 ;JR IF M0 OR M1 ;SECOND PAGE OF M2/M3 SCREEN ;PALTAB+LINITAB LEN ;COPY TO END OF SCREEN ;'SCREEN$' TYPE ;JR TO COMMON ROUTINE ;DATATOK

HDR6:

;MERGE "NAME" DATA NOT ALLOWED ;SKIP 'DATA' ;** BUG FIX ;FOUND/NOT FOUND STATUS ;TYPE ASSUMED TO BE STRING ;JP IF NUMERIC ;JR IF NOT RUNNING ;MUST BE NAME$ ;SKIP ')' ;MUST BE NAME$() ;JR IF NO OPENING BRACKET USED ;TYPE=17 ;ERROR IF NON-ARRAY NUMERIC ;INSIST ON ')', SKIP ;B=TYPE, 17 (NUMERIC) OR 18 (STRING) ;JR IF NOT FOUND

LD A,(MEMVAL+2) LD (HDR+HDN),A LD (HDR+HDN+1),DE ;START OF VARIABLE LD HL,MEMVAL+3 ;TEXT LEN DATA STORED HERE CALL ADD14 ;ALLOW FOR T/L,NAME,PG,MOD 16K

E1C3 E1C6 E1C9 E1CB E1CB E1CB E1CB E1CE E1D0 E1D3 E1D3 E1D4 E1D7 E1D7 E1DA E1DD E1E0 E1E2 E1E2 E1E5 E1E5 E1E8 E1EA E1ED E1ED E1ED E1ED E1F0 E1F2 E1F2 E1F6 E1F7 E1F8 E1FA E1FA E1FA E1FA E1FD E1FD E1FD E1FD E200 E202 E204 E204 E207 E209 E20B E20B E20E E210 E212 E212 E213 E216 E218 E218 E219 E21C E21C E21F E221 E224 E224 E226 E229 E229 E229 E229 E22C E22D E22E E22F E232 E233 E234 E235 E237 E237 E238 E239 E23B E23C E23F E23F E240 E241 E243 E243 E246 E248 E24B E24B E24B E24E E251 E254 E256 E257 E259 E259 E25A E25C

32224B 22234B 1808 ;NEW ARRAY 3A745B FE95 C2082D F1 CD153B 213F51 11104B 010B00 EDB0 32004B 3A745B FE94 CABFE4 CD1AE5 2808 DD21004B CF 81 1803 CDF1E3 3A504B D613 2014 3A745B FE96 201E 3A5F4B E602 2017 3D 32754B 1811 3D CAC0E2 3A745B FE95 CA23E3 FE96 CA5738 CD3820 41 C5 D5 CD3B20 E1 F1 3C 2814 3D A7 ED52 99 DABEE2 B4 B5 2808 3A745B FE97 CABEE2 211F4B CD3F20 3A004B FE13 79 2010 3C 2008 HDLNM: CDSCVE: LVM2: LKTH: LDFL: SLVMC: SLVM1: SVNWAR: SVDTCE:

LD (HDR+HDN+3),A LD (HDR+HDN+4),HL ;LEN OF VARIABLE INC. HEADER JR SVDTCE LD A,(CURCMD) CP LOADTOK JP NZ,VNFERR POP AF CALL CHKEND LD HL,TLBYTE LD DE,HDR+16 LD BC,11 LDIR LD (HDR),A LD A,(CURCMD) CP SAVETOK JP Z,SAMAIN CALL TORN JR Z,LKTH LD IX,HDR RST 08H DB FOPHK JR LDFL CALL LKHDR LD A,(HDL) SUB 19 JR NZ,LVM2 LD A,(CURCMD) CP MERGETOK JR NZ,CDSCVE LD A,(HDL+HFG) AND 02H JR NZ,CDSCVE DEC A LD (HDL+HDN+6),A JR CDSCVE DEC A JP Z,LDSCRN LD A,(CURCMD) CP LOADTOK JP Z,LDPRDT CP MERGETOK JP Z,MEPROG CALL RDRLEN LD B,C PUSH BC PUSH DE CALL RDLLEN POP HL POP AF INC A JR Z,HDLNM DEC A AND A SBC HL,DE SBC A,C JP C,TERROR OR H OR L JR Z,HDLNM LD A,(CURCMD) CP VERIFYTOK JP Z,TERROR LD HL,HDR+HDN CALL RDTHREE LD A,(HDR) CP 19 LD A,C JR NZ,STSPEC3 INC A JR NZ,STSPEC ;SAVE PROGRAM

;ERROR IF VERIFYING OR SAVING A NEW ARRAY ;TYPE

;COPY DETAILS OF VAR NAME TO HDR

;LOAD/VERIFY/MERGE MAIN LVMMAIN: ;JR IF TAPE, OR N AND NO DOS ;CALL DOS TO LOAD HDR (OPEN FILE FOR READ)

;JUMP FROM DOS (E=3) - LOAD HEADER, THEN FILE FROM TAPE/NET ;GET THE CORRECT HEADER ;JUMP FROM DOS (E=1) - LOAD JUST FILE FROM TAPE/NET ;JR IF NOT CODE ;JR IF LOAD/VERIFY CODE ;JR IF PROT - CANNOT STOP AUTO-RUN CODE ;PREVENT AUTO-RUN IF MERGE UNPROTECTED CODE ;JR IF TYPE=SCREEN$ (20) ;JR IF LOAD (A PROGRAM OR ARRAY - TYPES 16-18) ;JP IF MERGE PROGRAM - CONT WITH VERIFY ;CDE='DESIRED' LEN FROM HDR ;CDE=ACTUAL LEN FROM LOADED HDL (PAGEFORM) ;AHL=DESIRED LEN VALUE, CDE=ACTUAL LEN OR FFFFFF ;JR IF DESIRED LEN UNSPECIFIED (ONLY IF CODE)

;VERIFY PROGRAM, DATA, CODE OR SCREEN, LOAD CODE

;ERROR IF LEN OF FILE IS LONGER THAN REQUESTED ;EQUAL LENS OK FOR VERIFY OR LOAD ;IF LOAD, LEN CAN BE LESS THAN 'DESIRED' ;BUT VERIFY INSISTS ON EQUALITY ;CDE=DESIRED START ;FOR ANYTHING APART FROM CODE, 'START' IS ALWAYS ;'DESIRED' (E.G. CUR. PROG, SCREEN OR VAR. ADDR) ;JR IF DESIRED START WAS SPECIFIED: E.G. ;VERIFY/LOAD "NAME" CODE 40000

E25C E25F E262 E264 E264 E264 E264 E264 E265 E265 E268 E269 E269 E26A E26D E270 E271 E274 E277 E279 E27A E27A E27A E27A E27D E27F E281 E281 E284 E287 E289 E28B E28B E28E E291 E293 E294 E294 E297 E298 E299 E29C E29C E29C E29C E29F E2A1 E2A3 E2A3 E2A3 E2A3 E2A4 E2A4 E2A6 E2A7 E2AA E2AC E2AC E2B0 E2B1 E2B3 E2B3 E2B4 E2B5 E2B6 E2B6 E2B7 E2B8 E2B9 E2B9 E2BA E2BD E2BE E2BE E2BF E2C0 E2C0 E2C0 E2C0 E2C0 E2C3 E2C4 E2C7 E2C8 E2CA E2CC E2CC E2CD E2CE E2CE E2CF E2D2 E2D2 E2D5 E2D8 E2DB E2DE E2DF E2E2 E2E3 E2E6 E2E8 E2E9

216F4B CD3F20 1801 STSPEC: 0D 3AB35A 81 D5 CDDF3F CD3B20 E1 CD9CE2 3A745B FE97 C8 3A5F4B CB4F 200A 3A254B 2A264B FEFF 2009 3A754B 2A764B FEFF C8 CD7912 44 4D C30702 3A745B FE97 2801 37 3EFF F5 CD1AE5 280D DD21004B F1 3803 CF 83 C9 CF 82 C9 F1 CD0EE6 D8 CF 13 DOSLD: LDVD3: TERROR: HDNSTP: STSPEC2: STSPEC3: ; ; ;

LD HL,HDL+HDN CALL RDTHREE JR STSPEC2 IN A,(LRPORT) ADD A,C LD C,A DEC C LD A,(LDCO) ADD A,C PUSH DE CALL TSURPG CALL RDLLEN POP HL CALL LDVDBLK LD A,(CURCMD) CP VERIFYTOK RET Z LD A,(HDL+HFG) BIT 1,A JR NZ,HDNSTP LD LD CP JR

;CDE=LOADED START ;PAGE AT 0000 ;CONVERT REL LOAD ADDR TO ABS

;START SWITCHED IN AT HL ;CDE=ACTUAL LEN FROM LOADED HDL (PAGE FORM) ;START ;LOAD OR VERIFY BLOCK

;MUST BE LOAD CODE ;JR IF PROT - CANNOT STOP AUTO-RUN CODE

A,(HDR+HDN+6) HL,(HDR+HDN+7) 0FFH NZ,HDLDEX ;JR IF LOAD EXEC - OVER-RIDES ANY SAVED EXEC

LD A,(HDL+HDN+6) LD HL,(HDL+HDN+7) ;AHL=LOADED EXEC ADDR (REL PAGE FORM) OR FFXXXX CP 0FFH RET Z ;RET IF NO EXEC ADDR CALL PDPSR2 LD B,H LD C,L JP R1OFFCLBC LD A,(CURCMD) CP VERIFYTOK JR Z,LDVD2 SCF LD A,0FFH PUSH AF CALL TORN JR Z,LDVD3 LD IX,HDR POP AF JR C,DOSLD RST 08H DB VFYHK RET RST 08H DB LDHK RET POP AF CALL LDBYTES RET C RST 08H DB 19 ;'LOADING ERROR' ;SWITCH IN CORRECT PAGE, FIDDLE HL IF NEEDED ;CALL BC WITH ROM1 OFF

HDLDEX:

;LOAD OR VERIFY DATA BLOCK ACCORDING TO CURCMD LDVDBLK: ;JR WITH NC IF VERIFY ;LOAD ;DATA BLOCK ;Z IF 'T', OR 'N' AND NO DOS ;IF NO DOS LET ROM HANDLE NET LOAD ;HL=DEST, CDE=LEN ;DOS VERIFY FOR DISC/NET ETC ;DOS LOAD FOR DISC/NET ETC

;CALLED TO LOAD A DATA BLOCK LDDBLK: LDVD2:

DOSLV:

;LOAD/VERIFY SCREEN$ FILE 3A405A 4F 21604B 7E FE20 2002 71 79 B9 C45A01 CDB63F 21724B CD3F20 210080 D5 CD9CE2 D1 3A745B FE97 C8 LDSC2: LDSCRN: LD LD LD LD CP JR A,(MODE) C,A HL,HDL+16 A,(HL) 20H NZ,LDSC2

;20H IF THIS IS A CODE FILE LOADED AS SCREEN$ ;JR IF IT IS A SCREEN$ FILE LOADED AS SCREEN$ ;SET MODE=CURRENT MODE FOR CODE FILE ;SKIP MODET ;SELECT MODE IF A NEW ONE IS NEEDED ;CDE=LOADED LEN ;SCREEN START

LD (HL),C LD A,C CP C CALL NZ,MODET CALL SELSCRN LD HL,HDL+HDN+3 CALL RDTHREE LD HL,8000H PUSH DE CALL LDVDBLK POP DE LD A,(CURCMD) CP VERIFYTOK RET Z

E2E9 E2EC E2ED E2F0 E2F1 E2F3 E2F5 E2F6 E2F6 E2F7 E2F7 E2F9 E2F9 E2FC E2FE E2FF E300 E303 E306 E309 E30B E30B E30E E30E E310 E310 E311 E313 E314 E315 E316 E316 E317 E319 E31A E31A E31B E31D E31F E321 E322 E323 E323 E323 E323 E326 E327 E328 E32B E32C E32D E32F E32F E330 E333 E335 E335 E338 E338 E33B E33E E33F E340 E342 E342 E343 E344 E347 E348 E349 E34A E34B E34C E34F E352 E354 E356 E356 E359 E35C E35C E35C E35D E360 E363 E366 E369 E36B E36B E36C E36F E36F E372 E375 E375 E376 E379 E37A E37B E37C E37D E37E E37F

3A604B D5 CD0CE5 E1 CBBC ED52 C8 D8 CBFA 012800 ED42 E5 EB 3A785A CD2CE5 11D855 2803 11D8BF EDB0 7E FEC3 12 C1 D0 78 FE02 D0 F3 EDB0 3EFF D3F9 FB C9 CD3B20 D5 79 CD3820 E1 0C 2806 0D CDE71F 3803 CD1E3F 211F4B CD3F20 79 0C 282D F5 D5 CD3820 D5 51 C1 E1 F1 CDDF3F 3A004B D610 2015 32875A 32895A 7A CD531E 2AC65B 22C45B CD321F 180A 7A CD531E CD351F CDB91F E5 CD3B20 E1 C5 D5 79 42 4B CD1C1E LDCRX: LDCRA: LDCR3: LDNAR: LDSZOK: LDPRDT: PMV:

LD A,(HDL+16) PUSH DE CALL SCRLEN POP HL RES 7,H SBC HL,DE RET Z RET C SET 7,D LD BC,40 SBC HL,BC PUSH HL EX DE,HL LD A,(CUSCRNP) CALL CUS2 LD DE,PALTAB JR Z,PMV LD DE,PALBUF-4000H LDIR LD A,(HL) CP 195 LD (DE),A POP BC RET NC LD A,B CP 2 RET NC DI LDIR LD A,0FFH OUT (STATPORT),A EI RET ;LOAD PROGRAM OR DATA FILE CALL RDLLEN PUSH DE LD A,C CALL RDRLEN POP HL INC C JR Z,LDNAR DEC C CALL SUBAHLCDE JR C,LDSZOK CALL TSTRMAHL LD HL,HDR+HDN CALL RDTHREE LD A,C INC C JR Z,LDCRA PUSH AF PUSH DE CALL RDRLEN PUSH DE LD D,C POP BC POP HL POP AF CALL SELURPG LD A,(HDR) SUB 16 JR NZ,LDCRX LD (NVARSP),A LD (NVARS+1),A LD A,D CALL RECL2BIG LD HL,(BASSTK) LD (BSTKEND),HL CALL ADDRPROG JR LDCR3 LD A,D CALL RECL2BIG CALL ADDRELN CALL DECPTR PUSH HL CALL RDLLEN POP HL PUSH BC PUSH DE LD A,C LD B,D LD C,E CALL MKRBIG

;MODE ;DE=SCREEN LEN MOD 16K FOR MODE. NC ;FILE LEN MOD 16K ;HL=PALTAB/LINICOLS ;RET IF EXACT LEN CODE FILE ;OR SHORT ;DE=9B00 IF MODE 0, BB00 IF MODE 1, ELSE A000 (AND ;LOAD BLOCK MEANS C/D PAGED). ;SUB PALTAB LEN ;HL=LINICOL LEN IN FILE ;HL PTS TO PALTAB AND LINICOLS DATA ;Z IF CURRENT SCREEN IS DISPLAYED ;MOVE LOADED PALTAB TO ACTIVE PALTAB, OR STORED ;AREA, IF CURRENT SCRN IS INVIS. ;COPY PALTAB (40 BYTES)

;LINICOL LEN ;RET IF NO LINICOLS ;LIMIT LINICOL LEN TO 01FFH FOR SAFETY

;PREVENT ANY LINE INTS TILL AFTER NEXT FRAME

;CDE=LEN OF FILE TO LOAD (PAGEFORM) ;CDE=LEN OF CURRENT ('DESIRED') AREA ;AHL=LOADING LEN ;JR IF LOADING A NEW ARRAY (CUR LEN=FFXXXX) ;JR IF CURRENT FILE IS BIGGER THAN LOADING ;CHECK AHL BYTES OK. (PAGEFORM) ;START OF EXISTING ARRAY (PAGE FORM) OR FFXXXX ;JR IF NEW ARRAY ;START ;CURRENT LEN TO CDE (PAGEFORM) ;DBC=LEN ;AHL=START ;JR IF NOT PROGRAM (IT'S AN ARRAY) ;SINCE PROG AND NVARS HAVE BEEN DELETED, ;PREVENT XOINTERS ALTERING NVARS, CAUSING ;SADJ WITH NO FOR-NEXTS, OR ODD BSTK ;ABC=LEN ;DELETE CURRENT PROGRAM ;CLEAR BASIC STACK - DATA OBSOLETE ;ADDR PROG ;ABC=LEN ;DELETE CURRENT ARRAY ;ADDRESS ELINE ;DEC HL AND CHANGE PAGE IF BELOW 8000H ;CDE=LOADING LEN (PAGEFORM)

;OPEN ABC AT HL

E382 E384 E385 E386 E388 E389 E38A E38D E38E E38F E392 E394 E396 E396 E397 E39A E39D E39E E39F E3A1 E3A2 E3A3 E3A4 E3A5 E3A8 E3AA E3AB E3AB E3AB E3AB E3AD E3B0 E3B4 E3B4 E3B7 E3B8 E3B9 E3BC E3BF E3C2 E3C4 E3C7 E3C9 E3CC E3CE E3CF E3D1 E3D1 E3D4 E3D7 E3D9 E3D9 E3DC E3DF E3E0 E3E2 E3E2 E3E5 E3E8 E3E9 E3EA E3EA E3EB E3EE E3F1 E3F1 E3F1 E3F1 E3F1 E3F1 E3F4 E3F6 E3F6 E3F9 E3FC E3FD E3FF E401 E403 E403 E406 E409 E40B E40C E40D E40E E410 E410 E412 E413 E415 E417 E41A E41B E41D E41F E422 E422 E425 E428 E42B E42C E42D

36FF D1 C1 DBFB F5 E5 CDA3E2 D1 C1 3A004B FE10 2815 78 CDDF3F 21104B 1A AE E6F0 AE 12 13 23 010A00 EDB0 C9 0603 21604B FD21895A CD3F20 23 E5 CD321F CDDE1F FD7400 FD2B FD7500 FD2B FD7700 FD2B E1 10E3 CDA234 CD0102 DB33 3A254B 2A264B A7 2808 3A754B 2A764B A7 C0 3D 32465C C39A19 LDUSLN: LDPROG: SNTVL:

LD (HL),0FFH POP DE POP BC IN A,(251) PUSH AF PUSH HL CALL LDDBLK POP DE POP BC LD A,(HDR) CP 16 JR Z,LDPROG LD A,B CALL TSURPG LD HL,HDR+16 LD A,(DE) XOR (HL) AND 0F0H XOR (HL) LD (DE),A INC DE INC HL LD BC,10 LDIR RET ;BASIC FILE LOADED - SET VARS LD B,3 LD HL,HDL+16 LD IY,NVARS+1 CALL RDTHREE INC HL PUSH HL CALL ADDRPROG CALL ADDAHLCDE LD (IY+0),H DEC IY LD (IY+0),L DEC IY LD (IY+0),A DEC IY POP HL DJNZ SNTVL CALL RESTOREZ CALL R1OFFCL DW DOCOMP

;IN CASE LOAD FAILS!!

;LOAD MAIN BLOCK ;BDE=START OF MAIN BLK ;JR IF PROGRAM WAS LOADED ;DE PTS TO LOADED ARRAY TYPE/LEN BYTE

;TYPE FROM LOADED ARRAY, NAME LEN FROM REQUESTED ;PT TO NAME ;COPY REQUESTED NAME TO SAVARS

;DO NVARS, NUMEND, SAVARS ;CDE=HDL DATA (LEN OF PROG ALONE, WITH NVARS, ETC)

;HDL PTR ;SET NVARS, NUMEND, SAVARS ;SET DATA PTR TO START OF PROG

;DEF PROCS/DEF FNS AND LABELS NEED DOING ;ANY PRE-PASS OF LABELS ETC IS OBSOLETE. LD A,(HDR+HDN+6) LD HL,(HDR+HDN+7) AND A JR Z,LDUSLN ;JR IF THERE'S A DESIRED START LINE (LD "N" LINE n) LD A,(HDL+HDN+6) LD HL,(HDL+HDN+7) AND A RET NZ DEC A LD (PPC+1),A JP GOTO3 ;A=FF ;ENSURE GOTO SEARCH STARTS FROM PROG, NOT CLA ;SET VARS SO GOTO LINE HAPPENS NEXT

;LOOK FOR A HEADER FROM TAPE OR NET. ;LOOK FOR A MATCHING HEADER (USING HDR AREA), LOADING HEADERS TO HDL AREA ;PRINT NAMES IF BIT 0,(TPROMPTS)=0. LOOP TILL MATCH FOUND. CD66E4 30FB CD5E11 3A504B 4F F610 FE15 30EE 215F4B 3A335A E601 B6 77 1F 3812 3E0D D7 3E2A CB61 CC1000 79 F610 D60C CDB03D 01000A 11504B 21004B 1A BE 280F LKHNP: LKHDR: CALL LDHDR JR NC,LKHDR CALL STREAMFE LD A,(HDL) LD C,A OR 10H CP 15H JR NC,LKHDR LD HL,HDL+HFG LD A,(TPROMPTS) AND 1 OR (HL) LD (HL),A RRA JR C,LKHNP LD A,0DH RST 10H LD A,"*" BIT 4,C CALL Z,0010H LD A,C OR 10H SUB 12 CALL UTMSG LD LD LD LD CP JR BC,NMLEN*256 DE,HDL HL,HDR A,(DE) (HL) Z,LKHTM ;LOOP IF ERROR ;"S" ;TYPE

;ISOLATE SYS VAR 'PRINT NAMES' BIT. ;OR WITH HDR VERSION ;JR IF NO PRINTING OF NAMES WANTED

;PRINT "*" BEFORE NAME IF ZX TYPE ;A=16-20 ;A=4-8 ;PRINT TYPE MSG ;C=0 ;LOADED TYPE ;CP DESIRED TYPE

E42F E42F E431 E433 E435 E435 E436 E437 E439 E43B E43D E43D E43E E43E E43F E440 E441 E442 E444 E444 E445 E446 E446 E447 E448 E44A E44C E44C E44D E44D E450 E451 E452 E455 E456 E457 E459 E459 E45A E45B E45D E45D E460 E461 E463 E464 E464 E465 E466 E466 E466 E466 E469 E46C E46D E46E E46F E470 E473 E474 E474 E477 E478 E47A E47B E47B E47D E47F E482 E483 E483 E483 E483 E485 E486 E487 E48A E48D E490 E493 E495 E498 E499 E49B E49D E49D E49F E4A1 E4A1 E4A1 E4A1 E4A3 E4A4 E4A6 E4A6 E4A7 E4AA E4AB E4AE E4B1 E4B2 E4B5 E4B8

D614 CE00 2008 7E 12 D614 CE00 2801 0C 23 13 7E 3C 2002 62 6B 1A AE E6DF 2801 0C 3A5F4B 1F 1A D41000 23 13 10ED 79 A7 2094 3A5F4B 1F 3E0D D8 D7 C9 21504B 115000 AF 4F 3C 37 CD0EE6 D0 21504B 7E CB67 C0 D603 3E00 325F4B C0 3613 EB AF 2A5B4B CDF21F 32724B 22734B 0E20 2A5D4B 7C FE40 3809 FE5B 3005 3E14 12 0E00 79 32604B AF 325F4B CDF21F 3D 326F4B 22704B 3EFF HDTR5: LDHDR: PRHDC: PRHDLP: SNMN: LKHTM:

SUB 20 ADC A,0 JR NZ,SNMN LD A,(HL) LD (DE),A SUB 20 ADC A,0 JR Z,LKHTM INC C INC HL INC DE LD A,(HL) INC A JR NZ,PRHDLP LD H,D LD L,E LD A,(DE) XOR (HL) AND 0DFH JR Z,PRHDC INC C LD A,(HDL+HFG) RRA LD A,(DE) CALL NC,0010H INC HL INC DE DJNZ PRHDLP LD A,C AND A JR NZ,LKHDR LD A,(HDL+HFG) RRA LD A,0DH RET C RST 10H RET ;LOAD A HEADER LD HL,HDL LD DE,80 XOR A LD C,A INC A SCF CALL LDBYTES RET NC LD HL,HDL LD A,(HL) BIT 4,A RET NZ SUB 3 LD A,0 LD (HDL+HFG),A RET NZ LD (HL),19 EX DE,HL XOR A LD HL,(HDL+11) CALL PAGEFORM LD (HDL+HDN+3),A LD (HDL+HDN+4),HL LD C,20H LD HL,(HDL+13) LD A,H CP 40H JR C,HDTR5 CP 5BH JR NC,HDTR5 ;MUST BE LOADING TO SCREEN LD A,20 LD (DE),A LD C,0

;19->255, 20->0 ;19->0,20->0 ;JR IF NOT CODE/SCREEN$ ;ELSE ;LOADED=DESIRED (DESPITE UTMSG) ;IF OTHER FILE IS CODE/SCREEN$, ACCEPT MATCH ;'NO MATCH' - TYPES DIFFER

;IF DESIRED NAME=NULL (STARTS 0FFH) THEN ;ENSURE 'MATCH' OF LOADED NAME BY COMP VS. SELF! ;IGNORE MISMATCH ON BIT 5 (LC/UC) ;JR IF MATCH BETWEEN LOADED NAME CHAR AND DESIRED ;NZ C REG SHOWS A MISMATCH ;LOADED NAME CHAR ;PRINT UNLESS TURNED OFF

;JR IF ANY MISMATCH OCCURRED - LOOK FOR ANOTHER

;CR AFTER LAST (MATCHED) FILE NAME

;CDE=80 BUT DE WILL CHANGE TO 17 IF ZX HDR FOUND ;'HEADER' ;'LOAD' ;RET IF LOAD FAILED ;TYPE 0-3 IF ZX HEADER, 16-20 IF SAM ;RET IF A SAM HEADER. CY STILL SHOWS 'OK' ;ENSURE VISIBLE, UNPROTECTED ;RET IF OTHER THAN ZX CODE HDR (CY) ;TYPE=SAM CODE ;ZX FILE LEN ;SAM LENGTH FORMAT ;NORMAL 'SCREEN MODE' FOR SAM CODE FILE ** ;ZX START ADDR ;DEST ADDR MSB

;TRANSFORM 17-BYTE ZX CODE HEADER INTO SAM HEADER

;FILE TYPE=SCREEN$ ;MODE 0

LD A,C LD (HDL+16),A ;SET SCREEN MODE OR 'NO MODE' XOR A LD (HDL+HFG),A ;NO PROTECT OR INVIS CALL PAGEFORM DEC A LD (HDL+HDN),A LD (HDL+HDN+1),HL ;SAM START ADDR FORMAT (IRREL IF SCREEN$) LD A,0FFH

E4BA E4BD E4BE E4BF E4BF E4C2 E4C5 E4C7 E4C9 E4CB E4CB E4CD E4CD E4CE E4CF E4D2 E4D4 E4D4 E4D8 E4D9 E4DA E4DB E4DB E4DB E4DB E4DE E4DF E4E0 E4E2 E4E2 E4E5 E4E7 E4E7 E4EA E4EA E4EA E4EA E4EA E4EA E4EA E4EB E4EC E4ED E4F0 E4F0 E4F3 E4F6 E4F6 E4F9 E4FA E4FD E4FE E4FF E500 E501 E502 E503 E506 E507 E509 E50C E50C E50C E50C E50C E50C E50F E510 E511 E511 E513 E514 E515 E515 E517 E519 E51A E51A E51D E51E E51E E520 E521 E521 E524 E525 E526 E526 E529 E52B E52C E52C E52C E52C E52E E52F E531 E533 E534 E535 E535 E535 E535

32754B 37 C9 211F4B 3A004B FE13 3E00 2002 DBFA 86 77 CD1AE5 2807 DD21004B CF 84 C9 3A335A 1F 1F 3808 CD26E5 3E03 CC01E0 SAHDDB: AF 4F 3C 115000 21004B CD08E6 211F4B 7E CDDF3F 23 5E 23 56 D5 23 CD3F20 E1 3EFF C308E6 ; SAPA2: SAMAIN:

LD (HDL+HDN+6),A SCF RET LD LD CP LD JR HL,HDR+HDN A,(HDR) 19 A,0 NZ,SAPA2

;NO EXEC ADDR ;'OK'

;JR IF NOT CODE ;ADJUST START PAGE

IN A,(250) ADD A,(HL) LD (HL),A CALL TORN JR Z,SVFL LD IX,HDR RST 08H DB SVHK RET LD A,(TPROMPTS) RRA RRA JR C,SAHDDB CALL TCHK LD A,3 CALL Z,WTBRK IN A,(250) ; INC A ; CALL TSURPG XOR A LD C,A INC A LD DE,80 ; LD HL,HDR+4000H LD HL,HDR CALL SABYTES LD HL,HDR+HDN LD A,(HL) CALL TSURPG INC HL LD E,(HL) INC HL LD D,(HL) PUSH DE INC HL CALL RDTHREE POP HL LD A,0FFH JP SABYTES

;LET ROM HANDLE T SAVE, OR NET SAVE IF NO DOS ;DOS SAVE

SADOS:

;JUMP FROM DOS (E=2) - SAVE ENTIRE FILE TO TAPE OR NET SVFL:

;JR IF NO SAVE PROMPTS WANTED ;'START TAPE..' MSG NO. ;GIVE MSG IF TEMP DEVICE=T

;SAVE HEADER, AND DATA BLOCK SPECIFIED BY HEADER ;PAGE WITH HDR IN ;PAGE IN AT 8000H ;'HEADER' (A=1) ;CDE=80 (HEADER LEN) ;SAVE HEADER

;DE=ADDR TO START SAVING FROM (SWITCHED IN) ;CDE=LEN ;START ;MAIN BLOCK

;GET SCREEN LEN ;ENTRY: A=MODE. EXIT: ADE=001B00H IF MODE 0, 003800H IF MODE 1, ELSE 012000H 11001B A7 C8 1638 3D C8 3E01 1620 C9 CD26E5 C8 FE4E C0 3AC25B A7 C9 3AB75B FE54 C9 E67F 57 DBFC E67F BA C9 TCHK: TORN: SCRLEN: LD DE,1B00H AND A RET Z LD D,38H DEC A RET Z LD A,1 LD D,20H RET CALL TCHK RET Z CP "N" RET NZ LD A,(DOSFLG) AND A RET LD A,(SLDEV) CP "T" RET AND 7FH LD D,A IN A,(VIDPORT) AND 7FH CP D RET ;MIDI OUT BIT INACTIVE ;MODE 0 SCRN LEN ;MODE 1 SCRN LEN=3800H ;A=16K PAGE. MODES 2 AND 3 LEN=4000H+2000H

;CALLED BY VIDSEL AND TAPEMN CUS2:

INCLUDE TAPEX.SAM ; ;TAPEX.SAM - TAPE/NET EXECUTIVE ROUTINES

E535 E535 E535 E535 E535 E536 E538 E53B E53C E53F E540 E543 E543 E547 E54A E54A E54A E54A E54B E54C E54D E54D E54D E54D E54E E54E E551 E552 E554 E556 E558 E558 E55B E55C E55E E55F E55F E55F E55F E55F E55F E560 E561 E564 E566 E566 E569 E56A E56B E56C E56D E56E E571 E571 E572 E573 E574 E576 E576 E578 E578 E579 E57A E57B E57B E57C E57C E57C E57C E57C E57C E57D E57E E57F E582 E582 E583 E584 E586 E586 E587 E589 E589 E58A E58A E58D E58D E58E E590 E591 E593 E594 E594 E595 E597 E597 E598 E599 E59A E59C E59C E59E E5A0

;SAVE CDE BYTES FROM HL TO NET. TYPE ON STACK ;HDR/DATA FLAG ON STACK C5 0664 CD5F00 C1 CD3DE7 F1 CD4DE5 DD2142E6 CD6CE7 D9 7C D9 F5 CD5D0E AF DBF8 E602 20F6 CD5D0E F1 D3FD C9 NMOUT: NMOUT1: WNF: PUSH BC LD B,100 CALL DELBC POP BC CALL CKNET POP AF CALL NMOUT LD IX,NOSR CALL NIXR ;NET SEND PARITY EXX LD A,H EXX ;NET/MIDI OUT PUSH AF CALL BRKCR XOR A IN A,(CLUTPORT) AND 2 JR NZ,NMOUT1 CALL BRKCR POP AF OUT (MDIPORT),A RET ;ENTRY: HL POINTS TO DATA TO SAVE, CDE=LEN TO SAVE (PAGEFORM) A=TYPE (AND FIRST ;BYTE TO SAVE). 01=HEADER, FF=DATA ;EXIT: NC IF ALL SAVED, CY IF SPACE PRESSED F3 F5 CD26E5 20CF CD0420 F1 F5 D9 47 08 3AB85B 6F 3C 87 3002 3EFE 3C 67 E5 4F SVLC: SABLK: DI PUSH AF CALL TCHK JR NZ,WNF CALL CDENORM POP AF PUSH AF EXX LD B,A EX AF,AF' LD A,(SLDEV+1) LD L,A INC A ADD A,A JR NC,SVLC LD A,0FEH INC A LD H,A PUSH HL LD C,A ;HI VALUE IF CY ;H PRODUCES DELAY ABOUT TWICE AS LONG AS L ;LEADER DELAY ;CONVERT CDE TO 19-BIT

;WAIT FOR FREE NET ;SEND TYPE

;INITIALISE PARITY BYTE WITH TYPE ;SPEED. MAX SPEED IF 19 (GIVES ABOUT 5*ZX) ;HIGHER VALUES GIVE LOWER SPEEDS.

;NOW FIDDLE NO. OF LEADER CYCLES TO USE TO KEEP LEN ROUGHLY CONST. WHATEVER THE ;SVSPEED. 128 OR MORE=LC*2, 86-127=LC*3, 64-85=LC*4, 52-63=LC*5, 43-51=LC*6 ;37-42=LC*8,.... 19=LC*14 AF 67 6F 11B80B 19 81 30FC 04 1001 29 110202 7A EE0F 57 D3FE 41 05 20FD 2B 7C B5 20F1 CB39 CB39 0C SVTYP: SVHDR: SVCLC: XOR A LD H,A LD L,A LD DE,3000 ADD HL,DE ADD A,C JR NC,SVCLC INC B DJNZ SVTYP ADD HL,HL LD DE,0202H LD A,D XOR 0FH LD D,A OUT (KEYPORT),A LD B,C DEC B JR NZ,SVDL0 DEC HL LD A,H OR L JR NZ,SVHDR SRL C SRL C INC C ;DELAY REG*16 ;JR IF DATA ;LONGER LEADER IF HEADER ;D'=BORDER LS 3 BITS - RED

SVDL0:

;LOOP TILL LEADER SAVED ;QUARTER LENGTH PULSES NOW

E5A1 E5A2 E5A3 E5A5 E5A6 E5A8 E5A8 E5A9 E5AA E5AB E5AD E5AE E5B0 E5B0 E5B1 E5B3 E5B3 E5B4 E5B4 E5B5 E5B7 E5B9 E5B9 E5BA E5BA E5BC E5BC E5BD E5BE E5C0 E5C2 E5C4 E5C4 E5C7 E5C7 E5C8 E5C8 E5CA E5CA E5CC E5CC E5CC E5CC E5CC E5CC E5CD E5CE E5CF E5D0 E5D0 E5D0 E5D2 E5D2 E5D3 E5D4 E5D5 E5D5 E5D6 E5D8 E5DA E5DA E5DB E5DC E5DE E5DE E5DF E5E0 E5E1 E5E2 E5E3 E5E3 E5E5 E5E7 E5E9 E5EA E5EB E5EB E5EC E5ED E5EF E5F1 E5F2 E5F4 E5F4 E5F6 E5F8 E5F8 E5F9 E5FA E5FA E5FB E5FC E5FD E5FF E601 E601 E602 E603 E604 E604 E606 E608 E608

0C 0C 2E02 1D 20E5 E1 F1 5F 1601 37 CB13 4C 3801 4D 7A EE0F D3FE 41 10FE 0D 0D EE0F CB13 D3FE CACCE5 41 10FE 18E4 SVDL2: SVDL: SV2: SVBL:

INC C INC C LD L,2 DEC E JR NZ,SVHDR POP HL POP AF LD E,A LD D,1 SCF RL E LD C,H JR C,SV2 LD C,L LD A,D XOR 0FH OUT (KEYPORT),A LD B,C DJNZ SVDL DEC C DEC C XOR 0FH RL E OUT (KEYPORT),A JP Z,SVBY LD B,C DJNZ SVDL2 JR SVBL

;IN CASE VERY SMALL - HELPS AVOID SYNC BEING MISSED ;2 HALF-CYCLES ONLY ;JR IF SYNC PULSE TIME ;DELAY CONSTANTS FOR HI/LOW BITS ;TYPE BYTE ;FIRST BYTE ;D'=BORDER LS 3 BITS - BLUE ;ASSUME HI BIT ;GET DELAY FOR A LOW BIT ;BORDER COLOUR. ;FLIP MIC AND BORDER BITS ;38 OR 37 FROM SVBL TO END OF OUT INSTRUCTION ;55 OR 54 FROM PREV OUT, PLUS DELAY (IF WITHIN BYTE ;THESE 2 INSTRUCTIONS GIVE DELAY OF 13*C, -1 ;SUB 26 Ts FROM DELAY ;NC ;34 TO END OF OUT FROM PREV OUT, PLUS DELAY ;JP IF TIME FOR NEXT BYTE ;ELSE CY/NC SHOWS NEXT BIT

;FROM SVBL: 38/37,OUT,13*R-1,34,OUT,13*R-27,22; 38/37,OUT ETC. R=REGISTER ;E.G. REG=20: 38/37,OUT,293,OUT,293/291,OUT,293 (0.098 MSEC AT 6MHZ) ;E.G. REG=43: 38/37,OUT,592,OUT,592/591,OUT, (0.197 MSEC AT 6MHZ) D9 7A B3 79 200C 3C 3C C8 0D FE03 3004 08 47 1805 1B 46 08 A8 08 3EF7 DBF9 E620 37 C8 23 7C FEC0 DBFB 3C 3804 2680 D3FB 78 D9 5F 79 04 D611 3803 3C 47 37 CB13 18C0 CD5FE5 SV6: SABYTES: SV5: SV4: SVBY: EXX LD A,D OR E LD A,C JR NZ,SV4 INC A INC A RET Z DEC C CP 3 JR NC,SV4 EX AF,AF' LD B,A JR SV45 DEC DE LD B,(HL) EX AF,AF' XOR B EX AF,AF' LD A,0F7H IN A,(STATPORT) AND 20H SCF RET Z INC HL LD A,H CP 0C0H IN A,(251) INC A JR C,SV5 LD H,80H OUT (251),A LD A,B EXX LD E,A LD A,C INC B SUB 17 JR C,SV6 INC A LD B,A SCF RL E JR SVDL2 CALL SABLK ;NEXT BYTE TO SAVE ;ORIG DELAY, MINUS 2 ;B=1 ;COMP FOR EXTRA TIME TAKEN GETTING NEXT BYTE ;USE B=1 IF DELAY COUNTER CARRIED ;ENSURE NOT ZERO ;DELAY 182 Ts LESS ;SHOWS BYTE ALL SENT WHEN ROTATED OUT. ;ABOUT 187 EXTRA TO HANDLE THIS BYTE

;FF IF PARITY SENT, FE IF LAST JUNK BYTE SENT ;(SO PARITY LAST BIT TERMINATED CORRECTLY) ;0 IF LAST 64K BLOCK SENT ;JR IF MOD 64K NOT SAVED YET ;RET IF ALL BYTES SAVED - NC, Z ;DEC NUMBER OF 64K BLOCKS ; ;JR IF ORIG WASN'T FF OR 0 - SOME BLOCKS LEFT ;PARITY

;BYTE TO SAVE ;PARITY

SV45:

;RET IF ESC KEY HIT - CY

;READY IN CASE PASSED BFFF ;JR IF OK (ADDR HASN'T PASSED BFFF YET) ;NEXT PAGE

E60B E60C E60E E60E E611 E611 E612 E613 E616 E618 E61B E61C E61D E61D E61D E61D E61D E61E E61F E620 E621 E621 E622 E625 E625 E628 E62A E62A E62B E62C E62D E62F E62F E633 E636 E636 E636 E636 E639 E639 E63C E63C E63D E63E E63F E63F E641 E642 E642 E642 E642 E643 E646 E648 E648 E648 E648 E64B E64D E64D E64E E650 E650 E651 E652 E654 E654 E655 E656 E658 E658 E659 E65A E65B E65C E65C E65D E65D E65D E65D E65D E65D E65D E65D E65E E65F E662 E664 E664 E665 E668 E66C E66F E670 E671 E673 E675 E675 E675 E678 E679 E679 E67B

3F 1803 CD5DE6 FB 08 3A4B5C D3FE CD5D0E 08 C9 LDBYTES: SVLDCOM:

CCF JR SVLDCOM CALL LDBLK EI EX AF,AF' LD A,(BORDCOL) OUT (KEYPORT),A CALL BRKCR EX AF,AF' RET

;NOW CY=OK

;NC IF ERROR ;CHECK BREAK, STOP IF REQUIRED ;C IF OK

;LOAD CDE BYTES TO HL FROM NET. TYPE ON STACK F1 47 08 78 F5 CD3DE7 CD4FE7 30FB 47 F1 B8 20F2 DD2148E6 CD6CE7 CD4FE7 D2BEE2 D9 AC D9 FE01 C9 7E CD4DE5 1810 CD4FE7 30EC 08 3004 08 77 1804 08 BE 20E1 D9 AC 67 D9 C9 NTV: NTVL: NOSR: NERR: WNH: POP AF LD B,A EX AF,AF' LD A,B PUSH AF CALL CKNET CALL NMIN JR NC,WTNI LD B,A POP AF CP B JR NZ,WNHL LD IX,NISR CALL NIXR ;NET PARITY CHECK CALL NMIN JP NC,TERROR EXX XOR H EXX CP 1 RET ;NET OUT SR. OUTPUTS THE BYTE AT (HL), INCLUDES IN PARITY LD A,(HL) CALL NMOUT JR NTVL CALL NMIN JR NC,NERR EX AF,AF' JR NC,NTV EX AF,AF' LD (HL),A JR NTVL EX AF,AF' CP (HL) JR NZ,NERR EXX XOR H LD H,A EXX RET ;ENTRY: HL=DEST TO LOAD DATA TO, CDE=LEN TO SAVE (PGFORM), A=TYPE (CHECKED VS ;FIRST BYTE ON TAPE). 01=HEADER, FF=DATA. (IF TAPE TYPE=ZX HEADER, 17 BYTES ;WILL BE LOADED ;EXIT: CY IF LOADED OK, NC IF ERROR F3 F5 CD26E5 20B9 F1 CD0420 ED43C85A 22CA5A 0C 08 3E08 D3FE CD690E C8 0608 CD4520 LDERR: LDSTRT: LDBLK: DI PUSH AF CALL TCHK JR NZ,WNH POP AF CALL CDENORM LD (TEMPW1),BC LD (TEMPW2),HL INC C EX AF,AF' LD A,8 OUT (KEYPORT),A CALL BRKTST RET Z LD B,8 CALL EDGE2 ;CONVERT CDE TO 19-BIT ;SAVE C (64K BLOCKS) ;DEST ADDR ;NZ ;NZ=FIRST BYTE, NC=VERIFY, CY=LOAD ;ENSURE MIC BIT STARTS OFF OR WE CANNOT READ EAR! ;INIT EDGE TYPE. BORDER WILL GO WHITE ;RET IF ESC PRESSED - NC ;LOOK FOR ALTERED EAR SIGNAL ;JR IF VERIFYING ;LOAD BYTE ;VERIFY BYTE ;CY IF LOAD ;WAIT FOR FREE NET ;WAIT FOR A BYTE

WNHL: WTNI:

;WAIT FOR HDR OR DATA MARKER

;NET INPUT SR. LOAD OR VERIFY NET BYTE WITH (HL), INCLUDE IN PARITY NISR:

;PARITY BYTE

E67E E680 E680 E683 E685 E685 E686 E687 E689 E68A E68A E68C E68C E68C E68C E68F E691 E691 E692 E693 E694 E695 E696 E697 E698 E69A E69B E69C E69D E69E E69F E6A0 E6A1 E6A2 E6A3 E6A5 E6A5 E6A7 E6A7 E6A8 E6A9 E6AA E6AB E6AB E6AD E6AD E6AE E6B0 E6B0 E6B1 E6B3 E6B5 E6B6 E6B6 E6B7 E6B8 E6BA E6BB E6BD E6BE E6BF E6C0 E6C1 E6C2 E6C4 E6C5 E6C6 E6CA E6CB E6CC E6CC E6CD E6CF E6CF E6CF E6CF E6CF E6D1 E6D4 E6D5 E6D7 E6D7 E6D8 E6D9 E6DB E6DB E6DE E6DF E6E1 E6E1 E6E2 E6E4 E6E5 E6E6 E6E9 E6EA E6EC E6EC E6EE E6EF E6F0 E6F2 E6F2

30F5 CD4520 30F0 D9 6F 0600 D9 2E00 CD4520 30E4 D9 60 4D 29 29 29 29 ED42 4F 09 29 29 29 29 6C 7D 91 3002 ED44 87 87 BD D9 30CC 2D 20DC 78 E6F8 F602 47 D9 7D CB3F 47 CB3F 8D 5F 53 15 15 CB3A 78 85 ED4BC75A 04 D9 67 CB3C BLWAV: LDLDR:

JR NC,LDERR CALL EDGE2 JR NC,LDERR EXX LD L,A LD B,0 EXX LD L,0 CALL EDGE2 JR NC,LDERR EXX LD H,B LD C,L ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL SBC HL,BC LD C,A ADD HL,BC ADD HL,HL ADD HL,HL ADD HL,HL ADD HL,HL LD L,H LD A,L SUB C JR NC,BLWAV NEG ADD A,A ADD A,A CP L EXX JR NC,LDSTRT DEC L JR NZ,LDLDR LD A,B AND 0F8H OR 02H LD B,A EXX LD A,L SRL A LD B,A SRL A ADC A,L LD E,A LD D,E DEC D DEC D SRL D LD A,B ADD A,L LD BC,(TEMPW1-1) INC B EXX LD H,A SRL H

;LOOP IF TIMEOUT OR ESC

;LOOK AT 256 SAMPLES ;LOOK FOR TWO EDGES ;JR IF BREAK OR TIMEOUT ;HL=AV. B=0 ;BC=AV ;*16 ;*15 ;BC=SAMPLE ;*15+NEW SAMPLE ;H=NEW AV (HL/16) ;KEEP RUNNING AVERAGE OF PULSE WIDTH IN L ;LAST PULSE WIDTH ;GET ABS DIFF FROM AV. ;4*ABS DIFF FROM AVERAGE SHOULD BE LESS THAN AV. ;(+/-25%)

;A SIGNAL HAS BEEN FOUND - SEE IF LEADER

;LOOK FOR 256 LEADER PULSES ;L ENDS AS ZERO - PARITY BYTE INIT STATE. ;RED BORDER NOW

;A=1.25*AV LDR PULSE LEN ;E'=MAX LEN FOR 'LONG' (HI) BIT ;FIDDLE A BIT TO CENTRALIZE.. ;D'=HALF THAT - SHORT/LONG DECISION VALUE ;B'=64K BLOCKS, PLUS 1 ;0.75*AV

;NOTE: WAITING FOR SYNC THIS WAY ENSURES BOTH HALVES OF ALL PULSES KEPT TOGETHER ;WHATEVER POLARITY OF SIGNAL, AS WELL AS SHOWING START OF DATA 0E00 CD4C20 BC 30A2 87 BC 30F4 CD4C20 BC 30EE 78 EE03 47 D9 2ACA5A D9 182A CB11 24 25 2003 24 LDTYPE: WTSYNC: LD C,0 CALL EDGSENS CP H JR NC,LDSTRT ADD A,A CP H JR NC,WTSYNC CALL EDGSENS CP H JR NC,WTSYNC LD A,B XOR 3 LD B,A EXX LD HL,(TEMPW2) EXX JR LDSTART RL C INC H DEC H JR NZ,LDTCP INC H ;CP 1.50*AV HALF-CYCLE LEN ;ERROR IF TOO LONG (>0.75*AV) ;2*HALF-CYCLE ;CP 1.50*AV HALF-CYCLE LEN ;LOOP UNTIL FIRST HALF OF SYNC PULSE*2<1.50*AV ;HALF CYCLE. IE WAIT UNTIL 0.75 OR LESS OF AV. ;C IS CARRIED IN AS START VALUE ;A=TIME FOR WHOLE POSSIBLE SYNC PULSE ;INSIST WHOLE SYNC PULSE<0.5*AV WHOLE CYCLE ;NEW BORDER COLOURS ARE BLUE AND YELLOW ;DEST PTR ;JUMP TO LOAD TYPE BYTE ;SAVE CY ;JR IF NOT TYPE 0 (ZX HEADER) ;NOW TYPE=1 (SAM HEADER)

E6F3 E6F5 E6F5 E6F6 E6F7 E6F7 E6F8 E6F9 E6FA E6FC E6FC E6FD E6FD E6FE E6FF E700 E702 E702 E703 E704 E704 E705 E705 E706 E706 E707 E708 E709 E70B E70D E70E E710 E710 E712 E714 E714 E715 E716 E716 E718 E71A E71A E71D E71E E71E E71F E720 E721 E721 E722 E723 E724 E724 E726 E728 E72A E72A E72B E72C E72D E72D E72E E730 E730 E731 E732 E733 E735 E735 E736 E738 E739 E739 E73A E73C E73D E73D E73D E73D E73D E73E E73E E740 E740 E743 E745 E746 E748 E748 E749 E74A E74B E74D E74D E74E E74F E74F E74F E74F E74F E750 E753 E753

1E11 AC C0 79 1F 08 181A D9 08 7C D9 3803 AE C0 3E 77 08 23 7C FEC0 DBFB 3C 3804 2680 D3FB D9 1B 2601 0E03 CD4720 D0 D9 BB D0 BA 3F D9 CB14 0E00 30F0 7D AC 6F 08 20BC 08 7B B2 20C8 D9 10C4 D9 7D FE01 C9 LDDEC: LDSTART: LDBITS: LDNVER: LDNEXT: LDLOOP: LDDE: LDTCP:

LD E,17 XOR H RET NZ LD A,C RRA EX AF,AF' JR LDSTART EXX EX AF,AF' LD A,H EXX JR C,LDNVER XOR (HL) RET NZ DB 3EH LD (HL),A EX AF,AF' INC HL LD A,H CP 0C0H IN A,(251) INC A JR C,LDDEC LD H,80H OUT (251),A EXX DEC DE LD H,1 LD C,3 CALL EDGEC RET NC EXX CP E RET NC CP D CCF EXX RL H LD C,0 JR NC,LDBITS LD A,L XOR H LD L,A EX AF,AF' JR NZ,LDTYPE EX LD OR JR AF,AF' A,E D NZ,LDDE

;LEN=ZX HEADER LEN ;SEE IF TYPE FLAG A' MATCHES TYPE BYTE LOADED ;RET IF NOT - NC, NZ ;GET CY BACK. CAN'T USE RR C - CHANGES Z

LDVERIF:

;RET IF MATCH FAILED - NC,NZ ;"JR+1" ;STORE LOADED BYTE ;PROTECT FLAGS ;INC DEST PTR

;JR IF NOT PAST BFFFH ;NEXT PAGE ;DEC BYTE COUNT ;MARKER BIT SET IN DEST SHIFT REG ;COMP FOR TIME LOST BY HANDLING BYTE ;RET IF TIMEOUT OR SPACE PRESSED ;RET IF TOO LONG ;NC IF SHORTER THAN 'DECISION' REGISTER ;ACCUMULATE BITS IN H ;LOOP FOR ALL 8 BITS (TILL THE MARKER ROTATED OUT) ;PARITY BYTE ;MODIFIED ;WITH NEW DATA ;NO DEC B IF TYPE BYTE

;LOOP TO LOAD DE BYTES

EXX DJNZ LDLOOP EXX LD A,L CP 1 RET ;CHECK IF NET BUSY ;PARITY ;CY SET IF OK (ZERO)

E5 2604 CD5D0E DBFC 17 30F6 2B 7C B5 20F3 E1 C9

CKNET: CKNT1: CKNT2:

PUSH HL LD H,4 CALL BRKCR IN A,(VIDPORT) RLA JR NC,CKNT1 DEC HL LD A,H OR L JR NZ,CKNT2 POP HL RET

;LOOP TILL FREE

;ENSURE FREE FOR A WHILE

;NET/MIDI IN. GETS BYTE IN A (CY) OR NC AND A=0 IF NO BYTE E5 212C01 2B NMIN: NMIN1: PUSH HL LD HL,300 DEC HL

E754 E755 E756 E758 E758 E75B E75D E75F E761 E761 E763 E765 E767 E767 E769 E76A E76A E76B E76C E76C E76C E76D E76E E76F E76F E771 E772 E773 E775 E775 E776 E777 E77A E77D E77E E77F E780 E782 E782 E782 E782 E783 E784 E785 E785 E786 E788 E78B E78E E78F E790 E792 E792 E792 E792 E792 E792 E792 E792 E792 E792 E792 E792 E794 E798 E798 E799 E79D E7A1 E7A2 E7A4 E7A6 E7A7 E7A9 E7AB E7AB E7AC E7AE E7AE E7AE E7AE E7B1 E7B4 E7B6 E7B8 E7B8 E7B9 E7BB E7BB E7BC E7BD E7BF E7C0 E7C3 E7C4 E7C7 E7C8 E7C9 E7CC E7CD E7CF E7D2 E7D2

7C B5 2812 CD5D0E DBF9 CB57 20F2 DBF9 CB57 28FA DBFD 37 E1 C9 D9 67 D9 CBBA 79 A7 280D F5 D5 110040 CD82E7 D1 F1 3D 20F3 7A B3 C8 7C FEC0 D4F23F CD2D00 23 1B 18F0 NIXL: NMIN3: NIXR: NMIN2:

LD A,H OR L JR Z,NMIN3 CALL BRKCR IN A,(STATPORT) BIT 2,A JR NZ,NMIN1 IN A,(STATPORT) BIT 2,A JR Z,NMIN2 IN A,(MDIPORT) SCF POP HL RET EXX LD H,A EXX RES 7,D LD A,C AND A JR Z,NIXJ PUSH AF PUSH DE LD DE,4000H CALL NIXJ POP DE POP AF DEC A JR NZ,NIXL LD A,D OR E RET Z LD A,H CP 0C0H CALL NC,INCURPAGE ;** BUG FIX AND RE-WRITE CALL IXJUMP ;INPUT OR OUTPUT INC HL DEC DE JR NIXJ INCLUDE USING.SAM ;INSTR, LENGTH, STRING$, XOINTERS ;USING.SAM ;POINTERS ;ENTRY: HL=LOCN (PAGED IN), CDE=ADJUSTMENT, CY IF SUBTRACT ;EXIT: PAGCOUNT/MODCOUNT=BLOCK SIZE TO MOVE, AHL=OLD WKEND ; XOI3: ; ; LD B,3 LD IY,NUMENDP JR X31 LD B,14 LD IY,SAVARSP EX AF,AF' LD (TEMPW4),BC LD (TEMPW5),DE EX DE,HL IN A,(251) AND 1FH LD C,A BIT 6,D JR Z,PNT1 INC C RES 6,D PNT1: ; ; PUSH BC PUSH DE LD A,(WKENDP) LD HL,(WKEND) BIT 6,H JR Z,PNT15 INC A RES 6,H PNT15: PUSH AF PUSH HL IN A,(251) PUSH AF CALL ADDRNV PUSH HL CALL PNLP LD A,C POP BC LD HL,(NVARS) AND A SBC HL,BC CALL NZ,SADJ ;SAVE ORIG WKEND (END OF BLOCK TO MOVE) ;14 SYS VARS TO DO ;FIRST SYS VAR TO CONSIDER ;CY'=ADD/SUB FLAG ;PARITY BYTE ;16K BLOCKS

;DO 16K

;NET SAVE/LOAD/VERIFY 0-16K BYTES (DE BYTES FROM HL) NIXJ:

060E FD21815A 08 ED434D5B ED534F5B EB DBFB E61F 4F CB72 2803 0C CBB2 3A8D5A 2A8E5A CB74 2803 3C CBB4 F5 E5 DBFB F5 CD1F1F E5 CDA11E 79 C1 2A885A A7 ED42 C425E8

XOINTERS: X31:

;MAKE LOCN IN SECTION C ;ADJUSTED LOCN

;DO B SYS VARS

;IF NVARS HAVE MOVED, PROGRAM HAS ALTERED, SO ;CHECK ADDRESSES ON GOSUB/DO/PROC STACK. ;NOTE: DELETE OF 16K EXACTLY WILL BE MISSED..

E7D2 E7D3 E7D4 E7D6 E7D9 E7DC E7DC E7DD E7E0 E7E1 E7E2 E7E4 E7E7 E7E7 E7E8 E7E9 E7E9 E7E9 E7EA E7EB E7EE E7EF E7F1 E7F1 E7F2 E7F6 E7FA E7FD E7FE E7FE E7FF E801 E804 E805 E808 E809 E80A E80B E80B E80B E80E E811 E813 E816 E818 E818 E819 E81A E81C E81E E81E E81F E81F E820 E821 E823 E823 E824 E825 E825 E825 E825 E825 E826 E827 E82A E82A E82B E82D E82F E82F E830 E831 E835 E836 E837 E83A E83C E83D E83E E83F E840 E840 E841 E842 E845 E846 E847 E849 E84A E84B E84C E84D E84E E84F E851 E853 E855 E855 E856 E857 E858 E85A

4F F1 D3FB 3A935A CD0BE8 6F 3AB05A A7 7D 2E96 CC18E8 E1 F1 ; F5 E5 CDE71F 08 300D 08 ED4B4D5B ED5B4F5B CDE71F 08 08 CBBC 32835B 23 22845B E1 F1 C9 21905A CD18E8 2E8D CD18E8 2E99 F5 AE E61F 2805 35 23 23 CBF6 F1 C9 SMBS2: PNBS: ;

LD C,A POP AF OUT (251),A LD A,(ELINEP) CALL SMBW LD L,A LD A,(CLA+1) AND A LD A,L LD L,>CHADP CALL Z,SMBS POP HL POP AF POP DE POP BC PUSH AF PUSH HL CALL SUBAHLCDE EX AF,AF' JR NC,PNBS EX AF,AF' LD BC,(TEMPW4) LD DE,(TEMPW5) CALL SUBAHLCDE EX AF,AF' EX AF,AF' RES 7,H LD (PAGCOUNT),A INC HL LD (MODCOUNT),HL POP HL POP AF RET LD HL,WORKSPP CALL SMBS LD L,>WKENDP CALL SMBS LD L,>KCURP PUSH AF XOR (HL) AND 1FH JR Z,SMBS2 DEC (HL) INC HL INC HL SET 6,(HL) POP AF RET

;MAKE WORKSP AND ;WKEND SAME BASE PAGE AS ELINE

;IF RUNNING ELINE, MAKE CHAD SAME BASE AS ELINE ;AHL=OLD WKEND ;CDE=ORIG LOCN ;OLD WORKEND ;AHL=BLOCK SIZE TO MOVE IF MAKEROOM ;JR IF MAKEROOM

;SUBTRACT BLOCK SIZE IF RECLAIM

;ONE EXTRA (MODCOUNT MAY BE 4000H NOW) ;AHL=OLD WKEND

SMBW:

SMBS:

;IF WORKSPACE IS ON PAGE ABOVE, ADJUST ;TO SAME BASE AS ELINE

;STACK ADJUST ;80H=DO, 40H=PROC, 00=GOSUB C5 4F 2AC45B 7E FEFF 2011 E1 D5 ED53CC5A 51 08 CD0102 EE1E 08 D1 79 C9 F5 E5 CD9C1E E1 F1 E6E0 B6 77 23 23 23 23 E6E0 FE40 20D5 7E 23 B6 20FB SADJ2: SADJ: SADJL: PUSH BC LD C,A LD HL,(BSTKEND) LD A,(HL) CP 0FFH JR NZ,SADJ2 POP HL PUSH DE LD (TEMPW3),DE LD D,C EX AF,AF' CALL R1OFFCL DW AFLPS EX AF,AF' POP DE LD A,C RET PUSH AF PUSH HL CALL ASSV POP HL POP AF AND 0E0H OR (HL) LD (HL),A INC HL INC HL INC HL INC HL AND 0E0H CP 40H JR NZ,SADJL LD A,(HL) INC HL OR (HL) JR NZ,FPTLP ;OLD (STILL CORRECT!) NVARS ;CDE=LOCN ;TYPE/PAGE ;NVARS

;ADJUST FOR-NEXT LOOPS

;SAVE B BITS 7-5 OF PAGE ;ADJUST SINGLE "SYS VAR"

;KEEP TYPE BITS 7-5 ;SKIP PAGE ;SKIP OFFSET ;SKIP STAT ;ISOLATE TYPE BITS ;JR IF NOT PROC

FPTLP:

E85A E85B E85D E85D E85D E85D E85D E85D E85E E85F E863 E863 E866 E868 E869 E86B E86B E86C E86D E86F E870 E872 E873 E875 E876 E877 E877 E877 E877 E877 E877 E877 E877 E877 E87A E87B E87C E87E E880 E880 E883 E885 E885 E889 E88B E88C E88C E88D E88D E891 E894 E895 E895 E895 E895 E895 E895 E895 E898 E89B E89D E89D E89F E89F E8A0 E8A1 E8A2 E8A3 E8A3 E8A5 E8A5 E8A8 E8A8 E8AB E8AC E8AC E8AE E8AF E8AF E8AF E8AF E8AF E8B2 E8B2 E8B3 E8B6 E8B7 E8B8 E8BB E8BC E8BF E8BF E8C2 E8C2 E8C3 E8C4 E8C5 E8C5 E8C6 E8C7 E8C8 E8C9 E8CC

23 18CD

INC HL JR SADJL

;LOOP WHEN PROC DOUBLE ZERO TERMINATOR FOUND

;SEND BYTE IN 'A' TO PRINTER C5 F5 ED4B105A CD5D0E ED78 0F 38F8 0D F1 ED79 0C ED41 05 ED41 C1 C9 SNDA2: SENDLP: PUSH BC PUSH AF LD BC,(LPTPRT1) CALL BRKCR IN A,(C) RRCA JR C,SENDLP DEC POP OUT INC OUT DEC OUT POP RET C AF (C),A C (C),B B (C),B BC ;C=CONTROL PORT, B=1 ;STOP IF BREAK PRESSED ;TEST BIT 0 ;LOOP TILL NOT BUSY ;DATA TO DATA PORT ;STROBE SIGNAL TO CONTROL PORT ;CANCEL STROBE PULSE (ABOUT 2.6 USECS)

;HEAP ROOM ;ENTRY: BC=BYTES TO RESERVE (IF +VE) OR BYTES TO RELEASE (IF -VE) ;EXIT: DE=OLD HEAPEND (ROOM START). RELEASE OF >=HEAP SIZE MAKES IT EMPTY. ;E.G. LD BC,0C000H:CALL HEAPRM WILL MAKE HEAP MT. ;HL=NEW HEAPEND (ROOM+1). CAN BE CALLED WITH BC=0. NC INDICATES NOT ENOUGH ;ROOM. (HL=DEGREE OF OVERFLOW, 0+ BYTES). BC IS PRESERVED. 2AC85B 09 7C FE40 3005 2ACA5B 1808 ED5BC45B ED52 D0 19 ED5BC85B 22C85B C9 HEAPR3: HEAPR2: HEAPROOM: LD HL,(HEAPEND) ADD HL,BC LD A,H CP 40H JR NC,HEAPR2 LD HL,(HPST) JR HEAPR3 LD DE,(BSTKEND) SBC HL,DE RET NC ADD HL,DE LD DE,(HEAPEND) LD (HEAPEND),HL RET ;(4200H TO ABOUT 4A00H) ;JR IF HEAP NOT EMPTY AFTER ADJUSTMENT ;EMPTY HEAP

;RET IF NEW HEAPEND WOULD BE >=BSTKEND

;USING.SAM. USING AND INARRAY/INSTRING, LENGTH, STRING$ ;******************************************************************************* ;INSTRING FUNCTION - E.G. PRINT INSTR(2,S$,T$) OR INSTR(S$,T$) CD8B3A CD083B 2008 3009 EF E9 06 33 1803 CD9B3A CDA93A D0 DBFB F5 INSTR2: INSTR3: IMINSTR: CALL SINSISOBRK CALL EXPTEXPR JR NZ,INSTR2 JR NC,INSTR3 DB DB DB DB CALC STKONE SWOP EXIT ;'(' ;EXITS WITH Z IF $, NZ IF NUM, C IF RUNNING ;JR IF FOUND NUMBER FOR SEARCH START ;AVOID STACKING DEFAULT OF 1 IF SYNTAX CHK ;S$ ;S$,1 ;1,S$

JR INSTR3 CALL EXPTCSTR CALL EXPTCSTRB RET NC IN A,(URPORT) PUSH AF ;FETCH TARGET$, COPY TO PAGE 0 BUFFER IF LENGTH 1-255, ;FETCH SEARCH$. GET DE=S$ ST, BC=S$ LEN, A=T$ LEN, NC. S$ PAGED IN ;COMMA, SEARCH$ ;COMMA, TARGET$, ')' ;DON'T RET HERE IF NOT RUNNING

CDEA3E F5 CDDC3F D5 C5 CD2E1D B0 CA312E 3A055A D9 4F D9 0B E1 D1 F1 CDD0E8 F1

CALL SBFSR PUSH AF CALL GETSTRING PUSH DE PUSH BC CALL GETINT OR B JP Z,SWER2 LD A,(INSTHASH) EXX LD C,A EXX DEC BC POP HL POP DE POP AF CALL INARRAYEN POP AF

;COPY $ ON FPCS TO INSTBUF ;INV ARG IF T$ LEN >255. A=LEN, NC ON EXIT ;T$ LEN, NC ;S$ ST TO DE, LEN TO BC, PAGE IN ;S$ ST ;S$ LEN ;START TO BC. A=C ;ERROR IF POSN=0

;C'=HASH OR EQUIVALENT ;POSN >=0 ;S$ LEN ;S$ ST ;T$ LEN

E8CD E8D0 E8D0 E8D0 E8D0 E8D1 E8D2 E8D4 E8D4 E8D4 E8D4 E8D5 E8D8 E8D8 E8DA E8DB E8DD E8DD E8DE E8E0 E8E0 E8E3 E8E3 E8E4 E8E5 E8E6 E8E7 E8EA E8EA E8ED E8EE E8F0 E8F2 E8F2 E8F3 E8F6 E8F9 E8FB E8FB E8FB E8FB E8FB E8FC E8FC E8FF E900 E901 E903 E904 E905 E907 E907 E907 E907 E908 E909 E90D E910 E912 E912 E913 E914 E915 E916 E916 E916 E916 E919 E91C E91F E922 E924 E927 E927 E928 E92B E92C E92E E930 E930 E931 E934 E935 E935 E937 E937 E937 E937 E938 E939 E939 E93C E93C E93F E940 E942 E942 E945 E945 E948 E949 E94C E94C

C32FD1 ; C5 4F 0600 A7 CA333C ED42 C1 3803 23 ED42 DA343C EB 13 08 09 DC9D1F CDEF3F 7A FE3F 3815 D5 11FF3E CD07E9 3017 ; ; EB 01FF3E 09 E3 ED42 EB C1 18E3 08 F5 ED43475B CD0102 FE3B 08 F1 08 C9 CD8B3A CDE43A CD853A CD0102 733F CA082D DF CDC33A 08 CB69 2807 DF CDC33A D0 1815 08 D0 F24CE9 CD331D A7 204A 2A2151 3A2351 47 C32F18 C5 IMLENC: IMLEN3: IMLEN2: MINSR: INSTBKLP: NOTFND3H: INARRAYEN:

JP OSBC OUT (URPORT),A ; JP STACKBC PUSH BC LD C,A LD B,0 AND A JP Z,NOTFND2 SBC HL,BC POP BC JR C,NOTFND3H INC HL SBC HL,BC JP C,NOTFND3 EX DE,HL INC DE EX AF,AF' ADD HL,BC CALL C,PGOVERF CALL CHKHL LD A,D CP 3FH JR C,MINSR PUSH DE LD DE,3EFFH CALL MINSR JR NC,JUNKS POP DE RET EX DE,HL LD BC,3EFFH ADD HL,BC EX (SP),HL SBC HL,BC EX DE,HL POP BC JR INSTBKLP EX AF,AF' PUSH AF LD (BCSTORE),BC CALL R1OFFCL DW R0INST EX AF,AF' POP AF EX AF,AF' RET

;OUT (URPORT),A: JP STACKBC ;POSN ;A=T$ LEN ;BC=T$ LEN ;DE=S$ START ;HL=S$ LEN ;STACK=POSN ;NOT FOUND IF T$ LEN=0 ;SBC S$ LEN,T$ LEN ;POSN ;NOT FOUND IF TARGET$ LEN > SEARCH$ LEN ;SUB START POSN ;JR IF START POSN TOO FAR UP SEARCH$ ;DE=BYTES TO CHECK ;MODIFY START-OF-SEARCH PTR NOW IN HL ;IF OVERFLOW, GET HL IN 8000-BFFF AREA ;IF NEEDED, GET HL IN 8000-BFFF AREA ;JR IF OK FOR A SEARCH WITHOUT OVERFLOW ;LEN >=3F00 ;SEARCH 3EFF BYTES ;IF FOUND, JUNK PREV LEN, NC. BC=POSN ;JUNK PREVIOUS LEN ;FOUND - BC=POSN FOUND, NC ;ELSE A'=T$ LEN ;DE=S$ PTR, HL=START POSN ;INCR START POSN FOR NEW SEARCH ;HL=PREV. LEN, (SP)=START POSN ;DE=REMAINING LEN TO SEARCH, HL=S$ PTR ;START POSN

;ENTRY: A'=T$ LEN, HL=S$ PTR, DE=BYTES TO SEARCH, BC=START POSN

JUNKS:

;E.G. LENGTH(1,A$) OR LENGTH(2,B()) IMLENGTH: CALL SINSISOBRK CALL EXPT1NUM CALL INSISCOMA CALL R1OFFCL DW LENGSR JP Z,VNFERR RST 18H CALL EXCBRF EX AF,AF' BIT 5,C JR Z,IMLEN2 RST 18H CALL EXCBRF RET NC JR IMLEN3 ;E.G. ALPHA OR ASD$ EX AF,AF' RET NC JP P,IMLEN3 CALL GETBYTE AND A JR NZ,IMLERR LD HL,(MEMVAL) LD A,(MEMVAL+2) LD B,A JP ASBHL PUSH BC ;ADDR OF NUMERIC VALUE ;ADJUST BHL TO REL PAGE, STACK ;C=T/L ;RET IF SYNTAX TIME ;JR IF STRING VAR

;SETS BIT 6,(FLAGS) FOR NUM/STR ;ERROR IF NOT FOUND IN RUNTIME ;INSIST ON A$() OR XXX() ;CY IF RUNNING ;JR IF NOT NUMERIC ARRAY ;INSIST ON E.G. (1,AL() ) ;RET IF SYNTAX TIME

E94D E950 E951 E954 E955 E955 E955 E955 E955 E955 E956 E958 E959 E95A E95B E95C E95E E95E E95F E960 E961 E962 E962 E965 E967 E967 E968 E969 E96A E96B E96C E96D E96E E970 E970 E971 E972 E973 E974 E974 E975 E977 E97A E97B E97C E97E E97E E97F E97F E97F E97F E980 E981 E983 E983 E984 E987 E987 E988 E989 E98C E98C E98D E98E E98E E98E E98E E98E E991 E992 E992 E993 E994 E995 E996 E997 E998 E999 E99A E99B E99B E99E E99F E9A1 E9A1 E9A2 E9A4 E9A7 E9A7 E9A8 E9AB E9AC E9AD E9B0 E9B1 E9B2 E9B3 E9B4 E9B4 E9B5 E9B6 E9B8 E9B8

CD331D C1 212451 F5

CALL GETBYTE POP BC LD HL,MEMVAL+3 PUSH AF

;PTR TO LEN DATA

;ENTRY: C=TYPE BYTE, HL PTS TO HEADER DATA ;EXIT: HL PTS TO START OF TEXT, DE=EL LEN, ;BC=NO OF ELS. SIMPLE STRINGS HAVE EL LEN OF 1. 79 E660 7E 23 4E 23 2009 0F 0F B6 47 110100 180D 23 7E 23 4E 23 46 3D 28F2 23 5E 23 56 7D D623 2A2151 85 6F 3001 24 F1 A7 28C2 3D CADD1C EB 3D CAD61C CF 1E IMLERR: ASSAR6: ASSAR5: ASSAR3: ASSAR4: LD A,C AND 60H LD A,(HL) INC HL LD C,(HL) INC HL JR NZ,ASSAR4 RRCA RRCA OR (HL) LD B,A LD DE,1 JR ASSAR5 INC HL LD A,(HL) INC HL LD C,(HL) INC HL LD B,(HL) DEC A JR Z,ASSAR3 INC HL LD E,(HL) INC HL LD D,(HL) LD A,L SUB >MEMVAL+2 LD HL,(MEMVAL) ADD A,L LD L,A JR NC,ASSAR6 INC H ; HL=ARRAY ST, DE=EL. LEN, BC=EL NOS POP AF AND A JR Z,IMLENC DEC A JP Z,STACKBC EX DE,HL DEC A JP Z,STACKHL RST 08H DB 30 ;IOOR

;JR IF ARRAY ;A=PAGES OF SIMPLE STRING LEN ;BC=STRING LEN ('EL NUMBERS') ;DE='ELEMENT' LEN ;DIMS

;IF DIMS=1, USE BC AS EL. NOS, 1 AS EL LEN ;IF DIMS=2, DE IS LOADED WITH EL. LEN

;GET BYTES FROM DIMS TO TEXT

;******************************************************************************* ;STRING$(N,A$) CDCB3A D0 EF C8 25 D8 25 51 1D 00 33 CD2E1D B0 2820 78 FE02 D2283A C5 CDE43E C5 D5 CD331D E1 54 5D C1 C5 E5 EDB0 E1 STRSL: IMSTRINGS: CALL EXBNCSB RET NC DB DB DB DB DB DB DB DB DB CALC STOD0 DUP RCL0 DUP LEN SWOP23 MULT EXIT ;(N,$) ;RET IF SYNTAX TIME ;N,$ ;N ;N,N ;N,N,$ ;N,N,$,$ ;N,N,$, LEN $ ;N,$,N, LEN $ ;N,$,RESULT LEN

CALL GETINT OR B JR Z,STRINGSN LD A,B CP 2 JP NC,STLERR PUSH BC CALL SBUFFET PUSH BC PUSH DE CALL GETBYTE POP HL LD D,H LD E,L POP BC PUSH BC PUSH HL LDIR POP HL

;JR IF RESULT LEN ZERO ;LIMIT LEN TO <512 CHARS TO FIT BUFFER ;RESULT ;COPY $ ;$ LEN ;BUFFER ;N IN A ;BUFFER ;$ LEN ;MAKE REPEATED COPIES FROM BUFFER START ;(FIRST ONE ON TOP OF ITSELF!) LEN TO BUFFER, ERROR IF LEN >255. BC=LEN START START

E9B9 E9BA E9BB E9BD E9BD E9BE E9C1 E9C1 E9C1 E9C1 E9C1 E9C2 E9C3 E9C4 E9C5 E9C5 E9C8 E9C8 E9C8 E9C8 E9C8 E9CB E9CD E9CF E9CF E9D2 E9D5 E9D6 E9D8 E9D9 E9DA E9DB E9DB E9DB E9DC E9DD E9DE E9DE E9DE E9DE E9DF E9E0 E9E1 E9E3 E9E3 E9E3 E9E5 E9E7 E9E7 E9E9 E9E9 E9E9 E9EB E9ED E9ED E9ED E9EE E9F0 E9F2 E9F2 E9F2 E9F2 E9F5 E9F6 E9F7 E9F9 E9F9 E9FC E9FD E9FE E9FE E9FE E9FE E9FF EA00 EA01 EA04 EA05 EA07 EA07 EA0A EA0A EA0C EA0F EA0F EA10 EA11 EA12 EA13 EA14 EA15 EA17 EA17 EA19 EA1A EA1B EA1C EA1C EA1D EA1E EA20 EA22 EA22

C1 3D 20F7 C1 C3673C

POP BC DEC A JR NZ,STRSL POP BC JP CWKSTK ;RESULT LEN ;COPY RESULT TO WKSPACE AND STACK PARAMS.

;NULL STRING RESULT IF EG STRING$(0,"AA") OR STRING$(10,"") ;BC=0 EF 07 07 33 C3DD1C STRINGSN: DB DB DB DB CALC DROP DROP EXIT ;N,$ ;N ;

JP STACKBC ;CIRCLE/FILL SR. UNSTACKS COORDS TO B,C (NC) OR FIDDLED COORDS IN BC (CY) ; AND TEMPW1 IS SET UP AS OFFSET TO X COORD IF THIN PIX.

CD0102 9327 380F 3A745B 21405A 86 D6ED 37 3F C0 69 67 29

CIFILSR:

CALL R1OFFCL DW GTFCOORDS JR C,CIFISR2 LD A,(CURCMD) LD HL,MODE ADD A,(HL) SUB 0EBH+2 SCF CCF RET NZ LD L,C LD H,A ADD HL,HL

;v2.6 ;Y COORD IN B, X IN C, OR X IN HL AND CY IF THIN ;JR IF THINPIX

;FILLTOK+2 ;NC ;RET UNLESS: MODE 2, FATPIX, FILL ;(CUR CMD MUST BE 9A,9D OR EB) ;X=X*2. (ALWAYS USE THIN PIX SYSTEM FOR FILL)

;HL=X, B=Y 7C A7 7D 2006 FE80 3806 1809 FE80 3805 4D 2E00 1807 118000 4B A7 ED52 22C85A 37 C9 D5 E5 47 112C67 0D 2003 112D6F 3EED 21004D 77 23 72 23 73 23 10F8 36C9 E1 D1 C9 C5 0D 0EA8 2004 0E CRTBF: CRBB2: CRBBL: ;X>=0100H THINC2: ;X>017FH THINC3: CIFISR2: LD A,H AND A LD A,L JR NZ,THINC2 ;IF X IS <80H, JR, USE L (X LSB) AS X, ADD HL OF 0

;X IS <=00FF CP 80H JR C,THINC3 JR THINC4 CP 80H JR C,THINC4 LD C,L LD L,0 JR THINC5 LD DE,80H LD C,E AND A SBC HL,DE LD (TEMPW1),HL SCF RET PUSH DE PUSH HL LD B,A LD DE,672CH DEC C JR NZ,CRBB2 LD DE,6F2DH LD A,0EDH LD HL,CDBUFF LD (HL),A INC HL LD (HL),D INC HL LD (HL),E INC HL DJNZ CRBBL LD (HL),0C9H POP HL POP DE RET PUSH BC DEC C LD C,0A8H JR NZ,CRTB2 DB 0EH

;IF X>017FH, NO JR, USE L AS X, ADD HL OF 0100H

;X IS BETWEEN 80H AND 017FH THINC4: ;PRETEND CENTRE X IS 128 ;HL=0-FF=DISP TO ADD TO 80H CENTRE TO GET REAL CRD ;"THINPIX"

THINC5:

;PIXEL ROLL/SCROLL SR CRBBFN:

;2ND BYTE OF RRD/INC L ;JR IF MOVE RIGHT ;2ND BYTE OF RLD/DEC L ;1ST BYTE OF RLD OR RRD

;"RET"

;JR IF LDD WANTED ;"JR+1"

EA23 EA23 EA24 EA24 EA26 EA26 EA27 EA28 EA2A EA2D EA2D EA2E EA2F EA30 EA31 EA33 EA33 EA35 EA36 EA37 EA38 EA38 EA38 EA38 EA38 EA38 EA38 EA38 EA3B EA3C EA3D EA3F EA40 EA41 EA42 EA44 EA44 EA46 EA47 EA47 EA4A EA4D EA4E EA4F EA50 EA51 EA53 EA56 EA57 EA58 EA5B EA5B EA5C EA5D EA5E EA5E EA5F EA60 EA61 EA62 EA63 EA64 EA65 EA66 EA67 EA68 EA68 EA69 EA6A EA6B EA6C EA6D EA6E EA6F EA70 EA71 EA72 EA73 EA74 EA75 EA76 EA77 EA78 EA79 EA7A EA7B EA7C EA7D EA7E EA7E EA7F EA7F EA80 EA81 EA81 EA84 EA84 EA85 EA86 EA87 EA88 EA89 EA8A

C5 0EA0 E5 47 3EED 21004D 77 23 71 23 10FA 36C9 E1 C1 C9

CRTBFI: CRTB1: CRTB2:

PUSH BC LD C,0A0H PUSH HL LD B,A LD A,0EDH LD HL,CDBUFF LD (HL),A INC HL LD (HL),C INC HL DJNZ CRTBL LD (HL),0C9H POP HL POP BC RET ;"RET" ;ELSE LDI

CRTBL:

;DRCURVE ;DRAW TO X,Y,Z. MEM0 HOLDS Z, REGS HOLD FIDDLED COORDS (NOW DISPLACEMENTS). ;PUT COORDS BACK ON STACK, REPLACE Z. ;ENTRY: B=Y DIFF, C (OR HL IF THIN)=X DIFF, D=SGN Y, E=SGN X (01/FF) 3A4D5A A7 7B ED44 58 D5 EB 2803 1600 59 2A655C CDBCCB 23 23 D1 7A 1600 CDBCCB 23 23 22655C EF D8 33 EF 5D D5 E0 00 39 25 5C 1E 18 C8 5D 06 25 41 06 1C 25 41 1D 01 D8 05 41 D8 06 25 E6 03 2F 1E 07 07 07 33 C33CEB 25 43 26 02 06 05 DD DRCURV3: DROPEX: DRCURVE: DRT2: DRTCRV: LD A,(THFATT) AND A LD A,E NEG LD E,B PUSH DE EX DE,HL JR Z,DRT2 LD D,0 LD E,C LD HL,(STKEND) CALL STORADE INC HL INC HL POP DE LD A,D LD D,0 CALL STORADE INC HL INC HL LD (STKEND),HL DB CALC DB RCL0 DB EXIT DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC NEGATE STO5 STKHALF MULT SIN DUP NOT JPTRUE DROPEX-DRHLB STOD0 NEGATE SWOP DUP ABS SWOP SWOP13 DUP ABS SWOP23 ADDN RCL0 DIVN ABS RCL0 SWOP DUP STKFONE SUBN GRTE0 JPTRUE 07H ;Z IF THIN ;SGN X ;SGN Y, Y DIFF ;JR IF THIN PIX - DE=X DIFF ;DE=X DIFF ;FIDDLE SGN AND PUT DE ON FPCS ;PT TO NEXT NUMBER AREA ON FPCS ;SGN Y, Y DIFF

;GET CURVATURE BACK ;X,Y,-Z ;X,Y,Z (REVERSE ANGLE SO CURVES IN RIGHT DIRECTION) ;X,Y,Z (M5=Z) ;X,Y,Z,0.5 ;X,Y,Z/2 ;X,Y,SIN(Z/2) ;X,Y,SIN(Z/2),SIN(Z/2) ;X,Y,SIN(Z/2),1/0 ;JP IF APPROX. A STRAIGHT LINE, DROPEX ;X,Y (M0=SIN(Z/2) ;X,Y (REVERSED BECAUSE OF INVERSE Y AXIS) ;Y,X ;Y,X,X ;Y,X,ABS X ;Y,ABS X,X ;X,ABS X,Y ;X,ABS X,Y,Y ;X,ABS X,Y,ABS Y ;X,Y,ABS X,ABS Y ;X,Y,ABS X+ABS Y ;X,Y,ABS X+ABS Y,SIN(Z/2) ;X,Y,(ABS X+ABS Y)/SIN(Z/2) ;X,Y,FF ;X,Y,FF,SIN(Z/2) ;X,Y,SIN(Z/2),FF ;X,Y,SIN(Z/2),FF,FF ;X,Y,SIN(Z/2),FF,FF,1 ;X,Y,SIN(Z/2),FF,FF-1 ;X,Y,SIN(Z/2),FF,1/0 (1 IF FF>=1) ;JP IF NOT A STRAIGHT LINE, DRCURV3 ;X,Y,SIN(Z/2) ;X,Y

DRHLB:

DB DROP DB DROP DB EXIT JP LINEDRAW DB DB DB DB DB DB DB DUP SQR ONELIT 02H SWOP DIVN RCL5

;X,Y,SIN(Z/2),FF,FF ;X,Y,SIN(Z/2),FF,SQR FF ;" ;" ;" " " " ,FF,2,SQR FF ,FF,2/SQR FF ,FF,2/SQR FF,Z

EA8B EA8C EA8D EA8E EA8F EA8F EA92 EA94 EA96 EA96 EA97 EA99 EA9B EA9B EA9C EA9C EA9D EA9D EA9E EA9F EAA0 EAA1 EAA2 EAA3 EAA4 EAA5 EAA6 EAA7 EAA8 EAA9 EAAA EAAB EAAC EAAD EAAE EAAF EAB0 EAB1 EAB2 EAB3 EAB3 EAB4 EAB5 EAB6 EAB7 EAB8 EAB9 EABA EABB EABC EABD EABE EABF EAC0 EAC1 EAC2 EAC3 EAC4 EAC5 EAC6 EAC7 EAC8 EAC9 EACA EACB EACC EACD EACE EACF EAD0 EAD1 EAD2 EAD3 EAD4 EAD5 EAD6 EAD7 EAD8 EAD9 EADA EADB EADC EADD EADE EADF EAE0 EAE1 EAE2 EAE3 EAE3 EAE4 EAE5 EAE7 EAEA EAEA EAEB EAEC EAED EAEF EAF0 EAF1 EAF2 EAF3

06 05 41 33 CD651D 06FC 3806 A0 C604 2801 47 C5 EF DD 23 05 25 39 CC 25 E0 00 39 D1 06 C8 25 00 E0 05 E6 06 03 CB 07 D9 06 05 C9 06 25 D9 00 CA 06 25 D9 00 C9 DD D8 03 E0 00 25 39 D5 06 3A C8 D9 00 D8 DA 00 01 D9 06 C9 D8 00 DD DA 00 03 D2 41 D9 41 01 07 33 C1 1A FE81 DA3CEB EF 06 2A 425A D0 01 06 29 415A DRCURV4:

DB DB DB DB

SWOP DIVN ABS EXIT

;" ; ;

"

,FF,Z,2/SQR FF ,FF,Z*SQR FF/2 ,FF,ABS(Z*SQR FF/2)

CALL FPTOA LD B,0FCH JR C,DRCURV4 AND B ADD A,4 JR Z,DRCURV4 LD B,A PUSH BC DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC RCL5 STKBREG DIVN DUP SIN STOD4 DUP STKHALF MULT SIN STO1 SWOP STOD0 DUP MULT STKHALF DIVN STKFONE SWOP SUBN STOD3 DROP RCL1 SWOP DIVN STOD1 SWOP DUP RCL1 MULT STOD2 SWOP DUP RCL1 MULT STOD1 RCL5 RCL0 SUBN STKHALF MULT DUP SIN STO5 SWOP COS STOD0 RCL1 MULT RCL0 RCL2 MULT ADDN RCL1 SWOP STOD1 RCL0 MULT RCL5 RCL2 MULT SUBN STO2 ABS RCL1 ABS ADDN DROP EXIT

;JR IF TOO BIG ;A=00-FC ;A=04-00H ;JR IF TOO BIG ;ARCS IN B ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ,FF ,FF,Z ,FF,Z,ARCS ,FF,Z/ARCS ,FF,Z/ARCS,Z/ARCS ,FF,Z/ARCS,SIN(Z/ARCS) ,FF,Z/ARCS ,FF,Z/ARCS,Z/ARCS ,FF,Z/ARCS,Z/ARCS,0.5 ,FF,Z/ARCS,Z/2*ARCS ,FF,Z/ARCS,SIN(Z/2*ARCS) ,FF,Z/ARCS,SIN(Z/2*ARCS) ,FF,SIN(Z/2*ARCS),Z/ARCS ,FF,SIN(Z/2*ARCS) ,FF,SIN(Z/2*ARCS),SIN(Z/2*ARCS) ,FF,SIN(Z/2*ARCS)*SIN(Z/2*ARCS) ,FF,SIN(Z/2*ARCS)*SIN(Z/2*ARCS),0.5 ,FF,SIN(Z/2*ARCS)*SIN(Z/2*ARCS)*2 ,FF,SIN(Z/2*ARCS)*SIN(Z/2*ARCS)*2,1 ,FF,1,SIN(Z/2*ARCS)*SIN(Z/2*ARCS)*2 ,FF,1-SIN(Z/2*ARCS)*SIN(Z/2*ARCS)*2 ,FF

;X,Y,SIN(Z/2) ;X,Y,SIN(Z/2),SIN(Z/2*ARCS) ;X,Y,SIN(Z/2*ARCS),SIN(Z/2) ;X,Y,SIN(Z/2)/SIN(Z/2*ARCS) (CALL IT V) ;X,Y (M1=V) ;Y,X ;Y,X,X ;Y,X,X,V ;Y,X,X*V ;Y,X (M2=X*V) ;X,Y ;X,Y,Y ;X,Y,Y,V ;X,Y,Y*V ;X,Y (M1=Y*V) ;X,Y,Z ;X,Y,Z,Z/A ;X,Y,Z-Z/A ;X,Y,Z-Z/A,0.5 ;X,Y,(Z-Z/A)/2 (CALL IT T) ;X,Y,T,T ;X,Y,T,SIN T ;X,Y,T,SIN T (M5=SIN T) ;X,Y,SIN T,T ;X,Y,SIN T,COS T ;X,Y,SIN T (M0=COS T) ;X,Y,SIN T,Y*V ;X,Y,SIN T*Y*V ;X,Y,SIN T*Y*V,COS T ;X,Y,SIN T*Y*V,COS T,X*V ;X,Y,SIN T*Y*V,COS T*X*V ;X,Y,SIN T*Y*V+COS T*X*V (CALL IT P) ;X,Y,P,Y*V ;X,Y,Y*V,P ;X,Y,Y*V (M1=P) ;X,Y,Y*V,COS T ;X,Y,Y*V*COS T ;X,Y,Y*V*COS T,SIN T ;X,Y,Y*V*COS T,SIN T,X*V ;X,Y,Y*V*COS T,SIN T*X*V ;X,Y,Y*V*COS T-SIN T*X*V (CALL IT J) ;X,Y,J ;X,Y,ABS J ;X,Y,ABS J,P ;X,Y,ABS J,ABS P ;X,Y,ABS J+ABS P ;X,Y ;(DE)=EXP OF ABS J+ABS P

POP BC LD A,(DE) CP 81H JP C,LINEDRAW DB DB DB DW DB DB DB DB DW CALC SWOP LKADDRW XCOORD STO0 ADDN SWOP LKADDRB YCOORD ;Y,X ;Y,X,XCOORD ;Y,X,XCOORD ;Y,X+XCOORD ;X+XCOORD,Y ;X+XCOORD,Y,YCOORD

EAF5 EAF6 EAF7 EAF8 EAF9 EAFA EAFA EAFC EAFC EAFE EAFE EAFF EB00 EB01 EB02 EB03 EB04 EB05 EB06 EB07 EB08 EB09 EB0A EB0B EB0C EB0D EB0E EB0F EB10 EB10 EB11 EB12 EB13 EB14 EB15 EB16 EB18 EB19 EB1A EB1B EB1C EB1D EB1E EB1F EB21 EB22 EB23 EB24 EB24 EB25 EB28 EB2A EB2B EB2D EB2D EB2E EB2F EB30 EB31 EB32 EB34 EB35 EB36 EB37 EB39 EB3A EB3B EB3C EB3C EB3F EB41 EB44 EB44 EB44 EB44 EB44 EB44 EB44 EB44 EB47 EB49 EB49 EB4C EB4E EB4E EB51 EB52 EB55 EB56 EB57 EB59 EB59 EB59 EB59 EB59 EB5C EB5D EB5D EB5D EB5E EB5F EB60 EB61

D5 01 D8 DD 33 1014 182F EF D9 25 DB 00 DC DA 00 03 C9 DC 00 DB DA 00 01 CA 33 EF C8 D9 01 25 2A 425A 03 DA D8 01 D0 06 29 415A D8 03 33 C5 CD0102 9321 C1 10D1 EF 07 07 06 2A 425A 03 06 29 415A 06 03 33 CD0102 9321 C3C63F CURVEND: CURVLP:

DB DB DB DB DB

STO5 ADDN RCL0 RCL5 EXIT

;X+XCOORD,Y+YCOORD ;X+XCOORD,Y+YCOORD,XCOORD ;X+XCOORD,Y+YCOORD,XCOORD,YCOORD (END/START COORDS)

DJNZ CUENTRY JR CURVEND DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DW DB DB DB DB DB DB DB DW DB DB DB CALC RCL1 DUP RCL3 MULT RCL4 RCL2 MULT SUBN STOD1 RCL4 MULT RCL3 RCL2 MULT ADDN STOD2 EXIT CALC STOD0 RCL1 ADDN DUP LKADDRW XCOORD SUBN RCL2 RCL0 ADDN STO0 SWOP LKADDRB YCOORD RCL0 SUBN EXIT ;PREV X INC

;PREV Y INC ;NEW X INC

;NEW Y INC

CUENTRY:

;X INC ;PEEK X COORD ;Y INC

;PEEK Y COORD

PUSH BC CALL R1OFFCL DW DRAWFD POP BC DJNZ CURVLP DB DB DB DB DB DW DB DB DB DW DB DB DB CALC DROP DROP SWOP LKADDRW XCOORD SUBN SWOP LKADDRB YCOORD SWOP SUBN EXIT

;DRAW A LINE USING DISPS. ON FPCS, WITH XRG/YRG ;ADJUSTMENTS

LINEDRAW:

CALL R1OFFCL DW DRAWFD JP TRCURP

INCLUDE MISC31.SAM ;CALL, BORDER, ZOOM ETC, ;MISC31.SAM - CALL, BGRAPHICS, KEY, STRM16, NEW ;'CALL' CMD CDE43A 0E00 CD793A 2816 CD853A C5 CD083B C1 0C 30F0 ; ; ; 3A3B5C 47 EF 06 23 06 33 CALLER: FCALERLP: CALL EXPT1NUM LD C,0 CALL RCRC JR Z,FCALERCE CALL INSISCOMA PUSH BC CALL EXPTEXPR POP BC INC C JR NC,FCALERLP RLA SBC A,A INC A LD A,(FLAGS) LD B,A DB DB DB DB DB CALC SWOP STKBREG SWOP EXIT ;GET ADDR ;PARAMS COUNTER TO ZERO ;RST 18H, CRCOLON ;EXIT LOOP IF CR OR ':' ;Z=STR, NZ=NUM, CY IF RUNNING. (BIT 7,A GAVE Z/NZ)

;NC=STR, CY=NUMB ;STR=00, NUM=FF BUG**A IS CHAR BY THIS TIME ;STR=01, NUM=00 ;NOW STACK EXPR AND TYPE UNDER ADDR ;C IS SAVED ;ADDR,EXPR ;EXPR,ADDR ;EXPR,ADDR,TYPE ;EXPR,TYPE,ADDR

EB62 EB62 EB64 EB64 EB65 EB68 EB6B EB6B EB6E EB70 EB70 EB70 EB70 EB70 EB73 EB76 EB79 EB7C EB7F EB82 EB85 EB88 EB88 EB8A EB8B EB8B EB8C EB8F EB90 EB93 EB94 EB97 EB99 EB9C EB9E EB9E EB9E EBA4 EBA9 EBAE EBAE EBAE EBAF EBB1 EBB3 EBB3 EBB6 EBB7 EBB8 EBB9 EBBA EBBC EBBD EBBF EBC2 EBC5 EBC8 EBC9 EBCB EBCE EBCF EBD1 EBD1 EBD3 EBD4 EBD5 EBD7 EBD7 EBD8 EBD9 EBDA EBDB EBDD EBDD EBDE EBDF EBE1 EBE1 EBE2 EBE4 EBE6 EBE6 EBE8 EBEA EBEB EBED EBEF EBEF EBF0 EBF0 EBF1 EBF2 EBF3 EBF6 EBF8 EBFB EBFE EBFF EBFF EC01 EC02 EC04 EC04

18E5 79 32D05A CD153B CDFA01 FF17 FCALERCE:

JR FCALERLP LD A,C LD (TEMPB3),A CALL ABORTER CALL R1OFFJP DW CALLX ;CREATE ERROR, STAT, LINO

3A3A5C 119EEB CD88EB 2A455C 11A4EB CD8BEB 3A475C 11A9EB 2600 6F D5 CDD61C E1 113F51 7E 010600 EDB0 CDFA01 2B2B

SETUPVARS: LD A,(ERRNR) LD DE,ERVT CALL CRTVAR2 LD HL,(PPC) LD DE,ERVT+6 CALL CRTVAR3 LD A,(SUBPPC) LD DE,ERVT+11 CRTVAR2: CRTVAR3: LD H,0 LD L,A PUSH DE CALL STACKHL POP HL LD DE,TLBYTE LD A,(HL) LD BC,6 LDIR CALL R1OFFJP DW CRTVAR4 DB 4,"error" DB 3,"lino" DB 3,"stat" XOR A LD I,A IM 1 LD BC,CLUTPORT LD D,A ADD A,A ADD A,A ADD A,A OUT (C),A LD A,D OUT (URPORT),A LD HL,8000H LD DE,8001H LD BC,3FFFH LD (HL),L LDIR LD HL,8000H INC B LD E,40H LD (HL),0FFH LD D,(HL) INC D JR NZ,RAMEX LD (HL),D LD D,(HL) INC D DEC D JR NZ,RAMEX ADD HL,BC DEC E JR NZ,RMCK INC A CP 20H JR C,RMPS LD A,0FEH IN A,(0FEH) RRA LD A,10H JR NC,RAMEX ADD A,A RAMEX: LD B,A DEC A LD E,A LD (PRAMTP),A OUT (VIDPORT),A LD SP,ISPVAL LD HL,ALLOCT PUSH HL LD (HL),0 INC HL DJNZ ATIF SUB 21H

;PTR TO NAME

;PTR ;TLBYTE FOR SEARCH ;ENOUGH FOR 'ERROR' VAR

046572726F ERVT: 036C696E6F 0373746174 AF ED47 ED56 01F800 57 87 87 87 ED79 7A D3FB 210080 110180 01FF3F 75 EDB0 210080 04 1E40 36FF 56 14 2019 72 56 14 15 2013 09 1D 20F0 3C FE20 38CD 3EFE DBFE 1F 3E10 3001 87 47 3D 5F 32B45C D3FC 31004F 210051 E5 3600 23 10FB D621 MNINIT: RMPS:

;SET COLOUR 0

;CLEAR A PAGE ;BC=0100

RMCK:

;CHECK ALL BITS CAN BE ONES ;CHECK CAN BE ZEROED ;CHECK HOLDS ONE

;256K ;FORCE 256K SYSTEM IF SHIFT PRESSED ;20H=512K

;PHYSICAL RAMTOP PAGE (USUALLY 0F OR 1F) ;ANY NZ VAL STOPS SYS VARS APPEARING AS ATTR

ATIF:

;'FREE'

EC06 EC07 EC08 EC08 EC0A EC0B EC0D EC0D EC0E EC10 EC12 EC12 EC13 EC14 EC16 EC16 EC17 EC18 EC1B EC1E EC1E EC1F EC20 EC21 EC23 EC23 EC26 EC28 EC29 EC2A EC2B EC2E EC31 EC31 EC34 EC37 EC39 EC3B EC3B EC3C EC3C EC3F EC42 EC42 EC45 EC48 EC48 EC4B EC4F EC52 EC54 EC56 EC56 EC59 EC5C EC5E EC60 EC60 EC60 EC63 EC65 EC67 EC67 EC67 EC6A EC6C EC6E EC6E EC71 EC74 EC74 EC77 EC7A EC7A EC7D EC80 EC83 EC86 EC89 EC8B EC8B EC8E EC8F EC8F EC92 EC95 EC96 EC97 EC9A EC9C EC9E EC9E EC9F ECA0 ECA2 ECA4 ECA4 ECA7 ECA8 ECA9 ECAA ECAC ECAC

2F 47 36FF 23 10FB E1 3E40 0604 77 23 10FC 7D 3D 32B05C 32B15C 6B 2D 7D F660 329F5C 3EC0 77 23 77 21FFBF 22B25C 2169FC 11E158 0ED2 EDB0 EB 21CE59 CD72ED 21D59C 22A05A 11B65C ED534F5C 214AFC 0E1F EDB0 21DEFB 110058 0E44 EDB0 ; 11005A 0E12 EDB0 ; 11C65B 0E1A EDB0 219E1C 22E05A 214900 22705B CD39ED 219050 22365C 211055 227B5C 1804 CD153B F3 21A05C 229D5C 2B 7E 32785A D3FC 0610 23 77 3EFF 10FA 3AB45C 3D 3D 6F 2651 7E CSPL: NEW: NEW2: ATIU: ATIX:

CPL LD B,A LD (HL),0FFH INC HL DJNZ ATIX POP HL LD A,40H LD B,4 LD (HL),A INC HL DJNZ ATIU LD A,L DEC A LD (LASTPAGE),A LD (RAMTOPP),A LD L,E DEC L LD A,L OR 60H LD (FISCRNP),A LD A,0C0H LD (HL),A INC HL LD (HL),A LD HL,0BFFFH LD (RAMTOP),HL LD HL,KSRC LD DE,KTAB+1 LD C,70*3 LDIR EX DE,HL LD HL,KTAB+238 CALL PBSL

;IF PRAMTP WAS 0F, A=11H; IF 1F, A=01 ;'NON-EXISTENT/TERMINATOR' ;FILL REST OF TABLE WITH FF'S ;'IN USE, CONTEXT 0' ;PAGES TO RESERVE ;'USED BY CONTEXT A'

;LAST PAGE USED BY BASIC ;RAMTOP PAGE ;HL PTS TO SCREEN PAGES IN ALLOCT ;SCREEN PAGE=LAST POSSIBLE PAIR, MODE=3, MIDI ;BIT LOW (INACTIVE) ;'SCREEN'

;INIT MAIN KEYBOARD TABLES ;DE PTS TO TABLE OF VALUES AND DISPS TO NEXT ;DEST, ENDING IN ZERO ;DEST FOR BRIGHT CC ;B SHOULD BE ZERO ON ENTRY. EXITS UNCHANGED

LD HL,5CB6H+31+4000H LD (PROG),HL LD DE,5CB6H LD (CHANS),DE LD HL,CHANTAB LD C,31 LDIR

;INIT 6 CHANNELS

LD HL,DKSRC LD DE,DKBU LD C,DKEN-DKSRC+1 LDIR ;INIT DEF KEYS LD HL,CHIT LD DE,LNCUR LD C,18 LDIR LD HL,MAIT LD DE,BASSTK LD C,26 LDIR LD HL,NMISTOP LD (NMIV),HL LD HL,ANYI LD (ANYIV),HL CALL UPACK ;UNPACK CHAR SET LD HL,CHARSVAL-256 LD (CHARS),HL LD HL,CHARSVAL+896 LD (UDG),HL JR NEW2 CALL CHKEND DI LD HL,SCLIST LD (SCPTR),HL DEC HL LD A,(HL) LD (CUSCRNP),A OUT (VIDPORT),A LD B,16 INC HL LD (HL),A LD A,0FFH DJNZ SCLI LD A,(PRAMTP) DEC A DEC A LD L,A LD H,ALLOCT/256 LD A,(HL) ;PT TO FISCRNP

;INIT FIRST 18 BYTES OF SYS VARS

;13 IMPORTANT ADDRESSES INITED

SCLI:

;'CLOSED'

;SKIP PAST SCREEN 1

ECAD ECAF ECB1 ECB1 ECB2 ECB2 ECB3 ECB5 ECB5 ECB6 ECB9 ECBC ECBE ECBE ECBF ECC0 ECC1 ECC2 ECC3 ECC4 ECC6 ECC6 ECC8 ECC8 ECC9 ECCA ECCC ECCC ECCF ECD1 ECD2 ECD5 ECD8 ECDB ECDE ECE1 ECE4 ECE7 ECEA ECEB ECEE ECF1 ECF4 ECF5 ECF8 ECFB ECFE ED01 ED02 ED05 ED08 ED0A ED0D ED10 ED13 ED16 ED17 ED1B ED1B ED1B ED1B ED1E ED21 ED22 ED23 ED23 ED24 ED25 ED26 ED27 ED28 ED29 ED2A ED2B ED2C ED2D ED2E ED30 ED31 ED33 ED35 ED35 ED37 ED37 ED38 ED39 ED39 ED39 ED39 ED39 ED39 ED39 ED39 ED39 ED3C ED3D ED40 ED43 ED44 ED46 ED46 ED47 ED48

FEC0 2001 70 2D 20F7 4D 210C5C 118B02 0609 1A 13 77 23 71 23 10F8 0618 71 23 10FC CD321F 36FF 23 22885A 32875A 32935A CDA234 212103 22095C 212151 22685C 7C 32385C 32C65A 324D5A AF 32445A 32405A CD6B39 2A825A 23 22945A CD711D 3E03 CD5A01 CD80ED 31004F 21ED0E E5 ED733D5C 11D955 210056 45 4D 70 23 71 23 1A 13 77 23 77 23 78 C60B 47 FEA6 38EE 36FF CF 50 RBOWL: CLSTL: STRIL: DCSP:

CP 0C0H JR NZ,DCSP LD (HL),B DEC L JR NZ,CSPL LD LD LD LD C,L HL,STREAMS-4 DE,STRMTAB B,9

;JR IF NOT A SCREEN PAGE ;CLOSE SCREEN PAGE

;MUST BE IN ROM0! ;INITIALISE 9 STREAMS

LD A,(DE) INC DE LD (HL),A INC HL LD (HL),C INC HL DJNZ STRIL LD B,24 LD (HL),C INC HL DJNZ CLSTL CALL ADDRPROG LD (HL),0FFH INC HL LD (NVARS),HL LD (NVARSP),A LD (ELINEP),A CALL RESTOREZ LD HL,0321H LD (REPDEL),HL LD HL,MEMVAL LD (MEM),HL LD A,H LD (RASP),A LD (SPEEDIC),A LD (THFATT),A XOR A LD (THFATP),A LD (MODE),A CALL CLRSR LD HL,(SAVARS) INC HL LD (ELINE),HL CALL SETMIN LD A,3 CALL MODET CALL CLSHS2 LD SP,ISPVAL LD HL,MAINER PUSH HL LD (ERRSP),SP ;PROGRAM TERMINATOR ;12 MORE STREAM PTRS TO ZAP

;REPDEL=33, REPPER=3

;ANY NON-ZERO VALUE WILL DO ;TEMP FAT ;PERM THIN ;NOT MODE 3 SO XRG NOT HALVED ;CLEAR FPCS, BASIC STACK, NVARS, SAVARS

;SET MODE, CSIZE, WINDOWS

;RAINBOW SCREEN LD LD LD LD DE,PALTAB+1 HL,LINICOLS B,L C,L ;L=0 ;INIT SCAN NUMBER IN B

LD (HL),B INC HL LD (HL),C INC HL LD A,(DE) INC DE LD (HL),A INC HL LD (HL),A INC HL LD A,B ADD A,11 LD B,A CP 166 JR C,RBOWL LD (HL),0FFH RST 08H DB 50H

;PAL MEM ZERO

;ALT COLOUR=MAIN ;NEXT SCAN TO ALTER AT

;COPYRIGHT MSG

;UPACK - CALLED BY INITIALIZATION ROUTINE ;UPACK CHARSET FROM 5-BIT TO 8-BIT WITH 2 ZEROS AT LHS, 1 AT RHS. MAKE BOTTOM ;SCAN ZERO EXCEPT IN 13 CASES DEALT WITH SEPARATELY. ;CHAR DEFS. THIS ROUTINE TAKES 101 BYTES, WHEREAS A NORMAL LDIR WOULD TAKE 11. ;NET GAIN: 402 BYTES (NOTE:OUT OF DATE NOW FOREIGN SET DROPPED!) 210763 D9 214EFE 119051 AF 0605 4E 23 37 UPACK: LD HL,99*256+7 EXX LD HL,CHARSRC LD DE,CHARSVAL XOR A LD B,5 LD C,(HL) INC HL SCF ;H COUNTS 99 CHARS, L COUNTS 7 BYTES/CHAR

;5 BITS TO UNPACK ;AFTER FIRST PASS, C ROTATES IN NC. WHEN C=0, LAST

UPKGC:

ED49 ED49 ED4B ED4D ED4D ED4E ED50 ED50 ED51 ED52 ED53 ED54 ED56 ED57 ED58 ED59 ED5B ED5B ED5C ED5D ED5D ED5E ED60 ED61 ED62 ED64 ED64 ED67 ED67 ED69 ED6A ED6C ED6C ED6C ED6C ED6F ED72 ED72 ED72 ED72 ED73 ED74 ED75 ED76 ED77 ED78 ED79 ED7A ED7C ED7C ED7D ED7D ED7D ED7D ED80 ED80 ED80 ED80 ED83 ED86 ED86 ED87 ED88 ED89 ED8A ED8B ED8D ED8D ED8E ED8F ED91 ED92 ED95 ED95 ED95 ED95 ED95 ED96 ED99 ED9C ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F ED9F EDA2 EDA4 EDA4

;VALID DATA BIT HAS GONE, CY=JUNK (SET) CB11 28F9 17 10F9 07 12 13 AF 0605 D9 2D D9 20EE 12 13 D9 2E07 25 D9 20E5 218954 CBF6 23 10FB 1133FE 21F751 1A 13 77 1A 13 4F 09 A7 20F6 C9 ;CLS # CD143B CD5E11 011005 78 81 D7 AF D7 10F9 79 D7 3E07 D7 CD9E13 ; ; AF CD3AF1 CDA7ED C39806 ;ZBCI: CLSHS: CLSHS2: CLHSL: CALL SABORTER CALL STREAMFE LD BC,0510H LD A,B ADD A,C RST 10H XOR A RST 10H DJNZ CLHSL LD A,C RST 10H LD A,7 RST 10H CALL PER3 CALL ZBCI JP MCLS XOR A XOR A CALL SETBORD CALL COLINIT JP MCLS I,C I,B,C I,C LINE L or COLOUR I,B,C LINE L I LINE L=DELETE CHANGE OF I AT LINE L CLEARS ALL INTERRUPT CHANGES, RE-INITS PAL MEMORIES ;'S' ;CALLED BY NEW PBSL: SB5L: UPKBL: RL C JR Z,UPKGC RLA DJNZ UPKBL RLCA LD (DE),A INC DE XOR A LD B,5 EXX DEC L EXX JR NZ,UPKBL LD (DE),A INC DE EXX LD L,7 DEC H EXX JR NZ,UPKBL SET 6,(HL) INC HL DJNZ SB5L ;GET NEXT DATA BYTE IF C USED UP ;GET 5 BITS IN 'A' REG ;CENTRE DATA. ;NC, A=0 ;GET 5 BITS ;LOOP FOR 7 BYTES/CHAR ;8TH BYTE IS ZERO

;LOOP FOR 137 CHARS ;PT TO SECOND BYTE OF COPYRIGHT SIGN ;(FIRST OF 5 WHICH NEED BIT 6 SET) ;DO 5 BYTES

LD HL,95*8+CHARSVAL+1

;NOW PATCH CHARS WHERE BOTTOM SCAN IS USED LD DE,U8TAB LD HL,CHARSVAL+103 ;SCAN 7 OF COMMA ;CALLED TO UNPACK CONTROL KEY VALUES LD A,(DE) INC DE LD (HL),A LD A,(DE) INC DE LD C,A ADD HL,BC AND A JR NZ,PBSL RET ;BYTE TO PLACE ;TO DEST ;DISP TO NEXT DEST, OR 0 ;(B=0) ;PT HL TO NEXT DEST ;LOOP TILL TERMINATOR HIT

;PRINT CHR$ 15H/14H/13H/12H/11H ;OVER/INVERSE/BRIGHT/FLASH/PAPER 0 ;CHR$ 10H - PEN ;PEN 7 ;COPY TEMP EFFECTS OF COLOUR CODES TO PERMS.

;COLOUR.SAM ;E.G. PALETTE ; PALETTE ; PALETTE ; PALETTE ; PALETTE

;I=LOGICAL INK NUMBER (PALETTE MEMORY) 0-15. ;C IS A COLOUR NUMBER FROM 0-127. B AND C ARE 2 SUCH COLOURS TO ALTERNATE UNDER ;INTERRUPT CONTROL. VALUES ARE SIMPLY ENTERED INTO TWO TABLES USED BY THE ;FRAME INTERRUPT TO SET UP THE PALETTE 50 TIMES/SEC. IF TABLES MATCH, NO ;INKS FLASH, OTHERWISE FLASH HAPPENS AFTER (SPEEDINK) INTS. ;IF 'LINE L' IS USED, THE COLOUR(S) WILL ONLY BE SET FROM START OF SPECIFIED ;SCAN LINE (ACTUALLY RHS BORDER OF PRECEDING LINE). LINE CAN BE 174 TO -16. ;=SCANS 1-191. GIVES INT AT SCANS 0-190 (ACTUALLY END OF PRECEDING LINE), AND ;COLOUR CHANGE AT SCANS 1-191 ;UP TO 127 CHANGES CAN BE MADE PER SCREEN CD7A3A 2031 CD153B COLOUR: CALL CRCOLON JR NZ,COLOUR1 CALL CHKEND ;JR UNLESS JUST 'PALETTE'

EDA7 EDA7 EDA9 EDAC EDAF EDB2 EDB5 EDB8 EDBA EDBB EDBB EDBE EDC1 EDC4 EDC7 EDC7 EDC9 EDCC EDCC EDCF EDD2 EDD4 EDD5 EDD5 EDD8 EDDA EDDC EDDC EDDF EDDF EDE2 EDE3 EDE6 EDE9 EDEA EDEB EDEE EDEE EDEF EDF0 EDF1 EDF3 EDF3 EDF4 EDF4 EDF5 EDF6 EDF7 EDF9 EDF9 EDFA EDFB EDFD EDFD EDFE EDFF EE00 EE01 EE02 EE03 EE04 EE07 EE08 EE09 EE0B EE0C EE0D EE0D EE0E EE0F EE0F EE12 EE14 EE16 EE16 EE18 EE1A EE1A EE1D EE1D EE20 EE22 EE22 EE25 EE25 EE27 EE27 EE28 EE2B EE2E EE2F EE31 EE31 EE34 EE36 EE38 EE38 EE3B EE3B EE3D EE3E EE40 EE40

3EFF 320056 11D855 CDCCED CDCCED 3A405A FE02 C0 11D855 21E855 CDC7ED 11FC55 0604 C39918 011400 2151FD EDB0 C9 CDE43A FE8C 2033 CD573A CDC5EE F5 111710 CD621F D1 5F 210056 7E 23 BA 2806 D0 23 23 23 18F5 7E BB 20F7 54 5D 1B 23 23 23 E5 CDB5EE E1 F3 EDB0 FB C9 CF 17 CDDF3A FE2C 281B FE8C 2008 CD573A CDC5EE 1805 CD153B 3EFF F5 111880 CD621F F5 1820 CDE33A FE8C 2808 CD153B 3EFF F5 1807 CD573A

COLINIT:

LD A,0FFH LD (LINICOLS),A LD DE,PALTAB CALL COLINIT1 CALL COLINIT1 LD A,(MODE) CP 2 RET NZ LD DE,PALTAB LD HL,PALTAB+16 CALL PL4S LD DE,PALTAB+36 LD B,4 JP FPSWOPLP LD BC,20 LD HL,INITCOLS LDIR RET CALL EXPT1NUM CP LINETOK JR NZ,COLOUR5 CALL SSYNTAX6 CALL COLATSR PUSH AF LD DE,1000H+23 CALL LIMBYTE POP DE LD E,A LD HL,LINICOLS

;CLEAR INTERRUPT COL CHNG LIST ;DO IT TWICE

PALSW:

;IF CHANGING TO MODE 2, SAVE NON-MODE-2 PALTAB 0-3 ;TO STORE, AND GET BACK MODE 2 PALTAB 0-3 ;SWOP MAIN COLOURS. EXIT WITH HL=PALTAB+20 ;SWOP ALTERNATE COLOURS

PL4S: COLINIT1:

COLOUR1:

;I ;L OF 'PALETTE I LINE L' ;LINE ;LIMIT OF 16, INKVALERR ;I ;D=LINE ;E=I

COLDELP:

LD A,(HL) INC HL CP D JR Z,COLDEL2 RET NC INC HL INC HL INC HL JR COLDELP LD A,(HL) CP E JR NZ,COLDEL1 LD D,H LD E,L DEC DE INC HL INC HL INC HL PUSH HL CALL FLITD POP HL DI LDIR EI RET

;EXIT IF FOUND RIGHT SCAN ENTRY ;RET IF PAST ANY ENTRIES FOR LINE D

COLDEL1:

COLDEL2:

;JR IF WRONG I ;ELSE DELETE ENTRY ;DE PTS TO LINE VALUE ;HL PTS TO LINE VALUE OF NEXT ENTRY ;GET LEN TO TABLE END ;DELETE ENTRY. IF LINIPTR PTS BEFORE ;DELETED ENTRY, NO PROBLEM. IF PTS TO ; ;'Invalid colour' ;,C OF 'PALETTE I,C....' ;GET THIRD PARAM IF THERE IS ONE ;JR IF 'PALETTE I,C' ;LINE OF 'PALETTE I,C LINE L

INKVALERR: COLOUR5:

RST 08H DB 23 CALL EXPTCNUM CP "," JR Z,COLOURFL CP LINETOK JR NZ,COLSING CALL SSYNTAX6 CALL COLATSR JR COLOUR10

COLSING: COLOUR10:

CALL CHKEND LD A,0FFH PUSH AF LD DE,8000H+24 CALL LIMBYTE PUSH AF JR COLOUR2 CALL SEXPT1NUM CP LINETOK JR Z,COLATL CALL CHKEND LD A,0FFH PUSH AF JR COLOUR15 ;NUL LINE ;FPCS=I,B,C. (SP)=LINE ;LINE ;NUL LINE ;LIMIT TO <128 ;GET SINGLE COLOUR ;STACK IT AS THE 'SECOND' COLOUR TOO ;FPCS=I, (SP)=COL, (SP+2)=LINE, A=COL ;SECOND COLOUR

COLOURFL:

COLATL:

CALL SSYNTAX6

EE43 EE43 EE46 EE47 EE47 EE4A EE4D EE4D EE4E EE51 EE51 EE52 EE55 EE58 EE58 EE59 EE5A EE5B EE5C EE5D EE5D EE5D EE5D EE5F EE61 EE61 EE64 EE66 EE67 EE68 EE6A EE6B EE6C EE6D EE6D EE6E EE6F EE6F EE72 EE73 EE73 EE74 EE75 EE76 EE78 EE78 EE79 EE7A EE7B EE7D EE7D EE7F EE7F EE80 EE81 EE83 EE83 EE83 EE84 EE86 EE86 EE86 EE86 EE87 EE88 EE89 EE8A EE8D EE8E EE8F EE90 EE91 EE92 EE94 EE96 EE96 EE97 EE98 EE9A EE9B EE9C EE9D EE9E EEA1 EEA2 EEA3 EEA4 EEA6 EEA7 EEA8 EEA9 EEAA EEAB EEAC EEAC EEAD EEAE EEAF EEB0 EEB1 EEB2 EEB2 EEB2

CDC5EE F5 111880 CD621F F5 CD621F F5 111710 CD621F 5F C1 F1 4F F1 FEFF 200E 21D855 1600 19 70 1E14 19 71 C9 CF 19 210056 57 7E 23 BA 3005 23 23 23 18F6 2007 7E BB 20F5 F3 1826 2B C5 D5 E5 CDB2EE 03 03 03 03 78 C6FE 38D7 D1 E5 ED52 44 4D 03 D1 210400 19 EB F3 EDB8 23 D1 C1 72 23 73 23 70 23 71 FB C9

COLATL2: COLOUR15:

CALL COLATSR PUSH AF LD DE,8000H+24 CALL LIMBYTE PUSH AF CALL LIMBYTE

;LINE ;LIMIT TO <128 ;GET SECOND COLOUR TO A ;SECOND COLOUR ;FIRST COLOUR ;FIRST COLOUR ;LIMIT TO <16 ;PALETTE ENTRY (I) ;E=I ;B=FIRST COLOUR ;C=SECOND ;LINE

COLOUR2:

PUSH AF LD DE,1000H+23 CALL LIMBYTE LD E,A POP BC POP AF LD C,A POP AF

;A=LINE (FF IF NONE), B=FIRST COLOUR, C=SECOND, E=PALETTE ENTRY JPALET: CP 0FFH JR NZ,COLRLINE LD HL,PALTAB LD D,0 ADD HL,DE LD (HL),B LD E,20 ADD HL,DE LD (HL),C RET COLFULERR: COLRLINE: COLRLP: RST 08H DB 25 LD HL,LINICOLS LD D,A LD A,(HL) INC HL CP D JR NC,COLRL2 INC HL INC HL INC HL JR COLRLP JR NZ,COLRL3 LD A,(HL) CP E JR NZ,COLRLP2 DI JR LD2COL COLRL3: DEC HL PUSH BC PUSH DE PUSH HL CALL FLITE INC BC INC BC INC BC INC BC LD A,B ADD A,0FEH JR C,COLFULERR POP DE PUSH HL SBC HL,DE LD B,H LD C,L INC BC POP DE LD HL,4 ADD HL,DE EX DE,HL DI LDDR INC HL POP DE POP BC LD (HL),D INC HL LD (HL),E LD2COL: INC HL LD (HL),B INC HL LD (HL),C EI RET ;JR IF LINE HAS NO ENTRIES ALREADY ;CP I ;JR IF LINE DOES NOT CHANGE THIS I ;ELSE OVERWRITE ENTRY ;(IN CASE INTERRUPT COLOUR SWOP OCCURS) ;PT TO PALETTE TABLE ;FIRST COLOUR ;POINT TO ALTERNATE PALETTE TABLE ;SECOND COLOUR (OFTEN THE SAME) ;'Too many palette changes' ;D=LINE

;JR IF WE FOUND END (FF) OR LINE>=L

COLRLP2:

COLRL2:

;WE NEED TO OPEN 4 BYTES AT (HL-1) - MIGHT BE TERMINATOR POSN ;COLOURS ;LINE, I ;LINE OR TERMINATOR POSN ;GET HL=TABLE END, BC=LEN

;ERROR IF LIST WITH NEW ENTRY WOULD BE ;MORE THAN 01FFH LONG ;LOCN FOR NEW ENTRY ;GET TERMINATOR-LOCN ;ALLOW FOR INCLUSIVE BYTE=LEN TO MOVE ;TERMINATOR ;DE=TERMINATOR+4, HL=TERMINATOR ;PT TO 4 BYTE SPACE ;LINE ;I

EEB2 EEB2 EEB2 EEB5 EEB5 EEB5 EEB5 EEB8 EEB8 EEB9 EEBA EEBB EEBB EEBC EEBD EEBE EEBF EEC0 EEC1 EEC2 EEC3 EEC5 EEC5 EEC5 EEC5 EEC6 EEC7 EEC8 EEC8 EECB EECE EECF EED2 EED3 EED5 EED6 EED6 EED7 EED8 EED8 EED8 EED8 EED8 EED8 EED8 EED8 EED8 EED8 EEDB EEDB EEDC EEDD EEDE EEDF EEE0 EEE1 EEE2 EEE3 EEE4 EEE5 EEE6 EEE7 EEE8 EEE9 EEEA EEEA EEEB EEED EEEF EEEF EEF0 EEF1 EEF1 EEF4 EEF5 EEF6 EEF8 EEFA EEFA EEFC EEFE EEFE EEFF EF00 EF00 EF01 EF02 EF03 EF04 EF06 EF09 EF0A EF0B EF0C EF0D EF0E EF0E EF0F EF0F EF12 EF13 EF16 EF17

;FIND LINE INT TABLE END. EXIT WITH BC=TABLE LEN, HL=END. 210056 010100 7E 3C C8 23 23 23 23 03 03 03 03 18F3 EF 25 33 CDFB27 CDB027 F5 CD121D F1 D601 D0 CF 1E COLATSR: FLITE: FLITD: FLITL: LD HL,LINICOLS LD BC,1 LD A,(HL) INC A RET Z INC HL INC HL INC HL INC HL INC BC INC BC INC BC INC BC JR FLITL ;GET LINE FROM TOP OF FPCS AS 0-191 FROM BASIC'S 175 TO -16 DB CALC DB DUP DB EXIT CALL COORDFID CALL USYCOORD PUSH AF CALL FDELETE POP AF SUB 1 RET NC RST 08H DB 30 ;L,L SO COORDFID CAN BE USED ;GETS Y AS 0 TO 191 (175 TO -16) ;LINE ;JUNK DUMMY X ;A=LINE ;RET UNLESS A WAS ZERO ;IOOR ;COLOUR CHANGE AT LINE ;0-190 FOR ORIG 174 TO ;EG 1 GIVES INT AT END ;CHANGE AT END OF SCAN 175 NOT POS. -16 OF SCAN 0, COLOUR 1. ;FIND LINE INT TABLE DISP. EXIT WITH BC=DISP TO TERMINATOR FROM ENTRY HL,+1.

INCLUDE MISC32.SAM ;MISC32.SAM CD5F3A EF 26 1B 01 26 0C 05 32 26 37 00 25 1C 31 33 7E FE85 3802 CF 32 01FBFF 09 7E FE84 3804 FE8F 3802 CF 31 EF 00 06 27 9337 1B0000 06 05 26 0F 03 33 CD2E1D C5 CD2E1D EB E1 INVNOTE: BEEP3: BEEP2: BEEP: CALL SYNTAX8 DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB CALC ONELIT 27 ADDN ONELIT 12 DIVN POWR2 ONELIT 55 MULT DUP SWOP13 RESTACK EXIT

;RECORD, FATPIX, CSIZE, WINDOW, ;BEEP

;LENGTH,NOTE ;L,N,27 ;L,N+27 ;L,(N+27)/12 ;L,2^(N+27)/12 ;L,FREQUENCY ;L,F,F ;F,F,L ;F,F,L (FP FORM) ;L EXPONENT ;** ;ALLOW DURATION UP TO 16 SECS ;'note too long' ;F EXPONENT

LD A,(HL) CP 85H JR C,BEEP2 RST 08H DB 50 LD BC,-5 ADD HL,BC LD A,(HL) CP 84H JR C,INVNOTE CP 8FH JR C,BEEP3 RST 08H DB 49 DB DB DB DB DB DB DB DB DB DB DB CALC MULT SWOP FIVELIT 93H,37H 1BH,0,0 SWOP DIVN ONELIT 15 SUBN

;ALLOW FREQUENCIES OF 8Hz TO 16KHz. ;'Invalid note' ;F,F,L ;F,F*L=CYCLES ;CY,F ;CY,F,375000=8T UNITS IN A 1HZ HALF-CYCLE ;CY,375000,F ;F,375000/F=8T UNITS PER HALF-CYCLE ;ALLOW FOR TIME TAKEN BY LOOP EVEN IF NIL 8T UNITS ;(15*8=120 TS)

DB EXIT CALL GETINT PUSH BC CALL GETINT EX DE,HL POP HL

;DE=CYCLES (ALSO, BC=DE=BA) ;HL=8 T UNITS

EF18 EF19 EF1A EF1A EF1B EF1B EF1B EF1B EF1B EF1B EF1C EF1D EF20 EF22 EF24 EF24 EF25 EF26 EF26 EF27 EF29 EF2C EF2C EF2E EF30 EF30 EF31 EF32 EF32 EF32 EF32 EF33 EF34 EF34 EF35 EF37 EF37 EF39 EF3A EF3D EF3D EF3F EF41 EF42 EF43 EF45 EF47 EF47 EF48 EF49 EF4B EF4B EF4C EF4C EF4D EF4E EF50 EF50 EF51 EF53 EF53 EF54 EF55 EF56 EF56 EF56 EF59 EF59 EF5B EF5B EF5C EF5F EF61 EF63 EF66 EF67 EF68 EF6A EF6A EF6B EF6C EF6C EF6C EF6F EF6F EF71 EF74 EF76 EF76 EF79 EF79 EF7B EF7E EF7E EF80 EF80 EF82 EF83 EF83 EF85 EF86 EF86 EF87

B0 C8 1B

OR B RET Z DEC DE

;RET IF NONE TO DO ;DE=0 GIVES 1 CYCLE

;ENTRY: DE=CYCLES TO DO, MINUS 1 ; HL=8T UNITS PER HALF-CYCLE (ON ENTRY, H=2048 Ts, L=8 Ts) ;TAKES 118 TS EVEN IF HL=0, CONTENTION OF 'OUT' MAKES THAT 120 TS F3 C5 0130EF CB3D 3802 03 03 C5 DDE1 3A4B5C F618 180D 40 40 0C 04 05 20FD 067F 0D C234EF EE10 D3FE 47 4C CB67 2009 7A B3 2808 1B 78 45 DDE9 78 18F9 C1 FB C9 CD153B 0606 C5 010200 1E01 3E1E CD80EF F3 C1 10F1 FB C9 CD153B 1E01 010C00 1808 CD153B 1E06 01FDFF 3E4E 2EFF F5 2600 54 D9 C1 SAD: ZPC: PAF: ZOOM: BOOM: ZPL: BEEPR3: BEEPR4: BEEPR5: BPLENT: BPTMLP: BEEPLP: BEEPER2: BEEPP2: DI PUSH BC LD BC,BEEPLP SRL L JR C,BEEPER2 INC BC INC BC PUSH BC POP IX LD A,(BORDCOL) OR 18H JR BPLENT LD B,B LD B,B INC C INC B DEC B JR NZ,BPTMLP LD B,127 DEC C JP NZ,BPTMLP XOR 10H OUT (0FEH),A LD B,A LD C,H BIT 4,A JR NZ,BEEPR4 LD A,D OR E JR Z,BEEPR5 DEC DE LD A,B LD B,L JP (IX) LD A,B JR BEEPR3 POP BC EI RET CALL CHKEND LD B,6 PUSH BC LD BC,2 LD E,1 LD A,30 CALL PAF DI POP BC DJNZ ZPL EI RET CALL CHKEND LD E,1 LD BC,12 JR ZPC CALL CHKEND LD E,6 LD BC,65533 LD A,78 LD L,255 PUSH AF LD H,0 LD D,H EXX POP BC ;DELAY 4TS SO BOTH PATHS TAKE THE SAME TIME ;IX IS LOOPING ADDR ;BITS=STI01GRB ;(SOFF/THRO MIDI/INTENSITY/0/MIC/GRB) ;SPKR BIT HI (ON), MIC BIT HI (OFF) ;JUMP INTO LOOP - PULSE SPEAKER OFF

;L=16T UNITS NOW ;USE A LOOP 8 TS LONGER IF L WAS ODD

;ENTER HERE (IX) IF SHORTER LOOP ;INC IN CASE B OR C=0 ;EACH INNER LOOP=16 TS ;OUTER LOOP TAKES 32 TS. 127 GIVES 126*16+32=2048 ;REVERSE BIT 4 ;PULSE SPEAKER ;SAVE A FOR LATER ;JR IF JUST DONE FIRST HALF-CYCLE ;END IF DONE ALL CYCLES

ZAP:

EF88 EF88 EF89 EF8A EF8B EF8E EF8F EF90 EF91 EF92 EF93 EF95 EF95 EF96 EF97 EF98 EF98 EF9B EF9C EF9E EF9E EF9F EFA0 EFA2 EFA3 EFA4 EFA7 EFAA EFAB EFAC EFAE EFAE EFAF EFB0 EFB0 EFB3 EFB3 EFB6 EFB9 EFB9 EFBA EFBD EFBE EFBE EFBE EFBE EFC1 EFC1 EFC4 EFC5 EFC8 EFC9 EFCC EFCD EFD0 EFD0 EFD3 EFD4 EFD5 EFD6 EFD6 EFD6 EFD6 EFD6 EFD6 EFD9 EFDB EFDC EFDD EFE0 EFE1 EFE4 EFE4 EFE5 EFE8 EFE9 EFEB EFED EFED EFEF EFF1 EFF1 EFF2 EFF3 EFF5 EFF5 EFF7 EFF7 EFF8 EFF9 EFFB EFFB EFFC EFFC EFFF F000 F001 F002 F003 F003 F003 F006 F006

D9 D5 E5 CD1BEF F3 E1 D1 09 D9 10F3 D9 FB C9 CD153B EB 0600 1A 6F 2600 13 D5 110100 CD1BEF F3 D1 10F0 FB C9 CD583A 111E02 CD621F 3D 32345A C9 CD5F3A CD331D F5 CD2E1D F1 21E7FE 09 DA391D 2AD85B 09 77 C9

SELP:

EXX PUSH DE PUSH HL CALL BEEPP2 DI POP HL POP DE ADD HL,BC EXX DJNZ SELP EXX EI RET

POW: PWLP:

CALL CHKEND EX DE,HL LD B,0 LD A,(DE) LD L,A LD H,0 INC DE PUSH DE LD DE,1 CALL BEEPP2 DI POP DE DJNZ PWLP EI RET

BGRAPHICS: CALL SYNTAX6 LD DE,0200H+30 CALL LIMBYTE DEC A LD (BGFLG),A RET ;KEY POSN,VALUE KEY: CALL SYNTAX8 CALL GETBYTE PUSH AF CALL GETINT POP AF LD HL,-281 ADD HL,BC JP C,IOORERR LD HL,(KBTAB) ADD HL,BC LD (HL),A RET ;SELECT SAVE/LOAD DEVICE E.G. DEVICE M: DEVICE T: DEVICE N: DEVICE M2 ;DEVICE T45 SETS SPEED=45 ;LIMIT TO <2 OR IOOR ;0 IF USE BLOCKS, FF IF USE UDGS ;(BGRAPHICS 1=USE BLOCKS, 0=USE UDGS)

;LIMIT POSN TO 0-280 (0 NOT USED)

CDEC3A E6DF F5 E7 CDF73A D1 CD153B D5 CD331D F1 FE4E 280F FE54 2006 0C 0D 2007 0E70 0C 0D 2001 0C 21065A 77 23 71 C9 CD503A CD2E1D

SLDEVICE:

CALL GETALPH AND 0DFH PUSH AF RST 20H CALL FETCHNUM POP DE CALL CHKEND PUSH DE CALL GETBYTE POP AF CP "N" JR Z,DEVI3 CP "T" JR NZ,DEVI2 INC C DEC C JR NZ,DEVI3 LD C,TSPEED

;FORCE UPPER CASE ;NUMBER OR USE 0 ;LETTER ;IN C ;LETTER ;IF NET, USE NUMBER OR DEFAULT TO 0

;DEFAULT TAPE SPEED

DEVI2:

INC C DEC C JR NZ,DEVI3 INC C ;DEFAULT TO 1 IF DISC ;LETTER ;DRIVE/STATION/SPEED LD HL,PSLD LD (HL),A INC HL LD (HL),C RET CALL SYNTAX3 CALL GETINT

DEVI3:

PAUSE:

F009 F00B F00E F00E F011 F012 F015 F018 F01A F01C F01C F01D F01E F020 F020 F021 F022 F023 F024 F024 F026 F028 F028 F02A F02B F02B F02B F02C F02E F031 F031 F032 F035 F035 F036 F038 F038 F039 F03B F03B F03C F03E F03E F040 F041 F043 F045 F045 F046 F047 F04A F04B F04C F04D F04E F050 F050 F052 F053 F055 F057 F057 F059 F05A F05B F05C F05F F060 F061 F064 F066 F067 F067 F06A F06B F06B F06E F071 F071 F073 F076 F078 F079 F07B F07B F07D F07F F07F F080 F083 F084 F087 F089 F089 F08B F08C F08D F08F F091 F091 F093 F094 F095

1E07 CD6628 CDBD1C 76 CD5D0E 3AD15A E608 20F2 78 B1 2804 0B 78 B1 C8 CB6E 28E6 CBAE C9 42 D610 CAC6F0 3D CACAF0 3D 286A 3D 2836 3D 2012 0E04 7A FE02 3072 3D 2F 32545A 7A 07 07 47 181B 0E01 7A FE04 3060 1E04 C5 4F F5 CD6628 F1 C1 32555A FE02 D0 32535A 78 21505A C32AF1 0E40 3A405A FE02 7A 2824 FE02 3020 A7 3A515A 5F 3A525A 2808 F688 F5 7B F688 1806 E677 F5 7B E677 COBRI1: COINOVC: COBRIGHT: COOVER: COINVERSE: PRCOITEM2: PAU2: PAU1:

LD E,7 CALL GRAREC CALL KBFLUSH HALT CALL BRKCR LD A,(LASTSTAT) AND 8 JR NZ,PAU1 LD A,B OR C JR Z,PAU2 DEC BC LD A,B OR C RET Z BIT 5,(HL) JR Z,PAU1 RES 5,(HL) RET LD B,D SUB 16 JP Z,COINK DEC A JP Z,COPAPER DEC A JR Z,COFLASH DEC A JR Z,COBRIGHT DEC A JR NZ,COOVER LD LD CP JR C,4 A,D 2 NC,INVCOLERR

;BLITZ CODE FOR 'PAUSE' ;USE PAUSE MOD 256 AS PARAM (C) ;(HL=FLAGS) ;CHECK BREAK, STOP IF SO ;STATPORT VALUE ON LAST INTERRUPT ;JR IF IT WASN'T A FRAME INTERRUPT ;DON'T DEC BC IF PARAM WAS ZERO

;RET IF COUNTED TO ZERO ;LOOP IF NO KEY PRESSED ;'NO KEY' ;B ALSO IS PARAM

;MASK FOR BIT 2 - INVERSE ;ALLOW INVERSE 0 OR 1 ONLY ;0/1 ->00/FF

DEC A CPL LD (INVERT),A LD A,D RLCA RLCA LD B,A JR COINOVC LD LD CP JR C,1 A,D 4 NC,INVCOLERR

;PARAM BIT TO BIT 2 ;MASK FOR BIT 0 - OVER ;CHECK ORIG PARAM FOR 0/1 ;OVER 0/1/2/3 ALLOWED ;BLITZ CODE FOR 'OVER'

LD E,4 PUSH BC LD C,A PUSH AF CALL GRAREC POP AF POP BC LD (GOVERT),A CP 2 RET NC LD (OVERT),A LD A,B LD HL,PFLAGT JP COCHNG LD LD CP LD JR C,40H A,(MODE) 2 A,D Z,COBRI2

;GRAPHICS OVER IS 0-3 ;NO FURTHER ACTION IF OVER 2 OR 3

;ADD MODIFIED PARAM TO PFLAG ;MASK FOR BIT 6 - BRIGHT ;PARAM ;JR IF BRIGHT 8

CP 2 JR NC,COBRI2 AND A LD A,(M23PAPT) LD E,A LD A,(M23INKT) JR Z,COBRI1 OR 88H PUSH AF LD A,E OR 88H JR COBRI15 AND 77H PUSH AF LD A,E AND 77H

;JR IF BRIGHT 0 ;ADD 8 TO INK ;AND PAPER, IF <8

F097 F097 F09A F09B F09E F09F F09F F0A0 F0A2 F0A2 F0A4 F0A5 F0A5 F0A6 F0A7 F0A8 F0AA F0AC F0AC F0AD F0AF F0AF F0B1 F0B3 F0B3 F0B5 F0B7 F0B7 F0B8 F0B9 F0B9 F0BC F0BD F0C0 F0C1 F0C2 F0C3 F0C4 F0C6 F0C6 F0C8 F0CA F0CA F0CC F0CD F0CE F0CF F0D0 F0D1 F0D1 F0D4 F0D5 F0D7 F0D9 F0D9 F0DA F0DB F0DC F0DD F0DE F0DF F0E0 F0E2 F0E2 F0E4 F0E4 F0E7 F0E9 F0EA F0EC F0EC F0ED F0EE F0EF F0F1 F0F2 F0F2 F0F3 F0F3 F0F5 F0F7 F0F7 F0FA F0FC F0FD F0FE F101 F102 F104 F104 F107 F109 F109 F10B F10D F10D F10E F110 F110 F111 F112 F114 F116

32515A F1 32525A 7A 0F 1803 0E80 7A 0F 47 7A FE10 2003 0F CB08 FE08 2806 FE02 3802 CF 17 214E5A 78 CD2AF1 78 0F 0F 0F 1864 0E07 1807 0E38 7A 07 07 07 47 214E5A 7A FE10 3030 07 07 07 07 B2 5F 07 3002 CBF6 3A405A FE02 7B 2007 07 07 AB E6CC AB 07 CB41 280D 32525A 1E05 C5 4F CD6628 C1 1814 32515A 180F FE12 30AA 7E 2807 B1 2F E624 2802

COBRI15:

LD (M23PAPT),A POP AF LD (M23INKT),A LD A,D RRCA JR COBRFLC LD C,80H LD A,D RRCA LD B,A LD A,D CP 16 JR NZ,COBFC2 RRCA RRC B ;PARAM 0/1 ENDS IN BIT 6... ;MASK FOR BIT 7 - FLASH ;PARAM ;PARAM 0/1 TO BIT 7 (OR 6 IF FLASH) ;MODIFIED PARAM ;ALLOW ORIG PARAM OF 0/1, OR 8/16=TRANSP ;A=8 ;ADJ B TOO

COBRI2: COFLASH: COBRFLC:

COBFC2:

CP 8 JR Z,COFBOK CP 2 JR C,COFBOK

INVCOLERR: COFBOK:

RST 08H DB 23 LD HL,ATTRT LD A,B CALL COCHNG LD A,B RRCA RRCA RRCA JR COCHNG LD C,7 JR CINKPAPC LD C,38H LD A,D RLCA RLCA RLCA LD B,A LD LD CP JR HL,ATTRT A,D 16 NC,CINKPAP0 ;ADD FLASH 0/1 TO ATTRT ;FLASH/BRIGHT 8 MOVED TO CORRECT BIT FOR ;ADDING TO MASKT ;MASK FOR INK ;MASK FOR PAPER

COINK: COPAPER:

;GET PARAM BITS IN PLACE FOR PAPER ;PARAM

CINKPAPC:

RLCA RLCA RLCA RLCA OR D LD E,A RLCA JR NC,CONFBRI SET 6,(HL) CONFBRI: LD CP LD JR A,(MODE) 2 A,E NZ,COIPM3

;A=2 COPIES OF PARAM BITS 3-0 ;MODE 3 INK/PAP ;JR IF NO NEED TO FORCE BRIGHT 1 (COL<8) ;SET BRIGHT BIT IN ATTRT FOR COLOURS 8-15

RLCA RLCA XOR E AND 0CCH XOR E RLCA COIPM3: BIT 0,C JR Z,COPAPM3 LD (M23INKT),A LD E,5 PUSH BC LD C,A CALL GRAREC POP BC JR CINKPAP2 COPAPM3: CINKPAP0: LD (M23PAPT),A JR CINKPAP2 CP 18 JR NC,INVCOLERR LD JR A,(HL) Z,CINKPAP1

;BITS 5,4 AND 1,0 TO 7,6 AND 4,3 ;KEEP BITS 7,6,4,3 OF A ;A=4 COPIES OF PARAM BITS 1,0 IF MODE 2 ;WHICH ONLY HAS 4 INKS ;CORRECT BIT SWOP ;TEST MASK BIT ;JR IF PAPER ;BLITZ CODE FOR 'PEN'

;ONLY ALLOW INK/PAPER 16 OR 17 HERE ;GET (ATTRT) ;JR IF INK/PAPER 16 - NO CHNG TO ATTRT, ;JUST MASKT ;MAKE INK OR PAPER WHITE ;THEN BLACK. FLIP OTHER BITS ;00 100 100 ;JR IF INK/PAPER WAS LIGHT

OR C CPL AND 24H JR Z,CINKPAP2

F116 F117 F117 F118 F118 F119 F11C F11E F121 F122 F123 F125 F126 F128 F128 F129 F12A F12A F12B F12C F12D F12E F12F F130 F131 F131 F131 F134 F134 F137 F13A F13A F13B F13C F13D F13E F13F F140 F142 F143 F145 F146 F149 F14A F14C F14D F14E F14E F14F F151 F152 F153 F155 F157 F159 F159 F15B F15D F15D F160 F161 F162 F163 F164 F165 F166 F167 F16A F16C F16E F16E F171 F172 F174 F174 F176 F176 F177 F177 F17A F17B F17B F17B F17B F17E F180 F180 F181 F182 F183 F184 F186 F187 F188 F189 F18A F18A F18A F18D F18F F18F F192 F195

79 47 78 CD2AF1 3E0F CD28F1 07 07 E650 4F 3E10 BA 9F AE A1 AE 77 79 23 C9 CD583A 111710 CD621F 4F 69 07 07 47 A9 E620 A9 F608 EB 214B5C AE E63F AE 77 EB D3FE 78 07 2600 CB6F 2004 26FF F607 32485C 7D 07 07 07 07 B5 6F 3A405A FE02 2009 CD80F1 3C 2802 3EFF 67 22305A C9 CD80F1 18F7 7D 07 07 AD E6CC AD 07 6F C9 CD7A3A 283B CDD43A CD153B BORD2: BORD3: BORD1: SETBORD: CINKPAP1: CINKPAP2:

LD

A,C

;USE WHITE INK OR PAPER TO CONTRAST

LD B,A LD A,B CALL COCHNG LD A,15 CALL COCHNGP RLCA RLCA AND 50H LD C,A LD A,16 CP D SBC A,A XOR (HL) AND C XOR (HL) LD (HL),A LD A,C INC HL RET CALL SYNTAX6 LD DE,1000H+23 CALL LIMBYTE LD C,A LD L,C RLCA RLCA LD B,A XOR C AND 20H XOR C OR 08H EX DE,HL LD HL,BORDCOL XOR (HL) AND 3FH XOR (HL) LD (HL),A EX DE,HL OUT (KEYPORT),A LD A,B RLCA LD H,0 BIT 5,A JR NZ,BORD1 LD H,0FFH OR 07H LD (BORDCR),A LD A,L RLCA RLCA RLCA RLCA OR L LD L,A LD A,(MODE) CP 2 JR NZ,BORD3 CALL M3TO2 INC A JR Z,BORD2 LD A,0FFH LD H,A LD (M23LSC),HL RET CALL M3TO2 JR BORD3 LD A,L RLCA RLCA XOR L AND 0CCH XOR L RLCA LD L,A RET CALL CRCOLON JR Z,ALLWIND CALL EXPT4NUMS CALL CHKEND ;L,R,T,B ;CONVERT L ;LIMIT TO <16 OR INVALID COLOUR ;A=BORDER ;CHANGE ATTRT ;SO GET CARRY FOR INK/PAPER 16/17 ;CHANGE MASKT

;SO GET CARRY FOR INK/PAPER 17 ;THEN ALTER PFLAGT

COCHNGP: COCHNG:

BORDER:

;USE BIT 5 FROM A ;MIC OFF ;USE BITS 7 AND 6 (SOFF/THRO) FROM SYS VAR ;USED BY SAVE/LOAD TO RESTORE BORDER, AND BEEP ;BIT 7=SOFF STATUS ;0XXX X000 ;BLACK INK ;IS BORDER COLOUR LIGHT? ;JR IF SO - INK IS BLACK ;COLOUR 15/3 (WHITE) FOR LS INK (MODE 3/2) ;AND BORDER COLOUR

;DOUBLE PAPER NIBBLE

;USE INK 0 IF PAPER FF ;(USUALLY) WHITE INK OTHERWISE

;CONVERT LS PAPER TO NON-STRIPED MODE 2 COLOUR - CALLED BY MODE CVLSP: M3TO2:

;BITS 5,4 AND 1,0 TO 7,6 AND 4,3 ;KEEP BITS 7,6,4,3 OF A ;A=4 COPIES OF PARAM BITS 1,0 IF MODE 2 ;CORRECT BIT SWOP

WINDOW:

F195 F198 F19B F19C F19E F19E F19F F1A0 F1A3 F1A4 F1A5 F1A7 F1A7 F1A9 F1A9 F1AA F1AB F1AE F1B1 F1B2 F1B4 F1B4 F1B5 F1B8 F1B9 F1BA F1BC F1BC F1BD F1C0 F1C1 F1C4 F1C5 F1C6 F1C9 F1CA F1CA F1CD F1CD F1D0 F1D1 F1D2 F1D3 F1D4 F1D5 F1D7 F1D7 F1D8 F1D9 F1D9 F1D9 F1D9 F1DC F1DC F1DF F1E0 F1E3 F1E4 F1E6 F1E7 F1E7 F1EA F1EA F1EB F1EC F1EC F1EC F1EF F1EF F1F2 F1F3 F1F4 F1F6 F1F6 F1F9 F1F9 F1FC F1FD F1FD F1FD F1FD F1FD F1FD F1FD F1FD F1FD F1FD F1FF F201 F201 F201 F201 F202 F204 F207 F207 F208 F208 F20B F20B F20C F20C F20D

CD331D 3A5A5A 91 3839 41 C5 CD331D C1 B8 2802 302E 4F C5 CD331D 3A5B5A B9 3823 C5 CD331D E1 BD 301B 67 22385A E1 223A5A 65 6F 226C5A C9 CD153B 2A5A5A AF 55 5F D5 6C 18E5 CF 36 CD5F3A CD331D F5 CD2E1D F1 ED79 C9 CD153B CF 10 CD503A CD2E1D 7C B5 2003 2A785C 22765C C9 RANDOM1: STOP: WDERR: SETWIND: WND2:

CALL GETBYTE LD A,(WINDMAX) SUB C JR C,WDERR LD B,C PUSH BC CALL GETBYTE POP BC CP B JR Z,WND2 JR NC,WDERR LD C,A PUSH BC CALL GETBYTE LD A,(WINDMAX+1) CP C JR C,WDERR PUSH BC CALL GETBYTE POP HL CP L JR NC,WDERR LD H,A LD (UWRHS),HL POP HL LD (UWTOP),HL LD H,L LD L,A LD (SPOSNU),HL RET CALL CHKEND LD HL,(WINDMAX) XOR A LD D,L LD E,A PUSH DE LD L,H JR SETWIND RST 08H DB 54 CALL SYNTAX8 CALL GETBYTE PUSH AF CALL GETINT POP AF OUT (C),A RET CALL CHKEND RST 08H DB 16 RANDOMIZE: CALL SYNTAX3 CALL GETINT LD A,H OR L JR NZ,RANDOM1 LD HL,(FRAMES) LD (SEED),HL RET

;B ;LOWEST BOTTOM ;ERROR IF WINDOW BOTTOM WILL BE TO LOW ;T ;B=BOT ;OK IF WINDOW TOP=WINDOW BOTTOM (1 LINE HIGH) ;ERROR IF WINDOW TOP WILL BE BELOW BOTTOM ;BOT/TOP ;R ;MAX RHS MARGIN ;ERROR IF TOO FAR RIGHT ;LHS ;L=RHS ;ERROR IF WINDOW IS ONE CHAR OR LESS WIDE ;HL=LHS/RHS ;HL=BOT/TOP ;LHS ;TOP/LHS

ALLWIND:

;L=BOT, H=RHS ;DE=BOT/TOP ;L=RHS ;'Invalid WINDOW'

OUT:

;'STOP statement' ;NUMBER OR ZERO

;RANDOMIZE OR RANDOMIZE 0 USES FRAMES

;ON ERROR, FINDER, MNINIT, PALETTE, BLOCKS, ;KEY, DEVICE, PAUSE, COITEM2 INCLUDE SCRFN.SAM ;COPY, SCREEN$, LIST, SPACES, EDPTR2 ;SCRFN.SAM - TEXT/GRAPHICS COPY, SCREEN$ FUNCTION, ATTR FN, POINT, BORDER, ;LOOK SAM, WINDOW, ZAP ETC. ;MAIN COPY ROUTINE: FEFF 2007 E7 FE70 C2290D E7 CD153B 3E AF GRCOPY: JGCOPY: JTCOPY: COPY: ;TEXT COPY RST 20H CP CHRSTOK JP NZ,NONSENSE RST 20H CALL CHKEND DB 3EH XOR A ;'LD A,0AFH' ** ;SKIP 0FFH CP 0FFH JR NZ,GRCOPY

F20D F210 F210 F211 F212 F213 F213 F214 F214 F214 F214 F217 F218 F218 F21B F21C F21D F220 F222 F223 F226 F229 F22C F22C F22D F230 F230 F230 F230 F230 F230 F233 F234 F236 F237 F238 F23B F23B F23C F23D F23E F23F F242 F243 F246 F248 F24A F24A F24B F24C F24F F24F F250 F252 F252 F255 F255 F258 F25A F25A F25B F25C F25D F25E F25F F261 F261 F263 F263 F264 F265 F266 F267 F268 F26A F26A F26C F26C F26C F26C F26D F270 F273 F274 F276 F276 F277 F277 F27A F27B F27C F27F F280 F282 F282 F282 F282 F285 F286 F288 F28B F28D F28D

2ADA5A 24 25 C8 E9 CDAE3A D0 3A385A 3C 6F 3A3B5A C603 67 CDA4CF CD30F2 D2673C AF C3DA1C JPOPT:

LD HL,(DMPV) INC H DEC H RET Z JP (HL) ;SCREEN$(L,C) IMSCREENS: CALL EXB2NUMB RET NC LD A,(UWRHS) INC A LD L,A LD A,(UWBOT) ADD A,3 LD H,A CALL GETCP CALL IMSCSR JP NC,CWKSTK XOR A JP STACKA ;CHECK (X,Y). CY IF RUNNING ;A=0 FOR TEXT COPY, 0AF FOR GRAPHICS

;L=RHS LIMIT FOR COL, PLUS 1 ;ALLOWS FOR LW OF 2 LINES ;H=BOT LIMIT FOR LINE, PLUS 1 ;GET POSN IN DE ;IF FOUND, STACK 1 BYTE STRING, COPY TO WORKSP ;ELSE STACK NULL STRING

;CALLED BY TEXT COPY AND SCREEN$ FN ;ENTRY: DE=LINE/COL ;EXIT: CY IF FOUND, (HL)=CHAR, BC=1, ELSE NC, A=0 21735A 7E 3600 F5 E5 CDB73D E1 C1 70 EB 118851 F5 3A405A FE02 3822 F1 F5 CD4727 F1 3030 017E08 218851 2809 7E 07 A1 77 23 10F9 181F 7E 0F A1 77 23 10F9 1816 F1 010008 CDBB3F 17 3001 0D CDBB3F A9 12 CDF70C 13 10F5 2A365C 24 3E60 CDA6F2 300F 2A7B5C SCM01L: SCM01: SC6EAL: SC6OAL: IMSCSR: LD HL,DEVICE LD A,(HL) LD (HL),0 PUSH AF PUSH HL CALL ANYDEADDR POP HL POP BC LD (HL),B EX DE,HL LD DE,SCRNBUF PUSH AF LD A,(MODE) CP 2 JR C,SCM01 POP AF PUSH AF CALL CHARCOMP POP AF JR NC,SCBMCH LD BC,087EH LD HL,SCRNBUF JR Z,SC6EAL LD A,(HL) RLCA AND C LD (HL),A INC HL DJNZ SC6OAL JR SCBMCH LD A,(HL) RRCA AND C LD (HL),A INC HL DJNZ SC6EAL JR SCBMCH ;MODES 0 AND 1 DO NOT NEED COMPRESSION OF SCRN CHAR DATA - BUT TRANSFER IT POP AF LD BC,0800H CALL SREAD RLA JR NC,SCM01L DEC C CALL SREAD XOR C LD (DE),A CALL NXTDOWN INC DE DJNZ SCM01L LD HL,(CHARS) INC H LD A,96 CALL SCREENSR JR NC,SCRNFND LD HL,(UDG) ;JUNK FLAGS FOR 6-PIX ;BYTES TO DO/NO INVERSE ;ENSURE DEVICE=UPPER SCREEN, OR ANYDEADDR FAILS ;GET DE=SCREEN ADDR, CY IF 6-PIX CHARS IN USE, ;(IN WHICH CASE NZ/Z=ODD/EVEN COL)

;BUFFER WILL HOLD TARGET CHAR IN A STANDARD FORM

;CY IF 6-PIX, NZ/Z=ODD/EVEN COL ;COMPRESS SCREEN AREA TO BUFFER USING TOP LHS ;PIXEL OF CHAR AS BACKGROUND ;JR IF NOT 6-PIX - BUFFER OK ;8 BYTES TO ROTATE BY 1 PIX LEFT OR RIGHT FOR ;CENTRAL POSITION, C=MASK TO TRIM LHS AND RHS BITS ;JR IF EVEN COLUMN ;MASK OFF BITS 7 AND 0, WHICH MAY BE JUNK

;MASK=FF FOR INVERTING CHAR IF TOP LH PIX=FORGROUND

;DROP HL TO NEXT SCAN ;NEXT BUFF POSN

;SCREEN$ BUFFER MATCH - MATCH BUFFER WITH CHAR PATTERNS SCBMCH: ;CHARS TO CHECK (32-127) ;PTS TO CHR$ 144

F290 F293 F294 F296 F299 F29A F29A F29C F29C F29E F2A1 F2A4 F2A5 F2A6 F2A6 F2A6 F2A6 F2A6 F2A6 F2A6 F2A7 F2A8 F2AB F2AC F2AD F2AE F2AF F2B0 F2B1 F2B2 F2B5 F2B6 F2B6 F2B7 F2B8 F2BA F2BA F2BC F2BC F2BD F2BE F2BE F2BF F2C0 F2C1 F2C2 F2C3 F2C5 F2C5 F2C6 F2C7 F2C8 F2C9 F2CA F2CD F2CF F2CF F2D0 F2D1 F2D3 F2D3 F2D4 F2D5 F2D6 F2D9 F2DB F2DB F2DC F2DD F2DF F2DF F2E0 F2E1 F2E2 F2E3 F2E4 F2E4 F2E4 F2E4 F2E7 F2E7 F2EA F2EB F2EB F2EC F2EF F2F0 F2F3 F2F4 F2F7 F2F8 F2F9 F2FA F2FD F2FE F300 F301 F303 F303 F306 F308 F309 F309

0180FF 09 3E29 CDA6F2 D8 C660 C620 010100 21C85A 77 C9 UDGFND: SCRNFND:

LD BC,-128 ADD HL,BC LD A,41 CALL SCREENSR RET C ADD A,96 ADD A,32 LD BC,1 LD HL,TEMPW1 LD (HL),A RET

;PT TO CHR$ 128 ;128-168 ;RET IF NOT FOUND ;1-41 -> 97-137 ;1-96 -> 32-127, 97-137 -> 128-168 ;LEN=1 ;NC='FOUND'

;SR TO CHECK B CHARS IN CHAR. GENERATOR AT (HL) VS. CHAR IN SCRNBUF ;ENTRY: A=NO. OF CHARS, HL PTS TO CHARSET ;EXIT WITH NC IF MATCHED, A=CHAR MATCH POSN, 0 TO B-1, OR CY SET=FAIL 47 08 118C51 1A 4F 1B 1A 23 23 23 110800 FE 19 BE 2804 10FA 37 C9 79 23 BE 2B 7E 20F5 E5 C5 2B 2B 2B 118851 0608 1A BE 2808 C1 E1 7E 110800 18DF 23 13 10F0 C1 E1 08 90 C9 CD9006 CD14F3 D8 D7 CD5602 47 CDEF3F 23 CD5602 4F 2B EB 2A7F5A A7 ED42 EB 30E4 3A3C5C E610 C8 3A595A LSTR1: LSTLNL: FULCK1: FULCKLP: SCREEN2: SCREENSR: LD B,A EX AF,AF' LD DE,SCRNBUF+4 LD A,(DE) LD C,A DEC DE LD A,(DE) INC HL INC HL INC HL LD DE,8 DB 0FEH ADD HL,DE CP (HL) JR Z,SCREEN2 DJNZ SCREENLP SCF RET LD A,C INC HL CP (HL) DEC HL LD A,(HL) JR NZ,SCREEN1 PUSH HL PUSH BC DEC HL DEC HL DEC HL LD DE,SCRNBUF LD B,8 LD A,(DE) CP (HL) JR Z,FULCK1 POP BC POP HL LD A,(HL) LD DE,8 JR SCREEN1 INC HL INC DE DJNZ FULCKLP POP BC POP HL EX AF,AF' SUB B RET ;PT 2 OF LIST CALL SPACAN CALL OUTLINE RET C RST 10H CALL R1OFRD LD B,A CALL CHKHL INC HL CALL R1OFRD LD C,A DEC HL EX DE,HL LD HL,(LAST) AND A SBC HL,BC EX DE,HL JR NC,LSTLNL LD A,(TVFLAG) AND 10H RET Z LD A,(WINDBOT) ;RET IF HIT END OF PROG ;PRINT 0DH ;** ;BC=NUMBER OF NEXT LINE ;LAST LINE ;LOOP UNTIL PAST LAST LINE ASKED FOR ('LAST LINE'= ;EPPC IF AUTO-LIST) ;RET IF NOT AN AUTO-LIST, ELSE FILL REST OF SCREEN ;LOOP TILL ALL 8 MATCHED OK ;CHARS TO CHECK ;FIRST CHAR MATCH GIVES 0, LAST GIVES ORIG B-1 ;WITH NC ='MATCHED'. ;'FAILED' ;BYTE 4 OF TARGET CHARACTER ;VS. BYTE 4 IN CHAR. GEN. CHARACTER ;A'=CHARS TO CHECK (KEPT TILL END) ;C=BYTE 4 OF TARGET CHAR ;A=BYTE 3 OF TARGET CHAR ;PT HL TO BYTE 3 OF CHAR GEN. CHARACTER ;FOR STEPPING TO NEXT CHAR ;'JR+1' ;CHECK BYTE 3 FOR MATCH ;JR TO CHECK BYTE 4 IF NEEDED

SCREENLP: SCREEN1:

;PT TO BYTE 0 IN CHAR. GEN CHARACTER ; AND BYTE 0 OF TARGET CHAR IN BUFFER ;DOING A FULL CHECK IS NOW WORTHWHILE ;JR IF FULL MATCH STILL OK

F30C F30D F310 F311 F313 F313 F314 F314 F314 F314 F317 F318 F31A F31B F31B F31C F31F F320 F323 F326 F326 F326 F327 F328 F32B F32D F32E F32F F331 F331 F332 F332 F335 F338 F33B F33C F33E F33E F341 F342 F345 F346 F348 F349 F34B F34C F34D F34D F34E F34F F350 F351 F353 F353 F356 F356 F356 F356 F357 F35A F35C F35D F35F F35F F361 F362 F362 F363 F366 F369 F36A F36D F36E F371 F372 F373 F374 F377 F377 F37A F37B F37D F380 F383 F384 F387 F389 F38C F38D F38F F390 F390 F391 F391 F393 F395 F395 F396 F399 F39A F39B F39D F39D

5F 3A6D5A 93 38D4 C9 CD5602 47 C601 D8 23 CD5602 4F 3ABE5A 32BC5A AF EB 2A495C ED42 EB F5 3001 3C 32865B CDB4F5 3A735A A7 200F 3A585A 5F 3A6D5A 93 C652 5F 165B 7A 12 23 23 23 F1 200C CD64F5 EB 213B5C CBC6 EB 1803 3E20 D7 AF 32C05A 3AB85A A7 CD5602 E5 C411F4 E1 EB AF 32BA5A 2AA35A A7 ED52 CC6EF5 CD39F5 EB CD0102 A100 228B5B 23 FE0D C8 EB FE3A 2041 67 3AB85A A7 7C 2841 3ABA5A OUTLN25: OUTLN22: OUTLN2: OUTLINE:

LD E,A LD A,(SPOSNU+1) SUB E JR C,LSTLNL RET

;PRINT POSN ROW

;EXIT: CY=HIT END OF PROG, ELSE NC AND 0D JUST PRINTED. CALL R1OFRD LD B,A ADD A,1 RET C INC HL CALL R1OFRD LD C,A LD A,(NXTSPCS) LD (OLDSPCS),A XOR A EX DE,HL LD HL,(EPPC) SBC HL,BC EX DE,HL PUSH AF JR NC,OUTLN2 INC A LD (BCREG),A CALL PRNUMB2 LD A,(DEVICE) AND A JR NZ,OUTLN22 LD A,(WINDTOP) LD E,A LD A,(SPOSNU+1) SUB E ADD A,>LPT LD E,A LD D,LPT/256 LD A,D LD (DE),A INC HL INC HL INC HL POP AF JR NZ,OUTLN3 CALL PRLCU ;USED BY EDPRNT EX DE,HL LD HL,FLAGS SET 0,(HL) EX DE,HL JR OUTLN4 LD A," " RST 10H XOR A LD (NXTHSPCS),A LD A,(LISTFLG) AND A CALL R1OFRD PUSH HL CALL NZ,SPACES POP HL EX DE,HL XOR A LD (INQUFG),A LD HL,(XPTR) AND A SBC HL,DE CALL Z,PRFLQUERY CALL OPCURSOR EX DE,HL CALL R1OFFCL DW RDCN LD (LSPTR),HL INC HL CP 0DH RET Z EX DE,HL CP ":" JR NZ,OUTCH2 LD H,A LD A,(LISTFLG) AND A LD A,H JR Z,OUTCH3 LD A,(INQUFG) ;'NO LEADING SPACE NOW' ;1=CURRENT LINE HAS BEEN PRINTED ;O/P NUMBER BC WITH LEADING SPACES ;JR IF NOT UPPER SCREEN ;LINE ;GET LINE REL. TO WINDOW ;LN MSB ;RET IF FF END-OF-PROG STOPPER ;BC=CURRENT LN NO. ;IN CASE LINE IS LAST ON SCREEN AND NEEDS ;TO BE PRINTED TWICE - ALLOWS SPACES TO BE ;RESET BEFORE 2ND TIME ** ;'BEFORE CURRENT LINE' ;NC IF CUR LN=EPPC OR IS LESS THAN EPPC ;NC,Z IF '>' TO BE PRINTED ;JR IF 'BEFORE CURRENT LINE'

;ENTRY IN LPT SHOWS LINE HAS A LINE NUMBER ;PT TO FIRST CHAR IN LINE ;PRINT '>'

OUTLN3: OUTLN4:

;PRINT SPACE (ALSO SETS 'NO LEADING SPACE')

;FIRST CHAR IN LINE ;LINE PTR ;INDENT IF FLAG SAYS 'PRETTY LISTING' ;SAVE LINE PTR IN DE ;'NOT IN QUOTES'

OUTLNLP:

;PRINT A FLASHING '?' IF SYNTAX ERROR PTR ;=LD A,(HL): CALL NUMBER, WITH ROM1 OFF ;LINE SCAN PTR - USED BY CUOP O/P ROUTINE

;DE=LINE PTR

;JR IF NO PRETTY LISTING

F3A0 F3A1 F3A2 F3A4 F3A4 F3A7 F3A9 F3AA F3AC F3AC F3AC F3AC F3AC F3AF F3B0 F3B1 F3B4 F3B7 F3B8 F3BA F3BC F3BC F3BE F3BF F3C0 F3C1 F3C2 F3C2 F3C3 F3C5 F3C8 F3C9 F3CC F3CC F3CD F3D0 F3D1 F3D4 F3D6 F3D6 F3D8 F3DA F3DA F3DD F3DE F3DE F3DF F3E1 F3E1 F3E1 F3E1 F3E1 F3E1 F3E2 F3E4 F3E5 F3E6 F3E7 F3E8 F3E9 F3EA F3EA F3EA F3EA F3EB F3ED F3ED F3F0 F3F1 F3F2 F3F4 F3F5 F3F7 F3F8 F3F8 F3F9 F3F9 F3FA F3FB F3FD F3FD F3FE F3FE F401 F402 F404 F405 F408 F409 F40A F40B F40C F40C F40D F40E F410 F410 F411 F411 F414 F415 F416 F417

0F 7C 383A 3A715C E620 7C 2032

RRCA LD A,H JR C,OUTCH3 LD A,(FLAGX) AND 20H LD A,H JR NZ,OUTCH3

;BIT 0=1 IF INSIDE ;':' ;JR IF ':' IS INSIDE QUOTES

;JR IF INPUT MODE

;DO TAB 0 IF USING LOWER SCREEN (TO OVER-WRITE JUNK WITH SPACES) OR DO CR FOR ;SPEED IF NOT; FOLLOW EITHER WITH 6 SPACES TO INDENT TEXT 3ABD5A F5 AF 32BD5A 3A735A 3D 3E0D 2006 3E17 D7 AF D7 AF D7 0606 CD76DE F1 32BD5A EB CD5602 EB CD11F4 18A1 FE22 2004 21BA5A 34 D7 1896 OUTCH3: OUTCH2: TABS2: LD A,(INDOPFG) PUSH AF XOR A LD (INDOPFG),A LD A,(DEVICE) DEC A LD A,0DH JR NZ,TABS2 LD A,17H RST 10H XOR A RST 10H XOR A RST 10H LD B,6 CALL OPBSP POP AF LD (INDOPFG),A EX DE,HL CALL R1OFRD EX DE,HL CALL SPACES JR OUTLNLP CP 22H JR NZ,OUTCH3 LD HL,INQUFG INC (HL) RST 10H JR OUTLNLP ;FLIP BIT 0 (INSIDE/OUTSIDE QUOTES FLAG) ;A=(DE) (CHAR TO O/P NEXT) ;SET SPACES, O/P CURRENT SPACES

;NO INDENTED O/P SO TAB FILLING LINE AVOIDS INDENT ;JR IF NOT LOWER SCREEN ;TAB

;SCROLL TABLE ENTRIES ;ENTRY: A=LINES TO SCROLL BY, D=1 IF UP, NOT 1 IF DOWN 6F 3E1E 95 4F AF 47 67 7D 15 2811 116F5B D5 EB ED52 D1 EDB8 47 AF 12 1B 10FC C9 11525B 19 EDB0 47 218D5B 7E 90 77 AF 12 13 10FC C9 21BE5A E5 46 23 70 SPACES: PTU: PDCL: STENTS: LD L,A LD A,30 SUB L LD C,A XOR A LD B,A LD H,A LD A,L DEC D JR Z,PTU LD DE,LPT+29 PUSH DE EX DE,HL SBC HL,DE POP DE LDDR LD B,A XOR A LD (DE),A DEC DE DJNZ PDCL RET LD DE,LPT ADD HL,DE LDIR LD B,A LD HL,LNPTR LD A,(HL) SUB B LD (HL),A XOR A LD (DE),A INC DE DJNZ PTCL RET LD HL,NXTSPCS PUSH HL LD B,(HL) INC HL LD (HL),B ;POINT TO 'NEXT-SPACES' VAR. ;CURRENT SPACES=NEXT SPACES ;NEW ENTRIES IN TABLE ARE ZEROS

;HL=LINES TO SCROLL BY, BC=30-LINES TO SCROLL BY, A=LINES TO SCROLL BY, NC ;JR IF SCROLL UP ;HL=LPT+29, DE=LINES ;HL=LPT+29-LINES ;LPT+29 ;(NEW LINE FOR CURSOR SET BY PRINTING OF LINE)

;NEW LINE FOR CURSOR

PTCL:

F418 F419 F41A F41B F41C F41D F41D F41F F421 F421 F423 F425 F425 F427 F429 F429 F42B F42D F42D F42F F431 F431 F433 F435 F435 F437 F439 F439 F439 F43B F43D F43D F440 F441 F442 F443 F445 F445 F447 F449 F449 F44B F44D F44D F44F F451 F451 F452 F453 F455 F457 F457 F45A F45C F45C F45E F460 F460 F462 F464 F464 F467 F468 F469 F46A F46A F46A F46A F46C F46D F46D F46E F471 F472 F473 F474 F475 F476 F476 F477 F47A F47B F47C F47E F47F F47F F481 F482 F484 F484 F485 F485 F488 F488 F489 F48C F48D F48E F48F F490 F491 F491 F493

23 46 23 70 E1 FED4 2843 FED7 283F FECA 283B FEC0 2837 FED5 280C FECB 2808 FEDB 2804 FEC1 2008 CD88F4 46 2B 70 1828 FED6 280E FED9 280A FED3 2806 23 23 FEDA 2005 CD88F4 1811 FED8 2804 FEDE 2009 3AB85A 86 77 FE 3E06 FE AF 21BF5A 86 23 23 86 C8 47 2A565A 7D 94 FE0A D8 D605 B8 3001 47 C376DE 23 3AB85A 47 7E 90 77 D0 3600 C9 SPCS5: SPACESR: INCSPCS: SPACES3: SPACES35: DECSPCS:

INC HL LD B,(HL) INC HL LD (HL),B POP HL CP 0D4H JR Z,INCSPCS CP 0D7H JR Z,INCSPCS CP 0CAH JR Z,INCSPCS CP 0C0H JR Z,INCSPCS CP 0D5H JR Z,DECSPCS CP 0CBH JR Z,DECSPCS CP 0DBH JR Z,DECSPCS CP 0C1H JR NZ,SPACES2 CALL SPACESR LD B,(HL) DEC HL LD (HL),B JR SPACES4 CP 0D6H JR Z,SPACES3 CP 0D9H JR Z,SPACES3 CP 0D3H JR Z,SPACES3 INC HL INC HL CP 0DAH JR NZ,SPACES35 CALL SPACESR JR SPACES4 CP 0D8H JR Z,INCSPCS CP 0DEH JR NZ,SPACES4 LD A,(LISTFLG) ADD A,(HL) LD (HL),A DB 0FEH LD A,6 DB 0FEH XOR A LD HL,CURSPCS ADD A,(HL) INC HL INC HL ADD A,(HL) RET Z LD B,A LD HL,(WINDRHS) LD A,L SUB H CP 10 RET C SUB 5 CP B JR NC,SPCS5 LD B,A JP OPBSP INC HL LD A,(LISTFLG) LD B,A LD A,(HL) SUB B LD (HL),A RET NC LD (HL),00H RET

;CURRENT THEN SPACES=NEXT THEN SPACES ;PTR TO NEXT-SPACES ;DOTOK ;LIFTOK ;DEFPROCTOK ;FORTOK ;THESE CMDS NEED NEXT SP=NEXT SP+INDENT ;(INDENT FROM NEXT STATEMENT ONWARDS) ;LOOPTOK ;ENDPROCTOK ;ENDIFTOK ;THESE CMDS (AND NEXT) NEED TO CANCEL INDENT FOR ;CURRENT AND LATER STATEMENTS. ;NEXTTOK ;CURRENT=CURRENT-INDENT ;NEXT SPACES=CURRENT ;EXITIFTOK ;LELSETOK ;LOOPIFTOK ;LOOP IF, LELSE AND EXIT IF CANCEL INDENT FOR ;CURRENT STAT ONLY. ;PT TO SPACES THAT WILL CANCEL AT LINE END (SIF) ;ELSETOK ;SHORT ELSE CANCELS SOME OF THEM, AS DOES 'ON'

SPACES2:

;SIFTOK ;SHORT IF INDENTS FOR LATER STATEMENTS, THIS LINE ;ONTOK. AS DOES 'ON'

;"JR+3" (CP 3EH: LD B,FEH)

;CALLED FROM MAIN PRINT ROUTINE WHEN LINE FULL INDOPEN: SPACES4: ;'JR+1'

;SUB RHS,LHS=WIDTH-1 ;NO INDENT IF 10 COLS OR LESS ;FULL INDENT IF ROOM ;ELSE INDENT BY WIDTH-6

F494 F494 F494 F494 F497 F49A F49B F49B F49E F4A1 F4A4 F4A6 F4A8 F4AB F4AC F4AF F4B0 F4B4 F4B7 F4BA F4BB F4BC F4BF F4C2 F4C4 F4C6 F4C6 F4C7 F4C9 F4CB F4CB F4CE F4D1 F4D2 F4D2 F4D5 F4D5 F4D6 F4D9 F4D9 F4DC F4DF F4E0 F4E3 F4E4 F4E5 F4E5 F4E6 F4E9 F4EA F4EB F4ED F4EF F4EF F4F0 F4F2 F4F5 F4F7 F4F7 F4F7 F4F7 F4FA F4FD F4FE F4FE F4FF F500 F500 F501 F504 F508 F509 F50C F50F F510 F513 F514 F514 F517 F518 F51B F51C F51D F51E F51F F51F F51F F51F F51F F523 F526 F527 F529 F52B F52B F52E F531 F532 F535 F536 F536 F539 F539

CD8E11 CD893D D5 3A585A 32CF5A 213C5C CBAE CB9E 2A3D5C E5 21F7F4 E5 ED733D5C CDC204 2A825C E5 EB 0156F3 3A715C E620 200C 7E FE0D 280A CD9006 CDC508 BF C41600 EB CD39F5 CD8E11 CD893D E1 CD14F5 D5 E5 C1 CD893D EB A7 ED42 300F C5 3E20 CD7905 18EE CD8804 CD893D 21 D1 E1 E1 223D5C ED53825C E1 CD14F5 CD62DC AF 32A45A C9 3ACF5A 47 3A585A 90 84 67 C9

EDPTR2:

CALL TEMPS CALL POFETCH PUSH DE LD A,(WINDTOP) LD (TEMPB2),A LD HL,TVFLAG RES 5,(HL) RES 3,(HL) LD HL,(ERRSP) PUSH HL LD HL,EDPE PUSH HL LD (ERRSP),SP CALL SETDE LD HL,(OLDPOS) PUSH HL EX DE,HL LD BC,OUTLN25 LD A,(FLAGX) AND 20H JR NZ,EDIM LD A,(HL) CP 0DH JR Z,EDCOP CALL SPACAN CALL IOPCL CP A

;SAVE SCRN POSN SO THAT SEVERAL EDPRTS CAN ALL ;START AT THE SAME POSN, NOT CONCATENATED! ;'NO NEED TO CLEAR LS ON KEYSTROKE' ;'NO NEED TO COPY LINE TO LOWER SCRN' ;NEW ERROR HANDLER ;DE=START OF ELINE OR INPUT LINE ;POSN OF END OF LINE IN LOWER SCREEN ;HL=LINE START ;JR IF INPUT MODE - NO INDENT ;JR IF LINE EMPTY ** BUG FIX ;PRINT THE LINE, INDENTED ;Z ;DE=LINE PTR ;PRINT THE CURSOR IF IT IS AT THE END OF THE LINE ;(OR IT HAS BEEN PRINTED ALREADY) ;USE VALUE AS NEW 'OLDPOS' ;OLDPOS ;ADJUST IF LS SCROLLED ;NEW OLDPOS ;OLDPOS ;NEW POSN OF END OF LINE IN LOWER SCREEN ;NORMALLY NEW POSN IS FURTHER RIGHT, OR DOWN, AS ;TEXT IS ADDED, SO NC. BUT IF DELETE USED, CY ;NORMAL OUTPUT ;LOOP TILL LINE BLANKED TO OLD END-OF-LINE.

EDIM: EDCOP:

CALL NZ,BCJUMP EX DE,HL CALL OPCURSOR CALL TEMPS CALL POFETCH POP HL CALL LSASR PUSH DE PUSH HL

EDBL:

POP BC CALL POFETCH EX DE,HL AND A SBC HL,BC JR NC,EDBE PUSH BC LD A," " CALL FONOP JR EDBL

;EDPRNT ERRORS COME HERE EDPE: EDBE: CALL WARNBZ CALL POFETCH DB 21H POP DE POP HL POP HL LD (ERRSP),HL LD (OLDPOS),DE POP HL CALL LSASR CALL POSTORE XOR A LD (XPTR+1),A RET LSASR: LD A,(TEMPB2) LD B,A LD A,(WINDTOP) SUB B ADD A,H LD H,A RET ;FOR OLDPOS ;'JR+2' ;LAST END-OF-LINE POSN ;ERROR HANDLER ADDR

;ORIG SCRN POSN ;ORIG SCRN POSN, MODIFIED IF SCOLLED UP ;CANCEL ANY '?' ERROR MARKER

;A IS EG -1 IF LW HAS EXPANDED UP BY ONE ;EG ADJUST PRINT LINE UP BY ONE IF LS SCROLLED

;EDITOR'S SPECIAL CURSOR OUTPUT TO SET SCREEN POSN CUOPP: ED4B6E5A 2AC25A A7 ED42 200B 2A8B5B 229A5A F5 CD50F5 F1 C37905 CUOP2: LD BC,(SPOSNL) LD HL,(KPOS) AND A SBC HL,BC JR NZ,CUOP2 LD HL,(LSPTR) LD (KCUR),HL PUSH AF CALL OPCUR2 POP AF JP FONOP

;PREVENT LINE BEING BRIEFLY PRINTED 1 CHAR SHORTER ;AS OLD CURSOR VANISHES AND NEW CURS. POSN FOUND

F539 F539 F539 F53C F53D F53F F540 F540 F542 F543 F546 F547 F549 F54A F54A F54D F550 F550 F553 F556 F556 F559 F55C F55E F55F F561 F561 F562 F564 F564 F564 F564 F567 F56A F56D F56E F56E F570 F570 F570 F570 F570 F570 F571 F572 F575 F576 F577 F579 F57C F57D F580 F581 F584 F585 F587 F58A F58D F590 F591 F592 F595 F596 F597 F59A F59B F59E F59F F5A2 F5A3 F5A6 F5A7 F5A8 F5A8 F5A8 F5A8 F5A8 F5A9 F5AB F5AB F5AB F5AB F5AD F5AE F5AF F5B1 F5B1 F5B2 F5B3 F5B4 F5B4 F5B4 F5B4 F5B4 F5B6 F5B6 F5B7 F5B8 F5BB F5BB F5BC F5BD F5BE

;OP CURSOR IF DE=KCUR. 2A9A5A A7 ED52 C0 DBFB 67 3A995A AC E61F C0 2A6E5A 22C25A 2AFE5A CD10F2 2A015A 3A6A5C E608 7D 280F 7C 180C 3A6D5A 328D5B 3A005A FE 3E3F PRLCU: OPCUR2: OPCURSOR: LD HL,(KCUR) AND A SBC HL,DE RET NZ IN A,(251) LD H,A LD A,(KCURP) XOR H AND 1FH RET NZ LD HL,(SPOSNL) LD (KPOS),HL LD HL,(KURV) CALL JPOPT LD HL,(KURCHAR) LD A,(FLAGS2) AND 08H LD A,L JR Z,PRINVERT LD A,H JR PRINVERT ;PRINT LINE CURSOR - USED BY MAIN LIST ROUTINE AND FUPDN LD LD LD DB A,(SPOSNU+1) (LNPTR),A A,(LNCUR) 0FEH ;STORE LINE NO. WITH CURSOR ;"JR+2" (CP 3EH: CCF). PRINT INVERSE '>'

;RET IF THIS ISN'T CURSOR'S ADDR IN LINE

;** ;SAVE SCREEN POSN OF CURSOR

;JR IF CAPS LOCK OFF

PRFLQUERY: LD A,"?" ;PRINT CHAR IN 'A' REG IN INVERSE VIDEO ;USE CALL TO MNOP (VIA FONOP), NOT RST 10H, IN CASE INVERSE CHAR IS PRINTED ;BETWEEN CC AND ITS PARAMETER (AND CHANNEL ADDR HAS BEEN CHANGED).

47 E5 21505A 7E F5 CBD6 3A545A F5 3ABA5A F5 3A345A F5 3EFF 32BA5A 32545A 32345A 78 D5 CD7905 D1 F1 32345A F1 32BA5A F1 32545A F1 32505A E1 C9

PRINVERT:

LD B,A PUSH HL LD HL,PFLAGT LD A,(HL) PUSH AF SET 2,(HL) LD A,(INVERT) PUSH AF LD A,(INQUFG) PUSH AF LD A,(BGFLG) PUSH AF LD A,0FFH LD (INQUFG),A LD (INVERT),A LD (BGFLG),A LD A,B PUSH DE CALL FONOP POP DE POP AF LD (BGFLG),A POP AF LD (INQUFG),A POP AF LD (INVERT),A POP AF LD (PFLAGT),A POP HL RET

;INVERSE 1

;'IN QUOTES' SO CURSORS CAN BE UDGS

;PRINT INTEGER IN A, AS 1-3 CHARS. HL IS SAVED. USED FOR STAT AND ERROR NUMS. 4F 0600 1E00 78 3C 2005 4F 47 22 PRAREG: LD C,A LD B,0 LD E,0 LD A,B INC A JR NZ,PRNUMBC LD C,A LD B,A DB 22H ;NO LEADING SPACES

;USED FOR LINE NUMS IN REPORTS PRNUMB1:

;"JR+2". NUMBERS >=FF00 PRINT AS 0 (EG ELINE)

;PRINT INTEGER IN BC, PADDED TO 5 CHARS WITH LEADING SPACES. HL IS SAVED. ;USED FOR LINE NUMS IN LISTINGS. USES BC, DE, AF. 1E20 E5 C5 2146FE 4E 23 46 23 PRNUMB2: PRNUMBC: PRNUOLP: LD E,20H PUSH HL PUSH BC LD HL,SUBTAB LD C,(HL) INC HL LD B,(HL) INC HL ;LEADING SPACES ;NUMBER

F5BF F5C0 F5C1 F5C2 F5C3 F5C5 F5C5 F5C6 F5C6 F5C7 F5C8 F5CA F5CA F5CC F5CD F5CF F5CF F5D1 F5D1 F5D2 F5D5 F5D6 F5D7 F5D8 F5DA F5DA F5DB F5DC F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5DD F5FD F612 F619 F61A F638 F63F F646 F648 F64D F651 F651 F651 F651 F651 F653 F65C F662 F678 F687 F68C F691 F69A F6A6 F6A8 F6AC F6B5 F6BA F6BF F6D3 F6DE F6E1 F6E9 F6EC F6F3 F6F9 F6FF F704 F706 F709 F712 F71A F721 F728 F734 F745 F755 F75B F768 F770 F77B F788 F792 F7A3 F7AA F7B3 F7C3 F7C6 F7CC F7CF F7D2 F7DC

E3 7D 0C 0D 280A AF 3C 09 38FC ED42 3D 2802 1E30 83 C41000 E3 0C 0D 20E1 E1 E1 C9 PRNTNO1: PRNTNO2: PRNUILP:

EX (SP),HL LD A,L INC C DEC C JR Z,PRNTNO1 XOR A INC A ADD HL,BC JR C,PRNUILP SBC HL,BC DEC A JR Z,PRNTNO2 LD E,30H ADD A,E CALL NZ,0010H EX (SP),HL INC C DEC C JR NZ,PRNUOLP POP HL POP HL RET

;HL=NUMBER ;JR IF WE ARE AT 'UNITS' STAGE (C=TERMINATOR)

;SUCCESSIVE SUBTRACTIONS OF EG. 10, 100 ;A=DIGIT FOR 1000'S, 100'S ETC. ;LEAVE E ALONE IF IT'S A ZERO DIGIT ;AFTER A NON-ZERO DIGIT USE '0' FOR ZERO, RATHER ;THAN ' ' OR ''. ;CALL UNLESS LEADING SPACES SUPPRESSED. ;HL=TABLE PTR ;LOOP IF NOT AT 'UNITS' YET ;NUMBER ;ORIG ;OPCURSOR, PRLCU, PRINVERT, STENTS, PRAREG, ;PRNUMB

INCLUDE TEXT.SAM ;TABLES, MSGS, KEYWORDS, CMDADDRT, CHARSET ;TEXT.SAM - ERROR MESSAGES, KEYWORDS, MSGS, TABLES, CHARSET ETC ;REPORTS GENERATED BY E.G. RST 08H: DB 0 FOR OK ;UTILITY MESSAGES (START AT 0) ;UMVAL IS LOADED INTO UMSGS SYS VAR AT INIT. UMVAL: 2020204D49 2020202020 7363726F6C A0 53741F7420 4261736963 4E751E7269 138E 436F1D3AA0 530D3AA0 DB DB DB DC DB DB DB DB DB DB " MILES GORDON TECHNOLOGY plc " " ",127," 1990 SAM Cou","p"+80H ;0 "scroll","?"+80H ;1 " " ;2 NOT USED "St",CAR,"t tape and then press a ke","y"+80H ;3 "Basic:"," "+80H ;4 "Nu",CME,"ric",ARRAY+80H ;5 STRING,ARRAY+80H ;6 "Co",CDE,":"," "+80H ;7 "S",CREEN,":"," "+80H ;8

;ERRMVAL IS LOADED INTO ERRMSGS SYS VAR AT INIT. ERRMVAL: 4FCB 4F7574061E 11666F756E 4441544120 5375627363 0A01464FD2 464F52018A 464E014445 5245545552 029B 1B0144CF 0B504F5020 024445469A 0B454E449A 0C2D20434F 0C191C2070 167395 161920494E 001792 4C6F616419 001D766963 007308206E 456E640697 0098 000598 1405636861 501F611E74 001F67751E 4E09036C1F 4E6F742075 496E746567 531520646F 4F66662073 0B726F6F6D 00730D206D 00424C4954 531C726564 0050555420 505554206D 02454E4420 00761F6961 4241534943 130390 00730D206E 530D84 530884 4375727265 5308206973 DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB "O","K"+80H ;0 "Out",SOFS,CME,"mor","y"+80H ;1 SNOTS,"foun","d"+80H ;2 "DATA has all been rea","d"+80H ;3 "Subscript wron","g"+80H ;4 CNXT,WITHOUT,"FO","R"+80H ;5 "FOR",WITHOUT,CNXT+80H ;6 "FN",WITHOUT,"DEF F","N"+80H ;7 "RETURN",WITHOUT,"GOSU","B"+80H ;8 MISSING,CLOOP+80H ;9 CLOOP,WITHOUT,"D","O"+80H ;10 NO,"POP dat","a"+80H ;11 MISSING,"DEF",CPROC+80H ;12 NO,"END",CPROC+80H ;13 BREAK,"- CONTINUE ",CTO," repea","t"+80H ;14 BREAK,IN,CTO," progra","m"+80H ;15 CSTOP,"s",TATEMENT+80H ;16 CSTOP,IN," INPU","T"+80H ;17 INVALID,FILE,SNAME+80H ;18 "Load",IN,"g",ERROR+80H ;19 INVALID,CDE,"vic","e"+80H ;20 INVALID,"s",TREAM," n",UMBER+80H ;21 "End",SOFS,FILE+80H ;22 INVALID,CLOUR+80H ;23 INVALID,PALET,CLOUR+80H ;24 TOOMANY,PALET,"change","s"+80H ;25 "P",CAR,"a",CME,"ter",ERROR+80H ;26 INVALID,CAR,"gu",CME,"n","t"+80H ;27 "N",UMBER,TOO,"l",CAR,"g","e"+80H ;28 "Not un",CDE,"rs",CTO,"o","d"+80H ;29 "Integer out",SOFS,"rang","e"+80H ;30 "S",TATEMENT," doesn't exis","t"+80H ;31 "Off s",CREEN+80H ;32 NO,"room for l",IN,"e"+80H ;33 INVALID,"s",CREEN," mod","e"+80H ;34 INVALID,"BLITZ cod","e"+80H ;35 "S",CTO,"red ",CAR,"ea",TOO,"bi","g"+80H ;36 INVALID,"PUT bloc","k"+80H ;37 "PUT mask mismatc","h"+80H ;38 MISSING,"END I","F"+80H ;39 INVALID,"v",CAR,"iable",SNAME+80H ;40 "BASIC stack ful","l"+80H ;41 STRING,TOO,LONG+80H ;42 INVALID,"s",CREEN," n",UMBER+80H ;43 "S",CREEN,ISALREDOP+80H ;44 "S",TREAM,ISALREDOP+80H ;45 "Current s",CREEN+80H ;46 WAS INVALID CHANNEL "S",TREAM," is",SNOTS,"ope","n"+80H ;47

F7E6 F7F4 F7F6 F7F9 F7FD F807 F80D F814 F819 F819 F819 F819 F821 F821 F821 F821 F82A F82A F82A F82A F832 F832 F832 F832 F837 F837 F837 F837 F847 F847 F847 F847 F84F F84F F84F F84F F853 F853 F853 F853 F859 F859 F859 F859 F85E F85E F85E F85E F863 F863 F863 F863 F867 F867 F867 F867 F86A F86A F86A F86A F870 F870 F870 F870 F875 F875 F875 F875 F87D F87D F87D F87D F881 F881 F881 F881 F885 F885 F885 F885 F88A F88A F88A F88A F88F F88F F88F F88F F895 F895 F895 F895 F89E F89E F89E F89E F8A6 F8A6 F8A6 F8A6 F8AB F8AB F8AB

00434C4541 008F 0F0390 46504387 141D661969 4E6F20444F 0057494E44 02646973EB

DB DB DB DB DB DB DB DB

INVALID,"CLEAR addres","s"+80H INVALID,NOTE+80H NOTE,TOO,LONG+80H "FPC",ERROR+80H TOOMANY,CDE,"f",IN,"ition","s"+80H "No DO","S"+80H INVALID,"WINDO","W"+80H MISSING,"dis","k"+80H DB "Invalid"," "+80H EQU 0 DB " without"," "+80H

;48 ;49 ;50 ;51 ;52 ;53 ;54 ;55 ;14 uses ;5 uses ;5 uses ;3 uses ;2 uses ;2 uses ;3 uses ;4 uses ;3 uses ;3 uses ;2 uses ;3 uses ;2 uses ;6 USES ;2 USES ;2 USES ;2 USES ;2 USES ;2 USES ;2 USES ;2 USES ;2 USES ;2 USES

;SAVES OVER 200 BYTES. 496E76616C COMPLIST: 0000= 2077697468 0001= 4D69737369 0002= 20746F6FA0 0003= 2069732061 0004= 70616C6574 0005= 206F66A0 0006= 206572726F 0007= 74726561ED 0008= 756D6265F2 0009= 4E4558D4 000A= 4E6FA0 000B= 425245414B 000C= 63726565EE 000D= 2061727261 000E= 4E6F74E5 000F= 6C6F6EE7 0010= 206E6F74A0 0011= 206E616DE5 0012= 537472696E 0013= 546F6F206D 0014= 746174656D 0015= 53544F50A0 0016= CSTOP TATEMENT TOOMANY STRING SNAME SNOTS LONG NOTE ARRAY CREEN BREAK NO CNXT UMBER TREAM ERROR SOFS PALET ISALREDOP TOO MISSING WITHOUT INVALID

EQU 1 DB "Missing"," "+80H EQU 2 DB " too"," "+80H EQU 3 DB " is already ope","n"+80H EQU 4 DB "palette"," "+80H EQU 5 DB " of"," "+80H EQU 6 DB " erro","r"+80H EQU 7 DB "trea","m"+80H EQU 8 DB "umbe","r"+80H EQU 9 DB "NEX","T"+80H EQU 10 DB "No"," "+80H EQU 11 DB "BREAK"," "+80H EQU 12 DB "cree","n"+80H EQU 13 DB " array:"," "+80H EQU 14 DB "Not","e"+80H EQU 15 DB "lon","g"+80H EQU 16 DB " not"," "+80H EQU 17 DB " nam","e"+80H EQU 18 DB "Strin","g"+80H EQU 19 DB "Too many"," "+80H EQU 20 DB "tatemen","t"+80H EQU 21 DB "STOP"," "+80H EQU 22

F8AB F8AF F8AF F8AF F8AF F8B5 F8B5 F8B5 F8B5 F8B7 F8B7 F8B7 F8B7 F8BC F8BC F8BC F8BC F8C0 F8C0 F8C0 F8C0 F8C2 F8C2 F8C2 F8C2 F8C4 F8C4 F8C4 F8C4 F8C6 F8C6 F8C6 F8C6 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C8 F8C9 F8CB F8CE F8D3 F8D7 F8DD F8E1 F8E5 F8E7 F8EA F8F0 F8F6 F8FA F8FE F904 F905 F90A F90A F910 F917 F91B F91C F921 F928 F929 F92A F92A F92A F92A F92D F930 F933 F936 F939 F93C F93E F941 F944 F947 F94A F94D F950 F952 F956 F95B F95F F963

66696CE5 0017= 636F6C6F75 0018= 69EE 0019= 2050524FC3 001A= 4C4F4FD0 001B= 74EF 001C= 64E5 001D= 6DE5 001E= 61F2 001F= CAR CME CDE CTO CLOOP CPROC IN CLOUR FILE

DB "fil","e"+80H EQU 23 DB "colou","r"+80H EQU 24 DB "i","n"+80H EQU 25 DB " PRO","C"+80H EQU 26 DB "LOO","P"+80H EQU 27 DB "t","o"+80H EQU 28 DB "d","e"+80H EQU 29 DB "m","e"+80H EQU 30 DB "a","r"+80H EQU 31

;2 USES ;2 USES ;5 USES ;2 USES ;2 USES ;4 USES ;4 USES ;2 USES ;6 USES

;TOKENS.SAM - SAM TOKEN TABLE. ;FUNCTIONS RANGE 21-69H, PRECEDED BY FF ;ASCII RANGE 20-7F ;BLOCK GRAPHICS/EXTENDED CHARS 80-8F ;EXTENDED CHARS 90-A8 ;(80H-A8H ACT AS UDGS - PROGRAMMED AS BLOCK GRAPHICS, FOLLOWED BY EXTENDED CHARS ;ON POWER-UP. UDGS SYS VAR PTS TO USR "A". TAKES 328 BYTES OF RAM. OVERLAP WITH ;COMMAND TOKENS USES CONTEXT TO AVOID PROBLEMS - PRINT CHR$ 160 GIVES UDG, LIST ;COMMAND GIVES KEYWORD. QUOTES FORCES UDGS. ;ALLOW 80-95 IN PROC NAMES SO A FACE SYMBOL CAN BE A COMMAND? ;USE "." FOR EXTERNAL COMMAND ;QUALIFIERS 96-9F ;COMMANDS RANGE A0-FE ;FUNCTIONS HAVE 0FFH PREFIX ;"IMMEDIATE" FUNCTIONS A0 KEYWTAB: 50C9 IMFNTL: 524EC4 504F494ED4 465245C5 4C454E4754 495445CD 415454D2 46CE 4249CE 584D4F5553 594D4F5553 585045CE 595045CE 52414D544F AD 494E5354D2 494E4B4559 5343524545 4D454DA4 AD 50415448A4 535452494E AD AD ;FPC FUNCTIONS 5349CE FPCFNTL: 434FD3 5441CE 4153CE 4143D3 4154CE 4CCE 4558D0 4142D3 5347CE 5351D2 494ED4 5553D2 49CE 504545CB 44504545CB 445641D2 535641D2 425554544F DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC "SIN" "COS" "TAN" "ASN" "ACS" "ATN" "LN" "EXP" "ABS" "SGN" "SQR" "INT" "USR" "IN" "PEEK" "DPEEK" "DVAR" "SVAR" "BUTTON" ;53H ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; DB DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC 0A0H "PI" "RND" "POINT" "FREE" "LENGTH" "ITEM" "ATTR" "FN" "BIN" "XMOUSE" "YMOUSE" "XPEN" "YPEN" "RAMTOP" "-" "INSTR" "INKEY$" "SCREEN$" "MEM$" "-" "PATH$" "STRING$" "-" "-" ;3BH ; ; ; ; ; ; ; ; ; ; ; ; ; ; UNUSED INARRAY ;4AH ;4BH ; ; ; UNUSED CHAR$ ; ; ; UNUSED USING$ ;52H UNUSED SHIFT$

F969 F96C F96F F970 F973 F974 F977 F97B F97F F982 F988 F98C F990 F994 F998 F99C F99D F9A0 F9A1 F9A2 F9A3 F9A3 F9A3 F9A3 F9A6 F9A9 F9AC F9AD F9B1 F9B3 F9B6 F9B8 F9BA F9BC F9BC F9BC F9BC F9BC F9C1 F9C6 F9C8 F9CB F9CE F9D3 F9D8 F9DC F9E0 F9E2 F9E6 F9E6 F9E6 F9E6 F9E9 F9EF F9F4 F9F8 F9FC FA00 FA05 FA0B FA0F FA14 FA14 FA1A FA1E FA21 FA26 FA2C FA2F FA2F FA36 FA39 FA3E FA43 FA49 FA50 FA54 FA54 FA5A FA5F FA65 FA69 FA6D FA70 FA70 FA74 FA79 FA79 FA7C FA7F FA83 FA8B FA90 FA95 FA9B FAA1 FAA4 FAA4 FAA8 FAAC FAB3 FAB3 FAB8

454FC6 5054D2 AD 5544C7 AD 4C45CE 434F44C5 56414CA4 5641CC 5452554E43 434852A4 535452A4 42494EA4 484558A4 555352A4 AD 4E4FD4 AD AD AD 4D4FC4 4449D6 424FD2 AD 42414EC4 4FD2 414EC4 3CBE 3CBD 3EBD BINFNTL:

DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC ;BINARY OPERATORS DC DC DC DC DC DC DC DC DC DC

"EOF" "PTR" "-" "UDG" "-" "LEN" "CODE" "VAL$" "VAL" "TRUNC$" "CHR$" "STR$" "BIN$" "HEX$" "USR$" "-" "NOT" "-" "-" "-" "MOD" "DIV" "BOR" "-" "BAND" "OR" "AND" "<>" "<=" ">="

; ; DISC USE? ; RESERVED ; ; NUMBER ; ; ; ; ; ; ; ; ; ; ; CORRESPONDS TO INKEY$ FPC CODE ; ; ; ;79H ;7AH ; ; ;BXOR ; ; ; ; ; ;83H

;QUALIFIERS - RANGE 85H-8FH 5553494EC7 KWDS85: 57524954C5 41D4 5441C2 4F46C6 5748494CC5 554E5449CC 4C494EC5 544845CE 54CF 535445D0 ;COMMANDS. 4449D2 464F524D41 45524153C5 4D4F56C5 534156C5 4C4F41C4 4D455247C5 5645524946 4F5045CE 434C4F53C5 434952434C 504C4FD4 4C45D4 424C4954DA 424F524445 434CD3 50414C4554 KWDSA0: 5045CE 50415045D2 464C4153C8 4252494748 494E564552 4F5645D2 4641545049 4353495AC5 424C4F434B 4D4F44C5 475241C2 5055D4 424545D0 534F554EC4 4E45D7 5255CE 53544FD0 434F4E5449 434C4541D2 474F2054CF 474F205355 5245545552 5245CD 524541C4 444154C1 524553544F 5052494ED4 4C5052494E DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC "USING" "WRITE" "AT" "TAB" "OFF" "WHILE" "UNTIL" "LINE" "THEN" "TO" "STEP" "DIR" "FORMAT" "ERASE" "MOVE" "SAVE" "LOAD" "MERGE" "VERIFY" "OPEN" "CLOSE" "CIRCLE" "PLOT" "LET" "BLITZ" "BORDER" "CLS" "PALETTE" "PEN" "PAPER" "FLASH" "BRIGHT" "INVERSE" "OVER" "FATPIX" "CSIZE" "BLOCKS" "MODE" "GRAB" "PUT" ;85H ;86 ;87 ;88 ;89 ;8A ;8B ;8C ;8D ;8E ;8F ;90 ;91 ;92 ;93 ;94 ;95 ;96 ;97 ;98 ;99 ;9A ;9B ;9C ;9D ;9E ;9F ;A0 ;A1 ;A2 ;A3 ;A4 ;A5 ;A6 ;A7 ;A8 ;A9 ;AA ;AB ;AC ;AD ;AE ;AF ;B0 ;B1 ;B2 ;B3 ;B4 ;B5 ;B6 ;B7 ;B8 ;B9 ;BA ;BB ;BC 0=THIN, 1=FAT

RANGE 90H-FEH

DC "BEEP" DC "SOUND" DC DC DC DC DC DC DC DC DC "NEW" "RUN" "STOP" "CONTINUE" "CLEAR" "GO TO" "GO SUB" "RETURN" "REM"

DC "READ" DC "DATA" DC "RESTORE" DC "PRINT" DC "LPRINT"

FABE FAC2 FAC7 FACB FACB FACE FAD2 FAD7 FADB FAE2 FAE5 FAEA FAF3 FAF9 FB04 FB0C FB14 FB19 FB1F FB22 FB26 FB27 FB2C FB31 FB38 FB3A FB3E FB45 FB47 FB49 FB4D FB51 FB57 FB5A FB62 FB64 FB67 FB67 FB6A FB6E FB73 FB79 FB7D FB81 FB87 FB8D FB94 FB98 FB9D FBA1 FBA7 FBAB FBAE FBB4 FBBA FBC1 FBC5 FBC8 FBCB FBCF FBD3 FBD4 FBD5 FBD6 FBD7 FBD8 FBD9 FBDA FBDB FBDE FBDE FBDE FBDE FBDE FBDE FBE2 FBE7 FBEC FBF1 FBF5 FBF9 FBFE FC04 FC0C FC10 FC10 FC15 FC1B FC21 FC22 FC22 FC22 FC22 FC23 FC25 FC27 FC28 FC2A FC2B FC2D FC30 FC30 FC31

4C4953D4 4C4C4953D4 44554DD0 464FD2 KWDSC0: 4E4558D4 50415553C5 445241D7 4445464155 4449CD 494E5055D4 52414E444F 4445462046 444546204B 4445462050 454E442050 52454E55CD 44454C4554 5245C6 434F50D9 AD 4B455949CE 4C4F4341CC 4C4F4F5020 44CF 4C4F4FD0 4558495420 49C6 49C6 454C53C5 454C53C5 454E442049 4B45D9 4F4E204552 4FCE 4745D4 4F55D4 KWDSE0: 504F4BC5 44504F4BC5 52454E414D 43414CCC 524F4CCC 5343524F4C 5343524545 444953504C 424F4FD4 BTWD: 4C414245CC 46494CCC 57494E444F 415554CF 504FD0 5245434F52 4445564943 50524F5445 484944C5 5A41D0 504FD7 424F4FCD 5A4F4FCD AD AD AD AD AD AD AD AD 494ECB

DC "LIST" DC "LLIST" DC "DUMP" DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC DC "FOR" "NEXT" "PAUSE" "DRAW" "DEFAULT" "DIM" "INPUT" "RANDOMIZE" "DEF FN" "DEF KEYCODE" "DEF PROC" "END PROC" "RENUM" "DELETE" "REF" "COPY" "-" "KEYIN" "LOCAL" "LOOP IF" "DO" "LOOP" "EXIT IF" "IF" "IF" "ELSE" "ELSE" "END IF" "KEY" "ON ERROR" "ON" "GET" "OUT" "POKE" "DPOKE" "RENAME" "CALL" "ROLL" "SCROLL" "SCREEN" "DISPLAY" "BOOT" "LABEL" "FILL" "WINDOW" "AUTO" "POP" "RECORD" "DEVICE" "PROTECT" "HIDE" "ZAP" "POW" "BOOM" "ZOOM" "-" "-" "-" "-" "-" "-" "-" "-" "INK"

;BD ;BE ;BF ;C0 ;C1 ;C2 ;C3 ;C4 ;C5 ;C6 ;C7 ;C8 ;C9 ;CA ;CB ;CC ;CD ;CE ;CF ;D0 EDIT ;D1 ;D2 ;D3 ;D4 ;D5 ;D6 ;D7 ;D8 ;D9 ;DA ;DB ;DC ;DD ;DE ;DF ;E0 ;E1 ;E2 ;E3 ;E4 ;E5 ;E6 ;E7 ;E8 ;E9 USED BY BOOT TO CHECK FILE NAME ;EA ;EB ;EC ;ED ;EE ;EF ;F0 ;F1 ;F2 ;F3 ;F4 ;F5 ;F6 ;F7 ;F8 ;F9 ;FA ;FB ;FC ;FD ;FE ;FF (FUNCTION PREFIX) AND TEMP "INK" TOKEN

;DEF KEY INIT TABLE C00100BD DKSRC: C10200CC3A C20200BB3A C30200AA3A C40100B0 C50100B2 C602009F23 C703009522 C805009522 C90100E9 FC0200063A FD03001401 FE03001400 FF DKEN: 3E 8081 3130 23 5470 11 0056 FF0000 4F 0A CHIT: DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DW DB 192,1,0,0BDH 193,2,0,0CCH,":" 194,2,0,0BBH,":" 195,2,0,0AAH,":" 196,1,0,0B0H 197,1,0,0B2H 198,2,0,09FH,"#" 199,3,0,LOADTOK,22H,22H 200,5,0,LOADTOK,22H,22H,0FFH,CODETOK 201,1,0,0E9H 252,2,0,6,":" 253,3,0,20,1,":" 254,3,0,20,0,":" 0FFH ">" 128,129 "1","0" "#" "T",TSPEED 17 LINICOLS 0FFH,0,0 ;F0 ;F1 ;F2 ;F3 ;F4 ;F5 ;F6 ;F7 ;F8 ;F9 LIST RENUM : PRINT : MODE : RUN CONTINUE CLS # LOAD "" LOAD "" CODE BOOT

;TAB ;INVERSE 1 CC ;INVERSE 0 CC

;INIT TABLE - 18 BYTES ;CURRENT LINE CURSOR ;CURSOR CHARACTERS - LOWER CASE/UPPER CASE ;DIGIT CHARS FOR "BIN$" ;INSTR WILD CARD CHAR ;DEVICE T, TAPE SPEED ;COLOUR FLASH SPEED ;LINIPTR ;XCMDP SHOWS "NO EXTERNAL CMDS" ;PRINTER RHS ;AFTER CR CHARACTER

DB 79 DB 10

FC32 FC33 FC34 FC34 FC36 FC38 FC3A FC3C FC3E FC40 FC42 FC44 FC46 FC48 FC4A FC4A FC4A FC4C FC4E FC4F FC4F FC51 FC53 FC54 FC54 FC56 FC58 FC59 FC59 FC5B FC5D FC5E FC5E FC60 FC62 FC63 FC63 FC65 FC67 FC68 FC68 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC69 FC71 FC7A FC83 FC83 FC8C FC95 FC9E FCA7 FCAF FCAF FCAF FCAF FCB7 FCC0 FCC9 FCC9 FCD2 FCDB FCE4 FCED FCF5 FCF5 FCF5 FCF5 FCFD FD06 FD0F FD0F FD18 FD21 FD2A FD33 FD3B FD3B FD3B FD3B FD3B FD3D FD3F FD41 FD43 FD45 FD47 FD49 FD4B FD4D FD4F FD51

E9 01 FF4A 0040 0040 004D 0058 8058 77DC 51F6 DDF5 E058 65FD CC01 0205 4B CC01 0205 53 F202 123F 52 CC01 123F 50 AF01 123F 24 8101 123F 42 0D MAIT:

DB 0E9H DB 1 DW DW DW DW DW DW DW DW DW DW DW BSTACK HPEND HPEND FPSB DKBU DKBU+128 ENDOUTP ERRMVAL UMVAL KTAB CMDADT

;PRINTER CONTROL PORT (E8=DATA) ;PRINTER STROBE BYTE ;BASSTK ;HEAPEND ;HPST START WITH EMPTY HEAP ;FPSBOT ;DEF KEY BUFFER START ;LIMIT OF DEF KEY BUFFER GROWTH ;"PRINTABLE CHARS" O/P ROUTINE ;ERROR MESSAGES ;"UTILITY" MESSAGES ;KEYBOARD TABLE ;START OF CMD ADDR TABLE ;FIRST 4 BYTES IN CHANTAB ALSO USED!

CHANTAB:

DW PRMAIN DW KYIP DB "K" DW PRMAIN DW KYIP DB "S" DW ADDCHAR DW IDERR DB "R" DW PRMAIN DW IDERR DB "P" DW S16OP DW IDERR DB "$" DW SENDA DW IDERR DB "B" DB 0DH ;KEEPS READ CMD HAPPY ON FIRST LINE

;KEY MAP FOR 70 KEYS (3 NOT READ THIS WAY) IN UNSHIFTED, CAPS SHIFTED AND SYMB. ;SHIFTED STATES. EACH ROW CORRESPONDS TO A BIT ON THE PORT (BIT 7 AT TOP) AND ;EACH COLUMN TO A PORT MSB. CAPS SHIFT (BIT 0,PORT FE) SCANNED SEPARATELY, AS ;IS SYM SHIFT (BIT 1,PORT 7F) AND CONTROL (BIT 0,PORT FF) ;PORT MSB: ;BIT MAP BYTE FF 8 7F 7 BF 6 DF 5 EF 4 F7 3 FB 2 FD 1 FE 0

;254 DEFINED AS INVERSE CC,0 ;253 DEFINED AS INVERSE CC,1 ;252 DEFINED AS CHR$ 6 FD07C00C06 KSRC: 582E3A222B 582C3B3D2D 0962687936 086E6A7537 0A6D6B6938 0B586C6F39 58200D7030 5C07CA0E06 582E3A7F2A 582C3B5F2F 0942485926 084E4A5527 0A4D4B4928 0B584C4F29 58200D507E FE0F300E06 583E2ACF2A 583C2B5F2F 099E5E9D86 08A42D8187 0AA52BA580 0B5860947C 58200DBB7E DB 253,07H,0C0H,12,6H,0C9H,198,195 DB "X",".",":",""","+",252,200,197,194 DB "X",",",";","=","-"," ",199,196,193 DB DB DB DB DB ;CAPS SHIFTED DB "\",07H,202,0EH,06H,211,208,205 DB "X",".",":",127,"*",252,210,207,204 DB "X",",",";","_","/"," ",209,206,203 DB DB DB DB DB 09H,"B","H","Y","&","%","T","G","V" 08H,"N","J","U","'","$","R","F","C" 0AH,"M","K","I","(","#","E","D","X" 0BH,"X","L","O",")","@","W","S","Z" "X"," ",0DH,"P",126,"!","Q","A" 09H,"b","h","y","6","5","t","g","v" 08H,"n","j","u","7","4","r","f","c" 0AH,"m","k","i","8","3","e","d","x" 0BH,"X","l","o","9","2","w","s","z" "X"," ",0DH,"p","0","1","q","a" ;BIT 7 ; 6 ; 5 ; ; ; ; ; 4 3 2 1 0

;SYMBOL SHIFTED DB 254,0FH,"0",0EH,06H,"9","6","3" DB "X",">","*",0CFH,"*",252,"8","5","2" DB "X","<","+","_","/"," ","7","4","1" DB DB DB DB DB 09H,9EH,5EH,157,134,133,"]","}",VERIFYTOK 08H,164,"-",129,135,132,"[","{",168 0AH,165,"+",0A5H,128,131,130,9CH,"?" 0BH,"X",60H,148,124,130,">",SAVETOK,"?" "X"," ",0DH,187,126,129,"<",0B1H

;CONTROL KEY TABLE - DISP/VALUE 1303 8901 8A08 8801 8B07 1001 8F01 8C09 8D07 1102 8E00 CKTAB: DB DB DB DB DB DB DB DB DB DB DB 19,3 137,1 138,8 136,1 139,7 16,1 143,1 140,9 141,7 17,2 142,0 ;BRIGHT CC ;GRAPHICS ;PEN CC ;PAPER CC

FD51 FD51 FD51 FD51 FD51 FD52 FD53 FD54 FD55 FD56 FD57 FD58 FD59 FD59 FD5A FD5B FD5C FD5D FD5E FD5F FD60 FD61 FD61 FD61 FD61 FD62 FD63 FD64 FD65 FD65 FD65 FD65 FD67 FD69 FD6B FD6D FD6F FD71 FD73 FD75 FD77 FD79 FD7B FD7D FD7F FD81 FD83 FD85 FD85 FD87 FD89 FD8B FD8D FD8F FD91 FD93 FD95 FD97 FD99 FD9B FD9D FD9F FDA1 FDA3 FDA5 FDA5 FDA7 FDA9 FDAB FDAD FDAF FDB1 FDB3 FDB5 FDB7 FDB9 FDBB FDBD FDBF FDC1 FDC3 FDC5 FDC5 FDC7 FDC9 FDCB FDCD FDCF FDD1 FDD3 FDD5 FDD7 FDD9 FDDB FDDD FDDF FDE1 FDE3 FDE5 FDE5 FDE7 FDE9 FDEB

;INITIAL PALETTE COLOURS - MS GRB BITS, BRIGHT BIT, LS GRB BITS ; GRBbGRB 00 10 20 30 40 50 60 78 00 11 22 33 44 55 66 7F 00 11 22 7F 290D 290D 290D 290D 19E0 19E0 19E0 19E0 03D3 93D2 7120 AC22 AB38 B224 31F1 9B06 9FED 8913 8913 8913 8913 8913 8913 B5D7 EAD7 B0EF 9001 D028 5B29 D8EE 8AD8 8BEC F638 E7F1 A219 0139 61D6 5DD6 CD19 110E 9D12 2411 8F34 A607 A307 3A06 3706 FDF1 331B D11B 03F0 1C21 A838 DB2E 5B38 ECF1 9138 8D38 6C32 DE19 5F38 8538 290D 290D 290D 6738 3832 1C19 CMDADT: DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW INITCOLS: DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB 0000000B 0010000B 0100000B 0110000B 1000000B 1010000B 1100000B 1111000B 0000000B 0010001B 0100010B 0110011B 1000100B 1010101B 1100110B 1111111B 0000000B 0010001B 0100010B 1111111B ;BLACK ;BLUE ;RED ;MAGENTA ;GREEN ;CYAN ;YELLOW ;WHITE ;BRIGHT BLACK=BLACK ;BLUE ;RED ;MAGENTA ;GREEN ;CYAN ;YELLOW ;WHITE ;BLACK ;BLUE ;RED ;WHITE RANGE 90H-FEH ;DIR ;FORMAT ;ERASE ;MOVE ;SAVE ;LOAD ;MERGE ;VERIFY ;OPEN ;CLOSE ;CIRCLE ;PLOT ;LET ;BLITZ ;BORDER ;CLS ;PALETTE ;INK ;PAPER ;FLASH ;BRIGHT ;INVERSE ;OVER ;FATPIX ;CSIZE ;BLOCKS ;MODE ;GRAB ;PUT ;BEEP ;SOUND ;NEW ;RUN ;STOP ;CONTINUE ;CLEAR ;GO TO ;GO SUB ;RETURN ;REM ;READ ;DATA ;RESTORE ;PRINT ;LPRINT ;LIST ;LLIST ;DUMP 90 ** ALTERED 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF

;COLOURS FOR 4-COLOUR MODE

;COMMAND ADDRESS TABLE. NONSENSE NONSENSE NONSENSE NONSENSE SLMVC SLMVC SLMVC SLMVC OPSCRN CLSCRN CIRCLE PLOT LET BLITZ BORDER CLS COLOUR PERMS PERMS PERMS PERMS PERMS PERMS FATPIX WIDTH BGRAPHICS MODECMD GRAB PUT BEEP SOUND NEW RUN STOP CONTINUE CLEAR GOTO GOSUB RETURN REMARK READ DATA RESTORE PRINT LPRINT LIST LLIST COPY FOR NEXT PAUSE DRAW DEFAULT DIM INPUT RANDOMIZE DEFFN DEFKEY DEFPROC ENDPROC RENUM DELETE NONSENSE NONSENSE NONSENSE KEYIN LOCAL LOOPIF

PIXEL WIDTH BLOCK GRAPHICS/UDGS

;FOR ;NEXT ;PAUSE ;DRAW ;DEFAULT ;DIM ;INPUT ;RAND ;DEF FN ;DEF KEYCODE ;DEF PROC ;END PROC ;RENUM ;DELETE ;REF ;COPY ;EDIT ;KEYIN ;LOCAL ;LOOP IF D0 D1 D2 D3

FDED FDEF FDF1 FDF3 FDF5 FDF7 FDF9 FDFB FDFD FDFF FE01 FE03 FE05 FE05 FE07 FE09 FE0B FE0D FE0F FE11 FE13 FE15 FE17 FE19 FE1B FE1D FE1F FE21 FE23 FE25 FE25 FE27 FE29 FE2B FE2D FE2F FE31 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE33 FE35 FE37 FE39 FE3B FE3D FE3F FE41 FE43 FE44 FE44 FE46 FE46 FE46 FE46 FE48 FE4A FE4C FE4E FE4E FE4E FE4E FE4E FE4E FE4E FE4E FE4E FE53 FE58 FE5D FE62 FE67 FE6C FE71 FE76 FE7B FE80 FE85 FE8A FE8F FE94 FE99 FE9E FEA3 FEA8 FEAD FEB2 FEB7 FEBC FEC1 FEC6 FECB

E218 3219 2619 7F1A 7F1A E31A 191B 321B BEEF 731C 5219 8138 D9F1 0512 6212 290D 44EB 6109 6509 5BD2 9B3B CDD8 E338 DA24 8AF1 51D8 8938 1A2C D6EF 290D 290D 56EF 98EF 6CEF 76EF

DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW DW

DO LOOP EXITIF LIF SIF LELSE ELSE ENDIF KEY ONERROR ON GET OUT POKE DPOKE NONSENSE CALLER ROLL SCROLL SCREEN DISPLAY BOOT LABEL FILL WINDOW AUTO POP RECORD

;DO ;LOOP ;EXIT IF ;LONG IF ;SHORT IF ;LELSE ;ELSE ;END IF ;KEY ;ON ERROR ;ON ;GET ;OUT ;POKE ;DPOKE ;RENAME ;CALL ;ROLL ;SCROLL ;SCREEN ;DISPLAY ;BOOT ;LABEL ;FILL ;WINDOW ;AUTO ;POP ;RECORD ;DEVICE ;PROTECT ;HIDE ;ZAP ;POW ;BOOM ;ZOOM ; ; ; ; ; ; ; ; ;

D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF (FUNCTION PREFIX)

DW SLDEVICE DW NONSENSE DW NONSENSE DW ZAP DW POW DW BOOM DW ZOOM ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE ; DW NONSENSE

;TABLE FOR CHARS THAT USE ALL 8 SCANS; VALUE TO USE FOR SCAN 8, DISP TO NEXT ;SUCH CHAR, ZERO ENDS TABLE 0878 0880 00A0 FF40 1C18 1030 2008 0240 1C 005A F0D8 18FC 9CFF F6FF U8TAB: DB DB DB DB DB DB DB DB DB 08H,78H 08H,80H 00H,0A0H 0FFH,40H 1CH,18H 10H,30H 20H,08H 02H,40H 1CH ;"," ;";" ;DUMMY ;"_" ;"g" ;"j" ;"p" ;"q" ;"y" ;U8TAB TERMINATOR/SVAR BASE ADDR

VVAR2: SUBTAB: ;

DB 00H,5AH

;USED BY PRINT NUMBER DW -10000 DW -1000 DW -100 DW -10 DB 0 CHARSRC 1ST BYTE IS TERMINATOR!

;CHARSET BY SIMON N. GOODWIN ;CHARACTERS USE CENTRE 6 PIXELS, CAN BE UP TO 8 PIXELS HIGH ;COMPRESSED FORM USES 7 5-BIT SLICES PER CHAR, TAKES 600 BYTES VS 1096 CHARSRC: 0000000004 210840114A 000000295F 57D4A7528E 295D9C8888 9CD14A22B2 6984400000 0888420830 4108444095 77DD520084 F908000000 31840003E0 0000000006 3042222210 74675CC5C4 61084239D1 08888FBA21 3062E11952 F885F87821 8B8C887A31 77C2222210 7462E8C5CE 8C5E113000 3180630006 300C208888 2082007C1F DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB 000H,000H,000H,000H,004H 021H,008H,040H,011H,04AH 000H,000H,000H,029H,05FH 057H,0D4H,0A7H,052H,08EH 029H,05DH,09CH,088H,088H 09CH,0D1H,04AH,022H,0B2H 069H,084H,040H,000H,000H 008H,088H,042H,008H,030H 041H,008H,044H,040H,095H 077H,0DDH,052H,000H,084H 0F9H,008H,000H,000H,000H 031H,084H,000H,003H,0E0H 000H,000H,000H,000H,006H 030H,042H,022H,022H,010H 074H,067H,05CH,0C5H,0C4H 061H,008H,042H,039H,0D1H 008H,088H,08FH,0BAH,021H 030H,062H,0E1H,019H,052H 0F8H,085H,0F8H,078H,021H 08BH,08CH,088H,07AH,031H 077H,0C2H,022H,022H,010H 074H,062H,0E8H,0C5H,0CEH 08CH,05EH,011H,030H,000H 031H,080H,063H,000H,006H 030H,00CH,020H,088H,088H 020H,082H,000H,07CH,01FH

FED0 FED5 FEDA FEDF FEE4 FEE9 FEEE FEF3 FEF8 FEFD FF02 FF07 FF0C FF11 FF16 FF1B FF20 FF25 FF2A FF2F FF34 FF39 FF3E FF43 FF48 FF4D FF52 FF57 FF5C FF61 FF66 FF6B FF70 FF75 FF7A FF7F FF84 FF89 FF8E FF93 FF98 FF9D FFA2 FFA7 FFAC FFB1 FFB6 FFBB FFC0 FFC5 FFCA FFCF FFD4 FFD9 FFDE FFE3 FFE8 FFED FFF2 FFF7 FFFC 0000 0000 0000 0000 0000 0000 0000 0000

0020820888 83A2111004 74675BC1CE 8C7F18C7D1 8FA31F3A30 8422EF4631 8C7DF843D0 87FF087A10 83A3084E2E 8C63F8C62E 2108423821 0843174654 C525184210 843F1DD631 8C631CD671 8BA318C62E F463E8420E 8C635937D1 8FA928BA30 7062EF9084 210918C631 8BA318C62A 246318D6AA 8C54454631 8A884213E1 11110F9C84 2108784104 1043C21084 2708EA9084 2000000000 3251C423E0 0382F8BE10 F4631F000F 8420F085F1 8C5E003A3F 83CC947908 4000F8C5E1 843D18C624 0108420880 2108424211 9725121084 210C006AB5 AD400F4631 8800E8C62E 003D18FA00 03E3178400 B66108000F 8383E211E4 2106004631 8BC008C62A 200118C6AA 0022A22A20 0463178400 F8888F8884 4108221084 2108821044 220AA00000 0782D4B43E 00000F7BC0 F7BC0000C8 747F0780 ; ; 8000=

DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB DB

000H,020H,082H,008H,088H 083H,0A2H,011H,010H,004H 074H,067H,05BH,0C1H,0CEH 08CH,07FH,018H,0C7H,0D1H 08FH,0A3H,01FH,03AH,030H 084H,022H,0EFH,046H,031H 08CH,07DH,0F8H,043H,0D0H 087H,0FFH,008H,07AH,010H 083H,0A3H,008H,04EH,02EH 08CH,063H,0F8H,0C6H,02EH 021H,008H,042H,038H,021H 008H,043H,017H,046H,054H 0C5H,025H,018H,042H,010H 084H,03FH,01DH,0D6H,031H 08CH,063H,01CH,0D6H,071H 08BH,0A3H,018H,0C6H,02EH 0F4H,063H,0E8H,042H,00EH 08CH,063H,059H,037H,0D1H 08FH,0A9H,028H,0BAH,030H 070H,062H,0EFH,090H,084H 021H,009H,018H,0C6H,031H 08BH,0A3H,018H,0C6H,02AH 024H,063H,018H,0D6H,0AAH 08CH,054H,045H,046H,031H 08AH,088H,042H,013H,0E1H 011H,011H,00FH,09CH,084H 021H,008H,078H,041H,004H 010H,043H,0C2H,010H,084H 027H,008H,0EAH,090H,084H 020H,000H,000H,000H,000H 032H,051H,0C4H,023H,0E0H 003H,082H,0F8H,0BEH,010H 0F4H,063H,01FH,000H,00FH 084H,020H,0F0H,085H,0F1H 08CH,05EH,000H,03AH,03FH 083H,0CCH,094H,079H,008H 040H,000H,0F8H,0C5H,0E1H 084H,03DH,018H,0C6H,024H 001H,008H,042H,008H,080H 021H,008H,042H,042H,011H 097H,025H,012H,010H,084H 021H,00CH,000H,06AH,0B5H 0ADH,040H,00FH,046H,031H 088H,000H,0E8H,0C6H,02EH 000H,03DH,018H,0FAH,000H 003H,0E3H,017H,084H,000H 0B6H,061H,008H,000H,00FH 083H,083H,0E2H,011H,0E4H 021H,006H,000H,046H,031H 08BH,0C0H,008H,0C6H,02AH 020H,001H,018H,0C6H,0AAH 000H,022H,0A2H,02AH,020H 004H,063H,017H,084H,000H 0F8H,088H,08FH,088H,084H 041H,008H,022H,010H,084H 021H,008H,082H,010H,044H 022H,00AH,0A0H,000H,000H 007H,082H,0D4H,0B4H,03EH 000H,000H,00FH,07BH,0C0H 0F7H,0BCH,000H,000H,0C8H 074H,07FH,007H,080H DS 0FFFFH-$,0 SEND COMPUTER1 END 8000H ;dummy value

DB "AW,BG"

You might also like