minor changes

This commit is contained in:
dborth 2009-01-10 07:44:34 +00:00
parent bf187a2087
commit ad6f2134fc
5 changed files with 133 additions and 182 deletions

View File

@ -1,23 +1,3 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005-2006 Forgotten and the VBA development team
// Copyright (C) 2007-2008 VBA-M development team
// Copyright (C) 2007-2008 Shay Green (blargg)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <string.h> #include <string.h>
#include "../gba/Sound.h" #include "../gba/Sound.h"

View File

@ -1,7 +1,7 @@
// GB sound emulation #ifndef GBSOUND_H
#define GBSOUND_H
#ifndef VBA_GBSOUND_H // GB sound emulation
#define VBA_GBSOUND_H
// See Sound.h for sound setup/options // See Sound.h for sound setup/options
@ -75,4 +75,4 @@ extern int soundTicks; // Number of 16.8 MHz clocks until gbSoundTick()
void gbSoundSaveGame( gzFile out ); void gbSoundSaveGame( gzFile out );
void gbSoundReadGame( int version, gzFile in ); void gbSoundReadGame( int version, gzFile in );
#endif #endif // GBSOUND_H

View File

@ -1,21 +1,3 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005-2006 Forgotten and the VBA development team
// Copyright (C) VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@ -757,8 +739,13 @@ static bool CPUReadState(gzFile gzFile)
soundReadGame(gzFile, version); soundReadGame(gzFile, version);
if(version > SAVE_GAME_VERSION_1) { if(version > SAVE_GAME_VERSION_1) {
if(skipSaveGameCheats) {
// skip cheats list data
cheatsReadGameSkip(gzFile, version);
} else {
cheatsReadGame(gzFile, version); cheatsReadGame(gzFile, version);
} }
}
if(version > SAVE_GAME_VERSION_6) { if(version > SAVE_GAME_VERSION_6) {
rtcReadGame(gzFile); rtcReadGame(gzFile);
} }
@ -791,7 +778,7 @@ static bool CPUReadState(gzFile gzFile)
timer1Ticks = ((0x10000 - TM1D) << timer1ClockReload) - timer1Ticks; timer1Ticks = ((0x10000 - TM1D) << timer1ClockReload) - timer1Ticks;
timer2Ticks = ((0x10000 - TM2D) << timer2ClockReload) - timer2Ticks; timer2Ticks = ((0x10000 - TM2D) << timer2ClockReload) - timer2Ticks;
timer3Ticks = ((0x10000 - TM3D) << timer3ClockReload) - timer3Ticks; timer3Ticks = ((0x10000 - TM3D) << timer3ClockReload) - timer3Ticks;
// interp_rate(); interp_rate();
} }
// set pointers! // set pointers!
@ -2355,25 +2342,28 @@ void CPUCheckDMA(int reason, int dmamask)
void CPUUpdateRegister(u32 address, u16 value) void CPUUpdateRegister(u32 address, u16 value)
{ {
switch(address) { switch(address)
case 0x00:
{ {
if ((value & 7) >5) case 0x00:
{ // we need to place the following code in { } because we declare & initialize variables in a case statement
if((value & 7) > 5) {
// display modes above 0-5 are prohibited
DISPCNT = (value & 7); DISPCNT = (value & 7);
bool change = ((DISPCNT ^ value) & 0x80) ? true : false; }
bool changeBG = ((DISPCNT ^ value) & 0x0F00) ? true : false; bool change = (0 != ((DISPCNT ^ value) & 0x80));
u16 changeBGon = (((~DISPCNT) & value) & 0x0F00); bool changeBG = (0 != ((DISPCNT ^ value) & 0x0F00));
DISPCNT = (value & 0xFFF7); u16 changeBGon = ((~DISPCNT) & value) & 0x0F00; // these layers are being activated
DISPCNT = (value & 0xFFF7); // bit 3 can only be accessed by the BIOS to enable GBC mode
UPDATE_REG(0x00, DISPCNT); UPDATE_REG(0x00, DISPCNT);
if (changeBGon) if(changeBGon) {
{
layerEnableDelay = 4; layerEnableDelay = 4;
layerEnable = layerSettings & value & (~changeBGon); layerEnable = layerSettings & value & (~changeBGon);
} } else {
else
layerEnable = layerSettings & value; layerEnable = layerSettings & value;
// CPUUpdateTicks(); // CPUUpdateTicks();
}
windowOn = (layerEnable & 0x6000) ? true : false; windowOn = (layerEnable & 0x6000) ? true : false;
if(change && !((value & 0x80))) { if(change && !((value & 0x80))) {
@ -2389,10 +2379,11 @@ void CPUUpdateRegister(u32 address, u16 value)
} }
CPUUpdateRender(); CPUUpdateRender();
// we only care about changes in BG0-BG3 // we only care about changes in BG0-BG3
if(changeBG) if(changeBG) {
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
break; break;
}
case 0x04: case 0x04:
DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7); DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7);
UPDATE_REG(0x04, DISPSTAT); UPDATE_REG(0x04, DISPSTAT);
@ -2740,7 +2731,7 @@ void CPUUpdateRegister(u32 address, u16 value)
break; break;
case 0x100: case 0x100:
timer0Reload = value; timer0Reload = value;
// interp_rate(); interp_rate();
break; break;
case 0x102: case 0x102:
timer0Value = value; timer0Value = value;
@ -2749,7 +2740,7 @@ void CPUUpdateRegister(u32 address, u16 value)
break; break;
case 0x104: case 0x104:
timer1Reload = value; timer1Reload = value;
// interp_rate(); interp_rate();
break; break;
case 0x106: case 0x106:
timer1Value = value; timer1Value = value;
@ -2912,7 +2903,7 @@ void applyTimer ()
} }
timer0On = timer0Value & 0x80 ? true : false; timer0On = timer0Value & 0x80 ? true : false;
TM0CNT = timer0Value & 0xC7; TM0CNT = timer0Value & 0xC7;
// interp_rate(); interp_rate();
UPDATE_REG(0x102, TM0CNT); UPDATE_REG(0x102, TM0CNT);
// CPUUpdateTicks(); // CPUUpdateTicks();
} }
@ -2927,7 +2918,7 @@ void applyTimer ()
} }
timer1On = timer1Value & 0x80 ? true : false; timer1On = timer1Value & 0x80 ? true : false;
TM1CNT = timer1Value & 0xC7; TM1CNT = timer1Value & 0xC7;
// interp_rate(); interp_rate();
UPDATE_REG(0x106, TM1CNT); UPDATE_REG(0x106, TM1CNT);
} }
if (timerOnOffDelay & 4) if (timerOnOffDelay & 4)
@ -3624,95 +3615,96 @@ void CPULoop(int ticks)
case 16: case 16:
{ {
u16 *dest = (u16 *)pix + 242 * (VCOUNT+1); u16 *dest = (u16 *)pix + 242 * (VCOUNT+1);
for(int x = -1; x < 240;) { for(int x = 0; x < 240;) {
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
*dest++ = systemColorMap16[lineMix[++x]&0xFFFF]; *dest++ = systemColorMap16[lineMix[x++]&0xFFFF];
} }
// for filters that read past the screen // for filters that read past the screen
*dest = 0; *dest++ = 0;
} }
break; break;
case 24: case 24:
{ {
u8 *dest = (u8 *)pix + 240 * VCOUNT * 3; u8 *dest = (u8 *)pix + 240 * VCOUNT * 3;
for(int x = -1; x < 240;) { for(int x = 0; x < 240;) {
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF]; *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF];
dest += 3; dest += 3;
*((u32 *)dest) = systemColorMap32[lineMix[++x] & 0xFFFF];
} }
} }
break; break;
case 32: case 32:
{ {
u32 *dest = (u32 *)pix + 241 * (VCOUNT+1); u32 *dest = (u32 *)pix + 241 * (VCOUNT+1);
for(int x = -1; x < 240; ) { for(int x = 0; x < 240; ) {
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest++ = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
*dest = systemColorMap32[lineMix[++x] & 0xFFFF]; *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF];
} }
} }
break; break;

View File

@ -1,24 +1,3 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2004-2006 VBA development team
// Copyright (C) 2007-2008 VBA-M development team
// Copyright (C) 2007-2008 Shay Green (blargg)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <string.h> #include <string.h>
#include "Sound.h" #include "Sound.h"

View File

@ -1,9 +1,9 @@
#ifndef SOUND_H
#define SOUND_H
// Sound emulation setup/options and GBA sound emulation // Sound emulation setup/options and GBA sound emulation
#ifndef VBA_SOUND_H #include "../System.h"
#define VBA_SOUND_H
#include "System.h"
//// Setup/options (these affect GBA and GB sound) //// Setup/options (these affect GBA and GB sound)
@ -80,4 +80,4 @@ extern int soundTicks; // Number of 16.8 MHz clocks until soundTick() w
void soundSaveGame( gzFile ); void soundSaveGame( gzFile );
void soundReadGame( gzFile, int version ); void soundReadGame( gzFile, int version );
#endif // VBA_SOUND_H #endif // SOUND_H