Created
August 30, 2025 11:02
-
-
Save AndyA/f088d68caa40d44a970b8f1bbb2dfba5 to your computer and use it in GitHub Desktop.
Raster scaling 6502
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.scale_rast LDY #0 | |
STY rast_in_y | |
STY rast_out_y | |
.scr1 LDX #256-4 | |
.scr2 LDA (rast_in), Y | |
PHA | |
AND #&07 | |
STA scratch - 4, X | |
PLA | |
AND #&70 | |
LSR A | |
ORA scratch - 4, X | |
STA scratch - 4, X | |
INX | |
BNE scr2 | |
STY rast_in_y | |
LDY rast_out_y | |
\ Byte 0 | |
LDA scratch + 0 | |
ASL A | |
ASL A | |
LSR scratch + 1 | |
ROR A | |
LSR scratch + 1 | |
ROR A | |
STA (rast_out), Y | |
INY | |
\ Byte 1 | |
LDA scratch + 2 | |
LSR A | |
LSR A | |
LSR A | |
LSR A | |
ORA scratch + 1 | |
STA (rast_out), Y | |
INY | |
\ Byte 2 | |
LDA scratch + 2 | |
ASL A | |
ASL A | |
ASL A | |
ROL scratch + 3 | |
ASL A | |
ROL scratch + 3 | |
LDA scratch + 3 | |
STA (rast_out), Y | |
INY | |
STY rast_out_y | |
LDY rast_in_y | |
CPY #256 DIV 8 * 3 | |
BCC scr1 | |
\ Update pointers | |
CLC | |
LDA rast_in + 0 | |
ADC #256 DIV 8 * 4 | |
STA rast_in + 0 | |
BCC scr3 | |
INC rast_in + 1 | |
.scr3 CLC | |
LDA rast_out + 0 | |
ADC rast_out_y | |
STA rast_out + 0 | |
BCC scr4 | |
INC rast_out + 1 | |
.scr4 RTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment