bios.cpp done, still a bit to go for the cores
This commit is contained in:
parent
1944613131
commit
f0a4b5e533
|
@ -7,15 +7,15 @@
|
|||
#include "Globals.h"
|
||||
|
||||
#define debuggerWriteHalfWord(addr, value) \
|
||||
WRITE16LE((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask], (value))
|
||||
WRITE16LE((uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask], (value))
|
||||
|
||||
#define debuggerReadHalfWord(addr) \
|
||||
READ16LE(((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||
READ16LE(((uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||
|
||||
static bool agbPrintEnabled = false;
|
||||
static bool agbPrintProtect = false;
|
||||
|
||||
bool agbPrintWrite(u32 address, u16 value)
|
||||
bool agbPrintWrite(uint32_t address, uint16_t value)
|
||||
{
|
||||
if (agbPrintEnabled) {
|
||||
if (address == 0x9fe2ffe) { // protect
|
||||
|
@ -51,10 +51,10 @@ bool agbPrintIsEnabled()
|
|||
|
||||
void agbPrintFlush()
|
||||
{
|
||||
u16 get = debuggerReadHalfWord(0x9fe20fc);
|
||||
u16 put = debuggerReadHalfWord(0x9fe20fe);
|
||||
uint16_t get = debuggerReadHalfWord(0x9fe20fc);
|
||||
uint16_t put = debuggerReadHalfWord(0x9fe20fe);
|
||||
|
||||
u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16);
|
||||
uint32_t address = (debuggerReadHalfWord(0x9fe20fa) << 16);
|
||||
if (address != 0xfd0000 && address != 0x1fd0000) {
|
||||
dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
|
||||
// get rid of the text otherwise we will continue to be called
|
||||
|
@ -62,7 +62,7 @@ void agbPrintFlush()
|
|||
return;
|
||||
}
|
||||
|
||||
u8* data = &rom[address];
|
||||
uint8_t* data = &rom[address];
|
||||
|
||||
while (get != put) {
|
||||
char c = data[get++];
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
void agbPrintEnable(bool enable);
|
||||
bool agbPrintIsEnabled();
|
||||
void agbPrintReset();
|
||||
bool agbPrintWrite(u32 address, u16 value);
|
||||
bool agbPrintWrite(uint32_t address, uint16_t value);
|
||||
void agbPrintFlush();
|
||||
|
||||
#endif // AGBPRINT_H
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
#include "elf.h"
|
||||
|
||||
struct Opcodes {
|
||||
u32 mask;
|
||||
u32 cval;
|
||||
uint32_t mask;
|
||||
uint32_t cval;
|
||||
const char* mnemonic;
|
||||
};
|
||||
|
||||
#define debuggerReadMemory(addr) \
|
||||
READ32LE(((u32*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||
READ32LE(((uint32_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||
|
||||
#define debuggerReadHalfWord(addr) \
|
||||
READ16LE(((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||
READ16LE(((uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||
|
||||
#define debuggerReadByte(addr) \
|
||||
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
||||
|
@ -199,7 +199,7 @@ char* addStr(char* dest, const char* src)
|
|||
return dest;
|
||||
}
|
||||
|
||||
char* addHex(char* dest, int siz, u32 val)
|
||||
char* addHex(char* dest, int siz, uint32_t val)
|
||||
{
|
||||
if (siz == 0) {
|
||||
siz = 28;
|
||||
|
@ -214,9 +214,9 @@ char* addHex(char* dest, int siz, u32 val)
|
|||
return dest;
|
||||
}
|
||||
|
||||
int disArm(u32 offset, char* dest, int flags)
|
||||
int disArm(uint32_t offset, char* dest, int flags)
|
||||
{
|
||||
u32 opcode = debuggerReadMemory(offset);
|
||||
uint32_t opcode = debuggerReadMemory(offset);
|
||||
|
||||
const Opcodes* sp = armOpcodes;
|
||||
while (sp->cval != (opcode & sp->mask))
|
||||
|
@ -523,9 +523,9 @@ int disArm(u32 offset, char* dest, int flags)
|
|||
return 4;
|
||||
}
|
||||
|
||||
int disThumb(u32 offset, char* dest, int flags)
|
||||
int disThumb(uint32_t offset, char* dest, int flags)
|
||||
{
|
||||
u32 opcode = debuggerReadHalfWord(offset);
|
||||
uint32_t opcode = debuggerReadHalfWord(offset);
|
||||
|
||||
const Opcodes* sp = thumbOpcodes;
|
||||
int ret = 2;
|
||||
|
@ -593,7 +593,7 @@ int disThumb(u32 offset, char* dest, int flags)
|
|||
dest = addHex(dest, 32, (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
|
||||
break;
|
||||
case 'J': {
|
||||
u32 value = debuggerReadMemory((offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
|
||||
uint32_t value = debuggerReadMemory((offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
|
||||
*dest++ = '$';
|
||||
dest = addHex(dest, 32, value);
|
||||
const char* s = elfGetAddressSymbol(value);
|
||||
|
@ -603,7 +603,7 @@ int disThumb(u32 offset, char* dest, int flags)
|
|||
}
|
||||
} break;
|
||||
case 'K': {
|
||||
u32 value = (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2);
|
||||
uint32_t value = (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2);
|
||||
*dest++ = '$';
|
||||
dest = addHex(dest, 32, value);
|
||||
const char* s = elfGetAddressSymbol(value);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define DIS_VIEW_ADDRESS 1
|
||||
#define DIS_VIEW_CODE 2
|
||||
|
||||
int disThumb(u32 offset, char* dest, int flags);
|
||||
int disArm(u32 offset, char* dest, int flags);
|
||||
int disThumb(uint32_t offset, char* dest, int flags);
|
||||
int disArm(uint32_t offset, char* dest, int flags);
|
||||
|
||||
#endif // __ARMDIS_H__
|
||||
|
|
442
src/gba/bios.cpp
442
src/gba/bios.cpp
|
@ -7,39 +7,39 @@
|
|||
#include "Globals.h"
|
||||
#include "bios.h"
|
||||
|
||||
s16 sineTable[256] = {
|
||||
(s16)0x0000, (s16)0x0192, (s16)0x0323, (s16)0x04B5, (s16)0x0645, (s16)0x07D5, (s16)0x0964, (s16)0x0AF1,
|
||||
(s16)0x0C7C, (s16)0x0E05, (s16)0x0F8C, (s16)0x1111, (s16)0x1294, (s16)0x1413, (s16)0x158F, (s16)0x1708,
|
||||
(s16)0x187D, (s16)0x19EF, (s16)0x1B5D, (s16)0x1CC6, (s16)0x1E2B, (s16)0x1F8B, (s16)0x20E7, (s16)0x223D,
|
||||
(s16)0x238E, (s16)0x24DA, (s16)0x261F, (s16)0x275F, (s16)0x2899, (s16)0x29CD, (s16)0x2AFA, (s16)0x2C21,
|
||||
(s16)0x2D41, (s16)0x2E5A, (s16)0x2F6B, (s16)0x3076, (s16)0x3179, (s16)0x3274, (s16)0x3367, (s16)0x3453,
|
||||
(s16)0x3536, (s16)0x3612, (s16)0x36E5, (s16)0x37AF, (s16)0x3871, (s16)0x392A, (s16)0x39DA, (s16)0x3A82,
|
||||
(s16)0x3B20, (s16)0x3BB6, (s16)0x3C42, (s16)0x3CC5, (s16)0x3D3E, (s16)0x3DAE, (s16)0x3E14, (s16)0x3E71,
|
||||
(s16)0x3EC5, (s16)0x3F0E, (s16)0x3F4E, (s16)0x3F84, (s16)0x3FB1, (s16)0x3FD3, (s16)0x3FEC, (s16)0x3FFB,
|
||||
(s16)0x4000, (s16)0x3FFB, (s16)0x3FEC, (s16)0x3FD3, (s16)0x3FB1, (s16)0x3F84, (s16)0x3F4E, (s16)0x3F0E,
|
||||
(s16)0x3EC5, (s16)0x3E71, (s16)0x3E14, (s16)0x3DAE, (s16)0x3D3E, (s16)0x3CC5, (s16)0x3C42, (s16)0x3BB6,
|
||||
(s16)0x3B20, (s16)0x3A82, (s16)0x39DA, (s16)0x392A, (s16)0x3871, (s16)0x37AF, (s16)0x36E5, (s16)0x3612,
|
||||
(s16)0x3536, (s16)0x3453, (s16)0x3367, (s16)0x3274, (s16)0x3179, (s16)0x3076, (s16)0x2F6B, (s16)0x2E5A,
|
||||
(s16)0x2D41, (s16)0x2C21, (s16)0x2AFA, (s16)0x29CD, (s16)0x2899, (s16)0x275F, (s16)0x261F, (s16)0x24DA,
|
||||
(s16)0x238E, (s16)0x223D, (s16)0x20E7, (s16)0x1F8B, (s16)0x1E2B, (s16)0x1CC6, (s16)0x1B5D, (s16)0x19EF,
|
||||
(s16)0x187D, (s16)0x1708, (s16)0x158F, (s16)0x1413, (s16)0x1294, (s16)0x1111, (s16)0x0F8C, (s16)0x0E05,
|
||||
(s16)0x0C7C, (s16)0x0AF1, (s16)0x0964, (s16)0x07D5, (s16)0x0645, (s16)0x04B5, (s16)0x0323, (s16)0x0192,
|
||||
(s16)0x0000, (s16)0xFE6E, (s16)0xFCDD, (s16)0xFB4B, (s16)0xF9BB, (s16)0xF82B, (s16)0xF69C, (s16)0xF50F,
|
||||
(s16)0xF384, (s16)0xF1FB, (s16)0xF074, (s16)0xEEEF, (s16)0xED6C, (s16)0xEBED, (s16)0xEA71, (s16)0xE8F8,
|
||||
(s16)0xE783, (s16)0xE611, (s16)0xE4A3, (s16)0xE33A, (s16)0xE1D5, (s16)0xE075, (s16)0xDF19, (s16)0xDDC3,
|
||||
(s16)0xDC72, (s16)0xDB26, (s16)0xD9E1, (s16)0xD8A1, (s16)0xD767, (s16)0xD633, (s16)0xD506, (s16)0xD3DF,
|
||||
(s16)0xD2BF, (s16)0xD1A6, (s16)0xD095, (s16)0xCF8A, (s16)0xCE87, (s16)0xCD8C, (s16)0xCC99, (s16)0xCBAD,
|
||||
(s16)0xCACA, (s16)0xC9EE, (s16)0xC91B, (s16)0xC851, (s16)0xC78F, (s16)0xC6D6, (s16)0xC626, (s16)0xC57E,
|
||||
(s16)0xC4E0, (s16)0xC44A, (s16)0xC3BE, (s16)0xC33B, (s16)0xC2C2, (s16)0xC252, (s16)0xC1EC, (s16)0xC18F,
|
||||
(s16)0xC13B, (s16)0xC0F2, (s16)0xC0B2, (s16)0xC07C, (s16)0xC04F, (s16)0xC02D, (s16)0xC014, (s16)0xC005,
|
||||
(s16)0xC000, (s16)0xC005, (s16)0xC014, (s16)0xC02D, (s16)0xC04F, (s16)0xC07C, (s16)0xC0B2, (s16)0xC0F2,
|
||||
(s16)0xC13B, (s16)0xC18F, (s16)0xC1EC, (s16)0xC252, (s16)0xC2C2, (s16)0xC33B, (s16)0xC3BE, (s16)0xC44A,
|
||||
(s16)0xC4E0, (s16)0xC57E, (s16)0xC626, (s16)0xC6D6, (s16)0xC78F, (s16)0xC851, (s16)0xC91B, (s16)0xC9EE,
|
||||
(s16)0xCACA, (s16)0xCBAD, (s16)0xCC99, (s16)0xCD8C, (s16)0xCE87, (s16)0xCF8A, (s16)0xD095, (s16)0xD1A6,
|
||||
(s16)0xD2BF, (s16)0xD3DF, (s16)0xD506, (s16)0xD633, (s16)0xD767, (s16)0xD8A1, (s16)0xD9E1, (s16)0xDB26,
|
||||
(s16)0xDC72, (s16)0xDDC3, (s16)0xDF19, (s16)0xE075, (s16)0xE1D5, (s16)0xE33A, (s16)0xE4A3, (s16)0xE611,
|
||||
(s16)0xE783, (s16)0xE8F8, (s16)0xEA71, (s16)0xEBED, (s16)0xED6C, (s16)0xEEEF, (s16)0xF074, (s16)0xF1FB,
|
||||
(s16)0xF384, (s16)0xF50F, (s16)0xF69C, (s16)0xF82B, (s16)0xF9BB, (s16)0xFB4B, (s16)0xFCDD, (s16)0xFE6E
|
||||
int16_t sineTable[256] = {
|
||||
(int16_t)0x0000, (int16_t)0x0192, (int16_t)0x0323, (int16_t)0x04B5, (int16_t)0x0645, (int16_t)0x07D5, (int16_t)0x0964, (int16_t)0x0AF1,
|
||||
(int16_t)0x0C7C, (int16_t)0x0E05, (int16_t)0x0F8C, (int16_t)0x1111, (int16_t)0x1294, (int16_t)0x1413, (int16_t)0x158F, (int16_t)0x1708,
|
||||
(int16_t)0x187D, (int16_t)0x19EF, (int16_t)0x1B5D, (int16_t)0x1CC6, (int16_t)0x1E2B, (int16_t)0x1F8B, (int16_t)0x20E7, (int16_t)0x223D,
|
||||
(int16_t)0x238E, (int16_t)0x24DA, (int16_t)0x261F, (int16_t)0x275F, (int16_t)0x2899, (int16_t)0x29CD, (int16_t)0x2AFA, (int16_t)0x2C21,
|
||||
(int16_t)0x2D41, (int16_t)0x2E5A, (int16_t)0x2F6B, (int16_t)0x3076, (int16_t)0x3179, (int16_t)0x3274, (int16_t)0x3367, (int16_t)0x3453,
|
||||
(int16_t)0x3536, (int16_t)0x3612, (int16_t)0x36E5, (int16_t)0x37AF, (int16_t)0x3871, (int16_t)0x392A, (int16_t)0x39DA, (int16_t)0x3A82,
|
||||
(int16_t)0x3B20, (int16_t)0x3BB6, (int16_t)0x3C42, (int16_t)0x3CC5, (int16_t)0x3D3E, (int16_t)0x3DAE, (int16_t)0x3E14, (int16_t)0x3E71,
|
||||
(int16_t)0x3EC5, (int16_t)0x3F0E, (int16_t)0x3F4E, (int16_t)0x3F84, (int16_t)0x3FB1, (int16_t)0x3FD3, (int16_t)0x3FEC, (int16_t)0x3FFB,
|
||||
(int16_t)0x4000, (int16_t)0x3FFB, (int16_t)0x3FEC, (int16_t)0x3FD3, (int16_t)0x3FB1, (int16_t)0x3F84, (int16_t)0x3F4E, (int16_t)0x3F0E,
|
||||
(int16_t)0x3EC5, (int16_t)0x3E71, (int16_t)0x3E14, (int16_t)0x3DAE, (int16_t)0x3D3E, (int16_t)0x3CC5, (int16_t)0x3C42, (int16_t)0x3BB6,
|
||||
(int16_t)0x3B20, (int16_t)0x3A82, (int16_t)0x39DA, (int16_t)0x392A, (int16_t)0x3871, (int16_t)0x37AF, (int16_t)0x36E5, (int16_t)0x3612,
|
||||
(int16_t)0x3536, (int16_t)0x3453, (int16_t)0x3367, (int16_t)0x3274, (int16_t)0x3179, (int16_t)0x3076, (int16_t)0x2F6B, (int16_t)0x2E5A,
|
||||
(int16_t)0x2D41, (int16_t)0x2C21, (int16_t)0x2AFA, (int16_t)0x29CD, (int16_t)0x2899, (int16_t)0x275F, (int16_t)0x261F, (int16_t)0x24DA,
|
||||
(int16_t)0x238E, (int16_t)0x223D, (int16_t)0x20E7, (int16_t)0x1F8B, (int16_t)0x1E2B, (int16_t)0x1CC6, (int16_t)0x1B5D, (int16_t)0x19EF,
|
||||
(int16_t)0x187D, (int16_t)0x1708, (int16_t)0x158F, (int16_t)0x1413, (int16_t)0x1294, (int16_t)0x1111, (int16_t)0x0F8C, (int16_t)0x0E05,
|
||||
(int16_t)0x0C7C, (int16_t)0x0AF1, (int16_t)0x0964, (int16_t)0x07D5, (int16_t)0x0645, (int16_t)0x04B5, (int16_t)0x0323, (int16_t)0x0192,
|
||||
(int16_t)0x0000, (int16_t)0xFE6E, (int16_t)0xFCDD, (int16_t)0xFB4B, (int16_t)0xF9BB, (int16_t)0xF82B, (int16_t)0xF69C, (int16_t)0xF50F,
|
||||
(int16_t)0xF384, (int16_t)0xF1FB, (int16_t)0xF074, (int16_t)0xEEEF, (int16_t)0xED6C, (int16_t)0xEBED, (int16_t)0xEA71, (int16_t)0xE8F8,
|
||||
(int16_t)0xE783, (int16_t)0xE611, (int16_t)0xE4A3, (int16_t)0xE33A, (int16_t)0xE1D5, (int16_t)0xE075, (int16_t)0xDF19, (int16_t)0xDDC3,
|
||||
(int16_t)0xDC72, (int16_t)0xDB26, (int16_t)0xD9E1, (int16_t)0xD8A1, (int16_t)0xD767, (int16_t)0xD633, (int16_t)0xD506, (int16_t)0xD3DF,
|
||||
(int16_t)0xD2BF, (int16_t)0xD1A6, (int16_t)0xD095, (int16_t)0xCF8A, (int16_t)0xCE87, (int16_t)0xCD8C, (int16_t)0xCC99, (int16_t)0xCBAD,
|
||||
(int16_t)0xCACA, (int16_t)0xC9EE, (int16_t)0xC91B, (int16_t)0xC851, (int16_t)0xC78F, (int16_t)0xC6D6, (int16_t)0xC626, (int16_t)0xC57E,
|
||||
(int16_t)0xC4E0, (int16_t)0xC44A, (int16_t)0xC3BE, (int16_t)0xC33B, (int16_t)0xC2C2, (int16_t)0xC252, (int16_t)0xC1EC, (int16_t)0xC18F,
|
||||
(int16_t)0xC13B, (int16_t)0xC0F2, (int16_t)0xC0B2, (int16_t)0xC07C, (int16_t)0xC04F, (int16_t)0xC02D, (int16_t)0xC014, (int16_t)0xC005,
|
||||
(int16_t)0xC000, (int16_t)0xC005, (int16_t)0xC014, (int16_t)0xC02D, (int16_t)0xC04F, (int16_t)0xC07C, (int16_t)0xC0B2, (int16_t)0xC0F2,
|
||||
(int16_t)0xC13B, (int16_t)0xC18F, (int16_t)0xC1EC, (int16_t)0xC252, (int16_t)0xC2C2, (int16_t)0xC33B, (int16_t)0xC3BE, (int16_t)0xC44A,
|
||||
(int16_t)0xC4E0, (int16_t)0xC57E, (int16_t)0xC626, (int16_t)0xC6D6, (int16_t)0xC78F, (int16_t)0xC851, (int16_t)0xC91B, (int16_t)0xC9EE,
|
||||
(int16_t)0xCACA, (int16_t)0xCBAD, (int16_t)0xCC99, (int16_t)0xCD8C, (int16_t)0xCE87, (int16_t)0xCF8A, (int16_t)0xD095, (int16_t)0xD1A6,
|
||||
(int16_t)0xD2BF, (int16_t)0xD3DF, (int16_t)0xD506, (int16_t)0xD633, (int16_t)0xD767, (int16_t)0xD8A1, (int16_t)0xD9E1, (int16_t)0xDB26,
|
||||
(int16_t)0xDC72, (int16_t)0xDDC3, (int16_t)0xDF19, (int16_t)0xE075, (int16_t)0xE1D5, (int16_t)0xE33A, (int16_t)0xE4A3, (int16_t)0xE611,
|
||||
(int16_t)0xE783, (int16_t)0xE8F8, (int16_t)0xEA71, (int16_t)0xEBED, (int16_t)0xED6C, (int16_t)0xEEEF, (int16_t)0xF074, (int16_t)0xF1FB,
|
||||
(int16_t)0xF384, (int16_t)0xF50F, (int16_t)0xF69C, (int16_t)0xF82B, (int16_t)0xF9BB, (int16_t)0xFB4B, (int16_t)0xFCDD, (int16_t)0xFE6E
|
||||
};
|
||||
|
||||
void BIOS_ArcTan()
|
||||
|
@ -52,15 +52,15 @@ void BIOS_ArcTan()
|
|||
}
|
||||
#endif
|
||||
|
||||
s32 a = -(((s32)(reg[0].I * reg[0].I)) >> 14);
|
||||
s32 b = ((0xA9 * a) >> 14) + 0x390;
|
||||
int32_t a = -(((int32_t)(reg[0].I * reg[0].I)) >> 14);
|
||||
int32_t b = ((0xA9 * a) >> 14) + 0x390;
|
||||
b = ((b * a) >> 14) + 0x91C;
|
||||
b = ((b * a) >> 14) + 0xFB6;
|
||||
b = ((b * a) >> 14) + 0x16AA;
|
||||
b = ((b * a) >> 14) + 0x2081;
|
||||
b = ((b * a) >> 14) + 0x3651;
|
||||
b = ((b * a) >> 14) + 0xA2F9;
|
||||
a = ((s32)reg[0].I * b) >> 16;
|
||||
a = ((int32_t)reg[0].I * b) >> 16;
|
||||
reg[0].I = a;
|
||||
|
||||
#ifdef GBA_LOGGING
|
||||
|
@ -82,9 +82,9 @@ void BIOS_ArcTan2()
|
|||
}
|
||||
#endif
|
||||
|
||||
s32 x = reg[0].I;
|
||||
s32 y = reg[1].I;
|
||||
u32 res = 0;
|
||||
int32_t x = reg[0].I;
|
||||
int32_t y = reg[1].I;
|
||||
uint32_t res = 0;
|
||||
if (y == 0) {
|
||||
res = ((x >> 16) & 0x8000);
|
||||
} else {
|
||||
|
@ -130,9 +130,9 @@ void BIOS_BitUnPack()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
u32 header = reg[2].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
uint32_t header = reg[2].I;
|
||||
|
||||
int len = CPUReadHalfWord(header);
|
||||
// check address
|
||||
|
@ -141,8 +141,8 @@ void BIOS_BitUnPack()
|
|||
|
||||
int bits = CPUReadByte(header + 2);
|
||||
int revbits = 8 - bits;
|
||||
// u32 value = 0;
|
||||
u32 base = CPUReadMemory(header + 4);
|
||||
// uint32_t value = 0;
|
||||
uint32_t base = CPUReadMemory(header + 4);
|
||||
bool addBase = (base & 0x80000000) ? true : false;
|
||||
base &= 0x7fffffff;
|
||||
int dataSize = CPUReadByte(header + 3);
|
||||
|
@ -154,14 +154,14 @@ void BIOS_BitUnPack()
|
|||
if (len < 0)
|
||||
break;
|
||||
int mask = 0xff >> revbits;
|
||||
u8 b = CPUReadByte(source);
|
||||
uint8_t b = CPUReadByte(source);
|
||||
source++;
|
||||
int bitcount = 0;
|
||||
while (1) {
|
||||
if (bitcount >= 8)
|
||||
break;
|
||||
u32 d = b & mask;
|
||||
u32 temp = d >> bitcount;
|
||||
uint32_t d = b & mask;
|
||||
uint32_t temp = d >> bitcount;
|
||||
if (d || addBase) {
|
||||
temp += base;
|
||||
}
|
||||
|
@ -196,32 +196,32 @@ void BIOS_BgAffineSet()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 src = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t src = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
int num = reg[2].I;
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
s32 cx = CPUReadMemory(src);
|
||||
int32_t cx = CPUReadMemory(src);
|
||||
src += 4;
|
||||
s32 cy = CPUReadMemory(src);
|
||||
int32_t cy = CPUReadMemory(src);
|
||||
src += 4;
|
||||
s16 dispx = CPUReadHalfWord(src);
|
||||
int16_t dispx = CPUReadHalfWord(src);
|
||||
src += 2;
|
||||
s16 dispy = CPUReadHalfWord(src);
|
||||
int16_t dispy = CPUReadHalfWord(src);
|
||||
src += 2;
|
||||
s16 rx = CPUReadHalfWord(src);
|
||||
int16_t rx = CPUReadHalfWord(src);
|
||||
src += 2;
|
||||
s16 ry = CPUReadHalfWord(src);
|
||||
int16_t ry = CPUReadHalfWord(src);
|
||||
src += 2;
|
||||
u16 theta = CPUReadHalfWord(src) >> 8;
|
||||
uint16_t theta = CPUReadHalfWord(src) >> 8;
|
||||
src += 4; // keep structure alignment
|
||||
s32 a = sineTable[(theta + 0x40) & 255];
|
||||
s32 b = sineTable[theta];
|
||||
int32_t a = sineTable[(theta + 0x40) & 255];
|
||||
int32_t b = sineTable[theta];
|
||||
|
||||
s16 dx = (rx * a) >> 14;
|
||||
s16 dmx = (rx * b) >> 14;
|
||||
s16 dy = (ry * b) >> 14;
|
||||
s16 dmy = (ry * a) >> 14;
|
||||
int16_t dx = (rx * a) >> 14;
|
||||
int16_t dmx = (rx * b) >> 14;
|
||||
int16_t dy = (ry * b) >> 14;
|
||||
int16_t dmy = (ry * a) >> 14;
|
||||
|
||||
CPUWriteHalfWord(dest, dx);
|
||||
dest += 2;
|
||||
|
@ -232,8 +232,8 @@ void BIOS_BgAffineSet()
|
|||
CPUWriteHalfWord(dest, dmy);
|
||||
dest += 2;
|
||||
|
||||
s32 startx = cx - dx * dispx + dmx * dispy;
|
||||
s32 starty = cy - dy * dispx - dmy * dispy;
|
||||
int32_t startx = cx - dx * dispx + dmx * dispy;
|
||||
int32_t starty = cy - dy * dispx - dmy * dispy;
|
||||
|
||||
CPUWriteMemory(dest, startx);
|
||||
dest += 4;
|
||||
|
@ -251,9 +251,9 @@ void BIOS_CpuSet()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
u32 cnt = reg[2].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
uint32_t cnt = reg[2].I;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + (((cnt << 11) >> 9) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
@ -267,7 +267,7 @@ void BIOS_CpuSet()
|
|||
dest &= 0xFFFFFFFC;
|
||||
// fill ?
|
||||
if ((cnt >> 24) & 1) {
|
||||
u32 value = (source > 0x0EFFFFFF ? 0x1CAD1CAD : CPUReadMemory(source));
|
||||
uint32_t value = (source > 0x0EFFFFFF ? 0x1CAD1CAD : CPUReadMemory(source));
|
||||
while (count) {
|
||||
CPUWriteMemory(dest, value);
|
||||
dest += 4;
|
||||
|
@ -285,7 +285,7 @@ void BIOS_CpuSet()
|
|||
} else {
|
||||
// 16-bit fill?
|
||||
if ((cnt >> 24) & 1) {
|
||||
u16 value = (source > 0x0EFFFFFF ? 0x1CAD : CPUReadHalfWord(source));
|
||||
uint16_t value = (source > 0x0EFFFFFF ? 0x1CAD : CPUReadHalfWord(source));
|
||||
while (count) {
|
||||
CPUWriteHalfWord(dest, value);
|
||||
dest += 2;
|
||||
|
@ -312,9 +312,9 @@ void BIOS_CpuFastSet()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
u32 cnt = reg[2].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
uint32_t cnt = reg[2].I;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + (((cnt << 11) >> 9) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
@ -329,7 +329,7 @@ void BIOS_CpuFastSet()
|
|||
if ((cnt >> 24) & 1) {
|
||||
while (count > 0) {
|
||||
// BIOS always transfers 32 bytes at a time
|
||||
u32 value = (source > 0x0EFFFFFF ? 0xBAFFFFFB : CPUReadMemory(source));
|
||||
uint32_t value = (source > 0x0EFFFFFF ? 0xBAFFFFFB : CPUReadMemory(source));
|
||||
for (int i = 0; i < 8; i++) {
|
||||
CPUWriteMemory(dest, value);
|
||||
dest += 4;
|
||||
|
@ -359,10 +359,10 @@ void BIOS_Diff8bitUnFilterWram()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source);
|
||||
uint32_t header = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || (((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0))
|
||||
|
@ -370,12 +370,12 @@ void BIOS_Diff8bitUnFilterWram()
|
|||
|
||||
int len = header >> 8;
|
||||
|
||||
u8 data = CPUReadByte(source++);
|
||||
uint8_t data = CPUReadByte(source++);
|
||||
CPUWriteByte(dest++, data);
|
||||
len--;
|
||||
|
||||
while (len > 0) {
|
||||
u8 diff = CPUReadByte(source++);
|
||||
uint8_t diff = CPUReadByte(source++);
|
||||
data += diff;
|
||||
CPUWriteByte(dest++, data);
|
||||
len--;
|
||||
|
@ -391,10 +391,10 @@ void BIOS_Diff8bitUnFilterVram()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source);
|
||||
uint32_t header = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
|
@ -402,13 +402,13 @@ void BIOS_Diff8bitUnFilterVram()
|
|||
|
||||
int len = header >> 8;
|
||||
|
||||
u8 data = CPUReadByte(source++);
|
||||
u16 writeData = data;
|
||||
uint8_t data = CPUReadByte(source++);
|
||||
uint16_t writeData = data;
|
||||
int shift = 8;
|
||||
int bytes = 1;
|
||||
|
||||
while (len >= 2) {
|
||||
u8 diff = CPUReadByte(source++);
|
||||
uint8_t diff = CPUReadByte(source++);
|
||||
data += diff;
|
||||
writeData |= (data << shift);
|
||||
bytes++;
|
||||
|
@ -433,10 +433,10 @@ void BIOS_Diff16bitUnFilter()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source);
|
||||
uint32_t header = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
|
@ -444,14 +444,14 @@ void BIOS_Diff16bitUnFilter()
|
|||
|
||||
int len = header >> 8;
|
||||
|
||||
u16 data = CPUReadHalfWord(source);
|
||||
uint16_t data = CPUReadHalfWord(source);
|
||||
source += 2;
|
||||
CPUWriteHalfWord(dest, data);
|
||||
dest += 2;
|
||||
len -= 2;
|
||||
|
||||
while (len >= 2) {
|
||||
u16 diff = CPUReadHalfWord(source);
|
||||
uint16_t diff = CPUReadHalfWord(source);
|
||||
source += 2;
|
||||
data += diff;
|
||||
CPUWriteHalfWord(dest, data);
|
||||
|
@ -477,7 +477,7 @@ void BIOS_Div()
|
|||
if (denom != 0) {
|
||||
reg[0].I = number / denom;
|
||||
reg[1].I = number % denom;
|
||||
s32 temp = (s32)reg[0].I;
|
||||
int32_t temp = (int32_t)reg[0].I;
|
||||
reg[3].I = temp < 0 ? (u32)-temp : (u32)temp;
|
||||
}
|
||||
#ifdef GBA_LOGGING
|
||||
|
@ -500,7 +500,7 @@ void BIOS_DivARM()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 temp = reg[0].I;
|
||||
uint32_t temp = reg[0].I;
|
||||
reg[0].I = reg[1].I;
|
||||
reg[1].I = temp;
|
||||
BIOS_Div();
|
||||
|
@ -517,34 +517,34 @@ void BIOS_HuffUnComp()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source);
|
||||
uint32_t header = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
u8 treeSize = CPUReadByte(source++);
|
||||
uint8_t treeSize = CPUReadByte(source++);
|
||||
|
||||
u32 treeStart = source;
|
||||
uint32_t treeStart = source;
|
||||
|
||||
source += ((treeSize + 1) << 1) - 1; // minus because we already skipped one byte
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
u32 mask = 0x80000000;
|
||||
u32 data = CPUReadMemory(source);
|
||||
uint32_t mask = 0x80000000;
|
||||
uint32_t data = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
int pos = 0;
|
||||
u8 rootNode = CPUReadByte(treeStart);
|
||||
u8 currentNode = rootNode;
|
||||
uint8_t rootNode = CPUReadByte(treeStart);
|
||||
uint8_t currentNode = rootNode;
|
||||
bool writeData = false;
|
||||
int byteShift = 0;
|
||||
int byteCount = 0;
|
||||
u32 writeValue = 0;
|
||||
uint32_t writeValue = 0;
|
||||
|
||||
if ((header & 0x0F) == 8) {
|
||||
while (len > 0) {
|
||||
|
@ -662,10 +662,10 @@ void BIOS_LZ77UnCompVram()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source);
|
||||
uint32_t header = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
|
@ -673,21 +673,21 @@ void BIOS_LZ77UnCompVram()
|
|||
|
||||
int byteCount = 0;
|
||||
int byteShift = 0;
|
||||
u32 writeValue = 0;
|
||||
uint32_t writeValue = 0;
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
while (len > 0) {
|
||||
u8 d = CPUReadByte(source++);
|
||||
uint8_t d = CPUReadByte(source++);
|
||||
|
||||
if (d) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (d & 0x80) {
|
||||
u16 data = CPUReadByte(source++) << 8;
|
||||
uint16_t data = CPUReadByte(source++) << 8;
|
||||
data |= CPUReadByte(source++);
|
||||
int length = (data >> 12) + 3;
|
||||
int offset = (data & 0x0FFF);
|
||||
u32 windowOffset = dest + byteCount - offset - 1;
|
||||
uint32_t windowOffset = dest + byteCount - offset - 1;
|
||||
for (int i2 = 0; i2 < length; i2++) {
|
||||
writeValue |= (CPUReadByte(windowOffset++) << byteShift);
|
||||
byteShift += 8;
|
||||
|
@ -750,10 +750,10 @@ void BIOS_LZ77UnCompWram()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source);
|
||||
uint32_t header = CPUReadMemory(source);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
|
@ -762,16 +762,16 @@ void BIOS_LZ77UnCompWram()
|
|||
int len = header >> 8;
|
||||
|
||||
while (len > 0) {
|
||||
u8 d = CPUReadByte(source++);
|
||||
uint8_t d = CPUReadByte(source++);
|
||||
|
||||
if (d) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (d & 0x80) {
|
||||
u16 data = CPUReadByte(source++) << 8;
|
||||
uint16_t data = CPUReadByte(source++) << 8;
|
||||
data |= CPUReadByte(source++);
|
||||
int length = (data >> 12) + 3;
|
||||
int offset = (data & 0x0FFF);
|
||||
u32 windowOffset = dest - offset - 1;
|
||||
uint32_t windowOffset = dest - offset - 1;
|
||||
for (int i2 = 0; i2 < length; i2++) {
|
||||
CPUWriteByte(dest++, CPUReadByte(windowOffset++));
|
||||
len--;
|
||||
|
@ -810,26 +810,26 @@ void BIOS_ObjAffineSet()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 src = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t src = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
int num = reg[2].I;
|
||||
int offset = reg[3].I;
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
s16 rx = CPUReadHalfWord(src);
|
||||
int16_t rx = CPUReadHalfWord(src);
|
||||
src += 2;
|
||||
s16 ry = CPUReadHalfWord(src);
|
||||
int16_t ry = CPUReadHalfWord(src);
|
||||
src += 2;
|
||||
u16 theta = CPUReadHalfWord(src) >> 8;
|
||||
uint16_t theta = CPUReadHalfWord(src) >> 8;
|
||||
src += 4; // keep structure alignment
|
||||
|
||||
s32 a = (s32)sineTable[(theta + 0x40) & 255];
|
||||
s32 b = (s32)sineTable[theta];
|
||||
int32_t a = (int32_t)sineTable[(theta + 0x40) & 255];
|
||||
int32_t b = (int32_t)sineTable[theta];
|
||||
|
||||
s16 dx = ((s32)rx * a) >> 14;
|
||||
s16 dmx = ((s32)rx * b) >> 14;
|
||||
s16 dy = ((s32)ry * b) >> 14;
|
||||
s16 dmy = ((s32)ry * a) >> 14;
|
||||
int16_t dx = ((int32_t)rx * a) >> 14;
|
||||
int16_t dmx = ((int32_t)rx * b) >> 14;
|
||||
int16_t dy = ((int32_t)ry * b) >> 14;
|
||||
int16_t dmy = ((int32_t)ry * a) >> 14;
|
||||
|
||||
CPUWriteHalfWord(dest, dx);
|
||||
dest += offset;
|
||||
|
@ -942,10 +942,10 @@ void BIOS_RLUnCompVram()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source & 0xFFFFFFFC);
|
||||
uint32_t header = CPUReadMemory(source & 0xFFFFFFFC);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
|
@ -954,13 +954,13 @@ void BIOS_RLUnCompVram()
|
|||
int len = header >> 8;
|
||||
int byteCount = 0;
|
||||
int byteShift = 0;
|
||||
u32 writeValue = 0;
|
||||
uint32_t writeValue = 0;
|
||||
|
||||
while (len > 0) {
|
||||
u8 d = CPUReadByte(source++);
|
||||
uint8_t d = CPUReadByte(source++);
|
||||
int l = d & 0x7F;
|
||||
if (d & 0x80) {
|
||||
u8 data = CPUReadByte(source++);
|
||||
uint8_t data = CPUReadByte(source++);
|
||||
l += 3;
|
||||
for (int i = 0; i < l; i++) {
|
||||
writeValue |= (data << byteShift);
|
||||
|
@ -1010,10 +1010,10 @@ void BIOS_RLUnCompWram()
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
uint32_t source = reg[0].I;
|
||||
uint32_t dest = reg[1].I;
|
||||
|
||||
u32 header = CPUReadMemory(source & 0xFFFFFFFC);
|
||||
uint32_t header = CPUReadMemory(source & 0xFFFFFFFC);
|
||||
source += 4;
|
||||
|
||||
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
|
@ -1022,10 +1022,10 @@ void BIOS_RLUnCompWram()
|
|||
int len = header >> 8;
|
||||
|
||||
while (len > 0) {
|
||||
u8 d = CPUReadByte(source++);
|
||||
uint8_t d = CPUReadByte(source++);
|
||||
int l = d & 0x7F;
|
||||
if (d & 0x80) {
|
||||
u8 data = CPUReadByte(source++);
|
||||
uint8_t data = CPUReadByte(source++);
|
||||
l += 3;
|
||||
for (int i = 0; i < l; i++) {
|
||||
CPUWriteByte(dest++, data);
|
||||
|
@ -1066,7 +1066,7 @@ void BIOS_SoftReset()
|
|||
reg[R13_SVC].I = 0x03007FE0;
|
||||
reg[R14_SVC].I = 0x00000000;
|
||||
reg[SPSR_SVC].I = 0x00000000;
|
||||
u8 b = internalRAM[0x7ffa];
|
||||
uint8_t b = internalRAM[0x7ffa];
|
||||
|
||||
memset(&internalRAM[0x7e00], 0, 0x200);
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ void BIOS_Sqrt()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
reg[0].I = (u32)sqrt((double)reg[0].I);
|
||||
reg[0].I = (uint32_t)sqrt((double)reg[0].I);
|
||||
#ifdef GBA_LOGGING
|
||||
if (systemVerbose & VERBOSE_SWI) {
|
||||
log("Sqrt: return=%08x\n",
|
||||
|
@ -1098,10 +1098,10 @@ void BIOS_Sqrt()
|
|||
}
|
||||
|
||||
#define ADBITS_MASK 0x3FU
|
||||
u32 const base1 = 0x040000C0;
|
||||
u32 const base2 = 0x04000080;
|
||||
uint32_t const base1 = 0x040000C0;
|
||||
uint32_t const base2 = 0x04000080;
|
||||
|
||||
static bool BIOS_SndDriver_ba4(u32 r0, u32 r4r12) // 0xba4
|
||||
static bool BIOS_SndDriver_ba4(uint32_t r0, uint32_t r4r12) // 0xba4
|
||||
{
|
||||
if (r4r12) {
|
||||
r4r12 = r4r12 & ~0xFE000000;
|
||||
|
@ -1113,10 +1113,10 @@ static bool BIOS_SndDriver_ba4(u32 r0, u32 r4r12) // 0xba4
|
|||
return false;
|
||||
}
|
||||
|
||||
static void BIOS_SndDriver_b4c(u32 r0, u32 r1, u32 r2) // 0xb4c
|
||||
static void BIOS_SndDriver_b4c(uint32_t r0, uint32_t r1, uint32_t r2) // 0xb4c
|
||||
{
|
||||
// @r4
|
||||
u32 r4 = 4 * r2 & 0x7FFFFF;
|
||||
uint32_t r4 = 4 * r2 & 0x7FFFFF;
|
||||
bool ok = BIOS_SndDriver_ba4(r0, r4); // aka b9c
|
||||
|
||||
#if 0
|
||||
|
@ -1135,12 +1135,12 @@ static void BIOS_SndDriver_b4c(u32 r0, u32 r1, u32 r2) // 0xb4c
|
|||
|
||||
// 0b56
|
||||
if (!ok) {
|
||||
u32 r5 = 0; //v8
|
||||
uint32_t r5 = 0; //v8
|
||||
if (r2 >= (1 << (27 - 1))) //v6
|
||||
{
|
||||
r5 = r1 + r4;
|
||||
if (r2 >= (1 << (25 - 1))) {
|
||||
u32 r3 = CPUReadMemory(r0);
|
||||
uint32_t r3 = CPUReadMemory(r0);
|
||||
while (r1 < r5) {
|
||||
CPUWriteMemory(r1, r3);
|
||||
r1 += 4;
|
||||
|
@ -1184,13 +1184,13 @@ static void BIOS_SndDriver_b4c(u32 r0, u32 r1, u32 r2) // 0xb4c
|
|||
// 0x0b96
|
||||
}
|
||||
|
||||
static s32 BIOS_SndDriver_3e4(u32 const r0a, u32 const r1a) // 0x3e4
|
||||
static int32_t BIOS_SndDriver_3e4(uint32_t const r0a, uint32_t const r1a) // 0x3e4
|
||||
{
|
||||
s32 r0 = r1a;
|
||||
s32 r1 = r0a;
|
||||
u32 v5 = r0 & 0x80000000;
|
||||
s32 r12;
|
||||
s32 r2;
|
||||
int32_t r0 = r1a;
|
||||
int32_t r1 = r0a;
|
||||
uint32_t v5 = r0 & 0x80000000;
|
||||
int32_t r12;
|
||||
int32_t r2;
|
||||
bool gtr;
|
||||
|
||||
if ((r1 & 0x80000000 & 0x80000000) != 0)
|
||||
|
@ -1207,12 +1207,12 @@ static s32 BIOS_SndDriver_3e4(u32 const r0a, u32 const r1a) // 0x3e4
|
|||
} while (!gtr);
|
||||
|
||||
while (1) {
|
||||
v5 += (r0 >= (u32)r2) + v5;
|
||||
if (r0 >= (u32)r2)
|
||||
v5 += (r0 >= (uint32_t)r2) + v5;
|
||||
if (r0 >= (uint32_t)r2)
|
||||
r0 -= r2;
|
||||
if (r2 == r1)
|
||||
break;
|
||||
r2 = (u32)r2 >> 1;
|
||||
r2 = (uint32_t)r2 >> 1;
|
||||
}
|
||||
|
||||
if (!(r12 << 1))
|
||||
|
@ -1223,13 +1223,13 @@ static s32 BIOS_SndDriver_3e4(u32 const r0a, u32 const r1a) // 0x3e4
|
|||
|
||||
static void BIOS_SndDriverSub1(u32 p1) // 0x170a
|
||||
{
|
||||
u8 local1 = (p1 & 0x000F0000) >> 16; // param is r0
|
||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
uint8_t local1 = (p1 & 0x000F0000) >> 16; // param is r0
|
||||
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
|
||||
// Store something
|
||||
CPUWriteByte(puser1 + 8, local1);
|
||||
|
||||
u32 r0 = (0x31e8 + (local1 << 1)) - 0x20;
|
||||
uint32_t r0 = (0x31e8 + (local1 << 1)) - 0x20;
|
||||
|
||||
// @todo read from bios region
|
||||
if (r0 == 0x31D0) {
|
||||
|
@ -1240,14 +1240,14 @@ static void BIOS_SndDriverSub1(u32 p1) // 0x170a
|
|||
r0 = CPUReadHalfWord(r0 + 0x1E);
|
||||
CPUWriteMemory(puser1 + 0x10, r0);
|
||||
|
||||
u32 r1 = 0x630;
|
||||
u32 const r4 = r0;
|
||||
uint32_t r1 = 0x630;
|
||||
uint32_t const r4 = r0;
|
||||
|
||||
// 0x172c
|
||||
r0 = BIOS_SndDriver_3e4(r0, r1);
|
||||
CPUWriteByte(puser1 + 0xB, r0);
|
||||
|
||||
u32 x = 0x91d1b * r4;
|
||||
uint32_t x = 0x91d1b * r4;
|
||||
r1 = x + 0x1388;
|
||||
r0 = 0x1388 << 1;
|
||||
r0 = BIOS_SndDriver_3e4(r0, r1);
|
||||
|
@ -1259,7 +1259,7 @@ static void BIOS_SndDriverSub1(u32 p1) // 0x170a
|
|||
CPUWriteMemory(puser1 + 0x18, r0);
|
||||
|
||||
// 0x1750
|
||||
u32 r4basesnd = 0x4000100;
|
||||
uint32_t r4basesnd = 0x4000100;
|
||||
r0 = r4;
|
||||
r1 = 0x44940;
|
||||
CPUWriteHalfWord(r4basesnd + 2, 0);
|
||||
|
@ -1294,10 +1294,10 @@ void BIOS_SndDriverInit() // 0x166a
|
|||
#endif
|
||||
|
||||
// 7FC0 + 0x30
|
||||
u32 const puser1 = 0x3007FF0;
|
||||
u32 const user1 = reg[0].I;
|
||||
uint32_t const puser1 = 0x3007FF0;
|
||||
uint32_t const user1 = reg[0].I;
|
||||
|
||||
u32 base3 = 0x040000BC;
|
||||
uint32_t base3 = 0x040000BC;
|
||||
//u32 base4 = 0x03007FF0;
|
||||
|
||||
CPUWriteHalfWord(base1 + 6, 0);
|
||||
|
@ -1315,8 +1315,8 @@ void BIOS_SndDriverInit() // 0x166a
|
|||
CPUWriteMemory(base1 + 12, 0x40000A4);
|
||||
CPUWriteMemory(puser1, user1);
|
||||
|
||||
u32 const r2 = 0x050003EC;
|
||||
u32 const sp = reg[13].I; // 0x03003c98;
|
||||
uint32_t const r2 = 0x050003EC;
|
||||
uint32_t const sp = reg[13].I; // 0x03003c98;
|
||||
CPUWriteMemory(sp, 0);
|
||||
BIOS_SndDriver_b4c(sp, user1, r2);
|
||||
|
||||
|
@ -1337,24 +1337,24 @@ void BIOS_SndDriverInit() // 0x166a
|
|||
|
||||
void BIOS_SndDriverMode() //0x179c
|
||||
{
|
||||
u32 input = reg[0].I;
|
||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
u32 user1 = CPUReadMemory(puser1);
|
||||
uint32_t input = reg[0].I;
|
||||
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
uint32_t user1 = CPUReadMemory(puser1);
|
||||
|
||||
if (user1 == 0x68736D53) {
|
||||
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
||||
|
||||
// reverb values at bits 0...7
|
||||
u8 revb = (input & 0xFF);
|
||||
uint8_t revb = (input & 0xFF);
|
||||
if (revb) {
|
||||
revb >>= 1; // shift out the 7th enable bit
|
||||
CPUWriteByte(puser1 + 5, revb);
|
||||
}
|
||||
// direct sound multi channels at bits 8...11
|
||||
u8 chc = (input & 0xF00) >> 8;
|
||||
uint8_t chc = (input & 0xF00) >> 8;
|
||||
if (chc > 0) {
|
||||
CPUWriteByte(puser1 + 6, chc);
|
||||
u32 puser2 = puser1 + 7 + 0x49;
|
||||
uint32_t puser2 = puser1 + 7 + 0x49;
|
||||
int count = 12;
|
||||
while (count--) {
|
||||
CPUWriteByte(puser2, 0);
|
||||
|
@ -1362,21 +1362,21 @@ void BIOS_SndDriverMode() //0x179c
|
|||
}
|
||||
}
|
||||
// direct sound master volume at bits 12...15
|
||||
u8 chv = (input & 0xF000) >> 12;
|
||||
uint8_t chv = (input & 0xF000) >> 12;
|
||||
if (chv > 0) {
|
||||
CPUWriteByte(puser1 + 7, chv);
|
||||
}
|
||||
// DA converter bits at bits 20...23
|
||||
u32 dab = (input & 0x00B00000);
|
||||
uint32_t dab = (input & 0x00B00000);
|
||||
if (dab) {
|
||||
dab &= 0x00300000;
|
||||
dab >>= 0xE;
|
||||
u8 adv = CPUReadByte(puser1 + 9) & ADBITS_MASK; // @todo verify offset
|
||||
uint8_t adv = CPUReadByte(puser1 + 9) & ADBITS_MASK; // @todo verify offset
|
||||
dab |= adv;
|
||||
CPUWriteByte(puser1 + 9, dab);
|
||||
}
|
||||
// Playback frequency at bits 16...19
|
||||
u32 pbf = (input & 0x000F0000);
|
||||
uint32_t pbf = (input & 0x000F0000);
|
||||
if (pbf) {
|
||||
// Modifies puser1/user1
|
||||
BIOS_SndDriverVSyncOff();
|
||||
|
@ -1391,8 +1391,8 @@ void BIOS_SndDriverMode() //0x179c
|
|||
void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||
{
|
||||
//// Usually addr 0x2010928
|
||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30, //@+sp14
|
||||
u32 user1 = CPUReadMemory(puser1);
|
||||
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30, //@+sp14
|
||||
uint32_t user1 = CPUReadMemory(puser1);
|
||||
|
||||
if (user1 != 0x68736D53)
|
||||
return;
|
||||
|
@ -1413,9 +1413,9 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
break;
|
||||
}
|
||||
|
||||
u32 const v2 = CPUReadMemory(puser1 + 0x10); //r8
|
||||
u8 const user4 = CPUReadByte(puser1 + 4) - 1;
|
||||
u32 user41 = 0;
|
||||
uint32_t const v2 = CPUReadMemory(puser1 + 0x10); //r8
|
||||
uint8_t const user4 = CPUReadByte(puser1 + 4) - 1;
|
||||
uint32_t user41 = 0;
|
||||
|
||||
if (user4 > 0) {
|
||||
user41 = CPUReadByte(puser1 + 0x0B);
|
||||
|
@ -1423,8 +1423,8 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
user41 *= v2;
|
||||
}
|
||||
|
||||
u32 r5;
|
||||
u32 const r5c = puser1 + 0x350 + user41; //r5 @sp+8
|
||||
uint32_t r5;
|
||||
uint32_t const r5c = puser1 + 0x350 + user41; //r5 @sp+8
|
||||
int user6 = r5c + 0x630; //r6
|
||||
int user5 = CPUReadByte(puser1 + 0x5); //r3
|
||||
|
||||
|
@ -1480,16 +1480,16 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
}
|
||||
|
||||
//0x1ea2
|
||||
u32 r4 = puser1; // apparenty ch ptr?
|
||||
uint32_t r4 = puser1; // apparenty ch ptr?
|
||||
int r9 = CPUReadMemory(r4 + 0x14);
|
||||
int r12 = CPUReadMemory(r4 + 0x18);
|
||||
u32 i = CPUReadByte(r4 + 0x6);
|
||||
uint32_t i = CPUReadByte(r4 + 0x6);
|
||||
|
||||
for (r4 += 0x10; i > 0; i--) {
|
||||
r4 += 0x40;
|
||||
/*lbl_0x1eb0:*/
|
||||
u32 r3 = CPUReadMemory(r4 + 0x24);
|
||||
u8 r6 = CPUReadByte(r4);
|
||||
uint32_t r3 = CPUReadMemory(r4 + 0x24);
|
||||
uint8_t r6 = CPUReadByte(r4);
|
||||
|
||||
if ((r6 & 0xC7) == 0) // 0x1ebc
|
||||
continue; //goto lbl_20e4;
|
||||
|
@ -1506,7 +1506,7 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
CPUWriteByte(r4 + 0x9, 0);
|
||||
CPUWriteMemory(r4 + 0x1c, 0);
|
||||
|
||||
u8 r2a = CPUReadByte(r3 + 0x3); // seems to be LABEL_20e4
|
||||
uint8_t r2a = CPUReadByte(r3 + 0x3); // seems to be LABEL_20e4
|
||||
if ((r2a & 0xC0)) // 1ee4
|
||||
{
|
||||
}
|
||||
|
@ -1524,11 +1524,11 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
|
||||
if ((r6 & 0x03) == 2) // 0x1f2a
|
||||
{
|
||||
u8 mul1 = CPUReadByte(r4 + 0x5);
|
||||
uint8_t mul1 = CPUReadByte(r4 + 0x5);
|
||||
r5 *= mul1;
|
||||
r5 >>= 8;
|
||||
|
||||
u8 cmp1 = CPUReadByte(r4 + 0x6);
|
||||
uint8_t cmp1 = CPUReadByte(r4 + 0x6);
|
||||
if (r5 <= cmp1) {
|
||||
r5 = cmp1;
|
||||
// @todo beq @ 0x1f3a -> ??
|
||||
|
@ -1538,7 +1538,7 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
} else if ((r6 & 0x03) == 3) // 0x1f44
|
||||
{
|
||||
lbl_0x1f46: //@todo check if there is really another path to here
|
||||
u8 add1 = CPUReadByte(r4 + 0x4);
|
||||
uint8_t add1 = CPUReadByte(r4 + 0x4);
|
||||
r5 += add1;
|
||||
|
||||
if (r5 >= 0xff) {
|
||||
|
@ -1552,7 +1552,7 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
//lbl_0x1f54:
|
||||
CPUWriteByte(r4 + 0x9, r5);
|
||||
|
||||
u32 user0 = CPUReadByte(puser1 + 0x7); // @sp+10
|
||||
uint32_t user0 = CPUReadByte(puser1 + 0x7); // @sp+10
|
||||
user0++;
|
||||
user0 *= r5;
|
||||
r5 = user0 >> 4;
|
||||
|
@ -1573,20 +1573,20 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
}
|
||||
|
||||
r5 = r5c; // @todo below r5 is used and updated
|
||||
u32 r2 = CPUReadMemory(r4 + 0x18);
|
||||
uint32_t r2 = CPUReadMemory(r4 + 0x18);
|
||||
r3 = CPUReadMemory(r4 + 0x28);
|
||||
|
||||
u32 r8 = v2;
|
||||
uint32_t r8 = v2;
|
||||
|
||||
u8 r10 = CPUReadByte(r4 + 0xA);
|
||||
u8 r11 = CPUReadByte(r4 + 0xB);
|
||||
u8 r0a = CPUReadByte(r4 + 0x1);
|
||||
uint8_t r10 = CPUReadByte(r4 + 0xA);
|
||||
uint8_t r11 = CPUReadByte(r4 + 0xB);
|
||||
uint8_t r0a = CPUReadByte(r4 + 0x1);
|
||||
if ((r0a & 8)) //@todo 0x1fa8
|
||||
{
|
||||
}
|
||||
|
||||
u32 r7 = CPUReadMemory(r4 + 0x1c);
|
||||
u32 r14 = CPUReadMemory(r4 + 0x20);
|
||||
uint32_t r7 = CPUReadMemory(r4 + 0x1c);
|
||||
uint32_t r14 = CPUReadMemory(r4 + 0x20);
|
||||
|
||||
lbl_0x2004: // LABEL_52:
|
||||
while (r7 >= 4 * r9) {
|
||||
|
@ -1623,22 +1623,22 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
} while (r7 >= r9);
|
||||
lbl_207c:
|
||||
while (1) {
|
||||
s32 r0a = CPUReadByte(r3);
|
||||
s32 r1a = CPUReadByte(r3 + 0x1);
|
||||
int32_t r0a = CPUReadByte(r3);
|
||||
int32_t r1a = CPUReadByte(r3 + 0x1);
|
||||
|
||||
r1a -= r0a;
|
||||
s32 r6a = r1a * (s32)r7;
|
||||
int32_t r6a = r1a * (int32_t)r7;
|
||||
r1a = r6a * r12; // 208c
|
||||
r6a = (r0a + ((s8)(r1a >> 23)));
|
||||
r6a = (r0a + ((int8_t)(r1a >> 23)));
|
||||
|
||||
r1a = r6a * (s32)r11;
|
||||
r1a = r6a * (int32_t)r11;
|
||||
|
||||
r0a = CPUReadByte(r5 + 0x630);
|
||||
r0a = (r0a + ((s8)(r1a >> 8)));
|
||||
r0a = (r0a + ((int8_t)(r1a >> 8)));
|
||||
CPUWriteByte(r5 + 0x630, r0a);
|
||||
r1a = r6a * (s32)r10;
|
||||
r1a = r6a * (int32_t)r10;
|
||||
r0a = CPUReadByte(r5);
|
||||
r0a = (r0a + ((s8)(r1a >> 8)));
|
||||
r0a = (r0a + ((int8_t)(r1a >> 8)));
|
||||
CPUWriteByte(r5++, r0a); //ptr inc +1 not +4
|
||||
|
||||
r7 += r14;
|
||||
|
@ -1665,16 +1665,16 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
|||
// fully implemented @ 0x210c
|
||||
void BIOS_SndDriverVSync()
|
||||
{
|
||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // @todo some sound area, make it common.
|
||||
u32 const user1 = CPUReadMemory(puser1);
|
||||
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // @todo some sound area, make it common.
|
||||
uint32_t const user1 = CPUReadMemory(puser1);
|
||||
|
||||
if (user1 == 0x68736D53) {
|
||||
u8 v1 = CPUReadByte(puser1 + 4);
|
||||
s8 v1i = v1 - 1;
|
||||
uint8_t v1 = CPUReadByte(puser1 + 4);
|
||||
int8_t v1i = v1 - 1;
|
||||
CPUWriteByte(puser1 + 4, v1i);
|
||||
if (v1 <= 1) {
|
||||
u8 v2 = CPUReadByte(puser1 + 0xB); //11
|
||||
u32 base2 = 0x040000D2;
|
||||
uint8_t v2 = CPUReadByte(puser1 + 0xB); //11
|
||||
uint32_t base2 = 0x040000D2;
|
||||
CPUWriteByte(puser1 + 4, v2);
|
||||
|
||||
CPUWriteHalfWord(base1 + 0x6, 0);
|
||||
|
@ -1687,8 +1687,8 @@ void BIOS_SndDriverVSync()
|
|||
|
||||
void BIOS_SndDriverVSyncOff() // 0x1878
|
||||
{
|
||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
u32 user1 = CPUReadMemory(puser1);
|
||||
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
uint32_t user1 = CPUReadMemory(puser1);
|
||||
|
||||
if (user1 == 0x68736D53 || user1 == 0x68736D54) {
|
||||
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
||||
|
@ -1697,9 +1697,9 @@ void BIOS_SndDriverVSyncOff() // 0x1878
|
|||
CPUWriteHalfWord(base1 + 0x12, 0);
|
||||
CPUWriteByte(puser1 + 4, 0);
|
||||
|
||||
u32 r1 = puser1 + 0x350;
|
||||
u32 r2 = 0x05000318;
|
||||
u32 sp = reg[13].I; //0x03003c94;
|
||||
uint32_t r1 = puser1 + 0x350;
|
||||
uint32_t r2 = 0x05000318;
|
||||
uint32_t sp = reg[13].I; //0x03003c94;
|
||||
|
||||
CPUWriteMemory(sp, 0);
|
||||
BIOS_SndDriver_b4c(sp, r1, r2);
|
||||
|
@ -1715,12 +1715,12 @@ void BIOS_SndDriverVSyncOff() // 0x1878
|
|||
// r7 should be puser1, r6 should be flags, ....
|
||||
void BIOS_SndChannelClear() //0x1824
|
||||
{
|
||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
u32 user1 = CPUReadMemory(puser1);
|
||||
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||
uint32_t user1 = CPUReadMemory(puser1);
|
||||
|
||||
if (user1 == 0x68736D53) {
|
||||
CPUWriteMemory(puser1, (++user1));
|
||||
u32 puser2 = puser1 + 0x7 + 0x49;
|
||||
uint32_t puser2 = puser1 + 0x7 + 0x49;
|
||||
|
||||
int count = 12;
|
||||
while (count--) {
|
||||
|
|
Loading…
Reference in New Issue