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
SDLDIR=src/sdl
DMGDIR=src/gb
GBAPUDIR=src/gb/gb_apu
DMGDIR=src/dmg
GBAPUDIR=src/dmg/gb_apu
FEXDIR=../dependencies/File_Extractor-0.4.3
HQCDIR=src/hq/c
HQASMDIR=src/hq/asm

View File

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

View File

@ -974,39 +974,39 @@
Name="GB"
>
<File
RelativePath=".\src\gb\gb.cpp"
RelativePath=".\src\dmg\gb.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbCheats.cpp"
RelativePath=".\src\dmg\gbCheats.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbDis.cpp"
RelativePath=".\src\dmg\gbDis.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbGfx.cpp"
RelativePath=".\src\dmg\gbGfx.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbGlobals.cpp"
RelativePath=".\src\dmg\gbGlobals.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbMemory.cpp"
RelativePath=".\src\dmg\gbMemory.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbPrinter.cpp"
RelativePath=".\src\dmg\gbPrinter.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbSGB.cpp"
RelativePath=".\src\dmg\gbSGB.cpp"
>
</File>
<File
RelativePath=".\src\gb\gbSound.cpp"
RelativePath=".\src\dmg\gbSound.cpp"
>
</File>
</Filter>
@ -1372,39 +1372,39 @@
Name="GB"
>
<File
RelativePath=".\src\gb\gb.h"
RelativePath=".\src\dmg\gb.h"
>
</File>
<File
RelativePath=".\src\gb\gbCheats.h"
RelativePath=".\src\dmg\gbCheats.h"
>
</File>
<File
RelativePath=".\src\gb\gbCodes.h"
RelativePath=".\src\dmg\gbCodes.h"
>
</File>
<File
RelativePath=".\src\gb\gbCodesCB.h"
RelativePath=".\src\dmg\gbCodesCB.h"
>
</File>
<File
RelativePath=".\src\gb\gbGlobals.h"
RelativePath=".\src\dmg\gbGlobals.h"
>
</File>
<File
RelativePath=".\src\gb\gbMemory.h"
RelativePath=".\src\dmg\gbMemory.h"
>
</File>
<File
RelativePath=".\src\gb\gbPrinter.h"
RelativePath=".\src\dmg\gbPrinter.h"
>
</File>
<File
RelativePath=".\src\gb\gbSGB.h"
RelativePath=".\src\dmg\gbSGB.h"
>
</File>
<File
RelativePath=".\src\gb\gbSound.h"
RelativePath=".\src\dmg\gbSound.h"
>
</File>
</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++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// 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
// 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_GB_GB_H
#define VBA_GB_GB_H
#define C_FLAG 0x10
#define H_FLAG 0x20
#define N_FLAG 0x40
#define Z_FLAG 0x80
typedef union {
struct {
#ifdef WORDS_BIGENDIAN
u8 B1, B0;
#else
u8 B0,B1;
#endif
} B;
u16 W;
} gbRegister;
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 *);
extern bool gbWriteSaveState(const char *);
extern bool gbWriteMemSaveState(char *, int);
extern bool gbReadSaveState(const char *);
extern bool gbReadMemSaveState(char *, int);
extern void gbSgbRenderBorder();
extern bool gbWritePNGFile(const char *);
extern bool gbWriteBMPFile(const char *);
extern bool gbReadGSASnapshot(const char *);
extern struct EmulatedSystem GBSystem;
#endif
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// 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
// 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_GB_GB_H
#define VBA_GB_GB_H
#define C_FLAG 0x10
#define H_FLAG 0x20
#define N_FLAG 0x40
#define Z_FLAG 0x80
typedef union {
struct {
#ifdef WORDS_BIGENDIAN
u8 B1, B0;
#else
u8 B0,B1;
#endif
} B;
u16 W;
} gbRegister;
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 *);
extern bool gbWriteSaveState(const char *);
extern bool gbWriteMemSaveState(char *, int);
extern bool gbReadSaveState(const char *);
extern bool gbReadMemSaveState(char *, int);
extern void gbSgbRenderBorder();
extern bool gbWritePNGFile(const char *);
extern bool gbWriteBMPFile(const char *);
extern bool gbReadGSASnapshot(const char *);
extern struct EmulatedSystem GBSystem;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +1,62 @@
// -*- 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_GB_GBCHEATS_H
#define __VBA_GB_GBCHEATS_H
#include "../System.h"
struct gbXxCheat {
char cheatDesc[100];
char cheatCode[20];
};
struct gbCheat {
char cheatCode[20];
char cheatDesc[32];
u16 address;
int code;
u8 compare;
u8 value;
bool enabled;
};
void gbCheatsSaveGame(gzFile);
void gbCheatsReadGame(gzFile, int);
void gbCheatsSaveCheatList(const char *);
bool gbCheatsLoadCheatList(const char *);
bool gbCheatReadGSCodeFile(const char *);
bool gbAddGsCheat(const char *, const char*);
bool gbAddGgCheat(const char *, const char*);
void gbCheatRemove(int);
void gbCheatRemoveAll();
void gbCheatEnable(int);
void gbCheatDisable(int);
u8 gbCheatRead(u16);
void gbCheatWrite(bool);
bool gbVerifyGsCode(const char *code);
bool gbVerifyGgCode(const char *code);
extern int gbCheatNumber;
extern gbCheat gbCheatList[100];
extern bool gbCheatMap[0x10000];
#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_GB_GBCHEATS_H
#define __VBA_GB_GBCHEATS_H
#include "../System.h"
struct gbXxCheat {
char cheatDesc[100];
char cheatCode[20];
};
struct gbCheat {
char cheatCode[20];
char cheatDesc[32];
u16 address;
int code;
u8 compare;
u8 value;
bool enabled;
};
void gbCheatsSaveGame(gzFile);
void gbCheatsReadGame(gzFile, int);
void gbCheatsSaveCheatList(const char *);
bool gbCheatsLoadCheatList(const char *);
bool gbCheatReadGSCodeFile(const char *);
bool gbAddGsCheat(const char *, const char*);
bool gbAddGgCheat(const char *, const char*);
void gbCheatRemove(int);
void gbCheatRemoveAll();
void gbCheatEnable(int);
void gbCheatDisable(int);
u8 gbCheatRead(u16);
void gbCheatWrite(bool);
bool gbVerifyGsCode(const char *code);
bool gbVerifyGgCode(const char *code);
extern int gbCheatNumber;
extern gbCheat gbCheatList[100];
extern bool gbCheatMap[0x10000];
#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.
// 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 <string.h>
#include "../System.h"
#include "gbGlobals.h"
typedef struct {
u8 mask;
u8 value;
const char *mnen;
} GBOPCODE;
#define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff]
static const char *registers[] =
{ "B", "C", "D", "E", "H", "L", "(HL)", "A" };
static const char *registers16[] =
{ "BC", "DE", "HL", "SP", // for some operations
"BC", "DE", "HL", "AF" }; // for push/pop
static const char *cond[] =
{ "NZ", "Z", "NC", "C" };
static char hexDigits[16] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
static GBOPCODE opcodes[] = {
{ 0xff, 0x00, "NOP" },
{ 0xcf, 0x01, "LD %R4,%W" },
{ 0xff, 0x02, "LD (BC),A" },
{ 0xcf, 0x03, "INC %R4" },
{ 0xc7, 0x04, "INC %r3" },
{ 0xc7, 0x05, "DEC %r3" },
{ 0xc7, 0x06, "LD %r3,%B" },
{ 0xff, 0x07, "RLCA" },
{ 0xff, 0x08, "LD (%W),SP" },
{ 0xcf, 0x09, "ADD HL,%R4" },
{ 0xff, 0x0a, "LD A,(BC)" },
{ 0xcf, 0x0b, "DEC %R4" },
{ 0xff, 0x0f, "RRCA" },
{ 0xff, 0x10, "STOP" },
{ 0xff, 0x12, "LD (DE),A" },
{ 0xff, 0x17, "RLA" },
{ 0xff, 0x18, "JR %d" },
{ 0xff, 0x1a, "LD A,(DE)" },
{ 0xff, 0x1f, "RRA" },
{ 0xe7, 0x20, "JR %c3,%d" },
{ 0xff, 0x22, "LDI (HL),A" },
{ 0xff, 0x27, "DAA" },
{ 0xff, 0x2a, "LDI A,(HL)" },
{ 0xff, 0x2f, "CPL" },
{ 0xff, 0x32, "LDD (HL),A" },
{ 0xff, 0x37, "SCF" },
{ 0xff, 0x3a, "LDD A,(HL)" },
{ 0xff, 0x3f, "CCF" },
{ 0xff, 0x76, "HALT" },
{ 0xc0, 0x40, "LD %r3,%r0" },
{ 0xf8, 0x80, "ADD A,%r0" },
{ 0xf8, 0x88, "ADC A,%r0" },
{ 0xf8, 0x90, "SUB %r0" },
{ 0xf8, 0x98, "SBC A,%r0" },
{ 0xf8, 0xa0, "AND %r0" },
{ 0xf8, 0xa8, "XOR %r0" },
{ 0xf8, 0xb0, "OR %r0" },
{ 0xf8, 0xb8, "CP %r0" },
{ 0xe7, 0xc0, "RET %c3" },
{ 0xcf, 0xc1, "POP %t4" },
{ 0xe7, 0xc2, "JP %c3,%W" },
{ 0xff, 0xc3, "JP %W" },
{ 0xe7, 0xc4, "CALL %c3,%W" },
{ 0xcf, 0xc5, "PUSH %t4" },
{ 0xff, 0xc6, "ADD A,%B" },
{ 0xc7, 0xc7, "RST %P" },
{ 0xff, 0xc9, "RET" },
{ 0xff, 0xcd, "CALL %W" },
{ 0xff, 0xce, "ADC %B" },
{ 0xff, 0xd6, "SUB %B" },
{ 0xff, 0xd9, "RETI" },
{ 0xff, 0xde, "SBC %B" },
{ 0xff, 0xe0, "LD (FF%B),A" },
{ 0xff, 0xe2, "LD (FF00h+C),A" },
{ 0xff, 0xe6, "AND %B" },
{ 0xff, 0xe8, "ADD SP,%D" },
{ 0xff, 0xe9, "LD PC,HL" },
{ 0xff, 0xea, "LD (%W),A" },
{ 0xff, 0xee, "XOR %B" },
{ 0xff, 0xf0, "LD A,(FF%B)" },
{ 0xff, 0xf2, "LD A,(FF00h+C)" },
{ 0xff, 0xf3, "DI" },
{ 0xff, 0xf6, "OR %B" },
{ 0xff, 0xf8, "LD HL,SP%D" },
{ 0xff, 0xf9, "LD SP,HL" },
{ 0xff, 0xfa, "LD A,(%W)" },
{ 0xff, 0xfb, "EI" },
{ 0xff, 0xfe, "CP %B" },
{ 0x00, 0x00, "DB %B" }
};
static GBOPCODE cbOpcodes[] = {
{ 0xf8, 0x00, "RLC %r0" },
{ 0xf8, 0x08, "RRC %r0" },
{ 0xf8, 0x10, "RL %r0" },
{ 0xf8, 0x18, "RR %r0" },
{ 0xf8, 0x20, "SLA %r0" },
{ 0xf8, 0x28, "SRA %r0" },
{ 0xf8, 0x30, "SWAP %r0" },
{ 0xf8, 0x38, "SRL %r0" },
{ 0xc0, 0x40, "BIT %b,%r0" },
{ 0xc0, 0x80, "RES %b,%r0" },
{ 0xc0, 0xc0, "SET %b,%r0" },
{ 0x00, 0x00, "DB CBh,%B" }
};
static char *addHex(char *p, u8 value)
{
*p++ = hexDigits[value >> 4];
*p++ = hexDigits[value & 15];
return p;
}
static char *addHex16(char *p, u16 value)
{
p = addHex(p, value>>8);
return addHex(p, value & 255);
}
static char *addStr(char *p, const char *s)
{
while(*s) {
*p++ = *s++;
}
return p;
}
int gbDis(char *buffer, u16 address)
{
char *p = buffer;
int instr = 1;
u16 addr = address;
sprintf(p, "%04x ", address);
p += 12;
u8 opcode = GB_READ(address);
address++;
const char *mnen;
GBOPCODE *op;
if(opcode == 0xcb) {
opcode = GB_READ(address);
address++;
instr++;
op = cbOpcodes;
} else {
op = opcodes;
}
while(op->value != (opcode & op->mask)) op++;
mnen = op->mnen;
u8 b0, b1;
s8 disp;
int shift;
while(*mnen) {
if(*mnen == '%') {
mnen++;
switch(*mnen++) {
case 'W':
b0 = GB_READ(address);
address++;
b1 = GB_READ(address);
address++;
p = addHex16(p, b0|b1<<8);
instr += 2;
*p++ = 'h';
break;
case 'B':
p = addHex(p, GB_READ(address));
*p++ = 'h';
address++;
instr++;
break;
case 'D':
disp = GB_READ(address);
if(disp >= 0)
*p++ = '+';
p += sprintf(p, "%d", disp);
instr++;
break;
case 'd':
disp = GB_READ(address);
address++;
p = addHex16(p, address+disp);
*p++ = 'h';
instr++;
break;
case 'b':
// kind of a hack, but it works :-)
*p++ = hexDigits[(opcode >> 3) & 7];
break;
case 'r':
shift = *mnen++ - '0';
p = addStr(p, registers[(opcode >> shift) & 7]);
break;
case 'R':
shift = *mnen++ - '0';
p = addStr(p, registers16[(opcode >> shift) & 3]);
break;
case 't':
shift = *mnen++ - '0';
p = addStr(p, registers16[4+((opcode >> shift) & 3)]);
break;
case 'P':
p = addHex(p, ((opcode >> 3) & 7) * 8);
break;
case 'c':
shift = *mnen++ - '0';
p = addStr(p, cond[(opcode >> shift) & 3]);
break;
}
} else
*p++ = *mnen++;
}
for(int i = 0; i < instr; i++) {
u16 a = addr + i;
addHex(buffer+5+i*2, GB_READ(a));
}
*p = 0;
return instr;
}
// 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 <string.h>
#include "../System.h"
#include "gbGlobals.h"
typedef struct {
u8 mask;
u8 value;
const char *mnen;
} GBOPCODE;
#define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff]
static const char *registers[] =
{ "B", "C", "D", "E", "H", "L", "(HL)", "A" };
static const char *registers16[] =
{ "BC", "DE", "HL", "SP", // for some operations
"BC", "DE", "HL", "AF" }; // for push/pop
static const char *cond[] =
{ "NZ", "Z", "NC", "C" };
static char hexDigits[16] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
static GBOPCODE opcodes[] = {
{ 0xff, 0x00, "NOP" },
{ 0xcf, 0x01, "LD %R4,%W" },
{ 0xff, 0x02, "LD (BC),A" },
{ 0xcf, 0x03, "INC %R4" },
{ 0xc7, 0x04, "INC %r3" },
{ 0xc7, 0x05, "DEC %r3" },
{ 0xc7, 0x06, "LD %r3,%B" },
{ 0xff, 0x07, "RLCA" },
{ 0xff, 0x08, "LD (%W),SP" },
{ 0xcf, 0x09, "ADD HL,%R4" },
{ 0xff, 0x0a, "LD A,(BC)" },
{ 0xcf, 0x0b, "DEC %R4" },
{ 0xff, 0x0f, "RRCA" },
{ 0xff, 0x10, "STOP" },
{ 0xff, 0x12, "LD (DE),A" },
{ 0xff, 0x17, "RLA" },
{ 0xff, 0x18, "JR %d" },
{ 0xff, 0x1a, "LD A,(DE)" },
{ 0xff, 0x1f, "RRA" },
{ 0xe7, 0x20, "JR %c3,%d" },
{ 0xff, 0x22, "LDI (HL),A" },
{ 0xff, 0x27, "DAA" },
{ 0xff, 0x2a, "LDI A,(HL)" },
{ 0xff, 0x2f, "CPL" },
{ 0xff, 0x32, "LDD (HL),A" },
{ 0xff, 0x37, "SCF" },
{ 0xff, 0x3a, "LDD A,(HL)" },
{ 0xff, 0x3f, "CCF" },
{ 0xff, 0x76, "HALT" },
{ 0xc0, 0x40, "LD %r3,%r0" },
{ 0xf8, 0x80, "ADD A,%r0" },
{ 0xf8, 0x88, "ADC A,%r0" },
{ 0xf8, 0x90, "SUB %r0" },
{ 0xf8, 0x98, "SBC A,%r0" },
{ 0xf8, 0xa0, "AND %r0" },
{ 0xf8, 0xa8, "XOR %r0" },
{ 0xf8, 0xb0, "OR %r0" },
{ 0xf8, 0xb8, "CP %r0" },
{ 0xe7, 0xc0, "RET %c3" },
{ 0xcf, 0xc1, "POP %t4" },
{ 0xe7, 0xc2, "JP %c3,%W" },
{ 0xff, 0xc3, "JP %W" },
{ 0xe7, 0xc4, "CALL %c3,%W" },
{ 0xcf, 0xc5, "PUSH %t4" },
{ 0xff, 0xc6, "ADD A,%B" },
{ 0xc7, 0xc7, "RST %P" },
{ 0xff, 0xc9, "RET" },
{ 0xff, 0xcd, "CALL %W" },
{ 0xff, 0xce, "ADC %B" },
{ 0xff, 0xd6, "SUB %B" },
{ 0xff, 0xd9, "RETI" },
{ 0xff, 0xde, "SBC %B" },
{ 0xff, 0xe0, "LD (FF%B),A" },
{ 0xff, 0xe2, "LD (FF00h+C),A" },
{ 0xff, 0xe6, "AND %B" },
{ 0xff, 0xe8, "ADD SP,%D" },
{ 0xff, 0xe9, "LD PC,HL" },
{ 0xff, 0xea, "LD (%W),A" },
{ 0xff, 0xee, "XOR %B" },
{ 0xff, 0xf0, "LD A,(FF%B)" },
{ 0xff, 0xf2, "LD A,(FF00h+C)" },
{ 0xff, 0xf3, "DI" },
{ 0xff, 0xf6, "OR %B" },
{ 0xff, 0xf8, "LD HL,SP%D" },
{ 0xff, 0xf9, "LD SP,HL" },
{ 0xff, 0xfa, "LD A,(%W)" },
{ 0xff, 0xfb, "EI" },
{ 0xff, 0xfe, "CP %B" },
{ 0x00, 0x00, "DB %B" }
};
static GBOPCODE cbOpcodes[] = {
{ 0xf8, 0x00, "RLC %r0" },
{ 0xf8, 0x08, "RRC %r0" },
{ 0xf8, 0x10, "RL %r0" },
{ 0xf8, 0x18, "RR %r0" },
{ 0xf8, 0x20, "SLA %r0" },
{ 0xf8, 0x28, "SRA %r0" },
{ 0xf8, 0x30, "SWAP %r0" },
{ 0xf8, 0x38, "SRL %r0" },
{ 0xc0, 0x40, "BIT %b,%r0" },
{ 0xc0, 0x80, "RES %b,%r0" },
{ 0xc0, 0xc0, "SET %b,%r0" },
{ 0x00, 0x00, "DB CBh,%B" }
};
static char *addHex(char *p, u8 value)
{
*p++ = hexDigits[value >> 4];
*p++ = hexDigits[value & 15];
return p;
}
static char *addHex16(char *p, u16 value)
{
p = addHex(p, value>>8);
return addHex(p, value & 255);
}
static char *addStr(char *p, const char *s)
{
while(*s) {
*p++ = *s++;
}
return p;
}
int gbDis(char *buffer, u16 address)
{
char *p = buffer;
int instr = 1;
u16 addr = address;
sprintf(p, "%04x ", address);
p += 12;
u8 opcode = GB_READ(address);
address++;
const char *mnen;
GBOPCODE *op;
if(opcode == 0xcb) {
opcode = GB_READ(address);
address++;
instr++;
op = cbOpcodes;
} else {
op = opcodes;
}
while(op->value != (opcode & op->mask)) op++;
mnen = op->mnen;
u8 b0, b1;
s8 disp;
int shift;
while(*mnen) {
if(*mnen == '%') {
mnen++;
switch(*mnen++) {
case 'W':
b0 = GB_READ(address);
address++;
b1 = GB_READ(address);
address++;
p = addHex16(p, b0|b1<<8);
instr += 2;
*p++ = 'h';
break;
case 'B':
p = addHex(p, GB_READ(address));
*p++ = 'h';
address++;
instr++;
break;
case 'D':
disp = GB_READ(address);
if(disp >= 0)
*p++ = '+';
p += sprintf(p, "%d", disp);
instr++;
break;
case 'd':
disp = GB_READ(address);
address++;
p = addHex16(p, address+disp);
*p++ = 'h';
instr++;
break;
case 'b':
// kind of a hack, but it works :-)
*p++ = hexDigits[(opcode >> 3) & 7];
break;
case 'r':
shift = *mnen++ - '0';
p = addStr(p, registers[(opcode >> shift) & 7]);
break;
case 'R':
shift = *mnen++ - '0';
p = addStr(p, registers16[(opcode >> shift) & 3]);
break;
case 't':
shift = *mnen++ - '0';
p = addStr(p, registers16[4+((opcode >> shift) & 3)]);
break;
case 'P':
p = addHex(p, ((opcode >> 3) & 7) * 8);
break;
case 'c':
shift = *mnen++ - '0';
p = addStr(p, cond[(opcode >> shift) & 3]);
break;
}
} else
*p++ = *mnen++;
}
for(int i = 0; i < instr; i++) {
u16 a = addr + i;
addHex(buffer+5+i*2, GB_READ(a));
}
*p = 0;
return instr;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,57 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// 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
// 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"
u8 *gbMemoryMap[16];
int gbRomSizeMask = 0;
int gbRomSize = 0;
int gbRamSizeMask = 0;
int gbRamSize = 0;
int gbTAMA5ramSize = 0;
u8 *gbMemory = NULL;
u8 *gbVram = NULL;
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};
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];
int gbColorOption = 0;
int gbPaletteOption = 0;
int gbEmulatorType = 0;
int gbBorderOn = 1;
int gbBorderAutomatic = 0;
int gbBorderLineSkip = 160;
int gbBorderRowSkip = 0;
int gbBorderColumnSkip = 0;
int gbDmaTicks = 0;
u8 (*gbSerialFunction)(u8) = NULL;
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// 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
// 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"
u8 *gbMemoryMap[16];
int gbRomSizeMask = 0;
int gbRomSize = 0;
int gbRamSizeMask = 0;
int gbRamSize = 0;
int gbTAMA5ramSize = 0;
u8 *gbMemory = NULL;
u8 *gbVram = NULL;
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};
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];
int gbColorOption = 0;
int gbPaletteOption = 0;
int gbEmulatorType = 0;
int gbBorderOn = 1;
int gbBorderAutomatic = 0;
int gbBorderLineSkip = 160;
int gbBorderRowSkip = 0;
int gbBorderColumnSkip = 0;
int gbDmaTicks = 0;
u8 (*gbSerialFunction)(u8) = NULL;

View File

@ -1,89 +1,89 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// 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
// 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.
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;
extern u8 *gbVram;
extern u8 *gbWram;
extern u8 *gbMemory;
extern u16 *gbLineBuffer;
extern u8 *gbTAMA5ram;
extern u8 *gbMemoryMap[16];
extern int gbFrameSkip;
extern u16 gbColorFilter[32768];
extern int gbColorOption;
extern int gbPaletteOption;
extern int gbEmulatorType;
extern int gbBorderOn;
extern int gbBorderAutomatic;
extern int gbCgbMode;
extern int gbSgbMode;
extern int gbWindowLine;
extern int gbSpeed;
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;
extern u8 register_SCY;
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;
extern int gbBorderColumnSkip;
extern int gbDmaTicks;
extern void gbRenderLine();
extern void gbDrawSprites(bool);
extern u8 (*gbSerialFunction)(u8);
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// 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
// 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.
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;
extern u8 *gbVram;
extern u8 *gbWram;
extern u8 *gbMemory;
extern u16 *gbLineBuffer;
extern u8 *gbTAMA5ram;
extern u8 *gbMemoryMap[16];
extern int gbFrameSkip;
extern u16 gbColorFilter[32768];
extern int gbColorOption;
extern int gbPaletteOption;
extern int gbEmulatorType;
extern int gbBorderOn;
extern int gbBorderAutomatic;
extern int gbCgbMode;
extern int gbSgbMode;
extern int gbWindowLine;
extern int gbSpeed;
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;
extern u8 register_SCY;
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;
extern int gbBorderColumnSkip;
extern int gbDmaTicks;
extern void gbRenderLine();
extern void gbDrawSprites(bool);
extern u8 (*gbSerialFunction)(u8);

File diff suppressed because it is too large Load Diff

View File

@ -1,206 +1,206 @@
// -*- 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.
#include <time.h>
struct mapperMBC1 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperMemoryModel;
int mapperROMHighAddress;
int mapperRAMAddress;
int mapperRomBank0Remapping;
};
struct mapperMBC2 {
int mapperRAMEnable;
int mapperROMBank;
};
struct mapperMBC3 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int mapperClockLatch;
int mapperClockRegister;
int mapperSeconds;
int mapperMinutes;
int mapperHours;
int mapperDays;
int mapperControl;
int mapperLSeconds;
int mapperLMinutes;
int mapperLHours;
int mapperLDays;
int mapperLControl;
time_t mapperLastTime;
};
struct mapperMBC5 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperROMHighAddress;
int mapperRAMAddress;
int isRumbleCartridge;
};
struct mapperMBC7 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int cs;
int sk;
int state;
int buffer;
int idle;
int count;
int code;
int address;
int writeEnable;
int value;
};
struct mapperHuC1 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperMemoryModel;
int mapperROMHighAddress;
int mapperRAMAddress;
};
struct mapperHuC3 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int mapperAddress;
int mapperRAMFlag;
int mapperRAMValue;
int mapperRegister1;
int mapperRegister2;
int mapperRegister3;
int mapperRegister4;
int mapperRegister5;
int mapperRegister6;
int mapperRegister7;
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);
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);
void mapperHuC1ROM(u16,u8);
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);
extern void memoryUpdateMapMBC1();
extern void memoryUpdateMapMBC2();
extern void memoryUpdateMapMBC3();
extern void memoryUpdateMapMBC5();
extern void memoryUpdateMapMBC7();
extern void memoryUpdateMapHuC1();
extern void memoryUpdateMapHuC3();
extern void memoryUpdateMapTAMA5();
extern void memoryUpdateMapMMM01();
extern void memoryUpdateMapGS3();
// -*- 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.
#include <time.h>
struct mapperMBC1 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperMemoryModel;
int mapperROMHighAddress;
int mapperRAMAddress;
int mapperRomBank0Remapping;
};
struct mapperMBC2 {
int mapperRAMEnable;
int mapperROMBank;
};
struct mapperMBC3 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int mapperClockLatch;
int mapperClockRegister;
int mapperSeconds;
int mapperMinutes;
int mapperHours;
int mapperDays;
int mapperControl;
int mapperLSeconds;
int mapperLMinutes;
int mapperLHours;
int mapperLDays;
int mapperLControl;
time_t mapperLastTime;
};
struct mapperMBC5 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperROMHighAddress;
int mapperRAMAddress;
int isRumbleCartridge;
};
struct mapperMBC7 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int cs;
int sk;
int state;
int buffer;
int idle;
int count;
int code;
int address;
int writeEnable;
int value;
};
struct mapperHuC1 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperMemoryModel;
int mapperROMHighAddress;
int mapperRAMAddress;
};
struct mapperHuC3 {
int mapperRAMEnable;
int mapperROMBank;
int mapperRAMBank;
int mapperRAMAddress;
int mapperAddress;
int mapperRAMFlag;
int mapperRAMValue;
int mapperRegister1;
int mapperRegister2;
int mapperRegister3;
int mapperRegister4;
int mapperRegister5;
int mapperRegister6;
int mapperRegister7;
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);
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);
void mapperHuC1ROM(u16,u8);
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);
extern void memoryUpdateMapMBC1();
extern void memoryUpdateMapMBC2();
extern void memoryUpdateMapMBC3();
extern void memoryUpdateMapMBC5();
extern void memoryUpdateMapMBC7();
extern void memoryUpdateMapHuC1();
extern void memoryUpdateMapHuC3();
extern void memoryUpdateMapTAMA5();
extern void memoryUpdateMapMMM01();
extern void memoryUpdateMapGS3();

View File

@ -1,229 +1,229 @@
// 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"
u8 gbPrinterStatus = 0;
int gbPrinterState = 0;
u8 gbPrinterData[0x280*9];
u8 gbPrinterPacket[0x400];
int gbPrinterCount = 0;
int gbPrinterDataCount = 0;
int gbPrinterDataSize = 0;
int gbPrinterResult = 0;
bool gbPrinterCheckCRC()
{
u16 crc = 0;
for(int i = 2; i < (6+gbPrinterDataSize); i++) {
crc += gbPrinterPacket[i];
}
int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] +
(gbPrinterPacket[7+gbPrinterDataSize]<<8);
return msgCrc == crc;
}
void gbPrinterReset()
{
gbPrinterState = 0;
gbPrinterDataSize = 0;
gbPrinterDataCount = 0;
gbPrinterCount = 0;
gbPrinterStatus = 0;
gbPrinterResult = 0;
}
void gbPrinterShowData()
{
systemGbPrint(gbPrinterData,
gbPrinterPacket[6],
gbPrinterPacket[7],
gbPrinterPacket[8],
gbPrinterPacket[9]);
/*
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0);
PALETTE pal;
pal[0].r = 255;
pal[0].g = 255;
pal[0].b = 255;
pal[1].r = 168;
pal[1].g = 168;
pal[1].b = 168;
pal[2].r = 96;
pal[2].g = 96;
pal[2].b = 96;
pal[3].r = 0;
pal[3].g = 0;
pal[3].b = 0;
set_palette(pal);
acquire_screen();
u8 *data = gbPrinterData;
for(int y = 0; y < 0x12; y++) {
for(int x = 0; x < 0x14; x++) {
for(int k = 0; k < 8; k++) {
int a = *data++;
int b = *data++;
for(int j = 0; j < 8; j++) {
int mask = 1 << (7-j);
int c = 0;
if(a & mask)
c++;
if(b & mask)
c+=2;
putpixel(screen, x*8+j, y*8+k, c);
}
}
}
}
release_screen();
while(!keypressed()) {
}
*/
}
void gbPrinterReceiveData()
{
if(gbPrinterPacket[3]) { // compressed
u8 *data = &gbPrinterPacket[6];
u8 *dest = &gbPrinterData[gbPrinterDataCount];
int len = 0;
while(len < gbPrinterDataSize) {
u8 control = *data++;
if(control & 0x80) { // repeated data
control &= 0x7f;
control += 2;
memset(dest, *data++, control);
len += control;
dest += control;
} else { // raw data
control++;
memcpy(dest, data, control);
dest += control;
data += control;
len += control;
}
}
} else {
memcpy(&gbPrinterData[gbPrinterDataCount],
&gbPrinterPacket[6],
gbPrinterDataSize);
gbPrinterDataCount += gbPrinterDataSize;
}
}
void gbPrinterCommand()
{
switch(gbPrinterPacket[2]) {
case 0x01:
// reset/initialize packet
gbPrinterDataCount = 0;
gbPrinterStatus = 0;
break;
case 0x02:
// print packet
gbPrinterShowData();
break;
case 0x04:
// data packet
gbPrinterReceiveData();
break;
case 0x0f:
// NUL packet
break;
}
}
u8 gbPrinterSend(u8 b)
{
switch(gbPrinterState) {
case 0:
gbPrinterCount = 0;
// receiving preamble
if(b == 0x88) {
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++;
} else {
// todo: handle failure
gbPrinterReset();
}
break;
case 1:
// receiving preamble
if(b == 0x33) {
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++;
} else {
// todo: handle failure
gbPrinterReset();
}
break;
case 2:
// receiving header
gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCount == 6) {
gbPrinterState++;
gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8);
}
break;
case 3:
// receiving data
if(gbPrinterDataSize) {
gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCount == (6+gbPrinterDataSize)) {
gbPrinterState++;
}
break;
}
gbPrinterState++;
// intentionally move to next if no data to receive
case 4:
// receiving CRC
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++;
break;
case 5:
// receiving CRC-2
gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCheckCRC()) {
gbPrinterCommand();
}
gbPrinterState++;
break;
case 6:
// receiving dummy 1
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterResult = 0x81;
gbPrinterState++;
break;
case 7:
// receiving dummy 2
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterResult = gbPrinterStatus;
gbPrinterState = 0;
gbPrinterCount = 0;
break;
}
return gbPrinterResult;
}
// 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"
u8 gbPrinterStatus = 0;
int gbPrinterState = 0;
u8 gbPrinterData[0x280*9];
u8 gbPrinterPacket[0x400];
int gbPrinterCount = 0;
int gbPrinterDataCount = 0;
int gbPrinterDataSize = 0;
int gbPrinterResult = 0;
bool gbPrinterCheckCRC()
{
u16 crc = 0;
for(int i = 2; i < (6+gbPrinterDataSize); i++) {
crc += gbPrinterPacket[i];
}
int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] +
(gbPrinterPacket[7+gbPrinterDataSize]<<8);
return msgCrc == crc;
}
void gbPrinterReset()
{
gbPrinterState = 0;
gbPrinterDataSize = 0;
gbPrinterDataCount = 0;
gbPrinterCount = 0;
gbPrinterStatus = 0;
gbPrinterResult = 0;
}
void gbPrinterShowData()
{
systemGbPrint(gbPrinterData,
gbPrinterPacket[6],
gbPrinterPacket[7],
gbPrinterPacket[8],
gbPrinterPacket[9]);
/*
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0);
PALETTE pal;
pal[0].r = 255;
pal[0].g = 255;
pal[0].b = 255;
pal[1].r = 168;
pal[1].g = 168;
pal[1].b = 168;
pal[2].r = 96;
pal[2].g = 96;
pal[2].b = 96;
pal[3].r = 0;
pal[3].g = 0;
pal[3].b = 0;
set_palette(pal);
acquire_screen();
u8 *data = gbPrinterData;
for(int y = 0; y < 0x12; y++) {
for(int x = 0; x < 0x14; x++) {
for(int k = 0; k < 8; k++) {
int a = *data++;
int b = *data++;
for(int j = 0; j < 8; j++) {
int mask = 1 << (7-j);
int c = 0;
if(a & mask)
c++;
if(b & mask)
c+=2;
putpixel(screen, x*8+j, y*8+k, c);
}
}
}
}
release_screen();
while(!keypressed()) {
}
*/
}
void gbPrinterReceiveData()
{
if(gbPrinterPacket[3]) { // compressed
u8 *data = &gbPrinterPacket[6];
u8 *dest = &gbPrinterData[gbPrinterDataCount];
int len = 0;
while(len < gbPrinterDataSize) {
u8 control = *data++;
if(control & 0x80) { // repeated data
control &= 0x7f;
control += 2;
memset(dest, *data++, control);
len += control;
dest += control;
} else { // raw data
control++;
memcpy(dest, data, control);
dest += control;
data += control;
len += control;
}
}
} else {
memcpy(&gbPrinterData[gbPrinterDataCount],
&gbPrinterPacket[6],
gbPrinterDataSize);
gbPrinterDataCount += gbPrinterDataSize;
}
}
void gbPrinterCommand()
{
switch(gbPrinterPacket[2]) {
case 0x01:
// reset/initialize packet
gbPrinterDataCount = 0;
gbPrinterStatus = 0;
break;
case 0x02:
// print packet
gbPrinterShowData();
break;
case 0x04:
// data packet
gbPrinterReceiveData();
break;
case 0x0f:
// NUL packet
break;
}
}
u8 gbPrinterSend(u8 b)
{
switch(gbPrinterState) {
case 0:
gbPrinterCount = 0;
// receiving preamble
if(b == 0x88) {
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++;
} else {
// todo: handle failure
gbPrinterReset();
}
break;
case 1:
// receiving preamble
if(b == 0x33) {
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++;
} else {
// todo: handle failure
gbPrinterReset();
}
break;
case 2:
// receiving header
gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCount == 6) {
gbPrinterState++;
gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8);
}
break;
case 3:
// receiving data
if(gbPrinterDataSize) {
gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCount == (6+gbPrinterDataSize)) {
gbPrinterState++;
}
break;
}
gbPrinterState++;
// intentionally move to next if no data to receive
case 4:
// receiving CRC
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++;
break;
case 5:
// receiving CRC-2
gbPrinterPacket[gbPrinterCount++] = b;
if(gbPrinterCheckCRC()) {
gbPrinterCommand();
}
gbPrinterState++;
break;
case 6:
// receiving dummy 1
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterResult = 0x81;
gbPrinterState++;
break;
case 7:
// receiving dummy 2
gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterResult = gbPrinterStatus;
gbPrinterState = 0;
gbPrinterCount = 0;
break;
}
return gbPrinterResult;
}

View File

@ -1,20 +1,20 @@
// -*- 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.
extern u8 gbPrinterSend(u8 b);
// -*- 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.
extern u8 gbPrinterSend(u8 b);

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +1,39 @@
// -*- 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.
void gbSgbInit();
void gbSgbShutdown();
void gbSgbCommand();
void gbSgbResetPacketState();
void gbSgbReset();
void gbSgbDoBitTransfer(u8);
void gbSgbSaveGame(gzFile);
void gbSgbReadGame(gzFile, int version);
void gbSgbRenderBorder();
extern u8 gbSgbATF[20*18];
extern int gbSgbMode;
extern int gbSgbMask;
extern int gbSgbMultiplayer;
extern u8 gbSgbNextController;
extern int gbSgbPacketTimeout;
extern u8 gbSgbReadingController;
extern int gbSgbFourPlayers;
// -*- 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.
void gbSgbInit();
void gbSgbShutdown();
void gbSgbCommand();
void gbSgbResetPacketState();
void gbSgbReset();
void gbSgbDoBitTransfer(u8);
void gbSgbSaveGame(gzFile);
void gbSgbReadGame(gzFile, int version);
void gbSgbRenderBorder();
extern u8 gbSgbATF[20*18];
extern int gbSgbMode;
extern int gbSgbMask;
extern int gbSgbMultiplayer;
extern u8 gbSgbNextController;
extern int gbSgbPacketTimeout;
extern u8 gbSgbReadingController;
extern int gbSgbFourPlayers;

View File

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

View File

@ -1,74 +1,74 @@
// -*- 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;
struct gb_effects_config_t
{
bool enabled; // false = disable all effects
float echo; // 0.0 = none, 1.0 = lots
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
bool surround; // true = put some channels in back
};
// Can be changed at any time, probably from another thread too.
// Sound will notice changes during next 1/100 second.
extern gb_effects_config_t gb_effects_config;
// -*- 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;
struct gb_effects_config_t
{
bool enabled; // false = disable all effects
float echo; // 0.0 = none, 1.0 = lots
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
bool surround; // true = put some channels in back
};
// Can be changed at any time, probably from another thread too.
// Sound will notice changes during next 1/100 second.
extern gb_effects_config_t gb_effects_config;

View File

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

View File

@ -34,7 +34,7 @@
#include "../GBA.h"
#include "../Globals.h"
#include "../Util.h"
#include "../gb/gbGlobals.h"
#include "../dmg/gbGlobals.h"
#include "..\memgzio.h"
//Math
@ -97,8 +97,9 @@ public:
virtual void DisableOpenGL();
virtual bool initialize();
virtual void cleanup();
virtual void render();
virtual void clear();
virtual void render();
virtual bool changeRenderSize( int w, int h );
virtual void resize( int w, int h );
virtual void setOption( const char *, int );
@ -217,6 +218,124 @@ void OpenGLDisplay::cleanup()
//init renderer
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.mode640Available = FALSE;
theApp.mode800Available = FALSE;