more and more formating issues, I keep doing it in parts for my own reasons
This commit is contained in:
parent
48086ba62f
commit
1f37311a4a
|
@ -1,11 +1,10 @@
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../common/Types.h"
|
|
||||||
#include "gbGlobals.h"
|
#include "gbGlobals.h"
|
||||||
#include "gbSGB.h"
|
#include "gbSGB.h"
|
||||||
|
|
||||||
u8 gbInvertTab[256] = {
|
uint8_t gbInvertTab[256] = {
|
||||||
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
|
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
|
||||||
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
|
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
|
||||||
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
|
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
|
||||||
|
@ -40,16 +39,16 @@ u8 gbInvertTab[256] = {
|
||||||
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
|
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
|
||||||
};
|
};
|
||||||
|
|
||||||
u16 gbLineMix[160];
|
uint16_t gbLineMix[160];
|
||||||
u16 gbWindowColor[160];
|
uint16_t gbWindowColor[160];
|
||||||
extern int inUseRegister_WY;
|
extern int inUseRegister_WY;
|
||||||
extern int layerSettings;
|
extern int layerSettings;
|
||||||
|
|
||||||
void gbRenderLine()
|
void gbRenderLine()
|
||||||
{
|
{
|
||||||
memset(gbLineMix, 0, sizeof(gbLineMix));
|
memset(gbLineMix, 0, sizeof(gbLineMix));
|
||||||
u8* bank0;
|
uint8_t* bank0;
|
||||||
u8* bank1;
|
uint8_t* bank1;
|
||||||
if (gbCgbMode) {
|
if (gbCgbMode) {
|
||||||
bank0 = &gbVram[0x0000];
|
bank0 = &gbVram[0x0000];
|
||||||
bank1 = &gbVram[0x2000];
|
bank1 = &gbVram[0x2000];
|
||||||
|
@ -91,11 +90,11 @@ void gbRenderLine()
|
||||||
|
|
||||||
int tile_map_address = tile_map_line_y + tx;
|
int tile_map_address = tile_map_line_y + tx;
|
||||||
|
|
||||||
u8 attrs = 0;
|
uint8_t attrs = 0;
|
||||||
if (bank1 != NULL)
|
if (bank1 != NULL)
|
||||||
attrs = bank1[tile_map_address];
|
attrs = bank1[tile_map_address];
|
||||||
|
|
||||||
u8 tile = bank0[tile_map_address];
|
uint8_t tile = bank0[tile_map_address];
|
||||||
|
|
||||||
tile_map_address++;
|
tile_map_address++;
|
||||||
|
|
||||||
|
@ -108,8 +107,8 @@ void gbRenderLine()
|
||||||
if ((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100)) {
|
if ((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100)) {
|
||||||
while (x < 160) {
|
while (x < 160) {
|
||||||
|
|
||||||
u8 tile_a = 0;
|
uint8_t tile_a = 0;
|
||||||
u8 tile_b = 0;
|
uint8_t tile_b = 0;
|
||||||
|
|
||||||
if (attrs & 0x40) {
|
if (attrs & 0x40) {
|
||||||
tile_pattern_address = tile_pattern + tile * 16 + (7 - by) * 2;
|
tile_pattern_address = tile_pattern + tile * 16 + (7 - by) * 2;
|
||||||
|
@ -129,7 +128,7 @@ void gbRenderLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
while (bx > 0) {
|
while (bx > 0) {
|
||||||
u8 c = (tile_a & bx) ? 1 : 0;
|
uint8_t c = (tile_a & bx) ? 1 : 0;
|
||||||
c += ((tile_b & bx) ? 2 : 0);
|
c += ((tile_b & bx) ? 2 : 0);
|
||||||
|
|
||||||
gbLineBuffer[x] = c; // mark the gbLineBuffer color
|
gbLineBuffer[x] = c; // mark the gbLineBuffer color
|
||||||
|
@ -204,7 +203,7 @@ void gbRenderLine()
|
||||||
// (this fixes white flashes on Last Bible II)
|
// (this fixes white flashes on Last Bible II)
|
||||||
// Also added the gbColorOption (fixes Dracula Densetsu II color problems)
|
// Also added the gbColorOption (fixes Dracula Densetsu II color problems)
|
||||||
for (int i = 0; i < 160; i++) {
|
for (int i = 0; i < 160; i++) {
|
||||||
u16 color = gbColorOption ? gbColorFilter[0x7FFF] : 0x7FFF;
|
uint16_t color = gbColorOption ? gbColorFilter[0x7FFF] : 0x7FFF;
|
||||||
if (!gbCgbMode)
|
if (!gbCgbMode)
|
||||||
color = gbColorOption ? gbColorFilter[gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF] : gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF;
|
color = gbColorOption ? gbColorFilter[gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF] : gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF;
|
||||||
gbLineMix[i] = color;
|
gbLineMix[i] = color;
|
||||||
|
@ -279,7 +278,7 @@ void gbRenderLine()
|
||||||
x = wx;
|
x = wx;
|
||||||
|
|
||||||
tile = bank0[tile_map_address];
|
tile = bank0[tile_map_address];
|
||||||
u8 attrs = 0;
|
uint8_t attrs = 0;
|
||||||
if (bank1)
|
if (bank1)
|
||||||
attrs = bank1[tile_map_address];
|
attrs = bank1[tile_map_address];
|
||||||
tile_map_address++;
|
tile_map_address++;
|
||||||
|
@ -298,8 +297,8 @@ void gbRenderLine()
|
||||||
gbLineMix[i] = gbWindowColor[i];
|
gbLineMix[i] = gbWindowColor[i];
|
||||||
|
|
||||||
while (x < 160) {
|
while (x < 160) {
|
||||||
u8 tile_a = 0;
|
uint8_t tile_a = 0;
|
||||||
u8 tile_b = 0;
|
uint8_t tile_b = 0;
|
||||||
|
|
||||||
if (attrs & 0x40) {
|
if (attrs & 0x40) {
|
||||||
tile_pattern_address = tile_pattern + tile * 16 + (7 - by) * 2;
|
tile_pattern_address = tile_pattern + tile * 16 + (7 - by) * 2;
|
||||||
|
@ -319,7 +318,7 @@ void gbRenderLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
while (bx > 0) {
|
while (bx > 0) {
|
||||||
u8 c = (tile_a & bx) != 0 ? 1 : 0;
|
uint8_t c = (tile_a & bx) != 0 ? 1 : 0;
|
||||||
c += ((tile_b & bx) != 0 ? 2 : 0);
|
c += ((tile_b & bx) != 0 ? 2 : 0);
|
||||||
|
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
|
@ -386,7 +385,7 @@ void gbRenderLine()
|
||||||
gbWindowLine = 0;
|
gbWindowLine = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
u16 color = gbColorOption ? gbColorFilter[0x7FFF] : 0x7FFF;
|
uint16_t color = gbColorOption ? gbColorFilter[0x7FFF] : 0x7FFF;
|
||||||
if (!gbCgbMode)
|
if (!gbCgbMode)
|
||||||
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] : gbPalette[0] & 0x7FFF;
|
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] : gbPalette[0] & 0x7FFF;
|
||||||
for (int i = 0; i < 160; i++) {
|
for (int i = 0; i < 160; i++) {
|
||||||
|
@ -399,8 +398,8 @@ void gbRenderLine()
|
||||||
void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
|
void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
|
||||||
int size, int spriteNumber)
|
int size, int spriteNumber)
|
||||||
{
|
{
|
||||||
u8* bank0;
|
uint8_t* bank0;
|
||||||
u8* bank1;
|
uint8_t* bank1;
|
||||||
if (gbCgbMode) {
|
if (gbCgbMode) {
|
||||||
bank0 = &gbVram[0x0000];
|
bank0 = &gbVram[0x0000];
|
||||||
bank1 = &gbVram[0x2000];
|
bank1 = &gbVram[0x2000];
|
||||||
|
@ -415,7 +414,7 @@ void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
|
||||||
gbObp0[i] = (gbObp0Line[x + 11 + gbSpritesTicks[x] * (gbSpeed ? 2 : 4)] >> (i << 1)) & 3;
|
gbObp0[i] = (gbObp0Line[x + 11 + gbSpritesTicks[x] * (gbSpeed ? 2 : 4)] >> (i << 1)) & 3;
|
||||||
gbObp1[i] = (gbObp1Line[x + 11 + gbSpritesTicks[x] * (gbSpeed ? 2 : 4)] >> (i << 1)) & 3;
|
gbObp1[i] = (gbObp1Line[x + 11 + gbSpritesTicks[x] * (gbSpeed ? 2 : 4)] >> (i << 1)) & 3;
|
||||||
}
|
}
|
||||||
u8* pal = gbObp0;
|
uint8_t* pal = gbObp0;
|
||||||
|
|
||||||
int flipx = (flags & 0x20);
|
int flipx = (flags & 0x20);
|
||||||
int flipy = (flags & 0x40);
|
int flipy = (flags & 0x40);
|
||||||
|
@ -442,8 +441,8 @@ void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int xx = 0; xx < 8; xx++) {
|
for (int xx = 0; xx < 8; xx++) {
|
||||||
u8 mask = 1 << (7 - xx);
|
uint8_t mask = 1 << (7 - xx);
|
||||||
u8 c = 0;
|
uint8_t c = 0;
|
||||||
if ((a & mask))
|
if ((a & mask))
|
||||||
c++;
|
c++;
|
||||||
if ((b & mask))
|
if ((b & mask))
|
||||||
|
@ -459,7 +458,7 @@ void gbDrawSpriteTile(int tile, int x, int y, int t, int flags,
|
||||||
if (xxx < 0 || xxx > 159)
|
if (xxx < 0 || xxx > 159)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u16 color = gbLineBuffer[xxx];
|
uint16_t color = gbLineBuffer[xxx];
|
||||||
|
|
||||||
// Fixes OAM-BG priority
|
// Fixes OAM-BG priority
|
||||||
if (prio && (register_LCDC & 1)) {
|
if (prio && (register_LCDC & 1)) {
|
||||||
|
|
|
@ -95,10 +95,10 @@ w, word, u32 --> word
|
||||||
sw, sword, s32, int --> signed word
|
sw, sword, s32, int --> signed word
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "BreakpointStructures.h"
|
#include "BreakpointStructures.h"
|
||||||
#include "remote.h"
|
#include "remote.h"
|
||||||
|
@ -143,9 +143,6 @@ struct intToString compareFlagMapping[] = {
|
||||||
//
|
//
|
||||||
//char* compareFlagMapping[] = {"Never","==",">",">=","<","<=","!=","<=>"};
|
//char* compareFlagMapping[] = {"Never","==",">",">=","<","<=","!=","<=>"};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Constructors
|
//Constructors
|
||||||
//case '*': flag = 0xf; break;
|
//case '*': flag = 0xf; break;
|
||||||
//case 't': flag = 0x8; break; // thumb
|
//case 't': flag = 0x8; break; // thumb
|
||||||
|
@ -154,7 +151,8 @@ struct intToString compareFlagMapping[] = {
|
||||||
//case 'r': flag = 0x2; break; // mem read
|
//case 'r': flag = 0x2; break; // mem read
|
||||||
//case 'w': flag = 0x1; break; // mem write
|
//case 'w': flag = 0x1; break; // mem write
|
||||||
//case 'i': flag = 0x3; break;
|
//case 'i': flag = 0x3; break;
|
||||||
struct ConditionalBreak* addConditionalBreak(u32 address, u8 flag){
|
struct ConditionalBreak* addConditionalBreak(u32 address, u8 flag)
|
||||||
|
{
|
||||||
u8 condIndex = address >> 24;
|
u8 condIndex = address >> 24;
|
||||||
struct ConditionalBreak* cond = NULL;
|
struct ConditionalBreak* cond = NULL;
|
||||||
BreakSet((&map[condIndex])->breakPoints, address & (&map[condIndex])->mask, ((flag & 0xf) | (flag >> 4)));
|
BreakSet((&map[condIndex])->breakPoints, address & (&map[condIndex])->mask, ((flag & 0xf) | (flag >> 4)));
|
||||||
|
@ -225,8 +223,8 @@ addCB_nextHandle:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toAdd)
|
||||||
void addCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toAdd){
|
{
|
||||||
if (base->firstCond) {
|
if (base->firstCond) {
|
||||||
struct ConditionalBreakNode *curr, *prev;
|
struct ConditionalBreakNode *curr, *prev;
|
||||||
curr = base->firstCond;
|
curr = base->firstCond;
|
||||||
|
@ -242,7 +240,8 @@ void addCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* to
|
||||||
}
|
}
|
||||||
|
|
||||||
//destructors
|
//destructors
|
||||||
void freeConditionalBreak(struct ConditionalBreak* toFree){
|
void freeConditionalBreak(struct ConditionalBreak* toFree)
|
||||||
|
{
|
||||||
struct ConditionalBreakNode* freeMe;
|
struct ConditionalBreakNode* freeMe;
|
||||||
while (toFree->firstCond) {
|
while (toFree->firstCond) {
|
||||||
freeMe = toFree->firstCond;
|
freeMe = toFree->firstCond;
|
||||||
|
@ -252,7 +251,8 @@ void freeConditionalBreak(struct ConditionalBreak* toFree){
|
||||||
free(toFree);
|
free(toFree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeConditionalNode(struct ConditionalBreakNode* toDel){
|
void freeConditionalNode(struct ConditionalBreakNode* toDel)
|
||||||
|
{
|
||||||
if (toDel->next)
|
if (toDel->next)
|
||||||
freeConditionalNode(toDel->next);
|
freeConditionalNode(toDel->next);
|
||||||
if (toDel->address)
|
if (toDel->address)
|
||||||
|
@ -262,7 +262,8 @@ void freeConditionalNode(struct ConditionalBreakNode* toDel){
|
||||||
free(toDel);
|
free(toDel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeAllConditionals(){
|
void freeAllConditionals()
|
||||||
|
{
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
while (conditionals[i]) {
|
while (conditionals[i]) {
|
||||||
struct ConditionalBreak* tmp = conditionals[i];
|
struct ConditionalBreak* tmp = conditionals[i];
|
||||||
|
@ -272,7 +273,8 @@ void freeAllConditionals(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalBreak(struct ConditionalBreak* toDelete){
|
int removeConditionalBreak(struct ConditionalBreak* toDelete)
|
||||||
|
{
|
||||||
if (toDelete) {
|
if (toDelete) {
|
||||||
u8 condIndex = toDelete->break_address >> 24;
|
u8 condIndex = toDelete->break_address >> 24;
|
||||||
struct ConditionalBreak* base = conditionals[condIndex];
|
struct ConditionalBreak* base = conditionals[condIndex];
|
||||||
|
@ -391,7 +393,8 @@ int removeAllConditions(u32 address, u8 flags){
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void recountFlagsForAddress(u32 address){
|
void recountFlagsForAddress(u32 address)
|
||||||
|
{
|
||||||
struct ConditionalBreak* base = conditionals[address >> 24];
|
struct ConditionalBreak* base = conditionals[address >> 24];
|
||||||
u8 flags = 0;
|
u8 flags = 0;
|
||||||
while (base) {
|
while (base) {
|
||||||
|
@ -412,9 +415,9 @@ void recountFlagsForAddress(u32 address){
|
||||||
BreakSet((&map[address >> 24])->breakPoints, address & (&map[address >> 24])->mask, ((flags >> 4) | (flags & 0x8)));
|
BreakSet((&map[address >> 24])->breakPoints, address & (&map[address >> 24])->mask, ((flags >> 4) | (flags & 0x8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Removers
|
//Removers
|
||||||
int removeConditionalBreakNo(u32 addrNo, u8 number){
|
int removeConditionalBreakNo(u32 addrNo, u8 number)
|
||||||
|
{
|
||||||
if (conditionals[addrNo >> 24]) {
|
if (conditionals[addrNo >> 24]) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo >> 24];
|
struct ConditionalBreak* base = conditionals[addrNo >> 24];
|
||||||
struct ConditionalBreak* curr = conditionals[addrNo >> 24];
|
struct ConditionalBreak* curr = conditionals[addrNo >> 24];
|
||||||
|
@ -454,7 +457,8 @@ if(conditionals[addrNo>>24]){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeFlagFromConditionalBreakNo(u32 addrNo, u8 number, u8 flag){
|
int removeFlagFromConditionalBreakNo(u32 addrNo, u8 number, u8 flag)
|
||||||
|
{
|
||||||
if (conditionals[addrNo >> 24]) {
|
if (conditionals[addrNo >> 24]) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo >> 24];
|
struct ConditionalBreak* base = conditionals[addrNo >> 24];
|
||||||
struct ConditionalBreak* curr = conditionals[addrNo >> 24];
|
struct ConditionalBreak* curr = conditionals[addrNo >> 24];
|
||||||
|
@ -502,7 +506,8 @@ int removeFlagFromConditionalBreakNo(u32 addrNo, u8 number, u8 flag){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalWithAddress(u32 address){
|
int removeConditionalWithAddress(u32 address)
|
||||||
|
{
|
||||||
u8 addrNo = address >> 24;
|
u8 addrNo = address >> 24;
|
||||||
if (conditionals[addrNo] != NULL) {
|
if (conditionals[addrNo] != NULL) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo];
|
struct ConditionalBreak* base = conditionals[addrNo];
|
||||||
|
@ -527,7 +532,8 @@ int removeConditionalWithAddress(u32 address){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalWithFlag(u8 flag, bool orMode){
|
int removeConditionalWithFlag(u8 flag, bool orMode)
|
||||||
|
{
|
||||||
for (u8 addrNo = 0; addrNo < 16; addrNo++) {
|
for (u8 addrNo = 0; addrNo < 16; addrNo++) {
|
||||||
if (conditionals[addrNo] != NULL) {
|
if (conditionals[addrNo] != NULL) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo];
|
struct ConditionalBreak* base = conditionals[addrNo];
|
||||||
|
@ -542,8 +548,7 @@ int removeConditionalWithFlag(u8 flag, bool orMode){
|
||||||
conditionals[addrNo] = curr->next;
|
conditionals[addrNo] = curr->next;
|
||||||
base = curr->next;
|
base = curr->next;
|
||||||
curr = base;
|
curr = base;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
curr = base->next;
|
curr = base->next;
|
||||||
|
@ -564,15 +569,15 @@ int removeConditionalWithFlag(u8 flag, bool orMode){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode){
|
int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode)
|
||||||
|
{
|
||||||
u8 addrNo = address >> 24;
|
u8 addrNo = address >> 24;
|
||||||
if (conditionals[addrNo] != NULL) {
|
if (conditionals[addrNo] != NULL) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo];
|
struct ConditionalBreak* base = conditionals[addrNo];
|
||||||
struct ConditionalBreak* curr = conditionals[addrNo];
|
struct ConditionalBreak* curr = conditionals[addrNo];
|
||||||
u8 count = 0;
|
u8 count = 0;
|
||||||
while (curr && address >= curr->break_address) {
|
while (curr && address >= curr->break_address) {
|
||||||
if((curr->break_address == address) &&
|
if ((curr->break_address == address) && (((curr->type_flags & flag) == curr->type_flags) || (orMode && (curr->type_flags & flag)))) {
|
||||||
(((curr->type_flags & flag) == curr->type_flags) || (orMode && (curr->type_flags & flag)))){
|
|
||||||
curr->type_flags &= ~flag;
|
curr->type_flags &= ~flag;
|
||||||
BreakClear((&map[address >> 24])->breakPoints, curr->break_address & (&map[address >> 24])->mask, ((flag & 0xf) | (flag >> 4)));
|
BreakClear((&map[address >> 24])->breakPoints, curr->break_address & (&map[address >> 24])->mask, ((flag & 0xf) | (flag >> 4)));
|
||||||
if (curr->type_flags == 0) {
|
if (curr->type_flags == 0) {
|
||||||
|
@ -580,8 +585,7 @@ int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode){
|
||||||
conditionals[addrNo] = curr->next;
|
conditionals[addrNo] = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
curr = conditionals[addrNo];
|
curr = conditionals[addrNo];
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
curr = base->next;
|
curr = base->next;
|
||||||
|
@ -601,8 +605,6 @@ int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//true creating code for a given expression.
|
//true creating code for a given expression.
|
||||||
//It assumes an if was found, and that all up to the if was removed.
|
//It assumes an if was found, and that all up to the if was removed.
|
||||||
//receives an array of chars following the pattern:
|
//receives an array of chars following the pattern:
|
||||||
|
@ -610,7 +612,8 @@ int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode){
|
||||||
//<expType is optional, and always assumes int-compare as default.
|
//<expType is optional, and always assumes int-compare as default.
|
||||||
u8 parseExpressionType(char* type);
|
u8 parseExpressionType(char* type);
|
||||||
u8 parseConditionOperand(char* type);
|
u8 parseConditionOperand(char* type);
|
||||||
void parseAndCreateConditionalBreaks(u32 address, u8 flags, char** exp, int n){
|
void parseAndCreateConditionalBreaks(u32 address, u8 flags, char** exp, int n)
|
||||||
|
{
|
||||||
struct ConditionalBreak* workBreak = addConditionalBreak(address, flags);
|
struct ConditionalBreak* workBreak = addConditionalBreak(address, flags);
|
||||||
flags &= 0xf;
|
flags &= 0xf;
|
||||||
if (!flags)
|
if (!flags)
|
||||||
|
@ -624,22 +627,26 @@ void parseAndCreateConditionalBreaks(u32 address, u8 flags, char** exp, int n){
|
||||||
if (exp[i][0] == '\'') {
|
if (exp[i][0] == '\'') {
|
||||||
now->exp_type_flags |= parseExpressionType(&exp[i][1]);
|
now->exp_type_flags |= parseExpressionType(&exp[i][1]);
|
||||||
i++;
|
i++;
|
||||||
if(i >= n) goto fail;
|
if (i >= n)
|
||||||
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
now->exp_type_flags |= 6; //assume signed word
|
now->exp_type_flags |= 6; //assume signed word
|
||||||
}
|
}
|
||||||
now->address = strdup(exp[i]);
|
now->address = strdup(exp[i]);
|
||||||
i++;
|
i++;
|
||||||
if(i >= n) goto fail;
|
if (i >= n)
|
||||||
|
goto fail;
|
||||||
char* operandName = exp[i];
|
char* operandName = exp[i];
|
||||||
now->cond_flags = parseConditionOperand(exp[i]);
|
now->cond_flags = parseConditionOperand(exp[i]);
|
||||||
i++;
|
i++;
|
||||||
if(i >= n) goto fail;
|
if (i >= n)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
if (exp[i][0] == '\'') {
|
if (exp[i][0] == '\'') {
|
||||||
now->exp_type_flags |= (parseExpressionType(&exp[i][1]) << 4);
|
now->exp_type_flags |= (parseExpressionType(&exp[i][1]) << 4);
|
||||||
i++;
|
i++;
|
||||||
if(i >= n) goto fail;
|
if (i >= n)
|
||||||
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
now->exp_type_flags |= 0x60; //assume signed word
|
now->exp_type_flags |= 0x60; //assume signed word
|
||||||
}
|
}
|
||||||
|
@ -678,7 +685,8 @@ void parseAndCreateConditionalBreaks(u32 address, u8 flags, char** exp, int n){
|
||||||
}
|
}
|
||||||
|
|
||||||
//aux
|
//aux
|
||||||
u8 parseExpressionType(char* given_type){
|
u8 parseExpressionType(char* given_type)
|
||||||
|
{
|
||||||
u8 flags = 0;
|
u8 flags = 0;
|
||||||
//for such a small string, pays off to convert first
|
//for such a small string, pays off to convert first
|
||||||
char* type = strdup(given_type);
|
char* type = strdup(given_type);
|
||||||
|
@ -723,27 +731,32 @@ u8 parseExpressionType(char* given_type){
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 parseConditionOperand(char* type){
|
u8 parseConditionOperand(char* type)
|
||||||
|
{
|
||||||
u8 flag = 0;
|
u8 flag = 0;
|
||||||
if (toupper(type[0]) == 'S') {
|
if (toupper(type[0]) == 'S') {
|
||||||
flag = 8;
|
flag = 8;
|
||||||
type++;
|
type++;
|
||||||
}
|
}
|
||||||
switch (type[0]) {
|
switch (type[0]) {
|
||||||
case '!': if(type[1] == '=' || type[1] == '\0')
|
case '!':
|
||||||
|
if (type[1] == '=' || type[1] == '\0')
|
||||||
return flag | 0x6;
|
return flag | 0x6;
|
||||||
break;
|
break;
|
||||||
case '=': if(type[1] == '=' || type[1] == '\0')
|
case '=':
|
||||||
|
if (type[1] == '=' || type[1] == '\0')
|
||||||
return flag | 0x1;
|
return flag | 0x1;
|
||||||
break;
|
break;
|
||||||
case '<': if(type[1] == '>')
|
case '<':
|
||||||
|
if (type[1] == '>')
|
||||||
return flag | 0x6;
|
return flag | 0x6;
|
||||||
if (type[1] == '=')
|
if (type[1] == '=')
|
||||||
return flag | 0x5;
|
return flag | 0x5;
|
||||||
if (type[1] == '\0')
|
if (type[1] == '\0')
|
||||||
return flag | 0x4;
|
return flag | 0x4;
|
||||||
break;
|
break;
|
||||||
case '>': if(type[1] == '<')
|
case '>':
|
||||||
|
if (type[1] == '<')
|
||||||
return flag | 0x6;
|
return flag | 0x6;
|
||||||
if (type[1] == '=')
|
if (type[1] == '=')
|
||||||
return flag | 0x3;
|
return flag | 0x3;
|
||||||
|
@ -753,28 +766,33 @@ u8 parseConditionOperand(char* type){
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
switch (tolower(type[0])) {
|
switch (tolower(type[0])) {
|
||||||
case 'l': if(tolower(type[1]) == 'e')
|
case 'l':
|
||||||
|
if (tolower(type[1]) == 'e')
|
||||||
return flag | 0x5;
|
return flag | 0x5;
|
||||||
if (tolower(type[1]) == 't')
|
if (tolower(type[1]) == 't')
|
||||||
return flag | 0x4;
|
return flag | 0x4;
|
||||||
break;
|
break;
|
||||||
case 'g': if(tolower(type[1]) == 'e')
|
case 'g':
|
||||||
|
if (tolower(type[1]) == 'e')
|
||||||
return flag | 0x3;
|
return flag | 0x3;
|
||||||
if (tolower(type[1]) == 't')
|
if (tolower(type[1]) == 't')
|
||||||
return flag | 0x2;
|
return flag | 0x2;
|
||||||
|
|
||||||
case 'e': if(tolower(type[1]) == 'q')
|
case 'e':
|
||||||
|
if (tolower(type[1]) == 'q')
|
||||||
return flag | 0x1;
|
return flag | 0x1;
|
||||||
if (type[1] == '\0')
|
if (type[1] == '\0')
|
||||||
return flag | 0x1;
|
return flag | 0x1;
|
||||||
case 'n': if(tolower(type[1]) == 'e')
|
case 'n':
|
||||||
|
if (tolower(type[1]) == 'e')
|
||||||
return flag | 0x6;
|
return flag | 0x6;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 calculateFinalValue(char* expToEval, u8 type_of_flags){
|
u32 calculateFinalValue(char* expToEval, u8 type_of_flags)
|
||||||
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
if (!dexp_eval(expToEval, &val)) {
|
if (!dexp_eval(expToEval, &val)) {
|
||||||
printf("Invalid expression.\n");
|
printf("Invalid expression.\n");
|
||||||
|
@ -782,27 +800,34 @@ u32 calculateFinalValue(char* expToEval, u8 type_of_flags){
|
||||||
}
|
}
|
||||||
if (type_of_flags & 0x4) {
|
if (type_of_flags & 0x4) {
|
||||||
switch (type_of_flags & 0x3) {
|
switch (type_of_flags & 0x3) {
|
||||||
case 0: return (s8)(val&0xff);
|
case 0:
|
||||||
case 1: return (s16)(val&0xffff);
|
return (s8)(val & 0xff);
|
||||||
default: return (int)val;
|
case 1:
|
||||||
|
return (s16)(val & 0xffff);
|
||||||
|
default:
|
||||||
|
return (int)val;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (type_of_flags & 0x3) {
|
switch (type_of_flags & 0x3) {
|
||||||
case 0: return (u8)(val&0xff);
|
case 0:
|
||||||
case 1: return (u16)(val&0xffff);
|
return (u8)(val & 0xff);
|
||||||
default: return val;
|
case 1:
|
||||||
|
return (u16)(val & 0xffff);
|
||||||
|
default:
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for execution
|
//check for execution
|
||||||
bool isCorrectBreak(struct ConditionalBreak* toTest, u8 accessType){
|
bool isCorrectBreak(struct ConditionalBreak* toTest, u8 accessType)
|
||||||
|
{
|
||||||
|
|
||||||
return (toTest->type_flags & accessType);
|
return (toTest->type_flags & accessType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool doBreak(struct ConditionalBreak* toTest)
|
||||||
bool doBreak(struct ConditionalBreak* toTest){
|
{
|
||||||
struct ConditionalBreakNode* toExamine = toTest->firstCond;
|
struct ConditionalBreakNode* toExamine = toTest->firstCond;
|
||||||
|
|
||||||
bool globalVeredict = true;
|
bool globalVeredict = true;
|
||||||
|
@ -817,12 +842,12 @@ bool doBreak(struct ConditionalBreak* toTest){
|
||||||
}
|
}
|
||||||
toExamine = toExamine->next;
|
toExamine = toExamine->next;
|
||||||
globalVeredict = veredict && globalVeredict;
|
globalVeredict = veredict && globalVeredict;
|
||||||
|
|
||||||
}
|
}
|
||||||
return globalVeredict;
|
return globalVeredict;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doesBreak(u32 address, u8 allowedFlags){
|
bool doesBreak(u32 address, u8 allowedFlags)
|
||||||
|
{
|
||||||
u8 addrNo = address >> 24;
|
u8 addrNo = address >> 24;
|
||||||
if (conditionals[addrNo]) {
|
if (conditionals[addrNo]) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo];
|
struct ConditionalBreak* base = conditionals[addrNo];
|
||||||
|
|
|
@ -4,14 +4,10 @@
|
||||||
#include "../common/Types.h"
|
#include "../common/Types.h"
|
||||||
|
|
||||||
#define readWord(addr) \
|
#define readWord(addr) \
|
||||||
((map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + \
|
((map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + ((map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8) + ((map[(addr + 2) >> 24].address[(addr + 2) & map[(addr + 2) >> 24].mask]) << 16) + ((map[(addr + 3) >> 24].address[(addr + 3) & map[(addr + 3) >> 24].mask]) << 24))
|
||||||
((map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8) + \
|
|
||||||
((map[(addr + 2) >> 24].address[(addr + 2) & map[(addr + 2) >> 24].mask]) << 16) + \
|
|
||||||
((map[(addr + 3) >> 24].address[(addr + 3) & map[(addr + 3) >> 24].mask]) << 24))
|
|
||||||
|
|
||||||
#define readHalfWord(addr) \
|
#define readHalfWord(addr) \
|
||||||
((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + \
|
((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + ((&map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8))
|
||||||
((&map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8))
|
|
||||||
|
|
||||||
#define readByte(addr) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
#define readByte(addr) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "CheatSearch.h"
|
#include "CheatSearch.h"
|
||||||
|
|
||||||
|
@ -308,4 +308,3 @@ void cheatSearchUpdateValues(const CheatSearchData *cs)
|
||||||
memcpy(block->saved, block->data, block->size);
|
memcpy(block->saved, block->data, block->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,16 @@ struct CheatSearchData {
|
||||||
CheatSearchBlock* blocks;
|
CheatSearchBlock* blocks;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { SEARCH_EQ, SEARCH_NE, SEARCH_LT, SEARCH_LE, SEARCH_GT, SEARCH_GE };
|
enum { SEARCH_EQ,
|
||||||
|
SEARCH_NE,
|
||||||
|
SEARCH_LT,
|
||||||
|
SEARCH_LE,
|
||||||
|
SEARCH_GT,
|
||||||
|
SEARCH_GE };
|
||||||
|
|
||||||
enum { BITS_8, BITS_16, BITS_32 };
|
enum { BITS_8,
|
||||||
|
BITS_16,
|
||||||
|
BITS_32 };
|
||||||
|
|
||||||
#define SET_BIT(bits, off) (bits)[(off) >> 3] |= (1 << ((off)&7))
|
#define SET_BIT(bits, off) (bits)[(off) >> 3] |= (1 << ((off)&7))
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#include <memory.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "GBA.h"
|
|
||||||
#include "GBAinline.h"
|
|
||||||
#include "Cheats.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
#include "../NLS.h"
|
#include "../NLS.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
|
#include "Cheats.h"
|
||||||
|
#include "GBA.h"
|
||||||
|
#include "GBAinline.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gameshark code types: (based on AR v1.0)
|
* Gameshark code types: (based on AR v1.0)
|
||||||
|
@ -297,7 +297,6 @@ u8 v3_deadtable2[256] = {
|
||||||
#define debuggerWriteByte(addr, value) \
|
#define debuggerWriteByte(addr, value) \
|
||||||
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
|
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
|
||||||
|
|
||||||
|
|
||||||
#define CHEAT_IS_HEX(a) (((a) >= 'A' && (a) <= 'F') || ((a) >= '0' && (a) <= '9'))
|
#define CHEAT_IS_HEX(a) (((a) >= 'A' && (a) <= 'F') || ((a) >= '0' && (a) <= '9'))
|
||||||
|
|
||||||
#define CHEAT_PATCH_ROM_16BIT(a, v) \
|
#define CHEAT_PATCH_ROM_16BIT(a, v) \
|
||||||
|
@ -742,8 +741,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
|
CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CBA_IF_KEYS_PRESSED:
|
case CBA_IF_KEYS_PRESSED: {
|
||||||
{
|
|
||||||
u16 value = cheatsList[i].value;
|
u16 value = cheatsList[i].value;
|
||||||
u32 addr = cheatsList[i].address;
|
u32 addr = cheatsList[i].address;
|
||||||
if ((addr & 0xF0) == 0x20) {
|
if ((addr & 0xF0) == 0x20) {
|
||||||
|
@ -759,15 +757,13 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case CBA_IF_TRUE:
|
case CBA_IF_TRUE:
|
||||||
if (CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) {
|
if (CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CBA_SLIDE_CODE:
|
case CBA_SLIDE_CODE: {
|
||||||
{
|
|
||||||
u32 address = cheatsList[i].address;
|
u32 address = cheatsList[i].address;
|
||||||
u16 value = cheatsList[i].value;
|
u16 value = cheatsList[i].value;
|
||||||
i++;
|
i++;
|
||||||
|
@ -781,8 +777,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
value += vinc;
|
value += vinc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case CBA_IF_FALSE:
|
case CBA_IF_FALSE:
|
||||||
if (CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value) {
|
if (CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value) {
|
||||||
i++;
|
i++;
|
||||||
|
@ -790,8 +785,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
break;
|
break;
|
||||||
case CBA_AND:
|
case CBA_AND:
|
||||||
CPUWriteHalfWord(cheatsList[i].address,
|
CPUWriteHalfWord(cheatsList[i].address,
|
||||||
CPUReadHalfWord(cheatsList[i].address) &
|
CPUReadHalfWord(cheatsList[i].address) & cheatsList[i].value);
|
||||||
cheatsList[i].value);
|
|
||||||
break;
|
break;
|
||||||
case GSA_8_BIT_IF_TRUE:
|
case GSA_8_BIT_IF_TRUE:
|
||||||
if (CPUReadByte(cheatsList[i].address) != cheatsList[i].value) {
|
if (CPUReadByte(cheatsList[i].address) != cheatsList[i].value) {
|
||||||
|
@ -813,8 +807,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GSA_8_BIT_FILL:
|
case GSA_8_BIT_FILL: {
|
||||||
{
|
|
||||||
u32 addr = cheatsList[i].address;
|
u32 addr = cheatsList[i].address;
|
||||||
u8 v = cheatsList[i].value & 0xff;
|
u8 v = cheatsList[i].value & 0xff;
|
||||||
u32 end = addr + (cheatsList[i].value >> 8);
|
u32 end = addr + (cheatsList[i].value >> 8);
|
||||||
|
@ -822,10 +815,8 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
CPUWriteByte(addr, v);
|
CPUWriteByte(addr, v);
|
||||||
addr++;
|
addr++;
|
||||||
} while (addr <= end);
|
} while (addr <= end);
|
||||||
}
|
} break;
|
||||||
break;
|
case GSA_16_BIT_FILL: {
|
||||||
case GSA_16_BIT_FILL:
|
|
||||||
{
|
|
||||||
u32 addr = cheatsList[i].address;
|
u32 addr = cheatsList[i].address;
|
||||||
u16 v = cheatsList[i].value & 0xffff;
|
u16 v = cheatsList[i].value & 0xffff;
|
||||||
u32 end = addr + ((cheatsList[i].value >> 16) << 1);
|
u32 end = addr + ((cheatsList[i].value >> 16) << 1);
|
||||||
|
@ -833,8 +824,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
CPUWriteHalfWord(addr, v);
|
CPUWriteHalfWord(addr, v);
|
||||||
addr += 2;
|
addr += 2;
|
||||||
} while (addr <= end);
|
} while (addr <= end);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case GSA_8_BIT_IF_TRUE2:
|
case GSA_8_BIT_IF_TRUE2:
|
||||||
if (CPUReadByte(cheatsList[i].address) != cheatsList[i].value) {
|
if (CPUReadByte(cheatsList[i].address) != cheatsList[i].value) {
|
||||||
i += 2;
|
i += 2;
|
||||||
|
@ -868,18 +858,15 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
case CBA_ADD:
|
case CBA_ADD:
|
||||||
if ((cheatsList[i].address & 1) == 0) {
|
if ((cheatsList[i].address & 1) == 0) {
|
||||||
CPUWriteHalfWord(cheatsList[i].address,
|
CPUWriteHalfWord(cheatsList[i].address,
|
||||||
CPUReadHalfWord(cheatsList[i].address) +
|
CPUReadHalfWord(cheatsList[i].address) + cheatsList[i].value);
|
||||||
cheatsList[i].value);
|
|
||||||
} else {
|
} else {
|
||||||
CPUWriteMemory(cheatsList[i].address & 0x0FFFFFFE,
|
CPUWriteMemory(cheatsList[i].address & 0x0FFFFFFE,
|
||||||
CPUReadMemory(cheatsList[i].address & 0x0FFFFFFE) +
|
CPUReadMemory(cheatsList[i].address & 0x0FFFFFFE) + cheatsList[i].value);
|
||||||
cheatsList[i].value);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CBA_OR:
|
case CBA_OR:
|
||||||
CPUWriteHalfWord(cheatsList[i].address,
|
CPUWriteHalfWord(cheatsList[i].address,
|
||||||
CPUReadHalfWord(cheatsList[i].address) |
|
CPUReadHalfWord(cheatsList[i].address) | cheatsList[i].value);
|
||||||
cheatsList[i].value);
|
|
||||||
break;
|
break;
|
||||||
case CBA_GT:
|
case CBA_GT:
|
||||||
if (!(CPUReadHalfWord(cheatsList[i].address) > cheatsList[i].value)) {
|
if (!(CPUReadHalfWord(cheatsList[i].address) > cheatsList[i].value)) {
|
||||||
|
@ -891,8 +878,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CBA_SUPER:
|
case CBA_SUPER: {
|
||||||
{
|
|
||||||
int count = 2 * ((cheatsList[i].value - 1) & 0xFFFF) + 1;
|
int count = 2 * ((cheatsList[i].value - 1) & 0xFFFF) + 1;
|
||||||
u32 address = cheatsList[i].address;
|
u32 address = cheatsList[i].address;
|
||||||
for (int x = 0; x <= count; x++) {
|
for (int x = 0; x <= count; x++) {
|
||||||
|
@ -907,28 +893,21 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
CPUWriteByte(address, b);
|
CPUWriteByte(address, b);
|
||||||
address++;
|
address++;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case GSA_8_BIT_POINTER:
|
case GSA_8_BIT_POINTER:
|
||||||
if (((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000)) ||
|
if (((CPUReadMemory(cheatsList[i].address) >= 0x02000000) && (CPUReadMemory(cheatsList[i].address) < 0x02040000)) || ((CPUReadMemory(cheatsList[i].address) >= 0x03000000) && (CPUReadMemory(cheatsList[i].address) < 0x03008000))) {
|
||||||
((CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000)))
|
|
||||||
{
|
|
||||||
CPUWriteByte(CPUReadMemory(cheatsList[i].address) + ((cheatsList[i].value & 0xFFFFFF00) >> 8),
|
CPUWriteByte(CPUReadMemory(cheatsList[i].address) + ((cheatsList[i].value & 0xFFFFFF00) >> 8),
|
||||||
cheatsList[i].value & 0xFF);
|
cheatsList[i].value & 0xFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GSA_16_BIT_POINTER:
|
case GSA_16_BIT_POINTER:
|
||||||
if (((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000)) ||
|
if (((CPUReadMemory(cheatsList[i].address) >= 0x02000000) && (CPUReadMemory(cheatsList[i].address) < 0x02040000)) || ((CPUReadMemory(cheatsList[i].address) >= 0x03000000) && (CPUReadMemory(cheatsList[i].address) < 0x03008000))) {
|
||||||
((CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000)))
|
|
||||||
{
|
|
||||||
CPUWriteHalfWord(CPUReadMemory(cheatsList[i].address) + ((cheatsList[i].value & 0xFFFF0000) >> 15),
|
CPUWriteHalfWord(CPUReadMemory(cheatsList[i].address) + ((cheatsList[i].value & 0xFFFF0000) >> 15),
|
||||||
cheatsList[i].value & 0xFFFF);
|
cheatsList[i].value & 0xFFFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GSA_32_BIT_POINTER:
|
case GSA_32_BIT_POINTER:
|
||||||
if (((CPUReadMemory(cheatsList[i].address)>=0x02000000) && (CPUReadMemory(cheatsList[i].address)<0x02040000)) ||
|
if (((CPUReadMemory(cheatsList[i].address) >= 0x02000000) && (CPUReadMemory(cheatsList[i].address) < 0x02040000)) || ((CPUReadMemory(cheatsList[i].address) >= 0x03000000) && (CPUReadMemory(cheatsList[i].address) < 0x03008000))) {
|
||||||
((CPUReadMemory(cheatsList[i].address)>=0x03000000) && (CPUReadMemory(cheatsList[i].address)<0x03008000)))
|
|
||||||
{
|
|
||||||
CPUWriteMemory(CPUReadMemory(cheatsList[i].address),
|
CPUWriteMemory(CPUReadMemory(cheatsList[i].address),
|
||||||
cheatsList[i].value);
|
cheatsList[i].value);
|
||||||
}
|
}
|
||||||
|
@ -1102,13 +1081,11 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GSA_16_BIT_WRITE_IOREGS:
|
case GSA_16_BIT_WRITE_IOREGS:
|
||||||
if ((cheatsList[i].address <= 0x3FF) && (cheatsList[i].address != 0x6) &&
|
if ((cheatsList[i].address <= 0x3FF) && (cheatsList[i].address != 0x6) && (cheatsList[i].address != 0x130))
|
||||||
(cheatsList[i].address != 0x130))
|
|
||||||
ioMem[cheatsList[i].address & 0x3FE] = cheatsList[i].value & 0xFFFF;
|
ioMem[cheatsList[i].address & 0x3FE] = cheatsList[i].value & 0xFFFF;
|
||||||
break;
|
break;
|
||||||
case GSA_32_BIT_WRITE_IOREGS:
|
case GSA_32_BIT_WRITE_IOREGS:
|
||||||
if (cheatsList[i].address<=0x3FF)
|
if (cheatsList[i].address <= 0x3FF) {
|
||||||
{
|
|
||||||
if (((cheatsList[i].address & 0x3FC) != 0x6) && ((cheatsList[i].address & 0x3FC) != 0x130))
|
if (((cheatsList[i].address & 0x3FC) != 0x6) && ((cheatsList[i].address & 0x3FC) != 0x130))
|
||||||
ioMem[cheatsList[i].address & 0x3FC] = (cheatsList[i].value & 0xFFFF);
|
ioMem[cheatsList[i].address & 0x3FC] = (cheatsList[i].value & 0xFFFF);
|
||||||
if ((((cheatsList[i].address & 0x3FC) + 2) != 0x6) && ((cheatsList[i].address & 0x3FC) + 2) != 0x130)
|
if ((((cheatsList[i].address & 0x3FC) + 2) != 0x6) && ((cheatsList[i].address & 0x3FC) + 2) != 0x130)
|
||||||
|
@ -1225,8 +1202,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
onoff = false;
|
onoff = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GSA_GROUP_WRITE:
|
case GSA_GROUP_WRITE: {
|
||||||
{
|
|
||||||
int count = ((cheatsList[i].address) & 0xFFFE) + 1;
|
int count = ((cheatsList[i].address) & 0xFFFE) + 1;
|
||||||
u32 value = cheatsList[i].value;
|
u32 value = cheatsList[i].value;
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
@ -1237,12 +1213,10 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
||||||
if (x < count)
|
if (x < count)
|
||||||
i++;
|
i++;
|
||||||
CPUWriteMemory(cheatsList[i].rawaddress, value);
|
CPUWriteMemory(cheatsList[i].rawaddress, value);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
CPUWriteMemory(cheatsList[i].value, value);
|
CPUWriteMemory(cheatsList[i].value, value);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case GSA_32_BIT_ADD2:
|
case GSA_32_BIT_ADD2:
|
||||||
CPUWriteMemory(cheatsList[i].value,
|
CPUWriteMemory(cheatsList[i].value,
|
||||||
(CPUReadMemory(cheatsList[i].value) + cheatsList[i + 1].rawaddress) & 0xFFFFFFFF);
|
(CPUReadMemory(cheatsList[i].value) + cheatsList[i + 1].rawaddress) & 0xFFFFFFFF);
|
||||||
|
@ -1399,8 +1373,7 @@ void cheatsDelete(int number, bool restore)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((x + 1) < cheatsNumber) {
|
if ((x + 1) < cheatsNumber) {
|
||||||
memcpy(&cheatsList[x], &cheatsList[x+1], sizeof(CheatsData)*
|
memcpy(&cheatsList[x], &cheatsList[x + 1], sizeof(CheatsData) * (cheatsNumber - x - 1));
|
||||||
(cheatsNumber-x-1));
|
|
||||||
}
|
}
|
||||||
cheatsNumber--;
|
cheatsNumber--;
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1505,8 @@ u16 cheatsGSAGetDeadface(bool v3)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cheatsGSAChangeEncryption(u16 value, bool v3) {
|
void cheatsGSAChangeEncryption(u16 value, bool v3)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
u8 *deadtable1, *deadtable2;
|
u8 *deadtable1, *deadtable2;
|
||||||
|
|
||||||
|
@ -1541,8 +1515,7 @@ void cheatsGSAChangeEncryption(u16 value, bool v3) {
|
||||||
deadtable2 = (u8*)(&v3_deadtable2);
|
deadtable2 = (u8*)(&v3_deadtable2);
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
seeds_v3[i] = seed_gen(((value & 0xFF00) >> 8), (value & 0xFF) + i, deadtable1, deadtable2);
|
seeds_v3[i] = seed_gen(((value & 0xFF00) >> 8), (value & 0xFF) + i, deadtable1, deadtable2);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
deadtable1 = (u8*)(&v1_deadtable1);
|
deadtable1 = (u8*)(&v1_deadtable1);
|
||||||
deadtable2 = (u8*)(&v1_deadtable2);
|
deadtable2 = (u8*)(&v1_deadtable2);
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
@ -1551,7 +1524,8 @@ void cheatsGSAChangeEncryption(u16 value, bool v3) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 seed_gen(u8 upper, u8 seed, u8 *deadtable1, u8 *deadtable2) {
|
u32 seed_gen(u8 upper, u8 seed, u8* deadtable1, u8* deadtable2)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
u32 newseed = 0;
|
u32 newseed = 0;
|
||||||
|
|
||||||
|
@ -1568,10 +1542,8 @@ void cheatsDecryptGSACode(u32& address, u32& value, bool v3)
|
||||||
|
|
||||||
int bitsleft = 32;
|
int bitsleft = 32;
|
||||||
while (bitsleft > 0) {
|
while (bitsleft > 0) {
|
||||||
value -= ((((address << 4) + seeds[2]) ^ (address + rollingseed)) ^
|
value -= ((((address << 4) + seeds[2]) ^ (address + rollingseed)) ^ ((address >> 5) + seeds[3]));
|
||||||
((address >> 5) + seeds[3]));
|
address -= ((((value << 4) + seeds[0]) ^ (value + rollingseed)) ^ ((value >> 5) + seeds[1]));
|
||||||
address -= ((((value << 4) + seeds[0]) ^ (value + rollingseed)) ^
|
|
||||||
((value >> 5) + seeds[1]));
|
|
||||||
rollingseed -= 0x9E3779B9;
|
rollingseed -= 0x9E3779B9;
|
||||||
bitsleft--;
|
bitsleft--;
|
||||||
}
|
}
|
||||||
|
@ -1633,13 +1605,11 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
||||||
u32 addr = (address & 0x00F00000) << 4 | (address & 0x0003FFFF);
|
u32 addr = (address & 0x00F00000) << 4 | (address & 0x0003FFFF);
|
||||||
u16 mcode = (address >> 24 & 0xFF);
|
u16 mcode = (address >> 24 & 0xFF);
|
||||||
|
|
||||||
if ((mcode & 0xFE) == 0xC4)
|
if ((mcode & 0xFE) == 0xC4) {
|
||||||
{
|
|
||||||
cheatsAdd(code, desc, address, (address & 0x1FFFFFF) | (0x08000000),
|
cheatsAdd(code, desc, address, (address & 0x1FFFFFF) | (0x08000000),
|
||||||
value, 257, MASTER_CODE);
|
value, 257, MASTER_CODE);
|
||||||
mastercode = (address & 0x1FFFFFF) | (0x08000000);
|
mastercode = (address & 0x1FFFFFF) | (0x08000000);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
if (address == 0) {
|
if (address == 0) {
|
||||||
|
@ -2218,14 +2188,16 @@ u32 cheatsCBACalcIndex(u32 x, u32 y)
|
||||||
if (y < x) {
|
if (y < x) {
|
||||||
y = y << 4;
|
y = y << 4;
|
||||||
x0 = x0 << 4;
|
x0 = x0 << 4;
|
||||||
} else break;
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (y < 0x80000000) {
|
while (y < 0x80000000) {
|
||||||
if (y < x) {
|
if (y < x) {
|
||||||
y = y << 1;
|
y = y << 1;
|
||||||
x0 = x0 << 1;
|
x0 = x0 << 1;
|
||||||
} else break;
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
@ -2330,8 +2302,7 @@ u16 cheatsCBAGenValue(u32 x, u32 y, u32 z)
|
||||||
u32 temp = z ^ x;
|
u32 temp = z ^ x;
|
||||||
if ((int)temp >= 0) {
|
if ((int)temp >= 0) {
|
||||||
temp = z << 0x11;
|
temp = z << 0x11;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
temp = z << 0x01;
|
temp = z << 0x01;
|
||||||
temp ^= x0;
|
temp ^= x0;
|
||||||
temp = temp << 0x10;
|
temp = temp << 0x10;
|
||||||
|
@ -2343,7 +2314,8 @@ u16 cheatsCBAGenValue(u32 x, u32 y, u32 z)
|
||||||
return z & 0xffff;
|
return z & 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cheatsCBAGenTable() {
|
void cheatsCBAGenTable()
|
||||||
|
{
|
||||||
for (int i = 0; i < 0x100; i++) {
|
for (int i = 0; i < 0x100; i++) {
|
||||||
cheatsCBATable[i] = cheatsCBAGenValue(i, 0x1021, 0);
|
cheatsCBATable[i] = cheatsCBAGenValue(i, 0x1021, 0);
|
||||||
}
|
}
|
||||||
|
@ -2361,13 +2333,21 @@ u16 cheatsCBACalcCRC(u8 *rom, int count)
|
||||||
if (count != -1) {
|
if (count != -1) {
|
||||||
while (count != -1) {
|
while (count != -1) {
|
||||||
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
||||||
^ *rom++]) << 0x10) >> 0x10;
|
^ *rom++])
|
||||||
|
<< 0x10)
|
||||||
|
>> 0x10;
|
||||||
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
||||||
^ *rom++]) << 0x10) >> 0x10;
|
^ *rom++])
|
||||||
|
<< 0x10)
|
||||||
|
>> 0x10;
|
||||||
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
||||||
^ *rom++]) << 0x10) >> 0x10;
|
^ *rom++])
|
||||||
|
<< 0x10)
|
||||||
|
>> 0x10;
|
||||||
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18)
|
||||||
^ *rom++]) << 0x10) >> 0x10;
|
^ *rom++])
|
||||||
|
<< 0x10)
|
||||||
|
>> 0x10;
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2386,10 +2366,8 @@ void cheatsCBADecrypt(u8 *decrypt)
|
||||||
chatsCBAScramble(array, count, cheatsCBASeedBuffer[count]);
|
chatsCBAScramble(array, count, cheatsCBASeedBuffer[count]);
|
||||||
}
|
}
|
||||||
cheatsCBAArrayToValue(array, decrypt);
|
cheatsCBAArrayToValue(array, decrypt);
|
||||||
*((u32 *)decrypt) = cheatsCBAGetValue(decrypt) ^
|
*((u32*)decrypt) = cheatsCBAGetValue(decrypt) ^ cheatsCBASeed[0];
|
||||||
cheatsCBASeed[0];
|
*((u16*)(decrypt + 4)) = (cheatsCBAGetData(decrypt) ^ cheatsCBASeed[1]) & 0xffff;
|
||||||
*((u16 *)(decrypt+4)) = (cheatsCBAGetData(decrypt) ^
|
|
||||||
cheatsCBASeed[1]) & 0xffff;
|
|
||||||
|
|
||||||
cheatsCBAReverseArray(decrypt, array);
|
cheatsCBAReverseArray(decrypt, array);
|
||||||
|
|
||||||
|
@ -2409,7 +2387,8 @@ void cheatsCBADecrypt(u8 *decrypt)
|
||||||
*((u32*)decrypt) = cheatsCBAGetValue(decrypt)
|
*((u32*)decrypt) = cheatsCBAGetValue(decrypt)
|
||||||
^ cheatsCBASeed[2];
|
^ cheatsCBASeed[2];
|
||||||
*((u16*)(decrypt + 4)) = (cheatsCBAGetData(decrypt)
|
*((u16*)(decrypt + 4)) = (cheatsCBAGetData(decrypt)
|
||||||
^ cheatsCBASeed[3]) & 0xffff;
|
^ cheatsCBASeed[3])
|
||||||
|
& 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cheatsCBAGetCount()
|
int cheatsCBAGetCount()
|
||||||
|
@ -2487,8 +2466,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
if(cheatsCBAGetCount() == 0 &&
|
if (cheatsCBAGetCount() == 0 && (address >> 28) == 9) {
|
||||||
(address >> 28) == 9) {
|
|
||||||
u32 seed[8];
|
u32 seed[8];
|
||||||
cheatsCBAParseSeedCode(address, value, seed);
|
cheatsCBAParseSeedCode(address, value, seed);
|
||||||
cheatsCBAChangeEncryption(seed);
|
cheatsCBAChangeEncryption(seed);
|
||||||
|
@ -2510,8 +2488,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0x00:
|
case 0x00: {
|
||||||
{
|
|
||||||
if (!cheatsCBATableGenerated)
|
if (!cheatsCBATableGenerated)
|
||||||
cheatsCBAGenTable();
|
cheatsCBAGenTable();
|
||||||
u32 crc = cheatsCBACalcCRC(rom, 0x10000);
|
u32 crc = cheatsCBACalcCRC(rom, 0x10000);
|
||||||
|
@ -2521,8 +2498,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
||||||
}
|
}
|
||||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
|
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
|
||||||
UNKNOWN_CODE);
|
UNKNOWN_CODE);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 0x01:
|
case 0x01:
|
||||||
cheatsAdd(code, desc, address, (address & 0x1FFFFFF) | 0x08000000, value, 512, MASTER_CODE);
|
cheatsAdd(code, desc, address, (address & 0x1FFFFFF) | 0x08000000, value, 512, MASTER_CODE);
|
||||||
mastercode = (address & 0x1FFFFFF) | 0x08000000;
|
mastercode = (address & 0x1FFFFFF) | 0x08000000;
|
||||||
|
@ -2607,12 +2583,10 @@ void cheatsReadGame(gzFile file, int version)
|
||||||
if (version > 8)
|
if (version > 8)
|
||||||
utilGzRead(file, cheatsList, sizeof(cheatsList));
|
utilGzRead(file, cheatsList, sizeof(cheatsList));
|
||||||
|
|
||||||
|
|
||||||
bool firstCodeBreaker = true;
|
bool firstCodeBreaker = true;
|
||||||
|
|
||||||
for (int i = 0; i < cheatsNumber; i++) {
|
for (int i = 0; i < cheatsNumber; i++) {
|
||||||
if (version <9)
|
if (version < 9) {
|
||||||
{
|
|
||||||
cheatsList[i].code = utilReadInt(file);
|
cheatsList[i].code = utilReadInt(file);
|
||||||
cheatsList[i].size = utilReadInt(file);
|
cheatsList[i].size = utilReadInt(file);
|
||||||
cheatsList[i].status = utilReadInt(file);
|
cheatsList[i].status = utilReadInt(file);
|
||||||
|
@ -2668,7 +2642,6 @@ void cheatsReadGame(gzFile file, int version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// skip the cheat list data
|
// skip the cheat list data
|
||||||
void cheatsReadGameSkip(gzFile file, int version)
|
void cheatsReadGameSkip(gzFile file, int version)
|
||||||
{
|
{
|
||||||
|
@ -2686,7 +2659,6 @@ void cheatsReadGameSkip( gzFile file, int version )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cheatsSaveCheatList(const char* file)
|
void cheatsSaveCheatList(const char* file)
|
||||||
{
|
{
|
||||||
if (cheatsNumber == 0)
|
if (cheatsNumber == 0)
|
||||||
|
@ -2733,7 +2705,6 @@ bool cheatsLoadCheatList(const char *file)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((type != 0) && (type != 1)) {
|
if ((type != 0) && (type != 1)) {
|
||||||
systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_TYPE,
|
systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_TYPE,
|
||||||
N_("Unsupported cheat list type %d"), type);
|
N_("Unsupported cheat list type %d"), type);
|
||||||
|
@ -2745,15 +2716,12 @@ bool cheatsLoadCheatList(const char *file)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (type == 1)
|
if (type == 1) {
|
||||||
{
|
|
||||||
if (fread(cheatsList, 1, sizeof(cheatsList), f) > sizeof(cheatsList)) {
|
if (fread(cheatsList, 1, sizeof(cheatsList), f) > sizeof(cheatsList)) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else if (type == 0) {
|
||||||
else if (type == 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
fread(&cheatsList[i].code, 1, sizeof(int), f);
|
fread(&cheatsList[i].code, 1, sizeof(int), f);
|
||||||
fread(&cheatsList[i].size, 1, sizeof(int), f);
|
fread(&cheatsList[i].size, 1, sizeof(int), f);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include <memory.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "GBA.h"
|
|
||||||
#include "EEprom.h"
|
#include "EEprom.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
|
#include "GBA.h"
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
extern int cpuDmaCount;
|
extern int cpuDmaCount;
|
||||||
|
|
||||||
|
@ -110,8 +110,7 @@ int eepromRead(u32 /* address */)
|
||||||
case EEPROM_READADDRESS:
|
case EEPROM_READADDRESS:
|
||||||
case EEPROM_WRITEDATA:
|
case EEPROM_WRITEDATA:
|
||||||
return 1;
|
return 1;
|
||||||
case EEPROM_READDATA:
|
case EEPROM_READDATA: {
|
||||||
{
|
|
||||||
eepromBits++;
|
eepromBits++;
|
||||||
if (eepromBits == 4) {
|
if (eepromBits == 4) {
|
||||||
eepromMode = EEPROM_READDATA2;
|
eepromMode = EEPROM_READDATA2;
|
||||||
|
@ -120,8 +119,7 @@ int eepromRead(u32 /* address */)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case EEPROM_READDATA2:
|
case EEPROM_READDATA2: {
|
||||||
{
|
|
||||||
int data = 0;
|
int data = 0;
|
||||||
int address = eepromAddress << 3;
|
int address = eepromAddress << 3;
|
||||||
int mask = 1 << (7 - (eepromBits & 7));
|
int mask = 1 << (7 - (eepromBits & 7));
|
||||||
|
@ -162,8 +160,7 @@ void eepromWrite(u32 /* address */, u8 value)
|
||||||
if (eepromBits == 0x11) {
|
if (eepromBits == 0x11) {
|
||||||
eepromInUse = true;
|
eepromInUse = true;
|
||||||
eepromSize = 0x2000;
|
eepromSize = 0x2000;
|
||||||
eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) |
|
eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) | ((eepromBuffer[1] & 0xFF));
|
||||||
((eepromBuffer[1] & 0xFF));
|
|
||||||
if (!(eepromBuffer[0] & 0x40)) {
|
if (!(eepromBuffer[0] & 0x40)) {
|
||||||
eepromBuffer[0] = bit;
|
eepromBuffer[0] = bit;
|
||||||
eepromBits = 1;
|
eepromBits = 1;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include <stdio.h>
|
#include "Flash.h"
|
||||||
#include <string.h>
|
#include "../Util.h"
|
||||||
#include <memory.h>
|
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Flash.h"
|
|
||||||
#include "Sram.h"
|
#include "Sram.h"
|
||||||
#include "../Util.h"
|
#include <memory.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define FLASH_READ_ARRAY 0
|
#define FLASH_READ_ARRAY 0
|
||||||
#define FLASH_CMD_1 1
|
#define FLASH_CMD_1 1
|
||||||
|
@ -114,7 +114,6 @@ void flashReadGameSkip(gzFile gzFile, int version)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void flashSetSize(int size)
|
void flashSetSize(int size)
|
||||||
{
|
{
|
||||||
// log("Setting flash size to %d\n", size);
|
// log("Setting flash size to %d\n", size);
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../NLS.h"
|
||||||
|
#include "../System.h"
|
||||||
|
#include "../Util.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
#include "Cheats.h"
|
||||||
|
#include "EEprom.h"
|
||||||
|
#include "Flash.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "GBAcpu.h"
|
#include "GBAcpu.h"
|
||||||
#include "GBAinline.h"
|
#include "GBAinline.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "EEprom.h"
|
|
||||||
#include "Flash.h"
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "Sram.h"
|
#include "Sram.h"
|
||||||
#include "bios.h"
|
|
||||||
#include "Cheats.h"
|
|
||||||
#include "../NLS.h"
|
|
||||||
#include "elf.h"
|
|
||||||
#include "../Util.h"
|
|
||||||
#include "../System.h"
|
|
||||||
#include "../common/ConfigManager.h"
|
|
||||||
#include "agbprint.h"
|
#include "agbprint.h"
|
||||||
|
#include "bios.h"
|
||||||
|
#include "elf.h"
|
||||||
#include "remote.h"
|
#include "remote.h"
|
||||||
|
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
|
@ -59,7 +59,6 @@ static INSN_REGPARM void armBreakpoint(u32 opcode)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Subroutine to count instructions (for debugging/optimizing)
|
// Subroutine to count instructions (for debugging/optimizing)
|
||||||
//#define INSN_COUNTER // comment out if you don't want it
|
//#define INSN_COUNTER // comment out if you don't want it
|
||||||
#ifdef INSN_COUNTER
|
#ifdef INSN_COUNTER
|
||||||
|
@ -101,10 +100,12 @@ static void count(u32 opcode, int cond_res)
|
||||||
// Common macros //////////////////////////////////////////////////////////
|
// Common macros //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
#define CONSOLE_OUTPUT(a,b) do { \
|
#define CONSOLE_OUTPUT(a, b) \
|
||||||
|
do { \
|
||||||
if ((opcode == 0xe0000000) && (reg[0].I == 0xC0DED00D)) { \
|
if ((opcode == 0xe0000000) && (reg[0].I == 0xC0DED00D)) { \
|
||||||
dbgOutput((a), (b)); \
|
dbgOutput((a), (b)); \
|
||||||
} while (0)
|
} \
|
||||||
|
while (0)
|
||||||
#else
|
#else
|
||||||
#define CONSOLE_OUTPUT(a, b) /* nothing */
|
#define CONSOLE_OUTPUT(a, b) /* nothing */
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,8 +152,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -169,8 +169,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -187,8 +186,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -207,8 +205,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r"(value), \
|
"r"(value), \
|
||||||
"r" (C_FLAG << 29) \
|
"r"(C_FLAG << 29)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -227,8 +224,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r"(value), \
|
"r"(value), \
|
||||||
"r" (C_FLAG << 29) \
|
"r"(C_FLAG << 29)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -247,8 +243,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r"(value), \
|
"r"(value), \
|
||||||
"r" (C_FLAG << 29) \
|
"r"(C_FLAG << 29)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -265,8 +260,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1; \
|
||||||
|
@ -282,8 +276,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[base].I), \
|
: "r"(reg[base].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1; \
|
||||||
|
@ -303,7 +296,8 @@ static void count(u32 opcode, int cond_res)
|
||||||
#define EMIT2(op, src, dest) #op " " src ", " dest "; "
|
#define EMIT2(op, src, dest) #op " " src ", " dest "; "
|
||||||
#define KONST(val) "$" #val
|
#define KONST(val) "$" #val
|
||||||
#define ASMVAR(cvar) ASMVAR2(__USER_LABEL_PREFIX__, cvar)
|
#define ASMVAR(cvar) ASMVAR2(__USER_LABEL_PREFIX__, cvar)
|
||||||
#define ASMVAR2(prefix,cvar) STRING (prefix) cvar
|
#define ASMVAR2(prefix, cvar) STRING(prefix) \
|
||||||
|
cvar
|
||||||
#define STRING(x) #x
|
#define STRING(x) #x
|
||||||
#define VAR(var) ASMVAR(#var)
|
#define VAR(var) ASMVAR(#var)
|
||||||
#define VARL(var) ASMVAR(#var)
|
#define VARL(var) ASMVAR(#var)
|
||||||
|
@ -685,8 +679,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
: "0"(offset), "c"(shift));
|
: "0"(offset), "c"(shift));
|
||||||
|
|
||||||
#define RRX_OFFSET \
|
#define RRX_OFFSET \
|
||||||
asm(EMIT2(btl,KONST(0),VAR(C_FLAG)) \
|
asm(EMIT2(btl, KONST(0), VAR(C_FLAG)) "rcr $1, %0" \
|
||||||
"rcr $1, %0" \
|
|
||||||
: "=r"(offset) \
|
: "=r"(offset) \
|
||||||
: "0"(offset));
|
: "0"(offset));
|
||||||
|
|
||||||
|
@ -698,7 +691,6 @@ static void count(u32 opcode, int cond_res)
|
||||||
__asm ror value, cl \
|
__asm ror value, cl \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define ROR_OFFSET \
|
#define ROR_OFFSET \
|
||||||
__asm { \
|
__asm { \
|
||||||
__asm mov ecx, shift \
|
__asm mov ecx, shift \
|
||||||
|
@ -725,19 +717,13 @@ static void count(u32 opcode, int cond_res)
|
||||||
#define C_SETCOND_ADD \
|
#define C_SETCOND_ADD \
|
||||||
N_FLAG = ((s32)res < 0) ? true : false; \
|
N_FLAG = ((s32)res < 0) ? true : false; \
|
||||||
Z_FLAG = (res == 0) ? true : false; \
|
Z_FLAG = (res == 0) ? true : false; \
|
||||||
V_FLAG = ((NEG(lhs) & NEG(rhs) & POS(res)) | \
|
V_FLAG = ((NEG(lhs) & NEG(rhs) & POS(res)) | (POS(lhs) & POS(rhs) & NEG(res))) ? true : false; \
|
||||||
(POS(lhs) & POS(rhs) & NEG(res))) ? true : false;\
|
C_FLAG = ((NEG(lhs) & NEG(rhs)) | (NEG(lhs) & POS(res)) | (NEG(rhs) & POS(res))) ? true : false;
|
||||||
C_FLAG = ((NEG(lhs) & NEG(rhs)) | \
|
|
||||||
(NEG(lhs) & POS(res)) | \
|
|
||||||
(NEG(rhs) & POS(res))) ? true : false;
|
|
||||||
#define C_SETCOND_SUB \
|
#define C_SETCOND_SUB \
|
||||||
N_FLAG = ((s32)res < 0) ? true : false; \
|
N_FLAG = ((s32)res < 0) ? true : false; \
|
||||||
Z_FLAG = (res == 0) ? true : false; \
|
Z_FLAG = (res == 0) ? true : false; \
|
||||||
V_FLAG = ((NEG(lhs) & POS(rhs) & POS(res)) | \
|
V_FLAG = ((NEG(lhs) & POS(rhs) & POS(res)) | (POS(lhs) & NEG(rhs) & NEG(res))) ? true : false; \
|
||||||
(POS(lhs) & NEG(rhs) & NEG(res))) ? true : false;\
|
C_FLAG = ((NEG(lhs) & POS(rhs)) | (NEG(lhs) & POS(res)) | (POS(rhs) & POS(res))) ? true : false;
|
||||||
C_FLAG = ((NEG(lhs) & POS(rhs)) | \
|
|
||||||
(NEG(lhs) & POS(res)) | \
|
|
||||||
(POS(rhs) & POS(res))) ? true : false;
|
|
||||||
|
|
||||||
#ifndef ALU_INIT_C
|
#ifndef ALU_INIT_C
|
||||||
#define ALU_INIT_C \
|
#define ALU_INIT_C \
|
||||||
|
@ -870,13 +856,11 @@ static void count(u32 opcode, int cond_res)
|
||||||
if (LIKELY(shift)) { \
|
if (LIKELY(shift)) { \
|
||||||
u32 v = reg[opcode & 0x0F].I; \
|
u32 v = reg[opcode & 0x0F].I; \
|
||||||
C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
|
C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
|
||||||
value = ((v << (32 - shift)) | \
|
value = ((v << (32 - shift)) | (v >> shift)); \
|
||||||
(v >> shift)); \
|
|
||||||
} else { \
|
} else { \
|
||||||
u32 v = reg[opcode & 0x0F].I; \
|
u32 v = reg[opcode & 0x0F].I; \
|
||||||
C_OUT = (v & 1) ? true : false; \
|
C_OUT = (v & 1) ? true : false; \
|
||||||
value = ((v >> 1) | \
|
value = ((v >> 1) | (C_FLAG << 31)); \
|
||||||
(C_FLAG << 31)); \
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// OP Rd,Rb,Rm ROR Rs
|
// OP Rd,Rb,Rm ROR Rs
|
||||||
|
@ -890,8 +874,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
if (LIKELY(shift & 0x1F)) { \
|
if (LIKELY(shift & 0x1F)) { \
|
||||||
u32 v = rm; \
|
u32 v = rm; \
|
||||||
C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
|
C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
|
||||||
value = ((v << (32 - shift)) | \
|
value = ((v << (32 - shift)) | (v >> shift)); \
|
||||||
(v >> shift)); \
|
|
||||||
} else { \
|
} else { \
|
||||||
value = rm; \
|
value = rm; \
|
||||||
if (shift) \
|
if (shift) \
|
||||||
|
@ -905,8 +888,7 @@ static void count(u32 opcode, int cond_res)
|
||||||
if (UNLIKELY(shift)) { \
|
if (UNLIKELY(shift)) { \
|
||||||
u32 v = opcode & 0xFF; \
|
u32 v = opcode & 0xFF; \
|
||||||
C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
|
C_OUT = (v >> (shift - 1)) & 1 ? true : false; \
|
||||||
value = ((v << (32 - shift)) | \
|
value = ((v << (32 - shift)) | (v >> shift)); \
|
||||||
(v >> shift)); \
|
|
||||||
} else { \
|
} else { \
|
||||||
value = opcode & 0xFF; \
|
value = opcode & 0xFF; \
|
||||||
}
|
}
|
||||||
|
@ -945,7 +927,10 @@ static void count(u32 opcode, int cond_res)
|
||||||
#define VALUE_IMM_NC VALUE_IMM_C
|
#define VALUE_IMM_NC VALUE_IMM_C
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define C_CHECK_PC(SETCOND) if (LIKELY(dest != 15)) { SETCOND }
|
#define C_CHECK_PC(SETCOND) \
|
||||||
|
if (LIKELY(dest != 15)) { \
|
||||||
|
SETCOND \
|
||||||
|
}
|
||||||
#ifndef OP_AND
|
#ifndef OP_AND
|
||||||
#define OP_AND \
|
#define OP_AND \
|
||||||
u32 res = reg[(opcode >> 16) & 15].I & value; \
|
u32 res = reg[(opcode >> 16) & 15].I & value; \
|
||||||
|
@ -1566,8 +1551,7 @@ static INSN_REGPARM void arm121(u32 opcode)
|
||||||
#define LDR(CALC_OFFSET, CALC_ADDRESS, LOAD_DATA, WRITEBACK, SIZE) \
|
#define LDR(CALC_OFFSET, CALC_ADDRESS, LOAD_DATA, WRITEBACK, SIZE) \
|
||||||
LDRSTR_INIT(CALC_OFFSET, CALC_ADDRESS); \
|
LDRSTR_INIT(CALC_OFFSET, CALC_ADDRESS); \
|
||||||
LOAD_DATA; \
|
LOAD_DATA; \
|
||||||
if (dest != base) \
|
if (dest != base) { \
|
||||||
{ \
|
|
||||||
WRITEBACK; \
|
WRITEBACK; \
|
||||||
} \
|
} \
|
||||||
clockTicks = 0; \
|
clockTicks = 0; \
|
||||||
|
@ -2145,15 +2129,13 @@ static INSN_REGPARM void arm7F6(u32 opcode) { LDR_PREINC_WB(OFFSET_ROR, OP_LDRB,
|
||||||
clockTicks += 1 + codeTicksAccessSeq32(armNextPC); \
|
clockTicks += 1 + codeTicksAccessSeq32(armNextPC); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// STMDA Rn, {Rlist}
|
// STMDA Rn, {Rlist}
|
||||||
static INSN_REGPARM void arm800(u32 opcode)
|
static INSN_REGPARM void arm800(u32 opcode)
|
||||||
{
|
{
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STM_ALL;
|
STM_ALL;
|
||||||
|
@ -2166,8 +2148,7 @@ static INSN_REGPARM void arm810(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL;
|
LDM_ALL;
|
||||||
|
@ -2180,8 +2161,7 @@ static INSN_REGPARM void arm820(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STMW_ALL;
|
STMW_ALL;
|
||||||
|
@ -2194,8 +2174,7 @@ static INSN_REGPARM void arm830(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL;
|
LDM_ALL;
|
||||||
|
@ -2210,8 +2189,7 @@ static INSN_REGPARM void arm840(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STM_ALL_2;
|
STM_ALL_2;
|
||||||
|
@ -2224,8 +2202,7 @@ static INSN_REGPARM void arm850(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL_2;
|
LDM_ALL_2;
|
||||||
|
@ -2239,8 +2216,7 @@ static INSN_REGPARM void arm860(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STMW_ALL_2;
|
STMW_ALL_2;
|
||||||
|
@ -2253,8 +2229,7 @@ static INSN_REGPARM void arm870(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL_2;
|
LDM_ALL_2;
|
||||||
|
@ -2296,8 +2271,7 @@ static INSN_REGPARM void arm8A0(u32 opcode)
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 address = reg[base].I & 0xFFFFFFFC;
|
u32 address = reg[base].I & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
STMW_ALL;
|
STMW_ALL;
|
||||||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||||
}
|
}
|
||||||
|
@ -2308,8 +2282,7 @@ static INSN_REGPARM void arm8B0(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = reg[base].I & 0xFFFFFFFC;
|
u32 address = reg[base].I & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL;
|
LDM_ALL;
|
||||||
|
@ -2351,8 +2324,7 @@ static INSN_REGPARM void arm8E0(u32 opcode)
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 address = reg[base].I & 0xFFFFFFFC;
|
u32 address = reg[base].I & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
STMW_ALL_2;
|
STMW_ALL_2;
|
||||||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||||
}
|
}
|
||||||
|
@ -2363,8 +2335,7 @@ static INSN_REGPARM void arm8F0(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = reg[base].I & 0xFFFFFFFC;
|
u32 address = reg[base].I & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL_2;
|
LDM_ALL_2;
|
||||||
|
@ -2380,8 +2351,7 @@ static INSN_REGPARM void arm900(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STM_ALL;
|
STM_ALL;
|
||||||
|
@ -2394,8 +2364,7 @@ static INSN_REGPARM void arm910(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL;
|
LDM_ALL;
|
||||||
|
@ -2408,8 +2377,7 @@ static INSN_REGPARM void arm920(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STMW_ALL;
|
STMW_ALL;
|
||||||
|
@ -2422,8 +2390,7 @@ static INSN_REGPARM void arm930(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL;
|
LDM_ALL;
|
||||||
|
@ -2438,8 +2405,7 @@ static INSN_REGPARM void arm940(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STM_ALL_2;
|
STM_ALL_2;
|
||||||
|
@ -2452,8 +2418,7 @@ static INSN_REGPARM void arm950(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL_2;
|
LDM_ALL_2;
|
||||||
|
@ -2467,8 +2432,7 @@ static INSN_REGPARM void arm960(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
STMW_ALL_2;
|
STMW_ALL_2;
|
||||||
|
@ -2481,8 +2445,7 @@ static INSN_REGPARM void arm970(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I -
|
u32 temp = reg[base].I - 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = temp & 0xFFFFFFFC;
|
u32 address = temp & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL_2;
|
LDM_ALL_2;
|
||||||
|
@ -2524,8 +2487,7 @@ static INSN_REGPARM void arm9A0(u32 opcode)
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
STMW_ALL;
|
STMW_ALL;
|
||||||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||||
}
|
}
|
||||||
|
@ -2536,8 +2498,7 @@ static INSN_REGPARM void arm9B0(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL;
|
LDM_ALL;
|
||||||
|
@ -2579,8 +2540,7 @@ static INSN_REGPARM void arm9E0(u32 opcode)
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 0xFF] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
STMW_ALL_2;
|
STMW_ALL_2;
|
||||||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||||
}
|
}
|
||||||
|
@ -2591,8 +2551,7 @@ static INSN_REGPARM void arm9F0(u32 opcode)
|
||||||
if (busPrefetchCount == 0)
|
if (busPrefetchCount == 0)
|
||||||
busPrefetch = busPrefetchEnable;
|
busPrefetch = busPrefetchEnable;
|
||||||
int base = (opcode & 0x000F0000) >> 16;
|
int base = (opcode & 0x000F0000) >> 16;
|
||||||
u32 temp = reg[base].I +
|
u32 temp = reg[base].I + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
|
||||||
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
u32 address = (reg[base].I + 4) & 0xFFFFFFFC;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LDM_ALL_2;
|
LDM_ALL_2;
|
||||||
|
@ -2635,7 +2594,6 @@ static INSN_REGPARM void armB00(u32 opcode)
|
||||||
busPrefetchCount = 0;
|
busPrefetchCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef GP_SUPPORT
|
#ifdef GP_SUPPORT
|
||||||
// MRC
|
// MRC
|
||||||
static INSN_REGPARM void armE01(u32 opcode)
|
static INSN_REGPARM void armE01(u32 opcode)
|
||||||
|
@ -2645,7 +2603,6 @@ static INSN_REGPARM void armE01(u32 opcode)
|
||||||
#define armE01 armUnknownInsn
|
#define armE01 armUnknownInsn
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// SWI <comment>
|
// SWI <comment>
|
||||||
static INSN_REGPARM void armF00(u32 opcode)
|
static INSN_REGPARM void armF00(u32 opcode)
|
||||||
{
|
{
|
||||||
|
@ -2662,7 +2619,8 @@ typedef INSN_REGPARM void (*insnfunc_t)(u32 opcode);
|
||||||
insn, insn, insn, insn, insn, insn, insn, insn, \
|
insn, insn, insn, insn, insn, insn, insn, insn, \
|
||||||
insn, insn, insn, insn, insn, insn, insn, insn
|
insn, insn, insn, insn, insn, insn, insn, insn
|
||||||
#define REP256(insn) \
|
#define REP256(insn) \
|
||||||
REP16(insn),REP16(insn),REP16(insn),REP16(insn),\
|
REP16(insn) \
|
||||||
|
, REP16(insn), REP16(insn), REP16(insn), \
|
||||||
REP16(insn), REP16(insn), REP16(insn), REP16(insn), \
|
REP16(insn), REP16(insn), REP16(insn), REP16(insn), \
|
||||||
REP16(insn), REP16(insn), REP16(insn), REP16(insn), \
|
REP16(insn), REP16(insn), REP16(insn), REP16(insn), \
|
||||||
REP16(insn), REP16(insn), REP16(insn), REP16(insn)
|
REP16(insn), REP16(insn), REP16(insn), REP16(insn)
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../NLS.h"
|
||||||
|
#include "../System.h"
|
||||||
|
#include "../Util.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
#include "Cheats.h"
|
||||||
|
#include "EEprom.h"
|
||||||
|
#include "Flash.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "GBAcpu.h"
|
#include "GBAcpu.h"
|
||||||
#include "GBAinline.h"
|
#include "GBAinline.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "EEprom.h"
|
|
||||||
#include "Flash.h"
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "Sram.h"
|
#include "Sram.h"
|
||||||
#include "bios.h"
|
|
||||||
#include "Cheats.h"
|
|
||||||
#include "../NLS.h"
|
|
||||||
#include "elf.h"
|
|
||||||
#include "../Util.h"
|
|
||||||
#include "../System.h"
|
|
||||||
#include "../common/ConfigManager.h"
|
|
||||||
#include "agbprint.h"
|
#include "agbprint.h"
|
||||||
|
#include "bios.h"
|
||||||
|
#include "elf.h"
|
||||||
#include "remote.h"
|
#include "remote.h"
|
||||||
|
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
|
@ -59,12 +59,14 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
// Common macros //////////////////////////////////////////////////////////
|
// Common macros //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
# define THUMB_CONSOLE_OUTPUT(a,b) do { \
|
#define THUMB_CONSOLE_OUTPUT(a, b) \
|
||||||
|
do { \
|
||||||
if ((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) { \
|
if ((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) { \
|
||||||
dbgOutput((a), (b)); \
|
dbgOutput((a), (b)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
# define UPDATE_OLDREG do { \
|
#define UPDATE_OLDREG \
|
||||||
|
do { \
|
||||||
if (debugger_last) { \
|
if (debugger_last) { \
|
||||||
snprintf(oldbuffer, sizeof(oldbuffer), "%08X", \
|
snprintf(oldbuffer, sizeof(oldbuffer), "%08X", \
|
||||||
armState ? reg[15].I - 4 : reg[15].I - 2); \
|
armState ? reg[15].I - 4 : reg[15].I - 2); \
|
||||||
|
@ -95,8 +97,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[source].I), \
|
: "r"(reg[source].I), \
|
||||||
"r" (reg[N].I) \
|
"r"(reg[N].I)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -113,8 +114,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[source].I), \
|
: "r"(reg[source].I), \
|
||||||
"r" (N) \
|
"r"(N)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -132,8 +132,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[(d)].I), \
|
: "r"(reg[(d)].I), \
|
||||||
"r" (opcode & 255) \
|
"r"(opcode & 255)); \
|
||||||
); \
|
|
||||||
reg[(d)].I = Result; \
|
reg[(d)].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -150,8 +149,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[dest].I), \
|
: "r"(reg[dest].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1; \
|
||||||
|
@ -170,12 +168,12 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "r" (reg[dest].I), \
|
: "r" (reg[dest].I), \
|
||||||
"r" (value), \
|
"r" (value), \
|
||||||
"r" (C_FLAG << 29) \
|
"r" (C_FLAG << 29) \
|
||||||
); \
|
);
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result;
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1;
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1;
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1;
|
||||||
V_FLAG = (Flags >> 26) & 1; \
|
V_FLAG = (Flags >> 26) & 1;
|
||||||
}
|
}
|
||||||
#define SUB_RD_RS_RN(N) \
|
#define SUB_RD_RS_RN(N) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -187,8 +185,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[source].I), \
|
: "r"(reg[source].I), \
|
||||||
"r" (reg[N].I) \
|
"r"(reg[N].I)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -205,8 +202,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[source].I), \
|
: "r"(reg[source].I), \
|
||||||
"r" (N) \
|
"r"(N)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -224,8 +220,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[(d)].I), \
|
: "r"(reg[(d)].I), \
|
||||||
"r" (opcode & 255) \
|
"r"(opcode & 255)); \
|
||||||
); \
|
|
||||||
reg[(d)].I = Result; \
|
reg[(d)].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -242,8 +237,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[(d)].I), \
|
: "r"(reg[(d)].I), \
|
||||||
"r" (opcode & 255) \
|
"r"(opcode & 255)); \
|
||||||
); \
|
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1; \
|
||||||
|
@ -262,12 +256,12 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "r" (reg[dest].I), \
|
: "r" (reg[dest].I), \
|
||||||
"r" (value), \
|
"r" (value), \
|
||||||
"r" (C_FLAG << 29) \
|
"r" (C_FLAG << 29) \
|
||||||
); \
|
);
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result;
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1;
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1;
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1;
|
||||||
V_FLAG = (Flags >> 26) & 1; \
|
V_FLAG = (Flags >> 26) & 1;
|
||||||
}
|
}
|
||||||
#define NEG_RD_RS \
|
#define NEG_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
|
@ -279,8 +273,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[source].I), \
|
: "r"(reg[source].I), \
|
||||||
"r" (0) \
|
"r"(0)); \
|
||||||
); \
|
|
||||||
reg[dest].I = Result; \
|
reg[dest].I = Result; \
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
|
@ -297,8 +290,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "=r"(Result), \
|
: "=r"(Result), \
|
||||||
"=r"(Flags) \
|
"=r"(Flags) \
|
||||||
: "r"(reg[dest].I), \
|
: "r"(reg[dest].I), \
|
||||||
"r" (value) \
|
"r"(value)); \
|
||||||
); \
|
|
||||||
Z_FLAG = (Flags >> 29) & 1; \
|
Z_FLAG = (Flags >> 29) & 1; \
|
||||||
N_FLAG = (Flags >> 31) & 1; \
|
N_FLAG = (Flags >> 31) & 1; \
|
||||||
C_FLAG = (Flags >> 25) & 1; \
|
C_FLAG = (Flags >> 25) & 1; \
|
||||||
|
@ -309,7 +301,8 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
#define EMIT2(op, src, dest) #op " " src ", " dest "; "
|
#define EMIT2(op, src, dest) #op " " src ", " dest "; "
|
||||||
#define KONST(val) "$" #val
|
#define KONST(val) "$" #val
|
||||||
#define ASMVAR(cvar) ASMVAR2(__USER_LABEL_PREFIX__, cvar)
|
#define ASMVAR(cvar) ASMVAR2(__USER_LABEL_PREFIX__, cvar)
|
||||||
#define ASMVAR2(prefix,cvar) STRING (prefix) cvar
|
#define ASMVAR2(prefix, cvar) STRING(prefix) \
|
||||||
|
cvar
|
||||||
#define STRING(x) #x
|
#define STRING(x) #x
|
||||||
#define VAR(var) ASMVAR(#var)
|
#define VAR(var) ASMVAR(#var)
|
||||||
#define REGREF1(index) ASMVAR("reg(" index ")")
|
#define REGREF1(index) ASMVAR("reg(" index ")")
|
||||||
|
@ -319,24 +312,21 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
#define edx "%%edx"
|
#define edx "%%edx"
|
||||||
#define ADD_RN_O8(d) \
|
#define ADD_RN_O8(d) \
|
||||||
asm("andl $0xFF, %%eax;" \
|
asm("andl $0xFF, %%eax;" \
|
||||||
"addl %%eax, %0;"\
|
"addl %%eax, %0;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: "=m"(reg[(d)].I));
|
: "=m"(reg[(d)].I));
|
||||||
#define CMN_RD_RS \
|
#define CMN_RD_RS \
|
||||||
asm ("add %0, %1;"\
|
asm("add %0, %1;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: \
|
: \
|
||||||
: "r" (value), "r" (reg[dest].I):"1");
|
: "r"(value), "r"(reg[dest].I) \
|
||||||
|
: "1");
|
||||||
#define ADC_RD_RS \
|
#define ADC_RD_RS \
|
||||||
asm (EMIT2(bt,KONST(0),VAR(C_FLAG)) \
|
asm(EMIT2(bt, KONST(0), VAR(C_FLAG)) "adc %1, %%ebx;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
"adc %1, %%ebx;"\
|
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
|
@ -344,383 +334,216 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
: "r"(value), "b"(reg[dest].I));
|
: "r"(value), "b"(reg[dest].I));
|
||||||
#define SUB_RN_O8(d) \
|
#define SUB_RN_O8(d) \
|
||||||
asm("andl $0xFF, %%eax;" \
|
asm("andl $0xFF, %%eax;" \
|
||||||
"subl %%eax, %0;"\
|
"subl %%eax, %0;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: "=m"(reg[(d)].I));
|
: "=m"(reg[(d)].I));
|
||||||
#define MOV_RN_O8(d) \
|
#define MOV_RN_O8(d) \
|
||||||
asm ("andl $0xFF, %%eax;"\
|
asm("andl $0xFF, %%eax;" EMIT2(movb, KONST(0), VAR(N_FLAG)) "movl %%eax, %0;" EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT2(movb,KONST(0),VAR(N_FLAG)) \
|
|
||||||
"movl %%eax, %0;"\
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
|
||||||
: "=m"(reg[(d)].I));
|
: "=m"(reg[(d)].I));
|
||||||
#define CMP_RN_O8(d) \
|
#define CMP_RN_O8(d) \
|
||||||
asm("andl $0xFF, %%eax;" \
|
asm("andl $0xFF, %%eax;" \
|
||||||
"cmpl %%eax, %0;"\
|
"cmpl %%eax, %0;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: \
|
: \
|
||||||
: "m"(reg[(d)].I));
|
: "m"(reg[(d)].I));
|
||||||
#define SBC_RD_RS \
|
#define SBC_RD_RS \
|
||||||
asm volatile (EMIT2(bt,KONST(0),VAR(C_FLAG)) \
|
asm volatile(EMIT2(bt, KONST(0), VAR(C_FLAG)) "cmc;" \
|
||||||
"cmc;"\
|
"sbb %1, %%ebx;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
"sbb %1, %%ebx;"\
|
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: "=b"(reg[dest].I) \
|
: "=b"(reg[dest].I) \
|
||||||
: "r" (value), "b" (reg[dest].I) : "cc", "memory");
|
: "r"(value), "b"(reg[dest].I) \
|
||||||
|
: "cc", "memory");
|
||||||
#define LSL_RD_RS \
|
#define LSL_RD_RS \
|
||||||
asm ("shl %%cl, %%eax;"\
|
asm("shl %%cl, %%eax;" EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
|
||||||
: "=a"(value) \
|
: "=a"(value) \
|
||||||
: "a"(reg[dest].I), "c"(value));
|
: "a"(reg[dest].I), "c"(value));
|
||||||
#define LSR_RD_RS \
|
#define LSR_RD_RS \
|
||||||
asm ("shr %%cl, %%eax;"\
|
asm("shr %%cl, %%eax;" EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
|
||||||
: "=a"(value) \
|
: "=a"(value) \
|
||||||
: "a"(reg[dest].I), "c"(value));
|
: "a"(reg[dest].I), "c"(value));
|
||||||
#define ASR_RD_RS \
|
#define ASR_RD_RS \
|
||||||
asm ("sar %%cl, %%eax;"\
|
asm("sar %%cl, %%eax;" EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
|
||||||
: "=a"(value) \
|
: "=a"(value) \
|
||||||
: "a"(reg[dest].I), "c"(value));
|
: "a"(reg[dest].I), "c"(value));
|
||||||
#define ROR_RD_RS \
|
#define ROR_RD_RS \
|
||||||
asm ("ror %%cl, %%eax;"\
|
asm("ror %%cl, %%eax;" EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
|
||||||
: "=a"(value) \
|
: "=a"(value) \
|
||||||
: "a"(reg[dest].I), "c"(value));
|
: "a"(reg[dest].I), "c"(value));
|
||||||
#define NEG_RD_RS \
|
#define NEG_RD_RS \
|
||||||
asm ("neg %%ebx;"\
|
asm("neg %%ebx;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: "=b"(reg[dest].I) \
|
: "=b"(reg[dest].I) \
|
||||||
: "b"(reg[source].I));
|
: "b"(reg[source].I));
|
||||||
#define CMP_RD_RS \
|
#define CMP_RD_RS \
|
||||||
asm ("sub %0, %1;"\
|
asm("sub %0, %1;" EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG)) \
|
EMIT1(setob, VAR(V_FLAG)) \
|
||||||
: \
|
: \
|
||||||
: "r" (value), "r" (reg[dest].I):"1");
|
: "r"(value), "r"(reg[dest].I) \
|
||||||
|
: "1");
|
||||||
#define IMM5_INSN(OP, N) \
|
#define IMM5_INSN(OP, N) \
|
||||||
asm("movl %%eax,%%ecx;" \
|
asm("movl %%eax,%%ecx;" \
|
||||||
"shrl $1,%%eax;" \
|
"shrl $1,%%eax;" \
|
||||||
"andl $7,%%ecx;" \
|
"andl $7,%%ecx;" \
|
||||||
"andl $0x1C,%%eax;" \
|
"andl $0x1C,%%eax;" EMIT2(movl, REGREF1(eax), edx) \
|
||||||
EMIT2(movl, REGREF1(eax), edx) \
|
|
||||||
OP \
|
OP \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT2(movl, edx, REGREF2(ecx, 4)) \
|
EMIT2(movl, edx, REGREF2(ecx, 4)) \
|
||||||
: : "i" (N))
|
: \
|
||||||
|
: "i"(N))
|
||||||
#define IMM5_INSN_0(OP) \
|
#define IMM5_INSN_0(OP) \
|
||||||
asm("movl %%eax,%%ecx;" \
|
asm("movl %%eax,%%ecx;" \
|
||||||
"shrl $1,%%eax;" \
|
"shrl $1,%%eax;" \
|
||||||
"andl $7,%%ecx;" \
|
"andl $7,%%ecx;" \
|
||||||
"andl $0x1C,%%eax;" \
|
"andl $0x1C,%%eax;" EMIT2(movl, REGREF1(eax), edx) \
|
||||||
EMIT2(movl, REGREF1(eax), edx) \
|
|
||||||
OP \
|
OP \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT2(movl, edx, REGREF2(ecx, 4)) \
|
EMIT2(movl, edx, REGREF2(ecx, 4)) \
|
||||||
: : )
|
: \
|
||||||
|
:)
|
||||||
#define IMM5_LSL \
|
#define IMM5_LSL \
|
||||||
"shll %0,%%edx;"\
|
"shll %0,%%edx;" EMIT1(setcb, VAR(C_FLAG))
|
||||||
EMIT1(setcb, VAR(C_FLAG))
|
|
||||||
#define IMM5_LSL_0 \
|
#define IMM5_LSL_0 \
|
||||||
"testl %%edx,%%edx;"
|
"testl %%edx,%%edx;"
|
||||||
#define IMM5_LSR \
|
#define IMM5_LSR \
|
||||||
"shrl %0,%%edx;"\
|
"shrl %0,%%edx;" EMIT1(setcb, VAR(C_FLAG))
|
||||||
EMIT1(setcb, VAR(C_FLAG))
|
|
||||||
#define IMM5_LSR_0 \
|
#define IMM5_LSR_0 \
|
||||||
"testl %%edx,%%edx;"\
|
"testl %%edx,%%edx;" EMIT1(setsb, VAR(C_FLAG)) "xorl %%edx,%%edx;"
|
||||||
EMIT1(setsb, VAR(C_FLAG)) \
|
|
||||||
"xorl %%edx,%%edx;"
|
|
||||||
#define IMM5_ASR \
|
#define IMM5_ASR \
|
||||||
"sarl %0,%%edx;"\
|
"sarl %0,%%edx;" EMIT1(setcb, VAR(C_FLAG))
|
||||||
EMIT1(setcb, VAR(C_FLAG))
|
|
||||||
#define IMM5_ASR_0 \
|
#define IMM5_ASR_0 \
|
||||||
"sarl $31,%%edx;"\
|
"sarl $31,%%edx;" EMIT1(setsb, VAR(C_FLAG))
|
||||||
EMIT1(setsb, VAR(C_FLAG))
|
|
||||||
#define THREEARG_INSN(OP, N) \
|
#define THREEARG_INSN(OP, N) \
|
||||||
asm("movl %%eax,%%edx;" \
|
asm("movl %%eax,%%edx;" \
|
||||||
"shrl $1,%%edx;" \
|
"shrl $1,%%edx;" \
|
||||||
"andl $0x1C,%%edx;" \
|
"andl $0x1C,%%edx;" \
|
||||||
"andl $7,%%eax;" \
|
"andl $7,%%eax;" EMIT2(movl, REGREF1(edx), ecx) \
|
||||||
EMIT2(movl, REGREF1(edx), ecx) \
|
|
||||||
OP(N) \
|
OP(N) \
|
||||||
EMIT1(setsb, VAR(N_FLAG)) \
|
EMIT1(setsb, VAR(N_FLAG)) \
|
||||||
EMIT1(setzb, VAR(Z_FLAG)) \
|
EMIT1(setzb, VAR(Z_FLAG)) \
|
||||||
EMIT2(movl, ecx, REGREF2(eax, 4)) \
|
EMIT2(movl, ecx, REGREF2(eax, 4)) \
|
||||||
: : )
|
: \
|
||||||
|
:)
|
||||||
#define ADD_RD_RS_RN(N) \
|
#define ADD_RD_RS_RN(N) \
|
||||||
EMIT2(add, VAR(reg) "+" #N "*4", ecx) \
|
EMIT2(add, VAR(reg) "+" #N "*4", ecx) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG))
|
EMIT1(setob, VAR(V_FLAG))
|
||||||
#define ADD_RD_RS_O3(N) \
|
#define ADD_RD_RS_O3(N) \
|
||||||
"add $"#N",%%ecx;" \
|
"add $" #N ",%%ecx;" EMIT1(setcb, VAR(C_FLAG)) \
|
||||||
EMIT1(setcb, VAR(C_FLAG)) \
|
|
||||||
EMIT1(setob, VAR(V_FLAG))
|
EMIT1(setob, VAR(V_FLAG))
|
||||||
#define ADD_RD_RS_O3_0(N) \
|
#define ADD_RD_RS_O3_0(N) \
|
||||||
EMIT2(movb, KONST(0), VAR(C_FLAG)) \
|
EMIT2(movb, KONST(0), VAR(C_FLAG)) \
|
||||||
"add $0,%%ecx;" \
|
"add $0,%%ecx;" EMIT2(movb, KONST(0), VAR(V_FLAG))
|
||||||
EMIT2(movb,KONST(0),VAR(V_FLAG))
|
|
||||||
#define SUB_RD_RS_RN(N) \
|
#define SUB_RD_RS_RN(N) \
|
||||||
EMIT2(sub, VAR(reg) "+" #N "*4", ecx) \
|
EMIT2(sub, VAR(reg) "+" #N "*4", ecx) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setob, VAR(V_FLAG))
|
EMIT1(setob, VAR(V_FLAG))
|
||||||
#define SUB_RD_RS_O3(N) \
|
#define SUB_RD_RS_O3(N) \
|
||||||
"sub $"#N",%%ecx;" \
|
"sub $" #N ",%%ecx;" EMIT1(setncb, VAR(C_FLAG)) \
|
||||||
EMIT1(setncb, VAR(C_FLAG)) \
|
|
||||||
EMIT1(setob, VAR(V_FLAG))
|
EMIT1(setob, VAR(V_FLAG))
|
||||||
#define SUB_RD_RS_O3_0(N) \
|
#define SUB_RD_RS_O3_0(N) \
|
||||||
EMIT2(movb, KONST(1), VAR(C_FLAG)) \
|
EMIT2(movb, KONST(1), VAR(C_FLAG)) \
|
||||||
"sub $0,%%ecx;" \
|
"sub $0,%%ecx;" EMIT2(movb, KONST(0), VAR(V_FLAG))
|
||||||
EMIT2(movb,KONST(0),VAR(V_FLAG))
|
|
||||||
#endif
|
#endif
|
||||||
#else // !__GNUC__
|
#else // !__GNUC__
|
||||||
#define ADD_RD_RS_RN(N) \
|
#define ADD_RD_RS_RN(N) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm add ebx, dword ptr[OFFSET reg + 4 * N] __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm add ebx, dword ptr [OFFSET reg+4*N]\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define ADD_RD_RS_O3(N) \
|
#define ADD_RD_RS_O3(N) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm add ebx, N __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm add ebx, N\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define ADD_RD_RS_O3_0 \
|
#define ADD_RD_RS_O3_0 \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm add ebx, 0 __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm mov byte ptr C_FLAG, 0 __asm mov byte ptr V_FLAG, 0 \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm add ebx, 0\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm mov byte ptr C_FLAG, 0\
|
|
||||||
__asm mov byte ptr V_FLAG, 0\
|
|
||||||
}
|
}
|
||||||
#define ADD_RN_O8(d) \
|
#define ADD_RN_O8(d) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov ebx, opcode\
|
__asm mov ebx, opcode __asm and ebx, 255 __asm add dword ptr[OFFSET reg + 4 * (d)], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm and ebx, 255\
|
|
||||||
__asm add dword ptr [OFFSET reg+4*(d)], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define CMN_RD_RS \
|
#define CMN_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dest\
|
__asm mov eax, dest __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm add ebx, value __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm add ebx, value\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define ADC_RD_RS \
|
#define ADC_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov ebx, dest\
|
__asm mov ebx, dest __asm mov ebx, dword ptr[OFFSET reg + 4 * ebx] __asm bt word ptr C_FLAG, 0 __asm adc ebx, value __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
|
|
||||||
__asm bt word ptr C_FLAG, 0\
|
|
||||||
__asm adc ebx, value\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define SUB_RD_RS_RN(N) \
|
#define SUB_RD_RS_RN(N) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm sub ebx, dword ptr[OFFSET reg + 4 * N] __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm sub ebx, dword ptr [OFFSET reg+4*N]\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define SUB_RD_RS_O3(N) \
|
#define SUB_RD_RS_O3(N) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm sub ebx, N __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm sub ebx, N\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define SUB_RD_RS_O3_0 \
|
#define SUB_RD_RS_O3_0 \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm sub ebx, 0 __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm mov byte ptr C_FLAG, 1 __asm mov byte ptr V_FLAG, 0 \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm sub ebx, 0\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm mov byte ptr C_FLAG, 1\
|
|
||||||
__asm mov byte ptr V_FLAG, 0\
|
|
||||||
}
|
}
|
||||||
#define SUB_RN_O8(d) \
|
#define SUB_RN_O8(d) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov ebx, opcode\
|
__asm mov ebx, opcode __asm and ebx, 255 __asm sub dword ptr[OFFSET reg + 4 * (d)], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm and ebx, 255\
|
|
||||||
__asm sub dword ptr [OFFSET reg + 4*(d)], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define MOV_RN_O8(d) \
|
#define MOV_RN_O8(d) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, opcode\
|
__asm mov eax, opcode __asm and eax, 255 __asm mov dword ptr[OFFSET reg + 4 * (d)], eax __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG \
|
||||||
__asm and eax, 255\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*(d)], eax\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
}
|
}
|
||||||
#define CMP_RN_O8(d) \
|
#define CMP_RN_O8(d) \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dword ptr [OFFSET reg+4*(d)]\
|
__asm mov eax, dword ptr[OFFSET reg + 4 * (d)] __asm mov ebx, opcode __asm and ebx, 255 __asm sub eax, ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, opcode\
|
|
||||||
__asm and ebx, 255\
|
|
||||||
__asm sub eax, ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define SBC_RD_RS \
|
#define SBC_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov ebx, dest\
|
__asm mov ebx, dest __asm mov ebx, dword ptr[OFFSET reg + 4 * ebx] __asm mov eax, value __asm bt word ptr C_FLAG, 0 __asm cmc __asm sbb ebx, eax __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg + 4*ebx]\
|
|
||||||
__asm mov eax, value\
|
|
||||||
__asm bt word ptr C_FLAG, 0\
|
|
||||||
__asm cmc\
|
|
||||||
__asm sbb ebx, eax\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg + 4*eax], ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define LSL_RD_RM_I5 \
|
#define LSL_RD_RM_I5 \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr shift __asm shl eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
|
|
||||||
__asm mov cl, byte ptr shift\
|
|
||||||
__asm shl eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define LSL_RD_RS \
|
#define LSL_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dest\
|
__asm mov eax, dest __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr value __asm shl eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
|
|
||||||
__asm mov cl, byte ptr value\
|
|
||||||
__asm shl eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define LSR_RD_RM_I5 \
|
#define LSR_RD_RM_I5 \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr shift __asm shr eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
|
|
||||||
__asm mov cl, byte ptr shift\
|
|
||||||
__asm shr eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define LSR_RD_RS \
|
#define LSR_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dest\
|
__asm mov eax, dest __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr value __asm shr eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
|
|
||||||
__asm mov cl, byte ptr value\
|
|
||||||
__asm shr eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define ASR_RD_RM_I5 \
|
#define ASR_RD_RM_I5 \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, source\
|
__asm mov eax, source __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr shift __asm sar eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4*eax]\
|
|
||||||
__asm mov cl, byte ptr shift\
|
|
||||||
__asm sar eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define ASR_RD_RS \
|
#define ASR_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dest\
|
__asm mov eax, dest __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr value __asm sar eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4*eax]\
|
|
||||||
__asm mov cl, byte ptr value\
|
|
||||||
__asm sar eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define ROR_RD_RS \
|
#define ROR_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dest\
|
__asm mov eax, dest __asm mov eax, dword ptr[OFFSET reg + 4 * eax] __asm mov cl, byte ptr value __asm ror eax, cl __asm mov value, eax __asm setc byte ptr C_FLAG \
|
||||||
__asm mov eax, dword ptr [OFFSET reg + 4*eax]\
|
|
||||||
__asm mov cl, byte ptr value\
|
|
||||||
__asm ror eax, cl\
|
|
||||||
__asm mov value, eax\
|
|
||||||
__asm setc byte ptr C_FLAG\
|
|
||||||
}
|
}
|
||||||
#define NEG_RD_RS \
|
#define NEG_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov ebx, source\
|
__asm mov ebx, source __asm mov ebx, dword ptr[OFFSET reg + 4 * ebx] __asm neg ebx __asm mov eax, dest __asm mov dword ptr[OFFSET reg + 4 * eax], ebx __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
|
|
||||||
__asm neg ebx\
|
|
||||||
__asm mov eax, dest\
|
|
||||||
__asm mov dword ptr [OFFSET reg+4*eax],ebx\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#define CMP_RD_RS \
|
#define CMP_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
__asm mov eax, dest\
|
__asm mov eax, dest __asm mov ebx, dword ptr[OFFSET reg + 4 * eax] __asm sub ebx, value __asm sets byte ptr N_FLAG __asm setz byte ptr Z_FLAG __asm setnc byte ptr C_FLAG __asm seto byte ptr V_FLAG \
|
||||||
__asm mov ebx, dword ptr [OFFSET reg+4*eax]\
|
|
||||||
__asm sub ebx, value\
|
|
||||||
__asm sets byte ptr N_FLAG\
|
|
||||||
__asm setz byte ptr Z_FLAG\
|
|
||||||
__asm setnc byte ptr C_FLAG\
|
|
||||||
__asm seto byte ptr V_FLAG\
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -728,25 +551,19 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
// C core
|
// C core
|
||||||
#ifndef ADDCARRY
|
#ifndef ADDCARRY
|
||||||
#define ADDCARRY(a, b, c) \
|
#define ADDCARRY(a, b, c) \
|
||||||
C_FLAG = ((NEG(a) & NEG(b)) |\
|
C_FLAG = ((NEG(a) & NEG(b)) | (NEG(a) & POS(c)) | (NEG(b) & POS(c))) ? true : false;
|
||||||
(NEG(a) & POS(c)) |\
|
|
||||||
(NEG(b) & POS(c))) ? true : false;
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef ADDOVERFLOW
|
#ifndef ADDOVERFLOW
|
||||||
#define ADDOVERFLOW(a, b, c) \
|
#define ADDOVERFLOW(a, b, c) \
|
||||||
V_FLAG = ((NEG(a) & NEG(b) & POS(c)) |\
|
V_FLAG = ((NEG(a) & NEG(b) & POS(c)) | (POS(a) & POS(b) & NEG(c))) ? true : false;
|
||||||
(POS(a) & POS(b) & NEG(c))) ? true : false;
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef SUBCARRY
|
#ifndef SUBCARRY
|
||||||
#define SUBCARRY(a, b, c) \
|
#define SUBCARRY(a, b, c) \
|
||||||
C_FLAG = ((NEG(a) & POS(b)) |\
|
C_FLAG = ((NEG(a) & POS(b)) | (NEG(a) & POS(c)) | (POS(b) & POS(c))) ? true : false;
|
||||||
(NEG(a) & POS(c)) |\
|
|
||||||
(POS(b) & POS(c))) ? true : false;
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef SUBOVERFLOW
|
#ifndef SUBOVERFLOW
|
||||||
#define SUBOVERFLOW(a, b, c) \
|
#define SUBOVERFLOW(a, b, c) \
|
||||||
V_FLAG = ((NEG(a) & POS(b) & POS(c)) |\
|
V_FLAG = ((NEG(a) & POS(b) & POS(c)) | (POS(a) & NEG(b) & NEG(c))) ? true : false;
|
||||||
(POS(a) & NEG(b) & NEG(c))) ? true : false;
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef ADD_RD_RS_RN
|
#ifndef ADD_RD_RS_RN
|
||||||
#define ADD_RD_RS_RN(N) \
|
#define ADD_RD_RS_RN(N) \
|
||||||
|
@ -936,8 +753,7 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
|
||||||
#define ROR_RD_RS \
|
#define ROR_RD_RS \
|
||||||
{ \
|
{ \
|
||||||
C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false; \
|
C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false; \
|
||||||
value = ((reg[dest].I << (32 - value)) |\
|
value = ((reg[dest].I << (32 - value)) | (reg[dest].I >> value)); \
|
||||||
(reg[dest].I >> value));\
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NEG_RD_RS
|
#ifndef NEG_RD_RS
|
||||||
|
@ -1467,7 +1283,6 @@ static INSN_REGPARM void thumb46_3(u32 opcode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// BX Rs
|
// BX Rs
|
||||||
static INSN_REGPARM void thumb47(u32 opcode)
|
static INSN_REGPARM void thumb47(u32 opcode)
|
||||||
{
|
{
|
||||||
|
@ -2337,7 +2152,6 @@ int thumbExecute()
|
||||||
|
|
||||||
(*thumbInsnTable[opcode >> 6])(opcode);
|
(*thumbInsnTable[opcode >> 6])(opcode);
|
||||||
|
|
||||||
|
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (enableRegBreak) {
|
if (enableRegBreak) {
|
||||||
if (lowRegBreakCounter[0])
|
if (lowRegBreakCounter[0])
|
||||||
|
|
434
src/gba/GBA.cpp
434
src/gba/GBA.cpp
|
@ -1,32 +1,32 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "../NLS.h"
|
||||||
|
#include "../System.h"
|
||||||
|
#include "../Util.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
#include "../common/Port.h"
|
||||||
|
#include "Cheats.h"
|
||||||
|
#include "EEprom.h"
|
||||||
|
#include "Flash.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
|
#include "GBAGfx.h"
|
||||||
|
#include "GBALink.h"
|
||||||
#include "GBAcpu.h"
|
#include "GBAcpu.h"
|
||||||
#include "GBAinline.h"
|
#include "GBAinline.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "GBAGfx.h"
|
|
||||||
#include "EEprom.h"
|
|
||||||
#include "Flash.h"
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "Sram.h"
|
#include "Sram.h"
|
||||||
#include "bios.h"
|
|
||||||
#include "Cheats.h"
|
|
||||||
#include "../NLS.h"
|
|
||||||
#include "elf.h"
|
|
||||||
#include "../Util.h"
|
|
||||||
#include "../common/Port.h"
|
|
||||||
#include "../common/ConfigManager.h"
|
|
||||||
#include "../System.h"
|
|
||||||
#include "agbprint.h"
|
#include "agbprint.h"
|
||||||
|
#include "bios.h"
|
||||||
|
#include "elf.h"
|
||||||
#include "ereader.h"
|
#include "ereader.h"
|
||||||
#include "GBALink.h"
|
|
||||||
|
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
#include "prof/prof.h"
|
#include "prof/prof.h"
|
||||||
|
@ -143,18 +143,13 @@ const u8 gamepakWaitState[4] = { 4, 3, 2, 8 };
|
||||||
const u8 gamepakWaitState0[2] = { 2, 1 };
|
const u8 gamepakWaitState0[2] = { 2, 1 };
|
||||||
const u8 gamepakWaitState1[2] = { 4, 1 };
|
const u8 gamepakWaitState1[2] = { 4, 1 };
|
||||||
const u8 gamepakWaitState2[2] = { 8, 1 };
|
const u8 gamepakWaitState2[2] = { 8, 1 };
|
||||||
const bool isInRom [16]=
|
const bool isInRom[16] = { false, false, false, false, false, false, false, false,
|
||||||
{ false, false, false, false, false, false, false, false,
|
|
||||||
true, true, true, true, true, true, false, false };
|
true, true, true, true, true, true, false, false };
|
||||||
|
|
||||||
u8 memoryWait[16] =
|
u8 memoryWait[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0 };
|
||||||
{ 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 memoryWait32[16] =
|
u8 memoryWaitSeq[16] = { 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 4, 4, 8, 8, 4, 0 };
|
||||||
{ 0, 0, 5, 0, 0, 1, 1, 0, 7, 7, 9, 9, 13, 13, 4, 0 };
|
u8 memoryWaitSeq32[16] = { 0, 0, 5, 0, 0, 1, 1, 0, 5, 5, 9, 9, 17, 17, 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 };
|
|
||||||
|
|
||||||
// The videoMemoryWait constants are used to add some waitstates
|
// The videoMemoryWait constants are used to add some waitstates
|
||||||
// if the opcode access video memory data outside of vblank/hblank
|
// if the opcode access video memory data outside of vblank/hblank
|
||||||
|
@ -163,7 +158,6 @@ u8 memoryWaitSeq32[16] =
|
||||||
//const u8 videoMemoryWait[16] =
|
//const u8 videoMemoryWait[16] =
|
||||||
// {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
// {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
|
||||||
u8 biosProtected[4];
|
u8 biosProtected[4];
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
@ -482,7 +476,6 @@ void cpuEnableProfiling(int hz)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
inline int CPUUpdateTicks()
|
inline int CPUUpdateTicks()
|
||||||
{
|
{
|
||||||
int cpuLoopTicks = lcdTicks;
|
int cpuLoopTicks = lcdTicks;
|
||||||
|
@ -566,7 +559,7 @@ extern u32 line3[240];
|
||||||
for (int i = 0; i < 240; i++) { \
|
for (int i = 0; i < 240; i++) { \
|
||||||
*array++ = 0x80000000; \
|
*array++ = 0x80000000; \
|
||||||
} \
|
} \
|
||||||
}\
|
}
|
||||||
|
|
||||||
void CPUUpdateRenderBuffers(bool force)
|
void CPUUpdateRenderBuffers(bool force)
|
||||||
{
|
{
|
||||||
|
@ -683,7 +676,6 @@ bool CPUWriteState(const char *file)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CPUWriteMemState(char* memory, int available, long& reserved)
|
bool CPUWriteMemState(char* memory, int available, long& reserved)
|
||||||
{
|
{
|
||||||
gzFile gzFile = utilMemGzOpen(memory, available, "w");
|
gzFile gzFile = utilMemGzOpen(memory, available, "w");
|
||||||
|
@ -705,7 +697,6 @@ bool CPUWriteMemState(char *memory, int available, long& reserved)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
bool CPUReadState(const u8* data, unsigned size)
|
bool CPUReadState(const u8* data, unsigned size)
|
||||||
{
|
{
|
||||||
|
@ -731,8 +722,7 @@ bool CPUReadState(const u8* data, unsigned size)
|
||||||
IRQTicks = utilReadIntMem(data);
|
IRQTicks = utilReadIntMem(data);
|
||||||
if (IRQTicks > 0)
|
if (IRQTicks > 0)
|
||||||
intState = true;
|
intState = true;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
intState = false;
|
intState = false;
|
||||||
IRQTicks = 0;
|
IRQTicks = 0;
|
||||||
}
|
}
|
||||||
|
@ -854,18 +844,14 @@ static bool CPUReadState(gzFile gzFile)
|
||||||
else
|
else
|
||||||
stopState = utilReadInt(gzFile) ? true : false;
|
stopState = utilReadInt(gzFile) ? true : false;
|
||||||
|
|
||||||
if(version < SAVE_GAME_VERSION_4)
|
if (version < SAVE_GAME_VERSION_4) {
|
||||||
{
|
|
||||||
IRQTicks = 0;
|
IRQTicks = 0;
|
||||||
intState = false;
|
intState = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IRQTicks = utilReadInt(gzFile);
|
IRQTicks = utilReadInt(gzFile);
|
||||||
if (IRQTicks > 0)
|
if (IRQTicks > 0)
|
||||||
intState = true;
|
intState = true;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
intState = false;
|
intState = false;
|
||||||
IRQTicks = 0;
|
IRQTicks = 0;
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1006,8 @@ bool CPUWriteBatteryFile(const char *fileName)
|
||||||
if (gbaSaveType == 0) {
|
if (gbaSaveType == 0) {
|
||||||
if (eepromInUse)
|
if (eepromInUse)
|
||||||
gbaSaveType = 3;
|
gbaSaveType = 3;
|
||||||
else switch(saveType) {
|
else
|
||||||
|
switch (saveType) {
|
||||||
case 1:
|
case 1:
|
||||||
gbaSaveType = 1;
|
gbaSaveType = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -1134,7 +1121,8 @@ bool CPUReadGSASPSnapshot(const char *fileName)
|
||||||
const size_t namepos = 0x0c, namesz = 12;
|
const size_t namepos = 0x0c, namesz = 12;
|
||||||
const size_t footerpos = 0x42c, footersz = 4;
|
const size_t footerpos = 0x42c, footersz = 4;
|
||||||
|
|
||||||
char footer[footersz+1], romname[namesz+1], savename[namesz+1];;
|
char footer[footersz + 1], romname[namesz + 1], savename[namesz + 1];
|
||||||
|
;
|
||||||
FILE* file = fopen(fileName, "rb");
|
FILE* file = fopen(fileName, "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
@ -1183,7 +1171,6 @@ bool CPUReadGSASPSnapshot(const char *fileName)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CPUWriteGSASnapshot(const char* fileName,
|
bool CPUWriteGSASnapshot(const char* fileName,
|
||||||
const char* title,
|
const char* title,
|
||||||
const char* desc,
|
const char* desc,
|
||||||
|
@ -1506,8 +1493,7 @@ void SetMapMasks()
|
||||||
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
|
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
|
||||||
"TRACE");
|
"TRACE");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
map[i].trace = NULL;
|
map[i].trace = NULL;
|
||||||
map[i].breakPoints = NULL; //\\
|
map[i].breakPoints = NULL; //\\
|
||||||
|
|
||||||
|
@ -1563,8 +1549,7 @@ int CPULoadRom(const char *szFile)
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif //NO_DEBUGGER
|
#endif //NO_DEBUGGER
|
||||||
if(szFile!=NULL)
|
if (szFile != NULL) {
|
||||||
{
|
|
||||||
if (!utilLoad(szFile,
|
if (!utilLoad(szFile,
|
||||||
utilIsGBAImage,
|
utilIsGBAImage,
|
||||||
whereToLoad,
|
whereToLoad,
|
||||||
|
@ -1758,12 +1743,10 @@ void doMirroring (bool b)
|
||||||
romSizeRounded++;
|
romSizeRounded++;
|
||||||
u32 mirroredRomSize = (((romSizeRounded) >> 20) & 0x3F) << 20;
|
u32 mirroredRomSize = (((romSizeRounded) >> 20) & 0x3F) << 20;
|
||||||
u32 mirroredRomAddress = mirroredRomSize;
|
u32 mirroredRomAddress = mirroredRomSize;
|
||||||
if ((mirroredRomSize <=0x800000) && (b))
|
if ((mirroredRomSize <= 0x800000) && (b)) {
|
||||||
{
|
|
||||||
if (mirroredRomSize == 0)
|
if (mirroredRomSize == 0)
|
||||||
mirroredRomSize = 0x100000;
|
mirroredRomSize = 0x100000;
|
||||||
while (mirroredRomAddress<0x01000000)
|
while (mirroredRomAddress < 0x01000000) {
|
||||||
{
|
|
||||||
memcpy((u16*)(rom + mirroredRomAddress), (u16*)(rom), mirroredRomSize);
|
memcpy((u16*)(rom + mirroredRomAddress), (u16*)(rom), mirroredRomSize);
|
||||||
mirroredRomAddress += mirroredRomSize;
|
mirroredRomAddress += mirroredRomSize;
|
||||||
}
|
}
|
||||||
|
@ -1794,8 +1777,7 @@ void CPUUpdateRender()
|
||||||
{
|
{
|
||||||
switch (DISPCNT & 7) {
|
switch (DISPCNT & 7) {
|
||||||
case 0:
|
case 0:
|
||||||
if((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
|
if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) || cpuDisableSfx)
|
||||||
cpuDisableSfx)
|
|
||||||
renderLine = mode0RenderLine;
|
renderLine = mode0RenderLine;
|
||||||
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
||||||
renderLine = mode0RenderLineNoWindow;
|
renderLine = mode0RenderLineNoWindow;
|
||||||
|
@ -1803,8 +1785,7 @@ void CPUUpdateRender()
|
||||||
renderLine = mode0RenderLineAll;
|
renderLine = mode0RenderLineAll;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
|
if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) || cpuDisableSfx)
|
||||||
cpuDisableSfx)
|
|
||||||
renderLine = mode1RenderLine;
|
renderLine = mode1RenderLine;
|
||||||
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
||||||
renderLine = mode1RenderLineNoWindow;
|
renderLine = mode1RenderLineNoWindow;
|
||||||
|
@ -1812,8 +1793,7 @@ void CPUUpdateRender()
|
||||||
renderLine = mode1RenderLineAll;
|
renderLine = mode1RenderLineAll;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
|
if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) || cpuDisableSfx)
|
||||||
cpuDisableSfx)
|
|
||||||
renderLine = mode2RenderLine;
|
renderLine = mode2RenderLine;
|
||||||
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
||||||
renderLine = mode2RenderLineNoWindow;
|
renderLine = mode2RenderLineNoWindow;
|
||||||
|
@ -1821,8 +1801,7 @@ void CPUUpdateRender()
|
||||||
renderLine = mode2RenderLineAll;
|
renderLine = mode2RenderLineAll;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
|
if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) || cpuDisableSfx)
|
||||||
cpuDisableSfx)
|
|
||||||
renderLine = mode3RenderLine;
|
renderLine = mode3RenderLine;
|
||||||
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
||||||
renderLine = mode3RenderLineNoWindow;
|
renderLine = mode3RenderLineNoWindow;
|
||||||
|
@ -1830,8 +1809,7 @@ void CPUUpdateRender()
|
||||||
renderLine = mode3RenderLineAll;
|
renderLine = mode3RenderLineAll;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
|
if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) || cpuDisableSfx)
|
||||||
cpuDisableSfx)
|
|
||||||
renderLine = mode4RenderLine;
|
renderLine = mode4RenderLine;
|
||||||
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
||||||
renderLine = mode4RenderLineNoWindow;
|
renderLine = mode4RenderLineNoWindow;
|
||||||
|
@ -1839,8 +1817,7 @@ void CPUUpdateRender()
|
||||||
renderLine = mode4RenderLineAll;
|
renderLine = mode4RenderLineAll;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if((!fxOn && !windowOn && !(layerEnable & 0x8000)) ||
|
if ((!fxOn && !windowOn && !(layerEnable & 0x8000)) || cpuDisableSfx)
|
||||||
cpuDisableSfx)
|
|
||||||
renderLine = mode5RenderLine;
|
renderLine = mode5RenderLine;
|
||||||
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
else if (fxOn && !windowOn && !(layerEnable & 0x8000))
|
||||||
renderLine = mode5RenderLineNoWindow;
|
renderLine = mode5RenderLineNoWindow;
|
||||||
|
@ -2057,7 +2034,8 @@ void CPUSoftwareInterrupt()
|
||||||
void CPUSoftwareInterrupt(int comment)
|
void CPUSoftwareInterrupt(int comment)
|
||||||
{
|
{
|
||||||
static bool disableMessage = false;
|
static bool disableMessage = false;
|
||||||
if(armState) comment >>= 16;
|
if (armState)
|
||||||
|
comment >>= 16;
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (comment == 0xff) {
|
if (comment == 0xff) {
|
||||||
dbgOutput(NULL, reg[0].I);
|
dbgOutput(NULL, reg[0].I);
|
||||||
|
@ -2105,13 +2083,10 @@ void CPUSoftwareInterrupt(int comment)
|
||||||
VCOUNT);
|
VCOUNT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((comment & 0xF8) != 0xE0)
|
if ((comment & 0xF8) != 0xE0) {
|
||||||
{
|
|
||||||
CPUSoftwareInterrupt();
|
CPUSoftwareInterrupt();
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CheckEReaderRegion())
|
if (CheckEReaderRegion())
|
||||||
BIOS_EReader_ScanCard(comment);
|
BIOS_EReader_ScanCard(comment);
|
||||||
else
|
else
|
||||||
|
@ -2190,46 +2165,31 @@ void CPUSoftwareInterrupt(int comment)
|
||||||
case 0x0A:
|
case 0x0A:
|
||||||
BIOS_ArcTan2();
|
BIOS_ArcTan2();
|
||||||
break;
|
break;
|
||||||
case 0x0B:
|
case 0x0B: {
|
||||||
{
|
|
||||||
int len = (reg[2].I & 0x1FFFFF) >> 1;
|
int len = (reg[2].I & 0x1FFFFF) >> 1;
|
||||||
if (!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + len) & 0xe000000) == 0)) {
|
||||||
((reg[0].I + len) & 0xe000000) == 0))
|
if ((reg[2].I >> 24) & 1) {
|
||||||
{
|
|
||||||
if ((reg[2].I >> 24) & 1)
|
|
||||||
{
|
|
||||||
if ((reg[2].I >> 26) & 1)
|
if ((reg[2].I >> 26) & 1)
|
||||||
SWITicks = (7 + memoryWait32[(reg[1].I >> 24) & 0xF]) * (len >> 1);
|
SWITicks = (7 + memoryWait32[(reg[1].I >> 24) & 0xF]) * (len >> 1);
|
||||||
else
|
else
|
||||||
SWITicks = (8 + memoryWait[(reg[1].I >> 24) & 0xF]) * (len);
|
SWITicks = (8 + memoryWait[(reg[1].I >> 24) & 0xF]) * (len);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((reg[2].I >> 26) & 1)
|
if ((reg[2].I >> 26) & 1)
|
||||||
SWITicks = (10 + memoryWait32[(reg[0].I>>24) & 0xF] +
|
SWITicks = (10 + memoryWait32[(reg[0].I >> 24) & 0xF] + memoryWait32[(reg[1].I >> 24) & 0xF]) * (len >> 1);
|
||||||
memoryWait32[(reg[1].I>>24) & 0xF]) * (len>>1);
|
|
||||||
else
|
else
|
||||||
SWITicks = (11 + memoryWait[(reg[0].I>>24) & 0xF] +
|
SWITicks = (11 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
||||||
memoryWait[(reg[1].I>>24) & 0xF]) * len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIOS_CpuSet();
|
BIOS_CpuSet();
|
||||||
break;
|
break;
|
||||||
case 0x0C:
|
case 0x0C: {
|
||||||
{
|
|
||||||
int len = (reg[2].I & 0x1FFFFF) >> 5;
|
int len = (reg[2].I & 0x1FFFFF) >> 5;
|
||||||
if (!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + len) & 0xe000000) == 0)) {
|
||||||
((reg[0].I + len) & 0xe000000) == 0))
|
|
||||||
{
|
|
||||||
if ((reg[2].I >> 24) & 1)
|
if ((reg[2].I >> 24) & 1)
|
||||||
SWITicks = (6 + memoryWait32[(reg[1].I>>24) & 0xF] +
|
SWITicks = (6 + memoryWait32[(reg[1].I >> 24) & 0xF] + 7 * (memoryWaitSeq32[(reg[1].I >> 24) & 0xF] + 1)) * len;
|
||||||
7 * (memoryWaitSeq32[(reg[1].I>>24) & 0xF] + 1)) * len;
|
|
||||||
else
|
else
|
||||||
SWITicks = (9 + memoryWait32[(reg[0].I>>24) & 0xF] +
|
SWITicks = (9 + memoryWait32[(reg[0].I >> 24) & 0xF] + memoryWait32[(reg[1].I >> 24) & 0xF] + 7 * (memoryWaitSeq32[(reg[0].I >> 24) & 0xF] + memoryWaitSeq32[(reg[1].I >> 24) & 0xF] + 2)) * len;
|
||||||
memoryWait32[(reg[1].I>>24) & 0xF] +
|
|
||||||
7 * (memoryWaitSeq32[(reg[0].I>>24) & 0xF] +
|
|
||||||
memoryWaitSeq32[(reg[1].I>>24) & 0xF] + 2)) * len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIOS_CpuFastSet();
|
BIOS_CpuFastSet();
|
||||||
|
@ -2243,89 +2203,66 @@ void CPUSoftwareInterrupt(int comment)
|
||||||
case 0x0F:
|
case 0x0F:
|
||||||
BIOS_ObjAffineSet();
|
BIOS_ObjAffineSet();
|
||||||
break;
|
break;
|
||||||
case 0x10:
|
case 0x10: {
|
||||||
{
|
|
||||||
int len = CPUReadHalfWord(reg[2].I);
|
int len = CPUReadHalfWord(reg[2].I);
|
||||||
if (!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + len) & 0xe000000) == 0))
|
||||||
((reg[0].I + len) & 0xe000000) == 0))
|
|
||||||
SWITicks = (32 + memoryWait[(reg[0].I >> 24) & 0xF]) * len;
|
SWITicks = (32 + memoryWait[(reg[0].I >> 24) & 0xF]) * len;
|
||||||
}
|
}
|
||||||
BIOS_BitUnPack();
|
BIOS_BitUnPack();
|
||||||
break;
|
break;
|
||||||
case 0x11:
|
case 0x11: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
||||||
((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
|
||||||
SWITicks = (9 + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
SWITicks = (9 + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
||||||
}
|
}
|
||||||
BIOS_LZ77UnCompWram();
|
BIOS_LZ77UnCompWram();
|
||||||
break;
|
break;
|
||||||
case 0x12:
|
case 0x12: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
||||||
((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
|
||||||
SWITicks = (19 + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
SWITicks = (19 + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
||||||
}
|
}
|
||||||
BIOS_LZ77UnCompVram();
|
BIOS_LZ77UnCompVram();
|
||||||
break;
|
break;
|
||||||
case 0x13:
|
case 0x13: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
||||||
((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
|
||||||
SWITicks = (29 + (memoryWait[(reg[0].I >> 24) & 0xF] << 1)) * len;
|
SWITicks = (29 + (memoryWait[(reg[0].I >> 24) & 0xF] << 1)) * len;
|
||||||
}
|
}
|
||||||
BIOS_HuffUnComp();
|
BIOS_HuffUnComp();
|
||||||
break;
|
break;
|
||||||
case 0x14:
|
case 0x14: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
||||||
((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
SWITicks = (11 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
||||||
SWITicks = (11 + memoryWait[(reg[0].I>>24) & 0xF] +
|
|
||||||
memoryWait[(reg[1].I>>24) & 0xF]) * len;
|
|
||||||
}
|
}
|
||||||
BIOS_RLUnCompWram();
|
BIOS_RLUnCompWram();
|
||||||
break;
|
break;
|
||||||
case 0x15:
|
case 0x15: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 9;
|
u32 len = CPUReadMemory(reg[0].I) >> 9;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 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;
|
||||||
SWITicks = (34 + (memoryWait[(reg[0].I>>24) & 0xF] << 1) +
|
|
||||||
memoryWait[(reg[1].I>>24) & 0xF]) * len;
|
|
||||||
}
|
}
|
||||||
BIOS_RLUnCompVram();
|
BIOS_RLUnCompVram();
|
||||||
break;
|
break;
|
||||||
case 0x16:
|
case 0x16: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
u32 len = CPUReadMemory(reg[0].I) >> 8;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
||||||
((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
SWITicks = (13 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
||||||
SWITicks = (13 + memoryWait[(reg[0].I>>24) & 0xF] +
|
|
||||||
memoryWait[(reg[1].I>>24) & 0xF]) * len;
|
|
||||||
}
|
}
|
||||||
BIOS_Diff8bitUnFilterWram();
|
BIOS_Diff8bitUnFilterWram();
|
||||||
break;
|
break;
|
||||||
case 0x17:
|
case 0x17: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 9;
|
u32 len = CPUReadMemory(reg[0].I) >> 9;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 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;
|
||||||
SWITicks = (39 + (memoryWait[(reg[0].I>>24) & 0xF]<<1) +
|
|
||||||
memoryWait[(reg[1].I>>24) & 0xF]) * len;
|
|
||||||
}
|
}
|
||||||
BIOS_Diff8bitUnFilterVram();
|
BIOS_Diff8bitUnFilterVram();
|
||||||
break;
|
break;
|
||||||
case 0x18:
|
case 0x18: {
|
||||||
{
|
|
||||||
u32 len = CPUReadMemory(reg[0].I) >> 9;
|
u32 len = CPUReadMemory(reg[0].I) >> 9;
|
||||||
if(!(((reg[0].I & 0xe000000) == 0) ||
|
if (!(((reg[0].I & 0xe000000) == 0) || ((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
||||||
((reg[0].I + (len & 0x1fffff)) & 0xe000000) == 0))
|
SWITicks = (13 + memoryWait[(reg[0].I >> 24) & 0xF] + memoryWait[(reg[1].I >> 24) & 0xF]) * len;
|
||||||
SWITicks = (13 + memoryWait[(reg[0].I>>24) & 0xF] +
|
|
||||||
memoryWait[(reg[1].I>>24) & 0xF]) * len;
|
|
||||||
}
|
}
|
||||||
BIOS_Diff16bitUnFilter();
|
BIOS_Diff16bitUnFilter();
|
||||||
break;
|
break;
|
||||||
|
@ -2418,13 +2355,11 @@ void CPUCompareVCOUNT()
|
||||||
DISPSTAT &= 0xFFFB;
|
DISPSTAT &= 0xFFFB;
|
||||||
UPDATE_REG(0x4, DISPSTAT);
|
UPDATE_REG(0x4, DISPSTAT);
|
||||||
}
|
}
|
||||||
if (layerEnableDelay>0)
|
if (layerEnableDelay > 0) {
|
||||||
{
|
|
||||||
layerEnableDelay--;
|
layerEnableDelay--;
|
||||||
if (layerEnableDelay == 1)
|
if (layerEnableDelay == 1)
|
||||||
layerEnable = layerSettings & DISPCNT;
|
layerEnable = layerSettings & DISPCNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doDMA(u32& s, u32& d, u32 si, u32 di, u32 c, int transfer32)
|
void doDMA(u32& s, u32& d, u32 si, u32 di, u32 c, int transfer32)
|
||||||
|
@ -2492,15 +2427,11 @@ void doDMA(u32 &s, u32 &d, u32 si, u32 di, u32 c, int transfer32)
|
||||||
if (transfer32) {
|
if (transfer32) {
|
||||||
sw = 1 + memoryWaitSeq32[sm & 15];
|
sw = 1 + memoryWaitSeq32[sm & 15];
|
||||||
dw = 1 + memoryWaitSeq32[dm & 15];
|
dw = 1 + memoryWaitSeq32[dm & 15];
|
||||||
totalTicks = (sw+dw)*(sc-1) + 6 + memoryWait32[sm & 15] +
|
totalTicks = (sw + dw) * (sc - 1) + 6 + memoryWait32[sm & 15] + memoryWaitSeq32[dm & 15];
|
||||||
memoryWaitSeq32[dm & 15];
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sw = 1 + memoryWaitSeq[sm & 15];
|
sw = 1 + memoryWaitSeq[sm & 15];
|
||||||
dw = 1 + memoryWaitSeq[dm & 15];
|
dw = 1 + memoryWaitSeq[dm & 15];
|
||||||
totalTicks = (sw+dw)*(sc-1) + 6 + memoryWait[sm & 15] +
|
totalTicks = (sw + dw) * (sc - 1) + 6 + memoryWait[sm & 15] + memoryWaitSeq[dm & 15];
|
||||||
memoryWaitSeq[dm & 15];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuDmaTicksToUpdate += totalTicks;
|
cpuDmaTicksToUpdate += totalTicks;
|
||||||
|
@ -2761,10 +2692,8 @@ void CPUCheckDMA(int reason, int dmamask)
|
||||||
|
|
||||||
void CPUUpdateRegister(u32 address, u16 value)
|
void CPUUpdateRegister(u32 address, u16 value)
|
||||||
{
|
{
|
||||||
switch(address)
|
switch (address) {
|
||||||
{
|
case 0x00: { // we need to place the following code in { } because we declare & initialize variables in a case statement
|
||||||
case 0x00:
|
|
||||||
{ // we need to place the following code in { } because we declare & initialize variables in a case statement
|
|
||||||
if ((value & 7) > 5) {
|
if ((value & 7) > 5) {
|
||||||
// display modes above 0-5 are prohibited
|
// display modes above 0-5 are prohibited
|
||||||
DISPCNT = (value & 7);
|
DISPCNT = (value & 7);
|
||||||
|
@ -3025,8 +2954,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
DM0CNT_L = value & 0x3FFF;
|
DM0CNT_L = value & 0x3FFF;
|
||||||
UPDATE_REG(0xB8, 0);
|
UPDATE_REG(0xB8, 0);
|
||||||
break;
|
break;
|
||||||
case 0xBA:
|
case 0xBA: {
|
||||||
{
|
|
||||||
bool start = ((DM0CNT_H ^ value) & 0x8000) ? true : false;
|
bool start = ((DM0CNT_H ^ value) & 0x8000) ? true : false;
|
||||||
value &= 0xF7E0;
|
value &= 0xF7E0;
|
||||||
|
|
||||||
|
@ -3038,8 +2966,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
dma0Dest = DM0DAD_L | (DM0DAD_H << 16);
|
dma0Dest = DM0DAD_L | (DM0DAD_H << 16);
|
||||||
CPUCheckDMA(0, 1);
|
CPUCheckDMA(0, 1);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 0xBC:
|
case 0xBC:
|
||||||
DM1SAD_L = value;
|
DM1SAD_L = value;
|
||||||
UPDATE_REG(0xBC, DM1SAD_L);
|
UPDATE_REG(0xBC, DM1SAD_L);
|
||||||
|
@ -3060,8 +2987,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
DM1CNT_L = value & 0x3FFF;
|
DM1CNT_L = value & 0x3FFF;
|
||||||
UPDATE_REG(0xC4, 0);
|
UPDATE_REG(0xC4, 0);
|
||||||
break;
|
break;
|
||||||
case 0xC6:
|
case 0xC6: {
|
||||||
{
|
|
||||||
bool start = ((DM1CNT_H ^ value) & 0x8000) ? true : false;
|
bool start = ((DM1CNT_H ^ value) & 0x8000) ? true : false;
|
||||||
value &= 0xF7E0;
|
value &= 0xF7E0;
|
||||||
|
|
||||||
|
@ -3073,8 +2999,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
dma1Dest = DM1DAD_L | (DM1DAD_H << 16);
|
dma1Dest = DM1DAD_L | (DM1DAD_H << 16);
|
||||||
CPUCheckDMA(0, 2);
|
CPUCheckDMA(0, 2);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 0xC8:
|
case 0xC8:
|
||||||
DM2SAD_L = value;
|
DM2SAD_L = value;
|
||||||
UPDATE_REG(0xC8, DM2SAD_L);
|
UPDATE_REG(0xC8, DM2SAD_L);
|
||||||
|
@ -3095,8 +3020,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
DM2CNT_L = value & 0x3FFF;
|
DM2CNT_L = value & 0x3FFF;
|
||||||
UPDATE_REG(0xD0, 0);
|
UPDATE_REG(0xD0, 0);
|
||||||
break;
|
break;
|
||||||
case 0xD2:
|
case 0xD2: {
|
||||||
{
|
|
||||||
bool start = ((DM2CNT_H ^ value) & 0x8000) ? true : false;
|
bool start = ((DM2CNT_H ^ value) & 0x8000) ? true : false;
|
||||||
|
|
||||||
value &= 0xF7E0;
|
value &= 0xF7E0;
|
||||||
|
@ -3110,8 +3034,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
|
|
||||||
CPUCheckDMA(0, 4);
|
CPUCheckDMA(0, 4);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 0xD4:
|
case 0xD4:
|
||||||
DM3SAD_L = value;
|
DM3SAD_L = value;
|
||||||
UPDATE_REG(0xD4, DM3SAD_L);
|
UPDATE_REG(0xD4, DM3SAD_L);
|
||||||
|
@ -3132,8 +3055,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
DM3CNT_L = value;
|
DM3CNT_L = value;
|
||||||
UPDATE_REG(0xDC, 0);
|
UPDATE_REG(0xDC, 0);
|
||||||
break;
|
break;
|
||||||
case 0xDE:
|
case 0xDE: {
|
||||||
{
|
|
||||||
bool start = ((DM3CNT_H ^ value) & 0x8000) ? true : false;
|
bool start = ((DM3CNT_H ^ value) & 0x8000) ? true : false;
|
||||||
|
|
||||||
value &= 0xFFE0;
|
value &= 0xFFE0;
|
||||||
|
@ -3146,8 +3068,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
dma3Dest = DM3DAD_L | (DM3DAD_H << 16);
|
dma3Dest = DM3DAD_L | (DM3DAD_H << 16);
|
||||||
CPUCheckDMA(0, 8);
|
CPUCheckDMA(0, 8);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 0x100:
|
case 0x100:
|
||||||
timer0Reload = value;
|
timer0Reload = value;
|
||||||
interp_rate();
|
interp_rate();
|
||||||
|
@ -3183,7 +3104,6 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
cpuNextEvent = cpuTotalTicks;
|
cpuNextEvent = cpuTotalTicks;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_LINK
|
#ifndef NO_LINK
|
||||||
case COMM_SIOCNT:
|
case COMM_SIOCNT:
|
||||||
StartLink(value);
|
StartLink(value);
|
||||||
|
@ -3208,18 +3128,20 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
StartGPLink(value);
|
StartGPLink(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMM_JOYCNT:
|
case COMM_JOYCNT: {
|
||||||
{
|
|
||||||
u16 cur = READ16LE(&ioMem[COMM_JOYCNT]);
|
u16 cur = READ16LE(&ioMem[COMM_JOYCNT]);
|
||||||
|
|
||||||
if (value & JOYCNT_RESET) cur &= ~JOYCNT_RESET;
|
if (value & JOYCNT_RESET)
|
||||||
if (value & JOYCNT_RECV_COMPLETE) cur &= ~JOYCNT_RECV_COMPLETE;
|
cur &= ~JOYCNT_RESET;
|
||||||
if (value & JOYCNT_SEND_COMPLETE) cur &= ~JOYCNT_SEND_COMPLETE;
|
if (value & JOYCNT_RECV_COMPLETE)
|
||||||
if (value & JOYCNT_INT_ENABLE) cur |= JOYCNT_INT_ENABLE;
|
cur &= ~JOYCNT_RECV_COMPLETE;
|
||||||
|
if (value & JOYCNT_SEND_COMPLETE)
|
||||||
|
cur &= ~JOYCNT_SEND_COMPLETE;
|
||||||
|
if (value & JOYCNT_INT_ENABLE)
|
||||||
|
cur |= JOYCNT_INT_ENABLE;
|
||||||
|
|
||||||
UPDATE_REG(COMM_JOYCNT, cur);
|
UPDATE_REG(COMM_JOYCNT, cur);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
case COMM_JOY_RECV_L:
|
case COMM_JOY_RECV_L:
|
||||||
UPDATE_REG(COMM_JOY_RECV_L, value);
|
UPDATE_REG(COMM_JOY_RECV_L, value);
|
||||||
|
@ -3252,22 +3174,18 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
IF ^= (value & IF);
|
IF ^= (value & IF);
|
||||||
UPDATE_REG(0x202, IF);
|
UPDATE_REG(0x202, IF);
|
||||||
break;
|
break;
|
||||||
case 0x204:
|
case 0x204: {
|
||||||
{
|
|
||||||
memoryWait[0x0e] = memoryWaitSeq[0x0e] = gamepakRamWaitState[value & 3];
|
memoryWait[0x0e] = memoryWaitSeq[0x0e] = gamepakRamWaitState[value & 3];
|
||||||
|
|
||||||
if (!speedHack) {
|
if (!speedHack) {
|
||||||
memoryWait[0x08] = memoryWait[0x09] = gamepakWaitState[(value >> 2) & 3];
|
memoryWait[0x08] = memoryWait[0x09] = gamepakWaitState[(value >> 2) & 3];
|
||||||
memoryWaitSeq[0x08] = memoryWaitSeq[0x09] =
|
memoryWaitSeq[0x08] = memoryWaitSeq[0x09] = gamepakWaitState0[(value >> 4) & 1];
|
||||||
gamepakWaitState0[(value >> 4) & 1];
|
|
||||||
|
|
||||||
memoryWait[0x0a] = memoryWait[0x0b] = gamepakWaitState[(value >> 5) & 3];
|
memoryWait[0x0a] = memoryWait[0x0b] = gamepakWaitState[(value >> 5) & 3];
|
||||||
memoryWaitSeq[0x0a] = memoryWaitSeq[0x0b] =
|
memoryWaitSeq[0x0a] = memoryWaitSeq[0x0b] = gamepakWaitState1[(value >> 7) & 1];
|
||||||
gamepakWaitState1[(value >> 7) & 1];
|
|
||||||
|
|
||||||
memoryWait[0x0c] = memoryWait[0x0d] = gamepakWaitState[(value >> 8) & 3];
|
memoryWait[0x0c] = memoryWait[0x0d] = gamepakWaitState[(value >> 8) & 3];
|
||||||
memoryWaitSeq[0x0c] = memoryWaitSeq[0x0d] =
|
memoryWaitSeq[0x0c] = memoryWaitSeq[0x0d] = gamepakWaitState2[(value >> 10) & 1];
|
||||||
gamepakWaitState2[(value >> 10) & 1];
|
|
||||||
} else {
|
} else {
|
||||||
memoryWait[0x08] = memoryWait[0x09] = 3;
|
memoryWait[0x08] = memoryWait[0x09] = 3;
|
||||||
memoryWaitSeq[0x08] = memoryWaitSeq[0x09] = 1;
|
memoryWaitSeq[0x08] = memoryWaitSeq[0x09] = 1;
|
||||||
|
@ -3295,8 +3213,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
}
|
}
|
||||||
UPDATE_REG(0x204, value & 0x7FFF);
|
UPDATE_REG(0x204, value & 0x7FFF);
|
||||||
|
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 0x208:
|
case 0x208:
|
||||||
IME = value & 1;
|
IME = value & 1;
|
||||||
UPDATE_REG(0x208, IME);
|
UPDATE_REG(0x208, IME);
|
||||||
|
@ -3316,8 +3233,7 @@ void CPUUpdateRegister(u32 address, u16 value)
|
||||||
|
|
||||||
void applyTimer()
|
void applyTimer()
|
||||||
{
|
{
|
||||||
if (timerOnOffDelay & 1)
|
if (timerOnOffDelay & 1) {
|
||||||
{
|
|
||||||
timer0ClockReload = TIMER_TICKS[timer0Value & 3];
|
timer0ClockReload = TIMER_TICKS[timer0Value & 3];
|
||||||
if (!timer0On && (timer0Value & 0x80)) {
|
if (!timer0On && (timer0Value & 0x80)) {
|
||||||
// reload the counter
|
// reload the counter
|
||||||
|
@ -3331,8 +3247,7 @@ void applyTimer ()
|
||||||
UPDATE_REG(0x102, TM0CNT);
|
UPDATE_REG(0x102, TM0CNT);
|
||||||
// CPUUpdateTicks();
|
// CPUUpdateTicks();
|
||||||
}
|
}
|
||||||
if (timerOnOffDelay & 2)
|
if (timerOnOffDelay & 2) {
|
||||||
{
|
|
||||||
timer1ClockReload = TIMER_TICKS[timer1Value & 3];
|
timer1ClockReload = TIMER_TICKS[timer1Value & 3];
|
||||||
if (!timer1On && (timer1Value & 0x80)) {
|
if (!timer1On && (timer1Value & 0x80)) {
|
||||||
// reload the counter
|
// reload the counter
|
||||||
|
@ -3345,8 +3260,7 @@ void applyTimer ()
|
||||||
interp_rate();
|
interp_rate();
|
||||||
UPDATE_REG(0x106, TM1CNT);
|
UPDATE_REG(0x106, TM1CNT);
|
||||||
}
|
}
|
||||||
if (timerOnOffDelay & 4)
|
if (timerOnOffDelay & 4) {
|
||||||
{
|
|
||||||
timer2ClockReload = TIMER_TICKS[timer2Value & 3];
|
timer2ClockReload = TIMER_TICKS[timer2Value & 3];
|
||||||
if (!timer2On && (timer2Value & 0x80)) {
|
if (!timer2On && (timer2Value & 0x80)) {
|
||||||
// reload the counter
|
// reload the counter
|
||||||
|
@ -3358,8 +3272,7 @@ void applyTimer ()
|
||||||
TM2CNT = timer2Value & 0xC7;
|
TM2CNT = timer2Value & 0xC7;
|
||||||
UPDATE_REG(0x10A, TM2CNT);
|
UPDATE_REG(0x10A, TM2CNT);
|
||||||
}
|
}
|
||||||
if (timerOnOffDelay & 8)
|
if (timerOnOffDelay & 8) {
|
||||||
{
|
|
||||||
timer3ClockReload = TIMER_TICKS[timer3Value & 3];
|
timer3ClockReload = TIMER_TICKS[timer3Value & 3];
|
||||||
if (!timer3On && (timer3Value & 0x80)) {
|
if (!timer3On && (timer3Value & 0x80)) {
|
||||||
// reload the counter
|
// reload the counter
|
||||||
|
@ -3544,8 +3457,7 @@ void CPUReset()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (CheckEReaderRegion())
|
switch (CheckEReaderRegion()) {
|
||||||
{
|
|
||||||
case 1: //US
|
case 1: //US
|
||||||
EReaderWriteMemory(0x8009134, 0x46C0DFE0);
|
EReaderWriteMemory(0x8009134, 0x46C0DFE0);
|
||||||
break;
|
break;
|
||||||
|
@ -3823,7 +3735,6 @@ void CPULoop(int ticks)
|
||||||
if (cpuNextEvent > ticks)
|
if (cpuNextEvent > ticks)
|
||||||
cpuNextEvent = ticks;
|
cpuNextEvent = ticks;
|
||||||
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!holdState && !SWITicks) {
|
if (!holdState && !SWITicks) {
|
||||||
if (armState) {
|
if (armState) {
|
||||||
|
@ -3851,8 +3762,7 @@ void CPULoop(int ticks)
|
||||||
if (cpuTotalTicks >= cpuNextEvent) {
|
if (cpuTotalTicks >= cpuNextEvent) {
|
||||||
int remainingTicks = cpuTotalTicks - cpuNextEvent;
|
int remainingTicks = cpuTotalTicks - cpuNextEvent;
|
||||||
|
|
||||||
if (SWITicks)
|
if (SWITicks) {
|
||||||
{
|
|
||||||
SWITicks -= clockTicks;
|
SWITicks -= clockTicks;
|
||||||
if (SWITicks < 0)
|
if (SWITicks < 0)
|
||||||
SWITicks = 0;
|
SWITicks = 0;
|
||||||
|
@ -3863,8 +3773,7 @@ void CPULoop(int ticks)
|
||||||
|
|
||||||
updateLoop:
|
updateLoop:
|
||||||
|
|
||||||
if (IRQTicks)
|
if (IRQTicks) {
|
||||||
{
|
|
||||||
IRQTicks -= clockTicks;
|
IRQTicks -= clockTicks;
|
||||||
if (IRQTicks < 0)
|
if (IRQTicks < 0)
|
||||||
IRQTicks = 0;
|
IRQTicks = 0;
|
||||||
|
@ -3872,7 +3781,6 @@ void CPULoop(int ticks)
|
||||||
|
|
||||||
lcdTicks -= clockTicks;
|
lcdTicks -= clockTicks;
|
||||||
|
|
||||||
|
|
||||||
if (lcdTicks <= 0) {
|
if (lcdTicks <= 0) {
|
||||||
if (DISPSTAT & 1) { // V-BLANK
|
if (DISPSTAT & 1) { // V-BLANK
|
||||||
// if in V-Blank mode, keep computing...
|
// if in V-Blank mode, keep computing...
|
||||||
|
@ -3990,12 +3898,10 @@ void CPULoop(int ticks)
|
||||||
CPUCompareVCOUNT();
|
CPUCompareVCOUNT();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(frameCount >= framesToSkip)
|
if (frameCount >= framesToSkip) {
|
||||||
{
|
|
||||||
(*renderLine)();
|
(*renderLine)();
|
||||||
switch (systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 16:
|
case 16: {
|
||||||
{
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
u16* dest = (u16*)pix + 240 * VCOUNT;
|
u16* dest = (u16*)pix + 240 * VCOUNT;
|
||||||
#else
|
#else
|
||||||
|
@ -4026,10 +3932,8 @@ void CPULoop(int ticks)
|
||||||
#ifndef __LIBRETRO__
|
#ifndef __LIBRETRO__
|
||||||
*dest++ = 0;
|
*dest++ = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
} break;
|
||||||
break;
|
case 24: {
|
||||||
case 24:
|
|
||||||
{
|
|
||||||
u8* dest = (u8*)pix + 240 * VCOUNT * 3;
|
u8* dest = (u8*)pix + 240 * VCOUNT * 3;
|
||||||
for (int x = 0; x < 240;) {
|
for (int x = 0; x < 240;) {
|
||||||
*((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
|
*((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
|
||||||
|
@ -4068,10 +3972,8 @@ void CPULoop(int ticks)
|
||||||
*((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
|
*((u32*)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
|
||||||
dest += 3;
|
dest += 3;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case 32: {
|
||||||
case 32:
|
|
||||||
{
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
u32* dest = (u32*)pix + 240 * VCOUNT;
|
u32* dest = (u32*)pix + 240 * VCOUNT;
|
||||||
#else
|
#else
|
||||||
|
@ -4098,8 +4000,7 @@ void CPULoop(int ticks)
|
||||||
*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
|
*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
|
||||||
*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
|
*dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// entering H-Blank
|
// entering H-Blank
|
||||||
|
@ -4230,8 +4131,6 @@ void CPULoop(int ticks)
|
||||||
|
|
||||||
timerOverflow = 0;
|
timerOverflow = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
profilingTicks -= clockTicks;
|
profilingTicks -= clockTicks;
|
||||||
if (profilingTicks <= 0) {
|
if (profilingTicks <= 0) {
|
||||||
|
@ -4283,28 +4182,21 @@ void CPULoop(int ticks)
|
||||||
if (stopState)
|
if (stopState)
|
||||||
res &= 0x3080;
|
res &= 0x3080;
|
||||||
if (res) {
|
if (res) {
|
||||||
if (intState)
|
if (intState) {
|
||||||
{
|
if (!IRQTicks) {
|
||||||
if (!IRQTicks)
|
|
||||||
{
|
|
||||||
CPUInterrupt();
|
CPUInterrupt();
|
||||||
intState = false;
|
intState = false;
|
||||||
holdState = false;
|
holdState = false;
|
||||||
stopState = false;
|
stopState = false;
|
||||||
holdType = 0;
|
holdType = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (!holdState) {
|
||||||
{
|
|
||||||
if (!holdState)
|
|
||||||
{
|
|
||||||
intState = true;
|
intState = true;
|
||||||
IRQTicks = 7;
|
IRQTicks = 7;
|
||||||
if (cpuNextEvent > IRQTicks)
|
if (cpuNextEvent > IRQTicks)
|
||||||
cpuNextEvent = IRQTicks;
|
cpuNextEvent = IRQTicks;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CPUInterrupt();
|
CPUInterrupt();
|
||||||
holdState = false;
|
holdState = false;
|
||||||
stopState = false;
|
stopState = false;
|
||||||
|
@ -4338,7 +4230,6 @@ void CPULoop(int ticks)
|
||||||
|
|
||||||
if (ticks <= 0 || cpuBreakLoop)
|
if (ticks <= 0 || cpuBreakLoop)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef NO_LINK
|
#ifndef NO_LINK
|
||||||
|
@ -4348,8 +4239,7 @@ void CPULoop(int ticks)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TILED_RENDERING
|
#ifdef TILED_RENDERING
|
||||||
union u8h
|
union u8h {
|
||||||
{
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/* 0*/ unsigned lo : 4;
|
/* 0*/ unsigned lo : 4;
|
||||||
|
@ -4358,8 +4248,7 @@ union u8h
|
||||||
u8 val;
|
u8 val;
|
||||||
};
|
};
|
||||||
|
|
||||||
union TileEntry
|
union TileEntry {
|
||||||
{
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/* 0*/ unsigned tileNum : 10;
|
/* 0*/ unsigned tileNum : 10;
|
||||||
|
@ -4370,8 +4259,7 @@ union TileEntry
|
||||||
u16 val;
|
u16 val;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TileLine
|
struct TileLine {
|
||||||
{
|
|
||||||
u32 pixels[8];
|
u32 pixels[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4388,13 +4276,13 @@ inline const TileLine gfxReadTile(const u16 *screenSource, const int yyy, const
|
||||||
tile.val = READ16LE(screenSource);
|
tile.val = READ16LE(screenSource);
|
||||||
|
|
||||||
int tileY = yyy & 7;
|
int tileY = yyy & 7;
|
||||||
if (tile.vFlip) tileY = 7 - tileY;
|
if (tile.vFlip)
|
||||||
|
tileY = 7 - tileY;
|
||||||
TileLine tileLine;
|
TileLine tileLine;
|
||||||
|
|
||||||
const u8* tileBase = &charBase[tile.tileNum * 64 + tileY * 8];
|
const u8* tileBase = &charBase[tile.tileNum * 64 + tileY * 8];
|
||||||
|
|
||||||
if (!tile.hFlip)
|
if (!tile.hFlip) {
|
||||||
{
|
|
||||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[0], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[0], tileBase[0], palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[1], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[1], tileBase[1], palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[2], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[2], tileBase[2], palette, prio);
|
||||||
|
@ -4403,9 +4291,7 @@ inline const TileLine gfxReadTile(const u16 *screenSource, const int yyy, const
|
||||||
gfxDrawPixel(&tileLine.pixels[5], tileBase[5], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[5], tileBase[5], palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[6], tileBase[6], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[6], tileBase[6], palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[7], tileBase[7], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[7], tileBase[7], palette, prio);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[7], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[0], tileBase[7], palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[6], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[1], tileBase[6], palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[5], palette, prio);
|
gfxDrawPixel(&tileLine.pixels[2], tileBase[5], palette, prio);
|
||||||
|
@ -4425,14 +4311,14 @@ inline const TileLine gfxReadTilePal(const u16 *screenSource, const int yyy, con
|
||||||
tile.val = READ16LE(screenSource);
|
tile.val = READ16LE(screenSource);
|
||||||
|
|
||||||
int tileY = yyy & 7;
|
int tileY = yyy & 7;
|
||||||
if (tile.vFlip) tileY = 7 - tileY;
|
if (tile.vFlip)
|
||||||
|
tileY = 7 - tileY;
|
||||||
palette += tile.palette * 16;
|
palette += tile.palette * 16;
|
||||||
TileLine tileLine;
|
TileLine tileLine;
|
||||||
|
|
||||||
const u8h* tileBase = (u8h*)&charBase[tile.tileNum * 32 + tileY * 4];
|
const u8h* tileBase = (u8h*)&charBase[tile.tileNum * 32 + tileY * 4];
|
||||||
|
|
||||||
if (!tile.hFlip)
|
if (!tile.hFlip) {
|
||||||
{
|
|
||||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[0].lo, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[0], tileBase[0].lo, palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[0].hi, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[1], tileBase[0].hi, palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[1].lo, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[2], tileBase[1].lo, palette, prio);
|
||||||
|
@ -4441,9 +4327,7 @@ inline const TileLine gfxReadTilePal(const u16 *screenSource, const int yyy, con
|
||||||
gfxDrawPixel(&tileLine.pixels[5], tileBase[2].hi, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[5], tileBase[2].hi, palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[6], tileBase[3].lo, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[6], tileBase[3].lo, palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[7], tileBase[3].hi, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[7], tileBase[3].hi, palette, prio);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[3].hi, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[0], tileBase[3].hi, palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[3].lo, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[1], tileBase[3].lo, palette, prio);
|
||||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[2].hi, palette, prio);
|
gfxDrawPixel(&tileLine.pixels[2], tileBase[2].hi, palette, prio);
|
||||||
|
@ -4477,8 +4361,7 @@ static void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
||||||
u32 prio = ((control & 3) << 25) + 0x1000000;
|
u32 prio = ((control & 3) << 25) + 0x1000000;
|
||||||
int sizeX = 256;
|
int sizeX = 256;
|
||||||
int sizeY = 256;
|
int sizeY = 256;
|
||||||
switch ((control >> 14) & 3)
|
switch ((control >> 14) & 3) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -4503,17 +4386,14 @@ static void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
||||||
int mosaicX = (MOSAIC & 0x000F) + 1;
|
int mosaicX = (MOSAIC & 0x000F) + 1;
|
||||||
int mosaicY = ((MOSAIC & 0x00F0) >> 4) + 1;
|
int mosaicY = ((MOSAIC & 0x00F0) >> 4) + 1;
|
||||||
|
|
||||||
if (mosaicOn)
|
if (mosaicOn) {
|
||||||
{
|
if ((VCOUNT % mosaicY) != 0) {
|
||||||
if ((VCOUNT % mosaicY) != 0)
|
|
||||||
{
|
|
||||||
mosaicY = VCOUNT - (VCOUNT % mosaicY);
|
mosaicY = VCOUNT - (VCOUNT % mosaicY);
|
||||||
yyy = (vofs + mosaicY) & maskY;
|
yyy = (vofs + mosaicY) & maskY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yyy > 255 && sizeY > 256)
|
if (yyy > 255 && sizeY > 256) {
|
||||||
{
|
|
||||||
yyy &= 255;
|
yyy &= 255;
|
||||||
screenBase += 0x400;
|
screenBase += 0x400;
|
||||||
if (sizeX > 256)
|
if (sizeX > 256)
|
||||||
|
@ -4527,60 +4407,47 @@ static void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
||||||
const int firstTileX = xxx & 7;
|
const int firstTileX = xxx & 7;
|
||||||
|
|
||||||
// First tile, if clipped
|
// First tile, if clipped
|
||||||
if (firstTileX)
|
if (firstTileX) {
|
||||||
{
|
|
||||||
gfxDrawTileClipped(readTile(screenSource, yyy, charBase, palette, prio), &line[x], firstTileX, 8 - firstTileX);
|
gfxDrawTileClipped(readTile(screenSource, yyy, charBase, palette, prio), &line[x], firstTileX, 8 - firstTileX);
|
||||||
screenSource++;
|
screenSource++;
|
||||||
x += 8 - firstTileX;
|
x += 8 - firstTileX;
|
||||||
xxx += 8 - firstTileX;
|
xxx += 8 - firstTileX;
|
||||||
|
|
||||||
if (xxx == 256 && sizeX > 256)
|
if (xxx == 256 && sizeX > 256) {
|
||||||
{
|
|
||||||
screenSource = screenBase + 0x400 + yshift;
|
screenSource = screenBase + 0x400 + yshift;
|
||||||
}
|
} else if (xxx >= sizeX) {
|
||||||
else if (xxx >= sizeX)
|
|
||||||
{
|
|
||||||
xxx = 0;
|
xxx = 0;
|
||||||
screenSource = screenBase + yshift;
|
screenSource = screenBase + yshift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Middle tiles, full
|
// Middle tiles, full
|
||||||
while (x < 240 - firstTileX)
|
while (x < 240 - firstTileX) {
|
||||||
{
|
|
||||||
gfxDrawTile(readTile(screenSource, yyy, charBase, palette, prio), &line[x]);
|
gfxDrawTile(readTile(screenSource, yyy, charBase, palette, prio), &line[x]);
|
||||||
screenSource++;
|
screenSource++;
|
||||||
xxx += 8;
|
xxx += 8;
|
||||||
x += 8;
|
x += 8;
|
||||||
|
|
||||||
if (xxx == 256 && sizeX > 256)
|
if (xxx == 256 && sizeX > 256) {
|
||||||
{
|
|
||||||
screenSource = screenBase + 0x400 + yshift;
|
screenSource = screenBase + 0x400 + yshift;
|
||||||
}
|
} else if (xxx >= sizeX) {
|
||||||
else if (xxx >= sizeX)
|
|
||||||
{
|
|
||||||
xxx = 0;
|
xxx = 0;
|
||||||
screenSource = screenBase + yshift;
|
screenSource = screenBase + yshift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last tile, if clipped
|
// Last tile, if clipped
|
||||||
if (firstTileX)
|
if (firstTileX) {
|
||||||
{
|
|
||||||
gfxDrawTileClipped(readTile(screenSource, yyy, charBase, palette, prio), &line[x], 0, firstTileX);
|
gfxDrawTileClipped(readTile(screenSource, yyy, charBase, palette, prio), &line[x], 0, firstTileX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mosaicOn)
|
if (mosaicOn) {
|
||||||
{
|
if (mosaicX > 1) {
|
||||||
if (mosaicX > 1)
|
|
||||||
{
|
|
||||||
int m = 1;
|
int m = 1;
|
||||||
for (int i = 0; i < 239; i++)
|
for (int i = 0; i < 239; i++) {
|
||||||
{
|
|
||||||
line[i + 1] = line[i];
|
line[i + 1] = line[i];
|
||||||
m++;
|
m++;
|
||||||
if (m == mosaicX)
|
if (m == mosaicX) {
|
||||||
{
|
|
||||||
m = 1;
|
m = 1;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -4598,7 +4465,6 @@ void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct EmulatedSystem GBASystem = {
|
struct EmulatedSystem GBASystem = {
|
||||||
// emuMain
|
// emuMain
|
||||||
CPULoop,
|
CPULoop,
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
int coeff[32] = {
|
int coeff[32] = {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
|
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
|
||||||
|
};
|
||||||
|
|
||||||
u32 line0[240];
|
u32 line0[240];
|
||||||
u32 line1[240];
|
u32 line1[240];
|
||||||
|
|
513
src/gba/GBAGfx.h
513
src/gba/GBAGfx.h
|
@ -741,15 +741,10 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
t -= (t % mosaicY);
|
t -= (t % mosaicY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int realX = ((sizeX) << 7) -
|
int realX = ((sizeX) << 7) - (fieldX >> 1) * dx - (fieldY >> 1) * dmx + t * dmx;
|
||||||
(fieldX >> 1) * dx -
|
int realY = ((sizeY) << 7) - (fieldX >> 1) * dy - (fieldY >> 1) * dmy + t * dmy;
|
||||||
(fieldY >> 1) * dmx + t * dmx;
|
|
||||||
int realY = ((sizeY) << 7) -
|
|
||||||
(fieldX >> 1) * dy -
|
|
||||||
(fieldY >> 1) * dmy + t * dmy;
|
|
||||||
|
|
||||||
u32 prio = (((a2 >> 10) & 3) << 25) |
|
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00) << 6);
|
||||||
((a0 & 0x0c00) << 6);
|
|
||||||
|
|
||||||
if (a0 & 0x2000) {
|
if (a0 & 0x2000) {
|
||||||
int c = (a2 & 0x3FF);
|
int c = (a2 & 0x3FF);
|
||||||
|
@ -768,81 +763,52 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
int xxx = realX >> 8;
|
int xxx = realX >> 8;
|
||||||
int yyy = realY >> 8;
|
int yyy = realY >> 8;
|
||||||
|
|
||||||
if (xxx < 0 ||
|
if (xxx < 0 || xxx >= sizeX || yyy < 0 || yyy >= sizeY || sx >= 240)
|
||||||
xxx >= sizeX ||
|
|
||||||
yyy < 0 ||
|
|
||||||
yyy >= sizeY ||
|
|
||||||
sx >= 240)
|
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
u32 color = vram
|
u32 color = vram
|
||||||
[0x10000 +
|
[0x10000 + ((((c + (yyy >> 3) * inc)
|
||||||
((((c +
|
<< 5)
|
||||||
(yyy >>
|
+ ((yyy & 7)
|
||||||
3) *
|
<< 3)
|
||||||
inc)
|
+ ((xxx >> 3)
|
||||||
<< 5) +
|
<< 6)
|
||||||
((yyy & 7)
|
+ (xxx & 7))
|
||||||
<< 3) +
|
& 0x7FFF)];
|
||||||
((xxx >> 3)
|
if ((color == 0) && (((prio >> 25) & 3) < ((lineOBJ
|
||||||
<< 6) +
|
[sx]
|
||||||
(xxx & 7)) &
|
>> 25)
|
||||||
0x7FFF)];
|
& 3))) {
|
||||||
if ((color == 0) &&
|
lineOBJ[sx] = (lineOBJ
|
||||||
(((prio >> 25) &
|
[sx]
|
||||||
3) <
|
& 0xF9FFFFFF)
|
||||||
((lineOBJ
|
| prio;
|
||||||
[sx] >>
|
if ((a0 & 0x1000) && m)
|
||||||
25) &
|
lineOBJ[sx] = (lineOBJ
|
||||||
3))) {
|
[sx - 1]
|
||||||
lineOBJ[sx] =
|
& 0xF9FFFFFF)
|
||||||
(lineOBJ
|
| prio;
|
||||||
[sx] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
if ((a0 &
|
|
||||||
0x1000) &&
|
|
||||||
m)
|
|
||||||
lineOBJ[sx] =
|
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
} else if (
|
} else if (
|
||||||
(color) &&
|
(color) && (prio < (lineOBJ[sx] & 0xFF000000))) {
|
||||||
(prio <
|
lineOBJ[sx] = READ16LE(
|
||||||
(lineOBJ[sx] &
|
|
||||||
0xFF000000))) {
|
|
||||||
lineOBJ[sx] =
|
|
||||||
READ16LE(
|
|
||||||
&spritePalette
|
&spritePalette
|
||||||
[color]) |
|
[color])
|
||||||
prio;
|
| prio;
|
||||||
if ((a0 &
|
if ((a0 & 0x1000) && m)
|
||||||
0x1000) &&
|
lineOBJ[sx] = (lineOBJ
|
||||||
m)
|
[sx - 1]
|
||||||
lineOBJ[sx] =
|
& 0xF9FFFFFF)
|
||||||
(lineOBJ
|
| prio;
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a0 & 0x1000) {
|
if (a0 & 0x1000) {
|
||||||
m++;
|
m++;
|
||||||
if (m ==
|
if (m == mosaicX)
|
||||||
mosaicX)
|
|
||||||
m = 0;
|
m = 0;
|
||||||
}
|
}
|
||||||
#ifdef SPRITE_DEBUG
|
#ifdef SPRITE_DEBUG
|
||||||
if (t == 0 ||
|
if (t == 0 || t == maskY || x == 0 || x == maskX)
|
||||||
t == maskY ||
|
lineOBJ[sx] = 0x001F;
|
||||||
x == 0 ||
|
|
||||||
x == maskX)
|
|
||||||
lineOBJ[sx] =
|
|
||||||
0x001F;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
sx = (sx + 1) & 511;
|
sx = (sx + 1) & 511;
|
||||||
|
@ -865,74 +831,47 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
continue;
|
continue;
|
||||||
int xxx = realX >> 8;
|
int xxx = realX >> 8;
|
||||||
int yyy = realY >> 8;
|
int yyy = realY >> 8;
|
||||||
if (xxx < 0 ||
|
if (xxx < 0 || xxx >= sizeX || yyy < 0 || yyy >= sizeY || sx >= 240)
|
||||||
xxx >= sizeX ||
|
|
||||||
yyy < 0 ||
|
|
||||||
yyy >= sizeY ||
|
|
||||||
sx >= 240)
|
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
u32 color = vram
|
u32 color = vram
|
||||||
[0x10000 +
|
[0x10000 + ((((c + (yyy >> 3) * inc)
|
||||||
((((c +
|
<< 5)
|
||||||
(yyy >>
|
+ ((yyy & 7)
|
||||||
3) *
|
<< 2)
|
||||||
inc)
|
+ ((xxx >> 3)
|
||||||
<< 5) +
|
<< 5)
|
||||||
((yyy & 7)
|
+ ((xxx & 7) >> 1))
|
||||||
<< 2) +
|
& 0x7FFF)];
|
||||||
((xxx >> 3)
|
|
||||||
<< 5) +
|
|
||||||
((xxx & 7) >>
|
|
||||||
1)) &
|
|
||||||
0x7FFF)];
|
|
||||||
if (xxx & 1)
|
if (xxx & 1)
|
||||||
color >>= 4;
|
color >>= 4;
|
||||||
else
|
else
|
||||||
color &=
|
color &= 0x0F;
|
||||||
0x0F;
|
|
||||||
|
|
||||||
if ((color == 0) &&
|
if ((color == 0) && (((prio >> 25) & 3) < ((lineOBJ
|
||||||
(((prio >> 25) &
|
[sx]
|
||||||
3) <
|
>> 25)
|
||||||
((lineOBJ
|
& 3))) {
|
||||||
[sx] >>
|
lineOBJ[sx] = (lineOBJ
|
||||||
25) &
|
[sx]
|
||||||
3))) {
|
& 0xF9FFFFFF)
|
||||||
lineOBJ[sx] =
|
| prio;
|
||||||
(lineOBJ
|
if ((a0 & 0x1000) && m)
|
||||||
[sx] &
|
lineOBJ[sx] = (lineOBJ
|
||||||
0xF9FFFFFF) |
|
[sx - 1]
|
||||||
prio;
|
& 0xF9FFFFFF)
|
||||||
if ((a0 &
|
| prio;
|
||||||
0x1000) &&
|
|
||||||
m)
|
|
||||||
lineOBJ[sx] =
|
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
} else if (
|
} else if (
|
||||||
(color) &&
|
(color) && (prio < (lineOBJ[sx] & 0xFF000000))) {
|
||||||
(prio <
|
lineOBJ[sx] = READ16LE(
|
||||||
(lineOBJ[sx] &
|
|
||||||
0xFF000000))) {
|
|
||||||
lineOBJ[sx] =
|
|
||||||
READ16LE(
|
|
||||||
&spritePalette
|
&spritePalette
|
||||||
[palette +
|
[palette + color])
|
||||||
color]) |
|
| prio;
|
||||||
prio;
|
if ((a0 & 0x1000) && m)
|
||||||
if ((a0 &
|
lineOBJ[sx] = (lineOBJ
|
||||||
0x1000) &&
|
[sx - 1]
|
||||||
m)
|
& 0xF9FFFFFF)
|
||||||
lineOBJ[sx] =
|
| prio;
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((a0 & 0x1000) && m) {
|
if ((a0 & 0x1000) && m) {
|
||||||
|
@ -942,10 +881,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPRITE_DEBUG
|
#ifdef SPRITE_DEBUG
|
||||||
if (t == 0 || t == maskY ||
|
if (t == 0 || t == maskY || x == 0 || x == maskX)
|
||||||
x == 0 || x == maskX)
|
lineOBJ[sx] = 0x001F;
|
||||||
lineOBJ[sx] =
|
|
||||||
0x001F;
|
|
||||||
#endif
|
#endif
|
||||||
sx = (sx + 1) & 511;
|
sx = (sx + 1) & 511;
|
||||||
realX += dx;
|
realX += dx;
|
||||||
|
@ -986,17 +923,11 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
t -= (t % mosaicY);
|
t -= (t % mosaicY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int address =
|
int address = 0x10000 + ((((c + (t >> 3) * inc) << 5) + ((t & 7) << 3) + ((xxx >> 3) << 6) + (xxx & 7)) & 0x7FFF);
|
||||||
0x10000 +
|
|
||||||
((((c + (t >> 3) * inc) << 5) +
|
|
||||||
((t & 7) << 3) + ((xxx >> 3) << 6) +
|
|
||||||
(xxx & 7)) &
|
|
||||||
0x7FFF);
|
|
||||||
|
|
||||||
if (a1 & 0x1000)
|
if (a1 & 0x1000)
|
||||||
xxx = 7;
|
xxx = 7;
|
||||||
u32 prio = (((a2 >> 10) & 3) << 25) |
|
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00) << 6);
|
||||||
((a0 & 0x0c00) << 6);
|
|
||||||
|
|
||||||
for (int xx = 0; xx < sizeX; xx++) {
|
for (int xx = 0; xx < sizeX; xx++) {
|
||||||
if (xx >= startpix)
|
if (xx >= startpix)
|
||||||
|
@ -1005,39 +936,23 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
continue;
|
continue;
|
||||||
if (sx < 240) {
|
if (sx < 240) {
|
||||||
u8 color = vram[address];
|
u8 color = vram[address];
|
||||||
if ((color == 0) &&
|
if ((color == 0) && (((prio >> 25) & 3) < ((lineOBJ[sx] >> 25) & 3))) {
|
||||||
(((prio >> 25) & 3) <
|
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
|
||||||
((lineOBJ[sx] >> 25) &
|
if ((a0 & 0x1000) && m)
|
||||||
3))) {
|
lineOBJ[sx] = (lineOBJ
|
||||||
lineOBJ[sx] =
|
[sx - 1]
|
||||||
(lineOBJ[sx] &
|
& 0xF9FFFFFF)
|
||||||
0xF9FFFFFF) |
|
| prio;
|
||||||
prio;
|
} else if ((color) && (prio < (lineOBJ[sx] & 0xFF000000))) {
|
||||||
if ((a0 & 0x1000) &&
|
lineOBJ[sx] = READ16LE(
|
||||||
m)
|
|
||||||
lineOBJ[sx] =
|
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
} else if ((color) &&
|
|
||||||
(prio <
|
|
||||||
(lineOBJ[sx] &
|
|
||||||
0xFF000000))) {
|
|
||||||
lineOBJ[sx] =
|
|
||||||
READ16LE(
|
|
||||||
&spritePalette
|
&spritePalette
|
||||||
[color]) |
|
[color])
|
||||||
prio;
|
| prio;
|
||||||
if ((a0 & 0x1000) &&
|
if ((a0 & 0x1000) && m)
|
||||||
m)
|
lineOBJ[sx] = (lineOBJ
|
||||||
lineOBJ[sx] =
|
[sx - 1]
|
||||||
(lineOBJ
|
& 0xF9FFFFFF)
|
||||||
[sx -
|
| prio;
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a0 & 0x1000) {
|
if (a0 & 0x1000) {
|
||||||
|
@ -1047,10 +962,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPRITE_DEBUG
|
#ifdef SPRITE_DEBUG
|
||||||
if (t == 0 || t == maskY ||
|
if (t == 0 || t == maskY || xx == 0 || xx == maskX)
|
||||||
xx == 0 || xx == maskX)
|
lineOBJ[sx] = 0x001F;
|
||||||
lineOBJ[sx] =
|
|
||||||
0x001F;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,14 +1007,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
t -= (t % mosaicY);
|
t -= (t % mosaicY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int address =
|
int address = 0x10000 + ((((c + (t >> 3) * inc) << 5) + ((t & 7) << 2) + ((xxx >> 3) << 5) + ((xxx & 7) >> 1)) & 0x7FFF);
|
||||||
0x10000 +
|
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00) << 6);
|
||||||
((((c + (t >> 3) * inc) << 5) +
|
|
||||||
((t & 7) << 2) + ((xxx >> 3) << 5) +
|
|
||||||
((xxx & 7) >> 1)) &
|
|
||||||
0x7FFF);
|
|
||||||
u32 prio = (((a2 >> 10) & 3) << 25) |
|
|
||||||
((a0 & 0x0c00) << 6);
|
|
||||||
int palette = (a2 >> 8) & 0xF0;
|
int palette = (a2 >> 8) & 0xF0;
|
||||||
if (a1 & 0x1000) {
|
if (a1 & 0x1000) {
|
||||||
xxx = 7;
|
xxx = 7;
|
||||||
|
@ -1112,57 +1019,36 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
if (lineOBJpix < 0)
|
if (lineOBJpix < 0)
|
||||||
continue;
|
continue;
|
||||||
if (sx < 240) {
|
if (sx < 240) {
|
||||||
u8 color =
|
u8 color = vram[address];
|
||||||
vram[address];
|
|
||||||
if (xx & 1) {
|
if (xx & 1) {
|
||||||
color =
|
color = (color >> 4);
|
||||||
(color >>
|
|
||||||
4);
|
|
||||||
} else
|
} else
|
||||||
color &=
|
color &= 0x0F;
|
||||||
0x0F;
|
|
||||||
|
|
||||||
if ((color == 0) &&
|
if ((color == 0) && (((prio >> 25) & 3) < ((lineOBJ
|
||||||
(((prio >> 25) &
|
[sx]
|
||||||
3) <
|
>> 25)
|
||||||
((lineOBJ
|
& 3))) {
|
||||||
[sx] >>
|
lineOBJ[sx] = (lineOBJ
|
||||||
25) &
|
[sx]
|
||||||
3))) {
|
& 0xF9FFFFFF)
|
||||||
lineOBJ[sx] =
|
| prio;
|
||||||
(lineOBJ
|
if ((a0 & 0x1000) && m)
|
||||||
[sx] &
|
lineOBJ[sx] = (lineOBJ
|
||||||
0xF9FFFFFF) |
|
[sx - 1]
|
||||||
prio;
|
& 0xF9FFFFFF)
|
||||||
if ((a0 &
|
| prio;
|
||||||
0x1000) &&
|
|
||||||
m)
|
|
||||||
lineOBJ[sx] =
|
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
} else if (
|
} else if (
|
||||||
(color) &&
|
(color) && (prio < (lineOBJ[sx] & 0xFF000000))) {
|
||||||
(prio <
|
lineOBJ[sx] = READ16LE(
|
||||||
(lineOBJ[sx] &
|
|
||||||
0xFF000000))) {
|
|
||||||
lineOBJ[sx] =
|
|
||||||
READ16LE(
|
|
||||||
&spritePalette
|
&spritePalette
|
||||||
[palette +
|
[palette + color])
|
||||||
color]) |
|
| prio;
|
||||||
prio;
|
if ((a0 & 0x1000) && m)
|
||||||
if ((a0 &
|
lineOBJ[sx] = (lineOBJ
|
||||||
0x1000) &&
|
[sx - 1]
|
||||||
m)
|
& 0xF9FFFFFF)
|
||||||
lineOBJ[sx] =
|
| prio;
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (a0 & 0x1000) {
|
if (a0 & 0x1000) {
|
||||||
|
@ -1171,10 +1057,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
m = 0;
|
m = 0;
|
||||||
}
|
}
|
||||||
#ifdef SPRITE_DEBUG
|
#ifdef SPRITE_DEBUG
|
||||||
if (t == 0 || t == maskY ||
|
if (t == 0 || t == maskY || xx == 0 || xx == maskX)
|
||||||
xx == 0 || xx == maskX)
|
lineOBJ[sx] = 0x001F;
|
||||||
lineOBJ[sx] =
|
|
||||||
0x001F;
|
|
||||||
#endif
|
#endif
|
||||||
sx = (sx + 1) & 511;
|
sx = (sx + 1) & 511;
|
||||||
xxx--;
|
xxx--;
|
||||||
|
@ -1194,57 +1078,36 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
if (lineOBJpix < 0)
|
if (lineOBJpix < 0)
|
||||||
continue;
|
continue;
|
||||||
if (sx < 240) {
|
if (sx < 240) {
|
||||||
u8 color =
|
u8 color = vram[address];
|
||||||
vram[address];
|
|
||||||
if (xx & 1) {
|
if (xx & 1) {
|
||||||
color =
|
color = (color >> 4);
|
||||||
(color >>
|
|
||||||
4);
|
|
||||||
} else
|
} else
|
||||||
color &=
|
color &= 0x0F;
|
||||||
0x0F;
|
|
||||||
|
|
||||||
if ((color == 0) &&
|
if ((color == 0) && (((prio >> 25) & 3) < ((lineOBJ
|
||||||
(((prio >> 25) &
|
[sx]
|
||||||
3) <
|
>> 25)
|
||||||
((lineOBJ
|
& 3))) {
|
||||||
[sx] >>
|
lineOBJ[sx] = (lineOBJ
|
||||||
25) &
|
[sx]
|
||||||
3))) {
|
& 0xF9FFFFFF)
|
||||||
lineOBJ[sx] =
|
| prio;
|
||||||
(lineOBJ
|
if ((a0 & 0x1000) && m)
|
||||||
[sx] &
|
lineOBJ[sx] = (lineOBJ
|
||||||
0xF9FFFFFF) |
|
[sx - 1]
|
||||||
prio;
|
& 0xF9FFFFFF)
|
||||||
if ((a0 &
|
| prio;
|
||||||
0x1000) &&
|
|
||||||
m)
|
|
||||||
lineOBJ[sx] =
|
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
} else if (
|
} else if (
|
||||||
(color) &&
|
(color) && (prio < (lineOBJ[sx] & 0xFF000000))) {
|
||||||
(prio <
|
lineOBJ[sx] = READ16LE(
|
||||||
(lineOBJ[sx] &
|
|
||||||
0xFF000000))) {
|
|
||||||
lineOBJ[sx] =
|
|
||||||
READ16LE(
|
|
||||||
&spritePalette
|
&spritePalette
|
||||||
[palette +
|
[palette + color])
|
||||||
color]) |
|
| prio;
|
||||||
prio;
|
if ((a0 & 0x1000) && m)
|
||||||
if ((a0 &
|
lineOBJ[sx] = (lineOBJ
|
||||||
0x1000) &&
|
[sx - 1]
|
||||||
m)
|
& 0xF9FFFFFF)
|
||||||
lineOBJ[sx] =
|
| prio;
|
||||||
(lineOBJ
|
|
||||||
[sx -
|
|
||||||
1] &
|
|
||||||
0xF9FFFFFF) |
|
|
||||||
prio;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (a0 & 0x1000) {
|
if (a0 & 0x1000) {
|
||||||
|
@ -1253,10 +1116,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
m = 0;
|
m = 0;
|
||||||
}
|
}
|
||||||
#ifdef SPRITE_DEBUG
|
#ifdef SPRITE_DEBUG
|
||||||
if (t == 0 || t == maskY ||
|
if (t == 0 || t == maskY || xx == 0 || xx == maskX)
|
||||||
xx == 0 || xx == maskX)
|
lineOBJ[sx] = 0x001F;
|
||||||
lineOBJ[sx] =
|
|
||||||
0x001F;
|
|
||||||
#endif
|
#endif
|
||||||
sx = (sx + 1) & 511;
|
sx = (sx + 1) & 511;
|
||||||
xxx++;
|
xxx++;
|
||||||
|
@ -1357,10 +1218,8 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
if (dmy & 0x8000)
|
if (dmy & 0x8000)
|
||||||
dmy |= 0xFFFF8000;
|
dmy |= 0xFFFF8000;
|
||||||
|
|
||||||
int realX = ((sizeX) << 7) - (fieldX >> 1) * dx -
|
int realX = ((sizeX) << 7) - (fieldX >> 1) * dx - (fieldY >> 1) * dmx + t * dmx;
|
||||||
(fieldY >> 1) * dmx + t * dmx;
|
int realY = ((sizeY) << 7) - (fieldX >> 1) * dy - (fieldY >> 1) * dmy + t * dmy;
|
||||||
int realY = ((sizeY) << 7) - (fieldX >> 1) * dy -
|
|
||||||
(fieldY >> 1) * dmy + t * dmy;
|
|
||||||
|
|
||||||
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 &
|
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 &
|
||||||
// 0x0c00)<<6);
|
// 0x0c00)<<6);
|
||||||
|
@ -1382,19 +1241,13 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
int xxx = realX >> 8;
|
int xxx = realX >> 8;
|
||||||
int yyy = realY >> 8;
|
int yyy = realY >> 8;
|
||||||
|
|
||||||
if (xxx < 0 || xxx >= sizeX ||
|
if (xxx < 0 || xxx >= sizeX || yyy < 0 || yyy >= sizeY || sx >= 240) {
|
||||||
yyy < 0 || yyy >= sizeY ||
|
|
||||||
sx >= 240) {
|
|
||||||
} else {
|
} else {
|
||||||
u32 color = vram
|
u32 color = vram
|
||||||
[0x10000 +
|
[0x10000 + ((((c + (yyy >> 3) * inc)
|
||||||
((((c +
|
<< 5)
|
||||||
(yyy >> 3) * inc)
|
+ ((yyy & 7) << 3) + ((xxx >> 3) << 6) + (xxx & 7))
|
||||||
<< 5) +
|
& 0x7fff)];
|
||||||
((yyy & 7) << 3) +
|
|
||||||
((xxx >> 3) << 6) +
|
|
||||||
(xxx & 7)) &
|
|
||||||
0x7fff)];
|
|
||||||
if (color) {
|
if (color) {
|
||||||
lineOBJWin[sx] = 1;
|
lineOBJWin[sx] = 1;
|
||||||
}
|
}
|
||||||
|
@ -1427,19 +1280,13 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
// lineOBJ[sx] =
|
// lineOBJ[sx] =
|
||||||
// 0x001F | prio;
|
// 0x001F | prio;
|
||||||
// } else {
|
// } else {
|
||||||
if (xxx < 0 || xxx >= sizeX ||
|
if (xxx < 0 || xxx >= sizeX || yyy < 0 || yyy >= sizeY || sx >= 240) {
|
||||||
yyy < 0 || yyy >= sizeY ||
|
|
||||||
sx >= 240) {
|
|
||||||
} else {
|
} else {
|
||||||
u32 color = vram
|
u32 color = vram
|
||||||
[0x10000 +
|
[0x10000 + ((((c + (yyy >> 3) * inc)
|
||||||
((((c +
|
<< 5)
|
||||||
(yyy >> 3) * inc)
|
+ ((yyy & 7) << 2) + ((xxx >> 3) << 5) + ((xxx & 7) >> 1))
|
||||||
<< 5) +
|
& 0x7fff)];
|
||||||
((yyy & 7) << 2) +
|
|
||||||
((xxx >> 3) << 5) +
|
|
||||||
((xxx & 7) >> 1)) &
|
|
||||||
0x7fff)];
|
|
||||||
if (xxx & 1)
|
if (xxx & 1)
|
||||||
color >>= 4;
|
color >>= 4;
|
||||||
else
|
else
|
||||||
|
@ -1485,12 +1332,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
int xxx = 0;
|
int xxx = 0;
|
||||||
if (a1 & 0x1000)
|
if (a1 & 0x1000)
|
||||||
xxx = sizeX - 1;
|
xxx = sizeX - 1;
|
||||||
int address =
|
int address = 0x10000 + ((((c + (t >> 3) * inc) << 5) + ((t & 7) << 3) + ((xxx >> 3) << 6) + (xxx & 7)) & 0x7fff);
|
||||||
0x10000 +
|
|
||||||
((((c + (t >> 3) * inc) << 5) +
|
|
||||||
((t & 7) << 3) + ((xxx >> 3) << 6) +
|
|
||||||
(xxx & 7)) &
|
|
||||||
0x7fff);
|
|
||||||
if (a1 & 0x1000)
|
if (a1 & 0x1000)
|
||||||
xxx = 7;
|
xxx = 7;
|
||||||
// u32 prio = (((a2 >> 10) & 3) << 25) |
|
// u32 prio = (((a2 >> 10) & 3) << 25) |
|
||||||
|
@ -1542,12 +1384,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
int xxx = 0;
|
int xxx = 0;
|
||||||
if (a1 & 0x1000)
|
if (a1 & 0x1000)
|
||||||
xxx = sizeX - 1;
|
xxx = sizeX - 1;
|
||||||
int address =
|
int address = 0x10000 + ((((c + (t >> 3) * inc) << 5) + ((t & 7) << 2) + ((xxx >> 3) << 5) + ((xxx & 7) >> 1)) & 0x7fff);
|
||||||
0x10000 +
|
|
||||||
((((c + (t >> 3) * inc) << 5) +
|
|
||||||
((t & 7) << 2) + ((xxx >> 3) << 5) +
|
|
||||||
((xxx & 7) >> 1)) &
|
|
||||||
0x7fff);
|
|
||||||
// u32 prio = (((a2 >> 10) & 3) << 25) |
|
// u32 prio = (((a2 >> 10) & 3) << 25) |
|
||||||
// ((a0 & 0x0c00)<<6);
|
// ((a0 & 0x0c00)<<6);
|
||||||
// int palette = (a2 >> 8) & 0xF0;
|
// int palette = (a2 >> 8) & 0xF0;
|
||||||
|
@ -1560,20 +1397,16 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
if (lineOBJpix < 0)
|
if (lineOBJpix < 0)
|
||||||
continue;
|
continue;
|
||||||
if (sx < 240) {
|
if (sx < 240) {
|
||||||
u8 color =
|
u8 color = vram[address];
|
||||||
vram[address];
|
|
||||||
if (xx & 1) {
|
if (xx & 1) {
|
||||||
color =
|
color = (color >> 4);
|
||||||
(color >>
|
|
||||||
4);
|
|
||||||
} else
|
} else
|
||||||
color &=
|
color &= 0x0F;
|
||||||
0x0F;
|
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
lineOBJWin
|
lineOBJWin
|
||||||
[sx] =
|
[sx]
|
||||||
1;
|
= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sx = (sx + 1) & 511;
|
sx = (sx + 1) & 511;
|
||||||
|
@ -1594,20 +1427,16 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
if (lineOBJpix < 0)
|
if (lineOBJpix < 0)
|
||||||
continue;
|
continue;
|
||||||
if (sx < 240) {
|
if (sx < 240) {
|
||||||
u8 color =
|
u8 color = vram[address];
|
||||||
vram[address];
|
|
||||||
if (xx & 1) {
|
if (xx & 1) {
|
||||||
color =
|
color = (color >> 4);
|
||||||
(color >>
|
|
||||||
4);
|
|
||||||
} else
|
} else
|
||||||
color &=
|
color &= 0x0F;
|
||||||
0x0F;
|
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
lineOBJWin
|
lineOBJWin
|
||||||
[sx] =
|
[sx]
|
||||||
1;
|
= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sx = (sx + 1) & 511;
|
sx = (sx + 1) & 511;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,7 +18,10 @@ enum LinkMode {
|
||||||
/**
|
/**
|
||||||
* State of the connection attempt
|
* State of the connection attempt
|
||||||
*/
|
*/
|
||||||
enum ConnectionState { LINK_OK, LINK_ERROR, LINK_NEEDS_UPDATE, LINK_ABORT };
|
enum ConnectionState { LINK_OK,
|
||||||
|
LINK_ERROR,
|
||||||
|
LINK_NEEDS_UPDATE,
|
||||||
|
LINK_ABORT };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize GBA linking
|
* Initialize GBA linking
|
||||||
|
|
|
@ -46,8 +46,7 @@ char GBASockClient::ReceiveCmd(char* data_in, bool block)
|
||||||
return data_in[0];
|
return data_in[0];
|
||||||
|
|
||||||
std::size_t num_received = 0;
|
std::size_t num_received = 0;
|
||||||
if (block || clock_sync == 0)
|
if (block || clock_sync == 0) {
|
||||||
{
|
|
||||||
sf::SocketSelector Selector;
|
sf::SocketSelector Selector;
|
||||||
Selector.add(client);
|
Selector.add(client);
|
||||||
Selector.wait(sf::seconds(6));
|
Selector.wait(sf::seconds(6));
|
||||||
|
@ -68,8 +67,7 @@ void GBASockClient::ReceiveClock(bool block)
|
||||||
if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected)
|
if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected)
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
if (num_received == 4)
|
if (num_received == 4) {
|
||||||
{
|
|
||||||
clock_sync_ticks = 0;
|
clock_sync_ticks = 0;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
clock_sync_ticks |= (u8)(sync_ticks[i]) << ((3 - i) * 8);
|
clock_sync_ticks |= (u8)(sync_ticks[i]) << ((3 - i) * 8);
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
#include "../common/Types.h"
|
#include "../common/Types.h"
|
||||||
#include <SFML/Network.hpp>
|
#include <SFML/Network.hpp>
|
||||||
|
|
||||||
class GBASockClient
|
class GBASockClient {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
GBASockClient(sf::IpAddress _server_addr);
|
GBASockClient(sf::IpAddress _server_addr);
|
||||||
~GBASockClient();
|
~GBASockClient();
|
||||||
|
|
|
@ -144,12 +144,10 @@ inline int codeTicksAccess16(u32 address) // THUMB NON SEQ
|
||||||
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
||||||
if (busPrefetchCount & 0x1) {
|
if (busPrefetchCount & 0x1) {
|
||||||
if (busPrefetchCount & 0x2) {
|
if (busPrefetchCount & 0x2) {
|
||||||
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) |
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
(busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
busPrefetchCount =
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return memoryWaitSeq[addr] - 1;
|
return memoryWaitSeq[addr] - 1;
|
||||||
} else {
|
} else {
|
||||||
busPrefetchCount = 0;
|
busPrefetchCount = 0;
|
||||||
|
@ -168,12 +166,10 @@ inline int codeTicksAccess32(u32 address) // ARM NON SEQ
|
||||||
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
||||||
if (busPrefetchCount & 0x1) {
|
if (busPrefetchCount & 0x1) {
|
||||||
if (busPrefetchCount & 0x2) {
|
if (busPrefetchCount & 0x2) {
|
||||||
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) |
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
(busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
busPrefetchCount =
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return memoryWaitSeq[addr] - 1;
|
return memoryWaitSeq[addr] - 1;
|
||||||
} else {
|
} else {
|
||||||
busPrefetchCount = 0;
|
busPrefetchCount = 0;
|
||||||
|
@ -191,8 +187,7 @@ inline int codeTicksAccessSeq16(u32 address) // THUMB SEQ
|
||||||
|
|
||||||
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
||||||
if (busPrefetchCount & 0x1) {
|
if (busPrefetchCount & 0x1) {
|
||||||
busPrefetchCount =
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (busPrefetchCount > 0xFF) {
|
} else if (busPrefetchCount > 0xFF) {
|
||||||
busPrefetchCount = 0;
|
busPrefetchCount = 0;
|
||||||
|
@ -212,12 +207,10 @@ inline int codeTicksAccessSeq32(u32 address) // ARM SEQ
|
||||||
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
if ((addr >= 0x08) && (addr <= 0x0D)) {
|
||||||
if (busPrefetchCount & 0x1) {
|
if (busPrefetchCount & 0x1) {
|
||||||
if (busPrefetchCount & 0x2) {
|
if (busPrefetchCount & 0x2) {
|
||||||
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) |
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
(busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
busPrefetchCount =
|
busPrefetchCount = ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
||||||
((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00);
|
|
||||||
return memoryWaitSeq[addr];
|
return memoryWaitSeq[addr];
|
||||||
} else if (busPrefetchCount > 0xFF) {
|
} else if (busPrefetchCount > 0xFF) {
|
||||||
busPrefetchCount = 0;
|
busPrefetchCount = 0;
|
||||||
|
|
|
@ -154,8 +154,7 @@ static inline u32 CPUReadMemory(u32 address)
|
||||||
if (armState) {
|
if (armState) {
|
||||||
return CPUReadMemoryQuick(reg[15].I);
|
return CPUReadMemoryQuick(reg[15].I);
|
||||||
} else {
|
} else {
|
||||||
return CPUReadHalfWordQuick(reg[15].I) |
|
return CPUReadHalfWordQuick(reg[15].I) | CPUReadHalfWordQuick(reg[15].I) << 16;
|
||||||
CPUReadHalfWordQuick(reg[15].I) << 16;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -242,17 +241,13 @@ static inline u32 CPUReadHalfWord(u32 address)
|
||||||
value = READ16LE(((u16*)&ioMem[address & 0x3fe]));
|
value = READ16LE(((u16*)&ioMem[address & 0x3fe]));
|
||||||
if (((address & 0x3fe) > 0xFF) && ((address & 0x3fe) < 0x10E)) {
|
if (((address & 0x3fe) > 0xFF) && ((address & 0x3fe) < 0x10E)) {
|
||||||
if (((address & 0x3fe) == 0x100) && timer0On)
|
if (((address & 0x3fe) == 0x100) && timer0On)
|
||||||
value = 0xFFFF - ((timer0Ticks - cpuTotalTicks) >>
|
value = 0xFFFF - ((timer0Ticks - cpuTotalTicks) >> timer0ClockReload);
|
||||||
timer0ClockReload);
|
|
||||||
else if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4))
|
else if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4))
|
||||||
value = 0xFFFF - ((timer1Ticks - cpuTotalTicks) >>
|
value = 0xFFFF - ((timer1Ticks - cpuTotalTicks) >> timer1ClockReload);
|
||||||
timer1ClockReload);
|
|
||||||
else if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4))
|
else if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4))
|
||||||
value = 0xFFFF - ((timer2Ticks - cpuTotalTicks) >>
|
value = 0xFFFF - ((timer2Ticks - cpuTotalTicks) >> timer2ClockReload);
|
||||||
timer2ClockReload);
|
|
||||||
else if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4))
|
else if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4))
|
||||||
value = 0xFFFF - ((timer3Ticks - cpuTotalTicks) >>
|
value = 0xFFFF - ((timer3Ticks - cpuTotalTicks) >> timer3ClockReload);
|
||||||
timer3ClockReload);
|
|
||||||
}
|
}
|
||||||
} else if ((address < 0x4000400) && ioReadable[address & 0x3fc]) {
|
} else if ((address < 0x4000400) && ioReadable[address & 0x3fc]) {
|
||||||
value = 0;
|
value = 0;
|
||||||
|
@ -750,12 +745,10 @@ static inline void CPUWriteByte(u32 address, u8 b)
|
||||||
u32 lowerBits = address & 0x3fe;
|
u32 lowerBits = address & 0x3fe;
|
||||||
if (address & 1) {
|
if (address & 1) {
|
||||||
CPUUpdateRegister(lowerBits,
|
CPUUpdateRegister(lowerBits,
|
||||||
(READ16LE(&ioMem[lowerBits]) & 0x00FF) |
|
(READ16LE(&ioMem[lowerBits]) & 0x00FF) | (b << 8));
|
||||||
(b << 8));
|
|
||||||
} else {
|
} else {
|
||||||
CPUUpdateRegister(lowerBits,
|
CPUUpdateRegister(lowerBits,
|
||||||
(READ16LE(&ioMem[lowerBits]) & 0xFF00) |
|
(READ16LE(&ioMem[lowerBits]) & 0xFF00) | b);
|
||||||
b);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode0RenderLine()
|
void mode0RenderLine()
|
||||||
{
|
{
|
||||||
|
@ -185,8 +185,7 @@ void mode0RenderLineNoWindow()
|
||||||
switch (effect) {
|
switch (effect) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -229,10 +228,8 @@ void mode0RenderLineNoWindow()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
@ -443,8 +440,7 @@ void mode0RenderLineAll()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -488,8 +484,7 @@ void mode0RenderLineAll()
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode1RenderLine()
|
void mode1RenderLine()
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,6 @@ void mode1RenderLineNoWindow()
|
||||||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (layerEnable & 0x0200) {
|
if (layerEnable & 0x0200) {
|
||||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||||
}
|
}
|
||||||
|
@ -175,8 +174,7 @@ void mode1RenderLineNoWindow()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -213,8 +211,7 @@ void mode1RenderLineNoWindow()
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
@ -414,8 +411,7 @@ void mode1RenderLineAll()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -453,8 +449,7 @@ void mode1RenderLineAll()
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode2RenderLine()
|
void mode2RenderLine()
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,6 @@ void mode2RenderLine()
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
|
|
||||||
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
|
@ -148,7 +147,6 @@ void mode2RenderLineNoWindow()
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
|
|
||||||
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
|
@ -168,8 +166,7 @@ void mode2RenderLineNoWindow()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -200,8 +197,7 @@ void mode2RenderLineNoWindow()
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
@ -390,8 +386,7 @@ void mode2RenderLineAll()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -422,8 +417,7 @@ void mode2RenderLineAll()
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode3RenderLine()
|
void mode3RenderLine()
|
||||||
{
|
{
|
||||||
|
@ -136,8 +136,7 @@ void mode3RenderLineNoWindow()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -160,10 +159,8 @@ void mode3RenderLineNoWindow()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
@ -328,8 +325,7 @@ void mode3RenderLineAll()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -352,10 +348,8 @@ void mode3RenderLineAll()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
|
|
@ -134,8 +134,7 @@ void mode4RenderLineNoWindow()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -158,10 +157,8 @@ void mode4RenderLineNoWindow()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
@ -325,8 +322,7 @@ void mode4RenderLineAll()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -349,10 +345,8 @@ void mode4RenderLineAll()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode5RenderLine()
|
void mode5RenderLine()
|
||||||
{
|
{
|
||||||
|
@ -136,8 +136,7 @@ void mode5RenderLineNoWindow()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -160,10 +159,8 @@ void mode5RenderLineNoWindow()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
@ -328,8 +325,7 @@ void mode5RenderLineAll()
|
||||||
switch ((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: {
|
||||||
{
|
|
||||||
if (top & BLDMOD) {
|
if (top & BLDMOD) {
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
@ -352,10 +348,8 @@ void mode5RenderLineAll()
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
if (BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
|
|
134
src/gba/RTC.cpp
134
src/gba/RTC.cpp
|
@ -1,16 +1,15 @@
|
||||||
|
#include "../NLS.h"
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
#include "../Util.h"
|
||||||
|
#include "../common/Port.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "../common/Port.h"
|
|
||||||
#include "../Util.h"
|
|
||||||
#include "../NLS.h"
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
enum RTCSTATE
|
enum RTCSTATE {
|
||||||
{
|
|
||||||
IDLE = 0,
|
IDLE = 0,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
DATA,
|
DATA,
|
||||||
|
@ -59,8 +58,7 @@ u16 rtcRead(u32 address)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
switch (address)
|
switch (address) {
|
||||||
{
|
|
||||||
case 0x80000c8:
|
case 0x80000c8:
|
||||||
return rtcClockData.enable;
|
return rtcClockData.enable;
|
||||||
break;
|
break;
|
||||||
|
@ -70,31 +68,26 @@ u16 rtcRead(u32 address)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80000c4:
|
case 0x80000c4:
|
||||||
if (!(rtcClockData.enable & 1))
|
if (!(rtcClockData.enable & 1)) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boktai Solar Sensor
|
// Boktai Solar Sensor
|
||||||
if (rtcClockData.select == 0x07)
|
if (rtcClockData.select == 0x07) {
|
||||||
{
|
if (rtcClockData.reserved[11] >= systemGetSensorDarkness()) {
|
||||||
if (rtcClockData.reserved[11] >= systemGetSensorDarkness())
|
|
||||||
{
|
|
||||||
res |= 8;
|
res |= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarioWare Twisted Tilt Sensor
|
// WarioWare Twisted Tilt Sensor
|
||||||
if (rtcClockData.select == 0x0b)
|
if (rtcClockData.select == 0x0b) {
|
||||||
{
|
|
||||||
u16 v = systemGetSensorZ();
|
u16 v = systemGetSensorZ();
|
||||||
v = 0x6C0 + v;
|
v = 0x6C0 + v;
|
||||||
res |= ((v >> rtcClockData.reserved[11]) & 1) << 2;
|
res |= ((v >> rtcClockData.reserved[11]) & 1) << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Real Time Clock
|
// Real Time Clock
|
||||||
if (rtcClockEnabled && (rtcClockData.select & 0x04))
|
if (rtcClockEnabled && (rtcClockData.select & 0x04)) {
|
||||||
{
|
|
||||||
res |= rtcClockData.byte0;
|
res |= rtcClockData.byte0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +117,7 @@ void rtcUpdateTime(int ticks)
|
||||||
{
|
{
|
||||||
countTicks += ticks;
|
countTicks += ticks;
|
||||||
|
|
||||||
if (countTicks > TICKS_PER_SECOND)
|
if (countTicks > TICKS_PER_SECOND) {
|
||||||
{
|
|
||||||
countTicks -= TICKS_PER_SECOND;
|
countTicks -= TICKS_PER_SECOND;
|
||||||
gba_time.tm_sec++;
|
gba_time.tm_sec++;
|
||||||
mktime(&gba_time);
|
mktime(&gba_time);
|
||||||
|
@ -134,43 +126,33 @@ void rtcUpdateTime(int ticks)
|
||||||
|
|
||||||
bool rtcWrite(u32 address, u16 value)
|
bool rtcWrite(u32 address, u16 value)
|
||||||
{
|
{
|
||||||
if (address == 0x80000c8)
|
if (address == 0x80000c8) {
|
||||||
{
|
|
||||||
rtcClockData.enable = (u8)value; // bit 0 = enable reading from 0x80000c4 c6 and c8
|
rtcClockData.enable = (u8)value; // bit 0 = enable reading from 0x80000c4 c6 and c8
|
||||||
}
|
} else if (address == 0x80000c6) {
|
||||||
else if (address == 0x80000c6)
|
|
||||||
{
|
|
||||||
rtcClockData.select = (u8)value; // 0=read/1=write (for each of 4 low bits)
|
rtcClockData.select = (u8)value; // 0=read/1=write (for each of 4 low bits)
|
||||||
|
|
||||||
// rumble is off when not writing to that pin
|
// rumble is off when not writing to that pin
|
||||||
if (rtcRumbleEnabled && !(value & 8)) systemCartridgeRumble(false);
|
if (rtcRumbleEnabled && !(value & 8))
|
||||||
}
|
systemCartridgeRumble(false);
|
||||||
else if (address == 0x80000c4) // 4 bits of I/O Port Data (upper bits not used)
|
} else if (address == 0x80000c4) // 4 bits of I/O Port Data (upper bits not used)
|
||||||
{
|
{
|
||||||
// WarioWare Twisted rumble
|
// WarioWare Twisted rumble
|
||||||
if (rtcRumbleEnabled && (rtcClockData.select & 0x08))
|
if (rtcRumbleEnabled && (rtcClockData.select & 0x08)) {
|
||||||
{
|
|
||||||
systemCartridgeRumble(value & 8);
|
systemCartridgeRumble(value & 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boktai solar sensor
|
// Boktai solar sensor
|
||||||
if (rtcClockData.select == 0x07)
|
if (rtcClockData.select == 0x07) {
|
||||||
{
|
if (value & 2) {
|
||||||
if (value & 2)
|
|
||||||
{
|
|
||||||
// reset counter to 0
|
// reset counter to 0
|
||||||
rtcClockData.reserved[11] = 0;
|
rtcClockData.reserved[11] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value & 1) && !(rtcClockData.reserved[10] & 1))
|
if ((value & 1) && !(rtcClockData.reserved[10] & 1)) {
|
||||||
{
|
|
||||||
// increase counter, ready to do another read
|
// increase counter, ready to do another read
|
||||||
if (rtcClockData.reserved[11] < 255)
|
if (rtcClockData.reserved[11] < 255) {
|
||||||
{
|
|
||||||
rtcClockData.reserved[11]++;
|
rtcClockData.reserved[11]++;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
rtcClockData.reserved[11] = 0;
|
rtcClockData.reserved[11] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,16 +161,13 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarioWare Twisted rotation sensor
|
// WarioWare Twisted rotation sensor
|
||||||
if (rtcClockData.select == 0x0b)
|
if (rtcClockData.select == 0x0b) {
|
||||||
{
|
if (value & 2) {
|
||||||
if (value & 2)
|
|
||||||
{
|
|
||||||
// clock goes high in preperation for reading a bit
|
// clock goes high in preperation for reading a bit
|
||||||
rtcClockData.reserved[11]--;
|
rtcClockData.reserved[11]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value & 1)
|
if (value & 1) {
|
||||||
{
|
|
||||||
// start ADC conversion
|
// start ADC conversion
|
||||||
rtcClockData.reserved[11] = 15;
|
rtcClockData.reserved[11] = 15;
|
||||||
}
|
}
|
||||||
|
@ -197,30 +176,24 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Real Time Clock
|
// Real Time Clock
|
||||||
if (rtcClockData.select & 4)
|
if (rtcClockData.select & 4) {
|
||||||
{
|
if (rtcClockData.state == IDLE && rtcClockData.byte0 == 1 && value == 5) {
|
||||||
if (rtcClockData.state == IDLE && rtcClockData.byte0 == 1 && value == 5)
|
|
||||||
{
|
|
||||||
rtcClockData.state = COMMAND;
|
rtcClockData.state = COMMAND;
|
||||||
rtcClockData.bits = 0;
|
rtcClockData.bits = 0;
|
||||||
rtcClockData.command = 0;
|
rtcClockData.command = 0;
|
||||||
}
|
} else if (!(rtcClockData.byte0 & 1) && (value & 1)) // bit transfer
|
||||||
else if (!(rtcClockData.byte0 & 1) && (value & 1)) // bit transfer
|
|
||||||
{
|
{
|
||||||
rtcClockData.byte0 = (u8)value;
|
rtcClockData.byte0 = (u8)value;
|
||||||
|
|
||||||
switch (rtcClockData.state)
|
switch (rtcClockData.state) {
|
||||||
{
|
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
rtcClockData.command |= ((value & 2) >> 1) << (7 - rtcClockData.bits);
|
rtcClockData.command |= ((value & 2) >> 1) << (7 - rtcClockData.bits);
|
||||||
rtcClockData.bits++;
|
rtcClockData.bits++;
|
||||||
|
|
||||||
if (rtcClockData.bits == 8)
|
if (rtcClockData.bits == 8) {
|
||||||
{
|
|
||||||
rtcClockData.bits = 0;
|
rtcClockData.bits = 0;
|
||||||
|
|
||||||
switch (rtcClockData.command)
|
switch (rtcClockData.command) {
|
||||||
{
|
|
||||||
case 0x60:
|
case 0x60:
|
||||||
// not sure what this command does but it doesn't take parameters
|
// not sure what this command does but it doesn't take parameters
|
||||||
// maybe it is a reset or stop
|
// maybe it is a reset or stop
|
||||||
|
@ -243,8 +216,7 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
case 0x64:
|
case 0x64:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x65:
|
case 0x65: {
|
||||||
{
|
|
||||||
if (rtcEnabled)
|
if (rtcEnabled)
|
||||||
SetGBATime();
|
SetGBATime();
|
||||||
|
|
||||||
|
@ -257,11 +229,9 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
rtcClockData.data[5] = toBCD(gba_time.tm_min);
|
rtcClockData.data[5] = toBCD(gba_time.tm_min);
|
||||||
rtcClockData.data[6] = toBCD(gba_time.tm_sec);
|
rtcClockData.data[6] = toBCD(gba_time.tm_sec);
|
||||||
rtcClockData.state = DATA;
|
rtcClockData.state = DATA;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x67:
|
case 0x67: {
|
||||||
{
|
|
||||||
if (rtcEnabled)
|
if (rtcEnabled)
|
||||||
SetGBATime();
|
SetGBATime();
|
||||||
|
|
||||||
|
@ -270,8 +240,7 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
rtcClockData.data[1] = toBCD(gba_time.tm_min);
|
rtcClockData.data[1] = toBCD(gba_time.tm_min);
|
||||||
rtcClockData.data[2] = toBCD(gba_time.tm_sec);
|
rtcClockData.data[2] = toBCD(gba_time.tm_sec);
|
||||||
rtcClockData.state = DATA;
|
rtcClockData.state = DATA;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log(N_("Unknown RTC command %02x"), rtcClockData.command);
|
log(N_("Unknown RTC command %02x"), rtcClockData.command);
|
||||||
|
@ -283,18 +252,12 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DATA:
|
case DATA:
|
||||||
if (rtcClockData.select & 2)
|
if (rtcClockData.select & 2) {
|
||||||
{
|
} else if (rtcClockData.select & 4) {
|
||||||
}
|
rtcClockData.byte0 = (rtcClockData.byte0 & ~2) | ((rtcClockData.data[rtcClockData.bits >> 3] >> (rtcClockData.bits & 7)) & 1) * 2;
|
||||||
else if (rtcClockData.select & 4)
|
|
||||||
{
|
|
||||||
rtcClockData.byte0 = (rtcClockData.byte0 & ~2) |
|
|
||||||
((rtcClockData.data[rtcClockData.bits >> 3] >>
|
|
||||||
(rtcClockData.bits & 7)) & 1) * 2;
|
|
||||||
rtcClockData.bits++;
|
rtcClockData.bits++;
|
||||||
|
|
||||||
if (rtcClockData.bits == 8 * rtcClockData.dataLen)
|
if (rtcClockData.bits == 8 * rtcClockData.dataLen) {
|
||||||
{
|
|
||||||
rtcClockData.bits = 0;
|
rtcClockData.bits = 0;
|
||||||
rtcClockData.state = IDLE;
|
rtcClockData.state = IDLE;
|
||||||
}
|
}
|
||||||
|
@ -303,18 +266,12 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case READDATA:
|
case READDATA:
|
||||||
if (!(rtcClockData.select & 2))
|
if (!(rtcClockData.select & 2)) {
|
||||||
{
|
} else {
|
||||||
}
|
rtcClockData.data[rtcClockData.bits >> 3] = (rtcClockData.data[rtcClockData.bits >> 3] >> 1) | ((value << 6) & 128);
|
||||||
else
|
|
||||||
{
|
|
||||||
rtcClockData.data[rtcClockData.bits >> 3] =
|
|
||||||
(rtcClockData.data[rtcClockData.bits >> 3] >> 1) |
|
|
||||||
((value << 6) & 128);
|
|
||||||
rtcClockData.bits++;
|
rtcClockData.bits++;
|
||||||
|
|
||||||
if (rtcClockData.bits == 8 * rtcClockData.dataLen)
|
if (rtcClockData.bits == 8 * rtcClockData.dataLen) {
|
||||||
{
|
|
||||||
rtcClockData.bits = 0;
|
rtcClockData.bits = 0;
|
||||||
rtcClockData.state = IDLE;
|
rtcClockData.state = IDLE;
|
||||||
}
|
}
|
||||||
|
@ -325,8 +282,7 @@ bool rtcWrite(u32 address, u16 value)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
rtcClockData.byte0 = (u8)value;
|
rtcClockData.byte0 = (u8)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
#include "GBA.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../common/Port.h"
|
#include "../common/Port.h"
|
||||||
|
#include "GBA.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
#include "../apu/Gb_Apu.h"
|
#include "../apu/Gb_Apu.h"
|
||||||
#include "../apu/Multi_Buffer.h"
|
#include "../apu/Multi_Buffer.h"
|
||||||
|
@ -84,8 +84,8 @@ public:
|
||||||
int writeIndex;
|
int writeIndex;
|
||||||
u8 fifo[32];
|
u8 fifo[32];
|
||||||
int dac;
|
int dac;
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
int timer;
|
int timer;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
@ -118,17 +118,20 @@ void Gba_Pcm::apply_control( int idx )
|
||||||
ch = ioMem[SGCNT0_H + 1] >> (idx * 4) & 3;
|
ch = ioMem[SGCNT0_H + 1] >> (idx * 4) & 3;
|
||||||
|
|
||||||
Blip_Buffer* out = 0;
|
Blip_Buffer* out = 0;
|
||||||
switch ( ch )
|
switch (ch) {
|
||||||
{
|
case 1:
|
||||||
case 1: out = stereo_buffer->right(); break;
|
out = stereo_buffer->right();
|
||||||
case 2: out = stereo_buffer->left(); break;
|
break;
|
||||||
case 3: out = stereo_buffer->center(); break;
|
case 2:
|
||||||
|
out = stereo_buffer->left();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
out = stereo_buffer->center();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( output != out )
|
if (output != out) {
|
||||||
{
|
if (output) {
|
||||||
if ( output )
|
|
||||||
{
|
|
||||||
output->set_modified();
|
output->set_modified();
|
||||||
pcm_synth[0].offset(blip_time(), -last_amp, output);
|
pcm_synth[0].offset(blip_time(), -last_amp, output);
|
||||||
}
|
}
|
||||||
|
@ -149,19 +152,16 @@ void Gba_Pcm::end_frame( blip_time_t time )
|
||||||
|
|
||||||
void Gba_Pcm::update(int dac)
|
void Gba_Pcm::update(int dac)
|
||||||
{
|
{
|
||||||
if ( output )
|
if (output) {
|
||||||
{
|
|
||||||
blip_time_t time = blip_time();
|
blip_time_t time = blip_time();
|
||||||
|
|
||||||
dac = (s8)dac >> shift;
|
dac = (s8)dac >> shift;
|
||||||
int delta = dac - last_amp;
|
int delta = dac - last_amp;
|
||||||
if ( delta )
|
if (delta) {
|
||||||
{
|
|
||||||
last_amp = dac;
|
last_amp = dac;
|
||||||
|
|
||||||
int filter = 0;
|
int filter = 0;
|
||||||
if ( soundInterpolation )
|
if (soundInterpolation) {
|
||||||
{
|
|
||||||
// base filtering on how long since last sample was output
|
// base filtering on how long since last sample was output
|
||||||
int period = time - last_time;
|
int period = time - last_time;
|
||||||
|
|
||||||
|
@ -181,22 +181,18 @@ void Gba_Pcm::update( int dac )
|
||||||
|
|
||||||
void Gba_Pcm_Fifo::timer_overflowed(int which_timer)
|
void Gba_Pcm_Fifo::timer_overflowed(int which_timer)
|
||||||
{
|
{
|
||||||
if ( which_timer == timer && enabled )
|
if (which_timer == timer && enabled) {
|
||||||
{
|
|
||||||
/* Mother 3 fix, refined to not break Metroid Fusion */
|
/* Mother 3 fix, refined to not break Metroid Fusion */
|
||||||
if ( count == 16 || count == 0 )
|
if (count == 16 || count == 0) {
|
||||||
{
|
|
||||||
// Need to fill FIFO
|
// Need to fill FIFO
|
||||||
int saved_count = count;
|
int saved_count = count;
|
||||||
CPUCheckDMA(3, which ? 4 : 2);
|
CPUCheckDMA(3, which ? 4 : 2);
|
||||||
if (saved_count == 0 && count == 16)
|
if (saved_count == 0 && count == 16)
|
||||||
CPUCheckDMA(3, which ? 4 : 2);
|
CPUCheckDMA(3, which ? 4 : 2);
|
||||||
if ( count == 0 )
|
if (count == 0) {
|
||||||
{
|
|
||||||
// Not filled by DMA, so fill with 16 bytes of silence
|
// Not filled by DMA, so fill with 16 bytes of silence
|
||||||
int reg = which ? FIFOB_L : FIFOA_L;
|
int reg = which ? FIFOB_L : FIFOA_L;
|
||||||
for ( int n = 8; n--; )
|
for (int n = 8; n--;) {
|
||||||
{
|
|
||||||
soundEvent(reg, (u16)0);
|
soundEvent(reg, (u16)0);
|
||||||
soundEvent(reg + 2, (u16)0);
|
soundEvent(reg + 2, (u16)0);
|
||||||
}
|
}
|
||||||
|
@ -216,8 +212,7 @@ void Gba_Pcm_Fifo::write_control( int data )
|
||||||
enabled = (data & 0x0300) ? true : false;
|
enabled = (data & 0x0300) ? true : false;
|
||||||
timer = (data & 0x0400) ? 1 : 0;
|
timer = (data & 0x0400) ? 1 : 0;
|
||||||
|
|
||||||
if ( data & 0x0800 )
|
if (data & 0x0800) {
|
||||||
{
|
|
||||||
// Reset
|
// Reset
|
||||||
writeIndex = 0;
|
writeIndex = 0;
|
||||||
readIndex = 0;
|
readIndex = 0;
|
||||||
|
@ -246,8 +241,7 @@ static void apply_control()
|
||||||
|
|
||||||
static int gba_to_gb_sound(int addr)
|
static int gba_to_gb_sound(int addr)
|
||||||
{
|
{
|
||||||
static const int table [0x40] =
|
static const int table[0x40] = {
|
||||||
{
|
|
||||||
0xFF10, 0, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0, 0,
|
0xFF10, 0, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0, 0,
|
||||||
0xFF16, 0xFF17, 0, 0, 0xFF18, 0xFF19, 0, 0,
|
0xFF16, 0xFF17, 0, 0, 0xFF18, 0xFF19, 0, 0,
|
||||||
0xFF1A, 0, 0xFF1B, 0xFF1C, 0xFF1D, 0xFF1E, 0, 0,
|
0xFF1A, 0, 0xFF1B, 0xFF1C, 0xFF1D, 0xFF1E, 0, 0,
|
||||||
|
@ -265,8 +259,7 @@ static int gba_to_gb_sound( int addr )
|
||||||
void soundEvent(u32 address, u8 data)
|
void soundEvent(u32 address, u8 data)
|
||||||
{
|
{
|
||||||
int gb_addr = gba_to_gb_sound(address);
|
int gb_addr = gba_to_gb_sound(address);
|
||||||
if ( gb_addr )
|
if (gb_addr) {
|
||||||
{
|
|
||||||
ioMem[address] = data;
|
ioMem[address] = data;
|
||||||
gb_apu->write_register(blip_time(), gb_addr, data);
|
gb_apu->write_register(blip_time(), gb_addr, data);
|
||||||
|
|
||||||
|
@ -282,14 +275,12 @@ static void apply_volume( bool apu_only = false )
|
||||||
if (!apu_only)
|
if (!apu_only)
|
||||||
soundVolume_ = soundVolume;
|
soundVolume_ = soundVolume;
|
||||||
|
|
||||||
if ( gb_apu )
|
if (gb_apu) {
|
||||||
{
|
|
||||||
static float const apu_vols[4] = { 0.25, 0.5, 1, 0.25 };
|
static float const apu_vols[4] = { 0.25, 0.5, 1, 0.25 };
|
||||||
gb_apu->volume(soundVolume_ * apu_vols[ioMem[SGCNT0_H] & 3]);
|
gb_apu->volume(soundVolume_ * apu_vols[ioMem[SGCNT0_H] & 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !apu_only )
|
if (!apu_only) {
|
||||||
{
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
pcm_synth[i].volume(0.66 / 256 * soundVolume_);
|
pcm_synth[i].volume(0.66 / 256 * soundVolume_);
|
||||||
}
|
}
|
||||||
|
@ -305,8 +296,7 @@ static void write_SGCNT0_H( int data )
|
||||||
|
|
||||||
void soundEvent(u32 address, u16 data)
|
void soundEvent(u32 address, u16 data)
|
||||||
{
|
{
|
||||||
switch ( address )
|
switch (address) {
|
||||||
{
|
|
||||||
case SGCNT0_H:
|
case SGCNT0_H:
|
||||||
write_SGCNT0_H(data);
|
write_SGCNT0_H(data);
|
||||||
break;
|
break;
|
||||||
|
@ -370,8 +360,7 @@ void flush_samples(Multi_Buffer * buffer)
|
||||||
int const out_buf_size = soundBufferLen / sizeof *soundFinalWave;
|
int const out_buf_size = soundBufferLen / sizeof *soundFinalWave;
|
||||||
|
|
||||||
// Keep filling and writing soundFinalWave until it can't be fully filled
|
// Keep filling and writing soundFinalWave until it can't be fully filled
|
||||||
while ( buffer->samples_avail() >= out_buf_size )
|
while (buffer->samples_avail() >= out_buf_size) {
|
||||||
{
|
|
||||||
buffer->read_samples((blip_sample_t*)soundFinalWave, out_buf_size);
|
buffer->read_samples((blip_sample_t*)soundFinalWave, out_buf_size);
|
||||||
if (soundPaused)
|
if (soundPaused)
|
||||||
soundResume();
|
soundResume();
|
||||||
|
@ -389,8 +378,7 @@ static void apply_filtering()
|
||||||
int const base_freq = (int)(32768 - soundFiltering_ * 16384);
|
int const base_freq = (int)(32768 - soundFiltering_ * 16384);
|
||||||
int const nyquist = stereo_buffer->sample_rate() / 2;
|
int const nyquist = stereo_buffer->sample_rate() / 2;
|
||||||
|
|
||||||
for ( int i = 0; i < 3; i++ )
|
for (int i = 0; i < 3; i++) {
|
||||||
{
|
|
||||||
int cutoff = base_freq >> i;
|
int cutoff = base_freq >> i;
|
||||||
if (cutoff > nyquist)
|
if (cutoff > nyquist)
|
||||||
cutoff = nyquist;
|
cutoff = nyquist;
|
||||||
|
@ -400,8 +388,7 @@ static void apply_filtering()
|
||||||
|
|
||||||
void psoundTickfn()
|
void psoundTickfn()
|
||||||
{
|
{
|
||||||
if ( gb_apu && stereo_buffer )
|
if (gb_apu && stereo_buffer) {
|
||||||
{
|
|
||||||
// Run sound hardware to present
|
// Run sound hardware to present
|
||||||
end_frame(SOUND_CLOCK_TICKS);
|
end_frame(SOUND_CLOCK_TICKS);
|
||||||
|
|
||||||
|
@ -423,11 +410,9 @@ static void apply_muting()
|
||||||
// PCM
|
// PCM
|
||||||
apply_control();
|
apply_control();
|
||||||
|
|
||||||
if ( gb_apu )
|
if (gb_apu) {
|
||||||
{
|
|
||||||
// APU
|
// APU
|
||||||
for ( int i = 0; i < 4; i++ )
|
for (int i = 0; i < 4; i++) {
|
||||||
{
|
|
||||||
if (soundEnableFlag >> i & 1)
|
if (soundEnableFlag >> i & 1)
|
||||||
gb_apu->set_output(stereo_buffer->center(),
|
gb_apu->set_output(stereo_buffer->center(),
|
||||||
stereo_buffer->left(), stereo_buffer->right(), i);
|
stereo_buffer->left(), stereo_buffer->right(), i);
|
||||||
|
@ -457,8 +442,7 @@ static void remake_stereo_buffer()
|
||||||
pcm[1].pcm.init();
|
pcm[1].pcm.init();
|
||||||
|
|
||||||
// APU
|
// APU
|
||||||
if ( !gb_apu )
|
if (!gb_apu) {
|
||||||
{
|
|
||||||
gb_apu = new Gb_Apu; // TODO: handle out of memory
|
gb_apu = new Gb_Apu; // TODO: handle out of memory
|
||||||
reset_apu();
|
reset_apu();
|
||||||
}
|
}
|
||||||
|
@ -483,8 +467,7 @@ static void remake_stereo_buffer()
|
||||||
|
|
||||||
void soundShutdown()
|
void soundShutdown()
|
||||||
{
|
{
|
||||||
if (soundDriver)
|
if (soundDriver) {
|
||||||
{
|
|
||||||
delete soundDriver;
|
delete soundDriver;
|
||||||
soundDriver = 0;
|
soundDriver = 0;
|
||||||
}
|
}
|
||||||
|
@ -574,16 +557,12 @@ long soundGetSampleRate()
|
||||||
|
|
||||||
void soundSetSampleRate(long sampleRate)
|
void soundSetSampleRate(long sampleRate)
|
||||||
{
|
{
|
||||||
if ( soundSampleRate != sampleRate )
|
if (soundSampleRate != sampleRate) {
|
||||||
{
|
if (systemCanChangeSoundQuality()) {
|
||||||
if ( systemCanChangeSoundQuality() )
|
|
||||||
{
|
|
||||||
soundShutdown();
|
soundShutdown();
|
||||||
soundSampleRate = sampleRate;
|
soundSampleRate = sampleRate;
|
||||||
soundInit();
|
soundInit();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
soundSampleRate = sampleRate;
|
soundSampleRate = sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,9 +572,15 @@ void soundSetSampleRate(long sampleRate)
|
||||||
|
|
||||||
static int dummy_state[16];
|
static int dummy_state[16];
|
||||||
|
|
||||||
#define SKIP( type, name ) { dummy_state, sizeof (type) }
|
#define SKIP(type, name) \
|
||||||
|
{ \
|
||||||
|
dummy_state, sizeof(type) \
|
||||||
|
}
|
||||||
|
|
||||||
#define LOAD( type, name ) { &name, sizeof (type) }
|
#define LOAD(type, name) \
|
||||||
|
{ \
|
||||||
|
&name, sizeof(type) \
|
||||||
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
gb_apu_state_t apu;
|
gb_apu_state_t apu;
|
||||||
|
@ -606,8 +591,7 @@ static struct {
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
// Old GBA sound state format
|
// Old GBA sound state format
|
||||||
static variable_desc old_gba_state [] =
|
static variable_desc old_gba_state[] = {
|
||||||
{
|
|
||||||
SKIP(int, soundPaused),
|
SKIP(int, soundPaused),
|
||||||
SKIP(int, soundPlay),
|
SKIP(int, soundPlay),
|
||||||
SKIP(int, soundTicks),
|
SKIP(int, soundTicks),
|
||||||
|
@ -684,8 +668,7 @@ static variable_desc old_gba_state [] =
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
variable_desc old_gba_state2 [] =
|
variable_desc old_gba_state2[] = {
|
||||||
{
|
|
||||||
LOAD(u8[0x20], state.apu.regs[0x20]),
|
LOAD(u8[0x20], state.apu.regs[0x20]),
|
||||||
SKIP(int, sound3Bank),
|
SKIP(int, sound3Bank),
|
||||||
SKIP(int, sound3DataSize),
|
SKIP(int, sound3DataSize),
|
||||||
|
@ -694,8 +677,7 @@ variable_desc old_gba_state2 [] =
|
||||||
};
|
};
|
||||||
|
|
||||||
// New state format
|
// New state format
|
||||||
static variable_desc gba_state [] =
|
static variable_desc gba_state[] = {
|
||||||
{
|
|
||||||
// PCM
|
// PCM
|
||||||
LOAD(int, pcm[0].readIndex),
|
LOAD(int, pcm[0].readIndex),
|
||||||
LOAD(int, pcm[0].count),
|
LOAD(int, pcm[0].count),
|
||||||
|
@ -744,7 +726,6 @@ static variable_desc gba_state [] =
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
void soundSaveGame(u8*& out)
|
void soundSaveGame(u8*& out)
|
||||||
#else
|
#else
|
||||||
|
@ -769,8 +750,7 @@ static void skip_read( gzFile in, int count )
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
while ( count )
|
while (count) {
|
||||||
{
|
|
||||||
int n = sizeof buf;
|
int n = sizeof buf;
|
||||||
if (n > count)
|
if (n > count)
|
||||||
n = count;
|
n = count;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
#include "Sram.h"
|
||||||
|
#include "Flash.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Flash.h"
|
|
||||||
#include "Sram.h"
|
|
||||||
|
|
||||||
u8 sramRead(u32 address)
|
u8 sramRead(u32 address)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../System.h"
|
||||||
|
#include "../common/Port.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "../common/Port.h"
|
|
||||||
#include "../System.h"
|
|
||||||
|
|
||||||
#define debuggerWriteHalfWord(addr, value) \
|
#define debuggerWriteHalfWord(addr, value) \
|
||||||
WRITE16LE((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask], (value))
|
WRITE16LE((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask], (value))
|
||||||
|
@ -23,8 +23,7 @@ bool agbPrintWrite(u32 address, u16 value)
|
||||||
debuggerWriteHalfWord(address, value);
|
debuggerWriteHalfWord(address, value);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(agbPrintProtect &&
|
if (agbPrintProtect && ((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure
|
||||||
((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure
|
|
||||||
|| (address >= 0x8fd0000 && address <= 0x8fdffff)
|
|| (address >= 0x8fd0000 && address <= 0x8fdffff)
|
||||||
|| (address >= 0x9fd0000 && address <= 0x9fdffff))) {
|
|| (address >= 0x9fd0000 && address <= 0x9fdffff))) {
|
||||||
debuggerWriteHalfWord(address, value);
|
debuggerWriteHalfWord(address, value);
|
||||||
|
|
|
@ -191,14 +191,16 @@ const Opcodes armOpcodes[] = {
|
||||||
{ 0x00000000, 0x00000000, "[ ??? ]" }
|
{ 0x00000000, 0x00000000, "[ ??? ]" }
|
||||||
};
|
};
|
||||||
|
|
||||||
char* addStr(char *dest, const char *src){
|
char* addStr(char* dest, const char* src)
|
||||||
|
{
|
||||||
while (*src) {
|
while (*src) {
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* addHex(char *dest, int siz, u32 val){
|
char* addHex(char* dest, int siz, u32 val)
|
||||||
|
{
|
||||||
if (siz == 0) {
|
if (siz == 0) {
|
||||||
siz = 28;
|
siz = 28;
|
||||||
while ((((val >> siz) & 15) == 0) && (siz >= 4))
|
while ((((val >> siz) & 15) == 0) && (siz >= 4))
|
||||||
|
@ -212,7 +214,8 @@ char* addHex(char *dest, int siz, u32 val){
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int disArm(u32 offset, char *dest, int flags){
|
int disArm(u32 offset, char* dest, int flags)
|
||||||
|
{
|
||||||
u32 opcode = debuggerReadMemory(offset);
|
u32 opcode = debuggerReadMemory(offset);
|
||||||
|
|
||||||
const Opcodes* sp = armOpcodes;
|
const Opcodes* sp = armOpcodes;
|
||||||
|
@ -241,16 +244,14 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
case 'r':
|
case 'r':
|
||||||
dest = addStr(dest, regs[(opcode >> ((*(++src) - '0') * 4)) & 15]);
|
dest = addStr(dest, regs[(opcode >> ((*(++src) - '0') * 4)) & 15]);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o': {
|
||||||
{
|
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
int off = opcode & 0xffffff;
|
int off = opcode & 0xffffff;
|
||||||
if (off & 0x800000)
|
if (off & 0x800000)
|
||||||
off |= 0xff000000;
|
off |= 0xff000000;
|
||||||
off <<= 2;
|
off <<= 2;
|
||||||
dest = addHex(dest, 32, offset + 8 + off);
|
dest = addHex(dest, 32, offset + 8 + off);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 'i':
|
case 'i':
|
||||||
if (opcode & (1 << 25)) {
|
if (opcode & (1 << 25)) {
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
|
@ -466,23 +467,19 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
else
|
else
|
||||||
dest = addStr(dest, decVals[(opcode >> 20) & 15]);
|
dest = addStr(dest, decVals[(opcode >> 20) & 15]);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R': {
|
||||||
{
|
|
||||||
src++;
|
src++;
|
||||||
int reg = 4 * (*src - '0');
|
int reg = 4 * (*src - '0');
|
||||||
*dest++ = 'c';
|
*dest++ = 'c';
|
||||||
dest = addStr(dest, decVals[(opcode >> reg) & 15]);
|
dest = addStr(dest, decVals[(opcode >> reg) & 15]);
|
||||||
}
|
} break;
|
||||||
break;
|
case 'V': {
|
||||||
case 'V':
|
|
||||||
{
|
|
||||||
int val = (opcode >> 5) & 7;
|
int val = (opcode >> 5) & 7;
|
||||||
if (val) {
|
if (val) {
|
||||||
dest = addStr(dest, ", ");
|
dest = addStr(dest, ", ");
|
||||||
dest = addStr(dest, decVals[val]);
|
dest = addStr(dest, decVals[val]);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 'L':
|
case 'L':
|
||||||
if (opcode & (1 << 22))
|
if (opcode & (1 << 22))
|
||||||
*dest++ = 'l';
|
*dest++ = 'l';
|
||||||
|
@ -526,7 +523,8 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int disThumb(u32 offset, char *dest, int flags){
|
int disThumb(u32 offset, char* dest, int flags)
|
||||||
|
{
|
||||||
u32 opcode = debuggerReadHalfWord(offset);
|
u32 opcode = debuggerReadHalfWord(offset);
|
||||||
|
|
||||||
const Opcodes* sp = thumbOpcodes;
|
const Opcodes* sp = thumbOpcodes;
|
||||||
|
@ -578,16 +576,14 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, (opcode >> 6) & 7);
|
dest = addHex(dest, 0, (opcode >> 6) & 7);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h': {
|
||||||
{
|
|
||||||
src++;
|
src++;
|
||||||
int reg = (opcode >> (*src - '0')) & 7;
|
int reg = (opcode >> (*src - '0')) & 7;
|
||||||
src++;
|
src++;
|
||||||
if (opcode & (1 << (*src - '0')))
|
if (opcode & (1 << (*src - '0')))
|
||||||
reg += 8;
|
reg += 8;
|
||||||
dest = addStr(dest, regs[reg]);
|
dest = addStr(dest, regs[reg]);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 'O':
|
case 'O':
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, (opcode & 0xff));
|
dest = addHex(dest, 0, (opcode & 0xff));
|
||||||
|
@ -596,10 +592,8 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest, 32, (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
|
dest = addHex(dest, 32, (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
|
||||||
break;
|
break;
|
||||||
case 'J':
|
case 'J': {
|
||||||
{
|
u32 value = debuggerReadMemory((offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2));
|
||||||
u32 value = debuggerReadMemory((offset&0xfffffffc)+4+
|
|
||||||
((opcode & 0xff)<<2));
|
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest, 32, value);
|
dest = addHex(dest, 32, value);
|
||||||
const char* s = elfGetAddressSymbol(value);
|
const char* s = elfGetAddressSymbol(value);
|
||||||
|
@ -607,10 +601,8 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
dest = addStr(dest, s);
|
dest = addStr(dest, s);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case 'K': {
|
||||||
case 'K':
|
|
||||||
{
|
|
||||||
u32 value = (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2);
|
u32 value = (offset & 0xfffffffc) + 4 + ((opcode & 0xff) << 2);
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest, 32, value);
|
dest = addHex(dest, 32, value);
|
||||||
|
@ -619,8 +611,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
dest = addStr(dest, s);
|
dest = addStr(dest, s);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 'b':
|
case 'b':
|
||||||
if (opcode & (1 << 10))
|
if (opcode & (1 << 10))
|
||||||
*dest++ = 'b';
|
*dest++ = 'b';
|
||||||
|
@ -651,8 +642,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, (opcode & 0x7f) << 2);
|
dest = addHex(dest, 0, (opcode & 0x7f) << 2);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l': {
|
||||||
{
|
|
||||||
int rlst = opcode & 0xff;
|
int rlst = opcode & 0xff;
|
||||||
int msk = 0;
|
int msk = 0;
|
||||||
int not_first = 0;
|
int not_first = 0;
|
||||||
|
@ -676,8 +666,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
} else
|
} else
|
||||||
msk++;
|
msk++;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case 'm':
|
case 'm':
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest, 8, opcode & 0xff);
|
dest = addHex(dest, 8, opcode & 0xff);
|
||||||
|
@ -696,8 +685,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
dest = addHex(dest, 32, offset + 4 + add);
|
dest = addHex(dest, 32, offset + 4 + add);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A': {
|
||||||
{
|
|
||||||
int nopcode = debuggerReadHalfWord(offset + 2);
|
int nopcode = debuggerReadHalfWord(offset + 2);
|
||||||
int add = opcode & 0x7ff;
|
int add = opcode & 0x7ff;
|
||||||
if (add & 0x400)
|
if (add & 0x400)
|
||||||
|
@ -713,8 +701,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
||||||
*dest++ = ')';
|
*dest++ = ')';
|
||||||
}
|
}
|
||||||
ret = 4;
|
ret = 4;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
198
src/gba/bios.cpp
198
src/gba/bios.cpp
|
@ -3,9 +3,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "bios.h"
|
|
||||||
#include "GBAinline.h"
|
#include "GBAinline.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
#include "bios.h"
|
||||||
|
|
||||||
s16 sineTable[256] = {
|
s16 sineTable[256] = {
|
||||||
(s16)0x0000, (s16)0x0192, (s16)0x0323, (s16)0x04B5, (s16)0x0645, (s16)0x07D5, (s16)0x0964, (s16)0x0AF1,
|
(s16)0x0000, (s16)0x0192, (s16)0x0323, (s16)0x04B5, (s16)0x0645, (s16)0x07D5, (s16)0x0964, (s16)0x0AF1,
|
||||||
|
@ -136,8 +136,7 @@ void BIOS_BitUnPack()
|
||||||
|
|
||||||
int len = CPUReadHalfWord(header);
|
int len = CPUReadHalfWord(header);
|
||||||
// check address
|
// check address
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + len) & 0xe000000) == 0)
|
||||||
((source + len) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int bits = CPUReadByte(header + 2);
|
int bits = CPUReadByte(header + 2);
|
||||||
|
@ -256,8 +255,7 @@ void BIOS_CpuSet()
|
||||||
u32 dest = reg[1].I;
|
u32 dest = reg[1].I;
|
||||||
u32 cnt = reg[2].I;
|
u32 cnt = reg[2].I;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + (((cnt << 11) >> 9) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + (((cnt << 11)>>9) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int count = cnt & 0x1FFFFF;
|
int count = cnt & 0x1FFFFF;
|
||||||
|
@ -318,8 +316,7 @@ void BIOS_CpuFastSet()
|
||||||
u32 dest = reg[1].I;
|
u32 dest = reg[1].I;
|
||||||
u32 cnt = reg[2].I;
|
u32 cnt = reg[2].I;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + (((cnt << 11) >> 9) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + (((cnt << 11)>>9) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// needed for 32-bit mode!
|
// needed for 32-bit mode!
|
||||||
|
@ -368,8 +365,7 @@ void BIOS_Diff8bitUnFilterWram()
|
||||||
u32 header = CPUReadMemory(source);
|
u32 header = CPUReadMemory(source);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || (((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0))
|
||||||
(((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int len = header >> 8;
|
int len = header >> 8;
|
||||||
|
@ -401,8 +397,7 @@ void BIOS_Diff8bitUnFilterVram()
|
||||||
u32 header = CPUReadMemory(source);
|
u32 header = CPUReadMemory(source);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int len = header >> 8;
|
int len = header >> 8;
|
||||||
|
@ -444,8 +439,7 @@ void BIOS_Diff16bitUnFilter()
|
||||||
u32 header = CPUReadMemory(source);
|
u32 header = CPUReadMemory(source);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int len = header >> 8;
|
int len = header >> 8;
|
||||||
|
@ -529,8 +523,7 @@ void BIOS_HuffUnComp()
|
||||||
u32 header = CPUReadMemory(source);
|
u32 header = CPUReadMemory(source);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u8 treeSize = CPUReadByte(source++);
|
u8 treeSize = CPUReadByte(source++);
|
||||||
|
@ -675,8 +668,7 @@ void BIOS_LZ77UnCompVram()
|
||||||
u32 header = CPUReadMemory(source);
|
u32 header = CPUReadMemory(source);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int byteCount = 0;
|
int byteCount = 0;
|
||||||
|
@ -764,8 +756,7 @@ void BIOS_LZ77UnCompWram()
|
||||||
u32 header = CPUReadMemory(source);
|
u32 header = CPUReadMemory(source);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int len = header >> 8;
|
int len = header >> 8;
|
||||||
|
@ -957,8 +948,7 @@ void BIOS_RLUnCompVram()
|
||||||
u32 header = CPUReadMemory(source & 0xFFFFFFFC);
|
u32 header = CPUReadMemory(source & 0xFFFFFFFC);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int len = header >> 8;
|
int len = header >> 8;
|
||||||
|
@ -1026,8 +1016,7 @@ void BIOS_RLUnCompWram()
|
||||||
u32 header = CPUReadMemory(source & 0xFFFFFFFC);
|
u32 header = CPUReadMemory(source & 0xFFFFFFFC);
|
||||||
source += 4;
|
source += 4;
|
||||||
|
|
||||||
if(((source & 0xe000000) == 0) ||
|
if (((source & 0xe000000) == 0) || ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int len = header >> 8;
|
int len = header >> 8;
|
||||||
|
@ -1114,8 +1103,7 @@ u32 const base2 = 0x04000080;
|
||||||
|
|
||||||
static bool BIOS_SndDriver_ba4(u32 r0, u32 r4r12) // 0xba4
|
static bool BIOS_SndDriver_ba4(u32 r0, u32 r4r12) // 0xba4
|
||||||
{
|
{
|
||||||
if (r4r12)
|
if (r4r12) {
|
||||||
{
|
|
||||||
r4r12 = r4r12 & ~0xFE000000;
|
r4r12 = r4r12 & ~0xFE000000;
|
||||||
r4r12 += r0;
|
r4r12 += r0;
|
||||||
if (!((r0 & 0x0E000000) && (r4r12 & 0x0E000000)))
|
if (!((r0 & 0x0E000000) && (r4r12 & 0x0E000000)))
|
||||||
|
@ -1146,22 +1134,18 @@ static void BIOS_SndDriver_b4c(u32 r0, u32 r1, u32 r2) // 0xb4c
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 0b56
|
// 0b56
|
||||||
if ( !ok )
|
if (!ok) {
|
||||||
{
|
|
||||||
u32 r5 = 0; //v8
|
u32 r5 = 0; //v8
|
||||||
if (r2 >= (1 << (27 - 1))) //v6
|
if (r2 >= (1 << (27 - 1))) //v6
|
||||||
{
|
{
|
||||||
r5 = r1 + r4;
|
r5 = r1 + r4;
|
||||||
if ( r2 >= (1<<(25-1)) )
|
if (r2 >= (1 << (25 - 1))) {
|
||||||
{
|
|
||||||
u32 r3 = CPUReadMemory(r0);
|
u32 r3 = CPUReadMemory(r0);
|
||||||
while ( r1 < r5 )
|
while (r1 < r5) {
|
||||||
{
|
|
||||||
CPUWriteMemory(r1, r3);
|
CPUWriteMemory(r1, r3);
|
||||||
r1 += 4;
|
r1 += 4;
|
||||||
}
|
}
|
||||||
}
|
} else // @todo 0b6e
|
||||||
else // @todo 0b6e
|
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
while ( v5 < v9 )
|
while ( v5 < v9 )
|
||||||
|
@ -1173,8 +1157,7 @@ static void BIOS_SndDriver_b4c(u32 r0, u32 r1, u32 r2) // 0xb4c
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
} else // @todo 0b78
|
||||||
else // @todo 0b78
|
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
v12 = (unsigned int)v3 >> 1;
|
v12 = (unsigned int)v3 >> 1;
|
||||||
|
@ -1217,15 +1200,13 @@ static s32 BIOS_SndDriver_3e4(u32 const r0a, u32 const r1a) // 0x3e4
|
||||||
r0 = -r0;
|
r0 = -r0;
|
||||||
r2 = r1;
|
r2 = r1;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
gtr = (r2 >= r0 >> 1);
|
gtr = (r2 >= r0 >> 1);
|
||||||
if (r2 <= r0 >> 1)
|
if (r2 <= r0 >> 1)
|
||||||
r2 *= 2;
|
r2 *= 2;
|
||||||
} while (!gtr);
|
} while (!gtr);
|
||||||
|
|
||||||
while ( 1 )
|
while (1) {
|
||||||
{
|
|
||||||
v5 += (r0 >= (u32)r2) + v5;
|
v5 += (r0 >= (u32)r2) + v5;
|
||||||
if (r0 >= (u32)r2)
|
if (r0 >= (u32)r2)
|
||||||
r0 -= r2;
|
r0 -= r2;
|
||||||
|
@ -1251,15 +1232,12 @@ static void BIOS_SndDriverSub1(u32 p1) // 0x170a
|
||||||
u32 r0 = (0x31e8 + (local1 << 1)) - 0x20;
|
u32 r0 = (0x31e8 + (local1 << 1)) - 0x20;
|
||||||
|
|
||||||
// @todo read from bios region
|
// @todo read from bios region
|
||||||
if (r0 == 0x31D0)
|
if (r0 == 0x31D0) {
|
||||||
{
|
|
||||||
r0 = 0xE0;
|
r0 = 0xE0;
|
||||||
}
|
} else if (r0 == 0x31E0) {
|
||||||
else if (r0 == 0x31E0)
|
|
||||||
{
|
|
||||||
r0 = 0x2C0;
|
r0 = 0x2C0;
|
||||||
}
|
} else
|
||||||
else r0 = CPUReadHalfWord(r0+0x1E);
|
r0 = CPUReadHalfWord(r0 + 0x1E);
|
||||||
CPUWriteMemory(puser1 + 0x10, r0);
|
CPUWriteMemory(puser1 + 0x10, r0);
|
||||||
|
|
||||||
u32 r1 = 0x630;
|
u32 r1 = 0x630;
|
||||||
|
@ -1363,40 +1341,34 @@ void BIOS_SndDriverMode() //0x179c
|
||||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||||
u32 user1 = CPUReadMemory(puser1);
|
u32 user1 = CPUReadMemory(puser1);
|
||||||
|
|
||||||
if ( user1 == 0x68736D53 )
|
if (user1 == 0x68736D53) {
|
||||||
{
|
|
||||||
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
||||||
|
|
||||||
// reverb values at bits 0...7
|
// reverb values at bits 0...7
|
||||||
u8 revb = (input & 0xFF);
|
u8 revb = (input & 0xFF);
|
||||||
if ( revb )
|
if (revb) {
|
||||||
{
|
|
||||||
revb >>= 1; // shift out the 7th enable bit
|
revb >>= 1; // shift out the 7th enable bit
|
||||||
CPUWriteByte(puser1 + 5, revb);
|
CPUWriteByte(puser1 + 5, revb);
|
||||||
}
|
}
|
||||||
// direct sound multi channels at bits 8...11
|
// direct sound multi channels at bits 8...11
|
||||||
u8 chc = (input & 0xF00) >> 8;
|
u8 chc = (input & 0xF00) >> 8;
|
||||||
if ( chc > 0 )
|
if (chc > 0) {
|
||||||
{
|
|
||||||
CPUWriteByte(puser1 + 6, chc);
|
CPUWriteByte(puser1 + 6, chc);
|
||||||
u32 puser2 = puser1 + 7 + 0x49;
|
u32 puser2 = puser1 + 7 + 0x49;
|
||||||
int count = 12;
|
int count = 12;
|
||||||
while (count--)
|
while (count--) {
|
||||||
{
|
|
||||||
CPUWriteByte(puser2, 0);
|
CPUWriteByte(puser2, 0);
|
||||||
puser2 += 0x40;
|
puser2 += 0x40;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// direct sound master volume at bits 12...15
|
// direct sound master volume at bits 12...15
|
||||||
u8 chv = (input & 0xF000) >> 12;
|
u8 chv = (input & 0xF000) >> 12;
|
||||||
if ( chv > 0 )
|
if (chv > 0) {
|
||||||
{
|
|
||||||
CPUWriteByte(puser1 + 7, chv);
|
CPUWriteByte(puser1 + 7, chv);
|
||||||
}
|
}
|
||||||
// DA converter bits at bits 20...23
|
// DA converter bits at bits 20...23
|
||||||
u32 dab = (input & 0x00B00000);
|
u32 dab = (input & 0x00B00000);
|
||||||
if ( dab )
|
if (dab) {
|
||||||
{
|
|
||||||
dab &= 0x00300000;
|
dab &= 0x00300000;
|
||||||
dab >>= 0xE;
|
dab >>= 0xE;
|
||||||
u8 adv = CPUReadByte(puser1 + 9) & ADBITS_MASK; // @todo verify offset
|
u8 adv = CPUReadByte(puser1 + 9) & ADBITS_MASK; // @todo verify offset
|
||||||
|
@ -1405,8 +1377,7 @@ void BIOS_SndDriverMode() //0x179c
|
||||||
}
|
}
|
||||||
// Playback frequency at bits 16...19
|
// Playback frequency at bits 16...19
|
||||||
u32 pbf = (input & 0x000F0000);
|
u32 pbf = (input & 0x000F0000);
|
||||||
if ( pbf )
|
if (pbf) {
|
||||||
{
|
|
||||||
// Modifies puser1/user1
|
// Modifies puser1/user1
|
||||||
BIOS_SndDriverVSyncOff();
|
BIOS_SndDriverVSyncOff();
|
||||||
|
|
||||||
|
@ -1430,15 +1401,13 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||||
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
||||||
|
|
||||||
int const user2 = CPUReadMemory(puser1 + 0x20);
|
int const user2 = CPUReadMemory(puser1 + 0x20);
|
||||||
if ( user2 )
|
if (user2) {
|
||||||
{
|
|
||||||
int const par1 = CPUReadMemory(puser1 + 0x24);
|
int const par1 = CPUReadMemory(puser1 + 0x24);
|
||||||
// Call 0x2102 sub_16A8 - -> param r1
|
// Call 0x2102 sub_16A8 - -> param r1
|
||||||
}
|
}
|
||||||
|
|
||||||
int const userfunc = CPUReadMemory(puser1 + 0x28);
|
int const userfunc = CPUReadMemory(puser1 + 0x28);
|
||||||
switch (userfunc)
|
switch (userfunc) {
|
||||||
{
|
|
||||||
case 0x1709: //phantasy star
|
case 0x1709: //phantasy star
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1448,8 +1417,7 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||||
u8 const user4 = CPUReadByte(puser1 + 4) - 1;
|
u8 const user4 = CPUReadByte(puser1 + 4) - 1;
|
||||||
u32 user41 = 0;
|
u32 user41 = 0;
|
||||||
|
|
||||||
if ( user4 > 0 )
|
if (user4 > 0) {
|
||||||
{
|
|
||||||
user41 = CPUReadByte(puser1 + 0x0B);
|
user41 = CPUReadByte(puser1 + 0x0B);
|
||||||
user41 -= user4;
|
user41 -= user4;
|
||||||
user41 *= v2;
|
user41 *= v2;
|
||||||
|
@ -1460,48 +1428,52 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||||
int user6 = r5c + 0x630; //r6
|
int user6 = r5c + 0x630; //r6
|
||||||
int user5 = CPUReadByte(puser1 + 0x5); //r3
|
int user5 = CPUReadByte(puser1 + 0x5); //r3
|
||||||
|
|
||||||
if ( user5 )
|
if (user5) {
|
||||||
{
|
|
||||||
// @todo 0x1e1a
|
// @todo 0x1e1a
|
||||||
}
|
} else // 0x1e74
|
||||||
else // 0x1e74
|
|
||||||
{
|
{
|
||||||
r5 = r5c;
|
r5 = r5c;
|
||||||
int count = v2 >> 4; //r1...v13
|
int count = v2 >> 4; //r1...v13
|
||||||
if ( !(v2 >> 3) )
|
if (!(v2 >> 3)) {
|
||||||
{
|
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
}
|
}
|
||||||
if (!(v2 >> 1)) //0x1e7c
|
if (!(v2 >> 1)) //0x1e7c
|
||||||
{
|
{
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
|
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
}
|
}
|
||||||
do // 0x1e8e
|
do // 0x1e8e
|
||||||
{
|
{
|
||||||
// @todo optimize this memset
|
// @todo optimize this memset
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
|
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
|
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
|
|
||||||
CPUWriteMemory(r5, 0);
|
CPUWriteMemory(r5, 0);
|
||||||
CPUWriteMemory(user6, 0);
|
CPUWriteMemory(user6, 0);
|
||||||
r5+=4; user6+=4;
|
r5 += 4;
|
||||||
|
user6 += 4;
|
||||||
|
|
||||||
count -= 1;
|
count -= 1;
|
||||||
} while (count > 0);
|
} while (count > 0);
|
||||||
|
@ -1513,8 +1485,7 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||||
int r12 = CPUReadMemory(r4 + 0x18);
|
int r12 = CPUReadMemory(r4 + 0x18);
|
||||||
u32 i = CPUReadByte(r4 + 0x6);
|
u32 i = CPUReadByte(r4 + 0x6);
|
||||||
|
|
||||||
for (r4+=0x10; i > 0; i-- )
|
for (r4 += 0x10; i > 0; i--) {
|
||||||
{
|
|
||||||
r4 += 0x40;
|
r4 += 0x40;
|
||||||
/*lbl_0x1eb0:*/
|
/*lbl_0x1eb0:*/
|
||||||
u32 r3 = CPUReadMemory(r4 + 0x24);
|
u32 r3 = CPUReadMemory(r4 + 0x24);
|
||||||
|
@ -1538,22 +1509,17 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||||
u8 r2a = CPUReadByte(r3 + 0x3); // seems to be LABEL_20e4
|
u8 r2a = CPUReadByte(r3 + 0x3); // seems to be LABEL_20e4
|
||||||
if ((r2a & 0xC0)) // 1ee4
|
if ((r2a & 0xC0)) // 1ee4
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
goto lbl_0x1f46;
|
goto lbl_0x1f46;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//lbl_0x1eee:
|
//lbl_0x1eee:
|
||||||
r5 = CPUReadByte(r4 + 0x9); //
|
r5 = CPUReadByte(r4 + 0x9); //
|
||||||
if ((r6 & 0x4) != 0) // @todo 0x1ef4
|
if ((r6 & 0x4) != 0) // @todo 0x1ef4
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((r6 & 0x40) != 0) // @todo 0x1f08
|
if ((r6 & 0x40) != 0) // @todo 0x1f08
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((r6 & 0x03) == 2) // 0x1f2a
|
if ((r6 & 0x03) == 2) // 0x1f2a
|
||||||
|
@ -1563,22 +1529,19 @@ void BIOS_SndDriverMain() // 0x1dc4 -> 0x08004024 phantasy star
|
||||||
r5 >>= 8;
|
r5 >>= 8;
|
||||||
|
|
||||||
u8 cmp1 = CPUReadByte(r4 + 0x6);
|
u8 cmp1 = CPUReadByte(r4 + 0x6);
|
||||||
if (r5 <= cmp1)
|
if (r5 <= cmp1) {
|
||||||
{
|
|
||||||
r5 = cmp1;
|
r5 = cmp1;
|
||||||
// @todo beq @ 0x1f3a -> ??
|
// @todo beq @ 0x1f3a -> ??
|
||||||
r6--;
|
r6--;
|
||||||
CPUWriteByte(r4, r6);
|
CPUWriteByte(r4, r6);
|
||||||
}
|
}
|
||||||
}
|
} else if ((r6 & 0x03) == 3) // 0x1f44
|
||||||
else if ( (r6 & 0x03) == 3) // 0x1f44
|
|
||||||
{
|
{
|
||||||
lbl_0x1f46: //@todo check if there is really another path to here
|
lbl_0x1f46: //@todo check if there is really another path to here
|
||||||
u8 add1 = CPUReadByte(r4 + 0x4);
|
u8 add1 = CPUReadByte(r4 + 0x4);
|
||||||
r5 += add1;
|
r5 += add1;
|
||||||
|
|
||||||
if (r5>=0xff)
|
if (r5 >= 0xff) {
|
||||||
{
|
|
||||||
r6--;
|
r6--;
|
||||||
r5 = 0xff;
|
r5 = 0xff;
|
||||||
CPUWriteByte(r4, r6);
|
CPUWriteByte(r4, r6);
|
||||||
|
@ -1607,7 +1570,6 @@ lbl_0x1f46: //@todo check if there is really another path to here
|
||||||
user0 = r6 & 0x10;
|
user0 = r6 & 0x10;
|
||||||
if (user0 != 0) // @todo 0x1f76
|
if (user0 != 0) // @todo 0x1f76
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r5 = r5c; // @todo below r5 is used and updated
|
r5 = r5c; // @todo below r5 is used and updated
|
||||||
|
@ -1621,23 +1583,20 @@ lbl_0x1f46: //@todo check if there is really another path to here
|
||||||
u8 r0a = CPUReadByte(r4 + 0x1);
|
u8 r0a = CPUReadByte(r4 + 0x1);
|
||||||
if ((r0a & 8)) //@todo 0x1fa8
|
if ((r0a & 8)) //@todo 0x1fa8
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 r7 = CPUReadMemory(r4 + 0x1c);
|
u32 r7 = CPUReadMemory(r4 + 0x1c);
|
||||||
u32 r14 = CPUReadMemory(r4 + 0x20);
|
u32 r14 = CPUReadMemory(r4 + 0x20);
|
||||||
|
|
||||||
lbl_0x2004: // LABEL_52:
|
lbl_0x2004: // LABEL_52:
|
||||||
while ( r7 >= 4 * r9 )
|
while (r7 >= 4 * r9) {
|
||||||
{
|
|
||||||
if (r2 <= 4) // @todo 0x2008, no phant
|
if (r2 <= 4) // @todo 0x2008, no phant
|
||||||
goto lbl_204c;
|
goto lbl_204c;
|
||||||
r2 -= 4;
|
r2 -= 4;
|
||||||
r3 += 4;
|
r3 += 4;
|
||||||
r7 -= 4 * r9;
|
r7 -= 4 * r9;
|
||||||
}
|
}
|
||||||
if ( r7 >= 2 * r9 )
|
if (r7 >= 2 * r9) {
|
||||||
{
|
|
||||||
if (r2 <= 2) // @todo 0x2008, no phant
|
if (r2 <= 2) // @todo 0x2008, no phant
|
||||||
goto lbl_204c;
|
goto lbl_204c;
|
||||||
r2 -= 2;
|
r2 -= 2;
|
||||||
|
@ -1646,23 +1605,16 @@ lbl_0x2004:// LABEL_52:
|
||||||
}
|
}
|
||||||
if (r7 < r9)
|
if (r7 < r9)
|
||||||
goto lbl_207c;
|
goto lbl_207c;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
lbl_204c: // LABEL_59:
|
lbl_204c: // LABEL_59:
|
||||||
--r2;
|
--r2;
|
||||||
if ( r2 )
|
if (r2) {
|
||||||
{
|
|
||||||
++r3;
|
++r3;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
r2 = user0; //0x2054
|
r2 = user0; //0x2054
|
||||||
if ( r2 )
|
if (r2) {
|
||||||
{
|
|
||||||
r3 = CPUReadMemory(reg[13].I + 0xC); // @todo stack pull 0x205c
|
r3 = CPUReadMemory(reg[13].I + 0xC); // @todo stack pull 0x205c
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CPUWriteByte(r4, r2);
|
CPUWriteByte(r4, r2);
|
||||||
goto lbl_20e4;
|
goto lbl_20e4;
|
||||||
}
|
}
|
||||||
|
@ -1670,8 +1622,7 @@ lbl_204c: // LABEL_59:
|
||||||
r7 -= r9;
|
r7 -= r9;
|
||||||
} while (r7 >= r9);
|
} while (r7 >= r9);
|
||||||
lbl_207c:
|
lbl_207c:
|
||||||
while ( 1 )
|
while (1) {
|
||||||
{
|
|
||||||
s32 r0a = CPUReadByte(r3);
|
s32 r0a = CPUReadByte(r3);
|
||||||
s32 r1a = CPUReadByte(r3 + 0x1);
|
s32 r1a = CPUReadByte(r3 + 0x1);
|
||||||
|
|
||||||
|
@ -1717,13 +1668,11 @@ void BIOS_SndDriverVSync()
|
||||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // @todo some sound area, make it common.
|
u32 const puser1 = CPUReadMemory(0x3007FF0); // @todo some sound area, make it common.
|
||||||
u32 const user1 = CPUReadMemory(puser1);
|
u32 const user1 = CPUReadMemory(puser1);
|
||||||
|
|
||||||
if ( user1 == 0x68736D53 )
|
if (user1 == 0x68736D53) {
|
||||||
{
|
|
||||||
u8 v1 = CPUReadByte(puser1 + 4);
|
u8 v1 = CPUReadByte(puser1 + 4);
|
||||||
s8 v1i = v1 - 1;
|
s8 v1i = v1 - 1;
|
||||||
CPUWriteByte(puser1 + 4, v1i);
|
CPUWriteByte(puser1 + 4, v1i);
|
||||||
if ( v1 <= 1 )
|
if (v1 <= 1) {
|
||||||
{
|
|
||||||
u8 v2 = CPUReadByte(puser1 + 0xB); //11
|
u8 v2 = CPUReadByte(puser1 + 0xB); //11
|
||||||
u32 base2 = 0x040000D2;
|
u32 base2 = 0x040000D2;
|
||||||
CPUWriteByte(puser1 + 4, v2);
|
CPUWriteByte(puser1 + 4, v2);
|
||||||
|
@ -1741,8 +1690,7 @@ void BIOS_SndDriverVSyncOff() // 0x1878
|
||||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||||
u32 user1 = CPUReadMemory(puser1);
|
u32 user1 = CPUReadMemory(puser1);
|
||||||
|
|
||||||
if ( user1 == 0x68736D53 || user1 == 0x68736D54 )
|
if (user1 == 0x68736D53 || user1 == 0x68736D54) {
|
||||||
{
|
|
||||||
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
CPUWriteMemory(puser1, (++user1)); // this guard is common for funcs, unify
|
||||||
|
|
||||||
CPUWriteHalfWord(base1 + 0x6, 0);
|
CPUWriteHalfWord(base1 + 0x6, 0);
|
||||||
|
@ -1770,27 +1718,23 @@ void BIOS_SndChannelClear() //0x1824
|
||||||
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
u32 const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
|
||||||
u32 user1 = CPUReadMemory(puser1);
|
u32 user1 = CPUReadMemory(puser1);
|
||||||
|
|
||||||
if ( user1 == 0x68736D53 )
|
if (user1 == 0x68736D53) {
|
||||||
{
|
|
||||||
CPUWriteMemory(puser1, (++user1));
|
CPUWriteMemory(puser1, (++user1));
|
||||||
u32 puser2 = puser1 + 0x7 + 0x49;
|
u32 puser2 = puser1 + 0x7 + 0x49;
|
||||||
|
|
||||||
int count = 12;
|
int count = 12;
|
||||||
while (count--)
|
while (count--) {
|
||||||
{
|
|
||||||
CPUWriteByte(puser2, 0);
|
CPUWriteByte(puser2, 0);
|
||||||
puser2 += 0x40;
|
puser2 += 0x40;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg[4].I = CPUReadMemory(puser1 + 0x1c); //r5 -> some user thing
|
reg[4].I = CPUReadMemory(puser1 + 0x1c); //r5 -> some user thing
|
||||||
if ( reg[4].I != 0 )
|
if (reg[4].I != 0) {
|
||||||
{
|
|
||||||
reg[3].I = 1; // r4 -> channel counter?
|
reg[3].I = 1; // r4 -> channel counter?
|
||||||
int puser4 = puser1 + 0x2c;
|
int puser4 = puser1 + 0x2c;
|
||||||
//reg[0].I = reg[3].I = 1; // r0 & r4 => 1
|
//reg[0].I = reg[3].I = 1; // r0 & r4 => 1
|
||||||
|
|
||||||
while (reg[3].I <= 4)
|
while (reg[3].I <= 4) {
|
||||||
{
|
|
||||||
// @todo does user func modify these?
|
// @todo does user func modify these?
|
||||||
reg[0].I = reg[3].I << 24;
|
reg[0].I = reg[3].I << 24;
|
||||||
reg[0].I >>= 24;
|
reg[0].I >>= 24;
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
/* First, we deal with platform-specific or compiler-specific issues. */
|
/* First, we deal with platform-specific or compiler-specific issues. */
|
||||||
|
|
||||||
/* begin standard C headers. */
|
/* begin standard C headers. */
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#if (defined __WIN32__ || defined _WIN32)
|
#if (defined __WIN32__ || defined _WIN32)
|
||||||
#define fileno _fileno
|
#define fileno _fileno
|
||||||
|
@ -197,17 +197,14 @@ extern FILE *dexp_in, *dexp_out;
|
||||||
|
|
||||||
/* Return all but the first "n" matched characters back to the input stream. */
|
/* Return all but the first "n" matched characters back to the input stream. */
|
||||||
#define yyless(n) \
|
#define yyless(n) \
|
||||||
do \
|
do { \
|
||||||
{ \
|
|
||||||
/* Undo effects of setting up dexp_text. */ \
|
/* Undo effects of setting up dexp_text. */ \
|
||||||
int yyless_macro_arg = (n); \
|
int yyless_macro_arg = (n); \
|
||||||
YY_LESS_LINENO(yyless_macro_arg); \
|
YY_LESS_LINENO(yyless_macro_arg); \
|
||||||
*yy_cp = (yy_hold_char); \
|
*yy_cp = (yy_hold_char); \
|
||||||
YY_RESTORE_YY_MORE_OFFSET \
|
YY_RESTORE_YY_MORE_OFFSET(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
|
||||||
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
|
|
||||||
YY_DO_BEFORE_ACTION; /* set up dexp_text again */ \
|
YY_DO_BEFORE_ACTION; /* set up dexp_text again */ \
|
||||||
} \
|
} while (0)
|
||||||
while ( 0 )
|
|
||||||
|
|
||||||
#define unput(c) yyunput(c, (yytext_ptr))
|
#define unput(c) yyunput(c, (yytext_ptr))
|
||||||
|
|
||||||
|
@ -218,8 +215,7 @@ typedef size_t yy_size_t;
|
||||||
|
|
||||||
#ifndef YY_STRUCT_YY_BUFFER_STATE
|
#ifndef YY_STRUCT_YY_BUFFER_STATE
|
||||||
#define YY_STRUCT_YY_BUFFER_STATE
|
#define YY_STRUCT_YY_BUFFER_STATE
|
||||||
struct yy_buffer_state
|
struct yy_buffer_state {
|
||||||
{
|
|
||||||
FILE* yy_input_file;
|
FILE* yy_input_file;
|
||||||
|
|
||||||
char* yy_ch_buf; /* input buffer */
|
char* yy_ch_buf; /* input buffer */
|
||||||
|
@ -277,7 +273,6 @@ struct yy_buffer_state
|
||||||
* just pointing dexp_in at a new input file.
|
* just pointing dexp_in at a new input file.
|
||||||
*/
|
*/
|
||||||
#define YY_BUFFER_EOF_PENDING 2
|
#define YY_BUFFER_EOF_PENDING 2
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
||||||
|
|
||||||
|
@ -344,8 +339,7 @@ void dexp_free (void * );
|
||||||
{ \
|
{ \
|
||||||
if (!YY_CURRENT_BUFFER) { \
|
if (!YY_CURRENT_BUFFER) { \
|
||||||
dexp_ensure_buffer_stack(); \
|
dexp_ensure_buffer_stack(); \
|
||||||
YY_CURRENT_BUFFER_LVALUE = \
|
YY_CURRENT_BUFFER_LVALUE = dexp__create_buffer(dexp_in, YY_BUF_SIZE); \
|
||||||
dexp__create_buffer(dexp_in,YY_BUF_SIZE ); \
|
|
||||||
} \
|
} \
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
|
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
|
||||||
}
|
}
|
||||||
|
@ -354,8 +348,7 @@ void dexp_free (void * );
|
||||||
{ \
|
{ \
|
||||||
if (!YY_CURRENT_BUFFER) { \
|
if (!YY_CURRENT_BUFFER) { \
|
||||||
dexp_ensure_buffer_stack(); \
|
dexp_ensure_buffer_stack(); \
|
||||||
YY_CURRENT_BUFFER_LVALUE = \
|
YY_CURRENT_BUFFER_LVALUE = dexp__create_buffer(dexp_in, YY_BUF_SIZE); \
|
||||||
dexp__create_buffer(dexp_in,YY_BUF_SIZE ); \
|
|
||||||
} \
|
} \
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
|
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
|
||||||
}
|
}
|
||||||
|
@ -399,22 +392,18 @@ static void yy_fatal_error (yyconst char msg[] );
|
||||||
#define YY_END_OF_BUFFER 31
|
#define YY_END_OF_BUFFER 31
|
||||||
/* This struct is not used in this scanner,
|
/* This struct is not used in this scanner,
|
||||||
but its presence is necessary. */
|
but its presence is necessary. */
|
||||||
struct yy_trans_info
|
struct yy_trans_info {
|
||||||
{
|
|
||||||
flex_int32_t yy_verify;
|
flex_int32_t yy_verify;
|
||||||
flex_int32_t yy_nxt;
|
flex_int32_t yy_nxt;
|
||||||
};
|
};
|
||||||
static yyconst flex_int16_t yy_accept[51] =
|
static yyconst flex_int16_t yy_accept[51] = { 0,
|
||||||
{ 0,
|
|
||||||
0, 0, 31, 28, 30, 27, 25, 28, 23, 20,
|
0, 0, 31, 28, 30, 27, 25, 28, 23, 20,
|
||||||
21, 17, 14, 15, 16, 11, 10, 28, 28, 28,
|
21, 17, 14, 15, 16, 11, 10, 28, 28, 28,
|
||||||
28, 28, 28, 28, 28, 28, 9, 8, 24, 28,
|
28, 28, 28, 28, 28, 28, 9, 8, 24, 28,
|
||||||
22, 26, 13, 11, 0, 10, 18, 19, 29, 5,
|
22, 26, 13, 11, 0, 10, 18, 19, 29, 5,
|
||||||
6, 3, 4, 2, 7, 1, 1, 1, 12, 0
|
6, 3, 4, 2, 7, 1, 1, 1, 12, 0 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yyconst flex_int32_t yy_ec[256] =
|
static yyconst flex_int32_t yy_ec[256] = { 0,
|
||||||
{ 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
@ -442,39 +431,31 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1
|
1, 1, 1, 1, 1 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yyconst flex_int32_t yy_meta[36] =
|
static yyconst flex_int32_t yy_meta[36] = { 0,
|
||||||
{ 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 2, 2, 2, 2, 1, 1, 2, 2,
|
1, 1, 2, 2, 2, 2, 1, 1, 2, 2,
|
||||||
2, 3, 3, 3, 3, 3, 3, 3, 4, 1,
|
2, 3, 3, 3, 3, 3, 3, 3, 4, 1,
|
||||||
1, 1, 3, 1, 1
|
1, 1, 3, 1, 1 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yyconst flex_int16_t yy_base[55] =
|
static yyconst flex_int16_t yy_base[55] = { 0,
|
||||||
{ 0,
|
|
||||||
0, 0, 71, 72, 72, 72, 72, 0, 72, 72,
|
0, 0, 71, 72, 72, 72, 72, 0, 72, 72,
|
||||||
72, 72, 72, 72, 72, 41, 23, 52, 50, 0,
|
72, 72, 72, 72, 72, 41, 23, 52, 50, 0,
|
||||||
37, 36, 14, 44, 39, 33, 72, 72, 72, 28,
|
37, 36, 14, 44, 39, 33, 72, 72, 72, 28,
|
||||||
72, 72, 0, 33, 0, 35, 72, 72, 0, 72,
|
72, 72, 0, 33, 0, 35, 72, 72, 0, 72,
|
||||||
72, 0, 0, 0, 72, 32, 39, 0, 0, 72,
|
72, 0, 0, 0, 72, 32, 39, 0, 0, 72,
|
||||||
55, 54, 57, 52
|
55, 54, 57, 52 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yyconst flex_int16_t yy_def[55] =
|
static yyconst flex_int16_t yy_def[55] = { 0,
|
||||||
{ 0,
|
|
||||||
50, 1, 50, 50, 50, 50, 50, 51, 50, 50,
|
50, 1, 50, 50, 50, 50, 50, 51, 50, 50,
|
||||||
50, 50, 50, 50, 50, 52, 50, 50, 50, 53,
|
50, 50, 50, 50, 50, 52, 50, 50, 50, 53,
|
||||||
53, 53, 53, 53, 53, 53, 50, 50, 50, 53,
|
53, 53, 53, 53, 53, 53, 50, 50, 50, 53,
|
||||||
50, 50, 51, 52, 54, 50, 50, 50, 53, 50,
|
50, 50, 51, 52, 54, 50, 50, 50, 53, 50,
|
||||||
50, 53, 53, 53, 50, 30, 30, 53, 54, 0,
|
50, 53, 53, 53, 50, 30, 30, 53, 54, 0,
|
||||||
50, 50, 50, 50
|
50, 50, 50, 50 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yyconst flex_int16_t yy_nxt[108] =
|
static yyconst flex_int16_t yy_nxt[108] = { 0,
|
||||||
{ 0,
|
|
||||||
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||||
14, 15, 16, 17, 17, 17, 18, 19, 20, 21,
|
14, 15, 16, 17, 17, 17, 18, 19, 20, 21,
|
||||||
20, 20, 22, 23, 24, 20, 25, 26, 20, 27,
|
20, 20, 22, 23, 24, 20, 25, 26, 20, 27,
|
||||||
|
@ -486,11 +467,9 @@ static yyconst flex_int16_t yy_nxt[108] =
|
||||||
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
||||||
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
||||||
|
|
||||||
50, 50, 50, 50, 50, 50, 50
|
50, 50, 50, 50, 50, 50, 50 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yyconst flex_int16_t yy_chk[108] =
|
static yyconst flex_int16_t yy_chk[108] = { 0,
|
||||||
{ 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
@ -502,8 +481,7 @@ static yyconst flex_int16_t yy_chk[108] =
|
||||||
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
||||||
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
|
||||||
|
|
||||||
50, 50, 50, 50, 50, 50, 50
|
50, 50, 50, 50, 50, 50, 50 };
|
||||||
} ;
|
|
||||||
|
|
||||||
static yy_state_type yy_last_accepting_state;
|
static yy_state_type yy_last_accepting_state;
|
||||||
static char* yy_last_accepting_cpos;
|
static char* yy_last_accepting_cpos;
|
||||||
|
@ -521,9 +499,9 @@ int dexp__flex_debug = 0;
|
||||||
char* dexp_text;
|
char* dexp_text;
|
||||||
#line 1 "debugger-expr.l"
|
#line 1 "debugger-expr.l"
|
||||||
#line 2 "debugger-expr.l"
|
#line 2 "debugger-expr.l"
|
||||||
|
#include "debugger-expr-yacc.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "debugger-expr-yacc.hpp"
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define YY_NO_UNISTD_H
|
#define YY_NO_UNISTD_H
|
||||||
|
@ -637,7 +615,11 @@ static int input (void );
|
||||||
/* This used to be an fputs(), but since the string might contain NUL's,
|
/* This used to be an fputs(), but since the string might contain NUL's,
|
||||||
* we now use fwrite().
|
* we now use fwrite().
|
||||||
*/
|
*/
|
||||||
#define ECHO do { if (fwrite( dexp_text, dexp_leng, 1, dexp_out )) {} } while (0)
|
#define ECHO \
|
||||||
|
do { \
|
||||||
|
if (fwrite(dexp_text, dexp_leng, 1, dexp_out)) { \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
||||||
|
@ -645,34 +627,27 @@ static int input (void );
|
||||||
*/
|
*/
|
||||||
#ifndef YY_INPUT
|
#ifndef YY_INPUT
|
||||||
#define YY_INPUT(buf, result, max_size) \
|
#define YY_INPUT(buf, result, max_size) \
|
||||||
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
|
if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) { \
|
||||||
{ \
|
|
||||||
int c = '*'; \
|
int c = '*'; \
|
||||||
size_t n; \
|
size_t n; \
|
||||||
for ( n = 0; n < max_size && \
|
for (n = 0; n < max_size && (c = getc(dexp_in)) != EOF && c != '\n'; ++n) \
|
||||||
(c = getc( dexp_in )) != EOF && c != '\n'; ++n ) \
|
|
||||||
buf[n] = (char)c; \
|
buf[n] = (char)c; \
|
||||||
if (c == '\n') \
|
if (c == '\n') \
|
||||||
buf[n++] = (char)c; \
|
buf[n++] = (char)c; \
|
||||||
if (c == EOF && ferror(dexp_in)) \
|
if (c == EOF && ferror(dexp_in)) \
|
||||||
YY_FATAL_ERROR("input in flex scanner failed"); \
|
YY_FATAL_ERROR("input in flex scanner failed"); \
|
||||||
result = n; \
|
result = n; \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
errno = 0; \
|
errno = 0; \
|
||||||
while ( (result = fread(buf, 1, max_size, dexp_in))==0 && ferror(dexp_in)) \
|
while ((result = fread(buf, 1, max_size, dexp_in)) == 0 && ferror(dexp_in)) { \
|
||||||
{ \
|
if (errno != EINTR) { \
|
||||||
if( errno != EINTR) \
|
|
||||||
{ \
|
|
||||||
YY_FATAL_ERROR("input in flex scanner failed"); \
|
YY_FATAL_ERROR("input in flex scanner failed"); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
errno = 0; \
|
errno = 0; \
|
||||||
clearerr(dexp_in); \
|
clearerr(dexp_in); \
|
||||||
} \
|
} \
|
||||||
}\
|
}
|
||||||
\
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -734,8 +709,7 @@ YY_DECL
|
||||||
|
|
||||||
#line 732 "debugger-expr-lex.cpp"
|
#line 732 "debugger-expr-lex.cpp"
|
||||||
|
|
||||||
if ( !(yy_init) )
|
if (!(yy_init)) {
|
||||||
{
|
|
||||||
(yy_init) = 1;
|
(yy_init) = 1;
|
||||||
|
|
||||||
#ifdef YY_USER_INIT
|
#ifdef YY_USER_INIT
|
||||||
|
@ -753,8 +727,7 @@ YY_DECL
|
||||||
|
|
||||||
if (!YY_CURRENT_BUFFER) {
|
if (!YY_CURRENT_BUFFER) {
|
||||||
dexp_ensure_buffer_stack();
|
dexp_ensure_buffer_stack();
|
||||||
YY_CURRENT_BUFFER_LVALUE =
|
YY_CURRENT_BUFFER_LVALUE = dexp__create_buffer(dexp_in, YY_BUF_SIZE);
|
||||||
dexp__create_buffer(dexp_in,YY_BUF_SIZE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dexp__load_buffer_state();
|
dexp__load_buffer_state();
|
||||||
|
@ -774,29 +747,24 @@ YY_DECL
|
||||||
|
|
||||||
yy_current_state = (yy_start);
|
yy_current_state = (yy_start);
|
||||||
yy_match:
|
yy_match:
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
|
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
|
||||||
if ( yy_accept[yy_current_state] )
|
if (yy_accept[yy_current_state]) {
|
||||||
{
|
|
||||||
(yy_last_accepting_state) = yy_current_state;
|
(yy_last_accepting_state) = yy_current_state;
|
||||||
(yy_last_accepting_cpos) = yy_cp;
|
(yy_last_accepting_cpos) = yy_cp;
|
||||||
}
|
}
|
||||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
|
||||||
{
|
|
||||||
yy_current_state = (int)yy_def[yy_current_state];
|
yy_current_state = (int)yy_def[yy_current_state];
|
||||||
if (yy_current_state >= 51)
|
if (yy_current_state >= 51)
|
||||||
yy_c = yy_meta[(unsigned int)yy_c];
|
yy_c = yy_meta[(unsigned int)yy_c];
|
||||||
}
|
}
|
||||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c];
|
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c];
|
||||||
++yy_cp;
|
++yy_cp;
|
||||||
}
|
} while (yy_base[yy_current_state] != 72);
|
||||||
while ( yy_base[yy_current_state] != 72 );
|
|
||||||
|
|
||||||
yy_find_action:
|
yy_find_action:
|
||||||
yy_act = yy_accept[yy_current_state];
|
yy_act = yy_accept[yy_current_state];
|
||||||
if ( yy_act == 0 )
|
if (yy_act == 0) { /* have to back up */
|
||||||
{ /* have to back up */
|
|
||||||
yy_cp = (yy_last_accepting_cpos);
|
yy_cp = (yy_last_accepting_cpos);
|
||||||
yy_current_state = (yy_last_accepting_state);
|
yy_current_state = (yy_last_accepting_state);
|
||||||
yy_act = yy_accept[yy_current_state];
|
yy_act = yy_accept[yy_current_state];
|
||||||
|
@ -806,8 +774,7 @@ yy_find_action:
|
||||||
|
|
||||||
do_action: /* This label is used only to access EOF actions. */
|
do_action: /* This label is used only to access EOF actions. */
|
||||||
|
|
||||||
switch ( yy_act )
|
switch (yy_act) { /* beginning of action switch */
|
||||||
{ /* beginning of action switch */
|
|
||||||
case 0: /* must back up */
|
case 0: /* must back up */
|
||||||
/* undo the effects of YY_DO_BEFORE_ACTION */
|
/* undo the effects of YY_DO_BEFORE_ACTION */
|
||||||
*yy_cp = (yy_hold_char);
|
*yy_cp = (yy_hold_char);
|
||||||
|
@ -818,22 +785,26 @@ do_action: /* This label is used only to access EOF actions. */
|
||||||
case 1:
|
case 1:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 32 "debugger-expr.l"
|
#line 32 "debugger-expr.l"
|
||||||
dexp_lval.number=atoi((char *)(dexp_text+1)); return TOK_REGISTER;
|
dexp_lval.number = atoi((char*)(dexp_text + 1));
|
||||||
|
return TOK_REGISTER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 2:
|
case 2:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 33 "debugger-expr.l"
|
#line 33 "debugger-expr.l"
|
||||||
dexp_lval.number = 13; return TOK_REGISTER;
|
dexp_lval.number = 13;
|
||||||
|
return TOK_REGISTER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 3:
|
case 3:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 34 "debugger-expr.l"
|
#line 34 "debugger-expr.l"
|
||||||
dexp_lval.number = 14; return TOK_REGISTER;
|
dexp_lval.number = 14;
|
||||||
|
return TOK_REGISTER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 4:
|
case 4:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 35 "debugger-expr.l"
|
#line 35 "debugger-expr.l"
|
||||||
dexp_lval.number = 15; return TOK_REGISTER;
|
dexp_lval.number = 15;
|
||||||
|
return TOK_REGISTER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 5:
|
case 5:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
|
@ -863,22 +834,26 @@ return TOK_LBRACKET;
|
||||||
case 10:
|
case 10:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 41 "debugger-expr.l"
|
#line 41 "debugger-expr.l"
|
||||||
dexp_lval.number=atoi(dexp_text); return TOK_NUMBER;
|
dexp_lval.number = atoi(dexp_text);
|
||||||
|
return TOK_NUMBER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 11:
|
case 11:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 42 "debugger-expr.l"
|
#line 42 "debugger-expr.l"
|
||||||
sscanf(dexp_text, "%x", &dexp_lval.number); return TOK_NUMBER;
|
sscanf(dexp_text, "%x", &dexp_lval.number);
|
||||||
|
return TOK_NUMBER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 12:
|
case 12:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 43 "debugger-expr.l"
|
#line 43 "debugger-expr.l"
|
||||||
sscanf((char *)(dexp_text + 2), "%x", &dexp_lval.number); return TOK_NUMBER;
|
sscanf((char*)(dexp_text + 2), "%x", &dexp_lval.number);
|
||||||
|
return TOK_NUMBER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 13:
|
case 13:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 44 "debugger-expr.l"
|
#line 44 "debugger-expr.l"
|
||||||
sscanf((char *)(dexp_text + 1), "%x", &dexp_lval.number); return TOK_NUMBER;
|
sscanf((char*)(dexp_text + 1), "%x", &dexp_lval.number);
|
||||||
|
return TOK_NUMBER;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 14:
|
case 14:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
|
@ -958,7 +933,8 @@ printf("Unrecognised token: %s\n", dexp_text);
|
||||||
case 29:
|
case 29:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 60 "debugger-expr.l"
|
#line 60 "debugger-expr.l"
|
||||||
dexp_lval.string=dexp_text; return TOK_ID;
|
dexp_lval.string = dexp_text;
|
||||||
|
return TOK_ID;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 30:
|
case 30:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
|
@ -969,8 +945,7 @@ ECHO;
|
||||||
case YY_STATE_EOF(INITIAL):
|
case YY_STATE_EOF(INITIAL):
|
||||||
yyterminate();
|
yyterminate();
|
||||||
|
|
||||||
case YY_END_OF_BUFFER:
|
case YY_END_OF_BUFFER: {
|
||||||
{
|
|
||||||
/* Amount of text matched not including the EOB char. */
|
/* Amount of text matched not including the EOB char. */
|
||||||
int yy_amount_of_matched_text = (int)(yy_cp - (yytext_ptr)) - 1;
|
int yy_amount_of_matched_text = (int)(yy_cp - (yytext_ptr)) - 1;
|
||||||
|
|
||||||
|
@ -978,8 +953,7 @@ case YY_STATE_EOF(INITIAL):
|
||||||
*yy_cp = (yy_hold_char);
|
*yy_cp = (yy_hold_char);
|
||||||
YY_RESTORE_YY_MORE_OFFSET
|
YY_RESTORE_YY_MORE_OFFSET
|
||||||
|
|
||||||
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
|
if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW) {
|
||||||
{
|
|
||||||
/* We're scanning a new file or input source. It's
|
/* We're scanning a new file or input source. It's
|
||||||
* possible that this happened because the user
|
* possible that this happened because the user
|
||||||
* just pointed dexp_in at a new source and called
|
* just pointed dexp_in at a new source and called
|
||||||
|
@ -1001,8 +975,7 @@ case YY_STATE_EOF(INITIAL):
|
||||||
* end-of-buffer state). Contrast this with the test
|
* end-of-buffer state). Contrast this with the test
|
||||||
* in input().
|
* in input().
|
||||||
*/
|
*/
|
||||||
if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
|
if ((yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]) { /* This was really a NUL. */
|
||||||
{ /* This was really a NUL. */
|
|
||||||
yy_state_type yy_next_state;
|
yy_state_type yy_next_state;
|
||||||
|
|
||||||
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
|
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
|
||||||
|
@ -1022,29 +995,25 @@ case YY_STATE_EOF(INITIAL):
|
||||||
|
|
||||||
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
|
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
|
||||||
|
|
||||||
if ( yy_next_state )
|
if (yy_next_state) {
|
||||||
{
|
|
||||||
/* Consume the NUL. */
|
/* Consume the NUL. */
|
||||||
yy_cp = ++(yy_c_buf_p);
|
yy_cp = ++(yy_c_buf_p);
|
||||||
yy_current_state = yy_next_state;
|
yy_current_state = yy_next_state;
|
||||||
goto yy_match;
|
goto yy_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
yy_cp = (yy_c_buf_p);
|
yy_cp = (yy_c_buf_p);
|
||||||
goto yy_find_action;
|
goto yy_find_action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else switch ( yy_get_next_buffer( ) )
|
else
|
||||||
{
|
switch (yy_get_next_buffer()) {
|
||||||
case EOB_ACT_END_OF_FILE:
|
case EOB_ACT_END_OF_FILE: {
|
||||||
{
|
|
||||||
(yy_did_buffer_switch_on_eof) = 0;
|
(yy_did_buffer_switch_on_eof) = 0;
|
||||||
|
|
||||||
if ( dexp_wrap( ) )
|
if (dexp_wrap()) {
|
||||||
{
|
|
||||||
/* Note: because we've taken care in
|
/* Note: because we've taken care in
|
||||||
* yy_get_next_buffer() to have set up
|
* yy_get_next_buffer() to have set up
|
||||||
* dexp_text, we can now set up
|
* dexp_text, we can now set up
|
||||||
|
@ -1060,8 +1029,7 @@ case YY_STATE_EOF(INITIAL):
|
||||||
goto do_action;
|
goto do_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (!(yy_did_buffer_switch_on_eof))
|
if (!(yy_did_buffer_switch_on_eof))
|
||||||
YY_NEW_FILE;
|
YY_NEW_FILE;
|
||||||
}
|
}
|
||||||
|
@ -1069,8 +1037,7 @@ case YY_STATE_EOF(INITIAL):
|
||||||
}
|
}
|
||||||
|
|
||||||
case EOB_ACT_CONTINUE_SCAN:
|
case EOB_ACT_CONTINUE_SCAN:
|
||||||
(yy_c_buf_p) =
|
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
|
||||||
(yytext_ptr) + yy_amount_of_matched_text;
|
|
||||||
|
|
||||||
yy_current_state = yy_get_previous_state();
|
yy_current_state = yy_get_previous_state();
|
||||||
|
|
||||||
|
@ -1079,8 +1046,7 @@ case YY_STATE_EOF(INITIAL):
|
||||||
goto yy_match;
|
goto yy_match;
|
||||||
|
|
||||||
case EOB_ACT_LAST_MATCH:
|
case EOB_ACT_LAST_MATCH:
|
||||||
(yy_c_buf_p) =
|
(yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
|
||||||
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
|
|
||||||
|
|
||||||
yy_current_state = yy_get_previous_state();
|
yy_current_state = yy_get_previous_state();
|
||||||
|
|
||||||
|
@ -1116,18 +1082,15 @@ static int yy_get_next_buffer (void)
|
||||||
YY_FATAL_ERROR(
|
YY_FATAL_ERROR(
|
||||||
"fatal flex scanner internal error--end of buffer missed");
|
"fatal flex scanner internal error--end of buffer missed");
|
||||||
|
|
||||||
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
|
if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) { /* Don't try to fill the buffer, so this is an EOF. */
|
||||||
{ /* Don't try to fill the buffer, so this is an EOF. */
|
if ((yy_c_buf_p) - (yytext_ptr)-YY_MORE_ADJ == 1) {
|
||||||
if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
|
|
||||||
{
|
|
||||||
/* We matched a single character, the EOB, so
|
/* We matched a single character, the EOB, so
|
||||||
* treat this as a final EOF.
|
* treat this as a final EOF.
|
||||||
*/
|
*/
|
||||||
return EOB_ACT_END_OF_FILE;
|
return EOB_ACT_END_OF_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
/* We matched some text prior to the EOB, first
|
/* We matched some text prior to the EOB, first
|
||||||
* process it.
|
* process it.
|
||||||
*/
|
*/
|
||||||
|
@ -1149,22 +1112,17 @@ static int yy_get_next_buffer (void)
|
||||||
*/
|
*/
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
|
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
||||||
int num_to_read =
|
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
|
||||||
|
|
||||||
while ( num_to_read <= 0 )
|
while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */
|
||||||
{ /* Not enough room in the buffer - grow it. */
|
|
||||||
|
|
||||||
/* just a shorter name for the current buffer */
|
/* just a shorter name for the current buffer */
|
||||||
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
|
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
|
||||||
|
|
||||||
int yy_c_buf_p_offset =
|
int yy_c_buf_p_offset = (int)((yy_c_buf_p)-b->yy_ch_buf);
|
||||||
(int) ((yy_c_buf_p) - b->yy_ch_buf);
|
|
||||||
|
|
||||||
if ( b->yy_is_our_buffer )
|
if (b->yy_is_our_buffer) {
|
||||||
{
|
|
||||||
int new_size = b->yy_buf_size * 2;
|
int new_size = b->yy_buf_size * 2;
|
||||||
|
|
||||||
if (new_size <= 0)
|
if (new_size <= 0)
|
||||||
|
@ -1175,8 +1133,7 @@ static int yy_get_next_buffer (void)
|
||||||
b->yy_ch_buf = (char*)
|
b->yy_ch_buf = (char*)
|
||||||
/* Include room in for 2 EOB chars. */
|
/* Include room in for 2 EOB chars. */
|
||||||
dexp_realloc((void*)b->yy_ch_buf, b->yy_buf_size + 2);
|
dexp_realloc((void*)b->yy_ch_buf, b->yy_buf_size + 2);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
/* Can't grow it, we don't own it. */
|
/* Can't grow it, we don't own it. */
|
||||||
b->yy_ch_buf = 0;
|
b->yy_ch_buf = 0;
|
||||||
|
|
||||||
|
@ -1186,9 +1143,7 @@ static int yy_get_next_buffer (void)
|
||||||
|
|
||||||
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
|
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
|
||||||
|
|
||||||
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
|
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
||||||
number_to_move - 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_to_read > YY_READ_BUF_SIZE)
|
if (num_to_read > YY_READ_BUF_SIZE)
|
||||||
|
@ -1201,19 +1156,15 @@ static int yy_get_next_buffer (void)
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
|
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (yy_n_chars) == 0 )
|
if ((yy_n_chars) == 0) {
|
||||||
{
|
if (number_to_move == YY_MORE_ADJ) {
|
||||||
if ( number_to_move == YY_MORE_ADJ )
|
|
||||||
{
|
|
||||||
ret_val = EOB_ACT_END_OF_FILE;
|
ret_val = EOB_ACT_END_OF_FILE;
|
||||||
dexp_restart(dexp_in);
|
dexp_restart(dexp_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
ret_val = EOB_ACT_LAST_MATCH;
|
ret_val = EOB_ACT_LAST_MATCH;
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
|
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING;
|
||||||
YY_BUFFER_EOF_PENDING;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1246,16 +1197,13 @@ static int yy_get_next_buffer (void)
|
||||||
|
|
||||||
yy_current_state = (yy_start);
|
yy_current_state = (yy_start);
|
||||||
|
|
||||||
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
|
for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) {
|
||||||
{
|
|
||||||
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
|
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
|
||||||
if ( yy_accept[yy_current_state] )
|
if (yy_accept[yy_current_state]) {
|
||||||
{
|
|
||||||
(yy_last_accepting_state) = yy_current_state;
|
(yy_last_accepting_state) = yy_current_state;
|
||||||
(yy_last_accepting_cpos) = yy_cp;
|
(yy_last_accepting_cpos) = yy_cp;
|
||||||
}
|
}
|
||||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
|
||||||
{
|
|
||||||
yy_current_state = (int)yy_def[yy_current_state];
|
yy_current_state = (int)yy_def[yy_current_state];
|
||||||
if (yy_current_state >= 51)
|
if (yy_current_state >= 51)
|
||||||
yy_c = yy_meta[(unsigned int)yy_c];
|
yy_c = yy_meta[(unsigned int)yy_c];
|
||||||
|
@ -1277,13 +1225,11 @@ static int yy_get_next_buffer (void)
|
||||||
register char* yy_cp = (yy_c_buf_p);
|
register char* yy_cp = (yy_c_buf_p);
|
||||||
|
|
||||||
register YY_CHAR yy_c = 1;
|
register YY_CHAR yy_c = 1;
|
||||||
if ( yy_accept[yy_current_state] )
|
if (yy_accept[yy_current_state]) {
|
||||||
{
|
|
||||||
(yy_last_accepting_state) = yy_current_state;
|
(yy_last_accepting_state) = yy_current_state;
|
||||||
(yy_last_accepting_cpos) = yy_cp;
|
(yy_last_accepting_cpos) = yy_cp;
|
||||||
}
|
}
|
||||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
|
||||||
{
|
|
||||||
yy_current_state = (int)yy_def[yy_current_state];
|
yy_current_state = (int)yy_def[yy_current_state];
|
||||||
if (yy_current_state >= 51)
|
if (yy_current_state >= 51)
|
||||||
yy_c = yy_meta[(unsigned int)yy_c];
|
yy_c = yy_meta[(unsigned int)yy_c];
|
||||||
|
@ -1303,22 +1249,18 @@ static int yy_get_next_buffer (void)
|
||||||
/* undo effects of setting up dexp_text */
|
/* undo effects of setting up dexp_text */
|
||||||
*yy_cp = (yy_hold_char);
|
*yy_cp = (yy_hold_char);
|
||||||
|
|
||||||
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
|
if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2) { /* need to shift things up to make room */
|
||||||
{ /* need to shift things up to make room */
|
|
||||||
/* +2 for EOB chars. */
|
/* +2 for EOB chars. */
|
||||||
register int number_to_move = (yy_n_chars) + 2;
|
register int number_to_move = (yy_n_chars) + 2;
|
||||||
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
|
register char* dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
|
register char* source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
|
||||||
register char *source =
|
|
||||||
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
|
|
||||||
|
|
||||||
while (source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf)
|
while (source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf)
|
||||||
*--dest = *--source;
|
*--dest = *--source;
|
||||||
|
|
||||||
yy_cp += (int)(dest - source);
|
yy_cp += (int)(dest - source);
|
||||||
yy_bp += (int)(dest - source);
|
yy_bp += (int)(dest - source);
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
|
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
|
||||||
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
|
|
||||||
|
|
||||||
if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2)
|
if (yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2)
|
||||||
YY_FATAL_ERROR("flex scanner push-back overflow");
|
YY_FATAL_ERROR("flex scanner push-back overflow");
|
||||||
|
@ -1343,8 +1285,7 @@ static int yy_get_next_buffer (void)
|
||||||
|
|
||||||
*(yy_c_buf_p) = (yy_hold_char);
|
*(yy_c_buf_p) = (yy_hold_char);
|
||||||
|
|
||||||
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
|
if (*(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR) {
|
||||||
{
|
|
||||||
/* yy_c_buf_p now points to the character we want to return.
|
/* yy_c_buf_p now points to the character we want to return.
|
||||||
* If this occurs *before* the EOB characters, then it's a
|
* If this occurs *before* the EOB characters, then it's a
|
||||||
* valid NUL; if not, then we've hit the end of the buffer.
|
* valid NUL; if not, then we've hit the end of the buffer.
|
||||||
|
@ -1353,13 +1294,11 @@ static int yy_get_next_buffer (void)
|
||||||
/* This was really a NUL. */
|
/* This was really a NUL. */
|
||||||
*(yy_c_buf_p) = '\0';
|
*(yy_c_buf_p) = '\0';
|
||||||
|
|
||||||
else
|
else { /* need more input */
|
||||||
{ /* need more input */
|
|
||||||
int offset = (yy_c_buf_p) - (yytext_ptr);
|
int offset = (yy_c_buf_p) - (yytext_ptr);
|
||||||
++(yy_c_buf_p);
|
++(yy_c_buf_p);
|
||||||
|
|
||||||
switch ( yy_get_next_buffer( ) )
|
switch (yy_get_next_buffer()) {
|
||||||
{
|
|
||||||
case EOB_ACT_LAST_MATCH:
|
case EOB_ACT_LAST_MATCH:
|
||||||
/* This happens because yy_g_n_b()
|
/* This happens because yy_g_n_b()
|
||||||
* sees that we've accumulated a
|
* sees that we've accumulated a
|
||||||
|
@ -1376,8 +1315,7 @@ static int yy_get_next_buffer (void)
|
||||||
|
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
|
|
||||||
case EOB_ACT_END_OF_FILE:
|
case EOB_ACT_END_OF_FILE: {
|
||||||
{
|
|
||||||
if (dexp_wrap())
|
if (dexp_wrap())
|
||||||
return EOF;
|
return EOF;
|
||||||
|
|
||||||
|
@ -1415,8 +1353,7 @@ static int yy_get_next_buffer (void)
|
||||||
|
|
||||||
if (!YY_CURRENT_BUFFER) {
|
if (!YY_CURRENT_BUFFER) {
|
||||||
dexp_ensure_buffer_stack();
|
dexp_ensure_buffer_stack();
|
||||||
YY_CURRENT_BUFFER_LVALUE =
|
YY_CURRENT_BUFFER_LVALUE = dexp__create_buffer(dexp_in, YY_BUF_SIZE);
|
||||||
dexp__create_buffer(dexp_in,YY_BUF_SIZE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dexp__init_buffer(YY_CURRENT_BUFFER, input_file);
|
dexp__init_buffer(YY_CURRENT_BUFFER, input_file);
|
||||||
|
@ -1439,8 +1376,7 @@ static int yy_get_next_buffer (void)
|
||||||
if (YY_CURRENT_BUFFER == new_buffer)
|
if (YY_CURRENT_BUFFER == new_buffer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( YY_CURRENT_BUFFER )
|
if (YY_CURRENT_BUFFER) {
|
||||||
{
|
|
||||||
/* Flush out information for old buffer. */
|
/* Flush out information for old buffer. */
|
||||||
*(yy_c_buf_p) = (yy_hold_char);
|
*(yy_c_buf_p) = (yy_hold_char);
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
|
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
|
||||||
|
@ -1588,8 +1524,7 @@ void dexp_push_buffer_state (YY_BUFFER_STATE new_buffer )
|
||||||
dexp_ensure_buffer_stack();
|
dexp_ensure_buffer_stack();
|
||||||
|
|
||||||
/* This block is copied from dexp__switch_to_buffer. */
|
/* This block is copied from dexp__switch_to_buffer. */
|
||||||
if ( YY_CURRENT_BUFFER )
|
if (YY_CURRENT_BUFFER) {
|
||||||
{
|
|
||||||
/* Flush out information for old buffer. */
|
/* Flush out information for old buffer. */
|
||||||
*(yy_c_buf_p) = (yy_hold_char);
|
*(yy_c_buf_p) = (yy_hold_char);
|
||||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
|
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
|
||||||
|
@ -1640,9 +1575,7 @@ static void dexp_ensure_buffer_stack (void)
|
||||||
* immediate realloc on the next call.
|
* immediate realloc on the next call.
|
||||||
*/
|
*/
|
||||||
num_to_alloc = 1;
|
num_to_alloc = 1;
|
||||||
(yy_buffer_stack) = (struct yy_buffer_state**)dexp_alloc
|
(yy_buffer_stack) = (struct yy_buffer_state**)dexp_alloc(num_to_alloc * sizeof(struct yy_buffer_state*));
|
||||||
(num_to_alloc * sizeof(struct yy_buffer_state*)
|
|
||||||
);
|
|
||||||
if (!(yy_buffer_stack))
|
if (!(yy_buffer_stack))
|
||||||
YY_FATAL_ERROR("out of dynamic memory in dexp_ensure_buffer_stack()");
|
YY_FATAL_ERROR("out of dynamic memory in dexp_ensure_buffer_stack()");
|
||||||
|
|
||||||
|
@ -1659,10 +1592,8 @@ static void dexp_ensure_buffer_stack (void)
|
||||||
int grow_size = 8 /* arbitrary grow size */;
|
int grow_size = 8 /* arbitrary grow size */;
|
||||||
|
|
||||||
num_to_alloc = (yy_buffer_stack_max) + grow_size;
|
num_to_alloc = (yy_buffer_stack_max) + grow_size;
|
||||||
(yy_buffer_stack) = (struct yy_buffer_state**)dexp_realloc
|
(yy_buffer_stack) = (struct yy_buffer_state**)dexp_realloc((yy_buffer_stack),
|
||||||
((yy_buffer_stack),
|
num_to_alloc * sizeof(struct yy_buffer_state*));
|
||||||
num_to_alloc * sizeof(struct yy_buffer_state*)
|
|
||||||
);
|
|
||||||
if (!(yy_buffer_stack))
|
if (!(yy_buffer_stack))
|
||||||
YY_FATAL_ERROR("out of dynamic memory in dexp_ensure_buffer_stack()");
|
YY_FATAL_ERROR("out of dynamic memory in dexp_ensure_buffer_stack()");
|
||||||
|
|
||||||
|
@ -1682,9 +1613,7 @@ YY_BUFFER_STATE dexp__scan_buffer (char * base, yy_size_t size )
|
||||||
{
|
{
|
||||||
YY_BUFFER_STATE b;
|
YY_BUFFER_STATE b;
|
||||||
|
|
||||||
if ( size < 2 ||
|
if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR || base[size - 1] != YY_END_OF_BUFFER_CHAR)
|
||||||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
|
|
||||||
base[size-1] != YY_END_OF_BUFFER_CHAR )
|
|
||||||
/* They forgot to leave room for the EOB's. */
|
/* They forgot to leave room for the EOB's. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1772,8 +1701,7 @@ static void yy_fatal_error (yyconst char* msg )
|
||||||
|
|
||||||
#undef yyless
|
#undef yyless
|
||||||
#define yyless(n) \
|
#define yyless(n) \
|
||||||
do \
|
do { \
|
||||||
{ \
|
|
||||||
/* Undo effects of setting up dexp_text. */ \
|
/* Undo effects of setting up dexp_text. */ \
|
||||||
int yyless_macro_arg = (n); \
|
int yyless_macro_arg = (n); \
|
||||||
YY_LESS_LINENO(yyless_macro_arg); \
|
YY_LESS_LINENO(yyless_macro_arg); \
|
||||||
|
@ -1782,8 +1710,7 @@ static void yy_fatal_error (yyconst char* msg )
|
||||||
(yy_hold_char) = *(yy_c_buf_p); \
|
(yy_hold_char) = *(yy_c_buf_p); \
|
||||||
*(yy_c_buf_p) = '\0'; \
|
*(yy_c_buf_p) = '\0'; \
|
||||||
dexp_leng = yyless_macro_arg; \
|
dexp_leng = yyless_macro_arg; \
|
||||||
} \
|
} while (0)
|
||||||
while ( 0 )
|
|
||||||
|
|
||||||
/* Accessor methods (get/set functions) to struct members. */
|
/* Accessor methods (get/set functions) to struct members. */
|
||||||
|
|
||||||
|
@ -1965,10 +1892,7 @@ void dexp_free (void * ptr )
|
||||||
|
|
||||||
#line 62 "debugger-expr.l"
|
#line 62 "debugger-expr.l"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void dexp_flush()
|
void dexp_flush()
|
||||||
{
|
{
|
||||||
dexp__flush_buffer(YY_CURRENT_BUFFER);
|
dexp__flush_buffer(YY_CURRENT_BUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,21 +116,18 @@
|
||||||
#define TOK_NUMBER 276
|
#define TOK_NUMBER 276
|
||||||
#define TOK_ID 277
|
#define TOK_ID 277
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy the first part of user declarations. */
|
/* Copy the first part of user declarations. */
|
||||||
#line 1 "src/sdl/debugger-expr.y"
|
#line 1 "src/sdl/debugger-expr.y"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
#include "GBA.h"
|
|
||||||
#include "../common/Port.h"
|
#include "../common/Port.h"
|
||||||
|
#include "GBA.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
unsigned int dexp_result = 0;
|
unsigned int dexp_result = 0;
|
||||||
extern int dexp_error(char*);
|
extern int dexp_error(char*);
|
||||||
|
@ -148,9 +145,6 @@ std::map<std::string, u32> dexp_vars;
|
||||||
#define readByte(addr) \
|
#define readByte(addr) \
|
||||||
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
/* Enabling traces. */
|
||||||
#ifndef YYDEBUG
|
#ifndef YYDEBUG
|
||||||
#define YYDEBUG 0
|
#define YYDEBUG 0
|
||||||
|
@ -184,11 +178,8 @@ typedef union YYSTYPE
|
||||||
#define YYSTYPE_IS_TRIVIAL 1
|
#define YYSTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy the second part of user declarations. */
|
/* Copy the second part of user declarations. */
|
||||||
|
|
||||||
|
|
||||||
/* Line 216 of yacc.c. */
|
/* Line 216 of yacc.c. */
|
||||||
#line 188 "src/sdl/debugger-expr-yacc.cpp"
|
#line 188 "src/sdl/debugger-expr-yacc.cpp"
|
||||||
|
|
||||||
|
@ -268,8 +259,7 @@ static int
|
||||||
YYID(int i)
|
YYID(int i)
|
||||||
#else
|
#else
|
||||||
static int
|
static int
|
||||||
YYID (i)
|
YYID(i) int i;
|
||||||
int i;
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
|
@ -306,7 +296,10 @@ YYID (i)
|
||||||
|
|
||||||
#ifdef YYSTACK_ALLOC
|
#ifdef YYSTACK_ALLOC
|
||||||
/* Pacify GCC's `empty if-body' warning. */
|
/* Pacify GCC's `empty if-body' warning. */
|
||||||
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
|
#define YYSTACK_FREE(Ptr) \
|
||||||
|
do { /* empty */ \
|
||||||
|
; \
|
||||||
|
} while (YYID(0))
|
||||||
#ifndef YYSTACK_ALLOC_MAXIMUM
|
#ifndef YYSTACK_ALLOC_MAXIMUM
|
||||||
/* The OS might guarantee only one guard page at the bottom of the stack,
|
/* The OS might guarantee only one guard page at the bottom of the stack,
|
||||||
and a page size can be as small as 4096 bytes. So we cannot safely
|
and a page size can be as small as 4096 bytes. So we cannot safely
|
||||||
|
@ -345,14 +338,12 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||||
#endif
|
#endif
|
||||||
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
|
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
|
||||||
|
|
||||||
|
|
||||||
#if (!defined yyoverflow \
|
#if (!defined yyoverflow \
|
||||||
&& (!defined __cplusplus \
|
&& (!defined __cplusplus \
|
||||||
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
||||||
|
|
||||||
/* A type that is properly aligned for any stack member. */
|
/* A type that is properly aligned for any stack member. */
|
||||||
union yyalloc
|
union yyalloc {
|
||||||
{
|
|
||||||
yytype_int16 yyss;
|
yytype_int16 yyss;
|
||||||
YYSTYPE yyvs;
|
YYSTYPE yyvs;
|
||||||
};
|
};
|
||||||
|
@ -374,13 +365,11 @@ union yyalloc
|
||||||
__builtin_memcpy(To, From, (Count) * sizeof(*(From)))
|
__builtin_memcpy(To, From, (Count) * sizeof(*(From)))
|
||||||
#else
|
#else
|
||||||
#define YYCOPY(To, From, Count) \
|
#define YYCOPY(To, From, Count) \
|
||||||
do \
|
do { \
|
||||||
{ \
|
|
||||||
YYSIZE_T yyi; \
|
YYSIZE_T yyi; \
|
||||||
for (yyi = 0; yyi < (Count); yyi++) \
|
for (yyi = 0; yyi < (Count); yyi++) \
|
||||||
(To)[yyi] = (From)[yyi]; \
|
(To)[yyi] = (From)[yyi]; \
|
||||||
} \
|
} while (YYID(0))
|
||||||
while (YYID (0))
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -390,15 +379,13 @@ union yyalloc
|
||||||
stack. Advance YYPTR to a properly aligned location for the next
|
stack. Advance YYPTR to a properly aligned location for the next
|
||||||
stack. */
|
stack. */
|
||||||
#define YYSTACK_RELOCATE(Stack) \
|
#define YYSTACK_RELOCATE(Stack) \
|
||||||
do \
|
do { \
|
||||||
{ \
|
|
||||||
YYSIZE_T yynewbytes; \
|
YYSIZE_T yynewbytes; \
|
||||||
YYCOPY(&yyptr->Stack, Stack, yysize); \
|
YYCOPY(&yyptr->Stack, Stack, yysize); \
|
||||||
Stack = &yyptr->Stack; \
|
Stack = &yyptr->Stack; \
|
||||||
yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \
|
yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||||
yyptr += yynewbytes / sizeof(*yyptr); \
|
yyptr += yynewbytes / sizeof(*yyptr); \
|
||||||
} \
|
} while (YYID(0))
|
||||||
while (YYID (0))
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -424,8 +411,7 @@ union yyalloc
|
||||||
((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||||
|
|
||||||
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
|
||||||
static const yytype_uint8 yytranslate[] =
|
static const yytype_uint8 yytranslate[] = {
|
||||||
{
|
|
||||||
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
|
@ -459,16 +445,14 @@ static const yytype_uint8 yytranslate[] =
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
||||||
YYRHS. */
|
YYRHS. */
|
||||||
static const yytype_uint8 yyprhs[] =
|
static const yytype_uint8 yyprhs[] = {
|
||||||
{
|
|
||||||
0, 0, 3, 5, 7, 9, 13, 17, 20, 23,
|
0, 0, 3, 5, 7, 9, 13, 17, 20, 23,
|
||||||
27, 31, 35, 39, 43, 47, 51, 55, 57, 61,
|
27, 31, 35, 39, 43, 47, 51, 55, 57, 61,
|
||||||
65, 69
|
65, 69
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
static const yytype_int8 yyrhs[] =
|
static const yytype_int8 yyrhs[] = {
|
||||||
{
|
|
||||||
24, 0, -1, 25, -1, 21, -1, 22, -1, 25,
|
24, 0, -1, 25, -1, 21, -1, 22, -1, 25,
|
||||||
3, 25, -1, 25, 4, 25, -1, 4, 25, -1,
|
3, 25, -1, 25, 4, 25, -1, 4, 25, -1,
|
||||||
14, 25, -1, 25, 5, 25, -1, 25, 6, 25,
|
14, 25, -1, 25, 5, 25, -1, 25, 6, 25,
|
||||||
|
@ -480,8 +464,7 @@ static const yytype_int8 yyrhs[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
static const yytype_uint8 yyrline[] =
|
static const yytype_uint8 yyrline[] = {
|
||||||
{
|
|
||||||
0, 56, 56, 59, 60, 68, 69, 70, 71, 72,
|
0, 56, 56, 59, 60, 68, 69, 70, 71, 72,
|
||||||
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
|
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
|
||||||
83, 84
|
83, 84
|
||||||
|
@ -491,8 +474,7 @@ static const yytype_uint8 yyrline[] =
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
static const char *const yytname[] =
|
static const char* const yytname[] = {
|
||||||
{
|
|
||||||
"$end", "error", "$undefined", "TOK_PLUS", "TOK_MINUS", "TOK_DIVIDE",
|
"$end", "error", "$undefined", "TOK_PLUS", "TOK_MINUS", "TOK_DIVIDE",
|
||||||
"TOK_MULTIPLY", "TOK_LSHIFT", "TOK_RSHIFT", "TOK_LPAREN", "TOK_RPAREN",
|
"TOK_MULTIPLY", "TOK_LSHIFT", "TOK_RSHIFT", "TOK_LPAREN", "TOK_RPAREN",
|
||||||
"TOK_OR", "TOK_AND", "TOK_XOR", "TOK_NEGATE", "TOK_BBRACKET",
|
"TOK_OR", "TOK_AND", "TOK_XOR", "TOK_NEGATE", "TOK_BBRACKET",
|
||||||
|
@ -504,8 +486,7 @@ static const char *const yytname[] =
|
||||||
#ifdef YYPRINT
|
#ifdef YYPRINT
|
||||||
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
||||||
token YYLEX-NUM. */
|
token YYLEX-NUM. */
|
||||||
static const yytype_uint16 yytoknum[] =
|
static const yytype_uint16 yytoknum[] = {
|
||||||
{
|
|
||||||
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
||||||
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
||||||
275, 276, 277
|
275, 276, 277
|
||||||
|
@ -513,16 +494,14 @@ static const yytype_uint16 yytoknum[] =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
||||||
static const yytype_uint8 yyr1[] =
|
static const yytype_uint8 yyr1[] = {
|
||||||
{
|
|
||||||
0, 23, 24, 25, 25, 25, 25, 25, 25, 25,
|
0, 23, 24, 25, 25, 25, 25, 25, 25, 25,
|
||||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
25, 25
|
25, 25
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
||||||
static const yytype_uint8 yyr2[] =
|
static const yytype_uint8 yyr2[] = {
|
||||||
{
|
|
||||||
0, 2, 1, 1, 1, 3, 3, 2, 2, 3,
|
0, 2, 1, 1, 1, 3, 3, 2, 2, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3, 1, 3, 3,
|
3, 3, 3, 3, 3, 3, 3, 1, 3, 3,
|
||||||
3, 3
|
3, 3
|
||||||
|
@ -531,8 +510,7 @@ static const yytype_uint8 yyr2[] =
|
||||||
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
|
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
|
||||||
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
|
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
|
||||||
means the default is an error. */
|
means the default is an error. */
|
||||||
static const yytype_uint8 yydefact[] =
|
static const yytype_uint8 yydefact[] = {
|
||||||
{
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 17, 3,
|
0, 0, 0, 0, 0, 0, 0, 0, 17, 3,
|
||||||
4, 0, 2, 7, 0, 8, 0, 0, 0, 0,
|
4, 0, 2, 7, 0, 8, 0, 0, 0, 0,
|
||||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
@ -541,16 +519,14 @@ static const yytype_uint8 yydefact[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYDEFGOTO[NTERM-NUM]. */
|
/* YYDEFGOTO[NTERM-NUM]. */
|
||||||
static const yytype_int8 yydefgoto[] =
|
static const yytype_int8 yydefgoto[] = {
|
||||||
{
|
|
||||||
-1, 11, 12
|
-1, 11, 12
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||||
STATE-NUM. */
|
STATE-NUM. */
|
||||||
#define YYPACT_NINF -2
|
#define YYPACT_NINF -2
|
||||||
static const yytype_int8 yypact[] =
|
static const yytype_int8 yypact[] = {
|
||||||
{
|
|
||||||
25, 25, 25, 25, 25, 25, 25, 25, -2, -2,
|
25, 25, 25, 25, 25, 25, 25, 25, -2, -2,
|
||||||
-2, 13, 113, 122, 4, 122, 45, 62, 79, 96,
|
-2, 13, 113, 122, 4, 122, 45, 62, 79, 96,
|
||||||
-2, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
-2, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
|
@ -559,8 +535,7 @@ static const yytype_int8 yypact[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYPGOTO[NTERM-NUM]. */
|
/* YYPGOTO[NTERM-NUM]. */
|
||||||
static const yytype_int8 yypgoto[] =
|
static const yytype_int8 yypgoto[] = {
|
||||||
{
|
|
||||||
-2, -2, -1
|
-2, -2, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -569,8 +544,7 @@ static const yytype_int8 yypgoto[] =
|
||||||
number is the opposite. If zero, do what YYDEFACT says.
|
number is the opposite. If zero, do what YYDEFACT says.
|
||||||
If YYTABLE_NINF, syntax error. */
|
If YYTABLE_NINF, syntax error. */
|
||||||
#define YYTABLE_NINF -1
|
#define YYTABLE_NINF -1
|
||||||
static const yytype_uint8 yytable[] =
|
static const yytype_uint8 yytable[] = {
|
||||||
{
|
|
||||||
13, 14, 15, 16, 17, 18, 19, 21, 22, 23,
|
13, 14, 15, 16, 17, 18, 19, 21, 22, 23,
|
||||||
24, 25, 26, 20, 30, 27, 28, 29, 28, 29,
|
24, 25, 26, 20, 30, 27, 28, 29, 28, 29,
|
||||||
35, 36, 37, 38, 39, 40, 41, 42, 43, 1,
|
35, 36, 37, 38, 39, 40, 41, 42, 43, 1,
|
||||||
|
@ -587,8 +561,7 @@ static const yytype_uint8 yytable[] =
|
||||||
26, 0, 0, 27, 28, 29
|
26, 0, 0, 27, 28, 29
|
||||||
};
|
};
|
||||||
|
|
||||||
static const yytype_int8 yycheck[] =
|
static const yytype_int8 yycheck[] = {
|
||||||
{
|
|
||||||
1, 2, 3, 4, 5, 6, 7, 3, 4, 5,
|
1, 2, 3, 4, 5, 6, 7, 3, 4, 5,
|
||||||
6, 7, 8, 0, 10, 11, 12, 13, 12, 13,
|
6, 7, 8, 0, 10, 11, 12, 13, 12, 13,
|
||||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 4,
|
21, 22, 23, 24, 25, 26, 27, 28, 29, 4,
|
||||||
|
@ -607,8 +580,7 @@ static const yytype_int8 yycheck[] =
|
||||||
|
|
||||||
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
||||||
symbol of state STATE-NUM. */
|
symbol of state STATE-NUM. */
|
||||||
static const yytype_uint8 yystos[] =
|
static const yytype_uint8 yystos[] = {
|
||||||
{
|
|
||||||
0, 4, 9, 14, 15, 16, 17, 18, 20, 21,
|
0, 4, 9, 14, 15, 16, 17, 18, 20, 21,
|
||||||
22, 24, 25, 25, 25, 25, 25, 25, 25, 25,
|
22, 24, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
0, 3, 4, 5, 6, 7, 8, 11, 12, 13,
|
0, 3, 4, 5, 6, 7, 8, 11, 12, 13,
|
||||||
|
@ -625,7 +597,6 @@ static const yytype_uint8 yystos[] =
|
||||||
#define YYABORT goto yyabortlab
|
#define YYABORT goto yyabortlab
|
||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
|
|
||||||
|
|
||||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||||
to ease the transition to the new meaning of YYERROR, for GCC.
|
to ease the transition to the new meaning of YYERROR, for GCC.
|
||||||
Once GCC version 2 has supplanted version 1, this can go. */
|
Once GCC version 2 has supplanted version 1, this can go. */
|
||||||
|
@ -635,8 +606,8 @@ static const yytype_uint8 yystos[] =
|
||||||
#define YYRECOVERING() (!!yyerrstatus)
|
#define YYRECOVERING() (!!yyerrstatus)
|
||||||
|
|
||||||
#define YYBACKUP(Token, Value) \
|
#define YYBACKUP(Token, Value) \
|
||||||
do \
|
\
|
||||||
if (yychar == YYEMPTY && yylen == 1) \
|
do if (yychar == YYEMPTY && yylen == 1) \
|
||||||
{ \
|
{ \
|
||||||
yychar = (Token); \
|
yychar = (Token); \
|
||||||
yylval = (Value); \
|
yylval = (Value); \
|
||||||
|
@ -649,13 +620,12 @@ do \
|
||||||
yyerror(YY_("syntax error: cannot back up")); \
|
yyerror(YY_("syntax error: cannot back up")); \
|
||||||
YYERROR; \
|
YYERROR; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
while(YYID(0))
|
while(YYID(0))
|
||||||
|
|
||||||
|
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
#define YYERRCODE 256
|
#define YYERRCODE 256
|
||||||
|
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||||
If N is 0, then set CURRENT to the empty location which ends
|
If N is 0, then set CURRENT to the empty location which ends
|
||||||
the previous symbol: RHS[0] (always defined). */
|
the previous symbol: RHS[0] (always defined). */
|
||||||
|
@ -664,24 +634,18 @@ while (YYID (0))
|
||||||
#ifndef YYLLOC_DEFAULT
|
#ifndef YYLLOC_DEFAULT
|
||||||
#define YYLLOC_DEFAULT(Current, Rhs, N) \
|
#define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (YYID (N)) \
|
if (YYID(N)) { \
|
||||||
{ \
|
|
||||||
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
|
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
|
||||||
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
|
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
|
||||||
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \
|
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \
|
||||||
(Current).last_column = YYRHSLOC(Rhs, N).last_column; \
|
(Current).last_column = YYRHSLOC(Rhs, N).last_column; \
|
||||||
} \
|
} else { \
|
||||||
else \
|
(Current).first_line = (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \
|
||||||
{ \
|
(Current).first_column = (Current).last_column = YYRHSLOC(Rhs, 0).last_column; \
|
||||||
(Current).first_line = (Current).last_line = \
|
|
||||||
YYRHSLOC (Rhs, 0).last_line; \
|
|
||||||
(Current).first_column = (Current).last_column = \
|
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
|
||||||
} \
|
} \
|
||||||
while (YYID(0))
|
while (YYID(0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
we won't break user code: when these are the locations we know. */
|
we won't break user code: when these are the locations we know. */
|
||||||
|
@ -697,7 +661,6 @@ while (YYID (0))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||||
|
|
||||||
#ifdef YYLEX_PARAM
|
#ifdef YYLEX_PARAM
|
||||||
|
@ -715,22 +678,28 @@ while (YYID (0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define YYDPRINTF(Args) \
|
#define YYDPRINTF(Args) \
|
||||||
do { \
|
\
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (YYID (0))
|
\
|
||||||
|
} \
|
||||||
|
while (YYID(0))
|
||||||
|
|
||||||
#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
\
|
||||||
if (yydebug) \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
if (yydebug) { \
|
||||||
YYFPRINTF(stderr, "%s ", Title); \
|
YYFPRINTF(stderr, "%s ", Title); \
|
||||||
yy_symbol_print(stderr, \
|
yy_symbol_print(stderr, \
|
||||||
Type, Value); \
|
Type, Value); \
|
||||||
YYFPRINTF(stderr, "\n"); \
|
YYFPRINTF(stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (YYID (0))
|
\
|
||||||
|
} \
|
||||||
|
while (YYID(0))
|
||||||
|
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
|
@ -757,14 +726,12 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
|
||||||
#else
|
#else
|
||||||
YYUSE(yyoutput);
|
YYUSE(yyoutput);
|
||||||
#endif
|
#endif
|
||||||
switch (yytype)
|
switch (yytype) {
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------.
|
/*--------------------------------.
|
||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
@ -813,11 +780,14 @@ yy_stack_print (bottom, top)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YY_STACK_PRINT(Bottom, Top) \
|
#define YY_STACK_PRINT(Bottom, Top) \
|
||||||
do { \
|
\
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_stack_print((Bottom), (Top)); \
|
yy_stack_print((Bottom), (Top)); \
|
||||||
} while (YYID (0))
|
\
|
||||||
|
} \
|
||||||
|
while (YYID(0))
|
||||||
|
|
||||||
/*------------------------------------------------.
|
/*------------------------------------------------.
|
||||||
| Report that the YYRULE is going to be reduced. |
|
| Report that the YYRULE is going to be reduced. |
|
||||||
|
@ -840,21 +810,23 @@ yy_reduce_print (yyvsp, yyrule)
|
||||||
YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n",
|
YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||||
yyrule - 1, yylno);
|
yyrule - 1, yylno);
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
for (yyi = 0; yyi < yynrhs; yyi++) {
|
||||||
{
|
|
||||||
fprintf(stderr, " $%d = ", yyi + 1);
|
fprintf(stderr, " $%d = ", yyi + 1);
|
||||||
yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi],
|
yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi],
|
||||||
&(yyvsp[(yyi + 1) - (yynrhs)])
|
&(yyvsp[(yyi + 1) - (yynrhs)]));
|
||||||
);
|
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YY_REDUCE_PRINT(Rule) \
|
#define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
\
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print(yyvsp, Rule); \
|
yy_reduce_print(yyvsp, Rule); \
|
||||||
} while (YYID (0))
|
\
|
||||||
|
} \
|
||||||
|
while (YYID(0))
|
||||||
|
|
||||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
multiple parsers can coexist. */
|
multiple parsers can coexist. */
|
||||||
|
@ -866,7 +838,6 @@ int yydebug;
|
||||||
#define YY_REDUCE_PRINT(Rule)
|
#define YY_REDUCE_PRINT(Rule)
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
||||||
|
|
||||||
|
|
||||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||||
#ifndef YYINITDEPTH
|
#ifndef YYINITDEPTH
|
||||||
#define YYINITDEPTH 200
|
#define YYINITDEPTH 200
|
||||||
|
@ -883,8 +854,6 @@ int yydebug;
|
||||||
#define YYMAXDEPTH 10000
|
#define YYMAXDEPTH 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
||||||
|
|
||||||
#ifndef yystrlen
|
#ifndef yystrlen
|
||||||
|
@ -922,8 +891,7 @@ static char *
|
||||||
yystpcpy(char* yydest, const char* yysrc)
|
yystpcpy(char* yydest, const char* yysrc)
|
||||||
#else
|
#else
|
||||||
static char*
|
static char*
|
||||||
yystpcpy (yydest, yysrc)
|
yystpcpy(yydest, yysrc) char* yydest;
|
||||||
char *yydest;
|
|
||||||
const char* yysrc;
|
const char* yysrc;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -949,14 +917,12 @@ yystpcpy (yydest, yysrc)
|
||||||
static YYSIZE_T
|
static YYSIZE_T
|
||||||
yytnamerr(char* yyres, const char* yystr)
|
yytnamerr(char* yyres, const char* yystr)
|
||||||
{
|
{
|
||||||
if (*yystr == '"')
|
if (*yystr == '"') {
|
||||||
{
|
|
||||||
YYSIZE_T yyn = 0;
|
YYSIZE_T yyn = 0;
|
||||||
char const* yyp = yystr;
|
char const* yyp = yystr;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
switch (*++yyp)
|
switch (*++yyp) {
|
||||||
{
|
|
||||||
case '\'':
|
case '\'':
|
||||||
case ',':
|
case ',':
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
|
@ -1000,8 +966,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||||
|
|
||||||
if (!(YYPACT_NINF < yyn && yyn <= YYLAST))
|
if (!(YYPACT_NINF < yyn && yyn <= YYLAST))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
int yytype = YYTRANSLATE(yychar);
|
int yytype = YYTRANSLATE(yychar);
|
||||||
YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
|
YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
|
||||||
YYSIZE_T yysize = yysize0;
|
YYSIZE_T yysize = yysize0;
|
||||||
|
@ -1044,10 +1009,8 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||||
yyfmt = yystpcpy(yyformat, yyunexpected);
|
yyfmt = yystpcpy(yyformat, yyunexpected);
|
||||||
|
|
||||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
|
||||||
{
|
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
|
||||||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
|
||||||
{
|
|
||||||
yycount = 1;
|
yycount = 1;
|
||||||
yysize = yysize0;
|
yysize = yysize0;
|
||||||
yyformat[sizeof yyunexpected - 1] = '\0';
|
yyformat[sizeof yyunexpected - 1] = '\0';
|
||||||
|
@ -1069,22 +1032,17 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||||
if (yysize_overflow)
|
if (yysize_overflow)
|
||||||
return YYSIZE_MAXIMUM;
|
return YYSIZE_MAXIMUM;
|
||||||
|
|
||||||
if (yyresult)
|
if (yyresult) {
|
||||||
{
|
|
||||||
/* Avoid sprintf, as that infringes on the user's name space.
|
/* Avoid sprintf, as that infringes on the user's name space.
|
||||||
Don't have undefined behavior even if the translation
|
Don't have undefined behavior even if the translation
|
||||||
produced a string with the wrong number of "%s"s. */
|
produced a string with the wrong number of "%s"s. */
|
||||||
char* yyp = yyresult;
|
char* yyp = yyresult;
|
||||||
int yyi = 0;
|
int yyi = 0;
|
||||||
while ((*yyp = *yyf) != '\0')
|
while ((*yyp = *yyf) != '\0') {
|
||||||
{
|
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
|
||||||
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
|
|
||||||
{
|
|
||||||
yyp += yytnamerr(yyp, yyarg[yyi++]);
|
yyp += yytnamerr(yyp, yyarg[yyi++]);
|
||||||
yyf += 2;
|
yyf += 2;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
yyp++;
|
yyp++;
|
||||||
yyf++;
|
yyf++;
|
||||||
}
|
}
|
||||||
|
@ -1094,7 +1052,6 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------.
|
/*-----------------------------------------------.
|
||||||
| Release the memory associated to this symbol. |
|
| Release the memory associated to this symbol. |
|
||||||
|
@ -1119,14 +1076,12 @@ yydestruct (yymsg, yytype, yyvaluep)
|
||||||
yymsg = "Deleting";
|
yymsg = "Deleting";
|
||||||
YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
|
YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
|
||||||
|
|
||||||
switch (yytype)
|
switch (yytype) {
|
||||||
{
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Prevent warnings from -Wmissing-prototypes. */
|
/* Prevent warnings from -Wmissing-prototypes. */
|
||||||
|
|
||||||
|
@ -1144,8 +1099,6 @@ int yyparse ();
|
||||||
#endif
|
#endif
|
||||||
#endif /* ! YYPARSE_PARAM */
|
#endif /* ! YYPARSE_PARAM */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The look-ahead symbol. */
|
/* The look-ahead symbol. */
|
||||||
int yychar;
|
int yychar;
|
||||||
|
|
||||||
|
@ -1155,8 +1108,6 @@ YYSTYPE yylval;
|
||||||
/* Number of syntax errors so far. */
|
/* Number of syntax errors so far. */
|
||||||
int yynerrs;
|
int yynerrs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------.
|
/*----------.
|
||||||
| yyparse. |
|
| yyparse. |
|
||||||
`----------*/
|
`----------*/
|
||||||
|
@ -1164,21 +1115,17 @@ int yynerrs;
|
||||||
#ifdef YYPARSE_PARAM
|
#ifdef YYPARSE_PARAM
|
||||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||||
|| defined __cplusplus || defined _MSC_VER)
|
|| defined __cplusplus || defined _MSC_VER)
|
||||||
int
|
int yyparse(void* YYPARSE_PARAM)
|
||||||
yyparse (void *YYPARSE_PARAM)
|
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
yyparse (YYPARSE_PARAM)
|
yyparse(YYPARSE_PARAM) void* YYPARSE_PARAM;
|
||||||
void *YYPARSE_PARAM;
|
|
||||||
#endif
|
#endif
|
||||||
#else /* ! YYPARSE_PARAM */
|
#else /* ! YYPARSE_PARAM */
|
||||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||||
|| defined __cplusplus || defined _MSC_VER)
|
|| defined __cplusplus || defined _MSC_VER)
|
||||||
int
|
int yyparse(void)
|
||||||
yyparse (void)
|
|
||||||
#else
|
#else
|
||||||
int
|
int yyparse()
|
||||||
yyparse ()
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -1216,8 +1163,6 @@ yyparse ()
|
||||||
YYSTYPE* yyvs = yyvsa;
|
YYSTYPE* yyvs = yyvsa;
|
||||||
YYSTYPE* yyvsp;
|
YYSTYPE* yyvsp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
|
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
|
||||||
|
|
||||||
YYSIZE_T yystacksize = YYINITDEPTH;
|
YYSIZE_T yystacksize = YYINITDEPTH;
|
||||||
|
@ -1226,7 +1171,6 @@ yyparse ()
|
||||||
action routines. */
|
action routines. */
|
||||||
YYSTYPE yyval;
|
YYSTYPE yyval;
|
||||||
|
|
||||||
|
|
||||||
/* The number of symbols on the RHS of the reduced rule.
|
/* The number of symbols on the RHS of the reduced rule.
|
||||||
Keep to zero when no symbol should be popped. */
|
Keep to zero when no symbol should be popped. */
|
||||||
int yylen = 0;
|
int yylen = 0;
|
||||||
|
@ -1259,8 +1203,7 @@ yyparse ()
|
||||||
yysetstate:
|
yysetstate:
|
||||||
*yyssp = yystate;
|
*yyssp = yystate;
|
||||||
|
|
||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp) {
|
||||||
{
|
|
||||||
/* Get the current used size of the three stacks, in elements. */
|
/* Get the current used size of the three stacks, in elements. */
|
||||||
YYSIZE_T yysize = yyssp - yyss + 1;
|
YYSIZE_T yysize = yyssp - yyss + 1;
|
||||||
|
|
||||||
|
@ -1272,7 +1215,6 @@ yyparse ()
|
||||||
YYSTYPE* yyvs1 = yyvs;
|
YYSTYPE* yyvs1 = yyvs;
|
||||||
yytype_int16* yyss1 = yyss;
|
yytype_int16* yyss1 = yyss;
|
||||||
|
|
||||||
|
|
||||||
/* Each stack pointer address is followed by the size of the
|
/* Each stack pointer address is followed by the size of the
|
||||||
data in use in that stack, in bytes. This used to be a
|
data in use in that stack, in bytes. This used to be a
|
||||||
conditional around just the two extra args, but that might
|
conditional around just the two extra args, but that might
|
||||||
|
@ -1299,8 +1241,7 @@ yyparse ()
|
||||||
|
|
||||||
{
|
{
|
||||||
yytype_int16* yyss1 = yyss;
|
yytype_int16* yyss1 = yyss;
|
||||||
union yyalloc *yyptr =
|
union yyalloc* yyptr = (union yyalloc*)YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize));
|
||||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
|
||||||
if (!yyptr)
|
if (!yyptr)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
YYSTACK_RELOCATE(yyss);
|
YYSTACK_RELOCATE(yyss);
|
||||||
|
@ -1316,7 +1257,6 @@ yyparse ()
|
||||||
yyssp = yyss + yysize - 1;
|
yyssp = yyss + yysize - 1;
|
||||||
yyvsp = yyvs + yysize - 1;
|
yyvsp = yyvs + yysize - 1;
|
||||||
|
|
||||||
|
|
||||||
YYDPRINTF((stderr, "Stack size increased to %lu\n",
|
YYDPRINTF((stderr, "Stack size increased to %lu\n",
|
||||||
(unsigned long int)yystacksize));
|
(unsigned long int)yystacksize));
|
||||||
|
|
||||||
|
@ -1344,19 +1284,15 @@ yybackup:
|
||||||
/* Not known => get a look-ahead token if don't already have one. */
|
/* Not known => get a look-ahead token if don't already have one. */
|
||||||
|
|
||||||
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
|
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
|
||||||
if (yychar == YYEMPTY)
|
if (yychar == YYEMPTY) {
|
||||||
{
|
|
||||||
YYDPRINTF((stderr, "Reading a token: "));
|
YYDPRINTF((stderr, "Reading a token: "));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF) {
|
||||||
{
|
|
||||||
yychar = yytoken = YYEOF;
|
yychar = yytoken = YYEOF;
|
||||||
YYDPRINTF((stderr, "Now at end of input.\n"));
|
YYDPRINTF((stderr, "Now at end of input.\n"));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
yytoken = YYTRANSLATE(yychar);
|
yytoken = YYTRANSLATE(yychar);
|
||||||
YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
|
||||||
}
|
}
|
||||||
|
@ -1367,8 +1303,7 @@ yybackup:
|
||||||
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
|
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
|
||||||
goto yydefault;
|
goto yydefault;
|
||||||
yyn = yytable[yyn];
|
yyn = yytable[yyn];
|
||||||
if (yyn <= 0)
|
if (yyn <= 0) {
|
||||||
{
|
|
||||||
if (yyn == 0 || yyn == YYTABLE_NINF)
|
if (yyn == 0 || yyn == YYTABLE_NINF)
|
||||||
goto yyerrlab;
|
goto yyerrlab;
|
||||||
yyn = -yyn;
|
yyn = -yyn;
|
||||||
|
@ -1395,7 +1330,6 @@ yybackup:
|
||||||
|
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------.
|
/*-----------------------------------------------------------.
|
||||||
| yydefault -- do the default action for the current state. |
|
| yydefault -- do the default action for the current state. |
|
||||||
`-----------------------------------------------------------*/
|
`-----------------------------------------------------------*/
|
||||||
|
@ -1405,7 +1339,6 @@ yydefault:
|
||||||
goto yyerrlab;
|
goto yyerrlab;
|
||||||
goto yyreduce;
|
goto yyreduce;
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------.
|
/*-----------------------------.
|
||||||
| yyreduce -- Do a reduction. |
|
| yyreduce -- Do a reduction. |
|
||||||
`-----------------------------*/
|
`-----------------------------*/
|
||||||
|
@ -1423,19 +1356,19 @@ yyreduce:
|
||||||
GCC warning that YYVAL may be used uninitialized. */
|
GCC warning that YYVAL may be used uninitialized. */
|
||||||
yyval = yyvsp[1 - yylen];
|
yyval = yyvsp[1 - yylen];
|
||||||
|
|
||||||
|
|
||||||
YY_REDUCE_PRINT(yyn);
|
YY_REDUCE_PRINT(yyn);
|
||||||
switch (yyn)
|
switch (yyn) {
|
||||||
{
|
|
||||||
case 2:
|
case 2:
|
||||||
#line 56 "src/sdl/debugger-expr.y"
|
#line 56 "src/sdl/debugger-expr.y"
|
||||||
{dexp_result = (yyvsp[(1) - (1)].number);}
|
{
|
||||||
break;
|
dexp_result = (yyvsp[(1) - (1)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
#line 59 "src/sdl/debugger-expr.y"
|
#line 59 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (1)].number); }
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (1)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
#line 60 "src/sdl/debugger-expr.y"
|
#line 60 "src/sdl/debugger-expr.y"
|
||||||
|
@ -1446,98 +1379,114 @@ yyreduce:
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
(yyval.number) = dexp_vars[v];
|
(yyval.number) = dexp_vars[v];
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
#line 68 "src/sdl/debugger-expr.y"
|
#line 68 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) + (yyvsp[(3) - (3)].number); }
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) + (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
#line 69 "src/sdl/debugger-expr.y"
|
#line 69 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) - (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) - (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
#line 70 "src/sdl/debugger-expr.y"
|
#line 70 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = -(yyvsp[(2) - (2)].number);}
|
{
|
||||||
break;
|
(yyval.number) = -(yyvsp[(2) - (2)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
#line 71 "src/sdl/debugger-expr.y"
|
#line 71 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = ~(yyvsp[(2) - (2)].number);}
|
{
|
||||||
break;
|
(yyval.number) = ~(yyvsp[(2) - (2)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
#line 72 "src/sdl/debugger-expr.y"
|
#line 72 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) / (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) / (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
#line 73 "src/sdl/debugger-expr.y"
|
#line 73 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) * (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) * (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 11:
|
case 11:
|
||||||
#line 74 "src/sdl/debugger-expr.y"
|
#line 74 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) << (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) << (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
#line 75 "src/sdl/debugger-expr.y"
|
#line 75 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) >> (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) >> (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 13:
|
case 13:
|
||||||
#line 76 "src/sdl/debugger-expr.y"
|
#line 76 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number)=(yyvsp[(2) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(2) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 14:
|
case 14:
|
||||||
#line 77 "src/sdl/debugger-expr.y"
|
#line 77 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) & (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) & (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 15:
|
case 15:
|
||||||
#line 78 "src/sdl/debugger-expr.y"
|
#line 78 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) | (yyvsp[(3) - (3)].number);}
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) | (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
#line 79 "src/sdl/debugger-expr.y"
|
#line 79 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = (yyvsp[(1) - (3)].number) ^ (yyvsp[(3) - (3)].number); }
|
{
|
||||||
break;
|
(yyval.number) = (yyvsp[(1) - (3)].number) ^ (yyvsp[(3) - (3)].number);
|
||||||
|
} break;
|
||||||
|
|
||||||
case 17:
|
case 17:
|
||||||
#line 80 "src/sdl/debugger-expr.y"
|
#line 80 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = reg[(yyvsp[(1) - (1)].number)].I; }
|
{
|
||||||
break;
|
(yyval.number) = reg[(yyvsp[(1) - (1)].number)].I;
|
||||||
|
} break;
|
||||||
|
|
||||||
case 18:
|
case 18:
|
||||||
#line 81 "src/sdl/debugger-expr.y"
|
#line 81 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = readByte((yyvsp[(2) - (3)].number)); }
|
{
|
||||||
break;
|
(yyval.number) = readByte((yyvsp[(2) - (3)].number));
|
||||||
|
} break;
|
||||||
|
|
||||||
case 19:
|
case 19:
|
||||||
#line 82 "src/sdl/debugger-expr.y"
|
#line 82 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = readHalfWord((yyvsp[(2) - (3)].number)); }
|
{
|
||||||
break;
|
(yyval.number) = readHalfWord((yyvsp[(2) - (3)].number));
|
||||||
|
} break;
|
||||||
|
|
||||||
case 20:
|
case 20:
|
||||||
#line 83 "src/sdl/debugger-expr.y"
|
#line 83 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = readWord((yyvsp[(2) - (3)].number)); }
|
{
|
||||||
break;
|
(yyval.number) = readWord((yyvsp[(2) - (3)].number));
|
||||||
|
} break;
|
||||||
|
|
||||||
case 21:
|
case 21:
|
||||||
#line 84 "src/sdl/debugger-expr.y"
|
#line 84 "src/sdl/debugger-expr.y"
|
||||||
{ (yyval.number) = readWord((yyvsp[(2) - (3)].number)); }
|
{
|
||||||
break;
|
(yyval.number) = readWord((yyvsp[(2) - (3)].number));
|
||||||
|
} break;
|
||||||
|
|
||||||
/* Line 1267 of yacc.c. */
|
/* Line 1267 of yacc.c. */
|
||||||
#line 1534 "src/sdl/debugger-expr-yacc.cpp"
|
#line 1534 "src/sdl/debugger-expr-yacc.cpp"
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||||
|
|
||||||
|
@ -1547,7 +1496,6 @@ yyreduce:
|
||||||
|
|
||||||
*++yyvsp = yyval;
|
*++yyvsp = yyval;
|
||||||
|
|
||||||
|
|
||||||
/* Now `shift' the result of the reduction. Determine what state
|
/* Now `shift' the result of the reduction. Determine what state
|
||||||
that goes to, based on the state we popped back to and the rule
|
that goes to, based on the state we popped back to and the rule
|
||||||
number reduced by. */
|
number reduced by. */
|
||||||
|
@ -1562,22 +1510,19 @@ yyreduce:
|
||||||
|
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------.
|
/*------------------------------------.
|
||||||
| yyerrlab -- here on detecting error |
|
| yyerrlab -- here on detecting error |
|
||||||
`------------------------------------*/
|
`------------------------------------*/
|
||||||
yyerrlab:
|
yyerrlab:
|
||||||
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
||||||
if (!yyerrstatus)
|
if (!yyerrstatus) {
|
||||||
{
|
|
||||||
++yynerrs;
|
++yynerrs;
|
||||||
#if !YYERROR_VERBOSE
|
#if !YYERROR_VERBOSE
|
||||||
yyerror(YY_("syntax error"));
|
yyerror(YY_("syntax error"));
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
|
YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
|
||||||
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
|
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
|
||||||
{
|
|
||||||
YYSIZE_T yyalloc = 2 * yysize;
|
YYSIZE_T yyalloc = 2 * yysize;
|
||||||
if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
|
if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
|
||||||
yyalloc = YYSTACK_ALLOC_MAXIMUM;
|
yyalloc = YYSTACK_ALLOC_MAXIMUM;
|
||||||
|
@ -1586,20 +1531,16 @@ yyerrlab:
|
||||||
yymsg = (char*)YYSTACK_ALLOC(yyalloc);
|
yymsg = (char*)YYSTACK_ALLOC(yyalloc);
|
||||||
if (yymsg)
|
if (yymsg)
|
||||||
yymsg_alloc = yyalloc;
|
yymsg_alloc = yyalloc;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
yymsg = yymsgbuf;
|
yymsg = yymsgbuf;
|
||||||
yymsg_alloc = sizeof yymsgbuf;
|
yymsg_alloc = sizeof yymsgbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < yysize && yysize <= yymsg_alloc)
|
if (0 < yysize && yysize <= yymsg_alloc) {
|
||||||
{
|
|
||||||
(void)yysyntax_error(yymsg, yystate, yychar);
|
(void)yysyntax_error(yymsg, yystate, yychar);
|
||||||
yyerror(yymsg);
|
yyerror(yymsg);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
yyerror(YY_("syntax error"));
|
yyerror(YY_("syntax error"));
|
||||||
if (yysize != 0)
|
if (yysize != 0)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
|
@ -1608,21 +1549,15 @@ yyerrlab:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (yyerrstatus == 3) {
|
||||||
|
|
||||||
if (yyerrstatus == 3)
|
|
||||||
{
|
|
||||||
/* If just tried and failed to reuse look-ahead token after an
|
/* If just tried and failed to reuse look-ahead token after an
|
||||||
error, discard it. */
|
error, discard it. */
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF) {
|
||||||
{
|
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == YYEOF)
|
if (yychar == YYEOF)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
yydestruct("Error: discarding",
|
yydestruct("Error: discarding",
|
||||||
yytoken, &yylval);
|
yytoken, &yylval);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
|
@ -1633,7 +1568,6 @@ yyerrlab:
|
||||||
token. */
|
token. */
|
||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------.
|
/*---------------------------------------------------.
|
||||||
| yyerrorlab -- error raised explicitly by YYERROR. |
|
| yyerrorlab -- error raised explicitly by YYERROR. |
|
||||||
`---------------------------------------------------*/
|
`---------------------------------------------------*/
|
||||||
|
@ -1653,21 +1587,17 @@ yyerrorlab:
|
||||||
yystate = *yyssp;
|
yystate = *yyssp;
|
||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------.
|
/*-------------------------------------------------------------.
|
||||||
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
yyerrlab1:
|
yyerrlab1:
|
||||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
for (;;)
|
for (;;) {
|
||||||
{
|
|
||||||
yyn = yypact[yystate];
|
yyn = yypact[yystate];
|
||||||
if (yyn != YYPACT_NINF)
|
if (yyn != YYPACT_NINF) {
|
||||||
{
|
|
||||||
yyn += YYTERROR;
|
yyn += YYTERROR;
|
||||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
|
||||||
{
|
|
||||||
yyn = yytable[yyn];
|
yyn = yytable[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
break;
|
break;
|
||||||
|
@ -1678,7 +1608,6 @@ yyerrlab1:
|
||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
|
|
||||||
yydestruct("Error: popping",
|
yydestruct("Error: popping",
|
||||||
yystos[yystate], yyvsp);
|
yystos[yystate], yyvsp);
|
||||||
YYPOPSTACK(1);
|
YYPOPSTACK(1);
|
||||||
|
@ -1691,14 +1620,12 @@ yyerrlab1:
|
||||||
|
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
|
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
|
YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
|
||||||
|
|
||||||
yystate = yyn;
|
yystate = yyn;
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------.
|
/*-------------------------------------.
|
||||||
| yyacceptlab -- YYACCEPT comes here. |
|
| yyacceptlab -- YYACCEPT comes here. |
|
||||||
`-------------------------------------*/
|
`-------------------------------------*/
|
||||||
|
@ -1731,8 +1658,7 @@ yyreturn:
|
||||||
this YYABORT or YYACCEPT. */
|
this YYABORT or YYACCEPT. */
|
||||||
YYPOPSTACK(yylen);
|
YYPOPSTACK(yylen);
|
||||||
YY_STACK_PRINT(yyss, yyssp);
|
YY_STACK_PRINT(yyss, yyssp);
|
||||||
while (yyssp != yyss)
|
while (yyssp != yyss) {
|
||||||
{
|
|
||||||
yydestruct("Cleanup: popping",
|
yydestruct("Cleanup: popping",
|
||||||
yystos[*yyssp], yyvsp);
|
yystos[*yyssp], yyvsp);
|
||||||
YYPOPSTACK(1);
|
YYPOPSTACK(1);
|
||||||
|
@ -1749,10 +1675,8 @@ yyreturn:
|
||||||
return YYID(yyresult);
|
return YYID(yyresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#line 86 "src/sdl/debugger-expr.y"
|
#line 86 "src/sdl/debugger-expr.y"
|
||||||
|
|
||||||
|
|
||||||
bool dexp_eval(char* expr, u32* result)
|
bool dexp_eval(char* expr, u32* result)
|
||||||
{
|
{
|
||||||
extern void dexp_flush();
|
extern void dexp_flush();
|
||||||
|
@ -1761,7 +1685,6 @@ bool dexp_eval(char *expr, u32 *result)
|
||||||
|
|
||||||
dexp_flush();
|
dexp_flush();
|
||||||
|
|
||||||
|
|
||||||
dexprString = expr;
|
dexprString = expr;
|
||||||
dexprCol = 0;
|
dexprCol = 0;
|
||||||
|
|
||||||
|
|
224
src/gba/elf.cpp
224
src/gba/elf.cpp
|
@ -2,10 +2,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "GBA.h"
|
|
||||||
#include "../common/Port.h"
|
|
||||||
#include "elf.h"
|
|
||||||
#include "../NLS.h"
|
#include "../NLS.h"
|
||||||
|
#include "../common/Port.h"
|
||||||
|
#include "GBA.h"
|
||||||
|
#include "elf.h"
|
||||||
|
|
||||||
#define elfReadMemory(addr) \
|
#define elfReadMemory(addr) \
|
||||||
READ32LE((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
READ32LE((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||||
|
@ -185,7 +185,6 @@ enum ELFRegMode {
|
||||||
REG_REGISTER
|
REG_REGISTER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ELFFrameStateRegister {
|
struct ELFFrameStateRegister {
|
||||||
ELFRegMode mode;
|
ELFRegMode mode;
|
||||||
int reg;
|
int reg;
|
||||||
|
@ -483,8 +482,7 @@ ELFfde *elfGetFde(u32 address)
|
||||||
if (elfFdes) {
|
if (elfFdes) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < elfFdeCount; i++) {
|
for (i = 0; i < elfFdeCount; i++) {
|
||||||
if(address >= elfFdes[i]->address &&
|
if (address >= elfFdes[i]->address && address < elfFdes[i]->end) {
|
||||||
address < elfFdes[i]->end) {
|
|
||||||
return elfFdes[i];
|
return elfFdes[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,8 +509,7 @@ void elfExecuteCFAInstructions(ELFFrameState *state, u8 *data, u32 len,
|
||||||
case DW_CFA_offset:
|
case DW_CFA_offset:
|
||||||
reg = op & 0x3f;
|
reg = op & 0x3f;
|
||||||
state->registers.regs[reg].mode = REG_OFFSET;
|
state->registers.regs[reg].mode = REG_OFFSET;
|
||||||
state->registers.regs[reg].offset = state->dataAlign *
|
state->registers.regs[reg].offset = state->dataAlign * (s32)elfReadLEB128(data, &bytes);
|
||||||
(s32)elfReadLEB128(data, &bytes);
|
|
||||||
data += bytes;
|
data += bytes;
|
||||||
break;
|
break;
|
||||||
case DW_CFA_restore:
|
case DW_CFA_restore:
|
||||||
|
@ -539,8 +536,7 @@ void elfExecuteCFAInstructions(ELFFrameState *state, u8 *data, u32 len,
|
||||||
reg = elfReadLEB128(data, &bytes);
|
reg = elfReadLEB128(data, &bytes);
|
||||||
data += bytes;
|
data += bytes;
|
||||||
state->registers.regs[reg].mode = REG_OFFSET;
|
state->registers.regs[reg].mode = REG_OFFSET;
|
||||||
state->registers.regs[reg].offset = state->dataAlign *
|
state->registers.regs[reg].offset = state->dataAlign * (s32)elfReadLEB128(data, &bytes);
|
||||||
(s32)elfReadLEB128(data, &bytes);
|
|
||||||
data += bytes;
|
data += bytes;
|
||||||
break;
|
break;
|
||||||
case DW_CFA_restore_extended:
|
case DW_CFA_restore_extended:
|
||||||
|
@ -653,17 +649,14 @@ void elfPrintCallChain(u32 address)
|
||||||
memcpy(&newRegs[0], ®s[0], sizeof(reg_pair) * 15);
|
memcpy(&newRegs[0], ®s[0], sizeof(reg_pair) * 15);
|
||||||
u32 addr = 0;
|
u32 addr = 0;
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
ELFFrameStateRegister *r = &state->registers.
|
ELFFrameStateRegister* r = &state->registers.regs[i];
|
||||||
regs[i];
|
|
||||||
|
|
||||||
switch (r->mode) {
|
switch (r->mode) {
|
||||||
case REG_NOT_SET:
|
case REG_NOT_SET:
|
||||||
newRegs[i].I = regs[i].I;
|
newRegs[i].I = regs[i].I;
|
||||||
break;
|
break;
|
||||||
case REG_OFFSET:
|
case REG_OFFSET:
|
||||||
newRegs[i].I = elfReadMemory(regs[state->cfaRegister].I +
|
newRegs[i].I = elfReadMemory(regs[state->cfaRegister].I + state->cfaOffset + r->offset);
|
||||||
state->cfaOffset +
|
|
||||||
r->offset);
|
|
||||||
break;
|
break;
|
||||||
case REG_REGISTER:
|
case REG_REGISTER:
|
||||||
newRegs[i].I = regs[r->reg].I;
|
newRegs[i].I = regs[r->reg].I;
|
||||||
|
@ -757,14 +750,12 @@ u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type, u32 base)
|
||||||
location = *loc->data - 0x50;
|
location = *loc->data - 0x50;
|
||||||
*type = LOCATION_register;
|
*type = LOCATION_register;
|
||||||
break;
|
break;
|
||||||
case DW_OP_fbreg:
|
case DW_OP_fbreg: {
|
||||||
{
|
|
||||||
int bytes;
|
int bytes;
|
||||||
s32 off = elfReadSignedLEB128(loc->data + 1, &bytes);
|
s32 off = elfReadSignedLEB128(loc->data + 1, &bytes);
|
||||||
location = framebase + off;
|
location = framebase + off;
|
||||||
*type = LOCATION_memory;
|
*type = LOCATION_memory;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown location %02x\n", *loc->data);
|
fprintf(stderr, "Unknown location %02x\n", *loc->data);
|
||||||
break;
|
break;
|
||||||
|
@ -850,8 +841,8 @@ ELFSectionHeader *elfGetSectionByName(const char *name)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < elfSectionHeadersCount; i++) {
|
for (int i = 0; i < elfSectionHeadersCount; i++) {
|
||||||
if (strcmp(name,
|
if (strcmp(name,
|
||||||
&elfSectionHeadersStringTable[READ32LE(&elfSectionHeaders[i]->
|
&elfSectionHeadersStringTable[READ32LE(&elfSectionHeaders[i]->name)])
|
||||||
name)]) == 0) {
|
== 0) {
|
||||||
return elfSectionHeaders[i];
|
return elfSectionHeaders[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1004,8 +995,7 @@ ELFAbbrev **elfReadAbbrevs(u8 *data, u32 offset)
|
||||||
while (name) {
|
while (name) {
|
||||||
if ((abbrev->numAttrs % 4) == 0) {
|
if ((abbrev->numAttrs % 4) == 0) {
|
||||||
abbrev->attrs = (ELFAttr*)realloc(abbrev->attrs,
|
abbrev->attrs = (ELFAttr*)realloc(abbrev->attrs,
|
||||||
(abbrev->numAttrs + 4) *
|
(abbrev->numAttrs + 4) * sizeof(ELFAttr));
|
||||||
sizeof(ELFAttr));
|
|
||||||
}
|
}
|
||||||
abbrev->attrs[abbrev->numAttrs].name = name;
|
abbrev->attrs[abbrev->numAttrs].name = name;
|
||||||
abbrev->attrs[abbrev->numAttrs++].form = form;
|
abbrev->attrs[abbrev->numAttrs++].form = form;
|
||||||
|
@ -1116,8 +1106,7 @@ void elfParseCFA(u8 *top)
|
||||||
fde->dataLen = (u32)(dataEnd - data);
|
fde->dataLen = (u32)(dataEnd - data);
|
||||||
|
|
||||||
if ((elfFdeCount % 10) == 0) {
|
if ((elfFdeCount % 10) == 0) {
|
||||||
elfFdes = (ELFfde **)realloc(elfFdes, (elfFdeCount+10) *
|
elfFdes = (ELFfde**)realloc(elfFdes, (elfFdeCount + 10) * sizeof(ELFfde*));
|
||||||
sizeof(ELFfde *));
|
|
||||||
}
|
}
|
||||||
elfFdes[elfFdeCount++] = fde;
|
elfFdes[elfFdeCount++] = fde;
|
||||||
}
|
}
|
||||||
|
@ -1219,8 +1208,7 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
|
||||||
while (!endSeq) {
|
while (!endSeq) {
|
||||||
int op = *data++;
|
int op = *data++;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case DW_LNS_extended_op:
|
case DW_LNS_extended_op: {
|
||||||
{
|
|
||||||
data++;
|
data++;
|
||||||
op = *data++;
|
op = *data++;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -1235,8 +1223,7 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
|
||||||
fprintf(stderr, "Unknown extended LINE opcode %02x\n", op);
|
fprintf(stderr, "Unknown extended LINE opcode %02x\n", op);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case DW_LNS_copy:
|
case DW_LNS_copy:
|
||||||
// fprintf(stderr, "Address %08x line %d (%d)\n", address, line, file);
|
// fprintf(stderr, "Address %08x line %d (%d)\n", address, line, file);
|
||||||
elfAddLine(l, address, file, line, &max);
|
elfAddLine(l, address, file, line, &max);
|
||||||
|
@ -1345,8 +1332,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
Type** type)
|
Type** type)
|
||||||
{
|
{
|
||||||
switch (abbrev->tag) {
|
switch (abbrev->tag) {
|
||||||
case DW_TAG_typedef:
|
case DW_TAG_typedef: {
|
||||||
{
|
|
||||||
u32 typeref = 0;
|
u32 typeref = 0;
|
||||||
char* name = NULL;
|
char* name = NULL;
|
||||||
for (int i = 0; i < abbrev->numAttrs; i++) {
|
for (int i = 0; i < abbrev->numAttrs; i++) {
|
||||||
|
@ -1373,11 +1359,9 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
if (name)
|
if (name)
|
||||||
(*type)->name = name;
|
(*type)->name = name;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case DW_TAG_union_type:
|
case DW_TAG_union_type:
|
||||||
case DW_TAG_structure_type:
|
case DW_TAG_structure_type: {
|
||||||
{
|
|
||||||
Type* t = (Type*)calloc(sizeof(Type), 1);
|
Type* t = (Type*)calloc(sizeof(Type), 1);
|
||||||
if (abbrev->tag == DW_TAG_structure_type)
|
if (abbrev->tag == DW_TAG_structure_type)
|
||||||
t->type = TYPE_struct;
|
t->type = TYPE_struct;
|
||||||
|
@ -1419,8 +1403,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||||
|
|
||||||
switch (abbr->tag) {
|
switch (abbr->tag) {
|
||||||
case DW_TAG_member:
|
case DW_TAG_member: {
|
||||||
{
|
|
||||||
if ((index % 4) == 0)
|
if ((index % 4) == 0)
|
||||||
s->members = (Member*)realloc(s->members,
|
s->members = (Member*)realloc(s->members,
|
||||||
sizeof(Member) * (index + 4));
|
sizeof(Member) * (index + 4));
|
||||||
|
@ -1462,10 +1445,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_subprogram: {
|
||||||
case DW_TAG_subprogram:
|
|
||||||
{
|
|
||||||
Function* fnc = NULL;
|
Function* fnc = NULL;
|
||||||
data = elfParseFunction(data, abbr, unit, &fnc);
|
data = elfParseFunction(data, abbr, unit, &fnc);
|
||||||
if (fnc != NULL) {
|
if (fnc != NULL) {
|
||||||
|
@ -1475,8 +1456,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
unit->functions = fnc;
|
unit->functions = fnc;
|
||||||
unit->lastFunction = fnc;
|
unit->lastFunction = fnc;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case DW_TAG_inheritance:
|
case DW_TAG_inheritance:
|
||||||
// TODO: add support
|
// TODO: add support
|
||||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||||
|
@ -1500,10 +1480,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
}
|
}
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_base_type: {
|
||||||
case DW_TAG_base_type:
|
|
||||||
{
|
|
||||||
Type* t = (Type*)calloc(sizeof(Type), 1);
|
Type* t = (Type*)calloc(sizeof(Type), 1);
|
||||||
|
|
||||||
t->type = TYPE_base;
|
t->type = TYPE_base;
|
||||||
|
@ -1534,10 +1512,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
fprintf(stderr, "Unexpected children for base type\n");
|
fprintf(stderr, "Unexpected children for base type\n");
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_pointer_type: {
|
||||||
case DW_TAG_pointer_type:
|
|
||||||
{
|
|
||||||
Type* t = (Type*)calloc(sizeof(Type), 1);
|
Type* t = (Type*)calloc(sizeof(Type), 1);
|
||||||
|
|
||||||
t->type = TYPE_pointer;
|
t->type = TYPE_pointer;
|
||||||
|
@ -1563,10 +1539,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
fprintf(stderr, "Unexpected children for pointer type\n");
|
fprintf(stderr, "Unexpected children for pointer type\n");
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_reference_type: {
|
||||||
case DW_TAG_reference_type:
|
|
||||||
{
|
|
||||||
Type* t = (Type*)calloc(sizeof(Type), 1);
|
Type* t = (Type*)calloc(sizeof(Type), 1);
|
||||||
|
|
||||||
t->type = TYPE_reference;
|
t->type = TYPE_reference;
|
||||||
|
@ -1592,10 +1566,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
fprintf(stderr, "Unexpected children for ref type\n");
|
fprintf(stderr, "Unexpected children for ref type\n");
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_volatile_type: {
|
||||||
case DW_TAG_volatile_type:
|
|
||||||
{
|
|
||||||
u32 typeref = 0;
|
u32 typeref = 0;
|
||||||
|
|
||||||
for (int i = 0; i < abbrev->numAttrs; i++) {
|
for (int i = 0; i < abbrev->numAttrs; i++) {
|
||||||
|
@ -1615,10 +1587,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
fprintf(stderr, "Unexpected children for volatile type\n");
|
fprintf(stderr, "Unexpected children for volatile type\n");
|
||||||
*type = elfParseType(unit, typeref);
|
*type = elfParseType(unit, typeref);
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_const_type: {
|
||||||
case DW_TAG_const_type:
|
|
||||||
{
|
|
||||||
u32 typeref = 0;
|
u32 typeref = 0;
|
||||||
|
|
||||||
for (int i = 0; i < abbrev->numAttrs; i++) {
|
for (int i = 0; i < abbrev->numAttrs; i++) {
|
||||||
|
@ -1638,10 +1608,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
fprintf(stderr, "Unexpected children for const type\n");
|
fprintf(stderr, "Unexpected children for const type\n");
|
||||||
*type = elfParseType(unit, typeref);
|
*type = elfParseType(unit, typeref);
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_enumeration_type: {
|
||||||
case DW_TAG_enumeration_type:
|
|
||||||
{
|
|
||||||
Type* t = (Type*)calloc(sizeof(Type), 1);
|
Type* t = (Type*)calloc(sizeof(Type), 1);
|
||||||
t->type = TYPE_enum;
|
t->type = TYPE_enum;
|
||||||
Enum* e = (Enum*)calloc(sizeof(Enum), 1);
|
Enum* e = (Enum*)calloc(sizeof(Enum), 1);
|
||||||
|
@ -1674,8 +1642,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||||
|
|
||||||
switch (abbr->tag) {
|
switch (abbr->tag) {
|
||||||
case DW_TAG_enumerator:
|
case DW_TAG_enumerator: {
|
||||||
{
|
|
||||||
count++;
|
count++;
|
||||||
e->members = (EnumMember*)realloc(e->members,
|
e->members = (EnumMember*)realloc(e->members,
|
||||||
count * sizeof(EnumMember));
|
count * sizeof(EnumMember));
|
||||||
|
@ -1695,8 +1662,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
attr->name);
|
attr->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag);
|
fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag);
|
||||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||||
|
@ -1709,10 +1675,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
e->count = count;
|
e->count = count;
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_subroutine_type: {
|
||||||
case DW_TAG_subroutine_type:
|
|
||||||
{
|
|
||||||
Type* t = (Type*)calloc(sizeof(Type), 1);
|
Type* t = (Type*)calloc(sizeof(Type), 1);
|
||||||
t->type = TYPE_function;
|
t->type = TYPE_function;
|
||||||
FunctionType* f = (FunctionType*)calloc(sizeof(FunctionType), 1);
|
FunctionType* f = (FunctionType*)calloc(sizeof(FunctionType), 1);
|
||||||
|
@ -1741,8 +1705,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||||
|
|
||||||
switch (abbr->tag) {
|
switch (abbr->tag) {
|
||||||
case DW_TAG_formal_parameter:
|
case DW_TAG_formal_parameter: {
|
||||||
{
|
|
||||||
Object* o;
|
Object* o;
|
||||||
data = elfParseObject(data, abbr, unit, &o);
|
data = elfParseObject(data, abbr, unit, &o);
|
||||||
if (f->args)
|
if (f->args)
|
||||||
|
@ -1750,8 +1713,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
else
|
else
|
||||||
f->args = o;
|
f->args = o;
|
||||||
lastVar = o;
|
lastVar = o;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case DW_TAG_unspecified_parameters:
|
case DW_TAG_unspecified_parameters:
|
||||||
// no use in the debugger yet
|
// no use in the debugger yet
|
||||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||||
|
@ -1771,10 +1733,8 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
}
|
}
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_array_type: {
|
||||||
case DW_TAG_array_type:
|
|
||||||
{
|
|
||||||
u32 typeref = 0;
|
u32 typeref = 0;
|
||||||
int i;
|
int i;
|
||||||
Array* array = (Array*)calloc(sizeof(Array), 1);
|
Array* array = (Array*)calloc(sizeof(Array), 1);
|
||||||
|
@ -1806,8 +1766,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
ELFAbbrev* abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||||
|
|
||||||
switch (abbr->tag) {
|
switch (abbr->tag) {
|
||||||
case DW_TAG_subrange_type:
|
case DW_TAG_subrange_type: {
|
||||||
{
|
|
||||||
if (maxBounds == index) {
|
if (maxBounds == index) {
|
||||||
maxBounds += 4;
|
maxBounds += 4;
|
||||||
array->bounds = (int*)realloc(array->bounds,
|
array->bounds = (int*)realloc(array->bounds,
|
||||||
|
@ -1828,8 +1787,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown array tag %02x\n", abbr->tag);
|
fprintf(stderr, "Unknown array tag %02x\n", abbr->tag);
|
||||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||||
|
@ -1846,8 +1804,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
t->array = array;
|
t->array = array;
|
||||||
*type = t;
|
*type = t;
|
||||||
return;
|
return;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown type TAG %02x\n", abbrev->tag);
|
fprintf(stderr, "Unknown type TAG %02x\n", abbrev->tag);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -2038,8 +1995,7 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
case DW_TAG_lexical_block:
|
case DW_TAG_lexical_block:
|
||||||
data = elfParseBlock(data, abbrev, unit, func, lastVar);
|
data = elfParseBlock(data, abbrev, unit, func, lastVar);
|
||||||
break;
|
break;
|
||||||
case DW_TAG_subprogram:
|
case DW_TAG_subprogram: {
|
||||||
{
|
|
||||||
Function* f = NULL;
|
Function* f = NULL;
|
||||||
data = elfParseFunction(data, abbrev, unit, &f);
|
data = elfParseFunction(data, abbrev, unit, &f);
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
|
@ -2049,10 +2005,8 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
unit->functions = f;
|
unit->functions = f;
|
||||||
unit->lastFunction = f;
|
unit->lastFunction = f;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_variable: {
|
||||||
case DW_TAG_variable:
|
|
||||||
{
|
|
||||||
Object* o;
|
Object* o;
|
||||||
data = elfParseObject(data, abbrev, unit, &o);
|
data = elfParseObject(data, abbrev, unit, &o);
|
||||||
if (o->startScope == 0)
|
if (o->startScope == 0)
|
||||||
|
@ -2064,18 +2018,15 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
else
|
else
|
||||||
func->variables = o;
|
func->variables = o;
|
||||||
*lastVar = o;
|
*lastVar = o;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case DW_TAG_inlined_subroutine:
|
case DW_TAG_inlined_subroutine:
|
||||||
// TODO:
|
// TODO:
|
||||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag);
|
fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag);
|
||||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2267,8 +2218,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
case DW_TAG_label: // not needed
|
case DW_TAG_label: // not needed
|
||||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||||
break;
|
break;
|
||||||
case DW_TAG_subprogram:
|
case DW_TAG_subprogram: {
|
||||||
{
|
|
||||||
Function* fnc = NULL;
|
Function* fnc = NULL;
|
||||||
data = elfParseFunction(data, abbrev, unit, &fnc);
|
data = elfParseFunction(data, abbrev, unit, &fnc);
|
||||||
if (fnc != NULL) {
|
if (fnc != NULL) {
|
||||||
|
@ -2278,15 +2228,11 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
unit->lastFunction->next = fnc;
|
unit->lastFunction->next = fnc;
|
||||||
unit->lastFunction = fnc;
|
unit->lastFunction = fnc;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_lexical_block: {
|
||||||
case DW_TAG_lexical_block:
|
|
||||||
{
|
|
||||||
data = elfParseBlock(data, abbrev, unit, func, &lastVar);
|
data = elfParseBlock(data, abbrev, unit, func, &lastVar);
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_formal_parameter: {
|
||||||
case DW_TAG_formal_parameter:
|
|
||||||
{
|
|
||||||
Object* o;
|
Object* o;
|
||||||
data = elfParseObject(data, abbrev, unit, &o);
|
data = elfParseObject(data, abbrev, unit, &o);
|
||||||
if (func->parameters)
|
if (func->parameters)
|
||||||
|
@ -2294,10 +2240,8 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
else
|
else
|
||||||
func->parameters = o;
|
func->parameters = o;
|
||||||
lastParam = o;
|
lastParam = o;
|
||||||
}
|
} break;
|
||||||
break;
|
case DW_TAG_variable: {
|
||||||
case DW_TAG_variable:
|
|
||||||
{
|
|
||||||
Object* o;
|
Object* o;
|
||||||
data = elfParseObject(data, abbrev, unit, &o);
|
data = elfParseObject(data, abbrev, unit, &o);
|
||||||
if (func->variables)
|
if (func->variables)
|
||||||
|
@ -2305,11 +2249,9 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
else
|
else
|
||||||
func->variables = o;
|
func->variables = o;
|
||||||
lastVar = o;
|
lastVar = o;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case DW_TAG_unspecified_parameters:
|
case DW_TAG_unspecified_parameters:
|
||||||
case DW_TAG_inlined_subroutine:
|
case DW_TAG_inlined_subroutine: {
|
||||||
{
|
|
||||||
// todo
|
// todo
|
||||||
for (int i = 0; i < abbrev->numAttrs; i++) {
|
for (int i = 0; i < abbrev->numAttrs; i++) {
|
||||||
data = elfReadAttribute(data, &abbrev->attrs[i]);
|
data = elfReadAttribute(data, &abbrev->attrs[i]);
|
||||||
|
@ -2319,14 +2261,11 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||||
|
|
||||||
if (abbrev->hasChildren)
|
if (abbrev->hasChildren)
|
||||||
nesting++;
|
nesting++;
|
||||||
}
|
} break;
|
||||||
break;
|
default: {
|
||||||
default:
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag);
|
fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag);
|
||||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2386,8 +2325,7 @@ u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
|
||||||
while (abbrevNum) {
|
while (abbrevNum) {
|
||||||
ELFAbbrev* abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
|
ELFAbbrev* abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
|
||||||
switch (abbrev->tag) {
|
switch (abbrev->tag) {
|
||||||
case DW_TAG_subprogram:
|
case DW_TAG_subprogram: {
|
||||||
{
|
|
||||||
Function* func = NULL;
|
Function* func = NULL;
|
||||||
data = elfParseFunction(data, abbrev, unit, &func);
|
data = elfParseFunction(data, abbrev, unit, &func);
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
|
@ -2397,13 +2335,11 @@ u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
|
||||||
unit->functions = func;
|
unit->functions = func;
|
||||||
unit->lastFunction = func;
|
unit->lastFunction = func;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
CASE_TYPE_TAG:
|
CASE_TYPE_TAG:
|
||||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||||
break;
|
break;
|
||||||
case DW_TAG_variable:
|
case DW_TAG_variable: {
|
||||||
{
|
|
||||||
Object* var = NULL;
|
Object* var = NULL;
|
||||||
data = elfParseObject(data, abbrev, unit, &var);
|
data = elfParseObject(data, abbrev, unit, &var);
|
||||||
if (lastObj)
|
if (lastObj)
|
||||||
|
@ -2411,8 +2347,7 @@ u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
|
||||||
else
|
else
|
||||||
unit->variables = var;
|
unit->variables = var;
|
||||||
lastObj = var;
|
lastObj = var;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
data = elfParseUnknownData(data, abbrev, unit->abbrevs);
|
data = elfParseUnknownData(data, abbrev, unit->abbrevs);
|
||||||
break;
|
break;
|
||||||
|
@ -2424,7 +2359,6 @@ u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CompileUnit* elfParseCompUnit(u8* data, u8* abbrevData)
|
CompileUnit* elfParseCompUnit(u8* data, u8* abbrevData)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
|
@ -2631,16 +2565,14 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
||||||
// i, ph->type, ph->offset, ph->vaddr, ph->paddr,
|
// i, ph->type, ph->offset, ph->vaddr, ph->paddr,
|
||||||
// ph->filesz, ph->memsz, ph->flags, ph->align);
|
// ph->filesz, ph->memsz, ph->flags, ph->align);
|
||||||
if (cpuIsMultiBoot) {
|
if (cpuIsMultiBoot) {
|
||||||
if(READ32LE(&ph->paddr) >= 0x2000000 &&
|
if (READ32LE(&ph->paddr) >= 0x2000000 && READ32LE(&ph->paddr) <= 0x203ffff) {
|
||||||
READ32LE(&ph->paddr) <= 0x203ffff) {
|
|
||||||
memcpy(&workRAM[READ32LE(&ph->paddr) & 0x3ffff],
|
memcpy(&workRAM[READ32LE(&ph->paddr) & 0x3ffff],
|
||||||
data + READ32LE(&ph->offset),
|
data + READ32LE(&ph->offset),
|
||||||
READ32LE(&ph->filesz));
|
READ32LE(&ph->filesz));
|
||||||
size += READ32LE(&ph->filesz);
|
size += READ32LE(&ph->filesz);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(READ32LE(&ph->paddr) >= 0x8000000 &&
|
if (READ32LE(&ph->paddr) >= 0x8000000 && READ32LE(&ph->paddr) <= 0x9ffffff) {
|
||||||
READ32LE(&ph->paddr) <= 0x9ffffff) {
|
|
||||||
memcpy(&rom[READ32LE(&ph->paddr) & 0x1ffffff],
|
memcpy(&rom[READ32LE(&ph->paddr) & 0x1ffffff],
|
||||||
data + READ32LE(&ph->offset),
|
data + READ32LE(&ph->offset),
|
||||||
READ32LE(&ph->filesz));
|
READ32LE(&ph->filesz));
|
||||||
|
@ -2681,16 +2613,13 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
||||||
// sh[i]->link, sh[i]->info);
|
// sh[i]->link, sh[i]->info);
|
||||||
if (READ32LE(&sh[i]->flags) & 2) { // load section
|
if (READ32LE(&sh[i]->flags) & 2) { // load section
|
||||||
if (cpuIsMultiBoot) {
|
if (cpuIsMultiBoot) {
|
||||||
if(READ32LE(&sh[i]->addr) >= 0x2000000 &&
|
if (READ32LE(&sh[i]->addr) >= 0x2000000 && READ32LE(&sh[i]->addr) <= 0x203ffff) {
|
||||||
READ32LE(&sh[i]->addr) <= 0x203ffff) {
|
memcpy(&workRAM[READ32LE(&sh[i]->addr) & 0x3ffff], data + READ32LE(&sh[i]->offset),
|
||||||
memcpy(&workRAM[READ32LE(&sh[i]->addr) & 0x3ffff], data +
|
|
||||||
READ32LE(&sh[i]->offset),
|
|
||||||
READ32LE(&sh[i]->size));
|
READ32LE(&sh[i]->size));
|
||||||
size += READ32LE(&sh[i]->size);
|
size += READ32LE(&sh[i]->size);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(READ32LE(&sh[i]->addr) >= 0x8000000 &&
|
if (READ32LE(&sh[i]->addr) >= 0x8000000 && READ32LE(&sh[i]->addr) <= 0x9ffffff) {
|
||||||
READ32LE(&sh[i]->addr) <= 0x9ffffff) {
|
|
||||||
memcpy(&rom[READ32LE(&sh[i]->addr) & 0x1ffffff],
|
memcpy(&rom[READ32LE(&sh[i]->addr) & 0x1ffffff],
|
||||||
data + READ32LE(&sh[i]->offset),
|
data + READ32LE(&sh[i]->offset),
|
||||||
READ32LE(&sh[i]->size));
|
READ32LE(&sh[i]->size));
|
||||||
|
@ -2785,8 +2714,7 @@ bool elfRead(const char *name, int& siz, FILE *f)
|
||||||
int res = fread(elfFileData, 1, size, f);
|
int res = fread(elfFileData, 1, size, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0) {
|
||||||
{
|
|
||||||
free(elfFileData);
|
free(elfFileData);
|
||||||
elfFileData = NULL;
|
elfFileData = NULL;
|
||||||
return false;
|
return false;
|
||||||
|
@ -2794,9 +2722,7 @@ bool elfRead(const char *name, int& siz, FILE *f)
|
||||||
|
|
||||||
ELFHeader* header = (ELFHeader*)elfFileData;
|
ELFHeader* header = (ELFHeader*)elfFileData;
|
||||||
|
|
||||||
if(READ32LE(&header->magic) != 0x464C457F ||
|
if (READ32LE(&header->magic) != 0x464C457F || READ16LE(&header->e_machine) != 40 || header->clazz != 1) {
|
||||||
READ16LE(&header->e_machine) != 40 ||
|
|
||||||
header->clazz != 1) {
|
|
||||||
systemMessage(0, N_("Not a valid ELF file %s"), name);
|
systemMessage(0, N_("Not a valid ELF file %s"), name);
|
||||||
free(elfFileData);
|
free(elfFileData);
|
||||||
elfFileData = NULL;
|
elfFileData = NULL;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef ELF_H
|
#ifndef ELF_H
|
||||||
#define ELF_H
|
#define ELF_H
|
||||||
|
|
||||||
enum LocationType { LOCATION_register, LOCATION_memory, LOCATION_value };
|
enum LocationType { LOCATION_register,
|
||||||
|
LOCATION_memory,
|
||||||
|
LOCATION_value };
|
||||||
|
|
||||||
#define DW_ATE_boolean 0x02
|
#define DW_ATE_boolean 0x02
|
||||||
#define DW_ATE_signed 0x05
|
#define DW_ATE_signed 0x05
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ char rom_info[19];
|
||||||
|
|
||||||
char Signature[0x29] = "E-Reader Dotcode -Created- by CaitSith2";
|
char Signature[0x29] = "E-Reader Dotcode -Created- by CaitSith2";
|
||||||
|
|
||||||
|
|
||||||
unsigned char ShortDotCodeHeader[0x30] = {
|
unsigned char ShortDotCodeHeader[0x30] = {
|
||||||
0x00, 0x30, 0x01, 0x01,
|
0x00, 0x30, 0x01, 0x01,
|
||||||
0x00, 0x01, 0x05, 0x10,
|
0x00, 0x01, 0x05, 0x10,
|
||||||
|
@ -56,7 +55,6 @@ unsigned char LongDotCodeHeader[0x30] = {
|
||||||
0x4E, 0x54, 0x45, 0x4E, 0x44, 0x4F, 0x00, 0x22,
|
0x4E, 0x54, 0x45, 0x4E, 0x44, 0x4F, 0x00, 0x22,
|
||||||
0x00, 0x09, //Constant data
|
0x00, 0x09, //Constant data
|
||||||
|
|
||||||
|
|
||||||
0x00, 0x00, //Header, last 8 bytes
|
0x00, 0x00, //Header, last 8 bytes
|
||||||
0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00,
|
0x00, 0x00,
|
||||||
|
@ -138,39 +136,29 @@ int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM
|
||||||
CPUWriteMemory((MEM2 - 8) + i, 0);
|
CPUWriteMemory((MEM2 - 8) + i, 0);
|
||||||
for (i = 0; i < 0x1860; i += 4)
|
for (i = 0; i < 0x1860; i += 4)
|
||||||
CPUWriteMemory(temp1 + i, 0);
|
CPUWriteMemory(temp1 + i, 0);
|
||||||
if(DCdata != NULL)
|
if (DCdata != NULL) {
|
||||||
{
|
if (size == 0xB60) {
|
||||||
if(size==0xB60)
|
for (i = 0; i < 28; i++) {
|
||||||
{
|
for (j = 0, scantotal = 0; j < 0x68; j += 4) {
|
||||||
for(i=0;i<28;i++)
|
|
||||||
{
|
|
||||||
for(j=0,scantotal=0;j<0x68;j+=4)
|
|
||||||
{
|
|
||||||
scantotal += DCdata[((i * 0x68) + j) >> 2];
|
scantotal += DCdata[((i * 0x68) + j) >> 2];
|
||||||
}
|
}
|
||||||
if (scantotal)
|
if (scantotal)
|
||||||
scanmap[i] = longdotcodescan[i];
|
scanmap[i] = longdotcodescan[i];
|
||||||
}
|
}
|
||||||
for(i=0;i<size;i+=4)
|
for (i = 0; i < size; i += 4) {
|
||||||
{
|
|
||||||
CPUWriteMemory(temp1 + i + 0x9C0, DCdata[i >> 2]);
|
CPUWriteMemory(temp1 + i + 0x9C0, DCdata[i >> 2]);
|
||||||
}
|
}
|
||||||
}
|
} else if (size == 0x750) {
|
||||||
else if (size==0x750)
|
for (i = 0; i < 18; i++) {
|
||||||
{
|
|
||||||
for(i=0;i<18;i++)
|
|
||||||
{
|
|
||||||
if ((DCdata[0] == 0x02011394) && (DCdata[1] == 0x0203E110) && (i == 0))
|
if ((DCdata[0] == 0x02011394) && (DCdata[1] == 0x0203E110) && (i == 0))
|
||||||
continue;
|
continue;
|
||||||
for(j=0,scantotal=0;j<0x68;j+=4)
|
for (j = 0, scantotal = 0; j < 0x68; j += 4) {
|
||||||
{
|
|
||||||
scantotal += DCdata[((i * 0x68) + j) >> 2];
|
scantotal += DCdata[((i * 0x68) + j) >> 2];
|
||||||
}
|
}
|
||||||
if (scantotal)
|
if (scantotal)
|
||||||
scanmap[i] = longdotcodescan[i];
|
scanmap[i] = longdotcodescan[i];
|
||||||
}
|
}
|
||||||
for(i=0;i<size;i+=4)
|
for (i = 0; i < size; i += 4) {
|
||||||
{
|
|
||||||
CPUWriteMemory(temp1 + i, DCdata[i >> 2]);
|
CPUWriteMemory(temp1 + i, DCdata[i >> 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,16 +166,11 @@ int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM
|
||||||
CPUWriteMemory(MEM2 - 8, 0x1860);
|
CPUWriteMemory(MEM2 - 8, 0x1860);
|
||||||
CPUWriteMemory(MEM2 - 4, temp1);
|
CPUWriteMemory(MEM2 - 4, temp1);
|
||||||
|
|
||||||
|
if (size == 0xB60) {
|
||||||
if(size==0xB60)
|
if (loadraw) {
|
||||||
{
|
|
||||||
if(loadraw)
|
|
||||||
{
|
|
||||||
for (i = 0; i < 28; i++)
|
for (i = 0; i < 28; i++)
|
||||||
CPUWriteByte(MEM2 + 0x18 + i, scanmap[i]);
|
CPUWriteByte(MEM2 + 0x18 + i, scanmap[i]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CPUWriteMemory(MEM2 + 0x18, 0xF1F1F1F1);
|
CPUWriteMemory(MEM2 + 0x18, 0xF1F1F1F1);
|
||||||
CPUWriteMemory(MEM2 + 0x18 + 4, 0xF1F1F1F1);
|
CPUWriteMemory(MEM2 + 0x18 + 4, 0xF1F1F1F1);
|
||||||
CPUWriteMemory(MEM2 + 0x18 + 8, 0xF1F1F1F1);
|
CPUWriteMemory(MEM2 + 0x18 + 8, 0xF1F1F1F1);
|
||||||
|
@ -198,16 +181,11 @@ int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM
|
||||||
}
|
}
|
||||||
CPUWriteMemory(MEM2 + 0x40, 0x19);
|
CPUWriteMemory(MEM2 + 0x40, 0x19);
|
||||||
CPUWriteMemory(MEM2 + 0x44, 0x34);
|
CPUWriteMemory(MEM2 + 0x44, 0x34);
|
||||||
}
|
} else if (size == 0x750) {
|
||||||
else if (size==0x750)
|
if (loadraw) {
|
||||||
{
|
|
||||||
if(loadraw)
|
|
||||||
{
|
|
||||||
for (i = 0; i < 18; i++)
|
for (i = 0; i < 18; i++)
|
||||||
CPUWriteByte(MEM2 + i, scanmap[i]);
|
CPUWriteByte(MEM2 + i, scanmap[i]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CPUWriteMemory(MEM2, 0xF1F1F1F1);
|
CPUWriteMemory(MEM2, 0xF1F1F1F1);
|
||||||
CPUWriteMemory(MEM2 + 4, 0xF1F1F1F1);
|
CPUWriteMemory(MEM2 + 4, 0xF1F1F1F1);
|
||||||
CPUWriteMemory(MEM2 + 8, 0xF1F1F1F1);
|
CPUWriteMemory(MEM2 + 8, 0xF1F1F1F1);
|
||||||
|
@ -225,8 +203,7 @@ int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM
|
||||||
|
|
||||||
void EReaderWriteMemory(u32 address, u32 value)
|
void EReaderWriteMemory(u32 address, u32 value)
|
||||||
{
|
{
|
||||||
switch(address >> 24)
|
switch (address >> 24) {
|
||||||
{
|
|
||||||
case 2:
|
case 2:
|
||||||
WRITE32LE(((u32*)&workRAM[address & 0x3FFFF]), value);
|
WRITE32LE(((u32*)&workRAM[address & 0x3FFFF]), value);
|
||||||
break;
|
break;
|
||||||
|
@ -240,7 +217,6 @@ void EReaderWriteMemory(u32 address, u32 value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BIOS_EReader_ScanCard(int swi_num)
|
void BIOS_EReader_ScanCard(int swi_num)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -253,58 +229,47 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
|
|
||||||
//Open dotcode bin/raw
|
//Open dotcode bin/raw
|
||||||
|
|
||||||
if(swi_num == 0xE0)
|
if (swi_num == 0xE0) {
|
||||||
{
|
|
||||||
dotcodepointer = 0;
|
dotcodepointer = 0;
|
||||||
dotcodeinterleave = 0;
|
dotcodeinterleave = 0;
|
||||||
decodestate = 0;
|
decodestate = 0;
|
||||||
|
|
||||||
const char* loadDotCodeFile = GetLoadDotCodeFile();
|
const char* loadDotCodeFile = GetLoadDotCodeFile();
|
||||||
|
|
||||||
if (loadDotCodeFile == 0)
|
if (loadDotCodeFile == 0) {
|
||||||
{
|
|
||||||
reg[0].I = 0x301;
|
reg[0].I = 0x301;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
f = fopen(loadDotCodeFile, "rb");
|
f = fopen(loadDotCodeFile, "rb");
|
||||||
//f=fopen(filebuffer,"rb");
|
//f=fopen(filebuffer,"rb");
|
||||||
//f=fopen("dotcode4.raw","rb");
|
//f=fopen("dotcode4.raw","rb");
|
||||||
if(f==NULL)
|
if (f == NULL) {
|
||||||
{
|
|
||||||
reg[0].I = 0x303;
|
reg[0].I = 0x303;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
i = ftell(f);
|
i = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
if((i==0xB60) || (i==0x750))
|
if ((i == 0xB60) || (i == 0x750)) {
|
||||||
{
|
|
||||||
dotcodetype = 0;
|
dotcodetype = 0;
|
||||||
}
|
} else if ((i == 0x81C) || (i == 0x51C)) {
|
||||||
else if ((i==0x81C) || (i==0x51C))
|
|
||||||
{
|
|
||||||
dotcodetype = 1;
|
dotcodetype = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
reg[0].I = 0x303;
|
reg[0].I = 0x303;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DotCodeData = (unsigned char*)malloc(i);
|
DotCodeData = (unsigned char*)malloc(i);
|
||||||
if(DotCodeData == NULL)
|
if (DotCodeData == NULL) {
|
||||||
{
|
|
||||||
reg[0].I = 0x303;
|
reg[0].I = 0x303;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fread(DotCodeData, 1, i, f);
|
fread(DotCodeData, 1, i, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if(dotcodetype == 0)
|
if (dotcodetype == 0) {
|
||||||
{
|
|
||||||
|
|
||||||
switch(CheckEReaderRegion())
|
switch (CheckEReaderRegion()) {
|
||||||
{
|
|
||||||
case 1: //US
|
case 1: //US
|
||||||
LoadDotCodeData(i, (u32*)DotCodeData, 0x2032D14, 0x2028B28, 1);
|
LoadDotCodeData(i, (u32*)DotCodeData, 0x2032D14, 0x2028B28, 1);
|
||||||
EReaderWriteMemory(0x80091BA, 0x46C0DFE2);
|
EReaderWriteMemory(0x80091BA, 0x46C0DFE2);
|
||||||
|
@ -320,18 +285,14 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
}
|
}
|
||||||
reg[0].I = 0;
|
reg[0].I = 0;
|
||||||
free(DotCodeData);
|
free(DotCodeData);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//dotcodesize = i;
|
//dotcodesize = i;
|
||||||
if (i == 0x81C)
|
if (i == 0x81C)
|
||||||
dotcodesize = 0xB60;
|
dotcodesize = 0xB60;
|
||||||
else
|
else
|
||||||
dotcodesize = 0x750;
|
dotcodesize = 0x750;
|
||||||
|
|
||||||
|
switch (CheckEReaderRegion()) {
|
||||||
switch(CheckEReaderRegion())
|
|
||||||
{
|
|
||||||
case 1: //US
|
case 1: //US
|
||||||
LoadDotCodeData(dotcodesize, (u32*)NULL, 0x2032D14, 0x2028B28, 0);
|
LoadDotCodeData(dotcodesize, (u32*)NULL, 0x2032D14, 0x2028B28, 0);
|
||||||
EReaderWriteMemory(0x80091BA, 0x46C0DFE1);
|
EReaderWriteMemory(0x80091BA, 0x46C0DFE1);
|
||||||
|
@ -348,12 +309,9 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
reg[0].I = 0;
|
reg[0].I = 0;
|
||||||
dotcodesize = i;
|
dotcodesize = i;
|
||||||
}
|
}
|
||||||
}
|
} else if (swi_num == 0xE1) {
|
||||||
else if (swi_num == 0xE1)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch(CheckEReaderRegion())
|
switch (CheckEReaderRegion()) {
|
||||||
{
|
|
||||||
case 1: //US
|
case 1: //US
|
||||||
EReaderWriteMemory(0x80091BA, 0xF8A5F03B);
|
EReaderWriteMemory(0x80091BA, 0xF8A5F03B);
|
||||||
EReaderWriteMemory(0x3002F7C, 0xEFE40000); //Beginning of Reed-Solomon decoder
|
EReaderWriteMemory(0x3002F7C, 0xEFE40000); //Beginning of Reed-Solomon decoder
|
||||||
|
@ -386,8 +344,7 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
|
|
||||||
for (i = 0, j = 0; i < 12; i++)
|
for (i = 0, j = 0; i < 12; i++)
|
||||||
j ^= DotCodeData[i];
|
j ^= DotCodeData[i];
|
||||||
if(dotcodesize == 0x81C)
|
if (dotcodesize == 0x81C) {
|
||||||
{
|
|
||||||
LongDotCodeHeader[0x2E] = j;
|
LongDotCodeHeader[0x2E] = j;
|
||||||
LongDotCodeHeader[0x0D] = DotCodeData[0];
|
LongDotCodeHeader[0x0D] = DotCodeData[0];
|
||||||
LongDotCodeHeader[0x0C] = DotCodeData[1];
|
LongDotCodeHeader[0x0C] = DotCodeData[1];
|
||||||
|
@ -403,12 +360,10 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
LongDotCodeHeader[0x2C] = DotCodeData[10];
|
LongDotCodeHeader[0x2C] = DotCodeData[10];
|
||||||
LongDotCodeHeader[0x2D] = DotCodeData[11];
|
LongDotCodeHeader[0x2D] = DotCodeData[11];
|
||||||
|
|
||||||
|
|
||||||
LongDotCodeHeader[0x12] = 0x10; //calculate Global Checksum 1
|
LongDotCodeHeader[0x12] = 0x10; //calculate Global Checksum 1
|
||||||
LongDotCodeHeader[0x02] = 1; //Do not calculate Global Checksum 2
|
LongDotCodeHeader[0x02] = 1; //Do not calculate Global Checksum 2
|
||||||
|
|
||||||
for(i=0x0C,j=0;i<0x81C;i++)
|
for (i = 0x0C, j = 0; i < 0x81C; i++) {
|
||||||
{
|
|
||||||
if (i & 1)
|
if (i & 1)
|
||||||
j += DotCodeData[i];
|
j += DotCodeData[i];
|
||||||
else
|
else
|
||||||
|
@ -422,10 +377,8 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
for (i = 0, j = 0; i < 0x2F; i++)
|
for (i = 0, j = 0; i < 0x2F; i++)
|
||||||
j += LongDotCodeHeader[i];
|
j += LongDotCodeHeader[i];
|
||||||
j &= 0xFF;
|
j &= 0xFF;
|
||||||
for(i=1,global2=0;i<0x2C;i++)
|
for (i = 1, global2 = 0; i < 0x2C; i++) {
|
||||||
{
|
for (k = 0, global1 = 0; k < 0x30; k++) {
|
||||||
for(k=0,global1=0;k<0x30;k++)
|
|
||||||
{
|
|
||||||
global1 ^= DotCodeData[((i - 1) * 0x30) + k + 0x0C];
|
global1 ^= DotCodeData[((i - 1) * 0x30) + k + 0x0C];
|
||||||
}
|
}
|
||||||
global2 += global1;
|
global2 += global1;
|
||||||
|
@ -435,10 +388,7 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
global2 ^= 0xFF;
|
global2 ^= 0xFF;
|
||||||
LongDotCodeHeader[0x2F] = global2;
|
LongDotCodeHeader[0x2F] = global2;
|
||||||
|
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ShortDotCodeHeader[0x2E] = j;
|
ShortDotCodeHeader[0x2E] = j;
|
||||||
ShortDotCodeHeader[0x0D] = DotCodeData[0];
|
ShortDotCodeHeader[0x0D] = DotCodeData[0];
|
||||||
ShortDotCodeHeader[0x0C] = DotCodeData[1];
|
ShortDotCodeHeader[0x0C] = DotCodeData[1];
|
||||||
|
@ -457,8 +407,7 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
ShortDotCodeHeader[0x12] = 0x10; //calculate Global Checksum 1
|
ShortDotCodeHeader[0x12] = 0x10; //calculate Global Checksum 1
|
||||||
ShortDotCodeHeader[0x02] = 1; //Do not calculate Global Checksum 2
|
ShortDotCodeHeader[0x02] = 1; //Do not calculate Global Checksum 2
|
||||||
|
|
||||||
for(i=0x0C,j=0;i<0x51C;i++)
|
for (i = 0x0C, j = 0; i < 0x51C; i++) {
|
||||||
{
|
|
||||||
if (i & 1)
|
if (i & 1)
|
||||||
j += DotCodeData[i];
|
j += DotCodeData[i];
|
||||||
else
|
else
|
||||||
|
@ -472,10 +421,8 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
for (i = 0, j = 0; i < 0x2F; i++)
|
for (i = 0, j = 0; i < 0x2F; i++)
|
||||||
j += ShortDotCodeHeader[i];
|
j += ShortDotCodeHeader[i];
|
||||||
j &= 0xFF;
|
j &= 0xFF;
|
||||||
for(i=1,global2=0;i<0x1C;i++)
|
for (i = 1, global2 = 0; i < 0x1C; i++) {
|
||||||
{
|
for (k = 0, global1 = 0; k < 0x30; k++) {
|
||||||
for(k=0,global1=0;k<0x30;k++)
|
|
||||||
{
|
|
||||||
global1 ^= DotCodeData[((i - 1) * 0x30) + k + 0x0C];
|
global1 ^= DotCodeData[((i - 1) * 0x30) + k + 0x0C];
|
||||||
}
|
}
|
||||||
global2 += global1;
|
global2 += global1;
|
||||||
|
@ -486,11 +433,9 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
ShortDotCodeHeader[0x2F] = global2;
|
ShortDotCodeHeader[0x2F] = global2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (swi_num == 0xE2) //Header
|
||||||
else if (swi_num == 0xE2) //Header
|
|
||||||
{
|
|
||||||
switch(CheckEReaderRegion())
|
|
||||||
{
|
{
|
||||||
|
switch (CheckEReaderRegion()) {
|
||||||
case 1: //US
|
case 1: //US
|
||||||
EReaderWriteMemory(0x80091BA, 0xF8A5F03B);
|
EReaderWriteMemory(0x80091BA, 0xF8A5F03B);
|
||||||
EReaderWriteMemory(0x300338C, 0xEFE30000);
|
EReaderWriteMemory(0x300338C, 0xEFE30000);
|
||||||
|
@ -513,15 +458,11 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
ARM_PREFETCH
|
ARM_PREFETCH
|
||||||
else
|
else
|
||||||
THUMB_PREFETCH
|
THUMB_PREFETCH
|
||||||
}
|
} else if ((swi_num == 0xE3) || (swi_num == 0xE5)) //Dotcode data
|
||||||
else if ((swi_num == 0xE3) || (swi_num == 0xE5)) //Dotcode data
|
|
||||||
{
|
|
||||||
if((reg[0].I >= 0) && (reg[0].I <= 0x10))
|
|
||||||
{
|
|
||||||
if(decodestate == 0)
|
|
||||||
{
|
|
||||||
for(i=0x17;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
|
if ((reg[0].I >= 0) && (reg[0].I <= 0x10)) {
|
||||||
|
if (decodestate == 0) {
|
||||||
|
for (i = 0x17; i >= 0; i--) {
|
||||||
if ((0x17 - i) < 8)
|
if ((0x17 - i) < 8)
|
||||||
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i));
|
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i));
|
||||||
else
|
else
|
||||||
|
@ -536,11 +477,8 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
dotcodedata[(i * 0x68) + j] = dotcodeheader[(i * 2) + j];
|
dotcodedata[(i * 0x68) + j] = dotcodeheader[(i * 2) + j];
|
||||||
dotcodeinterleave = dotcodeheader[7];
|
dotcodeinterleave = dotcodeheader[7];
|
||||||
decodestate = 1;
|
decodestate = 1;
|
||||||
}
|
} else {
|
||||||
else
|
for (i = 0x3F; i >= 0; i--) {
|
||||||
{
|
|
||||||
for(i=0x3F;i>=0;i--)
|
|
||||||
{
|
|
||||||
if ((0x3F - i) < 0x30)
|
if ((0x3F - i) < 0x30)
|
||||||
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i));
|
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i));
|
||||||
else
|
else
|
||||||
|
@ -549,10 +487,8 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
}
|
}
|
||||||
dotcodepointer++;
|
dotcodepointer++;
|
||||||
|
|
||||||
if((dotcodepointer == dotcodeinterleave))
|
if ((dotcodepointer == dotcodeinterleave)) {
|
||||||
{
|
switch (dotcodeinterleave) {
|
||||||
switch(dotcodeinterleave)
|
|
||||||
{
|
|
||||||
case 0x1C:
|
case 0x1C:
|
||||||
j = 0x724;
|
j = 0x724;
|
||||||
k = 0x750 - j;
|
k = 0x750 - j;
|
||||||
|
@ -563,34 +499,26 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dotcodepointer = 0;
|
dotcodepointer = 0;
|
||||||
for(i=2;i<j;i++)
|
for (i = 2; i < j; i++) {
|
||||||
{
|
|
||||||
if ((i % 0x68) == 0)
|
if ((i % 0x68) == 0)
|
||||||
i += 2;
|
i += 2;
|
||||||
dotcodedata[i] = dotcodetemp[dotcodepointer++];
|
dotcodedata[i] = dotcodetemp[dotcodepointer++];
|
||||||
}
|
}
|
||||||
if(swi_num == 0xE3)
|
if (swi_num == 0xE3) {
|
||||||
{
|
|
||||||
const char* loadDotCodeFile = GetLoadDotCodeFile();
|
const char* loadDotCodeFile = GetLoadDotCodeFile();
|
||||||
f = fopen(loadDotCodeFile, "rb+");
|
f = fopen(loadDotCodeFile, "rb+");
|
||||||
if(f!=NULL)
|
if (f != NULL) {
|
||||||
{
|
|
||||||
fwrite(dotcodedata, 1, j, f);
|
fwrite(dotcodedata, 1, j, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
const char* saveDotCodeFile = GetSaveDotCodeFile();
|
const char* saveDotCodeFile = GetSaveDotCodeFile();
|
||||||
if (saveDotCodeFile)
|
if (saveDotCodeFile) {
|
||||||
{
|
|
||||||
f = fopen(saveDotCodeFile, "wb");
|
f = fopen(saveDotCodeFile, "wb");
|
||||||
if(f!=NULL)
|
if (f != NULL) {
|
||||||
{
|
|
||||||
fwrite(dotcodedata, 1, j, f);
|
fwrite(dotcodedata, 1, j, f);
|
||||||
fwrite(Signature, 1, 0x28, f);
|
fwrite(Signature, 1, 0x28, f);
|
||||||
if(j==0x724)
|
if (j == 0x724) {
|
||||||
{
|
|
||||||
fputc(0x65, f);
|
fputc(0x65, f);
|
||||||
fputc(0x02, f);
|
fputc(0x02, f);
|
||||||
fputc(0x71, f);
|
fputc(0x71, f);
|
||||||
|
@ -618,14 +546,10 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
reg[15].I += 2;
|
reg[15].I += 2;
|
||||||
THUMB_PREFETCH
|
THUMB_PREFETCH
|
||||||
}
|
}
|
||||||
}
|
} else if (swi_num == 0xE4) {
|
||||||
else if (swi_num == 0xE4)
|
|
||||||
{
|
|
||||||
reg[12].I = reg[13].I;
|
reg[12].I = reg[13].I;
|
||||||
if(decodestate == 0)
|
if (decodestate == 0) {
|
||||||
{
|
for (i = 0; i < 0x18; i++) {
|
||||||
for(i=0;i<0x18;i++)
|
|
||||||
{
|
|
||||||
if (dotcodesize == 0x81C)
|
if (dotcodesize == 0x81C)
|
||||||
j = longheader[i];
|
j = longheader[i];
|
||||||
else
|
else
|
||||||
|
@ -638,13 +562,9 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
|
|
||||||
CPUWriteByte(GFpow + 0x200 + (0x17 - i), j);
|
CPUWriteByte(GFpow + 0x200 + (0x17 - i), j);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (dotcodepointer == 0) {
|
||||||
{
|
for (i = 0; i < 0x30; i++) {
|
||||||
if(dotcodepointer == 0)
|
|
||||||
{
|
|
||||||
for(i=0;i<0x30;i++)
|
|
||||||
{
|
|
||||||
if (dotcodesize == 0x81C)
|
if (dotcodesize == 0x81C)
|
||||||
j = LongDotCodeHeader[i];
|
j = LongDotCodeHeader[i];
|
||||||
else
|
else
|
||||||
|
@ -654,11 +574,8 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
CPUWriteByte(GFpow + 0x200 + (0x3F - i), j);
|
CPUWriteByte(GFpow + 0x200 + (0x3F - i), j);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
for (i = 0; i < 0x30; i++) {
|
||||||
{
|
|
||||||
for(i=0;i<0x30;i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
j = DotCodeData[((dotcodepointer - 1) * 0x30) + 0x0C + i];
|
j = DotCodeData[((dotcodepointer - 1) * 0x30) + 0x0C + i];
|
||||||
j = CPUReadByte(GFpow + 0x100 + j);
|
j = CPUReadByte(GFpow + 0x100 + j);
|
||||||
|
@ -669,6 +586,4 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
CPUWriteByte(GFpow + 0x258 + i, 1); //16 Erasures on the parity bytes, to have them calculated.
|
CPUWriteByte(GFpow + 0x258 + i, 1); //16 Erasures on the parity bytes, to have them calculated.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,7 @@ void gbafilter_pal(u16 * buf, int count)
|
||||||
unsigned pix;
|
unsigned pix;
|
||||||
u8 red, green, blue;
|
u8 red, green, blue;
|
||||||
|
|
||||||
while (count--)
|
while (count--) {
|
||||||
{
|
|
||||||
pix = *buf;
|
pix = *buf;
|
||||||
|
|
||||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||||
|
@ -52,35 +51,47 @@ void gbafilter_pal(u16 * buf, int count)
|
||||||
temp[7] = s * influence[7];
|
temp[7] = s * influence[7];
|
||||||
temp[8] = s * influence[8];
|
temp[8] = s * influence[8];
|
||||||
|
|
||||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
if (temp[0] < temp[3])
|
||||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
swap(temp[0], temp[3]);
|
||||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
if (temp[0] < temp[6])
|
||||||
|
swap(temp[0], temp[6]);
|
||||||
|
if (temp[3] < temp[6])
|
||||||
|
swap(temp[3], temp[6]);
|
||||||
temp[3] <<= 1;
|
temp[3] <<= 1;
|
||||||
temp[0] <<= 2;
|
temp[0] <<= 2;
|
||||||
temp[0] += temp[3] + temp[6];
|
temp[0] += temp[3] + temp[6];
|
||||||
|
|
||||||
red = ((int(temp[0]) * 160) >> 17) + 4;
|
red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||||
if (red > 31) red = 31;
|
if (red > 31)
|
||||||
|
red = 31;
|
||||||
|
|
||||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
if (temp[2] < temp[5])
|
||||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
swap(temp[2], temp[5]);
|
||||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
if (temp[2] < temp[8])
|
||||||
|
swap(temp[2], temp[8]);
|
||||||
|
if (temp[5] < temp[8])
|
||||||
|
swap(temp[5], temp[8]);
|
||||||
temp[5] <<= 1;
|
temp[5] <<= 1;
|
||||||
temp[2] <<= 2;
|
temp[2] <<= 2;
|
||||||
temp[2] += temp[5] + temp[8];
|
temp[2] += temp[5] + temp[8];
|
||||||
|
|
||||||
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||||
if (blue > 31) blue = 31;
|
if (blue > 31)
|
||||||
|
blue = 31;
|
||||||
|
|
||||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
if (temp[1] < temp[4])
|
||||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
swap(temp[1], temp[4]);
|
||||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
if (temp[1] < temp[7])
|
||||||
|
swap(temp[1], temp[7]);
|
||||||
|
if (temp[4] < temp[7])
|
||||||
|
swap(temp[4], temp[7]);
|
||||||
temp[4] <<= 1;
|
temp[4] <<= 1;
|
||||||
temp[1] <<= 2;
|
temp[1] <<= 2;
|
||||||
temp[1] += temp[4] + temp[7];
|
temp[1] += temp[4] + temp[7];
|
||||||
|
|
||||||
green = ((int(temp[1]) * 160) >> 17) + 4;
|
green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||||
if (green > 31) green = 31;
|
if (green > 31)
|
||||||
|
green = 31;
|
||||||
|
|
||||||
pix = red << systemRedShift;
|
pix = red << systemRedShift;
|
||||||
pix += green << systemGreenShift;
|
pix += green << systemGreenShift;
|
||||||
|
@ -96,8 +107,7 @@ void gbafilter_pal32(u32 * buf, int count)
|
||||||
unsigned pix;
|
unsigned pix;
|
||||||
u8 red, green, blue;
|
u8 red, green, blue;
|
||||||
|
|
||||||
while (count--)
|
while (count--) {
|
||||||
{
|
|
||||||
pix = *buf;
|
pix = *buf;
|
||||||
|
|
||||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||||
|
@ -115,9 +125,12 @@ void gbafilter_pal32(u32 * buf, int count)
|
||||||
temp[7] = s * influence[7];
|
temp[7] = s * influence[7];
|
||||||
temp[8] = s * influence[8];
|
temp[8] = s * influence[8];
|
||||||
|
|
||||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
if (temp[0] < temp[3])
|
||||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
swap(temp[0], temp[3]);
|
||||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
if (temp[0] < temp[6])
|
||||||
|
swap(temp[0], temp[6]);
|
||||||
|
if (temp[3] < temp[6])
|
||||||
|
swap(temp[3], temp[6]);
|
||||||
temp[3] <<= 1;
|
temp[3] <<= 1;
|
||||||
temp[0] <<= 2;
|
temp[0] <<= 2;
|
||||||
temp[0] += temp[3] + temp[6];
|
temp[0] += temp[3] + temp[6];
|
||||||
|
@ -125,9 +138,12 @@ void gbafilter_pal32(u32 * buf, int count)
|
||||||
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||||
red = ((int(temp[0]) * 160) >> 14) + 32;
|
red = ((int(temp[0]) * 160) >> 14) + 32;
|
||||||
|
|
||||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
if (temp[2] < temp[5])
|
||||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
swap(temp[2], temp[5]);
|
||||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
if (temp[2] < temp[8])
|
||||||
|
swap(temp[2], temp[8]);
|
||||||
|
if (temp[5] < temp[8])
|
||||||
|
swap(temp[5], temp[8]);
|
||||||
temp[5] <<= 1;
|
temp[5] <<= 1;
|
||||||
temp[2] <<= 2;
|
temp[2] <<= 2;
|
||||||
temp[2] += temp[5] + temp[8];
|
temp[2] += temp[5] + temp[8];
|
||||||
|
@ -135,9 +151,12 @@ void gbafilter_pal32(u32 * buf, int count)
|
||||||
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||||
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
||||||
|
|
||||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
if (temp[1] < temp[4])
|
||||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
swap(temp[1], temp[4]);
|
||||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
if (temp[1] < temp[7])
|
||||||
|
swap(temp[1], temp[7]);
|
||||||
|
if (temp[4] < temp[7])
|
||||||
|
swap(temp[4], temp[7]);
|
||||||
temp[4] <<= 1;
|
temp[4] <<= 1;
|
||||||
temp[1] <<= 2;
|
temp[1] <<= 2;
|
||||||
temp[1] += temp[4] + temp[7];
|
temp[1] += temp[4] + temp[7];
|
||||||
|
@ -161,8 +180,7 @@ void gbafilter_pal32(u32 * buf, int count)
|
||||||
|
|
||||||
void gbafilter_pad(u8* buf, int count)
|
void gbafilter_pad(u8* buf, int count)
|
||||||
{
|
{
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
u8 r;
|
u8 r;
|
||||||
|
@ -171,26 +189,22 @@ void gbafilter_pad(u8 * buf, int count)
|
||||||
u8 a;
|
u8 a;
|
||||||
} part;
|
} part;
|
||||||
unsigned whole;
|
unsigned whole;
|
||||||
}
|
} mask;
|
||||||
mask;
|
|
||||||
|
|
||||||
mask.whole = 0x1f << systemRedShift;
|
mask.whole = 0x1f << systemRedShift;
|
||||||
mask.whole += 0x1f << systemGreenShift;
|
mask.whole += 0x1f << systemGreenShift;
|
||||||
mask.whole += 0x1f << systemBlueShift;
|
mask.whole += 0x1f << systemBlueShift;
|
||||||
|
|
||||||
switch (systemColorDepth)
|
switch (systemColorDepth) {
|
||||||
{
|
|
||||||
case 24:
|
case 24:
|
||||||
while (count--)
|
while (count--) {
|
||||||
{
|
|
||||||
*buf++ &= mask.part.r;
|
*buf++ &= mask.part.r;
|
||||||
*buf++ &= mask.part.g;
|
*buf++ &= mask.part.g;
|
||||||
*buf++ &= mask.part.b;
|
*buf++ &= mask.part.b;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
while (count--)
|
while (count--) {
|
||||||
{
|
|
||||||
*((u32*)buf) &= mask.whole;
|
*((u32*)buf) &= mask.whole;
|
||||||
buf += 4;
|
buf += 4;
|
||||||
}
|
}
|
||||||
|
|
1770
src/gba/remote.cpp
1770
src/gba/remote.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue