firework: no more wrapping on left

also some cycle counting
This commit is contained in:
Vince Weaver 2018-09-10 22:36:41 -04:00
parent 3c90dcb39d
commit c59e93230a

View File

@ -353,8 +353,8 @@ done_with_loop:
not_done_with_launch: not_done_with_launch:
lda #$c0 ; lda #$c0
jsr WAIT ; jsr WAIT
inc CURRENT_STEP inc CURRENT_STEP
@ -369,6 +369,9 @@ not_done_with_launch:
start_explosion: start_explosion:
lda #0
sta XPOS_H
; Set X position ; Set X position
jsr random16 ; 6+42 jsr random16 ; 6+42
@ -376,13 +379,29 @@ start_explosion:
and #$f ; 0..15 ; 2 and #$f ; 0..15 ; 2
sec ; 2 sec ; 2
sbc #8 ; -8..7 ; 2 sbc #8 ; -8..7 ; 2
clc
vmw:
bmi blahblah
adc X_OLD ; 3 adc X_OLD ; 3
sta XPOS_L ; xpos=x_old+(random()%16)-8; x +/- 8 ; 3 sta XPOS_L ; xpos=x_old+(random()%16)-8; x +/- 8 ; 3
lda #0 lda #0
adc XPOS_H
sta XPOS_H sta XPOS_H
jmp blahblah2
blahblah:
adc X_OLD ; 3
sta XPOS_L ; xpos=x_old+(random()%16)-8; x +/- 8 ; 3
lda #$ff
adc XPOS_H
sta XPOS_H
blahblah2:
; FIXME: XPOS from 255-280. A hard problem. Makes everything ; FIXME: XPOS from 255-280. A hard problem. Makes everything
; more complicated, 16-bit math ; more complicated, 16-bit math
@ -434,20 +453,20 @@ continue_explosion:
; Draw spreading dots in white ; Draw spreading dots in white
cpy #9 ; 2 cpy #9 ; 2
beq explosion_erase beq explosion_erase ; ?
; hcolor_equals(color_group+3); ; hcolor_equals(color_group+3);
lda COLOR_GROUP lda COLOR_GROUP ; 3
clc clc ; 2
adc #$3 adc #$3 ; 2
tax tax ; 2
lda colortbl,X ; get color from table lda colortbl,X ; get color from table ; 4+
sta HGR_COLOR sta HGR_COLOR ; 3
ldx TEMPY ldx TEMPY ; 3
stx OFFSET stx OFFSET ; 3
jsr explosion jsr explosion ; 6+
explosion_erase: explosion_erase:
;====================== ;======================
@ -455,40 +474,40 @@ explosion_erase:
; erase with proper color black (0 or 4) ; erase with proper color black (0 or 4)
ldx COLOR_GROUP ldx COLOR_GROUP ; 3
lda colortbl,X ; get color from table lda colortbl,X ; get color from table ; 4+
sta HGR_COLOR sta HGR_COLOR ; 3
ldx TEMPY ldx TEMPY ; 3
dex dex ; 2
stx OFFSET stx OFFSET ; 3
jsr explosion jsr explosion ; 6
done_with_explosion: done_with_explosion:
lda #$c0 lda #$c0 ;
jsr WAIT jsr WAIT ;
inc TEMPY inc TEMPY ; 5
lda TEMPY lda TEMPY ; 3
cmp #10 cmp #10 ; 2
beq explosion_done beq explosion_done ; ?
rts rts ; 6
explosion_done: explosion_done:
;================================== ;==================================
; randomly draw more explosions ; randomly draw more explosions
;================================== ;==================================
jsr random16 jsr random16 ; 6+42
lda SEEDL lda SEEDL ; 3
and #$2 and #$2 ; 2
sta STATE sta STATE ; 3
; if 0, then move to state 0 (start over) ; if 0, then move to state 0 (start over)
; if 2, then move to state 2 (new random explosion) ; if 2, then move to state 2 (new random explosion)
rts rts ; 6
@ -496,130 +515,138 @@ explosion_done:
; Draw explosion rays ; Draw explosion rays
;=============================== ;===============================
; ;
; Note: the western pixels don't do the full 16-bit math
; as currently it's not possible for those to overflow 256
;
; cycles = 275+275+270+270+272+278+278+279+6=2203
explosion: explosion:
; HPLOT X,Y: X= (y,x), Y=a ; HPLOT X,Y: X= (y,x), Y=a
; Southeast pixel ; Southeast pixel
clc clc ; 2
lda XPOS_L lda XPOS_L ; 3
adc OFFSET adc OFFSET ; 3
tax tax ; 2
lda XPOS_H lda XPOS_H ; 3
adc #0 adc #0 ; 2
tay tay ; 2
clc clc ; 2
lda YPOS_H lda YPOS_H ; 3
adc OFFSET adc OFFSET ; 3
jsr hplot0 ; hplot(xpos+o,ypos_h+o); jsr hplot0 ; hplot(xpos+o,ypos_h+o); ; 6+244
;==============
; 275
; Northeast Pixel ; Northeast Pixel
clc clc ; 2
lda XPOS_L lda XPOS_L ; 3
adc OFFSET adc OFFSET ; 3
tax tax ; 2
lda XPOS_H lda XPOS_H ; 3
adc #0 adc #0 ; 2
tay tay ; 2
sec sec ; 2
lda YPOS_H lda YPOS_H ; 3
sbc OFFSET sbc OFFSET ; 3
jsr hplot0 ; hplot(xpos+o,ypos_h-o); ; 6+244
;==============
; 275
jsr hplot0 ; hplot(xpos+o,ypos_h-o); ; Northwest Pixel
sec ; 2
lda XPOS_L ; 3
sec sbc OFFSET ; 3
lda XPOS_L tax ; 2
sbc OFFSET ldy #0 ; 2
tax sec ; 2
ldy #0 lda YPOS_H ; 3
sbc OFFSET ; 3
sec jsr hplot0 ; hplot(xpos-o,ypos_h-o); NW ; 6+244
lda YPOS_H ;==============
sbc OFFSET ; 270
jsr hplot0 ; hplot(xpos-o,ypos_h-o); NW
sec
lda XPOS_L
sbc OFFSET
tax
ldy #0
clc
lda YPOS_H
adc OFFSET
jsr hplot0 ; hplot(xpos-o,ypos_h+o); SW
; Southwest Pixel
sec ; 2
lda XPOS_L ; 3
sbc OFFSET ; 3
tax ; 2
ldy #0 ; 2
clc ; 2
lda YPOS_H ; 3
adc OFFSET ; 3
jsr hplot0 ; hplot(xpos-o,ypos_h+o); SW ; 6+244
;=============
; 270
; HPLOT X,Y: X= (y,x), Y=a ; HPLOT X,Y: X= (y,x), Y=a
ldx XPOS_L ; South Pixel
ldy XPOS_H ldx XPOS_L ; 3
ldy XPOS_H ; 3
clc clc ; 2
lda OFFSET lda OFFSET ; 3
adc OFFSET adc OFFSET ; 3
adc OFFSET adc OFFSET ; 3
lsr lsr ; 2
adc YPOS_H adc YPOS_H ; 3
jsr hplot0 ; hplot(xpos,ypos_h+(o*1.5)); S ; 6+244
jsr hplot0 ; hplot(xpos,ypos_h+(o*1.5)); S ;=============
; 272
ldx XPOS_L
ldy #0
clc ; O O*1.5 NEG
lda OFFSET ; 0 = 0 0
adc OFFSET ; 1 = 1 -1
adc OFFSET ; 2 = 3 -3
lsr ; 3 = 4 -4
eor #$FF ; 4 = 6 -6
clc
adc #1
adc YPOS_H
jsr hplot0 ; hplot(xpos,ypos_h-(o*1.5)); N
; North Pixel
ldx XPOS_L ; 3
ldy XPOS_H ; 3
clc ; O O*1.5 NEG ; 2
lda OFFSET ; 0 = 0 0 ; 3
adc OFFSET ; 1 = 1 -1 ; 3
adc OFFSET ; 2 = 3 -3 ; 3
lsr ; 3 = 4 -4 ; 2
eor #$FF ; 4 = 6 -6 ; 2
clc ; 2
adc #1 ; 2
adc YPOS_H ; 3
jsr hplot0 ; hplot(xpos,ypos_h-(o*1.5)); N ; 6+244
;==============
; 278
; HPLOT X,Y: X= (y,x), Y=a ; HPLOT X,Y: X= (y,x), Y=a
; East Pixel
clc ; 2
lda OFFSET ; 3
adc OFFSET ; 3
adc OFFSET ; 3
lsr ; 2
adc XPOS_L ; 3
tax ; 2
lda #0 ; 2
adc XPOS_H ; 3
tay ; 2
lda YPOS_H ; 3
jsr hplot0 ; hplot(xpos+(o*1.5),ypos_h); E ; 6+244
;==============
; 278
clc ; West Pixel
lda OFFSET clc ; O O*1.5 NEG ; 2
adc OFFSET lda OFFSET ; 0 = 0 0 ; 3
adc OFFSET adc OFFSET ; 1 = 1 -1 ; 3
lsr adc OFFSET ; 2 = 3 -3 ; 3
adc XPOS_L lsr ; 3 = 4 -4 ; 2
tax eor #$FF ; 4 = 6 -6 ; 2
ldy XPOS_H clc ; 2
adc #1 ; 2
adc XPOS_L ; 3
tax ; 2
ldy #0 ; 2
lda YPOS_H ; 3
jsr hplot0 ; hplot(xpos-(o*1.5),ypos_h); W ; 6+244
;==============
; 279
lda YPOS_H rts ; 6
jsr hplot0 ; hplot(xpos+(o*1.5),ypos_h); E
clc ; O O*1.5 NEG
lda OFFSET ; 0 = 0 0
adc OFFSET ; 1 = 1 -1
adc OFFSET ; 2 = 3 -3
lsr ; 3 = 4 -4
eor #$FF ; 4 = 6 -6
clc
adc #1
adc XPOS_L
tax
ldy #0
lda YPOS_H
jsr hplot0 ; hplot(xpos-(o*1.5),ypos_h); // W
rts