mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 13:09:56 +00:00
Match funcs and create unused_vblank.c
Also cleaned more .h files
This commit is contained in:
parent
de39525da5
commit
d20e2522c2
@ -1,71 +0,0 @@
|
||||
#include "asm/constants/gba_constants.inc"
|
||||
#include "asm/macros.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_800B850
|
||||
sub_800B850:
|
||||
push {r4-r7,lr}
|
||||
lsls r0, 16
|
||||
asrs r6, r0, 16
|
||||
bl DisableInterrupts
|
||||
lsls r0, 24
|
||||
lsrs r5, r0, 24
|
||||
movs r2, 0
|
||||
ldr r4, _0800B8A0
|
||||
ldr r3, _0800B8A4
|
||||
movs r1, 0
|
||||
ldrsh r0, [r3, r1]
|
||||
cmp r2, r0
|
||||
bge _0800B8B4
|
||||
adds r1, r3, 0
|
||||
_0800B86E:
|
||||
movs r7, 0
|
||||
ldrsh r0, [r4, r7]
|
||||
cmp r0, r6
|
||||
bne _0800B8A8
|
||||
ldrh r0, [r1]
|
||||
subs r0, 0x1
|
||||
strh r0, [r1]
|
||||
movs r3, 0
|
||||
ldrsh r0, [r1, r3]
|
||||
cmp r2, r0
|
||||
bge _0800B896
|
||||
ldr r3, _0800B8A4
|
||||
_0800B886:
|
||||
ldr r0, [r4, 0x8]
|
||||
ldr r1, [r4, 0xC]
|
||||
stm r4!, {r0,r1}
|
||||
adds r2, 0x1
|
||||
movs r7, 0
|
||||
ldrsh r0, [r3, r7]
|
||||
cmp r2, r0
|
||||
blt _0800B886
|
||||
_0800B896:
|
||||
cmp r5, 0
|
||||
beq _0800B8BC
|
||||
bl EnableInterrupts
|
||||
b _0800B8BC
|
||||
.align 2, 0
|
||||
_0800B8A0: .4byte gUnknown_202D608
|
||||
_0800B8A4: .4byte gUnknown_203B0AA
|
||||
_0800B8A8:
|
||||
adds r2, 0x1
|
||||
adds r4, 0x8
|
||||
movs r7, 0
|
||||
ldrsh r0, [r3, r7]
|
||||
cmp r2, r0
|
||||
blt _0800B86E
|
||||
_0800B8B4:
|
||||
cmp r5, 0
|
||||
beq _0800B8BC
|
||||
bl EnableInterrupts
|
||||
_0800B8BC:
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_800B850
|
||||
|
||||
.align 2, 0 @ Don't pad with nop.
|
6
include/bg_palette_buffer.h
Normal file
6
include/bg_palette_buffer.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef GUARD_BG_PALETTE_BUFFER_H
|
||||
#define GUARD_BG_PALETTE_BUFFER_H
|
||||
|
||||
void InitBGPaletteBuffer(void);
|
||||
|
||||
#endif // GUARD_BG_PALETTE_BUFFER_H
|
@ -1,6 +0,0 @@
|
||||
#ifndef GUARD_CODE_800B540_H
|
||||
#define GUARD_CODE_800B540_H
|
||||
|
||||
void sub_800CDA8(int a0);
|
||||
|
||||
#endif //GUARD_CODE_800B540_H
|
22
include/code_800B5F0.h
Normal file
22
include/code_800B5F0.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef GUARD_CODE_800B5F0_H
|
||||
#define GUARD_CODE_800B5F0_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
// size: 0x8
|
||||
struct unkStruct_202D648
|
||||
{
|
||||
s16 unk0;
|
||||
s16 unk2; // Vcount??
|
||||
IntrCallback unk4; // some function... just making it IntrCallback for now
|
||||
};
|
||||
|
||||
extern EWRAM_DATA s16 gUnknown_203B0A8;
|
||||
extern EWRAM_DATA s16 gUnknown_203B0AA;
|
||||
extern EWRAM_DATA s16 gUnknown_203B0AC;
|
||||
extern EWRAM_DATA s16 gUnknown_203B0AE;
|
||||
|
||||
void nullsub_17(void);
|
||||
void xxx_update_bg_sound_input(void);
|
||||
|
||||
#endif // GUARD_CODE_800B5F0_H
|
8
include/cpu.h
Normal file
8
include/cpu.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef GUARD_CPU_H
|
||||
#define GUARD_CPU_H
|
||||
|
||||
void VBlank_CB(void);
|
||||
|
||||
void sub_800CDA8(u32);
|
||||
|
||||
#endif //GUARD_CPU_H
|
@ -32,6 +32,7 @@ struct UnkFileStruct1
|
||||
/* 0x4 */ u32 unk4;
|
||||
};
|
||||
|
||||
void InitFileSystem(void);
|
||||
struct OpenedFile *OpenFile(const char *filename, const struct FileArchive *arc);
|
||||
u8 *GetFileDataPtr(struct OpenedFile *openedFile, int unused);
|
||||
struct OpenedFile *OpenFileAndGetFileDataPtr(const char *filename, const struct FileArchive *arc);
|
||||
|
12
include/main.h
Normal file
12
include/main.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef GUARD_MAIN_H
|
||||
#define GUARD_MAIN_H
|
||||
|
||||
typedef void (*IntrCallback)(void);
|
||||
|
||||
extern EWRAM_DATA IntrCallback gIntrCallbacks[6];
|
||||
|
||||
void AckInterrupt(u16);
|
||||
bool8 EnableInterrupts(void);
|
||||
bool8 DisableInterrupts(void);
|
||||
|
||||
#endif // GUARD_MAIN_H
|
11
include/sprite.h
Normal file
11
include/sprite.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef GUARD_SPRITE_H
|
||||
#define GUARD_SPRITE_H
|
||||
|
||||
void InitSprites(void);
|
||||
|
||||
// sprite.s
|
||||
extern void BlinkSavingIcon(void);
|
||||
extern void ResetSprites(bool32);
|
||||
extern void SetSavingIconCoords(u32);
|
||||
|
||||
#endif // GUARD_SPRITE_H
|
@ -7,6 +7,7 @@ void sub_8006518(struct UnkTextStruct2 *);
|
||||
void sub_8006554(struct UnkTextStruct1 *, void *, u8 *, u16 *, u32, const struct UnkTextStruct2 *, u8, u32, struct UnkTextStruct2_sub *, u8);
|
||||
|
||||
// text.s
|
||||
extern void InitGraphics(void);
|
||||
extern void xxx_call_draw_string(s32 x, u32 y, const u8 *str, u32 , u32);
|
||||
|
||||
#endif // GUARD_TEXT2_H
|
@ -74,7 +74,7 @@ SECTIONS {
|
||||
asm/code_8009804.o(.text);
|
||||
src/file_system.o(.text);
|
||||
src/main.o(.text);
|
||||
asm/code_800B5F0.o(.text);
|
||||
src/unused_vblank.o(.text);
|
||||
src/code_800B5F0.o(.text);
|
||||
src/music.o(.text);
|
||||
src/code_800C9CC.o(.text);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
|
||||
#define BG_PALETTE_BUFFER_SIZE 512
|
||||
#define BG_PALETTE_BUFFER_CHUNK_SIZE 16
|
||||
|
@ -17,7 +17,9 @@
|
||||
#include "exclusive_pokemon.h"
|
||||
#include "pokemon.h"
|
||||
#include "rescue_team_info.h"
|
||||
#include "cpu.h"
|
||||
#include "code_8094F88.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern void sub_801180C(void);
|
||||
extern void NDS_LoadOverlay_GroundMain(void);
|
||||
@ -30,15 +32,12 @@ extern void LoadMailInfo(void);
|
||||
extern void sub_800CD64(u32, u32);
|
||||
extern void SetWindowTitle(char *);
|
||||
extern void sub_800DAAC(void);
|
||||
extern void SetSavingIconCoords(u32);
|
||||
extern void sub_800135C(void);
|
||||
extern void xxx_script_related_8001334(u32);
|
||||
extern void sub_80015C0(u32, u32);
|
||||
extern u32 sub_8001658(u32, u32);
|
||||
extern void sub_800A8F8(u32);
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_80097B0(void);
|
||||
extern void sub_800CDA8(u32);
|
||||
extern void LoadTitleScreen(void);
|
||||
extern void SetBGPaletteBufferColorRGB(s32, u8 *, s32, u8 *);
|
||||
extern void sub_80095CC(u32, u32);
|
||||
@ -113,7 +112,7 @@ void GameLoop(void)
|
||||
while (1) {
|
||||
gUnknown_203B03C = 0; // ???
|
||||
sub_800A8F8(2);
|
||||
ResetSprites(1);
|
||||
ResetSprites(TRUE);
|
||||
xxx_update_some_bg_tiles(0);
|
||||
sub_80097B0();
|
||||
sub_800CDA8(2);
|
||||
@ -212,5 +211,5 @@ void xxx_update_stuff(u32 r0)
|
||||
xxx_call_update_bg_vram();
|
||||
sub_8009908();
|
||||
xxx_call_update_bg_sound_input();
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
}
|
||||
|
@ -1,69 +1,54 @@
|
||||
#include "global.h"
|
||||
#include "bg.h"
|
||||
#include "code_800B5F0.h"
|
||||
#include "debug.h"
|
||||
#include "input.h"
|
||||
#include "music.h"
|
||||
#include "debug.h"
|
||||
#include "sprite.h"
|
||||
|
||||
typedef void (*IntrCallback)(void);
|
||||
extern IntrCallback gIntrCallbacks[];
|
||||
|
||||
// size: 0x8
|
||||
struct unkStruct_202D648
|
||||
{
|
||||
s16 unk0;
|
||||
s16 unk2; // Vcount??
|
||||
IntrCallback unk4; // some function... just making it IntrCallback for now
|
||||
};
|
||||
extern struct unkStruct_202D648 gUnknown_202D648[8];
|
||||
extern struct unkStruct_202D648 gUnknown_202D608[8];
|
||||
extern struct unkStruct_202D648 gUnknown_202D648[8];
|
||||
|
||||
// bg_control.c
|
||||
extern u8 gUnknown_202D7FE;
|
||||
extern u16 gBldCnt;
|
||||
|
||||
EWRAM_DATA u8 gUnknown_203B099;
|
||||
EWRAM_DATA u8 gUnknown_203B09A;
|
||||
EWRAM_DATA u8 gUnknown_203B09B;
|
||||
EWRAM_DATA bool8 gUnknown_203B099;
|
||||
EWRAM_DATA bool8 gUnknown_203B09A;
|
||||
EWRAM_DATA bool8 gUnknown_203B09B;
|
||||
EWRAM_DATA u32 gUnknown_203B09C;
|
||||
EWRAM_DATA u32 gUnknown_203B0A0;
|
||||
EWRAM_DATA u32 gUnknown_203B0A4;
|
||||
EWRAM_DATA u32 gUnknown_203B0A4; // Written to but never read
|
||||
EWRAM_DATA s16 gUnknown_203B0A8;
|
||||
EWRAM_DATA s16 gUnknown_203B0AA;
|
||||
EWRAM_DATA s16 gUnknown_203B0AC;
|
||||
EWRAM_DATA s16 gUnknown_203B0AE;
|
||||
EWRAM_DATA s16 gUnknown_203B0B0;
|
||||
EWRAM_DATA s16 gUnknown_203B0B2;
|
||||
|
||||
extern bool8 EnableInterrupts(void);
|
||||
extern bool8 DisableInterrupts(void);
|
||||
void xxx_update_bg_sound_input();
|
||||
extern void AckInterrupt(u16);
|
||||
void BlinkSavingIcon();
|
||||
|
||||
void UnusedIntrFunc(void)
|
||||
{
|
||||
}
|
||||
EWRAM_DATA s16 gUnknown_203B0B0; // Written to but never read
|
||||
EWRAM_DATA s16 gUnknown_203B0B2; // Written to but never read
|
||||
|
||||
void VBlankIntr(void)
|
||||
{
|
||||
int index;
|
||||
s32 index;
|
||||
|
||||
gUnknown_203B0A0++;
|
||||
SoundVSync();
|
||||
BlinkSavingIcon();
|
||||
if (gIntrCallbacks[1] != NULL) {
|
||||
|
||||
if (gIntrCallbacks[1] != NULL)
|
||||
gIntrCallbacks[1]();
|
||||
}
|
||||
for(index = 0; index < gUnknown_203B0AA; index++) {
|
||||
|
||||
for (index = 0; index < gUnknown_203B0AA; index++)
|
||||
gUnknown_202D648[index] = gUnknown_202D608[index];
|
||||
}
|
||||
|
||||
gUnknown_203B0AC = gUnknown_203B0AA;
|
||||
gUnknown_203B0AE = -1;
|
||||
gUnknown_203B0B0 = -1;
|
||||
gUnknown_203B0B2 = -1;
|
||||
REG_DISPSTAT = DISPSTAT_VBLANK_INTR | DISPSTAT_VCOUNT_INTR;
|
||||
if (gUnknown_203B099 == 0) {
|
||||
|
||||
if (gUnknown_203B099 == 0)
|
||||
UpdateSound();
|
||||
}
|
||||
|
||||
AckInterrupt(INTR_FLAG_VBLANK);
|
||||
}
|
||||
|
||||
@ -215,44 +200,45 @@ void VCountIntr(void)
|
||||
|
||||
void sub_800BA5C(void)
|
||||
{
|
||||
if(gUnknown_203B09A != 0)
|
||||
{
|
||||
if (gUnknown_203B09A) {
|
||||
gUnknown_203B09C++;
|
||||
xxx_update_bg_sound_input();
|
||||
}
|
||||
gUnknown_203B09A = 1;
|
||||
gUnknown_203B09B = 0;
|
||||
|
||||
gUnknown_203B09A = TRUE;
|
||||
gUnknown_203B09B = FALSE;
|
||||
gUnknown_203B09C = 0;
|
||||
nullsub_25();
|
||||
|
||||
while(REG_VCOUNT > 159){}
|
||||
while (REG_VCOUNT >= 160){}
|
||||
|
||||
gUnknown_203B099 = 1;
|
||||
gUnknown_203B099 = TRUE;
|
||||
VBlankIntrWait();
|
||||
nullsub_18();
|
||||
}
|
||||
|
||||
void xxx_update_bg_sound_input(void)
|
||||
{
|
||||
if(gUnknown_203B09B != 0){
|
||||
if (gUnknown_203B09B)
|
||||
gUnknown_203B09C++;
|
||||
}
|
||||
else {
|
||||
gUnknown_203B09B = 1;
|
||||
gUnknown_203B09A = 0;
|
||||
gUnknown_203B09B = TRUE;
|
||||
gUnknown_203B09A = FALSE;
|
||||
gUnknown_203B09C = 0;
|
||||
UpdateBGControlRegisters();
|
||||
if(gUnknown_203B099 != 0)
|
||||
|
||||
if (gUnknown_203B099)
|
||||
UpdateSound();
|
||||
|
||||
UpdateInput();
|
||||
gUnknown_203B099 = 0;
|
||||
gUnknown_203B099 = FALSE;
|
||||
gUnknown_203B0A4 = gUnknown_203B0A0;
|
||||
}
|
||||
}
|
||||
|
||||
void Timer3Intr(void)
|
||||
{
|
||||
if(gIntrCallbacks[4])
|
||||
if (gIntrCallbacks[4])
|
||||
gIntrCallbacks[4]();
|
||||
AckInterrupt(INTR_FLAG_TIMER3);
|
||||
}
|
||||
@ -274,11 +260,11 @@ void sub_800BB44(void)
|
||||
u16 dispcnt_store;
|
||||
bool8 interrupt_flag;
|
||||
|
||||
while(REG_KEYINPUT != KEYS_MASK){}
|
||||
while (REG_KEYINPUT != KEYS_MASK){}
|
||||
|
||||
interrupt_flag = DisableInterrupts();
|
||||
|
||||
while(REG_VCOUNT < 160){}
|
||||
while (REG_VCOUNT < 160){}
|
||||
|
||||
dispcnt_store = REG_DISPCNT;
|
||||
REG_DISPCNT = DISPCNT_FORCED_BLANK;
|
||||
@ -301,9 +287,9 @@ void sub_800BB44(void)
|
||||
REG_DISPCNT = dispcnt_store;
|
||||
*(vu16 *)BG_PLTT = RGB_BLACK;
|
||||
|
||||
if(interrupt_flag)
|
||||
if (interrupt_flag)
|
||||
EnableInterrupts();
|
||||
while(REG_KEYINPUT != KEYS_MASK){}
|
||||
while (REG_KEYINPUT != KEYS_MASK){}
|
||||
}
|
||||
|
||||
void nullsub_17(void)
|
||||
@ -314,15 +300,13 @@ void UpdateBGControlRegisters(void)
|
||||
{
|
||||
u32 BGCNT_Priority[NUM_BGS];
|
||||
|
||||
if(gUnknown_202D7FE == 1)
|
||||
{
|
||||
if (gUnknown_202D7FE == 1) {
|
||||
BGCNT_Priority[BG0] = BGCNT_PRIORITY(1);
|
||||
BGCNT_Priority[BG1] = BGCNT_PRIORITY(2);
|
||||
BGCNT_Priority[BG2] = BGCNT_PRIORITY(0);
|
||||
BGCNT_Priority[BG3] = BGCNT_PRIORITY(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
BGCNT_Priority[BG0] = BGCNT_PRIORITY(0);
|
||||
BGCNT_Priority[BG1] = BGCNT_PRIORITY(1);
|
||||
BGCNT_Priority[BG2] = BGCNT_PRIORITY(2);
|
||||
@ -340,73 +324,10 @@ void UpdateBGControlRegisters(void)
|
||||
|
||||
REG_BG0CNT = BGCNT_Priority[BG0] | BGCNT_SCREENBASE(12) | BGCNT_CHARBASE(0) | BGCNT_WRAP; // 0x2C00
|
||||
REG_BG1CNT = BGCNT_Priority[BG1] | BGCNT_SCREENBASE(13) | BGCNT_CHARBASE(0) | BGCNT_WRAP; // 0x2D00
|
||||
if(gBG2Control.unk2 == 0x8000)
|
||||
if (gBG2Control.unk2 == 0x8000)
|
||||
REG_BG2CNT = BGCNT_Priority[BG2] | BGCNT_SCREENBASE(14) | BGCNT_CHARBASE(2) | BGCNT_WRAP; // 0x2E08
|
||||
else
|
||||
REG_BG2CNT = BGCNT_Priority[BG2] | BGCNT_SCREENBASE(14) | BGCNT_CHARBASE(0) | BGCNT_WRAP; // 0x2E00
|
||||
REG_BG3CNT = BGCNT_Priority[BG3] | BGCNT_SCREENBASE(15) | BGCNT_CHARBASE(2) | BGCNT_WRAP;
|
||||
REG_BLDCNT = gBldCnt;
|
||||
}
|
||||
|
||||
// Unused?
|
||||
s32 sub_800B720(s16 a0, IntrCallback a1)
|
||||
{
|
||||
s32 r2;
|
||||
struct unkStruct_202D648 *r3;
|
||||
s32 r4;
|
||||
bool8 sp4;
|
||||
s32 spC;
|
||||
bool32 sp10;
|
||||
|
||||
spC = a0;
|
||||
sp4 = DisableInterrupts();
|
||||
|
||||
do {
|
||||
sp10 = FALSE;
|
||||
r4 = 0;
|
||||
r3 = gUnknown_202D608;
|
||||
if (r4 >= gUnknown_203B0AA)
|
||||
continue;
|
||||
if (r3->unk0 == gUnknown_203B0A8) {
|
||||
gUnknown_203B0A8 = (gUnknown_203B0A8 + 1) & 0x7fff;
|
||||
sp10 = TRUE;
|
||||
continue;
|
||||
}
|
||||
label:
|
||||
do {
|
||||
r4++;
|
||||
r3++;
|
||||
if (r4 >= gUnknown_203B0AA)
|
||||
continue;
|
||||
if (r3->unk0 == gUnknown_203B0A8) {
|
||||
gUnknown_203B0A8 = (gUnknown_203B0A8 + 1) & 0x7fff;
|
||||
sp10 = TRUE;
|
||||
}
|
||||
else
|
||||
goto label;
|
||||
} while (0);
|
||||
} while (sp10);
|
||||
|
||||
for (r4 = 0, r3 = gUnknown_202D608; r4 < gUnknown_203B0AA; r4++, r3++) {
|
||||
if (r3->unk2 > spC)
|
||||
break;
|
||||
}
|
||||
|
||||
for (r2 = gUnknown_203B0AA - 1, r3 = &gUnknown_202D608[r2]; r2 >= r4; r2--, r3--) {
|
||||
r3[1] = r3[0];
|
||||
}
|
||||
|
||||
gUnknown_203B0AA++;
|
||||
gUnknown_202D608[r4].unk0 = gUnknown_203B0A8;
|
||||
#ifdef NONMATCHING
|
||||
gUnknown_202D608[r4].unk2 = spC;
|
||||
#else
|
||||
gUnknown_202D608[r4].unk2 = ((u32)spC << 0x10 >> 0x10); // fake and may overflow. Unspecified behavior
|
||||
#endif
|
||||
gUnknown_202D608[r4].unk4 = a1;
|
||||
|
||||
if (sp4)
|
||||
EnableInterrupts();
|
||||
|
||||
return gUnknown_203B0A8;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "code_800B5F0.h"
|
||||
#include "input.h"
|
||||
#include "random.h"
|
||||
|
||||
void sub_800BA5C();
|
||||
void xxx_update_bg_sound_input();
|
||||
|
||||
extern u32 gUnknown_203B0B8;
|
||||
extern u16 gRawKeyInput;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "input.h"
|
||||
#include "config.h"
|
||||
#include "game_options.h"
|
||||
#include "sprite.h"
|
||||
|
||||
void xxx_call_stop_bgm(void);
|
||||
|
||||
@ -47,7 +48,6 @@ extern void sub_8005180(void);
|
||||
extern void sub_80060EC(void);
|
||||
extern void sub_8011860(void);
|
||||
extern void sub_800CB20(void);
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_8004AF0(u8, u32 *r1, u32, u32, u32 *r2, u32);
|
||||
extern u8 sub_80111C4();
|
||||
extern void sub_8010F28();
|
||||
@ -75,7 +75,7 @@ void sub_801169C(void)
|
||||
sub_8009908();
|
||||
xxx_call_update_bg_sound_input();
|
||||
sub_8011860();
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
}
|
||||
|
||||
void sub_8011760(void)
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "code_800558C.h"
|
||||
#include "input.h"
|
||||
#include "game_options.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern void sub_8011860();
|
||||
extern void xxx_draw_string_80144C4();
|
||||
@ -14,7 +15,6 @@ extern void TransferBGPaletteBuffer();
|
||||
extern void xxx_call_update_bg_vram();
|
||||
extern void sub_8009908();
|
||||
extern void xxx_call_update_bg_sound_input();
|
||||
extern void ResetSprites(u8 r0);
|
||||
|
||||
extern struct GameOptions *gGameOptionsRef;
|
||||
|
||||
@ -34,6 +34,6 @@ void sub_8012A18()
|
||||
xxx_call_update_bg_vram();
|
||||
sub_8009908();
|
||||
xxx_call_update_bg_sound_input();
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "menu_input.h"
|
||||
#include "subStruct_203B240.h"
|
||||
#include "kecleon_bros.h"
|
||||
#include "sprite.h"
|
||||
|
||||
// based off of 203B240..
|
||||
struct unkStruct_203B230
|
||||
@ -94,7 +95,6 @@ extern void sub_80141B4(u8 *, u32, u32 *, u32);
|
||||
extern void sub_8014248(const char *, u32, u32, struct MenuItem *, u32, u32, u32, u32, u32);
|
||||
extern void sub_80140B4(struct UnkTextStruct2 *);
|
||||
extern void sub_801B46C(u32);
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_801BC64(void);
|
||||
extern void sub_801BC94(void);
|
||||
extern void sub_801BCCC(void);
|
||||
@ -118,7 +118,7 @@ void sub_801BC24(void);
|
||||
|
||||
u32 sub_801B3C0(struct Item *item)
|
||||
{
|
||||
ResetSprites(1);
|
||||
ResetSprites(TRUE);
|
||||
gUnknown_203B230 = MemoryAlloc(sizeof(struct unkStruct_203B230),8);
|
||||
gUnknown_203B230->item = *item;
|
||||
sub_801317C(&gUnknown_203B230->unk88);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "text2.h"
|
||||
#include "subStruct_203B240.h"
|
||||
#include "menu_input.h"
|
||||
#include "sprite.h"
|
||||
|
||||
struct unkStruct_203B238
|
||||
{
|
||||
@ -143,7 +144,6 @@ extern u8 *gUnknown_80D4970[];
|
||||
extern void sub_8007B7C(s32, s32, s32, s32, s32);
|
||||
extern u32 sub_801CE58(void);
|
||||
extern void sub_801CC38(void);
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_80140B4(struct UnkTextStruct2 *);
|
||||
extern void sub_8008C54(u32);
|
||||
extern void sub_80073B8(u32);
|
||||
@ -619,7 +619,7 @@ bool8 HasNoAvailIQSkills(s16 species)
|
||||
|
||||
u32 sub_801C620(u8 iqSkill)
|
||||
{
|
||||
ResetSprites(1);
|
||||
ResetSprites(TRUE);
|
||||
gUnknown_203B240 = MemoryAlloc(sizeof(struct unkStruct_203B240),8);
|
||||
gUnknown_203B240->chosenIQSkill = iqSkill;
|
||||
sub_801317C(&gUnknown_203B240->unk88);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "code_801EE10.h"
|
||||
#include "menu_input.h"
|
||||
#include "subStruct_203B240.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern struct unkStruct_203B270 *gUnknown_203B270;
|
||||
|
||||
@ -58,7 +59,6 @@ extern void PlayMenuSoundEffect(u32);
|
||||
extern void sub_8008C54(u32);
|
||||
extern void sub_80073B8(u32);
|
||||
extern void sub_80073E0(u32);
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_80140B4(struct UnkTextStruct2 *);
|
||||
extern void sub_801F918(s32);
|
||||
extern void sub_801FA58(void);
|
||||
@ -260,7 +260,7 @@ bool8 sub_801F808(u16 *moveIDs)
|
||||
{
|
||||
s32 index;
|
||||
|
||||
ResetSprites(1);
|
||||
ResetSprites(TRUE);
|
||||
gUnknown_203B278 = MemoryAlloc(sizeof(struct unkStruct_203B278), 8);
|
||||
gUnknown_203B278->unk5C = 0;
|
||||
gUnknown_203B278->unk60 = gUnknown_203B278->unk64;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "cpu.h"
|
||||
|
||||
extern u32 gUnknown_202D800;
|
||||
extern u16 gBldCnt; // used to update Blend Count Reg
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "friend_area_action_menu.h"
|
||||
#include "menu_input.h"
|
||||
#include "kecleon_bros.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern struct unkStruct_203B2BC *gUnknown_203B2BC;
|
||||
|
||||
@ -30,7 +31,6 @@ extern void unk_CopyMoves4To8(struct Move *, struct Move *);
|
||||
extern void sub_801EE10(u32, s16, struct Move *, u32, u32, u32);
|
||||
|
||||
extern void SetFriendAreaActionMenuState(u32);
|
||||
extern void ResetSprites(u8 );
|
||||
extern void sub_802719C();
|
||||
extern void sub_8027274();
|
||||
extern void sub_80277FC();
|
||||
@ -124,7 +124,7 @@ ALIGNED(4) const u8 gUnknown_80DD8D0[] = _(
|
||||
|
||||
u32 sub_8027074(void)
|
||||
{
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
gUnknown_203B2BC = MemoryAlloc(sizeof(struct unkStruct_203B2BC), 8);
|
||||
gUnknown_203B2BC->menuAction1 = 0;
|
||||
gUnknown_203B2BC->menuAction2 = 0;
|
||||
|
136
src/main.c
136
src/main.c
@ -1,66 +1,61 @@
|
||||
#include "global.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
#include "cpu.h"
|
||||
#include "code_800B5F0.h"
|
||||
#include "crt0.h"
|
||||
#include "random.h"
|
||||
#include "file_system.h"
|
||||
#include "flash.h"
|
||||
#include "input.h"
|
||||
#include "main.h"
|
||||
#include "random.h"
|
||||
#include "sprite.h"
|
||||
#include "text1.h"
|
||||
|
||||
extern char ewram_start[];
|
||||
|
||||
typedef void (*IntrCallback)(void);
|
||||
#include "text2.h"
|
||||
|
||||
EWRAM_DATA u8 IntrMain_Buffer[0x120] = {0};
|
||||
EWRAM_DATA IntrCallback gIntrTable[6] = {0};
|
||||
EWRAM_DATA IntrCallback gIntrCallbacks[6] = {0};
|
||||
|
||||
extern char ewram_start[];
|
||||
extern u16 gBldCnt;
|
||||
extern u8 gUnknown_202D7FE;
|
||||
EWRAM_DATA_2 u8 gInterruptsEnabled = {0};
|
||||
extern u16 gUnknown_203B0AC;
|
||||
extern s16 gUnknown_203B0AE;
|
||||
|
||||
|
||||
extern char alt_203B038[];
|
||||
|
||||
extern char gTitlePaletteFile[];
|
||||
extern char gUnknown_203BC04[];
|
||||
|
||||
extern char iwram_start[];
|
||||
|
||||
extern char alt_3001B58[];
|
||||
|
||||
extern char unk_code[];
|
||||
extern char unk_code_ram[];
|
||||
extern char unk_code_ram_end[];
|
||||
|
||||
extern u8 gUnknown_80B9BF1[];
|
||||
extern IntrCallback gInitialIntrTable[6];
|
||||
EWRAM_DATA_2 u8 gInterruptsEnabled = {0};
|
||||
|
||||
extern char gUnknown_8270000[];
|
||||
// data_8270000.s
|
||||
extern const char gUnknown_8270000[];
|
||||
// data_80B9BB8.s
|
||||
extern const u8 gUnknown_80B9BF1[];
|
||||
extern const IntrCallback gInitialIntrTable[6];
|
||||
|
||||
extern char unk_code[];
|
||||
|
||||
extern void sub_800CDA8(int);
|
||||
extern void sub_800B540(void);
|
||||
extern void InitSprites(void);
|
||||
// code_800558C_1.c
|
||||
extern void nullsub_9(void);
|
||||
extern void nullsub_6(void);
|
||||
extern void InitInput(void);
|
||||
extern void InitBGPaletteBuffer(void);
|
||||
extern void sub_80057E8(void);
|
||||
extern void InitFileSystem(void);
|
||||
// code_8009804.c
|
||||
extern void sub_80098A0(void);
|
||||
extern void InitGraphics(void);
|
||||
// code_2.c
|
||||
extern void GameLoop(void);
|
||||
// code_800D090.c
|
||||
extern void Hang(void);
|
||||
extern void VBlank_CB(void);
|
||||
|
||||
extern void nullsub_17(void);
|
||||
extern void InitMusic(void); // music initializer
|
||||
extern void sub_800D6AC(void);
|
||||
extern void sub_800D7D0(void);
|
||||
// music.c
|
||||
extern void InitMusic(void); // music initializer
|
||||
// code_8004AA0.s
|
||||
extern void nullsub_6(void);
|
||||
|
||||
bool8 EnableInterrupts(void);
|
||||
void InitIntrTable(const IntrCallback *interrupt_table);
|
||||
IntrCallback SetInterruptCallback(u32 index, IntrCallback new_callback);
|
||||
|
||||
void sub_800B540(void);
|
||||
|
||||
void AgbMain(void)
|
||||
{
|
||||
@ -77,8 +72,7 @@ void AgbMain(void)
|
||||
if (gUnknown_203BC04 - gTitlePaletteFile > 0)
|
||||
CpuCopy32(gUnknown_8270000, gTitlePaletteFile, gUnknown_203BC04 - gTitlePaletteFile);
|
||||
|
||||
if (alt_203B038 - ewram_start > 0)
|
||||
{
|
||||
if (alt_203B038 - ewram_start > 0) {
|
||||
memset(value, 0, 4);
|
||||
CpuSet(&value, ewram_start, CPU_SET_SRC_FIXED | CPU_SET_32BIT | (((alt_203B038 - ewram_start) / 4) & 0x1FFFFF));
|
||||
}
|
||||
@ -86,8 +80,7 @@ void AgbMain(void)
|
||||
if (unk_code_ram_end - unk_code_ram > 0)
|
||||
CpuCopy32(unk_code, unk_code_ram, unk_code_ram_end - unk_code_ram);
|
||||
|
||||
if (alt_3001B58 - iwram_start > 0)
|
||||
{
|
||||
if (alt_3001B58 - iwram_start > 0) {
|
||||
memset(value, 0, 4);
|
||||
CpuSet(&value, iwram_start, CPU_SET_SRC_FIXED | CPU_SET_32BIT | (((alt_3001B58 - iwram_start) / 4) & 0x1FFFFF));
|
||||
}
|
||||
@ -121,7 +114,7 @@ void AgbMain(void)
|
||||
LoadCharmaps();
|
||||
sub_80098A0();
|
||||
InitGraphics();
|
||||
SetInterruptCallback(1, (IntrCallback)VBlank_CB);
|
||||
SetInterruptCallback(1, VBlank_CB);
|
||||
REG_DISPCNT = DISPCNT_WIN1_ON | DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP; // 32576
|
||||
GameLoop();
|
||||
Hang();
|
||||
@ -130,14 +123,14 @@ void AgbMain(void)
|
||||
void sub_800B540(void)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < 6; i++) {
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
gIntrCallbacks[i] = NULL;
|
||||
}
|
||||
|
||||
nullsub_17();
|
||||
InitMusic(); // initialize music and stop DMAs
|
||||
|
||||
while(REG_VCOUNT < 160){}
|
||||
while (REG_VCOUNT < 160){}
|
||||
|
||||
REG_IE ^= INTR_FLAG_TIMER3 | INTR_FLAG_VBLANK | INTR_FLAG_VCOUNT; // 0x45
|
||||
|
||||
@ -161,64 +154,43 @@ void sub_800B540(void)
|
||||
|
||||
bool8 EnableInterrupts(void)
|
||||
{
|
||||
if(!gInterruptsEnabled)
|
||||
{
|
||||
if (!gInterruptsEnabled)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(REG_IME & 1)
|
||||
{
|
||||
if (REG_IME & 1)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
REG_IME = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
REG_IME = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 DisableInterrupts(void)
|
||||
{
|
||||
if(!gInterruptsEnabled)
|
||||
{
|
||||
if (!gInterruptsEnabled)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!(REG_IME & 1))
|
||||
{
|
||||
if (!(REG_IME & 1))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
REG_IME = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
REG_IME = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_800B650(void)
|
||||
{
|
||||
if(!gInterruptsEnabled)
|
||||
{
|
||||
if (!gInterruptsEnabled)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(REG_IME & 1)
|
||||
{
|
||||
if (REG_IME & 1)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void AckInterrupt(u16 flag)
|
||||
{
|
||||
if(!gInterruptsEnabled)
|
||||
{
|
||||
if (!gInterruptsEnabled)
|
||||
return;
|
||||
}
|
||||
|
||||
REG_IME = 0;
|
||||
INTR_CHECK |= flag;
|
||||
@ -227,8 +199,8 @@ void AckInterrupt(u16 flag)
|
||||
|
||||
void InitIntrTable(const IntrCallback *interrupt_table)
|
||||
{
|
||||
CpuCopy32(interrupt_table, gIntrTable, sizeof(gIntrTable)); // 0x18 = 0x6 * 4 (0x4f00 is 32 bits)
|
||||
CpuCopy32(IntrMain, IntrMain_Buffer, sizeof(IntrMain_Buffer)); // 0x120 = 0x48 * 4 (0x4f00 is 32 bits)
|
||||
CpuCopy32(interrupt_table, gIntrTable, sizeof(gIntrTable)); // 0x18 = 0x6 * 4 (0x4F00 is 32 bits)
|
||||
CpuCopy32(IntrMain, IntrMain_Buffer, sizeof(IntrMain_Buffer)); // 0x120 = 0x48 * 4 (0x4F00 is 32 bits)
|
||||
INTR_VECTOR = IntrMain_Buffer;
|
||||
}
|
||||
|
||||
@ -245,9 +217,9 @@ IntrCallback SetInterruptCallback(u32 index, IntrCallback new_callback)
|
||||
interrupt_var = DisableInterrupts();
|
||||
old_callback = gIntrCallbacks[index];
|
||||
gIntrCallbacks[index] = new_callback;
|
||||
if(interrupt_var){
|
||||
EnableInterrupts();
|
||||
}
|
||||
return old_callback;
|
||||
}
|
||||
|
||||
if (interrupt_var)
|
||||
EnableInterrupts();
|
||||
|
||||
return old_callback;
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "m4a.h"
|
||||
#include "music.h"
|
||||
#include "constants/bg_music.h"
|
||||
#include "m4a.h"
|
||||
#include "main.h"
|
||||
#include "music.h"
|
||||
|
||||
EWRAM_DATA u16 gBGMusicPlayerState = {0};
|
||||
EWRAM_DATA u16 gCurrentBGSong = {0};
|
||||
@ -14,8 +15,6 @@ EWRAM_DATA bool8 gRestartBGM = {0};
|
||||
IWRAM_DATA struct PMDMusicPlayer gBGMusicPlayers[NUM_BG_PLAYERS] = {0};
|
||||
IWRAM_DATA struct PMDMusicPlayer gSEMusicPlayers[NUM_SE_PLAYERS] = {0};
|
||||
|
||||
extern bool8 EnableInterrupts(void);
|
||||
extern bool8 DisableInterrupts(void);
|
||||
void nullsub_21(u16);
|
||||
|
||||
void InitMusic(void)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "dungeon_global_data.h"
|
||||
#include "pokemon.h"
|
||||
#include "code_8094F88.h"
|
||||
#include "sprite.h"
|
||||
|
||||
struct unkSprite
|
||||
{
|
||||
@ -446,7 +447,6 @@ static const u8 fill3[] = "pksdir0";
|
||||
static const u8 fill4[] = "pksdir0";
|
||||
|
||||
extern void sub_8037400(void);
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_8035CF4(struct MenuStruct *,u32, u32);
|
||||
extern void sub_80376CC();
|
||||
extern void sub_8035CC0(struct UnkTextStruct2 *, u32);
|
||||
@ -483,7 +483,7 @@ void sub_8036FDC(s32 param_1)
|
||||
|
||||
ResetUnusedInputStruct();
|
||||
sub_800641C(0,1,1);
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
if (gUnknown_203B35C == NULL) {
|
||||
gUnknown_203B35C = MemoryAlloc(0x504,8);
|
||||
MemoryFill8((u8 *)gUnknown_203B35C,0,0x504);
|
||||
@ -657,7 +657,7 @@ void sub_80373C4(void)
|
||||
xxx_call_update_bg_vram();
|
||||
sub_8009908();
|
||||
xxx_call_update_bg_sound_input();
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
}
|
||||
|
||||
// Unused
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "text1.h"
|
||||
#include "save.h"
|
||||
#include "menu_input.h"
|
||||
#include "sprite.h"
|
||||
|
||||
struct unkSprite
|
||||
{
|
||||
@ -132,7 +133,6 @@ ALIGNED(4) const u8 gUnknown_80E7178[] = _("{CENTER_ALIGN}The data could not be
|
||||
|
||||
ALIGNED(4) static const u8 save_menu_fill0[] = "pksdir0";
|
||||
|
||||
extern void ResetSprites(u32);
|
||||
extern void sub_8038440();
|
||||
extern void sub_8035CF4(struct MenuStruct *, u32, u32);
|
||||
extern void SetMenuItems(struct MenuStruct *, struct UnkTextStruct2 *, u32, const struct UnkTextStruct2 *, const struct MenuItem *, u32, u32, u32);
|
||||
@ -338,7 +338,7 @@ void sub_8038830(void)
|
||||
sprite->unk6 = r2;
|
||||
|
||||
gUnknown_203B364->unk1B0 = r5;
|
||||
ResetSprites(0);
|
||||
ResetSprites(FALSE);
|
||||
}
|
||||
|
||||
void sub_80388C4(void) {
|
||||
|
@ -1,10 +1,8 @@
|
||||
#include "global.h"
|
||||
|
||||
void ResetSprites(bool32);
|
||||
void SetSavingIconCoords(u32);
|
||||
#include "sprite.h"
|
||||
|
||||
void InitSprites(void)
|
||||
{
|
||||
ResetSprites(1);
|
||||
ResetSprites(TRUE);
|
||||
SetSavingIconCoords(0);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "file_system.h"
|
||||
#include "code_800558C.h"
|
||||
#include "code_800B540.h"
|
||||
#include "cpu.h"
|
||||
#include "file_system.h"
|
||||
#include "text1.h"
|
||||
#include "text2.h"
|
||||
|
||||
|
103
src/unused_vblank.c
Normal file
103
src/unused_vblank.c
Normal file
@ -0,0 +1,103 @@
|
||||
#include "global.h"
|
||||
#include "code_800B5F0.h"
|
||||
|
||||
extern struct unkStruct_202D648 gUnknown_202D608[8];
|
||||
extern struct unkStruct_202D648 gUnknown_202D648[8];
|
||||
|
||||
// Unused?
|
||||
s32 sub_800B720(s16 a0, IntrCallback a1)
|
||||
{
|
||||
s32 r2;
|
||||
struct unkStruct_202D648 *r3;
|
||||
s32 r4;
|
||||
bool8 sp4;
|
||||
s32 spC;
|
||||
bool32 sp10;
|
||||
|
||||
spC = a0;
|
||||
sp4 = DisableInterrupts();
|
||||
|
||||
do {
|
||||
sp10 = FALSE;
|
||||
r4 = 0;
|
||||
r3 = gUnknown_202D608;
|
||||
if (r4 >= gUnknown_203B0AA)
|
||||
continue;
|
||||
if (r3->unk0 == gUnknown_203B0A8) {
|
||||
gUnknown_203B0A8 = (gUnknown_203B0A8 + 1) & 0x7fff;
|
||||
sp10 = TRUE;
|
||||
continue;
|
||||
}
|
||||
label:
|
||||
do {
|
||||
r4++;
|
||||
r3++;
|
||||
if (r4 >= gUnknown_203B0AA)
|
||||
continue;
|
||||
if (r3->unk0 == gUnknown_203B0A8) {
|
||||
gUnknown_203B0A8 = (gUnknown_203B0A8 + 1) & 0x7fff;
|
||||
sp10 = TRUE;
|
||||
}
|
||||
else
|
||||
goto label;
|
||||
} while (0);
|
||||
} while (sp10);
|
||||
|
||||
for (r4 = 0, r3 = gUnknown_202D608; r4 < gUnknown_203B0AA; r4++, r3++) {
|
||||
if (r3->unk2 > spC)
|
||||
break;
|
||||
}
|
||||
|
||||
for (r2 = gUnknown_203B0AA - 1, r3 = &gUnknown_202D608[r2]; r2 >= r4; r2--, r3--)
|
||||
r3[1] = r3[0];
|
||||
|
||||
gUnknown_203B0AA++;
|
||||
gUnknown_202D608[r4].unk0 = gUnknown_203B0A8;
|
||||
#ifdef NONMATCHING
|
||||
gUnknown_202D608[r4].unk2 = spC;
|
||||
#else
|
||||
gUnknown_202D608[r4].unk2 = ((u32)spC << 0x10 >> 0x10); // fake and may overflow. Unspecified behavior
|
||||
#endif
|
||||
gUnknown_202D608[r4].unk4 = a1;
|
||||
|
||||
if (sp4)
|
||||
EnableInterrupts();
|
||||
|
||||
return gUnknown_203B0A8;
|
||||
}
|
||||
|
||||
// Unused?
|
||||
void sub_800B850(s16 a0)
|
||||
{
|
||||
s32 r2;
|
||||
struct unkStruct_202D648 *r4;
|
||||
bool8 r5;
|
||||
s32 r6;
|
||||
|
||||
r6 = a0;
|
||||
r5 = DisableInterrupts();
|
||||
|
||||
r2 = 0;
|
||||
r4 = &gUnknown_202D608[r2];
|
||||
r4++; r4--;
|
||||
for (; r2 < gUnknown_203B0AA; r2++, r4++) {
|
||||
if (r4->unk0 != r6)
|
||||
continue;
|
||||
|
||||
gUnknown_203B0AA--;
|
||||
for (; r2 < gUnknown_203B0AA; r2++, r4++)
|
||||
r4[0] = r4[1];
|
||||
|
||||
if (!r5)
|
||||
return;
|
||||
EnableInterrupts();
|
||||
return;
|
||||
}
|
||||
|
||||
if (r5)
|
||||
EnableInterrupts();
|
||||
}
|
||||
|
||||
void UnusedIntrFunc(void)
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue
Block a user