more battle interface

This commit is contained in:
DizzyEggg 2017-10-18 23:52:21 +02:00
parent 7c24b03742
commit ee6bdc9068
12 changed files with 98 additions and 350 deletions

View File

@ -1955,8 +1955,8 @@ _0805E1AE:
bx r1
thumb_func_end BattleLoadAllHealthBoxesGfx
thumb_func_start load_gfxc_health_bar
load_gfxc_health_bar: @ 805E1B8
thumb_func_start LoadBattleBarGfx
LoadBattleBarGfx: @ 805E1B8
push {lr}
ldr r0, =gUnknown_08C093F0
ldr r1, =gMonSpritesGfxPtr
@ -1969,7 +1969,7 @@ load_gfxc_health_bar: @ 805E1B8
pop {r0}
bx r0
.pool
thumb_func_end load_gfxc_health_bar
thumb_func_end LoadBattleBarGfx
thumb_func_start BattleInitAllSprites
BattleInitAllSprites: @ 805E1D8

View File

@ -5124,7 +5124,7 @@ sub_80670A0: @ 80670A0
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0

View File

@ -4433,7 +4433,7 @@ sub_814D63C: @ 814D63C
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0

View File

@ -5574,7 +5574,7 @@ sub_8062294: @ 8062294
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0

View File

@ -8936,7 +8936,7 @@ sub_805C410: @ 805C410
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0
@ -9067,7 +9067,7 @@ sub_805C528: @ 805C528
.pool
_0805C560:
movs r0, 0x1
bl load_gfxc_health_bar
bl LoadBattleBarGfx
adds r0, r4, 0
movs r1, 0xB
bl GetMonData

View File

@ -5162,7 +5162,7 @@ sub_81BDC10: @ 81BDC10
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0
@ -5275,7 +5275,7 @@ sub_81BDD00: @ 81BDD00
.pool
_081BDD38:
movs r0, 0x1
bl load_gfxc_health_bar
bl LoadBattleBarGfx
adds r0, r4, 0
movs r1, 0xB
bl GetMonData

View File

@ -4863,7 +4863,7 @@ sub_8188FD0: @ 8188FD0
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0

View File

@ -5007,7 +5007,7 @@ sub_818C5E8: @ 818C5E8
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0

View File

@ -3836,7 +3836,7 @@ sub_816A5D4: @ 816A5D4
push {r6,r7}
sub sp, 0x4
movs r0, 0
bl load_gfxc_health_bar
bl LoadBattleBarGfx
ldr r3, =gBattleBufferA
ldr r0, =gActiveBank
mov r9, r0

View File

@ -6,338 +6,6 @@
.text
thumb_func_start UpdateLeftNoOfBallsTextOnHealthbox
UpdateLeftNoOfBallsTextOnHealthbox: @ 80747D8
push {r4,r5,lr}
sub sp, 0x18
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
ldr r1, =gText_SafariBallLeft
add r0, sp, 0x4
bl StringCopy
ldr r1, =gNumSafariBalls
ldrb r1, [r1]
movs r2, 0
movs r3, 0x2
bl ConvertIntToDecimalStringN
movs r0, 0
add r1, sp, 0x4
movs r2, 0x2F
bl GetStringRightAlignXOffset
adds r1, r0, 0
add r0, sp, 0x14
str r0, [sp]
add r0, sp, 0x4
movs r2, 0x3
movs r3, 0x2
bl AddTextPrinterAndCreateWindowOnHealthbox
adds r5, r0, 0
ldr r1, =gSprites
lsls r0, r4, 4
adds r0, r4
lsls r0, 2
adds r0, r1
ldrh r4, [r0, 0x4]
lsls r4, 22
lsrs r4, 17
ldr r1, =0x060102c0
adds r0, r4, r1
adds r1, r5, 0
movs r2, 0x2
bl sub_80751E4
ldr r0, =0x06010a00
adds r4, r0
adds r5, 0x40
adds r0, r4, 0
adds r1, r5, 0
movs r2, 0x4
bl sub_80751E4
ldr r0, [sp, 0x14]
bl RemoveWindowOnHealthbox
add sp, 0x18
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end UpdateLeftNoOfBallsTextOnHealthbox
thumb_func_start UpdateHealthboxAttribute
UpdateHealthboxAttribute: @ 8074860
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
mov r8, r1
lsls r0, 24
lsrs r6, r0, 24
lsls r2, 24
lsrs r7, r2, 24
ldr r1, =gSprites
lsls r0, r6, 4
adds r0, r6
lsls r0, 2
adds r0, r1
ldrh r0, [r0, 0x3A]
lsls r0, 24
lsrs r0, 24
mov r9, r0
cmp r7, 0
bne _0807489C
bl IsDoubleBattle
lsls r0, 24
cmp r0, 0
bne _0807489C
mov r0, r9
bl GetBankSide
_0807489C:
ldr r1, =gSprites
lsls r0, r6, 4
adds r0, r6
lsls r0, 2
adds r0, r1
ldrh r0, [r0, 0x3A]
lsls r0, 24
lsrs r0, 24
bl GetBankSide
lsls r0, 24
cmp r0, 0
beq _080748B8
b _08074A18
_080748B8:
cmp r7, 0x3
beq _080748C0
cmp r7, 0
bne _080748D4
_080748C0:
mov r0, r8
movs r1, 0x38
bl GetMonData
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r6, 0
bl UpdateLvlInHealthbox
_080748D4:
cmp r7, 0x1
bhi _080748EE
mov r0, r8
movs r1, 0x39
bl GetMonData
adds r1, r0, 0
lsls r1, 16
asrs r1, 16
adds r0, r6, 0
movs r2, 0
bl UpdateHpTextInHealthbox
_080748EE:
cmp r7, 0x2
beq _080748F6
cmp r7, 0
bne _0807490C
_080748F6:
mov r0, r8
movs r1, 0x3A
bl GetMonData
adds r1, r0, 0
lsls r1, 16
asrs r1, 16
adds r0, r6, 0
movs r2, 0x1
bl UpdateHpTextInHealthbox
_0807490C:
cmp r7, 0x5
beq _08074914
cmp r7, 0
bne _08074948
_08074914:
movs r0, 0
bl load_gfxc_health_bar
mov r0, r8
movs r1, 0x3A
bl GetMonData
adds r4, r0, 0
mov r0, r8
movs r1, 0x39
bl GetMonData
adds r3, r0, 0
movs r0, 0
str r0, [sp]
mov r0, r9
adds r1, r6, 0
adds r2, r4, 0
bl SetBattleBarStruct
mov r0, r9
adds r1, r6, 0
movs r2, 0
movs r3, 0
bl sub_8074AA0
_08074948:
bl IsDoubleBattle
lsls r0, 24
lsrs r0, 24
mov r10, r0
cmp r0, 0
bne _080749CE
cmp r7, 0x6
beq _0807495E
cmp r7, 0
bne _080749CE
_0807495E:
movs r0, 0x3
bl load_gfxc_health_bar
mov r0, r8
movs r1, 0xB
bl GetMonData
adds r5, r0, 0
lsls r5, 16
lsrs r5, 16
mov r0, r8
movs r1, 0x38
bl GetMonData
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
mov r0, r8
movs r1, 0x19
bl GetMonData
adds r3, r0, 0
ldr r0, =gExperienceTables
mov r12, r0
lsls r1, r4, 2
ldr r2, =gBaseStats
lsls r0, r5, 3
subs r0, r5
lsls r0, 2
adds r0, r2
ldrb r2, [r0, 0x13]
movs r0, 0xCA
lsls r0, 1
muls r0, r2
adds r1, r0
add r1, r12
ldr r1, [r1]
subs r3, r1
adds r4, 0x1
lsls r4, 2
adds r4, r0
add r4, r12
ldr r2, [r4]
subs r2, r1
mov r0, r10
str r0, [sp]
mov r0, r9
adds r1, r6, 0
bl SetBattleBarStruct
mov r0, r9
adds r1, r6, 0
movs r2, 0x1
movs r3, 0
bl sub_8074AA0
_080749CE:
cmp r7, 0x4
beq _080749D6
cmp r7, 0
bne _080749DE
_080749D6:
adds r0, r6, 0
mov r1, r8
bl UpdateNickInHealthbox
_080749DE:
cmp r7, 0x9
beq _080749E6
cmp r7, 0
bne _080749EC
_080749E6:
adds r0, r6, 0
bl UpdateStatusIconInHealthbox
_080749EC:
cmp r7, 0xA
bne _080749F6
adds r0, r6, 0
bl UpdateSafariBallsTextOnHealthbox
_080749F6:
adds r0, r7, 0
subs r0, 0xA
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bhi _08074A8E
adds r0, r6, 0
bl UpdateLeftNoOfBallsTextOnHealthbox
b _08074A8E
.pool
_08074A18:
cmp r7, 0x3
beq _08074A20
cmp r7, 0
bne _08074A34
_08074A20:
mov r0, r8
movs r1, 0x38
bl GetMonData
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r6, 0
bl UpdateLvlInHealthbox
_08074A34:
cmp r7, 0x5
beq _08074A3C
cmp r7, 0
bne _08074A70
_08074A3C:
movs r0, 0
bl load_gfxc_health_bar
mov r0, r8
movs r1, 0x3A
bl GetMonData
adds r4, r0, 0
mov r0, r8
movs r1, 0x39
bl GetMonData
adds r3, r0, 0
movs r0, 0
str r0, [sp]
mov r0, r9
adds r1, r6, 0
adds r2, r4, 0
bl SetBattleBarStruct
mov r0, r9
adds r1, r6, 0
movs r2, 0
movs r3, 0
bl sub_8074AA0
_08074A70:
cmp r7, 0x4
beq _08074A78
cmp r7, 0
bne _08074A80
_08074A78:
adds r0, r6, 0
mov r1, r8
bl UpdateNickInHealthbox
_08074A80:
cmp r7, 0x9
beq _08074A88
cmp r7, 0
bne _08074A8E
_08074A88:
adds r0, r6, 0
bl UpdateStatusIconInHealthbox
_08074A8E:
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end UpdateHealthboxAttribute
thumb_func_start sub_8074AA0
sub_8074AA0: @ 8074AA0
push {r4-r7,lr}

View File

@ -10,8 +10,8 @@ enum
HEALTHBOX_NICK,
HEALTHBOX_HEALTH_BAR,
HEALTHBOX_EXP_BAR,
HEALTHBOX_7,
HEALTHBOX_8,
HEALTHBOX_UNUSED_7,
HEALTHBOX_UNUSED_8,
HEALTHBOX_STATUS_ICON,
HEALTHBOX_SAFARI_ALL_TEXT,
HEALTHBOX_SAFARI_BALLS_TEXT

View File

@ -35,6 +35,7 @@ void sub_80728B4(struct Sprite *sprite);
const u32 *GetHealthboxElementGfxPtr(u8 elementId);
u32 AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, u32 arg3, u32 *windowId);
void sub_8075198(void *objVram, u32 windowTileData, u32 arg2);
void sub_80751E4(void *objVram, u32 windowTileData, u32 arg2);
void RemoveWindowOnHealthbox(u32 windowId);
void sub_8075170(void *dest, u32 arg1, u32 arg2);
void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent);
@ -47,6 +48,7 @@ void sub_8073E64(u8 taskId);
void sub_8074158(struct Sprite *sprite);
void sub_8074090(struct Sprite *sprite);
u8 GetStatusIconForBankId(u8 statusElementId, u8 bank);
void sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3);
// const rom data
const struct OamData gUnknown_0832C138 =
@ -1767,13 +1769,91 @@ void UpdateSafariBallsTextOnHealthbox(u8 healthboxSpriteId)
RemoveWindowOnHealthbox(windowId);
}
void UpdateLeftNoOfBallsTextOnHealthbox(healthboxSpriteId)
void UpdateLeftNoOfBallsTextOnHealthbox(u8 healthboxSpriteId)
{
u8 text[20];
u8 text[16];
u8 *txtPtr;
u32 windowId, windowTileData, spriteTileNum;
txtPtr = StringCopy(text, gText_SafariBallLeft);
ConvertIntToDecimalStringN(txtPtr, gNumSafariBalls, STR_CONV_MODE_LEFT_ALIGN, 2);
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, GetStringRightAlignXOffset(0, 1));
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, GetStringRightAlignXOffset(0, text, 0x2F), 3, 2, &windowId);
spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32;
sub_80751E4((void*)(OBJ_VRAM0 + 0x2C0) + spriteTileNum, windowTileData, 2);
sub_80751E4((void*)(OBJ_VRAM0 + 0xA00) + spriteTileNum, windowTileData + 0x40, 4);
RemoveWindowOnHealthbox(windowId);
}
extern void LoadBattleBarGfx(u8 arg0);
void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId)
{
u32 maxHp, currHp;
u8 bank = gSprites[healthboxSpriteId].data6;
if (elementId == HEALTHBOX_ALL && !IsDoubleBattle())
GetBankSide(bank); // pointless function call
if (GetBankSide(gSprites[healthboxSpriteId].data6) == SIDE_PLAYER)
{
u8 isDoubles;
if (elementId == HEALTHBOX_LEVEL || elementId == HEALTHBOX_ALL)
UpdateLvlInHealthbox(healthboxSpriteId, GetMonData(mon, MON_DATA_LEVEL));
if (elementId == HEALTHBOX_CURRENT_HP || elementId == HEALTHBOX_ALL)
UpdateHpTextInHealthbox(healthboxSpriteId, GetMonData(mon, MON_DATA_HP), 0);
if (elementId == HEALTHBOX_MAX_HP || elementId == HEALTHBOX_ALL)
UpdateHpTextInHealthbox(healthboxSpriteId, GetMonData(mon, MON_DATA_MAX_HP), 1);
if (elementId == HEALTHBOX_HEALTH_BAR || elementId == HEALTHBOX_ALL)
{
LoadBattleBarGfx(0);
maxHp = GetMonData(mon, MON_DATA_MAX_HP);
currHp = GetMonData(mon, MON_DATA_HP);
SetBattleBarStruct(bank, healthboxSpriteId, maxHp, currHp, FALSE);
sub_8074AA0(bank, healthboxSpriteId, 0, 0);
}
isDoubles = IsDoubleBattle();
if (!isDoubles && (elementId == HEALTHBOX_EXP_BAR || elementId == HEALTHBOX_ALL))
{
u16 species;
u32 exp, currLevelExp, currExpBarValue, maxExpBarValue;
u8 level;
LoadBattleBarGfx(3);
species = GetMonData(mon, MON_DATA_SPECIES);
level = GetMonData(mon, MON_DATA_LEVEL);
exp = GetMonData(mon, MON_DATA_EXP);
currLevelExp = gExperienceTables[gBaseStats[species].growthRate][level];
currExpBarValue = exp - currLevelExp;
maxExpBarValue = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLevelExp;
SetBattleBarStruct(bank, healthboxSpriteId, maxExpBarValue, currExpBarValue, isDoubles);
sub_8074AA0(bank, healthboxSpriteId, 1, 0);
}
if (elementId == HEALTHBOX_NICK || elementId == HEALTHBOX_ALL)
UpdateNickInHealthbox(healthboxSpriteId, mon);
if (elementId == HEALTHBOX_STATUS_ICON || elementId == HEALTHBOX_ALL)
UpdateStatusIconInHealthbox(healthboxSpriteId);
if (elementId == HEALTHBOX_SAFARI_ALL_TEXT)
UpdateSafariBallsTextOnHealthbox(healthboxSpriteId);
if (elementId == HEALTHBOX_SAFARI_ALL_TEXT || elementId == HEALTHBOX_SAFARI_BALLS_TEXT)
UpdateLeftNoOfBallsTextOnHealthbox(healthboxSpriteId);
}
else
{
if (elementId == HEALTHBOX_LEVEL || elementId == HEALTHBOX_ALL)
UpdateLvlInHealthbox(healthboxSpriteId, GetMonData(mon, MON_DATA_LEVEL));
if (elementId == HEALTHBOX_HEALTH_BAR || elementId == HEALTHBOX_ALL)
{
LoadBattleBarGfx(0);
maxHp = GetMonData(mon, MON_DATA_MAX_HP);
currHp = GetMonData(mon, MON_DATA_HP);
SetBattleBarStruct(bank, healthboxSpriteId, maxHp, currHp, FALSE);
sub_8074AA0(bank, healthboxSpriteId, 0, 0);
}
if (elementId == HEALTHBOX_NICK || elementId == HEALTHBOX_ALL)
UpdateNickInHealthbox(healthboxSpriteId, mon);
if (elementId == HEALTHBOX_STATUS_ICON || elementId == HEALTHBOX_ALL)
UpdateStatusIconInHealthbox(healthboxSpriteId);
}
}