From 5fd6aecff7259e271dd00db144153c721913ef99 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 10 Feb 2021 13:16:52 -0500 Subject: [PATCH] tfv: initial inventory/info screen --- games/tfv/Makefile | 4 +- games/tfv/gr_hlin.s | 129 +++++++------- games/tfv/load_game.s | 9 +- games/tfv/tfv_info.s | 357 ++++++++++++++++++++++++++++++++++++++ games/tfv/tfv_overworld.s | 2 +- games/tfv/tfv_world.s | 1 + games/tfv/zp.inc | 30 ++-- 7 files changed, 453 insertions(+), 79 deletions(-) create mode 100644 games/tfv/tfv_info.s diff --git a/games/tfv/Makefile b/games/tfv/Makefile index cf4f9dc8..14a26844 100644 --- a/games/tfv/Makefile +++ b/games/tfv/Makefile @@ -76,8 +76,8 @@ 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 gr_put_num.s gr_putsprite_mask.s \ - tfv_overworld.s tfv_drawmap.s \ + long_wait.s gr_put_num.s gr_putsprite_mask.s gr_hlin.s \ + tfv_overworld.s tfv_drawmap.s tfv_info.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_attack.s \ diff --git a/games/tfv/gr_hlin.s b/games/tfv/gr_hlin.s index 29efa598..14254b78 100644 --- a/games/tfv/gr_hlin.s +++ b/games/tfv/gr_hlin.s @@ -1,105 +1,115 @@ -;===================================================================== -;= ROUTINES -;===================================================================== +;============================= +; decently fast hlin routines +;============================= +; can also be used to print repeated text if desperate + - ;================================ - ; hlin_setup - ;================================ - ; put address in GBASL/GBASH - ; Ycoord in A, Xcoord in Y -hlin_setup: - sty TEMPY ; 3 - tay ; y=A ; 2 - lda gr_offsets,Y ; lookup low-res memory address ; 4 - clc ; 2 - adc TEMPY ; 3 - sta GBASL ; 3 - iny ; 2 - lda gr_offsets,Y ; 4 - adc DRAW_PAGE ; add in draw page offset ; 3 - sta GBASH ; 3 - rts ; 6 - ;=========== - ; 35 ;================================ ; hlin_double: ;================================ ; HLIN Y, V2 AT A - ; Y, X, A trashed - ; start at Y, draw up to and including X + ; color in COLOR + ; GBASL/GBASH set to proper address + ; A, Y trashed + ; at end Y points to end of line + hlin_double: -;int hlin_double(int page, int x1, int x2, int at) { - jsr hlin_setup ; 41 + inc V2 ; drawing inclusive - sec ; 2 - lda V2 ; 3 - sbc TEMPY ; 3 - - tax ; 2 - inx ; 2 + sty TEMPY ; 3 + and #$fe ; make even ; 2 + tay ; y=A ; 2 + lda gr_offsets,Y ; lookup low-res memory address ; 4 + sta GBASL ; 3 + clc ; 2 + lda gr_offsets+1,Y ; 4 + adc DRAW_PAGE ; add in draw page offset ; 3 + sta GBASH ; 3 ;=========== - ; 53 - ; fallthrough + ; 26 + + lda COLOR ; 3 + ldy TEMPY ; restore ; 3 +hlin_double_loop: + sta (GBASL),Y ; 6 + iny ; 2 + cpy V2 ; 3 + bne hlin_double_loop ; 2nt/3 + + rts ; 6 + ;================================= ; hlin_double_continue: width ;================================= ; GBASL has correct offset for row/col - ; width in X + ; V2=start, width in X + ; A, X, Y trashed + ; V2=xcoord at end hlin_double_continue: - ldy #0 ; 2 + txa + clc + adc V2 + sta V2 lda COLOR ; 3 -hlin_double_loop: +hlin_double_continue_loop: sta (GBASL),Y ; 6 - inc GBASL ; 5 - dex ; 2 - bne hlin_double_loop ; 2nt/3 + iny ; 2 + cpy V2 + bne hlin_double_continue_loop ; 2nt/3 rts ; 6 ;============= - ; 53+5+X*16+5 + ;================================ ; hlin_single: ;================================ ; HLIN Y, V2 AT A + ; color in COLOR + ; GBASL/GBASH set to proper address + ; A, Y trashed + ; at end Y points to end of line ; Y, X, A trashed hlin_single: - jsr hlin_setup + inc V2 ; drawing inclusive - sec - lda V2 - sbc TEMPY + sty TEMPY ; 3 + and #$fe ; make even ; 2 + php ; save if zero ; 2 + tay ; y=A ; 2 + lda gr_offsets,Y ; lookup low-res memory address ; 4 + sta GBASL ; 3 + clc ; 2 + lda gr_offsets+1,Y ; 4 + adc DRAW_PAGE ; add in draw page offset ; 3 + sta GBASH ; 3 + ;=========== + ; 28 - tax - ; fallthrough + plp ; restore if 0 + beq hlin_single_bottom - ;================================= - ; hlin_single_continue: width - ;================================= - ; width in X - -hlin_single_continue: hlin_single_top: lda COLOR and #$f0 sta COLOR + ldy TEMPY hlin_single_top_loop: - ldy #0 lda (GBASL),Y and #$0f ora COLOR sta (GBASL),Y - inc GBASL - dex + iny + cpy V2 bne hlin_single_top_loop rts @@ -110,15 +120,14 @@ hlin_single_bottom: and #$0f sta COLOR + ldy TEMPY hlin_single_bottom_loop: - ldy #0 lda (GBASL),Y and #$f0 sta (GBASL),Y - inc GBASL - dex + iny + cpy V2 bne hlin_single_bottom_loop rts - diff --git a/games/tfv/load_game.s b/games/tfv/load_game.s index a041d92e..d96efcb3 100644 --- a/games/tfv/load_game.s +++ b/games/tfv/load_game.s @@ -23,8 +23,6 @@ load_game: sta HERO_XP lda #$25 sta HERO_MONEY - lda #$00 - sta HERO_INVENTORY lda #'D' sta HERO_NAME lda #'E' @@ -48,4 +46,11 @@ load_game: sta TFV_Y sta MAP_X + lda #$ff + sta HERO_INVENTORY1 + sta HERO_INVENTORY2 + lda #$3 + sta HERO_INVENTORY3 + + rts diff --git a/games/tfv/tfv_info.s b/games/tfv/tfv_info.s new file mode 100644 index 00000000..a3017922 --- /dev/null +++ b/games/tfv/tfv_info.s @@ -0,0 +1,357 @@ + ;=========================== + ; print inventory and stats + ;=========================== +print_info: + + lda #$a0 + jsr clear_top_a + + bit SET_TEXT + + jsr normal_text + + ; inverse space + lda #$20 + sta COLOR + + + ; Draw boxes + + ; HLIN Y, V2 AT A + + ; hlin_double(0,0,39,0); + ldy #39 + sty V2 + ldy #0 + lda #0 + jsr hlin_double + + + ; hlin_double(0,0,39,4); + ldy #39 + sty V2 + ldy #0 + lda #4 + jsr hlin_double + + ; hlin_double(0,0,39,8); + ldy #39 + sty V2 + ldy #0 + lda #8 + jsr hlin_double + + ; hlin_double(0,0,39,46); + ldy #39 + sty V2 + ldy #0 + lda #46 + jsr hlin_double + + ; X, V2 at Y + + ; basic_vlin(0,47,0); + ldy #0 + ldx #47 + stx V2 + ldx #0 + jsr vlin + + ; basic_vlin(0,47,20); + ldy #20 + ldx #47 + stx V2 + ldx #0 + jsr vlin + + ; basic_vlin(0,47,39); + ldy #39 + ldx #47 + stx V2 + ldx #0 + jsr vlin + + jsr normal_text + lda #info_name_string + sta OUTH + + jsr move_and_print ; print name + jsr move_and_print ; print level + jsr move_and_print ; print inventory + jsr move_and_print ; print stats + jsr move_and_print ; print hp + jsr move_and_print ; print mp + jsr move_and_print ; print exp + jsr move_and_print ; print next + jsr move_and_print ; print money + jsr move_and_print ; print time + + ;================== + ; print inventory + ;================== + + ldy #10 ; start at 5 (*2) + + ;============ + ; print item1 + + lda #$1 + sta MASK + ldx #0 +item1_loop: + clc + lda gr_offsets,Y + adc #3 ; indent + sta BASL + + lda gr_offsets+1,Y + adc DRAW_PAGE + sta BASH + + lda MASK + and HERO_INVENTORY1 + beq item1_not_there + + lda item1_name_addr,X + sta OUTL + lda item1_name_addr+1,X + sta OUTH + + sty TEMPY + jsr print_string + ldy TEMPY + + iny + iny + +item1_not_there: + + asl MASK + inx + inx + cpx #16 + bne item1_loop + + ;============ + ; print item2 + + + lda #$1 + sta MASK + ldx #0 +item2_loop: + clc + lda gr_offsets,Y + adc #3 ; indent + sta BASL + + lda gr_offsets+1,Y + adc DRAW_PAGE + sta BASH + + lda MASK + and HERO_INVENTORY2 + beq item2_not_there + + lda item2_name_addr,X + sta OUTL + lda item2_name_addr+1,X + sta OUTH + + sty TEMPY + jsr print_string + ldy TEMPY + + iny + iny + +item2_not_there: + + asl MASK + inx + inx + cpx #16 + bne item2_loop + + ;============ + ; print item3 + + lda #$1 + sta MASK + ldx #0 +item3_loop: + clc + lda gr_offsets,Y + adc #3 ; indent + sta BASL + + lda gr_offsets+1,Y + adc DRAW_PAGE + sta BASH + + lda MASK + and HERO_INVENTORY3 + beq item3_not_there + + lda item3_name_addr,X + sta OUTL + lda item3_name_addr+1,X + sta OUTH + + sty TEMPY + jsr print_string + ldy TEMPY + + iny + iny + +item3_not_there: + + asl MASK + inx + inx + cpx #4 + bne item3_loop + + + ;===================== + ; done printing info + + + jsr page_flip + + jsr wait_until_keypressed + + bit SET_GR ; set graphics + + jsr clear_bottoms + + rts + + + + + + +; 1 2 3 4 +;01234567890123456789012345678901234567890 +;**************************************** 1 +;* DEATER * LEVEL 1 * 2 +;**************************************** 3 +;* INVENTORY * STATS * 4 +;**************************************** 5 +;* * HP: 50/100 * 6 +;* * MP: 0/0 * 7 +;* * * 8 +;* * EXPERIENCE: 0 * 9 +;* * NEXT LEVEL: 16 * 10 +;* * * 11 +;* * MONEY: $1 * 12 0-256 +;* * TIME: 00:00 * 13 +;* * * 14 +;* * * 15 +;* * * 16 +;* * * 17 +;* * * 18 +;* * * 19 +;* * * 20 +;* * * 21 +;* * * 22 +;* * * 23 +;**************************************** 24 + +;EXPERIENCE = 0...255 +;LEVEL = EXPERIENCE / = 0...63 +;NEXT LEVEL = +;MONEY = 0...255 +;MAX_HP = 32+EXPERIENCE (maxing at 255) + + +info_name_string: +.byte 2,1,"DEATER ",0 + +info_level_string: +.byte 22,1,"LEVEL 1",0 + +info_inventory_string: +.byte 2,3,"INVENTORY:",0 + +info_stats_string: +.byte 22,3,"STATS",0 + +info_hp_string: +.byte 23,5,"HP: 123 / 456",0 + +info_mp_string: +.byte 23,6,"MP: 55 / 99",0 + +info_exp_string: +.byte 22,8,"EXPERIENCE: 123",0 + +info_nextlev_string: +.byte 22,9,"NEXT LEVEL: 123",0 + +info_money_string: +.byte 22,11,"MONEY: $123",0 + +info_time_string: +.byte 22,13,"TIME: 00:00",0 + +item1_name_addr: + .word item1_cupcake + .word item1_carrot + .word item1_smartpass + .word item1_elf_runes + .word item1_lizbeth_star + .word item1_karte_spiel + .word item1_glamdring + .word item1_vegemite + +item1_names: + item1_cupcake: .byte "CUPCAKE",0 + item1_carrot: .byte "CARROT",0 + item1_smartpass: .byte "METRO SMARTPASS",0 + item1_elf_runes: .byte "ELF RUNES",0 + item1_lizbeth_star: .byte "STAR OF LIZBETH",0 + item1_karte_spiel: .byte "KARTE SPIEL",0 + item1_glamdring: .byte "GLAMDRING",0 + item1_vegemite: .byte "VEGEMITE",0 + +item2_name_addr: + .word item2_blue_led + .word item2_red_led + .word item2_1k_resistor + .word item2_4p7k_resistor + .word item2_9v_battery + .word item2_1p5v_battery + .word item2_linux_cd + .word item2_army_knife + +item2_names: + item2_blue_led: .byte "BLUE LED",0 + item2_red_led: .byte "RED LED",0 + item2_1k_resistor: .byte "1K RESISTOR",0 + item2_4p7k_resistor: .byte "4.7K RESISTOR",0 + item2_9v_battery: .byte "9V BATTERY",0 + item2_1p5v_battery: .byte "1.5V BATTERY",0 + item2_linux_cd: .byte "LINUX CD",0 + item2_army_knife: .byte "SWISS ARMY KNIFE",0 + +item3_name_addr: + .word item3_chex_mix + .word item3_class_ring + .word item3_missing + .word item3_missing + .word item3_missing + .word item3_missing + .word item3_missing + .word item3_missing + +item3_names: + item3_chex_mix: .byte "CHEX MIX",0 + item3_class_ring: .byte "CLASS RING",0 ; from golf course? + item3_missing: .byte "MISSING",0 + + diff --git a/games/tfv/tfv_overworld.s b/games/tfv/tfv_overworld.s index a39ee1ee..0dede273 100644 --- a/games/tfv/tfv_overworld.s +++ b/games/tfv/tfv_overworld.s @@ -158,7 +158,7 @@ worldmap_handle_info: cmp #'I' bne worldmap_handle_map - ; jsr print_info + jsr print_info inc REFRESH jmp worldmap_done_keyboard diff --git a/games/tfv/tfv_world.s b/games/tfv/tfv_world.s index bc4bb19b..46833ada 100644 --- a/games/tfv/tfv_world.s +++ b/games/tfv/tfv_world.s @@ -45,6 +45,7 @@ ; External modules ;=============================================== +.include "tfv_info.s" .include "tfv_drawmap.s" .include "tfv_overworld.s" .include "tfv_game_over.s" diff --git a/games/tfv/zp.inc b/games/tfv/zp.inc index 21617290..7b1e8b8f 100644 --- a/games/tfv/zp.inc +++ b/games/tfv/zp.inc @@ -122,24 +122,26 @@ HERO_LIMIT = $95 ; hero's limit break count HERO_LEVEL = $96 ; hero's level, also high byte of max hp HERO_XP = $97 ; hero's experience points HERO_MONEY = $98 ; hero's money -HERO_INVENTORY = $99 ; hero's inventory -HERO_NAME = $9A ; 8 chars -HERO_NAME1 = $9B ; 8 chars -HERO_NAME2 = $9C ; 8 chars -HERO_NAME3 = $9D ; 8 chars -HERO_NAME4 = $9E ; 8 chars -HERO_NAME5 = $9F ; 8 chars -HERO_NAME6 = $A0 ; 8 chars -HERO_NAME7 = $A1 ; 8 chars -HERO_STATE = $A2 ; state of hero +HERO_INVENTORY1 = $99 ; hero's inventory +HERO_INVENTORY2 = $9A ; hero's inventory +HERO_INVENTORY3 = $9B ; hero's inventory +HERO_NAME = $9C ; 8 chars +HERO_NAME1 = $9D ; 8 chars +HERO_NAME2 = $9E ; 8 chars +HERO_NAME3 = $9F ; 8 chars +HERO_NAME4 = $A0 ; 8 chars +HERO_NAME5 = $A1 ; 8 chars +HERO_NAME6 = $A2 ; 8 chars +HERO_NAME7 = $A3 ; 8 chars +HERO_STATE = $A4 ; state of hero HERO_ON_BIRD = $01 HERO_ODD = $02 ; stand/walk position HERO_DIRECTION = $04 ; 0=left, 1=right -HERO_STEPS = $A3 ; number of steps +HERO_STEPS = $A5 ; number of steps -TFV_X = $A4 ; location on screen -TFV_Y = $A5 ; location on screen -MAP_X = $A6 ; which map region we're on +TFV_X = $A6 ; location on screen +TFV_Y = $A7 ; location on screen +MAP_X = $A8 ; which map region we're on