Renamed GB to DMG, fixed makefiles and vc project files to accomodate this change

This commit is contained in:
squall_leonhart69r 2008-02-27 13:33:37 +00:00
parent 1479e11435
commit df3ae15cac
38 changed files with 13634 additions and 13514 deletions

View File

@ -58,8 +58,8 @@ endif
MAINDIR=src MAINDIR=src
SDLDIR=src/sdl SDLDIR=src/sdl
DMGDIR=src/gb DMGDIR=src/dmg
GBAPUDIR=src/gb/gb_apu GBAPUDIR=src/dmg/gb_apu
FEXDIR=../dependencies/File_Extractor-0.4.3 FEXDIR=../dependencies/File_Extractor-0.4.3
HQCDIR=src/hq/c HQCDIR=src/hq/c
HQASMDIR=src/hq/asm HQASMDIR=src/hq/asm

View File

@ -726,66 +726,66 @@
Name="GB" Name="GB"
> >
<File <File
RelativePath=".\src\gb\gb.cpp" RelativePath=".\src\dmg\gb.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCheats.cpp" RelativePath=".\src\dmg\gbCheats.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbDis.cpp" RelativePath=".\src\dmg\gbDis.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbGfx.cpp" RelativePath=".\src\dmg\gbGfx.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbGlobals.cpp" RelativePath=".\src\dmg\gbGlobals.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbMemory.cpp" RelativePath=".\src\dmg\gbMemory.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbPrinter.cpp" RelativePath=".\src\dmg\gbPrinter.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSGB.cpp" RelativePath=".\src\dmg\gbSGB.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSound.cpp" RelativePath=".\src\dmg\gbSound.cpp"
> >
</File> </File>
<Filter <Filter
Name="GB APU" Name="GB APU"
> >
<File <File
RelativePath=".\src\gb\gb_apu\Blip_Buffer.cpp" RelativePath=".\src\dmg\gb_apu\Blip_Buffer.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Effects_Buffer.cpp" RelativePath=".\src\dmg\gb_apu\Effects_Buffer.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Gb_Apu.cpp" RelativePath=".\src\dmg\gb_apu\Gb_Apu.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Gb_Apu_State.cpp" RelativePath=".\src\dmg\gb_apu\Gb_Apu_State.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Gb_Oscs.cpp" RelativePath=".\src\dmg\gb_apu\Gb_Oscs.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Multi_Buffer.cpp" RelativePath=".\src\dmg\gb_apu\Multi_Buffer.cpp"
> >
</File> </File>
</Filter> </Filter>
@ -1156,74 +1156,74 @@
Name="GB" Name="GB"
> >
<File <File
RelativePath=".\src\gb\gb.h" RelativePath=".\src\dmg\gb.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCheats.h" RelativePath=".\src\dmg\gbCheats.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCodes.h" RelativePath=".\src\dmg\gbCodes.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCodesCB.h" RelativePath=".\src\dmg\gbCodesCB.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbGlobals.h" RelativePath=".\src\dmg\gbGlobals.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbMemory.h" RelativePath=".\src\dmg\gbMemory.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbPrinter.h" RelativePath=".\src\dmg\gbPrinter.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSGB.h" RelativePath=".\src\dmg\gbSGB.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSound.h" RelativePath=".\src\dmg\gbSound.h"
> >
</File> </File>
<Filter <Filter
Name="GB APU" Name="GB APU"
> >
<File <File
RelativePath=".\src\gb\gb_apu\blargg_common.h" RelativePath=".\src\dmg\gb_apu\blargg_common.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\blargg_config.h" RelativePath=".\src\dmg\gb_apu\blargg_config.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\blargg_source.h" RelativePath=".\src\dmg\gb_apu\blargg_source.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Blip_Buffer.h" RelativePath=".\src\dmg\gb_apu\Blip_Buffer.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Effects_Buffer.h" RelativePath=".\src\dmg\gb_apu\Effects_Buffer.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Gb_Apu.h" RelativePath=".\src\dmg\gb_apu\Gb_Apu.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Gb_Oscs.h" RelativePath=".\src\dmg\gb_apu\Gb_Oscs.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gb_apu\Multi_Buffer.h" RelativePath=".\src\dmg\gb_apu\Multi_Buffer.h"
> >
</File> </File>
</Filter> </Filter>

View File

@ -974,39 +974,39 @@
Name="GB" Name="GB"
> >
<File <File
RelativePath=".\src\gb\gb.cpp" RelativePath=".\src\dmg\gb.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCheats.cpp" RelativePath=".\src\dmg\gbCheats.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbDis.cpp" RelativePath=".\src\dmg\gbDis.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbGfx.cpp" RelativePath=".\src\dmg\gbGfx.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbGlobals.cpp" RelativePath=".\src\dmg\gbGlobals.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbMemory.cpp" RelativePath=".\src\dmg\gbMemory.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbPrinter.cpp" RelativePath=".\src\dmg\gbPrinter.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSGB.cpp" RelativePath=".\src\dmg\gbSGB.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSound.cpp" RelativePath=".\src\dmg\gbSound.cpp"
> >
</File> </File>
</Filter> </Filter>
@ -1372,39 +1372,39 @@
Name="GB" Name="GB"
> >
<File <File
RelativePath=".\src\gb\gb.h" RelativePath=".\src\dmg\gb.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCheats.h" RelativePath=".\src\dmg\gbCheats.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCodes.h" RelativePath=".\src\dmg\gbCodes.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbCodesCB.h" RelativePath=".\src\dmg\gbCodesCB.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbGlobals.h" RelativePath=".\src\dmg\gbGlobals.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbMemory.h" RelativePath=".\src\dmg\gbMemory.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbPrinter.h" RelativePath=".\src\dmg\gbPrinter.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSGB.h" RelativePath=".\src\dmg\gbSGB.h"
> >
</File> </File>
<File <File
RelativePath=".\src\gb\gbSound.h" RelativePath=".\src\dmg\gbSound.h"
> >
</File> </File>
</Filter> </Filter>

1
src/agb/placeholder.txt Normal file
View File

@ -0,0 +1 @@
AGB files will go here once src folder is cleaned up.

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,64 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005-2006 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 // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef VBA_GB_GB_H #ifndef VBA_GB_GB_H
#define VBA_GB_GB_H #define VBA_GB_GB_H
#define C_FLAG 0x10 #define C_FLAG 0x10
#define H_FLAG 0x20 #define H_FLAG 0x20
#define N_FLAG 0x40 #define N_FLAG 0x40
#define Z_FLAG 0x80 #define Z_FLAG 0x80
typedef union { typedef union {
struct { struct {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
u8 B1, B0; u8 B1, B0;
#else #else
u8 B0,B1; u8 B0,B1;
#endif #endif
} B; } B;
u16 W; u16 W;
} gbRegister; } gbRegister;
extern bool gbLoadRom(const char *); extern bool gbLoadRom(const char *);
extern void gbEmulate(int); extern void gbEmulate(int);
extern void gbWriteMemory(register u16, register u8); extern void gbWriteMemory(register u16, register u8);
extern void gbDrawLine(); extern void gbDrawLine();
extern bool gbIsGameboyRom(const char *); extern bool gbIsGameboyRom(const char *);
extern void gbSoundReset(); extern void gbSoundReset();
extern void gbSoundSetQuality(int); extern void gbSoundSetQuality(int);
extern void gbGetHardwareType(); extern void gbGetHardwareType();
extern void gbReset(); extern void gbReset();
extern void gbCleanUp(); extern void gbCleanUp();
extern void gbCPUInit(const char *,bool); extern void gbCPUInit(const char *,bool);
extern bool gbWriteBatteryFile(const char *); extern bool gbWriteBatteryFile(const char *);
extern bool gbWriteBatteryFile(const char *, bool); extern bool gbWriteBatteryFile(const char *, bool);
extern bool gbReadBatteryFile(const char *); extern bool gbReadBatteryFile(const char *);
extern bool gbWriteSaveState(const char *); extern bool gbWriteSaveState(const char *);
extern bool gbWriteMemSaveState(char *, int); extern bool gbWriteMemSaveState(char *, int);
extern bool gbReadSaveState(const char *); extern bool gbReadSaveState(const char *);
extern bool gbReadMemSaveState(char *, int); extern bool gbReadMemSaveState(char *, int);
extern void gbSgbRenderBorder(); extern void gbSgbRenderBorder();
extern bool gbWritePNGFile(const char *); extern bool gbWritePNGFile(const char *);
extern bool gbWriteBMPFile(const char *); extern bool gbWriteBMPFile(const char *);
extern bool gbReadGSASnapshot(const char *); extern bool gbReadGSASnapshot(const char *);
extern struct EmulatedSystem GBSystem; extern struct EmulatedSystem GBSystem;
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +1,62 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __VBA_GB_GBCHEATS_H #ifndef __VBA_GB_GBCHEATS_H
#define __VBA_GB_GBCHEATS_H #define __VBA_GB_GBCHEATS_H
#include "../System.h" #include "../System.h"
struct gbXxCheat { struct gbXxCheat {
char cheatDesc[100]; char cheatDesc[100];
char cheatCode[20]; char cheatCode[20];
}; };
struct gbCheat { struct gbCheat {
char cheatCode[20]; char cheatCode[20];
char cheatDesc[32]; char cheatDesc[32];
u16 address; u16 address;
int code; int code;
u8 compare; u8 compare;
u8 value; u8 value;
bool enabled; bool enabled;
}; };
void gbCheatsSaveGame(gzFile); void gbCheatsSaveGame(gzFile);
void gbCheatsReadGame(gzFile, int); void gbCheatsReadGame(gzFile, int);
void gbCheatsSaveCheatList(const char *); void gbCheatsSaveCheatList(const char *);
bool gbCheatsLoadCheatList(const char *); bool gbCheatsLoadCheatList(const char *);
bool gbCheatReadGSCodeFile(const char *); bool gbCheatReadGSCodeFile(const char *);
bool gbAddGsCheat(const char *, const char*); bool gbAddGsCheat(const char *, const char*);
bool gbAddGgCheat(const char *, const char*); bool gbAddGgCheat(const char *, const char*);
void gbCheatRemove(int); void gbCheatRemove(int);
void gbCheatRemoveAll(); void gbCheatRemoveAll();
void gbCheatEnable(int); void gbCheatEnable(int);
void gbCheatDisable(int); void gbCheatDisable(int);
u8 gbCheatRead(u16); u8 gbCheatRead(u16);
void gbCheatWrite(bool); void gbCheatWrite(bool);
bool gbVerifyGsCode(const char *code); bool gbVerifyGsCode(const char *code);
bool gbVerifyGgCode(const char *code); bool gbVerifyGgCode(const char *code);
extern int gbCheatNumber; extern int gbCheatNumber;
extern gbCheat gbCheatList[100]; extern gbCheat gbCheatList[100];
extern bool gbCheatMap[0x10000]; extern bool gbCheatMap[0x10000];
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,249 +1,249 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "../System.h" #include "../System.h"
#include "gbGlobals.h" #include "gbGlobals.h"
typedef struct { typedef struct {
u8 mask; u8 mask;
u8 value; u8 value;
const char *mnen; const char *mnen;
} GBOPCODE; } GBOPCODE;
#define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff] #define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff]
static const char *registers[] = static const char *registers[] =
{ "B", "C", "D", "E", "H", "L", "(HL)", "A" }; { "B", "C", "D", "E", "H", "L", "(HL)", "A" };
static const char *registers16[] = static const char *registers16[] =
{ "BC", "DE", "HL", "SP", // for some operations { "BC", "DE", "HL", "SP", // for some operations
"BC", "DE", "HL", "AF" }; // for push/pop "BC", "DE", "HL", "AF" }; // for push/pop
static const char *cond[] = static const char *cond[] =
{ "NZ", "Z", "NC", "C" }; { "NZ", "Z", "NC", "C" };
static char hexDigits[16] = { static char hexDigits[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
}; };
static GBOPCODE opcodes[] = { static GBOPCODE opcodes[] = {
{ 0xff, 0x00, "NOP" }, { 0xff, 0x00, "NOP" },
{ 0xcf, 0x01, "LD %R4,%W" }, { 0xcf, 0x01, "LD %R4,%W" },
{ 0xff, 0x02, "LD (BC),A" }, { 0xff, 0x02, "LD (BC),A" },
{ 0xcf, 0x03, "INC %R4" }, { 0xcf, 0x03, "INC %R4" },
{ 0xc7, 0x04, "INC %r3" }, { 0xc7, 0x04, "INC %r3" },
{ 0xc7, 0x05, "DEC %r3" }, { 0xc7, 0x05, "DEC %r3" },
{ 0xc7, 0x06, "LD %r3,%B" }, { 0xc7, 0x06, "LD %r3,%B" },
{ 0xff, 0x07, "RLCA" }, { 0xff, 0x07, "RLCA" },
{ 0xff, 0x08, "LD (%W),SP" }, { 0xff, 0x08, "LD (%W),SP" },
{ 0xcf, 0x09, "ADD HL,%R4" }, { 0xcf, 0x09, "ADD HL,%R4" },
{ 0xff, 0x0a, "LD A,(BC)" }, { 0xff, 0x0a, "LD A,(BC)" },
{ 0xcf, 0x0b, "DEC %R4" }, { 0xcf, 0x0b, "DEC %R4" },
{ 0xff, 0x0f, "RRCA" }, { 0xff, 0x0f, "RRCA" },
{ 0xff, 0x10, "STOP" }, { 0xff, 0x10, "STOP" },
{ 0xff, 0x12, "LD (DE),A" }, { 0xff, 0x12, "LD (DE),A" },
{ 0xff, 0x17, "RLA" }, { 0xff, 0x17, "RLA" },
{ 0xff, 0x18, "JR %d" }, { 0xff, 0x18, "JR %d" },
{ 0xff, 0x1a, "LD A,(DE)" }, { 0xff, 0x1a, "LD A,(DE)" },
{ 0xff, 0x1f, "RRA" }, { 0xff, 0x1f, "RRA" },
{ 0xe7, 0x20, "JR %c3,%d" }, { 0xe7, 0x20, "JR %c3,%d" },
{ 0xff, 0x22, "LDI (HL),A" }, { 0xff, 0x22, "LDI (HL),A" },
{ 0xff, 0x27, "DAA" }, { 0xff, 0x27, "DAA" },
{ 0xff, 0x2a, "LDI A,(HL)" }, { 0xff, 0x2a, "LDI A,(HL)" },
{ 0xff, 0x2f, "CPL" }, { 0xff, 0x2f, "CPL" },
{ 0xff, 0x32, "LDD (HL),A" }, { 0xff, 0x32, "LDD (HL),A" },
{ 0xff, 0x37, "SCF" }, { 0xff, 0x37, "SCF" },
{ 0xff, 0x3a, "LDD A,(HL)" }, { 0xff, 0x3a, "LDD A,(HL)" },
{ 0xff, 0x3f, "CCF" }, { 0xff, 0x3f, "CCF" },
{ 0xff, 0x76, "HALT" }, { 0xff, 0x76, "HALT" },
{ 0xc0, 0x40, "LD %r3,%r0" }, { 0xc0, 0x40, "LD %r3,%r0" },
{ 0xf8, 0x80, "ADD A,%r0" }, { 0xf8, 0x80, "ADD A,%r0" },
{ 0xf8, 0x88, "ADC A,%r0" }, { 0xf8, 0x88, "ADC A,%r0" },
{ 0xf8, 0x90, "SUB %r0" }, { 0xf8, 0x90, "SUB %r0" },
{ 0xf8, 0x98, "SBC A,%r0" }, { 0xf8, 0x98, "SBC A,%r0" },
{ 0xf8, 0xa0, "AND %r0" }, { 0xf8, 0xa0, "AND %r0" },
{ 0xf8, 0xa8, "XOR %r0" }, { 0xf8, 0xa8, "XOR %r0" },
{ 0xf8, 0xb0, "OR %r0" }, { 0xf8, 0xb0, "OR %r0" },
{ 0xf8, 0xb8, "CP %r0" }, { 0xf8, 0xb8, "CP %r0" },
{ 0xe7, 0xc0, "RET %c3" }, { 0xe7, 0xc0, "RET %c3" },
{ 0xcf, 0xc1, "POP %t4" }, { 0xcf, 0xc1, "POP %t4" },
{ 0xe7, 0xc2, "JP %c3,%W" }, { 0xe7, 0xc2, "JP %c3,%W" },
{ 0xff, 0xc3, "JP %W" }, { 0xff, 0xc3, "JP %W" },
{ 0xe7, 0xc4, "CALL %c3,%W" }, { 0xe7, 0xc4, "CALL %c3,%W" },
{ 0xcf, 0xc5, "PUSH %t4" }, { 0xcf, 0xc5, "PUSH %t4" },
{ 0xff, 0xc6, "ADD A,%B" }, { 0xff, 0xc6, "ADD A,%B" },
{ 0xc7, 0xc7, "RST %P" }, { 0xc7, 0xc7, "RST %P" },
{ 0xff, 0xc9, "RET" }, { 0xff, 0xc9, "RET" },
{ 0xff, 0xcd, "CALL %W" }, { 0xff, 0xcd, "CALL %W" },
{ 0xff, 0xce, "ADC %B" }, { 0xff, 0xce, "ADC %B" },
{ 0xff, 0xd6, "SUB %B" }, { 0xff, 0xd6, "SUB %B" },
{ 0xff, 0xd9, "RETI" }, { 0xff, 0xd9, "RETI" },
{ 0xff, 0xde, "SBC %B" }, { 0xff, 0xde, "SBC %B" },
{ 0xff, 0xe0, "LD (FF%B),A" }, { 0xff, 0xe0, "LD (FF%B),A" },
{ 0xff, 0xe2, "LD (FF00h+C),A" }, { 0xff, 0xe2, "LD (FF00h+C),A" },
{ 0xff, 0xe6, "AND %B" }, { 0xff, 0xe6, "AND %B" },
{ 0xff, 0xe8, "ADD SP,%D" }, { 0xff, 0xe8, "ADD SP,%D" },
{ 0xff, 0xe9, "LD PC,HL" }, { 0xff, 0xe9, "LD PC,HL" },
{ 0xff, 0xea, "LD (%W),A" }, { 0xff, 0xea, "LD (%W),A" },
{ 0xff, 0xee, "XOR %B" }, { 0xff, 0xee, "XOR %B" },
{ 0xff, 0xf0, "LD A,(FF%B)" }, { 0xff, 0xf0, "LD A,(FF%B)" },
{ 0xff, 0xf2, "LD A,(FF00h+C)" }, { 0xff, 0xf2, "LD A,(FF00h+C)" },
{ 0xff, 0xf3, "DI" }, { 0xff, 0xf3, "DI" },
{ 0xff, 0xf6, "OR %B" }, { 0xff, 0xf6, "OR %B" },
{ 0xff, 0xf8, "LD HL,SP%D" }, { 0xff, 0xf8, "LD HL,SP%D" },
{ 0xff, 0xf9, "LD SP,HL" }, { 0xff, 0xf9, "LD SP,HL" },
{ 0xff, 0xfa, "LD A,(%W)" }, { 0xff, 0xfa, "LD A,(%W)" },
{ 0xff, 0xfb, "EI" }, { 0xff, 0xfb, "EI" },
{ 0xff, 0xfe, "CP %B" }, { 0xff, 0xfe, "CP %B" },
{ 0x00, 0x00, "DB %B" } { 0x00, 0x00, "DB %B" }
}; };
static GBOPCODE cbOpcodes[] = { static GBOPCODE cbOpcodes[] = {
{ 0xf8, 0x00, "RLC %r0" }, { 0xf8, 0x00, "RLC %r0" },
{ 0xf8, 0x08, "RRC %r0" }, { 0xf8, 0x08, "RRC %r0" },
{ 0xf8, 0x10, "RL %r0" }, { 0xf8, 0x10, "RL %r0" },
{ 0xf8, 0x18, "RR %r0" }, { 0xf8, 0x18, "RR %r0" },
{ 0xf8, 0x20, "SLA %r0" }, { 0xf8, 0x20, "SLA %r0" },
{ 0xf8, 0x28, "SRA %r0" }, { 0xf8, 0x28, "SRA %r0" },
{ 0xf8, 0x30, "SWAP %r0" }, { 0xf8, 0x30, "SWAP %r0" },
{ 0xf8, 0x38, "SRL %r0" }, { 0xf8, 0x38, "SRL %r0" },
{ 0xc0, 0x40, "BIT %b,%r0" }, { 0xc0, 0x40, "BIT %b,%r0" },
{ 0xc0, 0x80, "RES %b,%r0" }, { 0xc0, 0x80, "RES %b,%r0" },
{ 0xc0, 0xc0, "SET %b,%r0" }, { 0xc0, 0xc0, "SET %b,%r0" },
{ 0x00, 0x00, "DB CBh,%B" } { 0x00, 0x00, "DB CBh,%B" }
}; };
static char *addHex(char *p, u8 value) static char *addHex(char *p, u8 value)
{ {
*p++ = hexDigits[value >> 4]; *p++ = hexDigits[value >> 4];
*p++ = hexDigits[value & 15]; *p++ = hexDigits[value & 15];
return p; return p;
} }
static char *addHex16(char *p, u16 value) static char *addHex16(char *p, u16 value)
{ {
p = addHex(p, value>>8); p = addHex(p, value>>8);
return addHex(p, value & 255); return addHex(p, value & 255);
} }
static char *addStr(char *p, const char *s) static char *addStr(char *p, const char *s)
{ {
while(*s) { while(*s) {
*p++ = *s++; *p++ = *s++;
} }
return p; return p;
} }
int gbDis(char *buffer, u16 address) int gbDis(char *buffer, u16 address)
{ {
char *p = buffer; char *p = buffer;
int instr = 1; int instr = 1;
u16 addr = address; u16 addr = address;
sprintf(p, "%04x ", address); sprintf(p, "%04x ", address);
p += 12; p += 12;
u8 opcode = GB_READ(address); u8 opcode = GB_READ(address);
address++; address++;
const char *mnen; const char *mnen;
GBOPCODE *op; GBOPCODE *op;
if(opcode == 0xcb) { if(opcode == 0xcb) {
opcode = GB_READ(address); opcode = GB_READ(address);
address++; address++;
instr++; instr++;
op = cbOpcodes; op = cbOpcodes;
} else { } else {
op = opcodes; op = opcodes;
} }
while(op->value != (opcode & op->mask)) op++; while(op->value != (opcode & op->mask)) op++;
mnen = op->mnen; mnen = op->mnen;
u8 b0, b1; u8 b0, b1;
s8 disp; s8 disp;
int shift; int shift;
while(*mnen) { while(*mnen) {
if(*mnen == '%') { if(*mnen == '%') {
mnen++; mnen++;
switch(*mnen++) { switch(*mnen++) {
case 'W': case 'W':
b0 = GB_READ(address); b0 = GB_READ(address);
address++; address++;
b1 = GB_READ(address); b1 = GB_READ(address);
address++; address++;
p = addHex16(p, b0|b1<<8); p = addHex16(p, b0|b1<<8);
instr += 2; instr += 2;
*p++ = 'h'; *p++ = 'h';
break; break;
case 'B': case 'B':
p = addHex(p, GB_READ(address)); p = addHex(p, GB_READ(address));
*p++ = 'h'; *p++ = 'h';
address++; address++;
instr++; instr++;
break; break;
case 'D': case 'D':
disp = GB_READ(address); disp = GB_READ(address);
if(disp >= 0) if(disp >= 0)
*p++ = '+'; *p++ = '+';
p += sprintf(p, "%d", disp); p += sprintf(p, "%d", disp);
instr++; instr++;
break; break;
case 'd': case 'd':
disp = GB_READ(address); disp = GB_READ(address);
address++; address++;
p = addHex16(p, address+disp); p = addHex16(p, address+disp);
*p++ = 'h'; *p++ = 'h';
instr++; instr++;
break; break;
case 'b': case 'b':
// kind of a hack, but it works :-) // kind of a hack, but it works :-)
*p++ = hexDigits[(opcode >> 3) & 7]; *p++ = hexDigits[(opcode >> 3) & 7];
break; break;
case 'r': case 'r':
shift = *mnen++ - '0'; shift = *mnen++ - '0';
p = addStr(p, registers[(opcode >> shift) & 7]); p = addStr(p, registers[(opcode >> shift) & 7]);
break; break;
case 'R': case 'R':
shift = *mnen++ - '0'; shift = *mnen++ - '0';
p = addStr(p, registers16[(opcode >> shift) & 3]); p = addStr(p, registers16[(opcode >> shift) & 3]);
break; break;
case 't': case 't':
shift = *mnen++ - '0'; shift = *mnen++ - '0';
p = addStr(p, registers16[4+((opcode >> shift) & 3)]); p = addStr(p, registers16[4+((opcode >> shift) & 3)]);
break; break;
case 'P': case 'P':
p = addHex(p, ((opcode >> 3) & 7) * 8); p = addHex(p, ((opcode >> 3) & 7) * 8);
break; break;
case 'c': case 'c':
shift = *mnen++ - '0'; shift = *mnen++ - '0';
p = addStr(p, cond[(opcode >> shift) & 3]); p = addStr(p, cond[(opcode >> shift) & 3]);
break; break;
} }
} else } else
*p++ = *mnen++; *p++ = *mnen++;
} }
for(int i = 0; i < instr; i++) { for(int i = 0; i < instr; i++) {
u16 a = addr + i; u16 a = addr + i;
addHex(buffer+5+i*2, GB_READ(a)); addHex(buffer+5+i*2, GB_READ(a));
} }
*p = 0; *p = 0;
return instr; return instr;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,57 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005-2006 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 // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../GBA.h" #include "../GBA.h"
u8 *gbMemoryMap[16]; u8 *gbMemoryMap[16];
int gbRomSizeMask = 0; int gbRomSizeMask = 0;
int gbRomSize = 0; int gbRomSize = 0;
int gbRamSizeMask = 0; int gbRamSizeMask = 0;
int gbRamSize = 0; int gbRamSize = 0;
int gbTAMA5ramSize = 0; int gbTAMA5ramSize = 0;
u8 *gbMemory = NULL; u8 *gbMemory = NULL;
u8 *gbVram = NULL; u8 *gbVram = NULL;
u8 *gbRom = NULL; u8 *gbRom = NULL;
u8 *gbRam = NULL; u8 *gbRam = NULL;
u8 *gbWram = NULL; u8 *gbWram = NULL;
u16 *gbLineBuffer = NULL; u16 *gbLineBuffer = NULL;
u8 *gbTAMA5ram = NULL; u8 *gbTAMA5ram = NULL;
u16 gbPalette[128]; u16 gbPalette[128];
u8 gbBgp[4] = { 0, 1, 2, 3}; u8 gbBgp[4] = { 0, 1, 2, 3};
u8 gbObp0[4] = { 0, 1, 2, 3}; u8 gbObp0[4] = { 0, 1, 2, 3};
u8 gbObp1[4] = { 0, 1, 2, 3}; u8 gbObp1[4] = { 0, 1, 2, 3};
int gbWindowLine = -1; int gbWindowLine = -1;
bool genericflashcardEnable = false; bool genericflashcardEnable = false;
int gbCgbMode = 0; int gbCgbMode = 0;
u16 gbColorFilter[32768]; u16 gbColorFilter[32768];
int gbColorOption = 0; int gbColorOption = 0;
int gbPaletteOption = 0; int gbPaletteOption = 0;
int gbEmulatorType = 0; int gbEmulatorType = 0;
int gbBorderOn = 1; int gbBorderOn = 1;
int gbBorderAutomatic = 0; int gbBorderAutomatic = 0;
int gbBorderLineSkip = 160; int gbBorderLineSkip = 160;
int gbBorderRowSkip = 0; int gbBorderRowSkip = 0;
int gbBorderColumnSkip = 0; int gbBorderColumnSkip = 0;
int gbDmaTicks = 0; int gbDmaTicks = 0;
u8 (*gbSerialFunction)(u8) = NULL; u8 (*gbSerialFunction)(u8) = NULL;

View File

@ -1,89 +1,89 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005-2006 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 // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int gbRomSizeMask; extern int gbRomSizeMask;
extern int gbRomSize; extern int gbRomSize;
extern int gbRamSize; extern int gbRamSize;
extern int gbRamSizeMask; extern int gbRamSizeMask;
extern int gbTAMA5ramSize; extern int gbTAMA5ramSize;
extern bool useBios; extern bool useBios;
extern bool skipBios; extern bool skipBios;
extern u8 *bios; extern u8 *bios;
extern u8 *gbRom; extern u8 *gbRom;
extern u8 *gbRam; extern u8 *gbRam;
extern u8 *gbVram; extern u8 *gbVram;
extern u8 *gbWram; extern u8 *gbWram;
extern u8 *gbMemory; extern u8 *gbMemory;
extern u16 *gbLineBuffer; extern u16 *gbLineBuffer;
extern u8 *gbTAMA5ram; extern u8 *gbTAMA5ram;
extern u8 *gbMemoryMap[16]; extern u8 *gbMemoryMap[16];
extern int gbFrameSkip; extern int gbFrameSkip;
extern u16 gbColorFilter[32768]; extern u16 gbColorFilter[32768];
extern int gbColorOption; extern int gbColorOption;
extern int gbPaletteOption; extern int gbPaletteOption;
extern int gbEmulatorType; extern int gbEmulatorType;
extern int gbBorderOn; extern int gbBorderOn;
extern int gbBorderAutomatic; extern int gbBorderAutomatic;
extern int gbCgbMode; extern int gbCgbMode;
extern int gbSgbMode; extern int gbSgbMode;
extern int gbWindowLine; extern int gbWindowLine;
extern int gbSpeed; extern int gbSpeed;
extern u8 gbBgp[4]; extern u8 gbBgp[4];
extern u8 gbObp0[4]; extern u8 gbObp0[4];
extern u8 gbObp1[4]; extern u8 gbObp1[4];
extern u16 gbPalette[128]; extern u16 gbPalette[128];
extern bool gbScreenOn; extern bool gbScreenOn;
extern bool gbDrawWindow; extern bool gbDrawWindow;
extern u8 gbSCYLine[300]; extern u8 gbSCYLine[300];
// gbSCXLine is used for the emulation (bug) of the SX change // gbSCXLine is used for the emulation (bug) of the SX change
// found in the Artic Zone game. // found in the Artic Zone game.
extern u8 gbSCXLine[300]; extern u8 gbSCXLine[300];
// gbBgpLine is used for the emulation of the // gbBgpLine is used for the emulation of the
// Prehistorik Man's title screen scroller. // Prehistorik Man's title screen scroller.
extern u8 gbBgpLine[300]; extern u8 gbBgpLine[300];
extern u8 gbObp0Line [300]; extern u8 gbObp0Line [300];
extern u8 gbObp1Line [300]; extern u8 gbObp1Line [300];
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam. // gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
extern u8 gbSpritesTicks[300]; extern u8 gbSpritesTicks[300];
extern u8 register_LCDC; extern u8 register_LCDC;
extern u8 register_LY; extern u8 register_LY;
extern u8 register_SCY; extern u8 register_SCY;
extern u8 register_SCX; extern u8 register_SCX;
extern u8 register_WY; extern u8 register_WY;
extern u8 register_WX; extern u8 register_WX;
extern u8 register_VBK; extern u8 register_VBK;
extern u8 oldRegister_WY; extern u8 oldRegister_WY;
extern int emulating; extern int emulating;
extern bool genericflashcardEnable; extern bool genericflashcardEnable;
extern int gbBorderLineSkip; extern int gbBorderLineSkip;
extern int gbBorderRowSkip; extern int gbBorderRowSkip;
extern int gbBorderColumnSkip; extern int gbBorderColumnSkip;
extern int gbDmaTicks; extern int gbDmaTicks;
extern void gbRenderLine(); extern void gbRenderLine();
extern void gbDrawSprites(bool); extern void gbDrawSprites(bool);
extern u8 (*gbSerialFunction)(u8); extern u8 (*gbSerialFunction)(u8);

File diff suppressed because it is too large Load Diff

View File

@ -1,206 +1,206 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004-2006 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 // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <time.h> #include <time.h>
struct mapperMBC1 { struct mapperMBC1 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperMemoryModel; int mapperMemoryModel;
int mapperROMHighAddress; int mapperROMHighAddress;
int mapperRAMAddress; int mapperRAMAddress;
int mapperRomBank0Remapping; int mapperRomBank0Remapping;
}; };
struct mapperMBC2 { struct mapperMBC2 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
}; };
struct mapperMBC3 { struct mapperMBC3 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperRAMAddress; int mapperRAMAddress;
int mapperClockLatch; int mapperClockLatch;
int mapperClockRegister; int mapperClockRegister;
int mapperSeconds; int mapperSeconds;
int mapperMinutes; int mapperMinutes;
int mapperHours; int mapperHours;
int mapperDays; int mapperDays;
int mapperControl; int mapperControl;
int mapperLSeconds; int mapperLSeconds;
int mapperLMinutes; int mapperLMinutes;
int mapperLHours; int mapperLHours;
int mapperLDays; int mapperLDays;
int mapperLControl; int mapperLControl;
time_t mapperLastTime; time_t mapperLastTime;
}; };
struct mapperMBC5 { struct mapperMBC5 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperROMHighAddress; int mapperROMHighAddress;
int mapperRAMAddress; int mapperRAMAddress;
int isRumbleCartridge; int isRumbleCartridge;
}; };
struct mapperMBC7 { struct mapperMBC7 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperRAMAddress; int mapperRAMAddress;
int cs; int cs;
int sk; int sk;
int state; int state;
int buffer; int buffer;
int idle; int idle;
int count; int count;
int code; int code;
int address; int address;
int writeEnable; int writeEnable;
int value; int value;
}; };
struct mapperHuC1 { struct mapperHuC1 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperMemoryModel; int mapperMemoryModel;
int mapperROMHighAddress; int mapperROMHighAddress;
int mapperRAMAddress; int mapperRAMAddress;
}; };
struct mapperHuC3 { struct mapperHuC3 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperRAMAddress; int mapperRAMAddress;
int mapperAddress; int mapperAddress;
int mapperRAMFlag; int mapperRAMFlag;
int mapperRAMValue; int mapperRAMValue;
int mapperRegister1; int mapperRegister1;
int mapperRegister2; int mapperRegister2;
int mapperRegister3; int mapperRegister3;
int mapperRegister4; int mapperRegister4;
int mapperRegister5; int mapperRegister5;
int mapperRegister6; int mapperRegister6;
int mapperRegister7; int mapperRegister7;
int mapperRegister8; int mapperRegister8;
}; };
struct mapperTAMA5 { struct mapperTAMA5 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperRAMAddress; int mapperRAMAddress;
int mapperRamByteSelect; int mapperRamByteSelect;
int mapperCommandNumber; int mapperCommandNumber;
int mapperLastCommandNumber; int mapperLastCommandNumber;
int mapperCommands[0x10]; int mapperCommands[0x10];
int mapperRegister; int mapperRegister;
int mapperClockLatch; int mapperClockLatch;
int mapperClockRegister; int mapperClockRegister;
int mapperSeconds; int mapperSeconds;
int mapperMinutes; int mapperMinutes;
int mapperHours; int mapperHours;
int mapperDays; int mapperDays;
int mapperMonths; int mapperMonths;
int mapperYears; int mapperYears;
int mapperControl; int mapperControl;
int mapperLSeconds; int mapperLSeconds;
int mapperLMinutes; int mapperLMinutes;
int mapperLHours; int mapperLHours;
int mapperLDays; int mapperLDays;
int mapperLMonths; int mapperLMonths;
int mapperLYears; int mapperLYears;
int mapperLControl; int mapperLControl;
time_t mapperLastTime; time_t mapperLastTime;
}; };
struct mapperMMM01 { struct mapperMMM01 {
int mapperRAMEnable; int mapperRAMEnable;
int mapperROMBank; int mapperROMBank;
int mapperRAMBank; int mapperRAMBank;
int mapperMemoryModel; int mapperMemoryModel;
int mapperROMHighAddress; int mapperROMHighAddress;
int mapperRAMAddress; int mapperRAMAddress;
int mapperRomBank0Remapping; int mapperRomBank0Remapping;
}; };
struct mapperGS3 { struct mapperGS3 {
int mapperROMBank; int mapperROMBank;
}; };
extern mapperMBC1 gbDataMBC1; extern mapperMBC1 gbDataMBC1;
extern mapperMBC2 gbDataMBC2; extern mapperMBC2 gbDataMBC2;
extern mapperMBC3 gbDataMBC3; extern mapperMBC3 gbDataMBC3;
extern mapperMBC5 gbDataMBC5; extern mapperMBC5 gbDataMBC5;
extern mapperHuC1 gbDataHuC1; extern mapperHuC1 gbDataHuC1;
extern mapperHuC3 gbDataHuC3; extern mapperHuC3 gbDataHuC3;
extern mapperTAMA5 gbDataTAMA5; extern mapperTAMA5 gbDataTAMA5;
extern mapperMMM01 gbDataMMM01; extern mapperMMM01 gbDataMMM01;
extern mapperGS3 gbDataGS3; extern mapperGS3 gbDataGS3;
void mapperMBC1ROM(u16,u8); void mapperMBC1ROM(u16,u8);
void mapperMBC1RAM(u16,u8); void mapperMBC1RAM(u16,u8);
u8 mapperMBC1ReadRAM(u16); u8 mapperMBC1ReadRAM(u16);
void mapperMBC2ROM(u16,u8); void mapperMBC2ROM(u16,u8);
void mapperMBC2RAM(u16,u8); void mapperMBC2RAM(u16,u8);
void mapperMBC3ROM(u16,u8); void mapperMBC3ROM(u16,u8);
void mapperMBC3RAM(u16,u8); void mapperMBC3RAM(u16,u8);
u8 mapperMBC3ReadRAM(u16); u8 mapperMBC3ReadRAM(u16);
void mapperMBC5ROM(u16,u8); void mapperMBC5ROM(u16,u8);
void mapperMBC5RAM(u16,u8); void mapperMBC5RAM(u16,u8);
u8 mapperMBC5ReadRAM(u16); u8 mapperMBC5ReadRAM(u16);
void mapperMBC7ROM(u16,u8); void mapperMBC7ROM(u16,u8);
void mapperMBC7RAM(u16,u8); void mapperMBC7RAM(u16,u8);
u8 mapperMBC7ReadRAM(u16); u8 mapperMBC7ReadRAM(u16);
void mapperHuC1ROM(u16,u8); void mapperHuC1ROM(u16,u8);
void mapperHuC1RAM(u16,u8); void mapperHuC1RAM(u16,u8);
void mapperHuC3ROM(u16,u8); void mapperHuC3ROM(u16,u8);
void mapperHuC3RAM(u16,u8); void mapperHuC3RAM(u16,u8);
u8 mapperHuC3ReadRAM(u16); u8 mapperHuC3ReadRAM(u16);
void mapperTAMA5RAM(u16,u8); void mapperTAMA5RAM(u16,u8);
u8 mapperTAMA5ReadRAM(u16); u8 mapperTAMA5ReadRAM(u16);
void memoryUpdateTAMA5Clock(); void memoryUpdateTAMA5Clock();
void mapperMMM01ROM(u16,u8); void mapperMMM01ROM(u16,u8);
void mapperMMM01RAM(u16,u8); void mapperMMM01RAM(u16,u8);
void mapperGGROM(u16,u8); void mapperGGROM(u16,u8);
void mapperGS3ROM(u16,u8); void mapperGS3ROM(u16,u8);
//extern void (*mapper)(u16,u8); //extern void (*mapper)(u16,u8);
//extern void (*mapperRAM)(u16,u8); //extern void (*mapperRAM)(u16,u8);
//extern u8 (*mapperReadRAM)(u16); //extern u8 (*mapperReadRAM)(u16);
extern void memoryUpdateMapMBC1(); extern void memoryUpdateMapMBC1();
extern void memoryUpdateMapMBC2(); extern void memoryUpdateMapMBC2();
extern void memoryUpdateMapMBC3(); extern void memoryUpdateMapMBC3();
extern void memoryUpdateMapMBC5(); extern void memoryUpdateMapMBC5();
extern void memoryUpdateMapMBC7(); extern void memoryUpdateMapMBC7();
extern void memoryUpdateMapHuC1(); extern void memoryUpdateMapHuC1();
extern void memoryUpdateMapHuC3(); extern void memoryUpdateMapHuC3();
extern void memoryUpdateMapTAMA5(); extern void memoryUpdateMapTAMA5();
extern void memoryUpdateMapMMM01(); extern void memoryUpdateMapMMM01();
extern void memoryUpdateMapGS3(); extern void memoryUpdateMapGS3();

View File

@ -1,229 +1,229 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h> #include <stdio.h>
#include <memory.h> #include <memory.h>
#include "../GBA.h" #include "../GBA.h"
u8 gbPrinterStatus = 0; u8 gbPrinterStatus = 0;
int gbPrinterState = 0; int gbPrinterState = 0;
u8 gbPrinterData[0x280*9]; u8 gbPrinterData[0x280*9];
u8 gbPrinterPacket[0x400]; u8 gbPrinterPacket[0x400];
int gbPrinterCount = 0; int gbPrinterCount = 0;
int gbPrinterDataCount = 0; int gbPrinterDataCount = 0;
int gbPrinterDataSize = 0; int gbPrinterDataSize = 0;
int gbPrinterResult = 0; int gbPrinterResult = 0;
bool gbPrinterCheckCRC() bool gbPrinterCheckCRC()
{ {
u16 crc = 0; u16 crc = 0;
for(int i = 2; i < (6+gbPrinterDataSize); i++) { for(int i = 2; i < (6+gbPrinterDataSize); i++) {
crc += gbPrinterPacket[i]; crc += gbPrinterPacket[i];
} }
int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] + int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] +
(gbPrinterPacket[7+gbPrinterDataSize]<<8); (gbPrinterPacket[7+gbPrinterDataSize]<<8);
return msgCrc == crc; return msgCrc == crc;
} }
void gbPrinterReset() void gbPrinterReset()
{ {
gbPrinterState = 0; gbPrinterState = 0;
gbPrinterDataSize = 0; gbPrinterDataSize = 0;
gbPrinterDataCount = 0; gbPrinterDataCount = 0;
gbPrinterCount = 0; gbPrinterCount = 0;
gbPrinterStatus = 0; gbPrinterStatus = 0;
gbPrinterResult = 0; gbPrinterResult = 0;
} }
void gbPrinterShowData() void gbPrinterShowData()
{ {
systemGbPrint(gbPrinterData, systemGbPrint(gbPrinterData,
gbPrinterPacket[6], gbPrinterPacket[6],
gbPrinterPacket[7], gbPrinterPacket[7],
gbPrinterPacket[8], gbPrinterPacket[8],
gbPrinterPacket[9]); gbPrinterPacket[9]);
/* /*
allegro_init(); allegro_init();
install_keyboard(); install_keyboard();
set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0); set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0);
PALETTE pal; PALETTE pal;
pal[0].r = 255; pal[0].r = 255;
pal[0].g = 255; pal[0].g = 255;
pal[0].b = 255; pal[0].b = 255;
pal[1].r = 168; pal[1].r = 168;
pal[1].g = 168; pal[1].g = 168;
pal[1].b = 168; pal[1].b = 168;
pal[2].r = 96; pal[2].r = 96;
pal[2].g = 96; pal[2].g = 96;
pal[2].b = 96; pal[2].b = 96;
pal[3].r = 0; pal[3].r = 0;
pal[3].g = 0; pal[3].g = 0;
pal[3].b = 0; pal[3].b = 0;
set_palette(pal); set_palette(pal);
acquire_screen(); acquire_screen();
u8 *data = gbPrinterData; u8 *data = gbPrinterData;
for(int y = 0; y < 0x12; y++) { for(int y = 0; y < 0x12; y++) {
for(int x = 0; x < 0x14; x++) { for(int x = 0; x < 0x14; x++) {
for(int k = 0; k < 8; k++) { for(int k = 0; k < 8; k++) {
int a = *data++; int a = *data++;
int b = *data++; int b = *data++;
for(int j = 0; j < 8; j++) { for(int j = 0; j < 8; j++) {
int mask = 1 << (7-j); int mask = 1 << (7-j);
int c = 0; int c = 0;
if(a & mask) if(a & mask)
c++; c++;
if(b & mask) if(b & mask)
c+=2; c+=2;
putpixel(screen, x*8+j, y*8+k, c); putpixel(screen, x*8+j, y*8+k, c);
} }
} }
} }
} }
release_screen(); release_screen();
while(!keypressed()) { while(!keypressed()) {
} }
*/ */
} }
void gbPrinterReceiveData() void gbPrinterReceiveData()
{ {
if(gbPrinterPacket[3]) { // compressed if(gbPrinterPacket[3]) { // compressed
u8 *data = &gbPrinterPacket[6]; u8 *data = &gbPrinterPacket[6];
u8 *dest = &gbPrinterData[gbPrinterDataCount]; u8 *dest = &gbPrinterData[gbPrinterDataCount];
int len = 0; int len = 0;
while(len < gbPrinterDataSize) { while(len < gbPrinterDataSize) {
u8 control = *data++; u8 control = *data++;
if(control & 0x80) { // repeated data if(control & 0x80) { // repeated data
control &= 0x7f; control &= 0x7f;
control += 2; control += 2;
memset(dest, *data++, control); memset(dest, *data++, control);
len += control; len += control;
dest += control; dest += control;
} else { // raw data } else { // raw data
control++; control++;
memcpy(dest, data, control); memcpy(dest, data, control);
dest += control; dest += control;
data += control; data += control;
len += control; len += control;
} }
} }
} else { } else {
memcpy(&gbPrinterData[gbPrinterDataCount], memcpy(&gbPrinterData[gbPrinterDataCount],
&gbPrinterPacket[6], &gbPrinterPacket[6],
gbPrinterDataSize); gbPrinterDataSize);
gbPrinterDataCount += gbPrinterDataSize; gbPrinterDataCount += gbPrinterDataSize;
} }
} }
void gbPrinterCommand() void gbPrinterCommand()
{ {
switch(gbPrinterPacket[2]) { switch(gbPrinterPacket[2]) {
case 0x01: case 0x01:
// reset/initialize packet // reset/initialize packet
gbPrinterDataCount = 0; gbPrinterDataCount = 0;
gbPrinterStatus = 0; gbPrinterStatus = 0;
break; break;
case 0x02: case 0x02:
// print packet // print packet
gbPrinterShowData(); gbPrinterShowData();
break; break;
case 0x04: case 0x04:
// data packet // data packet
gbPrinterReceiveData(); gbPrinterReceiveData();
break; break;
case 0x0f: case 0x0f:
// NUL packet // NUL packet
break; break;
} }
} }
u8 gbPrinterSend(u8 b) u8 gbPrinterSend(u8 b)
{ {
switch(gbPrinterState) { switch(gbPrinterState) {
case 0: case 0:
gbPrinterCount = 0; gbPrinterCount = 0;
// receiving preamble // receiving preamble
if(b == 0x88) { if(b == 0x88) {
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++; gbPrinterState++;
} else { } else {
// todo: handle failure // todo: handle failure
gbPrinterReset(); gbPrinterReset();
} }
break; break;
case 1: case 1:
// receiving preamble // receiving preamble
if(b == 0x33) { if(b == 0x33) {
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++; gbPrinterState++;
} else { } else {
// todo: handle failure // todo: handle failure
gbPrinterReset(); gbPrinterReset();
} }
break; break;
case 2: case 2:
// receiving header // receiving header
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCount == 6) { if(gbPrinterCount == 6) {
gbPrinterState++; gbPrinterState++;
gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8); gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8);
} }
break; break;
case 3: case 3:
// receiving data // receiving data
if(gbPrinterDataSize) { if(gbPrinterDataSize) {
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCount == (6+gbPrinterDataSize)) { if(gbPrinterCount == (6+gbPrinterDataSize)) {
gbPrinterState++; gbPrinterState++;
} }
break; break;
} }
gbPrinterState++; gbPrinterState++;
// intentionally move to next if no data to receive // intentionally move to next if no data to receive
case 4: case 4:
// receiving CRC // receiving CRC
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++; gbPrinterState++;
break; break;
case 5: case 5:
// receiving CRC-2 // receiving CRC-2
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCheckCRC()) { if(gbPrinterCheckCRC()) {
gbPrinterCommand(); gbPrinterCommand();
} }
gbPrinterState++; gbPrinterState++;
break; break;
case 6: case 6:
// receiving dummy 1 // receiving dummy 1
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterResult = 0x81; gbPrinterResult = 0x81;
gbPrinterState++; gbPrinterState++;
break; break;
case 7: case 7:
// receiving dummy 2 // receiving dummy 2
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterResult = gbPrinterStatus; gbPrinterResult = gbPrinterStatus;
gbPrinterState = 0; gbPrinterState = 0;
gbPrinterCount = 0; gbPrinterCount = 0;
break; break;
} }
return gbPrinterResult; return gbPrinterResult;
} }

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +1,39 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void gbSgbInit(); void gbSgbInit();
void gbSgbShutdown(); void gbSgbShutdown();
void gbSgbCommand(); void gbSgbCommand();
void gbSgbResetPacketState(); void gbSgbResetPacketState();
void gbSgbReset(); void gbSgbReset();
void gbSgbDoBitTransfer(u8); void gbSgbDoBitTransfer(u8);
void gbSgbSaveGame(gzFile); void gbSgbSaveGame(gzFile);
void gbSgbReadGame(gzFile, int version); void gbSgbReadGame(gzFile, int version);
void gbSgbRenderBorder(); void gbSgbRenderBorder();
extern u8 gbSgbATF[20*18]; extern u8 gbSgbATF[20*18];
extern int gbSgbMode; extern int gbSgbMode;
extern int gbSgbMask; extern int gbSgbMask;
extern int gbSgbMultiplayer; extern int gbSgbMultiplayer;
extern u8 gbSgbNextController; extern u8 gbSgbNextController;
extern int gbSgbPacketTimeout; extern int gbSgbPacketTimeout;
extern u8 gbSgbReadingController; extern u8 gbSgbReadingController;
extern int gbSgbFourPlayers; extern int gbSgbFourPlayers;

View File

@ -1,412 +1,412 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005-2006 Forgotten and the VBA development team // Copyright (C) 2005-2006 Forgotten and the VBA development team
// Copyright (C) 2007-2008 VBA-M development team // Copyright (C) 2007-2008 VBA-M development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <memory.h> #include <memory.h>
#include "../System.h" #include "../System.h"
#include "../Util.h" #include "../Util.h"
#include "gbGlobals.h" #include "gbGlobals.h"
#include "gbSound.h" #include "gbSound.h"
#include "gb_apu/Gb_Apu.h" #include "gb_apu/Gb_Apu.h"
#include "gb_apu/Effects_Buffer.h" #include "gb_apu/Effects_Buffer.h"
static Gb_Apu* gb_apu; static Gb_Apu* gb_apu;
static Simple_Effects_Buffer* stereo_buffer; static Simple_Effects_Buffer* stereo_buffer;
extern u16 soundFinalWave[1470]; extern u16 soundFinalWave[1470];
extern int soundVolume; extern int soundVolume;
extern int gbHardware; extern int gbHardware;
extern void soundResume(); extern void soundResume();
extern int soundBufferLen; extern int soundBufferLen;
extern int soundQuality; extern int soundQuality;
extern bool soundPaused; extern bool soundPaused;
extern int soundTicks; extern int soundTicks;
extern int SOUND_CLOCK_TICKS; extern int SOUND_CLOCK_TICKS;
extern u32 soundNextPosition; extern u32 soundNextPosition;
extern int soundDebug; extern int soundDebug;
extern bool soundEcho; extern bool soundEcho;
extern bool soundLowPass; extern bool soundLowPass;
extern bool soundReverse; extern bool soundReverse;
extern bool soundOffFlag; extern bool soundOffFlag;
int const ticks_to_time = 2 * GB_APU_OVERCLOCK; int const ticks_to_time = 2 * GB_APU_OVERCLOCK;
static inline blip_time_t blip_time() static inline blip_time_t blip_time()
{ {
return (SOUND_CLOCK_TICKS - soundTicks) * ticks_to_time; return (SOUND_CLOCK_TICKS - soundTicks) * ticks_to_time;
} }
u8 gbSoundRead( u16 address ) u8 gbSoundRead( u16 address )
{ {
if ( gb_apu && address >= NR10 && address <= 0xFF3F ) if ( gb_apu && address >= NR10 && address <= 0xFF3F )
return gb_apu->read_register( blip_time(), address ); return gb_apu->read_register( blip_time(), address );
return gbMemory[address]; return gbMemory[address];
} }
void gbSoundEvent(register u16 address, register int data) void gbSoundEvent(register u16 address, register int data)
{ {
int freq = 0; int freq = 0;
gbMemory[address] = data; gbMemory[address] = data;
#ifndef FINAL_VERSION #ifndef FINAL_VERSION
if(soundDebug) { if(soundDebug) {
// don't translate. debug only // don't translate. debug only
log("Sound event: %08lx %02x\n", address, data); log("Sound event: %08lx %02x\n", address, data);
} }
#endif #endif
if ( gb_apu && address >= NR10 && address <= 0xFF3F ) if ( gb_apu && address >= NR10 && address <= 0xFF3F )
gb_apu->write_register( blip_time(), address, data ); gb_apu->write_register( blip_time(), address, data );
} }
static void end_frame( blip_time_t time ) static void end_frame( blip_time_t time )
{ {
gb_apu ->end_frame( time ); gb_apu ->end_frame( time );
stereo_buffer->end_frame( time ); stereo_buffer->end_frame( time );
} }
static void flush_samples() static void flush_samples()
{ {
// number of samples in output buffer // number of samples in output buffer
int const out_buf_size = soundBufferLen / sizeof *soundFinalWave; int const out_buf_size = soundBufferLen / sizeof *soundFinalWave;
// Keep filling and writing soundFinalWave until it can't be fully filled // Keep filling and writing soundFinalWave until it can't be fully filled
while ( stereo_buffer->samples_avail() >= out_buf_size ) while ( stereo_buffer->samples_avail() >= out_buf_size )
{ {
stereo_buffer->read_samples( (blip_sample_t*) soundFinalWave, out_buf_size ); stereo_buffer->read_samples( (blip_sample_t*) soundFinalWave, out_buf_size );
if(systemSoundOn) if(systemSoundOn)
{ {
if(soundPaused) if(soundPaused)
soundResume(); soundResume();
systemWriteDataToSoundBuffer(); systemWriteDataToSoundBuffer();
} }
} }
} }
int const chan_count = 4; int const chan_count = 4;
gb_effects_config_t gb_effects_config; gb_effects_config_t gb_effects_config;
static gb_effects_config_t gb_effects_config_current; static gb_effects_config_t gb_effects_config_current;
static void apply_effects() static void apply_effects()
{ {
gb_effects_config_current = gb_effects_config; gb_effects_config_current = gb_effects_config;
stereo_buffer->config().enabled = gb_effects_config_current.enabled; stereo_buffer->config().enabled = gb_effects_config_current.enabled;
stereo_buffer->config().echo = gb_effects_config_current.echo; stereo_buffer->config().echo = gb_effects_config_current.echo;
stereo_buffer->config().stereo = gb_effects_config_current.stereo; stereo_buffer->config().stereo = gb_effects_config_current.stereo;
stereo_buffer->config().surround = gb_effects_config_current.surround; stereo_buffer->config().surround = gb_effects_config_current.surround;
stereo_buffer->apply_config(); stereo_buffer->apply_config();
for ( int i = 0; i < chan_count; i++ ) for ( int i = 0; i < chan_count; i++ )
{ {
Multi_Buffer::channel_t ch = stereo_buffer->channel( i ); Multi_Buffer::channel_t ch = stereo_buffer->channel( i );
gb_apu->set_output( ch.center, ch.left, ch.right, i ); gb_apu->set_output( ch.center, ch.left, ch.right, i );
} }
} }
void gbSoundTick() void gbSoundTick()
{ {
if ( systemSoundOn && gb_apu && stereo_buffer ) if ( systemSoundOn && gb_apu && stereo_buffer )
{ {
// Run sound hardware to present // Run sound hardware to present
end_frame( SOUND_CLOCK_TICKS * ticks_to_time ); end_frame( SOUND_CLOCK_TICKS * ticks_to_time );
flush_samples(); flush_samples();
gb_effects_config.enabled = soundEcho; gb_effects_config.enabled = soundEcho;
// Update effects config if it was changed // Update effects config if it was changed
if ( memcmp( &gb_effects_config_current, &gb_effects_config, if ( memcmp( &gb_effects_config_current, &gb_effects_config,
sizeof gb_effects_config ) ) sizeof gb_effects_config ) )
apply_effects(); apply_effects();
} }
} }
static void reset_apu() static void reset_apu()
{ {
// Use DMG or CGB sound differences based on type of game // Use DMG or CGB sound differences based on type of game
gb_apu->reset( gbHardware & 1 ? gb_apu->mode_dmg : gb_apu->mode_cgb ); gb_apu->reset( gbHardware & 1 ? gb_apu->mode_dmg : gb_apu->mode_cgb );
if ( stereo_buffer ) if ( stereo_buffer )
stereo_buffer->clear(); stereo_buffer->clear();
soundTicks = SOUND_CLOCK_TICKS; soundTicks = SOUND_CLOCK_TICKS;
} }
static void remake_stereo_buffer() static void remake_stereo_buffer()
{ {
// Stereo_Buffer // Stereo_Buffer
delete stereo_buffer; delete stereo_buffer;
stereo_buffer = 0; stereo_buffer = 0;
stereo_buffer = new Simple_Effects_Buffer; // TODO: handle out of memory stereo_buffer = new Simple_Effects_Buffer; // TODO: handle out of memory
stereo_buffer->set_sample_rate( 44100 / soundQuality ); // TODO: handle out of memory stereo_buffer->set_sample_rate( 44100 / soundQuality ); // TODO: handle out of memory
stereo_buffer->clock_rate( gb_apu->clock_rate ); stereo_buffer->clock_rate( gb_apu->clock_rate );
// APU // APU
static int const chan_types [chan_count] = { static int const chan_types [chan_count] = {
Multi_Buffer::wave_type+1, Multi_Buffer::wave_type+2, Multi_Buffer::wave_type+1, Multi_Buffer::wave_type+2,
Multi_Buffer::wave_type+3, Multi_Buffer::mixed_type+1 Multi_Buffer::wave_type+3, Multi_Buffer::mixed_type+1
}; };
stereo_buffer->set_channel_count( chan_count, chan_types ); stereo_buffer->set_channel_count( chan_count, chan_types );
if ( !gb_apu ) if ( !gb_apu )
{ {
gb_apu = new Gb_Apu; gb_apu = new Gb_Apu;
reset_apu(); reset_apu();
} }
apply_effects(); apply_effects();
} }
void gbSoundReset() void gbSoundReset()
{ {
gb_effects_config.echo = 0.20f; gb_effects_config.echo = 0.20f;
gb_effects_config.stereo = 0.15f; gb_effects_config.stereo = 0.15f;
gb_effects_config.surround = false; gb_effects_config.surround = false;
SOUND_CLOCK_TICKS = 20000; SOUND_CLOCK_TICKS = 20000;
remake_stereo_buffer(); remake_stereo_buffer();
reset_apu(); reset_apu();
soundPaused = 1; soundPaused = 1;
soundNextPosition = 0; soundNextPosition = 0;
// don't translate // don't translate
#ifndef FINAL_VERSION #ifndef FINAL_VERSION
if(soundDebug) { if(soundDebug) {
log("*** Sound Init ***\n"); log("*** Sound Init ***\n");
} }
#endif #endif
gbSoundEvent(0xff10, 0x80); gbSoundEvent(0xff10, 0x80);
gbSoundEvent(0xff11, 0xbf); gbSoundEvent(0xff11, 0xbf);
gbSoundEvent(0xff12, 0xf3); gbSoundEvent(0xff12, 0xf3);
gbSoundEvent(0xff14, 0xbf); gbSoundEvent(0xff14, 0xbf);
gbSoundEvent(0xff16, 0x3f); gbSoundEvent(0xff16, 0x3f);
gbSoundEvent(0xff17, 0x00); gbSoundEvent(0xff17, 0x00);
gbSoundEvent(0xff19, 0xbf); gbSoundEvent(0xff19, 0xbf);
gbSoundEvent(0xff1a, 0x7f); gbSoundEvent(0xff1a, 0x7f);
gbSoundEvent(0xff1b, 0xff); gbSoundEvent(0xff1b, 0xff);
gbSoundEvent(0xff1c, 0xbf); gbSoundEvent(0xff1c, 0xbf);
gbSoundEvent(0xff1e, 0xbf); gbSoundEvent(0xff1e, 0xbf);
gbSoundEvent(0xff20, 0xff); gbSoundEvent(0xff20, 0xff);
gbSoundEvent(0xff21, 0x00); gbSoundEvent(0xff21, 0x00);
gbSoundEvent(0xff22, 0x00); gbSoundEvent(0xff22, 0x00);
gbSoundEvent(0xff23, 0xbf); gbSoundEvent(0xff23, 0xbf);
gbSoundEvent(0xff24, 0x77); gbSoundEvent(0xff24, 0x77);
gbSoundEvent(0xff25, 0xf3); gbSoundEvent(0xff25, 0xf3);
if (gbHardware & 0x4) if (gbHardware & 0x4)
gbSoundEvent(0xff26, 0xf0); gbSoundEvent(0xff26, 0xf0);
else else
gbSoundEvent(0xff26, 0xf1); gbSoundEvent(0xff26, 0xf1);
// don't translate // don't translate
#ifndef FINAL_VERSION #ifndef FINAL_VERSION
if(soundDebug) { if(soundDebug) {
log("*** Sound Init Complete ***\n"); log("*** Sound Init Complete ***\n");
} }
#endif #endif
int addr = 0xff30; int addr = 0xff30;
while(addr < 0xff40) { while(addr < 0xff40) {
gbMemory[addr++] = 0x00; gbMemory[addr++] = 0x00;
gbMemory[addr++] = 0xff; gbMemory[addr++] = 0xff;
} }
} }
extern bool soundInit(); extern bool soundInit();
extern void soundShutdown(); extern void soundShutdown();
void gbSoundSetQuality(int quality) void gbSoundSetQuality(int quality)
{ {
if ( soundQuality != quality ) if ( soundQuality != quality )
{ {
if ( systemCanChangeSoundQuality() ) if ( systemCanChangeSoundQuality() )
{ {
if ( !soundOffFlag ) if ( !soundOffFlag )
soundShutdown(); soundShutdown();
soundQuality = quality; soundQuality = quality;
soundNextPosition = 0; soundNextPosition = 0;
if ( !soundOffFlag ) if ( !soundOffFlag )
soundInit(); soundInit();
} }
else else
{ {
soundQuality = quality; soundQuality = quality;
soundNextPosition = 0; soundNextPosition = 0;
} }
remake_stereo_buffer(); remake_stereo_buffer();
} }
} }
static char dummy_buf [735 * 2]; static char dummy_buf [735 * 2];
#define SKIP( type, name ) { dummy_buf, sizeof (type) } #define SKIP( type, name ) { dummy_buf, sizeof (type) }
// funny expr at end ensures that type matches type of variable // funny expr at end ensures that type matches type of variable
#define LOAD( type, name ) { &name, sizeof (name) + (&name - (type*) &name) } #define LOAD( type, name ) { &name, sizeof (name) + (&name - (type*) &name) }
static variable_desc gbsound_format [] = static variable_desc gbsound_format [] =
{ {
SKIP( int, soundPaused ), SKIP( int, soundPaused ),
SKIP( int, soundPlay ), SKIP( int, soundPlay ),
SKIP( int, soundTicks ), SKIP( int, soundTicks ),
SKIP( int, SOUND_CLOCK_TICKS ), SKIP( int, SOUND_CLOCK_TICKS ),
SKIP( int, soundLevel1 ), SKIP( int, soundLevel1 ),
SKIP( int, soundLevel2 ), SKIP( int, soundLevel2 ),
SKIP( int, soundBalance ), SKIP( int, soundBalance ),
SKIP( int, soundMasterOn ), SKIP( int, soundMasterOn ),
SKIP( int, soundIndex ), SKIP( int, soundIndex ),
SKIP( int, soundVIN ), SKIP( int, soundVIN ),
SKIP( int, soundOn [0] ), SKIP( int, soundOn [0] ),
SKIP( int, soundATL [0] ), SKIP( int, soundATL [0] ),
SKIP( int, sound1Skip ), SKIP( int, sound1Skip ),
SKIP( int, soundIndex [0] ), SKIP( int, soundIndex [0] ),
SKIP( int, sound1Continue ), SKIP( int, sound1Continue ),
SKIP( int, soundEnvelopeVolume [0] ), SKIP( int, soundEnvelopeVolume [0] ),
SKIP( int, soundEnvelopeATL [0] ), SKIP( int, soundEnvelopeATL [0] ),
SKIP( int, sound1EnvelopeATLReload ), SKIP( int, sound1EnvelopeATLReload ),
SKIP( int, sound1EnvelopeUpDown ), SKIP( int, sound1EnvelopeUpDown ),
SKIP( int, sound1SweepATL ), SKIP( int, sound1SweepATL ),
SKIP( int, sound1SweepATLReload ), SKIP( int, sound1SweepATLReload ),
SKIP( int, sound1SweepSteps ), SKIP( int, sound1SweepSteps ),
SKIP( int, sound1SweepUpDown ), SKIP( int, sound1SweepUpDown ),
SKIP( int, sound1SweepStep ), SKIP( int, sound1SweepStep ),
SKIP( int, soundOn [1] ), SKIP( int, soundOn [1] ),
SKIP( int, soundATL [1] ), SKIP( int, soundATL [1] ),
SKIP( int, sound2Skip ), SKIP( int, sound2Skip ),
SKIP( int, soundIndex [1] ), SKIP( int, soundIndex [1] ),
SKIP( int, sound2Continue ), SKIP( int, sound2Continue ),
SKIP( int, soundEnvelopeVolume [1] ), SKIP( int, soundEnvelopeVolume [1] ),
SKIP( int, soundEnvelopeATL [1] ), SKIP( int, soundEnvelopeATL [1] ),
SKIP( int, sound2EnvelopeATLReload ), SKIP( int, sound2EnvelopeATLReload ),
SKIP( int, sound2EnvelopeUpDown ), SKIP( int, sound2EnvelopeUpDown ),
SKIP( int, soundOn [2] ), SKIP( int, soundOn [2] ),
SKIP( int, soundATL [2] ), SKIP( int, soundATL [2] ),
SKIP( int, sound3Skip ), SKIP( int, sound3Skip ),
SKIP( int, soundIndex [2] ), SKIP( int, soundIndex [2] ),
SKIP( int, sound3Continue ), SKIP( int, sound3Continue ),
SKIP( int, sound3OutputLevel ), SKIP( int, sound3OutputLevel ),
SKIP( int, soundOn [3] ), SKIP( int, soundOn [3] ),
SKIP( int, soundATL [3] ), SKIP( int, soundATL [3] ),
SKIP( int, sound4Skip ), SKIP( int, sound4Skip ),
SKIP( int, soundIndex [3] ), SKIP( int, soundIndex [3] ),
SKIP( int, sound4Clock ), SKIP( int, sound4Clock ),
SKIP( int, sound4ShiftRight ), SKIP( int, sound4ShiftRight ),
SKIP( int, sound4ShiftSkip ), SKIP( int, sound4ShiftSkip ),
SKIP( int, sound4ShiftIndex ), SKIP( int, sound4ShiftIndex ),
SKIP( int, sound4NSteps ), SKIP( int, sound4NSteps ),
SKIP( int, sound4CountDown ), SKIP( int, sound4CountDown ),
SKIP( int, sound4Continue ), SKIP( int, sound4Continue ),
SKIP( int, soundEnvelopeVolume [2] ), SKIP( int, soundEnvelopeVolume [2] ),
SKIP( int, soundEnvelopeATL [2] ), SKIP( int, soundEnvelopeATL [2] ),
SKIP( int, sound4EnvelopeATLReload ), SKIP( int, sound4EnvelopeATLReload ),
SKIP( int, sound4EnvelopeUpDown ), SKIP( int, sound4EnvelopeUpDown ),
SKIP( int, soundEnableFlag ), SKIP( int, soundEnableFlag ),
{ NULL, 0 } { NULL, 0 }
}; };
static variable_desc gbsound_format2 [] = static variable_desc gbsound_format2 [] =
{ {
SKIP( int, sound1ATLreload ), SKIP( int, sound1ATLreload ),
SKIP( int, freq1low ), SKIP( int, freq1low ),
SKIP( int, freq1high ), SKIP( int, freq1high ),
SKIP( int, sound2ATLreload ), SKIP( int, sound2ATLreload ),
SKIP( int, freq2low ), SKIP( int, freq2low ),
SKIP( int, freq2high ), SKIP( int, freq2high ),
SKIP( int, sound3ATLreload ), SKIP( int, sound3ATLreload ),
SKIP( int, freq3low ), SKIP( int, freq3low ),
SKIP( int, freq3high ), SKIP( int, freq3high ),
SKIP( int, sound4ATLreload ), SKIP( int, sound4ATLreload ),
SKIP( int, freq4 ), SKIP( int, freq4 ),
{ NULL, 0 } { NULL, 0 }
}; };
static variable_desc gbsound_format3 [] = static variable_desc gbsound_format3 [] =
{ {
SKIP( u8[2*735], soundBuffer ), SKIP( u8[2*735], soundBuffer ),
SKIP( u8[2*735], soundBuffer ), SKIP( u8[2*735], soundBuffer ),
SKIP( u16[735], soundFinalWave ), SKIP( u16[735], soundFinalWave ),
{ NULL, 0 } { NULL, 0 }
}; };
void gbSoundSaveGame(gzFile gzFile) void gbSoundSaveGame(gzFile gzFile)
{ {
// TODO: implement // TODO: implement
} }
enum { enum {
nr10 = 0, nr10 = 0,
nr11, nr12, nr13, nr14, nr11, nr12, nr13, nr14,
nr20, nr21, nr22, nr23, nr24, nr20, nr21, nr22, nr23, nr24,
nr30, nr31, nr32, nr33, nr34, nr30, nr31, nr32, nr33, nr34,
nr40, nr41, nr42, nr43, nr44, nr40, nr41, nr42, nr43, nr44,
nr50, nr51, nr52 nr50, nr51, nr52
}; };
void gbSoundReadGame(int version,gzFile gzFile) void gbSoundReadGame(int version,gzFile gzFile)
{ {
return; // TODO: apparently GB save states don't work in the main emulator return; // TODO: apparently GB save states don't work in the main emulator
// Load state // Load state
utilReadData( gzFile, gbsound_format ); utilReadData( gzFile, gbsound_format );
if ( version >= 11 ) if ( version >= 11 )
utilReadData( gzFile, gbsound_format2 ); utilReadData( gzFile, gbsound_format2 );
utilReadData( gzFile, gbsound_format3 ); utilReadData( gzFile, gbsound_format3 );
int quality = 1; int quality = 1;
if ( version >= 7 ) if ( version >= 7 )
quality = utilReadInt( gzFile ); quality = utilReadInt( gzFile );
gbSoundSetQuality( quality ); gbSoundSetQuality( quality );
// Convert to format Gb_Apu uses // Convert to format Gb_Apu uses
reset_apu(); reset_apu();
gb_apu_state_t s; gb_apu_state_t s;
gb_apu->save_state( &s ); // use fresh values for anything not restored gb_apu->save_state( &s ); // use fresh values for anything not restored
// Only some registers are properly preserved // Only some registers are properly preserved
static int const regs_to_copy [] = { static int const regs_to_copy [] = {
nr10, nr11, nr12, nr21, nr22, nr30, nr32, nr42, nr43, nr50, nr51, nr52, -1 nr10, nr11, nr12, nr21, nr22, nr30, nr32, nr42, nr43, nr50, nr51, nr52, -1
}; };
for ( int i = 0; regs_to_copy [i] >= 0; i++ ) for ( int i = 0; regs_to_copy [i] >= 0; i++ )
s.regs [regs_to_copy [i]] = gbMemory [0xFF10 + regs_to_copy [i]]; s.regs [regs_to_copy [i]] = gbMemory [0xFF10 + regs_to_copy [i]];
memcpy( &s.regs [0x20], &gbMemory [0xFF30], 0x10 ); // wave memcpy( &s.regs [0x20], &gbMemory [0xFF30], 0x10 ); // wave
gb_apu->load_state( s ); gb_apu->load_state( s );
} }

View File

@ -1,74 +1,74 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define NR10 0xff10 #define NR10 0xff10
#define NR11 0xff11 #define NR11 0xff11
#define NR12 0xff12 #define NR12 0xff12
#define NR13 0xff13 #define NR13 0xff13
#define NR14 0xff14 #define NR14 0xff14
#define NR21 0xff16 #define NR21 0xff16
#define NR22 0xff17 #define NR22 0xff17
#define NR23 0xff18 #define NR23 0xff18
#define NR24 0xff19 #define NR24 0xff19
#define NR30 0xff1a #define NR30 0xff1a
#define NR31 0xff1b #define NR31 0xff1b
#define NR32 0xff1c #define NR32 0xff1c
#define NR33 0xff1d #define NR33 0xff1d
#define NR34 0xff1e #define NR34 0xff1e
#define NR41 0xff20 #define NR41 0xff20
#define NR42 0xff21 #define NR42 0xff21
#define NR43 0xff22 #define NR43 0xff22
#define NR44 0xff23 #define NR44 0xff23
#define NR50 0xff24 #define NR50 0xff24
#define NR51 0xff25 #define NR51 0xff25
#define NR52 0xff26 #define NR52 0xff26
#define SOUND_EVENT(address,value) \ #define SOUND_EVENT(address,value) \
gbSoundEvent(address,value) gbSoundEvent(address,value)
extern void gbSoundTick(); extern void gbSoundTick();
extern void gbSoundPause(); extern void gbSoundPause();
extern void gbSoundResume(); extern void gbSoundResume();
extern void gbSoundEnable(int); extern void gbSoundEnable(int);
extern void gbSoundDisable(int); extern void gbSoundDisable(int);
extern int gbSoundGetEnable(); extern int gbSoundGetEnable();
extern void gbSoundReset(); extern void gbSoundReset();
extern void gbSoundSaveGame(gzFile); extern void gbSoundSaveGame(gzFile);
extern void gbSoundReadGame(int,gzFile); extern void gbSoundReadGame(int,gzFile);
extern void gbSoundEvent(register u16, register int); extern void gbSoundEvent(register u16, register int);
extern void gbSoundSetQuality(int); extern void gbSoundSetQuality(int);
extern u8 gbSoundRead(u16 address); extern u8 gbSoundRead(u16 address);
extern int soundTicks; extern int soundTicks;
extern int soundQuality; extern int soundQuality;
extern int SOUND_CLOCK_TICKS; extern int SOUND_CLOCK_TICKS;
struct gb_effects_config_t struct gb_effects_config_t
{ {
bool enabled; // false = disable all effects bool enabled; // false = disable all effects
float echo; // 0.0 = none, 1.0 = lots float echo; // 0.0 = none, 1.0 = lots
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
bool surround; // true = put some channels in back bool surround; // true = put some channels in back
}; };
// Can be changed at any time, probably from another thread too. // Can be changed at any time, probably from another thread too.
// Sound will notice changes during next 1/100 second. // Sound will notice changes during next 1/100 second.
extern gb_effects_config_t gb_effects_config; extern gb_effects_config_t gb_effects_config;

View File

@ -28,8 +28,8 @@
#include "../System.h" #include "../System.h"
#include "../CheatSearch.h" #include "../CheatSearch.h"
#include "../gb/gbCheats.h" #include "../dmg/gbCheats.h"
#include "../gb/gbGlobals.h" #include "../dmg/gbGlobals.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW

View File

@ -34,7 +34,7 @@
#include "../GBA.h" #include "../GBA.h"
#include "../Globals.h" #include "../Globals.h"
#include "../Util.h" #include "../Util.h"
#include "../gb/gbGlobals.h" #include "../dmg/gbGlobals.h"
#include "..\memgzio.h" #include "..\memgzio.h"
//Math //Math
@ -97,8 +97,9 @@ public:
virtual void DisableOpenGL(); virtual void DisableOpenGL();
virtual bool initialize(); virtual bool initialize();
virtual void cleanup(); virtual void cleanup();
virtual void render();
virtual void clear(); virtual void clear();
virtual void render();
virtual bool changeRenderSize( int w, int h ); virtual bool changeRenderSize( int w, int h );
virtual void resize( int w, int h ); virtual void resize( int w, int h );
virtual void setOption( const char *, int ); virtual void setOption( const char *, int );
@ -217,6 +218,124 @@ void OpenGLDisplay::cleanup()
//init renderer //init renderer
bool OpenGLDisplay::initialize() bool OpenGLDisplay::initialize()
{ {
switch( theApp.cartridgeType )
{
case IMAGE_GBA:
theApp.sizeX = 240;
theApp.sizeY = 160;
break;
case IMAGE_GB:
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_1280x960:
case VIDEO_OTHER:
{
if( theApp.fullScreenStretch ) {
theApp.surfaceSizeX = theApp.fsWidth;
theApp.surfaceSizeY = theApp.fsHeight;
} else {
float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX;
float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY;
float min = ( scaleX < scaleY ) ? scaleX : scaleY;
if( theApp.fsMaxScale )
min = ( min > (float)theApp.fsMaxScale ) ? (float)theApp.fsMaxScale : min;
theApp.surfaceSizeX = (int)((float)theApp.sizeX * min);
theApp.surfaceSizeY = (int)((float)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;
int x = 0, y = 0;
if( theApp.videoOption <= VIDEO_4X ) {
x = theApp.windowPositionX;
y = theApp.windowPositionY;
} else {
winSizeX = theApp.fsWidth;
winSizeY = theApp.fsHeight;
}
// 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.mode320Available = FALSE;
theApp.mode640Available = FALSE; theApp.mode640Available = FALSE;
theApp.mode800Available = FALSE; theApp.mode800Available = FALSE;