mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 00:15:10 +01:00
revert some changes
This commit is contained in:
parent
ad987a37ad
commit
923667cecc
@ -23,14 +23,14 @@ public:
|
|||||||
// Global configuration
|
// Global configuration
|
||||||
struct config_t
|
struct config_t
|
||||||
{
|
{
|
||||||
pan_vol_t side_chans [2]; // left and right side channel volume and pan
|
bool enabled; // false = disable all effects
|
||||||
|
|
||||||
// Current sound is echoed at adjustable left/right delay,
|
// Current sound is echoed at adjustable left/right delay,
|
||||||
// with reduced treble and volume (feedback).
|
// with reduced treble and volume (feedback).
|
||||||
float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent
|
float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent
|
||||||
float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony
|
int delay [2]; // left, right delays (msec)
|
||||||
int delay [2]; // left, right delays (msec)
|
float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony
|
||||||
bool enabled; // false = disable all effects
|
pan_vol_t side_chans [2]; // left and right side channel volume and pan
|
||||||
};
|
};
|
||||||
config_t& config() { return config_; }
|
config_t& config() { return config_; }
|
||||||
|
|
||||||
@ -123,10 +123,10 @@ class Simple_Effects_Buffer : public Effects_Buffer {
|
|||||||
public:
|
public:
|
||||||
struct config_t
|
struct config_t
|
||||||
{
|
{
|
||||||
|
bool enabled; // false = disable all effects
|
||||||
float echo; // 0.0 = none, 1.0 = lots
|
float echo; // 0.0 = none, 1.0 = lots
|
||||||
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
|
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
|
||||||
bool surround; // true = put some channels in back
|
bool surround; // true = put some channels in back
|
||||||
bool enabled; // false = disable all effects
|
|
||||||
};
|
};
|
||||||
config_t& config() { return config_; }
|
config_t& config() { return config_; }
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ void Gb_Apu::set_output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* ri
|
|||||||
|
|
||||||
void Gb_Apu::synth_volume( int iv )
|
void Gb_Apu::synth_volume( int iv )
|
||||||
{
|
{
|
||||||
double v = volume_ * iv * 0.005 / osc_count;
|
double v = volume_ * 0.60 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv;
|
||||||
good_synth.volume( v );
|
good_synth.volume( v );
|
||||||
med_synth .volume( v );
|
med_synth .volume( v );
|
||||||
}
|
}
|
||||||
@ -88,18 +88,8 @@ void Gb_Apu::volume( double v )
|
|||||||
|
|
||||||
void Gb_Apu::reset_regs()
|
void Gb_Apu::reset_regs()
|
||||||
{
|
{
|
||||||
int i = 24; // 32 - 8
|
for ( int i = 0; i < 0x20; i++ )
|
||||||
do {
|
regs [i] = 0;
|
||||||
regs [i] =
|
|
||||||
regs [i+1] =
|
|
||||||
regs [i+2] =
|
|
||||||
regs [i+3] =
|
|
||||||
regs [i+4] =
|
|
||||||
regs [i+5] =
|
|
||||||
regs [i+6] =
|
|
||||||
regs [i+7] = 0;
|
|
||||||
i-=8;
|
|
||||||
} while(i>=0);
|
|
||||||
|
|
||||||
square1.reset();
|
square1.reset();
|
||||||
square2.reset();
|
square2.reset();
|
||||||
@ -126,7 +116,7 @@ void Gb_Apu::reduce_clicks( bool reduce )
|
|||||||
if ( reduce && wave.mode != mode_agb ) // AGB already eliminates clicks
|
if ( reduce && wave.mode != mode_agb ) // AGB already eliminates clicks
|
||||||
dac_off_amp = -Gb_Osc::dac_bias;
|
dac_off_amp = -Gb_Osc::dac_bias;
|
||||||
|
|
||||||
for ( int i = 0; i < osc_count; ++i )
|
for ( int i = 0; i < osc_count; i++ )
|
||||||
oscs [i]->dac_off_amp = dac_off_amp;
|
oscs [i]->dac_off_amp = dac_off_amp;
|
||||||
|
|
||||||
// AGB always eliminates clicks on wave channel using same method
|
// AGB always eliminates clicks on wave channel using same method
|
||||||
@ -140,7 +130,7 @@ void Gb_Apu::reset( mode_t mode, bool agb_wave )
|
|||||||
if ( agb_wave )
|
if ( agb_wave )
|
||||||
mode = mode_agb; // using AGB wave features implies AGB hardware
|
mode = mode_agb; // using AGB wave features implies AGB hardware
|
||||||
wave.agb_mask = agb_wave ? 0xFF : 0;
|
wave.agb_mask = agb_wave ? 0xFF : 0;
|
||||||
for ( int i = 0; i < osc_count; ++i )
|
for ( int i = 0; i < osc_count; i++ )
|
||||||
oscs [i]->mode = mode;
|
oscs [i]->mode = mode;
|
||||||
reduce_clicks( reduce_clicks_ );
|
reduce_clicks( reduce_clicks_ );
|
||||||
|
|
||||||
@ -157,18 +147,13 @@ void Gb_Apu::reset( mode_t mode, bool agb_wave )
|
|||||||
{0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C,0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA},
|
{0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C,0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA},
|
||||||
{0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF},
|
{0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF},
|
||||||
};
|
};
|
||||||
unsigned i = 0;
|
for ( int b = 2; --b >= 0; )
|
||||||
unsigned initialSize = sizeof(initial_wave[0]);
|
{
|
||||||
|
// Init both banks (does nothing if not in AGB mode)
|
||||||
// Init both banks (does nothing if not in AGB mode)
|
// TODO: verify that this works
|
||||||
// TODO: verify that this works
|
write_register( 0, 0xFF1A, b * 0x40 );
|
||||||
write_register( 0, 0xFF1A, 0x40 );
|
for ( unsigned i = 0; i < sizeof initial_wave [0]; i++ )
|
||||||
for (; i < initialSize; ++i ){
|
write_register( 0, i + wave_ram, initial_wave [(mode != mode_dmg)] [i] );
|
||||||
write_register( 0, i + wave_ram, initial_wave [(mode != mode_dmg)] [i] );
|
|
||||||
}
|
|
||||||
write_register( 0, 0xFF1A, 0 );
|
|
||||||
for ( i = 0; i < initialSize; ++i ){
|
|
||||||
write_register( 0, i + wave_ram, initial_wave [(mode != mode_dmg)] [i] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +173,8 @@ Gb_Apu::Gb_Apu()
|
|||||||
oscs [2] = &wave;
|
oscs [2] = &wave;
|
||||||
oscs [3] = &noise;
|
oscs [3] = &noise;
|
||||||
|
|
||||||
int i = osc_count - 1;
|
for ( int i = osc_count; --i >= 0; )
|
||||||
do {
|
{
|
||||||
Gb_Osc& o = *oscs [i];
|
Gb_Osc& o = *oscs [i];
|
||||||
o.regs = ®s [i * 5];
|
o.regs = ®s [i * 5];
|
||||||
o.output = 0;
|
o.output = 0;
|
||||||
@ -199,8 +184,7 @@ Gb_Apu::Gb_Apu()
|
|||||||
o.outputs [3] = 0;
|
o.outputs [3] = 0;
|
||||||
o.good_synth = &good_synth;
|
o.good_synth = &good_synth;
|
||||||
o.med_synth = &med_synth;
|
o.med_synth = &med_synth;
|
||||||
--i;
|
}
|
||||||
} while(i >= 0);
|
|
||||||
|
|
||||||
reduce_clicks_ = false;
|
reduce_clicks_ = false;
|
||||||
set_tempo( 1.0 );
|
set_tempo( 1.0 );
|
||||||
@ -288,8 +272,8 @@ void Gb_Apu::silence_osc( Gb_Osc& o )
|
|||||||
|
|
||||||
void Gb_Apu::apply_stereo()
|
void Gb_Apu::apply_stereo()
|
||||||
{
|
{
|
||||||
int i = osc_count - 1;
|
for ( int i = osc_count; --i >= 0; )
|
||||||
do {
|
{
|
||||||
Gb_Osc& o = *oscs [i];
|
Gb_Osc& o = *oscs [i];
|
||||||
Blip_Buffer* out = o.outputs [calc_output( i )];
|
Blip_Buffer* out = o.outputs [calc_output( i )];
|
||||||
if ( o.output != out )
|
if ( o.output != out )
|
||||||
@ -297,8 +281,7 @@ void Gb_Apu::apply_stereo()
|
|||||||
silence_osc( o );
|
silence_osc( o );
|
||||||
o.output = out;
|
o.output = out;
|
||||||
}
|
}
|
||||||
--i;
|
}
|
||||||
} while(i >=0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
||||||
@ -343,11 +326,8 @@ void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
|||||||
else if ( addr == vol_reg && data != old_data )
|
else if ( addr == vol_reg && data != old_data )
|
||||||
{
|
{
|
||||||
// Master volume
|
// Master volume
|
||||||
int i = osc_count - 1;
|
for ( int i = osc_count; --i >= 0; )
|
||||||
do {
|
|
||||||
silence_osc( *oscs [i] );
|
silence_osc( *oscs [i] );
|
||||||
--i;
|
|
||||||
} while( i >=0);
|
|
||||||
|
|
||||||
apply_volume();
|
apply_volume();
|
||||||
}
|
}
|
||||||
@ -360,11 +340,8 @@ void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
|||||||
{
|
{
|
||||||
// Power control
|
// Power control
|
||||||
frame_phase = 0;
|
frame_phase = 0;
|
||||||
int i = osc_count - 1;
|
for ( int i = osc_count; --i >= 0; )
|
||||||
do {
|
|
||||||
silence_osc( *oscs [i] );
|
silence_osc( *oscs [i] );
|
||||||
--i;
|
|
||||||
} while( i >=0);
|
|
||||||
|
|
||||||
reset_regs();
|
reset_regs();
|
||||||
if ( wave.mode != mode_dmg )
|
if ( wave.mode != mode_dmg )
|
||||||
|
@ -583,8 +583,7 @@ u8 ZeroTable[256] = {
|
|||||||
|
|
||||||
int inline gbGetValue(int min,int max,int v)
|
int inline gbGetValue(int min,int max,int v)
|
||||||
{
|
{
|
||||||
float o31 = float(v) / 31.0f;
|
return (int)(min+(float)(max-min)*(2.0*(v/31.0)-(v/31.0)*(v/31.0)));
|
||||||
return (min +((int)((float)(max-min)* o31*(2.0f - o31))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbGenFilter()
|
void gbGenFilter()
|
||||||
@ -632,9 +631,9 @@ void gbCopyMemory(u16 d, u16 s, int count)
|
|||||||
{
|
{
|
||||||
while(count) {
|
while(count) {
|
||||||
gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff];
|
gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff];
|
||||||
++s;
|
s++;
|
||||||
++d;
|
d++;
|
||||||
--count;
|
count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,7 +670,7 @@ void gbDoHdma()
|
|||||||
gbDmaTicks = 9;
|
gbDmaTicks = 9;
|
||||||
|
|
||||||
if (IFF & 0x80)
|
if (IFF & 0x80)
|
||||||
++gbDmaTicks;
|
gbDmaTicks++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,14 +888,16 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
{
|
{
|
||||||
bool temp = false;
|
bool temp = false;
|
||||||
|
|
||||||
if (((gbTimerOn && !gbTimerModeChange) && (gbTimerMode & 2) &&
|
if ((gbTimerOn && !gbTimerModeChange) && (gbTimerMode & 2) &&
|
||||||
!(gbInternalTimer & 0x80) && (gbInternalTimer & (gbTimerClockTicks>>1)) &&
|
!(gbInternalTimer & 0x80) && (gbInternalTimer & (gbTimerClockTicks>>1)) &&
|
||||||
!(gbInternalTimer & (gbTimerClockTicks>>5)))
|
!(gbInternalTimer & (gbTimerClockTicks>>5)))
|
||||||
||
|
temp = true;
|
||||||
((!gbTimerOn && !gbTimerModeChange && gbTimerOnChange ) && ((gbTimerTicks-1) < (gbTimerClockTicks>>1)))){
|
else if ((!gbTimerOn && !gbTimerModeChange && gbTimerOnChange ) && ((gbTimerTicks-1) < (gbTimerClockTicks>>1)))
|
||||||
temp = true;
|
temp = true;
|
||||||
}else if (gbTimerOn && gbTimerModeChange && !gbTimerOnChange){
|
else if (gbTimerOn && gbTimerModeChange && !gbTimerOnChange)
|
||||||
switch(gbTimerMode & 3){
|
{
|
||||||
|
switch(gbTimerMode & 3)
|
||||||
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
temp = false;
|
temp = false;
|
||||||
break;
|
break;
|
||||||
@ -1015,6 +1016,8 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
|
|
||||||
// systemDrawScreen();
|
// systemDrawScreen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gbRegisterLYLCDCOffOn = (register_LY + 144) % 154;
|
gbRegisterLYLCDCOffOn = (register_LY + 144) % 154;
|
||||||
|
|
||||||
gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS - (gbSpeed ? 2 : 1);
|
gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS - (gbSpeed ? 2 : 1);
|
||||||
@ -1119,24 +1122,13 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
temp = ((GBLY_INCREMENT_CLOCK_TICKS-GBLCD_MODE_2_CLOCK_TICKS) -
|
temp = ((GBLY_INCREMENT_CLOCK_TICKS-GBLCD_MODE_2_CLOCK_TICKS) -
|
||||||
gbLcdLYIncrementTicks);
|
gbLcdLYIncrementTicks);
|
||||||
|
|
||||||
if (temp >=0){
|
if (temp >=0)
|
||||||
if (temp < 300){
|
{
|
||||||
|
for (int i=temp<<(gbSpeed ? 1 : 2);i<300;i++)
|
||||||
int i = temp << (gbSpeed ? 1 : 2);
|
if (temp < 300)
|
||||||
|
gbSCYLine[i] = value;
|
||||||
if((i % 2) == 0){ // Divisible by 2
|
|
||||||
// If it is divisible by 2, it'll go much faster
|
|
||||||
for (; i < 300; i += 2){
|
|
||||||
gbSCYLine[i] =
|
|
||||||
gbSCYLine[i+1] = value;
|
|
||||||
}
|
|
||||||
}else{ // Not divisible by 2
|
|
||||||
for (; i < 300; ++i){
|
|
||||||
gbSCYLine[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
memset(gbSCYLine, value, sizeof(gbSCYLine));
|
memset(gbSCYLine, value, sizeof(gbSCYLine));
|
||||||
|
|
||||||
@ -1154,22 +1146,9 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
|
|
||||||
if (temp >=0)
|
if (temp >=0)
|
||||||
{
|
{
|
||||||
if (temp < 300){
|
for (int i=temp<<(gbSpeed ? 1 : 2);i<300;i++)
|
||||||
int i = temp << (gbSpeed ? 1 : 2);
|
if (temp < 300)
|
||||||
|
gbSCXLine[i] = value;
|
||||||
if((i % 2) == 0){ // Divisible by 2
|
|
||||||
// If it is divisible by 2, it'll go much faster
|
|
||||||
for (; i < 300; i += 2){
|
|
||||||
gbSCXLine[i] =
|
|
||||||
gbSCXLine[i+1] = value;
|
|
||||||
}
|
|
||||||
}else{ // Not divisible by 2
|
|
||||||
for (; i < 300; ++i){
|
|
||||||
gbSCXLine[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -1199,8 +1178,11 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
|
|
||||||
// DMA!
|
// DMA!
|
||||||
case 0x46: {
|
case 0x46: {
|
||||||
int source = value << 8;
|
int source = value * 0x0100;
|
||||||
gbCopyMemory(0xfe00, source, 0xa0);
|
|
||||||
|
gbCopyMemory(0xfe00,
|
||||||
|
source,
|
||||||
|
0xa0);
|
||||||
gbMemory[0xff46] = register_DMA = value;
|
gbMemory[0xff46] = register_DMA = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1218,21 +1200,9 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
|
|
||||||
if (temp >=0)
|
if (temp >=0)
|
||||||
{
|
{
|
||||||
if (temp < 300){
|
for (int i=temp<<(gbSpeed ? 1 : 2);i<300;i++)
|
||||||
int i = temp << (gbSpeed ? 1 : 2);
|
if (temp < 300)
|
||||||
|
gbBgpLine[i] = value;
|
||||||
if((i % 2) == 0){ // Divisible by 2
|
|
||||||
// If it is divisible by 2, it'll go much faster
|
|
||||||
for (; i < 300; i += 2){
|
|
||||||
gbBgpLine[i] =
|
|
||||||
gbBgpLine[i+1] = value;
|
|
||||||
}
|
|
||||||
}else{ // Not divisible by 2
|
|
||||||
for (; i < 300; ++i){
|
|
||||||
gbBgpLine[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memset(gbBgpLine,value,sizeof(gbBgpLine));
|
memset(gbBgpLine,value,sizeof(gbBgpLine));
|
||||||
@ -1253,21 +1223,9 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
|
|
||||||
if (temp >=0)
|
if (temp >=0)
|
||||||
{
|
{
|
||||||
if (temp < 300){
|
for (int i=temp<<(gbSpeed ? 1 : 2);i<300;i++)
|
||||||
int i = temp << (gbSpeed ? 1 : 2);
|
if (temp < 300)
|
||||||
|
gbObp0Line[i] = value;
|
||||||
if((i % 2) == 0){ // Divisible by 2
|
|
||||||
// If it is divisible by 2, it'll go much faster
|
|
||||||
for (; i < 300; i += 2){
|
|
||||||
gbObp0Line[i] =
|
|
||||||
gbObp0Line[i+1] = value;
|
|
||||||
}
|
|
||||||
}else{ // Not divisible by 2
|
|
||||||
for (; i < 300; ++i){
|
|
||||||
gbObp0Line[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memset(gbObp0Line,value,sizeof(gbObp0Line));
|
memset(gbObp0Line,value,sizeof(gbObp0Line));
|
||||||
@ -1288,21 +1246,9 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
|
|
||||||
if (temp >=0)
|
if (temp >=0)
|
||||||
{
|
{
|
||||||
if (temp < 300){
|
for (int i=temp<<(gbSpeed ? 1 : 2);i<300;i++)
|
||||||
int i = temp << (gbSpeed ? 1 : 2);
|
if (temp < 300)
|
||||||
|
gbObp1Line[i] = value;
|
||||||
if((i % 2) == 0){ // Divisible by 2
|
|
||||||
// If it is divisible by 2, it'll go much faster
|
|
||||||
for (; i < 300; i += 2){
|
|
||||||
gbObp1Line[i] =
|
|
||||||
gbObp1Line[i+1] = value;
|
|
||||||
}
|
|
||||||
}else{ // Not divisible by 2
|
|
||||||
for (; i < 300; ++i){
|
|
||||||
gbObp1Line[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memset(gbObp1Line,value,sizeof(gbObp1Line));
|
memset(gbObp1Line,value,sizeof(gbObp1Line));
|
||||||
@ -1338,11 +1284,11 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
// VBK
|
// VBK
|
||||||
case 0x4f: {
|
case 0x4f: {
|
||||||
if(gbCgbMode) {
|
if(gbCgbMode) {
|
||||||
value &= 1;
|
value = value & 1;
|
||||||
if(value == gbVramBank)
|
if(value == gbVramBank)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int vramAddress = value << 13; //* 0x2000
|
int vramAddress = value * 0x2000;
|
||||||
gbMemoryMap[0x08] = &gbVram[vramAddress];
|
gbMemoryMap[0x08] = &gbVram[vramAddress];
|
||||||
gbMemoryMap[0x09] = &gbVram[vramAddress + 0x1000];
|
gbMemoryMap[0x09] = &gbVram[vramAddress + 0x1000];
|
||||||
|
|
||||||
@ -1419,7 +1365,7 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
case 0x55: {
|
case 0x55: {
|
||||||
|
|
||||||
if(gbCgbMode) {
|
if(gbCgbMode) {
|
||||||
gbHdmaBytes = 16 + ((value & 0x7f) <<4);
|
gbHdmaBytes = 16 + (value & 0x7f) * 16;
|
||||||
if(gbHdmaOn) {
|
if(gbHdmaOn) {
|
||||||
if(value & 0x80) {
|
if(value & 0x80) {
|
||||||
gbMemory[0xff55] = register_HDMA5 = (value & 0x7f);
|
gbMemory[0xff55] = register_HDMA5 = (value & 0x7f);
|
||||||
@ -1438,10 +1384,10 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
// account... according to GB DEV FAQs, the setup time is the same
|
// account... according to GB DEV FAQs, the setup time is the same
|
||||||
// for single and double speed, but the actual transfer takes the
|
// for single and double speed, but the actual transfer takes the
|
||||||
// same time
|
// same time
|
||||||
if(gbSpeed)
|
if(gbSpeed)
|
||||||
gbDmaTicks = 2 + (((value & 0x7f) + 1) << 4);
|
gbDmaTicks = 2+16 * ((value & 0x7f) +1);
|
||||||
else
|
else
|
||||||
gbDmaTicks = 1 + (((value & 0x7f) + 1) << 3);
|
gbDmaTicks = 1+8 * ((value & 0x7f)+1);
|
||||||
|
|
||||||
gbCopyMemory((gbHdmaDestination & 0x1ff0) | 0x8000,
|
gbCopyMemory((gbHdmaDestination & 0x1ff0) | 0x8000,
|
||||||
gbHdmaSource & 0xfff0,
|
gbHdmaSource & 0xfff0,
|
||||||
@ -1449,17 +1395,11 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
gbHdmaDestination += gbHdmaBytes;
|
gbHdmaDestination += gbHdmaBytes;
|
||||||
gbHdmaSource += gbHdmaBytes;
|
gbHdmaSource += gbHdmaBytes;
|
||||||
|
|
||||||
// Spacial alignemnt
|
gbMemory[0xff51] = register_HDMA1 = 0xff;// = (gbHdmaSource >> 8) & 0xff;
|
||||||
gbMemory[0xff51] =
|
gbMemory[0xff52] = register_HDMA2 = 0xff;// = gbHdmaSource & 0xf0;
|
||||||
gbMemory[0xff52] =
|
gbMemory[0xff53] = register_HDMA3 = 0xff;// = ((gbHdmaDestination - 0x8000) >> 8) & 0x1f;
|
||||||
gbMemory[0xff53] =
|
gbMemory[0xff54] = register_HDMA4 = 0xff;// = gbHdmaDestination & 0xf0;
|
||||||
gbMemory[0xff54] =
|
gbMemory[0xff55] = register_HDMA5 = 0xff;
|
||||||
gbMemory[0xff55] = 0xff;
|
|
||||||
register_HDMA1 =
|
|
||||||
register_HDMA2 =
|
|
||||||
register_HDMA3 =
|
|
||||||
register_HDMA4 =
|
|
||||||
register_HDMA5 = 0xff;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1592,7 +1532,7 @@ void gbWriteMemory(register u16 address, register u8 value)
|
|||||||
if(bank == gbWramBank)
|
if(bank == gbWramBank)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int wramAddress = bank << 12; //* 0x1000
|
int wramAddress = bank * 0x1000;
|
||||||
gbMemoryMap[0x0d] = &gbWram[wramAddress];
|
gbMemoryMap[0x0d] = &gbWram[wramAddress];
|
||||||
|
|
||||||
gbWramBank = bank;
|
gbWramBank = bank;
|
||||||
@ -1837,18 +1777,20 @@ u8 gbReadMemory(register u16 address)
|
|||||||
int joy = 0;
|
int joy = 0;
|
||||||
if(gbSgbMode && gbSgbMultiplayer) {
|
if(gbSgbMode && gbSgbMultiplayer) {
|
||||||
switch(gbSgbNextController) {
|
switch(gbSgbNextController) {
|
||||||
case 0x0f:
|
case 0x0f:
|
||||||
default:
|
joy = 0;
|
||||||
break;
|
break;
|
||||||
case 0x0e:
|
case 0x0e:
|
||||||
joy = 1;
|
joy = 1;
|
||||||
break;
|
break;
|
||||||
case 0x0d:
|
case 0x0d:
|
||||||
joy = 2;
|
joy = 2;
|
||||||
break;
|
break;
|
||||||
case 0x0c:
|
case 0x0c:
|
||||||
joy = 3;
|
joy = 3;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
joy = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int joystate = gbJoymask[joy];
|
int joystate = gbJoymask[joy];
|
||||||
@ -1868,18 +1810,20 @@ u8 gbReadMemory(register u16 address)
|
|||||||
int joy = 0;
|
int joy = 0;
|
||||||
if(gbSgbMode && gbSgbMultiplayer) {
|
if(gbSgbMode && gbSgbMultiplayer) {
|
||||||
switch(gbSgbNextController) {
|
switch(gbSgbNextController) {
|
||||||
case 0x0f:
|
case 0x0f:
|
||||||
default:
|
joy = 0;
|
||||||
break;
|
break;
|
||||||
case 0x0e:
|
case 0x0e:
|
||||||
joy = 1;
|
joy = 1;
|
||||||
break;
|
break;
|
||||||
case 0x0d:
|
case 0x0d:
|
||||||
joy = 2;
|
joy = 2;
|
||||||
break;
|
break;
|
||||||
case 0x0c:
|
case 0x0c:
|
||||||
joy = 3;
|
joy = 3;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
joy = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int joystate = gbJoymask[joy];
|
int joystate = gbJoymask[joy];
|
||||||
@ -2073,24 +2017,24 @@ void gbSpeedSwitch()
|
|||||||
gbBlackScreen = true;
|
gbBlackScreen = true;
|
||||||
if(gbSpeed == 0) {
|
if(gbSpeed == 0) {
|
||||||
gbSpeed = 1;
|
gbSpeed = 1;
|
||||||
GBLCD_MODE_0_CLOCK_TICKS = 51 << 1;
|
GBLCD_MODE_0_CLOCK_TICKS = 51 * 2;
|
||||||
GBLCD_MODE_1_CLOCK_TICKS = 1140 << 1;
|
GBLCD_MODE_1_CLOCK_TICKS = 1140 * 2;
|
||||||
GBLCD_MODE_2_CLOCK_TICKS = 20 << 1;
|
GBLCD_MODE_2_CLOCK_TICKS = 20 * 2;
|
||||||
GBLCD_MODE_3_CLOCK_TICKS = 43 << 1;
|
GBLCD_MODE_3_CLOCK_TICKS = 43 * 2;
|
||||||
GBLY_INCREMENT_CLOCK_TICKS = 114 << 1;
|
GBLY_INCREMENT_CLOCK_TICKS = 114 * 2;
|
||||||
GBDIV_CLOCK_TICKS = 64;
|
GBDIV_CLOCK_TICKS = 64;
|
||||||
GBTIMER_MODE_0_CLOCK_TICKS = 256;
|
GBTIMER_MODE_0_CLOCK_TICKS = 256;
|
||||||
GBTIMER_MODE_1_CLOCK_TICKS = 4;
|
GBTIMER_MODE_1_CLOCK_TICKS = 4;
|
||||||
GBTIMER_MODE_2_CLOCK_TICKS = 16;
|
GBTIMER_MODE_2_CLOCK_TICKS = 16;
|
||||||
GBTIMER_MODE_3_CLOCK_TICKS = 64;
|
GBTIMER_MODE_3_CLOCK_TICKS = 64;
|
||||||
GBSERIAL_CLOCK_TICKS = 128 << 1;
|
GBSERIAL_CLOCK_TICKS = 128 * 2;
|
||||||
gbLcdTicks <<= 1;
|
gbLcdTicks *= 2;
|
||||||
gbLcdTicksDelayed <<= 1;
|
gbLcdTicksDelayed *=2;
|
||||||
--gbLcdTicksDelayed;
|
gbLcdTicksDelayed--;
|
||||||
gbLcdLYIncrementTicks <<= 1;
|
gbLcdLYIncrementTicks *= 2;
|
||||||
gbLcdLYIncrementTicksDelayed <<= 1;
|
gbLcdLYIncrementTicksDelayed *= 2;
|
||||||
--gbLcdLYIncrementTicksDelayed;
|
gbLcdLYIncrementTicksDelayed--;
|
||||||
gbSerialTicks <<= 1;
|
gbSerialTicks *= 2;
|
||||||
//SOUND_CLOCK_TICKS = soundQuality * 24 * 2;
|
//SOUND_CLOCK_TICKS = soundQuality * 24 * 2;
|
||||||
//soundTicks *= 2;
|
//soundTicks *= 2;
|
||||||
gbLine99Ticks = 3;
|
gbLine99Ticks = 3;
|
||||||
@ -2108,17 +2052,17 @@ void gbSpeedSwitch()
|
|||||||
GBTIMER_MODE_3_CLOCK_TICKS = 64;
|
GBTIMER_MODE_3_CLOCK_TICKS = 64;
|
||||||
GBSERIAL_CLOCK_TICKS = 128;
|
GBSERIAL_CLOCK_TICKS = 128;
|
||||||
gbLcdTicks >>= 1;
|
gbLcdTicks >>= 1;
|
||||||
++gbLcdTicksDelayed;
|
gbLcdTicksDelayed++;
|
||||||
gbLcdTicksDelayed >>=1;
|
gbLcdTicksDelayed >>=1;
|
||||||
gbLcdLYIncrementTicks >>= 1;
|
gbLcdLYIncrementTicks >>= 1;
|
||||||
++gbLcdLYIncrementTicksDelayed;
|
gbLcdLYIncrementTicksDelayed++;
|
||||||
gbLcdLYIncrementTicksDelayed >>= 1;
|
gbLcdLYIncrementTicksDelayed >>= 1;
|
||||||
gbSerialTicks >>= 1;
|
gbSerialTicks /= 2;
|
||||||
//SOUND_CLOCK_TICKS = soundQuality * 24;
|
//SOUND_CLOCK_TICKS = soundQuality * 24;
|
||||||
//soundTicks /= 2;
|
//soundTicks /= 2;
|
||||||
gbLine99Ticks = 1;
|
gbLine99Ticks = 1;
|
||||||
if (gbHardware & 8)
|
if (gbHardware & 8)
|
||||||
++gbLine99Ticks;
|
gbLine99Ticks++;
|
||||||
}
|
}
|
||||||
gbDmaTicks += (134)*GBLY_INCREMENT_CLOCK_TICKS + (37<<(gbSpeed ? 1 : 0));
|
gbDmaTicks += (134)*GBLY_INCREMENT_CLOCK_TICKS + (37<<(gbSpeed ? 1 : 0));
|
||||||
}
|
}
|
||||||
@ -2166,15 +2110,18 @@ void gbGetHardwareType()
|
|||||||
gbCgbMode = 0;
|
gbCgbMode = 0;
|
||||||
gbSgbMode = 0;
|
gbSgbMode = 0;
|
||||||
if(gbRom[0x143] & 0x80) {
|
if(gbRom[0x143] & 0x80) {
|
||||||
if((1<<gbEmulatorType) & ((1<<0)|(1<<1)|(1<<4))){
|
if((gbEmulatorType == 0) ||
|
||||||
|
gbEmulatorType == 1 ||
|
||||||
|
gbEmulatorType == 4) {
|
||||||
gbCgbMode = 1;
|
gbCgbMode = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((gbCgbMode == 0 ) && (gbRom[0x146] == 0x03)) {
|
if((gbCgbMode == 0 ) && (gbRom[0x146] == 0x03)) {
|
||||||
if((1<<gbEmulatorType) & ((1<<0)|(1<<2)|(1<<5))){
|
if(gbEmulatorType == 0 ||
|
||||||
|
gbEmulatorType == 2 ||
|
||||||
|
gbEmulatorType == 5)
|
||||||
gbSgbMode = 1;
|
gbSgbMode = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gbHardware = 1; // GB
|
gbHardware = 1; // GB
|
||||||
@ -3751,24 +3698,17 @@ static bool gbReadSaveState(gzFile gzFile)
|
|||||||
memset(pix, 0, 257*226*sizeof(u32));
|
memset(pix, 0, 257*226*sizeof(u32));
|
||||||
|
|
||||||
if(version < GBSAVE_GAME_VERSION_6) {
|
if(version < GBSAVE_GAME_VERSION_6) {
|
||||||
utilGzRead(gzFile, gbPalette, (sizeof(u16)<<6));
|
utilGzRead(gzFile, gbPalette, 64 * sizeof(u16));
|
||||||
} else{
|
} else
|
||||||
utilGzRead(gzFile, gbPalette, (sizeof(u16)<<7));
|
utilGzRead(gzFile, gbPalette, 128 * sizeof(u16));
|
||||||
}
|
|
||||||
|
|
||||||
if (version < 11){
|
if (version < 11)
|
||||||
utilGzRead(gzFile, gbPalette, (sizeof(u16)<<7));
|
utilGzRead(gzFile, gbPalette, 128 * sizeof(u16));
|
||||||
}
|
|
||||||
|
|
||||||
if(version < GBSAVE_GAME_VERSION_10) {
|
if(version < GBSAVE_GAME_VERSION_10) {
|
||||||
if(gbCgbMode || gbSgbMode) {
|
if(!gbCgbMode && !gbSgbMode) {
|
||||||
int gbp8 = gbPaletteOption << 3;
|
for(int i = 0; i < 8; i++)
|
||||||
for(int i = 0; i < 8; i+=4){
|
gbPalette[i] = systemGbPalette[gbPaletteOption*8+i];
|
||||||
gbPalette[i ] = systemGbPalette[gbp8+i ];
|
|
||||||
gbPalette[i+1] = systemGbPalette[gbp8+i+1];
|
|
||||||
gbPalette[i+2] = systemGbPalette[gbp8+i+2];
|
|
||||||
gbPalette[i+3] = systemGbPalette[gbp8+i+3];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3897,9 +3837,9 @@ static bool gbReadSaveState(gzFile gzFile)
|
|||||||
if(value == 0)
|
if(value == 0)
|
||||||
value = 1;
|
value = 1;
|
||||||
|
|
||||||
gbMemoryMap[0x08] = &gbVram[register_VBK << 13];
|
gbMemoryMap[0x08] = &gbVram[register_VBK * 0x2000];
|
||||||
gbMemoryMap[0x09] = &gbVram[(register_VBK << 13) + 0x1000];
|
gbMemoryMap[0x09] = &gbVram[register_VBK * 0x2000 + 0x1000];
|
||||||
gbMemoryMap[0x0d] = &gbWram[value << 12];
|
gbMemoryMap[0x0d] = &gbWram[value * 0x1000];
|
||||||
}
|
}
|
||||||
|
|
||||||
gbSoundReadGame(version, gzFile);
|
gbSoundReadGame(version, gzFile);
|
||||||
@ -3949,7 +3889,7 @@ static bool gbReadSaveState(gzFile gzFile)
|
|||||||
GBDIV_CLOCK_TICKS = 64;
|
GBDIV_CLOCK_TICKS = 64;
|
||||||
|
|
||||||
if (gbSpeed)
|
if (gbSpeed)
|
||||||
gbDivTicks >>=1;
|
gbDivTicks /=2;
|
||||||
|
|
||||||
if ((gbLcdMode == 0) && (register_STAT & 8))
|
if ((gbLcdMode == 0) && (register_STAT & 8))
|
||||||
gbInt48Signal |= 1;
|
gbInt48Signal |= 1;
|
||||||
@ -4000,7 +3940,7 @@ static bool gbReadSaveState(gzFile gzFile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gbSpeed)
|
if (gbSpeed)
|
||||||
gbLine99Ticks <<= 1;
|
gbLine99Ticks *= 2;
|
||||||
|
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
|
||||||
|
|
||||||
@ -4009,6 +3949,7 @@ static bool gbReadSaveState(gzFile gzFile)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gbReadMemSaveState(char *memory, int available)
|
bool gbReadMemSaveState(char *memory, int available)
|
||||||
{
|
{
|
||||||
gzFile gzFile = utilMemGzOpen(memory, available, "r");
|
gzFile gzFile = utilMemGzOpen(memory, available, "r");
|
||||||
@ -4143,11 +4084,8 @@ bool gbUpdateSizes()
|
|||||||
|
|
||||||
if(gbRomSize < gbRomSizes[gbRom[0x148]]) {
|
if(gbRomSize < gbRomSizes[gbRom[0x148]]) {
|
||||||
gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
||||||
|
for (int i = gbRomSize; i<gbRomSizes[gbRom[0x148]]; i++)
|
||||||
int gbrSize = gbRomSizes[gbRom[0x148]];
|
|
||||||
for (int i = gbRomSize; i < gbrSize; ++i){
|
|
||||||
gbRom[i] = 0x00; // Not sure if it's 0x00, 0xff or random data...
|
gbRom[i] = 0x00; // Not sure if it's 0x00, 0xff or random data...
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// (it's in the case a cart is 'lying' on its size.
|
// (it's in the case a cart is 'lying' on its size.
|
||||||
else if ((gbRomSize>gbRomSizes[gbRom[0x148]]) && (genericflashcardEnable))
|
else if ((gbRomSize>gbRomSizes[gbRom[0x148]]) && (genericflashcardEnable))
|
||||||
@ -4158,10 +4096,10 @@ bool gbUpdateSizes()
|
|||||||
{
|
{
|
||||||
while (!((gbRomSize & 1) || (gbRom[0x148] == 7)))
|
while (!((gbRomSize & 1) || (gbRom[0x148] == 7)))
|
||||||
{
|
{
|
||||||
++gbRom[0x148];
|
gbRom[0x148]++;
|
||||||
gbRomSize>>=1;
|
gbRomSize>>=1;
|
||||||
}
|
}
|
||||||
++gbRom[0x148];
|
gbRom[0x148]++;
|
||||||
}
|
}
|
||||||
gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]);
|
||||||
}
|
}
|
||||||
@ -4180,29 +4118,17 @@ bool gbUpdateSizes()
|
|||||||
u8 ramsize = genericflashcardEnable ? 5 : gbRom[0x149];
|
u8 ramsize = genericflashcardEnable ? 5 : gbRom[0x149];
|
||||||
gbRom[0x149] = ramsize;
|
gbRom[0x149] = ramsize;
|
||||||
|
|
||||||
if(((gbRom[2] - 0x6D) | (gbRom[5] - 0x47) | (gbRom[6] - 0x65) | (gbRom[7] - 0x6E) |
|
if ((gbRom[2] == 0x6D) && (gbRom[5] == 0x47) && (gbRom[6] == 0x65) && (gbRom[7] == 0x6E) &&
|
||||||
(gbRom[8] - 0x69) | (gbRom[9] - 0x65) | (gbRom[0xA] - 0x28) | (gbRom[0xB] - 0x54)) == 0)
|
(gbRom[8] == 0x69) && (gbRom[9] == 0x65) && (gbRom[0xA] == 0x28) && (gbRom[0xB] == 0x54))
|
||||||
{
|
{
|
||||||
gbCheatingDevice = 1; // GameGenie
|
gbCheatingDevice = 1; // GameGenie
|
||||||
|
for (int i = 0; i < 0x20; i++) // Cleans GG hardware registers
|
||||||
for (int i = 0; i < 0x20; i+=8){ // Cleans GG hardware registers
|
gbRom[0x4000+i] = 0;
|
||||||
gbRom[0x4000+i] =
|
|
||||||
gbRom[0x4001+i] =
|
|
||||||
gbRom[0x4002+i] =
|
|
||||||
gbRom[0x4003+i] =
|
|
||||||
gbRom[0x4004+i] =
|
|
||||||
gbRom[0x4005+i] =
|
|
||||||
gbRom[0x4006+i] =
|
|
||||||
gbRom[0x4007+i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if((((gbRom[0x104] - 0x44) | (gbRom[0x156] - 0xEA) | (gbRom[0x158] - 0x7F) |
|
|
||||||
(gbRom[0x159] - 0xEA) | (gbRom[0x15B] - 0x7F)) == 0)
|
|
||||||
|| (((gbRom[0x165] - 0x3E) | (gbRom[0x166] - 0xD9) | (gbRom[0x16D] - 0xE1) | (gbRom[0x16E] - 0x7F)) == 0))
|
|
||||||
|
|
||||||
{
|
|
||||||
gbCheatingDevice = 2; // GameShark
|
|
||||||
}
|
}
|
||||||
|
else if (((gbRom[0x104] == 0x44) && (gbRom[0x156] == 0xEA) && (gbRom[0x158] == 0x7F) &&
|
||||||
|
(gbRom[0x159] == 0xEA) && (gbRom[0x15B] == 0x7F)) || ((gbRom[0x165] == 0x3E) &&
|
||||||
|
(gbRom[0x166] == 0xD9) && (gbRom[0x16D] == 0xE1) && (gbRom[0x16E] == 0x7F)))
|
||||||
|
gbCheatingDevice = 2; // GameShark
|
||||||
else gbCheatingDevice = 0;
|
else gbCheatingDevice = 0;
|
||||||
|
|
||||||
if(ramsize > 5) {
|
if(ramsize > 5) {
|
||||||
@ -4217,6 +4143,16 @@ bool gbUpdateSizes()
|
|||||||
gbRomType = gbRom[0x147];
|
gbRomType = gbRom[0x147];
|
||||||
if (genericflashcardEnable)
|
if (genericflashcardEnable)
|
||||||
{
|
{
|
||||||
|
/*if (gbRomType<2)
|
||||||
|
gbRomType =3;
|
||||||
|
else if ((gbRomType == 0xc) || (gbRomType == 0xf) || (gbRomType == 0x12) ||
|
||||||
|
(gbRomType == 0x16) || (gbRomType == 0x1a) || (gbRomType == 0x1d))
|
||||||
|
gbRomType++;
|
||||||
|
else if ((gbRomType == 0xb) || (gbRomType == 0x11) || (gbRomType == 0x15) ||
|
||||||
|
(gbRomType == 0x19) || (gbRomType == 0x1c))
|
||||||
|
gbRomType+=2;
|
||||||
|
else if ((gbRomType == 0x5) || (gbRomType == 0x6))
|
||||||
|
gbRomType = 0x1a;*/
|
||||||
gbRomType = 0x1b;
|
gbRomType = 0x1b;
|
||||||
}
|
}
|
||||||
else if (gbCheatingDevice == 1)
|
else if (gbCheatingDevice == 1)
|
||||||
@ -4372,6 +4308,7 @@ bool gbUpdateSizes()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gbGetNextEvent (int clockTicks)
|
int gbGetNextEvent (int clockTicks)
|
||||||
{
|
{
|
||||||
if (register_LCDC & 0x80)
|
if (register_LCDC & 0x80)
|
||||||
@ -4412,27 +4349,26 @@ void gbDrawLine()
|
|||||||
u16 * dest = (u16 *)pix +
|
u16 * dest = (u16 *)pix +
|
||||||
(gbBorderLineSkip+2) * (register_LY + gbBorderRowSkip+1)
|
(gbBorderLineSkip+2) * (register_LY + gbBorderRowSkip+1)
|
||||||
+ gbBorderColumnSkip;
|
+ gbBorderColumnSkip;
|
||||||
for(u32 x = 0; x < 160u; ) {
|
for(int x = 0; x < 160; ) {
|
||||||
dest[x ] = systemColorMap16[gbLineMix[x ]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+1] = systemColorMap16[gbLineMix[x+1]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+2] = systemColorMap16[gbLineMix[x+2]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+3] = systemColorMap16[gbLineMix[x+3]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
|
|
||||||
dest[x+4] = systemColorMap16[gbLineMix[x+4]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+5] = systemColorMap16[gbLineMix[x+5]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+6] = systemColorMap16[gbLineMix[x+6]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+7] = systemColorMap16[gbLineMix[x+7]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
|
|
||||||
dest[x+8] = systemColorMap16[gbLineMix[x+8]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+9] = systemColorMap16[gbLineMix[x+9]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+10] = systemColorMap16[gbLineMix[x+10]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+11] = systemColorMap16[gbLineMix[x+11]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
|
|
||||||
dest[x+12] = systemColorMap16[gbLineMix[x+12]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+13] = systemColorMap16[gbLineMix[x+13]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+14] = systemColorMap16[gbLineMix[x+14]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
dest[x+15] = systemColorMap16[gbLineMix[x+15]];
|
*dest++ = systemColorMap16[gbLineMix[x++]];
|
||||||
x += 16;
|
|
||||||
}
|
}
|
||||||
if(gbBorderOn)
|
if(gbBorderOn)
|
||||||
dest += gbBorderColumnSkip;
|
dest += gbBorderColumnSkip;
|
||||||
@ -4445,7 +4381,7 @@ void gbDrawLine()
|
|||||||
u8 *dest = (u8 *)pix +
|
u8 *dest = (u8 *)pix +
|
||||||
3*(gbBorderLineSkip * (register_LY + gbBorderRowSkip) +
|
3*(gbBorderLineSkip * (register_LY + gbBorderRowSkip) +
|
||||||
gbBorderColumnSkip);
|
gbBorderColumnSkip);
|
||||||
for(u32 x = 0; x < 160;) {
|
for(int x = 0; x < 160;) {
|
||||||
*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
|
*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
|
||||||
dest+= 3;
|
dest+= 3;
|
||||||
*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
|
*((u32 *)dest) = systemColorMap32[gbLineMix[x++]];
|
||||||
@ -4490,32 +4426,32 @@ void gbDrawLine()
|
|||||||
u32 * dest = (u32 *)pix +
|
u32 * dest = (u32 *)pix +
|
||||||
(gbBorderLineSkip+1) * (register_LY + gbBorderRowSkip+1)
|
(gbBorderLineSkip+1) * (register_LY + gbBorderRowSkip+1)
|
||||||
+ gbBorderColumnSkip;
|
+ gbBorderColumnSkip;
|
||||||
for(u32 x = 0; x < 160u; ) {
|
for(int x = 0; x < 160;) {
|
||||||
dest[x ] = systemColorMap32[gbLineMix[x ]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+1] = systemColorMap32[gbLineMix[x+1]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+2] = systemColorMap32[gbLineMix[x+2]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+3] = systemColorMap32[gbLineMix[x+3]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
|
|
||||||
dest[x+4] = systemColorMap32[gbLineMix[x+4]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+5] = systemColorMap32[gbLineMix[x+5]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+6] = systemColorMap32[gbLineMix[x+6]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+7] = systemColorMap32[gbLineMix[x+7]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
|
|
||||||
dest[x+8] = systemColorMap32[gbLineMix[x+8]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+9] = systemColorMap32[gbLineMix[x+9]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+10] = systemColorMap32[gbLineMix[x+10]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+11] = systemColorMap32[gbLineMix[x+11]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
|
|
||||||
dest[x+12] = systemColorMap32[gbLineMix[x+12]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+13] = systemColorMap32[gbLineMix[x+13]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+14] = systemColorMap32[gbLineMix[x+14]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
dest[x+15] = systemColorMap32[gbLineMix[x+15]];
|
*dest++ = systemColorMap32[gbLineMix[x++]];
|
||||||
x+=16;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbEmulate(int ticksToStop)
|
void gbEmulate(int ticksToStop)
|
||||||
{
|
{
|
||||||
gbRegister tempRegister;
|
gbRegister tempRegister;
|
||||||
@ -4590,7 +4526,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
// PC.W is not incremented for the first byte of the next instruction.
|
// PC.W is not incremented for the first byte of the next instruction.
|
||||||
if (IFF & 2)
|
if (IFF & 2)
|
||||||
{
|
{
|
||||||
--PC.W;
|
PC.W--;
|
||||||
IFF &= ~2;
|
IFF &= ~2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4855,28 +4791,12 @@ void gbEmulate(int ticksToStop)
|
|||||||
if (wx<0)
|
if (wx<0)
|
||||||
wx = 0;
|
wx = 0;
|
||||||
|
|
||||||
if((wx <= 159) && (tempgbWindowLine <= 143)){
|
if((wx <= 159) && (tempgbWindowLine <= 143))
|
||||||
|
for (int i = wx; i<300; i++)
|
||||||
int i = 300 - 4;
|
if (gbSpeed)
|
||||||
if (gbSpeed){
|
gbSpritesTicks[i]+=3;
|
||||||
do{
|
else
|
||||||
gbSpritesTicks[i]+=3;
|
gbSpritesTicks[i]+=1;
|
||||||
gbSpritesTicks[i+1]+=3;
|
|
||||||
gbSpritesTicks[i+2]+=3;
|
|
||||||
gbSpritesTicks[i+3]+=3;
|
|
||||||
i-=4;
|
|
||||||
}while(i>=0);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
do{
|
|
||||||
++gbSpritesTicks[i];
|
|
||||||
++gbSpritesTicks[i+1];
|
|
||||||
++gbSpritesTicks[i+2];
|
|
||||||
++gbSpritesTicks[i+3];
|
|
||||||
i-=4;
|
|
||||||
}while(i>=0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4947,9 +4867,11 @@ void gbEmulate(int ticksToStop)
|
|||||||
// set the LY increment counter
|
// set the LY increment counter
|
||||||
|
|
||||||
if(register_LCDC & 0x80) {
|
if(register_LCDC & 0x80) {
|
||||||
if (gbHardware & 0xa){
|
if (gbHardware & 0xa)
|
||||||
register_IF |= 1; // V-Blank interrupt
|
{
|
||||||
gbInterruptLaunched |=1;
|
|
||||||
|
register_IF |= 1; // V-Blank interrupt
|
||||||
|
gbInterruptLaunched |=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4958,7 +4880,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
gbLcdTicksDelayed += GBLCD_MODE_1_CLOCK_TICKS;
|
gbLcdTicksDelayed += GBLCD_MODE_1_CLOCK_TICKS;
|
||||||
gbLcdModeDelayed = 1;
|
gbLcdModeDelayed = 1;
|
||||||
|
|
||||||
++gbFrameCount;
|
gbFrameCount++;
|
||||||
systemFrame();
|
systemFrame();
|
||||||
|
|
||||||
if((gbFrameCount % 10) == 0)
|
if((gbFrameCount % 10) == 0)
|
||||||
@ -4977,12 +4899,15 @@ void gbEmulate(int ticksToStop)
|
|||||||
if(systemReadJoypads()) {
|
if(systemReadJoypads()) {
|
||||||
// read joystick
|
// read joystick
|
||||||
if(gbSgbMode && gbSgbMultiplayer) {
|
if(gbSgbMode && gbSgbMultiplayer) {
|
||||||
gbJoymask[0] = systemReadJoypad(0);
|
if(gbSgbFourPlayers) {
|
||||||
gbJoymask[1] = systemReadJoypad(1);
|
gbJoymask[0] = systemReadJoypad(0);
|
||||||
if(gbSgbFourPlayers) {
|
gbJoymask[1] = systemReadJoypad(1);
|
||||||
gbJoymask[2] = systemReadJoypad(2);
|
gbJoymask[2] = systemReadJoypad(2);
|
||||||
gbJoymask[3] = systemReadJoypad(3);
|
gbJoymask[3] = systemReadJoypad(3);
|
||||||
}
|
} else {
|
||||||
|
gbJoymask[0] = systemReadJoypad(0);
|
||||||
|
gbJoymask[1] = systemReadJoypad(1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
gbJoymask[0] = systemReadJoypad(-1);
|
gbJoymask[0] = systemReadJoypad(-1);
|
||||||
}
|
}
|
||||||
@ -5005,7 +4930,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
gbCapture = (newmask & 2) ? true : false;
|
gbCapture = (newmask & 2) ? true : false;
|
||||||
|
|
||||||
if(gbCapture && !gbCapturePrevious) {
|
if(gbCapture && !gbCapturePrevious) {
|
||||||
++gbCaptureNumber;
|
gbCaptureNumber++;
|
||||||
systemScreenCapture(gbCaptureNumber);
|
systemScreenCapture(gbCaptureNumber);
|
||||||
}
|
}
|
||||||
gbCapturePrevious = gbCapture;
|
gbCapturePrevious = gbCapture;
|
||||||
@ -5021,7 +4946,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
}
|
}
|
||||||
gbFrameSkipCount = 0;
|
gbFrameSkipCount = 0;
|
||||||
} else
|
} else
|
||||||
++gbFrameSkipCount;
|
gbFrameSkipCount++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// go the the OAM being accessed mode
|
// go the the OAM being accessed mode
|
||||||
@ -5074,19 +4999,11 @@ void gbEmulate(int ticksToStop)
|
|||||||
if (!gbCgbMode)
|
if (!gbCgbMode)
|
||||||
color = gbColorOption ? gbColorFilter[gbPalette[3] & 0x7FFF] :
|
color = gbColorOption ? gbColorFilter[gbPalette[3] & 0x7FFF] :
|
||||||
gbPalette[3] & 0x7FFF;
|
gbPalette[3] & 0x7FFF;
|
||||||
|
for(int i = 0; i < 160; i++)
|
||||||
int i = 160-4;
|
{
|
||||||
do{
|
gbLineMix[i] = color;
|
||||||
gbLineMix[i ] =
|
gbLineBuffer[i] = 0;
|
||||||
gbLineMix[i+1] =
|
}
|
||||||
gbLineMix[i+2] =
|
|
||||||
gbLineMix[i+3] = color;
|
|
||||||
gbLineBuffer[i] =
|
|
||||||
gbLineBuffer[i+1] =
|
|
||||||
gbLineBuffer[i+2] =
|
|
||||||
gbLineBuffer[i+3] = 0;
|
|
||||||
i-=4;
|
|
||||||
}while(i >= 0);
|
|
||||||
}
|
}
|
||||||
gbDrawLine();
|
gbDrawLine();
|
||||||
}
|
}
|
||||||
@ -5139,7 +5056,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Used to update the screen with white lines when it's off.
|
// Used to update the screen with white lines when it's off.
|
||||||
// (it looks strange, but it's kinda accurate)
|
// (it looks strange, but it's kinda accurate :p)
|
||||||
// You can try the Mario Demo Vx.x for exemple
|
// You can try the Mario Demo Vx.x for exemple
|
||||||
// (check the bottom 2 lines while moving)
|
// (check the bottom 2 lines while moving)
|
||||||
if (!gbWhiteScreen)
|
if (!gbWhiteScreen)
|
||||||
@ -5155,27 +5072,18 @@ void gbEmulate(int ticksToStop)
|
|||||||
{
|
{
|
||||||
gbWhiteScreen = 1;
|
gbWhiteScreen = 1;
|
||||||
u8 register_LYLcdOff = ((register_LY+154)%154);
|
u8 register_LYLcdOff = ((register_LY+154)%154);
|
||||||
for (register_LY=0;register_LY <= 0x90;++register_LY)
|
for (register_LY=0;register_LY <= 0x90;register_LY++)
|
||||||
{
|
{
|
||||||
u16 color = gbColorOption ? gbColorFilter[0x7FFF] :
|
u16 color = gbColorOption ? gbColorFilter[0x7FFF] :
|
||||||
0x7FFF;
|
0x7FFF;
|
||||||
if (!gbCgbMode)
|
if (!gbCgbMode)
|
||||||
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
|
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
|
||||||
gbPalette[0] & 0x7FFF;
|
gbPalette[0] & 0x7FFF;
|
||||||
|
for(int i = 0; i < 160; i++)
|
||||||
int i = 160 - 4;
|
{
|
||||||
do{
|
gbLineMix[i] = color;
|
||||||
|
gbLineBuffer[i] = 0;
|
||||||
gbLineMix[i ] =
|
}
|
||||||
gbLineMix[i+1] =
|
|
||||||
gbLineMix[i+2] =
|
|
||||||
gbLineMix[i+3] = color;
|
|
||||||
gbLineBuffer[i] =
|
|
||||||
gbLineBuffer[i+1] =
|
|
||||||
gbLineBuffer[i+2] =
|
|
||||||
gbLineBuffer[i+3] = 0;
|
|
||||||
i-=4;
|
|
||||||
}while(i >= 0);
|
|
||||||
gbDrawLine();
|
gbDrawLine();
|
||||||
}
|
}
|
||||||
register_LY = register_LYLcdOff;
|
register_LY = register_LYLcdOff;
|
||||||
@ -5198,20 +5106,11 @@ void gbEmulate(int ticksToStop)
|
|||||||
if (!gbCgbMode)
|
if (!gbCgbMode)
|
||||||
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
|
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
|
||||||
gbPalette[0] & 0x7FFF;
|
gbPalette[0] & 0x7FFF;
|
||||||
|
for(int i = 0; i < 160; i++)
|
||||||
int i = 160 - 4;
|
{
|
||||||
do{
|
gbLineMix[i] = color;
|
||||||
gbLineMix[i ] =
|
gbLineBuffer[i] = 0;
|
||||||
gbLineMix[i+1] =
|
}
|
||||||
gbLineMix[i+2] =
|
|
||||||
gbLineMix[i+3] = color;
|
|
||||||
gbLineBuffer[i] =
|
|
||||||
gbLineBuffer[i+1] =
|
|
||||||
gbLineBuffer[i+2] =
|
|
||||||
gbLineBuffer[i+3] = 0;
|
|
||||||
i-=4;
|
|
||||||
}while(i >= 0);
|
|
||||||
|
|
||||||
gbDrawLine();
|
gbDrawLine();
|
||||||
}
|
}
|
||||||
else if ((register_LY==144) && (!systemFrameSkip))
|
else if ((register_LY==144) && (!systemFrameSkip))
|
||||||
@ -5233,17 +5132,20 @@ void gbEmulate(int ticksToStop)
|
|||||||
if(systemReadJoypads()) {
|
if(systemReadJoypads()) {
|
||||||
// read joystick
|
// read joystick
|
||||||
if(gbSgbMode && gbSgbMultiplayer) {
|
if(gbSgbMode && gbSgbMultiplayer) {
|
||||||
gbJoymask[0] = systemReadJoypad(0);
|
if(gbSgbFourPlayers) {
|
||||||
|
gbJoymask[0] = systemReadJoypad(0);
|
||||||
gbJoymask[1] = systemReadJoypad(1);
|
gbJoymask[1] = systemReadJoypad(1);
|
||||||
if(gbSgbFourPlayers) {
|
|
||||||
gbJoymask[2] = systemReadJoypad(2);
|
gbJoymask[2] = systemReadJoypad(2);
|
||||||
gbJoymask[3] = systemReadJoypad(3);
|
gbJoymask[3] = systemReadJoypad(3);
|
||||||
|
} else {
|
||||||
|
gbJoymask[0] = systemReadJoypad(0);
|
||||||
|
gbJoymask[1] = systemReadJoypad(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gbJoymask[0] = systemReadJoypad(-1);
|
gbJoymask[0] = systemReadJoypad(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++gbFrameCount;
|
gbFrameCount++;
|
||||||
|
|
||||||
systemFrame();
|
systemFrame();
|
||||||
|
|
||||||
@ -5274,7 +5176,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
|
|
||||||
while(gbSerialTicks <= 0) {
|
while(gbSerialTicks <= 0) {
|
||||||
// increment number of shifted bits
|
// increment number of shifted bits
|
||||||
++gbSerialBits;
|
gbSerialBits++;
|
||||||
linkProc();
|
linkProc();
|
||||||
if(gbSerialOn && (gbMemory[0xff02] & 1)) {
|
if(gbSerialOn && (gbMemory[0xff02] & 1)) {
|
||||||
if(gbSerialBits == 8) {
|
if(gbSerialBits == 8) {
|
||||||
@ -5298,7 +5200,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
// shift serial byte to right and put a 1 bit in its place
|
// shift serial byte to right and put a 1 bit in its place
|
||||||
// gbMemory[0xff01] = 0x80 | (gbMemory[0xff01]>>1);
|
// gbMemory[0xff01] = 0x80 | (gbMemory[0xff01]>>1);
|
||||||
// increment number of shifted bits
|
// increment number of shifted bits
|
||||||
++gbSerialBits;
|
gbSerialBits++;
|
||||||
if(gbSerialBits == 8) {
|
if(gbSerialBits == 8) {
|
||||||
// end of transmission
|
// end of transmission
|
||||||
if(gbSerialFunction) // external device
|
if(gbSerialFunction) // external device
|
||||||
@ -5337,7 +5239,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
gbTimerTicks= ((gbInternalTimer) & gbTimerMask[gbTimerMode])+1-clockTicks;
|
gbTimerTicks= ((gbInternalTimer) & gbTimerMask[gbTimerMode])+1-clockTicks;
|
||||||
|
|
||||||
while(gbTimerTicks <= 0) {
|
while(gbTimerTicks <= 0) {
|
||||||
++register_TIMA;
|
register_TIMA++;
|
||||||
// timer overflow!
|
// timer overflow!
|
||||||
if((register_TIMA & 0xff) == 0) {
|
if((register_TIMA & 0xff) == 0) {
|
||||||
// reload timer modulo
|
// reload timer modulo
|
||||||
@ -5432,7 +5334,7 @@ void gbEmulate(int ticksToStop)
|
|||||||
|
|
||||||
if (gbIntBreak == 2)
|
if (gbIntBreak == 2)
|
||||||
{
|
{
|
||||||
--gbDmaTicks;
|
gbDmaTicks--;
|
||||||
gbIntBreak = 0;
|
gbIntBreak = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5478,11 +5380,14 @@ void gbEmulate(int ticksToStop)
|
|||||||
if(systemReadJoypads()) {
|
if(systemReadJoypads()) {
|
||||||
// read joystick
|
// read joystick
|
||||||
if(gbSgbMode && gbSgbMultiplayer) {
|
if(gbSgbMode && gbSgbMultiplayer) {
|
||||||
gbJoymask[0] = systemReadJoypad(0);
|
if(gbSgbFourPlayers) {
|
||||||
gbJoymask[1] = systemReadJoypad(1);
|
gbJoymask[0] = systemReadJoypad(0);
|
||||||
if(gbSgbFourPlayers) {
|
gbJoymask[1] = systemReadJoypad(1);
|
||||||
gbJoymask[2] = systemReadJoypad(2);
|
gbJoymask[2] = systemReadJoypad(2);
|
||||||
gbJoymask[3] = systemReadJoypad(3);
|
gbJoymask[3] = systemReadJoypad(3);
|
||||||
|
} else {
|
||||||
|
gbJoymask[0] = systemReadJoypad(0);
|
||||||
|
gbJoymask[1] = systemReadJoypad(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gbJoymask[0] = systemReadJoypad(-1);
|
gbJoymask[0] = systemReadJoypad(-1);
|
||||||
|
@ -78,7 +78,7 @@ void gbRenderLine()
|
|||||||
if(y >= 144)
|
if(y >= 144)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int SpritesTicks = gbSpritesTicks[x] << (gbSpeed ? 1 : 2);
|
int SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4);
|
||||||
int sx = gbSCXLine[(gbSpeed ? 0 : 4)+SpritesTicks];
|
int sx = gbSCXLine[(gbSpeed ? 0 : 4)+SpritesTicks];
|
||||||
int sy = gbSCYLine[(gbSpeed ? 11 : 5)+SpritesTicks];
|
int sy = gbSCYLine[(gbSpeed ? 11 : 5)+SpritesTicks];
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ void gbRenderLine()
|
|||||||
int bx = 1 << (7 - (sx & 7));
|
int bx = 1 << (7 - (sx & 7));
|
||||||
int by = sy & 7;
|
int by = sy & 7;
|
||||||
|
|
||||||
int tile_map_line_y = tile_map + (ty <<5);
|
int tile_map_line_y = tile_map + ty * 32;
|
||||||
|
|
||||||
int tile_map_address = tile_map_line_y + tx;
|
int tile_map_address = tile_map_line_y + tx;
|
||||||
|
|
||||||
@ -102,22 +102,24 @@ void gbRenderLine()
|
|||||||
|
|
||||||
u8 tile = bank0[tile_map_address];
|
u8 tile = bank0[tile_map_address];
|
||||||
|
|
||||||
++tile_map_address;
|
tile_map_address++;
|
||||||
|
|
||||||
if(!(register_LCDC & 0x10))
|
if(!(register_LCDC & 0x10))
|
||||||
tile ^= 0x80;
|
tile ^= 0x80;
|
||||||
|
|
||||||
int tile_pattern_address = tile_pattern + (tile<< 4) + (by<<1);
|
int tile_pattern_address = tile_pattern + tile * 16 + by*2;
|
||||||
|
|
||||||
if(register_LCDC & 0x80) {
|
if(register_LCDC & 0x80) {
|
||||||
if((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100)) {
|
if((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100)) {
|
||||||
while(x < 160) {
|
while(x < 160) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
u8 tile_a = 0;
|
u8 tile_a = 0;
|
||||||
u8 tile_b = 0;
|
u8 tile_b = 0;
|
||||||
|
|
||||||
if(attrs & 0x40) {
|
if(attrs & 0x40) {
|
||||||
tile_pattern_address = tile_pattern + (tile<<4) + ((7-by)<<1);
|
tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attrs & 0x08) {
|
if(attrs & 0x08) {
|
||||||
@ -143,7 +145,7 @@ void gbRenderLine()
|
|||||||
gbLineBuffer[x] |= 0x300;
|
gbLineBuffer[x] |= 0x300;
|
||||||
|
|
||||||
if(gbCgbMode) {
|
if(gbCgbMode) {
|
||||||
c += (attrs & 7)<<2;
|
c = c + (attrs & 7)*4;
|
||||||
} else {
|
} else {
|
||||||
// Get the background palette to use (from the delayed pipeline)
|
// Get the background palette to use (from the delayed pipeline)
|
||||||
u8 BgPal = gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks];
|
u8 BgPal = gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks];
|
||||||
@ -158,7 +160,7 @@ void gbRenderLine()
|
|||||||
if(c == 0)
|
if(c == 0)
|
||||||
palette = 0;
|
palette = 0;
|
||||||
|
|
||||||
c += palette<<2;
|
c = c + 4*palette;
|
||||||
// Mono Game Boy requires special palette handling
|
// Mono Game Boy requires special palette handling
|
||||||
} else {
|
} else {
|
||||||
if (BgPal!=oldBgPal) {
|
if (BgPal!=oldBgPal) {
|
||||||
@ -166,11 +168,12 @@ void gbRenderLine()
|
|||||||
oldBgPal = BgPal;
|
oldBgPal = BgPal;
|
||||||
}
|
}
|
||||||
if (!ColorizeGameboy) c = (BgPal>>(c<<1)) &3;
|
if (!ColorizeGameboy) c = (BgPal>>(c<<1)) &3;
|
||||||
|
else c += 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
|
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
|
||||||
gbPalette[c] & 0x7FFF;
|
gbPalette[c] & 0x7FFF;
|
||||||
++x;
|
x++;
|
||||||
if(x >= 160)
|
if(x >= 160)
|
||||||
break;
|
break;
|
||||||
bx >>= 1;
|
bx >>= 1;
|
||||||
@ -178,7 +181,7 @@ void gbRenderLine()
|
|||||||
|
|
||||||
bx = 128;
|
bx = 128;
|
||||||
|
|
||||||
SpritesTicks = gbSpritesTicks[x] << (gbSpeed ? 1 : 2);
|
SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4);
|
||||||
|
|
||||||
sx = gbSCXLine[x+(gbSpeed ? 0 : 4)+SpritesTicks];
|
sx = gbSCXLine[x+(gbSpeed ? 0 : 4)+SpritesTicks];
|
||||||
|
|
||||||
@ -195,9 +198,9 @@ void gbRenderLine()
|
|||||||
|
|
||||||
by = sy & 7;
|
by = sy & 7;
|
||||||
|
|
||||||
tile_pattern_address = tile_pattern + (tile<<4) + (by<<1);
|
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
|
||||||
|
|
||||||
tile_map_line_y = tile_map + (ty<<5);
|
tile_map_line_y = tile_map + ty * 32;
|
||||||
|
|
||||||
tile_map_address = tile_map_line_y + tx;
|
tile_map_address = tile_map_line_y + tx;
|
||||||
|
|
||||||
@ -209,7 +212,7 @@ void gbRenderLine()
|
|||||||
if(!(register_LCDC & 0x10))
|
if(!(register_LCDC & 0x10))
|
||||||
tile ^= 0x80;
|
tile ^= 0x80;
|
||||||
|
|
||||||
tile_pattern_address = tile_pattern + (tile<<4) + (by<<1);
|
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use gbBgp[0] instead of 0 (?)
|
// Use gbBgp[0] instead of 0 (?)
|
||||||
@ -217,11 +220,11 @@ void gbRenderLine()
|
|||||||
// 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;
|
u16 color = gbColorOption ? gbColorFilter[0x7FFF] :
|
||||||
|
0x7FFF;
|
||||||
if (!gbCgbMode) {
|
if (!gbCgbMode) {
|
||||||
// Get the background palette to use (from the delayed pipeline)
|
// Get the background palette to use (from the delayed pipeline)
|
||||||
|
u8 BgPal = gbBgpLine[i+(gbSpeed ? 5 : 11)+gbSpritesTicks[i]*(gbSpeed ? 2 : 4)];
|
||||||
u8 BgPal = gbBgpLine[i+(gbSpeed ? 5 : 11)+(gbSpritesTicks[i] << (gbSpeed ? 1 : 2))];
|
|
||||||
if ((BgPal!=oldBgPal) && !gbSgbMode) {
|
if ((BgPal!=oldBgPal) && !gbSgbMode) {
|
||||||
gbSetBGPalette(BgPal);
|
gbSetBGPalette(BgPal);
|
||||||
oldBgPal = BgPal;
|
oldBgPal = BgPal;
|
||||||
@ -277,7 +280,7 @@ void gbRenderLine()
|
|||||||
by = gbWindowLine & 7;
|
by = gbWindowLine & 7;
|
||||||
|
|
||||||
// Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7).
|
// Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7).
|
||||||
// Nothing close to perfect, but good enough for now...
|
// Nothing close to perfect, but good enought for now...
|
||||||
if (wx == -7)
|
if (wx == -7)
|
||||||
{
|
{
|
||||||
swx = 7-((gbSCXLine[0]-1) & 7);
|
swx = 7-((gbSCXLine[0]-1) & 7);
|
||||||
@ -300,7 +303,7 @@ void gbRenderLine()
|
|||||||
wx = 0;
|
wx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_map_line_y = tile_map + (ty<<5);
|
tile_map_line_y = tile_map + ty * 32;
|
||||||
|
|
||||||
tile_map_address = tile_map_line_y + tx;
|
tile_map_address = tile_map_line_y + tx;
|
||||||
|
|
||||||
@ -310,29 +313,25 @@ void gbRenderLine()
|
|||||||
u8 attrs = 0;
|
u8 attrs = 0;
|
||||||
if(bank1)
|
if(bank1)
|
||||||
attrs = bank1[tile_map_address];
|
attrs = bank1[tile_map_address];
|
||||||
++tile_map_address;
|
tile_map_address++;
|
||||||
|
|
||||||
if((register_LCDC & 16) == 0) {
|
if((register_LCDC & 16) == 0) {
|
||||||
if(tile < 128) tile += 128;
|
if(tile < 128) tile += 128;
|
||||||
else tile -= 128;
|
else tile -= 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_pattern_address = tile_pattern + (tile<<4) + (by<<1);
|
tile_pattern_address = tile_pattern + tile * 16 + by*2;
|
||||||
|
|
||||||
if (wx){
|
if (wx)
|
||||||
i = swx - 1;
|
for (i = 0; i<swx; i++)
|
||||||
do{
|
gbLineMix[i] = gbWindowColor[i];
|
||||||
gbLineMix[i] = gbWindowColor[i];
|
|
||||||
--i;
|
|
||||||
}while(i >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(x < 160) {
|
while(x < 160) {
|
||||||
u8 tile_a = 0;
|
u8 tile_a = 0;
|
||||||
u8 tile_b = 0;
|
u8 tile_b = 0;
|
||||||
|
|
||||||
if(attrs & 0x40) {
|
if(attrs & 0x40) {
|
||||||
tile_pattern_address = tile_pattern + (tile<<4) + ((7-by)<<1);
|
tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attrs & 0x08) {
|
if(attrs & 0x08) {
|
||||||
@ -360,7 +359,7 @@ void gbRenderLine()
|
|||||||
gbLineBuffer[x] = 0x100 + c;
|
gbLineBuffer[x] = 0x100 + c;
|
||||||
|
|
||||||
if(gbCgbMode) {
|
if(gbCgbMode) {
|
||||||
c += (attrs & 7) <<2;
|
c = c + (attrs & 7) * 4;
|
||||||
} else {
|
} else {
|
||||||
// Get the background palette to use (from the delayed pipeline)
|
// Get the background palette to use (from the delayed pipeline)
|
||||||
u8 BgPal = gbBgpLine[x+(gbSpeed ? 5 : 11)+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)];
|
u8 BgPal = gbBgpLine[x+(gbSpeed ? 5 : 11)+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)];
|
||||||
@ -375,7 +374,7 @@ void gbRenderLine()
|
|||||||
if(c == 0)
|
if(c == 0)
|
||||||
palette = 0;
|
palette = 0;
|
||||||
|
|
||||||
c += palette<<2;
|
c = c + 4*palette;
|
||||||
// Mono Game Boy requires special palette handling
|
// Mono Game Boy requires special palette handling
|
||||||
} else {
|
} else {
|
||||||
if (BgPal!=oldBgPal) {
|
if (BgPal!=oldBgPal) {
|
||||||
@ -389,12 +388,12 @@ void gbRenderLine()
|
|||||||
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
|
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
|
||||||
gbPalette[c] & 0x7FFF;
|
gbPalette[c] & 0x7FFF;
|
||||||
}
|
}
|
||||||
++x;
|
x++;
|
||||||
if(x >= 160)
|
if(x >= 160)
|
||||||
break;
|
break;
|
||||||
bx >>= 1;
|
bx >>= 1;
|
||||||
}
|
}
|
||||||
++tx;
|
tx++;
|
||||||
if(tx == 32)
|
if(tx == 32)
|
||||||
tx = 0;
|
tx = 0;
|
||||||
bx = 128;
|
bx = 128;
|
||||||
@ -406,12 +405,12 @@ void gbRenderLine()
|
|||||||
if(tile < 128) tile += 128;
|
if(tile < 128) tile += 128;
|
||||||
else tile -= 128;
|
else tile -= 128;
|
||||||
}
|
}
|
||||||
tile_pattern_address = tile_pattern + (tile<<4) + (by<<1);
|
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//for (i = swx; i<160; i++)
|
//for (i = swx; i<160; i++)
|
||||||
// gbLineMix[i] = gbWindowColor[i];
|
// gbLineMix[i] = gbWindowColor[i];
|
||||||
++gbWindowLine;
|
gbWindowLine++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,25 +423,16 @@ void gbRenderLine()
|
|||||||
gbWindowLine = 0;
|
gbWindowLine = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
u16 color = gbColorOption ? gbColorFilter[0x7FFF] : 0x7FFF;
|
u16 color = gbColorOption ? gbColorFilter[0x7FFF] :
|
||||||
|
0x7FFF;
|
||||||
if (!gbCgbMode)
|
if (!gbCgbMode)
|
||||||
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
|
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
|
||||||
gbPalette[0] & 0x7FFF;
|
gbPalette[0] & 0x7FFF;
|
||||||
|
for(int i = 0; i < 160; i++)
|
||||||
int i = 160 - 4;
|
{
|
||||||
do{
|
gbLineMix[i] = color;
|
||||||
|
gbLineBuffer[i] = 0;
|
||||||
gbLineMix[i] =
|
}
|
||||||
gbLineMix[i+1] =
|
|
||||||
gbLineMix[i+2] =
|
|
||||||
gbLineMix[i+3] = color;
|
|
||||||
gbLineBuffer[i] =
|
|
||||||
gbLineBuffer[i+1] =
|
|
||||||
gbLineBuffer[i+2] =
|
|
||||||
gbLineBuffer[i+3] = 0;
|
|
||||||
|
|
||||||
i-=4;
|
|
||||||
}while(i>=0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +466,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
if(!gbCgbMode) {
|
if(!gbCgbMode) {
|
||||||
if(flags & 0x10) {
|
if(flags & 0x10) {
|
||||||
pal = gbObp1;
|
pal = gbObp1;
|
||||||
ObjPal = gbObp1Line[x+11+(gbSpritesTicks[x] << (gbSpeed ? 1 : 2))];
|
ObjPal = gbObp1Line[x+11+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)];
|
||||||
if (ObjPal!=oldObj1Pal && !gbSgbMode) {
|
if (ObjPal!=oldObj1Pal && !gbSgbMode) {
|
||||||
gbSetObj1Palette(ObjPal);
|
gbSetObj1Palette(ObjPal);
|
||||||
oldObj1Pal = ObjPal;
|
oldObj1Pal = ObjPal;
|
||||||
@ -484,7 +474,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
PalOffset = 12;
|
PalOffset = 12;
|
||||||
} else {
|
} else {
|
||||||
pal = gbObp0;
|
pal = gbObp0;
|
||||||
ObjPal = gbObp0Line[x+11+(gbSpritesTicks[x] << (gbSpeed ? 1 : 2))];
|
ObjPal = gbObp0Line[x+11+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)];
|
||||||
if (ObjPal!=oldObj0Pal && !gbSgbMode) {
|
if (ObjPal!=oldObj0Pal && !gbSgbMode) {
|
||||||
gbSetObj0Palette(ObjPal);
|
gbSetObj0Palette(ObjPal);
|
||||||
oldObj0Pal = ObjPal;
|
oldObj0Pal = ObjPal;
|
||||||
@ -502,7 +492,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
|
|
||||||
int prio = flags & 0x80;
|
int prio = flags & 0x80;
|
||||||
|
|
||||||
int address = init + (tile<<4) + (t<<1);
|
int address = init + tile * 16 + 2*t;
|
||||||
int a = 0;
|
int a = 0;
|
||||||
int b = 0;
|
int b = 0;
|
||||||
|
|
||||||
@ -514,11 +504,11 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
b = bank0[address++];
|
b = bank0[address++];
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int xx = 0; xx < 8; ++xx) {
|
for(int xx = 0; xx < 8; xx++) {
|
||||||
u8 mask = 1 << (7-xx);
|
u8 mask = 1 << (7-xx);
|
||||||
u8 c = 0;
|
u8 c = 0;
|
||||||
if( (a & mask))
|
if( (a & mask))
|
||||||
++c;
|
c++;
|
||||||
if( (b & mask))
|
if( (b & mask))
|
||||||
c+=2;
|
c+=2;
|
||||||
|
|
||||||
@ -529,7 +519,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
if(flipx)
|
if(flipx)
|
||||||
xxx = (7-xx+x);
|
xxx = (7-xx+x);
|
||||||
|
|
||||||
if(unsigned(xxx-1) >= 159)
|
if(xxx < 0 || xxx > 159)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u16 color = gbLineBuffer[xxx];
|
u16 color = gbLineBuffer[xxx];
|
||||||
@ -540,13 +530,12 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Fixes OAM-BG priority for Moorhuhn 2
|
// Fixes OAM-BG priority for Moorhuhn 2
|
||||||
if(color >= 0x300 && color != 0x300 && (register_LCDC & 1)){
|
if(color >= 0x300 && color != 0x300 && (register_LCDC & 1))
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}else if(color >= 0x200 && color < 0x300) {
|
else if(color >= 0x200 && color < 0x300) {
|
||||||
int sprite = color & 0xff;
|
int sprite = color & 0xff;
|
||||||
|
|
||||||
int spriteX = gbMemory[0xfe00 + (sprite<<2) + 1] - 8;
|
int spriteX = gbMemory[0xfe00 + 4 * sprite + 1] - 8;
|
||||||
|
|
||||||
if(spriteX == x) {
|
if(spriteX == x) {
|
||||||
if(sprite < spriteNumber)
|
if(sprite < spriteNumber)
|
||||||
@ -569,7 +558,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
|
|
||||||
// make sure that sprites will work even in CGB mode
|
// make sure that sprites will work even in CGB mode
|
||||||
if(gbCgbMode) {
|
if(gbCgbMode) {
|
||||||
c += ((flags & 0x07)<<2) + 32;
|
c = c + (flags & 0x07)*4 + 32;
|
||||||
} else {
|
} else {
|
||||||
// Super Game Boy has its own special palettes
|
// Super Game Boy has its own special palettes
|
||||||
if(gbSgbMode) {
|
if(gbSgbMode) {
|
||||||
@ -582,7 +571,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||||||
if(c == 0)
|
if(c == 0)
|
||||||
palette = 0;
|
palette = 0;
|
||||||
|
|
||||||
c += palette<<2;
|
c = c + 4*palette;
|
||||||
// Monochrome Game Boy
|
// Monochrome Game Boy
|
||||||
} else {
|
} else {
|
||||||
if (!ColorizeGameboy) c = (ObjPal>>(c<<1)) &3;
|
if (!ColorizeGameboy) c = (ObjPal>>(c<<1)) &3;
|
||||||
@ -613,7 +602,7 @@ void gbDrawSprites(bool draw)
|
|||||||
int yc = register_LY;
|
int yc = register_LY;
|
||||||
|
|
||||||
int address = 0xfe00;
|
int address = 0xfe00;
|
||||||
for(int i = 0; i < 40; ++i) {
|
for(int i = 0; i < 40; i++) {
|
||||||
y = gbMemory[address++];
|
y = gbMemory[address++];
|
||||||
x = gbMemory[address++];
|
x = gbMemory[address++];
|
||||||
int tile = gbMemory[address++];
|
int tile = gbMemory[address++];
|
||||||
@ -621,74 +610,24 @@ void gbDrawSprites(bool draw)
|
|||||||
tile &= 254;
|
tile &= 254;
|
||||||
int flags = gbMemory[address++];
|
int flags = gbMemory[address++];
|
||||||
|
|
||||||
// Subtract 1 because we're not checking against greater-equal 0
|
if(x > 0 && y > 0 && x < 168 && y < 160) {
|
||||||
if(unsigned(x-1) < 167 && unsigned(y-1) < 159) {
|
|
||||||
// check if sprite intersects current line
|
// check if sprite intersects current line
|
||||||
int t = yc -y + 16;
|
int t = yc -y + 16;
|
||||||
|
if((size && t >=0 && t < 16) || (!size && t >= 0 && t < 8)) {
|
||||||
if((size && (unsigned(t) < 16u)) || (!size && (unsigned(t) < 8u))) {
|
|
||||||
if (draw)
|
if (draw)
|
||||||
gbDrawSpriteTile(tile,x-8,yc,t,flags,size,i);
|
gbDrawSpriteTile(tile,x-8,yc,t,flags,size,i);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int j = x - 8;
|
for (int j = x-8; j<300; j++)
|
||||||
// Less than 0 or divisible by 4
|
if (j>=0)
|
||||||
if(j < 0 || (j & 3) == 0){
|
{
|
||||||
|
if (gbSpeed)
|
||||||
// If it's less than 0, set it to 0, and then we KNOW
|
gbSpritesTicks[j] += 5;
|
||||||
// that it can be incremented by 4.
|
else
|
||||||
if(j < 0) j = 0;
|
gbSpritesTicks[j] += 2+(count&1);
|
||||||
// Yeah, we have to check twice. It's either that or
|
}
|
||||||
// have a (rather large) duplicate if-else statement
|
|
||||||
|
|
||||||
if(gbSpeed){
|
|
||||||
for (; j<300; j+=4){
|
|
||||||
gbSpritesTicks[j] += 5;
|
|
||||||
gbSpritesTicks[j+1] += 5;
|
|
||||||
gbSpritesTicks[j+2] += 5;
|
|
||||||
gbSpritesTicks[j+3] += 5;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
int count2 = 2 + (count & 1);
|
|
||||||
for (; j<300; j+=4){
|
|
||||||
gbSpritesTicks[j] += count2;
|
|
||||||
gbSpritesTicks[j+1] += count2;
|
|
||||||
gbSpritesTicks[j+2] += count2;
|
|
||||||
gbSpritesTicks[j+3] += count2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//divisible by 2 at least?
|
|
||||||
else if((j & 1) == 0){
|
|
||||||
if(gbSpeed){
|
|
||||||
for (; j<300; j+=2){
|
|
||||||
gbSpritesTicks[j] += 5;
|
|
||||||
gbSpritesTicks[j+1] += 5;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
int count2 = 2 + (count & 1);
|
|
||||||
for (; j<300; j+=2){
|
|
||||||
gbSpritesTicks[j] += count2;
|
|
||||||
gbSpritesTicks[j+1] += count2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// Not divisible by 4 OR 2: use the old one
|
|
||||||
else{
|
|
||||||
if(gbSpeed){
|
|
||||||
for (; j<300; ++j){
|
|
||||||
gbSpritesTicks[j] += 5;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
int count2 = 2 + (count & 1);
|
|
||||||
for (; j<300; ++j){
|
|
||||||
gbSpritesTicks[j] += count2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
++count;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sprite limit reached!
|
// sprite limit reached!
|
||||||
|
@ -334,7 +334,7 @@ void memoryUpdateMBC3Clock()
|
|||||||
gbDataMBC3.mapperSeconds += (int)(diff % 60);
|
gbDataMBC3.mapperSeconds += (int)(diff % 60);
|
||||||
if(gbDataMBC3.mapperSeconds > 59) {
|
if(gbDataMBC3.mapperSeconds > 59) {
|
||||||
gbDataMBC3.mapperSeconds -= 60;
|
gbDataMBC3.mapperSeconds -= 60;
|
||||||
++gbDataMBC3.mapperMinutes;
|
gbDataMBC3.mapperMinutes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff /= 60;
|
diff /= 60;
|
||||||
@ -342,7 +342,7 @@ void memoryUpdateMBC3Clock()
|
|||||||
gbDataMBC3.mapperMinutes += (int)(diff % 60);
|
gbDataMBC3.mapperMinutes += (int)(diff % 60);
|
||||||
if(gbDataMBC3.mapperMinutes > 59) {
|
if(gbDataMBC3.mapperMinutes > 59) {
|
||||||
gbDataMBC3.mapperMinutes -= 60;
|
gbDataMBC3.mapperMinutes -= 60;
|
||||||
++gbDataMBC3.mapperHours;
|
gbDataMBC3.mapperHours++;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff /= 60;
|
diff /= 60;
|
||||||
@ -350,7 +350,7 @@ void memoryUpdateMBC3Clock()
|
|||||||
gbDataMBC3.mapperHours += (int)(diff % 24);
|
gbDataMBC3.mapperHours += (int)(diff % 24);
|
||||||
if(gbDataMBC3.mapperHours > 23) {
|
if(gbDataMBC3.mapperHours > 23) {
|
||||||
gbDataMBC3.mapperHours -= 24;
|
gbDataMBC3.mapperHours -= 24;
|
||||||
++gbDataMBC3.mapperDays;
|
gbDataMBC3.mapperDays++;
|
||||||
}
|
}
|
||||||
diff /= 24;
|
diff /= 24;
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ void mapperMBC5ROM(u16 address, u8 value)
|
|||||||
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
|
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
value &= 1;
|
value = value & 1;
|
||||||
if(value == gbDataMBC5.mapperROMHighAddress)
|
if(value == gbDataMBC5.mapperROMHighAddress)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -818,7 +818,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||||||
// receiving command
|
// receiving command
|
||||||
gbDataMBC7.buffer <<= 1;
|
gbDataMBC7.buffer <<= 1;
|
||||||
gbDataMBC7.buffer |= (value & 0x02)?1:0;
|
gbDataMBC7.buffer |= (value & 0x02)?1:0;
|
||||||
++gbDataMBC7.count;
|
gbDataMBC7.count++;
|
||||||
if(gbDataMBC7.count==2) {
|
if(gbDataMBC7.count==2) {
|
||||||
// finished receiving command
|
// finished receiving command
|
||||||
gbDataMBC7.state=2;
|
gbDataMBC7.state=2;
|
||||||
@ -830,7 +830,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||||||
// receive address
|
// receive address
|
||||||
gbDataMBC7.buffer <<= 1;
|
gbDataMBC7.buffer <<= 1;
|
||||||
gbDataMBC7.buffer |= (value&0x02)?1:0;
|
gbDataMBC7.buffer |= (value&0x02)?1:0;
|
||||||
++gbDataMBC7.count;
|
gbDataMBC7.count++;
|
||||||
if(gbDataMBC7.count==8) {
|
if(gbDataMBC7.count==8) {
|
||||||
// finish receiving
|
// finish receiving
|
||||||
gbDataMBC7.state=3;
|
gbDataMBC7.state=3;
|
||||||
@ -850,7 +850,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||||||
case 3:
|
case 3:
|
||||||
gbDataMBC7.buffer <<= 1;
|
gbDataMBC7.buffer <<= 1;
|
||||||
gbDataMBC7.buffer |= (value&0x02)?1:0;
|
gbDataMBC7.buffer |= (value&0x02)?1:0;
|
||||||
++gbDataMBC7.count;
|
gbDataMBC7.count++;
|
||||||
|
|
||||||
switch(gbDataMBC7.code) {
|
switch(gbDataMBC7.code) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -1238,7 +1238,7 @@ void memoryUpdateTAMA5Clock()
|
|||||||
gbDataTAMA5.mapperSeconds += (int)(diff % 60);
|
gbDataTAMA5.mapperSeconds += (int)(diff % 60);
|
||||||
if(gbDataTAMA5.mapperSeconds > 59) {
|
if(gbDataTAMA5.mapperSeconds > 59) {
|
||||||
gbDataTAMA5.mapperSeconds -= 60;
|
gbDataTAMA5.mapperSeconds -= 60;
|
||||||
++gbDataTAMA5.mapperMinutes;
|
gbDataTAMA5.mapperMinutes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff /= 60;
|
diff /= 60;
|
||||||
@ -1246,7 +1246,7 @@ void memoryUpdateTAMA5Clock()
|
|||||||
gbDataTAMA5.mapperMinutes += (int)(diff % 60);
|
gbDataTAMA5.mapperMinutes += (int)(diff % 60);
|
||||||
if(gbDataTAMA5.mapperMinutes > 59) {
|
if(gbDataTAMA5.mapperMinutes > 59) {
|
||||||
gbDataTAMA5.mapperMinutes -= 60;
|
gbDataTAMA5.mapperMinutes -= 60;
|
||||||
++gbDataTAMA5.mapperHours;
|
gbDataTAMA5.mapperHours++;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff /= 60;
|
diff /= 60;
|
||||||
@ -1255,23 +1255,23 @@ void memoryUpdateTAMA5Clock()
|
|||||||
diff /= 24;
|
diff /= 24;
|
||||||
if(gbDataTAMA5.mapperHours > 23) {
|
if(gbDataTAMA5.mapperHours > 23) {
|
||||||
gbDataTAMA5.mapperHours -= 24;
|
gbDataTAMA5.mapperHours -= 24;
|
||||||
++diff;
|
diff++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t days = diff;
|
time_t days = diff;
|
||||||
while (days)
|
while (days)
|
||||||
{
|
{
|
||||||
++gbDataTAMA5.mapperDays;
|
gbDataTAMA5.mapperDays++;
|
||||||
--days;
|
days--;
|
||||||
if (gbDataTAMA5.mapperDays>gbDaysinMonth[gbDataTAMA5.mapperMonths-1])
|
if (gbDataTAMA5.mapperDays>gbDaysinMonth[gbDataTAMA5.mapperMonths-1])
|
||||||
{
|
{
|
||||||
gbDataTAMA5.mapperDays = 1;
|
gbDataTAMA5.mapperDays = 1;
|
||||||
++gbDataTAMA5.mapperMonths;
|
gbDataTAMA5.mapperMonths++;
|
||||||
if (gbDataTAMA5.mapperMonths>12)
|
if (gbDataTAMA5.mapperMonths>12)
|
||||||
{
|
{
|
||||||
gbDataTAMA5.mapperMonths = 1;
|
gbDataTAMA5.mapperMonths = 1;
|
||||||
++gbDataTAMA5.mapperYears;
|
gbDataTAMA5.mapperYears++;
|
||||||
if ((gbDataTAMA5.mapperYears & 3) == 0)
|
if ((gbDataTAMA5.mapperYears & 3) == 0)
|
||||||
gbDaysinMonth[1] = 29;
|
gbDaysinMonth[1] = 29;
|
||||||
else
|
else
|
||||||
@ -1376,11 +1376,11 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
|||||||
gbDataTAMA5.mapperLYears = gbDataTAMA5.mapperYears;
|
gbDataTAMA5.mapperLYears = gbDataTAMA5.mapperYears;
|
||||||
gbDataTAMA5.mapperLControl = gbDataTAMA5.mapperControl;
|
gbDataTAMA5.mapperLControl = gbDataTAMA5.mapperControl;
|
||||||
|
|
||||||
int seconds = ((gbDataTAMA5.mapperLSeconds / 10)<<4) + gbDataTAMA5.mapperLSeconds %10;
|
int seconds = (gbDataTAMA5.mapperLSeconds / 10)*16 + gbDataTAMA5.mapperLSeconds %10;
|
||||||
int secondsL = (gbDataTAMA5.mapperLSeconds % 10);
|
int secondsL = (gbDataTAMA5.mapperLSeconds % 10);
|
||||||
int secondsH = (gbDataTAMA5.mapperLSeconds / 10);
|
int secondsH = (gbDataTAMA5.mapperLSeconds / 10);
|
||||||
int minutes = ((gbDataTAMA5.mapperLMinutes / 10)<<4) + gbDataTAMA5.mapperLMinutes %10;
|
int minutes = (gbDataTAMA5.mapperLMinutes / 10)*16 + gbDataTAMA5.mapperLMinutes %10;
|
||||||
int hours = ((gbDataTAMA5.mapperLHours / 10)<<4) + gbDataTAMA5.mapperLHours %10;
|
int hours = (gbDataTAMA5.mapperLHours / 10)*16 + gbDataTAMA5.mapperLHours %10;
|
||||||
int DaysL = gbDataTAMA5.mapperLDays % 10;
|
int DaysL = gbDataTAMA5.mapperLDays % 10;
|
||||||
int DaysH = gbDataTAMA5.mapperLDays /10;
|
int DaysH = gbDataTAMA5.mapperLDays /10;
|
||||||
int MonthsL = gbDataTAMA5.mapperLMonths % 10;
|
int MonthsL = gbDataTAMA5.mapperLMonths % 10;
|
||||||
@ -1438,11 +1438,11 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
|||||||
}
|
}
|
||||||
else if (gbDataTAMA5.mapperRamByteSelect == 0x44)
|
else if (gbDataTAMA5.mapperRamByteSelect == 0x44)
|
||||||
{
|
{
|
||||||
gbDataTAMA5.mapperMinutes = (data>>4)*10 + (data & 15);
|
gbDataTAMA5.mapperMinutes = (data/16)*10 + data%16;
|
||||||
}
|
}
|
||||||
else if (gbDataTAMA5.mapperRamByteSelect == 0x54)
|
else if (gbDataTAMA5.mapperRamByteSelect == 0x54)
|
||||||
{
|
{
|
||||||
gbDataTAMA5.mapperHours = (data>>4)*10 + (data & 15);
|
gbDataTAMA5.mapperHours = (data/16)*10 + data%16;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1462,13 +1462,14 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
|||||||
// I put it there...
|
// I put it there...
|
||||||
if (value == 0x0a)
|
if (value == 0x0a)
|
||||||
{
|
{
|
||||||
for (int i = 0; i<0x10; i++){
|
for (int i = 0; i<0x10; i++)
|
||||||
int i16 = i<<4;
|
for (int j = 0; j<0x10; j++)
|
||||||
for (int j = 0; j<0x10; j+=4){
|
if (!(j&2))
|
||||||
gbTAMA5ram[(i16 + j ) | 2] = gbTAMA5ram[i16 + j ];
|
gbTAMA5ram[((i*0x10)+j) | 2] = gbTAMA5ram[(i*0x10)+j];
|
||||||
gbTAMA5ram[(i16 + j + 1) | 2] = gbTAMA5ram[i16 + j + 1];
|
// Enable this to see the content of the flashrom in 0xe000
|
||||||
}
|
/*for (int k = 0; k<0x100; k++)
|
||||||
}
|
gbMemoryMap[0xe][k] = gbTAMA5ram[k];*/
|
||||||
|
|
||||||
gbMemoryMap[0xa][0] = gbDataTAMA5.mapperRAMEnable = 1;
|
gbMemoryMap[0xa][0] = gbDataTAMA5.mapperRAMEnable = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -10,9 +10,8 @@
|
|||||||
#include "gbGlobals.h"
|
#include "gbGlobals.h"
|
||||||
#include "../../vbagx.h"
|
#include "../../vbagx.h"
|
||||||
#include "../../menu.h"
|
#include "../../menu.h"
|
||||||
#include "../../fastmath.h"
|
|
||||||
|
|
||||||
#define CARLLOG
|
//#define CARLLOG
|
||||||
|
|
||||||
bool ColorizeGameboy = true;
|
bool ColorizeGameboy = true;
|
||||||
|
|
||||||
@ -38,20 +37,18 @@ const float BL[4] = {0.1f, 0.4f, 0.7f, 1.0f};
|
|||||||
// factor is from 0 to 1. 0 = no extra whiteness, 1 = 100% whiteness
|
// factor is from 0 to 1. 0 = no extra whiteness, 1 = 100% whiteness
|
||||||
u16 changeColourWhiteness(u16 rgb, float factor) {
|
u16 changeColourWhiteness(u16 rgb, float factor) {
|
||||||
if (factor==0.0f) return rgb;
|
if (factor==0.0f) return rgb;
|
||||||
int f1factor = (0x1f*factor);
|
|
||||||
int factorm1 = 1-factor;
|
|
||||||
int r = (rgb & 0x1f);
|
int r = (rgb & 0x1f);
|
||||||
r = (r * factorm1)+ f1factor;
|
r = (r * (1-factor))+(0x1f*factor);
|
||||||
if (r>31) {
|
if (r>31) {
|
||||||
r=31;
|
r=31;
|
||||||
}
|
}
|
||||||
int g = ((rgb >> 5) & 0x1f);
|
int g = ((rgb >> 5) & 0x1f);
|
||||||
g = (g * factorm1)+f1factor;
|
g = (g * (1-factor))+(0x1f*factor);
|
||||||
if (g>31) {
|
if (g>31) {
|
||||||
g=31;
|
g=31;
|
||||||
}
|
}
|
||||||
int b = ((rgb >> 10) & 0x1f);
|
int b = ((rgb >> 10) & 0x1f);
|
||||||
b = (b * factorm1)+f1factor;
|
b = (b * (1-factor))+(0x1f*factor);
|
||||||
if (b>31) {
|
if (b>31) {
|
||||||
b=31;
|
b=31;
|
||||||
}
|
}
|
||||||
@ -63,26 +60,27 @@ u16 changeColourWhiteness(u16 rgb, float factor) {
|
|||||||
u16 changeColourBrightness(u16 rgb, float factor) {
|
u16 changeColourBrightness(u16 rgb, float factor) {
|
||||||
if (factor==1.0f) return rgb;
|
if (factor==1.0f) return rgb;
|
||||||
int bonus = 0;
|
int bonus = 0;
|
||||||
int r = int(float(rgb & 0x1f) * factor);
|
int r = (rgb & 0x1f);
|
||||||
|
r = r * factor;
|
||||||
if (r>31) {
|
if (r>31) {
|
||||||
r=31;
|
r=31;
|
||||||
bonus+= (1 >> 1);
|
bonus+=(r-30)/2;
|
||||||
}
|
}
|
||||||
int g = int(float((rgb >> 5) & 0x1f) * factor);
|
int g = ((rgb >> 5) & 0x1f);
|
||||||
|
g = g * factor;
|
||||||
if (g>31) {
|
if (g>31) {
|
||||||
g=31;
|
g=31;
|
||||||
bonus+=(1 >> 1);
|
bonus+=(g-30)/2;
|
||||||
}
|
}
|
||||||
int b = int(float((rgb >> 10) & 0x1f) * factor);
|
int b = ((rgb >> 10) & 0x1f);
|
||||||
|
b = b * factor;
|
||||||
if (b>31) {
|
if (b>31) {
|
||||||
b=31;
|
b=31;
|
||||||
bonus += (1 >> 1);
|
bonus+=(b-30)/2;
|
||||||
}
|
}
|
||||||
r += bonus;
|
r+=bonus;
|
||||||
g += bonus;
|
g+=bonus;
|
||||||
b += bonus;
|
b+=bonus;
|
||||||
if (r>31) r=31;
|
if (r>31) r=31;
|
||||||
if (g>31) g=31;
|
if (g>31) g=31;
|
||||||
if (b>31) b=31;
|
if (b>31) b=31;
|
||||||
@ -113,8 +111,8 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
log("Bg Pal: %c %c %c %c", DN[gbObp0[0]], DN[gbObp0[1]], DN[gbObp0[2]], DN[gbObp0[3]]);
|
log("Bg Pal: %c %c %c %c", DN[gbObp0[0]], DN[gbObp0[1]], DN[gbObp0[2]], DN[gbObp0[3]]);
|
||||||
#endif
|
#endif
|
||||||
// check for duplicates
|
// check for duplicates
|
||||||
for (unsigned i=0; i<=2u; ++i)
|
for (int i=0; i<=2; i++)
|
||||||
for (unsigned j=i+1; j<=3u; ++j)
|
for (int j=i+1; j<=3; j++)
|
||||||
if (gbBgp[i]==gbBgp[j]) {
|
if (gbBgp[i]==gbBgp[j]) {
|
||||||
dup=true;
|
dup=true;
|
||||||
dupDarkness = gbBgp[i];
|
dupDarkness = gbBgp[i];
|
||||||
@ -122,26 +120,19 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
}
|
}
|
||||||
// We haven't had a full palette yet, so guess...
|
// We haven't had a full palette yet, so guess...
|
||||||
if (dup && !HadBgPal) {
|
if (dup && !HadBgPal) {
|
||||||
|
int index;
|
||||||
if (gbBgp[0]>gbBgp[3]) {
|
if (gbBgp[0]>gbBgp[3]) {
|
||||||
DarkestToBrightestIndex[0] = 0;
|
for (int Colour=0; Colour<=3; Colour++) {
|
||||||
DarkestToBrightestIndex[1] = 1;
|
index = Colour;
|
||||||
DarkestToBrightestIndex[2] = 2;
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
DarkestToBrightestIndex[3] = 3;
|
Darkness[Colour]=gbBgp[index];
|
||||||
|
}
|
||||||
Darkness[0] = gbBgp[0];
|
|
||||||
Darkness[1] = gbBgp[1];
|
|
||||||
Darkness[2] = gbBgp[2];
|
|
||||||
Darkness[3] = gbBgp[3];
|
|
||||||
} else {
|
} else {
|
||||||
DarkestToBrightestIndex[0] = 3;
|
for (int Colour=0; Colour<=3; Colour++) {
|
||||||
DarkestToBrightestIndex[1] = 2;
|
index = 3-Colour;
|
||||||
DarkestToBrightestIndex[2] = 1;
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
DarkestToBrightestIndex[3] = 0;
|
Darkness[Colour]=gbBgp[index];
|
||||||
|
}
|
||||||
Darkness[0] = gbBgp[3];
|
|
||||||
Darkness[1] = gbBgp[2];
|
|
||||||
Darkness[2] = gbBgp[1];
|
|
||||||
Darkness[3] = gbBgp[0];
|
|
||||||
}
|
}
|
||||||
// brightness of brightest colour
|
// brightness of brightest colour
|
||||||
BrightnessForBrightest = BL[3-gbBgp[DarkestToBrightestIndex[3]]];
|
BrightnessForBrightest = BL[3-gbBgp[DarkestToBrightestIndex[3]]];
|
||||||
@ -150,12 +141,12 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
HadBgPal = true;
|
HadBgPal = true;
|
||||||
// now we need to map them from darkest to brightest
|
// now we need to map them from darkest to brightest
|
||||||
int Colour = 0;
|
int Colour = 0;
|
||||||
for (int darkness = 3; darkness>=0; --darkness) {
|
for (int darkness = 3; darkness>=0; darkness--) {
|
||||||
for (int index=0; index<=3; ++index) {
|
for (int index=0; index<=3; index++) {
|
||||||
if (gbBgp[index]==darkness) {
|
if (gbBgp[index]==darkness) {
|
||||||
DarkestToBrightestIndex[Colour]=index;
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
Darkness[Colour]=gbBgp[index];
|
Darkness[Colour]=gbBgp[index];
|
||||||
++Colour;
|
Colour++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,16 +166,13 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
if (dupDarkness==0) {
|
if (dupDarkness==0) {
|
||||||
// Multiple colours set to white
|
// Multiple colours set to white
|
||||||
BrightnessFactor = 0;
|
BrightnessFactor = 0;
|
||||||
WhitenessFactor += BL[3-gbBgp[0]]
|
float MaxWhiteness = 0;
|
||||||
+ BL[3-gbBgp[1]]
|
int i;
|
||||||
+ BL[3-gbBgp[2]]
|
for (i=0; i<=3; i++) {
|
||||||
+ BL[3-gbBgp[3]]
|
WhitenessFactor+=BL[3-gbBgp[i]]-BL[3-i];
|
||||||
- BL[3] - BL[2] - BL[1]- BL[0];
|
MaxWhiteness+=BL[3]-BL[3-i];
|
||||||
|
}
|
||||||
float MaxWhiteness = BL[3] + BL[3] + BL[3] + BL[3]
|
WhitenessFactor = WhitenessFactor / (MaxWhiteness+0.4f);
|
||||||
-BL[3] -BL[2] -BL[1] -BL[0];
|
|
||||||
|
|
||||||
WhitenessFactor /= (MaxWhiteness+0.4f);
|
|
||||||
// check if they are trying to make the palette brighter
|
// check if they are trying to make the palette brighter
|
||||||
} else if (NewBrightnessForBrightest==1.0f && BrightnessForBrightest==1.0f) {
|
} else if (NewBrightnessForBrightest==1.0f && BrightnessForBrightest==1.0f) {
|
||||||
float NewBrightnessForDarkest = BL[3-gbBgp[DarkestToBrightestIndex[0]]];
|
float NewBrightnessForDarkest = BL[3-gbBgp[DarkestToBrightestIndex[0]]];
|
||||||
@ -196,7 +184,7 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
}
|
}
|
||||||
if (WhitenessFactor) {
|
if (WhitenessFactor) {
|
||||||
// BG colours
|
// BG colours
|
||||||
for (int colour = 0; colour <= 3; ++colour) {
|
for (int colour = 0; colour <= 3; colour++) {
|
||||||
u16 colourRGB = systemMonoPalette[colour];
|
u16 colourRGB = systemMonoPalette[colour];
|
||||||
float colourBrightness = BL[colour];
|
float colourBrightness = BL[colour];
|
||||||
float indexBrightness = BL[3-Darkness[colour]];
|
float indexBrightness = BL[3-Darkness[colour]];
|
||||||
@ -204,7 +192,7 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
gbPalette[0+DarkestToBrightestIndex[colour]] = changeColourWhiteness(colourRGB, WhitenessFactor);
|
gbPalette[0+DarkestToBrightestIndex[colour]] = changeColourWhiteness(colourRGB, WhitenessFactor);
|
||||||
}
|
}
|
||||||
// Window colours
|
// Window colours
|
||||||
for (int colour = 0; colour <= 3; ++colour) {
|
for (int colour = 0; colour <= 3; colour++) {
|
||||||
u16 colourRGB = systemMonoPalette[4+colour];
|
u16 colourRGB = systemMonoPalette[4+colour];
|
||||||
float colourBrightness = BL[colour];
|
float colourBrightness = BL[colour];
|
||||||
float indexBrightness = BL[3-Darkness[colour]];
|
float indexBrightness = BL[3-Darkness[colour]];
|
||||||
@ -213,14 +201,14 @@ void gbSetBGPalette(u8 value, bool ColoursChanged=false) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// BG colours
|
// BG colours
|
||||||
for (int colour = 0; colour <= 3; ++colour) {
|
for (int colour = 0; colour <= 3; colour++) {
|
||||||
u16 colourRGB = systemMonoPalette[colour];
|
u16 colourRGB = systemMonoPalette[colour];
|
||||||
float colourBrightness = BL[colour];
|
float colourBrightness = BL[colour];
|
||||||
float indexBrightness = BL[3-Darkness[colour]]*BrightnessFactor;
|
float indexBrightness = BL[3-Darkness[colour]]*BrightnessFactor;
|
||||||
gbPalette[0+DarkestToBrightestIndex[colour]] = changeColourBrightness(colourRGB, indexBrightness/colourBrightness);
|
gbPalette[0+DarkestToBrightestIndex[colour]] = changeColourBrightness(colourRGB, indexBrightness/colourBrightness);
|
||||||
}
|
}
|
||||||
// Window colours
|
// Window colours
|
||||||
for (int colour = 0; colour <= 3; ++colour) {
|
for (int colour = 0; colour <= 3; colour++) {
|
||||||
u16 colourRGB = systemMonoPalette[4+colour];
|
u16 colourRGB = systemMonoPalette[4+colour];
|
||||||
float colourBrightness = BL[colour];
|
float colourBrightness = BL[colour];
|
||||||
float indexBrightness = BL[3-Darkness[colour]]*BrightnessFactor;
|
float indexBrightness = BL[3-Darkness[colour]]*BrightnessFactor;
|
||||||
@ -262,21 +250,19 @@ void gbSetObj0Palette(u8 value, bool ColoursChanged = false) {
|
|||||||
}
|
}
|
||||||
// We haven't had a full palette yet, so guess...
|
// We haven't had a full palette yet, so guess...
|
||||||
if (dup && !HadObj1Pal) {
|
if (dup && !HadObj1Pal) {
|
||||||
if (gbObp0[1]>gbObp0[3]) {
|
int index;
|
||||||
DarkestToBrightestIndex[0] = 1;
|
if (gbObp0[1]>gbObp0[3]) {
|
||||||
DarkestToBrightestIndex[1] = 2;
|
for (int Colour=0; Colour<=2; Colour++) {
|
||||||
DarkestToBrightestIndex[2] = 3;
|
index = Colour+1;
|
||||||
Darkness[0] = gbObp0[1];
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
Darkness[1] = gbObp0[2];
|
Darkness[Colour]=gbObp0[index];
|
||||||
Darkness[2] = gbObp0[3];
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DarkestToBrightestIndex[0] = 3;
|
for (int Colour=0; Colour<=2; Colour++) {
|
||||||
DarkestToBrightestIndex[1] = 2;
|
index = 2-Colour+1;
|
||||||
DarkestToBrightestIndex[2] = 1;
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
Darkness[0] = gbObp0[3];
|
Darkness[Colour]=gbObp0[index];
|
||||||
Darkness[1] = gbObp0[2];
|
}
|
||||||
Darkness[2] = gbObp0[1];
|
|
||||||
}
|
}
|
||||||
// brightness of brightest colour
|
// brightness of brightest colour
|
||||||
BrightnessForBrightest = BL[3-gbObp0[DarkestToBrightestIndex[2]]];
|
BrightnessForBrightest = BL[3-gbObp0[DarkestToBrightestIndex[2]]];
|
||||||
@ -285,12 +271,12 @@ void gbSetObj0Palette(u8 value, bool ColoursChanged = false) {
|
|||||||
HadObj0Pal = true;
|
HadObj0Pal = true;
|
||||||
// now we need to map them from darkest to brightest
|
// now we need to map them from darkest to brightest
|
||||||
int Colour = 0;
|
int Colour = 0;
|
||||||
for (int darkness = 3; darkness>=0; --darkness) {
|
for (int darkness = 3; darkness>=0; darkness--) {
|
||||||
for (int index=1; index<=3; index++) {
|
for (int index=1; index<=3; index++) {
|
||||||
if (gbObp0[index]==darkness) {
|
if (gbObp0[index]==darkness) {
|
||||||
DarkestToBrightestIndex[Colour]=index;
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
Darkness[Colour]=gbObp0[index];
|
Darkness[Colour]=gbObp0[index];
|
||||||
++Colour;
|
Colour++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,16 +296,13 @@ void gbSetObj0Palette(u8 value, bool ColoursChanged = false) {
|
|||||||
if (dupDarkness==0) {
|
if (dupDarkness==0) {
|
||||||
// Multiple colours set to white
|
// Multiple colours set to white
|
||||||
BrightnessFactor = 0;
|
BrightnessFactor = 0;
|
||||||
WhitenessFactor+= BL[3-gbObp0[1]]
|
float MaxWhiteness = 0;
|
||||||
+ BL[3-gbObp0[2]]
|
int i;
|
||||||
+ BL[3-gbObp0[3]]
|
for (i=1; i<=3; i++) {
|
||||||
-BL[3] -BL[2] -BL[1];
|
WhitenessFactor+=BL[3-gbObp0[i]]-BL[3-(i-1)];
|
||||||
|
MaxWhiteness+=BL[3]-BL[3-(i-1)];
|
||||||
float MaxWhiteness = BL[3] + BL[3] + BL[3]
|
}
|
||||||
- BL[3] - BL[2] - BL[1];
|
WhitenessFactor = WhitenessFactor / (MaxWhiteness+0.3f);
|
||||||
|
|
||||||
|
|
||||||
WhitenessFactor /= (MaxWhiteness+0.3f);
|
|
||||||
// check if they are trying to make the palette brighter
|
// check if they are trying to make the palette brighter
|
||||||
} else if (NewBrightnessForBrightest==1.0f && BrightnessForBrightest==1.0f) {
|
} else if (NewBrightnessForBrightest==1.0f && BrightnessForBrightest==1.0f) {
|
||||||
float NewBrightnessForDarkest = BL[3-gbObp0[DarkestToBrightestIndex[0]]];
|
float NewBrightnessForDarkest = BL[3-gbObp0[DarkestToBrightestIndex[0]]];
|
||||||
@ -379,21 +362,19 @@ void gbSetObj1Palette(u8 value, bool ColoursChanged = false) {
|
|||||||
}
|
}
|
||||||
// We haven't had a full palette yet, so guess...
|
// We haven't had a full palette yet, so guess...
|
||||||
if (dup && !HadObj1Pal) {
|
if (dup && !HadObj1Pal) {
|
||||||
if (gbObp0[1]>gbObp0[3]) {
|
int index;
|
||||||
DarkestToBrightestIndex[0] = 1;
|
if (gbObp1[1]>gbObp1[3]) {
|
||||||
DarkestToBrightestIndex[1] = 2;
|
for (int Colour=0; Colour<=2; Colour++) {
|
||||||
DarkestToBrightestIndex[2] = 3;
|
index = Colour+1;
|
||||||
Darkness[0] = gbObp0[1];
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
Darkness[1] = gbObp0[2];
|
Darkness[Colour]=gbObp1[index];
|
||||||
Darkness[2] = gbObp0[3];
|
}
|
||||||
} else {
|
} else {
|
||||||
DarkestToBrightestIndex[0] = 3;
|
for (int Colour=0; Colour<=2; Colour++) {
|
||||||
DarkestToBrightestIndex[1] = 2;
|
index = 2-Colour+1;
|
||||||
DarkestToBrightestIndex[2] = 1;
|
DarkestToBrightestIndex[Colour]=index;
|
||||||
Darkness[0] = gbObp0[3];
|
Darkness[Colour]=gbObp1[index];
|
||||||
Darkness[1] = gbObp0[2];
|
}
|
||||||
Darkness[2] = gbObp0[1];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// brightness of brightest colour
|
// brightness of brightest colour
|
||||||
BrightnessForBrightest = BL[3-gbObp1[DarkestToBrightestIndex[2]]];
|
BrightnessForBrightest = BL[3-gbObp1[DarkestToBrightestIndex[2]]];
|
||||||
@ -427,14 +408,13 @@ void gbSetObj1Palette(u8 value, bool ColoursChanged = false) {
|
|||||||
if (dupDarkness==0) {
|
if (dupDarkness==0) {
|
||||||
// Multiple colours set to white
|
// Multiple colours set to white
|
||||||
BrightnessFactor = 0;
|
BrightnessFactor = 0;
|
||||||
WhitenessFactor+= BL[3-gbObp1[1]]
|
float MaxWhiteness = 0;
|
||||||
+ BL[3-gbObp1[2]]
|
int i;
|
||||||
+ BL[3-gbObp1[3]]
|
for (i=1; i<=3; i++) {
|
||||||
-BL[3] -BL[2] -BL[1];
|
WhitenessFactor+=BL[3-gbObp1[i]]-BL[3-(i-1)];
|
||||||
|
MaxWhiteness+=BL[3]-BL[3-(i-1)];
|
||||||
float MaxWhiteness = BL[3] + BL[3] + BL[3]
|
}
|
||||||
- BL[3] - BL[2] - BL[1];
|
WhitenessFactor = WhitenessFactor / (MaxWhiteness+0.3f);
|
||||||
WhitenessFactor /= (MaxWhiteness+0.3f);
|
|
||||||
// check if they are trying to make the palette brighter
|
// check if they are trying to make the palette brighter
|
||||||
} else if (NewBrightnessForBrightest==1.0f && BrightnessForBrightest==1.0f) {
|
} else if (NewBrightnessForBrightest==1.0f && BrightnessForBrightest==1.0f) {
|
||||||
float NewBrightnessForDarkest = BL[3-gbObp1[DarkestToBrightestIndex[0]]];
|
float NewBrightnessForDarkest = BL[3-gbObp1[DarkestToBrightestIndex[0]]];
|
||||||
@ -473,16 +453,10 @@ bool StartColorizing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StopColorizing() {
|
void StopColorizing() {
|
||||||
if(!ColorizeGameboy || gbSgbMode || gbCgbMode) return;
|
if(!ColorizeGameboy || gbSgbMode || gbCgbMode) return;
|
||||||
|
for(int i = 0; i < 12; i++)
|
||||||
int gbpo12 = gbPaletteOption*12;
|
gbPalette[i] = systemGbPalette[gbPaletteOption*12+i];
|
||||||
for(int i = 0; i < 12; i+=4){
|
ColorizeGameboy = false;
|
||||||
gbPalette[i] = systemGbPalette[gbpo12+i];
|
|
||||||
gbPalette[i+1] = systemGbPalette[gbpo12+i+1];
|
|
||||||
gbPalette[i+2] = systemGbPalette[gbpo12+i+2];
|
|
||||||
gbPalette[i+3] = systemGbPalette[gbpo12+i+3];
|
|
||||||
}
|
|
||||||
ColorizeGameboy = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert 0xRRGGBB to our 15 bit format
|
// convert 0xRRGGBB to our 15 bit format
|
||||||
@ -497,9 +471,7 @@ void gbSetSpritePal(u8 WhichPal, u32 bright, u32 medium, u32 dark) {
|
|||||||
// cancel if we already set to these colours
|
// cancel if we already set to these colours
|
||||||
if (WhichPal>0) {
|
if (WhichPal>0) {
|
||||||
int p = WhichPal-1;
|
int p = WhichPal-1;
|
||||||
if(((OldObpBright[p] - bright) | (OldObpMedium[p] - medium) | (OldObpDark[p] - dark)) == 0){
|
if (OldObpBright[p]==bright && OldObpMedium[p]==medium && OldObpDark[p]==dark) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
// check if we are setting both sprite palettes at once
|
// check if we are setting both sprite palettes at once
|
||||||
@ -562,9 +534,9 @@ void gbSetBgPal(u8 WhichPal, u32 bright) {
|
|||||||
u8 r = (bright >> 16) & 0xFF;
|
u8 r = (bright >> 16) & 0xFF;
|
||||||
u8 g = (bright >> 8) & 0xFF;
|
u8 g = (bright >> 8) & 0xFF;
|
||||||
u8 b = (bright >> 0) & 0xFF;
|
u8 b = (bright >> 0) & 0xFF;
|
||||||
u32 medium = ((ftou((utof(r)*0.7f))) << 16) | ((ftou((utof(g)*0.7f))) << 8) | ((ftou((utof(b)*0.7f))) << 0);
|
u32 medium = (((u32)(r*0.7f)) << 16) | (((u32)(g*0.7f)) << 8) | (((u32)(b*0.7f)) << 0);
|
||||||
u32 dark = ((ftou((utof(r)*0.4f))) << 16) | ((ftou((utof(g)*0.4f))) << 8) | ((ftou((utof(b)*0.4f))) << 0);
|
u32 dark = (((u32)(r*0.4f)) << 16) | (((u32)(g*0.4f)) << 8) | (((u32)(b*0.4f)) << 0);
|
||||||
u32 black = ((ftou((utof(r)*0.1f))) << 16) | ((ftou((utof(g)*0.1f))) << 8) | ((ftou((utof(b)*0.1f))) << 0);
|
u32 black = (((u32)(r*0.1f)) << 16) | (((u32)(g*0.1f)) << 8) | (((u32)(b*0.1f)) << 0);
|
||||||
gbSetBgPal(WhichPal, bright, medium, dark, black);
|
gbSetBgPal(WhichPal, bright, medium, dark, black);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +553,7 @@ void gbPaletteReset() {
|
|||||||
oldBgp = 0xFC;
|
oldBgp = 0xFC;
|
||||||
oldObp0 = oldObp1 = 0xFF;
|
oldObp0 = oldObp1 = 0xFF;
|
||||||
OldBgBright=0; OldBgMedium=0; OldBgDark=0; OldBgBlack=0;
|
OldBgBright=0; OldBgMedium=0; OldBgDark=0; OldBgBlack=0;
|
||||||
OldObpBright[0]= OldObpBright[1]=
|
for (int i=0; i<=1; i++) {
|
||||||
OldObpMedium[0]= OldObpMedium[1]=
|
OldObpBright[i]=OldObpMedium[i]=OldObpDark[i]=0;
|
||||||
OldObpDark[0]= OldObpDark[1] =0;
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,10 @@ bool gbSoundGetDeclicking();
|
|||||||
// Effects configuration
|
// Effects configuration
|
||||||
struct gb_effects_config_t
|
struct gb_effects_config_t
|
||||||
{
|
{
|
||||||
|
bool enabled; // false = disable all effects
|
||||||
|
|
||||||
float echo; // 0.0 = none, 1.0 = lots
|
float echo; // 0.0 = none, 1.0 = lots
|
||||||
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
|
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
|
||||||
bool enabled; // false = disable all effects
|
|
||||||
bool surround; // true = put some channels in back
|
bool surround; // true = put some channels in back
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,11 +9,10 @@ int eepromMode = EEPROM_IDLE;
|
|||||||
int eepromByte = 0;
|
int eepromByte = 0;
|
||||||
int eepromBits = 0;
|
int eepromBits = 0;
|
||||||
int eepromAddress = 0;
|
int eepromAddress = 0;
|
||||||
//--DCN (restructuring for alignment)
|
|
||||||
int eepromSize = 512;
|
|
||||||
u8 eepromData[0x2000];
|
u8 eepromData[0x2000];
|
||||||
u8 eepromBuffer[16];
|
u8 eepromBuffer[16];
|
||||||
bool eepromInUse = false;
|
bool eepromInUse = false;
|
||||||
|
int eepromSize = 512;
|
||||||
|
|
||||||
variable_desc eepromSaveData[] = {
|
variable_desc eepromSaveData[] = {
|
||||||
{ &eepromMode, sizeof(int) },
|
{ &eepromMode, sizeof(int) },
|
||||||
@ -79,7 +78,7 @@ int eepromRead(u32 /* address */)
|
|||||||
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;
|
||||||
@ -89,14 +88,13 @@ int eepromRead(u32 /* address */)
|
|||||||
}
|
}
|
||||||
case EEPROM_READDATA2:
|
case EEPROM_READDATA2:
|
||||||
{
|
{
|
||||||
//--DCN
|
int data = 0;
|
||||||
int address = eepromAddress << 3;
|
int address = eepromAddress << 3;
|
||||||
int mask = 1 << (7 - (eepromBits & 7));
|
int mask = 1 << (7 - (eepromBits & 7));
|
||||||
int 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;
|
||||||
@ -122,9 +120,9 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||||||
case EEPROM_READADDRESS:
|
case EEPROM_READADDRESS:
|
||||||
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) {
|
||||||
@ -143,8 +141,8 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||||||
eepromBits = 0;
|
eepromBits = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--DCN (else, if into else if, may be an improvement; couldn't hurt)
|
} 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)) {
|
||||||
@ -157,6 +155,7 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||||||
eepromByte = 0;
|
eepromByte = 0;
|
||||||
eepromBits = 0;
|
eepromBits = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EEPROM_READDATA:
|
case EEPROM_READDATA:
|
||||||
@ -167,21 +166,15 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||||||
case EEPROM_WRITEDATA:
|
case EEPROM_WRITEDATA:
|
||||||
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;
|
||||||
//--DCN
|
for(int i = 0; i < 8; i++) {
|
||||||
int eeprom3 = eepromAddress << 3;
|
eepromData[(eepromAddress << 3) + i] = eepromBuffer[i];
|
||||||
for(int i = 0; i < 8; i+=4) {
|
|
||||||
|
|
||||||
eepromData[eeprom3 + i+1] = eepromBuffer[i+1];
|
|
||||||
eepromData[eeprom3 + i+2] = eepromBuffer[i+2];
|
|
||||||
eepromData[eeprom3 + i+3] = eepromBuffer[i+3];
|
|
||||||
eepromData[eeprom3 + i+4] = eepromBuffer[i+4];
|
|
||||||
}
|
}
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||||
} else if(eepromBits == 0x41) {
|
} else if(eepromBits == 0x41) {
|
||||||
|
@ -14,23 +14,23 @@ enum LocationType {
|
|||||||
|
|
||||||
struct ELFHeader {
|
struct ELFHeader {
|
||||||
u32 magic;
|
u32 magic;
|
||||||
|
u8 clazz;
|
||||||
|
u8 data;
|
||||||
|
u8 version;
|
||||||
|
u8 pad[9];
|
||||||
|
u16 e_type;
|
||||||
|
u16 e_machine;
|
||||||
u32 e_version;
|
u32 e_version;
|
||||||
u32 e_entry;
|
u32 e_entry;
|
||||||
u32 e_phoff;
|
u32 e_phoff;
|
||||||
u32 e_shoff;
|
u32 e_shoff;
|
||||||
u32 e_flags;
|
u32 e_flags;
|
||||||
u16 e_type;
|
|
||||||
u16 e_machine;
|
|
||||||
u16 e_ehsize;
|
u16 e_ehsize;
|
||||||
u16 e_phentsize;
|
u16 e_phentsize;
|
||||||
u16 e_phnum;
|
u16 e_phnum;
|
||||||
u16 e_shentsize;
|
u16 e_shentsize;
|
||||||
u16 e_shnum;
|
u16 e_shnum;
|
||||||
u16 e_shstrndx;
|
u16 e_shstrndx;
|
||||||
u8 clazz;
|
|
||||||
u8 data;
|
|
||||||
u8 version;
|
|
||||||
u8 pad[9];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ELFProgramHeader {
|
struct ELFProgramHeader {
|
||||||
@ -61,9 +61,9 @@ struct ELFSymbol {
|
|||||||
u32 name;
|
u32 name;
|
||||||
u32 value;
|
u32 value;
|
||||||
u32 size;
|
u32 size;
|
||||||
u16 shndx;
|
|
||||||
u8 info;
|
u8 info;
|
||||||
u8 other;
|
u8 other;
|
||||||
|
u16 shndx;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ELFBlock {
|
struct ELFBlock {
|
||||||
@ -75,21 +75,21 @@ struct ELFAttr {
|
|||||||
u32 name;
|
u32 name;
|
||||||
u32 form;
|
u32 form;
|
||||||
union {
|
union {
|
||||||
ELFBlock *block;
|
u32 value;
|
||||||
u32 value;
|
|
||||||
char *string;
|
char *string;
|
||||||
u8 *data;
|
u8 *data;
|
||||||
bool flag;
|
bool flag;
|
||||||
|
ELFBlock *block;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ELFAbbrev {
|
struct ELFAbbrev {
|
||||||
u32 number;
|
u32 number;
|
||||||
u32 tag;
|
u32 tag;
|
||||||
|
bool hasChildren;
|
||||||
int numAttrs;
|
int numAttrs;
|
||||||
ELFAttr *attrs;
|
ELFAttr *attrs;
|
||||||
ELFAbbrev *next;
|
ELFAbbrev *next;
|
||||||
bool hasChildren;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TypeEnum {
|
enum TypeEnum {
|
||||||
@ -163,12 +163,12 @@ struct Object {
|
|||||||
char *name;
|
char *name;
|
||||||
int file;
|
int file;
|
||||||
int line;
|
int line;
|
||||||
|
bool external;
|
||||||
Type *type;
|
Type *type;
|
||||||
ELFBlock *location;
|
ELFBlock *location;
|
||||||
u32 startScope;
|
u32 startScope;
|
||||||
u32 endScope;
|
u32 endScope;
|
||||||
Object *next;
|
Object *next;
|
||||||
bool external;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Function {
|
struct Function {
|
||||||
@ -177,12 +177,12 @@ struct Function {
|
|||||||
u32 highPC;
|
u32 highPC;
|
||||||
int file;
|
int file;
|
||||||
int line;
|
int line;
|
||||||
|
bool external;
|
||||||
Type *returnType;
|
Type *returnType;
|
||||||
Object *parameters;
|
Object *parameters;
|
||||||
Object *variables;
|
Object *variables;
|
||||||
ELFBlock *frameBase;
|
ELFBlock *frameBase;
|
||||||
Function *next;
|
Function *next;
|
||||||
bool external;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LineInfoItem {
|
struct LineInfoItem {
|
||||||
@ -193,8 +193,8 @@ struct LineInfoItem {
|
|||||||
|
|
||||||
struct LineInfo {
|
struct LineInfo {
|
||||||
int fileCount;
|
int fileCount;
|
||||||
int number;
|
|
||||||
char **files;
|
char **files;
|
||||||
|
int number;
|
||||||
LineInfoItem *lines;
|
LineInfoItem *lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -219,6 +219,7 @@ struct CompileUnit {
|
|||||||
char *compdir;
|
char *compdir;
|
||||||
u32 lowPC;
|
u32 lowPC;
|
||||||
u32 highPC;
|
u32 highPC;
|
||||||
|
bool hasLineInfo;
|
||||||
u32 lineInfo;
|
u32 lineInfo;
|
||||||
LineInfo *lineInfoTable;
|
LineInfo *lineInfoTable;
|
||||||
Function *functions;
|
Function *functions;
|
||||||
@ -226,7 +227,6 @@ struct CompileUnit {
|
|||||||
Object *variables;
|
Object *variables;
|
||||||
Type *types;
|
Type *types;
|
||||||
CompileUnit *next;
|
CompileUnit *next;
|
||||||
bool hasLineInfo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebugInfo {
|
struct DebugInfo {
|
||||||
|
Loading…
Reference in New Issue
Block a user