From 7c2792139465a82edef76380278d109653f70353 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 2 Feb 2022 15:12:54 -0500 Subject: [PATCH] orb: down to 252 bytes! --- demos/l/orb_256/combo.s | 9 +++++++-- demos/l/orb_256/orb.s | 28 +++++++++++++++------------- demos/l/orb_256/staggered.s | 20 +++++++++++--------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/demos/l/orb_256/combo.s b/demos/l/orb_256/combo.s index fdcd69c9..72365409 100644 --- a/demos/l/orb_256/combo.s +++ b/demos/l/orb_256/combo.s @@ -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 diff --git a/demos/l/orb_256/orb.s b/demos/l/orb_256/orb.s index c49af65f..14db0fbf 100644 --- a/demos/l/orb_256/orb.s +++ b/demos/l/orb_256/orb.s @@ -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