-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepoint-cursor-options.asm
executable file
·84 lines (54 loc) · 2.73 KB
/
repoint-cursor-options.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
.definelabel free_space, 0x08800000
NUM_FIELD_MOVE_CURSOR_OPTIONS equ 12
NUM_REGULAR_CURSOR_OPTIONS_OLD equ 18
NUM_ADDITIONAL_REGULAR_CURSOR_OPTIONS equ 1
// -----------------------------------------------------------------------------
.definelabel sCursorOptionsOld, readu32("rom.gba", 0x08120F74 & 0x1FFFFFF)
.if sCursorOptionsOld == free_space
.error "The source and destination of the repointing are the same."
.endif
// -----------------------------------------------------------------------------
NUM_REGULAR_CURSOR_OPTIONS_NEW equ (NUM_REGULAR_CURSOR_OPTIONS_OLD + NUM_ADDITIONAL_REGULAR_CURSOR_OPTIONS)
SIZEOF_CURSOR_OPTION equ 8
MENU_FIELD_MOVES_OLD equ NUM_REGULAR_CURSOR_OPTIONS_OLD
MENU_FIELD_MOVES_NEW equ NUM_REGULAR_CURSOR_OPTIONS_NEW
// -----------------------------------------------------------------------------
.include "macros.s"
.gba
.open "rom.gba", 0x08000000
// -----------------------------------------------------------------------------
// populate the new cursor options table using the contents of the old one
.org free_space
.align 4
sCursorOptionsNew:
incbinm "rom.gba", sCursorOptionsOld, NUM_REGULAR_CURSOR_OPTIONS_OLD * SIZEOF_CURSOR_OPTION
.fill NUM_ADDITIONAL_REGULAR_CURSOR_OPTIONS * SIZEOF_CURSOR_OPTION, 0
incbinm "rom.gba", sCursorOptionsOld + NUM_REGULAR_CURSOR_OPTIONS_OLD * SIZEOF_CURSOR_OPTION, NUM_FIELD_MOVE_CURSOR_OPTIONS * SIZEOF_CURSOR_OPTION
// -----------------------------------------------------------------------------
// delete the old cursor options table
.org sCursorOptionsOld
.fill (NUM_REGULAR_CURSOR_OPTIONS_OLD + NUM_FIELD_MOVE_CURSOR_OPTIONS) * SIZEOF_CURSOR_OPTION, 0xFF
// -----------------------------------------------------------------------------
// update pointers to the old cursor options table
safeupdateptr 0x08120F74, sCursorOptionsOld, sCursorOptionsNew
safeupdateptr 0x08121FB8, sCursorOptionsOld, sCursorOptionsNew
safeupdateptr 0x08122D18, sCursorOptionsOld, sCursorOptionsNew
safeupdateptr 0x08122D48, sCursorOptionsOld, sCursorOptionsNew
// -----------------------------------------------------------------------------
// the assumption of field moves starting at 0x12 is in various places
.org 0x081245BC
sub r0, MENU_FIELD_MOVES_NEW
.org 0x08122146
cmp r5, MENU_FIELD_MOVES_NEW - 1
.org 0x0812219E
sub r0, MENU_FIELD_MOVES_NEW
.org 0x08122A6A
add r2, MENU_FIELD_MOVES_NEW
.org 0x08121F36
cmp r0, MENU_FIELD_MOVES_NEW - 1
// -----------------------------------------------------------------------------
.close
.if sCursorOptionsOld != free_space
.notice "sCursorOptions has been moved from 0x" + tohex(sCursorOptionsOld) + " to 0x" + tohex(sCursorOptionsNew)
.notice "MENU_MOVE_ITEM = 0x" + tohex(NUM_REGULAR_CURSOR_OPTIONS_OLD, 2)
.endif