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"
|
||||||
|
@ -107,14 +107,14 @@ sw, sword, s32, int --> signed word
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool dexp_eval(char *, u32*);
|
extern bool dexp_eval(char*, u32*);
|
||||||
|
|
||||||
//struct intToString{
|
//struct intToString{
|
||||||
// int value;
|
// int value;
|
||||||
// char mapping[20];
|
// char mapping[20];
|
||||||
//};
|
//};
|
||||||
|
|
||||||
struct ConditionalBreak* conditionals[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
struct ConditionalBreak* conditionals[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
//struct intToString breakFlagMapping[] = {
|
//struct intToString breakFlagMapping[] = {
|
||||||
// {0x80,"Thumb"},
|
// {0x80,"Thumb"},
|
||||||
|
@ -143,48 +143,46 @@ 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
|
||||||
//case 'a': flag = 0x4; break; // arm
|
//case 'a': flag = 0x4; break; // arm
|
||||||
//case 'x': flag = 0xC; break;
|
//case 'x': flag = 0xC; break;
|
||||||
//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)));
|
||||||
if(flag & 0xf0){
|
if (flag & 0xf0) {
|
||||||
struct ConditionalBreak* base = conditionals[condIndex];
|
struct ConditionalBreak* base = conditionals[condIndex];
|
||||||
struct ConditionalBreak* prev = conditionals[condIndex];
|
struct ConditionalBreak* prev = conditionals[condIndex];
|
||||||
if(conditionals[condIndex]){
|
if (conditionals[condIndex]) {
|
||||||
while((base) && (address >= base->break_address)){
|
while ((base) && (address >= base->break_address)) {
|
||||||
if(base->break_address == address){
|
if (base->break_address == address) {
|
||||||
if(base->type_flags & 0xf0){
|
if (base->type_flags & 0xf0) {
|
||||||
base->type_flags |= (flag&0xf0);
|
base->type_flags |= (flag & 0xf0);
|
||||||
flag &= 0xf;
|
flag &= 0xf;
|
||||||
cond = base;
|
cond = base;
|
||||||
goto addCB_nextHandle;
|
goto addCB_nextHandle;
|
||||||
}else{
|
} else {
|
||||||
goto condCreateForFlagAlways;
|
goto condCreateForFlagAlways;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
prev = base;
|
prev = base;
|
||||||
base = base->next;
|
base = base->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
condCreateForFlagAlways:
|
condCreateForFlagAlways:
|
||||||
cond = (struct ConditionalBreak*)malloc(sizeof(struct ConditionalBreak));
|
cond = (struct ConditionalBreak*)malloc(sizeof(struct ConditionalBreak));
|
||||||
cond->break_address = address;
|
cond->break_address = address;
|
||||||
cond->type_flags = flag&0xf0;
|
cond->type_flags = flag & 0xf0;
|
||||||
cond->next = base;
|
cond->next = base;
|
||||||
cond->firstCond = NULL;
|
cond->firstCond = NULL;
|
||||||
if(prev == conditionals[condIndex])
|
if (prev == conditionals[condIndex])
|
||||||
conditionals[condIndex] = cond;
|
conditionals[condIndex] = cond;
|
||||||
else
|
else
|
||||||
prev->next = cond;
|
prev->next = cond;
|
||||||
|
@ -192,7 +190,7 @@ condCreateForFlagAlways:
|
||||||
flag &= 0xf;
|
flag &= 0xf;
|
||||||
|
|
||||||
addCB_nextHandle:
|
addCB_nextHandle:
|
||||||
if(flag == 0)
|
if (flag == 0)
|
||||||
return cond;
|
return cond;
|
||||||
|
|
||||||
cond = (struct ConditionalBreak*)malloc(sizeof(struct ConditionalBreak));
|
cond = (struct ConditionalBreak*)malloc(sizeof(struct ConditionalBreak));
|
||||||
|
@ -200,18 +198,18 @@ addCB_nextHandle:
|
||||||
cond->type_flags = flag;
|
cond->type_flags = flag;
|
||||||
cond->next = NULL;
|
cond->next = NULL;
|
||||||
cond->firstCond = NULL;
|
cond->firstCond = NULL;
|
||||||
if(conditionals[condIndex] == NULL){
|
if (conditionals[condIndex] == NULL) {
|
||||||
conditionals[condIndex] = cond;
|
conditionals[condIndex] = cond;
|
||||||
return cond;
|
return cond;
|
||||||
}else{
|
} else {
|
||||||
struct ConditionalBreak *curr, *prev;
|
struct ConditionalBreak *curr, *prev;
|
||||||
curr = conditionals[condIndex];
|
curr = conditionals[condIndex];
|
||||||
prev = conditionals[condIndex];
|
prev = conditionals[condIndex];
|
||||||
while(curr){
|
while (curr) {
|
||||||
if(curr->break_address > address){
|
if (curr->break_address > address) {
|
||||||
if(prev == curr){
|
if (prev == curr) {
|
||||||
conditionals[condIndex] = cond;
|
conditionals[condIndex] = cond;
|
||||||
}else{
|
} else {
|
||||||
prev->next = cond;
|
prev->next = cond;
|
||||||
}
|
}
|
||||||
cond->next = curr;
|
cond->next = curr;
|
||||||
|
@ -225,26 +223,27 @@ 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;
|
||||||
prev = base->firstCond;
|
prev = base->firstCond;
|
||||||
while(curr){
|
while (curr) {
|
||||||
prev = curr;
|
prev = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
prev->next = toAdd;
|
prev->next = toAdd;
|
||||||
}else{
|
} else {
|
||||||
base->firstCond = toAdd;
|
base->firstCond = toAdd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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;
|
||||||
toFree->firstCond = toFree->firstCond->next;
|
toFree->firstCond = toFree->firstCond->next;
|
||||||
free(freeMe);
|
free(freeMe);
|
||||||
|
@ -252,36 +251,39 @@ 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)
|
||||||
free(toDel->address);
|
free(toDel->address);
|
||||||
if(toDel->value)
|
if (toDel->value)
|
||||||
free(toDel->value);
|
free(toDel->value);
|
||||||
free(toDel);
|
free(toDel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeAllConditionals(){
|
void freeAllConditionals()
|
||||||
for(int i = 0; i<16; i++){
|
{
|
||||||
while(conditionals[i]){
|
for (int i = 0; i < 16; i++) {
|
||||||
|
while (conditionals[i]) {
|
||||||
struct ConditionalBreak* tmp = conditionals[i];
|
struct ConditionalBreak* tmp = conditionals[i];
|
||||||
conditionals[i] = conditionals[i]->next;
|
conditionals[i] = conditionals[i]->next;
|
||||||
freeConditionalBreak(tmp);
|
freeConditionalBreak(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalBreak(struct ConditionalBreak* toDelete){
|
int removeConditionalBreak(struct ConditionalBreak* toDelete)
|
||||||
if(toDelete){
|
{
|
||||||
u8 condIndex = toDelete->break_address>>24;
|
if (toDelete) {
|
||||||
|
u8 condIndex = toDelete->break_address >> 24;
|
||||||
struct ConditionalBreak* base = conditionals[condIndex];
|
struct ConditionalBreak* base = conditionals[condIndex];
|
||||||
struct ConditionalBreak* prev = conditionals[condIndex];
|
struct ConditionalBreak* prev = conditionals[condIndex];
|
||||||
while(base){
|
while (base) {
|
||||||
if(base == toDelete){
|
if (base == toDelete) {
|
||||||
if(base == prev){
|
if (base == prev) {
|
||||||
conditionals[condIndex] = base->next;
|
conditionals[condIndex] = base->next;
|
||||||
}else{
|
} else {
|
||||||
prev->next = base->next;
|
prev->next = base->next;
|
||||||
}
|
}
|
||||||
freeConditionalBreak(toDelete);
|
freeConditionalBreak(toDelete);
|
||||||
|
@ -391,53 +393,54 @@ 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) {
|
||||||
if(base->break_address < address){
|
if (base->break_address < address) {
|
||||||
base = base->next;
|
base = base->next;
|
||||||
}else{
|
} else {
|
||||||
if(base->break_address == address){
|
if (base->break_address == address) {
|
||||||
flags |= base->type_flags;
|
flags |= base->type_flags;
|
||||||
}else{
|
} else {
|
||||||
BreakClear((&map[address>>24])->breakPoints,address & (&map[address>>24])->mask,0xff);
|
BreakClear((&map[address >> 24])->breakPoints, address & (&map[address >> 24])->mask, 0xff);
|
||||||
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)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base = base->next;
|
base = base->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreakClear((&map[address>>24])->breakPoints,address & (&map[address>>24])->mask,0xff);
|
BreakClear((&map[address >> 24])->breakPoints, address & (&map[address >> 24])->mask, 0xff);
|
||||||
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]){
|
{
|
||||||
struct ConditionalBreak* base = conditionals[addrNo>>24];
|
if (conditionals[addrNo >> 24]) {
|
||||||
struct ConditionalBreak* curr = conditionals[addrNo>>24];
|
struct ConditionalBreak* base = conditionals[addrNo >> 24];
|
||||||
|
struct ConditionalBreak* curr = conditionals[addrNo >> 24];
|
||||||
u8 count = 1;
|
u8 count = 1;
|
||||||
while (curr->break_address < addrNo){
|
while (curr->break_address < addrNo) {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
if(curr->break_address == addrNo){
|
if (curr->break_address == addrNo) {
|
||||||
if(number == 1){
|
if (number == 1) {
|
||||||
if(base == curr){
|
if (base == curr) {
|
||||||
conditionals[addrNo>>24] = curr->next;
|
conditionals[addrNo >> 24] = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
}else{
|
} else {
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
}
|
}
|
||||||
recountFlagsForAddress(addrNo);
|
recountFlagsForAddress(addrNo);
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
} else {
|
||||||
int count = 1;
|
int count = 1;
|
||||||
while(curr && (curr->break_address == addrNo)){
|
while (curr && (curr->break_address == addrNo)) {
|
||||||
if(count == number){
|
if (count == number) {
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
recountFlagsForAddress(addrNo);
|
recountFlagsForAddress(addrNo);
|
||||||
|
@ -454,35 +457,36 @@ 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]){
|
{
|
||||||
struct ConditionalBreak* base = conditionals[addrNo>>24];
|
if (conditionals[addrNo >> 24]) {
|
||||||
struct ConditionalBreak* curr = conditionals[addrNo>>24];
|
struct ConditionalBreak* base = conditionals[addrNo >> 24];
|
||||||
|
struct ConditionalBreak* curr = conditionals[addrNo >> 24];
|
||||||
u8 count = 1;
|
u8 count = 1;
|
||||||
while (curr->break_address < addrNo){
|
while (curr->break_address < addrNo) {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
if(curr->break_address == addrNo){
|
if (curr->break_address == addrNo) {
|
||||||
if(number == 1){
|
if (number == 1) {
|
||||||
curr->type_flags &= ~flag;
|
curr->type_flags &= ~flag;
|
||||||
if(curr->type_flags == 0){
|
if (curr->type_flags == 0) {
|
||||||
if(base == curr){
|
if (base == curr) {
|
||||||
conditionals[addrNo>>24] = curr->next;
|
conditionals[addrNo >> 24] = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
}else{
|
} else {
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recountFlagsForAddress(addrNo);
|
recountFlagsForAddress(addrNo);
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
} else {
|
||||||
int count = 1;
|
int count = 1;
|
||||||
while(curr && (curr->break_address == addrNo)){
|
while (curr && (curr->break_address == addrNo)) {
|
||||||
if(count == number){
|
if (count == number) {
|
||||||
curr->type_flags &= ~flag;
|
curr->type_flags &= ~flag;
|
||||||
if(!curr->type_flags){
|
if (!curr->type_flags) {
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
recountFlagsForAddress(addrNo);
|
recountFlagsForAddress(addrNo);
|
||||||
|
@ -502,58 +506,59 @@ int removeFlagFromConditionalBreakNo(u32 addrNo, u8 number, u8 flag){
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalWithAddress(u32 address){
|
int removeConditionalWithAddress(u32 address)
|
||||||
u8 addrNo = address>>24;
|
{
|
||||||
if(conditionals[addrNo] != NULL){
|
u8 addrNo = address >> 24;
|
||||||
|
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;
|
||||||
u8 flags = 0;
|
u8 flags = 0;
|
||||||
while(curr && address >= curr->break_address){
|
while (curr && address >= curr->break_address) {
|
||||||
if(curr->break_address == address){
|
if (curr->break_address == address) {
|
||||||
base->next = curr->next;
|
base->next = curr->next;
|
||||||
flags |= curr->type_flags;
|
flags |= curr->type_flags;
|
||||||
freeConditionalBreak(curr);
|
freeConditionalBreak(curr);
|
||||||
curr = base->next;
|
curr = base->next;
|
||||||
count++;
|
count++;
|
||||||
}else{
|
} else {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreakClear((&map[address>>24])->breakPoints,address & (&map[address>>24])->mask,((flags&0xf)|(flags>>4)));
|
BreakClear((&map[address >> 24])->breakPoints, address & (&map[address >> 24])->mask, ((flags & 0xf) | (flags >> 4)));
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeConditionalWithFlag(u8 flag, bool orMode){
|
int removeConditionalWithFlag(u8 flag, bool orMode)
|
||||||
for(u8 addrNo = 0; addrNo < 16;addrNo++){
|
{
|
||||||
if(conditionals[addrNo] != NULL){
|
for (u8 addrNo = 0; addrNo < 16; addrNo++) {
|
||||||
|
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){
|
while (curr) {
|
||||||
if(((curr->type_flags & flag) == curr->type_flags) || (orMode && (curr->type_flags & flag))){
|
if (((curr->type_flags & flag) == curr->type_flags) || (orMode && (curr->type_flags & flag))) {
|
||||||
curr->type_flags &= ~flag;
|
curr->type_flags &= ~flag;
|
||||||
BreakClear((&map[addrNo])->breakPoints,curr->break_address & (&map[addrNo])->mask,((flag&0xf)|(flag>>4)));
|
BreakClear((&map[addrNo])->breakPoints, curr->break_address & (&map[addrNo])->mask, ((flag & 0xf) | (flag >> 4)));
|
||||||
if(curr->type_flags == 0){
|
if (curr->type_flags == 0) {
|
||||||
if(base == conditionals[addrNo]){
|
if (base == conditionals[addrNo]) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}else{
|
} else {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
|
@ -564,34 +569,33 @@ 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;
|
{
|
||||||
if(conditionals[addrNo] != NULL){
|
u8 addrNo = address >> 24;
|
||||||
|
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) {
|
||||||
if(curr == conditionals[addrNo]){
|
if (curr == conditionals[addrNo]) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}else{
|
} else {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
base = curr;
|
base = curr;
|
||||||
curr = curr->next;
|
curr = curr->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,230 +612,253 @@ 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)
|
||||||
return;
|
return;
|
||||||
bool notBk = true;
|
bool notBk = true;
|
||||||
struct ConditionalBreakNode* now = (struct ConditionalBreakNode*)malloc(sizeof(struct ConditionalBreakNode));
|
struct ConditionalBreakNode* now = (struct ConditionalBreakNode*)malloc(sizeof(struct ConditionalBreakNode));
|
||||||
struct ConditionalBreakNode* toAdd = now;
|
struct ConditionalBreakNode* toAdd = now;
|
||||||
for(int i = 0; i < n; i++){
|
for (int i = 0; i < n; i++) {
|
||||||
now->next = 0;
|
now->next = 0;
|
||||||
now->exp_type_flags = 0;
|
now->exp_type_flags = 0;
|
||||||
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)
|
||||||
}else{
|
goto fail;
|
||||||
|
} 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)
|
||||||
}else{
|
goto fail;
|
||||||
|
} else {
|
||||||
now->exp_type_flags |= 0x60; //assume signed word
|
now->exp_type_flags |= 0x60; //assume signed word
|
||||||
}
|
}
|
||||||
now->value = strdup(exp[i]);
|
now->value = strdup(exp[i]);
|
||||||
i++;
|
i++;
|
||||||
u32 val;
|
u32 val;
|
||||||
if(!dexp_eval(now->value, &val) || !dexp_eval(now->address, &val)){
|
if (!dexp_eval(now->value, &val) || !dexp_eval(now->address, &val)) {
|
||||||
printf("Invalid expression.\n");
|
printf("Invalid expression.\n");
|
||||||
if(workBreak)
|
if (workBreak)
|
||||||
removeConditionalBreak(workBreak);
|
removeConditionalBreak(workBreak);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(i < n){
|
if (i < n) {
|
||||||
if(strcmp(exp[i], "&&") == 0){
|
if (strcmp(exp[i], "&&") == 0) {
|
||||||
now = (struct ConditionalBreakNode*)malloc(sizeof(struct ConditionalBreakNode));
|
now = (struct ConditionalBreakNode*)malloc(sizeof(struct ConditionalBreakNode));
|
||||||
toAdd->next = now;
|
toAdd->next = now;
|
||||||
}else if (strcmp(exp[i], "||") == 0){
|
} else if (strcmp(exp[i], "||") == 0) {
|
||||||
addCondition(workBreak,toAdd);
|
addCondition(workBreak, toAdd);
|
||||||
printf("Added break on address %08x, with condition:\n%s %s %s\n", address, now->address, operandName,now->value);
|
printf("Added break on address %08x, with condition:\n%s %s %s\n", address, now->address, operandName, now->value);
|
||||||
workBreak = addConditionalBreak(address, flags);
|
workBreak = addConditionalBreak(address, flags);
|
||||||
now = (struct ConditionalBreakNode*)malloc(sizeof(struct ConditionalBreakNode));
|
now = (struct ConditionalBreakNode*)malloc(sizeof(struct ConditionalBreakNode));
|
||||||
toAdd = now;
|
toAdd = now;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
addCondition(workBreak,toAdd);
|
addCondition(workBreak, toAdd);
|
||||||
printf("Added break on address %08x, ending with condition: \n%s %s %s\n", address, now->address, operandName,now->value);
|
printf("Added break on address %08x, ending with condition: \n%s %s %s\n", address, now->address, operandName, now->value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
printf("Not enough material (expressions) to work with.");
|
printf("Not enough material (expressions) to work with.");
|
||||||
removeConditionalBreak(workBreak);
|
removeConditionalBreak(workBreak);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//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);
|
||||||
for(int i = 0; type[i] != '\0'; i++){
|
for (int i = 0; type[i] != '\0'; i++) {
|
||||||
type[i] = toupper(type[i]);
|
type[i] = toupper(type[i]);
|
||||||
}
|
}
|
||||||
if((type[0] == 'S') || type[0] == 'U'){
|
if ((type[0] == 'S') || type[0] == 'U') {
|
||||||
flags |= (4 - ((type[0]-'S')<<1));
|
flags |= (4 - ((type[0] - 'S') << 1));
|
||||||
type++;
|
type++;
|
||||||
if(type[0] == 'H'){
|
if (type[0] == 'H') {
|
||||||
type[0] = '1';
|
type[0] = '1';
|
||||||
type[1] = '6';
|
type[1] = '6';
|
||||||
type[2] = '\0';
|
type[2] = '\0';
|
||||||
}else if(type[0] == 'W'){
|
} else if (type[0] == 'W') {
|
||||||
type[0] = '3';
|
type[0] = '3';
|
||||||
type[1] = '2';
|
type[1] = '2';
|
||||||
type[2] = '\0';
|
type[2] = '\0';
|
||||||
}else if(type[0] == 'B'){
|
} else if (type[0] == 'B') {
|
||||||
type[0] = '8';
|
type[0] = '8';
|
||||||
type[1] = '\0';
|
type[1] = '\0';
|
||||||
}
|
}
|
||||||
int size;
|
int size;
|
||||||
sscanf(type, "%d",&size);
|
sscanf(type, "%d", &size);
|
||||||
size = (size>>3) - 1;
|
size = (size >> 3) - 1;
|
||||||
flags |= (size >= 2 ? 2: ((u8)size));
|
flags |= (size >= 2 ? 2 : ((u8)size));
|
||||||
free(type);
|
free(type);
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
if(strcmp(type, "INT")==0){
|
if (strcmp(type, "INT") == 0) {
|
||||||
flags = 6;
|
flags = 6;
|
||||||
}
|
}
|
||||||
if(type[0] == 'H'){
|
if (type[0] == 'H') {
|
||||||
flags = 1;
|
flags = 1;
|
||||||
}else if(type[0] == 'W'){
|
} else if (type[0] == 'W') {
|
||||||
flags = 2;
|
flags = 2;
|
||||||
}else if(type[0] == 'B'){
|
} else if (type[0] == 'B') {
|
||||||
flags = 0;
|
flags = 0;
|
||||||
}else{
|
} else {
|
||||||
flags = 6;
|
flags = 6;
|
||||||
}
|
}
|
||||||
free(type);
|
free(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;
|
||||||
if(type[1] == '\0')
|
if (type[1] == '\0')
|
||||||
return flag | 0x2;
|
return flag | 0x2;
|
||||||
break;
|
break;
|
||||||
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");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
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;
|
||||||
bool veredict = false;
|
bool veredict = false;
|
||||||
while(toExamine && globalVeredict){
|
while (toExamine && globalVeredict) {
|
||||||
u32 address = calculateFinalValue(toExamine->address, toExamine->exp_type_flags&0xf);
|
u32 address = calculateFinalValue(toExamine->address, toExamine->exp_type_flags & 0xf);
|
||||||
u32 value = calculateFinalValue(toExamine->value, toExamine->exp_type_flags>>4);
|
u32 value = calculateFinalValue(toExamine->value, toExamine->exp_type_flags >> 4);
|
||||||
if((toExamine->cond_flags &0x7) != 0){
|
if ((toExamine->cond_flags & 0x7) != 0) {
|
||||||
veredict = veredict || ((toExamine->cond_flags&1)? (address == value):false);
|
veredict = veredict || ((toExamine->cond_flags & 1) ? (address == value) : false);
|
||||||
veredict = veredict || ((toExamine->cond_flags&4)? ((toExamine->cond_flags&8)? ((int)address < (int)value) : (address < value)) : false);
|
veredict = veredict || ((toExamine->cond_flags & 4) ? ((toExamine->cond_flags & 8) ? ((int)address < (int)value) : (address < value)) : false);
|
||||||
veredict = veredict || ((toExamine->cond_flags&2)? ((toExamine->cond_flags&8)? ((int)address > (int)value) : (address > value)) : false);
|
veredict = veredict || ((toExamine->cond_flags & 2) ? ((toExamine->cond_flags & 8) ? ((int)address > (int)value) : (address > value)) : false);
|
||||||
}
|
}
|
||||||
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;
|
{
|
||||||
if(conditionals[addrNo]){
|
u8 addrNo = address >> 24;
|
||||||
|
if (conditionals[addrNo]) {
|
||||||
struct ConditionalBreak* base = conditionals[addrNo];
|
struct ConditionalBreak* base = conditionals[addrNo];
|
||||||
while(base && base->break_address < address){
|
while (base && base->break_address < address) {
|
||||||
base = base->next;
|
base = base->next;
|
||||||
}
|
}
|
||||||
while(base && base->break_address == address){
|
while (base && base->break_address == address) {
|
||||||
if(base->type_flags & allowedFlags &0xf0){
|
if (base->type_flags & allowedFlags & 0xf0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(isCorrectBreak(base,allowedFlags) && doBreak(base)){
|
if (isCorrectBreak(base, allowedFlags) && doBreak(base)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
base = base->next;
|
base = base->next;
|
||||||
|
|
|
@ -4,33 +4,29 @@
|
||||||
#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]
|
||||||
|
|
||||||
struct ConditionalBreakNode {
|
struct ConditionalBreakNode {
|
||||||
char *address;
|
char* address;
|
||||||
char *value;
|
char* value;
|
||||||
u8 cond_flags;
|
u8 cond_flags;
|
||||||
u8 exp_type_flags;
|
u8 exp_type_flags;
|
||||||
struct ConditionalBreakNode *next;
|
struct ConditionalBreakNode* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConditionalBreak {
|
struct ConditionalBreak {
|
||||||
u32 break_address;
|
u32 break_address;
|
||||||
u8 type_flags;
|
u8 type_flags;
|
||||||
struct ConditionalBreakNode *firstCond;
|
struct ConditionalBreakNode* firstCond;
|
||||||
struct ConditionalBreak *next;
|
struct ConditionalBreak* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ConditionalBreak *conditionals[16];
|
extern struct ConditionalBreak* conditionals[16];
|
||||||
|
|
||||||
// conditional break manipulators
|
// conditional break manipulators
|
||||||
// case '*': flag = 0xf; break;
|
// case '*': flag = 0xf; break;
|
||||||
|
@ -40,7 +36,7 @@ extern struct ConditionalBreak *conditionals[16];
|
||||||
// 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);
|
||||||
|
|
||||||
int removeConditionalBreakNo(u32 address, u8 number);
|
int removeConditionalBreakNo(u32 address, u8 number);
|
||||||
int removeFlagFromConditionalBreakNo(u32 address, u8 number, u8 flag);
|
int removeFlagFromConditionalBreakNo(u32 address, u8 number, u8 flag);
|
||||||
|
@ -49,17 +45,17 @@ int removeConditionalWithFlag(u8 flag, bool orMode);
|
||||||
int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode);
|
int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode);
|
||||||
// void freeConditionalBreak(struct ConditionalBreak* toFree);
|
// void freeConditionalBreak(struct ConditionalBreak* toFree);
|
||||||
|
|
||||||
void addCondition(struct ConditionalBreak *base, struct ConditionalBreakNode *toAdd);
|
void addCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toAdd);
|
||||||
// bool removeCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toDel);
|
// bool removeCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toDel);
|
||||||
// bool removeCondition(u32 address, u8 flags, u8 num);
|
// bool removeCondition(u32 address, u8 flags, u8 num);
|
||||||
|
|
||||||
void freeConditionalNode(struct ConditionalBreakNode *toDel);
|
void freeConditionalNode(struct ConditionalBreakNode* toDel);
|
||||||
|
|
||||||
void parseAndCreateConditionalBreaks(u32 address, u8 flags, char **exp, int n);
|
void parseAndCreateConditionalBreaks(u32 address, u8 flags, char** exp, int n);
|
||||||
|
|
||||||
bool isCorrectBreak(struct ConditionalBreak *toTest, u8 accessType);
|
bool isCorrectBreak(struct ConditionalBreak* toTest, u8 accessType);
|
||||||
bool doesBreak(u32 address, u8 allowedFlags);
|
bool doesBreak(u32 address, u8 allowedFlags);
|
||||||
bool doBreak(struct ConditionalBreak *toTest);
|
bool doBreak(struct ConditionalBreak* toTest);
|
||||||
|
|
||||||
// printing the structure(AKA list Breaks)
|
// printing the structure(AKA list Breaks)
|
||||||
// void printConditionalBreak(struct ConditionalBreak* toPrint, bool printAddress);
|
// void printConditionalBreak(struct ConditionalBreak* toPrint, bool printAddress);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <stdlib.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "CheatSearch.h"
|
#include "CheatSearch.h"
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ static bool cheatSearchSignedGE(s32 a, s32 b)
|
||||||
return a >= b;
|
return a >= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool (*cheatSearchFunc[])(u32,u32) = {
|
static bool (*cheatSearchFunc[])(u32, u32) = {
|
||||||
cheatSearchEQ,
|
cheatSearchEQ,
|
||||||
cheatSearchNE,
|
cheatSearchNE,
|
||||||
cheatSearchLT,
|
cheatSearchLT,
|
||||||
|
@ -79,7 +79,7 @@ static bool (*cheatSearchFunc[])(u32,u32) = {
|
||||||
cheatSearchGE
|
cheatSearchGE
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool (*cheatSearchSignedFunc[])(s32,s32) = {
|
static bool (*cheatSearchSignedFunc[])(s32, s32) = {
|
||||||
cheatSearchSignedEQ,
|
cheatSearchSignedEQ,
|
||||||
cheatSearchSignedNE,
|
cheatSearchSignedNE,
|
||||||
cheatSearchSignedLT,
|
cheatSearchSignedLT,
|
||||||
|
@ -88,123 +88,123 @@ static bool (*cheatSearchSignedFunc[])(s32,s32) = {
|
||||||
cheatSearchSignedGE
|
cheatSearchSignedGE
|
||||||
};
|
};
|
||||||
|
|
||||||
void cheatSearchCleanup(CheatSearchData *cs)
|
void cheatSearchCleanup(CheatSearchData* cs)
|
||||||
{
|
{
|
||||||
int count = cs->count;
|
int count = cs->count;
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
free(cs->blocks[i].saved);
|
free(cs->blocks[i].saved);
|
||||||
free(cs->blocks[i].bits);
|
free(cs->blocks[i].bits);
|
||||||
}
|
}
|
||||||
cs->count = 0;
|
cs->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cheatSearchStart(const CheatSearchData *cs)
|
void cheatSearchStart(const CheatSearchData* cs)
|
||||||
{
|
{
|
||||||
int count = cs->count;
|
int count = cs->count;
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
|
|
||||||
memset(block->bits, 0xff, block->size >> 3);
|
memset(block->bits, 0xff, block->size >> 3);
|
||||||
memcpy(block->saved, block->data, block->size);
|
memcpy(block->saved, block->data, block->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cheatSearchSignedRead(u8 *data, int off, int size)
|
s32 cheatSearchSignedRead(u8* data, int off, int size)
|
||||||
{
|
{
|
||||||
u32 res = data[off++];
|
u32 res = data[off++];
|
||||||
|
|
||||||
switch(size) {
|
switch (size) {
|
||||||
case BITS_8:
|
case BITS_8:
|
||||||
res <<= 24;
|
res <<= 24;
|
||||||
return ((s32)res) >> 24;
|
return ((s32)res) >> 24;
|
||||||
case BITS_16:
|
case BITS_16:
|
||||||
res |= ((u32)data[off++])<<8;
|
res |= ((u32)data[off++]) << 8;
|
||||||
res <<= 16;
|
res <<= 16;
|
||||||
return ((s32)res) >> 16;
|
return ((s32)res) >> 16;
|
||||||
case BITS_32:
|
case BITS_32:
|
||||||
res |= ((u32)data[off++])<<8;
|
res |= ((u32)data[off++]) << 8;
|
||||||
res |= ((u32)data[off++])<<16;
|
res |= ((u32)data[off++]) << 16;
|
||||||
res |= ((u32)data[off++])<<24;
|
res |= ((u32)data[off++]) << 24;
|
||||||
return (s32)res;
|
return (s32)res;
|
||||||
}
|
}
|
||||||
return (s32)res;
|
return (s32)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 cheatSearchRead(u8 *data, int off, int size)
|
u32 cheatSearchRead(u8* data, int off, int size)
|
||||||
{
|
{
|
||||||
u32 res = data[off++];
|
u32 res = data[off++];
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
res |= ((u32)data[off++])<<8;
|
res |= ((u32)data[off++]) << 8;
|
||||||
else if(size == BITS_32) {
|
else if (size == BITS_32) {
|
||||||
res |= ((u32)data[off++])<<8;
|
res |= ((u32)data[off++]) << 8;
|
||||||
res |= ((u32)data[off++])<<16;
|
res |= ((u32)data[off++]) << 16;
|
||||||
res |= ((u32)data[off++])<<24;
|
res |= ((u32)data[off++]) << 24;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
void cheatSearch(const CheatSearchData* cs, int compare, int size,
|
||||||
bool isSigned)
|
bool isSigned)
|
||||||
{
|
{
|
||||||
if(compare < 0 || compare > SEARCH_GE)
|
if (compare < 0 || compare > SEARCH_GE)
|
||||||
return;
|
return;
|
||||||
int inc = 1;
|
int inc = 1;
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
inc = 2;
|
inc = 2;
|
||||||
else if(size == BITS_32)
|
else if (size == BITS_32)
|
||||||
inc = 4;
|
inc = 4;
|
||||||
|
|
||||||
if(isSigned) {
|
if (isSigned) {
|
||||||
bool (*func)(s32,s32) = cheatSearchSignedFunc[compare];
|
bool (*func)(s32, s32) = cheatSearchSignedFunc[compare];
|
||||||
|
|
||||||
for(int i = 0; i < cs->count; i++) {
|
for (int i = 0; i < cs->count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
int size2 = block->size;
|
int size2 = block->size;
|
||||||
u8 *bits = block->bits;
|
u8* bits = block->bits;
|
||||||
u8 *data = block->data;
|
u8* data = block->data;
|
||||||
u8 *saved = block->saved;
|
u8* saved = block->saved;
|
||||||
|
|
||||||
for(int j = 0; j < size2; j += inc) {
|
for (int j = 0; j < size2; j += inc) {
|
||||||
if(IS_BIT_SET(bits, j)) {
|
if (IS_BIT_SET(bits, j)) {
|
||||||
s32 a = cheatSearchSignedRead(data, j, size);
|
s32 a = cheatSearchSignedRead(data, j, size);
|
||||||
s32 b = cheatSearchSignedRead(saved,j, size);
|
s32 b = cheatSearchSignedRead(saved, j, size);
|
||||||
|
|
||||||
if(!func(a, b)) {
|
if (!func(a, b)) {
|
||||||
CLEAR_BIT(bits, j);
|
CLEAR_BIT(bits, j);
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
CLEAR_BIT(bits, j+1);
|
CLEAR_BIT(bits, j + 1);
|
||||||
if(size == BITS_32) {
|
if (size == BITS_32) {
|
||||||
CLEAR_BIT(bits, j+2);
|
CLEAR_BIT(bits, j + 2);
|
||||||
CLEAR_BIT(bits, j+3);
|
CLEAR_BIT(bits, j + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool (*func)(u32,u32) = cheatSearchFunc[compare];
|
bool (*func)(u32, u32) = cheatSearchFunc[compare];
|
||||||
|
|
||||||
for(int i = 0; i < cs->count; i++) {
|
for (int i = 0; i < cs->count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
int size2 = block->size;
|
int size2 = block->size;
|
||||||
u8 *bits = block->bits;
|
u8* bits = block->bits;
|
||||||
u8 *data = block->data;
|
u8* data = block->data;
|
||||||
u8 *saved = block->saved;
|
u8* saved = block->saved;
|
||||||
|
|
||||||
for(int j = 0; j < size2; j += inc) {
|
for (int j = 0; j < size2; j += inc) {
|
||||||
if(IS_BIT_SET(bits, j)) {
|
if (IS_BIT_SET(bits, j)) {
|
||||||
u32 a = cheatSearchRead(data, j, size);
|
u32 a = cheatSearchRead(data, j, size);
|
||||||
u32 b = cheatSearchRead(saved,j, size);
|
u32 b = cheatSearchRead(saved, j, size);
|
||||||
|
|
||||||
if(!func(a, b)) {
|
if (!func(a, b)) {
|
||||||
CLEAR_BIT(bits, j);
|
CLEAR_BIT(bits, j);
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
CLEAR_BIT(bits, j+1);
|
CLEAR_BIT(bits, j + 1);
|
||||||
if(size == BITS_32) {
|
if (size == BITS_32) {
|
||||||
CLEAR_BIT(bits, j+2);
|
CLEAR_BIT(bits, j + 2);
|
||||||
CLEAR_BIT(bits, j+3);
|
CLEAR_BIT(bits, j + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,63 +213,63 @@ void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
void cheatSearchValue(const CheatSearchData* cs, int compare, int size,
|
||||||
bool isSigned, u32 value)
|
bool isSigned, u32 value)
|
||||||
{
|
{
|
||||||
if(compare < 0 || compare > SEARCH_GE)
|
if (compare < 0 || compare > SEARCH_GE)
|
||||||
return;
|
return;
|
||||||
int inc = 1;
|
int inc = 1;
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
inc = 2;
|
inc = 2;
|
||||||
else if(size == BITS_32)
|
else if (size == BITS_32)
|
||||||
inc = 4;
|
inc = 4;
|
||||||
|
|
||||||
if(isSigned) {
|
if (isSigned) {
|
||||||
bool (*func)(s32,s32) = cheatSearchSignedFunc[compare];
|
bool (*func)(s32, s32) = cheatSearchSignedFunc[compare];
|
||||||
|
|
||||||
for(int i = 0; i < cs->count; i++) {
|
for (int i = 0; i < cs->count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
int size2 = block->size;
|
int size2 = block->size;
|
||||||
u8 *bits = block->bits;
|
u8* bits = block->bits;
|
||||||
u8 *data = block->data;
|
u8* data = block->data;
|
||||||
|
|
||||||
for(int j = 0; j < size2; j += inc) {
|
for (int j = 0; j < size2; j += inc) {
|
||||||
if(IS_BIT_SET(bits, j)) {
|
if (IS_BIT_SET(bits, j)) {
|
||||||
s32 a = cheatSearchSignedRead(data, j, size);
|
s32 a = cheatSearchSignedRead(data, j, size);
|
||||||
s32 b = (s32)value;
|
s32 b = (s32)value;
|
||||||
|
|
||||||
if(!func(a, b)) {
|
if (!func(a, b)) {
|
||||||
CLEAR_BIT(bits, j);
|
CLEAR_BIT(bits, j);
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
CLEAR_BIT(bits, j+1);
|
CLEAR_BIT(bits, j + 1);
|
||||||
if(size == BITS_32) {
|
if (size == BITS_32) {
|
||||||
CLEAR_BIT(bits, j+2);
|
CLEAR_BIT(bits, j + 2);
|
||||||
CLEAR_BIT(bits, j+3);
|
CLEAR_BIT(bits, j + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool (*func)(u32,u32) = cheatSearchFunc[compare];
|
bool (*func)(u32, u32) = cheatSearchFunc[compare];
|
||||||
|
|
||||||
for(int i = 0; i < cs->count; i++) {
|
for (int i = 0; i < cs->count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
int size2 = block->size;
|
int size2 = block->size;
|
||||||
u8 *bits = block->bits;
|
u8* bits = block->bits;
|
||||||
u8 *data = block->data;
|
u8* data = block->data;
|
||||||
|
|
||||||
for(int j = 0; j < size2; j += inc) {
|
for (int j = 0; j < size2; j += inc) {
|
||||||
if(IS_BIT_SET(bits, j)) {
|
if (IS_BIT_SET(bits, j)) {
|
||||||
u32 a = cheatSearchRead(data, j, size);
|
u32 a = cheatSearchRead(data, j, size);
|
||||||
|
|
||||||
if(!func(a, value)) {
|
if (!func(a, value)) {
|
||||||
CLEAR_BIT(bits, j);
|
CLEAR_BIT(bits, j);
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
CLEAR_BIT(bits, j+1);
|
CLEAR_BIT(bits, j + 1);
|
||||||
if(size == BITS_32) {
|
if (size == BITS_32) {
|
||||||
CLEAR_BIT(bits, j+2);
|
CLEAR_BIT(bits, j + 2);
|
||||||
CLEAR_BIT(bits, j+3);
|
CLEAR_BIT(bits, j + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,34 +278,33 @@ void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int cheatSearchGetCount(const CheatSearchData *cs, int size)
|
int cheatSearchGetCount(const CheatSearchData* cs, int size)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int inc = 1;
|
int inc = 1;
|
||||||
if(size == BITS_16)
|
if (size == BITS_16)
|
||||||
inc = 2;
|
inc = 2;
|
||||||
else if(size == BITS_32)
|
else if (size == BITS_32)
|
||||||
inc = 4;
|
inc = 4;
|
||||||
|
|
||||||
for(int i = 0; i < cs->count; i++) {
|
for (int i = 0; i < cs->count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
|
|
||||||
int size2 = block->size;
|
int size2 = block->size;
|
||||||
u8 *bits = block->bits;
|
u8* bits = block->bits;
|
||||||
for(int j = 0; j < size2; j += inc) {
|
for (int j = 0; j < size2; j += inc) {
|
||||||
if(IS_BIT_SET(bits, j))
|
if (IS_BIT_SET(bits, j))
|
||||||
res++;
|
res++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cheatSearchUpdateValues(const CheatSearchData *cs)
|
void cheatSearchUpdateValues(const CheatSearchData* cs)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < cs->count; i++) {
|
for (int i = 0; i < cs->count; i++) {
|
||||||
CheatSearchBlock *block = &cs->blocks[i];
|
CheatSearchBlock* block = &cs->blocks[i];
|
||||||
|
|
||||||
memcpy(block->saved, block->data, block->size);
|
memcpy(block->saved, block->data, block->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,26 @@
|
||||||
struct CheatSearchBlock {
|
struct CheatSearchBlock {
|
||||||
int size;
|
int size;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
u8 *bits;
|
u8* bits;
|
||||||
u8 *data;
|
u8* data;
|
||||||
u8 *saved;
|
u8* saved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CheatSearchData {
|
struct CheatSearchData {
|
||||||
int count;
|
int count;
|
||||||
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))
|
||||||
|
|
||||||
|
@ -28,13 +35,13 @@ enum { BITS_8, BITS_16, BITS_32 };
|
||||||
|
|
||||||
extern CheatSearchData cheatSearchData;
|
extern CheatSearchData cheatSearchData;
|
||||||
|
|
||||||
void cheatSearchCleanup(CheatSearchData *cs);
|
void cheatSearchCleanup(CheatSearchData* cs);
|
||||||
void cheatSearchStart(const CheatSearchData *cs);
|
void cheatSearchStart(const CheatSearchData* cs);
|
||||||
void cheatSearch(const CheatSearchData *cs, int compare, int size, bool isSigned);
|
void cheatSearch(const CheatSearchData* cs, int compare, int size, bool isSigned);
|
||||||
void cheatSearchValue(const CheatSearchData *cs, int compare, int size, bool isSigned, u32 value);
|
void cheatSearchValue(const CheatSearchData* cs, int compare, int size, bool isSigned, u32 value);
|
||||||
int cheatSearchGetCount(const CheatSearchData *cs, int size);
|
int cheatSearchGetCount(const CheatSearchData* cs, int size);
|
||||||
void cheatSearchUpdateValues(const CheatSearchData *cs);
|
void cheatSearchUpdateValues(const CheatSearchData* cs);
|
||||||
s32 cheatSearchSignedRead(u8 *data, int off, int size);
|
s32 cheatSearchSignedRead(u8* data, int off, int size);
|
||||||
u32 cheatSearchRead(u8 *data, int off, int size);
|
u32 cheatSearchRead(u8* data, int off, int size);
|
||||||
|
|
||||||
#endif // CHEATSEARCH_H
|
#endif // CHEATSEARCH_H
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,12 +16,12 @@ struct CheatsData {
|
||||||
char desc[32];
|
char desc[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
void cheatsAdd(const char *codeStr, const char *desc, u32 rawaddress, u32 address, u32 value,
|
void cheatsAdd(const char* codeStr, const char* desc, u32 rawaddress, u32 address, u32 value,
|
||||||
int code, int size);
|
int code, int size);
|
||||||
void cheatsAddCheatCode(const char *code, const char *desc);
|
void cheatsAddCheatCode(const char* code, const char* desc);
|
||||||
void cheatsAddGSACode(const char *code, const char *desc, bool v3);
|
void cheatsAddGSACode(const char* code, const char* desc, bool v3);
|
||||||
void cheatsAddCBACode(const char *code, const char *desc);
|
void cheatsAddCBACode(const char* code, const char* desc);
|
||||||
bool cheatsImportGSACodeFile(const char *name, int game, bool v3);
|
bool cheatsImportGSACodeFile(const char* name, int game, bool v3);
|
||||||
void cheatsDelete(int number, bool restore);
|
void cheatsDelete(int number, bool restore);
|
||||||
void cheatsDeleteAll(bool restore);
|
void cheatsDeleteAll(bool restore);
|
||||||
void cheatsEnable(int number);
|
void cheatsEnable(int number);
|
||||||
|
@ -30,8 +30,8 @@ void cheatsDisable(int number);
|
||||||
void cheatsSaveGame(gzFile file);
|
void cheatsSaveGame(gzFile file);
|
||||||
void cheatsReadGame(gzFile file, int version);
|
void cheatsReadGame(gzFile file, int version);
|
||||||
void cheatsReadGameSkip(gzFile file, int version);
|
void cheatsReadGameSkip(gzFile file, int version);
|
||||||
void cheatsSaveCheatList(const char *file);
|
void cheatsSaveCheatList(const char* file);
|
||||||
bool cheatsLoadCheatList(const char *file);
|
bool cheatsLoadCheatList(const char* file);
|
||||||
#endif
|
#endif
|
||||||
void cheatsWriteMemory(u32 address, u32 value);
|
void cheatsWriteMemory(u32 address, u32 value);
|
||||||
void cheatsWriteHalfWord(u32 address, u16 value);
|
void cheatsWriteHalfWord(u32 address, u16 value);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ int eepromAddress = 0;
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
// Workaround for broken-by-design GBA save semantics
|
// Workaround for broken-by-design GBA save semantics
|
||||||
extern u8 libretro_save_buf[0x20000 + 0x2000];
|
extern u8 libretro_save_buf[0x20000 + 0x2000];
|
||||||
u8 *eepromData = libretro_save_buf + 0x20000;
|
u8* eepromData = libretro_save_buf + 0x20000;
|
||||||
#else
|
#else
|
||||||
u8 eepromData[0x2000];
|
u8 eepromData[0x2000];
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,8 +26,8 @@ int eepromSize = 512;
|
||||||
variable_desc eepromSaveData[] = {
|
variable_desc eepromSaveData[] = {
|
||||||
{ &eepromMode, sizeof(int) },
|
{ &eepromMode, sizeof(int) },
|
||||||
{ &eepromByte, sizeof(int) },
|
{ &eepromByte, sizeof(int) },
|
||||||
{ &eepromBits , sizeof(int) },
|
{ &eepromBits, sizeof(int) },
|
||||||
{ &eepromAddress , sizeof(int) },
|
{ &eepromAddress, sizeof(int) },
|
||||||
{ &eepromInUse, sizeof(bool) },
|
{ &eepromInUse, sizeof(bool) },
|
||||||
{ &eepromData[0], 512 },
|
{ &eepromData[0], 512 },
|
||||||
{ &eepromBuffer[0], 16 },
|
{ &eepromBuffer[0], 16 },
|
||||||
|
@ -54,14 +54,14 @@ void eepromReset()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
void eepromSaveGame(uint8_t *& data)
|
void eepromSaveGame(uint8_t*& data)
|
||||||
{
|
{
|
||||||
utilWriteDataMem(data, eepromSaveData);
|
utilWriteDataMem(data, eepromSaveData);
|
||||||
utilWriteIntMem(data, eepromSize);
|
utilWriteIntMem(data, eepromSize);
|
||||||
utilWriteMem(data, eepromData, 0x2000);
|
utilWriteMem(data, eepromData, 0x2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void eepromReadGame(const uint8_t *& data, int version)
|
void eepromReadGame(const uint8_t*& data, int version)
|
||||||
{
|
{
|
||||||
utilReadDataMem(data, eepromSaveData);
|
utilReadDataMem(data, eepromSaveData);
|
||||||
if (version >= SAVE_GAME_VERSION_3) {
|
if (version >= SAVE_GAME_VERSION_3) {
|
||||||
|
@ -83,7 +83,7 @@ void eepromSaveGame(gzFile gzFile)
|
||||||
void eepromReadGame(gzFile gzFile, int version)
|
void eepromReadGame(gzFile gzFile, int version)
|
||||||
{
|
{
|
||||||
utilReadData(gzFile, eepromSaveData);
|
utilReadData(gzFile, eepromSaveData);
|
||||||
if(version >= SAVE_GAME_VERSION_3) {
|
if (version >= SAVE_GAME_VERSION_3) {
|
||||||
eepromSize = utilReadInt(gzFile);
|
eepromSize = utilReadInt(gzFile);
|
||||||
utilGzRead(gzFile, eepromData, 0x2000);
|
utilGzRead(gzFile, eepromData, 0x2000);
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,7 +96,7 @@ void eepromReadGameSkip(gzFile gzFile, int version)
|
||||||
{
|
{
|
||||||
// skip the eeprom data in a save game
|
// skip the eeprom data in a save game
|
||||||
utilReadDataSkip(gzFile, eepromSaveData);
|
utilReadDataSkip(gzFile, eepromSaveData);
|
||||||
if(version >= SAVE_GAME_VERSION_3) {
|
if (version >= SAVE_GAME_VERSION_3) {
|
||||||
utilGzSeek(gzFile, sizeof(int), SEEK_CUR);
|
utilGzSeek(gzFile, sizeof(int), SEEK_CUR);
|
||||||
utilGzSeek(gzFile, 0x2000, SEEK_CUR);
|
utilGzSeek(gzFile, 0x2000, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
@ -105,31 +105,29 @@ void eepromReadGameSkip(gzFile gzFile, int version)
|
||||||
|
|
||||||
int eepromRead(u32 /* address */)
|
int eepromRead(u32 /* address */)
|
||||||
{
|
{
|
||||||
switch(eepromMode) {
|
switch (eepromMode) {
|
||||||
case EEPROM_IDLE:
|
case EEPROM_IDLE:
|
||||||
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;
|
||||||
eepromBits = 0;
|
eepromBits = 0;
|
||||||
eepromByte = 0;
|
eepromByte = 0;
|
||||||
}
|
}
|
||||||
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));
|
||||||
data = (eepromData[address+eepromByte] & mask) ? 1 : 0;
|
data = (eepromData[address + eepromByte] & mask) ? 1 : 0;
|
||||||
eepromBits++;
|
eepromBits++;
|
||||||
if((eepromBits & 7) == 0)
|
if ((eepromBits & 7) == 0)
|
||||||
eepromByte++;
|
eepromByte++;
|
||||||
if(eepromBits == 0x40)
|
if (eepromBits == 0x40)
|
||||||
eepromMode = EEPROM_IDLE;
|
eepromMode = EEPROM_IDLE;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -141,10 +139,10 @@ int eepromRead(u32 /* address */)
|
||||||
|
|
||||||
void eepromWrite(u32 /* address */, u8 value)
|
void eepromWrite(u32 /* address */, u8 value)
|
||||||
{
|
{
|
||||||
if(cpuDmaCount == 0)
|
if (cpuDmaCount == 0)
|
||||||
return;
|
return;
|
||||||
int bit = value & 1;
|
int bit = value & 1;
|
||||||
switch(eepromMode) {
|
switch (eepromMode) {
|
||||||
case EEPROM_IDLE:
|
case EEPROM_IDLE:
|
||||||
eepromByte = 0;
|
eepromByte = 0;
|
||||||
eepromBits = 1;
|
eepromBits = 1;
|
||||||
|
@ -155,16 +153,15 @@ void eepromWrite(u32 /* address */, u8 value)
|
||||||
eepromBuffer[eepromByte] <<= 1;
|
eepromBuffer[eepromByte] <<= 1;
|
||||||
eepromBuffer[eepromByte] |= bit;
|
eepromBuffer[eepromByte] |= bit;
|
||||||
eepromBits++;
|
eepromBits++;
|
||||||
if((eepromBits & 7) == 0) {
|
if ((eepromBits & 7) == 0) {
|
||||||
eepromByte++;
|
eepromByte++;
|
||||||
}
|
}
|
||||||
if(cpuDmaCount == 0x11 || cpuDmaCount == 0x51) {
|
if (cpuDmaCount == 0x11 || cpuDmaCount == 0x51) {
|
||||||
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;
|
||||||
eepromByte = 0;
|
eepromByte = 0;
|
||||||
|
@ -176,10 +173,10 @@ void eepromWrite(u32 /* address */, u8 value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(eepromBits == 9) {
|
if (eepromBits == 9) {
|
||||||
eepromInUse = true;
|
eepromInUse = true;
|
||||||
eepromAddress = (eepromBuffer[0] & 0x3F);
|
eepromAddress = (eepromBuffer[0] & 0x3F);
|
||||||
if(!(eepromBuffer[0] & 0x40)) {
|
if (!(eepromBuffer[0] & 0x40)) {
|
||||||
eepromBuffer[0] = bit;
|
eepromBuffer[0] = bit;
|
||||||
eepromBits = 1;
|
eepromBits = 1;
|
||||||
eepromByte = 0;
|
eepromByte = 0;
|
||||||
|
@ -201,17 +198,17 @@ void eepromWrite(u32 /* address */, u8 value)
|
||||||
eepromBuffer[eepromByte] <<= 1;
|
eepromBuffer[eepromByte] <<= 1;
|
||||||
eepromBuffer[eepromByte] |= bit;
|
eepromBuffer[eepromByte] |= bit;
|
||||||
eepromBits++;
|
eepromBits++;
|
||||||
if((eepromBits & 7) == 0) {
|
if ((eepromBits & 7) == 0) {
|
||||||
eepromByte++;
|
eepromByte++;
|
||||||
}
|
}
|
||||||
if(eepromBits == 0x40) {
|
if (eepromBits == 0x40) {
|
||||||
eepromInUse = true;
|
eepromInUse = true;
|
||||||
// write data;
|
// write data;
|
||||||
for(int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
eepromData[(eepromAddress << 3) + i] = eepromBuffer[i];
|
eepromData[(eepromAddress << 3) + i] = eepromBuffer[i];
|
||||||
}
|
}
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||||
} else if(eepromBits == 0x41) {
|
} else if (eepromBits == 0x41) {
|
||||||
eepromMode = EEPROM_IDLE;
|
eepromMode = EEPROM_IDLE;
|
||||||
eepromByte = 0;
|
eepromByte = 0;
|
||||||
eepromBits = 0;
|
eepromBits = 0;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define EEPROM_H
|
#define EEPROM_H
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
extern void eepromSaveGame(u8 *&data);
|
extern void eepromSaveGame(u8*& data);
|
||||||
extern void eepromReadGame(const u8 *&data, int version);
|
extern void eepromReadGame(const u8*& data, int version);
|
||||||
#else
|
#else
|
||||||
extern void eepromSaveGame(gzFile _gzFile);
|
extern void eepromSaveGame(gzFile _gzFile);
|
||||||
extern void eepromReadGame(gzFile _gzFile, int version);
|
extern void eepromReadGame(gzFile _gzFile, int version);
|
||||||
|
@ -14,7 +14,7 @@ extern void eepromWrite(u32 address, u8 value);
|
||||||
extern void eepromInit();
|
extern void eepromInit();
|
||||||
extern void eepromReset();
|
extern void eepromReset();
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
extern u8 *eepromData;
|
extern u8* eepromData;
|
||||||
#else
|
#else
|
||||||
extern u8 eepromData[0x2000];
|
extern u8 eepromData[0x2000];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
extern uint8_t libretro_save_buf[0x20000 + 0x2000];
|
extern uint8_t libretro_save_buf[0x20000 + 0x2000];
|
||||||
uint8_t *flashSaveMemory = libretro_save_buf;
|
uint8_t* flashSaveMemory = libretro_save_buf;
|
||||||
#else
|
#else
|
||||||
uint8_t flashSaveMemory[FLASH_128K_SZ];
|
uint8_t flashSaveMemory[FLASH_128K_SZ];
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,12 +73,12 @@ void flashReset()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
void flashSaveGame(uint8_t *& data)
|
void flashSaveGame(uint8_t*& data)
|
||||||
{
|
{
|
||||||
utilWriteDataMem(data, flashSaveData3);
|
utilWriteDataMem(data, flashSaveData3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void flashReadGame(const uint8_t *& data, int)
|
void flashReadGame(const uint8_t*& data, int)
|
||||||
{
|
{
|
||||||
utilReadDataMem(data, flashSaveData3);
|
utilReadDataMem(data, flashSaveData3);
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,9 @@ void flashSaveGame(gzFile gzFile)
|
||||||
|
|
||||||
void flashReadGame(gzFile gzFile, int version)
|
void flashReadGame(gzFile gzFile, int version)
|
||||||
{
|
{
|
||||||
if(version < SAVE_GAME_VERSION_5)
|
if (version < SAVE_GAME_VERSION_5)
|
||||||
utilReadData(gzFile, flashSaveData);
|
utilReadData(gzFile, flashSaveData);
|
||||||
else if(version < SAVE_GAME_VERSION_7) {
|
else if (version < SAVE_GAME_VERSION_7) {
|
||||||
utilReadData(gzFile, flashSaveData2);
|
utilReadData(gzFile, flashSaveData2);
|
||||||
flashBank = 0;
|
flashBank = 0;
|
||||||
flashSetSize(flashSize);
|
flashSetSize(flashSize);
|
||||||
|
@ -104,9 +104,9 @@ void flashReadGame(gzFile gzFile, int version)
|
||||||
void flashReadGameSkip(gzFile gzFile, int version)
|
void flashReadGameSkip(gzFile gzFile, int version)
|
||||||
{
|
{
|
||||||
// skip the flash data in a save game
|
// skip the flash data in a save game
|
||||||
if(version < SAVE_GAME_VERSION_5)
|
if (version < SAVE_GAME_VERSION_5)
|
||||||
utilReadDataSkip(gzFile, flashSaveData);
|
utilReadDataSkip(gzFile, flashSaveData);
|
||||||
else if(version < SAVE_GAME_VERSION_7) {
|
else if (version < SAVE_GAME_VERSION_7) {
|
||||||
utilReadDataSkip(gzFile, flashSaveData2);
|
utilReadDataSkip(gzFile, flashSaveData2);
|
||||||
} else {
|
} else {
|
||||||
utilReadDataSkip(gzFile, flashSaveData3);
|
utilReadDataSkip(gzFile, flashSaveData3);
|
||||||
|
@ -114,11 +114,10 @@ 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);
|
||||||
if(size == 0x10000) {
|
if (size == 0x10000) {
|
||||||
flashDeviceID = 0x1b;
|
flashDeviceID = 0x1b;
|
||||||
flashManufacturerID = 0x32;
|
flashManufacturerID = 0x32;
|
||||||
} else {
|
} else {
|
||||||
|
@ -128,7 +127,7 @@ void flashSetSize(int size)
|
||||||
// Added to make 64k saves compatible with 128k ones
|
// Added to make 64k saves compatible with 128k ones
|
||||||
// (allow wrongfuly set 64k saves to work for Pokemon games)
|
// (allow wrongfuly set 64k saves to work for Pokemon games)
|
||||||
if ((size == 0x20000) && (flashSize == 0x10000))
|
if ((size == 0x20000) && (flashSize == 0x10000))
|
||||||
memcpy((u8 *)(flashSaveMemory+0x10000), (u8 *)(flashSaveMemory), 0x10000);
|
memcpy((u8*)(flashSaveMemory + 0x10000), (u8*)(flashSaveMemory), 0x10000);
|
||||||
flashSize = size;
|
flashSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,11 +137,11 @@ u8 flashRead(u32 address)
|
||||||
// log("Current read state is %d\n", flashReadState);
|
// log("Current read state is %d\n", flashReadState);
|
||||||
address &= 0xFFFF;
|
address &= 0xFFFF;
|
||||||
|
|
||||||
switch(flashReadState) {
|
switch (flashReadState) {
|
||||||
case FLASH_READ_ARRAY:
|
case FLASH_READ_ARRAY:
|
||||||
return flashSaveMemory[(flashBank << 16) + address];
|
return flashSaveMemory[(flashBank << 16) + address];
|
||||||
case FLASH_AUTOSELECT:
|
case FLASH_AUTOSELECT:
|
||||||
switch(address & 0xFF) {
|
switch (address & 0xFF) {
|
||||||
case 0:
|
case 0:
|
||||||
// manufacturer ID
|
// manufacturer ID
|
||||||
return flashManufacturerID;
|
return flashManufacturerID;
|
||||||
|
@ -165,7 +164,7 @@ void flashSaveDecide(u32 address, u8 byte)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// log("Deciding save type %08x\n", address);
|
// log("Deciding save type %08x\n", address);
|
||||||
if(address == 0x0e005555) {
|
if (address == 0x0e005555) {
|
||||||
saveType = 3;
|
saveType = 3;
|
||||||
cpuSaveGameFunc = flashWrite;
|
cpuSaveGameFunc = flashWrite;
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,30 +187,30 @@ void flashWrite(u32 address, u8 byte)
|
||||||
// log("Writing %02x at %08x\n", byte, address);
|
// log("Writing %02x at %08x\n", byte, address);
|
||||||
// log("Current state is %d\n", flashState);
|
// log("Current state is %d\n", flashState);
|
||||||
address &= 0xFFFF;
|
address &= 0xFFFF;
|
||||||
switch(flashState) {
|
switch (flashState) {
|
||||||
case FLASH_READ_ARRAY:
|
case FLASH_READ_ARRAY:
|
||||||
if(address == 0x5555 && byte == 0xAA)
|
if (address == 0x5555 && byte == 0xAA)
|
||||||
flashState = FLASH_CMD_1;
|
flashState = FLASH_CMD_1;
|
||||||
break;
|
break;
|
||||||
case FLASH_CMD_1:
|
case FLASH_CMD_1:
|
||||||
if(address == 0x2AAA && byte == 0x55)
|
if (address == 0x2AAA && byte == 0x55)
|
||||||
flashState = FLASH_CMD_2;
|
flashState = FLASH_CMD_2;
|
||||||
else
|
else
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
break;
|
break;
|
||||||
case FLASH_CMD_2:
|
case FLASH_CMD_2:
|
||||||
if(address == 0x5555) {
|
if (address == 0x5555) {
|
||||||
if(byte == 0x90) {
|
if (byte == 0x90) {
|
||||||
flashState = FLASH_AUTOSELECT;
|
flashState = FLASH_AUTOSELECT;
|
||||||
flashReadState = FLASH_AUTOSELECT;
|
flashReadState = FLASH_AUTOSELECT;
|
||||||
} else if(byte == 0x80) {
|
} else if (byte == 0x80) {
|
||||||
flashState = FLASH_CMD_3;
|
flashState = FLASH_CMD_3;
|
||||||
} else if(byte == 0xF0) {
|
} else if (byte == 0xF0) {
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
flashReadState = FLASH_READ_ARRAY;
|
flashReadState = FLASH_READ_ARRAY;
|
||||||
} else if(byte == 0xA0) {
|
} else if (byte == 0xA0) {
|
||||||
flashState = FLASH_PROGRAM;
|
flashState = FLASH_PROGRAM;
|
||||||
} else if(byte == 0xB0 && flashSize == 0x20000) {
|
} else if (byte == 0xB0 && flashSize == 0x20000) {
|
||||||
flashState = FLASH_SETBANK;
|
flashState = FLASH_SETBANK;
|
||||||
} else {
|
} else {
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
|
@ -223,7 +222,7 @@ void flashWrite(u32 address, u8 byte)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FLASH_CMD_3:
|
case FLASH_CMD_3:
|
||||||
if(address == 0x5555 && byte == 0xAA) {
|
if (address == 0x5555 && byte == 0xAA) {
|
||||||
flashState = FLASH_CMD_4;
|
flashState = FLASH_CMD_4;
|
||||||
} else {
|
} else {
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
|
@ -231,7 +230,7 @@ void flashWrite(u32 address, u8 byte)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FLASH_CMD_4:
|
case FLASH_CMD_4:
|
||||||
if(address == 0x2AAA && byte == 0x55) {
|
if (address == 0x2AAA && byte == 0x55) {
|
||||||
flashState = FLASH_CMD_5;
|
flashState = FLASH_CMD_5;
|
||||||
} else {
|
} else {
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
|
@ -239,14 +238,14 @@ void flashWrite(u32 address, u8 byte)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FLASH_CMD_5:
|
case FLASH_CMD_5:
|
||||||
if(byte == 0x30) {
|
if (byte == 0x30) {
|
||||||
// SECTOR ERASE
|
// SECTOR ERASE
|
||||||
memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)],
|
memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)],
|
||||||
0,
|
0,
|
||||||
0x1000);
|
0x1000);
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||||
flashReadState = FLASH_ERASE_COMPLETE;
|
flashReadState = FLASH_ERASE_COMPLETE;
|
||||||
} else if(byte == 0x10) {
|
} else if (byte == 0x10) {
|
||||||
// CHIP ERASE
|
// CHIP ERASE
|
||||||
memset(flashSaveMemory, 0, flashSize);
|
memset(flashSaveMemory, 0, flashSize);
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||||
|
@ -257,10 +256,10 @@ void flashWrite(u32 address, u8 byte)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FLASH_AUTOSELECT:
|
case FLASH_AUTOSELECT:
|
||||||
if(byte == 0xF0) {
|
if (byte == 0xF0) {
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
flashReadState = FLASH_READ_ARRAY;
|
flashReadState = FLASH_READ_ARRAY;
|
||||||
} else if(address == 0x5555 && byte == 0xAA)
|
} else if (address == 0x5555 && byte == 0xAA)
|
||||||
flashState = FLASH_CMD_1;
|
flashState = FLASH_CMD_1;
|
||||||
else {
|
else {
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
|
@ -268,13 +267,13 @@ void flashWrite(u32 address, u8 byte)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FLASH_PROGRAM:
|
case FLASH_PROGRAM:
|
||||||
flashSaveMemory[(flashBank<<16)+address] = byte;
|
flashSaveMemory[(flashBank << 16) + address] = byte;
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
flashReadState = FLASH_READ_ARRAY;
|
flashReadState = FLASH_READ_ARRAY;
|
||||||
break;
|
break;
|
||||||
case FLASH_SETBANK:
|
case FLASH_SETBANK:
|
||||||
if(address == 0) {
|
if (address == 0) {
|
||||||
flashBank = (byte & 1);
|
flashBank = (byte & 1);
|
||||||
}
|
}
|
||||||
flashState = FLASH_READ_ARRAY;
|
flashState = FLASH_READ_ARRAY;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#define FLASH_128K_SZ 0x20000
|
#define FLASH_128K_SZ 0x20000
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
extern void flashSaveGame(u8 *&data);
|
extern void flashSaveGame(u8*& data);
|
||||||
extern void flashReadGame(const u8 *&data, int);
|
extern void flashReadGame(const u8*& data, int);
|
||||||
#else
|
#else
|
||||||
extern void flashSaveGame(gzFile _gzFile);
|
extern void flashSaveGame(gzFile _gzFile);
|
||||||
extern void flashReadGame(gzFile _gzFile, int version);
|
extern void flashReadGame(gzFile _gzFile, int version);
|
||||||
|
@ -15,7 +15,7 @@ extern u8 flashRead(u32 address);
|
||||||
extern void flashWrite(u32 address, u8 byte);
|
extern void flashWrite(u32 address, u8 byte);
|
||||||
extern void flashDelayedWrite(u32 address, u8 byte);
|
extern void flashDelayedWrite(u32 address, u8 byte);
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
extern uint8_t *flashSaveMemory;
|
extern uint8_t* flashSaveMemory;
|
||||||
#else
|
#else
|
||||||
extern u8 flashSaveMemory[FLASH_128K_SZ];
|
extern u8 flashSaveMemory[FLASH_128K_SZ];
|
||||||
#endif
|
#endif
|
||||||
|
|
1148
src/gba/GBA-arm.cpp
1148
src/gba/GBA-arm.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2184
src/gba/GBA.cpp
2184
src/gba/GBA.cpp
File diff suppressed because it is too large
Load Diff
|
@ -18,12 +18,12 @@ const u64 TICKS_PER_SECOND = 16777216;
|
||||||
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10
|
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 *address;
|
u8* address;
|
||||||
u32 mask;
|
u32 mask;
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
u8 *breakPoints;
|
u8* breakPoints;
|
||||||
u8 *searchMatch;
|
u8* searchMatch;
|
||||||
u8 *trace;
|
u8* trace;
|
||||||
u32 size;
|
u32 size;
|
||||||
#endif
|
#endif
|
||||||
} memoryMap;
|
} memoryMap;
|
||||||
|
@ -78,49 +78,49 @@ extern char oldbuffer[10];
|
||||||
extern bool debugger;
|
extern bool debugger;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool CPUReadGSASnapshot(const char *);
|
extern bool CPUReadGSASnapshot(const char*);
|
||||||
extern bool CPUReadGSASPSnapshot(const char *);
|
extern bool CPUReadGSASPSnapshot(const char*);
|
||||||
extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *);
|
extern bool CPUWriteGSASnapshot(const char*, const char*, const char*, const char*);
|
||||||
extern bool CPUWriteBatteryFile(const char *);
|
extern bool CPUWriteBatteryFile(const char*);
|
||||||
extern bool CPUReadBatteryFile(const char *);
|
extern bool CPUReadBatteryFile(const char*);
|
||||||
extern bool CPUExportEepromFile(const char *);
|
extern bool CPUExportEepromFile(const char*);
|
||||||
extern bool CPUImportEepromFile(const char *);
|
extern bool CPUImportEepromFile(const char*);
|
||||||
extern bool CPUWritePNGFile(const char *);
|
extern bool CPUWritePNGFile(const char*);
|
||||||
extern bool CPUWriteBMPFile(const char *);
|
extern bool CPUWriteBMPFile(const char*);
|
||||||
extern void CPUCleanUp();
|
extern void CPUCleanUp();
|
||||||
extern void CPUUpdateRender();
|
extern void CPUUpdateRender();
|
||||||
extern void CPUUpdateRenderBuffers(bool);
|
extern void CPUUpdateRenderBuffers(bool);
|
||||||
extern bool CPUReadMemState(char *, int);
|
extern bool CPUReadMemState(char*, int);
|
||||||
extern bool CPUWriteMemState(char *, int);
|
extern bool CPUWriteMemState(char*, int);
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
extern bool CPUReadState(const u8 *, unsigned);
|
extern bool CPUReadState(const u8*, unsigned);
|
||||||
extern unsigned int CPUWriteState(u8 *data, unsigned int size);
|
extern unsigned int CPUWriteState(u8* data, unsigned int size);
|
||||||
#else
|
#else
|
||||||
extern bool CPUReadState(const char *);
|
extern bool CPUReadState(const char*);
|
||||||
extern bool CPUWriteState(const char *);
|
extern bool CPUWriteState(const char*);
|
||||||
#endif
|
#endif
|
||||||
extern int CPULoadRom(const char *);
|
extern int CPULoadRom(const char*);
|
||||||
extern int CPULoadRomData(const char *data, int size);
|
extern int CPULoadRomData(const char* data, int size);
|
||||||
extern void doMirroring(bool);
|
extern void doMirroring(bool);
|
||||||
extern void CPUUpdateRegister(u32, u16);
|
extern void CPUUpdateRegister(u32, u16);
|
||||||
extern void applyTimer();
|
extern void applyTimer();
|
||||||
extern void CPUInit(const char *, bool);
|
extern void CPUInit(const char*, bool);
|
||||||
void SetSaveType(int st);
|
void SetSaveType(int st);
|
||||||
extern void CPUReset();
|
extern void CPUReset();
|
||||||
extern void CPULoop(int);
|
extern void CPULoop(int);
|
||||||
extern void CPUCheckDMA(int, int);
|
extern void CPUCheckDMA(int, int);
|
||||||
extern bool CPUIsGBAImage(const char *);
|
extern bool CPUIsGBAImage(const char*);
|
||||||
extern bool CPUIsZipFile(const char *);
|
extern bool CPUIsZipFile(const char*);
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
#include "prof/prof.h"
|
#include "prof/prof.h"
|
||||||
extern void cpuProfil(profile_segment *seg);
|
extern void cpuProfil(profile_segment* seg);
|
||||||
extern void cpuEnableProfiling(int hz);
|
extern void cpuEnableProfiling(int hz);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *GetLoadDotCodeFile();
|
const char* GetLoadDotCodeFile();
|
||||||
const char *GetSaveDotCodeFile();
|
const char* GetSaveDotCodeFile();
|
||||||
void SetLoadDotCodeFile(const char *szFile);
|
void SetLoadDotCodeFile(const char* szFile);
|
||||||
void SetSaveDotCodeFile(const char *szFile);
|
void SetSaveDotCodeFile(const char* szFile);
|
||||||
|
|
||||||
extern struct EmulatedSystem GBASystem;
|
extern struct EmulatedSystem GBASystem;
|
||||||
|
|
||||||
|
|
|
@ -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];
|
||||||
|
|
603
src/gba/GBAGfx.h
603
src/gba/GBAGfx.h
|
@ -9,21 +9,21 @@
|
||||||
//#define SPRITE_DEBUG
|
//#define SPRITE_DEBUG
|
||||||
|
|
||||||
#ifdef TILED_RENDERING
|
#ifdef TILED_RENDERING
|
||||||
extern void gfxDrawTextScreen(u16, u16, u16, u32 *);
|
extern void gfxDrawTextScreen(u16, u16, u16, u32*);
|
||||||
#else
|
#else
|
||||||
static void gfxDrawTextScreen(u16, u16, u16, u32 *);
|
static void gfxDrawTextScreen(u16, u16, u16, u32*);
|
||||||
#endif
|
#endif
|
||||||
static void gfxDrawRotScreen(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int, u32 *);
|
static void gfxDrawRotScreen(u16, u16, u16, u16, u16, u16, u16, u16, u16, int&, int&, int, u32*);
|
||||||
static void gfxDrawRotScreen16Bit(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int,
|
static void gfxDrawRotScreen16Bit(u16, u16, u16, u16, u16, u16, u16, u16, u16, int&, int&, int,
|
||||||
u32 *);
|
u32*);
|
||||||
static void gfxDrawRotScreen256(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int,
|
static void gfxDrawRotScreen256(u16, u16, u16, u16, u16, u16, u16, u16, u16, int&, int&, int,
|
||||||
u32 *);
|
u32*);
|
||||||
static void gfxDrawRotScreen16Bit160(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int,
|
static void gfxDrawRotScreen16Bit160(u16, u16, u16, u16, u16, u16, u16, u16, u16, int&, int&, int,
|
||||||
u32 *);
|
u32*);
|
||||||
static void gfxDrawSprites(u32 *);
|
static void gfxDrawSprites(u32*);
|
||||||
static void gfxIncreaseBrightness(u32 *line, int coeff);
|
static void gfxIncreaseBrightness(u32* line, int coeff);
|
||||||
static void gfxDecreaseBrightness(u32 *line, int coeff);
|
static void gfxDecreaseBrightness(u32* line, int coeff);
|
||||||
static void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb);
|
static void gfxAlphaBlend(u32* ta, u32* tb, int ca, int cb);
|
||||||
|
|
||||||
void mode0RenderLine();
|
void mode0RenderLine();
|
||||||
void mode0RenderLineNoWindow();
|
void mode0RenderLineNoWindow();
|
||||||
|
@ -70,7 +70,7 @@ extern int gfxBG3X;
|
||||||
extern int gfxBG3Y;
|
extern int gfxBG3Y;
|
||||||
extern int gfxLastVCOUNT;
|
extern int gfxLastVCOUNT;
|
||||||
|
|
||||||
static inline void gfxClearArray(u32 *array)
|
static inline void gfxClearArray(u32* array)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 240; i++) {
|
for (int i = 0; i < 240; i++) {
|
||||||
*array++ = 0x80000000;
|
*array++ = 0x80000000;
|
||||||
|
@ -78,11 +78,11 @@ static inline void gfxClearArray(u32 *array)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TILED_RENDERING
|
#ifndef TILED_RENDERING
|
||||||
static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line)
|
static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32* line)
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];
|
u8* charBase = &vram[((control >> 2) & 0x03) * 0x4000];
|
||||||
u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800];
|
u16* screenBase = (u16*)&vram[((control >> 8) & 0x1f) * 0x800];
|
||||||
u32 prio = ((control & 3) << 25) + 0x1000000;
|
u32 prio = ((control & 3) << 25) + 0x1000000;
|
||||||
int sizeX = 256;
|
int sizeX = 256;
|
||||||
int sizeY = 256;
|
int sizeY = 256;
|
||||||
|
@ -127,7 +127,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line)
|
||||||
|
|
||||||
int yshift = ((yyy >> 3) << 5);
|
int yshift = ((yyy >> 3) << 5);
|
||||||
if ((control)&0x80) {
|
if ((control)&0x80) {
|
||||||
u16 *screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift;
|
u16* screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift;
|
||||||
for (int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u16 data = READ16LE(screenSource);
|
u16 data = READ16LE(screenSource);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
u16 *screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift;
|
u16* screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift;
|
||||||
for (int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u16 data = READ16LE(screenSource);
|
u16 data = READ16LE(screenSource);
|
||||||
|
|
||||||
|
@ -219,12 +219,12 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void gfxDrawRotScreen(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa, u16 pb,
|
static inline void gfxDrawRotScreen(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa, u16 pb,
|
||||||
u16 pc, u16 pd, int ¤tX, int ¤tY, int changed,
|
u16 pc, u16 pd, int& currentX, int& currentY, int changed,
|
||||||
u32 *line)
|
u32* line)
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];
|
u8* charBase = &vram[((control >> 2) & 0x03) * 0x4000];
|
||||||
u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800];
|
u8* screenBase = (u8*)&vram[((control >> 8) & 0x1f) * 0x800];
|
||||||
int prio = ((control & 3) << 25) + 0x1000000;
|
int prio = ((control & 3) << 25) + 0x1000000;
|
||||||
|
|
||||||
int sizeX = 128;
|
int sizeX = 128;
|
||||||
|
@ -346,10 +346,10 @@ static inline void gfxDrawRotScreen(u16 control, u16 x_l, u16 x_h, u16 y_l, u16
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxDrawRotScreen16Bit(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa,
|
static inline void gfxDrawRotScreen16Bit(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa,
|
||||||
u16 pb, u16 pc, u16 pd, int ¤tX, int ¤tY,
|
u16 pb, u16 pc, u16 pd, int& currentX, int& currentY,
|
||||||
int changed, u32 *line)
|
int changed, u32* line)
|
||||||
{
|
{
|
||||||
u16 *screenBase = (u16 *)&vram[0];
|
u16* screenBase = (u16*)&vram[0];
|
||||||
int prio = ((control & 3) << 25) + 0x1000000;
|
int prio = ((control & 3) << 25) + 0x1000000;
|
||||||
int sizeX = 240;
|
int sizeX = 240;
|
||||||
int sizeY = 160;
|
int sizeY = 160;
|
||||||
|
@ -435,11 +435,11 @@ static inline void gfxDrawRotScreen16Bit(u16 control, u16 x_l, u16 x_h, u16 y_l,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxDrawRotScreen256(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa,
|
static inline void gfxDrawRotScreen256(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa,
|
||||||
u16 pb, u16 pc, u16 pd, int ¤tX, int ¤tY,
|
u16 pb, u16 pc, u16 pd, int& currentX, int& currentY,
|
||||||
int changed, u32 *line)
|
int changed, u32* line)
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
u8 *screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000];
|
u8* screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000];
|
||||||
int prio = ((control & 3) << 25) + 0x1000000;
|
int prio = ((control & 3) << 25) + 0x1000000;
|
||||||
int sizeX = 240;
|
int sizeX = 240;
|
||||||
int sizeY = 160;
|
int sizeY = 160;
|
||||||
|
@ -528,10 +528,10 @@ static inline void gfxDrawRotScreen256(u16 control, u16 x_l, u16 x_h, u16 y_l, u
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxDrawRotScreen16Bit160(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa,
|
static inline void gfxDrawRotScreen16Bit160(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa,
|
||||||
u16 pb, u16 pc, u16 pd, int ¤tX, int ¤tY,
|
u16 pb, u16 pc, u16 pd, int& currentX, int& currentY,
|
||||||
int changed, u32 *line)
|
int changed, u32* line)
|
||||||
{
|
{
|
||||||
u16 *screenBase = (DISPCNT & 0x0010) ? (u16 *)&vram[0xa000] : (u16 *)&vram[0];
|
u16* screenBase = (DISPCNT & 0x0010) ? (u16*)&vram[0xa000] : (u16*)&vram[0];
|
||||||
int prio = ((control & 3) << 25) + 0x1000000;
|
int prio = ((control & 3) << 25) + 0x1000000;
|
||||||
int sizeX = 160;
|
int sizeX = 160;
|
||||||
int sizeY = 128;
|
int sizeY = 128;
|
||||||
|
@ -617,7 +617,7 @@ static inline void gfxDrawRotScreen16Bit160(u16 control, u16 x_l, u16 x_h, u16 y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxDrawSprites(u32 *lineOBJ)
|
static inline void gfxDrawSprites(u32* lineOBJ)
|
||||||
{
|
{
|
||||||
// lineOBJpix is used to keep track of the drawn OBJs
|
// lineOBJpix is used to keep track of the drawn OBJs
|
||||||
// and to stop drawing them if the 'maximum number of OBJ per line'
|
// and to stop drawing them if the 'maximum number of OBJ per line'
|
||||||
|
@ -626,8 +626,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
int m = 0;
|
int m = 0;
|
||||||
gfxClearArray(lineOBJ);
|
gfxClearArray(lineOBJ);
|
||||||
if (layerEnable & 0x1000) {
|
if (layerEnable & 0x1000) {
|
||||||
u16 *sprites = (u16 *)oam;
|
u16* sprites = (u16*)oam;
|
||||||
u16 *spritePalette = &((u16 *)paletteRAM)[256];
|
u16* spritePalette = &((u16*)paletteRAM)[256];
|
||||||
int mosaicY = ((MOSAIC & 0xF000) >> 12) + 1;
|
int mosaicY = ((MOSAIC & 0xF000) >> 12) + 1;
|
||||||
int mosaicX = ((MOSAIC & 0xF00) >> 8) + 1;
|
int mosaicX = ((MOSAIC & 0xF00) >> 8) + 1;
|
||||||
for (int x = 0; x < 128; x++) {
|
for (int x = 0; x < 128; x++) {
|
||||||
|
@ -723,7 +723,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
lineOBJpix -= 8;
|
lineOBJpix -= 8;
|
||||||
// int t2 = t - (fieldY >> 1);
|
// int t2 = t - (fieldY >> 1);
|
||||||
int rot = (a1 >> 9) & 0x1F;
|
int rot = (a1 >> 9) & 0x1F;
|
||||||
u16 *OAM = (u16 *)oam;
|
u16* OAM = (u16*)oam;
|
||||||
int dx = READ16LE(&OAM[3 + (rot << 4)]);
|
int dx = READ16LE(&OAM[3 + (rot << 4)]);
|
||||||
if (dx & 0x8000)
|
if (dx & 0x8000)
|
||||||
dx |= 0xFFFF8000;
|
dx |= 0xFFFF8000;
|
||||||
|
@ -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++;
|
||||||
|
@ -1278,11 +1139,11 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
static inline void gfxDrawOBJWin(u32* lineOBJWin)
|
||||||
{
|
{
|
||||||
gfxClearArray(lineOBJWin);
|
gfxClearArray(lineOBJWin);
|
||||||
if ((layerEnable & 0x9000) == 0x9000) {
|
if ((layerEnable & 0x9000) == 0x9000) {
|
||||||
u16 *sprites = (u16 *)oam;
|
u16* sprites = (u16*)oam;
|
||||||
// u16 *spritePalette = &((u16 *)paletteRAM)[256];
|
// u16 *spritePalette = &((u16 *)paletteRAM)[256];
|
||||||
for (int x = 0; x < 128; x++) {
|
for (int x = 0; x < 128; x++) {
|
||||||
int lineOBJpix = lineOBJpixleft[x];
|
int lineOBJpix = lineOBJpixleft[x];
|
||||||
|
@ -1343,7 +1204,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
||||||
lineOBJpix -= 8;
|
lineOBJpix -= 8;
|
||||||
// int t2 = t - (fieldY >> 1);
|
// int t2 = t - (fieldY >> 1);
|
||||||
int rot = (a1 >> 9) & 0x1F;
|
int rot = (a1 >> 9) & 0x1F;
|
||||||
u16 *OAM = (u16 *)oam;
|
u16* OAM = (u16*)oam;
|
||||||
int dx = READ16LE(&OAM[3 + (rot << 4)]);
|
int dx = READ16LE(&OAM[3 + (rot << 4)]);
|
||||||
if (dx & 0x8000)
|
if (dx & 0x8000)
|
||||||
dx |= 0xFFFF8000;
|
dx |= 0xFFFF8000;
|
||||||
|
@ -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;
|
||||||
|
@ -1641,7 +1470,7 @@ static inline u32 gfxIncreaseBrightness(u32 color, int coeff)
|
||||||
return (color >> 16) | color;
|
return (color >> 16) | color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxIncreaseBrightness(u32 *line, int coeff)
|
static inline void gfxIncreaseBrightness(u32* line, int coeff)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = *line;
|
u32 color = *line;
|
||||||
|
@ -1672,7 +1501,7 @@ static inline u32 gfxDecreaseBrightness(u32 color, int coeff)
|
||||||
return (color >> 16) | color;
|
return (color >> 16) | color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxDecreaseBrightness(u32 *line, int coeff)
|
static inline void gfxDecreaseBrightness(u32* line, int coeff)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = *line;
|
u32 color = *line;
|
||||||
|
@ -1718,7 +1547,7 @@ static inline u32 gfxAlphaBlend(u32 color, u32 color2, int ca, int cb)
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb)
|
static inline void gfxAlphaBlend(u32* ta, u32* tb, int ca, int cb)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = *ta;
|
u32 color = *ta;
|
||||||
|
|
1206
src/gba/GBALink.cpp
1206
src/gba/GBALink.cpp
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
|
||||||
|
@ -34,7 +37,7 @@ extern ConnectionState InitLink(LinkMode mode);
|
||||||
* @param message Information message
|
* @param message Information message
|
||||||
* @param size Maximum message size
|
* @param size Maximum message size
|
||||||
*/
|
*/
|
||||||
extern ConnectionState ConnectLinkUpdate(char *const message, size_t size);
|
extern ConnectionState ConnectLinkUpdate(char* const message, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the currently enabled link mode
|
* Get the currently enabled link mode
|
||||||
|
@ -63,7 +66,7 @@ extern void EnableSpeedHacks(bool enable);
|
||||||
*
|
*
|
||||||
* @return false if the address is invalid
|
* @return false if the address is invalid
|
||||||
*/
|
*/
|
||||||
extern bool SetLinkServerHost(const char *host);
|
extern bool SetLinkServerHost(const char* host);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the host relevant to context
|
* Get the host relevant to context
|
||||||
|
@ -73,7 +76,7 @@ extern bool SetLinkServerHost(const char *host);
|
||||||
* If in gamecube mode, returns the IP adress of the dolphin host
|
* If in gamecube mode, returns the IP adress of the dolphin host
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
extern void GetLinkServerHost(char *const host, size_t size);
|
extern void GetLinkServerHost(char* const host, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value in milliseconds of the timeout after which a connection is
|
* Set the value in milliseconds of the timeout after which a connection is
|
||||||
|
@ -131,7 +134,7 @@ extern void CleanLocalLink();
|
||||||
* @return completed filename
|
* @return completed filename
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern const char *MakeInstanceFilename(const char *Input);
|
extern const char* MakeInstanceFilename(const char* Input);
|
||||||
|
|
||||||
// register definitions
|
// register definitions
|
||||||
#define COMM_SIODATA32_L 0x120 // Lower 16bit on Normal mode
|
#define COMM_SIODATA32_L 0x120 // Lower 16bit on Normal mode
|
||||||
|
@ -178,7 +181,7 @@ extern const char *MakeInstanceFilename(const char *Input);
|
||||||
|
|
||||||
#define RF_RECVCMD \
|
#define RF_RECVCMD \
|
||||||
0x278 // Unknown, Seems to be related to Wireless Adapter(RF_RCNT or armMode/CPSR or CMD
|
0x278 // Unknown, Seems to be related to Wireless Adapter(RF_RCNT or armMode/CPSR or CMD
|
||||||
// sent by the adapter when RF_SIOCNT=0x83 or when RCNT=0x80aX?)
|
// sent by the adapter when RF_SIOCNT=0x83 or when RCNT=0x80aX?)
|
||||||
#define RF_CNT 0x27a // Unknown, Seems to be related to Wireless Adapter(RF_SIOCNT?)
|
#define RF_CNT 0x27a // Unknown, Seems to be related to Wireless Adapter(RF_SIOCNT?)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -199,6 +202,6 @@ extern void gbInitLinkIPC();
|
||||||
extern u8 gbStartLinkIPC(u8 b);
|
extern u8 gbStartLinkIPC(u8 b);
|
||||||
extern u16 gbLinkUpdateIPC(u8 b, int gbSerialOn);
|
extern u16 gbLinkUpdateIPC(u8 b, int gbSerialOn);
|
||||||
|
|
||||||
extern void BootLink(int m_type, const char *host, int timeout, bool m_hacks, int m_numplayers);
|
extern void BootLink(int m_type, const char* host, int timeout, bool m_hacks, int m_numplayers);
|
||||||
|
|
||||||
#endif /* GBA_GBALINK_H */
|
#endif /* GBA_GBALINK_H */
|
||||||
|
|
|
@ -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,22 +3,21 @@
|
||||||
#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();
|
||||||
|
|
||||||
bool Connect(sf::IpAddress server_addr);
|
bool Connect(sf::IpAddress server_addr);
|
||||||
void Send(std::vector<char> data);
|
void Send(std::vector<char> data);
|
||||||
char ReceiveCmd(char *data_in, bool block);
|
char ReceiveCmd(char* data_in, bool block);
|
||||||
void ReceiveClock(bool block);
|
void ReceiveClock(bool block);
|
||||||
|
|
||||||
void ClockSync(u32 ticks);
|
void ClockSync(u32 ticks);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
bool IsDisconnected();
|
bool IsDisconnected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sf::IpAddress server_addr;
|
sf::IpAddress server_addr;
|
||||||
sf::TcpSocket client;
|
sf::TcpSocket client;
|
||||||
sf::TcpSocket clock_client;
|
sf::TcpSocket clock_client;
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern int thumbExecute();
|
||||||
|
|
||||||
#define UPDATE_REG(address, value) \
|
#define UPDATE_REG(address, value) \
|
||||||
{ \
|
{ \
|
||||||
WRITE16LE(((u16 *)&ioMem[address]), value); \
|
WRITE16LE(((u16*)&ioMem[address]), value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARM_PREFETCH \
|
#define ARM_PREFETCH \
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -39,17 +39,17 @@ extern int cpuTotalTicks;
|
||||||
#define CPUReadByteQuick(addr) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
#define CPUReadByteQuick(addr) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
||||||
|
|
||||||
#define CPUReadHalfWordQuick(addr) \
|
#define CPUReadHalfWordQuick(addr) \
|
||||||
READ16LE(((u16 *)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
READ16LE(((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||||
|
|
||||||
#define CPUReadMemoryQuick(addr) \
|
#define CPUReadMemoryQuick(addr) \
|
||||||
READ32LE(((u32 *)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
READ32LE(((u32*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||||
|
|
||||||
extern u32 myROM[];
|
extern u32 myROM[];
|
||||||
|
|
||||||
static inline u32 CPUReadMemory(u32 address)
|
static inline u32 CPUReadMemory(u32 address)
|
||||||
{
|
{
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
memoryMap *m = &map[address >> 24];
|
memoryMap* m = &map[address >> 24];
|
||||||
if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) {
|
if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) {
|
||||||
if (debuggerBreakOnRead(address, 2)) {
|
if (debuggerBreakOnRead(address, 2)) {
|
||||||
// CPU_BREAK_LOOP_2;
|
// CPU_BREAK_LOOP_2;
|
||||||
|
@ -75,33 +75,33 @@ static inline u32 CPUReadMemory(u32 address)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
value = READ32LE(((u32 *)&biosProtected));
|
value = READ32LE(((u32*)&biosProtected));
|
||||||
} else
|
} else
|
||||||
goto unreadable;
|
goto unreadable;
|
||||||
} else
|
} else
|
||||||
value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
|
value = READ32LE(((u32*)&bios[address & 0x3FFC]));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
|
value = READ32LE(((u32*)&workRAM[address & 0x3FFFC]));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
|
value = READ32LE(((u32*)&internalRAM[address & 0x7ffC]));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ((address < 0x4000400) && ioReadable[address & 0x3fc]) {
|
if ((address < 0x4000400) && ioReadable[address & 0x3fc]) {
|
||||||
if (ioReadable[(address & 0x3fc) + 2]) {
|
if (ioReadable[(address & 0x3fc) + 2]) {
|
||||||
value = READ32LE(((u32 *)&ioMem[address & 0x3fC]));
|
value = READ32LE(((u32*)&ioMem[address & 0x3fC]));
|
||||||
if ((address & 0x3fc) == COMM_JOY_RECV_L)
|
if ((address & 0x3fc) == COMM_JOY_RECV_L)
|
||||||
UPDATE_REG(COMM_JOYSTAT,
|
UPDATE_REG(COMM_JOYSTAT,
|
||||||
READ16LE(&ioMem[COMM_JOYSTAT]) & ~JOYSTAT_RECV);
|
READ16LE(&ioMem[COMM_JOYSTAT]) & ~JOYSTAT_RECV);
|
||||||
} else {
|
} else {
|
||||||
value = READ16LE(((u16 *)&ioMem[address & 0x3fc]));
|
value = READ16LE(((u16*)&ioMem[address & 0x3fc]));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
goto unreadable;
|
goto unreadable;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
|
value = READ32LE(((u32*)&paletteRAM[address & 0x3fC]));
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
address = (address & 0x1fffc);
|
address = (address & 0x1fffc);
|
||||||
|
@ -111,17 +111,17 @@ static inline u32 CPUReadMemory(u32 address)
|
||||||
}
|
}
|
||||||
if ((address & 0x18000) == 0x18000)
|
if ((address & 0x18000) == 0x18000)
|
||||||
address &= 0x17fff;
|
address &= 0x17fff;
|
||||||
value = READ32LE(((u32 *)&vram[address]));
|
value = READ32LE(((u32*)&vram[address]));
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
value = READ32LE(((u32 *)&oam[address & 0x3FC]));
|
value = READ32LE(((u32*)&oam[address & 0x3FC]));
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
case 10:
|
case 10:
|
||||||
case 11:
|
case 11:
|
||||||
case 12:
|
case 12:
|
||||||
value = READ32LE(((u32 *)&rom[address & 0x1FFFFFC]));
|
value = READ32LE(((u32*)&rom[address & 0x1FFFFFC]));
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
if (cpuEEPROMEnabled)
|
if (cpuEEPROMEnabled)
|
||||||
|
@ -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;
|
||||||
|
@ -199,7 +198,7 @@ static inline u32 CPUReadMemory(u32 address)
|
||||||
static inline u32 CPUReadHalfWord(u32 address)
|
static inline u32 CPUReadHalfWord(u32 address)
|
||||||
{
|
{
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
memoryMap *m = &map[address >> 24];
|
memoryMap* m = &map[address >> 24];
|
||||||
if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) {
|
if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) {
|
||||||
if (debuggerBreakOnRead(address, 1)) {
|
if (debuggerBreakOnRead(address, 1)) {
|
||||||
// CPU_BREAK_LOOP_2;
|
// CPU_BREAK_LOOP_2;
|
||||||
|
@ -225,34 +224,30 @@ static inline u32 CPUReadHalfWord(u32 address)
|
||||||
armMode ? armNextPC - 4 : armNextPC - 2);
|
armMode ? armNextPC - 4 : armNextPC - 2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
value = READ16LE(((u16 *)&biosProtected[address & 2]));
|
value = READ16LE(((u16*)&biosProtected[address & 2]));
|
||||||
} else
|
} else
|
||||||
goto unreadable;
|
goto unreadable;
|
||||||
} else
|
} else
|
||||||
value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
|
value = READ16LE(((u16*)&bios[address & 0x3FFE]));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
|
value = READ16LE(((u16*)&workRAM[address & 0x3FFFE]));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
|
value = READ16LE(((u16*)&internalRAM[address & 0x7ffe]));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ((address < 0x4000400) && ioReadable[address & 0x3fe]) {
|
if ((address < 0x4000400) && ioReadable[address & 0x3fe]) {
|
||||||
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;
|
||||||
|
@ -260,7 +255,7 @@ static inline u32 CPUReadHalfWord(u32 address)
|
||||||
goto unreadable;
|
goto unreadable;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
|
value = READ16LE(((u16*)&paletteRAM[address & 0x3fe]));
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
address = (address & 0x1fffe);
|
address = (address & 0x1fffe);
|
||||||
|
@ -270,10 +265,10 @@ static inline u32 CPUReadHalfWord(u32 address)
|
||||||
}
|
}
|
||||||
if ((address & 0x18000) == 0x18000)
|
if ((address & 0x18000) == 0x18000)
|
||||||
address &= 0x17fff;
|
address &= 0x17fff;
|
||||||
value = READ16LE(((u16 *)&vram[address]));
|
value = READ16LE(((u16*)&vram[address]));
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
value = READ16LE(((u16 *)&oam[address & 0x3fe]));
|
value = READ16LE(((u16*)&oam[address & 0x3fe]));
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
|
@ -283,7 +278,7 @@ static inline u32 CPUReadHalfWord(u32 address)
|
||||||
if (address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
|
if (address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
|
||||||
value = rtcRead(address);
|
value = rtcRead(address);
|
||||||
else
|
else
|
||||||
value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
|
value = READ16LE(((u16*)&rom[address & 0x1FFFFFE]));
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
if (cpuEEPROMEnabled)
|
if (cpuEEPROMEnabled)
|
||||||
|
@ -358,7 +353,7 @@ static inline s16 CPUReadHalfWordSigned(u32 address)
|
||||||
static inline u8 CPUReadByte(u32 address)
|
static inline u8 CPUReadByte(u32 address)
|
||||||
{
|
{
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
memoryMap *m = &map[address >> 24];
|
memoryMap* m = &map[address >> 24];
|
||||||
if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) {
|
if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) {
|
||||||
if (debuggerBreakOnRead(address, 0)) {
|
if (debuggerBreakOnRead(address, 0)) {
|
||||||
// CPU_BREAK_LOOP_2;
|
// CPU_BREAK_LOOP_2;
|
||||||
|
@ -463,7 +458,7 @@ static inline void CPUWriteMemory(u32 address, u32 value)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
memoryMap *m = &map[address >> 24];
|
memoryMap* m = &map[address >> 24];
|
||||||
if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) {
|
if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) {
|
||||||
if (debuggerBreakOnWrite(address, value, 1)) {
|
if (debuggerBreakOnWrite(address, value, 1)) {
|
||||||
// CPU_BREAK_LOOP_2;
|
// CPU_BREAK_LOOP_2;
|
||||||
|
@ -476,19 +471,19 @@ static inline void CPUWriteMemory(u32 address, u32 value)
|
||||||
switch (address >> 24) {
|
switch (address >> 24) {
|
||||||
case 0x02:
|
case 0x02:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
|
if (*((u32*)&freezeWorkRAM[address & 0x3FFFC]))
|
||||||
cheatsWriteMemory(address & 0x203FFFC, value);
|
cheatsWriteMemory(address & 0x203FFFC, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
|
WRITE32LE(((u32*)&workRAM[address & 0x3FFFC]), value);
|
||||||
break;
|
break;
|
||||||
case 0x03:
|
case 0x03:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
|
if (*((u32*)&freezeInternalRAM[address & 0x7ffc]))
|
||||||
cheatsWriteMemory(address & 0x3007FFC, value);
|
cheatsWriteMemory(address & 0x3007FFC, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
|
WRITE32LE(((u32*)&internalRAM[address & 0x7ffC]), value);
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
if (address < 0x4000400) {
|
if (address < 0x4000400) {
|
||||||
|
@ -499,11 +494,11 @@ static inline void CPUWriteMemory(u32 address, u32 value)
|
||||||
break;
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u32 *)&freezePRAM[address & 0x3fc]))
|
if (*((u32*)&freezePRAM[address & 0x3fc]))
|
||||||
cheatsWriteMemory(address & 0x70003FC, value);
|
cheatsWriteMemory(address & 0x70003FC, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
|
WRITE32LE(((u32*)&paletteRAM[address & 0x3FC]), value);
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
address = (address & 0x1fffc);
|
address = (address & 0x1fffc);
|
||||||
|
@ -513,20 +508,20 @@ static inline void CPUWriteMemory(u32 address, u32 value)
|
||||||
address &= 0x17fff;
|
address &= 0x17fff;
|
||||||
|
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u32 *)&freezeVRAM[address]))
|
if (*((u32*)&freezeVRAM[address]))
|
||||||
cheatsWriteMemory(address + 0x06000000, value);
|
cheatsWriteMemory(address + 0x06000000, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WRITE32LE(((u32 *)&vram[address]), value);
|
WRITE32LE(((u32*)&vram[address]), value);
|
||||||
break;
|
break;
|
||||||
case 0x07:
|
case 0x07:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u32 *)&freezeOAM[address & 0x3fc]))
|
if (*((u32*)&freezeOAM[address & 0x3fc]))
|
||||||
cheatsWriteMemory(address & 0x70003FC, value);
|
cheatsWriteMemory(address & 0x70003FC, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
|
WRITE32LE(((u32*)&oam[address & 0x3fc]), value);
|
||||||
break;
|
break;
|
||||||
case 0x0D:
|
case 0x0D:
|
||||||
if (cpuEEPROMEnabled) {
|
if (cpuEEPROMEnabled) {
|
||||||
|
@ -569,7 +564,7 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
memoryMap *m = &map[address >> 24];
|
memoryMap* m = &map[address >> 24];
|
||||||
if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) {
|
if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) {
|
||||||
if (debuggerBreakOnWrite(address, value, 1)) {
|
if (debuggerBreakOnWrite(address, value, 1)) {
|
||||||
// CPU_BREAK_LOOP_2;
|
// CPU_BREAK_LOOP_2;
|
||||||
|
@ -582,19 +577,19 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
|
||||||
switch (address >> 24) {
|
switch (address >> 24) {
|
||||||
case 2:
|
case 2:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u16 *)&freezeWorkRAM[address & 0x3FFFE]))
|
if (*((u16*)&freezeWorkRAM[address & 0x3FFFE]))
|
||||||
cheatsWriteHalfWord(address & 0x203FFFE, value);
|
cheatsWriteHalfWord(address & 0x203FFFE, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE16LE(((u16 *)&workRAM[address & 0x3FFFE]), value);
|
WRITE16LE(((u16*)&workRAM[address & 0x3FFFE]), value);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u16 *)&freezeInternalRAM[address & 0x7ffe]))
|
if (*((u16*)&freezeInternalRAM[address & 0x7ffe]))
|
||||||
cheatsWriteHalfWord(address & 0x3007ffe, value);
|
cheatsWriteHalfWord(address & 0x3007ffe, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE16LE(((u16 *)&internalRAM[address & 0x7ffe]), value);
|
WRITE16LE(((u16*)&internalRAM[address & 0x7ffe]), value);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (address < 0x4000400)
|
if (address < 0x4000400)
|
||||||
|
@ -604,11 +599,11 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u16 *)&freezePRAM[address & 0x03fe]))
|
if (*((u16*)&freezePRAM[address & 0x03fe]))
|
||||||
cheatsWriteHalfWord(address & 0x70003fe, value);
|
cheatsWriteHalfWord(address & 0x70003fe, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE16LE(((u16 *)&paletteRAM[address & 0x3fe]), value);
|
WRITE16LE(((u16*)&paletteRAM[address & 0x3fe]), value);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
address = (address & 0x1fffe);
|
address = (address & 0x1fffe);
|
||||||
|
@ -617,19 +612,19 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
|
||||||
if ((address & 0x18000) == 0x18000)
|
if ((address & 0x18000) == 0x18000)
|
||||||
address &= 0x17fff;
|
address &= 0x17fff;
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u16 *)&freezeVRAM[address]))
|
if (*((u16*)&freezeVRAM[address]))
|
||||||
cheatsWriteHalfWord(address + 0x06000000, value);
|
cheatsWriteHalfWord(address + 0x06000000, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE16LE(((u16 *)&vram[address]), value);
|
WRITE16LE(((u16*)&vram[address]), value);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
if (*((u16 *)&freezeOAM[address & 0x03fe]))
|
if (*((u16*)&freezeOAM[address & 0x03fe]))
|
||||||
cheatsWriteHalfWord(address & 0x70003fe, value);
|
cheatsWriteHalfWord(address & 0x70003fe, value);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
WRITE16LE(((u16 *)&oam[address & 0x3fe]), value);
|
WRITE16LE(((u16*)&oam[address & 0x3fe]), value);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
|
@ -669,7 +664,7 @@ static inline void CPUWriteHalfWord(u32 address, u16 value)
|
||||||
static inline void CPUWriteByte(u32 address, u8 b)
|
static inline void CPUWriteByte(u32 address, u8 b)
|
||||||
{
|
{
|
||||||
#ifdef BKPT_SUPPORT
|
#ifdef BKPT_SUPPORT
|
||||||
memoryMap *m = &map[address >> 24];
|
memoryMap* m = &map[address >> 24];
|
||||||
if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) {
|
if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) {
|
||||||
if (debuggerBreakOnWrite(address, b, 1)) {
|
if (debuggerBreakOnWrite(address, b, 1)) {
|
||||||
// CPU_BREAK_LOOP_2;
|
// CPU_BREAK_LOOP_2;
|
||||||
|
@ -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;
|
||||||
|
@ -764,7 +757,7 @@ static inline void CPUWriteByte(u32 address, u8 b)
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
// no need to switch
|
// no need to switch
|
||||||
*((u16 *)&paletteRAM[address & 0x3FE]) = (b << 8) | b;
|
*((u16*)&paletteRAM[address & 0x3FE]) = (b << 8) | b;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
address = (address & 0x1fffe);
|
address = (address & 0x1fffe);
|
||||||
|
@ -781,7 +774,7 @@ static inline void CPUWriteByte(u32 address, u8 b)
|
||||||
cheatsWriteByte(address + 0x06000000, b);
|
cheatsWriteByte(address + 0x06000000, b);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
*((u16 *)&vram[address]) = (b << 8) | b;
|
*((u16*)&vram[address]) = (b << 8) | b;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
|
|
|
@ -23,15 +23,15 @@ u32 stop = 0x08000568;
|
||||||
// 0x0000 to 0x7FFF: set custom 15 bit color
|
// 0x0000 to 0x7FFF: set custom 15 bit color
|
||||||
int customBackdropColor = -1;
|
int customBackdropColor = -1;
|
||||||
|
|
||||||
u8 *bios = 0;
|
u8* bios = 0;
|
||||||
u8 *rom = 0;
|
u8* rom = 0;
|
||||||
u8 *internalRAM = 0;
|
u8* internalRAM = 0;
|
||||||
u8 *workRAM = 0;
|
u8* workRAM = 0;
|
||||||
u8 *paletteRAM = 0;
|
u8* paletteRAM = 0;
|
||||||
u8 *vram = 0;
|
u8* vram = 0;
|
||||||
u8 *pix = 0;
|
u8* pix = 0;
|
||||||
u8 *oam = 0;
|
u8* oam = 0;
|
||||||
u8 *ioMem = 0;
|
u8* ioMem = 0;
|
||||||
|
|
||||||
u16 DISPCNT = 0x0080;
|
u16 DISPCNT = 0x0080;
|
||||||
u16 DISPSTAT = 0x0000;
|
u16 DISPSTAT = 0x0000;
|
||||||
|
|
|
@ -36,15 +36,15 @@ extern int layerEnable;
|
||||||
extern int cpuSaveType;
|
extern int cpuSaveType;
|
||||||
extern int customBackdropColor;
|
extern int customBackdropColor;
|
||||||
|
|
||||||
extern u8 *bios;
|
extern u8* bios;
|
||||||
extern u8 *rom;
|
extern u8* rom;
|
||||||
extern u8 *internalRAM;
|
extern u8* internalRAM;
|
||||||
extern u8 *workRAM;
|
extern u8* workRAM;
|
||||||
extern u8 *paletteRAM;
|
extern u8* paletteRAM;
|
||||||
extern u8 *vram;
|
extern u8* vram;
|
||||||
extern u8 *pix;
|
extern u8* pix;
|
||||||
extern u8 *oam;
|
extern u8* oam;
|
||||||
extern u8 *ioMem;
|
extern u8* ioMem;
|
||||||
|
|
||||||
extern u16 DISPCNT;
|
extern u16 DISPCNT;
|
||||||
extern u16 DISPSTAT;
|
extern u16 DISPSTAT;
|
||||||
|
|
|
@ -1,109 +1,109 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode0RenderLine()
|
void mode0RenderLine()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0100) {
|
if (layerEnable & 0x0100) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0800) {
|
if (layerEnable & 0x0800) {
|
||||||
gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
|
gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line0[x] < color) {
|
if (line0[x] < color) {
|
||||||
color = line0[x];
|
color = line0[x];
|
||||||
top = 0x01;
|
top = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line1[x];
|
color = line1[x];
|
||||||
top = 0x02;
|
top = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line3[x];
|
color = line3[x];
|
||||||
top = 0x08;
|
top = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((top & 0x10) && (color & 0x00010000)) {
|
if ((top & 0x10) && (color & 0x00010000)) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -116,35 +116,35 @@ void mode0RenderLine()
|
||||||
|
|
||||||
void mode0RenderLineNoWindow()
|
void mode0RenderLineNoWindow()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0100) {
|
if (layerEnable & 0x0100) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0800) {
|
if (layerEnable & 0x0800) {
|
||||||
gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
|
gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
|
@ -152,93 +152,90 @@ void mode0RenderLineNoWindow()
|
||||||
|
|
||||||
int effect = (BLDMOD >> 6) & 3;
|
int effect = (BLDMOD >> 6) & 3;
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line0[x] < color) {
|
if (line0[x] < color) {
|
||||||
color = line0[x];
|
color = line0[x];
|
||||||
top = 0x01;
|
top = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line1[x] < (color & 0xFF000000)) {
|
if (line1[x] < (color & 0xFF000000)) {
|
||||||
color = line1[x];
|
color = line1[x];
|
||||||
top = 0x02;
|
top = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line2[x] < (color & 0xFF000000)) {
|
if (line2[x] < (color & 0xFF000000)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line3[x] < (color & 0xFF000000)) {
|
if (line3[x] < (color & 0xFF000000)) {
|
||||||
color = line3[x];
|
color = line3[x];
|
||||||
top = 0x08;
|
top = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lineOBJ[x] < (color & 0xFF000000)) {
|
if (lineOBJ[x] < (color & 0xFF000000)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(color & 0x00010000)) {
|
if (!(color & 0x00010000)) {
|
||||||
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;
|
||||||
if(line0[x] < back) {
|
if (line0[x] < back) {
|
||||||
if(top != 0x01) {
|
if (top != 0x01) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line1[x] < (back & 0xFF000000)) {
|
if (line1[x] < (back & 0xFF000000)) {
|
||||||
if(top != 0x02) {
|
if (top != 0x02) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line2[x] < (back & 0xFF000000)) {
|
if (line2[x] < (back & 0xFF000000)) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line3[x] < (back & 0xFF000000)) {
|
if (line3[x] < (back & 0xFF000000)) {
|
||||||
if(top != 0x08) {
|
if (top != 0x08) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lineOBJ[x] < (back & 0xFF000000)) {
|
if (lineOBJ[x] < (back & 0xFF000000)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -247,38 +244,38 @@ void mode0RenderLineNoWindow()
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line0[x] < back) {
|
if (line0[x] < back) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line1[x] < (back & 0xFF000000)) {
|
if (line1[x] < (back & 0xFF000000)) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line2[x] < (back & 0xFF000000)) {
|
if (line2[x] < (back & 0xFF000000)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line3[x] < (back & 0xFF000000)) {
|
if (line3[x] < (back & 0xFF000000)) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -291,10 +288,10 @@ void mode0RenderLineNoWindow()
|
||||||
|
|
||||||
void mode0RenderLineAll()
|
void mode0RenderLineAll()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -303,38 +300,38 @@ void mode0RenderLineAll()
|
||||||
bool inWindow0 = false;
|
bool inWindow0 = false;
|
||||||
bool inWindow1 = false;
|
bool inWindow1 = false;
|
||||||
|
|
||||||
if(layerEnable & 0x2000) {
|
if (layerEnable & 0x2000) {
|
||||||
u8 v0 = WIN0V >> 8;
|
u8 v0 = WIN0V >> 8;
|
||||||
u8 v1 = WIN0V & 255;
|
u8 v1 = WIN0V & 255;
|
||||||
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
if(layerEnable & 0x4000) {
|
if (layerEnable & 0x4000) {
|
||||||
u8 v0 = WIN1V >> 8;
|
u8 v0 = WIN1V >> 8;
|
||||||
u8 v1 = WIN1V & 255;
|
u8 v1 = WIN1V & 255;
|
||||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((layerEnable & 0x0100)) {
|
if ((layerEnable & 0x0100)) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((layerEnable & 0x0400)) {
|
if ((layerEnable & 0x0400)) {
|
||||||
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((layerEnable & 0x0800)) {
|
if ((layerEnable & 0x0800)) {
|
||||||
gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
|
gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +339,7 @@ void mode0RenderLineAll()
|
||||||
gfxDrawOBJWin(lineOBJWin);
|
gfxDrawOBJWin(lineOBJWin);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
|
@ -352,150 +349,148 @@ void mode0RenderLineAll()
|
||||||
u8 inWin1Mask = WININ >> 8;
|
u8 inWin1Mask = WININ >> 8;
|
||||||
u8 outMask = WINOUT & 0xFF;
|
u8 outMask = WINOUT & 0xFF;
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
u8 mask = outMask;
|
u8 mask = outMask;
|
||||||
|
|
||||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
if (!(lineOBJWin[x] & 0x80000000)) {
|
||||||
mask = WINOUT >> 8;
|
mask = WINOUT >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow1) {
|
if (inWindow1) {
|
||||||
if(gfxInWin1[x])
|
if (gfxInWin1[x])
|
||||||
mask = inWin1Mask;
|
mask = inWin1Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow0) {
|
if (inWindow0) {
|
||||||
if(gfxInWin0[x]) {
|
if (gfxInWin0[x]) {
|
||||||
mask = inWin0Mask;
|
mask = inWin0Mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 1) && (line0[x] < color)) {
|
if ((mask & 1) && (line0[x] < color)) {
|
||||||
color = line0[x];
|
color = line0[x];
|
||||||
top = 0x01;
|
top = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24))) {
|
if ((mask & 2) && ((u8)(line1[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = line1[x];
|
color = line1[x];
|
||||||
top = 0x02;
|
top = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24))) {
|
if ((mask & 4) && ((u8)(line2[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24))) {
|
if ((mask & 8) && ((u8)(line3[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = line3[x];
|
color = line3[x];
|
||||||
top = 0x08;
|
top = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))) {
|
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color & 0x00010000) {
|
if (color & 0x00010000) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) {
|
if ((mask & 1) && ((u8)(line0[x] >> 24) < (u8)(back >> 24))) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) {
|
if ((mask & 2) && ((u8)(line1[x] >> 24) < (u8)(back >> 24))) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) {
|
if ((mask & 4) && ((u8)(line2[x] >> 24) < (u8)(back >> 24))) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) {
|
if ((mask & 8) && ((u8)(line3[x] >> 24) < (u8)(back >> 24))) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mask & 32) {
|
} else if (mask & 32) {
|
||||||
// special FX on in the window
|
// special FX on in the window
|
||||||
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;
|
||||||
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 1) && (u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x01) {
|
if (top != 0x01) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 2) && (u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x02) {
|
if (top != 0x02) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 4) && (u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 8) && (u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x08) {
|
if (top != 0x08) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode1RenderLine()
|
void mode1RenderLine()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0100) {
|
if (layerEnable & 0x0100) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
BG2PA, BG2PB, BG2PC, BG2PD,
|
BG2PA, BG2PB, BG2PC, BG2PD,
|
||||||
|
@ -34,68 +34,68 @@ void mode1RenderLine()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line0[x] < color) {
|
if (line0[x] < color) {
|
||||||
color = line0[x];
|
color = line0[x];
|
||||||
top = 0x01;
|
top = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line1[x];
|
color = line1[x];
|
||||||
top = 0x02;
|
top = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((top & 0x10) && (color & 0x00010000)) {
|
if ((top & 0x10) && (color & 0x00010000)) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -110,28 +110,27 @@ void mode1RenderLine()
|
||||||
|
|
||||||
void mode1RenderLineNoWindow()
|
void mode1RenderLineNoWindow()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0100) {
|
if (layerEnable & 0x0100) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
BG2PA, BG2PB, BG2PC, BG2PD,
|
BG2PA, BG2PB, BG2PC, BG2PD,
|
||||||
|
@ -141,86 +140,84 @@ void mode1RenderLineNoWindow()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line0[x] < color) {
|
if (line0[x] < color) {
|
||||||
color = line0[x];
|
color = line0[x];
|
||||||
top = 0x01;
|
top = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line1[x];
|
color = line1[x];
|
||||||
top = 0x02;
|
top = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(color & 0x00010000)) {
|
if (!(color & 0x00010000)) {
|
||||||
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;
|
||||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x01) {
|
if (top != 0x01) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x02) {
|
if (top != 0x02) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -229,33 +226,33 @@ void mode1RenderLineNoWindow()
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -270,10 +267,10 @@ void mode1RenderLineNoWindow()
|
||||||
|
|
||||||
void mode1RenderLineAll()
|
void mode1RenderLineAll()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
|
@ -283,36 +280,36 @@ void mode1RenderLineAll()
|
||||||
bool inWindow0 = false;
|
bool inWindow0 = false;
|
||||||
bool inWindow1 = false;
|
bool inWindow1 = false;
|
||||||
|
|
||||||
if(layerEnable & 0x2000) {
|
if (layerEnable & 0x2000) {
|
||||||
u8 v0 = WIN0V >> 8;
|
u8 v0 = WIN0V >> 8;
|
||||||
u8 v1 = WIN0V & 255;
|
u8 v1 = WIN0V & 255;
|
||||||
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
if(layerEnable & 0x4000) {
|
if (layerEnable & 0x4000) {
|
||||||
u8 v0 = WIN1V >> 8;
|
u8 v0 = WIN1V >> 8;
|
||||||
u8 v1 = WIN1V & 255;
|
u8 v1 = WIN1V & 255;
|
||||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0100) {
|
if (layerEnable & 0x0100) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
BG2PA, BG2PB, BG2PC, BG2PD,
|
BG2PA, BG2PB, BG2PC, BG2PD,
|
||||||
|
@ -323,7 +320,7 @@ void mode1RenderLineAll()
|
||||||
gfxDrawOBJWin(lineOBJWin);
|
gfxDrawOBJWin(lineOBJWin);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
|
@ -333,134 +330,132 @@ void mode1RenderLineAll()
|
||||||
u8 inWin1Mask = WININ >> 8;
|
u8 inWin1Mask = WININ >> 8;
|
||||||
u8 outMask = WINOUT & 0xFF;
|
u8 outMask = WINOUT & 0xFF;
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
u8 mask = outMask;
|
u8 mask = outMask;
|
||||||
|
|
||||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
if (!(lineOBJWin[x] & 0x80000000)) {
|
||||||
mask = WINOUT >> 8;
|
mask = WINOUT >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow1) {
|
if (inWindow1) {
|
||||||
if(gfxInWin1[x])
|
if (gfxInWin1[x])
|
||||||
mask = inWin1Mask;
|
mask = inWin1Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow0) {
|
if (inWindow0) {
|
||||||
if(gfxInWin0[x]) {
|
if (gfxInWin0[x]) {
|
||||||
mask = inWin0Mask;
|
mask = inWin0Mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line0[x] < color && (mask & 1)) {
|
if (line0[x] < color && (mask & 1)) {
|
||||||
color = line0[x];
|
color = line0[x];
|
||||||
top = 0x01;
|
top = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line1[x]>>24) < (u8)(color >> 24) && (mask & 2)) {
|
if ((u8)(line1[x] >> 24) < (u8)(color >> 24) && (mask & 2)) {
|
||||||
color = line1[x];
|
color = line1[x];
|
||||||
top = 0x02;
|
top = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(color >> 24) && (mask & 4)) {
|
if ((u8)(line2[x] >> 24) < (u8)(color >> 24) && (mask & 4)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24) && (mask & 16)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color & 0x00010000) {
|
if (color & 0x00010000) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 1) && (u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 2) && (u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 4) && (u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mask & 32) {
|
} else if (mask & 32) {
|
||||||
// special FX on the window
|
// special FX on the window
|
||||||
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;
|
||||||
|
|
||||||
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 1) && (u8)(line0[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x01) {
|
if (top != 0x01) {
|
||||||
back = line0[x];
|
back = line0[x];
|
||||||
top2 = 0x01;
|
top2 = 0x01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 2) && (u8)(line1[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x02) {
|
if (top != 0x02) {
|
||||||
back = line1[x];
|
back = line1[x];
|
||||||
top2 = 0x02;
|
top2 = 0x02;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 4) && (u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode2RenderLine()
|
void mode2RenderLine()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
|
@ -24,9 +24,9 @@ void mode2RenderLine()
|
||||||
changed, line2);
|
changed, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0800) {
|
if (layerEnable & 0x0800) {
|
||||||
int changed = gfxBG3Changed;
|
int changed = gfxBG3Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
||||||
|
@ -37,59 +37,58 @@ void mode2RenderLine()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line3[x];
|
color = line3[x];
|
||||||
top = 0x08;
|
top = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((top & 0x10) && (color & 0x00010000)) {
|
if ((top & 0x10) && (color & 0x00010000)) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -105,19 +104,19 @@ void mode2RenderLine()
|
||||||
|
|
||||||
void mode2RenderLineNoWindow()
|
void mode2RenderLineNoWindow()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
|
@ -125,9 +124,9 @@ void mode2RenderLineNoWindow()
|
||||||
changed, line2);
|
changed, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0800) {
|
if (layerEnable & 0x0800) {
|
||||||
int changed = gfxBG3Changed;
|
int changed = gfxBG3Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
||||||
|
@ -138,76 +137,73 @@ void mode2RenderLineNoWindow()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = line3[x];
|
color = line3[x];
|
||||||
top = 0x08;
|
top = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(color & 0x00010000)) {
|
if (!(color & 0x00010000)) {
|
||||||
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;
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x08) {
|
if (top != 0x08) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -216,28 +212,28 @@ void mode2RenderLineNoWindow()
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -253,10 +249,10 @@ void mode2RenderLineNoWindow()
|
||||||
|
|
||||||
void mode2RenderLineAll()
|
void mode2RenderLineAll()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
|
@ -266,28 +262,28 @@ void mode2RenderLineAll()
|
||||||
bool inWindow0 = false;
|
bool inWindow0 = false;
|
||||||
bool inWindow1 = false;
|
bool inWindow1 = false;
|
||||||
|
|
||||||
if(layerEnable & 0x2000) {
|
if (layerEnable & 0x2000) {
|
||||||
u8 v0 = WIN0V >> 8;
|
u8 v0 = WIN0V >> 8;
|
||||||
u8 v1 = WIN0V & 255;
|
u8 v1 = WIN0V & 255;
|
||||||
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
if(layerEnable & 0x4000) {
|
if (layerEnable & 0x4000) {
|
||||||
u8 v0 = WIN1V >> 8;
|
u8 v0 = WIN1V >> 8;
|
||||||
u8 v1 = WIN1V & 255;
|
u8 v1 = WIN1V & 255;
|
||||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
|
@ -295,9 +291,9 @@ void mode2RenderLineAll()
|
||||||
changed, line2);
|
changed, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0800) {
|
if (layerEnable & 0x0800) {
|
||||||
int changed = gfxBG3Changed;
|
int changed = gfxBG3Changed;
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
||||||
|
@ -309,7 +305,7 @@ void mode2RenderLineAll()
|
||||||
gfxDrawOBJWin(lineOBJWin);
|
gfxDrawOBJWin(lineOBJWin);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
|
@ -319,117 +315,115 @@ void mode2RenderLineAll()
|
||||||
u8 inWin1Mask = WININ >> 8;
|
u8 inWin1Mask = WININ >> 8;
|
||||||
u8 outMask = WINOUT & 0xFF;
|
u8 outMask = WINOUT & 0xFF;
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
u8 mask = outMask;
|
u8 mask = outMask;
|
||||||
|
|
||||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
if (!(lineOBJWin[x] & 0x80000000)) {
|
||||||
mask = WINOUT >> 8;
|
mask = WINOUT >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow1) {
|
if (inWindow1) {
|
||||||
if(gfxInWin1[x])
|
if (gfxInWin1[x])
|
||||||
mask = inWin1Mask;
|
mask = inWin1Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow0) {
|
if (inWindow0) {
|
||||||
if(gfxInWin0[x]) {
|
if (gfxInWin0[x]) {
|
||||||
mask = inWin0Mask;
|
mask = inWin0Mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line2[x] < color && (mask & 4)) {
|
if (line2[x] < color && (mask & 4)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(line3[x]>>24) < (u8)(color >> 24) && (mask & 8)) {
|
if ((u8)(line3[x] >> 24) < (u8)(color >> 24) && (mask & 8)) {
|
||||||
color = line3[x];
|
color = line3[x];
|
||||||
top = 0x08;
|
top = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24) && (mask & 16)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color & 0x00010000) {
|
if (color & 0x00010000) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 8) && (u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mask & 32) {
|
} else if (mask & 32) {
|
||||||
// special FX on the window
|
// special FX on the window
|
||||||
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;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 8) && (u8)(line3[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x08) {
|
if (top != 0x08) {
|
||||||
back = line3[x];
|
back = line3[x];
|
||||||
top2 = 0x08;
|
top2 = 0x08;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode3RenderLine()
|
void mode3RenderLine()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
||||||
|
@ -30,48 +30,48 @@ void mode3RenderLine()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 background;
|
u32 background;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
background = (READ16LE(&palette[0]) | 0x30000000);
|
background = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = background;
|
u32 color = background;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line2[x] < color) {
|
if (line2[x] < color) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((top & 0x10) && (color & 0x00010000)) {
|
if ((top & 0x10) && (color & 0x00010000)) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -86,20 +86,20 @@ void mode3RenderLine()
|
||||||
|
|
||||||
void mode3RenderLineNoWindow()
|
void mode3RenderLineNoWindow()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
||||||
|
@ -112,64 +112,61 @@ void mode3RenderLineNoWindow()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 background;
|
u32 background;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
background = (READ16LE(&palette[0]) | 0x30000000);
|
background = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = background;
|
u32 color = background;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line2[x] < color) {
|
if (line2[x] < color) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(color & 0x00010000)) {
|
if (!(color & 0x00010000)) {
|
||||||
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;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -178,23 +175,23 @@ void mode3RenderLineNoWindow()
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -209,10 +206,10 @@ void mode3RenderLineNoWindow()
|
||||||
|
|
||||||
void mode3RenderLineAll()
|
void mode3RenderLineAll()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x80) {
|
if (DISPCNT & 0x80) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
|
@ -222,29 +219,29 @@ void mode3RenderLineAll()
|
||||||
bool inWindow0 = false;
|
bool inWindow0 = false;
|
||||||
bool inWindow1 = false;
|
bool inWindow1 = false;
|
||||||
|
|
||||||
if(layerEnable & 0x2000) {
|
if (layerEnable & 0x2000) {
|
||||||
u8 v0 = WIN0V >> 8;
|
u8 v0 = WIN0V >> 8;
|
||||||
u8 v1 = WIN0V & 255;
|
u8 v1 = WIN0V & 255;
|
||||||
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
if(layerEnable & 0x4000) {
|
if (layerEnable & 0x4000) {
|
||||||
u8 v0 = WIN1V >> 8;
|
u8 v0 = WIN1V >> 8;
|
||||||
u8 v1 = WIN1V & 255;
|
u8 v1 = WIN1V & 255;
|
||||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
||||||
|
@ -262,106 +259,103 @@ void mode3RenderLineAll()
|
||||||
u8 outMask = WINOUT & 0xFF;
|
u8 outMask = WINOUT & 0xFF;
|
||||||
|
|
||||||
u32 background;
|
u32 background;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
background = (READ16LE(&palette[0]) | 0x30000000);
|
background = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = background;
|
u32 color = background;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
u8 mask = outMask;
|
u8 mask = outMask;
|
||||||
|
|
||||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
if (!(lineOBJWin[x] & 0x80000000)) {
|
||||||
mask = WINOUT >> 8;
|
mask = WINOUT >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow1) {
|
if (inWindow1) {
|
||||||
if(gfxInWin1[x])
|
if (gfxInWin1[x])
|
||||||
mask = inWin1Mask;
|
mask = inWin1Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow0) {
|
if (inWindow0) {
|
||||||
if(gfxInWin0[x]) {
|
if (gfxInWin0[x]) {
|
||||||
mask = inWin0Mask;
|
mask = inWin0Mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && (line2[x] < color)) {
|
if ((mask & 4) && (line2[x] < color)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))) {
|
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color & 0x00010000) {
|
if (color & 0x00010000) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mask & 32) {
|
} else if (mask & 32) {
|
||||||
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;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,20 @@
|
||||||
|
|
||||||
void mode4RenderLine()
|
void mode4RenderLine()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x0080) {
|
if (DISPCNT & 0x0080) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x400) {
|
if (layerEnable & 0x400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
|
@ -29,48 +29,48 @@ void mode4RenderLine()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line2[x] < color) {
|
if (line2[x] < color) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((top & 0x10) && (color & 0x00010000)) {
|
if ((top & 0x10) && (color & 0x00010000)) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -85,20 +85,20 @@ void mode4RenderLine()
|
||||||
|
|
||||||
void mode4RenderLineNoWindow()
|
void mode4RenderLineNoWindow()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x0080) {
|
if (DISPCNT & 0x0080) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x400) {
|
if (layerEnable & 0x400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
|
@ -110,64 +110,61 @@ void mode4RenderLineNoWindow()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line2[x] < color) {
|
if (line2[x] < color) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(color & 0x00010000)) {
|
if (!(color & 0x00010000)) {
|
||||||
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;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -176,23 +173,23 @@ void mode4RenderLineNoWindow()
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -207,10 +204,10 @@ void mode4RenderLineNoWindow()
|
||||||
|
|
||||||
void mode4RenderLineAll()
|
void mode4RenderLineAll()
|
||||||
{
|
{
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(DISPCNT & 0x0080) {
|
if (DISPCNT & 0x0080) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
|
@ -220,29 +217,29 @@ void mode4RenderLineAll()
|
||||||
bool inWindow0 = false;
|
bool inWindow0 = false;
|
||||||
bool inWindow1 = false;
|
bool inWindow1 = false;
|
||||||
|
|
||||||
if(layerEnable & 0x2000) {
|
if (layerEnable & 0x2000) {
|
||||||
u8 v0 = WIN0V >> 8;
|
u8 v0 = WIN0V >> 8;
|
||||||
u8 v1 = WIN0V & 255;
|
u8 v1 = WIN0V & 255;
|
||||||
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
if(layerEnable & 0x4000) {
|
if (layerEnable & 0x4000) {
|
||||||
u8 v0 = WIN1V >> 8;
|
u8 v0 = WIN1V >> 8;
|
||||||
u8 v1 = WIN1V & 255;
|
u8 v1 = WIN1V & 255;
|
||||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerEnable & 0x400) {
|
if (layerEnable & 0x400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||||
|
@ -255,7 +252,7 @@ void mode4RenderLineAll()
|
||||||
gfxDrawOBJWin(lineOBJWin);
|
gfxDrawOBJWin(lineOBJWin);
|
||||||
|
|
||||||
u32 backdrop;
|
u32 backdrop;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
|
@ -265,100 +262,97 @@ void mode4RenderLineAll()
|
||||||
u8 inWin1Mask = WININ >> 8;
|
u8 inWin1Mask = WININ >> 8;
|
||||||
u8 outMask = WINOUT & 0xFF;
|
u8 outMask = WINOUT & 0xFF;
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = backdrop;
|
u32 color = backdrop;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
u8 mask = outMask;
|
u8 mask = outMask;
|
||||||
|
|
||||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
if (!(lineOBJWin[x] & 0x80000000)) {
|
||||||
mask = WINOUT >> 8;
|
mask = WINOUT >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow1) {
|
if (inWindow1) {
|
||||||
if(gfxInWin1[x])
|
if (gfxInWin1[x])
|
||||||
mask = inWin1Mask;
|
mask = inWin1Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow0) {
|
if (inWindow0) {
|
||||||
if(gfxInWin0[x]) {
|
if (gfxInWin0[x]) {
|
||||||
mask = inWin0Mask;
|
mask = inWin0Mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && (line2[x] < color)) {
|
if ((mask & 4) && (line2[x] < color)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))) {
|
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color & 0x00010000) {
|
if (color & 0x00010000) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = backdrop;
|
u32 back = backdrop;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mask & 32) {
|
} else if (mask & 32) {
|
||||||
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;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
#include "Globals.h"
|
|
||||||
#include "GBAGfx.h"
|
#include "GBAGfx.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
void mode5RenderLine()
|
void mode5RenderLine()
|
||||||
{
|
{
|
||||||
if(DISPCNT & 0x0080) {
|
if (DISPCNT & 0x0080) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
||||||
|
@ -30,48 +30,48 @@ void mode5RenderLine()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 background;
|
u32 background;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
background = (READ16LE(&palette[0]) | 0x30000000);
|
background = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = background;
|
u32 color = background;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line2[x] < color) {
|
if (line2[x] < color) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((top & 0x10) && (color & 0x00010000)) {
|
if ((top & 0x10) && (color & 0x00010000)) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -86,20 +86,20 @@ void mode5RenderLine()
|
||||||
|
|
||||||
void mode5RenderLineNoWindow()
|
void mode5RenderLineNoWindow()
|
||||||
{
|
{
|
||||||
if(DISPCNT & 0x0080) {
|
if (DISPCNT & 0x0080) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
||||||
|
@ -112,64 +112,61 @@ void mode5RenderLineNoWindow()
|
||||||
gfxDrawSprites(lineOBJ);
|
gfxDrawSprites(lineOBJ);
|
||||||
|
|
||||||
u32 background;
|
u32 background;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
background = (READ16LE(&palette[0]) | 0x30000000);
|
background = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = background;
|
u32 color = background;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
|
|
||||||
if(line2[x] < color) {
|
if (line2[x] < color) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(color & 0x00010000)) {
|
if (!(color & 0x00010000)) {
|
||||||
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;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -178,23 +175,23 @@ void mode5RenderLineNoWindow()
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if(line2[x] < back) {
|
if (line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -209,20 +206,20 @@ void mode5RenderLineNoWindow()
|
||||||
|
|
||||||
void mode5RenderLineAll()
|
void mode5RenderLineAll()
|
||||||
{
|
{
|
||||||
if(DISPCNT & 0x0080) {
|
if (DISPCNT & 0x0080) {
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
lineMix[x] = 0x7fff;
|
lineMix[x] = 0x7fff;
|
||||||
}
|
}
|
||||||
gfxLastVCOUNT = VCOUNT;
|
gfxLastVCOUNT = VCOUNT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 *palette = (u16 *)paletteRAM;
|
u16* palette = (u16*)paletteRAM;
|
||||||
|
|
||||||
if(layerEnable & 0x0400) {
|
if (layerEnable & 0x0400) {
|
||||||
int changed = gfxBG2Changed;
|
int changed = gfxBG2Changed;
|
||||||
|
|
||||||
if(gfxLastVCOUNT > VCOUNT)
|
if (gfxLastVCOUNT > VCOUNT)
|
||||||
changed = 3;
|
changed = 3;
|
||||||
|
|
||||||
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
||||||
|
@ -238,20 +235,20 @@ void mode5RenderLineAll()
|
||||||
bool inWindow0 = false;
|
bool inWindow0 = false;
|
||||||
bool inWindow1 = false;
|
bool inWindow1 = false;
|
||||||
|
|
||||||
if(layerEnable & 0x2000) {
|
if (layerEnable & 0x2000) {
|
||||||
u8 v0 = WIN0V >> 8;
|
u8 v0 = WIN0V >> 8;
|
||||||
u8 v1 = WIN0V & 255;
|
u8 v1 = WIN0V & 255;
|
||||||
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
}
|
}
|
||||||
if(layerEnable & 0x4000) {
|
if (layerEnable & 0x4000) {
|
||||||
u8 v0 = WIN1V >> 8;
|
u8 v0 = WIN1V >> 8;
|
||||||
u8 v1 = WIN1V & 255;
|
u8 v1 = WIN1V & 255;
|
||||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||||
if(v1 >= v0)
|
if (v1 >= v0)
|
||||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||||
else
|
else
|
||||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||||
|
@ -262,106 +259,103 @@ void mode5RenderLineAll()
|
||||||
u8 outMask = WINOUT & 0xFF;
|
u8 outMask = WINOUT & 0xFF;
|
||||||
|
|
||||||
u32 background;
|
u32 background;
|
||||||
if(customBackdropColor == -1) {
|
if (customBackdropColor == -1) {
|
||||||
background = (READ16LE(&palette[0]) | 0x30000000);
|
background = (READ16LE(&palette[0]) | 0x30000000);
|
||||||
} else {
|
} else {
|
||||||
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
background = ((customBackdropColor & 0x7FFF) | 0x30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < 240; x++) {
|
for (int x = 0; x < 240; x++) {
|
||||||
u32 color = background;
|
u32 color = background;
|
||||||
u8 top = 0x20;
|
u8 top = 0x20;
|
||||||
u8 mask = outMask;
|
u8 mask = outMask;
|
||||||
|
|
||||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
if (!(lineOBJWin[x] & 0x80000000)) {
|
||||||
mask = WINOUT >> 8;
|
mask = WINOUT >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow1) {
|
if (inWindow1) {
|
||||||
if(gfxInWin1[x])
|
if (gfxInWin1[x])
|
||||||
mask = inWin1Mask;
|
mask = inWin1Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inWindow0) {
|
if (inWindow0) {
|
||||||
if(gfxInWin0[x]) {
|
if (gfxInWin0[x]) {
|
||||||
mask = inWin0Mask;
|
mask = inWin0Mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 4) && (line2[x] < color)) {
|
if ((mask & 4) && (line2[x] < color)) {
|
||||||
color = line2[x];
|
color = line2[x];
|
||||||
top = 0x04;
|
top = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))) {
|
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
|
||||||
color = lineOBJ[x];
|
color = lineOBJ[x];
|
||||||
top = 0x10;
|
top = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color & 0x00010000) {
|
if (color & 0x00010000) {
|
||||||
// semi-transparent OBJ
|
// semi-transparent OBJ
|
||||||
u32 back = background;
|
u32 back = background;
|
||||||
u8 top2 = 0x20;
|
u8 top2 = 0x20;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
color = gfxAlphaBlend(color, back,
|
color = gfxAlphaBlend(color, back,
|
||||||
coeff[COLEV & 0x1F],
|
coeff[COLEV & 0x1F],
|
||||||
coeff[(COLEV >> 8) & 0x1F]);
|
coeff[(COLEV >> 8) & 0x1F]);
|
||||||
else {
|
else {
|
||||||
switch((BLDMOD >> 6) & 3) {
|
switch ((BLDMOD >> 6) & 3) {
|
||||||
case 2:
|
case 2:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(mask & 32) {
|
} else if (mask & 32) {
|
||||||
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;
|
||||||
|
|
||||||
if((mask & 4) && line2[x] < back) {
|
if ((mask & 4) && line2[x] < back) {
|
||||||
if(top != 0x04) {
|
if (top != 0x04) {
|
||||||
back = line2[x];
|
back = line2[x];
|
||||||
top2 = 0x04;
|
top2 = 0x04;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
|
||||||
if(top != 0x10) {
|
if (top != 0x10) {
|
||||||
back = lineOBJ[x];
|
back = lineOBJ[x];
|
||||||
top2 = 0x10;
|
top2 = 0x10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top2 & (BLDMOD>>8))
|
if (top2 & (BLDMOD >> 8))
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(BLDMOD & top)
|
if (BLDMOD & top)
|
||||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
138
src/gba/RTC.cpp
138
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,12 +305,12 @@ void rtcReset()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
void rtcSaveGame(u8* &data)
|
void rtcSaveGame(u8*& data)
|
||||||
{
|
{
|
||||||
utilWriteMem(data, &rtcClockData, sizeof(rtcClockData));
|
utilWriteMem(data, &rtcClockData, sizeof(rtcClockData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtcReadGame(const u8* &data)
|
void rtcReadGame(const u8*& data)
|
||||||
{
|
{
|
||||||
utilReadMem(&rtcClockData, data, sizeof(rtcClockData));
|
utilReadMem(&rtcClockData, data, sizeof(rtcClockData));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ bool rtcIsEnabled();
|
||||||
void rtcReset();
|
void rtcReset();
|
||||||
|
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
void rtcReadGame(const u8 *&data);
|
void rtcReadGame(const u8*& data);
|
||||||
void rtcSaveGame(u8 *&data);
|
void rtcSaveGame(u8*& data);
|
||||||
#else
|
#else
|
||||||
void rtcReadGame(gzFile gzFile);
|
void rtcReadGame(gzFile gzFile);
|
||||||
void rtcSaveGame(gzFile gzFile);
|
void rtcSaveGame(gzFile gzFile);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -74,8 +74,8 @@ extern int soundTicks; // Number of 16.8 MHz clocks until soundTick() wil
|
||||||
|
|
||||||
// Saves/loads emulator state
|
// Saves/loads emulator state
|
||||||
#ifdef __LIBRETRO__
|
#ifdef __LIBRETRO__
|
||||||
void soundSaveGame(u8 *&);
|
void soundSaveGame(u8*&);
|
||||||
void soundReadGame(const u8 *&in, int version);
|
void soundReadGame(const u8*& in, int version);
|
||||||
#else
|
#else
|
||||||
void soundSaveGame(gzFile);
|
void soundSaveGame(gzFile);
|
||||||
void soundReadGame(gzFile, int version);
|
void soundReadGame(gzFile, int version);
|
||||||
|
@ -83,6 +83,6 @@ void soundReadGame(gzFile, int version);
|
||||||
|
|
||||||
class Multi_Buffer;
|
class Multi_Buffer;
|
||||||
|
|
||||||
void flush_samples(Multi_Buffer *buffer);
|
void flush_samples(Multi_Buffer* buffer);
|
||||||
|
|
||||||
#endif // SOUND_H
|
#endif // SOUND_H
|
||||||
|
|
|
@ -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,30 +1,29 @@
|
||||||
#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))
|
||||||
|
|
||||||
#define debuggerReadHalfWord(addr) \
|
#define debuggerReadHalfWord(addr) \
|
||||||
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
READ16LE(((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||||
|
|
||||||
static bool agbPrintEnabled = false;
|
static bool agbPrintEnabled = false;
|
||||||
static bool agbPrintProtect = false;
|
static bool agbPrintProtect = false;
|
||||||
|
|
||||||
bool agbPrintWrite(u32 address, u16 value)
|
bool agbPrintWrite(u32 address, u16 value)
|
||||||
{
|
{
|
||||||
if(agbPrintEnabled) {
|
if (agbPrintEnabled) {
|
||||||
if(address == 0x9fe2ffe) { // protect
|
if (address == 0x9fe2ffe) { // protect
|
||||||
agbPrintProtect = (value != 0);
|
agbPrintProtect = (value != 0);
|
||||||
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);
|
||||||
|
@ -56,24 +55,24 @@ void agbPrintFlush()
|
||||||
u16 put = debuggerReadHalfWord(0x9fe20fe);
|
u16 put = debuggerReadHalfWord(0x9fe20fe);
|
||||||
|
|
||||||
u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16);
|
u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16);
|
||||||
if(address != 0xfd0000 && address != 0x1fd0000) {
|
if (address != 0xfd0000 && address != 0x1fd0000) {
|
||||||
dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
|
dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
|
||||||
// get rid of the text otherwise we will continue to be called
|
// get rid of the text otherwise we will continue to be called
|
||||||
debuggerWriteHalfWord(0x9fe20fc, put);
|
debuggerWriteHalfWord(0x9fe20fc, put);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 *data = &rom[address];
|
u8* data = &rom[address];
|
||||||
|
|
||||||
while(get != put) {
|
while (get != put) {
|
||||||
char c = data[get++];
|
char c = data[get++];
|
||||||
char s[2];
|
char s[2];
|
||||||
s[0] = c;
|
s[0] = c;
|
||||||
s[1] = 0;
|
s[1] = 0;
|
||||||
|
|
||||||
if(systemVerbose & VERBOSE_AGBPRINT)
|
if (systemVerbose & VERBOSE_AGBPRINT)
|
||||||
dbgOutput(s, 0);
|
dbgOutput(s, 0);
|
||||||
if(c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
debuggerWriteHalfWord(0x9fe20fc, get);
|
debuggerWriteHalfWord(0x9fe20fc, get);
|
||||||
|
|
|
@ -12,268 +12,269 @@
|
||||||
struct Opcodes {
|
struct Opcodes {
|
||||||
u32 mask;
|
u32 mask;
|
||||||
u32 cval;
|
u32 cval;
|
||||||
const char *mnemonic;
|
const char* mnemonic;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define debuggerReadMemory(addr) \
|
#define debuggerReadMemory(addr) \
|
||||||
READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
READ32LE(((u32*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||||
|
|
||||||
#define debuggerReadHalfWord(addr) \
|
#define debuggerReadHalfWord(addr) \
|
||||||
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
READ16LE(((u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
|
||||||
|
|
||||||
#define debuggerReadByte(addr) \
|
#define debuggerReadByte(addr) \
|
||||||
map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
|
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
|
||||||
|
|
||||||
const char hdig[] = "0123456789abcdef";
|
const char hdig[] = "0123456789abcdef";
|
||||||
|
|
||||||
const char *decVals[16] = {
|
const char* decVals[16] = {
|
||||||
"0","1","2","3","4","5","6","7","8",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8",
|
||||||
"9","10","11","12","13","14","15"
|
"9", "10", "11", "12", "13", "14", "15"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *regs[16] = {
|
const char* regs[16] = {
|
||||||
"r0","r1","r2","r3","r4","r5","r6","r7",
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
||||||
"r8","r9","r10","r11","r12","sp","lr","pc"
|
"r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *conditions[16] = {
|
const char* conditions[16] = {
|
||||||
"eq","ne","cs","cc","mi","pl","vs","vc",
|
"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc",
|
||||||
"hi","ls","ge","lt","gt","le","","nv"
|
"hi", "ls", "ge", "lt", "gt", "le", "", "nv"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *shifts[5] = {
|
const char* shifts[5] = {
|
||||||
"lsl","lsr","asr","ror","rrx"
|
"lsl", "lsr", "asr", "ror", "rrx"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *armMultLoadStore[12] = {
|
const char* armMultLoadStore[12] = {
|
||||||
// non-stack
|
// non-stack
|
||||||
"da","ia","db","ib",
|
"da", "ia", "db", "ib",
|
||||||
// stack store
|
// stack store
|
||||||
"ed","ea","fd","fa",
|
"ed", "ea", "fd", "fa",
|
||||||
// stack load
|
// stack load
|
||||||
"fa","fd","ea","ed"
|
"fa", "fd", "ea", "ed"
|
||||||
};
|
};
|
||||||
|
|
||||||
const Opcodes thumbOpcodes[] = {
|
const Opcodes thumbOpcodes[] = {
|
||||||
// Format 1
|
// Format 1
|
||||||
{0xf800, 0x0000, "lsl %r0, %r3, %o"},
|
{ 0xf800, 0x0000, "lsl %r0, %r3, %o" },
|
||||||
{0xf800, 0x0800, "lsr %r0, %r3, %o"},
|
{ 0xf800, 0x0800, "lsr %r0, %r3, %o" },
|
||||||
{0xf800, 0x1000, "asr %r0, %r3, %o"},
|
{ 0xf800, 0x1000, "asr %r0, %r3, %o" },
|
||||||
// Format 2
|
// Format 2
|
||||||
{0xfe00, 0x1800, "add %r0, %r3, %r6"},
|
{ 0xfe00, 0x1800, "add %r0, %r3, %r6" },
|
||||||
{0xfe00, 0x1a00, "sub %r0, %r3, %r6"},
|
{ 0xfe00, 0x1a00, "sub %r0, %r3, %r6" },
|
||||||
{0xfe00, 0x1c00, "add %r0, %r3, %i"},
|
{ 0xfe00, 0x1c00, "add %r0, %r3, %i" },
|
||||||
{0xfe00, 0x1e00, "sub %r0, %r3, %i"},
|
{ 0xfe00, 0x1e00, "sub %r0, %r3, %i" },
|
||||||
// Format 3
|
// Format 3
|
||||||
{0xf800, 0x2000, "mov %r8, %O"},
|
{ 0xf800, 0x2000, "mov %r8, %O" },
|
||||||
{0xf800, 0x2800, "cmp %r8, %O"},
|
{ 0xf800, 0x2800, "cmp %r8, %O" },
|
||||||
{0xf800, 0x3000, "add %r8, %O"},
|
{ 0xf800, 0x3000, "add %r8, %O" },
|
||||||
{0xf800, 0x3800, "sub %r8, %O"},
|
{ 0xf800, 0x3800, "sub %r8, %O" },
|
||||||
// Format 4
|
// Format 4
|
||||||
{0xffc0, 0x4000, "and %r0, %r3"},
|
{ 0xffc0, 0x4000, "and %r0, %r3" },
|
||||||
{0xffc0, 0x4040, "eor %r0, %r3"},
|
{ 0xffc0, 0x4040, "eor %r0, %r3" },
|
||||||
{0xffc0, 0x4080, "lsl %r0, %r3"},
|
{ 0xffc0, 0x4080, "lsl %r0, %r3" },
|
||||||
{0xffc0, 0x40c0, "lsr %r0, %r3"},
|
{ 0xffc0, 0x40c0, "lsr %r0, %r3" },
|
||||||
{0xffc0, 0x4100, "asr %r0, %r3"},
|
{ 0xffc0, 0x4100, "asr %r0, %r3" },
|
||||||
{0xffc0, 0x4140, "adc %r0, %r3"},
|
{ 0xffc0, 0x4140, "adc %r0, %r3" },
|
||||||
{0xffc0, 0x4180, "sbc %r0, %r3"},
|
{ 0xffc0, 0x4180, "sbc %r0, %r3" },
|
||||||
{0xffc0, 0x41c0, "ror %r0, %r3"},
|
{ 0xffc0, 0x41c0, "ror %r0, %r3" },
|
||||||
{0xffc0, 0x4200, "tst %r0, %r3"},
|
{ 0xffc0, 0x4200, "tst %r0, %r3" },
|
||||||
{0xffc0, 0x4240, "neg %r0, %r3"},
|
{ 0xffc0, 0x4240, "neg %r0, %r3" },
|
||||||
{0xffc0, 0x4280, "cmp %r0, %r3"},
|
{ 0xffc0, 0x4280, "cmp %r0, %r3" },
|
||||||
{0xffc0, 0x42c0, "cmn %r0, %r3"},
|
{ 0xffc0, 0x42c0, "cmn %r0, %r3" },
|
||||||
{0xffc0, 0x4300, "orr %r0, %r3"},
|
{ 0xffc0, 0x4300, "orr %r0, %r3" },
|
||||||
{0xffc0, 0x4340, "mul %r0, %r3"},
|
{ 0xffc0, 0x4340, "mul %r0, %r3" },
|
||||||
{0xffc0, 0x4380, "bic %r0, %r3"},
|
{ 0xffc0, 0x4380, "bic %r0, %r3" },
|
||||||
{0xffc0, 0x43c0, "mvn %r0, %r3"},
|
{ 0xffc0, 0x43c0, "mvn %r0, %r3" },
|
||||||
// Format 5
|
// Format 5
|
||||||
{0xff80, 0x4700, "bx %h36"},
|
{ 0xff80, 0x4700, "bx %h36" },
|
||||||
{0xfcc0, 0x4400, "[ ??? ]"},
|
{ 0xfcc0, 0x4400, "[ ??? ]" },
|
||||||
{0xff00, 0x4400, "add %h07, %h36"},
|
{ 0xff00, 0x4400, "add %h07, %h36" },
|
||||||
{0xff00, 0x4500, "cmp %h07, %h36"},
|
{ 0xff00, 0x4500, "cmp %h07, %h36" },
|
||||||
{0xff00, 0x4600, "mov %h07, %h36"},
|
{ 0xff00, 0x4600, "mov %h07, %h36" },
|
||||||
// Format 6
|
// Format 6
|
||||||
{0xf800, 0x4800, "ldr %r8, [%I] (=%J)"},
|
{ 0xf800, 0x4800, "ldr %r8, [%I] (=%J)" },
|
||||||
// Format 7
|
// Format 7
|
||||||
{0xfa00, 0x5000, "str%b %r0, [%r3, %r6]"},
|
{ 0xfa00, 0x5000, "str%b %r0, [%r3, %r6]" },
|
||||||
{0xfa00, 0x5800, "ldr%b %r0, [%r3, %r6]"},
|
{ 0xfa00, 0x5800, "ldr%b %r0, [%r3, %r6]" },
|
||||||
// Format 8
|
// Format 8
|
||||||
{0xfe00, 0x5200, "strh %r0, [%r3, %r6]"},
|
{ 0xfe00, 0x5200, "strh %r0, [%r3, %r6]" },
|
||||||
{0xfe00, 0x5600, "ldsb %r0, [%r3, %r6]"},
|
{ 0xfe00, 0x5600, "ldsb %r0, [%r3, %r6]" },
|
||||||
{0xfe00, 0x5a00, "ldrh %r0, [%r3, %r6]"},
|
{ 0xfe00, 0x5a00, "ldrh %r0, [%r3, %r6]" },
|
||||||
{0xfe00, 0x5e00, "ldsh %r0, [%r3, %r6]"},
|
{ 0xfe00, 0x5e00, "ldsh %r0, [%r3, %r6]" },
|
||||||
// Format 9
|
// Format 9
|
||||||
{0xe800, 0x6000, "str%B %r0, [%r3, %p]"},
|
{ 0xe800, 0x6000, "str%B %r0, [%r3, %p]" },
|
||||||
{0xe800, 0x6800, "ldr%B %r0, [%r3, %p]"},
|
{ 0xe800, 0x6800, "ldr%B %r0, [%r3, %p]" },
|
||||||
// Format 10
|
// Format 10
|
||||||
{0xf800, 0x8000, "strh %r0, [%r3, %e]"},
|
{ 0xf800, 0x8000, "strh %r0, [%r3, %e]" },
|
||||||
{0xf800, 0x8800, "ldrh %r0, [%r3, %e]"},
|
{ 0xf800, 0x8800, "ldrh %r0, [%r3, %e]" },
|
||||||
// Format 11
|
// Format 11
|
||||||
{0xf800, 0x9000, "str %r8, [sp, %w]"},
|
{ 0xf800, 0x9000, "str %r8, [sp, %w]" },
|
||||||
{0xf800, 0x9800, "ldr %r8, [sp, %w]"},
|
{ 0xf800, 0x9800, "ldr %r8, [sp, %w]" },
|
||||||
// Format 12
|
// Format 12
|
||||||
{0xf800, 0xa000, "add %r8, pc, %w (=%K)"},
|
{ 0xf800, 0xa000, "add %r8, pc, %w (=%K)" },
|
||||||
{0xf800, 0xa800, "add %r8, sp, %w"},
|
{ 0xf800, 0xa800, "add %r8, sp, %w" },
|
||||||
// Format 13
|
// Format 13
|
||||||
{0xff00, 0xb000, "add sp, %s"},
|
{ 0xff00, 0xb000, "add sp, %s" },
|
||||||
// Format 14
|
// Format 14
|
||||||
{0xffff, 0xb500, "push {lr}"},
|
{ 0xffff, 0xb500, "push {lr}" },
|
||||||
{0xff00, 0xb400, "push {%l}"},
|
{ 0xff00, 0xb400, "push {%l}" },
|
||||||
{0xff00, 0xb500, "push {%l,lr}"},
|
{ 0xff00, 0xb500, "push {%l,lr}" },
|
||||||
{0xffff, 0xbd00, "pop {pc}"},
|
{ 0xffff, 0xbd00, "pop {pc}" },
|
||||||
{0xff00, 0xbd00, "pop {%l,pc}"},
|
{ 0xff00, 0xbd00, "pop {%l,pc}" },
|
||||||
{0xff00, 0xbc00, "pop {%l}"},
|
{ 0xff00, 0xbc00, "pop {%l}" },
|
||||||
// Format 15
|
// Format 15
|
||||||
{0xf800, 0xc000, "stmia %r8!, {%l}"},
|
{ 0xf800, 0xc000, "stmia %r8!, {%l}" },
|
||||||
{0xf800, 0xc800, "ldmia %r8!, {%l}"},
|
{ 0xf800, 0xc800, "ldmia %r8!, {%l}" },
|
||||||
// Format 17
|
// Format 17
|
||||||
{0xff00, 0xdf00, "swi %m"},
|
{ 0xff00, 0xdf00, "swi %m" },
|
||||||
// Format 16
|
// Format 16
|
||||||
{0xf000, 0xd000, "b%c %W"},
|
{ 0xf000, 0xd000, "b%c %W" },
|
||||||
// Format 18
|
// Format 18
|
||||||
{0xf800, 0xe000, "b %a"},
|
{ 0xf800, 0xe000, "b %a" },
|
||||||
// Format 19
|
// Format 19
|
||||||
{0xf800, 0xf000, "bl %A"},
|
{ 0xf800, 0xf000, "bl %A" },
|
||||||
{0xf800, 0xf800, "blh %Z"},
|
{ 0xf800, 0xf800, "blh %Z" },
|
||||||
{0xff00, 0xbe00, "bkpt %O"},
|
{ 0xff00, 0xbe00, "bkpt %O" },
|
||||||
// Unknown
|
// Unknown
|
||||||
{0x0000, 0x0000, "[ ??? ]"}
|
{ 0x0000, 0x0000, "[ ??? ]" }
|
||||||
};
|
};
|
||||||
|
|
||||||
const Opcodes armOpcodes[] = {
|
const Opcodes armOpcodes[] = {
|
||||||
// Undefined
|
// Undefined
|
||||||
{0x0e000010, 0x06000010, "[ undefined ]"},
|
{ 0x0e000010, 0x06000010, "[ undefined ]" },
|
||||||
// Branch instructions
|
// Branch instructions
|
||||||
{0x0ff000f0, 0x01200010, "bx%c %r0"},
|
{ 0x0ff000f0, 0x01200010, "bx%c %r0" },
|
||||||
{0x0f000000, 0x0a000000, "b%c %o"},
|
{ 0x0f000000, 0x0a000000, "b%c %o" },
|
||||||
{0x0f000000, 0x0b000000, "bl%c %o"},
|
{ 0x0f000000, 0x0b000000, "bl%c %o" },
|
||||||
{0x0f000000, 0x0f000000, "swi%c %q"},
|
{ 0x0f000000, 0x0f000000, "swi%c %q" },
|
||||||
// PSR transfer
|
// PSR transfer
|
||||||
{0x0fbf0fff, 0x010f0000, "mrs%c %r3, %p"},
|
{ 0x0fbf0fff, 0x010f0000, "mrs%c %r3, %p" },
|
||||||
{0x0db0f000, 0x0120f000, "msr%c %p, %i"},
|
{ 0x0db0f000, 0x0120f000, "msr%c %p, %i" },
|
||||||
// Multiply instructions
|
// Multiply instructions
|
||||||
{0x0fe000f0, 0x00000090, "mul%c%s %r4, %r0, %r2"},
|
{ 0x0fe000f0, 0x00000090, "mul%c%s %r4, %r0, %r2" },
|
||||||
{0x0fe000f0, 0x00200090, "mla%c%s %r4, %r0, %r2, %r3"},
|
{ 0x0fe000f0, 0x00200090, "mla%c%s %r4, %r0, %r2, %r3" },
|
||||||
{0x0fa000f0, 0x00800090, "%umull%c%s %r3, %r4, %r0, %r2"},
|
{ 0x0fa000f0, 0x00800090, "%umull%c%s %r3, %r4, %r0, %r2" },
|
||||||
{0x0fa000f0, 0x00a00090, "%umlal%c%s %r3, %r4, %r0, %r2"},
|
{ 0x0fa000f0, 0x00a00090, "%umlal%c%s %r3, %r4, %r0, %r2" },
|
||||||
// Load/Store instructions
|
// Load/Store instructions
|
||||||
{0x0fb00ff0, 0x01000090, "swp%c%b %r3, %r0, [%r4]"},
|
{ 0x0fb00ff0, 0x01000090, "swp%c%b %r3, %r0, [%r4]" },
|
||||||
{0x0fb000f0, 0x01000090, "[ ??? ]"},
|
{ 0x0fb000f0, 0x01000090, "[ ??? ]" },
|
||||||
{0x0c100000, 0x04000000, "str%c%b%t %r3, %a"},
|
{ 0x0c100000, 0x04000000, "str%c%b%t %r3, %a" },
|
||||||
{0x0c100000, 0x04100000, "ldr%c%b%t %r3, %a"},
|
{ 0x0c100000, 0x04100000, "ldr%c%b%t %r3, %a" },
|
||||||
{0x0e100090, 0x00000090, "str%c%h %r3, %a"},
|
{ 0x0e100090, 0x00000090, "str%c%h %r3, %a" },
|
||||||
{0x0e100090, 0x00100090, "ldr%c%h %r3, %a"},
|
{ 0x0e100090, 0x00100090, "ldr%c%h %r3, %a" },
|
||||||
{0x0e100000, 0x08000000, "stm%c%m %r4%l"},
|
{ 0x0e100000, 0x08000000, "stm%c%m %r4%l" },
|
||||||
{0x0e100000, 0x08100000, "ldm%c%m %r4%l"},
|
{ 0x0e100000, 0x08100000, "ldm%c%m %r4%l" },
|
||||||
// Data processing
|
// Data processing
|
||||||
{0x0de00000, 0x00000000, "and%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00000000, "and%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00200000, "eor%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00200000, "eor%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00400000, "sub%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00400000, "sub%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00600000, "rsb%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00600000, "rsb%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00800000, "add%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00800000, "add%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00a00000, "adc%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00a00000, "adc%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00c00000, "sbc%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00c00000, "sbc%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x00e00000, "rsc%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x00e00000, "rsc%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x01000000, "tst%c%s %r4, %i"},
|
{ 0x0de00000, 0x01000000, "tst%c%s %r4, %i" },
|
||||||
{0x0de00000, 0x01200000, "teq%c%s %r4, %i"},
|
{ 0x0de00000, 0x01200000, "teq%c%s %r4, %i" },
|
||||||
{0x0de00000, 0x01400000, "cmp%c%s %r4, %i"},
|
{ 0x0de00000, 0x01400000, "cmp%c%s %r4, %i" },
|
||||||
{0x0de00000, 0x01600000, "cmn%c%s %r4, %i"},
|
{ 0x0de00000, 0x01600000, "cmn%c%s %r4, %i" },
|
||||||
{0x0de00000, 0x01800000, "orr%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x01800000, "orr%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x01a00000, "mov%c%s %r3, %i"},
|
{ 0x0de00000, 0x01a00000, "mov%c%s %r3, %i" },
|
||||||
{0x0de00000, 0x01c00000, "bic%c%s %r3, %r4, %i"},
|
{ 0x0de00000, 0x01c00000, "bic%c%s %r3, %r4, %i" },
|
||||||
{0x0de00000, 0x01e00000, "mvn%c%s %r3, %i"},
|
{ 0x0de00000, 0x01e00000, "mvn%c%s %r3, %i" },
|
||||||
// Coprocessor operations
|
// Coprocessor operations
|
||||||
{0x0f000010, 0x0e000000, "cdp%c %P, %N, %r3, %R4, %R0%V"},
|
{ 0x0f000010, 0x0e000000, "cdp%c %P, %N, %r3, %R4, %R0%V" },
|
||||||
{0x0e100000, 0x0c000000, "stc%c%L %P, %r3, %A"},
|
{ 0x0e100000, 0x0c000000, "stc%c%L %P, %r3, %A" },
|
||||||
{0x0f100010, 0x0e000010, "mcr%c %P, %N, %r3, %R4, %R0%V"},
|
{ 0x0f100010, 0x0e000010, "mcr%c %P, %N, %r3, %R4, %R0%V" },
|
||||||
{0x0f100010, 0x0e100010, "mrc%c %P, %N, %r3, %R4, %R0%V"},
|
{ 0x0f100010, 0x0e100010, "mrc%c %P, %N, %r3, %R4, %R0%V" },
|
||||||
// Unknown
|
// Unknown
|
||||||
{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))
|
||||||
siz -= 4;
|
siz -= 4;
|
||||||
siz += 4;
|
siz += 4;
|
||||||
}
|
}
|
||||||
while (siz>0){
|
while (siz > 0) {
|
||||||
siz -= 4;
|
siz -= 4;
|
||||||
*dest++ = hdig[(val>>siz)&15];
|
*dest++ = hdig[(val >> siz) & 15];
|
||||||
}
|
}
|
||||||
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;
|
||||||
while( sp->cval != (opcode & sp->mask) )
|
while (sp->cval != (opcode & sp->mask))
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
if (flags&DIS_VIEW_ADDRESS){
|
if (flags & DIS_VIEW_ADDRESS) {
|
||||||
dest = addHex(dest, 32, offset);
|
dest = addHex(dest, 32, offset);
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
}
|
}
|
||||||
if (flags&DIS_VIEW_CODE){
|
if (flags & DIS_VIEW_CODE) {
|
||||||
dest = addHex(dest, 32, opcode);
|
dest = addHex(dest, 32, opcode);
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *src = sp->mnemonic;
|
const char* src = sp->mnemonic;
|
||||||
while (*src){
|
while (*src) {
|
||||||
if (*src!='%')
|
if (*src != '%')
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
else{
|
else {
|
||||||
src++;
|
src++;
|
||||||
switch (*src){
|
switch (*src) {
|
||||||
case 'c':
|
case 'c':
|
||||||
dest = addStr(dest, conditions[opcode>>28]);
|
dest = addStr(dest, conditions[opcode >> 28]);
|
||||||
break;
|
break;
|
||||||
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");
|
||||||
int imm = opcode&0xff;
|
int imm = opcode & 0xff;
|
||||||
int rot = (opcode&0xf00)>>7;
|
int rot = (opcode & 0xf00) >> 7;
|
||||||
int val = (imm<<(32-rot))|(imm>>rot);
|
int val = (imm << (32 - rot)) | (imm >> rot);
|
||||||
dest = addHex(dest, 0, val);
|
dest = addHex(dest, 0, val);
|
||||||
} else{
|
} else {
|
||||||
dest = addStr(dest, regs[opcode&0x0f]);
|
dest = addStr(dest, regs[opcode & 0x0f]);
|
||||||
int shi = (opcode>>5)&3;
|
int shi = (opcode >> 5) & 3;
|
||||||
int sdw = (opcode>>7)&0x1f;
|
int sdw = (opcode >> 7) & 0x1f;
|
||||||
if ((sdw==0)&&(shi==3))
|
if ((sdw == 0) && (shi == 3))
|
||||||
shi = 4;
|
shi = 4;
|
||||||
if ( (sdw) || (opcode&0x10) || (shi)) {
|
if ((sdw) || (opcode & 0x10) || (shi)) {
|
||||||
dest = addStr(dest, ", ");
|
dest = addStr(dest, ", ");
|
||||||
dest = addStr(dest, shifts[shi]);
|
dest = addStr(dest, shifts[shi]);
|
||||||
if (opcode&0x10){
|
if (opcode & 0x10) {
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
dest = addStr(dest, regs[(opcode>>8)&15]);
|
dest = addStr(dest, regs[(opcode >> 8) & 15]);
|
||||||
} else {
|
} else {
|
||||||
if (sdw==0 && ( (shi==1) || (shi==2) ))
|
if (sdw == 0 && ((shi == 1) || (shi == 2)))
|
||||||
sdw = 32;
|
sdw = 32;
|
||||||
if(shi != 4) {
|
if (shi != 4) {
|
||||||
dest = addStr(dest, " #0x");
|
dest = addStr(dest, " #0x");
|
||||||
dest = addHex(dest, 8, sdw);
|
dest = addHex(dest, 8, sdw);
|
||||||
}
|
}
|
||||||
|
@ -282,47 +283,47 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (opcode&(1<<22))
|
if (opcode & (1 << 22))
|
||||||
dest = addStr(dest, "spsr");
|
dest = addStr(dest, "spsr");
|
||||||
else
|
else
|
||||||
dest = addStr(dest, "cpsr");
|
dest = addStr(dest, "cpsr");
|
||||||
if(opcode & 0x00F00000) {
|
if (opcode & 0x00F00000) {
|
||||||
*dest++ = '_';
|
*dest++ = '_';
|
||||||
if(opcode & 0x00080000)
|
if (opcode & 0x00080000)
|
||||||
*dest++ = 'f';
|
*dest++ = 'f';
|
||||||
if(opcode & 0x00040000)
|
if (opcode & 0x00040000)
|
||||||
*dest++ = 's';
|
*dest++ = 's';
|
||||||
if(opcode & 0x00020000)
|
if (opcode & 0x00020000)
|
||||||
*dest++ = 'x';
|
*dest++ = 'x';
|
||||||
if(opcode & 0x00010000)
|
if (opcode & 0x00010000)
|
||||||
*dest++ = 'c';
|
*dest++ = 'c';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (opcode&(1<<20))
|
if (opcode & (1 << 20))
|
||||||
*dest++ = 's';
|
*dest++ = 's';
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (opcode&(1<<22))
|
if (opcode & (1 << 22))
|
||||||
*dest++ = 's';
|
*dest++ = 's';
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
if (opcode&(1<<22))
|
if (opcode & (1 << 22))
|
||||||
*dest++ = 's';
|
*dest++ = 's';
|
||||||
else
|
else
|
||||||
*dest++ = 'u';
|
*dest++ = 'u';
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
if (opcode&(1<<22))
|
if (opcode & (1 << 22))
|
||||||
*dest++ = 'b';
|
*dest++ = 'b';
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
if ((opcode&0x076f0000)==0x004f0000){
|
if ((opcode & 0x076f0000) == 0x004f0000) {
|
||||||
*dest++ = '[';
|
*dest++ = '[';
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
int adr = offset+8;
|
int adr = offset + 8;
|
||||||
int add = (opcode&15)|((opcode>>8)&0xf0);
|
int add = (opcode & 15) | ((opcode >> 8) & 0xf0);
|
||||||
if (opcode&(1<<23))
|
if (opcode & (1 << 23))
|
||||||
adr += add;
|
adr += add;
|
||||||
else
|
else
|
||||||
adr -= add;
|
adr -= add;
|
||||||
|
@ -330,45 +331,45 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
*dest++ = ']';
|
*dest++ = ']';
|
||||||
dest = addStr(dest, " (=");
|
dest = addStr(dest, " (=");
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest ,32, debuggerReadMemory(adr));
|
dest = addHex(dest, 32, debuggerReadMemory(adr));
|
||||||
*dest++=')';
|
*dest++ = ')';
|
||||||
}
|
}
|
||||||
if ((opcode&0x072f0000)==0x050f0000){
|
if ((opcode & 0x072f0000) == 0x050f0000) {
|
||||||
*dest++ = '[';
|
*dest++ = '[';
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
int adr = offset+8;
|
int adr = offset + 8;
|
||||||
if (opcode&(1<<23))
|
if (opcode & (1 << 23))
|
||||||
adr += opcode&0xfff;
|
adr += opcode & 0xfff;
|
||||||
else
|
else
|
||||||
adr -= opcode&0xfff;
|
adr -= opcode & 0xfff;
|
||||||
dest = addHex(dest, 32, adr);
|
dest = addHex(dest, 32, adr);
|
||||||
*dest++ = ']';
|
*dest++ = ']';
|
||||||
dest = addStr(dest, " (=");
|
dest = addStr(dest, " (=");
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest ,32, debuggerReadMemory(adr));
|
dest = addHex(dest, 32, debuggerReadMemory(adr));
|
||||||
*dest++=')';
|
*dest++ = ')';
|
||||||
} else {
|
} else {
|
||||||
int reg = (opcode>>16)&15;
|
int reg = (opcode >> 16) & 15;
|
||||||
*dest++ = '[';
|
*dest++ = '[';
|
||||||
dest = addStr(dest, regs[reg]);
|
dest = addStr(dest, regs[reg]);
|
||||||
if (!(opcode&(1<<24)))
|
if (!(opcode & (1 << 24)))
|
||||||
*dest++ = ']';
|
*dest++ = ']';
|
||||||
if ( ((opcode&(1<<25))&&(opcode&(1<<26))) || (!(opcode&(1<<22))&&!(opcode&(1<<26))) ){
|
if (((opcode & (1 << 25)) && (opcode & (1 << 26))) || (!(opcode & (1 << 22)) && !(opcode & (1 << 26)))) {
|
||||||
dest = addStr(dest, ", ");
|
dest = addStr(dest, ", ");
|
||||||
if (!(opcode&(1<<23)))
|
if (!(opcode & (1 << 23)))
|
||||||
*dest++ = '-';
|
*dest++ = '-';
|
||||||
dest = addStr(dest, regs[opcode&0x0f]);
|
dest = addStr(dest, regs[opcode & 0x0f]);
|
||||||
int shi = (opcode>>5)&3;
|
int shi = (opcode >> 5) & 3;
|
||||||
if (opcode&(1<<26)){
|
if (opcode & (1 << 26)) {
|
||||||
if ( ((opcode>>7)&0x1f) || (opcode&0x10) || (shi==1) || (shi==2)){
|
if (((opcode >> 7) & 0x1f) || (opcode & 0x10) || (shi == 1) || (shi == 2)) {
|
||||||
dest = addStr(dest, ", ");
|
dest = addStr(dest, ", ");
|
||||||
dest = addStr(dest, shifts[shi]);
|
dest = addStr(dest, shifts[shi]);
|
||||||
if (opcode&0x10){
|
if (opcode & 0x10) {
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
dest = addStr(dest, regs[(opcode>>8)&15]);
|
dest = addStr(dest, regs[(opcode >> 8) & 15]);
|
||||||
} else {
|
} else {
|
||||||
int sdw = (opcode>>7)&0x1f;
|
int sdw = (opcode >> 7) & 0x1f;
|
||||||
if (sdw==0 && ( (shi==1) || (shi==2) ))
|
if (sdw == 0 && ((shi == 1) || (shi == 2)))
|
||||||
sdw = 32;
|
sdw = 32;
|
||||||
dest = addStr(dest, " #0x");
|
dest = addStr(dest, " #0x");
|
||||||
dest = addHex(dest, 8, sdw);
|
dest = addHex(dest, 8, sdw);
|
||||||
|
@ -377,66 +378,66 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int off;
|
int off;
|
||||||
if (opcode&(1<<26))
|
if (opcode & (1 << 26))
|
||||||
off = opcode&0xfff;
|
off = opcode & 0xfff;
|
||||||
else
|
else
|
||||||
off = (opcode&15)|((opcode>>4)&0xf0);
|
off = (opcode & 15) | ((opcode >> 4) & 0xf0);
|
||||||
if (off){
|
if (off) {
|
||||||
dest = addStr(dest, ", ");
|
dest = addStr(dest, ", ");
|
||||||
if (!(opcode&(1<<23)))
|
if (!(opcode & (1 << 23)))
|
||||||
*dest++ = '-';
|
*dest++ = '-';
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, off);
|
dest = addHex(dest, 0, off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opcode&(1<<24)){
|
if (opcode & (1 << 24)) {
|
||||||
*dest++ = ']';
|
*dest++ = ']';
|
||||||
if (opcode&(1<<21))
|
if (opcode & (1 << 21))
|
||||||
*dest++ = '!';
|
*dest++ = '!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if ((opcode&0x01200000)==0x01200000)
|
if ((opcode & 0x01200000) == 0x01200000)
|
||||||
*dest++ = 't';
|
*dest++ = 't';
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
if (opcode&(1<<6))
|
if (opcode & (1 << 6))
|
||||||
*dest++ = 's';
|
*dest++ = 's';
|
||||||
if (opcode&(1<<5))
|
if (opcode & (1 << 5))
|
||||||
*dest++ = 'h';
|
*dest++ = 'h';
|
||||||
else
|
else
|
||||||
*dest++ = 'b';
|
*dest++ = 'b';
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (((opcode>>16)&15)==13) {
|
if (((opcode >> 16) & 15) == 13) {
|
||||||
if(opcode & 0x00100000)
|
if (opcode & 0x00100000)
|
||||||
dest = addStr(dest, armMultLoadStore[8+((opcode>>23)&3)]);
|
dest = addStr(dest, armMultLoadStore[8 + ((opcode >> 23) & 3)]);
|
||||||
else
|
else
|
||||||
dest = addStr(dest, armMultLoadStore[4+((opcode>>23)&3)]);
|
dest = addStr(dest, armMultLoadStore[4 + ((opcode >> 23) & 3)]);
|
||||||
} else
|
} else
|
||||||
dest = addStr(dest, armMultLoadStore[(opcode>>23)&3]);
|
dest = addStr(dest, armMultLoadStore[(opcode >> 23) & 3]);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (opcode&(1<<21))
|
if (opcode & (1 << 21))
|
||||||
*dest++ = '!';
|
*dest++ = '!';
|
||||||
dest = addStr(dest, ", {");
|
dest = addStr(dest, ", {");
|
||||||
{
|
{
|
||||||
int rlst = opcode&0xffff;
|
int rlst = opcode & 0xffff;
|
||||||
int msk = 0;
|
int msk = 0;
|
||||||
int not_first = 0;
|
int not_first = 0;
|
||||||
while (msk<16){
|
while (msk < 16) {
|
||||||
if (rlst&(1<<msk)){
|
if (rlst & (1 << msk)) {
|
||||||
int fr = msk;
|
int fr = msk;
|
||||||
while (rlst&(1<<msk))
|
while (rlst & (1 << msk))
|
||||||
msk++;
|
msk++;
|
||||||
int to = msk-1;
|
int to = msk - 1;
|
||||||
if (not_first)
|
if (not_first)
|
||||||
//dest = addStr(dest, ", ");
|
//dest = addStr(dest, ", ");
|
||||||
*dest++ = ',';
|
*dest++ = ',';
|
||||||
dest = addStr(dest, regs[fr]);
|
dest = addStr(dest, regs[fr]);
|
||||||
if (fr!=to){
|
if (fr != to) {
|
||||||
if (fr==to-1)
|
if (fr == to - 1)
|
||||||
//dest = addStr(", ");
|
//dest = addStr(", ");
|
||||||
*dest++ = ',';
|
*dest++ = ',';
|
||||||
else
|
else
|
||||||
|
@ -448,50 +449,46 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
msk++;
|
msk++;
|
||||||
}
|
}
|
||||||
*dest++ = '}';
|
*dest++ = '}';
|
||||||
if (opcode&(1<<22))
|
if (opcode & (1 << 22))
|
||||||
*dest++ = '^';
|
*dest++ = '^';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest, 24, opcode&0xffffff);
|
dest = addHex(dest, 24, opcode & 0xffffff);
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
*dest++ = 'p';
|
*dest++ = 'p';
|
||||||
dest = addStr(dest, decVals[(opcode>>8)&15]);
|
dest = addStr(dest, decVals[(opcode >> 8) & 15]);
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
if (opcode&0x10)
|
if (opcode & 0x10)
|
||||||
dest = addStr(dest, decVals[(opcode>>21)&7]);
|
dest = addStr(dest, decVals[(opcode >> 21) & 7]);
|
||||||
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;
|
||||||
{
|
if (val) {
|
||||||
int val = (opcode>>5)&7;
|
|
||||||
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';
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
if ((opcode&0x012f0000)==0x010f0000){
|
if ((opcode & 0x012f0000) == 0x010f0000) {
|
||||||
int adr = offset+8;
|
int adr = offset + 8;
|
||||||
int add = (opcode&0xff)<<2;
|
int add = (opcode & 0xff) << 2;
|
||||||
if (opcode&(1<<23))
|
if (opcode & (1 << 23))
|
||||||
adr += add;
|
adr += add;
|
||||||
else
|
else
|
||||||
adr -= add;
|
adr -= add;
|
||||||
|
@ -499,20 +496,20 @@ int disArm(u32 offset, char *dest, int flags){
|
||||||
addHex(dest, 32, adr);
|
addHex(dest, 32, adr);
|
||||||
} else {
|
} else {
|
||||||
*dest++ = '[';
|
*dest++ = '[';
|
||||||
dest = addStr(dest, regs[(opcode>>16)&15]);
|
dest = addStr(dest, regs[(opcode >> 16) & 15]);
|
||||||
if (!(opcode&(1<<24)))
|
if (!(opcode & (1 << 24)))
|
||||||
*dest++ = ']';
|
*dest++ = ']';
|
||||||
int off = (opcode&0xff)<<2;
|
int off = (opcode & 0xff) << 2;
|
||||||
if (off){
|
if (off) {
|
||||||
dest = addStr(dest, ", ");
|
dest = addStr(dest, ", ");
|
||||||
if (!(opcode&(1<<23)))
|
if (!(opcode & (1 << 23)))
|
||||||
*dest++ = '-';
|
*dest++ = '-';
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, off);
|
dest = addHex(dest, 0, off);
|
||||||
}
|
}
|
||||||
if (opcode&(1<<24)){
|
if (opcode & (1 << 24)) {
|
||||||
*dest++ = ']';
|
*dest++ = ']';
|
||||||
if (opcode&(1<<21))
|
if (opcode & (1 << 21))
|
||||||
*dest++ = '!';
|
*dest++ = '!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,147 +523,140 @@ 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;
|
||||||
int ret = 2;
|
int ret = 2;
|
||||||
while( sp->cval != (opcode & sp->mask) )
|
while (sp->cval != (opcode & sp->mask))
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
if (flags&DIS_VIEW_ADDRESS){
|
if (flags & DIS_VIEW_ADDRESS) {
|
||||||
dest = addHex(dest, 32, offset);
|
dest = addHex(dest, 32, offset);
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
}
|
}
|
||||||
if (flags&DIS_VIEW_CODE){
|
if (flags & DIS_VIEW_CODE) {
|
||||||
dest = addHex(dest, 16, opcode);
|
dest = addHex(dest, 16, opcode);
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *src = sp->mnemonic;
|
const char* src = sp->mnemonic;
|
||||||
while (*src){
|
while (*src) {
|
||||||
if (*src!='%')
|
if (*src != '%')
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
else {
|
else {
|
||||||
src++;
|
src++;
|
||||||
switch (*src){
|
switch (*src) {
|
||||||
case 'r':
|
case 'r':
|
||||||
src++;
|
src++;
|
||||||
dest = addStr(dest, regs[(opcode>>(*src-'0'))&7]);
|
dest = addStr(dest, regs[(opcode >> (*src - '0')) & 7]);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
{
|
{
|
||||||
int val = (opcode>>6)&0x1f;
|
int val = (opcode >> 6) & 0x1f;
|
||||||
dest = addHex(dest, 8, val);
|
dest = addHex(dest, 8, val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
{
|
{
|
||||||
int val = (opcode>>6)&0x1f;
|
int val = (opcode >> 6) & 0x1f;
|
||||||
if (!(opcode&(1<<12)))
|
if (!(opcode & (1 << 12)))
|
||||||
val <<= 2;
|
val <<= 2;
|
||||||
dest = addHex(dest, 0, val);
|
dest = addHex(dest, 0, val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, ((opcode>>6)&0x1f)<<1);
|
dest = addHex(dest, 0, ((opcode >> 6) & 0x1f) << 1);
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
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));
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
*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);
|
||||||
if(*s) {
|
if (*s) {
|
||||||
*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);
|
||||||
const char *s = elfGetAddressSymbol(value);
|
const char* s = elfGetAddressSymbol(value);
|
||||||
if(*s) {
|
if (*s) {
|
||||||
*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';
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
if (opcode&(1<<12))
|
if (opcode & (1 << 12))
|
||||||
*dest++ = 'b';
|
*dest++ = 'b';
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
dest = addStr(dest, "#0x");
|
dest = addStr(dest, "#0x");
|
||||||
dest = addHex(dest, 0, (opcode&0xff)<<2);
|
dest = addHex(dest, 0, (opcode & 0xff) << 2);
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
{
|
{
|
||||||
int add = opcode&0xff;
|
int add = opcode & 0xff;
|
||||||
if (add&0x80)
|
if (add & 0x80)
|
||||||
add |= 0xffffff00;
|
add |= 0xffffff00;
|
||||||
dest = addHex(dest, 32, (offset&0xfffffffe)+4+(add<<1));
|
dest = addHex(dest, 32, (offset & 0xfffffffe) + 4 + (add << 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
dest = addStr(dest, conditions[(opcode>>8)&15]);
|
dest = addStr(dest, conditions[(opcode >> 8) & 15]);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (opcode&(1<<7))
|
if (opcode & (1 << 7))
|
||||||
*dest++ = '-';
|
*dest++ = '-';
|
||||||
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;
|
||||||
while (msk<8){
|
while (msk < 8) {
|
||||||
if (rlst&(1<<msk)){
|
if (rlst & (1 << msk)) {
|
||||||
int fr = msk;
|
int fr = msk;
|
||||||
while (rlst&(1<<msk))
|
while (rlst & (1 << msk))
|
||||||
msk++;
|
msk++;
|
||||||
int to = msk-1;
|
int to = msk - 1;
|
||||||
if (not_first)
|
if (not_first)
|
||||||
*dest++ = ',';
|
*dest++ = ',';
|
||||||
dest = addStr(dest, regs[fr]);
|
dest = addStr(dest, regs[fr]);
|
||||||
if (fr!=to){
|
if (fr != to) {
|
||||||
if (fr==to-1)
|
if (fr == to - 1)
|
||||||
*dest++ = ',';
|
*dest++ = ',';
|
||||||
else
|
else
|
||||||
*dest++ = '-';
|
*dest++ = '-';
|
||||||
|
@ -676,45 +666,42 @@ 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);
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest, 16, (opcode&0x7ff)<<1);
|
dest = addHex(dest, 16, (opcode & 0x7ff) << 1);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
{
|
{
|
||||||
int add = opcode&0x07ff;
|
int add = opcode & 0x07ff;
|
||||||
if (add&0x400)
|
if (add & 0x400)
|
||||||
add |= 0xfffff800;
|
add |= 0xfffff800;
|
||||||
add <<= 1;
|
add <<= 1;
|
||||||
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)
|
|
||||||
add |= 0xfff800;
|
add |= 0xfff800;
|
||||||
add = (add<<12)|((nopcode&0x7ff)<<1);
|
add = (add << 12) | ((nopcode & 0x7ff) << 1);
|
||||||
*dest++ = '$';
|
*dest++ = '$';
|
||||||
dest = addHex(dest,32, offset+4+add);
|
dest = addHex(dest, 32, offset + 4 + add);
|
||||||
const char *s = elfGetAddressSymbol(offset+4+add);
|
const char* s = elfGetAddressSymbol(offset + 4 + add);
|
||||||
if(*s) {
|
if (*s) {
|
||||||
*dest++ = ' ';
|
*dest++ = ' ';
|
||||||
*dest++ = '(';
|
*dest++ = '(';
|
||||||
dest = addStr(dest, s);
|
dest = addStr(dest, s);
|
||||||
*dest++ = ')';
|
*dest++ = ')';
|
||||||
}
|
}
|
||||||
ret = 4;
|
ret = 4;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#define DIS_VIEW_ADDRESS 1
|
#define DIS_VIEW_ADDRESS 1
|
||||||
#define DIS_VIEW_CODE 2
|
#define DIS_VIEW_CODE 2
|
||||||
|
|
||||||
int disThumb(u32 offset, char *dest, int flags);
|
int disThumb(u32 offset, char* dest, int flags);
|
||||||
int disArm(u32 offset, char *dest, int flags);
|
int disArm(u32 offset, char* dest, int flags);
|
||||||
|
|
||||||
#endif // __ARMDIS_H__
|
#endif // __ARMDIS_H__
|
||||||
|
|
840
src/gba/bios.cpp
840
src/gba/bios.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1382
src/gba/elf.cpp
1382
src/gba/elf.cpp
File diff suppressed because it is too large
Load Diff
138
src/gba/elf.h
138
src/gba/elf.h
|
@ -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
|
||||||
|
@ -64,7 +66,7 @@ struct ELFSymbol {
|
||||||
|
|
||||||
struct ELFBlock {
|
struct ELFBlock {
|
||||||
int length;
|
int length;
|
||||||
u8 *data;
|
u8* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ELFAttr {
|
struct ELFAttr {
|
||||||
|
@ -72,10 +74,10 @@ struct ELFAttr {
|
||||||
u32 form;
|
u32 form;
|
||||||
union {
|
union {
|
||||||
u32 value;
|
u32 value;
|
||||||
char *string;
|
char* string;
|
||||||
u8 *data;
|
u8* data;
|
||||||
bool flag;
|
bool flag;
|
||||||
ELFBlock *block;
|
ELFBlock* block;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,8 +86,8 @@ struct ELFAbbrev {
|
||||||
u32 tag;
|
u32 tag;
|
||||||
bool hasChildren;
|
bool hasChildren;
|
||||||
int numAttrs;
|
int numAttrs;
|
||||||
ELFAttr *attrs;
|
ELFAttr* attrs;
|
||||||
ELFAbbrev *next;
|
ELFAbbrev* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TypeEnum {
|
enum TypeEnum {
|
||||||
|
@ -104,94 +106,94 @@ struct Type;
|
||||||
struct Object;
|
struct Object;
|
||||||
|
|
||||||
struct FunctionType {
|
struct FunctionType {
|
||||||
Type *returnType;
|
Type* returnType;
|
||||||
Object *args;
|
Object* args;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Member {
|
struct Member {
|
||||||
char *name;
|
char* name;
|
||||||
Type *type;
|
Type* type;
|
||||||
int bitSize;
|
int bitSize;
|
||||||
int bitOffset;
|
int bitOffset;
|
||||||
int byteSize;
|
int byteSize;
|
||||||
ELFBlock *location;
|
ELFBlock* location;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Struct {
|
struct Struct {
|
||||||
int memberCount;
|
int memberCount;
|
||||||
Member *members;
|
Member* members;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Array {
|
struct Array {
|
||||||
Type *type;
|
Type* type;
|
||||||
int maxBounds;
|
int maxBounds;
|
||||||
int *bounds;
|
int* bounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EnumMember {
|
struct EnumMember {
|
||||||
char *name;
|
char* name;
|
||||||
u32 value;
|
u32 value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Enum {
|
struct Enum {
|
||||||
int count;
|
int count;
|
||||||
EnumMember *members;
|
EnumMember* members;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Type {
|
struct Type {
|
||||||
u32 offset;
|
u32 offset;
|
||||||
TypeEnum type;
|
TypeEnum type;
|
||||||
const char *name;
|
const char* name;
|
||||||
int encoding;
|
int encoding;
|
||||||
int size;
|
int size;
|
||||||
int bitSize;
|
int bitSize;
|
||||||
union {
|
union {
|
||||||
Type *pointer;
|
Type* pointer;
|
||||||
FunctionType *function;
|
FunctionType* function;
|
||||||
Array *array;
|
Array* array;
|
||||||
Struct *structure;
|
Struct* structure;
|
||||||
Enum *enumeration;
|
Enum* enumeration;
|
||||||
};
|
};
|
||||||
Type *next;
|
Type* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Object {
|
struct Object {
|
||||||
char *name;
|
char* name;
|
||||||
int file;
|
int file;
|
||||||
int line;
|
int line;
|
||||||
bool external;
|
bool external;
|
||||||
Type *type;
|
Type* type;
|
||||||
ELFBlock *location;
|
ELFBlock* location;
|
||||||
u32 startScope;
|
u32 startScope;
|
||||||
u32 endScope;
|
u32 endScope;
|
||||||
Object *next;
|
Object* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Function {
|
struct Function {
|
||||||
char *name;
|
char* name;
|
||||||
u32 lowPC;
|
u32 lowPC;
|
||||||
u32 highPC;
|
u32 highPC;
|
||||||
int file;
|
int file;
|
||||||
int line;
|
int line;
|
||||||
bool external;
|
bool external;
|
||||||
Type *returnType;
|
Type* returnType;
|
||||||
Object *parameters;
|
Object* parameters;
|
||||||
Object *variables;
|
Object* variables;
|
||||||
ELFBlock *frameBase;
|
ELFBlock* frameBase;
|
||||||
Function *next;
|
Function* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LineInfoItem {
|
struct LineInfoItem {
|
||||||
u32 address;
|
u32 address;
|
||||||
char *file;
|
char* file;
|
||||||
int line;
|
int line;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LineInfo {
|
struct LineInfo {
|
||||||
int fileCount;
|
int fileCount;
|
||||||
char **files;
|
char** files;
|
||||||
int number;
|
int number;
|
||||||
LineInfoItem *lines;
|
LineInfoItem* lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ARange {
|
struct ARange {
|
||||||
|
@ -202,40 +204,40 @@ struct ARange {
|
||||||
struct ARanges {
|
struct ARanges {
|
||||||
u32 offset;
|
u32 offset;
|
||||||
int count;
|
int count;
|
||||||
ARange *ranges;
|
ARange* ranges;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompileUnit {
|
struct CompileUnit {
|
||||||
u32 length;
|
u32 length;
|
||||||
u8 *top;
|
u8* top;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
ELFAbbrev **abbrevs;
|
ELFAbbrev** abbrevs;
|
||||||
ARanges *ranges;
|
ARanges* ranges;
|
||||||
char *name;
|
char* name;
|
||||||
char *compdir;
|
char* compdir;
|
||||||
u32 lowPC;
|
u32 lowPC;
|
||||||
u32 highPC;
|
u32 highPC;
|
||||||
bool hasLineInfo;
|
bool hasLineInfo;
|
||||||
u32 lineInfo;
|
u32 lineInfo;
|
||||||
LineInfo *lineInfoTable;
|
LineInfo* lineInfoTable;
|
||||||
Function *functions;
|
Function* functions;
|
||||||
Function *lastFunction;
|
Function* lastFunction;
|
||||||
Object *variables;
|
Object* variables;
|
||||||
Type *types;
|
Type* types;
|
||||||
CompileUnit *next;
|
CompileUnit* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebugInfo {
|
struct DebugInfo {
|
||||||
u8 *debugfile;
|
u8* debugfile;
|
||||||
u8 *abbrevdata;
|
u8* abbrevdata;
|
||||||
u8 *debugdata;
|
u8* debugdata;
|
||||||
u8 *infodata;
|
u8* infodata;
|
||||||
int numRanges;
|
int numRanges;
|
||||||
ARanges *ranges;
|
ARanges* ranges;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Symbol {
|
struct Symbol {
|
||||||
const char *name;
|
const char* name;
|
||||||
int type;
|
int type;
|
||||||
int binding;
|
int binding;
|
||||||
u32 address;
|
u32 address;
|
||||||
|
@ -243,19 +245,19 @@ struct Symbol {
|
||||||
u32 size;
|
u32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern u32 elfReadLEB128(u8 *, int *);
|
extern u32 elfReadLEB128(u8*, int*);
|
||||||
extern s32 elfReadSignedLEB128(u8 *, int *);
|
extern s32 elfReadSignedLEB128(u8*, int*);
|
||||||
extern bool elfRead(const char *, int &, FILE *f);
|
extern bool elfRead(const char*, int&, FILE* f);
|
||||||
extern bool elfGetSymbolAddress(const char *, u32 *, u32 *, int *);
|
extern bool elfGetSymbolAddress(const char*, u32*, u32*, int*);
|
||||||
extern const char *elfGetAddressSymbol(u32);
|
extern const char* elfGetAddressSymbol(u32);
|
||||||
extern const char *elfGetSymbol(int, u32 *, u32 *, int *);
|
extern const char* elfGetSymbol(int, u32*, u32*, int*);
|
||||||
extern void elfCleanUp();
|
extern void elfCleanUp();
|
||||||
extern bool elfGetCurrentFunction(u32, Function **, CompileUnit **c);
|
extern bool elfGetCurrentFunction(u32, Function**, CompileUnit** c);
|
||||||
extern bool elfGetObject(const char *, Function *, CompileUnit *, Object **);
|
extern bool elfGetObject(const char*, Function*, CompileUnit*, Object**);
|
||||||
extern bool elfFindLineInUnit(u32 *, CompileUnit *, int);
|
extern bool elfFindLineInUnit(u32*, CompileUnit*, int);
|
||||||
extern bool elfFindLineInModule(u32 *, const char *, int);
|
extern bool elfFindLineInModule(u32*, const char*, int);
|
||||||
u32 elfDecodeLocation(Function *, ELFBlock *, LocationType *);
|
u32 elfDecodeLocation(Function*, ELFBlock*, LocationType*);
|
||||||
u32 elfDecodeLocation(Function *, ELFBlock *, LocationType *, u32);
|
u32 elfDecodeLocation(Function*, ELFBlock*, LocationType*, u32);
|
||||||
int elfFindLine(CompileUnit *unit, Function *func, u32 addr, const char **);
|
int elfFindLine(CompileUnit* unit, Function* func, u32 addr, const char**);
|
||||||
|
|
||||||
#endif // ELF_H
|
#endif // ELF_H
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -84,7 +82,7 @@ int decodestate;
|
||||||
|
|
||||||
u32 GFpow;
|
u32 GFpow;
|
||||||
|
|
||||||
unsigned char *DotCodeData;
|
unsigned char* DotCodeData;
|
||||||
char filebuffer[2048];
|
char filebuffer[2048];
|
||||||
|
|
||||||
int dotcodesize;
|
int dotcodesize;
|
||||||
|
@ -96,8 +94,8 @@ int dotcodesize;
|
||||||
int CheckEReaderRegion(void) //US = 1, JAP = 2, JAP+ = 3
|
int CheckEReaderRegion(void) //US = 1, JAP = 2, JAP+ = 3
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<18;i++)
|
for (i = 0; i < 18; i++)
|
||||||
rom_info[i] = rom[0xA0+i];
|
rom_info[i] = rom[0xA0 + i];
|
||||||
rom_info[i] = 0;
|
rom_info[i] = 0;
|
||||||
|
|
||||||
if (!strcasecmp(rom_info, US_Ereader))
|
if (!strcasecmp(rom_info, US_Ereader))
|
||||||
|
@ -113,12 +111,12 @@ int CheckEReaderRegion(void) //US = 1, JAP = 2, JAP+ = 3
|
||||||
int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM2, int loadraw)
|
int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM2, int loadraw)
|
||||||
{
|
{
|
||||||
u32 temp1;
|
u32 temp1;
|
||||||
int i,j;
|
int i, j;
|
||||||
|
|
||||||
unsigned char scanmap[28];
|
unsigned char scanmap[28];
|
||||||
int scantotal=0;
|
int scantotal = 0;
|
||||||
|
|
||||||
for(i=0;i<28;i++)
|
for (i = 0; i < 28; i++)
|
||||||
scanmap[i] = 0;
|
scanmap[i] = 0;
|
||||||
|
|
||||||
unsigned char longdotcodescan[28] = {
|
unsigned char longdotcodescan[28] = {
|
||||||
|
@ -133,246 +131,206 @@ int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM
|
||||||
0xF1, 0xF1, 0xF1, 0xF2, 0xB1, 0xB1
|
0xF1, 0xF1, 0xF1, 0xF2, 0xB1, 0xB1
|
||||||
};
|
};
|
||||||
|
|
||||||
temp1 = CPUReadMemory(MEM1-4);
|
temp1 = CPUReadMemory(MEM1 - 4);
|
||||||
for(i=0;i<0x60;i+=4)
|
for (i = 0; i < 0x60; i += 4)
|
||||||
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++)
|
scantotal += DCdata[((i * 0x68) + j) >> 2];
|
||||||
{
|
|
||||||
for(j=0,scantotal=0;j<0x68;j+=4)
|
|
||||||
{
|
|
||||||
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++) {
|
||||||
{
|
if ((DCdata[0] == 0x02011394) && (DCdata[1] == 0x0203E110) && (i == 0))
|
||||||
for(i=0;i<18;i++)
|
|
||||||
{
|
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CPUWriteMemory(MEM2-8,0x1860);
|
CPUWriteMemory(MEM2 - 8, 0x1860);
|
||||||
CPUWriteMemory(MEM2-4,temp1);
|
CPUWriteMemory(MEM2 - 4, temp1);
|
||||||
|
|
||||||
|
if (size == 0xB60) {
|
||||||
if(size==0xB60)
|
if (loadraw) {
|
||||||
{
|
for (i = 0; i < 28; i++)
|
||||||
if(loadraw)
|
CPUWriteByte(MEM2 + 0x18 + i, scanmap[i]);
|
||||||
{
|
} else {
|
||||||
for(i=0;i<28;i++)
|
CPUWriteMemory(MEM2 + 0x18, 0xF1F1F1F1);
|
||||||
CPUWriteByte(MEM2+0x18+i,scanmap[i]);
|
CPUWriteMemory(MEM2 + 0x18 + 4, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 0x18 + 8, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 0x18 + 12, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 0x18 + 16, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 0x18 + 20, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 0x18 + 24, 0xB1B1F2F1);
|
||||||
}
|
}
|
||||||
else
|
CPUWriteMemory(MEM2 + 0x40, 0x19);
|
||||||
{
|
CPUWriteMemory(MEM2 + 0x44, 0x34);
|
||||||
CPUWriteMemory(MEM2+0x18,0xF1F1F1F1);
|
} else if (size == 0x750) {
|
||||||
CPUWriteMemory(MEM2+0x18+4,0xF1F1F1F1);
|
if (loadraw) {
|
||||||
CPUWriteMemory(MEM2+0x18+8,0xF1F1F1F1);
|
for (i = 0; i < 18; i++)
|
||||||
CPUWriteMemory(MEM2+0x18+12,0xF1F1F1F1);
|
CPUWriteByte(MEM2 + i, scanmap[i]);
|
||||||
CPUWriteMemory(MEM2+0x18+16,0xF1F1F1F1);
|
} else {
|
||||||
CPUWriteMemory(MEM2+0x18+20,0xF1F1F1F1);
|
CPUWriteMemory(MEM2, 0xF1F1F1F1);
|
||||||
CPUWriteMemory(MEM2+0x18+24,0xB1B1F2F1);
|
CPUWriteMemory(MEM2 + 4, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 8, 0xF1F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 12, 0xF2F1F1F1);
|
||||||
|
CPUWriteMemory(MEM2 + 16, 0xB1B1);
|
||||||
}
|
}
|
||||||
CPUWriteMemory(MEM2+0x40,0x19);
|
CPUWriteMemory(MEM2 + 0x40, 0x01);
|
||||||
CPUWriteMemory(MEM2+0x44,0x34);
|
CPUWriteMemory(MEM2 + 0x44, 0x12);
|
||||||
}
|
}
|
||||||
else if (size==0x750)
|
CPUWriteMemory(MEM2 + 0x48, 0x3C);
|
||||||
{
|
CPUWriteMemory(MEM2 + 0x4C, MEM2);
|
||||||
if(loadraw)
|
|
||||||
{
|
|
||||||
for(i=0;i<18;i++)
|
|
||||||
CPUWriteByte(MEM2+i,scanmap[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CPUWriteMemory(MEM2,0xF1F1F1F1);
|
|
||||||
CPUWriteMemory(MEM2+4,0xF1F1F1F1);
|
|
||||||
CPUWriteMemory(MEM2+8,0xF1F1F1F1);
|
|
||||||
CPUWriteMemory(MEM2+12,0xF2F1F1F1);
|
|
||||||
CPUWriteMemory(MEM2+16,0xB1B1);
|
|
||||||
}
|
|
||||||
CPUWriteMemory(MEM2+0x40,0x01);
|
|
||||||
CPUWriteMemory(MEM2+0x44,0x12);
|
|
||||||
}
|
|
||||||
CPUWriteMemory(MEM2+0x48,0x3C);
|
|
||||||
CPUWriteMemory(MEM2+0x4C,MEM2);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
case 3:
|
case 3:
|
||||||
WRITE32LE(((u32 *)&internalRAM[address & 0x7FFF]), value);
|
WRITE32LE(((u32*)&internalRAM[address & 0x7FFF]), value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WRITE32LE(((u32 *)&rom[address & 0x1FFFFFF]), value);
|
WRITE32LE(((u32*)&rom[address & 0x1FFFFFF]), value);
|
||||||
//rom[address & 0x1FFFFFF] = data;
|
//rom[address & 0x1FFFFFF] = data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BIOS_EReader_ScanCard(int swi_num)
|
void BIOS_EReader_ScanCard(int swi_num)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i,j,k;
|
int i, j, k;
|
||||||
int dotcodetype;
|
int dotcodetype;
|
||||||
|
|
||||||
int global1, global2;
|
int global1, global2;
|
||||||
|
|
||||||
FILE *f;
|
FILE* f;
|
||||||
|
|
||||||
//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);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
LoadDotCodeData(i,(u32 *)DotCodeData,0x2006EC4,0x2002478,1);
|
LoadDotCodeData(i, (u32*)DotCodeData, 0x2006EC4, 0x2002478, 1);
|
||||||
EReaderWriteMemory(0x8008B12,0x46C0DFE2);
|
EReaderWriteMemory(0x8008B12, 0x46C0DFE2);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
LoadDotCodeData(i,(u32 *)DotCodeData,0x202F8A4,0x2031034,1);
|
LoadDotCodeData(i, (u32*)DotCodeData, 0x202F8A4, 0x2031034, 1);
|
||||||
EReaderWriteMemory(0x800922E,0x46C0DFE2);
|
EReaderWriteMemory(0x800922E, 0x46C0DFE2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
LoadDotCodeData(dotcodesize,(u32 *)NULL,0x2006EC4,0x2002478,0);
|
LoadDotCodeData(dotcodesize, (u32*)NULL, 0x2006EC4, 0x2002478, 0);
|
||||||
EReaderWriteMemory(0x8008B12,0x46C0DFE1);
|
EReaderWriteMemory(0x8008B12, 0x46C0DFE1);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
LoadDotCodeData(dotcodesize,(u32 *)NULL,0x202F8A4,0x2031034,0);
|
LoadDotCodeData(dotcodesize, (u32*)NULL, 0x202F8A4, 0x2031034, 0);
|
||||||
EReaderWriteMemory(0x800922E,0x46C0DFE1);
|
EReaderWriteMemory(0x800922E, 0x46C0DFE1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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
|
||||||
EReaderWriteMemory(0x3003144,0xCA00002F); //Fix required to Correct 16 "Erasures"
|
EReaderWriteMemory(0x3003144, 0xCA00002F); //Fix required to Correct 16 "Erasures"
|
||||||
EReaderWriteMemory(0x300338C,0xEFE50000); //End of Reed-Solomon decoder
|
EReaderWriteMemory(0x300338C, 0xEFE50000); //End of Reed-Solomon decoder
|
||||||
GFpow = 0x3000A6C;
|
GFpow = 0x3000A6C;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
EReaderWriteMemory(0x8008B12,0xFB0BF035);
|
EReaderWriteMemory(0x8008B12, 0xFB0BF035);
|
||||||
EReaderWriteMemory(0x3002F88,0xEFE40000);
|
EReaderWriteMemory(0x3002F88, 0xEFE40000);
|
||||||
EReaderWriteMemory(0x3003150,0xCA00002F);
|
EReaderWriteMemory(0x3003150, 0xCA00002F);
|
||||||
EReaderWriteMemory(0x3003398,0xEFE50000);
|
EReaderWriteMemory(0x3003398, 0xEFE50000);
|
||||||
GFpow = 0x3000A78;
|
GFpow = 0x3000A78;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
EReaderWriteMemory(0x800922E,0xF94BF04B);
|
EReaderWriteMemory(0x800922E, 0xF94BF04B);
|
||||||
EReaderWriteMemory(0x3002F7C,0xEFE40000);
|
EReaderWriteMemory(0x3002F7C, 0xEFE40000);
|
||||||
EReaderWriteMemory(0x3003144,0xCA00002F);
|
EReaderWriteMemory(0x3003144, 0xCA00002F);
|
||||||
EReaderWriteMemory(0x300338C,0xEFE50000);
|
EReaderWriteMemory(0x300338C, 0xEFE50000);
|
||||||
GFpow = 0x3000A6C;
|
GFpow = 0x3000A6C;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -384,10 +342,9 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
else
|
else
|
||||||
THUMB_PREFETCH
|
THUMB_PREFETCH
|
||||||
|
|
||||||
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,13 +360,11 @@ 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
|
||||||
j += (DotCodeData[i] << 8);
|
j += (DotCodeData[i] << 8);
|
||||||
|
@ -419,14 +374,12 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
LongDotCodeHeader[0x13] = (j & 0xFF00) >> 8;
|
LongDotCodeHeader[0x13] = (j & 0xFF00) >> 8;
|
||||||
LongDotCodeHeader[0x14] = (j & 0x00FF);
|
LongDotCodeHeader[0x14] = (j & 0x00FF);
|
||||||
|
|
||||||
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,9 +407,8 @@ 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
|
||||||
j += (DotCodeData[i] << 8);
|
j += (DotCodeData[i] << 8);
|
||||||
|
@ -469,14 +418,12 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
ShortDotCodeHeader[0x13] = (j & 0xFF00) >> 8;
|
ShortDotCodeHeader[0x13] = (j & 0xFF00) >> 8;
|
||||||
ShortDotCodeHeader[0x14] = (j & 0x00FF);
|
ShortDotCodeHeader[0x14] = (j & 0x00FF);
|
||||||
|
|
||||||
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,24 +433,22 @@ 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);
|
||||||
GFpow = 0x3000A6C;
|
GFpow = 0x3000A6C;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
EReaderWriteMemory(0x8008B12,0xFB0BF035);
|
EReaderWriteMemory(0x8008B12, 0xFB0BF035);
|
||||||
EReaderWriteMemory(0x3003398,0xEFE30000);
|
EReaderWriteMemory(0x3003398, 0xEFE30000);
|
||||||
GFpow = 0x3000A78;
|
GFpow = 0x3000A78;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
EReaderWriteMemory(0x800922E,0xF94BF04B);
|
EReaderWriteMemory(0x800922E, 0xF94BF04B);
|
||||||
EReaderWriteMemory(0x300338C,0xEFE30000);
|
EReaderWriteMemory(0x300338C, 0xEFE30000);
|
||||||
GFpow = 0x3000A6C;
|
GFpow = 0x3000A6C;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -513,46 +458,37 @@ 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 ((reg[0].I >= 0) && (reg[0].I <= 0x10)) {
|
||||||
{
|
if (decodestate == 0) {
|
||||||
if(decodestate == 0)
|
for (i = 0x17; i >= 0; i--) {
|
||||||
{
|
if ((0x17 - i) < 8)
|
||||||
for(i=0x17;i>=0;i--)
|
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i));
|
||||||
{
|
|
||||||
if((0x17 - i) < 8)
|
|
||||||
j=CPUReadByte(GFpow + CPUReadByte(GFpow+0x200+i));
|
|
||||||
else
|
else
|
||||||
j=CPUReadByte(GFpow + CPUReadByte(GFpow+0x200+i)) ^ 0xFF;
|
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i)) ^ 0xFF;
|
||||||
|
|
||||||
dotcodeheader[(0x17-i)] = j;
|
dotcodeheader[(0x17 - i)] = j;
|
||||||
dotcodeheader[(0x17-i)+0x18] = j;
|
dotcodeheader[(0x17 - i) + 0x18] = j;
|
||||||
dotcodeheader[(0x17-i)+0x30] = j;
|
dotcodeheader[(0x17 - i) + 0x30] = j;
|
||||||
}
|
}
|
||||||
for(i=0;i<28;i++)
|
for (i = 0; i < 28; i++)
|
||||||
for(j=0;j<2;j++)
|
for (j = 0; j < 2; j++)
|
||||||
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 {
|
||||||
|
for (i = 0x3F; i >= 0; i--) {
|
||||||
|
if ((0x3F - i) < 0x30)
|
||||||
|
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i));
|
||||||
else
|
else
|
||||||
{
|
j = CPUReadByte(GFpow + CPUReadByte(GFpow + 0x200 + i)) ^ 0xFF;
|
||||||
for(i=0x3F;i>=0;i--)
|
dotcodetemp[((0x3F - i) * dotcodeinterleave) + dotcodepointer] = j;
|
||||||
{
|
|
||||||
if((0x3F - i) < 0x30)
|
|
||||||
j=CPUReadByte(GFpow + CPUReadByte(GFpow+0x200+i));
|
|
||||||
else
|
|
||||||
j=CPUReadByte(GFpow + CPUReadByte(GFpow+0x200+i)) ^ 0xFF;
|
|
||||||
dotcodetemp[((0x3F-i)*dotcodeinterleave)+dotcodepointer] = j;
|
|
||||||
}
|
}
|
||||||
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,38 +499,30 @@ 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(0x02, f);
|
||||||
fputc(0x65,f);
|
fputc(0x71, f);
|
||||||
fputc(0x02,f);
|
fputc(0x10, f);
|
||||||
fputc(0x71,f);
|
|
||||||
fputc(0x10,f);
|
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
@ -607,7 +535,7 @@ void BIOS_EReader_ScanCard(int swi_num)
|
||||||
|
|
||||||
int base = 14;
|
int base = 14;
|
||||||
armState = reg[base].I & 1 ? false : true;
|
armState = reg[base].I & 1 ? false : true;
|
||||||
if(armState) {
|
if (armState) {
|
||||||
reg[15].I = reg[base].I & 0xFFFFFFFC;
|
reg[15].I = reg[base].I & 0xFFFFFFFC;
|
||||||
armNextPC = reg[15].I;
|
armNextPC = reg[15].I;
|
||||||
reg[15].I += 4;
|
reg[15].I += 4;
|
||||||
|
@ -618,57 +546,44 @@ 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)
|
||||||
{
|
j = longheader[i];
|
||||||
if(dotcodesize == 0x81C)
|
|
||||||
j=longheader[i];
|
|
||||||
else
|
else
|
||||||
j=shortheader[i];
|
j = shortheader[i];
|
||||||
|
|
||||||
if(i<8)
|
if (i < 8)
|
||||||
j=CPUReadByte(GFpow + 0x100 + j);
|
j = CPUReadByte(GFpow + 0x100 + j);
|
||||||
else
|
else
|
||||||
j=CPUReadByte(GFpow + 0x100 + (j ^ 0xFF));
|
j = CPUReadByte(GFpow + 0x100 + (j ^ 0xFF));
|
||||||
|
|
||||||
CPUWriteByte(GFpow + 0x200 + (0x17 - i),j);
|
CPUWriteByte(GFpow + 0x200 + (0x17 - i), j);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (dotcodepointer == 0) {
|
||||||
|
for (i = 0; i < 0x30; i++) {
|
||||||
|
if (dotcodesize == 0x81C)
|
||||||
|
j = LongDotCodeHeader[i];
|
||||||
else
|
else
|
||||||
{
|
j = ShortDotCodeHeader[i];
|
||||||
if(dotcodepointer == 0)
|
|
||||||
{
|
|
||||||
for(i=0;i<0x30;i++)
|
|
||||||
{
|
|
||||||
if(dotcodesize == 0x81C)
|
|
||||||
j=LongDotCodeHeader[i];
|
|
||||||
else
|
|
||||||
j=ShortDotCodeHeader[i];
|
|
||||||
|
|
||||||
j=CPUReadByte(GFpow + 0x100 + j);
|
j = CPUReadByte(GFpow + 0x100 + j);
|
||||||
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);
|
||||||
CPUWriteByte(GFpow + 0x200 + (0x3F - i),j);
|
CPUWriteByte(GFpow + 0x200 + (0x3F - i), j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=0;i<16;i++)
|
for (i = 0; i < 16; i++)
|
||||||
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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
extern unsigned char *DotCodeData;
|
extern unsigned char* DotCodeData;
|
||||||
extern char filebuffer[];
|
extern char filebuffer[];
|
||||||
|
|
||||||
int OpenDotCodeFile(void);
|
int OpenDotCodeFile(void);
|
||||||
int CheckEReaderRegion(void);
|
int CheckEReaderRegion(void);
|
||||||
int LoadDotCodeData(int size, u32 *DCdata, unsigned long MEM1, unsigned long MEM2);
|
int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM2);
|
||||||
void EReaderWriteMemory(u32 address, u32 value);
|
void EReaderWriteMemory(u32 address, u32 value);
|
||||||
|
|
||||||
void BIOS_EReader_ScanCard(int swi_num);
|
void BIOS_EReader_ScanCard(int swi_num);
|
||||||
|
|
|
@ -13,28 +13,27 @@ extern u32 systemColorMap32[0x10000];
|
||||||
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
||||||
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
||||||
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
||||||
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
|
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0 };
|
||||||
|
|
||||||
// output R G B
|
// output R G B
|
||||||
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
||||||
8, 16, 8, // green
|
8, 16, 8, // green
|
||||||
0, 8, 16};// blue
|
0, 8, 16 }; // blue
|
||||||
|
|
||||||
inline void swap(short & a, short & b)
|
inline void swap(short& a, short& b)
|
||||||
{
|
{
|
||||||
short temp = a;
|
short temp = a;
|
||||||
a = b;
|
a = b;
|
||||||
b = temp;
|
b = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbafilter_pal(u16 * buf, int count)
|
void gbafilter_pal(u16* buf, int count)
|
||||||
{
|
{
|
||||||
short temp[3 * 3], s;
|
short temp[3 * 3], s;
|
||||||
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;
|
||||||
|
@ -90,14 +101,13 @@ void gbafilter_pal(u16 * buf, int count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbafilter_pal32(u32 * buf, int count)
|
void gbafilter_pal32(u32* buf, int count)
|
||||||
{
|
{
|
||||||
short temp[3 * 3], s;
|
short temp[3 * 3], s;
|
||||||
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];
|
||||||
|
@ -159,10 +178,9 @@ void gbafilter_pal32(u32 * buf, int count)
|
||||||
|
|
||||||
// for palette mode to work with the three spoony filters in 32bpp depth
|
// for palette mode to work with the three spoony filters in 32bpp depth
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
|
||||||
void gbafilter_pal(u16 *buf, int count);
|
void gbafilter_pal(u16* buf, int count);
|
||||||
void gbafilter_pal32(u32 *buf, int count);
|
void gbafilter_pal32(u32* buf, int count);
|
||||||
void gbafilter_pad(u8 *buf, int count);
|
void gbafilter_pad(u8* buf, int count);
|
||||||
|
|
2550
src/gba/remote.cpp
2550
src/gba/remote.cpp
File diff suppressed because it is too large
Load Diff
|
@ -4,39 +4,39 @@
|
||||||
#include "../common/Types.h"
|
#include "../common/Types.h"
|
||||||
#include "GBA.h"
|
#include "GBA.h"
|
||||||
|
|
||||||
#define BitSet(array, bit) ((u8 *)(array))[(bit) >> 3] |= (1 << ((bit)&7))
|
#define BitSet(array, bit) ((u8*)(array))[(bit) >> 3] |= (1 << ((bit)&7))
|
||||||
|
|
||||||
#define BitClear(array, bit) ((u8 *)(array))[(bit) >> 3] &= ~(1 << ((bit)&7))
|
#define BitClear(array, bit) ((u8*)(array))[(bit) >> 3] &= ~(1 << ((bit)&7))
|
||||||
|
|
||||||
#define BitGet(array, bit) ((u8)((array)[(bit) >> 3]) & (u8)(1 << ((bit)&7)))
|
#define BitGet(array, bit) ((u8)((array)[(bit) >> 3]) & (u8)(1 << ((bit)&7)))
|
||||||
|
|
||||||
#define BreakSet(array, addr, flag) \
|
#define BreakSet(array, addr, flag) \
|
||||||
((u8 *)(array))[(addr) >> 1] |= ((addr & 1) ? (flag << 4) : (flag & 0xf))
|
((u8*)(array))[(addr) >> 1] |= ((addr & 1) ? (flag << 4) : (flag & 0xf))
|
||||||
|
|
||||||
#define BreakClear(array, addr, flag) \
|
#define BreakClear(array, addr, flag) \
|
||||||
((u8 *)(array))[(addr) >> 1] &= ~((addr & 1) ? (flag << 4) : (flag & 0xf))
|
((u8*)(array))[(addr) >> 1] &= ~((addr & 1) ? (flag << 4) : (flag & 0xf))
|
||||||
|
|
||||||
// check
|
// check
|
||||||
#define BreakThumbCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x80 : 0x8)
|
#define BreakThumbCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x80 : 0x8)
|
||||||
|
|
||||||
#define BreakARMCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x40 : 0x4)
|
#define BreakARMCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x40 : 0x4)
|
||||||
|
|
||||||
#define BreakReadCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x20 : 0x2)
|
#define BreakReadCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x20 : 0x2)
|
||||||
|
|
||||||
#define BreakWriteCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x10 : 0x1)
|
#define BreakWriteCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x10 : 0x1)
|
||||||
|
|
||||||
#define BreakCheck(array, addr, flag) \
|
#define BreakCheck(array, addr, flag) \
|
||||||
((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf))
|
((u8*)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf))
|
||||||
|
|
||||||
extern bool debugger;
|
extern bool debugger;
|
||||||
|
|
||||||
extern bool dexp_eval(char *, u32 *);
|
extern bool dexp_eval(char*, u32*);
|
||||||
extern void dexp_setVar(char *, u32);
|
extern void dexp_setVar(char*, u32);
|
||||||
extern void dexp_listVars();
|
extern void dexp_listVars();
|
||||||
extern void dexp_saveVars(char *);
|
extern void dexp_saveVars(char*);
|
||||||
extern void dexp_loadVars(char *);
|
extern void dexp_loadVars(char*);
|
||||||
|
|
||||||
void debuggerOutput(const char *s, u32 addr);
|
void debuggerOutput(const char* s, u32 addr);
|
||||||
|
|
||||||
bool debuggerBreakOnExecution(u32 address, u8 state);
|
bool debuggerBreakOnExecution(u32 address, u8 state);
|
||||||
bool debuggerBreakOnWrite(u32 address, u32 value, int size);
|
bool debuggerBreakOnWrite(u32 address, u32 value, int size);
|
||||||
|
@ -51,7 +51,7 @@ struct regBreak {
|
||||||
// bit 3 = signed
|
// bit 3 = signed
|
||||||
u8 flags;
|
u8 flags;
|
||||||
u32 intVal;
|
u32 intVal;
|
||||||
struct regBreak *next;
|
struct regBreak* next;
|
||||||
};
|
};
|
||||||
extern u8 lowRegBreakCounter[4]; //(r0-r3)
|
extern u8 lowRegBreakCounter[4]; //(r0-r3)
|
||||||
extern u8 medRegBreakCounter[4]; //(r4-r7)
|
extern u8 medRegBreakCounter[4]; //(r4-r7)
|
||||||
|
@ -59,10 +59,10 @@ extern u8 highRegBreakCounter[4]; //(r8-r11)
|
||||||
extern u8 statusRegBreakCounter[4]; //(r12-r15)
|
extern u8 statusRegBreakCounter[4]; //(r12-r15)
|
||||||
|
|
||||||
extern bool enableRegBreak;
|
extern bool enableRegBreak;
|
||||||
extern regBreak *breakRegList[16];
|
extern regBreak* breakRegList[16];
|
||||||
extern void breakReg_check(int i);
|
extern void breakReg_check(int i);
|
||||||
|
|
||||||
struct regBreak *getFromBreakRegList(u8 regnum, int location);
|
struct regBreak* getFromBreakRegList(u8 regnum, int location);
|
||||||
|
|
||||||
void clearBreakRegList();
|
void clearBreakRegList();
|
||||||
void clearParticularRegListBreaks(int reg);
|
void clearParticularRegListBreaks(int reg);
|
||||||
|
@ -73,7 +73,7 @@ void printBreakRegList(bool verbose);
|
||||||
|
|
||||||
void remoteStubMain();
|
void remoteStubMain();
|
||||||
void remoteStubSignal(int sig, int number);
|
void remoteStubSignal(int sig, int number);
|
||||||
void remoteOutput(const char *s, u32 addr);
|
void remoteOutput(const char* s, u32 addr);
|
||||||
void remoteSetProtocol(int p);
|
void remoteSetProtocol(int p);
|
||||||
void remoteSetPort(int port);
|
void remoteSetPort(int port);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue