From 386a71978399cd4706d682d1dde2aaa12e3ec6ab Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 17 Jan 2021 23:48:12 -0500 Subject: [PATCH] tfv: split off gr_put_num --- games/tfv/Makefile | 4 +- .../tfv/{number_sprites.inc => gr_put_num.s} | 94 ++++++++++++++++++ games/tfv/tfv_battle.s | 97 +------------------ games/tfv/tfv_world.s | 2 +- 4 files changed, 100 insertions(+), 97 deletions(-) rename games/tfv/{number_sprites.inc => gr_put_num.s} (53%) diff --git a/games/tfv/Makefile b/games/tfv/Makefile index 465754d2..d0a3d700 100644 --- a/games/tfv/Makefile +++ b/games/tfv/Makefile @@ -75,7 +75,7 @@ TFV_WORLD: tfv_world.o ld65 -o TFV_WORLD tfv_world.o -C ../../linker_scripts/apple2_2000.inc tfv_world.o: tfv_world.s zp.inc \ - long_wait.s \ + long_wait.s gr_put_num.s \ 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 \ @@ -83,7 +83,7 @@ tfv_world.o: tfv_world.s zp.inc \ help_overworld.s rotate_intro.s \ sound_effects.s speaker_tone.s \ graphics_map/tfv_backgrounds.inc \ - tfv_sprites.inc battle_sprites.inc number_sprites.inc + tfv_sprites.inc battle_sprites.inc ca65 -o tfv_world.o tfv_world.s -l tfv_world.lst graphics_map/tfv_backgrounds.inc: diff --git a/games/tfv/number_sprites.inc b/games/tfv/gr_put_num.s similarity index 53% rename from games/tfv/number_sprites.inc rename to games/tfv/gr_put_num.s index 1369312e..90c35517 100644 --- a/games/tfv/number_sprites.inc +++ b/games/tfv/gr_put_num.s @@ -1,3 +1,97 @@ + +;****** ** **** **** ** ** ****** **** ****** ****** ****** +;** ** **** ** ** ** ** ** ** ** ** ** ** ** +;** ** ** **** **** ****** **** ****** ** ****** ****** +;** ** ** ** ** ** ** ** ** ** ** ** ** +;****** ****** ****** **** ** **** ****** ** ****** ** + + ;=========================== + ; gr put num + ;=========================== + ; damage in DAMAGE_VAL_LO/HI (BCD) + ; location in XPOS,YPOS + +gr_put_num: + lda #1 + sta gr_put_num_leading_zero + + ; put high digit first + lda DAMAGE_VAL_HI + beq gr_put_num_bottom_byte + jsr gr_put_num_byte +gr_put_num_bottom_byte: + lda DAMAGE_VAL_LO + ; fallthrough + + ;================================= + ; print two-digit BCD number in A +gr_put_num_byte: + pha ; store on stack + +gr_put_num_tens: + + and #$f0 + bne gr_put_num_print_tens + + ; was zero, check if we should print + + lda gr_put_num_leading_zero ; if 1, we skip + bne gr_put_num_ones + + pla ; restore value + pha + +gr_put_num_print_tens: + + ; we were non-zero, notify leading zero + ldy #0 + sty gr_put_num_leading_zero + + + ; print tens digit + lsr + lsr + lsr + lsr + + + 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 ones digit + pla + and #$f + + asl + tay + lda number_sprites,Y + sta INL + lda number_sprites+1,Y + sta INH + + jsr put_sprite_crop + + rts + + + +gr_put_num_leading_zero: .byte $01 + + ; Numbers diff --git a/games/tfv/tfv_battle.s b/games/tfv/tfv_battle.s index 2384becf..0c4bebd2 100644 --- a/games/tfv/tfv_battle.s +++ b/games/tfv/tfv_battle.s @@ -326,101 +326,7 @@ battle_game_over: -;****** ** **** **** ** ** ****** **** ****** ****** ****** -;** ** **** ** ** ** ** ** ** ** ** ** ** ** -;** ** ** **** **** ****** **** ****** ** ****** ****** -;** ** ** ** ** ** ** ** ** ** ** ** ** -;****** ****** ****** **** ** **** ****** ** ****** ** -gr_put_num_leading_zero: .byte $00 - - ;=========================== - ; gr put num - ;=========================== - ; damage in DAMAGE_VAL_LO/HI (BCD) - ; location in XPOS,YPOS - -gr_put_num: - lda #1 - sta gr_put_num_leading_zero - - ; put high digit first - lda DAMAGE_VAL_HI - beq gr_put_num_bottom_byte - jsr gr_put_num_byte -gr_put_num_bottom_byte: - lda DAMAGE_VAL_LO - ; fallthrough - - ;================================= - ; print two-digit BCD number in A -gr_put_num_byte: - pha ; store on stack - -gr_put_num_tens: - - and #$f0 - bne gr_put_num_print_tens - - ; was zero, check if we should print - - lda gr_put_num_leading_zero ; if 1, we skip - bne gr_put_num_ones - - pla ; restore value - pha - -gr_put_num_print_tens: - - ; we were non-zero, notify leading zero - ldy #0 - sty gr_put_num_leading_zero - - - ; print tens digit - lsr - lsr - lsr - lsr - - - 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 ones digit - pla - and #$f - - asl - tay - lda number_sprites,Y - sta INL - lda number_sprites+1,Y - sta INH - - jsr put_sprite_crop - - rts - - - -victory_string: - .byte 13,21,"EXPERIENCE +2",0 - .byte 16,22,"MONEY +1",0 ;==================================== @@ -485,3 +391,6 @@ victory_draw_done: rts +victory_string: + .byte 13,21,"EXPERIENCE +2",0 + .byte 16,22,"MONEY +1",0 diff --git a/games/tfv/tfv_world.s b/games/tfv/tfv_world.s index 91e853b2..479e659a 100644 --- a/games/tfv/tfv_world.s +++ b/games/tfv/tfv_world.s @@ -43,6 +43,7 @@ .include "gr_hlin.s" .include "gr_vlin.s" .include "gr_pageflip.s" +.include "gr_put_num.s" .include "keyboard.s" .include "joystick.s" .include "gr_putsprite_crop.s" @@ -75,7 +76,6 @@ .include "tfv_sprites.inc" .include "battle_sprites.inc" -.include "number_sprites.inc" .include "graphics_map/tfv_backgrounds.inc" ;===============================================