Prev: $3687 Up: Map Next: $3724
$36E3: Update the SRB for a single character cell
Used by the routines at $11CF, $16E9 and $322E.
($49) x-coordinate
($4A) y-coordinate
$36E3 LDA #$08 Prepare to address the screen refresh buffer (SRB) at $4008.
$36E5 STA $52
$36E7 LDA #$40
$36E9 STA $53
$36EB LDA #$00 Calculate the index of the SRB byte that corresponds to the leftmost segment of 8 character cells in the row at the given y-coordinate and store it at $55.
$36ED LDY $4A
$36EF BEQ $36F7
$36F1 CLC
$36F2 ADC #$05
$36F4 DEY
$36F5 BNE $36F1
$36F7 STA $55
$36F9 LDA $49 Pick up the x-coordinate from $49, divide by 8 and store the result at $56. This will be added to the index at $55 later to get the index of the target SRB byte.
$36FE STA $56
$3700 ASL A Store the multiple of 8 closest to but not greater than the x-coordinate at $54.
$3701 ASL A
$3702 ASL A
$3703 STA $54
$3705 LDA $49 Compute the remainder when the x-coordinate is divided by 8 and transfer it to Y. This indicates the bit of the SRB byte that needs to be set.
$3707 SEC
$3708 SBC $54
$370A TAY
$370B LDA #$80 Set the bit in A that needs to be set in the SRB byte.
$370D CPY #$00
$370F BEQ $3715
$3711 LSR A
$3712 DEY
$3713 BNE $3711
$3715 STA $54 Store A (with the appropriate bit set) at $54.
$3717 LDA $55 Compute the index of the SRB byte that needs updating and transfer it to Y.
$3719 CLC
$371A ADC $56
$371C TAY
$371D LDA ($52),Y Set the appropriate bit in the SRB byte.
$371F ORA $54
$3721 STA ($52),Y
$3723 RTS
Prev: $3687 Up: Map Next: $3724