gb folder is done, next up gba, once this is all up I'm going to look at enhancing the cores

This commit is contained in:
Zach Bacon 2016-07-09 11:41:31 -04:00
parent 1f37311a4a
commit 1944613131
No known key found for this signature in database
GPG Key ID: 7D110798AFE84B3A
246 changed files with 53650 additions and 56296 deletions

View File

@ -1,7 +1,7 @@
#include "../common/Types.h" #include "../common/Types.h"
#include <cstdlib> #include <cstdlib>
u8* gbMemoryMap[16]; uint8_t* gbMemoryMap[16];
int gbRomSizeMask = 0; int gbRomSizeMask = 0;
int gbRomSize = 0; int gbRomSize = 0;
@ -9,24 +9,24 @@ int gbRamSizeMask = 0;
int gbRamSize = 0; int gbRamSize = 0;
int gbTAMA5ramSize = 0; int gbTAMA5ramSize = 0;
u8* gbMemory = NULL; uint8_t* gbMemory = NULL;
u8* gbVram = NULL; uint8_t* gbVram = NULL;
u8* gbRom = NULL; uint8_t* gbRom = NULL;
u8* gbRam = NULL; uint8_t* gbRam = NULL;
u8* gbWram = NULL; uint8_t* gbWram = NULL;
u16* gbLineBuffer = NULL; uint16_t* gbLineBuffer = NULL;
u8* gbTAMA5ram = NULL; uint8_t* gbTAMA5ram = NULL;
u16 gbPalette[128]; uint16_t gbPalette[128];
u8 gbBgp[4] = { 0, 1, 2, 3 }; uint8_t gbBgp[4] = { 0, 1, 2, 3 };
u8 gbObp0[4] = { 0, 1, 2, 3 }; uint8_t gbObp0[4] = { 0, 1, 2, 3 };
u8 gbObp1[4] = { 0, 1, 2, 3 }; uint8_t 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]; uint16_t gbColorFilter[32768];
int gbColorOption = 0; int gbColorOption = 0;
int gbPaletteOption = 0; int gbPaletteOption = 0;
int gbEmulatorType = 0; int gbEmulatorType = 0;
@ -37,4 +37,4 @@ int gbBorderRowSkip = 0;
int gbBorderColumnSkip = 0; int gbBorderColumnSkip = 0;
int gbDmaTicks = 0; int gbDmaTicks = 0;
u8 (*gbSerialFunction)(u8) = NULL; uint8_t (*gbSerialFunction)(uint8_t) = NULL;

View File

@ -7,20 +7,20 @@ extern int gbRamSize;
extern int gbRamSizeMask; extern int gbRamSizeMask;
extern int gbTAMA5ramSize; extern int gbTAMA5ramSize;
extern u8* bios; extern uint8_t* bios;
extern u8* gbRom; extern uint8_t* gbRom;
extern u8* gbRam; extern uint8_t* gbRam;
extern u8* gbVram; extern uint8_t* gbVram;
extern u8* gbWram; extern uint8_t* gbWram;
extern u8* gbMemory; extern uint8_t* gbMemory;
extern u16* gbLineBuffer; extern uint16_t* gbLineBuffer;
extern u8* gbTAMA5ram; extern uint8_t* gbTAMA5ram;
extern u8* gbMemoryMap[16]; extern uint8_t* gbMemoryMap[16];
extern int gbFrameSkip; extern int gbFrameSkip;
extern u16 gbColorFilter[32768]; extern uint16_t gbColorFilter[32768];
extern int gbColorOption; extern int gbColorOption;
extern int gbPaletteOption; extern int gbPaletteOption;
extern int gbEmulatorType; extern int gbEmulatorType;
@ -30,32 +30,32 @@ 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 uint8_t gbBgp[4];
extern u8 gbObp0[4]; extern uint8_t gbObp0[4];
extern u8 gbObp1[4]; extern uint8_t gbObp1[4];
extern u16 gbPalette[128]; extern uint16_t gbPalette[128];
extern bool gbScreenOn; extern bool gbScreenOn;
extern bool gbDrawWindow; extern bool gbDrawWindow;
extern u8 gbSCYLine[300]; extern uint8_t 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 uint8_t 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 uint8_t gbBgpLine[300];
extern u8 gbObp0Line[300]; extern uint8_t gbObp0Line[300];
extern u8 gbObp1Line[300]; extern uint8_t 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 uint8_t gbSpritesTicks[300];
extern u8 register_LCDC; extern uint8_t register_LCDC;
extern u8 register_LY; extern uint8_t register_LY;
extern u8 register_SCY; extern uint8_t register_SCY;
extern u8 register_SCX; extern uint8_t register_SCX;
extern u8 register_WY; extern uint8_t register_WY;
extern u8 register_WX; extern uint8_t register_WX;
extern u8 register_VBK; extern uint8_t register_VBK;
extern u8 oldRegister_WY; extern uint8_t oldRegister_WY;
extern int emulating; extern int emulating;
extern bool genericflashcardEnable; extern bool genericflashcardEnable;
@ -68,6 +68,6 @@ extern int gbDmaTicks;
extern void gbRenderLine(); extern void gbRenderLine();
extern void gbDrawSprites(bool); extern void gbDrawSprites(bool);
extern u8 (*gbSerialFunction)(u8); extern uint8_t (*gbSerialFunction)(uint8_t);
#endif // GBGLOBALS_H #endif // GBGLOBALS_H

View File

@ -3,8 +3,8 @@
#include "../common/Port.h" #include "../common/Port.h"
#include "gb.h" #include "gb.h"
#include "gbGlobals.h" #include "gbGlobals.h"
u8 gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; uint8_t gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
const u8 gbDisabledRam[8] = { 0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf }; const uint8_t gbDisabledRam[8] = { 0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf };
extern int gbGBCColorType; extern int gbGBCColorType;
extern gbRegister PC; extern gbRegister PC;
@ -19,7 +19,7 @@ mapperMBC1 gbDataMBC1 = {
}; };
// MBC1 ROM write registers // MBC1 ROM write registers
void mapperMBC1ROM(u16 address, u8 value) void mapperMBC1ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -153,7 +153,7 @@ void mapperMBC1ROM(u16 address, u8 value)
} }
// MBC1 RAM write // MBC1 RAM write
void mapperMBC1RAM(u16 address, u8 value) void mapperMBC1RAM(uint16_t address, uint8_t value)
{ {
if (gbDataMBC1.mapperRAMEnable) { if (gbDataMBC1.mapperRAMEnable) {
if (gbRamSize) { if (gbRamSize) {
@ -164,7 +164,7 @@ void mapperMBC1RAM(u16 address, u8 value)
} }
// MBC1 read RAM // MBC1 read RAM
u8 mapperMBC1ReadRAM(u16 address) uint8_t mapperMBC1ReadRAM(uint16_t address)
{ {
if (gbDataMBC1.mapperRAMEnable) if (gbDataMBC1.mapperRAMEnable)
@ -237,7 +237,7 @@ mapperMBC2 gbDataMBC2 = {
}; };
// MBC2 ROM write registers // MBC2 ROM write registers
void mapperMBC2ROM(u16 address, u8 value) void mapperMBC2ROM(uint16_t address, uint8_t value)
{ {
switch (address & 0x6000) { switch (address & 0x6000) {
case 0x0000: // RAM enable case 0x0000: // RAM enable
@ -269,7 +269,7 @@ void mapperMBC2ROM(u16 address, u8 value)
} }
// MBC2 RAM write // MBC2 RAM write
void mapperMBC2RAM(u16 address, u8 value) void mapperMBC2RAM(uint16_t address, uint8_t value)
{ {
if (gbDataMBC2.mapperRAMEnable) { if (gbDataMBC2.mapperRAMEnable) {
if (gbRamSize && address < 0xa200) { if (gbRamSize && address < 0xa200) {
@ -353,7 +353,7 @@ void memoryUpdateMBC3Clock()
} }
// MBC3 ROM write registers // MBC3 ROM write registers
void mapperMBC3ROM(u16 address, u8 value) void mapperMBC3ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -412,7 +412,7 @@ void mapperMBC3ROM(u16 address, u8 value)
} }
// MBC3 RAM write // MBC3 RAM write
void mapperMBC3RAM(u16 address, u8 value) void mapperMBC3RAM(uint16_t address, uint8_t value)
{ {
if (gbDataMBC3.mapperRAMEnable) { if (gbDataMBC3.mapperRAMEnable) {
if (gbDataMBC3.mapperRAMBank != -1) { if (gbDataMBC3.mapperRAMBank != -1) {
@ -447,7 +447,7 @@ void mapperMBC3RAM(u16 address, u8 value)
} }
// MBC3 read RAM // MBC3 read RAM
u8 mapperMBC3ReadRAM(u16 address) uint8_t mapperMBC3ReadRAM(uint16_t address)
{ {
if (gbDataMBC3.mapperRAMEnable) { if (gbDataMBC3.mapperRAMEnable) {
if (gbDataMBC3.mapperRAMBank != -1) { if (gbDataMBC3.mapperRAMBank != -1) {
@ -520,7 +520,7 @@ mapperMBC5 gbDataMBC5 = {
}; };
// MBC5 ROM write registers // MBC5 ROM write registers
void mapperMBC5ROM(u16 address, u8 value) void mapperMBC5ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -580,7 +580,7 @@ void mapperMBC5ROM(u16 address, u8 value)
} }
// MBC5 RAM write // MBC5 RAM write
void mapperMBC5RAM(u16 address, u8 value) void mapperMBC5RAM(uint16_t address, uint8_t value)
{ {
if (gbDataMBC5.mapperRAMEnable) { if (gbDataMBC5.mapperRAMEnable) {
if (gbRamSize) { if (gbRamSize) {
@ -591,7 +591,7 @@ void mapperMBC5RAM(u16 address, u8 value)
} }
// MBC5 read RAM // MBC5 read RAM
u8 mapperMBC5ReadRAM(u16 address) uint8_t mapperMBC5ReadRAM(uint16_t address)
{ {
if (gbDataMBC5.mapperRAMEnable) if (gbDataMBC5.mapperRAMEnable)
@ -652,7 +652,7 @@ mapperMBC7 gbDataMBC7 = {
}; };
// MBC7 ROM write registers // MBC7 ROM write registers
void mapperMBC7ROM(u16 address, u8 value) void mapperMBC7ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -694,7 +694,7 @@ void mapperMBC7ROM(u16 address, u8 value)
} }
// MBC7 read RAM // MBC7 read RAM
u8 mapperMBC7ReadRAM(u16 address) uint8_t mapperMBC7ReadRAM(uint16_t address)
{ {
switch (address & 0xa0f0) { switch (address & 0xa0f0) {
case 0xa000: case 0xa000:
@ -738,7 +738,7 @@ u8 mapperMBC7ReadRAM(u16 address)
} }
// MBC7 RAM write // MBC7 RAM write
void mapperMBC7RAM(u16 address, u8 value) void mapperMBC7RAM(uint16_t address, uint8_t value)
{ {
if (address == 0xa080) { if (address == 0xa080) {
// special processing needed // special processing needed
@ -827,7 +827,7 @@ void mapperMBC7RAM(u16 address, u8 value)
} else if ((gbDataMBC7.address >> 6) == 2) { } else if ((gbDataMBC7.address >> 6) == 2) {
if (gbDataMBC7.writeEnable) { if (gbDataMBC7.writeEnable) {
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
WRITE16LE((u16*)&gbMemory[0xa000 + i * 2], 0xffff); WRITE16LE((uint16_t*)&gbMemory[0xa000 + i * 2], 0xffff);
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
} }
gbDataMBC7.state = 5; gbDataMBC7.state = 5;
@ -901,7 +901,7 @@ mapperHuC1 gbDataHuC1 = {
}; };
// HuC1 ROM write registers // HuC1 ROM write registers
void mapperHuC1ROM(u16 address, u8 value) void mapperHuC1ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -956,7 +956,7 @@ void mapperHuC1ROM(u16 address, u8 value)
} }
// HuC1 RAM write // HuC1 RAM write
void mapperHuC1RAM(u16 address, u8 value) void mapperHuC1RAM(uint16_t address, uint8_t value)
{ {
if (gbDataHuC1.mapperRAMEnable) { if (gbDataHuC1.mapperRAMEnable) {
if (gbRamSize) { if (gbRamSize) {
@ -995,7 +995,7 @@ mapperHuC3 gbDataHuC3 = {
}; };
// HuC3 ROM write registers // HuC3 ROM write registers
void mapperHuC3ROM(u16 address, u8 value) void mapperHuC3ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -1039,7 +1039,7 @@ void mapperHuC3ROM(u16 address, u8 value)
} }
// HuC3 read RAM // HuC3 read RAM
u8 mapperHuC3ReadRAM(u16 address) uint8_t mapperHuC3ReadRAM(uint16_t address)
{ {
if (gbDataHuC3.mapperRAMFlag > 0x0b && gbDataHuC3.mapperRAMFlag < 0x0e) { if (gbDataHuC3.mapperRAMFlag > 0x0b && gbDataHuC3.mapperRAMFlag < 0x0e) {
if (gbDataHuC3.mapperRAMFlag != 0x0c) if (gbDataHuC3.mapperRAMFlag != 0x0c)
@ -1050,7 +1050,7 @@ u8 mapperHuC3ReadRAM(u16 address)
} }
// HuC3 RAM write // HuC3 RAM write
void mapperHuC3RAM(u16 address, u8 value) void mapperHuC3RAM(uint16_t address, uint8_t value)
{ {
int* p; int* p;
@ -1225,7 +1225,7 @@ void memoryUpdateTAMA5Clock()
} }
// TAMA5 RAM write // TAMA5 RAM write
void mapperTAMA5RAM(u16 address, u8 value) void mapperTAMA5RAM(uint16_t address, uint8_t value)
{ {
if ((address & 0xffff) <= 0xa001) { if ((address & 0xffff) <= 0xa001) {
switch (address & 1) { switch (address & 1) {
@ -1390,7 +1390,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
if ((value & 0x0e) == 0x0c) { if ((value & 0x0e) == 0x0c) {
gbDataTAMA5.mapperRamByteSelect = gbDataTAMA5.mapperCommands[6] | (gbDataTAMA5.mapperCommands[7] << 4); gbDataTAMA5.mapperRamByteSelect = gbDataTAMA5.mapperCommands[6] | (gbDataTAMA5.mapperCommands[7] << 4);
u8 byte = gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect]; uint8_t byte = gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect];
gbMemoryMap[0xa][0] = (value & 1) ? byte >> 4 : byte & 0x0f; gbMemoryMap[0xa][0] = (value & 1) ? byte >> 4 : byte & 0x0f;
@ -1413,7 +1413,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
} }
// TAMA5 read RAM // TAMA5 read RAM
u8 mapperTAMA5ReadRAM(u16 address) uint8_t mapperTAMA5ReadRAM(uint16_t address)
{ {
return gbMemoryMap[address >> 12][address & 0xfff]; return gbMemoryMap[address >> 12][address & 0xfff];
} }
@ -1448,7 +1448,7 @@ mapperMMM01 gbDataMMM01 = {
}; };
// MMM01 ROM write registers // MMM01 ROM write registers
void mapperMMM01ROM(u16 address, u8 value) void mapperMMM01ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;
@ -1518,7 +1518,7 @@ void mapperMMM01ROM(u16 address, u8 value)
} }
// MMM01 RAM write // MMM01 RAM write
void mapperMMM01RAM(u16 address, u8 value) void mapperMMM01RAM(uint16_t address, uint8_t value)
{ {
if (gbDataMMM01.mapperRAMEnable) { if (gbDataMMM01.mapperRAMEnable) {
if (gbRamSize) { if (gbRamSize) {
@ -1558,7 +1558,7 @@ void memoryUpdateMapMMM01()
} }
// GameGenie ROM write registers // GameGenie ROM write registers
void mapperGGROM(u16 address, u8 value) void mapperGGROM(uint16_t address, uint8_t value)
{ {
switch (address & 0x6000) { switch (address & 0x6000) {
case 0x0000: // RAM enable register case 0x0000: // RAM enable register
@ -1577,7 +1577,7 @@ void mapperGGROM(u16 address, u8 value)
// GS3 Used to emulate the GS V3.0 rom bank switching // GS3 Used to emulate the GS V3.0 rom bank switching
mapperGS3 gbDataGS3 = { 1 }; // ROM bank mapperGS3 gbDataGS3 = { 1 }; // ROM bank
void mapperGS3ROM(u16 address, u8 value) void mapperGS3ROM(uint16_t address, uint8_t value)
{ {
int tmpAddress = 0; int tmpAddress = 0;

View File

@ -144,35 +144,35 @@ extern mapperTAMA5 gbDataTAMA5;
extern mapperMMM01 gbDataMMM01; extern mapperMMM01 gbDataMMM01;
extern mapperGS3 gbDataGS3; extern mapperGS3 gbDataGS3;
void mapperMBC1ROM(u16, u8); void mapperMBC1ROM(uint16_t, uint8_t);
void mapperMBC1RAM(u16, u8); void mapperMBC1RAM(uint16_t, uint8_t);
u8 mapperMBC1ReadRAM(u16); uint8_t mapperMBC1ReadRAM(uint16_t);
void mapperMBC2ROM(u16, u8); void mapperMBC2ROM(uint16_t, uint8_t);
void mapperMBC2RAM(u16, u8); void mapperMBC2RAM(uint16_t, uint8_t);
void mapperMBC3ROM(u16, u8); void mapperMBC3ROM(uint16_t, uint8_t);
void mapperMBC3RAM(u16, u8); void mapperMBC3RAM(uint16_t, uint8_t);
u8 mapperMBC3ReadRAM(u16); uint8_t mapperMBC3ReadRAM(uint16_t);
void mapperMBC5ROM(u16, u8); void mapperMBC5ROM(uint16_t, uint8_t);
void mapperMBC5RAM(u16, u8); void mapperMBC5RAM(uint16_t, uint8_t);
u8 mapperMBC5ReadRAM(u16); uint8_t mapperMBC5ReadRAM(uint16_t);
void mapperMBC7ROM(u16, u8); void mapperMBC7ROM(uint16_t, uint8_t);
void mapperMBC7RAM(u16, u8); void mapperMBC7RAM(uint16_t, uint8_t);
u8 mapperMBC7ReadRAM(u16); uint8_t mapperMBC7ReadRAM(uint16_t);
void mapperHuC1ROM(u16, u8); void mapperHuC1ROM(uint16_t, uint8_t);
void mapperHuC1RAM(u16, u8); void mapperHuC1RAM(uint16_t, uint8_t);
void mapperHuC3ROM(u16, u8); void mapperHuC3ROM(uint16_t, uint8_t);
void mapperHuC3RAM(u16, u8); void mapperHuC3RAM(uint16_t, uint8_t);
u8 mapperHuC3ReadRAM(u16); uint8_t mapperHuC3ReadRAM(uint16_t);
void mapperTAMA5RAM(u16, u8); void mapperTAMA5RAM(uint16_t, uint8_t);
u8 mapperTAMA5ReadRAM(u16); uint8_t mapperTAMA5ReadRAM(uint16_t);
void memoryUpdateTAMA5Clock(); void memoryUpdateTAMA5Clock();
void mapperMMM01ROM(u16, u8); void mapperMMM01ROM(uint16_t, uint8_t);
void mapperMMM01RAM(u16, u8); void mapperMMM01RAM(uint16_t, uint8_t);
void mapperGGROM(u16, u8); void mapperGGROM(uint16_t, uint8_t);
void mapperGS3ROM(u16, u8); void mapperGS3ROM(uint16_t, uint8_t);
// extern void (*mapper)(u16,u8); // extern void (*mapper)(uint16_t,uint8_t);
// extern void (*mapperRAM)(u16,u8); // extern void (*mapperRAM)(uint16_t,uint8_t);
// extern u8 (*mapperReadRAM)(u16); // extern uint8_t (*mapperReadRAM)(uint16_t);
extern void memoryUpdateMapMBC1(); extern void memoryUpdateMapMBC1();
extern void memoryUpdateMapMBC2(); extern void memoryUpdateMapMBC2();

View File

@ -2,10 +2,10 @@
#include <memory.h> #include <memory.h>
#include <stdio.h> #include <stdio.h>
u8 gbPrinterStatus = 0; uint8_t gbPrinterStatus = 0;
int gbPrinterState = 0; int gbPrinterState = 0;
u8 gbPrinterData[0x280 * 9]; uint8_t gbPrinterData[0x280 * 9];
u8 gbPrinterPacket[0x400]; uint8_t gbPrinterPacket[0x400];
int gbPrinterCount = 0; int gbPrinterCount = 0;
int gbPrinterDataCount = 0; int gbPrinterDataCount = 0;
int gbPrinterDataSize = 0; int gbPrinterDataSize = 0;
@ -13,7 +13,7 @@ int gbPrinterResult = 0;
bool gbPrinterCheckCRC() bool gbPrinterCheckCRC()
{ {
u16 crc = 0; uint16_t crc = 0;
for (int i = 2; i < (6 + gbPrinterDataSize); i++) { for (int i = 2; i < (6 + gbPrinterDataSize); i++) {
crc += gbPrinterPacket[i]; crc += gbPrinterPacket[i];
@ -61,7 +61,7 @@ void gbPrinterShowData()
pal[3].b = 0; pal[3].b = 0;
set_palette(pal); set_palette(pal);
acquire_screen(); acquire_screen();
u8 *data = gbPrinterData; uint8_t *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++) {
@ -89,11 +89,11 @@ void gbPrinterReceiveData()
{ {
int i = gbPrinterDataCount; int i = gbPrinterDataCount;
if (gbPrinterPacket[3]) { // compressed if (gbPrinterPacket[3]) { // compressed
u8* data = &gbPrinterPacket[6]; uint8_t* data = &gbPrinterPacket[6];
u8* dest = &gbPrinterData[gbPrinterDataCount]; uint8_t* dest = &gbPrinterData[gbPrinterDataCount];
int len = 0; int len = 0;
while (len < gbPrinterDataSize) { while (len < gbPrinterDataSize) {
u8 control = *data++; uint8_t control = *data++;
if (control & 0x80) { // repeated data if (control & 0x80) { // repeated data
control &= 0x7f; control &= 0x7f;
control += 2; control += 2;
@ -139,7 +139,7 @@ void gbPrinterCommand()
} }
} }
u8 gbPrinterSend(u8 b) uint8_t gbPrinterSend(uint8_t b)
{ {
switch (gbPrinterState) { switch (gbPrinterState) {
case 0: case 0:

View File

@ -3,6 +3,6 @@
#include "../System.h" #include "../System.h"
u8 gbPrinterSend(u8 b); uint8_t gbPrinterSend(uint8_t b);
#endif // GBPRINTER_H #endif // GBPRINTER_H

View File

@ -7,7 +7,7 @@
#include "gb.h" #include "gb.h"
#include "gbGlobals.h" #include "gbGlobals.h"
extern u8* pix; extern uint8_t* pix;
extern bool speedup; extern bool speedup;
extern bool gbSgbResetFlag; extern bool gbSgbResetFlag;
@ -15,8 +15,8 @@ extern bool gbSgbResetFlag;
#define GBSGB_RESET 1 #define GBSGB_RESET 1
#define GBSGB_PACKET_TRANSMIT 2 #define GBSGB_PACKET_TRANSMIT 2
u8* gbSgbBorderChar = NULL; uint8_t* gbSgbBorderChar = NULL;
u8* gbSgbBorder = NULL; uint8_t* gbSgbBorder = NULL;
int gbSgbCGBSupport = 0; int gbSgbCGBSupport = 0;
int gbSgbMask = 0; int gbSgbMask = 0;
@ -25,30 +25,30 @@ int gbSgbPacketState = GBSGB_NONE;
int gbSgbBit = 0; int gbSgbBit = 0;
int gbSgbPacketTimeout = 0; int gbSgbPacketTimeout = 0;
int GBSGB_PACKET_TIMEOUT = 66666; int GBSGB_PACKET_TIMEOUT = 66666;
u8 gbSgbPacket[16 * 7]; uint8_t gbSgbPacket[16 * 7];
int gbSgbPacketNBits = 0; int gbSgbPacketNBits = 0;
int gbSgbPacketByte = 0; int gbSgbPacketByte = 0;
int gbSgbPacketNumber = 0; int gbSgbPacketNumber = 0;
int gbSgbMultiplayer = 0; int gbSgbMultiplayer = 0;
int gbSgbFourPlayers = 0; int gbSgbFourPlayers = 0;
u8 gbSgbNextController = 0x0f; uint8_t gbSgbNextController = 0x0f;
u8 gbSgbReadingController = 0; uint8_t gbSgbReadingController = 0;
u16 gbSgbSCPPalette[4 * 512]; uint16_t gbSgbSCPPalette[4 * 512];
u8 gbSgbATF[20 * 18]; uint8_t gbSgbATF[20 * 18];
u8 gbSgbATFList[45 * 20 * 18]; uint8_t gbSgbATFList[45 * 20 * 18];
u8 gbSgbScreenBuffer[4160]; uint8_t gbSgbScreenBuffer[4160];
inline void gbSgbDraw24Bit(u8* p, u16 v) inline void gbSgbDraw24Bit(uint8_t* p, uint16_t v)
{ {
memcpy(p, &systemColorMap32[v], 3); memcpy(p, &systemColorMap32[v], 3);
} }
inline void gbSgbDraw32Bit(u32* p, u16 v) inline void gbSgbDraw32Bit(uint32_t* p, uint16_t v)
{ {
*p = systemColorMap32[v]; *p = systemColorMap32[v];
} }
inline void gbSgbDraw16Bit(u16* p, u16 v) inline void gbSgbDraw16Bit(uint16_t* p, uint16_t v)
{ {
*p = systemColorMap16[v]; *p = systemColorMap16[v];
} }
@ -89,8 +89,8 @@ void gbSgbReset()
void gbSgbInit() void gbSgbInit()
{ {
gbSgbBorderChar = (u8*)malloc(32 * 256); gbSgbBorderChar = (uint8_t*)malloc(32 * 256);
gbSgbBorder = (u8*)malloc(2048); gbSgbBorder = (uint8_t*)malloc(2048);
gbSgbReset(); gbSgbReset();
} }
@ -108,13 +108,13 @@ void gbSgbShutdown()
} }
} }
void gbSgbFillScreen(u16 color) void gbSgbFillScreen(uint16_t color)
{ {
switch (systemColorDepth) { switch (systemColorDepth) {
case 16: { case 16: {
for (int y = 0; y < 144; y++) { for (int y = 0; y < 144; y++) {
int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 2) + gbBorderColumnSkip; int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 2) + gbBorderColumnSkip;
u16* dest = (u16*)pix + yLine; uint16_t* dest = (uint16_t*)pix + yLine;
for (register int x = 0; x < 160; x++) for (register int x = 0; x < 160; x++)
gbSgbDraw16Bit(dest++, color); gbSgbDraw16Bit(dest++, color);
} }
@ -122,7 +122,7 @@ void gbSgbFillScreen(u16 color)
case 24: { case 24: {
for (int y = 0; y < 144; y++) { for (int y = 0; y < 144; y++) {
int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip + gbBorderColumnSkip; int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip + gbBorderColumnSkip;
u8* dest = (u8*)pix + yLine * 3; uint8_t* dest = (uint8_t*)pix + yLine * 3;
for (register int x = 0; x < 160; x++) { for (register int x = 0; x < 160; x++) {
gbSgbDraw24Bit(dest, color); gbSgbDraw24Bit(dest, color);
dest += 3; dest += 3;
@ -132,7 +132,7 @@ void gbSgbFillScreen(u16 color)
case 32: { case 32: {
for (int y = 0; y < 144; y++) { for (int y = 0; y < 144; y++) {
int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 1) + gbBorderColumnSkip; int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 1) + gbBorderColumnSkip;
u32* dest = (u32*)pix + yLine; uint32_t* dest = (uint32_t*)pix + yLine;
for (register int x = 0; x < 160; x++) { for (register int x = 0; x < 160; x++) {
gbSgbDraw32Bit(dest++, color); gbSgbDraw32Bit(dest++, color);
} }
@ -145,12 +145,12 @@ void gbSgbFillScreen(u16 color)
void gbSgbRenderScreenToBuffer() void gbSgbRenderScreenToBuffer()
{ {
u16 mapAddress = 0x9800; uint16_t mapAddress = 0x9800;
if (register_LCDC & 0x08) if (register_LCDC & 0x08)
mapAddress = 0x9c00; mapAddress = 0x9c00;
u16 patternAddress = 0x8800; uint16_t patternAddress = 0x8800;
int flag = 1; int flag = 1;
@ -159,7 +159,7 @@ void gbSgbRenderScreenToBuffer()
flag = 0; flag = 0;
} }
u8* toAddress = gbSgbScreenBuffer; uint8_t* toAddress = gbSgbScreenBuffer;
for (int i = 0; i < 13; i++) { for (int i = 0; i < 13; i++) {
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
@ -181,36 +181,36 @@ void gbSgbRenderScreenToBuffer()
void gbSgbDrawBorderTile(int x, int y, int tile, int attr) void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
{ {
u16* dest = (u16*)pix + ((y + 1) * (256 + 2)) + x; uint16_t* dest = (uint16_t*)pix + ((y + 1) * (256 + 2)) + x;
u8* dest8 = (u8*)pix + ((y * 256) + x) * 3; uint8_t* dest8 = (uint8_t*)pix + ((y * 256) + x) * 3;
u32* dest32 = (u32*)pix + ((y + 1) * 257) + x; uint32_t* dest32 = (uint32_t*)pix + ((y + 1) * 257) + x;
u8* tileAddress = &gbSgbBorderChar[tile * 32]; uint8_t* tileAddress = &gbSgbBorderChar[tile * 32];
u8* tileAddress2 = &gbSgbBorderChar[tile * 32 + 16]; uint8_t* tileAddress2 = &gbSgbBorderChar[tile * 32 + 16];
u8 l = 8; uint8_t l = 8;
u8 palette = ((attr >> 2) & 7); uint8_t palette = ((attr >> 2) & 7);
if (palette < 4) if (palette < 4)
palette += 4; palette += 4;
palette *= 16; palette *= 16;
u8 xx = 0; uint8_t xx = 0;
u8 yy = 0; uint8_t yy = 0;
int flipX = attr & 0x40; int flipX = attr & 0x40;
int flipY = attr & 0x80; int flipY = attr & 0x80;
while (l > 0) { while (l > 0) {
u8 mask = 0x80; uint8_t mask = 0x80;
u8 a = *tileAddress++; uint8_t a = *tileAddress++;
u8 b = *tileAddress++; uint8_t b = *tileAddress++;
u8 c = *tileAddress2++; uint8_t c = *tileAddress2++;
u8 d = *tileAddress2++; uint8_t d = *tileAddress2++;
u8 yyy; uint8_t yyy;
if (!flipY) if (!flipY)
yyy = yy; yyy = yy;
else else
@ -218,7 +218,7 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
while (mask > 0) { while (mask > 0) {
u8 color = 0; uint8_t color = 0;
if (a & mask) if (a & mask)
color++; color++;
if (b & mask) if (b & mask)
@ -229,14 +229,14 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
color += 8; color += 8;
if (color || (y + yy < 40 || y + yy >= 184) || (x + xx < 48 || x + xx >= 208)) { if (color || (y + yy < 40 || y + yy >= 184) || (x + xx < 48 || x + xx >= 208)) {
u8 xxx; uint8_t xxx;
if (!flipX) if (!flipX)
xxx = xx; xxx = xx;
else else
xxx = 7 - xx; xxx = 7 - xx;
u16 cc; uint16_t cc;
if (color) { if (color) {
cc = gbPalette[palette + color]; cc = gbPalette[palette + color];
} else { } else {
@ -270,12 +270,12 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
void gbSgbRenderBorder() void gbSgbRenderBorder()
{ {
if (gbBorderOn) { if (gbBorderOn) {
u8* fromAddress = gbSgbBorder; uint8_t* fromAddress = gbSgbBorder;
for (u8 y = 0; y < 28; y++) { for (uint8_t y = 0; y < 28; y++) {
for (u8 x = 0; x < 32; x++) { for (uint8_t x = 0; x < 32; x++) {
u8 tile = *fromAddress++; uint8_t tile = *fromAddress++;
u8 attr = *fromAddress++; uint8_t attr = *fromAddress++;
gbSgbDrawBorderTile(x * 8, y * 8, tile, attr); gbSgbDrawBorderTile(x * 8, y * 8, tile, attr);
} }
@ -289,7 +289,7 @@ void gbSgbPicture()
memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048); memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048);
u16* paletteAddr = (u16*)&gbSgbScreenBuffer[2048]; uint16_t* paletteAddr = (uint16_t*)&gbSgbScreenBuffer[2048];
for (int i = 64; i < 128; i++) { for (int i = 64; i < 128; i++) {
gbPalette[i] = READ16LE(paletteAddr++); gbPalette[i] = READ16LE(paletteAddr++);
@ -317,9 +317,9 @@ void gbSgbPicture()
gbSgbCGBSupport = 0; gbSgbCGBSupport = 0;
} }
void gbSgbSetPalette(int a, int b, u16* p) void gbSgbSetPalette(int a, int b, uint16_t* p)
{ {
u16 bit00 = READ16LE(p++); uint16_t bit00 = READ16LE(p++);
int i; int i;
for (i = 1; i < 4; i++) { for (i = 1; i < 4; i++) {
@ -339,7 +339,7 @@ void gbSgbScpPalette()
{ {
gbSgbRenderScreenToBuffer(); gbSgbRenderScreenToBuffer();
u16* fromAddress = (u16*)gbSgbScreenBuffer; uint16_t* fromAddress = (uint16_t*)gbSgbScreenBuffer;
for (int i = 0; i < 512 * 4; i++) { for (int i = 0; i < 512 * 4; i++) {
gbSgbSCPPalette[i] = READ16LE(fromAddress++); gbSgbSCPPalette[i] = READ16LE(fromAddress++);
@ -363,19 +363,19 @@ void gbSgbSetATF(int n)
void gbSgbSetPalette() void gbSgbSetPalette()
{ {
u16 pal = READ16LE((((u16*)&gbSgbPacket[1]))) & 511; uint16_t pal = READ16LE((((uint16_t*)&gbSgbPacket[1]))) & 511;
memcpy(&gbPalette[0], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16)); memcpy(&gbPalette[0], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
pal = READ16LE((((u16*)&gbSgbPacket[3]))) & 511; pal = READ16LE((((uint16_t*)&gbSgbPacket[3]))) & 511;
memcpy(&gbPalette[4], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16)); memcpy(&gbPalette[4], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
pal = READ16LE((((u16*)&gbSgbPacket[5]))) & 511; pal = READ16LE((((uint16_t*)&gbSgbPacket[5]))) & 511;
memcpy(&gbPalette[8], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16)); memcpy(&gbPalette[8], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
pal = READ16LE((((u16*)&gbSgbPacket[7]))) & 511; pal = READ16LE((((uint16_t*)&gbSgbPacket[7]))) & 511;
memcpy(&gbPalette[12], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16)); memcpy(&gbPalette[12], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
u8 atf = gbSgbPacket[9]; uint8_t atf = gbSgbPacket[9];
if (atf & 0x80) { if (atf & 0x80) {
gbSgbSetATF(atf & 0x3f); gbSgbSetATF(atf & 0x3f);
@ -390,26 +390,26 @@ void gbSgbSetPalette()
void gbSgbAttributeBlock() void gbSgbAttributeBlock()
{ {
u8* fromAddress = &gbSgbPacket[1]; uint8_t* fromAddress = &gbSgbPacket[1];
u8 nDataSet = *fromAddress++; uint8_t nDataSet = *fromAddress++;
if (nDataSet > 12) if (nDataSet > 12)
nDataSet = 12; nDataSet = 12;
if (nDataSet == 0) if (nDataSet == 0)
nDataSet = 1; nDataSet = 1;
while (nDataSet) { while (nDataSet) {
u8 controlCode = (*fromAddress++) & 7; uint8_t controlCode = (*fromAddress++) & 7;
u8 paletteDesignation = (*fromAddress++) & 0x3f; uint8_t paletteDesignation = (*fromAddress++) & 0x3f;
u8 startH = (*fromAddress++) & 0x1f; uint8_t startH = (*fromAddress++) & 0x1f;
u8 startV = (*fromAddress++) & 0x1f; uint8_t startV = (*fromAddress++) & 0x1f;
u8 endH = (*fromAddress++) & 0x1f; uint8_t endH = (*fromAddress++) & 0x1f;
u8 endV = (*fromAddress++) & 0x1f; uint8_t endV = (*fromAddress++) & 0x1f;
u8* toAddress = gbSgbATF; uint8_t* toAddress = gbSgbATF;
for (u8 y = 0; y < 18; y++) { for (uint8_t y = 0; y < 18; y++) {
for (u8 x = 0; x < 20; x++) { for (uint8_t x = 0; x < 20; x++) {
if (x < startH || y < startV || x > endH || y > endV) { if (x < startH || y < startV || x > endH || y > endV) {
// outside // outside
if (controlCode & 0x04) if (controlCode & 0x04)
@ -432,7 +432,7 @@ void gbSgbAttributeBlock()
} }
} }
void gbSgbSetColumnPalette(u8 col, u8 p) void gbSgbSetColumnPalette(uint8_t col, uint8_t p)
{ {
// if(col < 0) // if(col < 0)
// col = 0; // col = 0;
@ -441,15 +441,15 @@ void gbSgbSetColumnPalette(u8 col, u8 p)
p &= 3; p &= 3;
u8* toAddress = &gbSgbATF[col]; uint8_t* toAddress = &gbSgbATF[col];
for (u8 y = 0; y < 18; y++) { for (uint8_t y = 0; y < 18; y++) {
*toAddress = p; *toAddress = p;
toAddress += 20; toAddress += 20;
} }
} }
void gbSgbSetRowPalette(u8 row, u8 p) void gbSgbSetRowPalette(uint8_t row, uint8_t p)
{ {
// if(row < 0) // if(row < 0)
// row = 0; // row = 0;
@ -458,26 +458,26 @@ void gbSgbSetRowPalette(u8 row, u8 p)
p &= 3; p &= 3;
u8* toAddress = &gbSgbATF[row * 20]; uint8_t* toAddress = &gbSgbATF[row * 20];
for (u8 x = 0; x < 20; x++) { for (uint8_t x = 0; x < 20; x++) {
*toAddress++ = p; *toAddress++ = p;
} }
} }
void gbSgbAttributeDivide() void gbSgbAttributeDivide()
{ {
u8 control = gbSgbPacket[1]; uint8_t control = gbSgbPacket[1];
u8 coord = gbSgbPacket[2]; uint8_t coord = gbSgbPacket[2];
u8 colorBR = control & 3; uint8_t colorBR = control & 3;
u8 colorAL = (control >> 2) & 3; uint8_t colorAL = (control >> 2) & 3;
u8 colorOL = (control >> 4) & 3; uint8_t colorOL = (control >> 4) & 3;
if (control & 0x40) { if (control & 0x40) {
if (coord > 17) if (coord > 17)
coord = 17; coord = 17;
for (u8 i = 0; i < 18; i++) { for (uint8_t i = 0; i < 18; i++) {
if (i < coord) if (i < coord)
gbSgbSetRowPalette(i, colorAL); gbSgbSetRowPalette(i, colorAL);
else if (i > coord) else if (i > coord)
@ -489,7 +489,7 @@ void gbSgbAttributeDivide()
if (coord > 19) if (coord > 19)
coord = 19; coord = 19;
for (u8 i = 0; i < 20; i++) { for (uint8_t i = 0; i < 20; i++) {
if (i < coord) if (i < coord)
gbSgbSetColumnPalette(i, colorAL); gbSgbSetColumnPalette(i, colorAL);
else if (i > coord) else if (i > coord)
@ -502,17 +502,17 @@ void gbSgbAttributeDivide()
void gbSgbAttributeLine() void gbSgbAttributeLine()
{ {
u8* fromAddress = &gbSgbPacket[1]; uint8_t* fromAddress = &gbSgbPacket[1];
u8 nDataSet = *fromAddress++; uint8_t nDataSet = *fromAddress++;
if (nDataSet > 0x6e) if (nDataSet > 0x6e)
nDataSet = 0x6e; nDataSet = 0x6e;
while (nDataSet) { while (nDataSet) {
u8 line = *fromAddress++; uint8_t line = *fromAddress++;
u8 num = line & 0x1f; uint8_t num = line & 0x1f;
u8 pal = (line >> 5) & 0x03; uint8_t pal = (line >> 5) & 0x03;
if (line & 0x80) { if (line & 0x80) {
if (num > 17) if (num > 17)
num = 17; num = 17;
@ -528,22 +528,22 @@ void gbSgbAttributeLine()
void gbSgbAttributeCharacter() void gbSgbAttributeCharacter()
{ {
u8 startH = gbSgbPacket[1] & 0x1f; uint8_t startH = gbSgbPacket[1] & 0x1f;
u8 startV = gbSgbPacket[2] & 0x1f; uint8_t startV = gbSgbPacket[2] & 0x1f;
int nDataSet = READ16LE(((u16*)&gbSgbPacket[3])); int nDataSet = READ16LE(((uint16_t*)&gbSgbPacket[3]));
int style = gbSgbPacket[5] & 1; int style = gbSgbPacket[5] & 1;
if (startH > 19) if (startH > 19)
startH = 19; startH = 19;
if (startV > 17) if (startV > 17)
startV = 17; startV = 17;
u8 s = 6; uint8_t s = 6;
u8* fromAddress = &gbSgbPacket[6]; uint8_t* fromAddress = &gbSgbPacket[6];
u8 v = *fromAddress++; uint8_t v = *fromAddress++;
if (style) { if (style) {
while (nDataSet) { while (nDataSet) {
u8 p = (v >> s) & 3; uint8_t p = (v >> s) & 3;
gbSgbATF[startV * 20 + startH] = p; gbSgbATF[startV * 20 + startH] = p;
startV++; startV++;
if (startV == 18) { if (startV == 18) {
@ -563,7 +563,7 @@ void gbSgbAttributeCharacter()
} }
} else { } else {
while (nDataSet) { while (nDataSet) {
u8 p = (v >> s) & 3; uint8_t p = (v >> s) & 3;
gbSgbATF[startV * 20 + startH] = p; gbSgbATF[startV * 20 + startH] = p;
startH++; startH++;
if (startH == 20) { if (startH == 20) {
@ -588,13 +588,13 @@ void gbSgbSetATFList()
{ {
gbSgbRenderScreenToBuffer(); gbSgbRenderScreenToBuffer();
u8* fromAddress = gbSgbScreenBuffer; uint8_t* fromAddress = gbSgbScreenBuffer;
u8* toAddress = gbSgbATFList; uint8_t* toAddress = gbSgbATFList;
for (int i = 0; i < 45; i++) { for (int i = 0; i < 45; i++) {
for (int j = 0; j < 90; j++) { for (int j = 0; j < 90; j++) {
u8 v = *fromAddress++; uint8_t v = *fromAddress++;
u8 s = 6; uint8_t s = 6;
if (i == 2) if (i == 2)
s = 6; s = 6;
for (int k = 0; k < 4; k++) { for (int k = 0; k < 4; k++) {
@ -616,7 +616,7 @@ void gbSgbMaskEnable()
break; break;
case 2: case 2:
gbSgbFillScreen(0x0000); gbSgbFillScreen(0x0000);
// memset(&gbPalette[0], 0, 128*sizeof(u16)); // memset(&gbPalette[0], 0, 128*sizeof(uint16_t));
break; break;
case 3: case 3:
gbSgbFillScreen(gbPalette[0]); gbSgbFillScreen(gbPalette[0]);
@ -684,16 +684,16 @@ void gbSgbCommand()
switch (command) { switch (command) {
case 0x00: case 0x00:
gbSgbSetPalette(0, 1, (u16*)&gbSgbPacket[1]); gbSgbSetPalette(0, 1, (uint16_t*)&gbSgbPacket[1]);
break; break;
case 0x01: case 0x01:
gbSgbSetPalette(2, 3, (u16*)&gbSgbPacket[1]); gbSgbSetPalette(2, 3, (uint16_t*)&gbSgbPacket[1]);
break; break;
case 0x02: case 0x02:
gbSgbSetPalette(0, 3, (u16*)&gbSgbPacket[1]); gbSgbSetPalette(0, 3, (uint16_t*)&gbSgbPacket[1]);
break; break;
case 0x03: case 0x03:
gbSgbSetPalette(1, 2, (u16*)&gbSgbPacket[1]); gbSgbSetPalette(1, 2, (uint16_t*)&gbSgbPacket[1]);
break; break;
case 0x04: case 0x04:
gbSgbAttributeBlock(); gbSgbAttributeBlock();
@ -740,7 +740,7 @@ void gbSgbResetPacketState()
gbSgbPacketTimeout = 0; gbSgbPacketTimeout = 0;
} }
void gbSgbDoBitTransfer(u8 value) void gbSgbDoBitTransfer(uint8_t value)
{ {
value = value & 0x30; value = value & 0x30;
switch (gbSgbPacketState) { switch (gbSgbPacketState) {
@ -841,8 +841,8 @@ variable_desc gbSgbSaveStruct[] = {
{ &gbSgbPacketByte, sizeof(int) }, { &gbSgbPacketByte, sizeof(int) },
{ &gbSgbPacketNumber, sizeof(int) }, { &gbSgbPacketNumber, sizeof(int) },
{ &gbSgbMultiplayer, sizeof(int) }, { &gbSgbMultiplayer, sizeof(int) },
{ &gbSgbNextController, sizeof(u8) }, { &gbSgbNextController, sizeof(uint8_t) },
{ &gbSgbReadingController, sizeof(u8) }, { &gbSgbReadingController, sizeof(uint8_t) },
{ NULL, 0 } { NULL, 0 }
}; };
@ -854,8 +854,8 @@ variable_desc gbSgbSaveStructV3[] = {
{ &gbSgbPacketByte, sizeof(int) }, { &gbSgbPacketByte, sizeof(int) },
{ &gbSgbPacketNumber, sizeof(int) }, { &gbSgbPacketNumber, sizeof(int) },
{ &gbSgbMultiplayer, sizeof(int) }, { &gbSgbMultiplayer, sizeof(int) },
{ &gbSgbNextController, sizeof(u8) }, { &gbSgbNextController, sizeof(uint8_t) },
{ &gbSgbReadingController, sizeof(u8) }, { &gbSgbReadingController, sizeof(uint8_t) },
{ &gbSgbFourPlayers, sizeof(int) }, { &gbSgbFourPlayers, sizeof(int) },
{ NULL, 0 } { NULL, 0 }
}; };
@ -869,7 +869,7 @@ void gbSgbSaveGame(gzFile gzFile)
utilGzWrite(gzFile, gbSgbPacket, 16 * 7); utilGzWrite(gzFile, gbSgbPacket, 16 * 7);
utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16)); utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(uint16_t));
utilGzWrite(gzFile, gbSgbATF, 20 * 18); utilGzWrite(gzFile, gbSgbATF, 20 * 18);
utilGzWrite(gzFile, gbSgbATFList, 45 * 20 * 18); utilGzWrite(gzFile, gbSgbATFList, 45 * 20 * 18);
} }
@ -890,7 +890,7 @@ void gbSgbReadGame(gzFile gzFile, int version)
utilGzRead(gzFile, gbSgbPacket, 16 * 7); utilGzRead(gzFile, gbSgbPacket, 16 * 7);
utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16)); utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(uint16_t));
utilGzRead(gzFile, gbSgbATF, 20 * 18); utilGzRead(gzFile, gbSgbATF, 20 * 18);
utilGzRead(gzFile, gbSgbATFList, 45 * 20 * 18); utilGzRead(gzFile, gbSgbATFList, 45 * 20 * 18);
} }

View File

@ -6,18 +6,18 @@ void gbSgbShutdown();
void gbSgbCommand(); void gbSgbCommand();
void gbSgbResetPacketState(); void gbSgbResetPacketState();
void gbSgbReset(); void gbSgbReset();
void gbSgbDoBitTransfer(u8); void gbSgbDoBitTransfer(uint8_t);
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 uint8_t 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 uint8_t gbSgbNextController;
extern int gbSgbPacketTimeout; extern int gbSgbPacketTimeout;
extern u8 gbSgbReadingController; extern uint8_t gbSgbReadingController;
extern int gbSgbFourPlayers; extern int gbSgbFourPlayers;
#endif // GBSGB_H #endif // GBSGB_H

View File

@ -29,7 +29,7 @@ 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) uint8_t gbSoundRead(uint16_t 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);
@ -37,7 +37,7 @@ u8 gbSoundRead(u16 address)
return gbMemory[address]; return gbMemory[address];
} }
void gbSoundEvent(register u16 address, register int data) void gbSoundEvent(register uint16_t address, register int data)
{ {
gbMemory[address] = data; gbMemory[address] = data;
@ -326,9 +326,9 @@ static variable_desc gbsound_format2[] = {
}; };
static variable_desc gbsound_format3[] = { static variable_desc gbsound_format3[] = {
SKIP(u8[2 * 735], soundBuffer), SKIP(uint8_t[2 * 735], soundBuffer),
SKIP(u8[2 * 735], soundBuffer), SKIP(uint8_t[2 * 735], soundBuffer),
SKIP(u16[735], soundFinalWave), SKIP(uint16_t[735], soundFinalWave),
{ NULL, 0 } { NULL, 0 }
}; };
@ -402,7 +402,7 @@ static variable_desc gb_state[] = {
LOAD(int, state.version), // room_for_expansion will be used by later versions LOAD(int, state.version), // room_for_expansion will be used by later versions
// APU // APU
LOAD(u8[0x40], state.apu.regs), // last values written to registers and wave RAM (both banks) LOAD(uint8_t[0x40], state.apu.regs), // last values written to registers and wave RAM (both banks)
LOAD(int, state.apu.frame_time), // clocks until next frame sequencer action LOAD(int, state.apu.frame_time), // clocks until next frame sequencer action
LOAD(int, state.apu.frame_phase), // next step frame sequencer will run LOAD(int, state.apu.frame_phase), // next step frame sequencer will run

View File

@ -56,11 +56,11 @@ extern gb_effects_config_t gb_effects_config; // current configuration
void gbSoundReset(); void gbSoundReset();
// Emulates write to sound hardware // Emulates write to sound hardware
void gbSoundEvent(u16 address, int data); void gbSoundEvent(uint16_t address, int data);
#define SOUND_EVENT gbSoundEvent #define SOUND_EVENT gbSoundEvent
// Emulates read from sound hardware // Emulates read from sound hardware
u8 gbSoundRead(u16 address); uint8_t gbSoundRead(uint16_t address);
// Notifies emulator that SOUND_CLOCK_TICKS clocks have passed // Notifies emulator that SOUND_CLOCK_TICKS clocks have passed
void gbSoundTick(); void gbSoundTick();

View File

@ -20,16 +20,15 @@
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
/** /**
* GameBoyAdvanceCheatEditDialog * GameBoyAdvanceCheatEditDialog
* *
* A unified cheat editing dialog for multiple code types. * A unified cheat editing dialog for multiple code types.
*/ */
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog) : Gtk::Dialog(_pstDialog)
{ {
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry); refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox); refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
@ -60,8 +59,7 @@ ECheatType CheatEditDialog::vGetType()
{ {
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active(); Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
if (iter) if (iter) {
{
Gtk::TreeModel::Row row = *iter; Gtk::TreeModel::Row row = *iter;
return row[m_oTypeModel.iType]; return row[m_oTypeModel.iType];
@ -75,8 +73,7 @@ void CheatEditDialog::vSetWindow(VBA::Window * _poWindow)
m_poWindow = _poWindow; m_poWindow = _poWindow;
// GameBoy Advance // GameBoy Advance
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA) if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA) {
{
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append()); Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGeneric; row[m_oTypeModel.iType] = CheatGeneric;
@ -95,8 +92,7 @@ void CheatEditDialog::vSetWindow(VBA::Window * _poWindow)
m_poCheatTypeComboBox->set_active(CheatGeneric); m_poCheatTypeComboBox->set_active(CheatGeneric);
} }
// GameBoy // GameBoy
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB) else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB) {
{
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append()); Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGS; row[m_oTypeModel.iType] = CheatGS;
@ -116,7 +112,8 @@ void CheatEditDialog::vOnApply()
response(Gtk::RESPONSE_APPLY); response(Gtk::RESPONSE_APPLY);
} }
void CheatEditDialog::vOnCancel() { void CheatEditDialog::vOnCancel()
{
response(Gtk::RESPONSE_CANCEL); response(Gtk::RESPONSE_CANCEL);
} }

View File

@ -27,12 +27,14 @@
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ enum ECheatType { CheatGeneric,
enum ECheatType { CheatGeneric, CheatGSA, CheatCBA, CheatGS, CheatGG }; CheatGSA,
CheatCBA,
CheatGS,
CheatGG };
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
{
public: public:
EditCheatCodeColumns() EditCheatCodeColumns()
{ {
@ -48,8 +50,7 @@ class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
Gtk::TreeModelColumn<ECheatType> iType; Gtk::TreeModelColumn<ECheatType> iType;
}; };
class CheatEditDialog : public Gtk::Dialog class CheatEditDialog : public Gtk::Dialog {
{
public: public:
CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
Glib::RefPtr<Gtk::TextBuffer> vGetCode(); Glib::RefPtr<Gtk::TextBuffer> vGetCode();

View File

@ -24,11 +24,10 @@
#include "intl.h" #include "intl.h"
#include <vector> #include <vector>
namespace VBA namespace VBA {
{
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog) : Gtk::Dialog(_pstDialog)
{ {
refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton); refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton); refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
@ -74,15 +73,13 @@ void CheatListDialog::vOnCheatListOpen()
oDialog.set_current_folder(Glib::get_home_dir()); oDialog.set_current_folder(Glib::get_home_dir());
while (oDialog.run() == Gtk::RESPONSE_OK) while (oDialog.run() == Gtk::RESPONSE_OK) {
{
// delete existing cheats before loading the list // delete existing cheats before loading the list
vRemoveAllCheats(); vRemoveAllCheats();
m_poCheatListStore->clear(); m_poCheatListStore->clear();
if (vCheatListOpen(oDialog.get_filename().c_str())) if (vCheatListOpen(oDialog.get_filename().c_str())) {
{
vUpdateList(); vUpdateList();
break; break;
} }
@ -121,8 +118,7 @@ void CheatListDialog::vOnCheatRemove()
{ {
Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected(); Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected();
if (iter) if (iter) {
{
Gtk::TreeModel::Row row = *iter; Gtk::TreeModel::Row row = *iter;
vRemoveCheat(row[m_oRecordModel.iIndex]); vRemoveCheat(row[m_oRecordModel.iIndex]);
@ -142,8 +138,7 @@ void CheatListDialog::vOnCheatMarkAll()
{ {
Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children(); Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children();
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++) for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++) {
{
Gtk::TreeModel::Row row = *iter; Gtk::TreeModel::Row row = *iter;
row[m_oRecordModel.bEnabled] = bMark; row[m_oRecordModel.bEnabled] = bMark;

View File

@ -25,10 +25,8 @@
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
{
public: public:
ListCheatCodeColumns() ListCheatCodeColumns()
{ {
@ -46,15 +44,15 @@ class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
Gtk::TreeModelColumn<Glib::ustring> uDesc; Gtk::TreeModelColumn<Glib::ustring> uDesc;
}; };
class CheatListDialog : public Gtk::Dialog class CheatListDialog : public Gtk::Dialog {
{
public: public:
CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetWindow(VBA::Window* _poWindow); void vSetWindow(VBA::Window* _poWindow);
protected: protected:
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type, virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
Glib::RefPtr<Gtk::TextBuffer> buffer) = 0; Glib::RefPtr<Gtk::TextBuffer> buffer)
= 0;
virtual bool vCheatListOpen(const char* file) = 0; virtual bool vCheatListOpen(const char* file) = 0;
virtual void vCheatListSave(const char* file) = 0; virtual void vCheatListSave(const char* file) = 0;
virtual void vRemoveCheat(int index) = 0; virtual void vRemoveCheat(int index) = 0;

View File

@ -23,31 +23,27 @@
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/iochannel.h> #include <glibmm/iochannel.h>
namespace VBA namespace VBA {
{ namespace Config {
namespace Config
{
using std::string; using std::string;
using Glib::IOChannel; using Glib::IOChannel;
Line::Line(const string & _rsKey, const string & _rsValue) : Line::Line(const string& _rsKey, const string& _rsValue)
m_sKey(_rsKey), : m_sKey(_rsKey)
m_sValue(_rsValue) , m_sValue(_rsValue)
{ {
} }
Section::Section(const string & _rsName) : Section::Section(const string& _rsName)
m_sName(_rsName) : m_sName(_rsName)
{ {
} }
bool Section::bKeyExists(const string& _rsKey) bool Section::bKeyExists(const string& _rsKey)
{ {
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->m_sKey == _rsKey) {
if (it->m_sKey == _rsKey)
{
return true; return true;
} }
} }
@ -56,10 +52,8 @@ bool Section::bKeyExists(const string & _rsKey)
void Section::vSetKey(const string& _rsKey, const string& _rsValue) void Section::vSetKey(const string& _rsKey, const string& _rsValue)
{ {
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->m_sKey == _rsKey) {
if (it->m_sKey == _rsKey)
{
it->m_sValue = _rsValue; it->m_sValue = _rsValue;
return; return;
} }
@ -69,10 +63,8 @@ void Section::vSetKey(const string & _rsKey, const string & _rsValue)
string Section::sGetKey(const string& _rsKey) const string Section::sGetKey(const string& _rsKey) const
{ {
for (const_iterator it = begin(); it != end(); it++) for (const_iterator it = begin(); it != end(); it++) {
{ if (it->m_sKey == _rsKey) {
if (it->m_sKey == _rsKey)
{
return it->m_sValue; return it->m_sValue;
} }
} }
@ -81,10 +73,8 @@ string Section::sGetKey(const string & _rsKey) const
void Section::vRemoveKey(const string& _rsKey) void Section::vRemoveKey(const string& _rsKey)
{ {
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->m_sKey == _rsKey) {
if (it->m_sKey == _rsKey)
{
erase(it); erase(it);
return; return;
} }
@ -106,10 +96,8 @@ File::~File()
bool File::bSectionExists(const string& _rsName) bool File::bSectionExists(const string& _rsName)
{ {
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->sGetName() == _rsName) {
if (it->sGetName() == _rsName)
{
return true; return true;
} }
} }
@ -119,15 +107,12 @@ bool File::bSectionExists(const string & _rsName)
Section* File::poAddSection(const string& _rsName) Section* File::poAddSection(const string& _rsName)
{ {
Section* poSection = NULL; Section* poSection = NULL;
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->sGetName() == _rsName) {
if (it->sGetName() == _rsName)
{
poSection = &(*it); poSection = &(*it);
} }
} }
if (poSection == NULL) if (poSection == NULL) {
{
push_back(Section(_rsName)); push_back(Section(_rsName));
poSection = &back(); poSection = &back();
} }
@ -136,10 +121,8 @@ Section * File::poAddSection(const string & _rsName)
Section* File::poGetSection(const string& _rsName) Section* File::poGetSection(const string& _rsName)
{ {
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->sGetName() == _rsName) {
if (it->sGetName() == _rsName)
{
return &(*it); return &(*it);
} }
} }
@ -148,10 +131,8 @@ Section * File::poGetSection(const string & _rsName)
void File::vRemoveSection(const string& _rsName) void File::vRemoveSection(const string& _rsName)
{ {
for (iterator it = begin(); it != end(); it++) for (iterator it = begin(); it != end(); it++) {
{ if (it->sGetName() == _rsName) {
if (it->sGetName() == _rsName)
{
erase(it); erase(it);
return; return;
} }
@ -167,38 +148,25 @@ void File::vLoad(const string & _rsFile,
char** lines = g_strsplit(sBuffer.c_str(), "\n", 0); char** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
char* tmp; char* tmp;
int i = 0; int i = 0;
while (lines[i]) while (lines[i]) {
{ if (lines[i][0] == '[') {
if (lines[i][0] == '[') if ((tmp = strchr(lines[i], ']'))) {
{
if ((tmp = strchr(lines[i], ']')))
{
*tmp = '\0'; *tmp = '\0';
if (_bAddSection) if (_bAddSection) {
{
poSection = poAddSection(&lines[i][1]); poSection = poAddSection(&lines[i][1]);
} } else {
else try {
{
try
{
poSection = poGetSection(&lines[i][1]); poSection = poGetSection(&lines[i][1]);
} } catch (...) {
catch (...)
{
poSection = NULL; poSection = NULL;
} }
} }
} }
} } else if (lines[i][0] != '#' && poSection != NULL) {
else if (lines[i][0] != '#' && poSection != NULL) if ((tmp = strchr(lines[i], '='))) {
{
if ((tmp = strchr(lines[i], '=')))
{
*tmp = '\0'; *tmp = '\0';
tmp++; tmp++;
if (_bAddKey || poSection->bKeyExists(lines[i])) if (_bAddKey || poSection->bKeyExists(lines[i])) {
{
poSection->vSetKey(lines[i], tmp); poSection->vSetKey(lines[i], tmp);
} }
} }
@ -215,15 +183,13 @@ void File::vSave(const string & _rsFile)
for (const_iterator poSection = begin(); for (const_iterator poSection = begin();
poSection != end(); poSection != end();
poSection++) poSection++) {
{
string sName = "[" + poSection->sGetName() + "]\n"; string sName = "[" + poSection->sGetName() + "]\n";
poFile->write(sName); poFile->write(sName);
for (Section::const_iterator poLine = poSection->begin(); for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end(); poLine != poSection->end();
poLine++) poLine++) {
{
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n"; string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
poFile->write(sLine); poFile->write(sLine);
} }
@ -240,15 +206,13 @@ std::ostream & operator<<(std::ostream & _roOut, const File & _roFile)
{ {
for (File::const_iterator poSection = _roFile.begin(); for (File::const_iterator poSection = _roFile.begin();
poSection != _roFile.end(); poSection != _roFile.end();
poSection++) poSection++) {
{
string sName = "[" + poSection->sGetName() + "]\n"; string sName = "[" + poSection->sGetName() + "]\n";
_roOut << sName; _roOut << sName;
for (Section::const_iterator poLine = poSection->begin(); for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end(); poLine != poSection->end();
poLine++) poLine++) {
{
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n"; string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
_roOut << sLine; _roOut << sLine;
} }

View File

@ -23,12 +23,9 @@
#include <list> #include <list>
#include <sstream> #include <sstream>
namespace VBA namespace VBA {
{ namespace Config {
namespace Config class NotFound {
{
class NotFound
{
public: public:
virtual ~NotFound() virtual ~NotFound()
{ {
@ -40,10 +37,10 @@ class NotFound
} }
}; };
class SectionNotFound : public NotFound class SectionNotFound : public NotFound {
{
public: public:
SectionNotFound(const std::string &_rsName) : m_sName(_rsName) SectionNotFound(const std::string& _rsName)
: m_sName(_rsName)
{ {
} }
virtual ~SectionNotFound() virtual ~SectionNotFound()
@ -59,11 +56,11 @@ class SectionNotFound : public NotFound
std::string m_sName; std::string m_sName;
}; };
class KeyNotFound : public NotFound class KeyNotFound : public NotFound {
{
public: public:
KeyNotFound(const std::string& _rsSection, const std::string& _rsKey) KeyNotFound(const std::string& _rsSection, const std::string& _rsKey)
: m_sSection(_rsSection), m_sKey(_rsKey) : m_sSection(_rsSection)
, m_sKey(_rsKey)
{ {
} }
virtual ~KeyNotFound() virtual ~KeyNotFound()
@ -84,8 +81,7 @@ class KeyNotFound : public NotFound
std::string m_sKey; std::string m_sKey;
}; };
class Line class Line {
{
public: public:
Line(const std::string& _rsKey, const std::string& _rsValue); Line(const std::string& _rsKey, const std::string& _rsValue);
@ -93,8 +89,7 @@ class Line
std::string m_sValue; std::string m_sValue;
}; };
class Section : private std::list<Line> class Section : private std::list<Line> {
{
public: public:
explicit Section(const std::string& _rsName); explicit Section(const std::string& _rsName);
@ -108,9 +103,11 @@ class Section : private std::list<Line>
std::string sGetKey(const std::string& _rsKey) const; std::string sGetKey(const std::string& _rsKey) const;
void vRemoveKey(const std::string& _rsKey); void vRemoveKey(const std::string& _rsKey);
template <typename T> void vSetKey(const std::string &_rsKey, const T &_rValue); template <typename T>
void vSetKey(const std::string& _rsKey, const T& _rValue);
template <typename T> T oGetKey(const std::string &_rsKey) const; template <typename T>
T oGetKey(const std::string& _rsKey) const;
// read only // read only
typedef std::list<Line>::const_iterator const_iterator; typedef std::list<Line>::const_iterator const_iterator;
@ -136,8 +133,7 @@ class Section : private std::list<Line>
std::string m_sName; std::string m_sName;
}; };
class File : private std::list<Section> class File : private std::list<Section> {
{
public: public:
File(); File();
File(const std::string& _rsFile); File(const std::string& _rsFile);
@ -176,7 +172,8 @@ class File : private std::list<Section>
// debug // debug
std::ostream& operator<<(std::ostream& _roOut, const File& _roConfig); std::ostream& operator<<(std::ostream& _roOut, const File& _roConfig);
template <typename T> void Section::vSetKey(const std::string &_rsKey, const T &_rValue) template <typename T>
void Section::vSetKey(const std::string& _rsKey, const T& _rValue)
{ {
std::ostringstream oOut; std::ostringstream oOut;
oOut << _rValue; oOut << _rValue;
@ -189,7 +186,8 @@ template <typename T> void Section::vSetKey(const std::string &_rsKey, const T &
push_back(Line(_rsKey, oOut.str())); push_back(Line(_rsKey, oOut.str()));
} }
template <typename T> T Section::oGetKey(const std::string &_rsKey) const template <typename T>
T Section::oGetKey(const std::string& _rsKey) const
{ {
T oValue; T oValue;
for (const_iterator it = begin(); it != end(); it++) { for (const_iterator it = begin(); it != end(); it++) {

View File

@ -22,11 +22,9 @@
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = {
{
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" }, { "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" }, { "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" }, { "batteries", N_("Batteries :"), "BatteriesDirEntry" },
@ -35,16 +33,15 @@ const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] =
{ "captures", N_("Captures :"), "CapturesDirEntry" } { "captures", N_("Captures :"), "CapturesDirEntry" }
}; };
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section * _poConfig) : DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section* _poConfig)
Gtk::Dialog(_("Directories config"), true), : Gtk::Dialog(_("Directories config"), true)
m_poConfig(_poConfig) , m_poConfig(_poConfig)
{ {
Gtk::Table* poTable = Gtk::manage(new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false)); Gtk::Table* poTable = Gtk::manage(new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
poTable->set_border_width(5); poTable->set_border_width(5);
poTable->set_spacings(5); poTable->set_spacings(5);
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
{
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END)); Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END));
m_poButtons[i] = Gtk::manage(new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER)); m_poButtons[i] = Gtk::manage(new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey)); m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey));
@ -60,8 +57,7 @@ DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section * _poConfig) :
void DirectoriesConfigDialog::on_response(int response_id) void DirectoriesConfigDialog::on_response(int response_id)
{ {
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
{
m_poConfig->vSetKey(m_astDirs[i].m_csKey, m_poButtons[i]->get_current_folder()); m_poConfig->vSetKey(m_astDirs[i].m_csKey, m_poButtons[i]->get_current_folder());
} }
} }

View File

@ -26,10 +26,8 @@
#include "configfile.h" #include "configfile.h"
namespace VBA namespace VBA {
{ class DirectoriesConfigDialog : public Gtk::Dialog {
class DirectoriesConfigDialog : public Gtk::Dialog
{
public: public:
DirectoriesConfigDialog(Config::Section* _poConfig); DirectoriesConfigDialog(Config::Section* _poConfig);

View File

@ -18,21 +18,20 @@
#include "displayconfig.h" #include "displayconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h> #include <gtkmm/frame.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/radiobutton.h> #include <gtkmm/radiobutton.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/stock.h>
#include "intl.h"
#include "filters.h" #include "filters.h"
#include "intl.h"
namespace VBA namespace VBA {
{
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog), : Gtk::Dialog(_pstDialog)
m_poConfig(0) , m_poConfig(0)
{ {
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox); refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox); refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
@ -46,13 +45,11 @@ DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
m_poOutputOpenGLRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputOpenGL)); m_poOutputOpenGLRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputOpenGL));
m_poOutputCairoRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputCairo)); m_poOutputCairoRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputCairo));
// Populate the filters combobox // Populate the filters combobox
Glib::RefPtr<Gtk::ListStore> poFiltersListStore; Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore")); poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
for (guint i = FirstFilter; i <= LastFilter; i++) for (guint i = FirstFilter; i <= LastFilter; i++) {
{
Gtk::TreeModel::Row row = *(poFiltersListStore->append()); Gtk::TreeModel::Row row = *(poFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterName((EFilter)i))); row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
} }
@ -61,8 +58,7 @@ DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore; Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore")); poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
for (guint i = FirstFilterIB; i <= LastFilterIB; i++) for (guint i = FirstFilterIB; i <= LastFilterIB; i++) {
{
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append()); Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i))); row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
} }
@ -84,8 +80,7 @@ void DisplayConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window *
// Set the default output module // Set the default output module
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output"); VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
switch (_eOutput) switch (_eOutput) {
{
case VBA::Window::OutputOpenGL: case VBA::Window::OutputOpenGL:
m_poOutputOpenGLRadioButton->set_active(); m_poOutputOpenGLRadioButton->set_active();
break; break;
@ -98,8 +93,7 @@ void DisplayConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window *
void DisplayConfigDialog::vOnFilterChanged() void DisplayConfigDialog::vOnFilterChanged()
{ {
int iFilter = m_poFiltersComboBox->get_active_row_number(); int iFilter = m_poFiltersComboBox->get_active_row_number();
if (iFilter >= 0) if (iFilter >= 0) {
{
m_poConfig->vSetKey("filter2x", iFilter); m_poConfig->vSetKey("filter2x", iFilter);
m_poWindow->vApplyConfigFilter(); m_poWindow->vApplyConfigFilter();
} }
@ -108,8 +102,7 @@ void DisplayConfigDialog::vOnFilterChanged()
void DisplayConfigDialog::vOnFilterIBChanged() void DisplayConfigDialog::vOnFilterIBChanged()
{ {
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number(); int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
if (iFilterIB >= 0) if (iFilterIB >= 0) {
{
m_poConfig->vSetKey("filterIB", iFilterIB); m_poConfig->vSetKey("filterIB", iFilterIB);
m_poWindow->vApplyConfigFilterIB(); m_poWindow->vApplyConfigFilterIB();
} }
@ -122,12 +115,10 @@ void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
if (_eOutput == eOldOutput) if (_eOutput == eOldOutput)
return; return;
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active()) if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active()) {
{
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL); m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
m_poWindow->vApplyConfigScreenArea(); m_poWindow->vApplyConfigScreenArea();
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active()) } else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active()) {
{
m_poConfig->vSetKey("output", VBA::Window::OutputCairo); m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
m_poWindow->vApplyConfigScreenArea(); m_poWindow->vApplyConfigScreenArea();
} }
@ -136,8 +127,7 @@ void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
void DisplayConfigDialog::vOnScaleChanged() void DisplayConfigDialog::vOnScaleChanged()
{ {
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1; int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
if (iScale > 0) if (iScale > 0) {
{
m_poConfig->vSetKey("scale", iScale); m_poConfig->vSetKey("scale", iScale);
m_poWindow->vUpdateScreen(); m_poWindow->vUpdateScreen();
} }

View File

@ -27,10 +27,8 @@
#include "configfile.h" #include "configfile.h"
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ class DisplayConfigDialog : public Gtk::Dialog {
class DisplayConfigDialog : public Gtk::Dialog
{
public: public:
DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -48,16 +48,13 @@ void SmartIB32 (u8 *, u32, int, int);
void MotionBlurIB(u8*, u32, int, int); void MotionBlurIB(u8*, u32, int, int);
void MotionBlurIB32(u8*, u32, int, int); void MotionBlurIB32(u8*, u32, int, int);
namespace VBA namespace VBA {
{
struct { struct {
char m_csName[30]; char m_csName[30];
int m_iEnlargeFactor; int m_iEnlargeFactor;
Filter m_apvFunc[2]; Filter m_apvFunc[2];
} } static const astFilters[] = {
static const astFilters[] =
{
{ N_("None"), 1, { 0, 0 } }, { N_("None"), 1, { 0, 0 } },
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } }, { N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } }, { N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
@ -76,9 +73,7 @@ static const astFilters[] =
struct { struct {
char m_csName[30]; char m_csName[30];
FilterIB m_apvFunc[2]; FilterIB m_apvFunc[2];
} } static const astFiltersIB[] = {
static const astFiltersIB[] =
{
{ N_("None"), { 0, 0 } }, { N_("None"), { 0, 0 } },
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } }, { N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } } { N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }

View File

@ -24,8 +24,7 @@
int Init_2xSaI(u32); int Init_2xSaI(u32);
namespace VBA namespace VBA {
{
typedef void (*Filter)(u8*, u32, u8*, u8*, u32, int, int); typedef void (*Filter)(u8*, u32, u8*, u8*, u32, int, int);
typedef void (*FilterIB)(u8*, u32, int, int); typedef void (*FilterIB)(u8*, u32, int, int);
@ -55,7 +54,8 @@ enum EFilterIB {
LastFilterIB = FilterIBMotionBlur LastFilterIB = FilterIBMotionBlur
}; };
enum EFilterDepth { FilterDepth16, FilterDepth32 }; enum EFilterDepth { FilterDepth16,
FilterDepth32 };
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth); Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
const char* pcsGetFilterName(const EFilter _eFilter); const char* pcsGetFilterName(const EFilter _eFilter);

View File

@ -21,11 +21,10 @@
#include <vector> #include <vector>
namespace VBA namespace VBA {
{
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
CheatListDialog(_pstDialog, refBuilder) : CheatListDialog(_pstDialog, refBuilder)
{ {
vUpdateList(); vUpdateList();
} }
@ -34,19 +33,16 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
{ {
int previous = cheatsNumber; int previous = cheatsNumber;
switch (type) switch (type) {
{
// Generic Code // Generic Code
case CheatGeneric: case CheatGeneric: {
{
std::vector<Glib::ustring> tokens; std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens); vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin(); for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end(); it != tokens.end();
it++) it++) {
{
Glib::ustring sToken = it->uppercase(); Glib::ustring sToken = it->uppercase();
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str()); cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
@ -56,8 +52,7 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
} }
// Gameshark Advance & CodeBreaker Advance // Gameshark Advance & CodeBreaker Advance
case CheatGSA: case CheatGSA:
case CheatCBA: case CheatCBA: {
{
std::vector<Glib::ustring> tokens; std::vector<Glib::ustring> tokens;
Glib::ustring sToken; Glib::ustring sToken;
@ -68,35 +63,27 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
for (std::vector<Glib::ustring>::iterator it = tokens.begin(); for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end(); it != tokens.end();
it++) it++) {
{
sToken = it->uppercase(); sToken = it->uppercase();
const char* cToken = sToken.c_str(); const char* cToken = sToken.c_str();
if (sToken.size() == 16) if (sToken.size() == 16)
cheatsAddGSACode(cToken, sDesc.c_str(), false); cheatsAddGSACode(cToken, sDesc.c_str(), false);
else if (sToken.size() == 12) else if (sToken.size() == 12) {
{
sCode = sToken.substr(0, 8); sCode = sToken.substr(0, 8);
sCode += " "; sCode += " ";
sCode += sToken.substr(9, 4); sCode += sToken.substr(9, 4);
cheatsAddCBACode(sCode.c_str(), sDesc.c_str()); cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
} } else if (sPart.empty())
else
if (sPart.empty())
sPart = sToken; sPart = sToken;
else else {
{ if (sToken.size() == 4) {
if (sToken.size() == 4)
{
sCode = sPart; sCode = sPart;
sCode += " "; sCode += " ";
sCode += cToken; sCode += cToken;
cheatsAddCBACode(sCode.c_str(), sDesc.c_str()); cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
} } else {
else
{
sCode = sPart + sToken; sCode = sPart + sToken;
cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true); cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true);
} }
@ -122,15 +109,18 @@ void GameBoyAdvanceCheatListDialog::vCheatListSave(const char *file)
cheatsSaveCheatList(file); cheatsSaveCheatList(file);
} }
void GameBoyAdvanceCheatListDialog::vRemoveCheat(int index) { void GameBoyAdvanceCheatListDialog::vRemoveCheat(int index)
{
cheatsDelete(index, false); cheatsDelete(index, false);
} }
void GameBoyAdvanceCheatListDialog::vRemoveAllCheats() { void GameBoyAdvanceCheatListDialog::vRemoveAllCheats()
{
cheatsDeleteAll(false); cheatsDeleteAll(false);
} }
void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable) { void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable)
{
if (enable) if (enable)
cheatsEnable(index); cheatsEnable(index);
else else
@ -139,8 +129,7 @@ void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable) {
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous) void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
{ {
for (int i = previous; i < cheatsNumber; i++) for (int i = previous; i < cheatsNumber; i++) {
{
// Add row for each newly added cheat // Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append()); Gtk::TreeModel::Row row = *(m_poCheatListStore->append());

View File

@ -25,10 +25,8 @@
#include "../gba/Globals.h" #include "../gba/Globals.h"
#include "cheatlist.h" #include "cheatlist.h"
namespace VBA namespace VBA {
{ class GameBoyAdvanceCheatListDialog : public CheatListDialog {
class GameBoyAdvanceCheatListDialog : public CheatListDialog
{
public: public:
GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog,
const Glib::RefPtr<Gtk::Builder>& refBuilder); const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -20,12 +20,11 @@
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog), : Gtk::Dialog(_pstDialog)
m_poConfig(0) , m_poConfig(0)
{ {
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox); refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox); refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
@ -49,12 +48,9 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
m_poSaveTypeComboBox->set_active(eDefaultSaveType); m_poSaveTypeComboBox->set_active(eDefaultSaveType);
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size"); int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
if (iDefaultFlashSize == 128) if (iDefaultFlashSize == 128) {
{
m_poFlashSizeComboBox->set_active(1); m_poFlashSizeComboBox->set_active(1);
} } else {
else
{
m_poFlashSizeComboBox->set_active(0); m_poFlashSizeComboBox->set_active(0);
} }
@ -65,8 +61,7 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file"); std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
m_poBiosFileChooserButton->set_filename(sBios); m_poBiosFileChooserButton->set_filename(sBios);
const char * acsPattern[] = const char* acsPattern[] = {
{
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]", "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]" "*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
}; };
@ -78,8 +73,7 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
Gtk::FileFilter oBiosFilter; Gtk::FileFilter oBiosFilter;
oBiosFilter.set_name(_("Gameboy Advance BIOS")); oBiosFilter.set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
{
oBiosFilter.add_pattern(acsPattern[i]); oBiosFilter.add_pattern(acsPattern[i]);
} }
#else #else
@ -89,8 +83,7 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create(); const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
oBiosFilter->set_name(_("Gameboy Advance BIOS")); oBiosFilter->set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
{
oBiosFilter->add_pattern(acsPattern[i]); oBiosFilter->add_pattern(acsPattern[i]);
} }
#endif #endif
@ -113,12 +106,9 @@ void GameBoyAdvanceConfigDialog::vOnSaveTypeChanged()
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged() void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
{ {
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number(); int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
if (iFlashSize == 0) if (iFlashSize == 0) {
{
m_poConfig->vSetKey("flash_size", 64); m_poConfig->vSetKey("flash_size", 64);
} } else {
else
{
m_poConfig->vSetKey("flash_size", 128); m_poConfig->vSetKey("flash_size", 128);
} }

View File

@ -26,10 +26,8 @@
#include "configfile.h" #include "configfile.h"
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ class GameBoyAdvanceConfigDialog : public Gtk::Dialog {
class GameBoyAdvanceConfigDialog : public Gtk::Dialog
{
public: public:
GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog,
const Glib::RefPtr<Gtk::Builder>& refBuilder); const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -21,11 +21,10 @@
#include <vector> #include <vector>
namespace VBA namespace VBA {
{
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
CheatListDialog(_pstDialog, refBuilder) : CheatListDialog(_pstDialog, refBuilder)
{ {
vUpdateList(); vUpdateList();
} }
@ -34,19 +33,16 @@ void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Gli
{ {
int previous = gbCheatNumber; int previous = gbCheatNumber;
switch (type) switch (type) {
{
// GameShark // GameShark
case CheatGS: case CheatGS: {
{
std::vector<Glib::ustring> tokens; std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens); vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin(); for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end(); it != tokens.end();
it++) it++) {
{
Glib::ustring sToken = it->uppercase(); Glib::ustring sToken = it->uppercase();
gbAddGsCheat(sToken.c_str(), sDesc.c_str()); gbAddGsCheat(sToken.c_str(), sDesc.c_str());
@ -55,16 +51,14 @@ void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Gli
break; break;
} }
// GameGenie // GameGenie
case CheatGG: case CheatGG: {
{
std::vector<Glib::ustring> tokens; std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens); vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin(); for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end(); it != tokens.end();
it++) it++) {
{
Glib::ustring sToken = it->uppercase(); Glib::ustring sToken = it->uppercase();
gbAddGgCheat(sToken.c_str(), sDesc.c_str()); gbAddGgCheat(sToken.c_str(), sDesc.c_str());
@ -99,7 +93,8 @@ void GameBoyCheatListDialog::vRemoveAllCheats()
gbCheatRemoveAll(); gbCheatRemoveAll();
} }
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable) { void GameBoyCheatListDialog::vToggleCheat(int index, bool enable)
{
if (enable) if (enable)
gbCheatEnable(index); gbCheatEnable(index);
else else
@ -108,8 +103,7 @@ void GameBoyCheatListDialog::vToggleCheat(int index, bool enable) {
void GameBoyCheatListDialog::vUpdateList(int previous) void GameBoyCheatListDialog::vUpdateList(int previous)
{ {
for (int i = previous; i < gbCheatNumber; i++) for (int i = previous; i < gbCheatNumber; i++) {
{
// Add row for each newly added cheat // Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append()); Gtk::TreeModel::Row row = *(m_poCheatListStore->append());

View File

@ -22,10 +22,8 @@
#include "../gb/gbCheats.h" #include "../gb/gbCheats.h"
#include "cheatlist.h" #include "cheatlist.h"
namespace VBA namespace VBA {
{ class GameBoyCheatListDialog : public CheatListDialog {
class GameBoyCheatListDialog : public CheatListDialog
{
public: public:
GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -18,17 +18,15 @@
#include "gameboyconfig.h" #include "gameboyconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h> #include <gtkmm/frame.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
static const VBA::Window::EEmulatorType aEmulatorType[] = static const VBA::Window::EEmulatorType aEmulatorType[] = {
{
VBA::Window::EmulatorAuto, VBA::Window::EmulatorAuto,
VBA::Window::EmulatorCGB, VBA::Window::EmulatorCGB,
VBA::Window::EmulatorSGB, VBA::Window::EmulatorSGB,
@ -37,9 +35,9 @@ static const VBA::Window::EEmulatorType aEmulatorType[] =
VBA::Window::EmulatorSGB2 VBA::Window::EmulatorSGB2
}; };
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog), : Gtk::Dialog(_pstDialog)
m_poConfig(0) , m_poConfig(0)
{ {
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox); refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton); refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);

View File

@ -26,10 +26,8 @@
#include "configfile.h" #include "configfile.h"
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ class GameBoyConfigDialog : public Gtk::Dialog {
class GameBoyConfigDialog : public Gtk::Dialog
{
public: public:
GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -18,18 +18,17 @@
#include "generalconfig.h" #include "generalconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h> #include <gtkmm/frame.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog), : Gtk::Dialog(_pstDialog)
m_poConfig(0) , m_poConfig(0)
{ {
refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton); refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton);
refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton); refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton);
@ -40,7 +39,6 @@ PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<G
m_poFrameSkipAutomaticCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged)); m_poFrameSkipAutomaticCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
m_poFrameSkipLevelSpinButton->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged)); m_poFrameSkipLevelSpinButton->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
m_poSpeedIndicatorComboBox->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnSpeedIndicatorChanged)); m_poSpeedIndicatorComboBox->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnSpeedIndicatorChanged));
} }
void PreferencesDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow) void PreferencesDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
@ -78,12 +76,9 @@ void PreferencesDialog::vOnFrameskipChanged()
{ {
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active(); bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
if (bAutoFrameskip) if (bAutoFrameskip) {
{
m_poConfig->vSetKey("frameskip", "auto"); m_poConfig->vSetKey("frameskip", "auto");
} } else {
else
{
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value(); int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
m_poConfig->vSetKey("frameskip", iFrameskip); m_poConfig->vSetKey("frameskip", iFrameskip);
} }

View File

@ -26,10 +26,8 @@
#include "configfile.h" #include "configfile.h"
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ class PreferencesDialog : public Gtk::Dialog {
class PreferencesDialog : public Gtk::Dialog
{
public: public:
PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -23,11 +23,9 @@
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = {
{
{ KEY_UP, N_("Up :") }, { KEY_UP, N_("Up :") },
{ KEY_DOWN, N_("Down :") }, { KEY_DOWN, N_("Down :") },
{ KEY_LEFT, N_("Left :") }, { KEY_LEFT, N_("Left :") },
@ -44,16 +42,16 @@ const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") } { KEY_BUTTON_AUTO_B, N_("Autofire B :") }
}; };
JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) : JoypadConfigDialog::JoypadConfigDialog(Config::Section* _poConfig)
Gtk::Dialog(_("Joypad config"), true), : Gtk::Dialog(_("Joypad config"), true)
m_oTitleHBox(false, 5), , m_oTitleHBox(false, 5)
m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END), , m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END)
m_oDefaultJoypad(_("Default joypad")), , m_oDefaultJoypad(_("Default joypad"))
m_oTable(G_N_ELEMENTS(m_astKeys), 2, false), , m_oTable(G_N_ELEMENTS(m_astKeys), 2, false)
m_iCurrentEntry(-1), , m_iCurrentEntry(-1)
m_bUpdating(false), , m_bUpdating(false)
m_ePad(PAD_MAIN), , m_ePad(PAD_MAIN)
m_poConfig(_poConfig) , m_poConfig(_poConfig)
{ {
// Joypad selection // Joypad selection
#if !GTK_CHECK_VERSION(3, 0, 0) #if !GTK_CHECK_VERSION(3, 0, 0)
@ -72,8 +70,7 @@ JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :
m_oTitleHBox.pack_start(m_oTitleCombo); m_oTitleHBox.pack_start(m_oTitleCombo);
// Joypad buttons // Joypad buttons
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++) for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++) {
{
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END)); Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END));
Gtk::Entry* poEntry = Gtk::manage(new Gtk::Entry()); Gtk::Entry* poEntry = Gtk::manage(new Gtk::Entry());
m_oTable.attach(*poLabel, 0, 1, i, i + 1); m_oTable.attach(*poLabel, 0, 1, i, i + 1);
@ -121,60 +118,55 @@ void JoypadConfigDialog::vUpdateEntries()
m_bUpdating = true; m_bUpdating = true;
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad); m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
for (guint i = 0; i < m_oEntries.size(); i++) for (guint i = 0; i < m_oEntries.size(); i++) {
{
std::string csName; std::string csName;
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag); guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
int dev = uiKeyval >> 16; int dev = uiKeyval >> 16;
if (dev == 0) if (dev == 0) {
{
csName = gdk_keyval_name(uiKeyval); csName = gdk_keyval_name(uiKeyval);
} } else {
else
{
int what = uiKeyval & 0xffff; int what = uiKeyval & 0xffff;
std::stringstream os; std::stringstream os;
os << _("Joy ") << dev; os << _("Joy ") << dev;
if(what >= 128) if (what >= 128) {
{
// joystick button // joystick button
int button = what - 128; int button = what - 128;
os << _(" Button ") << button; os << _(" Button ") << button;
} } else if (what < 0x20) {
else if (what < 0x20)
{
// joystick axis // joystick axis
int dir = what & 1; int dir = what & 1;
what >>= 1; what >>= 1;
os << _(" Axis ") << what << (dir ? '-' : '+'); os << _(" Axis ") << what << (dir ? '-' : '+');
} } else if (what < 0x30) {
else if (what < 0x30)
{
// joystick hat // joystick hat
int dir = (what & 3); int dir = (what & 3);
what = (what & 15); what = (what & 15);
what >>= 2; what >>= 2;
os << _(" Hat ") << what << " "; os << _(" Hat ") << what << " ";
switch (dir) switch (dir) {
{ case 0:
case 0: os << _("Up"); break; os << _("Up");
case 1: os << _("Down"); break; break;
case 2: os << _("Right"); break; case 1:
case 3: os << _("Left"); break; os << _("Down");
break;
case 2:
os << _("Right");
break;
case 3:
os << _("Left");
break;
} }
} }
csName = os.str(); csName = os.str();
} }
if (csName.empty()) if (csName.empty()) {
{
m_oEntries[i]->set_text(_("<Undefined>")); m_oEntries[i]->set_text(_("<Undefined>"));
} } else {
else
{
m_oEntries[i]->set_text(csName); m_oEntries[i]->set_text(csName);
} }
} }
@ -199,8 +191,7 @@ bool JoypadConfigDialog::bOnEntryFocusOut(GdkEventFocus * _pstEvent)
bool JoypadConfigDialog::on_key_press_event(GdkEventKey* _pstEvent) bool JoypadConfigDialog::on_key_press_event(GdkEventKey* _pstEvent)
{ {
if (m_iCurrentEntry < 0) if (m_iCurrentEntry < 0) {
{
return Gtk::Window::on_key_press_event(_pstEvent); return Gtk::Window::on_key_press_event(_pstEvent);
} }
@ -224,22 +215,19 @@ void JoypadConfigDialog::on_response(int response_id)
void JoypadConfigDialog::vOnInputEvent(const SDL_Event& event) void JoypadConfigDialog::vOnInputEvent(const SDL_Event& event)
{ {
if (m_iCurrentEntry < 0) if (m_iCurrentEntry < 0) {
{
return; return;
} }
int code = inputGetEventCode(event); int code = inputGetEventCode(event);
if (!code) return; if (!code)
return;
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code); inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
vUpdateEntries(); vUpdateEntries();
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) {
{
m_oEntries[m_iCurrentEntry + 1]->grab_focus(); m_oEntries[m_iCurrentEntry + 1]->grab_focus();
} } else {
else
{
m_poOkButton->grab_focus(); m_poOkButton->grab_focus();
} }
} }
@ -247,17 +235,15 @@ void JoypadConfigDialog::vOnInputEvent(const SDL_Event &event)
bool JoypadConfigDialog::bOnConfigIdle() bool JoypadConfigDialog::bOnConfigIdle()
{ {
SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)) while (SDL_PollEvent(&event)) {
{ switch (event.type) {
switch(event.type)
{
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
if (abs(event.jaxis.value) < 16384) continue; if (abs(event.jaxis.value) < 16384)
continue;
if (event.jaxis.which != m_oPreviousEvent.jaxis.which if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|| event.jaxis.axis != m_oPreviousEvent.jaxis.axis || event.jaxis.axis != m_oPreviousEvent.jaxis.axis
|| (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0) || (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
|| (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0)) || (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0)) {
{
vOnInputEvent(event); vOnInputEvent(event);
m_oPreviousEvent = event; m_oPreviousEvent = event;
} }
@ -268,8 +254,7 @@ bool JoypadConfigDialog::bOnConfigIdle()
vEmptyEventQueue(); vEmptyEventQueue();
break; break;
case SDL_JOYHATMOTION: case SDL_JOYHATMOTION:
if (event.jhat.value) if (event.jhat.value) {
{
vOnInputEvent(event); vOnInputEvent(event);
vEmptyEventQueue(); vEmptyEventQueue();
} }
@ -284,27 +269,21 @@ void JoypadConfigDialog::vEmptyEventQueue()
{ {
// Empty the SDL event queue // Empty the SDL event queue
SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)); while (SDL_PollEvent(&event))
;
} }
void JoypadConfigDialog::vOnJoypadSelect() void JoypadConfigDialog::vOnJoypadSelect()
{ {
std::string oText = m_oTitleCombo.get_active_text(); std::string oText = m_oTitleCombo.get_active_text();
if (oText == "1") if (oText == "1") {
{
m_ePad = PAD_1; m_ePad = PAD_1;
} } else if (oText == "2") {
else if (oText == "2")
{
m_ePad = PAD_2; m_ePad = PAD_2;
} } else if (oText == "3") {
else if (oText == "3")
{
m_ePad = PAD_3; m_ePad = PAD_3;
} } else if (oText == "4") {
else if (oText == "4")
{
m_ePad = PAD_4; m_ePad = PAD_4;
} }
@ -316,14 +295,12 @@ void JoypadConfigDialog::vOnJoypadSelect()
void JoypadConfigDialog::vOnDefaultJoypadSelect() void JoypadConfigDialog::vOnDefaultJoypadSelect()
{ {
if (m_bUpdating) return; if (m_bUpdating)
return;
if (m_oDefaultJoypad.get_active()) if (m_oDefaultJoypad.get_active()) {
{
inputSetDefaultJoypad(m_ePad); inputSetDefaultJoypad(m_ePad);
} } else {
else
{
inputSetDefaultJoypad(PAD_MAIN); inputSetDefaultJoypad(PAD_MAIN);
} }
} }

View File

@ -33,10 +33,8 @@
#include "../sdl/inputSDL.h" #include "../sdl/inputSDL.h"
#include "configfile.h" #include "configfile.h"
namespace VBA namespace VBA {
{ class JoypadConfigDialog : public Gtk::Dialog {
class JoypadConfigDialog : public Gtk::Dialog
{
public: public:
JoypadConfigDialog(Config::Section* _poConfig); JoypadConfigDialog(Config::Section* _poConfig);
virtual ~JoypadConfigDialog(); virtual ~JoypadConfigDialog();

View File

@ -16,10 +16,10 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/messagedialog.h>
#include <glibmm/miscutils.h> #include <glibmm/miscutils.h>
#include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/window.h>
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0) #if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
#include <gtkmm/gl/init.h> #include <gtkmm/gl/init.h>
@ -28,8 +28,8 @@
// this will be ifdefed soon // this will be ifdefed soon
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "window.h"
#include "intl.h" #include "intl.h"
#include "window.h"
int systemDebug = 0; int systemDebug = 0;
@ -70,12 +70,9 @@ int main(int argc, char * argv[])
oContext.set_main_group(oGroup); oContext.set_main_group(oGroup);
try try {
{
oContext.parse(argc, argv); oContext.parse(argc, argv);
} } catch (const Glib::Error& e) {
catch (const Glib::Error& e)
{
Gtk::MessageDialog oDialog(e.what(), Gtk::MessageDialog oDialog(e.what(),
false, false,
Gtk::MESSAGE_ERROR, Gtk::MESSAGE_ERROR,
@ -84,8 +81,7 @@ int main(int argc, char * argv[])
return 1; return 1;
} }
if (bShowVersion) if (bShowVersion) {
{
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION); g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
exit(0); exit(0);
} }
@ -95,14 +91,11 @@ int main(int argc, char * argv[])
std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui"); std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");
Glib::RefPtr<Gtk::Builder> poXml; Glib::RefPtr<Gtk::Builder> poXml;
try try {
{
poXml = Gtk::Builder::create(); poXml = Gtk::Builder::create();
poXml->add_from_file(sGtkBuilderFile, "accelgroup1"); poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
poXml->add_from_file(sGtkBuilderFile, "MainWindow"); poXml->add_from_file(sGtkBuilderFile, "MainWindow");
} } catch (const Gtk::BuilderError& e) {
catch (const Gtk::BuilderError & e)
{
Gtk::MessageDialog oDialog(e.what(), Gtk::MessageDialog oDialog(e.what(),
false, false,
Gtk::MESSAGE_ERROR, Gtk::MESSAGE_ERROR,
@ -114,12 +107,10 @@ int main(int argc, char * argv[])
VBA::Window* poWindow = NULL; VBA::Window* poWindow = NULL;
poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow); poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
if (listRemaining.size() == 1) if (listRemaining.size() == 1) {
{
// Display the window before loading the file // Display the window before loading the file
poWindow->show(); poWindow->show();
while (Gtk::Main::events_pending()) while (Gtk::Main::events_pending()) {
{
Gtk::Main::iteration(); Gtk::Main::iteration();
} }

View File

@ -20,14 +20,15 @@
#include <cstring> #include <cstring>
namespace VBA namespace VBA {
{
template<typename T> T min( T x, T y ) { return x < y ? x : y; } template <typename T>
template<typename T> T max( T x, T y ) { return x > y ? x : y; } T min(T x, T y) { return x < y ? x : y; }
template <typename T>
T max(T x, T y) { return x > y ? x : y; }
ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale) : ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale)
ScreenArea(_iWidth, _iHeight, _iScale) : ScreenArea(_iWidth, _iHeight, _iScale)
{ {
vUpdateSize(); vUpdateSize();
} }
@ -100,8 +101,7 @@ bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context> &poContext)
void ScreenAreaCairo::vDrawBlackScreen() void ScreenAreaCairo::vDrawBlackScreen()
{ {
if (m_puiPixels && get_realized()) if (m_puiPixels && get_realized()) {
{
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32)); memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
queue_draw_area(0, 0, get_width(), get_height()); queue_draw_area(0, 0, get_width(), get_height());
} }

View File

@ -22,10 +22,8 @@
#include "screenarea.h" #include "screenarea.h"
namespace VBA namespace VBA {
{ class ScreenAreaCairo : public ScreenArea {
class ScreenAreaCairo : public ScreenArea
{
public: public:
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1); ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData); void vDrawPixels(u8* _puiData);

View File

@ -21,23 +21,22 @@
#include <cstring> #include <cstring>
namespace VBA namespace VBA {
{
template<typename T> T min( T x, T y ) { return x < y ? x : y; } template <typename T>
template<typename T> T max( T x, T y ) { return x > y ? x : y; } T min(T x, T y) { return x < y ? x : y; }
template <typename T>
T max(T x, T y) { return x > y ? x : y; }
ScreenAreaGl::ScreenAreaGl(int _iWidth, int _iHeight, int _iScale) : ScreenAreaGl::ScreenAreaGl(int _iWidth, int _iHeight, int _iScale)
ScreenArea(_iWidth, _iHeight, _iScale), : ScreenArea(_iWidth, _iHeight, _iScale)
m_uiScreenTexture(0), , m_uiScreenTexture(0)
m_iTextureSize(0) , m_iTextureSize(0)
{ {
Glib::RefPtr<Gdk::GL::Config> glconfig; Glib::RefPtr<Gdk::GL::Config> glconfig;
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DOUBLE);
Gdk::GL::MODE_DOUBLE); if (!glconfig) {
if (!glconfig)
{
fprintf(stderr, _("*** OpenGL : Cannot open display.\n")); fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
throw std::exception(); throw std::exception();
} }
@ -52,8 +51,10 @@ void ScreenAreaGl::vUpdateTexture()
// Calculate the new texture size as a the smallest working power of two // Calculate the new texture size as a the smallest working power of two
// TODO: Support the ARB_texture_rectangle extension // TODO: Support the ARB_texture_rectangle extension
int iExpX = 0, iExpY = 0; int iExpX = 0, iExpY = 0;
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX); for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX)
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY); ;
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY)
;
int iNewTextureSize = 1 << max(iExpX, iExpY); int iNewTextureSize = 1 << max(iExpX, iExpY);
// Notify the system if the texture size changed // Notify the system if the texture size changed
@ -109,8 +110,7 @@ void ScreenAreaGl::vDrawPixels(u8 * _puiData)
void ScreenAreaGl::vDrawBlackScreen() void ScreenAreaGl::vDrawBlackScreen()
{ {
if (m_puiPixels && get_realized()) if (m_puiPixels && get_realized()) {
{
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32)); memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
queue_draw_area(0, 0, get_width(), get_height()); queue_draw_area(0, 0, get_width(), get_height());
} }

View File

@ -23,10 +23,8 @@
#include "screenarea.h" #include "screenarea.h"
#include <gtkmm/gl/widget.h> #include <gtkmm/gl/widget.h>
namespace VBA namespace VBA {
{ class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl>
{
public: public:
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1); ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData); void vDrawPixels(u8* _puiData);

View File

@ -21,19 +21,18 @@
#include <cstring> #include <cstring>
#include <glibmm/main.h> #include <glibmm/main.h>
namespace VBA namespace VBA {
{
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) : ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale)
m_iFilterScale(1), : m_iFilterScale(1)
m_vFilter2x(NULL), , m_vFilter2x(NULL)
m_vFilterIB(NULL), , m_vFilterIB(NULL)
m_puiPixels(NULL), , m_puiPixels(NULL)
m_puiDelta(NULL), , m_puiDelta(NULL)
m_iScaledWidth(_iWidth), , m_iScaledWidth(_iWidth)
m_iScaledHeight(_iHeight), , m_iScaledHeight(_iHeight)
m_bEnableRender(true), , m_bEnableRender(true)
m_bShowCursor(true) , m_bShowCursor(true)
{ {
g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1); g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
@ -58,19 +57,16 @@ ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) :
ScreenArea::~ScreenArea() ScreenArea::~ScreenArea()
{ {
if (m_puiPixels) if (m_puiPixels) {
{
delete[] m_puiPixels; delete[] m_puiPixels;
} }
if (m_puiDelta) if (m_puiDelta) {
{
delete[] m_puiDelta; delete[] m_puiDelta;
} }
#if !GTK_CHECK_VERSION(3, 0, 0) #if !GTK_CHECK_VERSION(3, 0, 0)
if (m_poEmptyCursor != NULL) if (m_poEmptyCursor != NULL) {
{
delete m_poEmptyCursor; delete m_poEmptyCursor;
} }
#else #else
@ -82,8 +78,7 @@ void ScreenArea::vSetSize(int _iWidth, int _iHeight)
{ {
g_return_if_fail(_iWidth >= 1 && _iHeight >= 1); g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
if (_iWidth != m_iWidth || _iHeight != m_iHeight) if (_iWidth != m_iWidth || _iHeight != m_iHeight) {
{
m_iWidth = _iWidth; m_iWidth = _iWidth;
m_iHeight = _iHeight; m_iHeight = _iHeight;
vUpdateSize(); vUpdateSize();
@ -94,8 +89,7 @@ void ScreenArea::vSetScale(int _iScale)
{ {
g_return_if_fail(_iScale >= 1); g_return_if_fail(_iScale >= 1);
if (_iScale == 1) if (_iScale == 1) {
{
vSetFilter(FilterNone); vSetFilter(FilterNone);
} }
@ -108,8 +102,7 @@ void ScreenArea::vSetFilter(EFilter _eFilter)
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32); m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
m_iFilterScale = 1; m_iFilterScale = 1;
if (m_vFilter2x != NULL) if (m_vFilter2x != NULL) {
{
m_iFilterScale = 2; m_iFilterScale = 2;
} }
@ -152,8 +145,7 @@ void ScreenArea::vShowCursor()
bool ScreenArea::on_motion_notify_event(GdkEventMotion* _pstEvent) bool ScreenArea::on_motion_notify_event(GdkEventMotion* _pstEvent)
{ {
if (! m_bShowCursor) if (!m_bShowCursor) {
{
vShowCursor(); vShowCursor();
} }
vStartCursorTimeout(); vStartCursorTimeout();
@ -169,8 +161,7 @@ bool ScreenArea::on_enter_notify_event(GdkEventCrossing * _pstEvent)
bool ScreenArea::on_leave_notify_event(GdkEventCrossing* _pstEvent) bool ScreenArea::on_leave_notify_event(GdkEventCrossing* _pstEvent)
{ {
vStopCursorTimeout(); vStopCursorTimeout();
if (! m_bShowCursor) if (!m_bShowCursor) {
{
vShowCursor(); vShowCursor();
} }
return false; return false;
@ -187,16 +178,14 @@ void ScreenArea::vDrawPixels(u8 * _puiData)
const int iSrcPitch = (m_iWidth + 1) * sizeof(u32); const int iSrcPitch = (m_iWidth + 1) * sizeof(u32);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32); const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
if (m_vFilterIB != NULL) if (m_vFilterIB != NULL) {
{
m_vFilterIB(_puiData + iSrcPitch, m_vFilterIB(_puiData + iSrcPitch,
iSrcPitch, iSrcPitch,
m_iWidth, m_iWidth,
m_iHeight); m_iHeight);
} }
if (m_vFilter2x != NULL) if (m_vFilter2x != NULL) {
{
m_vFilter2x(_puiData + iSrcPitch, m_vFilter2x(_puiData + iSrcPitch,
iSrcPitch, iSrcPitch,
m_puiDelta, m_puiDelta,
@ -204,22 +193,18 @@ void ScreenArea::vDrawPixels(u8 * _puiData)
iScaledPitch, iScaledPitch,
m_iWidth, m_iWidth,
m_iHeight); m_iHeight);
} } else {
else
{
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch); memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
} }
} }
void ScreenArea::vUpdateSize() void ScreenArea::vUpdateSize()
{ {
if (m_puiPixels) if (m_puiPixels) {
{
delete[] m_puiPixels; delete[] m_puiPixels;
} }
if (m_puiDelta) if (m_puiDelta) {
{
delete[] m_puiDelta; delete[] m_puiDelta;
} }

View File

@ -25,10 +25,8 @@
#include "filters.h" #include "filters.h"
namespace VBA namespace VBA {
{ class ScreenArea : public Gtk::DrawingArea {
class ScreenArea : public Gtk::DrawingArea
{
public: public:
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1); ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
virtual ~ScreenArea(); virtual ~ScreenArea();

View File

@ -18,18 +18,17 @@
#include "soundconfig.h" #include "soundconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h> #include <gtkmm/frame.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h" #include "intl.h"
namespace VBA namespace VBA {
{
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) : SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
Gtk::Dialog(_pstDialog), : Gtk::Dialog(_pstDialog)
m_poConfig(0) , m_poConfig(0)
{ {
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox); refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
refBuilder->get_widget("RateComboBox", m_poRateComboBox); refBuilder->get_widget("RateComboBox", m_poRateComboBox);
@ -58,8 +57,7 @@ void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _p
m_poVolumeComboBox->set_active(3); m_poVolumeComboBox->set_active(3);
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate"); long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
switch (iSoundSampleRate) switch (iSoundSampleRate) {
{
case 11025: case 11025:
m_poRateComboBox->set_active(0); m_poRateComboBox->set_active(0);
break; break;
@ -79,8 +77,7 @@ void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _p
void SoundConfigDialog::vOnVolumeChanged() void SoundConfigDialog::vOnVolumeChanged()
{ {
int iVolume = m_poVolumeComboBox->get_active_row_number(); int iVolume = m_poVolumeComboBox->get_active_row_number();
switch (iVolume) switch (iVolume) {
{
case 0: // Mute case 0: // Mute
m_poConfig->vSetKey("mute", true); m_poConfig->vSetKey("mute", true);
m_poConfig->vSetKey("volume", 1.0f); m_poConfig->vSetKey("volume", 1.0f);
@ -111,8 +108,7 @@ void SoundConfigDialog::vOnVolumeChanged()
void SoundConfigDialog::vOnRateChanged() void SoundConfigDialog::vOnRateChanged()
{ {
int iRate = m_poRateComboBox->get_active_row_number(); int iRate = m_poRateComboBox->get_active_row_number();
switch (iRate) switch (iRate) {
{
case 0: // 11 KHz case 0: // 11 KHz
m_poConfig->vSetKey("sample_rate", 11025); m_poConfig->vSetKey("sample_rate", 11025);
break; break;

View File

@ -26,10 +26,8 @@
#include "configfile.h" #include "configfile.h"
#include "window.h" #include "window.h"
namespace VBA namespace VBA {
{ class SoundConfigDialog : public Gtk::Dialog {
class SoundConfigDialog : public Gtk::Dialog
{
public: public:
SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder); SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);

View File

@ -16,12 +16,12 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "../sdl/inputSDL.h"
#include "../gba/Sound.h"
#include "../common/SoundSDL.h" #include "../common/SoundSDL.h"
#include "../gba/Sound.h"
#include "../sdl/inputSDL.h"
#include "window.h"
#include "intl.h" #include "intl.h"
#include "window.h"
// Required vars, used by the emulator core // Required vars, used by the emulator core
// //
@ -49,14 +49,16 @@ void systemMessage(int _iId, const char * _csFormat, ...)
va_list args; va_list args;
va_start(args, _csFormat); va_start(args, _csFormat);
GUI()->vPopupErrorV(_(_csFormat), args); GUI()
->vPopupErrorV(_(_csFormat), args);
va_end(args); va_end(args);
} }
void systemDrawScreen() void systemDrawScreen()
{ {
GUI()->vDrawScreen(); GUI()
->vDrawScreen();
} }
bool systemReadJoypads() bool systemReadJoypads()
@ -71,12 +73,14 @@ u32 systemReadJoypad(int joy)
void systemShowSpeed(int _iSpeed) void systemShowSpeed(int _iSpeed)
{ {
GUI()->vShowSpeed(_iSpeed); GUI()
->vShowSpeed(_iSpeed);
} }
void system10Frames(int _iRate) void system10Frames(int _iRate)
{ {
GUI()->vComputeFrameskip(_iRate); GUI()
->vComputeFrameskip(_iRate);
} }
void systemFrame() void systemFrame()
@ -85,12 +89,14 @@ void systemFrame()
void systemSetTitle(const char* _csTitle) void systemSetTitle(const char* _csTitle)
{ {
GUI()->set_title(_csTitle); GUI()
->set_title(_csTitle);
} }
void systemScreenCapture(int _iNum) void systemScreenCapture(int _iNum)
{ {
GUI()->vCaptureScreen(_iNum); GUI()
->vCaptureScreen(_iNum);
} }
u32 systemGetClock() u32 systemGetClock()

View File

@ -18,8 +18,7 @@
#include "tools.h" #include "tools.h"
namespace VBA namespace VBA {
{
std::string sCutSuffix(const std::string& _rsString, std::string sCutSuffix(const std::string& _rsString,
const std::string& _rsSep) const std::string& _rsSep)
@ -37,24 +36,18 @@ bool bHasSuffix(const Glib::ustring & _rsString,
const Glib::ustring& _rsSuffix, const Glib::ustring& _rsSuffix,
bool _bCaseSensitive) bool _bCaseSensitive)
{ {
if (_rsSuffix.size() > _rsString.size()) if (_rsSuffix.size() > _rsString.size()) {
{
return false; return false;
} }
Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size()); Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
if (_bCaseSensitive) if (_bCaseSensitive) {
{ if (_rsSuffix == sEnd) {
if (_rsSuffix == sEnd)
{
return true; return true;
} }
} } else {
else if (_rsSuffix.lowercase() == sEnd.lowercase()) {
{
if (_rsSuffix.lowercase() == sEnd.lowercase())
{
return true; return true;
} }
} }
@ -71,8 +64,7 @@ void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens)
// Find first "non-delimiter". // Find first "non-delimiter".
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos); Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
while (Glib::ustring::npos != pos || std:: string::npos != lastPos) while (Glib::ustring::npos != pos || std::string::npos != lastPos) {
{
// Found a token, add it to the vector. // Found a token, add it to the vector.
tokens.push_back(source.substr(lastPos, pos - lastPos)); tokens.push_back(source.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of" // Skip delimiters. Note the "not_of"

View File

@ -24,8 +24,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace VBA namespace VBA {
{
std::string sCutSuffix(const std::string& _rsString, const std::string& _rsSep = "."); std::string sCutSuffix(const std::string& _rsString, const std::string& _rsSep = ".");
Glib::ustring sCutSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSep = "."); Glib::ustring sCutSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSep = ".");

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,8 @@
#include "filters.h" #include "filters.h"
#include "screenarea.h" #include "screenarea.h"
namespace VBA namespace VBA {
{ class Window : public Gtk::Window {
class Window : public Gtk::Window
{
friend class Gtk::Builder; friend class Gtk::Builder;
public: public:
@ -49,9 +47,12 @@ class Window : public Gtk::Window
} }
static std::string sGetUiFilePath(const std::string& _sFileName); static std::string sGetUiFilePath(const std::string& _sFileName);
enum ECartridge { CartridgeNone, CartridgeGB, CartridgeGBA }; enum ECartridge { CartridgeNone,
CartridgeGB,
CartridgeGBA };
enum EVideoOutput { OutputCairo, OutputOpenGL }; enum EVideoOutput { OutputCairo,
OutputOpenGL };
enum EEmulatorType { enum EEmulatorType {
EmulatorAuto, EmulatorAuto,
@ -62,7 +63,12 @@ class Window : public Gtk::Window
EmulatorSGB2 EmulatorSGB2
}; };
enum ESaveType { SaveAuto, SaveEEPROM, SaveSRAM, SaveFlash, SaveEEPROMSensor, SaveNone }; enum ESaveType { SaveAuto,
SaveEEPROM,
SaveSRAM,
SaveFlash,
SaveEEPROMSensor,
SaveNone };
// GB/GBA screen sizes // GB/GBA screen sizes
const int m_iGBScreenWidth; const int m_iGBScreenWidth;
@ -104,11 +110,16 @@ class Window : public Gtk::Window
protected: protected:
Window(GtkWindow* _pstWindow, const Glib::RefPtr<Gtk::Builder>& _poXml); Window(GtkWindow* _pstWindow, const Glib::RefPtr<Gtk::Builder>& _poXml);
enum EShowSpeed { ShowNone, ShowPercentage, ShowDetailed }; enum EShowSpeed { ShowNone,
ShowPercentage,
ShowDetailed };
enum ESoundStatus { SoundOff, SoundMute, SoundOn }; enum ESoundStatus { SoundOff,
SoundMute,
SoundOn };
enum EColorFormat { ColorFormatRGB, ColorFormatBGR }; enum EColorFormat { ColorFormatRGB,
ColorFormatBGR };
virtual void vOnMenuEnter(); virtual void vOnMenuEnter();
virtual void vOnMenuExit(); virtual void vOnMenuExit();

View File

@ -20,45 +20,43 @@
#include <glibmm/convert.h> #include <glibmm/convert.h>
#include <glibmm/fileutils.h> #include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/main.h> #include <glibmm/main.h>
#include <glibmm/miscutils.h>
#include <deque> #include <deque>
#include <gtkmm/stock.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/aboutdialog.h> #include <gtkmm/aboutdialog.h>
#include <gtkmm/builder.h> #include <gtkmm/builder.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/stock.h>
#include <SDL.h> #include <SDL.h>
#include "../Util.h"
#include "../common/ConfigManager.h" #include "../common/ConfigManager.h"
#include "../gba/GBA.h"
#include "../gba/Sound.h"
#include "../gb/gb.h" #include "../gb/gb.h"
#include "../gb/gbGlobals.h" #include "../gb/gbGlobals.h"
#include "../Util.h" #include "../gba/GBA.h"
#include "../gba/Sound.h"
#include "../sdl/inputSDL.h" #include "../sdl/inputSDL.h"
#include "tools.h"
#include "intl.h"
#include "joypadconfig.h"
#include "directoriesconfig.h" #include "directoriesconfig.h"
#include "displayconfig.h" #include "displayconfig.h"
#include "soundconfig.h"
#include "gameboyconfig.h"
#include "gameboyadvanceconfig.h"
#include "generalconfig.h"
#include "gameboyadvancecheatlist.h" #include "gameboyadvancecheatlist.h"
#include "gameboyadvanceconfig.h"
#include "gameboycheatlist.h" #include "gameboycheatlist.h"
#include "gameboyconfig.h"
#include "generalconfig.h"
#include "intl.h"
#include "joypadconfig.h"
#include "soundconfig.h"
#include "tools.h"
namespace VBA namespace VBA {
{
void Window::vOnMenuEnter() void Window::vOnMenuEnter()
{ {
if (emulating && ! m_bPaused) if (emulating && !m_bPaused) {
{
vStopEmu(); vStopEmu();
soundPause(); soundPause();
} }
@ -66,8 +64,7 @@ void Window::vOnMenuEnter()
void Window::vOnMenuExit() void Window::vOnMenuExit()
{ {
if (emulating && ! m_bPaused) if (emulating && !m_bPaused) {
{
vStartEmu(); vStartEmu();
soundResume(); soundResume();
} }
@ -75,10 +72,8 @@ void Window::vOnMenuExit()
void Window::vOnFileOpen() void Window::vOnFileOpen()
{ {
while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK) while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK) {
{ if (bLoadROM(m_poFileOpenDialog->get_filename())) {
if (bLoadROM(m_poFileOpenDialog->get_filename()))
{
break; break;
} }
} }
@ -93,12 +88,9 @@ void Window::vOnFileLoad()
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
if (sSaveDir == "") if (sSaveDir == "") {
{
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
} } else {
else
{
oDialog.set_current_folder(sSaveDir); oDialog.set_current_folder(sSaveDir);
oDialog.add_shortcut_folder(sSaveDir); oDialog.add_shortcut_folder(sSaveDir);
} }
@ -115,10 +107,8 @@ void Window::vOnFileLoad()
oDialog.add_filter(oSaveFilter); oDialog.add_filter(oSaveFilter);
while (oDialog.run() == Gtk::RESPONSE_OK) while (oDialog.run() == Gtk::RESPONSE_OK) {
{ if (m_stEmulator.emuReadState(oDialog.get_filename().c_str())) {
if (m_stEmulator.emuReadState(oDialog.get_filename().c_str()))
{
break; break;
} }
} }
@ -133,12 +123,9 @@ void Window::vOnFileSave()
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
if (sSaveDir == "") if (sSaveDir == "") {
{
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
} } else {
else
{
oDialog.set_current_folder(sSaveDir); oDialog.set_current_folder(sSaveDir);
oDialog.add_shortcut_folder(sSaveDir); oDialog.add_shortcut_folder(sSaveDir);
} }
@ -156,29 +143,24 @@ void Window::vOnFileSave()
oDialog.add_filter(oSaveFilter); oDialog.add_filter(oSaveFilter);
while (oDialog.run() == Gtk::RESPONSE_OK) while (oDialog.run() == Gtk::RESPONSE_OK) {
{
Glib::ustring sFile = oDialog.get_filename(); Glib::ustring sFile = oDialog.get_filename();
if (! bHasSuffix(sFile, ".sgm", false)) if (!bHasSuffix(sFile, ".sgm", false)) {
{
sFile += ".sgm"; sFile += ".sgm";
} }
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) {
{
Gtk::MessageDialog oConfirmDialog(*this, Gtk::MessageDialog oConfirmDialog(*this,
_("File already exists. Overwrite it?"), _("File already exists. Overwrite it?"),
false, false,
Gtk::MESSAGE_QUESTION, Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_YES_NO); Gtk::BUTTONS_YES_NO);
if (oConfirmDialog.run() != Gtk::RESPONSE_YES) if (oConfirmDialog.run() != Gtk::RESPONSE_YES) {
{
continue; continue;
} }
} }
if (m_stEmulator.emuWriteState(sFile.c_str())) if (m_stEmulator.emuWriteState(sFile.c_str())) {
{
break; break;
} }
} }
@ -189,18 +171,15 @@ void Window::vOnLoadGameMostRecent()
int iMostRecent = -1; int iMostRecent = -1;
time_t uiTimeMax = 0; time_t uiTimeMax = 0;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++) {
{
if (!m_astGameSlot[i].m_bEmpty if (!m_astGameSlot[i].m_bEmpty
&& (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax)) && (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax)) {
{
iMostRecent = i; iMostRecent = i;
uiTimeMax = m_astGameSlot[i].m_uiTime; uiTimeMax = m_astGameSlot[i].m_uiTime;
} }
} }
if (iMostRecent >= 0) if (iMostRecent >= 0) {
{
vOnLoadGame(iMostRecent + 1); vOnLoadGame(iMostRecent + 1);
} }
} }
@ -213,8 +192,7 @@ void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI)
void Window::vOnLoadGame(int _iSlot) void Window::vOnLoadGame(int _iSlot)
{ {
int i = _iSlot - 1; int i = _iSlot - 1;
if (! m_astGameSlot[i].m_bEmpty) if (!m_astGameSlot[i].m_bEmpty) {
{
m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str()); m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str());
m_poFilePauseItem->set_active(false); m_poFilePauseItem->set_active(false);
} }
@ -225,22 +203,17 @@ void Window::vOnSaveGameOldest()
int iOldest = -1; int iOldest = -1;
time_t uiTimeMin = 0; time_t uiTimeMin = 0;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++) {
{
if (!m_astGameSlot[i].m_bEmpty if (!m_astGameSlot[i].m_bEmpty
&& (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin)) && (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin)) {
{
iOldest = i; iOldest = i;
uiTimeMin = m_astGameSlot[i].m_uiTime; uiTimeMin = m_astGameSlot[i].m_uiTime;
} }
} }
if (iOldest >= 0) if (iOldest >= 0) {
{
vOnSaveGame(iOldest + 1); vOnSaveGame(iOldest + 1);
} } else {
else
{
vOnSaveGame(1); vOnSaveGame(1);
} }
} }
@ -255,15 +228,11 @@ void Window::vOnSaveGame(int _iSlot)
void Window::vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI) void Window::vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI)
{ {
m_bPaused = _poCMI->get_active(); m_bPaused = _poCMI->get_active();
if (emulating) if (emulating) {
{ if (m_bPaused) {
if (m_bPaused)
{
vStopEmu(); vStopEmu();
soundPause(); soundPause();
} } else {
else
{
vStartEmu(); vStartEmu();
soundResume(); soundResume();
} }
@ -272,8 +241,7 @@ void Window::vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI)
void Window::vOnFileReset() void Window::vOnFileReset()
{ {
if (emulating) if (emulating) {
{
m_stEmulator.emuReset(); m_stEmulator.emuReset();
m_poFilePauseItem->set_active(false); m_poFilePauseItem->set_active(false);
} }
@ -283,8 +251,7 @@ void Window::vOnRecentFile()
{ {
Glib::ustring sURI = m_poRecentChooserMenu->get_current_uri(); Glib::ustring sURI = m_poRecentChooserMenu->get_current_uri();
if (!sURI.empty()) if (!sURI.empty()) {
{
std::string sFileName = Glib::filename_from_uri(sURI); std::string sFileName = Glib::filename_from_uri(sURI);
bLoadROM(sFileName); bLoadROM(sFileName);
} }
@ -299,12 +266,9 @@ void Window::vOnFileScreenCapture()
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
if (sCaptureDir == "") if (sCaptureDir == "") {
{
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
} } else {
else
{
oDialog.set_current_folder(sCaptureDir); oDialog.set_current_folder(sCaptureDir);
oDialog.add_shortcut_folder(sCaptureDir); oDialog.add_shortcut_folder(sCaptureDir);
} }
@ -322,31 +286,26 @@ void Window::vOnFileScreenCapture()
oDialog.add_filter(oPngFilter); oDialog.add_filter(oPngFilter);
while (oDialog.run() == Gtk::RESPONSE_OK) while (oDialog.run() == Gtk::RESPONSE_OK) {
{
Glib::ustring sFile = oDialog.get_filename(); Glib::ustring sFile = oDialog.get_filename();
Glib::ustring sExt = ".png"; Glib::ustring sExt = ".png";
if (! bHasSuffix(sFile, sExt, false)) if (!bHasSuffix(sFile, sExt, false)) {
{
sFile += sExt; sFile += sExt;
} }
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) {
{
Gtk::MessageDialog oConfirmDialog(*this, Gtk::MessageDialog oConfirmDialog(*this,
_("File already exists. Overwrite it?"), _("File already exists. Overwrite it?"),
false, false,
Gtk::MESSAGE_QUESTION, Gtk::MESSAGE_QUESTION,
Gtk::BUTTONS_YES_NO); Gtk::BUTTONS_YES_NO);
if (oConfirmDialog.run() != Gtk::RESPONSE_YES) if (oConfirmDialog.run() != Gtk::RESPONSE_YES) {
{
continue; continue;
} }
} }
if (m_stEmulator.emuWritePNG(sFile.c_str())) if (m_stEmulator.emuWritePNG(sFile.c_str())) {
{
break; break;
} }
} }
@ -354,8 +313,7 @@ void Window::vOnFileScreenCapture()
void Window::vOnFileClose() void Window::vOnFileClose()
{ {
if (m_eCartridge != CartridgeNone) if (m_eCartridge != CartridgeNone) {
{
soundPause(); soundPause();
vStopEmu(); vStopEmu();
vSetDefaultTitle(); vSetDefaultTitle();
@ -377,8 +335,7 @@ void Window::vOnFileClose()
for (std::list<Gtk::Widget*>::iterator it = m_listSensitiveWhenPlaying.begin(); for (std::list<Gtk::Widget*>::iterator it = m_listSensitiveWhenPlaying.begin();
it != m_listSensitiveWhenPlaying.end(); it != m_listSensitiveWhenPlaying.end();
it++) it++) {
{
(*it)->set_sensitive(false); (*it)->set_sensitive(false);
} }
@ -480,8 +437,7 @@ void Window::vOnGeneralConfigure()
void Window::vOnCheatList() void Window::vOnCheatList()
{ {
if (m_eCartridge == CartridgeGBA) if (m_eCartridge == CartridgeGBA) {
{
std::string sUiFile = sGetUiFilePath("cheatlist.ui"); std::string sUiFile = sGetUiFilePath("cheatlist.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile); Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
@ -491,9 +447,7 @@ void Window::vOnCheatList()
poDialog->vSetWindow(this); poDialog->vSetWindow(this);
poDialog->run(); poDialog->run();
poDialog->hide(); poDialog->hide();
} } else if (m_eCartridge == CartridgeGB) {
else if (m_eCartridge == CartridgeGB)
{
std::string sUiFile = sGetUiFilePath("cheatlist.ui"); std::string sUiFile = sGetUiFilePath("cheatlist.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile); Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
@ -510,8 +464,7 @@ void Window::vOnCheatDisableToggled(Gtk::CheckMenuItem * _poCMI)
{ {
if (m_eCartridge == CartridgeGB) { if (m_eCartridge == CartridgeGB) {
cheatsEnabled = !cheatsEnabled; cheatsEnabled = !cheatsEnabled;
} } else if (m_eCartridge == CartridgeGBA) {
else if (m_eCartridge == CartridgeGBA) {
cheatsEnabled = !cheatsEnabled; cheatsEnabled = !cheatsEnabled;
} }
@ -587,7 +540,8 @@ bool Window::bOnEmuRewind()
} }
} }
bool Window::bOnEmuSaveStateRewind() { bool Window::bOnEmuSaveStateRewind()
{
// check if we're disabled // check if we're disabled
char* psavestate; char* psavestate;
if (m_state_count_max == 0u) { if (m_state_count_max == 0u) {
@ -627,8 +581,7 @@ bool Window::bOnEmuIdle()
bool Window::on_focus_in_event(GdkEventFocus* _pstEvent) bool Window::on_focus_in_event(GdkEventFocus* _pstEvent)
{ {
if (emulating && !m_bPaused) if (emulating && !m_bPaused) {
{
vStartEmu(); vStartEmu();
soundResume(); soundResume();
} }
@ -639,8 +592,7 @@ bool Window::on_focus_out_event(GdkEventFocus * _pstEvent)
{ {
if (emulating if (emulating
&& !m_bPaused && !m_bPaused
&& m_poCoreConfig->oGetKey<bool>("pause_when_inactive")) && m_poCoreConfig->oGetKey<bool>("pause_when_inactive")) {
{
vStopEmu(); vStopEmu();
soundPause(); soundPause();
} }
@ -650,8 +602,7 @@ bool Window::on_focus_out_event(GdkEventFocus * _pstEvent)
bool Window::on_key_press_event(GdkEventKey* _pstEvent) bool Window::on_key_press_event(GdkEventKey* _pstEvent)
{ {
// The menu accelerators are disabled when it is hidden // The menu accelerators are disabled when it is hidden
if (_pstEvent->keyval == GDK_KEY_F11 && !m_poMenuBar->is_visible()) if (_pstEvent->keyval == GDK_KEY_F11 && !m_poMenuBar->is_visible()) {
{
vToggleFullscreen(); vToggleFullscreen();
return true; return true;
} }
@ -659,7 +610,8 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
// Rewind key CTRL+B // Rewind key CTRL+B
if (m_state_count_max > 0u && (_pstEvent->state & GDK_CONTROL_MASK) && _pstEvent->keyval == GDK_KEY_b) { if (m_state_count_max > 0u && (_pstEvent->state & GDK_CONTROL_MASK) && _pstEvent->keyval == GDK_KEY_b) {
// disable saves first and then connect new handler // disable saves first and then connect new handler
if (m_oEmuRewindSig.connected()) m_oEmuRewindSig.disconnect(); if (m_oEmuRewindSig.connected())
m_oEmuRewindSig.disconnect();
m_state_count_max = 0u; m_state_count_max = 0u;
//return this->bOnEmuRewind(); //return this->bOnEmuRewind();
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuRewind), m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuRewind),
@ -685,7 +637,8 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent)
// Rewind key CTRL+B // Rewind key CTRL+B
if (_pstEvent->keyval == GDK_KEY_b /*&& !(_pstEvent->state & GDK_CONTROL_MASK)*/) { if (_pstEvent->keyval == GDK_KEY_b /*&& !(_pstEvent->state & GDK_CONTROL_MASK)*/) {
// connect save handler back // connect save handler back
if (m_oEmuRewindSig.connected()) m_oEmuRewindSig.disconnect(); if (m_oEmuRewindSig.connected())
m_oEmuRewindSig.disconnect();
m_state_count_max = m_poCoreConfig->oGetKey<unsigned short>("rewind_count_max"); m_state_count_max = m_poCoreConfig->oGetKey<unsigned short>("rewind_count_max");
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuSaveStateRewind), m_rewind_interval); m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuSaveStateRewind), m_rewind_interval);
return true; return true;
@ -701,14 +654,12 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent)
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval; event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
inputProcessSDLEvent(event); inputProcessSDLEvent(event);
return Gtk::Window::on_key_release_event(_pstEvent); return Gtk::Window::on_key_release_event(_pstEvent);
} }
bool Window::on_window_state_event(GdkEventWindowState* _pstEvent) bool Window::on_window_state_event(GdkEventWindowState* _pstEvent)
{ {
if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
{
m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN; m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
} }

View File

@ -15,8 +15,8 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "libretro.h"
#include "SoundRetro.h" #include "SoundRetro.h"
#include "libretro.h"
unsigned g_audio_frames; unsigned g_audio_frames;
extern retro_audio_sample_batch_t audio_batch_cb; extern retro_audio_sample_batch_t audio_batch_cb;
@ -33,7 +33,6 @@ void SoundRetro::write(u16 * finalWave, int length)
g_audio_frames += frames; g_audio_frames += frames;
} }
bool SoundRetro::init(long sampleRate) bool SoundRetro::init(long sampleRate)
{ {
g_audio_frames = 0; g_audio_frames = 0;

View File

@ -20,8 +20,7 @@
#include "../common/SoundDriver.h" #include "../common/SoundDriver.h"
class SoundRetro : public SoundDriver class SoundRetro : public SoundDriver {
{
public: public:
SoundRetro(); SoundRetro();
virtual ~SoundRetro(); virtual ~SoundRetro();

View File

@ -2,17 +2,17 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "System.h"
#include "NLS.h" #include "NLS.h"
#include "System.h"
#include "Util.h" #include "Util.h"
#include "common/Port.h"
#include "gba/Flash.h" #include "gba/Flash.h"
#include "gba/GBA.h" #include "gba/GBA.h"
#include "gba/Globals.h" #include "gba/Globals.h"
#include "gba/RTC.h" #include "gba/RTC.h"
#include "common/Port.h"
#include "gba/gbafilter.h"
#include "gb/gbGlobals.h" #include "gb/gbGlobals.h"
#include "gba/gbafilter.h"
#ifndef _MSC_VER #ifndef _MSC_VER
#include <strings.h> #include <strings.h>
@ -60,10 +60,7 @@ bool utilIsGBAImage(const char * file)
const char* p = strrchr(file, '.'); const char* p = strrchr(file, '.');
if (p != NULL) { if (p != NULL) {
if((_stricmp(p, ".agb") == 0) || if ((_stricmp(p, ".agb") == 0) || (_stricmp(p, ".gba") == 0) || (_stricmp(p, ".bin") == 0) || (_stricmp(p, ".elf") == 0))
(_stricmp(p, ".gba") == 0) ||
(_stricmp(p, ".bin") == 0) ||
(_stricmp(p, ".elf") == 0))
return true; return true;
if (_stricmp(p, ".mb") == 0) { if (_stricmp(p, ".mb") == 0) {
cpuIsMultiBoot = true; cpuIsMultiBoot = true;
@ -81,11 +78,7 @@ bool utilIsGBImage(const char * file)
const char* p = strrchr(file, '.'); const char* p = strrchr(file, '.');
if (p != NULL) { if (p != NULL) {
if((_stricmp(p, ".dmg") == 0) || if ((_stricmp(p, ".dmg") == 0) || (_stricmp(p, ".gb") == 0) || (_stricmp(p, ".gbc") == 0) || (_stricmp(p, ".cgb") == 0) || (_stricmp(p, ".sgb") == 0))
(_stricmp(p, ".gb") == 0) ||
(_stricmp(p, ".gbc") == 0) ||
(_stricmp(p, ".cgb") == 0) ||
(_stricmp(p, ".sgb") == 0))
return true; return true;
} }
} }
@ -134,12 +127,10 @@ uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data,
rewind(fp); rewind(fp);
uint8_t* image = data; uint8_t* image = data;
if(image == NULL) if (image == NULL) {
{
//allocate buffer memory if none was passed to the function //allocate buffer memory if none was passed to the function
image = (uint8_t*)malloc(utilGetSize(size)); image = (uint8_t*)malloc(utilGetSize(size));
if(image == NULL) if (image == NULL) {
{
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
"data"); "data");
return NULL; return NULL;
@ -203,27 +194,21 @@ void utilGBAFindSave(const uint8_t *data, const int size)
void utilUpdateSystemColorMaps(bool lcd) void utilUpdateSystemColorMaps(bool lcd)
{ {
switch (systemColorDepth) { switch (systemColorDepth) {
case 16: case 16: {
{
for (int i = 0; i < 0x10000; i++) { for (int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
} }
if (lcd) gbafilter_pal(systemColorMap16, 0x10000); if (lcd)
} gbafilter_pal(systemColorMap16, 0x10000);
break; } break;
case 24: case 24:
case 32: case 32: {
{
for (int i = 0; i < 0x10000; i++) { for (int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
} }
if (lcd) gbafilter_pal32(systemColorMap32, 0x10000); if (lcd)
} gbafilter_pal32(systemColorMap32, 0x10000);
break; } break;
} }
} }
@ -254,8 +239,7 @@ void utilWriteMem(uint8_t *& data, const void *in_data, unsigned size)
void utilWriteDataMem(uint8_t*& data, variable_desc* desc) void utilWriteDataMem(uint8_t*& data, variable_desc* desc)
{ {
while (desc->address) while (desc->address) {
{
utilWriteMem(data, desc->address, desc->size); utilWriteMem(data, desc->address, desc->size);
desc++; desc++;
} }
@ -277,8 +261,7 @@ void utilReadMem(void *buf, const uint8_t *& data, unsigned size)
void utilReadDataMem(const uint8_t*& data, variable_desc* desc) void utilReadDataMem(const uint8_t*& data, variable_desc* desc)
{ {
while (desc->address) while (desc->address) {
{
utilReadMem(desc->address, data, desc->size); utilReadMem(desc->address, data, desc->size);
desc++; desc++;
} }

View File

@ -8,7 +8,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
enum save_type { EEPROM_512B, EEPROM_8K, FLASH_64K, FLASH_128K, SAVE_UNKNOWN }; enum save_type { EEPROM_512B,
EEPROM_8K,
FLASH_64K,
FLASH_128K,
SAVE_UNKNOWN };
static const char* save_type_to_string(enum save_type type) static const char* save_type_to_string(enum save_type type)
{ {
@ -54,8 +58,7 @@ static enum save_type detect_save_type(const uint8_t *data, unsigned size)
if (scan_section(data, 0x20000)) if (scan_section(data, 0x20000))
return FLASH_128K; return FLASH_128K;
if (scan_section(data + 0x20000, 512) && if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512))
!scan_section(data + 0x20000 + 512, 0x20000 - 512))
return EEPROM_512B; return EEPROM_512B;
if (scan_section(data + 0x20000, 0x2000)) if (scan_section(data + 0x20000, 0x2000))
return EEPROM_8K; return EEPROM_8K;

View File

@ -1,27 +1,27 @@
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include "libretro.h"
#include "SoundRetro.h" #include "SoundRetro.h"
#include "libretro.h"
#include "../Util.h"
#include "../System.h" #include "../System.h"
#include "../Util.h"
#include "../apu/Blip_Buffer.h"
#include "../apu/Gb_Apu.h"
#include "../apu/Gb_Oscs.h"
#include "../common/Port.h" #include "../common/Port.h"
#include "../common/Types.h" #include "../common/Types.h"
#include "../gba/RTC.h"
#include "../gba/GBAGfx.h"
#include "../gba/bios.h"
#include "../gba/Flash.h"
#include "../gba/EEprom.h"
#include "../gba/Sound.h"
#include "../apu/Blip_Buffer.h"
#include "../apu/Gb_Oscs.h"
#include "../apu/Gb_Apu.h"
#include "../gba/Globals.h"
#include "../gba/Cheats.h" #include "../gba/Cheats.h"
#include "../gba/EEprom.h"
#include "../gba/Flash.h"
#include "../gba/GBAGfx.h"
#include "../gba/Globals.h"
#include "../gba/RTC.h"
#include "../gba/Sound.h"
#include "../gba/bios.h"
#define RETRO_DEVICE_GBA RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0) #define RETRO_DEVICE_GBA RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
#define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1) #define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
@ -93,36 +93,25 @@ static bool scan_area(const uint8_t *data, unsigned size)
static void adjust_save_ram() static void adjust_save_ram()
{ {
if (scan_area(libretro_save_buf, 512) && if (scan_area(libretro_save_buf, 512) && !scan_area(libretro_save_buf + 512, sizeof(libretro_save_buf) - 512)) {
!scan_area(libretro_save_buf + 512, sizeof(libretro_save_buf) - 512))
{
libretro_save_size = 512; libretro_save_size = 512;
if (log_cb) if (log_cb)
log_cb(RETRO_LOG_INFO, "Detecting EEprom 8kbit\n"); log_cb(RETRO_LOG_INFO, "Detecting EEprom 8kbit\n");
} } else if (scan_area(libretro_save_buf, 0x2000) && !scan_area(libretro_save_buf + 0x2000, sizeof(libretro_save_buf) - 0x2000)) {
else if (scan_area(libretro_save_buf, 0x2000) &&
!scan_area(libretro_save_buf + 0x2000, sizeof(libretro_save_buf) - 0x2000))
{
libretro_save_size = 0x2000; libretro_save_size = 0x2000;
if (log_cb) if (log_cb)
log_cb(RETRO_LOG_INFO, "Detecting EEprom 64kbit\n"); log_cb(RETRO_LOG_INFO, "Detecting EEprom 64kbit\n");
} }
else if (scan_area(libretro_save_buf, 0x10000) && else if (scan_area(libretro_save_buf, 0x10000) && !scan_area(libretro_save_buf + 0x10000, sizeof(libretro_save_buf) - 0x10000)) {
!scan_area(libretro_save_buf + 0x10000, sizeof(libretro_save_buf) - 0x10000))
{
libretro_save_size = 0x10000; libretro_save_size = 0x10000;
if (log_cb) if (log_cb)
log_cb(RETRO_LOG_INFO, "Detecting Flash 512kbit\n"); log_cb(RETRO_LOG_INFO, "Detecting Flash 512kbit\n");
} } else if (scan_area(libretro_save_buf, 0x20000) && !scan_area(libretro_save_buf + 0x20000, sizeof(libretro_save_buf) - 0x20000)) {
else if (scan_area(libretro_save_buf, 0x20000) &&
!scan_area(libretro_save_buf + 0x20000, sizeof(libretro_save_buf) - 0x20000))
{
libretro_save_size = 0x20000; libretro_save_size = 0x20000;
if (log_cb) if (log_cb)
log_cb(RETRO_LOG_INFO, "Detecting Flash 1Mbit\n"); log_cb(RETRO_LOG_INFO, "Detecting Flash 1Mbit\n");
} } else if (log_cb)
else if (log_cb)
log_cb(RETRO_LOG_INFO, "Did not detect any particular SRAM type.\n"); log_cb(RETRO_LOG_INFO, "Did not detect any particular SRAM type.\n");
if (libretro_save_size == 512 || libretro_save_size == 0x2000) if (libretro_save_size == 512 || libretro_save_size == 0x2000)
@ -131,7 +120,6 @@ static void adjust_save_ram()
flashSaveMemory = libretro_save_buf; flashSaveMemory = libretro_save_buf;
} }
unsigned retro_api_version(void) unsigned retro_api_version(void)
{ {
return RETRO_API_VERSION; return RETRO_API_VERSION;
@ -143,7 +131,8 @@ void retro_set_video_refresh(retro_video_refresh_t cb)
} }
void retro_set_audio_sample(retro_audio_sample_t cb) void retro_set_audio_sample(retro_audio_sample_t cb)
{ } {
}
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
{ {
@ -163,8 +152,7 @@ void retro_set_input_state(retro_input_state_t cb)
void retro_set_controller_port_device(unsigned port, unsigned device) void retro_set_controller_port_device(unsigned port, unsigned device)
{ {
log_cb(RETRO_LOG_INFO, "Controller %d'\n", device); log_cb(RETRO_LOG_INFO, "Controller %d'\n", device);
switch(device) switch (device) {
{
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
case RETRO_DEVICE_GBA: case RETRO_DEVICE_GBA:
@ -189,7 +177,6 @@ void retro_set_environment(retro_environment_t cb)
struct retro_variable variables[] = { struct retro_variable variables[] = {
{ NULL, NULL }, { NULL, NULL },
}; };
@ -201,8 +188,6 @@ void retro_set_environment(retro_environment_t cb)
static const struct retro_controller_info ports[] = { { port_1, 4 }, { 0, 0 } }; static const struct retro_controller_info ports[] = { { port_1, 4 }, { 0, 0 } };
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports); cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
} }
@ -383,18 +368,15 @@ static void load_image_preferences (void)
bool found = false; bool found = false;
int found_no = 0; int found_no = 0;
for(int i = 0; i < 256; i++) for (int i = 0; i < 256; i++) {
{ if (!strcmp(gbaover[i].romid, buffer)) {
if(!strcmp(gbaover[i].romid, buffer))
{
found = true; found = true;
found_no = i; found_no = i;
break; break;
} }
} }
if(found) if (found) {
{
if (log_cb) if (log_cb)
log_cb(RETRO_LOG_INFO, "Found ROM in vba-over list.\n"); log_cb(RETRO_LOG_INFO, "Found ROM in vba-over list.\n");
@ -410,8 +392,7 @@ static void load_image_preferences (void)
mirroringEnable = gbaover[found_no].mirroringEnabled; mirroringEnable = gbaover[found_no].mirroringEnabled;
} }
if (log_cb) if (log_cb) {
{
log_cb(RETRO_LOG_INFO, "RTC = %d.\n", enableRtc); log_cb(RETRO_LOG_INFO, "RTC = %d.\n", enableRtc);
log_cb(RETRO_LOG_INFO, "flashSize = %d.\n", flashSize); log_cb(RETRO_LOG_INFO, "flashSize = %d.\n", flashSize);
log_cb(RETRO_LOG_INFO, "cpuSaveType = %d.\n", cpuSaveType); log_cb(RETRO_LOG_INFO, "cpuSaveType = %d.\n", cpuSaveType);
@ -437,7 +418,6 @@ static void gba_init(void)
systemBlueShift = 3; systemBlueShift = 3;
#endif #endif
utilUpdateSystemColorMaps(false); utilUpdateSystemColorMaps(false);
if (cpuSaveType == 0) if (cpuSaveType == 0)
@ -525,7 +505,6 @@ static unsigned has_frame;
static void update_variables(void) static void update_variables(void)
{ {
} }
#ifdef FINAL_VERSION #ifdef FINAL_VERSION
@ -542,7 +521,6 @@ void retro_run(void)
poll_cb(); poll_cb();
has_frame = 0; has_frame = 0;
do { do {
@ -639,28 +617,57 @@ bool retro_load_game(const struct retro_game_info *game)
struct retro_memory_descriptor desc[9]; struct retro_memory_descriptor desc[9];
memset(desc, 0, sizeof(desc)); memset(desc, 0, sizeof(desc));
desc[0].start=0x03000000; desc[0].select=0xFF000000; desc[0].len=0x8000; desc[0].ptr=internalRAM;//fast WRAM desc[0].start = 0x03000000;
desc[1].start=0x02000000; desc[1].select=0xFF000000; desc[1].len=0x40000; desc[1].ptr=workRAM;//slow WRAM desc[0].select = 0xFF000000;
desc[2].start=0x0E000000; desc[2].select=0xFF000000; desc[2].len=libretro_save_size; desc[2].ptr=flashSaveMemory;//SRAM desc[0].len = 0x8000;
desc[3].start=0x08000000; desc[3].select=0xFC000000; desc[3].len=0x2000000; desc[3].ptr=rom;//ROM, parts 1 and 2 desc[0].ptr = internalRAM; //fast WRAM
desc[1].start = 0x02000000;
desc[1].select = 0xFF000000;
desc[1].len = 0x40000;
desc[1].ptr = workRAM; //slow WRAM
desc[2].start = 0x0E000000;
desc[2].select = 0xFF000000;
desc[2].len = libretro_save_size;
desc[2].ptr = flashSaveMemory; //SRAM
desc[3].start = 0x08000000;
desc[3].select = 0xFC000000;
desc[3].len = 0x2000000;
desc[3].ptr = rom; //ROM, parts 1 and 2
desc[3].flags = RETRO_MEMDESC_CONST; //we need two mappings since its size is not a power of 2 desc[3].flags = RETRO_MEMDESC_CONST; //we need two mappings since its size is not a power of 2
desc[4].start=0x0C000000; desc[4].select=0xFE000000; desc[4].len=0x2000000; desc[4].ptr=rom;//ROM part 3 desc[4].start = 0x0C000000;
desc[4].select = 0xFE000000;
desc[4].len = 0x2000000;
desc[4].ptr = rom; //ROM part 3
desc[4].flags = RETRO_MEMDESC_CONST; desc[4].flags = RETRO_MEMDESC_CONST;
desc[5].start=0x00000000; desc[5].select=0xFF000000; desc[5].len=0x4000; desc[5].ptr=bios;//BIOS desc[5].start = 0x00000000;
desc[5].select = 0xFF000000;
desc[5].len = 0x4000;
desc[5].ptr = bios; //BIOS
desc[5].flags = RETRO_MEMDESC_CONST; desc[5].flags = RETRO_MEMDESC_CONST;
desc[6].start=0x06000000; desc[6].select=0xFF000000; desc[6].len=0x18000; desc[6].ptr=vram;//VRAM desc[6].start = 0x06000000;
desc[7].start=0x07000000; desc[7].select=0xFF000000; desc[7].len=0x400; desc[7].ptr=paletteRAM;//palettes desc[6].select = 0xFF000000;
desc[8].start=0x05000000; desc[8].select=0xFF000000; desc[8].len=0x400; desc[8].ptr=oam;//OAM desc[6].len = 0x18000;
desc[6].ptr = vram; //VRAM
desc[7].start = 0x07000000;
desc[7].select = 0xFF000000;
desc[7].len = 0x400;
desc[7].ptr = paletteRAM; //palettes
desc[8].start = 0x05000000;
desc[8].select = 0xFF000000;
desc[8].len = 0x400;
desc[8].ptr = oam; //OAM
struct retro_memory_map retromap = { desc, sizeof(desc) / sizeof(*desc) }; struct retro_memory_map retromap = { desc, sizeof(desc) / sizeof(*desc) };
if (ret) environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap); if (ret)
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap);
return ret; return ret;
} }
bool retro_load_game_special( bool retro_load_game_special(
unsigned game_type, unsigned game_type,
const struct retro_game_info *info, size_t num_info const struct retro_game_info* info, size_t num_info)
) {
{ return false; } return false;
}
extern unsigned g_audio_frames; extern unsigned g_audio_frames;
static unsigned g_video_frames; static unsigned g_video_frames;
@ -725,7 +732,6 @@ void systemMessage(int, const char* fmt, ...)
va_end(ap); va_end(ap);
} }
int systemGetSensorX(void) int systemGetSensorX(void)
{ {
return 0; return 0;
@ -748,8 +754,7 @@ u32 systemReadJoypad(int which)
u32 J = 0; u32 J = 0;
for (unsigned i = 0; i < 10; i++) for (unsigned i = 0; i < 10; i++) {
{
if (controller_layout[0] == 1) if (controller_layout[0] == 1)
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds1[i]) << i; J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds1[i]) << i;
else if (controller_layout[0] == 2) else if (controller_layout[0] == 2)

View File

@ -61,20 +61,27 @@ static const unsigned long crc_table[256] = {
}; };
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); #define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf); #define DO2_CRC32(buf) \
#define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf); DO1_CRC32(buf); \
#define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf); DO1_CRC32(buf);
#define DO4_CRC32(buf) \
DO2_CRC32(buf); \
DO2_CRC32(buf);
#define DO8_CRC32(buf) \
DO4_CRC32(buf); \
DO4_CRC32(buf);
unsigned long crc32(unsigned long crc, const unsigned char* buf, unsigned int len) unsigned long crc32(unsigned long crc, const unsigned char* buf, unsigned int len)
{ {
if (buf == 0) return 0L; if (buf == 0)
return 0L;
crc = crc ^ 0xffffffffL; crc = crc ^ 0xffffffffL;
while (len >= 8) while (len >= 8) {
{
DO8_CRC32(buf); DO8_CRC32(buf);
len -= 8; len -= 8;
} }
if (len) do { if (len)
do {
DO1_CRC32(buf); DO1_CRC32(buf);
} while (--len); } while (--len);
return crc ^ 0xffffffffL; return crc ^ 0xffffffffL;
@ -85,4 +92,3 @@ unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int le
#endif #endif
#endif #endif

View File

@ -22,19 +22,19 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cmath> #include <cmath>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenGL/glu.h>
#include <OpenGL/glext.h> #include <OpenGL/glext.h>
#include <OpenGL/glu.h>
#else #else
#include <GL/glu.h>
#include <GL/glext.h> #include <GL/glext.h>
#include <GL/glu.h>
#endif #endif
#include <time.h> #include <time.h>
@ -44,24 +44,24 @@
#include <SDL.h> #include <SDL.h>
#include "../common/Patch.h" #include "../Util.h"
#include "../common/ConfigManager.h" #include "../common/ConfigManager.h"
#include "../gba/GBA.h" #include "../common/Patch.h"
#include "../gba/agbprint.h" #include "../gb/gb.h"
#include "../gba/Flash.h" #include "../gb/gbCheats.h"
#include "../gb/gbGlobals.h"
#include "../gb/gbSound.h"
#include "../gba/Cheats.h" #include "../gba/Cheats.h"
#include "../gba/Flash.h"
#include "../gba/GBA.h"
#include "../gba/RTC.h" #include "../gba/RTC.h"
#include "../gba/Sound.h" #include "../gba/Sound.h"
#include "../gb/gb.h" #include "../gba/agbprint.h"
#include "../gb/gbGlobals.h"
#include "../gb/gbCheats.h"
#include "../gb/gbSound.h"
#include "../Util.h"
#include "filters.h"
#include "text.h"
#include "inputSDL.h"
#include "../common/SoundSDL.h" #include "../common/SoundSDL.h"
#include "filters.h"
#include "inputSDL.h"
#include "text.h"
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
@ -82,8 +82,8 @@
#endif // ! __GNUC__ #endif // ! __GNUC__
#if WITH_LIRC #if WITH_LIRC
#include <sys/poll.h>
#include <lirc/lirc_client.h> #include <lirc/lirc_client.h>
#include <sys/poll.h>
#endif #endif
extern void remoteInit(); extern void remoteInit();
@ -174,8 +174,17 @@ extern int autoFireMaxCount;
#define REWIND_SIZE 400000 #define REWIND_SIZE 400000
enum VIDEO_SIZE { enum VIDEO_SIZE {
VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X, VIDEO_5X, VIDEO_6X, VIDEO_1X,
VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_1024x768, VIDEO_1280x1024, VIDEO_2X,
VIDEO_3X,
VIDEO_4X,
VIDEO_5X,
VIDEO_6X,
VIDEO_320x240,
VIDEO_640x480,
VIDEO_800x600,
VIDEO_1024x768,
VIDEO_1280x1024,
VIDEO_OTHER VIDEO_OTHER
}; };
@ -205,8 +214,10 @@ static void sdlChangeVolume(float d)
float oldVolume = soundGetVolume(); float oldVolume = soundGetVolume();
float newVolume = oldVolume + d; float newVolume = oldVolume + d;
if (newVolume < 0.0) newVolume = 0.0; if (newVolume < 0.0)
if (newVolume > SOUND_MAX_VOLUME) newVolume = SOUND_MAX_VOLUME; newVolume = 0.0;
if (newVolume > SOUND_MAX_VOLUME)
newVolume = SOUND_MAX_VOLUME;
if (fabs(newVolume - oldVolume) > 0.001) { if (fabs(newVolume - oldVolume) > 0.001) {
char tmp[32]; char tmp[32];
@ -265,7 +276,6 @@ void StopLirc(void)
} }
#endif #endif
#ifdef __MSC__ #ifdef __MSC__
#define stat _stat #define stat _stat
#define S_IFDIR _S_IFDIR #define S_IFDIR _S_IFDIR
@ -273,8 +283,7 @@ void StopLirc(void)
void sdlCheckDirectory(const char* dir) void sdlCheckDirectory(const char* dir)
{ {
if (!dir || !dir[0]) if (!dir || !dir[0]) {
{
return; return;
} }
@ -284,8 +293,7 @@ void sdlCheckDirectory(const char *dir)
char* p = (char*)dir + len - 1; char* p = (char*)dir + len - 1;
if(*p == '/' || if (*p == '/' || *p == '\\')
*p == '\\')
*p = 0; *p = 0;
if (stat(dir, &buf) == 0) { if (stat(dir, &buf) == 0) {
@ -306,8 +314,7 @@ char *sdlGetFilename(char *name)
char* p = name + len - 1; char* p = name + len - 1;
while (true) { while (true) {
if(*p == '/' || if (*p == '/' || *p == '\\') {
*p == '\\') {
p++; p++;
break; break;
} }
@ -368,8 +375,7 @@ FILE *sdlFindFile(const char *name)
return f; return f;
} }
if (!strchr(home, '/') && if (!strchr(home, '/') && !strchr(home, '\\')) {
!strchr(home, '\\')) {
char* path = getenv("PATH"); char* path = getenv("PATH");
if (path != NULL) { if (path != NULL) {
@ -662,13 +668,10 @@ void sdlWriteState(int num)
emulator.emuWriteState(stateName); emulator.emuWriteState(stateName);
// now we reuse the stateName buffer - 2048 bytes fit in a lot // now we reuse the stateName buffer - 2048 bytes fit in a lot
if (num == SLOT_POS_LOAD_BACKUP) if (num == SLOT_POS_LOAD_BACKUP) {
{
sprintf(stateName, "Current state backed up to %d", num + 1); sprintf(stateName, "Current state backed up to %d", num + 1);
systemScreenMessage(stateName); systemScreenMessage(stateName);
} } else if (num >= 0) {
else if (num>=0)
{
sprintf(stateName, "Wrote state %d", num + 1); sprintf(stateName, "Wrote state %d", num + 1);
systemScreenMessage(stateName); systemScreenMessage(stateName);
} }
@ -684,16 +687,11 @@ void sdlReadState(int num)
if (emulator.emuReadState) if (emulator.emuReadState)
emulator.emuReadState(stateName); emulator.emuReadState(stateName);
if (num == SLOT_POS_LOAD_BACKUP) if (num == SLOT_POS_LOAD_BACKUP) {
{
sprintf(stateName, "Last load UNDONE"); sprintf(stateName, "Last load UNDONE");
} else } else if (num == SLOT_POS_SAVE_BACKUP) {
if (num == SLOT_POS_SAVE_BACKUP)
{
sprintf(stateName, "Last save UNDONE"); sprintf(stateName, "Last save UNDONE");
} } else {
else
{
sprintf(stateName, "Loaded state %d", num + 1); sprintf(stateName, "Loaded state %d", num + 1);
} }
systemScreenMessage(stateName); systemScreenMessage(stateName);
@ -780,14 +778,16 @@ void sdlReadBattery()
systemScreenMessage("Loaded battery"); systemScreenMessage("Loaded battery");
} }
void sdlReadDesktopVideoMode() { void sdlReadDesktopVideoMode()
{
SDL_DisplayMode dm; SDL_DisplayMode dm;
SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(window), &dm); SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(window), &dm);
desktopWidth = dm.w; desktopWidth = dm.w;
desktopHeight = dm.h; desktopHeight = dm.h;
} }
static void sdlResizeVideo() { static void sdlResizeVideo()
{
filter_enlarge = getFilterEnlargeFactor(filter); filter_enlarge = getFilterEnlargeFactor(filter);
destWidth = filter_enlarge * sizeX; destWidth = filter_enlarge * sizeX;
@ -799,8 +799,10 @@ static void sdlResizeVideo() {
sdlOpenGLVideoResize(); sdlOpenGLVideoResize();
} }
if (surface) SDL_FreeSurface(surface); if (surface)
if (texture) SDL_DestroyTexture(texture); SDL_FreeSurface(surface);
if (texture)
SDL_DestroyTexture(texture);
if (!openGL) { if (!openGL) {
surface = SDL_CreateRGBSurface(0, destWidth, destHeight, 32, surface = SDL_CreateRGBSurface(0, destWidth, destHeight, 32,
@ -818,7 +820,8 @@ static void sdlResizeVideo() {
} }
} }
void sdlInitVideo() { void sdlInitVideo()
{
int flags; int flags;
int screenWidth; int screenWidth;
int screenHeight; int screenHeight;
@ -837,8 +840,10 @@ void sdlInitVideo() {
screenWidth = destWidth; screenWidth = destWidth;
screenHeight = destHeight; screenHeight = destHeight;
if (window) SDL_DestroyWindow(window); if (window)
if (renderer) SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window);
if (renderer)
SDL_DestroyRenderer(renderer);
window = SDL_CreateWindow("VBA-M", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window = SDL_CreateWindow("VBA-M", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
screenWidth, screenHeight, flags); screenWidth, screenHeight, flags);
if (!openGL) { if (!openGL) {
@ -971,7 +976,6 @@ void sdlInitVideo() {
#define MOD_NOALT (KMOD_CTRL | KMOD_SHIFT | KMOD_META) #define MOD_NOALT (KMOD_CTRL | KMOD_SHIFT | KMOD_META)
#define MOD_NOSHIFT (KMOD_CTRL | KMOD_ALT | KMOD_META) #define MOD_NOSHIFT (KMOD_CTRL | KMOD_ALT | KMOD_META)
/* /*
* 04.02.2008 (xKiv): factored out from sdlPollEvents * 04.02.2008 (xKiv): factored out from sdlPollEvents
* *
@ -979,13 +983,11 @@ void sdlInitVideo() {
void change_rewind(int howmuch) void change_rewind(int howmuch)
{ {
if (emulating && emulator.emuReadMemState && rewindMemory if (emulating && emulator.emuReadMemState && rewindMemory
&& rewindCount && rewindCount) {
) {
rewindPos = (rewindPos + rewindCount + howmuch) % rewindCount; rewindPos = (rewindPos + rewindCount + howmuch) % rewindCount;
emulator.emuReadMemState( emulator.emuReadMemState(
&rewindMemory[REWIND_SIZE * rewindPos], &rewindMemory[REWIND_SIZE * rewindPos],
REWIND_SIZE REWIND_SIZE);
);
rewindCounter = 0; rewindCounter = 0;
{ {
char rewindMsgBuffer[50]; char rewindMsgBuffer[50];
@ -1015,23 +1017,19 @@ static void sdlHandleSavestateKey(int num, int shifted)
// 1: save // 1: save
int backuping = 1; // controls whether we are doing savestate backups int backuping = 1; // controls whether we are doing savestate backups
if ( sdlSaveKeysSwitch == 2 ) if (sdlSaveKeysSwitch == 2) {
{
// ignore "shifted" // ignore "shifted"
switch (num) switch (num) {
{
// nb.: saveSlotPosition is base 0, but to the user, we show base 1 indexes (F## numbers)! // nb.: saveSlotPosition is base 0, but to the user, we show base 1 indexes (F## numbers)!
case 4: case 4:
if (saveSlotPosition > 0) if (saveSlotPosition > 0) {
{
saveSlotPosition--; saveSlotPosition--;
fprintf(stdout, "Changed savestate slot to %d.\n", saveSlotPosition + 1); fprintf(stdout, "Changed savestate slot to %d.\n", saveSlotPosition + 1);
} else } else
fprintf(stderr, "Can't decrease slotnumber below 1.\n"); fprintf(stderr, "Can't decrease slotnumber below 1.\n");
return; // handled return; // handled
case 5: case 5:
if (saveSlotPosition < 7) if (saveSlotPosition < 7) {
{
saveSlotPosition++; saveSlotPosition++;
fprintf(stdout, "Changed savestate slot to %d.\n", saveSlotPosition + 1); fprintf(stdout, "Changed savestate slot to %d.\n", saveSlotPosition + 1);
} else } else
@ -1053,41 +1051,38 @@ static void sdlHandleSavestateKey(int num, int shifted)
{ {
if (shifted) if (shifted)
action = 1; // save action = 1; // save
else action = 0; // load else
action = 0; // load
saveSlotPosition = num; saveSlotPosition = num;
} }
if (sdlSaveKeysSwitch == 1) /* "xKiv" VBA: shifted is load */ if (sdlSaveKeysSwitch == 1) /* "xKiv" VBA: shifted is load */
{ {
if (!shifted) if (!shifted)
action = 1; // save action = 1; // save
else action = 0; // load else
action = 0; // load
saveSlotPosition = num; saveSlotPosition = num;
} }
if (action < 0 || action > 1) if (action < 0 || action > 1) {
{
fprintf( fprintf(
stderr, stderr,
"sdlHandleSavestateKey(%d,%d), mode %d: unexpected action %d.\n", "sdlHandleSavestateKey(%d,%d), mode %d: unexpected action %d.\n",
num, num,
shifted, shifted,
sdlSaveKeysSwitch, sdlSaveKeysSwitch,
action action);
);
} }
if (action) if (action) { /* save */
{ /* save */ if (backuping) {
if (backuping)
{
sdlWriteState(-1); // save to a special slot sdlWriteState(-1); // save to a special slot
sdlWriteBackupStateExchange(-1, saveSlotPosition, SLOT_POS_SAVE_BACKUP); // F10 sdlWriteBackupStateExchange(-1, saveSlotPosition, SLOT_POS_SAVE_BACKUP); // F10
} else { } else {
sdlWriteState(saveSlotPosition); sdlWriteState(saveSlotPosition);
} }
} else { /* load */ } else { /* load */
if (backuping) if (backuping) {
{
/* first back up where we are now */ /* first back up where we are now */
sdlWriteState(SLOT_POS_LOAD_BACKUP); // F9 sdlWriteState(SLOT_POS_LOAD_BACKUP); // F9
} }
@ -1185,8 +1180,7 @@ void sdlPollEvents()
case SDL_KEYUP: case SDL_KEYUP:
switch (event.key.keysym.sym) { switch (event.key.keysym.sym) {
case SDLK_r: case SDLK_r:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
if (emulating) { if (emulating) {
emulator.emuReset(); emulator.emuReset();
@ -1195,37 +1189,30 @@ void sdlPollEvents()
} }
break; break;
case SDLK_b: case SDLK_b:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
(event.key.keysym.mod & KMOD_CTRL))
change_rewind(-1); change_rewind(-1);
break; break;
case SDLK_v: case SDLK_v:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
(event.key.keysym.mod & KMOD_CTRL))
change_rewind(+1); change_rewind(+1);
break; break;
case SDLK_h: case SDLK_h:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
(event.key.keysym.mod & KMOD_CTRL))
change_rewind(0); change_rewind(0);
break; break;
case SDLK_j: case SDLK_j:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
(event.key.keysym.mod & KMOD_CTRL))
change_rewind((rewindTopPos - rewindPos) * ((rewindTopPos > rewindPos) ? +1 : -1)); change_rewind((rewindTopPos - rewindPos) * ((rewindTopPos > rewindPos) ? +1 : -1));
break; break;
case SDLK_e: case SDLK_e:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
cheatsEnabled = !cheatsEnabled; cheatsEnabled = !cheatsEnabled;
systemConsoleMessage(cheatsEnabled ? "Cheats on" : "Cheats off"); systemConsoleMessage(cheatsEnabled ? "Cheats on" : "Cheats off");
} }
break; break;
case SDLK_s: case SDLK_s:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)
) {
if (sdlSoundToggledOff) { // was off if (sdlSoundToggledOff) { // was off
// restore saved state // restore saved state
soundSetEnable(sdlSoundToggledOff); soundSetEnable(sdlSoundToggledOff);
@ -1288,8 +1275,7 @@ void sdlPollEvents()
break; break;
case SDLK_p: case SDLK_p:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
paused = !paused; paused = !paused;
if (paused) if (paused)
soundPause(); soundPause();
@ -1304,12 +1290,10 @@ void sdlPollEvents()
emulating = 0; emulating = 0;
break; break;
case SDLK_f: case SDLK_f:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
fullScreen = !fullScreen; fullScreen = !fullScreen;
SDL_SetWindowFullscreen(window, fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); SDL_SetWindowFullscreen(window, fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
if (openGL) if (openGL) {
{
if (fullScreen) if (fullScreen)
sdlOpenGLScaleWithAspect(desktopWidth, desktopHeight); sdlOpenGLScaleWithAspect(desktopWidth, desktopHeight);
else else
@ -1319,11 +1303,9 @@ void sdlPollEvents()
} }
break; break;
case SDLK_g: case SDLK_g:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
filterFunction = 0; filterFunction = 0;
while (!filterFunction) while (!filterFunction) {
{
filter = (Filter)((filter + 1) % kInvalidFilter); filter = (Filter)((filter + 1) % kInvalidFilter);
filterFunction = initFilter(filter, systemColorDepth, sizeX); filterFunction = initFilter(filter, systemColorDepth, sizeX);
} }
@ -1353,8 +1335,7 @@ void sdlPollEvents()
case SDLK_F6: case SDLK_F6:
case SDLK_F7: case SDLK_F7:
case SDLK_F8: case SDLK_F8:
if(!(event.key.keysym.mod & MOD_NOSHIFT) && if (!(event.key.keysym.mod & MOD_NOSHIFT) && (event.key.keysym.mod & KMOD_SHIFT)) {
(event.key.keysym.mod & KMOD_SHIFT)) {
sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 1); // with SHIFT sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 1); // with SHIFT
} else if (!(event.key.keysym.mod & MOD_KEYS)) { } else if (!(event.key.keysym.mod & MOD_KEYS)) {
sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 0); // without SHIFT sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 0); // without SHIFT
@ -1379,15 +1360,12 @@ void sdlPollEvents()
case SDLK_2: case SDLK_2:
case SDLK_3: case SDLK_3:
case SDLK_4: case SDLK_4:
if(!(event.key.keysym.mod & MOD_NOALT) && if (!(event.key.keysym.mod & MOD_NOALT) && (event.key.keysym.mod & KMOD_ALT)) {
(event.key.keysym.mod & KMOD_ALT)) { const char* disableMessages[4] = { "autofire A disabled",
const char *disableMessages[4] =
{ "autofire A disabled",
"autofire B disabled", "autofire B disabled",
"autofire R disabled", "autofire R disabled",
"autofire L disabled" }; "autofire L disabled" };
const char *enableMessages[4] = const char* enableMessages[4] = { "autofire A",
{ "autofire A",
"autofire B", "autofire B",
"autofire R", "autofire R",
"autofire L" }; "autofire L" };
@ -1407,8 +1385,7 @@ void sdlPollEvents()
} else { } else {
systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]); systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]);
} }
} else if(!(event.key.keysym.mod & MOD_NOCTRL) && } else if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
int mask = 0x0100 << (event.key.keysym.sym - SDLK_1); int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
layerSettings ^= mask; layerSettings ^= mask;
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
@ -1419,16 +1396,14 @@ void sdlPollEvents()
case SDLK_6: case SDLK_6:
case SDLK_7: case SDLK_7:
case SDLK_8: case SDLK_8:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
int mask = 0x0100 << (event.key.keysym.sym - SDLK_1); int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
layerSettings ^= mask; layerSettings ^= mask;
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
} }
break; break;
case SDLK_n: case SDLK_n:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
(event.key.keysym.mod & KMOD_CTRL)) {
if (paused) if (paused)
paused = false; paused = false;
pauseNextFrame = true; pauseNextFrame = true;
@ -1476,7 +1451,8 @@ void lircCheckInput(void)
soundPause(); soundPause();
else else
soundResume(); soundResume();
if(paused) wasPaused = true; if (paused)
wasPaused = true;
systemConsoleMessage(paused ? "Pause on" : "Pause off"); systemConsoleMessage(paused ? "Pause on" : "Pause off");
systemScreenMessage(paused ? "Pause on" : "Pause off"); systemScreenMessage(paused ? "Pause on" : "Pause off");
} else if (strcmp(CmdLIRC, "RESET") == 0) { } else if (strcmp(CmdLIRC, "RESET") == 0) {
@ -1630,13 +1606,11 @@ void handleRewinds()
long resize; long resize;
if ( if (
emulator.emuWriteMemState emulator.emuWriteMemState
&& && emulator.emuWriteMemState(
emulator.emuWriteMemState(
&rewindMemory[curSavePos * REWIND_SIZE], &rewindMemory[curSavePos * REWIND_SIZE],
REWIND_SIZE, /* available*/ REWIND_SIZE, /* available*/
resize /* actual size */ resize /* actual size */
) )) {
) {
char rewMsgBuf[100]; char rewMsgBuf[100];
sprintf(rewMsgBuf, "Remembered rewind %1d (of %1d), serial %d.", curSavePos + 1, rewindCount, rewindSerial); sprintf(rewMsgBuf, "Remembered rewind %1d (of %1d), serial %d.", curSavePos + 1, rewindCount, rewindSerial);
rewMsgBuf[99] = 0; rewMsgBuf[99] = 0;
@ -1747,7 +1721,6 @@ int main(int argc, char **argv)
sdlSaveKeysSwitch = (ReadPrefHex("saveKeysSwitch")); sdlSaveKeysSwitch = (ReadPrefHex("saveKeysSwitch"));
sdlOpenglScale = (ReadPrefHex("openGLscale")); sdlOpenglScale = (ReadPrefHex("openGLscale"));
if (optPrintUsage) { if (optPrintUsage) {
usage(argv[0]); usage(argv[0]);
exit(-1); exit(-1);
@ -1770,8 +1743,7 @@ int main(int argc, char **argv)
if (p) if (p)
*p = 0; *p = 0;
if (autoPatch && patchNum == 0) if (autoPatch && patchNum == 0) {
{
char* tmp; char* tmp;
// no patch given yet - look for ROMBASENAME.ips // no patch given yet - look for ROMBASENAME.ips
tmp = (char*)malloc(strlen(filename) + 4 + 1); tmp = (char*)malloc(strlen(filename) + 4 + 1);
@ -1902,8 +1874,7 @@ int main(int argc, char **argv)
sizeX = 240; sizeX = 240;
sizeY = 160; sizeY = 160;
systemFrameSkip = frameSkip; systemFrameSkip = frameSkip;
} } else if (cartridgeType == IMAGE_GB) {
else if (cartridgeType == IMAGE_GB) {
if (gbBorderOn) { if (gbBorderOn) {
sizeX = 256; sizeX = 256;
sizeY = 224; sizeY = 224;
@ -1936,8 +1907,7 @@ int main(int argc, char **argv)
if (systemColorDepth == 15) if (systemColorDepth == 15)
systemColorDepth = 16; systemColorDepth = 16;
if(systemColorDepth != 16 && systemColorDepth != 24 && if (systemColorDepth != 16 && systemColorDepth != 24 && systemColorDepth != 32) {
systemColorDepth != 32) {
fprintf(stderr, "Unsupported color depth '%d'.\nOnly 16, 24 and 32 bit color depths are supported\n", systemColorDepth); fprintf(stderr, "Unsupported color depth '%d'.\nOnly 16, 24 and 32 bit color depths are supported\n", systemColorDepth);
exit(-1); exit(-1);
} }
@ -1981,7 +1951,6 @@ int main(int argc, char **argv)
} }
} }
while (emulating) { while (emulating) {
if (!paused && active) { if (!paused && active) {
if (debugger && emulator.emuHasDebugger) if (debugger && emulator.emuHasDebugger)
@ -2013,8 +1982,7 @@ int main(int argc, char **argv)
remoteCleanUp(); remoteCleanUp();
soundShutdown(); soundShutdown();
if (openGL) if (openGL) {
{
SDL_GL_DeleteContext(glcontext); SDL_GL_DeleteContext(glcontext);
} }
@ -2063,8 +2031,7 @@ void drawScreenMessage(u8 *screen, int pitch, int x, int y, unsigned int duratio
if (cartridgeType == 1 && gbBorderOn) { if (cartridgeType == 1 && gbBorderOn) {
gbSgbRenderBorder(); gbSgbRenderBorder();
} }
if(((systemGetClock() - screenMessageTime) < duration) && if (((systemGetClock() - screenMessageTime) < duration) && !disableStatusMessages) {
!disableStatusMessages) {
drawText(screen, pitch, x, y, drawText(screen, pitch, x, y,
screenMessageBuffer, false); screenMessageBuffer, false);
} else { } else {
@ -2106,12 +2073,10 @@ void systemDrawScreen()
filterFunction(pix + srcPitch, srcPitch, delta, screen, filterFunction(pix + srcPitch, srcPitch, delta, screen,
destPitch, sizeX, sizeY); destPitch, sizeX, sizeY);
if (openGL) if (openGL) {
{
int bytes = (systemColorDepth >> 3); int bytes = (systemColorDepth >> 3);
for (int i = 0; i < destWidth; i++) for (int i = 0; i < destWidth; i++)
for (int j = 0; j < destHeight; j++) for (int j = 0; j < destHeight; j++) {
{
u8 k; u8 k;
k = filterPix[i * bytes + j * destPitch + 3]; k = filterPix[i * bytes + j * destPitch + 3];
filterPix[i * bytes + j * destPitch + 3] = filterPix[i * bytes + j * destPitch + 1]; filterPix[i * bytes + j * destPitch + 3] = filterPix[i * bytes + j * destPitch + 1];
@ -2153,7 +2118,6 @@ void systemDrawScreen()
SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
} }
void systemSetTitle(const char* title) void systemSetTitle(const char* title)
@ -2296,8 +2260,7 @@ void systemConsoleMessage(const char *msg)
now_time_broken.tm_mday, now_time_broken.tm_mday,
now_time_broken.tm_mon + 1, now_time_broken.tm_mon + 1,
now_time_broken.tm_year + 1900, now_time_broken.tm_year + 1900,
msg msg);
);
} }
void systemScreenMessage(const char* msg) void systemScreenMessage(const char* msg)

View File

@ -18,16 +18,16 @@
// Parts adapted from VBA-H (VBA for Hackers) by LabMaster // Parts adapted from VBA-H (VBA for Hackers) by LabMaster
#include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include "../common/Port.h"
#include "../gba/GBA.h" #include "../gba/GBA.h"
#include "../gba/Sound.h" #include "../gba/Sound.h"
#include "../gba/armdis.h" #include "../gba/armdis.h"
#include "../gba/elf.h" #include "../gba/elf.h"
#include "../common/Port.h"
#include "exprNode.h" #include "exprNode.h"
extern bool debugger; extern bool debugger;
@ -225,9 +225,7 @@ static void debuggerPrefetch()
static void debuggerApplyBreakpoint(u32 address, int num, int size) static void debuggerApplyBreakpoint(u32 address, int num, int size)
{ {
if (size) if (size)
debuggerWriteMemory(address, (u32)(0xe1200070 | debuggerWriteMemory(address, (u32)(0xe1200070 | (num & 0xf) | ((num << 4) & 0xf0)));
(num & 0xf) |
((num<<4)&0xf0)));
else else
debuggerWriteHalfWord(address, debuggerWriteHalfWord(address,
(u16)(0xbe00 | num)); (u16)(0xbe00 | num));
@ -293,8 +291,7 @@ static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
if (t->size == 8) { if (t->size == 8) {
u64 value = 0; u64 value = 0;
if (type == LOCATION_memory) { if (type == LOCATION_memory) {
value = debuggerReadMemory(location) | value = debuggerReadMemory(location) | ((u64)debuggerReadMemory(location + 4) << 32);
((u64)debuggerReadMemory(location+4)<<32);
} else if (type == LOCATION_register) { } else if (type == LOCATION_register) {
value = reg[location].I | ((u64)reg[location + 1].I << 32); value = reg[location].I | ((u64)reg[location + 1].I << 32);
} }
@ -858,14 +855,11 @@ static void debuggerContinue(int n, char **args)
/*extern*/ void debuggerSignal(int sig, int number) /*extern*/ void debuggerSignal(int sig, int number)
{ {
switch (sig) { switch (sig) {
case 4: case 4: {
{
printf("Illegal instruction at %08x\n", armNextPC); printf("Illegal instruction at %08x\n", armNextPC);
debugger = true; debugger = true;
} } break;
break; case 5: {
case 5:
{
bool cond = debuggerCondEvaluate(number & 255); bool cond = debuggerCondEvaluate(number & 255);
if (cond) { if (cond) {
printf("Breakpoint %d reached\n", number); printf("Breakpoint %d reached\n", number);
@ -890,8 +884,7 @@ static void debuggerContinue(int n, char **args)
printf("File %s, function %s, line %d\n", file, f->name, printf("File %s, function %s, line %d\n", file, f->name,
line); line);
} }
} } break;
break;
default: default:
printf("Unknown signal %d\n", sig); printf("Unknown signal %d\n", sig);
break; break;
@ -919,17 +912,13 @@ static void debuggerBreakDelete(int n, char **args)
n++; n++;
if (n < debuggerNumOfBreakpoints) { if (n < debuggerNumOfBreakpoints) {
for (int i = n; i < debuggerNumOfBreakpoints; i++) { for (int i = n; i < debuggerNumOfBreakpoints; i++) {
debuggerBreakpointList[i-1].address = debuggerBreakpointList[i - 1].address = debuggerBreakpointList[i].address;
debuggerBreakpointList[i].address; debuggerBreakpointList[i - 1].value = debuggerBreakpointList[i].value;
debuggerBreakpointList[i-1].value = debuggerBreakpointList[i - 1].size = debuggerBreakpointList[i].size;
debuggerBreakpointList[i].value;
debuggerBreakpointList[i-1].size =
debuggerBreakpointList[i].size;
} }
} }
debuggerNumOfBreakpoints--; debuggerNumOfBreakpoints--;
} } else
else
printf("No breakpoints are set\n"); printf("No breakpoints are set\n");
} else } else
debuggerUsage("bd"); debuggerUsage("bd");
@ -1010,8 +999,7 @@ static void debuggerBreak(int n, char **args)
if (type == 2) if (type == 2)
size = 1; size = 1;
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
debuggerBreakpointList[i].value = type == 0x02 ? debuggerBreakpointList[i].value = type == 0x02 ? debuggerReadMemory(address) : debuggerReadHalfWord(address);
debuggerReadMemory(address) : debuggerReadHalfWord(address);
debuggerBreakpointList[i].size = size; debuggerBreakpointList[i].size = size;
// debuggerApplyBreakpoint(address, i, size); // debuggerApplyBreakpoint(address, i, size);
debuggerNumOfBreakpoints++; debuggerNumOfBreakpoints++;
@ -1066,19 +1054,14 @@ static void debuggerBreakWriteClear(int n, char **args)
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (!((address >= 0x02000000 && address < 0x02040000) || (address >= 0x03000000 && address < 0x03008000) || (address >= 0x05000000 && address < 0x05000400) || (address >= 0x06000000 && address < 0x06018000) || (address >= 0x07000000 && address < 0x07000400))) {
(address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
u32 final = address + n; u32 final = address + n;
switch (address >> 24) { switch (address >> 24) {
case 2: case 2: {
{
address &= 0x3ffff; address &= 0x3ffff;
final &= 0x3ffff; final &= 0x3ffff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1086,10 +1069,8 @@ static void debuggerBreakWriteClear(int n, char **args)
freezeWorkRAM[i] = 0; freezeWorkRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
0x2000000 + address, 0x2000000 + final); 0x2000000 + address, 0x2000000 + final);
} } break;
break; case 3: {
case 3:
{
address &= 0x7fff; address &= 0x7fff;
final &= 0x7fff; final &= 0x7fff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1097,10 +1078,8 @@ static void debuggerBreakWriteClear(int n, char **args)
freezeInternalRAM[i] = 0; freezeInternalRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
0x3000000 + address, 0x3000000 + final); 0x3000000 + address, 0x3000000 + final);
} } break;
break; case 5: {
case 5:
{
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1108,10 +1087,8 @@ static void debuggerBreakWriteClear(int n, char **args)
freezePRAM[i] = 0; freezePRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
0x5000000 + address, 0x5000000 + final); 0x5000000 + address, 0x5000000 + final);
} } break;
break; case 6: {
case 6:
{
if (address > 0x6010000) { if (address > 0x6010000) {
address &= 0x17fff; address &= 0x17fff;
final &= 0x17fff; final &= 0x17fff;
@ -1125,10 +1102,8 @@ static void debuggerBreakWriteClear(int n, char **args)
freezeVRAM[i] = 0; freezeVRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
0x06000000 + address, 0x06000000 + final); 0x06000000 + address, 0x06000000 + final);
} } break;
break; case 7: {
case 7:
{
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1136,8 +1111,7 @@ static void debuggerBreakWriteClear(int n, char **args)
freezeOAM[i] = 0; freezeOAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
0x7000000 + address, 0x7000000 + final); 0x7000000 + address, 0x7000000 + final);
} } break;
break;
} }
} else if (n == 1) { } else if (n == 1) {
int i; int i;
@ -1174,11 +1148,7 @@ static void debuggerBreakWrite(int n, char **args)
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (!((address >= 0x02000000 && address < 0x02040000) || (address >= 0x03000000 && address < 0x03008000) || (address >= 0x05000000 && address < 0x05000400) || (address >= 0x06000000 && address < 0x06018000) || (address >= 0x07000000 && address < 0x07000400))) {
(address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
@ -1240,19 +1210,14 @@ static void debuggerBreakChangeClear(int n, char **args)
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (!((address >= 0x02000000 && address < 0x02040000) || (address >= 0x03000000 && address < 0x03008000) || (address >= 0x05000000 && address < 0x05000400) || (address >= 0x06000000 && address < 0x06018000) || (address >= 0x07000000 && address < 0x07000400))) {
(address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
u32 final = address + n; u32 final = address + n;
switch (address >> 24) { switch (address >> 24) {
case 2: case 2: {
{
address &= 0x3ffff; address &= 0x3ffff;
final &= 0x3ffff; final &= 0x3ffff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1260,10 +1225,8 @@ static void debuggerBreakChangeClear(int n, char **args)
freezeWorkRAM[i] = 0; freezeWorkRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
0x2000000 + address, 0x2000000 + final); 0x2000000 + address, 0x2000000 + final);
} } break;
break; case 3: {
case 3:
{
address &= 0x7fff; address &= 0x7fff;
final &= 0x7fff; final &= 0x7fff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1271,10 +1234,8 @@ static void debuggerBreakChangeClear(int n, char **args)
freezeInternalRAM[i] = 0; freezeInternalRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
0x3000000 + address, 0x3000000 + final); 0x3000000 + address, 0x3000000 + final);
} } break;
break; case 5: {
case 5:
{
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1282,10 +1243,8 @@ static void debuggerBreakChangeClear(int n, char **args)
freezePRAM[i] = 0; freezePRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
0x5000000 + address, 0x5000000 + final); 0x5000000 + address, 0x5000000 + final);
} } break;
break; case 6: {
case 6:
{
if (address > 0x6010000) { if (address > 0x6010000) {
address &= 0x17fff; address &= 0x17fff;
final &= 0x17fff; final &= 0x17fff;
@ -1298,10 +1257,8 @@ static void debuggerBreakChangeClear(int n, char **args)
freezeVRAM[i] = 0; freezeVRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
0x3000000 + address, 0x3000000 + final); 0x3000000 + address, 0x3000000 + final);
} } break;
break; case 7: {
case 7:
{
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (u32 i = address; i < final; i++)
@ -1309,8 +1266,7 @@ static void debuggerBreakChangeClear(int n, char **args)
freezeOAM[i] = 0; freezeOAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
0x7000000 + address, 0x7000000 + final); 0x7000000 + address, 0x7000000 + final);
} } break;
break;
} }
} else if (n == 1) { } else if (n == 1) {
int i; int i;
@ -1347,11 +1303,7 @@ static void debuggerBreakChange(int n, char **args)
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (!((address >= 0x02000000 && address < 0x02040000) || (address >= 0x03000000 && address < 0x03008000) || (address >= 0x05000000 && address < 0x05000400) || (address >= 0x06000000 && address < 0x06018000) || (address >= 0x07000000 && address < 0x07000400))) {
(address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
@ -1543,25 +1495,20 @@ static void debuggerFileDisassembleThumb(int n, char **args)
void debuggerFindText(int n, char** args) void debuggerFindText(int n, char** args)
{ {
if ((n == 4) || (n == 3)) if ((n == 4) || (n == 3)) {
{
SearchResults = 0; SearchResults = 0;
sscanf(args[1], "%x", &SearchStart); sscanf(args[1], "%x", &SearchStart);
if (n == 4) if (n == 4) {
{
sscanf(args[2], "%u", &SearchMaxMatches); sscanf(args[2], "%u", &SearchMaxMatches);
strncpy((char*)SearchData, args[3], 64); strncpy((char*)SearchData, args[3], 64);
SearchLength = strlen(args[3]); SearchLength = strlen(args[3]);
} } else if (n == 3) {
else if (n == 3)
{
strncpy((char*)SearchData, args[2], 64); strncpy((char*)SearchData, args[2], 64);
SearchLength = strlen(args[2]); SearchLength = strlen(args[2]);
}; };
if (SearchLength > 64) if (SearchLength > 64) {
{
printf("Entered string (length: %d) is longer than 64 bytes and was cut.\n", SearchLength); printf("Entered string (length: %d) is longer than 64 bytes and was cut.\n", SearchLength);
SearchLength = 64; SearchLength = 64;
}; };
@ -1574,20 +1521,16 @@ void debuggerFindText(int n, char **args)
void debuggerFindHex(int n, char** args) void debuggerFindHex(int n, char** args)
{ {
if ((n == 4) || (n == 3)) if ((n == 4) || (n == 3)) {
{
SearchResults = 0; SearchResults = 0;
sscanf(args[1], "%x", &SearchStart); sscanf(args[1], "%x", &SearchStart);
char SearchHex[128]; char SearchHex[128];
if (n == 4) if (n == 4) {
{
sscanf(args[2], "%u", &SearchMaxMatches); sscanf(args[2], "%u", &SearchMaxMatches);
strncpy(SearchHex, args[3], 128); strncpy(SearchHex, args[3], 128);
SearchLength = strlen(args[3]); SearchLength = strlen(args[3]);
} } else if (n == 3) {
else if (n == 3)
{
strncpy(SearchHex, args[2], 128); strncpy(SearchHex, args[2], 128);
SearchLength = strlen(args[2]); SearchLength = strlen(args[2]);
}; };
@ -1597,14 +1540,12 @@ void debuggerFindHex(int n, char **args)
SearchLength /= 2; SearchLength /= 2;
if (SearchLength > 64) if (SearchLength > 64) {
{
printf("Entered string (length: %d) is longer than 64 bytes and was cut.\n", SearchLength); printf("Entered string (length: %d) is longer than 64 bytes and was cut.\n", SearchLength);
SearchLength = 64; SearchLength = 64;
}; };
for (unsigned int i = 0; i < SearchLength; i++) for (unsigned int i = 0; i < SearchLength; i++) {
{
unsigned int cbuf = 0; unsigned int cbuf = 0;
sscanf(&SearchHex[i << 1], "%02x", &cbuf); sscanf(&SearchHex[i << 1], "%02x", &cbuf);
SearchData[i] = cbuf; SearchData[i] = cbuf;
@ -1618,10 +1559,8 @@ void debuggerFindHex(int n, char **args)
void debuggerFindResume(int n, char** args) void debuggerFindResume(int n, char** args)
{ {
if ((n == 1) || (n == 2)) if ((n == 1) || (n == 2)) {
{ if (SearchLength == 0) {
if (SearchLength == 0)
{
printf("Error: No search in progress. Start a search with ft or fh.\n"); printf("Error: No search in progress. Start a search with ft or fh.\n");
debuggerUsage("fr"); debuggerUsage("fr");
return; return;
@ -1640,43 +1579,86 @@ void debuggerDoSearch()
{ {
unsigned int count = 0; unsigned int count = 0;
while (true) while (true) {
{
unsigned int final = SearchStart + SearchLength - 1; unsigned int final = SearchStart + SearchLength - 1;
u8* end; u8* end;
u8* start; u8* start;
switch (SearchStart >> 24) switch (SearchStart >> 24) {
{
case 0: case 0:
if (final > 0x00003FFF) { SearchStart = 0x02000000; continue; } if (final > 0x00003FFF) {
else { start = bios + (SearchStart & 0x3FFF); end = bios + 0x3FFF; break; }; SearchStart = 0x02000000;
continue;
} else {
start = bios + (SearchStart & 0x3FFF);
end = bios + 0x3FFF;
break;
};
case 2: case 2:
if (final > 0x0203FFFF) { SearchStart = 0x03000000; continue; } if (final > 0x0203FFFF) {
else { start = workRAM + (SearchStart & 0x3FFFF); end = workRAM + 0x3FFFF; break; }; SearchStart = 0x03000000;
continue;
} else {
start = workRAM + (SearchStart & 0x3FFFF);
end = workRAM + 0x3FFFF;
break;
};
case 3: case 3:
if (final > 0x03007FFF) { SearchStart = 0x04000000; continue; } if (final > 0x03007FFF) {
else { start = internalRAM + (SearchStart & 0x7FFF); end = internalRAM + 0x7FFF; break; }; SearchStart = 0x04000000;
continue;
} else {
start = internalRAM + (SearchStart & 0x7FFF);
end = internalRAM + 0x7FFF;
break;
};
case 4: case 4:
if (final > 0x040003FF) { SearchStart = 0x05000000; continue; } if (final > 0x040003FF) {
else { start = ioMem + (SearchStart & 0x3FF); end = ioMem + 0x3FF; break; }; SearchStart = 0x05000000;
continue;
} else {
start = ioMem + (SearchStart & 0x3FF);
end = ioMem + 0x3FF;
break;
};
case 5: case 5:
if (final > 0x050003FF) { SearchStart = 0x06000000; continue; } if (final > 0x050003FF) {
else { start = paletteRAM + (SearchStart & 0x3FF); end = paletteRAM + 0x3FF; break; }; SearchStart = 0x06000000;
continue;
} else {
start = paletteRAM + (SearchStart & 0x3FF);
end = paletteRAM + 0x3FF;
break;
};
case 6: case 6:
if (final > 0x0601FFFF) { SearchStart = 0x07000000; continue; } if (final > 0x0601FFFF) {
else { start = vram + (SearchStart & 0x1FFFF); end = vram + 0x1FFFF; break; }; SearchStart = 0x07000000;
continue;
} else {
start = vram + (SearchStart & 0x1FFFF);
end = vram + 0x1FFFF;
break;
};
case 7: case 7:
if (final > 0x070003FF) { SearchStart = 0x08000000; continue; } if (final > 0x070003FF) {
else { start = oam + (SearchStart & 0x3FF); end = oam + 0x3FF; break; }; SearchStart = 0x08000000;
continue;
} else {
start = oam + (SearchStart & 0x3FF);
end = oam + 0x3FF;
break;
};
case 8: case 8:
case 9: case 9:
case 10: case 10:
case 11: case 11:
case 12: case 12:
case 13: case 13:
if (final <= 0x09FFFFFF) if (final <= 0x09FFFFFF) {
{ start = rom + (SearchStart & 0x01FFFFFF); end = rom + 0x01FFFFFF; break; }; start = rom + (SearchStart & 0x01FFFFFF);
end = rom + 0x01FFFFFF;
break;
};
default: default:
printf("Search completed.\n"); printf("Search completed.\n");
SearchLength = 0; SearchLength = 0;
@ -1685,8 +1667,7 @@ void debuggerDoSearch()
end -= SearchLength - 1; end -= SearchLength - 1;
u8 firstbyte = SearchData[0]; u8 firstbyte = SearchData[0];
while (start <= end) while (start <= end) {
{
while ((start <= end) && (*start != firstbyte)) while ((start <= end) && (*start != firstbyte))
start++; start++;
@ -1697,12 +1678,10 @@ void debuggerDoSearch()
while ((start[p] == SearchData[p]) && (p < SearchLength)) while ((start[p] == SearchData[p]) && (p < SearchLength))
p++; p++;
if (p == SearchLength) if (p == SearchLength) {
{
printf("Search result (%d): %08x\n", count + SearchResults, AddressToGBA(start)); printf("Search result (%d): %08x\n", count + SearchResults, AddressToGBA(start));
count++; count++;
if (count == SearchMaxMatches) if (count == SearchMaxMatches) {
{
SearchStart = AddressToGBA(start + p); SearchStart = AddressToGBA(start + p);
SearchResults += count; SearchResults += count;
return; return;
@ -1769,8 +1748,7 @@ static void debuggerRegisters(int, char **)
char buffer[10]; char buffer[10];
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
if (debugger_last) if (debugger_last) {
{
printf("R00=%08x R04=%08x R08=%08x R12=%08x\n", printf("R00=%08x R04=%08x R08=%08x R12=%08x\n",
oldreg[0], oldreg[4], oldreg[8], oldreg[12]); oldreg[0], oldreg[4], oldreg[8], oldreg[12]);
printf("R01=%08x R05=%08x R09=%08x R13=%08x\n", printf("R01=%08x R05=%08x R09=%08x R13=%08x\n",
@ -1905,7 +1883,8 @@ static void debuggerIo(int n, char **args)
debuggerIoTimer(); debuggerIoTimer();
else if (!strcmp(args[1], "misc")) else if (!strcmp(args[1], "misc"))
debuggerIoMisc(); debuggerIoMisc();
else printf("Unrecognized option %s\n", args[1]); else
printf("Unrecognized option %s\n", args[1]);
} }
static void debuggerEditByte(int n, char** args) static void debuggerEditByte(int n, char** args)
@ -1970,7 +1949,6 @@ static void debuggerEdit(int n, char **args)
debuggerUsage("ew"); debuggerUsage("ew");
} }
#define ASCII(c) (c)<32 ? '.' : (c)> 127 ? '.' : (c) #define ASCII(c) (c)<32 ? '.' : (c)> 127 ? '.' : (c)
static void debuggerMemoryByte(int n, char** args) static void debuggerMemoryByte(int n, char** args)
@ -2106,8 +2084,7 @@ static void debuggerWriteState(int n, char **args)
sdlWriteState(num - 1); sdlWriteState(num - 1);
else else
printf("Savestate number must be in the 1-10 range"); printf("Savestate number must be in the 1-10 range");
} } else
else
debuggerUsage("save"); debuggerUsage("save");
} }
@ -2121,8 +2098,7 @@ static void debuggerReadState(int n, char **args)
sdlReadState(num - 1); sdlReadState(num - 1);
else else
printf("Savestate number must be in the 1-10 range"); printf("Savestate number must be in the 1-10 range");
} } else
else
debuggerUsage("load"); debuggerUsage("load");
} }
@ -2204,7 +2180,6 @@ static void debuggerCondBreakThumb(int n, char **args)
debuggerCondValidate(n, args, 2); debuggerCondValidate(n, args, 2);
} else } else
debuggerUsage("cbt"); debuggerUsage("cbt");
} }
static void debuggerCondBreakArm(int n, char** args) static void debuggerCondBreakArm(int n, char** args)
@ -2571,8 +2546,7 @@ char* strqtok (char* string, const char* ctrl)
char deli[32]; char deli[32];
memset(deli, 0, 32 * sizeof(char)); memset(deli, 0, 32 * sizeof(char));
while (*ctrl) while (*ctrl) {
{
deli[*ctrl >> 3] |= (1 << (*ctrl & 7)); deli[*ctrl >> 3] |= (1 << (*ctrl & 7));
ctrl++; ctrl++;
}; };
@ -2583,8 +2557,7 @@ char* strqtok (char* string, const char* ctrl)
while ((deli[*str >> 3] & (1 << (*str & 7))) && *str) while ((deli[*str >> 3] & (1 << (*str & 7))) && *str)
str++; str++;
if (*str == '"') if (*str == '"') {
{
string = ++str; string = ++str;
// only break if another quote or end of string is found // only break if another quote or end of string is found
@ -2598,13 +2571,11 @@ char* strqtok (char* string, const char* ctrl)
str++; str++;
}; };
if (string == str) if (string == str) {
{
nexttoken = NULL; nexttoken = NULL;
return NULL; return NULL;
} else { } else {
if (*str) if (*str) {
{
*str = 0; *str = 0;
nexttoken = str + 1; nexttoken = str + 1;
} else } else

View File

@ -17,10 +17,10 @@
/* First, we deal with platform-specific or compiler-specific issues. */ /* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */ /* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
/* end standard C headers. */ /* end standard C headers. */
@ -166,17 +166,14 @@ extern FILE *yyin, *yyout;
/* Return all but the first "n" matched characters back to the input stream. */ /* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \ #define yyless(n) \
do \ do { \
{ \
/* Undo effects of setting up yytext. */ \ /* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \ int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg); \ YY_LESS_LINENO(yyless_macro_arg); \
*yy_cp = (yy_hold_char); \ *yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \ YY_RESTORE_YY_MORE_OFFSET(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \ } while (0)
while ( 0 )
#define unput(c) yyunput(c, (yytext_ptr)) #define unput(c) yyunput(c, (yytext_ptr))
@ -187,8 +184,7 @@ typedef size_t yy_size_t;
#ifndef YY_STRUCT_YY_BUFFER_STATE #ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state struct yy_buffer_state {
{
FILE* yy_input_file; FILE* yy_input_file;
char* yy_ch_buf; /* input buffer */ char* yy_ch_buf; /* input buffer */
@ -246,7 +242,6 @@ struct yy_buffer_state
* just pointing yyin at a new input file. * just pointing yyin at a new input file.
*/ */
#define YY_BUFFER_EOF_PENDING 2 #define YY_BUFFER_EOF_PENDING 2
}; };
#endif /* !YY_STRUCT_YY_BUFFER_STATE */ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
@ -313,8 +308,7 @@ void yyfree (void * );
{ \ { \
if (!YY_CURRENT_BUFFER) { \ if (!YY_CURRENT_BUFFER) { \
yyensure_buffer_stack(); \ yyensure_buffer_stack(); \
YY_CURRENT_BUFFER_LVALUE = \ YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); \
yy_create_buffer(yyin,YY_BUF_SIZE ); \
} \ } \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
} }
@ -323,8 +317,7 @@ void yyfree (void * );
{ \ { \
if (!YY_CURRENT_BUFFER) { \ if (!YY_CURRENT_BUFFER) { \
yyensure_buffer_stack(); \ yyensure_buffer_stack(); \
YY_CURRENT_BUFFER_LVALUE = \ YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE); \
yy_create_buffer(yyin,YY_BUF_SIZE ); \
} \ } \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
} }
@ -368,20 +361,16 @@ static void yy_fatal_error (yyconst char msg[] );
#define YY_END_OF_BUFFER 11 #define YY_END_OF_BUFFER 11
/* This struct is not used in this scanner, /* This struct is not used in this scanner,
but its presence is necessary. */ but its presence is necessary. */
struct yy_trans_info struct yy_trans_info {
{
flex_int32_t yy_verify; flex_int32_t yy_verify;
flex_int32_t yy_nxt; flex_int32_t yy_nxt;
}; };
static yyconst flex_int16_t yy_accept[24] = static yyconst flex_int16_t yy_accept[24] = { 0,
{ 0,
0, 0, 11, 9, 8, 8, 6, 7, 9, 4, 0, 0, 11, 9, 8, 8, 6, 7, 9, 4,
3, 2, 2, 8, 5, 3, 2, 2, 2, 2, 3, 2, 2, 8, 5, 3, 2, 2, 2, 2,
2, 1, 0 2, 1, 0 };
} ;
static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_ec[256] = { 0,
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -409,46 +398,35 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1 1, 1, 1, 1, 1 };
} ;
static yyconst flex_int32_t yy_meta[17] = static yyconst flex_int32_t yy_meta[17] = { 0,
{ 0,
1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2,
2, 2, 2, 2, 2, 2 2, 2, 2, 2, 2, 2 };
} ;
static yyconst flex_int16_t yy_base[25] = static yyconst flex_int16_t yy_base[25] = { 0,
{ 0,
0, 0, 32, 33, 15, 17, 33, 33, 22, 33, 0, 0, 32, 33, 15, 17, 33, 33, 22, 33,
22, 0, 16, 19, 33, 20, 0, 11, 15, 11, 22, 0, 16, 19, 33, 20, 0, 11, 15, 11,
12, 0, 33, 21 12, 0, 33, 21 };
} ;
static yyconst flex_int16_t yy_def[25] = static yyconst flex_int16_t yy_def[25] = { 0,
{ 0,
23, 1, 23, 23, 23, 23, 23, 23, 23, 23, 23, 1, 23, 23, 23, 23, 23, 23, 23, 23,
23, 24, 24, 23, 23, 23, 24, 24, 24, 24, 23, 24, 24, 23, 23, 23, 24, 24, 24, 24,
24, 24, 0, 23 24, 24, 0, 23 };
} ;
static yyconst flex_int16_t yy_nxt[50] = static yyconst flex_int16_t yy_nxt[50] = { 0,
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 4, 12, 4, 5, 6, 7, 8, 9, 10, 11, 4, 12,
12, 12, 12, 12, 13, 12, 14, 14, 14, 14, 12, 12, 12, 12, 13, 12, 14, 14, 14, 14,
14, 14, 17, 22, 21, 20, 19, 16, 18, 16, 14, 14, 17, 22, 21, 20, 19, 16, 18, 16,
15, 23, 3, 23, 23, 23, 23, 23, 23, 23, 15, 23, 3, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23 23, 23, 23, 23, 23, 23, 23, 23, 23 };
} ;
static yyconst flex_int16_t yy_chk[50] = static yyconst flex_int16_t yy_chk[50] = { 0,
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 5, 5, 6, 6, 1, 1, 1, 1, 1, 1, 5, 5, 6, 6,
14, 14, 24, 21, 20, 19, 18, 16, 13, 11, 14, 14, 24, 21, 20, 19, 18, 16, 13, 11,
9, 3, 23, 23, 23, 23, 23, 23, 23, 23, 9, 3, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23 23, 23, 23, 23, 23, 23, 23, 23, 23 };
} ;
static yy_state_type yy_last_accepting_state; static yy_state_type yy_last_accepting_state;
static char* yy_last_accepting_cpos; static char* yy_last_accepting_cpos;
@ -570,7 +548,11 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's, /* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite(). * we now use fwrite().
*/ */
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #define ECHO \
do { \
if (fwrite(yytext, yyleng, 1, yyout)) { \
} \
} while (0)
#endif #endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -578,34 +560,27 @@ static int input (void );
*/ */
#ifndef YY_INPUT #ifndef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) { \
{ \
int c = '*'; \ int c = '*'; \
size_t n; \ size_t n; \
for ( n = 0; n < max_size && \ for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char)c; \ buf[n] = (char)c; \
if (c == '\n') \ if (c == '\n') \
buf[n++] = (char)c; \ buf[n++] = (char)c; \
if (c == EOF && ferror(yyin)) \ if (c == EOF && ferror(yyin)) \
YY_FATAL_ERROR("input in flex scanner failed"); \ YY_FATAL_ERROR("input in flex scanner failed"); \
result = n; \ result = n; \
} \ } else { \
else \
{ \
errno = 0; \ errno = 0; \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ while ((result = fread(buf, 1, max_size, yyin)) == 0 && ferror(yyin)) { \
{ \ if (errno != EINTR) { \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR("input in flex scanner failed"); \ YY_FATAL_ERROR("input in flex scanner failed"); \
break; \ break; \
} \ } \
errno = 0; \ errno = 0; \
clearerr(yyin); \ clearerr(yyin); \
} \ } \
}\ }
\
#endif #endif
@ -665,11 +640,9 @@ YY_DECL
#line 33 "expr.l" #line 33 "expr.l"
#line 670 "expr-lex.cpp" #line 670 "expr-lex.cpp"
if ( !(yy_init) ) if (!(yy_init)) {
{
(yy_init) = 1; (yy_init) = 1;
#ifdef YY_USER_INIT #ifdef YY_USER_INIT
@ -687,8 +660,7 @@ YY_DECL
if (!YY_CURRENT_BUFFER) { if (!YY_CURRENT_BUFFER) {
yyensure_buffer_stack(); yyensure_buffer_stack();
YY_CURRENT_BUFFER_LVALUE = YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE);
yy_create_buffer(yyin,YY_BUF_SIZE );
} }
yy_load_buffer_state(); yy_load_buffer_state();
@ -708,29 +680,24 @@ YY_DECL
yy_current_state = (yy_start); yy_current_state = (yy_start);
yy_match: yy_match:
do do {
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] ) if (yy_accept[yy_current_state]) {
{
(yy_last_accepting_state) = yy_current_state; (yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp; (yy_last_accepting_cpos) = yy_cp;
} }
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
{
yy_current_state = (int)yy_def[yy_current_state]; yy_current_state = (int)yy_def[yy_current_state];
if (yy_current_state >= 24) if (yy_current_state >= 24)
yy_c = yy_meta[(unsigned int)yy_c]; yy_c = yy_meta[(unsigned int)yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c];
++yy_cp; ++yy_cp;
} } while (yy_base[yy_current_state] != 33);
while ( yy_base[yy_current_state] != 33 );
yy_find_action: yy_find_action:
yy_act = yy_accept[yy_current_state]; yy_act = yy_accept[yy_current_state];
if ( yy_act == 0 ) if (yy_act == 0) { /* have to back up */
{ /* have to back up */
yy_cp = (yy_last_accepting_cpos); yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state); yy_current_state = (yy_last_accepting_state);
yy_act = yy_accept[yy_current_state]; yy_act = yy_accept[yy_current_state];
@ -740,8 +707,7 @@ yy_find_action:
do_action: /* This label is used only to access EOF actions. */ do_action: /* This label is used only to access EOF actions. */
switch ( yy_act ) switch (yy_act) { /* beginning of action switch */
{ /* beginning of action switch */
case 0: /* must back up */ case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */ /* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = (yy_hold_char); *yy_cp = (yy_hold_char);
@ -818,8 +784,7 @@ ECHO;
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
yyterminate(); yyterminate();
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER: {
{
/* Amount of text matched not including the EOB char. */ /* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int)(yy_cp - (yytext_ptr)) - 1; int yy_amount_of_matched_text = (int)(yy_cp - (yytext_ptr)) - 1;
@ -827,8 +792,7 @@ case YY_STATE_EOF(INITIAL):
*yy_cp = (yy_hold_char); *yy_cp = (yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW) {
{
/* We're scanning a new file or input source. It's /* We're scanning a new file or input source. It's
* possible that this happened because the user * possible that this happened because the user
* just pointed yyin at a new source and called * just pointed yyin at a new source and called
@ -850,8 +814,7 @@ case YY_STATE_EOF(INITIAL):
* end-of-buffer state). Contrast this with the test * end-of-buffer state). Contrast this with the test
* in input(). * in input().
*/ */
if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) if ((yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]) { /* This was really a NUL. */
{ /* This was really a NUL. */
yy_state_type yy_next_state; yy_state_type yy_next_state;
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
@ -871,29 +834,25 @@ case YY_STATE_EOF(INITIAL):
yy_bp = (yytext_ptr) + YY_MORE_ADJ; yy_bp = (yytext_ptr) + YY_MORE_ADJ;
if ( yy_next_state ) if (yy_next_state) {
{
/* Consume the NUL. */ /* Consume the NUL. */
yy_cp = ++(yy_c_buf_p); yy_cp = ++(yy_c_buf_p);
yy_current_state = yy_next_state; yy_current_state = yy_next_state;
goto yy_match; goto yy_match;
} }
else else {
{
yy_cp = (yy_c_buf_p); yy_cp = (yy_c_buf_p);
goto yy_find_action; goto yy_find_action;
} }
} }
else switch ( yy_get_next_buffer( ) ) else
{ switch (yy_get_next_buffer()) {
case EOB_ACT_END_OF_FILE: case EOB_ACT_END_OF_FILE: {
{
(yy_did_buffer_switch_on_eof) = 0; (yy_did_buffer_switch_on_eof) = 0;
if ( yywrap( ) ) if (yywrap()) {
{
/* Note: because we've taken care in /* Note: because we've taken care in
* yy_get_next_buffer() to have set up * yy_get_next_buffer() to have set up
* yytext, we can now set up * yytext, we can now set up
@ -909,8 +868,7 @@ case YY_STATE_EOF(INITIAL):
goto do_action; goto do_action;
} }
else else {
{
if (!(yy_did_buffer_switch_on_eof)) if (!(yy_did_buffer_switch_on_eof))
YY_NEW_FILE; YY_NEW_FILE;
} }
@ -918,8 +876,7 @@ case YY_STATE_EOF(INITIAL):
} }
case EOB_ACT_CONTINUE_SCAN: case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) = (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
(yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state(); yy_current_state = yy_get_previous_state();
@ -928,8 +885,7 @@ case YY_STATE_EOF(INITIAL):
goto yy_match; goto yy_match;
case EOB_ACT_LAST_MATCH: case EOB_ACT_LAST_MATCH:
(yy_c_buf_p) = (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
yy_current_state = yy_get_previous_state(); yy_current_state = yy_get_previous_state();
@ -965,18 +921,15 @@ static int yy_get_next_buffer (void)
YY_FATAL_ERROR( YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed"); "fatal flex scanner internal error--end of buffer missed");
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) { /* Don't try to fill the buffer, so this is an EOF. */
{ /* Don't try to fill the buffer, so this is an EOF. */ if ((yy_c_buf_p) - (yytext_ptr)-YY_MORE_ADJ == 1) {
if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so /* We matched a single character, the EOB, so
* treat this as a final EOF. * treat this as a final EOF.
*/ */
return EOB_ACT_END_OF_FILE; return EOB_ACT_END_OF_FILE;
} }
else else {
{
/* We matched some text prior to the EOB, first /* We matched some text prior to the EOB, first
* process it. * process it.
*/ */
@ -998,22 +951,17 @@ static int yy_get_next_buffer (void)
*/ */
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
else else {
{ int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 ) while (num_to_read <= 0) { /* Not enough room in the buffer - grow it. */
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */ /* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER; YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset = int yy_c_buf_p_offset = (int)((yy_c_buf_p)-b->yy_ch_buf);
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer ) if (b->yy_is_our_buffer) {
{
int new_size = b->yy_buf_size * 2; int new_size = b->yy_buf_size * 2;
if (new_size <= 0) if (new_size <= 0)
@ -1024,8 +972,7 @@ static int yy_get_next_buffer (void)
b->yy_ch_buf = (char*) b->yy_ch_buf = (char*)
/* Include room in for 2 EOB chars. */ /* Include room in for 2 EOB chars. */
yyrealloc((void*)b->yy_ch_buf, b->yy_buf_size + 2); yyrealloc((void*)b->yy_ch_buf, b->yy_buf_size + 2);
} } else
else
/* Can't grow it, we don't own it. */ /* Can't grow it, we don't own it. */
b->yy_ch_buf = 0; b->yy_ch_buf = 0;
@ -1035,9 +982,7 @@ static int yy_get_next_buffer (void)
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
number_to_move - 1;
} }
if (num_to_read > YY_READ_BUF_SIZE) if (num_to_read > YY_READ_BUF_SIZE)
@ -1050,19 +995,15 @@ static int yy_get_next_buffer (void)
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
} }
if ( (yy_n_chars) == 0 ) if ((yy_n_chars) == 0) {
{ if (number_to_move == YY_MORE_ADJ) {
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE; ret_val = EOB_ACT_END_OF_FILE;
yyrestart(yyin); yyrestart(yyin);
} }
else else {
{
ret_val = EOB_ACT_LAST_MATCH; ret_val = EOB_ACT_LAST_MATCH;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING;
YY_BUFFER_EOF_PENDING;
} }
} }
@ -1095,16 +1036,13 @@ static int yy_get_next_buffer (void)
yy_current_state = (yy_start); yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) {
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] ) if (yy_accept[yy_current_state]) {
{
(yy_last_accepting_state) = yy_current_state; (yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp; (yy_last_accepting_cpos) = yy_cp;
} }
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
{
yy_current_state = (int)yy_def[yy_current_state]; yy_current_state = (int)yy_def[yy_current_state];
if (yy_current_state >= 24) if (yy_current_state >= 24)
yy_c = yy_meta[(unsigned int)yy_c]; yy_c = yy_meta[(unsigned int)yy_c];
@ -1126,13 +1064,11 @@ static int yy_get_next_buffer (void)
register char* yy_cp = (yy_c_buf_p); register char* yy_cp = (yy_c_buf_p);
register YY_CHAR yy_c = 1; register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] ) if (yy_accept[yy_current_state]) {
{
(yy_last_accepting_state) = yy_current_state; (yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp; (yy_last_accepting_cpos) = yy_cp;
} }
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
{
yy_current_state = (int)yy_def[yy_current_state]; yy_current_state = (int)yy_def[yy_current_state];
if (yy_current_state >= 24) if (yy_current_state >= 24)
yy_c = yy_meta[(unsigned int)yy_c]; yy_c = yy_meta[(unsigned int)yy_c];
@ -1155,8 +1091,7 @@ static int yy_get_next_buffer (void)
*(yy_c_buf_p) = (yy_hold_char); *(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) if (*(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR) {
{
/* yy_c_buf_p now points to the character we want to return. /* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a * If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer. * valid NUL; if not, then we've hit the end of the buffer.
@ -1165,13 +1100,11 @@ static int yy_get_next_buffer (void)
/* This was really a NUL. */ /* This was really a NUL. */
*(yy_c_buf_p) = '\0'; *(yy_c_buf_p) = '\0';
else else { /* need more input */
{ /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr); int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p); ++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) ) switch (yy_get_next_buffer()) {
{
case EOB_ACT_LAST_MATCH: case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b() /* This happens because yy_g_n_b()
* sees that we've accumulated a * sees that we've accumulated a
@ -1188,8 +1121,7 @@ static int yy_get_next_buffer (void)
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE: case EOB_ACT_END_OF_FILE: {
{
if (yywrap()) if (yywrap())
return EOF; return EOF;
@ -1227,8 +1159,7 @@ static int yy_get_next_buffer (void)
if (!YY_CURRENT_BUFFER) { if (!YY_CURRENT_BUFFER) {
yyensure_buffer_stack(); yyensure_buffer_stack();
YY_CURRENT_BUFFER_LVALUE = YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE);
yy_create_buffer(yyin,YY_BUF_SIZE );
} }
yy_init_buffer(YY_CURRENT_BUFFER, input_file); yy_init_buffer(YY_CURRENT_BUFFER, input_file);
@ -1251,8 +1182,7 @@ static int yy_get_next_buffer (void)
if (YY_CURRENT_BUFFER == new_buffer) if (YY_CURRENT_BUFFER == new_buffer)
return; return;
if ( YY_CURRENT_BUFFER ) if (YY_CURRENT_BUFFER) {
{
/* Flush out information for old buffer. */ /* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char); *(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
@ -1400,8 +1330,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
yyensure_buffer_stack(); yyensure_buffer_stack();
/* This block is copied from yy_switch_to_buffer. */ /* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER ) if (YY_CURRENT_BUFFER) {
{
/* Flush out information for old buffer. */ /* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char); *(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
@ -1452,9 +1381,7 @@ static void yyensure_buffer_stack (void)
* immediate realloc on the next call. * immediate realloc on the next call.
*/ */
num_to_alloc = 1; num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc(num_to_alloc * sizeof(struct yy_buffer_state*));
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if (!(yy_buffer_stack)) if (!(yy_buffer_stack))
YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
@ -1471,10 +1398,8 @@ static void yyensure_buffer_stack (void)
int grow_size = 8 /* arbitrary grow size */; int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size; num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc((yy_buffer_stack),
((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*));
num_to_alloc * sizeof(struct yy_buffer_state*)
);
if (!(yy_buffer_stack)) if (!(yy_buffer_stack))
YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
@ -1494,9 +1419,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{ {
YY_BUFFER_STATE b; YY_BUFFER_STATE b;
if ( size < 2 || if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR || base[size - 1] != YY_END_OF_BUFFER_CHAR)
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */ /* They forgot to leave room for the EOB's. */
return 0; return 0;
@ -1584,8 +1507,7 @@ static void yy_fatal_error (yyconst char* msg )
#undef yyless #undef yyless
#define yyless(n) \ #define yyless(n) \
do \ do { \
{ \
/* Undo effects of setting up yytext. */ \ /* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \ int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg); \ YY_LESS_LINENO(yyless_macro_arg); \
@ -1594,8 +1516,7 @@ static void yy_fatal_error (yyconst char* msg )
(yy_hold_char) = *(yy_c_buf_p); \ (yy_hold_char) = *(yy_c_buf_p); \
*(yy_c_buf_p) = '\0'; \ *(yy_c_buf_p) = '\0'; \
yyleng = yyless_macro_arg; \ yyleng = yyless_macro_arg; \
} \ } while (0)
while ( 0 )
/* Accessor methods (get/set functions) to struct members. */ /* Accessor methods (get/set functions) to struct members. */
@ -1777,11 +1698,8 @@ void yyfree (void * ptr )
#line 67 "expr.l" #line 67 "expr.l"
void exprCleanBuffer() void exprCleanBuffer()
{ {
yy_delete_buffer(YY_CURRENT_BUFFER); yy_delete_buffer(YY_CURRENT_BUFFER);
yy_init = 1; yy_init = 1;
} }

View File

@ -58,8 +58,6 @@
/* Using locations. */ /* Using locations. */
#define YYLSP_NEEDED 0 #define YYLSP_NEEDED 0
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
#define YYTOKENTYPE #define YYTOKENTYPE
@ -84,15 +82,12 @@
#define TOKEN_SIZEOF 263 #define TOKEN_SIZEOF 263
#define TOKEN_NUMBER 264 #define TOKEN_NUMBER 264
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
#line 1 "expr.ypp" #line 1 "expr.ypp"
namespace std { namespace std {
#include <stdio.h>
#include <memory.h> #include <memory.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
} }
@ -107,13 +102,11 @@ extern int yyerror(const char *);
extern int yylex(); extern int yylex();
extern char* yytext; extern char* yytext;
//#define YYERROR_VERBOSE 1 //#define YYERROR_VERBOSE 1
//#define YYDEBUG 1 //#define YYDEBUG 1
Node* result = NULL; Node* result = NULL;
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
#define YYDEBUG 0 #define YYDEBUG 0
@ -139,11 +132,8 @@ typedef int YYSTYPE;
#define YYSTYPE_IS_TRIVIAL 1 #define YYSTYPE_IS_TRIVIAL 1
#endif #endif
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
/* Line 216 of yacc.c. */ /* Line 216 of yacc.c. */
#line 149 "expr.tab.cpp" #line 149 "expr.tab.cpp"
@ -223,8 +213,7 @@ static int
YYID(int i) YYID(int i)
#else #else
static int static int
YYID (i) YYID(i) int i;
int i;
#endif #endif
{ {
return i; return i;
@ -261,7 +250,10 @@ YYID (i)
#ifdef YYSTACK_ALLOC #ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */ /* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) #define YYSTACK_FREE(Ptr) \
do { /* empty */ \
; \
} while (YYID(0))
#ifndef YYSTACK_ALLOC_MAXIMUM #ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack, /* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely and a page size can be as small as 4096 bytes. So we cannot safely
@ -300,14 +292,12 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#endif #endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (!defined yyoverflow \ #if (!defined yyoverflow \
&& (!defined __cplusplus \ && (!defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */ /* A type that is properly aligned for any stack member. */
union yyalloc union yyalloc {
{
yytype_int16 yyss; yytype_int16 yyss;
YYSTYPE yyvs; YYSTYPE yyvs;
}; };
@ -329,13 +319,11 @@ union yyalloc
__builtin_memcpy(To, From, (Count) * sizeof(*(From))) __builtin_memcpy(To, From, (Count) * sizeof(*(From)))
#else #else
#define YYCOPY(To, From, Count) \ #define YYCOPY(To, From, Count) \
do \ do { \
{ \
YYSIZE_T yyi; \ YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \ for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \ (To)[yyi] = (From)[yyi]; \
} \ } while (YYID(0))
while (YYID (0))
#endif #endif
#endif #endif
@ -345,15 +333,13 @@ union yyalloc
stack. Advance YYPTR to a properly aligned location for the next stack. Advance YYPTR to a properly aligned location for the next
stack. */ stack. */
#define YYSTACK_RELOCATE(Stack) \ #define YYSTACK_RELOCATE(Stack) \
do \ do { \
{ \
YYSIZE_T yynewbytes; \ YYSIZE_T yynewbytes; \
YYCOPY(&yyptr->Stack, Stack, yysize); \ YYCOPY(&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \ Stack = &yyptr->Stack; \
yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \ yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof(*yyptr); \ yyptr += yynewbytes / sizeof(*yyptr); \
} \ } while (YYID(0))
while (YYID (0))
#endif #endif
@ -379,8 +365,7 @@ union yyalloc
((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) ((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
static const yytype_uint8 yytranslate[] = static const yytype_uint8 yytranslate[] = {
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@ -413,15 +398,13 @@ static const yytype_uint8 yytranslate[] =
#if YYDEBUG #if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */ YYRHS. */
static const yytype_uint8 yyprhs[] = static const yytype_uint8 yyprhs[] = {
{
0, 0, 3, 5, 7, 11, 15, 19, 24, 26, 0, 0, 3, 5, 7, 11, 15, 19, 24, 26,
29, 32, 37, 39 29, 32, 37, 39
}; };
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] = static const yytype_int8 yyrhs[] = {
{
15, 0, -1, 16, -1, 17, -1, 11, 16, 12, 15, 0, -1, 16, -1, 17, -1, 11, 16, 12,
-1, 16, 4, 19, -1, 16, 6, 19, -1, 16, -1, 16, 4, 19, -1, 16, 6, 19, -1, 16,
10, 18, 13, -1, 19, -1, 5, 16, -1, 7, 10, 18, 13, -1, 19, -1, 5, 16, -1, 7,
@ -430,8 +413,7 @@ static const yytype_int8 yyrhs[] =
}; };
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] = static const yytype_uint8 yyrline[] = {
{
0, 32, 32, 36, 37, 38, 39, 40, 43, 44, 0, 32, 32, 36, 37, 38, 39, 40, 43, 44,
45, 46, 50, 54 45, 46, 50, 54
}; };
@ -440,8 +422,7 @@ static const yytype_uint8 yyrline[] =
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] = static const char* const yytname[] = {
{
"$end", "error", "$undefined", "TOKEN_IDENTIFIER", "TOKEN_DOT", "$end", "error", "$undefined", "TOKEN_IDENTIFIER", "TOKEN_DOT",
"TOKEN_STAR", "TOKEN_ARROW", "TOKEN_ADDR", "TOKEN_SIZEOF", "TOKEN_STAR", "TOKEN_ARROW", "TOKEN_ADDR", "TOKEN_SIZEOF",
"TOKEN_NUMBER", "'['", "'('", "')'", "']'", "$accept", "final", "TOKEN_NUMBER", "'['", "'('", "')'", "']'", "$accept", "final",
@ -452,23 +433,20 @@ static const char *const yytname[] =
#ifdef YYPRINT #ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
token YYLEX-NUM. */ token YYLEX-NUM. */
static const yytype_uint16 yytoknum[] = static const yytype_uint16 yytoknum[] = {
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
91, 40, 41, 93 91, 40, 41, 93
}; };
#endif #endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] = static const yytype_uint8 yyr1[] = {
{
0, 14, 15, 16, 16, 16, 16, 16, 17, 17, 0, 14, 15, 16, 16, 16, 16, 16, 17, 17,
17, 17, 18, 19 17, 17, 18, 19
}; };
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] = static const yytype_uint8 yyr2[] = {
{
0, 2, 1, 1, 3, 3, 3, 4, 1, 2, 0, 2, 1, 1, 3, 3, 3, 4, 1, 2,
2, 4, 1, 1 2, 4, 1, 1
}; };
@ -476,32 +454,28 @@ static const yytype_uint8 yyr2[] =
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
STATE-NUM when YYTABLE doesn't specify something else to do. Zero STATE-NUM when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] = {
{
0, 13, 0, 0, 0, 0, 0, 2, 3, 8, 0, 13, 0, 0, 0, 0, 0, 2, 3, 8,
9, 10, 0, 0, 1, 0, 0, 0, 0, 4, 9, 10, 0, 0, 1, 0, 0, 0, 0, 4,
5, 6, 12, 0, 11, 7 5, 6, 12, 0, 11, 7
}; };
/* YYDEFGOTO[NTERM-NUM]. */ /* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] = static const yytype_int8 yydefgoto[] = {
{
-1, 6, 7, 8, 23, 9 -1, 6, 7, 8, 23, 9
}; };
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */ STATE-NUM. */
#define YYPACT_NINF -10 #define YYPACT_NINF -10
static const yytype_int8 yypact[] = static const yytype_int8 yypact[] = {
{
1, -10, 1, 1, -9, 1, 5, 17, -10, -10, 1, -10, 1, 1, -9, 1, 5, 17, -10, -10,
17, 17, 1, 7, -10, 4, 4, 6, 10, -10, 17, 17, 1, 7, -10, 4, 4, 6, 10, -10,
-10, -10, -10, 13, -10, -10 -10, -10, -10, 13, -10, -10
}; };
/* YYPGOTO[NTERM-NUM]. */ /* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = static const yytype_int8 yypgoto[] = {
{
-10, -10, -2, -10, -10, 9 -10, -10, -2, -10, -10, 9
}; };
@ -510,15 +484,13 @@ static const yytype_int8 yypgoto[] =
number is the opposite. If zero, do what YYDEFACT says. number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */ If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -1 #define YYTABLE_NINF -1
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] = {
{
10, 11, 12, 13, 1, 14, 2, 1, 3, 4, 10, 11, 12, 13, 1, 14, 2, 1, 3, 4,
18, 15, 5, 16, 15, 22, 16, 17, 0, 19, 18, 15, 5, 16, 15, 22, 16, 17, 0, 19,
17, 15, 24, 16, 20, 21, 25, 17 17, 15, 24, 16, 20, 21, 25, 17
}; };
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] = {
{
2, 3, 11, 5, 3, 0, 5, 3, 7, 8, 2, 3, 11, 5, 3, 0, 5, 3, 7, 8,
12, 4, 11, 6, 4, 9, 6, 10, -1, 12, 12, 4, 11, 6, 4, 9, 6, 10, -1, 12,
10, 4, 12, 6, 15, 16, 13, 10 10, 4, 12, 6, 15, 16, 13, 10
@ -526,8 +498,7 @@ static const yytype_int8 yycheck[] =
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */ symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] = static const yytype_uint8 yystos[] = {
{
0, 3, 5, 7, 8, 11, 15, 16, 17, 19, 0, 3, 5, 7, 8, 11, 15, 16, 17, 19,
16, 16, 11, 16, 0, 4, 6, 10, 16, 12, 16, 16, 11, 16, 0, 4, 6, 10, 16, 12,
19, 19, 9, 18, 12, 13 19, 19, 9, 18, 12, 13
@ -542,7 +513,6 @@ static const yytype_uint8 yystos[] =
#define YYABORT goto yyabortlab #define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab #define YYERROR goto yyerrorlab
/* Like YYERROR except do call yyerror. This remains here temporarily /* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC. to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */ Once GCC version 2 has supplanted version 1, this can go. */
@ -553,26 +523,21 @@ static const yytype_uint8 yystos[] =
#define YYBACKUP(Token, Value) \ #define YYBACKUP(Token, Value) \
do \ do \
if (yychar == YYEMPTY && yylen == 1) \ if (yychar == YYEMPTY && yylen == 1) { \
{ \
yychar = (Token); \ yychar = (Token); \
yylval = (Value); \ yylval = (Value); \
yytoken = YYTRANSLATE(yychar); \ yytoken = YYTRANSLATE(yychar); \
YYPOPSTACK(1); \ YYPOPSTACK(1); \
goto yybackup; \ goto yybackup; \
} \ } else { \
else \
{ \
yyerror(YY_("syntax error: cannot back up")); \ yyerror(YY_("syntax error: cannot back up")); \
YYERROR; \ YYERROR; \
} \ } \
while (YYID(0)) while (YYID(0))
#define YYTERROR 1 #define YYTERROR 1
#define YYERRCODE 256 #define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */ the previous symbol: RHS[0] (always defined). */
@ -581,24 +546,18 @@ while (YYID (0))
#ifndef YYLLOC_DEFAULT #ifndef YYLLOC_DEFAULT
#define YYLLOC_DEFAULT(Current, Rhs, N) \ #define YYLLOC_DEFAULT(Current, Rhs, N) \
do \ do \
if (YYID (N)) \ if (YYID(N)) { \
{ \
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \ (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
(Current).last_column = YYRHSLOC(Rhs, N).last_column; \ (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
} \ } else { \
else \ (Current).first_line = (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \
{ \ (Current).first_column = (Current).last_column = YYRHSLOC(Rhs, 0).last_column; \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \ } \
while (YYID(0)) while (YYID(0))
#endif #endif
/* YY_LOCATION_PRINT -- Print the location on the stream. /* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */ we won't break user code: when these are the locations we know. */
@ -614,7 +573,6 @@ while (YYID (0))
#endif #endif
#endif #endif
/* YYLEX -- calling `yylex' with the right arguments. */ /* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM #ifdef YYLEX_PARAM
@ -639,8 +597,7 @@ do { \
#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ #define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \ do { \
if (yydebug) \ if (yydebug) { \
{ \
YYFPRINTF(stderr, "%s ", Title); \ YYFPRINTF(stderr, "%s ", Title); \
yy_symbol_print(stderr, \ yy_symbol_print(stderr, \
Type, Value); \ Type, Value); \
@ -648,7 +605,6 @@ do { \
} \ } \
} while (YYID(0)) } while (YYID(0))
/*--------------------------------. /*--------------------------------.
| Print this symbol on YYOUTPUT. | | Print this symbol on YYOUTPUT. |
`--------------------------------*/ `--------------------------------*/
@ -674,14 +630,12 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep)
#else #else
YYUSE(yyoutput); YYUSE(yyoutput);
#endif #endif
switch (yytype) switch (yytype) {
{
default: default:
break; break;
} }
} }
/*--------------------------------. /*--------------------------------.
| Print this symbol on YYOUTPUT. | | Print this symbol on YYOUTPUT. |
`--------------------------------*/ `--------------------------------*/
@ -735,7 +689,6 @@ do { \
yy_stack_print((Bottom), (Top)); \ yy_stack_print((Bottom), (Top)); \
} while (YYID(0)) } while (YYID(0))
/*------------------------------------------------. /*------------------------------------------------.
| Report that the YYRULE is going to be reduced. | | Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/ `------------------------------------------------*/
@ -757,12 +710,10 @@ yy_reduce_print (yyvsp, yyrule)
YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n", YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno); yyrule - 1, yylno);
/* The symbols being reduced. */ /* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++) for (yyi = 0; yyi < yynrhs; yyi++) {
{
fprintf(stderr, " $%d = ", yyi + 1); fprintf(stderr, " $%d = ", yyi + 1);
yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi], yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)]) &(yyvsp[(yyi + 1) - (yynrhs)]));
);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
} }
@ -783,7 +734,6 @@ int yydebug;
#define YY_REDUCE_PRINT(Rule) #define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */ #endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */ /* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH #ifndef YYINITDEPTH
#define YYINITDEPTH 200 #define YYINITDEPTH 200
@ -800,8 +750,6 @@ int yydebug;
#define YYMAXDEPTH 10000 #define YYMAXDEPTH 10000
#endif #endif
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
#ifndef yystrlen #ifndef yystrlen
@ -839,8 +787,7 @@ static char *
yystpcpy(char* yydest, const char* yysrc) yystpcpy(char* yydest, const char* yysrc)
#else #else
static char* static char*
yystpcpy (yydest, yysrc) yystpcpy(yydest, yysrc) char* yydest;
char *yydest;
const char* yysrc; const char* yysrc;
#endif #endif
{ {
@ -866,14 +813,12 @@ yystpcpy (yydest, yysrc)
static YYSIZE_T static YYSIZE_T
yytnamerr(char* yyres, const char* yystr) yytnamerr(char* yyres, const char* yystr)
{ {
if (*yystr == '"') if (*yystr == '"') {
{
YYSIZE_T yyn = 0; YYSIZE_T yyn = 0;
char const* yyp = yystr; char const* yyp = yystr;
for (;;) for (;;)
switch (*++yyp) switch (*++yyp) {
{
case '\'': case '\'':
case ',': case ',':
goto do_not_strip_quotes; goto do_not_strip_quotes;
@ -917,8 +862,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) if (!(YYPACT_NINF < yyn && yyn <= YYLAST))
return 0; return 0;
else else {
{
int yytype = YYTRANSLATE(yychar); int yytype = YYTRANSLATE(yychar);
YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]); YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
YYSIZE_T yysize = yysize0; YYSIZE_T yysize = yysize0;
@ -961,10 +905,8 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
yyfmt = yystpcpy(yyformat, yyunexpected); yyfmt = yystpcpy(yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx) for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
{ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1; yycount = 1;
yysize = yysize0; yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0'; yyformat[sizeof yyunexpected - 1] = '\0';
@ -986,22 +928,17 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
if (yysize_overflow) if (yysize_overflow)
return YYSIZE_MAXIMUM; return YYSIZE_MAXIMUM;
if (yyresult) if (yyresult) {
{
/* Avoid sprintf, as that infringes on the user's name space. /* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */ produced a string with the wrong number of "%s"s. */
char* yyp = yyresult; char* yyp = yyresult;
int yyi = 0; int yyi = 0;
while ((*yyp = *yyf) != '\0') while ((*yyp = *yyf) != '\0') {
{ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
{
yyp += yytnamerr(yyp, yyarg[yyi++]); yyp += yytnamerr(yyp, yyarg[yyi++]);
yyf += 2; yyf += 2;
} } else {
else
{
yyp++; yyp++;
yyf++; yyf++;
} }
@ -1011,7 +948,6 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
} }
} }
#endif /* YYERROR_VERBOSE */ #endif /* YYERROR_VERBOSE */
/*-----------------------------------------------. /*-----------------------------------------------.
| Release the memory associated to this symbol. | | Release the memory associated to this symbol. |
@ -1036,14 +972,12 @@ yydestruct (yymsg, yytype, yyvaluep)
yymsg = "Deleting"; yymsg = "Deleting";
YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp); YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
switch (yytype) switch (yytype) {
{
default: default:
break; break;
} }
} }
/* Prevent warnings from -Wmissing-prototypes. */ /* Prevent warnings from -Wmissing-prototypes. */
@ -1061,8 +995,6 @@ int yyparse ();
#endif #endif
#endif /* ! YYPARSE_PARAM */ #endif /* ! YYPARSE_PARAM */
/* The look-ahead symbol. */ /* The look-ahead symbol. */
int yychar; int yychar;
@ -1072,8 +1004,6 @@ YYSTYPE yylval;
/* Number of syntax errors so far. */ /* Number of syntax errors so far. */
int yynerrs; int yynerrs;
/*----------. /*----------.
| yyparse. | | yyparse. |
`----------*/ `----------*/
@ -1081,21 +1011,17 @@ int yynerrs;
#ifdef YYPARSE_PARAM #ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
int int yyparse(void* YYPARSE_PARAM)
yyparse (void *YYPARSE_PARAM)
#else #else
int int
yyparse (YYPARSE_PARAM) yyparse(YYPARSE_PARAM) void* YYPARSE_PARAM;
void *YYPARSE_PARAM;
#endif #endif
#else /* ! YYPARSE_PARAM */ #else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
int int yyparse(void)
yyparse (void)
#else #else
int int yyparse()
yyparse ()
#endif #endif
#endif #endif
@ -1133,8 +1059,6 @@ yyparse ()
YYSTYPE* yyvs = yyvsa; YYSTYPE* yyvs = yyvsa;
YYSTYPE* yyvsp; YYSTYPE* yyvsp;
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
YYSIZE_T yystacksize = YYINITDEPTH; YYSIZE_T yystacksize = YYINITDEPTH;
@ -1143,7 +1067,6 @@ yyparse ()
action routines. */ action routines. */
YYSTYPE yyval; YYSTYPE yyval;
/* The number of symbols on the RHS of the reduced rule. /* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */ Keep to zero when no symbol should be popped. */
int yylen = 0; int yylen = 0;
@ -1176,8 +1099,7 @@ yyparse ()
yysetstate: yysetstate:
*yyssp = yystate; *yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp) if (yyss + yystacksize - 1 <= yyssp) {
{
/* Get the current used size of the three stacks, in elements. */ /* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1; YYSIZE_T yysize = yyssp - yyss + 1;
@ -1189,7 +1111,6 @@ yyparse ()
YYSTYPE* yyvs1 = yyvs; YYSTYPE* yyvs1 = yyvs;
yytype_int16* yyss1 = yyss; yytype_int16* yyss1 = yyss;
/* Each stack pointer address is followed by the size of the /* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might conditional around just the two extra args, but that might
@ -1216,8 +1137,7 @@ yyparse ()
{ {
yytype_int16* yyss1 = yyss; yytype_int16* yyss1 = yyss;
union yyalloc *yyptr = union yyalloc* yyptr = (union yyalloc*)YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize));
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (!yyptr) if (!yyptr)
goto yyexhaustedlab; goto yyexhaustedlab;
YYSTACK_RELOCATE(yyss); YYSTACK_RELOCATE(yyss);
@ -1233,7 +1153,6 @@ yyparse ()
yyssp = yyss + yysize - 1; yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1; yyvsp = yyvs + yysize - 1;
YYDPRINTF((stderr, "Stack size increased to %lu\n", YYDPRINTF((stderr, "Stack size increased to %lu\n",
(unsigned long int)yystacksize)); (unsigned long int)yystacksize));
@ -1261,19 +1180,15 @@ yybackup:
/* Not known => get a look-ahead token if don't already have one. */ /* Not known => get a look-ahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
if (yychar == YYEMPTY) if (yychar == YYEMPTY) {
{
YYDPRINTF((stderr, "Reading a token: ")); YYDPRINTF((stderr, "Reading a token: "));
yychar = YYLEX; yychar = YYLEX;
} }
if (yychar <= YYEOF) if (yychar <= YYEOF) {
{
yychar = yytoken = YYEOF; yychar = yytoken = YYEOF;
YYDPRINTF((stderr, "Now at end of input.\n")); YYDPRINTF((stderr, "Now at end of input.\n"));
} } else {
else
{
yytoken = YYTRANSLATE(yychar); yytoken = YYTRANSLATE(yychar);
YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc); YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
} }
@ -1284,8 +1199,7 @@ yybackup:
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault; goto yydefault;
yyn = yytable[yyn]; yyn = yytable[yyn];
if (yyn <= 0) if (yyn <= 0) {
{
if (yyn == 0 || yyn == YYTABLE_NINF) if (yyn == 0 || yyn == YYTABLE_NINF)
goto yyerrlab; goto yyerrlab;
yyn = -yyn; yyn = -yyn;
@ -1312,7 +1226,6 @@ yybackup:
goto yynewstate; goto yynewstate;
/*-----------------------------------------------------------. /*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. | | yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/ `-----------------------------------------------------------*/
@ -1322,7 +1235,6 @@ yydefault:
goto yyerrlab; goto yyerrlab;
goto yyreduce; goto yyreduce;
/*-----------------------------. /*-----------------------------.
| yyreduce -- Do a reduction. | | yyreduce -- Do a reduction. |
`-----------------------------*/ `-----------------------------*/
@ -1340,74 +1252,96 @@ yyreduce:
GCC warning that YYVAL may be used uninitialized. */ GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1 - yylen]; yyval = yyvsp[1 - yylen];
YY_REDUCE_PRINT(yyn); YY_REDUCE_PRINT(yyn);
switch (yyn) switch (yyn) {
{
case 2: case 2:
#line 32 "expr.ypp" #line 32 "expr.ypp"
{ result = (yyvsp[(1) - (1)]); ;} {
break; result = (yyvsp[(1) - (1)]);
;
} break;
case 3: case 3:
#line 36 "expr.ypp" #line 36 "expr.ypp"
{ (yyval) = (yyvsp[(1) - (1)]); ;} {
break; (yyval) = (yyvsp[(1) - (1)]);
;
} break;
case 4: case 4:
#line 37 "expr.ypp" #line 37 "expr.ypp"
{ (yyval) = (yyvsp[(2) - (3)]); ;} {
break; (yyval) = (yyvsp[(2) - (3)]);
;
} break;
case 5: case 5:
#line 38 "expr.ypp" #line 38 "expr.ypp"
{ (yyval) = exprNodeDot((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;} {
break; (yyval) = exprNodeDot((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
;
} break;
case 6: case 6:
#line 39 "expr.ypp" #line 39 "expr.ypp"
{ (yyval) = exprNodeArrow((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;} {
break; (yyval) = exprNodeArrow((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
;
} break;
case 7: case 7:
#line 40 "expr.ypp" #line 40 "expr.ypp"
{ (yyval) = exprNodeArray((yyvsp[(1) - (4)]), (yyvsp[(3) - (4)])); ;} {
break; (yyval) = exprNodeArray((yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));
;
} break;
case 8: case 8:
#line 43 "expr.ypp" #line 43 "expr.ypp"
{ (yyval) = (yyvsp[(1) - (1)]); ;} {
break; (yyval) = (yyvsp[(1) - (1)]);
;
} break;
case 9: case 9:
#line 44 "expr.ypp" #line 44 "expr.ypp"
{ (yyval) = exprNodeStar((yyvsp[(2) - (2)])); ;} {
break; (yyval) = exprNodeStar((yyvsp[(2) - (2)]));
;
} break;
case 10: case 10:
#line 45 "expr.ypp" #line 45 "expr.ypp"
{ (yyval) = exprNodeAddr((yyvsp[(2) - (2)])); ;} {
break; (yyval) = exprNodeAddr((yyvsp[(2) - (2)]));
;
} break;
case 11: case 11:
#line 46 "expr.ypp" #line 46 "expr.ypp"
{ (yyval) = exprNodeSizeof((yyvsp[(3) - (4)])); ;} {
break; (yyval) = exprNodeSizeof((yyvsp[(3) - (4)]));
;
} break;
case 12: case 12:
#line 50 "expr.ypp" #line 50 "expr.ypp"
{ (yyval) = exprNodeNumber(); ;} {
break; (yyval) = exprNodeNumber();
;
} break;
case 13: case 13:
#line 54 "expr.ypp" #line 54 "expr.ypp"
{(yyval) = exprNodeIdentifier(); ;} {
break; (yyval) = exprNodeIdentifier();
;
} break;
/* Line 1267 of yacc.c. */ /* Line 1267 of yacc.c. */
#line 1410 "expr.tab.cpp" #line 1410 "expr.tab.cpp"
default: break; default:
break;
} }
YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc); YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@ -1417,7 +1351,6 @@ yyreduce:
*++yyvsp = yyval; *++yyvsp = yyval;
/* Now `shift' the result of the reduction. Determine what state /* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule that goes to, based on the state we popped back to and the rule
number reduced by. */ number reduced by. */
@ -1432,22 +1365,19 @@ yyreduce:
goto yynewstate; goto yynewstate;
/*------------------------------------. /*------------------------------------.
| yyerrlab -- here on detecting error | | yyerrlab -- here on detecting error |
`------------------------------------*/ `------------------------------------*/
yyerrlab: yyerrlab:
/* If not already recovering from an error, report this error. */ /* If not already recovering from an error, report this error. */
if (!yyerrstatus) if (!yyerrstatus) {
{
++yynerrs; ++yynerrs;
#if !YYERROR_VERBOSE #if !YYERROR_VERBOSE
yyerror(YY_("syntax error")); yyerror(YY_("syntax error"));
#else #else
{ {
YYSIZE_T yysize = yysyntax_error(0, yystate, yychar); YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
{
YYSIZE_T yyalloc = 2 * yysize; YYSIZE_T yyalloc = 2 * yysize;
if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
yyalloc = YYSTACK_ALLOC_MAXIMUM; yyalloc = YYSTACK_ALLOC_MAXIMUM;
@ -1456,20 +1386,16 @@ yyerrlab:
yymsg = (char*)YYSTACK_ALLOC(yyalloc); yymsg = (char*)YYSTACK_ALLOC(yyalloc);
if (yymsg) if (yymsg)
yymsg_alloc = yyalloc; yymsg_alloc = yyalloc;
else else {
{
yymsg = yymsgbuf; yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf; yymsg_alloc = sizeof yymsgbuf;
} }
} }
if (0 < yysize && yysize <= yymsg_alloc) if (0 < yysize && yysize <= yymsg_alloc) {
{
(void)yysyntax_error(yymsg, yystate, yychar); (void)yysyntax_error(yymsg, yystate, yychar);
yyerror(yymsg); yyerror(yymsg);
} } else {
else
{
yyerror(YY_("syntax error")); yyerror(YY_("syntax error"));
if (yysize != 0) if (yysize != 0)
goto yyexhaustedlab; goto yyexhaustedlab;
@ -1478,21 +1404,15 @@ yyerrlab:
#endif #endif
} }
if (yyerrstatus == 3) {
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse look-ahead token after an /* If just tried and failed to reuse look-ahead token after an
error, discard it. */ error, discard it. */
if (yychar <= YYEOF) if (yychar <= YYEOF) {
{
/* Return failure if at end of input. */ /* Return failure if at end of input. */
if (yychar == YYEOF) if (yychar == YYEOF)
YYABORT; YYABORT;
} } else {
else
{
yydestruct("Error: discarding", yydestruct("Error: discarding",
yytoken, &yylval); yytoken, &yylval);
yychar = YYEMPTY; yychar = YYEMPTY;
@ -1503,7 +1423,6 @@ yyerrlab:
token. */ token. */
goto yyerrlab1; goto yyerrlab1;
/*---------------------------------------------------. /*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. | | yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/ `---------------------------------------------------*/
@ -1523,21 +1442,17 @@ yyerrorlab:
yystate = *yyssp; yystate = *yyssp;
goto yyerrlab1; goto yyerrlab1;
/*-------------------------------------------------------------. /*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. | | yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/ `-------------------------------------------------------------*/
yyerrlab1: yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */ yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;) for (;;) {
{
yyn = yypact[yystate]; yyn = yypact[yystate];
if (yyn != YYPACT_NINF) if (yyn != YYPACT_NINF) {
{
yyn += YYTERROR; yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
{
yyn = yytable[yyn]; yyn = yytable[yyn];
if (0 < yyn) if (0 < yyn)
break; break;
@ -1548,7 +1463,6 @@ yyerrlab1:
if (yyssp == yyss) if (yyssp == yyss)
YYABORT; YYABORT;
yydestruct("Error: popping", yydestruct("Error: popping",
yystos[yystate], yyvsp); yystos[yystate], yyvsp);
YYPOPSTACK(1); YYPOPSTACK(1);
@ -1561,14 +1475,12 @@ yyerrlab1:
*++yyvsp = yylval; *++yyvsp = yylval;
/* Shift the error token. */ /* Shift the error token. */
YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp); YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn; yystate = yyn;
goto yynewstate; goto yynewstate;
/*-------------------------------------. /*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. | | yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/ `-------------------------------------*/
@ -1601,8 +1513,7 @@ yyreturn:
this YYABORT or YYACCEPT. */ this YYABORT or YYACCEPT. */
YYPOPSTACK(yylen); YYPOPSTACK(yylen);
YY_STACK_PRINT(yyss, yyssp); YY_STACK_PRINT(yyss, yyssp);
while (yyssp != yyss) while (yyssp != yyss) {
{
yydestruct("Cleanup: popping", yydestruct("Cleanup: popping",
yystos[*yyssp], yyvsp); yystos[*yyssp], yyvsp);
YYPOPSTACK(1); YYPOPSTACK(1);
@ -1619,10 +1530,8 @@ yyreturn:
return YYID(yyresult); return YYID(yyresult);
} }
#line 57 "expr.ypp" #line 57 "expr.ypp"
int yyerror(const char* s) int yyerror(const char* s)
{ {
return 0; return 0;
@ -1642,4 +1551,3 @@ int main(int argc, char **argv)
result->print(); result->print();
} }
#endif #endif

View File

@ -16,13 +16,13 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "../common/Port.h"
#include "../gba/GBA.h" #include "../gba/GBA.h"
#include "../gba/elf.h" #include "../gba/elf.h"
#include "../common/Port.h"
#include "exprNode.h" #include "exprNode.h"
#ifndef __GNUC__ #ifndef __GNUC__
@ -163,8 +163,7 @@ bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
if (n->expression->resolve(n->expression, f, u)) { if (n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type; TypeEnum tt = n->expression->type->type;
if(tt == TYPE_struct || if (tt == TYPE_struct || tt == TYPE_union) {
tt == TYPE_union) {
u32 loc = n->expression->location; u32 loc = n->expression->location;
Type* t = n->expression->type; Type* t = n->expression->type;
int count = t->structure->memberCount; int count = t->structure->memberCount;
@ -225,8 +224,7 @@ bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
} }
tt = n->expression->type->pointer->type; tt = n->expression->type->pointer->type;
if(tt == TYPE_struct || if (tt == TYPE_struct || tt == TYPE_union) {
tt == TYPE_union) {
u32 loc = debuggerReadMemory(n->expression->location); u32 loc = debuggerReadMemory(n->expression->location);
Type* t = n->expression->type->pointer; Type* t = n->expression->type->pointer;
int count = t->structure->memberCount; int count = t->structure->memberCount;
@ -361,8 +359,7 @@ bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
{ {
if (n->expression->resolve(n->expression, f, u)) { if (n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type; TypeEnum tt = n->expression->type->type;
if(tt != TYPE_array && if (tt != TYPE_array && tt != TYPE_pointer) {
tt != TYPE_pointer) {
printf("Object not of array or pointer type\n"); printf("Object not of array or pointer type\n");
return false; return false;
} }
@ -384,8 +381,7 @@ bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
n->type = n->expression->type; n->type = n->expression->type;
n->index = index + 1; n->index = index + 1;
n->locType = LOCATION_memory; n->locType = LOCATION_memory;
n->location = n->expression->location + n->location = n->expression->location + n->value * exprNodeGetSize(a, index);
n->value * exprNodeGetSize(a, index);
return true; return true;
} }
} }

View File

@ -146,9 +146,12 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth)
case k2xSaI: case k2xSaI:
case kSuper2xSaI: case kSuper2xSaI:
case kSuperEagle: case kSuperEagle:
if (colorDepth == 15) Init_2xSaI(555); if (colorDepth == 15)
else if (colorDepth == 16) Init_2xSaI(565); Init_2xSaI(555);
else Init_2xSaI(colorDepth); else if (colorDepth == 16)
Init_2xSaI(565);
else
Init_2xSaI(colorDepth);
break; break;
case khq2x: case khq2x:
case klq2x: case klq2x:
@ -218,10 +221,7 @@ u8 sdlStretcher[16384];
#ifdef _MSC_VER #ifdef _MSC_VER
#define SDL_CALL_STRETCHER \ #define SDL_CALL_STRETCHER \
{ \ { \
__asm mov eax, stretcher\ __asm mov eax, stretcher __asm mov edi, destPtr __asm mov esi, srcPtr __asm call eax \
__asm mov edi, destPtr\
__asm mov esi, srcPtr\
__asm call eax\
} }
#else #else
#define SDL_CALL_STRETCHER \ #define SDL_CALL_STRETCHER \
@ -632,7 +632,8 @@ bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth)
return true; return true;
} }
void sdlStretch1x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) { void sdlStretch1x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
{
int i; int i;
#ifndef C_CORE #ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher; u32* stretcher = (u32*)sdlStretcher;
@ -643,7 +644,8 @@ void sdlStretch1x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
dstPtr += dstPitch; dstPtr += dstPitch;
} }
} }
void sdlStretch2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) { void sdlStretch2x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
{
int i; int i;
#ifndef C_CORE #ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher; u32* stretcher = (u32*)sdlStretcher;
@ -656,7 +658,8 @@ void sdlStretch2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
dstPtr += dstPitch; dstPtr += dstPitch;
} }
} }
void sdlStretch3x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) { void sdlStretch3x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
{
int i; int i;
#ifndef C_CORE #ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher; u32* stretcher = (u32*)sdlStretcher;
@ -671,7 +674,8 @@ void sdlStretch3x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
dstPtr += dstPitch; dstPtr += dstPitch;
} }
} }
void sdlStretch4x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) { void sdlStretch4x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
{
int i; int i;
#ifndef C_CORE #ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher; u32* stretcher = (u32*)sdlStretcher;
@ -688,5 +692,3 @@ void sdlStretch4x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
dstPtr += dstPitch; dstPtr += dstPitch;
} }
} }

View File

@ -69,7 +69,10 @@ char *getFilterName(const int f);
// //
// List of available IFB filters // List of available IFB filters
enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter }; enum IFBFilter { kIFBNone,
kIBMotionBlur,
kIBSmart,
kInvalidIFBFilter };
// Function pointer type for an IFB filter function // Function pointer type for an IFB filter function
typedef void (*IFBFilterFunc)(u8*, u32, int, int); typedef void (*IFBFilterFunc)(u8*, u32, int, int);

View File

@ -187,7 +187,9 @@ int optopt = '?';
of the value of `ordering'. In the case of RETURN_IN_ORDER, only of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `optind' != ARGC. */ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; static enum { REQUIRE_ORDER,
PERMUTE,
RETURN_IN_ORDER } ordering;
/* Value of POSIXLY_CORRECT environment variable. */ /* Value of POSIXLY_CORRECT environment variable. */
static char* posixly_correct; static char* posixly_correct;
@ -509,8 +511,7 @@ int long_only;
is only used when the used in the GNU libc. */ is only used when the used in the GNU libc. */
#ifdef _LIBC #ifdef _LIBC
#define NONOPTION_P \ #define NONOPTION_P \
(argv[optind][0] != '-' || argv[optind][1] == '\0' || \ (argv[optind][0] != '-' || argv[optind][1] == '\0' || (optind < nonoption_flags_len && __getopt_nonoption_flags[optind] == '1'))
(optind < nonoption_flags_len && __getopt_nonoption_flags[optind] == '1'))
#else #else
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
#endif #endif
@ -601,9 +602,7 @@ int long_only;
This distinction seems to be the most useful approach. */ This distinction seems to be the most useful approach. */
if (longopts != NULL && if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index(optstring, argv[optind][1]))))) {
(argv[optind][1] == '-' ||
(long_only && (argv[optind][2] || !my_index(optstring, argv[optind][1]))))) {
char* nameend; char* nameend;
const struct option* p; const struct option* p;
const struct option* pfound = NULL; const struct option* pfound = NULL;
@ -619,8 +618,7 @@ int long_only;
or abbreviated matches. */ or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++) for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp(p->name, nextchar, nameend - nextchar)) { if (!strncmp(p->name, nextchar, nameend - nextchar)) {
if ((unsigned int)(nameend - nextchar) == if ((unsigned int)(nameend - nextchar) == (unsigned int)strlen(p->name)) {
(unsigned int)strlen(p->name)) {
/* Exact match found. */ /* Exact match found. */
pfound = p; pfound = p;
indfound = option_index; indfound = option_index;
@ -707,8 +705,7 @@ int long_only;
or the option starts with '--' or is not a valid short or the option starts with '--' or is not a valid short
option, then it's an error. option, then it's an error.
Otherwise interpret it as a short option. */ Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-' || if (!long_only || argv[optind][1] == '-' || my_index(optstring, *nextchar) == NULL) {
my_index(optstring, *nextchar) == NULL) {
if (opterr) { if (opterr) {
if (argv[optind][1] == '-') if (argv[optind][1] == '-')
/* --option */ /* --option */

View File

@ -29,20 +29,16 @@ static bool sdlCheckJoyKey(int key);
static bool sdlButtons[4][SDLBUTTONS_NUM] = { static bool sdlButtons[4][SDLBUTTONS_NUM] = {
{ false, false, false, false, false, false, { false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false,
false, false false, false },
},
{ false, false, false, false, false, false, { false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false,
false, false false, false },
},
{ false, false, false, false, false, false, { false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false,
false, false false, false },
},
{ false, false, false, false, false, false, { false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false,
false, false false, false }
}
}; };
static bool sdlMotionButtons[4] = { false, false, false, false }; static bool sdlMotionButtons[4] = { false, false, false, false };
@ -59,7 +55,8 @@ static uint32_t joypad[5][SDLBUTTONS_NUM] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ SDLK_LEFT, SDLK_RIGHT, {
SDLK_LEFT, SDLK_RIGHT,
SDLK_UP, SDLK_DOWN, SDLK_UP, SDLK_DOWN,
SDLK_z, SDLK_x, SDLK_z, SDLK_x,
SDLK_RETURN, SDLK_BACKSPACE, SDLK_RETURN, SDLK_BACKSPACE,
@ -77,50 +74,33 @@ static uint32_t defaultMotion[4] = {
SDLK_KP_4, SDLK_KP_6, SDLK_KP_8, SDLK_KP_2 SDLK_KP_4, SDLK_KP_6, SDLK_KP_8, SDLK_KP_2
}; };
static uint32_t sdlGetHatCode(const SDL_Event& event) static uint32_t sdlGetHatCode(const SDL_Event& event)
{ {
if (!event.jhat.value) return 0; if (!event.jhat.value)
return 0;
return ( return (
((event.jhat.which + 1) << 16) | ((event.jhat.which + 1) << 16) | 32 | (event.jhat.hat << 2) | (event.jhat.value & SDL_HAT_UP ? 0 : event.jhat.value & SDL_HAT_DOWN ? 1 : event.jhat.value & SDL_HAT_RIGHT ? 2 : event.jhat.value & SDL_HAT_LEFT ? 3 : 0));
32 |
(event.jhat.hat << 2) |
(
event.jhat.value & SDL_HAT_UP ? 0 :
event.jhat.value & SDL_HAT_DOWN ? 1 :
event.jhat.value & SDL_HAT_RIGHT ? 2 :
event.jhat.value & SDL_HAT_LEFT ? 3 : 0
)
);
} }
static uint32_t sdlGetButtonCode(const SDL_Event& event) static uint32_t sdlGetButtonCode(const SDL_Event& event)
{ {
return ( return (
((event.jbutton.which + 1) << 16) | ((event.jbutton.which + 1) << 16) | (event.jbutton.button + 0x80));
(event.jbutton.button + 0x80)
);
} }
static uint32_t sdlGetAxisCode(const SDL_Event& event) static uint32_t sdlGetAxisCode(const SDL_Event& event)
{ {
if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384) return 0; if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384)
return 0;
return ( return (
((event.jaxis.which + 1) << 16) | ((event.jaxis.which + 1) << 16) | (event.jaxis.axis << 1) | (event.jaxis.value > 16384 ? 1 : event.jaxis.value < -16384 ? 0 : 0));
(event.jaxis.axis << 1) |
(
event.jaxis.value > 16384 ? 1 :
event.jaxis.value < -16384 ? 0 : 0
)
);
} }
uint32_t inputGetEventCode(const SDL_Event& event) uint32_t inputGetEventCode(const SDL_Event& event)
{ {
switch(event.type) switch (event.type) {
{
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
return event.key.keysym.sym; return event.key.keysym.sym;
@ -160,8 +140,7 @@ bool inputGetAutoFire(EKey key)
{ {
int mask = 0; int mask = 0;
switch (key) switch (key) {
{
case KEY_BUTTON_A: case KEY_BUTTON_A:
mask = 1 << 0; mask = 1 << 0;
break; break;
@ -185,8 +164,7 @@ bool inputToggleAutoFire(EKey key)
{ {
int mask = 0; int mask = 0;
switch (key) switch (key) {
{
case KEY_BUTTON_A: case KEY_BUTTON_A:
mask = 1 << 0; mask = 1 << 0;
break; break;
@ -203,13 +181,10 @@ bool inputToggleAutoFire(EKey key)
break; break;
} }
if(autoFire & mask) if (autoFire & mask) {
{
autoFire &= ~mask; autoFire &= ~mask;
return false; return false;
} } else {
else
{
autoFire |= mask; autoFire |= mask;
return true; return true;
} }
@ -398,8 +373,7 @@ void inputInitJoysticks()
sdlNumDevices = SDL_NumJoysticks(); sdlNumDevices = SDL_NumJoysticks();
if (sdlNumDevices) if (sdlNumDevices)
sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices * sdlDevices = (SDL_Joystick**)calloc(1, sdlNumDevices * sizeof(SDL_Joystick**));
sizeof(SDL_Joystick **));
bool usesJoy = false; bool usesJoy = false;
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
@ -460,13 +434,14 @@ void inputProcessSDLEvent(const SDL_Event &event)
{ {
// fprintf(stdout, "%x\n", inputGetEventCode(event)); // fprintf(stdout, "%x\n", inputGetEventCode(event));
switch(event.type) switch (event.type) {
{
case SDL_KEYDOWN: case SDL_KEYDOWN:
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, true); if (!event.key.keysym.mod)
sdlUpdateKey(event.key.keysym.sym, true);
break; break;
case SDL_KEYUP: case SDL_KEYUP:
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, false); if (!event.key.keysym.mod)
sdlUpdateKey(event.key.keysym.sym, false);
break; break;
case SDL_JOYHATMOTION: case SDL_JOYHATMOTION:
sdlUpdateJoyHat(event.jhat.which, sdlUpdateJoyHat(event.jhat.which,
@ -615,4 +590,3 @@ EPad inputGetDefaultJoypad()
{ {
return sdlDefaultJoypad; return sdlDefaultJoypad;
} }

View File

@ -37,7 +37,12 @@ enum EKey {
KEY_BUTTON_AUTO_B KEY_BUTTON_AUTO_B
}; };
enum EPad { PAD_MAIN, PAD_1 = PAD_MAIN, PAD_2, PAD_3, PAD_4, PAD_DEFAULT }; enum EPad { PAD_MAIN,
PAD_1 = PAD_MAIN,
PAD_2,
PAD_3,
PAD_4,
PAD_DEFAULT };
/** /**
* Init the joysticks needed by the keymap. Verify that the keymap is compatible * Init the joysticks needed by the keymap. Verify that the keymap is compatible

View File

@ -51,8 +51,7 @@ void drawText(u8 *screen, int pitch, int x, int y,
screen += x * inc; screen += x * inc;
switch (systemColorDepth) { switch (systemColorDepth) {
case 16: case 16: {
{
while (*string) { while (*string) {
char c = *string++; char c = *string++;
u8* scr = screen; u8* scr = screen;
@ -66,8 +65,7 @@ void drawText(u8 *screen, int pitch, int x, int y,
if (trans) { if (trans) {
if (on) if (on)
*s = ((0xf) << systemRedShift) + *s = ((0xf) << systemRedShift) + ((*s & mask) >> 1);
((*s & mask) >>1);
} else { } else {
if (on) if (on)
*s = (0x1f) << systemRedShift; *s = (0x1f) << systemRedShift;
@ -78,10 +76,8 @@ void drawText(u8 *screen, int pitch, int x, int y,
} }
screen += inc * 8; screen += inc * 8;
} }
} } break;
break; case 24: {
case 24:
{
while (*string) { while (*string) {
char c = *string++; char c = *string++;
u8* scr = screen; u8* scr = screen;
@ -113,10 +109,8 @@ void drawText(u8 *screen, int pitch, int x, int y,
} }
screen += inc * 8; screen += inc * 8;
} }
} } break;
break; case 32: {
case 32:
{
while (*string) { while (*string) {
char c = *string++; char c = *string++;
u8* scr = screen; u8* scr = screen;
@ -141,8 +135,6 @@ void drawText(u8 *screen, int pitch, int x, int y,
} }
screen += inc * 8; screen += inc * 8;
} }
} } break;
break;
} }
} }

View File

@ -3,7 +3,6 @@
#include "AVIWrite.h" #include "AVIWrite.h"
#pragma comment(lib, "Vfw32") #pragma comment(lib, "Vfw32")
AVIWrite::AVIWrite() AVIWrite::AVIWrite()
{ {
m_failed = false; m_failed = false;
@ -24,7 +23,6 @@ AVIWrite::AVIWrite()
AVIFileInit(); AVIFileInit();
} }
AVIWrite::~AVIWrite() AVIWrite::~AVIWrite()
{ {
if (m_audioCompressed) { if (m_audioCompressed) {
@ -50,10 +48,10 @@ AVIWrite::~AVIWrite()
AVIFileExit(); AVIFileExit();
} }
bool AVIWrite::CreateAVIFile(LPCTSTR filename) bool AVIWrite::CreateAVIFile(LPCTSTR filename)
{ {
if( m_file || m_failed ) return false; if (m_file || m_failed)
return false;
HRESULT err = 0; HRESULT err = 0;
@ -62,8 +60,7 @@ bool AVIWrite::CreateAVIFile( LPCTSTR filename )
&m_file, &m_file,
filename, filename,
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE, OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
NULL NULL);
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;
@ -73,11 +70,11 @@ bool AVIWrite::CreateAVIFile( LPCTSTR filename )
return true; return true;
} }
// colorBits: 16, 24 or 32 // colorBits: 16, 24 or 32
bool AVIWrite::CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd) bool AVIWrite::CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd)
{ {
if( m_videoStream || m_failed ) return false; if (m_videoStream || m_failed)
return false;
HRESULT err = 0; HRESULT err = 0;
AVISTREAMINFO videoInfo; AVISTREAMINFO videoInfo;
@ -98,29 +95,25 @@ bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorB
err = AVIFileCreateStream( err = AVIFileCreateStream(
m_file, m_file,
&m_videoStream, &m_videoStream,
&videoInfo &videoInfo);
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;
return false; return false;
} }
// -- ask for compression settings -- // -- ask for compression settings --
if (AVISaveOptions( if (AVISaveOptions(
parentWnd, parentWnd,
0, 0,
1, 1,
&m_videoStream, &m_videoStream,
settings ) ) settings)) {
{
err = AVIMakeCompressedStream( err = AVIMakeCompressedStream(
&m_videoCompressed, &m_videoCompressed,
m_videoStream, m_videoStream,
settings[0], settings[0],
NULL NULL);
);
AVISaveOptionsFree(1, settings); AVISaveOptionsFree(1, settings);
if (FAILED(err)) { if (FAILED(err)) {
@ -133,7 +126,6 @@ bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorB
return false; return false;
} }
// -- initialize the video stream format -- // -- initialize the video stream format --
bitmapInfo.biSize = sizeof(bitmapInfo); bitmapInfo.biSize = sizeof(bitmapInfo);
bitmapInfo.biWidth = imageWidth; bitmapInfo.biWidth = imageWidth;
@ -148,28 +140,26 @@ bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorB
m_videoCompressed, m_videoCompressed,
0, 0,
&bitmapInfo, &bitmapInfo,
bitmapInfo.biSize + ( bitmapInfo.biClrUsed * sizeof( RGBQUAD ) ) bitmapInfo.biSize + (bitmapInfo.biClrUsed * sizeof(RGBQUAD)));
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;
return false; return false;
} }
m_frameRate = framesPerSecond; m_frameRate = framesPerSecond;
m_videoFrameSize = imageWidth * imageHeight * (colorBits >> 3); m_videoFrameSize = imageWidth * imageHeight * (colorBits >> 3);
return true; return true;
} }
// call AddVideoStream() first // call AddVideoStream() first
// channelCount: max. 2 // channelCount: max. 2
// sampleBits: max. 16 // sampleBits: max. 16
bool AVIWrite::CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd) bool AVIWrite::CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd)
{ {
if( m_audioStream || m_failed ) return false; if (m_audioStream || m_failed)
return false;
HRESULT err = 0; HRESULT err = 0;
AVISTREAMINFO audioInfo; AVISTREAMINFO audioInfo;
@ -190,15 +180,13 @@ bool AVIWrite::CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD samp
err = AVIFileCreateStream( err = AVIFileCreateStream(
m_file, m_file,
&m_audioStream, &m_audioStream,
&audioInfo &audioInfo);
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;
return false; return false;
} }
// -- initialize the audio stream format -- // -- initialize the audio stream format --
waveInfo.wFormatTag = WAVE_FORMAT_PCM; waveInfo.wFormatTag = WAVE_FORMAT_PCM;
waveInfo.nChannels = channelCount; waveInfo.nChannels = channelCount;
@ -213,8 +201,7 @@ bool AVIWrite::CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD samp
m_audioStream, m_audioStream,
0, 0,
&waveInfo, &waveInfo,
sizeof( waveInfo ) sizeof(waveInfo));
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;
@ -227,10 +214,10 @@ bool AVIWrite::CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD samp
return true; return true;
} }
bool AVIWrite::AddVideoFrame(LPVOID imageData) bool AVIWrite::AddVideoFrame(LPVOID imageData)
{ {
if( !m_videoStream || m_failed ) return false; if (!m_videoStream || m_failed)
return false;
HRESULT err = 0; HRESULT err = 0;
@ -242,8 +229,7 @@ bool AVIWrite::AddVideoFrame( LPVOID imageData )
m_videoFrameSize, m_videoFrameSize,
AVIIF_KEYFRAME, AVIIF_KEYFRAME,
NULL, NULL,
NULL NULL);
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;
@ -255,10 +241,10 @@ bool AVIWrite::AddVideoFrame( LPVOID imageData )
return true; return true;
} }
bool AVIWrite::AddAudioFrame(LPVOID soundData) bool AVIWrite::AddAudioFrame(LPVOID soundData)
{ {
if( !m_audioStream || m_failed ) return false; if (!m_audioStream || m_failed)
return false;
HRESULT err = 0; HRESULT err = 0;
@ -270,8 +256,7 @@ bool AVIWrite::AddAudioFrame( LPVOID soundData )
m_audioFrameSize, m_audioFrameSize,
0, 0,
NULL, NULL,
NULL NULL);
);
if (FAILED(err)) { if (FAILED(err)) {
m_failed = true; m_failed = true;

View File

@ -1,8 +1,7 @@
#include <vfw.h> #include <vfw.h>
// info: recreate the whole AVIWrite object if any method fails // info: recreate the whole AVIWrite object if any method fails
class AVIWrite class AVIWrite {
{
public: public:
AVIWrite(); AVIWrite();
virtual ~AVIWrite(); virtual ~AVIWrite();

View File

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "AboutDialog.h" #include "AboutDialog.h"
#include "../AutoBuild.h" #include "../AutoBuild.h"
#include "stdafx.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -11,7 +11,6 @@ static char THIS_FILE[] = __FILE__;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// AboutDialog dialog // AboutDialog dialog
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/) AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
: CDialog(AboutDialog::IDD, pParent) : CDialog(AboutDialog::IDD, pParent)
{ {
@ -19,7 +18,6 @@ AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
m_date = _T(__DATE__); m_date = _T(__DATE__);
} }
void AboutDialog::DoDataExchange(CDataExchange* pDX) void AboutDialog::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -30,7 +28,6 @@ void AboutDialog::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_DATE, m_date); DDX_Text(pDX, IDC_DATE, m_date);
} }
BEGIN_MESSAGE_MAP(AboutDialog, CDialog) BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
//{{AFX_MSG_MAP(AboutDialog) //{{AFX_MSG_MAP(AboutDialog)
//}}AFX_MSG_MAP //}}AFX_MSG_MAP

View File

@ -4,8 +4,7 @@
#include "resource.h" #include "resource.h"
#include "stdafx.h" #include "stdafx.h"
class AboutDialog : public CDialog class AboutDialog : public CDialog {
{
public: public:
AboutDialog(CWnd* pParent = NULL); AboutDialog(CWnd* pParent = NULL);
enum { IDD = IDD_ABOUT }; enum { IDD = IDD_ABOUT };

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "vba.h"
#include "AccelEditor.h" #include "AccelEditor.h"
#include "CmdAccelOb.h" #include "CmdAccelOb.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -12,7 +12,6 @@ static char THIS_FILE[] = __FILE__;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// AccelEditor dialog // AccelEditor dialog
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/) AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
: ResizeDlg(AccelEditor::IDD, pParent) : ResizeDlg(AccelEditor::IDD, pParent)
{ {
@ -22,7 +21,6 @@ AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
mgr = theApp.winAccelMgr; mgr = theApp.winAccelMgr;
} }
void AccelEditor::DoDataExchange(CDataExchange* pDX) void AccelEditor::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -34,7 +32,6 @@ void AccelEditor::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP //}}AFX_DATA_MAP
} }
BEGIN_MESSAGE_MAP(AccelEditor, CDialog) BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
//{{AFX_MSG_MAP(AccelEditor) //{{AFX_MSG_MAP(AccelEditor)
ON_BN_CLICKED(ID_OK, OnOk) ON_BN_CLICKED(ID_OK, OnOk)
@ -140,7 +137,6 @@ void AccelEditor::OnSelchangeCommands()
} }
// Init the key editor // Init the key editor
// m_pKey->ResetKey(); // m_pKey->ResetKey();
} }
void AccelEditor::OnReset() void AccelEditor::OnReset()

View File

@ -13,8 +13,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// AccelEditor dialog // AccelEditor dialog
class AccelEditor : public ResizeDlg class AccelEditor : public ResizeDlg {
{
// Construction // Construction
public: public:
CAcceleratorManager mgr; CAcceleratorManager mgr;

View File

@ -26,8 +26,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "VBA.h" #include "VBA.h"
#include "stdafx.h"
#include "AcceleratorManager.h" #include "AcceleratorManager.h"
#include "Reg.h" #include "Reg.h"
@ -38,8 +38,6 @@ static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Constructor/Destructor // Constructor/Destructor
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -55,7 +53,6 @@ CAcceleratorManager::CAcceleratorManager()
m_bDefaultTable = false; m_bDefaultTable = false;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -70,7 +67,6 @@ CAcceleratorManager::~CAcceleratorManager()
Reset(); Reset();
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Internal fcts // Internal fcts
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -96,7 +92,6 @@ void CAcceleratorManager::Reset()
m_mapAccelTableSaved.RemoveAll(); m_mapAccelTableSaved.RemoveAll();
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -119,8 +114,7 @@ bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTS
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) { while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos); pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->m_cVirt == cVirt && if (pAccel->m_cVirt == cVirt && pAccel->m_wKey == wKey)
pAccel->m_wKey == wKey)
return FALSE; return FALSE;
} }
// Adding the accelerator // Adding the accelerator
@ -136,7 +130,6 @@ bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTS
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Debug fcts // Debug fcts
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -174,7 +167,6 @@ void CAcceleratorManager::Dump(CDumpContext& dc) const
} }
#endif #endif
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -187,7 +179,6 @@ void CAcceleratorManager::Connect(CWnd* pWnd, bool bAutoSave)
m_bAutoSave = bAutoSave; m_bAutoSave = bAutoSave;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -201,7 +192,6 @@ bool CAcceleratorManager::GetRegKey(HKEY& hRegKey, CString& szRegKey)
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -215,7 +205,6 @@ bool CAcceleratorManager::SetRegKey(HKEY hRegKey, LPCTSTR szRegKey)
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Update the application's ACCELs table // Update the application's ACCELs table
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -285,7 +274,6 @@ bool CAcceleratorManager::UpdateWndTable()
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Create/Destroy accelerators // Create/Destroy accelerators
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -314,7 +302,6 @@ bool CAcceleratorManager::DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wKey)
return false; return false;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -337,7 +324,6 @@ bool CAcceleratorManager::DeleteEntry(WORD wIDCommand)
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -352,7 +338,6 @@ bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand)
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -363,7 +348,6 @@ bool CAcceleratorManager::SetAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTS
return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked); return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked);
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -389,7 +373,6 @@ bool CAcceleratorManager::AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bo
return bRet; return bRet;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -409,7 +392,6 @@ bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand)
return false; return false;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Get a string from the ACCEL definition // Get a string from the ACCEL definition
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -428,7 +410,6 @@ bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel)
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -443,7 +424,6 @@ bool CAcceleratorManager::GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& sz
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Copy function // Copy function
// //
@ -654,7 +634,6 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
return false; return false;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -670,7 +649,6 @@ bool CAcceleratorManager::Load()
return false; return false;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
@ -725,7 +703,6 @@ bool CAcceleratorManager::Write()
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Defaults values management. // Defaults values management.
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -773,7 +750,6 @@ bool CAcceleratorManager::CreateDefaultTable()
return true; return true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //

View File

@ -47,8 +47,7 @@ typedef CMap<WORD, WORD &, CCmdAccelOb *, CCmdAccelOb *&> CMapWordToCCmdAccelOb;
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
class CAcceleratorManager : public CObject class CAcceleratorManager : public CObject {
{
friend class AccelEditor; friend class AccelEditor;
public: public:

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "vba.h"
#include "Associate.h" #include "Associate.h"
#include "Reg.h" #include "Reg.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -12,7 +12,6 @@ static char THIS_FILE[] = __FILE__;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Associate dialog // Associate dialog
Associate::Associate(CWnd* pParent /*=NULL*/) Associate::Associate(CWnd* pParent /*=NULL*/)
: CDialog(Associate::IDD, pParent) : CDialog(Associate::IDD, pParent)
{ {
@ -28,7 +27,6 @@ Associate::Associate(CWnd* pParent /*=NULL*/)
//}}AFX_DATA_INIT //}}AFX_DATA_INIT
} }
void Associate::DoDataExchange(CDataExchange* pDX) void Associate::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -44,7 +42,6 @@ void Associate::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP //}}AFX_DATA_MAP
} }
BEGIN_MESSAGE_MAP(Associate, CDialog) BEGIN_MESSAGE_MAP(Associate, CDialog)
//{{AFX_MSG_MAP(Associate) //{{AFX_MSG_MAP(Associate)
ON_BN_CLICKED(ID_CANCEL, OnCancel) ON_BN_CLICKED(ID_CANCEL, OnCancel)

View File

@ -10,8 +10,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Associate dialog // Associate dialog
class Associate : public CDialog class Associate : public CDialog {
{
// Construction // Construction
public: public:
Associate(CWnd* pParent = NULL); // standard constructor Associate(CWnd* pParent = NULL); // standard constructor

View File

@ -1,12 +1,11 @@
#include "stdafx.h"
#include "VBA.h" #include "VBA.h"
#include "stdafx.h"
#include "AudioCoreSettingsDlg.h" #include "AudioCoreSettingsDlg.h"
#define MIN_VOLUME 0.0f #define MIN_VOLUME 0.0f
#define MAX_VOLUME 4.0f #define MAX_VOLUME 4.0f
// AudioCoreSettingsDlg dialog // AudioCoreSettingsDlg dialog
IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog) IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog)
@ -117,13 +116,11 @@ BOOL AudioCoreSettingsDlg::OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResul
return i_provided_tooltip_with_text; return i_provided_tooltip_with_text;
} }
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog) BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText) ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume) ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
END_MESSAGE_MAP() END_MESSAGE_MAP()
// AudioCoreSettingsDlg message handlers // AudioCoreSettingsDlg message handlers
BOOL AudioCoreSettingsDlg::OnInitDialog() BOOL AudioCoreSettingsDlg::OnInitDialog()

View File

@ -2,8 +2,7 @@
// AudioCoreSettingsDlg dialog // AudioCoreSettingsDlg dialog
class AudioCoreSettingsDlg : public CDialog class AudioCoreSettingsDlg : public CDialog {
{
DECLARE_DYNAMIC(AudioCoreSettingsDlg) DECLARE_DYNAMIC(AudioCoreSettingsDlg)
public: public:

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "VBA.h" #include "VBA.h"
#include "stdafx.h"
#include "BIOSDialog.h" #include "BIOSDialog.h"
// BIOSDialog dialog // BIOSDialog dialog
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog) IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
@ -50,14 +49,12 @@ void BIOSDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog) BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath) ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath)
ON_BN_CLICKED(IDC_SELECT_GBC_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbcBiosPath) ON_BN_CLICKED(IDC_SELECT_GBC_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbcBiosPath)
ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath) ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
END_MESSAGE_MAP() END_MESSAGE_MAP()
// BIOSDialog message handlers // BIOSDialog message handlers
void BIOSDialog::OnBnClickedSelectGbBiosPath() void BIOSDialog::OnBnClickedSelectGbBiosPath()

View File

@ -2,8 +2,7 @@
// BIOSDialog dialog // BIOSDialog dialog
class BIOSDialog : public CDialog class BIOSDialog : public CDialog {
{
DECLARE_DYNAMIC(BIOSDialog) DECLARE_DYNAMIC(BIOSDialog)
public: public:

View File

@ -1,6 +1,6 @@
#include "BitmapControl.h"
#include "stdafx.h" #include "stdafx.h"
#include "vba.h" #include "vba.h"
#include "BitmapControl.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -32,7 +32,6 @@ BitmapControl::~BitmapControl()
{ {
} }
BEGIN_MESSAGE_MAP(BitmapControl, CScrollView) BEGIN_MESSAGE_MAP(BitmapControl, CScrollView)
//{{AFX_MSG_MAP(BitmapControl) //{{AFX_MSG_MAP(BitmapControl)
ON_WM_ERASEBKGND() ON_WM_ERASEBKGND()
@ -110,8 +109,7 @@ void BitmapControl::OnDraw(CDC* dc)
dc->BitBlt(0, 0, w1, h1, dc->BitBlt(0, 0, w1, h1,
&memDC, 0, 0, SRCCOPY); &memDC, 0, 0, SRCCOPY);
if (boxreigon.right != 0 && boxreigon.bottom != 0) if (boxreigon.right != 0 && boxreigon.bottom != 0) {
{
CBrush br = CBrush(RGB(255, 0, 0)); CBrush br = CBrush(RGB(255, 0, 0));
dc->FrameRect(&boxreigon, &br); dc->FrameRect(&boxreigon, &br);
} }
@ -179,9 +177,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
int yyy = yy / 8; int yyy = yy / 8;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
memcpy(&colors[i*3*8], &data[xxx * 8 * 3 + memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
w * yyy * 8 * 3 +
i * w * 3], 8 * 3);
} }
} else { } else {
POINT p; POINT p;
@ -191,8 +187,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
p.x += x; p.x += x;
p.y += y; p.y += y;
if(p.x >= w || if (p.x >= w || p.y >= h)
p.y >= h)
return; return;
point = p.x | (p.y << 16); point = p.x | (p.y << 16);
@ -201,16 +196,13 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
int yyy = p.y / 8; int yyy = p.y / 8;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
memcpy(&colors[i*3*8], &data[xxx * 8 * 3 + memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
w * yyy * 8 * 3 +
i * w * 3], 8 * 3);
} }
} }
GetParent()->SendMessage(WM_MAPINFO, GetParent()->SendMessage(WM_MAPINFO,
point, point,
(LPARAM)colors); (LPARAM)colors);
} }
void BitmapControl::setBmpInfo(BITMAPINFO* info) void BitmapControl::setBmpInfo(BITMAPINFO* info)
@ -246,7 +238,6 @@ void BitmapControl::refresh()
Invalidate(); Invalidate();
} }
void BitmapControl::registerClass() void BitmapControl::registerClass()
{ {
if (!isRegistered) { if (!isRegistered) {

View File

@ -16,8 +16,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BitmapControl view // BitmapControl view
class BitmapControl : public CScrollView class BitmapControl : public CScrollView {
{
public: public:
BitmapControl(); // protected constructor used by dynamic creation BitmapControl(); // protected constructor used by dynamic creation
protected: protected:

View File

@ -19,17 +19,17 @@
// BugReport.cpp : implementation file // BugReport.cpp : implementation file
// //
#include "BugReport.h"
#include "stdafx.h" #include "stdafx.h"
#include "vba.h" #include "vba.h"
#include "BugReport.h"
#include "../agb/agbprint.h"
#include "../AutoBuild.h" #include "../AutoBuild.h"
#include "../agb/GBA.h"
#include "../Globals.h" #include "../Globals.h"
#include "../Port.h" #include "../Port.h"
#include "../RTC.h" #include "../RTC.h"
#include "../Sound.h" #include "../Sound.h"
#include "../agb/GBA.h"
#include "../agb/agbprint.h"
#include "../dmg/gbCheats.h" #include "../dmg/gbCheats.h"
#include "../dmg/gbGlobals.h" #include "../dmg/gbGlobals.h"
@ -42,7 +42,6 @@ static char THIS_FILE[] = __FILE__;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BugReport dialog // BugReport dialog
BugReport::BugReport(CWnd* pParent /*=NULL*/) BugReport::BugReport(CWnd* pParent /*=NULL*/)
: CDialog(BugReport::IDD, pParent) : CDialog(BugReport::IDD, pParent)
{ {
@ -51,7 +50,6 @@ BugReport::BugReport(CWnd* pParent /*=NULL*/)
//}}AFX_DATA_INIT //}}AFX_DATA_INIT
} }
void BugReport::DoDataExchange(CDataExchange* pDX) void BugReport::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -60,7 +58,6 @@ void BugReport::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP //}}AFX_DATA_MAP
} }
BEGIN_MESSAGE_MAP(BugReport, CDialog) BEGIN_MESSAGE_MAP(BugReport, CDialog)
//{{AFX_MSG_MAP(BugReport) //{{AFX_MSG_MAP(BugReport)
ON_BN_CLICKED(IDC_COPY, OnCopy) ON_BN_CLICKED(IDC_COPY, OnCopy)
@ -123,7 +120,6 @@ BOOL BugReport::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
} }
static void AppendFormat(CString& report, const char* format, ...) static void AppendFormat(CString& report, const char* format, ...)
{ {
CString buffer; CString buffer;

View File

@ -29,8 +29,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BugReport dialog // BugReport dialog
class BugReport : public CDialog class BugReport : public CDialog {
{
// Construction // Construction
public: public:
BugReport(CWnd* pParent = NULL); // standard constructor BugReport(CWnd* pParent = NULL); // standard constructor

View File

@ -26,8 +26,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CmdAccelOb.h" #include "CmdAccelOb.h"
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
@ -155,7 +155,6 @@ MAPVIRTKEYS mapVirtKeys[] = {
{ VK_OEM_CLEAR, "VK_OEM_CLEAR" }, { VK_OEM_CLEAR, "VK_OEM_CLEAR" },
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -165,7 +164,6 @@ MAPVIRTKEYS mapVirtSysKeys[] = {
{ FSHIFT, "Shift" }, { FSHIFT, "Shift" },
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// helper fct for external access // helper fct for external access
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -180,14 +178,11 @@ TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
return NULL; return NULL;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
#define DEFAULT_ACCEL 0x01 #define DEFAULT_ACCEL 0x01
#define USER_ACCEL 0x02 #define USER_ACCEL 0x02
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -200,7 +195,6 @@ CAccelsOb::CAccelsOb()
m_bLocked = false; m_bLocked = false;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -213,7 +207,6 @@ CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
m_bLocked = pFrom->m_bLocked; m_bLocked = pFrom->m_bLocked;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -224,7 +217,6 @@ CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
m_bLocked = bLocked; m_bLocked = bLocked;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -237,7 +229,6 @@ CAccelsOb::CAccelsOb(LPACCEL pACCEL)
m_bLocked = false; m_bLocked = false;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -250,7 +241,6 @@ CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
return *this; return *this;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -281,7 +271,6 @@ void CAccelsOb::GetString(CString& szBuffer)
AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid"); AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -290,7 +279,6 @@ bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
// CString szTemp; // CString szTemp;
// GetString(szTemp); // GetString(szTemp);
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false; bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
bool bRet = (bCtrl == m_bCtrl); bool bRet = (bCtrl == m_bCtrl);
@ -305,7 +293,6 @@ bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
return bRet; return bRet;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -321,7 +308,6 @@ DWORD CAccelsOb::GetData()
return MAKELONG(m_wKey, bCodes); return MAKELONG(m_wKey, bCodes);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -356,7 +342,6 @@ void CAccelsOb::Dump(CDumpContext& dc) const
dc << "\t\t"; dc << "\t\t";
CObject::Dump(dc); CObject::Dump(dc);
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n"; dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
} }
#endif #endif
@ -369,7 +354,6 @@ CCmdAccelOb::CCmdAccelOb()
{ {
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -381,7 +365,6 @@ CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
m_szCommand = szCommand; m_szCommand = szCommand;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -397,7 +380,6 @@ CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szComma
m_Accels.AddTail(pAccel); m_Accels.AddTail(pAccel);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -409,7 +391,6 @@ CCmdAccelOb::~CCmdAccelOb()
m_Accels.RemoveAll(); m_Accels.RemoveAll();
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -422,7 +403,6 @@ void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
m_Accels.AddTail(pAccel); m_Accels.AddTail(pAccel);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -432,7 +412,6 @@ void CCmdAccelOb::Add(CAccelsOb* pAccel)
m_Accels.AddTail(pAccel); m_Accels.AddTail(pAccel);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -453,7 +432,6 @@ CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
return *this; return *this;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -472,7 +450,6 @@ void CCmdAccelOb::DeleteUserAccels()
} }
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
@ -501,7 +478,6 @@ void CCmdAccelOb::AssertValid() const
CObject::AssertValid(); CObject::AssertValid();
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //

View File

@ -46,8 +46,7 @@ typedef struct tagMAPVIRTKEYS {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// //
class CAccelsOb : public CObject class CAccelsOb : public CObject {
{
public: public:
CAccelsOb(); CAccelsOb();
CAccelsOb(CAccelsOb* pFrom); CAccelsOb(CAccelsOb* pFrom);
@ -77,8 +76,7 @@ class CAccelsOb : public CObject
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// //
class CCmdAccelOb : public CObject class CCmdAccelOb : public CObject {
{
public: public:
CCmdAccelOb(); CCmdAccelOb();
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand); CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);

View File

@ -1,6 +1,6 @@
#include "ColorButton.h"
#include "stdafx.h" #include "stdafx.h"
#include "vba.h" #include "vba.h"
#include "ColorButton.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -23,7 +23,6 @@ ColorButton::~ColorButton()
{ {
} }
BEGIN_MESSAGE_MAP(ColorButton, CButton) BEGIN_MESSAGE_MAP(ColorButton, CButton)
//{{AFX_MSG_MAP(ColorButton) //{{AFX_MSG_MAP(ColorButton)
// NOTE - the ClassWizard will add and remove mapping macros here. // NOTE - the ClassWizard will add and remove mapping macros here.
@ -62,8 +61,7 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
InflateRect(&rect, -margins.cx, -margins.cy); InflateRect(&rect, -margins.cx, -margins.cy);
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? ::GetSysColor(COLOR_3DFACE) : RGB(r, g, b));
::GetSysColor(COLOR_3DFACE) : RGB(r,g,b));
FillRect(dc, &rect, br); FillRect(dc, &rect, br);

View File

@ -11,8 +11,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ColorButton window // ColorButton window
class ColorButton : public CButton class ColorButton : public CButton {
{
// Construction // Construction
public: public:
ColorButton(); ColorButton();

View File

@ -1,6 +1,6 @@
#include "ColorControl.h"
#include "stdafx.h" #include "stdafx.h"
#include "vba.h" #include "vba.h"
#include "ColorControl.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -23,7 +23,6 @@ ColorControl::~ColorControl()
{ {
} }
BEGIN_MESSAGE_MAP(ColorControl, CWnd) BEGIN_MESSAGE_MAP(ColorControl, CWnd)
//{{AFX_MSG_MAP(ColorControl) //{{AFX_MSG_MAP(ColorControl)
ON_WM_PAINT() ON_WM_PAINT()
@ -31,7 +30,6 @@ BEGIN_MESSAGE_MAP(ColorControl, CWnd)
//}}AFX_MSG_MAP //}}AFX_MSG_MAP
END_MESSAGE_MAP() END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ColorControl message handlers // ColorControl message handlers

View File

@ -11,8 +11,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ColorControl window // ColorControl window
class ColorControl : public CWnd class ColorControl : public CWnd {
{
// Construction // Construction
public: public:
ColorControl(); ColorControl();

View File

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "AcceleratorManager.h" #include "AcceleratorManager.h"
#include "resource.h" #include "resource.h"
#include "stdafx.h"
#include <afxres.h> #include <afxres.h>
#include <afxtempl.h> // MFC Templates extension #include <afxtempl.h> // MFC Templates extension
@ -228,5 +228,4 @@ void winAccelAddCommands(CAcceleratorManager& mgr)
if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false)) if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command); mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
} }
} }

View File

@ -8,26 +8,26 @@
#include "Display.h" #include "Display.h"
#include "MainWnd.h"
#include "FullscreenSettings.h" #include "FullscreenSettings.h"
#include "MainWnd.h"
#include "../System.h" #include "../System.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "../Util.h" #include "../Util.h"
#include "../gb/gbGlobals.h" #include "../gb/gbGlobals.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include <memory.h>
#include <cassert> #include <cassert>
#include <memory.h>
// Direct3D // Direct3D
#ifdef _DEBUG #ifdef _DEBUG
#define D3D_DEBUG_INFO #define D3D_DEBUG_INFO
#endif #endif
#define DIRECT3D_VERSION 0x0900 #define DIRECT3D_VERSION 0x0900
#include <d3d9.h> // main include file
#include <D3dx9core.h> // required for font rendering #include <D3dx9core.h> // required for font rendering
#include <Dxerr.h> // contains debug functions #include <Dxerr.h> // contains debug functions
#include <d3d9.h> // main include file
extern int Init_2xSaI(u32); // initializes all pixel filters extern int Init_2xSaI(u32); // initializes all pixel filters
extern int systemSpeed; extern int systemSpeed;
@ -132,7 +132,6 @@ public:
virtual bool selectFullScreenMode(VIDEO_MODE& mode); virtual bool selectFullScreenMode(VIDEO_MODE& mode);
}; };
Direct3DDisplay::Direct3DDisplay() Direct3DDisplay::Direct3DDisplay()
{ {
initialized = false; initialized = false;
@ -153,10 +152,10 @@ Direct3DDisplay::Direct3DDisplay()
pfthread_data = NULL; pfthread_data = NULL;
hThreads = NULL; hThreads = NULL;
nThreads = theApp.maxCpuCores; nThreads = theApp.maxCpuCores;
if( nThreads > 8 ) nThreads = 8; if (nThreads > 8)
nThreads = 8;
} }
Direct3DDisplay::~Direct3DDisplay() Direct3DDisplay::~Direct3DDisplay()
{ {
cleanup(); cleanup();
@ -183,7 +182,6 @@ void Direct3DDisplay::prepareDisplayMode()
dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
// D3DPRESENT_INTERVAL_ONE means VSync ON // D3DPRESENT_INTERVAL_ONE means VSync ON
#ifdef _DEBUG #ifdef _DEBUG
// make debugging full screen easier // make debugging full screen easier
if (dpp.Windowed == FALSE) { if (dpp.Windowed == FALSE) {
@ -202,7 +200,6 @@ void Direct3DDisplay::prepareDisplayMode()
#endif #endif
} }
void Direct3DDisplay::cleanup() void Direct3DDisplay::cleanup()
{ {
if (hThreads) { if (hThreads) {
@ -229,7 +226,6 @@ void Direct3DDisplay::cleanup()
} }
} }
bool Direct3DDisplay::initialize() bool Direct3DDisplay::initialize()
{ {
#ifdef _DEBUG #ifdef _DEBUG
@ -276,7 +272,6 @@ bool Direct3DDisplay::initialize()
fsColorDepth = systemColorDepth; fsColorDepth = systemColorDepth;
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1); utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
#ifdef MMX #ifdef MMX
if (!disableMMX) { if (!disableMMX) {
cpu_mmx = theApp.detectMMX(); cpu_mmx = theApp.detectMMX();
@ -285,11 +280,9 @@ bool Direct3DDisplay::initialize()
} }
#endif #endif
theApp.updateFilter(); theApp.updateFilter();
theApp.updateIFB(); theApp.updateIFB();
// create device // create device
// Direct3D will use the selected full screen adapter for windowed mode as well // Direct3D will use the selected full screen adapter for windowed mode as well
prepareDisplayMode(); prepareDisplayMode();
@ -298,8 +291,7 @@ bool Direct3DDisplay::initialize()
fsAdapter, fsAdapter,
D3DDEVTYPE_HAL, D3DDEVTYPE_HAL,
theApp.m_pMainWnd->GetSafeHwnd(), theApp.m_pMainWnd->GetSafeHwnd(),
D3DCREATE_FPU_PRESERVE | D3DCREATE_FPU_PRESERVE | D3DCREATE_SOFTWARE_VERTEXPROCESSING,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&dpp, &dpp,
&pDevice); &pDevice);
if (FAILED(hret)) { if (FAILED(hret)) {
@ -326,7 +318,8 @@ bool Direct3DDisplay::initialize()
failed = true; failed = true;
} }
if(failed) return false; if (failed)
return false;
initialized = true; initialized = true;
@ -337,7 +330,6 @@ bool Direct3DDisplay::initialize()
return TRUE; return TRUE;
} }
void Direct3DDisplay::clear() void Direct3DDisplay::clear()
{ {
if (pDevice) { if (pDevice) {
@ -349,11 +341,12 @@ void Direct3DDisplay::clear()
} }
} }
void Direct3DDisplay::render() void Direct3DDisplay::render()
{ {
if( failed ) return; if (failed)
if(!pDevice) return; return;
if (!pDevice)
return;
// Multi-Tasking fix // Multi-Tasking fix
HRESULT hr = pDevice->TestCooperativeLevel(); HRESULT hr = pDevice->TestCooperativeLevel();
@ -455,13 +448,11 @@ void Direct3DDisplay::render()
(u8*)lr.pBits, (u8*)lr.pBits,
lr.Pitch, lr.Pitch,
sizeX, sizeX,
sizeY sizeY);
);
} }
} else { } else {
// pixel filter disabled // pixel filter disabled
switch( systemColorDepth ) switch (systemColorDepth) {
{
case 32: case 32:
cpyImg32( cpyImg32(
(unsigned char*)lr.pBits, (unsigned char*)lr.pBits,
@ -469,8 +460,7 @@ void Direct3DDisplay::render()
pix + pitch, pix + pitch,
pitch, pitch,
sizeX, sizeX,
sizeY sizeY);
);
break; break;
case 16: case 16:
cpyImg16( cpyImg16(
@ -479,8 +469,7 @@ void Direct3DDisplay::render()
pix + pitch, pix + pitch,
pitch, pitch,
sizeX, sizeX,
sizeY sizeY);
);
break; break;
} }
} }
@ -488,7 +477,6 @@ void Direct3DDisplay::render()
pDevice->UpdateTexture(tempImage, emulatedImage[mbCurrentTexture]); pDevice->UpdateTexture(tempImage, emulatedImage[mbCurrentTexture]);
} }
if (!theApp.d3dMotionBlur) { if (!theApp.d3dMotionBlur) {
// draw the current frame to the screen // draw the current frame to the screen
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]); pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
@ -515,7 +503,6 @@ void Direct3DDisplay::render()
mbCurrentTexture ^= 1; // switch current texture mbCurrentTexture ^= 1; // switch current texture
} }
// render speed and status messages // render speed and status messages
D3DCOLOR color; D3DCOLOR color;
RECT r; RECT r;
@ -552,7 +539,6 @@ void Direct3DDisplay::render()
return; return;
} }
bool Direct3DDisplay::changeRenderSize(int w, int h) bool Direct3DDisplay::changeRenderSize(int w, int h)
{ {
if ((w != width) || (h != height)) { if ((w != width) || (h != height)) {
@ -567,22 +553,18 @@ bool Direct3DDisplay::changeRenderSize( int w, int h )
return true; return true;
} }
void Direct3DDisplay::resize(int w, int h) void Direct3DDisplay::resize(int w, int h)
{ {
if (!initialized) { if (!initialized) {
return; return;
} }
if( (w != dpp.BackBufferWidth) || if ((w != dpp.BackBufferWidth) || (h != dpp.BackBufferHeight) || (videoOption > VIDEO_6X)) {
(h != dpp.BackBufferHeight) ||
(videoOption > VIDEO_6X) ) {
resetDevice(); resetDevice();
calculateDestRect(); calculateDestRect();
} }
} }
bool Direct3DDisplay::selectFullScreenMode(VIDEO_MODE& mode) bool Direct3DDisplay::selectFullScreenMode(VIDEO_MODE& mode)
{ {
FullscreenSettings dlg; FullscreenSettings dlg;
@ -590,8 +572,7 @@ bool Direct3DDisplay::selectFullScreenMode( VIDEO_MODE &mode )
INT_PTR ret = dlg.DoModal(); INT_PTR ret = dlg.DoModal();
if (ret == IDOK) { if (ret == IDOK) {
mode.adapter = dlg.m_device; mode.adapter = dlg.m_device;
switch( dlg.m_colorDepth ) switch (dlg.m_colorDepth) {
{
case 30: case 30:
// TODO: support // TODO: support
return false; return false;
@ -613,7 +594,6 @@ bool Direct3DDisplay::selectFullScreenMode( VIDEO_MODE &mode )
} }
} }
void Direct3DDisplay::createFont() void Direct3DDisplay::createFont()
{ {
if (!pFont) { if (!pFont) {
@ -636,7 +616,6 @@ void Direct3DDisplay::createFont()
} }
} }
void Direct3DDisplay::destroyFont() void Direct3DDisplay::destroyFont()
{ {
if (pFont) { if (pFont) {
@ -645,7 +624,6 @@ void Direct3DDisplay::destroyFont()
} }
} }
// fill texture completely with black // fill texture completely with black
bool Direct3DDisplay::clearTexture(LPDIRECT3DTEXTURE9 texture, size_t textureHeight) bool Direct3DDisplay::clearTexture(LPDIRECT3DTEXTURE9 texture, size_t textureHeight)
{ {
@ -662,7 +640,6 @@ bool Direct3DDisplay::clearTexture( LPDIRECT3DTEXTURE9 texture, size_t textureHe
} }
} }
// when either textureWidth or textureHeight is 0, last texture size will be used // when either textureWidth or textureHeight is 0, last texture size will be used
void Direct3DDisplay::createTexture(unsigned int textureWidth, unsigned int textureHeight) void Direct3DDisplay::createTexture(unsigned int textureWidth, unsigned int textureHeight)
{ {
@ -682,7 +659,6 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
} }
} }
if (!tempImage) { if (!tempImage) {
HRESULT hr = pDevice->CreateTexture( HRESULT hr = pDevice->CreateTexture(
textureSize, textureSize, textureSize, textureSize,
@ -703,7 +679,6 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
clearTexture(tempImage, textureSize); clearTexture(tempImage, textureSize);
} }
if (!emulatedImage[0]) { if (!emulatedImage[0]) {
HRESULT hr = pDevice->CreateTexture( HRESULT hr = pDevice->CreateTexture(
textureSize, textureSize, textureSize, textureSize,
@ -739,7 +714,6 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
} }
} }
void Direct3DDisplay::destroyTexture() void Direct3DDisplay::destroyTexture()
{ {
if (tempImage) { if (tempImage) {
@ -758,7 +732,6 @@ void Direct3DDisplay::destroyTexture()
} }
} }
void Direct3DDisplay::calculateDestRect() void Direct3DDisplay::calculateDestRect()
{ {
if (fullScreenStretch) { if (fullScreenStretch) {
@ -790,10 +763,7 @@ void Direct3DDisplay::calculateDestRect()
destRect.bottom += diff; destRect.bottom += diff;
} }
if( ( destRect.left == 0 ) && if ((destRect.left == 0) && (destRect.top == 0) && (destRect.right == dpp.BackBufferWidth) && (destRect.bottom == dpp.BackBufferHeight)) {
( destRect.top == 0 ) &&
( destRect.right == dpp.BackBufferWidth ) &&
( destRect.bottom == dpp.BackBufferHeight ) ) {
rectangleFillsScreen = true; rectangleFillsScreen = true;
} else { } else {
rectangleFillsScreen = false; rectangleFillsScreen = false;
@ -864,7 +834,6 @@ void Direct3DDisplay::calculateDestRect()
} }
} }
void Direct3DDisplay::setOption(const char* option, int value) void Direct3DDisplay::setOption(const char* option, int value)
{ {
if (!_tcscmp(option, _T("vsync"))) { if (!_tcscmp(option, _T("vsync"))) {
@ -880,8 +849,7 @@ void Direct3DDisplay::setOption( const char *option, int value )
} }
if (!_tcscmp(option, _T("d3dFilter"))) { if (!_tcscmp(option, _T("d3dFilter"))) {
switch( value ) switch (value) {
{
case 0: //point case 0: //point
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
@ -902,8 +870,7 @@ void Direct3DDisplay::setOption( const char *option, int value )
} }
if (!_tcscmp(option, _T("motionBlur"))) { if (!_tcscmp(option, _T("motionBlur"))) {
switch( value ) switch (value) {
{
case 0: case 0:
mbCurrentTexture = 0; mbCurrentTexture = 0;
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
@ -923,10 +890,10 @@ void Direct3DDisplay::setOption( const char *option, int value )
} }
} }
bool Direct3DDisplay::resetDevice() bool Direct3DDisplay::resetDevice()
{ {
if( !pDevice ) return false; if (!pDevice)
return false;
HRESULT hr; HRESULT hr;
if (pFont) { if (pFont) {
@ -953,7 +920,6 @@ bool Direct3DDisplay::resetDevice()
return true; return true;
} }
IDisplay* newDirect3DDisplay() IDisplay* newDirect3DDisplay()
{ {
return new Direct3DDisplay(); return new Direct3DDisplay();

View File

@ -1,15 +1,14 @@
#include "stdafx.h"
#include "VBA.h"
#include "Input.h" #include "Input.h"
#include "Reg.h" #include "Reg.h"
#include "VBA.h"
#include "WinResUtil.h" #include "WinResUtil.h"
#include "stdafx.h"
#define DIRECTINPUT_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800
#include <dinput.h> #include <dinput.h>
#pragma comment(lib, "dinput8") #pragma comment(lib, "dinput8")
#pragma comment(lib, "dxguid") #pragma comment(lib, "dxguid")
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
#undef THIS_FILE #undef THIS_FILE
@ -67,11 +66,7 @@ static deviceInfo *pDevices = NULL;
static LPDIRECTINPUT8 pDirectInput = NULL; static LPDIRECTINPUT8 pDirectInput = NULL;
static int axisNumber = 0; static int axisNumber = 0;
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] = {
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] =
{
DIK_LEFT, DIK_RIGHT, DIK_LEFT, DIK_RIGHT,
DIK_UP, DIK_DOWN, DIK_UP, DIK_DOWN,
DIK_X, DIK_Z, DIK_X, DIK_Z,
@ -85,15 +80,13 @@ LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] =
DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2 DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2
}; };
void winReadKey(const char* name, KeyList& Keys) void winReadKey(const char* name, KeyList& Keys)
{ {
CString TxtKeyList = regQueryStringValue(name, ""); CString TxtKeyList = regQueryStringValue(name, "");
int curPos = 0; int curPos = 0;
CString resToken = TxtKeyList.Tokenize(",", curPos); CString resToken = TxtKeyList.Tokenize(",", curPos);
while (resToken != "") while (resToken != "") {
{
Keys.AddTail(atoi(resToken)); Keys.AddTail(atoi(resToken));
resToken = TxtKeyList.Tokenize(",", curPos); resToken = TxtKeyList.Tokenize(",", curPos);
}; };
@ -107,7 +100,6 @@ void winReadKey(const char *name, int num, KeyList& Keys)
winReadKey(buffer, Keys); winReadKey(buffer, Keys);
} }
void winReadKeys() void winReadKeys()
{ {
@ -137,8 +129,7 @@ void winSaveKey(char *name, KeyList& value)
CString txtKeys; CString txtKeys;
POSITION p = value.GetHeadPosition(); POSITION p = value.GetHeadPosition();
while(p!=NULL) while (p != NULL) {
{
CString tmp; CString tmp;
tmp.Format("%d", value.GetNext(p)); tmp.Format("%d", value.GetNext(p));
txtKeys += tmp; txtKeys += tmp;
@ -209,8 +200,7 @@ static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
hRet = pDevices[numDevices].device->GetCapabilities(&caps); hRet = pDevices[numDevices].device->GetCapabilities(&caps);
if (hRet == DI_OK) { if (hRet == DI_OK) {
if (caps.dwFlags & DIDC_POLLEDDATAFORMAT || if (caps.dwFlags & DIDC_POLLEDDATAFORMAT || caps.dwFlags & DIDC_POLLEDDEVICE)
caps.dwFlags & DIDC_POLLEDDEVICE)
pDevices[numDevices].isPolled = TRUE; pDevices[numDevices].isPolled = TRUE;
pDevices[numDevices].nButtons = caps.dwButtons; pDevices[numDevices].nButtons = caps.dwButtons;
@ -224,10 +214,8 @@ static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
} }
} }
numDevices++; numDevices++;
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
@ -260,13 +248,11 @@ static void checkKeys()
LONG_PTR dev = 0; LONG_PTR dev = 0;
int i; int i;
for(i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++) for (i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++) {
{
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i]) if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
theApp.input->joypaddata[i].AddTail(defvalues[i]); theApp.input->joypaddata[i].AddTail(defvalues[i]);
POSITION p = theApp.input->joypaddata[i].GetHeadPosition(); POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
while(p!=NULL) while (p != NULL) {
{
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p); LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
if (k > 0 && DEVICEOF(k) < numDevices) if (k > 0 && DEVICEOF(k) < numDevices)
pDevices[DEVICEOF(k)].needed = true; pDevices[DEVICEOF(k)].needed = true;
@ -279,8 +265,7 @@ static void checkKeys()
static bool readKeyboard() static bool readKeyboard()
{ {
if (pDevices[0].needed) { if (pDevices[0].needed) {
HRESULT hret = pDevices[0].device-> HRESULT hret = pDevices[0].device->GetDeviceState(256,
GetDeviceState(256,
(LPVOID)pDevices[0].data); (LPVOID)pDevices[0].data);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) { if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
@ -301,8 +286,7 @@ static bool readJoystick(int joy)
if (pDevices[joy].isPolled) if (pDevices[joy].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll(); ((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
HRESULT hret = pDevices[joy].device-> HRESULT hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state); (LPVOID)&pDevices[joy].state);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) { if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
@ -313,8 +297,7 @@ static bool readJoystick(int joy)
if (pDevices[joy].isPolled) if (pDevices[joy].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll(); ((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
hret = pDevices[joy].device-> hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state); (LPVOID)&pDevices[joy].state);
} }
} }
@ -337,8 +320,7 @@ static void checkKeyboard()
return; return;
} }
hret = pDevices[0].device-> hret = pDevices[0].device->GetDeviceState(256, (LPVOID)keystate);
GetDeviceState(256, (LPVOID)keystate);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) { if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
return; return;
@ -346,7 +328,8 @@ static void checkKeyboard()
if (hret == DI_OK) { if (hret == DI_OK) {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
if (keystate[i] == pDevices[0].data[i]) continue; if (keystate[i] == pDevices[0].data[i])
continue;
if (KEYDOWN(keystate, i)) { if (KEYDOWN(keystate, i)) {
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, 0, i); SendMessage(GetFocus(), JOYCONFIG_MESSAGE, 0, i);
break; break;
@ -371,7 +354,6 @@ static void checkJoypads()
for (i = 1; i < numDevices; i++) { for (i = 1; i < numDevices; i++) {
HRESULT hret = pDevices[i].device->Acquire(); HRESULT hret = pDevices[i].device->Acquire();
if (pDevices[i].isPolled) if (pDevices[i].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll(); ((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll();
@ -387,7 +369,8 @@ static void checkJoypads()
for (j = 0; j < pDevices[i].nButtons; j++) { for (j = 0; j < pDevices[i].nButtons; j++) {
if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j]) if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j])
& joystick.rgbButtons[j]) & 0x80) { & joystick.rgbButtons[j])
& 0x80) {
HWND focus = GetFocus(); HWND focus = GetFocus();
SendMessage(focus, JOYCONFIG_MESSAGE, i, j + 128); SendMessage(focus, JOYCONFIG_MESSAGE, i, j + 128);
@ -468,8 +451,7 @@ BOOL checkKey(LONG_PTR key)
BOOL checkKey(KeyList& k) BOOL checkKey(KeyList& k)
{ {
POSITION p = k.GetHeadPosition(); POSITION p = k.GetHeadPosition();
while(p!=NULL) while (p != NULL) {
{
if (checkKey(k.GetNext(p))) if (checkKey(k.GetNext(p)))
return TRUE; return TRUE;
} }
@ -512,16 +494,14 @@ bool DirectInput::initialize()
(LPVOID*)&pDirectInput, (LPVOID*)&pDirectInput,
NULL); NULL);
ASSERT(hr == DI_OK); ASSERT(hr == DI_OK);
if( hr != DI_OK ) return false; if (hr != DI_OK)
return false;
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL, hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
DIEnumDevicesCallback2, DIEnumDevicesCallback2,
NULL, NULL,
DIEDFL_ATTACHEDONLY); DIEDFL_ATTACHEDONLY);
pDevices = (deviceInfo*)calloc(numDevices, sizeof(deviceInfo)); pDevices = (deviceInfo*)calloc(numDevices, sizeof(deviceInfo));
hr = pDirectInput->CreateDevice(GUID_SysKeyboard, &pDevices[0].device, NULL); hr = pDirectInput->CreateDevice(GUID_SysKeyboard, &pDevices[0].device, NULL);
@ -533,7 +513,6 @@ bool DirectInput::initialize()
return false; return false;
} }
numDevices = 1; numDevices = 1;
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL, hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
@ -541,7 +520,6 @@ bool DirectInput::initialize()
NULL, NULL,
DIEDFL_ATTACHEDONLY); DIEDFL_ATTACHEDONLY);
if (hr != DI_OK) { if (hr != DI_OK) {
return false; return false;
} }
@ -567,8 +545,7 @@ bool DirectInput::initialize()
range.diph.dwHow = DIPH_BYOFFSET; range.diph.dwHow = DIPH_BYOFFSET;
// screw EnumObjects, just go through all the axis offsets and try to GetProperty // screw EnumObjects, just go through all the axis offsets and try to GetProperty
// this should be more foolproof, less code, and probably faster // this should be more foolproof, less code, and probably faster
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG)) for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG)) {
{
range.diph.dwObj = offset; range.diph.dwObj = offset;
// try to set some nice power of 2 values (8192) // try to set some nice power of 2 values (8192)
range.lMin = -(1 << 13); range.lMin = -(1 << 13);
@ -577,8 +554,7 @@ bool DirectInput::initialize()
// but i guess not all devices support setting range // but i guess not all devices support setting range
// so i getproperty right afterward incase it didn't set :P // so i getproperty right afterward incase it didn't set :P
// this also checks that the axis is present // this also checks that the axis is present
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph))) if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph))) {
{
const LONG center = (range.lMin + range.lMax) / 2; const LONG center = (range.lMin + range.lMax) / 2;
const LONG threshold = (range.lMax - center) / 2; const LONG threshold = (range.lMax - center) / 2;
@ -589,12 +565,10 @@ bool DirectInput::initialize()
++axisNumber; ++axisNumber;
} }
} }
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV); currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
currentDevice = NULL; currentDevice = NULL;
} }
@ -704,8 +678,7 @@ CString DirectInput::getKeyName(LONG_PTR key)
pDevices[0].device->GetObjectInfo(&di, (DWORD)key, DIPH_BYOFFSET); pDevices[0].device->GetObjectInfo(&di, (DWORD)key, DIPH_BYOFFSET);
winBuffer = di.tszName; winBuffer = di.tszName;
} else if (d < numDevices) { } else if (d < numDevices) {
if (k < 16) if (k < 16) {
{
pDevices[d].device->GetObjectInfo(&di, pDevices[d].device->GetObjectInfo(&di,
pDevices[d].axis[k >> 1].offset, pDevices[d].axis[k >> 1].offset,
DIPH_BYOFFSET); DIPH_BYOFFSET);
@ -733,9 +706,7 @@ CString DirectInput::getKeyName(LONG_PTR key)
DIPH_BYOFFSET); DIPH_BYOFFSET);
winBuffer.Format(winResLoadString(IDS_JOY_BUTTON), d, di.tszName); winBuffer.Format(winResLoadString(IDS_JOY_BUTTON), d, di.tszName);
} }
} } else {
else
{
// Joystick isn't plugged in. We can't decipher k, so just show its value. // Joystick isn't plugged in. We can't decipher k, so just show its value.
winBuffer.Format("Joy %d (%d)", d, k); winBuffer.Format("Joy %d (%d)", d, k);
} }
@ -808,7 +779,6 @@ Input *newDirectInput()
return new DirectInput; return new DirectInput;
} }
void DirectInput::checkDevices() void DirectInput::checkDevices()
{ {
checkJoypads(); checkJoypads();

View File

@ -10,10 +10,10 @@
// Internals // Internals
#include "../System.h" #include "../System.h"
#include "../common/SoundDriver.h"
#include "../gba/GBA.h" #include "../gba/GBA.h"
#include "../gba/Globals.h" #include "../gba/Globals.h"
#include "../gba/Sound.h" #include "../gba/Sound.h"
#include "../common/SoundDriver.h"
// DirectSound8 // DirectSound8
#define DIRECTSOUND_VERSION 0x0800 #define DIRECTSOUND_VERSION 0x0800
@ -21,8 +21,7 @@
extern bool soundBufferLow; extern bool soundBufferLow;
class DirectSound : public SoundDriver class DirectSound : public SoundDriver {
{
private: private:
LPDIRECTSOUND8 pDirectSound; // DirectSound interface LPDIRECTSOUND8 pDirectSound; // DirectSound interface
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
@ -45,7 +44,6 @@ public:
void write(u16* finalWave, int length); // write the emulated sound to the secondary sound buffer void write(u16* finalWave, int length); // write the emulated sound to the secondary sound buffer
}; };
DirectSound::DirectSound() DirectSound::DirectSound()
{ {
pDirectSound = NULL; pDirectSound = NULL;
@ -58,7 +56,6 @@ DirectSound::DirectSound()
soundNextPosition = 0; soundNextPosition = 0;
} }
DirectSound::~DirectSound() DirectSound::~DirectSound()
{ {
if (dsbNotify) { if (dsbNotify) {
@ -87,7 +84,6 @@ DirectSound::~DirectSound()
} }
} }
bool DirectSound::init(long sampleRate) bool DirectSound::init(long sampleRate)
{ {
HRESULT hr; HRESULT hr;
@ -112,7 +108,6 @@ bool DirectSound::init(long sampleRate)
return false; return false;
} }
// Create primary sound buffer // Create primary sound buffer
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC); dsbdesc.dwSize = sizeof(DSBUFFERDESC);
@ -146,7 +141,6 @@ bool DirectSound::init(long sampleRate)
return false; return false;
} }
// Create secondary sound buffer // Create secondary sound buffer
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC)); ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC); dsbdesc.dwSize = sizeof(DSBUFFERDESC);
@ -167,7 +161,6 @@ bool DirectSound::init(long sampleRate)
return false; return false;
} }
if (SUCCEEDED(hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify))) { if (SUCCEEDED(hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify))) {
dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL); dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
DSBPOSITIONNOTIFY notify[10]; DSBPOSITIONNOTIFY notify[10];
@ -184,7 +177,6 @@ bool DirectSound::init(long sampleRate)
} }
} }
// Play primary buffer // Play primary buffer
if (FAILED(hr = dsbPrimary->Play(0, 0, DSBPLAY_LOOPING))) { if (FAILED(hr = dsbPrimary->Play(0, 0, DSBPLAY_LOOPING))) {
systemMessage(IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr); systemMessage(IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr);
@ -194,22 +186,23 @@ bool DirectSound::init(long sampleRate)
return true; return true;
} }
void DirectSound::pause() void DirectSound::pause()
{ {
if( dsbSecondary == NULL ) return; if (dsbSecondary == NULL)
return;
DWORD status; DWORD status;
dsbSecondary->GetStatus(&status); dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) dsbSecondary->Stop(); if (status & DSBSTATUS_PLAYING)
dsbSecondary->Stop();
} }
void DirectSound::reset() void DirectSound::reset()
{ {
if( dsbSecondary == NULL ) return; if (dsbSecondary == NULL)
return;
dsbSecondary->Stop(); dsbSecondary->Stop();
@ -218,19 +211,18 @@ void DirectSound::reset()
soundNextPosition = 0; soundNextPosition = 0;
} }
void DirectSound::resume() void DirectSound::resume()
{ {
if( dsbSecondary == NULL ) return; if (dsbSecondary == NULL)
return;
dsbSecondary->Play(0, 0, DSBPLAY_LOOPING); dsbSecondary->Play(0, 0, DSBPLAY_LOOPING);
} }
void DirectSound::write(u16* finalWave, int length) void DirectSound::write(u16* finalWave, int length)
{ {
if(!pDirectSound) return; if (!pDirectSound)
return;
HRESULT hr; HRESULT hr;
DWORD status = 0; DWORD status = 0;
@ -246,12 +238,9 @@ void DirectSound::write(u16 * finalWave, int length)
if (!soundPaused) { if (!soundPaused) {
while (true) { while (true) {
dsbSecondary->GetCurrentPosition(&play, NULL); dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ? int BufferLeft = ((soundNextPosition <= play) ? play - soundNextPosition : soundBufferTotalLen - soundNextPosition + play);
play - soundNextPosition :
soundBufferTotalLen - soundNextPosition + play);
if(BufferLeft > soundBufferLen) if (BufferLeft > soundBufferLen) {
{
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3)) if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true; soundBufferLow = true;
break; break;
@ -269,7 +258,6 @@ void DirectSound::write(u16 * finalWave, int length)
}*/ }*/
} }
// Obtain memory address of write block. // Obtain memory address of write block.
// This will be in two parts if the block wraps around. // This will be in two parts if the block wraps around.
if (DSERR_BUFFERLOST == (hr = dsbSecondary->Lock( if (DSERR_BUFFERLOST == (hr = dsbSecondary->Lock(

View File

@ -1,8 +1,8 @@
#include "stdafx.h"
#include "vba.h"
#include "Directories.h" #include "Directories.h"
#include "Reg.h" #include "Reg.h"
#include "WinResUtil.h" #include "WinResUtil.h"
#include "stdafx.h"
#include "vba.h"
#include <shlobj.h> #include <shlobj.h>
#include <shlwapi.h> #include <shlwapi.h>
@ -35,7 +35,6 @@ Directories::Directories(CWnd* pParent /*=NULL*/)
{ {
} }
void Directories::DoDataExchange(CDataExchange* pDX) void Directories::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -47,7 +46,6 @@ void Directories::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath); DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath);
} }
BEGIN_MESSAGE_MAP(Directories, CDialog) BEGIN_MESSAGE_MAP(Directories, CDialog)
ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir) ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir)
ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir) ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir)
@ -157,7 +155,6 @@ void Directories::OnOK()
baseDir[MAX_PATH] = '\0'; // for security reasons baseDir[MAX_PATH] = '\0'; // for security reasons
PathRemoveFileSpec(baseDir); // removes the trailing file name and backslash PathRemoveFileSpec(baseDir); // removes the trailing file name and backslash
CString buffer; CString buffer;
m_romPath.GetWindowText(buffer); m_romPath.GetWindowText(buffer);

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
class Directories : public CDialog class Directories : public CDialog {
{
public: public:
Directories(CWnd* pParent = NULL); Directories(CWnd* pParent = NULL);
enum { IDD = IDD_DIRECTORIES }; enum { IDD = IDD_DIRECTORIES };

View File

@ -1,11 +1,11 @@
#include "Disassemble.h"
#include "stdafx.h" #include "stdafx.h"
#include "vba.h" #include "vba.h"
#include "Disassemble.h"
#include "../System.h" #include "../System.h"
#include "../gba/armdis.h"
#include "../gba/GBA.h" #include "../gba/GBA.h"
#include "../gba/Globals.h" #include "../gba/Globals.h"
#include "../gba/armdis.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -17,11 +17,9 @@ extern int emulating;
extern void CPUUpdateCPSR(); extern void CPUUpdateCPSR();
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Disassemble dialog // Disassemble dialog
Disassemble::Disassemble(CWnd* pParent /*=NULL*/) Disassemble::Disassemble(CWnd* pParent /*=NULL*/)
: ResizeDlg(Disassemble::IDD, pParent) : ResizeDlg(Disassemble::IDD, pParent)
{ {
@ -41,7 +39,6 @@ Disassemble::Disassemble(CWnd* pParent /*=NULL*/)
count = 1; count = 1;
} }
void Disassemble::DoDataExchange(CDataExchange* pDX) void Disassemble::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -59,7 +56,6 @@ void Disassemble::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP //}}AFX_DATA_MAP
} }
BEGIN_MESSAGE_MAP(Disassemble, CDialog) BEGIN_MESSAGE_MAP(Disassemble, CDialog)
//{{AFX_MSG_MAP(Disassemble) //{{AFX_MSG_MAP(Disassemble)
ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate)
@ -122,8 +118,7 @@ void Disassemble::OnGo()
void Disassemble::OnGopc() void Disassemble::OnGopc()
{ {
if(rom != NULL) if (rom != NULL) {
{
if (armState) if (armState)
address = armNextPC - 16; address = armNextPC - 16;
else else
@ -135,8 +130,7 @@ void Disassemble::OnGopc()
void Disassemble::OnNext() void Disassemble::OnNext()
{ {
if(rom != NULL) if (rom != NULL) {
{
CPULoop(1); CPULoop(1);
if (armState) { if (armState) {
u32 total = address + count * 4; u32 total = address + count * 4;
@ -204,7 +198,6 @@ BOOL Disassemble::OnInitDialog()
GetDlgItem(IDC_MODE)->SetFont(font, FALSE); GetDlgItem(IDC_MODE)->SetFont(font, FALSE);
m_address.LimitText(8); m_address.LimitText(8);
refresh(); refresh();

View File

@ -14,8 +14,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Disassemble dialog // Disassemble dialog
class Disassemble : public ResizeDlg, IUpdateListener class Disassemble : public ResizeDlg, IUpdateListener {
{
// Construction // Construction
public: public:
virtual void update(); virtual void update();

View File

@ -2,10 +2,10 @@
#include <memory.h> #include <memory.h>
enum DISPLAY_TYPE { DIRECT_3D = 0, OPENGL = 1 }; enum DISPLAY_TYPE { DIRECT_3D = 0,
OPENGL = 1 };
class IDisplay class IDisplay {
{
public: public:
IDisplay(){}; IDisplay(){};
virtual ~IDisplay(){}; virtual ~IDisplay(){};

View File

@ -1,9 +1,9 @@
#include "ExportGSASnapshot.h"
#include "stdafx.h" #include "stdafx.h"
#include "vba.h" #include "vba.h"
#include "ExportGSASnapshot.h"
#include "../gba/GBA.h"
#include "../NLS.h" #include "../NLS.h"
#include "../gba/GBA.h"
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@ -14,7 +14,6 @@ static char THIS_FILE[] = __FILE__;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ExportGSASnapshot dialog // ExportGSASnapshot dialog
ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pParent /*=NULL*/) ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pParent /*=NULL*/)
: CDialog(ExportGSASnapshot::IDD, pParent) : CDialog(ExportGSASnapshot::IDD, pParent)
{ {
@ -43,7 +42,6 @@ ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pPar
m_desc.Format("%s %s", date, time); m_desc.Format("%s %s", date, time);
} }
void ExportGSASnapshot::DoDataExchange(CDataExchange* pDX) void ExportGSASnapshot::DoDataExchange(CDataExchange* pDX)
{ {
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
@ -57,7 +55,6 @@ void ExportGSASnapshot::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP //}}AFX_DATA_MAP
} }
BEGIN_MESSAGE_MAP(ExportGSASnapshot, CDialog) BEGIN_MESSAGE_MAP(ExportGSASnapshot, CDialog)
//{{AFX_MSG_MAP(ExportGSASnapshot) //{{AFX_MSG_MAP(ExportGSASnapshot)
ON_BN_CLICKED(ID_CANCEL, OnCancel) ON_BN_CLICKED(ID_CANCEL, OnCancel)

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