summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/data.asm9
-rw-r--r--macros/farcall.asm47
-rw-r--r--macros/scripts/events.asm61
-rw-r--r--macros/scripts/gfx_anims.asm37
-rw-r--r--macros/scripts/text.asm6
-rw-r--r--macros/wram.asm20
6 files changed, 169 insertions, 11 deletions
diff --git a/macros/data.asm b/macros/data.asm
index eb5b5564..9d8a4406 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -60,3 +60,12 @@ ENDM
dab: MACRO
dwb \1, BANK(\1)
ENDM
+
+sine_table: MACRO
+; \1 samples of sin(x) from x=0 to x<32768 (pi radians)
+x = 0
+REPT \1
+ dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up
+x = x + DIV(32768, \1) ; a circle has 65536 "degrees"
+ENDR
+ENDM
diff --git a/macros/farcall.asm b/macros/farcall.asm
index 93f8f1ac..f3fa07d4 100644
--- a/macros/farcall.asm
+++ b/macros/farcall.asm
@@ -26,23 +26,54 @@ homecall: MACRO
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
- ldh [hLoadedROMBank], a
- ld [MBC1RomBank], a
+ call BankswitchCommon
call \1
pop af
- ldh [hLoadedROMBank], a
- ld [MBC1RomBank], a
+ call BankswitchCommon
+ENDM
+
+homejp: MACRO
+ ldh a, [hLoadedROMBank]
+ push af
+ ld a, BANK(\1)
+ call BankswitchCommon
+ call \1
+ pop af
+ jp BankswitchCommon
ENDM
homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
- ldh [hLoadedROMBank], a
- ld [MBC1RomBank], a
+ call BankswitchCommon
call \1
pop bc
ld a, b
- ldh [hLoadedROMBank], a
- ld [MBC1RomBank], a
+ call BankswitchCommon
+ENDM
+
+homejp_sf: MACRO ; homejp but save flags by popping into bc instead of af
+ ldh a, [hLoadedROMBank]
+ push af
+ ld a, BANK(\1)
+ call BankswitchCommon
+ call \1
+ pop bc
+ ld a, b
+ jp BankswitchCommon
+ENDM
+
+calladb_ModifyPikachuHappiness: MACRO
+ ld hl, ModifyPikachuHappiness
+ ld d, \1
+ ld b, BANK(ModifyPikachuHappiness)
+ call Bankswitch
+ENDM
+
+callabd_ModifyPikachuHappiness: MACRO
+ ld hl, ModifyPikachuHappiness
+ ld b, BANK(ModifyPikachuHappiness)
+ ld d, \1
+ call Bankswitch
ENDM
diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm
index c7fdb484..a5f7113d 100644
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -62,6 +62,16 @@ event_byte = ((\2) / 8)
ENDM
+EventFlagAddressA: MACRO
+event_byte = ((\1) / 8)
+ ld [wEventFlags + event_byte], a
+ENDM
+
+AEventFlagAddress: MACRO
+event_byte = ((\1) / 8)
+ ld a, [wEventFlags + event_byte]
+ENDM
+
;\1 = event index
CheckEventHL: MACRO
event_byte = ((\1) / 8)
@@ -138,6 +148,27 @@ CheckAndResetEventA: MACRO
ENDM
+CheckAndSetEventReuseHL: MACRO
+ IF event_byte != ((\1) / 8)
+event_byte = ((\1) / 8)
+ ld hl, wEventFlags + event_byte
+ ENDC
+
+ bit (\1) % 8, [hl]
+ set (\1) % 8, [hl]
+ENDM
+
+CheckAndResetEventReuseHL: MACRO
+ IF event_byte != ((\1) / 8)
+event_byte = ((\1) / 8)
+ ld hl, wEventFlags + event_byte
+ ENDC
+
+ bit (\1) % 8, [hl]
+ res (\1) % 8, [hl]
+ENDM
+
+
;\1 = event index
SetEvent: MACRO
event_byte = ((\1) / 8)
@@ -438,6 +469,36 @@ CheckEitherEventSet: MACRO
ENDM
+CheckEitherEventSetReuseA: MACRO
+ IF event_byte != ((\1) / 8)
+event_byte = ((\1) / 8)
+ ld a, [wEventFlags + event_byte]
+ ENDC
+ IF ((\1) / 8) == ((\2) / 8)
+ ld a, [wEventFlags + ((\1) / 8)]
+ and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
+ ELSE
+ ; This case doesn't happen in the original ROM.
+ IF ((\1) % 8) == ((\2) % 8)
+ push hl
+ ld a, [wEventFlags + ((\1) / 8)]
+ ld hl, wEventFlags + ((\2) / 8)
+ or [hl]
+ bit ((\1) % 8), a
+ pop hl
+ ELSE
+ push bc
+ ld a, [wEventFlags + ((\1) / 8)]
+ and (1 << ((\1) % 8))
+ ld b, a
+ ld a, [wEventFlags + ((\2) / 8)]
+ and (1 << ((\2) % 8))
+ or b
+ pop bc
+ ENDC
+ ENDC
+ENDM
+
; for handling fixed event bits when events are inserted/removed
;\1 = event index
;\2 = fixed flag bit
diff --git a/macros/scripts/gfx_anims.asm b/macros/scripts/gfx_anims.asm
new file mode 100644
index 00000000..f475ad8d
--- /dev/null
+++ b/macros/scripts/gfx_anims.asm
@@ -0,0 +1,37 @@
+; pic + oam animations
+
+frame: MACRO
+ db \1
+x = \2
+IF _NARG > 2
+REPT _NARG - 2
+x = x | (\3 << 1)
+ shift
+ENDR
+ENDC
+ db x
+ENDM
+
+ const_def -1, -1
+
+ const endanim_command ; $ff
+endanim: MACRO
+ db endanim_command
+ENDM
+
+ const dorestart_command ; $fe
+dorestart: MACRO
+ db dorestart_command
+ENDM
+
+ const dorepeat_command ; $fd
+dorepeat: MACRO
+ db dorepeat_command
+ db \1 ; command offset to jump to
+ENDM
+
+ const delanim_command ; $fc
+delanim: MACRO
+; Removes the object from the screen, as opposed to `endanim` which just stops all motion
+ db delanim_command
+ENDM
diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm
index c446c6c7..38e56b77 100644
--- a/macros/scripts/text.asm
+++ b/macros/scripts/text.asm
@@ -127,9 +127,9 @@ sound_dex_page_added: MACRO
db TX_SOUND_DEX_PAGE_ADDED
ENDM
- const TX_SOUND_CRY_NIDORINA ; $14
-sound_cry_nidorina: MACRO
- db TX_SOUND_CRY_NIDORINA
+ const TX_SOUND_CRY_PIKACHU ; $14
+sound_cry_pikachu: MACRO
+ db TX_SOUND_CRY_PIKACHU
ENDM
const TX_SOUND_CRY_PIDGEOT ; $15
diff --git a/macros/wram.asm b/macros/wram.asm
index 872e7f57..be89dad6 100644
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -113,3 +113,23 @@ map_connection_struct: MACRO
\1ConnectedMapXAlignment:: db
\1ConnectedMapViewPointer:: dw
ENDM
+
+animated_object: MACRO
+\1Index:: db
+\1FramesetID:: db
+\1AnimSeqID:: db
+\1TileID:: db
+\1XCoord:: db
+\1YCoord:: db
+\1XOffset:: db
+\1YOffset:: db
+\1Duration:: db
+\1DurationOffset:: db
+\1FrameIndex:: db
+\1FieldB:: db
+\1FieldC:: db
+\1FieldD:: db
+\1FieldE:: db
+\1FieldF:: db
+\1End::
+ENDM