chucks2

by snydej

Game:

Description: Chucks 2: Electric Boogaloo

!frame_counter = $7e0014
!soundfx = $7e1df9

!rng = $01acf9
!init_sprite = $07f7d2

!sprite_id = $7e009e
!sprite_status = $7e14c8
!sprite_phase = $7e00c2

!sprite_vx = $7e00b6
!sprite_vy = $7e00aa

!sprite_x_lo = $7e00e4
!sprite_x_hi = $7e14e0
!sprite_y_lo = $7e00d8
!sprite_y_hi = $7e14d4

!screen_x_lo = $7e001a
!screen_x_hi = $7e001b
!screen_y_lo = $7e001c
!screen_y_hi = $7e001d


	lda !mode
	cmp #$14
	bne end
	
	lda !frame_counter
	bit #$3
	bne end
	
	lda !carl_initialized
	beq do_it
	
	dec
	sta !carl_initialized	
	bra end

do_it:
	lda #$4a
	sta !carl_initialized
	lda #$28
	sta !soundfx

; Find sprite slot
	ldx #$0b
slot_loop:
	lda !sprite_status, x
	beq slot_found
	dex
	bpl slot_loop

; Sprite slots full
end:
	lda #$0
	rtl
	
slot_found:
	lda #$91
	sta !sprite_id,x
	lda #$08
	sta !sprite_status,x

;rng!!! :D
	jsl !rng
	pha
	cmp #$00
	bmi from_right
;from left
	lda #$ff
	pha
	lda #$e0
	bra set_x
from_right:
	lda #$01
	pha
	lda #$00

set_x:
	clc
	adc !screen_x_lo
	sta !sprite_x_lo,x
	pla
	adc !screen_x_hi
	sta !sprite_x_hi,x

; set y
	lda #$80
	clc
	adc !screen_y_lo
	sta !sprite_y_lo,x
	lda !screen_y_hi
	adc #$00
	sta !sprite_y_hi,x

	jsl !init_sprite
	
	lda #$06
	sta !sprite_phase,x

	pla
	sta !sprite_vx,x
	lda #$c0
	sta !sprite_vy,x

	bra end
back to listings