Created
December 13, 2020 23:02
-
-
Save classilla/9c8b99cc4d53abf18a9b69950a2a0b26 to your computer and use it in GitHub Desktop.
6502 assembly to take a value and create an interlaced square sprite of that size (assemble with xa65). https://oldvcr.blogspot.com/2020/12/stereoscopic-computing-anaglyph-sprites.html
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
; given 0-21, create a sprite sized x by x, skipping every other line | |
; cameron kaiser 2020 | |
; public domain | |
SA = $c000 | |
SPRITE = $0340 | |
* = SA | |
.word SA | |
; accept a comma and a 16 bit value, storing in $14-15 | |
jsr $aefd | |
jsr $ad9e | |
jsr $b7f7 | |
lda #0 | |
sta SPRITE | |
sta SPRITE+1 | |
sta SPRITE+2 | |
lda $14 | |
tax | |
beq lup3 ; value was 0, clear sprite | |
; turn x into x 1-bits | |
lup1 sec | |
ror SPRITE | |
ror SPRITE+1 | |
ror SPRITE+2 | |
dex | |
bne lup1 | |
; copy the right number of lines, skipping every other | |
; x register is conveniently already 0, accumulator has value of $14 | |
; if 1x1, no copies (already handled). | |
; if 2x2, no copies. | |
; if 3x3, one copy. | |
; if 4x4, one copy. | |
; if 5x5, two copies. | |
; if 6x6, two copies. etc. | |
sbc #0 ; carry is already clear from the above, so -1 | |
lsr | |
beq clrs ; no copies, clear the remainder of the sprite | |
tay | |
clc | |
lup2 lda SPRITE | |
sta SPRITE+6,x | |
lda SPRITE+1 | |
sta SPRITE+7,x | |
lda SPRITE+2 | |
sta SPRITE+8,x | |
txa | |
adc #6 | |
tax | |
dey | |
bne lup2 | |
clrs lda #0 | |
lup3 sta SPRITE+6,x | |
inx | |
cpx #58 | |
bcc lup3 | |
rts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment