tfv: can attack during battle

This commit is contained in:
Vince Weaver 2021-01-13 12:16:20 -05:00
parent 94edd9ca01
commit 5a3db0f576
6 changed files with 359 additions and 119 deletions

View File

@ -66,7 +66,7 @@ TFV_WORLD: tfv_world.o
tfv_world.o: tfv_world.s zp.inc \ tfv_world.o: tfv_world.s zp.inc \
tfv_overworld.s tfv_drawmap.s tfv_battle.s \ tfv_overworld.s tfv_drawmap.s tfv_battle.s \
help_overworld.s rotate_intro.s \ help_overworld.s rotate_intro.s \
graphics_map/tfv_backgrounds.inc tfv_sprites.inc graphics_map/tfv_backgrounds.inc tfv_sprites.inc number_sprites.inc
ca65 -o tfv_world.o tfv_world.s -l tfv_world.lst ca65 -o tfv_world.o tfv_world.s -l tfv_world.lst
graphics_map/tfv_backgrounds.inc: graphics_map/tfv_backgrounds.inc:

View File

@ -1,4 +1,4 @@
proper slowdown/delay in attack
simple sound effects when selecting menu simple sound effects when selecting menu
maybe gradients on backgrounds maybe gradients on backgrounds

View File

@ -0,0 +1,94 @@
; Numbers
; ****** ** **** **** ** ** ****** **** ****** ****** ******
; ** ** **** ** ** ** ** ** ** ** ** ** ** **
; ** ** ** **** **** ****** **** ****** ** ****** ******
; ** ** ** ** ** ** ** ** ** ** ** ** **
; ****** ****** ****** **** ** **** ****** ** ****** **
number_sprites:
.word number0_sprite
.word number1_sprite
.word number2_sprite
.word number3_sprite
.word number4_sprite
.word number5_sprite
.word number6_sprite
.word number7_sprite
.word number8_sprite
.word number9_sprite
.word numberX_sprite
.word numberX_sprite
.word numberX_sprite
.word numberX_sprite
.word numberX_sprite
.word numberX_sprite
number0_sprite:
.byte $3,$3
.byte $55,$A5,$55
.byte $55,$AA,$55
.byte $A5,$A5,$A5
number1_sprite:
.byte $3,$3
.byte $5A,$55,$AA
.byte $AA,$55,$AA
.byte $A5,$A5,$A5
number2_sprite:
.byte $3,$3
.byte $A5,$A5,$5A
.byte $5A,$A5,$A5
.byte $A5,$A5,$A5
number3_sprite:
.byte $3,$3
.byte $A5,$A5,$5A
.byte $A5,$A5,$5A
.byte $A5,$A5,$AA
number4_sprite:
.byte $3,$3
.byte $55,$AA,$55
.byte $A5,$A5,$55
.byte $AA,$AA,$A5
number5_sprite:
.byte $3,$3
.byte $55,$A5,$A5
.byte $A5,$A5,$5A
.byte $A5,$A5,$AA
number6_sprite:
.byte $3,$3
.byte $5A,$A5,$A5
.byte $55,$A5,$55
.byte $A5,$A5,$A5
number7_sprite:
.byte $3,$3
.byte $A5,$A5,$55
.byte $AA,$55,$AA
.byte $AA,$A5,$AA
number8_sprite:
.byte $3,$3
.byte $55,$A5,$55
.byte $55,$A5,$55
.byte $A5,$A5,$A5
number9_sprite:
.byte $3,$3
.byte $55,$A5,$55
.byte $A5,$A5,$55
.byte $AA,$AA,$A5
numberX_sprite:
.byte $3,$3
.byte $55,$55,$55
.byte $55,$55,$55
.byte $55,$55,$55

View File

@ -190,15 +190,7 @@ battle_draw_enemy:
lda #20 lda #20
sta YPOS sta YPOS
draw_enemy_smc1: jsr draw_enemy
lda #$a5
sta INL
draw_enemy_smc2:
lda #$a5
battle_actual_draw_enemy:
sta INH
jsr put_sprite_crop
battle_done_draw_enemy: battle_done_draw_enemy:
@ -320,17 +312,11 @@ done_battle:
rts rts
.if 0 ; Metrocat (summon?)
; Environment: grass, beach, forest, ice
; Do Battle */ ; Enemies: HP ATTACK WEAKNESS RESIST
; Metrocat (summon?) */
; Environment: grass, beach, forest, ice */
; Enemies: HP ATTACK WEAKNESS RESIST */
; Killer Crab RND-32 PINCH MALAISE FIRE ; Killer Crab RND-32 PINCH MALAISE FIRE
; Plain Fish BUBBLE FIRE ICE ; Plain Fish BUBBLE FIRE ICE
@ -374,28 +360,25 @@ done_battle:
;** ** ** ** ** ** ** ** ** ** ** ** ** ;** ** ** ** ** ** ** ** ** ** ** ** **
;****** ****** ****** **** ** **** ****** ** ****** ** ;****** ****** ****** **** ** **** ****** ** ****** **
static int battle_bar=0; ; Background depend on map location?
static int susie_out=0; ; Room for guinea pig in party?
; Background depend on map location? */ ; Attacks -> HIT, ZAP, HEAL, RUNAWAY
; Room for guinea pig in party? */ ;#define MAGIC_NONE 0
;#define MAGIC_FIRE 1
;#define MAGIC_ICE 2
;#define MAGIC_MALAISE 4
;#define MAGIC_BOLT 8
;#define MAGIC_HEAL 16
; Attacks -> HIT, ZAP, HEAL, RUNAWAY */ ; struct enemy_type {
#define MAGIC_NONE 0 ; char *name;
#define MAGIC_FIRE 1 ; int hp_base,hp_mask;
#define MAGIC_ICE 2 ; char *attack_name;
#define MAGIC_MALAISE 4 ; int weakness,resist;
#define MAGIC_BOLT 8 ; unsigned char *sprite;
#define MAGIC_HEAL 16 ;};
struct enemy_type {
char *name;
int hp_base,hp_mask;
char *attack_name;
int weakness,resist;
unsigned char *sprite;
};
.endif
;============================= ;=============================
; Init Enemy ; Init Enemy
@ -415,7 +398,7 @@ init_enemy:
sta ENEMY_TYPE sta ENEMY_TYPE
sta ENEMY_X sta ENEMY_X
lda #200 lda #$30 ; BCD
sta ENEMY_HP sta ENEMY_HP
lda #30 lda #30
@ -428,7 +411,6 @@ init_enemy:
rts rts
.if 0
;static struct enemy_type enemies[9]={ ;static struct enemy_type enemies[9]={
; [0]= { ; [0]= {
@ -514,30 +496,66 @@ init_enemy:
; }, ; },
;}; ;};
static int gr_put_num(int xx,int yy,int number) {
int xt=xx,digit,left,hundreds; ;===========================
; gr put num
;===========================
; damage in DAMAGE_VAL (BCD)
; location in XPOS,YPOS
digit=number/100; gr_put_num:
if ((digit) && (digit<10)) {
grsim_put_sprite(numbers[digit],xt,yy);
xt+=4;
}
hundreds=digit;
left=number%100;
digit=left/10;
if ((digit) || (hundreds)) {
grsim_put_sprite(numbers[digit],xt,yy);
xt+=4;
}
left=number%10;
digit=left; ; digit=number/100;
grsim_put_sprite(numbers[digit],xt,yy); ; if ((digit) && (digit<10)) {
; grsim_put_sprite(numbers[digit],xt,yy);
; xt+=4;
; }
; hundreds=digit;
; left=number%100;
return 0; gr_put_num_tens:
} ; print tens digit
lda DAMAGE_VAL
lsr
lsr
lsr
lsr
; leading zero suppression
beq gr_put_num_ones
asl
tay
lda number_sprites,Y
sta INL
lda number_sprites+1,Y
sta INH
jsr put_sprite_crop
; point to next
lda XPOS
clc
adc #4
sta XPOS
gr_put_num_ones:
; print tens digit
lda DAMAGE_VAL
and #$f
asl
tay
lda number_sprites,Y
sta INL
lda number_sprites+1,Y
sta INH
jsr put_sprite_crop
rts
; ;
; ATTACK SKIP ; ATTACK SKIP
@ -546,10 +564,10 @@ static int gr_put_num(int xx,int yy,int number) {
; ;
; SUMMONS -> METROCAT VORTEXCN ; SUMMONS -> METROCAT VORTEXCN
; MAGIC -> HEAL FIRE ; MAGIC -> HEAL FIRE
; ICE MALAISE ; ICE MALAISE
; BOLT ; BOLT
; LIMIT -> SLICE ZAP ; LIMIT -> SLICE ZAP
; DROP ; DROP
; ;
; State Machine ; State Machine
; ;
@ -563,19 +581,8 @@ static int gr_put_num(int xx,int yy,int number) {
; ;
; ;
#define MENU_NONE 0 ; static int enemy_attacking=0;
#define MENU_MAIN 1
#define MENU_MAGIC 2
#define MENU_SUMMON 3
#define MENU_LIMIT 4
static int enemy_attacking=0;
static int menu_state=MENU_NONE;
static int menu_position=0;
static int battle_count=0;
.endif
battle_enemy_string: battle_enemy_string:
.byte 0,21,"KILLER CRAB",0 .byte 0,21,"KILLER CRAB",0
@ -1066,72 +1073,192 @@ done_bar:
.if 0 ;=========================
; damage enemy
;=========================
; amount to damage in DAMAGE_VAL
damage_enemy:
lda DAMAGE_VAL
cmp ENEMY_HP
bcs damage_enemy_too_much ; bge
; enemy hp is BCD
sed
static int damage_enemy(int value) { sec
lda ENEMY_HP
sbc DAMAGE_VAL
if (enemy_hp>value) enemy_hp-=value; cld
else enemy_hp=0;
return 0; jmp damage_enemy_update
} damage_enemy_too_much:
lda #0
static int heal_self(int value) { damage_enemy_update:
sta ENEMY_HP
hp+=value; rts
if (hp>max_hp) hp=max_hp;
return 0; ;===================
; heal self
;===================
; heal amount in DAMAGE_VAL (yes, I know)
} heal_self:
clc
lda HERO_HP
adc DAMAGE_VAL
; check if HP went down, if so we wrapped
static int damage_tfv(int value) { cmp HERO_HP
bcc heal_self_max ; blt
bcs heal_self_update
if (hp>value) hp-=value; heal_self_max:
else hp=0; lda HERO_HP_MAX
return 0; heal_self_update:
sta HERO_HP
rts
;========================
; damage TFV
;========================
; value in DAMAGE_VAL
damage_tfv:
lda DAMAGE_VAL
cmp HERO_HP
bcs damage_hero_too_much ; bge
sec
lda HERO_HP
sbc DAMAGE_VAL
jmp damage_hero_update
damage_hero_too_much:
lda #0
damage_hero_update:
sta HERO_HP
rts
}
.endif
;========================= ;=========================
; attack ; attack
;========================= ;=========================
attack: attack:
; int ax=34; lda #34
; int damage=10; sta HERO_X
; while(ax>10) { lda #$10
sta DAMAGE_VAL
; gr_copy_to_current(0xc00); attack_loop:
; if (ax&1) { ; copy over background
; grsim_put_sprite(tfv_stand_left,ax,20);
; } jsr gr_copy_to_current
; else {
; grsim_put_sprite(tfv_walk_left,ax,20); ; draw hero
; }
; grsim_put_sprite(tfv_led_sword,ax-5,20); lda #20
; sta YPOS
; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20);
; lda HERO_X
; draw_battle_bottom(enemy_type); sta XPOS
;
; page_flip(); lsr
; bcc attack_draw_walk
; ax-=1;
; attack_draw_stand:
; usleep(20000); lda #<tfv_stand_left_sprite
; } sta INL
; lda #>tfv_stand_left_sprite
; damage_enemy(damage); jmp attack_actually_draw
; gr_put_num(2,10,damage);
; page_flip(); attack_draw_walk:
; usleep(250000); 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 rts
@ -1979,6 +2106,23 @@ keypress_summon_action:
rts rts
;================================
; draw enemy
; relies on self-modifying code
; position in XPOS,YPOS
draw_enemy:
draw_enemy_smc1:
lda #$a5
sta INL
draw_enemy_smc2:
lda #$a5
battle_actual_draw_enemy:
sta INH
jmp put_sprite_crop ; tail call

View File

@ -56,8 +56,9 @@
.include "rotate_intro.s" .include "rotate_intro.s"
;=============================================== ;===============================================
; Variables ; Graphics
;=============================================== ;===============================================
.include "tfv_sprites.inc" .include "tfv_sprites.inc"
.include "number_sprites.inc"
.include "graphics_map/tfv_backgrounds.inc" .include "graphics_map/tfv_backgrounds.inc"

View File

@ -139,6 +139,7 @@ MENU_POSITION = $B8
MENU_LIMIT_DROP = 2 MENU_LIMIT_DROP = 2
LAST_KEY = $B9 LAST_KEY = $B9
DAMAGE_VAL = $BA
COLOR1 = $E0 COLOR1 = $E0
COLOR2 = $E1 COLOR2 = $E1