CPU-Z80-Disassembler
view release on metacpan or search on metacpan
t/data/zx48.asm view on Meta::CPAN
; No real harm can come from SCREEN$(255,255) although the BASIC manual
; says that invalid values will be trapped.
; Interestingly, in the Pitman pocket guide, 1984, Vickers says that the
; range checking will be performed.
;; S-SCRN$-S
L2535: CALL L2307 ; routine STK-TO-BC.
LD HL,($5C36) ; fetch address of CHARS.
LD DE,$0100 ; 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 $E0 ; 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 $18 ; and with 00011000
XOR $40 ; xor with 01000000 (high byte screen start)
LD D,A ; register DE now holds start address of cell.
LD B,$60 ; there are 96 characters in ASCII set.
;; S-SCRN-LP
L254F: 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,L255A ; 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,L2573 ; 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
L255A: LD C,A ; load C with inverse mask $00 or $FF
LD B,$07 ; count seven more bytes
;; S-SC-ROWS
L255D: 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,L2573 ; forward to S-SCR-NXT if no match.
DJNZ L255D ; 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,$80 ; the endpoint of character set
SUB B ; subtract the counter
; to give the code 32-127
LD BC,$0001 ; make one space in workspace.
RST 30H ; BC-SPACES creates the space sliding
; the calculator stack upwards.
LD (DE),A ; start is addressed by DE, so insert code
JR L257D ; forward to S-SCR-STO
; ---
; the jump was here if no match and more bitmaps to test.
;; S-SCR-NXT
L2573: POP HL ; restore the last bitmap start
LD DE,$0008 ; 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 L254F ; back to S-SCRN-LP if more characters.
LD C,B ; B is now zero, so BC now zero.
;; S-SCR-STO
L257D: JP L2AB2 ; 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
L2580: CALL L2307 ; 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 $E0 ; 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 $03 ; mask to give correct third of
; screen $00 - $02
XOR $58 ; combine with base address.
LD H,A ; high byte correct.
LD A,(HL) ; pick up the colour attribute.
( run in 1.104 second using v1.01-cache-2.11-cpan-524268b4103 )