Routines |
Prev: $31DF | Up: Map | Next: $322E |
$31EA | LDY #$5E | Prepare to address the screen refresh buffer (SRB) at $4008, working backwards from the last byte at $4070 to the 11th byte $4012. This ignores the first ten bytes - which correspond to the top two rows of the screen - and is a bug. | ||
$31EC | LDA #$12 | |||
$31EE | STA $4E | |||
$31F0 | LDA #$40 | |||
$31F2 | STA $4F | |||
$31F4 | LDA ($4E),Y | Pick up a byte from the screen refresh buffer. | ||
$31F6 | BEQ $322A | Branch if it's zero (no updates required). | ||
$31F8 | STA $57 | Store the SRB byte at $57. | ||
$31FA | TYA | Save Y temporarily. | ||
$31FB | PHA | |||
$31FC | LDX #$01 | Set X to 1+8*INT(Y/40). | ||
$31FE | CMP #$28 | |||
$3200 | BCC $3206 | |||
$3202 | SBC #$28 | |||
$3204 | LDX #$09 | |||
$3206 | INX | Increase X by INT((Y%40)/5)+1. This is the play area y-coordinate of the segment corresponding to the SRB byte under inspection. | ||
$3207 | SEC | |||
$3208 | SBC #$05 | |||
$320A | BPL $3206 | |||
$320C | STX $28 | Store this play area y-coordinate at $28. | ||
$320E | ADC #$05 | Now 0<=A<5, the remainder when Y is divided by 5. | ||
$3210 | ASL A | Multiply by 8 and add the x-coordinate of the leftmost column of the skool on screen. This gives the play area x-coordinate of the leftmost cell in the segment corresponding to the SRB byte under inspection. | ||
$3211 | ASL A | |||
$3212 | ASL A | |||
$3213 | ADC $58 | |||
$3215 | STA $27 | Store this play area x-coordinate at $27. | ||
$3217 | ASL $57 | Move bit 7 of the SRB byte into the carry flag. | ||
$3219 | BCC $321E | Branch if it's clear (no update required). | ||
$321B | JSR $3326 | Print the corresponding play area tile. | ||
$321E | INC $27 | Increment the play area x-coordinate at $27. | ||
$3220 | LDA $57 | Pick up the remains of the SRB byte. | ||
$3222 | BNE $3217 | Branch back until it's zero. | ||
$3224 | PLA | Restore the SRB index to Y. | ||
$3225 | TAY | |||
$3226 | LDA #$00 | Clear all bits in this byte of the screen refresh buffer. | ||
$3228 | STA ($4E),Y | |||
$322A | DEY | Next byte in the screen refresh buffer. | ||
$322B | BPL $31F4 | Branch back unless we've finished. | ||
$322D | RTS |
Prev: $31DF | Up: Map | Next: $322E |