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 ; 263 bytes -- more circle optimization
; 261 bytes -- optimize boxes ; 261 bytes -- optimize boxes
; 257 bytes -- optimize staggered ; 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 ; zero page
GBASL = $26 ;GBASL = $26
GBASH = $27 ;GBASH = $27
; D0+ used by HGR routines ; D0+ used by HGR routines
HGR_COLOR = $E4 HGR_COLOR = $E4
HGR_PAGE = $E6 HGR_PAGE = $E6
@ -28,6 +31,8 @@ X1 = $F3
COLOR = $F4 COLOR = $F4
COUNT = $F6 COUNT = $F6
INDEXL = $F6
INDEXH = $F7
XX = $F7 XX = $F7
MINUSXX = $F8 MINUSXX = $F8

View File

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

View File

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