![]() |
Routines |
Prev: 2530 | Up: Map |
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 +20 (space) to +7F (©) although the user can alter CHARS to match for other characters, including user-defined graphics.
|
||||||||
S_SCRN_S | 2535 | CALL STK_TO_BC | x to C, y to B; 0<=x<=23; 0<=y<=31. | |||||
2538 | LD HL,($5C36) | CHARS plus +0100 gives HL pointing to the character set. | ||||||
253B | LD DE,$0100 | |||||||
253E | ADD HL,DE | |||||||
253F | LD A,C | x is copied to A. | ||||||
2540 | 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. | ||||||
2541 | RRCA | |||||||
2542 | RRCA | |||||||
2543 | AND $E0 | |||||||
2545 | XOR B | |||||||
2546 | LD E,A | |||||||
2547 | LD A,C | x is copied to A again. | ||||||
2548 | AND $18 | Now the number 64+8*INT (x/8) is inserted into D. DE now holds the screen address. | ||||||
254A | XOR $40 | |||||||
254C | LD D,A | |||||||
254D | LD B,$60 | B counts the 96 characters. | ||||||
S_SCRN_LP | 254F | PUSH BC | Save the count. | |||||
2550 | PUSH DE | And the screen pointer. | ||||||
2551 | PUSH HL | And the character set pointer. | ||||||
2552 | LD A,(DE) | Get first row of screen character. | ||||||
2553 | XOR (HL) | Match with row from character set. | ||||||
2554 | JR Z,S_SC_MTCH | Jump if direct match found. | ||||||
2556 | INC A | Now test for match with inverse character (get +00 in A from +FF). | ||||||
2557 | JR NZ,S_SCR_NXT | Jump if neither match found. | ||||||
2559 | DEC A | Restore +FF to A. | ||||||
S_SC_MTCH | 255A | LD C,A | Inverse status (+00 or +FF) to C. | |||||
255B | LD B,$07 | B counts through the other 7 rows. | ||||||
S_SC_ROWS | 255D | INC D | Move DE to next row (add +0100). | |||||
255E | INC HL | Move HL to next row (i.e. next byte). | ||||||
255F | LD A,(DE) | Get the screen row. | ||||||
2560 | XOR (HL) | Match with row from the ROM. | ||||||
2561 | XOR C | Include the inverse status. | ||||||
2562 | JR NZ,S_SCR_NXT | Jump if row fails to match. | ||||||
2564 | DJNZ S_SC_ROWS | Jump back till all rows done. | ||||||
2566 | POP BC | Discard character set pointer. | ||||||
2567 | POP BC | And screen pointer. | ||||||
2568 | POP BC | Final count to BC. | ||||||
2569 | LD A,$80 | Last character code in set plus one. | ||||||
256B | SUB B | A now holds required code. | ||||||
256C | LD BC,$0001 | One space is now needed in the work space. | ||||||
256F | RST $30 | Make the space. | ||||||
2570 | LD (DE),A | Put the character into it. | ||||||
2571 | JR S_SCR_STO | Jump to stack the character. | ||||||
S_SCR_NXT | 2573 | POP HL | Restore character set pointer. | |||||
2574 | LD DE,$0008 | Move it on 8 bytes, to the next character in the set. | ||||||
2577 | ADD HL,DE | |||||||
2578 | POP DE | Restore the screen pointer. | ||||||
2579 | POP BC | And the counter. | ||||||
257A | DJNZ S_SCRN_LP | Loop back for the 96 characters. | ||||||
257C | LD C,B | Stack the empty string (length zero). | ||||||
S_SCR_STO | 257D | 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: 2530 | Up: Map |