summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2020-01-07 09:39:57 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2020-01-07 09:39:57 -0500
commitcdc025132e7ec7844587782df736df04b5953d5a (patch)
tree5798c341e7e1f93532afe41571036cfd25a58618
parentccb5c0f324e2b9002a687c9111b2675bc6bd101d (diff)
Use official names for crt0 routines
-rw-r--r--asm/crt0.s73
-rw-r--r--berry_fix/payload/asm/crt0.s8
-rw-r--r--berry_fix/payload/src/main.c4
-rw-r--r--constants/version.inc92
-rw-r--r--src/main.c4
5 files changed, 49 insertions, 132 deletions
diff --git a/asm/crt0.s b/asm/crt0.s
index 609845337..28855d504 100644
--- a/asm/crt0.s
+++ b/asm/crt0.s
@@ -1,4 +1,6 @@
.include "constants/gba_constants.inc"
+ .include "constants/misc_constants.inc"
+ .include "constants/version.inc"
.syntax unified
@@ -8,8 +10,8 @@
.arm
-Start: @ 8000000
- b Init
+_start: @ 8000000
+ b start_vector
.include "asm/rom_header.inc"
@@ -32,8 +34,6 @@ GPIOPortReadEnable: @ 80000C8
@ 80000D0
-@ TODO: figure out what this data is
-
.4byte 0xFFFFFFFF
.4byte 0xFFFFFFFF
.4byte 0xFFFFFFFF
@@ -46,19 +46,21 @@ GPIOPortReadEnable: @ 80000C8
.4byte 0xFFFFFFFF
.4byte 0xFFFFFFFF
.4byte 0xFFFFFFFF
+
+@ 8000100
+ .global CartIdent
+CartIdent:
+ .4byte GAME_VERSION
+ .4byte GAME_LANGUAGE
+.game_name:
.ifdef FIRERED
- .4byte 4
- .4byte 2
.ascii "pokemon red version"
- .space 13
.else
.ifdef LEAFGREEN
- .4byte 5
- .4byte 2
.ascii "pokemon green version"
- .space 11
.endif
.endif
+ .space .game_name+0x20-.
.4byte gMonFrontPicTable
.4byte gMonBackPicTable
.4byte gMonPaletteTable
@@ -118,32 +120,32 @@ GPIOPortReadEnable: @ 80000C8
.arm
.align 2, 0
- .global Init
-Init:
+ .global start_vector
+start_vector:
mov r0, PSR_IRQ_MODE
msr cpsr_cf, r0
ldr sp, sp_irq
mov r0, PSR_SYS_MODE
msr cpsr_cf, r0
- ldr sp, sp_sys
+ ldr sp, sp_usr
ldr r1, =INTR_VECTOR
- adr r0, IntrMain
+ adr r0, intr_main
str r0, [r1]
ldr r1, =AgbMain
mov lr, pc
bx r1
- b Init
+ b start_vector
.align 2, 0
-sp_sys: .word IWRAM_END - 0x1C0
+sp_usr: .word IWRAM_END - 0x1C0
sp_irq: .word IWRAM_END - 0x60
.pool
.arm
.align 2, 0
- .global IntrMain
-IntrMain:
+ .global intr_main
+intr_main:
mov r3, REG_BASE
add r3, r3, 0x200
ldr r2, [r3, OFFSET_REG_IE - 0x200]
@@ -155,50 +157,51 @@ IntrMain:
and r1, r2, r2, lsr 16
mov r12, 0
ands r0, r1, INTR_FLAG_VCOUNT
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
mov r0, 0x1
strh r0, [r3, OFFSET_REG_IME - 0x200]
ands r0, r1, INTR_FLAG_SERIAL
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_TIMER3
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_HBLANK
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_VBLANK
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_TIMER0
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_TIMER1
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_TIMER2
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_DMA0
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_DMA1
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_DMA2
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_DMA3
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_KEYPAD
- bne IntrMain_FoundIntr
+ bne jump_intr
add r12, r12, 0x4
ands r0, r1, INTR_FLAG_GAMEPAK
strbne r0, [r3, OFFSET_REG_SOUNDCNT_X - 0x200]
- bne . @ spin
-IntrMain_FoundIntr:
+loop:
+ bne loop @ spin
+jump_intr:
strh r0, [r3, OFFSET_REG_IF - 0x200]
bic r2, r2, r0
ldr r0, =gRfuState
@@ -218,9 +221,9 @@ IntrMain_FoundIntr:
add r1, r1, r12
ldr r0, [r1]
stmdb sp!, {lr}
- adr lr, IntrMain_RetAddr
+ adr lr, intr_return
bx r0
-IntrMain_RetAddr:
+intr_return:
ldmia sp!, {lr}
mrs r3, cpsr
bic r3, r3, PSR_I_BIT | PSR_F_BIT | PSR_MODE_MASK
diff --git a/berry_fix/payload/asm/crt0.s b/berry_fix/payload/asm/crt0.s
index edbb83328..9a0e75c77 100644
--- a/berry_fix/payload/asm/crt0.s
+++ b/berry_fix/payload/asm/crt0.s
@@ -16,7 +16,7 @@ Init:
msr cpsr_cf, r0
ldr sp, sp_sys
ldr r1, =INTR_VECTOR
- ldr r0, =IntrMain
+ ldr r0, =intr_main
str r0, [r1]
ldr r1, =AgbMain + 1
mov lr, pc
@@ -32,8 +32,8 @@ sp_irq: .word IWRAM_END - 0x60
.arm
.align 2, 0
- .global IntrMain
-IntrMain: @ 0x2010048
+ .global intr_main
+intr_main: @ 0x2010048
mov ip, REG_BASE
add r3, ip, OFFSET_REG_IE
ldr r2, [r3]
@@ -79,4 +79,4 @@ _020100DC:
ldr r0, [r1]
bx r0
.pool
- .size IntrMain, .-IntrMain
+ .size intr_main, .-intr_main
diff --git a/berry_fix/payload/src/main.c b/berry_fix/payload/src/main.c
index 325d3830e..a017e8f69 100644
--- a/berry_fix/payload/src/main.c
+++ b/berry_fix/payload/src/main.c
@@ -17,7 +17,7 @@ u32 gGameVersion;
EWRAM_DATA u8 gSharedMem[0x8000] = {};
-void IntrMain(void);
+void intr_main(void);
void ReadKeys(void);
void dummy_intr_0(void);
void dummy_intr_1(void);
@@ -62,7 +62,7 @@ void AgbMain(void)
{
RegisterRamReset(0x1E);
DmaCopy32(3, gIntrFuncPointers, gIntrTable, sizeof gIntrFuncPointers);
- DmaCopy32(3, IntrMain, gIntrVector, sizeof(gIntrVector));
+ DmaCopy32(3, intr_main, gIntrVector, sizeof(gIntrVector));
INTR_VECTOR = gIntrVector;
REG_IE = INTR_FLAG_VBLANK;
if (*RomHeaderMagic == 0x96 && *(u32 *)RomHeaderGameCode == *(u32 *)gBerryFixGameCode)
diff --git a/constants/version.inc b/constants/version.inc
index c93e439f4..07c3bfa29 100644
--- a/constants/version.inc
+++ b/constants/version.inc
@@ -1,91 +1,5 @@
- .ifdef SAPPHIRE
- .equiv GAME_VERSION, 1
+ .ifdef FIRERED
+ .equiv GAME_VERSION, 4
.else
- .equiv GAME_VERSION, 2
- .endif
-
- .ifdef SAPPHIRE
- .set BGM_EVIL_TEAM, BGM_AQA_0
- .set BGM_GOOD_TEAM, BGM_MGM0
- .else
- .set BGM_EVIL_TEAM, BGM_MGM0
- .set BGM_GOOD_TEAM, BGM_AQA_0
- .endc
-
- .ifdef SAPPHIRE
- .set ITEM_RED_OR_BLUE_ORB, ITEM_BLUE_ORB
- .else
- .set ITEM_RED_OR_BLUE_ORB, ITEM_RED_ORB
- .endif
-
- .ifdef SAPPHIRE
- .set SPECIES_GROUDON_OR_KYOGRE, SPECIES_KYOGRE
- .else
- .set SPECIES_GROUDON_OR_KYOGRE, SPECIES_GROUDON
- .endif
-
- .ifdef SAPPHIRE
- .set SPECIES_LATIAS_OR_LATIOS, SPECIES_LATIOS
- .else
- .set SPECIES_LATIAS_OR_LATIOS, SPECIES_LATIAS
- .endif
-
- .ifdef SAPPHIRE
- .set OPPONENT_PETALBURG_WOODS_GRUNT, OPPONENT_GRUNT_9
- .set OPPONENT_RUSTURF_TUNNEL_GRUNT, OPPONENT_GRUNT_15
- .set OPPONENT_MUSEUM_2F_GRUNT_1, OPPONENT_GRUNT_19
- .set OPPONENT_MUSEUM_2F_GRUNT_2, OPPONENT_GRUNT_20
- .set OPPONENT_514, OPPONENT_HECTOR_1
- .set OPPONENT_MT_CHIMNEY_GRUNT_1, OPPONENT_MATT_2
- .set OPPONENT_MT_CHIMNEY_GRUNT_2, OPPONENT_GRUNT_13
- .set OPPONENT_HIDEOUT_1F_GRUNT, OPPONENT_GRUNT_1
- .set OPPONENT_HIDEOUT_B1F_GRUNT_1, OPPONENT_GRUNT_2
- .set OPPONENT_HIDEOUT_B1F_GRUNT_2, OPPONENT_GRUNT_3
- .set OPPONENT_HIDEOUT_B1F_GRUNT_3, OPPONENT_GRUNT_26
- .set OPPONENT_HIDEOUT_B2F_GRUNT_1, OPPONENT_MATT_1
- .set OPPONENT_HIDEOUT_B2F_GRUNT_2, OPPONENT_GRUNT_4
- .set OPPONENT_HIDEOUT_B2F_GRUNT_3, OPPONENT_GRUNT_27
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_1, OPPONENT_GRUNT_5
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_2, OPPONENT_GRUNT_6
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_3, OPPONENT_SHELLY_2
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_4, OPPONENT_GRUNT_7
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_5, OPPONENT_ARCHIE_2
- .set OPPONENT_MT_CHIMNEY_GRUNT_3, OPPONENT_ARCHIE_3
- .set OPPONENT_MT_PYRE_SUMMIT_GRUNT_1, OPPONENT_GRUNT_22
- .set OPPONENT_MT_PYRE_SUMMIT_GRUNT_2, OPPONENT_GRUNT_23
- .set OPPONENT_MT_PYRE_SUMMIT_GRUNT_3, OPPONENT_GRUNT_24
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_1, OPPONENT_GRUNT_16
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_2, OPPONENT_GRUNT_25
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_3, OPPONENT_GRUNT_17
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_4, OPPONENT_GRUNT_18
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_5, OPPONENT_SHELLY_1
- .else
- .set OPPONENT_PETALBURG_WOODS_GRUNT, OPPONENT_GRUNT_36
- .set OPPONENT_RUSTURF_TUNNEL_GRUNT, OPPONENT_GRUNT_42
- .set OPPONENT_MUSEUM_2F_GRUNT_1, OPPONENT_GRUNT_46
- .set OPPONENT_MUSEUM_2F_GRUNT_2, OPPONENT_GRUNT_47
- .set OPPONENT_514, OPPONENT_HECTOR_2
- .set OPPONENT_MT_CHIMNEY_GRUNT_1, OPPONENT_TABITHA_2
- .set OPPONENT_MT_CHIMNEY_GRUNT_2, OPPONENT_GRUNT_40
- .set OPPONENT_HIDEOUT_1F_GRUNT, OPPONENT_GRUNT_28
- .set OPPONENT_HIDEOUT_B1F_GRUNT_1, OPPONENT_GRUNT_29
- .set OPPONENT_HIDEOUT_B1F_GRUNT_2, OPPONENT_GRUNT_30
- .set OPPONENT_HIDEOUT_B1F_GRUNT_3, OPPONENT_GRUNT_53
- .set OPPONENT_HIDEOUT_B2F_GRUNT_1, OPPONENT_TABITHA_1
- .set OPPONENT_HIDEOUT_B2F_GRUNT_2, OPPONENT_GRUNT_31
- .set OPPONENT_HIDEOUT_B2F_GRUNT_3, OPPONENT_GRUNT_54
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_1, OPPONENT_GRUNT_32
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_2, OPPONENT_GRUNT_33
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_3, OPPONENT_COURTNEY_2
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_4, OPPONENT_GRUNT_34
- .set OPPONENT_SEAFLOOR_CAVERN_GRUNT_5, OPPONENT_MAXIE_2
- .set OPPONENT_MT_CHIMNEY_GRUNT_3, OPPONENT_MAXIE_3
- .set OPPONENT_MT_PYRE_SUMMIT_GRUNT_1, OPPONENT_GRUNT_49
- .set OPPONENT_MT_PYRE_SUMMIT_GRUNT_2, OPPONENT_GRUNT_50
- .set OPPONENT_MT_PYRE_SUMMIT_GRUNT_3, OPPONENT_GRUNT_51
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_1, OPPONENT_GRUNT_43
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_2, OPPONENT_GRUNT_52
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_3, OPPONENT_GRUNT_44
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_4, OPPONENT_GRUNT_45
- .set OPPONENT_WEATHER_INSTITUTE_GRUNT_5, OPPONENT_COURTNEY_1
+ .equiv GAME_VERSION, 5
.endif
diff --git a/src/main.c b/src/main.c
index c96e4cc3a..60f762a62 100644
--- a/src/main.c
+++ b/src/main.c
@@ -36,7 +36,7 @@ extern bool32 sub_80F5118(void);
extern struct SoundInfo gSoundInfo;
extern u32 gFlashMemoryPresent;
-extern u32 IntrMain[];
+extern u32 intr_main[];
extern u8 gHeap[];
extern struct SaveBlock1 gSaveBlock1;
extern struct SaveBlock2 gSaveBlock2;
@@ -313,7 +313,7 @@ void InitIntrHandlers(void)
for (i = 0; i < INTR_COUNT; i++)
gIntrTable[i] = gIntrTableTemplate[i];
- DmaCopy32(3, IntrMain, IntrMain_Buffer, sizeof(IntrMain_Buffer));
+ DmaCopy32(3, intr_main, IntrMain_Buffer, sizeof(IntrMain_Buffer));
INTR_VECTOR = IntrMain_Buffer;