mirror of https://github.com/zeldaret/tmc.git
input.c OK
This commit is contained in:
parent
035d4a150f
commit
d49545317a
|
@ -1,54 +0,0 @@
|
||||||
.include "asm/macros.inc"
|
|
||||||
.include "constants/constants.inc"
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
|
|
||||||
.text
|
|
||||||
|
|
||||||
thumb_func_start ReadKeyInput
|
|
||||||
ReadKeyInput: @ 0x0801D6C0
|
|
||||||
push {lr}
|
|
||||||
ldr r0, _0801D6D4 @ =0x04000130
|
|
||||||
ldrh r0, [r0]
|
|
||||||
ldr r1, _0801D6D8 @ =0x000003FF
|
|
||||||
bics r1, r0
|
|
||||||
ldr r0, _0801D6DC @ =gUnk_03000FF0
|
|
||||||
bl sub_0801D6E0
|
|
||||||
pop {pc}
|
|
||||||
.align 2, 0
|
|
||||||
_0801D6D4: .4byte 0x04000130
|
|
||||||
_0801D6D8: .4byte 0x000003FF
|
|
||||||
_0801D6DC: .4byte gUnk_03000FF0
|
|
||||||
|
|
||||||
|
|
||||||
thumb_func_start sub_0801D6E0
|
|
||||||
sub_0801D6E0: @ 0x0801D6E0
|
|
||||||
push {lr}
|
|
||||||
adds r2, r0, #0
|
|
||||||
ldrh r0, [r2]
|
|
||||||
adds r3, r1, #0
|
|
||||||
bics r3, r0
|
|
||||||
strh r3, [r2, #2]
|
|
||||||
cmp r1, r0
|
|
||||||
bne _0801D70A
|
|
||||||
ldrb r0, [r2, #7]
|
|
||||||
subs r0, #1
|
|
||||||
strb r0, [r2, #7]
|
|
||||||
lsls r0, r0, #0x18
|
|
||||||
cmp r0, #0
|
|
||||||
bne _0801D704
|
|
||||||
movs r0, #4
|
|
||||||
strb r0, [r2, #7]
|
|
||||||
strh r1, [r2, #4]
|
|
||||||
b _0801D710
|
|
||||||
_0801D704:
|
|
||||||
movs r0, #0
|
|
||||||
strh r0, [r2, #4]
|
|
||||||
b _0801D710
|
|
||||||
_0801D70A:
|
|
||||||
movs r0, #0x14
|
|
||||||
strb r0, [r2, #7]
|
|
||||||
strh r3, [r2, #4]
|
|
||||||
_0801D710:
|
|
||||||
strh r1, [r2]
|
|
||||||
pop {pc}
|
|
|
@ -319,7 +319,7 @@ SECTIONS {
|
||||||
src/_dmaFill32.o(.text);
|
src/_dmaFill32.o(.text);
|
||||||
asm/sub_0801D630.o(.text);
|
asm/sub_0801D630.o(.text);
|
||||||
asm/sub_0801D66C.o(.text);
|
asm/sub_0801D66C.o(.text);
|
||||||
asm/readKeyInput.o(.text);
|
src/input.o(.text);
|
||||||
asm/code_0801D714.o(.text);
|
asm/code_0801D714.o(.text);
|
||||||
asm/code_0801D79C.o(.text);
|
asm/code_0801D79C.o(.text);
|
||||||
/* enemies */
|
/* enemies */
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "global.h"
|
||||||
|
#include "entity.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u16 field_0x0;
|
||||||
|
u16 field_0x2;
|
||||||
|
u16 field_0x4;
|
||||||
|
u8 field_0x6;
|
||||||
|
u8 field_0x7;
|
||||||
|
} Input;
|
||||||
|
|
||||||
|
void StoreKeyInput(Input *pkeyInput, u32 ioKeyInput);
|
||||||
|
|
||||||
|
extern Input gUnk_03000FF0;
|
||||||
|
|
||||||
|
void ReadKeyInput(void)
|
||||||
|
{
|
||||||
|
u32 reg = ~*(u16*)0x04000130 & 0x3FF;
|
||||||
|
Input* input = &gUnk_03000FF0;
|
||||||
|
StoreKeyInput(input, reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StoreKeyInput(Input *input, u32 ioKeyInput)
|
||||||
|
{
|
||||||
|
u32 difference;
|
||||||
|
u32 temp = input->field_0x0;
|
||||||
|
|
||||||
|
difference = ioKeyInput & ~temp;
|
||||||
|
input->field_0x2 = difference;
|
||||||
|
if (ioKeyInput == temp) {
|
||||||
|
if (--input->field_0x7 == 0) {
|
||||||
|
input->field_0x7 = 4;
|
||||||
|
input->field_0x4 = ioKeyInput;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
input->field_0x4 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
input->field_0x7 = 0x14;
|
||||||
|
input->field_0x4 = difference;
|
||||||
|
}
|
||||||
|
input->field_0x0 = ioKeyInput;
|
||||||
|
}
|
Loading…
Reference in New Issue