mirror of
https://github.com/pret/pokeheartgold.git
synced 2026-04-25 15:41:42 -05:00
system.c, 3
This commit is contained in:
parent
e67aa5e302
commit
fd153bb18e
491
asm/game_init.s
491
asm/game_init.s
|
|
@ -1,491 +0,0 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "global.inc"
|
||||
|
||||
.text
|
||||
|
||||
.public sub_0201A08C
|
||||
.public CallHBlankIntrCallback
|
||||
.public sub_0201A1B4
|
||||
|
||||
thumb_func_start InitKeypadAndTouchpad
|
||||
InitKeypadAndTouchpad: ; 0x0201A458
|
||||
push {r3, lr}
|
||||
sub sp, #8
|
||||
ldr r0, _0201A4A4 ; =gSystem
|
||||
mov r2, #0
|
||||
str r2, [r0, #0x34]
|
||||
str r2, [r0, #0x38]
|
||||
str r2, [r0, #0x3c]
|
||||
str r2, [r0, #0x40]
|
||||
str r2, [r0, #0x44]
|
||||
str r2, [r0, #0x48]
|
||||
str r2, [r0, #0x4c]
|
||||
str r2, [r0, #0x50]
|
||||
mov r1, #4
|
||||
str r1, [r0, #0x54]
|
||||
mov r1, #8
|
||||
str r1, [r0, #0x58]
|
||||
ldr r0, _0201A4A8 ; =gSystem + 0x40
|
||||
strh r2, [r0, #0x20]
|
||||
strh r2, [r0, #0x22]
|
||||
strh r2, [r0, #0x24]
|
||||
strh r2, [r0, #0x26]
|
||||
ldr r0, _0201A4AC ; =gSystem + 0x60
|
||||
strb r2, [r0, #8]
|
||||
bl TP_Init
|
||||
bl GF_TouchpadInit
|
||||
add r0, sp, #0
|
||||
bl TP_GetUserInfo
|
||||
cmp r0, #1
|
||||
bne _0201A49E
|
||||
add r0, sp, #0
|
||||
bl TP_SetCalibrateParam
|
||||
_0201A49E:
|
||||
add sp, #8
|
||||
pop {r3, pc}
|
||||
nop
|
||||
_0201A4A4: .word gSystem
|
||||
_0201A4A8: .word gSystem + 0x40
|
||||
_0201A4AC: .word gSystem + 0x60
|
||||
thumb_func_end InitKeypadAndTouchpad
|
||||
|
||||
thumb_func_start sub_0201A4B0
|
||||
sub_0201A4B0: ; 0x0201A4B0
|
||||
ldr r1, _0201A4B8 ; =gSystem + 0x60
|
||||
strb r0, [r1, #0xa]
|
||||
bx lr
|
||||
nop
|
||||
_0201A4B8: .word gSystem + 0x60
|
||||
thumb_func_end sub_0201A4B0
|
||||
|
||||
thumb_func_start sub_0201A4BC
|
||||
sub_0201A4BC: ; 0x0201A4BC
|
||||
ldr r1, _0201A4C8 ; =gSystem + 0x60
|
||||
ldrb r2, [r1, #0xb]
|
||||
orr r0, r2
|
||||
strb r0, [r1, #0xb]
|
||||
bx lr
|
||||
nop
|
||||
_0201A4C8: .word gSystem + 0x60
|
||||
thumb_func_end sub_0201A4BC
|
||||
|
||||
thumb_func_start sub_0201A4CC
|
||||
sub_0201A4CC: ; 0x0201A4CC
|
||||
ldr r1, _0201A4D8 ; =gSystem + 0x60
|
||||
mvn r0, r0
|
||||
ldrb r2, [r1, #0xb]
|
||||
and r0, r2
|
||||
strb r0, [r1, #0xb]
|
||||
bx lr
|
||||
.balign 4, 0
|
||||
_0201A4D8: .word gSystem + 0x60
|
||||
thumb_func_end sub_0201A4CC
|
||||
|
||||
thumb_func_start ReadKeypadAndTouchpad
|
||||
ReadKeypadAndTouchpad: ; 0x0201A4DC
|
||||
push {r4, lr}
|
||||
sub sp, #0x10
|
||||
ldr r2, _0201A5D0 ; =0x027FFFA8
|
||||
mov r0, #2
|
||||
ldrh r1, [r2]
|
||||
lsl r0, r0, #0xe
|
||||
and r0, r1
|
||||
asr r0, r0, #0xf
|
||||
beq _0201A502
|
||||
ldr r0, _0201A5D4 ; =gSystem
|
||||
mov r1, #0
|
||||
str r1, [r0, #0x48]
|
||||
str r1, [r0, #0x44]
|
||||
str r1, [r0, #0x4c]
|
||||
ldr r0, _0201A5D8 ; =gSystem + 0x40
|
||||
add sp, #0x10
|
||||
strh r1, [r0, #0x24]
|
||||
strh r1, [r0, #0x26]
|
||||
pop {r4, pc}
|
||||
_0201A502:
|
||||
ldr r0, _0201A5DC ; =0x04000130
|
||||
ldrh r1, [r0]
|
||||
ldrh r0, [r2]
|
||||
orr r1, r0
|
||||
ldr r0, _0201A5E0 ; =0x00002FFF
|
||||
eor r1, r0
|
||||
and r0, r1
|
||||
lsl r0, r0, #0x10
|
||||
ldr r1, _0201A5D4 ; =gSystem
|
||||
lsr r2, r0, #0x10
|
||||
ldr r0, [r1, #0x5c]
|
||||
orr r0, r2
|
||||
mov r2, #0
|
||||
str r2, [r1, #0x5c]
|
||||
ldr r2, [r1, #0x38]
|
||||
add r3, r0, #0
|
||||
eor r3, r2
|
||||
and r3, r0
|
||||
str r3, [r1, #0x3c]
|
||||
str r3, [r1, #0x40]
|
||||
cmp r0, #0
|
||||
beq _0201A542
|
||||
cmp r2, r0
|
||||
bne _0201A542
|
||||
ldr r2, [r1, #0x50]
|
||||
sub r2, r2, #1
|
||||
str r2, [r1, #0x50]
|
||||
bne _0201A548
|
||||
str r0, [r1, #0x40]
|
||||
ldr r2, [r1, #0x54]
|
||||
str r2, [r1, #0x50]
|
||||
b _0201A548
|
||||
_0201A542:
|
||||
ldr r1, _0201A5D4 ; =gSystem
|
||||
ldr r2, [r1, #0x58]
|
||||
str r2, [r1, #0x50]
|
||||
_0201A548:
|
||||
ldr r1, _0201A5D4 ; =gSystem
|
||||
str r0, [r1, #0x38]
|
||||
ldr r2, [r1, #0x3c]
|
||||
str r2, [r1, #0x48]
|
||||
str r0, [r1, #0x44]
|
||||
ldr r0, [r1, #0x40]
|
||||
str r0, [r1, #0x4c]
|
||||
bl sub_0201A5E8
|
||||
ldr r0, _0201A5E4 ; =gSystem + 0x60
|
||||
ldrb r0, [r0, #8]
|
||||
cmp r0, #0
|
||||
bne _0201A574
|
||||
add r4, sp, #8
|
||||
_0201A564:
|
||||
bl TP_RequestSamplingAsync
|
||||
add r0, r4, #0
|
||||
bl TP_WaitRawResult
|
||||
cmp r0, #0
|
||||
bne _0201A564
|
||||
b _0201A57A
|
||||
_0201A574:
|
||||
add r0, sp, #8
|
||||
bl TP_GetLatestRawPointInAuto
|
||||
_0201A57A:
|
||||
add r0, sp, #0
|
||||
add r1, sp, #8
|
||||
bl TP_GetCalibratedPoint
|
||||
add r1, sp, #0
|
||||
ldrh r3, [r1, #6]
|
||||
cmp r3, #0
|
||||
bne _0201A596
|
||||
ldrh r2, [r1]
|
||||
ldr r0, _0201A5D8 ; =gSystem + 0x40
|
||||
strh r2, [r0, #0x20]
|
||||
ldrh r1, [r1, #2]
|
||||
strh r1, [r0, #0x22]
|
||||
b _0201A5BA
|
||||
_0201A596:
|
||||
ldr r0, _0201A5D8 ; =gSystem + 0x40
|
||||
ldrh r2, [r0, #0x26]
|
||||
cmp r2, #0
|
||||
beq _0201A5B6
|
||||
cmp r3, #1
|
||||
beq _0201A5AA
|
||||
cmp r3, #2
|
||||
beq _0201A5B0
|
||||
cmp r3, #3
|
||||
b _0201A5BA
|
||||
_0201A5AA:
|
||||
ldrh r1, [r1, #2]
|
||||
strh r1, [r0, #0x22]
|
||||
b _0201A5BA
|
||||
_0201A5B0:
|
||||
ldrh r1, [r1]
|
||||
strh r1, [r0, #0x20]
|
||||
b _0201A5BA
|
||||
_0201A5B6:
|
||||
mov r0, #0
|
||||
strh r0, [r1, #4]
|
||||
_0201A5BA:
|
||||
add r0, sp, #0
|
||||
ldrh r2, [r0, #4]
|
||||
ldr r0, _0201A5D8 ; =gSystem + 0x40
|
||||
ldrh r1, [r0, #0x26]
|
||||
eor r1, r2
|
||||
and r1, r2
|
||||
strh r1, [r0, #0x24]
|
||||
strh r2, [r0, #0x26]
|
||||
add sp, #0x10
|
||||
pop {r4, pc}
|
||||
nop
|
||||
_0201A5D0: .word 0x027FFFA8
|
||||
_0201A5D4: .word gSystem
|
||||
_0201A5D8: .word gSystem + 0x40
|
||||
_0201A5DC: .word 0x04000130
|
||||
_0201A5E0: .word 0x00002FFF
|
||||
_0201A5E4: .word gSystem + 0x60
|
||||
thumb_func_end ReadKeypadAndTouchpad
|
||||
|
||||
thumb_func_start sub_0201A5E8
|
||||
sub_0201A5E8: ; 0x0201A5E8
|
||||
ldr r0, _0201A710 ; =gSystem
|
||||
ldr r1, [r0, #0x34]
|
||||
cmp r1, #3
|
||||
bls _0201A5F2
|
||||
b _0201A70C
|
||||
_0201A5F2:
|
||||
add r1, r1, r1
|
||||
add r1, pc
|
||||
ldrh r1, [r1, #6]
|
||||
lsl r1, r1, #0x10
|
||||
asr r1, r1, #0x10
|
||||
add pc, r1
|
||||
_0201A5FE: ; jump table
|
||||
.short _0201A70C - _0201A5FE - 2 ; case 0
|
||||
.short _0201A606 - _0201A5FE - 2 ; case 1
|
||||
.short _0201A63C - _0201A5FE - 2 ; case 2
|
||||
.short _0201A6C2 - _0201A5FE - 2 ; case 3
|
||||
_0201A606:
|
||||
ldr r2, [r0, #0x48]
|
||||
mov r1, #8
|
||||
add r3, r2, #0
|
||||
tst r3, r1
|
||||
beq _0201A616
|
||||
lsl r1, r1, #7
|
||||
orr r1, r2
|
||||
str r1, [r0, #0x48]
|
||||
_0201A616:
|
||||
ldr r1, _0201A710 ; =gSystem
|
||||
mov r0, #8
|
||||
ldr r2, [r1, #0x44]
|
||||
add r3, r2, #0
|
||||
tst r3, r0
|
||||
beq _0201A628
|
||||
lsl r0, r0, #7
|
||||
orr r0, r2
|
||||
str r0, [r1, #0x44]
|
||||
_0201A628:
|
||||
ldr r1, _0201A710 ; =gSystem
|
||||
mov r0, #8
|
||||
ldr r2, [r1, #0x4c]
|
||||
add r3, r2, #0
|
||||
tst r3, r0
|
||||
beq _0201A70C
|
||||
lsl r0, r0, #7
|
||||
orr r0, r2
|
||||
str r0, [r1, #0x4c]
|
||||
bx lr
|
||||
_0201A63C:
|
||||
ldr r3, [r0, #0x48]
|
||||
mov r0, #1
|
||||
lsl r0, r0, #0xa
|
||||
add r2, r3, #0
|
||||
mov r1, #0
|
||||
tst r2, r0
|
||||
beq _0201A64E
|
||||
lsl r0, r0, #1
|
||||
orr r1, r0
|
||||
_0201A64E:
|
||||
mov r0, #2
|
||||
lsl r0, r0, #0xa
|
||||
add r2, r3, #0
|
||||
tst r2, r0
|
||||
beq _0201A65C
|
||||
lsr r0, r0, #1
|
||||
orr r1, r0
|
||||
_0201A65C:
|
||||
ldr r2, _0201A710 ; =gSystem
|
||||
ldr r0, _0201A714 ; =0x0000F3FF
|
||||
ldr r3, [r2, #0x48]
|
||||
and r0, r3
|
||||
orr r0, r1
|
||||
str r0, [r2, #0x48]
|
||||
ldr r3, [r2, #0x44]
|
||||
mov r1, #1
|
||||
lsl r1, r1, #0xa
|
||||
add r2, r3, #0
|
||||
mov r0, #0
|
||||
tst r2, r1
|
||||
beq _0201A67A
|
||||
lsl r1, r1, #1
|
||||
orr r0, r1
|
||||
_0201A67A:
|
||||
mov r1, #2
|
||||
lsl r1, r1, #0xa
|
||||
add r2, r3, #0
|
||||
tst r2, r1
|
||||
beq _0201A688
|
||||
lsr r1, r1, #1
|
||||
orr r0, r1
|
||||
_0201A688:
|
||||
ldr r2, _0201A710 ; =gSystem
|
||||
ldr r1, _0201A714 ; =0x0000F3FF
|
||||
ldr r3, [r2, #0x44]
|
||||
and r1, r3
|
||||
orr r0, r1
|
||||
str r0, [r2, #0x44]
|
||||
ldr r3, [r2, #0x4c]
|
||||
mov r1, #1
|
||||
lsl r1, r1, #0xa
|
||||
add r2, r3, #0
|
||||
mov r0, #0
|
||||
tst r2, r1
|
||||
beq _0201A6A6
|
||||
lsl r1, r1, #1
|
||||
orr r0, r1
|
||||
_0201A6A6:
|
||||
mov r1, #2
|
||||
lsl r1, r1, #0xa
|
||||
add r2, r3, #0
|
||||
tst r2, r1
|
||||
beq _0201A6B4
|
||||
lsr r1, r1, #1
|
||||
orr r0, r1
|
||||
_0201A6B4:
|
||||
ldr r2, _0201A710 ; =gSystem
|
||||
ldr r1, _0201A714 ; =0x0000F3FF
|
||||
ldr r3, [r2, #0x4c]
|
||||
and r1, r3
|
||||
orr r0, r1
|
||||
str r0, [r2, #0x4c]
|
||||
bx lr
|
||||
_0201A6C2:
|
||||
mov r1, #2
|
||||
ldr r2, [r0, #0x48]
|
||||
lsl r1, r1, #8
|
||||
tst r1, r2
|
||||
beq _0201A6D2
|
||||
mov r1, #1
|
||||
orr r1, r2
|
||||
str r1, [r0, #0x48]
|
||||
_0201A6D2:
|
||||
ldr r1, _0201A710 ; =gSystem
|
||||
mov r0, #2
|
||||
ldr r2, [r1, #0x44]
|
||||
lsl r0, r0, #8
|
||||
tst r0, r2
|
||||
beq _0201A6E4
|
||||
mov r0, #1
|
||||
orr r0, r2
|
||||
str r0, [r1, #0x44]
|
||||
_0201A6E4:
|
||||
ldr r1, _0201A710 ; =gSystem
|
||||
mov r0, #2
|
||||
ldr r2, [r1, #0x4c]
|
||||
lsl r0, r0, #8
|
||||
tst r0, r2
|
||||
beq _0201A6F6
|
||||
mov r0, #1
|
||||
orr r0, r2
|
||||
str r0, [r1, #0x4c]
|
||||
_0201A6F6:
|
||||
ldr r1, _0201A710 ; =gSystem
|
||||
ldr r0, _0201A718 ; =0x0000FCFF
|
||||
ldr r2, [r1, #0x48]
|
||||
and r2, r0
|
||||
str r2, [r1, #0x48]
|
||||
ldr r2, [r1, #0x44]
|
||||
and r2, r0
|
||||
str r2, [r1, #0x44]
|
||||
ldr r2, [r1, #0x4c]
|
||||
and r0, r2
|
||||
str r0, [r1, #0x4c]
|
||||
_0201A70C:
|
||||
bx lr
|
||||
nop
|
||||
_0201A710: .word gSystem
|
||||
_0201A714: .word 0x0000F3FF
|
||||
_0201A718: .word 0x0000FCFF
|
||||
thumb_func_end sub_0201A5E8
|
||||
|
||||
thumb_func_start SetKeyRepeatTimers
|
||||
SetKeyRepeatTimers: ; 0x0201A71C
|
||||
ldr r2, _0201A724 ; =gSystem
|
||||
str r0, [r2, #0x54]
|
||||
str r1, [r2, #0x58]
|
||||
bx lr
|
||||
.balign 4, 0
|
||||
_0201A724: .word gSystem
|
||||
thumb_func_end SetKeyRepeatTimers
|
||||
|
||||
thumb_func_start sub_0201A728
|
||||
sub_0201A728: ; 0x0201A728
|
||||
ldr r1, _0201A734 ; =gSystem + 0x60
|
||||
ldrb r2, [r1, #0xc]
|
||||
orr r0, r2
|
||||
strb r0, [r1, #0xc]
|
||||
bx lr
|
||||
nop
|
||||
_0201A734: .word gSystem + 0x60
|
||||
thumb_func_end sub_0201A728
|
||||
|
||||
thumb_func_start sub_0201A738
|
||||
sub_0201A738: ; 0x0201A738
|
||||
ldr r1, _0201A744 ; =gSystem + 0x60
|
||||
mvn r0, r0
|
||||
ldrb r2, [r1, #0xc]
|
||||
and r0, r2
|
||||
strb r0, [r1, #0xc]
|
||||
bx lr
|
||||
.balign 4, 0
|
||||
_0201A744: .word gSystem + 0x60
|
||||
thumb_func_end sub_0201A738
|
||||
|
||||
thumb_func_start sub_0201A748
|
||||
sub_0201A748: ; 0x0201A748
|
||||
push {r4, lr}
|
||||
add r4, r0, #0
|
||||
ldr r0, _0201A76C ; =gSystem
|
||||
ldr r0, [r0, #0x74]
|
||||
cmp r0, #0
|
||||
beq _0201A758
|
||||
bl GF_AssertFail
|
||||
_0201A758:
|
||||
add r0, r4, #0
|
||||
mov r1, #4
|
||||
bl AllocFromHeapAtEnd
|
||||
ldr r1, _0201A76C ; =gSystem
|
||||
str r0, [r1, #0x74]
|
||||
ldr r1, _0201A770 ; =0x2F93A1BC
|
||||
str r1, [r0]
|
||||
pop {r4, pc}
|
||||
nop
|
||||
_0201A76C: .word gSystem
|
||||
_0201A770: .word 0x2F93A1BC
|
||||
thumb_func_end sub_0201A748
|
||||
|
||||
thumb_func_start sub_0201A774
|
||||
sub_0201A774: ; 0x0201A774
|
||||
push {r3, lr}
|
||||
ldr r0, _0201A798 ; =gSystem
|
||||
ldr r0, [r0, #0x74]
|
||||
cmp r0, #0
|
||||
bne _0201A782
|
||||
bl GF_AssertFail
|
||||
_0201A782:
|
||||
ldr r0, _0201A798 ; =gSystem
|
||||
mov r2, #0
|
||||
ldr r1, [r0, #0x74]
|
||||
str r2, [r1]
|
||||
ldr r0, [r0, #0x74]
|
||||
bl FreeToHeap
|
||||
ldr r0, _0201A798 ; =gSystem
|
||||
mov r1, #0
|
||||
str r1, [r0, #0x74]
|
||||
pop {r3, pc}
|
||||
.balign 4, 0
|
||||
_0201A798: .word gSystem
|
||||
thumb_func_end sub_0201A774
|
||||
|
||||
thumb_func_start sub_0201A79C
|
||||
sub_0201A79C: ; 0x0201A79C
|
||||
ldr r0, _0201A7B4 ; =gSystem
|
||||
ldr r0, [r0, #0x74]
|
||||
cmp r0, #0
|
||||
beq _0201A7B0
|
||||
ldr r1, [r0]
|
||||
ldr r0, _0201A7B8 ; =0x2F93A1BC
|
||||
cmp r1, r0
|
||||
bne _0201A7B0
|
||||
mov r0, #1
|
||||
bx lr
|
||||
_0201A7B0:
|
||||
mov r0, #0
|
||||
bx lr
|
||||
.balign 4, 0
|
||||
_0201A7B4: .word gSystem
|
||||
_0201A7B8: .word 0x2F93A1BC
|
||||
thumb_func_end sub_0201A79C
|
||||
|
|
@ -1,6 +1,13 @@
|
|||
#ifndef POKEHEARTGOLD_SYSTEM_H
|
||||
#define POKEHEARTGOLD_SYSTEM_H
|
||||
|
||||
#include "unk_0201F79C.h"
|
||||
|
||||
#define BUTTONMODE_NORMAL 0
|
||||
#define BUTTONMODE_STARTEQUALSX 1
|
||||
#define BUTTONMODE_SWAPXY 2
|
||||
#define BUTTONMODE_LEQUALSA 3
|
||||
|
||||
typedef void (*GFIntrCB)(void *);
|
||||
|
||||
struct FSCacheEntry {
|
||||
|
|
@ -10,43 +17,41 @@ struct FSCacheEntry {
|
|||
|
||||
struct System {
|
||||
GFIntrCB vBlankIntr;
|
||||
void * vBlankIntrArg;
|
||||
void *vBlankIntrArg;
|
||||
GFIntrCB hBlankIntr;
|
||||
void * hBlankIntrArg;
|
||||
s32 unk10;
|
||||
s32 unk14;
|
||||
void * unk18;
|
||||
void * unk1C;
|
||||
void * unk20;
|
||||
void * unk24;
|
||||
s32 unk28;
|
||||
void *hBlankIntrArg;
|
||||
void (*unk10)(void);
|
||||
void (*unk14)(void);
|
||||
UNK_0201F79C *unk18;
|
||||
UNK_0201F79C *unk1C;
|
||||
UNK_0201F79C *unk20;
|
||||
UNK_0201F79C *unk24;
|
||||
u32 *unk28;
|
||||
u32 vblankCounter;
|
||||
s32 unk30;
|
||||
u32 buttonMode;
|
||||
u32 heldKeysRaw;
|
||||
u32 newKeysRaw;
|
||||
u32 newAndRepeatedKeysRaw;
|
||||
u32 heldKeys;
|
||||
u32 newKeys;
|
||||
u32 newAndRepeatedKeys;
|
||||
s32 keyRepeatCounter;
|
||||
s32 keyRepeatContinueDelay;
|
||||
s32 keyRepeatStartDelay;
|
||||
u32 unk30;
|
||||
int buttonMode;
|
||||
int heldKeysRaw;
|
||||
int newKeysRaw;
|
||||
int newAndRepeatedKeysRaw; // 40
|
||||
int heldKeys;
|
||||
int newKeys;
|
||||
int newAndRepeatedKeys;
|
||||
int keyRepeatCounter; // 50
|
||||
int keyRepeatContinueDelay;
|
||||
int keyRepeatStartDelay;
|
||||
int simulatedInputs;
|
||||
|
||||
u16 touchX;
|
||||
u16 touchY;
|
||||
u16 touchNew;
|
||||
u16 touchHeld;
|
||||
u8 touchpadReadAuto;
|
||||
u8 screensFlipped;
|
||||
u8 unk66;
|
||||
u8 unk67;
|
||||
u8 softResetDisabled;
|
||||
u8 unk69; // nice
|
||||
u8 unk6A;
|
||||
u8 lidClosedPauseDisabled;
|
||||
u8 unk6C;
|
||||
int unk70;
|
||||
int unk74;
|
||||
u8 softResetDisabled;
|
||||
BOOL unk70;
|
||||
u32 *unk74;
|
||||
}; // size=0x478
|
||||
|
||||
extern struct System gSystem;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef POKEHEARTGOLD_UNK_020210A0_H
|
||||
#define POKEHEARTGOLD_UNK_020210A0_H
|
||||
|
||||
void GF_TouchpadInit(void);
|
||||
void GF_TouchpadPauseOnLidClose(void);
|
||||
void GF_TouchpadResumeOnLidOpen(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
#include <nitro/spi/userInfo.h>
|
||||
#include <nitro/spi/common/pm_common.h>
|
||||
#ifdef SDK_ARM9
|
||||
#include <nitro/spi/ARM9/mic.h>
|
||||
#include <nitro/spi/ARM9/pm.h>
|
||||
#include <nitro/spi/ARM9/tp.h>
|
||||
#endif //SDK_ARM9
|
||||
|
||||
#endif //NITRO_SPI_H_
|
||||
|
|
|
|||
39
lib/include/nitro/spi/ARM9/tp.h
Normal file
39
lib/include/nitro/spi/ARM9/tp.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef NITRO_SPI_ARM9_TP_H
|
||||
#define NITRO_SPI_ARM9_TP_H
|
||||
|
||||
#define TP_TOUCH_OFF 0
|
||||
#define TP_TOUCH_ON 1
|
||||
|
||||
#define TP_VALIDITY_VALID 0
|
||||
#define TP_VALIDITY_INVALID_X 1
|
||||
#define TP_VALIDITY_INVALID_Y 2
|
||||
#define TP_VALIDITY_INVALID_XY (TP_VALIDITY_INVALID_X | TP_VALIDITY_INVALID_Y)
|
||||
|
||||
typedef struct {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 touch;
|
||||
u16 validity;
|
||||
} TPData;
|
||||
|
||||
typedef struct NvTpData {
|
||||
s16 x0;
|
||||
s16 y0;
|
||||
s16 xDotSize;
|
||||
s16 yDotSize;
|
||||
} TPCalibrateParam;
|
||||
|
||||
void TP_Init(void);
|
||||
void TP_SetCalibrateParam(const TPCalibrateParam *param);
|
||||
BOOL TP_GetUserInfo(TPCalibrateParam *param);
|
||||
void TP_RequestSamplingAsync(void);
|
||||
u32 TP_WaitRawResult(TPData *result);
|
||||
void TP_GetLatestRawPointInAuto(TPData *result);
|
||||
void TP_GetCalibratedPoint(TPData *calib, const TPData *raw);
|
||||
|
||||
static inline u32 TP_RequestRawSampling(TPData *result) {
|
||||
TP_RequestSamplingAsync();
|
||||
return TP_WaitRawResult(result);
|
||||
}
|
||||
|
||||
#endif //NITRO_SPI_ARM9_TP_H
|
||||
1
main.lsf
1
main.lsf
|
|
@ -59,7 +59,6 @@ Static main
|
|||
Object unk_020183F0.o
|
||||
Object unk_02019014.o
|
||||
Object system.o
|
||||
Object game_init.o
|
||||
Object heap.o
|
||||
Object bg_window.o
|
||||
Object unk_0201F4C4.o
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ void NitroMain(void) {
|
|||
HandleDSLidAction();
|
||||
ReadKeypadAndTouchpad();
|
||||
if ((gSystem.heldKeysRaw & (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R)) == (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R)) {
|
||||
if (!gSystem.unk6C) {
|
||||
if (!gSystem.softResetDisabled) {
|
||||
DoSoftReset(0); // no return
|
||||
}
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ void sub_02000FD8(u32 a0, int a1) {
|
|||
r4 = 0;
|
||||
sp4 = sub_0203993C();
|
||||
r7 = sub_02039998();
|
||||
gSystem.softResetDisabled = FALSE;
|
||||
gSystem.touchpadReadAuto = FALSE;
|
||||
if (a1 == 3) {
|
||||
r5 = 3;
|
||||
} else {
|
||||
|
|
|
|||
190
src/system.c
190
src/system.c
|
|
@ -1,13 +1,14 @@
|
|||
#include "system.h"
|
||||
#include "unk_0201F79C.h"
|
||||
#include "unk_02027010.h"
|
||||
#include "heap.h"
|
||||
#include "math_util.h"
|
||||
#include "unk_020210A0.h"
|
||||
|
||||
struct System gSystem;
|
||||
struct FSCacheEntry gFileCache[128];
|
||||
|
||||
void HBlankIntrRegsToggle(BOOL enable);
|
||||
void sub_0201A5E8(void);
|
||||
|
||||
void sub_0201A08C(void) {
|
||||
OS_SetIrqCheckFlag(OS_IE_VBLANK);
|
||||
|
|
@ -132,11 +133,11 @@ void InitSystemForTheGame(void) {
|
|||
FS_TryLoadTable(fsTable, table_size);
|
||||
gSystem.vBlankIntr = NULL;
|
||||
gSystem.hBlankIntr = NULL;
|
||||
gSystem.unk10 = 0;
|
||||
gSystem.unk14 = 0;
|
||||
gSystem.unk74 = 0;
|
||||
gSystem.unk10 = NULL;
|
||||
gSystem.unk14 = NULL;
|
||||
gSystem.unk74 = NULL;
|
||||
gSystem.vblankCounter = 0;
|
||||
gSystem.unk69 = 0;
|
||||
gSystem.screensFlipped = 0;
|
||||
CARD_SetCacheFlushThreshold(0x500, 0x2400);
|
||||
GF_CRC16Init(0);
|
||||
}
|
||||
|
|
@ -197,3 +198,182 @@ void sub_0201A430(void) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InitKeypadAndTouchpad(void) {
|
||||
TPCalibrateParam tp_calibrate;
|
||||
gSystem.buttonMode = 0;
|
||||
gSystem.heldKeysRaw = 0;
|
||||
gSystem.newKeysRaw = 0;
|
||||
gSystem.newAndRepeatedKeysRaw = 0;
|
||||
gSystem.heldKeys = 0;
|
||||
gSystem.newKeys = 0;
|
||||
gSystem.newAndRepeatedKeys = 0;
|
||||
gSystem.keyRepeatCounter = 0;
|
||||
gSystem.keyRepeatContinueDelay = 4;
|
||||
gSystem.keyRepeatStartDelay = 8;
|
||||
gSystem.touchX = 0;
|
||||
gSystem.touchY = 0;
|
||||
gSystem.touchNew = 0;
|
||||
gSystem.touchHeld = 0;
|
||||
gSystem.touchpadReadAuto = FALSE;
|
||||
TP_Init();
|
||||
GF_TouchpadInit();
|
||||
if (TP_GetUserInfo(&tp_calibrate) == TRUE) {
|
||||
TP_SetCalibrateParam(&tp_calibrate);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0201A4B0(int a0) {
|
||||
gSystem.unk6A = a0;
|
||||
}
|
||||
|
||||
void sub_0201A4BC(int a0) {
|
||||
gSystem.lidClosedPauseDisabled |= a0;
|
||||
}
|
||||
|
||||
void sub_0201A4CC(int a0) {
|
||||
gSystem.lidClosedPauseDisabled &= ~a0;
|
||||
}
|
||||
|
||||
void ReadKeypadAndTouchpad(void) {
|
||||
TPData rawTpData, calibTpData;
|
||||
u32 tpSamplingResult;
|
||||
int raw;
|
||||
if (PAD_DetectFold()) {
|
||||
gSystem.newKeys = 0;
|
||||
gSystem.heldKeys = 0;
|
||||
gSystem.newAndRepeatedKeys = 0;
|
||||
gSystem.touchNew = 0;
|
||||
gSystem.touchHeld = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
raw = PAD_Read() | gSystem.simulatedInputs;
|
||||
gSystem.simulatedInputs = 0;
|
||||
gSystem.newKeysRaw = raw & (raw ^ gSystem.heldKeysRaw);
|
||||
gSystem.newAndRepeatedKeysRaw = raw & (raw ^ gSystem.heldKeysRaw);
|
||||
if (raw != 0 && gSystem.heldKeysRaw == raw) {
|
||||
gSystem.keyRepeatCounter--;
|
||||
if (gSystem.keyRepeatCounter == 0) {
|
||||
gSystem.newAndRepeatedKeysRaw = raw;
|
||||
gSystem.keyRepeatCounter = gSystem.keyRepeatContinueDelay;
|
||||
}
|
||||
} else {
|
||||
gSystem.keyRepeatCounter = gSystem.keyRepeatStartDelay;
|
||||
}
|
||||
gSystem.heldKeysRaw = raw;
|
||||
gSystem.newKeys = gSystem.newKeysRaw;
|
||||
gSystem.heldKeys = gSystem.heldKeysRaw;
|
||||
gSystem.newAndRepeatedKeys = gSystem.newAndRepeatedKeysRaw;
|
||||
sub_0201A5E8();
|
||||
if (!gSystem.touchpadReadAuto) {
|
||||
while (TP_RequestRawSampling(&rawTpData)) {}
|
||||
} else {
|
||||
TP_GetLatestRawPointInAuto(&rawTpData);
|
||||
}
|
||||
TP_GetCalibratedPoint(&calibTpData, &rawTpData);
|
||||
if (calibTpData.validity == TP_VALIDITY_VALID) {
|
||||
gSystem.touchX = calibTpData.x;
|
||||
gSystem.touchY = calibTpData.y;
|
||||
} else {
|
||||
if (gSystem.touchHeld) {
|
||||
switch (calibTpData.validity) {
|
||||
case TP_VALIDITY_INVALID_X:
|
||||
gSystem.touchY = calibTpData.y;
|
||||
break;
|
||||
case TP_VALIDITY_INVALID_Y:
|
||||
gSystem.touchX = calibTpData.x;
|
||||
break;
|
||||
case TP_VALIDITY_INVALID_XY:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
calibTpData.touch = TP_TOUCH_OFF;
|
||||
}
|
||||
}
|
||||
gSystem.touchNew = calibTpData.touch & (calibTpData.touch ^ gSystem.touchHeld);
|
||||
gSystem.touchHeld = calibTpData.touch;
|
||||
}
|
||||
|
||||
#define BUTTON_COPY(adrs, if_pressed, set_these) { \
|
||||
if (adrs & if_pressed) { \
|
||||
adrs |= set_these; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BUTTON_SWAP(adrs, pat1, pat2) { \
|
||||
int tmp = 0; \
|
||||
if (adrs & pat1) { \
|
||||
tmp |= pat2; \
|
||||
} \
|
||||
if (adrs & pat2) { \
|
||||
tmp |= pat1; \
|
||||
} \
|
||||
adrs &= ((pat1 | pat2) ^ 0xFFFF); \
|
||||
adrs |= tmp; \
|
||||
}
|
||||
|
||||
#define BUTTON_HIDE(adrs, pat) { \
|
||||
adrs &= (pat ^ 0xFFFF); \
|
||||
}
|
||||
|
||||
void sub_0201A5E8(void) {
|
||||
switch (gSystem.buttonMode) {
|
||||
case BUTTONMODE_NORMAL:
|
||||
break;
|
||||
case BUTTONMODE_STARTEQUALSX:
|
||||
BUTTON_COPY(gSystem.newKeys, PAD_BUTTON_START, PAD_BUTTON_X);
|
||||
BUTTON_COPY(gSystem.heldKeys, PAD_BUTTON_START, PAD_BUTTON_X);
|
||||
BUTTON_COPY(gSystem.newAndRepeatedKeys, PAD_BUTTON_START, PAD_BUTTON_X);
|
||||
break;
|
||||
case BUTTONMODE_SWAPXY:
|
||||
BUTTON_SWAP(gSystem.newKeys, PAD_BUTTON_X, PAD_BUTTON_Y);
|
||||
BUTTON_SWAP(gSystem.heldKeys, PAD_BUTTON_X, PAD_BUTTON_Y);
|
||||
BUTTON_SWAP(gSystem.newAndRepeatedKeys, PAD_BUTTON_X, PAD_BUTTON_Y);
|
||||
break;
|
||||
case BUTTONMODE_LEQUALSA:
|
||||
BUTTON_COPY(gSystem.newKeys, PAD_BUTTON_L, PAD_BUTTON_A);
|
||||
BUTTON_COPY(gSystem.heldKeys, PAD_BUTTON_L, PAD_BUTTON_A);
|
||||
BUTTON_COPY(gSystem.newAndRepeatedKeys, PAD_BUTTON_L, PAD_BUTTON_A);
|
||||
BUTTON_HIDE(gSystem.newKeys, (PAD_BUTTON_L | PAD_BUTTON_R));
|
||||
BUTTON_HIDE(gSystem.heldKeys, (PAD_BUTTON_L | PAD_BUTTON_R));
|
||||
BUTTON_HIDE(gSystem.newAndRepeatedKeys, (PAD_BUTTON_L | PAD_BUTTON_R));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SetKeyRepeatTimers(int cont, int start) {
|
||||
gSystem.keyRepeatContinueDelay = cont;
|
||||
gSystem.keyRepeatStartDelay = start;
|
||||
}
|
||||
|
||||
void sub_0201A728(int a0) {
|
||||
gSystem.softResetDisabled |= a0;
|
||||
}
|
||||
|
||||
void sub_0201A738(int a0) {
|
||||
gSystem.softResetDisabled &= ~a0;
|
||||
}
|
||||
|
||||
void sub_0201A748(HeapID heapId) {
|
||||
GF_ASSERT(gSystem.unk74 == NULL);
|
||||
gSystem.unk74 = AllocFromHeapAtEnd(heapId, sizeof(u32));
|
||||
*gSystem.unk74 = 0x2F93A1BC;
|
||||
}
|
||||
|
||||
void sub_0201A774(void) {
|
||||
GF_ASSERT(gSystem.unk74 != NULL);
|
||||
*gSystem.unk74 = 0;
|
||||
FreeToHeap(gSystem.unk74);
|
||||
gSystem.unk74 = NULL;
|
||||
}
|
||||
|
||||
BOOL sub_0201A79C(void) {
|
||||
if (gSystem.unk74 != NULL && *gSystem.unk74 == 0x2F93A1BC) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user