starbot: improve comments

This commit is contained in:
Vince Weaver 2021-06-12 13:01:26 -04:00
parent 45094f7b9f
commit 546cf5918c

View File

@ -20,9 +20,16 @@
; trying all kinds of stuff, including using BELL for WAIT ; trying all kinds of stuff, including using BELL for WAIT
; 139 bytes -- just made math innacurate (remove sec in sign correction) ; 139 bytes -- just made math innacurate (remove sec in sign correction)
; zero page locations
COLOR = $30 COLOR = $30
star_z = $60
oldx = $70
oldy = $80
star_x = $90
star_y = $A0
NEGATIVE = $F9 NEGATIVE = $F9
QUOTIENT = $FA QUOTIENT = $FA
DIVISOR = $FB DIVISOR = $FB
@ -31,22 +38,12 @@ XX = $FD
YY = $FE YY = $FE
FRAME = $FF FRAME = $FF
star_z = $60 ; soft-switches
oldx = $70
oldy = $80
star_x = $90
star_y = $A0
;oldx = $1000
;oldy = $1040
;star_x = $2000 ; should be 0, not used as we never /0
;star_y = $2040
;star_z = $2080
LORES = $C056 ; Enable LORES graphics LORES = $C056 ; Enable LORES graphics
; ROM routines
HGR2 = $F3D8 HGR2 = $F3D8
HGR = $F3E2 HGR = $F3E2
PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved)
@ -65,10 +62,8 @@ small_starfield:
; draw the stars ; draw the stars
;=================================== ;===================================
; bit LORES ; there are ways to skip this, but on real hardware there's
; jsr SETGR ; no guarantee star_z will be in a valid state, so waste the bytes
; tax
ldx #15 ldx #15
make_orig_stars: make_orig_stars:
@ -79,19 +74,17 @@ make_orig_stars:
;=================================== ;===================================
; starloop ; starloop
;2FORP=0TO5 ;2FORP=0TO15
big_loop: big_loop:
ldx #15 ldx #15
; really tried hard not to have to set this value
; txa ; hard to judge best value for this
; tay
; ldy #30
; jsr $FBE4 ; BEEP
lda #80 lda #80
; txa
jsr WAIT jsr WAIT
; jsr $FBE4 ; BEEP delays too
; A now 0 ; A now 0
@ -99,10 +92,10 @@ star_loop:
; X=FF ; X=FF
;=================== ;===================
; erase old ; erase old star
;4 COLOR=0 ;4 COLOR=0
lda #$00 lda #$00 ; color to black
sta COLOR sta COLOR
;PLOT O(P),Q(P) ;PLOT O(P),Q(P)
@ -118,7 +111,7 @@ star_loop:
; beq new_star ; should never happen ; beq new_star ; should never happen
; sta DIVISOR ; sta DIVISOR
; DIVISOR always star_z,X ; DIVISOR always star_z,X so can hard code this in divide routine
;============================== ;==============================
; get Y/Z ; get Y/Z
@ -130,6 +123,8 @@ star_loop:
jsr do_divide jsr do_divide
; if off-screen then need new star
bmi new_star ; if <0 bmi new_star ; if <0
cmp #40 cmp #40
bcs new_star ; bge >39 bcs new_star ; bge >39
@ -146,8 +141,9 @@ star_loop:
jsr do_divide jsr do_divide
; sta XX tay ; put XX in Y
tay
; if offscreen then draw new star
bmi new_star ; if <0 bmi new_star ; if <0
cpy #40 cpy #40
@ -166,17 +162,22 @@ draw_star:
; COLOR=15 ; COLOR=15
dec COLOR ; color from $00 (black) to $ff (white) dec COLOR ; color from $00 (black) to $ff (white)
; trouble causing code, wanted it two-tone
; this will make it white or blue depending on if odd or even star
; initially tried distance based color on Z, didn't look as good
txa txa
ror ror
bcs not_far bcs not_far
jsr NEXTCOL jsr NEXTCOL
; ror
; jsr NEXTCOL
; lda #$55
; sta COLOR ; FF -> 7F
not_far: not_far:
;===========================
; actually plot the star
;PLOT X,Y ;PLOT X,Y
; O(P)=X:Q(P)=Y ; O(P)=X:Q(P)=Y
@ -199,14 +200,7 @@ done_star:
dex dex
bpl star_loop bpl star_loop
; lda #120
; jsr WAIT ; A is 0 after
; jsr $FBE2 ; BEEP
; jsr $FBE4 ; BEEP
; GOTO2 ; GOTO2
; beq big_loop ; bra
bmi big_loop ; bra bmi big_loop ; bra
@ -238,7 +232,8 @@ color_lookup:
rts rts
;============================= ;=============================
; do divide ; do signed divide
; the signed part is the pain
;============================= ;=============================
; Z is in divisor ; Z is in divisor
; x/y is in A ; x/y is in A
@ -248,9 +243,9 @@ do_divide:
php php
bpl not_negative bpl not_negative
eor #$ff eor #$ff ; make positive for division
clc clc ; is this necessary?
adc #1 ; invert adc #1
not_negative: not_negative:
@ -268,13 +263,13 @@ div_loop:
bpl pos_add bpl pos_add
eor #$ff eor #$ff
; sec ; sec ; FIXME: made math inaccurate to save room
; bcs do_add ; bcs do_add
pos_add: pos_add:
clc clc
do_add: do_add:
adc #20 adc #20 ; pre-adjust to have star origin mid screen
early_out: early_out:
rts rts