Skip to content

Commit

Permalink
Rework Exp Bar
Browse files Browse the repository at this point in the history
Make use of the GBC tilemap attribute instead of duplicating a flipped version of the HP bar.
Leave the original pokered-gbc code commented out.

Revert the changes that had been made to accommodate the exp bar in the french font.
  • Loading branch information
Engezerstorung committed Oct 11, 2024
1 parent c926265 commit 692225d
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 52 deletions.
106 changes: 83 additions & 23 deletions color/color.asm
Original file line number Diff line number Diff line change
Expand Up @@ -326,30 +326,30 @@ ENDC
ld c, 11
call FillBox

IF GEN_2_GRAPHICS
; Bottom half; player lifebar
ld hl, W2_TilesetPaletteMap + 7 * 20 + 9
ld a, 2
ld b, 4
ld c, 11
call FillBox

; Player exp bar
ld hl, W2_TilesetPaletteMap + 9 + 11 * 20
ld a, 4
ld b, 1
ld c, 11
call FillBox
ENDC

IF !GEN_2_GRAPHICS
;IF GEN_2_GRAPHICS
; ; Bottom half; player lifebar
; ld hl, W2_TilesetPaletteMap + 7 * 20 + 9
; ld a, 2
; ld b, 4
; ld c, 11
; call FillBox

; ; Player exp bar
; ld hl, W2_TilesetPaletteMap + 9 + 11 * 20
; ld a, 4
; ld b, 1
; ld c, 11
; call FillBox
;ENDC

;IF !GEN_2_GRAPHICS
; Bottom half; player lifebar
ld hl, W2_TilesetPaletteMap + 7 * 20 + 9
ld a, 2
ld b, 5
ld c, 11
call FillBox
ENDC
;ENDC

; Player pokemon
ld hl, W2_TilesetPaletteMap + 4 * 20
Expand Down Expand Up @@ -383,7 +383,11 @@ ENDC
ld a, SET_PAL_BATTLE
ld [wDefaultPaletteCommand], a

IF GEN_2_GRAPHICS
jp SetPal_BattleExpBar
ELSE
ret
ENDC

; hl: starting address
; a: pal number
Expand Down Expand Up @@ -514,17 +518,73 @@ IF GEN_2_GRAPHICS
; Player exp bar
ld hl, W2_TilesetPaletteMap + 11 + 5 * SCREEN_WIDTH
ld b, 8
ld a, 4
.expLoop
ld [hli], a
dec b
jr nz, .expLoop
ld a, 4 | %00100000 ; load palette 4 and set bit 5 for H flip
call FillLine
ENDC

xor a
ldh [rSVBK], a
ret

IF GEN_2_GRAPHICS
; SetPal functions related to the exp bar

SetPal_StatusScreen2:
ld a, 2
ldh [rSVBK], a

ld hl, W2_TilesetPaletteMap + 11 + 5 * SCREEN_WIDTH
ld b, 8
ld a, 1
call FillLine

jr SetPal_BattleExpBar.end

SetPal_BattleAtkExpBar:
ld a, 2
ldh [rSVBK], a

ld hl, W2_TilesetPaletteMap + 10 + 11 * 20
ld [hl], 2

jr SetPal_BattleExpBar.end

SetPal_BattleBagExpBar:
ld c, 2
jr SetPal_BattleExpBar.common

SetPal_BattleExpBar:
ld c, 4 | %00100000 ; palette 4 and set bit 5 for H flip

.common
ld a, 2
ldh [rSVBK], a

ld hl, W2_TilesetPaletteMap + 10 + 11 * 20
ld b, 8
ld a, c
call FillLine

.end
; Set palette map
ld a, 3
ld [W2_StaticPaletteMapChanged], a
xor a
ld [W2_TileBasedPalettes], a ; Use a direct color map instead of assigning colors to tiles
ldh [rSVBK], a
ret
ENDC

; hl: starting address
; a: pal number
; b: number of tiles
FillLine:
.loop
ld [hli], a
dec b
jr nz, .loop
ret

; Show pokedex data
SetPal_Pokedex:
ld a, [wCurPartySpecies]
Expand Down
4 changes: 2 additions & 2 deletions color/exp_bar.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AnimateEXPBarAgain:
xor a
ld [wEXPBarPixelLength], a
hlcoord 17, 11
ld a, $c0
ld a, $63
ld c, $08
.loop
ld [hld], a
Expand Down Expand Up @@ -33,7 +33,7 @@ AnimateEXPBar:
hlcoord 17, 11
.loop1
ld a, [hl]
cp $c8
cp $6B
jr nz, .loop2
dec hl
dec c
Expand Down
8 changes: 4 additions & 4 deletions color/load_hp_and_exp_bar.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ LoadHPBarAndEXPBar::
ld de, HpBarAndStatusGraphics
ld hl, vChars2 tile $62
lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10
call GoodCopyVideoData
ld de, EXPBarGraphics
ld hl, vChars1 tile $40
lb bc, BANK(EXPBarGraphics), (EXPBarGraphicsEnd - EXPBarGraphics) / $10
; call GoodCopyVideoData
; ld de, EXPBarGraphics
; ld hl, vChars1 tile $40
; lb bc, BANK(EXPBarGraphics), (EXPBarGraphicsEnd - EXPBarGraphics) / $10

jp GoodCopyVideoData
;GoodCopyVideoData:
Expand Down
4 changes: 4 additions & 0 deletions color/status_screen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ ENDC
ret

; Only called when GEN_2_GRAPHICS is set
IF GEN_2_GRAPHICS
StatusScreen2Hook:
ld b, SET_PAL_STATUS_SCREEN2
call RunPaletteCommand
hlcoord 19, 1
lb bc, 6, 10
jp DrawLineBox ; Draws the box around name, HP and status
ENDC
34 changes: 17 additions & 17 deletions constants/charmap.asm
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@
charmap "è", $bb
charmap "é", $bc
charmap "ù", $bd
charmap "Ä", $be
charmap "Ö", $bf

charmap "Ü", $c9
charmap "ä", $ca
charmap "ö", $cb
charmap "ü", $cc
charmap "ë", $cd
charmap "ï", $ce
charmap "â", $cf
charmap "ô", $d0
charmap "û", $d1
charmap "ê", $d2
charmap "î", $d3

charmap "ß", $be
charmap "ç", $bf
charmap "Ä", $c0
charmap "Ö", $c1
charmap "Ü", $c2
charmap "ä", $c3
charmap "ö", $c4
charmap "ü", $c5
charmap "ë", $c6
charmap "ï", $c7
charmap "â", $c8
charmap "ô", $c9
charmap "û", $ca
charmap "ê", $cb
charmap "î", $cc
charmap "c'", $d4
charmap "d'", $d5
charmap "j'", $d6
Expand All @@ -194,8 +194,8 @@
charmap ".", $e8

charmap "ァ", $e9 ; katakana small a, unused
charmap "ß", $ea
charmap "ç", $eb
charmap "", $ea ; katakana small u, unused
charmap "", $eb ; katakana small e, unused

charmap "▷", $ec
charmap "▶", $ed
Expand Down
6 changes: 6 additions & 0 deletions constants/palette_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ DEF PALETTE_SIZE EQU NUM_PAL_COLORS * PAL_COLOR_SIZE
const SET_PAL_OAK_INTRO ; $0E
const SET_PAL_NAMING_SCREEN ; $0F
const SET_PAL_BATTLE_AFTER_BLACK ; $10
IF GEN_2_GRAPHICS
const SET_PAL_STATUS_SCREEN2 ; $11
const SET_PAL_BATTLE_EXPBAR ; $12
const SET_PAL_BATTLE_BAGEXPBAR ; $13
const SET_PAL_BATTLE_ATKEXPBAR ; $14
ENDC

DEF SET_PAL_PARTY_MENU_HP_BARS EQU $fc
DEF SET_PAL_DEFAULT EQU $ff
Expand Down
36 changes: 34 additions & 2 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,12 @@ CenterMonName:
ret

DisplayBattleMenu::
IF GEN_2_GRAPHICS
call LoadScreenTilesFromBuffer1_BattleExpBarPalHook
ELSE
call LoadScreenTilesFromBuffer1 ; restore saved screen
ENDC

ld a, [wBattleType]
and a
jr nz, .nonstandardbattle
Expand Down Expand Up @@ -2209,7 +2214,11 @@ DisplayBattleMenu::
jr UseBagItem

BagWasSelected:
IF GEN_2_GRAPHICS
call LoadScreenTilesFromBuffer1_BattleBagExpBarPalHook
ELSE
call LoadScreenTilesFromBuffer1
ENDC
ld a, [wBattleType]
and a ; is it a normal battle?
jr nz, .next
Expand Down Expand Up @@ -2693,7 +2702,11 @@ SelectMenuItem:
ld hl, MoveNoPPText
.print
call PrintText
IF GEN_2_GRAPHICS
call LoadScreenTilesFromBuffer1_BattleExpBarPalHook
ELSE
call LoadScreenTilesFromBuffer1
ENDC
jp MoveSelectionMenu

MoveNoPPText:
Expand Down Expand Up @@ -2854,7 +2867,11 @@ SwapMovesInMenu:
ld [wMenuItemToSwap], a ; select the current menu item for swapping
jp MoveSelectionMenu

IF GEN_2_GRAPHICS
_PrintMenuItem:
ELSE
PrintMenuItem:
ENDC
xor a
ldh [hAutoBGTransferEnabled], a
hlcoord 0, 8
Expand Down Expand Up @@ -7134,7 +7151,7 @@ PrintEXPBar:
jr .loop
.skip
ld b, a
ld a, $c0
ld a, $63
add c
.loop2
ld [hld], a
Expand All @@ -7143,7 +7160,7 @@ PrintEXPBar:
ld a, b
and a
jr nz, .loop
ld a, $c0
ld a, $63
jr .loop2

CalcEXPBarPixelLength:
Expand Down Expand Up @@ -7338,4 +7355,19 @@ PrintGenderCommon: ; used by both routines
ld a, [wPokedexNum]
ret

LoadScreenTilesFromBuffer1_BattleExpBarPalHook:
call LoadScreenTilesFromBuffer1
ld b, SET_PAL_BATTLE_EXPBAR
jp RunPaletteCommand

LoadScreenTilesFromBuffer1_BattleBagExpBarPalHook:
call LoadScreenTilesFromBuffer1
ld b, SET_PAL_BATTLE_BAGEXPBAR
jp RunPaletteCommand

PrintMenuItem:
ld b, SET_PAL_BATTLE_ATKEXPBAR
call RunPaletteCommand
jp _PrintMenuItem

ENDC
6 changes: 6 additions & 0 deletions engine/gfx/palettes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ SetPalFunctions:
dw SetPal_OakIntro ; Set prof oak's color
dw SetPal_NameEntry ; Name entry (partially replaces 08)
dw SetPal_BattleAfterBlack ; Like SetPal_Battle but specifically for clearing the black palettes
IF GEN_2_GRAPHICS
dw SetPal_StatusScreen2
dw SetPal_BattleExpBar
dw SetPal_BattleBagExpBar
dw SetPal_BattleAtkExpBar
ENDC

; HAXed to give trainers palettes independantly
; Also skips the "transform" check, caller does that instead
Expand Down
Binary file modified gfx/font/font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/gs/font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ INCLUDE "engine/math/random.asm"

INCLUDE "color/status_screen.asm"

IF GEN_2_GRAPHICS
EXPBarGraphics: INCBIN "gfx/gs/exp_bar.2bpp"
EXPBarGraphicsEnd:
ENDC
;IF GEN_2_GRAPHICS
;EXPBarGraphics: INCBIN "gfx/gs/exp_bar.2bpp"
;EXPBarGraphicsEnd:
;ENDC

SECTION "Battle Engine 2", ROMX

Expand Down

0 comments on commit 692225d

Please sign in to comment.