Move gflib srcs and headers to gflib subdir
This commit is contained in:
-210
@@ -1,210 +0,0 @@
|
||||
#include "global.h"
|
||||
|
||||
static void *sHeapStart;
|
||||
static u32 sHeapSize;
|
||||
static u32 malloc_c_unused_0300000c; // needed to align dma3_manager.o(.bss)
|
||||
|
||||
#define MALLOC_SYSTEM_ID 0xA3A3
|
||||
|
||||
struct MemBlock {
|
||||
// Whether this block is currently allocated.
|
||||
bool16 flag;
|
||||
|
||||
// Magic number used for error checking. Should equal MALLOC_SYSTEM_ID.
|
||||
u16 magic;
|
||||
|
||||
// Size of the block (not including this header struct).
|
||||
u32 size;
|
||||
|
||||
// Previous block pointer. Equals sHeapStart if this is the first block.
|
||||
struct MemBlock *prev;
|
||||
|
||||
// Next block pointer. Equals sHeapStart if this is the last block.
|
||||
struct MemBlock *next;
|
||||
|
||||
// Data in the memory block. (Arrays of length 0 are a GNU extension.)
|
||||
u8 data[0];
|
||||
};
|
||||
|
||||
void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size)
|
||||
{
|
||||
struct MemBlock *header = (struct MemBlock *)block;
|
||||
|
||||
header->flag = FALSE;
|
||||
header->magic = MALLOC_SYSTEM_ID;
|
||||
header->size = size;
|
||||
header->prev = prev;
|
||||
header->next = next;
|
||||
}
|
||||
|
||||
void PutFirstMemBlockHeader(void *block, u32 size)
|
||||
{
|
||||
PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock));
|
||||
}
|
||||
|
||||
void *AllocInternal(void *heapStart, u32 size)
|
||||
{
|
||||
struct MemBlock *pos = (struct MemBlock *)heapStart;
|
||||
struct MemBlock *head = pos;
|
||||
struct MemBlock *splitBlock;
|
||||
u32 foundBlockSize;
|
||||
|
||||
// Alignment
|
||||
if (size & 3)
|
||||
size = 4 * ((size / 4) + 1);
|
||||
|
||||
for (;;) {
|
||||
// Loop through the blocks looking for unused block that's big enough.
|
||||
|
||||
if (!pos->flag) {
|
||||
foundBlockSize = pos->size;
|
||||
|
||||
if (foundBlockSize >= size) {
|
||||
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
|
||||
// The block isn't much bigger than the requested size,
|
||||
// so just use it.
|
||||
pos->flag = TRUE;
|
||||
} else {
|
||||
// The block is significantly bigger than the requested
|
||||
// size, so split the rest into a separate block.
|
||||
foundBlockSize -= sizeof(struct MemBlock);
|
||||
foundBlockSize -= size;
|
||||
|
||||
splitBlock = (struct MemBlock *)(pos->data + size);
|
||||
|
||||
pos->flag = TRUE;
|
||||
pos->size = size;
|
||||
|
||||
PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize);
|
||||
|
||||
pos->next = splitBlock;
|
||||
|
||||
if (splitBlock->next != head)
|
||||
splitBlock->next->prev = splitBlock;
|
||||
}
|
||||
|
||||
return pos->data;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos->next == head)
|
||||
return NULL;
|
||||
|
||||
pos = pos->next;
|
||||
}
|
||||
}
|
||||
|
||||
void FreeInternal(void *heapStart, void *pointer)
|
||||
{
|
||||
if (pointer) {
|
||||
struct MemBlock *head = (struct MemBlock *)heapStart;
|
||||
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
|
||||
block->flag = FALSE;
|
||||
|
||||
// If the freed block isn't the last one, merge with the next block
|
||||
// if it's not in use.
|
||||
if (block->next != head) {
|
||||
if (!block->next->flag) {
|
||||
block->size += sizeof(struct MemBlock) + block->next->size;
|
||||
block->next->magic = 0;
|
||||
block->next = block->next->next;
|
||||
if (block->next != head)
|
||||
block->next->prev = block;
|
||||
}
|
||||
}
|
||||
|
||||
// If the freed block isn't the first one, merge with the previous block
|
||||
// if it's not in use.
|
||||
if (block != head) {
|
||||
if (!block->prev->flag) {
|
||||
block->prev->next = block->next;
|
||||
|
||||
if (block->next != head)
|
||||
block->next->prev = block->prev;
|
||||
|
||||
block->magic = 0;
|
||||
block->prev->size += sizeof(struct MemBlock) + block->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *AllocZeroedInternal(void *heapStart, u32 size)
|
||||
{
|
||||
void *mem = AllocInternal(heapStart, size);
|
||||
|
||||
if (mem != NULL) {
|
||||
if (size & 3)
|
||||
size = 4 * ((size / 4) + 1);
|
||||
|
||||
CpuFill32(0, mem, size);
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
bool32 CheckMemBlockInternal(void *heapStart, void *pointer)
|
||||
{
|
||||
struct MemBlock *head = (struct MemBlock *)heapStart;
|
||||
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
|
||||
|
||||
if (block->magic != MALLOC_SYSTEM_ID)
|
||||
return FALSE;
|
||||
|
||||
if (block->next->magic != MALLOC_SYSTEM_ID)
|
||||
return FALSE;
|
||||
|
||||
if (block->next != head && block->next->prev != block)
|
||||
return FALSE;
|
||||
|
||||
if (block->prev->magic != MALLOC_SYSTEM_ID)
|
||||
return FALSE;
|
||||
|
||||
if (block->prev != head && block->prev->next != block)
|
||||
return FALSE;
|
||||
|
||||
if (block->next != head && block->next != (struct MemBlock *)(block->data + block->size))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void InitHeap(void *heapStart, u32 heapSize)
|
||||
{
|
||||
sHeapStart = heapStart;
|
||||
sHeapSize = heapSize;
|
||||
PutFirstMemBlockHeader(heapStart, heapSize);
|
||||
}
|
||||
|
||||
void *Alloc(u32 size)
|
||||
{
|
||||
return AllocInternal(sHeapStart, size);
|
||||
}
|
||||
|
||||
void *AllocZeroed(u32 size)
|
||||
{
|
||||
return AllocZeroedInternal(sHeapStart, size);
|
||||
}
|
||||
|
||||
void Free(void *pointer)
|
||||
{
|
||||
FreeInternal(sHeapStart, pointer);
|
||||
}
|
||||
|
||||
bool32 CheckMemBlock(void *pointer)
|
||||
{
|
||||
return CheckMemBlockInternal(sHeapStart, pointer);
|
||||
}
|
||||
|
||||
bool32 CheckHeap()
|
||||
{
|
||||
struct MemBlock *pos = (struct MemBlock *)sHeapStart;
|
||||
|
||||
do {
|
||||
if (!CheckMemBlockInternal(sHeapStart, pos->data))
|
||||
return FALSE;
|
||||
pos = pos->next;
|
||||
} while (pos != (struct MemBlock *)sHeapStart);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#include "item.h"
|
||||
#include "item_menu.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "new_game.h"
|
||||
#include "party_menu.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_interface.h"
|
||||
#include "decompress.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_interface.h"
|
||||
#include "decompress.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
#include "bg.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "decompress.h"
|
||||
#include "dma3.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "pokemon_icon.h"
|
||||
#include "sprite.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "contest.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "sound.h"
|
||||
#include "sprite.h"
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include "event_data.h"
|
||||
#include "overworld.h"
|
||||
#include "util.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "string_util.h"
|
||||
#include "random.h"
|
||||
#include "task.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "palette.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "string_util.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "constants/battle_anim.h"
|
||||
#include "battle_interface.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "graphics.h"
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
#include "link_rfu.h"
|
||||
#include "load_save.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "m4a.h"
|
||||
#include "palette.h"
|
||||
#include "party_menu.h"
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
#include "task.h"
|
||||
#include "battle_tower.h"
|
||||
#include "party_menu.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "script.h"
|
||||
#include "battle_setup.h"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "main.h"
|
||||
#include "load_save.h"
|
||||
#include "script.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "overworld.h"
|
||||
#include "event_scripts.h"
|
||||
#include "constants/battle_frontier.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "list_menu.h"
|
||||
#include "mail.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "overworld.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "international_string_util.h"
|
||||
#include "sound.h"
|
||||
#include "constants/songs.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "constants/game_stat.h"
|
||||
#include "trainer_hill.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "field_weather.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "overworld.h"
|
||||
#include "palette.h"
|
||||
#include "random.h"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "pokemon.h"
|
||||
#include "trainer_hill.h"
|
||||
#include "party_menu.h"
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
#include "bg.h"
|
||||
#include "palette.h"
|
||||
#include "decompress.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "berry_powder.h"
|
||||
#include "bg.h"
|
||||
#include "event_data.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "multiboot.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "graphics.h"
|
||||
#include "main.h"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "string_util.h"
|
||||
#include "strings.h"
|
||||
#include "bg.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
|
||||
-209
@@ -1,209 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "blit.h"
|
||||
|
||||
void BlitBitmapRect4BitWithoutColorKey(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
|
||||
{
|
||||
BlitBitmapRect4Bit(src, dst, srcX, srcY, dstX, dstY, width, height, 0xFF);
|
||||
}
|
||||
|
||||
void BlitBitmapRect4Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey)
|
||||
{
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
s32 multiplierSrcY;
|
||||
s32 multiplierDstY;
|
||||
s32 loopSrcY, loopDstY;
|
||||
s32 loopSrcX, loopDstX;
|
||||
const u8 *pixelsSrc;
|
||||
u8 *pixelsDst;
|
||||
s32 toOrr;
|
||||
s32 toAnd;
|
||||
s32 toShift;
|
||||
|
||||
if (dst->width - dstX < width)
|
||||
xEnd = (dst->width - dstX) + srcX;
|
||||
else
|
||||
xEnd = srcX + width;
|
||||
|
||||
if (dst->height - dstY < height)
|
||||
yEnd = (dst->height - dstY) + srcY;
|
||||
else
|
||||
yEnd = height + srcY;
|
||||
|
||||
multiplierSrcY = (src->width + (src->width & 7)) >> 3;
|
||||
multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
|
||||
|
||||
if (colorKey == 0xFF)
|
||||
{
|
||||
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
||||
{
|
||||
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
||||
{
|
||||
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
|
||||
pixelsDst = dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + (((loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B);
|
||||
toOrr = ((*pixelsSrc >> ((loopSrcX & 1) << 2)) & 0xF);
|
||||
toShift = ((loopDstX & 1) << 2);
|
||||
toOrr <<= toShift;
|
||||
toAnd = 0xF0 >> (toShift);
|
||||
*pixelsDst = toOrr | (*pixelsDst & toAnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
||||
{
|
||||
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
||||
{
|
||||
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1B);
|
||||
pixelsDst = dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + (((loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 0x1d) >> 0x1B);
|
||||
toOrr = ((*pixelsSrc >> ((loopSrcX & 1) << 2)) & 0xF);
|
||||
if (toOrr != colorKey)
|
||||
{
|
||||
toShift = ((loopDstX & 1) << 2);
|
||||
toOrr <<= toShift;
|
||||
toAnd = 0xF0 >> (toShift);
|
||||
*pixelsDst = toOrr | (*pixelsDst & toAnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue)
|
||||
{
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
s32 multiplierY;
|
||||
s32 loopX, loopY;
|
||||
s32 toOrr1, toOrr2;
|
||||
|
||||
xEnd = x + width;
|
||||
if (xEnd > surface->width)
|
||||
xEnd = surface->width;
|
||||
|
||||
yEnd = y + height;
|
||||
if (yEnd > surface->height)
|
||||
yEnd = surface->height;
|
||||
|
||||
multiplierY = (surface->width + (surface->width & 7)) >> 3;
|
||||
toOrr1 = (u32)(fillValue << 0x1C) >> 0x18;
|
||||
toOrr2 = (fillValue & 0xF);
|
||||
|
||||
for (loopY = y; loopY < yEnd; loopY++)
|
||||
{
|
||||
for (loopX = x; loopX < xEnd; loopX++)
|
||||
{
|
||||
u8 *pixels = surface->pixels + ((loopX >> 1) & 3) + ((loopX >> 3) << 5) + (((loopY >> 3) * multiplierY) << 5) + ((u32)(loopY << 0x1d) >> 0x1B);
|
||||
if ((loopX << 0x1F) != 0)
|
||||
*pixels = toOrr1 | (*pixels & 0xF);
|
||||
else
|
||||
*pixels = toOrr2 | (*pixels & 0xF0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlitBitmapRect4BitTo8Bit(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey, u8 paletteOffset)
|
||||
{
|
||||
s32 palOffsetBits;
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
s32 multiplierSrcY;
|
||||
s32 multiplierDstY;
|
||||
s32 loopSrcY, loopDstY;
|
||||
s32 loopSrcX, loopDstX;
|
||||
const u8 *pixelsSrc;
|
||||
u8 *pixelsDst;
|
||||
s32 colorKeyBits;
|
||||
|
||||
palOffsetBits = (u32)(paletteOffset << 0x1C) >> 0x18;
|
||||
colorKeyBits = (u32)(colorKey << 0x1C) >> 0x18;
|
||||
|
||||
if (dst->width - dstX < width)
|
||||
xEnd = (dst->width - dstX) + srcX;
|
||||
else
|
||||
xEnd = width + srcX;
|
||||
|
||||
if (dst->height - dstY < height)
|
||||
yEnd = (srcY + dst->height) - dstY;
|
||||
else
|
||||
yEnd = srcY + height;
|
||||
|
||||
multiplierSrcY = (src->width + (src->width & 7)) >> 3;
|
||||
multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
|
||||
|
||||
if (colorKey == 0xFF)
|
||||
{
|
||||
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
||||
{
|
||||
pixelsSrc = src->pixels + ((srcX >> 1) & 3) + ((srcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
|
||||
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
||||
{
|
||||
pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
|
||||
if (loopSrcX & 1)
|
||||
{
|
||||
*pixelsDst = palOffsetBits + (*pixelsSrc >> 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
|
||||
*pixelsDst = palOffsetBits + (*pixelsSrc & 0xF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
||||
{
|
||||
pixelsSrc = src->pixels + ((srcX >> 1) & 3) + ((srcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
|
||||
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
||||
{
|
||||
if (loopSrcX & 1)
|
||||
{
|
||||
if ((*pixelsSrc & 0xF0) != colorKeyBits)
|
||||
{
|
||||
pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
|
||||
*pixelsDst = palOffsetBits + (*pixelsSrc >> 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 0x1d) >> 0x1b);
|
||||
if ((*pixelsSrc & 0xF) != colorKey)
|
||||
{
|
||||
pixelsDst = dst->pixels + (loopDstX & 7) + ((loopDstX >> 3) << 6) + (((loopDstY >> 3) * multiplierDstY) << 6) + ((u32)(loopDstY << 0x1d) >> 0x1a);
|
||||
*pixelsDst = palOffsetBits + (*pixelsSrc & 0xF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FillBitmapRect8Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue)
|
||||
{
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
s32 multiplierY;
|
||||
s32 loopX, loopY;
|
||||
|
||||
xEnd = x + width;
|
||||
if (xEnd > surface->width)
|
||||
xEnd = surface->width;
|
||||
|
||||
yEnd = y + height;
|
||||
if (yEnd > surface->height)
|
||||
yEnd = surface->height;
|
||||
|
||||
multiplierY = (surface->width + (surface->width & 7)) >> 3;
|
||||
|
||||
for (loopY = y; loopY < yEnd; loopY++)
|
||||
{
|
||||
for (loopX = x; loopX < xEnd; loopX++)
|
||||
{
|
||||
u8 *pixels = surface->pixels + (loopX & 7) + ((loopX >> 3) << 6) + (((loopY >> 3) * multiplierY) << 6) + ((u32)(loopY << 0x1d) >> 0x1a);
|
||||
*pixels = fillValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#include "field_weather.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "overworld.h"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "bg.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "constants/items.h"
|
||||
#include "constants/event_objects.h"
|
||||
#include "constants/moves.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_gfx_sfx_util.h"
|
||||
#include "bg.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_gfx_sfx_util.h"
|
||||
#include "bg.h"
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include "main.h"
|
||||
#include "task.h"
|
||||
#include "bg.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "window.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "data.h"
|
||||
#include "graphics.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "data.h"
|
||||
#include "decompress.h"
|
||||
#include "pokemon.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "decoration.h"
|
||||
#include "decoration_inventory.h"
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include "easy_chat.h"
|
||||
#include "event_data.h"
|
||||
#include "link.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "random.h"
|
||||
#include "text.h"
|
||||
#include "tv.h"
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "task.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "dma3.h"
|
||||
|
||||
#define MAX_DMA_REQUESTS 128
|
||||
|
||||
#define DMA_REQUEST_COPY32 1
|
||||
#define DMA_REQUEST_FILL32 2
|
||||
#define DMA_REQUEST_COPY16 3
|
||||
#define DMA_REQUEST_FILL16 4
|
||||
|
||||
BSS_DATA struct
|
||||
{
|
||||
const u8 *src;
|
||||
u8 *dest;
|
||||
u16 size;
|
||||
u16 mode;
|
||||
u32 value;
|
||||
} gDma3Requests[MAX_DMA_REQUESTS];
|
||||
|
||||
static volatile bool8 gDma3ManagerLocked;
|
||||
static u8 gDma3RequestCursor;
|
||||
|
||||
void ClearDma3Requests(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
gDma3ManagerLocked = TRUE;
|
||||
gDma3RequestCursor = 0;
|
||||
|
||||
for (i = 0; i < MAX_DMA_REQUESTS; i++)
|
||||
{
|
||||
gDma3Requests[i].size = 0;
|
||||
gDma3Requests[i].src = NULL;
|
||||
gDma3Requests[i].dest = NULL;
|
||||
}
|
||||
|
||||
gDma3ManagerLocked = FALSE;
|
||||
}
|
||||
|
||||
void ProcessDma3Requests(void)
|
||||
{
|
||||
u16 bytesTransferred;
|
||||
|
||||
if (gDma3ManagerLocked)
|
||||
return;
|
||||
|
||||
bytesTransferred = 0;
|
||||
|
||||
// as long as there are DMA requests to process (unless size or vblank is an issue), do not exit
|
||||
while (gDma3Requests[gDma3RequestCursor].size != 0)
|
||||
{
|
||||
bytesTransferred += gDma3Requests[gDma3RequestCursor].size;
|
||||
|
||||
if (bytesTransferred > 40 * 1024)
|
||||
return; // don't transfer more than 40 KiB
|
||||
if (*(u8 *)REG_ADDR_VCOUNT > 224)
|
||||
return; // we're about to leave vblank, stop
|
||||
|
||||
switch (gDma3Requests[gDma3RequestCursor].mode)
|
||||
{
|
||||
case DMA_REQUEST_COPY32: // regular 32-bit copy
|
||||
Dma3CopyLarge32_(gDma3Requests[gDma3RequestCursor].src,
|
||||
gDma3Requests[gDma3RequestCursor].dest,
|
||||
gDma3Requests[gDma3RequestCursor].size);
|
||||
break;
|
||||
case DMA_REQUEST_FILL32: // repeat a single 32-bit value across RAM
|
||||
Dma3FillLarge32_(gDma3Requests[gDma3RequestCursor].value,
|
||||
gDma3Requests[gDma3RequestCursor].dest,
|
||||
gDma3Requests[gDma3RequestCursor].size);
|
||||
break;
|
||||
case DMA_REQUEST_COPY16: // regular 16-bit copy
|
||||
Dma3CopyLarge16_(gDma3Requests[gDma3RequestCursor].src,
|
||||
gDma3Requests[gDma3RequestCursor].dest,
|
||||
gDma3Requests[gDma3RequestCursor].size);
|
||||
break;
|
||||
case DMA_REQUEST_FILL16: // repeat a single 16-bit value across RAM
|
||||
Dma3FillLarge16_(gDma3Requests[gDma3RequestCursor].value,
|
||||
gDma3Requests[gDma3RequestCursor].dest,
|
||||
gDma3Requests[gDma3RequestCursor].size);
|
||||
break;
|
||||
}
|
||||
|
||||
// Free the request
|
||||
gDma3Requests[gDma3RequestCursor].src = NULL;
|
||||
gDma3Requests[gDma3RequestCursor].dest = NULL;
|
||||
gDma3Requests[gDma3RequestCursor].size = 0;
|
||||
gDma3Requests[gDma3RequestCursor].mode = 0;
|
||||
gDma3Requests[gDma3RequestCursor].value = 0;
|
||||
gDma3RequestCursor++;
|
||||
|
||||
if (gDma3RequestCursor >= MAX_DMA_REQUESTS) // loop back to the first DMA request
|
||||
gDma3RequestCursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode)
|
||||
{
|
||||
int cursor;
|
||||
int i = 0;
|
||||
|
||||
gDma3ManagerLocked = TRUE;
|
||||
cursor = gDma3RequestCursor;
|
||||
|
||||
while (i < MAX_DMA_REQUESTS)
|
||||
{
|
||||
if (gDma3Requests[cursor].size == 0) // an empty request was found.
|
||||
{
|
||||
gDma3Requests[cursor].src = src;
|
||||
gDma3Requests[cursor].dest = dest;
|
||||
gDma3Requests[cursor].size = size;
|
||||
|
||||
if (mode == 1)
|
||||
gDma3Requests[cursor].mode = DMA_REQUEST_COPY32;
|
||||
else
|
||||
gDma3Requests[cursor].mode = DMA_REQUEST_COPY16;
|
||||
|
||||
gDma3ManagerLocked = FALSE;
|
||||
return cursor;
|
||||
}
|
||||
if (++cursor >= MAX_DMA_REQUESTS) // loop back to start.
|
||||
cursor = 0;
|
||||
i++;
|
||||
}
|
||||
gDma3ManagerLocked = FALSE;
|
||||
return -1; // no free DMA request was found
|
||||
}
|
||||
|
||||
s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode)
|
||||
{
|
||||
int cursor;
|
||||
int i = 0;
|
||||
|
||||
cursor = gDma3RequestCursor;
|
||||
gDma3ManagerLocked = TRUE;
|
||||
|
||||
while (i < MAX_DMA_REQUESTS)
|
||||
{
|
||||
if (gDma3Requests[cursor].size == 0) // an empty request was found.
|
||||
{
|
||||
gDma3Requests[cursor].dest = dest;
|
||||
gDma3Requests[cursor].size = size;
|
||||
gDma3Requests[cursor].mode = mode;
|
||||
gDma3Requests[cursor].value = value;
|
||||
|
||||
if(mode == 1)
|
||||
gDma3Requests[cursor].mode = DMA_REQUEST_FILL32;
|
||||
else
|
||||
gDma3Requests[cursor].mode = DMA_REQUEST_FILL16;
|
||||
|
||||
gDma3ManagerLocked = FALSE;
|
||||
return cursor;
|
||||
}
|
||||
if (++cursor >= MAX_DMA_REQUESTS) // loop back to start.
|
||||
cursor = 0;
|
||||
i++;
|
||||
}
|
||||
gDma3ManagerLocked = FALSE;
|
||||
return -1; // no free DMA request was found
|
||||
}
|
||||
|
||||
s16 CheckForSpaceForDma3Request(s16 index)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (index == -1) // check if all requests are free
|
||||
{
|
||||
while (i < MAX_DMA_REQUESTS)
|
||||
{
|
||||
if (gDma3Requests[i].size != 0)
|
||||
return -1;
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else // check the specified request
|
||||
{
|
||||
if (gDma3Requests[index].size != 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "dodrio_berry_picking.h"
|
||||
#include "dynamic_placeholder_text_util.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bard_music.h"
|
||||
#include "bg.h"
|
||||
#include "data.h"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
#include "menu.h"
|
||||
#include "trig.h"
|
||||
#include "random.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "dma3.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "bg.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "ereader_helpers.h"
|
||||
#include "link.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "ereader_helpers.h"
|
||||
#include "link.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle_pyramid.h"
|
||||
#include "berry.h"
|
||||
#include "decoration.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_message.h"
|
||||
#include "bg.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "international_string_util.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "palette.h"
|
||||
#include "region_map.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_tower.h"
|
||||
#include "cable_club.h"
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#include "field_player_avatar.h"
|
||||
#include "fieldmap.h"
|
||||
#include "fldeff.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "overworld.h"
|
||||
#include "party_menu.h"
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include "battle_anim.h"
|
||||
#include "event_data.h"
|
||||
#include "recorded_battle.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "sprite.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "text_window.h"
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
#include "data.h"
|
||||
#include "record_mixing.h"
|
||||
#include "strings.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "save.h"
|
||||
#include "load_save.h"
|
||||
#include "battle_dome.h"
|
||||
|
||||
-195
@@ -1,195 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "gpu_regs.h"
|
||||
|
||||
#define GPU_REG_BUF_SIZE 0x60
|
||||
|
||||
#define GPU_REG_BUF(offset) (*(u16 *)(&sGpuRegBuffer[offset]))
|
||||
#define GPU_REG(offset) (*(vu16 *)(REG_BASE + offset))
|
||||
|
||||
#define EMPTY_SLOT 0xFF
|
||||
|
||||
static u8 sGpuRegBuffer[GPU_REG_BUF_SIZE];
|
||||
static u8 sGpuRegWaitingList[GPU_REG_BUF_SIZE];
|
||||
static volatile bool8 sGpuRegBufferLocked;
|
||||
static volatile bool8 sShouldSyncRegIE;
|
||||
static vu16 sRegIE;
|
||||
|
||||
static void CopyBufferedValueToGpuReg(u8 regOffset);
|
||||
static void SyncRegIE(void);
|
||||
static void UpdateRegDispstatIntrBits(u16 regIE);
|
||||
|
||||
void InitGpuRegManager(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < GPU_REG_BUF_SIZE; i++)
|
||||
{
|
||||
sGpuRegBuffer[i] = 0;
|
||||
sGpuRegWaitingList[i] = EMPTY_SLOT;
|
||||
}
|
||||
|
||||
sGpuRegBufferLocked = FALSE;
|
||||
sShouldSyncRegIE = FALSE;
|
||||
sRegIE = 0;
|
||||
}
|
||||
|
||||
static void CopyBufferedValueToGpuReg(u8 regOffset)
|
||||
{
|
||||
if (regOffset == REG_OFFSET_DISPSTAT)
|
||||
{
|
||||
REG_DISPSTAT &= ~(DISPSTAT_HBLANK_INTR | DISPSTAT_VBLANK_INTR);
|
||||
REG_DISPSTAT |= GPU_REG_BUF(REG_OFFSET_DISPSTAT);
|
||||
}
|
||||
else
|
||||
{
|
||||
GPU_REG(regOffset) = GPU_REG_BUF(regOffset);
|
||||
}
|
||||
}
|
||||
|
||||
void CopyBufferedValuesToGpuRegs(void)
|
||||
{
|
||||
if (!sGpuRegBufferLocked)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < GPU_REG_BUF_SIZE; i++)
|
||||
{
|
||||
u8 regOffset = sGpuRegWaitingList[i];
|
||||
if (regOffset == EMPTY_SLOT)
|
||||
return;
|
||||
CopyBufferedValueToGpuReg(regOffset);
|
||||
sGpuRegWaitingList[i] = EMPTY_SLOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetGpuReg(u8 regOffset, u16 value)
|
||||
{
|
||||
if (regOffset < GPU_REG_BUF_SIZE)
|
||||
{
|
||||
u16 vcount;
|
||||
|
||||
GPU_REG_BUF(regOffset) = value;
|
||||
vcount = REG_VCOUNT & 0xFF;
|
||||
|
||||
if ((vcount >= 161 && vcount <= 225) || (REG_DISPCNT & DISPCNT_FORCED_BLANK))
|
||||
{
|
||||
CopyBufferedValueToGpuReg(regOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 i;
|
||||
|
||||
sGpuRegBufferLocked = TRUE;
|
||||
|
||||
for (i = 0; i < GPU_REG_BUF_SIZE && sGpuRegWaitingList[i] != EMPTY_SLOT; i++)
|
||||
{
|
||||
if (sGpuRegWaitingList[i] == regOffset)
|
||||
{
|
||||
sGpuRegBufferLocked = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sGpuRegWaitingList[i] = regOffset;
|
||||
sGpuRegBufferLocked = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetGpuReg_ForcedBlank(u8 regOffset, u16 value)
|
||||
{
|
||||
if (regOffset < GPU_REG_BUF_SIZE)
|
||||
{
|
||||
GPU_REG_BUF(regOffset) = value;
|
||||
|
||||
if (REG_DISPCNT & DISPCNT_FORCED_BLANK)
|
||||
{
|
||||
CopyBufferedValueToGpuReg(regOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 i;
|
||||
|
||||
sGpuRegBufferLocked = TRUE;
|
||||
|
||||
for (i = 0; i < GPU_REG_BUF_SIZE && sGpuRegWaitingList[i] != EMPTY_SLOT; i++)
|
||||
{
|
||||
if (sGpuRegWaitingList[i] == regOffset)
|
||||
{
|
||||
sGpuRegBufferLocked = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sGpuRegWaitingList[i] = regOffset;
|
||||
sGpuRegBufferLocked = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u16 GetGpuReg(u8 regOffset)
|
||||
{
|
||||
if (regOffset == REG_OFFSET_DISPSTAT)
|
||||
return REG_DISPSTAT;
|
||||
|
||||
if (regOffset == REG_OFFSET_VCOUNT)
|
||||
return REG_VCOUNT;
|
||||
|
||||
return GPU_REG_BUF(regOffset);
|
||||
}
|
||||
|
||||
void SetGpuRegBits(u8 regOffset, u16 mask)
|
||||
{
|
||||
u16 regValue = GPU_REG_BUF(regOffset);
|
||||
SetGpuReg(regOffset, regValue | mask);
|
||||
}
|
||||
|
||||
void ClearGpuRegBits(u8 regOffset, u16 mask)
|
||||
{
|
||||
u16 regValue = GPU_REG_BUF(regOffset);
|
||||
SetGpuReg(regOffset, regValue & ~mask);
|
||||
}
|
||||
|
||||
static void SyncRegIE(void)
|
||||
{
|
||||
if (sShouldSyncRegIE)
|
||||
{
|
||||
u16 temp = REG_IME;
|
||||
REG_IME = 0;
|
||||
REG_IE = sRegIE;
|
||||
REG_IME = temp;
|
||||
sShouldSyncRegIE = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void EnableInterrupts(u16 mask)
|
||||
{
|
||||
sRegIE |= mask;
|
||||
sShouldSyncRegIE = TRUE;
|
||||
SyncRegIE();
|
||||
UpdateRegDispstatIntrBits(sRegIE);
|
||||
}
|
||||
|
||||
void DisableInterrupts(u16 mask)
|
||||
{
|
||||
sRegIE &= ~mask;
|
||||
sShouldSyncRegIE = TRUE;
|
||||
SyncRegIE();
|
||||
UpdateRegDispstatIntrBits(sRegIE);
|
||||
}
|
||||
|
||||
static void UpdateRegDispstatIntrBits(u16 regIE)
|
||||
{
|
||||
u16 oldValue = GetGpuReg(REG_OFFSET_DISPSTAT) & (DISPSTAT_HBLANK_INTR | DISPSTAT_VBLANK_INTR);
|
||||
u16 newValue = 0;
|
||||
|
||||
if (regIE & INTR_FLAG_VBLANK)
|
||||
newValue |= DISPSTAT_VBLANK_INTR;
|
||||
|
||||
if (regIE & INTR_FLAG_HBLANK)
|
||||
newValue |= DISPSTAT_HBLANK_INTR;
|
||||
|
||||
if (oldValue != newValue)
|
||||
SetGpuReg(REG_OFFSET_DISPSTAT, newValue);
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#include "pokemon.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
#include "main.h"
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include "task.h"
|
||||
#include "title_screen.h"
|
||||
#include "libgcnmultiboot.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "link.h"
|
||||
#include "multiboot_pokemon_colosseum.h"
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
#include "event_data.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "secret_base.h"
|
||||
#include "item_menu.h"
|
||||
#include "strings.h"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "decompress.h"
|
||||
#include "graphics.h"
|
||||
#include "item_icon.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "sprite.h"
|
||||
#include "constants/items.h"
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include "link.h"
|
||||
#include "mail.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "map_name_popup.h"
|
||||
#include "menu.h"
|
||||
#include "money.h"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "m4a.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "reset_save_heap.h"
|
||||
#include "save.h"
|
||||
#include "bg.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "berry_blender.h"
|
||||
#include "decompress.h"
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include "trig.h"
|
||||
#include "decompress.h"
|
||||
#include "palette.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "strings.h"
|
||||
#include "sound.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "berry_powder.h"
|
||||
#include "item.h"
|
||||
#include "load_save.h"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
#include "bg.h"
|
||||
#include "pokemon_icon.h"
|
||||
#include "constants/species.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "easy_chat.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "crt0.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "link.h"
|
||||
#include "link_rfu.h"
|
||||
#include "librfu.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_setup.h"
|
||||
#include "bg.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "blit.h"
|
||||
#include "dma3.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle_main.h"
|
||||
#include "contest_effect.h"
|
||||
#include "data.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "palette.h"
|
||||
#include "decompress.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "pokemon_icon.h"
|
||||
#include "union_room.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "overworld.h"
|
||||
#include "script.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "script.h"
|
||||
#include "mevent.h"
|
||||
#include "mevent_server.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "util.h"
|
||||
#include "link.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "event_data.h"
|
||||
#include "event_object_movement.h"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "event_object_movement.h"
|
||||
#include "fieldmap.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "mossdeep_gym.h"
|
||||
#include "script_movement.h"
|
||||
#include "constants/event_object_movement_constants.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "move_relearner.h"
|
||||
#include "list_menu.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "menu_specialized.h"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "main.h"
|
||||
#include "text.h"
|
||||
#include "task.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "text_window.h"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "naming_screen.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "task.h"
|
||||
#include "sprite.h"
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
#include "link_rfu.h"
|
||||
#include "load_save.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "m4a.h"
|
||||
#include "map_name_popup.h"
|
||||
#include "match_call.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_controllers.h"
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include "list_menu.h"
|
||||
#include "mail.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "overworld.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "battle_message.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "bg.h"
|
||||
#include "data.h"
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include "graphics.h"
|
||||
#include "international_string_util.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "m4a.h"
|
||||
#include "overworld.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "overworld.h"
|
||||
#include "palette.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "bg.h"
|
||||
#include "m4a.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "pokedex_cry_screen.h"
|
||||
#include "sound.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "apprentice.h"
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle_anim.h"
|
||||
#include "bg.h"
|
||||
#include "data.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "data.h"
|
||||
#include "decompress.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "item.h"
|
||||
#include "link.h"
|
||||
#include "m4a.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "mon_markings.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "overworld.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "bg.h"
|
||||
#include "palette.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "graphics.h"
|
||||
#include "bg.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "menu.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "random.h"
|
||||
#include "constants/items.h"
|
||||
#include "text.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "string_util.h"
|
||||
#include "palette.h"
|
||||
#include "save.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "util.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#include "main.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "palette.h"
|
||||
#include "party_menu.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "save.h"
|
||||
#include "new_game.h"
|
||||
#include "overworld.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
|
||||
void sub_81700F8(void)
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "rom_8034C54.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
#include "main.h"
|
||||
#include "battle_main.h"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "rom_81520A8.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "main.h"
|
||||
#include "rom_8034C54.h"
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "coins.h"
|
||||
#include "decompress.h"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_setup.h"
|
||||
#include "decoration.h"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
#include "item_menu.h"
|
||||
#include "list_menu.h"
|
||||
#include "main.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "money.h"
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include "util.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "bg.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "coins.h"
|
||||
|
||||
-1758
File diff suppressed because it is too large
Load Diff
@@ -1,784 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
|
||||
EWRAM_DATA u8 gStringVar1[0x100] = {0};
|
||||
EWRAM_DATA u8 gStringVar2[0x100] = {0};
|
||||
EWRAM_DATA u8 gStringVar3[0x100] = {0};
|
||||
EWRAM_DATA u8 gStringVar4[0x3E8] = {0};
|
||||
EWRAM_DATA static u8 sUnknownStringVar[16] = {0};
|
||||
|
||||
static const u8 sDigits[] = __("0123456789ABCDEF");
|
||||
|
||||
static const s32 sPowersOfTen[] =
|
||||
{
|
||||
1,
|
||||
10,
|
||||
100,
|
||||
1000,
|
||||
10000,
|
||||
100000,
|
||||
1000000,
|
||||
10000000,
|
||||
100000000,
|
||||
1000000000,
|
||||
};
|
||||
|
||||
extern const u8 gExpandedPlaceholder_Empty[];
|
||||
extern const u8 gExpandedPlaceholder_Kun[];
|
||||
extern const u8 gExpandedPlaceholder_Chan[];
|
||||
extern const u8 gExpandedPlaceholder_Sapphire[];
|
||||
extern const u8 gExpandedPlaceholder_Ruby[];
|
||||
extern const u8 gExpandedPlaceholder_Emerald[];
|
||||
extern const u8 gExpandedPlaceholder_Aqua[];
|
||||
extern const u8 gExpandedPlaceholder_Magma[];
|
||||
extern const u8 gExpandedPlaceholder_Archie[];
|
||||
extern const u8 gExpandedPlaceholder_Maxie[];
|
||||
extern const u8 gExpandedPlaceholder_Kyogre[];
|
||||
extern const u8 gExpandedPlaceholder_Groudon[];
|
||||
extern const u8 gExpandedPlaceholder_Brendan[];
|
||||
extern const u8 gExpandedPlaceholder_May[];
|
||||
|
||||
u8 *StringCopy10(u8 *dest, const u8 *src)
|
||||
{
|
||||
u8 i;
|
||||
u32 limit = 10;
|
||||
|
||||
for (i = 0; i < limit; i++)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
|
||||
if (dest[i] == EOS)
|
||||
return &dest[i];
|
||||
}
|
||||
|
||||
dest[i] = EOS;
|
||||
return &dest[i];
|
||||
}
|
||||
|
||||
u8 *StringGetEnd10(u8 *str)
|
||||
{
|
||||
u8 i;
|
||||
u32 limit = 10;
|
||||
|
||||
for (i = 0; i < limit; i++)
|
||||
if (str[i] == EOS)
|
||||
return &str[i];
|
||||
|
||||
str[i] = EOS;
|
||||
return &str[i];
|
||||
}
|
||||
|
||||
u8 *StringCopy7(u8 *dest, const u8 *src)
|
||||
{
|
||||
s32 i;
|
||||
s32 limit = 7;
|
||||
|
||||
for (i = 0; i < limit; i++)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
|
||||
if (dest[i] == EOS)
|
||||
return &dest[i];
|
||||
}
|
||||
|
||||
dest[i] = EOS;
|
||||
return &dest[i];
|
||||
}
|
||||
|
||||
u8 *StringCopy(u8 *dest, const u8 *src)
|
||||
{
|
||||
while (*src != EOS)
|
||||
{
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u8 *StringAppend(u8 *dest, const u8 *src)
|
||||
{
|
||||
while (*dest != EOS)
|
||||
dest++;
|
||||
|
||||
return StringCopy(dest, src);
|
||||
}
|
||||
|
||||
u8 *StringCopyN(u8 *dest, const u8 *src, u8 n)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
dest[i] = src[i];
|
||||
|
||||
return &dest[n];
|
||||
}
|
||||
|
||||
u8 *StringAppendN(u8 *dest, const u8 *src, u8 n)
|
||||
{
|
||||
while (*dest != EOS)
|
||||
dest++;
|
||||
|
||||
return StringCopyN(dest, src, n);
|
||||
}
|
||||
|
||||
u16 StringLength(const u8 *str)
|
||||
{
|
||||
u16 length = 0;
|
||||
|
||||
while (str[length] != EOS)
|
||||
length++;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
s32 StringCompare(const u8 *str1, const u8 *str2)
|
||||
{
|
||||
while (*str1 == *str2)
|
||||
{
|
||||
if (*str1 == EOS)
|
||||
return 0;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
s32 StringCompareN(const u8 *str1, const u8 *str2, u32 n)
|
||||
{
|
||||
while (*str1 == *str2)
|
||||
{
|
||||
if (*str1 == EOS)
|
||||
return 0;
|
||||
str1++;
|
||||
str2++;
|
||||
if (--n == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
bool8 IsStringLengthAtLeast(const u8 *str, s32 n)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (str[i] && str[i] != EOS)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 *ConvertIntToDecimalStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 n)
|
||||
{
|
||||
enum { WAITING_FOR_NONZERO_DIGIT, WRITING_DIGITS, WRITING_SPACES } state;
|
||||
s32 powerOfTen;
|
||||
s32 largestPowerOfTen = sPowersOfTen[n - 1];
|
||||
|
||||
state = WAITING_FOR_NONZERO_DIGIT;
|
||||
|
||||
if (mode == STR_CONV_MODE_RIGHT_ALIGN)
|
||||
state = WRITING_SPACES;
|
||||
|
||||
if (mode == STR_CONV_MODE_LEADING_ZEROS)
|
||||
state = WRITING_DIGITS;
|
||||
|
||||
for (powerOfTen = largestPowerOfTen; powerOfTen > 0; powerOfTen /= 10)
|
||||
{
|
||||
u8 c;
|
||||
u16 digit = value / powerOfTen;
|
||||
s32 temp = value - (powerOfTen * digit);
|
||||
|
||||
if (state == WRITING_DIGITS)
|
||||
{
|
||||
u8 *out = dest++;
|
||||
|
||||
if (digit <= 9)
|
||||
c = sDigits[digit];
|
||||
else
|
||||
c = CHAR_QUESTION_MARK;
|
||||
|
||||
*out = c;
|
||||
}
|
||||
else if (digit != 0 || powerOfTen == 1)
|
||||
{
|
||||
u8 *out;
|
||||
state = WRITING_DIGITS;
|
||||
out = dest++;
|
||||
|
||||
if (digit <= 9)
|
||||
c = sDigits[digit];
|
||||
else
|
||||
c = CHAR_QUESTION_MARK;
|
||||
|
||||
*out = c;
|
||||
}
|
||||
else if (state == WRITING_SPACES)
|
||||
{
|
||||
*dest++ = 0x77;
|
||||
}
|
||||
|
||||
value = temp;
|
||||
}
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u8 *ConvertUIntToDecimalStringN(u8 *dest, u32 value, enum StringConvertMode mode, u8 n)
|
||||
{
|
||||
enum { WAITING_FOR_NONZERO_DIGIT, WRITING_DIGITS, WRITING_SPACES } state;
|
||||
s32 powerOfTen;
|
||||
s32 largestPowerOfTen = sPowersOfTen[n - 1];
|
||||
|
||||
state = WAITING_FOR_NONZERO_DIGIT;
|
||||
|
||||
if (mode == STR_CONV_MODE_RIGHT_ALIGN)
|
||||
state = WRITING_SPACES;
|
||||
|
||||
if (mode == STR_CONV_MODE_LEADING_ZEROS)
|
||||
state = WRITING_DIGITS;
|
||||
|
||||
for (powerOfTen = largestPowerOfTen; powerOfTen > 0; powerOfTen /= 10)
|
||||
{
|
||||
u8 c;
|
||||
u16 digit = value / powerOfTen;
|
||||
u32 temp = value - (powerOfTen * digit);
|
||||
|
||||
if (state == WRITING_DIGITS)
|
||||
{
|
||||
u8 *out = dest++;
|
||||
|
||||
if (digit <= 9)
|
||||
c = sDigits[digit];
|
||||
else
|
||||
c = CHAR_QUESTION_MARK;
|
||||
|
||||
*out = c;
|
||||
}
|
||||
else if (digit != 0 || powerOfTen == 1)
|
||||
{
|
||||
u8 *out;
|
||||
state = WRITING_DIGITS;
|
||||
out = dest++;
|
||||
|
||||
if (digit <= 9)
|
||||
c = sDigits[digit];
|
||||
else
|
||||
c = CHAR_QUESTION_MARK;
|
||||
|
||||
*out = c;
|
||||
}
|
||||
else if (state == WRITING_SPACES)
|
||||
{
|
||||
*dest++ = 0x77;
|
||||
}
|
||||
|
||||
value = temp;
|
||||
}
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 n)
|
||||
{
|
||||
enum { WAITING_FOR_NONZERO_DIGIT, WRITING_DIGITS, WRITING_SPACES } state;
|
||||
u8 i;
|
||||
s32 powerOfSixteen;
|
||||
s32 largestPowerOfSixteen = 1;
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
largestPowerOfSixteen *= 16;
|
||||
|
||||
state = WAITING_FOR_NONZERO_DIGIT;
|
||||
|
||||
if (mode == STR_CONV_MODE_RIGHT_ALIGN)
|
||||
state = WRITING_SPACES;
|
||||
|
||||
if (mode == STR_CONV_MODE_LEADING_ZEROS)
|
||||
state = WRITING_DIGITS;
|
||||
|
||||
for (powerOfSixteen = largestPowerOfSixteen; powerOfSixteen > 0; powerOfSixteen /= 16)
|
||||
{
|
||||
u8 c;
|
||||
u32 digit = value / powerOfSixteen;
|
||||
s32 temp = value % powerOfSixteen;
|
||||
|
||||
if (state == WRITING_DIGITS)
|
||||
{
|
||||
char *out = dest++;
|
||||
|
||||
if (digit <= 0xF)
|
||||
c = sDigits[digit];
|
||||
else
|
||||
c = CHAR_QUESTION_MARK;
|
||||
|
||||
*out = c;
|
||||
}
|
||||
else if (digit != 0 || powerOfSixteen == 1)
|
||||
{
|
||||
char *out;
|
||||
state = WRITING_DIGITS;
|
||||
out = dest++;
|
||||
|
||||
if (digit <= 0xF)
|
||||
c = sDigits[digit];
|
||||
else
|
||||
c = CHAR_QUESTION_MARK;
|
||||
|
||||
*out = c;
|
||||
}
|
||||
else if (state == WRITING_SPACES)
|
||||
{
|
||||
*dest++ = 0x77;
|
||||
}
|
||||
|
||||
value = temp;
|
||||
}
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
u8 c = *src++;
|
||||
u8 placeholderId;
|
||||
const u8 *expandedString;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case PLACEHOLDER_BEGIN:
|
||||
placeholderId = *src++;
|
||||
expandedString = GetExpandedPlaceholder(placeholderId);
|
||||
dest = StringExpandPlaceholders(dest, expandedString);
|
||||
break;
|
||||
case EXT_CTRL_CODE_BEGIN:
|
||||
*dest++ = c;
|
||||
c = *src++;
|
||||
*dest++ = c;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0x07:
|
||||
case 0x09:
|
||||
case 0x0F:
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x17:
|
||||
case 0x18:
|
||||
break;
|
||||
case 0x04:
|
||||
*dest++ = *src++;
|
||||
case 0x0B:
|
||||
*dest++ = *src++;
|
||||
default:
|
||||
*dest++ = *src++;
|
||||
}
|
||||
break;
|
||||
case EOS:
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
case CHAR_PROMPT_SCROLL:
|
||||
case CHAR_PROMPT_CLEAR:
|
||||
case CHAR_NEWLINE:
|
||||
default:
|
||||
*dest++ = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u8 *StringBraille(u8 *dest, const u8 *src)
|
||||
{
|
||||
u8 setBrailleFont[] = { EXT_CTRL_CODE_BEGIN, 0x06, 0x06, EOS };
|
||||
u8 gotoLine2[] = { CHAR_NEWLINE, EXT_CTRL_CODE_BEGIN, 0x0E, 0x02, EOS };
|
||||
|
||||
dest = StringCopy(dest, setBrailleFont);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
u8 c = *src++;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case EOS:
|
||||
*dest = c;
|
||||
return dest;
|
||||
case CHAR_NEWLINE:
|
||||
dest = StringCopy(dest, gotoLine2);
|
||||
break;
|
||||
default:
|
||||
*dest++ = c;
|
||||
*dest++ = c + 0x40;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_UnknownStringVar(void)
|
||||
{
|
||||
return sUnknownStringVar;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_PlayerName(void)
|
||||
{
|
||||
return gSaveBlock2Ptr->playerName;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_StringVar1(void)
|
||||
{
|
||||
return gStringVar1;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_StringVar2(void)
|
||||
{
|
||||
return gStringVar2;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_StringVar3(void)
|
||||
{
|
||||
return gStringVar3;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_KunChan(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->playerGender == MALE)
|
||||
return gExpandedPlaceholder_Kun;
|
||||
else
|
||||
return gExpandedPlaceholder_Chan;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_RivalName(void)
|
||||
{
|
||||
if (gSaveBlock2Ptr->playerGender == MALE)
|
||||
return gExpandedPlaceholder_May;
|
||||
else
|
||||
return gExpandedPlaceholder_Brendan;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Version(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Emerald;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Aqua(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Aqua;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Magma(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Magma;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Archie(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Archie;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Maxie(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Maxie;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Kyogre(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Kyogre;
|
||||
}
|
||||
|
||||
static const u8 *ExpandPlaceholder_Groudon(void)
|
||||
{
|
||||
return gExpandedPlaceholder_Groudon;
|
||||
}
|
||||
|
||||
const u8 *GetExpandedPlaceholder(u32 id)
|
||||
{
|
||||
typedef const u8 *(*ExpandPlaceholderFunc)(void);
|
||||
|
||||
static const ExpandPlaceholderFunc funcs[] =
|
||||
{
|
||||
ExpandPlaceholder_UnknownStringVar,
|
||||
ExpandPlaceholder_PlayerName,
|
||||
ExpandPlaceholder_StringVar1,
|
||||
ExpandPlaceholder_StringVar2,
|
||||
ExpandPlaceholder_StringVar3,
|
||||
ExpandPlaceholder_KunChan,
|
||||
ExpandPlaceholder_RivalName,
|
||||
ExpandPlaceholder_Version,
|
||||
ExpandPlaceholder_Aqua,
|
||||
ExpandPlaceholder_Magma,
|
||||
ExpandPlaceholder_Archie,
|
||||
ExpandPlaceholder_Maxie,
|
||||
ExpandPlaceholder_Kyogre,
|
||||
ExpandPlaceholder_Groudon,
|
||||
};
|
||||
|
||||
if (id >= ARRAY_COUNT(funcs))
|
||||
return gExpandedPlaceholder_Empty;
|
||||
else
|
||||
return funcs[id]();
|
||||
}
|
||||
|
||||
u8 *StringFill(u8 *dest, u8 c, u16 n)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
*dest++ = c;
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u8 *StringCopyPadded(u8 *dest, const u8 *src, u8 c, u16 n)
|
||||
{
|
||||
while (*src != EOS)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
|
||||
if (n)
|
||||
n--;
|
||||
}
|
||||
|
||||
n--;
|
||||
|
||||
while (n != (u16)-1)
|
||||
{
|
||||
*dest++ = c;
|
||||
n--;
|
||||
}
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u8 *StringFillWithTerminator(u8 *dest, u16 n)
|
||||
{
|
||||
return StringFill(dest, EOS, n);
|
||||
}
|
||||
|
||||
u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = n - 1; i != (u32)-1; i--)
|
||||
{
|
||||
if (*src == EOS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dest++ = *src++;
|
||||
if (*(src - 1) == CHAR_SPECIAL_F9)
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
u32 StringLength_Multibyte(const u8 *str)
|
||||
{
|
||||
u32 length = 0;
|
||||
|
||||
while (*str != EOS)
|
||||
{
|
||||
if (*str == CHAR_SPECIAL_F9)
|
||||
str++;
|
||||
str++;
|
||||
length++;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
u8 *WriteColorChangeControlCode(u8 *dest, u32 colorType, u8 color)
|
||||
{
|
||||
*dest = EXT_CTRL_CODE_BEGIN;
|
||||
dest++;
|
||||
|
||||
switch (colorType)
|
||||
{
|
||||
case 0:
|
||||
*dest = 1;
|
||||
dest++;
|
||||
break;
|
||||
case 1:
|
||||
*dest = 3;
|
||||
dest++;
|
||||
break;
|
||||
case 2:
|
||||
*dest = 2;
|
||||
dest++;
|
||||
break;
|
||||
}
|
||||
|
||||
*dest = color;
|
||||
dest++;
|
||||
*dest = EOS;
|
||||
return dest;
|
||||
}
|
||||
|
||||
bool32 IsStringJapanese(u8 *str)
|
||||
{
|
||||
while (*str != EOS)
|
||||
{
|
||||
if (*str <= 0xA0)
|
||||
if (*str != CHAR_SPACE)
|
||||
return TRUE;
|
||||
str++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_800924C(u8 *str, s32 n)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; *str != EOS && i < n; i++)
|
||||
{
|
||||
if (*str <= 0xA0)
|
||||
if (*str != CHAR_SPACE)
|
||||
return TRUE;
|
||||
str++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 GetExtCtrlCodeLength(u8 code)
|
||||
{
|
||||
static const u8 lengths[] =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
4,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
};
|
||||
|
||||
u8 length = 0;
|
||||
if (code < ARRAY_COUNT(lengths))
|
||||
length = lengths[code];
|
||||
return length;
|
||||
}
|
||||
|
||||
static const u8 *SkipExtCtrlCode(const u8 *s)
|
||||
{
|
||||
while (*s == EXT_CTRL_CODE_BEGIN)
|
||||
{
|
||||
s++;
|
||||
s += GetExtCtrlCodeLength(*s);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2)
|
||||
{
|
||||
s32 retVal = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
str1 = SkipExtCtrlCode(str1);
|
||||
str2 = SkipExtCtrlCode(str2);
|
||||
|
||||
if (*str1 > *str2)
|
||||
break;
|
||||
|
||||
if (*str1 < *str2)
|
||||
{
|
||||
retVal = -1;
|
||||
if (*str2 == EOS)
|
||||
retVal = 1;
|
||||
}
|
||||
|
||||
if (*str1 == EOS)
|
||||
return retVal;
|
||||
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
|
||||
retVal = 1;
|
||||
|
||||
if (*str1 == EOS)
|
||||
retVal = -1;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void ConvertInternationalString(u8 *s, u8 language)
|
||||
{
|
||||
if (language == LANGUAGE_JAPANESE)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
StripExtCtrlCodes(s);
|
||||
i = StringLength(s);
|
||||
s[i++] = EXT_CTRL_CODE_BEGIN;
|
||||
s[i++] = 22;
|
||||
s[i++] = EOS;
|
||||
|
||||
i--;
|
||||
|
||||
while (i != (u8)-1)
|
||||
{
|
||||
s[i + 2] = s[i];
|
||||
i--;
|
||||
}
|
||||
|
||||
s[0] = EXT_CTRL_CODE_BEGIN;
|
||||
s[1] = 21;
|
||||
}
|
||||
}
|
||||
|
||||
void StripExtCtrlCodes(u8 *str)
|
||||
{
|
||||
u16 srcIndex = 0;
|
||||
u16 destIndex = 0;
|
||||
while (str[srcIndex] != EOS)
|
||||
{
|
||||
if (str[srcIndex] == EXT_CTRL_CODE_BEGIN)
|
||||
{
|
||||
srcIndex++;
|
||||
srcIndex += GetExtCtrlCodeLength(str[srcIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
str[destIndex++] = str[srcIndex++];
|
||||
}
|
||||
}
|
||||
str[destIndex] = EOS;
|
||||
}
|
||||
-2540
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "battle_anim.h"
|
||||
#include "battle_interface.h"
|
||||
#include "bg.h"
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "window.h"
|
||||
#include "alloc.h"
|
||||
#include "malloc.h"
|
||||
#include "link.h"
|
||||
#include "bg.h"
|
||||
#include "sound.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user