(notifybox) decompile complete and renamed as [popup2]

This commit is contained in:
mokhaleee 2022-10-05 14:34:57 +08:00
parent 45c72907d5
commit e80ad27370
18 changed files with 368 additions and 551 deletions

View File

@ -19126,7 +19126,7 @@ _0804AB54:
movs r1, #0x60
movs r2, #0
movs r3, #0
bl NewPopup2mple
bl NewPopup_Simple
adds r0, r5, #0
movs r1, #3
bl Proc_Goto
@ -19141,7 +19141,7 @@ _0804AB8C:
movs r1, #0x60
movs r2, #0
movs r3, #0
bl NewPopup2mple
bl NewPopup_Simple
adds r0, r5, #0
movs r1, #4
bl Proc_Goto

View File

@ -6473,7 +6473,7 @@ _080105D8:
ldr r0, _080105E4 @ gEventSlots
ldrh r2, [r0, #0xc]
adds r0, r5, #0
bl NewItemGot
bl NewPopup_ItemGot
b _0801060C
.align 2, 0
_080105E4: .4byte gEventSlots
@ -6481,7 +6481,7 @@ _080105E8:
ldr r0, _080105F4 @ gEventSlots
ldr r2, [r0, #0xc]
adds r0, r5, #0
bl NewGoldGotPopup
bl NewPopup_GoldGot
b _0801060C
.align 2, 0
_080105F4: .4byte gEventSlots
@ -6657,7 +6657,7 @@ _0801071C:
lsls r0, r3, #0x10
asrs r0, r0, #0x10
adds r2, r4, #0
bl NewPopupVerySimple
bl NewPopup_VerySimple
b _08010740
_0801072A:
ldrh r2, [r1, #6]

View File

@ -1,371 +0,0 @@
.INCLUDE "macro.inc"
.SYNTAX UNIFIED
THUMB_FUNC_START StartPopup2WithIconAndNum
StartPopup2WithIconAndNum: @ 0x0801FA8C
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, r9
mov r5, r8
push {r5, r6, r7}
sub sp, #0xc
mov sl, r0
adds r7, r1, #0
mov r8, r2
mov r9, r3
movs r4, #1
cmp r2, #0
beq _0801FAAE
mov r0, r8
bl GetStringTextWidth
adds r4, r0, #3
_0801FAAE:
ldr r0, [sp, #0x2c]
cmp r0, #0
beq _0801FABC
bl GetStringTextWidth
adds r1, r4, #2
adds r4, r1, r0
_0801FABC:
movs r5, #8
mov r0, r9
b _0801FAC4
_0801FAC2:
adds r5, #8
_0801FAC4:
movs r1, #0xa
bl __divsi3
cmp r0, #0
bne _0801FAC2
cmp r7, #0
blt _0801FAD4
adds r4, #0x10
_0801FAD4:
adds r4, #0x18
movs r0, #0xf0
subs r0, r0, r4
cmp r0, #0
bge _0801FAE0
adds r0, #0xf
_0801FAE0:
asrs r6, r0, #4
adds r4, r4, r5
adds r1, r4, #0
cmp r4, #0
bge _0801FAEC
adds r1, r4, #7
_0801FAEC:
asrs r5, r1, #3
movs r0, #0
str r0, [sp]
adds r0, r6, #0
movs r1, #8
adds r2, r5, #0
movs r3, #4
bl DrawUiFrame2
cmp r7, #0
blt _0801FB1E
bl ResetIconGraphics_
movs r0, #4
bl LoadIconPalettes
lsls r0, r6, #1
ldr r1, _0801FBA4 @ gUnknown_02022EEA
adds r0, r0, r1
movs r2, #0x80
lsls r2, r2, #7
adds r1, r7, #0
bl DrawIcon
adds r6, #2
_0801FB1E:
bl Font_ResetAllocation
add r0, sp, #4
adds r1, r5, #0
bl Text_Init
add r0, sp, #4
movs r1, #1
bl Text_Advance
mov r0, r8
cmp r0, #0
beq _0801FB50
add r0, sp, #4
movs r1, #0
bl Text_SetColorId
add r0, sp, #4
mov r1, r8
bl Text_AppendString
add r0, sp, #4
movs r1, #2
bl Text_Advance
_0801FB50:
add r0, sp, #4
movs r1, #2
bl Text_SetColorId
add r0, sp, #4
mov r1, r9
bl sub_80040C0
ldr r0, [sp, #0x2c]
cmp r0, #0
beq _0801FB7E
add r0, sp, #4
movs r1, #2
bl Text_Advance
add r0, sp, #4
movs r1, #0
bl Text_SetColorId
add r0, sp, #4
ldr r1, [sp, #0x2c]
bl Text_AppendString
_0801FB7E:
lsls r1, r6, #1
ldr r0, _0801FBA4 @ gUnknown_02022EEA
adds r1, r1, r0
add r0, sp, #4
bl Text_Draw
ldr r0, _0801FBA8 @ ProcScr_Popup2
mov r1, sl
bl Proc_StartBlocking
add sp, #0xc
pop {r3, r4, r5}
mov r8, r3
mov r9, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
_0801FBA4: .4byte gUnknown_02022EEA
_0801FBA8: .4byte ProcScr_Popup2
THUMB_FUNC_END StartPopup2WithIconAndNum
THUMB_FUNC_START sub_801FBAC
sub_801FBAC: @ 0x0801FBAC
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
sub sp, #0xc
mov r8, r0
adds r7, r1, #0
adds r4, r2, #0
bl Font_ResetAllocation
add r0, sp, #4
movs r1, #0x14
bl Text_Init
add r0, sp, #4
movs r1, #2
bl Text_SetColorId
adds r0, r7, #0
bl GetItemName
adds r1, r0, #0
add r0, sp, #4
bl Text_AppendString
add r0, sp, #4
movs r1, #2
bl Text_Advance
add r0, sp, #4
movs r1, #0
bl Text_SetColorId
adds r0, r4, #0
bl GetStringFromIndex
adds r1, r0, #0
add r0, sp, #4
bl Text_AppendString
add r0, sp, #4
bl Text_GetXCursor
adds r2, r0, #0
adds r2, #0x28
movs r0, #0xf0
subs r0, r0, r2
cmp r0, #0
bge _0801FC0E
adds r0, #0xf
_0801FC0E:
asrs r5, r0, #4
adds r0, r2, #0
cmp r0, #0
bge _0801FC18
adds r0, #7
_0801FC18:
asrs r2, r0, #3
movs r0, #0
str r0, [sp]
adds r0, r5, #0
movs r1, #8
movs r3, #4
bl DrawUiFrame2
lsls r5, r5, #1
ldr r4, _0801FC60 @ gUnknown_02022EEA
adds r6, r5, r4
adds r0, r7, #0
bl GetItemIconId
adds r1, r0, #0
movs r2, #0x80
lsls r2, r2, #7
adds r0, r6, #0
bl DrawIcon
adds r4, #4
adds r5, r5, r4
add r0, sp, #4
adds r1, r5, #0
bl Text_Draw
ldr r0, _0801FC64 @ ProcScr_Popup2
mov r1, r8
bl Proc_StartBlocking
add sp, #0xc
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
_0801FC60: .4byte gUnknown_02022EEA
_0801FC64: .4byte ProcScr_Popup2
THUMB_FUNC_END sub_801FBAC
THUMB_FUNC_START sub_801FC68
sub_801FC68: @ 0x0801FC68
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
sub sp, #0xc
mov r8, r0
adds r7, r1, #0
adds r4, r2, #0
adds r5, r3, #0
bl Font_ResetAllocation
add r0, sp, #4
movs r1, #0x14
bl Text_Init
cmp r4, #0
beq _0801FCA6
add r0, sp, #4
movs r1, #0
bl Text_SetColorId
adds r0, r4, #0
bl GetStringFromIndex
adds r1, r0, #0
add r0, sp, #4
bl Text_AppendString
add r0, sp, #4
movs r1, #2
bl Text_Advance
_0801FCA6:
add r0, sp, #4
movs r1, #2
bl Text_SetColorId
cmp r4, #0
beq _0801FCB8
adds r0, r7, #0
movs r1, #0
b _0801FCBC
_0801FCB8:
adds r0, r7, #0
movs r1, #1
_0801FCBC:
bl GetItemNameWithArticle
adds r1, r0, #0
add r0, sp, #4
bl Text_AppendString
add r0, sp, #4
bl Text_GetXCursor
adds r1, r0, #7
cmp r1, #0
bge _0801FCD6
adds r1, #7
_0801FCD6:
asrs r4, r1, #3
adds r1, r4, #2
lsls r1, r1, #3
add r0, sp, #4
bl Text_SetXCursor
add r0, sp, #4
movs r1, #0
bl Text_SetColorId
cmp r5, #0
beq _0801FCFC
adds r0, r5, #0
bl GetStringFromIndex
adds r1, r0, #0
add r0, sp, #4
bl Text_AppendString
_0801FCFC:
add r0, sp, #4
bl Text_GetXCursor
adds r2, r0, #0
adds r2, #0x18
movs r0, #0xf0
subs r0, r0, r2
cmp r0, #0
bge _0801FD10
adds r0, #0xf
_0801FD10:
asrs r6, r0, #4
adds r0, r2, #0
cmp r0, #0
bge _0801FD1A
adds r0, #7
_0801FD1A:
asrs r2, r0, #3
movs r0, #0
str r0, [sp]
adds r0, r6, #0
movs r1, #8
movs r3, #4
bl DrawUiFrame2
lsls r1, r6, #1
ldr r5, _0801FD68 @ gUnknown_02022EEA
adds r1, r1, r5
add r0, sp, #4
bl Text_Draw
adds r4, #1
adds r4, r6, r4
lsls r4, r4, #1
subs r5, #2
adds r4, r4, r5
adds r0, r7, #0
bl GetItemIconId
adds r1, r0, #0
movs r2, #0x80
lsls r2, r2, #7
adds r0, r4, #0
bl DrawIcon
ldr r0, _0801FD6C @ ProcScr_Popup2
mov r1, r8
bl Proc_StartBlocking
add sp, #0xc
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
_0801FD68: .4byte gUnknown_02022EEA
_0801FD6C: .4byte ProcScr_Popup2
THUMB_FUNC_END sub_801FC68
THUMB_FUNC_START sub_801FD70
sub_801FD70: @ 0x0801FD70
push {lr}
movs r2, #0xf
movs r3, #0x22
bl sub_801FC68
pop {r0}
bx r0
THUMB_FUNC_END sub_801FD70
THUMB_FUNC_START sub_801FD80
sub_801FD80: @ 0x0801FD80
push {lr}
movs r2, #0x10
movs r3, #0x11
bl sub_801FC68
pop {r0}
bx r0
THUMB_FUNC_END sub_801FD80
.align 2, 0 @ align with 0

View File

@ -1,17 +0,0 @@
.section .data
.global ProcScr_Popup2
ProcScr_Popup2: @ 0x0859B0C0
@ PROC_CALL
.short 0x2, 0x0
.word ProcPopup2_Init
@ PROC_REPEAT
.short 0x3, 0x0
.word ProcPopup2_Loop
@ PROC_CALL
.short 0x2, 0x0
.word ClearBg0Bg1
@ PROC_END
.short 0x0, 0x0
.word 0x0

View File

@ -105,7 +105,7 @@ void sub_8003FAC(const char* str, int* outWidth, int* outHeight);
char *String_GetEnd(char *);
void Text_AppendString(struct TextHandle *th, const char* str);
void Text_AppendDecNumber(struct TextHandle *th, int n);
// ??? sub_80040C0(???);
void sub_80040C0(struct TextHandle *th, int n);
void Text_AppendNumberOr2Dashes(struct TextHandle *th, int n);
const char *Text_AppendChar(struct TextHandle *a, const char *b);
void *GetVRAMPointerForTextMaybe(struct TextHandle *a);

View File

@ -462,21 +462,21 @@ void ResetDialogueScreen(void);
// ??? SetPopupUnit(???);
// ??? SetPopupItem(???);
// ??? SetPopupNumber(???);
// ??? NewPopup2mple(???);
// ??? NewPopup(???);
// ??? NewGotItemPopup(???);
// ??? NewPopup_Simple(???);
// ??? NewPopupCore(???);
// ??? NewPopup_ItemGot_unused(???);
// ??? ItemGot_DisplayLePopup(???);
// ??? ItemGot_GotLeItem(???);
// ??? NewItemGot(???);
// ??? NewGeneralItemGot(???);
// ??? NewPopup_ItemGot(???);
// ??? NewPopup_GeneralItemGot(???);
// ??? NewGoldNumPopup_unused(???);
// ??? NewNumberPopup_unused(???);
// ??? NewGoldGotPopup(???);
void CreatedItemStealingPopUp(u16 weapon, ProcPtr parent);
// ??? NewPopup_GoldGot(???);
void NewPopup_ItemStealing(u16 weapon, ProcPtr parent);
void NewPopup_WeaponBroke(u16 weapon, ProcPtr parent);
void NewPopup_WRankIncrease(u16 weapon, ProcPtr parent);
// ??? NewPopup_NewAlly(???);
// ??? NewPopupVerySimple(???);
// ??? NewPopup_VerySimple(???);
// ??? sub_8011784(???);
// ??? nullsub_44(???);
// ??? sub_8011A1C(???);
@ -887,12 +887,12 @@ void ChangeActiveUnitFacing(int xLook, int yLook);
// ??? sub_801F978(???);
// ??? ProcPopup2_Init(???);
// ??? ProcPopup2_Loop(???);
// ??? StartPopup2WithIcon(???);
// ??? StartPopup2WithIconAndNum(???);
// ??? sub_801FBAC(???);
// ??? sub_801FC68(???);
void sub_801FD70(ProcPtr, int);
void sub_801FD80(ProcPtr, int);
// ??? NewPopup2_PlanA(???);
// ??? NewPopup2_PlanB(???);
// ??? NewPopup2_PlanC(???);
// ??? NewPopup2_PlanD(???);
void NewPopup2_DropItem(ProcPtr, int);
void NewPopup2_SendItem(ProcPtr, int);
void PutScreenFogEffect(void);
void PutScreenFogEffectOverlayed(void);
// ??? sub_80211C8(???);

View File

@ -88,23 +88,30 @@ void SetPopupUnit(struct Unit* unit);
void SetPopupItem(u16 item);
void SetPopupNumber(u32 num);
ProcPtr NewPopup2mple(const struct PopupInstruction *inst,
int clock,
int winStyle,
ProcPtr parent);
ProcPtr NewPopup(const struct PopupInstruction *inst,
ProcPtr NewPopupCore(const struct PopupInstruction *inst,
int clock,
int winStyle,
int iconObjTileId,
int pal_base, /* proc->iconPalId - 0x10 */
ProcPtr parent);
ProcPtr NewPopup_Simple(const struct PopupInstruction *inst,
int clock,
int winStyle,
ProcPtr parent);
void NewPopup_VerySimple(u32 msg, u32 sound_index, ProcPtr parent);
void NewGotItemPopup(struct Unit* unit, u16 item, ProcPtr parent);
void NewItemGot(ProcPtr parent, struct Unit *unit, u16 item);
void NewGeneralItemGot(struct Unit *unit, u16 item, ProcPtr parent);
void NewGoldGotPopup(ProcPtr parent, struct Unit *unit, int value);
void CreatedItemStealingPopUp(u16 item, ProcPtr parent);
void NewPopup_ItemGot_unused(struct Unit* unit, u16 item, ProcPtr parent);
void NewPopup_ItemGot(ProcPtr parent, struct Unit *unit, u16 item);
void NewPopup_GeneralItemGot(struct Unit *unit, u16 item, ProcPtr parent);
void NewPopup_GoldGot(ProcPtr parent, struct Unit *unit, int value);
void NewPopup_ItemStealing(u16 item, ProcPtr parent);
void NewPopup_WeaponBroke(u16 item, ProcPtr parent);
void NewPopup2_PlanA(ProcPtr parent, int IconIndex, char *str);
void NewPopup2_PlanB(ProcPtr proc, int icon_index, char *str0, int num, char *str1);
void NewPopup2_PlanC(ProcPtr parent, int item, int msg);
void NewPopup2_PlanD(ProcPtr parent, int item, int msg0, int msg1);
void NewPopup2_DropItem(ProcPtr parent, int item);
void NewPopup2_SendItem(ProcPtr parent, int item);
#endif /* GUARD_POPUP_H */

View File

@ -73,8 +73,7 @@ SECTIONS
src/phasechangefx.o(.text);
src/unit_facing.o(.text);
src/trapfx.o(.text);
src/notifybox.o(.text);
asm/notifybox.o(.text);
src/popup2.o(.text);
src/chapterintrofx.o(.text);
asm/gameoverbgfx.o(.text);
asm/lightrunefx.o(.text);
@ -297,7 +296,7 @@ SECTIONS
. = ALIGN(4); src/prep_unitswap.o(.data);
. = ALIGN(4); src/phasechangefx.o(.data);
. = ALIGN(4); src/trapfx.o(.data);
. = ALIGN(4); data/data_59AD88.o(.data);
. = ALIGN(4); src/popup2.o(.data);
. = ALIGN(4); src/chapterintrofx.o(.data);
. = ALIGN(4); data/data_59B358.o(.data);
. = ALIGN(4); src/bmmenu.o(.data);

View File

@ -141,7 +141,7 @@ void PutUnitSprite(int, int, int, struct Unit*);
void BWL_AddWinOrLossIdk(u8, u8, int);
// popup.s
void NewGeneralItemGot(struct Unit*, int, ProcPtr);
void NewPopup_GeneralItemGot(struct Unit*, int, ProcPtr);
s8 ActionRescue(ProcPtr);
s8 ActionDrop(ProcPtr);
@ -677,7 +677,7 @@ bool8 BATTLE_HandleItemDrop(ProcPtr proc) {
return 1;
}
NewGeneralItemGot(
NewPopup_GeneralItemGot(
unitB,
GetUnitLastItem(unitA),
proc

View File

@ -33,7 +33,7 @@ struct TrapData* GetCurrentChapterBallistaePtr(void);
struct TrapData* GetCurrentChapterBallistae2Ptr(void);
// notifybox.s
void StartPopup2WithIcon(ProcPtr, int, char*);
void NewPopup2_PlanA(ProcPtr, int, char*);
struct UnknownBMTrapProc {
/* 00 */ PROC_HEADER;
@ -202,13 +202,13 @@ int ExecTrap(ProcPtr proc, struct Unit* unit, int param_3) {
case 0xF:
RemoveTrap(GetTrapAt(unit->xPos, unit->yPos));
PlaySoundEffect(0xB1);
StartPopup2WithIcon(proc, -1, GetStringFromIndex(0x20));
NewPopup2_PlanA(proc, -1, GetStringFromIndex(0x20));
break;
case 0x10:
RemoveTrap(GetTrapAt(unit->xPos, unit->yPos));
PlaySoundEffect(0xB1);
StartPopup2WithIcon(proc, -1, GetStringFromIndex(0x21));
NewPopup2_PlanA(proc, -1, GetStringFromIndex(0x21));
UnitAddItem(unit, MakeNewItem(ITEM_MINE));
break;
}

View File

@ -18,6 +18,7 @@
#include "bmtrick.h"
#include "bmtrap.h"
#include "bmtarget.h"
#include "popup.h"
#include "bmusemind.h"
@ -54,10 +55,6 @@ static struct ProcCmd CONST_DATA sProcScr_ExecNightmareStaff[] = {
PROC_END,
};
// notifybox.s
void StartPopup2WithIcon(ProcPtr, int, char*);
void StartPopup2WithIconAndNum(ProcPtr, int, char*, int, char*);
// lightrunefx.s
void sub_8021684(ProcPtr, int, int);
void sub_8021818(ProcPtr, int, int);
@ -759,7 +756,7 @@ void ExecStatBoostItem(ProcPtr proc) {
PlaySoundEffect(0x5A);
StartPopup2WithIcon(proc, GetItemIconId(item), GetStringFromIndex(messageId));
NewPopup2_PlanA(proc, GetItemIconId(item), GetStringFromIndex(messageId));
return;
}
@ -806,7 +803,7 @@ void ExecJunaFruitItem(ProcPtr proc) {
PlaySoundEffect(0x5A);
StartPopup2WithIconAndNum(proc, GetItemIconId(itemId), 0, levelCount, GetStringFromIndex(0x1E));
NewPopup2_PlanB(proc, GetItemIconId(itemId), 0, levelCount, GetStringFromIndex(0x1E));
return;
}

View File

@ -1,4 +1,6 @@
#include "global.h"
#include "functions.h"
#include "variables.h"
#include "proc.h"
#include "bmcontainer.h"
#include "icon.h"
@ -9,8 +11,8 @@
#include "bmmenu.h"
#include "bmitem.h"
#include "hardware.h"
#include "functions.h"
#include "variables.h"
#include "popup.h"
struct ProcCmd CONST_DATA gProcCmd_ConvoyMenu[] = {
PROC_CALL_2(ConvoyMenuProc_StarMenu),
@ -78,11 +80,11 @@ void ConvoyMenuProc_ExecBootlegPopup(ProcPtr proc)
{
if (HasConvoyAccess()) {
if (gConvoyItemCount < 100)
sub_801FD80(proc, gActionData.item);
NewPopup2_SendItem(proc, gActionData.item);
else
sub_801FD70(proc, gActionData.item);
NewPopup2_DropItem(proc, gActionData.item);
} else
sub_801FD70(proc, gActionData.item);
NewPopup2_DropItem(proc, gActionData.item);
}
void HandleNewItemGetFromDrop(struct Unit* unit, int item, ProcPtr proc)

View File

@ -244,7 +244,7 @@ void AiStartStealAction(struct CpPerformProc* proc) {
UnitAddItem(gActiveUnit, item);
UnitRemoveItem(unit, gAiDecision.itemSlot);
CreatedItemStealingPopUp(item, proc);
NewPopup_ItemStealing(item, proc);
return;
}
@ -274,7 +274,7 @@ s8 AiPillageAction(struct CpPerformProc* proc) {
PlaySoundEffect(0xAB);
NewPopup2mple(gPopup_085A80A4, 0x60, 0, proc);
NewPopup_Simple(gPopup_085A80A4, 0x60, 0, proc);
}
return 1;

View File

@ -16,7 +16,7 @@
// unreferenced
void sub_807A708(ProcPtr proc) {
if (gCurrentMapAnimState.u62 == 1) {
CreatedItemStealingPopUp(gCurrentMapAnimState.actors[1].pBattleUnit->weapon, proc);
NewPopup_ItemStealing(gCurrentMapAnimState.actors[1].pBattleUnit->weapon, proc);
}
}

View File

@ -1,85 +0,0 @@
#include "global.h"
#include "functions.h"
#include "variables.h"
#include "proc.h"
#include "uiutils.h"
#include "fontgrp.h"
#include "hardware.h"
#include "icon.h"
/**
* It's like a popup but for some reason it's not
*/
/* struct definitions */
struct Popup2Proc {
PROC_HEADER;
/* 29 */ u8 _pad_29[0x4C - 0x29];
/* 4c */ u16 timer;
};
/* function declarations */
void ProcPopup2_Init(struct Popup2Proc *proc);
void ProcPopup2_Loop(struct Popup2Proc *proc);
/* section.data */
extern struct ProcCmd CONST_DATA ProcScr_Popup2[];
/* section.text */
void ProcPopup2_Init(struct Popup2Proc *proc)
{
proc->timer = 0xF0;
}
void ProcPopup2_Loop(struct Popup2Proc *proc)
{
int timer = --proc->timer;
/* todo */
if ((timer << 0x10 < 0) || ((A_BUTTON | B_BUTTON) & gKeyStatusPtr->newKeys))
Proc_Break(proc);
}
void StartPopup2WithIcon(ProcPtr parent, int IconIndex, char *str)
{
int len = GetStringTextWidth(str);
int x, x_tile, y_tile;
if (IconIndex >= 0)
len += 0x10;
len += 0x18;
x_tile = 0xF0 - len;
if (x_tile < 0)
x_tile += 0xF;
x = x_tile >> 4;
y_tile = len < 0 ? len + 7 : len;
DrawUiFrame2(x_tile >> 4, 8, y_tile >> 3, 4, 0);
if (IconIndex >= 0) {
ResetIconGraphics_();
LoadIconPalettes(4);
DrawIcon(
TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9),
IconIndex,
TILEREF(0, 0x4)); /* todo */
x += 2;
}
Font_ResetAllocation();
DrawTextInline(NULL, TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9), TEXT_COLOR_NORMAL, 0, 0x14, str);
Proc_StartBlocking(ProcScr_Popup2, parent);
}

View File

@ -625,15 +625,15 @@ void SetPopupNumber(u32 num)
gPopupNumber = num;
}
ProcPtr NewPopup2mple(const struct PopupInstruction *inst,
ProcPtr NewPopup_Simple(const struct PopupInstruction *inst,
int clock,
int winStyle,
ProcPtr parent)
{
return NewPopup(inst, clock, winStyle, 0x240, 4, parent);
return NewPopupCore(inst, clock, winStyle, 0x240, 4, parent);
}
ProcPtr NewPopup(const struct PopupInstruction *inst,
ProcPtr NewPopupCore(const struct PopupInstruction *inst,
int clock,
int winStyle,
int iconObjTileId,
@ -655,19 +655,19 @@ ProcPtr NewPopup(const struct PopupInstruction *inst,
return proc;
}
void NewGotItemPopup(struct Unit* unit, u16 item, ProcPtr parent)
void NewPopup_ItemGot_unused(struct Unit* unit, u16 item, ProcPtr parent)
{
SetPopupItem(item);
if (FACTION_BLUE == UNIT_FACTION(unit))
NewPopup2mple(gPopup_GotItem, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_GotItem, 0x60, 0x0, parent);
else
NewPopup2mple(gPopup_ItemWasPilfered, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_ItemWasPilfered, 0x60, 0x0, parent);
}
void ItemGot_DisplayLePopup(struct GotItemPopupProc *proc)
{
NewGotItemPopup(proc->unit, proc->item, proc);
NewPopup_ItemGot_unused(proc->unit, proc->item, proc);
}
void ItemGot_GotLeItem(struct GotItemPopupProc *proc)
@ -675,7 +675,7 @@ void ItemGot_GotLeItem(struct GotItemPopupProc *proc)
HandleNewItemGetFromDrop(proc->unit, MakeNewItem(proc->item), proc);
}
void NewItemGot(ProcPtr parent, struct Unit *unit, u16 item)
void NewPopup_ItemGot(ProcPtr parent, struct Unit *unit, u16 item)
{
struct GotItemPopupProc *proc;
@ -690,7 +690,7 @@ void NewItemGot(ProcPtr parent, struct Unit *unit, u16 item)
unit->state |= US_DROP_ITEM;
}
void NewGeneralItemGot(struct Unit *unit, u16 item, ProcPtr parent)
void NewPopup_GeneralItemGot(struct Unit *unit, u16 item, ProcPtr parent)
{
switch (ITEM_INDEX(item)) {
case ITEM_1G:
@ -702,11 +702,11 @@ void NewGeneralItemGot(struct Unit *unit, u16 item, ProcPtr parent)
case ITEM_5000G:
case ITEM_150G:
case ITEM_200G:
NewGoldGotPopup(parent, unit, GetItemCost(item));
NewPopup_GoldGot(parent, unit, GetItemCost(item));
break;
default:
NewItemGot(parent, unit, item);
NewPopup_ItemGot(parent, unit, item);
break;
} /* switch item index */
}
@ -716,59 +716,59 @@ void NewGoldNumPopup_unused(u32 num, ProcPtr parent) /* unused */
SetPopupNumber(num);
if (FACTION_BLUE == UNIT_FACTION(gActiveUnit))
NewPopup2mple(gPopup_GotGold, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_GotGold, 0x60, 0x0, parent);
else
NewPopup2mple(gPopup_GoldWasStole, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_GoldWasStole, 0x60, 0x0, parent);
}
void NewNumberPopup_unused(u32 num, ProcPtr parent) /* unused */
{
SetPopupNumber(num);
NewPopup2mple(gPopup_GotGold, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_GotGold, 0x60, 0x0, parent);
}
void NewGoldGotPopup(ProcPtr parent, struct Unit *unit, int value)
void NewPopup_GoldGot(ProcPtr parent, struct Unit *unit, int value)
{
SetPopupNumber(value);
if (FACTION_BLUE == UNIT_FACTION(unit)) {
value += GetPartyGoldAmount();
SetPartyGoldAmount(value);
NewPopup2mple(gPopup_GotGold, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_GotGold, 0x60, 0x0, parent);
} else
NewPopup2mple(gPopup_GoldWasStole, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_GoldWasStole, 0x60, 0x0, parent);
}
void CreatedItemStealingPopUp(u16 item, ProcPtr parent)
void NewPopup_ItemStealing(u16 item, ProcPtr parent)
{
SetPopupItem(item);
if (FACTION_BLUE == UNIT_FACTION(gActiveUnit))
NewPopup2mple(gPopup_StoleItem, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_StoleItem, 0x60, 0x0, parent);
else
NewPopup2mple(gPopup_ItemStolen, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_ItemStolen, 0x60, 0x0, parent);
}
void NewPopup_WeaponBroke(u16 item, ProcPtr parent)
{
SetPopupItem(item);
NewPopup2mple(gPopup_WpnBroken, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_WpnBroken, 0x60, 0x0, parent);
}
void NewPopup_WRankIncrease(u16 item, ProcPtr parent)
{
SetPopupItem(item);
NewPopup2mple(gPopup_WRankUp, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_WRankUp, 0x60, 0x0, parent);
}
/* maybe change uniy fraction to ally */
void NewPopup_NewAlly(ProcPtr parent, u8 char_id)
{
SetPopupUnit(GetUnitFromCharId(char_id));
NewPopup2mple(gPopup_NewAlly, 0x60, 0x0, parent);
NewPopup_Simple(gPopup_NewAlly, 0x60, 0x0, parent);
}
void NewPopupVerySimple(u32 msg, u32 sound_index, ProcPtr parent)
void NewPopup_VerySimple(u32 msg, u32 sound_index, ProcPtr parent)
{
gPopupInst[0].opcode = POPUP_OP_SOUND;
gPopupInst[0].data = sound_index;
@ -782,5 +782,5 @@ void NewPopupVerySimple(u32 msg, u32 sound_index, ProcPtr parent)
gPopupInst[3].opcode = POPUP_OP_END;
gPopupInst[3].data = 0;
NewPopup2mple(gPopupInst, 0x60, 0x0, parent);
NewPopup_Simple(gPopupInst, 0x60, 0x0, parent);
}

285
src/popup2.c Normal file
View File

@ -0,0 +1,285 @@
#include "global.h"
#include "functions.h"
#include "variables.h"
#include "proc.h"
#include "uiutils.h"
#include "fontgrp.h"
#include "hardware.h"
#include "icon.h"
#include "bmitem.h"
/**
* It's like a popup but for some reason it's not
*/
/* struct definitions */
struct Popup2Proc {
PROC_HEADER;
/* 29 */ u8 _pad_29[0x4C - 0x29];
/* 4c */ u16 timer;
};
/* function declarations */
void ProcPopup2_Init(struct Popup2Proc *proc);
void ProcPopup2_Loop(struct Popup2Proc *proc);
/* section.data */
struct ProcCmd CONST_DATA ProcScr_Popup2[] = {
PROC_CALL(ProcPopup2_Init),
PROC_REPEAT(ProcPopup2_Loop),
PROC_CALL(ClearBg0Bg1),
PROC_END
};
/* section.text */
void ProcPopup2_Init(struct Popup2Proc *proc)
{
proc->timer = 0xF0;
}
void ProcPopup2_Loop(struct Popup2Proc *proc)
{
int timer = --proc->timer;
/* todo */
if ((timer << 0x10 < 0) || ((A_BUTTON | B_BUTTON) & gKeyStatusPtr->newKeys))
Proc_Break(proc);
}
void NewPopup2_PlanA(ProcPtr parent, int IconIndex, char *str)
{
int len = GetStringTextWidth(str);
int x, x_tile, y_tile;
if (IconIndex >= 0)
len += 0x10;
len += 0x18;
x_tile = 0xF0 - len;
if (x_tile < 0)
x_tile += 0xF;
x = x_tile >> 4;
y_tile = len < 0 ? len + 7 : len;
DrawUiFrame2(x_tile >> 4, 8, y_tile >> 3, 4, 0);
if (IconIndex >= 0) {
ResetIconGraphics_();
LoadIconPalettes(4);
DrawIcon(
TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9),
IconIndex,
TILEREF(0, 0x4)); /* todo */
x += 2;
}
Font_ResetAllocation();
DrawTextInline(NULL, TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9), TEXT_COLOR_NORMAL, 0, 0x14, str);
Proc_StartBlocking(ProcScr_Popup2, parent);
}
void NewPopup2_PlanB(ProcPtr proc, int icon_index, char *str0, int num, char *str1)
{
int tmp, tiles, x, y, x_tile, y_tile;
struct TextHandle th;
int len = 1;
if (0 != str0)
len += GetStringTextWidth(str0) + 2;
if (0 != str1)
len += GetStringTextWidth(str1) + 2;
tiles = 8;
tmp = num;
while (1) {
tmp = tmp / 0xA;
if (tmp == 0)
break;
tiles += 8;
}
if (icon_index >= 0)
len += 0x10;
len += 0x18;
x_tile = 0xF0 - len;
if (x_tile < 0)
x_tile += 0xF;
x = x_tile >> 4;
tmp = len += tiles;
len = len < 0 ? tmp + 7 : tmp;
tiles = len >> 3;
DrawUiFrame2(x, 8, tiles, 4, 0);
if (icon_index >= 0) {
ResetIconGraphics_();
LoadIconPalettes(4);
DrawIcon(
TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9),
icon_index,
TILEREF(0, 0x4)); /* todo */
x += 2;
}
Font_ResetAllocation();
Text_Init(&th, tiles);
Text_Advance(&th, 1);
if (0 != str0) {
Text_SetColorId(&th, 0);
Text_AppendString(&th, str0);
Text_Advance(&th, 2);
}
Text_SetColorId(&th, 2);
sub_80040C0(&th, num); /* seems like draw this number */
if (0 != str1) {
Text_Advance(&th, 2);
Text_SetColorId(&th, 0);
Text_AppendString(&th, str1);
}
Text_Draw(&th, TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9));
Proc_StartBlocking(ProcScr_Popup2, proc);
}
void NewPopup2_PlanC(ProcPtr parent, int item, int msg)
{
int len, x, y, x_tile, y_tile;
struct TextHandle th;
Font_ResetAllocation();
Text_Init(&th, 0x14);
Text_SetColorId(&th, TEXT_COLOR_BLUE);
Text_AppendString(&th, GetItemName(item));
Text_Advance(&th, 2);
Text_SetColorId(&th, TEXT_COLOR_NORMAL);
Text_AppendString(&th, GetStringFromIndex(msg));
len = Text_GetXCursor(&th);
len += 0x28;
x_tile = 0xF0 - len;
if (x_tile < 0)
x_tile += 0xF;
x = x_tile >> 4;
y_tile = len < 0 ? len + 7 : len;
y = y_tile >> 3;
DrawUiFrame2(x, 8, y, 4, 0);
DrawIcon(
TILEMAP_LOCATED(gBG0TilemapBuffer, x + 1, 9),
GetItemIconId(item),
TILEREF(0, 0x4)
);
Text_Draw(&th, TILEMAP_LOCATED(gBG0TilemapBuffer, x + 3, 9));
Proc_StartBlocking(ProcScr_Popup2, parent);
}
void NewPopup2_PlanD(ProcPtr parent, int item, int msg0, int msg1)
{
int len2, x_tile, y_tile, y;
char *str;
#if NONMATCHING
int len1, x0, x1;
#else
register int len1 asm("r1") = 0;
register int x0 asm("r4") = 0;
register int x1 asm("r6") = 0;
#endif /* NONMATCHING */
struct TextHandle th;
Font_ResetAllocation();
Text_Init(&th, 0x14);
if (0 != msg0) {
Text_SetColorId(&th, 0);
Text_AppendString(&th, GetStringFromIndex(msg0));
Text_Advance(&th, 2);
}
Text_SetColorId(&th, 2);
if (0 != msg0)
str = GetItemNameWithArticle(item, 0);
else
str = GetItemNameWithArticle(item, 1);
Text_AppendString(&th, str);
len1 = Text_GetXCursor(&th) + 7;
if (len1 < 0)
len1 += 7;
x0 = len1 >> 3;
Text_SetXCursor(&th, (x0 + 2) * 8);
Text_SetColorId(&th, 0);
if (0 != msg1) {
Text_AppendString(&th, GetStringFromIndex(msg1));
}
len2 = Text_GetXCursor(&th);
len2 += 0x18;
x_tile = 0xF0 - len2;
if (x_tile < 0)
x_tile += 0xF;
x1 = x_tile >> 4;
y_tile = len2 < 0 ? len2 + 7 : len2;
y = y_tile >> 3;
DrawUiFrame2(x1, 8, y, 4, 0);
Text_Draw(&th, TILEMAP_LOCATED(gBG0TilemapBuffer, x1 + 1, 9));
x0 += 1;
DrawIcon(
TILEMAP_LOCATED(gBG0TilemapBuffer, x1 + x0, 9),
GetItemIconId(item),
TILEREF(0, 0x4)
);
Proc_StartBlocking(ProcScr_Popup2, parent);
}
void NewPopup2_DropItem(ProcPtr parent, int item)
{
NewPopup2_PlanD(parent, item,
0x00F, /* Dropped */
0x022); /* .[.] */
}
void NewPopup2_SendItem(ProcPtr parent, int item)
{
NewPopup2_PlanD(parent, item,
0x010, /* Sent [.] */
0x011); /* .[.] */
}

0
src/unitswapfx.c Executable file
View File