mode7: more work on starfield

This commit is contained in:
Vince Weaver 2017-12-30 10:04:22 -05:00
parent 9e4b1c132a
commit 04205b7d2b

View File

@ -55,6 +55,7 @@ starfield_loop:
ldx #NUMSTARS ldx #NUMSTARS
draw_stars: draw_stars:
stx XX
txa txa
tay tay
@ -63,19 +64,28 @@ draw_stars:
lda #$ff lda #$ff
sta COLOR sta COLOR
sty YPOS
; calculate x value, stars[i].x/stars[i].z ; calculate x value, stars[i].x/stars[i].z
; put 1/stars[i].z in NUM1H:NUM1L and multiply
lda #20 ldy YPOS
ldy #20 sty XPOS
lda star_z,Y
sta NUM1H ; I
lda #0 ; I
sta NUM1H
lda #0 ; F lda #0 ; F
sta NUM1L sta NUM1L
lda #1 ; load stars[i].x into NUM2H:NUM2L
; NUM2L is always zero
lda star_x,Y
sta NUM2H sta NUM2H
lda #2
lda #0
sta NUM2L sta NUM2L
sec ; don't reuse old values sec ; don't reuse old values
jsr multiply jsr multiply
@ -84,7 +94,8 @@ draw_stars:
txa txa
clc clc
adc #20 adc #20
sta XX ; sta XPOS
; calculate y value, stars[i].y/stars[i].z ; calculate y value, stars[i].y/stars[i].z
@ -106,7 +117,7 @@ draw_stars:
adc #20 adc #20
tay ; put Y value in Y to plot tay ; put Y value in Y to plot
lda XX ; reload X value to plot lda XPOS ; reload X value to plot
;================================ ;================================
; plot routine ; plot routine
@ -151,6 +162,7 @@ plot_write:
;============================== ;==============================
ldx XX
dex dex
bpl draw_stars bpl draw_stars