orb: down to 252 bytes!

This commit is contained in:
Vince Weaver 2022-02-02 15:12:54 -05:00
parent 5e015925a7
commit 7c27921394
3 changed files with 33 additions and 24 deletions

View File

@ -11,11 +11,14 @@
; 263 bytes -- more circle optimization
; 261 bytes -- optimize boxes
; 257 bytes -- optimize staggered
; 255 bytes -- put some circle draw code in loop
; 253 bytes -- reuse previous zeroed ZP address for the staggered code
; 252 bytes -- trying removing random SEC to see if it hurts things
; zero page
GBASL = $26
GBASH = $27
;GBASL = $26
;GBASH = $27
; D0+ used by HGR routines
HGR_COLOR = $E4
HGR_PAGE = $E6
@ -28,6 +31,8 @@ X1 = $F3
COLOR = $F4
COUNT = $F6
INDEXL = $F6
INDEXH = $F7
XX = $F7
MINUSXX = $F8

View File

@ -33,6 +33,8 @@ draw_next:
sbc R
sbc R
; D is now in A
; always odd, never zero
bne do_plots ; bra skip ahead first time through
@ -53,7 +55,7 @@ d_positive:
; D=D+4*(XX-YY)+10
; XX is already in A
sec
; sec ; saves a byte, seems to be OK?
sbc YY
ldy #10
d_negative:
@ -71,17 +73,17 @@ do_plots:
sta D
; setup constants
; setup plus/minus XX/YY
lda XX
ldx #2
plus_minus_loop:
lda XX,X
eor #$FF
sta MINUSXX
inc MINUSXX
lda YY
eor #$FF
sta MINUSYY
inc MINUSYY
sta MINUSXX,X
inc MINUSXX,X
dex
dex
bpl plus_minus_loop
; HPLOT CX+X,CY+Y
; HPLOT CX-X,CY+Y
@ -106,7 +108,7 @@ pos_loop:
lda #96 ; center around y=96
clc
adc XX,X ; index with COUNT
pha ; save for later
tay ; save for later
; calc x co-ord
@ -121,7 +123,7 @@ pos_loop:
tax
pla ; restore Y co-ordinate
tya ; restore Y co-ordinate
ldy #0 ; always 0
jsr HPLOT0 ; plot at (Y,X), (A)
@ -148,7 +150,7 @@ pos_loop:
; IF YY>=XX THEN 4
; should be equivelant to IF XX<YY
; but sadly appears we need IF XX<=YY for same effect
; but sadly appears we need IF XX<=YY for our initial effect
lda YY
cmp XX
bcs circle_loop

View File

@ -5,33 +5,35 @@ staggered:
stx FRAME ; set FRAME to 48
ldx #$00 ; init X to 0
stx GBASL ; set GBASL to 0
; we can count on INDEXL (COUNT) being 0 from the orb code
; stx INDEXL ; set INDEXL to 0
; pulse loop horizontal
outer_loop:
lda #$40 ; reset GBASH to begin page2
sta GBASH
lda #$40 ; reset INDEXH to begin page2
sta INDEXH
inner_loop:
lda even_lookup,X ; get even color
sta (GBASL),Y ; store it to memory
sta (INDEXL),Y ; store it to memory
iny
lda odd_lookup,X ; get odd color
sta (GBASL),Y ; store it to memory
sta (INDEXL),Y ; store it to memory
iny
bne inner_loop ; repeat for 256
inc GBASH ; point to next page
inc INDEXH ; point to next page
inx ; wrap lookup at 8
txa
inx ; point to next lookup
txa ; wrap to 0..7
and #$7
tax
lda #$60 ; see if done
cmp GBASH
cmp INDEXH
bne inner_loop
; lda #100 ; A is $60 here