CPU-Z80-Disassembler
view release on metacpan or search on metacpan
t/data/zx48_base.asm view on Meta::CPAN
;; S-SCRN$-S
S_SCRN__S:
call STK_TO_BC ; routine STK-TO-BC.
ld hl,(0x5C36) ; fetch address of CHARS.
ld de,0x0100 ; fetch offset to chr$ 32
add hl,de ; and find start of bitmaps.
; Note. not inc h. ??
ld a,c ; transfer line to A.
rrca ; multiply
rrca ; by
rrca ; thirty-two.
and 0xE0 ; and with 11100000
xor b ; combine with column $00 - $1F
ld e,a ; to give the low byte of top line
ld a,c ; column to A range 00000000 to 00011111
and 0x18 ; and with 00011000
xor 0x40 ; xor with 01000000 (high byte screen start)
ld d,a ; register DE now holds start address of cell.
ld b,0x60 ; there are 96 characters in ASCII set.
;; S-SCRN-LP
S_SCRN_LP:
push bc ; save count
push de ; save screen start address
push hl ; save bitmap start
ld a,(de) ; first byte of screen to A
xor (hl) ; xor with corresponding character byte
jr z,S_SC_MTCH ; forward to S-SC-MTCH if they match
; if inverse result would be $FF
; if any other then mismatch
inc a ; set to $00 if inverse
jr nz,S_SCR_NXT ; forward to S-SCR-NXT if a mismatch
dec a ; restore $FF
; a match has been found so seven more to test.
;; S-SC-MTCH
S_SC_MTCH:
ld c,a ; load C with inverse mask $00 or $FF
ld b,0x07 ; count seven more bytes
;; S-SC-ROWS
S_SC_ROWS:
inc d ; increment screen address.
inc hl ; increment bitmap address.
ld a,(de) ; byte to A
xor (hl) ; will give $00 or $FF (inverse)
xor c ; xor with inverse mask
jr nz,S_SCR_NXT ; forward to S-SCR-NXT if no match.
djnz S_SC_ROWS ; back to S-SC-ROWS until all eight matched.
; continue if a match of all eight bytes was found
pop bc ; discard the
pop bc ; saved
pop bc ; pointers
ld a,0x80 ; the endpoint of character set
sub b ; subtract the counter
; to give the code 32-127
ld bc,0x0001 ; make one space in workspace.
rst 0x30 ; BC-SPACES creates the space sliding
; the calculator stack upwards.
ld (de),a ; start is addressed by DE, so insert code
jr S_SCR_STO ; forward to S-SCR-STO
; ---
; the jump was here if no match and more bitmaps to test.
;; S-SCR-NXT
S_SCR_NXT:
pop hl ; restore the last bitmap start
ld de,0x0008 ; and prepare to add 8.
add hl,de ; now addresses next character bitmap.
pop de ; restore screen address
pop bc ; and character counter in B
djnz S_SCRN_LP ; back to S-SCRN-LP if more characters.
ld c,b ; B is now zero, so BC now zero.
;; S-SCR-STO
S_SCR_STO:
jp STK_STO__ ; to STK-STO-$ to store the string in
; workspace or a string with zero length.
; (value of DE doesn't matter in last case)
; Note. this exit seems correct but the general-purpose routine S-STRING
; that calls this one will also stack any of its string results so this
; leads to a double storing of the result in this case.
; The instruction at L257D should just be a RET.
; credit Stephen Kelly and others, 1982.
; -------------
; Scanning ATTR
; -------------
; This function subroutine returns the attributes of a screen location -
; a numeric result.
; Again it's up to the BASIC programmer to supply valid values of line/column.
;; S-ATTR-S
S_ATTR_S:
call STK_TO_BC ; routine STK-TO-BC fetches line to C,
; and column to B.
ld a,c ; line to A $00 - $17 (max 00010111)
rrca ; rotate
rrca ; bits
rrca ; left.
ld c,a ; store in C as an intermediate value.
and 0xE0 ; pick up bits 11100000 ( was 00011100 )
xor b ; combine with column $00 - $1F
ld l,a ; low byte now correct.
ld a,c ; bring back intermediate result from C
and 0x03 ; mask to give correct third of
; screen $00 - $02
( run in 2.378 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )