mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-23 13:09:56 +00:00
99a038284b
This decision was made to reduce the complexity of using .include whilst juggling with tools/scaninc and tools/preproc: - tools/scaninc doesn't apply the proper search rules for .include (it assumes #include behavior). In particular, it doesn't consider paths starting from $PWD, and doesn't scan the included files as a result. - .include had to be processed before #include by preproc in many cases, as code was being included that had to be preprocessed by CPP (think of #define). This contradicts standard GCC behavior. To make include paths consistent across the asm/ data/ and src/ directories, the following files were moved: - constants/ → include/asm/constants/ - asm/macros/ → include/asm/macros/ - asm/macros.inc → include/asm/macros.inc - include/macros/m4a.inc → include/asm/macros/m4a.inc As part of the necessary changes for this to work, the scaninc method in the makefile was improved to generate .d files that don't choke when files are missing.
104 lines
1.9 KiB
ArmAsm
104 lines
1.9 KiB
ArmAsm
#include "asm/constants/gba_constants.inc"
|
|
|
|
.syntax unified
|
|
|
|
.global Start
|
|
|
|
.text
|
|
|
|
.arm
|
|
|
|
Start: @ 8000000
|
|
b Init
|
|
|
|
#include "rom_header.inc"
|
|
|
|
.arm
|
|
.align 2, 0
|
|
.global Init
|
|
Init: @ 80000C0
|
|
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 r1, =INTR_VECTOR
|
|
adr r0, IntrMain
|
|
str r0, [r1]
|
|
ldr r1, =AgbMain
|
|
mov lr, pc
|
|
bx r1
|
|
b Init
|
|
|
|
.align 2, 0
|
|
sp_sys: .word IWRAM_END - 0x100
|
|
sp_irq: .word IWRAM_END - 0x60
|
|
|
|
.pool
|
|
|
|
.arm
|
|
.align 2, 0
|
|
.global IntrMain
|
|
IntrMain: @ 8000104
|
|
mov r3, REG_BASE
|
|
add r3, r3, 0x200
|
|
ldr r2, [r3, OFFSET_REG_IE - 0x200]
|
|
ldrh r1, [r3, OFFSET_REG_IME - 0x200]
|
|
mrs r0, spsr
|
|
stmdb sp!, {r0-r3,lr}
|
|
mov r0, 1
|
|
strh r0, [r3, OFFSET_REG_IME - 0x200]
|
|
and r1, r2, r2, lsr 16
|
|
mov r12, 0
|
|
ands r0, r1, INTR_FLAG_SERIAL | INTR_FLAG_TIMER3
|
|
bne IntrMain_FoundIntr
|
|
add r12, r12, 0x4
|
|
ands r0, r1, INTR_FLAG_VBLANK
|
|
bne IntrMain_FoundIntr
|
|
add r12, r12, 0x4
|
|
ands r0, r1, INTR_FLAG_VCOUNT
|
|
bne IntrMain_FoundIntr
|
|
add r12, r12, 0x4
|
|
ands r0, r1, INTR_FLAG_TIMER2
|
|
bne IntrMain_FoundIntr
|
|
add r12, r12, 0x4
|
|
ands r0, r1, INTR_FLAG_TIMER3
|
|
bne IntrMain_FoundIntr
|
|
add r12, r12, 0x4
|
|
ands r0, r1, INTR_FLAG_GAMEPAK
|
|
strbne r0, [r3, OFFSET_REG_SOUNDCNT_X - 0x200]
|
|
IntrMain_Loop:
|
|
bne IntrMain_Loop
|
|
IntrMain_FoundIntr:
|
|
strh r0, [r3, OFFSET_REG_IF - 0x200]
|
|
mov r1, INTR_FLAG_GAMEPAK | INTR_FLAG_SERIAL
|
|
bic r2, r2, r0
|
|
and r1, r1, r2
|
|
strh r1, [r3, OFFSET_REG_IE - 0x200]
|
|
mrs r3, cpsr
|
|
bic r3, r3, PSR_I_BIT | PSR_F_BIT | PSR_MODE_MASK
|
|
orr r3, r3, PSR_SYS_MODE
|
|
msr cpsr_cf, r3
|
|
ldr r1, =gIntrTable
|
|
add r1, r1, r12
|
|
ldr r0, [r1]
|
|
stmdb sp!, {lr}
|
|
adr lr, IntrMain_RetAddr
|
|
bx r0
|
|
IntrMain_RetAddr:
|
|
ldmia sp!, {lr}
|
|
mrs r3, cpsr
|
|
bic r3, r3, PSR_I_BIT | PSR_F_BIT | PSR_MODE_MASK
|
|
orr r3, r3, PSR_I_BIT | PSR_IRQ_MODE
|
|
msr cpsr_cf, r3
|
|
ldmia sp!, {r0-r3,lr}
|
|
strh r2, [r3, OFFSET_REG_IE - 0x200]
|
|
strh r1, [r3, OFFSET_REG_IME - 0x200]
|
|
msr spsr_cf, r0
|
|
bx lr
|
|
|
|
.pool
|
|
|
|
.align 2, 0 @ Don't pad with nop.
|