?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4. buffer=0x4000
  5.  
  6.         org PROGSTART
  7. cmd_begin
  8.         ld sp,0x4000
  9.         ld e,6+8 ;textmode +noturbo
  10.         OS_SETGFX
  11.         YIELD
  12.         YIELD
  13.        
  14.         ld de,filename
  15.         OS_OPENHANDLE
  16.         ld a,b
  17.         ld (curhandle),a
  18. taploop0
  19.         ld de,sizer
  20.         ld hl,3
  21. curhandle=$+1
  22.         ld b,0
  23.         push hl
  24.         OS_READHANDLE
  25.         pop bc
  26.         or a
  27.         jr nz,taploop0q ;file error!
  28.         or a
  29.         sbc hl,bc
  30.         ld a,h
  31.         or l
  32.         jr nz,taploop0q ;file too short!
  33.        
  34.         ld de,buffer
  35.         ld hl,(sizer)
  36.         dec hl ;flag byte is already loaded
  37.         ld a,(curhandle)
  38.         ld b,a
  39.         push hl
  40.         OS_READHANDLE
  41.         pop bc
  42.         or a
  43.         jr nz,taploop0q ;file error!
  44.         or a
  45.         sbc hl,bc
  46.         ld a,h
  47.         or l
  48.         jr nz,taploop0q ;file too short!
  49.        
  50.         ld ix,buffer
  51.         ld de,(sizer)
  52.         dec de
  53.         dec de
  54.         ld a,(sizer+2) ;flag
  55.         call L04C2
  56.  
  57.         LD B,50
  58.         HALT
  59.         DJNZ $-1
  60.  
  61.         jr taploop0
  62. taploop0q
  63.         ld a,(curhandle)
  64.         ld b,a
  65.         OS_CLOSEHANDLE
  66. quit
  67.         QUIT
  68.  
  69. filename
  70.         db "tilt.tap",0
  71.         ds filename+MAXPATH_sz-$
  72.  
  73. sizer
  74.         ds 3 ;2b size, 1b flag
  75.  
  76.  
  77. ;The .TAP files contain blocks of tape-saved data. All blocks start with two bytes specifying how many bytes will follow (not counting the two length bytes). Then raw tape data follows, including the flag and checksum bytes. The checksum is the bitwise XOR of all bytes including the flag byte. For example, when you execute the line SAVE "ROM" CODE 0,2 this will result:
  78.  
  79.       ;|------ Spectrum-generated data -------|      |---------|
  80.  
  81. ;13 00 00 03 52 4f 4d 7x20 02 00 00 00 00 80 f1 04 00 ff f3 af a3
  82.  
  83. ;^^^^^...... first block is 19 bytes (17 bytes+flag+checksum)
  84.       ;^^... flag byte (A reg, 00 for headers, ff for data blocks)
  85.          ;^^ first byte of header, indicating a code block
  86.  
  87. ;file name ..^^^^^^^^^^^^^
  88. ;header info ..............^^^^^^^^^^^^^^^^^
  89. ;checksum of header .........................^^
  90. ;length of second block ........................^^^^^
  91. ;flag byte ...........................................^^
  92. ;first two bytes of rom .................................^^^^^
  93. ;checksum (checkbittoggle would be a better name!).............^^
  94.  
  95. ;Note that it is possible to join .TAP files by simply stringing them together; for example, in DOS / Windows: COPY /B FILE1.TAP + FILE2.TAP ALL.TAP ; or in Unix/Linux: cp file1.tap all.tap && cat file2.tap >> all.tap
  96.  
  97. ;For completeness, I'll include the structure of a tape header. A header always consists of 17 bytes:
  98. ;Byte Length Description
  99. ;0 1 Type (0,1,2 or 3)
  100. ;1 10 Filename (padded with blanks)
  101. ;11 2 Length of data block
  102. ;13 2 Parameter 1
  103. ;15 2 Parameter 2
  104.  
  105. ;The type is 0,1,2 or 3 for a Program, Number array, Character array or Code file. A SCREEN$ file is regarded as a Code file with start address 16384 and length 6912 decimal. If the file is a Program file, parameter 1 holds the autostart line number (or a number >=32768 if no LINE parameter was given) and parameter 2 holds the start of the variable area relative to the start of the program. If it's a Code file, parameter 1 holds the start of the code block when saved, and parameter 2 holds 32768. For data files finally, the byte at position 14 decimal holds the variable name.
  106.  
  107. ;-----------------------------------
  108. ; Save header and program/data bytes
  109. ;-----------------------------------
  110. ;
  111. ;
  112.  
  113. ;; SA-BYTES
  114. L04C2   LD      HL,L053F        ; address: SA/LD-RET
  115.         PUSH    HL              ;
  116.         LD      HL,$1F80        ;
  117.         BIT     7,A             ;
  118.         JR      Z,L04D0         ; to SA-FLAG
  119.  
  120.         LD      HL,$0C98        ;
  121.  
  122. ;; SA-FLAG
  123. L04D0   EX      AF,AF'          ;
  124.        INC     DE              ;
  125.        DEC     IX              ;
  126.        DI                      ; Disable Interrupts
  127.        LD      A,$02           ;
  128.        LD      B,A             ;
  129.  
  130. ;; SA-LEADER
  131. L04D8   DJNZ    L04D8           ; to SA-LEADER
  132.  
  133.        OUT     ($FE),A         ;
  134.        XOR     $0F             ;
  135.        LD      B,$A4           ;
  136.        DEC     L               ;
  137.        JR      NZ,L04D8        ; to SA-LEADER
  138.  
  139.        DEC     B               ;
  140.        DEC     H               ;
  141.        JP      P,L04D8         ; to SA-LEADER
  142.  
  143.        LD       B,$2F          ;
  144.  
  145. ;; SA-SYNC-1
  146. L04EA   DJNZ    L04EA           ; to SA-SYNC-1
  147.  
  148.        OUT     ($FE),A         ;
  149.        LD      A,$0D           ;
  150.        LD      B,$37           ;
  151.  
  152. ;; SA-SYNC-2
  153. L04F2   DJNZ    L04F2           ; to SA-SYNC-2
  154.  
  155.        OUT     ($FE),A         ;
  156.        LD      BC,$3B0E        ;
  157.        EX      AF,AF'          ;
  158.         LD      L,A             ;
  159.         JP      L0507           ; to SA-START
  160.  
  161. ;; SA-LOOP
  162. L04FE   LD      A,D             ;
  163.         OR      E               ;
  164.         JR      Z,L050E         ; to SA-PARITY
  165.  
  166.         LD      L,(IX+$00)      ;
  167.  
  168. ;; SA-LOOP-P
  169. L0505   LD      A,H             ;
  170.         XOR     L               ;
  171.  
  172. ;; SA-START
  173. L0507   LD      H,A             ;
  174.         LD      A,$01           ;
  175.         SCF                     ; Set Carry Flag
  176.         JP      L0525           ; to SA-8-BITS
  177.  
  178. ;; SA-PARITY
  179. L050E   LD      L,H             ;
  180.         JR      L0505           ; to SA-LOOP-P
  181.  
  182. ;; SA-BIT-2
  183. L0511   LD      A,C             ;
  184.         BIT     7,B             ;
  185.  
  186. ;; SA-BIT-1
  187. L0514   DJNZ    L0514           ; to SA-BIT-1
  188.  
  189.         JR      NC,L051C        ; to SA-OUT
  190.  
  191.         LD      B,$42           ;
  192.  
  193. ;; SA-SET
  194. L051A   DJNZ    L051A           ; to SA-SET
  195.  
  196. ;; SA-OUT
  197. L051C   OUT     ($FE),A         ;
  198.         LD      B,$3E           ;
  199.         JR      NZ,L0511        ; to SA-BIT-2
  200.  
  201.         DEC     B               ;
  202.         XOR     A               ;
  203.         INC     A               ;
  204.  
  205. ;; SA-8-BITS
  206. L0525   RL      L               ;
  207.         JP      NZ,L0514        ; to SA-BIT-1
  208.  
  209.         DEC     DE              ;
  210.         INC     IX              ;
  211.         LD      B,$31           ;
  212.         LD      A,$7F           ;
  213.         IN      A,($FE)         ;
  214.         RRA                     ;
  215.         RET     NC              ;
  216.  
  217.         LD      A,D             ;
  218.         INC     A               ;
  219.         JP      NZ,L04FE        ; to SA-LOOP
  220.  
  221.         LD      B,$3B           ;
  222.  
  223. ;; SA-DELAY
  224. L053C   DJNZ    L053C           ; to SA-DELAY
  225.  
  226.         RET                     ;
  227.  
  228. ;---------------------------------------------------
  229. ; Reset border and check BREAK key for LOAD and SAVE
  230. ;---------------------------------------------------
  231. ;
  232. ;
  233.  
  234. ;; SA/LD-RET
  235. L053F   PUSH    AF              ;
  236.         LD       A,($5C48)      ; BORDCR
  237.         AND     $38             ;
  238.         RRCA                    ;
  239.         RRCA                    ;
  240.         RRCA                    ;
  241.         OUT     ($FE),A         ;
  242.         LD      A,$7F           ;
  243.         IN      A,($FE)         ;
  244.         RRA                     ;
  245.         EI                      ; Enable Interrupts
  246.         JR      C,L0554         ; to SA/LD-END
  247.  
  248.  
  249. ;; REPORT-Da
  250. ;L0552   RST     08H             ; ERROR-1
  251. ;        DEFB    $0C             ; Error Report: BREAK - CONT repeats
  252.         jp quit
  253.  
  254. ;; SA/LD-END
  255. L0554   POP     AF              ;
  256.         RET                     ;
  257.  
  258.         if 1==0
  259. ;-------------------------------------
  260. ; Load header and block of information
  261. ;-------------------------------------
  262. ;
  263. ;
  264.  
  265. ;; LD-BYTES
  266. L0556   INC     D               ;
  267.         EX      AF,AF'          ;
  268.        DEC     D               ;
  269.        DI                      ; Disable Interrupts
  270.        LD      A,$0F           ;
  271.        OUT     ($FE),A         ;
  272.        LD      HL,L053F        ; Address: SA/LD-RET
  273.        PUSH    HL              ;
  274.        IN      A,($FE)         ;
  275.        RRA                     ;
  276.        AND     $20             ;
  277.        OR      $02             ;
  278.        LD      C,A             ;
  279.        CP      A               ;
  280.  
  281. ;; LD-BREAK
  282. L056B   RET     NZ              ;
  283.  
  284. ;; LD-START
  285. L056C   CALL    L05E7           ; routine LD-EDGE-1
  286.        JR      NC,L056B        ; to LD-BREAK
  287.  
  288.        LD      HL,$0415        ;
  289.  
  290. ;; LD-WAIT
  291. L0574   DJNZ    L0574           ; to LD-WAIT
  292.  
  293.        DEC     HL              ;
  294.        LD      A,H             ;
  295.        OR      L               ;
  296.        JR      NZ,L0574        ; to LD-WAIT
  297.  
  298.        CALL    L05E3           ; routine LD-EDGE-2
  299.        JR      NC,L056B        ; to LD-BREAK
  300.  
  301. ;; LD-LEADER
  302. L0580   LD      B,$9C           ;
  303.        CALL    L05E3           ; routine LD-EDGE-2
  304.        JR      NC,L056B        ; to LD-BREAK
  305.  
  306.        LD      A,$C6           ;
  307.        CP      B               ;
  308.        JR      NC,L056C        ; to LD-START
  309.  
  310.        INC     H               ;
  311.        JR      NZ,L0580        ; to LD-LEADER
  312.  
  313. ;; LD-SYNC
  314. L058F   LD      B,$C9           ;
  315.        CALL    L05E7           ; routine LD-EDGE-1
  316.        JR      NC,L056B        ; to LD-BREAK
  317.  
  318.        LD      A,B             ;
  319.        CP      $D4             ;
  320.        JR       NC,L058F       ; to LD-SYNC
  321.  
  322.        CALL    L05E7           ; routine LD-EDGE-1
  323.        RET     NC              ;
  324.  
  325.        LD      A,C             ;
  326.        XOR     $03             ;
  327.        LD      C,A             ;
  328.        LD      H,$00           ;
  329.        LD      B,$B0           ;
  330.        JR      L05C8           ; to LD-MARKER
  331.  
  332. ;; LD-LOOP
  333. L05A9   EX      AF,AF'          ;
  334.         JR      NZ,L05B3        ; to LD-FLAG
  335.  
  336.         JR      NC,L05BD        ; to LD-VERIFY
  337.  
  338.         LD      (IX+$00),L      ;
  339.         JR      L05C2           ; to LD-NEXT
  340.  
  341. ;; LD-FLAG
  342. L05B3   RL      C               ;
  343.         XOR     L               ;
  344.         RET     NZ              ;
  345.  
  346.         LD      A,C             ;
  347.         RRA                     ;
  348.         LD      C,A             ;
  349.         INC     DE              ;
  350.         JR      L05C4           ; to LD-DEC
  351.  
  352. ;; LD-VERIFY
  353. L05BD   LD      A,(IX+$00)      ;
  354.         XOR     L               ;
  355.         RET     NZ              ;
  356.  
  357. ;; LD-NEXT
  358. L05C2   INC     IX              ;
  359.  
  360. ;; LD-DEC
  361. L05C4   DEC     DE              ;
  362.         EX      AF,AF'          ;
  363.        LD      B,$B2           ;
  364.  
  365. ;; LD-MARKER
  366. L05C8   LD      L,$01           ;
  367.  
  368. ;; LD-8-BITS
  369. L05CA   CALL    L05E3           ; routine LD-EDGE-2
  370.        RET     NC              ;
  371.  
  372.        LD      A,$CB           ;
  373.        CP      B               ;
  374.        RL      L               ;
  375.        LD      B,$B0           ;
  376.        JP      NC,L05CA        ; to LD-8-BITS
  377.  
  378.        LD      A,H             ;
  379.        XOR     L               ;
  380.        LD      H,A             ;
  381.        LD      A,D             ;
  382.        OR      E               ;
  383.        JR      NZ,L05A9        ; to LD-LOOP
  384.  
  385.        LD      A,H             ;
  386.        CP      $01             ;
  387.        RET                     ;
  388.  
  389. ;--------------------------
  390. ; Check signal being loaded
  391. ;--------------------------
  392. ;
  393. ;
  394.  
  395. ;; LD-EDGE-2
  396. L05E3   CALL    L05E7           ; routine LD-EDGE-1
  397.        RET     NC              ;
  398.  
  399. ;; LD-EDGE-1
  400. L05E7   LD      A,$16           ;
  401.  
  402. ;; LD-DELAY
  403. L05E9   DEC     A               ;
  404.        JR      NZ,L05E9        ; to LD-DELAY
  405.  
  406.        AND      A              ;
  407.  
  408. ;; LD-SAMPLE
  409. L05ED   INC     B               ;
  410.        RET     Z               ;
  411.  
  412.        LD      A,$7F           ;
  413.        IN      A,($FE)         ;
  414.        RRA                     ;
  415.        RET     NC              ;
  416.  
  417.        XOR     C               ;
  418.        AND     $20             ;
  419.        JR      Z,L05ED         ; to LD-SAMPLE
  420.  
  421.        LD      A,C             ;
  422.        CPL                     ;
  423.        LD      C,A             ;
  424.        AND     $07             ;
  425.        OR      $08             ;
  426.        OUT     ($FE),A         ;
  427.        SCF                     ; Set Carry Flag
  428.        RET                     ;
  429.  
  430. ;----------------------------------
  431. ; Entry point for all tape commands
  432. ;----------------------------------
  433. ; This is the single entry point for the four tape commands.
  434. ; The routine first determines in what context it has been called by examaning
  435. ; the low byte of the Syntax table entry which was stored in T_ADDR.
  436. ; Subtracting $EO (the present arrangement) gives a value of
  437. ; $00 - SAVE
  438. ; $01 - LOAD
  439. ; $02 - VERIFY
  440. ; $03 - MERGE
  441. ; As with all commands the address STMT-RET is on the stack.
  442.  
  443. ;; SAVE-ETC
  444. L0605   POP     AF              ; discard address STMT-RET.
  445.        LD      A,($5C74)       ; fetch T_ADDR
  446.  
  447. ; Now reduce the low byte of the Syntax table entry to give command.
  448.  
  449. L0609   SUB     L1ADF + 1 % 256 ; subtract the known offset.
  450.                                ; ( is SUB $E0 in standard ROM )
  451.  
  452.        LD      ($5C74),A       ; and put back in T_ADDR as 0,1,2, or 3
  453.                                ; for future reference.
  454.  
  455.        CALL    L1C8C           ; routine EXPT-EXP checks that a string
  456.                                ; expression follows and stacks the
  457.                                ; parameters in run-time.
  458.  
  459.        CALL    L2530           ; routine SYNTAX-Z
  460.        JR      Z,L0652         ; forward to SA-DATA if checking syntax.
  461.  
  462.        LD      BC,$0011        ; presume seventeen bytes for a header.
  463.        LD      A,($5C74)       ; fetch command from T_ADDR.
  464.        AND     A               ; test for zero - SAVE.
  465.        JR      Z,L0621         ; forward to SA-SPACE if so.
  466.  
  467.        LD      C,$22           ; else double length to thirty four.
  468.  
  469. ;; SA-SPACE
  470. L0621   RST     30H             ; BC-SPACES creates 17/34 bytes in workspace.
  471.  
  472.        PUSH    DE              ; transfer the start of new space to
  473.        POP     IX              ; the available index register.
  474.  
  475. ; ten spaces are required for the default filename but it is simpler to
  476. ; overwrite the first file-type indicator byte as well.
  477.  
  478.        LD      B,$0B           ; set counter to eleven.
  479.        LD      A,$20           ; prepare a space.
  480.  
  481. ;; SA-BLANK
  482. L0629   LD      (DE),A          ; set workspace location to space.
  483.        INC     DE              ; next location.
  484.        DJNZ    L0629           ; loop back to SA-BLANK till all eleven done.
  485.  
  486.        LD      (IX+$01),$FF    ; invert the first byte of ten character
  487.                                ; filename as a default.
  488.  
  489.        CALL    L2BF1           ; routine STK-FETCH fetches the filename
  490.                                ; parameters from the calculator stack.
  491.                                ; length of string in BC.
  492.  
  493.        LD      HL,$FFF6        ; prepare the value minus ten.
  494.        DEC     BC              ; decrement length to range 0 - 9.
  495.        ADD     HL,BC           ; trial addition.
  496.        INC     BC              ; restore length.
  497.        JR      NC,L064B        ; forward to SA-NAME if length is ten or less.
  498.  
  499.        LD      A,($5C74)       ; fetch command from T_ADDR.
  500.        AND     A               ; test for zero - SAVE.
  501.        JR      NZ,L0644        ; forward to SA-NULL if not the SAVE command.
  502.  
  503. ; but only ten characters are allowed for SAVE.
  504. ; The first ten characters of any other command parameter are acceptable.
  505. ; Weird, but necessary, if saving to sectors.
  506. ; Note. the golden rule that there are no restriction on anything is broken.
  507.  
  508. ;; REPORT-Fa
  509. L0642   RST     08H             ; ERROR-1
  510.        DEFB    $0E             ; Error Report: Invalid file name
  511.  
  512. ; continue with LOAD, MERGE, VERIFY and SAVE within ten character limit.
  513.  
  514. ;; SA-NULL
  515. L0644   LD      A,B             ; test length
  516.        OR      C               ; for zero.
  517.        JR      Z,L0652         ; forward to SA-DATA if so.
  518.  
  519.        LD      BC,$000A        ; else set/limit length to ten.
  520.  
  521. ;; SA-NAME
  522. L064B   PUSH    IX              ; push start of file descriptor.
  523.        POP     HL              ; and pop into HL.
  524.  
  525.        INC     HL              ; HL now addresses first byte of filename.
  526.        EX      DE,HL           ; transfer destination address to DE, start
  527.                                ; of string to HL.
  528.        LDIR                    ; copy ten bytes
  529.  
  530. ; the case for the null string rejoins here.
  531.  
  532. ;; SA-DATA
  533. L0652   RST     18H             ; GET-CHAR
  534.        CP      $E4             ; is character the token 'DATA' ?
  535.        JR      NZ,L06A0        ; forward to SA-SCR$ to consider SCREEN$ if
  536.                                ; not.
  537.  
  538. ; continue to consider DATA.
  539.  
  540.        LD      A,($5C74)       ; fetch command from T_ADDR
  541.        CP      $03             ; is it 'VERIFY' ?
  542.        JP      Z,L1C8A         ; jump forward to REPORT-C if so.
  543.                                ; 'Nonsense in basic'
  544.  
  545. ; continue with SAVE, LOAD, MERGE of DATA.
  546.  
  547.        RST     20H             ; NEXT-CHAR
  548.        CALL    L28B2           ; routine LOOK-VARS searches variables area
  549.                                ; returning with carry reset if found or
  550.                                ; checking syntax.
  551.        SET     7,C             ; signal result. ????
  552.        JR      NC,L0672        ; forward to SA-V-OLD if found or syntax path.
  553.  
  554.        LD      HL,$0000        ;
  555.        LD      A,($5C74)       ; fetch command from T_ADDR
  556.        DEC     A               ; test for 1 - LOAD
  557.        JR      Z,L0685         ; forward to SA-V-NEW with LOAD DATA.
  558.                                ; It is allowable to load a saved array into
  559.                                ; an array of a different name.
  560.  
  561. ; otherwise the variable was not found in run-time with SAVE/MERGE.
  562.  
  563. ;; REPORT-2a
  564. L0670   RST     08H             ; ERROR-1
  565.        DEFB    $01             ; Error Report: Variable not found
  566.  
  567. ; continue with SAVE/LOAD/ DATA
  568.  
  569. ;; SA-V-OLD
  570. L0672   JP      NZ,L1C8A        ; to REPORT-C if not an array variable. ????
  571.                                ; 'Nonsense in basic'
  572.  
  573.  
  574.        CALL    L2530           ; routine SYNTAX-Z
  575.        JR      Z,L0692         ; forward to SA-DATA-1 if checking syntax.
  576.  
  577.        INC     HL              ; step past single character variable name.
  578.        LD      A,(HL)          ; fetch low byte of length.
  579.        LD      (IX+$0B),A      ; place in descriptor.
  580.        INC     HL              ; point to high byte.
  581.        LD      A,(HL)          ; and transfer that
  582.        LD      (IX+$0C),A      ; to descriptor.
  583.        INC     HL              ; increase pointer within variable.
  584.  
  585. ;; SA-V-NEW
  586. L0685   LD      (IX+$0E),C      ; load
  587.        LD      A,$01           ; default to type ??
  588.        BIT     6,C             ; test result
  589.        JR      Z,L068F         ; forward to SA-V-TYPE if numeric.
  590.  
  591.        INC     A               ; set type to string.
  592.  
  593. ;; SA-V-TYPE
  594. L068F   LD      (IX+$00),A      ; place type 0, 1 or 2 in descriptor.
  595.  
  596. ;; SA-DATA-1
  597. L0692   EX      DE,HL           ; save var pointer in DE
  598.  
  599.        RST     20H             ; NEXT-CHAR
  600.        CP      $29             ; is character ')'?
  601.        JR      NZ,L0672        ; back if not to SA-V-OLD to
  602.  
  603.  
  604.        RST     20H             ; NEXT-CHAR advances character address.
  605.        CALL    L1BEE           ; routine CHECK-END errors if not end of
  606.                                ; the statement.
  607.  
  608.        EX      DE,HL           ; bring back variables data pointer.
  609.        JP      L075A           ; jump forward to SA-ALL
  610.  
  611. ; ---
  612. ; the branch was here to consider a 'SCREEN$', the display file.
  613.  
  614. ;; SA-SCR$
  615. L06A0   CP      $AA             ; is character the token 'SCREEN$' ?
  616.        JR      NZ,L06C3        ; forward to SA-CODE if not.
  617.  
  618.        LD      A,($5C74)       ; fetch command from T_ADDR
  619.        CP      $03             ; is it MERGE ?
  620.        JP       Z,L1C8A        ; jump to REPORT-C if so.
  621.                                ; 'Nonsense in basic'
  622.  
  623. ; continue with SAVE/LOAD/VERIFY SCREEN$.
  624.  
  625.        RST     20H             ; NEXT-CHAR
  626.        CALL    L1BEE           ; routine CHECK-END errors if not end of
  627.                                ; statement.
  628.  
  629. ; continue in runtime.
  630.  
  631.        LD      (IX+$0B),$00    ; set descriptor length
  632.        LD      (IX+$0C),$1B    ; to $1b00 to include bitmaps and attributes.
  633.  
  634.        LD      HL,$4000        ; set start to display file start.
  635.        LD      (IX+$0D),L      ; place start in
  636.        LD      (IX+$0E),H      ; the descriptor.
  637.        JR      L0710           ; forward to SA-TYPE-3
  638.  
  639. ; ---
  640. ; the branch was here to consider CODE.
  641.  
  642. ;; SA-CODE
  643. L06C3   CP      $AF             ; is character the token 'CODE' ?
  644.        JR      NZ,L0716        ; forward if not to SA-LINE to consider an
  645.                                ; auto-started basic program.
  646.  
  647.        LD      A,($5C74)       ; fetch command from T_ADDR
  648.        CP      $03             ; is it MERGE ?
  649.        JP      Z,L1C8A         ; jump forward to REPORT-C if so.
  650.                                ; 'Nonsense in basic'
  651.  
  652.  
  653.        RST     20H             ; NEXT-CHAR advances character address.
  654.        CALL    L2048           ; routine PR-ST-END checks if a carriage
  655.                                ; return or ':' follows.
  656.        JR      NZ,L06E1        ; forward to SA-CODE-1 if there are parameters.
  657.  
  658.        LD      A,($5C74)       ; else fetch the command from T_ADDR.
  659.        AND     A               ; test for zero - SAVE without a specification.
  660.        JP      Z,L1C8A         ; jump to REPORT-C if so.
  661.                                ; 'Nonsense in basic'
  662.  
  663. ; for LOAD/VERIFY put zero on stack to signify handle at location saved from.
  664.  
  665.        CALL    L1CE6           ; routine USE-ZERO
  666.        JR      L06F0           ; forward to SA-CODE-2
  667.  
  668. ; ---
  669. ; if there are more characters after CODE expect start and possibly length.
  670.  
  671. ;; SA-CODE-1
  672. L06E1   CALL    L1C82           ; routine EXPT-1NUM checks for numeric
  673.                                ; expression and stacks it in run-time.
  674.  
  675.        RST     18H             ; GET-CHAR
  676.        CP      $2C             ; does a comma follow ?
  677.        JR      Z,L06F5         ; forward if so to SA-CODE-3
  678.  
  679. ; else allow saved code to be loaded to a specified address.
  680.  
  681.        LD      A,($5C74)       ; fetch command from T_ADDR.
  682.        AND     A               ; is the command SAVE which requires length ?
  683.        JP      Z,L1C8A         ; jump to REPORT-C if so.
  684.                                ; 'Nonsense in basic'
  685.  
  686. ; the command LOAD code may rejoin here with zero stacked as start.
  687.  
  688. ;; SA-CODE-2
  689. L06F0   CALL    L1CE6           ; routine USE-ZERO stacks zero for length.
  690.        JR      L06F9           ; forward to SA-CODE-4
  691.  
  692. ; ---
  693. ; the branch was here with SAVE CODE start,
  694.  
  695. ;; SA-CODE-3
  696. L06F5   RST     20H             ; NEXT-CHAR advances character address.
  697.        CALL    L1C82           ; routine EXPT-1NUM checks for exprssion
  698.                                ; and stacks in run-time.
  699.  
  700. ; paths converge here and nothing must follow.
  701.  
  702. ;; SA-CODE-4
  703. L06F9   CALL    L1BEE           ; routine CHECK-END errors with extraneous
  704.                                ; characters and quits if checking syntax.
  705.  
  706. ; in run-time there are two 16-bit parameters on the calculator stack.
  707.  
  708.        CALL    L1E99           ; routine FIND-INT2 gets length.
  709.        LD      (IX+$0B),C      ; place length
  710.        LD      (IX+$0C),B      ; in descriptor.
  711.        CALL    L1E99           ; routine FIND-INT2 gets start.
  712.        LD      (IX+$0D),C      ; place start
  713.        LD      (IX+$0E),B      ; in descriptor.
  714.        LD      H,B             ; transfer the
  715.        LD      L,C             ; start to HL also.
  716.  
  717. ;; SA-TYPE-3
  718. L0710   LD      (IX+$00),$03    ; place type 3 - code in descriptor.
  719.        JR      L075A           ; forward to SA-ALL.
  720.  
  721. ; ---
  722. ; the branch was here with basic to consider an optional auto-start line
  723. ; number.
  724.  
  725. ;; SA-LINE
  726. L0716   CP      $CA             ; is character the token 'LINE' ?
  727.        JR      Z,L0723         ; forward to SA-LINE-1 if so.
  728.  
  729. ; else all possibilities have been considered and nothing must follow.
  730.  
  731.        CALL    L1BEE           ; routine CHECK-END
  732.  
  733. ; continue in run-time to save basic without auto-start.
  734.  
  735.        LD      (IX+$0E),$80    ; place high line number in descriptor to
  736.                                ; disable auto-start.
  737.        JR      L073A           ; forward to SA-TYPE-0 to save program.
  738.  
  739. ; ---
  740. ; the branch was here to consider auto-start.
  741.  
  742. ;; SA-LINE-1
  743. L0723   LD      A,($5C74)       ; fetch command from T_ADDR
  744.        AND     A               ; test for SAVE.
  745.        JP      NZ,L1C8A        ; to REPORT-C with anything else.
  746.                                ; 'Nonsense in basic'
  747.  
  748. ;
  749.  
  750.        RST     20H             ; NEXT-CHAR
  751.        CALL    L1C82           ; routine EXPT-1NUM checks for numeric
  752.                                ; expression and stacks in run-time.
  753.        CALL    L1BEE           ; routine CHECK-END quits if syntax path.
  754.        CALL    L1E99           ; routine FIND-INT2 fetches the numeric
  755.                                ; expression.
  756.        LD      (IX+$0D),C      ; place the auto-start
  757.        LD      (IX+$0E),B      ; line number in the descriptor.
  758.  
  759. ; Note. this isn't checked, but is handled by system.
  760. ; If the user typed 40000 instead of 4000 then it won't auto-start
  761. ; at line 4000, or indeed, at all.
  762.  
  763. ; continue to save program and any variables.
  764.  
  765. ;; SA-TYPE-0
  766. L073A   LD      (IX+$00),$00    ; place type zero - program in descriptor.
  767.         LD      HL,($5C59)      ; fetch E_LINE to HL.
  768.         LD      DE,($5C53)      ; fetch PROG to DE.
  769.         SCF                     ; set carry flag to calculate from end of
  770.                                 ; variables E_LINE -1.
  771.         SBC     HL,DE           ; subtract to give total length.
  772.  
  773.         LD      (IX+$0B),L      ; place total length
  774.         LD      (IX+$0C),H      ; in descriptor.
  775.         LD      HL,($5C4B)      ; load HL from system variable VARS
  776.         SBC     HL,DE           ; subtract to give program length.
  777.         LD      (IX+$0F),L      ; place length of program
  778.         LD      (IX+$10),H      ; in the descriptor.
  779.         EX      DE,HL           ; start to HL, length to DE.
  780.  
  781. ;; SA-ALL
  782. L075A   LD      A,($5C74)       ; fetch command from T_ADDR
  783.         AND     A               ; test for zero - SAVE.
  784.         JP      Z,L0970         ; jump forward to SA-CONTRL with SAVE  ->
  785.  
  786. ; ---
  787. ; continue with LOAD, MERGE and VERIFY.
  788.  
  789.         PUSH    HL              ; save start.
  790.         LD      BC,$0011        ; prepare to add seventeen
  791.         ADD     IX,BC           ; to point IX at second descriptor.
  792.  
  793. ;; LD-LOOK-H
  794. L0767   PUSH    IX              ; save IX
  795.         LD      DE,$0011        ; seventeen bytes
  796.         XOR     A               ; reset zero flag
  797.         SCF                     ; set carry flag
  798.         CALL    L0556           ; routine LD-BYTES loads a header from tape
  799.                                 ; to second descriptor.
  800.         POP     IX              ; restore IX.
  801.         JR      NC,L0767        ; loop back to LD-LOOK-H until header found.
  802.  
  803.         LD      A,$FE           ; select system channel 'S'
  804.                                 ; user is at liberty to re-attach stream 2.
  805.         CALL    L1601           ; routine CHAN-OPEN opens it.
  806.         LD      (IY+$52),$03    ; set SCR_CT to 3 lines.
  807.         LD      C,$80           ; C has bit 7 set.
  808.         LD      A,(IX+$00)      ; fetch loaded header type to A
  809.         CP      (IX-$11)        ; compare with expected type.
  810.         JR      NZ,L078A        ; forward to LD-TYPE with mis-match.
  811.  
  812.         LD      C,$F6           ; 11110110  -10
  813.  
  814. ;; LD-TYPE
  815. L078A   CP      $04             ; check if type in acceptable range 0 - 3.
  816.         JR      NC,L0767        ; back to LD-LOOK-H with 4 and over.
  817.  
  818. ; else A indicates type 0-3.
  819.  
  820.         LD      DE,L09C0        ; base of last 4 tape messages
  821.         PUSH    BC              ; save BC
  822.         CALL    L0C0A           ; routine PO-MSG outputs relevant message.
  823.         POP     BC              ; restore
  824.  
  825.         PUSH    IX              ; transfer IX,
  826.         POP     DE              ; the 2nd descriptor, to DE.
  827.         LD      HL,$FFF0        ; prepare minus seventeen.
  828.         ADD     HL,DE           ; add to point HL to 1st descriptor.
  829.         LD      B,$0A           ; the count will be ten characters for the
  830.                                 ; filename.
  831.         LD      A,(HL)          ;
  832.         INC     A               ;
  833.         JR      NZ,L07A6        ; to LD-NAME
  834.  
  835.         LD      A,C             ;
  836.         ADD     A,B             ;
  837.         LD      C,A             ;
  838.  
  839. ;; LD-NAME
  840. L07A6   INC     DE              ; address next input name
  841.         LD      A,(DE)          ; fetch character
  842.         CP      (HL)            ; compare to expected
  843.         INC     HL              ; address next expected character
  844.         JR      NZ,L07AD        ; forward to LD-CH-PR with mismatch
  845.  
  846.         INC     C               ; increment count
  847.  
  848. ;; LD-CH-PR
  849. L07AD   RST     10H             ; PRINT-A-1 prints character
  850.         DJNZ    L07A6           ; loop back to LD-NAME for ten characters.
  851.  
  852.         BIT     7,C             ; test if all matched
  853.         JR      NZ,L0767        ; back to LD-LOOK-H if not
  854.  
  855. ; else
  856.  
  857.         LD      A,$0D           ; prepare carriage return.
  858.         RST     10H             ; PRINT-A-1 outputs it.
  859.  
  860. ;
  861.  
  862.         POP     HL              ; restore xx
  863.         LD      A,(IX+$00)      ; fetch incoming type
  864.         CP      $03             ; compare with code
  865.         JR      Z,L07CB         ; forward to VR-CONTROL if equal
  866.  
  867.         LD      A,($5C74)       ; fetch command from T_ADDR
  868.         DEC     A               ; was it LOAD ?
  869.         JP      Z,L0808         ; jump forward to LD-CONTRL if so
  870.  
  871.         CP      $02             ; was command MERGE ?
  872.         JP      Z,L08B6         ; jump forward to ME-CONTRL if so.
  873.  
  874. ; else continue into VERIFY control routine.
  875.  
  876. ;----------------------
  877. ; Handle VERIFY control
  878. ;----------------------
  879. ;
  880. ;
  881.  
  882. ;; VR-CONTROL
  883. L07CB   PUSH    HL              ;
  884.         LD      L,(IX-$06)      ;
  885.         LD      H,(IX-$05)      ;
  886.         LD      E,(IX+$0B)      ;
  887.         LD      D,(IX+$0C)      ;
  888.         LD      A,H             ;
  889.         OR      L               ;
  890.         JR      Z,L07E9         ; to VR-CONT-1
  891.  
  892.         SBC     HL,DE           ;
  893.         JR      C,L0806         ; to REPORT-R
  894.  
  895.         JR      Z,L07E9         ; to VR-CONT-1
  896.  
  897.         LD      A,(IX+$00)      ;
  898.         CP      $03             ;
  899.         JR      NZ,L0806        ; to REPORT-R
  900.  
  901. ;; VR-CONT-1
  902. L07E9   POP     HL              ;
  903.         LD      A,H             ;
  904.         OR      L               ;
  905.         JR      NZ,L07F4        ; to VR-CONT-2
  906.  
  907.         LD      L,(IX+$0D)      ;
  908.         LD      H,(IX+$0E)      ;
  909.  
  910. ;; VR-CONT-2
  911. L07F4   PUSH    HL              ;
  912.         POP     IX              ;
  913.         LD      A,($5C74)       ; T_ADDR
  914.         CP      $02             ;
  915.         SCF                     ; Set Carry Flag
  916.         JR      NZ,L0800        ; to VR-CONT-3
  917.  
  918.         AND     A               ;
  919.  
  920. ;; VR-CONT-3
  921. L0800   LD      A,$FF           ;
  922.  
  923. ;------------------
  924. ; Load a data block
  925. ;------------------
  926. ;
  927. ;
  928.  
  929. ;; LD-BLOCK
  930. L0802   CALL    L0556           ; routine LD-BYTES
  931.         RET     C               ;
  932.  
  933.  
  934. ;; REPORT-R
  935. L0806   RST     08H             ; ERROR-1
  936.         DEFB    $1A             ; Error Report: Tape loading error
  937.  
  938. ;--------------------
  939. ; Handle LOAD control
  940. ;--------------------
  941. ;
  942. ;
  943.  
  944. ;; LD-CONTRL
  945. L0808   LD      E,(IX+$0B)      ;
  946.         LD      D,(IX+$0C)      ;
  947.         PUSH    HL              ;
  948.         LD      A,H             ;
  949.         OR      L               ;
  950.         JR      NZ,L0819        ; to LD-CONT-1
  951.  
  952.         INC     DE              ;
  953.         INC     DE              ;
  954.         INC     DE              ;
  955.         EX      DE,HL           ;
  956.         JR      L0825           ; to LD-CONT-2
  957.  
  958. ;; LD-CONT-1
  959. L0819   LD      L,(IX-$06)      ;
  960.         LD      H,(IX-$05)      ;
  961.         EX      DE,HL           ;
  962.         SCF                     ; Set Carry Flag
  963.         SBC     HL,DE           ;
  964.         JR      C,L082E         ; to LD-DATA
  965.  
  966. ;; LD-CONT-2
  967. L0825   LD      DE,$0005        ;
  968.         ADD     HL,DE           ;
  969.         LD      B,H             ;
  970.         LD      C,L             ;
  971.         CALL    L1F05           ; routine TEST-ROOM
  972.  
  973. ;; LD-DATA
  974. L082E   POP     HL              ;
  975.         LD      A,(IX+$00)      ;
  976.         AND     A               ;
  977.         JR      Z,L0873         ; to LD-PROG
  978.  
  979.         LD      A,H             ;
  980.         OR      L               ;
  981.         JR      Z,L084C         ; to LD-DATA-1
  982.  
  983.         DEC     HL              ;
  984.         LD      B,(HL)          ;
  985.         DEC     HL              ;
  986.         LD      C,(HL)          ;
  987.         DEC     HL              ;
  988.         INC     BC              ;
  989.         INC     BC              ;
  990.         INC     BC              ;
  991.         LD      ($5C5F),IX      ; X_PTR
  992.         CALL    L19E8           ; routine RECLAIM-2
  993.         LD      IX,($5C5F)      ; X_PTR
  994.  
  995. ;; LD-DATA-1
  996. L084C   LD      HL,($5C59)      ; E_LINE
  997.         DEC     HL              ;
  998.         LD      C,(IX+$0B)      ;
  999.         LD      B,(IX+$0C)      ;
  1000.         PUSH    BC              ;
  1001.         INC     BC              ;
  1002.         INC     BC              ;
  1003.         INC     BC              ;
  1004.         LD      A,(IX-$03)      ;
  1005.         PUSH    AF              ;
  1006.         CALL    L1655           ; routine MAKE-ROOM
  1007.         INC     HL              ;
  1008.         POP     AF              ;
  1009.         LD      (HL),A          ;
  1010.         POP     DE              ;
  1011.         INC     HL              ;
  1012.         LD      (HL),E          ;
  1013.         INC     HL              ;
  1014.         LD      (HL),D          ;
  1015.         INC     HL              ;
  1016.         PUSH    HL              ;
  1017.         POP     IX              ;
  1018.         SCF                     ; Set Carry Flag
  1019.         LD      A,$FF           ;
  1020.         JP      L0802           ; to LD-BLOCK
  1021.  
  1022. ;; LD-PROG
  1023. L0873   EX      DE,HL           ;
  1024.         LD      HL,($5C59)      ; E_LINE
  1025.         DEC     HL              ;
  1026.         LD      ($5C5F),IX      ; X_PTR
  1027.         LD      C,(IX+$0B)      ;
  1028.         LD      B,(IX+$0C)      ;
  1029.         PUSH    BC              ;
  1030.         CALL    L19E5           ; routine RECLAIM-1
  1031.         POP     BC              ;
  1032.         PUSH    HL              ;
  1033.         PUSH    BC              ;
  1034.         CALL    L1655           ; routine MAKE-ROOM
  1035.         LD      IX,($5C5F)      ; X_PTR
  1036.         INC     HL              ;
  1037.         LD      C,(IX+$0F)      ;
  1038.         LD      B,(IX+$10)      ;
  1039.         ADD     HL,BC           ;
  1040.         LD      ($5C4B),HL      ; VARS
  1041.         LD      H,(IX+$0E)      ;
  1042.         LD      A,H             ;
  1043.         AND     $C0             ;
  1044.         JR      NZ,L08AD        ; to LD-PROG-1
  1045.  
  1046.         LD      L,(IX+$0D)      ;
  1047.         LD      ($5C42),HL      ; NEWPPC
  1048.         LD      (IY+$0A),$00    ; NSPPC
  1049.  
  1050. ;; LD-PROG-1
  1051. L08AD   POP     DE              ;
  1052.         POP     IX              ;
  1053.         SCF                     ; Set Carry Flag
  1054.         LD      A,$FF           ;
  1055.         JP      L0802           ; to LD-BLOCK
  1056.  
  1057. ;---------------------
  1058. ; Handle MERGE control
  1059. ;---------------------
  1060. ;
  1061. ;
  1062.  
  1063. ;; ME-CONTRL
  1064. L08B6   LD      C,(IX+$0B)      ;
  1065.         LD      B,(IX+$0C)      ;
  1066.         PUSH    BC              ;
  1067.         INC     BC              ;
  1068.  
  1069.         RST     30H             ; BC-SPACES
  1070.         LD      (HL),$80        ;
  1071.         EX      DE,HL           ;
  1072.         POP     DE              ;
  1073.         PUSH    HL              ;
  1074.         PUSH    HL              ;
  1075.         POP     IX              ;
  1076.         SCF                     ; Set Carry Flag
  1077.         LD      A,$FF           ;
  1078.         CALL    L0802           ; routine LD-BLOCK
  1079.         POP     HL              ;
  1080.         LD      DE,($5C53)      ; PROG
  1081.  
  1082. ;; ME-NEW-LP
  1083. L08D2   LD      A,(HL)          ;
  1084.         AND     $C0             ;
  1085.         JR      NZ,L08F0        ; to ME-VAR-LP
  1086.  
  1087. ;; ME-OLD-LP
  1088. L08D7   LD      A,(DE)          ;
  1089.         INC     DE              ;
  1090.         CP      (HL)            ;
  1091.         INC     HL              ;
  1092.         JR      NZ,L08DF        ; to ME-OLD-L1
  1093.  
  1094.         LD      A,(DE)          ;
  1095.         CP      (HL)            ;
  1096.  
  1097. ;; ME-OLD-L1
  1098. L08DF   DEC     DE              ;
  1099.         DEC     HL              ;
  1100.         JR      NC,L08EB        ; to ME-NEW-L2
  1101.  
  1102.         PUSH    HL              ;
  1103.         EX      DE,HL           ;
  1104.         CALL    L19B8           ; routine NEXT-ONE
  1105.         POP     HL              ;
  1106.         JR      L08D7           ; to ME-OLD-LP
  1107.  
  1108. ;; ME-NEW-L2
  1109. L08EB   CALL    L092C           ; routine ME-ENTER
  1110.         JR      L08D2           ; to ME-NEW-LP
  1111.  
  1112. ;; ME-VAR-LP
  1113. L08F0   LD      A,(HL)          ;
  1114.         LD      C,A             ;
  1115.         CP      $80             ;
  1116.         RET     Z               ;
  1117.  
  1118.         PUSH    HL              ;
  1119.         LD      HL,($5C4B)      ; VARS
  1120.  
  1121. ;; ME-OLD-VP
  1122. L08F9   LD      A,(HL)          ;
  1123.         CP      $80             ;
  1124.         JR      Z,L0923         ; to ME-VAR-L2
  1125.  
  1126.         CP      C               ;
  1127.         JR      Z,L0909         ; to ME-OLD-V2
  1128.  
  1129. ;; ME-OLD-V1
  1130. L0901   PUSH    BC              ;
  1131.         CALL    L19B8           ; routine NEXT-ONE
  1132.         POP     BC              ;
  1133.         EX      DE,HL           ;
  1134.         JR      L08F9           ; to ME-OLD-VP
  1135.  
  1136. ;; ME-OLD-V2
  1137. L0909   AND     $E0             ;
  1138.         CP      $A0             ;
  1139.         JR      NZ,L0921        ; to ME-VAR-L1
  1140.  
  1141.         POP     DE              ;
  1142.         PUSH    DE              ;
  1143.         PUSH    HL              ;
  1144.  
  1145. ;; ME-OLD-V3
  1146. L0912   INC     HL              ;
  1147.         INC     DE              ;
  1148.         LD      A,(DE)          ;
  1149.         CP      (HL)            ;
  1150.         JR      NZ,L091E        ; to ME-OLD-V4
  1151.  
  1152.         RLA                     ;
  1153.         JR      NC,L0912        ; to ME-OLD-V3
  1154.  
  1155.         POP     HL              ;
  1156.         JR      L0921           ; to ME-VAR-L1
  1157.  
  1158. ;; ME-OLD-V4
  1159. L091E   POP     HL              ;
  1160.         JR      L0901           ; to ME-OLD-V1
  1161.  
  1162. ;; ME-VAR-L1
  1163. L0921   LD      A,$FF           ;
  1164.  
  1165. ;; ME-VAR-L2
  1166. L0923   POP     DE              ;
  1167.         EX      DE,HL           ;
  1168.         INC     A               ;
  1169.         SCF                     ; Set Carry Flag
  1170.         CALL    L092C           ; routine ME-ENTER
  1171.         JR      L08F0           ; to ME-VAR-LP
  1172.  
  1173. ;-------------------------
  1174. ; Merge a Line or Variable
  1175. ;-------------------------
  1176. ;
  1177. ;
  1178.  
  1179. ;; ME-ENTER
  1180. L092C   JR      NZ,L093E        ; to ME-ENT-1
  1181.  
  1182.         EX      AF,AF'          ;
  1183.        LD      ($5C5F),HL      ; X_PTR
  1184.        EX      DE,HL           ;
  1185.        CALL    L19B8           ; routine NEXT-ONE
  1186.        CALL    L19E8           ; routine RECLAIM-2
  1187.        EX      DE,HL           ;
  1188.        LD      HL,($5C5F)      ; X_PTR
  1189.        EX      AF,AF'          ;
  1190.  
  1191. ;; ME-ENT-1
  1192. L093E   EX      AF,AF'          ;
  1193.        PUSH    DE              ;
  1194.        CALL    L19B8           ; routine NEXT-ONE
  1195.        LD      ($5C5F),HL      ; X_PTR
  1196.        LD      HL,($5C53)      ; PROG
  1197.        EX      (SP),HL         ;
  1198.        PUSH    BC              ;
  1199.        EX      AF,AF'          ;
  1200.         JR      C,L0955         ; to ME-ENT-2
  1201.  
  1202.         DEC     HL              ;
  1203.         CALL    L1655           ; routine MAKE-ROOM
  1204.         INC     HL              ;
  1205.         JR      L0958           ; to ME-ENT-3
  1206.  
  1207. ;; ME-ENT-2
  1208. L0955   CALL    L1655           ; routine MAKE-ROOM
  1209.  
  1210. ;; ME-ENT-3
  1211. L0958   INC     HL              ;
  1212.         POP     BC              ;
  1213.         POP     DE              ;
  1214.         LD      ($5C53),DE      ; PROG
  1215.         LD      DE,($5C5F)      ; X_PTR
  1216.         PUSH    BC              ;
  1217.         PUSH    DE              ;
  1218.         EX      DE,HL           ;
  1219.         LDIR                    ; Copy Bytes
  1220.         POP     HL              ;
  1221.         POP     BC              ;
  1222.         PUSH    DE              ;
  1223.         CALL    L19E8           ; routine RECLAIM-2
  1224.         POP     DE              ;
  1225.         RET                     ;
  1226.  
  1227.         endif
  1228.  
  1229.  
  1230. ;--------------------
  1231. ; Handle SAVE control
  1232. ;--------------------
  1233. ;
  1234. ;hl=addr
  1235. ;ix=header
  1236.  
  1237. ;; SA-CONTRL
  1238. L0970   PUSH    HL              ;
  1239.         ;LD      A,$FD           ;
  1240.         ;CALL    L1601           ; routine CHAN-OPEN
  1241.         ;XOR     A               ; clear to address table directly
  1242.         ;LD      DE,L09A1        ; address: tape-msgs
  1243.         ;CALL    L0C0A           ; routine PO-MSG -
  1244.                                 ; 'Start tape then press any key.'
  1245.  
  1246.         ;SET     5,(IY+$02)      ; TV_FLAG  - Signal lower screen requires
  1247.                                 ; clearing
  1248.         ;CALL    L15D4           ; routine WAIT-KEY
  1249.         PUSH    IX              ;
  1250.         LD      DE,$0011        ;
  1251.         XOR     A               ;
  1252.         CALL    L04C2           ; routine SA-BYTES
  1253.         POP     IX              ;
  1254.         LD      B,$32           ;
  1255.  
  1256. ;; SA-1-SEC
  1257. L0991   HALT                    ; Wait for Interrupt
  1258.         DJNZ    L0991           ; to SA-1-SEC
  1259.  
  1260.         LD      E,(IX+$0B)      ;
  1261.         LD      D,(IX+$0C)      ;
  1262.         LD      A,$FF           ;
  1263.         POP     IX              ;
  1264.         JP      L04C2           ; to SA-BYTES
  1265.  
  1266.  
  1267.         if 1==0
  1268. ;-------------------------
  1269. ; Canned cassette messages
  1270. ;-------------------------
  1271. ; The last-character-inverted Cassette messages.
  1272. ; Start with normal initial step-over byte.
  1273.  
  1274. ;; tape-msgs
  1275. L09A1   DEFB    $80
  1276.         DEFB    "Start tape, then press any key"
  1277. L09C0   DEFB    '.'+$80
  1278.         DEFB    $0D
  1279.         DEFB    "Program:",' '+$80
  1280.         DEFB    $0D
  1281.         DEFB    "Number array:",' '+$80
  1282.         DEFB    $0D
  1283.         DEFB    "Character array:",' '+$80
  1284.         DEFB    $0D
  1285.         DEFB    "Bytes:",' '+$80
  1286.         endif
  1287.  
  1288. cmd_end
  1289.         savebin "playtap.com",cmd_begin,cmd_end-cmd_begin
  1290.  
  1291.         LABELSLIST "../../us/user.l"
  1292.