tfv: battle, split off attack code

This commit is contained in:
Vince Weaver 2021-01-17 16:14:56 -05:00
parent a7725fd35b
commit b249df66fa
4 changed files with 118 additions and 119 deletions

View File

@ -79,7 +79,7 @@ tfv_world.o: tfv_world.s zp.inc \
tfv_overworld.s tfv_drawmap.s \
tfv_battle.s tfv_battle_menu.s tfv_battle_limit.s tfv_battle_summons.s \
tfv_battle_magic.s tfv_battle_enemy.s tfv_battle_draw_hero.s \
tfv_battle_boss.s \
tfv_battle_boss.s tfv_battle_attack.s \
help_overworld.s rotate_intro.s \
sound_effects.s speaker_tone.s \
graphics_map/tfv_backgrounds.inc \

View File

@ -386,124 +386,6 @@ gr_put_num_ones:
;=========================
; attack
;=========================
attack:
lda #34
sta HERO_X
lda #$10
sta DAMAGE_VAL
attack_loop:
; copy over background
jsr gr_copy_to_current
; draw hero
lda #20
sta YPOS
lda HERO_X
sta XPOS
lsr
bcc attack_draw_walk
attack_draw_stand:
lda #<tfv_stand_left_sprite
sta INL
lda #>tfv_stand_left_sprite
jmp attack_actually_draw
attack_draw_walk:
lda #<tfv_walk_left_sprite
sta INL
lda #>tfv_walk_left_sprite
attack_actually_draw:
sta INH
jsr put_sprite_crop
;=========================
; draw sword
lda HERO_X
sec
sbc #5
sta XPOS
; ypos already 20?
lda #<tfv_led_sword_sprite
sta INL
lda #>tfv_led_sword_sprite
sta INH
jsr put_sprite_crop
;=========================
; draw enemy
lda ENEMY_X
sta XPOS
; ypos already 20?
jsr draw_enemy
;===========================
; draw battle bottom
jsr draw_battle_bottom
;===========================
; page flip
jsr page_flip
dec HERO_X
lda HERO_X
cmp #10 ; repeat until 10
bne attack_loop
;======================
; attack done
;===================
; damage the enemy
jsr damage_enemy
; display damage
lda #2
sta XPOS
lda #10
sta YPOS
jsr gr_put_num
;===================
; page flip
jsr page_flip
; delay
lda #255
jsr WAIT
; restore X value
lda #34
sta HERO_X
rts
victory_string:
.byte 13,21,"EXPERIENCE +2",0
.byte 16,22,"MONEY +1",0

View File

@ -0,0 +1,116 @@
;=========================
; attack
;=========================
attack:
lda #34
sta HERO_X
lda #$10
sta DAMAGE_VAL
attack_loop:
; copy over background
jsr gr_copy_to_current
; draw hero
lda #20
sta YPOS
lda HERO_X
sta XPOS
lsr
bcc attack_draw_walk
attack_draw_stand:
lda #<tfv_stand_left_sprite
sta INL
lda #>tfv_stand_left_sprite
jmp attack_actually_draw
attack_draw_walk:
lda #<tfv_walk_left_sprite
sta INL
lda #>tfv_walk_left_sprite
attack_actually_draw:
sta INH
jsr put_sprite_crop
;=========================
; draw sword
lda HERO_X
sec
sbc #5
sta XPOS
; ypos already 20?
lda #<tfv_led_sword_sprite
sta INL
lda #>tfv_led_sword_sprite
sta INH
jsr put_sprite_crop
;=========================
; draw enemy
lda ENEMY_X
sta XPOS
; ypos already 20?
jsr draw_enemy
;===========================
; draw battle bottom
jsr draw_battle_bottom
;===========================
; page flip
jsr page_flip
dec HERO_X
lda HERO_X
cmp #10 ; repeat until 10
bne attack_loop
;======================
; attack done
;===================
; damage the enemy
jsr damage_enemy
; display damage
lda #2
sta XPOS
lda #10
sta YPOS
jsr gr_put_num
;===================
; page flip
jsr page_flip
; delay
lda #255
jsr WAIT
; restore X value
lda #34
sta HERO_X
rts

View File

@ -59,6 +59,7 @@
.include "tfv_battle.s"
.include "tfv_battle_menu.s"
.include "tfv_battle_attack.s"
.include "tfv_battle_enemy.s"
.include "tfv_battle_magic.s"
.include "tfv_battle_limit.s"