diff --git a/src/gba/Flash.cpp b/src/gba/Flash.cpp index 9700abe8..2cceb6d4 100644 --- a/src/gba/Flash.cpp +++ b/src/gba/Flash.cpp @@ -127,11 +127,11 @@ void flashSetSize(int size) // Added to make 64k saves compatible with 128k ones // (allow wrongfuly set 64k saves to work for Pokemon games) if ((size == 0x20000) && (flashSize == 0x10000)) - memcpy((u8*)(flashSaveMemory + 0x10000), (u8*)(flashSaveMemory), 0x10000); + memcpy((uint8_t*)(flashSaveMemory + 0x10000), (uint8_t*)(flashSaveMemory), 0x10000); flashSize = size; } -u8 flashRead(u32 address) +uint8_t flashRead(uint32_t address) { // log("Reading %08x from %08x\n", address, reg[15].I); // log("Current read state is %d\n", flashReadState); @@ -158,7 +158,7 @@ u8 flashRead(u32 address) return 0; } -void flashSaveDecide(u32 address, u8 byte) +void flashSaveDecide(uint32_t address, uint8_t byte) { if (saveType == 1) return; @@ -175,14 +175,14 @@ void flashSaveDecide(u32 address, u8 byte) (*cpuSaveGameFunc)(address, byte); } -void flashDelayedWrite(u32 address, u8 byte) +void flashDelayedWrite(uint32_t address, uint8_t byte) { saveType = 3; cpuSaveGameFunc = flashWrite; flashWrite(address, byte); } -void flashWrite(u32 address, u8 byte) +void flashWrite(uint32_t address, uint8_t byte) { // log("Writing %02x at %08x\n", byte, address); // log("Current state is %d\n", flashState); diff --git a/src/gba/Flash.h b/src/gba/Flash.h index 16873c17..3088f814 100644 --- a/src/gba/Flash.h +++ b/src/gba/Flash.h @@ -4,22 +4,22 @@ #define FLASH_128K_SZ 0x20000 #ifdef __LIBRETRO__ -extern void flashSaveGame(u8*& data); -extern void flashReadGame(const u8*& data, int); +extern void flashSaveGame(uint8_t*& data); +extern void flashReadGame(const uint8_t*& data, int); #else extern void flashSaveGame(gzFile _gzFile); extern void flashReadGame(gzFile _gzFile, int version); extern void flashReadGameSkip(gzFile _gzFile, int version); #endif -extern u8 flashRead(u32 address); -extern void flashWrite(u32 address, u8 byte); -extern void flashDelayedWrite(u32 address, u8 byte); +extern uint8_t flashRead(uint32_t address); +extern void flashWrite(uint32_t address, uint8_t byte); +extern void flashDelayedWrite(uint32_t address, uint8_t byte); #ifdef __LIBRETRO__ extern uint8_t* flashSaveMemory; #else -extern u8 flashSaveMemory[FLASH_128K_SZ]; +extern uint8_t flashSaveMemory[FLASH_128K_SZ]; #endif -extern void flashSaveDecide(u32 address, u8 byte); +extern void flashSaveDecide(uint32_t address, uint8_t byte); extern void flashReset(); extern void flashSetSize(int size); extern void flashInit(); diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index 62fe0970..2e00d2d1 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -42,15 +42,15 @@ bool debugger; int SWITicks = 0; int IRQTicks = 0; -u32 mastercode = 0; +uint32_t mastercode = 0; int layerEnableDelay = 0; bool busPrefetch = false; bool busPrefetchEnable = false; -u32 busPrefetchCount = 0; +uint32_t busPrefetchCount = 0; int cpuDmaTicksToUpdate = 0; int cpuDmaCount = 0; bool cpuDmaHack = false; -u32 cpuDmaLast = 0; +uint32_t cpuDmaLast = 0; int dummyAddress = 0; bool cpuBreakLoop = false; @@ -66,7 +66,7 @@ bool cpuFlashEnabled = true; bool cpuEEPROMEnabled = true; bool cpuEEPROMSensorEnabled = false; -u32 cpuPrefetch[2]; +uint32_t cpuPrefetch[2]; int cpuTotalTicks = 0; #ifdef PROFILING @@ -76,51 +76,51 @@ static profile_segment* profilSegment = NULL; #endif #ifdef BKPT_SUPPORT -u8 freezeWorkRAM[0x40000]; -u8 freezeInternalRAM[0x8000]; -u8 freezeVRAM[0x18000]; -u8 freezePRAM[0x400]; -u8 freezeOAM[0x400]; +uint8_t freezeWorkRAM[0x40000]; +uint8_t freezeInternalRAM[0x8000]; +uint8_t freezeVRAM[0x18000]; +uint8_t freezePRAM[0x400]; +uint8_t freezeOAM[0x400]; bool debugger_last; #endif int lcdTicks = (useBios && !skipBios) ? 1008 : 208; -u8 timerOnOffDelay = 0; -u16 timer0Value = 0; +uint8_t timerOnOffDelay = 0; +uint16_t timer0Value = 0; bool timer0On = false; int timer0Ticks = 0; int timer0Reload = 0; int timer0ClockReload = 0; -u16 timer1Value = 0; +uint16_t timer1Value = 0; bool timer1On = false; int timer1Ticks = 0; int timer1Reload = 0; int timer1ClockReload = 0; -u16 timer2Value = 0; +uint16_t timer2Value = 0; bool timer2On = false; int timer2Ticks = 0; int timer2Reload = 0; int timer2ClockReload = 0; -u16 timer3Value = 0; +uint16_t timer3Value = 0; bool timer3On = false; int timer3Ticks = 0; int timer3Reload = 0; int timer3ClockReload = 0; -u32 dma0Source = 0; -u32 dma0Dest = 0; -u32 dma1Source = 0; -u32 dma1Dest = 0; -u32 dma2Source = 0; -u32 dma2Dest = 0; -u32 dma3Source = 0; -u32 dma3Dest = 0; -void (*cpuSaveGameFunc)(u32, u8) = flashSaveDecide; +uint32_t dma0Source = 0; +uint32_t dma0Dest = 0; +uint32_t dma1Source = 0; +uint32_t dma1Dest = 0; +uint32_t dma2Source = 0; +uint32_t dma2Dest = 0; +uint32_t dma3Source = 0; +uint32_t dma3Dest = 0; +void (*cpuSaveGameFunc)(uint32_t, uint8_t) = flashSaveDecide; void (*renderLine)() = mode0RenderLine; bool fxOn = false; bool windowOn = false; int frameCount = 0; char buffer[1024]; -u32 lastTime = 0; +uint32_t lastTime = 0; int count = 0; int capture = 0; @@ -137,34 +137,34 @@ const int TIMER_TICKS[4] = { 10 }; -const u32 objTilesAddress[3] = { 0x010000, 0x014000, 0x014000 }; -const u8 gamepakRamWaitState[4] = { 4, 3, 2, 8 }; -const u8 gamepakWaitState[4] = { 4, 3, 2, 8 }; -const u8 gamepakWaitState0[2] = { 2, 1 }; -const u8 gamepakWaitState1[2] = { 4, 1 }; -const u8 gamepakWaitState2[2] = { 8, 1 }; +const uint32_t objTilesAddress[3] = { 0x010000, 0x014000, 0x014000 }; +const uint8_t gamepakRamWaitState[4] = { 4, 3, 2, 8 }; +const uint8_t gamepakWaitState[4] = { 4, 3, 2, 8 }; +const uint8_t gamepakWaitState0[2] = { 2, 1 }; +const uint8_t gamepakWaitState1[2] = { 4, 1 }; +const uint8_t gamepakWaitState2[2] = { 8, 1 }; const bool isInRom[16] = { false, false, false, false, false, false, false, false, true, true, true, true, true, true, false, false }; -u8 memoryWait[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0 }; -u8 memoryWait32[16] = { 0, 0, 5, 0, 0, 1, 1, 0, 7, 7, 9, 9, 13, 13, 4, 0 }; -u8 memoryWaitSeq[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 4, 4, 8, 8, 4, 0 }; -u8 memoryWaitSeq32[16] = { 0, 0, 5, 0, 0, 1, 1, 0, 5, 5, 9, 9, 17, 17, 4, 0 }; +uint8_t memoryWait[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0 }; +uint8_t memoryWait32[16] = { 0, 0, 5, 0, 0, 1, 1, 0, 7, 7, 9, 9, 13, 13, 4, 0 }; +uint8_t memoryWaitSeq[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 4, 4, 8, 8, 4, 0 }; +uint8_t memoryWaitSeq32[16] = { 0, 0, 5, 0, 0, 1, 1, 0, 5, 5, 9, 9, 17, 17, 4, 0 }; // The videoMemoryWait constants are used to add some waitstates // if the opcode access video memory data outside of vblank/hblank // It seems to happen on only one ticks for each pixel. // Not used for now (too problematic with current code). -//const u8 videoMemoryWait[16] = +//const uint8_t videoMemoryWait[16] = // {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -u8 biosProtected[4]; +uint8_t biosProtected[4]; #ifdef WORDS_BIGENDIAN bool cpuBiosSwapped = false; #endif -u32 myROM[] = { +uint32_t myROM[] = { 0xEA000006, 0xEA000093, 0xEA000006, @@ -341,83 +341,83 @@ u32 myROM[] = { }; variable_desc saveGameStruct[] = { - { &DISPCNT, sizeof(u16) }, - { &DISPSTAT, sizeof(u16) }, - { &VCOUNT, sizeof(u16) }, - { &BG0CNT, sizeof(u16) }, - { &BG1CNT, sizeof(u16) }, - { &BG2CNT, sizeof(u16) }, - { &BG3CNT, sizeof(u16) }, - { &BG0HOFS, sizeof(u16) }, - { &BG0VOFS, sizeof(u16) }, - { &BG1HOFS, sizeof(u16) }, - { &BG1VOFS, sizeof(u16) }, - { &BG2HOFS, sizeof(u16) }, - { &BG2VOFS, sizeof(u16) }, - { &BG3HOFS, sizeof(u16) }, - { &BG3VOFS, sizeof(u16) }, - { &BG2PA, sizeof(u16) }, - { &BG2PB, sizeof(u16) }, - { &BG2PC, sizeof(u16) }, - { &BG2PD, sizeof(u16) }, - { &BG2X_L, sizeof(u16) }, - { &BG2X_H, sizeof(u16) }, - { &BG2Y_L, sizeof(u16) }, - { &BG2Y_H, sizeof(u16) }, - { &BG3PA, sizeof(u16) }, - { &BG3PB, sizeof(u16) }, - { &BG3PC, sizeof(u16) }, - { &BG3PD, sizeof(u16) }, - { &BG3X_L, sizeof(u16) }, - { &BG3X_H, sizeof(u16) }, - { &BG3Y_L, sizeof(u16) }, - { &BG3Y_H, sizeof(u16) }, - { &WIN0H, sizeof(u16) }, - { &WIN1H, sizeof(u16) }, - { &WIN0V, sizeof(u16) }, - { &WIN1V, sizeof(u16) }, - { &WININ, sizeof(u16) }, - { &WINOUT, sizeof(u16) }, - { &MOSAIC, sizeof(u16) }, - { &BLDMOD, sizeof(u16) }, - { &COLEV, sizeof(u16) }, - { &COLY, sizeof(u16) }, - { &DM0SAD_L, sizeof(u16) }, - { &DM0SAD_H, sizeof(u16) }, - { &DM0DAD_L, sizeof(u16) }, - { &DM0DAD_H, sizeof(u16) }, - { &DM0CNT_L, sizeof(u16) }, - { &DM0CNT_H, sizeof(u16) }, - { &DM1SAD_L, sizeof(u16) }, - { &DM1SAD_H, sizeof(u16) }, - { &DM1DAD_L, sizeof(u16) }, - { &DM1DAD_H, sizeof(u16) }, - { &DM1CNT_L, sizeof(u16) }, - { &DM1CNT_H, sizeof(u16) }, - { &DM2SAD_L, sizeof(u16) }, - { &DM2SAD_H, sizeof(u16) }, - { &DM2DAD_L, sizeof(u16) }, - { &DM2DAD_H, sizeof(u16) }, - { &DM2CNT_L, sizeof(u16) }, - { &DM2CNT_H, sizeof(u16) }, - { &DM3SAD_L, sizeof(u16) }, - { &DM3SAD_H, sizeof(u16) }, - { &DM3DAD_L, sizeof(u16) }, - { &DM3DAD_H, sizeof(u16) }, - { &DM3CNT_L, sizeof(u16) }, - { &DM3CNT_H, sizeof(u16) }, - { &TM0D, sizeof(u16) }, - { &TM0CNT, sizeof(u16) }, - { &TM1D, sizeof(u16) }, - { &TM1CNT, sizeof(u16) }, - { &TM2D, sizeof(u16) }, - { &TM2CNT, sizeof(u16) }, - { &TM3D, sizeof(u16) }, - { &TM3CNT, sizeof(u16) }, - { &P1, sizeof(u16) }, - { &IE, sizeof(u16) }, - { &IF, sizeof(u16) }, - { &IME, sizeof(u16) }, + { &DISPCNT, sizeof(uint16_t) }, + { &DISPSTAT, sizeof(uint16_t) }, + { &VCOUNT, sizeof(uint16_t) }, + { &BG0CNT, sizeof(uint16_t) }, + { &BG1CNT, sizeof(uint16_t) }, + { &BG2CNT, sizeof(uint16_t) }, + { &BG3CNT, sizeof(uint16_t) }, + { &BG0HOFS, sizeof(uint16_t) }, + { &BG0VOFS, sizeof(uint16_t) }, + { &BG1HOFS, sizeof(uint16_t) }, + { &BG1VOFS, sizeof(uint16_t) }, + { &BG2HOFS, sizeof(uint16_t) }, + { &BG2VOFS, sizeof(uint16_t) }, + { &BG3HOFS, sizeof(uint16_t) }, + { &BG3VOFS, sizeof(uint16_t) }, + { &BG2PA, sizeof(uint16_t) }, + { &BG2PB, sizeof(uint16_t) }, + { &BG2PC, sizeof(uint16_t) }, + { &BG2PD, sizeof(uint16_t) }, + { &BG2X_L, sizeof(uint16_t) }, + { &BG2X_H, sizeof(uint16_t) }, + { &BG2Y_L, sizeof(uint16_t) }, + { &BG2Y_H, sizeof(uint16_t) }, + { &BG3PA, sizeof(uint16_t) }, + { &BG3PB, sizeof(uint16_t) }, + { &BG3PC, sizeof(uint16_t) }, + { &BG3PD, sizeof(uint16_t) }, + { &BG3X_L, sizeof(uint16_t) }, + { &BG3X_H, sizeof(uint16_t) }, + { &BG3Y_L, sizeof(uint16_t) }, + { &BG3Y_H, sizeof(uint16_t) }, + { &WIN0H, sizeof(uint16_t) }, + { &WIN1H, sizeof(uint16_t) }, + { &WIN0V, sizeof(uint16_t) }, + { &WIN1V, sizeof(uint16_t) }, + { &WININ, sizeof(uint16_t) }, + { &WINOUT, sizeof(uint16_t) }, + { &MOSAIC, sizeof(uint16_t) }, + { &BLDMOD, sizeof(uint16_t) }, + { &COLEV, sizeof(uint16_t) }, + { &COLY, sizeof(uint16_t) }, + { &DM0SAD_L, sizeof(uint16_t) }, + { &DM0SAD_H, sizeof(uint16_t) }, + { &DM0DAD_L, sizeof(uint16_t) }, + { &DM0DAD_H, sizeof(uint16_t) }, + { &DM0CNT_L, sizeof(uint16_t) }, + { &DM0CNT_H, sizeof(uint16_t) }, + { &DM1SAD_L, sizeof(uint16_t) }, + { &DM1SAD_H, sizeof(uint16_t) }, + { &DM1DAD_L, sizeof(uint16_t) }, + { &DM1DAD_H, sizeof(uint16_t) }, + { &DM1CNT_L, sizeof(uint16_t) }, + { &DM1CNT_H, sizeof(uint16_t) }, + { &DM2SAD_L, sizeof(uint16_t) }, + { &DM2SAD_H, sizeof(uint16_t) }, + { &DM2DAD_L, sizeof(uint16_t) }, + { &DM2DAD_H, sizeof(uint16_t) }, + { &DM2CNT_L, sizeof(uint16_t) }, + { &DM2CNT_H, sizeof(uint16_t) }, + { &DM3SAD_L, sizeof(uint16_t) }, + { &DM3SAD_H, sizeof(uint16_t) }, + { &DM3DAD_L, sizeof(uint16_t) }, + { &DM3DAD_H, sizeof(uint16_t) }, + { &DM3CNT_L, sizeof(uint16_t) }, + { &DM3CNT_H, sizeof(uint16_t) }, + { &TM0D, sizeof(uint16_t) }, + { &TM0CNT, sizeof(uint16_t) }, + { &TM1D, sizeof(uint16_t) }, + { &TM1CNT, sizeof(uint16_t) }, + { &TM2D, sizeof(uint16_t) }, + { &TM2CNT, sizeof(uint16_t) }, + { &TM3D, sizeof(uint16_t) }, + { &TM3CNT, sizeof(uint16_t) }, + { &P1, sizeof(uint16_t) }, + { &IE, sizeof(uint16_t) }, + { &IF, sizeof(uint16_t) }, + { &IME, sizeof(uint16_t) }, { &holdState, sizeof(bool) }, { &holdType, sizeof(int) }, { &lcdTicks, sizeof(int) }, @@ -437,14 +437,14 @@ variable_desc saveGameStruct[] = { { &timer3Ticks, sizeof(int) }, { &timer3Reload, sizeof(int) }, { &timer3ClockReload, sizeof(int) }, - { &dma0Source, sizeof(u32) }, - { &dma0Dest, sizeof(u32) }, - { &dma1Source, sizeof(u32) }, - { &dma1Dest, sizeof(u32) }, - { &dma2Source, sizeof(u32) }, - { &dma2Dest, sizeof(u32) }, - { &dma3Source, sizeof(u32) }, - { &dma3Dest, sizeof(u32) }, + { &dma0Source, sizeof(uint32_t) }, + { &dma0Dest, sizeof(uint32_t) }, + { &dma1Source, sizeof(uint32_t) }, + { &dma1Dest, sizeof(uint32_t) }, + { &dma2Source, sizeof(uint32_t) }, + { &dma2Dest, sizeof(uint32_t) }, + { &dma3Source, sizeof(uint32_t) }, + { &dma3Dest, sizeof(uint32_t) }, { &fxOn, sizeof(bool) }, { &windowOn, sizeof(bool) }, { &N_FLAG, sizeof(bool) }, @@ -453,7 +453,7 @@ variable_desc saveGameStruct[] = { { &V_FLAG, sizeof(bool) }, { &armState, sizeof(bool) }, { &armIrqEnable, sizeof(bool) }, - { &armNextPC, sizeof(u32) }, + { &armNextPC, sizeof(uint32_t) }, { &armMode, sizeof(int) }, { &saveType, sizeof(int) }, { NULL, 0 } @@ -548,14 +548,14 @@ void CPUUpdateWindow1() } } -extern u32 line0[240]; -extern u32 line1[240]; -extern u32 line2[240]; -extern u32 line3[240]; +extern uint32_t line0[240]; +extern uint32_t line1[240]; +extern uint32_t line2[240]; +extern uint32_t line3[240]; #define CLEAR_ARRAY(a) \ { \ - u32* array = (a); \ + uint32_t* array = (a); \ for (int i = 0; i < 240; i++) { \ *array++ = 0x80000000; \ } \ @@ -580,7 +580,7 @@ void CPUUpdateRenderBuffers(bool force) #ifdef __LIBRETRO__ #include -unsigned int CPUWriteState(u8* data, unsigned size) +unsigned int CPUWriteState(uint8_t* data, unsigned size) { uint8_t* orig = data; @@ -698,7 +698,7 @@ bool CPUWriteMemState(char* memory, int available, long& reserved) #endif #ifdef __LIBRETRO__ -bool CPUReadState(const u8* data, unsigned size) +bool CPUReadState(const uint8_t* data, unsigned size) { // Don't really care about version. int version = utilReadIntMem(data); @@ -810,7 +810,7 @@ static bool CPUReadState(gzFile gzFile) return false; } - u8 romname[17]; + uint8_t romname[17]; utilGzRead(gzFile, romname, 16); @@ -896,7 +896,7 @@ static bool CPUReadState(gzFile gzFile) } if (version <= SAVE_GAME_VERSION_7) { - u32 temp; + uint32_t temp; #define SWAP(a, b, c) \ temp = (a); \ (a) = (b) << 16 | (c); \ @@ -1183,20 +1183,20 @@ bool CPUWriteGSASnapshot(const char* fileName, return false; } - u8 buffer[17]; + uint8_t buffer[17]; utilPutDword(buffer, 0x0d); // SharkPortSave length fwrite(buffer, 1, 4, file); fwrite("SharkPortSave", 1, 0x0d, file); utilPutDword(buffer, 0x000f0000); fwrite(buffer, 1, 4, file); // save type 0x000f0000 = GBA save - utilPutDword(buffer, (u32)strlen(title)); + utilPutDword(buffer, (uint32_t)strlen(title)); fwrite(buffer, 1, 4, file); // title length fwrite(title, 1, strlen(title), file); - utilPutDword(buffer, (u32)strlen(desc)); + utilPutDword(buffer, (uint32_t)strlen(desc)); fwrite(buffer, 1, 4, file); // desc length fwrite(desc, 1, strlen(desc), file); - utilPutDword(buffer, (u32)strlen(notes)); + utilPutDword(buffer, (uint32_t)strlen(notes)); fwrite(buffer, 1, 4, file); // notes length fwrite(notes, 1, strlen(notes), file); int saveSize = 0x10000; @@ -1217,10 +1217,10 @@ bool CPUWriteGSASnapshot(const char* fileName, temp[0x14] = 1; // 1 save ? memcpy(&temp[0x1c], flashSaveMemory, saveSize); // copy save fwrite(temp, 1, totalSize, file); // write save + header - u32 crc = 0; + uint32_t crc = 0; for (int i = 0; i < totalSize; i++) { - crc += ((u32)temp[i] << (crc % 0x18)); + crc += ((uint32_t)temp[i] << (crc % 0x18)); } utilPutDword(buffer, crc); @@ -1249,7 +1249,7 @@ bool CPUImportEepromFile(const char* fileName) return false; } for (int i = 0; i < size;) { - u8 tmp = eepromData[i]; + uint8_t tmp = eepromData[i]; eepromData[i] = eepromData[7 - i]; eepromData[7 - i] = tmp; i++; @@ -1485,9 +1485,9 @@ void SetMapMasks() for (int i = 0; i < 16; i++) { map[i].size = map[i].mask + 1; if (map[i].size > 0) { - map[i].trace = (u8*)calloc(map[i].size >> 3, sizeof(u8)); + map[i].trace = (uint8_t*)calloc(map[i].size >> 3, sizeof(uint8_t)); - map[i].breakPoints = (u8*)calloc(map[i].size >> 1, sizeof(u8)); //\\ + map[i].breakPoints = (uint8_t*)calloc(map[i].size >> 1, sizeof(uint8_t)); //\\ if (map[i].trace == NULL || map[i].breakPoints == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), @@ -1511,20 +1511,20 @@ int CPULoadRom(const char* szFile) systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; - rom = (u8*)malloc(0x2000000); + rom = (uint8_t*)malloc(0x2000000); if (rom == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "ROM"); return 0; } - workRAM = (u8*)calloc(1, 0x40000); + workRAM = (uint8_t*)calloc(1, 0x40000); if (workRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "WRAM"); return 0; } - u8* whereToLoad = cpuIsMultiBoot ? workRAM : rom; + uint8_t* whereToLoad = cpuIsMultiBoot ? workRAM : rom; #ifndef NO_DEBUGGER if (CPUIsELF(szFile)) { @@ -1562,42 +1562,42 @@ int CPULoadRom(const char* szFile) } } - u16* temp = (u16*)(rom + ((romSize + 1) & ~1)); + uint16_t* temp = (uint16_t*)(rom + ((romSize + 1) & ~1)); int i; for (i = (romSize + 1) & ~1; i < 0x2000000; i += 2) { WRITE16LE(temp, (i >> 1) & 0xFFFF); temp++; } - bios = (u8*)calloc(1, 0x4000); + bios = (uint8_t*)calloc(1, 0x4000); if (bios == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "BIOS"); CPUCleanUp(); return 0; } - internalRAM = (u8*)calloc(1, 0x8000); + internalRAM = (uint8_t*)calloc(1, 0x8000); if (internalRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "IRAM"); CPUCleanUp(); return 0; } - paletteRAM = (u8*)calloc(1, 0x400); + paletteRAM = (uint8_t*)calloc(1, 0x400); if (paletteRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "PRAM"); CPUCleanUp(); return 0; } - vram = (u8*)calloc(1, 0x20000); + vram = (uint8_t*)calloc(1, 0x20000); if (vram == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "VRAM"); CPUCleanUp(); return 0; } - oam = (u8*)calloc(1, 0x400); + oam = (uint8_t*)calloc(1, 0x400); if (oam == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "OAM"); @@ -1605,9 +1605,9 @@ int CPULoadRom(const char* szFile) return 0; } #ifdef __LIBRETRO__ - pix = (u8*)calloc(1, 4 * 240 * 160); + pix = (uint8_t*)calloc(1, 4 * 240 * 160); #else - pix = (u8*)calloc(1, 4 * 241 * 162); + pix = (uint8_t*)calloc(1, 4 * 241 * 162); #endif if (pix == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), @@ -1615,7 +1615,7 @@ int CPULoadRom(const char* szFile) CPUCleanUp(); return 0; } - ioMem = (u8*)calloc(1, 0x400); + ioMem = (uint8_t*)calloc(1, 0x400); if (ioMem == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "IO"); @@ -1640,60 +1640,60 @@ int CPULoadRomData(const char* data, int size) systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; - rom = (u8*)malloc(0x2000000); + rom = (uint8_t*)malloc(0x2000000); if (rom == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "ROM"); return 0; } - workRAM = (u8*)calloc(1, 0x40000); + workRAM = (uint8_t*)calloc(1, 0x40000); if (workRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "WRAM"); return 0; } - u8* whereToLoad = cpuIsMultiBoot ? workRAM : rom; + uint8_t* whereToLoad = cpuIsMultiBoot ? workRAM : rom; romSize = size % 2 == 0 ? size : size + 1; memcpy(whereToLoad, data, size); - u16* temp = (u16*)(rom + ((romSize + 1) & ~1)); + uint16_t* temp = (uint16_t*)(rom + ((romSize + 1) & ~1)); int i; for (i = (romSize + 1) & ~1; i < 0x2000000; i += 2) { WRITE16LE(temp, (i >> 1) & 0xFFFF); temp++; } - bios = (u8*)calloc(1, 0x4000); + bios = (uint8_t*)calloc(1, 0x4000); if (bios == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "BIOS"); CPUCleanUp(); return 0; } - internalRAM = (u8*)calloc(1, 0x8000); + internalRAM = (uint8_t*)calloc(1, 0x8000); if (internalRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "IRAM"); CPUCleanUp(); return 0; } - paletteRAM = (u8*)calloc(1, 0x400); + paletteRAM = (uint8_t*)calloc(1, 0x400); if (paletteRAM == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "PRAM"); CPUCleanUp(); return 0; } - vram = (u8*)calloc(1, 0x20000); + vram = (uint8_t*)calloc(1, 0x20000); if (vram == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "VRAM"); CPUCleanUp(); return 0; } - oam = (u8*)calloc(1, 0x400); + oam = (uint8_t*)calloc(1, 0x400); if (oam == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "OAM"); @@ -1701,9 +1701,9 @@ int CPULoadRomData(const char* data, int size) return 0; } #ifdef __LIBRETRO__ - pix = (u8*)calloc(1, 4 * 240 * 160); + pix = (uint8_t*)calloc(1, 4 * 240 * 160); #else - pix = (u8*)calloc(1, 4 * 241 * 162); + pix = (uint8_t*)calloc(1, 4 * 241 * 162); #endif if (pix == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), @@ -1711,7 +1711,7 @@ int CPULoadRomData(const char* data, int size) CPUCleanUp(); return 0; } - ioMem = (u8*)calloc(1, 0x400); + ioMem = (uint8_t*)calloc(1, 0x400); if (ioMem == NULL) { systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), "IO"); @@ -1741,13 +1741,13 @@ void doMirroring(bool b) romSizeRounded |= romSizeRounded >> 8; romSizeRounded |= romSizeRounded >> 16; romSizeRounded++; - u32 mirroredRomSize = (((romSizeRounded) >> 20) & 0x3F) << 20; - u32 mirroredRomAddress = mirroredRomSize; + uint32_t mirroredRomSize = (((romSizeRounded) >> 20) & 0x3F) << 20; + uint32_t mirroredRomAddress = mirroredRomSize; if ((mirroredRomSize <= 0x800000) && (b)) { if (mirroredRomSize == 0) mirroredRomSize = 0x100000; while (mirroredRomAddress < 0x01000000) { - memcpy((u16*)(rom + mirroredRomAddress), (u16*)(rom), mirroredRomSize); + memcpy((uint16_t*)(rom + mirroredRomAddress), (uint16_t*)(rom), mirroredRomSize); mirroredRomAddress += mirroredRomSize; } } @@ -1830,7 +1830,7 @@ void CPUUpdateRender() void CPUUpdateCPSR() { - u32 CPSR = reg[16].I & 0x40; + uint32_t CPSR = reg[16].I & 0x40; if (N_FLAG) CPSR |= 0x80000000; if (Z_FLAG) @@ -1849,7 +1849,7 @@ void CPUUpdateCPSR() void CPUUpdateFlags(bool breakLoop) { - u32 CPSR = reg[16].I; + uint32_t CPSR = reg[16].I; N_FLAG = (CPSR & 0x80000000) ? true : false; Z_FLAG = (CPSR & 0x40000000) ? true : false; @@ -1869,16 +1869,16 @@ void CPUUpdateFlags() } #ifdef WORDS_BIGENDIAN -static void CPUSwap(volatile u32* a, volatile u32* b) +static void CPUSwap(volatile uint32_t* a, volatile uint32_t* b) { - volatile u32 c = *b; + volatile uint32_t c = *b; *b = *a; *a = c; } #else -static void CPUSwap(u32* a, u32* b) +static void CPUSwap(uint32_t* a, uint32_t* b) { - u32 c = *b; + uint32_t c = *b; *b = *a; *a = c; } @@ -1930,8 +1930,8 @@ void CPUSwitchMode(int mode, bool saveState, bool breakLoop) break; } - u32 CPSR = reg[16].I; - u32 SPSR = reg[17].I; + uint32_t CPSR = reg[16].I; + uint32_t SPSR = reg[17].I; switch (mode) { case 0x10: @@ -2005,7 +2005,7 @@ void CPUSwitchMode(int mode, bool saveState) void CPUUndefinedException() { - u32 PC = reg[15].I; + uint32_t PC = reg[15].I; bool savedArmState = armState; CPUSwitchMode(0x1b, true, false); reg[14].I = PC - (savedArmState ? 4 : 2); @@ -2019,7 +2019,7 @@ void CPUUndefinedException() void CPUSoftwareInterrupt() { - u32 PC = reg[15].I; + uint32_t PC = reg[15].I; bool savedArmState = armState; CPUSwitchMode(0x13, true, false); reg[14].I = PC - (savedArmState ? 4 : 2); @@ -2211,56 +2211,56 @@ void CPUSoftwareInterrupt(int comment) BIOS_BitUnPack(); break; case 0x11: { - u32 len = CPUReadMemory(reg[0].I) >> 8; + uint32_t len = CPUReadMemory(reg[0].I) >> 8; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (9 + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } BIOS_LZ77UnCompWram(); break; case 0x12: { - u32 len = CPUReadMemory(reg[0].I) >> 8; + uint32_t len = CPUReadMemory(reg[0].I) >> 8; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (19 + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } BIOS_LZ77UnCompVram(); break; case 0x13: { - u32 len = CPUReadMemory(reg[0].I) >> 8; + uint32_t len = CPUReadMemory(reg[0].I) >> 8; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (29 + (memoryWait[(reg[0].I >> 24) & 0xF] << 1)) * len; } BIOS_HuffUnComp(); break; case 0x14: { - u32 len = CPUReadMemory(reg[0].I) >> 8; + uint32_t len = CPUReadMemory(reg[0].I) >> 8; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (11 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } BIOS_RLUnCompWram(); break; case 0x15: { - u32 len = CPUReadMemory(reg[0].I) >> 9; + uint32_t len = CPUReadMemory(reg[0].I) >> 9; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (34 + (memoryWait[(reg[0].I >> 24) & 0xF] << 1) + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } BIOS_RLUnCompVram(); break; case 0x16: { - u32 len = CPUReadMemory(reg[0].I) >> 8; + uint32_t len = CPUReadMemory(reg[0].I) >> 8; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (13 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } BIOS_Diff8bitUnFilterWram(); break; case 0x17: { - u32 len = CPUReadMemory(reg[0].I) >> 9; + uint32_t len = CPUReadMemory(reg[0].I) >> 9; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (39 + (memoryWait[(reg[0].I >> 24) & 0xF] << 1) + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } BIOS_Diff8bitUnFilterVram(); break; case 0x18: { - u32 len = CPUReadMemory(reg[0].I) >> 9; + uint32_t len = CPUReadMemory(reg[0].I) >> 9; if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0)) SWITicks = (13 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len; } @@ -2362,7 +2362,7 @@ void CPUCompareVCOUNT() } } -void doDMA(u32& s, u32& d, u32 si, u32 di, u32 c, int transfer32) +void doDMA(uint32_t& s, uint32_t& d, uint32_t si, uint32_t di, uint32_t c, int transfer32) { int sm = s >> 24; int dm = d >> 24; @@ -2443,13 +2443,13 @@ void CPUCheckDMA(int reason, int dmamask) // DMA 0 if ((DM0CNT_H & 0x8000) && (dmamask & 1)) { if (((DM0CNT_H >> 12) & 3) == reason) { - u32 sourceIncrement = 4; - u32 destIncrement = 4; + uint32_t sourceIncrement = 4; + uint32_t destIncrement = 4; switch ((DM0CNT_H >> 7) & 3) { case 0: break; case 1: - sourceIncrement = (u32)-4; + sourceIncrement = (uint32_t)-4; break; case 2: sourceIncrement = 0; @@ -2459,7 +2459,7 @@ void CPUCheckDMA(int reason, int dmamask) case 0: break; case 1: - destIncrement = (u32)-4; + destIncrement = (uint32_t)-4; break; case 2: destIncrement = 0; @@ -2499,13 +2499,13 @@ void CPUCheckDMA(int reason, int dmamask) // DMA 1 if ((DM1CNT_H & 0x8000) && (dmamask & 2)) { if (((DM1CNT_H >> 12) & 3) == reason) { - u32 sourceIncrement = 4; - u32 destIncrement = 4; + uint32_t sourceIncrement = 4; + uint32_t destIncrement = 4; switch ((DM1CNT_H >> 7) & 3) { case 0: break; case 1: - sourceIncrement = (u32)-4; + sourceIncrement = (uint32_t)-4; break; case 2: sourceIncrement = 0; @@ -2515,7 +2515,7 @@ void CPUCheckDMA(int reason, int dmamask) case 0: break; case 1: - destIncrement = (u32)-4; + destIncrement = (uint32_t)-4; break; case 2: destIncrement = 0; @@ -2567,13 +2567,13 @@ void CPUCheckDMA(int reason, int dmamask) // DMA 2 if ((DM2CNT_H & 0x8000) && (dmamask & 4)) { if (((DM2CNT_H >> 12) & 3) == reason) { - u32 sourceIncrement = 4; - u32 destIncrement = 4; + uint32_t sourceIncrement = 4; + uint32_t destIncrement = 4; switch ((DM2CNT_H >> 7) & 3) { case 0: break; case 1: - sourceIncrement = (u32)-4; + sourceIncrement = (uint32_t)-4; break; case 2: sourceIncrement = 0; @@ -2583,7 +2583,7 @@ void CPUCheckDMA(int reason, int dmamask) case 0: break; case 1: - destIncrement = (u32)-4; + destIncrement = (uint32_t)-4; break; case 2: destIncrement = 0; @@ -2636,13 +2636,13 @@ void CPUCheckDMA(int reason, int dmamask) // DMA 3 if ((DM3CNT_H & 0x8000) && (dmamask & 8)) { if (((DM3CNT_H >> 12) & 3) == reason) { - u32 sourceIncrement = 4; - u32 destIncrement = 4; + uint32_t sourceIncrement = 4; + uint32_t destIncrement = 4; switch ((DM3CNT_H >> 7) & 3) { case 0: break; case 1: - sourceIncrement = (u32)-4; + sourceIncrement = (uint32_t)-4; break; case 2: sourceIncrement = 0; @@ -2652,7 +2652,7 @@ void CPUCheckDMA(int reason, int dmamask) case 0: break; case 1: - destIncrement = (u32)-4; + destIncrement = (uint32_t)-4; break; case 2: destIncrement = 0; @@ -2690,7 +2690,7 @@ void CPUCheckDMA(int reason, int dmamask) } } -void CPUUpdateRegister(u32 address, u16 value) +void CPUUpdateRegister(uint32_t address, uint16_t value) { switch (address) { case 0x00: { // we need to place the following code in { } because we declare & initialize variables in a case statement @@ -2700,7 +2700,7 @@ void CPUUpdateRegister(u32 address, u16 value) } bool change = (0 != ((DISPCNT ^ value) & 0x80)); bool changeBG = (0 != ((DISPCNT ^ value) & 0x0F00)); - u16 changeBGon = ((~DISPCNT) & value) & 0x0F00; // these layers are being activated + uint16_t changeBGon = ((~DISPCNT) & value) & 0x0F00; // these layers are being activated DISPCNT = (value & 0xFFF7); // bit 3 can only be accessed by the BIOS to enable GBC mode UPDATE_REG(0x00, DISPCNT); @@ -2915,8 +2915,8 @@ void CPUUpdateRegister(u32 address, u16 value) case 0x7c: case 0x80: case 0x84: - soundEvent(address & 0xFF, (u8)(value & 0xFF)); - soundEvent((address & 0xFF) + 1, (u8)(value >> 8)); + soundEvent(address & 0xFF, (uint8_t)(value & 0xFF)); + soundEvent((address & 0xFF) + 1, (uint8_t)(value >> 8)); break; case 0x82: case 0x88: @@ -3129,7 +3129,7 @@ void CPUUpdateRegister(u32 address, u16 value) break; case COMM_JOYCNT: { - u16 cur = READ16LE(&ioMem[COMM_JOYCNT]); + uint16_t cur = READ16LE(&ioMem[COMM_JOYCNT]); if (value & JOYCNT_RESET) cur &= ~JOYCNT_RESET; @@ -3288,8 +3288,8 @@ void applyTimer() timerOnOffDelay = 0; } -u8 cpuBitsSet[256]; -u8 cpuLowestBitSet[256]; +uint8_t cpuBitsSet[256]; +uint8_t cpuLowestBitSet[256]; void CPUInit(const char* biosFileName, bool useBiosFile) { @@ -3379,8 +3379,8 @@ void CPUInit(const char* biosFileName, bool useBiosFile) ioReadable[i] = false; if (romSize < 0x1fe2000) { - *((u16*)&rom[0x1fe209c]) = 0xdffa; // SWI 0xFA - *((u16*)&rom[0x1fe209e]) = 0x4770; // BX LR + *((uint16_t*)&rom[0x1fe209c]) = 0xdffa; // SWI 0xFA + *((uint16_t*)&rom[0x1fe209e]) = 0x4770; // BX LR } else { agbPrintEnable(false); } @@ -3645,7 +3645,7 @@ void CPUReset() CPUUpdateRenderBuffers(true); for (int i = 0; i < 256; i++) { - map[i].address = (u8*)&dummyAddress; + map[i].address = (uint8_t*)&dummyAddress; map[i].mask = 0; } @@ -3695,7 +3695,7 @@ void CPUReset() void CPUInterrupt() { - u32 PC = reg[15].I; + uint32_t PC = reg[15].I; bool savedState = armState; CPUSwitchMode(0x12, true, false); reg[14].I = PC; @@ -3720,7 +3720,7 @@ void CPULoop(int ticks) { int clockTicks; int timerOverflow = 0; - u32 memAddr = 0; + uint32_t memAddr = 0; // variable used by the CPU core cpuTotalTicks = 0; @@ -3828,16 +3828,16 @@ void CPULoop(int ticks) system10Frames(60); } if (count == 60) { - u32 time = systemGetClock(); + uint32_t time = systemGetClock(); if (time != lastTime) { - u32 t = 100000 / (time - lastTime); + uint32_t t = 100000 / (time - lastTime); systemShowSpeed(t); } else systemShowSpeed(0); lastTime = time; count = 0; } - u32 joy = 0; + uint32_t joy = 0; // update joystick information if (systemReadJoypads()) // read default joystick @@ -3845,12 +3845,12 @@ void CPULoop(int ticks) P1 = 0x03FF ^ (joy & 0x3FF); systemUpdateMotionSensor(); UPDATE_REG(0x130, P1); - u16 P1CNT = READ16LE(((u16*)&ioMem[0x132])); + uint16_t P1CNT = READ16LE(((uint16_t*)&ioMem[0x132])); // this seems wrong, but there are cases where the game // can enter the stop state without requesting an IRQ from // the joypad. if ((P1CNT & 0x4000) || stopState) { - u16 p1 = (0x3FF ^ P1) & 0x3FF; + uint16_t p1 = (0x3FF ^ P1) & 0x3FF; if (P1CNT & 0x8000) { if (p1 == (P1CNT & 0x3FF)) { IF |= 0x1000; @@ -3864,7 +3864,7 @@ void CPULoop(int ticks) } } - u32 ext = (joy >> 10); + uint32_t ext = (joy >> 10); // If no (m) code is enabled, apply the cheats at each LCDline if ((cheatsEnabled) && (mastercode == 0)) remainingTicks += cheatsCheckKeys(P1 ^ 0x3FF, ext); @@ -3903,9 +3903,9 @@ void CPULoop(int ticks) switch (systemColorDepth) { case 16: { #ifdef __LIBRETRO__ - u16* dest = (u16*)pix + 240 * VCOUNT; + uint16_t* dest = (uint16_t*)pix + 240 * VCOUNT; #else - u16* dest = (u16*)pix + 242 * (VCOUNT + 1); + uint16_t* dest = (uint16_t*)pix + 242 * (VCOUNT + 1); #endif for (int x = 0; x < 240;) { *dest++ = systemColorMap16[lineMix[x++] & 0xFFFF]; @@ -3934,50 +3934,50 @@ void CPULoop(int ticks) #endif } break; case 24: { - u8* dest = (u8*)pix + 240 * VCOUNT * 3; + uint8_t* dest = (uint8_t*)pix + 240 * VCOUNT * 3; for (int x = 0; x < 240;) { - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; - *((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + *((uint32_t*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; dest += 3; } } break; case 32: { #ifdef __LIBRETRO__ - u32* dest = (u32*)pix + 240 * VCOUNT; + uint32_t* dest = (uint32_t*)pix + 240 * VCOUNT; #else - u32* dest = (u32*)pix + 241 * (VCOUNT + 1); + uint32_t* dest = (uint32_t*)pix + 241 * (VCOUNT + 1); #endif for (int x = 0; x < 240;) { *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; @@ -4138,7 +4138,7 @@ void CPULoop(int ticks) if (profilSegment) { profile_segment* seg = profilSegment; do { - u16* b = (u16*)seg->sbuf; + uint16_t* b = (uint16_t*)seg->sbuf; int pc = ((reg[15].I - seg->s_lowpc) * seg->s_scale) / 0x10000; if (pc >= 0 && pc < seg->ssiz) { b[pc]++; @@ -4245,7 +4245,7 @@ union u8h { /* 0*/ unsigned lo : 4; /* 4*/ unsigned hi : 4; } __attribute__((packed)); - u8 val; + uint8_t val; }; union TileEntry { @@ -4256,21 +4256,21 @@ union TileEntry { /*13*/ unsigned vFlip : 1; /*14*/ unsigned palette : 4; }; - u16 val; + uint16_t val; }; struct TileLine { - u32 pixels[8]; + uint32_t pixels[8]; }; -typedef const TileLine (*TileReader)(const u16*, const int, const u8*, u16*, const u32); +typedef const TileLine (*TileReader)(const uint16_t*, const int, const uint8_t*, uint16_t*, const uint32_t); -static inline void gfxDrawPixel(u32* dest, const u8 color, const u16* palette, const u32 prio) +static inline void gfxDrawPixel(uint32_t* dest, const uint8_t color, const uint16_t* palette, const uint32_t prio) { *dest = color ? (READ16LE(&palette[color]) | prio) : 0x80000000; } -inline const TileLine gfxReadTile(const u16* screenSource, const int yyy, const u8* charBase, u16* palette, const u32 prio) +inline const TileLine gfxReadTile(const uint16_t* screenSource, const int yyy, const uint8_t* charBase, uint16_t* palette, const uint32_t prio) { TileEntry tile; tile.val = READ16LE(screenSource); @@ -4280,7 +4280,7 @@ inline const TileLine gfxReadTile(const u16* screenSource, const int yyy, const tileY = 7 - tileY; TileLine tileLine; - const u8* tileBase = &charBase[tile.tileNum * 64 + tileY * 8]; + const uint8_t* tileBase = &charBase[tile.tileNum * 64 + tileY * 8]; if (!tile.hFlip) { gfxDrawPixel(&tileLine.pixels[0], tileBase[0], palette, prio); @@ -4305,7 +4305,7 @@ inline const TileLine gfxReadTile(const u16* screenSource, const int yyy, const return tileLine; } -inline const TileLine gfxReadTilePal(const u16* screenSource, const int yyy, const u8* charBase, u16* palette, const u32 prio) +inline const TileLine gfxReadTilePal(const uint16_t* screenSource, const int yyy, const uint8_t* charBase, uint16_t* palette, const uint32_t prio) { TileEntry tile; tile.val = READ16LE(screenSource); @@ -4341,24 +4341,24 @@ inline const TileLine gfxReadTilePal(const u16* screenSource, const int yyy, con return tileLine; } -static inline void gfxDrawTile(const TileLine& tileLine, u32* line) +static inline void gfxDrawTile(const TileLine& tileLine, uint32_t* line) { memcpy(line, tileLine.pixels, sizeof(tileLine.pixels)); } -static inline void gfxDrawTileClipped(const TileLine& tileLine, u32* line, const int start, int w) +static inline void gfxDrawTileClipped(const TileLine& tileLine, uint32_t* line, const int start, int w) { - memcpy(line, tileLine.pixels + start, w * sizeof(u32)); + memcpy(line, tileLine.pixels + start, w * sizeof(uint32_t)); } template -static void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, - u32* line) +static void gfxDrawTextScreen(uint16_t control, uint16_t hofs, uint16_t vofs, + uint32_t* line) { - u16* palette = (u16*)paletteRAM; - u8* charBase = &vram[((control >> 2) & 0x03) * 0x4000]; - u16* screenBase = (u16*)&vram[((control >> 8) & 0x1f) * 0x800]; - u32 prio = ((control & 3) << 25) + 0x1000000; + uint16_t* palette = (uint16_t*)paletteRAM; + uint8_t* charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + uint16_t* screenBase = (uint16_t*)&vram[((control >> 8) & 0x1f) * 0x800]; + uint32_t prio = ((control & 3) << 25) + 0x1000000; int sizeX = 256; int sizeY = 256; switch ((control >> 14) & 3) { @@ -4402,7 +4402,7 @@ static void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, int yshift = ((yyy >> 3) << 5); - u16* screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift; + uint16_t* screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift; int x = 0; const int firstTileX = xxx & 7; @@ -4456,7 +4456,7 @@ static void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, } } -void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32* line) +void gfxDrawTextScreen(uint16_t control, uint16_t hofs, uint16_t vofs, uint32_t* line) { if (control & 0x80) // 1 pal / 256 col gfxDrawTextScreen(control, hofs, vofs, line); diff --git a/src/gba/GBA.h b/src/gba/GBA.h index 576f0b78..a5895cca 100644 --- a/src/gba/GBA.h +++ b/src/gba/GBA.h @@ -3,7 +3,7 @@ #include "../System.h" -const u64 TICKS_PER_SECOND = 16777216; +const uint64_t TICKS_PER_SECOND = 16777216; #define SAVE_GAME_VERSION_1 1 #define SAVE_GAME_VERSION_2 2 @@ -18,43 +18,43 @@ const u64 TICKS_PER_SECOND = 16777216; #define SAVE_GAME_VERSION SAVE_GAME_VERSION_10 typedef struct { - u8* address; - u32 mask; + uint8_t* address; + uint32_t mask; #ifdef BKPT_SUPPORT - u8* breakPoints; - u8* searchMatch; - u8* trace; - u32 size; + uint8_t* breakPoints; + uint8_t* searchMatch; + uint8_t* trace; + uint32_t size; #endif } memoryMap; typedef union { struct { #ifdef WORDS_BIGENDIAN - u8 B3; - u8 B2; - u8 B1; - u8 B0; + uint8_t B3; + uint8_t B2; + uint8_t B1; + uint8_t B0; #else - u8 B0; - u8 B1; - u8 B2; - u8 B3; + uint8_t B0; + uint8_t B1; + uint8_t B2; + uint8_t B3; #endif } B; struct { #ifdef WORDS_BIGENDIAN - u16 W1; - u16 W0; + uint16_t W1; + uint16_t W0; #else - u16 W0; - u16 W1; + uint16_t W0; + uint16_t W1; #endif } W; #ifdef WORDS_BIGENDIAN - volatile u32 I; + volatile uint32_t I; #else - u32 I; + uint32_t I; #endif } reg_pair; @@ -62,16 +62,16 @@ typedef union { extern memoryMap map[256]; #endif -extern u8 biosProtected[4]; +extern uint8_t biosProtected[4]; -extern void (*cpuSaveGameFunc)(u32, u8); +extern void (*cpuSaveGameFunc)(uint32_t, uint8_t); #ifdef BKPT_SUPPORT -extern u8 freezeWorkRAM[0x40000]; -extern u8 freezeInternalRAM[0x8000]; -extern u8 freezeVRAM[0x18000]; -extern u8 freezeOAM[0x400]; -extern u8 freezePRAM[0x400]; +extern uint8_t freezeWorkRAM[0x40000]; +extern uint8_t freezeInternalRAM[0x8000]; +extern uint8_t freezeVRAM[0x18000]; +extern uint8_t freezeOAM[0x400]; +extern uint8_t freezePRAM[0x400]; extern bool debugger_last; extern int oldreg[18]; extern char oldbuffer[10]; @@ -93,8 +93,8 @@ extern void CPUUpdateRenderBuffers(bool); extern bool CPUReadMemState(char*, int); extern bool CPUWriteMemState(char*, int); #ifdef __LIBRETRO__ -extern bool CPUReadState(const u8*, unsigned); -extern unsigned int CPUWriteState(u8* data, unsigned int size); +extern bool CPUReadState(const uint8_t*, unsigned); +extern unsigned int CPUWriteState(uint8_t* data, unsigned int size); #else extern bool CPUReadState(const char*); extern bool CPUWriteState(const char*); @@ -102,7 +102,7 @@ extern bool CPUWriteState(const char*); extern int CPULoadRom(const char*); extern int CPULoadRomData(const char* data, int size); extern void doMirroring(bool); -extern void CPUUpdateRegister(u32, u16); +extern void CPUUpdateRegister(uint32_t, uint16_t); extern void applyTimer(); extern void CPUInit(const char*, bool); void SetSaveType(int st); diff --git a/src/gba/elf.cpp b/src/gba/elf.cpp index 529ae88b..d844e6a0 100644 --- a/src/gba/elf.cpp +++ b/src/gba/elf.cpp @@ -162,21 +162,21 @@ struct ELFcie { ELFcie* next; - u32 offset; - u8* augmentation; - u32 codeAlign; - s32 dataAlign; + uint32_t offset; + uint8_t* augmentation; + uint32_t codeAlign; + int32_t dataAlign; int returnAddress; - u8* data; - u32 dataLen; + uint8_t* data; + uint32_t dataLen; }; struct ELFfde { ELFcie* cie; - u32 address; - u32 end; - u8* data; - u32 dataLen; + uint32_t address; + uint32_t end; + uint8_t* data; + uint32_t dataLen; }; enum ELFRegMode { @@ -188,7 +188,7 @@ enum ELFRegMode { struct ELFFrameStateRegister { ELFRegMode mode; int reg; - s32 offset; + int32_t offset; }; struct ELFFrameStateRegisters { @@ -206,9 +206,9 @@ struct ELFFrameState { ELFCfaMode cfaMode; int cfaRegister; - s32 cfaOffset; + int32_t cfaOffset; - u32 pc; + uint32_t pc; int dataAlign; int codeAlign; @@ -224,7 +224,7 @@ int elfSymbolsCount = 0; ELFSectionHeader** elfSectionHeaders = NULL; char* elfSectionHeadersStringTable = NULL; int elfSectionHeadersCount = 0; -u8* elfFileData = NULL; +uint8_t* elfFileData = NULL; CompileUnit* elfCompileUnits = NULL; DebugInfo* elfDebugInfo = NULL; @@ -236,10 +236,10 @@ int elfFdeCount = 0; CompileUnit* elfCurrentUnit = NULL; -u32 elfRead4Bytes(u8*); -u16 elfRead2Bytes(u8*); +uint32_t elfRead4Bytes(uint8_t*); +uint16_t elfRead2Bytes(uint8_t*); -CompileUnit* elfGetCompileUnit(u32 addr) +CompileUnit* elfGetCompileUnit(uint32_t addr) { if (elfCompileUnits) { CompileUnit* unit = elfCompileUnits; @@ -263,7 +263,7 @@ CompileUnit* elfGetCompileUnit(u32 addr) return NULL; } -const char* elfGetAddressSymbol(u32 addr) +const char* elfGetAddressSymbol(uint32_t addr) { static char buffer[256]; @@ -313,7 +313,7 @@ const char* elfGetAddressSymbol(u32 addr) return ""; } -bool elfFindLineInModule(u32* addr, const char* name, int line) +bool elfFindLineInModule(uint32_t* addr, const char* name, int line) { CompileUnit* unit = elfCompileUnits; @@ -347,7 +347,7 @@ bool elfFindLineInModule(u32* addr, const char* name, int line) return false; } -int elfFindLine(CompileUnit* unit, Function* /* func */, u32 addr, const char** f) +int elfFindLine(CompileUnit* unit, Function* /* func */, uint32_t addr, const char** f) { int currentLine = -1; if (unit->hasLineInfo) { @@ -366,7 +366,7 @@ int elfFindLine(CompileUnit* unit, Function* /* func */, u32 addr, const char** return currentLine; } -bool elfFindLineInUnit(u32* addr, CompileUnit* unit, int line) +bool elfFindLineInUnit(uint32_t* addr, CompileUnit* unit, int line) { if (unit->hasLineInfo) { int count = unit->lineInfoTable->number; @@ -382,7 +382,7 @@ bool elfFindLineInUnit(u32* addr, CompileUnit* unit, int line) return false; } -bool elfGetCurrentFunction(u32 addr, Function** f, CompileUnit** u) +bool elfGetCurrentFunction(uint32_t addr, Function** f, CompileUnit** u) { CompileUnit* unit = elfGetCompileUnit(addr); // found unit, need to find function @@ -449,7 +449,7 @@ bool elfGetObject(const char* name, Function* f, CompileUnit* u, Object** o) return false; } -const char* elfGetSymbol(int i, u32* value, u32* size, int* type) +const char* elfGetSymbol(int i, uint32_t* value, uint32_t* size, int* type) { if (i < elfSymbolsCount) { Symbol* s = &elfSymbols[i]; @@ -461,7 +461,7 @@ const char* elfGetSymbol(int i, u32* value, u32* size, int* type) return NULL; } -bool elfGetSymbolAddress(const char* sym, u32* addr, u32* size, int* type) +bool elfGetSymbolAddress(const char* sym, uint32_t* addr, uint32_t* size, int* type) { if (elfSymbolsCount) { for (int i = 0; i < elfSymbolsCount; i++) { @@ -477,7 +477,7 @@ bool elfGetSymbolAddress(const char* sym, u32* addr, u32* size, int* type) return false; } -ELFfde* elfGetFde(u32 address) +ELFfde* elfGetFde(uint32_t address) { if (elfFdes) { int i; @@ -491,16 +491,16 @@ ELFfde* elfGetFde(u32 address) return NULL; } -void elfExecuteCFAInstructions(ELFFrameState* state, u8* data, u32 len, - u32 pc) +void elfExecuteCFAInstructions(ELFFrameState* state, uint8_t* data, uint32_t len, + uint32_t pc) { - u8* end = data + len; + uint8_t* end = data + len; int bytes; int reg; ELFFrameStateRegisters* fs; while (data < end && state->pc < pc) { - u8 op = *data++; + uint8_t op = *data++; switch (op >> 6) { case DW_CFA_advance_loc: @@ -509,7 +509,7 @@ void elfExecuteCFAInstructions(ELFFrameState* state, u8* data, u32 len, case DW_CFA_offset: reg = op & 0x3f; state->registers.regs[reg].mode = REG_OFFSET; - state->registers.regs[reg].offset = state->dataAlign * (s32)elfReadLEB128(data, &bytes); + state->registers.regs[reg].offset = state->dataAlign * (int32_t)elfReadLEB128(data, &bytes); data += bytes; break; case DW_CFA_restore: @@ -536,7 +536,7 @@ void elfExecuteCFAInstructions(ELFFrameState* state, u8* data, u32 len, reg = elfReadLEB128(data, &bytes); data += bytes; state->registers.regs[reg].mode = REG_OFFSET; - state->registers.regs[reg].offset = state->dataAlign * (s32)elfReadLEB128(data, &bytes); + state->registers.regs[reg].offset = state->dataAlign * (int32_t)elfReadLEB128(data, &bytes); data += bytes; break; case DW_CFA_restore_extended: @@ -571,7 +571,7 @@ void elfExecuteCFAInstructions(ELFFrameState* state, u8* data, u32 len, case DW_CFA_def_cfa: state->cfaRegister = elfReadLEB128(data, &bytes); data += bytes; - state->cfaOffset = (s32)elfReadLEB128(data, &bytes); + state->cfaOffset = (int32_t)elfReadLEB128(data, &bytes); data += bytes; state->cfaMode = CFA_REG_OFFSET; break; @@ -581,7 +581,7 @@ void elfExecuteCFAInstructions(ELFFrameState* state, u8* data, u32 len, state->cfaMode = CFA_REG_OFFSET; break; case DW_CFA_def_cfa_offset: - state->cfaOffset = (s32)elfReadLEB128(data, &bytes); + state->cfaOffset = (int32_t)elfReadLEB128(data, &bytes); data += bytes; state->cfaMode = CFA_REG_OFFSET; break; @@ -597,7 +597,7 @@ void elfExecuteCFAInstructions(ELFFrameState* state, u8* data, u32 len, } } -ELFFrameState* elfGetFrameState(ELFfde* fde, u32 address) +ELFFrameState* elfGetFrameState(ELFfde* fde, uint32_t address) { ELFFrameState* state = (ELFFrameState*)calloc(1, sizeof(ELFFrameState)); state->pc = fde->address; @@ -617,7 +617,7 @@ ELFFrameState* elfGetFrameState(ELFfde* fde, u32 address) return state; } -void elfPrintCallChain(u32 address) +void elfPrintCallChain(uint32_t address) { int count = 1; @@ -647,7 +647,7 @@ void elfPrintCallChain(u32 address) if (state->cfaMode == CFA_REG_OFFSET) { memcpy(&newRegs[0], ®s[0], sizeof(reg_pair) * 15); - u32 addr = 0; + uint32_t addr = 0; for (int i = 0; i < 15; i++) { ELFFrameStateRegister* r = &state->registers.regs[i]; @@ -688,9 +688,9 @@ void elfPrintCallChain(u32 address) } } -u32 elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type, u32 base) +uint32_t elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type, uint32_t base) { - u32 framebase = 0; + uint32_t framebase = 0; if (f && f->frameBase) { ELFBlock* b = f->frameBase; switch (*b->data) { @@ -719,7 +719,7 @@ u32 elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type, u32 base) } ELFBlock* loc = o; - u32 location = 0; + uint32_t location = 0; int bytes = 0; if (loc) { switch (*loc->data) { @@ -752,7 +752,7 @@ u32 elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type, u32 base) break; case DW_OP_fbreg: { int bytes; - s32 off = elfReadSignedLEB128(loc->data + 1, &bytes); + int32_t off = elfReadSignedLEB128(loc->data + 1, &bytes); location = framebase + off; *type = LOCATION_memory; } break; @@ -764,30 +764,30 @@ u32 elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type, u32 base) return location; } -u32 elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type) +uint32_t elfDecodeLocation(Function* f, ELFBlock* o, LocationType* type) { return elfDecodeLocation(f, o, type, 0); } // reading function -u32 elfRead4Bytes(u8* data) +uint32_t elfRead4Bytes(uint8_t* data) { - u32 value = *data++; + uint32_t value = *data++; value |= (*data++ << 8); value |= (*data++ << 16); value |= (*data << 24); return value; } -u16 elfRead2Bytes(u8* data) +uint16_t elfRead2Bytes(uint8_t* data) { - u16 value = *data++; + uint16_t value = *data++; value |= (*data << 8); return value; } -char* elfReadString(u8* data, int* bytesRead) +char* elfReadString(uint8_t* data, int* bytesRead) { if (*data == 0) { *bytesRead = 1; @@ -797,13 +797,13 @@ char* elfReadString(u8* data, int* bytesRead) return (char*)data; } -s32 elfReadSignedLEB128(u8* data, int* bytesRead) +int32_t elfReadSignedLEB128(uint8_t* data, int* bytesRead) { - s32 result = 0; + int32_t result = 0; int shift = 0; int count = 0; - u8 byte; + uint8_t byte; do { byte = *data++; count++; @@ -816,12 +816,12 @@ s32 elfReadSignedLEB128(u8* data, int* bytesRead) return result; } -u32 elfReadLEB128(u8* data, int* bytesRead) +uint32_t elfReadLEB128(uint8_t* data, int* bytesRead) { - u32 result = 0; + uint32_t result = 0; int shift = 0; int count = 0; - u8 byte; + uint8_t byte; do { byte = *data++; count++; @@ -832,7 +832,7 @@ u32 elfReadLEB128(u8* data, int* bytesRead) return result; } -u8* elfReadSection(u8* data, ELFSectionHeader* sh) +uint8_t* elfReadSection(uint8_t* data, ELFSectionHeader* sh) { return data + READ32LE(&sh->offset); } @@ -857,9 +857,9 @@ ELFSectionHeader* elfGetSectionByNumber(int number) return NULL; } -CompileUnit* elfGetCompileUnitForData(u8* data) +CompileUnit* elfGetCompileUnitForData(uint8_t* data) { - u8* end = elfCurrentUnit->top + 4 + elfCurrentUnit->length; + uint8_t* end = elfCurrentUnit->top + 4 + elfCurrentUnit->length; if (data >= elfCurrentUnit->top && data < end) return elfCurrentUnit; @@ -880,7 +880,7 @@ CompileUnit* elfGetCompileUnitForData(u8* data) exit(-1); } -u8* elfReadAttribute(u8* data, ELFAttr* attr) +uint8_t* elfReadAttribute(uint8_t* data, ELFAttr* attr) { int bytes; int form = attr->form; @@ -934,7 +934,7 @@ start: data += bytes; break; case DW_FORM_ref_addr: - attr->value = (u32)((elfDebugInfo->infodata + elfRead4Bytes(data)) - elfGetCompileUnitForData(data)->top); + attr->value = (uint32_t)((elfDebugInfo->infodata + elfRead4Bytes(data)) - elfGetCompileUnitForData(data)->top); data += 4; break; case DW_FORM_ref4: @@ -942,7 +942,7 @@ start: data += 4; break; case DW_FORM_ref_udata: - attr->value = (u32)((elfDebugInfo->infodata + (elfGetCompileUnitForData(data)->top - elfDebugInfo->infodata) + elfReadLEB128(data, &bytes)) - elfCurrentUnit->top); + attr->value = (uint32_t)((elfDebugInfo->infodata + (elfGetCompileUnitForData(data)->top - elfDebugInfo->infodata) + elfReadLEB128(data, &bytes)) - elfCurrentUnit->top); data += bytes; break; case DW_FORM_indirect: @@ -956,7 +956,7 @@ start: return data; } -ELFAbbrev* elfGetAbbrev(ELFAbbrev** table, u32 number) +ELFAbbrev* elfGetAbbrev(ELFAbbrev** table, uint32_t number) { int hash = number % 121; @@ -970,12 +970,12 @@ ELFAbbrev* elfGetAbbrev(ELFAbbrev** table, u32 number) return NULL; } -ELFAbbrev** elfReadAbbrevs(u8* data, u32 offset) +ELFAbbrev** elfReadAbbrevs(uint8_t* data, uint32_t offset) { data += offset; ELFAbbrev** abbrevs = (ELFAbbrev**)calloc(sizeof(ELFAbbrev*) * 121, 1); int bytes = 0; - u32 number = elfReadLEB128(data, &bytes); + uint32_t number = elfReadLEB128(data, &bytes); data += bytes; while (number) { ELFAbbrev* abbrev = (ELFAbbrev*)calloc(sizeof(ELFAbbrev), 1); @@ -1020,7 +1020,7 @@ ELFAbbrev** elfReadAbbrevs(u8* data, u32 offset) return abbrevs; } -void elfParseCFA(u8* top) +void elfParseCFA(uint8_t* top) { ELFSectionHeader* h = elfGetSectionByName(".debug_frame"); @@ -1028,22 +1028,22 @@ void elfParseCFA(u8* top) return; } - u8* data = elfReadSection(top, h); + uint8_t* data = elfReadSection(top, h); - u8* topOffset = data; + uint8_t* topOffset = data; - u8* end = data + READ32LE(&h->size); + uint8_t* end = data + READ32LE(&h->size); ELFcie* cies = NULL; while (data < end) { - u32 offset = (u32)(data - topOffset); - u32 len = elfRead4Bytes(data); + uint32_t offset = (uint32_t)(data - topOffset); + uint32_t len = elfRead4Bytes(data); data += 4; - u8* dataEnd = data + len; + uint8_t* dataEnd = data + len; - u32 id = elfRead4Bytes(data); + uint32_t id = elfRead4Bytes(data); data += 4; if (id == 0xffffffff) { @@ -1077,7 +1077,7 @@ void elfParseCFA(u8* top) cie->returnAddress = *data++; cie->data = data; - cie->dataLen = (u32)(dataEnd - data); + cie->dataLen = (uint32_t)(dataEnd - data); } else { ELFfde* fde = (ELFfde*)calloc(1, sizeof(ELFfde)); @@ -1103,7 +1103,7 @@ void elfParseCFA(u8* top) data += 4; fde->data = data; - fde->dataLen = (u32)(dataEnd - data); + fde->dataLen = (uint32_t)(dataEnd - data); if ((elfFdeCount % 10) == 0) { elfFdes = (ELFfde**)realloc(elfFdes, (elfFdeCount + 10) * sizeof(ELFfde*)); @@ -1116,7 +1116,7 @@ void elfParseCFA(u8* top) elfCies = cies; } -void elfAddLine(LineInfo* l, u32 a, int file, int line, int* max) +void elfAddLine(LineInfo* l, uint32_t a, int file, int line, int* max) { if (l->number == *max) { *max += 1000; @@ -1129,7 +1129,7 @@ void elfAddLine(LineInfo* l, u32 a, int file, int line, int* max) l->number++; } -void elfParseLineInfo(CompileUnit* unit, u8* top) +void elfParseLineInfo(CompileUnit* unit, uint8_t* top) { ELFSectionHeader* h = elfGetSectionByName(".debug_line"); if (h == NULL) { @@ -1141,21 +1141,21 @@ void elfParseLineInfo(CompileUnit* unit, u8* top) int max = 1000; l->lines = (LineInfoItem*)malloc(1000 * sizeof(LineInfoItem)); - u8* data = elfReadSection(top, h); + uint8_t* data = elfReadSection(top, h); data += unit->lineInfo; - u32 totalLen = elfRead4Bytes(data); + uint32_t totalLen = elfRead4Bytes(data); data += 4; - u8* end = data + totalLen; - // u16 version = elfRead2Bytes(data); + uint8_t* end = data + totalLen; + // uint16_t version = elfRead2Bytes(data); data += 2; - // u32 offset = elfRead4Bytes(data); + // uint32_t offset = elfRead4Bytes(data); data += 4; int minInstrSize = *data++; int defaultIsStmt = *data++; - int lineBase = (s8)*data++; + int lineBase = (int8_t)*data++; int lineRange = *data++; int opcodeBase = *data++; - u8* stdOpLen = (u8*)malloc(opcodeBase * sizeof(u8)); + uint8_t* stdOpLen = (uint8_t*)malloc(opcodeBase * sizeof(uint8_t)); stdOpLen[0] = 1; int i; for (i = 1; i < opcodeBase; i++) @@ -1197,7 +1197,7 @@ void elfParseLineInfo(CompileUnit* unit, u8* top) data += bytes; while (data < end) { - u32 address = 0; + uint32_t address = 0; int file = 1; int line = 1; int col = 0; @@ -1272,7 +1272,7 @@ void elfParseLineInfo(CompileUnit* unit, u8* top) l->lines = (LineInfoItem*)realloc(l->lines, l->number * sizeof(LineInfoItem)); } -u8* elfSkipData(u8* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) +uint8_t* elfSkipData(uint8_t* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) { int i; int bytes; @@ -1286,7 +1286,7 @@ u8* elfSkipData(u8* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) if (abbrev->hasChildren) { int nesting = 1; while (nesting) { - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -1310,14 +1310,14 @@ u8* elfSkipData(u8* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) return data; } -Type* elfParseType(CompileUnit* unit, u32); -u8* elfParseObject(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, +Type* elfParseType(CompileUnit* unit, uint32_t); +uint8_t* elfParseObject(uint8_t* data, ELFAbbrev* abbrev, CompileUnit* unit, Object** object); -u8* elfParseFunction(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, +uint8_t* elfParseFunction(uint8_t* data, ELFAbbrev* abbrev, CompileUnit* unit, Function** function); void elfCleanUp(Function*); -void elfAddType(Type* type, CompileUnit* unit, u32 offset) +void elfAddType(Type* type, CompileUnit* unit, uint32_t offset) { if (type->next == NULL) { if (unit->types != type && type->offset == 0) { @@ -1328,12 +1328,12 @@ void elfAddType(Type* type, CompileUnit* unit, u32 offset) } } -void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, +void elfParseType(uint8_t* data, uint32_t offset, ELFAbbrev* abbrev, CompileUnit* unit, Type** type) { switch (abbrev->tag) { case DW_TAG_typedef: { - u32 typeref = 0; + uint32_t typeref = 0; char* name = NULL; for (int i = 0; i < abbrev->numAttrs; i++) { ELFAttr* attr = &abbrev->attrs[i]; @@ -1396,7 +1396,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, } if (abbrev->hasChildren) { int bytes; - u32 num = elfReadLEB128(data, &bytes); + uint32_t num = elfReadLEB128(data, &bytes); data += bytes; int index = 0; while (num) { @@ -1568,7 +1568,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, return; } break; case DW_TAG_volatile_type: { - u32 typeref = 0; + uint32_t typeref = 0; for (int i = 0; i < abbrev->numAttrs; i++) { ELFAttr* attr = &abbrev->attrs[i]; @@ -1589,7 +1589,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, return; } break; case DW_TAG_const_type: { - u32 typeref = 0; + uint32_t typeref = 0; for (int i = 0; i < abbrev->numAttrs; i++) { ELFAttr* attr = &abbrev->attrs[i]; @@ -1636,7 +1636,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, } if (abbrev->hasChildren) { int bytes; - u32 num = elfReadLEB128(data, &bytes); + uint32_t num = elfReadLEB128(data, &bytes); data += bytes; while (num) { ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num); @@ -1698,7 +1698,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, } if (abbrev->hasChildren) { int bytes; - u32 num = elfReadLEB128(data, &bytes); + uint32_t num = elfReadLEB128(data, &bytes); data += bytes; Object* lastVar = NULL; while (num) { @@ -1735,7 +1735,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, return; } break; case DW_TAG_array_type: { - u32 typeref = 0; + uint32_t typeref = 0; int i; Array* array = (Array*)calloc(sizeof(Array), 1); Type* t = (Type*)calloc(sizeof(Type), 1); @@ -1758,7 +1758,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, } if (abbrev->hasChildren) { int bytes; - u32 num = elfReadLEB128(data, &bytes); + uint32_t num = elfReadLEB128(data, &bytes); data += bytes; int index = 0; int maxBounds = 0; @@ -1811,7 +1811,7 @@ void elfParseType(u8* data, u32 offset, ELFAbbrev* abbrev, CompileUnit* unit, } } -Type* elfParseType(CompileUnit* unit, u32 offset) +Type* elfParseType(CompileUnit* unit, uint32_t offset) { Type* t = unit->types; @@ -1827,7 +1827,7 @@ Type* elfParseType(CompileUnit* unit, u32 offset) elfAddType(t, unit, 0); return t; } - u8* data = unit->top + offset; + uint8_t* data = unit->top + offset; int bytes; int abbrevNum = elfReadLEB128(data, &bytes); data += bytes; @@ -1839,11 +1839,11 @@ Type* elfParseType(CompileUnit* unit, u32 offset) return type; } -void elfGetObjectAttributes(CompileUnit* unit, u32 offset, Object* o) +void elfGetObjectAttributes(CompileUnit* unit, uint32_t offset, Object* o) { - u8* data = unit->top + offset; + uint8_t* data = unit->top + offset; int bytes; - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -1894,7 +1894,7 @@ void elfGetObjectAttributes(CompileUnit* unit, u32 offset, Object* o) } } -u8* elfParseObject(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, +uint8_t* elfParseObject(uint8_t* data, ELFAbbrev* abbrev, CompileUnit* unit, Object** object) { Object* o = (Object*)calloc(sizeof(Object), 1); @@ -1946,12 +1946,12 @@ u8* elfParseObject(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, return data; } -u8* elfParseBlock(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, +uint8_t* elfParseBlock(uint8_t* data, ELFAbbrev* abbrev, CompileUnit* unit, Function* func, Object** lastVar) { int bytes; - u32 start = func->lowPC; - u32 end = func->highPC; + uint32_t start = func->lowPC; + uint32_t end = func->highPC; for (int i = 0; i < abbrev->numAttrs; i++) { ELFAttr* attr = &abbrev->attrs[i]; @@ -1977,7 +1977,7 @@ u8* elfParseBlock(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, int nesting = 1; while (nesting) { - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -2033,11 +2033,11 @@ u8* elfParseBlock(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, return data; } -void elfGetFunctionAttributes(CompileUnit* unit, u32 offset, Function* func) +void elfGetFunctionAttributes(CompileUnit* unit, uint32_t offset, Function* func) { - u8* data = unit->top + offset; + uint8_t* data = unit->top + offset; int bytes; - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -2106,7 +2106,7 @@ void elfGetFunctionAttributes(CompileUnit* unit, u32 offset, Function* func) return; } -u8* elfParseFunction(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, +uint8_t* elfParseFunction(uint8_t* data, ELFAbbrev* abbrev, CompileUnit* unit, Function** f) { Function* func = (Function*)calloc(sizeof(Function), 1); @@ -2184,7 +2184,7 @@ u8* elfParseFunction(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, *f = NULL; while (1) { - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -2203,7 +2203,7 @@ u8* elfParseFunction(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, Object* lastVar = NULL; while (nesting) { - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -2272,7 +2272,7 @@ u8* elfParseFunction(u8* data, ELFAbbrev* abbrev, CompileUnit* unit, return data; } -u8* elfParseUnknownData(u8* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) +uint8_t* elfParseUnknownData(uint8_t* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) { int i; int bytes; @@ -2289,7 +2289,7 @@ u8* elfParseUnknownData(u8* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) if (abbrev->hasChildren) { int nesting = 1; while (nesting) { - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; if (!abbrevNum) { @@ -2316,10 +2316,10 @@ u8* elfParseUnknownData(u8* data, ELFAbbrev* abbrev, ELFAbbrev** abbrevs) return data; } -u8* elfParseCompileUnitChildren(u8* data, CompileUnit* unit) +uint8_t* elfParseCompileUnitChildren(uint8_t* data, CompileUnit* unit) { int bytes; - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; Object* lastObj = NULL; while (abbrevNum) { @@ -2359,21 +2359,21 @@ u8* elfParseCompileUnitChildren(u8* data, CompileUnit* unit) return data; } -CompileUnit* elfParseCompUnit(u8* data, u8* abbrevData) +CompileUnit* elfParseCompUnit(uint8_t* data, uint8_t* abbrevData) { int bytes; - u8* top = data; + uint8_t* top = data; - u32 length = elfRead4Bytes(data); + uint32_t length = elfRead4Bytes(data); data += 4; - u16 version = elfRead2Bytes(data); + uint16_t version = elfRead2Bytes(data); data += 2; - u32 offset = elfRead4Bytes(data); + uint32_t offset = elfRead4Bytes(data); data += 4; - u8 addrSize = *data++; + uint8_t addrSize = *data++; if (version != 2) { fprintf(stderr, "Unsupported debugging information version %d\n", version); @@ -2387,7 +2387,7 @@ CompileUnit* elfParseCompUnit(u8* data, u8* abbrevData) ELFAbbrev** abbrevs = elfReadAbbrevs(abbrevData, offset); - u32 abbrevNum = elfReadLEB128(data, &bytes); + uint32_t abbrevNum = elfReadLEB128(data, &bytes); data += bytes; ELFAbbrev* abbrev = elfGetAbbrev(abbrevs, abbrevNum); @@ -2441,7 +2441,7 @@ CompileUnit* elfParseCompUnit(u8* data, u8* abbrevData) return unit; } -void elfParseAranges(u8* data) +void elfParseAranges(uint8_t* data) { ELFSectionHeader* sh = elfGetSectionByName(".debug_aranges"); if (sh == NULL) { @@ -2450,7 +2450,7 @@ void elfParseAranges(u8* data) } data = elfReadSection(data, sh); - u8* end = data + READ32LE(&sh->size); + uint8_t* end = data + READ32LE(&sh->size); int max = 4; ARanges* ranges = (ARanges*)calloc(sizeof(ARanges), 4); @@ -2458,14 +2458,14 @@ void elfParseAranges(u8* data) int index = 0; while (data < end) { - u32 len = elfRead4Bytes(data); + uint32_t len = elfRead4Bytes(data); data += 4; - // u16 version = elfRead2Bytes(data); + // uint16_t version = elfRead2Bytes(data); data += 2; - u32 offset = elfRead4Bytes(data); + uint32_t offset = elfRead4Bytes(data); data += 4; - // u8 addrSize = *data++; - // u8 segSize = *data++; + // uint8_t addrSize = *data++; + // uint8_t segSize = *data++; data += 2; // remove if uncommenting above data += 4; ranges[index].count = (len - 20) / 8; @@ -2473,9 +2473,9 @@ void elfParseAranges(u8* data) ranges[index].ranges = (ARange*)calloc(sizeof(ARange), (len - 20) / 8); int i = 0; while (true) { - u32 addr = elfRead4Bytes(data); + uint32_t addr = elfRead4Bytes(data); data += 4; - u32 len = elfRead4Bytes(data); + uint32_t len = elfRead4Bytes(data); data += 4; if (addr == 0 && len == 0) break; @@ -2493,7 +2493,7 @@ void elfParseAranges(u8* data) elfDebugInfo->ranges = ranges; } -void elfReadSymtab(u8* data) +void elfReadSymtab(uint8_t* data) { ELFSectionHeader* sh = elfGetSectionByName(".symtab"); int table = READ32LE(&sh->link); @@ -2543,7 +2543,7 @@ void elfReadSymtab(u8* data) // free(symtab); } -bool elfReadProgram(ELFHeader* eh, u8* data, int& size, bool parseDebug) +bool elfReadProgram(ELFHeader* eh, uint8_t* data, int& size, bool parseDebug) { int count = READ16LE(&eh->e_phnum); int i; @@ -2552,7 +2552,7 @@ bool elfReadProgram(ELFHeader* eh, u8* data, int& size, bool parseDebug) cpuIsMultiBoot = true; // read program headers... should probably move this code down - u8* p = data + READ32LE(&eh->e_phoff); + uint8_t* p = data + READ32LE(&eh->e_phoff); size = 0; for (i = 0; i < count; i++) { ELFProgramHeader* ph = (ELFProgramHeader*)p; @@ -2645,7 +2645,7 @@ bool elfReadProgram(ELFHeader* eh, u8* data, int& size, bool parseDebug) } elfDebugInfo = (DebugInfo*)calloc(sizeof(DebugInfo), 1); - u8* abbrevdata = elfReadSection(data, h); + uint8_t* abbrevdata = elfReadSection(data, h); h = elfGetSectionByName(".debug_str"); @@ -2654,21 +2654,21 @@ bool elfReadProgram(ELFHeader* eh, u8* data, int& size, bool parseDebug) else elfDebugStrings = (char*)elfReadSection(data, h); - u8* debugdata = elfReadSection(data, dbgHeader); + uint8_t* debugdata = elfReadSection(data, dbgHeader); elfDebugInfo->debugdata = data; elfDebugInfo->infodata = debugdata; - u32 total = READ32LE(&dbgHeader->size); - u8* end = debugdata + total; - u8* ddata = debugdata; + uint32_t total = READ32LE(&dbgHeader->size); + uint8_t* end = debugdata + total; + uint8_t* ddata = debugdata; CompileUnit* last = NULL; CompileUnit* unit = NULL; while (ddata < end) { unit = elfParseCompUnit(ddata, abbrevdata); - unit->offset = (u32)(ddata - debugdata); + unit->offset = (uint32_t)(ddata - debugdata); elfParseLineInfo(unit, data); if (last == NULL) elfCompileUnits = unit; @@ -2709,7 +2709,7 @@ bool elfRead(const char* name, int& siz, FILE* f) { fseek(f, 0, SEEK_END); long size = ftell(f); - elfFileData = (u8*)malloc(size); + elfFileData = (uint8_t*)malloc(size); fseek(f, 0, SEEK_SET); int res = fread(elfFileData, 1, size, f); fclose(f); diff --git a/src/gba/elf.h b/src/gba/elf.h index 46636b7a..7c87dd43 100644 --- a/src/gba/elf.h +++ b/src/gba/elf.h @@ -11,79 +11,79 @@ enum LocationType { LOCATION_register, #define DW_ATE_unsigned_char 0x08 struct ELFHeader { - u32 magic; - u8 clazz; - u8 data; - u8 version; - u8 pad[9]; - u16 e_type; - u16 e_machine; - u32 e_version; - u32 e_entry; - u32 e_phoff; - u32 e_shoff; - u32 e_flags; - u16 e_ehsize; - u16 e_phentsize; - u16 e_phnum; - u16 e_shentsize; - u16 e_shnum; - u16 e_shstrndx; + uint32_t magic; + uint8_t clazz; + uint8_t data; + uint8_t version; + uint8_t pad[9]; + uint16_t e_type; + uint16_t e_machine; + uint32_t e_version; + uint32_t e_entry; + uint32_t e_phoff; + uint32_t e_shoff; + uint32_t e_flags; + uint16_t e_ehsize; + uint16_t e_phentsize; + uint16_t e_phnum; + uint16_t e_shentsize; + uint16_t e_shnum; + uint16_t e_shstrndx; }; struct ELFProgramHeader { - u32 type; - u32 offset; - u32 vaddr; - u32 paddr; - u32 filesz; - u32 memsz; - u32 flags; - u32 align; + uint32_t type; + uint32_t offset; + uint32_t vaddr; + uint32_t paddr; + uint32_t filesz; + uint32_t memsz; + uint32_t flags; + uint32_t align; }; struct ELFSectionHeader { - u32 name; - u32 type; - u32 flags; - u32 addr; - u32 offset; - u32 size; - u32 link; - u32 info; - u32 addralign; - u32 entsize; + uint32_t name; + uint32_t type; + uint32_t flags; + uint32_t addr; + uint32_t offset; + uint32_t size; + uint32_t link; + uint32_t info; + uint32_t addralign; + uint32_t entsize; }; struct ELFSymbol { - u32 name; - u32 value; - u32 size; - u8 info; - u8 other; - u16 shndx; + uint32_t name; + uint32_t value; + uint32_t size; + uint8_t info; + uint8_t other; + uint16_t shndx; }; struct ELFBlock { int length; - u8* data; + uint8_t* data; }; struct ELFAttr { - u32 name; - u32 form; + uint32_t name; + uint32_t form; union { - u32 value; + uint32_t value; char* string; - u8* data; + uint8_t* data; bool flag; ELFBlock* block; }; }; struct ELFAbbrev { - u32 number; - u32 tag; + uint32_t number; + uint32_t tag; bool hasChildren; int numAttrs; ELFAttr* attrs; @@ -132,7 +132,7 @@ struct Array { struct EnumMember { char* name; - u32 value; + uint32_t value; }; struct Enum { @@ -141,7 +141,7 @@ struct Enum { }; struct Type { - u32 offset; + uint32_t offset; TypeEnum type; const char* name; int encoding; @@ -164,15 +164,15 @@ struct Object { bool external; Type* type; ELFBlock* location; - u32 startScope; - u32 endScope; + uint32_t startScope; + uint32_t endScope; Object* next; }; struct Function { char* name; - u32 lowPC; - u32 highPC; + uint32_t lowPC; + uint32_t highPC; int file; int line; bool external; @@ -184,7 +184,7 @@ struct Function { }; struct LineInfoItem { - u32 address; + uint32_t address; char* file; int line; }; @@ -197,28 +197,28 @@ struct LineInfo { }; struct ARange { - u32 lowPC; - u32 highPC; + uint32_t lowPC; + uint32_t highPC; }; struct ARanges { - u32 offset; + uint32_t offset; int count; ARange* ranges; }; struct CompileUnit { - u32 length; - u8* top; - u32 offset; + uint32_t length; + uint8_t* top; + uint32_t offset; ELFAbbrev** abbrevs; ARanges* ranges; char* name; char* compdir; - u32 lowPC; - u32 highPC; + uint32_t lowPC; + uint32_t highPC; bool hasLineInfo; - u32 lineInfo; + uint32_t lineInfo; LineInfo* lineInfoTable; Function* functions; Function* lastFunction; @@ -228,10 +228,10 @@ struct CompileUnit { }; struct DebugInfo { - u8* debugfile; - u8* abbrevdata; - u8* debugdata; - u8* infodata; + uint8_t* debugfile; + uint8_t* abbrevdata; + uint8_t* debugdata; + uint8_t* infodata; int numRanges; ARanges* ranges; }; @@ -240,24 +240,24 @@ struct Symbol { const char* name; int type; int binding; - u32 address; - u32 value; - u32 size; + uint32_t address; + uint32_t value; + uint32_t size; }; -extern u32 elfReadLEB128(u8*, int*); -extern s32 elfReadSignedLEB128(u8*, int*); +extern uint32_t elfReadLEB128(uint8_t*, int*); +extern int32_t elfReadSignedLEB128(uint8_t*, int*); extern bool elfRead(const char*, int&, FILE* f); -extern bool elfGetSymbolAddress(const char*, u32*, u32*, int*); -extern const char* elfGetAddressSymbol(u32); -extern const char* elfGetSymbol(int, u32*, u32*, int*); +extern bool elfGetSymbolAddress(const char*, uint32_t*, uint32_t*, int*); +extern const char* elfGetAddressSymbol(uint32_t); +extern const char* elfGetSymbol(int, uint32_t*, uint32_t*, int*); extern void elfCleanUp(); -extern bool elfGetCurrentFunction(u32, Function**, CompileUnit** c); +extern bool elfGetCurrentFunction(uint32_t, Function**, CompileUnit** c); extern bool elfGetObject(const char*, Function*, CompileUnit*, Object**); -extern bool elfFindLineInUnit(u32*, CompileUnit*, int); -extern bool elfFindLineInModule(u32*, const char*, int); -u32 elfDecodeLocation(Function*, ELFBlock*, LocationType*); -u32 elfDecodeLocation(Function*, ELFBlock*, LocationType*, u32); -int elfFindLine(CompileUnit* unit, Function* func, u32 addr, const char**); +extern bool elfFindLineInUnit(uint32_t*, CompileUnit*, int); +extern bool elfFindLineInModule(uint32_t*, const char*, int); +uint32_t elfDecodeLocation(Function*, ELFBlock*, LocationType*); +uint32_t elfDecodeLocation(Function*, ELFBlock*, LocationType*, uint32_t); +int elfFindLine(CompileUnit* unit, Function* func, uint32_t addr, const char**); #endif // ELF_H diff --git a/src/gba/ereader.cpp b/src/gba/ereader.cpp index 63b4fcf3..41413d3c 100644 --- a/src/gba/ereader.cpp +++ b/src/gba/ereader.cpp @@ -80,7 +80,7 @@ int dotcodepointer; int dotcodeinterleave; int decodestate; -u32 GFpow; +uint32_t GFpow; unsigned char* DotCodeData; char filebuffer[2048]; @@ -108,9 +108,9 @@ int CheckEReaderRegion(void) //US = 1, JAP = 2, JAP+ = 3 return 0; } -int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM2, int loadraw) +int LoadDotCodeData(int size, uint32_t* DCdata, unsigned long MEM1, unsigned long MEM2, int loadraw) { - u32 temp1; + uint32_t temp1; int i, j; unsigned char scanmap[28]; @@ -201,17 +201,17 @@ int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM return 0; } -void EReaderWriteMemory(u32 address, u32 value) +void EReaderWriteMemory(uint32_t address, uint32_t value) { switch (address >> 24) { case 2: - WRITE32LE(((u32*)&workRAM[address & 0x3FFFF]), value); + WRITE32LE(((uint32_t*)&workRAM[address & 0x3FFFF]), value); break; case 3: - WRITE32LE(((u32*)&internalRAM[address & 0x7FFF]), value); + WRITE32LE(((uint32_t*)&internalRAM[address & 0x7FFF]), value); break; default: - WRITE32LE(((u32*)&rom[address & 0x1FFFFFF]), value); + WRITE32LE(((uint32_t*)&rom[address & 0x1FFFFFF]), value); //rom[address & 0x1FFFFFF] = data; break; } @@ -271,15 +271,15 @@ void BIOS_EReader_ScanCard(int swi_num) switch (CheckEReaderRegion()) { case 1: //US - LoadDotCodeData(i, (u32*)DotCodeData, 0x2032D14, 0x2028B28, 1); + LoadDotCodeData(i, (uint32_t*)DotCodeData, 0x2032D14, 0x2028B28, 1); EReaderWriteMemory(0x80091BA, 0x46C0DFE2); break; case 2: - LoadDotCodeData(i, (u32*)DotCodeData, 0x2006EC4, 0x2002478, 1); + LoadDotCodeData(i, (uint32_t*)DotCodeData, 0x2006EC4, 0x2002478, 1); EReaderWriteMemory(0x8008B12, 0x46C0DFE2); break; case 3: - LoadDotCodeData(i, (u32*)DotCodeData, 0x202F8A4, 0x2031034, 1); + LoadDotCodeData(i, (uint32_t*)DotCodeData, 0x202F8A4, 0x2031034, 1); EReaderWriteMemory(0x800922E, 0x46C0DFE2); break; } @@ -294,15 +294,15 @@ void BIOS_EReader_ScanCard(int swi_num) switch (CheckEReaderRegion()) { case 1: //US - LoadDotCodeData(dotcodesize, (u32*)NULL, 0x2032D14, 0x2028B28, 0); + LoadDotCodeData(dotcodesize, (uint32_t*)NULL, 0x2032D14, 0x2028B28, 0); EReaderWriteMemory(0x80091BA, 0x46C0DFE1); break; case 2: - LoadDotCodeData(dotcodesize, (u32*)NULL, 0x2006EC4, 0x2002478, 0); + LoadDotCodeData(dotcodesize, (uint32_t*)NULL, 0x2006EC4, 0x2002478, 0); EReaderWriteMemory(0x8008B12, 0x46C0DFE1); break; case 3: - LoadDotCodeData(dotcodesize, (u32*)NULL, 0x202F8A4, 0x2031034, 0); + LoadDotCodeData(dotcodesize, (uint32_t*)NULL, 0x202F8A4, 0x2031034, 0); EReaderWriteMemory(0x800922E, 0x46C0DFE1); break; } diff --git a/src/gba/ereader.h b/src/gba/ereader.h index 88e58806..72d8209b 100644 --- a/src/gba/ereader.h +++ b/src/gba/ereader.h @@ -3,7 +3,7 @@ extern char filebuffer[]; int OpenDotCodeFile(void); int CheckEReaderRegion(void); -int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM2); -void EReaderWriteMemory(u32 address, u32 value); +int LoadDotCodeData(int size, uint32_t* DCdata, unsigned long MEM1, unsigned long MEM2); +void EReaderWriteMemory(uint32_t address, uint32_t value); void BIOS_EReader_ScanCard(int swi_num);