Prev: 09520 Up: Map Next: 09600
09525: THE 'SCANNING SCREEN$' SUBROUTINE
Used by the routine at S_SCREEN.
This subroutine is used to find the character that appears at line x, column y of the screen. It only searches the character set 'pointed to' by CHARS.
Note: this is normally the characters 32 (space) to 127 (©) although the user can alter CHARS to match for other characters, including user-defined graphics.
S_SCRN_S 09525 CALL STK_TO_BC x to C, y to B; 0<=x<=23; 0<=y<=31.
09528 LD HL,(23606) CHARS plus 256 gives HL pointing to the character set.
09531 LD DE,256
09534 ADD HL,DE
09535 LD A,C x is copied to A.
09536 RRCA The number 32*(x mod 8)+y is formed in A and copied to E. This is the low byte of the required screen address.
09537 RRCA
09538 RRCA
09539 AND 224
09541 XOR B
09542 LD E,A
09543 LD A,C x is copied to A again.
09544 AND 24 Now the number 64+8*INT (x/8) is inserted into D. DE now holds the screen address.
09546 XOR 64
09548 LD D,A
09549 LD B,96 B counts the 96 characters.
S_SCRN_LP 09551 PUSH BC Save the count.
09552 PUSH DE And the screen pointer.
09553 PUSH HL And the character set pointer.
09554 LD A,(DE) Get first row of screen character.
09555 XOR (HL) Match with row from character set.
09556 JR Z,S_SC_MTCH Jump if direct match found.
09558 INC A Now test for match with inverse character (get 0 in A from 255).
09559 JR NZ,S_SCR_NXT Jump if neither match found.
09561 DEC A Restore 255 to A.
S_SC_MTCH 09562 LD C,A Inverse status (0 or 255) to C.
09563 LD B,7 B counts through the other 7 rows.
S_SC_ROWS 09565 INC D Move DE to next row (add 256).
09566 INC HL Move HL to next row (i.e. next byte).
09567 LD A,(DE) Get the screen row.
09568 XOR (HL) Match with row from the ROM.
09569 XOR C Include the inverse status.
09570 JR NZ,S_SCR_NXT Jump if row fails to match.
09572 DJNZ S_SC_ROWS Jump back till all rows done.
09574 POP BC Discard character set pointer.
09575 POP BC And screen pointer.
09576 POP BC Final count to BC.
09577 LD A,128 Last character code in set plus one.
09579 SUB B A now holds required code.
09580 LD BC,1 One space is now needed in the work space.
09583 RST 48 Make the space.
09584 LD (DE),A Put the character into it.
09585 JR S_SCR_STO Jump to stack the character.
S_SCR_NXT 09587 POP HL Restore character set pointer.
09588 LD DE,8 Move it on 8 bytes, to the next character in the set.
09591 ADD HL,DE
09592 POP DE Restore the screen pointer.
09593 POP BC And the counter.
09594 DJNZ S_SCRN_LP Loop back for the 96 characters.
09596 LD C,B Stack the empty string (length zero).
S_SCR_STO 09597 JP STK_STO Jump to stack the matching character, or the null string if no match is found.
Note: this exit, via STK_STO, is a mistake as it leads to 'double storing' of the string result (see S_STRING). The instruction line should be 'RET'.
Prev: 09520 Up: Map Next: 09600