wearmouth:version_2
                Differences
This shows you the differences between two versions of the page.
| wearmouth:version_2 [2022/03/22 09:24] – created evert | wearmouth:version_2 [2022/03/22 09:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | 2 | + | < | 
| + | < | ||
| + | ; Disassembly of the file " | ||
| + | ; | ||
| + | ; CPU Type: Z80 | ||
| + | ; | ||
| + | ; Created with dZ80 1.50 | ||
| + | ; | ||
| + | ; on Sunday, 28 of April 2002 at 12:35 PM | ||
| + | ; | ||
| + | |||
| + | ; ------------------------ | ||
| + | ; last updated 14-JAN-2004 | ||
| + | ; ------------------------ | ||
| + | |||
| + | #define DEFB .BYTE | ||
| + | #define DEFW .WORD | ||
| + | #define DEFM .TEXT | ||
| + | #define EQU .EQU | ||
| + | #define ORG .ORG | ||
| + | |||
| + |         ORG      | ||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; FLAGS3 System Variable - IY+$7C ($5CB6) | ||
| + | ; --------------------------------------- | ||
| + | ; Bit 0 - set when executing an extended command. | ||
| + | ; Bit 1 - set during CRT-VARS and CLEAR #, CLOSE etc. | ||
| + | ; Bit 2 - settable by User to force the ERR_SP routine to handle errors. | ||
| + | ; Bit 3 - set when networking. | ||
| + | ; Bit 4 - set during LOAD and MOVE | ||
| + | ; Bit 5 - set during SAVE | ||
| + | ; Bit 6 - set during MERGE | ||
| + | ; Bit 7 - set during VERIFY | ||
| + | ; | ||
| + | ; <font color=# | ||
| + | ; byte of channels and so PEEK 23734 gives 244 decimal (%11110100) the high | ||
| + | ; order byte of the Main ROM address PRINT-OUT - $09F4. | ||
| + | ; | ||
| + | ; ------------------------------------------- | ||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; The system is initialized by the Main ROM so this address is accessed | ||
| + | ;    | ||
| + | ; to the Main ROM. | ||
| + | |||
| + | <a name=" | ||
| + | L0000:  | ||
| + |         LD      (IY+$7C), | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ------------------- | ||
| + | ; THE < | ||
| + | ; ------------------- | ||
| + | ; An instruction fetch on address $0008 pages in this ROM. | ||
| + | ; The three-byte instruction at this location must exist on both sides of | ||
| + | ;   the looking-glass.  | ||
| + | ; It follows that this restart should never be invoked from this ROM. | ||
| + | |||
| + | <a name=" | ||
| + | L0008:  | ||
| + |         POP      | ||
| + | PUSH HL ; and save again on machine stack. | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ----------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------- | ||
| + | ; Call an address in the main ROM. The address follows the restart so this | ||
| + | ; is as convenient and as brief as a CALL instruction. | ||
| + | ; The SBRT routine within the system variables area reads | ||
| + | ; | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ; | ||
| + | ; By immediately placing the current value of HL in the subroutine, then | ||
| + | ; all registers before the call are as they were before the RST | ||
| + | ;    | ||
| + | ; this now redundant location so that, after this ROM is paged back in, | ||
| + | ; the registers, after the RST instruction has executed, are as they were | ||
| + | ;    | ||
| + | ; see START-2. | ||
| + | |||
| + | <a name=" | ||
| + | L0010:  | ||
| + | ; Z80 code to be picked up later. | ||
| + | |||
| + |         POP      | ||
| + | ; of address to be called. | ||
| + | PUSH DE ; preserve the DE register contents. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | DEFB $FF ; unused. | ||
| + | |||
| + | ; --------------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------------- | ||
| + | ; On the ZX80, testing the syntax flag was done with the 4-byte | ||
| + | ;    | ||
| + | ; ZX Spectrum, a call to SYNTAX-Z reduced the invocation to a three-byte | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0018:  | ||
| + | RET ; return the result. | ||
| + | ; (Z = Syntax, NZ = Run-time) | ||
| + | |||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | |||
| + | ; -------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------- | ||
| + | ; This is similar to the Main ROM error handler and the following byte | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0020:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | ; and then REP-MSG | ||
| + | |||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | |||
| + | ; ------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------ | ||
| + | ; This restart invokes the error handler of the Main 16K ROM. The required | ||
| + | ;   error number is usually first placed in the System Variable ERR_NR.  | ||
| + | ; some cases the error code is already present and this restart is used when | ||
| + | ; the error situations handled by this ROM have been eliminated. | ||
| + | ; Since the exit from this point is by manipulating the stack, the return | ||
| + | ;    | ||
| + | ; three conditional jumps back to this point. | ||
| + | |||
| + | <a name=" | ||
| + | L0028:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | |||
| + | ; ------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------------------- | ||
| + | ; This restart is used the first time that that the ROM is paged in to | ||
| + | ;    create the System Variables.  | ||
| + | ; fetch on $0008 or $1708. | ||
| + | |||
| + | <a name=" | ||
| + | L0030:  | ||
| + | |||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | DEFB $FF ; unused. | ||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; There is no service routine but should the routine be called either | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0038:  | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------ | ||
| + | ; This branch allows the user to trap errors before this ROM is used to print | ||
| + | ; the error report. | ||
| + | |||
| + | <a name=" | ||
| + | L003A:  | ||
| + | ; usually returns. | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; a continuation of RST 28H. | ||
| + | ; This ROM has inserted a Main ROM error code into ERR_NR and the routine in | ||
| + | ; the Main ROM is now invoked. | ||
| + | ; First a check is made to see if the user wishes to trap errors using a | ||
| + | ;    | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0040:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; run-time errors at this point but normally | ||
| + | ; returns here. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; channels and stops all microdrive motors. | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ;   As a security measure, the file ' | ||
| + | |||
| + |         LD      A, | ||
| + | ; ERR_NR. | ||
| + | CP $14 ; is it "CODE error" ? | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ;   The user has pressed BREAK while trying to load the program ' | ||
| + | |||
| + |         LD      HL, | ||
| + | PUSH HL ; place address zero on machine stack. | ||
| + |         RST      | ||
| + | |||
| + | ; | ||
| + | |||
| + | DEFB $FF ; unused | ||
| + | DEFB $FF ; unused | ||
| + | DEFB $FF ; unused | ||
| + | DEFB $FF ; unused | ||
| + | DEFB $FF ; unused | ||
| + | |||
| + | ; ------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------ | ||
| + | ; There is no NMI functionality. | ||
| + | |||
| + | <a name=" | ||
| + | L0066:  | ||
| + | |||
| + | |||
| + | ; -------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------- | ||
| + | ; An error has occurred during syntax checking so the position must be | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0068:  | ||
| + |         LD      ($5C5F), | ||
| + | |||
| + |         LD      SP, | ||
| + | |||
| + |         LD      HL, | ||
| + | PUSH HL ; push on the machine stack. | ||
| + | |||
| + |         RST      | ||
| + | ; the work areas before returning to the Error | ||
| + | ; Routine obtained from ERR_SP. | ||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; This allows the user's software to trap any errors at this point by setting | ||
| + | ; the otherwise unused bit 2 of FLAGS_3 after inserting a custom error | ||
| + | ;    | ||
| + | ; Both Shadow ROM situations and Main ROM situations can be trapped and the | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0077:  | ||
| + | ; error handler in Main RAM ? | ||
| + |         RET      | ||
| + | |||
| + | ;    | ||
| + | ; in the system variable ERR_SP and set bit 2 of FLAGS_3 so that it is invoked | ||
| + | ; at this point. | ||
| + | |||
| + |         LD      SP, | ||
| + |         RST      | ||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; A continuation of the code at $0010. | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0081:  | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + | |||
| + |         LD      ($5CBD), | ||
| + |         INC      | ||
| + | |||
| + |         EX      (SP), | ||
| + | ; stack - and the stack value (was DE) to HL. | ||
| + | |||
| + | EX DE,HL ; original DE value now restored. | ||
| + | |||
| + |         LD      HL, | ||
| + | PUSH HL ; place on stack. | ||
| + | |||
| + |         LD      HL, | ||
| + | PUSH HL ; place on stack | ||
| + | |||
| + |         LD      HL, | ||
| + | PUSH HL ; place on stack. | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------- | ||
| + | ; THE < | ||
| + | ; --------------------- | ||
| + | ; A continuation of code at L0008. The return address has been dropped off | ||
| + | ; the machine stack into HL. | ||
| + | ; | ||
| + | ; First see if this ROM was paged in as a result of the $0008 address | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L009A:  | ||
| + | |||
| + | LD A,H ; test HL for zero - the CALBAS | ||
| + | OR L ; indicator value. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         POP      | ||
| + |         LD      HL, | ||
| + | RET ; return. | ||
| + | |||
| + | ; | ||
| + | ; Now consider that the address $0008 may have been an input or output | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ; of the CALL-SUB routine in the Main ROM, i.e. | ||
| + | ;    | ||
| + | ;    | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L00A5:  | ||
| + |         LD      DE, | ||
| + |         SBC      | ||
| + |         POP      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; This ROM has been paged by an attempt to use a stream. | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + | PUSH HL ; the Main ROM afterwards. | ||
| + | |||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + |         LD      E, | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + | EX DE,HL ; transfer I/O address to HL. | ||
| + | |||
| + | JP (HL) ; jump to routine and then to UNPAGE | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ;   By elimination, | ||
| + | ; RST 08 instruction in the Main ROM. This may be the very first time | ||
| + | ; that this ROM has been paged in after startup or NEW. | ||
| + | |||
| + | <a name=" | ||
| + | L00BC:  | ||
| + | |||
| + | LD A,$01 ; %00000001 | ||
| + |         OUT      | ||
| + | |||
| + | LD A,$EE ; %11101110 | ||
| + |         OUT      | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | PUSH AF ; save accumulator again. | ||
| + | |||
| + | ;   < | ||
| + | ; but it is not in this ROM. Luckily in the Main ROM at $007B is the | ||
| + | ;    | ||
| + | ; the known address. | ||
| + | |||
| + |         RST      | ||
| + | DEFW $007B ; main TEMP-PTR3 | ||
| + | |||
| + |         LD      ($5C3A), | ||
| + | |||
| + | ; The error code at this stage is one less than actual code. | ||
| + | |||
| + |         CP      $FF             ; is it ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | ; the edit buffer. | ||
| + |         LD      A, | ||
| + | |||
| + |         CP      $F7             ; is character the token ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L00E7:  | ||
| + |         DEFB    $FF             ; ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ;    | ||
| + | ; Error RESTART in the Main ROM - range $00 (NEXT without FOR) to | ||
| + | ; $1A (Tape Loading Error) or a RESTART in RAM which could also include | ||
| + | ; the Hook Codes. | ||
| + | |||
| + | <a name=" | ||
| + | L00E9:  | ||
| + |         JP      NC,<A href="# | ||
| + | |||
| + |         CP      $F0             ; was it $0B ' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $F3             ; was it $0D ' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $FC             ; was it $17 ' | ||
| + |         JP      NZ,<A href="# | ||
| + | |||
| + | ; If one of the above three reports, then this is possibly an extended | ||
| + | ;    | ||
| + | ; may apply. The error could have occurred - | ||
| + | ; | ||
| + | ; 1) In INPUT - just pass control back to Main ROM. This is just a normal | ||
| + | ; Nonsense in BASIC and will not be due to anything new. | ||
| + | ; 2) While already investigating an error. Too much - just use Main ROM. | ||
| + | ; 3) While entering a new or modified line and syntax failed. | ||
| + | ; 4) While running the program and an error was encountered. | ||
| + | ; | ||
| + | ; The character address CH_ADD is not much use as that is the place | ||
| + | ; after the command where the standard ROM encountered an error. | ||
| + | ; It will be required by the Main ROM if control is passed back so, in | ||
| + | ; order that the Main ROM parsing routines can be used, make a copy of the | ||
| + | ; error character position. We will have to work forward from the | ||
| + | ;    | ||
| + | ;    | ||
| + | ; be necessary to remove hidden characters from the BASIC line. | ||
| + | |||
| + | <a name=" | ||
| + | L00FB:  | ||
| + |         LD      ($5CCB), | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         BIT      | ||
| + | |||
| + |         JP      NZ,<A href="# | ||
| + | |||
| + | ;    | ||
| + | |||
| + |         BIT      | ||
| + |         JP      NZ,<A href="# | ||
| + | |||
| + | ; else signal - handling an extended command - so that such a double error | ||
| + | ; can be trapped. | ||
| + | |||
| + |         SET      | ||
| + | ; extended command. | ||
| + | |||
| + |         RST      | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      (IY+$0C), | ||
| + | ; entry situation. | ||
| + | |||
| + | ; In both cases, load B with the statement number where the error was | ||
| + | ;    encountered.  | ||
| + | |||
| + | <a name=" | ||
| + | L011B:  | ||
| + | LD C,$00 ; and set C to zero for a quotes flag. | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; An edit line may have a line number at start and whitespace. We need to | ||
| + | ; set CH_ADD at the first command. | ||
| + | |||
| + | PUSH BC ; save BC | ||
| + | |||
| + |         RST      | ||
| + | DEFW $19FB ; main E-LINE-NO fetches any line number to | ||
| + | ; BC, setting CH_ADD at the command token. | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0018 ; main GET-CHAR gets first command of the | ||
| + | ; first statement of the errant line. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | ; the errant statement. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0130:  | ||
| + | |||
| + | <a name=" | ||
| + | L0133:  | ||
| + | CP (HL) ; compare with tested high byte. | ||
| + |         JR      NC,<A href="# | ||
| + | ; to TEST-LOW | ||
| + | |||
| + | ; else, unusually, the current line is not there so let Main ROM handle. | ||
| + | |||
| + | <a name=" | ||
| + | L0139:  | ||
| + | DEFB $00 ; Nonsense in BASIC | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L013B:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | CP (HL) ; compare to addressed byte. | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0144:  | ||
| + |         LD      E, | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + |         INC      | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | ; the mid-entry point of the statement loop. | ||
| + | |||
| + |         ADD      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ; Entered at mid-point S-STAT with statement counter in B and a quotes | ||
| + | ; counter, C, set at an even zero. | ||
| + | |||
| + | <a name=" | ||
| + | L014E:  | ||
| + |         ADD      | ||
| + | |||
| + | ; -> The Looping Point. | ||
| + | |||
| + | <a name=" | ||
| + | L0152:  | ||
| + | CP $0E ; is it the hidden number indicator ? | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         INC      | ||
| + | |||
| + |         CP      $22             ; is it quotes character '"' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DEC      | ||
| + | |||
| + | <a name=" | ||
| + | L015D:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $CB             ; is character ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0165:  | ||
| + |         JR      Z,<A href="# | ||
| + | ; for next statement. | ||
| + | |||
| + | ; A carriage return must not appear within quotes. | ||
| + | |||
| + | <a name=" | ||
| + | L0169:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + | |||
| + | ;    The Statement Loop Entry Point --& | ||
| + | |||
| + | <a name=" | ||
| + | L016F:  | ||
| + | ; to EACH-ST. | ||
| + | |||
| + | ; The errant statement has been located and CH_ADD is set to start. | ||
| + | |||
| + |         DEC      | ||
| + | |||
| + |         LD      ($5C5D), | ||
| + | |||
| + |         RST      | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         DEC      | ||
| + | |||
| + | LD C,$00 ; ?? | ||
| + | |||
| + | ;   It is well to reflect on what has been achieved up to this point.  | ||
| + | ; each statement, the first attempt at validation is made by the Main ROM. | ||
| + | ; Then if that should encounter something not to its liking, this ROM has | ||
| + | ; a bash. There could be ten or more statements before this one and each | ||
| + | ;   will have been validated by the Main ROM or by this routine.  | ||
| + | ; that validation process, when a number is parsed, then the integer or | ||
| + | ;    | ||
| + | ;    | ||
| + | ; | ||
| + | ; Once a statement has passed validation by either ROM, then it is not | ||
| + | ;    | ||
| + | ; | ||
| + | ;   10 PRINT "Hi :" : LET vat = 15 : OPEN# 7, " | ||
| + | ; | ||
| + | ;   then it will have already inserted six bytes after the ' | ||
| + | ;   the error ' | ||
| + | ; the command but needs to remove the hidden numbers before parsing the | ||
| + | ;    | ||
| + | ;    | ||
| + | ; right to the end of the line. There won't be any after this statement | ||
| + | ; but stopping at a CHR$(13) is easier than considering end of statement | ||
| + | ;    | ||
| + | ;    | ||
| + | ; and it is needlessly preserved on the stack. | ||
| + | ; | ||
| + | ; The end-user is oblivious to this elegant toing and froing between ROMS | ||
| + | ; and the unseen error code generation and cancellation. All that is | ||
| + | ;    | ||
| + | ; the program. | ||
| + | |||
| + | <a name=" | ||
| + | L0182:  | ||
| + |         LD      A, | ||
| + | |||
| + | CP $0E ; is it the number marker ? | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH BC ; preserve BC (zero) | ||
| + | |||
| + |         LD      BC, | ||
| + | |||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2 | ||
| + | |||
| + | PUSH HL ; preserve character pointer. | ||
| + | |||
| + |         LD      DE, | ||
| + |         AND      | ||
| + |         SBC      | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | EX DE,HL ; transfer CHADD_ value to HL. | ||
| + |         LD      BC, | ||
| + |         AND      | ||
| + |         SBC      | ||
| + |         LD      ($5CCB), | ||
| + | |||
| + | <a name=" | ||
| + | L01A3:  | ||
| + |         POP      | ||
| + | |||
| + | <a name=" | ||
| + | L01A5:  | ||
| + | CP $0D ; carriage return ? | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; The run-time path rejoins here | ||
| + | |||
| + | <a name=" | ||
| + | L01AA:  | ||
| + | DEFW $16BF ; main SET-WORK | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; from that following CHADD_ to that preceding | ||
| + | ; COPIES to the value $FF. | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR advances CH_ADD and fetches | ||
| + | ; the command character. | ||
| + | |||
| + |         SUB      | ||
| + | |||
| + |         CP      $01             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $02             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $03             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $04             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + | CP $05 ; 'OPEN #' ? | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $2A             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $21             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $08             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $07             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $2D             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CP      $2F             ; ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + | ; If none of the new extended commands then load HL from the VECTOR | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L01EC:  | ||
| + | JP (HL) ; jump to address. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L01F0:  | ||
| + | ; CHADD_ | ||
| + |         LD      ($5C5D), | ||
| + |         RST      | ||
| + | |||
| + | ; ----------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------- | ||
| + | ; A continuation of the restart code at $0030. A check is made to see if | ||
| + | ; the 58 variables already exist and the stack is set up to create the | ||
| + | ; room using the main ROM routine. If there isn't 58 free bytes available | ||
| + | ;   then an 'Out of memory' | ||
| + | |||
| + | <a name=" | ||
| + | L01F7:  | ||
| + |         LD      DE, | ||
| + |                                 ;                                    | ||
| + |         ADD      | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + | PUSH HL ; push on machine stack | ||
| + | |||
| + |         LD      HL, | ||
| + |         LD      ($5C65), | ||
| + | |||
| + |         LD      HL, | ||
| + |         LD      ($5C68), | ||
| + | |||
| + |         LD      HL, | ||
| + | ; P-RAMT_hi - the location before new area. | ||
| + |         LD      BC,<A href="# | ||
| + | |||
| + | ; Now call MAKE-ROOM in the Main ROM by placing a sequence of addresses | ||
| + | ; on the machine stack as it is not possible to use the CALBAS routine yet. | ||
| + | |||
| + |         LD      DE, | ||
| + | PUSH DE ; stack word. | ||
| + | |||
| + | LD E,$08 ; form address $0008 in Main ROM. | ||
| + | PUSH DE ; stack word. | ||
| + | |||
| + |         LD      DE, | ||
| + | PUSH DE ; stack word. | ||
| + | |||
| + | ; The machine stack now has the hierarchy DEFAULT; $0000; ERROR-1; | ||
| + | ;    | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ;   After creating room and paging this ROM back in, ' | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0224:  | ||
| + |         LD      BC, | ||
| + |         LD      DE, | ||
| + | LDIR ; copy the bytes. | ||
| + | |||
| + | ;   < | ||
| + | ;    | ||
| + | ;    | ||
| + | ; | ||
| + | ;   OPEN # | ||
| + | ; | ||
| + | ; may not work. | ||
| + | ; The fix would be to use 'ld hl $5cef ; ld (hl), $01' (5 bytes) | ||
| + | ;   or even 'dec h ; ld ($5cee), | ||
| + | ; The next pair of instructions would have been better if executed using | ||
| + | ; the HL register pair also. | ||
| + | |||
| + | LD A,$01 ; set accumulator to 1. | ||
| + |         LD      ($5CEF), | ||
| + | |||
| + |         LD      (IY+$77), | ||
| + |         LD      (IY+$76), | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; The extended System Variables already exist. | ||
| + | |||
| + | <a name=" | ||
| + | L023D:  | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------------- | ||
| + | ; These are the initial values of the first section of the extended System | ||
| + | ;    | ||
| + | ;   the standard 48K Spectrum System Variables.  | ||
| + | ; this location (CHANS) is moved upwards to make room. | ||
| + | ; The first new location (which was the first byte of CHANS) is now | ||
| + | ;    | ||
| + | ;   ROM becomes active again.  | ||
| + | ; by the copy itself. | ||
| + | |||
| + | <a name=" | ||
| + | L0242:  | ||
| + | DEFW $01F0 ; VECTOR | ||
| + | |||
| + |         LD      HL, | ||
| + | CALL $0000 ; | ||
| + |         LD      ($5CBA), | ||
| + | RET ; | ||
| + | |||
| + | DEFW $000C ; BAUD | ||
| + | DEFB $01 ; NTSTAT | ||
| + | DEFB $00 ; IOBORD - black. | ||
| + | DEFW $0000 ; SER_FL | ||
| + | |||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; The central area is filled with $FF bytes. | ||
| + | ; This occurs whenever a new extended command is invoked. | ||
| + | |||
| + | <a name=" | ||
| + | L0255:  | ||
| + | LD B,$22 ; thirty four bytes to fill. | ||
| + | |||
| + | <a name=" | ||
| + | L025A:  | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; ------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------ | ||
| + | ; This routine prints the error reports of the Shadow ROM. | ||
| + | ;   These relate to the code that follows a RST 20H restart.  | ||
| + | ;   is not printed as it would conflict with Main ROM reports.  | ||
| + | ; the message is printed and then the Main ROM routine is used to print a | ||
| + | ;   comma and then the line number and statement.  | ||
| + | ;    | ||
| + | ; The code is similar to that at MAIN-4 in the Main ROM. Some improvements | ||
| + | ; have been made but at least one slight error has been replicated. | ||
| + | |||
| + | <a name=" | ||
| + | L0260:  | ||
| + | ; this ROM. | ||
| + | |||
| + | EI ; Enable Interrupts. | ||
| + | |||
| + | HALT ; wait for the first interrupt. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; channels and stops any running drive motor. | ||
| + | |||
| + |         RES      | ||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0ECD ; main routine - COPY-BUFF | ||
| + |                                 ; <font color=# | ||
| + | ; set bit 1 of FLAGS first. | ||
| + | |||
| + | <a name=" | ||
| + | L0276:  | ||
| + |         LD      A, | ||
| + |         LD      (IY+$00), | ||
| + |         INC      | ||
| + | PUSH AF ; save actual code and status flags. | ||
| + | |||
| + |         LD      HL, | ||
| + |         LD      (IY+$37), | ||
| + |         LD      (IY+$26), | ||
| + |         LD      ($5C0B), | ||
| + | ; function is being evaluated. | ||
| + | |||
| + |         INC      | ||
| + |         LD      ($5C16), | ||
| + | |||
| + |         RST      | ||
| + | DEFW $16B0 ; main SET-MIN clears workspace etc. | ||
| + | |||
| + |         RES      | ||
| + | ; not INPUT mode. | ||
| + |                                 ; <font color=# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0D6E ; main CLS-LOWER | ||
| + | |||
| + |         SET      | ||
| + | ; requires clearing. | ||
| + |         RES      | ||
| + | |||
| + |         POP      | ||
| + |         LD      HL,<A href="# | ||
| + | LD B,$04 ; roughly ensure that BC does not limit | ||
| + | ; search area as code must be found. | ||
| + | CPIR ; search for code $00 - $17 skipping | ||
| + | ; all ASCII text. | ||
| + | |||
| + | ; At this point HL addresses first character of message. | ||
| + | |||
| + | <a name=" | ||
| + | L02A7:  | ||
| + | CP $20 ; compare to space. | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | PUSH HL ; save the character pointer | ||
| + |         RST      | ||
| + | DEFW $0010 ; main PRINT-A | ||
| + | |||
| + |         POP      | ||
| + |         INC      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L02B4:  | ||
| + |         INC      | ||
| + |         INC      | ||
| + |         LD      HL, | ||
| + | ; the comma and line statement. | ||
| + | PUSH HL ; push address to base of stack. | ||
| + |         RST      | ||
| + | |||
| + | ;   < | ||
| + | ; the Main ROM routine at $1349 will complete the ", 0:1" part looping | ||
| + | ; back to MAIN-2 to put $1303 on the stack again. | ||
| + | |||
| + | ; ------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------ | ||
| + | ;   These are the Shadow Error Reports.  | ||
| + | ;   " | ||
| + | ; which must be less than a space, serves to delimit the preceding text. | ||
| + | ; The final delimiter might just as well be $18. | ||
| + | |||
| + | <a name=" | ||
| + | L02BF    | ||
| + |         DEFM    " | ||
| + | DEFB $01 | ||
| + |         DEFM    " | ||
| + | DEFB $02 | ||
| + |         DEFM    " | ||
| + | DEFB $03 | ||
| + |         DEFM    " | ||
| + | DEFB $04 | ||
| + |         DEFM    " | ||
| + | DEFB $05 | ||
| + |         DEFM    " | ||
| + | DEFB $06 | ||
| + |         DEFM    " | ||
| + | DEFB $07 | ||
| + |         DEFM    " | ||
| + | DEFB $08 | ||
| + |         DEFM    " | ||
| + | DEFB $09 | ||
| + |         DEFM    " | ||
| + | DEFB $0A | ||
| + |         DEFM    " | ||
| + | DEFB $0B | ||
| + |         DEFM    "er mismatch e"  | ||
| + | DEFB $0C | ||
| + |         DEFM    " | ||
| + | DEFB $0D | ||
| + |         DEFM    " | ||
| + | DEFB $0E | ||
| + |         DEFM    " | ||
| + | DEFB $0F | ||
| + |         DEFM    "Drive ' | ||
| + | DEFB $10 | ||
| + |         DEFM    " | ||
| + | DEFB $11 | ||
| + |         DEFM    " | ||
| + | DEFB $12 | ||
| + |         DEFM    "File not found" | ||
| + | DEFB $13 | ||
| + |         DEFM    "Hook code error"  | ||
| + | DEFB $14 | ||
| + |         DEFM    "CODE error" | ||
| + | DEFB $15 | ||
| + |         DEFM    "MERGE error" | ||
| + | DEFB $16 | ||
| + |         DEFM    " | ||
| + | DEFB $17 | ||
| + |         DEFM    "Wrong file type" | ||
| + | DEFB $18 ; end-marker | ||
| + | |||
| + | ; ********************************************* | ||
| + | ; ** T H E S Y N T A X R O U T I N E S ** | ||
| + | ; ********************************************* | ||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; e.g. CAT 3 | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ;   the range 0 to 15 decimal.  | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0486:  | ||
| + |         LD      (HL), | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | CP $0D ; carriage return ? | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $3A             ; is character ':' | ||
| + | |||
| + | <a name=" | ||
| + | L0494:  | ||
| + | |||
| + |         CP      $23             ; is character '#' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ;    | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | <a name=" | ||
| + | L04A6:  | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + | ; range 1 - 8. | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L04B2:  | ||
| + | DEFB $00 ; Nonsense in BASIC | ||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L04B4:  | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L04BF:  | ||
| + |         LD      A, | ||
| + |         CP      $54             ; is character  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $42             ; is character  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L04CD:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L04D3:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         LD      A, | ||
| + | AND A | ||
| + |         JP      Z,<A href="# | ||
| + |         LD      ($5CC5), | ||
| + |         JP      <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L04E7:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L04ED:  | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0500:  | ||
| + |         LD      A, | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1727 ; main STR-DATA1 | ||
| + | |||
| + |         LD      HL, | ||
| + |         AND      | ||
| + |         SBC      | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      $54             ; " | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $42             ; " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L051C:  | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L051F:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0529:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L052F:  | ||
| + | DEFB $0B ; Stream already open | ||
| + | |||
| + | ; ---------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0531:  | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L053D:  | ||
| + |         CALL    <A href="# | ||
| + |         RST      | ||
| + | DEFW $0018 ; main GET-CHAR | ||
| + | |||
| + |         CP      $CC             ; ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         RST      | ||
| + | DEFW $0018 ; main GET-CHAR | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; -------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0559:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + |         CP      $23             ; is the character '#' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + |         LD      ($5C8D), | ||
| + |         LD      ($5C8F), | ||
| + |                                 ; <font color=# | ||
| + |         LD      (IY+$0E), | ||
| + |         LD      (IY+$57), | ||
| + | |||
| + | LD A,$07 ; load A with white. | ||
| + |         OUT      | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0D6B ; main CLS clears screen and sets colours. | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L057F:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CP      $23             ; '#' | ||
| + | |||
| + | <a name=" | ||
| + | L0584:  | ||
| + |                                 ; ' | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | |||
| + |         XOR      | ||
| + | |||
| + | <a name=" | ||
| + | L058E:  | ||
| + |         SET      | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + |         INC      | ||
| + | CP $10 ; | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | |||
| + | ; ----------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------------------- | ||
| + | ; This routine is used by the MOVE routines to bring one of the two 8-byte | ||
| + | ;   file specifiers into context.  | ||
| + | ; first Interface 1 ROM and this, the most efficient, has survived. | ||
| + | |||
| + | <a name=" | ||
| + | L059F:  | ||
| + |         LD      DE, | ||
| + | LD B,$08 ; eight bytes to swap. | ||
| + | |||
| + | <a name=" | ||
| + | L05A7:  | ||
| + |         LD      C, | ||
| + |         LD      (HL), | ||
| + | LD A,C ; byte 2 to accumulator. | ||
| + |         LD      (DE), | ||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ----------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------- | ||
| + | ; This routine returns with zero flag set if the current character is | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L05B1:  | ||
| + |         RET      | ||
| + | |||
| + |         CP      $3B             ; is character ';' | ||
| + | RET ; return. | ||
| + | |||
| + | ; ------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L05B7:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $3A             ; is character a ':' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L05BF:  | ||
| + |         RET      | ||
| + | |||
| + | |||
| + | ; -------------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L05C1:  | ||
| + |         LD      (IY+$00), | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + |         RST      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | LD A,$7F ; | ||
| + |         IN      A, | ||
| + | RRA ; | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | LD A,$FE ; | ||
| + |         IN      A, | ||
| + | RRA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L05DD:  | ||
| + | |||
| + | <a name=" | ||
| + | L05E0:  | ||
| + |         RST      | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L05E2:  | ||
| + |         RST      | ||
| + |                                 ; 'BREAK into program' | ||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L05E7:  | ||
| + | DEFW $1C8C ; main EXPT-EXP | ||
| + |         RST      | ||
| + | RET Z | ||
| + | |||
| + | PUSH AF | ||
| + |         RST      | ||
| + | DEFW $2BF1 ; main STK-FETCH | ||
| + | POP AF | ||
| + | RET | ||
| + | |||
| + | |||
| + | ; ----------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L05F2:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L05F5    | ||
| + | ; start in DE, length in BC. | ||
| + | |||
| + | ; one of the main tenets of Sinclair BASIC is that a value can be replaced | ||
| + | ; by an expression of the same type at any time, so this routine must allow | ||
| + | ; something like " | ||
| + | ; Only in runtime when the expression is evaluated can a single character be | ||
| + | ; insisted upon. | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | PUSH AF ; save following character. | ||
| + | |||
| + | LD A,C ; in runtime check | ||
| + |         DEC      | ||
| + | OR B ; a single character. | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         LD      A, | ||
| + | |||
| + |         RST      | ||
| + | DEFW $2C8D ; main ALPHA | ||
| + | |||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         AND      | ||
| + | |||
| + |         LD      ($5CD9), | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | <a name=" | ||
| + | L060C:  | ||
| + |         RET      | ||
| + | |||
| + |         CP      $3A             ; is character ':' | ||
| + |         RET      | ||
| + | |||
| + | CP $A5 ; RND | ||
| + |         RET      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JP      NZ,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | ; ----------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------------- | ||
| + | ; This routine is called once only to evaluate the numeric expression | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L061E:  | ||
| + | DEFW $1C82 ; main EXPT-1NUM | ||
| + |         RST      | ||
| + |         RET      | ||
| + | |||
| + | PUSH AF ; save NZ not syntax flag | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1E99 ; main FIND-INT2 | ||
| + | |||
| + |         LD      ($5CD6), | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L062D:  | ||
| + |         DEFB    $02             ; ' | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L062F:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CALL    <A href="# | ||
| + | RET Z | ||
| + | |||
| + | PUSH AF | ||
| + | LD A,C | ||
| + | OR B | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | LD HL,$000A | ||
| + |         SBC      | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      ($5CDA), | ||
| + |         LD      ($5CDC), | ||
| + | POP AF | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L064C:  | ||
| + | DEFB $03 ; Invalid name | ||
| + | |||
| + | ; ------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L064E:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         RST      | ||
| + | DEFW $1C82 ; main EXPT-1NUM | ||
| + |         RST      | ||
| + |         RET      | ||
| + | |||
| + | PUSH AF ; | ||
| + |         RST      | ||
| + | DEFW $1E94 ; main FIND-INT1 | ||
| + | CP $10 ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         LD      ($5CD8), | ||
| + |         POP      | ||
| + | RET ; | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0663:  | ||
| + | DEFB $01 ; Invalid stream number | ||
| + | |||
| + | |||
| + | ; ---------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------- | ||
| + | ; called once from TEST-MNAM | ||
| + | |||
| + | <a name=" | ||
| + | L0665:  | ||
| + |         CP      $4D             ; is character " | ||
| + |         JP      NZ,<A href="# | ||
| + |                                 ; Error: ' | ||
| + | |||
| + | <a name=" | ||
| + | L066D:  | ||
| + | LD A,E ; test for | ||
| + | OR D ; zero. | ||
| + |         JR      Z,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         INC      | ||
| + | LD A,E ; location does not hold | ||
| + | OR D ; the default $FFFF value. | ||
| + |         JR      Z,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         DEC      | ||
| + |         LD      HL,<A href="# | ||
| + |         SBC      | ||
| + |         RET      | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0681:  | ||
| + | DEFB $04 ; Invalid drive number | ||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0683:  | ||
| + | DEFB $08 ; Missing drive number | ||
| + | |||
| + | ; ----------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------------- | ||
| + | ; This routine checks that the device expression is " | ||
| + | ; the range 1 - 8 and that the filename is not null. | ||
| + | |||
| + | <a name=" | ||
| + | L0685:  | ||
| + | ; drive number. | ||
| + | |||
| + |         LD      A, | ||
| + | ; of filename. | ||
| + |         AND      | ||
| + |         RET      | ||
| + | |||
| + | ; else system default $FF. | ||
| + | |||
| + |         RST      | ||
| + | DEFB $06 ; Missing name | ||
| + | |||
| + | |||
| + | ; ---------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L068F:  | ||
| + | INC DE | ||
| + | LD A,E | ||
| + | OR D | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | DEC DE | ||
| + | LD HL,L0040 | ||
| + |         SBC      | ||
| + | RET NC | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L069F:  | ||
| + | DEFB $05 ; Invalid station number | ||
| + | |||
| + | <a name=" | ||
| + | L06A1:  | ||
| + | DEFB $07 ; Missing station number | ||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L06A3:  | ||
| + |         CALL    <A href="# | ||
| + |         JP      NZ,<A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | RET ; return... | ||
| + | |||
| + | |||
| + | ; ----------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L06B0:  | ||
| + | INC HL | ||
| + | LD A,L | ||
| + | OR H | ||
| + | RET NZ | ||
| + | |||
| + |         RST      | ||
| + | DEFB $09 ; Missing baud rate | ||
| + | |||
| + | ; ------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L06B9:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CP      $23             ; is character '#' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L06CC:  | ||
| + | RET Z | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      $54             ; is character " | ||
| + |         RET      | ||
| + | |||
| + |         CP      $42             ; is character " | ||
| + |         RET      | ||
| + | |||
| + |         CP      $4E             ; is character " | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0700:  | ||
| + | |||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0701:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CP      $2A             ; is character ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0716:  | ||
| + |         LD      A, | ||
| + | |||
| + |         CP      $4E             ; is character " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         SET      | ||
| + | |||
| + | <a name=" | ||
| + | L0722:  | ||
| + | CP $0D ; is character carriage return ? | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $3A             ; is character ':' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $AA             ; is character the token ' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $AF             ; is character the token ' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $CA             ; is character the token ' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $E4             ; is character the token ' | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L073C:  | ||
| + | DEFB $00 ; Nonsense in BASIC | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L073E:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1C82 ; main EXPT-1NUM | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1E99 ; main FIND-INT2 | ||
| + | |||
| + |         LD      ($5CED), | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0750:  | ||
| + | |||
| + | ; the ' | ||
| + | |||
| + | <a name=" | ||
| + | L0753:  | ||
| + |         LD      ($5CE6), | ||
| + |         LD      HL, | ||
| + |         LD      DE, | ||
| + |         LD      ($5CE9), | ||
| + | SCF ; | ||
| + |         SBC      | ||
| + |         LD      ($5CE7), | ||
| + |         LD      HL, | ||
| + |         SBC      | ||
| + |         LD      ($5CEB), | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0771:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | LD HL,$1B00 | ||
| + |         LD      ($5CE7), | ||
| + | LD HL,$4000 | ||
| + |         LD      ($5CE9), | ||
| + | LD A,$03 | ||
| + |         LD      ($5CE6), | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0789:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | CP $0D ; is character a carriage return ? | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $3A             ; is character a ':' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L079A:  | ||
| + | DEFW $1CE6 ; main USE-ZERO | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L079F:  | ||
| + | DEFW $1C82 ; main EXPT-1NUM | ||
| + |         CALL    <A href="# | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L07A7:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1CE6 ; main USE-ZERO | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L07B2:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         RST      | ||
| + | DEFW $1C82 ; main EXPT-1NUM | ||
| + | |||
| + | <a name=" | ||
| + | L07B8:  | ||
| + | DEFW $0018 ; main GET-CHAR | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1E99 ; main FIND-INT2 | ||
| + |         LD      ($5CE7), | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1E99 ; main FIND-INT2 | ||
| + |         LD      ($5CE9), | ||
| + | |||
| + | LD A,$03 | ||
| + |         LD      ($5CE6), | ||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | ; | ||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L07D2:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $14 ; MERGE error | ||
| + | |||
| + | <a name=" | ||
| + | L07DA:  | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         RST      | ||
| + | DEFW $28B2 ; main LOOK-VARS | ||
| + | |||
| + | SET 7,C | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | LD HL,$0000 | ||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      (IY+$00), | ||
| + |         RST      | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L07F2:  | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L07F4:  | ||
| + | DEFB $00 ; Nonsense in BASIC | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L07F6:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0803:  | ||
| + | LD A,(HL) | ||
| + |         LD      ($5CE7), | ||
| + | INC HL | ||
| + | LD A,(HL) | ||
| + |         LD      ($5CE8), | ||
| + | INC HL | ||
| + | |||
| + | <a name=" | ||
| + | L080E:  | ||
| + |         LD      ($5CEB), | ||
| + | LD A,$01 | ||
| + | BIT 6,C | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | INC A | ||
| + | |||
| + | <a name=" | ||
| + | L0819:  | ||
| + | |||
| + | <a name=" | ||
| + | L081C:  | ||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CP      $29             ; is character ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0020 ; main NEXT-CHAR | ||
| + | |||
| + | |||
| + |         CALL    <A href="# | ||
| + |         LD      ($5CE9), | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L082F:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | |||
| + |         CP      $42             ; is character ' | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $4E             ; is character ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0849:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L084F:  | ||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L0854:  | ||
| + | INC HL | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | CP $03 ; compare with three - type CODE | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | <a name=" | ||
| + | L086E:  | ||
| + | |||
| + | <a name=" | ||
| + | L0872:  | ||
| + | OR B ; | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | PUSH IX ;;; | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         DEC      | ||
| + |         INC      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0881:  | ||
| + | |||
| + | ; -------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0884:  | ||
| + | PUSH BC ; | ||
| + |         BIT      | ||
| + |         LD      A, | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0892:  | ||
| + | |||
| + | <a name=" | ||
| + | L0895:  | ||
| + |         POP      | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0898:  | ||
| + |         CALL    <A href="# | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L08A2:  | ||
| + |         CALL    <A href="# | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ---------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L08AC:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L08B3:  | ||
| + |         LD      DE, | ||
| + |         LD      BC, | ||
| + | LDIR ; copy type, start, length, length of program. | ||
| + | |||
| + |         LD      A, | ||
| + | |||
| + |         CP      $4E             ; " | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $42             ; " | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; proceed with Microdrive device. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |                                 ; device is " | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; record for the above filename and populates | ||
| + | ; the locations HD_00 to HD_11. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | ; types agree and then loads rest of records. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L08D1:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L08D7:  | ||
| + | LD B,$09 ; | ||
| + | |||
| + | <a name=" | ||
| + | L08DC:  | ||
| + | PUSH BC | ||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L08E4:  | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L08EB:  | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L08F0:  | ||
| + | POP HL | ||
| + | LD (HL),A | ||
| + | INC HL | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | ; --& | ||
| + | |||
| + | <a name=" | ||
| + | L08F6:  | ||
| + | LD B,A | ||
| + |         LD      A, | ||
| + | CP B | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | CP $03 ; compare with three - type CODE | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         JR      C,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0906:  | ||
| + | DEFB $16 ; Wrong file type | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0908:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0915:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $14 ; MERGE error | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L091D:  | ||
| + |         LD      DE, | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         SBC      | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $13 ; Code Error | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0934:  | ||
| + | DEFB $15 ; Verification has failed | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0936:  | ||
| + |         LD      A, | ||
| + |         CP      $CD             ; ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0945:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | CP $03 ; compare with three - type CODE | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         ADD      | ||
| + | |||
| + | <a name=" | ||
| + | L0956:  | ||
| + | OR L ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L095D:  | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L0966:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L096B:  | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | |||
| + |         RST      | ||
| + | DEFB $14 ; MERGE error | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0977:  | ||
| + | PUSH BC ; | ||
| + |         INC      | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0030 ; main BC-SPACES | ||
| + | |||
| + |         LD      (HL), | ||
| + | EX DE,HL ; | ||
| + |         POP      | ||
| + | PUSH HL ; | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + | |||
| + |         RST      | ||
| + | DEFW $08CE ; main ME-CTRLX | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L098C:  | ||
| + |         CP      $CD             ; ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0998:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L09A4:  | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L09A7:  | ||
| + |         LD      HL, | ||
| + | PUSH HL ; | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         INC      | ||
| + | EX DE,HL ; | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L09B9:  | ||
| + | EX DE,HL ; | ||
| + | SCF ; | ||
| + |         SBC      | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L09C2:  | ||
| + |         ADD      | ||
| + | LD B,H ; | ||
| + | LD C,L ; | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1F05 ; main TEST-ROOM | ||
| + | |||
| + | ;   < | ||
| + | ;   of the microdrive is running.  | ||
| + | ; then the processor stops at the HALT instruction at address $1303 | ||
| + | ;    | ||
| + | ;    | ||
| + | ; call to a 6-byte subroutine which carries out the same instructions | ||
| + | ;    | ||
| + | ; this ROM will be paged again by the instruction fetch at 0008. The | ||
| + | ;    | ||
| + | ;   other ROM to execute the "LD A, | ||
| + | ;   the " | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L09CB:  | ||
| + |         LD      A, | ||
| + | AND A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | LD A,H | ||
| + | OR L | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      $CD             ; is character an inverted " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L09E2:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | LD DE,$0114 | ||
| + |         ADD      | ||
| + | |||
| + | <a name=" | ||
| + | L09EC:  | ||
| + | LD B,(HL) | ||
| + | DEC HL | ||
| + | LD C,(HL) | ||
| + | DEC HL | ||
| + | INC BC | ||
| + | INC BC | ||
| + | INC BC | ||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2 | ||
| + | |||
| + | <a name=" | ||
| + | L09F7:  | ||
| + | DEC HL | ||
| + |         LD      BC, | ||
| + | PUSH BC | ||
| + | INC BC | ||
| + | INC BC | ||
| + | INC BC | ||
| + |         LD      A, | ||
| + | PUSH AF | ||
| + |         RST      | ||
| + | DEFW $1655 ; main MAKE-ROOM | ||
| + | INC HL | ||
| + | POP AF | ||
| + | LD (HL),A | ||
| + | POP DE | ||
| + | INC HL | ||
| + | LD (HL),E | ||
| + | INC HL | ||
| + | LD (HL),D | ||
| + | INC HL | ||
| + | |||
| + | <a name=" | ||
| + | L0A13:  | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0A19:  | ||
| + |         LD      DE, | ||
| + |         LD      HL, | ||
| + | DEC HL | ||
| + |         RST      | ||
| + | DEFW $19E5 ; main RECLAIM-1 | ||
| + |         LD      BC, | ||
| + |         LD      HL, | ||
| + |         RST      | ||
| + | DEFW $1655 ; main MAKE-ROOM | ||
| + | INC HL | ||
| + |         LD      BC, | ||
| + |         ADD      | ||
| + |         LD      ($5C4B), | ||
| + |         LD      A, | ||
| + | LD H,A | ||
| + | AND $C0 | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         SET      | ||
| + |         LD      A, | ||
| + | LD L,A | ||
| + |         LD      ($5C42), | ||
| + |         LD      (IY+$0A), | ||
| + | |||
| + | <a name=" | ||
| + | L0A52:  | ||
| + |         LD      DE, | ||
| + | DEC HL | ||
| + |         LD      ($5C57), | ||
| + | INC HL | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; This routine is able to either LOAD or VERIFY a block of bytes, from any | ||
| + | ; of the three possible binary sources, A Microdrive cartridge, the Binary | ||
| + | ;   " | ||
| + | ; The block could be a program, code bytes or an array and the first | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0A60:  | ||
| + | OR E ; for zero. | ||
| + |         RET      | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      $CD             ; is letter " | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | ; the B channel or network. | ||
| + | |||
| + | ; else is a temporary " | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; of code from microdrive. | ||
| + | |||
| + | RET ; return after called routine. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; Load or Verify from B channel or Network. | ||
| + | |||
| + | <a name=" | ||
| + | L0A6E:  | ||
| + | PUSH DE ; save byte count. | ||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; Load or Verify from " | ||
| + | |||
| + | <a name=" | ||
| + | L0A76:  | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; Load or Verify from " | ||
| + | |||
| + | <a name=" | ||
| + | L0A7D:  | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | ; Load or Verify " | ||
| + | |||
| + | <a name=" | ||
| + | L0A82:  | ||
| + |         DEC      | ||
| + |         POP      | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      (HL), | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; Verify " | ||
| + | |||
| + | <a name=" | ||
| + | L0A8E:  | ||
| + | ; memory. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $15             ; ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; Load or Verify " | ||
| + | |||
| + | <a name=" | ||
| + | L0A93:  | ||
| + | LD A,E ; test the byte | ||
| + | OR D ; counter for zero. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0A99:  | ||
| + |         LD      ($5CD6), | ||
| + | |||
| + |         LD      BC, | ||
| + |         LD      ($5CDA), | ||
| + | |||
| + |         LD      BC,<A href="# | ||
| + |         LD      ($5CDC), | ||
| + | |||
| + |         SET      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; bytes for a program. | ||
| + | |||
| + |         LD      HL, | ||
| + |         LD      DE, | ||
| + |         LD      BC, | ||
| + |                                 ; <font color=# | ||
| + | |||
| + | LDIR ; block copy. | ||
| + | |||
| + |         SET      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |                                 ; record for the ' | ||
| + | ; the nine locations HD_00 to HD_11. | ||
| + | |||
| + |         JP      <A href="# | ||
| + |                                 ; ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0ACA:  | ||
| + | |||
| + | ; ******************************************* | ||
| + | ; ** T H E R S 2 3 2 R O U T I N E S ** | ||
| + | ; ******************************************* | ||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0ACD:  | ||
| + |         LD      HL,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0AD4:  | ||
| + | INC HL | ||
| + | LD D,(HL) | ||
| + | INC HL | ||
| + | EX DE,HL | ||
| + | LD A,H | ||
| + | CP $4B ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | AND A | ||
| + |         SBC      | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | EX DE,HL | ||
| + | INC HL | ||
| + | INC HL | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0AE8:  | ||
| + | LD E,(HL) | ||
| + | INC HL | ||
| + | LD D,(HL) | ||
| + |         LD      ($5CC3), | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0AF3:  | ||
| + | DEFW $0A82 ; | ||
| + | DEFW $006E ; | ||
| + | DEFW $04C5 ; | ||
| + | DEFW $012C ; | ||
| + | DEFW $01BE ; | ||
| + | DEFW $0258 ; | ||
| + | DEFW $00DE ; | ||
| + | DEFW $04B0 ; | ||
| + | DEFW $006E ; | ||
| + | DEFW $0960 ; | ||
| + | DEFW $0036 ; | ||
| + | DEFW $12C0 ; | ||
| + | DEFW $001A ; | ||
| + | DEFW $2580 ; | ||
| + | DEFW $000C ; | ||
| + | DEFW $4B00 ; | ||
| + | DEFW $0005 ; | ||
| + | |||
| + | |||
| + | ; ---------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0B17:  | ||
| + | ; location following the Channels area. | ||
| + |         DEC      | ||
| + |         LD      BC, | ||
| + | PUSH BC ; save bytes | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1655 ; main routine MAKE-ROOM opens up the space. | ||
| + | ; register HL points to location before room. | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | PUSH DE ; save DE briefly | ||
| + |         CALL    <A href="# | ||
| + | ; pointers to filenames in D_STR1 and D_STR2. | ||
| + |         POP      | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + |         LD      BC, | ||
| + | LDDR ; block copy downwards. | ||
| + | |||
| + |         INC      | ||
| + |         LD      A, | ||
| + |         CP      $42             ; is it " | ||
| + |         RET      | ||
| + | |||
| + | ; but if this is to be a binary channel then overwrite the letter and the output | ||
| + | ; and input routines. | ||
| + | |||
| + | PUSH DE ; | ||
| + | |||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + | |||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + | |||
| + |         LD      DE,<A href="# | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + | |||
| + |         LD      DE,<A href="# | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + | |||
| + |         POP      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0B4E:  | ||
| + | |||
| + | <a name=" | ||
| + | L0B51:  | ||
| + | DEC HL | ||
| + | EX DE,HL | ||
| + | AND A | ||
| + |         SBC      | ||
| + | EX DE,HL | ||
| + |         LD      HL, | ||
| + |         LD      A, | ||
| + | RLCA | ||
| + | LD C,A | ||
| + | LD B,$00 | ||
| + |         ADD      | ||
| + | LD (HL),E | ||
| + | INC HL | ||
| + | LD (HL),D | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; the eleven-byte " | ||
| + | |||
| + | <a name=" | ||
| + | L0B6B:  | ||
| + | DEFW $0008 ; main ERROR-1 | ||
| + |         DEFB    $54             ; character " | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + | DEFW $000B ; channel length - 11 bytes. | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0B76:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0B7C:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0B82:  | ||
| + | RES 7,A | ||
| + | RET | ||
| + | |||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L0B88:  | ||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      A, | ||
| + | SCF ; | ||
| + | |||
| + | RET ; Return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0B95:  | ||
| + | |||
| + | DI ; Disable Interrupts | ||
| + | |||
| + |         LD      A, | ||
| + |         OUT      | ||
| + | |||
| + |         LD      DE, | ||
| + |         LD      HL, | ||
| + | LD B,D ; | ||
| + | LD C,E ; | ||
| + |         SRL      | ||
| + | RR C ; | ||
| + | LD A,$FE ; | ||
| + |         OUT      | ||
| + | |||
| + | <a name=" | ||
| + | L0BAF:  | ||
| + | RLCA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0BC3:  | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH AF ; | ||
| + | LD A,$EE ; | ||
| + |         OUT      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0BCF:  | ||
| + | LD L,C ; | ||
| + | |||
| + | LD B,$80 ; Load B with the start bit. | ||
| + | |||
| + |         DEC      | ||
| + |         DEC      | ||
| + |         DEC      | ||
| + | |||
| + | <a name=" | ||
| + | L0BD6:  | ||
| + | NOP ; (4) a timing value. | ||
| + | |||
| + | <a name=" | ||
| + | L0BD8:  | ||
| + | LD A,H ; (4) | ||
| + | OR L ; (4) | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         ADD      | ||
| + |         IN      A, | ||
| + | RLCA ; Rotate bit 7 to carry. | ||
| + | RR B ; pick up carry in B | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | LD A,$EE ; Send CTS line low (comms data 0 also) | ||
| + |         OUT      | ||
| + | |||
| + | LD A,B ; Transfer the received byte to A. | ||
| + | CPL ; Complement. | ||
| + | SCF ; Set Carry to signal success. | ||
| + | PUSH AF ; (*) push the success flag. | ||
| + | |||
| + | ; The success and failure (time out) paths converge here with the HL register | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0BEE:  | ||
| + | |||
| + | <a name=" | ||
| + | L0BEF:  | ||
| + | LD A,L ; ( 4) | ||
| + | OR H ; ( 4) | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ;    | ||
| + | |||
| + |         ADD      | ||
| + |         ADD      | ||
| + |         ADD      | ||
| + | |||
| + | ; The device at the other end of the cable (not a Spectrum) may send a | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0BF7:  | ||
| + | LD A,L ; Test for | ||
| + | OR H ; zero. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; test the bit read. | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | ; As with first byte, TXdata must be high four four tests. | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | |||
| + | ; A second byte is on its way and is received exactly as before. | ||
| + | |||
| + | LD H,D ; | ||
| + | LD L,E ; | ||
| + |         SRL      | ||
| + | RR L ; | ||
| + | LD B,$80 ; | ||
| + |         DEC      | ||
| + |         DEC      | ||
| + |         DEC      | ||
| + | |||
| + | <a name=" | ||
| + | L0C1B:  | ||
| + | NOP ; timing. | ||
| + | |||
| + | <a name=" | ||
| + | L0C1D:  | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         ADD      | ||
| + |         IN      A, | ||
| + | RLCA ; | ||
| + | RR B ; | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | ; The start bit has been pushed out and B contains the second received byte. | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + | LD A,B ; Transfer the byte to A. | ||
| + | CPL ; Complement | ||
| + |         LD      (HL), | ||
| + | |||
| + | <a name=" | ||
| + | L0C34:  | ||
| + | |||
| + |         POP      | ||
| + | ; and the carry flag set ) | ||
| + | |||
| + | EI ; Enable Interrupts | ||
| + | |||
| + | RET ; Return. | ||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; The text channel output routine is able to list programs and, when | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0C3A:  | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         SUB      | ||
| + |         RST      | ||
| + | DEFW $0C10 ; main PO-TOKENS | ||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0C44:  | ||
| + |         RES      | ||
| + | CP $20 ; compare to space | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         SET      | ||
| + | |||
| + | <a name=" | ||
| + | L0C4F:  | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      A,$3F           ; output CHR$(127) and graphics as '?' | ||
| + | |||
| + | <a name=" | ||
| + | L0C55:  | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | PUSH AF ; Preserve character. | ||
| + | |||
| + |         INC      | ||
| + |         LD      A, | ||
| + |         CP      (IY+$76)  | ||
| + | |||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      (IY+$76), | ||
| + | |||
| + | <a name=" | ||
| + | L0C6C:  | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0C70:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0C74:  | ||
| + | LD A,$0D ; output a CR carriage return. | ||
| + |         CALL    <A href="# | ||
| + | LD A,$0A ; output a LF line feed. | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0C82:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + | LD E,$00 ; | ||
| + | |||
| + | <a name=" | ||
| + | L0C8C:  | ||
| + | INC C | ||
| + | LD A,C | ||
| + | CP B | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0C92:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0C9A:  | ||
| + | LD A,$20 | ||
| + |         CALL    <A href="# | ||
| + | POP DE | ||
| + | DEC E | ||
| + | RET Z | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0CA5:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | CP $17 | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | CP $10 | ||
| + | RET C | ||
| + | |||
| + | LD DE,$0CD0 | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0CB5:  | ||
| + | |||
| + | <a name=" | ||
| + | L0CB8:  | ||
| + | |||
| + | <a name=" | ||
| + | L0CBB:  | ||
| + | PUSH DE | ||
| + | LD DE,$0005 | ||
| + |         ADD      | ||
| + | POP DE | ||
| + | LD (HL),E | ||
| + | INC HL | ||
| + | LD (HL),D | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0CC8:  | ||
| + |         LD      ($5C0F), | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0CD0:  | ||
| + |         CALL    <A href="# | ||
| + | LD D,A | ||
| + |         LD      A, | ||
| + | CP $16 ; AT control code ? | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | CP $17 ; TAB control code ? | ||
| + | CCF | ||
| + | RET NZ | ||
| + | |||
| + |         LD      A, | ||
| + | LD D,A | ||
| + | |||
| + | <a name=" | ||
| + | L0CE6:  | ||
| + | CP D | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0CEE:  | ||
| + | LD A,D | ||
| + | SUB B | ||
| + | LD D,A | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0CF4:  | ||
| + | OR A | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0CF9:  | ||
| + | CP D ; | ||
| + |         RET      | ||
| + | |||
| + | PUSH DE ; | ||
| + | LD A,$20 ; | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; <font color=# | ||
| + | ; The bits of a byte are sent inverted. They are fixed in length and heralded | ||
| + | ; by a start bit and followed by two stop bits. | ||
| + | |||
| + | <a name=" | ||
| + | L0D07:  | ||
| + | |||
| + | CPL ; Invert the bits of the character. | ||
| + | LD C,A ; Copy the character to C. | ||
| + | |||
| + |         LD      A, | ||
| + |         OUT      | ||
| + | |||
| + | LD A,$EF ; Set to %11101111 | ||
| + |         OUT      | ||
| + | |||
| + | CPL ; reset bit 0 (other bits of no importance) | ||
| + |         OUT      | ||
| + | |||
| + |         LD      HL, | ||
| + | LD D,H ; Copy BAUD value to DE for count. | ||
| + | LD E,L ; | ||
| + | |||
| + | <a name=" | ||
| + | L0D1C:  | ||
| + | LD A,D ; ( 4) | ||
| + | OR E ; ( 4) | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0D21:  | ||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | SCF ; Set carry flag as the start bit. | ||
| + | DI ; Disable Interrupts. | ||
| + | |||
| + | <a name=" | ||
| + | L0D2C:  | ||
| + |         OUT      | ||
| + | |||
| + | LD D,H ; Transfer the BAUD value to DE for count. | ||
| + | LD E,L ; | ||
| + | |||
| + | <a name=" | ||
| + | L0D32:  | ||
| + | LD A,D ; ( 4) | ||
| + | OR E ; ( 4) | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DEC      | ||
| + |         XOR      | ||
| + |         SRL      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | ; Note the last two bits will have been sent reset as C is exhausted. | ||
| + | |||
| + | EI ; Enable Interrupts. | ||
| + | |||
| + | LD A,$01 ; Set RXdata | ||
| + | |||
| + | LD C,$EF ; prepare port address. | ||
| + | LD B,$EE ; prepare value %11101110 | ||
| + |         OUT      | ||
| + |         OUT      | ||
| + | |||
| + | <a name=" | ||
| + | L0D48:  | ||
| + | LD A,L ; ( 4) | ||
| + | OR H ; ( 4) | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0D4D:  | ||
| + | |||
| + |         LD      A, | ||
| + |         AND      | ||
| + | RRCA ; Rotate to the range 0 - 7 | ||
| + | RRCA ; | ||
| + | RRCA ; | ||
| + |         OUT      | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | RET ; Return. | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; If the extended streams e.g. #7 are being used for input then this ROM | ||
| + | ; will be paged in as a result of the $0008 address in the normal INPUT | ||
| + | ;    | ||
| + | ; it is the purpose of this routine to determine which has been used. | ||
| + | ; Note also that 'MOVE #7 TO #2' could also invoke this routine and that MOVE | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0D5A:  | ||
| + | ; unchanged. | ||
| + |                                 ; <font color=# | ||
| + | ; ROM before entering the EDITOR. | ||
| + | |||
| + | PUSH HL ; (*) Preserve HL the address of the actual | ||
| + | ; service routine - either NCHAN_IN, MCHAN_IN, | ||
| + | ; BCHAN_IN ot T_CHAN_IN. | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + |         LD      E, | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + | |||
| + |         AND      | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + |         SBC      | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ;    | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         LD      SP, | ||
| + |         POP      | ||
| + |         POP      | ||
| + | ; (usually). | ||
| + |         LD      ($5C3D), | ||
| + | |||
| + | <a name=" | ||
| + | L0D78:  | ||
| + | ; e.g. NCHAN_IN on the machine stack. | ||
| + | |||
| + |         LD      DE,<A href="# | ||
| + | PUSH DE ; push this address | ||
| + | |||
| + | JP (HL) ; jump to the service routine either MCHAN_IN, | ||
| + | ; NCHAN_IN, BCHAN_IN or TCHAN_IN and then return | ||
| + | ; to the next address IN-AG-RET. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0D7E    | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L0D82:  | ||
| + |         RST      | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0D87:  | ||
| + | ; and try again as always for INPUT. | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0D8A:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0F85 ; main ADD-CHRX | ||
| + | ; A special entry point within ADD-CHAR to add | ||
| + | ; the character to WORKSPACE. | ||
| + | |||
| + |         POP      | ||
| + | ; routine. | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0D94:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ------------------- | ||
| + | ; THE < | ||
| + | ; ------------------- | ||
| + | |||
| + | <a name=" | ||
| + | L0D98:  | ||
| + |         LD      DE,<A href="# | ||
| + | PUSH DE ; push this address for the return address. | ||
| + | |||
| + | JP (HL) ; jump to the service routine either MCHAN_IN, | ||
| + | ; NCHAN_IN, BCHAN_IN or TCHAN_IN and then return | ||
| + | ; to the next address IN-AG-RET. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0D9E    | ||
| + | |||
| + |         RET      | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | OR $01 ; | ||
| + | RET ; return with zero and carry reset. | ||
| + | |||
| + | |||
| + | ; *********************************************** | ||
| + | ; ** T H E N E T W O R K R O U T I N E S ** | ||
| + | ; *********************************************** | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0DA9:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0DAF:  | ||
| + |         LD      A, | ||
| + | AND A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0D             ; Reading a ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0DBB:  | ||
| + | AND A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      E, | ||
| + | DEC A | ||
| + | SUB E | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | LD D,$00 | ||
| + | INC E | ||
| + |         LD      (IX+$13), | ||
| + |         ADD      | ||
| + |         LD      A, | ||
| + | SCF | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0DD5:  | ||
| + | AND A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0DDC:  | ||
| + |         OUT      | ||
| + | DI | ||
| + | |||
| + | <a name=" | ||
| + | L0DE2:  | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | EI | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      (IX+$13), | ||
| + |         LD      A, | ||
| + |         LD      (IX+$0F), | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0DFC:  | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | EI ; | ||
| + |         CALL    <A href="# | ||
| + |         AND      | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0E09:  | ||
| + | LD B,A | ||
| + |         LD      A, | ||
| + | AND A | ||
| + | LD A,B | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0C             ; Writing to a ' | ||
| + | |||
| + | <a name=" | ||
| + | L0E17:  | ||
| + |         INC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH AF ; | ||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + | LD E,$01 ; | ||
| + | |||
| + | <a name=" | ||
| + | L0E25:  | ||
| + | LD D,$00 ; | ||
| + |         ADD      | ||
| + |         LD      (IX+$14), | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ----------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0E30:  | ||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         RET      | ||
| + | |||
| + |         LD      HL, | ||
| + |         LD      (HL), | ||
| + | LD E,$01 ; | ||
| + |         CALL    <A href="# | ||
| + |         RET      | ||
| + | |||
| + |         LD      A, | ||
| + |         DEC      | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0E48:  | ||
| + |         RET      | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ----------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------- | ||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L0E4F:  | ||
| + |         LD      B, | ||
| + |         LD      A, | ||
| + |         OUT      | ||
| + | |||
| + | PUSH IX ; | ||
| + |         POP      | ||
| + | |||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + |         XOR      | ||
| + | |||
| + | <a name=" | ||
| + | L0E62:  | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         LD      (IX+$11), | ||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + | PUSH HL ; | ||
| + | LD B,$07 ; | ||
| + |         XOR      | ||
| + | |||
| + | <a name=" | ||
| + | L0E71:  | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         LD      (HL), | ||
| + | DI ; | ||
| + | |||
| + | <a name=" | ||
| + | L0E77:  | ||
| + |         POP      | ||
| + | PUSH HL ; | ||
| + | LD E,$08 ; | ||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH IX ; | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      E, | ||
| + | LD A,E ; | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | LD B,$20 ; | ||
| + | |||
| + | <a name=" | ||
| + | L0E93:  | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0E9A:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + | |||
| + | <a name=" | ||
| + | L0EA2:  | ||
| + |         CALL    <A href="# | ||
| + | EI ; | ||
| + |         LD      A, | ||
| + |         AND      | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0EAC:  | ||
| + | |||
| + | <a name=" | ||
| + | L0EAF:  | ||
| + | LD A,E ; | ||
| + | OR D ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; --------------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0EB5:  | ||
| + | LD E,$08 | ||
| + |         CALL    <A href="# | ||
| + | RET NZ | ||
| + | |||
| + |         LD      HL, | ||
| + | XOR A | ||
| + | LD B,$07 | ||
| + | |||
| + | <a name=" | ||
| + | L0EC4:  | ||
| + | INC HL | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | CP (HL) | ||
| + | RET NZ | ||
| + | |||
| + |         LD      A, | ||
| + | AND A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      (IX+$0C)  | ||
| + | RET NZ | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      (IX+$0B)  | ||
| + | RET NZ | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L0EDD:  | ||
| + | OR A | ||
| + | RET NZ | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0EE2:  | ||
| + |         LD      E, | ||
| + |         LD      D, | ||
| + | AND A | ||
| + |         SBC      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | DEC HL | ||
| + | LD A,H | ||
| + | OR L | ||
| + | RET NZ | ||
| + | |||
| + | ;   < | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | ;   < | ||
| + | |||
| + |         DEC      | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         DEC      | ||
| + | |||
| + | <a name=" | ||
| + | L0EFF:  | ||
| + | RET | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0F02:  | ||
| + | OR A | ||
| + |         CALL    NZ,<A href="# | ||
| + |         LD      A, | ||
| + | AND A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | PUSH IX | ||
| + | POP HL | ||
| + | |||
| + | LD DE,$0015 | ||
| + |         ADD      | ||
| + | PUSH HL | ||
| + | LD E,A | ||
| + |         CALL    <A href="# | ||
| + | POP HL | ||
| + | RET NZ | ||
| + | |||
| + |         LD      A, | ||
| + | LD B,A | ||
| + |         LD      A, | ||
| + | |||
| + | <a name=" | ||
| + | L0F24:  | ||
| + | INC HL | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | RET NZ | ||
| + | |||
| + |         LD      A, | ||
| + | AND A | ||
| + |         CALL    NZ,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L0F30:  | ||
| + |         LD      (IX+$14), | ||
| + |         INC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + | |||
| + | <a name=" | ||
| + | L0F3E:  | ||
| + | RET | ||
| + | |||
| + | |||
| + | ; -------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0F40:  | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; <font color=# | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0F46:  | ||
| + |         LD      IX, | ||
| + |         SET      | ||
| + | RET | ||
| + | |||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0F52:  | ||
| + | DEC HL | ||
| + | |||
| + | LD BC,$0114 | ||
| + | PUSH BC | ||
| + | PUSH HL | ||
| + | PUSH BC | ||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + |         JP      C,<A href="# | ||
| + | |||
| + | LD BC,$0050 | ||
| + |         ADD      | ||
| + |         JP      C,<A href="# | ||
| + | |||
| + |         SBC      | ||
| + |         JP      NC,<A href="# | ||
| + | |||
| + | POP BC | ||
| + | POP HL | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1655 ; main MAKE-ROOM | ||
| + | |||
| + | INC HL | ||
| + | POP BC | ||
| + |         CALL    <A href="# | ||
| + |         LD      ($5C51), | ||
| + | |||
| + | EX DE,HL ; | ||
| + |         LD      HL,<A href="# | ||
| + |         LD      BC, | ||
| + | LDIR ; | ||
| + | |||
| + |         LD      A, | ||
| + | LD (DE),A | ||
| + | INC DE | ||
| + |         LD      A, | ||
| + | LD (DE),A | ||
| + | INC DE | ||
| + | XOR A | ||
| + | LD (DE),A | ||
| + | LD H,D | ||
| + | LD L,E | ||
| + | INC DE | ||
| + | LD BC,$0106 | ||
| + | LDIR | ||
| + |         LD      DE, | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0F9E:  | ||
| + |         RST      | ||
| + | |||
| + | |||
| + | ; ------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0FA3:  | ||
| + | DEFW $0008 ; main ERROR-1 | ||
| + |         DEFB    $4E             ; character " | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + | DEFW $0114 ; length | ||
| + | |||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0FAE:  | ||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         RET      | ||
| + | |||
| + | LD A,$01 ; | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0FBC:  | ||
| + | OR $C0 ; | ||
| + | LD B,A ; | ||
| + |         CALL    <A href="# | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0FC7:  | ||
| + | |||
| + | <a name=" | ||
| + | L0FCA:  | ||
| + |         POP      | ||
| + |         IN      A, | ||
| + | RRCA ; | ||
| + |         RET      | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L0FD3:  | ||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L0FD9:  | ||
| + |         CALL    <A href="# | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         DEC      | ||
| + |         DEC      | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | RET ; | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L0FED:  | ||
| + | RRCA ; | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | LD A,$7F ; | ||
| + |         IN      A, | ||
| + | OR $FE ; | ||
| + |         IN      A, | ||
| + | RRA ; | ||
| + |         CALL    NC,<A href="# | ||
| + |         DEC      | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; -------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------- | ||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L100A:  | ||
| + |         CALL    <A href="# | ||
| + |         LD      (IY+$00), | ||
| + |         RST      | ||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1013:  | ||
| + | |||
| + | <a name=" | ||
| + | L1015:  | ||
| + | SCF | ||
| + | RET Z | ||
| + | |||
| + | LD B,$0E | ||
| + | |||
| + | <a name=" | ||
| + | L101A:  | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; ------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L101E:  | ||
| + | LD C,$F7 | ||
| + | LD HL,$0009 | ||
| + |         LD      A, | ||
| + | LD E,A | ||
| + | IN A,($F7) | ||
| + | RRCA | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L102F:  | ||
| + | LD D,H | ||
| + | LD H,$00 | ||
| + | RLC E | ||
| + | RL H | ||
| + | |||
| + | |||
| + | LD B,$08 | ||
| + | |||
| + | <a name=" | ||
| + | L103A:  | ||
| + | |||
| + | IN A,($F7) | ||
| + | AND $01 | ||
| + | CP D | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | DEC L | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD A,$01 | ||
| + |         OUT      | ||
| + | LD B,$0E | ||
| + | |||
| + | <a name=" | ||
| + | L104C:  | ||
| + | |||
| + | RET | ||
| + | |||
| + | |||
| + | ; ------------------- | ||
| + | ; THE < | ||
| + | ; ------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L104F:  | ||
| + | |||
| + | <a name=" | ||
| + | L1051:  | ||
| + | RRA | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | INC B | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L105A:  | ||
| + | |||
| + | <a name=" | ||
| + | L105B:  | ||
| + | LD A,$CE | ||
| + |         OUT      | ||
| + | NOP | ||
| + | NOP | ||
| + | INC IX | ||
| + | DEC IX | ||
| + | INC IX | ||
| + | DEC IX | ||
| + | |||
| + | <a name=" | ||
| + | L106B:  | ||
| + | IN A,($F7) | ||
| + | RRA | ||
| + | RR E | ||
| + |         JP      NC,<A href="# | ||
| + | LD (HL),E | ||
| + | INC HL | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | CP A | ||
| + | RET | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L107B:  | ||
| + |         LD      HL, | ||
| + | LD (HL),A | ||
| + | LD E,A | ||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1082:  | ||
| + |         OUT      | ||
| + | LD B,$04 | ||
| + | |||
| + | <a name=" | ||
| + | L1087:  | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1089:  | ||
| + | CPL | ||
| + | SCF | ||
| + | RLA | ||
| + | LD B,$0A | ||
| + | |||
| + | <a name=" | ||
| + | L108F:  | ||
| + | RRA | ||
| + | AND A | ||
| + | DEC B | ||
| + | LD D,$00 | ||
| + |         JP      NZ,<A href="# | ||
| + | INC HL | ||
| + | DEC E | ||
| + | PUSH HL | ||
| + | POP HL | ||
| + |         JP      NZ,<A href="# | ||
| + | LD A,$01 | ||
| + |         OUT      | ||
| + | RET | ||
| + | |||
| + | ; ***************************************************** | ||
| + | ; ** T H E M I C R O D R I V E R O U T I N E S ** | ||
| + | ; ***************************************************** | ||
| + | ; The shadow ROM uses the alternate HL register solely in connection with the | ||
| + | ; microdrive maps. This does not conflict with the Main ROM use in the | ||
| + | ; calculator.  | ||
| + | ; use by the user and so HL' should be preserved throughout. | ||
| + | |||
| + | ; ----------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------- | ||
| + | ; <font color=# | ||
| + | ; This routine is used to create all microdrive channels. The routine that | ||
| + | ; creates a permanent channel (as used by a print file) uses this routine and | ||
| + | ; then converts the temporary channel to a permanent one. | ||
| + | ; Temporary channels are created by LOAD, SAVE, CAT etc. and last just as long | ||
| + | ; as required. They are deleted before returning to the Main ROM by the next | ||
| + | ; routine DEL-M-BUF. | ||
| + | |||
| + | <a name=" | ||
| + | L10A5:  | ||
| + |         LD      HL, | ||
| + | ; condition. | ||
| + | EXX ; exx | ||
| + | |||
| + |         LD      IX, | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | ; now enter a search of existing " | ||
| + | |||
| + | <a name=" | ||
| + | L10B3:  | ||
| + | CP $80 ; compare to end-marker. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         CP      $4D             ; is it character ' | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; an existing Microdrive Channel has been found. | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      (IX+$19)  | ||
| + | ; this channel. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; a Microdrive Channel has been found that matches the current drive. | ||
| + | ; It will not be necessary to create a new map for the temporary channel. | ||
| + | |||
| + | EXX ; - | ||
| + |         LD      L, | ||
| + |         LD      H, | ||
| + | EXX ; - | ||
| + | |||
| + |         LD      BC, | ||
| + |         LD      HL, | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; against name addressed by HL. | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0D             ; Reading a ' | ||
| + | |||
| + | <a name=" | ||
| + | L10E7:  | ||
| + |         LD      D, | ||
| + |         ADD      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; Now create the space for the channel. | ||
| + | |||
| + | <a name=" | ||
| + | L10F1:  | ||
| + |         DEC      | ||
| + | |||
| + | PUSH HL ; * save a copy of new location. | ||
| + |         LD      BC, | ||
| + | |||
| + | ;   < | ||
| + | ;    | ||
| + | ;    | ||
| + | ; The solution here is to perform the same checks that will be performed by | ||
| + | ; the Main MAKE-ROOM routine. | ||
| + | |||
| + | PUSH HL ; save first location | ||
| + | PUSH BC ; and amount while free memory is checked. | ||
| + | |||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + | ; result is higher than 65535 | ||
| + |         JP      C,<A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         ADD      | ||
| + |         JP      C,<A href="# | ||
| + | |||
| + |         SBC      | ||
| + | ; stack pointer at the other side of free memory. | ||
| + |         JP      NC,<A href="# | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | ; now call the MAKE-ROOM routine in the certain knowledge that nothing can | ||
| + | ; go wrong. | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1655 ; main MAKE-ROOM | ||
| + | |||
| + |         POP      | ||
| + | PUSH DE ; * and save on machine stack again. | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + |         LD      BC, | ||
| + | LDIR ; filename to start of new channel. | ||
| + | |||
| + |         LD      A, | ||
| + |         LD      (IX+$19), | ||
| + | |||
| + |         LD      BC, | ||
| + | |||
| + | PUSH IX ; move start of channel | ||
| + |         POP      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; leaving DE at first filename D_STR1. | ||
| + | |||
| + | EX DE,HL ; transfer filename pointer to HL. | ||
| + | |||
| + |         LD      BC, | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; now enter a loop to transfer the filename to CHNAME, counting BC down to zero. | ||
| + | ; The filename could be in ROM with < | ||
| + | ; with its parameters on the calculator stack as with | ||
| + | ; LOAD * " | ||
| + | ; SAVE * " | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1135:  | ||
| + | OR C ; for zero. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         LD      (IX+$0E), | ||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         DEC      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1143:  | ||
| + | |||
| + | EXX ; exchange set - no need now to keep balanced. | ||
| + | LD A,H ; test map address for zero . | ||
| + | OR L ; indicating that this drive has no map. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; a microdrive map is now created for this drive. | ||
| + | |||
| + |         LD      HL, | ||
| + | PUSH HL ; save this pointer to the new area. | ||
| + |         DEC      | ||
| + |         LD      BC, | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1655 ; main MAKE-ROOM. | ||
| + | |||
| + | ; now handle dynamic pointers outside the control of the Main ROM | ||
| + | |||
| + |         POP      | ||
| + |         LD      BC, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | ; fill map with $FF bytes | ||
| + | |||
| + | LD A,$FF ; the fill byte. | ||
| + | LD B,$20 ; thirty two locations. | ||
| + | PUSH HL ; save map address pointer. | ||
| + | |||
| + | <a name=" | ||
| + | L1163:  | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | <a name=" | ||
| + | L1168:  | ||
| + |         LD      (IX+$1B), | ||
| + | |||
| + | ; now make DE point to IX+$19 the header preamble and copy ROM preamble bytes. | ||
| + | |||
| + | PUSH IX ; push start of channel | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | EX DE,HL ; transfer this destination to DE. | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + |         LD      BC, | ||
| + | LDIR ; in they go. | ||
| + | |||
| + | ; now use the same technique to copy the same 12 bytes of ROM preamble | ||
| + | ; to IX+$37, the data block preamble in the channel. | ||
| + | ; A little long-winded as the destination only requires adjustment. | ||
| + | |||
| + | PUSH IX ; | ||
| + |         POP      | ||
| + |         LD      DE, | ||
| + |         LD      BC, | ||
| + | |||
| + |         ADD      | ||
| + | EX DE,HL ; | ||
| + |         LD      HL,<A href="# | ||
| + | LDIR ; | ||
| + | |||
| + | ; now form the offset from CHANS to this channel for a return value to be | ||
| + | ; inserted in the STRMS area. | ||
| + | |||
| + | PUSH IX ; transfer | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + | OR A ; clear carry for subtraction. | ||
| + |         SBC      | ||
| + | |||
| + |         INC      | ||
| + | |||
| + |         RET                     ; return.  | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L119A:  | ||
| + |         RST      | ||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; <font color=# | ||
| + | ; This routine is used to reclaim a temporary " | ||
| + | ; by the routine above and to reclaim a permanent " | ||
| + | ; command routines. | ||
| + | |||
| + | <a name=" | ||
| + | L119F:  | ||
| + |         LD      H, | ||
| + | PUSH HL ; and save. | ||
| + |         LD      A, | ||
| + | PUSH AF ; and save also. | ||
| + | |||
| + | PUSH IX ; transfer channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      BC, | ||
| + | |||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2 reclaims the channel. | ||
| + | |||
| + | PUSH IX ; transfer channel | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + | OR A ; clear carry. | ||
| + |         SBC      | ||
| + |         INC      | ||
| + | |||
| + |         LD      BC, | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; in the standard systems variables area | ||
| + | ; reducing them if they followed the deleted | ||
| + | ; channel. | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | ; now consider deleting the map if it was used only by the reclaimed channel. | ||
| + | |||
| + | LD B,A ; transfer drive to B | ||
| + |         LD      IX, | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | <a name=" | ||
| + | L11D0:  | ||
| + | CP $80 ; compare to end-marker. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         CP      $4D             ; is character " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | CP B ; compare to that of deleted channel. | ||
| + |         RET      | ||
| + |                                 ; still in use.                              & | ||
| + | |||
| + | ; else continue search. | ||
| + | |||
| + | <a name=" | ||
| + | L11E5:  | ||
| + |         LD      D, | ||
| + |         ADD      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; the branch was here when the end-marker was encountered without finding a | ||
| + | ; channel that uses the map. | ||
| + | |||
| + | <a name=" | ||
| + | L11EF:  | ||
| + | PUSH HL ; save pointer to start. | ||
| + | PUSH BC ; save the 32 bytes. | ||
| + | |||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2 reclaims the microdrive map. | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; addresses. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L11FD:  | ||
| + |         LD      HL,<A href="# | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1207:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L120D:  | ||
| + |         DEFB    $0D             ; Reading a ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L120F:  | ||
| + |         LD      D, | ||
| + | |||
| + |         LD      L, | ||
| + |         LD      H, | ||
| + | |||
| + | SCF ; set carry to include | ||
| + |         SBC      | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         LD      (IX+$0B), | ||
| + |         LD      (IX+$0C), | ||
| + |         DEC      | ||
| + | |||
| + | PUSH IX ; save start of channel. | ||
| + |         ADD      | ||
| + |         LD      A, | ||
| + | ; channel to character. | ||
| + |         POP      | ||
| + | SCF ; set carry flag. | ||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1233:  | ||
| + | ; record in this file. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         XOR      | ||
| + |         ADD      | ||
| + | ; carry flag and resetting the zero flag. | ||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L123D:  | ||
| + |         LD      (IX+$0B), | ||
| + |         LD      (IX+$0C), | ||
| + | |||
| + |         INC      | ||
| + |         CALL    <A href="# | ||
| + | ; by CHREQ matching filename CHNAME from the | ||
| + | ; cartridge in the drive CHDRIV which is | ||
| + | ; started. | ||
| + | |||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; -------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------- | ||
| + | ; This routine is used to read a specific record from a PRINT type file. | ||
| + | ; It is called twice - | ||
| + | ;   1) From the " | ||
| + | ; next record is to be read in. | ||
| + | ; 2) From Hook Code $27 READ-RANDOM. | ||
| + | |||
| + | <a name=" | ||
| + | L1252:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | ; -> | ||
| + | |||
| + | <a name=" | ||
| + | L1258:  | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | <a name=" | ||
| + | L125F:  | ||
| + | ; matching record to pass the tape head. | ||
| + | |||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      (IX+$0D)  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH IX ; transfer address of Microdrive channel | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         CALL    <A href="# | ||
| + |         RET      | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1279:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; else produce the Error Report. | ||
| + | |||
| + |         RST      | ||
| + | DEFB $11 ; File not found | ||
| + | |||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; This routine fetches at random a header and matching record and sets the | ||
| + | ; flags to indicate three possible outcomes. | ||
| + | ; | ||
| + | ; Zero flag set - record is not in use. | ||
| + | ; Carry flag set - name does not match required | ||
| + | ; Both flags reset - the name matches required. | ||
| + | |||
| + | <a name=" | ||
| + | L1280:  | ||
| + | ; the next 14 byte header to pass tape heads. | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; descriptor and data. | ||
| + | ; register HL addresses RECFLG | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; of the record descriptor. | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; now test descriptor for an unused record. | ||
| + | |||
| + |         LD      A, | ||
| + |         OR      (IX+$46)  | ||
| + |         AND      | ||
| + |         RET      | ||
| + | ; signaling that record is unused. | ||
| + | |||
| + | ; the record is a contender for a header record. | ||
| + | |||
| + | PUSH IX ; transfer start of channel | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      BC, | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; else set flags to signal success before returning. | ||
| + | |||
| + | LD A,$FF ; prepare to reset zero flag | ||
| + | OR A ; also reset carry | ||
| + | RET ; return with zero reset and carry reset. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; else set carry to signal names do not match. | ||
| + | |||
| + | <a name=" | ||
| + | L12B1:  | ||
| + | ; instigate another search. | ||
| + | RET ; return with zero reset and carry set. | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; labeled MWRCH in source code. | ||
| + | |||
| + | <a name=" | ||
| + | L12B3:  | ||
| + |         ADD      | ||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0C             ; Writing to a ' | ||
| + | |||
| + | <a name=" | ||
| + | L12C1:  | ||
| + | |||
| + | |||
| + |         LD      D, | ||
| + | PUSH IX | ||
| + |         ADD      | ||
| + |         LD      (IX+$52), | ||
| + | POP IX | ||
| + | INC DE | ||
| + |         LD      (IX+$0B), | ||
| + |         LD      (IX+$0C), | ||
| + |         BIT      | ||
| + |         RET      | ||
| + | |||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ; <font color=# | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L12DA:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; ----------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------- | ||
| + | ; | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L12EE:  | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0F             ; ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L12FC:  | ||
| + | LD B,$0A ; count ten characters. | ||
| + | |||
| + | <a name=" | ||
| + | L1300:  | ||
| + |         LD      (IX+$47), | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         LD      C, | ||
| + |         LD      (IX+$45), | ||
| + | |||
| + |         LD      A, | ||
| + |         LD      (IX+$46), | ||
| + | |||
| + |         LD      A, | ||
| + |         LD      (IX+$44), | ||
| + | |||
| + |         RES      | ||
| + | |||
| + | PUSH IX ; transfer channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         PUSH    IX              ; <font color=# | ||
| + |         POP      | ||
| + |         LD      DE, | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; cartridge as indicated my microdrive map | ||
| + | ; which is updated. | ||
| + | |||
| + | ; now prepare channel for next record. accumulator could be used to set CHBYTE. | ||
| + | |||
| + |         LD      DE, | ||
| + |         LD      (IX+$0B), | ||
| + |         LD      (IX+$0C), | ||
| + |         INC      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; Check the thirty two bytes of a microdrive map for a reset bit. | ||
| + | |||
| + | <a name=" | ||
| + | L1349:  | ||
| + |         LD      H, | ||
| + | LD B,$20 ; set counter to thirty two. | ||
| + | |||
| + | <a name=" | ||
| + | L1351:  | ||
| + | CP $FF ; compare to the all-full indicator. | ||
| + |         RET      | ||
| + | |||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         XOR      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; This important routine is called from the FORMAT routine and the WRITE-PRC | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L135A:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | PUSH HL ; save pointer to data block | ||
| + | |||
| + | ; now enter a loop to find the header of an available record on microdrive. | ||
| + | ; This SEND-BLK routine is only called when there is known to be a record | ||
| + | ; available on the tape. | ||
| + | |||
| + | <a name=" | ||
| + | L1362:  | ||
| + |         CALL    <A href="# | ||
| + | ; on the microdrive map. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; A usable sector has been found on the drive. HL addresses byte within map. | ||
| + | |||
| + |         EX      (SP), | ||
| + | PUSH BC ; preserve B the map byte mask. | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; Drive ' | ||
| + | |||
| + | <a name=" | ||
| + | L1374:  | ||
| + |         OUT      | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | ; record now approaches the tape heads. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; data buffer. | ||
| + | |||
| + |         LD      A,$EE           ;  | ||
| + |         OUT      | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | ; map. | ||
| + | LD A,B ; transfer masked bit to A. | ||
| + | OR (HL) ; combine with status of other 7 sectors. | ||
| + |         LD      (HL), | ||
| + | ; used. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------ | ||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L138B:  | ||
| + |         POP      | ||
| + | |||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L138E:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         SET      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L139B:  | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + | RET ; return after subroutine. | ||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | |||
| + | <a name=" | ||
| + | L13A3:  | ||
| + |         LD      A, | ||
| + |         LD      ($5C3A), | ||
| + |         RST      | ||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ; This routine fetches the next valid 14-byte header to pass the tape heads | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L13A9:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; microdrive - last is a checksum byte. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | RET ; return - with HL addressing start of header. | ||
| + | |||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L13BF:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L13C4:  | ||
| + | |||
| + | ; -> | ||
| + | |||
| + | <a name=" | ||
| + | L13C7:  | ||
| + |         LD      H, | ||
| + | |||
| + | ; the pseudo-map routine enters here with a temporary map address. | ||
| + | |||
| + | <a name=" | ||
| + | L13CD:  | ||
| + | LD D,A ; clear D in preparation for addition. | ||
| + | LD A,E ; transfer sector to A. | ||
| + |         AND      | ||
| + | |||
| + |         SRL      | ||
| + |         SRL      | ||
| + |         SRL      | ||
| + |         ADD      | ||
| + | LD B,A ; now load sector mod 8 to B and | ||
| + |         INC      | ||
| + | |||
| + |         XOR      | ||
| + | SCF ; and set carry bit ready to rotate in. | ||
| + | |||
| + | <a name=" | ||
| + | L13DD:  | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD B,A ; return sector bit in B. | ||
| + |         AND      | ||
| + | RET ; return - Z = free, NZ = occupied. | ||
| + | |||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; This routine is called when opening a channel and by FORMAT, CAT and ERASE | ||
| + | ; to mark a map bit representing a sector as available. | ||
| + | |||
| + | <a name=" | ||
| + | L13E3:  | ||
| + | ; location addressed by HL into B register. | ||
| + | |||
| + | LD A,B ; fetch sector mask with one bit set. | ||
| + | CPL ; complement - seven bits set and one bit reset. | ||
| + |         AND      | ||
| + |         LD      (HL), | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L13EB:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      E, | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; ------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L13F7:  | ||
| + |         DEC      | ||
| + |         LD      ($5CC9), | ||
| + | LD A,B ; | ||
| + | OR C ; | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1403:  | ||
| + | |||
| + | LD B,$0A ; | ||
| + | |||
| + | <a name=" | ||
| + | L1407:  | ||
| + |         CP      (IX+$0E)  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         DEC      | ||
| + |         DEC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD A,B ; | ||
| + | OR A ; | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1418:  | ||
| + | CP $20 ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1423:  | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ----------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------- | ||
| + | ; Used for microdrive channels only. | ||
| + | ; While the two checksums within a Network buffer are simple 8-bit sums of | ||
| + | ; the data, the algorithm used for the microdrive channels is a little more | ||
| + | ; sophisticated as it avoids the formation of the result $FF. While across the | ||
| + | ; network a byte is as good as its neighbour, with microdrives the value $FF | ||
| + | ; might arise as a result of a failed read. | ||
| + | ; The same routine is used both to prepare the checksum prior to saving and to | ||
| + | ; calculate and compare the checksum after reading. | ||
| + | ; The first entry point is used for the 14 bytes of HDCHK and DESCHK | ||
| + | ; and the second entry point is used for the 512 bytes of DCHK. | ||
| + | |||
| + | <a name=" | ||
| + | L1426:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | ; -> | ||
| + | |||
| + | <a name=" | ||
| + | L142B:  | ||
| + | |||
| + | ; common code. | ||
| + | |||
| + | <a name=" | ||
| + | L142E:  | ||
| + | LD E,$00 ; initialize checksum to zero | ||
| + | |||
| + | <a name=" | ||
| + | L1431:  | ||
| + |         ADD      | ||
| + |         INC      | ||
| + | |||
| + | |||
| + |         ADC      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         DEC      | ||
| + | |||
| + | <a name=" | ||
| + | L1439:  | ||
| + | |||
| + |         DEC      | ||
| + | LD A,B ; and check | ||
| + | OR C ; for zero. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD A,E ; fetch running sum | ||
| + | CP (HL) ; compare to checksum contents | ||
| + |         LD      (HL), | ||
| + | |||
| + |         POP      | ||
| + | RET ; return - with zero flag set if sums agree. | ||
| + | |||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; When a channel is deleted, then the streams that point to channels beyond | ||
| + | ; that one have to have their offsets reduced by the deleted amount. | ||
| + | ; Also a stream that exactly matches the offset to the deleted channel, and | ||
| + | ; there could be several, will have its entry set to zero. | ||
| + | ; On entry, HL = offset, BC = $0253 | ||
| + | |||
| + | <a name=" | ||
| + | L1444:  | ||
| + | LD A,$10 ; maximum streams + 1 | ||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L144A:  | ||
| + | |||
| + |         LD      E, | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + | |||
| + |         POP      | ||
| + | PUSH HL ; supplied offset. | ||
| + | |||
| + | OR A ; clear carry. | ||
| + |         SBC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      DE, | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L145C:  | ||
| + | |||
| + | ; else this stream entry is to be reduced by $0253 bytes. | ||
| + | |||
| + | EX DE,HL ; streams offset to HL | ||
| + | OR A ; clear carry | ||
| + |         SBC      | ||
| + | EX DE,HL ; transfer reduced entry to DE. | ||
| + | |||
| + | <a name=" | ||
| + | L1463:  | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + | |||
| + | ; -> | ||
| + | |||
| + | <a name=" | ||
| + | L1469:  | ||
| + |         INC      | ||
| + |         INC      | ||
| + |         DEC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; else clean up and return. | ||
| + | |||
| + |         LD      ($5C5F), | ||
| + |         POP      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; When a microdrive map is reclaimed, then all the addresses of the microdrive | ||
| + | ; maps in the " | ||
| + | ; address is reduced by thirty two bytes. | ||
| + | ; On entry, HL = map address, BC = $0020. | ||
| + | |||
| + | <a name=" | ||
| + | L1476:  | ||
| + |         LD      IX, | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | ; now enter a loop. | ||
| + | |||
| + | <a name=" | ||
| + | L1482:  | ||
| + | CP $80 ; is it the channels area end-marker ? | ||
| + |         RET      | ||
| + | |||
| + | PUSH HL ; save map address. | ||
| + |         LD      A, | ||
| + |         AND      | ||
| + |         CP      $4D             ; compare to " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; a microdrive channel has been found so compare the address of the map. | ||
| + | |||
| + |         LD      E, | ||
| + |         LD      D, | ||
| + |         SBC      | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | ; address of this microdrive map is higher than the one deleted. | ||
| + | |||
| + | EX DE,HL ; transfer address to HL. | ||
| + | OR A ; clear carry. | ||
| + |         SBC      | ||
| + |         LD      (IX+$1A), | ||
| + |         LD      (IX+$1B), | ||
| + | |||
| + | <a name=" | ||
| + | L14A6:  | ||
| + |         LD      E, | ||
| + |         LD      D, | ||
| + |         ADD      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; ------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L14B1:  | ||
| + | DEFW $0008 ; main ERROR-1 | ||
| + |         DEFB    $CD             ; inverted " | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + | DEFW $0253 ; length | ||
| + | DEFW $0000 ; | ||
| + | DEFB $00 ; | ||
| + |         DEFM    "  | ||
| + | DEFB $FF ; CHFLAG | ||
| + | |||
| + | ; ------------------- | ||
| + | ; THE < | ||
| + | ; ------------------- | ||
| + | ; The PREAMBLE consists of twelve distinctive bytes that are saved to a | ||
| + | ;    | ||
| + | ; the ULA of the microdrive to recognize the start of a saved data block. | ||
| + | |||
| + | <a name=" | ||
| + | L14CA:  | ||
| + | DEFB $00, $00, $00 | ||
| + | DEFB $00, $00, $00 | ||
| + | DEFB $00, $FF, $FF | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; The following four routines are for debugging | ||
| + | ; purposes during development. | ||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L14D6:  | ||
| + | RRA ; | ||
| + | RRA ; | ||
| + | RRA ; | ||
| + | RRA ; | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + | |||
| + | <a name=" | ||
| + | L14DF:  | ||
| + | |||
| + | CP $0A ; | ||
| + | |||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         ADD      | ||
| + | |||
| + | <a name=" | ||
| + | L14E7:  | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ----------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------- | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L14ED:  | ||
| + |         CALL    <A href="# | ||
| + | LD A,$20 ; | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; --------------------- | ||
| + | ; THE < | ||
| + | ; --------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L14F8:  | ||
| + | PUSH DE ; | ||
| + | PUSH BC ; | ||
| + | PUSH AF ; | ||
| + | EXX ; | ||
| + | PUSH HL ; | ||
| + | PUSH DE ; | ||
| + | PUSH BC ; | ||
| + | PUSH AF ; | ||
| + |         LD      HL, | ||
| + | PUSH HL ; | ||
| + | PUSH AF ; | ||
| + | LD A,$02 ; | ||
| + |         RST      | ||
| + | DEFW $1601 ; main CHAN-OPEN | ||
| + |         POP      | ||
| + |         RST      | ||
| + | DEFW $0010 ; main PRINT-A | ||
| + | |||
| + | |||
| + |         POP      | ||
| + |         LD      ($5C51), | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + | EXX ; | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; The Master routine which displays ten bytes of memory, addressed by HL, | ||
| + | ; in Hexadecimal followed by a CR. The thirty output characters sit | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L151D:  | ||
| + | PUSH BC ; | ||
| + | PUSH AF ; | ||
| + | LD B,$0A ; | ||
| + | |||
| + | <a name=" | ||
| + | L1522:  | ||
| + |         CALL    <A href="# | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD A,$0D ; | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; <font color=# | ||
| + | ; This important routine is called on over twenty occasions to activate a | ||
| + | ;    | ||
| + | ;   zero, to stop all motors.  | ||
| + | ; or virtual bank of eight microdrives. | ||
| + | ; It is called with interrupts disabled and this condition should be in | ||
| + | ; force when the Hook Code is used. | ||
| + | |||
| + | <a name=" | ||
| + | L1532:  | ||
| + | |||
| + | CP $00 ; is the parameter zero ? | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; The requirement is to ensure that all eight drives are switched off. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | EI ; Enable Interrupts. | ||
| + | |||
| + |         POP      | ||
| + |         RET                     ; return.  | ||
| + | |||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ; This route turns on a drive in the range 1 - 8. If the Hook Code has | ||
| + | ; been erroneously invoked with a higher value, then this will be treated | ||
| + | ; in much the same way as with zero. See later. | ||
| + | |||
| + | <a name=" | ||
| + | L153D:  | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L1544:  | ||
| + | LD A,H ; delay loop to | ||
| + | OR L ; let things settle down. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | |||
| + | ; Now enter another 5000 loop testing for break and searching for a GAP on | ||
| + | ; the tape at each iteration. | ||
| + | |||
| + | <a name=" | ||
| + | L154C:  | ||
| + | ; as a gap. | ||
| + | |||
| + | <a name=" | ||
| + | L154E:  | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | ; A gap has been found - a formatted cartridge is in the drive. | ||
| + | |||
| + |         POP      | ||
| + | RET ; return with motor running, interrupts | ||
| + |                                 ; disabled.  | ||
| + | |||
| + | ; ------------------- | ||
| + | ; THE < | ||
| + | ; ------------------- | ||
| + | ; If no gap signal found on drive so far then continue counting down from | ||
| + | ; 5000 and looping back to test for six gaps. | ||
| + | |||
| + | <a name=" | ||
| + | L155B:  | ||
| + | LD A,H ; test for | ||
| + | OR L ; zero. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; stops the drive motor. | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $10             ; ' | ||
| + | |||
| + | ; ----------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------- | ||
| + | ; The main developer of the microdrives and acknowledged co-inventor was | ||
| + | ; the late Ben Cheese, 14-Jul-1954 - 15-Jan-2001. | ||
| + | ; | ||
| + | ; This ROM software always handles the switching of microdrives as if | ||
| + | ;   there were eight drives connected.  | ||
| + | ;    | ||
| + | ; Each microdrive includes a D-flip flop, capable of holding logic state | ||
| + | ; one or zero. When the flip-flop is set at logic one then the | ||
| + | ;    | ||
| + | ; | ||
| + | ; The first microdrive has the D-input terminal of the flip-flop connected | ||
| + | ; to the comms data line of the Interface 1 and the clock-input terminal | ||
| + | ;    | ||
| + | ;    | ||
| + | ;   of the next innermost drive/ | ||
| + | ;    | ||
| + | ;    | ||
| + | ; | ||
| + | ; The eight microdrives thus behave as a shift register allowing a logic 1 | ||
| + | ;    | ||
| + | ; into the first flip-flop by a single clock pulse and to be shifted out | ||
| + | ; to the appropriate flip-flop by a series of further clock pulses. | ||
| + | ; | ||
| + | ; As eight pulses will be required, then the logic state of drive eight is | ||
| + | ;    | ||
| + | ; | ||
| + | ; By negating the drive number and adding nine, the routine below begins | ||
| + | ; by effecting this reversal and, by converting zero to nine, it ensures | ||
| + | ; that eight logic zeros are shifted out for this case and for the case | ||
| + | ; of any out-of-range parameter, which can arise in the case of a User | ||
| + | ;    | ||
| + | ; The limit of eight microdrives is set in the routine below and not in | ||
| + | ;    | ||
| + | ; | ||
| + | ; As Ben pointed out on his patent from which some of these details are | ||
| + | ;    | ||
| + | ;    | ||
| + | ; any number of associated devices may be accommodated by use of the | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1565:  | ||
| + | |||
| + |         LD      DE, | ||
| + | ; logic zero. | ||
| + | |||
| + | NEG ; negate the supplied drive number 0 - n | ||
| + |         ADD      | ||
| + | LD C,A ; place the reversed parameter in C. | ||
| + | LD B,$08 ; set clock shift counter to eight. | ||
| + | |||
| + | <a name=" | ||
| + | L1570:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; The time has come to send out a signal to start this drive. | ||
| + | |||
| + | LD A,D ; select logic one. | ||
| + |         OUT      | ||
| + | |||
| + | LD A,$EE ; select comms clock 1, comms data 0 | ||
| + |         OUT      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | LD A,$EC ; select comms clock 0, comms data 0 | ||
| + |         OUT      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1586:  | ||
| + |         OUT      | ||
| + | |||
| + | LD A,E ; select logic 0. | ||
| + |         OUT      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | LD A,$ED ; select comms clock 0, comms data 1 | ||
| + |         OUT      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L1597:  | ||
| + | |||
| + | LD A,D ; select logic one. | ||
| + |         OUT      | ||
| + | LD A,$EE ; select comms clock 1, comms data 0. | ||
| + |         OUT      | ||
| + | |||
| + |         POP      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; --------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------- | ||
| + | ; This subroutine is used to time the transitions of the Delay-flip-flops | ||
| + | ; used, above, to control the array of microdrives attached to Interface 1. | ||
| + | ; Delay flip flops become unstable if transitions are too close together | ||
| + | ; and this routine provides a 1 millisecond delay between clock pulses. | ||
| + | |||
| + | <a name=" | ||
| + | L15A2:  | ||
| + | PUSH AF ; | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; --------------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------------- | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L15AD:  | ||
| + |         LD      DE, | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; ------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L15B3:  | ||
| + |         LD      DE, | ||
| + | |||
| + | ; -> Common code. | ||
| + | |||
| + | <a name=" | ||
| + | L15B7:  | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; Drive ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L15BF:  | ||
| + |         OUT      | ||
| + | LD A,$E2 ; | ||
| + |         OUT      | ||
| + |         INC      | ||
| + | LD A,D ; | ||
| + | LD B,E ; | ||
| + | LD C,$E7 ; | ||
| + | |||
| + | NOP ; | ||
| + | NOP ; | ||
| + | NOP ; | ||
| + | |||
| + | <a name=" | ||
| + | L15D0:  | ||
| + |         DEC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD A,$E6 ; | ||
| + |         OUT      | ||
| + |         CALL    <A href="# | ||
| + |         POP      | ||
| + | RET ; return. | ||
| + | |||
| + | ; ----------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------- | ||
| + | ; This exit point is used twice from the next routines when the required | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L15DE:  | ||
| + |         POP      | ||
| + |         INC      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; -------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L15E2:  | ||
| + |         LD      DE, | ||
| + |         LD      HL, | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; -------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L15EB:  | ||
| + |         LD      DE, | ||
| + |         LD      HL, | ||
| + | |||
| + | ; --& | ||
| + | |||
| + | <a name=" | ||
| + | L15F2:  | ||
| + | LD C,D ; load C register with count of further loads. | ||
| + |         INC      | ||
| + | PUSH BC ; save the INIR counters. | ||
| + | |||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L15F6:  | ||
| + | |||
| + |         DEC      | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L15FD:  | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L1608:  | ||
| + |         DEC      | ||
| + | LD A,H ; | ||
| + | OR L ; | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L160F:  | ||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD A,$EE ; | ||
| + |         OUT      | ||
| + | |||
| + | LD B,$3C ; set count 60 decimal. | ||
| + | |||
| + | <a name=" | ||
| + | L1620:  | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L162A:  | ||
| + |         POP      | ||
| + | PUSH HL ; and stack again. | ||
| + |         CALL    <A href="# | ||
| + | LD A,C ; transfer repeat counter to A. | ||
| + | LD C,$E7 ; set port to $E7. | ||
| + | |||
| + | ; Now the INIR (INput to memory Increment and Repeat) instruction is used. | ||
| + | |||
| + | <a name=" | ||
| + | L1633:  | ||
| + | |||
| + | ; B (zero) will now count 256 bytes if first block was not the total. | ||
| + | |||
| + |         DEC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; All bytes, 15 or 528 have now been read. | ||
| + | |||
| + | LD A,$EE ; | ||
| + |         OUT      | ||
| + | |||
| + |         POP      | ||
| + | RET ; return. | ||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ;   < | ||
| + | |||
| + | <a name=" | ||
| + | L163E:  | ||
| + |         IN      A, | ||
| + | RRA ; test for SPACE key. | ||
| + |         RET      | ||
| + | |||
| + | LD A,$FE ; read port $FEFE - keys SHIFT, Z, X, C, V. | ||
| + |         IN      A, | ||
| + | RRA ; test for SHIFT key. | ||
| + |         RET      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      (IY+$00), | ||
| + |         RST      | ||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1652:  | ||
| + | |||
| + | <a name=" | ||
| + | L1653:  | ||
| + | LD A,B ; | ||
| + | OR C ; | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         POP      | ||
| + | RET ; | ||
| + | |||
| + | ; ------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------ | ||
| + | ;   < | ||
| + | ; Used by format routine. | ||
| + | |||
| + | <a name=" | ||
| + | L165A:  | ||
| + | PUSH BC | ||
| + | |||
| + | <a name=" | ||
| + | L165C:  | ||
| + | |||
| + | <a name=" | ||
| + | L165E:  | ||
| + | |||
| + | IN A,($EF) | ||
| + |         AND      | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1669:  | ||
| + | |||
| + | <a name=" | ||
| + | L166B:  | ||
| + | |||
| + | IN A,($EF) | ||
| + |         AND      | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD A,$EE | ||
| + |         OUT      | ||
| + | |||
| + | LD B,$3C ; set counter to 60d. | ||
| + | |||
| + | <a name=" | ||
| + | L167C:  | ||
| + |         AND      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1686:  | ||
| + | POP HL | ||
| + | PUSH HL | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | LD C,$E7 ; port | ||
| + | LD E,$FC ; required test byte | ||
| + | LD B,$0F ; initial counter. | ||
| + | LD D,$64 ; final counter. | ||
| + | INIR | ||
| + | |||
| + | <a name=" | ||
| + | L1696:  | ||
| + | CP E | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L169D:  | ||
| + | CP E | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD B,D ; final counter is $64 | ||
| + | |||
| + | <a name=" | ||
| + | L16A5:  | ||
| + | CP E | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         XOR      | ||
| + | |||
| + | <a name=" | ||
| + | L16AD:  | ||
| + | RET ; return. | ||
| + | |||
| + | ; ------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------- | ||
| + | ;   < | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L16AF:  | ||
| + | |||
| + |         LD      A, | ||
| + |         OUT      | ||
| + | |||
| + | LD A,$E2 | ||
| + |         OUT      | ||
| + | |||
| + | LD E,$66 | ||
| + | LD C,$E7 | ||
| + | LD B,$1B | ||
| + | LD A,$FC ; test byte written | ||
| + | NOP ; | ||
| + | OTIR ; | ||
| + | |||
| + | <a name=" | ||
| + | L16C4:  | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L16C8:  | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD B,E ; load counter with $66 | ||
| + | |||
| + | <a name=" | ||
| + | L16CD:  | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD A,$E6 | ||
| + |         OUT      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ;    | ||
| + | ; is set to $FF. This section is situated before the fixed-position CLOSE | ||
| + | ;    | ||
| + | |||
| + |         DEFB    $7F             ; copyright  | ||
| + |         DEFM    " 1983 Sinclair" | ||
| + | DEFM " Research Ltd" | ||
| + |         DEFM    " MJB "  | ||
| + | |||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | DEFB $FF | ||
| + | |||
| + | ; -------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------- | ||
| + | ;   < | ||
| + | |||
| + | <a name=" | ||
| + | L1708:  | ||
| + | |||
| + |         RST      | ||
| + | |||
| + | ;   < | ||
| + | ; now hold the value 1 from the setting of COPIES. | ||
| + | ;   A command like       OPEN # | ||
| + | ; If the system variables were already created then it is possible to | ||
| + | ;    | ||
| + | ; that were performed on the value in the main ROM. | ||
| + | |||
| + | |||
| + |         SRL      | ||
| + |         SUB      | ||
| + | |||
| + |         RES      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; This command is called from above and also from ALL-STRMS as part of the | ||
| + | ; CLEAR # command execution. | ||
| + | |||
| + | <a name=" | ||
| + | L1718:  | ||
| + | DEFW $1727 ; main STR-DATA1 | ||
| + | |||
| + | ; Now perform the check that should have taken place in the original ROM. | ||
| + | |||
| + | LD A,C ; Test offset for zero. | ||
| + | OR B ; | ||
| + |         RET      | ||
| + | |||
| + | PUSH BC ; | ||
| + | PUSH HL ; | ||
| + | |||
| + |         LD      HL, | ||
| + |         DEC      | ||
| + |         ADD      | ||
| + |         EX      (SP), | ||
| + |         RST      | ||
| + | DEFW $16EB ; main CLOSEX | ||
| + |         LD      HL, | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         POP      | ||
| + | SCF ; | ||
| + |         SBC      | ||
| + |         POP      | ||
| + | |||
| + | |||
| + |         RET      | ||
| + | |||
| + | PUSH BC ; | ||
| + | PUSH DE ; | ||
| + | EX DE,HL ; | ||
| + |         LD      ($5C51), | ||
| + |         INC      | ||
| + | |||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         INC      | ||
| + | |||
| + |         LD      A, | ||
| + | |||
| + | ; Now mark the channel as temporary so that if anything goes wrong, such | ||
| + | ; as the user pressing BREAK, then the channel can be reclaimed by CLEAR #. | ||
| + | |||
| + | L1741:  | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      E, | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + | PUSH DE ; | ||
| + |         CP      $54             ; compare to " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD A,$0D | ||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L175C:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L176B:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         BIT      | ||
| + |         JP      Z,<A href="# | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L177D:  | ||
| + |         POP      | ||
| + | PUSH BC ; | ||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2 | ||
| + |         XOR      | ||
| + |         LD      HL, | ||
| + | |||
| + | <a name=" | ||
| + | L1787:  | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + |         DEC      | ||
| + |         LD      ($5C5F), | ||
| + |         POP      | ||
| + |         POP      | ||
| + | PUSH HL ; | ||
| + | PUSH BC ; | ||
| + |         AND      | ||
| + |         SBC      | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | EX DE,HL ; | ||
| + |         AND      | ||
| + |         SBC      | ||
| + | EX DE,HL ; | ||
| + |         LD      HL, | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + | |||
| + | <a name=" | ||
| + | L17A2:  | ||
| + |         INC      | ||
| + |         INC      | ||
| + |         INC      | ||
| + | CP $10 ; | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      (IY+$26), | ||
| + |         POP      | ||
| + |         POP      | ||
| + |         RES      | ||
| + | RET ; return. | ||
| + | |||
| + | ; ---------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L17B7:  | ||
| + | LD DE,$0014 | ||
| + |         ADD      | ||
| + | |||
| + | <a name=" | ||
| + | L17C0:  | ||
| + | CP $80 ; is it the end-marker ? | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD A,$EE | ||
| + |         OUT      | ||
| + | |||
| + | XOR A | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | RET ; unused - the above JP was probably once a CALL. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L17D0:  | ||
| + |         CP      $CD             ; is it an inverted " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L17DC:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | LD BC,$0114 | ||
| + | PUSH IX | ||
| + | POP HL | ||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2 | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L17EB:  | ||
| + |         LD      D, | ||
| + |         ADD      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; -------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L17F5:  | ||
| + | ; progress - see INKEY$ | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         LD      HL, | ||
| + | PUSH HL | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + | POP DE | ||
| + |         LD      HL, | ||
| + | OR A | ||
| + |         SBC      | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      ($5CDA), | ||
| + | |||
| + | <a name=" | ||
| + | L1818:  | ||
| + |         LD      ($5C51), | ||
| + | |||
| + | <a name=" | ||
| + | L181E:  | ||
| + | DEFW $15E6 ; main INPUT-AD | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1827:  | ||
| + |         LD      ($5C51), | ||
| + |         RST      | ||
| + | DEFW $0010 ; main PRINT-A | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L1832:  | ||
| + |         LD      HL, | ||
| + | PUSH HL | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + | POP DE | ||
| + |         LD      HL, | ||
| + | OR A | ||
| + |         SBC      | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      ($5CDA), | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | RET ; RETURN | ||
| + | |||
| + | |||
| + | ; --------------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1859:  | ||
| + | INC A | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | DEC A | ||
| + |         RST      | ||
| + | DEFW $1601 ; main CHAN-OPEN | ||
| + |         LD      HL, | ||
| + |         LD      ($5CDA), | ||
| + | RET | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L186A:  | ||
| + | |||
| + |         CP      $4D             ; is character " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; microdrive channel, starts motor, and | ||
| + | ; fetches record zero of named file. | ||
| + | XOR A | ||
| + |         CALL    <A href="# | ||
| + |         LD      ($5CDA), | ||
| + |         BIT      | ||
| + | RET Z | ||
| + | |||
| + |         RST      | ||
| + | DEFB $16 ; Wrong file type | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1883:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         LD      ($5CDA), | ||
| + | RET | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L188F:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CP      $42             ; is character " | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $00 ; Nonsense in BASIC | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1899:  | ||
| + |         LD      ($5CDA), | ||
| + | PUSH DE ; | ||
| + |         POP      | ||
| + |         SET      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L18A8:  | ||
| + | INC A | ||
| + | RET NZ | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      $4D             ; is character " | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      IX, | ||
| + |         CALL    <A href="# | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L18BC:  | ||
| + |         RET      | ||
| + | |||
| + |         LD      IX, | ||
| + |         LD      ($5C51), | ||
| + |         CALL    <A href="# | ||
| + | RET | ||
| + | |||
| + | |||
| + | ; --------------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L18CB:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; 'Drive ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L18D9:  | ||
| + |         LD      ($5CE4), | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; microdrive channel, starts motor, and | ||
| + | ; attempts to fetch record zero of named file. | ||
| + | |||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; and stops the motor. | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0C             ; Writing to a ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L18ED:  | ||
| + | |||
| + | ;   < | ||
| + | ;   two lines are not necessary.  | ||
| + | ;    | ||
| + | |||
| + |         LD      A, | ||
| + |         CALL    <A href="# | ||
| + | ; motor. | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | EX DE,HL ; transfer this destination to DE. | ||
| + | |||
| + |         LD      HL, | ||
| + |         LD      BC, | ||
| + |         LD      (IX+$0B), | ||
| + | |||
| + | LDIR ; block move the header info into the buffer. | ||
| + | |||
| + | PUSH DE ; save destination. | ||
| + | |||
| + | ; Now calculate the number of sectors required using a similar method to | ||
| + | ; the one used for calculating the number of records to load. | ||
| + | ;   < | ||
| + | ; from the total bytes to ensure that there is at least one byte in the EOF | ||
| + | ;    | ||
| + | |||
| + | L190B:  | ||
| + |         LD      BC, | ||
| + |         ADD      | ||
| + | |||
| + |         SRL      | ||
| + |         INC      | ||
| + | |||
| + | ;   < | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | |||
| + | PUSH HL ; preserve register H the sector counter. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; cartridge. | ||
| + | |||
| + |         POP      | ||
| + | LD A,E ; load accumulator with actual sectors. | ||
| + | CP H ; compare with estimate | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0F             ; ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1921:  | ||
| + |         LD      HL, | ||
| + |         LD      BC, | ||
| + | |||
| + | <a name=" | ||
| + | L1929:  | ||
| + | OR C ; zero bytes. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | CP $02 ; compare to 2 which would indicate 512 bytes. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; a sector is written to microdrive. | ||
| + | |||
| + | PUSH HL ; preserve start of data. | ||
| + | PUSH BC ; preserve length. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | EX DE,HL ; transfer this destination to DE. | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | <a name=" | ||
| + | L1943:  | ||
| + | ; the total byte counter. | ||
| + | |||
| + | ; now increment the channel byte counter which started at zero and has a | ||
| + | ; limit of 512 bytes. | ||
| + | |||
| + |         INC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L194F:  | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         DEC      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      ($5CEF), | ||
| + | |||
| + |         RES      | ||
| + | LD A,$00 ; prepare to start saving at record zero again. | ||
| + |         LD      (IX+$0D), | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L196A:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JP      <A href="# | ||
| + | |||
| + | ; ---------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------------------------------- | ||
| + | ; this routine extracts the nine bytes of global header information that | ||
| + | ; is prepended to the data saved on microdrive. This relates to the type - | ||
| + | ; Basic, Code and length etc. and is the equivalent of a tape header without | ||
| + | ; the name which, in contrast, does have to be saved to every record. | ||
| + | ; It is obtained therefore from the start of data at record zero. | ||
| + | ; | ||
| + | ; <font color=# | ||
| + | ; has already been calculated and since opening a channel will move this | ||
| + | ; destination up in memory, the "Start of data" is transferred to the D_STR2 | ||
| + | ; location, otherwise used for the second filename during moves, so that its | ||
| + | ; value is adjusted by REST-N-AD during OP-TEMP-M. | ||
| + | |||
| + | <a name=" | ||
| + | L1971:  | ||
| + |         LD      ($5CE4), | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; microdrive channel, starts motor, and | ||
| + | ; fetches record zero of named file. | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $11             ; 'File not found' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1982:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $16             ; 'Wrong file type' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L198A:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      DE, | ||
| + | ; starting at location HD_00. | ||
| + |         LD      BC, | ||
| + | |||
| + | LDIR ; block move to HD_00 - HD_11. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; -------------------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------------------- | ||
| + | ; This subroutine is called once only from LV-ANY to load a block of code, | ||
| + | ;    | ||
| + | ; At this stage a temporary channel has already been created and it holds | ||
| + | ; the first 512 byte record containing at the start the nine header bytes. | ||
| + | ; There will be an accurate microdrive map for the drive which has its | ||
| + | ; motor running. | ||
| + | ; The block could be a program, code bytes or an array and the first | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L199A:  | ||
| + | |||
| + | ; now directly read the header values at the start of the data buffer. | ||
| + | |||
| + |         LD      E, | ||
| + |         LD      D, | ||
| + | |||
| + | ; now calculate how many 512 byte microdrive records need to be read in | ||
| + | ; by taking the total minus one to ensure an EOF record. | ||
| + | ;    | ||
| + | ; 1023 bytes = 1014 bytes + 9 header - 1 = $03FE, SRL=$01, INC=$02 sectors | ||
| + | ; 1024 bytes = 1015 bytes + 9 header - 1 = $03FF, SRL=$01, INC=$02 sectors | ||
| + | ; 1025 bytes = 1016 bytes + 9 header - 1 = $0400, SRL=$02, INC=$03 sectors | ||
| + | |||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + | |||
| + | ; the MSB is the number of 256 chunks. | ||
| + | |||
| + |         SRL      | ||
| + | ; chunks. | ||
| + |         INC      | ||
| + | |||
| + | LD A,H ; use accumulator to store record count | ||
| + |         LD      ($5CE7), | ||
| + | |||
| + | ; the microdrive map is now saved on the machine stack, for later recall, | ||
| + | ; and at the same time the current map locations are all set to zero. | ||
| + | ; The new map is to be used for records rather than sectors. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; of the map on the machine stack safely | ||
| + | ; dipping into the 80 bytes of spare memory. | ||
| + | |||
| + | ; now, since this is record zero, subtract the nine header bytes from the | ||
| + | ;    | ||
| + | |||
| + |         LD      DE, | ||
| + | |||
| + |         LD      L, | ||
| + |         LD      H, | ||
| + | |||
| + | OR A ; clear carry | ||
| + | |||
| + |         SBC      | ||
| + | |||
| + |         LD      (IX+$45), | ||
| + |         LD      (IX+$46), | ||
| + | |||
| + | ; | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         LD      DE, | ||
| + | |||
| + |         JR      <A href="# | ||
| + | ; loading loop at the mid-point as record | ||
| + | ; zero is already in the channel. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ;   The record loading loop loads records in random order.  | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L19D0:  | ||
| + | ; record that matches the name specified | ||
| + | ; in CHNAME and only if the map bit is reset | ||
| + | ; indicating no sector with this record number | ||
| + | ; has already been loaded. | ||
| + | |||
| + |         LD      A, | ||
| + | |||
| + | ; <font color=# | ||
| + | ; so no sector with record zero could be reloaded. | ||
| + | |||
| + | OR A ; test for a record zero. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; now calculate the destination if this 512 byte sector. | ||
| + | |||
| + | RLA ; double recnum to give 512 byte chunks | ||
| + |         DEC      | ||
| + | LD D,A ; place in MSB of offset | ||
| + | |||
| + | LD E,$F7 ; set LSB of offset to $00 - $09 for header. | ||
| + |         LD      HL, | ||
| + | |||
| + |         ADD      | ||
| + | EX DE,HL ; transfer destination to DE. | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      BC, | ||
| + |         ADD      | ||
| + | |||
| + | ; -> The mid loop entry point. | ||
| + | |||
| + | <a name=" | ||
| + | L19EA:  | ||
| + | ; registers. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; and B to the mask. | ||
| + | |||
| + | ; <font color=# | ||
| + | ; been loaded but this is not possible. | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; since this is the first time for this record mark so that not loaded again. | ||
| + | |||
| + |         LD      A, | ||
| + | OR B ; by setting it so that it is not | ||
| + |         LD      (HL), | ||
| + | |||
| + | EXX ; restore HL (source) and DE (destination). | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; data record. | ||
| + | |||
| + | ; now decrement the record count which is beyond reach of IY register. | ||
| + | |||
| + |         LD      A, | ||
| + |         DEC      | ||
| + |         LD      ($5CE7), | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; the block is loaded | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; map from the stack. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ; This routine saves the sector-mapped microdrive map on the machine stack | ||
| + | ; at the same time setting each of the 32 vacated locations to zero. | ||
| + | |||
| + | <a name=" | ||
| + | L1A04:  | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + |         LD      L, | ||
| + |         LD      H, | ||
| + |         LD      BC, | ||
| + | |||
| + | ; now enter a loop stacking two bytes at a time. | ||
| + | |||
| + | <a name=" | ||
| + | L1A11:  | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + | |||
| + | PUSH DE ; save DE on machine stack. | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | JP (HL) ; and jump to location. | ||
| + | |||
| + | ; --------------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------------- | ||
| + | ; This routine is the opposite of the above and restores the sector-mapped | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1A1E:  | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + |         LD      L, | ||
| + |         LD      H, | ||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | LD B,$10 ; set the pop counter to sixteen. | ||
| + | |||
| + | <a name=" | ||
| + | L1A2E:  | ||
| + | |||
| + |         LD      (HL), | ||
| + |         DEC      | ||
| + |         LD      (HL), | ||
| + |         DEC      | ||
| + | |||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         LD      HL, | ||
| + | JP (HL) ; and jump to address. | ||
| + | |||
| + | ; --------------------- | ||
| + | ; THE < | ||
| + | ; --------------------- | ||
| + | ; The Load or Verify from Microdrive routine. | ||
| + | ; This routine loads or verifies up to 512 bytes of data currently in the | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1A39:  | ||
| + |         LD      B, | ||
| + | |||
| + | ; now test if a VERIFY operation by performing the equivalent of bit 7, | ||
| + | |||
| + |         LD      A, | ||
| + |         BIT      | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; the operation is a LOAD. | ||
| + | |||
| + | LDIR ; block copy the bytes. | ||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; the operation is a VERIFY. | ||
| + | |||
| + | <a name=" | ||
| + | L1A49:  | ||
| + | CP (HL) ; compare to that of source | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         DEC      | ||
| + | LD A,B ; test for | ||
| + | OR C ; zero. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1A55:  | ||
| + |         DEFB    $15             ; ' | ||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ;    | ||
| + | ;   < | ||
| + | |||
| + | <a name=" | ||
| + | L1A57:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | ; --& | ||
| + | |||
| + | <a name=" | ||
| + | L1A5D:  | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | <a name=" | ||
| + | L1A64:  | ||
| + | ; matching record to pass tape head. | ||
| + | |||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         CALL    <A href="# | ||
| + |         RET      | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1A7B:  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $11 ; File not found | ||
| + | |||
| + | |||
| + | ; ----------------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------------- | ||
| + | ; This subroutine performs a similar function to the Main ROM POINTERS routine | ||
| + | ; by adjusting the extra system variables that point to filenames within | ||
| + | ; the sliding, dynamic areas. | ||
| + | ; On entry HL points to the start of the New Room and BC holds the number of | ||
| + | ; bytes created. | ||
| + | |||
| + | <a name=" | ||
| + | L1A82:  | ||
| + | |||
| + | PUSH HL ; Preserve HL for second call. | ||
| + | |||
| + |         LD      DE, | ||
| + |         CALL    <A href="# | ||
| + |         LD      ($5CE4), | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         CALL    <A href="# | ||
| + |         LD      ($5CDC), | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; This subroutine is used twice from above to test if the filename address | ||
| + | ;   is within the Spectrum' | ||
| + | ; HL = location before new room. | ||
| + | ; DE = address of filename. | ||
| + | ; BC = amount of room just created. | ||
| + | |||
| + | <a name=" | ||
| + | L1A9D:  | ||
| + |         SBC      | ||
| + |         RET      | ||
| + | |||
| + |         LD      HL, | ||
| + |         SBC      | ||
| + |         RET      | ||
| + | |||
| + | EX DE,HL ; add the number of bytes created | ||
| + |         ADD      | ||
| + | EX DE,HL ; to bring it into line. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1AAB:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1AB0:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1AB5:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1ABA:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1ABF:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1AC4:  | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1AC9:  | ||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1ACC:  | ||
| + |         ADD      | ||
| + |         LD      HL, | ||
| + | LD E,A ; | ||
| + | LD D,$00 ; | ||
| + |         ADD      | ||
| + | PUSH HL ; | ||
| + |         CALL    <A href="# | ||
| + | ; microdrive channel, starts motor, and | ||
| + | ; fetches record zero of named file. | ||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; Drive ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1AE9:  | ||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + |         BIT      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $16 ; Wrong file type | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1AFF:  | ||
| + |         POP      | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + | RET ; | ||
| + | |||
| + | |||
| + | ; ------------------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------------------ | ||
| + | ; <font color=# | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1B05:  | ||
| + | ; using either an existing microdrive map from | ||
| + | ; a channel also using this drive or allocating | ||
| + | ; a new one initialized to $FF bytes. | ||
| + | ; fields CHREC etc. are set to zero. | ||
| + | |||
| + | PUSH HL ; preserve the offset to this channel from CHANS | ||
| + | |||
| + |         LD      A, | ||
| + |         CALL    <A href="# | ||
| + | ; interrupts. | ||
| + | |||
| + |         LD      BC, | ||
| + |         LD      ($5CC9), | ||
| + | ; and set SECTOR_hi to zero. | ||
| + | |||
| + | ; now enter a loop | ||
| + | |||
| + | <a name=" | ||
| + | L1B16:  | ||
| + | ; matching record | ||
| + | |||
| + | PUSH AF ; preserve return status flags. | ||
| + | |||
| + | ; maintain the ' | ||
| + | |||
| + |         LD      A, | ||
| + |         ADD      | ||
| + |         LD      HL, | ||
| + | CP (HL) ; compare | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      (HL), | ||
| + | |||
| + | <a name=" | ||
| + | L1B26:  | ||
| + | |||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | ; to reset map bit. | ||
| + | |||
| + | ; the fetched record is one from the file named in CHNAME | ||
| + | |||
| + |         RES      | ||
| + | |||
| + |         LD      A, | ||
| + | OR A ; test for zero - first record. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L1B41:  | ||
| + | ; subroutine G-HD-RC (as at start of loop) | ||
| + | ; until the validated record matching CHREC | ||
| + | ; (zero) is loaded. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1B46:  | ||
| + | ; sectors. | ||
| + | |||
| + | ; the branch was here | ||
| + | |||
| + | <a name=" | ||
| + | L1B49:  | ||
| + | |||
| + |         LD      A, | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + |         DEC      | ||
| + | CP (HL) ; compare. | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + | ; else a full revolution occurred without finding the record. | ||
| + | |||
| + |         RES      | ||
| + |         RES      | ||
| + | |||
| + | ; the branch was here with record zero of named file. | ||
| + | |||
| + | <a name=" | ||
| + | L1B5B:  | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; e.g. FORMAT " | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1B5D:  | ||
| + | ; microdrive channel with name of cartridge. | ||
| + | |||
| + |         LD      A, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | DI ; Disable Interrupts. | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; Drive ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1B75:  | ||
| + |         OUT      | ||
| + | |||
| + |         LD      BC, | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | EX DE,HL ; make destination HDNAME | ||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + | |||
| + |         LD      BC, | ||
| + | LDIR ; copy - C is now zero. | ||
| + | |||
| + | ; now prepare an ' | ||
| + | |||
| + |         XOR      | ||
| + | |||
| + |         LD      (IX+$47), | ||
| + |         SET      | ||
| + |         RES      | ||
| + |         SET      | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      HL, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | ; Now enter a loop to write the blocks to the cartridge | ||
| + | |||
| + | <a name=" | ||
| + | L1BAB:  | ||
| + | ; set to $FF | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      (IX+$29), | ||
| + | |||
| + | PUSH IX ; transfer the base channel address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE,<A href="# | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; preserving the HL value. | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | PUSH IX ; transfer start of channel | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ; -> the branch was to here when all sectors from 254 down to 1 have been | ||
| + | ; written. | ||
| + | |||
| + | <a name=" | ||
| + | L1BDF:  | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | LD A,$EE ; signal disable writing. | ||
| + |         OUT      | ||
| + | |||
| + |         LD      A, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | <a name=" | ||
| + | L1BF6:  | ||
| + | ; to pass the tape head. | ||
| + |         LD      A, | ||
| + |         ADD      | ||
| + |         LD      HL, | ||
| + | CP (HL) ; and compare to total of sectors to visit. | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      (HL), | ||
| + | |||
| + | <a name=" | ||
| + | L1C05:  | ||
| + | ; on the microdrive map. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | PUSH IX ; transfer channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | ; leaving map bit set. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; the sector as usable. | ||
| + | |||
| + | <a name=" | ||
| + | L1C1E:  | ||
| + |         LD      A, | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + | |||
| + |         DEC      | ||
| + | CP (HL) ; compare counter to limit. | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      L, | ||
| + |         LD      H, | ||
| + | |||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ; the top seventy sectors, or so, will be marked as unusable though not on an | ||
| + | ;    | ||
| + | ;    | ||
| + | ; and there may be some other sectors unusable due to dirt on the recording | ||
| + | ;    | ||
| + | ; What happens next is unique to this ROM and is no doubt due to extensive | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ;   as bad also.  One can conclude that Sinclair Research' | ||
| + | ;    | ||
| + | ;   or damaged sectors.  | ||
| + | ; This perhaps explains why my use of the microdrives with ROM 2 has been | ||
| + | ; more reliable than early reviews, no doubt with ROM 1, suggested. | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | LD B,$20 ; count the thirty two bytes of a map. | ||
| + | |||
| + | SCF ; set carry flag to ensure that sector 255 | ||
| + | ; is unusable - but it is already marked so ?? | ||
| + | |||
| + | <a name=" | ||
| + | L1C35:  | ||
| + | |||
| + |         LD      C,A             ; and store it in C - <font color=# | ||
| + | |||
| + |         RRA                     ; rotate right accumulator  | ||
| + | |||
| + | OR C ; combine with original value. Why not OR (HL) ? | ||
| + | |||
| + |         LD      (HL), | ||
| + | |||
| + |         DEC      | ||
| + | ; sectors. | ||
| + | |||
| + | L1C3B:  | ||
| + | |||
| + | ;   < | ||
| + | ; and no need to store the original value in C. While it achieves it's aims, | ||
| + | ; if sector one is bad it has no effect on the next sector to be encountered. | ||
| + | ; That would be hard to implement but the first sector that is marked bad, | ||
| + | ; the highest numbered sector, is marked so solely because it is adjacent to | ||
| + | ; the overwritten section. | ||
| + | |||
| + | ;   < | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | ; Now prepare to overwrite the unusable sectors (which are mapped as usable) | ||
| + | ; with record descriptors which are usable. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; descriptor fields as usable by blanking | ||
| + | ; both RECFLG and RECLEN and then inserting | ||
| + | ; the descriptor checksum. | ||
| + | |||
| + | ; A loop is now entered to write usable datablocks to every sector indicated | ||
| + | ; as usable in the microdrive map. | ||
| + | |||
| + | <a name=" | ||
| + | L1C40:  | ||
| + | ; usable sector on the cartridge. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; The FORMAT operation is now complete. | ||
| + | |||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; buffer and the microdrive map. | ||
| + | |||
| + |         RET                     ; return.  | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1C4D:  | ||
| + | ; cartridge as indicated by the microdrive map | ||
| + | ; which is then updated by the routine. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; ------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------- | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1C52:  | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1601 ; main CHAN-OPEN | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      A, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      BC, | ||
| + | ; value of sectors read to zero. | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | ; On the original Interface 1 ROM operations like CAT and ERASE were quite | ||
| + | ; slow as the routines assumed the theoretical maximum number of sectors was | ||
| + | ;    | ||
| + | ;    | ||
| + | ;    | ||
| + | ; is to keep a record of the maximum sector + 3 and when the number of | ||
| + | ;    | ||
| + | ; tape has been made and the operation can cease. The overhead of three is | ||
| + | ; to ensure that bad sectors or the tape splice do not cause the operation to | ||
| + | ; end prematurely. | ||
| + | ;    | ||
| + | ; full 256 sectors. | ||
| + | |||
| + | <a name=" | ||
| + | L1C68:  | ||
| + | |||
| + |         LD      A, | ||
| + | |||
| + |         ADD      | ||
| + | |||
| + |         LD      HL, | ||
| + | CP (HL) ; compare to contents | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         LD      (HL), | ||
| + | |||
| + | <a name=" | ||
| + | L1C77:  | ||
| + | ; 14 byte record descriptor. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; a record can be considered in use if either the RECLEN is maximum $0200 or | ||
| + | ; the RECFLG indicates that it is the seldom full EOF record. | ||
| + | |||
| + |         LD      A, | ||
| + |         OR      (IX+$46)  | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; else mark sector free in microdrive map and find next sector. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; a name is to be inserted in the 512 byte data buffer workspace, if it is not | ||
| + | ; there already. Secret files are not listed. | ||
| + | |||
| + | <a name=" | ||
| + | L1C8B:  | ||
| + | OR A ; test for zero. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | PUSH IX ; transfer base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      DE, | ||
| + | LD B,$00 ; set high byte to zero. | ||
| + |         LD      C, | ||
| + | |||
| + | <a name=" | ||
| + | L1CA0:  | ||
| + | OR A ; | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | PUSH HL ; save buffer address. | ||
| + | PUSH IX ; save channel base address. | ||
| + | PUSH BC ; save name total. | ||
| + | |||
| + | LD B,$0A ; set character counter to ten. | ||
| + | |||
| + | <a name=" | ||
| + | L1CAA:  | ||
| + |         CP      (IX+$47)  | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1CB5:  | ||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | ; if all ten characters match then find next sector. | ||
| + | |||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; if buffered name is higher than new name then re-order to create a slot. | ||
| + | |||
| + |         JR      NC,<A href="# | ||
| + | |||
| + | ; else add ten to buffer address and compare with following name performing | ||
| + | ; a simple insert if the end of the list is reached. | ||
| + | |||
| + |         ADD      | ||
| + |         DEC      | ||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1CC1:  | ||
| + | PUSH DE ; save the value ten. | ||
| + | PUSH BC ; save the buffered name counter. | ||
| + | |||
| + | PUSH HL ; save address of name slot again. | ||
| + |         SLA      | ||
| + | LD H,B ; set H to zero. | ||
| + | LD L,C ; HL = 2 * count | ||
| + |         ADD      | ||
| + |         ADD      | ||
| + |         ADD      | ||
| + |         ADD      | ||
| + | |||
| + | LD B,H ; transfer number of bytes | ||
| + | LD C,L ; to be moved to BC register. | ||
| + | |||
| + |         POP      | ||
| + |         DEC      | ||
| + |         ADD      | ||
| + | |||
| + | EX DE,HL ; now make DE | ||
| + |         ADD      | ||
| + | EX DE,HL ; ten bytes higher. | ||
| + | |||
| + | LDDR ; slide the block of higher names upwards. | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | <a name=" | ||
| + | L1CDA:  | ||
| + | LD B,$0A ; set character count to ten. | ||
| + | |||
| + | <a name=" | ||
| + | L1CDE:  | ||
| + |         LD      (HL), | ||
| + |         INC      | ||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         LD      A, | ||
| + |         INC      | ||
| + |         LD      (IX+$0D), | ||
| + | |||
| + | CP $32 ; compare to maximum of 50. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1CF4:  | ||
| + |         LD      A, | ||
| + |         INC      | ||
| + |         LD      (HL), | ||
| + |         DEC      | ||
| + | CP (HL) ; compare | ||
| + |         JP      C,<A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L1CFF:  | ||
| + | |||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | PUSH IX ; transfer the channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; return. | ||
| + | |||
| + | LD A,$0D ; prepare an extra carriage return. | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | PUSH IX ; | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         LD      B, | ||
| + | LD A,B ; test for | ||
| + | OR A ; zero. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1D22:  | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1D27:  | ||
| + | |||
| + | LD A,E ; | ||
| + |         SRL      | ||
| + | |||
| + |         RST      | ||
| + | DEFW $2D28 ; main STACK-A | ||
| + | |||
| + | LD A,$0D ; | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFW $2DE3 ; main PRINT-FP | ||
| + | |||
| + | LD A,$0D ; | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------- | ||
| + | ; This routine is called from SAVE and CAT to calculate the number of free | ||
| + | ;    | ||
| + | ; The count of free sectors is returned in the E register. | ||
| + | |||
| + | <a name=" | ||
| + | L1D43:  | ||
| + |         LD      H, | ||
| + | |||
| + | LD E,$00 ; initialize sector count to zero. | ||
| + | LD C,$20 ; there are thirty two bytes to examine. | ||
| + | |||
| + | <a name=" | ||
| + | L1D4D:  | ||
| + |         INC      | ||
| + | |||
| + | LD B,$08 ; count eight bits. | ||
| + | |||
| + | <a name=" | ||
| + | L1D51:  | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         INC      | ||
| + | |||
| + | <a name=" | ||
| + | L1D55:  | ||
| + | |||
| + |         DEC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ; This routine outputs a ten character name, followed by a carriage return, | ||
| + | ; and is used by the CAT command to first print the cartridge name and then | ||
| + | ;   the filenames on the cartridge.  | ||
| + | ;   < | ||
| + | ; until one notices the call to TEMPS at the end. This applies the permanent | ||
| + | ;    | ||
| + | ; the routine as a security measure to ensure that if the cartridge name | ||
| + | ; or filename contains a string of colour control codes that render filenames | ||
| + | ;    | ||
| + | ; | ||
| + | ; On the other hand, colour control codes can be used in the cartridge name | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1D5B:  | ||
| + | |||
| + | LD B,$0A ; ten characters per name. | ||
| + | |||
| + | <a name=" | ||
| + | L1D5E:  | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | LD A,$0D ; prepare a carriage return. | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | PUSH HL ; preserve character address. | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0D4D ; main TEMPS restores temporary colours from | ||
| + | ; the permanent colours after each name. | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; -------------------- | ||
| + | ; THE < | ||
| + | ; -------------------- | ||
| + | ; The PRINT CHARACTER routine utilizes the output restart in the main ROM | ||
| + | ;   which outputs to any stream and so a stream such as the " | ||
| + | ; could be sent output. The IX register has therefore to be preserved. | ||
| + | |||
| + | <a name=" | ||
| + | L1D71:  | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0010 ; main PRINT-A | ||
| + | |||
| + |         POP      | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; <font color=# | ||
| + | ; The ERASE command is in two stages and uses the first 32 bytes of the | ||
| + | ;    | ||
| + | ; The first stage performs this mapping and in one revolution of the tape | ||
| + | ; it should find all sectors that have the specified name. It should also | ||
| + | ; find the EOF record, which all files have, and which contains in the | ||
| + | ;    | ||
| + | ;    | ||
| + | ; Once the number of marked records equals the max record plus one then the | ||
| + | ;    | ||
| + | ; | ||
| + | ; There are two circumstances under which the procedure might not be so | ||
| + | ;    | ||
| + | ; The first is if the user has pressed BREAK during a previous ERASE | ||
| + | ;    | ||
| + | ; The second is if the file has been saved with the System Variable COPIES | ||
| + | ;    | ||
| + | ; be five EOF records and five records with RECNUM equal to zero etc. | ||
| + | ; | ||
| + | ; For the first case the command will make five revolutions of the tape | ||
| + | ;    | ||
| + | ; This may happen in the second case also if more multi records were found | ||
| + | ;    | ||
| + | ; It is more likely that the ERASE command will have to be invoked several | ||
| + | ; times to erase the file. It is simpler to issue the command within a | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1D79:  | ||
| + | ; using either an existing microdrive map from | ||
| + | ; a channel also using this drive or allocating | ||
| + | ; a new one initialized to $FF bytes. | ||
| + | |||
| + |         LD      A, | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         IN      A, | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; Drive ' | ||
| + | |||
| + | |||
| + | <a name=" | ||
| + | L1D8A:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | ; A pseudo microdrive map will also be created within the buffer conserving | ||
| + | ;    | ||
| + | |||
| + | PUSH HL ; transfer buffer address | ||
| + |         POP      | ||
| + |         INC      | ||
| + | |||
| + |         LD      BC, | ||
| + |         XOR      | ||
| + |         LD      (HL), | ||
| + | LDIR ; copy to other 31 addresses | ||
| + | |||
| + | LD A,$FF ; prepare, as a default, to examine every sector. | ||
| + |         LD      (IX+$0D), | ||
| + | |||
| + |         LD      BC, | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | ;   < | ||
| + | ;    | ||
| + | ; occur after which all mapped sectors will be erased. Normally with a | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1DA7:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; header to pass the tape heads. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; 14-byte record descriptor for this sector. | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; now check if sector is in use. Considered it so if next position is | ||
| + | ; at $0200 or if it is the EOF record. | ||
| + | |||
| + |         LD      A, | ||
| + |         OR      (IX+$46)  | ||
| + | AND $02 | ||
| + |         JR      NZ,<A href="# | ||
| + | ; to consider for erasure. | ||
| + | |||
| + | ; the sector is not used so reset the REAL microdrive map bit. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; the REAL microdrive map. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1DC3:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         LD      BC, | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; the name matches so sector is marked free. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; bit in HL and bit mask in B. | ||
| + | |||
| + | LD A,B ; transfer mask to B | ||
| + | OR (HL) ; combine with addressed byte | ||
| + |         LD      (HL), | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; All files should have an EOF record and, if this is it, then the endpoint | ||
| + | ; can be reduced from $FF to record number plus one as range starts at 1. | ||
| + | |||
| + |         LD      A, | ||
| + |         INC      | ||
| + | ; zero. | ||
| + |         LD      (IX+$0D), | ||
| + | |||
| + | <a name=" | ||
| + | L1DE5:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | LD E,$00 ; initialize E to zero. | ||
| + | LD C,$20 ; and C counter to thirty two. | ||
| + | |||
| + | <a name=" | ||
| + | L1DF0:  | ||
| + |         INC      | ||
| + | |||
| + | LD B,$08 ; set bit counter to eight. | ||
| + | |||
| + | <a name=" | ||
| + | L1DF4:  | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         INC      | ||
| + | |||
| + | <a name=" | ||
| + | L1DF8:  | ||
| + | |||
| + |         DEC      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; now E holds the number of records marked for erasure in range 1 to NR. | ||
| + | |||
| + |         LD      A, | ||
| + | CP E ; compare to records marked for erasure. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; Now the second stage begins. Since the pseudomap has a representation of | ||
| + | ; all the records to be erased we can load the headers one by one, and | ||
| + | ;    | ||
| + | ; The same record is written after all the appropriate headers. Fields | ||
| + | ; like RECNUM only have relevance when the record is in use. | ||
| + | ; | ||
| + | ;   First prepare a clear record descriptor.  | ||
| + | ; have to be clear and in fact contains the pseudomap. Note also that the | ||
| + | ;    | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1E03:  | ||
| + | ; descriptor fields as usable by blanking | ||
| + | ; both RECFLG and RECLEN and then inserting | ||
| + | ; the descriptor checksum. | ||
| + | |||
| + | ; now enter a loop for all marked records. | ||
| + | |||
| + | <a name=" | ||
| + | L1E06:  | ||
| + | ; to pass the tape heads. | ||
| + |         CALL    <A href="# | ||
| + | ; (in HDNUMB) is marked to be erased in the | ||
| + | ; pseudomap. | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + | ; this record is marked for erasure. | ||
| + | |||
| + | PUSH HL ; save pseudomap sector bit address. | ||
| + | PUSH BC ; save pseudomap bit mask which has one set bit. | ||
| + | |||
| + | LD A,$E6 ; enable writing. | ||
| + |         OUT      | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | ; record now approaches the tape heads. | ||
| + | |||
| + | PUSH IX ; transfer channel base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |                                 ; data buffer. The descriptor is checksummed, | ||
| + | ; the data is not. | ||
| + | |||
| + | LD A,$EE ; disable writing | ||
| + |         OUT      | ||
| + | |||
| + | ; now update bit the real microdrive map and the pseudomap. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; for the now free sector in the REAL | ||
| + | ; microdrive map. | ||
| + | |||
| + |         POP      | ||
| + |         POP      | ||
| + | |||
| + | LD A,B ; transfer bitmask to B. | ||
| + | CPL ; the set bit is now reset and the other seven | ||
| + | ; bits are set. | ||
| + |         AND      | ||
| + |         LD      (HL), | ||
| + | |||
| + | ; now check if there are any more sectors to do. | ||
| + | |||
| + | <a name=" | ||
| + | L1E31:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | LD B,$20 ; set byte count to thirty two. | ||
| + | |||
| + | <a name=" | ||
| + | L1E3A:  | ||
| + | OR A ; test for zero. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         INC      | ||
| + |         DJNZ    <A href="# | ||
| + | |||
| + | ; at this point all records have been erased and it only remains to clear up. | ||
| + | |||
| + |         XOR      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; The two indicators within the current channel are marked clear and the | ||
| + | ;    | ||
| + | ; to be marked free. | ||
| + | |||
| + | <a name=" | ||
| + | L1E49:  | ||
| + |         LD      (IX+$43), | ||
| + |         LD      (IX+$45), | ||
| + |         LD      (IX+$46), | ||
| + | |||
| + | PUSH IX ; transfer the start of channel | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; -------------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------------- | ||
| + | ; This routine is used by CAT, ERASE and the GET-DESC Hook Code $33. | ||
| + | ; It loads and verifies the 14 byte record descriptor from RECFLG to RECNAM. | ||
| + | ; This is normally loaded with the following data block | ||
| + | ; or with the header block. | ||
| + | ; The Zero Flag is set upon successful completion. | ||
| + | |||
| + | <a name=" | ||
| + | L1E5E:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         CALL    <A href="# | ||
| + |         CALL    <A href="# | ||
| + |         RET      | ||
| + | |||
| + |         BIT      | ||
| + | RET ; return. | ||
| + | |||
| + | ; ----------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------- | ||
| + | ; This accesses the twenty six hook codes now reduced to the range $00 - $19. | ||
| + | |||
| + | <a name=" | ||
| + | L1E71:  | ||
| + |         JR      C,<A href="# | ||
| + | |||
| + |         RST      | ||
| + | DEFB $12 ; Hook code error. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1E77:  | ||
| + | |||
| + |         SET      | ||
| + | |||
| + |         INC      | ||
| + |         EX      (SP), | ||
| + | PUSH HL ; push back what was at stack pointer - the | ||
| + | ; preserved value of AF on entry. | ||
| + | |||
| + |         ADD      | ||
| + | LD D,$00 ; set D to zero for indexing. | ||
| + | LD E,A ; transfer the code to E. | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + |         ADD      | ||
| + | |||
| + |         LD      E, | ||
| + |         INC      | ||
| + |         LD      D, | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         LD      HL,<A href="# | ||
| + | PUSH HL ; on the machine stack. | ||
| + | |||
| + | EX DE,HL ; transfer address to HL. | ||
| + | JP (HL) ; jump to Hook Code routine. | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; <font color=# | ||
| + | ; This allows the user to call any address in the shadow ROM. | ||
| + | |||
| + | <a name=" | ||
| + | L1E94:  | ||
| + | JP (HL) ; jump to routine. | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; <font color=# | ||
| + | ; This Hook Code ensures that the extra System Variables are created. Since | ||
| + | ; this has already occurred, as is the case with all Hook Codes, then all that | ||
| + | ; remains to do is to return to the address on the stack - the UNPAGE location. | ||
| + | |||
| + | <a name=" | ||
| + | L1E98:  | ||
| + | |||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ;   The addresses of the Hook Codes.  | ||
| + | |||
| + | <a name=" | ||
| + | L1E99:  | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + | |||
| + |         DEFW    <A href="# | ||
| + |         DEFW    <A href="# | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L1ECD:  | ||
| + |         RES      | ||
| + | |||
| + | <a name=" | ||
| + | L1ED2:  | ||
| + | |||
| + |         RST      | ||
| + | DEFW $02BF ; main KEYBOARD | ||
| + | |||
| + |         BIT      | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      A, | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; <font color=# | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1EE0:  | ||
| + | LD A,$FE ; use system stream $FE - upper screen. | ||
| + | |||
| + | ; -> | ||
| + | |||
| + | <a name=" | ||
| + | L1EE3:  | ||
| + |         LD      (HL), | ||
| + | ; prompt. | ||
| + | |||
| + |         RST      | ||
| + | DEFW $1601 ; main CHAN-OPEN opens selected stream. | ||
| + | |||
| + |         POP      | ||
| + | |||
| + |         RST      | ||
| + | DEFW $0010 ; main PRINT-A prints character in accumulator. | ||
| + | |||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; <font color=# | ||
| + | ;    | ||
| + | |||
| + | <a name=" | ||
| + | L1EF0:  | ||
| + | LD A,$03 ; select stream 3 | ||
| + |         JR      <A href="# | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; ( Hook Code: $20 ) | ||
| + | ; Normally a single reset bit in A determines which half row is read but by | ||
| + | ; resetting all bits the entire keyboard is read. A pressed key will cause | ||
| + | ; a bit to be reset.  | ||
| + | ; NZ otherwise. | ||
| + | |||
| + | <a name=" | ||
| + | L1EF5:  | ||
| + |         IN      A, | ||
| + |         AND      | ||
| + | ; no key. | ||
| + |         SUB      | ||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; <font color=# | ||
| + | ; | ||
| + | |||
| + | <a name=" | ||
| + | L1EFD:  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         LD      (IY+$00), | ||
| + |         RST      | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1F08:  | ||
| + | ; and continue into next routine... | ||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; <font color=# | ||
| + | ; reads a PRINT record randomly. | ||
| + | |||
| + | <a name=" | ||
| + | L1F0B:  | ||
| + | ; by CHREQ matching filename CHNAME from the | ||
| + | ; cartridge in the drive CHDRIV which is | ||
| + | ; started. | ||
| + | |||
| + |         BIT      | ||
| + |         RET      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; channel thus losing the buffer contents. | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $16             ; 'Wrong file type' | ||
| + | |||
| + | ; ------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------- | ||
| + | ; <font color=# | ||
| + | ; Hook Code Only | ||
| + | |||
| + | <a name=" | ||
| + | L1F18:  | ||
| + | |||
| + | PUSH IX ; pick up start address | ||
| + |         POP      | ||
| + | |||
| + |         LD      BC, | ||
| + | |||
| + |         RST      | ||
| + | DEFW $19E8 ; main RECLAIM-2. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | |||
| + | ; ------------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------------- | ||
| + | ; <font color=# | ||
| + | |||
| + | <a name=" | ||
| + | L1F25:  | ||
| + |         OUT      | ||
| + | DI | ||
| + |         CALL    <A href="# | ||
| + |         JR      NC,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | EI ; | ||
| + |         AND      | ||
| + |         JP      <A href="# | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1F3A:  | ||
| + | EI ; | ||
| + |         JP      <A href="# | ||
| + | |||
| + | |||
| + | ; --------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------- | ||
| + | ; <font color=# | ||
| + | ; fetches header from sector specified by CHREC. | ||
| + | ; If the sector is from a PRINT type file then it returns with success. | ||
| + | ; Otherwise if a program or code file the data area is ' | ||
| + | |||
| + | <a name=" | ||
| + | L1F3F:  | ||
| + |                                 ; <font color=# | ||
| + | ; would not be compatible with emulators. | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | <a name=" | ||
| + | L1F45:  | ||
| + | ; to pass the tape heads. | ||
| + | |||
| + |         LD      A, | ||
| + |         CP      (IX+$0D)  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $11             ; 'File not found' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1F57:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; descriptor and the 512 bytes of data. | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | OR A ; clear carry | ||
| + |         BIT      | ||
| + |         RET      | ||
| + | |||
| + | <a name=" | ||
| + | L1F75:  | ||
| + | ; contents to same values. | ||
| + | SCF ; signal error. | ||
| + | RET ; return from hook-code. | ||
| + | |||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; <font color=# | ||
| + | ; This hook code just reads the next header to pass the tape head and then, | ||
| + | ; without further qualification, | ||
| + | ; routine above. If not a PRINT file then the data is cleared. | ||
| + | ; It needlessly sets up a sector counter in the System Variable SECTOR. | ||
| + | |||
| + | <a name=" | ||
| + | L1F7A:  | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; to pass the tape heads. | ||
| + | |||
| + |         JR      <A href="# | ||
| + | ; corresponding descriptor and data. | ||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; <font color=# | ||
| + | ; writes to microdrive the sector in CHREC. | ||
| + | |||
| + | <a name=" | ||
| + | L1F85:  | ||
| + |         LD      ($5CC9), | ||
| + | |||
| + | PUSH IX ; transfer base address | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | PUSH HL ; preserve location on machine stack. | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + |         CALL    <A href="# | ||
| + | |||
| + | <a name=" | ||
| + | L1FA1:  | ||
| + |         LD      A, | ||
| + |         CP      (IX+$0D)  | ||
| + |         JR      Z,<A href="# | ||
| + | |||
| + |         CALL    <A href="# | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; else the header was not found after a complete tape revolution. | ||
| + | |||
| + |         RST      | ||
| + | DEFB $11 ; File not found | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1FB3:  | ||
| + |         AND      | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + |         RST      | ||
| + |         DEFB    $0E             ; Drive ' | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | <a name=" | ||
| + | L1FBB:  | ||
| + |         OUT      | ||
| + | |||
| + |         LD      BC, | ||
| + |         CALL    <A href="# | ||
| + | ; record now approaches the tape heads. | ||
| + | |||
| + |         POP      | ||
| + |         CALL    <A href="# | ||
| + | ; data buffer. | ||
| + | |||
| + | LD A,$EE ; disable writing | ||
| + |         OUT      | ||
| + | |||
| + |         CALL    <A href="# | ||
| + | ; location addressed by HL into B register. | ||
| + | |||
| + | LD A,B ; transfer mask to accumulator | ||
| + | OR (HL) ; combine with any set bits already there. | ||
| + |         LD      (HL), | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; ----------------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------------- | ||
| + | ; This routine sets the contents of the 14 byte record descriptor and | ||
| + | ; the 512 byte data buffer to the same value so that they are unreadable. | ||
| + | ; This is invoked when the possibility that a secret file, whose name begins | ||
| + | ; with CHR$ 0 has been read. | ||
| + | |||
| + | <a name=" | ||
| + | L1FD4:  | ||
| + |         POP      | ||
| + | |||
| + |         LD      DE, | ||
| + |         ADD      | ||
| + | |||
| + | LD D,H ; transfer same | ||
| + | LD E,L ; address to DE and | ||
| + |         INC      | ||
| + | |||
| + |         LD      BC, | ||
| + | LDIR ; fill with HDFLAG contents. | ||
| + | |||
| + | RET ; return. | ||
| + | |||
| + | ; --------------------------------------- | ||
| + | ; THE < | ||
| + | ; --------------------------------------- | ||
| + | ; <font color=# | ||
| + | ; <font color=# | ||
| + | ; This Hook Code reads the next header and corresponding record descriptor | ||
| + | ; returning with carry flag set with header mismatch or if the name starts | ||
| + | ; with CHR$ 0 and should therefore be secret. | ||
| + | |||
| + | <a name=" | ||
| + | L1FE4:  | ||
| + | ; header to pass the tape heads. | ||
| + |         CALL    <A href="# | ||
| + | ; 14-byte record descriptor for this sector. | ||
| + |         JR      NZ,<A href="# | ||
| + | |||
| + | ; a valid header and matching descriptor has been read. | ||
| + | |||
| + |         LD      A, | ||
| + | OR A ; test for CHR$ 0. | ||
| + |         RET      | ||
| + | |||
| + | ; but if a secret file then ensure that the 14 descriptor bytes (read) and | ||
| + | ; the 512 buffer bytes (not read) are cleared to the same value. | ||
| + | |||
| + | <a name=" | ||
| + | L1FF1:  | ||
| + | SCF ; signal error. | ||
| + | RET ; return from hook code. | ||
| + | |||
| + | ; -------------------------------- | ||
| + | ; THE < | ||
| + | ; -------------------------------- | ||
| + | ; <font color=# | ||
| + | ; New in this ROM. | ||
| + | |||
| + | <a name=" | ||
| + | L1FF6:  | ||
| + |         LD      ($5CD9), | ||
| + |         CALL    <A href="# | ||
| + | RET ; return. | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | DEFB $FF ; spare | ||
| + | |||
| + | ; --- | ||
| + | |||
| + | .end | ||
| + | |||
| + | ; ----------------------------- | ||
| + | ; THE < | ||
| + | ; ----------------------------- | ||
| + | ; | ||
| + | ; X1  23734 $5CB6  FLAGS3  | ||
| + | ; X2  23735 $5CB7  VECTOR  | ||
| + | ; X10 23737 $5CB9 SBRT ; 10 bytes of Z80 code to Page ROM. | ||
| + | ; 2   23747 $5CC3  BAUD                   ; BAUD=(3500000/ | ||
| + | ; 1   23749 $5CC5  NTSTAT  | ||
| + | ; 1   23750 $5CC6  IOBORD  | ||
| + | ; N2  23751 $5CC7  SER_FL  | ||
| + | ; N2  23753 $5CC9  SECTOR  | ||
| + | ; N2  23755 $5CCB  CHADD_  | ||
| + | ; 1   23757 $5CCC  NTRESP  | ||
| + | ; --  ----- -----  ------  | ||
| + | ; 1   23758 $5CCD  NTDEST  | ||
| + | ; 1   23759 $5CCE  NTSRCE  | ||
| + | ; X2  23760 $5CD0  NTNUMB  | ||
| + | ; N1  23762 $5CD2  NTTYPE  | ||
| + | ; X1 23763 $5CD3 NTLEN ; Data block length 0 - 255. | ||
| + | ; N1 23764 $5CD4 NTDCS ; Data block checksum. | ||
| + | ; N1 23765 $5CD5 NTHDS ; Header block checksum. | ||
| + | ; --  ----- -----  ------  | ||
| + | ; N2  23766 $5CD6  D_STR1  | ||
| + | ; N1  23768 $5CD8  S_STR1  | ||
| + | ; N1  23769 $5CD9  L_STR1  | ||
| + | ; N2  23770 $5CDA  N-STR1  | ||
| + | ; N2  23772 $5CDC              | ||
| + | ; --  ----- -----  ------  | ||
| + | ; N1  23774 $5CDE  D_STR2  | ||
| + | ; N1  23775 $5CDF                         ; number.  | ||
| + | ; N1  23776 $5CE0  S_STR2  | ||
| + | ; N1  23777 $5CE1  L_STR2  | ||
| + | ; N1  23778 $5CE2  N-STR2  | ||
| + | ; N1  23779 $5CE3                         ; filename.  | ||
| + | ; N1  23780 $5CE4              | ||
| + | ; N1  23781 $5CE5              | ||
| + | ; --  ----- -----  ------  | ||
| + | ; N1 23782 $5CE6 HD_00 ; File type . _ | ||
| + | ; N2 23783 $5CE7 HD_0B ; Length of data. /\ | ||
| + | ; N2 23785 $5CE9 HD_0D ; Start of data. / | ||
| + | ; N2 23787 $5CEB HD_0F ; Program length. / | ||
| + | ; N2 23789 $5CED HD_11 ; Line number. | ||
| + | ; --  ----- -----  ------  | ||
| + | ; 1   23791 $5CEF  COPIES  | ||
| + | ; --  ----- -----  ------  | ||
| + | |||
| + | ; <font color=# | ||
| + | ; position in the standard audio tape header. The ten bytes HD_01 to HD_0A | ||
| + | ; would be the tape filename and are not held within the above area. | ||
| + | ; The area D_STR2 is multipurpose and sometimes the HD_?? variables are | ||
| + | ; copied to this region and sometimes the D_STR1 variables are copied there. | ||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; | ||
| + | ; The creation of the extra system variables moves the start of CHANS up to | ||
| + | ; address 23792.  | ||
| + | ; Microdrive Maps will be created.  | ||
| + | ; 256 bits for each possible sector and as each map is created, CHANS moves | ||
| + | ; up by another 32 bytes. | ||
| + | |||
| + | ; 10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 | ||
| + | ; 00000000 00000000 00000000 00000000 00010101 01010100 00000000 00000000 | ||
| + | ; 00000000 01100000 00000000 00000000 00000000 00000000 00000111 11111111 | ||
| + | ; 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 | ||
| + | |||
| + | ; <font color=# | ||
| + | ; is written first and sector $01 is the last to be written. Sectors $00 and | ||
| + | ; $FF are therefore always unavailable.  | ||
| + | ; sectors on a 100 foot long tape, the higher numbered sectors are later | ||
| + | ; overwritten by the lower numbered sectors. | ||
| + | ; Where the tape is spliced together one or two bad sectors will appear. | ||
| + | ; When saving bytes there isn't enough time to copy the next 512 bytes from | ||
| + | ; the program/ | ||
| + | ; code/data block is written to alternating sectors as with the 3K example | ||
| + | ; above.  | ||
| + | ; usable sectors and LOAD/SAVE operations take longer. | ||
| + | ; A growing number of Spectrum emulators feature the microdrives and they | ||
| + | ; usually make available all 254 sectors so a typical cartridge will hold 126 | ||
| + | ; Kilobytes compared to say 92 K on real hardware. | ||
| + | ; | ||
| + | ; During a LOAD operation the entire sector map is pushed on the machine stack | ||
| + | ; and the microdrive map is used to map loaded records after which the previous | ||
| + | ; map is ' | ||
| + | ; | ||
| + | ; ------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------ | ||
| + | ; The twenty bytes of the standard channels as set up my Main ROM. | ||
| + | ; | ||
| + | ; CHANS                    | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ; | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ; | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ; | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ;                          | ||
| + | ; | ||
| + | ;                          | ||
| + | |||
| + | ; ------------------------------- | ||
| + | ; THE < | ||
| + | ; ------------------------------- | ||
| + | ; | ||
| + | ;   2 IX+$00  | ||
| + | ;   2 IX+$02  | ||
| + | ;   1 IX+$04  | ||
| + | ;   2 IX+$05  | ||
| + | ;   2 IX+$07  | ||
| + | ;   2 IX+$09  | ||
| + | ;   2 IX+$0B  | ||
| + | ;   1 IX+$0D  | ||
| + | ;  10 IX+$0E  | ||
| + | ;   1 IX+$18  | ||
| + | ;   1 IX+$19  | ||
| + | ;   2 IX+$1A  | ||
| + | ; ------------------------------------------------------------------------------ | ||
| + | ;  12 IX+$1C  | ||
| + | ; ------------------------------------------------------------------------------ | ||
| + | ;   1 IX+$28  | ||
| + | ; ; bit 0 set indicates a header. | ||
| + | ;   1 IX+$29  | ||
| + | ;   2 IX+$2A  | ||
| + | ;  10 IX+$2C  | ||
| + | ;   1 IX+$36  | ||
| + | ; ------------------------------------------------------------------------------ | ||
| + | ;  12 IX+$37  | ||
| + | ; ------------------------------------------------------------------------------ | ||
| + | ;   1 IX+$43  | ||
| + | ; ; bit 0 reset indicates a record. | ||
| + | ; ; bit 1 reset no EOF, set EOF | ||
| + | ; ; bit 2 reset indicates a PRINT FILE | ||
| + | ;   1 IX+$44  | ||
| + | ;   2 IX+$45  | ||
| + | ;  10 IX+$47  | ||
| + | ;   1 IX+$51  | ||
| + | ; ------------------------------------------------------------------------------ | ||
| + | ; 512 IX+$52  | ||
| + | ;   1 +$0252  | ||
| + | |||
| + | ; ---------------------------- | ||
| + | ; THE < | ||
| + | ; ---------------------------- | ||
| + | ; | ||
| + | ;   2 IX+$00  | ||
| + | ;   2 IX+$02  | ||
| + | ;   1 IX+$04  | ||
| + | ;   2 IX+$05  | ||
| + | ;   2 IX+$07  | ||
| + | ;   2 IX+$09  | ||
| + | ;   1 IX+$0B NCIRIS  | ||
| + | ;   1 IX+$0C NCSELF  | ||
| + | ;   2 IX+$0D NCNUMB  | ||
| + | ;   1 IX+$0F NCTYPE  | ||
| + | ; 1 IX+$10 NCOBL ; Number of bytes in data block. | ||
| + | ; 1 IX+$11 NCDCS ; The data checksum. | ||
| + | ; 1 IX+$12 NCHCS ; The header checksum. | ||
| + | ; 1 IX+$13 NCCUR ; The position of last buffer char taken | ||
| + | ; 1 IX+$14 NCIBL ; Number of bytes in the input buffer. | ||
| + | ; 1 IX+$15 NCB ; A 255 byte data buffer. | ||
| + | |||
| + | ; ------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------ | ||
| + | ; | ||
| + | ;   2 IX+$00  | ||
| + | ;   2 IX+$02  | ||
| + | ;   1 IX+$04  | ||
| + | ;   2 IX+$05  | ||
| + | ;   2 IX+$07  | ||
| + | ;   2 IX+$09  | ||
| + | |||
| + | ; ------------------------------ | ||
| + | ; THE < | ||
| + | ; ------------------------------ | ||
| + | ; created by overwriting a " | ||
| + | ; | ||
| + | ;   2 IX+$00  | ||
| + | ;   2 IX+$02  | ||
| + | ;   1 IX+$04  | ||
| + | ;   2 IX+$05  | ||
| + | ;   2 IX+$07  | ||
| + | ;   2 IX+$09  | ||
| + | |||
| + | |||
| + | ; Acknowledgements | ||
| + | ; ---------------- | ||
| + | ; Dr Ian Logan for main ROM labels ( and half on Interface 1) | ||
| + | ; Dr Frank O' | ||
| + | ; Gianluca Carri for Interface 1 v1.2 labels | ||
| + | |||
| + | ; Credits | ||
| + | ; ------- | ||
| + | ; Jonathan Needle  | ||
| + | ;                        | ||
| + | ; Also for the Interface1-aware Spectaculator emulator | ||
| + | ; and help with PORTS. | ||
| + | ; Paul Dunn for help with PORTS and the SPIN emulator. | ||
| + | ; Chris Born for documentation. | ||
| + | </ | ||
| + | </ | ||
wearmouth/version_2.1647941050.txt.gz · Last modified: 2022/03/22 09:24 by evert
                
                