Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions library-asm/load.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include once <alloc.asm>
#include once <free.asm>
#include once <print.asm>

#ifndef HIDE_LOAD_MSG
# include once <print.asm>
#endif

LOAD_CODE:
; This function will implement the LOAD CODE Routine
Expand All @@ -22,7 +25,9 @@ LOAD_CODE:
LOCAL LD_CH_PR
LOCAL LOAD_END
LOCAL VR_CONTROL, VR_CONT_1, VR_CONT_2
LOCAL MEM0

MEM0 EQU 5C92h ; Temporary memory buffer
HEAD1 EQU MEM0 + 8 ; Uses CALC Mem for temporary storage
; Must skip first 8 bytes used by
; PRINT routine
Expand Down Expand Up @@ -134,7 +139,10 @@ LD_TYPE:
cp 4 ; check if type in acceptable range 0 - 3.
jr nc, LD_LOOK_H ; back to LD-LOOK-H with 4 and over.
; else A indicates type 0-3.
#ifndef HIDE_LOAD_MSG
call PRINT_TAPE_MESSAGES; Print tape msg
#endif

ld hl, HEAD1 + 1 ; point HL to 1st descriptor.
ld de, (TMP_HEADER) ; point DE to 2nd descriptor.
ld b, 10 ; the count will be ten characters for the
Expand Down Expand Up @@ -167,16 +175,20 @@ LD_NAME:

;; LD-CH-PR
LD_CH_PR:
#ifndef HIDE_LOAD_MSG
call __PRINTCHAR ; PRINT-A prints character
#endif
djnz LD_NAME ; loop back to LD-NAME for ten characters.

bit 7, c ; test if all matched
jr nz, LD_LOOK_H ; back to LD-LOOK-H if not

; else print a terminal carriage return.

#ifndef HIDE_LOAD_MSG
ld a, 0Dh ; prepare carriage return.
call __PRINTCHAR ; PRINT-A outputs it.
#endif

ld a, (HEAD1)
cp 03 ; Only "bytes:" header is used un ZX BASIC
Expand All @@ -197,7 +209,7 @@ VR_CONTROL:
jr z, VR_CONT_1 ; forward to VR-CONT-1 if length unspecified
; e.g. LOAD "x" CODE
sbc hl, de
jr nz, LOAD_ERROR ; Lenghts don't match
jr nz, LOAD_ERROR ; Lengths don't match

VR_CONT_1:
ld hl, HEAD1 + 13 ; fetch start of old data (orig. header)
Expand Down Expand Up @@ -262,6 +274,7 @@ LD_BYTES_NOINTER:
ENDP


#ifndef HIDE_LOAD_MSG
PRINT_TAPE_MESSAGES:

PROC
Expand Down Expand Up @@ -310,3 +323,5 @@ PRINT_TAPE_MSG:
ret

ENDP

#endif
50 changes: 30 additions & 20 deletions tests/functional/code00.asm
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
ENDP
#line 3 "load.asm"
#line 1 "print.asm"
; vim:ts=4:sw=4:et:
; vim:ts=4:sw=4:et:
; PRINT command routine
; Does not print attribute. Use PRINT_STR or PRINT_NUM for that
Expand Down Expand Up @@ -523,7 +524,7 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var.
POSX EQU S_POSN ; Current POS X
POSY EQU S_POSN + 1 ; Current POS Y
ENDP
#line 6 "print.asm"
#line 7 "print.asm"
#line 1 "cls.asm"
; JUMPS directly to spectrum CLS
; This routine does not clear lower screen
Expand Down Expand Up @@ -560,7 +561,7 @@ __CLS_SCR:
SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines
; to get the start of the screen
ENDP
#line 7 "print.asm"
#line 8 "print.asm"
#line 1 "in_screen.asm"
__IN_SCREEN:
; Returns NO carry if current coords (D, E)
Expand All @@ -583,7 +584,7 @@ __OUT_OF_SCREEN_ERR:
ld a, ERROR_OutOfScreen
jp __STOP ; Saves error code and exits
ENDP
#line 8 "print.asm"
#line 9 "print.asm"
#line 1 "table_jump.asm"
JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A
add a, a
Expand All @@ -598,7 +599,7 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE)
ex de, hl
CALL_HL:
jp (hl)
#line 9 "print.asm"
#line 10 "print.asm"
#line 1 "ink.asm"
; Sets ink color in ATTR_P permanently
; Parameter: Paper color in A register
Expand Down Expand Up @@ -643,7 +644,7 @@ INK_TMP:
ld de, ATTR_T
jp __SET_INK
ENDP
#line 10 "print.asm"
#line 11 "print.asm"
#line 1 "paper.asm"
; Sets paper color in ATTR_P permanently
; Parameter: Paper color in A register
Expand Down Expand Up @@ -681,7 +682,7 @@ PAPER_TMP:
ld de, ATTR_T
jp __SET_PAPER
ENDP
#line 11 "print.asm"
#line 12 "print.asm"
#line 1 "flash.asm"
; Sets flash flag in ATTR_P permanently
; Parameter: Paper color in A register
Expand Down Expand Up @@ -716,7 +717,7 @@ FLASH_TMP:
ld hl, ATTR_T
jr __SET_FLASH
ENDP
#line 12 "print.asm"
#line 13 "print.asm"
#line 1 "bright.asm"
; Sets bright flag in ATTR_P permanently
; Parameter: Paper color in A register
Expand Down Expand Up @@ -751,7 +752,7 @@ BRIGHT_TMP:
ld hl, ATTR_T
jr __SET_BRIGHT
ENDP
#line 13 "print.asm"
#line 14 "print.asm"
#line 1 "over.asm"
; Sets OVER flag in P_FLAG permanently
; Parameter: OVER flag in bit 0 of A register
Expand Down Expand Up @@ -817,7 +818,7 @@ OVER_TMP:
ld (hl), a
jp __SET_ATTR_MODE
ENDP
#line 14 "print.asm"
#line 15 "print.asm"
#line 1 "inverse.asm"
; Sets INVERSE flag in P_FLAG permanently
; Parameter: INVERSE flag in bit 0 of A register
Expand All @@ -843,7 +844,7 @@ INVERSE_TMP:
ld (hl), a
jp __SET_ATTR_MODE
ENDP
#line 15 "print.asm"
#line 16 "print.asm"
#line 1 "bold.asm"
; Sets BOLD flag in P_FLAG permanently
; Parameter: BOLD flag in bit 0 of A register
Expand All @@ -869,7 +870,7 @@ BOLD_TMP:
ld (hl), a
ret
ENDP
#line 16 "print.asm"
#line 17 "print.asm"
#line 1 "italic.asm"
; Sets ITALIC flag in P_FLAG permanently
; Parameter: ITALIC flag in bit 0 of A register
Expand Down Expand Up @@ -897,7 +898,7 @@ ITALIC_TMP:
ld (hl), a
ret
ENDP
#line 17 "print.asm"
#line 18 "print.asm"
#line 1 "attr.asm"
; Attribute routines
; vim:ts=4:et:sw:
Expand Down Expand Up @@ -955,7 +956,7 @@ SET_PIXEL_ADDR_ATTR:
ld de, (SCREEN_ADDR)
add hl, de ;; Final screen addr
jp __SET_ATTR2
#line 19 "print.asm"
#line 20 "print.asm"
; Putting a comment starting with @INIT <address>
; will make the compiler to add a CALL to <address>
; It is useful for initialization routines.
Expand Down Expand Up @@ -995,14 +996,14 @@ __SCROLL: ; Scroll?
ld hl, __TVFLAGS
res 1, (hl)
ret
#line 75 "/zxbasic/library-asm/print.asm"
#line 76 "/zxbasic/library-asm/print.asm"
__PRINT_START:
cp ' '
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
exx ; Switch to alternative registers
ex af, af' ; Saves a value (char to print) for later
call __SCROLL
#line 86 "/zxbasic/library-asm/print.asm"
#line 87 "/zxbasic/library-asm/print.asm"
call __LOAD_S_POSN
; At this point we have the new coord
ld hl, (SCREEN_ADDR)
Expand Down Expand Up @@ -1097,7 +1098,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence
exx
__PRINT_0Dh: ; Called WHEN printing CHR$(13)
call __SCROLL
#line 209 "/zxbasic/library-asm/print.asm"
#line 210 "/zxbasic/library-asm/print.asm"
call __LOAD_S_POSN
__PRINT_EOL1: ; Another entry called from PRINT when next line required
ld e, 0
Expand All @@ -1111,6 +1112,7 @@ __PRINT_AT1_END:
ld hl, __TVFLAGS
set 1, (hl)
ld a, d
#line 230 "/zxbasic/library-asm/print.asm"
__PRINT_EOL_END:
ld d, a
__PRINT_AT2_END:
Expand Down Expand Up @@ -1323,6 +1325,7 @@ PRINT_AT: ; Changes cursor to ROW, COL
ret nc ; Return if out of screen
ld hl, __TVFLAGS
res 1, (hl)
#line 482 "/zxbasic/library-asm/print.asm"
jp __SAVE_S_POSN
LOCAL __PRINT_COM
LOCAL __BOLD
Expand Down Expand Up @@ -1368,7 +1371,8 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes
DW __PRINT_AT ; 22 AT
DW __PRINT_TAB ; 23 TAB
ENDP
#line 4 "load.asm"
#line 6 "load.asm"
#line 7 "/zxbasic/library-asm/load.asm"
LOAD_CODE:
; This function will implement the LOAD CODE Routine
; Parameters in the stack are HL => String with LOAD name
Expand All @@ -1387,11 +1391,13 @@ LOAD_CODE:
LOCAL LD_CH_PR
LOCAL LOAD_END
LOCAL VR_CONTROL, VR_CONT_1, VR_CONT_2
LOCAL MEM0
MEM0 EQU 5C92h ; Temporary memory buffer
HEAD1 EQU MEM0 + 8 ; Uses CALC Mem for temporary storage
; Must skip first 8 bytes used by
; PRINT routine
TMP_HEADER EQU HEAD1 + 17 ; Temporary HEADER2 pointer storage
#line 34 "/zxbasic/library-asm/load.asm"
#line 39 "/zxbasic/library-asm/load.asm"
TMP_FLAG EQU 23655 ; Uses BREG as a Temporary FLAG
pop hl ; Return address
pop af ; A = 1 => LOAD; A = 0 => VERIFY
Expand Down Expand Up @@ -1476,6 +1482,7 @@ LD_TYPE:
jr nc, LD_LOOK_H ; back to LD-LOOK-H with 4 and over.
; else A indicates type 0-3.
call PRINT_TAPE_MESSAGES; Print tape msg
#line 145 "/zxbasic/library-asm/load.asm"
ld hl, HEAD1 + 1 ; point HL to 1st descriptor.
ld de, (TMP_HEADER) ; point DE to 2nd descriptor.
ld b, 10 ; the count will be ten characters for the
Expand All @@ -1502,12 +1509,14 @@ LD_NAME:
;; LD-CH-PR
LD_CH_PR:
call __PRINTCHAR ; PRINT-A prints character
#line 181 "/zxbasic/library-asm/load.asm"
djnz LD_NAME ; loop back to LD-NAME for ten characters.
bit 7, c ; test if all matched
jr nz, LD_LOOK_H ; back to LD-LOOK-H if not
; else print a terminal carriage return.
ld a, 0Dh ; prepare carriage return.
call __PRINTCHAR ; PRINT-A outputs it.
#line 192 "/zxbasic/library-asm/load.asm"
ld a, (HEAD1)
cp 03 ; Only "bytes:" header is used un ZX BASIC
jr nz, LD_LOOK_H
Expand All @@ -1524,7 +1533,7 @@ VR_CONTROL:
jr z, VR_CONT_1 ; forward to VR-CONT-1 if length unspecified
; e.g. LOAD "x" CODE
sbc hl, de
jr nz, LOAD_ERROR ; Lenghts don't match
jr nz, LOAD_ERROR ; Lengths don't match
VR_CONT_1:
ld hl, HEAD1 + 13 ; fetch start of old data (orig. header)
ld a, (hl)
Expand Down Expand Up @@ -1572,7 +1581,7 @@ LD_BYTES_RET:
LD_BYTES_NOINTER:
ex af, af'
ret
#line 262 "/zxbasic/library-asm/load.asm"
#line 274 "/zxbasic/library-asm/load.asm"
ENDP
PRINT_TAPE_MESSAGES:
PROC
Expand Down Expand Up @@ -1611,6 +1620,7 @@ PRINT_TAPE_MSG:
pop bc
ret
ENDP
#line 328 "/zxbasic/library-asm/load.asm"
#line 30 "code00.bas"
#line 1 "loadstr.asm"
; Loads a string (ptr) from HL
Expand Down
Loading