starfield: Finally

just make the math inaccurate
This commit is contained in:
Vince Weaver 2021-06-12 12:36:43 -04:00
parent bdf64d1d2d
commit 45094f7b9f
6 changed files with 111 additions and 46 deletions

View File

@ -16,7 +16,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \
C64.BAS SIERPINSKI.BAS FAKES.BAS SIER.BAS DROPS.BAS RR.BAS RR_HGR.BAS \
COMBO.BAS WIRES.BAS PATTERN.BAS BALL.BAS LINES.BAS MOD9.BAS \
XOR_ZOOM.BAS MOD9_HGR.BAS SIER_HGR.BAS MOVE.BAS SINE.BAS XDRAW128.BAS \
GATOR.BAS CURSOR.BAS STARGATE.BAS TUNNEL.BAS
GATOR.BAS CURSOR.BAS STARGATE.BAS TUNNEL.BAS STARFIELD.BAS
# cp $(EMPTY_DISK)/empty.dsk appleiibot.dsk
cp empty.dsk appleiibot.dsk
@ -85,6 +85,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \
$(DOS33) -y appleiibot.dsk SAVE A CURSOR.BAS
$(DOS33) -y appleiibot.dsk SAVE A STARGATE.BAS
$(DOS33) -y appleiibot.dsk SAVE A TUNNEL.BAS
$(DOS33) -y appleiibot.dsk SAVE A STARFIELD.BAS
####
@ -268,6 +269,11 @@ STARGATE.BAS: stargate.bas
TUNNEL.BAS: tunnel.bas
$(TOKENIZE) < tunnel.bas > TUNNEL.BAS
####
STARFIELD.BAS: starfield.bas
$(TOKENIZE) < starfield.bas > STARFIELD.BAS
####

View File

@ -0,0 +1,2 @@
1FORI=0TO138:POKE877+I,4*PEEK(2125+I)-192+(PEEK(2264+I/3)-35)/4^(I-INT(I/3)*3):NEXT
2&",=nU38U.b*lX2ZD8ZoV/Q<]L]P8,m]L5f(::b:\0Oo]T8c0Z<7`:\6eHl3a<PJ\$5GnULSnUP80ba0)]0Z2_;]Yn^0kUTZ/lQW^,k::10MFioH2/0Bk5J$Uo^=m@2nV:4#?o5J5DBK0S1RK*#4#$3SF$I$2##%+-V#<#S_E'*'445:D&76T3C#Y'3&

View File

@ -21,7 +21,7 @@ starfield.dsk: $(DOS33) HELLO STARFIELD_DEMO STARFIELD_1K STARFIELD.BAS \
$(DOS33) -y starfield.dsk BSAVE -a 0x1000 STARFIELD_1K
$(DOS33) -y starfield.dsk BSAVE -a 0xc00 STARSMALL
$(DOS33) -y starfield.dsk BSAVE -a 0xc00 STARBOT_LOOKUP
$(DOS33) -y starfield.dsk BSAVE -a 0xc00 STARBOT
$(DOS33) -y starfield.dsk BSAVE -a 0x36d STARBOT
###
@ -69,7 +69,7 @@ starsmall.o: starsmall.s
###
STARBOT: starbot.o
ld65 -o STARBOT starbot.o -C $(LINKERSCRIPTS)/apple2_c00.inc
ld65 -o STARBOT starbot.o -C $(LINKERSCRIPTS)/apple2_36d.inc
starbot.o: starbot.s
ca65 -o starbot.o starbot.s -l starbot.lst

View File

@ -15,6 +15,11 @@
; 133 bytes -- undo opt, no lookup table, just raw divide
; 145 bytes -- init stars at beginning, so don't initially run bacward if Z=FF
; 135 bytes -- optimize divide some more
; 143 bytes -- add in different color star
; 142 bytes -- closer :(
; trying all kinds of stuff, including using BELL for WAIT
; 139 bytes -- just made math innacurate (remove sec in sign correction)
COLOR = $30
@ -77,7 +82,21 @@ make_orig_stars:
;2FORP=0TO5
big_loop:
ldx #15
; txa
; tay
; ldy #30
; jsr $FBE4 ; BEEP
lda #80
; txa
jsr WAIT
; A now 0
star_loop:
; X=FF
;===================
; erase old
@ -111,12 +130,11 @@ star_loop:
jsr do_divide
sta YY ; YY
bmi new_star ; if <0
cmp #40
bcs new_star ; bge >39
sta YY ; YY
;==============================
; get X/Z
@ -181,11 +199,15 @@ done_star:
dex
bpl star_loop
lda #120
jsr WAIT ; A is 0 after
; lda #120
; jsr WAIT ; A is 0 after
; jsr $FBE2 ; BEEP
; jsr $FBE4 ; BEEP
; GOTO2
beq big_loop ; bra
; beq big_loop ; bra
bmi big_loop ; bra
;===========================
@ -246,8 +268,8 @@ div_loop:
bpl pos_add
eor #$ff
sec
bcs do_add
; sec
; bcs do_add
pos_add:
clc
@ -261,5 +283,5 @@ early_out:
; for BASIC bot load
; need this to be at $3F5
; it's at 8A, so 6B
; it's at 8C, so 6D
jmp small_starfield

View File

@ -1,8 +1,10 @@
; starfield
; actually too fast
; original 189 bytes
COLOR = $30
COUNT = $FA
QUOTIENT = $FA
DIVISOR = $FB
DIVIDEND = $FC
XX = $FD
@ -24,7 +26,7 @@ HGR2 = $F3D8
HGR = $F3E2
PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved)
SETGR = $FB40
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
small_starfield:
@ -35,31 +37,49 @@ small_starfield:
; init the X/Z tables
ldy #63 ; Y==z for(z=1;z<64;z++) {
xloop:
ldx #0 ; X==x
zloop:
lda #$ff
sta COUNT
sta QUOTIENT
stx DIVIDEND
sty DIVISOR
div_loop:
inc COUNT
inc QUOTIENT
sec
lda DIVIDEND
sbc DIVISOR
sta DIVIDEND
bpl div_loop
lda COUNT
; write out quotient
lda QUOTIENT
pha
clc
adc #20
to_smc:
sta $5F00,X
sta $5F80,X
inx
bne zloop
bpl zloop ; loop until 128
ldx #0
negative_loop:
pla
eor #$ff
sec
adc #20
to2_smc:
sta $5F00,X
inx
bpl negative_loop
dec to_smc+2
dec to2_smc+2
dey
bne zloop
bne xloop
;===================================
@ -81,40 +101,41 @@ star_loop:
; get X/Z
; X=V(A(P),Z(P))
; position Z
lda star_z,X
asl
asl
asl
asl
ora #$20
clc
adc #$20
sta xload_smc+2
sta xload2_smc+2
; get XX
ldy star_x,X
xload_smc:
lda $5F00,Y
sta XX
bmi new_star
cmp #39
bcs new_star
bmi new_star ; if <0
cmp #40
bcs new_star ; bge >40
;==============================
; get Y/Z
; Y=V(B(P),Z(P))
ldy star_y,X
; get YY
ldy star_y,X
xload2_smc:
lda $5F00,Y
sta YY
bmi new_star
cmp #39
bcs new_star
bmi new_star ; if <0
cmp #40
bcs new_star ; bge >39
;Z(P)=Z(P)-1
dec star_z,X
bne draw_star
bne draw_star ; if Z!=0, draw star
new_star:
;IFX<0ORX>39ORY<0ORY>39ORZ(P)<1THEN
@ -124,16 +145,17 @@ new_star:
ldy FRAME
lda $F000,Y
; and #$3f
sta star_x,X
sta star_x,X ; random XX
lda $F001,Y
; and #$3f
sta star_y,X
sta star_y,X ; random YY
lda $F002,Y
and #$3f
and #$3f ; random ZZ 0..63
ora #$1 ; avoid 0
sta star_z,X
iny
iny ; FIXME
iny
iny
sty FRAME
@ -149,24 +171,22 @@ draw_star:
;PLOT O(P),Q(P)
ldy oldx,X
lda oldy,Y
lda oldy,X
jsr PLOT ; PLOT AT Y,A
; COLOR=15
dec COLOR
;PLOT X,Y
ldy XX
lda YY
jsr PLOT ; PLOT AT Y,A
; O(P)=X:Q(P)=Y
lda XX
sta oldx,X
tay
lda YY
sta oldy,X
jsr PLOT ; PLOT AT Y,A
done_star:
;7NEXT
@ -174,6 +194,9 @@ done_star:
dex
bpl star_loop
lda #100
jsr WAIT
; GOTO2
jmp big_loop

View File

@ -0,0 +1,12 @@
MEMORY {
ZP: start = $00, size = $1A, type = rw;
RAM: start = $36d, size = $8E00, file = %O;
}
SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}