mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-28 02:55:03 +00:00
orb: optimizing, still not enough
This commit is contained in:
parent
dbd4351b0e
commit
37828ba154
@ -56,9 +56,10 @@ rectangle_loop:
|
|||||||
|
|
||||||
lda XRUN ; XRUN into A
|
lda XRUN ; XRUN into A
|
||||||
and #$3f
|
and #$3f
|
||||||
ldx #0 ; always 0
|
; ldx #0 ; always 0
|
||||||
ldy #0 ; relative Y is 0
|
; ldy #0 ; relative Y is 0
|
||||||
jsr HLINRL ; (X,A),(Y)
|
; jsr HLINRL ; (X,A),(Y)
|
||||||
|
jsr combo_hlinrl
|
||||||
|
|
||||||
blah:
|
blah:
|
||||||
inc Y1
|
inc Y1
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
; 280 bytes -- initial combo
|
; 280 bytes -- initial combo
|
||||||
; 276 bytes -- shave some bytes
|
; 276 bytes -- shave some bytes
|
||||||
|
; 275 bytes -- common HLINRL function (thought it would save more)
|
||||||
|
; 271 bytes -- optimize circle draw code
|
||||||
|
; 268 bytes -- circle code now <128 so use bne instead of jmp
|
||||||
|
|
||||||
; zero page
|
; zero page
|
||||||
|
|
||||||
@ -19,6 +22,7 @@ YY = $F9
|
|||||||
MINUSYY = $FA
|
MINUSYY = $FA
|
||||||
D = $FB
|
D = $FB
|
||||||
R = $FC
|
R = $FC
|
||||||
|
DADD = $FD
|
||||||
FRAME = $FF
|
FRAME = $FF
|
||||||
|
|
||||||
; soft-switches
|
; soft-switches
|
||||||
@ -57,6 +61,14 @@ combo:
|
|||||||
.include "staggered.s"
|
.include "staggered.s"
|
||||||
.include "boxes.s"
|
.include "boxes.s"
|
||||||
|
|
||||||
|
|
||||||
|
; sadly this only saves a byte
|
||||||
|
combo_hlinrl:
|
||||||
|
ldy #0
|
||||||
|
ldx #0
|
||||||
|
jmp HLINRL ; plot relative (X,A), (Y)
|
||||||
|
|
||||||
|
|
||||||
even_lookup:
|
even_lookup:
|
||||||
.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
|
.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
|
||||||
odd_lookup:
|
odd_lookup:
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
; it's doing Bresenham circle algo I think, which does weird
|
; it's doing Bresenham circle algo I think, which does weird
|
||||||
; things when radius=0
|
; things when radius=0
|
||||||
|
|
||||||
; FIXME: assume hcolor is 3 somehow?
|
|
||||||
|
|
||||||
orb:
|
orb:
|
||||||
; a=0, y=0 here
|
; a=0, y=0 here
|
||||||
|
|
||||||
@ -23,17 +21,12 @@ draw_next:
|
|||||||
; draw circle at (CX,CY) of radius R
|
; draw circle at (CX,CY) of radius R
|
||||||
; signed 8-bit math so problems if R > 64?
|
; signed 8-bit math so problems if R > 64?
|
||||||
|
|
||||||
; XX=0 YY=R
|
|
||||||
; D=3-2*R
|
|
||||||
; GOTO6
|
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sta XX
|
sta XX ; XX = 0
|
||||||
|
|
||||||
; lda R
|
stx YY ; YY =R (X is R here)
|
||||||
stx YY
|
|
||||||
|
|
||||||
lda #3
|
lda #3 ; D=3-2*R
|
||||||
sec
|
sec
|
||||||
sbc R
|
sbc R
|
||||||
sbc R
|
sbc R
|
||||||
@ -41,20 +34,26 @@ draw_next:
|
|||||||
|
|
||||||
; always odd, never zero
|
; always odd, never zero
|
||||||
|
|
||||||
bne do_plots ; bra
|
bne do_plots ; bra skip ahead first time through
|
||||||
|
|
||||||
circle_loop:
|
circle_loop:
|
||||||
; X=X+1
|
inc XX ; XX=XX+1
|
||||||
|
|
||||||
inc XX
|
lda XX ; XX is common both paths
|
||||||
|
ldy #6 ; default path add 6
|
||||||
|
|
||||||
; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10
|
; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10
|
||||||
lda D
|
bit D ; check if negative w/o changing A
|
||||||
bmi else
|
bmi d_negative
|
||||||
|
|
||||||
dec YY
|
dec YY ; YY=YY-1
|
||||||
|
|
||||||
lda XX
|
|
||||||
|
.if 0
|
||||||
|
d_positive:
|
||||||
|
; D=D+4*(XX-YY)+10
|
||||||
|
|
||||||
|
; XX is already in A
|
||||||
sec
|
sec
|
||||||
sbc YY
|
sbc YY
|
||||||
asl
|
asl
|
||||||
@ -63,9 +62,9 @@ circle_loop:
|
|||||||
adc #10
|
adc #10
|
||||||
jmp store_D
|
jmp store_D
|
||||||
|
|
||||||
else:
|
d_negative:
|
||||||
; ELSE D=D+4*X+6
|
; ELSE D=D+4*X+6
|
||||||
lda XX
|
; lda XX
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
clc
|
clc
|
||||||
@ -73,6 +72,25 @@ else:
|
|||||||
store_D:
|
store_D:
|
||||||
adc D
|
adc D
|
||||||
sta D
|
sta D
|
||||||
|
.endif
|
||||||
|
|
||||||
|
d_positive:
|
||||||
|
; D=D+4*(XX-YY)+10
|
||||||
|
|
||||||
|
; XX is already in A
|
||||||
|
sec
|
||||||
|
sbc YY
|
||||||
|
ldy #10
|
||||||
|
d_negative:
|
||||||
|
; ELSE D=D+4*(XX)+6
|
||||||
|
common_D:
|
||||||
|
sty DADD
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
clc
|
||||||
|
adc DADD
|
||||||
|
adc D
|
||||||
|
sta D
|
||||||
|
|
||||||
do_plots:
|
do_plots:
|
||||||
; setup constants
|
; setup constants
|
||||||
@ -109,6 +127,8 @@ pos_loop:
|
|||||||
eor #$2
|
eor #$2
|
||||||
tay
|
tay
|
||||||
; lda CX
|
; lda CX
|
||||||
|
|
||||||
|
|
||||||
lda #128
|
lda #128
|
||||||
clc
|
clc
|
||||||
adc XX,Y
|
adc XX,Y
|
||||||
@ -135,14 +155,14 @@ pos_loop:
|
|||||||
lda XX,Y
|
lda XX,Y
|
||||||
asl
|
asl
|
||||||
|
|
||||||
ldy #0
|
; ldy #0
|
||||||
ldx #0
|
; ldx #0
|
||||||
|
|
||||||
jsr HLINRL ; plot relative (X,A), (Y)
|
; jsr HLINRL ; plot relative (X,A), (Y)
|
||||||
|
jsr combo_hlinrl
|
||||||
; so in our case (0,XX*2),0
|
; so in our case (0,XX*2),0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dec COUNT
|
dec COUNT
|
||||||
bpl pos_loop
|
bpl pos_loop
|
||||||
|
|
||||||
@ -157,10 +177,7 @@ done:
|
|||||||
inx ; increment radius
|
inx ; increment radius
|
||||||
jsr HCOLOR1 ; use as color
|
jsr HCOLOR1 ; use as color
|
||||||
|
|
||||||
cpx #48 ; loop
|
cpx #48 ; run until R=48
|
||||||
beq rdone
|
bne draw_next ; loop (GOTO 1)
|
||||||
; GOTO1
|
|
||||||
jmp draw_next
|
|
||||||
|
|
||||||
rdone:
|
rdone:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user