Skip to content

Commit

Permalink
pal world (#1218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alto1772 authored Nov 9, 2024
1 parent 355f5b3 commit c356a0e
Show file tree
Hide file tree
Showing 121 changed files with 11,802 additions and 17,180 deletions.
9 changes: 3 additions & 6 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,8 @@ typedef struct SaveGlobals {
/* 0x34 */ s32 crc2;
/* 0x38 */ s32 useMonoSound;
/* 0x3C */ u32 lastFileSelected;
/* 0x40 */ s8 reserved[64]; // unused
/* 0x40 */ u32 language; // only used for PAL
/* 0x44 */ s8 reserved[60]; // unused
} SaveGlobals; // size = 0x80

typedef struct SaveMetadata {
Expand Down Expand Up @@ -2253,7 +2254,7 @@ typedef struct {

#if VERSION_JP
#define DISPLAYCONTEXT_GFX_COUNT 0x2000
#elif VERSION_IQUE
#elif VERSION_IQUE || VERSION_PAL
#define DISPLAYCONTEXT_GFX_COUNT 0x2200
#else
#define DISPLAYCONTEXT_GFX_COUNT 0x2080
Expand All @@ -2265,10 +2266,6 @@ typedef struct {
/* 0x00030 */ Mtx camPerspMatrix[8]; // could only be length 4, unsure
/* 0x00230 */ Gfx mainGfx[DISPLAYCONTEXT_GFX_COUNT];
/* 0x10630 */ Gfx backgroundGfx[0x200]; // used by gfx_task_background
#if VERSION_PAL
// TODO: find where this space belongs to
s32 pad[0x300];
#endif
/* 0x11630 */ Mtx matrixStack[0x200];
} DisplayContext; // size = 0x19630

Expand Down
20 changes: 16 additions & 4 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -5352,31 +5352,43 @@ enum FileMenuMessages {
/* 14 */ FILE_MESSAGE_YES, // Yes[End]
/* 15 */ FILE_MESSAGE_NO, // No[End]
/* 16 */ FILE_MESSAGE_DELETE, // Delete[End]
#if !VERSION_PAL
/* 17 */ FILE_MESSAGE_OVERRIDE_TO_NEW_DATA, // Override to New Data[End]
/* 18 */ FILE_MESSAGE_SAVE_OK, // Save OK?[End]
#endif
/* 19 */ FILE_MESSAGE_FILE_NAME_IS, // File name is :[End]
/* 20 */ FILE_MESSAGE_PERIOD_20, // .[End]
/* 21 */ FILE_MESSAGE_OK, // OK?[End]
/* 22 */ FILE_MESSAGE_FILE_22, // File[End]
#if VERSION_PAL
FILE_MESSAGE_PAL_FILE_20, // File[End] / Dat.[End] / Fich.[End]
#endif
/* 23 */ FILE_MESSAGE_WILL_BE_DELETED, // will be deleted.[End]
/* 24 */ FILE_MESSAGE_OK_TO_COPY_TO_THIS_FILE, // OK to copy to this file?[End]
/* 25 */ FILE_MESSAGE_START_GAME_WITH, // Start game with[End]
#if VERSION_PAL
FILE_MESSAGE_PAL_QUESTION_24, // ?[End] / beginnen?[End]
#endif
/* 26 */ FILE_MESSAGE_FILE_26, // File[End]
/* 27 */ FILE_MESSAGE_HAS_BEEN_DELETED, // has been deleted.[End]
/* 28 */ FILE_MESSAGE_28, // [End]
/* 29 */ FILE_MESSAGE_COPY_FROM, // Copy from[End]
/* 30 */ FILE_MESSAGE_TO, // to[End]
#if VERSION_PAL
FILE_MESSAGE_PAL_PERIOD_30, // .[End] / kopieren.[End]
#endif
/* 31 */ FILE_MESSAGE_HAS_BEEN_CREATED, // has been created.[End]
#if VERSION_PAL
// TODO: determine where these new entries should be placed
FILE_MESSAGE_PAL_UNK1,
FILE_MESSAGE_PAL_UNK2,
FILE_MESSAGE_PAL_ARTICLE, // [End] / Le[End] / El[End]
#endif
/* 32 */ FILE_MESSAGE_ENTER_A_FILE_NAME, // Enter a file name![End]
/* 33 */ FILE_MESSAGE_QUESTION, // ?[End]
/* 34 */ FILE_MESSAGE_PERIOD_34, // .[End]
#if VERSION_PAL
FILE_MESSAGE_PAL_UNK3,
FILE_MESSAGE_PAL_FILENUM_1,
FILE_MESSAGE_PAL_FILENUM_2,
FILE_MESSAGE_PAL_FILENUM_3,
FILE_MESSAGE_PAL_FILENUM_4,
#endif
};

Expand Down
4 changes: 2 additions & 2 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,9 @@ typedef s32 Difficulty2D[AC_DIFFICULTY_LEN][2];
#endif

#if VERSION_PAL
#define DT (50.0f/60.0f)
#define DT (50.0/60.0)
#else
#define DT (1.0f)
#define DT (1.0)
#endif

#define DMA_COPY_SEGMENT(segment) dma_copy(segment##_ROM_START, segment##_ROM_END, segment##_VRAM)
Expand Down
3 changes: 3 additions & 0 deletions include/nu/nusys.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ extern u32 nuGfxDisplay; /* Display on/off flag */
extern u32 nuGfxCfbCounter; /* For frame buffer swapping */
//extern OSMesgQueue nuGfxMesgQ;
extern OSThread nuGfxThread; /* graphic thread */
extern s32 nuGfxUcodeFifoSize;
extern u64* nuGfxUcodeFifoPtr;

/*--------------------------------------*/
/* controller Manager variables */
Expand Down Expand Up @@ -791,6 +793,7 @@ extern void nuGfxPreNMIFuncSet(NUGfxPreNMIFunc func);
extern void nuGfxSwapCfbFuncSet(NUGfxSwapCfbFunc func);
extern void nuGfxSetCfb(u16** framebuf, u32 framebufnum);
extern void nuGfxSwapCfb(void* framebuffer);
extern void nuGfxSetUcodeFifo(void* fifoBufPtr, s32 size);

extern void nuGfxTaskEndFuncSet(NUGfxTaskEndFunc func);
extern void nuGfxTaskAllEndWait(void);
Expand Down
2 changes: 1 addition & 1 deletion progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def main(args):
sizes, vrams = get_func_info()
total_size = sum(sizes.values())
# TODO hack for now since non-us roms aren't mapped out
if args.version not in ("us", "ique"):
if args.version not in ("us", "ique", "pal"):
total_size = 3718612
all_funcs = set(sizes.keys())

Expand Down
23 changes: 9 additions & 14 deletions src/8a860_len_3f30.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ void func_800F16CC(void) {
gPopupState = POPUP_STATE_20;
}

#if VERSION_PAL
s32 popup_menu_update(void);
INCLUDE_ASM(s32, "8a860_len_3f30", popup_menu_update);
#else
s32 popup_menu_update(void) {
s32 posX;
s32 posY;
Expand All @@ -359,10 +355,11 @@ s32 popup_menu_update(void) {
s32 one;
s32 i;

s32 var_s6 = 0;
s32 var_s5 = 0;
s32 var_s6 = 0; // maybe 6 before 5
s32 msgWidth;
s32 width2;
s32 height2;
s32 posX2;

switch (gPopupState) {
Expand All @@ -371,7 +368,6 @@ s32 popup_menu_update(void) {
D_8010D67C = 32;
D_8010D67E = 72;
D_8010D680 = 32;
PopupMenu_StarPieceCounterPosX = 32;
#else
D_8010D67C = 20;
D_8010D67E = 72;
Expand All @@ -380,9 +376,7 @@ s32 popup_menu_update(void) {
D_8010D682 = 186;
D_8010D684 = 16;
D_8010D686 = 88;
#if !VERSION_JP
PopupMenu_StarPieceCounterPosX = 32;
#endif
PopupMenu_StarPieceCounterPosY = 164;
if (PopupNotBattle) {
#if VERSION_JP
Expand Down Expand Up @@ -601,12 +595,14 @@ s32 popup_menu_update(void) {
set_window_properties(WIN_POPUP_CONTENT, posX, posY, var_s6, (PopupMenu_DisplayedEntryCount * LINE_HEIGHT) + 26,
WINDOW_PRIORITY_20, popup_menu_draw_menu_contents, NULL, -1);
if (gPopupMenu->unk_338 == 0) {
set_window_properties(WIN_POPUP_TITLE_A, posX2, -6, width2, 16, WINDOW_PRIORITY_21,
posX = posX2; //! required to match
set_window_properties(WIN_POPUP_TITLE_A, posX, -6, width2, 16, WINDOW_PRIORITY_21,
popup_menu_draw_title_contents, NULL, WIN_POPUP_CONTENT);
set_window_update(WIN_POPUP_TITLE_A, 1);
set_window_update(WIN_POPUP_TITLE_B, 2);
} else {
set_window_properties(WIN_POPUP_TITLE_B, posX2, -6, width2, 16, WINDOW_PRIORITY_21,
posX = posX2; //! required to match
set_window_properties(WIN_POPUP_TITLE_B, posX, -6, width2, 16, WINDOW_PRIORITY_21,
popup_menu_draw_title_contents, NULL, WIN_POPUP_CONTENT);
set_window_update(WIN_POPUP_TITLE_A, 2);
set_window_update(WIN_POPUP_TITLE_B, 1);
Expand Down Expand Up @@ -804,11 +800,11 @@ s32 popup_menu_update(void) {
posY = D_8010D686;

#if VERSION_PAL
height = 32;
height2 = 32;
if (get_msg_lines(gPopupMenu->unk_33C) == 2) {
height = 40;
height2 = 40;
}
set_window_properties(WIN_POPUP_PROMPT, posX, posY, gPopupMenu->unk_340 + 144, height, WINDOW_PRIORITY_20, func_800F4944, NULL, -1);
set_window_properties(WIN_POPUP_PROMPT, posX, posY, gPopupMenu->unk_340 + 144, height2, WINDOW_PRIORITY_20, func_800F4944, NULL, -1);
#else
switch (gPopupMenu->popupType) {
#if VERSION_JP
Expand Down Expand Up @@ -1388,7 +1384,6 @@ s32 popup_menu_update(void) {
gPopupMenu->result = POPUP_RESULT_CHOOSING;
return 0;
}
#endif

void popup_menu_draw_menu_contents(s32* userData, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
s32 x, y;
Expand Down
12 changes: 10 additions & 2 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ typedef u8* WaveData;
#define ALIGN16_(val) (((val) + 0xF) & 0xFFF0)
#define AU_FILE_RELATIVE(base,offset) ((void*)((s32)(offset) + (s32)(base)))

#define AUDIO_HEAP_SIZE 0x56000
// NU_AU_AUDIO_SAMPLES ?
#define AUDIO_SAMPLES 184
#if VERSION_PAL
#define AUDIO_FRAMES_PER_SECOND 50
#define AUDIO_HEAP_SIZE 0x5B000
#define AUDIO_MAX_SAMPLES (AUDIO_SAMPLES * 2)
#define AUDIO_COMMAND_LIST_BUFFER_SIZE 0x5558
#else
#define AUDIO_FRAMES_PER_SECOND 60
#define AUDIO_HEAP_SIZE 0x56000
#define AUDIO_MAX_SAMPLES AUDIO_SAMPLES
#define AUDIO_COMMAND_LIST_BUFFER_SIZE 0x4000
#endif

#define ADPCMFBYTES 9

Expand Down
6 changes: 3 additions & 3 deletions src/audio/25f00_len_940.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ void create_audio_system(void) {
config.num_pvoice = 24;
config.num_bus = 4;
outputRate = osAiSetFrequency(32000);
frameSize = (nusched.retraceCount * outputRate + 59) / 60;
frameSize = (nusched.retraceCount * outputRate + (AUDIO_FRAMES_PER_SECOND - 1)) / AUDIO_FRAMES_PER_SECOND;
config.outputRate = outputRate;
config.unk_0C = 0;
config.heap = &nuAuHeap;
config.dmaNew = nuAuDmaNew;
AlFrameSize = ((frameSize / AUDIO_SAMPLES) + 1) * AUDIO_SAMPLES;
AlMinFrameSize = AlFrameSize - AUDIO_SAMPLES;
AlMinFrameSize = AlFrameSize - AUDIO_MAX_SAMPLES;

for (i = 0; i < ARRAY_COUNT(AlCmdListBuffers); i++) {
AlCmdListBuffers[i] = alHeapAlloc(config.heap, 1, AUDIO_COMMAND_LIST_BUFFER_SIZE);
Expand Down Expand Up @@ -166,7 +166,7 @@ void nuAuMgr(void* arg) {
cmdListBuf = AlCmdListBuffers[cmdListIndex];
bufferPtr = D_800A3628[bufferIndex];
}
if (sampleSize < AUDIO_SAMPLES || cond) {
if (sampleSize < AUDIO_MAX_SAMPLES || cond) {
samples = AlFrameSize;
cond = FALSE;
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/audio/2e230_len_2190.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ extern f32 AlTuneScaling[];
#define SBN_ROM_OFFSET (s32) audio_ROM_START
#elif VERSION_JP
#define SBN_ROM_OFFSET 0xFC0000
#elif VERSION_PAL
#define SBN_ROM_OFFSET 0x13A0000
#else
#define SBN_ROM_OFFSET 0xF00000
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/battle/16C8E0.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ void btl_update(void) {
s32 cond;

if (battleStatus->inputBitmask != -1) {
#if !VERSION_PAL
if ((battleStatus->flags1 & BS_FLAGS1_PARTNER_ACTING) && gGameStatusPtr->multiplayerEnabled) {
s32 inputBitmask = battleStatus->inputBitmask;

Expand All @@ -272,14 +273,17 @@ void btl_update(void) {
battleStatus->stickX = gGameStatusPtr->stickX[1];
battleStatus->stickY = gGameStatusPtr->stickY[1];
} else {
#endif
s32 inputBitmask2 = battleStatus->inputBitmask;

battleStatus->curButtonsDown = gGameStatusPtr->curButtons[0] & inputBitmask2;
battleStatus->curButtonsPressed = gGameStatusPtr->pressedButtons[0] & inputBitmask2;
battleStatus->curButtonsHeld = gGameStatusPtr->heldButtons[0] & inputBitmask2;
battleStatus->stickX = gGameStatusPtr->stickX[0];
battleStatus->stickY = gGameStatusPtr->stickY[0];
#if !VERSION_PAL
}
#endif
}

get_stick_input_radial(&outAngle, &outMagnitude);
Expand Down
20 changes: 20 additions & 0 deletions src/battle/190B20.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void create_target_list(Actor* actor, b32 targetHomePos) {
s32 sampleCol;
s32 sampleRow;
s32 removeTarget;
s8 *targetIndexIt;

// a target has been manually selected
if (battleStatus->curTargetListFlags & TARGET_FLAG_OVERRIDE) {
Expand Down Expand Up @@ -247,9 +248,14 @@ void create_target_list(Actor* actor, b32 targetHomePos) {
// ------------------------------------------------------------------------
// remove targets based on simple criteria (coarse pass)

// TODO find someway into removing this do-while loop hack
#if VERSION_PAL
actor->selectedTargetIndex = 0;
#else
do {
actor->selectedTargetIndex = 0;
} while (0);
#endif
actor->targetListLength = numTargets;

/// @bug this should be % 4
Expand Down Expand Up @@ -494,11 +500,23 @@ void create_target_list(Actor* actor, b32 targetHomePos) {

targetDataList = actor->targetData;

#if VERSION_PAL
targetIndexList = actor->targetIndexList;
numTargets = actor->targetListLength;

i = ARRAY_COUNT(actor->targetIndexList) - 1;
targetIndexIt = &actor->targetIndexList[ARRAY_COUNT(actor->targetIndexList) - 1];

while (i >= 0) {
*targetIndexIt-- = i--;
}
#else
numTargets = actor->targetListLength;
targetIndexList = actor->targetIndexList;
for (i = 0; i < numTargets; i++) {
targetIndexList[i] = i;
}
#endif

// sort targets by priority
for (i = 0; i < numTargets - 1; i++) {
Expand Down Expand Up @@ -3156,6 +3174,7 @@ EvtScript EVS_BattleRumble_PlayerMin = {
End
};

#if !VERSION_PAL
EvtScript EVS_BattleRumble_PlayerLight = {
Call(N(StartRumbleWithParams), 150, 20)
Return
Expand All @@ -3179,6 +3198,7 @@ EvtScript EVS_BattleRumble_PlayerMax = {
Return
End
};
#endif

void start_rumble_type(u32 type) {
if (bCurRumbleScript != 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/battle/action_cmd/squirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ enum {
// how much to subtract from the meter per frame after overfilling it
#define METER_DRAIN_RATE 250

s32 N(DrainRateTable)[] = { 300, 300, 265, 220, 175, 175 };
s32 N(FillRateTable)[] = { 300, 300, 265, 220, 175, 175 };
s32 N(DrainRateTable)[] = { 300 / DT, 300 / DT, 265 / DT, 220 / DT, 175 / DT, 175 / DT };
s32 N(FillRateTable)[] = { 300 / DT, 300 / DT, 265 / DT, 220 / DT, 175 / DT, 175 / DT };

// bug: the sixth entry is not accessible due to the way idx is calculated in these macros
#define GET_DRAIN_RATE(pct) (N(DrainRateTable)[((pct) / (ONE_PCT_MASH / 5))])
Expand Down
6 changes: 3 additions & 3 deletions src/battle/action_cmd/three_chances.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void N(update)(void) {
&& acs->threeChances.time >= -5
) {
s32 (*difficultyVec)[2] = (s32 (*)[2])battleStatus->actionCmdDifficultyTable;
window = difficultyVec[acs->difficulty][0] + difficultyVec[acs->difficulty][1] + ANTI_MASH_TIME;
window = difficultyVec[acs->difficulty][0] + difficultyVec[acs->difficulty][1] + (s32)(ANTI_MASH_TIME * DT);
pos = battleStatus->inputBufferPos;
pos -= window;
if (pos < 0) {
Expand Down Expand Up @@ -452,7 +452,7 @@ void N(update)(void) {
&& acs->threeChances.time >= -5
) {
s32 (*difficultyVec)[2] = (s32 (*)[2])battleStatus->actionCmdDifficultyTable;
window = difficultyVec[acs->difficulty][0] + difficultyVec[acs->difficulty][1] + ANTI_MASH_TIME - 1;
window = difficultyVec[acs->difficulty][0] + difficultyVec[acs->difficulty][1] + (s32)((ANTI_MASH_TIME - 1) * DT);
if (window < 6) {
window = 6;
}
Expand Down Expand Up @@ -540,7 +540,7 @@ void N(update)(void) {
&& acs->threeChances.time >= -5
) {
s32 (*difficultyVec)[2] = (s32 (*)[2])battleStatus->actionCmdDifficultyTable;
window = difficultyVec[acs->difficulty][0] + difficultyVec[acs->difficulty][1] + ANTI_MASH_TIME - 2;
window = difficultyVec[acs->difficulty][0] + difficultyVec[acs->difficulty][1] + (s32)((ANTI_MASH_TIME - 2) * DT);
if (window < 6) {
window = 6;
}
Expand Down
Loading

0 comments on commit c356a0e

Please sign in to comment.