mirror of
https://github.com/pret/pokeheartgold.git
synced 2025-02-24 23:33:27 +00:00
system.c, 1
This commit is contained in:
parent
a46fc6f604
commit
747d0d670a
226
asm/game_init.s
226
asm/game_init.s
@ -1,223 +1,11 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "global.inc"
|
||||
|
||||
.rodata
|
||||
|
||||
_020F62A4:
|
||||
.byte 0x00, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x02, 0x00
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x11, 0x00
|
||||
.byte 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
.bss
|
||||
|
||||
gSystem: ; 0x021D110C
|
||||
.space 0x478
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_0201A08C
|
||||
sub_0201A08C: ; 0x0201A08C
|
||||
push {r3, lr}
|
||||
ldr r3, _0201A0B4 ; =OS_IRQTable
|
||||
ldr r1, _0201A0B8 ; =0x00003FF8
|
||||
mov r0, #1
|
||||
ldr r2, [r3, r1]
|
||||
orr r0, r2
|
||||
str r0, [r3, r1]
|
||||
mov r0, #3
|
||||
bl MI_WaitDma
|
||||
ldr r0, _0201A0BC ; =gSystem
|
||||
ldr r0, [r0, #0x1c]
|
||||
bl sub_0201F880
|
||||
ldr r0, _0201A0BC ; =gSystem
|
||||
ldr r1, [r0, #0x30]
|
||||
add r1, r1, #1
|
||||
str r1, [r0, #0x30]
|
||||
pop {r3, pc}
|
||||
nop
|
||||
_0201A0B4: .word OS_IRQTable
|
||||
_0201A0B8: .word 0x00003FF8
|
||||
_0201A0BC: .word gSystem
|
||||
thumb_func_end sub_0201A08C
|
||||
|
||||
thumb_func_start sub_0201A0C0
|
||||
sub_0201A0C0: ; 0x0201A0C0
|
||||
ldr r3, _0201A0D4 ; =OS_IRQTable
|
||||
ldr r1, _0201A0D8 ; =0x00003FF8
|
||||
mov r0, #1
|
||||
ldr r2, [r3, r1]
|
||||
orr r0, r2
|
||||
str r0, [r3, r1]
|
||||
ldr r3, _0201A0DC ; =MI_WaitDma
|
||||
mov r0, #3
|
||||
bx r3
|
||||
nop
|
||||
_0201A0D4: .word OS_IRQTable
|
||||
_0201A0D8: .word 0x00003FF8
|
||||
_0201A0DC: .word MI_WaitDma
|
||||
thumb_func_end sub_0201A0C0
|
||||
|
||||
thumb_func_start sub_0201A0E0
|
||||
sub_0201A0E0: ; 0x0201A0E0
|
||||
push {r3, lr}
|
||||
mov r0, #1
|
||||
bl OS_DisableIrqMask
|
||||
ldr r1, _0201A0F8 ; =sub_0201A0C0
|
||||
mov r0, #1
|
||||
bl OS_SetIrqFunction
|
||||
mov r0, #1
|
||||
bl OS_EnableIrqMask
|
||||
pop {r3, pc}
|
||||
.balign 4, 0
|
||||
_0201A0F8: .word sub_0201A0C0
|
||||
thumb_func_end sub_0201A0E0
|
||||
|
||||
thumb_func_start Main_SetVBlankIntrCB
|
||||
Main_SetVBlankIntrCB: ; 0x0201A0FC
|
||||
ldr r2, _0201A104 ; =gSystem
|
||||
str r0, [r2]
|
||||
str r1, [r2, #4]
|
||||
bx lr
|
||||
.balign 4, 0
|
||||
_0201A104: .word gSystem
|
||||
thumb_func_end Main_SetVBlankIntrCB
|
||||
|
||||
thumb_func_start HBlankInterruptDisable
|
||||
HBlankInterruptDisable: ; 0x0201A108
|
||||
push {r3, lr}
|
||||
mov r0, #0
|
||||
bl HBlankIntrRegsToggle
|
||||
ldr r0, _0201A11C ; =gSystem
|
||||
mov r1, #0
|
||||
str r1, [r0, #8]
|
||||
str r1, [r0, #0xc]
|
||||
pop {r3, pc}
|
||||
nop
|
||||
_0201A11C: .word gSystem
|
||||
thumb_func_end HBlankInterruptDisable
|
||||
|
||||
thumb_func_start Main_SetHBlankIntrCB
|
||||
Main_SetHBlankIntrCB: ; 0x0201A120
|
||||
push {r3, lr}
|
||||
cmp r0, #0
|
||||
bne _0201A138
|
||||
mov r0, #0
|
||||
bl HBlankIntrRegsToggle
|
||||
ldr r0, _0201A154 ; =gSystem
|
||||
mov r1, #0
|
||||
str r1, [r0, #8]
|
||||
str r1, [r0, #0xc]
|
||||
mov r0, #1
|
||||
pop {r3, pc}
|
||||
_0201A138:
|
||||
ldr r2, _0201A154 ; =gSystem
|
||||
ldr r3, [r2, #8]
|
||||
cmp r3, #0
|
||||
bne _0201A14E
|
||||
str r1, [r2, #0xc]
|
||||
str r0, [r2, #8]
|
||||
mov r0, #1
|
||||
bl HBlankIntrRegsToggle
|
||||
mov r0, #1
|
||||
pop {r3, pc}
|
||||
_0201A14E:
|
||||
mov r0, #0
|
||||
pop {r3, pc}
|
||||
nop
|
||||
_0201A154: .word gSystem
|
||||
thumb_func_end Main_SetHBlankIntrCB
|
||||
|
||||
thumb_func_start CallHBlankIntrCallback
|
||||
CallHBlankIntrCallback: ; 0x0201A158
|
||||
push {r3, lr}
|
||||
ldr r0, _0201A168 ; =gSystem
|
||||
ldr r1, [r0, #8]
|
||||
cmp r1, #0
|
||||
beq _0201A166
|
||||
ldr r0, [r0, #0xc]
|
||||
blx r1
|
||||
_0201A166:
|
||||
pop {r3, pc}
|
||||
.balign 4, 0
|
||||
_0201A168: .word gSystem
|
||||
thumb_func_end CallHBlankIntrCallback
|
||||
|
||||
thumb_func_start HBlankIntrRegsToggle
|
||||
HBlankIntrRegsToggle: ; 0x0201A16C
|
||||
push {r3, lr}
|
||||
ldr r2, _0201A1AC ; =0x04000208
|
||||
ldrh r1, [r2]
|
||||
mov r1, #0
|
||||
strh r1, [r2]
|
||||
cmp r0, #0
|
||||
bne _0201A18A
|
||||
ldr r0, [r2, #8]
|
||||
mov r0, #2
|
||||
bl OS_DisableIrqMask
|
||||
mov r0, #0
|
||||
bl GX_HBlankIntr
|
||||
b _0201A1A0
|
||||
_0201A18A:
|
||||
ldr r0, [r2, #8]
|
||||
ldr r1, _0201A1B0 ; =CallHBlankIntrCallback
|
||||
mov r0, #2
|
||||
bl OS_SetIrqFunction
|
||||
mov r0, #2
|
||||
bl OS_EnableIrqMask
|
||||
mov r0, #1
|
||||
bl GX_HBlankIntr
|
||||
_0201A1A0:
|
||||
ldr r1, _0201A1AC ; =0x04000208
|
||||
ldrh r0, [r1]
|
||||
mov r0, #1
|
||||
strh r0, [r1]
|
||||
pop {r3, pc}
|
||||
nop
|
||||
_0201A1AC: .word 0x04000208
|
||||
_0201A1B0: .word CallHBlankIntrCallback
|
||||
thumb_func_end HBlankIntrRegsToggle
|
||||
|
||||
thumb_func_start sub_0201A1B4
|
||||
sub_0201A1B4: ; 0x0201A1B4
|
||||
push {r3, lr}
|
||||
sub sp, #0x30
|
||||
add r0, sp, #0x10
|
||||
bl OS_GetLowEntropyData
|
||||
add r0, sp, #0
|
||||
add r1, sp, #0x10
|
||||
mov r2, #0x20
|
||||
bl MATH_CalcMD5
|
||||
mov r3, #0
|
||||
add r1, r3, #0
|
||||
add r2, sp, #0
|
||||
_0201A1CE:
|
||||
ldrb r0, [r2]
|
||||
add r1, r1, #1
|
||||
add r2, r2, #1
|
||||
add r3, r3, r0
|
||||
cmp r1, #0x10
|
||||
blo _0201A1CE
|
||||
lsl r0, r3, #0x18
|
||||
lsr r3, r0, #0x18
|
||||
mov r0, #3
|
||||
tst r0, r3
|
||||
beq _0201A1EE
|
||||
mov r0, #3
|
||||
_0201A1E6:
|
||||
add r3, r3, #1
|
||||
add r1, r3, #0
|
||||
tst r1, r0
|
||||
bne _0201A1E6
|
||||
_0201A1EE:
|
||||
ldr r0, _0201A1FC ; =_020F62A4
|
||||
mov r1, #4
|
||||
mov r2, #0xa1
|
||||
bl InitHeapSystem
|
||||
add sp, #0x30
|
||||
pop {r3, pc}
|
||||
.balign 4, 0
|
||||
_0201A1FC: .word _020F62A4
|
||||
thumb_func_end sub_0201A1B4
|
||||
.public sub_0201A08C
|
||||
.public CallHBlankIntrCallback
|
||||
.public sub_0201A1B4
|
||||
|
||||
thumb_func_start InitSystemForTheGame
|
||||
InitSystemForTheGame: ; 0x0201A200
|
||||
@ -391,8 +179,8 @@ _0201A39C: .word 0x07000400
|
||||
_0201A3A0: .word 0x05000400
|
||||
thumb_func_end InitGraphicMemory
|
||||
|
||||
thumb_func_start sub_0201A3A4
|
||||
sub_0201A3A4: ; 0x0201A3A4
|
||||
thumb_func_start Sys_AllocAndReadFile
|
||||
Sys_AllocAndReadFile: ; 0x0201A3A4
|
||||
push {r4, r5, r6, lr}
|
||||
sub sp, #0x48
|
||||
add r6, r0, #0
|
||||
@ -432,7 +220,7 @@ _0201A3F2:
|
||||
add r0, r4, #0
|
||||
add sp, #0x48
|
||||
pop {r4, r5, r6, pc}
|
||||
thumb_func_end sub_0201A3A4
|
||||
thumb_func_end Sys_AllocAndReadFile
|
||||
|
||||
thumb_func_start sub_0201A3F8
|
||||
sub_0201A3F8: ; 0x0201A3F8
|
||||
@ -514,7 +302,7 @@ InitKeypadAndTouchpad: ; 0x0201A458
|
||||
ldr r0, _0201A4AC ; =gSystem + 0x60
|
||||
strb r2, [r0, #8]
|
||||
bl TP_Init
|
||||
bl sub_020210A0
|
||||
bl GF_TouchpadInit
|
||||
add r0, sp, #0
|
||||
bl TP_GetUserInfo
|
||||
cmp r0, #1
|
||||
|
@ -9605,7 +9605,7 @@ ov01_021EA3E0: ; 0x021EA3E0
|
||||
str r1, [sp]
|
||||
mov r0, #4
|
||||
add r1, r2, #0
|
||||
bl sub_0201A3A4
|
||||
bl Sys_AllocAndReadFile
|
||||
mov r1, #0
|
||||
str r0, [sp, #0x14]
|
||||
str r1, [sp, #8]
|
||||
|
@ -1592,8 +1592,8 @@ GF_MIC_StopAutoSampling: ; 0x02005550
|
||||
_02005564: .word _021D05E8
|
||||
thumb_func_end GF_MIC_StopAutoSampling
|
||||
|
||||
thumb_func_start sub_02005568
|
||||
sub_02005568: ; 0x02005568
|
||||
thumb_func_start GF_MicPauseOnLidClose
|
||||
GF_MicPauseOnLidClose: ; 0x02005568
|
||||
push {r3, lr}
|
||||
ldr r0, _02005580 ; =_021D05E8
|
||||
ldrb r0, [r0]
|
||||
@ -1607,10 +1607,10 @@ _0200557E:
|
||||
pop {r3, pc}
|
||||
.balign 4, 0
|
||||
_02005580: .word _021D05E8
|
||||
thumb_func_end sub_02005568
|
||||
thumb_func_end GF_MicPauseOnLidClose
|
||||
|
||||
thumb_func_start sub_02005584
|
||||
sub_02005584: ; 0x02005584
|
||||
thumb_func_start GF_MicResumeOnLidOpen
|
||||
GF_MicResumeOnLidOpen: ; 0x02005584
|
||||
push {r3, lr}
|
||||
ldr r0, _020055A4 ; =_021D05E8
|
||||
ldrb r0, [r0]
|
||||
@ -1627,7 +1627,7 @@ _0200559C:
|
||||
nop
|
||||
_020055A4: .word _021D05E8
|
||||
_020055A8: .word _021D05F8
|
||||
thumb_func_end sub_02005584
|
||||
thumb_func_end GF_MicResumeOnLidOpen
|
||||
|
||||
thumb_func_start sub_020055AC
|
||||
sub_020055AC: ; 0x020055AC
|
||||
|
@ -8,8 +8,8 @@ _021D2198:
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_020210A0
|
||||
sub_020210A0: ; 0x020210A0
|
||||
thumb_func_start GF_TouchpadInit
|
||||
GF_TouchpadInit: ; 0x020210A0
|
||||
mov r0, #0
|
||||
ldr r3, _020210B8 ; =_021D2198
|
||||
add r1, r0, #0
|
||||
@ -24,7 +24,7 @@ _020210A8:
|
||||
bx lr
|
||||
nop
|
||||
_020210B8: .word _021D2198
|
||||
thumb_func_end sub_020210A0
|
||||
thumb_func_end GF_TouchpadInit
|
||||
|
||||
thumb_func_start sub_020210BC
|
||||
sub_020210BC: ; 0x020210BC
|
||||
@ -84,7 +84,7 @@ _02021112:
|
||||
pop {r4, r5, r6, pc}
|
||||
_0202111E:
|
||||
add r0, r4, #0
|
||||
bl sub_02021384
|
||||
bl GF_TouchpadStartAutoSampling
|
||||
cmp r0, #1
|
||||
bne _0202113E
|
||||
mov r0, #0
|
||||
@ -141,7 +141,7 @@ _0202117C:
|
||||
mov r0, #0
|
||||
pop {r4, pc}
|
||||
_02021188:
|
||||
bl sub_02021384
|
||||
bl GF_TouchpadStartAutoSampling
|
||||
cmp r0, #1
|
||||
bne _020211A4
|
||||
mov r2, #0
|
||||
@ -201,8 +201,8 @@ _020211F2:
|
||||
bx lr
|
||||
thumb_func_end sub_020211E0
|
||||
|
||||
thumb_func_start sub_020211F4
|
||||
sub_020211F4: ; 0x020211F4
|
||||
thumb_func_start GF_TouchpadStopAutoSampling
|
||||
GF_TouchpadStopAutoSampling: ; 0x020211F4
|
||||
push {r4, r5, r6, lr}
|
||||
ldr r0, _02021234 ; =_021D2198 + 0x40
|
||||
mov r5, #0
|
||||
@ -238,7 +238,7 @@ _0202122E:
|
||||
pop {r4, r5, r6, pc}
|
||||
nop
|
||||
_02021234: .word _021D2198 + 0x40
|
||||
thumb_func_end sub_020211F4
|
||||
thumb_func_end GF_TouchpadStopAutoSampling
|
||||
|
||||
thumb_func_start sub_02021238
|
||||
sub_02021238: ; 0x02021238
|
||||
@ -259,7 +259,7 @@ sub_02021238: ; 0x02021238
|
||||
mov r0, #1
|
||||
pop {r4, pc}
|
||||
_0202125A:
|
||||
bl sub_020211F4
|
||||
bl GF_TouchpadStopAutoSampling
|
||||
add r4, r0, #0
|
||||
cmp r4, #1
|
||||
bne _02021274
|
||||
@ -370,8 +370,8 @@ _02021322:
|
||||
.balign 4, 0
|
||||
thumb_func_end sub_020212EC
|
||||
|
||||
thumb_func_start sub_02021328
|
||||
sub_02021328: ; 0x02021328
|
||||
thumb_func_start GF_TouchpadResumeOnLidOpen
|
||||
GF_TouchpadResumeOnLidOpen: ; 0x02021328
|
||||
push {r3, lr}
|
||||
ldr r0, _02021354 ; =_021D2198 + 0x40
|
||||
ldrh r1, [r0, #0x1a]
|
||||
@ -383,7 +383,7 @@ sub_02021328: ; 0x02021328
|
||||
ldr r0, _02021358 ; =_021D2198
|
||||
ldr r0, [r0, #8]
|
||||
lsr r0, r0, #1
|
||||
bl sub_02021384
|
||||
bl GF_TouchpadStartAutoSampling
|
||||
cmp r0, #1
|
||||
beq _0202134A
|
||||
bl GF_AssertFail
|
||||
@ -396,10 +396,10 @@ _02021350:
|
||||
nop
|
||||
_02021354: .word _021D2198 + 0x40
|
||||
_02021358: .word _021D2198
|
||||
thumb_func_end sub_02021328
|
||||
thumb_func_end GF_TouchpadResumeOnLidOpen
|
||||
|
||||
thumb_func_start sub_0202135C
|
||||
sub_0202135C: ; 0x0202135C
|
||||
thumb_func_start GF_TouchpadPauseOnLidClose
|
||||
GF_TouchpadPauseOnLidClose: ; 0x0202135C
|
||||
push {r3, lr}
|
||||
ldr r0, _02021380 ; =_021D2198 + 0x40
|
||||
ldrh r1, [r0, #0x1a]
|
||||
@ -408,7 +408,7 @@ sub_0202135C: ; 0x0202135C
|
||||
ldrh r0, [r0, #0x18]
|
||||
cmp r0, #0
|
||||
beq _0202137E
|
||||
bl sub_020211F4
|
||||
bl GF_TouchpadStopAutoSampling
|
||||
cmp r0, #1
|
||||
beq _02021378
|
||||
bl GF_AssertFail
|
||||
@ -420,10 +420,10 @@ _0202137E:
|
||||
pop {r3, pc}
|
||||
.balign 4, 0
|
||||
_02021380: .word _021D2198 + 0x40
|
||||
thumb_func_end sub_0202135C
|
||||
thumb_func_end GF_TouchpadPauseOnLidClose
|
||||
|
||||
thumb_func_start sub_02021384
|
||||
sub_02021384: ; 0x02021384
|
||||
thumb_func_start GF_TouchpadStartAutoSampling
|
||||
GF_TouchpadStartAutoSampling: ; 0x02021384
|
||||
push {r3, r4, r5, r6, r7, lr}
|
||||
mov r5, #0
|
||||
lsl r0, r0, #0x10
|
||||
@ -458,7 +458,7 @@ _020213BE:
|
||||
pop {r3, r4, r5, r6, r7, pc}
|
||||
nop
|
||||
_020213C4: .word _021D2198 + 0xC
|
||||
thumb_func_end sub_02021384
|
||||
thumb_func_end GF_TouchpadStartAutoSampling
|
||||
|
||||
thumb_func_start sub_020213C8
|
||||
sub_020213C8: ; 0x020213C8
|
||||
|
@ -2120,7 +2120,7 @@ _020244B8:
|
||||
str r0, [r4, r1]
|
||||
ldr r0, [r5, #8]
|
||||
ldr r1, _02024500 ; =_0210F6E0
|
||||
bl sub_0201A3A4
|
||||
bl Sys_AllocAndReadFile
|
||||
mov r1, #0x46
|
||||
lsl r1, r1, #2
|
||||
str r0, [r4, r1]
|
||||
|
@ -145,7 +145,7 @@ _02025628:
|
||||
_02025638:
|
||||
ldr r0, [sp]
|
||||
add r1, r6, #0
|
||||
bl sub_0201A3A4
|
||||
bl Sys_AllocAndReadFile
|
||||
str r0, [r4, #4]
|
||||
cmp r0, #0
|
||||
bne _0202564A
|
||||
|
12
global.inc
12
global.inc
@ -26200,8 +26200,8 @@
|
||||
.public sub_020054F8
|
||||
.public sub_02005504
|
||||
.public sub_02005518
|
||||
.public sub_02005568
|
||||
.public sub_02005584
|
||||
.public GF_MicPauseOnLidClose
|
||||
.public GF_MicResumeOnLidOpen
|
||||
.public sub_020055AC
|
||||
.public sub_02005600
|
||||
.public sub_02005680
|
||||
@ -26837,7 +26837,7 @@
|
||||
.public sub_0201A0E0
|
||||
.public HBlankInterruptDisable
|
||||
.public Main_SetHBlankIntrCB
|
||||
.public sub_0201A3A4
|
||||
.public Sys_AllocAndReadFile
|
||||
.public sub_0201A3F8
|
||||
.public sub_0201A430
|
||||
.public sub_0201A4B0
|
||||
@ -26955,14 +26955,14 @@
|
||||
.public sub_02020E80
|
||||
.public sub_02020EB0
|
||||
.public sub_02020F4C
|
||||
.public sub_020210A0
|
||||
.public GF_TouchpadInit
|
||||
.public sub_020210BC
|
||||
.public sub_020210D8
|
||||
.public sub_02021148
|
||||
.public sub_02021238
|
||||
.public sub_02021280
|
||||
.public sub_02021328
|
||||
.public sub_0202135C
|
||||
.public GF_TouchpadResumeOnLidOpen
|
||||
.public GF_TouchpadPauseOnLidClose
|
||||
.public sub_020215A0
|
||||
.public sub_020215C0
|
||||
.public sub_0202168C
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define POKEHEARTGOLD_SOUND_02004A44_H
|
||||
|
||||
void sub_02005D00(void);
|
||||
void sub_02005568(void);
|
||||
void sub_02005584(void);
|
||||
void GF_MicPauseOnLidClose(void);
|
||||
void GF_MicResumeOnLidOpen(void);
|
||||
|
||||
#endif //POKEHEARTGOLD_SOUND_02004A44_H
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef POKEHEARTGOLD_SYSTEM_H
|
||||
#define POKEHEARTGOLD_SYSTEM_H
|
||||
|
||||
typedef void (*GFIntrCB)(void *);
|
||||
|
||||
struct System {
|
||||
void (*vBlankIntr)(void *);
|
||||
GFIntrCB vBlankIntr;
|
||||
void * vBlankIntrArg;
|
||||
void (*hBlankIntr)(void *);
|
||||
GFIntrCB hBlankIntr;
|
||||
void * hBlankIntrArg;
|
||||
s32 unk10;
|
||||
s32 unk14;
|
||||
@ -13,7 +15,7 @@ struct System {
|
||||
void * unk20;
|
||||
void * unk24;
|
||||
s32 unk28;
|
||||
u32 unk2C;
|
||||
u32 vblankCounter;
|
||||
s32 unk30;
|
||||
u32 buttonMode;
|
||||
u32 heldKeysRaw;
|
||||
@ -36,10 +38,11 @@ struct System {
|
||||
u8 softResetDisabled;
|
||||
u8 unk69; // nice
|
||||
u8 unk6A;
|
||||
u8 unk6B;
|
||||
u8 lidClosedPauseDisabled;
|
||||
u8 unk6C;
|
||||
int unk70;
|
||||
};
|
||||
u8 filler_74[0x404];
|
||||
}; // size=0x478
|
||||
|
||||
extern struct System gSystem;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef POKEHEARTGOLD_UNK_020210A0_H
|
||||
#define POKEHEARTGOLD_UNK_020210A0_H
|
||||
|
||||
void sub_0202135C(void);
|
||||
void sub_02021328(void);
|
||||
void GF_TouchpadPauseOnLidClose(void);
|
||||
void GF_TouchpadResumeOnLidOpen(void);
|
||||
|
||||
#endif //POKEHEARTGOLD_UNK_020210A0_H
|
||||
|
11
lib/include/nitro/dgt/common.h
Normal file
11
lib/include/nitro/dgt/common.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef NITRO_DGT_COMMON_H_
|
||||
#define NITRO_DGT_COMMON_H_
|
||||
|
||||
#define DGT_HASH1_DIGEST_SIZE (128/8)
|
||||
#define DGT_HASH2_DIGEST_SIZE (160/8)
|
||||
#define DGT_HASH_DIGEST_SIZE_MAX DGT_HASH2_DIGEST_SIZE
|
||||
#define DGT_HASH_BLOCK_SIZE (512/8)
|
||||
|
||||
|
||||
|
||||
#endif //NITRO_DGT_COMMON_H_
|
@ -96,5 +96,6 @@ static inline void GX_SetBGCharOffset(GXBGCharOffset offset) {
|
||||
(offset << REG_GX_DISPCNT_BGCHAROFFSET_SHIFT));
|
||||
}
|
||||
|
||||
s32 GX_HBlankIntr(BOOL enable);
|
||||
|
||||
#endif //NITRO_GX_GX_H_
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include <nitro/hw/ARM7/io_reg.h>
|
||||
#endif
|
||||
|
||||
#define REG_OS_IME_IME_SHIFT 0
|
||||
#define REG_OS_IME_IME_SIZE 1
|
||||
#define REG_OS_IME_IME_MASK 0x0001
|
||||
|
||||
#define REG_INTF_OFFSET (0x180)
|
||||
#define REG_INTF_ADDR (HW_REG_BASE + REG_INTF_OFFSET)
|
||||
#define reg_PXI_INTF (*(REGType16v *)REG_INTF_ADDR)
|
||||
|
@ -2,5 +2,6 @@
|
||||
#define NITRO_MATH_H_
|
||||
|
||||
#include <nitro/math/crc.h>
|
||||
#include <nitro/math/dgt.h>
|
||||
|
||||
#endif //NITRO_MATH_H_
|
||||
|
14
lib/include/nitro/math/dgt.h
Normal file
14
lib/include/nitro/math/dgt.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef NITRO_MATH_DGT_H_
|
||||
#define NITRO_MATH_DGT_H_
|
||||
|
||||
#include <nitro/dgt/common.h>
|
||||
|
||||
#define MATH_MD5_DIGEST_SIZE DGT_HASH1_DIGEST_SIZE
|
||||
#define MATH_SHA1_DIGEST_SIZE DGT_HASH2_DIGEST_SIZE
|
||||
#define MATH_MD5_BLOCK_SIZE DGT_HASH_BLOCK_SIZE
|
||||
#define MATH_SHA1_BLOCK_SIZE DGT_HASH_BLOCK_SIZE
|
||||
|
||||
void MATH_CalcMD5(void *digest, const void *data, u32 dataLength);
|
||||
void MATH_CalcSHA1(void *digest, const void *data, u32 dataLength);
|
||||
|
||||
#endif //NITRO_MATH_DGT_H_
|
@ -17,6 +17,22 @@
|
||||
#include <nitro/os/tick.h>
|
||||
#include <nitro/os/alarm.h>
|
||||
#include <nitro/os/ownerInfo.h>
|
||||
#include <nitro/os/context.h>
|
||||
#include <nitro/os/system.h>
|
||||
#include <nitro/os/systemWork.h>
|
||||
#include <nitro/os/thread.h>
|
||||
#include <nitro/os/mutex.h>
|
||||
#include <nitro/os/interrupt.h>
|
||||
#include <nitro/os/systemCall.h>
|
||||
#include <nitro/os/spinLock.h>
|
||||
#include <nitro/os/printf.h>
|
||||
#include <nitro/os/init.h>
|
||||
#include <nitro/os/exception.h>
|
||||
#include <nitro/os/valarm.h>
|
||||
#include <nitro/os/emulator.h>
|
||||
#include <nitro/os/tick.h>
|
||||
#include <nitro/os/alarm.h>
|
||||
#include <nitro/os/common/entropy.h>
|
||||
|
||||
#ifdef SDK_ARM9
|
||||
#include <nitro/os/cache.h>
|
||||
|
7
lib/include/nitro/os/common/entropy.h
Normal file
7
lib/include/nitro/os/common/entropy.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef NITRO_OS_COMMON_ENTROPY_H_
|
||||
#define NITRO_OS_COMMON_ENTROPY_H_
|
||||
|
||||
#define OS_LOW_ENTROPY_DATA_SIZE 32
|
||||
void OS_GetLowEntropyData(u32 buffer[OS_LOW_ENTROPY_DATA_SIZE / sizeof(u32)]);
|
||||
|
||||
#endif //NITRO_OS_COMMON_ENTROPY_H_
|
@ -4,6 +4,9 @@
|
||||
#include <nitro/os/common/interrupt_shared.h>
|
||||
#include <nitro/hw/consts.h>
|
||||
|
||||
#define OS_IME_DISABLE (0UL << REG_OS_IME_IME_SHIFT)
|
||||
#define OS_IME_ENABLE (1UL << REG_OS_IME_IME_SHIFT)
|
||||
|
||||
#ifdef SDK_ARM7
|
||||
#include <nitro/os/ARM7/interrupt.h>
|
||||
#define OS_IRQ_TABLE_MAX 25
|
||||
@ -44,10 +47,17 @@ static inline void OS_SetIrqCheckFlag(OSIrqMask intr) {
|
||||
*(vu32 *)HW_INTR_CHECK_BUF |= (u32)intr;
|
||||
}
|
||||
|
||||
static inline BOOL OS_EnableIrq(void)
|
||||
{
|
||||
u16 prep = reg_OS_IME;
|
||||
reg_OS_IME = OS_IME_ENABLE;
|
||||
return (BOOL)prep;
|
||||
}
|
||||
|
||||
#ifdef SDK_ARM9
|
||||
static inline BOOL OS_DisableIrq(void) {
|
||||
BOOL ime = reg_OS_IME;
|
||||
reg_OS_IME = 0;
|
||||
reg_OS_IME = OS_IME_DISABLE;
|
||||
return ime;
|
||||
}
|
||||
#else
|
||||
@ -60,6 +70,10 @@ static inline BOOL OS_RestoreIrq(BOOL enable) {
|
||||
return ime;
|
||||
}
|
||||
|
||||
static inline OSIrqMask OS_GetIrqMask(void) {
|
||||
return reg_OS_IE;
|
||||
}
|
||||
|
||||
void OS_InitIrqTable(void);
|
||||
void OS_SetIrqFunction(OSIrqMask intrBit, OSIrqFunction function);
|
||||
void OSi_EnterTimerCallback(u32 timerNo, void (*callback) (void *), void *arg);
|
||||
|
1
main.lsf
1
main.lsf
@ -58,6 +58,7 @@ Static main
|
||||
Object unk_02018380.o
|
||||
Object unk_020183F0.o
|
||||
Object unk_02019014.o
|
||||
Object system.o
|
||||
Object game_init.o
|
||||
Object heap.o
|
||||
Object bg_window.o
|
||||
|
22
src/main.c
22
src/main.c
@ -108,7 +108,7 @@ void NitroMain(void) {
|
||||
sub_0201F880(gSystem.unk24);
|
||||
if (!gSystem.unk30) {
|
||||
OS_WaitIrq(TRUE, OS_IE_VBLANK);
|
||||
gSystem.unk2C++;
|
||||
gSystem.vblankCounter++;
|
||||
}
|
||||
}
|
||||
GF_RTC_UpdateOnFrame();
|
||||
@ -116,7 +116,7 @@ void NitroMain(void) {
|
||||
sub_02026E60();
|
||||
sub_0201F880(gSystem.unk24);
|
||||
OS_WaitIrq(TRUE, OS_IE_VBLANK);
|
||||
gSystem.unk2C++;
|
||||
gSystem.vblankCounter++;
|
||||
gSystem.unk30 = 0;
|
||||
sub_0200B594();
|
||||
sub_0200FB2C();
|
||||
@ -166,7 +166,7 @@ void RegisterMainOverlay(FSOverlayID overlayId, const OVY_MGR_TEMPLATE *template
|
||||
void sub_02000F14(void) {
|
||||
sub_02036144();
|
||||
OS_WaitIrq(TRUE, OS_IE_VBLANK);
|
||||
gSystem.unk2C++;
|
||||
gSystem.vblankCounter++;
|
||||
gSystem.unk30 = 0;
|
||||
if (gSystem.vBlankIntr != NULL) {
|
||||
gSystem.vBlankIntr(gSystem.vBlankIntrArg);
|
||||
@ -279,7 +279,7 @@ void InitializeMainRNG(void) {
|
||||
RTCTime time;
|
||||
u32 seed;
|
||||
GF_RTC_CopyDateTime(&date, &time);
|
||||
seed = date.year + date.month * 0x100 * date.day * 0x10000 + time.hour * 0x10000 + (time.minute + time.second) * 0x1000000 + gSystem.unk2C;
|
||||
seed = date.year + date.month * 0x100 * date.day * 0x10000 + time.hour * 0x10000 + (time.minute + time.second) * 0x1000000 + gSystem.vblankCounter;
|
||||
SetMTRNGSeed(seed);
|
||||
SetLCRNGSeed(seed);
|
||||
}
|
||||
@ -288,9 +288,9 @@ void HandleDSLidAction(void) {
|
||||
PMBackLightSwitch top, bottom;
|
||||
PMWakeUpTrigger trigger;
|
||||
if (PAD_DetectFold()) {
|
||||
if (!gSystem.unk6B) {
|
||||
sub_0202135C();
|
||||
sub_02005568();
|
||||
if (!gSystem.lidClosedPauseDisabled) {
|
||||
GF_TouchpadPauseOnLidClose();
|
||||
GF_MicPauseOnLidClose();
|
||||
if (CTRDG_IsPulledOut() == TRUE) {
|
||||
_02111864 = 1;
|
||||
}
|
||||
@ -308,10 +308,10 @@ void HandleDSLidAction(void) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
sub_02021328();
|
||||
sub_02005584();
|
||||
GF_TouchpadResumeOnLidOpen();
|
||||
GF_MicResumeOnLidOpen();
|
||||
} else {
|
||||
sub_0202135C();
|
||||
GF_TouchpadPauseOnLidClose();
|
||||
PM_GetBackLight(&top, &bottom);
|
||||
if (top == PM_BACKLIGHT_ON) {
|
||||
PM_SetBackLight(PM_LCD_ALL, PM_BACKLIGHT_OFF);
|
||||
@ -319,7 +319,7 @@ void HandleDSLidAction(void) {
|
||||
}
|
||||
} else {
|
||||
PM_GetBackLight(&top, &bottom);
|
||||
sub_02021328();
|
||||
GF_TouchpadResumeOnLidOpen();
|
||||
if (top == PM_BACKLIGHT_OFF) {
|
||||
PM_SetBackLight(PM_LCD_ALL, gBacklightTop);
|
||||
}
|
||||
|
100
src/system.c
Normal file
100
src/system.c
Normal file
@ -0,0 +1,100 @@
|
||||
#include "system.h"
|
||||
#include "unk_0201F79C.h"
|
||||
#include "heap.h"
|
||||
|
||||
struct System gSystem;
|
||||
|
||||
void HBlankIntrRegsToggle(BOOL enable);
|
||||
|
||||
void sub_0201A08C(void) {
|
||||
OS_SetIrqCheckFlag(OS_IE_VBLANK);
|
||||
MI_WaitDma(3);
|
||||
sub_0201F880(gSystem.unk1C);
|
||||
gSystem.unk30++;
|
||||
}
|
||||
|
||||
void sub_0201A0C0(void) {
|
||||
OS_SetIrqCheckFlag(OS_IE_VBLANK);
|
||||
MI_WaitDma(3);
|
||||
}
|
||||
|
||||
void sub_0201A0E0(void) {
|
||||
OS_DisableIrqMask(OS_IE_VBLANK);
|
||||
OS_SetIrqFunction(OS_IE_VBLANK, sub_0201A0C0);
|
||||
OS_EnableIrqMask(OS_IE_VBLANK);
|
||||
}
|
||||
|
||||
void Main_SetVBlankIntrCB(GFIntrCB cb, void *arg) {
|
||||
gSystem.vBlankIntr = cb;
|
||||
gSystem.vBlankIntrArg = arg;
|
||||
}
|
||||
|
||||
void HBlankInterruptDisable(void) {
|
||||
HBlankIntrRegsToggle(FALSE);
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.hBlankIntrArg = NULL;
|
||||
}
|
||||
|
||||
BOOL Main_SetHBlankIntrCB(GFIntrCB cb, void *arg) {
|
||||
if (cb == NULL) {
|
||||
HBlankIntrRegsToggle(FALSE);
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.hBlankIntrArg = NULL;
|
||||
return TRUE;
|
||||
} else if (gSystem.hBlankIntr == NULL) {
|
||||
gSystem.hBlankIntrArg = arg;
|
||||
gSystem.hBlankIntr = cb;
|
||||
HBlankIntrRegsToggle(TRUE);
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void CallHBlankIntrCallback(void) {
|
||||
if (gSystem.hBlankIntr != NULL) {
|
||||
gSystem.hBlankIntr(gSystem.hBlankIntrArg);
|
||||
}
|
||||
}
|
||||
|
||||
void HBlankIntrRegsToggle(BOOL enable) {
|
||||
OS_DisableIrq();
|
||||
if (!enable) {
|
||||
OS_GetIrqMask();
|
||||
OS_DisableIrqMask(OS_IE_HBLANK);
|
||||
GX_HBlankIntr(FALSE);
|
||||
} else {
|
||||
OS_GetIrqMask();
|
||||
OS_SetIrqFunction(OS_IE_HBLANK, CallHBlankIntrCallback);
|
||||
OS_EnableIrqMask(OS_IE_HBLANK);
|
||||
GX_HBlankIntr(TRUE);
|
||||
}
|
||||
OS_EnableIrq();
|
||||
}
|
||||
|
||||
static const struct HeapParam _020F62A4[] = {
|
||||
{0xD200, OS_ARENA_MAIN},
|
||||
{0x23600, OS_ARENA_MAIN},
|
||||
{0x10, OS_ARENA_MAIN},
|
||||
{0x11D000, OS_ARENA_MAIN},
|
||||
};
|
||||
|
||||
void sub_0201A1B4(void) {
|
||||
u32 lowEntropyBuffer[OS_LOW_ENTROPY_DATA_SIZE / sizeof(u32)];
|
||||
u8 digest[MATH_MD5_DIGEST_SIZE];
|
||||
u32 heap_size_pre;
|
||||
u32 i;
|
||||
|
||||
OS_GetLowEntropyData(lowEntropyBuffer);
|
||||
MATH_CalcMD5(digest, lowEntropyBuffer, OS_LOW_ENTROPY_DATA_SIZE);
|
||||
|
||||
heap_size_pre = 0;
|
||||
for (i = 0; i < MATH_MD5_DIGEST_SIZE; i++) {
|
||||
heap_size_pre += digest[i];
|
||||
}
|
||||
heap_size_pre &= 0xFF;
|
||||
while (heap_size_pre & 3) {
|
||||
heap_size_pre++;
|
||||
}
|
||||
InitHeapSystem(_020F62A4, NELEMS(_020F62A4), 161, heap_size_pre);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user