diff --git a/README.md b/README.md index 7ccb089..e95f00f 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ This patch is mostly compatible with vanilla saves. The bag expansion patch **wi - Colored stat values based on nature - Repeated item usage - Error screen for wrong save file type +- Multiple Registered Key Items
diff --git a/config.asm b/config.asm index 015b77f..caaf05f 100644 --- a/config.asm +++ b/config.asm @@ -54,6 +54,9 @@ ; Enable this to show an error screen when loaded with the wrong save file type. .definelabel WRONG_SAVE_TYPE_ERROR, 1 +; Allows for multiple key items to be registered and used from a list. +.definelabel MULTIPLE_REGISTERED_ITEMS, 1 + ; Bugfixes ; -------- diff --git a/include/battle.h b/include/battle.h index 1db70cf..b80e23b 100644 --- a/include/battle.h +++ b/include/battle.h @@ -1,8 +1,8 @@ #pragma once -#include "main.h" #include "types.h" #include "berry.h" +#include "main.h" #include "pokemon.h" #include "constants/moves.h" diff --git a/include/bios.h b/include/bios.h index b37a043..50b9764 100644 --- a/include/bios.h +++ b/include/bios.h @@ -2,35 +2,52 @@ #include "types.h" +void CpuSet(const void *src, void *dest, u32 control); void CpuFastSet(const void *src, void *dest, u32 control); void LZ77UnCompVram(const void *src, void *dest); -#define CPU_FAST_SET_SRC_FIXED 0x01000000 -#define CpuFastCopy(src, dest, size) CpuFastSet(src, dest, ((size) / (32 / 8) & 0x1FFFFF)) +#define CPU_FILL(value, dest, size, bit) \ + { \ + vu##bit tmp = (vu##bit)(value); \ + CpuSet((void *)&tmp, dest, CPU_SET_##bit##BIT | CPU_SET_SRC_FIXED | ((size) / (bit / 8) & 0x1FFFFF)); \ + } + +#define CpuFill16(value, dest, size) CPU_FILL(value, dest, size, 16) +#define CpuFill32(value, dest, size) CPU_FILL(value, dest, size, 32) + +#define CPU_COPY(src, dest, size, bit) CpuSet(src, dest, CPU_SET_##bit##BIT | ((size) / (bit / 8) & 0x1FFFFF)) + +#define CpuCopy16(src, dest, size) CPU_COPY(src, dest, size, 16) +#define CpuCopy32(src, dest, size) CPU_COPY(src, dest, size, 32) + +#define CPU_FAST_SET_SRC_FIXED 0x01000000 #define CpuFastFill(value, dest, size) \ { \ vu32 tmp = (vu32)(value); \ CpuFastSet((void *)&tmp, dest, CPU_FAST_SET_SRC_FIXED | ((size) / (32 / 8) & 0x1FFFFF)); \ } -#define DmaSet(dmaNum, src, dest, control) \ -{ \ - vu32 *dmaRegs = (vu32 *)REG_ADDR_DMA##dmaNum; \ - dmaRegs[0] = (vu32)(src); \ - dmaRegs[1] = (vu32)(dest); \ - dmaRegs[2] = (vu32)(control); \ - dmaRegs[2]; \ -} - -#define DMA_FILL(dmaNum, value, dest, size, bit) \ -{ \ - vu##bit tmp = (vu##bit)(value); \ - DmaSet(dmaNum, \ - &tmp, \ - dest, \ - (DMA_ENABLE | DMA_START_NOW | DMA_##bit##BIT | DMA_SRC_FIXED | DMA_DEST_INC) << 16 \ - | ((size)/(bit/8))); \ -} +#define CpuFastFill16(value, dest, size) CpuFastFill(((value) << 16) | (value), (dest), (size)) +#define CpuFastCopy(src, dest, size) CpuFastSet(src, dest, ((size) / (32 / 8) & 0x1FFFFF)) + +#define DmaSet(dmaNum, src, dest, control) \ + { \ + vu32 *dmaRegs = (vu32 *)REG_ADDR_DMA##dmaNum; \ + dmaRegs[0] = (vu32)(src); \ + dmaRegs[1] = (vu32)(dest); \ + dmaRegs[2] = (vu32)(control); \ + dmaRegs[2]; \ + } + +#define DMA_FILL(dmaNum, value, dest, size, bit) \ + { \ + vu##bit tmp = (vu##bit)(value); \ + DmaSet(dmaNum, \ + &tmp, \ + dest, \ + (DMA_ENABLE | DMA_START_NOW | DMA_##bit##BIT | DMA_SRC_FIXED | DMA_DEST_INC) << 16 \ + | ((size) / (bit / 8))); \ + } #define DmaFill16(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 16) #define DmaFill32(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 32) diff --git a/include/constants/gba.h b/include/constants/gba.h index 3af7017..bc35c0d 100644 --- a/include/constants/gba.h +++ b/include/constants/gba.h @@ -761,55 +761,55 @@ #define WAITCNT_AGB (0 << 15) #define WAITCNT_CGB (1 << 15) -#define EWRAM 0x2000000 -#define IWRAM 0x3000000 +#define EWRAM 0x2000000 +#define IWRAM 0x3000000 -#define PLTT 0x5000000 -#define PLTT_SIZE 0x400 +#define PLTT 0x5000000 +#define PLTT_SIZE 0x400 -#define BG_PLTT PLTT -#define BG_PLTT_SIZE 0x200 +#define BG_PLTT PLTT +#define BG_PLTT_SIZE 0x200 -#define OBJ_PLTT (PLTT + 0x200) -#define OBJ_PLTT_SIZE 0x200 +#define OBJ_PLTT (PLTT + 0x200) +#define OBJ_PLTT_SIZE 0x200 -#define VRAM 0x6000000 -#define VRAM_SIZE 0x18000 +#define VRAM 0x6000000 +#define VRAM_SIZE 0x18000 -#define BG_VRAM VRAM -#define BG_VRAM_SIZE 0x10000 -#define BG_CHAR_ADDR(n) (void *)(BG_VRAM + (0x4000 * (n))) -#define BG_SCREEN_ADDR(n) (void *)(BG_VRAM + (0x800 * (n))) -#define BG_TILE_ADDR(n) (void *)(BG_VRAM + (0x80 * (n))) +#define BG_VRAM VRAM +#define BG_VRAM_SIZE 0x10000 +#define BG_CHAR_ADDR(n) (void *)(BG_VRAM + (0x4000 * (n))) +#define BG_SCREEN_ADDR(n) (void *)(BG_VRAM + (0x800 * (n))) +#define BG_TILE_ADDR(n) (void *)(BG_VRAM + (0x80 * (n))) // text-mode BG #define OBJ_VRAM0 (void *)(VRAM + 0x10000) #define OBJ_VRAM0_SIZE 0x8000 // bitmap-mode BG -#define OBJ_VRAM1 (void *)(VRAM + 0x14000) -#define OBJ_VRAM1_SIZE 0x4000 +#define OBJ_VRAM1 (void *)(VRAM + 0x14000) +#define OBJ_VRAM1_SIZE 0x4000 -#define OAM 0x7000000 -#define OAM_SIZE 0x400 +#define OAM 0x7000000 +#define OAM_SIZE 0x400 -#define DISPLAY_WIDTH 240 -#define DISPLAY_HEIGHT 160 +#define DISPLAY_WIDTH 240 +#define DISPLAY_HEIGHT 160 -#define TILE_SIZE_4BPP 32 -#define TILE_SIZE_8BPP 64 +#define TILE_SIZE_4BPP 32 +#define TILE_SIZE_8BPP 64 #define TOTAL_OBJ_TILE_COUNT 1024 -#define PLTT_SIZEOF(n) ((n) * sizeof(u16)) -#define PLTT_SIZE_4BPP PLTT_SIZEOF(16) -#define PLTT_SIZE_8BPP PLTT_SIZEOF(256) +#define PLTT_SIZEOF(n) ((n) * sizeof(u16)) +#define PLTT_SIZE_4BPP PLTT_SIZEOF(16) +#define PLTT_SIZE_8BPP PLTT_SIZEOF(256) -#define PLTT_OFFSET_4BPP(n) ((n) * PLTT_SIZE_4BPP) +#define PLTT_OFFSET_4BPP(n) ((n)*PLTT_SIZE_4BPP) -#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) +#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) -#define RGB_BLACK RGB(0, 0, 0) -#define RGB_WHITE RGB(31, 31, 31) +#define RGB_BLACK RGB(0, 0, 0) +#define RGB_WHITE RGB(31, 31, 31) -#define WIN_RANGE(a, b) (((a) << 8) | (b)) \ No newline at end of file +#define WIN_RANGE(a, b) (((a) << 8) | (b)) \ No newline at end of file diff --git a/include/constants/songs.h b/include/constants/songs.h index 9a268f9..c5477a0 100644 --- a/include/constants/songs.h +++ b/include/constants/songs.h @@ -3,255 +3,255 @@ // Original JP names listed on right, along with any additional notes -#define MUS_DUMMY 0 // MUS_DUMMY -#define SE_USE_ITEM 1 // SE_KAIFUKU -#define SE_PC_LOGIN 2 // SE_PC_LOGIN -#define SE_PC_OFF 3 // SE_PC_OFF -#define SE_PC_ON 4 // SE_PC_ON -#define SE_SELECT 5 // SE_SELECT -#define SE_WIN_OPEN 6 // SE_WIN_OPEN -#define SE_WALL_HIT 7 // SE_WALL_HIT -#define SE_DOOR 8 // SE_DOOR -#define SE_EXIT 9 // SE_KAIDAN -#define SE_LEDGE 10 // SE_DANSA -#define SE_BIKE_BELL 11 // SE_JITENSYA -#define SE_NOT_EFFECTIVE 12 // SE_KOUKA_L -#define SE_EFFECTIVE 13 // SE_KOUKA_M -#define SE_SUPER_EFFECTIVE 14 // SE_KOUKA_H -#define SE_BALL_OPEN 15 // SE_BOWA2 -#define SE_FAINT 16 // SE_POKE_DEAD -#define SE_FLEE 17 // SE_NIGERU -#define SE_SLIDING_DOOR 18 // SE_JIDO_DOA -#define SE_SHIP 19 // SE_NAMINORI -#define SE_BANG 20 // SE_BAN -#define SE_PIN 21 // SE_PIN (General "good", commonly for "!") -#define SE_BOO 22 // SE_BOO (General "bad") -#define SE_BALL 23 // SE_BOWA (Giving Poké Ball to nurse, Poké Ball shake, etc) -#define SE_CONTEST_PLACE 24 // SE_JYUNI -#define SE_A 25 // SE_A (Bard sounds) -#define SE_I 26 // SE_I -#define SE_U 27 // SE_U -#define SE_E 28 // SE_E -#define SE_O 29 // SE_O -#define SE_N 30 // SE_N -#define SE_SUCCESS 31 // SE_SEIKAI -#define SE_FAILURE 32 // SE_HAZURE -#define SE_EXP 33 // SE_EXP -#define SE_BIKE_HOP 34 // SE_JITE_PYOKO -#define SE_SWITCH 35 // SE_MU_PACHI -#define SE_CLICK 36 // SE_TK_KASYA -#define SE_FU_ZAKU 37 // SE_FU_ZAKU (Unknown purpose, unused) -#define SE_CONTEST_CONDITION_LOSE 38 // SE_FU_ZAKU2 -#define SE_LAVARIDGE_FALL_WARP 39 // SE_FU_ZUZUZU -#define SE_ICE_STAIRS 40 // SE_RU_GASHIN -#define SE_ICE_BREAK 41 // SE_RU_GASYAN -#define SE_ICE_CRACK 42 // SE_RU_BARI -#define SE_FALL 43 // SE_RU_HYUU -#define SE_UNLOCK 44 // SE_KI_GASYAN -#define SE_WARP_IN 45 // SE_TK_WARPIN -#define SE_WARP_OUT 46 // SE_TK_WARPOUT -#define SE_REPEL 47 // SE_TU_SAA -#define SE_ROTATING_GATE 48 // SE_HI_TURUN -#define SE_TRUCK_MOVE 49 // SE_TRACK_MOVE -#define SE_TRUCK_STOP 50 // SE_TRACK_STOP -#define SE_TRUCK_UNLOAD 51 // SE_TRACK_HAIKI -#define SE_TRUCK_DOOR 52 // SE_TRACK_DOOR -#define SE_BERRY_BLENDER 53 // SE_MOTER -#define SE_CARD 54 // SE_CARD -#define SE_SAVE 55 // SE_SAVE -#define SE_BALL_BOUNCE_1 56 // SE_KON -#define SE_BALL_BOUNCE_2 57 // SE_KON2 -#define SE_BALL_BOUNCE_3 58 // SE_KON3 -#define SE_BALL_BOUNCE_4 59 // SE_KON4 -#define SE_BALL_TRADE 60 // SE_SUIKOMU -#define SE_BALL_THROW 61 // SE_NAGERU -#define SE_NOTE_C 62 // SE_TOY_C -#define SE_NOTE_D 63 // SE_TOY_D -#define SE_NOTE_E 64 // SE_TOY_E -#define SE_NOTE_F 65 // SE_TOY_F -#define SE_NOTE_G 66 // SE_TOY_G -#define SE_NOTE_A 67 // SE_TOY_A -#define SE_NOTE_B 68 // SE_TOY_B -#define SE_NOTE_C_HIGH 69 // SE_TOY_C1 -#define SE_PUDDLE 70 // SE_MIZU -#define SE_BRIDGE_WALK 71 // SE_HASHI -#define SE_ITEMFINDER 72 // SE_DAUGI -#define SE_DING_DONG 73 // SE_PINPON -#define SE_BALLOON_RED 74 // SE_FUUSEN1 -#define SE_BALLOON_BLUE 75 // SE_FUUSEN2 -#define SE_BALLOON_YELLOW 76 // SE_FUUSEN3 -#define SE_BREAKABLE_DOOR 77 // SE_TOY_KABE -#define SE_MUD_BALL 78 // SE_TOY_DANGO -#define SE_FIELD_POISON 79 // SE_DOKU -#define SE_ESCALATOR 80 // SE_ESUKA -#define SE_THUNDERSTORM 81 // SE_T_AME -#define SE_THUNDERSTORM_STOP 82 // SE_T_AME_E -#define SE_DOWNPOUR 83 // SE_T_OOAME -#define SE_DOWNPOUR_STOP 84 // SE_T_OOAME_E -#define SE_RAIN 85 // SE_T_KOAME -#define SE_RAIN_STOP 86 // SE_T_KOAME_E -#define SE_THUNDER 87 // SE_T_KAMI -#define SE_THUNDER2 88 // SE_T_KAMI2 -#define SE_ELEVATOR 89 // SE_ELEBETA -#define SE_LOW_HEALTH 90 // SE_HINSI -#define SE_EXP_MAX 91 // SE_EXPMAX -#define SE_ROULETTE_BALL 92 // SE_TAMAKORO -#define SE_ROULETTE_BALL2 93 // SE_TAMAKORO_E -#define SE_TAILLOW_WING_FLAP 94 // SE_BASABASA -#define SE_SHOP 95 // SE_REGI -#define SE_CONTEST_HEART 96 // SE_C_GAJI -#define SE_CONTEST_CURTAIN_RISE 97 // SE_C_MAKU_U -#define SE_CONTEST_CURTAIN_FALL 98 // SE_C_MAKU_D -#define SE_CONTEST_ICON_CHANGE 99 // SE_C_PASI -#define SE_CONTEST_ICON_CLEAR 100 // SE_C_SYU -#define SE_CONTEST_MONS_TURN 101 // SE_C_PIKON -#define SE_SHINY 102 // SE_REAPOKE -#define SE_INTRO_BLAST 103 // SE_OP_BASYU -#define SE_MUGSHOT 104 // SE_BT_START -#define SE_APPLAUSE 105 // SE_DENDOU -#define SE_VEND 106 // SE_JIHANKI -#define SE_ORB 107 // SE_TAMA -#define SE_DEX_SCROLL 108 // SE_Z_SCROLL -#define SE_DEX_PAGE 109 // SE_Z_PAGE -#define SE_POKENAV_ON 110 // SE_PN_ON -#define SE_POKENAV_OFF 111 // SE_PN_OFF -#define SE_DEX_SEARCH 112 // SE_Z_SEARCH -#define SE_EGG_HATCH 113 // SE_TAMAGO -#define SE_BALL_TRAY_ENTER 114 // SE_TB_START -#define SE_BALL_TRAY_BALL 115 // SE_TB_KON -#define SE_BALL_TRAY_EXIT 116 // SE_TB_KARA -#define SE_GLASS_FLUTE 117 // SE_BIDORO +#define MUS_DUMMY 0 // MUS_DUMMY +#define SE_USE_ITEM 1 // SE_KAIFUKU +#define SE_PC_LOGIN 2 // SE_PC_LOGIN +#define SE_PC_OFF 3 // SE_PC_OFF +#define SE_PC_ON 4 // SE_PC_ON +#define SE_SELECT 5 // SE_SELECT +#define SE_WIN_OPEN 6 // SE_WIN_OPEN +#define SE_WALL_HIT 7 // SE_WALL_HIT +#define SE_DOOR 8 // SE_DOOR +#define SE_EXIT 9 // SE_KAIDAN +#define SE_LEDGE 10 // SE_DANSA +#define SE_BIKE_BELL 11 // SE_JITENSYA +#define SE_NOT_EFFECTIVE 12 // SE_KOUKA_L +#define SE_EFFECTIVE 13 // SE_KOUKA_M +#define SE_SUPER_EFFECTIVE 14 // SE_KOUKA_H +#define SE_BALL_OPEN 15 // SE_BOWA2 +#define SE_FAINT 16 // SE_POKE_DEAD +#define SE_FLEE 17 // SE_NIGERU +#define SE_SLIDING_DOOR 18 // SE_JIDO_DOA +#define SE_SHIP 19 // SE_NAMINORI +#define SE_BANG 20 // SE_BAN +#define SE_PIN 21 // SE_PIN (General "good", commonly for "!") +#define SE_BOO 22 // SE_BOO (General "bad") +#define SE_BALL 23 // SE_BOWA (Giving Poké Ball to nurse, Poké Ball shake, etc) +#define SE_CONTEST_PLACE 24 // SE_JYUNI +#define SE_A 25 // SE_A (Bard sounds) +#define SE_I 26 // SE_I +#define SE_U 27 // SE_U +#define SE_E 28 // SE_E +#define SE_O 29 // SE_O +#define SE_N 30 // SE_N +#define SE_SUCCESS 31 // SE_SEIKAI +#define SE_FAILURE 32 // SE_HAZURE +#define SE_EXP 33 // SE_EXP +#define SE_BIKE_HOP 34 // SE_JITE_PYOKO +#define SE_SWITCH 35 // SE_MU_PACHI +#define SE_CLICK 36 // SE_TK_KASYA +#define SE_FU_ZAKU 37 // SE_FU_ZAKU (Unknown purpose, unused) +#define SE_CONTEST_CONDITION_LOSE 38 // SE_FU_ZAKU2 +#define SE_LAVARIDGE_FALL_WARP 39 // SE_FU_ZUZUZU +#define SE_ICE_STAIRS 40 // SE_RU_GASHIN +#define SE_ICE_BREAK 41 // SE_RU_GASYAN +#define SE_ICE_CRACK 42 // SE_RU_BARI +#define SE_FALL 43 // SE_RU_HYUU +#define SE_UNLOCK 44 // SE_KI_GASYAN +#define SE_WARP_IN 45 // SE_TK_WARPIN +#define SE_WARP_OUT 46 // SE_TK_WARPOUT +#define SE_REPEL 47 // SE_TU_SAA +#define SE_ROTATING_GATE 48 // SE_HI_TURUN +#define SE_TRUCK_MOVE 49 // SE_TRACK_MOVE +#define SE_TRUCK_STOP 50 // SE_TRACK_STOP +#define SE_TRUCK_UNLOAD 51 // SE_TRACK_HAIKI +#define SE_TRUCK_DOOR 52 // SE_TRACK_DOOR +#define SE_BERRY_BLENDER 53 // SE_MOTER +#define SE_CARD 54 // SE_CARD +#define SE_SAVE 55 // SE_SAVE +#define SE_BALL_BOUNCE_1 56 // SE_KON +#define SE_BALL_BOUNCE_2 57 // SE_KON2 +#define SE_BALL_BOUNCE_3 58 // SE_KON3 +#define SE_BALL_BOUNCE_4 59 // SE_KON4 +#define SE_BALL_TRADE 60 // SE_SUIKOMU +#define SE_BALL_THROW 61 // SE_NAGERU +#define SE_NOTE_C 62 // SE_TOY_C +#define SE_NOTE_D 63 // SE_TOY_D +#define SE_NOTE_E 64 // SE_TOY_E +#define SE_NOTE_F 65 // SE_TOY_F +#define SE_NOTE_G 66 // SE_TOY_G +#define SE_NOTE_A 67 // SE_TOY_A +#define SE_NOTE_B 68 // SE_TOY_B +#define SE_NOTE_C_HIGH 69 // SE_TOY_C1 +#define SE_PUDDLE 70 // SE_MIZU +#define SE_BRIDGE_WALK 71 // SE_HASHI +#define SE_ITEMFINDER 72 // SE_DAUGI +#define SE_DING_DONG 73 // SE_PINPON +#define SE_BALLOON_RED 74 // SE_FUUSEN1 +#define SE_BALLOON_BLUE 75 // SE_FUUSEN2 +#define SE_BALLOON_YELLOW 76 // SE_FUUSEN3 +#define SE_BREAKABLE_DOOR 77 // SE_TOY_KABE +#define SE_MUD_BALL 78 // SE_TOY_DANGO +#define SE_FIELD_POISON 79 // SE_DOKU +#define SE_ESCALATOR 80 // SE_ESUKA +#define SE_THUNDERSTORM 81 // SE_T_AME +#define SE_THUNDERSTORM_STOP 82 // SE_T_AME_E +#define SE_DOWNPOUR 83 // SE_T_OOAME +#define SE_DOWNPOUR_STOP 84 // SE_T_OOAME_E +#define SE_RAIN 85 // SE_T_KOAME +#define SE_RAIN_STOP 86 // SE_T_KOAME_E +#define SE_THUNDER 87 // SE_T_KAMI +#define SE_THUNDER2 88 // SE_T_KAMI2 +#define SE_ELEVATOR 89 // SE_ELEBETA +#define SE_LOW_HEALTH 90 // SE_HINSI +#define SE_EXP_MAX 91 // SE_EXPMAX +#define SE_ROULETTE_BALL 92 // SE_TAMAKORO +#define SE_ROULETTE_BALL2 93 // SE_TAMAKORO_E +#define SE_TAILLOW_WING_FLAP 94 // SE_BASABASA +#define SE_SHOP 95 // SE_REGI +#define SE_CONTEST_HEART 96 // SE_C_GAJI +#define SE_CONTEST_CURTAIN_RISE 97 // SE_C_MAKU_U +#define SE_CONTEST_CURTAIN_FALL 98 // SE_C_MAKU_D +#define SE_CONTEST_ICON_CHANGE 99 // SE_C_PASI +#define SE_CONTEST_ICON_CLEAR 100 // SE_C_SYU +#define SE_CONTEST_MONS_TURN 101 // SE_C_PIKON +#define SE_SHINY 102 // SE_REAPOKE +#define SE_INTRO_BLAST 103 // SE_OP_BASYU +#define SE_MUGSHOT 104 // SE_BT_START +#define SE_APPLAUSE 105 // SE_DENDOU +#define SE_VEND 106 // SE_JIHANKI +#define SE_ORB 107 // SE_TAMA +#define SE_DEX_SCROLL 108 // SE_Z_SCROLL +#define SE_DEX_PAGE 109 // SE_Z_PAGE +#define SE_POKENAV_ON 110 // SE_PN_ON +#define SE_POKENAV_OFF 111 // SE_PN_OFF +#define SE_DEX_SEARCH 112 // SE_Z_SEARCH +#define SE_EGG_HATCH 113 // SE_TAMAGO +#define SE_BALL_TRAY_ENTER 114 // SE_TB_START +#define SE_BALL_TRAY_BALL 115 // SE_TB_KON +#define SE_BALL_TRAY_EXIT 116 // SE_TB_KARA +#define SE_GLASS_FLUTE 117 // SE_BIDORO // Move SFX -#define SE_M_THUNDERBOLT 118 // SE_W085 -#define SE_M_THUNDERBOLT2 119 // SE_W085B -#define SE_M_HARDEN 120 // SE_W231 -#define SE_M_NIGHTMARE 121 // SE_W171 -#define SE_M_VITAL_THROW 122 // SE_W233 -#define SE_M_VITAL_THROW2 123 // SE_W233B -#define SE_M_BUBBLE 124 // SE_W145 -#define SE_M_BUBBLE2 125 // SE_W145B -#define SE_M_BUBBLE3 126 // SE_W145C -#define SE_M_RAIN_DANCE 127 // SE_W240 -#define SE_M_CUT 128 // SE_W015 -#define SE_M_STRING_SHOT 129 // SE_W081 -#define SE_M_STRING_SHOT2 130 // SE_W081B -#define SE_M_ROCK_THROW 131 // SE_W088 -#define SE_M_GUST 132 // SE_W016 -#define SE_M_GUST2 133 // SE_W016B -#define SE_M_DOUBLE_SLAP 134 // SE_W003 -#define SE_M_DOUBLE_TEAM 135 // SE_W104 -#define SE_M_RAZOR_WIND 136 // SE_W013 -#define SE_M_ICY_WIND 137 // SE_W196 -#define SE_M_THUNDER_WAVE 138 // SE_W086 -#define SE_M_COMET_PUNCH 139 // SE_W004 -#define SE_M_MEGA_KICK 140 // SE_W025 -#define SE_M_MEGA_KICK2 141 // SE_W025B -#define SE_M_CRABHAMMER 142 // SE_W152 -#define SE_M_JUMP_KICK 143 // SE_W026 -#define SE_M_FLAME_WHEEL 144 // SE_W172 -#define SE_M_FLAME_WHEEL2 145 // SE_W172B -#define SE_M_FLAMETHROWER 146 // SE_W053 -#define SE_M_FIRE_PUNCH 147 // SE_W007 -#define SE_M_TOXIC 148 // SE_W092 -#define SE_M_SACRED_FIRE 149 // SE_W221 -#define SE_M_SACRED_FIRE2 150 // SE_W221B -#define SE_M_EMBER 151 // SE_W052 -#define SE_M_TAKE_DOWN 152 // SE_W036 -#define SE_M_BLIZZARD 153 // SE_W059 -#define SE_M_BLIZZARD2 154 // SE_W059B -#define SE_M_SCRATCH 155 // SE_W010 -#define SE_M_VICEGRIP 156 // SE_W011 -#define SE_M_WING_ATTACK 157 // SE_W017 -#define SE_M_FLY 158 // SE_W019 -#define SE_M_SAND_ATTACK 159 // SE_W028 -#define SE_M_RAZOR_WIND2 160 // SE_W013B -#define SE_M_BITE 161 // SE_W044 -#define SE_M_HEADBUTT 162 // SE_W029 -#define SE_M_SURF 163 // SE_W057 -#define SE_M_HYDRO_PUMP 164 // SE_W056 -#define SE_M_WHIRLPOOL 165 // SE_W250 -#define SE_M_HORN_ATTACK 166 // SE_W030 -#define SE_M_TAIL_WHIP 167 // SE_W039 -#define SE_M_MIST 168 // SE_W054 -#define SE_M_POISON_POWDER 169 // SE_W077 -#define SE_M_BIND 170 // SE_W020 -#define SE_M_DRAGON_RAGE 171 // SE_W082 -#define SE_M_SING 172 // SE_W047 -#define SE_M_PERISH_SONG 173 // SE_W195 -#define SE_M_PAY_DAY 174 // SE_W006 -#define SE_M_DIG 175 // SE_W091 -#define SE_M_DIZZY_PUNCH 176 // SE_W146 -#define SE_M_SELF_DESTRUCT 177 // SE_W120 -#define SE_M_EXPLOSION 178 // SE_W153 -#define SE_M_ABSORB_2 179 // SE_W071B -#define SE_M_ABSORB 180 // SE_W071 -#define SE_M_SCREECH 181 // SE_W103 -#define SE_M_BUBBLE_BEAM 182 // SE_W062 -#define SE_M_BUBBLE_BEAM2 183 // SE_W062B -#define SE_M_SUPERSONIC 184 // SE_W048 -#define SE_M_BELLY_DRUM 185 // SE_W187 -#define SE_M_METRONOME 186 // SE_W118 -#define SE_M_BONEMERANG 187 // SE_W155 -#define SE_M_LICK 188 // SE_W122 -#define SE_M_PSYBEAM 189 // SE_W060 -#define SE_M_FAINT_ATTACK 190 // SE_W185 -#define SE_M_SWORDS_DANCE 191 // SE_W014 -#define SE_M_LEER 192 // SE_W043 -#define SE_M_SWAGGER 193 // SE_W207 -#define SE_M_SWAGGER2 194 // SE_W207B -#define SE_M_HEAL_BELL 195 // SE_W215 -#define SE_M_CONFUSE_RAY 196 // SE_W109 -#define SE_M_SNORE 197 // SE_W173 -#define SE_M_BRICK_BREAK 198 // SE_W280 -#define SE_M_GIGA_DRAIN 199 // SE_W202 -#define SE_M_PSYBEAM2 200 // SE_W060B -#define SE_M_SOLAR_BEAM 201 // SE_W076 -#define SE_M_PETAL_DANCE 202 // SE_W080 -#define SE_M_TELEPORT 203 // SE_W100 -#define SE_M_MINIMIZE 204 // SE_W107 -#define SE_M_SKETCH 205 // SE_W166 -#define SE_M_SWIFT 206 // SE_W129 -#define SE_M_REFLECT 207 // SE_W115 -#define SE_M_BARRIER 208 // SE_W112 -#define SE_M_DETECT 209 // SE_W197 -#define SE_M_LOCK_ON 210 // SE_W199 -#define SE_M_MOONLIGHT 211 // SE_W236 -#define SE_M_CHARM 212 // SE_W204 -#define SE_M_CHARGE 213 // SE_W268 -#define SE_M_STRENGTH 214 // SE_W070 -#define SE_M_HYPER_BEAM 215 // SE_W063 -#define SE_M_WATERFALL 216 // SE_W127 -#define SE_M_REVERSAL 217 // SE_W179 -#define SE_M_ACID_ARMOR 218 // SE_W151 -#define SE_M_SANDSTORM 219 // SE_W201 -#define SE_M_TRI_ATTACK 220 // SE_W161 -#define SE_M_TRI_ATTACK2 221 // SE_W161B -#define SE_M_ENCORE 222 // SE_W227 -#define SE_M_ENCORE2 223 // SE_W227B -#define SE_M_BATON_PASS 224 // SE_W226 -#define SE_M_MILK_DRINK 225 // SE_W208 -#define SE_M_ATTRACT 226 // SE_W213 -#define SE_M_ATTRACT2 227 // SE_W213B -#define SE_M_MORNING_SUN 228 // SE_W234 -#define SE_M_FLATTER 229 // SE_W260 -#define SE_M_SAND_TOMB 230 // SE_W328 -#define SE_M_GRASSWHISTLE 231 // SE_W320 -#define SE_M_SPIT_UP 232 // SE_W255 -#define SE_M_DIVE 233 // SE_W291 -#define SE_M_EARTHQUAKE 234 // SE_W089 -#define SE_M_TWISTER 235 // SE_W239 -#define SE_M_SWEET_SCENT 236 // SE_W230 -#define SE_M_YAWN 237 // SE_W281 -#define SE_M_SKY_UPPERCUT 238 // SE_W327 -#define SE_M_STAT_INCREASE 239 // SE_W287 -#define SE_M_HEAT_WAVE 240 // SE_W257 -#define SE_M_UPROAR 241 // SE_W253 -#define SE_M_HAIL 242 // SE_W258 -#define SE_M_COSMIC_POWER 243 // SE_W322 -#define SE_M_TEETER_DANCE 244 // SE_W298 -#define SE_M_STAT_DECREASE 245 // SE_W287B -#define SE_M_HAZE 246 // SE_W114 -#define SE_M_HYPER_BEAM2 247 // SE_W063B +#define SE_M_THUNDERBOLT 118 // SE_W085 +#define SE_M_THUNDERBOLT2 119 // SE_W085B +#define SE_M_HARDEN 120 // SE_W231 +#define SE_M_NIGHTMARE 121 // SE_W171 +#define SE_M_VITAL_THROW 122 // SE_W233 +#define SE_M_VITAL_THROW2 123 // SE_W233B +#define SE_M_BUBBLE 124 // SE_W145 +#define SE_M_BUBBLE2 125 // SE_W145B +#define SE_M_BUBBLE3 126 // SE_W145C +#define SE_M_RAIN_DANCE 127 // SE_W240 +#define SE_M_CUT 128 // SE_W015 +#define SE_M_STRING_SHOT 129 // SE_W081 +#define SE_M_STRING_SHOT2 130 // SE_W081B +#define SE_M_ROCK_THROW 131 // SE_W088 +#define SE_M_GUST 132 // SE_W016 +#define SE_M_GUST2 133 // SE_W016B +#define SE_M_DOUBLE_SLAP 134 // SE_W003 +#define SE_M_DOUBLE_TEAM 135 // SE_W104 +#define SE_M_RAZOR_WIND 136 // SE_W013 +#define SE_M_ICY_WIND 137 // SE_W196 +#define SE_M_THUNDER_WAVE 138 // SE_W086 +#define SE_M_COMET_PUNCH 139 // SE_W004 +#define SE_M_MEGA_KICK 140 // SE_W025 +#define SE_M_MEGA_KICK2 141 // SE_W025B +#define SE_M_CRABHAMMER 142 // SE_W152 +#define SE_M_JUMP_KICK 143 // SE_W026 +#define SE_M_FLAME_WHEEL 144 // SE_W172 +#define SE_M_FLAME_WHEEL2 145 // SE_W172B +#define SE_M_FLAMETHROWER 146 // SE_W053 +#define SE_M_FIRE_PUNCH 147 // SE_W007 +#define SE_M_TOXIC 148 // SE_W092 +#define SE_M_SACRED_FIRE 149 // SE_W221 +#define SE_M_SACRED_FIRE2 150 // SE_W221B +#define SE_M_EMBER 151 // SE_W052 +#define SE_M_TAKE_DOWN 152 // SE_W036 +#define SE_M_BLIZZARD 153 // SE_W059 +#define SE_M_BLIZZARD2 154 // SE_W059B +#define SE_M_SCRATCH 155 // SE_W010 +#define SE_M_VICEGRIP 156 // SE_W011 +#define SE_M_WING_ATTACK 157 // SE_W017 +#define SE_M_FLY 158 // SE_W019 +#define SE_M_SAND_ATTACK 159 // SE_W028 +#define SE_M_RAZOR_WIND2 160 // SE_W013B +#define SE_M_BITE 161 // SE_W044 +#define SE_M_HEADBUTT 162 // SE_W029 +#define SE_M_SURF 163 // SE_W057 +#define SE_M_HYDRO_PUMP 164 // SE_W056 +#define SE_M_WHIRLPOOL 165 // SE_W250 +#define SE_M_HORN_ATTACK 166 // SE_W030 +#define SE_M_TAIL_WHIP 167 // SE_W039 +#define SE_M_MIST 168 // SE_W054 +#define SE_M_POISON_POWDER 169 // SE_W077 +#define SE_M_BIND 170 // SE_W020 +#define SE_M_DRAGON_RAGE 171 // SE_W082 +#define SE_M_SING 172 // SE_W047 +#define SE_M_PERISH_SONG 173 // SE_W195 +#define SE_M_PAY_DAY 174 // SE_W006 +#define SE_M_DIG 175 // SE_W091 +#define SE_M_DIZZY_PUNCH 176 // SE_W146 +#define SE_M_SELF_DESTRUCT 177 // SE_W120 +#define SE_M_EXPLOSION 178 // SE_W153 +#define SE_M_ABSORB_2 179 // SE_W071B +#define SE_M_ABSORB 180 // SE_W071 +#define SE_M_SCREECH 181 // SE_W103 +#define SE_M_BUBBLE_BEAM 182 // SE_W062 +#define SE_M_BUBBLE_BEAM2 183 // SE_W062B +#define SE_M_SUPERSONIC 184 // SE_W048 +#define SE_M_BELLY_DRUM 185 // SE_W187 +#define SE_M_METRONOME 186 // SE_W118 +#define SE_M_BONEMERANG 187 // SE_W155 +#define SE_M_LICK 188 // SE_W122 +#define SE_M_PSYBEAM 189 // SE_W060 +#define SE_M_FAINT_ATTACK 190 // SE_W185 +#define SE_M_SWORDS_DANCE 191 // SE_W014 +#define SE_M_LEER 192 // SE_W043 +#define SE_M_SWAGGER 193 // SE_W207 +#define SE_M_SWAGGER2 194 // SE_W207B +#define SE_M_HEAL_BELL 195 // SE_W215 +#define SE_M_CONFUSE_RAY 196 // SE_W109 +#define SE_M_SNORE 197 // SE_W173 +#define SE_M_BRICK_BREAK 198 // SE_W280 +#define SE_M_GIGA_DRAIN 199 // SE_W202 +#define SE_M_PSYBEAM2 200 // SE_W060B +#define SE_M_SOLAR_BEAM 201 // SE_W076 +#define SE_M_PETAL_DANCE 202 // SE_W080 +#define SE_M_TELEPORT 203 // SE_W100 +#define SE_M_MINIMIZE 204 // SE_W107 +#define SE_M_SKETCH 205 // SE_W166 +#define SE_M_SWIFT 206 // SE_W129 +#define SE_M_REFLECT 207 // SE_W115 +#define SE_M_BARRIER 208 // SE_W112 +#define SE_M_DETECT 209 // SE_W197 +#define SE_M_LOCK_ON 210 // SE_W199 +#define SE_M_MOONLIGHT 211 // SE_W236 +#define SE_M_CHARM 212 // SE_W204 +#define SE_M_CHARGE 213 // SE_W268 +#define SE_M_STRENGTH 214 // SE_W070 +#define SE_M_HYPER_BEAM 215 // SE_W063 +#define SE_M_WATERFALL 216 // SE_W127 +#define SE_M_REVERSAL 217 // SE_W179 +#define SE_M_ACID_ARMOR 218 // SE_W151 +#define SE_M_SANDSTORM 219 // SE_W201 +#define SE_M_TRI_ATTACK 220 // SE_W161 +#define SE_M_TRI_ATTACK2 221 // SE_W161B +#define SE_M_ENCORE 222 // SE_W227 +#define SE_M_ENCORE2 223 // SE_W227B +#define SE_M_BATON_PASS 224 // SE_W226 +#define SE_M_MILK_DRINK 225 // SE_W208 +#define SE_M_ATTRACT 226 // SE_W213 +#define SE_M_ATTRACT2 227 // SE_W213B +#define SE_M_MORNING_SUN 228 // SE_W234 +#define SE_M_FLATTER 229 // SE_W260 +#define SE_M_SAND_TOMB 230 // SE_W328 +#define SE_M_GRASSWHISTLE 231 // SE_W320 +#define SE_M_SPIT_UP 232 // SE_W255 +#define SE_M_DIVE 233 // SE_W291 +#define SE_M_EARTHQUAKE 234 // SE_W089 +#define SE_M_TWISTER 235 // SE_W239 +#define SE_M_SWEET_SCENT 236 // SE_W230 +#define SE_M_YAWN 237 // SE_W281 +#define SE_M_SKY_UPPERCUT 238 // SE_W327 +#define SE_M_STAT_INCREASE 239 // SE_W287 +#define SE_M_HEAT_WAVE 240 // SE_W257 +#define SE_M_UPROAR 241 // SE_W253 +#define SE_M_HAIL 242 // SE_W258 +#define SE_M_COSMIC_POWER 243 // SE_W322 +#define SE_M_TEETER_DANCE 244 // SE_W298 +#define SE_M_STAT_DECREASE 245 // SE_W287B +#define SE_M_HAZE 246 // SE_W114 +#define SE_M_HYPER_BEAM2 247 // SE_W063B // Music #define MUS_STOP 349 // MUS_STOP @@ -374,6 +374,6 @@ #define MUS_VS_AQUA_MAGMA_LEADER 466 // MUS_BATTLE30 #define MUS_GSC_RADIO_TOWER_TAKEOVER 467 -#define MUS_ROUTE_118 0x7FFF // Map is split into 2 music sections. controlled by GetCurrLocationDefaultMusic(). +#define MUS_ROUTE_118 0x7FFF // Map is split into 2 music sections. controlled by GetCurrLocationDefaultMusic(). -#endif // GUARD_CONSTANTS_SONGS_H +#endif // GUARD_CONSTANTS_SONGS_H diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 52c3b1a..6138d90 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -55,6 +55,7 @@ void ObjectEventSetGraphicsId(struct ObjectEvent *, u8); void ObjectEventTurn(struct ObjectEvent *, u8); void ObjectEventGetLocalIdAndMap(struct ObjectEvent *, void *, void *, void *); void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *); +void FreezeObjectEvents(void); #define GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN (1 << 0) #define GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE (1 << 1) diff --git a/include/field_message_box.h b/include/field_message_box.h new file mode 100644 index 0000000..f07e684 --- /dev/null +++ b/include/field_message_box.h @@ -0,0 +1,4 @@ +#pragma once + +bool8 ShowFieldMessage(const u8 *message); +void HideFieldMessageBox(void); \ No newline at end of file diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 121e126..5517c5b 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -44,3 +44,5 @@ struct PlayerAvatar /* 0x202E858 */ extern struct PlayerAvatar gPlayerAvatar; void SetPlayerAvatarStateMask(u8 a); +void StopPlayerAvatar(void); +void PlayerFreeze(void); diff --git a/include/item.h b/include/item.h index 32eb51a..27f388f 100644 --- a/include/item.h +++ b/include/item.h @@ -48,5 +48,6 @@ const u8 *ItemId_GetName(u16 itemId); const u8 *ItemId_GetDescription(u16 itemId); bool8 RemoveBagItem(u16 itemId, u16 count); bool8 ItemIsMail(u16); +ItemUseFunc ItemId_GetFieldFunc(u16 itemId); extern const struct Item gItems[]; diff --git a/include/item_menu.h b/include/item_menu.h index ac941d5..94993fa 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -16,12 +16,23 @@ struct PocketScrollState u8 cursorMax; }; -#define BAG_ITEMS_COUNT 60 +#define BAG_ITEMS_COUNT 60 +#define REGISTERED_ITEMS_COUNT 5 extern struct ItemSlot *gCurrentBagPocketItemSlots; extern struct PocketScrollState gBagPocketScrollStates[5]; extern s8 sCurrentBagPocket; extern struct ItemSlot gExpandedItemPockets[BAG_ITEMS_COUNT]; +extern u16 gRegisteredItems[REGISTERED_ITEMS_COUNT]; +extern u8 gLastUsedRegisteredItem; u8 *HighlightSelectedOption(u8 taskId, u8 *text, u8 itemSlot); bool8 PrintCancelOption(u8 itemPos, int b); + +void DrawSelectIcon(u32 itemPos); +void MoveSelectIcon(u8 itemPos); +void EraseSelectIcon(u8 itemPos); + +void ItemListMenu_InitMenu(void); + +extern const u8 Event_NoRegisteredItem[]; diff --git a/include/map_name_popup.h b/include/map_name_popup.h new file mode 100644 index 0000000..ea06058 --- /dev/null +++ b/include/map_name_popup.h @@ -0,0 +1,3 @@ +#pragma once + +void HideMapNamePopup(); \ No newline at end of file diff --git a/include/party_menu.h b/include/party_menu.h index ab0d010..ef8a258 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -1,15 +1,18 @@ #pragma once +#include "pokemon.h" +#include "task.h" + extern u8 gPartyMenuUseExitCallback; -#define pmStatGrowths data -#define pmSetupState data[0] -#define pmMonIndex data[1] -#define pmUnk268 data[2] -#define pmUnk272 data[7] -#define pmUnk27E data[13] -#define pmUnk280 data[14] -#define pmUnk282 data[15] +#define pmStatGrowths data +#define pmSetupState data[0] +#define pmMonIndex data[1] +#define pmUnk268 data[2] +#define pmUnk272 data[7] +#define pmUnk27E data[13] +#define pmUnk280 data[14] +#define pmUnk282 data[15] struct Unk201B000 { @@ -59,4 +62,3 @@ void ReturnToBagFromPartyMenu(u8 taskId); void HandleItemUsePartyMenu(u8 taskID); u8 GetItemEffectType(u16 item); void PartyMenuEraseMsgBoxAndFrame(void); - diff --git a/include/script.h b/include/script.h index e7d0dcd..064df47 100644 --- a/include/script.h +++ b/include/script.h @@ -20,3 +20,7 @@ struct ScriptContext extern struct ScriptContext gScriptContext1; void SetupNativeScript(struct ScriptContext *ctx, bool8 (*ptr)(void)); +void ScriptContext1_SetupScript(const u8 *ptr); +void ScriptContext2_Enable(void); +void ScriptContext1_Stop(void); +bool8 ScriptContext2_IsEnabled(void); diff --git a/include/types.h b/include/types.h index 08dab95..dc5addb 100644 --- a/include/types.h +++ b/include/types.h @@ -34,8 +34,8 @@ struct UCoords16 u16 y; }; -#define PACKED __attribute__((packed)) -#define NAKED __attribute__((naked)) +#define PACKED __attribute__((packed)) +#define NAKED __attribute__((naked)) #define TRUE 1 #define FALSE 0 diff --git a/main.asm b/main.asm index ec1e0a7..cb25754 100644 --- a/main.asm +++ b/main.asm @@ -57,6 +57,7 @@ .include "scripts/hm_system.asm" .include "scripts/ow_shadows.asm" .include "scripts/ps_split.asm" +.include "scripts/registered_item_list.asm" .include "scripts/repeated_item.asm" .include "scripts/repel_prompt.asm" .include "scripts/reusable_tms.asm" diff --git a/rom.ld b/rom.ld index 93d1eca..add2fea 100644 --- a/rom.ld +++ b/rom.ld @@ -2,6 +2,7 @@ __modsi3 = 0x81e0978 | 1; __umodsi3 = 0x81e0f08 | 1; __divsi3 = 0x81e0868 | 1; __udivsi3 = 0x81e0e90 | 1; +CpuSet = 0x81e07ec | 1; CpuFastSet = 0x81e07e8 | 1; LZ77UnCompVram = 0x81e07f0 | 1; @@ -12,6 +13,7 @@ gWindowTemplate_81E6C3C = 0x81E6C3C; gBattleMoves = 0x81fb12c; gMain = 0x3001770; gItems = 0x83c5564; +gUnknown_02038558 = 0x2038558; gSpecialVar_ItemId = 0x203855e; gNatureStatTable = 0x81fd070; gPartyMenuUseExitCallback = 0x202e8f4; @@ -55,6 +57,7 @@ gTakenDmgByBattler = 0x2024c74; gBattlerAttacker = 0x2024c07; BattleScript_SubstituteFade = 0x81d99ab; gRepelMenuChoices = 0x203a400; +gLastUsedRegisteredItem = 0x203a403; gPlayerParty = 0x3004360; sPokeMenuCursorPos = 0x202ffa8; sPokeMenuOptionsNo = 0x202ffa9; @@ -62,6 +65,7 @@ sPokeMenuOptionsOrder = 0x202ffaa; gLastFieldPokeMenuOpened = 0x3005ce0; sPokeMenuFieldMoves = 0x839f554; gExpandedItemPockets = 0x2025420; +gRegisteredItems = 0x2025520; gWeatherPtr = 0x8396fc4; gPlttBufferUnfaded = 0x202eac8; gPlttBufferFaded = 0x202eec8; @@ -86,6 +90,7 @@ gFieldEffectObjectTemplatePointers = 0x836dfc0; gShadowEffectTemplateIds = 0x8401e32; gFontDefaultPalette = 0x81e66b2; gMenuTextWindowTemplate = 0x81e6ce4; +Event_NoRegisteredItem = 0x81a14af; gStringVar1 = 0x20231cc; gStringVar2 = 0x20232cc; @@ -284,3 +289,22 @@ LoadFontDefaultPalette = 0x8002a1c | 1; TransferPlttBuffer = 0x8073ae0 | 1; InitMenuWindow = 0x8071c4c | 1; CB2_ShowDiploma = 0x8145d88 | 1; +; RemoveSelectIconFromRegisteredItem = 0x80a40d0 | 1; +; AddSelectIconToRegisteredItem = 0x80a413c | 1; +ItemListMenu_InitMenu = 0x80a736c | 1; +sub_80A7528 = 0x80A7528 | 1; +sub_80A41D4 = 0x80A41D4 | 1; +sub_80A37C0 = 0x80A37C0 | 1; +DrawSelectIcon = 0x80a4030 | 1; +MoveSelectIcon = 0x80a405c | 1; +EraseSelectIcon = 0x80a40ac | 1; +ScriptContext1_SetupScript = 0x80655b8 | 1; +HideMapNamePopup = 0x80a30a4 | 1; +ItemId_GetFieldFunc = 0x80a9a98 | 1; +ScriptContext2_Enable = 0x8065530 | 1; +FreezeObjectEvents = 0x8064434 | 1; +StopPlayerAvatar = 0x80597F4 | 1; +PlayerFreeze = 0x80594C0 | 1; +ShowFieldMessage = 0x8064b68 | 1; +ScriptContext2_IsEnabled = 0x8065548 | 1; +HideFieldMessageBox = 0x8064c58 | 1; diff --git a/scripts/registered_item_list.asm b/scripts/registered_item_list.asm new file mode 100644 index 0000000..7a4ce9f --- /dev/null +++ b/scripts/registered_item_list.asm @@ -0,0 +1,85 @@ +.if MULTIPLE_REGISTERED_ITEMS +; Clear gRegisteredItems on New Game +.org 0x8052f04 +set_function_hook r4, @NewGameInitDataHook + +.org 0x80a444c +set_function_hook r5, Menu_PrintKeyItem + +.org 0x83c165c +.word (HandlePopupMenuAction_Register | 1) + +.org 0x80a3dac +set_function_hook r2, @HandleItemRemoval + +.org 0x8068158 +set_function_hook r4, @ProcessPlayerFieldInputHook + +.org 0x80c9100 +.word @BirchVoice + +.autoregion +.align 2 +@ProcessPlayerFieldInputHook: +cmp r0, #0 +beq @@ReturnToFunc + +push {r0-r7} +ldr r0, =@EventScript_UseRegisteredItem +ldr r1, =@UseWhichRegisteredItem +bl UseRegisteredKeyItemFromField +pop {r0-r7} + +ldr r4, =(0x8068160 | 1) +bx r4 + +@@ReturnToFunc: +ldr r4, =(0x8068164 | 1) +bx r4 + + +@HandleItemRemoval: +push {r0-r7} +mov r0, r3 +bl TryRemoveRegisteredItem +pop {r0-r7} + +ldr r2, =(0x80a3db4 | 1) +bx r2 + +.align 2 +@NewGameInitDataHook: +ldr r4, =(0x80a3714 | 1) ; ClearBag +bl @linker + +push {r0-r7} +bl ClearRegisteredItems +pop {r0-r7} + +ldr r4, =(0x8052f0c | 1) ; Return to NewGameInitData +bx r4 + +@linker: +bx r4 +.pool + +@EventScript_UseRegisteredItem: +s_lockall +s_message @UseWhichRegisteredItem +s_waitmessage +s_callnative (DrawRegisteredItemsMultichoice | 1) +s_waitstate +s_callnative (UseSelectedRegisteredItem | 1) +s_releaseall +s_return + +@UseWhichRegisteredItem: +.string "Use which item?" + +@BirchVoice: +.string "BIRCH's voice echoes....\nReally, [player]? Right now?\lI think not.", 0xfc, 0x09 +.endautoregion + +.org 0x80b5290 +cmp r0, #2 +.endif \ No newline at end of file diff --git a/scripts/save_flash_failed.asm b/scripts/save_flash_failed.asm index d60698d..3b750e6 100644 --- a/scripts/save_flash_failed.asm +++ b/scripts/save_flash_failed.asm @@ -1,8 +1,6 @@ .if WRONG_SAVE_TYPE_ERROR .org 0x800028c -ldr r7, =(@NoFlashMemoryCallback | 1) -bx r7 -.pool +set_function_hook r7, @NoFlashMemoryCallback .autoregion .align 2 diff --git a/src/event_object_movement.c b/src/event_object_movement.c index e200a0e..2d6c978 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -57,7 +57,7 @@ static void GetGroundEffectFlags_Shadow(struct ObjectEvent *objEvent, u32 *flags || MetatileBehavior_IsReflective(objEvent->currentMetatileBehavior) || MetatileBehavior_IsReflective(objEvent->previousMetatileBehavior) || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior) || objEvent->inSandPile - || objEvent->inHotSprings || objEvent->inShallowFlowingWater || objEvent->inanimate) + || objEvent->inHotSprings || objEvent->inShallowFlowingWater || objEvent->inanimate || objEvent->invisible) { objEvent->hasShadow = FALSE; } diff --git a/src/item_menu.c b/src/item_menu.c index c93ea6e..40c951c 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1,10 +1,28 @@ #include "types.h" #include "item_menu.h" +#include "event_object_movement.h" +#include "field_message_box.h" +#include "field_player_avatar.h" #include "item.h" +#include "item_use.h" +#include "map_name_popup.h" #include "menu.h" +#include "script.h" +#include "script_menu.h" +#include "sound.h" #include "string_util.h" +#include "task.h" #include "text.h" #include "constants/items.h" +#include "constants/songs.h" + +bool8 IsItemRegistered(u16 itemId); +void CompactRegisterItems(void); +void RegisterItem(u16 itemId); +void UnregisterItem(u16 itemId); +void HandleRegisterItem(u16 itemId); + +void RedrawSelectIconForRegisteredItems(void); void Menu_PrintTMHM(u16 taskId, int topItemOffset, int bottomItemOffset, int d) { @@ -35,15 +53,15 @@ void Menu_PrintTMHM(u16 taskId, int topItemOffset, int bottomItemOffset, int d) gBGTilemapBuffers[2][tilemapOffset + 33] = 0x4F; moveName = gMoveNames[ItemIdToBattleMoveId(gCurrentBagPocketItemSlots[slot].itemId)]; text[0] = EXT_CTRL_CODE_BEGIN; - text[1] = 0x13; - text[2] = 8; + text[1] = EXT_CTRL_CODE_CLEAR_TO; + text[2] = 0x8; text += 3; text = ConvertIntToDecimalStringN(text, gCurrentBagPocketItemSlots[slot].itemId - (ITEM_TM01_FOCUS_PUNCH - 1), STR_CONV_MODE_LEADING_ZEROS, 2); text[0] = EXT_CTRL_CODE_BEGIN; - text[1] = 0x13; + text[1] = EXT_CTRL_CODE_CLEAR_TO; text[2] = 0x18; text += 3; text = AlignStringInMenuWindow(text, moveName, 0x78 - 2 * 6, 0); @@ -56,12 +74,12 @@ void Menu_PrintTMHM(u16 taskId, int topItemOffset, int bottomItemOffset, int d) gBGTilemapBuffers[2][tilemapOffset + 32] = 0x106D; gBGTilemapBuffers[2][tilemapOffset + 33] = 0x106E; text[0] = EXT_CTRL_CODE_BEGIN; - text[1] = 0x13; + text[1] = EXT_CTRL_CODE_CLEAR_TO; text[2] = 0x11; text += 3; text = ConvertIntToDecimalString(text, gCurrentBagPocketItemSlots[slot].itemId - (ITEM_HM01_CUT - 1)); text[0] = EXT_CTRL_CODE_BEGIN; - text[1] = 0x13; + text[1] = EXT_CTRL_CODE_CLEAR_TO; text[2] = 0x18; text += 3; moveName = gMoveNames[ItemIdToBattleMoveId(gCurrentBagPocketItemSlots[slot].itemId)]; @@ -70,4 +88,247 @@ void Menu_PrintTMHM(u16 taskId, int topItemOffset, int bottomItemOffset, int d) Menu_PrintText(gStringVar1, 14, y); } -} \ No newline at end of file +} + +extern u8 gUnknown_02038558; + +void Menu_PrintKeyItem(u16 taskId, int topItemOffset, int bottomItemOffset, int d) +{ + u8 i; + + for (i = topItemOffset; i <= bottomItemOffset; i++) + { + u8 slot; + u8 top; + u8 *text; + + if (PrintCancelOption(i, d)) + break; + + slot = gBagPocketScrollStates[sCurrentBagPocket].scrollTop + i; + top = i * 2 + 2; + text = gStringVar1; + text = HighlightSelectedOption(taskId, text, i); + AlignStringInMenuWindow(text, ItemId_GetName(gCurrentBagPocketItemSlots[slot].itemId), 0x63, 0); + Menu_PrintText(gStringVar1, 14, top); + + if (IsItemRegistered(gCurrentBagPocketItemSlots[slot].itemId)) + DrawSelectIcon(i); + else + EraseSelectIcon(i); + } +} + +void sub_80A7528(u8 a); +void sub_80A41D4(u8 taskId); +void sub_80A37C0(u8 taskId); + +void RedrawSelectIconForRegisteredItems(void) +{ + u8 i; + + for (i = 0; i < 8; i++) + { + if (!IsItemRegistered( + gCurrentBagPocketItemSlots[gBagPocketScrollStates[sCurrentBagPocket].scrollTop + i].itemId)) + EraseSelectIcon(i); + else + DrawSelectIcon(gBagPocketScrollStates[sCurrentBagPocket].cursorPos); + } +} + +void HandlePopupMenuAction_Register(u8 taskId) +{ + PlaySE(SE_SELECT); + HandleRegisterItem(gSpecialVar_ItemId); + RedrawSelectIconForRegisteredItems(); + sub_80A7528(0); + sub_80A41D4(taskId); + ItemListMenu_InitMenu(); + sub_80A37C0(taskId); +} + +// Multiple Registered Items + +bool8 IsItemRegistered(u16 itemId) +{ + u8 i; + + for (i = 0; i < REGISTERED_ITEMS_COUNT; ++i) + { + if (gRegisteredItems[i] == itemId) + return TRUE; + } + + return FALSE; +} + +void CompactRegisterItems(void) +{ + u16 i; + u16 j; + + for (i = 0; i < REGISTERED_ITEMS_COUNT - 1; i++) + { + for (j = i + 1; j <= REGISTERED_ITEMS_COUNT - 1; j++) + { + if (gRegisteredItems[i] == ITEM_NONE && gRegisteredItems[j] != ITEM_NONE) + { + u16 temp = gRegisteredItems[i]; + gRegisteredItems[i] = gRegisteredItems[j]; + gRegisteredItems[j] = temp; + } + } + } +} + +void RegisterItem(u16 itemId) +{ + u8 i; + + for (i = 0; i < REGISTERED_ITEMS_COUNT; ++i) + { + if (gRegisteredItems[i] == ITEM_NONE) + { + gRegisteredItems[i] = itemId; + break; + } + } +} + +void UnregisterItem(u16 itemId) +{ + u8 i; + + for (i = 0; i < REGISTERED_ITEMS_COUNT; ++i) + { + if (gRegisteredItems[i] == itemId) + { + gRegisteredItems[i] = ITEM_NONE; + CompactRegisterItems(); + break; + } + } +} + +void HandleRegisterItem(u16 itemId) +{ + if (IsItemRegistered(itemId)) + { + UnregisterItem(itemId); + } + else + { + if (!IsItemRegistered(ITEM_NONE)) // Check for free slots + { + gRegisteredItems[0] = ITEM_NONE; + CompactRegisterItems(); + } + + RegisterItem(itemId); + } +} + +void TryRemoveRegisteredItem(u16 itemId) +{ + UnregisterItem(itemId); + RedrawSelectIconForRegisteredItems(); +} + +void EnsureRegisteredItemsInBag(void) +{ + u8 i; + + for (i = 0; i < REGISTERED_ITEMS_COUNT; ++i) + { + if (!CheckBagHasItem(gRegisteredItems[i], 1)) + { + gRegisteredItems[i] = ITEM_NONE; + } + } + + CompactRegisterItems(); +} + +void UseRegisteredKeyItem(u16 item) +{ + u8 taskId; + + ScriptContext2_Enable(); + FreezeObjectEvents(); + PlayerFreeze(); + StopPlayerAvatar(); + gSpecialVar_ItemId = item; + taskId = CreateTask(ItemId_GetFieldFunc(item), 8); + + if (taskId != 0xff) + gTasks[taskId].data[2] = 1; +} + +bool8 UseRegisteredKeyItemFromField(const u8 *script, const u8 *message) +{ + u8 i, numRegisteredItems; + bool8 compatItems = FALSE; + + HideMapNamePopup(); + EnsureRegisteredItemsInBag(); + + for (i = 0, numRegisteredItems = 0; i < REGISTERED_ITEMS_COUNT; ++i) + { + if (gRegisteredItems[i] == ITEM_NONE) + continue; + + numRegisteredItems++; + } + + if (numRegisteredItems) + { + if (numRegisteredItems == 1) + UseRegisteredKeyItem(gRegisteredItems[0]); + else + ScriptContext1_SetupScript(script); + } + else + { + ScriptContext1_SetupScript(Event_NoRegisteredItem); + } + return FALSE; +} + +void DrawRegisteredItemsMultichoice(void) +{ + u8 i, numRegisteredItems; + struct MenuAction actions[REGISTERED_ITEMS_COUNT]; + + for (i = 0, numRegisteredItems = 0; i < REGISTERED_ITEMS_COUNT; ++i) + { + if (gRegisteredItems[i] == ITEM_NONE) + continue; + + actions[numRegisteredItems].func = NULL; + actions[numRegisteredItems].text = ItemId_GetName(gRegisteredItems[i]); + numRegisteredItems++; + } + + DrawMultichoiceMenu(0, 0, numRegisteredItems, actions, FALSE, gLastUsedRegisteredItem); // Store the last used index +} + +static void Task_UseSelectedRegisteredItem(u8 taskId) +{ + // Make sure UseRegisteredKeyItem isn't called until after EventScript_UseRegisteredItem + // is finished. + if (!ScriptContext2_IsEnabled()) + { + UseRegisteredKeyItem(gRegisteredItems[gSpecialVar_Result]); + DestroyTask(taskId); + } +} + +void UseSelectedRegisteredItem(void) +{ + if (gSpecialVar_Result == 127) + return; + + CreateTask(Task_UseSelectedRegisteredItem, 0xFF); + gLastUsedRegisteredItem = gSpecialVar_Result; +} diff --git a/src/new_game.c b/src/new_game.c new file mode 100644 index 0000000..fc8b50f --- /dev/null +++ b/src/new_game.c @@ -0,0 +1,8 @@ +#include "types.h" +#include "bios.h" +#include "item_menu.h" + +void ClearRegisteredItems(void) +{ + CpuFastFill16(0x1, gRegisteredItems, sizeof(gRegisteredItems)); +} \ No newline at end of file diff --git a/src/party_menu.c b/src/party_menu.c index dcb4b3d..8b2734d 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1,16 +1,16 @@ #include "types.h" -#include "pokemon.h" -#include "task.h" -#include "item.h" #include "party_menu.h" +#include "item.h" #include "item_menu.h" -#include "menu.h" #include "item_use.h" +#include "menu.h" +#include "palette.h" +#include "pokemon.h" #include "sound.h" +#include "task.h" #include "text.h" -#include "constants/songs.h" #include "constants/pokemon.h" -#include "palette.h" +#include "constants/songs.h" void Task_ItemUseCallback(u8 taskId) { diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 5b2eb24..6aa4625 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -1,10 +1,10 @@ #include "types.h" -#include "constants/gba.h" +#include "bios.h" #include "main.h" #include "menu.h" #include "palette.h" #include "text.h" -#include "bios.h" +#include "constants/gba.h" void FlashNotDetectedScreen(const u8 *message) { @@ -47,7 +47,7 @@ void FlashNotDetectedScreen(const u8 *message) REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; TransferPlttBuffer(); - *(u16*)PLTT = RGB(17, 18, 31); + *(u16 *)PLTT = RGB(17, 18, 31); REG_SOUNDCNT_X = 0; REG_SOUNDBIAS = 0; } \ No newline at end of file diff --git a/src/summary_screen.c b/src/summary_screen.c index 49d72cc..4136081 100644 --- a/src/summary_screen.c +++ b/src/summary_screen.c @@ -35,13 +35,13 @@ void PrintStatText(struct Pokemon *mon, u8 stat, u8 nature, u8 left, u8 top, u16 switch (mod) { - case 0: // Neutral + case 0: // Neutral *(buffer++) = 0xF; // Black break; - case 1: // Increased + case 1: // Increased *(buffer++) = 0x9; // Red break; - case -1: // Decreased + case -1: // Decreased *(buffer++) = 0x2; // Light Blue break; }