mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-28 17:55:04 +00:00
orb: more optimizations. so close...
This commit is contained in:
parent
b550f014b4
commit
5e015925a7
@ -18,13 +18,15 @@ outer_boxes:
|
|||||||
ldx #5 ; grab 5 bytes
|
ldx #5 ; grab 5 bytes
|
||||||
; YRUN, XRUN, Y1, X1, COLOR
|
; YRUN, XRUN, Y1, X1, COLOR
|
||||||
data_smc:
|
data_smc:
|
||||||
lda $f180
|
lda $f200 ; was $f180
|
||||||
sta YRUN-1,X ; store reverse for some reason
|
sta YRUN-1,X ; store reverse for some reason
|
||||||
inc data_smc+1 ; move to next
|
inc data_smc+1 ; move to next
|
||||||
dex
|
dex
|
||||||
bne data_smc
|
bne data_smc
|
||||||
|
|
||||||
lda YRUN
|
; at end, YRUN is in A, X=0
|
||||||
|
|
||||||
|
; lda YRUN ; keep size of YRUN<64
|
||||||
and #$3f
|
and #$3f
|
||||||
sta YRUN
|
sta YRUN
|
||||||
|
|
||||||
@ -45,23 +47,20 @@ rectangle_loop:
|
|||||||
and #$f
|
and #$f
|
||||||
tax
|
tax
|
||||||
|
|
||||||
jsr HCOLOR1
|
jsr HCOLOR1 ; index into color table with X
|
||||||
; lda COLORTBL,X ; index into color table
|
; Note: we purposefully index off end
|
||||||
; sta HGR_COLOR ; and store
|
|
||||||
|
|
||||||
ldx X1 ; X1 into X
|
ldx X1 ; X1 into X
|
||||||
lda Y1 ; Y1 into A
|
lda Y1 ; Y1 into A
|
||||||
ldy #0 ; always 0
|
ldy #0 ; always 0
|
||||||
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
|
jsr HPLOT0 ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||||
|
|
||||||
lda XRUN ; XRUN into A
|
lda XRUN ; XRUN into A
|
||||||
and #$3f
|
and #$3f ; keep it <64
|
||||||
; ldx #0 ; always 0
|
|
||||||
; ldy #0 ; relative Y is 0
|
; sets X=0,Y=0 first
|
||||||
; jsr HLINRL ; (X,A),(Y)
|
jsr combo_hlinrl ; draw relative (X,A),Y
|
||||||
jsr combo_hlinrl
|
|
||||||
|
|
||||||
blah:
|
|
||||||
inc Y1
|
inc Y1
|
||||||
dec YRUN
|
dec YRUN
|
||||||
bne rectangle_loop
|
bne rectangle_loop
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
; combo -- Apple II Hires
|
; combo -- Apple II Hires
|
||||||
|
|
||||||
|
; need 252 bytes to qualify (4 byte Apple II header)
|
||||||
|
|
||||||
; 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)
|
; 275 bytes -- common HLINRL function (thought it would save more)
|
||||||
@ -7,6 +9,8 @@
|
|||||||
; 268 bytes -- circle code now <128 so use bne instead of jmp
|
; 268 bytes -- circle code now <128 so use bne instead of jmp
|
||||||
; 266 bytes -- use X to index in zero page
|
; 266 bytes -- use X to index in zero page
|
||||||
; 263 bytes -- more circle optimization
|
; 263 bytes -- more circle optimization
|
||||||
|
; 261 bytes -- optimize boxes
|
||||||
|
; 257 bytes -- optimize staggered
|
||||||
|
|
||||||
; zero page
|
; zero page
|
||||||
|
|
||||||
@ -58,9 +62,6 @@ WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
|
|||||||
|
|
||||||
combo:
|
combo:
|
||||||
|
|
||||||
lda #$20
|
|
||||||
sta FRAME
|
|
||||||
|
|
||||||
jsr HGR2 ; after, A=0, Y=0
|
jsr HGR2 ; after, A=0, Y=0
|
||||||
|
|
||||||
|
|
||||||
@ -71,6 +72,11 @@ combo:
|
|||||||
.include "boxes.s"
|
.include "boxes.s"
|
||||||
|
|
||||||
|
|
||||||
|
even_lookup:
|
||||||
|
.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
|
||||||
|
odd_lookup:
|
||||||
|
.byte $AA,$AA,$AA,$AB, $AB,$AE,$BA,$EA
|
||||||
|
|
||||||
; sadly this only saves a byte
|
; sadly this only saves a byte
|
||||||
combo_hlinrl:
|
combo_hlinrl:
|
||||||
ldy #0
|
ldy #0
|
||||||
@ -78,8 +84,5 @@ combo_hlinrl:
|
|||||||
jmp HLINRL ; plot relative (X,A), (Y)
|
jmp HLINRL ; plot relative (X,A), (Y)
|
||||||
|
|
||||||
|
|
||||||
even_lookup:
|
|
||||||
.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
|
|
||||||
odd_lookup:
|
|
||||||
.byte $AA,$AA,$AA,$AB, $AB,$AE,$BA,$EA
|
|
||||||
|
|
||||||
|
154
demos/l/orb_256/horror.s
Normal file
154
demos/l/orb_256/horror.s
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
; orb
|
||||||
|
|
||||||
|
; this was found accidentally when trying to draw circles
|
||||||
|
; it's doing Bresenham circle algo I think, which does weird
|
||||||
|
; things when radius=0
|
||||||
|
|
||||||
|
orb:
|
||||||
|
; a=0, y=0 here
|
||||||
|
|
||||||
|
tax ; x=0
|
||||||
|
|
||||||
|
dey ; set init color to white
|
||||||
|
sty HGR_COLOR ; set init color to white
|
||||||
|
|
||||||
|
draw_next:
|
||||||
|
stx R
|
||||||
|
|
||||||
|
;===============================
|
||||||
|
; draw circle
|
||||||
|
;===============================
|
||||||
|
; draw circle at (CX,CY) of radius R
|
||||||
|
; signed 8-bit math so problems if R > 64?
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta XX ; XX = 0
|
||||||
|
|
||||||
|
stx YY ; YY =R (X is R here)
|
||||||
|
|
||||||
|
lda #3 ; D=3-2*R
|
||||||
|
sec
|
||||||
|
sbc R
|
||||||
|
sbc R
|
||||||
|
sta D
|
||||||
|
|
||||||
|
; always odd, never zero
|
||||||
|
|
||||||
|
bne do_plots ; bra skip ahead first time through
|
||||||
|
|
||||||
|
circle_loop:
|
||||||
|
inc XX ; XX=XX+1
|
||||||
|
|
||||||
|
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
|
||||||
|
bit D ; check if negative w/o changing A
|
||||||
|
bmi d_negative
|
||||||
|
|
||||||
|
dec YY ; YY=YY-1
|
||||||
|
|
||||||
|
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:
|
||||||
|
; setup constants
|
||||||
|
|
||||||
|
lda XX
|
||||||
|
eor #$FF
|
||||||
|
sta MINUSXX
|
||||||
|
inc MINUSXX
|
||||||
|
|
||||||
|
lda YY
|
||||||
|
eor #$FF
|
||||||
|
sta MINUSYY
|
||||||
|
inc MINUSYY
|
||||||
|
|
||||||
|
; HPLOT CX+X,CY+Y
|
||||||
|
; HPLOT CX-X,CY+Y
|
||||||
|
; HPLOT CX+X,CY-Y
|
||||||
|
; HPLOT CX-X,CY-Y
|
||||||
|
; HPLOT CX+Y,CY+X
|
||||||
|
; HPLOT CX-Y,CY+X
|
||||||
|
; HPLOT CX+Y,CY-X
|
||||||
|
; HPLOT CX-Y,CY-X
|
||||||
|
|
||||||
|
lda #3
|
||||||
|
sta COUNT
|
||||||
|
pos_loop:
|
||||||
|
|
||||||
|
; calc left side
|
||||||
|
|
||||||
|
; calc X co-ord
|
||||||
|
|
||||||
|
lda COUNT
|
||||||
|
ora #$1
|
||||||
|
eor #$2
|
||||||
|
tax
|
||||||
|
; lda CX
|
||||||
|
|
||||||
|
|
||||||
|
lda #128
|
||||||
|
clc
|
||||||
|
adc XX,X
|
||||||
|
tax
|
||||||
|
|
||||||
|
; calc y co-ord
|
||||||
|
|
||||||
|
ldx COUNT
|
||||||
|
; lda CY
|
||||||
|
lda #96
|
||||||
|
clc
|
||||||
|
adc XX,X
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
jsr HPLOT0 ; plot at (Y,X), (A)
|
||||||
|
|
||||||
|
|
||||||
|
; calc right side
|
||||||
|
lda COUNT
|
||||||
|
and #$2
|
||||||
|
eor #$2
|
||||||
|
tax
|
||||||
|
lda XX,X
|
||||||
|
asl
|
||||||
|
|
||||||
|
jsr combo_hlinrl ; plot relative (X,A), (Y)
|
||||||
|
; so in our case (0,XX*2),0
|
||||||
|
|
||||||
|
|
||||||
|
dec COUNT
|
||||||
|
bpl pos_loop
|
||||||
|
|
||||||
|
; IF YY>=XX THEN 4
|
||||||
|
; equivelant to IF XX<YY
|
||||||
|
; but sadly appears we need IF XX<=YY for same effect
|
||||||
|
lda YY
|
||||||
|
cmp XX
|
||||||
|
bcs circle_loop
|
||||||
|
|
||||||
|
done:
|
||||||
|
ldx R
|
||||||
|
inx ; increment radius
|
||||||
|
jsr HCOLOR1 ; use as color
|
||||||
|
|
||||||
|
cpx #48 ; run until R=48
|
||||||
|
bne draw_next ; loop (GOTO 1)
|
||||||
|
|
||||||
|
rdone:
|
@ -147,7 +147,7 @@ pos_loop:
|
|||||||
|
|
||||||
|
|
||||||
; IF YY>=XX THEN 4
|
; IF YY>=XX THEN 4
|
||||||
; 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 same effect
|
||||||
lda YY
|
lda YY
|
||||||
cmp XX
|
cmp XX
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
|
; shimmery blue pattern
|
||||||
|
; X=48 here, can't count on others
|
||||||
|
|
||||||
staggered:
|
staggered:
|
||||||
|
stx FRAME ; set FRAME to 48
|
||||||
|
|
||||||
|
ldx #$00 ; init X to 0
|
||||||
|
stx GBASL ; set GBASL to 0
|
||||||
|
|
||||||
; pulse loop horizontal
|
; pulse loop horizontal
|
||||||
|
|
||||||
lda #$00
|
|
||||||
tay
|
|
||||||
tax
|
|
||||||
sta GBASL
|
|
||||||
|
|
||||||
outer_loop:
|
outer_loop:
|
||||||
lda #$40
|
lda #$40 ; reset GBASH to begin page2
|
||||||
sta GBASH
|
sta GBASH
|
||||||
|
|
||||||
inner_loop:
|
inner_loop:
|
||||||
|
lda even_lookup,X ; get even color
|
||||||
lda even_lookup,X
|
sta (GBASL),Y ; store it to memory
|
||||||
sta (GBASL),Y
|
|
||||||
iny
|
iny
|
||||||
|
|
||||||
lda odd_lookup,X
|
lda odd_lookup,X ; get odd color
|
||||||
sta (GBASL),Y
|
sta (GBASL),Y ; store it to memory
|
||||||
|
|
||||||
iny
|
iny
|
||||||
bne inner_loop
|
|
||||||
|
|
||||||
inc GBASH
|
bne inner_loop ; repeat for 256
|
||||||
|
|
||||||
inx
|
inc GBASH ; point to next page
|
||||||
|
|
||||||
|
inx ; wrap lookup at 8
|
||||||
txa
|
txa
|
||||||
and #$7
|
and #$7
|
||||||
tax
|
tax
|
||||||
|
|
||||||
|
lda #$60 ; see if done
|
||||||
lda #$60
|
|
||||||
cmp GBASH
|
cmp GBASH
|
||||||
bne inner_loop
|
bne inner_loop
|
||||||
|
|
||||||
; lda #100
|
; lda #100 ; A is $60 here
|
||||||
jsr WAIT
|
jsr WAIT ; pause a bit
|
||||||
|
|
||||||
inx
|
; A is 0 here
|
||||||
|
|
||||||
dec FRAME
|
inx ; offset next FRAME
|
||||||
|
|
||||||
|
dec FRAME ; exit after so many frames
|
||||||
|
|
||||||
bne outer_loop
|
bne outer_loop
|
||||||
|
|
||||||
@ -50,4 +50,3 @@ inner_loop:
|
|||||||
;.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
|
;.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
|
||||||
;odd_lookup:
|
;odd_lookup:
|
||||||
;.byte $AA,$AA,$AA,$AB, $AB,$AE,$BA,$EA
|
;.byte $AA,$AA,$AA,$AB, $AB,$AE,$BA,$EA
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user