Merge remote-tracking branch 'upstream/master' into upper-hand
This commit is contained in:
commit
b21275dfe9
13 changed files with 199 additions and 203 deletions
119
gflib/malloc.c
119
gflib/malloc.c
|
@ -1,23 +1,40 @@
|
|||
#include "global.h"
|
||||
#include "malloc.h"
|
||||
#if TESTING
|
||||
#include "test/test.h"
|
||||
#endif
|
||||
|
||||
static void *sHeapStart;
|
||||
static u32 sHeapSize;
|
||||
|
||||
EWRAM_DATA u8 gHeap[HEAP_SIZE] = {0};
|
||||
|
||||
#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->allocated = FALSE;
|
||||
header->locationHi = 0;
|
||||
header->flag = FALSE;
|
||||
header->magic = MALLOC_SYSTEM_ID;
|
||||
header->size = size;
|
||||
header->locationLo = 0;
|
||||
header->prev = prev;
|
||||
header->next = next;
|
||||
}
|
||||
|
@ -27,7 +44,7 @@ void PutFirstMemBlockHeader(void *block, u32 size)
|
|||
PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock));
|
||||
}
|
||||
|
||||
void *AllocInternal(void *heapStart, u32 size, const char *location)
|
||||
void *AllocInternal(void *heapStart, u32 size)
|
||||
{
|
||||
struct MemBlock *pos = (struct MemBlock *)heapStart;
|
||||
struct MemBlock *head = pos;
|
||||
|
@ -38,18 +55,24 @@ void *AllocInternal(void *heapStart, u32 size, const char *location)
|
|||
if (size & 3)
|
||||
size = 4 * ((size / 4) + 1);
|
||||
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
// Loop through the blocks looking for unused block that's big enough.
|
||||
|
||||
if (!pos->allocated) {
|
||||
if (!pos->flag)
|
||||
{
|
||||
foundBlockSize = pos->size;
|
||||
|
||||
if (foundBlockSize >= size) {
|
||||
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
|
||||
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->allocated = TRUE;
|
||||
} else {
|
||||
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);
|
||||
|
@ -57,7 +80,7 @@ void *AllocInternal(void *heapStart, u32 size, const char *location)
|
|||
|
||||
splitBlock = (struct MemBlock *)(pos->data + size);
|
||||
|
||||
pos->allocated = TRUE;
|
||||
pos->flag = TRUE;
|
||||
pos->size = size;
|
||||
|
||||
PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize);
|
||||
|
@ -68,35 +91,12 @@ void *AllocInternal(void *heapStart, u32 size, const char *location)
|
|||
splitBlock->next->prev = splitBlock;
|
||||
}
|
||||
|
||||
pos->locationHi = ((uintptr_t)location) >> 14;
|
||||
pos->locationLo = (uintptr_t)location;
|
||||
|
||||
return pos->data;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos->next == head)
|
||||
{
|
||||
#if TESTING
|
||||
const struct MemBlock *head = HeapHead();
|
||||
const struct MemBlock *block = head;
|
||||
do
|
||||
{
|
||||
if (block->allocated)
|
||||
{
|
||||
const char *location = MemBlockLocation(block);
|
||||
if (location)
|
||||
MgbaPrintf_("%s: %d bytes allocated", location, block->size);
|
||||
else
|
||||
MgbaPrintf_("<unknown>: %d bytes allocated", block->size);
|
||||
}
|
||||
block = block->next;
|
||||
}
|
||||
while (block != head);
|
||||
Test_ExitWithResult(TEST_RESULT_ERROR, "%s: OOM allocating %d bytes", location, size);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pos = pos->next;
|
||||
}
|
||||
|
@ -104,15 +104,18 @@ void *AllocInternal(void *heapStart, u32 size, const char *location)
|
|||
|
||||
void FreeInternal(void *heapStart, void *pointer)
|
||||
{
|
||||
if (pointer) {
|
||||
if (pointer)
|
||||
{
|
||||
struct MemBlock *head = (struct MemBlock *)heapStart;
|
||||
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
|
||||
block->allocated = FALSE;
|
||||
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->allocated) {
|
||||
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;
|
||||
|
@ -123,8 +126,10 @@ void FreeInternal(void *heapStart, void *pointer)
|
|||
|
||||
// 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->allocated) {
|
||||
if (block != head)
|
||||
{
|
||||
if (!block->prev->flag)
|
||||
{
|
||||
block->prev->next = block->next;
|
||||
|
||||
if (block->next != head)
|
||||
|
@ -137,11 +142,12 @@ void FreeInternal(void *heapStart, void *pointer)
|
|||
}
|
||||
}
|
||||
|
||||
void *AllocZeroedInternal(void *heapStart, u32 size, const char *location)
|
||||
void *AllocZeroedInternal(void *heapStart, u32 size)
|
||||
{
|
||||
void *mem = AllocInternal(heapStart, size, location);
|
||||
void *mem = AllocInternal(heapStart, size);
|
||||
|
||||
if (mem != NULL) {
|
||||
if (mem != NULL)
|
||||
{
|
||||
if (size & 3)
|
||||
size = 4 * ((size / 4) + 1);
|
||||
|
||||
|
@ -184,14 +190,14 @@ void InitHeap(void *heapStart, u32 heapSize)
|
|||
PutFirstMemBlockHeader(heapStart, heapSize);
|
||||
}
|
||||
|
||||
void *Alloc_(u32 size, const char *location)
|
||||
void *Alloc(u32 size)
|
||||
{
|
||||
return AllocInternal(sHeapStart, size, location);
|
||||
return AllocInternal(sHeapStart, size);
|
||||
}
|
||||
|
||||
void *AllocZeroed_(u32 size, const char *location)
|
||||
void *AllocZeroed(u32 size)
|
||||
{
|
||||
return AllocZeroedInternal(sHeapStart, size, location);
|
||||
return AllocZeroedInternal(sHeapStart, size);
|
||||
}
|
||||
|
||||
void Free(void *pointer)
|
||||
|
@ -216,16 +222,3 @@ bool32 CheckHeap()
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const struct MemBlock *HeapHead(void)
|
||||
{
|
||||
return (const struct MemBlock *)sHeapStart;
|
||||
}
|
||||
|
||||
const char *MemBlockLocation(const struct MemBlock *block)
|
||||
{
|
||||
if (!block->allocated)
|
||||
return NULL;
|
||||
|
||||
return (const char *)(ROM_START | (block->locationHi << 14) | block->locationLo);
|
||||
}
|
||||
|
|
|
@ -9,18 +9,6 @@
|
|||
#define METATILE_BattleDome_Door_Lobby 0x209
|
||||
#define METATILE_BattleDome_Door_PreBattleRoom 0x20A
|
||||
|
||||
// gTileset_BattleFrontierOutsideEast
|
||||
#define METATILE_BattleFrontierOutsideEast_Door 0x3FC
|
||||
#define METATILE_BattleFrontierOutsideEast_Door_BattleArena 0x291
|
||||
#define METATILE_BattleFrontierOutsideEast_Door_BattleTower 0x329
|
||||
#define METATILE_BattleFrontierOutsideEast_Door_Sliding 0x396
|
||||
|
||||
// gTileset_BattleFrontierOutsideWest
|
||||
#define METATILE_BattleFrontierOutsideWest_Door 0x3FC
|
||||
#define METATILE_BattleFrontierOutsideWest_Door_BattleDome 0x28A
|
||||
#define METATILE_BattleFrontierOutsideWest_Door_BattleFactory 0x263
|
||||
#define METATILE_BattleFrontierOutsideWest_Door_Sliding 0x396
|
||||
|
||||
// gTileset_BattleFrontier
|
||||
#define METATILE_BattleFrontier_CorridorOpenDoor_Bottom 0x20F
|
||||
#define METATILE_BattleFrontier_CorridorOpenDoor_Top 0x207
|
||||
|
@ -36,6 +24,18 @@
|
|||
#define METATILE_BattleFrontier_Elevator_Top1 0x32A
|
||||
#define METATILE_BattleFrontier_Elevator_Top2 0x32B
|
||||
|
||||
// gTileset_BattleFrontierOutsideEast
|
||||
#define METATILE_BattleFrontierOutsideEast_Door 0x3FC
|
||||
#define METATILE_BattleFrontierOutsideEast_Door_BattleArena 0x291
|
||||
#define METATILE_BattleFrontierOutsideEast_Door_BattleTower 0x329
|
||||
#define METATILE_BattleFrontierOutsideEast_Door_Sliding 0x396
|
||||
|
||||
// gTileset_BattleFrontierOutsideWest
|
||||
#define METATILE_BattleFrontierOutsideWest_Door 0x3FC
|
||||
#define METATILE_BattleFrontierOutsideWest_Door_BattleDome 0x28A
|
||||
#define METATILE_BattleFrontierOutsideWest_Door_BattleFactory 0x263
|
||||
#define METATILE_BattleFrontierOutsideWest_Door_Sliding 0x396
|
||||
|
||||
// gTileset_BattlePalace
|
||||
#define METATILE_BattlePalace_Door 0x219
|
||||
|
||||
|
@ -272,6 +272,18 @@
|
|||
#define METATILE_Lavaridge_NormalGrass 0x206
|
||||
#define METATILE_Lavaridge_RockWall 0x274
|
||||
|
||||
// gTileset_Lilycove
|
||||
#define METATILE_Lilycove_Door 0x246
|
||||
#define METATILE_Lilycove_Door_DeptStore 0x30C
|
||||
#define METATILE_Lilycove_Door_SafariZone 0x32D
|
||||
#define METATILE_Lilycove_Door_Wooden 0x28E
|
||||
#define METATILE_Lilycove_Wailmer0 0x290
|
||||
#define METATILE_Lilycove_Wailmer0_Alt 0x298
|
||||
#define METATILE_Lilycove_Wailmer1 0x291
|
||||
#define METATILE_Lilycove_Wailmer1_Alt 0x299
|
||||
#define METATILE_Lilycove_Wailmer2 0x2A0
|
||||
#define METATILE_Lilycove_Wailmer3 0x2A1
|
||||
|
||||
// gTileset_LilycoveMuseum
|
||||
#define METATILE_LilycoveMuseum_Painting0_Left 0x25A
|
||||
#define METATILE_LilycoveMuseum_Painting0_Right 0x25B
|
||||
|
@ -284,17 +296,31 @@
|
|||
#define METATILE_LilycoveMuseum_Painting4_Left 0x262
|
||||
#define METATILE_LilycoveMuseum_Painting4_Right 0x263
|
||||
|
||||
// gTileset_Lilycove
|
||||
#define METATILE_Lilycove_Door 0x246
|
||||
#define METATILE_Lilycove_Door_DeptStore 0x30C
|
||||
#define METATILE_Lilycove_Door_SafariZone 0x32D
|
||||
#define METATILE_Lilycove_Door_Wooden 0x28E
|
||||
#define METATILE_Lilycove_Wailmer0 0x290
|
||||
#define METATILE_Lilycove_Wailmer0_Alt 0x298
|
||||
#define METATILE_Lilycove_Wailmer1 0x291
|
||||
#define METATILE_Lilycove_Wailmer1_Alt 0x299
|
||||
#define METATILE_Lilycove_Wailmer2 0x2A0
|
||||
#define METATILE_Lilycove_Wailmer3 0x2A1
|
||||
// gTileset_Mauville
|
||||
#define METATILE_Mauville_DeepSand_BottomMid 0x259
|
||||
#define METATILE_Mauville_DeepSand_Center 0x251
|
||||
#define METATILE_Mauville_Door 0x2AC
|
||||
#define METATILE_Mauville_Door_BattleTent 0x3D4
|
||||
#define METATILE_Mauville_Door_CyclingRoad 0x289
|
||||
#define METATILE_Mauville_Door_Verdanturf 0x3A1
|
||||
#define METATILE_Mauville_MirageTower_Tile0 0x3D8
|
||||
#define METATILE_Mauville_MirageTower_Tile1 0x3D9
|
||||
#define METATILE_Mauville_MirageTower_Tile10 0x3E4
|
||||
#define METATILE_Mauville_MirageTower_Tile11 0x3E5
|
||||
#define METATILE_Mauville_MirageTower_Tile2 0x3DA
|
||||
#define METATILE_Mauville_MirageTower_Tile3 0x3E0
|
||||
#define METATILE_Mauville_MirageTower_Tile4 0x3E1
|
||||
#define METATILE_Mauville_MirageTower_Tile5 0x3E2
|
||||
#define METATILE_Mauville_MirageTower_Tile6 0x3E8
|
||||
#define METATILE_Mauville_MirageTower_Tile7 0x3E9
|
||||
#define METATILE_Mauville_MirageTower_Tile8 0x3EA
|
||||
#define METATILE_Mauville_MirageTower_Tile9 0x3F0
|
||||
#define METATILE_Mauville_MirageTower_TileA 0x3F1
|
||||
#define METATILE_Mauville_MirageTower_TileB 0x3F2
|
||||
#define METATILE_Mauville_MirageTower_TileC 0x3DB
|
||||
#define METATILE_Mauville_MirageTower_TileD 0x3DC
|
||||
#define METATILE_Mauville_MirageTower_TileE 0x3DD
|
||||
#define METATILE_Mauville_MirageTower_TileF 0x3E3
|
||||
|
||||
// gTileset_MauvilleGym
|
||||
#define METATILE_MauvilleGym_FloorTile 0x21A
|
||||
|
@ -325,38 +351,16 @@
|
|||
#define METATILE_MauvilleGym_RedBeamV1_On 0x241
|
||||
#define METATILE_MauvilleGym_RedBeamV2_On 0x249
|
||||
|
||||
// gTileset_Mauville
|
||||
#define METATILE_Mauville_DeepSand_BottomMid 0x259
|
||||
#define METATILE_Mauville_DeepSand_Center 0x251
|
||||
#define METATILE_Mauville_Door 0x2AC
|
||||
#define METATILE_Mauville_Door_BattleTent 0x3D4
|
||||
#define METATILE_Mauville_Door_CyclingRoad 0x289
|
||||
#define METATILE_Mauville_Door_Verdanturf 0x3A1
|
||||
#define METATILE_Mauville_MirageTower_Tile0 0x3D8
|
||||
#define METATILE_Mauville_MirageTower_Tile1 0x3D9
|
||||
#define METATILE_Mauville_MirageTower_Tile10 0x3E4
|
||||
#define METATILE_Mauville_MirageTower_Tile11 0x3E5
|
||||
#define METATILE_Mauville_MirageTower_Tile2 0x3DA
|
||||
#define METATILE_Mauville_MirageTower_Tile3 0x3E0
|
||||
#define METATILE_Mauville_MirageTower_Tile4 0x3E1
|
||||
#define METATILE_Mauville_MirageTower_Tile5 0x3E2
|
||||
#define METATILE_Mauville_MirageTower_Tile6 0x3E8
|
||||
#define METATILE_Mauville_MirageTower_Tile7 0x3E9
|
||||
#define METATILE_Mauville_MirageTower_Tile8 0x3EA
|
||||
#define METATILE_Mauville_MirageTower_Tile9 0x3F0
|
||||
#define METATILE_Mauville_MirageTower_TileA 0x3F1
|
||||
#define METATILE_Mauville_MirageTower_TileB 0x3F2
|
||||
#define METATILE_Mauville_MirageTower_TileC 0x3DB
|
||||
#define METATILE_Mauville_MirageTower_TileD 0x3DC
|
||||
#define METATILE_Mauville_MirageTower_TileE 0x3DD
|
||||
#define METATILE_Mauville_MirageTower_TileF 0x3E3
|
||||
|
||||
// gTileset_MeteorFalls
|
||||
#define METATILE_MeteorFalls_CaveEntrance_Bottom 0x24E
|
||||
#define METATILE_MeteorFalls_CaveEntrance_Left 0x24D
|
||||
#define METATILE_MeteorFalls_CaveEntrance_Right 0x24F
|
||||
#define METATILE_MeteorFalls_CaveEntrance_Top 0x246
|
||||
|
||||
// gTileset_Mossdeep
|
||||
#define METATILE_Mossdeep_Door 0x2A1
|
||||
#define METATILE_Mossdeep_Door_SpaceCenter 0x2ED
|
||||
|
||||
// gTileset_MossdeepGameCorner
|
||||
#define METATILE_MossdeepGameCorner_CounterClosed_Bottom 0x232
|
||||
#define METATILE_MossdeepGameCorner_CounterClosed_Top 0x22A
|
||||
|
@ -366,10 +370,6 @@
|
|||
// gTileset_MossdeepGym
|
||||
#define METATILE_MossdeepGym_YellowArrow_Right 0x250
|
||||
|
||||
// gTileset_Mossdeep
|
||||
#define METATILE_Mossdeep_Door 0x2A1
|
||||
#define METATILE_Mossdeep_Door_SpaceCenter 0x2ED
|
||||
|
||||
// gTileset_Pacifidlog
|
||||
#define METATILE_Pacifidlog_Door 0x21A
|
||||
#define METATILE_Pacifidlog_FloatingLogs_HorizontalLeft 0x250
|
||||
|
@ -388,6 +388,11 @@
|
|||
#define METATILE_Pacifidlog_SubmergedLogs_VerticalBottom 0x262
|
||||
#define METATILE_Pacifidlog_SubmergedLogs_VerticalTop 0x25A
|
||||
|
||||
// gTileset_Petalburg
|
||||
#define METATILE_Petalburg_Door_BirchsLab 0x249
|
||||
#define METATILE_Petalburg_Door_Littleroot 0x248
|
||||
#define METATILE_Petalburg_Door_Oldale 0x287
|
||||
|
||||
// gTileset_PetalburgGym
|
||||
#define METATILE_PetalburgGym_Door 0x224
|
||||
#define METATILE_PetalburgGym_RoomEntrance_Left 0x210
|
||||
|
@ -398,11 +403,6 @@
|
|||
#define METATILE_PetalburgGym_SlidingDoor_Frame3 0x21B
|
||||
#define METATILE_PetalburgGym_SlidingDoor_Frame4 0x21C
|
||||
|
||||
// gTileset_Petalburg
|
||||
#define METATILE_Petalburg_Door_BirchsLab 0x249
|
||||
#define METATILE_Petalburg_Door_Littleroot 0x248
|
||||
#define METATILE_Petalburg_Door_Oldale 0x287
|
||||
|
||||
// gTileset_PokemonCenter
|
||||
#define METATILE_PokemonCenter_CounterBarrier 0x25D
|
||||
#define METATILE_PokemonCenter_Door_CableClub 0x264
|
||||
|
@ -431,14 +431,6 @@
|
|||
#define METATILE_PokemonCenter_Floor_ShadowTop 0x21E
|
||||
#define METATILE_PokemonCenter_Floor_ShadowTop_Alt 0x2DC
|
||||
|
||||
// gTileset_RSMossdeepGym
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Down 0x205
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Left 0x20C
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Right 0x204
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Up 0x20D
|
||||
#define METATILE_RSMossdeepGym_Switch_Down 0x239
|
||||
#define METATILE_RSMossdeepGym_Switch_Up 0x238
|
||||
|
||||
// gTileset_Rustboro
|
||||
#define METATILE_Rustboro_Door_Gray 0x21F
|
||||
#define METATILE_Rustboro_Door_Tan 0x22F
|
||||
|
@ -726,11 +718,6 @@
|
|||
#define METATILE_Slateport_Door 0x2DC
|
||||
#define METATILE_Slateport_Door_BattleTent 0x393
|
||||
|
||||
// gTileset_SootopolisGym
|
||||
#define METATILE_SootopolisGym_Ice_Broken 0x206
|
||||
#define METATILE_SootopolisGym_Ice_Cracked 0x20E
|
||||
#define METATILE_SootopolisGym_Stairs 0x207
|
||||
|
||||
// gTileset_Sootopolis
|
||||
#define METATILE_Sootopolis_Door 0x21E
|
||||
#define METATILE_Sootopolis_Door_Closed 0x248
|
||||
|
@ -738,6 +725,11 @@
|
|||
#define METATILE_Sootopolis_GymDoor_Closed 0x250
|
||||
#define METATILE_Sootopolis_RoughWater 0x290
|
||||
|
||||
// gTileset_SootopolisGym
|
||||
#define METATILE_SootopolisGym_Ice_Broken 0x206
|
||||
#define METATILE_SootopolisGym_Ice_Cracked 0x20E
|
||||
#define METATILE_SootopolisGym_Stairs 0x207
|
||||
|
||||
// gTileset_TrainerHill
|
||||
#define METATILE_TrainerHill_CounterDoor 0x334
|
||||
#define METATILE_TrainerHill_Door_Elevator_Lobby 0x32C
|
||||
|
@ -787,4 +779,12 @@
|
|||
#define METATILE_Underwater_FloorShadow 0x228
|
||||
#define METATILE_Underwater_RockWall 0x21E
|
||||
|
||||
// Other
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Down 0x205
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Left 0x20C
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Right 0x204
|
||||
#define METATILE_RSMossdeepGym_RedArrow_Up 0x20D
|
||||
#define METATILE_RSMossdeepGym_Switch_Down 0x239
|
||||
#define METATILE_RSMossdeepGym_Switch_Up 0x238
|
||||
|
||||
#endif // GUARD_METATILE_LABELS_H
|
||||
|
|
|
@ -2,7 +2,6 @@ ENTRY(Start)
|
|||
|
||||
gNumMusicPlayers = 4;
|
||||
gMaxLines = 0;
|
||||
gInitialMainCB2 = CB2_InitCopyrightScreenAfterBootup;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
|
@ -13,31 +12,19 @@ MEMORY
|
|||
|
||||
SECTIONS {
|
||||
|
||||
|
||||
.ewram ORIGIN(EWRAM) : AT (__ewram_lma)
|
||||
ewram 0x2000000 (NOLOAD) :
|
||||
ALIGN(4)
|
||||
{
|
||||
__ewram_start = .;
|
||||
*(.ewram*)
|
||||
__ewram_end = .;
|
||||
/*
|
||||
We link malloc.o here to prevent `gHeap` from landing in the middle of EWRAM.
|
||||
Otherwise this causes corruption issues on some ld versions
|
||||
*/
|
||||
gflib/malloc.o(ewram_data);
|
||||
src/*.o(ewram_data);
|
||||
gflib/*.o(ewram_data);
|
||||
} > EWRAM
|
||||
|
||||
.ewram.sbss (NOLOAD) :
|
||||
ALIGN(4)
|
||||
{
|
||||
src/*.o(.sbss);
|
||||
gflib/*.o(.sbss);
|
||||
} > EWRAM
|
||||
|
||||
.iwram ORIGIN(IWRAM) : AT (__iwram_lma)
|
||||
ALIGN(4)
|
||||
{
|
||||
__iwram_start = .;
|
||||
*(.iwram*);
|
||||
__iwram_end = .;
|
||||
} > IWRAM
|
||||
|
||||
.iwram.bss (NOLOAD) :
|
||||
iwram 0x3000000 (NOLOAD) :
|
||||
ALIGN(4)
|
||||
{
|
||||
src/*.o(.bss);
|
||||
|
@ -52,17 +39,16 @@ SECTIONS {
|
|||
gflib/*.o(COMMON);
|
||||
*libc.a:*.o(COMMON);
|
||||
*libnosys.a:*.o(COMMON);
|
||||
gStackBase = .;
|
||||
} > IWRAM
|
||||
|
||||
/* BEGIN ROM DATA */
|
||||
. = 0x8000000;
|
||||
|
||||
.text ORIGIN(ROM) :
|
||||
.text :
|
||||
ALIGN(4)
|
||||
{
|
||||
src/rom_header.o(.text*);
|
||||
src/rom_header_gf.o(.text.*);
|
||||
src/rom_header_rhh.o(.text.*);
|
||||
src/crt0.o(.text);
|
||||
src/main.o(.text);
|
||||
gflib/*.o(.text*);
|
||||
|
@ -126,7 +112,7 @@ SECTIONS {
|
|||
*libc.a:*.o(.rodata*);
|
||||
*libc.a:*.o(.data*);
|
||||
src/libisagbprn.o(.rodata);
|
||||
} > ROM =0
|
||||
} =0
|
||||
|
||||
multiboot_data :
|
||||
ALIGN(4)
|
||||
|
@ -136,28 +122,18 @@ SECTIONS {
|
|||
data/multiboot_pokemon_colosseum.o(.rodata);
|
||||
} > ROM =0
|
||||
|
||||
anim_mon_front_pic_data :
|
||||
ALIGN(4)
|
||||
{
|
||||
src/anim_mon_front_pics.o(.rodata);
|
||||
} > ROM =0
|
||||
|
||||
gfx_data :
|
||||
ALIGN(4)
|
||||
{
|
||||
src/graphics.o(.rodata);
|
||||
} > ROM =0
|
||||
|
||||
.data.iwram :
|
||||
ALIGN(4)
|
||||
{
|
||||
__iwram_lma = .;
|
||||
. = . + (__iwram_end - __iwram_start);
|
||||
} > ROM = 0
|
||||
|
||||
.data.ewram :
|
||||
ALIGN(4)
|
||||
{
|
||||
__ewram_lma = .;
|
||||
. = . + (__ewram_end - __ewram_start);
|
||||
} > ROM = 0
|
||||
|
||||
__rom_end = .;
|
||||
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
|
|
|
@ -694,11 +694,13 @@ static void AnimTask_SpiteTargetShadow_Step1(u8 taskId)
|
|||
task->data[3] = 16;
|
||||
task->data[13] = GetAnimBattlerSpriteId(ANIM_TARGET);
|
||||
task->data[4] = OBJ_PLTT_ID2(gSprites[task->data[13]].oam.paletteNum);
|
||||
if (position == 1) {
|
||||
if (position == 1)
|
||||
{
|
||||
u16 mask = DISPCNT_BG1_ON;
|
||||
mask2 = mask;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
u16 mask = DISPCNT_BG2_ON;
|
||||
mask2 = mask;
|
||||
}
|
||||
|
|
|
@ -2050,7 +2050,8 @@ static void UpdateSpeedFromHit(u16 cmd)
|
|||
switch (cmd)
|
||||
{
|
||||
case LINKCMD_BLENDER_SCORE_BEST:
|
||||
if (sBerryBlender->speed < 1500) {
|
||||
if (sBerryBlender->speed < 1500)
|
||||
{
|
||||
sBerryBlender->speed += (384 / sNumPlayersToSpeedDivisor[sBerryBlender->numPlayers]);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -138,7 +138,8 @@ static void ContestEffect_StartleFrontMon(void)
|
|||
u8 idx = 0;
|
||||
u8 a = eContestAppealResults.contestant;
|
||||
|
||||
if (eContestAppealResults.turnOrder[a] != 0) {
|
||||
if (eContestAppealResults.turnOrder[a] != 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONTESTANT_COUNT; i++)
|
||||
|
|
|
@ -218,7 +218,8 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u
|
|||
// While the remaining space will be filled with actual data
|
||||
if (object_size == 6)
|
||||
{
|
||||
for (k = 0; k < 256; k++) {
|
||||
for (k = 0; k < 256; k++)
|
||||
{
|
||||
*dest = 0;
|
||||
dest++;
|
||||
}
|
||||
|
@ -228,14 +229,16 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u
|
|||
{
|
||||
if (object_size == 6)
|
||||
{
|
||||
for (k = 0; k < 32; k++) {
|
||||
for (k = 0; k < 32; k++)
|
||||
{
|
||||
*dest = 0;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy tile data
|
||||
for (k = 0; k < 32 * object_size; k++) {
|
||||
for (k = 0; k < 32 * object_size; k++)
|
||||
{
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
|
@ -243,7 +246,8 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u
|
|||
|
||||
if (object_size == 6)
|
||||
{
|
||||
for (k = 0; k < 32; k++) {
|
||||
for (k = 0; k < 32; k++)
|
||||
{
|
||||
*dest = 0;
|
||||
dest++;
|
||||
}
|
||||
|
@ -252,7 +256,8 @@ static void UNUSED StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u
|
|||
|
||||
if (object_size == 6)
|
||||
{
|
||||
for (k = 0; k < 256; k++) {
|
||||
for (k = 0; k < 256; k++)
|
||||
{
|
||||
*dest = 0;
|
||||
dest++;
|
||||
}
|
||||
|
|
|
@ -1340,7 +1340,8 @@ static void DecorationItemsMenuAction_AttemptPlace(u8 taskId)
|
|||
else
|
||||
{
|
||||
ConvertIntToDecimalStringN(gStringVar1, sDecorationContext.size, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
||||
if (sDecorationContext.isPlayerRoom == FALSE) {
|
||||
if (sDecorationContext.isPlayerRoom == FALSE)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, gText_NoMoreDecorations);
|
||||
}
|
||||
else
|
||||
|
@ -2254,7 +2255,8 @@ static void Task_PutAwayDecoration(u8 taskId)
|
|||
gTasks[taskId].tState = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (!gPaletteFade.active) {
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
DrawWholeMapView();
|
||||
ScriptContext_SetupScript(SecretBase_EventScript_PutAwayDecoration);
|
||||
ClearDialogWindowAndFrame(0, TRUE);
|
||||
|
|
|
@ -1091,32 +1091,39 @@ static void InitResults_Member(void)
|
|||
{
|
||||
u8 i;
|
||||
|
||||
switch (sGame->state) {
|
||||
switch (sGame->state)
|
||||
{
|
||||
case 0:
|
||||
if (SendBlock(0, sGame->berryResults[sGame->timer], sizeof(sGame->berryResults))) {
|
||||
if (SendBlock(0, sGame->berryResults[sGame->timer], sizeof(sGame->berryResults)))
|
||||
{
|
||||
sGame->playersReceived = 0;
|
||||
sGame->state++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (IsLinkTaskFinished()) {
|
||||
if (IsLinkTaskFinished())
|
||||
{
|
||||
sGame->state++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (AllLinkBlocksReceived()) {
|
||||
for (i = 0; i < sGame->numPlayers; i++) {
|
||||
if (AllLinkBlocksReceived())
|
||||
{
|
||||
for (i = 0; i < sGame->numPlayers; i++)
|
||||
{
|
||||
memcpy(sGame->berryResults, gBlockRecvBuffer, sizeof(sGame->berryResults));
|
||||
sGame->playersReceived = sGame->numPlayers;
|
||||
}
|
||||
}
|
||||
if (sGame->playersReceived >= sGame->numPlayers) {
|
||||
if (sGame->playersReceived >= sGame->numPlayers)
|
||||
{
|
||||
sGame->timer++;
|
||||
sGame->state++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (WaitFanfare(TRUE)) {
|
||||
if (WaitFanfare(TRUE))
|
||||
{
|
||||
sGame->maxBerriesPickedInRow = sGame->berryResults[sGame->multiplayerId][BERRY_IN_ROW];
|
||||
SetGameFunc(FUNC_RESULTS);
|
||||
FadeOutAndPlayNewMapMusic(MUS_RG_VICTORY_WILD, 4);
|
||||
|
|
|
@ -102,8 +102,10 @@ static s32 _putsAscii(char *s, s32 len, void *buf)
|
|||
p0 = b->buffer;
|
||||
|
||||
/* Copy to buffer */
|
||||
for (i = 0; i < len; i++) {
|
||||
if(b->pbuffer == b->buffer + b->buffer_len - 1) {
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if(b->pbuffer == b->buffer + b->buffer_len - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
*(b->pbuffer ++) = s[i];
|
||||
|
@ -125,8 +127,10 @@ static s32 _putsEncoded(char *s, s32 len, void *buf)
|
|||
p0 = b->buffer;
|
||||
|
||||
/* Copy to buffer */
|
||||
for (i = 0; i < len; i++) {
|
||||
if(b->pbuffer == b->buffer + b->buffer_len - 1) {
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if(b->pbuffer == b->buffer + b->buffer_len - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
*(b->pbuffer ++) = mini_pchar_decode(s[i]);
|
||||
|
@ -191,7 +195,8 @@ static s32 mini_pad(char* ptr, s32 len, char pad_char, s32 pad_to, char *buffer)
|
|||
char * pbuffer = buffer;
|
||||
if(pad_to == 0)
|
||||
pad_to = len;
|
||||
if (len > pad_to) {
|
||||
if (len > pad_to)
|
||||
{
|
||||
len = pad_to;
|
||||
overflow = TRUE;
|
||||
}
|
||||
|
|
|
@ -3324,7 +3324,8 @@ static void SpriteCB_FlashMatchingLines(struct Sprite *sprite)
|
|||
if (sprite->sNumFullFlashes)
|
||||
sprite->sNumFullFlashes--;
|
||||
}
|
||||
else if (sprite->sColor >= maxColorChange) {
|
||||
else if (sprite->sColor >= maxColorChange)
|
||||
{
|
||||
// Reached peak darkness, reverse
|
||||
sprite->sColorIncr = -sprite->sColorIncr;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ static unsigned char *ConvertBitDepth(unsigned char *src, int srcBitDepth, int d
|
|||
|
||||
for (j = 8 - srcBitDepth; j >= 0; j -= srcBitDepth)
|
||||
{
|
||||
unsigned char pixel = (srcByte >> j) % (1 << destBitDepth);
|
||||
unsigned char pixel = ((srcByte >> j) % (1 << srcBitDepth)) % (1 << destBitDepth);
|
||||
*dest |= pixel << destBit;
|
||||
destBit -= destBitDepth;
|
||||
if (destBit < 0)
|
||||
|
|
|
@ -105,10 +105,13 @@ int main(int argc, char *argv[])
|
|||
});
|
||||
|
||||
env.add_callback("cleanString", 1, [](Arguments& args) {
|
||||
string badChars = ".'{} \n\t-\u00e9";
|
||||
string str = args.at(0)->get<string>();
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
if (badChars.find(str[i]) != std::string::npos) {
|
||||
// This code is not Unicode aware, so UTF-8 is not easily parsable without introducing
|
||||
// another library. Just filter out any non-alphanumeric characters for now.
|
||||
// TODO: proper Unicode string normalization
|
||||
if ((i == 0 && isdigit(str[i]))
|
||||
|| !isalnum(str[i])) {
|
||||
str[i] = '_';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue