Upgrade to 1.8 beta core

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@23 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
DJRobX 2007-11-07 01:27:54 +00:00
parent 0e1ef89215
commit ee40ad3d5c
301 changed files with 100519 additions and 33545 deletions

View File

@ -51,7 +51,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)zlib&quot;;&quot;$(SolutionDir)libpng&quot;"
AdditionalIncludeDirectories="&quot;$(SolutionDir)src\win32\dependencies\zlib&quot;;&quot;$(SolutionDir)src\win32\dependencies\libpng&quot;;&quot;$(SolutionDir)src\win32\dependencies\cximage&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;MMX;_CRT_SECURE_NO_WARNINGS"
StringPooling="false"
MinimalRebuild="true"
@ -83,7 +83,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nafxcwd.lib LIBCMTD.lib Vfw32.Lib OpenGL32.Lib dinput8.lib dxguid.lib ddraw.lib winmm.lib d3dx9.lib Dsound.lib"
AdditionalDependencies="nafxcwd.lib LIBCMTD.lib Vfw32.Lib OpenGL32.Lib dinput8.lib dxguid.lib ddraw.lib dxerr9.lib winmm.lib d3dx9.lib d3d9.lib Dsound.lib"
OutputFile="$(ProjectDir)VisualBoyAdvance.exe"
Version=""
LinkIncremental="2"
@ -165,7 +165,7 @@
OmitFramePointers="true"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="&quot;$(SolutionDir)zlib&quot;;&quot;$(SolutionDir)libpng&quot;"
AdditionalIncludeDirectories="&quot;$(SolutionDir)src\win32\dependencies\zlib&quot;;&quot;$(SolutionDir)src\win32\dependencies\libpng&quot;;&quot;$(SolutionDir)src\win32\dependencies\cximage&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;FINAL_VERSION;MMX;_CRT_SECURE_NO_WARNINGS"
IgnoreStandardIncludePath="false"
GeneratePreprocessedFile="0"
@ -216,7 +216,7 @@
Name="VCLinkerTool"
RegisterOutput="false"
IgnoreImportLibrary="false"
AdditionalDependencies="nafxcw.lib LIBCMT.lib Vfw32.Lib OpenGL32.Lib dinput8.lib winmm.lib dxguid.lib ddraw.lib d3dx9.lib Dsound.lib"
AdditionalDependencies="nafxcw.lib LIBCMT.lib Vfw32.Lib OpenGL32.Lib dinput8.lib winmm.lib dxguid.lib ddraw.lib d3d9.lib d3dx9.lib Dsound.lib"
ShowProgress="0"
OutputFile="$(ProjectDir)VisualBoyAdvance.exe"
Version=""
@ -308,7 +308,7 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="&quot;$(SolutionDir)zlib&quot;;&quot;$(SolutionDir)libpng&quot;"
AdditionalIncludeDirectories="&quot;$(SolutionDir)src\win32\dependencies\zlib&quot;;&quot;$(SolutionDir)src\win32\dependencies\libpng&quot;;&quot;$(SolutionDir)src\win32\dependencies\cximage&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;FINAL_VERSION;MMX;_CRT_SECURE_NO_WARNINGS"
IgnoreStandardIncludePath="false"
GeneratePreprocessedFile="0"
@ -649,14 +649,6 @@
RelativePath=".\src\hq_shared32.cpp"
>
</File>
<File
RelativePath=".\src\lq3x.cpp"
>
</File>
<File
RelativePath=".\src\lq4x.cpp"
>
</File>
<File
RelativePath=".\src\portable.cpp"
>
@ -683,16 +675,40 @@
>
</File>
<File
RelativePath=".\src\getopt.cpp"
RelativePath=".\src\getopt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\getopt1.cpp"
RelativePath=".\src\getopt1.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\memgzio.cpp"
RelativePath=".\src\memgzio.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\snd_interp.cpp"
@ -890,6 +906,10 @@
RelativePath=".\src\win32\FileDlg.cpp"
>
</File>
<File
RelativePath=".\src\win32\GameOverrides.cpp"
>
</File>
<File
RelativePath=".\src\win32\GBACheats.cpp"
>
@ -1002,6 +1022,14 @@
RelativePath=".\src\win32\RomInfo.cpp"
>
</File>
<File
RelativePath=".\src\win32\skin.cpp"
>
</File>
<File
RelativePath=".\src\win32\skinButton.cpp"
>
</File>
<File
RelativePath=".\src\win32\StringTokenizer.cpp"
>
@ -1014,10 +1042,6 @@
RelativePath=".\src\win32\TileView.cpp"
>
</File>
<File
RelativePath=".\src\win32\UniVideoModeDlg.cpp"
>
</File>
<File
RelativePath=".\src\win32\VideoMode.cpp"
>
@ -1106,6 +1130,10 @@
RelativePath=".\src\win32\DirectSound.cpp"
>
</File>
<File
RelativePath=".\src\win32\display.cpp"
>
</File>
<File
RelativePath=".\src\win32\GDIDisplay.cpp"
>
@ -1155,6 +1183,130 @@
>
</File>
</Filter>
<Filter
Name="Cximage"
>
<File
RelativePath=".\src\win32\dependencies\cximage\tif_xfile.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximabmp.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximadsp.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximaenc.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximaexif.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximage.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximagif.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximahist.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximaico.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximainfo.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximaint.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximaj2k.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximajas.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximajbg.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximajpg.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximalpha.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximalyr.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximamng.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximapal.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximapcx.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximapng.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximasel.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximatga.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximath.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximatif.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximatran.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximawbmp.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximawmf.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\ximawnd.cpp"
>
</File>
<File
RelativePath=".\src\win32\dependencies\cximage\xmemfile.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header"
@ -1624,15 +1776,7 @@
>
</File>
<File
RelativePath=".\res\resource.h"
>
</File>
<File
RelativePath=".\res\VBA.ico"
>
</File>
<File
RelativePath=".\res\VBA.rc"
RelativePath=".\src\win32\VBA.rc"
>
</File>
</Filter>

View File

@ -1,6 +1,8 @@
#include "System.h"
#include "Port.h"
extern int RGB_LOW_BITS_MASK;
extern "C"
{
@ -48,6 +50,7 @@ int Init_2xSaI(u32 BitFormat)
greenMask = 0x7E0;
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xF7DEF7DE;
hq2x_init(16);
RGB_LOW_BITS_MASK = 0x0821;
} else if (BitFormat == 555) {
colorMask = 0x7BDE7BDE;
lowPixelMask = 0x04210421;
@ -57,6 +60,7 @@ int Init_2xSaI(u32 BitFormat)
greenMask = 0x3E0;
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0x7BDE7BDE;
hq2x_init(15);
RGB_LOW_BITS_MASK = 0x0421;
} else {
return 0;
}
@ -67,6 +71,7 @@ int Init_2xSaI(u32 BitFormat)
qlowpixelMask = 0x030303;
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xfefefe;
hq2x_init(32);
RGB_LOW_BITS_MASK = 0x010101;
} else
return 0;

31
src/AutoBuild.h Normal file
View File

@ -0,0 +1,31 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef __AUTOBUILD_H__
#define __AUTOBUILD_H__
#ifndef VERSION
#define VERSION "1.8.0"
#endif
//change the FALSE to TRUE for autoincrement of build number
#define INCREMENT_VERSION FALSE
#define FILEVER 1,8,0,600
#define PRODUCTVER 1,8,0,600
#define STRFILEVER "1, 8, 0, 600\0"
#define STRPRODUCTVER "1, 8, 0, 600\0"
#endif //__AUTOBUILD_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +1,55 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef GBA_CHEATS_H
#define GBA_CHEATS_H
struct CheatsData {
int code;
int size;
int status;
bool enabled;
u32 rawaddress;
u32 address;
u32 value;
u32 oldValue;
char codestring[20];
char desc[32];
};
extern void cheatsAdd(const char *,const char *,u32, u32,u32,int,int);
extern void cheatsAddCheatCode(const char *code, const char *desc);
extern void cheatsAddGSACode(const char *code, const char *desc, bool v3);
extern void cheatsAddCBACode(const char *code, const char *desc);
extern bool cheatsImportGSACodeFile(const char *name, int game, bool v3);
extern void cheatsDelete(int number, bool restore);
extern void cheatsDeleteAll(bool restore);
extern void cheatsEnable(int number);
extern void cheatsDisable(int number);
extern void cheatsSaveGame(gzFile file);
extern void cheatsReadGame(gzFile file);
extern void cheatsSaveCheatList(const char *file);
extern bool cheatsLoadCheatList(const char *file);
extern void cheatsWriteMemory(u32, u32);
extern void cheatsWriteHalfWord(u32, u16);
extern void cheatsWriteByte(u32, u8);
extern int cheatsCheckKeys(u32,u32);
extern int cheatsNumber;
extern CheatsData cheatsList[100];
#endif // GBA_CHEATS_H
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004-2006 Forgotten and the VBA 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.
#ifndef GBA_CHEATS_H
#define GBA_CHEATS_H
struct CheatsData {
int code;
int size;
int status;
bool enabled;
u32 rawaddress;
u32 address;
u32 value;
u32 oldValue;
char codestring[20];
char desc[32];
};
extern void cheatsAdd(const char *,const char *,u32, u32,u32,int,int);
extern void cheatsAddCheatCode(const char *code, const char *desc);
extern void cheatsAddGSACode(const char *code, const char *desc, bool v3);
extern void cheatsAddCBACode(const char *code, const char *desc);
extern bool cheatsImportGSACodeFile(const char *name, int game, bool v3);
extern void cheatsDelete(int number, bool restore);
extern void cheatsDeleteAll(bool restore);
extern void cheatsEnable(int number);
extern void cheatsDisable(int number);
extern void cheatsSaveGame(gzFile file);
extern void cheatsReadGame(gzFile file, int version);
extern void cheatsSaveCheatList(const char *file);
extern bool cheatsLoadCheatList(const char *file);
extern void cheatsWriteMemory(u32, u32);
extern void cheatsWriteHalfWord(u32, u16);
extern void cheatsWriteByte(u32, u8);
extern int cheatsCheckKeys(u32,u32);
extern int cheatsNumber;
extern CheatsData cheatsList[100];
#endif // GBA_CHEATS_H

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <memory.h>
#include "GBA.h"
#include "EEprom.h"
#include "Util.h"
@ -42,6 +43,11 @@ variable_desc eepromSaveData[] = {
{ NULL, 0 }
};
void eepromInit()
{
memset(eepromData, 255, sizeof(eepromData));
}
void eepromReset()
{
eepromMode = EEPROM_IDLE;

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -20,10 +20,11 @@
#ifndef VBA_EEPROM_H
#define VBA_EEPROM_H
extern void eepromSaveGame(gzFile gzFile);
extern void eepromReadGame(gzFile gzFile, int version);
extern void eepromSaveGame(gzFile _gzFile);
extern void eepromReadGame(gzFile _gzFile, int version);
extern int eepromRead(u32 address);
extern void eepromWrite(u32 address, u8 value);
extern void eepromInit();
extern void eepromReset();
extern u8 eepromData[0x2000];
extern bool eepromInUse;

View File

@ -1,259 +1,263 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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 <memory.h>
#include "GBA.h"
#include "Globals.h"
#include "Flash.h"
#include "Sram.h"
#include "Util.h"
#define FLASH_READ_ARRAY 0
#define FLASH_CMD_1 1
#define FLASH_CMD_2 2
#define FLASH_AUTOSELECT 3
#define FLASH_CMD_3 4
#define FLASH_CMD_4 5
#define FLASH_CMD_5 6
#define FLASH_ERASE_COMPLETE 7
#define FLASH_PROGRAM 8
#define FLASH_SETBANK 9
u8 flashSaveMemory[0x20000];
int flashState = FLASH_READ_ARRAY;
int flashReadState = FLASH_READ_ARRAY;
int flashSize = 0x10000;
int flashDeviceID = 0x1b;
int flashManufacturerID = 0x32;
int flashBank = 0;
static variable_desc flashSaveData[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSaveMemory[0], 0x10000 },
{ NULL, 0 }
};
static variable_desc flashSaveData2[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashSaveMemory[0], 0x20000 },
{ NULL, 0 }
};
static variable_desc flashSaveData3[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashBank, sizeof(int) },
{ &flashSaveMemory[0], 0x20000 },
{ NULL, 0 }
};
void flashInit()
{
memset(flashSaveMemory, 0xff, sizeof(flashSaveMemory));
}
void flashReset()
{
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
flashBank = 0;
}
void flashSaveGame(gzFile gzFile)
{
utilWriteData(gzFile, flashSaveData3);
}
void flashReadGame(gzFile gzFile, int version)
{
if(version < SAVE_GAME_VERSION_5)
utilReadData(gzFile, flashSaveData);
else if(version < SAVE_GAME_VERSION_7) {
utilReadData(gzFile, flashSaveData2);
flashBank = 0;
flashSetSize(flashSize);
} else {
utilReadData(gzFile, flashSaveData3);
}
}
void flashSetSize(int size)
{
// log("Setting flash size to %d\n", size);
flashSize = size;
if(size == 0x10000) {
flashDeviceID = 0x1b;
flashManufacturerID = 0x32;
} else {
flashDeviceID = 0x13; //0x09;
flashManufacturerID = 0x62; //0xc2;
}
}
u8 flashRead(u32 address)
{
// log("Reading %08x from %08x\n", address, reg[15].I);
// log("Current read state is %d\n", flashReadState);
address &= 0xFFFF;
switch(flashReadState) {
case FLASH_READ_ARRAY:
return flashSaveMemory[(flashBank << 16) + address];
case FLASH_AUTOSELECT:
switch(address & 0xFF) {
case 0:
// manufacturer ID
return flashManufacturerID;
case 1:
// device ID
return flashDeviceID;
}
break;
case FLASH_ERASE_COMPLETE:
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
return 0xFF;
};
return 0;
}
void flashSaveDecide(u32 address, u8 byte)
{
// log("Deciding save type %08x\n", address);
if(address == 0x0e005555) {
saveType = 2;
cpuSaveGameFunc = flashWrite;
} else {
saveType = 1;
cpuSaveGameFunc = sramWrite;
}
(*cpuSaveGameFunc)(address, byte);
}
void flashDelayedWrite(u32 address, u8 byte)
{
saveType = 2;
cpuSaveGameFunc = flashWrite;
flashWrite(address, byte);
}
void flashWrite(u32 address, u8 byte)
{
// log("Writing %02x at %08x\n", byte, address);
// log("Current state is %d\n", flashState);
address &= 0xFFFF;
switch(flashState) {
case FLASH_READ_ARRAY:
if(address == 0x5555 && byte == 0xAA)
flashState = FLASH_CMD_1;
break;
case FLASH_CMD_1:
if(address == 0x2AAA && byte == 0x55)
flashState = FLASH_CMD_2;
else
flashState = FLASH_READ_ARRAY;
break;
case FLASH_CMD_2:
if(address == 0x5555) {
if(byte == 0x90) {
flashState = FLASH_AUTOSELECT;
flashReadState = FLASH_AUTOSELECT;
} else if(byte == 0x80) {
flashState = FLASH_CMD_3;
} else if(byte == 0xF0) {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
} else if(byte == 0xA0) {
flashState = FLASH_PROGRAM;
} else if(byte == 0xB0 && flashSize == 0x20000) {
flashState = FLASH_SETBANK;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_CMD_3:
if(address == 0x5555 && byte == 0xAA) {
flashState = FLASH_CMD_4;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_CMD_4:
if(address == 0x2AAA && byte == 0x55) {
flashState = FLASH_CMD_5;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_CMD_5:
if(byte == 0x30) {
// SECTOR ERASE
memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)],
0,
0x1000);
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
flashReadState = FLASH_ERASE_COMPLETE;
} else if(byte == 0x10) {
// CHIP ERASE
memset(flashSaveMemory, 0, flashSize);
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
flashReadState = FLASH_ERASE_COMPLETE;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_AUTOSELECT:
if(byte == 0xF0) {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
} else if(address == 0x5555 && byte == 0xAA)
flashState = FLASH_CMD_1;
else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_PROGRAM:
flashSaveMemory[(flashBank<<16)+address] = byte;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
break;
case FLASH_SETBANK:
if(address == 0) {
flashBank = (byte & 1);
}
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
break;
}
}
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004-2006 Forgotten and the VBA 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 <memory.h>
#include "GBA.h"
#include "Globals.h"
#include "Flash.h"
#include "Sram.h"
#include "Util.h"
#define FLASH_READ_ARRAY 0
#define FLASH_CMD_1 1
#define FLASH_CMD_2 2
#define FLASH_AUTOSELECT 3
#define FLASH_CMD_3 4
#define FLASH_CMD_4 5
#define FLASH_CMD_5 6
#define FLASH_ERASE_COMPLETE 7
#define FLASH_PROGRAM 8
#define FLASH_SETBANK 9
u8 flashSaveMemory[0x20000];
int flashState = FLASH_READ_ARRAY;
int flashReadState = FLASH_READ_ARRAY;
int flashSize = 0x10000;
int flashDeviceID = 0x1b;
int flashManufacturerID = 0x32;
int flashBank = 0;
static variable_desc flashSaveData[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSaveMemory[0], 0x10000 },
{ NULL, 0 }
};
static variable_desc flashSaveData2[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashSaveMemory[0], 0x20000 },
{ NULL, 0 }
};
static variable_desc flashSaveData3[] = {
{ &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) },
{ &flashBank, sizeof(int) },
{ &flashSaveMemory[0], 0x20000 },
{ NULL, 0 }
};
void flashInit()
{
memset(flashSaveMemory, 0xff, sizeof(flashSaveMemory));
}
void flashReset()
{
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
flashBank = 0;
}
void flashSaveGame(gzFile gzFile)
{
utilWriteData(gzFile, flashSaveData3);
}
void flashReadGame(gzFile gzFile, int version)
{
if(version < SAVE_GAME_VERSION_5)
utilReadData(gzFile, flashSaveData);
else if(version < SAVE_GAME_VERSION_7) {
utilReadData(gzFile, flashSaveData2);
flashBank = 0;
flashSetSize(flashSize);
} else {
utilReadData(gzFile, flashSaveData3);
}
}
void flashSetSize(int size)
{
// log("Setting flash size to %d\n", size);
if(size == 0x10000) {
flashDeviceID = 0x1b;
flashManufacturerID = 0x32;
} else {
flashDeviceID = 0x13; //0x09;
flashManufacturerID = 0x62; //0xc2;
}
// Added to make 64k saves compatible with 128k ones
// (allow wrongfuly set 64k saves to work for Pokemon games)
if ((size == 0x20000) && (flashSize == 0x10000))
memcpy((u8 *)(flashSaveMemory+0x10000), (u8 *)(flashSaveMemory), 0x10000);
flashSize = size;
}
u8 flashRead(u32 address)
{
// log("Reading %08x from %08x\n", address, reg[15].I);
// log("Current read state is %d\n", flashReadState);
address &= 0xFFFF;
switch(flashReadState) {
case FLASH_READ_ARRAY:
return flashSaveMemory[(flashBank << 16) + address];
case FLASH_AUTOSELECT:
switch(address & 0xFF) {
case 0:
// manufacturer ID
return flashManufacturerID;
case 1:
// device ID
return flashDeviceID;
}
break;
case FLASH_ERASE_COMPLETE:
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
return 0xFF;
};
return 0;
}
void flashSaveDecide(u32 address, u8 byte)
{
// log("Deciding save type %08x\n", address);
if(address == 0x0e005555) {
saveType = 2;
cpuSaveGameFunc = flashWrite;
} else {
saveType = 1;
cpuSaveGameFunc = sramWrite;
}
(*cpuSaveGameFunc)(address, byte);
}
void flashDelayedWrite(u32 address, u8 byte)
{
saveType = 2;
cpuSaveGameFunc = flashWrite;
flashWrite(address, byte);
}
void flashWrite(u32 address, u8 byte)
{
// log("Writing %02x at %08x\n", byte, address);
// log("Current state is %d\n", flashState);
address &= 0xFFFF;
switch(flashState) {
case FLASH_READ_ARRAY:
if(address == 0x5555 && byte == 0xAA)
flashState = FLASH_CMD_1;
break;
case FLASH_CMD_1:
if(address == 0x2AAA && byte == 0x55)
flashState = FLASH_CMD_2;
else
flashState = FLASH_READ_ARRAY;
break;
case FLASH_CMD_2:
if(address == 0x5555) {
if(byte == 0x90) {
flashState = FLASH_AUTOSELECT;
flashReadState = FLASH_AUTOSELECT;
} else if(byte == 0x80) {
flashState = FLASH_CMD_3;
} else if(byte == 0xF0) {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
} else if(byte == 0xA0) {
flashState = FLASH_PROGRAM;
} else if(byte == 0xB0 && flashSize == 0x20000) {
flashState = FLASH_SETBANK;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_CMD_3:
if(address == 0x5555 && byte == 0xAA) {
flashState = FLASH_CMD_4;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_CMD_4:
if(address == 0x2AAA && byte == 0x55) {
flashState = FLASH_CMD_5;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_CMD_5:
if(byte == 0x30) {
// SECTOR ERASE
memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)],
0,
0x1000);
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
flashReadState = FLASH_ERASE_COMPLETE;
} else if(byte == 0x10) {
// CHIP ERASE
memset(flashSaveMemory, 0, flashSize);
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
flashReadState = FLASH_ERASE_COMPLETE;
} else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_AUTOSELECT:
if(byte == 0xF0) {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
} else if(address == 0x5555 && byte == 0xAA)
flashState = FLASH_CMD_1;
else {
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
}
break;
case FLASH_PROGRAM:
flashSaveMemory[(flashBank<<16)+address] = byte;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
break;
case FLASH_SETBANK:
if(address == 0) {
flashBank = (byte & 1);
}
flashState = FLASH_READ_ARRAY;
flashReadState = FLASH_READ_ARRAY;
break;
}
}

View File

@ -1,35 +1,35 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_FLASH_H
#define VBA_FLASH_H
extern void flashSaveGame(gzFile gzFile);
extern void flashReadGame(gzFile gzFile, int version);
extern u8 flashRead(u32 address);
extern void flashWrite(u32 address, u8 byte);
extern void flashDelayedWrite(u32 address, u8 byte);
extern u8 flashSaveMemory[0x20000];
extern void flashSaveDecide(u32 address, u8 byte);
extern void flashReset();
extern void flashSetSize(int size);
extern void flashInit();
extern int flashSize;
#endif // VBA_FLASH_H
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_FLASH_H
#define VBA_FLASH_H
extern void flashSaveGame(gzFile _gzFile);
extern void flashReadGame(gzFile _gzFile, int version);
extern u8 flashRead(u32 address);
extern void flashWrite(u32 address, u8 byte);
extern void flashDelayedWrite(u32 address, u8 byte);
extern u8 flashSaveMemory[0x20000];
extern void flashSaveDecide(u32 address, u8 byte);
extern void flashReset();
extern void flashSetSize(int size);
extern void flashInit();
extern int flashSize;
#endif // VBA_FLASH_H

File diff suppressed because it is too large Load Diff

305
src/GBA.h
View File

@ -1,147 +1,158 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_GBA_H
#define VBA_GBA_H
#include "System.h"
#define SAVE_GAME_VERSION_1 1
#define SAVE_GAME_VERSION_2 2
#define SAVE_GAME_VERSION_3 3
#define SAVE_GAME_VERSION_4 4
#define SAVE_GAME_VERSION_5 5
#define SAVE_GAME_VERSION_6 6
#define SAVE_GAME_VERSION_7 7
#define SAVE_GAME_VERSION_8 8
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_8
typedef struct {
u8 *address;
u32 mask;
} memoryMap;
typedef union {
struct {
#ifdef WORDS_BIGENDIAN
u8 B3;
u8 B2;
u8 B1;
u8 B0;
#else
u8 B0;
u8 B1;
u8 B2;
u8 B3;
#endif
} B;
struct {
#ifdef WORDS_BIGENDIAN
u16 W1;
u16 W0;
#else
u16 W0;
u16 W1;
#endif
} W;
#ifdef WORDS_BIGENDIAN
volatile u32 I;
#else
u32 I;
#endif
} reg_pair;
#ifndef NO_GBA_MAP
extern memoryMap map[256];
#endif
extern reg_pair reg[45];
extern u8 biosProtected[4];
extern bool N_FLAG;
extern bool Z_FLAG;
extern bool C_FLAG;
extern bool V_FLAG;
extern bool armIrqEnable;
extern bool armState;
extern int armMode;
extern void (*cpuSaveGameFunc)(u32,u8);
extern u8 freezeWorkRAM[0x40000];
extern u8 freezeInternalRAM[0x8000];
extern bool CPUReadGSASnapshot(const char *);
extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *);
extern bool CPUWriteBatteryFile(const char *);
extern bool CPUReadBatteryFile(const char *);
extern bool CPUExportEepromFile(const char *);
extern bool CPUImportEepromFile(const char *);
extern bool CPUWritePNGFile(const char *);
extern bool CPUWriteBMPFile(const char *);
extern void CPUCleanUp();
extern void CPUUpdateRender();
extern bool CPUReadMemState(char *, int);
extern bool CPUReadState(const char *);
extern bool CPUWriteMemState(char *, int);
extern bool CPUWriteState(const char *);
extern int CPULoadRom(const char *);
extern void CPUUpdateRegister(u32, u16);
extern void CPUWriteHalfWord(u32, u16);
extern void CPUWriteByte(u32, u8);
extern void CPUInit(const char *,bool);
extern void CPUReset();
extern void CPULoop(int);
extern bool CPUCheckDMA(int,int);
extern bool CPUIsGBAImage(const char *);
extern bool CPUIsZipFile(const char *);
#ifdef PROFILING
extern void cpuProfil(char *buffer, int, u32, int);
extern void cpuEnableProfiling(int hz);
#endif
extern struct EmulatedSystem GBASystem;
#define R13_IRQ 18
#define R14_IRQ 19
#define SPSR_IRQ 20
#define R13_USR 26
#define R14_USR 27
#define R13_SVC 28
#define R14_SVC 29
#define SPSR_SVC 30
#define R13_ABT 31
#define R14_ABT 32
#define SPSR_ABT 33
#define R13_UND 34
#define R14_UND 35
#define SPSR_UND 36
#define R8_FIQ 37
#define R9_FIQ 38
#define R10_FIQ 39
#define R11_FIQ 40
#define R12_FIQ 41
#define R13_FIQ 42
#define R14_FIQ 43
#define SPSR_FIQ 44
#include "Cheats.h"
#include "Globals.h"
#include "EEprom.h"
#include "Flash.h"
#endif //VBA_GBA_H
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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.
#ifndef VBA_GBA_H
#define VBA_GBA_H
#include "System.h"
#define SAVE_GAME_VERSION_1 1
#define SAVE_GAME_VERSION_2 2
#define SAVE_GAME_VERSION_3 3
#define SAVE_GAME_VERSION_4 4
#define SAVE_GAME_VERSION_5 5
#define SAVE_GAME_VERSION_6 6
#define SAVE_GAME_VERSION_7 7
#define SAVE_GAME_VERSION_8 8
#define SAVE_GAME_VERSION_9 9
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_9
typedef struct {
u8 *address;
u32 mask;
} memoryMap;
typedef union {
struct {
#ifdef WORDS_BIGENDIAN
u8 B3;
u8 B2;
u8 B1;
u8 B0;
#else
u8 B0;
u8 B1;
u8 B2;
u8 B3;
#endif
} B;
struct {
#ifdef WORDS_BIGENDIAN
u16 W1;
u16 W0;
#else
u16 W0;
u16 W1;
#endif
} W;
#ifdef WORDS_BIGENDIAN
volatile u32 I;
#else
u32 I;
#endif
} reg_pair;
#ifndef NO_GBA_MAP
extern memoryMap map[256];
#endif
extern reg_pair reg[45];
extern u8 biosProtected[4];
extern bool N_FLAG;
extern bool Z_FLAG;
extern bool C_FLAG;
extern bool V_FLAG;
extern bool armIrqEnable;
extern bool armState;
extern int armMode;
extern void (*cpuSaveGameFunc)(u32,u8);
extern u8 freezeWorkRAM[0x40000];
extern u8 freezeInternalRAM[0x8000];
extern u8 freezeVRAM[0x18000];
extern u8 freezeOAM[0x400];
extern u8 freezePRAM[0x400];
extern bool debugger_last;
extern int oldreg[17];
extern char oldbuffer[10];
extern bool CPUReadGSASnapshot(const char *);
extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *);
extern bool CPUWriteBatteryFile(const char *);
extern bool CPUReadBatteryFile(const char *);
extern bool CPUExportEepromFile(const char *);
extern bool CPUImportEepromFile(const char *);
extern bool CPUWritePNGFile(const char *);
extern bool CPUWriteBMPFile(const char *);
extern void CPUCleanUp();
extern void CPUUpdateRender();
extern bool CPUReadMemState(char *, int);
extern bool CPUReadState(const char *);
extern bool CPUWriteMemState(char *, int);
extern bool CPUWriteState(const char *);
extern int CPULoadRom(const char *);
extern void doMirroring(bool);
extern void CPUUpdateRegister(u32, u16);
extern void applyTimer ();
extern void CPUWriteHalfWord(u32, u16);
extern void CPUWriteByte(u32, u8);
extern void CPUInit(const char *,bool);
extern void CPUReset();
extern void CPULoop(int);
extern void CPUCheckDMA(int,int);
extern bool CPUIsGBAImage(const char *);
extern bool CPUIsZipFile(const char *);
#ifdef PROFILING
#include "prof/prof.h"
extern void cpuProfil(profile_segment *seg);
extern void cpuEnableProfiling(int hz);
#endif
extern struct EmulatedSystem GBASystem;
#define R13_IRQ 18
#define R14_IRQ 19
#define SPSR_IRQ 20
#define R13_USR 26
#define R14_USR 27
#define R13_SVC 28
#define R14_SVC 29
#define SPSR_SVC 30
#define R13_ABT 31
#define R14_ABT 32
#define SPSR_ABT 33
#define R13_UND 34
#define R14_UND 35
#define SPSR_UND 36
#define R8_FIQ 37
#define R9_FIQ 38
#define R10_FIQ 39
#define R11_FIQ 40
#define R12_FIQ 41
#define R13_FIQ 42
#define R14_FIQ 43
#define SPSR_FIQ 44
#include "Cheats.h"
#include "Globals.h"
#include "EEprom.h"
#include "Flash.h"
#endif //VBA_GBA_H

View File

@ -1,427 +1,488 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_GBAinline_H
#define VBA_GBAinline_H
#include "System.h"
#include "Port.h"
#include "RTC.h"
#include "Sound.h"
extern bool cpuSramEnabled;
extern bool cpuFlashEnabled;
extern bool cpuEEPROMEnabled;
extern bool cpuEEPROMSensorEnabled;
extern bool cpuDmaHack;
extern bool cpuDmaHack2;
extern u32 cpuDmaLast;
extern int lspeed;
extern void LinkSStop(void);
#define CPUReadByteQuick(addr) \
map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
#define CPUReadHalfWordQuick(addr) \
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
#define CPUReadMemoryQuick(addr) \
READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
inline u32 CPUReadMemory(u32 address)
{
#ifdef DEV_VERSION
if(address & 3) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
}
#endif
u32 value;
switch(address >> 24) {
case 0:
if(reg[15].I >> 24) {
if(address < 0x4000) {
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
value = READ32LE(((u32 *)&biosProtected));
}
else goto unreadable;
} else
value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
break;
case 2:
value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
break;
case 3:
value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
break;
case 4:
if((address>=0x4000120||address<=0x4000126)&&lspeed)
LinkSStop();
if((address < 0x4000400) && ioReadable[address & 0x3fc]) {
if(ioReadable[(address & 0x3fc) + 2])
value = soundRead32(address & 0x3fC);
else
value = soundRead16(address & 0x3fc);
} else goto unreadable;
break;
case 5:
value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
break;
case 6:
value = READ32LE(((u32 *)&vram[address & 0x1fffc]));
break;
case 7:
value = READ32LE(((u32 *)&oam[address & 0x3FC]));
break;
case 8:
case 9:
case 10:
case 11:
case 12:
value = READ32LE(((u32 *)&rom[address&0x1FFFFFC]));
break;
case 13:
if(cpuEEPROMEnabled)
// no need to swap this
return eepromRead(address);
goto unreadable;
case 14:
if(cpuFlashEnabled | cpuSramEnabled)
// no need to swap this
return flashRead(address);
// default
default:
unreadable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
if(cpuDmaHack || cpuDmaHack2) {
value = cpuDmaLast;
} else {
if(armState) {
value = CPUReadMemoryQuick(reg[15].I);
} else {
value = CPUReadHalfWordQuick(reg[15].I) |
CPUReadHalfWordQuick(reg[15].I) << 16;
}
}
}
if(address & 3) {
#ifdef C_CORE
int shift = (address & 3) << 3;
value = (value >> shift) | (value << (32 - shift));
#else
#ifdef __GNUC__
asm("and $3, %%ecx;"
"shl $3 ,%%ecx;"
"ror %%cl, %0"
: "=r" (value)
: "r" (value), "c" (address));
#else
__asm {
mov ecx, address;
and ecx, 3;
shl ecx, 3;
ror [dword ptr value], cl;
}
#endif
#endif
}
return value;
}
extern u32 myROM[];
inline u32 CPUReadHalfWord(u32 address)
{
#ifdef DEV_VERSION
if(address & 1) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
}
#endif
u32 value;
switch(address >> 24) {
case 0:
if (reg[15].I >> 24) {
if(address < 0x4000) {
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
value = READ16LE(((u16 *)&biosProtected[address&2]));
} else goto unreadable;
} else
value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
break;
case 2:
value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
break;
case 3:
value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
break;
case 4:
if((address>=0x4000120||address<=0x4000126)&&lspeed)
LinkSStop();
if((address < 0x4000400) && ioReadable[address & 0x3fe])
value = READ16LE(((u16 *)&ioMem[address & 0x3fe]));
else goto unreadable;
break;
case 5:
value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
break;
case 6:
value = READ16LE(((u16 *)&vram[address & 0x1fffe]));
break;
case 7:
value = READ16LE(((u16 *)&oam[address & 0x3fe]));
break;
case 8:
case 9:
case 10:
case 11:
case 12:
if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
value = rtcRead(address);
else
value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
break;
case 13:
if(cpuEEPROMEnabled)
// no need to swap this
return eepromRead(address);
goto unreadable;
case 14:
if(cpuFlashEnabled | cpuSramEnabled)
// no need to swap this
return flashRead(address);
// default
default:
unreadable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
if(cpuDmaHack2 || cpuDmaHack) {
value = cpuDmaLast & 0xFFFF;
} else {
if(armState) {
value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
} else {
value = CPUReadHalfWordQuick(reg[15].I);
}
}
break;
}
if(address & 1) {
value = (value >> 8) | (value << 24);
}
return value;
}
inline u16 CPUReadHalfWordSigned(u32 address)
{
u16 value = CPUReadHalfWord(address);
if((address & 1))
value = (s8)value;
return value;
}
inline u8 CPUReadByte(u32 address)
{
switch(address >> 24) {
case 0:
if (reg[15].I >> 24) {
if(address < 0x4000) {
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
return biosProtected[address & 3];
} else goto unreadable;
}
return bios[address & 0x3FFF];
case 2:
return workRAM[address & 0x3FFFF];
case 3:
return internalRAM[address & 0x7fff];
case 4:
if((address>=0x4000120||address<=0x4000126)&&lspeed)
LinkSStop();
if((address < 0x4000400) && ioReadable[address & 0x3ff])
return soundRead(address & 0x3ff);
else goto unreadable;
case 5:
return paletteRAM[address & 0x3ff];
case 6:
return vram[address & 0x1ffff];
case 7:
return oam[address & 0x3ff];
case 8:
case 9:
case 10:
case 11:
case 12:
return rom[address & 0x1FFFFFF];
case 13:
if(cpuEEPROMEnabled)
return eepromRead(address);
goto unreadable;
case 14:
if(cpuSramEnabled | cpuFlashEnabled)
return flashRead(address);
if(cpuEEPROMSensorEnabled) {
switch(address & 0x00008f00) {
case 0x8200:
return systemGetSensorX() & 255;
case 0x8300:
return (systemGetSensorX() >> 8)|0x80;
case 0x8400:
return systemGetSensorY() & 255;
case 0x8500:
return systemGetSensorY() >> 8;
}
}
// default
default:
unreadable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
if(cpuDmaHack || cpuDmaHack2) {
return cpuDmaLast & 0xFF;
} else {
if(armState) {
return CPUReadByteQuick(reg[15].I+(address & 3));
} else {
return CPUReadByteQuick(reg[15].I+(address & 1));
}
}
break;
}
}
inline void CPUWriteMemory(u32 address, u32 value)
{
#ifdef DEV_VERSION
if(address & 3) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaliagned word write: %08x to %08x from %08x\n",
value,
address,
armMode ? armNextPC - 4 : armNextPC - 2);
}
}
#endif
switch(address >> 24) {
case 0x02:
#ifdef SDL
if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
cheatsWriteMemory(address & 0x203FFFC,
value);
else
#endif
WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
break;
case 0x03:
#ifdef SDL
if(*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
cheatsWriteMemory(address & 0x3007FFC,
value);
else
#endif
WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
break;
case 0x04:
if(address < 0x4000400) {
CPUUpdateRegister((address & 0x3FC), value & 0xFFFF);
CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16));
} else goto unwritable;
break;
case 0x05:
WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
break;
case 0x06:
if(address & 0x10000)
WRITE32LE(((u32 *)&vram[address & 0x17ffc]), value);
else
WRITE32LE(((u32 *)&vram[address & 0x1fffc]), value);
break;
case 0x07:
WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
break;
case 0x0D:
if(cpuEEPROMEnabled) {
eepromWrite(address, value);
break;
}
goto unwritable;
case 0x0E:
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
(*cpuSaveGameFunc)(address, (u8)value);
break;
}
// default
default:
unwritable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
log("Illegal word write: %08x to %08x from %08x\n",
value,
address,
armMode ? armNextPC - 4 : armNextPC - 2);
}
#endif
break;
}
}
#endif //VBA_GBAinline_H
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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.
#ifndef VBA_GBAinline_H
#define VBA_GBAinline_H
#include "System.h"
#include "Port.h"
#include "RTC.h"
extern bool cpuSramEnabled;
extern bool cpuFlashEnabled;
extern bool cpuEEPROMEnabled;
extern bool cpuEEPROMSensorEnabled;
extern bool cpuDmaHack;
extern u32 cpuDmaLast;
extern bool timer0On;
extern int timer0Ticks;
extern int timer0ClockReload;
extern bool timer1On;
extern int timer1Ticks;
extern int timer1ClockReload;
extern bool timer2On;
extern int timer2Ticks;
extern int timer2ClockReload;
extern bool timer3On;
extern int timer3Ticks;
extern int timer3ClockReload;
extern int cpuTotalTicks;
#define CPUReadByteQuick(addr) \
map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
#define CPUReadHalfWordQuick(addr) \
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
#define CPUReadMemoryQuick(addr) \
READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
static inline u32 CPUReadMemory(u32 address)
{
#ifdef DEV_VERSION
if(address & 3) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
}
#endif
u32 value;
switch(address >> 24) {
case 0:
if(reg[15].I >> 24) {
if(address < 0x4000) {
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
value = READ32LE(((u32 *)&biosProtected));
}
else goto unreadable;
} else
value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
break;
case 2:
value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
break;
case 3:
value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
break;
case 4:
if((address < 0x4000400) && ioReadable[address & 0x3fc]) {
if(ioReadable[(address & 0x3fc) + 2])
value = READ32LE(((u32 *)&ioMem[address & 0x3fC]));
else
value = READ16LE(((u16 *)&ioMem[address & 0x3fc]));
} else goto unreadable;
break;
case 5:
value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
break;
case 6:
address = (address & 0x1fffc);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
{
value = 0;
break;
}
if ((address & 0x18000) == 0x18000)
address &= 0x17fff;
value = READ32LE(((u32 *)&vram[address]));
break;
case 7:
value = READ32LE(((u32 *)&oam[address & 0x3FC]));
break;
case 8:
case 9:
case 10:
case 11:
case 12:
value = READ32LE(((u32 *)&rom[address&0x1FFFFFC]));
break;
case 13:
if(cpuEEPROMEnabled)
// no need to swap this
return eepromRead(address);
goto unreadable;
case 14:
if(cpuFlashEnabled | cpuSramEnabled)
// no need to swap this
return flashRead(address);
// default
default:
unreadable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
if(cpuDmaHack) {
value = cpuDmaLast;
} else {
if(armState) {
value = CPUReadMemoryQuick(reg[15].I);
} else {
value = CPUReadHalfWordQuick(reg[15].I) |
CPUReadHalfWordQuick(reg[15].I) << 16;
}
}
}
if(address & 3) {
#ifdef C_CORE
int shift = (address & 3) << 3;
value = (value >> shift) | (value << (32 - shift));
#else
#ifdef __GNUC__
asm("and $3, %%ecx;"
"shl $3 ,%%ecx;"
"ror %%cl, %0"
: "=r" (value)
: "r" (value), "c" (address));
#else
__asm {
mov ecx, address;
and ecx, 3;
shl ecx, 3;
ror [dword ptr value], cl;
}
#endif
#endif
}
return value;
}
extern u32 myROM[];
static inline u32 CPUReadHalfWord(u32 address)
{
#ifdef DEV_VERSION
if(address & 1) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
}
#endif
u32 value;
switch(address >> 24) {
case 0:
if (reg[15].I >> 24) {
if(address < 0x4000) {
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
value = READ16LE(((u16 *)&biosProtected[address&2]));
} else goto unreadable;
} else
value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
break;
case 2:
value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
break;
case 3:
value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
break;
case 4:
if((address < 0x4000400) && ioReadable[address & 0x3fe])
{
value = READ16LE(((u16 *)&ioMem[address & 0x3fe]));
if (((address & 0x3fe)>0xFF) && ((address & 0x3fe)<0x10E))
{
if (((address & 0x3fe) == 0x100) && timer0On)
value = 0xFFFF - ((timer0Ticks-cpuTotalTicks) >> timer0ClockReload);
else
if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4))
value = 0xFFFF - ((timer1Ticks-cpuTotalTicks) >> timer1ClockReload);
else
if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4))
value = 0xFFFF - ((timer2Ticks-cpuTotalTicks) >> timer2ClockReload);
else
if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4))
value = 0xFFFF - ((timer3Ticks-cpuTotalTicks) >> timer3ClockReload);
}
}
else goto unreadable;
break;
case 5:
value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
break;
case 6:
address = (address & 0x1fffe);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
{
value = 0;
break;
}
if ((address & 0x18000) == 0x18000)
address &= 0x17fff;
value = READ16LE(((u16 *)&vram[address]));
break;
case 7:
value = READ16LE(((u16 *)&oam[address & 0x3fe]));
break;
case 8:
case 9:
case 10:
case 11:
case 12:
if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
value = rtcRead(address);
else
value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
break;
case 13:
if(cpuEEPROMEnabled)
// no need to swap this
return eepromRead(address);
goto unreadable;
case 14:
if(cpuFlashEnabled | cpuSramEnabled)
// no need to swap this
return flashRead(address);
// default
default:
unreadable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
if(cpuDmaHack) {
value = cpuDmaLast & 0xFFFF;
} else {
if(armState) {
value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
} else {
value = CPUReadHalfWordQuick(reg[15].I);
}
}
break;
}
if(address & 1) {
value = (value >> 8) | (value << 24);
}
return value;
}
static inline u16 CPUReadHalfWordSigned(u32 address)
{
u16 value = CPUReadHalfWord(address);
if((address & 1))
value = (s8)value;
return value;
}
static inline u8 CPUReadByte(u32 address)
{
switch(address >> 24) {
case 0:
if (reg[15].I >> 24) {
if(address < 0x4000) {
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
return biosProtected[address & 3];
} else goto unreadable;
}
return bios[address & 0x3FFF];
case 2:
return workRAM[address & 0x3FFFF];
case 3:
return internalRAM[address & 0x7fff];
case 4:
if((address < 0x4000400) && ioReadable[address & 0x3ff])
return ioMem[address & 0x3ff];
else goto unreadable;
case 5:
return paletteRAM[address & 0x3ff];
case 6:
address = (address & 0x1ffff);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
return 0;
if ((address & 0x18000) == 0x18000)
address &= 0x17fff;
return vram[address];
case 7:
return oam[address & 0x3ff];
case 8:
case 9:
case 10:
case 11:
case 12:
return rom[address & 0x1FFFFFF];
case 13:
if(cpuEEPROMEnabled)
return eepromRead(address);
goto unreadable;
case 14:
if(cpuSramEnabled | cpuFlashEnabled)
return flashRead(address);
if(cpuEEPROMSensorEnabled) {
switch(address & 0x00008f00) {
case 0x8200:
return systemGetSensorX() & 255;
case 0x8300:
return (systemGetSensorX() >> 8)|0x80;
case 0x8400:
return systemGetSensorY() & 255;
case 0x8500:
return systemGetSensorY() >> 8;
}
}
// default
default:
unreadable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2);
}
#endif
if(cpuDmaHack) {
return cpuDmaLast & 0xFF;
} else {
if(armState) {
return CPUReadByteQuick(reg[15].I+(address & 3));
} else {
return CPUReadByteQuick(reg[15].I+(address & 1));
}
}
break;
}
}
static inline void CPUWriteMemory(u32 address, u32 value)
{
#ifdef DEV_VERSION
if(address & 3) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned word write: %08x to %08x from %08x\n",
value,
address,
armMode ? armNextPC - 4 : armNextPC - 2);
}
}
#endif
switch(address >> 24) {
case 0x02:
#ifdef BKPT_SUPPORT
if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
cheatsWriteMemory(address & 0x203FFFC,
value);
else
#endif
WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
break;
case 0x03:
#ifdef BKPT_SUPPORT
if(*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
cheatsWriteMemory(address & 0x3007FFC,
value);
else
#endif
WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
break;
case 0x04:
if(address < 0x4000400) {
CPUUpdateRegister((address & 0x3FC), value & 0xFFFF);
CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16));
} else goto unwritable;
break;
case 0x05:
#ifdef BKPT_SUPPORT
if(*((u32 *)&freezePRAM[address & 0x3fc]))
cheatsWriteMemory(address & 0x70003FC,
value);
else
#endif
WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
break;
case 0x06:
address = (address & 0x1fffc);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
return;
if ((address & 0x18000) == 0x18000)
address &= 0x17fff;
#ifdef BKPT_SUPPORT
if(*((u32 *)&freezeVRAM[address]))
cheatsWriteMemory(address + 0x06000000, value);
else
#endif
WRITE32LE(((u32 *)&vram[address]), value);
break;
case 0x07:
#ifdef BKPT_SUPPORT
if(*((u32 *)&freezeOAM[address & 0x3fc]))
cheatsWriteMemory(address & 0x70003FC,
value);
else
#endif
WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
break;
case 0x0D:
if(cpuEEPROMEnabled) {
eepromWrite(address, value);
break;
}
goto unwritable;
case 0x0E:
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
(*cpuSaveGameFunc)(address, (u8)value);
break;
}
// default
default:
unwritable:
#ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
log("Illegal word write: %08x to %08x from %08x\n",
value,
address,
armMode ? armNextPC - 4 : armNextPC - 2);
}
#endif
break;
}
}
#endif //VBA_GBAinline_H

View File

@ -22,7 +22,6 @@ int coeff[32] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
u32 line0[240];
u32 line1[240];
u32 line2[240];
@ -32,6 +31,7 @@ u32 lineOBJWin[240];
u32 lineMix[240];
bool gfxInWin0[240];
bool gfxInWin1[240];
int lineOBJpixleft[128];
int gfxBG2Changed = 0;
int gfxBG3Changed = 0;

3235
src/Gfx.h

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,12 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Globals.h"
#include "GBA.h"
#ifdef BKPT_SUPPORT
int oldreg[17];
char oldbuffer[10];
#endif
reg_pair reg[45];
memoryMap map[256];
@ -43,8 +48,8 @@ int layerSettings = 0xff00;
int layerEnable = 0xff00;
bool speedHack = false;
int cpuSaveType = 0;
bool cpuEnhancedDetection = true;
bool cheatsEnabled = true;
bool mirroringEnable = false;
u8 *bios = NULL;
u8 *rom = NULL;

View File

@ -57,8 +57,8 @@ extern int layerSettings;
extern int layerEnable;
extern bool speedHack;
extern int cpuSaveType;
extern bool cpuEnhancedDetection;
extern bool cheatsEnabled;
extern bool mirroringEnable;
extern u8 *bios;
extern u8 *rom;

126
src/NLS.h
View File

@ -1,62 +1,64 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#define N_(String) (String)
#define MSG_UNSUPPORTED_VBA_SGM 1
#define MSG_CANNOT_LOAD_SGM 2
#define MSG_SAVE_GAME_NOT_USING_BIOS 3
#define MSG_SAVE_GAME_USING_BIOS 4
#define MSG_UNSUPPORTED_SAVE_TYPE 5
#define MSG_CANNOT_OPEN_FILE 6
#define MSG_BAD_ARCHIVE_FILE 7
#define MSG_NO_IMAGE_ON_ARCHIVE 8
#define MSG_ERROR_OPENING_IMAGE 9
#define MSG_ERROR_READING_IMAGE 10
#define MSG_UNSUPPORTED_BIOS_FUNCTION 11
#define MSG_INVALID_BIOS_FILE_SIZE 12
#define MSG_INVALID_CHEAT_CODE 13
#define MSG_UNKNOWN_ARM_OPCODE 14
#define MSG_UNKNOWN_THUMB_OPCODE 15
#define MSG_ERROR_CREATING_FILE 16
#define MSG_FAILED_TO_READ_SGM 17
#define MSG_FAILED_TO_READ_RTC 18
#define MSG_UNSUPPORTED_VB_SGM 19
#define MSG_CANNOT_LOAD_SGM_FOR 20
#define MSG_ERROR_OPENING_IMAGE_FROM 21
#define MSG_ERROR_READING_IMAGE_FROM 22
#define MSG_UNSUPPORTED_ROM_SIZE 23
#define MSG_UNSUPPORTED_RAM_SIZE 24
#define MSG_UNKNOWN_CARTRIDGE_TYPE 25
#define MSG_MAXIMUM_NUMBER_OF_CHEATS 26
#define MSG_INVALID_GAMESHARK_CODE 27
#define MSG_INVALID_GAMEGENIE_CODE 28
#define MSG_INVALID_CHEAT_TO_REMOVE 29
#define MSG_INVALID_CHEAT_CODE_ADDRESS 30
#define MSG_UNSUPPORTED_CHEAT_LIST_VERSION 31
#define MSG_UNSUPPORTED_CHEAT_LIST_TYPE 32
#define MSG_INVALID_GSA_CODE 33
#define MSG_CANNOT_IMPORT_SNAPSHOT_FOR 34
#define MSG_UNSUPPORTED_SNAPSHOT_FILE 35
#define MSG_UNSUPPORTED_ARM_MODE 36
#define MSG_UNSUPPORTED_CODE_FILE 37
#define MSG_GBA_CODE_WARNING 38
#define MSG_INVALID_CBA_CODE 39
#define MSG_CBA_CODE_WARNING 40
#define MSG_OUT_OF_MEMORY 41
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#define N_(String) (String)
#define MSG_UNSUPPORTED_VBA_SGM 1
#define MSG_CANNOT_LOAD_SGM 2
#define MSG_SAVE_GAME_NOT_USING_BIOS 3
#define MSG_SAVE_GAME_USING_BIOS 4
#define MSG_UNSUPPORTED_SAVE_TYPE 5
#define MSG_CANNOT_OPEN_FILE 6
#define MSG_BAD_ZIP_FILE 7
#define MSG_NO_IMAGE_ON_ZIP 8
#define MSG_ERROR_OPENING_IMAGE 9
#define MSG_ERROR_READING_IMAGE 10
#define MSG_UNSUPPORTED_BIOS_FUNCTION 11
#define MSG_INVALID_BIOS_FILE_SIZE 12
#define MSG_INVALID_CHEAT_CODE 13
#define MSG_UNKNOWN_ARM_OPCODE 14
#define MSG_UNKNOWN_THUMB_OPCODE 15
#define MSG_ERROR_CREATING_FILE 16
#define MSG_FAILED_TO_READ_SGM 17
#define MSG_FAILED_TO_READ_RTC 18
#define MSG_UNSUPPORTED_VB_SGM 19
#define MSG_CANNOT_LOAD_SGM_FOR 20
#define MSG_ERROR_OPENING_IMAGE_FROM 21
#define MSG_ERROR_READING_IMAGE_FROM 22
#define MSG_UNSUPPORTED_ROM_SIZE 23
#define MSG_UNSUPPORTED_RAM_SIZE 24
#define MSG_UNKNOWN_CARTRIDGE_TYPE 25
#define MSG_MAXIMUM_NUMBER_OF_CHEATS 26
#define MSG_INVALID_GAMESHARK_CODE 27
#define MSG_INVALID_GAMEGENIE_CODE 28
#define MSG_INVALID_CHEAT_TO_REMOVE 29
#define MSG_INVALID_CHEAT_CODE_ADDRESS 30
#define MSG_UNSUPPORTED_CHEAT_LIST_VERSION 31
#define MSG_UNSUPPORTED_CHEAT_LIST_TYPE 32
#define MSG_INVALID_GSA_CODE 33
#define MSG_CANNOT_IMPORT_SNAPSHOT_FOR 34
#define MSG_UNSUPPORTED_SNAPSHOT_FILE 35
#define MSG_UNSUPPORTED_ARM_MODE 36
#define MSG_UNSUPPORTED_CODE_FILE 37
#define MSG_GBA_CODE_WARNING 38
#define MSG_INVALID_CBA_CODE 39
#define MSG_CBA_CODE_WARNING 40
#define MSG_OUT_OF_MEMORY 41
#define MSG_WRONG_GAMESHARK_CODE 42
#define MSG_UNSUPPORTED_GAMESHARK_CODE 43

View File

@ -1,220 +1,222 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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 "System.h"
#include "GBA.h"
#include "Globals.h"
#include "Port.h"
#include "Util.h"
#include "NLS.h"
#include <time.h>
#include <memory.h>
enum RTCSTATE { IDLE, COMMAND, DATA, READDATA };
typedef struct {
u8 byte0;
u8 byte1;
u8 byte2;
u8 command;
int dataLen;
int bits;
RTCSTATE state;
u8 data[12];
// reserved variables for future
u8 reserved[12];
bool reserved2;
u32 reserved3;
} RTCCLOCKDATA;
static RTCCLOCKDATA rtcClockData;
static bool rtcEnabled = false;
void rtcEnable(bool e)
{
rtcEnabled = e;
}
bool rtcIsEnabled()
{
return rtcEnabled;
}
u16 rtcRead(u32 address)
{
if(rtcEnabled) {
if(address == 0x80000c8)
return rtcClockData.byte2;
else if(address == 0x80000c6)
return rtcClockData.byte1;
else if(address == 0x80000c4) {
return rtcClockData.byte0;
}
}
return READ16LE((&rom[address & 0x1FFFFFE]));
}
static u8 toBCD(u8 value)
{
value = value % 100;
int l = value % 10;
int h = value / 10;
return h * 16 + l;
}
bool rtcWrite(u32 address, u16 value)
{
if(!rtcEnabled)
return false;
if(address == 0x80000c8) {
rtcClockData.byte2 = (u8)value; // enable ?
} else if(address == 0x80000c6) {
rtcClockData.byte1 = (u8)value; // read/write
} else if(address == 0x80000c4) {
if(rtcClockData.byte2 & 1) {
if(rtcClockData.state == IDLE && rtcClockData.byte0 == 1 && value == 5) {
rtcClockData.state = COMMAND;
rtcClockData.bits = 0;
rtcClockData.command = 0;
} else if(!(rtcClockData.byte0 & 1) && (value & 1)) { // bit transfer
rtcClockData.byte0 = (u8)value;
switch(rtcClockData.state) {
case COMMAND:
rtcClockData.command |= ((value & 2) >> 1) << (7-rtcClockData.bits);
rtcClockData.bits++;
if(rtcClockData.bits == 8) {
rtcClockData.bits = 0;
switch(rtcClockData.command) {
case 0x60:
// not sure what this command does but it doesn't take parameters
// maybe it is a reset or stop
rtcClockData.state = IDLE;
rtcClockData.bits = 0;
break;
case 0x62:
// this sets the control state but not sure what those values are
rtcClockData.state = READDATA;
rtcClockData.dataLen = 1;
break;
case 0x63:
rtcClockData.dataLen = 1;
rtcClockData.data[0] = 0x40;
rtcClockData.state = DATA;
break;
case 0x65:
{
struct tm *newtime;
time_t long_time;
time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */
rtcClockData.dataLen = 7;
rtcClockData.data[0] = toBCD(newtime->tm_year);
rtcClockData.data[1] = toBCD(newtime->tm_mon+1);
rtcClockData.data[2] = toBCD(newtime->tm_mday);
rtcClockData.data[3] = toBCD(newtime->tm_wday);
rtcClockData.data[4] = toBCD(newtime->tm_hour);
rtcClockData.data[5] = toBCD(newtime->tm_min);
rtcClockData.data[6] = toBCD(newtime->tm_sec);
rtcClockData.state = DATA;
}
break;
case 0x67:
{
struct tm *newtime;
time_t long_time;
time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */
rtcClockData.dataLen = 3;
rtcClockData.data[0] = toBCD(newtime->tm_hour);
rtcClockData.data[1] = toBCD(newtime->tm_min);
rtcClockData.data[2] = toBCD(newtime->tm_sec);
rtcClockData.state = DATA;
}
break;
default:
systemMessage(0, N_("Unknown RTC command %02x"), rtcClockData.command);
rtcClockData.state = IDLE;
break;
}
}
break;
case DATA:
if(rtcClockData.byte1 & 2) {
} else {
rtcClockData.byte0 = (rtcClockData.byte0 & ~2) |
((rtcClockData.data[rtcClockData.bits >> 3] >>
(rtcClockData.bits & 7)) & 1)*2;
rtcClockData.bits++;
if(rtcClockData.bits == 8*rtcClockData.dataLen) {
rtcClockData.bits = 0;
rtcClockData.state = IDLE;
}
}
break;
case READDATA:
if(!(rtcClockData.byte1 & 2)) {
} else {
rtcClockData.data[rtcClockData.bits >> 3] =
(rtcClockData.data[rtcClockData.bits >> 3] >> 1) |
((value << 6) & 128);
rtcClockData.bits++;
if(rtcClockData.bits == 8*rtcClockData.dataLen) {
rtcClockData.bits = 0;
rtcClockData.state = IDLE;
}
}
break;
default:
break;
}
} else
rtcClockData.byte0 = (u8)value;
}
}
return true;
}
void rtcReset()
{
memset(&rtcClockData, 0, sizeof(rtcClockData));
rtcClockData.byte0 = 0;
rtcClockData.byte1 = 0;
rtcClockData.byte2 = 0;
rtcClockData.command = 0;
rtcClockData.dataLen = 0;
rtcClockData.bits = 0;
rtcClockData.state = IDLE;
}
void rtcSaveGame(gzFile gzFile)
{
utilGzWrite(gzFile, &rtcClockData, sizeof(rtcClockData));
}
void rtcReadGame(gzFile gzFile)
{
utilGzRead(gzFile, &rtcClockData, sizeof(rtcClockData));
}
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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 "System.h"
#include "GBA.h"
#include "Globals.h"
#include "Port.h"
#include "Util.h"
#include "NLS.h"
#include <time.h>
#include <memory.h>
enum RTCSTATE { IDLE, COMMAND, DATA, READDATA };
typedef struct {
u8 byte0;
u8 byte1;
u8 byte2;
u8 command;
int dataLen;
int bits;
RTCSTATE state;
u8 data[12];
// reserved variables for future
u8 reserved[12];
bool reserved2;
u32 reserved3;
} RTCCLOCKDATA;
static RTCCLOCKDATA rtcClockData;
static bool rtcEnabled = false;
void rtcEnable(bool e)
{
rtcEnabled = e;
}
bool rtcIsEnabled()
{
return rtcEnabled;
}
u16 rtcRead(u32 address)
{
if(rtcEnabled) {
if(address == 0x80000c8)
return rtcClockData.byte2;
else if(address == 0x80000c6)
return rtcClockData.byte1;
else if(address == 0x80000c4) {
return rtcClockData.byte0;
}
}
return READ16LE((&rom[address & 0x1FFFFFE]));
}
static u8 toBCD(u8 value)
{
value = value % 100;
int l = value % 10;
int h = value / 10;
return h * 16 + l;
}
bool rtcWrite(u32 address, u16 value)
{
if(!rtcEnabled)
return false;
if(address == 0x80000c8) {
rtcClockData.byte2 = (u8)value; // enable ?
} else if(address == 0x80000c6) {
rtcClockData.byte1 = (u8)value; // read/write
} else if(address == 0x80000c4) {
if(rtcClockData.byte2 & 1) {
if(rtcClockData.state == IDLE && rtcClockData.byte0 == 1 && value == 5) {
rtcClockData.state = COMMAND;
rtcClockData.bits = 0;
rtcClockData.command = 0;
} else if(!(rtcClockData.byte0 & 1) && (value & 1)) { // bit transfer
rtcClockData.byte0 = (u8)value;
switch(rtcClockData.state) {
case COMMAND:
rtcClockData.command |= ((value & 2) >> 1) << (7-rtcClockData.bits);
rtcClockData.bits++;
if(rtcClockData.bits == 8) {
rtcClockData.bits = 0;
switch(rtcClockData.command) {
case 0x60:
// not sure what this command does but it doesn't take parameters
// maybe it is a reset or stop
rtcClockData.state = IDLE;
rtcClockData.bits = 0;
break;
case 0x62:
// this sets the control state but not sure what those values are
rtcClockData.state = READDATA;
rtcClockData.dataLen = 1;
break;
case 0x63:
rtcClockData.dataLen = 1;
rtcClockData.data[0] = 0x40;
rtcClockData.state = DATA;
break;
case 0x64:
break;
case 0x65:
{
struct tm *newtime;
time_t long_time;
time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */
rtcClockData.dataLen = 7;
rtcClockData.data[0] = toBCD(newtime->tm_year);
rtcClockData.data[1] = toBCD(newtime->tm_mon+1);
rtcClockData.data[2] = toBCD(newtime->tm_mday);
rtcClockData.data[3] = toBCD(newtime->tm_wday);
rtcClockData.data[4] = toBCD(newtime->tm_hour);
rtcClockData.data[5] = toBCD(newtime->tm_min);
rtcClockData.data[6] = toBCD(newtime->tm_sec);
rtcClockData.state = DATA;
}
break;
case 0x67:
{
struct tm *newtime;
time_t long_time;
time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */
rtcClockData.dataLen = 3;
rtcClockData.data[0] = toBCD(newtime->tm_hour);
rtcClockData.data[1] = toBCD(newtime->tm_min);
rtcClockData.data[2] = toBCD(newtime->tm_sec);
rtcClockData.state = DATA;
}
break;
default:
systemMessage(0, N_("Unknown RTC command %02x"), rtcClockData.command);
rtcClockData.state = IDLE;
break;
}
}
break;
case DATA:
if(rtcClockData.byte1 & 2) {
} else {
rtcClockData.byte0 = (rtcClockData.byte0 & ~2) |
((rtcClockData.data[rtcClockData.bits >> 3] >>
(rtcClockData.bits & 7)) & 1)*2;
rtcClockData.bits++;
if(rtcClockData.bits == 8*rtcClockData.dataLen) {
rtcClockData.bits = 0;
rtcClockData.state = IDLE;
}
}
break;
case READDATA:
if(!(rtcClockData.byte1 & 2)) {
} else {
rtcClockData.data[rtcClockData.bits >> 3] =
(rtcClockData.data[rtcClockData.bits >> 3] >> 1) |
((value << 6) & 128);
rtcClockData.bits++;
if(rtcClockData.bits == 8*rtcClockData.dataLen) {
rtcClockData.bits = 0;
rtcClockData.state = IDLE;
}
}
break;
default:
break;
}
} else
rtcClockData.byte0 = (u8)value;
}
}
return true;
}
void rtcReset()
{
memset(&rtcClockData, 0, sizeof(rtcClockData));
rtcClockData.byte0 = 0;
rtcClockData.byte1 = 0;
rtcClockData.byte2 = 0;
rtcClockData.command = 0;
rtcClockData.dataLen = 0;
rtcClockData.bits = 0;
rtcClockData.state = IDLE;
}
void rtcSaveGame(gzFile gzFile)
{
utilGzWrite(gzFile, &rtcClockData, sizeof(rtcClockData));
}
void rtcReadGame(gzFile gzFile)
{
utilGzRead(gzFile, &rtcClockData, sizeof(rtcClockData));
}

View File

@ -659,40 +659,17 @@ void soundChannel4()
{
}
#include <stdio.h>
inline void soundDirectSoundA()
{
#ifdef ENHANCED_RATE
double cr = calc_rate(soundDSATimer);
static int cnt = 0;
static double lastcr = 0;
static FILE *fp = NULL;
if (fp==NULL)
fp=fopen("C:\\cr.txt", "at");
if (cr!=lastcr)
{
fprintf(fp, "%f %d\n", lastcr, cnt);
cnt=0;
lastcr=cr;
}
else
cnt++;
directBuffer[0][soundIndex] = interp_pop(0, calc_rate(soundDSATimer)); //soundDSAValue;
#else
directBuffer[0][soundIndex] = interp_pop(0); //soundDSAValue;
#endif
}
void soundDirectSoundATimer()
{
if(soundDSAEnabled) {
if(soundDSFifoACount <= 16) {
cpuDmaHack2 = CPUCheckDMA(3, 2);
CPUCheckDMA(3, 2);
if(soundDSFifoACount <= 16) {
soundEvent(FIFOA_L, (u16)0);
soundEvent(FIFOA_H, (u16)0);
@ -714,18 +691,15 @@ void soundDirectSoundATimer()
inline void soundDirectSoundB()
{
#ifdef ENHANCED_RATE
directBuffer[1][soundIndex] = interp_pop(1, calc_rate(soundDSBTimer)); //soundDSBValue;
#else
directBuffer[1][soundIndex] = interp_pop(1); //soundDSBValue;
#endif
}
void soundDirectSoundBTimer()
{
if(soundDSBEnabled) {
if(soundDSFifoBCount <= 16) {
cpuDmaHack2 = CPUCheckDMA(3, 4);
//cpuDmaHack2 =
CPUCheckDMA(3, 4);
if(soundDSFifoBCount <= 16) {
soundEvent(FIFOB_L, (u16)0);
soundEvent(FIFOB_H, (u16)0);

View File

@ -2,6 +2,7 @@
// 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
// 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
@ -95,7 +96,6 @@ extern Multi_Buffer * apu_out;
extern Gb_Apu * apu;
extern const BOOST::uint8_t sound_data [Gb_Apu::register_count];
extern void interp_rate();

View File

@ -1,39 +1,39 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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 "GBA.h"
#include "Globals.h"
#include "Flash.h"
#include "Sram.h"
u8 sramRead(u32 address)
{
return flashSaveMemory[address & 0xFFFF];
}
void sramDelayedWrite(u32 address, u8 byte)
{
saveType = 1;
cpuSaveGameFunc = sramWrite;
sramWrite(address, byte);
}
void sramWrite(u32 address, u8 byte)
{
flashSaveMemory[address & 0xFFFF] = byte;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
}
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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 "GBA.h"
#include "Globals.h"
#include "Flash.h"
#include "Sram.h"
u8 sramRead(u32 address)
{
return flashSaveMemory[address & 0xFFFF];
}
void sramDelayedWrite(u32 address, u8 byte)
{
saveType = 1;
cpuSaveGameFunc = sramWrite;
sramWrite(address, byte);
}
void sramWrite(u32 address, u8 byte)
{
flashSaveMemory[address & 0xFFFF] = byte;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
}

View File

@ -1,27 +1,27 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_SRAM_H
#define VBA_SRAM_H
extern u8 sramRead(u32 address);
extern void sramWrite(u32 address, u8 byte);
extern void sramDelayedWrite(u32 address, u8 byte);
#endif // VBA_SRAM_H
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_SRAM_H
#define VBA_SRAM_H
extern u8 sramRead(u32 address);
extern void sramWrite(u32 address, u8 byte);
extern void sramDelayedWrite(u32 address, u8 byte);
#endif // VBA_SRAM_H

View File

@ -106,6 +106,12 @@ extern void system10Frames(int);
extern void systemFrame();
extern void systemGbBorderOn();
extern void Sm60FPS_Init();
extern bool Sm60FPS_CanSkipFrame();
extern void Sm60FPS_Sleep();
extern void DbgMsg(const char *msg, ...);
extern void winlog(const char *,...);
extern bool systemSoundOn;
extern u16 systemColorMap16[0x10000];
extern u32 systemColorMap32[0x10000];
@ -118,6 +124,7 @@ extern int systemDebug;
extern int systemVerbose;
extern int systemFrameSkip;
extern int systemSaveUpdateCounter;
extern int systemSpeed;
#define SYSTEM_SAVE_UPDATED 30
#define SYSTEM_SAVE_NOT_UPDATED 0

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_UTIL_H
#define VBA_UTIL_H
enum IMAGE_TYPE {
IMAGE_UNKNOWN = -1,
IMAGE_GBA = 0,
IMAGE_GB = 1
};
// save game
typedef struct {
void *address;
int size;
} variable_desc;
extern bool utilWritePNGFile(const char *, int, int, u8 *);
extern bool utilWriteBMPFile(const char *, int, int, u8 *);
extern void utilApplyIPS(const char *ips, u8 **rom, int *size);
extern void utilWriteBMP(char *, int, int, u8 *);
extern bool utilIsGBAImage(const char *);
extern bool utilIsGBImage(const char *);
extern bool utilIsZipFile(const char *);
extern bool utilIsGzipFile(const char *);
extern bool utilIsRarFile(const char *);
extern void utilGetBaseName(const char *, char *);
extern IMAGE_TYPE utilFindType(const char *);
extern u8 *utilLoad(const char *,
bool (*)(const char*),
u8 *,
int &);
extern void utilPutDword(u8 *, u32);
extern void utilPutWord(u8 *, u16);
extern void utilWriteData(gzFile, variable_desc *);
extern void utilReadData(gzFile, variable_desc *);
extern int utilReadInt(gzFile);
extern void utilWriteInt(gzFile, int);
extern gzFile utilGzOpen(const char *file, const char *mode);
extern gzFile utilMemGzOpen(char *memory, int available, char *mode);
extern int utilGzWrite(gzFile file, const voidp buffer, unsigned int len);
extern int utilGzRead(gzFile file, voidp buffer, unsigned int len);
extern int utilGzClose(gzFile file);
extern long utilGzMemTell(gzFile file);
extern void utilGBAFindSave(const u8 *, const int);
extern void utilUpdateSystemColorMaps(int lcd);
#endif
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#ifndef VBA_UTIL_H
#define VBA_UTIL_H
enum IMAGE_TYPE {
IMAGE_UNKNOWN = -1,
IMAGE_GBA = 0,
IMAGE_GB = 1
};
// save game
typedef struct {
void *address;
int size;
} variable_desc;
extern bool utilWritePNGFile(const char *, int, int, u8 *);
extern bool utilWriteBMPFile(const char *, int, int, u8 *);
extern void utilApplyIPS(const char *ips, u8 **rom, int *size);
extern void utilWriteBMP(char *, int, int, u8 *);
extern bool utilIsGBAImage(const char *);
extern bool utilIsGBImage(const char *);
extern bool utilIsZipFile(const char *);
extern bool utilIsGzipFile(const char *);
extern bool utilIsRarFile(const char *);
extern void utilGetBaseName(const char *, char *);
extern IMAGE_TYPE utilFindType(const char *);
extern u8 *utilLoad(const char *,
bool (*)(const char*),
u8 *,
int &);
extern void utilPutDword(u8 *, u32);
extern void utilPutWord(u8 *, u16);
extern void utilWriteData(gzFile, variable_desc *);
extern void utilReadData(gzFile, variable_desc *);
extern int utilReadInt(gzFile);
extern void utilWriteInt(gzFile, int);
extern gzFile utilGzOpen(const char *file, const char *mode);
extern gzFile utilMemGzOpen(char *memory, int available, char *mode);
extern int utilGzWrite(gzFile file, const voidp buffer, unsigned int len);
extern int utilGzRead(gzFile file, voidp buffer, unsigned int len);
extern int utilGzClose(gzFile file);
extern long utilGzMemTell(gzFile file);
extern void utilGBAFindSave(const u8 *, const int);
extern void utilUpdateSystemColorMaps();
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -117,8 +117,8 @@ const Opcodes thumbOpcodes[] = {
{0xfa00, 0x5800, "ldr%b %r0, [%r3, %r6]"},
// Format 8
{0xfe00, 0x5200, "strh %r0, [%r3, %r6]"},
{0xfe00, 0x5600, "ldrh %r0, [%r3, %r6]"},
{0xfe00, 0x5a00, "ldsb %r0, [%r3, %r6]"},
{0xfe00, 0x5600, "ldsb %r0, [%r3, %r6]"},
{0xfe00, 0x5a00, "ldrh %r0, [%r3, %r6]"},
{0xfe00, 0x5e00, "ldsh %r0, [%r3, %r6]"},
// Format 9
{0xe800, 0x6000, "str%B %r0, [%r3, %p]"},

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2004-2006 Forgotten and the VBA 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
@ -23,6 +23,7 @@
extern void BIOS_ArcTan();
extern void BIOS_ArcTan2();
extern void BIOS_BitUnPack();
extern void BIOS_GetBiosChecksum();
extern void BIOS_BgAffineSet();
extern void BIOS_CpuSet();
extern void BIOS_CpuFastSet();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 Forgotten and the VBA 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
@ -38,11 +38,15 @@ typedef union {
extern bool gbLoadRom(const char *);
extern void gbEmulate(int);
extern void gbWriteMemory(register u16, register u8);
extern void gbDrawLine();
extern bool gbIsGameboyRom(const char *);
extern void gbSoundReset();
extern void gbSoundSetQuality(int);
extern void gbGetHardwareType();
extern void gbReset();
extern void gbCleanUp();
extern void gbCPUInit(const char *,bool);
extern bool gbWriteBatteryFile(const char *);
extern bool gbWriteBatteryFile(const char *, bool);
extern bool gbReadBatteryFile(const char *);

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -27,9 +27,11 @@
#include "gbCheats.h"
#include "gbGlobals.h"
#include "GB.h"
gbCheat gbCheatList[100];
int gbCheatNumber = 0;
int gbNextCheat = 0;
bool gbCheatMap[0x10000];
extern bool cheatsEnabled;
@ -50,7 +52,7 @@ void gbCheatUpdateMap()
void gbCheatsSaveGame(gzFile gzFile)
{
utilWriteInt(gzFile, gbCheatNumber);
if(gbCheatNumber)
if(gbCheatNumber>0)
utilGzWrite(gzFile, &gbCheatList[0], sizeof(gbCheat)*gbCheatNumber);
}
@ -81,7 +83,7 @@ void gbCheatsReadGame(gzFile gzFile, int version)
} else {
gbCheatNumber = utilReadInt(gzFile);
if(gbCheatNumber) {
if(gbCheatNumber>0) {
utilGzRead(gzFile, &gbCheatList[0], sizeof(gbCheat)*gbCheatNumber);
}
}
@ -163,7 +165,7 @@ bool gbCheatsLoadCheatList(const char *file)
bool gbVerifyGsCode(const char *code)
{
int len = strlen(code);
size_t len = strlen(code);
if(len == 0)
return true;
@ -180,10 +182,6 @@ bool gbVerifyGsCode(const char *code)
GBCHEAT_HEX_VALUE(code[4]) << 4 |
GBCHEAT_HEX_VALUE(code[5]);
if(address < 0xa000 ||
address > 0xdfff)
return false;
return true;
}
@ -220,15 +218,23 @@ void gbAddGsCheat(const char *code, const char *desc)
gbCheatList[i].compare = 0;
gbCheatList[i].enabled = true;
gbCheatMap[gbCheatList[i].address] = true;
int gsCode = gbCheatList[i].code;
if ((gsCode !=1) && ((gsCode & 0xF0) !=0x80) && ((gsCode & 0xF0) !=0x90) &&
((gsCode & 0xF0) !=0xA0) && ((gsCode) !=0xF0) && ((gsCode) !=0xF1))
systemMessage(MSG_WRONG_GAMESHARK_CODE,
N_("Wrong GameShark code type : %s"), code);
else if (((gsCode & 0xF0) ==0xA0) || ((gsCode) ==0xF0) || ((gsCode) ==0xF1))
systemMessage(MSG_UNSUPPORTED_GAMESHARK_CODE,
N_("Unsupported GameShark code type : %s"), code);
gbCheatNumber++;
}
bool gbVerifyGgCode(const char *code)
{
int len = strlen(code);
size_t len = strlen(code);
if(len != 11 &&
len != 7 &&
@ -313,12 +319,12 @@ void gbAddGgCheat(const char *code, const char *desc)
int i = gbCheatNumber;
int len = strlen(code);
size_t len = strlen(code);
strcpy(gbCheatList[i].cheatCode, code);
strcpy(gbCheatList[i].cheatDesc, desc);
gbCheatList[i].code = 1;
gbCheatList[i].code = 0x101;
gbCheatList[i].value = (GBCHEAT_HEX_VALUE(code[0]) << 4) +
GBCHEAT_HEX_VALUE(code[1]);
@ -338,9 +344,12 @@ void gbAddGgCheat(const char *code, const char *desc)
compare ^= 0x45;
gbCheatList[i].compare = compare;
gbCheatList[i].code = 0;
//gbCheatList[i].code = 0;
gbCheatList[i].code = 0x100; // fix for compare value
}
gbCheatList[i].enabled = true;
gbCheatMap[gbCheatList[i].address] = true;
@ -425,6 +434,7 @@ bool gbCheatReadGSCodeFile(const char *fileName)
return true;
}
// Used to emulated GG codes
u8 gbCheatRead(u16 address)
{
if(!cheatsEnabled)
@ -437,26 +447,72 @@ u8 gbCheatRead(u16 address)
if(gbMemoryMap[address>>12][address&0xFFF] == gbCheatList[i].compare)
return gbCheatList[i].value;
break;
case 0x00:
case 0x01:
case 0x80:
return gbCheatList[i].value;
case 0x90:
case 0x91:
case 0x92:
case 0x93:
case 0x94:
case 0x95:
case 0x96:
case 0x97:
if(address >= 0xd000 && address < 0xe000) {
if(((gbMemoryMap[0x0d] - gbWram)/0x1000) ==
(gbCheatList[i].code - 0x90))
return gbCheatList[i].value;
} else
case 0x101: // GameGenie 6 digits code support
return gbCheatList[i].value;
break;
}
}
}
return gbMemoryMap[address>>12][address&0xFFF];
}
// Used to emulate GS codes.
void gbCheatWrite(bool reboot)
{
if(cheatsEnabled)
{
u16 address = 0;
if (gbNextCheat >= gbCheatNumber)
gbNextCheat = 0;
for(int i = gbNextCheat; i < gbCheatNumber; i++) {
if(gbCheatList[i].enabled) {
address = gbCheatList[i].address;
if ((!reboot) && (address >= 0x8000) && !((address>=0xA000) && (address<0xC000)))
{ // These codes are executed one per one, at each Vblank
switch(gbCheatList[i].code) {
case 0x01:
gbWriteMemory(address, gbCheatList[i].value);
gbNextCheat = i+1;
return;
case 0x90:
case 0x91:
case 0x92:
case 0x93:
case 0x94:
case 0x95:
case 0x96:
case 0x97:
case 0x98:
case 0x99:
case 0x9A:
case 0x9B:
case 0x9C:
case 0x9D:
case 0x9E:
case 0x9F:
int oldbank = gbMemory[0xff70];
gbWriteMemory(0xff70, gbCheatList[i].code & 0xf);
gbWriteMemory(address, gbCheatList[i].value);
gbWriteMemory(0xff70, oldbank);
gbNextCheat = i+1;
return;
}
}
else // These codes are only executed when the game is booted
{
switch(gbCheatList[i].code & 0xF0) {
case 0x80:
gbWriteMemory(0x0000, 0x0A);
gbWriteMemory(0x4000, gbCheatList[i].value & 0xF);
gbWriteMemory(address, gbCheatList[i].value);
gbNextCheat = i+1;
return;
}
}
}
}
}
}

View File

@ -50,6 +50,7 @@ extern void gbCheatRemoveAll();
extern void gbCheatEnable(int);
extern void gbCheatDisable(int);
extern u8 gbCheatRead(u16);
extern void gbCheatWrite(bool);
extern int gbCheatNumber;
extern gbCheat gbCheatList[100];

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 Forgotten and the VBA 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
@ -22,8 +22,8 @@
break;
case 0x01:
// LD BC, NNNN
BC.B.B0=gbReadMemory(PC.W++);
BC.B.B1=gbReadMemory(PC.W++);
BC.B.B0=gbReadOpcode(PC.W++);
BC.B.B1=gbReadOpcode(PC.W++);
break;
case 0x02:
// LD (BC),A
@ -102,7 +102,9 @@
opcode = gbReadOpcode(PC.W++);
if(gbCgbMode) {
if(gbMemory[0xff4d] & 1) {
gbSpeedSwitch();
//clockTicks += 228*144-(gbSpeed ? 62 : 63);
if(gbSpeed == 0)
gbMemory[0xff4d] = 0x00;
@ -113,8 +115,8 @@
break;
case 0x11:
// LD DE, NNNN
DE.B.B0=gbReadMemory(PC.W++);
DE.B.B1=gbReadMemory(PC.W++);
DE.B.B0=gbReadOpcode(PC.W++);
DE.B.B1=gbReadOpcode(PC.W++);
break;
case 0x12:
// LD (DE),A
@ -147,7 +149,7 @@
break;
case 0x18:
// JR NN
PC.W+=(s8)gbReadMemory(PC.W)+1;
PC.W+=(s8)gbReadOpcode(PC.W)+1;
break;
case 0x19:
// ADD HL,DE
@ -190,14 +192,14 @@
if(AF.B.B0&Z_FLAG)
PC.W++;
else {
PC.W+=(s8)gbReadMemory(PC.W)+1;
PC.W+=(s8)gbReadOpcode(PC.W)+1;
clockTicks++;
}
break;
case 0x21:
// LD HL,NNNN
HL.B.B0=gbReadMemory(PC.W++);
HL.B.B1=gbReadMemory(PC.W++);
HL.B.B0=gbReadOpcode(PC.W++);
HL.B.B1=gbReadOpcode(PC.W++);
break;
case 0x22:
// LDI (HL),A
@ -233,7 +235,7 @@
case 0x28:
// JR Z,NN
if(AF.B.B0&Z_FLAG) {
PC.W+=(s8)gbReadMemory(PC.W)+1;
PC.W+=(s8)gbReadOpcode(PC.W)+1;
clockTicks++;
} else
PC.W++;
@ -278,14 +280,14 @@
if(AF.B.B0&C_FLAG)
PC.W++;
else {
PC.W+=(s8)gbReadMemory(PC.W)+1;
PC.W+=(s8)gbReadOpcode(PC.W)+1;
clockTicks++;
}
break;
case 0x31:
// LD SP,NNNN
SP.B.B0=gbReadMemory(PC.W++);
SP.B.B1=gbReadMemory(PC.W++);
SP.B.B0=gbReadOpcode(PC.W++);
SP.B.B1=gbReadOpcode(PC.W++);
break;
case 0x32:
// LDD (HL),A
@ -318,7 +320,7 @@
case 0x38:
// JR C,NN
if(AF.B.B0&C_FLAG) {
PC.W+=(s8)gbReadMemory(PC.W)+1;
PC.W+=(s8)gbReadOpcode(PC.W)+1;
clockTicks ++;
} else
PC.W++;
@ -575,16 +577,24 @@ case 0x38:
break;
case 0x76:
// HALT
if(IFF & 1) {
// If an EI is pending, the interrupts are triggered before Halt state !!
// Fix Torpedo Range's intro.
if (IFF & 0x40)
{
IFF &= ~0x70;
IFF |=1;
PC.W--;
IFF |= 0x80;
} else {
if((register_IE & register_IF) > 0)
IFF |= 0x100;
else {
PC.W--;
IFF |= 0x81;
}
else
{
// if (IE & IF) and interrupts are disabeld,
// Halt is cancelled.
if ((register_IE & register_IF & 0x1f) && !(IFF & 1))
{
IFF|=2;
}
else
IFF |= 0x80;
}
break;
case 0x77:
@ -1036,16 +1046,16 @@ case 0x38:
if(AF.B.B0&Z_FLAG)
PC.W+=2;
else {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W);
PC.W=tempRegister.W;
clockTicks++;
}
break;
case 0xc3:
// JP NNNN
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W);
PC.W=tempRegister.W;
break;
case 0xc4:
@ -1053,8 +1063,8 @@ case 0x38:
if(AF.B.B0&Z_FLAG)
PC.W+=2;
else {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W++);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W,PC.B.B1);
gbWriteMemory(--SP.W,PC.B.B0);
PC.W=tempRegister.W;
@ -1096,8 +1106,8 @@ case 0x38:
case 0xca:
// JP Z,NNNN
if(AF.B.B0&Z_FLAG) {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W);
PC.W=tempRegister.W;
clockTicks++;
} else
@ -1107,8 +1117,8 @@ case 0x38:
case 0xcc:
// CALL Z,NNNN
if(AF.B.B0&Z_FLAG) {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W++);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W,PC.B.B1);
gbWriteMemory(--SP.W,PC.B.B0);
PC.W=tempRegister.W;
@ -1118,8 +1128,8 @@ case 0x38:
break;
case 0xcd:
// CALL NNNN
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W++);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W,PC.B.B1);
gbWriteMemory(--SP.W,PC.B.B0);
PC.W=tempRegister.W;
@ -1156,20 +1166,24 @@ case 0x38:
if(AF.B.B0&C_FLAG)
PC.W+=2;
else {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W);
PC.W=tempRegister.W;
clockTicks++;
}
break;
// D3 illegal
case 0xd3:
PC.W--;
IFF = 0;
break;
case 0xd4:
// CALL NC,NNNN
if(AF.B.B0&C_FLAG)
PC.W+=2;
else {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W++);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W,PC.B.B1);
gbWriteMemory(--SP.W,PC.B.B0);
PC.W=tempRegister.W;
@ -1200,7 +1214,7 @@ case 0x38:
if(AF.B.B0&C_FLAG) {
PC.B.B0=gbReadMemory(SP.W++);
PC.B.B1=gbReadMemory(SP.W++);
clockTicks += 4;
clockTicks += 3;
}
break;
case 0xd9:
@ -1212,19 +1226,23 @@ case 0x38:
case 0xda:
// JP C,NNNN
if(AF.B.B0&C_FLAG) {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W);
PC.W=tempRegister.W;
clockTicks++;
} else
PC.W+=2;
break;
// DB illegal
case 0xdb:
PC.W--;
IFF = 0;
break;
case 0xdc:
// CALL C,NNNN
if(AF.B.B0&C_FLAG) {
tempRegister.B.B0=gbReadMemory(PC.W++);
tempRegister.B.B1=gbReadMemory(PC.W++);
tempRegister.B.B0=gbReadOpcode(PC.W++);
tempRegister.B.B1=gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W,PC.B.B1);
gbWriteMemory(--SP.W,PC.B.B0);
PC.W=tempRegister.W;
@ -1233,6 +1251,10 @@ case 0x38:
PC.W+=2;
break;
// DD illegal
case 0xdd:
PC.W--;
IFF = 0;
break;
case 0xde:
// SBC NN
tempValue=gbReadOpcode(PC.W++);
@ -1262,6 +1284,11 @@ case 0x38:
break;
// E3 illegal
// E4 illegal
case 0xe3:
case 0xe4:
PC.W--;
IFF = 0;
break;
case 0xe5:
// PUSH HL
gbWriteMemory(--SP.W,HL.B.B1);
@ -1308,6 +1335,12 @@ case 0x38:
// EB illegal
// EC illegal
// ED illegal
case 0xeb:
case 0xec:
case 0xed:
PC.W--;
IFF = 0;
break;
case 0xee:
// XOR NN
tempValue=gbReadOpcode(PC.W++);
@ -1336,9 +1369,13 @@ case 0x38:
case 0xf3:
// DI
// IFF&=0xFE;
IFF&=(~0x21);
IFF|=0x08;
break;
// F4 illegal
case 0xf4:
PC.W--;
IFF = 0;
break;
case 0xf5:
// PUSH AF
gbWriteMemory(--SP.W,AF.B.B1);
@ -1383,10 +1420,23 @@ case 0x38:
break;
case 0xfb:
// EI
IFF|=0x20;
if (!(IFF & 0x30))
// If an EI is executed right before HALT,
// the interrupts are triggered before the Halt state !!
// Fix Torpedo Range Intro.
// IFF |= 0x10 : 1 ticks before the EI enables the interrupts
// IFF |= 0x40 : marks that an EI is being executed.
IFF|=0x50;
break;
// FC illegal
// FC illegal (FC = breakpoint)
case 0xfc:
breakpoint = true;
break;
// FD illegal
case 0xfd:
PC.W--;
IFF = 0;
break;
case 0xfe:
// CP NN
tempValue=gbReadOpcode(PC.W++);
@ -1401,7 +1451,10 @@ case 0x38:
PC.W=0x0038;
break;
default:
systemMessage(0, N_("Unknown opcode %02x at %04x"),
gbReadOpcode(PC.W-1),PC.W-1);
emulating = false;
if (gbSystemMessage == false)
{
systemMessage(0, N_("Unknown opcode %02x at %04x"),
gbReadOpcode(PC.W-1),PC.W-1);
gbSystemMessage =true;
}
return;

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -1282,7 +1282,10 @@
AF.B.B1|=1<<7;
break;
default:
systemMessage(0, N_("Unknown opcode %02x at %04x"),
gbReadOpcode(PC.W-1),PC.W-1);
emulating = false;
if (gbSystemMessage == false)
{
systemMessage(0, N_("Unknown opcode %02x at %04x"),
gbReadOpcode(PC.W-1),PC.W-1);
gbSystemMessage =true;
}
return;

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 Forgotten and the VBA 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
@ -58,9 +58,12 @@ u8 gbInvertTab[256] = {
};
u16 gbLineMix[160];
u16 gbWindowColor[160];
extern int inUseRegister_WY;
void gbRenderLine()
{
memset(gbLineMix, 0, sizeof(gbLineMix));
u8 * bank0;
u8 * bank1;
if(gbCgbMode) {
@ -86,10 +89,9 @@ void gbRenderLine()
if(y >= 144)
return;
// int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip;
int sx = register_SCX;
int sy = register_SCY;
int SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4);
int sx = gbSCXLine[(gbSpeed ? 0 : 4)+SpritesTicks];
int sy = gbSCYLine[(gbSpeed ? 11 : 5)+SpritesTicks];
sy+=y;
@ -113,16 +115,17 @@ void gbRenderLine()
tile_map_address++;
if((register_LCDC & 16) == 0) {
if(tile < 128) tile += 128;
else tile -= 128;
}
if(!(register_LCDC & 0x10))
tile ^= 0x80;
int tile_pattern_address = tile_pattern + tile * 16 + by*2;
if(register_LCDC & 0x80) {
if((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100)) {
while(x < 160) {
u8 tile_a = 0;
u8 tile_b = 0;
@ -155,7 +158,7 @@ void gbRenderLine()
if(gbCgbMode) {
c = c + (attrs & 7)*4;
} else {
c = gbBgp[c];
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks]>>(c<<1)) &3;
if(gbSgbMode && !gbCgbMode) {
int dx = x >> 3;
int dy = y >> 3;
@ -168,42 +171,92 @@ void gbRenderLine()
c = c + 4*palette;
}
}
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c]] :
gbPalette[c];
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
gbPalette[c] & 0x7FFF;
x++;
if(x >= 160)
break;
bx >>= 1;
}
tx++;
if(tx == 32)
tx = 0;
bx = 128;
SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4);
sx = gbSCXLine[x+(gbSpeed ? 0 : 4)+SpritesTicks];
sy = gbSCYLine[x+(gbSpeed ? 11 : 5)+SpritesTicks];
tx = ((sx+x)>>3) & 0x1f;
sy+=y;
sy &= 255;
ty = sy >> 3;
by = sy & 7;
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
tile_map_line_y = tile_map + ty * 32;
tile_map_address = tile_map_line_y + tx;
if(bank1)
attrs = bank1[tile_map_line_y + tx];
tile = bank0[tile_map_line_y + tx];
if((register_LCDC & 16) == 0) {
if(tile < 128) tile += 128;
else tile -= 128;
}
if(!(register_LCDC & 0x10))
tile ^= 0x80;
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
}
} else {
for(int i = 0; i < 160; i++) {
gbLineMix[i] = gbPalette[0];
// Use gbBgp[0] instead of 0 (?)
// (this fixes white flashes on Last Bible II)
// Also added the gbColorOption (fixes Dracula Densetsu II color problems)
for(int i = 0; i < 160; i++)
{
u16 color = gbColorOption ? gbColorFilter[0x7FFF] :
0x7FFF;
if (!gbCgbMode)
color = gbColorOption ? gbColorFilter[gbPalette[gbBgpLine[i+(gbSpeed ? 5 : 11)+gbSpritesTicks[i]*(gbSpeed ? 2 : 4)]&3] & 0x7FFF] :
gbPalette[gbBgpLine[i+(gbSpeed ? 5 : 11)+gbSpritesTicks[i]*(gbSpeed ? 2 : 4)]&3] & 0x7FFF;
gbLineMix[i] = color;
gbLineBuffer[i] = 0;
}
}
// do the window display
if((register_LCDC & 0x20) && (layerSettings & 0x2000)) {
int wy = register_WY;
// LCDC.0 also enables/disables the window in !gbCgbMode ?!?!
// (tested on real hardware)
// This fixes Last Bible II & Zankurou Musouken
if((register_LCDC & 0x01 || gbCgbMode) && (register_LCDC & 0x20) &&
(layerSettings & 0x2000) && (gbWindowLine != -2)) {
int i = 0;
// Fix (accurate emulation) for most of the window display problems
// (ie. Zen - Intergalactic Ninja, Urusei Yatsura...).
if ((gbWindowLine == -1) || (gbWindowLine>144))
{
inUseRegister_WY = oldRegister_WY;
if (register_LY>oldRegister_WY)
gbWindowLine = 146;
// for (i = 0; i<160; i++)
// gbWindowColor[i] = gbLineMix[i];
}
int wy = inUseRegister_WY;
if(y >= wy) {
if(y >= inUseRegister_WY) {
if (gbWindowLine == -1)
gbWindowLine = 0;
int wx = register_WX;
int swx = 0;
wx -= 7;
if( wx <= 159 && gbWindowLine <= 143) {
@ -212,10 +265,7 @@ void gbRenderLine()
if((register_LCDC & 0x40) != 0)
tile_map = 0x1c00;
if(gbWindowLine == -1) {
gbWindowLine = 0;
}
tx = 0;
ty = gbWindowLine >> 3;
@ -223,6 +273,25 @@ void gbRenderLine()
bx = 128;
by = gbWindowLine & 7;
// Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7).
// Nothing close to perfect, but good enought for now...
if (wx == -7)
{
swx = 7-((gbSCXLine[0]-1) & 7);
bx >>= ((gbSCXLine[0]+((swx != 1) ? 1 : 0)) & 7);
if (swx == 1)
swx = 2;
//bx >>= ((gbSCXLine[0]+(((swx>1) && (swx != 7)) ? 1 : 0)) & 7);
if ((swx == 7))
{
//wx = 0;
if ((gbWindowLine>0) || (wy == 0))
swx = 0;
}
}
else
if(wx < 0) {
bx >>= (-wx);
wx = 0;
@ -247,6 +316,10 @@ void gbRenderLine()
tile_pattern_address = tile_pattern + tile * 16 + by*2;
if (wx)
for (i = 0; i<swx; i++)
gbLineMix[i] = gbWindowColor[i];
while(x < 160) {
u8 tile_a = 0;
u8 tile_b = 0;
@ -272,6 +345,8 @@ void gbRenderLine()
u8 c = (tile_a & bx) != 0 ? 1 : 0;
c += ((tile_b & bx) != 0 ? 2 : 0);
if (x>=0)
{
if(attrs & 0x80)
gbLineBuffer[x] = 0x300 + c;
else
@ -280,8 +355,8 @@ void gbRenderLine()
if(gbCgbMode) {
c = c + (attrs & 7) * 4;
} else {
c = gbBgp[c];
if(gbSgbMode && ! gbCgbMode) {
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)]>>(c<<1)) &3;
if(gbSgbMode && !gbCgbMode) {
int dx = x >> 3;
int dy = y >> 3;
@ -293,8 +368,9 @@ void gbRenderLine()
c = c + 4*palette;
}
}
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c]] :
gbPalette[c];
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
gbPalette[c] & 0x7FFF;
}
x++;
if(x >= 160)
break;
@ -314,13 +390,30 @@ void gbRenderLine()
}
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
}
//for (i = swx; i<160; i++)
// gbLineMix[i] = gbWindowColor[i];
gbWindowLine++;
}
}
}
else if (gbWindowLine == -2)
{
inUseRegister_WY = oldRegister_WY;
if (register_LY>oldRegister_WY)
gbWindowLine = 146;
else
gbWindowLine = 0;
}
} else {
for(int i = 0; i < 160; i++) {
gbLineMix[i] = gbPalette[0];
u16 color = gbColorOption ? gbColorFilter[0x7FFF] :
0x7FFF;
if (!gbCgbMode)
color = gbColorOption ? gbColorFilter[gbPalette[0] & 0x7FFF] :
gbPalette[0] & 0x7FFF;
for(int i = 0; i < 160; i++)
{
gbLineMix[i] = color;
gbLineBuffer[i] = 0;
}
}
@ -346,8 +439,11 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
int init = 0x0000;
// int yLine = (y+gbBorderRowSkip) * gbBorderLineSkip;
for (int i = 0; i<4; i++)
{
gbObp0[i] = (gbObp0Line[x+11+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)]>>(i<<1)) & 3;
gbObp1[i] = (gbObp1Line[x+11+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)]>>(i<<1)) & 3;
}
u8 *pal = gbObp0;
int flipx = (flags & 0x20);
@ -366,7 +462,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
int a = 0;
int b = 0;
if(gbCgbMode && flags & 0x08) {
if(gbCgbMode && (flags & 0x08)) {
a = bank1[address++];
b = bank1[address++];
} else {
@ -392,12 +488,14 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
continue;
u16 color = gbLineBuffer[xxx];
if(prio) {
// Fixes OAM-BG priority
if(prio && (register_LCDC & 1)) {
if(color < 0x200 && ((color & 0xFF) != 0))
continue;
}
if(color >= 0x300 && color != 0x300)
// Fixes OAM-BG priority for Moorhuhn 2
if(color >= 0x300 && color != 0x300 && (register_LCDC & 1))
continue;
else if(color >= 0x200 && color < 0x300) {
int sprite = color & 0xff;
@ -412,7 +510,9 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
if(sprite < spriteNumber)
continue;
} else {
if(spriteX < x+8)
// Fixes GB sprites priorities (was '< x + 8' before)
// ('A boy and his blob...' sprites' emulation is now correct)
if(spriteX < x)
continue;
}
}
@ -442,12 +542,12 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
}
}
gbLineMix[xxx] = gbColorOption ? gbColorFilter[gbPalette[c]] :
gbPalette[c];
gbLineMix[xxx] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
gbPalette[c] & 0x7FFF;
}
}
void gbDrawSprites()
void gbDrawSprites(bool draw)
{
int x = 0;
int y = 0;
@ -455,6 +555,9 @@ void gbDrawSprites()
int size = (register_LCDC & 4);
if (!draw)
memset (gbSpritesTicks, 0, sizeof(gbSpritesTicks));
if(!(register_LCDC & 0x80))
return;
@ -473,11 +576,19 @@ void gbDrawSprites()
if(x > 0 && y > 0 && x < 168 && y < 160) {
// check if sprite intersects current line
int t = yc -y + 16;
if(size && t >=0 && t < 16) {
gbDrawSpriteTile(tile,x-8,yc,t,flags,size,i);
count++;
} else if(!size && t >= 0 && t < 8) {
gbDrawSpriteTile(tile, x-8, yc, t, flags,size,i);
if((size && t >=0 && t < 16) || (!size && t >= 0 && t < 8)) {
if (draw)
gbDrawSpriteTile(tile,x-8,yc,t,flags,size,i);
else
{
for (int j = x-8; j<300; j++)
if (j>=0)
if (gbSpeed)
gbSpritesTicks[j] += 5;
else
gbSpritesTicks[j] += 2+(count&1);
}
count++;
}
}
@ -486,5 +597,5 @@ void gbDrawSprites()
break;
}
}
}
return;
}

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 Forgotten and the VBA 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
@ -24,6 +24,7 @@ int gbRomSizeMask = 0;
int gbRomSize = 0;
int gbRamSizeMask = 0;
int gbRamSize = 0;
int gbTAMA5ramSize = 0;
u8 *gbMemory = NULL;
u8 *gbVram = NULL;
@ -31,6 +32,7 @@ u8 *gbRom = NULL;
u8 *gbRam = NULL;
u8 *gbWram = NULL;
u16 *gbLineBuffer = NULL;
u8 *gbTAMA5ram = NULL;
u16 gbPalette[128];
u8 gbBgp[4] = { 0, 1, 2, 3};
@ -38,6 +40,7 @@ u8 gbObp0[4] = { 0, 1, 2, 3};
u8 gbObp1[4] = { 0, 1, 2, 3};
int gbWindowLine = -1;
bool genericflashcardEnable = false;
int gbCgbMode = 0;
u16 gbColorFilter[32768];

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 Forgotten and the VBA 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
@ -21,6 +21,11 @@ extern int gbRomSizeMask;
extern int gbRomSize;
extern int gbRamSize;
extern int gbRamSizeMask;
extern int gbTAMA5ramSize;
extern bool useBios;
extern bool skipBios;
extern u8 *bios;
extern u8 *gbRom;
extern u8 *gbRam;
@ -28,6 +33,7 @@ extern u8 *gbVram;
extern u8 *gbWram;
extern u8 *gbMemory;
extern u16 *gbLineBuffer;
extern u8 *gbTAMA5ram;
extern u8 *gbMemoryMap[16];
@ -46,6 +52,19 @@ extern u8 gbBgp[4];
extern u8 gbObp0[4];
extern u8 gbObp1[4];
extern u16 gbPalette[128];
extern bool gbScreenOn;
extern bool gbDrawWindow;
extern u8 gbSCYLine[300];
// gbSCXLine is used for the emulation (bug) of the SX change
// found in the Artic Zone game.
extern u8 gbSCXLine[300];
// gbBgpLine is used for the emulation of the
// Prehistorik Man's title screen scroller.
extern u8 gbBgpLine[300];
extern u8 gbObp0Line [300];
extern u8 gbObp1Line [300];
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
extern u8 gbSpritesTicks[300];
extern u8 register_LCDC;
extern u8 register_LY;
@ -54,8 +73,10 @@ extern u8 register_SCX;
extern u8 register_WY;
extern u8 register_WX;
extern u8 register_VBK;
extern u8 oldRegister_WY;
extern int emulating;
extern bool genericflashcardEnable;
extern int gbBorderLineSkip;
extern int gbBorderRowSkip;
@ -63,6 +84,6 @@ extern int gbBorderColumnSkip;
extern int gbDmaTicks;
extern void gbRenderLine();
extern void gbDrawSprites();
extern void gbDrawSprites(bool);
extern u8 (*gbSerialFunction)(u8);

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 Forgotten and the VBA 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
@ -20,6 +20,12 @@
#include "../Port.h"
#include "gbGlobals.h"
#include "gbMemory.h"
#include "GB.h"
u8 gbDaysinMonth [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const u8 gbDisabledRam [8] = {0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf};
extern int gbHardware;
extern int gbGBCColorType;
extern gbRegister PC;
mapperMBC1 gbDataMBC1 = {
0, // RAM enable
@ -27,7 +33,8 @@ mapperMBC1 gbDataMBC1 = {
0, // RAM bank
0, // memory model
0, // ROM high address
0 // RAM address
0, // RAM address
0 // Rom Bank 0 remapping
};
// MBC1 ROM write registers
@ -41,17 +48,25 @@ void mapperMBC1ROM(u16 address, u8 value)
break;
case 0x2000: // ROM bank select
// value = value & 0x1f;
if(value == 0)
value = 1;
if ((value == 1) && (address == 0x2100))
gbDataMBC1.mapperRomBank0Remapping = 1;
if((value & 0x1f) == 0)
value += 1;
if(value == gbDataMBC1.mapperROMBank)
break;
tmpAddress = value << 14;
// check current model
if (gbDataMBC1.mapperRomBank0Remapping == 3) {
tmpAddress = (value & 0xf) << 14;
tmpAddress |= (gbDataMBC1.mapperROMHighAddress & 3) << 18;
}
else
if(gbDataMBC1.mapperMemoryModel == 0) {
// model is 16/8, so we have a high address in use
tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19;
tmpAddress |= (gbDataMBC1.mapperROMHighAddress & 3) << 19;
}
tmpAddress &= gbRomSizeMask;
@ -63,16 +78,39 @@ void mapperMBC1ROM(u16 address, u8 value)
break;
case 0x4000: // RAM bank select
if(gbDataMBC1.mapperMemoryModel == 1) {
if (!gbRamSize)
{
if (gbDataMBC1.mapperRomBank0Remapping == 3)
{
gbDataMBC1.mapperROMHighAddress = value & 0x03;
tmpAddress = (gbDataMBC1.mapperROMHighAddress) << 18;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x00] = &gbRom[tmpAddress];
gbMemoryMap[0x01] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x02] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x03] = &gbRom[tmpAddress + 0x3000];
gbMemoryMap[0x04] = &gbRom[tmpAddress + 0x4000];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x5000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x6000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x7000];
}
else gbDataMBC1.mapperRomBank0Remapping = 0;
}
// 4/32 model, RAM bank switching provided
value = value & 0x03;
if(value == gbDataMBC1.mapperRAMBank)
break;
tmpAddress = value << 13;
tmpAddress &= gbRamSizeMask;
gbMemoryMap[0x0a] = &gbRam[tmpAddress];
gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
if(gbRamSize) {
gbMemoryMap[0x0a] = &gbRam[tmpAddress];
gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
}
gbDataMBC1.mapperRAMBank = value;
gbDataMBC1.mapperRAMAddress = tmpAddress;
if (gbDataMBC1.mapperRomBank0Remapping != 3)
gbDataMBC1.mapperROMHighAddress = 0;
} else {
// 16/8, set the high address
gbDataMBC1.mapperROMHighAddress = value & 0x03;
@ -83,10 +121,57 @@ void mapperMBC1ROM(u16 address, u8 value)
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
if(gbRamSize) {
gbMemoryMap[0x0a] = &gbRam[0];
gbMemoryMap[0x0b] = &gbRam[0x1000];
}
gbDataMBC1.mapperRAMBank = 0;
}
break;
case 0x6000: // memory model select
gbDataMBC1.mapperMemoryModel = value & 1;
if(gbDataMBC1.mapperMemoryModel == 1) {
// 4/32 model, RAM bank switching provided
value = gbDataMBC1.mapperRAMBank & 0x03;
tmpAddress = value << 13;
tmpAddress &= gbRamSizeMask;
if(gbRamSize) {
gbMemoryMap[0x0a] = &gbRam[gbDataMBC1.mapperRAMAddress];
gbMemoryMap[0x0b] = &gbRam[gbDataMBC1.mapperRAMAddress + 0x1000];
gbDataMBC1.mapperRomBank0Remapping = 0;
}
else gbDataMBC1.mapperRomBank0Remapping |=2;
gbDataMBC1.mapperRAMBank = value;
gbDataMBC1.mapperRAMAddress = tmpAddress;
tmpAddress = gbDataMBC1.mapperROMBank << 14;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
} else {
// 16/8, set the high address
tmpAddress = gbDataMBC1.mapperROMBank << 14;
tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
if(gbRamSize) {
gbMemoryMap[0x0a] = &gbRam[0];
gbMemoryMap[0x0b] = &gbRam[0x1000];
}
}
break;
}
}
@ -102,23 +187,72 @@ void mapperMBC1RAM(u16 address, u8 value)
}
}
// MBC1 read RAM
u8 mapperMBC1ReadRAM(u16 address)
{
if(gbDataMBC1.mapperRAMEnable)
return gbMemoryMap[address>>12][address & 0x0fff];
if (!genericflashcardEnable)
return 0xff;
else
if ((address & 0x1000) >= 0x1000)
{
// The value returned when reading RAM while it's disabled
// is constant, exept for the GBASP hardware.
// (actually, is the address that read is out of the ROM, the returned value if 0xff...)
if (PC.W>=0xff80)
return 0xff;
else
if ((gbHardware & 0x08) && (gbGBCColorType == 2))
{
if (address & 1)
return 0xfb;
else
return 0x7a;
}
else
return 0x0a;
}
else
return gbDisabledRam[address & 7];
}
void memoryUpdateMapMBC1()
{
int tmpAddress = gbDataMBC1.mapperROMBank << 14;
// check current model
if(gbDataMBC1.mapperMemoryModel == 1) {
// model is 16/8, so we have a high address in use
tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19;
if (gbDataMBC1.mapperRomBank0Remapping == 3) {
tmpAddress = (gbDataMBC1.mapperROMHighAddress & 3) << 18;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x00] = &gbRom[tmpAddress];
gbMemoryMap[0x01] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x02] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x03] = &gbRom[tmpAddress + 0x3000];
tmpAddress |= (gbDataMBC1.mapperROMBank & 0xf) << 14;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
}
else
{
if(gbDataMBC1.mapperMemoryModel == 0) {
// model is 16/8, so we have a high address in use
tmpAddress |= (gbDataMBC1.mapperROMHighAddress & 3) << 19;
}
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
}
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
if(gbRamSize) {
if((gbRamSize) && (gbDataMBC1.mapperMemoryModel == 1)){
gbMemoryMap[0x0a] = &gbRam[gbDataMBC1.mapperRAMAddress];
gbMemoryMap[0x0b] = &gbRam[gbDataMBC1.mapperRAMAddress + 0x1000];
}
@ -210,7 +344,7 @@ void memoryUpdateMBC3Clock()
time_t diff = now - gbDataMBC3.mapperLastTime;
if(diff > 0) {
// update the clock according to the last update time
gbDataMBC3.mapperSeconds += diff % 60;
gbDataMBC3.mapperSeconds += (int)(diff % 60);
if(gbDataMBC3.mapperSeconds > 59) {
gbDataMBC3.mapperSeconds -= 60;
gbDataMBC3.mapperMinutes++;
@ -218,22 +352,22 @@ void memoryUpdateMBC3Clock()
diff /= 60;
gbDataMBC3.mapperMinutes += diff % 60;
if(gbDataMBC3.mapperMinutes > 60) {
gbDataMBC3.mapperMinutes += (int)(diff % 60);
if(gbDataMBC3.mapperMinutes > 59) {
gbDataMBC3.mapperMinutes -= 60;
gbDataMBC3.mapperHours++;
}
diff /= 60;
gbDataMBC3.mapperHours += diff % 24;
if(gbDataMBC3.mapperHours > 24) {
gbDataMBC3.mapperHours += (int)(diff % 24);
if(gbDataMBC3.mapperHours > 23) {
gbDataMBC3.mapperHours -= 24;
gbDataMBC3.mapperDays++;
}
diff /= 24;
gbDataMBC3.mapperDays += diff;
gbDataMBC3.mapperDays += (int)(diff & 0xffffffff);
if(gbDataMBC3.mapperDays > 255) {
if(gbDataMBC3.mapperDays > 511) {
gbDataMBC3.mapperDays %= 512;
@ -365,7 +499,30 @@ u8 mapperMBC3ReadRAM(u16 address)
return gbDataMBC3.mapperLControl;
}
}
return 0;
if (!genericflashcardEnable)
return 0xff;
else
if ((address & 0x1000) >= 0x1000)
{
// The value returned when reading RAM while it's disabled
// is constant, exept for the GBASP hardware.
// (actually, is the address that read is out of the ROM, the returned value if 0xff...)
if (PC.W>=0xff80)
return 0xff;
else
if ((gbHardware & 0x08) && (gbGBCColorType == 2))
{
if (address & 1)
return 0xfb;
else
return 0x7a;
}
else
return 0x0a;
}
else
return gbDisabledRam[address & 7];
}
void memoryUpdateMapMBC3()
@ -406,6 +563,7 @@ void mapperMBC5ROM(u16 address, u8 value)
gbDataMBC5.mapperRAMEnable = ( ( value & 0x0a) == 0x0a ? 1 : 0);
break;
case 0x2000: // ROM bank select
if(address < 0x3000) {
value = value & 0xff;
if(value == gbDataMBC5.mapperROMBank)
@ -466,6 +624,38 @@ void mapperMBC5RAM(u16 address, u8 value)
}
}
// MBC5 read RAM
u8 mapperMBC5ReadRAM(u16 address)
{
if(gbDataMBC5.mapperRAMEnable)
return gbMemoryMap[address>>12][address & 0x0fff];
if (!genericflashcardEnable)
return 0xff;
else
if ((address & 0x1000) >= 0x1000)
{
// The value returned when reading RAM while it's disabled
// is constant, exept for the GBASP hardware.
// (actually, is the address that read is out of the ROM, the returned value if 0xff...)
if (PC.W>=0xff80)
return 0xff;
else
if ((gbHardware & 0x08) && (gbGBCColorType == 2))
{
if (address & 1)
return 0xfb;
else
return 0x7a;
}
else
return 0x0a;
}
else
return gbDisabledRam[address & 7];
}
void memoryUpdateMapMBC5()
{
int tmpAddress = (gbDataMBC5.mapperROMBank << 14) |
@ -568,7 +758,30 @@ u8 mapperMBC7ReadRAM(u16 address)
case 0xa080:
return gbDataMBC7.value;
}
return 0xff;
if (!genericflashcardEnable)
return 0xff;
else
if ((address & 0x1000) >= 0x1000)
{
// The value returned when reading RAM while it's disabled
// is constant, exept for the GBASP hardware.
// (actually, is the address that read is out of the ROM, the returned value if 0xff...)
if (PC.W>=0xff80)
return 0xff;
else
if ((gbHardware & 0x08) && (gbGBCColorType == 2))
{
if (address & 1)
return 0xfb;
else
return 0x7a;
}
else
return 0x0a;
}
else
return gbDisabledRam[address & 7];
}
// MBC7 RAM write
@ -717,7 +930,7 @@ void mapperMBC7RAM(u16 address, u8 value)
void memoryUpdateMapMBC7()
{
int tmpAddress = (gbDataMBC5.mapperROMBank << 14);
int tmpAddress = (gbDataMBC7.mapperROMBank << 14);
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
@ -965,3 +1178,540 @@ void memoryUpdateMapHuC3()
gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
}
}
// TAMA5 (for Tamagotchi 3 (gb)).
// Very basic (and ugly :p) support, only rom bank switching is actually working...
mapperTAMA5 gbDataTAMA5 = {
1, // RAM enable
1, // ROM bank
0, // RAM bank
0, // RAM address
0, // RAM Byte select
0, // mapper command number
0, // mapper last command;
0, // commands 0x0
0, // commands 0x1
0, // commands 0x2
0, // commands 0x3
0, // commands 0x4
0, // commands 0x5
0, // commands 0x6
0, // commands 0x7
0, // commands 0x8
0, // commands 0x9
0, // commands 0xa
0, // commands 0xb
0, // commands 0xc
0, // commands 0xd
0, // commands 0xe
0, // commands 0xf
0, // register
0, // timer clock latch
0, // timer clock register
0, // timer seconds
0, // timer minutes
0, // timer hours
0, // timer days
0, // timer months
0, // timer years
0, // timer control
0, // timer latched seconds
0, // timer latched minutes
0, // timer latched hours
0, // timer latched days
0, // timer latched months
0, // timer latched years
0, // timer latched control
(time_t)-1 // last time
};
void memoryUpdateTAMA5Clock()
{
if ((gbDataTAMA5.mapperYears & 3) == 0)
gbDaysinMonth[1] = 29;
else
gbDaysinMonth[1] = 28;
time_t now = time(NULL);
time_t diff = now - gbDataTAMA5.mapperLastTime;
if(diff > 0) {
// update the clock according to the last update time
gbDataTAMA5.mapperSeconds += (int)(diff % 60);
if(gbDataTAMA5.mapperSeconds > 59) {
gbDataTAMA5.mapperSeconds -= 60;
gbDataTAMA5.mapperMinutes++;
}
diff /= 60;
gbDataTAMA5.mapperMinutes += (int)(diff % 60);
if(gbDataTAMA5.mapperMinutes > 59) {
gbDataTAMA5.mapperMinutes -= 60;
gbDataTAMA5.mapperHours++;
}
diff /= 60;
gbDataTAMA5.mapperHours += (int)(diff % 24);
diff /= 24;
if(gbDataTAMA5.mapperHours > 23) {
gbDataTAMA5.mapperHours -= 24;
diff++;
}
time_t days = diff;
while (days)
{
gbDataTAMA5.mapperDays++;
days--;
if (gbDataTAMA5.mapperDays>gbDaysinMonth[gbDataTAMA5.mapperMonths-1])
{
gbDataTAMA5.mapperDays = 1;
gbDataTAMA5.mapperMonths++;
if (gbDataTAMA5.mapperMonths>12)
{
gbDataTAMA5.mapperMonths = 1;
gbDataTAMA5.mapperYears++;
if ((gbDataTAMA5.mapperYears & 3) == 0)
gbDaysinMonth[1] = 29;
else
gbDaysinMonth[1] = 28;
}
}
}
}
gbDataTAMA5.mapperLastTime = now;
}
// TAMA5 RAM write
void mapperTAMA5RAM(u16 address, u8 value)
{
if ((address & 0xffff) <= 0xa001)
{
switch (address & 1)
{
case 0: // 'Values' Register
{
value &= 0xf;
gbDataTAMA5.mapperCommands[gbDataTAMA5.mapperCommandNumber] = value;
gbMemoryMap[0xa][0] = value;
int test = gbDataTAMA5.mapperCommands[gbDataTAMA5.mapperCommandNumber & 0x0e] |
(gbDataTAMA5.mapperCommands[(gbDataTAMA5.mapperCommandNumber & 0x0e) +1]<<4);
if ((gbDataTAMA5.mapperCommandNumber & 0xe) == 0) // Read Command !!!
{
gbDataTAMA5.mapperROMBank = gbDataTAMA5.mapperCommands[0] |
(gbDataTAMA5.mapperCommands[1]<<4);
int tmpAddress = (gbDataTAMA5.mapperROMBank << 14);
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
gbDataTAMA5.mapperCommands[0x0f] = 0;
}
else if ((gbDataTAMA5.mapperCommandNumber & 0xe) == 4)
{
gbDataTAMA5.mapperCommands[0x0f] = 1;
if (gbDataTAMA5.mapperCommandNumber == 4)
gbDataTAMA5.mapperCommands[5] =0; // correct ?
}
else if ((gbDataTAMA5.mapperCommandNumber & 0xe) == 6)
{
gbDataTAMA5.mapperRamByteSelect = (gbDataTAMA5.mapperCommands[7]<<4) |
(gbDataTAMA5.mapperCommands[6]&0x0f);
// Write Commands !!!
if (gbDataTAMA5.mapperCommands[0x0f] && (gbDataTAMA5.mapperCommandNumber == 7))
{
int data = gbDataTAMA5.mapperCommands[0x04] & 0x0f |
(gbDataTAMA5.mapperCommands[0x05] <<4);
// Not sure when the write command should reset...
// but it doesn't seem to matter.
// gbDataTAMA5.mapperCommands[0x0f] = 0;
if (gbDataTAMA5.mapperRamByteSelect == 0x8) // Timer stuff
{
switch (data & 0xf)
{
case 0x7:
gbDataTAMA5.mapperDays = ((gbDataTAMA5.mapperDays)/10)*10 + (data >> 4);
break;
case 0x8:
gbDataTAMA5.mapperDays = (gbDataTAMA5.mapperDays%10) + (data >>4)*10;
break;
case 0x9:
gbDataTAMA5.mapperMonths = ((gbDataTAMA5.mapperMonths)/10)*10 + (data >> 4);
break;
case 0xa:
gbDataTAMA5.mapperMonths = (gbDataTAMA5.mapperMonths%10) + (data >>4)*10;
break;
case 0xb:
gbDataTAMA5.mapperYears = ((gbDataTAMA5.mapperYears)%1000) + (data >> 4)*1000;
break;
case 0xc:
gbDataTAMA5.mapperYears = (gbDataTAMA5.mapperYears%100) + (gbDataTAMA5.mapperYears/1000)*1000 +
(data >>4)*100;
break;
default :
break;
}
}
else if (gbDataTAMA5.mapperRamByteSelect == 0x18) // Timer stuff again
{
memoryUpdateTAMA5Clock();
gbDataTAMA5.mapperLSeconds = gbDataTAMA5.mapperSeconds;
gbDataTAMA5.mapperLMinutes = gbDataTAMA5.mapperMinutes;
gbDataTAMA5.mapperLHours = gbDataTAMA5.mapperHours;
gbDataTAMA5.mapperLDays = gbDataTAMA5.mapperDays;
gbDataTAMA5.mapperLMonths = gbDataTAMA5.mapperMonths;
gbDataTAMA5.mapperLYears = gbDataTAMA5.mapperYears;
gbDataTAMA5.mapperLControl = gbDataTAMA5.mapperControl;
int seconds = (gbDataTAMA5.mapperLSeconds / 10)*16 + gbDataTAMA5.mapperLSeconds %10;
int secondsL = (gbDataTAMA5.mapperLSeconds % 10);
int secondsH = (gbDataTAMA5.mapperLSeconds / 10);
int minutes = (gbDataTAMA5.mapperLMinutes / 10)*16 + gbDataTAMA5.mapperLMinutes %10;
int hours = (gbDataTAMA5.mapperLHours / 10)*16 + gbDataTAMA5.mapperLHours %10;
int DaysL = gbDataTAMA5.mapperLDays % 10;
int DaysH = gbDataTAMA5.mapperLDays /10;
int MonthsL = gbDataTAMA5.mapperLMonths % 10;
int MonthsH = gbDataTAMA5.mapperLMonths / 10;
int Years3 = (gbDataTAMA5.mapperLYears / 100) % 10;
int Years4 = (gbDataTAMA5.mapperLYears / 1000);
switch (data & 0x0f)
{
// I guess cases 0 and 1 are used for secondsL and secondsH
// so the game would update the timer values on screen when
// the seconds reset to 0... ?
case 0x0:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = secondsL;
break;
case 0x1:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = secondsH;
break;
case 0x7:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = DaysL; // days low
break;
case 0x8:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = DaysH; // days high
break;
case 0x9:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = MonthsL; // month low
break;
case 0xa:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = MonthsH; // month high
break;
case 0xb:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = Years4; // years 4th digit
break;
case 0xc:
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = Years3; // years 3rd digit
break;
default :
break;
}
gbTAMA5ram[0x54] = seconds; // incorrect ? (not used by the game) ?
gbTAMA5ram[0x64] = minutes;
gbTAMA5ram[0x74] = hours;
gbTAMA5ram[0x84] = DaysH*16+DaysL; // incorrect ? (not used by the game) ?
gbTAMA5ram[0x94] = MonthsH*16+MonthsL; // incorrect ? (not used by the game) ?
time(&gbDataTAMA5.mapperLastTime);
gbMemoryMap[0xa][0] = 1;
}
else if (gbDataTAMA5.mapperRamByteSelect == 0x28) // Timer stuff again
{
if ((data & 0xf) == 0xb)
gbDataTAMA5.mapperYears = ((gbDataTAMA5.mapperYears>>2)<<2) + (data & 3);
}
else if (gbDataTAMA5.mapperRamByteSelect == 0x44)
{
gbDataTAMA5.mapperMinutes = (data/16)*10 + data%16;
}
else if (gbDataTAMA5.mapperRamByteSelect == 0x54)
{
gbDataTAMA5.mapperHours = (data/16)*10 + data%16;
}
else
{
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = data;
}
}
}
}
break;
case 1: // 'Commands' Register
{
gbMemoryMap[0xa][1] = gbDataTAMA5.mapperCommandNumber = value;
// This should be only a 'is the flashrom ready ?' command.
// However as I couldn't find any 'copy' command
// (that seems to be needed for the saving system to work)
// I put it there...
if (value == 0x0a)
{
for (int i = 0; i<0x10; i++)
for (int j = 0; j<0x10; j++)
if (!(j&2))
gbTAMA5ram[(i*0x10)+j | 2] = gbTAMA5ram[(i*0x10)+j];
// 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;
}
else
{
if ((value & 0x0e) == 0x0c)
{
gbDataTAMA5.mapperRamByteSelect = gbDataTAMA5.mapperCommands[6] |
(gbDataTAMA5.mapperCommands[7]<<4);
u8 byte = gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect];
gbMemoryMap[0xa][0] = (value & 1) ? byte >> 4 : byte & 0x0f;
gbDataTAMA5.mapperCommands[0x0f] = 0;
}
}
break;
}
}
}
else
{
if(gbDataTAMA5.mapperRAMEnable) {
if(gbDataTAMA5.mapperRAMBank != -1) {
if(gbRamSize) {
gbMemoryMap[address>>12][address & 0x0fff] = value;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
}
}
}
}
}
// TAMA5 read RAM
u8 mapperTAMA5ReadRAM(u16 address)
{
return gbMemoryMap[address>>12][address & 0xfff];
}
void memoryUpdateMapTAMA5()
{
int tmpAddress = (gbDataTAMA5.mapperROMBank << 14);
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
if(gbRamSize) {
tmpAddress = 0 << 13;
tmpAddress &= gbRamSizeMask;
gbMemoryMap[0x0a] = &gbRam[tmpAddress];
gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
}
}
// MMM01 Used in Momotarou collection (however the rom is corrupted)
mapperMMM01 gbDataMMM01 ={
0, // RAM enable
1, // ROM bank
0, // RAM bank
0, // memory model
0, // ROM high address
0, // RAM address
0 // Rom Bank 0 remapping
};
// MMM01 ROM write registers
void mapperMMM01ROM(u16 address, u8 value)
{
int tmpAddress = 0;
switch(address & 0x6000) {
case 0x0000: // RAM enable register
gbDataMMM01.mapperRAMEnable = ( ( value & 0x0a) == 0x0a ? 1 : 0);
break;
case 0x2000: // ROM bank select
// value = value & 0x1f;
if(value == 0)
value = 1;
if(value == gbDataMMM01.mapperROMBank)
break;
tmpAddress = value << 14;
// check current model
if(gbDataMMM01.mapperMemoryModel == 0) {
// model is 16/8, so we have a high address in use
tmpAddress |= (gbDataMMM01.mapperROMHighAddress) << 19;
}
else
tmpAddress |= gbDataMMM01.mapperRomBank0Remapping << 18;
tmpAddress &= gbRomSizeMask;
gbDataMMM01.mapperROMBank = value;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
break;
case 0x4000: // RAM bank select
if(gbDataMMM01.mapperMemoryModel == 1) {
// 4/32 model, RAM bank switching provided
value = value & 0x03;
if(value == gbDataMBC1.mapperRAMBank)
break;
tmpAddress = value << 13;
tmpAddress &= gbRamSizeMask;
gbMemoryMap[0x0a] = &gbRam[tmpAddress];
gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000];
gbDataMMM01.mapperRAMBank = value;
gbDataMMM01.mapperRAMAddress = tmpAddress;
} else {
// 16/8, set the high address
gbDataMMM01.mapperROMHighAddress = value & 0x03;
tmpAddress = gbDataMMM01.mapperROMBank << 14;
tmpAddress |= (gbDataMMM01.mapperROMHighAddress) << 19;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
gbDataMMM01.mapperRomBank0Remapping = ((value<<1) | (value & 0x40 ? 1 : 0)) & 0xff;
tmpAddress = gbDataMMM01.mapperRomBank0Remapping << 18;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x00] = &gbRom[tmpAddress];
gbMemoryMap[0x01] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x02] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x03] = &gbRom[tmpAddress + 0x3000];
}
break;
case 0x6000: // memory model select
gbDataMMM01.mapperMemoryModel = value & 1;
break;
}
}
// MMM01 RAM write
void mapperMMM01RAM(u16 address, u8 value)
{
if(gbDataMMM01.mapperRAMEnable) {
if(gbRamSize) {
gbMemoryMap[address >> 12][address & 0x0fff] = value;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
}
}
}
void memoryUpdateMapMMM01()
{
int tmpAddress = gbDataMMM01.mapperROMBank << 14;
// check current model
if(gbDataMMM01.mapperMemoryModel == 1) {
// model is 16/8, so we have a high address in use
tmpAddress |= (gbDataMMM01.mapperROMHighAddress) << 19;
}
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
tmpAddress = gbDataMMM01.mapperRomBank0Remapping << 18;
tmpAddress &= gbRomSizeMask;
gbMemoryMap[0x00] = &gbRom[tmpAddress];
gbMemoryMap[0x01] = &gbRom[tmpAddress + 0x1000];
gbMemoryMap[0x02] = &gbRom[tmpAddress + 0x2000];
gbMemoryMap[0x03] = &gbRom[tmpAddress + 0x3000];
if(gbRamSize) {
gbMemoryMap[0x0a] = &gbRam[gbDataMMM01.mapperRAMAddress];
gbMemoryMap[0x0b] = &gbRam[gbDataMMM01.mapperRAMAddress + 0x1000];
}
}
// GameGenie ROM write registers
void mapperGGROM(u16 address, u8 value)
{
int tmpAddress = 0;
switch(address & 0x6000) {
case 0x0000: // RAM enable register
break;
case 0x2000: // GameGenie has only a half bank
break;
case 0x4000: // GameGenie has no RAM
if ((address >=0x4001) && (address <= 0x4020)) // GG Hardware Registers
gbMemoryMap[address >> 12][address & 0x0fff] = value;
break;
case 0x6000: // GameGenie has only a half bank
break;
}
}
// GS3 Used to emulate the GS V3.0 rom bank switching
mapperGS3 gbDataGS3 = { 1 }; // ROM bank
void mapperGS3ROM(u16 address, u8 value)
{
int tmpAddress = 0;
switch(address & 0x6000) {
case 0x0000: // GS has no ram
break;
case 0x2000: // GS has no 'classic' ROM bank select
break;
case 0x4000: // GS has no ram
break;
case 0x6000: // 0x6000 area is RW, and used for GS hardware registers
if (address == 0x7FE1) // This is the (half) ROM bank select register
{
if(value == gbDataGS3.mapperROMBank)
break;
tmpAddress = value << 13;
tmpAddress &= gbRomSizeMask;
gbDataGS3.mapperROMBank = value;
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
}
else
gbMemoryMap[address>>12][address & 0x0fff] = value;
break;
}
}
void memoryUpdateMapGS3()
{
int tmpAddress = gbDataGS3.mapperROMBank << 13;
tmpAddress &= gbRomSizeMask;
// GS can only change a half ROM bank
gbMemoryMap[0x04] = &gbRom[tmpAddress];
gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000];
}

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2004-2006 Forgotten and the VBA 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
@ -26,6 +26,7 @@ struct mapperMBC1 {
int mapperMemoryModel;
int mapperROMHighAddress;
int mapperRAMAddress;
int mapperRomBank0Remapping;
};
struct mapperMBC2 {
@ -106,15 +107,62 @@ struct mapperHuC3 {
int mapperRegister8;
};
struct mapperTAMA5 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int mapperRamByteSelect;
int mapperCommandNumber;
int mapperLastCommandNumber;
int mapperCommands[0x10];
int mapperRegister;
int mapperClockLatch;
int mapperClockRegister;
int mapperSeconds;
int mapperMinutes;
int mapperHours;
int mapperDays;
int mapperMonths;
int mapperYears;
int mapperControl;
int mapperLSeconds;
int mapperLMinutes;
int mapperLHours;
int mapperLDays;
int mapperLMonths;
int mapperLYears;
int mapperLControl;
time_t mapperLastTime;
};
struct mapperMMM01 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperMemoryModel;
int mapperROMHighAddress;
int mapperRAMAddress;
int mapperRomBank0Remapping;
};
struct mapperGS3 {
int mapperROMBank;
};
extern mapperMBC1 gbDataMBC1;
extern mapperMBC2 gbDataMBC2;
extern mapperMBC3 gbDataMBC3;
extern mapperMBC5 gbDataMBC5;
extern mapperHuC1 gbDataHuC1;
extern mapperHuC3 gbDataHuC3;
extern mapperTAMA5 gbDataTAMA5;
extern mapperMMM01 gbDataMMM01;
extern mapperGS3 gbDataGS3;
void mapperMBC1ROM(u16,u8);
void mapperMBC1RAM(u16,u8);
u8 mapperMBC1ReadRAM(u16);
void mapperMBC2ROM(u16,u8);
void mapperMBC2RAM(u16,u8);
void mapperMBC3ROM(u16,u8);
@ -122,6 +170,7 @@ void mapperMBC3RAM(u16,u8);
u8 mapperMBC3ReadRAM(u16);
void mapperMBC5ROM(u16,u8);
void mapperMBC5RAM(u16,u8);
u8 mapperMBC5ReadRAM(u16);
void mapperMBC7ROM(u16,u8);
void mapperMBC7RAM(u16,u8);
u8 mapperMBC7ReadRAM(u16);
@ -130,7 +179,13 @@ void mapperHuC1RAM(u16,u8);
void mapperHuC3ROM(u16,u8);
void mapperHuC3RAM(u16,u8);
u8 mapperHuC3ReadRAM(u16);
void mapperTAMA5RAM(u16,u8);
u8 mapperTAMA5ReadRAM(u16);
void memoryUpdateTAMA5Clock();
void mapperMMM01ROM(u16,u8);
void mapperMMM01RAM(u16,u8);
void mapperGGROM(u16,u8);
void mapperGS3ROM(u16,u8);
//extern void (*mapper)(u16,u8);
//extern void (*mapperRAM)(u16,u8);
//extern u8 (*mapperReadRAM)(u16);
@ -142,7 +197,9 @@ extern void memoryUpdateMapMBC5();
extern void memoryUpdateMapMBC7();
extern void memoryUpdateMapHuC1();
extern void memoryUpdateMapHuC3();
extern void memoryUpdateMapTAMA5();
extern void memoryUpdateMapMMM01();
extern void memoryUpdateMapGS3();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +1,59 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#define NR10 0xff10
#define NR11 0xff11
#define NR12 0xff12
#define NR13 0xff13
#define NR14 0xff14
#define NR21 0xff16
#define NR22 0xff17
#define NR23 0xff18
#define NR24 0xff19
#define NR30 0xff1a
#define NR31 0xff1b
#define NR32 0xff1c
#define NR33 0xff1d
#define NR34 0xff1e
#define NR41 0xff20
#define NR42 0xff21
#define NR43 0xff22
#define NR44 0xff23
#define NR50 0xff24
#define NR51 0xff25
#define NR52 0xff26
#define SOUND_EVENT(address,value) \
gbSoundEvent(address,value)
extern void gbSoundTick();
extern void gbSoundPause();
extern void gbSoundResume();
extern void gbSoundEnable(int);
extern void gbSoundDisable(int);
extern int gbSoundGetEnable();
extern void gbSoundReset();
extern void gbSoundSaveGame(gzFile);
extern void gbSoundReadGame(int,gzFile);
extern void gbSoundEvent(register u16, register int);
extern void gbSoundSetQuality(int);
extern u8 gbSoundRead(u16 address);
extern int soundTicks;
extern int soundQuality;
extern int SOUND_CLOCK_TICKS;
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#define NR10 0xff10
#define NR11 0xff11
#define NR12 0xff12
#define NR13 0xff13
#define NR14 0xff14
#define NR21 0xff16
#define NR22 0xff17
#define NR23 0xff18
#define NR24 0xff19
#define NR30 0xff1a
#define NR31 0xff1b
#define NR32 0xff1c
#define NR33 0xff1d
#define NR34 0xff1e
#define NR41 0xff20
#define NR42 0xff21
#define NR43 0xff22
#define NR44 0xff23
#define NR50 0xff24
#define NR51 0xff25
#define NR52 0xff26
#define SOUND_EVENT(address,value) \
gbSoundEvent(address,value)
extern void gbSoundTick();
extern void gbSoundPause();
extern void gbSoundResume();
extern void gbSoundEnable(int);
extern void gbSoundDisable(int);
extern int gbSoundGetEnable();
extern void gbSoundReset();
extern void gbSoundSaveGame(gzFile);
extern void gbSoundReadGame(int,gzFile);
extern void gbSoundEvent(register u16, register int);
extern void gbSoundSetQuality(int);
extern int soundTicks;
extern int soundQuality;
extern int SOUND_CLOCK_TICKS;

File diff suppressed because it is too large Load Diff

View File

@ -131,10 +131,7 @@ extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
extern int _getopt_internal ();
#endif /* __STDC__ */
#ifdef __cplusplus

View File

@ -1,180 +0,0 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
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. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "getopt.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

File diff suppressed because it is too large Load Diff

View File

@ -40,11 +40,6 @@
static unsigned interp_mask[2];
static unsigned interp_bits_per_pixel;
typedef unsigned short interp_uint16;
typedef unsigned int interp_uint32;
#define restrict
#define INTERP_16_MASK_1(v) (v & interp_mask[0])
#define INTERP_16_MASK_2(v) (v & interp_mask[1])

View File

@ -9,7 +9,7 @@
* Adapted from original gzio.c from zlib library by Forgotten
*/
/* @(#) $Id: memgzio.c,v 1.3 2004/01/17 23:07:32 kxu Exp $ */
/* @(#) $Id: memgzio.c,v 1.5 2006/06/06 21:04:20 spacy51 Exp $ */
#include <stdio.h>
#include <stdarg.h>
@ -125,7 +125,7 @@ local size_t memWrite(const void *buffer, size_t size, size_t count,
total = file->available;
}
memcpy(file->next, buffer, total);
file->available -= total;
file->available -= (int)total;
file->next += total;
return total;
}
@ -147,7 +147,7 @@ local size_t memRead(void *buffer, size_t size, size_t count,
total = file->available;
}
memcpy(buffer, file->next, total);
file->available -= total;
file->available -= (int)total;
file->next += total;
return total;
}
@ -170,7 +170,7 @@ local int memPutc(int c, MEMFILE *file)
local long memTell(MEMFILE *f)
{
return (f->next - f->memory) - 8;
return (long)(f->next - f->memory) - 8;
}
local int memError(MEMFILE *f)
@ -197,7 +197,7 @@ local int memPrintf(MEMFILE *f, const char *format, ...)
len = vsprintf(buffer, format, list);
va_end(list);
return memWrite(buffer, 1, len, f);
return (int)memWrite(buffer, 1, len, f);
}
/* ===========================================================================
@ -209,7 +209,10 @@ local int memPrintf(MEMFILE *f, const char *format, ...)
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR).
*/
local gzFile gz_open (char *memory, const int available, const char *mode)
local gzFile gz_open (memory, available, mode)
char *memory;
const int available;
const char *mode;
{
int err;
int level = Z_DEFAULT_COMPRESSION; /* compression level */
@ -309,7 +312,10 @@ local gzFile gz_open (char *memory, const int available, const char *mode)
/* ===========================================================================
Opens a gzip (.gz) file for reading or writing.
*/
gzFile ZEXPORT memgzopen (char *memory, int available, const char *mode)
gzFile ZEXPORT memgzopen (memory, available, mode)
char *memory;
int available;
const char *mode;
{
return gz_open (memory, available, mode);
}
@ -319,12 +325,13 @@ gzFile ZEXPORT memgzopen (char *memory, int available, const char *mode)
for end of file.
IN assertion: the stream s has been sucessfully opened for reading.
*/
local int get_byte(mem_stream *s)
local int get_byte(s)
mem_stream *s;
{
if (s->z_eof) return EOF;
if (s->stream.avail_in == 0) {
errno = 0;
s->stream.avail_in = memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
s->z_eof = 1;
if (memError(s->file)) s->z_err = Z_ERRNO;
@ -345,7 +352,8 @@ local int get_byte(mem_stream *s)
s->stream.avail_in is zero for the first time, but may be non-zero
for concatenated .gz files.
*/
local void check_header(mem_stream *s)
local void check_header(s)
mem_stream *s;
{
int method; /* method byte */
int flags; /* flags byte */
@ -397,7 +405,8 @@ local void check_header(mem_stream *s)
* Cleanup then free the given mem_stream. Return a zlib error code.
Try freeing in the reverse order of allocations.
*/
local int destroy (mem_stream *s)
local int destroy (s)
mem_stream *s;
{
int err = Z_OK;
@ -434,7 +443,10 @@ local int destroy (mem_stream *s)
Reads the given number of uncompressed bytes from the compressed file.
gzread returns the number of bytes actually read (0 for end of file).
*/
int ZEXPORT memgzread (gzFile file, voidp buf, unsigned len)
int ZEXPORT memgzread (file, buf, len)
gzFile file;
voidp buf;
unsigned len;
{
mem_stream *s = (mem_stream*)file;
Bytef *start = (Bytef*)buf; /* starting point for crc computation */
@ -464,8 +476,7 @@ int ZEXPORT memgzread (gzFile file, voidp buf, unsigned len)
s->stream.avail_in -= n;
}
if (s->stream.avail_out > 0) {
s->stream.avail_out -= memRead(next_out, 1, s->stream.avail_out,
s->file);
s->stream.avail_out -= (uInt)memRead(next_out, 1, s->stream.avail_out, s->file);
}
len -= s->stream.avail_out;
s->stream.total_in += (uLong)len;
@ -476,7 +487,7 @@ int ZEXPORT memgzread (gzFile file, voidp buf, unsigned len)
if (s->stream.avail_in == 0 && !s->z_eof) {
errno = 0;
s->stream.avail_in = memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
s->z_eof = 1;
if (memError(s->file)) {
@ -526,7 +537,10 @@ int ZEXPORT memgzread (gzFile file, voidp buf, unsigned len)
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of bytes actually written (0 in case of error).
*/
int ZEXPORT memgzwrite (gzFile file, const voidp buf, unsigned len)
int ZEXPORT memgzwrite (file, buf, len)
gzFile file;
const voidp buf;
unsigned len;
{
mem_stream *s = (mem_stream*)file;
@ -558,7 +572,9 @@ int ZEXPORT memgzwrite (gzFile file, const voidp buf, unsigned len)
Flushes all pending output into the compressed file. The parameter
flush is as in the deflate() function.
*/
local int do_flush (gzFile file, int flush)
local int do_flush (file, flush)
gzFile file;
int flush;
{
uInt len;
int done = 0;
@ -598,7 +614,9 @@ local int do_flush (gzFile file, int flush)
/* ===========================================================================
Outputs a long in LSB order to the given file
*/
local void putLong (MEMFILE *file, uLong x)
local void putLong (file, x)
MEMFILE *file;
uLong x;
{
int n;
for (n = 0; n < 4; n++) {
@ -611,7 +629,8 @@ local void putLong (MEMFILE *file, uLong x)
Reads a long in LSB order from the given mem_stream. Sets z_err in case
of error.
*/
local uLong getLong (mem_stream *s)
local uLong getLong (s)
mem_stream *s;
{
uLong x = (uLong)get_byte(s);
int c;
@ -628,7 +647,8 @@ local uLong getLong (mem_stream *s)
Flushes all pending output if necessary, closes the compressed file
and deallocates all the (de)compression state.
*/
int ZEXPORT memgzclose (gzFile file)
int ZEXPORT memgzclose (file)
gzFile file;
{
int err;
mem_stream *s = (mem_stream*)file;
@ -649,7 +669,8 @@ int ZEXPORT memgzclose (gzFile file)
return destroy((mem_stream*)file);
}
long ZEXPORT memtell(gzFile file)
long ZEXPORT memtell(file)
gzFile file;
{
mem_stream *s = (mem_stream*)file;

View File

@ -8,7 +8,12 @@
/* memgzio.c - IO on .gz files in memory
* Adapted from original gzio.c from zlib library by Forgotten
*/
#include <zutil.h>
#if defined(HAVE_ZUTIL_H) || defined(_WIN32)
# include <zutil.h>
#else
# include "../win32/dependencies/zlib/zutil.h"
#endif
gzFile ZEXPORT memgzopen(char *memory, int, const char *);
int ZEXPORT memgzread(gzFile, voidp, unsigned);

View File

@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
#ifndef WIN32
#ifndef _WIN32
# include <unistd.h>
# include <sys/socket.h>
# include <netdb.h>
@ -32,14 +32,15 @@
# else // ! HAVE_ARPA_INET_H
# define socklen_t int
# endif // ! HAVE_ARPA_INET_H
#else // WIN32
# define SOCKET int
#else // _WIN32
# include <winsock.h>
# include <io.h>
# define socklen_t int
# define close closesocket
# define read _read
# define write _write
#endif // WIN32
#endif // _WIN32
#include "GBA.h"
@ -54,8 +55,8 @@ extern void debuggerSignal(int,int);
int remotePort = 55555;
int remoteSignal = 5;
int remoteSocket = -1;
int remoteListenSocket = -1;
SOCKET remoteSocket = -1;
SOCKET remoteListenSocket = -1;
bool remoteConnected = false;
bool remoteResumed = false;
@ -85,11 +86,11 @@ int remoteTcpRecv(char *data, int len)
bool remoteTcpInit()
{
if(remoteSocket == -1) {
#ifdef WIN32
#ifdef _WIN32
WSADATA wsaData;
int error = WSAStartup(MAKEWORD(1,1),&wsaData);
#endif // WIN32
int s = socket(PF_INET, SOCK_STREAM, 0);
#endif // _WIN32
SOCKET s = socket(PF_INET, SOCK_STREAM, 0);
remoteListenSocket = s;
@ -131,19 +132,19 @@ bool remoteTcpInit()
}
socklen_t len = sizeof(addr);
#ifdef WIN32
#ifdef _WIN32
int flag = 0;
ioctlsocket(s, FIONBIO, (unsigned long *)&flag);
#endif // WIN32
int s2 = accept(s, (sockaddr *)&addr, &len);
#endif // _WIN32
SOCKET s2 = accept(s, (sockaddr *)&addr, &len);
if(s2 > 0) {
fprintf(stderr, "Got a connection from %s %d\n",
inet_ntoa((in_addr)addr.sin_addr),
ntohs(addr.sin_port));
} else {
#ifdef WIN32
#ifdef _WIN32
int error = WSAGetLastError();
#endif // WIN32
#endif // _WIN32
}
char dummy;
recv(s2, &dummy, 1, 0);
@ -230,14 +231,14 @@ void remotePutPacket(char *packet)
char *hex = "0123456789abcdef";
char buffer[1024];
int count = strlen(packet);
size_t count = strlen(packet);
unsigned char csum = 0;
char *p = buffer;
*p++ = '$';
for(int i = 0 ;i < count; i++) {
for(size_t i = 0 ;i < count; i++) {
csum += packet[i];
*p++ = packet[i];
}
@ -246,7 +247,7 @@ void remotePutPacket(char *packet)
*p++ = hex[csum & 15];
*p++ = 0;
// printf("Sending %s\n", buffer);
remoteSendFnc(buffer, count + 4);
remoteSendFnc(buffer, (int)count + 4);
char c = 0;
remoteRecvFnc(&c, 1);

File diff suppressed because it is too large Load Diff

View File

@ -154,7 +154,7 @@ typedef struct
local int unzlocal_getByte(FILE *fin,int *pi)
{
unsigned char c;
int err = fread(&c, 1, 1, fin);
size_t err = fread(&c, 1, 1, fin);
if (err==1)
{
*pi = (int)c;

View File

@ -19,8 +19,9 @@
// AboutDialog.cpp : implementation file
//
#include "stdafx.h"
#include "AboutDialog.h"
#include "..\..\res\resource.h"
#include "../AutoBuild.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -63,15 +64,13 @@ BOOL AboutDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL);
if(p) {
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
}
m_link.SetWindowText("http://vba.ngemu.com");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AboutDialog::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}

View File

@ -27,7 +27,7 @@
//
#include "stdafx.h"
#include "Hyperlink.h"
#include "..\..\res\resource.h"
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// AboutDialog dialog
@ -60,7 +60,6 @@ class AboutDialog : public CDialog
// Generated message map functions
//{{AFX_MSG(AboutDialog)
virtual BOOL OnInitDialog();
virtual void OnOK();
//}}AFX_MSG

View File

@ -156,7 +156,7 @@ void AccelEditor::OnSelchangeCommands()
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
// and a pointer to the accel object.
m_currents.SetItemData(index, (DWORD)pAccel);
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
}
}
// Init the key editor
@ -180,12 +180,12 @@ void AccelEditor::OnAssign()
WORD wKey;
bool bCtrl, bAlt, bShift;
int index;
if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
return; // no valid key, abort
int count = m_commands.GetCount();
int index;
for (index = 0; index < count; index++) {
wIDCommand = LOWORD(m_commands.GetItemData(index));
@ -235,7 +235,7 @@ void AccelEditor::OnAssign()
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
m_currents.SetItemData(index, (DWORD)pAccel);
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
// Reset the key editor.
m_key.ResetKey();

View File

@ -27,7 +27,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//#include "..\..\res\resource.h"
//#include "resource.h"
#include "../System.h"
#include "AcceleratorManager.h"
@ -247,7 +247,7 @@ bool CAcceleratorManager::UpdateWndTable()
}
}
int nAccel = arrayACCEL.GetSize();
INT_PTR nAccel = arrayACCEL.GetSize();
LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
if (!lpAccel) {
for (iLoop = 0; iLoop < nAccel; iLoop++)
@ -268,7 +268,7 @@ bool CAcceleratorManager::UpdateWndTable()
}
arrayACCEL.RemoveAll();
HACCEL hNewTable = CreateAcceleratorTable(lpAccel, nAccel);
HACCEL hNewTable = CreateAcceleratorTable(lpAccel, (int)nAccel);
if (!hNewTable) {
::LocalFree(lpAccel);
return false;
@ -709,14 +709,14 @@ bool CAcceleratorManager::Write()
}
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
int count = AccelsDatasArray.GetSize();
INT_PTR count = AccelsDatasArray.GetSize();
DWORD *data = (DWORD *)malloc(count * sizeof(DWORD));
ASSERT(data != NULL);
for(int index = 0; index < count; index++)
data[index] = AccelsDatasArray[index];
regSetBinaryValue("keyboard", (char *)data, count*sizeof(DWORD));
regSetBinaryValue("keyboard", (char *)data, (int)(count*sizeof(DWORD)));
AccelsDatasArray.RemoveAll();
CmdDatasArray.RemoveAll();

View File

@ -33,6 +33,7 @@
#endif // _MSC_VER >= 1000
#include "CmdAccelOb.h"

View File

@ -20,7 +20,7 @@
#if !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_)
#define AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -24,6 +24,7 @@
#include "BugReport.h"
#include "../agbprint.h"
#include "../AutoBuild.h"
#include "../GBA.h"
#include "../Globals.h"
#include "../Port.h"
@ -215,7 +216,6 @@ CString BugReport::createReport()
AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile);
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
AppendFormat(report, "Skip intro : %d\r\n", theApp.removeIntros);
AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
@ -226,6 +226,7 @@ CString BugReport::createReport()
AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
AppendFormat(report, "Save type : %d (%d)\r\n",
theApp.winSaveType, cpuSaveType);
AppendFormat(report, "Flash size : %08X (%08x)\r\n",

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
#if !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_)
#define AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

View File

@ -20,7 +20,7 @@
#if !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_)
#define AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

View File

@ -1,253 +1,258 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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 "stdafx.h"
#include "AcceleratorManager.h"
#include "..\..\res\resource.h"
#include <afxres.h>
#include <afxtempl.h> // MFC Templates extension
#ifndef CMapStringToWord
typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord;
#endif
static CMapStringToWord winAccelStrings;
static bool initialized = false;
struct {
const char *command;
WORD id;
} winAccelCommands[] = {
{ "FileOpen", ID_FILE_OPEN },
{ "FileOpenGameboy", ID_FILE_OPENGAMEBOY },
{ "FileLoad", ID_FILE_LOAD },
{ "FileSave", ID_FILE_SAVE },
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
{ "FileRecentReset", ID_FILE_RECENT_RESET },
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
{ "FileRecent01", ID_FILE_MRU_FILE1 },
{ "FileRecent02", ID_FILE_MRU_FILE2 },
{ "FileRecent03", ID_FILE_MRU_FILE3 },
{ "FileRecent04", ID_FILE_MRU_FILE4 },
{ "FileRecent05", ID_FILE_MRU_FILE5 },
{ "FileRecent06", ID_FILE_MRU_FILE6 },
{ "FileRecent07", ID_FILE_MRU_FILE7 },
{ "FileRecent08", ID_FILE_MRU_FILE8 },
{ "FileRecent09", ID_FILE_MRU_FILE9 },
{ "FileRecent10", ID_FILE_MRU_FILE10 },
{ "FilePause", ID_FILE_PAUSE },
{ "FileReset", ID_FILE_RESET },
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
{ "FileImportGamesharkSnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
{ "FileToggleMenu", ID_FILE_TOGGLEMENU },
{ "FileClose", ID_FILE_CLOSE },
{ "FileExit", ID_FILE_EXIT },
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
{ "OptionsVideoRenderGDI", ID_OPTIONS_VIDEO_RENDERMETHOD_GDI },
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
{ "OptionsVideoLayersBg0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
{ "OptionsVideoLayersBg1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
{ "OptionsVideoLayersBg2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
{ "OptionsVideoLayersBg3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
{ "OptionsEmulatorSelectBIOS", ID_OPTIONS_EMULATOR_SELECTBIOSFILE },
{ "OptionsEmulatorUseBIOS", ID_OPTIONS_EMULATOR_USEBIOSFILE },
{ "OptionsEmulatorSkipBIOS", ID_OPTIONS_EMULATOR_SKIPBIOS },
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
{ "OptionsEmulatorRemoveIntros", ID_OPTIONS_EMULATOR_REMOVEINTROSGBA },
{ "OptionsEmulatorAutoHideMenu", ID_OPTIONS_EMULATOR_AUTOHIDEMENU },
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorAutoIPSPatch", ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
{ "OptionsSoundOff", ID_OPTIONS_SOUND_OFF },
{ "OptionsSoundMute", ID_OPTIONS_SOUND_OFF }, /* mute hax */
{ "OptionsSoundOn", ID_OPTIONS_SOUND_ON },
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
{ "OptionsSound11Khz", ID_OPTIONS_SOUND_11KHZ },
{ "OptionsSound22Khz", ID_OPTIONS_SOUND_22KHZ },
{ "OptionsSound44Khz", ID_OPTIONS_SOUND_44KHZ },
{ "OptionsSoundEcho", ID_OPTIONS_SOUND_ECHO },
{ "OptionsSoundLowPassFilter", ID_OPTIONS_SOUND_LOWPASSFILTER },
{ "OptionsSoundReverseStereo", ID_OPTIONS_SOUND_REVERSESTEREO },
{ "OptionsSoundVolume1x", ID_OPTIONS_SOUND_VOLUME_1X },
{ "OptionsSoundVolume2x", ID_OPTIONS_SOUND_VOLUME_2X },
{ "OptionsSoundVolume3x", ID_OPTIONS_SOUND_VOLUME_3X },
{ "OptionsSoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
{ "CheatsList", ID_CHEATS_CHEATLIST },
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
{ "ToolsDebugGDBLoad", ID_TOOLS_DEBUG_LOADANDWAIT },
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
{ "ToolsLogging", ID_TOOLS_LOGGING },
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
{ "ToolsRewind", ID_TOOLS_REWIND },
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
{ "HelpBugReport", ID_HELP_BUGREPORT },
{ "HelpFAQ", ID_HELP_FAQ },
{ "HelpAbout", ID_HELP_ABOUT }
};
bool winAccelGetID(const char *command, WORD& id)
{
if(!initialized) {
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) {
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
}
initialized = true;
}
return winAccelStrings.Lookup(command, id) ? true : false;
}
void winAccelAddCommands(CAcceleratorManager& mgr)
{
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) {
if(!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
}
}
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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 "stdafx.h"
#include "AcceleratorManager.h"
#include "resource.h"
#include <afxres.h>
#include <afxtempl.h> // MFC Templates extension
#ifndef CMapStringToWord
typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord;
#endif
static CMapStringToWord winAccelStrings;
static bool initialized = false;
struct {
const char *command;
WORD id;
} winAccelCommands[] = {
{ "FileOpen", ID_FILE_OPEN },
{ "FileOpenGameboy", ID_FILE_OPENGAMEBOY },
{ "FileLoad", ID_FILE_LOAD },
{ "FileSave", ID_FILE_SAVE },
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
{ "FileRecentReset", ID_FILE_RECENT_RESET },
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
{ "FileRecent01", ID_FILE_MRU_FILE1 },
{ "FileRecent02", ID_FILE_MRU_FILE2 },
{ "FileRecent03", ID_FILE_MRU_FILE3 },
{ "FileRecent04", ID_FILE_MRU_FILE4 },
{ "FileRecent05", ID_FILE_MRU_FILE5 },
{ "FileRecent06", ID_FILE_MRU_FILE6 },
{ "FileRecent07", ID_FILE_MRU_FILE7 },
{ "FileRecent08", ID_FILE_MRU_FILE8 },
{ "FileRecent09", ID_FILE_MRU_FILE9 },
{ "FileRecent10", ID_FILE_MRU_FILE10 },
{ "FilePause", ID_FILE_PAUSE },
{ "FileReset", ID_FILE_RESET },
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
{ "FileImportGamesharkSnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
{ "FileToggleMenu", ID_FILE_TOGGLEMENU },
{ "FileClose", ID_FILE_CLOSE },
{ "FileExit", ID_FILE_EXIT },
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
{ "OptionsVideoRenderGDI", ID_OPTIONS_VIDEO_RENDERMETHOD_GDI },
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
{ "OptionsVideoRenderSelectSkin", ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN },
{ "OptionsVideoRenderSkin", ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN },
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
{ "OptionsVideoLayersBg0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
{ "OptionsVideoLayersBg1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
{ "OptionsVideoLayersBg2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
{ "OptionsVideoLayersBg3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
{ "OptionsEmulatorSelectBIOS", ID_OPTIONS_EMULATOR_SELECTBIOSFILE },
{ "OptionsEmulatorUseBIOS", ID_OPTIONS_EMULATOR_USEBIOSFILE },
{ "OptionsEmulatorGameOverrides", ID_OPTIONS_EMULATOR_GAMEOVERRIDES },
{ "OptionsEmulatorSkipBIOS", ID_OPTIONS_EMULATOR_SKIPBIOS },
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
{ "OptionsEmulatorAutoHideMenu", ID_OPTIONS_EMULATOR_AUTOHIDEMENU },
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorAutoIPSPatch", ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
{ "OptionsEmulatorGenericflashcard", ID_OPTIONS_EMULATOR_GENERICFLASHCARD },
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
{ "OptionsSoundOff", ID_OPTIONS_SOUND_OFF },
{ "OptionsSoundMute", ID_OPTIONS_SOUND_MUTE },
{ "OptionsSoundOn", ID_OPTIONS_SOUND_ON },
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
{ "OptionsSound11Khz", ID_OPTIONS_SOUND_11KHZ },
{ "OptionsSound22Khz", ID_OPTIONS_SOUND_22KHZ },
{ "OptionsSound44Khz", ID_OPTIONS_SOUND_44KHZ },
{ "OptionsSoundEcho", ID_OPTIONS_SOUND_ECHO },
{ "OptionsSoundLowPassFilter", ID_OPTIONS_SOUND_LOWPASSFILTER },
{ "OptionsSoundReverseStereo", ID_OPTIONS_SOUND_REVERSESTEREO },
{ "OptionsSoundVolume1x", ID_OPTIONS_SOUND_VOLUME_1X },
{ "OptionsSoundVolume2x", ID_OPTIONS_SOUND_VOLUME_2X },
{ "OptionsSoundVolume3x", ID_OPTIONS_SOUND_VOLUME_3X },
{ "OptionsSoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
{ "OptionsFilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL },
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
{ "CheatsList", ID_CHEATS_CHEATLIST },
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
{ "ToolsDebugGDBLoad", ID_TOOLS_DEBUG_LOADANDWAIT },
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
{ "ToolsLogging", ID_TOOLS_LOGGING },
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
{ "ToolsRewind", ID_TOOLS_REWIND },
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
{ "HelpBugReport", ID_HELP_BUGREPORT },
{ "HelpFAQ", ID_HELP_FAQ },
{ "HelpAbout", ID_HELP_ABOUT },
{ "SystemMinimize", ID_SYSTEM_MINIMIZE }
};
bool winAccelGetID(const char *command, WORD& id)
{
if(!initialized) {
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) {
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
}
initialized = true;
}
return winAccelStrings.Lookup(command, id) ? true : false;
}
void winAccelAddCommands(CAcceleratorManager& mgr)
{
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) {
if(!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,6 @@
#define DIRECTDRAW_VERSION 0x0700
#include <ddraw.h>
#include <mmsystem.h>
#include "../System.h"
#include "../gb/gbGlobals.h"
#include "../GBA.h"
@ -33,7 +31,9 @@
#include "VBA.h"
#include "MainWnd.h"
#include "Reg.h"
#include "..\..\res\resource.h"
#include "resource.h"
#include "Display.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -58,18 +58,7 @@ private:
int height;
bool failed;
volatile unsigned wait_lastscanline;
volatile unsigned wait_screenheight;
volatile unsigned wait_maxheight;
volatile unsigned wait_firstline;
HANDLE wait_event;
UINT wait_timerres;
UINT wait_timerid;
bool initializeOffscreen(int w, int h);
bool StartTimer();
void StopTimer();
static void CALLBACK g_timer_proc( UINT id, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2 );
public:
DirectDrawDisplay();
virtual ~DirectDrawDisplay();
@ -83,9 +72,8 @@ public:
virtual bool changeRenderSize(int w, int h);
virtual DISPLAY_TYPE getType() { return DIRECT_DRAW; };
virtual void setOption(const char *, int) {}
virtual bool isSkinSupported() { return true; }
virtual int selectFullScreenMode(GUID **);
void timer_proc( UINT id, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2 );
};
static HRESULT WINAPI checkModesAvailable(LPDDSURFACEDESC2 surf, LPVOID lpContext)
@ -144,10 +132,6 @@ DirectDrawDisplay::DirectDrawDisplay()
width = 0;
height = 0;
failed = false;
wait_screenheight = 0;
wait_event = 0;
wait_timerres = 0;
wait_timerid = 0;
}
DirectDrawDisplay::~DirectDrawDisplay()
@ -158,15 +142,6 @@ DirectDrawDisplay::~DirectDrawDisplay()
void DirectDrawDisplay::cleanup()
{
if(pDirectDraw != NULL) {
if ( wait_timerid ) {
StopTimer();
}
if ( wait_event ) {
CloseHandle( wait_event );
wait_event = 0;
}
if(ddsClipper != NULL) {
ddsClipper->Release();
ddsClipper = NULL;
@ -192,7 +167,11 @@ void DirectDrawDisplay::cleanup()
}
if(ddrawDLL != NULL) {
FreeLibrary(ddrawDLL);
#ifdef _AFXDLL
AfxFreeLibrary( ddrawDLL );
#else
FreeLibrary( ddrawDLL );
#endif
ddrawDLL = NULL;
}
width = 0;
@ -228,13 +207,13 @@ bool DirectDrawDisplay::initialize()
case VIDEO_1280x1024:
case VIDEO_OTHER:
{
float scaleX = ((float)theApp.fsWidth / (float)theApp.sizeX);
float scaleY = ((float)theApp.fsHeight / (float)theApp.sizeY);
float min = scaleX < scaleY ? scaleX : scaleY;
int scaleX = (theApp.fsWidth / theApp.sizeX);
int scaleY = (theApp.fsHeight / theApp.sizeY);
int min = scaleX < scaleY ? scaleX : scaleY;
if(theApp.fsMaxScale)
min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min;
theApp.surfaceSizeX = (int)(theApp.sizeX * min);
theApp.surfaceSizeY = (int)(theApp.sizeY * min);
theApp.surfaceSizeX = theApp.sizeX * min;
theApp.surfaceSizeY = theApp.sizeY * min;
if(theApp.fullScreenStretch) {
theApp.surfaceSizeX = theApp.fsWidth;
theApp.surfaceSizeY = theApp.fsHeight;
@ -242,7 +221,7 @@ bool DirectDrawDisplay::initialize()
}
break;
}
theApp.rect.left = 0;
theApp.rect.top = 0;
theApp.rect.right = theApp.sizeX;
@ -306,7 +285,12 @@ bool DirectDrawDisplay::initialize()
if(theApp.pVideoDriverGUID)
guid = theApp.pVideoDriverGUID;
ddrawDLL = LoadLibrary("DDRAW.DLL");
#ifdef _AFXDLL
ddrawDLL = AfxLoadLibrary("ddraw.dll");
#else
ddrawDLL = LoadLibrary( _T("ddraw.dll") );
#endif
HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *);
if(ddrawDLL != NULL) {
DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *))
@ -459,12 +443,6 @@ bool DirectDrawDisplay::initialize()
}
// }
wait_event = CreateEvent( NULL, FALSE, FALSE, NULL );
if ( ! StartTimer() ) {
return FALSE;
}
DDPIXELFORMAT px;
px.dwSize = sizeof(px);
@ -633,7 +611,7 @@ bool DirectDrawDisplay::initializeOffscreen(int w, int h)
winlog("B shift: %d\n", systemBlueShift);
}
utilUpdateSystemColorMaps(theApp.filterLCD);
utilUpdateSystemColorMaps();
width = w;
height = h;
return true;
@ -671,6 +649,7 @@ void DirectDrawDisplay::checkFullScreen()
void DirectDrawDisplay::render()
{
HRESULT hret;
unsigned int nBytesPerPixel = systemColorDepth>>3;
if(pDirectDraw == NULL ||
ddsOffscreen == NULL ||
@ -743,62 +722,9 @@ void DirectDrawDisplay::render()
copyY = 144;
}
}
// MMX doesn't seem to be faster to copy the data
__asm {
mov eax, copyX;
mov ebx, copyY;
mov esi, pix;
mov edi, ddsDesc.lpSurface;
mov edx, ddsDesc.lPitch;
cmp systemColorDepth, 16;
jnz gbaOtherColor;
sub edx, eax;
sub edx, eax;
lea esi,[esi+2*eax+4];
shr eax, 1;
gbaLoop16bit:
mov ecx, eax;
repz movsd;
inc esi;
inc esi;
inc esi;
inc esi;
add edi, edx;
dec ebx;
jnz gbaLoop16bit;
jmp gbaLoopEnd;
gbaOtherColor:
cmp systemColorDepth, 32;
jnz gbaOtherColor2;
sub edx, eax;
sub edx, eax;
sub edx, eax;
sub edx, eax;
lea esi, [esi+4*eax+4];
gbaLoop32bit:
mov ecx, eax;
repz movsd;
add esi, 4;
add edi, edx;
dec ebx;
jnz gbaLoop32bit;
jmp gbaLoopEnd;
gbaOtherColor2:
lea eax, [eax+2*eax];
sub edx, eax;
gbaLoop24bit:
mov ecx, eax;
shr ecx, 2;
repz movsd;
add edi, edx;
dec ebx;
jnz gbaLoop24bit;
gbaLoopEnd:
}
copyImage( pix, ddsDesc.lpSurface, copyX, copyY, ddsDesc.lPitch, systemColorDepth );
}
if(theApp.showSpeed && theApp.videoOption > VIDEO_4X) {
if(theApp.showSpeed && (theApp.videoOption > VIDEO_4X || theApp.skin != NULL)) {
char buffer[30];
if(theApp.showSpeed == 1)
sprintf(buffer, "%3d%%", systemSpeed);
@ -826,8 +752,7 @@ void DirectDrawDisplay::render()
if(hret == DD_OK) {
if(theApp.vsync && !(theApp.tripleBuffering && theApp.videoOption > VIDEO_4X) && !speedup) { // isn't the Flip() call synced unless a certain flag is passed to it?
//hret = pDirectDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
WaitForSingleObject( wait_event, 100 );
hret = pDirectDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
}
ddsOffscreen->PageLock(0);
if(theApp.tripleBuffering && theApp.videoOption > VIDEO_4X) {
@ -865,7 +790,7 @@ void DirectDrawDisplay::render()
SetTextColor(hdc, RGB(255,0,0));
SetBkMode(hdc,TRANSPARENT);
TextOut(hdc, theApp.dest.left+10, theApp.dest.bottom - 20, theApp.screenMessageBuffer,
strlen(theApp.screenMessageBuffer));
(int)_tcslen(theApp.screenMessageBuffer));
ddsPrimary->ReleaseDC(hdc);
} else {
theApp.screenMessage = false;
@ -883,74 +808,8 @@ int DirectDrawDisplay::selectFullScreenMode(GUID **pGUID)
return winVideoModeSelect(theApp.m_pMainWnd, pGUID);
}
bool DirectDrawDisplay::StartTimer()
{
MMRESULT result;
TIMECAPS tc;
if ( TIMERR_NOERROR == timeGetDevCaps( & tc, sizeof( TIMECAPS ) ) ) {
wait_timerres = min( max( tc.wPeriodMin, 1 ), tc.wPeriodMax );
timeBeginPeriod( wait_timerres );
} else {
return false;
}
result = timeSetEvent( wait_timerres, wait_timerres, & DirectDrawDisplay::g_timer_proc, ( DWORD_PTR ) this, TIME_PERIODIC );
if (NULL != result) {
wait_timerid = (UINT)result;
return true;
}
return false;
}
void DirectDrawDisplay::StopTimer()
{
MMRESULT result;
result = timeKillEvent( wait_timerid );
if ( TIMERR_NOERROR == result ) {
wait_timerid = 0;
}
if ( 0 != wait_timerres ) {
timeEndPeriod( wait_timerres );
wait_timerres = 0;
}
}
void CALLBACK DirectDrawDisplay::g_timer_proc( UINT id, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2 )
{
DirectDrawDisplay * p_this = reinterpret_cast< DirectDrawDisplay * >( dwUser );
if ( p_this ) {
p_this->timer_proc( id, msg, dw1, dw2 );
}
}
void DirectDrawDisplay::timer_proc( UINT id, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2 )
{
DWORD scanline;
if ( pDirectDraw->GetScanLine( & scanline ) == DD_OK ) {
unsigned height = GetSystemMetrics( SM_CYSCREEN );
if ( wait_screenheight != height ) {
wait_screenheight = height;
wait_maxheight = height;
}
if ( scanline >= wait_maxheight ) wait_maxheight = scanline + 1;
scanline = ( scanline + wait_maxheight - min( theApp.dest.bottom, wait_screenheight ) ) % wait_maxheight;
if ( scanline < wait_lastscanline ) {
PulseEvent( wait_event );
}
wait_lastscanline = scanline;
}
}
IDisplay *newDirectDrawDisplay()
{
return new DirectDrawDisplay();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,380 +1,383 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004-2005 Forgotten and the VBA 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 "stdafx.h"
#include "VBA.h"
#include "AVIWrite.h"
#include "Sound.h"
#include "WavWriter.h"
#include "../System.h"
#include "../GBA.h"
#include "../Globals.h"
#include "../Sound.h"
#include <mmreg.h>
#include <Dsound.h> //DirectSound
extern bool soundBufferLow;
class DirectSound : public ISound
{
private:
HINSTANCE dsoundDLL;
LPDIRECTSOUND pDirectSound;
LPDIRECTSOUNDBUFFER dsbPrimary;
LPDIRECTSOUNDBUFFER dsbSecondary;
LPDIRECTSOUNDNOTIFY dsbNotify;
HANDLE dsbEvent;
WAVEFORMATEX wfx;
public:
DirectSound();
virtual ~DirectSound();
bool init();
void pause();
void reset();
void resume();
void write();
};
DirectSound::DirectSound()
{
dsoundDLL = NULL;
pDirectSound = NULL;
dsbPrimary = NULL;
dsbSecondary = NULL;
dsbNotify = NULL;
dsbEvent = NULL;
}
DirectSound::~DirectSound()
{
if(theApp.aviRecorder != NULL) {
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviFrameNumber = 0;
}
if(theApp.soundRecording) {
if(theApp.soundRecorder != NULL) {
delete theApp.soundRecorder;
theApp.soundRecorder = NULL;
}
theApp.soundRecording = false;
}
if(dsbNotify != NULL) {
dsbNotify->Release();
dsbNotify = NULL;
}
if(dsbEvent != NULL) {
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
if(pDirectSound != NULL) {
if(dsbPrimary != NULL) {
dsbPrimary->Release();
dsbPrimary = NULL;
}
if(dsbSecondary != NULL) {
dsbSecondary->Release();
dsbSecondary = NULL;
}
pDirectSound->Release();
pDirectSound = NULL;
}
if(dsoundDLL != NULL) {
FreeLibrary(dsoundDLL);
dsoundDLL = NULL;
}
}
bool DirectSound::init()
{
HRESULT hr;
dsoundDLL = LoadLibrary("dsound.dll");
HRESULT (WINAPI *DSoundCreate)(LPCGUID,LPDIRECTSOUND *,IUnknown *);
if(dsoundDLL != NULL) {
DSoundCreate = (HRESULT (WINAPI *)(LPCGUID,LPDIRECTSOUND *,IUnknown *))
GetProcAddress(dsoundDLL, "DirectSoundCreate8");
if(DSoundCreate == NULL) {
theApp.directXMessage("DirectSoundCreate8");
return false;
}
} else {
theApp.directXMessage("dsound.dll");
return false;
}
if((hr = DSoundCreate(NULL,&pDirectSound,NULL) != DS_OK)) {
// errorMessage(myLoadString(IDS_ERROR_SOUND_CREATE), hr);
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND,
"Cannot create DirectSound %08x", hr);
pDirectSound = NULL;
dsbSecondary = NULL;
return false;
}
if((hr=pDirectSound->SetCooperativeLevel((HWND)*theApp.m_pMainWnd,
DSSCL_EXCLUSIVE)) != DS_OK) {
// errorMessage(myLoadString(IDS_ERROR_SOUND_LEVEL), hr);
systemMessage(IDS_CANNOT_SETCOOPERATIVELEVEL,
"Cannot SetCooperativeLevel %08x", hr);
return false;
}
DSBUFFERDESC dsbdesc;
ZeroMemory(&dsbdesc,sizeof(DSBUFFERDESC));
dsbdesc.dwSize=sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if((hr=pDirectSound->CreateSoundBuffer(&dsbdesc,
&dsbPrimary,
NULL) != DS_OK)) {
// errorMessage(myLoadString(IDS_ERROR_SOUND_BUFFER),hr);
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER,
"Cannot CreateSoundBuffer %08x", hr);
return false;
}
// Set primary buffer format
memset(&wfx, 0, sizeof(WAVEFORMATEX));
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
switch(soundQuality) {
case 2:
wfx.nSamplesPerSec = 22050;
soundBufferLen = 736*2;
soundBufferTotalLen = 7360*2;
break;
case 4:
wfx.nSamplesPerSec = 11025;
soundBufferLen = 368*2;
soundBufferTotalLen = 3680*2;
break;
default:
soundQuality = 1;
wfx.nSamplesPerSec = 44100;
soundBufferLen = 1470*2;
soundBufferTotalLen = 14700*2;
}
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if((hr = dsbPrimary->SetFormat(&wfx)) != DS_OK) {
// errorMessage(myLoadString(IDS_ERROR_SOUND_PRIMARY),hr);
systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY,
"Cannot SetFormat for primary %08x", hr);
return false;
}
ZeroMemory(&dsbdesc,sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLPOSITIONNOTIFY;
dsbdesc.dwBufferBytes = soundBufferTotalLen;
dsbdesc.lpwfxFormat = &wfx;
if((hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))
!= DS_OK) {
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
if((hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))
!= DS_OK) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER_SEC,
"Cannot CreateSoundBuffer secondary %08x", hr);
return false;
}
}
dsbSecondary->SetCurrentPosition(0);
if(!theApp.useOldSync) {
hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify,
(void **)&dsbNotify);
if(!FAILED(hr)) {
dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
DSBPOSITIONNOTIFY notify[10];
for(int i = 0; i < 10; i++) {
notify[i].dwOffset = i*soundBufferLen;
notify[i].hEventNotify = dsbEvent;
}
if(FAILED(dsbNotify->SetNotificationPositions(10, notify))) {
dsbNotify->Release();
dsbNotify = NULL;
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
}
}
hr = dsbPrimary->Play(0,0,DSBPLAY_LOOPING);
if(hr != DS_OK) {
// errorMessage(myLoadString(IDS_ERROR_SOUND_PLAYPRIM), hr);
systemMessage(IDS_CANNOT_PLAY_PRIMARY, "Cannot Play primary %08x", hr);
return false;
}
setsystemSoundOn(true);
return true;
}
void DirectSound::pause()
{
if(dsbSecondary != NULL) {
DWORD status = 0;
dsbSecondary->GetStatus(&status);
if(status & DSBSTATUS_PLAYING) {
dsbSecondary->Stop();
}
}
}
void DirectSound::reset()
{
if(dsbSecondary) {
dsbSecondary->Stop();
dsbSecondary->SetCurrentPosition(0);
}
}
void DirectSound::resume()
{
if(dsbSecondary != NULL) {
dsbSecondary->Play(0,0,DSBPLAY_LOOPING);
}
}
void DirectSound::write()
{
int len = soundBufferLen;
LPVOID lpvPtr1;
DWORD dwBytes1;
LPVOID lpvPtr2;
DWORD dwBytes2;
if(!pDirectSound)
return;
if(theApp.soundRecording) {
if(dsbSecondary) {
if(theApp.soundRecorder == NULL) {
theApp.soundRecorder = new WavWriter;
WAVEFORMATEX format;
dsbSecondary->GetFormat(&format, sizeof(format), NULL);
if(theApp.soundRecorder->Open(theApp.soundRecordName))
theApp.soundRecorder->SetFormat(&format);
}
}
if(theApp.soundRecorder) {
theApp.soundRecorder->AddSound((u8 *)soundFinalWave, len);
}
}
if(theApp.aviRecording) {
if(theApp.aviRecorder) {
if(dsbSecondary) {
if(!theApp.aviRecorder->IsSoundAdded()) {
WAVEFORMATEX format;
dsbSecondary->GetFormat(&format, sizeof(format), NULL);
theApp.aviRecorder->SetSoundFormat(&format);
}
}
theApp.aviRecorder->AddSound((const char *)soundFinalWave, len);
}
}
HRESULT hr;
if(!speedup && synchronize && !theApp.throttle) {
DWORD status=0;
hr = dsbSecondary->GetStatus(&status);
if(status && DSBSTATUS_PLAYING) {
if(!soundPaused) {
DWORD play;
while(true) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ?
play - soundNextPosition :
soundBufferTotalLen - soundNextPosition + play);
if(BufferLeft > soundBufferLen)
{
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if(dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
} else {
setsoundPaused(true);
}
}
// Obtain memory address of write block. This will be in two parts
// if the block wraps around.
hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen, &lpvPtr1,
&dwBytes1, &lpvPtr2, &dwBytes2,
0);
// If DSERR_BUFFERLOST is returned, restore and retry lock.
if (DSERR_BUFFERLOST == hr) {
dsbSecondary->Restore();
hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen,&lpvPtr1,
&dwBytes1, &lpvPtr2, &dwBytes2,
0);
}
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
if SUCCEEDED(hr) {
// Write to pointers.
CopyMemory(lpvPtr1, soundFinalWave, dwBytes1);
if (NULL != lpvPtr2) {
CopyMemory(lpvPtr2, soundFinalWave+dwBytes1, dwBytes2);
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2,
dwBytes2);
}
}
ISound *newDirectSound()
{
return new DirectSound();
}
// 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
// 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.
// MFC
#include "stdafx.h"
// Tools
#include "AVIWrite.h"
#include "WavWriter.h"
// Internals
#include "../System.h"
#include "../GBA.h"
#include "../Globals.h"
#include "../Sound.h"
// DirectSound8
#include <Dsound.h>
#pragma comment( lib, "Dsound" )
#pragma comment( lib, "Dxguid" )
extern bool soundBufferLow;
class DirectSound : public ISound
{
private:
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
LPDIRECTSOUNDBUFFER dsbSecondary; // Secondary DirectSound buffer
LPDIRECTSOUNDNOTIFY8 dsbNotify;
HANDLE dsbEvent;
WAVEFORMATEX wfx; // Primary buffer wave format
public:
DirectSound();
virtual ~DirectSound();
bool init(); // initialize the primary and secondary sound buffer
void pause(); // pause the secondary sound buffer
void reset(); // stop and reset the secondary sound buffer
void resume(); // resume the secondary sound buffer
void write(); // write the emulated sound to the secondary sound buffer
};
DirectSound::DirectSound()
{
CoInitialize( NULL );
pDirectSound = NULL;
dsbPrimary = NULL;
dsbSecondary = NULL;
dsbNotify = NULL;
dsbEvent = NULL;
}
DirectSound::~DirectSound()
{
if(theApp.aviRecorder) {
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviFrameNumber = 0;
}
if(theApp.soundRecording) {
if(theApp.soundRecorder) {
delete theApp.soundRecorder;
theApp.soundRecorder = NULL;
}
theApp.soundRecording = false;
}
if(dsbNotify) {
dsbNotify->Release();
dsbNotify = NULL;
}
if(dsbEvent) {
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
if(pDirectSound) {
if(dsbPrimary) {
dsbPrimary->Release();
dsbPrimary = NULL;
}
if(dsbSecondary) {
dsbSecondary->Release();
dsbSecondary = NULL;
}
pDirectSound->Release();
pDirectSound = NULL;
}
CoUninitialize();
}
bool DirectSound::init()
{
HRESULT hr;
DWORD freq;
DSBUFFERDESC dsbdesc;
int i;
// Initialize DirectSound
if( FAILED( hr = DirectSoundCreate8( &DSDEVID_DefaultPlayback, &pDirectSound, NULL ) ) ) {
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, _T("Cannot create DirectSound %08x"), hr );
pDirectSound = NULL;
return false;
}
if( FAILED( hr = pDirectSound->SetCooperativeLevel( theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE ) ) ) {
systemMessage( IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr );
return false;
}
// Create primary sound buffer
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if( theApp.dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbPrimary, NULL ) ) ) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
return false;
}
switch(soundQuality)
{
case 4:
freq = 11025;
break;
case 2:
freq = 22050;
break;
default:
soundQuality = 1;
case 1:
freq = 44100;
break;
}
soundBufferLen = freq*2/30;
soundBufferTotalLen = soundBufferLen * 10;
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = freq;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if( FAILED( hr = dsbPrimary->SetFormat( &wfx ) ) ) {
systemMessage( IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr );
return false;
}
// Create secondary sound buffer
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
if( theApp.dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
dsbdesc.dwBufferBytes = soundBufferTotalLen;
dsbdesc.lpwfxFormat = &wfx;
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbSecondary, NULL ) ) ) {
systemMessage( IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr );
return false;
}
if( FAILED( hr = dsbSecondary->SetCurrentPosition( 0 ) ) ) {
systemMessage( 0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr );
return false;
}
if( !theApp.useOldSync ) {
if( FAILED( hr = dsbSecondary->QueryInterface( IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify ) ) ) {
dsbEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
DSBPOSITIONNOTIFY notify[10];
for( i = 0; i < 10; i++ ) {
notify[i].dwOffset = i * soundBufferLen;
notify[i].hEventNotify = dsbEvent;
}
if( FAILED( dsbNotify->SetNotificationPositions( 10, notify ) ) ) {
dsbNotify->Release();
dsbNotify = NULL;
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
}
}
// Play primary buffer
if( FAILED( hr = dsbPrimary->Play( 0, 0, DSBPLAY_LOOPING ) ) ) {
systemMessage( IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr );
return false;
}
systemSoundOn = true;
return true;
}
void DirectSound::pause()
{
if( dsbSecondary == NULL ) return;
DWORD status;
dsbSecondary->GetStatus( &status );
if( status & DSBSTATUS_PLAYING ) dsbSecondary->Stop();
}
void DirectSound::reset()
{
if( dsbSecondary == NULL ) return;
dsbSecondary->Stop();
dsbSecondary->SetCurrentPosition( 0 );
}
void DirectSound::resume()
{
if( dsbSecondary == NULL ) return;
dsbSecondary->Play( 0, 0, DSBPLAY_LOOPING );
}
void DirectSound::write()
{
if(!pDirectSound) return;
HRESULT hr;
DWORD status = 0;
DWORD play = 0;
WAVEFORMATEX format;
LPVOID lpvPtr1;
DWORD dwBytes1 = 0;
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
if( theApp.soundRecording ) {
if( dsbSecondary ) {
if( theApp.soundRecorder ) {
theApp.soundRecorder->AddSound( (u8 *)soundFinalWave, soundBufferLen );
} else {
theApp.soundRecorder = new WavWriter;
dsbSecondary->GetFormat( &format, sizeof(format), NULL );
if( theApp.soundRecorder->Open( theApp.soundRecordName ) ) {
theApp.soundRecorder->SetFormat( &format );
}
}
}
}
if( theApp.aviRecording ) {
if( theApp.aviRecorder ) {
if( dsbSecondary ) {
if( !theApp.aviRecorder->IsSoundAdded() ) {
dsbSecondary->GetFormat( &format, sizeof(format), NULL );
theApp.aviRecorder->SetSoundFormat( &format );
}
}
theApp.aviRecorder->AddSound( (const char *)soundFinalWave, soundBufferLen );
}
}
if( !speedup && synchronize && !theApp.throttle ) {
hr = dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) {
if( !soundPaused ) {
while( true ) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ?
play - soundNextPosition :
soundBufferTotalLen - soundNextPosition + play);
if(BufferLeft > soundBufferLen)
{
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if(dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
} else {
setsoundPaused(true);
}
}
// Obtain memory address of write block.
// This will be in two parts if the block wraps around.
if( DSERR_BUFFERLOST == ( hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0 ) ) ) {
// If DSERR_BUFFERLOST is returned, restore and retry lock.
dsbSecondary->Restore();
hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0 );
}
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
if( SUCCEEDED( hr ) ) {
// Write to pointers.
CopyMemory( lpvPtr1, soundFinalWave, dwBytes1 );
if ( lpvPtr2 ) {
CopyMemory( lpvPtr2, soundFinalWave + dwBytes1, dwBytes2 );
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock( lpvPtr1, dwBytes1, lpvPtr2, dwBytes2 );
} else {
systemMessage( 0, _T("dsbSecondary->Lock() failed: %08x"), hr );
return;
}
}
ISound *newDirectSound()
{
return new DirectSound();
}

View File

@ -26,6 +26,7 @@
#include "WinResUtil.h"
#include <shlobj.h>
#include <shlwapi.h>
#ifdef _DEBUG
#define new DEBUG_NEW
@ -54,27 +55,21 @@ static int CALLBACK browseCallbackProc(HWND hWnd, UINT msg,
Directories::Directories(CWnd* pParent /*=NULL*/)
: CDialog(Directories::IDD, pParent)
{
//{{AFX_DATA_INIT(Directories)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void Directories::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Directories)
DDX_Control(pDX, IDC_SAVE_PATH, m_savePath);
DDX_Control(pDX, IDC_ROM_PATH, m_romPath);
DDX_Control(pDX, IDC_GBROM_PATH, m_gbromPath);
DDX_Control(pDX, IDC_CAPTURE_PATH, m_capturePath);
DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Directories, CDialog)
//{{AFX_MSG_MAP(Directories)
ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir)
ON_BN_CLICKED(IDC_BATTERY_DIR_RESET, OnBatteryDirReset)
ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir)
@ -85,8 +80,7 @@ BEGIN_MESSAGE_MAP(Directories, CDialog)
ON_BN_CLICKED(IDC_ROM_DIR_RESET, OnRomDirReset)
ON_BN_CLICKED(IDC_SAVE_DIR, OnSaveDir)
ON_BN_CLICKED(IDC_SAVE_DIR_RESET, OnSaveDirReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Directories message handlers
@ -206,23 +200,76 @@ void Directories::OnCancel()
void Directories::OnOK()
{
CString buffer;
m_romPath.GetWindowText(buffer);
if(!buffer.IsEmpty())
regSetStringValue("romdir", buffer);
m_gbromPath.GetWindowText(buffer);
if(!buffer.IsEmpty())
regSetStringValue("gbromdir", buffer);
m_batteryPath.GetWindowText(buffer);
if(!buffer.IsEmpty())
regSetStringValue("batteryDir", buffer);
m_savePath.GetWindowText(buffer);
if(!buffer.IsEmpty())
regSetStringValue("saveDir", buffer);
m_capturePath.GetWindowText(buffer);
if(!buffer.IsEmpty())
regSetStringValue("captureDir", buffer);
EndDialog(TRUE);
char baseDir[MAX_PATH+1];
char temp[MAX_PATH+1];
GetModuleFileName( NULL, baseDir, MAX_PATH );
baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
CString buffer;
m_romPath.GetWindowText(buffer);
if( !buffer.IsEmpty() )
regSetStringValue( "romdir", buffer );
if( buffer[0] == '.' ) {
strcpy( temp, baseDir );
strcat( temp, "\\" );
strcat( temp, buffer );
buffer = temp;
}
if( !directoryDoesExist( buffer ) )
SHCreateDirectoryEx( NULL, buffer, NULL );
m_gbromPath.GetWindowText(buffer);
if( !buffer.IsEmpty() )
regSetStringValue( "gbromdir", buffer );
if( buffer[0] == '.' ) {
strcpy( temp, baseDir );
strcat( temp, "\\" );
strcat( temp, buffer );
buffer = temp;
}
if( !directoryDoesExist( buffer ) )
SHCreateDirectoryEx( NULL, buffer, NULL );
m_batteryPath.GetWindowText(buffer);
if( !buffer.IsEmpty() )
regSetStringValue( "batteryDir", buffer );
if( buffer[0] == '.' ) {
strcpy( temp, baseDir );
strcat( temp, "\\" );
strcat( temp, buffer );
buffer = temp;
}
if( !directoryDoesExist( buffer ) )
SHCreateDirectoryEx( NULL, buffer, NULL );
m_savePath.GetWindowText(buffer);
if( !buffer.IsEmpty() )
regSetStringValue( "saveDir", buffer );
if( buffer[0] == '.' ) {
strcpy( temp, baseDir );
strcat( temp, "\\" );
strcat( temp, buffer );
buffer = temp;
}
if( !directoryDoesExist( buffer ) )
SHCreateDirectoryEx( NULL, buffer, NULL );
m_capturePath.GetWindowText(buffer);
if( !buffer.IsEmpty() )
regSetStringValue( "captureDir", buffer );
if( buffer[0] == '.' ) {
strcpy( temp, baseDir );
strcat( temp, "\\" );
strcat( temp, buffer );
buffer = temp;
}
if( !directoryDoesExist( buffer ) )
SHCreateDirectoryEx( NULL, buffer, NULL );
EndDialog(TRUE);
}
CString Directories::browseForDir(CString title)

View File

@ -75,7 +75,24 @@ class Directories : public CDialog
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
private:
bool directoryDoesExist(const char *directory)
{ // returns true if the directory does exist
HANDLE hDir;
hDir = CreateFile(
directory,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL );
bool retval = (hDir == INVALID_HANDLE_VALUE) ? false : true;
CloseHandle( hDir );
return retval;
}
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -118,6 +118,7 @@ void Disassemble::OnAutomatic()
void Disassemble::OnArm()
{
mode = 1;
address&=0xfffffffC;
refresh();
}
@ -133,21 +134,30 @@ void Disassemble::OnGo()
CString buffer;
m_address.GetWindowText(buffer);
sscanf(buffer, "%x", &address);
if (mode==1)
address&=0xfffffffc;
else if (mode==2)
address&=0xfffffffe;
refresh();
}
void Disassemble::OnGopc()
{
if(rom != NULL)
{
if(armState)
address = armNextPC - 16;
else
address = armNextPC - 8;
refresh();
}
}
void Disassemble::OnNext()
{
if(rom != NULL)
{
CPULoop(1);
if(armState) {
u32 total = address+count*4;
@ -163,6 +173,7 @@ void Disassemble::OnNext()
}
}
refresh();
}
}
void Disassemble::OnRefresh()
@ -173,6 +184,7 @@ void Disassemble::OnRefresh()
void Disassemble::OnThumb()
{
mode = 2;
address&=0xfffffffe;
refresh();
}

View File

@ -17,6 +17,8 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma once
enum DISPLAY_TYPE {
GDI = 0,
DIRECT_DRAW = 1,
@ -32,13 +34,15 @@ class IDisplay {
virtual bool initialize() = 0;
virtual void cleanup() = 0;
virtual void render() = 0;
virtual void checkFullScreen() { };
virtual void renderMenu() { };
virtual void checkFullScreen() {};
virtual void renderMenu() {};
virtual void clear() = 0;
virtual bool changeRenderSize(int w, int h) { return true; };
virtual void resize(int w, int h) {};
virtual void setOption(const char *option, int value) = 0;
virtual void setOption(const char *option, int value) {};
virtual DISPLAY_TYPE getType() = 0;
virtual bool isSkinSupported() { return false; }
virtual int selectFullScreenMode(GUID **) = 0;
virtual int selectFullScreenMode2() { return 0; };
};
void copyImage( void *source, void *destination, unsigned int width, unsigned int height, unsigned int destinationPitch, unsigned int colorDepth );

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -18,7 +18,7 @@
// FileDlg.cpp: implementation of the FileDlg class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <commdlg.h>
#include <dlgs.h>
@ -26,7 +26,7 @@
#include "VBA.h"
#include "FileDlg.h"
#include "../System.h"
#include "..\..\res\resource.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -159,20 +159,23 @@ void FileDlg::OnTypeChange(HWND hwnd)
ASSERT(typeControl != NULL);
int sel = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0);
LRESULT sel = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0);
ASSERT(sel != -1);
LPCTSTR typeName = extensions[sel];
if(filename.GetLength() == 0) {
filename.Format("*%s", typeName);
if(strlen(typeName) != 0)
filename.Format("*%s", typeName);
} else {
int index = filename.Find('.');
if (index == -1) {
filename = filename + typeName;
} else {
filename = filename.Left(index) + typeName;
if(strlen(typeName) != 0) {
int index = filename.Find('.');
if (index == -1) {
filename = filename + typeName;
} else {
filename = filename.Left(index) + typeName;
}
}
}
SetWindowText(fileNameControl, filename);

View File

@ -683,7 +683,7 @@ bool AddCheat::addCheat()
code.Format("%08x:%08x", address, value);
break;
}
cheatsAdd(code, buffer, address ,address, value,-1, sizeType);
return true;
}
@ -765,16 +765,16 @@ void GBACheatList::OnEnable()
if(mark != -1) {
LVITEM item;
for(int i = 0; i < count; i++) {
memset(&item,0, sizeof(item));
memset(&item, 0, sizeof(item));
item.mask = LVIF_PARAM|LVIF_STATE;
item.stateMask = LVIS_SELECTED;
item.iItem = i;
if(m_list.GetItem(&item)) {
if(item.state & LVIS_SELECTED) {
if(cheatsList[item.lParam].enabled)
cheatsDisable(item.lParam);
cheatsDisable((int)(item.lParam & 0xFFFFFFFF));
else
cheatsEnable(item.lParam);
cheatsEnable((int)(item.lParam & 0xFFFFFFFF));
}
}
}
@ -796,7 +796,7 @@ void GBACheatList::OnRemove()
item.stateMask = LVIS_SELECTED;
if(m_list.GetItem(&item)) {
if(item.state & LVIS_SELECTED) {
cheatsDelete(item.lParam, restoreValues);
cheatsDelete((int)(item.lParam & 0xFFFFFFFF), restoreValues);
}
}
}
@ -838,9 +838,9 @@ void GBACheatList::OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult)
if(((l->uOldState & LVIS_STATEIMAGEMASK)>>12) !=
(((l->uNewState & LVIS_STATEIMAGEMASK)>>12))) {
if(m_list.GetCheck(l->iItem))
cheatsEnable(l->lParam);
cheatsEnable((int)(l->lParam & 0xFFFFFFFF));
else
cheatsDisable(l->lParam);
cheatsDisable((int)(l->lParam & 0xFFFFFFFF));
refresh();
}
}

View File

@ -20,7 +20,7 @@
#if !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_)
#define AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

View File

@ -637,7 +637,7 @@ bool AddGBCheat::addCheat()
m_desc.GetWindowText(buffer);
int bank = (address >> 16);
LONG_PTR bank = (address >> 16);
address &= 0xFFFF;
if(address >= 0xd000)
@ -689,9 +689,7 @@ BOOL AddGBCheat::OnInitDialog()
buffer.Format("%02x:%08x", (address>>16), address&0xFFFF);
m_address.SetWindowText(buffer);
m_address.EnableWindow(FALSE);
::SetWindowLong(m_address,
GWL_USERDATA,
address);
::SetWindowLongPtr( m_address.GetSafeHwnd(), GWLP_USERDATA, address);
numberType = regQueryDwordValue("gbCheatsNumberType", 2);
if(numberType < 0 || numberType > 2)
@ -826,9 +824,9 @@ void GBCheatList::OnEnable()
item.iItem = mark;
if(m_list.GetItem(&item)) {
if(gbCheatList[item.lParam].enabled)
gbCheatDisable(item.lParam);
gbCheatDisable((int)item.lParam);
else
gbCheatEnable(item.lParam);
gbCheatEnable((int)item.lParam);
refresh();
}
}
@ -844,7 +842,7 @@ void GBCheatList::OnRemove()
item.mask = LVIF_PARAM;
item.iItem = mark;
if(m_list.GetItem(&item)) {
gbCheatRemove(item.lParam);
gbCheatRemove((int)item.lParam);
refresh();
}
}
@ -872,9 +870,9 @@ void GBCheatList::OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult)
if(((l->uOldState & LVIS_STATEIMAGEMASK)>>12) !=
(((l->uNewState & LVIS_STATEIMAGEMASK)>>12))) {
if(m_list.GetCheck(l->iItem))
gbCheatEnable(l->lParam);
gbCheatEnable((int)l->lParam);
else
gbCheatDisable(l->lParam);
gbCheatDisable((int)l->lParam);
refresh();
}
}

View File

@ -121,7 +121,7 @@ class AddGBCheat : public CDialog
// Implementation
protected:
u32 address;
LONG_PTR address;
// Generated message map functions
//{{AFX_MSG(AddGBCheat)

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2004-2006 Forgotten and the VBA 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
@ -32,28 +32,31 @@ extern u16 gbPalette[128];
static u16 defaultPalettes[][24] = {
{
0x7FFF, 0x56B5, 0x318C, 0x0000, 0x7FFF, 0x56B5, 0x318C, 0x0000,
0x7FFF, 0x56B5, 0x318C, 0x0000, 0x7FFF, 0x56B5, 0x318C, 0x0000,
},
{
0x6200, 0x7E10, 0x7C10, 0x5000, 0x6200, 0x7E10, 0x7C10, 0x5000,
0x6200, 0x7E10, 0x7C10, 0x5000, 0x6200, 0x7E10, 0x7C10, 0x5000,
},
{
0x4008, 0x4000, 0x2000, 0x2008, 0x4008, 0x4000, 0x2000, 0x2008,
0x4008, 0x4000, 0x2000, 0x2008, 0x4008, 0x4000, 0x2000, 0x2008,
},
{
0x43F0, 0x03E0, 0x4200, 0x2200, 0x43F0, 0x03E0, 0x4200, 0x2200,
0x43F0, 0x03E0, 0x4200, 0x2200, 0x43F0, 0x03E0, 0x4200, 0x2200,
},
{
0x43FF, 0x03FF, 0x221F, 0x021F, 0x43FF, 0x03FF, 0x221F, 0x021F,
0x43FF, 0x03FF, 0x221F, 0x021F, 0x43FF, 0x03FF, 0x221F, 0x021F,
},
{
0x621F, 0x7E1F, 0x7C1F, 0x2010, 0x621F, 0x7E1F, 0x7C1F, 0x2010,
0x621F, 0x7E1F, 0x7C1F, 0x2010, 0x621F, 0x7E1F, 0x7C1F, 0x2010,
},
{
0x621F, 0x401F, 0x001F, 0x2010, 0x621F, 0x401F, 0x001F, 0x2010,
0x621F, 0x401F, 0x001F, 0x2010, 0x621F, 0x401F, 0x001F, 0x2010,
},
{
0x421F, 0x03E0, 0x7C00, 0x401F, 0x021F, 0x2200, 0x4008, 0x2010,
0x1B8E, 0x02C0, 0x0DA0, 0x1140, 0x1B8E, 0x02C0, 0x0DA0, 0x1140,
},
{
0x7BDE, /*0x23F0*/ 0x5778, /*0x5DC0*/ 0x5640, 0x0000, 0x7BDE, /*0x3678*/ 0x529C, /*0x0980*/ 0x2990, 0x0000,
}
};
@ -70,20 +73,15 @@ static char THIS_FILE[] = __FILE__;
GBColorDlg::GBColorDlg(CWnd* pParent /*=NULL*/)
: CDialog(GBColorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(GBColorDlg)
which = -1;
//}}AFX_DATA_INIT
which = gbPaletteOption;
}
void GBColorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(GBColorDlg)
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PREDEFINED, m_predefined);
DDX_Radio(pDX, IDC_DEFAULT, which);
//}}AFX_DATA_MAP
DDX_Radio(pDX, IDC_DEFAULT, which);
}
@ -95,8 +93,8 @@ BEGIN_MESSAGE_MAP(GBColorDlg, CDialog)
ON_BN_CLICKED(IDC_USER2, OnUser2)
ON_BN_CLICKED(ID_OK, OnOk)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_CBN_SELCHANGE(IDC_PREDEFINED, OnSelchangePredefined)
//}}AFX_MSG_MAP
ON_CBN_SELCHANGE(IDC_PREDEFINED, OnSelchangePredefined)
//}}AFX_MSG_MAP
ON_CONTROL_RANGE(BN_CLICKED, IDC_COLOR_BG0, IDC_COLOR_OB3, OnColorClicked)
END_MESSAGE_MAP()
@ -167,10 +165,12 @@ BOOL GBColorDlg::OnInitDialog()
"Green Forest",
"Hot Desert",
"Pink Dreams",
"Weird Colors"
"Weird Colors",
"Real GB Colors",
"Real 'GB on GBASP' Colors"
};
for(int j = 0; j < 7; j++) {
for(int j = 0; j < 9; j++) {
int index = m_predefined.AddString(names[j]);
m_predefined.SetItemData(index, j);
}
@ -222,15 +222,20 @@ void GBColorDlg::OnColorClicked(UINT id)
{
id -= IDC_COLOR_BG0;
u16 color = colors[id];
u16 color = colors[which*8+id];
CColorDialog dlg(RGB(color & 0x1f, (color >> 5) & 0x1f, (color >> 10) & 0x1f),
COLORREF colorInit =
RGB((color & 0x1f) << 3, ((color >> 5) & 0x1f) << 3, ((color >> 10) & 0x1f) << 3);
CColorDialog dlg(colorInit,
CC_FULLOPEN | CC_ANYCOLOR, this);
if(dlg.DoModal()) {
if(IDOK == dlg.DoModal())
{
COLORREF c = dlg.GetColor();
colors[which*8+id] = (u16)((c >> 3) & 0x1f | ((c >> 11) & 0x1f) << 5 |
((c >> 19) & 0x1f) << 10);
colors[which*8+id] = (u16)((c >> 3) & 0x1f | ((c >> 11) & 0x1f) << 5 | ((c >> 19) & 0x1f) << 10);
colorControls[id].setColor(colors[which*8+id]);
}
}
@ -246,7 +251,7 @@ void GBColorDlg::OnSelchangePredefined()
int sel = m_predefined.GetCurSel();
if(sel != -1) {
int data = m_predefined.GetItemData(sel);
DWORD_PTR data = m_predefined.GetItemData(sel);
for(int i = 0; i < 8; i++) {
colorControls[i].setColor(defaultPalettes[data][i]);
colors[which*8+i] = defaultPalettes[data][i];

View File

@ -21,7 +21,7 @@
#define AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_
#include "ColorButton.h" // Added by ClassView
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -39,6 +39,7 @@ extern gbRegister DE;
extern gbRegister HL;
extern gbRegister SP;
extern gbRegister PC;
extern u8 register_LY;
extern u16 IFF;
extern int gbDis(char *, u16);
@ -114,8 +115,9 @@ void GBDisassemble::OnNext()
void GBDisassemble::OnGo()
{
CString buffer;
m_address.GetWindowText(buffer);
sscanf(buffer, "%x", &address);
sscanf(buffer, "%hx", &address);
refresh();
}
@ -242,6 +244,8 @@ void GBDisassemble::refresh()
GetDlgItem(IDC_R5)->SetWindowText(buffer);
sprintf(buffer, "%04x", IFF);
GetDlgItem(IDC_R6)->SetWindowText(buffer);
sprintf(buffer, "%04x", register_LY);
GetDlgItem(IDC_LY)->SetWindowText(buffer);
m_z = (AF.B.B0 & 0x80) != 0;
m_n = (AF.B.B0 & 0x40) != 0;

View File

@ -20,7 +20,7 @@
#if !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_)
#define AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

View File

@ -499,8 +499,8 @@ LRESULT GBMapView::OnMapInfo(WPARAM wParam, LPARAM lParam)
u8 *colors = (u8 *)lParam;
mapViewZoom.setColors(colors);
int x = wParam & 0xffff;
int y = (wParam >> 16);
int x = (int)(wParam & 0xffff);
int y = (int)(wParam >> 16);
CString buffer;
buffer.Format("(%d,%d)", x, y);

View File

@ -31,7 +31,7 @@
#include "ZoomControl.h"
#include "ResizeDlg.h"
#include "IUpdate.h"
#include "..\System.h" // Added by ClassView
#include "../System.h" // Added by ClassView
/////////////////////////////////////////////////////////////////////////////
// GBMapView dialog

View File

@ -135,8 +135,8 @@ void GBPaletteView::save(int which)
if(dlg.DoModal() == IDCANCEL) {
return;
}
captureBuffer = dlg.GetPathName();
captureBuffer = dlg.GetPathName();
PaletteViewControl *p = NULL;

View File

@ -460,8 +460,8 @@ LRESULT GBTileView::OnMapInfo(WPARAM wParam, LPARAM lParam)
u8 *colors = (u8 *)lParam;
zoom.setColors(colors);
int x = (wParam & 0xFFFF)/8;
int y = ((wParam >> 16) & 0xFFFF)/8;
int x = (int)((wParam & 0xffff)/8);
int y = (int)(((wParam >> 16) & 0xFFFF)/8);
int tiles = 0x0000;
if(charBase)

View File

@ -1,479 +1,402 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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 "stdafx.h"
#include <stdio.h>
#include "../System.h"
#include "../GBA.h"
#include "../Globals.h"
#include "..\gb\gbGlobals.h"
#include "../Text.h"
#include "../Util.h"
#include "UniVideoModeDlg.h"
#include "VBA.h"
#include "MainWnd.h"
#include "Reg.h"
#include "..\..\res\resource.h"
#include "../gbafilter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern void winlog(const char *,...);
extern int Init_2xSaI(u32);
extern int systemSpeed;
extern int winVideoModeSelect(CWnd *, GUID **);
class GDIDisplay : public IDisplay
{
private:
u8 *filterData;
u8 info[sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)];
int SelectedFreq, SelectedAdapter;
public:
GDIDisplay();
virtual ~GDIDisplay();
virtual bool changeRenderSize(int w, int h);
virtual bool initialize();
virtual void cleanup();
virtual void render();
virtual void checkFullScreen();
virtual void renderMenu();
virtual void clear();
virtual DISPLAY_TYPE getType() { return GDI; };
virtual void setOption(const char *, int) {}
virtual int selectFullScreenMode(GUID **);
virtual int selectFullScreenMode2();
};
static int calculateShift(u32 mask)
{
int m = 0;
while(mask) {
m++;
mask >>= 1;
}
return m-5;
}
GDIDisplay::GDIDisplay()
{
filterData = NULL;
}
GDIDisplay::~GDIDisplay()
{
cleanup();
}
void GDIDisplay::cleanup()
{
if(filterData)
{
delete [] filterData;
filterData = NULL;
}
}
bool GDIDisplay::initialize()
{
switch(theApp.cartridgeType)
{
case 0:
theApp.sizeX = 240;
theApp.sizeY = 160;
break;
case 1:
if(gbBorderOn)
{
theApp.sizeX = 256;
theApp.sizeY = 224;
}
else
{
theApp.sizeX = 160;
theApp.sizeY = 144;
}
break;
}
switch(theApp.videoOption)
{
case VIDEO_1X:
theApp.surfaceSizeX = theApp.sizeX;
theApp.surfaceSizeY = theApp.sizeY;
break;
case VIDEO_2X:
theApp.surfaceSizeX = theApp.sizeX * 2;
theApp.surfaceSizeY = theApp.sizeY * 2;
break;
case VIDEO_3X:
theApp.surfaceSizeX = theApp.sizeX * 3;
theApp.surfaceSizeY = theApp.sizeY * 3;
break;
case VIDEO_4X:
theApp.surfaceSizeX = theApp.sizeX * 4;
theApp.surfaceSizeY = theApp.sizeY * 4;
break;
case VIDEO_320x240:
case VIDEO_640x480:
case VIDEO_800x600:
case VIDEO_1024x768:
case VIDEO_1280x1024:
case VIDEO_OTHER:
float scaleX = ((float)theApp.fsWidth / theApp.sizeX);
float scaleY = ((float)theApp.fsHeight / theApp.sizeY);
float min = scaleX < scaleY ? scaleX : scaleY;
if(theApp.fsMaxScale)
min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min;
if(theApp.fullScreenStretch)
{
theApp.surfaceSizeX = theApp.fsWidth;
theApp.surfaceSizeY = theApp.fsHeight;
}
else
{
theApp.surfaceSizeX = (int)(theApp.sizeX * min);
theApp.surfaceSizeY = (int)(theApp.sizeY * min);
}
break;
}
theApp.rect.left = 0;
theApp.rect.top = 0;
theApp.rect.right = theApp.sizeX;
theApp.rect.bottom = theApp.sizeY;
theApp.dest.left = 0;
theApp.dest.top = 0;
theApp.dest.right = theApp.surfaceSizeX;
theApp.dest.bottom = theApp.surfaceSizeY;
DWORD style = WS_POPUP | WS_VISIBLE;
DWORD styleEx = 0;
if(theApp.videoOption <= VIDEO_4X)
style |= WS_OVERLAPPEDWINDOW;
else
styleEx = 0;
if(theApp.videoOption <= VIDEO_4X)
AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx);
else
AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx);
int winSizeX = theApp.dest.right-theApp.dest.left;
int winSizeY = theApp.dest.bottom-theApp.dest.top;
if(theApp.videoOption > VIDEO_4X) {
winSizeX = theApp.fsWidth;
winSizeY = theApp.fsHeight;
}
int x = 0;
int y = 0;
if(theApp.videoOption <= VIDEO_4X) {
x = theApp.windowPositionX;
y = theApp.windowPositionY;
}
// Create a window
MainWnd *pWnd = new MainWnd;
theApp.m_pMainWnd = pWnd;
pWnd->CreateEx(styleEx,
theApp.wndClass,
"VisualBoyAdvance",
style,
x,y,winSizeX,winSizeY,
NULL,
0);
if (!(HWND)*pWnd) {
winlog("Error creating Window %08x\n", GetLastError());
return FALSE;
}
theApp.updateMenuBar();
theApp.adjustDestRect();
// Enumerate available display modes
theApp.mode320Available = false;
theApp.mode640Available = false;
theApp.mode800Available = false;
theApp.mode1024Available = false;
theApp.mode1280Available = false;
DISPLAY_DEVICE dev;
dev.cb = sizeof(DISPLAY_DEVICE);
EnumDisplayDevices(NULL, 0, &dev, 0);
DEVMODE mode;
for (DWORD iMode = 0;
TRUE == EnumDisplaySettings(dev.DeviceName, iMode, &mode);
iMode++)
{
if ( (mode.dmBitsPerPel == 16) &&
(mode.dmPelsWidth==320) && (mode.dmPelsHeight==240))
theApp.mode320Available = true;
if ( (mode.dmBitsPerPel == 16) &&
(mode.dmPelsWidth==640) && (mode.dmPelsHeight==480))
theApp.mode640Available = true;
if ( (mode.dmBitsPerPel == 16) &&
(mode.dmPelsWidth==800) && (mode.dmPelsHeight==600))
theApp.mode800Available = true;
if ( (mode.dmBitsPerPel == 32) &&
(mode.dmPelsWidth==1024) && (mode.dmPelsHeight==768))
theApp.mode1024Available = true;
if ( (mode.dmBitsPerPel == 32) &&
(mode.dmPelsWidth==1280) && (mode.dmPelsHeight==1024))
theApp.mode1280Available = true;
}
// Go into fullscreen
if(theApp.videoOption >= VIDEO_320x240)
{
mode.dmBitsPerPel = theApp.fsColorDepth;
mode.dmPelsWidth = theApp.fsWidth;
mode.dmPelsHeight = theApp.fsHeight;
mode.dmDisplayFrequency = theApp.fsFrequency;
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
DISPLAY_DEVICE dd;
dd.cb = sizeof(DISPLAY_DEVICE);
EnumDisplayDevices(NULL, theApp.fsAdapter, &dd, 0);
ChangeDisplaySettingsEx(dd.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL);
}
else // Reset from fullscreen
{
ChangeDisplaySettings(NULL, 0);
}
// Initialize 2xSaI
HDC dc = GetDC(NULL);
HBITMAP hbm = CreateCompatibleBitmap(dc, 1, 1);
BITMAPINFO *bi = (BITMAPINFO *)info;
ZeroMemory(bi, sizeof(info));
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS);
GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS);
DeleteObject(hbm);
ReleaseDC(NULL, dc);
if(bi->bmiHeader.biCompression == BI_BITFIELDS) {
systemColorDepth = bi->bmiHeader.biBitCount;
if(systemColorDepth == 15)
systemColorDepth = 16;
systemRedShift = calculateShift(*((DWORD *)&bi->bmiColors[0]));
systemGreenShift = calculateShift(*((DWORD *)&bi->bmiColors[1]));
systemBlueShift = calculateShift(*((DWORD *)&bi->bmiColors[2]));
if(systemColorDepth == 16) {
if(systemGreenShift == 6) {
Init_2xSaI(565);
} else {
Init_2xSaI(555);
}
} else if(systemColorDepth == 32)
Init_2xSaI(32);
} else {
systemColorDepth = 32;
systemRedShift = 19;
systemGreenShift = 11;
systemBlueShift = 3;
Init_2xSaI(32);
}
// Setup system color depth
theApp.fsColorDepth = systemColorDepth;
if(systemColorDepth == 24)
theApp.filterFunction = NULL;
#ifdef MMX
if(!theApp.disableMMX)
cpu_mmx = theApp.detectMMX();
else
cpu_mmx = 0;
#endif
utilUpdateSystemColorMaps(theApp.filterLCD );
theApp.updateFilter();
theApp.updateIFB();
pWnd->DragAcceptFiles(TRUE);
return TRUE;
}
void GDIDisplay::clear()
{
CDC *dc = theApp.m_pMainWnd->GetDC();
CBrush brush(RGB(0x00, 0x00, 0x00));
dc->FillRect(CRect(0, 0, theApp.fsWidth, theApp.fsHeight), &brush);
theApp.m_pMainWnd->ReleaseDC(dc);
}
void GDIDisplay::renderMenu()
{
checkFullScreen();
theApp.m_pMainWnd->DrawMenuBar();
}
void GDIDisplay::checkFullScreen()
{
}
void GDIDisplay::render()
{
unsigned int pitch = theApp.filterWidth * (systemColorDepth / 8) + 4;
BITMAPINFO *bi = (BITMAPINFO *)info;
bi->bmiHeader.biWidth = theApp.filterWidth + 1;
bi->bmiHeader.biHeight = -theApp.filterHeight;
if(theApp.filterFunction)
{
bi->bmiHeader.biWidth = theApp.rect.right;
bi->bmiHeader.biHeight = -(int)theApp.rect.bottom;
(*theApp.filterFunction)(
pix + pitch,
pitch,
(u8*)theApp.delta,
(u8*)filterData,
theApp.rect.right * (systemColorDepth / 8),
theApp.filterWidth,
theApp.filterHeight);
}
POINT p1, p2;
p1.x = theApp.dest.left;
p1.y = theApp.dest.top;
p2.x = theApp.dest.right;
p2.y = theApp.dest.bottom;
theApp.m_pMainWnd->ScreenToClient(&p1);
theApp.m_pMainWnd->ScreenToClient(&p2);
CDC *dc = theApp.m_pMainWnd->GetDC();
// Draw bitmap to device
StretchDIBits(
dc->GetSafeHdc(),
p1.x, p1.y,
p2.x - p1.x,
p2.y - p1.y,
theApp.rect.left, theApp.rect.top,
theApp.rect.right - theApp.rect.left,
theApp.rect.bottom - theApp.rect.top,
theApp.filterFunction ? filterData : pix + pitch,
bi,
DIB_RGB_COLORS,
SRCCOPY);
// Draw frame counter
if (theApp.showSpeed && (theApp.videoOption >= VIDEO_320x240))
{
CString speedText;
if (theApp.showSpeed == 1)
speedText.AppendFormat("%3d%%", systemSpeed);
else
speedText.AppendFormat("%3d%%(%d, %d fps)",
systemSpeed, systemFrameSkip, theApp.showRenderedFrames);
dc->SetTextColor(RGB(0xFF, 0x3F, 0x3F));
if (theApp.showSpeedTransparent)
dc->SetBkMode(TRANSPARENT);
else
dc->SetBkMode(OPAQUE);
dc->SetBkColor(RGB(0xFF, 0xFF, 0xFF));
dc->TextOut(p1.x + 16, p1.y + 16, speedText);
}
// Draw screen message
if (theApp.screenMessage)
{
if ( ((GetTickCount() - theApp.screenMessageTime) < 3000) && !theApp.disableStatusMessage )
{
dc->SetTextColor(RGB(0x3F, 0x3F, 0xFF));
if (theApp.showSpeedTransparent)
dc->SetBkMode(TRANSPARENT);
else
dc->SetBkMode(OPAQUE);
dc->SetBkColor(RGB(0xFF, 0xFF, 0xFF));
dc->TextOut(p1.x + 16, p2.y - 16, theApp.screenMessageBuffer);
}
else
theApp.screenMessage = false;
}
theApp.m_pMainWnd->ReleaseDC(dc);
}
int GDIDisplay::selectFullScreenMode(GUID **pGUID)
{
int w, h, b;
UniVideoModeDlg dlg(0, &w, &h, &b, &SelectedFreq, &SelectedAdapter);
if (0 == dlg.DoModal())
{
return (b<<24) + (w<<12) + h;
// Bits<<24 | Width<<12 | Height
}
else
{
return -1;
}
}
int GDIDisplay::selectFullScreenMode2()
{
return (SelectedAdapter<<16) + SelectedFreq;
}
bool GDIDisplay::changeRenderSize(int w, int h)
{
if (filterData)
{
delete [] filterData;
filterData = NULL;
}
filterData = new u8[w*h*(systemColorDepth>>3)];
return true;
}
IDisplay *newGDIDisplay()
{
return new GDIDisplay();
}
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005-2006 VBA 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 "stdafx.h"
#include "Display.h"
#include "../System.h"
#include "../GBA.h"
#include "../Globals.h"
#include "../Text.h"
#include "../Util.h"
#include "VBA.h"
#include "MainWnd.h"
#include "Reg.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern void winlog(const char *,...);
extern int Init_2xSaI(u32);
extern int systemSpeed;
class GDIDisplay : public IDisplay {
private:
u8 *filterData;
u8 info[sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)];
public:
GDIDisplay();
virtual ~GDIDisplay();
virtual bool initialize();
virtual void cleanup();
virtual void render();
virtual void checkFullScreen();
virtual void renderMenu();
virtual void clear();
virtual DISPLAY_TYPE getType() { return GDI; };
virtual void setOption(const char *, int) {}
virtual bool isSkinSupported() { return true; }
virtual int selectFullScreenMode(GUID **);
};
static int calculateShift(u32 mask)
{
int m = 0;
while(mask) {
m++;
mask >>= 1;
}
return m-5;
}
GDIDisplay::GDIDisplay()
{
filterData = (u8 *)malloc(4*4*256*240);
}
GDIDisplay::~GDIDisplay()
{
cleanup();
}
void GDIDisplay::cleanup()
{
if(filterData) {
free(filterData);
filterData = NULL;
}
}
bool GDIDisplay::initialize()
{
theApp.sizeX = 240;
theApp.sizeY = 160;
switch(theApp.videoOption) {
case VIDEO_1X:
theApp.surfaceSizeX = theApp.sizeX;
theApp.surfaceSizeY = theApp.sizeY;
break;
case VIDEO_2X:
theApp.surfaceSizeX = theApp.sizeX * 2;
theApp.surfaceSizeY = theApp.sizeY * 2;
break;
case VIDEO_3X:
theApp.surfaceSizeX = theApp.sizeX * 3;
theApp.surfaceSizeY = theApp.sizeY * 3;
break;
case VIDEO_4X:
theApp.surfaceSizeX = theApp.sizeX * 4;
theApp.surfaceSizeY = theApp.sizeY * 4;
break;
case VIDEO_320x240:
case VIDEO_640x480:
case VIDEO_800x600:
case VIDEO_OTHER:
{
int scaleX = (theApp.fsWidth / theApp.sizeX);
int scaleY = (theApp.fsHeight / theApp.sizeY);
int min = scaleX < scaleY ? scaleX : scaleY;
if(theApp.fsMaxScale)
min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min;
theApp.surfaceSizeX = theApp.sizeX * min;
theApp.surfaceSizeY = theApp.sizeY * min;
if(theApp.fullScreenStretch) {
theApp.surfaceSizeX = theApp.fsWidth;
theApp.surfaceSizeY = theApp.fsHeight;
}
}
break;
}
theApp.rect.left = 0;
theApp.rect.top = 0;
theApp.rect.right = theApp.sizeX;
theApp.rect.bottom = theApp.sizeY;
theApp.dest.left = 0;
theApp.dest.top = 0;
theApp.dest.right = theApp.surfaceSizeX;
theApp.dest.bottom = theApp.surfaceSizeY;
DWORD style = WS_POPUP | WS_VISIBLE;
DWORD styleEx = 0;
if(theApp.videoOption <= VIDEO_4X)
style |= WS_OVERLAPPEDWINDOW;
else
styleEx = 0;
if(theApp.videoOption <= VIDEO_4X)
AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx);
else
AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx);
int winSizeX = theApp.dest.right-theApp.dest.left;
int winSizeY = theApp.dest.bottom-theApp.dest.top;
if(theApp.videoOption > VIDEO_4X) {
winSizeX = theApp.fsWidth;
winSizeY = theApp.fsHeight;
}
int x = 0;
int y = 0;
if(theApp.videoOption <= VIDEO_4X) {
x = theApp.windowPositionX;
y = theApp.windowPositionY;
}
// Create a window
MainWnd *pWnd = new MainWnd;
theApp.m_pMainWnd = pWnd;
pWnd->CreateEx(styleEx,
theApp.wndClass,
"VisualBoyAdvance",
style,
x,y,winSizeX,winSizeY,
NULL,
0);
if (!(HWND)*pWnd) {
winlog("Error creating Window %08x\n", GetLastError());
return FALSE;
}
theApp.updateMenuBar();
theApp.adjustDestRect();
theApp.mode320Available = false;
theApp.mode640Available = false;
theApp.mode800Available = false;
HDC dc = GetDC(NULL);
HBITMAP hbm = CreateCompatibleBitmap(dc, 1, 1);
BITMAPINFO *bi = (BITMAPINFO *)info;
ZeroMemory(bi, sizeof(info));
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS);
GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS);
DeleteObject(hbm);
ReleaseDC(NULL, dc);
if(bi->bmiHeader.biCompression == BI_BITFIELDS) {
systemColorDepth = bi->bmiHeader.biBitCount;
if(systemColorDepth == 15)
systemColorDepth = 16;
systemRedShift = calculateShift(*((DWORD *)&bi->bmiColors[0]));
systemGreenShift = calculateShift(*((DWORD *)&bi->bmiColors[1]));
systemBlueShift = calculateShift(*((DWORD *)&bi->bmiColors[2]));
if(systemColorDepth == 16) {
if(systemGreenShift == 6) {
Init_2xSaI(565);
} else {
Init_2xSaI(555);
}
} else if(systemColorDepth == 32)
Init_2xSaI(32);
} else {
systemColorDepth = 32;
systemRedShift = 19;
systemGreenShift = 11;
systemBlueShift = 3;
Init_2xSaI(32);
}
theApp.fsColorDepth = systemColorDepth;
if(systemColorDepth == 24)
theApp.filterFunction = NULL;
#ifdef MMX
if(!theApp.disableMMX)
cpu_mmx = theApp.detectMMX();
else
cpu_mmx = 0;
#endif
utilUpdateSystemColorMaps();
theApp.updateFilter();
theApp.updateIFB();
pWnd->DragAcceptFiles(TRUE);
return TRUE;
}
void GDIDisplay::clear()
{
}
void GDIDisplay::renderMenu()
{
checkFullScreen();
theApp.m_pMainWnd->DrawMenuBar();
}
void GDIDisplay::checkFullScreen()
{
}
void GDIDisplay::render()
{
BITMAPINFO *bi = (BITMAPINFO *)info;
bi->bmiHeader.biWidth = theApp.filterWidth+1;
bi->bmiHeader.biHeight = -theApp.filterHeight;
int pitch = theApp.filterWidth * 2 + 4;
if(systemColorDepth == 24)
pitch = theApp.filterWidth * 3;
else if(systemColorDepth == 32)
pitch = theApp.filterWidth * 4 + 4;
if(theApp.filterFunction) {
bi->bmiHeader.biWidth = theApp.filterWidth * 2;
bi->bmiHeader.biHeight = -theApp.filterHeight * 2;
if(systemColorDepth == 16)
(*theApp.filterFunction)(pix+pitch,
pitch,
(u8*)theApp.delta,
(u8*)filterData,
theApp.filterWidth*2*2,
theApp.filterWidth,
theApp.filterHeight);
else
(*theApp.filterFunction)(pix+pitch,
pitch,
(u8*)theApp.delta,
(u8*)filterData,
theApp.filterWidth*4*2,
theApp.filterWidth,
theApp.filterHeight);
}
if(theApp.showSpeed && (theApp.videoOption > VIDEO_4X || theApp.skin != NULL)) {
char buffer[30];
if(theApp.showSpeed == 1)
sprintf(buffer, "%3d%%", systemSpeed);
else
sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
systemFrameSkip,
theApp.showRenderedFrames);
if(theApp.filterFunction) {
int p = theApp.filterWidth * 4;
if(systemColorDepth == 24)
p = theApp.filterWidth * 6;
else if(systemColorDepth == 32)
p = theApp.filterWidth * 8;
if(theApp.showSpeedTransparent)
drawTextTransp((u8*)filterData,
p,
10,
theApp.filterHeight*2-10,
buffer);
else
drawText((u8*)filterData,
p,
10,
theApp.filterHeight*2-10,
buffer);
} else {
if(theApp.showSpeedTransparent)
drawTextTransp((u8*)pix,
pitch,
10,
theApp.filterHeight-10,
buffer);
else
drawText((u8*)pix,
pitch,
10,
theApp.filterHeight-10,
buffer);
}
}
POINT p;
p.x = theApp.dest.left;
p.y = theApp.dest.top;
CWnd *pWnd = theApp.m_pMainWnd;
pWnd->ScreenToClient(&p);
POINT p2;
p2.x = theApp.dest.right;
p2.y = theApp.dest.bottom;
pWnd->ScreenToClient(&p2);
CDC *dc = pWnd->GetDC();
StretchDIBits((HDC)*dc,
p.x,
p.y,
p2.x - p.x,
p2.y - p.y,
0,
0,
theApp.rect.right,
theApp.rect.bottom,
theApp.filterFunction ? filterData : pix+pitch,
bi,
DIB_RGB_COLORS,
SRCCOPY);
if(theApp.screenMessage) {
if(((GetTickCount() - theApp.screenMessageTime) < 3000) &&
!theApp.disableStatusMessage) {
dc->SetTextColor(RGB(255,0,0));
dc->SetBkMode(TRANSPARENT);
dc->TextOut(p.x+10, p2.y - 20, theApp.screenMessageBuffer);
} else {
theApp.screenMessage = false;
}
}
pWnd->ReleaseDC(dc);
}
int GDIDisplay::selectFullScreenMode(GUID **)
{
HWND wnd = GetDesktopWindow();
RECT r;
GetWindowRect(wnd, &r);
int w = (r.right - r.left) & 4095;
int h = (r.bottom - r.top) & 4095;
HDC dc = GetDC(wnd);
int c = GetDeviceCaps(dc, BITSPIXEL);
ReleaseDC(wnd, dc);
return (c << 24) | (w << 12) | h;
}
IDisplay *newGDIDisplay()
{
return new GDIDisplay();
}

View File

@ -1,202 +1,239 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
// IOViewer.cpp : implementation file
//
#include "stdafx.h"
#include "vba.h"
#include "IOViewer.h"
#include "../System.h"
#include "../GBA.h"
#include "../Globals.h"
#include "../Sound.h"
#include "IOViewerRegs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// IOViewer dialog
IOViewer::IOViewer(CWnd* pParent /*=NULL*/)
: ResizeDlg(IOViewer::IDD, pParent)
{
//{{AFX_DATA_INIT(IOViewer)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
selected = 0;
autoUpdate = false;
}
void IOViewer::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(IOViewer)
DDX_Control(pDX, IDC_VALUE, m_value);
DDX_Control(pDX, IDC_ADDRESSES, m_address);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(IOViewer, CDialog)
//{{AFX_MSG_MAP(IOViewer)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses)
ON_BN_CLICKED(IDC_APPLY, OnApply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// IOViewer message handlers
void IOViewer::OnClose()
{
theApp.winRemoveUpdateListener(this);
DestroyWindow();
}
void IOViewer::OnRefresh()
{
// TODO: Add your control notification handler code here
}
void IOViewer::OnAutoUpdate()
{
autoUpdate = !autoUpdate;
if(autoUpdate) {
theApp.winAddUpdateListener(this);
} else {
theApp.winRemoveUpdateListener(this);
}
}
void IOViewer::OnSelchangeAddresses()
{
selected = m_address.GetCurSel();
update();
}
void IOViewer::PostNcDestroy()
{
delete this;
}
BOOL IOViewer::OnInitDialog()
{
CDialog::OnInitDialog();
// winCenterWindow(getHandle());
DIALOG_SIZER_START( sz )
DIALOG_SIZER_END()
SetData(sz,
TRUE,
HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\IOView",
NULL);
CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));
int i;
for(i = 0; i < sizeof(ioViewRegisters)/sizeof(IOData); i++) {
m_address.AddString(ioViewRegisters[i].name);
}
m_address.SetFont(font);
for(i = 0; i < 16; i++) {
GetDlgItem(IDC_BIT_0+i)->SetFont(font);
}
RECT cbSize;
int Height;
m_address.GetClientRect(&cbSize);
Height = m_address.GetItemHeight(0);
Height += m_address.GetItemHeight(0) * (10);
// Note: The use of SM_CYEDGE assumes that we're using Windows '95
// Now add on the height of the border of the edit box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
// The height of the border of the drop-down box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
// now set the size of the window
m_address.SetWindowPos(NULL,
0, 0,
cbSize.right, Height,
SWP_NOMOVE | SWP_NOZORDER);
m_address.SetCurSel(0);
update();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void IOViewer::update()
{
CString buffer;
const IOData *sel = &ioViewRegisters[selected];
u16 data = sel->address ? *sel->address :
(ioMem ? soundRead16(sel->offset) : 0);
for(int i = 0; i < 16; i++) {
CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
if(pWnd) {
if(!(sel->write & (1 << i)))
pWnd->EnableWindow(FALSE);
else
pWnd->EnableWindow(TRUE);
pWnd->SetCheck(((data & (1 << i)) >> i));
buffer.Format("%2d %s", i, sel->bits[i]);
pWnd->SetWindowText(buffer);
}
}
buffer.Format("%04X", data);
m_value.SetWindowText(buffer);
}
void IOViewer::OnApply()
{
const IOData *sel = &ioViewRegisters[selected];
u16 res = 0;
for(int i = 0; i < 16; i++) {
CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
if(pWnd) {
if(pWnd->GetCheck())
res |= (1 << i);
}
}
CPUWriteHalfWord(0x4000000+sel->offset, res);
update();
}
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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.
// IOViewer.cpp : implementation file
//
#include "stdafx.h"
#include "vba.h"
#include "IOViewer.h"
#include "../System.h"
#include "../GBA.h"
#include "../Globals.h"
#include "IOViewerRegs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// IOViewer dialog
IOViewer::IOViewer(CWnd* pParent /*=NULL*/)
: ResizeDlg(IOViewer::IDD, pParent)
{
//{{AFX_DATA_INIT(IOViewer)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
selected = 0;
autoUpdate = false;
}
void IOViewer::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(IOViewer)
DDX_Control(pDX, IDC_VALUE, m_value);
DDX_Control(pDX, IDC_ADDRESSES, m_address);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(IOViewer, CDialog)
//{{AFX_MSG_MAP(IOViewer)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses)
ON_BN_CLICKED(IDC_APPLY, OnApply)
ON_BN_CLICKED(IDC_BIT_0, bitChange)
ON_BN_CLICKED(IDC_BIT_1, bitChange)
ON_BN_CLICKED(IDC_BIT_2, bitChange)
ON_BN_CLICKED(IDC_BIT_3, bitChange)
ON_BN_CLICKED(IDC_BIT_4, bitChange)
ON_BN_CLICKED(IDC_BIT_5, bitChange)
ON_BN_CLICKED(IDC_BIT_6, bitChange)
ON_BN_CLICKED(IDC_BIT_7, bitChange)
ON_BN_CLICKED(IDC_BIT_8, bitChange)
ON_BN_CLICKED(IDC_BIT_9, bitChange)
ON_BN_CLICKED(IDC_BIT_10, bitChange)
ON_BN_CLICKED(IDC_BIT_11, bitChange)
ON_BN_CLICKED(IDC_BIT_12, bitChange)
ON_BN_CLICKED(IDC_BIT_13, bitChange)
ON_BN_CLICKED(IDC_BIT_14, bitChange)
ON_BN_CLICKED(IDC_BIT_15, bitChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// IOViewer message handlers
void IOViewer::OnClose()
{
theApp.winRemoveUpdateListener(this);
DestroyWindow();
}
void IOViewer::bitChange()
{
CString buffer;
u16 data = 0;
for(int i = 0; i < 16; i++) {
CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
if(pWnd) {
if(pWnd->GetCheck())
data |= (1 << i);
}
}
buffer.Format("%04X", data);
m_value.SetWindowText(buffer);
}
void IOViewer::OnRefresh()
{
// TODO: Add your control notification handler code here
update();
}
void IOViewer::OnAutoUpdate()
{
autoUpdate = !autoUpdate;
if(autoUpdate) {
theApp.winAddUpdateListener(this);
} else {
theApp.winRemoveUpdateListener(this);
}
}
void IOViewer::OnSelchangeAddresses()
{
selected = m_address.GetCurSel();
update();
}
void IOViewer::PostNcDestroy()
{
delete this;
}
BOOL IOViewer::OnInitDialog()
{
CDialog::OnInitDialog();
// winCenterWindow(getHandle());
DIALOG_SIZER_START( sz )
DIALOG_SIZER_END()
SetData(sz,
TRUE,
HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\IOView",
NULL);
CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT));
int i;
for(i = 0; i < sizeof(ioViewRegisters)/sizeof(IOData); i++) {
m_address.AddString(ioViewRegisters[i].name);
}
m_address.SetFont(font);
for(i = 0; i < 16; i++) {
GetDlgItem(IDC_BIT_0+i)->SetFont(font);
}
RECT cbSize;
int Height;
m_address.GetClientRect(&cbSize);
Height = m_address.GetItemHeight(0);
Height += m_address.GetItemHeight(0) * (10);
// Note: The use of SM_CYEDGE assumes that we're using Windows '95
// Now add on the height of the border of the edit box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
// The height of the border of the drop-down box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
// now set the size of the window
m_address.SetWindowPos(NULL,
0, 0,
cbSize.right, Height,
SWP_NOMOVE | SWP_NOZORDER);
m_address.SetCurSel(0);
update();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void IOViewer::update()
{
CString buffer;
const IOData *sel = &ioViewRegisters[selected];
u16 data = sel->address ? *sel->address :
(ioMem ? *((u16 *)&ioMem[sel->offset]) : 0);
for(int i = 0; i < 16; i++) {
CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
if(pWnd) {
if(!(sel->write & (1 << i)))
pWnd->EnableWindow(FALSE);
else
pWnd->EnableWindow(TRUE);
pWnd->SetCheck(((data & (1 << i)) >> i));
buffer.Format("%2d %s", i, sel->bits[i]);
pWnd->SetWindowText(buffer);
}
}
buffer.Format("%04X", data);
m_value.SetWindowText(buffer);
}
void IOViewer::OnApply()
{
if(rom != NULL)
{
const IOData *sel = &ioViewRegisters[selected];
u16 res = 0;
for(int i = 0; i < 16; i++) {
CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i);
if(pWnd) {
if(pWnd->GetCheck())
res |= (1 << i);
}
}
CPUWriteHalfWord(0x4000000+sel->offset, res);
update();
}
}

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -37,6 +37,7 @@ class IOViewer : public ResizeDlg, IUpdateListener
// Construction
public:
void update();
void bitChange();
bool autoUpdate;
int selected;
IOViewer(CWnd* pParent = NULL); // standard constructor

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -258,7 +258,7 @@ const IOData ioViewRegisters[] = {
}
},
{
&BG2HOFS, 0x18, "0x4000018-BG8HOFS", 0x01FF,
&BG2HOFS, 0x18, "0x4000018-BG2HOFS", 0x01FF,
{
"",
"",
@ -1119,7 +1119,7 @@ const IOData ioViewRegisters[] = {
}
},
{
NULL, 0x82, "0x4000082-SGCNT0_H", 0xFF1F,
NULL, 0x82, "0x4000082-SGCNT0_H", 0xFF0F,
{
"",
"Sound 1-4 Volume (2 bits)",

View File

@ -22,10 +22,6 @@
#include "../System.h"
#define JOYCONFIG_MESSAGE (WM_USER + 1000)
typedef CList<int,int> KeyList;
//typedef CList<USHORT,USHORT> KeyList;
#define JOYPADS 4
#define MOTION_KEYS 4
#define KEYS_PER_PAD 13
@ -35,6 +31,8 @@ typedef CList<int,int> KeyList;
#define DEVICEOF(key) (key >> 8)
#define KEYOF(key) (key & 255)
typedef CList<LONG_PTR,LONG_PTR> KeyList;
enum {
KEY_LEFT, KEY_RIGHT,
KEY_UP, KEY_DOWN,
@ -46,6 +44,7 @@ enum {
};
class Input {
public:
KeyList joypaddata[JOYPADS * KEYS_PER_PAD + MOTION_KEYS];
@ -56,7 +55,7 @@ class Input {
virtual bool readDevices() = 0;
virtual u32 readDevice(int which) = 0;
virtual CString getKeyName(int key) = 0;
virtual CString getKeyName(LONG_PTR key) = 0;
virtual void checkKeys() = 0;
virtual void checkMotionKeys() = 0;
virtual void checkDevices() = 0;
@ -65,6 +64,4 @@ class Input {
virtual void saveSettings() = 0;
};
#define joypad theApp.input->joypaddata
#endif

View File

@ -43,25 +43,25 @@ void AssignKey(KeyList &Key, int Out)
CString GetKeyListName(KeyList& Keys)
{
CString txtKeys;
POSITION p = Keys.GetHeadPosition();
while(p!=NULL)
{
txtKeys+=theApp.input->getKeyName(Keys.GetNext(p));
if (p!=NULL)
txtKeys+=", ";
}
CString txtKeys;
POSITION p = Keys.GetHeadPosition();
while(p!=NULL)
{
txtKeys+=theApp.input->getKeyName(Keys.GetNext(p));
if (p!=NULL)
txtKeys+=", ";
}
return txtKeys;
}
void CopyKeys(KeyList &Out, KeyList &In)
{
Out.RemoveAll();
POSITION p = In.GetHeadPosition();
while(p!=NULL)
Out.AddTail(In.GetNext(p));
}
POSITION p = In.GetHeadPosition();
while(p!=NULL)
Out.AddTail(In.GetNext(p));
}
#define AssignKeys(in, out) CopyKeys(out, in);
@ -100,6 +100,7 @@ LRESULT JoypadEditControl::OnJoyConfig(WPARAM wParam, LPARAM lParam)
return TRUE;
}
BOOL JoypadEditControl::PreTranslateMessage(MSG *pMsg)
{
if(pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_RETURN))
@ -125,35 +126,33 @@ JoypadConfig::JoypadConfig(int w, CWnd* pParent /*=NULL*/)
void JoypadConfig::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(JoypadConfig)
DDX_Control(pDX, IDC_EDIT_UP, up);
DDX_Control(pDX, IDC_EDIT_SPEED, speed);
DDX_Control(pDX, IDC_EDIT_RIGHT, right);
DDX_Control(pDX, IDC_EDIT_LEFT, left);
DDX_Control(pDX, IDC_EDIT_DOWN, down);
DDX_Control(pDX, IDC_EDIT_CAPTURE, capture);
DDX_Control(pDX, IDC_EDIT_BUTTON_START, buttonStart);
DDX_Control(pDX, IDC_EDIT_BUTTON_SELECT, buttonSelect);
DDX_Control(pDX, IDC_EDIT_BUTTON_R, buttonR);
DDX_Control(pDX, IDC_EDIT_BUTTON_L, buttonL);
DDX_Control(pDX, IDC_EDIT_BUTTON_GS, buttonGS);
DDX_Control(pDX, IDC_EDIT_BUTTON_B, buttonB);
DDX_Control(pDX, IDC_EDIT_BUTTON_A, buttonA);
//}}AFX_DATA_MAP
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(JoypadConfig)
DDX_Control(pDX, IDC_EDIT_UP, up);
DDX_Control(pDX, IDC_EDIT_SPEED, speed);
DDX_Control(pDX, IDC_EDIT_RIGHT, right);
DDX_Control(pDX, IDC_EDIT_LEFT, left);
DDX_Control(pDX, IDC_EDIT_DOWN, down);
DDX_Control(pDX, IDC_EDIT_CAPTURE, capture);
DDX_Control(pDX, IDC_EDIT_BUTTON_START, buttonStart);
DDX_Control(pDX, IDC_EDIT_BUTTON_SELECT, buttonSelect);
DDX_Control(pDX, IDC_EDIT_BUTTON_R, buttonR);
DDX_Control(pDX, IDC_EDIT_BUTTON_L, buttonL);
DDX_Control(pDX, IDC_EDIT_BUTTON_GS, buttonGS);
DDX_Control(pDX, IDC_EDIT_BUTTON_B, buttonB);
DDX_Control(pDX, IDC_EDIT_BUTTON_A, buttonA);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(JoypadConfig, CDialog)
//{{AFX_MSG_MAP(JoypadConfig)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(ID_OK, OnOk)
ON_WM_CHAR()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_APPENDMODE, &JoypadConfig::OnBnClickedAppendmode)
ON_BN_CLICKED(IDC_APPENDMODE, &JoypadConfig::OnBnClickedAppendmode)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@ -166,19 +165,19 @@ void JoypadConfig::OnCancel()
void JoypadConfig::OnOk()
{
AssignKeys(up.m_Keys,joypad[JOYPAD(which,KEY_UP)]);
AssignKeys(speed.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_SPEED)]);
AssignKeys(right.m_Keys,joypad[JOYPAD(which,KEY_RIGHT)]);
AssignKeys(left.m_Keys,joypad[JOYPAD(which,KEY_LEFT)]);
AssignKeys(down.m_Keys,joypad[JOYPAD(which,KEY_DOWN)]);
AssignKeys(capture.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)]);
AssignKeys(buttonStart.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_START)]);
AssignKeys(buttonSelect.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_SELECT)]);
AssignKeys(buttonR.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_R)]);
AssignKeys(buttonL.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_L)]);
AssignKeys(buttonGS.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_GS)]);
AssignKeys(buttonB.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_B)]);
AssignKeys(buttonA.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_A)]);
AssignKeys(up.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_UP)]);
AssignKeys(speed.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SPEED)]);
AssignKeys(right.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_RIGHT)]);
AssignKeys(left.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_LEFT)]);
AssignKeys(down.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_DOWN)]);
AssignKeys(capture.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_CAPTURE)]);
AssignKeys(buttonStart.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_START)]);
AssignKeys(buttonSelect.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SELECT)]);
AssignKeys(buttonR.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_R)]);
AssignKeys(buttonL.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_L)]);
AssignKeys(buttonGS.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_GS)]);
AssignKeys(buttonB.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_B)]);
AssignKeys(buttonA.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_A)]);
theApp.input->checkKeys();
EndDialog(TRUE);
@ -195,7 +194,7 @@ void JoypadConfig::OnDestroy()
KillTimer(timerId);
}
void JoypadConfig::OnTimer(UINT nIDEvent)
void JoypadConfig::OnTimer(UINT_PTR nIDEvent)
{
theApp.input->checkDevices();
@ -212,35 +211,35 @@ BOOL JoypadConfig::OnInitDialog()
bAppendMode = FALSE;
timerId = SetTimer(0,200,NULL);
timerId = SetTimer(0,50,NULL);
CopyKeys(up.m_Keys,joypad[JOYPAD(which,KEY_UP)]);
CopyKeys(speed.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_SPEED)]);
CopyKeys(right.m_Keys,joypad[JOYPAD(which,KEY_RIGHT)]);
CopyKeys(left.m_Keys,joypad[JOYPAD(which,KEY_LEFT)]);
CopyKeys(down.m_Keys,joypad[JOYPAD(which,KEY_DOWN)]);
CopyKeys(capture.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)]);
CopyKeys(buttonStart.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_START)]);
CopyKeys(buttonSelect.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_SELECT)]);
CopyKeys(buttonR.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_R)]);
CopyKeys(buttonL.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_L)]);
CopyKeys(buttonGS.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_GS)]);
CopyKeys(buttonB.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_B)]);
CopyKeys(buttonA.m_Keys,joypad[JOYPAD(which,KEY_BUTTON_A)]);
CopyKeys(up.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_UP)]);
CopyKeys(speed.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SPEED)]);
CopyKeys(right.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_RIGHT)]);
CopyKeys(left.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_LEFT)]);
CopyKeys(down.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_DOWN)]);
CopyKeys(capture.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_CAPTURE)]);
CopyKeys(buttonStart.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_START)]);
CopyKeys(buttonSelect.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SELECT)]);
CopyKeys(buttonR.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_R)]);
CopyKeys(buttonL.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_L)]);
CopyKeys(buttonGS.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_GS)]);
CopyKeys(buttonB.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_B)]);
CopyKeys(buttonA.m_Keys,theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_A)]);
up.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_UP)]));
down.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_DOWN)]));
left.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_LEFT)]));
right.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_RIGHT)]));
buttonA.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_A)]));
buttonB.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_B)]));
buttonL.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_L)]));
buttonR.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_R)]));
buttonSelect.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_SELECT)]));
buttonStart.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_START)]));
speed.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_SPEED)]));
capture.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)]));
buttonGS.SetWindowText(GetKeyListName(joypad[JOYPAD(which,KEY_BUTTON_GS)]));
up.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_UP)]));
down.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_DOWN)]));
left.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_LEFT)]));
right.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_RIGHT)]));
buttonA.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_A)]));
buttonB.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_B)]));
buttonL.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_L)]));
buttonR.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_R)]));
buttonSelect.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SELECT)]));
buttonStart.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_START)]));
speed.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SPEED)]));
capture.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_CAPTURE)]));
buttonGS.SetWindowText(GetKeyListName(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_GS)]));
CenterWindow();
@ -248,47 +247,47 @@ BOOL JoypadConfig::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
void JoypadConfig::assignKey(int id, int key)
void JoypadConfig::assignKey(int id, LONG_PTR key)
{
switch(id) {
case IDC_EDIT_LEFT:
AssignKey(joypad[JOYPAD(which,KEY_LEFT)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_LEFT)],key);
break;
case IDC_EDIT_RIGHT:
AssignKey(joypad[JOYPAD(which,KEY_RIGHT)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_RIGHT)],key);
break;
case IDC_EDIT_UP:
AssignKey(joypad[JOYPAD(which,KEY_UP)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_UP)],key);
break;
case IDC_EDIT_SPEED:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_SPEED)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SPEED)],key);
break;
case IDC_EDIT_CAPTURE:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_CAPTURE)],key);
break;
case IDC_EDIT_DOWN:
AssignKey(joypad[JOYPAD(which,KEY_DOWN)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_DOWN)],key);
break;
case IDC_EDIT_BUTTON_A:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_A)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_A)],key);
break;
case IDC_EDIT_BUTTON_B:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_B)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_B)],key);
break;
case IDC_EDIT_BUTTON_L:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_L)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_L)],key);
break;
case IDC_EDIT_BUTTON_R:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_R)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_R)],key);
break;
case IDC_EDIT_BUTTON_START:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_START)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_START)],key);
break;
case IDC_EDIT_BUTTON_SELECT:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_SELECT)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_SELECT)],key);
break;
case IDC_EDIT_BUTTON_GS:
AssignKey(joypad[JOYPAD(which,KEY_BUTTON_GS)],key);
AssignKey(theApp.input->joypaddata[JOYPAD(which,KEY_BUTTON_GS)],key);
break;
}
}
@ -322,15 +321,12 @@ void MotionConfig::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(MotionConfig, CDialog)
//{{AFX_MSG_MAP(MotionConfig)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(ID_OK, OnOk)
ON_WM_CHAR()
ON_WM_DESTROY()
ON_WM_KEYDOWN()
ON_WM_TIMER()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_APPENDMODE, &MotionConfig::OnBnClickedAppendmode)
ON_BN_CLICKED(IDC_APPENDMODE, &MotionConfig::OnBnClickedAppendmode)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@ -343,16 +339,11 @@ void MotionConfig::OnCancel()
void MotionConfig::OnOk()
{
assignKeys();
theApp.input->checkKeys();
EndDialog( TRUE);
}
void MotionConfig::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
}
void MotionConfig::OnDestroy()
{
CDialog::OnDestroy();
@ -360,24 +351,23 @@ void MotionConfig::OnDestroy()
KillTimer(timerId);
}
BOOL MotionConfig::OnInitDialog()
{
CDialog::OnInitDialog();
timerId = SetTimer(0,200,NULL);
timerId = SetTimer(0,50,NULL);
CopyKeys(up.m_Keys, joypad[MOTION(KEY_UP)]);
up.SetWindowText(GetKeyListName(joypad[MOTION(KEY_UP)]));
CopyKeys(up.m_Keys, theApp.input->joypaddata[MOTION(KEY_UP)]);
up.SetWindowText(GetKeyListName(theApp.input->joypaddata[MOTION(KEY_UP)]));
CopyKeys(down.m_Keys, joypad[MOTION(KEY_DOWN)]);
down.SetWindowText(GetKeyListName(joypad[MOTION(KEY_DOWN)]));
CopyKeys(down.m_Keys, theApp.input->joypaddata[MOTION(KEY_DOWN)]);
down.SetWindowText(GetKeyListName(theApp.input->joypaddata[MOTION(KEY_DOWN)]));
CopyKeys(left.m_Keys, joypad[MOTION(KEY_LEFT)]);
left.SetWindowText(GetKeyListName(joypad[MOTION(KEY_LEFT)]));
CopyKeys(left.m_Keys, theApp.input->joypaddata[MOTION(KEY_LEFT)]);
left.SetWindowText(GetKeyListName(theApp.input->joypaddata[MOTION(KEY_LEFT)]));
CopyKeys(right.m_Keys, joypad[MOTION(KEY_RIGHT)]);
right.SetWindowText(GetKeyListName(joypad[MOTION(KEY_RIGHT)]));
CopyKeys(right.m_Keys, theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
right.SetWindowText(GetKeyListName(theApp.input->joypaddata[MOTION(KEY_RIGHT)]));
CenterWindow();
@ -400,16 +390,16 @@ void MotionConfig::assignKey(int id, int key)
{
switch(id) {
case IDC_EDIT_LEFT:
AssignKey(joypad[MOTION(KEY_LEFT)],key);
AssignKey(theApp.input->joypaddata[MOTION(KEY_LEFT)],key);
break;
case IDC_EDIT_RIGHT:
AssignKey(joypad[MOTION(KEY_RIGHT)],key);
AssignKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)],key);
break;
case IDC_EDIT_UP:
AssignKey(joypad[MOTION(KEY_UP)],key);
AssignKey(theApp.input->joypaddata[MOTION(KEY_UP)],key);
break;
case IDC_EDIT_DOWN:
AssignKey(joypad[MOTION(KEY_DOWN)],key);
AssignKey(theApp.input->joypaddata[MOTION(KEY_DOWN)],key);
break;
}
}
@ -430,13 +420,13 @@ void MotionConfig::assignKeys()
id = IDC_EDIT_RIGHT;
assignKey(id, GetWindowLong(right, GWL_USERDATA));
}
void JoypadConfig::OnBnClickedAppendmode()
{
bAppendMode = (::SendMessage(GetDlgItem(IDC_APPENDMODE)->GetSafeHwnd(), BM_GETCHECK, 0, 0L) != 0);
}
void MotionConfig::OnBnClickedAppendmode()
{
bAppendMode = (::SendMessage(GetDlgItem(IDC_APPENDMODE)->GetSafeHwnd(), BM_GETCHECK, 0, 0L) != 0);
}
void JoypadConfig::OnBnClickedAppendmode()
{
bAppendMode = (::SendMessage(GetDlgItem(IDC_APPENDMODE)->GetSafeHwnd(), BM_GETCHECK, 0, 0L) != 0);
}
void MotionConfig::OnBnClickedAppendmode()
{
bAppendMode = (::SendMessage(GetDlgItem(IDC_APPENDMODE)->GetSafeHwnd(), BM_GETCHECK, 0, 0L) != 0);
}

View File

@ -1,176 +1,176 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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 "afxwin.h"
#if !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_)
#define AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Joypad.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// JoypadEditControl window
class JoypadEditControl : public CEdit
{
// Construction
public:
JoypadEditControl();
KeyList m_Keys;
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(JoypadEditControl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual BOOL PreTranslateMessage(MSG *pMsg);
afx_msg LRESULT OnJoyConfig(WPARAM wParam, LPARAM lParam);
virtual ~JoypadEditControl();
// Generated message map functions
protected:
//{{AFX_MSG(JoypadEditControl)
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// JoypadConfig dialog
class JoypadConfig : public CDialog
{
// Construction
public:
void assignKey(int id, int key);
JoypadConfig(int w, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(JoypadConfig)
enum { IDD = IDD_CONFIG };
JoypadEditControl up;
JoypadEditControl speed;
JoypadEditControl right;
JoypadEditControl left;
JoypadEditControl down;
JoypadEditControl capture;
JoypadEditControl buttonStart;
JoypadEditControl buttonSelect;
JoypadEditControl buttonR;
JoypadEditControl buttonL;
JoypadEditControl buttonGS;
JoypadEditControl buttonB;
JoypadEditControl buttonA;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(JoypadConfig)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
UINT timerId;
int which;
// Generated message map functions
//{{AFX_MSG(JoypadConfig)
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
#if !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_)
#define AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Joypad.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// JoypadEditControl window
class JoypadEditControl : public CEdit
{
// Construction
public:
JoypadEditControl();
KeyList m_Keys;
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(JoypadEditControl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual BOOL PreTranslateMessage(MSG *pMsg);
afx_msg LRESULT OnJoyConfig(WPARAM wParam, LPARAM lParam);
virtual ~JoypadEditControl();
// Generated message map functions
protected:
//{{AFX_MSG(JoypadEditControl)
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// JoypadConfig dialog
class JoypadConfig : public CDialog
{
// Construction
public:
void assignKey(int id, LONG_PTR key);
JoypadConfig(int w, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(JoypadConfig)
enum { IDD = IDD_CONFIG };
JoypadEditControl up;
JoypadEditControl speed;
JoypadEditControl right;
JoypadEditControl left;
JoypadEditControl down;
JoypadEditControl capture;
JoypadEditControl buttonStart;
JoypadEditControl buttonSelect;
JoypadEditControl buttonR;
JoypadEditControl buttonL;
JoypadEditControl buttonGS;
JoypadEditControl buttonB;
JoypadEditControl buttonA;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(JoypadConfig)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
UINT timerId;
int which;
// Generated message map functions
//{{AFX_MSG(JoypadConfig)
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedAppendmode();
};
/////////////////////////////////////////////////////////////////////////////
// MotionConfig dialog
class MotionConfig : public CDialog
{
// Construction
public:
void assignKeys();
void assignKey(int id, int key);
MotionConfig(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(MotionConfig)
enum { IDD = IDD_MOTION_CONFIG };
JoypadEditControl up;
JoypadEditControl right;
JoypadEditControl left;
JoypadEditControl down;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(MotionConfig)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(MotionConfig)
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDestroy();
virtual BOOL OnInitDialog();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
UINT timerId;
};
/////////////////////////////////////////////////////////////////////////////
// MotionConfig dialog
class MotionConfig : public CDialog
{
// Construction
public:
void assignKeys();
void assignKey(int id, int key);
MotionConfig(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(MotionConfig)
enum { IDD = IDD_MOTION_CONFIG };
JoypadEditControl up;
JoypadEditControl right;
JoypadEditControl left;
JoypadEditControl down;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(MotionConfig)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(MotionConfig)
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDestroy();
virtual BOOL OnInitDialog();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
UINT timerId;
public:
afx_msg void OnBnClickedAppendmode();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_)
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_)

View File

@ -1,6 +1,6 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2005 Forgotten and the VBA 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
@ -225,7 +225,7 @@ BOOL Logging::OnInitDialog()
m_dma2 = (systemVerbose & 64) != 0;
m_dma3 = (systemVerbose & 128) != 0;
m_undefined = (systemVerbose & 256) != 0;
m_agbprint = (systemVerbose & 256) != 0;
m_agbprint = (systemVerbose & 512) != 0;
UpdateData(FALSE);
m_log.LimitText(-1);
@ -237,7 +237,7 @@ BOOL Logging::OnInitDialog()
void Logging::log(const char *s)
{
int size = ::SendMessage(m_log, WM_GETTEXTLENGTH, 0, 0);
DWORD size = (DWORD)::SendMessage(m_log, WM_GETTEXTLENGTH, 0, 0);
m_log.SetSel(size, size);
m_log.ReplaceSel(s);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,442 +1,446 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA 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.
#if !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_)
#define AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MainWnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// MainWnd window
class MainWnd : public CWnd
{
// Construction
public:
MainWnd();
// Attributes
public:
// Operations
public:
bool FileRun();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(MainWnd)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
// Implementation
public:
HCURSOR arrow;
void winMouseOn();
void screenCapture(int captureNumber);
HACCEL m_hAccelTable;
bool fileOpenSelect();
afx_msg LRESULT OnConfirmMode(WPARAM, LPARAM);
afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM);
afx_msg void OnUpdateFileLoadGameSlot(CCmdUI *pCmdUI);
afx_msg void OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI);
afx_msg void OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsJoypadAutofire(UINT nID);
afx_msg void OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsJoypadDefault(UINT nID);
afx_msg void OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsFilterIFB(UINT nID);
afx_msg void OnUpdateOptionsFilter(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsFilter(UINT nID);
afx_msg void OnUpdateOptionsPriority(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsPriority(UINT nID);
afx_msg void OnSetFocus(CWnd * pOldWnd);
afx_msg void OnKillFocus(CWnd * pNewWnd);
void updateSoundChannels(UINT nID);
afx_msg void OnUpdateOptionsSoundVolume(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsSoundVolume(UINT nID);
afx_msg void OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsEmulatorShowSpeed(UINT nID);
afx_msg void OnSystemMinimize();
afx_msg void OnUpdateVideoLayer(CCmdUI* pCmdUI);
afx_msg BOOL OnVideoLayer(UINT nID);
void winConfirmMode();
afx_msg BOOL OnOptionVideoSize(UINT nID);
afx_msg BOOL OnOptionsFrameskip(UINT nID);
bool fileImportGSACodeFile(CString& fileName);
bool writeSaveGame(const char *name);
bool loadSaveGame(const char *name);
CString winLoadFilter(UINT id);
void winLoadCheatList(const char *name);
void winLoadCheatListDefault();
void readBatteryFile();
void writeBatteryFile();
bool isDriveRoot(CString& file);
CString getDirFromFile(CString& file);
void winSaveCheatList(const char *name);
void winSaveCheatListDefault();
virtual ~MainWnd();
// Generated message map functions
protected:
//{{AFX_MSG(MainWnd)
afx_msg void OnClose();
afx_msg void OnHelpAbout();
afx_msg void OnHelpFaq();
afx_msg void OnFileOpen();
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg void OnFilePause();
afx_msg void OnUpdateFilePause(CCmdUI* pCmdUI);
afx_msg void OnFileReset();
afx_msg void OnUpdateFileReset(CCmdUI* pCmdUI);
afx_msg void OnUpdateFileRecentFreeze(CCmdUI* pCmdUI);
afx_msg void OnFileRecentReset();
afx_msg void OnFileRecentFreeze();
afx_msg void OnFileExit();
afx_msg void OnFileClose();
afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
afx_msg void OnFileOpengameboy();
afx_msg void OnFileLoad();
afx_msg void OnUpdateFileLoad(CCmdUI* pCmdUI);
afx_msg void OnFileSave();
afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
afx_msg void OnFileImportBatteryfile();
afx_msg void OnUpdateFileImportBatteryfile(CCmdUI* pCmdUI);
afx_msg void OnFileImportGamesharkcodefile();
afx_msg void OnUpdateFileImportGamesharkcodefile(CCmdUI* pCmdUI);
afx_msg void OnFileImportGamesharksnapshot();
afx_msg void OnUpdateFileImportGamesharksnapshot(CCmdUI* pCmdUI);
afx_msg void OnFileExportBatteryfile();
afx_msg void OnUpdateFileExportBatteryfile(CCmdUI* pCmdUI);
afx_msg void OnFileExportGamesharksnapshot();
afx_msg void OnUpdateFileExportGamesharksnapshot(CCmdUI* pCmdUI);
afx_msg void OnFileScreencapture();
afx_msg void OnUpdateFileScreencapture(CCmdUI* pCmdUI);
afx_msg void OnFileRominformation();
afx_msg void OnUpdateFileRominformation(CCmdUI* pCmdUI);
afx_msg void OnFileTogglemenu();
afx_msg void OnUpdateFileTogglemenu(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI);
afx_msg void OnOptionsFrameskipThrottleNothrottle();
afx_msg void OnOptionsFrameskipThrottle25();
afx_msg void OnOptionsFrameskipThrottle50();
afx_msg void OnOptionsFrameskipThrottle100();
afx_msg void OnOptionsFrameskipThrottle150();
afx_msg void OnOptionsFrameskipThrottle200();
afx_msg void OnOptionsFrameskipThrottleOther();
afx_msg void OnOptionsFrameskipAutomatic();
afx_msg void OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoVsync();
afx_msg void OnUpdateOptionsVideoVsync(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX1(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX2(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX3(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX4(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen320x240(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen640x480(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen800x600(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoFullscreen320x240();
afx_msg void OnOptionsVideoFullscreen640x480();
afx_msg void OnOptionsVideoFullscreen800x600();
afx_msg void OnOptionsVideoFullscreen();
afx_msg void OnUpdateOptionsVideoFullscreen(CCmdUI* pCmdUI);
afx_msg void OnMove(int x, int y);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnOptionsVideoDisablesfx();
afx_msg void OnUpdateOptionsVideoDisablesfx(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoFullscreenstretchtofit();
afx_msg void OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodGdi();
afx_msg void OnUpdateOptionsVideoRendermethodGdi(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodDirectdraw();
afx_msg void OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodDirect3d();
afx_msg void OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodOpengl();
afx_msg void OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoTriplebuffering();
afx_msg void OnUpdateOptionsVideoTriplebuffering(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoDdrawemulationonly();
afx_msg void OnUpdateOptionsVideoDdrawemulationonly(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoDdrawusevideomemory();
afx_msg void OnUpdateOptionsVideoDdrawusevideomemory(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsD3dnofilter();
afx_msg void OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsD3dbilinear();
afx_msg void OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlnearest();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlbilinear();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGltriangle();
afx_msg void OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlquads();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnOptionsEmulatorAssociate();
afx_msg void OnOptionsEmulatorDirectories();
afx_msg void OnOptionsEmulatorDisablestatusmessages();
afx_msg void OnUpdateOptionsEmulatorDisablestatusmessages(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSynchronize();
afx_msg void OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorPausewheninactive();
afx_msg void OnUpdateOptionsEmulatorPausewheninactive(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSpeeduptoggle();
afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorRemoveintrosgba();
afx_msg void OnUpdateOptionsEmulatorRemoveintrosgba(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAutomaticallyipspatch();
afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAgbprint();
afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorRealtimeclock();
afx_msg void OnUpdateOptionsEmulatorRealtimeclock(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAutohidemenu();
afx_msg void OnUpdateOptionsEmulatorAutohidemenu(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorRewindinterval();
afx_msg void OnOptionsEmulatorSavetypeAutomatic();
afx_msg void OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeEeprom();
afx_msg void OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeSram();
afx_msg void OnUpdateOptionsEmulatorSavetypeSram(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeFlash();
afx_msg void OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeEepromsensor();
afx_msg void OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeNone();
afx_msg void OnUpdateOptionsEmulatorSavetypeNone(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeFlash512k();
afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeFlash1m();
afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorUsebiosfile();
afx_msg void OnUpdateOptionsEmulatorUsebiosfile(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSkipbios();
afx_msg void OnUpdateOptionsEmulatorSkipbios(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSelectbiosfile();
afx_msg void OnOptionsEmulatorPngformat();
afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorBmpformat();
afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundOff(); /* mute hax */
afx_msg void OnUpdateOptionsSoundOff(CCmdUI* pCmdUI); /* mute hax */
afx_msg void OnOptionsSoundMute();
afx_msg void OnUpdateOptionsSoundMute(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundOn();
afx_msg void OnUpdateOptionsSoundOn(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundUseoldsynchronization();
afx_msg void OnUpdateOptionsSoundUseoldsynchronization(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundEcho();
afx_msg void OnUpdateOptionsSoundEcho(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundLowpassfilter();
afx_msg void OnUpdateOptionsSoundLowpassfilter(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundReversestereo();
afx_msg void OnUpdateOptionsSoundReversestereo(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound11khz();
afx_msg void OnUpdateOptionsSound11khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound22khz();
afx_msg void OnUpdateOptionsSound22khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound44khz();
afx_msg void OnUpdateOptionsSound44khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel1();
afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel2();
afx_msg void OnUpdateOptionsSoundChannel2(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel3();
afx_msg void OnUpdateOptionsSoundChannel3(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel4();
afx_msg void OnUpdateOptionsSoundChannel4(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundDirectsounda();
afx_msg void OnUpdateOptionsSoundDirectsounda(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundDirectsoundb();
afx_msg void OnUpdateOptionsSoundDirectsoundb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyBorder();
afx_msg void OnUpdateOptionsGameboyBorder(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyPrinter();
afx_msg void OnUpdateOptionsGameboyPrinter(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyBorderAutomatic();
afx_msg void OnUpdateOptionsGameboyBorderAutomatic(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyAutomatic();
afx_msg void OnUpdateOptionsGameboyAutomatic(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyGba();
afx_msg void OnUpdateOptionsGameboyGba(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyCgb();
afx_msg void OnUpdateOptionsGameboyCgb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboySgb();
afx_msg void OnUpdateOptionsGameboySgb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboySgb2();
afx_msg void OnUpdateOptionsGameboySgb2(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyGb();
afx_msg void OnUpdateOptionsGameboyGb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyRealcolors();
afx_msg void OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyGameboycolors();
afx_msg void OnUpdateOptionsGameboyGameboycolors(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyColors();
afx_msg void OnOptionsFilterDisablemmx();
afx_msg void OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI);
afx_msg void OnOptionsLanguageSystem();
afx_msg void OnUpdateOptionsLanguageSystem(CCmdUI* pCmdUI);
afx_msg void OnOptionsLanguageEnglish();
afx_msg void OnUpdateOptionsLanguageEnglish(CCmdUI* pCmdUI);
afx_msg void OnOptionsLanguageOther();
afx_msg void OnUpdateOptionsLanguageOther(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure1();
afx_msg void OnUpdateOptionsJoypadConfigure1(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure2();
afx_msg void OnUpdateOptionsJoypadConfigure2(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure3();
afx_msg void OnUpdateOptionsJoypadConfigure3(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure4();
afx_msg void OnUpdateOptionsJoypadConfigure4(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadMotionconfigure();
afx_msg void OnUpdateOptionsJoypadMotionconfigure(CCmdUI* pCmdUI);
afx_msg void OnCheatsSearchforcheats();
afx_msg void OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI);
afx_msg void OnCheatsCheatlist();
afx_msg void OnUpdateCheatsCheatlist(CCmdUI* pCmdUI);
afx_msg void OnCheatsAutomaticsaveloadcheats();
afx_msg void OnCheatsLoadcheatlist();
afx_msg void OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI);
afx_msg void OnCheatsSavecheatlist();
afx_msg void OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI);
afx_msg void OnToolsDisassemble();
afx_msg void OnUpdateToolsDisassemble(CCmdUI* pCmdUI);
afx_msg void OnToolsLogging();
afx_msg void OnUpdateToolsLogging(CCmdUI* pCmdUI);
afx_msg void OnToolsIoviewer();
afx_msg void OnUpdateToolsIoviewer(CCmdUI* pCmdUI);
afx_msg void OnToolsMapview();
afx_msg void OnUpdateToolsMapview(CCmdUI* pCmdUI);
afx_msg void OnToolsMemoryviewer();
afx_msg void OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI);
afx_msg void OnToolsOamviewer();
afx_msg void OnUpdateToolsOamviewer(CCmdUI* pCmdUI);
afx_msg void OnToolsPaletteview();
afx_msg void OnUpdateToolsPaletteview(CCmdUI* pCmdUI);
afx_msg void OnToolsTileviewer();
afx_msg void OnUpdateToolsTileviewer(CCmdUI* pCmdUI);
afx_msg void OnDebugNextframe();
afx_msg void OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugGdb();
afx_msg void OnUpdateToolsDebugGdb(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugLoadandwait();
afx_msg void OnUpdateToolsDebugLoadandwait(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugBreak();
afx_msg void OnUpdateToolsDebugBreak(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugDisconnect();
afx_msg void OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundStartrecording();
afx_msg void OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundStoprecording();
afx_msg void OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI);
afx_msg void OnToolsRecordStartavirecording();
afx_msg void OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI);
afx_msg void OnToolsRecordStopavirecording();
afx_msg void OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI);
afx_msg void OnPaint();
afx_msg void OnToolsRecordStartmovierecording();
afx_msg void OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI);
afx_msg void OnToolsRecordStopmovierecording();
afx_msg void OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI);
afx_msg void OnToolsPlayStartmovieplaying();
afx_msg void OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI);
afx_msg void OnToolsPlayStopmovieplaying();
afx_msg void OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI);
afx_msg void OnToolsRewind();
afx_msg void OnUpdateToolsRewind(CCmdUI* pCmdUI);
afx_msg void OnToolsCustomize();
afx_msg void OnUpdateToolsCustomize(CCmdUI* pCmdUI);
afx_msg void OnHelpBugreport();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnInitMenu(CMenu* pMenu);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
#if _MSC_VER <= 1200
afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
#else
afx_msg void OnActivateApp(BOOL bActive, DWORD hTask);
#endif
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnFileSavegameOldestslot();
afx_msg void OnUpdateFileSavegameOldestslot(CCmdUI* pCmdUI);
afx_msg void OnFileLoadgameMostrecent();
afx_msg void OnUpdateFileLoadgameMostrecent(CCmdUI* pCmdUI);
afx_msg void OnFileLoadgameAutoloadmostrecent();
afx_msg void OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundVolume25x();
afx_msg void OnUpdateOptionsSoundVolume25x(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundVolume5x();
afx_msg void OnUpdateOptionsSoundVolume5x(CCmdUI* pCmdUI);
afx_msg void OnCheatsDisablecheats();
afx_msg void OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoFullscreenmaxscale();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
afx_msg BOOL OnFileRecentFile(UINT nID);
afx_msg BOOL OnFileLoadSlot(UINT nID);
afx_msg BOOL OnFileSaveSlot(UINT nID);
afx_msg void OnOptionsFilterLcdcolors();
afx_msg void OnUpdateOptionsFilterLcdcolors(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsSoundPcminterpolation(UINT nID);
afx_msg void OnUpdateOptionsSoundPcminterpolation(CCmdUI *pCmdUI);
public:
afx_msg void OnOptionsVideoFullscreen1280x1024();
afx_msg void OnOptionsVideoFullscreen1024x768();
afx_msg void OnUpdateOptionsVideoFullscreen1024x768(CCmdUI *pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen1280x1024(CCmdUI *pCmdUI);
void OnLinkOptions();
void OnOptionsLinkLog() ;
void OnUpdateOptionsLinkLog(CCmdUI* pCmdUI) ;
void OnOptionsLinkRFU() ;
void OnUpdateOptionsLinkRFU(CCmdUI* pCmdUI) ;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_)
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA 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.
#if !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_)
#define AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MainWnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// MainWnd window
class MainWnd : public CWnd
{
// Construction
public:
MainWnd();
// Attributes
public:
// Operations
public:
bool FileRun();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(MainWnd)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
// Implementation
public:
HCURSOR arrow;
void winMouseOn();
void screenCapture(int captureNumber);
HACCEL m_hAccelTable;
bool fileOpenSelect( bool gb = false );
afx_msg LRESULT OnConfirmMode(WPARAM, LPARAM);
afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM);
afx_msg void OnUpdateFileLoadGameSlot(CCmdUI *pCmdUI);
afx_msg void OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI);
afx_msg void OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsJoypadAutofire(UINT nID);
afx_msg void OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsJoypadDefault(UINT nID);
afx_msg void OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsFilterIFB(UINT nID);
afx_msg void OnUpdateOptionsFilter(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsFilter(UINT nID);
afx_msg void OnUpdateOptionsPriority(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsPriority(UINT nID);
void updateSoundChannels(UINT nID);
afx_msg void OnUpdateOptionsSoundVolume(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsSoundVolume(UINT nID);
afx_msg void OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsEmulatorShowSpeed(UINT nID);
afx_msg void OnSystemMinimize();
afx_msg void OnUpdateVideoLayer(CCmdUI* pCmdUI);
afx_msg BOOL OnVideoLayer(UINT nID);
void winConfirmMode();
afx_msg BOOL OnOptionVideoSize(UINT nID);
afx_msg BOOL OnOptionsFrameskip(UINT nID);
bool fileImportGSACodeFile(CString& fileName);
bool writeSaveGame(const char *name);
bool loadSaveGame(const char *name);
CString winLoadFilter(UINT id);
void winLoadCheatList(const char *name);
void winLoadCheatListDefault();
void readBatteryFile();
void writeBatteryFile();
bool isDriveRoot(CString& file);
CString getDirFromFile(CString& file);
void winSaveCheatList(const char *name);
void winSaveCheatListDefault();
virtual ~MainWnd();
// Generated message map functions
protected:
//{{AFX_MSG(MainWnd)
afx_msg void OnClose();
afx_msg void OnHelpAbout();
afx_msg void OnHelpFaq();
afx_msg void OnFileOpen();
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg void OnFilePause();
afx_msg void OnUpdateFilePause(CCmdUI* pCmdUI);
afx_msg void OnFileReset();
afx_msg void OnUpdateFileReset(CCmdUI* pCmdUI);
afx_msg void OnUpdateFileRecentFreeze(CCmdUI* pCmdUI);
afx_msg void OnFileRecentReset();
afx_msg void OnFileRecentFreeze();
afx_msg void OnFileExit();
afx_msg void OnFileClose();
afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
afx_msg void OnFileOpengameboy();
afx_msg void OnFileLoad();
afx_msg void OnUpdateFileLoad(CCmdUI* pCmdUI);
afx_msg void OnFileSave();
afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
afx_msg void OnFileImportBatteryfile();
afx_msg void OnUpdateFileImportBatteryfile(CCmdUI* pCmdUI);
afx_msg void OnFileImportGamesharkcodefile();
afx_msg void OnUpdateFileImportGamesharkcodefile(CCmdUI* pCmdUI);
afx_msg void OnFileImportGamesharksnapshot();
afx_msg void OnUpdateFileImportGamesharksnapshot(CCmdUI* pCmdUI);
afx_msg void OnFileExportBatteryfile();
afx_msg void OnUpdateFileExportBatteryfile(CCmdUI* pCmdUI);
afx_msg void OnFileExportGamesharksnapshot();
afx_msg void OnUpdateFileExportGamesharksnapshot(CCmdUI* pCmdUI);
afx_msg void OnFileScreencapture();
afx_msg void OnUpdateFileScreencapture(CCmdUI* pCmdUI);
afx_msg void OnFileRominformation();
afx_msg void OnUpdateFileRominformation(CCmdUI* pCmdUI);
afx_msg void OnFileTogglemenu();
afx_msg void OnUpdateFileTogglemenu(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI);
afx_msg void OnOptionsFrameskipThrottleNothrottle();
afx_msg void OnOptionsFrameskipThrottle25();
afx_msg void OnOptionsFrameskipThrottle50();
afx_msg void OnOptionsFrameskipThrottle100();
afx_msg void OnOptionsFrameskipThrottle150();
afx_msg void OnOptionsFrameskipThrottle200();
afx_msg void OnOptionsFrameskipThrottleOther();
afx_msg void OnOptionsFrameskipAutomatic();
afx_msg void OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoVsync();
afx_msg void OnUpdateOptionsVideoVsync(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX1(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX2(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX3(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoX4(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen320x240(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen640x480(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen800x600(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoFullscreen320x240();
afx_msg void OnOptionsVideoFullscreen640x480();
afx_msg void OnOptionsVideoFullscreen800x600();
afx_msg void OnOptionsVideoFullscreen();
afx_msg void OnUpdateOptionsVideoFullscreen(CCmdUI* pCmdUI);
afx_msg void OnMove(int x, int y);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnOptionsVideoDisablesfx();
afx_msg void OnUpdateOptionsVideoDisablesfx(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoFullscreenstretchtofit();
afx_msg void OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodGdi();
afx_msg void OnUpdateOptionsVideoRendermethodGdi(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodDirectdraw();
afx_msg void OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodDirect3d();
afx_msg void OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRendermethodOpengl();
afx_msg void OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoTriplebuffering();
afx_msg void OnUpdateOptionsVideoTriplebuffering(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoDdrawemulationonly();
afx_msg void OnUpdateOptionsVideoDdrawemulationonly(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoDdrawusevideomemory();
afx_msg void OnUpdateOptionsVideoDdrawusevideomemory(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsD3dnofilter();
afx_msg void OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsD3dbilinear();
afx_msg void OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlnearest();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlbilinear();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGltriangle();
afx_msg void OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlquads();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsSelectskin();
afx_msg void OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsSkin();
afx_msg void OnUpdateOptionsVideoRenderoptionsSkin(CCmdUI* pCmdUI);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnOptionsEmulatorAssociate();
afx_msg void OnOptionsEmulatorDirectories();
afx_msg void OnOptionsEmulatorDisablestatusmessages();
afx_msg void OnUpdateOptionsEmulatorDisablestatusmessages(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSynchronize();
afx_msg void OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorPausewheninactive();
afx_msg void OnUpdateOptionsEmulatorPausewheninactive(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSpeeduptoggle();
afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAutomaticallyipspatch();
afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAgbprint();
afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorRealtimeclock();
afx_msg void OnUpdateOptionsEmulatorRealtimeclock(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorGenericflashcard();
afx_msg void OnUpdateOptionsEmulatorGenericflashcard(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorAutohidemenu();
afx_msg void OnUpdateOptionsEmulatorAutohidemenu(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorRewindinterval();
afx_msg void OnOptionsEmulatorSavetypeAutomatic();
afx_msg void OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeEeprom();
afx_msg void OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeSram();
afx_msg void OnUpdateOptionsEmulatorSavetypeSram(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeFlash();
afx_msg void OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeEepromsensor();
afx_msg void OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeNone();
afx_msg void OnUpdateOptionsEmulatorSavetypeNone(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeFlash512k();
afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSavetypeFlash1m();
afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorUsebiosfile();
afx_msg void OnUpdateOptionsEmulatorUsebiosfile(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSkipbios();
afx_msg void OnUpdateOptionsEmulatorSkipbios(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorSelectbiosfile();
afx_msg void OnOptionsEmulatorPngformat();
afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorBmpformat();
afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundOff();
afx_msg void OnUpdateOptionsSoundOff(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundMute();
afx_msg void OnUpdateOptionsSoundMute(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundOn();
afx_msg void OnUpdateOptionsSoundOn(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundUseoldsynchronization();
afx_msg void OnUpdateOptionsSoundUseoldsynchronization(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundEcho();
afx_msg void OnUpdateOptionsSoundEcho(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundLowpassfilter();
afx_msg void OnUpdateOptionsSoundLowpassfilter(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundReversestereo();
afx_msg void OnUpdateOptionsSoundReversestereo(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound11khz();
afx_msg void OnUpdateOptionsSound11khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound22khz();
afx_msg void OnUpdateOptionsSound22khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound44khz();
afx_msg void OnUpdateOptionsSound44khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel1();
afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel2();
afx_msg void OnUpdateOptionsSoundChannel2(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel3();
afx_msg void OnUpdateOptionsSoundChannel3(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel4();
afx_msg void OnUpdateOptionsSoundChannel4(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundDirectsounda();
afx_msg void OnUpdateOptionsSoundDirectsounda(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundDirectsoundb();
afx_msg void OnUpdateOptionsSoundDirectsoundb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyBorder();
afx_msg void OnUpdateOptionsGameboyBorder(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyPrinter();
afx_msg void OnUpdateOptionsGameboyPrinter(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyBorderAutomatic();
afx_msg void OnUpdateOptionsGameboyBorderAutomatic(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyAutomatic();
afx_msg void OnUpdateOptionsGameboyAutomatic(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyGba();
afx_msg void OnUpdateOptionsGameboyGba(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyCgb();
afx_msg void OnUpdateOptionsGameboyCgb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboySgb();
afx_msg void OnUpdateOptionsGameboySgb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboySgb2();
afx_msg void OnUpdateOptionsGameboySgb2(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyGb();
afx_msg void OnUpdateOptionsGameboyGb(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyRealcolors();
afx_msg void OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyGameboycolors();
afx_msg void OnUpdateOptionsGameboyGameboycolors(CCmdUI* pCmdUI);
afx_msg void OnOptionsGameboyColors();
afx_msg void OnOptionsFilterDisablemmx();
afx_msg void OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI);
afx_msg void OnOptionsLanguageSystem();
afx_msg void OnUpdateOptionsLanguageSystem(CCmdUI* pCmdUI);
afx_msg void OnOptionsLanguageEnglish();
afx_msg void OnUpdateOptionsLanguageEnglish(CCmdUI* pCmdUI);
afx_msg void OnOptionsLanguageOther();
afx_msg void OnUpdateOptionsLanguageOther(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure1();
afx_msg void OnUpdateOptionsJoypadConfigure1(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure2();
afx_msg void OnUpdateOptionsJoypadConfigure2(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure3();
afx_msg void OnUpdateOptionsJoypadConfigure3(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadConfigure4();
afx_msg void OnUpdateOptionsJoypadConfigure4(CCmdUI* pCmdUI);
afx_msg void OnOptionsJoypadMotionconfigure();
afx_msg void OnUpdateOptionsJoypadMotionconfigure(CCmdUI* pCmdUI);
afx_msg void OnCheatsSearchforcheats();
afx_msg void OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI);
afx_msg void OnCheatsCheatlist();
afx_msg void OnUpdateCheatsCheatlist(CCmdUI* pCmdUI);
afx_msg void OnCheatsAutomaticsaveloadcheats();
afx_msg void OnCheatsLoadcheatlist();
afx_msg void OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI);
afx_msg void OnCheatsSavecheatlist();
afx_msg void OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI);
afx_msg void OnToolsDisassemble();
afx_msg void OnUpdateToolsDisassemble(CCmdUI* pCmdUI);
afx_msg void OnToolsLogging();
afx_msg void OnUpdateToolsLogging(CCmdUI* pCmdUI);
afx_msg void OnToolsIoviewer();
afx_msg void OnUpdateToolsIoviewer(CCmdUI* pCmdUI);
afx_msg void OnToolsMapview();
afx_msg void OnUpdateToolsMapview(CCmdUI* pCmdUI);
afx_msg void OnToolsMemoryviewer();
afx_msg void OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI);
afx_msg void OnToolsOamviewer();
afx_msg void OnUpdateToolsOamviewer(CCmdUI* pCmdUI);
afx_msg void OnToolsPaletteview();
afx_msg void OnUpdateToolsPaletteview(CCmdUI* pCmdUI);
afx_msg void OnToolsTileviewer();
afx_msg void OnUpdateToolsTileviewer(CCmdUI* pCmdUI);
afx_msg void OnDebugNextframe();
afx_msg void OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugGdb();
afx_msg void OnUpdateToolsDebugGdb(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugLoadandwait();
afx_msg void OnUpdateToolsDebugLoadandwait(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugBreak();
afx_msg void OnUpdateToolsDebugBreak(CCmdUI* pCmdUI);
afx_msg void OnToolsDebugDisconnect();
afx_msg void OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundStartrecording();
afx_msg void OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundStoprecording();
afx_msg void OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI);
afx_msg void OnToolsRecordStartavirecording();
afx_msg void OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI);
afx_msg void OnToolsRecordStopavirecording();
afx_msg void OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI);
afx_msg void OnPaint();
afx_msg void OnToolsRecordStartmovierecording();
afx_msg void OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI);
afx_msg void OnToolsRecordStopmovierecording();
afx_msg void OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI);
afx_msg void OnToolsPlayStartmovieplaying();
afx_msg void OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI);
afx_msg void OnToolsPlayStopmovieplaying();
afx_msg void OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI);
afx_msg void OnToolsRewind();
afx_msg void OnUpdateToolsRewind(CCmdUI* pCmdUI);
afx_msg void OnToolsCustomize();
afx_msg void OnUpdateToolsCustomize(CCmdUI* pCmdUI);
afx_msg void OnHelpBugreport();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnInitMenu(CMenu* pMenu);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
#if _MSC_VER <= 1200
afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
#else
afx_msg void OnActivateApp(BOOL bActive, DWORD hTask);
#endif
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnFileSavegameOldestslot();
afx_msg void OnUpdateFileSavegameOldestslot(CCmdUI* pCmdUI);
afx_msg void OnFileLoadgameMostrecent();
afx_msg void OnUpdateFileLoadgameMostrecent(CCmdUI* pCmdUI);
afx_msg void OnFileLoadgameAutoloadmostrecent();
afx_msg void OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundVolume25x();
afx_msg void OnUpdateOptionsSoundVolume25x(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundVolume5x();
afx_msg void OnUpdateOptionsSoundVolume5x(CCmdUI* pCmdUI);
afx_msg void OnCheatsDisablecheats();
afx_msg void OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoFullscreenmaxscale();
afx_msg void OnOptionsEmulatorGameoverrides();
afx_msg void OnUpdateOptionsEmulatorGameoverrides(CCmdUI* pCmdUI);
afx_msg void OnHelpGnupubliclicense();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
afx_msg BOOL OnFileRecentFile(UINT nID);
afx_msg BOOL OnFileLoadSlot(UINT nID);
afx_msg BOOL OnFileSaveSlot(UINT nID);
afx_msg void OnOptionsFilterLcdcolors();
afx_msg void OnUpdateOptionsFilterLcdcolors(CCmdUI *pCmdUI);
afx_msg BOOL OnOptionsSoundPcminterpolation(UINT nID);
afx_msg void OnUpdateOptionsSoundPcminterpolation(CCmdUI *pCmdUI);
public:
afx_msg void OnOptionsSoundHardwareacceleration();
afx_msg void OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI);
afx_msg void OnOptionsVideoFullscreen1280x1024();
afx_msg void OnOptionsVideoFullscreen1024x768();
afx_msg void OnUpdateOptionsVideoFullscreen1024x768(CCmdUI *pCmdUI);
afx_msg void OnUpdateOptionsVideoFullscreen1280x1024(CCmdUI *pCmdUI);
void OnLinkOptions();
void OnOptionsLinkLog() ;
void OnUpdateOptionsLinkLog(CCmdUI* pCmdUI) ;
void OnOptionsLinkRFU() ;
void OnUpdateOptionsLinkRFU(CCmdUI* pCmdUI) ;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_)

File diff suppressed because it is too large Load Diff

View File

@ -44,3 +44,9 @@ void MainWnd::OnHelpBugreport()
dlg.DoModal();
}
void MainWnd::OnHelpGnupubliclicense()
{
::ShellExecute(0, _T("open"), "http://www.gnu.org/licenses/gpl.html",
0, 0, SW_SHOWNORMAL);
}

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@ static char THIS_FILE[] = __FILE__;
extern bool debugger;
extern int emulating;
extern int remoteSocket;
extern SOCKET remoteSocket;
extern void remoteCleanUp();
extern void remoteSetSockets(SOCKET, SOCKET);
@ -205,7 +205,7 @@ void MainWnd::OnToolsDebugGdb()
remoteSetSockets(wait.getListenSocket(), wait.getSocket());
debugger = true;
emulating = 1;
theApp.cartridgeType = 0;
theApp.cartridgeType = IMAGE_GBA;
theApp.filename = "\\gnu_stub";
rom = (u8 *)malloc(0x2000000);
workRAM = (u8 *)calloc(1, 0x40000);
@ -214,7 +214,7 @@ void MainWnd::OnToolsDebugGdb()
paletteRAM = (u8 *)calloc(1,0x400);
vram = (u8 *)calloc(1, 0x20000);
oam = (u8 *)calloc(1, 0x400);
pix = (u8 *)calloc(1, 4 * 240 * 160);
pix = (u8 *)calloc(1, 4 * 241 * 162);
ioMem = (u8 *)calloc(1, 0x400);
theApp.emulator = GBASystem;

Some files were not shown because too many files have changed in this diff Show More