mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-04-28 23:37:45 +00:00
starpath: optimize asm some more
This commit is contained in:
parent
6c56c915bd
commit
412d514049
@ -9,10 +9,10 @@ FULLGR = $C052
|
|||||||
FRAME = $F0
|
FRAME = $F0
|
||||||
YPOS = $F1
|
YPOS = $F1
|
||||||
XPOS = $F2
|
XPOS = $F2
|
||||||
D = $F3
|
DEPTH = $F3
|
||||||
C = $F4
|
C = $F4
|
||||||
AL = $F5
|
AL = $F5
|
||||||
AH = $F6
|
;AH = $F6
|
||||||
PRODLO = $F7
|
PRODLO = $F7
|
||||||
FACTOR2 = $F8
|
FACTOR2 = $F8
|
||||||
YPL = $F9
|
YPL = $F9
|
||||||
@ -42,7 +42,7 @@ starpath:
|
|||||||
lda #0
|
lda #0
|
||||||
sta FRAME
|
sta FRAME
|
||||||
|
|
||||||
big_loop:
|
next_frame:
|
||||||
lda #0 ; start with YPOS=0
|
lda #0 ; start with YPOS=0
|
||||||
sta YPOS
|
sta YPOS
|
||||||
yloop:
|
yloop:
|
||||||
@ -50,117 +50,179 @@ yloop:
|
|||||||
sta XPOS
|
sta XPOS
|
||||||
xloop:
|
xloop:
|
||||||
lda #14
|
lda #14
|
||||||
sta D ; start D at 14
|
sta DEPTH ; start Depth at 14
|
||||||
|
|
||||||
loop3:
|
depth_loop:
|
||||||
lda YPOS ; YP=Y*4*D
|
;===============
|
||||||
|
; YP = Y*4*DEPTH
|
||||||
|
;===============
|
||||||
|
|
||||||
|
lda YPOS ;
|
||||||
asl
|
asl
|
||||||
asl ; YPOS*4
|
asl ; A is YPOS*4
|
||||||
|
|
||||||
tay ; multiply Y*4*D
|
tay ; multiply Y*4*DEPTH
|
||||||
lda D
|
lda DEPTH
|
||||||
jsr mul8 ; definitely 8-bit mul in original
|
jsr mul8 ; 8-bit unsigned multiply
|
||||||
|
|
||||||
sta YPH ; store out to YPH:YPL
|
sta YPH ; store out to YPH:YPL
|
||||||
lda PRODLO
|
lda PRODLO
|
||||||
sta YPL
|
sta YPL
|
||||||
|
|
||||||
lda XPOS ; XP=(X*6)-D curve X by depth
|
;========================
|
||||||
|
; XP=(X*6)-DEPTH
|
||||||
|
; curve X by depth
|
||||||
|
;=========================
|
||||||
|
|
||||||
|
lda XPOS ; load XPOS
|
||||||
asl
|
asl
|
||||||
sta XPL
|
sta XPL
|
||||||
asl
|
asl
|
||||||
clc
|
;clc ; carry always 0 as x never more than 40?
|
||||||
adc XPL
|
adc XPL
|
||||||
sta XPL ; XPL=X*6
|
sta XPL ; XPL=XPOS*6
|
||||||
|
|
||||||
sta AL ; AL also is X*6
|
sta AL ; AL also is XPOS*6
|
||||||
|
|
||||||
sec ; XPL=X*6-D
|
sec ; Subtract DEPTH
|
||||||
sbc D
|
sbc DEPTH
|
||||||
sta XPL
|
sta XPL ; XP=(XPOS*6)-DEPTH
|
||||||
|
|
||||||
bcs loop4 ; IF XP<0 THEN if left then draw sky
|
; if carry set means not negative
|
||||||
|
; and draw path
|
||||||
|
; otherwise we draw the sky
|
||||||
|
bcs draw_path
|
||||||
|
|
||||||
|
;========================
|
||||||
|
; draw the sky
|
||||||
|
;========================
|
||||||
|
draw_sky:
|
||||||
|
|
||||||
|
;================================
|
||||||
|
; set color to white for star?
|
||||||
|
|
||||||
lda #31 ; C=31
|
lda #31 ; C=31
|
||||||
sta C
|
sta C
|
||||||
|
|
||||||
|
;=====================
|
||||||
|
; calc A=(XPOS*6)+YP
|
||||||
|
|
||||||
|
; ??? used to see if star
|
||||||
|
|
||||||
clc
|
clc
|
||||||
lda AL
|
lda AL
|
||||||
adc YPL ; A=X*6+YP
|
adc YPL ; A=X*6+YP
|
||||||
sta AL
|
|
||||||
|
|
||||||
lda #0 ; AH
|
;==============
|
||||||
adc YPH
|
; see if star
|
||||||
sta AH
|
|
||||||
|
|
||||||
jmp loop7 ; GOTO7
|
cmp #6 ; if A&0xFF < 6 then skip, we are star
|
||||||
|
bcc plot_pixel
|
||||||
|
|
||||||
loop4:
|
;==============
|
||||||
; Q=XP*D/256 multiply X by current depth
|
; not star, sky
|
||||||
; want high part
|
|
||||||
; definitely 8-bit mul
|
|
||||||
ldy XPL
|
|
||||||
lda D
|
|
||||||
jsr mul8
|
|
||||||
ora YPH ; R=YP/256
|
|
||||||
sta Q ; Q=ora Q,R
|
|
||||||
; or for texture pattern
|
|
||||||
clc
|
|
||||||
lda D ; add depth plus frame D+F
|
|
||||||
adc FRAME
|
|
||||||
|
|
||||||
and Q ; mask geometry by time shifted depth
|
lda YPOS ; C=Y/4+32
|
||||||
|
|
||||||
sta C
|
|
||||||
inc D ; D=D+1
|
|
||||||
cmp #16 ; IF C<16 THEN 3
|
|
||||||
bcc loop3
|
|
||||||
loop6:
|
|
||||||
jmp loop9
|
|
||||||
loop7:
|
|
||||||
lda AL
|
|
||||||
cmp #6
|
|
||||||
bcc loop9
|
|
||||||
; 8IF(A&0xff)>6THENC=Y/4+32
|
|
||||||
lda YPOS
|
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
clc
|
clc
|
||||||
adc #32
|
adc #32
|
||||||
sta C
|
sta C
|
||||||
loop9:
|
|
||||||
|
bne plot_pixel ; bra
|
||||||
|
|
||||||
|
;====================
|
||||||
|
; draw path
|
||||||
|
;====================
|
||||||
|
|
||||||
|
draw_path:
|
||||||
|
;=================================
|
||||||
|
; calc XP*DEPTH and get high byte
|
||||||
|
|
||||||
|
ldy XPL
|
||||||
|
lda DEPTH
|
||||||
|
jsr mul8 ; A=XP*DEPTH
|
||||||
|
|
||||||
|
;===================================
|
||||||
|
; calc Q= (XP*DEPTH)/256 | (YP/256)
|
||||||
|
; for texture pattern
|
||||||
|
|
||||||
|
ora YPH ; Q=(XP*DEPTH)/256 | YP/256
|
||||||
|
sta Q
|
||||||
|
|
||||||
|
;==============================
|
||||||
|
; calc C = Q & (Depth + Frame)
|
||||||
|
; mask geometry by time shifted depth
|
||||||
|
|
||||||
|
clc
|
||||||
|
lda DEPTH
|
||||||
|
adc FRAME ; add depth plus frame D+F
|
||||||
|
|
||||||
|
and Q ; C = Q & (D+FRAME)
|
||||||
|
sta C
|
||||||
|
|
||||||
|
;=========================
|
||||||
|
; increment depth
|
||||||
|
|
||||||
|
inc DEPTH ; DEPTH=DEPTH+1
|
||||||
|
|
||||||
|
;==========================
|
||||||
|
; to create gaps
|
||||||
|
|
||||||
|
cmp #16 ; IF C<16 THEN 3
|
||||||
|
bcc depth_loop
|
||||||
|
|
||||||
|
;===========================
|
||||||
|
; plot pixel
|
||||||
|
; XPOS,YPOS COLOR=LOOKUP(C/2-8)
|
||||||
|
plot_pixel:
|
||||||
lda C
|
lda C
|
||||||
lsr
|
lsr
|
||||||
sec
|
sec
|
||||||
sbc #8
|
sbc #8 ; A is C/2-8
|
||||||
|
|
||||||
tax
|
tax
|
||||||
lda color_lookup,X
|
lda color_lookup,X ; Lookup in color table
|
||||||
jsr SETCOL ;COLOR=CL(C/2-8)
|
|
||||||
|
;=====================
|
||||||
|
; set color
|
||||||
|
|
||||||
|
jsr SETCOL ; Set COLOR with ROM routine (mul*17)
|
||||||
|
|
||||||
|
;=====================
|
||||||
|
; plot point
|
||||||
|
|
||||||
ldy XPOS
|
ldy XPOS
|
||||||
lda YPOS
|
lda YPOS
|
||||||
jsr PLOT ; PLOT AT Y,A (Y preserved)
|
jsr PLOT ; PLOT AT Y,A (Y preserved)
|
||||||
|
|
||||||
|
;===================
|
||||||
|
; increment xloop
|
||||||
|
|
||||||
inc XPOS
|
inc XPOS
|
||||||
lda XPOS
|
lda XPOS
|
||||||
cmp #40
|
cmp #40
|
||||||
; bne xloop
|
bne xloop
|
||||||
beq xloop_done
|
; beq xloop_done
|
||||||
jmp xloop
|
; jmp xloop
|
||||||
xloop_done:
|
xloop_done:
|
||||||
|
|
||||||
|
;===================
|
||||||
|
; increment yloop
|
||||||
|
|
||||||
inc YPOS
|
inc YPOS
|
||||||
lda YPOS
|
lda YPOS
|
||||||
cmp #48
|
cmp #48
|
||||||
;bne yloop
|
; bne yloop
|
||||||
beq yloop_done
|
beq yloop_done
|
||||||
jmp yloop
|
jmp yloop
|
||||||
yloop_done:
|
yloop_done:
|
||||||
inc FRAME
|
inc FRAME
|
||||||
|
|
||||||
jmp big_loop
|
jmp next_frame
|
||||||
|
|
||||||
color_lookup:
|
color_lookup:
|
||||||
.byte 0,5,10,5,10,7,15,15,2,1,3,9,13,12,4,4
|
.byte 0,5,10,5,10,7,15,15,2,1,3,9,13,12
|
||||||
|
|
||||||
|
|
||||||
; Russian Peasant multiply by Thwaite
|
; Russian Peasant multiply by Thwaite
|
||||||
|
Loading…
x
Reference in New Issue
Block a user