Skip to content

Commit

Permalink
Allow for multiple Key Item Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseurae committed Jul 4, 2023
1 parent 57f8572 commit ca72353
Show file tree
Hide file tree
Showing 25 changed files with 762 additions and 336 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<details>

Expand Down
3 changes: 3 additions & 0 deletions config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
; --------

Expand Down
2 changes: 1 addition & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
57 changes: 37 additions & 20 deletions include/bios.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
62 changes: 31 additions & 31 deletions include/constants/gba.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
#define WIN_RANGE(a, b) (((a) << 8) | (b))
Loading

0 comments on commit ca72353

Please sign in to comment.