mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-08-05 02:25:03 +00:00
starpath: first assembly version
slow slow slow
This commit is contained in:
@@ -7,15 +7,16 @@ TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
|
||||
LINKERSCRIPTS = ../../../linker_scripts
|
||||
EMPTYDISK = ../../../empty_disk
|
||||
|
||||
all: starpath.dsk ANDOR
|
||||
all: starpath.dsk ANDOR STARPATH
|
||||
|
||||
$(DOS33):
|
||||
cd ../../utils/dos33fs-utils && make
|
||||
|
||||
starpath.dsk: $(DOS33) HELLO STARPATH.BAS
|
||||
starpath.dsk: $(DOS33) HELLO STARPATH.BAS STARPATH
|
||||
cp $(EMPTYDISK)/empty.dsk starpath.dsk
|
||||
$(DOS33) -y starpath.dsk SAVE A HELLO
|
||||
$(DOS33) -y starpath.dsk SAVE A STARPATH.BAS
|
||||
$(DOS33) -y starpath.dsk BSAVE -a 0xc00 STARPATH
|
||||
|
||||
|
||||
|
||||
@@ -38,9 +39,18 @@ ANDOR: andor.o
|
||||
andor.o: andor.s
|
||||
ca65 -o andor.o andor.s -l andor.lst
|
||||
|
||||
####
|
||||
|
||||
STARPATH: starpath.o
|
||||
ld65 -o STARPATH starpath.o -C $(LINKERSCRIPTS)/apple2_c00.inc
|
||||
|
||||
starpath.o: starpath.s
|
||||
ca65 -o starpath.o starpath.s -l starpath.lst
|
||||
|
||||
|
||||
###
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o HELLO STARPATH.BAS *.lst
|
||||
rm -f *~ *.o HELLO STARPATH.BAS STARPATH *.lst
|
||||
|
||||
|
@@ -1,20 +1,16 @@
|
||||
; calculates &X,Y,Z,C
|
||||
; C = (X|Y)&Z
|
||||
|
||||
|
||||
; Routine for calling from &
|
||||
; when called next char/token in A
|
||||
; can't return anything unless you look up a variable by name
|
||||
; and write to it
|
||||
|
||||
; USER() can take one argument, returns value
|
||||
|
||||
; dump with od -t u1 ./ANDOR
|
||||
|
||||
VARPNTL = $83
|
||||
VARPNTH = $84
|
||||
|
||||
|
||||
FRMEVL = $DD7B
|
||||
GETADDR= $E752
|
||||
CHKCOM = $DEBE
|
||||
@@ -22,33 +18,33 @@ SNGFLT = $E301
|
||||
PTRGET = $DFE3 ; returns pointer to variable in VARPNT and (Y,A)
|
||||
MOVMF = $EB2B
|
||||
|
||||
; 58 bytes -- first working value
|
||||
; 48 bytes -- make it recursive
|
||||
|
||||
andor:
|
||||
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
|
||||
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
|
||||
jsr CHKCOM ; 20 BE DE move past comma
|
||||
lda $50
|
||||
jsr oog
|
||||
sta $24
|
||||
|
||||
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
|
||||
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
|
||||
jsr CHKCOM ; 20 BE DE move past comma
|
||||
lda $50 ; A5 50
|
||||
jsr oog
|
||||
sta $25 ; 85 50
|
||||
|
||||
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
|
||||
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
|
||||
jsr CHKCOM ; 20 BE DE move past comma
|
||||
jsr oog
|
||||
|
||||
lda $24 ; A5 24
|
||||
ora $25 ; 05 25
|
||||
and $50 ; 25 50
|
||||
sta $24
|
||||
pha
|
||||
|
||||
jsr PTRGET ; 20 E3 DF
|
||||
ldy $24 ; A8
|
||||
pla
|
||||
tay
|
||||
jsr SNGFLT ; 20 01 E3 unsigned Y -> FAC
|
||||
|
||||
ldx VARPNTL ;VARPNT
|
||||
ldy VARPNTH ;VARPNT+1
|
||||
jmp MOVMF
|
||||
|
||||
oog:
|
||||
jsr FRMEVL ; 20 7B DD (or FRMNUM) 20 67 DD value->FAC
|
||||
jsr GETADDR ; 20 52 E7 FAC-> LINNUM ($50/$51)
|
||||
jsr CHKCOM ; 20 BE DE move past comma
|
||||
lda $50
|
||||
rts
|
||||
|
@@ -1,12 +1,11 @@
|
||||
0FOR I=0 TO 57:READ D:POKE 768+I,D:NEXT:POKE 1014,0:POKE 1015,3
|
||||
1DIML(16):FORI=0TO14:READL(I):NEXT:GR:POKE49234,0
|
||||
0 REM
|
||||
1FOR I=0 TO 46:READ D:POKE 768+I,D:NEXT:POKE 1014,0:POKE 1015,3:DIML(16):FORI=0TO14:READL(I):NEXT:GR:POKE49234,0
|
||||
2FORY=0TO47:FORX=0TO39:D=I
|
||||
3Z=Y*4*D:T=X*6-D:IFT<0THENC=31:A=X*6+Z:&0,A,255,A:GOTO8
|
||||
4&T*D/256,Z/256,D+F,C:D=D+1:A=0:IFC<16THEN3
|
||||
8IFA>6THENC=Y/4+32
|
||||
9COLOR=L(C/2-8):PLOTX,Y:NEXTX,Y:F=F+1:GOTO2
|
||||
100 DATA 32,123,221,32,82,231,32,190,222,165,80,133,36,32,123,221
|
||||
110 DATA 32,82,231,32,190,222,165,80,133,37,32,123,221,32,82,231
|
||||
120 DATA 32,190,222,165,36,5,37,37,80,133,36,32,227,223,164,36
|
||||
130 DATA 32,1,227,166,131,164,132,76,43,235
|
||||
100 DATA 32,35,3,133,36,32,35,3,133,37,32,35,3,165,36,5
|
||||
110 DATA 37,37,80,72,32,227,223,104,168,32,1,227,166,131,164,132
|
||||
120 DATA 76,43,235,32,123,221,32,82,231,32,190,222,165,80,96
|
||||
140 DATA0,5,10,5,10,7,15,15,2,1,3,9,13,12,4,4
|
||||
|
194
graphics/gr/starpath/starpath.s
Normal file
194
graphics/gr/starpath/starpath.s
Normal file
@@ -0,0 +1,194 @@
|
||||
PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved)
|
||||
PLOT1 = $F80E ; PLOT at (GBASL),Y (need MASK to be $0f or $f0)
|
||||
|
||||
SETCOL = $F864 ; COLOR=A
|
||||
SETGR = $FB40
|
||||
|
||||
FULLGR = $C052
|
||||
|
||||
FRAME = $F0
|
||||
YPOS = $F1
|
||||
XPOS = $F2
|
||||
D = $F3
|
||||
C = $F4
|
||||
AL = $F5
|
||||
AH = $F6
|
||||
PRODLO = $F7
|
||||
FACTOR2 = $F8
|
||||
YPL = $F9
|
||||
YPH = $FA
|
||||
XPL = $FB
|
||||
XPH = $FC
|
||||
Q = $FD
|
||||
|
||||
;=============================
|
||||
;=============================
|
||||
; star path
|
||||
;=============================
|
||||
;=============================
|
||||
|
||||
starpath:
|
||||
;=============================
|
||||
; setup graphics
|
||||
;=============================
|
||||
|
||||
jsr SETGR ; set graphics
|
||||
bit $C052 ; set full-screen graphics
|
||||
|
||||
;=============================
|
||||
; initialize
|
||||
;=============================
|
||||
|
||||
lda #0
|
||||
sta FRAME
|
||||
|
||||
big_loop:
|
||||
lda #0 ; start with YPOS=0
|
||||
sta YPOS
|
||||
yloop:
|
||||
lda #0 ; start with XPOS=0
|
||||
sta XPOS
|
||||
xloop:
|
||||
lda #14
|
||||
sta D ; start D at 14
|
||||
|
||||
loop3:
|
||||
lda YPOS ; YP=Y*4*D
|
||||
asl
|
||||
asl ; YPOS*4
|
||||
|
||||
tay ; multiply Y*4*D
|
||||
lda D
|
||||
jsr mul8
|
||||
|
||||
sta YPH ; store out to YPH:YPL
|
||||
lda PRODLO
|
||||
sta YPL
|
||||
|
||||
lda XPOS ; XP=(X*6)-D
|
||||
asl
|
||||
sta XPL
|
||||
asl
|
||||
clc
|
||||
adc XPL
|
||||
sta XPL ; XPL=X*6
|
||||
|
||||
sta AL ; AL also is X*6
|
||||
|
||||
sec ; XPL=X*6-D
|
||||
sbc D
|
||||
sta XPL
|
||||
|
||||
bpl loop4 ;IF XP<0 THEN
|
||||
|
||||
lda #31 ; C=31
|
||||
sta C
|
||||
|
||||
clc
|
||||
lda AL
|
||||
adc YPL ; A=X*6+YP
|
||||
sta AL
|
||||
|
||||
lda #0 ; AH
|
||||
adc YPH
|
||||
sta AH
|
||||
|
||||
jmp loop7 ; GOTO7
|
||||
|
||||
loop4:
|
||||
; Q=XP*D/256
|
||||
ldy XPL
|
||||
lda D
|
||||
jsr mul8
|
||||
ora YPH ; R=YP/256
|
||||
sta Q ; Q=ora Q,R
|
||||
|
||||
clc
|
||||
lda D ;and D+F
|
||||
adc FRAME
|
||||
and Q
|
||||
|
||||
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
|
||||
clc
|
||||
adc #32
|
||||
sta C
|
||||
loop9:
|
||||
lda C
|
||||
lsr
|
||||
sec
|
||||
sbc #8
|
||||
tax
|
||||
lda color_lookup,X
|
||||
jsr SETCOL ;COLOR=CL(C/2-8)
|
||||
|
||||
ldy XPOS
|
||||
lda YPOS
|
||||
jsr PLOT ; PLOT AT Y,A (Y preserved)
|
||||
|
||||
inc XPOS
|
||||
lda XPOS
|
||||
cmp #40
|
||||
; bne xloop
|
||||
beq xloop_done
|
||||
jmp xloop
|
||||
xloop_done:
|
||||
inc YPOS
|
||||
lda YPOS
|
||||
cmp #48
|
||||
;bne yloop
|
||||
beq yloop_done
|
||||
jmp yloop
|
||||
yloop_done:
|
||||
inc FRAME
|
||||
|
||||
jmp big_loop
|
||||
|
||||
color_lookup:
|
||||
.byte 0,5,10,5,10,7,15,15,2,1,3,9,13,12,4,4
|
||||
|
||||
|
||||
; Russian Peasant multiply by Thwaite
|
||||
; https://www.nesdev.org/wiki/8-bit_Multiply
|
||||
;
|
||||
; Multiplies two 8-bit factors to produce a 16-bit product
|
||||
; in about 153 cycles.
|
||||
; @param A one factor
|
||||
; @param Y another factor
|
||||
; @return high 8 bits in A; low 8 bits in PRODLO
|
||||
; Y and FACTOR2 are trashed; X is untouched
|
||||
|
||||
mul8:
|
||||
; Factor 1 is stored in the lower bits of prodlo; the low byte of
|
||||
; the product is stored in the upper bits.
|
||||
|
||||
lsr ; prime the carry bit for the loop
|
||||
sta PRODLO
|
||||
sty FACTOR2
|
||||
lda #0
|
||||
ldy #8
|
||||
mul8_loop:
|
||||
; At the start of the loop, one bit of prodlo has already been
|
||||
; shifted out into the carry.
|
||||
bcc mul8_noadd
|
||||
clc
|
||||
adc FACTOR2
|
||||
mul8_noadd:
|
||||
ror
|
||||
ror PRODLO ; pull another bit out for the next iteration
|
||||
dey ; inc/dec don't modify carry; only shifts and adds do
|
||||
bne mul8_loop
|
||||
rts
|
||||
|
Reference in New Issue
Block a user