lemm: particle effects working

This commit is contained in:
Vince Weaver 2022-03-15 21:56:47 -04:00
parent f31a7529f7
commit e4edbf2fb7
6 changed files with 256 additions and 5 deletions

View File

@ -70,7 +70,7 @@ lemm.o: lemm.s zp.inc hardware.inc \
draw_door.s move_lemming.s draw_lemming.s \
hgr_hlin.s hgr_vlin.s update_menu.s \
interrupt_handler.s keyboard.s draw_pointer.s \
pointer_sprites.inc \
pointer_sprites.inc particle_hgr.s \
level1.s level5.s title.s audio.s letsgo.s
ca65 -o lemm.o lemm.s -l lemm.lst

View File

@ -1,8 +1,7 @@
+ ability to walk up hills
+ ability to explode
+ particle effects
+ wait a second after last lemming gone to exit
+ update the "in" %
+ dig off the map, end level
+ fill in some of the ground so we don't get stuck when digging
+ Update credits?
+ "Out" counter is only printed to page1 so gets erased by cursor

View File

@ -69,6 +69,8 @@ do_draw_lemming:
beq draw_falling_sprite
cmp #LEMMING_EXPLODING
beq draw_exploding_sprite
cmp #LEMMING_PARTICLES
beq draw_particles
draw_walking_sprite:
@ -142,6 +144,17 @@ draw_exploding_sprite:
jmp done_draw_lemming
;====================
; draw particles
;====================
draw_particles:
jsr handle_particles
jmp done_draw_lemming
;======================
; digging
@ -256,6 +269,28 @@ countdown_sprites_h:
.byte >countdown2_sprite,>countdown1_sprite
handle_particles:
jsr hgr_draw_particles
lda lemming_frame
cmp #16
bne still_going
; partway through make lemming not out
lda #0
sta lemming_out
jsr update_lemmings_out
lda #LEVEL_FAIL
sta LEVEL_OVER
still_going:
not_done_particle:
rts
; moved to make room
handle_explosion:
@ -267,6 +302,11 @@ handle_explosion:
start_particles:
lda #0
sta lemming_frame
jsr init_particles
; erase explosion
ldy #0

View File

@ -326,6 +326,7 @@ load_song_chunk_good:
.include "title.s"
.include "audio.s"
.include "letsgo.s"
.include "particle_hgr.s"
; pt3 player

211
games/lemm/particle_hgr.s Normal file
View File

@ -0,0 +1,211 @@
; particle effect? -- Apple II Lores
; by Vince `deater` Weaver
PARTICLES = 64
SCALE = 2
;HGR_BITS = $1C
;COLOR = $30
;SEEDLO = $43
;SEEDHI = $44
;HGR_COLOR = $E4
;QUOTIENT = $FA
;DIVISOR = $FB
;DIVIDEND = $FC
;XX = $FD
;YY = $FE
;FRAME = $FF
;FULLGR = $C052
;LORES = $C056 ; Enable LORES graphics
;HGR2 = $F3D8
;HGR = $F3E2
;HPLOT0 = $F457 ; plot at (Y,X), (A)
;PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved)
;SETGR = $FB40
;WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
particle_x = $800
particle_y = $880
particle_life = $900
particle_vx = $980
particle_vy = $a00
init_particles:
; init
ldx #PARTICLES
init_particles_loop:
jsr init_particle
dex
bpl init_particles_loop
rts
hgr_draw_particles:
lda #0
sta HGR_COLOR
ldx #PARTICLES
clear_loop:
txa
pha
tay
ldx particle_x,Y
lda particle_y,Y
ldy #0
jsr HPLOT0 ; plot at (Y,X), (A)
pla
tax
dex
bpl clear_loop
; move particles
; draw particles
ldx #PARTICLES
draw_particles_loop:
; adjust x
lda particle_x,X
clc
adc particle_vx,X
sta particle_x,X
; bmi redo_particle
; cmp #40*SCALE
; bcs redo_particle
; adjust y
; first adjust for gravity
inc particle_vy,X
; inc particle_vy,X
lda particle_y,X
clc
adc particle_vy,X
sta particle_y,X
; bmi redo_particle
cmp #191
bcc y_good
redo_particle:
jsr init_particle
y_good:
dec particle_life,X
beq redo_particle
lda #$ff
sta HGR_COLOR
; lda particle_life,X
; sta HGR_COLOR
; sec
; sbc #$11
; sta particle_life,X
; cmp #$ef
; beq redo_particle
txa
pha
tay
ldx particle_x,Y
lda particle_y,Y
ldy #0
jsr HPLOT0 ; plot at (Y,X), (A)
pla
tax
dex
bpl draw_particles_loop
rts
HPLOT0:
; line from (x,a) to (x+y,a)
ldy #1
jsr hgr_hlin
rts
; init particle
; particle in X
init_particle:
; source
; lda #128 ; init x
lda lemming_x
asl
adc lemming_x
asl
adc lemming_x ; mul by 7
sta particle_x,X
lda lemming_y
; lda #100 ; init y
sta particle_y,X
; color
lda #$ff
sta particle_life,X
; velocities
; -8 to 8?
jsr random
cmp #$80
ror
sta particle_vx,X
jsr random
ora #$f0
sta particle_vy,X
rts
; -8 to 8
; batari RNG
random:
lda SEEDHI
lsr
rol SEEDLO
bcc noeor
eor #$B4
noeor:
sta SEEDHI
eor SEEDLO
and #$f
sec
sbc #$8
rts

View File

@ -24,8 +24,8 @@ MASK = $2E
COLOR_MASK = $2F
COLOR = $30
SEEDL = $4e
SEEDH = $4f
SEEDLO = $4e
SEEDHI = $4f
XMAX = $50