ootw: initial friend implementation

This commit is contained in:
Vince Weaver 2019-07-19 11:13:29 -04:00
parent 2bc061fa98
commit 3381971db9
4 changed files with 563 additions and 1 deletions

View File

@ -56,10 +56,11 @@ OOTW_C2: ootw_c2.o
ootw_c2.o: ootw_c2.s \
gr_copy.s gr_copy_offset.s gr_fast_clear.s gr_pageflip.s gr_unrle.s \
gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \
keyboard.s gr_run_sequence.s physicist.s alien.s \
keyboard.s gr_run_sequence.s physicist.s alien.s friend.s \
ootw_c2_miners.s \
ootw_graphics/sprites/sprites_physicist.inc \
ootw_graphics/sprites/sprites_alien.inc \
ootw_graphics/sprites/sprites_friend.inc \
ootw_c2_cage.s ootw_c2_jail.s ootw_c2_elevator.s ootw_c2_intro.s \
ootw_graphics/l2cage/ootw_c2_cage.inc \
ootw_graphics/l2intro/ootw_l2intro.inc

265
ootw/friend.s Normal file
View File

@ -0,0 +1,265 @@
; draw/move our friend
friend_out: .byte 0
friend_x: .byte 0
friend_y: .byte 0
friend_state: .byte 0
friend_gait: .byte 0
friend_direction: .byte 0
friend_gun: .byte 0
F_STANDING = 0
F_WALKING = 1
F_RUNNING = 2
F_CROUCHING = 3
F_TURNING = 4
;=======================================
; Move friend based on current state
;
move_friend:
lda friend_state
beq done_move_friend
lda friend_state
cmp #F_WALKING
beq move_friend_walking
cmp #F_RUNNING
beq move_friend_running
done_move_friend:
rts
;======================
; walking
move_friend_walking:
inc friend_gait ; cycle through animation
lda friend_gait
and #$f
cmp #$8 ; only walk roughly 1/8 of time
bne friend_no_move_walk
lda friend_direction
beq f_walk_left
inc friend_x ; walk right
rts
f_walk_left:
dec friend_x ; walk left
friend_no_move_walk:
rts
;======================
; running
move_friend_running:
inc friend_gait ; cycle through animation
lda friend_gait
and #$3
cmp #$2 ; only run roughly 1/4 of time
bne friend_no_move_run
lda friend_direction
beq f_run_left
inc friend_x ; run right
rts
f_run_left:
dec friend_x ; run left
friend_no_move_run:
rts
;======================
; standing
move_friend_standing:
fstate_table_lo:
.byte <friend_standing ; 00
.byte <friend_walking ; 01
.byte <friend_running ; 02
.byte <friend_crouching ; 03
.byte <friend_turning ; 04
fstate_table_hi:
.byte >friend_standing ; 00
.byte >friend_walking ; 01
.byte >friend_running ; 02
.byte >friend_crouching ; 03
.byte >friend_turning ; 04
; Urgh, make sure this doesn't end up at $FF or you hit the
; NMOS 6502 bug
.align 2
fjump:
.word $0000
.align 1
;======================================
; draw friend
;======================================
draw_friend:
lda friend_out
beq no_friend
lda friend_state
tay
lda fstate_table_lo,y
sta fjump
lda fstate_table_hi,y
sta fjump+1
jmp (fjump)
no_friend:
rts
;==================================
; STANDING
;==================================
friend_standing:
lda #<friend_stand
sta INL
lda #>friend_stand
sta INH
jmp finally_draw_friend
;===================================
; CROUCHING
;===================================
friend_crouching:
; FIXME: we have an animation?
lda #<friend_crouch2
sta INL
lda #>friend_crouch2
sta INH
jmp finally_draw_friend
;===============================
; Walking
;================================
friend_walking:
lda friend_gait
cmp #64
bcc friend_gait_fine ; blt
lda #0
sta friend_gait
friend_gait_fine:
lsr
lsr
and #$fe
tay
lda friend_walk_progression,Y
sta INL
lda friend_walk_progression+1,Y
sta INH
jmp finally_draw_friend
;===============================
; Running
;================================
friend_running:
lda friend_gait
cmp #32
bcc friend_run_gait_fine ; blt
lda #0
sta friend_gait
friend_run_gait_fine:
lsr
and #$fe
tay
lda friend_run_progression,Y
sta INL
lda friend_run_progression+1,Y
sta INH
jmp finally_draw_friend
;===============================
; Turning
;================================
friend_turning:
dec friend_gait
bpl friend_draw_turning
lda #0
sta friend_gait
; switch direction
lda friend_direction
eor #$1
sta friend_direction
lda #F_WALKING
sta friend_state
friend_draw_turning:
lda #<friend_turning_sprite
sta INL
lda #>friend_turning_sprite
sta INH
jmp finally_draw_friend
;=============================
; Actually Draw Alien
;=============================
finally_draw_friend:
lda friend_x
sta XPOS
lda friend_y
sta YPOS
lda friend_direction
bne friend_facing_right
friend_facing_left:
jmp put_sprite_crop
friend_facing_right:
jmp put_sprite_flipped_crop

View File

@ -153,6 +153,7 @@ end_message:
.include "physicist.s"
.include "alien.s"
.include "friend.s"
; background miners
.include "ootw_c2_miners.s"
@ -163,6 +164,7 @@ end_message:
; sprites
.include "ootw_graphics/sprites/sprites_physicist.inc"
.include "ootw_graphics/sprites/sprites_alien.inc"
.include "ootw_graphics/sprites/sprites_friend.inc"
; intro
.include "ootw_graphics/l2intro/ootw_l2intro.inc"
; city movie

View File

@ -0,0 +1,294 @@
; note, for some reason these are all facing left
;=====================
;=====================
; STANDING
;=====================
;=====================
;====================
; Going Left
friend_stand:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$aa,$44,$aa,$aa
.byte $aa,$aa,$44,$aa,$aa
.byte $aa,$fa,$f4,$aa,$aa
;=====================
;=====================
; WALKING
;=====================
;=====================
friend_walk_progression:
.word friend_walk_left1
.word friend_walk_left2
.word friend_walk_left3
.word friend_walk_left4
.word friend_walk_left5
.word friend_walk_left6
.word friend_walk_left7
.word friend_walk_left8
friend_walk_left1:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$5a,$00,$77,$aa
.byte $aa,$55,$10,$77,$aa
.byte $aa,$aa,$00,$07,$aa
.byte $aa,$aa,$77,$a5,$5a
.byte $aa,$aa,$07,$aa,$05
.byte $aa,$a0,$00,$0a,$00
friend_walk_left2:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$5a,$77,$17,$aa
.byte $aa,$aa,$07,$00,$aa
.byte $aa,$aa,$77,$55,$aa
.byte $aa,$aa,$07,$aa,$05
.byte $aa,$0a,$00,$00,$a0
friend_walk_left3:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$10,$aa
.byte $aa,$aa,$07,$00,$aa
.byte $aa,$aa,$77,$55,$aa
.byte $aa,$aa,$07,$00,$0a
.byte $aa,$0a,$00,$aa,$a0
friend_walk_left4:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$10,$aa
.byte $aa,$a7,$00,$00,$aa
.byte $aa,$aa,$77,$55,$aa
.byte $aa,$aa,$07,$05,$aa
.byte $aa,$0a,$00,$00,$aa
friend_walk_left5:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$10,$aa
.byte $aa,$a7,$00,$00,$aa
.byte $aa,$5a,$55,$77,$aa
.byte $aa,$00,$a7,$07,$aa
.byte $a0,$a0,$0a,$00,$aa
friend_walk_left6:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$77,$17,$5a
.byte $aa,$aa,$07,$00,$a5
.byte $aa,$5a,$55,$77,$7a
.byte $aa,$05,$aa,$aa,$07
.byte $a0,$a0,$aa,$0a,$00
friend_walk_left7:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$aa,$10,$77,$aa
.byte $aa,$aa,$00,$07,$aa
.byte $aa,$aa,$57,$77,$aa
.byte $aa,$aa,$05,$a7,$07
.byte $aa,$0a,$00,$00,$a0
friend_walk_left8:
.byte $5,$8
.byte $aa,$7a,$f7,$7f,$aa
.byte $aa,$77,$07,$00,$aa
.byte $aa,$aa,$00,$77,$aa
.byte $aa,$5a,$10,$77,$7a
.byte $aa,$a5,$00,$00,$a7
.byte $aa,$aa,$55,$77,$aa
.byte $aa,$aa,$a5,$07,$aa
.byte $aa,$aa,$00,$00,$aa
;=====================
;=====================
; RUNNING
;=====================
;=====================
friend_run_progression:
.word friend_run_left1
.word friend_run_left2
.word friend_run_left3
.word friend_run_left4
.word friend_run_left5
.word friend_run_left6
.word friend_run_left7
.word friend_run_left8
friend_run_left1:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ba,$0b,$aa,$aa
.byte $aa,$aa,$44,$aa,$aa
.byte $aa,$aa,$44,$ac,$77
.byte $aa,$fa,$f4,$aa,$aa
friend_run_left2:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $ba,$ab,$00,$aa,$aa
.byte $aa,$ca,$44,$aa,$aa
.byte $aa,$ac,$44,$4a,$aa
.byte $aa,$aa,$fa,$f4,$aa
friend_run_left3:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $ab,$ab,$00,$aa,$aa
.byte $aa,$ca,$44,$aa,$aa
.byte $aa,$cc,$a4,$4a,$aa
.byte $a7,$a7,$fa,$af,$aa
friend_run_left4:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $ba,$ba,$0b,$aa,$aa
.byte $aa,$ab,$00,$aa,$aa
.byte $aa,$ca,$44,$aa,$aa
.byte $aa,$cc,$aa,$44,$aa
.byte $7a,$a7,$aa,$fa,$af
friend_run_left5:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ab,$0b,$aa,$aa
.byte $aa,$aa,$44,$4a,$fa
.byte $aa,$cc,$aa,$aa,$af
.byte $7a,$7c,$aa,$aa,$aa
friend_run_left6:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ab,$00,$aa,$aa
.byte $aa,$aa,$44,$4a,$fa
.byte $aa,$aa,$cc,$aa,$af
.byte $aa,$7a,$7c,$aa,$aa
friend_run_left7:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$aa,$bb,$aa,$aa
.byte $aa,$ab,$0b,$aa,$aa
.byte $aa,$4a,$44,$aa,$aa
.byte $aa,$a4,$c4,$ff,$aa
.byte $aa,$7a,$7c,$aa,$aa
friend_run_left8:
.byte $5,$8
.byte $aa,$9a,$9a,$aa,$aa
.byte $aa,$bb,$99,$aa,$aa
.byte $aa,$aa,$0b,$aa,$aa
.byte $aa,$ba,$bb,$aa,$aa
.byte $aa,$aa,$0b,$ba,$aa
.byte $aa,$4a,$44,$aa,$aa
.byte $aa,$44,$ac,$ca,$aa
.byte $af,$af,$7a,$7c,$aa
;=====================
;=====================
; JUMPING
;=====================
;=====================
;=====================
;=====================
; CROUCHING
;=====================
;=====================
friend_crouch_progression:
.word friend_crouch1
.word friend_crouch2
friend_crouch1:
.byte $3,$8
.byte $aa,$aa,$aa
.byte $9a,$9a,$aa
.byte $bb,$99,$aa
.byte $aa,$0b,$aa
.byte $aa,$bb,$aa
.byte $aa,$bb,$aa
.byte $44,$44,$aa
.byte $5a,$fc,$f4
friend_crouch2:
.byte $3,$8
.byte $aa,$aa,$aa
.byte $aa,$aa,$aa
.byte $9a,$9a,$aa
.byte $bb,$99,$aa
.byte $aa,$0b,$0a
.byte $aa,$bb,$00
.byte $ba,$4b,$aa
.byte $54,$f4,$f4
;=====================
;=====================
; TURNING
;=====================
;=====================
friend_turning_sprite:
.byte $5,$8
.byte $aa,$57,$77,$aa,$aa
.byte $0a,$05,$00,$0a,$aa
.byte $77,$00,$00,$55,$aa
.byte $77,$00,$00,$55,$aa
.byte $aa,$00,$00,$a5,$aa
.byte $aa,$77,$55,$aa,$aa
.byte $07,$aa,$05,$aa,$aa
.byte $00,$aa,$00,$aa,$aa