Port over berry fix program

This commit is contained in:
PikalaxALT
2018-12-16 20:17:31 -05:00
parent cc84f66655
commit f91b71d395
47 changed files with 7189 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
.global BerryFixMBHeaderNintendoLogo
BerryFixMBHeaderNintendoLogo:
.space 156
BerryFixMBHeaderGameTitle:
.space 12
.global BerryFixMBHeaderGameCode
BerryFixMBHeaderGameCode:
.space 4
BerryFixMBHeaderMakerCode:
.space 2
BerryFixMBHeaderMagic:
.byte 0
BerryFixMBHeaderMainUnitCode:
.byte 0
BerryFixMBHeaderDeviceType:
.byte 0
BerryFixMBHeaderReserved1:
.space 7
.global BerryFixMBHeaderSoftwareVersion
BerryFixMBHeaderSoftwareVersion:
.byte 0
BerryFixMBHeaderChecksum:
.byte 0
BerryFixMBHeaderReserved2:
.space 2
+119
View File
@@ -0,0 +1,119 @@
.include "asm/macros/asm.inc"
.include "asm/macros/function.inc"
.include "constants/gba_constants.inc"
.set SIO_ERROR, 0x0040
.set SIO_MULTI_BUSY, 0x0080
.set EWRAM_ORIG, 0x02000000
.set gCode, 0x02010000
.set PROG_ORIG, 0x00008000
.syntax unified
.text
arm_func_start _start
_start: @ 0
b _entry
arm_func_end _start
.include "asm/berry_fix_header.inc"
@ C0
.word 0
.global _GPIOPortData
_GPIOPortData: @ C4
.2byte 0
.global _GPIOPortDirection
_GPIOPortDirection: @ C6
.2byte 0
.global _GPIOPortReadEnable
_GPIOPortReadEnable: @ C8
.2byte 0
@ CA
.2byte 0
@ CC
.space 0x34
arm_func_start _entry
_entry: @ 100
b _send
arm_func_end _entry
.space 0x1C
arm_func_start _recv
_recv:
@ Waits until link cable is no longer busy.
@ Returns nz if an error has occurred
@ Otherwise, returns the received short in r1.
@ Preserves r0
_120:
ldrh r1, [r0, 0x8] @ SIOCNT
tst r1, SIO_MULTI_BUSY
beq _120
_12c:
ldrh r1, [r0, 0x8] @ SIOCNT
tst r1, SIO_MULTI_BUSY
bne _12c
ldrh r1, [r0, 0x8] @ SIOCNT
tst r1, SIO_ERROR
bxne lr
ldrh r1, [r0] @ SIOMULTI0
bx lr
arm_func_end _recv
arm_func_start _send
_send: @ 14c
ldr r0, =REG_SIOMULTI0
_150:
bl _recv
bne _150
mov r2, 0
strh r2, [r0, 0xa] @ SIOMLT_SEND
cmp r1, 0
bne _150
mov r2, 0x8000
_16c:
mov r1, 0
_170:
strh r1, [r0, 0xa] @ SIOMLT_SEND
bl _recv
bne _150
cmp r1, r2
bne _16c
lsr r2, 5
cmp r1, 0
bne _170
ldr r3, =BerryFixMBHeaderGameCode
ldrh r2, [r3]
strh r2, [r0, 0xa] @ SIOMLT_SEND
bl _recv
_1a0:
bne _1a0
cmp r1, r2
bne _1a0
ldrh r2, [r3, 0x2]
strh r2, [r0, 0xa] @ SIOMLT_SEND
bl _recv
bne _1a0
cmp r1, r2
bne _1a0
mov r1, 0
strh r1, [r0, 0xa] @ SIOMLT_SEND
ldr r0, =_data_2f0
ldr r1, =gCode
swi 0x11 << 16
ldr lr, =gCode
bx lr
.pool
arm_func_end _send
@ 1f0
.align 2, 0 @ don't pad with nop
+12
View File
@@ -0,0 +1,12 @@
.macro inc x
.set \x, \x + 1
.endm
.macro enum_start x=0
.set __enum__, \x
.endm
.macro enum constant
.equiv \constant, __enum__
inc __enum__
.endm
+29
View File
@@ -0,0 +1,29 @@
.macro arm_func_start name
.align 2, 0
.global \name
.arm
.type \name, %function
.endm
.macro arm_func_end name
.size \name, .-\name
.endm
.macro thumb_func_start name
.align 2, 0
.global \name
.thumb
.thumb_func
.type \name, %function
.endm
.macro non_word_aligned_thumb_func_start name
.global \name
.thumb
.thumb_func
.type \name, %function
.endm
.macro thumb_func_end name
.size \name, .-\name
.endm