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 <cstdlib>
u8* gbMemoryMap[16];
uint8_t* gbMemoryMap[16];
int gbRomSizeMask = 0;
int gbRomSize = 0;
@ -9,24 +9,24 @@ int gbRamSizeMask = 0;
int gbRamSize = 0;
int gbTAMA5ramSize = 0;
u8* gbMemory = NULL;
u8* gbVram = NULL;
u8* gbRom = NULL;
u8* gbRam = NULL;
u8* gbWram = NULL;
u16* gbLineBuffer = NULL;
u8* gbTAMA5ram = NULL;
uint8_t* gbMemory = NULL;
uint8_t* gbVram = NULL;
uint8_t* gbRom = NULL;
uint8_t* gbRam = NULL;
uint8_t* gbWram = NULL;
uint16_t* gbLineBuffer = NULL;
uint8_t* gbTAMA5ram = NULL;
u16 gbPalette[128];
u8 gbBgp[4] = { 0, 1, 2, 3 };
u8 gbObp0[4] = { 0, 1, 2, 3 };
u8 gbObp1[4] = { 0, 1, 2, 3 };
uint16_t gbPalette[128];
uint8_t gbBgp[4] = { 0, 1, 2, 3 };
uint8_t gbObp0[4] = { 0, 1, 2, 3 };
uint8_t gbObp1[4] = { 0, 1, 2, 3 };
int gbWindowLine = -1;
bool genericflashcardEnable = false;
int gbCgbMode = 0;
u16 gbColorFilter[32768];
uint16_t gbColorFilter[32768];
int gbColorOption = 0;
int gbPaletteOption = 0;
int gbEmulatorType = 0;
@ -37,4 +37,4 @@ int gbBorderRowSkip = 0;
int gbBorderColumnSkip = 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 gbTAMA5ramSize;
extern u8* bios;
extern uint8_t* bios;
extern u8* gbRom;
extern u8* gbRam;
extern u8* gbVram;
extern u8* gbWram;
extern u8* gbMemory;
extern u16* gbLineBuffer;
extern u8* gbTAMA5ram;
extern uint8_t* gbRom;
extern uint8_t* gbRam;
extern uint8_t* gbVram;
extern uint8_t* gbWram;
extern uint8_t* gbMemory;
extern uint16_t* gbLineBuffer;
extern uint8_t* gbTAMA5ram;
extern u8* gbMemoryMap[16];
extern uint8_t* gbMemoryMap[16];
extern int gbFrameSkip;
extern u16 gbColorFilter[32768];
extern uint16_t gbColorFilter[32768];
extern int gbColorOption;
extern int gbPaletteOption;
extern int gbEmulatorType;
@ -30,32 +30,32 @@ extern int gbCgbMode;
extern int gbSgbMode;
extern int gbWindowLine;
extern int gbSpeed;
extern u8 gbBgp[4];
extern u8 gbObp0[4];
extern u8 gbObp1[4];
extern u16 gbPalette[128];
extern uint8_t gbBgp[4];
extern uint8_t gbObp0[4];
extern uint8_t gbObp1[4];
extern uint16_t gbPalette[128];
extern bool gbScreenOn;
extern bool gbDrawWindow;
extern u8 gbSCYLine[300];
extern uint8_t gbSCYLine[300];
// gbSCXLine is used for the emulation (bug) of the SX change
// found in the Artic Zone game.
extern u8 gbSCXLine[300];
extern uint8_t gbSCXLine[300];
// gbBgpLine is used for the emulation of the
// Prehistorik Man's title screen scroller.
extern u8 gbBgpLine[300];
extern u8 gbObp0Line[300];
extern u8 gbObp1Line[300];
extern uint8_t gbBgpLine[300];
extern uint8_t gbObp0Line[300];
extern uint8_t gbObp1Line[300];
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
extern u8 gbSpritesTicks[300];
extern uint8_t gbSpritesTicks[300];
extern u8 register_LCDC;
extern u8 register_LY;
extern u8 register_SCY;
extern u8 register_SCX;
extern u8 register_WY;
extern u8 register_WX;
extern u8 register_VBK;
extern u8 oldRegister_WY;
extern uint8_t register_LCDC;
extern uint8_t register_LY;
extern uint8_t register_SCY;
extern uint8_t register_SCX;
extern uint8_t register_WY;
extern uint8_t register_WX;
extern uint8_t register_VBK;
extern uint8_t oldRegister_WY;
extern int emulating;
extern bool genericflashcardEnable;
@ -68,6 +68,6 @@ extern int gbDmaTicks;
extern void gbRenderLine();
extern void gbDrawSprites(bool);
extern u8 (*gbSerialFunction)(u8);
extern uint8_t (*gbSerialFunction)(uint8_t);
#endif // GBGLOBALS_H

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,18 +6,18 @@ void gbSgbShutdown();
void gbSgbCommand();
void gbSgbResetPacketState();
void gbSgbReset();
void gbSgbDoBitTransfer(u8);
void gbSgbDoBitTransfer(uint8_t);
void gbSgbSaveGame(gzFile);
void gbSgbReadGame(gzFile, int version);
void gbSgbRenderBorder();
extern u8 gbSgbATF[20 * 18];
extern uint8_t gbSgbATF[20 * 18];
extern int gbSgbMode;
extern int gbSgbMask;
extern int gbSgbMultiplayer;
extern u8 gbSgbNextController;
extern uint8_t gbSgbNextController;
extern int gbSgbPacketTimeout;
extern u8 gbSgbReadingController;
extern uint8_t gbSgbReadingController;
extern int gbSgbFourPlayers;
#endif // GBSGB_H

View File

@ -29,7 +29,7 @@ static inline blip_time_t blip_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)
return gb_apu->read_register(blip_time(), address);
@ -37,7 +37,7 @@ u8 gbSoundRead(u16 address)
return gbMemory[address];
}
void gbSoundEvent(register u16 address, register int data)
void gbSoundEvent(register uint16_t address, register int data)
{
gbMemory[address] = data;
@ -326,9 +326,9 @@ static variable_desc gbsound_format2[] = {
};
static variable_desc gbsound_format3[] = {
SKIP(u8[2 * 735], soundBuffer),
SKIP(u8[2 * 735], soundBuffer),
SKIP(u16[735], soundFinalWave),
SKIP(uint8_t[2 * 735], soundBuffer),
SKIP(uint8_t[2 * 735], soundBuffer),
SKIP(uint16_t[735], soundFinalWave),
{ NULL, 0 }
};
@ -402,7 +402,7 @@ static variable_desc gb_state[] = {
LOAD(int, state.version), // room_for_expansion will be used by later versions
// 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_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();
// Emulates write to sound hardware
void gbSoundEvent(u16 address, int data);
void gbSoundEvent(uint16_t address, int data);
#define SOUND_EVENT gbSoundEvent
// Emulates read from sound hardware
u8 gbSoundRead(u16 address);
uint8_t gbSoundRead(uint16_t address);
// Notifies emulator that SOUND_CLOCK_TICKS clocks have passed
void gbSoundTick();

View File

@ -20,104 +20,101 @@
#include "intl.h"
namespace VBA
{
namespace VBA {
/**
* GameBoyAdvanceCheatEditDialog
*
* A unified cheat editing dialog for multiple code types.
*/
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog)
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
{
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
refBuilder->get_widget("CheatInputTextView", m_poCheatInputTextView);
refBuilder->get_widget("CheatApplyButton", m_poCheatApplyButton);
refBuilder->get_widget("CheatCancelButton", m_poCheatCancelButton);
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
refBuilder->get_widget("CheatInputTextView", m_poCheatInputTextView);
refBuilder->get_widget("CheatApplyButton", m_poCheatApplyButton);
refBuilder->get_widget("CheatCancelButton", m_poCheatCancelButton);
// Tree View model
m_poCheatTypeStore = Gtk::ListStore::create(m_oTypeModel);
// Tree View model
m_poCheatTypeStore = Gtk::ListStore::create(m_oTypeModel);
m_poCheatTypeComboBox->set_model(m_poCheatTypeStore);
m_poCheatTypeComboBox->set_model(m_poCheatTypeStore);
m_poCheatApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnApply));
m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel));
m_poCheatApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnApply));
m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel));
}
Glib::RefPtr<Gtk::TextBuffer> CheatEditDialog::vGetCode()
{
return m_poCheatInputTextView->get_buffer();
return m_poCheatInputTextView->get_buffer();
}
Glib::ustring CheatEditDialog::vGetDesc()
{
return m_poCheatDescEntry->get_text();
return m_poCheatDescEntry->get_text();
}
ECheatType CheatEditDialog::vGetType()
{
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
if (iter)
{
Gtk::TreeModel::Row row = *iter;
if (iter) {
Gtk::TreeModel::Row row = *iter;
return row[m_oTypeModel.iType];
}
return row[m_oTypeModel.iType];
}
return CheatGeneric;
return CheatGeneric;
}
void CheatEditDialog::vSetWindow(VBA::Window * _poWindow)
void CheatEditDialog::vSetWindow(VBA::Window* _poWindow)
{
m_poWindow = _poWindow;
m_poWindow = _poWindow;
// GameBoy Advance
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA)
{
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
// GameBoy Advance
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA) {
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGeneric;
row[m_oTypeModel.uText] = _("Generic Code");
row[m_oTypeModel.iType] = CheatGeneric;
row[m_oTypeModel.uText] = _("Generic Code");
row = *(m_poCheatTypeStore->append());
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGSA;
row[m_oTypeModel.uText] = _("Gameshark Advance");
row[m_oTypeModel.iType] = CheatGSA;
row[m_oTypeModel.uText] = _("Gameshark Advance");
row = *(m_poCheatTypeStore->append());
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatCBA;
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
row[m_oTypeModel.iType] = CheatCBA;
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
m_poCheatTypeComboBox->set_active(CheatGeneric);
}
// GameBoy
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB)
{
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
m_poCheatTypeComboBox->set_active(CheatGeneric);
}
// GameBoy
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB) {
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGS;
row[m_oTypeModel.uText] = _("GameShark");
row[m_oTypeModel.iType] = CheatGS;
row[m_oTypeModel.uText] = _("GameShark");
row = *(m_poCheatTypeStore->append());
row = *(m_poCheatTypeStore->append());
row[m_oTypeModel.iType] = CheatGG;
row[m_oTypeModel.uText] = _("GameGenie");
row[m_oTypeModel.iType] = CheatGG;
row[m_oTypeModel.uText] = _("GameGenie");
m_poCheatTypeComboBox->set_active(0);
}
m_poCheatTypeComboBox->set_active(0);
}
}
void CheatEditDialog::vOnApply()
{
response(Gtk::RESPONSE_APPLY);
response(Gtk::RESPONSE_APPLY);
}
void CheatEditDialog::vOnCancel() {
response(Gtk::RESPONSE_CANCEL);
void CheatEditDialog::vOnCancel()
{
response(Gtk::RESPONSE_CANCEL);
}
} // namespace VBA

View File

@ -27,50 +27,51 @@
#include "window.h"
namespace VBA
{
enum ECheatType { CheatGeneric, CheatGSA, CheatCBA, CheatGS, CheatGG };
namespace VBA {
enum ECheatType { CheatGeneric,
CheatGSA,
CheatCBA,
CheatGS,
CheatGG };
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
{
public:
EditCheatCodeColumns()
{
add(uText);
add(iType);
}
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
public:
EditCheatCodeColumns()
{
add(uText);
add(iType);
}
~EditCheatCodeColumns()
{
}
~EditCheatCodeColumns()
{
}
Gtk::TreeModelColumn<Glib::ustring> uText;
Gtk::TreeModelColumn<ECheatType> iType;
Gtk::TreeModelColumn<Glib::ustring> uText;
Gtk::TreeModelColumn<ECheatType> iType;
};
class CheatEditDialog : public Gtk::Dialog
{
public:
CheatEditDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
Glib::ustring vGetDesc();
ECheatType vGetType();
void vSetWindow(VBA::Window *_poWindow);
class CheatEditDialog : public Gtk::Dialog {
public:
CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
Glib::ustring vGetDesc();
ECheatType vGetType();
void vSetWindow(VBA::Window* _poWindow);
private:
void vOnApply();
void vOnCancel();
private:
void vOnApply();
void vOnCancel();
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Gtk::Entry *m_poCheatDescEntry;
Gtk::ComboBox *m_poCheatTypeComboBox;
Gtk::TextView *m_poCheatInputTextView;
Gtk::Button *m_poCheatApplyButton;
Gtk::Button *m_poCheatCancelButton;
Glib::RefPtr<Gtk::TextBuffer> m_poCheatInputBuffer;
Glib::RefPtr<Gtk::ListStore> m_poCheatTypeStore;
EditCheatCodeColumns m_oTypeModel;
Gtk::Entry* m_poCheatDescEntry;
Gtk::ComboBox* m_poCheatTypeComboBox;
Gtk::TextView* m_poCheatInputTextView;
Gtk::Button* m_poCheatApplyButton;
Gtk::Button* m_poCheatCancelButton;
Glib::RefPtr<Gtk::TextBuffer> m_poCheatInputBuffer;
Glib::RefPtr<Gtk::ListStore> m_poCheatTypeStore;
EditCheatCodeColumns m_oTypeModel;
};
} // namespace VBA

View File

@ -24,150 +24,145 @@
#include "intl.h"
#include <vector>
namespace VBA
namespace VBA {
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
{
refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
refBuilder->get_widget("CheatAddButton", m_poCheatAddButton);
refBuilder->get_widget("CheatRemoveButton", m_poCheatRemoveButton);
refBuilder->get_widget("CheatRemoveAllButton", m_poCheatRemoveAllButton);
refBuilder->get_widget("CheatMarkAllButton", m_poCheatMarkAllButton);
refBuilder->get_widget("CheatTreeView", m_poCheatTreeView);
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog)
{
refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
refBuilder->get_widget("CheatAddButton", m_poCheatAddButton);
refBuilder->get_widget("CheatRemoveButton", m_poCheatRemoveButton);
refBuilder->get_widget("CheatRemoveAllButton", m_poCheatRemoveAllButton);
refBuilder->get_widget("CheatMarkAllButton", m_poCheatMarkAllButton);
refBuilder->get_widget("CheatTreeView", m_poCheatTreeView);
// Tree View model
m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);
// Tree View model
m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);
m_poCheatTreeView->set_model(m_poCheatListStore);
m_poCheatTreeView->set_model(m_poCheatListStore);
Gtk::CellRendererToggle* pRenderer = Gtk::manage(new Gtk::CellRendererToggle());
Gtk::CellRendererToggle* pRenderer = Gtk::manage(new Gtk::CellRendererToggle());
int cols_count = m_poCheatTreeView->append_column("", *pRenderer);
int cols_count = m_poCheatTreeView->append_column("", *pRenderer);
pRenderer->signal_toggled().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatToggled));
pRenderer->signal_toggled().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatToggled));
Gtk::TreeViewColumn* pColumn = m_poCheatTreeView->get_column(cols_count - 1);
Gtk::TreeViewColumn* pColumn = m_poCheatTreeView->get_column(cols_count - 1);
if (pColumn)
pColumn->add_attribute(pRenderer->property_active(), m_oRecordModel.bEnabled);
if (pColumn)
pColumn->add_attribute(pRenderer->property_active(), m_oRecordModel.bEnabled);
m_poCheatTreeView->append_column("Description", m_oRecordModel.uDesc);
m_poCheatTreeView->append_column("Description", m_oRecordModel.uDesc);
m_poCheatOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListOpen));
m_poCheatSaveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListSave));
m_poCheatAddButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatAdd));
m_poCheatRemoveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemove));
m_poCheatRemoveAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemoveAll));
m_poCheatMarkAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatMarkAll));
m_poCheatOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListOpen));
m_poCheatSaveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatListSave));
m_poCheatAddButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatAdd));
m_poCheatRemoveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemove));
m_poCheatRemoveAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatRemoveAll));
m_poCheatMarkAllButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatMarkAll));
bMark = false;
bMark = false;
}
void CheatListDialog::vOnCheatListOpen()
{
Gtk::FileChooserDialog oDialog(*this, _("Open cheat list"));
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
Gtk::FileChooserDialog oDialog(*this, _("Open cheat list"));
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
oDialog.set_current_folder(Glib::get_home_dir());
oDialog.set_current_folder(Glib::get_home_dir());
while (oDialog.run() == Gtk::RESPONSE_OK)
{
// delete existing cheats before loading the list
vRemoveAllCheats();
while (oDialog.run() == Gtk::RESPONSE_OK) {
// delete existing cheats before loading the list
vRemoveAllCheats();
m_poCheatListStore->clear();
m_poCheatListStore->clear();
if (vCheatListOpen(oDialog.get_filename().c_str()))
{
vUpdateList();
break;
if (vCheatListOpen(oDialog.get_filename().c_str())) {
vUpdateList();
break;
}
}
}
}
void CheatListDialog::vOnCheatListSave()
{
Gtk::FileChooserDialog sDialog(*this, _("Save cheat list"));
sDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
sDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
Gtk::FileChooserDialog sDialog(*this, _("Save cheat list"));
sDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
sDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
sDialog.set_current_folder(Glib::get_home_dir());
sDialog.set_current_folder(Glib::get_home_dir());
if (sDialog.run() == Gtk::RESPONSE_OK)
vCheatListSave(sDialog.get_filename().c_str());
if (sDialog.run() == Gtk::RESPONSE_OK)
vCheatListSave(sDialog.get_filename().c_str());
}
void CheatListDialog::vOnCheatAdd()
{
std::string sUiFile = VBA::Window::sGetUiFilePath("cheatedit.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
std::string sUiFile = VBA::Window::sGetUiFilePath("cheatedit.ui");
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
CheatEditDialog * poDialog = 0;
poBuilder->get_widget_derived("CheatEditDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vSetWindow(m_poWindow);
int response = poDialog->run();
poDialog->hide();
CheatEditDialog* poDialog = 0;
poBuilder->get_widget_derived("CheatEditDialog", poDialog);
poDialog->set_transient_for(*this);
poDialog->vSetWindow(m_poWindow);
int response = poDialog->run();
poDialog->hide();
if (response == Gtk::RESPONSE_APPLY)
vAddCheat(poDialog->vGetDesc(), poDialog->vGetType(), poDialog->vGetCode());
if (response == Gtk::RESPONSE_APPLY)
vAddCheat(poDialog->vGetDesc(), poDialog->vGetType(), poDialog->vGetCode());
}
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)
{
Gtk::TreeModel::Row row = *iter;
if (iter) {
Gtk::TreeModel::Row row = *iter;
vRemoveCheat(row[m_oRecordModel.iIndex]);
vRemoveCheat(row[m_oRecordModel.iIndex]);
m_poCheatListStore->erase(iter);
}
m_poCheatListStore->erase(iter);
}
}
void CheatListDialog::vOnCheatRemoveAll()
{
vRemoveAllCheats();
vRemoveAllCheats();
m_poCheatListStore->clear();
m_poCheatListStore->clear();
}
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++)
{
Gtk::TreeModel::Row row = *iter;
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++) {
Gtk::TreeModel::Row row = *iter;
row[m_oRecordModel.bEnabled] = bMark;
row[m_oRecordModel.bEnabled] = bMark;
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
}
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
}
bMark = !bMark;
bMark = !bMark;
}
void CheatListDialog::vOnCheatToggled(Glib::ustring const& string_path)
{
Gtk::TreeIter iter = m_poCheatListStore->get_iter(string_path);
Gtk::TreeIter iter = m_poCheatListStore->get_iter(string_path);
Gtk::TreeModel::Row row = *iter;
Gtk::TreeModel::Row row = *iter;
row[m_oRecordModel.bEnabled] = !row[m_oRecordModel.bEnabled];
row[m_oRecordModel.bEnabled] = !row[m_oRecordModel.bEnabled];
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
}
void CheatListDialog::vSetWindow(VBA::Window * _poWindow)
void CheatListDialog::vSetWindow(VBA::Window* _poWindow)
{
m_poWindow = _poWindow;
m_poWindow = _poWindow;
}
} // namespace VBA

View File

@ -25,66 +25,64 @@
#include "window.h"
namespace VBA
{
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ListCheatCodeColumns()
{
add(iIndex);
add(bEnabled);
add(uDesc);
}
namespace VBA {
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
public:
ListCheatCodeColumns()
{
add(iIndex);
add(bEnabled);
add(uDesc);
}
~ListCheatCodeColumns()
{
}
~ListCheatCodeColumns()
{
}
Gtk::TreeModelColumn<int> iIndex;
Gtk::TreeModelColumn<bool> bEnabled;
Gtk::TreeModelColumn<Glib::ustring> uDesc;
Gtk::TreeModelColumn<int> iIndex;
Gtk::TreeModelColumn<bool> bEnabled;
Gtk::TreeModelColumn<Glib::ustring> uDesc;
};
class CheatListDialog : public Gtk::Dialog
{
public:
CheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
void vSetWindow(VBA::Window *_poWindow);
class CheatListDialog : public Gtk::Dialog {
public:
CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetWindow(VBA::Window* _poWindow);
protected:
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
Glib::RefPtr<Gtk::TextBuffer> buffer) = 0;
virtual bool vCheatListOpen(const char *file) = 0;
virtual void vCheatListSave(const char *file) = 0;
virtual void vRemoveCheat(int index) = 0;
virtual void vRemoveAllCheats() = 0;
virtual void vToggleCheat(int index, bool enable) = 0;
virtual void vUpdateList(int previous = 0) = 0;
protected:
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
Glib::RefPtr<Gtk::TextBuffer> buffer)
= 0;
virtual bool vCheatListOpen(const char* file) = 0;
virtual void vCheatListSave(const char* file) = 0;
virtual void vRemoveCheat(int index) = 0;
virtual void vRemoveAllCheats() = 0;
virtual void vToggleCheat(int index, bool enable) = 0;
virtual void vUpdateList(int previous = 0) = 0;
Glib::RefPtr<Gtk::ListStore> m_poCheatListStore;
ListCheatCodeColumns m_oRecordModel;
Glib::RefPtr<Gtk::ListStore> m_poCheatListStore;
ListCheatCodeColumns m_oRecordModel;
private:
void vOnCheatListOpen();
void vOnCheatListSave();
void vOnCheatAdd();
void vOnCheatRemove();
void vOnCheatRemoveAll();
void vOnCheatMarkAll();
void vOnCheatToggled(Glib::ustring const &string_path);
private:
void vOnCheatListOpen();
void vOnCheatListSave();
void vOnCheatAdd();
void vOnCheatRemove();
void vOnCheatRemoveAll();
void vOnCheatMarkAll();
void vOnCheatToggled(Glib::ustring const& string_path);
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Gtk::ToolButton *m_poCheatOpenButton;
Gtk::ToolButton *m_poCheatSaveButton;
Gtk::ToolButton *m_poCheatAddButton;
Gtk::ToolButton *m_poCheatRemoveButton;
Gtk::ToolButton *m_poCheatRemoveAllButton;
Gtk::ToolButton *m_poCheatMarkAllButton;
Gtk::TreeView *m_poCheatTreeView;
Gtk::ToolButton* m_poCheatOpenButton;
Gtk::ToolButton* m_poCheatSaveButton;
Gtk::ToolButton* m_poCheatAddButton;
Gtk::ToolButton* m_poCheatRemoveButton;
Gtk::ToolButton* m_poCheatRemoveAllButton;
Gtk::ToolButton* m_poCheatMarkAllButton;
Gtk::TreeView* m_poCheatTreeView;
bool bMark;
bool bMark;
};
} // namespace VBA

View File

@ -23,239 +23,203 @@
#include <glibmm/fileutils.h>
#include <glibmm/iochannel.h>
namespace VBA
{
namespace Config
{
namespace VBA {
namespace Config {
using std::string;
using Glib::IOChannel;
using std::string;
using Glib::IOChannel;
Line::Line(const string & _rsKey, const string & _rsValue) :
m_sKey(_rsKey),
m_sValue(_rsValue)
{
}
Section::Section(const string & _rsName) :
m_sName(_rsName)
{
}
bool Section::bKeyExists(const string & _rsKey)
{
for (iterator it = begin(); it != end(); it++)
{
if (it->m_sKey == _rsKey)
Line::Line(const string& _rsKey, const string& _rsValue)
: m_sKey(_rsKey)
, m_sValue(_rsValue)
{
return true;
}
}
return false;
}
void Section::vSetKey(const string & _rsKey, const string & _rsValue)
{
for (iterator it = begin(); it != end(); it++)
{
if (it->m_sKey == _rsKey)
Section::Section(const string& _rsName)
: m_sName(_rsName)
{
it->m_sValue = _rsValue;
return;
}
}
push_back(Line(_rsKey, _rsValue));
}
string Section::sGetKey(const string & _rsKey) const
{
for (const_iterator it = begin(); it != end(); it++)
{
if (it->m_sKey == _rsKey)
bool Section::bKeyExists(const string& _rsKey)
{
return it->m_sValue;
}
}
throw KeyNotFound(m_sName, _rsKey);
}
void Section::vRemoveKey(const string & _rsKey)
{
for (iterator it = begin(); it != end(); it++)
{
if (it->m_sKey == _rsKey)
{
erase(it);
return;
}
}
}
File::File()
{
}
File::File(const string & _rsFile)
{
vLoad(_rsFile);
}
File::~File()
{
}
bool File::bSectionExists(const string & _rsName)
{
for (iterator it = begin(); it != end(); it++)
{
if (it->sGetName() == _rsName)
{
return true;
}
}
return false;
}
Section * File::poAddSection(const string & _rsName)
{
Section * poSection = NULL;
for (iterator it = begin(); it != end(); it++)
{
if (it->sGetName() == _rsName)
{
poSection = &(*it);
}
}
if (poSection == NULL)
{
push_back(Section(_rsName));
poSection = &back();
}
return poSection;
}
Section * File::poGetSection(const string & _rsName)
{
for (iterator it = begin(); it != end(); it++)
{
if (it->sGetName() == _rsName)
{
return &(*it);
}
}
throw SectionNotFound(_rsName);
}
void File::vRemoveSection(const string & _rsName)
{
for (iterator it = begin(); it != end(); it++)
{
if (it->sGetName() == _rsName)
{
erase(it);
return;
}
}
}
void File::vLoad(const string & _rsFile,
bool _bAddSection,
bool _bAddKey)
{
string sBuffer = Glib::file_get_contents(_rsFile);
Section * poSection = NULL;
char ** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
char * tmp;
int i = 0;
while (lines[i])
{
if (lines[i][0] == '[')
{
if ((tmp = strchr(lines[i], ']')))
{
*tmp = '\0';
if (_bAddSection)
{
poSection = poAddSection(&lines[i][1]);
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
return true;
}
}
else
{
try
{
poSection = poGetSection(&lines[i][1]);
}
catch (...)
{
poSection = NULL;
}
return false;
}
void Section::vSetKey(const string& _rsKey, const string& _rsValue)
{
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
it->m_sValue = _rsValue;
return;
}
}
}
push_back(Line(_rsKey, _rsValue));
}
else if (lines[i][0] != '#' && poSection != NULL)
string Section::sGetKey(const string& _rsKey) const
{
if ((tmp = strchr(lines[i], '=')))
{
*tmp = '\0';
tmp++;
if (_bAddKey || poSection->bKeyExists(lines[i]))
{
poSection->vSetKey(lines[i], tmp);
for (const_iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
return it->m_sValue;
}
}
}
throw KeyNotFound(m_sName, _rsKey);
}
i++;
}
g_strfreev(lines);
}
void File::vSave(const string & _rsFile)
{
Glib::RefPtr<IOChannel> poFile = IOChannel::create_from_file(_rsFile, "w");
poFile->set_encoding("");
for (const_iterator poSection = begin();
poSection != end();
poSection++)
{
string sName = "[" + poSection->sGetName() + "]\n";
poFile->write(sName);
for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end();
poLine++)
void Section::vRemoveKey(const string& _rsKey)
{
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
poFile->write(sLine);
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
erase(it);
return;
}
}
}
poFile->write("\n");
}
}
void File::vClear()
{
clear();
}
std::ostream & operator<<(std::ostream & _roOut, const File & _roFile)
{
for (File::const_iterator poSection = _roFile.begin();
poSection != _roFile.end();
poSection++)
{
string sName = "[" + poSection->sGetName() + "]\n";
_roOut << sName;
for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end();
poLine++)
File::File()
{
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
_roOut << sLine;
}
_roOut << "\n";
}
return _roOut;
}
File::File(const string& _rsFile)
{
vLoad(_rsFile);
}
File::~File()
{
}
bool File::bSectionExists(const string& _rsName)
{
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
return true;
}
}
return false;
}
Section* File::poAddSection(const string& _rsName)
{
Section* poSection = NULL;
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
poSection = &(*it);
}
}
if (poSection == NULL) {
push_back(Section(_rsName));
poSection = &back();
}
return poSection;
}
Section* File::poGetSection(const string& _rsName)
{
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
return &(*it);
}
}
throw SectionNotFound(_rsName);
}
void File::vRemoveSection(const string& _rsName)
{
for (iterator it = begin(); it != end(); it++) {
if (it->sGetName() == _rsName) {
erase(it);
return;
}
}
}
void File::vLoad(const string& _rsFile,
bool _bAddSection,
bool _bAddKey)
{
string sBuffer = Glib::file_get_contents(_rsFile);
Section* poSection = NULL;
char** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
char* tmp;
int i = 0;
while (lines[i]) {
if (lines[i][0] == '[') {
if ((tmp = strchr(lines[i], ']'))) {
*tmp = '\0';
if (_bAddSection) {
poSection = poAddSection(&lines[i][1]);
} else {
try {
poSection = poGetSection(&lines[i][1]);
} catch (...) {
poSection = NULL;
}
}
}
} else if (lines[i][0] != '#' && poSection != NULL) {
if ((tmp = strchr(lines[i], '='))) {
*tmp = '\0';
tmp++;
if (_bAddKey || poSection->bKeyExists(lines[i])) {
poSection->vSetKey(lines[i], tmp);
}
}
}
i++;
}
g_strfreev(lines);
}
void File::vSave(const string& _rsFile)
{
Glib::RefPtr<IOChannel> poFile = IOChannel::create_from_file(_rsFile, "w");
poFile->set_encoding("");
for (const_iterator poSection = begin();
poSection != end();
poSection++) {
string sName = "[" + poSection->sGetName() + "]\n";
poFile->write(sName);
for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end();
poLine++) {
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
poFile->write(sLine);
}
poFile->write("\n");
}
}
void File::vClear()
{
clear();
}
std::ostream& operator<<(std::ostream& _roOut, const File& _roFile)
{
for (File::const_iterator poSection = _roFile.begin();
poSection != _roFile.end();
poSection++) {
string sName = "[" + poSection->sGetName() + "]\n";
_roOut << sName;
for (Section::const_iterator poLine = poSection->begin();
poLine != poSection->end();
poLine++) {
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
_roOut << sLine;
}
_roOut << "\n";
}
return _roOut;
}
} // namespace Config
} // namespace VBA

View File

@ -23,27 +23,24 @@
#include <list>
#include <sstream>
namespace VBA
{
namespace Config
{
class NotFound
{
public:
namespace VBA {
namespace Config {
class NotFound {
public:
virtual ~NotFound()
{
}
protected:
protected:
NotFound()
{
}
};
};
class SectionNotFound : public NotFound
{
public:
SectionNotFound(const std::string &_rsName) : m_sName(_rsName)
class SectionNotFound : public NotFound {
public:
SectionNotFound(const std::string& _rsName)
: m_sName(_rsName)
{
}
virtual ~SectionNotFound()
@ -52,18 +49,18 @@ class SectionNotFound : public NotFound
inline std::string sGetName() const
{
return m_sName;
return m_sName;
}
private:
private:
std::string m_sName;
};
};
class KeyNotFound : public NotFound
{
public:
KeyNotFound(const std::string &_rsSection, const std::string &_rsKey)
: m_sSection(_rsSection), m_sKey(_rsKey)
class KeyNotFound : public NotFound {
public:
KeyNotFound(const std::string& _rsSection, const std::string& _rsKey)
: m_sSection(_rsSection)
, m_sKey(_rsKey)
{
}
virtual ~KeyNotFound()
@ -72,135 +69,136 @@ class KeyNotFound : public NotFound
inline std::string sGetSection() const
{
return m_sSection;
return m_sSection;
}
inline std::string sGetKey() const
{
return m_sKey;
return m_sKey;
}
private:
private:
std::string m_sSection;
std::string m_sKey;
};
};
class Line
{
public:
Line(const std::string &_rsKey, const std::string &_rsValue);
class Line {
public:
Line(const std::string& _rsKey, const std::string& _rsValue);
std::string m_sKey;
std::string m_sValue;
};
};
class Section : private std::list<Line>
{
public:
explicit Section(const std::string &_rsName);
class Section : private std::list<Line> {
public:
explicit Section(const std::string& _rsName);
inline std::string sGetName() const
{
return m_sName;
return m_sName;
}
bool bKeyExists(const std::string &_rsKey);
void vSetKey(const std::string &_rsKey, const std::string &_rsValue);
std::string sGetKey(const std::string &_rsKey) const;
void vRemoveKey(const std::string &_rsKey);
bool bKeyExists(const std::string& _rsKey);
void vSetKey(const std::string& _rsKey, const std::string& _rsValue);
std::string sGetKey(const std::string& _rsKey) const;
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
typedef std::list<Line>::const_iterator const_iterator;
inline const_iterator begin() const
{
return std::list<Line>::begin();
return std::list<Line>::begin();
}
inline const_iterator end() const
{
return std::list<Line>::end();
return std::list<Line>::end();
}
private:
private:
inline iterator begin()
{
return std::list<Line>::begin();
return std::list<Line>::begin();
}
inline iterator end()
{
return std::list<Line>::end();
return std::list<Line>::end();
}
std::string m_sName;
};
};
class File : private std::list<Section>
{
public:
class File : private std::list<Section> {
public:
File();
File(const std::string &_rsFile);
File(const std::string& _rsFile);
virtual ~File();
bool bSectionExists(const std::string &_rsName);
Section *poAddSection(const std::string &_rsName);
Section *poGetSection(const std::string &_rsName);
void vRemoveSection(const std::string &_rsName);
void vLoad(const std::string &_rsFile, bool _bAddSection = true, bool _bAddKey = true);
void vSave(const std::string &_rsFile);
bool bSectionExists(const std::string& _rsName);
Section* poAddSection(const std::string& _rsName);
Section* poGetSection(const std::string& _rsName);
void vRemoveSection(const std::string& _rsName);
void vLoad(const std::string& _rsFile, bool _bAddSection = true, bool _bAddKey = true);
void vSave(const std::string& _rsFile);
void vClear();
// read only
typedef std::list<Section>::const_iterator const_iterator;
inline const_iterator begin() const
{
return std::list<Section>::begin();
return std::list<Section>::begin();
}
inline const_iterator end() const
{
return std::list<Section>::end();
return std::list<Section>::end();
}
private:
private:
inline iterator begin()
{
return std::list<Section>::begin();
return std::list<Section>::begin();
}
inline iterator end()
{
return std::list<Section>::end();
return std::list<Section>::end();
}
};
};
// debug
std::ostream &operator<<(std::ostream &_roOut, const File &_roConfig);
// debug
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;
oOut << _rValue;
for (iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
it->m_sValue = oOut.str();
return;
}
if (it->m_sKey == _rsKey) {
it->m_sValue = oOut.str();
return;
}
}
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;
for (const_iterator it = begin(); it != end(); it++) {
if (it->m_sKey == _rsKey) {
std::istringstream oIn(it->m_sValue);
oIn >> oValue;
return oValue;
}
if (it->m_sKey == _rsKey) {
std::istringstream oIn(it->m_sValue);
oIn >> oValue;
return oValue;
}
}
throw KeyNotFound(m_sName, _rsKey);
}
}
} // namespace Config
} // namespace VBA

View File

@ -22,48 +22,44 @@
#include "intl.h"
namespace VBA
{
namespace VBA {
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] =
{
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = {
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
{ "cheats", N_("Cheats :"), "CheatsDirEntry" },
{ "saves", N_("Saves :"), "SavesDirEntry" },
{ "captures", N_("Captures :"), "CapturesDirEntry" }
{ "cheats", N_("Cheats :"), "CheatsDirEntry" },
{ "saves", N_("Saves :"), "SavesDirEntry" },
{ "captures", N_("Captures :"), "CapturesDirEntry" }
};
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section * _poConfig) :
Gtk::Dialog(_("Directories config"), true),
m_poConfig(_poConfig)
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section* _poConfig)
: Gtk::Dialog(_("Directories config"), true)
, m_poConfig(_poConfig)
{
Gtk::Table * poTable = Gtk::manage( new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
poTable->set_border_width(5);
poTable->set_spacings(5);
Gtk::Table* poTable = Gtk::manage(new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
poTable->set_border_width(5);
poTable->set_spacings(5);
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) );
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));
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));
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));
poTable->attach(* poLabel, 0, 1, i, i + 1);
poTable->attach(* m_poButtons[i], 1, 2, i, i + 1);
}
poTable->attach(*poLabel, 0, 1, i, i + 1);
poTable->attach(*m_poButtons[i], 1, 2, i, i + 1);
}
add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
get_vbox()->pack_start(* poTable);
show_all_children();
add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
get_vbox()->pack_start(*poTable);
show_all_children();
}
void DirectoriesConfigDialog::on_response(int response_id)
{
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());
}
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());
}
}
} // namespace VBA

View File

@ -26,26 +26,24 @@
#include "configfile.h"
namespace VBA
{
class DirectoriesConfigDialog : public Gtk::Dialog
{
public:
DirectoriesConfigDialog(Config::Section *_poConfig);
namespace VBA {
class DirectoriesConfigDialog : public Gtk::Dialog {
public:
DirectoriesConfigDialog(Config::Section* _poConfig);
protected:
void on_response(int response_id);
protected:
void on_response(int response_id);
private:
struct SDirEntry {
const char *m_csKey;
const char *m_csLabel;
const char *m_csFileChooserButton;
};
private:
struct SDirEntry {
const char* m_csKey;
const char* m_csLabel;
const char* m_csFileChooserButton;
};
Config::Section *m_poConfig;
static const SDirEntry m_astDirs[];
Gtk::FileChooserButton *m_poButtons[6];
Config::Section* m_poConfig;
static const SDirEntry m_astDirs[];
Gtk::FileChooserButton* m_poButtons[6];
};
} // namespace VBA

View File

@ -18,129 +18,119 @@
#include "displayconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/liststore.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/stock.h>
#include "intl.h"
#include "filters.h"
#include "intl.h"
namespace VBA
namespace VBA {
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
refBuilder->get_widget("DefaultScaleComboBox", m_poDefaultScaleComboBox);
refBuilder->get_widget("OutputOpenGL", m_poOutputOpenGLRadioButton);
refBuilder->get_widget("OutputCairo", m_poOutputCairoRadioButton);
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog),
m_poConfig(0)
{
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
refBuilder->get_widget("DefaultScaleComboBox", m_poDefaultScaleComboBox);
refBuilder->get_widget("OutputOpenGL", m_poOutputOpenGLRadioButton);
refBuilder->get_widget("OutputCairo", m_poOutputCairoRadioButton);
m_poFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterChanged));
m_poIBFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterIBChanged));
m_poDefaultScaleComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnScaleChanged));
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_poFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterChanged));
m_poIBFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterIBChanged));
m_poDefaultScaleComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnScaleChanged));
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));
// Populate the filters combobox
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
for (guint i = FirstFilter; i <= LastFilter; i++) {
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
}
// Populate the filters combobox
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
// Populate the interframe blending filters combobox
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
for (guint i = FirstFilter; i <= LastFilter; i++)
{
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
}
// Populate the interframe blending filters combobox
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
for (guint i = FirstFilterIB; i <= LastFilterIB; i++)
{
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
}
for (guint i = FirstFilterIB; i <= LastFilterIB; i++) {
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
}
}
void DisplayConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
void DisplayConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
m_poConfig = _poConfig;
m_poWindow = _poWindow;
int iDefaultFilter = m_poConfig->oGetKey<int>("filter2x");
m_poFiltersComboBox->set_active(iDefaultFilter);
int iDefaultFilter = m_poConfig->oGetKey<int>("filter2x");
m_poFiltersComboBox->set_active(iDefaultFilter);
int iDefaultFilterIB = m_poConfig->oGetKey<int>("filterIB");
m_poIBFiltersComboBox->set_active(iDefaultFilterIB);
int iDefaultFilterIB = m_poConfig->oGetKey<int>("filterIB");
m_poIBFiltersComboBox->set_active(iDefaultFilterIB);
int iDefaultScale = m_poConfig->oGetKey<int>("scale");
m_poDefaultScaleComboBox->set_active(iDefaultScale - 1);
int iDefaultScale = m_poConfig->oGetKey<int>("scale");
m_poDefaultScaleComboBox->set_active(iDefaultScale - 1);
// Set the default output module
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
switch (_eOutput)
{
// Set the default output module
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
switch (_eOutput) {
case VBA::Window::OutputOpenGL:
m_poOutputOpenGLRadioButton->set_active();
break;
m_poOutputOpenGLRadioButton->set_active();
break;
default:
m_poOutputCairoRadioButton->set_active();
break;
}
m_poOutputCairoRadioButton->set_active();
break;
}
}
void DisplayConfigDialog::vOnFilterChanged()
{
int iFilter = m_poFiltersComboBox->get_active_row_number();
if (iFilter >= 0)
{
m_poConfig->vSetKey("filter2x", iFilter);
m_poWindow->vApplyConfigFilter();
}
int iFilter = m_poFiltersComboBox->get_active_row_number();
if (iFilter >= 0) {
m_poConfig->vSetKey("filter2x", iFilter);
m_poWindow->vApplyConfigFilter();
}
}
void DisplayConfigDialog::vOnFilterIBChanged()
{
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
if (iFilterIB >= 0)
{
m_poConfig->vSetKey("filterIB", iFilterIB);
m_poWindow->vApplyConfigFilterIB();
}
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
if (iFilterIB >= 0) {
m_poConfig->vSetKey("filterIB", iFilterIB);
m_poWindow->vApplyConfigFilterIB();
}
}
void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
{
VBA::Window::EVideoOutput eOldOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
VBA::Window::EVideoOutput eOldOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
if (_eOutput == eOldOutput)
return;
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active())
{
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
m_poWindow->vApplyConfigScreenArea();
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active())
{
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
m_poWindow->vApplyConfigScreenArea();
}
if (_eOutput == eOldOutput)
return;
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active()) {
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
m_poWindow->vApplyConfigScreenArea();
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active()) {
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
m_poWindow->vApplyConfigScreenArea();
}
}
void DisplayConfigDialog::vOnScaleChanged()
{
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
if (iScale > 0)
{
m_poConfig->vSetKey("scale", iScale);
m_poWindow->vUpdateScreen();
}
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
if (iScale > 0) {
m_poConfig->vSetKey("scale", iScale);
m_poWindow->vUpdateScreen();
}
}
} // namespace VBA

View File

@ -27,29 +27,27 @@
#include "configfile.h"
#include "window.h"
namespace VBA
{
class DisplayConfigDialog : public Gtk::Dialog
{
public:
DisplayConfigDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class DisplayConfigDialog : public Gtk::Dialog {
public:
DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnFilterChanged();
void vOnFilterIBChanged();
void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput);
void vOnScaleChanged();
private:
void vOnFilterChanged();
void vOnFilterIBChanged();
void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput);
void vOnScaleChanged();
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Config::Section *m_poConfig;
Gtk::ComboBox *m_poFiltersComboBox;
Gtk::ComboBox *m_poIBFiltersComboBox;
Gtk::ComboBox *m_poDefaultScaleComboBox;
Gtk::RadioButton *m_poOutputOpenGLRadioButton;
Gtk::RadioButton *m_poOutputCairoRadioButton;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poFiltersComboBox;
Gtk::ComboBox* m_poIBFiltersComboBox;
Gtk::ComboBox* m_poDefaultScaleComboBox;
Gtk::RadioButton* m_poOutputOpenGLRadioButton;
Gtk::RadioButton* m_poOutputCairoRadioButton;
};
} // namespace VBA

View File

@ -19,89 +19,84 @@
#include "filters.h"
#include "intl.h"
void _2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int);
void _2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Super2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int);
void Super2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void SuperEagle (u8 *, u32, u8 *, u8 *, u32, int, int);
void SuperEagle32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Pixelate (u8 *, u32, u8 *, u8 *, u32, int, int);
void Pixelate32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void AdMame2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void AdMame2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void Bilinear (u8 *, u32, u8 *, u8 *, u32, int, int);
void Bilinear32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void BilinearPlus (u8 *, u32, u8 *, u8 *, u32, int, int);
void BilinearPlus32(u8 *, u32, u8 *, u8 *, u32, int, int);
void Scanlines (u8 *, u32, u8 *, u8 *, u32, int, int);
void Scanlines32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void ScanlinesTV (u8 *, u32, u8 *, u8 *, u32, int, int);
void ScanlinesTV32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void hq2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void hq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void lq2x (u8 *, u32, u8 *, u8 *, u32, int, int);
void lq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void xbrz2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
void _2xSaI(u8*, u32, u8*, u8*, u32, int, int);
void _2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
void Super2xSaI(u8*, u32, u8*, u8*, u32, int, int);
void Super2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
void SuperEagle(u8*, u32, u8*, u8*, u32, int, int);
void SuperEagle32(u8*, u32, u8*, u8*, u32, int, int);
void Pixelate(u8*, u32, u8*, u8*, u32, int, int);
void Pixelate32(u8*, u32, u8*, u8*, u32, int, int);
void AdMame2x(u8*, u32, u8*, u8*, u32, int, int);
void AdMame2x32(u8*, u32, u8*, u8*, u32, int, int);
void Bilinear(u8*, u32, u8*, u8*, u32, int, int);
void Bilinear32(u8*, u32, u8*, u8*, u32, int, int);
void BilinearPlus(u8*, u32, u8*, u8*, u32, int, int);
void BilinearPlus32(u8*, u32, u8*, u8*, u32, int, int);
void Scanlines(u8*, u32, u8*, u8*, u32, int, int);
void Scanlines32(u8*, u32, u8*, u8*, u32, int, int);
void ScanlinesTV(u8*, u32, u8*, u8*, u32, int, int);
void ScanlinesTV32(u8*, u32, u8*, u8*, u32, int, int);
void hq2x(u8*, u32, u8*, u8*, u32, int, int);
void hq2x32(u8*, u32, u8*, u8*, u32, int, int);
void lq2x(u8*, u32, u8*, u8*, u32, int, int);
void lq2x32(u8*, u32, u8*, u8*, u32, int, int);
void xbrz2x32(u8*, u32, u8*, u8*, u32, int, int);
void SmartIB (u8 *, u32, int, int);
void SmartIB32 (u8 *, u32, int, int);
void MotionBlurIB (u8 *, u32, int, int);
void MotionBlurIB32(u8 *, u32, int, int);
void SmartIB(u8*, u32, int, int);
void SmartIB32(u8*, u32, int, int);
void MotionBlurIB(u8*, u32, int, int);
void MotionBlurIB32(u8*, u32, int, int);
namespace VBA
{
namespace VBA {
struct {
char m_csName[30];
int m_iEnlargeFactor;
Filter m_apvFunc[2];
}
static const astFilters[] =
{
{ N_("None"), 1, { 0, 0 } },
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
{ N_("Super Eagle"), 2, { SuperEagle, SuperEagle32 } },
{ N_("Pixelate"), 2, { Pixelate, Pixelate32 } },
{ N_("AdvanceMAME Scale2x"), 2, { AdMame2x, AdMame2x32 } },
{ N_("Bilinear"), 2, { Bilinear, Bilinear32 } },
{ N_("Bilinear Plus"), 2, { BilinearPlus, BilinearPlus32 } },
{ N_("Scanlines"), 2, { Scanlines, Scanlines32 } },
{ N_("TV Mode"), 2, { ScanlinesTV, ScanlinesTV32 } },
{ N_("hq2x"), 2, { hq2x, hq2x32 } },
{ N_("lq2x"), 2, { lq2x, lq2x32 } },
{ N_("xbrz2x"), 2, { 0, xbrz2x32 } }
char m_csName[30];
int m_iEnlargeFactor;
Filter m_apvFunc[2];
} static const astFilters[] = {
{ N_("None"), 1, { 0, 0 } },
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
{ N_("Super Eagle"), 2, { SuperEagle, SuperEagle32 } },
{ N_("Pixelate"), 2, { Pixelate, Pixelate32 } },
{ N_("AdvanceMAME Scale2x"), 2, { AdMame2x, AdMame2x32 } },
{ N_("Bilinear"), 2, { Bilinear, Bilinear32 } },
{ N_("Bilinear Plus"), 2, { BilinearPlus, BilinearPlus32 } },
{ N_("Scanlines"), 2, { Scanlines, Scanlines32 } },
{ N_("TV Mode"), 2, { ScanlinesTV, ScanlinesTV32 } },
{ N_("hq2x"), 2, { hq2x, hq2x32 } },
{ N_("lq2x"), 2, { lq2x, lq2x32 } },
{ N_("xbrz2x"), 2, { 0, xbrz2x32 } }
};
struct {
char m_csName[30];
FilterIB m_apvFunc[2];
}
static const astFiltersIB[] =
{
{ N_("None"), { 0, 0 } },
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
char m_csName[30];
FilterIB m_apvFunc[2];
} static const astFiltersIB[] = {
{ N_("None"), { 0, 0 } },
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
};
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth)
{
return astFilters[_eFilter].m_apvFunc[_eDepth];
return astFilters[_eFilter].m_apvFunc[_eDepth];
}
const char* pcsGetFilterName(const EFilter _eFilter)
{
return gettext(astFilters[_eFilter].m_csName);
return gettext(astFilters[_eFilter].m_csName);
}
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth)
{
return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth];
return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth];
}
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB)
{
return gettext(astFiltersIB[_eFilterIB].m_csName);
return gettext(astFiltersIB[_eFilterIB].m_csName);
}
} // namespace VBA

View File

@ -24,44 +24,44 @@
int Init_2xSaI(u32);
namespace VBA
{
typedef void (*Filter)(u8 *, u32, u8 *, u8 *, u32, int, int);
typedef void (*FilterIB)(u8 *, u32, int, int);
namespace VBA {
typedef void (*Filter)(u8*, u32, u8*, u8*, u32, int, int);
typedef void (*FilterIB)(u8*, u32, int, int);
enum EFilter {
FirstFilter,
FilterNone = FirstFilter,
Filter2xSaI,
FilterSuper2xSaI,
FilterSuperEagle,
FilterPixelate,
FilterAdMame2x,
FilterBilinear,
FilterBilinearPlus,
FilterScanlines,
FilterScanlinesTV,
FilterHq2x,
FilterLq2x,
FilterxBRZ2x,
LastFilter = FilterxBRZ2x
FirstFilter,
FilterNone = FirstFilter,
Filter2xSaI,
FilterSuper2xSaI,
FilterSuperEagle,
FilterPixelate,
FilterAdMame2x,
FilterBilinear,
FilterBilinearPlus,
FilterScanlines,
FilterScanlinesTV,
FilterHq2x,
FilterLq2x,
FilterxBRZ2x,
LastFilter = FilterxBRZ2x
};
enum EFilterIB {
FirstFilterIB,
FilterIBNone = FirstFilterIB,
FilterIBSmart,
FilterIBMotionBlur,
LastFilterIB = FilterIBMotionBlur
FirstFilterIB,
FilterIBNone = FirstFilterIB,
FilterIBSmart,
FilterIBMotionBlur,
LastFilterIB = FilterIBMotionBlur
};
enum EFilterDepth { FilterDepth16, FilterDepth32 };
enum EFilterDepth { FilterDepth16,
FilterDepth32 };
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
const char *pcsGetFilterName(const EFilter _eFilter);
const char* pcsGetFilterName(const EFilter _eFilter);
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth);
const char *pcsGetFilterIBName(const EFilterIB _eFilterIB);
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB);
} // namespace VBA

View File

@ -21,133 +21,122 @@
#include <vector>
namespace VBA
{
namespace VBA {
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
CheatListDialog(_pstDialog, refBuilder)
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: CheatListDialog(_pstDialog, refBuilder)
{
vUpdateList();
vUpdateList();
}
void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
{
int previous = cheatsNumber;
int previous = cheatsNumber;
switch (type)
{
// Generic Code
case CheatGeneric:
{
std::vector<Glib::ustring> tokens;
switch (type) {
// Generic Code
case CheatGeneric: {
std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens);
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++)
{
Glib::ustring sToken = it->uppercase();
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
Glib::ustring sToken = it->uppercase();
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
}
break;
}
// Gameshark Advance & CodeBreaker Advance
case CheatGSA:
case CheatCBA:
{
std::vector<Glib::ustring> tokens;
Glib::ustring sToken;
Glib::ustring sCode;
Glib::ustring sPart = "";
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++)
{
sToken = it->uppercase();
const char *cToken = sToken.c_str();
if (sToken.size() == 16)
cheatsAddGSACode(cToken, sDesc.c_str(), false);
else if (sToken.size() == 12)
{
sCode = sToken.substr(0,8);
sCode += " ";
sCode += sToken.substr(9,4);
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
}
else
if (sPart.empty())
sPart = sToken;
else
{
if (sToken.size() == 4)
{
sCode = sPart;
sCode += " ";
sCode += cToken;
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
}
else
{
sCode = sPart + sToken;
cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true);
}
sPart = "";
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
}
} // end of loop
} // end of case
default:; // silence warnings
} // end of switch
break;
}
// Gameshark Advance & CodeBreaker Advance
case CheatGSA:
case CheatCBA: {
std::vector<Glib::ustring> tokens;
vUpdateList(previous);
Glib::ustring sToken;
Glib::ustring sCode;
Glib::ustring sPart = "";
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
sToken = it->uppercase();
const char* cToken = sToken.c_str();
if (sToken.size() == 16)
cheatsAddGSACode(cToken, sDesc.c_str(), false);
else if (sToken.size() == 12) {
sCode = sToken.substr(0, 8);
sCode += " ";
sCode += sToken.substr(9, 4);
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
} else if (sPart.empty())
sPart = sToken;
else {
if (sToken.size() == 4) {
sCode = sPart;
sCode += " ";
sCode += cToken;
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
} else {
sCode = sPart + sToken;
cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true);
}
sPart = "";
}
} // end of loop
} // end of case
default:; // silence warnings
} // end of switch
vUpdateList(previous);
}
bool GameBoyAdvanceCheatListDialog::vCheatListOpen(const char *file)
bool GameBoyAdvanceCheatListDialog::vCheatListOpen(const char* file)
{
return cheatsLoadCheatList(file);
return cheatsLoadCheatList(file);
}
void GameBoyAdvanceCheatListDialog::vCheatListSave(const char *file)
void GameBoyAdvanceCheatListDialog::vCheatListSave(const char* file)
{
cheatsSaveCheatList(file);
cheatsSaveCheatList(file);
}
void GameBoyAdvanceCheatListDialog::vRemoveCheat(int index) {
cheatsDelete(index, false);
void GameBoyAdvanceCheatListDialog::vRemoveCheat(int index)
{
cheatsDelete(index, false);
}
void GameBoyAdvanceCheatListDialog::vRemoveAllCheats() {
cheatsDeleteAll(false);
void GameBoyAdvanceCheatListDialog::vRemoveAllCheats()
{
cheatsDeleteAll(false);
}
void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable) {
if (enable)
cheatsEnable(index);
else
cheatsDisable(index);
void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable)
{
if (enable)
cheatsEnable(index);
else
cheatsDisable(index);
}
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
{
for (int i = previous; i < cheatsNumber; i++)
{
// Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
for (int i = previous; i < cheatsNumber; i++) {
// Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
row[m_oRecordModel.iIndex] = i;
row[m_oRecordModel.bEnabled] = cheatsList[i].enabled;
row[m_oRecordModel.uDesc] = cheatsList[i].desc;
}
row[m_oRecordModel.iIndex] = i;
row[m_oRecordModel.bEnabled] = cheatsList[i].enabled;
row[m_oRecordModel.uDesc] = cheatsList[i].desc;
}
}
} // namespace VBA

View File

@ -25,22 +25,20 @@
#include "../gba/Globals.h"
#include "cheatlist.h"
namespace VBA
{
class GameBoyAdvanceCheatListDialog : public CheatListDialog
{
public:
GameBoyAdvanceCheatListDialog(GtkDialog *_pstDialog,
const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class GameBoyAdvanceCheatListDialog : public CheatListDialog {
public:
GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog,
const Glib::RefPtr<Gtk::Builder>& refBuilder);
protected:
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
bool vCheatListOpen(const char *file);
void vCheatListSave(const char *file);
void vRemoveCheat(int index);
void vRemoveAllCheats();
void vToggleCheat(int index, bool enable);
void vUpdateList(int previous = 0);
protected:
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
bool vCheatListOpen(const char* file);
void vCheatListSave(const char* file);
void vRemoveCheat(int index);
void vRemoveAllCheats();
void vToggleCheat(int index, bool enable);
void vUpdateList(int previous = 0);
};
} // namespace VBA

View File

@ -20,128 +20,118 @@
#include "intl.h"
namespace VBA
{
namespace VBA {
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog),
m_poConfig(0)
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
refBuilder->get_widget("BiosCheckButton", m_poBiosCheckButton);
refBuilder->get_widget("BiosFileChooserButton", m_poBiosFileChooserButton);
refBuilder->get_widget("RTCCheckButton", m_poRTCCheckButton);
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
refBuilder->get_widget("BiosCheckButton", m_poBiosCheckButton);
refBuilder->get_widget("BiosFileChooserButton", m_poBiosFileChooserButton);
refBuilder->get_widget("RTCCheckButton", m_poRTCCheckButton);
m_poSaveTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnSaveTypeChanged));
m_poFlashSizeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnFlashSizeChanged));
m_poBiosCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnUseBiosChanged));
m_poBiosFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged));
m_poRTCCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnEnableRTCChanged));
m_poSaveTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnSaveTypeChanged));
m_poFlashSizeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnFlashSizeChanged));
m_poBiosCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnUseBiosChanged));
m_poBiosFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged));
m_poRTCCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnEnableRTCChanged));
}
void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
m_poConfig = _poConfig;
m_poWindow = _poWindow;
VBA::Window::ESaveType eDefaultSaveType = (VBA::Window::ESaveType)m_poConfig->oGetKey<int>("save_type");
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
VBA::Window::ESaveType eDefaultSaveType = (VBA::Window::ESaveType)m_poConfig->oGetKey<int>("save_type");
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
if (iDefaultFlashSize == 128)
{
m_poFlashSizeComboBox->set_active(1);
}
else
{
m_poFlashSizeComboBox->set_active(0);
}
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
if (iDefaultFlashSize == 128) {
m_poFlashSizeComboBox->set_active(1);
} else {
m_poFlashSizeComboBox->set_active(0);
}
bool bUseBios = m_poConfig->oGetKey<bool>("use_bios_file");
m_poBiosCheckButton->set_active(bUseBios);
m_poBiosFileChooserButton->set_sensitive(bUseBios);
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
m_poBiosFileChooserButton->set_filename(sBios);
const char * acsPattern[] =
{
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
};
bool bUseBios = m_poConfig->oGetKey<bool>("use_bios_file");
m_poBiosCheckButton->set_active(bUseBios);
m_poBiosFileChooserButton->set_sensitive(bUseBios);
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
m_poBiosFileChooserButton->set_filename(sBios);
const char* acsPattern[] = {
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
};
#if !GTK_CHECK_VERSION(3, 0, 0)
Gtk::FileFilter oAllFilter;
oAllFilter.set_name(_("All files"));
oAllFilter.add_pattern("*");
Gtk::FileFilter oAllFilter;
oAllFilter.set_name(_("All files"));
oAllFilter.add_pattern("*");
Gtk::FileFilter oBiosFilter;
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
{
oBiosFilter.add_pattern(acsPattern[i]);
}
Gtk::FileFilter oBiosFilter;
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
oBiosFilter.add_pattern(acsPattern[i]);
}
#else
const Glib::RefPtr<Gtk::FileFilter> oAllFilter = Gtk::FileFilter::create();
oAllFilter->set_name(_("All files"));
oAllFilter->add_pattern("*");
const Glib::RefPtr<Gtk::FileFilter> oAllFilter = Gtk::FileFilter::create();
oAllFilter->set_name(_("All files"));
oAllFilter->add_pattern("*");
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
{
oBiosFilter->add_pattern(acsPattern[i]);
}
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
oBiosFilter->add_pattern(acsPattern[i]);
}
#endif
m_poBiosFileChooserButton->add_filter(oAllFilter);
m_poBiosFileChooserButton->add_filter(oBiosFilter);
m_poBiosFileChooserButton->set_filter(oBiosFilter);
m_poBiosFileChooserButton->add_filter(oAllFilter);
m_poBiosFileChooserButton->add_filter(oBiosFilter);
m_poBiosFileChooserButton->set_filter(oBiosFilter);
bool bEnableRTC = m_poConfig->oGetKey<bool>("enable_rtc");
m_poRTCCheckButton->set_active(bEnableRTC);
bool bEnableRTC = m_poConfig->oGetKey<bool>("enable_rtc");
m_poRTCCheckButton->set_active(bEnableRTC);
}
void GameBoyAdvanceConfigDialog::vOnSaveTypeChanged()
{
int iSaveType = m_poSaveTypeComboBox->get_active_row_number();
m_poConfig->vSetKey("save_type", iSaveType);
m_poWindow->vApplyConfigGBASaveType();
int iSaveType = m_poSaveTypeComboBox->get_active_row_number();
m_poConfig->vSetKey("save_type", iSaveType);
m_poWindow->vApplyConfigGBASaveType();
}
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
{
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
if (iFlashSize == 0)
{
m_poConfig->vSetKey("flash_size", 64);
}
else
{
m_poConfig->vSetKey("flash_size", 128);
}
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
if (iFlashSize == 0) {
m_poConfig->vSetKey("flash_size", 64);
} else {
m_poConfig->vSetKey("flash_size", 128);
}
m_poWindow->vApplyConfigGBAFlashSize();
m_poWindow->vApplyConfigGBAFlashSize();
}
void GameBoyAdvanceConfigDialog::vOnUseBiosChanged()
{
bool bUseBios = m_poBiosCheckButton->get_active();
m_poConfig->vSetKey("use_bios_file", bUseBios);
m_poBiosFileChooserButton->set_sensitive(bUseBios);
bool bUseBios = m_poBiosCheckButton->get_active();
m_poConfig->vSetKey("use_bios_file", bUseBios);
m_poBiosFileChooserButton->set_sensitive(bUseBios);
}
void GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged()
{
std::string sBios = m_poBiosFileChooserButton->get_filename();
m_poConfig->vSetKey("bios_file", sBios);
std::string sBios = m_poBiosFileChooserButton->get_filename();
m_poConfig->vSetKey("bios_file", sBios);
}
void GameBoyAdvanceConfigDialog::vOnEnableRTCChanged()
{
bool bEnableRTC = m_poRTCCheckButton->get_active();
m_poConfig->vSetKey("enable_rtc", bEnableRTC);
bool bEnableRTC = m_poRTCCheckButton->get_active();
m_poConfig->vSetKey("enable_rtc", bEnableRTC);
}
} // namespace VBA

View File

@ -26,31 +26,29 @@
#include "configfile.h"
#include "window.h"
namespace VBA
{
class GameBoyAdvanceConfigDialog : public Gtk::Dialog
{
public:
GameBoyAdvanceConfigDialog(GtkDialog *_pstDialog,
const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class GameBoyAdvanceConfigDialog : public Gtk::Dialog {
public:
GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog,
const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnSaveTypeChanged();
void vOnFlashSizeChanged();
void vOnUseBiosChanged();
void vOnBiosSelectionChanged();
void vOnEnableRTCChanged();
private:
void vOnSaveTypeChanged();
void vOnFlashSizeChanged();
void vOnUseBiosChanged();
void vOnBiosSelectionChanged();
void vOnEnableRTCChanged();
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Config::Section *m_poConfig;
Gtk::ComboBox *m_poSaveTypeComboBox;
Gtk::ComboBox *m_poFlashSizeComboBox;
Gtk::CheckButton *m_poBiosCheckButton;
Gtk::FileChooserButton *m_poBiosFileChooserButton;
Gtk::CheckButton *m_poRTCCheckButton;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poSaveTypeComboBox;
Gtk::ComboBox* m_poFlashSizeComboBox;
Gtk::CheckButton* m_poBiosCheckButton;
Gtk::FileChooserButton* m_poBiosFileChooserButton;
Gtk::CheckButton* m_poRTCCheckButton;
};
} // namespace VBA

View File

@ -21,102 +21,96 @@
#include <vector>
namespace VBA
{
namespace VBA {
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
CheatListDialog(_pstDialog, refBuilder)
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: CheatListDialog(_pstDialog, refBuilder)
{
vUpdateList();
vUpdateList();
}
void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
{
int previous = gbCheatNumber;
int previous = gbCheatNumber;
switch (type)
{
// GameShark
case CheatGS:
{
std::vector<Glib::ustring> tokens;
switch (type) {
// GameShark
case CheatGS: {
std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens);
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++)
{
Glib::ustring sToken = it->uppercase();
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
Glib::ustring sToken = it->uppercase();
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
}
break;
}
// GameGenie
case CheatGG: {
std::vector<Glib::ustring> tokens;
break;
}
// GameGenie
case CheatGG:
{
std::vector<Glib::ustring> tokens;
vTokenize(buffer->get_text(), tokens);
vTokenize(buffer->get_text(), tokens);
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++) {
Glib::ustring sToken = it->uppercase();
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
it != tokens.end();
it++)
{
Glib::ustring sToken = it->uppercase();
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
}
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
break;
}
default:; // silence warnings
}
// end of switch
break;
}
default:; // silence warnings
}
// end of switch
vUpdateList(previous);
vUpdateList(previous);
}
bool GameBoyCheatListDialog::vCheatListOpen(const char *file)
bool GameBoyCheatListDialog::vCheatListOpen(const char* file)
{
return gbCheatsLoadCheatList(file);
return gbCheatsLoadCheatList(file);
}
void GameBoyCheatListDialog::vCheatListSave(const char *file)
void GameBoyCheatListDialog::vCheatListSave(const char* file)
{
gbCheatsSaveCheatList(file);
gbCheatsSaveCheatList(file);
}
void GameBoyCheatListDialog::vRemoveCheat(int index)
{
gbCheatRemove(index);
gbCheatRemove(index);
}
void GameBoyCheatListDialog::vRemoveAllCheats()
{
gbCheatRemoveAll();
gbCheatRemoveAll();
}
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable) {
if (enable)
gbCheatEnable(index);
else
gbCheatDisable(index);
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable)
{
if (enable)
gbCheatEnable(index);
else
gbCheatDisable(index);
}
void GameBoyCheatListDialog::vUpdateList(int previous)
{
for (int i = previous; i < gbCheatNumber; i++)
{
// Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
for (int i = previous; i < gbCheatNumber; i++) {
// Add row for each newly added cheat
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
row[m_oRecordModel.iIndex] = i;
row[m_oRecordModel.bEnabled] = gbCheatList[i].enabled;
row[m_oRecordModel.uDesc] = gbCheatList[i].cheatDesc;
}
row[m_oRecordModel.iIndex] = i;
row[m_oRecordModel.bEnabled] = gbCheatList[i].enabled;
row[m_oRecordModel.uDesc] = gbCheatList[i].cheatDesc;
}
}
} // namespace VBA

View File

@ -22,21 +22,19 @@
#include "../gb/gbCheats.h"
#include "cheatlist.h"
namespace VBA
{
class GameBoyCheatListDialog : public CheatListDialog
{
public:
GameBoyCheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class GameBoyCheatListDialog : public CheatListDialog {
public:
GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
protected:
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
bool vCheatListOpen(const char *file);
void vCheatListSave(const char *file);
void vRemoveCheat(int index);
void vRemoveAllCheats();
void vToggleCheat(int index, bool enable);
void vUpdateList(int previous = 0);
protected:
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
bool vCheatListOpen(const char* file);
void vCheatListSave(const char* file);
void vRemoveCheat(int index);
void vRemoveAllCheats();
void vToggleCheat(int index, bool enable);
void vUpdateList(int previous = 0);
};
} // namespace VBA

View File

@ -18,97 +18,95 @@
#include "gameboyconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA
{
namespace VBA {
static const VBA::Window::EEmulatorType aEmulatorType[] =
{
VBA::Window::EmulatorAuto,
VBA::Window::EmulatorCGB,
VBA::Window::EmulatorSGB,
VBA::Window::EmulatorGB,
VBA::Window::EmulatorGBA,
VBA::Window::EmulatorSGB2
static const VBA::Window::EEmulatorType aEmulatorType[] = {
VBA::Window::EmulatorAuto,
VBA::Window::EmulatorCGB,
VBA::Window::EmulatorSGB,
VBA::Window::EmulatorGB,
VBA::Window::EmulatorGBA,
VBA::Window::EmulatorSGB2
};
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog),
m_poConfig(0)
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton);
refBuilder->get_widget("BootRomCheckButton", m_poBootRomCheckButton);
refBuilder->get_widget("BootRomFileChooserButton", m_poBootRomFileChooserButton);
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton);
refBuilder->get_widget("BootRomCheckButton", m_poBootRomCheckButton);
refBuilder->get_widget("BootRomFileChooserButton", m_poBootRomFileChooserButton);
m_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged));
m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged));
m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged));
m_poBootRomCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnUseBootRomChanged));
m_poBootRomFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBootRomSelectionChanged));
m_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged));
m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged));
m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged));
m_poBootRomCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnUseBootRomChanged));
m_poBootRomFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBootRomSelectionChanged));
}
void GameBoyConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
void GameBoyConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
m_poConfig = _poConfig;
m_poWindow = _poWindow;
VBA::Window::EEmulatorType eDefaultEmulatorType = (VBA::Window::EEmulatorType)m_poConfig->oGetKey<int>("emulator_type");
m_poSystemComboBox->set_active(aEmulatorType[eDefaultEmulatorType]);
VBA::Window::EEmulatorType eDefaultEmulatorType = (VBA::Window::EEmulatorType)m_poConfig->oGetKey<int>("emulator_type");
m_poSystemComboBox->set_active(aEmulatorType[eDefaultEmulatorType]);
bool bBorder = m_poConfig->oGetKey<bool>("gb_border");
m_poBorderCheckButton->set_active(bBorder);
bool bBorder = m_poConfig->oGetKey<bool>("gb_border");
m_poBorderCheckButton->set_active(bBorder);
bool bPrinter = m_poConfig->oGetKey<bool>("gb_printer");
m_poPrinterCheckButton->set_active(bPrinter);
bool bUseBootRom = m_poConfig->oGetKey<bool>("gb_use_bios_file");
m_poBootRomCheckButton->set_active(bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
std::string sBootRom = m_poConfig->oGetKey<std::string>("gb_bios_file");
m_poBootRomFileChooserButton->set_filename(sBootRom);
bool bPrinter = m_poConfig->oGetKey<bool>("gb_printer");
m_poPrinterCheckButton->set_active(bPrinter);
bool bUseBootRom = m_poConfig->oGetKey<bool>("gb_use_bios_file");
m_poBootRomCheckButton->set_active(bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
std::string sBootRom = m_poConfig->oGetKey<std::string>("gb_bios_file");
m_poBootRomFileChooserButton->set_filename(sBootRom);
}
void GameBoyConfigDialog::vOnSystemChanged()
{
int iSystem = m_poSystemComboBox->get_active_row_number();
m_poConfig->vSetKey("emulator_type", aEmulatorType[iSystem]);
m_poWindow->vApplyConfigGBSystem();
int iSystem = m_poSystemComboBox->get_active_row_number();
m_poConfig->vSetKey("emulator_type", aEmulatorType[iSystem]);
m_poWindow->vApplyConfigGBSystem();
}
void GameBoyConfigDialog::vOnBorderChanged()
{
bool bBorder = m_poBorderCheckButton->get_active();
m_poConfig->vSetKey("gb_border", bBorder);
m_poWindow->vApplyConfigGBBorder();
bool bBorder = m_poBorderCheckButton->get_active();
m_poConfig->vSetKey("gb_border", bBorder);
m_poWindow->vApplyConfigGBBorder();
}
void GameBoyConfigDialog::vOnPrinterChanged()
{
bool bPrinter = m_poPrinterCheckButton->get_active();
m_poConfig->vSetKey("gb_printer", bPrinter);
m_poWindow->vApplyConfigGBPrinter();
bool bPrinter = m_poPrinterCheckButton->get_active();
m_poConfig->vSetKey("gb_printer", bPrinter);
m_poWindow->vApplyConfigGBPrinter();
}
void GameBoyConfigDialog::vOnUseBootRomChanged()
{
bool bUseBootRom = m_poBootRomCheckButton->get_active();
m_poConfig->vSetKey("gb_use_bios_file", bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
bool bUseBootRom = m_poBootRomCheckButton->get_active();
m_poConfig->vSetKey("gb_use_bios_file", bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
}
void GameBoyConfigDialog::vOnBootRomSelectionChanged()
{
std::string sBootRom = m_poBootRomFileChooserButton->get_filename();
m_poConfig->vSetKey("gb_bios_file", sBootRom);
std::string sBootRom = m_poBootRomFileChooserButton->get_filename();
m_poConfig->vSetKey("gb_bios_file", sBootRom);
}
} // namespace VBA

View File

@ -26,30 +26,28 @@
#include "configfile.h"
#include "window.h"
namespace VBA
{
class GameBoyConfigDialog : public Gtk::Dialog
{
public:
GameBoyConfigDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class GameBoyConfigDialog : public Gtk::Dialog {
public:
GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnSystemChanged();
void vOnBorderChanged();
void vOnPrinterChanged();
void vOnUseBootRomChanged();
void vOnBootRomSelectionChanged();
private:
void vOnSystemChanged();
void vOnBorderChanged();
void vOnPrinterChanged();
void vOnUseBootRomChanged();
void vOnBootRomSelectionChanged();
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Config::Section *m_poConfig;
Gtk::ComboBox *m_poSystemComboBox;
Gtk::CheckButton *m_poBorderCheckButton;
Gtk::CheckButton *m_poPrinterCheckButton;
Gtk::CheckButton *m_poBootRomCheckButton;
Gtk::FileChooserButton *m_poBootRomFileChooserButton;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poSystemComboBox;
Gtk::CheckButton* m_poBorderCheckButton;
Gtk::CheckButton* m_poPrinterCheckButton;
Gtk::CheckButton* m_poBootRomCheckButton;
Gtk::FileChooserButton* m_poBootRomFileChooserButton;
};
} // namespace VBA

View File

@ -18,87 +18,82 @@
#include "generalconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA
namespace VBA {
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton);
refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton);
refBuilder->get_widget("FrameSkipLevelSpinButton", m_poFrameSkipLevelSpinButton);
refBuilder->get_widget("SpeedIndicatorComboBox", m_poSpeedIndicatorComboBox);
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog),
m_poConfig(0)
{
refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton);
refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton);
refBuilder->get_widget("FrameSkipLevelSpinButton", m_poFrameSkipLevelSpinButton);
refBuilder->get_widget("SpeedIndicatorComboBox", m_poSpeedIndicatorComboBox);
m_poPauseWhenInactiveCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnPauseWhenInactiveChanged));
m_poFrameSkipAutomaticCheckButton->signal_toggled().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_poPauseWhenInactiveCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnPauseWhenInactiveChanged));
m_poFrameSkipAutomaticCheckButton->signal_toggled().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));
}
void PreferencesDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
void PreferencesDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
m_poConfig = _poConfig;
m_poWindow = _poWindow;
bool bPauseWhenInactive = m_poConfig->oGetKey<bool>("pause_when_inactive");
m_poPauseWhenInactiveCheckButton->set_active(bPauseWhenInactive);
bool bPauseWhenInactive = m_poConfig->oGetKey<bool>("pause_when_inactive");
m_poPauseWhenInactiveCheckButton->set_active(bPauseWhenInactive);
std::string sFrameskip = m_poConfig->oGetKey<std::string>("frameskip");
int iFrameskip = 0;
bool bAutoFrameskip = false;
if (sFrameskip == "auto")
bAutoFrameskip = true;
else
iFrameskip = m_poConfig->oGetKey<int>("frameskip");
std::string sFrameskip = m_poConfig->oGetKey<std::string>("frameskip");
int iFrameskip = 0;
bool bAutoFrameskip = false;
m_poFrameSkipAutomaticCheckButton->set_active(bAutoFrameskip);
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
m_poFrameSkipLevelSpinButton->set_value(iFrameskip);
if (sFrameskip == "auto")
bAutoFrameskip = true;
else
iFrameskip = m_poConfig->oGetKey<int>("frameskip");
int iShowSpeed = m_poConfig->oGetKey<int>("show_speed");
m_poSpeedIndicatorComboBox->set_active(iShowSpeed);
m_poFrameSkipAutomaticCheckButton->set_active(bAutoFrameskip);
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
m_poFrameSkipLevelSpinButton->set_value(iFrameskip);
int iShowSpeed = m_poConfig->oGetKey<int>("show_speed");
m_poSpeedIndicatorComboBox->set_active(iShowSpeed);
}
void PreferencesDialog::vOnPauseWhenInactiveChanged()
{
bool bPauseWhenInactive = m_poPauseWhenInactiveCheckButton->get_active();
m_poConfig->vSetKey("pause_when_inactive", bPauseWhenInactive);
bool bPauseWhenInactive = m_poPauseWhenInactiveCheckButton->get_active();
m_poConfig->vSetKey("pause_when_inactive", bPauseWhenInactive);
}
void PreferencesDialog::vOnFrameskipChanged()
{
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
if (bAutoFrameskip)
{
m_poConfig->vSetKey("frameskip", "auto");
}
else
{
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
m_poConfig->vSetKey("frameskip", iFrameskip);
}
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
m_poWindow->vApplyConfigFrameskip();
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
if (bAutoFrameskip) {
m_poConfig->vSetKey("frameskip", "auto");
} else {
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
m_poConfig->vSetKey("frameskip", iFrameskip);
}
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
m_poWindow->vApplyConfigFrameskip();
}
void PreferencesDialog::vOnSpeedIndicatorChanged()
{
int iShowSpeed = m_poSpeedIndicatorComboBox->get_active_row_number();
m_poConfig->vSetKey<int>("show_speed", iShowSpeed);
m_poWindow->vApplyConfigShowSpeed();
int iShowSpeed = m_poSpeedIndicatorComboBox->get_active_row_number();
m_poConfig->vSetKey<int>("show_speed", iShowSpeed);
m_poWindow->vApplyConfigShowSpeed();
}
} // namespace VBA

View File

@ -26,27 +26,25 @@
#include "configfile.h"
#include "window.h"
namespace VBA
{
class PreferencesDialog : public Gtk::Dialog
{
public:
PreferencesDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class PreferencesDialog : public Gtk::Dialog {
public:
PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnPauseWhenInactiveChanged();
void vOnFrameskipChanged();
void vOnSpeedIndicatorChanged();
private:
void vOnPauseWhenInactiveChanged();
void vOnFrameskipChanged();
void vOnSpeedIndicatorChanged();
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Config::Section *m_poConfig;
Gtk::CheckButton *m_poPauseWhenInactiveCheckButton;
Gtk::CheckButton *m_poFrameSkipAutomaticCheckButton;
Gtk::SpinButton *m_poFrameSkipLevelSpinButton;
Gtk::ComboBox *m_poSpeedIndicatorComboBox;
Config::Section* m_poConfig;
Gtk::CheckButton* m_poPauseWhenInactiveCheckButton;
Gtk::CheckButton* m_poFrameSkipAutomaticCheckButton;
Gtk::SpinButton* m_poFrameSkipLevelSpinButton;
Gtk::ComboBox* m_poSpeedIndicatorComboBox;
};
} // namespace VBA

View File

@ -23,309 +23,286 @@
#include "intl.h"
namespace VBA
{
namespace VBA {
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
{
{ KEY_UP, N_("Up :") },
{ KEY_DOWN, N_("Down :") },
{ KEY_LEFT, N_("Left :") },
{ KEY_RIGHT, N_("Right :") },
{ KEY_BUTTON_A, N_("Button A :") },
{ KEY_BUTTON_B, N_("Button B :") },
{ KEY_BUTTON_L, N_("Button L :") },
{ KEY_BUTTON_R, N_("Button R :") },
{ KEY_BUTTON_SELECT, N_("Select :") },
{ KEY_BUTTON_START, N_("Start :") },
{ KEY_BUTTON_SPEED, N_("Speed :") },
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = {
{ KEY_UP, N_("Up :") },
{ KEY_DOWN, N_("Down :") },
{ KEY_LEFT, N_("Left :") },
{ KEY_RIGHT, N_("Right :") },
{ KEY_BUTTON_A, N_("Button A :") },
{ KEY_BUTTON_B, N_("Button B :") },
{ KEY_BUTTON_L, N_("Button L :") },
{ KEY_BUTTON_R, N_("Button R :") },
{ KEY_BUTTON_SELECT, N_("Select :") },
{ KEY_BUTTON_START, N_("Start :") },
{ KEY_BUTTON_SPEED, N_("Speed :") },
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
};
JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :
Gtk::Dialog(_("Joypad config"), true),
m_oTitleHBox(false, 5),
m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END),
m_oDefaultJoypad(_("Default joypad")),
m_oTable(G_N_ELEMENTS(m_astKeys), 2, false),
m_iCurrentEntry(-1),
m_bUpdating(false),
m_ePad(PAD_MAIN),
m_poConfig(_poConfig)
JoypadConfigDialog::JoypadConfigDialog(Config::Section* _poConfig)
: Gtk::Dialog(_("Joypad config"), true)
, m_oTitleHBox(false, 5)
, m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END)
, m_oDefaultJoypad(_("Default joypad"))
, m_oTable(G_N_ELEMENTS(m_astKeys), 2, false)
, m_iCurrentEntry(-1)
, m_bUpdating(false)
, m_ePad(PAD_MAIN)
, m_poConfig(_poConfig)
{
// Joypad selection
// Joypad selection
#if !GTK_CHECK_VERSION(3, 0, 0)
m_oTitleCombo.append_text("1");
m_oTitleCombo.append_text("2");
m_oTitleCombo.append_text("3");
m_oTitleCombo.append_text("4");
m_oTitleCombo.append_text("1");
m_oTitleCombo.append_text("2");
m_oTitleCombo.append_text("3");
m_oTitleCombo.append_text("4");
#else
m_oTitleCombo.append("1");
m_oTitleCombo.append("2");
m_oTitleCombo.append("3");
m_oTitleCombo.append("4");
m_oTitleCombo.append("1");
m_oTitleCombo.append("2");
m_oTitleCombo.append("3");
m_oTitleCombo.append("4");
#endif
m_oTitleHBox.pack_start(m_oTitleLabel, Gtk::PACK_SHRINK);
m_oTitleHBox.pack_start(m_oTitleCombo);
m_oTitleHBox.pack_start(m_oTitleLabel, Gtk::PACK_SHRINK);
m_oTitleHBox.pack_start(m_oTitleCombo);
// Joypad buttons
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::Entry * poEntry = Gtk::manage( new Gtk::Entry() );
m_oTable.attach(* poLabel, 0, 1, i, i + 1);
m_oTable.attach(* poEntry, 1, 2, i, i + 1);
m_oEntries.push_back(poEntry);
// Joypad buttons
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::Entry* poEntry = Gtk::manage(new Gtk::Entry());
m_oTable.attach(*poLabel, 0, 1, i, i + 1);
m_oTable.attach(*poEntry, 1, 2, i, i + 1);
m_oEntries.push_back(poEntry);
poEntry->signal_focus_in_event().connect(sigc::bind(
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn), i));
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
}
poEntry->signal_focus_in_event().connect(sigc::bind(
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn), i));
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
}
// Dialog validation button
m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
// Dialog validation button
m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
// Layout
m_oTitleHBox.set_border_width(5);
m_oTable.set_border_width(5);
m_oTable.set_spacings(5);
get_vbox()->set_spacing(5);
get_vbox()->pack_start(m_oTitleHBox);
get_vbox()->pack_start(m_oSeparator);
get_vbox()->pack_start(m_oDefaultJoypad);
get_vbox()->pack_start(m_oTable);
// Layout
m_oTitleHBox.set_border_width(5);
m_oTable.set_border_width(5);
m_oTable.set_spacings(5);
get_vbox()->set_spacing(5);
get_vbox()->pack_start(m_oTitleHBox);
get_vbox()->pack_start(m_oSeparator);
get_vbox()->pack_start(m_oDefaultJoypad);
get_vbox()->pack_start(m_oTable);
// Signals and default values
m_oConfigSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
50);
m_oDefaultJoypad.signal_toggled().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnDefaultJoypadSelect) );
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnJoypadSelect) );
// Signals and default values
m_oConfigSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
50);
m_oDefaultJoypad.signal_toggled().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnDefaultJoypadSelect));
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnJoypadSelect));
m_oTitleCombo.set_active_text("1");
m_oTitleCombo.set_active_text("1");
show_all_children();
show_all_children();
}
JoypadConfigDialog::~JoypadConfigDialog()
{
m_oConfigSig.disconnect();
m_oConfigSig.disconnect();
}
void JoypadConfigDialog::vUpdateEntries()
{
m_bUpdating = true;
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
m_bUpdating = true;
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
for (guint i = 0; i < m_oEntries.size(); i++)
{
std::string csName;
for (guint i = 0; i < m_oEntries.size(); i++) {
std::string csName;
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
int dev = uiKeyval >> 16;
if (dev == 0)
{
csName = gdk_keyval_name(uiKeyval);
}
else
{
int what = uiKeyval & 0xffff;
std::stringstream os;
os << _("Joy ") << dev;
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
int dev = uiKeyval >> 16;
if (dev == 0) {
csName = gdk_keyval_name(uiKeyval);
} else {
int what = uiKeyval & 0xffff;
std::stringstream os;
os << _("Joy ") << dev;
if(what >= 128)
{
// joystick button
int button = what - 128;
os << _(" Button ") << button;
}
else if (what < 0x20)
{
// joystick axis
int dir = what & 1;
what >>= 1;
os << _(" Axis ") << what << (dir?'-':'+');
}
else if (what < 0x30)
{
// joystick hat
int dir = (what & 3);
what = (what & 15);
what >>= 2;
os << _(" Hat ") << what << " ";
switch (dir)
{
case 0: os << _("Up"); break;
case 1: os << _("Down"); break;
case 2: os << _("Right"); break;
case 3: os << _("Left"); break;
}
}
if (what >= 128) {
// joystick button
int button = what - 128;
os << _(" Button ") << button;
} else if (what < 0x20) {
// joystick axis
int dir = what & 1;
what >>= 1;
os << _(" Axis ") << what << (dir ? '-' : '+');
} else if (what < 0x30) {
// joystick hat
int dir = (what & 3);
what = (what & 15);
what >>= 2;
os << _(" Hat ") << what << " ";
switch (dir) {
case 0:
os << _("Up");
break;
case 1:
os << _("Down");
break;
case 2:
os << _("Right");
break;
case 3:
os << _("Left");
break;
}
}
csName = os.str();
csName = os.str();
}
if (csName.empty()) {
m_oEntries[i]->set_text(_("<Undefined>"));
} else {
m_oEntries[i]->set_text(csName);
}
}
if (csName.empty())
{
m_oEntries[i]->set_text(_("<Undefined>"));
}
else
{
m_oEntries[i]->set_text(csName);
}
}
m_bUpdating = false;
m_bUpdating = false;
}
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus * _pstEvent,
guint _uiEntry)
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus* _pstEvent,
guint _uiEntry)
{
m_iCurrentEntry = _uiEntry;
m_iCurrentEntry = _uiEntry;
return false;
return false;
}
bool JoypadConfigDialog::bOnEntryFocusOut(GdkEventFocus * _pstEvent)
bool JoypadConfigDialog::bOnEntryFocusOut(GdkEventFocus* _pstEvent)
{
m_iCurrentEntry = -1;
m_iCurrentEntry = -1;
return false;
return false;
}
bool JoypadConfigDialog::on_key_press_event(GdkEventKey * _pstEvent)
bool JoypadConfigDialog::on_key_press_event(GdkEventKey* _pstEvent)
{
if (m_iCurrentEntry < 0)
{
return Gtk::Window::on_key_press_event(_pstEvent);
}
if (m_iCurrentEntry < 0) {
return Gtk::Window::on_key_press_event(_pstEvent);
}
// Forward the keyboard event by faking a SDL event
SDL_Event event;
event.type = SDL_KEYDOWN;
//event.key.timestamp = SDL_GetTicks();
//event.key.windowID = 0;
//event.key.repeat = 0;
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
vOnInputEvent(event);
// Forward the keyboard event by faking a SDL event
SDL_Event event;
event.type = SDL_KEYDOWN;
//event.key.timestamp = SDL_GetTicks();
//event.key.windowID = 0;
//event.key.repeat = 0;
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
vOnInputEvent(event);
return true;
return true;
}
void JoypadConfigDialog::on_response(int response_id)
{
m_poConfig->vSetKey("active_joypad", inputGetDefaultJoypad());
m_poConfig->vSetKey("active_joypad", inputGetDefaultJoypad());
}
void JoypadConfigDialog::vOnInputEvent(const SDL_Event &event)
void JoypadConfigDialog::vOnInputEvent(const SDL_Event& event)
{
if (m_iCurrentEntry < 0)
{
return;
}
if (m_iCurrentEntry < 0) {
return;
}
int code = inputGetEventCode(event);
if (!code) return;
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
vUpdateEntries();
int code = inputGetEventCode(event);
if (!code)
return;
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
vUpdateEntries();
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size())
{
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
}
else
{
m_poOkButton->grab_focus();
}
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) {
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
} else {
m_poOkButton->grab_focus();
}
}
bool JoypadConfigDialog::bOnConfigIdle()
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_JOYAXISMOTION:
if (abs(event.jaxis.value) < 16384) continue;
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|| 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))
{
vOnInputEvent(event);
m_oPreviousEvent = event;
}
vEmptyEventQueue();
break;
case SDL_JOYBUTTONUP:
vOnInputEvent(event);
vEmptyEventQueue();
break;
case SDL_JOYHATMOTION:
if (event.jhat.value)
{
vOnInputEvent(event);
vEmptyEventQueue();
}
break;
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_JOYAXISMOTION:
if (abs(event.jaxis.value) < 16384)
continue;
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|| 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)) {
vOnInputEvent(event);
m_oPreviousEvent = event;
}
vEmptyEventQueue();
break;
case SDL_JOYBUTTONUP:
vOnInputEvent(event);
vEmptyEventQueue();
break;
case SDL_JOYHATMOTION:
if (event.jhat.value) {
vOnInputEvent(event);
vEmptyEventQueue();
}
break;
}
}
}
return true;
return true;
}
void JoypadConfigDialog::vEmptyEventQueue()
{
// Empty the SDL event queue
SDL_Event event;
while(SDL_PollEvent(&event));
// Empty the SDL event queue
SDL_Event event;
while (SDL_PollEvent(&event))
;
}
void JoypadConfigDialog::vOnJoypadSelect()
{
std::string oText = m_oTitleCombo.get_active_text();
std::string oText = m_oTitleCombo.get_active_text();
if (oText == "1")
{
m_ePad = PAD_1;
}
else if (oText == "2")
{
m_ePad = PAD_2;
}
else if (oText == "3")
{
m_ePad = PAD_3;
}
else if (oText == "4")
{
m_ePad = PAD_4;
}
if (oText == "1") {
m_ePad = PAD_1;
} else if (oText == "2") {
m_ePad = PAD_2;
} else if (oText == "3") {
m_ePad = PAD_3;
} else if (oText == "4") {
m_ePad = PAD_4;
}
vEmptyEventQueue();
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
vEmptyEventQueue();
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
vUpdateEntries();
vUpdateEntries();
}
void JoypadConfigDialog::vOnDefaultJoypadSelect()
{
if (m_bUpdating) return;
if (m_bUpdating)
return;
if (m_oDefaultJoypad.get_active())
{
inputSetDefaultJoypad(m_ePad);
}
else
{
inputSetDefaultJoypad(PAD_MAIN);
}
if (m_oDefaultJoypad.get_active()) {
inputSetDefaultJoypad(m_ePad);
} else {
inputSetDefaultJoypad(PAD_MAIN);
}
}
} // namespace VBA

View File

@ -33,49 +33,47 @@
#include "../sdl/inputSDL.h"
#include "configfile.h"
namespace VBA
{
class JoypadConfigDialog : public Gtk::Dialog
{
public:
JoypadConfigDialog(Config::Section *_poConfig);
virtual ~JoypadConfigDialog();
namespace VBA {
class JoypadConfigDialog : public Gtk::Dialog {
public:
JoypadConfigDialog(Config::Section* _poConfig);
virtual ~JoypadConfigDialog();
protected:
bool bOnEntryFocusIn(GdkEventFocus *_pstEvent, guint _uiEntry);
bool bOnEntryFocusOut(GdkEventFocus *_pstEvent);
protected:
bool bOnEntryFocusIn(GdkEventFocus* _pstEvent, guint _uiEntry);
bool bOnEntryFocusOut(GdkEventFocus* _pstEvent);
void vOnInputEvent(const SDL_Event &event);
bool on_key_press_event(GdkEventKey *_pstEvent);
void on_response(int response_id);
void vOnInputEvent(const SDL_Event& event);
bool on_key_press_event(GdkEventKey* _pstEvent);
void on_response(int response_id);
private:
struct SJoypadKey {
const EKey m_eKeyFlag;
const char *m_csKeyName;
};
private:
struct SJoypadKey {
const EKey m_eKeyFlag;
const char* m_csKeyName;
};
Gtk::HBox m_oTitleHBox;
Gtk::Label m_oTitleLabel;
Gtk::ComboBoxText m_oTitleCombo;
Gtk::HSeparator m_oSeparator;
Gtk::CheckButton m_oDefaultJoypad;
Gtk::Table m_oTable;
Gtk::Button *m_poOkButton;
std::vector<Gtk::Entry *> m_oEntries;
gint m_iCurrentEntry;
bool m_bUpdating;
static const SJoypadKey m_astKeys[];
sigc::connection m_oConfigSig;
SDL_Event m_oPreviousEvent;
EPad m_ePad;
Config::Section *m_poConfig;
Gtk::HBox m_oTitleHBox;
Gtk::Label m_oTitleLabel;
Gtk::ComboBoxText m_oTitleCombo;
Gtk::HSeparator m_oSeparator;
Gtk::CheckButton m_oDefaultJoypad;
Gtk::Table m_oTable;
Gtk::Button* m_poOkButton;
std::vector<Gtk::Entry*> m_oEntries;
gint m_iCurrentEntry;
bool m_bUpdating;
static const SJoypadKey m_astKeys[];
sigc::connection m_oConfigSig;
SDL_Event m_oPreviousEvent;
EPad m_ePad;
Config::Section* m_poConfig;
bool bOnConfigIdle();
void vOnJoypadSelect();
void vOnDefaultJoypadSelect();
void vUpdateEntries();
void vEmptyEventQueue();
bool bOnConfigIdle();
void vOnJoypadSelect();
void vOnDefaultJoypadSelect();
void vUpdateEntries();
void vEmptyEventQueue();
};
} // namespace VBA

View File

@ -16,10 +16,10 @@
// along with this program; if not, write to the Free Software Foundation,
// 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 <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/window.h>
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
#include <gtkmm/gl/init.h>
@ -28,106 +28,97 @@
// this will be ifdefed soon
#include <X11/Xlib.h>
#include "window.h"
#include "intl.h"
#include "window.h"
int systemDebug = 0;
int main(int argc, char * argv[])
int main(int argc, char* argv[])
{
bool bShowVersion = false;
Glib::OptionGroup::vecustrings listRemaining;
bool bShowVersion = false;
Glib::OptionGroup::vecustrings listRemaining;
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain("gvbam", LOCALEDIR);
textdomain("gvbam");
setlocale(LC_ALL, "");
bindtextdomain("gvbam", LOCALEDIR);
textdomain("gvbam");
#endif // ENABLE_NLS
//will be ifdefed
XInitThreads();
//will be ifdefed
XInitThreads();
Glib::set_application_name(_("VBA-M"));
Glib::set_application_name(_("VBA-M"));
Gtk::Main oKit(argc, argv);
Gtk::Main oKit(argc, argv);
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
Gtk::GL::init(argc, argv);
Gtk::GL::init(argc, argv);
#endif // USE_OPENGL
Glib::OptionContext oContext;
Glib::OptionGroup oGroup("main_group", _("Main VBA-M options"));
Glib::OptionContext oContext;
Glib::OptionGroup oGroup("main_group", _("Main VBA-M options"));
Glib::OptionEntry oVersion;
oVersion.set_long_name("version");
oVersion.set_short_name('v');
oVersion.set_description(_("Output version information."));
oGroup.add_entry(oVersion, bShowVersion);
Glib::OptionEntry oVersion;
oVersion.set_long_name("version");
oVersion.set_short_name('v');
oVersion.set_description(_("Output version information."));
oGroup.add_entry(oVersion, bShowVersion);
Glib::OptionEntry oFileName;
oFileName.set_long_name(G_OPTION_REMAINING);
oFileName.set_description(G_OPTION_REMAINING);
oGroup.add_entry(oFileName, listRemaining);
Glib::OptionEntry oFileName;
oFileName.set_long_name(G_OPTION_REMAINING);
oFileName.set_description(G_OPTION_REMAINING);
oGroup.add_entry(oFileName, listRemaining);
oContext.set_main_group(oGroup);
oContext.set_main_group(oGroup);
try
{
oContext.parse(argc, argv);
}
catch (const Glib::Error& e)
{
Gtk::MessageDialog oDialog(e.what(),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
oDialog.run();
return 1;
}
if (bShowVersion)
{
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
exit(0);
}
Gtk::Window::set_default_icon_name("vbam");
std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");
Glib::RefPtr<Gtk::Builder> poXml;
try
{
poXml = Gtk::Builder::create();
poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
poXml->add_from_file(sGtkBuilderFile, "MainWindow");
}
catch (const Gtk::BuilderError & e)
{
Gtk::MessageDialog oDialog(e.what(),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
oDialog.run();
return 1;
}
VBA::Window * poWindow = NULL;
poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
if (listRemaining.size() == 1)
{
// Display the window before loading the file
poWindow->show();
while (Gtk::Main::events_pending())
{
Gtk::Main::iteration();
try {
oContext.parse(argc, argv);
} catch (const Glib::Error& e) {
Gtk::MessageDialog oDialog(e.what(),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
oDialog.run();
return 1;
}
poWindow->bLoadROM(listRemaining[0]);
}
if (bShowVersion) {
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
exit(0);
}
Gtk::Main::run(*poWindow);
delete poWindow;
Gtk::Window::set_default_icon_name("vbam");
return 0;
std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");
Glib::RefPtr<Gtk::Builder> poXml;
try {
poXml = Gtk::Builder::create();
poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
poXml->add_from_file(sGtkBuilderFile, "MainWindow");
} catch (const Gtk::BuilderError& e) {
Gtk::MessageDialog oDialog(e.what(),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
oDialog.run();
return 1;
}
VBA::Window* poWindow = NULL;
poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
if (listRemaining.size() == 1) {
// Display the window before loading the file
poWindow->show();
while (Gtk::Main::events_pending()) {
Gtk::Main::iteration();
}
poWindow->bLoadROM(listRemaining[0]);
}
Gtk::Main::run(*poWindow);
delete poWindow;
return 0;
}

View File

@ -20,100 +20,100 @@
#include <cstring>
namespace VBA
{
namespace VBA {
template<typename T> 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; }
template <typename T>
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) :
ScreenArea(_iWidth, _iHeight, _iScale)
ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale)
: ScreenArea(_iWidth, _iHeight, _iScale)
{
vUpdateSize();
vUpdateSize();
}
void ScreenAreaCairo::vDrawPixels(u8 * _puiData)
void ScreenAreaCairo::vDrawPixels(u8* _puiData)
{
ScreenArea::vDrawPixels(_puiData);
ScreenArea::vDrawPixels(_puiData);
queue_draw();
queue_draw();
}
#if !GTK_CHECK_VERSION(3, 0, 0)
bool ScreenAreaCairo::on_expose_event(GdkEventExpose * _pstEvent)
bool ScreenAreaCairo::on_expose_event(GdkEventExpose* _pstEvent)
{
DrawingArea::on_expose_event(_pstEvent);
Cairo::RefPtr< Cairo::ImageSurface > poImage;
Cairo::RefPtr< Cairo::SurfacePattern > poPattern;
Cairo::RefPtr< Cairo::Context > poContext;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
DrawingArea::on_expose_event(_pstEvent);
Cairo::RefPtr<Cairo::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::RefPtr<Cairo::Context> poContext;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
poContext = get_window()->create_cairo_context();
poContext = get_window()->create_cairo_context();
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((u8 *)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
return true;
return true;
}
#else
bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context> &poContext)
bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext)
{
DrawingArea::on_draw(poContext);
Cairo::RefPtr< Cairo::ImageSurface > poImage;
Cairo::RefPtr< Cairo::SurfacePattern > poPattern;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
DrawingArea::on_draw(poContext);
Cairo::RefPtr<Cairo::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((u8 *)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
return true;
return true;
}
#endif
void ScreenAreaCairo::vDrawBlackScreen()
{
if (m_puiPixels && get_realized())
{
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
queue_draw_area(0, 0, get_width(), get_height());
}
if (m_puiPixels && get_realized()) {
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
queue_draw_area(0, 0, get_width(), get_height());
}
}
void ScreenAreaCairo::vOnWidgetResize()
{
m_dScaleFactor = min<double>(get_height() / (double)m_iHeight, get_width() / (double)m_iWidth);
m_dScaleFactor /= m_iFilterScale;
m_dScaleFactor = min<double>(get_height() / (double)m_iHeight, get_width() / (double)m_iWidth);
m_dScaleFactor /= m_iFilterScale;
m_iAreaTop = (get_height() / m_dScaleFactor - m_iHeight * m_iFilterScale) / 2;
m_iAreaLeft = (get_width() / m_dScaleFactor - m_iWidth * m_iFilterScale) / 2;
m_iAreaTop = (get_height() / m_dScaleFactor - m_iHeight * m_iFilterScale) / 2;
m_iAreaLeft = (get_width() / m_dScaleFactor - m_iWidth * m_iFilterScale) / 2;
}
} // namespace VBA

View File

@ -22,27 +22,25 @@
#include "screenarea.h"
namespace VBA
{
class ScreenAreaCairo : public ScreenArea
{
public:
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8 *_puiData);
void vDrawBlackScreen();
namespace VBA {
class ScreenAreaCairo : public ScreenArea {
public:
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData);
void vDrawBlackScreen();
protected:
protected:
#if !GTK_CHECK_VERSION(3, 0, 0)
bool on_expose_event(GdkEventExpose *_pstEvent);
bool on_expose_event(GdkEventExpose* _pstEvent);
#else
bool on_draw(const Cairo::RefPtr<Cairo::Context> &poContext);
bool on_draw(const Cairo::RefPtr<Cairo::Context>& poContext);
#endif
void vOnWidgetResize();
void vOnWidgetResize();
private:
double m_dScaleFactor;
int m_iAreaTop;
int m_iAreaLeft;
private:
double m_dScaleFactor;
int m_iAreaTop;
int m_iAreaLeft;
};
} // namespace VBA

View File

@ -21,62 +21,63 @@
#include <cstring>
namespace VBA
namespace VBA {
template <typename T>
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)
: ScreenArea(_iWidth, _iHeight, _iScale)
, m_uiScreenTexture(0)
, m_iTextureSize(0)
{
Glib::RefPtr<Gdk::GL::Config> glconfig;
template<typename T> 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) :
ScreenArea(_iWidth, _iHeight, _iScale),
m_uiScreenTexture(0),
m_iTextureSize(0)
{
Glib::RefPtr<Gdk::GL::Config> glconfig;
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB |
Gdk::GL::MODE_DOUBLE);
if (!glconfig)
{
fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
throw std::exception();
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DOUBLE);
if (!glconfig) {
fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
throw std::exception();
}
set_gl_capability(glconfig);
set_gl_capability(glconfig);
vUpdateSize();
vUpdateSize();
}
void ScreenAreaGl::vUpdateTexture()
{
// Calculate the new texture size as a the smallest working power of two
// TODO: Support the ARB_texture_rectangle extension
int iExpX = 0, iExpY = 0;
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX);
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY);
int iNewTextureSize = 1 << max(iExpX, iExpY);
// Calculate the new texture size as a the smallest working power of two
// TODO: Support the ARB_texture_rectangle extension
int iExpX = 0, iExpY = 0;
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX)
;
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY)
;
int iNewTextureSize = 1 << max(iExpX, iExpY);
// Notify the system if the texture size changed
if (iNewTextureSize != m_iTextureSize) {
m_iTextureSize = iNewTextureSize;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iNewTextureSize, iNewTextureSize,
0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
}
// Notify the system if the texture size changed
if (iNewTextureSize != m_iTextureSize) {
m_iTextureSize = iNewTextureSize;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iNewTextureSize, iNewTextureSize,
0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
}
}
void ScreenAreaGl::on_realize()
{
Gtk::DrawingArea::on_realize();
Gtk::DrawingArea::on_realize();
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
glDisable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
if (glIsTexture(m_uiScreenTexture))
glDeleteTextures(1, &m_uiScreenTexture);
glDeleteTextures(1, &m_uiScreenTexture);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@ -97,96 +98,95 @@ void ScreenAreaGl::on_realize()
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glwindow->gl_end();
glwindow->gl_end();
}
void ScreenAreaGl::vDrawPixels(u8 * _puiData)
void ScreenAreaGl::vDrawPixels(u8* _puiData)
{
ScreenArea::vDrawPixels(_puiData);
ScreenArea::vDrawPixels(_puiData);
queue_draw_area(0, 0, get_width(), get_height());
queue_draw_area(0, 0, get_width(), get_height());
}
void ScreenAreaGl::vDrawBlackScreen()
{
if (m_puiPixels && get_realized())
{
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
queue_draw_area(0, 0, get_width(), get_height());
}
if (m_puiPixels && get_realized()) {
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
queue_draw_area(0, 0, get_width(), get_height());
}
}
void ScreenAreaGl::vOnWidgetResize()
{
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
int iWidth = get_width();
int iHeight = get_height();
float fScreenAspect = (float) m_iScaledWidth / m_iScaledHeight,
fWindowAspect = (float) iWidth / iHeight;
int iWidth = get_width();
int iHeight = get_height();
if (!glwindow->gl_begin(get_gl_context()))
return;
float fScreenAspect = (float)m_iScaledWidth / m_iScaledHeight,
fWindowAspect = (float)iWidth / iHeight;
if (!glwindow->gl_begin(get_gl_context()))
return;
if (fWindowAspect == fScreenAspect)
glViewport(0, 0, iWidth, iHeight);
glViewport(0, 0, iWidth, iHeight);
else if (fWindowAspect < fScreenAspect) {
int iAspectHeight = (int)(iWidth / fScreenAspect);
glViewport(0, (iHeight - iAspectHeight) / 2, iWidth, iAspectHeight);
int iAspectHeight = (int)(iWidth / fScreenAspect);
glViewport(0, (iHeight - iAspectHeight) / 2, iWidth, iAspectHeight);
} else {
int iAspectWidth = (int)(iHeight * fScreenAspect);
glViewport((iWidth - iAspectWidth) / 2, 0, iAspectWidth, iHeight);
int iAspectWidth = (int)(iHeight * fScreenAspect);
glViewport((iWidth - iAspectWidth) / 2, 0, iAspectWidth, iHeight);
}
glwindow->gl_end();
glwindow->gl_end();
}
bool ScreenAreaGl::on_expose_event(GdkEventExpose * _pstEvent)
bool ScreenAreaGl::on_expose_event(GdkEventExpose* _pstEvent)
{
if (!m_bEnableRender)
return true;
if (!m_bEnableRender)
return true;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return false;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return false;
glClear( GL_COLOR_BUFFER_BIT );
glClear(GL_COLOR_BUFFER_BIT);
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_iScaledWidth + 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_iScaledWidth + 1, m_iScaledHeight,
GL_RGBA, GL_UNSIGNED_BYTE, m_puiPixels);
GL_RGBA, GL_UNSIGNED_BYTE, m_puiPixels);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0f, 0.0f);
glVertex3i(0, 0, 0);
glTexCoord2f(m_iScaledWidth / (GLfloat) m_iTextureSize, 0.0f);
glVertex3i(1, 0, 0);
glTexCoord2f(0.0f, m_iScaledHeight / (GLfloat) m_iTextureSize);
glVertex3i(0, 1, 0);
glTexCoord2f(m_iScaledWidth / (GLfloat) m_iTextureSize,
m_iScaledHeight / (GLfloat) m_iTextureSize);
glVertex3i(1, 1, 0);
glTexCoord2f(0.0f, 0.0f);
glVertex3i(0, 0, 0);
glTexCoord2f(m_iScaledWidth / (GLfloat)m_iTextureSize, 0.0f);
glVertex3i(1, 0, 0);
glTexCoord2f(0.0f, m_iScaledHeight / (GLfloat)m_iTextureSize);
glVertex3i(0, 1, 0);
glTexCoord2f(m_iScaledWidth / (GLfloat)m_iTextureSize,
m_iScaledHeight / (GLfloat)m_iTextureSize);
glVertex3i(1, 1, 0);
glEnd();
glwindow->swap_buffers();
glwindow->gl_end();
glwindow->gl_end();
return true;
return true;
}
void ScreenAreaGl::vOnSizeUpdated()
{
if (!get_realized())
return;
if (!get_realized())
return;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
vUpdateTexture();
vUpdateTexture();
glwindow->gl_end();
glwindow->gl_end();
}
} // namespace VBA

View File

@ -23,26 +23,24 @@
#include "screenarea.h"
#include <gtkmm/gl/widget.h>
namespace VBA
{
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl>
{
public:
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8 *_puiData);
void vDrawBlackScreen();
namespace VBA {
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
public:
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData);
void vDrawBlackScreen();
protected:
void on_realize();
bool on_expose_event(GdkEventExpose *_pstEvent);
void vOnWidgetResize();
protected:
void on_realize();
bool on_expose_event(GdkEventExpose* _pstEvent);
void vOnWidgetResize();
private:
GLuint m_uiScreenTexture;
int m_iTextureSize;
private:
GLuint m_uiScreenTexture;
int m_iTextureSize;
void vUpdateTexture();
void vOnSizeUpdated();
void vUpdateTexture();
void vOnSizeUpdated();
};
} // namespace VBA

View File

@ -21,231 +21,216 @@
#include <cstring>
#include <glibmm/main.h>
namespace VBA
namespace VBA {
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale)
: m_iFilterScale(1)
, m_vFilter2x(NULL)
, m_vFilterIB(NULL)
, m_puiPixels(NULL)
, m_puiDelta(NULL)
, m_iScaledWidth(_iWidth)
, m_iScaledHeight(_iHeight)
, m_bEnableRender(true)
, m_bShowCursor(true)
{
g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) :
m_iFilterScale(1),
m_vFilter2x(NULL),
m_vFilterIB(NULL),
m_puiPixels(NULL),
m_puiDelta(NULL),
m_iScaledWidth(_iWidth),
m_iScaledHeight(_iHeight),
m_bEnableRender(true),
m_bShowCursor(true)
{
g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
m_iWidth = _iWidth;
m_iHeight = _iHeight;
m_iScale = _iScale;
m_iWidth = _iWidth;
m_iHeight = _iHeight;
m_iScale = _iScale;
set_events(Gdk::EXPOSURE_MASK
| Gdk::POINTER_MOTION_MASK
| Gdk::ENTER_NOTIFY_MASK
| Gdk::LEAVE_NOTIFY_MASK);
set_events(Gdk::EXPOSURE_MASK
| Gdk::POINTER_MOTION_MASK
| Gdk::ENTER_NOTIFY_MASK
| Gdk::LEAVE_NOTIFY_MASK);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, 8, 8);
pixbuf->fill(0);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, 8, 8);
pixbuf->fill(0);
#if !GTK_CHECK_VERSION(3, 0, 0)
m_poEmptyCursor = new Gdk::Cursor(get_display, pixbuf, 0, 0);
m_poEmptyCursor = new Gdk::Cursor(get_display, pixbuf, 0, 0);
#else
m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0);
m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0);
#endif
}
ScreenArea::~ScreenArea()
{
if (m_puiPixels)
{
delete[] m_puiPixels;
}
if (m_puiPixels) {
delete[] m_puiPixels;
}
if (m_puiDelta)
{
delete[] m_puiDelta;
}
if (m_puiDelta) {
delete[] m_puiDelta;
}
#if !GTK_CHECK_VERSION(3, 0, 0)
if (m_poEmptyCursor != NULL)
{
delete m_poEmptyCursor;
}
if (m_poEmptyCursor != NULL) {
delete m_poEmptyCursor;
}
#else
m_poEmptyCursor.reset();
m_poEmptyCursor.reset();
#endif
}
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)
{
m_iWidth = _iWidth;
m_iHeight = _iHeight;
vUpdateSize();
}
if (_iWidth != m_iWidth || _iHeight != m_iHeight) {
m_iWidth = _iWidth;
m_iHeight = _iHeight;
vUpdateSize();
}
}
void ScreenArea::vSetScale(int _iScale)
{
g_return_if_fail(_iScale >= 1);
g_return_if_fail(_iScale >= 1);
if (_iScale == 1)
{
vSetFilter(FilterNone);
}
if (_iScale == 1) {
vSetFilter(FilterNone);
}
m_iScale = _iScale;
vUpdateSize();
m_iScale = _iScale;
vUpdateSize();
}
void ScreenArea::vSetFilter(EFilter _eFilter)
{
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
m_iFilterScale = 1;
if (m_vFilter2x != NULL)
{
m_iFilterScale = 2;
}
m_iFilterScale = 1;
if (m_vFilter2x != NULL) {
m_iFilterScale = 2;
}
vUpdateSize();
vUpdateSize();
}
void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB)
{
m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32);
m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32);
}
void ScreenArea::vStartCursorTimeout()
{
m_oCursorSig.disconnect();
m_oCursorSig = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &ScreenArea::bOnCursorTimeout),
2000);
m_oCursorSig.disconnect();
m_oCursorSig = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &ScreenArea::bOnCursorTimeout),
2000);
}
void ScreenArea::vStopCursorTimeout()
{
m_oCursorSig.disconnect();
m_oCursorSig.disconnect();
}
void ScreenArea::vHideCursor()
{
#if !GTK_CHECK_VERSION(3, 0, 0)
get_window()->set_cursor(*m_poEmptyCursor);
get_window()->set_cursor(*m_poEmptyCursor);
#else
get_window()->set_cursor(m_poEmptyCursor);
get_window()->set_cursor(m_poEmptyCursor);
#endif
m_bShowCursor = false;
m_bShowCursor = false;
}
void ScreenArea::vShowCursor()
{
get_window()->set_cursor();
m_bShowCursor = true;
get_window()->set_cursor();
m_bShowCursor = true;
}
bool ScreenArea::on_motion_notify_event(GdkEventMotion * _pstEvent)
bool ScreenArea::on_motion_notify_event(GdkEventMotion* _pstEvent)
{
if (! m_bShowCursor)
{
vShowCursor();
}
vStartCursorTimeout();
return false;
if (!m_bShowCursor) {
vShowCursor();
}
vStartCursorTimeout();
return false;
}
bool ScreenArea::on_enter_notify_event(GdkEventCrossing * _pstEvent)
bool ScreenArea::on_enter_notify_event(GdkEventCrossing* _pstEvent)
{
vStartCursorTimeout();
return false;
vStartCursorTimeout();
return false;
}
bool ScreenArea::on_leave_notify_event(GdkEventCrossing * _pstEvent)
bool ScreenArea::on_leave_notify_event(GdkEventCrossing* _pstEvent)
{
vStopCursorTimeout();
if (! m_bShowCursor)
{
vShowCursor();
}
return false;
vStopCursorTimeout();
if (!m_bShowCursor) {
vShowCursor();
}
return false;
}
bool ScreenArea::bOnCursorTimeout()
{
vHideCursor();
return false;
vHideCursor();
return false;
}
void ScreenArea::vDrawPixels(u8 * _puiData)
void ScreenArea::vDrawPixels(u8* _puiData)
{
const int iSrcPitch = (m_iWidth + 1) * sizeof(u32);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
const int iSrcPitch = (m_iWidth + 1) * sizeof(u32);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
if (m_vFilterIB != NULL)
{
m_vFilterIB(_puiData + iSrcPitch,
iSrcPitch,
m_iWidth,
m_iHeight);
}
if (m_vFilterIB != NULL) {
m_vFilterIB(_puiData + iSrcPitch,
iSrcPitch,
m_iWidth,
m_iHeight);
}
if (m_vFilter2x != NULL)
{
m_vFilter2x(_puiData + iSrcPitch,
iSrcPitch,
m_puiDelta,
(u8 *)m_puiPixels,
iScaledPitch,
m_iWidth,
m_iHeight);
}
else
{
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
}
if (m_vFilter2x != NULL) {
m_vFilter2x(_puiData + iSrcPitch,
iSrcPitch,
m_puiDelta,
(u8*)m_puiPixels,
iScaledPitch,
m_iWidth,
m_iHeight);
} else {
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
}
}
void ScreenArea::vUpdateSize()
{
if (m_puiPixels)
{
delete[] m_puiPixels;
}
if (m_puiPixels) {
delete[] m_puiPixels;
}
if (m_puiDelta)
{
delete[] m_puiDelta;
}
if (m_puiDelta) {
delete[] m_puiDelta;
}
m_iScaledWidth = m_iFilterScale * m_iWidth;
m_iScaledHeight = m_iFilterScale * m_iHeight;
m_iScaledWidth = m_iFilterScale * m_iWidth;
m_iScaledHeight = m_iFilterScale * m_iHeight;
m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight];
m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)];
memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(u32));
memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32));
m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight];
m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)];
memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(u32));
memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32));
vOnSizeUpdated();
vOnSizeUpdated();
set_size_request(m_iScale * m_iWidth, m_iScale * m_iHeight);
set_size_request(m_iScale * m_iWidth, m_iScale * m_iHeight);
}
bool ScreenArea::on_configure_event(GdkEventConfigure * event)
bool ScreenArea::on_configure_event(GdkEventConfigure* event)
{
vOnWidgetResize();
vOnWidgetResize();
return true;
return true;
}
void ScreenArea::vSetEnableRender(bool _bEnable)
{
m_bEnableRender = _bEnable;
m_bEnableRender = _bEnable;
}
} // namespace VBA

View File

@ -25,61 +25,59 @@
#include "filters.h"
namespace VBA
{
class ScreenArea : public Gtk::DrawingArea
{
public:
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
virtual ~ScreenArea();
namespace VBA {
class ScreenArea : public Gtk::DrawingArea {
public:
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
virtual ~ScreenArea();
void vSetSize(int _iWidth, int _iHeight);
void vSetScale(int _iScale);
void vSetFilter(EFilter _eFilter);
void vSetFilterIB(EFilterIB _eFilterIB);
void vSetEnableRender(bool _bEnable);
virtual void vDrawPixels(u8 *_puiData);
virtual void vDrawBlackScreen() = 0;
void vSetSize(int _iWidth, int _iHeight);
void vSetScale(int _iScale);
void vSetFilter(EFilter _eFilter);
void vSetFilterIB(EFilterIB _eFilterIB);
void vSetEnableRender(bool _bEnable);
virtual void vDrawPixels(u8* _puiData);
virtual void vDrawBlackScreen() = 0;
protected:
virtual bool on_motion_notify_event(GdkEventMotion *_pstEvent);
virtual bool on_enter_notify_event(GdkEventCrossing *_pstEvent);
virtual bool on_leave_notify_event(GdkEventCrossing *_pstEvent);
virtual bool on_configure_event(GdkEventConfigure *event);
virtual bool bOnCursorTimeout();
virtual void vOnSizeUpdated()
{
}
protected:
virtual bool on_motion_notify_event(GdkEventMotion* _pstEvent);
virtual bool on_enter_notify_event(GdkEventCrossing* _pstEvent);
virtual bool on_leave_notify_event(GdkEventCrossing* _pstEvent);
virtual bool on_configure_event(GdkEventConfigure* event);
virtual bool bOnCursorTimeout();
virtual void vOnSizeUpdated()
{
}
int m_iWidth;
int m_iHeight;
int m_iScale;
int m_iFilterScale;
int m_iAreaWidth;
int m_iAreaHeight;
Filter m_vFilter2x;
FilterIB m_vFilterIB;
u32 *m_puiPixels;
u8 *m_puiDelta;
int m_iScaledWidth;
int m_iScaledHeight;
bool m_bEnableRender;
int m_iWidth;
int m_iHeight;
int m_iScale;
int m_iFilterScale;
int m_iAreaWidth;
int m_iAreaHeight;
Filter m_vFilter2x;
FilterIB m_vFilterIB;
u32* m_puiPixels;
u8* m_puiDelta;
int m_iScaledWidth;
int m_iScaledHeight;
bool m_bEnableRender;
bool m_bShowCursor;
bool m_bShowCursor;
#if !GTK_CHECK_VERSION(3, 0, 0)
Gdk::Cursor *m_poEmptyCursor;
Gdk::Cursor* m_poEmptyCursor;
#else
Glib::RefPtr<Gdk::Cursor> m_poEmptyCursor;
Glib::RefPtr<Gdk::Cursor> m_poEmptyCursor;
#endif
sigc::connection m_oCursorSig;
sigc::connection m_oCursorSig;
void vUpdateSize();
virtual void vOnWidgetResize() = 0;
void vStartCursorTimeout();
void vStopCursorTimeout();
void vHideCursor();
void vShowCursor();
void vUpdateSize();
virtual void vOnWidgetResize() = 0;
void vStartCursorTimeout();
void vStopCursorTimeout();
void vHideCursor();
void vShowCursor();
};
} // namespace VBA

View File

@ -18,117 +18,113 @@
#include "soundconfig.h"
#include <gtkmm/stock.h>
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/stock.h>
#include "intl.h"
namespace VBA
{
namespace VBA {
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
Gtk::Dialog(_pstDialog),
m_poConfig(0)
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
: Gtk::Dialog(_pstDialog)
, m_poConfig(0)
{
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
m_poVolumeComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnVolumeChanged));
m_poRateComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnRateChanged));
m_poVolumeComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnVolumeChanged));
m_poRateComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnRateChanged));
}
void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
void SoundConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
{
m_poConfig = _poConfig;
m_poWindow = _poWindow;
m_poConfig = _poConfig;
m_poWindow = _poWindow;
bool bMute = m_poConfig->oGetKey<bool>("mute");
float fSoundVolume = m_poConfig->oGetKey<float>("volume");
bool bMute = m_poConfig->oGetKey<bool>("mute");
float fSoundVolume = m_poConfig->oGetKey<float>("volume");
if (bMute)
m_poVolumeComboBox->set_active(0);
else if (0.0f <= fSoundVolume && fSoundVolume <= 0.25f)
m_poVolumeComboBox->set_active(1);
else if (0.25f < fSoundVolume && fSoundVolume <= 0.50f)
m_poVolumeComboBox->set_active(2);
else if (1.0f < fSoundVolume && fSoundVolume <= 2.0f)
m_poVolumeComboBox->set_active(4);
else
m_poVolumeComboBox->set_active(3);
if (bMute)
m_poVolumeComboBox->set_active(0);
else if (0.0f <= fSoundVolume && fSoundVolume <= 0.25f)
m_poVolumeComboBox->set_active(1);
else if (0.25f < fSoundVolume && fSoundVolume <= 0.50f)
m_poVolumeComboBox->set_active(2);
else if (1.0f < fSoundVolume && fSoundVolume <= 2.0f)
m_poVolumeComboBox->set_active(4);
else
m_poVolumeComboBox->set_active(3);
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
switch (iSoundSampleRate)
{
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
switch (iSoundSampleRate) {
case 11025:
m_poRateComboBox->set_active(0);
break;
m_poRateComboBox->set_active(0);
break;
case 22050:
m_poRateComboBox->set_active(1);
break;
m_poRateComboBox->set_active(1);
break;
default:
case 44100:
m_poRateComboBox->set_active(2);
break;
m_poRateComboBox->set_active(2);
break;
case 48000:
m_poRateComboBox->set_active(3);
break;
}
m_poRateComboBox->set_active(3);
break;
}
}
void SoundConfigDialog::vOnVolumeChanged()
{
int iVolume = m_poVolumeComboBox->get_active_row_number();
switch (iVolume)
{
int iVolume = m_poVolumeComboBox->get_active_row_number();
switch (iVolume) {
case 0: // Mute
m_poConfig->vSetKey("mute", true);
m_poConfig->vSetKey("volume", 1.0f);
break;
m_poConfig->vSetKey("mute", true);
m_poConfig->vSetKey("volume", 1.0f);
break;
case 1: // 25 %
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 0.25f);
break;
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 0.25f);
break;
case 2: // 50 %
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 0.50f);
break;
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 0.50f);
break;
case 4: // 200 %
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 2.00f);
break;
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 2.00f);
break;
case 3: // 100 %
default:
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 1.00f);
break;
}
m_poConfig->vSetKey("mute", false);
m_poConfig->vSetKey("volume", 1.00f);
break;
}
m_poWindow->vApplyConfigMute();
m_poWindow->vApplyConfigVolume();
m_poWindow->vApplyConfigMute();
m_poWindow->vApplyConfigVolume();
}
void SoundConfigDialog::vOnRateChanged()
{
int iRate = m_poRateComboBox->get_active_row_number();
switch (iRate)
{
int iRate = m_poRateComboBox->get_active_row_number();
switch (iRate) {
case 0: // 11 KHz
m_poConfig->vSetKey("sample_rate", 11025);
break;
m_poConfig->vSetKey("sample_rate", 11025);
break;
case 1: // 22 KHz
m_poConfig->vSetKey("sample_rate", 22050);
break;
m_poConfig->vSetKey("sample_rate", 22050);
break;
case 2: // 44 KHz
default:
m_poConfig->vSetKey("sample_rate", 44100);
break;
m_poConfig->vSetKey("sample_rate", 44100);
break;
case 3: // 48 KHz
m_poConfig->vSetKey("sample_rate", 48000);
break;
}
m_poConfig->vSetKey("sample_rate", 48000);
break;
}
m_poWindow->vApplyConfigSoundSampleRate();
m_poWindow->vApplyConfigSoundSampleRate();
}
} // namespace VBA

View File

@ -26,24 +26,22 @@
#include "configfile.h"
#include "window.h"
namespace VBA
{
class SoundConfigDialog : public Gtk::Dialog
{
public:
SoundConfigDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
namespace VBA {
class SoundConfigDialog : public Gtk::Dialog {
public:
SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow);
void vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow);
private:
void vOnVolumeChanged();
void vOnRateChanged();
private:
void vOnVolumeChanged();
void vOnRateChanged();
VBA::Window *m_poWindow;
VBA::Window* m_poWindow;
Config::Section *m_poConfig;
Gtk::ComboBox *m_poVolumeComboBox;
Gtk::ComboBox *m_poRateComboBox;
Config::Section* m_poConfig;
Gtk::ComboBox* m_poVolumeComboBox;
Gtk::ComboBox* m_poRateComboBox;
};
} // namespace VBA

View File

@ -16,81 +16,87 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "../sdl/inputSDL.h"
#include "../gba/Sound.h"
#include "../common/SoundSDL.h"
#include "../gba/Sound.h"
#include "../sdl/inputSDL.h"
#include "window.h"
#include "intl.h"
#include "window.h"
// Required vars, used by the emulator core
//
int systemRedShift;
int systemGreenShift;
int systemBlueShift;
int systemColorDepth;
int systemVerbose;
int systemSaveUpdateCounter;
int systemFrameSkip;
u32 systemColorMap32[0x10000];
u16 systemColorMap16[0x10000];
u16 systemGbPalette[24];
int systemRedShift;
int systemGreenShift;
int systemBlueShift;
int systemColorDepth;
int systemVerbose;
int systemSaveUpdateCounter;
int systemFrameSkip;
u32 systemColorMap32[0x10000];
u16 systemColorMap16[0x10000];
u16 systemGbPalette[24];
int emulating;
int RGB_LOW_BITS_MASK;
int emulating;
int RGB_LOW_BITS_MASK;
inline VBA::Window * GUI()
inline VBA::Window* GUI()
{
return VBA::Window::poGetInstance();
return VBA::Window::poGetInstance();
}
void systemMessage(int _iId, const char * _csFormat, ...)
void systemMessage(int _iId, const char* _csFormat, ...)
{
va_list args;
va_start(args, _csFormat);
va_list args;
va_start(args, _csFormat);
GUI()->vPopupErrorV(_(_csFormat), args);
GUI()
->vPopupErrorV(_(_csFormat), args);
va_end(args);
va_end(args);
}
void systemDrawScreen()
{
GUI()->vDrawScreen();
GUI()
->vDrawScreen();
}
bool systemReadJoypads()
{
return true;
return true;
}
u32 systemReadJoypad(int joy)
{
return inputReadJoypad(joy);
return inputReadJoypad(joy);
}
void systemShowSpeed(int _iSpeed)
{
GUI()->vShowSpeed(_iSpeed);
GUI()
->vShowSpeed(_iSpeed);
}
void system10Frames(int _iRate)
{
GUI()->vComputeFrameskip(_iRate);
GUI()
->vComputeFrameskip(_iRate);
}
void systemFrame()
{
}
void systemSetTitle(const char * _csTitle)
void systemSetTitle(const char* _csTitle)
{
GUI()->set_title(_csTitle);
GUI()
->set_title(_csTitle);
}
void systemScreenCapture(int _iNum)
{
GUI()->vCaptureScreen(_iNum);
GUI()
->vCaptureScreen(_iNum);
}
u32 systemGetClock()
@ -106,67 +112,67 @@ void systemUpdateMotionSensor()
u8 systemGetSensorDarkness()
{
return 0xE8;
return 0xE8;
}
int systemGetSensorX()
{
return 0;
return 0;
}
int systemGetSensorY()
{
return 0;
return 0;
}
int systemGetSensorZ()
{
return 0;
return 0;
}
void systemCartridgeRumble(bool)
{
}
void systemGbPrint(u8 * _puiData,
int _iLen,
int _iPages,
int _iFeed,
int _iPalette,
int _iContrast)
void systemGbPrint(u8* _puiData,
int _iLen,
int _iPages,
int _iFeed,
int _iPalette,
int _iContrast)
{
}
void systemScreenMessage(const char * _csMsg)
void systemScreenMessage(const char* _csMsg)
{
}
bool systemCanChangeSoundQuality()
{
return true;
return true;
}
bool systemPauseOnFrame()
{
return false;
return false;
}
void systemGbBorderOn()
{
}
SoundDriver * systemSoundInit()
SoundDriver* systemSoundInit()
{
soundShutdown();
soundShutdown();
return new SoundSDL();
return new SoundSDL();
}
void systemOnSoundShutdown()
{
}
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
void systemOnWriteDataToSoundBuffer(const u16* finalWave, int length)
{
}
@ -178,17 +184,17 @@ void debuggerSignal(int, int)
{
}
void log(const char *defaultMsg, ...)
void log(const char* defaultMsg, ...)
{
static FILE *out = NULL;
static FILE* out = NULL;
if(out == NULL) {
out = fopen("trace.log","w");
}
if (out == NULL) {
out = fopen("trace.log", "w");
}
va_list valist;
va_list valist;
va_start(valist, defaultMsg);
vfprintf(out, defaultMsg, valist);
va_end(valist);
va_start(valist, defaultMsg);
vfprintf(out, defaultMsg, valist);
va_end(valist);
}

View File

@ -18,68 +18,60 @@
#include "tools.h"
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)
{
return _rsString.substr(0, _rsString.find_last_of(_rsSep));
return _rsString.substr(0, _rsString.find_last_of(_rsSep));
}
Glib::ustring sCutSuffix(const Glib::ustring & _rsString,
const Glib::ustring & _rsSep)
Glib::ustring sCutSuffix(const Glib::ustring& _rsString,
const Glib::ustring& _rsSep)
{
return _rsString.substr(0, _rsString.find_last_of(_rsSep));
return _rsString.substr(0, _rsString.find_last_of(_rsSep));
}
bool bHasSuffix(const Glib::ustring & _rsString,
const Glib::ustring & _rsSuffix,
bool _bCaseSensitive)
bool bHasSuffix(const Glib::ustring& _rsString,
const Glib::ustring& _rsSuffix,
bool _bCaseSensitive)
{
if (_rsSuffix.size() > _rsString.size())
{
if (_rsSuffix.size() > _rsString.size()) {
return false;
}
Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
if (_bCaseSensitive) {
if (_rsSuffix == sEnd) {
return true;
}
} else {
if (_rsSuffix.lowercase() == sEnd.lowercase()) {
return true;
}
}
return false;
}
Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
if (_bCaseSensitive)
{
if (_rsSuffix == sEnd)
{
return true;
}
}
else
{
if (_rsSuffix.lowercase() == sEnd.lowercase())
{
return true;
}
}
return false;
}
void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens)
{
Glib::ustring delimiters = " \t\n\r";
Glib::ustring delimiters = " \t\n\r";
// Skip delimiters at beginning.
Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
// Skip delimiters at beginning.
Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
while (Glib::ustring::npos != pos || std:: string::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(source.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = source.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = source.find_first_of(delimiters, lastPos);
}
while (Glib::ustring::npos != pos || std::string::npos != lastPos) {
// Found a token, add it to the vector.
tokens.push_back(source.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = source.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = source.find_first_of(delimiters, lastPos);
}
}
} // namespace VBA

View File

@ -24,16 +24,15 @@
#include <string>
#include <vector>
namespace VBA
{
std::string sCutSuffix(const std::string &_rsString, const std::string &_rsSep = ".");
namespace VBA {
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 = ".");
bool bHasSuffix(const Glib::ustring &_rsString, const Glib::ustring &_rsSuffix,
bool _bCaseSensitive = true);
bool bHasSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSuffix,
bool _bCaseSensitive = true);
void vTokenize(Glib::ustring source, std::vector<Glib::ustring> &tokens);
void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens);
}
#endif // __VBA_TOOLS_H__

File diff suppressed because it is too large Load Diff

View File

@ -34,231 +34,242 @@
#include "filters.h"
#include "screenarea.h"
namespace VBA
{
class Window : public Gtk::Window
{
friend class Gtk::Builder;
namespace VBA {
class Window : public Gtk::Window {
friend class Gtk::Builder;
public:
virtual ~Window();
public:
virtual ~Window();
inline static Window *poGetInstance()
{
return m_poInstance;
}
static std::string sGetUiFilePath(const std::string &_sFileName);
inline static Window* poGetInstance()
{
return m_poInstance;
}
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 {
EmulatorAuto,
EmulatorCGB,
EmulatorSGB,
EmulatorGB,
EmulatorGBA,
EmulatorSGB2
};
enum EEmulatorType {
EmulatorAuto,
EmulatorCGB,
EmulatorSGB,
EmulatorGB,
EmulatorGBA,
EmulatorSGB2
};
enum ESaveType { SaveAuto, SaveEEPROM, SaveSRAM, SaveFlash, SaveEEPROMSensor, SaveNone };
enum ESaveType { SaveAuto,
SaveEEPROM,
SaveSRAM,
SaveFlash,
SaveEEPROMSensor,
SaveNone };
// GB/GBA screen sizes
const int m_iGBScreenWidth;
const int m_iGBScreenHeight;
const int m_iSGBScreenWidth;
const int m_iSGBScreenHeight;
const int m_iGBAScreenWidth;
const int m_iGBAScreenHeight;
// GB/GBA screen sizes
const int m_iGBScreenWidth;
const int m_iGBScreenHeight;
const int m_iSGBScreenWidth;
const int m_iSGBScreenHeight;
const int m_iGBAScreenWidth;
const int m_iGBAScreenHeight;
bool bLoadROM(const std::string &_rsFile);
void vPopupError(const char *_csFormat, ...);
void vPopupErrorV(const char *_csFormat, va_list _args);
void vDrawScreen();
void vComputeFrameskip(int _iRate);
void vShowSpeed(int _iSpeed);
void vCaptureScreen(int _iNum);
void vApplyConfigFilter();
void vApplyConfigFilterIB();
void vApplyConfigScreenArea();
void vApplyConfigMute();
void vApplyConfigVolume();
void vApplyConfigSoundSampleRate();
void vApplyConfigGBSystem();
void vApplyConfigGBBorder();
void vApplyConfigGBPrinter();
void vApplyConfigGBASaveType();
void vApplyConfigGBAFlashSize();
void vApplyConfigGBARTC();
void vApplyConfigFrameskip();
void vApplyConfigShowSpeed();
void vApplyPerGameConfig();
void vUpdateScreen();
bool bLoadROM(const std::string& _rsFile);
void vPopupError(const char* _csFormat, ...);
void vPopupErrorV(const char* _csFormat, va_list _args);
void vDrawScreen();
void vComputeFrameskip(int _iRate);
void vShowSpeed(int _iSpeed);
void vCaptureScreen(int _iNum);
void vApplyConfigFilter();
void vApplyConfigFilterIB();
void vApplyConfigScreenArea();
void vApplyConfigMute();
void vApplyConfigVolume();
void vApplyConfigSoundSampleRate();
void vApplyConfigGBSystem();
void vApplyConfigGBBorder();
void vApplyConfigGBPrinter();
void vApplyConfigGBASaveType();
void vApplyConfigGBAFlashSize();
void vApplyConfigGBARTC();
void vApplyConfigFrameskip();
void vApplyConfigShowSpeed();
void vApplyPerGameConfig();
void vUpdateScreen();
inline ECartridge eGetCartridge() const
{
return m_eCartridge;
}
inline ECartridge eGetCartridge() const
{
return m_eCartridge;
}
protected:
Window(GtkWindow *_pstWindow, const Glib::RefPtr<Gtk::Builder> &_poXml);
protected:
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 vOnMenuExit();
virtual void vOnFileOpen();
virtual void vOnFileLoad();
virtual void vOnFileSave();
virtual void vOnLoadGameMostRecent();
virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem *_poCMI);
void vOnLoadGame(int _iSlot);
virtual void vOnSaveGameOldest();
void vOnSaveGame(int _iSlot);
virtual void vOnFilePauseToggled(Gtk::CheckMenuItem *_poCMI);
virtual void vOnFileReset();
virtual void vOnRecentFile();
virtual void vOnFileScreenCapture();
virtual void vOnFileClose();
virtual void vOnFileExit();
virtual void vOnVideoFullscreen();
virtual void vOnDirectories();
virtual void vOnGeneralConfigure();
virtual void vOnJoypadConfigure();
virtual void vOnDisplayConfigure();
virtual void vOnSoundConfigure();
virtual void vOnGameBoyConfigure();
virtual void vOnGameBoyAdvanceConfigure();
virtual void vOnCheatList();
virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem *_poCMI);
virtual void vOnHelpAbout();
virtual bool bOnEmuIdle();
virtual bool bOnEmuSaveStateRewind();
virtual bool bOnEmuRewind();
virtual void vOnMenuEnter();
virtual void vOnMenuExit();
virtual void vOnFileOpen();
virtual void vOnFileLoad();
virtual void vOnFileSave();
virtual void vOnLoadGameMostRecent();
virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem* _poCMI);
void vOnLoadGame(int _iSlot);
virtual void vOnSaveGameOldest();
void vOnSaveGame(int _iSlot);
virtual void vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI);
virtual void vOnFileReset();
virtual void vOnRecentFile();
virtual void vOnFileScreenCapture();
virtual void vOnFileClose();
virtual void vOnFileExit();
virtual void vOnVideoFullscreen();
virtual void vOnDirectories();
virtual void vOnGeneralConfigure();
virtual void vOnJoypadConfigure();
virtual void vOnDisplayConfigure();
virtual void vOnSoundConfigure();
virtual void vOnGameBoyConfigure();
virtual void vOnGameBoyAdvanceConfigure();
virtual void vOnCheatList();
virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem* _poCMI);
virtual void vOnHelpAbout();
virtual bool bOnEmuIdle();
virtual bool bOnEmuSaveStateRewind();
virtual bool bOnEmuRewind();
virtual bool on_focus_in_event(GdkEventFocus *_pstEvent);
virtual bool on_focus_out_event(GdkEventFocus *_pstEvent);
virtual bool on_key_press_event(GdkEventKey *_pstEvent);
virtual bool on_key_release_event(GdkEventKey *_pstEvent);
virtual bool on_window_state_event(GdkEventWindowState *_pstEvent);
virtual bool on_focus_in_event(GdkEventFocus* _pstEvent);
virtual bool on_focus_out_event(GdkEventFocus* _pstEvent);
virtual bool on_key_press_event(GdkEventKey* _pstEvent);
virtual bool on_key_release_event(GdkEventKey* _pstEvent);
virtual bool on_window_state_event(GdkEventWindowState* _pstEvent);
private:
// Config limits
const int m_iFrameskipMin;
const int m_iFrameskipMax;
const int m_iScaleMin;
const int m_iScaleMax;
const int m_iShowSpeedMin;
const int m_iShowSpeedMax;
const int m_iSaveTypeMin;
const int m_iSaveTypeMax;
const int m_iSoundSampleRateMin;
const int m_iSoundSampleRateMax;
const float m_fSoundVolumeMin;
const float m_fSoundVolumeMax;
const int m_iEmulatorTypeMin;
const int m_iEmulatorTypeMax;
const int m_iFilter2xMin;
const int m_iFilter2xMax;
const int m_iFilterIBMin;
const int m_iFilterIBMax;
const EPad m_iJoypadMin;
const EPad m_iJoypadMax;
const int m_iVideoOutputMin;
const int m_iVideoOutputMax;
private:
// Config limits
const int m_iFrameskipMin;
const int m_iFrameskipMax;
const int m_iScaleMin;
const int m_iScaleMax;
const int m_iShowSpeedMin;
const int m_iShowSpeedMax;
const int m_iSaveTypeMin;
const int m_iSaveTypeMax;
const int m_iSoundSampleRateMin;
const int m_iSoundSampleRateMax;
const float m_fSoundVolumeMin;
const float m_fSoundVolumeMax;
const int m_iEmulatorTypeMin;
const int m_iEmulatorTypeMax;
const int m_iFilter2xMin;
const int m_iFilter2xMax;
const int m_iFilterIBMin;
const int m_iFilterIBMax;
const EPad m_iJoypadMin;
const EPad m_iJoypadMax;
const int m_iVideoOutputMin;
const int m_iVideoOutputMax;
static Window *m_poInstance;
static Window* m_poInstance;
Glib::RefPtr<Gtk::Builder> m_poXml;
Glib::RefPtr<Gtk::Builder> m_poXml;
std::string m_sUserDataDir;
std::string m_sConfigFile;
Config::File m_oConfig;
Config::Section *m_poDirConfig;
Config::Section *m_poCoreConfig;
Config::Section *m_poDisplayConfig;
Config::Section *m_poSoundConfig;
Config::Section *m_poInputConfig;
std::string m_sUserDataDir;
std::string m_sConfigFile;
Config::File m_oConfig;
Config::Section* m_poDirConfig;
Config::Section* m_poCoreConfig;
Config::Section* m_poDisplayConfig;
Config::Section* m_poSoundConfig;
Config::Section* m_poInputConfig;
Gtk::FileChooserDialog *m_poFileOpenDialog;
Gtk::FileChooserDialog* m_poFileOpenDialog;
ScreenArea *m_poScreenArea;
Gtk::CheckMenuItem *m_poFilePauseItem;
Gtk::MenuBar *m_poMenuBar;
ScreenArea* m_poScreenArea;
Gtk::CheckMenuItem* m_poFilePauseItem;
Gtk::MenuBar* m_poMenuBar;
struct SGameSlot {
bool m_bEmpty;
std::string m_sFile;
time_t m_uiTime;
};
struct SGameSlot {
bool m_bEmpty;
std::string m_sFile;
time_t m_uiTime;
};
struct SJoypadKey {
const char *m_csKey;
const EKey m_eKeyFlag;
};
struct SJoypadKey {
const char* m_csKey;
const EKey m_eKeyFlag;
};
static const SJoypadKey m_astJoypad[];
static const SJoypadKey m_astJoypad[];
Gtk::MenuItem *m_apoLoadGameItem[10];
Gtk::MenuItem *m_apoSaveGameItem[10];
SGameSlot m_astGameSlot[10];
Gtk::MenuItem* m_apoLoadGameItem[10];
Gtk::MenuItem* m_apoSaveGameItem[10];
SGameSlot m_astGameSlot[10];
Glib::RefPtr<Gtk::RecentManager> m_poRecentManager;
Gtk::MenuItem *m_poRecentMenu;
Gtk::RecentChooserMenu *m_poRecentChooserMenu;
Glib::RefPtr<Gtk::RecentManager> m_poRecentManager;
Gtk::MenuItem* m_poRecentMenu;
Gtk::RecentChooserMenu* m_poRecentChooserMenu;
std::list<Gtk::Widget *> m_listSensitiveWhenPlaying;
std::list<Gtk::Widget*> m_listSensitiveWhenPlaying;
sigc::connection m_oEmuSig, m_oEmuRewindSig;
sigc::connection m_oEmuSig, m_oEmuRewindSig;
int m_bFullscreen;
int m_iScreenWidth;
int m_iScreenHeight;
int m_iFrameCount;
int m_bFullscreen;
int m_iScreenWidth;
int m_iScreenHeight;
int m_iFrameCount;
std::string m_sRomFile;
ECartridge m_eCartridge;
EmulatedSystem m_stEmulator;
bool m_bPaused;
bool m_bWasEmulating;
bool m_bAutoFrameskip;
EShowSpeed m_eShowSpeed;
std::string m_sRomFile;
ECartridge m_eCartridge;
EmulatedSystem m_stEmulator;
bool m_bPaused;
bool m_bWasEmulating;
bool m_bAutoFrameskip;
EShowSpeed m_eShowSpeed;
/* State saving into memory & rewind to saved state */
u16 m_state_count_max;
u16 m_rewind_interval;
static const u32 SZSTATE = 1024 * 512;
std::deque<char *> m_rewind_load_q;
char *m_psavestate;
/* State saving into memory & rewind to saved state */
u16 m_state_count_max;
u16 m_rewind_interval;
static const u32 SZSTATE = 1024 * 512;
std::deque<char*> m_rewind_load_q;
char* m_psavestate;
void vInitSystem();
void vUnInitSystem();
void vInitSDL();
void vInitConfig();
void vCheckConfig();
void vInitColors(EColorFormat _eColorFormat);
void vLoadConfig(const std::string &_rsFile);
void vSaveConfig(const std::string &_rsFile);
void vHistoryAdd(const std::string &_rsFile);
void vApplyConfigJoypads();
void vSaveJoypadsToConfig();
void vDrawDefaultScreen();
void vSetDefaultTitle();
void vCreateFileOpenDialog();
void vLoadBattery();
void vLoadCheats();
void vSaveBattery();
void vSaveCheats();
void vStartEmu();
void vStopEmu();
void vUpdateGameSlots();
void vToggleFullscreen();
void vSDLPollEvents();
void vInitSystem();
void vUnInitSystem();
void vInitSDL();
void vInitConfig();
void vCheckConfig();
void vInitColors(EColorFormat _eColorFormat);
void vLoadConfig(const std::string& _rsFile);
void vSaveConfig(const std::string& _rsFile);
void vHistoryAdd(const std::string& _rsFile);
void vApplyConfigJoypads();
void vSaveJoypadsToConfig();
void vDrawDefaultScreen();
void vSetDefaultTitle();
void vCreateFileOpenDialog();
void vLoadBattery();
void vLoadCheats();
void vSaveBattery();
void vSaveCheats();
void vStartEmu();
void vStopEmu();
void vUpdateGameSlots();
void vToggleFullscreen();
void vSDLPollEvents();
};
} // namespace VBA

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,8 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "libretro.h"
#include "SoundRetro.h"
#include "libretro.h"
unsigned g_audio_frames;
extern retro_audio_sample_batch_t audio_batch_cb;
@ -24,21 +24,20 @@ SoundRetro::SoundRetro()
{
}
void SoundRetro::write(u16 * finalWave, int length)
void SoundRetro::write(u16* finalWave, int length)
{
const int16_t* wave = (const int16_t*)finalWave;
int frames = length >> 1;
audio_batch_cb(wave, frames);
const int16_t* wave = (const int16_t*)finalWave;
int frames = length >> 1;
audio_batch_cb(wave, frames);
g_audio_frames += frames;
g_audio_frames += frames;
}
bool SoundRetro::init(long sampleRate)
{
g_audio_frames = 0;
g_audio_frames = 0;
return true;
return true;
}
SoundRetro::~SoundRetro()

View File

@ -20,17 +20,16 @@
#include "../common/SoundDriver.h"
class SoundRetro : public SoundDriver
{
public:
SoundRetro();
virtual ~SoundRetro();
class SoundRetro : public SoundDriver {
public:
SoundRetro();
virtual ~SoundRetro();
virtual bool init(long sampleRate);
virtual void pause();
virtual void reset();
virtual void resume();
virtual void write(u16 *finalWave, int length);
virtual bool init(long sampleRate);
virtual void pause();
virtual void reset();
virtual void resume();
virtual void write(u16* finalWave, int length);
};
#endif // __VBA_SOUND_RETRO_H__

View File

@ -2,17 +2,17 @@
#include <stdlib.h>
#include <string.h>
#include "System.h"
#include "NLS.h"
#include "System.h"
#include "Util.h"
#include "common/Port.h"
#include "gba/Flash.h"
#include "gba/GBA.h"
#include "gba/Globals.h"
#include "gba/RTC.h"
#include "common/Port.h"
#include "gba/gbafilter.h"
#include "gb/gbGlobals.h"
#include "gba/gbafilter.h"
#ifndef _MSC_VER
#include <strings.h>
@ -27,259 +27,242 @@ extern int systemBlueShift;
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];
bool utilWritePNGFile(const char *fileName, int w, int h, uint8_t *pix)
bool utilWritePNGFile(const char* fileName, int w, int h, uint8_t* pix)
{
return false;
return false;
}
void utilPutDword(u8 *p, u32 value)
void utilPutDword(u8* p, u32 value)
{
*p++ = value & 255;
*p++ = (value >> 8) & 255;
*p++ = (value >> 16) & 255;
*p = (value >> 24) & 255;
*p++ = value & 255;
*p++ = (value >> 8) & 255;
*p++ = (value >> 16) & 255;
*p = (value >> 24) & 255;
}
void utilPutWord(uint8_t *p, uint16_t value)
void utilPutWord(uint8_t* p, uint16_t value)
{
*p++ = value & 255;
*p = (value >> 8) & 255;
*p++ = value & 255;
*p = (value >> 8) & 255;
}
bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix)
bool utilWriteBMPFile(const char* fileName, int w, int h, uint8_t* pix)
{
return false;
return false;
}
extern bool cpuIsMultiBoot;
bool utilIsGBAImage(const char * file)
bool utilIsGBAImage(const char* file)
{
cpuIsMultiBoot = false;
if(strlen(file) > 4) {
const char * p = strrchr(file,'.');
cpuIsMultiBoot = false;
if (strlen(file) > 4) {
const char* p = strrchr(file, '.');
if(p != NULL) {
if((_stricmp(p, ".agb") == 0) ||
(_stricmp(p, ".gba") == 0) ||
(_stricmp(p, ".bin") == 0) ||
(_stricmp(p, ".elf") == 0))
return true;
if(_stricmp(p, ".mb") == 0) {
cpuIsMultiBoot = true;
return true;
}
if (p != NULL) {
if ((_stricmp(p, ".agb") == 0) || (_stricmp(p, ".gba") == 0) || (_stricmp(p, ".bin") == 0) || (_stricmp(p, ".elf") == 0))
return true;
if (_stricmp(p, ".mb") == 0) {
cpuIsMultiBoot = true;
return true;
}
}
}
}
return false;
return false;
}
bool utilIsGBImage(const char * file)
bool utilIsGBImage(const char* file)
{
if(strlen(file) > 4) {
const char * p = strrchr(file,'.');
if (strlen(file) > 4) {
const char* p = strrchr(file, '.');
if(p != NULL) {
if((_stricmp(p, ".dmg") == 0) ||
(_stricmp(p, ".gb") == 0) ||
(_stricmp(p, ".gbc") == 0) ||
(_stricmp(p, ".cgb") == 0) ||
(_stricmp(p, ".sgb") == 0))
return true;
if (p != NULL) {
if ((_stricmp(p, ".dmg") == 0) || (_stricmp(p, ".gb") == 0) || (_stricmp(p, ".gbc") == 0) || (_stricmp(p, ".cgb") == 0) || (_stricmp(p, ".sgb") == 0))
return true;
}
}
}
return false;
return false;
}
// strip .gz or .z off end
void utilStripDoubleExtension(const char *file, char *buffer)
void utilStripDoubleExtension(const char* file, char* buffer)
{
if(buffer != file) // allows conversion in place
strcpy(buffer, file);
if (buffer != file) // allows conversion in place
strcpy(buffer, file);
}
static bool utilIsImage(const char *file)
static bool utilIsImage(const char* file)
{
return utilIsGBAImage(file) || utilIsGBImage(file);
return utilIsGBAImage(file) || utilIsGBImage(file);
}
IMAGE_TYPE utilFindType(const char *file)
IMAGE_TYPE utilFindType(const char* file)
{
char buffer [2048];
if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead?
{
return IMAGE_UNKNOWN;
}
return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB;
char buffer[2048];
if (!utilIsImage(file)) // TODO: utilIsArchive() instead?
{
return IMAGE_UNKNOWN;
}
return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB;
}
static int utilGetSize(int size)
{
int res = 1;
while(res < size)
res <<= 1;
return res;
int res = 1;
while (res < size)
res <<= 1;
return res;
}
uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data, int &size)
uint8_t* utilLoad(const char* file, bool (*accept)(const char*), uint8_t* data, int& size)
{
FILE *fp = NULL;
char *buf = NULL;
FILE* fp = NULL;
char* buf = NULL;
fp = fopen(file,"rb");
fseek(fp, 0, SEEK_END); //go to end
size = ftell(fp); // get position at end (length)
rewind(fp);
fp = fopen(file, "rb");
fseek(fp, 0, SEEK_END); //go to end
size = ftell(fp); // get position at end (length)
rewind(fp);
uint8_t *image = data;
if(image == NULL)
{
//allocate buffer memory if none was passed to the function
image = (uint8_t *)malloc(utilGetSize(size));
if(image == NULL)
{
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
"data");
return NULL;
}
}
fread(image, 1, size, fp); // read into buffer
fclose(fp);
return image;
}
void utilGBAFindSave(const uint8_t *data, const int size)
{
uint32_t *p = (uint32_t *)data;
uint32_t *end = (uint32_t *)(data + size);
int saveType = 0;
int flashSize = 0x10000;
bool rtcFound = false;
while(p < end) {
uint32_t d = READ32LE(p);
if(d == 0x52504545) {
if(memcmp(p, "EEPROM_", 7) == 0) {
if(saveType == 0)
saveType = 3;
}
} else if (d == 0x4D415253) {
if(memcmp(p, "SRAM_", 5) == 0) {
if(saveType == 0)
saveType = 1;
}
} else if (d == 0x53414C46) {
if(memcmp(p, "FLASH1M_", 8) == 0) {
if(saveType == 0) {
saveType = 2;
flashSize = 0x20000;
uint8_t* image = data;
if (image == NULL) {
//allocate buffer memory if none was passed to the function
image = (uint8_t*)malloc(utilGetSize(size));
if (image == NULL) {
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
"data");
return NULL;
}
} else if(memcmp(p, "FLASH", 5) == 0) {
if(saveType == 0) {
saveType = 2;
flashSize = 0x10000;
}
}
} else if (d == 0x52494953) {
if(memcmp(p, "SIIRTC_V", 8) == 0)
rtcFound = true;
}
p++;
}
// if no matches found, then set it to NONE
if(saveType == 0) {
saveType = 5;
}
rtcEnable(rtcFound);
cpuSaveType = saveType;
flashSetSize(flashSize);
fread(image, 1, size, fp); // read into buffer
fclose(fp);
return image;
}
void utilGBAFindSave(const uint8_t* data, const int size)
{
uint32_t* p = (uint32_t*)data;
uint32_t* end = (uint32_t*)(data + size);
int saveType = 0;
int flashSize = 0x10000;
bool rtcFound = false;
while (p < end) {
uint32_t d = READ32LE(p);
if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {
if (saveType == 0)
saveType = 3;
}
} else if (d == 0x4D415253) {
if (memcmp(p, "SRAM_", 5) == 0) {
if (saveType == 0)
saveType = 1;
}
} else if (d == 0x53414C46) {
if (memcmp(p, "FLASH1M_", 8) == 0) {
if (saveType == 0) {
saveType = 2;
flashSize = 0x20000;
}
} else if (memcmp(p, "FLASH", 5) == 0) {
if (saveType == 0) {
saveType = 2;
flashSize = 0x10000;
}
}
} else if (d == 0x52494953) {
if (memcmp(p, "SIIRTC_V", 8) == 0)
rtcFound = true;
}
p++;
}
// if no matches found, then set it to NONE
if (saveType == 0) {
saveType = 5;
}
rtcEnable(rtcFound);
cpuSaveType = saveType;
flashSetSize(flashSize);
}
void utilUpdateSystemColorMaps(bool lcd)
{
switch(systemColorDepth) {
case 16:
{
for(int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd) gbafilter_pal(systemColorMap16, 0x10000);
switch (systemColorDepth) {
case 16: {
for (int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd)
gbafilter_pal(systemColorMap16, 0x10000);
} break;
case 24:
case 32: {
for (int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd)
gbafilter_pal32(systemColorMap32, 0x10000);
} break;
}
break;
case 24:
case 32:
{
for(int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd) gbafilter_pal32(systemColorMap32, 0x10000);
}
break;
}
}
// Check for existence of file.
bool utilFileExists( const char *filename )
bool utilFileExists(const char* filename)
{
FILE *f = fopen( filename, "r" );
if( f == NULL ) {
return false;
} else {
fclose( f );
return true;
}
FILE* f = fopen(filename, "r");
if (f == NULL) {
return false;
} else {
fclose(f);
return true;
}
}
// Not endian safe, but VBA itself doesn't seem to care, so hey <_<
void utilWriteIntMem(uint8_t *& data, int val)
void utilWriteIntMem(uint8_t*& data, int val)
{
memcpy(data, &val, sizeof(int));
data += sizeof(int);
memcpy(data, &val, sizeof(int));
data += sizeof(int);
}
void utilWriteMem(uint8_t *& data, const void *in_data, unsigned size)
void utilWriteMem(uint8_t*& data, const void* in_data, unsigned size)
{
memcpy(data, in_data, size);
data += size;
memcpy(data, in_data, size);
data += size;
}
void utilWriteDataMem(uint8_t *& data, variable_desc *desc)
void utilWriteDataMem(uint8_t*& data, variable_desc* desc)
{
while (desc->address)
{
utilWriteMem(data, desc->address, desc->size);
desc++;
}
while (desc->address) {
utilWriteMem(data, desc->address, desc->size);
desc++;
}
}
int utilReadIntMem(const uint8_t *& data)
int utilReadIntMem(const uint8_t*& data)
{
int res;
memcpy(&res, data, sizeof(int));
data += sizeof(int);
return res;
int res;
memcpy(&res, data, sizeof(int));
data += sizeof(int);
return res;
}
void utilReadMem(void *buf, const uint8_t *& data, unsigned size)
void utilReadMem(void* buf, const uint8_t*& data, unsigned size)
{
memcpy(buf, data, size);
data += size;
memcpy(buf, data, size);
data += size;
}
void utilReadDataMem(const uint8_t *& data, variable_desc *desc)
void utilReadDataMem(const uint8_t*& data, variable_desc* desc)
{
while (desc->address)
{
utilReadMem(desc->address, data, desc->size);
desc++;
}
while (desc->address) {
utilReadMem(desc->address, data, desc->size);
desc++;
}
}

View File

@ -8,191 +8,194 @@
#include <stdlib.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)
{
switch (type) {
case EEPROM_512B:
return "EEPROM 4kbit";
case EEPROM_8K:
return "EEPROM 64kbit";
case FLASH_64K:
return "FLASH 512kbit";
case FLASH_128K:
return "FLASH 1MBit";
switch (type) {
case EEPROM_512B:
return "EEPROM 4kbit";
case EEPROM_8K:
return "EEPROM 64kbit";
case FLASH_64K:
return "FLASH 512kbit";
case FLASH_128K:
return "FLASH 1MBit";
default:
return "Unknown type";
}
default:
return "Unknown type";
}
}
static bool scan_section(const uint8_t *data, unsigned size)
static bool scan_section(const uint8_t* data, unsigned size)
{
for (unsigned i = 0; i < size; i++) {
if (data[i] != 0xff)
return true;
}
for (unsigned i = 0; i < size; i++) {
if (data[i] != 0xff)
return true;
}
return false;
return false;
}
static enum save_type detect_save_type(const uint8_t *data, unsigned size)
static enum save_type detect_save_type(const uint8_t* data, unsigned size)
{
if (size == 512)
return EEPROM_512B;
if (size == 0x2000)
return EEPROM_8K;
if (size == 0x10000)
return FLASH_64K;
if (size == 0x20000)
return FLASH_128K;
if (size == 512)
return EEPROM_512B;
if (size == 0x2000)
return EEPROM_8K;
if (size == 0x10000)
return FLASH_64K;
if (size == 0x20000)
return FLASH_128K;
if (size == (0x20000 + 0x2000)) {
if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000))
return FLASH_64K;
if (scan_section(data, 0x20000))
return FLASH_128K;
if (size == (0x20000 + 0x2000)) {
if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000))
return FLASH_64K;
if (scan_section(data, 0x20000))
return FLASH_128K;
if (scan_section(data + 0x20000, 512) &&
!scan_section(data + 0x20000 + 512, 0x20000 - 512))
return EEPROM_512B;
if (scan_section(data + 0x20000, 0x2000))
return EEPROM_8K;
}
if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512))
return EEPROM_512B;
if (scan_section(data + 0x20000, 0x2000))
return EEPROM_8K;
}
return SAVE_UNKNOWN;
return SAVE_UNKNOWN;
}
static void dump_srm(FILE *file, const uint8_t *data, enum save_type type)
static void dump_srm(FILE* file, const uint8_t* data, enum save_type type)
{
void *buf = malloc(0x20000 + 0x2000);
memset(buf, 0xff, 0x20000 + 0x2000);
void* buf = malloc(0x20000 + 0x2000);
memset(buf, 0xff, 0x20000 + 0x2000);
switch (type) {
case EEPROM_512B:
fwrite(buf, 1, 0x20000, file);
fwrite(data, 1, 512, file);
fwrite(buf, 1, 0x2000 - 512, file);
break;
switch (type) {
case EEPROM_512B:
fwrite(buf, 1, 0x20000, file);
fwrite(data, 1, 512, file);
fwrite(buf, 1, 0x2000 - 512, file);
break;
case EEPROM_8K:
fwrite(buf, 1, 0x20000, file);
fwrite(data, 1, 0x2000, file);
break;
case EEPROM_8K:
fwrite(buf, 1, 0x20000, file);
fwrite(data, 1, 0x2000, file);
break;
case FLASH_64K:
fwrite(data, 1, 0x10000, file);
fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file);
break;
case FLASH_64K:
fwrite(data, 1, 0x10000, file);
fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file);
break;
case FLASH_128K:
fwrite(data, 1, 0x20000, file);
fwrite(buf, 1, 0x2000, file);
break;
case FLASH_128K:
fwrite(data, 1, 0x20000, file);
fwrite(buf, 1, 0x2000, file);
break;
default:
break;
}
default:
break;
}
free(buf);
free(buf);
}
static void dump_sav(FILE *file, const uint8_t *data, enum save_type type)
static void dump_sav(FILE* file, const uint8_t* data, enum save_type type)
{
switch (type) {
case EEPROM_512B:
fwrite(data + 0x20000, 1, 512, file);
break;
switch (type) {
case EEPROM_512B:
fwrite(data + 0x20000, 1, 512, file);
break;
case EEPROM_8K:
fwrite(data + 0x20000, 1, 0x2000, file);
break;
case EEPROM_8K:
fwrite(data + 0x20000, 1, 0x2000, file);
break;
case FLASH_64K:
fwrite(data, 1, 0x10000, file);
break;
case FLASH_64K:
fwrite(data, 1, 0x10000, file);
break;
case FLASH_128K:
fwrite(data, 1, 0x20000, file);
break;
case FLASH_128K:
fwrite(data, 1, 0x20000, file);
break;
default:
break;
}
default:
break;
}
}
// One shot cowboy code :)
int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
if (argc != 2) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
return 1;
}
if (argc != 2) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
return 1;
}
FILE *file = fopen(argv[1], "rb");
if (!file) {
fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]);
goto error;
}
FILE* file = fopen(argv[1], "rb");
if (!file) {
fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]);
goto error;
}
fseek(file, 0, SEEK_END);
long len = ftell(file);
rewind(file);
fseek(file, 0, SEEK_END);
long len = ftell(file);
rewind(file);
uint8_t *buffer = malloc(len);
if (!buffer) {
fprintf(stderr, "Failed to allocate memory!\n");
goto error;
}
fread(buffer, 1, len, file);
fclose(file);
file = NULL;
uint8_t* buffer = malloc(len);
if (!buffer) {
fprintf(stderr, "Failed to allocate memory!\n");
goto error;
}
fread(buffer, 1, len, file);
fclose(file);
file = NULL;
char *out_path = strdup(argv[1]);
char *split = strrchr(out_path, '.');
const char *ext = NULL;
char* out_path = strdup(argv[1]);
char* split = strrchr(out_path, '.');
const char* ext = NULL;
if (split) {
*split = '\0';
ext = split + 1;
if (split) {
*split = '\0';
ext = split + 1;
if (strcasecmp(ext, "srm") == 0)
strcat(out_path, ".sav");
else if (strlen(ext) >= 3)
strcat(out_path, ".srm");
else
ext = NULL;
}
if (!ext) {
fprintf(stderr, "Cannot detect extension!\n");
goto error;
}
enum save_type type = detect_save_type(buffer, len);
printf("Detected save type: %s\n", save_type_to_string(type));
if (type == SAVE_UNKNOWN) {
fprintf(stderr, "Cannot infer save type ...\n");
goto error;
}
file = fopen(out_path, "wb");
if (!file)
goto error;
if (len == (0x20000 + 0x2000))
dump_sav(file, buffer, type);
if (strcasecmp(ext, "srm") == 0)
strcat(out_path, ".sav");
else if (strlen(ext) >= 3)
strcat(out_path, ".srm");
else
dump_srm(file, buffer, type);
fclose(file);
ext = NULL;
}
return 0;
if (!ext) {
fprintf(stderr, "Cannot detect extension!\n");
goto error;
}
enum save_type type = detect_save_type(buffer, len);
printf("Detected save type: %s\n", save_type_to_string(type));
if (type == SAVE_UNKNOWN) {
fprintf(stderr, "Cannot infer save type ...\n");
goto error;
}
file = fopen(out_path, "wb");
if (!file)
goto error;
if (len == (0x20000 + 0x2000))
dump_sav(file, buffer, type);
else
dump_srm(file, buffer, type);
fclose(file);
return 0;
error:
if (file)
fclose(file);
return 1;
if (file)
fclose(file);
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -6,78 +6,85 @@ extern "C" {
#endif
static const unsigned long crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO2_CRC32(buf) DO1_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);
#define DO2_CRC32(buf) \
DO1_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;
crc = crc ^ 0xffffffffL;
while (len >= 8)
{
DO8_CRC32(buf);
len -= 8;
}
if (len) do {
DO1_CRC32(buf);
} while (--len);
return crc ^ 0xffffffffL;
if (buf == 0)
return 0L;
crc = crc ^ 0xffffffffL;
while (len >= 8) {
DO8_CRC32(buf);
len -= 8;
}
if (len)
do {
DO1_CRC32(buf);
} while (--len);
return crc ^ 0xffffffffL;
}
#ifdef __cplusplus
@ -85,4 +92,3 @@ unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int le
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,5 +18,5 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
extern void debuggerMain();
extern void debuggerOutput(const char *, u32);
extern void debuggerOutput(const char*, u32);
extern void debuggerSignal(int, int);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -39,13 +39,13 @@
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
TOKEN_IDENTIFIER = 258,
TOKEN_DOT = 259,
TOKEN_STAR = 260,
TOKEN_ARROW = 261,
TOKEN_ADDR = 262,
TOKEN_SIZEOF = 263,
TOKEN_NUMBER = 264
TOKEN_IDENTIFIER = 258,
TOKEN_DOT = 259,
TOKEN_STAR = 260,
TOKEN_ARROW = 261,
TOKEN_ADDR = 262,
TOKEN_SIZEOF = 263,
TOKEN_NUMBER = 264
};
#endif
/* Tokens. */

View File

@ -16,400 +16,396 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../common/Port.h"
#include "../gba/GBA.h"
#include "../gba/elf.h"
#include "../common/Port.h"
#include "exprNode.h"
#ifndef __GNUC__
#define strdup _strdup
#endif
extern char *yytext;
extern char* yytext;
#define debuggerReadMemory(addr) \
READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
READ32LE((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
const void *exprNodeCleanUpList[100];
const void* exprNodeCleanUpList[100];
int exprNodeCleanUpCount = 0;
Type exprNodeType = { 0, TYPE_base, "int", DW_ATE_signed, 4, 0, {0}, 0 };
Type exprNodeType = { 0, TYPE_base, "int", DW_ATE_signed, 4, 0, { 0 }, 0 };
void exprNodeClean(const void *m)
void exprNodeClean(const void* m)
{
exprNodeCleanUpList[exprNodeCleanUpCount++] = m;
exprNodeCleanUpList[exprNodeCleanUpCount++] = m;
}
void exprNodeCleanUp()
{
for(int i = 0; i < exprNodeCleanUpCount; i++) {
free((void *)exprNodeCleanUpList[i]);
}
exprNodeCleanUpCount = 0;
for (int i = 0; i < exprNodeCleanUpCount; i++) {
free((void*)exprNodeCleanUpList[i]);
}
exprNodeCleanUpCount = 0;
}
Node *exprNodeIdentifier()
Node* exprNodeIdentifier()
{
Node *n = (Node *)calloc(1, sizeof(Node));
n->name = strdup(yytext);
Node* n = (Node*)calloc(1, sizeof(Node));
n->name = strdup(yytext);
exprNodeClean(n->name);
exprNodeClean(n);
exprNodeClean(n->name);
exprNodeClean(n);
n->print = exprNodeIdentifierPrint;
n->resolve = exprNodeIdentifierResolve;
return n;
n->print = exprNodeIdentifierPrint;
n->resolve = exprNodeIdentifierResolve;
return n;
}
bool exprNodeIdentifierResolve(Node *n, Function *f, CompileUnit *u)
bool exprNodeIdentifierResolve(Node* n, Function* f, CompileUnit* u)
{
Object *o;
if(elfGetObject(n->name, f, u, &o)) {
n->type = o->type;
n->location = elfDecodeLocation(f, o->location, &n->locType);
return true;
} else {
printf("Object %s not found\n", n->name);
}
return false;
}
void exprNodeIdentifierPrint(Node *n)
{
printf("%s", n->name);
}
Node *exprNodeNumber()
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
n->location = atoi(yytext);
n->type = &exprNodeType;
n->locType = LOCATION_value;
n->print = exprNodeNumberPrint;
n->resolve = exprNodeNumberResolve;
return n;
}
bool exprNodeNumberResolve(Node *n, Function *f, CompileUnit *u)
{
return true;
}
void exprNodeNumberPrint(Node *n)
{
printf("%d", n->location);
}
Node *exprNodeStar(Node *exp)
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->print = exprNodeStarPrint;
n->resolve = exprNodeStarResolve;
return n;
}
bool exprNodeStarResolve(Node *n, Function *f, CompileUnit *u)
{
if(n->expression->resolve(n->expression, f, u)) {
if(n->expression->type->type == TYPE_pointer) {
n->location = n->expression->location;
if(n->expression->locType == LOCATION_memory) {
n->location = debuggerReadMemory(n->location);
} else if(n->expression->locType == LOCATION_register) {
n->location = reg[n->expression->location].I;
} else {
n->location = n->expression->location;
}
n->type = n->expression->type->pointer;
n->locType = LOCATION_memory;
return true;
Object* o;
if (elfGetObject(n->name, f, u, &o)) {
n->type = o->type;
n->location = elfDecodeLocation(f, o->location, &n->locType);
return true;
} else {
printf("Object is not of pointer type\n");
printf("Object %s not found\n", n->name);
}
}
return false;
return false;
}
void exprNodeStarPrint(Node *n)
void exprNodeIdentifierPrint(Node* n)
{
printf("*");
n->expression->print(n->expression);
printf("%s", n->name);
}
Node *exprNodeDot(Node *exp, Node *ident)
Node* exprNodeNumber()
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
Node* n = (Node*)calloc(1, sizeof(Node));
n->expression = exp;
n->name = ident->name;
n->print = exprNodeDotPrint;
n->resolve = exprNodeDotResolve;
return n;
}
bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
{
if(n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type;
if(tt == TYPE_struct ||
tt == TYPE_union) {
u32 loc = n->expression->location;
Type *t = n->expression->type;
int count = t->structure->memberCount;
int i = 0;
while(i < count) {
Member *m = &t->structure->members[i];
if(strcmp(m->name, n->name) == 0) {
// found member
n->type = m->type;
if(tt == TYPE_struct) {
n->location = elfDecodeLocation(f, m->location, &n->locType,
loc);
n->objLocation = loc;
} else {
n->location = loc;
n->locType = n->expression->locType;
n->objLocation = loc;
}
n->member = m;
return true;
}
i++;
}
printf("Member %s not found\n", n->name);
} else {
printf("Object is not of structure type\n");
}
}
return false;
}
void exprNodeDotPrint(Node *n)
{
n->expression->print(n->expression);
printf(".%s", n->name);
}
Node *exprNodeArrow(Node *exp, Node *ident)
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->name = ident->name;
n->print = exprNodeArrowPrint;
n->resolve = exprNodeArrowResolve;
return n;
}
bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
{
if(n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type;
if(tt != TYPE_pointer) {
printf("Object not of pointer type\n");
return false;
}
tt = n->expression->type->pointer->type;
if(tt == TYPE_struct ||
tt == TYPE_union) {
u32 loc = debuggerReadMemory(n->expression->location);
Type *t = n->expression->type->pointer;
int count = t->structure->memberCount;
int i = 0;
while(i < count) {
Member *m = &t->structure->members[i];
if(strcmp(m->name, n->name) == 0) {
// found member
n->type = m->type;
if(tt == TYPE_struct) {
n->location = elfDecodeLocation(f, m->location, &n->locType,
loc);
n->objLocation = loc;
} else {
n->location = loc;
n->objLocation = loc;
}
n->locType = LOCATION_memory;
n->member = m;
return true;
}
i++;
}
printf("Member %s not found\n", n->name);
} else {
printf("Object is not of structure type\n");
}
}
return false;
}
void exprNodeArrowPrint(Node *n)
{
n->expression->print(n->expression);
printf("->%s", n->name);
}
Node *exprNodeAddr(Node *exp)
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->print = exprNodeAddrPrint;
n->resolve = exprNodeAddrResolve;
return n;
}
bool exprNodeAddrResolve(Node *n, Function *f, CompileUnit *u)
{
if(n->expression->resolve(n->expression, f, u)) {
if(n->expression->locType == LOCATION_memory) {
n->location = n->expression->location;
n->locType = LOCATION_value;
n->type = &exprNodeType;
} else if(n->expression->locType == LOCATION_register) {
printf("Value is in register %d\n", n->expression->location);
} else {
printf("Direct value is %d\n", n->location);
}
return true;
}
return false;
}
void exprNodeAddrPrint(Node *n)
{
printf("*");
n->expression->print(n->expression);
}
Node *exprNodeSizeof(Node *exp)
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->print = exprNodeSizeofPrint;
n->resolve = exprNodeSizeofResolve;
return n;
}
bool exprNodeSizeofResolve(Node *n, Function *f, CompileUnit *u)
{
if(n->expression->resolve(n->expression, f, u)) {
n->location = n->expression->type->size;
n->locType = LOCATION_value;
exprNodeClean(n);
n->location = atoi(yytext);
n->type = &exprNodeType;
n->locType = LOCATION_value;
n->print = exprNodeNumberPrint;
n->resolve = exprNodeNumberResolve;
return n;
}
bool exprNodeNumberResolve(Node* n, Function* f, CompileUnit* u)
{
return true;
}
return false;
}
void exprNodeSizeofPrint(Node *n)
void exprNodeNumberPrint(Node* n)
{
printf("sizeof(");
n->expression->print(n->expression);
printf(")");
printf("%d", n->location);
}
Node *exprNodeArray(Node *exp, Node *number)
Node* exprNodeStar(Node* exp)
{
Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n);
Node* n = (Node*)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->value = number->location;
n->expression = exp;
n->print = exprNodeArrayPrint;
n->resolve = exprNodeArrayResolve;
return n;
n->print = exprNodeStarPrint;
n->resolve = exprNodeStarResolve;
return n;
}
int exprNodeGetSize(Array *a, int index)
bool exprNodeStarResolve(Node* n, Function* f, CompileUnit* u)
{
index++;
if(index == a->maxBounds) {
return a->type->size;
} else {
int size = a->bounds[a->maxBounds-1] * a->type->size;
for(int i = index; i < a->maxBounds-1; i++) {
size *= a->bounds[i];
}
return size;
}
}
bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
{
if(n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type;
if(tt != TYPE_array &&
tt != TYPE_pointer) {
printf("Object not of array or pointer type\n");
return false;
}
if(tt == TYPE_array) {
Array *a = n->expression->type->array;
u32 loc = n->expression->location;
Type *t = a->type;
if(a->maxBounds > 1) {
int index = n->expression->index;
if(index == a->maxBounds) {
printf("Too many indices for array\n");
return false;
if (n->expression->resolve(n->expression, f, u)) {
if (n->expression->type->type == TYPE_pointer) {
n->location = n->expression->location;
if (n->expression->locType == LOCATION_memory) {
n->location = debuggerReadMemory(n->location);
} else if (n->expression->locType == LOCATION_register) {
n->location = reg[n->expression->location].I;
} else {
n->location = n->expression->location;
}
n->type = n->expression->type->pointer;
n->locType = LOCATION_memory;
return true;
} else {
printf("Object is not of pointer type\n");
}
}
return false;
}
if((index+1) < a->maxBounds) {
n->type = n->expression->type;
n->index = index+1;
n->locType = LOCATION_memory;
n->location = n->expression->location +
n->value * exprNodeGetSize(a, index);
return true;
void exprNodeStarPrint(Node* n)
{
printf("*");
n->expression->print(n->expression);
}
Node* exprNodeDot(Node* exp, Node* ident)
{
Node* n = (Node*)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->name = ident->name;
n->print = exprNodeDotPrint;
n->resolve = exprNodeDotResolve;
return n;
}
bool exprNodeDotResolve(Node* n, Function* f, CompileUnit* u)
{
if (n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type;
if (tt == TYPE_struct || tt == TYPE_union) {
u32 loc = n->expression->location;
Type* t = n->expression->type;
int count = t->structure->memberCount;
int i = 0;
while (i < count) {
Member* m = &t->structure->members[i];
if (strcmp(m->name, n->name) == 0) {
// found member
n->type = m->type;
if (tt == TYPE_struct) {
n->location = elfDecodeLocation(f, m->location, &n->locType,
loc);
n->objLocation = loc;
} else {
n->location = loc;
n->locType = n->expression->locType;
n->objLocation = loc;
}
n->member = m;
return true;
}
i++;
}
printf("Member %s not found\n", n->name);
} else {
printf("Object is not of structure type\n");
}
}
n->type = t;
n->location = loc + n->value * t->size;
n->locType = LOCATION_memory;
}
return false;
}
void exprNodeDotPrint(Node* n)
{
n->expression->print(n->expression);
printf(".%s", n->name);
}
Node* exprNodeArrow(Node* exp, Node* ident)
{
Node* n = (Node*)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->name = ident->name;
n->print = exprNodeArrowPrint;
n->resolve = exprNodeArrowResolve;
return n;
}
bool exprNodeArrowResolve(Node* n, Function* f, CompileUnit* u)
{
if (n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type;
if (tt != TYPE_pointer) {
printf("Object not of pointer type\n");
return false;
}
tt = n->expression->type->pointer->type;
if (tt == TYPE_struct || tt == TYPE_union) {
u32 loc = debuggerReadMemory(n->expression->location);
Type* t = n->expression->type->pointer;
int count = t->structure->memberCount;
int i = 0;
while (i < count) {
Member* m = &t->structure->members[i];
if (strcmp(m->name, n->name) == 0) {
// found member
n->type = m->type;
if (tt == TYPE_struct) {
n->location = elfDecodeLocation(f, m->location, &n->locType,
loc);
n->objLocation = loc;
} else {
n->location = loc;
n->objLocation = loc;
}
n->locType = LOCATION_memory;
n->member = m;
return true;
}
i++;
}
printf("Member %s not found\n", n->name);
} else {
printf("Object is not of structure type\n");
}
}
return false;
}
void exprNodeArrowPrint(Node* n)
{
n->expression->print(n->expression);
printf("->%s", n->name);
}
Node* exprNodeAddr(Node* exp)
{
Node* n = (Node*)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->print = exprNodeAddrPrint;
n->resolve = exprNodeAddrResolve;
return n;
}
bool exprNodeAddrResolve(Node* n, Function* f, CompileUnit* u)
{
if (n->expression->resolve(n->expression, f, u)) {
if (n->expression->locType == LOCATION_memory) {
n->location = n->expression->location;
n->locType = LOCATION_value;
n->type = &exprNodeType;
} else if (n->expression->locType == LOCATION_register) {
printf("Value is in register %d\n", n->expression->location);
} else {
printf("Direct value is %d\n", n->location);
}
return true;
}
return false;
}
void exprNodeAddrPrint(Node* n)
{
printf("*");
n->expression->print(n->expression);
}
Node* exprNodeSizeof(Node* exp)
{
Node* n = (Node*)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->print = exprNodeSizeofPrint;
n->resolve = exprNodeSizeofResolve;
return n;
}
bool exprNodeSizeofResolve(Node* n, Function* f, CompileUnit* u)
{
if (n->expression->resolve(n->expression, f, u)) {
n->location = n->expression->type->size;
n->locType = LOCATION_value;
n->type = &exprNodeType;
return true;
}
return false;
}
void exprNodeSizeofPrint(Node* n)
{
printf("sizeof(");
n->expression->print(n->expression);
printf(")");
}
Node* exprNodeArray(Node* exp, Node* number)
{
Node* n = (Node*)calloc(1, sizeof(Node));
exprNodeClean(n);
n->expression = exp;
n->value = number->location;
n->print = exprNodeArrayPrint;
n->resolve = exprNodeArrayResolve;
return n;
}
int exprNodeGetSize(Array* a, int index)
{
index++;
if (index == a->maxBounds) {
return a->type->size;
} else {
Type *t = n->expression->type->pointer;
u32 loc = n->expression->location;
if(n->expression->locType == LOCATION_register)
loc = reg[loc].I;
else
loc = debuggerReadMemory(loc);
n->type = t;
n->location = loc + n->value * t->size;
n->locType = LOCATION_memory;
int size = a->bounds[a->maxBounds - 1] * a->type->size;
for (int i = index; i < a->maxBounds - 1; i++) {
size *= a->bounds[i];
}
return size;
}
return true;
}
return false;
}
void exprNodeArrayPrint(Node *n)
bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
{
n->expression->print(n->expression);
printf("[%d]", n->value);
if (n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type;
if (tt != TYPE_array && tt != TYPE_pointer) {
printf("Object not of array or pointer type\n");
return false;
}
if (tt == TYPE_array) {
Array* a = n->expression->type->array;
u32 loc = n->expression->location;
Type* t = a->type;
if (a->maxBounds > 1) {
int index = n->expression->index;
if (index == a->maxBounds) {
printf("Too many indices for array\n");
return false;
}
if ((index + 1) < a->maxBounds) {
n->type = n->expression->type;
n->index = index + 1;
n->locType = LOCATION_memory;
n->location = n->expression->location + n->value * exprNodeGetSize(a, index);
return true;
}
}
n->type = t;
n->location = loc + n->value * t->size;
n->locType = LOCATION_memory;
} else {
Type* t = n->expression->type->pointer;
u32 loc = n->expression->location;
if (n->expression->locType == LOCATION_register)
loc = reg[loc].I;
else
loc = debuggerReadMemory(loc);
n->type = t;
n->location = loc + n->value * t->size;
n->locType = LOCATION_memory;
}
return true;
}
return false;
}
void exprNodeArrayPrint(Node* n)
{
n->expression->print(n->expression);
printf("[%d]", n->value);
}

View File

@ -18,51 +18,51 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
struct Node {
Type *type;
u32 location;
u32 objLocation;
LocationType locType;
int value;
int index;
const char *name;
Node *expression;
Member *member;
void (*print)(Node *);
bool (*resolve)(Node *, Function *f, CompileUnit *u);
Type* type;
u32 location;
u32 objLocation;
LocationType locType;
int value;
int index;
const char* name;
Node* expression;
Member* member;
void (*print)(Node*);
bool (*resolve)(Node*, Function* f, CompileUnit* u);
};
extern void exprNodeCleanUp();
extern Node *exprNodeIdentifier();
extern void exprNodeIdentifierPrint(Node *);
extern bool exprNodeIdentifierResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeIdentifier();
extern void exprNodeIdentifierPrint(Node*);
extern bool exprNodeIdentifierResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeNumber();
extern void exprNodeNumberPrint(Node *);
extern bool exprNodeNumberResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeNumber();
extern void exprNodeNumberPrint(Node*);
extern bool exprNodeNumberResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeStar(Node *);
extern void exprNodeStarPrint(Node *);
extern bool exprNodeStarResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeStar(Node*);
extern void exprNodeStarPrint(Node*);
extern bool exprNodeStarResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeDot(Node *, Node *);
extern void exprNodeDotPrint(Node *);
extern bool exprNodeDotResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeDot(Node*, Node*);
extern void exprNodeDotPrint(Node*);
extern bool exprNodeDotResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeArrow(Node *, Node *);
extern void exprNodeArrowPrint(Node *);
extern bool exprNodeArrowResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeArrow(Node*, Node*);
extern void exprNodeArrowPrint(Node*);
extern bool exprNodeArrowResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeAddr(Node *);
extern void exprNodeAddrPrint(Node *);
extern bool exprNodeAddrResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeAddr(Node*);
extern void exprNodeAddrPrint(Node*);
extern bool exprNodeAddrResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeSizeof(Node *);
extern void exprNodeSizeofPrint(Node *);
extern bool exprNodeSizeofResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeSizeof(Node*);
extern void exprNodeSizeofPrint(Node*);
extern bool exprNodeSizeofResolve(Node*, Function*, CompileUnit*);
extern Node *exprNodeArray(Node *, Node *);
extern void exprNodeArrayPrint(Node *);
extern bool exprNodeArrayResolve(Node *, Function *, CompileUnit *);
extern Node* exprNodeArray(Node*, Node*);
extern void exprNodeArrayPrint(Node*);
extern bool exprNodeArrayResolve(Node*, Function*, CompileUnit*);
#define YYSTYPE struct Node *
#define YYSTYPE struct Node*

File diff suppressed because it is too large Load Diff

View File

@ -27,33 +27,33 @@
// List of available filters
enum Filter {
kStretch1x,
kStretch2x,
k2xSaI,
kSuper2xSaI,
kSuperEagle,
kPixelate,
kAdMame2x,
kBilinear,
kBilinearPlus,
kScanlines,
kScanlinesTV,
klq2x,
khq2x,
xbrz2x,
kStretch3x,
khq3x,
xbrz3x,
kStretch4x,
khq4x,
xbrz4x,
xbrz5x,
xbrz6x,
kInvalidFilter
kStretch1x,
kStretch2x,
k2xSaI,
kSuper2xSaI,
kSuperEagle,
kPixelate,
kAdMame2x,
kBilinear,
kBilinearPlus,
kScanlines,
kScanlinesTV,
klq2x,
khq2x,
xbrz2x,
kStretch3x,
khq3x,
xbrz3x,
kStretch4x,
khq4x,
xbrz4x,
xbrz5x,
xbrz6x,
kInvalidFilter
};
// Function pointer type for a filter function
typedef void (*FilterFunc)(u8 *, u32, u8 *, u8 *, u32, int, int);
typedef void (*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int);
// Initialize a filter and get the corresponding filter function pointer
FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth);
@ -62,22 +62,25 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth);
int getFilterEnlargeFactor(const int f);
// Get the display name for a filter
char *getFilterName(const int f);
char* getFilterName(const int f);
//
// Interframe 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
typedef void (*IFBFilterFunc)(u8 *, u32, int, int);
typedef void (*IFBFilterFunc)(u8*, u32, int, int);
// Initialize an IFB filter and get the corresponding filter function pointer
IFBFilterFunc initIFBFilter(const int f, const int colorDepth);
// Get the display name for an IFB filter
char *getIFBFilterName(const IFBFilter f);
char* getIFBFilterName(const IFBFilter f);
#endif // VBA_SDL_FILTERS_H

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ extern "C" {
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
extern char* optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
@ -81,15 +81,15 @@ extern int optopt;
struct option {
#if defined(__STDC__) && __STDC__
const char *name;
const char* name;
#else
char *name;
char* name;
#endif
/* has_arg can't be an enum because some compilers complain about
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
int has_arg;
int* flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
@ -108,21 +108,21 @@ struct option {
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt(int argc, char *const *argv, const char *shortopts);
extern int getopt(int argc, char* const* argv, const char* shortopts);
#else /* not __GNU_LIBRARY__ */
#if !defined(HAVE_DECL_GETOPT)
extern int getopt();
#endif
#endif /* __GNU_LIBRARY__ */
extern int getopt_long(int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only(int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long(int argc, char* const* argv, const char* shortopts,
const struct option* longopts, int* longind);
extern int getopt_long_only(int argc, char* const* argv, const char* shortopts,
const struct option* longopts, int* longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal(int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind, int long_only);
#else /* not __STDC__ */
extern int _getopt_internal(int argc, char* const* argv, const char* shortopts,
const struct option* longopts, int* longind, int long_only);
#else /* not __STDC__ */
extern int getopt();
extern int getopt_long();
extern int getopt_long_only();

View File

@ -65,12 +65,12 @@
#endif
int getopt_long(argc, argv, options, long_options, opt_index) int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
char* const* argv;
const char* options;
const struct option* long_options;
int* opt_index;
{
return _getopt_internal(argc, argv, options, long_options, opt_index, 0);
return _getopt_internal(argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
@ -79,12 +79,12 @@ int *opt_index;
instead. */
int getopt_long_only(argc, argv, options, long_options, opt_index) int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
char* const* argv;
const char* options;
const struct option* long_options;
int* opt_index;
{
return _getopt_internal(argc, argv, options, long_options, opt_index, 1);
return _getopt_internal(argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
@ -94,82 +94,82 @@ int *opt_index;
#include <stdio.h>
int main(argc, argv) int argc;
char **argv;
char** argv;
{
int c;
int digit_optind = 0;
int c;
int digit_optind = 0;
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = { { "add", 1, 0, 0 },
{ "append", 0, 0, 0 },
{ "delete", 1, 0, 0 },
{ "verbose", 0, 0, 0 },
{ "create", 0, 0, 0 },
{ "file", 1, 0, 0 },
{ 0, 0, 0, 0 } };
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = { { "add", 1, 0, 0 },
{ "append", 0, 0, 0 },
{ "delete", 1, 0, 0 },
{ "verbose", 0, 0, 0 },
{ "create", 0, 0, 0 },
{ "file", 1, 0, 0 },
{ 0, 0, 0, 0 } };
c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index);
if (c == -1)
break;
c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
printf("option %s", long_options[option_index].name);
if (optarg)
printf(" with arg %s", optarg);
printf("\n");
break;
switch (c) {
case 0:
printf("option %s", long_options[option_index].name);
if (optarg)
printf(" with arg %s", optarg);
printf("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf("option %c\n", c);
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf("option %c\n", c);
break;
case 'a':
printf("option a\n");
break;
case 'a':
printf("option a\n");
break;
case 'b':
printf("option b\n");
break;
case 'b':
printf("option b\n");
break;
case 'c':
printf("option c with value `%s'\n", optarg);
break;
case 'c':
printf("option c with value `%s'\n", optarg);
break;
case 'd':
printf("option d with value `%s'\n", optarg);
break;
case 'd':
printf("option d with value `%s'\n", optarg);
break;
case '?':
break;
case '?':
break;
default:
printf("?? getopt returned character code 0%o ??\n", c);
}
default:
printf("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc) {
printf("non-option ARGV-elements: ");
while (optind < argc)
printf("%s ", argv[optind++]);
printf("\n");
}
if (optind < argc) {
printf("non-option ARGV-elements: ");
while (optind < argc)
printf("%s ", argv[optind++]);
printf("\n");
}
exit(0);
exit(0);
}
#endif /* TEST */

View File

@ -27,128 +27,108 @@ static void sdlUpdateJoyAxis(int which, int axis, int value);
static bool sdlCheckJoyKey(int key);
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 int sdlNumDevices = 0;
static SDL_Joystick **sdlDevices = NULL;
static SDL_Joystick** sdlDevices = NULL;
static EPad sdlDefaultJoypad = PAD_MAIN;
static int autoFireCountdown = 0;
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 },
{ SDLK_LEFT, SDLK_RIGHT,
SDLK_UP, SDLK_DOWN,
SDLK_z, SDLK_x,
SDLK_RETURN,SDLK_BACKSPACE,
SDLK_a, SDLK_s,
SDLK_SPACE, SDLK_F12,
SDLK_q, SDLK_w,
}
{ 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_UP, SDLK_DOWN,
SDLK_z, SDLK_x,
SDLK_RETURN, SDLK_BACKSPACE,
SDLK_a, SDLK_s,
SDLK_SPACE, SDLK_F12,
SDLK_q, SDLK_w,
}
};
static uint32_t motion[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 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 (
((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
)
);
((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));
}
static uint32_t sdlGetButtonCode(const SDL_Event &event)
static uint32_t sdlGetButtonCode(const SDL_Event& event)
{
return (
((event.jbutton.which + 1) << 16) |
(event.jbutton.button + 0x80)
);
((event.jbutton.which + 1) << 16) | (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 (
((event.jaxis.which + 1) << 16) |
(event.jaxis.axis << 1) |
(
event.jaxis.value > 16384 ? 1 :
event.jaxis.value < -16384 ? 0 : 0
)
);
((event.jaxis.which + 1) << 16) | (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)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
return event.key.keysym.sym;
break;
case SDL_JOYHATMOTION:
return sdlGetHatCode(event);
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
return sdlGetButtonCode(event);
break;
case SDL_JOYAXISMOTION:
return sdlGetAxisCode(event);
break;
default:
return 0;
break;
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
return event.key.keysym.sym;
break;
case SDL_JOYHATMOTION:
return sdlGetHatCode(event);
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
return sdlGetButtonCode(event);
break;
case SDL_JOYAXISMOTION:
return sdlGetAxisCode(event);
break;
default:
return 0;
break;
}
}
uint32_t inputGetKeymap(EPad pad, EKey key)
{
return joypad[pad][key];
return joypad[pad][key];
}
void inputSetKeymap(EPad pad, EKey key, uint32_t code)
{
joypad[pad][key] = code;
joypad[pad][key] = code;
}
void inputSetMotionKeymap(EKey key, uint32_t code)
@ -160,22 +140,21 @@ bool inputGetAutoFire(EKey key)
{
int mask = 0;
switch (key)
{
case KEY_BUTTON_A:
mask = 1 << 0;
break;
case KEY_BUTTON_B:
mask = 1 << 1;
break;
case KEY_BUTTON_R:
mask = 1 << 8;
break;
case KEY_BUTTON_L:
mask = 1 << 9;
break;
default:
break;
switch (key) {
case KEY_BUTTON_A:
mask = 1 << 0;
break;
case KEY_BUTTON_B:
mask = 1 << 1;
break;
case KEY_BUTTON_R:
mask = 1 << 8;
break;
case KEY_BUTTON_L:
mask = 1 << 9;
break;
default:
break;
}
return !(autoFire & mask);
@ -185,31 +164,27 @@ bool inputToggleAutoFire(EKey key)
{
int mask = 0;
switch (key)
{
case KEY_BUTTON_A:
mask = 1 << 0;
break;
case KEY_BUTTON_B:
mask = 1 << 1;
break;
case KEY_BUTTON_R:
mask = 1 << 8;
break;
case KEY_BUTTON_L:
mask = 1 << 9;
break;
default:
break;
switch (key) {
case KEY_BUTTON_A:
mask = 1 << 0;
break;
case KEY_BUTTON_B:
mask = 1 << 1;
break;
case KEY_BUTTON_R:
mask = 1 << 8;
break;
case KEY_BUTTON_L:
mask = 1 << 9;
break;
default:
break;
}
if(autoFire & mask)
{
if (autoFire & mask) {
autoFire &= ~mask;
return false;
}
else
{
} else {
autoFire |= mask;
return true;
}
@ -217,402 +192,401 @@ bool inputToggleAutoFire(EKey key)
static void sdlUpdateKey(uint32_t key, bool down)
{
int i;
for(int j = 0; j < 4; j++) {
for(i = 0 ; i < SDLBUTTONS_NUM; i++) {
//if((joypad[j][i] & 0xffff0000) == 0) {
if(key == joypad[j][i])
sdlButtons[j][i] = down;
//}
int i;
for (int j = 0; j < 4; j++) {
for (i = 0; i < SDLBUTTONS_NUM; i++) {
//if((joypad[j][i] & 0xffff0000) == 0) {
if (key == joypad[j][i])
sdlButtons[j][i] = down;
//}
}
}
for (i = 0; i < 4; i++) {
//if((motion[i] & 0xffff0000) == 0) {
if (key == motion[i])
sdlMotionButtons[i] = down;
//}
}
}
for(i = 0 ; i < 4; i++) {
//if((motion[i] & 0xffff0000) == 0) {
if(key == motion[i])
sdlMotionButtons[i] = down;
//}
}
}
static void sdlUpdateJoyButton(int which,
int button,
bool pressed)
int button,
bool pressed)
{
int i;
for(int j = 0; j < 4; j++) {
for(i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = (joypad[j][i] >> 16);
int b = joypad[j][i] & 0xffff;
if(dev) {
dev--;
int i;
for (int j = 0; j < 4; j++) {
for (i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = (joypad[j][i] >> 16);
int b = joypad[j][i] & 0xffff;
if (dev) {
dev--;
if((dev == which) && (b >= 128) && (b == (button+128))) {
sdlButtons[j][i] = pressed;
if ((dev == which) && (b >= 128) && (b == (button + 128))) {
sdlButtons[j][i] = pressed;
}
}
}
}
}
}
for(i = 0; i < 4; i++) {
int dev = (motion[i] >> 16);
int b = motion[i] & 0xffff;
if(dev) {
dev--;
for (i = 0; i < 4; i++) {
int dev = (motion[i] >> 16);
int b = motion[i] & 0xffff;
if (dev) {
dev--;
if((dev == which) && (b >= 128) && (b == (button+128))) {
sdlMotionButtons[i] = pressed;
}
if ((dev == which) && (b >= 128) && (b == (button + 128))) {
sdlMotionButtons[i] = pressed;
}
}
}
}
}
static void sdlUpdateJoyHat(int which,
int hat,
int value)
int hat,
int value)
{
int i;
for(int j = 0; j < 4; j++) {
for(i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = (joypad[j][i] >> 16);
int a = joypad[j][i] & 0xffff;
if(dev) {
dev--;
int i;
for (int j = 0; j < 4; j++) {
for (i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = (joypad[j][i] >> 16);
int a = joypad[j][i] & 0xffff;
if (dev) {
dev--;
if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
int dir = a & 3;
int v = 0;
switch(dir) {
case 0:
v = value & SDL_HAT_UP;
break;
case 1:
v = value & SDL_HAT_DOWN;
break;
case 2:
v = value & SDL_HAT_RIGHT;
break;
case 3:
v = value & SDL_HAT_LEFT;
break;
}
sdlButtons[j][i] = (v ? true : false);
if ((dev == which) && (a >= 32) && (a < 48) && (((a & 15) >> 2) == hat)) {
int dir = a & 3;
int v = 0;
switch (dir) {
case 0:
v = value & SDL_HAT_UP;
break;
case 1:
v = value & SDL_HAT_DOWN;
break;
case 2:
v = value & SDL_HAT_RIGHT;
break;
case 3:
v = value & SDL_HAT_LEFT;
break;
}
sdlButtons[j][i] = (v ? true : false);
}
}
}
}
}
}
for(i = 0; i < 4; i++) {
int dev = (motion[i] >> 16);
int a = motion[i] & 0xffff;
if(dev) {
dev--;
for (i = 0; i < 4; i++) {
int dev = (motion[i] >> 16);
int a = motion[i] & 0xffff;
if (dev) {
dev--;
if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
int dir = a & 3;
int v = 0;
switch(dir) {
case 0:
v = value & SDL_HAT_UP;
break;
case 1:
v = value & SDL_HAT_DOWN;
break;
case 2:
v = value & SDL_HAT_RIGHT;
break;
case 3:
v = value & SDL_HAT_LEFT;
break;
if ((dev == which) && (a >= 32) && (a < 48) && (((a & 15) >> 2) == hat)) {
int dir = a & 3;
int v = 0;
switch (dir) {
case 0:
v = value & SDL_HAT_UP;
break;
case 1:
v = value & SDL_HAT_DOWN;
break;
case 2:
v = value & SDL_HAT_RIGHT;
break;
case 3:
v = value & SDL_HAT_LEFT;
break;
}
sdlMotionButtons[i] = (v ? true : false);
}
}
sdlMotionButtons[i] = (v ? true : false);
}
}
}
}
static void sdlUpdateJoyAxis(int which,
int axis,
int value)
int axis,
int value)
{
int i;
for(int j = 0; j < 4; j++) {
for(i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = (joypad[j][i] >> 16);
int a = joypad[j][i] & 0xffff;
if(dev) {
dev--;
int i;
for (int j = 0; j < 4; j++) {
for (i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = (joypad[j][i] >> 16);
int a = joypad[j][i] & 0xffff;
if (dev) {
dev--;
if((dev == which) && (a < 32) && ((a>>1) == axis)) {
sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384);
if ((dev == which) && (a < 32) && ((a >> 1) == axis)) {
sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384);
}
}
}
}
}
}
for(i = 0; i < 4; i++) {
int dev = (motion[i] >> 16);
int a = motion[i] & 0xffff;
if(dev) {
dev--;
for (i = 0; i < 4; i++) {
int dev = (motion[i] >> 16);
int a = motion[i] & 0xffff;
if (dev) {
dev--;
if((dev == which) && (a < 32) && ((a>>1) == axis)) {
sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
}
if ((dev == which) && (a < 32) && ((a >> 1) == axis)) {
sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
}
}
}
}
}
static bool sdlCheckJoyKey(int key)
{
int dev = (key >> 16) - 1;
int what = key & 0xffff;
int dev = (key >> 16) - 1;
int what = key & 0xffff;
if(what >= 128) {
// joystick button
int button = what - 128;
if (what >= 128) {
// joystick button
int button = what - 128;
if(button >= SDL_JoystickNumButtons(sdlDevices[dev]))
return false;
} else if (what < 0x20) {
// joystick axis
what >>= 1;
if(what >= SDL_JoystickNumAxes(sdlDevices[dev]))
return false;
} else if (what < 0x30) {
// joystick hat
what = (what & 15);
what >>= 2;
if(what >= SDL_JoystickNumHats(sdlDevices[dev]))
return false;
}
if (button >= SDL_JoystickNumButtons(sdlDevices[dev]))
return false;
} else if (what < 0x20) {
// joystick axis
what >>= 1;
if (what >= SDL_JoystickNumAxes(sdlDevices[dev]))
return false;
} else if (what < 0x30) {
// joystick hat
what = (what & 15);
what >>= 2;
if (what >= SDL_JoystickNumHats(sdlDevices[dev]))
return false;
}
// no problem found
return true;
// no problem found
return true;
}
void inputInitJoysticks()
{
// The main joypad has to be entirely defined
for(int i = 0; i < SDLBUTTONS_NUM; i++) {
if (!joypad[PAD_MAIN][i])
joypad[PAD_MAIN][i] = joypad[PAD_DEFAULT][i];
}
// The main joypad has to be entirely defined
for (int i = 0; i < SDLBUTTONS_NUM; i++) {
if (!joypad[PAD_MAIN][i])
joypad[PAD_MAIN][i] = joypad[PAD_DEFAULT][i];
}
sdlNumDevices = SDL_NumJoysticks();
sdlNumDevices = SDL_NumJoysticks();
if(sdlNumDevices)
sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices *
sizeof(SDL_Joystick **));
bool usesJoy = false;
if (sdlNumDevices)
sdlDevices = (SDL_Joystick**)calloc(1, sdlNumDevices * sizeof(SDL_Joystick**));
bool usesJoy = false;
for(int j = 0; j < 4; j++) {
for(int i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = joypad[j][i] >> 16;
if(dev) {
dev--;
bool ok = false;
for (int j = 0; j < 4; j++) {
for (int i = 0; i < SDLBUTTONS_NUM; i++) {
int dev = joypad[j][i] >> 16;
if (dev) {
dev--;
bool ok = false;
if(sdlDevices) {
if(dev < sdlNumDevices) {
if(sdlDevices[dev] == NULL) {
sdlDevices[dev] = SDL_JoystickOpen(dev);
if (sdlDevices) {
if (dev < sdlNumDevices) {
if (sdlDevices[dev] == NULL) {
sdlDevices[dev] = SDL_JoystickOpen(dev);
}
ok = sdlCheckJoyKey(joypad[j][i]);
} else
ok = false;
}
if (!ok)
joypad[j][i] = joypad[PAD_DEFAULT][i];
else
usesJoy = true;
}
}
}
for (int i = 0; i < 4; i++) {
int dev = motion[i] >> 16;
if (dev) {
dev--;
bool ok = false;
if (sdlDevices) {
if (dev < sdlNumDevices) {
if (sdlDevices[dev] == NULL) {
sdlDevices[dev] = SDL_JoystickOpen(dev);
}
ok = sdlCheckJoyKey(motion[i]);
} else
ok = false;
}
ok = sdlCheckJoyKey(joypad[j][i]);
} else
ok = false;
if (!ok)
motion[i] = defaultMotion[i];
else
usesJoy = true;
}
if(!ok)
joypad[j][i] = joypad[PAD_DEFAULT][i];
else
usesJoy = true;
}
}
}
for(int i = 0; i < 4; i++) {
int dev = motion[i] >> 16;
if(dev) {
dev--;
bool ok = false;
if(sdlDevices) {
if(dev < sdlNumDevices) {
if(sdlDevices[dev] == NULL) {
sdlDevices[dev] = SDL_JoystickOpen(dev);
}
ok = sdlCheckJoyKey(motion[i]);
} else
ok = false;
}
if(!ok)
motion[i] = defaultMotion[i];
else
usesJoy = true;
}
}
if(usesJoy)
SDL_JoystickEventState(SDL_ENABLE);
if (usesJoy)
SDL_JoystickEventState(SDL_ENABLE);
}
void inputProcessSDLEvent(const SDL_Event &event)
void inputProcessSDLEvent(const SDL_Event& event)
{
// fprintf(stdout, "%x\n", inputGetEventCode(event));
// fprintf(stdout, "%x\n", inputGetEventCode(event));
switch(event.type)
{
case SDL_KEYDOWN:
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, true);
break;
case SDL_KEYUP:
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, false);
break;
case SDL_JOYHATMOTION:
sdlUpdateJoyHat(event.jhat.which,
event.jhat.hat,
event.jhat.value);
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
sdlUpdateJoyButton(event.jbutton.which,
event.jbutton.button,
event.jbutton.state == SDL_PRESSED);
break;
case SDL_JOYAXISMOTION:
sdlUpdateJoyAxis(event.jaxis.which,
event.jaxis.axis,
event.jaxis.value);
break;
switch (event.type) {
case SDL_KEYDOWN:
if (!event.key.keysym.mod)
sdlUpdateKey(event.key.keysym.sym, true);
break;
case SDL_KEYUP:
if (!event.key.keysym.mod)
sdlUpdateKey(event.key.keysym.sym, false);
break;
case SDL_JOYHATMOTION:
sdlUpdateJoyHat(event.jhat.which,
event.jhat.hat,
event.jhat.value);
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
sdlUpdateJoyButton(event.jbutton.which,
event.jbutton.button,
event.jbutton.state == SDL_PRESSED);
break;
case SDL_JOYAXISMOTION:
sdlUpdateJoyAxis(event.jaxis.which,
event.jaxis.axis,
event.jaxis.value);
break;
}
}
uint32_t inputReadJoypad(int which)
{
int realAutoFire = autoFire;
int realAutoFire = autoFire;
if(which < 0 || which > 3)
which = sdlDefaultJoypad;
if (which < 0 || which > 3)
which = sdlDefaultJoypad;
uint32_t res = 0;
uint32_t res = 0;
if(sdlButtons[which][KEY_BUTTON_A])
res |= 1;
if(sdlButtons[which][KEY_BUTTON_B])
res |= 2;
if(sdlButtons[which][KEY_BUTTON_SELECT])
res |= 4;
if(sdlButtons[which][KEY_BUTTON_START])
res |= 8;
if(sdlButtons[which][KEY_RIGHT])
res |= 16;
if(sdlButtons[which][KEY_LEFT])
res |= 32;
if(sdlButtons[which][KEY_UP])
res |= 64;
if(sdlButtons[which][KEY_DOWN])
res |= 128;
if(sdlButtons[which][KEY_BUTTON_R])
res |= 256;
if(sdlButtons[which][KEY_BUTTON_L])
res |= 512;
if(sdlButtons[which][KEY_BUTTON_AUTO_A])
realAutoFire ^= 1;
if(sdlButtons[which][KEY_BUTTON_AUTO_B])
realAutoFire ^= 2;
if (sdlButtons[which][KEY_BUTTON_A])
res |= 1;
if (sdlButtons[which][KEY_BUTTON_B])
res |= 2;
if (sdlButtons[which][KEY_BUTTON_SELECT])
res |= 4;
if (sdlButtons[which][KEY_BUTTON_START])
res |= 8;
if (sdlButtons[which][KEY_RIGHT])
res |= 16;
if (sdlButtons[which][KEY_LEFT])
res |= 32;
if (sdlButtons[which][KEY_UP])
res |= 64;
if (sdlButtons[which][KEY_DOWN])
res |= 128;
if (sdlButtons[which][KEY_BUTTON_R])
res |= 256;
if (sdlButtons[which][KEY_BUTTON_L])
res |= 512;
if (sdlButtons[which][KEY_BUTTON_AUTO_A])
realAutoFire ^= 1;
if (sdlButtons[which][KEY_BUTTON_AUTO_B])
realAutoFire ^= 2;
// disallow L+R or U+D of being pressed at the same time
if((res & 48) == 48)
res &= ~16;
if((res & 192) == 192)
res &= ~128;
// disallow L+R or U+D of being pressed at the same time
if ((res & 48) == 48)
res &= ~16;
if ((res & 192) == 192)
res &= ~128;
if(sdlButtons[which][KEY_BUTTON_SPEED])
res |= 1024;
if(sdlButtons[which][KEY_BUTTON_CAPTURE])
res |= 2048;
if (sdlButtons[which][KEY_BUTTON_SPEED])
res |= 1024;
if (sdlButtons[which][KEY_BUTTON_CAPTURE])
res |= 2048;
if(realAutoFire) {
res &= (~realAutoFire);
if(autoFireToggle)
res |= realAutoFire;
autoFireCountdown--; // this needs decrementing even when autoFireToggle is toggled,
// so that autoFireMaxCount==1 (the default) will alternate at the maximum possible
// frequency (every time this code is reached). Which is what it did before
// introducing autoFireCountdown.
if (autoFireCountdown <= 0) {
autoFireToggle = !autoFireToggle;
autoFireCountdown = autoFireMaxCount;
if (realAutoFire) {
res &= (~realAutoFire);
if (autoFireToggle)
res |= realAutoFire;
autoFireCountdown--; // this needs decrementing even when autoFireToggle is toggled,
// so that autoFireMaxCount==1 (the default) will alternate at the maximum possible
// frequency (every time this code is reached). Which is what it did before
// introducing autoFireCountdown.
if (autoFireCountdown <= 0) {
autoFireToggle = !autoFireToggle;
autoFireCountdown = autoFireMaxCount;
}
}
}
return res;
return res;
}
void inputUpdateMotionSensor()
{
if(sdlMotionButtons[KEY_LEFT]) {
sensorX += 3;
if(sensorX > 2197)
sensorX = 2197;
if(sensorX < 2047)
sensorX = 2057;
} else if(sdlMotionButtons[KEY_RIGHT]) {
sensorX -= 3;
if(sensorX < 1897)
sensorX = 1897;
if(sensorX > 2047)
sensorX = 2037;
} else if(sensorX > 2047) {
sensorX -= 2;
if(sensorX < 2047)
sensorX = 2047;
} else {
sensorX += 2;
if(sensorX > 2047)
sensorX = 2047;
}
if (sdlMotionButtons[KEY_LEFT]) {
sensorX += 3;
if (sensorX > 2197)
sensorX = 2197;
if (sensorX < 2047)
sensorX = 2057;
} else if (sdlMotionButtons[KEY_RIGHT]) {
sensorX -= 3;
if (sensorX < 1897)
sensorX = 1897;
if (sensorX > 2047)
sensorX = 2037;
} else if (sensorX > 2047) {
sensorX -= 2;
if (sensorX < 2047)
sensorX = 2047;
} else {
sensorX += 2;
if (sensorX > 2047)
sensorX = 2047;
}
if(sdlMotionButtons[KEY_UP]) {
sensorY += 3;
if(sensorY > 2197)
sensorY = 2197;
if(sensorY < 2047)
sensorY = 2057;
} else if(sdlMotionButtons[KEY_DOWN]) {
sensorY -= 3;
if(sensorY < 1897)
sensorY = 1897;
if(sensorY > 2047)
sensorY = 2037;
} else if(sensorY > 2047) {
sensorY -= 2;
if(sensorY < 2047)
sensorY = 2047;
} else {
sensorY += 2;
if(sensorY > 2047)
sensorY = 2047;
}
if (sdlMotionButtons[KEY_UP]) {
sensorY += 3;
if (sensorY > 2197)
sensorY = 2197;
if (sensorY < 2047)
sensorY = 2057;
} else if (sdlMotionButtons[KEY_DOWN]) {
sensorY -= 3;
if (sensorY < 1897)
sensorY = 1897;
if (sensorY > 2047)
sensorY = 2037;
} else if (sensorY > 2047) {
sensorY -= 2;
if (sensorY < 2047)
sensorY = 2047;
} else {
sensorY += 2;
if (sensorY > 2047)
sensorY = 2047;
}
}
int inputGetSensorX()
{
return sensorX;
return sensorX;
}
int inputGetSensorY()
{
return sensorY;
return sensorY;
}
void inputSetDefaultJoypad(EPad pad)
{
sdlDefaultJoypad = pad;
sdlDefaultJoypad = pad;
}
EPad inputGetDefaultJoypad()
{
return sdlDefaultJoypad;
return sdlDefaultJoypad;
}

View File

@ -21,23 +21,28 @@
#include <SDL.h>
enum EKey {
KEY_LEFT,
KEY_RIGHT,
KEY_UP,
KEY_DOWN,
KEY_BUTTON_A,
KEY_BUTTON_B,
KEY_BUTTON_START,
KEY_BUTTON_SELECT,
KEY_BUTTON_L,
KEY_BUTTON_R,
KEY_BUTTON_SPEED,
KEY_BUTTON_CAPTURE,
KEY_BUTTON_AUTO_A,
KEY_BUTTON_AUTO_B
KEY_LEFT,
KEY_RIGHT,
KEY_UP,
KEY_DOWN,
KEY_BUTTON_A,
KEY_BUTTON_B,
KEY_BUTTON_START,
KEY_BUTTON_SELECT,
KEY_BUTTON_L,
KEY_BUTTON_R,
KEY_BUTTON_SPEED,
KEY_BUTTON_CAPTURE,
KEY_BUTTON_AUTO_A,
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
@ -86,14 +91,14 @@ bool inputGetAutoFire(EKey key);
* Update the emulated pads state with a SDL event
* @param SDL_Event An event that has just occured
*/
void inputProcessSDLEvent(const SDL_Event &event);
void inputProcessSDLEvent(const SDL_Event& event);
/**
* Get the keymap code corresponding to a SDL event
* @param SDL_Event An event that has just occured
* @return Keymap code
*/
uint32_t inputGetEventCode(const SDL_Event &event);
uint32_t inputGetEventCode(const SDL_Event& event);
/**
* Read the state of an emulated joypad

View File

@ -25,124 +25,116 @@
extern int RGB_LOW_BITS_MASK;
static const u8 fontdata2[2048] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e,0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e,0x36,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x1c,0x3e,0x1c,0x7f,0x7f,0x3e,0x1c,0x3e,0x08,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x3e,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xf0,0xe0,0xf0,0xbe,0x33,0x33,0x33,0x1e,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0xfc,0xcc,0xfc,0x0c,0x0c,0x0e,0x0f,0x07,0xfe,0xc6,0xfe,0xc6,0xc6,0xe6,0x67,0x03,0x99,0x5a,0x3c,0xe7,0xe7,0x3c,0x5a,0x99,0x01,0x07,0x1f,0x7f,0x1f,0x07,0x01,0x00,0x40,0x70,0x7c,0x7f,0x7c,0x70,0x40,0x00,0x18,0x3c,0x7e,0x18,0x18,0x7e,0x3c,0x18,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,0xfe,0xdb,0xdb,0xde,0xd8,0xd8,0xd8,0x00,0x7c,0xc6,0x1c,0x36,0x36,0x1c,0x33,0x1e,0x00,0x00,0x00,0x00,0x7e,0x7e,0x7e,0x00,0x18,0x3c,0x7e,0x18,0x7e,0x3c,0x18,0xff,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x18,0x30,0x7f,0x30,0x18,0x00,0x00,0x00,0x0c,0x06,0x7f,0x06,0x0c,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0x7e,0x3c,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x1e,0x1e,0x0c,0x0c,0x00,0x0c,0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7f,0x36,0x7f,0x36,0x36,0x00,0x0c,0x3e,0x03,0x1e,0x30,0x1f,0x0c,0x00,0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00,0x1c,0x36,0x1c,0x6e,0x3b,0x33,0x6e,0x00,0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0x06,0x06,0x06,0x0c,0x18,0x00,0x06,0x0c,0x18,0x18,0x18,0x0c,0x06,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x06,0x00,0x00,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00,0x3e,0x63,0x73,0x7b,0x6f,0x67,0x3e,0x00,0x0c,0x0e,0x0c,0x0c,0x0c,0x0c,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x06,0x33,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x30,0x33,0x1e,0x00,0x38,0x3c,0x36,0x33,0x7f,0x30,0x78,0x00,0x3f,0x03,0x1f,0x30,0x30,0x33,0x1e,0x00,0x1c,0x06,0x03,0x1f,0x33,0x33,0x1e,0x00,0x3f,0x33,0x30,0x18,0x0c,0x0c,0x0c,0x00,0x1e,0x33,0x33,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x33,0x3e,0x30,0x18,0x0e,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x06,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x00,0x00,0x00,0x3f,0x00,0x00,0x3f,0x00,0x00,0x06,0x0c,0x18,0x30,0x18,0x0c,0x06,0x00,0x1e,0x33,0x30,0x18,0x0c,0x00,0x0c,0x00,
0x3e,0x63,0x7b,0x7b,0x7b,0x03,0x1e,0x00,0x0c,0x1e,0x33,0x33,0x3f,0x33,0x33,0x00,0x3f,0x66,0x66,0x3e,0x66,0x66,0x3f,0x00,0x3c,0x66,0x03,0x03,0x03,0x66,0x3c,0x00,0x1f,0x36,0x66,0x66,0x66,0x36,0x1f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x46,0x7f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x06,0x0f,0x00,0x3c,0x66,0x03,0x03,0x73,0x66,0x7c,0x00,0x33,0x33,0x33,0x3f,0x33,0x33,0x33,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x78,0x30,0x30,0x30,0x33,0x33,0x1e,0x00,0x67,0x66,0x36,0x1e,0x36,0x66,0x67,0x00,0x0f,0x06,0x06,0x06,0x46,0x66,0x7f,0x00,0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x00,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x00,0x1c,0x36,0x63,0x63,0x63,0x36,0x1c,0x00,0x3f,0x66,0x66,0x3e,0x06,0x06,0x0f,0x00,0x1e,0x33,0x33,0x33,0x3b,0x1e,0x38,0x00,0x3f,0x66,0x66,0x3e,0x36,0x66,0x67,0x00,0x1e,0x33,0x07,0x0e,0x38,0x33,0x1e,0x00,0x3f,0x2d,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x00,0x33,0x33,0x33,0x33,0x33,0x1e,0x0c,0x00,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00,0x33,0x33,0x33,0x1e,0x0c,0x0c,0x1e,0x00,0x7f,0x63,0x31,0x18,0x4c,0x66,0x7f,0x00,0x1e,0x06,0x06,0x06,0x06,0x06,0x1e,0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00,0x1e,0x18,0x18,0x18,0x18,0x18,0x1e,0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0x0c,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x30,0x3e,0x33,0x6e,0x00,0x07,0x06,0x06,0x3e,0x66,0x66,0x3b,0x00,0x00,0x00,0x1e,0x33,0x03,0x33,0x1e,0x00,0x38,0x30,0x30,0x3e,0x33,0x33,0x6e,0x00,0x00,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x1c,0x36,0x06,0x0f,0x06,0x06,0x0f,0x00,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x1f,0x07,0x06,0x36,0x6e,0x66,0x66,0x67,0x00,0x0c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x30,0x00,0x30,0x30,0x30,0x33,0x33,0x1e,0x07,0x06,0x66,0x36,0x1e,0x36,0x67,0x00,0x0e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x33,0x7f,0x7f,0x6b,0x63,0x00,0x00,0x00,0x1f,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x1e,0x33,0x33,0x33,0x1e,0x00,0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x0f,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x78,0x00,0x00,0x3b,0x6e,0x66,0x06,0x0f,0x00,0x00,0x00,0x3e,0x03,0x1e,0x30,0x1f,0x00,0x08,0x0c,0x3e,0x0c,0x0c,0x2c,0x18,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x6e,0x00,0x00,0x00,0x33,0x33,0x33,0x1e,0x0c,0x00,0x00,0x00,0x63,0x6b,0x7f,0x7f,0x36,0x00,0x00,0x00,0x63,0x36,0x1c,0x36,0x63,0x00,0x00,0x00,0x33,0x33,0x33,0x3e,0x30,0x1f,0x00,0x00,0x3f,0x19,0x0c,0x26,0x3f,0x00,0x38,0x0c,0x0c,0x07,0x0c,0x0c,0x38,0x00,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x07,0x0c,0x0c,0x38,0x0c,0x0c,0x07,0x00,0x6e,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00,
0x1e,0x33,0x03,0x33,0x1e,0x18,0x30,0x1e,0x00,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x38,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x7e,0xc3,0x3c,0x60,0x7c,0x66,0xfc,0x00,0x33,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x07,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x0c,0x0c,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x00,0x00,0x1e,0x03,0x03,0x1e,0x30,0x1c,0x7e,0xc3,0x3c,0x66,0x7e,0x06,0x3c,0x00,0x33,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x07,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x33,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x3e,0x63,0x1c,0x18,0x18,0x18,0x3c,0x00,0x07,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x63,0x1c,0x36,0x63,0x7f,0x63,0x63,0x00,0x0c,0x0c,0x00,0x1e,0x33,0x3f,0x33,0x00,0x38,0x00,0x3f,0x06,0x1e,0x06,0x3f,0x00,0x00,0x00,0xfe,0x30,0xfe,0x33,0xfe,0x00,0x7c,0x36,0x33,0x7f,0x33,0x33,0x73,0x00,0x1e,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x07,0x00,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x07,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x33,0x00,0x33,0x33,0x3e,0x30,0x1f,0xc3,0x18,0x3c,0x66,0x66,0x3c,0x18,0x00,0x33,0x00,0x33,0x33,0x33,0x33,0x1e,0x00,0x18,0x18,0x7e,0x03,0x03,0x7e,0x18,0x18,0x1c,0x36,0x26,0x0f,0x06,0x67,0x3f,0x00,0x33,0x33,0x1e,0x3f,0x0c,0x3f,0x0c,0x0c,0x1f,0x33,0x33,0x5f,0x63,0xf3,0x63,0xe3,0x70,0xd8,0x18,0x3c,0x18,0x18,0x1b,0x0e,
0x38,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x1c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x38,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x38,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x1f,0x00,0x1f,0x33,0x33,0x33,0x00,0x3f,0x00,0x33,0x37,0x3f,0x3b,0x33,0x00,0x3c,0x36,0x36,0x7c,0x00,0x7e,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x3e,0x00,0x00,0x0c,0x00,0x0c,0x06,0x03,0x33,0x1e,0x00,0x00,0x00,0x00,0x3f,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x30,0x00,0x00,0xc3,0x63,0x33,0x7b,0xcc,0x66,0x33,0xf0,0xc3,0x63,0x33,0xdb,0xec,0xf6,0xf3,0xc0,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0xcc,0x66,0x33,0x66,0xcc,0x00,0x00,0x00,0x33,0x66,0xcc,0x66,0x33,0x00,0x00,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xdb,0xee,0xdb,0x77,0xdb,0xee,0xdb,0x77,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0x6f,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x7f,0x6c,0x6c,0x6c,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x7f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6f,0x60,0x7f,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0x7f,0x00,0x00,0x00,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0x0c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xef,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xec,0x6c,0x6c,0x6c,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0xef,0x00,0xef,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xfc,0x00,0x00,0x00,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xfc,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xff,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x6e,0x3b,0x13,0x3b,0x6e,0x00,0x00,0x1e,0x33,0x1f,0x33,0x1f,0x03,0x03,0x00,0x3f,0x33,0x03,0x03,0x03,0x03,0x00,0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00,0x3f,0x33,0x06,0x0c,0x06,0x33,0x3f,0x00,0x00,0x00,0x7e,0x1b,0x1b,0x1b,0x0e,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x06,0x03,0x00,0x6e,0x3b,0x18,0x18,0x18,0x18,0x00,0x3f,0x0c,0x1e,0x33,0x33,0x1e,0x0c,0x3f,0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00,0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x38,0x0c,0x18,0x3e,0x33,0x33,0x1e,0x00,0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00,0x60,0x30,0x7e,0xdb,0xdb,0x7e,0x06,0x03,0x1c,0x06,0x03,0x1f,0x03,0x06,0x1c,0x00,0x1e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x3f,0x00,0x3f,0x00,0x3f,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x3f,0x00,0x06,0x0c,0x18,0x0c,0x06,0x00,0x3f,0x00,0x18,0x0c,0x06,0x0c,0x18,0x00,0x3f,0x00,0x70,0xd8,0xd8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x0e,0x0c,0x0c,0x00,0x3f,0x00,0x0c,0x0c,0x00,0x00,0x6e,0x3b,0x00,0x6e,0x3b,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xf0,0x30,0x30,0x30,0x37,0x36,0x3c,0x38,0x1e,0x36,0x36,0x36,0x36,0x00,0x00,0x00,0x0e,0x18,0x0c,0x06,0x1e,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x1c, 0x3e, 0x1c, 0x7f, 0x7f, 0x3e, 0x1c, 0x3e, 0x08, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x3e, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xf0, 0xe0, 0xf0, 0xbe, 0x33, 0x33, 0x33, 0x1e, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0xfc, 0xcc, 0xfc, 0x0c, 0x0c, 0x0e, 0x0f, 0x07, 0xfe, 0xc6, 0xfe, 0xc6, 0xc6, 0xe6, 0x67, 0x03, 0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99, 0x01, 0x07, 0x1f, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x40, 0x70, 0x7c, 0x7f, 0x7c, 0x70, 0x40, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, 0xfe, 0xdb, 0xdb, 0xde, 0xd8, 0xd8, 0xd8, 0x00, 0x7c, 0xc6, 0x1c, 0x36, 0x36, 0x1c, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x18, 0x30, 0x7f, 0x30, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x06, 0x7f, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x7f, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1e, 0x1e, 0x0c, 0x0c, 0x00, 0x0c, 0x00, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7f, 0x36, 0x7f, 0x36, 0x36, 0x00, 0x0c, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x0c, 0x00, 0x00, 0x63, 0x33, 0x18, 0x0c, 0x66, 0x63, 0x00, 0x1c, 0x36, 0x1c, 0x6e, 0x3b, 0x33, 0x6e, 0x00, 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x06, 0x06, 0x06, 0x0c, 0x18, 0x00, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x01, 0x00, 0x3e, 0x63, 0x73, 0x7b, 0x6f, 0x67, 0x3e, 0x00, 0x0c, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x3f, 0x00, 0x1e, 0x33, 0x30, 0x1c, 0x06, 0x33, 0x3f, 0x00, 0x1e, 0x33, 0x30, 0x1c, 0x30, 0x33, 0x1e, 0x00, 0x38, 0x3c, 0x36, 0x33, 0x7f, 0x30, 0x78, 0x00, 0x3f, 0x03, 0x1f, 0x30, 0x30, 0x33, 0x1e, 0x00, 0x1c, 0x06, 0x03, 0x1f, 0x33, 0x33, 0x1e, 0x00, 0x3f, 0x33, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x33, 0x3e, 0x30, 0x18, 0x0e, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x1e, 0x33, 0x30, 0x18, 0x0c, 0x00, 0x0c, 0x00,
0x3e, 0x63, 0x7b, 0x7b, 0x7b, 0x03, 0x1e, 0x00, 0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x66, 0x66, 0x3f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3c, 0x00, 0x1f, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1f, 0x00, 0x7f, 0x46, 0x16, 0x1e, 0x16, 0x46, 0x7f, 0x00, 0x7f, 0x46, 0x16, 0x1e, 0x16, 0x06, 0x0f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7c, 0x00, 0x33, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x33, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1e, 0x00, 0x67, 0x66, 0x36, 0x1e, 0x36, 0x66, 0x67, 0x00, 0x0f, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7f, 0x00, 0x63, 0x77, 0x7f, 0x7f, 0x6b, 0x63, 0x63, 0x00, 0x63, 0x67, 0x6f, 0x7b, 0x73, 0x63, 0x63, 0x00, 0x1c, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1c, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x06, 0x06, 0x0f, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x3b, 0x1e, 0x38, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x36, 0x66, 0x67, 0x00, 0x1e, 0x33, 0x07, 0x0e, 0x38, 0x33, 0x1e, 0x00, 0x3f, 0x2d, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x63, 0x63, 0x63, 0x6b, 0x7f, 0x77, 0x63, 0x00, 0x63, 0x63, 0x36, 0x1c, 0x1c, 0x36, 0x63, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x0c, 0x1e, 0x00, 0x7f, 0x63, 0x31, 0x18, 0x4c, 0x66, 0x7f, 0x00, 0x1e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1e, 0x00, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x40, 0x00, 0x1e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1e, 0x00, 0x08, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x0c, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x6e, 0x00, 0x07, 0x06, 0x06, 0x3e, 0x66, 0x66, 0x3b, 0x00, 0x00, 0x00, 0x1e, 0x33, 0x03, 0x33, 0x1e, 0x00, 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6e, 0x00, 0x00, 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x1c, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x6e, 0x33, 0x33, 0x3e, 0x30, 0x1f, 0x07, 0x06, 0x36, 0x6e, 0x66, 0x66, 0x67, 0x00, 0x0c, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1e, 0x07, 0x06, 0x66, 0x36, 0x1e, 0x36, 0x67, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x33, 0x7f, 0x7f, 0x6b, 0x63, 0x00, 0x00, 0x00, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x3b, 0x66, 0x66, 0x3e, 0x06, 0x0f, 0x00, 0x00, 0x6e, 0x33, 0x33, 0x3e, 0x30, 0x78, 0x00, 0x00, 0x3b, 0x6e, 0x66, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x00, 0x08, 0x0c, 0x3e, 0x0c, 0x0c, 0x2c, 0x18, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6e, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x00, 0x00, 0x63, 0x6b, 0x7f, 0x7f, 0x36, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x3e, 0x30, 0x1f, 0x00, 0x00, 0x3f, 0x19, 0x0c, 0x26, 0x3f, 0x00, 0x38, 0x0c, 0x0c, 0x07, 0x0c, 0x0c, 0x38, 0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, 0x07, 0x0c, 0x0c, 0x38, 0x0c, 0x0c, 0x07, 0x00, 0x6e, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x36, 0x63, 0x63, 0x7f, 0x00,
0x1e, 0x33, 0x03, 0x33, 0x1e, 0x18, 0x30, 0x1e, 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x38, 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x7e, 0xc3, 0x3c, 0x60, 0x7c, 0x66, 0xfc, 0x00, 0x33, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x07, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x0c, 0x0c, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x00, 0x00, 0x1e, 0x03, 0x03, 0x1e, 0x30, 0x1c, 0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x06, 0x3c, 0x00, 0x33, 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x07, 0x00, 0x1e, 0x33, 0x3f, 0x03, 0x1e, 0x00, 0x33, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x3e, 0x63, 0x1c, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x07, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x63, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x63, 0x00, 0x0c, 0x0c, 0x00, 0x1e, 0x33, 0x3f, 0x33, 0x00, 0x38, 0x00, 0x3f, 0x06, 0x1e, 0x06, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x30, 0xfe, 0x33, 0xfe, 0x00, 0x7c, 0x36, 0x33, 0x7f, 0x33, 0x33, 0x73, 0x00, 0x1e, 0x33, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x33, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x07, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x33, 0x00, 0x33, 0x33, 0x3e, 0x30, 0x1f, 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x00, 0x18, 0x18, 0x7e, 0x03, 0x03, 0x7e, 0x18, 0x18, 0x1c, 0x36, 0x26, 0x0f, 0x06, 0x67, 0x3f, 0x00, 0x33, 0x33, 0x1e, 0x3f, 0x0c, 0x3f, 0x0c, 0x0c, 0x1f, 0x33, 0x33, 0x5f, 0x63, 0xf3, 0x63, 0xe3, 0x70, 0xd8, 0x18, 0x3c, 0x18, 0x18, 0x1b, 0x0e,
0x38, 0x00, 0x1e, 0x30, 0x3e, 0x33, 0x7e, 0x00, 0x1c, 0x00, 0x0e, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x38, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7e, 0x00, 0x00, 0x1f, 0x00, 0x1f, 0x33, 0x33, 0x33, 0x00, 0x3f, 0x00, 0x33, 0x37, 0x3f, 0x3b, 0x33, 0x00, 0x3c, 0x36, 0x36, 0x7c, 0x00, 0x7e, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00, 0x3e, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x06, 0x03, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x30, 0x00, 0x00, 0xc3, 0x63, 0x33, 0x7b, 0xcc, 0x66, 0x33, 0xf0, 0xc3, 0x63, 0x33, 0xdb, 0xec, 0xf6, 0xf3, 0xc0, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xdb, 0xee, 0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x7f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x60, 0x7f, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0x7f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xef, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xef, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xff, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xfc, 0x00, 0x00, 0x00, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xff, 0x6c, 0x6c, 0x6c, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x6e, 0x3b, 0x13, 0x3b, 0x6e, 0x00, 0x00, 0x1e, 0x33, 0x1f, 0x33, 0x1f, 0x03, 0x03, 0x00, 0x3f, 0x33, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x7f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x3f, 0x33, 0x06, 0x0c, 0x06, 0x33, 0x3f, 0x00, 0x00, 0x00, 0x7e, 0x1b, 0x1b, 0x1b, 0x0e, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x03, 0x00, 0x6e, 0x3b, 0x18, 0x18, 0x18, 0x18, 0x00, 0x3f, 0x0c, 0x1e, 0x33, 0x33, 0x1e, 0x0c, 0x3f, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x36, 0x1c, 0x00, 0x1c, 0x36, 0x63, 0x63, 0x36, 0x36, 0x77, 0x00, 0x38, 0x0c, 0x18, 0x3e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x60, 0x30, 0x7e, 0xdb, 0xdb, 0x7e, 0x06, 0x03, 0x1c, 0x06, 0x03, 0x1f, 0x03, 0x06, 0x1c, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x3f, 0x00, 0x06, 0x0c, 0x18, 0x0c, 0x06, 0x00, 0x3f, 0x00, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x00, 0x3f, 0x00, 0x70, 0xd8, 0xd8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1b, 0x1b, 0x0e, 0x0c, 0x0c, 0x00, 0x3f, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x6e, 0x3b, 0x00, 0x6e, 0x3b, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xf0, 0x30, 0x30, 0x30, 0x37, 0x36, 0x3c, 0x38, 0x1e, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x0e, 0x18, 0x0c, 0x06, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void drawText(u8 *screen, int pitch, int x, int y,
const char *string, bool trans)
void drawText(u8* screen, int pitch, int x, int y,
const char* string, bool trans)
{
screen += y*pitch;
int inc = 2;
switch(systemColorDepth) {
case 24:
inc = 3;
break;
case 32:
inc = 4;
break;
}
screen += x*inc;
switch(systemColorDepth) {
case 16:
{
while(*string) {
char c = *string++;
u8 *scr = screen;
u16 mask = ~RGB_LOW_BITS_MASK;
int h, w;
u16 *s = (u16 *)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c<<3)+h]>>w)&1;
if(trans) {
if(on)
*s = ((0xf) << systemRedShift) +
((*s & mask) >>1);
} else {
if(on)
*s = (0x1f) << systemRedShift;
}
}
scr += pitch;
s = (u16 *)scr;
}
screen += inc*8;
}
screen += y * pitch;
int inc = 2;
switch (systemColorDepth) {
case 24:
inc = 3;
break;
case 32:
inc = 4;
break;
}
break;
case 24:
{
while(*string) {
char c = *string++;
u8 *scr = screen;
screen += x * inc;
int h, w;
u8 *s = (u8 *)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s+=3) {
int on = (fontdata2[(c<<3)+h]>>w)&1;
switch (systemColorDepth) {
case 16: {
while (*string) {
char c = *string++;
u8* scr = screen;
if(trans) {
if(on) {
u32 color = (0x1f) << systemRedShift;
*s = ((color & 255)>>1)+(*s>>1);
*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
}
} else {
if(on) {
u32 color = (0x1f) << systemRedShift;
*s = (color & 255);
*(s+1) = (color >> 8) & 255;
*(s+2) = (color >> 16) & 255;
}
u16 mask = ~RGB_LOW_BITS_MASK;
int h, w;
u16* s = (u16*)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c << 3) + h] >> w) & 1;
if (trans) {
if (on)
*s = ((0xf) << systemRedShift) + ((*s & mask) >> 1);
} else {
if (on)
*s = (0x1f) << systemRedShift;
}
}
scr += pitch;
s = (u16*)scr;
}
}
scr += pitch;
s = (u8 *)scr;
screen += inc * 8;
}
screen += inc*8;
}
}
break;
case 32:
{
while(*string) {
char c = *string++;
u8 *scr = screen;
} break;
case 24: {
while (*string) {
char c = *string++;
u8* scr = screen;
int h, w;
u32 mask = 0xfefefe;
u32 *s = (u32 *)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c<<3)+h]>>w)&1;
int h, w;
u8* s = (u8*)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s += 3) {
int on = (fontdata2[(c << 3) + h] >> w) & 1;
if(trans) {
if(on)
*s = ((0xf) << systemRedShift) + ((*s & mask)>>1);
} else {
if(on)
*s = (0x1f) << systemRedShift;
if (trans) {
if (on) {
u32 color = (0x1f) << systemRedShift;
*s = ((color & 255) >> 1) + (*s >> 1);
*(s + 1) = (((color >> 8) & 255) >> 1) + (*(s + 1) >> 1);
*(s + 2) = (((color >> 16) & 255) >> 1) + (*(s + 2) >> 1);
}
} else {
if (on) {
u32 color = (0x1f) << systemRedShift;
*s = (color & 255);
*(s + 1) = (color >> 8) & 255;
*(s + 2) = (color >> 16) & 255;
}
}
}
scr += pitch;
s = (u8*)scr;
}
}
scr += pitch;
s = (u32 *)scr;
screen += inc * 8;
}
screen += inc*8;
}
} break;
case 32: {
while (*string) {
char c = *string++;
u8* scr = screen;
int h, w;
u32 mask = 0xfefefe;
u32* s = (u32*)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c << 3) + h] >> w) & 1;
if (trans) {
if (on)
*s = ((0xf) << systemRedShift) + ((*s & mask) >> 1);
} else {
if (on)
*s = (0x1f) << systemRedShift;
}
}
scr += pitch;
s = (u32*)scr;
}
screen += inc * 8;
}
} break;
}
break;
}
}

View File

@ -17,4 +17,4 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
extern void drawText(u8 *, int, int, int, const char *, bool);
extern void drawText(u8*, int, int, int, const char*, bool);

View File

@ -1,284 +1,269 @@
#include "stdafx.h"
#include "AVIWrite.h"
#pragma comment( lib, "Vfw32" )
#pragma comment(lib, "Vfw32")
AVIWrite::AVIWrite()
{
m_failed = false;
m_file = NULL;
m_videoStream = NULL;
m_audioStream = NULL;
ZeroMemory( &m_videoCompSettings, sizeof( m_videoCompSettings ) );
ZeroMemory( &m_audioCompSettings, sizeof( m_audioCompSettings ) );
m_videoCompressed = NULL;
m_audioCompressed = NULL;
m_frameRate = 0;
m_frameCounter = 0;
m_sampleCounter = 0;
m_videoFrameSize = 0;
m_audioFrameSize = 0;
m_audioBlockAlign = 0;
m_failed = false;
m_file = NULL;
m_videoStream = NULL;
m_audioStream = NULL;
ZeroMemory(&m_videoCompSettings, sizeof(m_videoCompSettings));
ZeroMemory(&m_audioCompSettings, sizeof(m_audioCompSettings));
m_videoCompressed = NULL;
m_audioCompressed = NULL;
m_frameRate = 0;
m_frameCounter = 0;
m_sampleCounter = 0;
m_videoFrameSize = 0;
m_audioFrameSize = 0;
m_audioBlockAlign = 0;
AVIFileInit();
AVIFileInit();
}
AVIWrite::~AVIWrite()
{
if( m_audioCompressed ) {
AVIStreamRelease( m_audioCompressed );
}
if (m_audioCompressed) {
AVIStreamRelease(m_audioCompressed);
}
if( m_audioStream ) {
AVIStreamRelease( m_audioStream );
}
if (m_audioStream) {
AVIStreamRelease(m_audioStream);
}
if( m_videoCompressed ) {
AVIStreamRelease( m_videoCompressed );
}
if (m_videoCompressed) {
AVIStreamRelease(m_videoCompressed);
}
if( m_videoStream ) {
AVIStreamRelease( m_videoStream );
}
if (m_videoStream) {
AVIStreamRelease(m_videoStream);
}
if( m_file ) {
AVIFileRelease( m_file );
}
if (m_file) {
AVIFileRelease(m_file);
}
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;
// -- create the AVI file --
err = AVIFileOpen(
&m_file,
filename,
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
NULL
);
// -- create the AVI file --
err = AVIFileOpen(
&m_file,
filename,
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
NULL);
if( FAILED( err ) ) {
m_failed = true;
return false;
}
if (FAILED(err)) {
m_failed = true;
return false;
}
return true;
return true;
}
// 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;
AVISTREAMINFO videoInfo;
BITMAPINFOHEADER bitmapInfo;
AVICOMPRESSOPTIONS *settings[1];
ZeroMemory( &videoInfo, sizeof( videoInfo ) );
ZeroMemory( &bitmapInfo, sizeof( bitmapInfo ) );
settings[0] = &m_videoCompSettings;
HRESULT err = 0;
AVISTREAMINFO videoInfo;
BITMAPINFOHEADER bitmapInfo;
AVICOMPRESSOPTIONS* settings[1];
ZeroMemory(&videoInfo, sizeof(videoInfo));
ZeroMemory(&bitmapInfo, sizeof(bitmapInfo));
settings[0] = &m_videoCompSettings;
// -- initialize the video stream information --
videoInfo.fccType = streamtypeVIDEO;
videoInfo.fccHandler = 0;
videoInfo.dwScale = 1;
videoInfo.dwRate = framesPerSecond;
videoInfo.dwSuggestedBufferSize = imageWidth * imageHeight * ( colorBits >> 3 );
// -- initialize the video stream information --
videoInfo.fccType = streamtypeVIDEO;
videoInfo.fccHandler = 0;
videoInfo.dwScale = 1;
videoInfo.dwRate = framesPerSecond;
videoInfo.dwSuggestedBufferSize = imageWidth * imageHeight * (colorBits >> 3);
// -- create the video stream --
err = AVIFileCreateStream(
m_file,
&m_videoStream,
&videoInfo
);
// -- create the video stream --
err = AVIFileCreateStream(
m_file,
&m_videoStream,
&videoInfo);
if( FAILED( err ) ) {
m_failed = true;
return false;
}
if (FAILED(err)) {
m_failed = true;
return false;
}
// -- ask for compression settings --
if (AVISaveOptions(
parentWnd,
0,
1,
&m_videoStream,
settings)) {
err = AVIMakeCompressedStream(
&m_videoCompressed,
m_videoStream,
settings[0],
NULL);
// -- ask for compression settings --
if( AVISaveOptions(
parentWnd,
0,
1,
&m_videoStream,
settings ) )
{
err = AVIMakeCompressedStream(
&m_videoCompressed,
m_videoStream,
settings[0],
NULL
);
AVISaveOptionsFree(1, settings);
if (FAILED(err)) {
m_failed = true;
return false;
}
} else {
AVISaveOptionsFree(1, settings);
m_failed = true;
return false;
}
AVISaveOptionsFree( 1, settings );
if( FAILED( err ) ) {
m_failed = true;
return false;
}
} else {
AVISaveOptionsFree( 1, settings );
m_failed = true;
return false;
}
// -- initialize the video stream format --
bitmapInfo.biSize = sizeof(bitmapInfo);
bitmapInfo.biWidth = imageWidth;
bitmapInfo.biHeight = imageHeight;
bitmapInfo.biBitCount = colorBits;
bitmapInfo.biPlanes = 1;
bitmapInfo.biCompression = BI_RGB;
bitmapInfo.biSizeImage = imageWidth * imageHeight * (colorBits >> 3);
// -- set the video stream format --
err = AVIStreamSetFormat(
m_videoCompressed,
0,
&bitmapInfo,
bitmapInfo.biSize + (bitmapInfo.biClrUsed * sizeof(RGBQUAD)));
// -- initialize the video stream format --
bitmapInfo.biSize = sizeof( bitmapInfo );
bitmapInfo.biWidth = imageWidth;
bitmapInfo.biHeight = imageHeight;
bitmapInfo.biBitCount = colorBits;
bitmapInfo.biPlanes = 1;
bitmapInfo.biCompression = BI_RGB;
bitmapInfo.biSizeImage = imageWidth * imageHeight * ( colorBits >> 3 );
if (FAILED(err)) {
m_failed = true;
return false;
}
// -- set the video stream format --
err = AVIStreamSetFormat(
m_videoCompressed,
0,
&bitmapInfo,
bitmapInfo.biSize + ( bitmapInfo.biClrUsed * sizeof( RGBQUAD ) )
);
m_frameRate = framesPerSecond;
m_videoFrameSize = imageWidth * imageHeight * (colorBits >> 3);
if( FAILED( err ) ) {
m_failed = true;
return false;
}
m_frameRate = framesPerSecond;
m_videoFrameSize = imageWidth * imageHeight * ( colorBits >> 3 );
return true;
return true;
}
// call AddVideoStream() first
// channelCount: max. 2
// 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;
AVISTREAMINFO audioInfo;
WAVEFORMATEX waveInfo;
ZeroMemory( &audioInfo, sizeof( audioInfo ) );
ZeroMemory( &waveInfo, sizeof( waveInfo ) );
HRESULT err = 0;
AVISTREAMINFO audioInfo;
WAVEFORMATEX waveInfo;
ZeroMemory(&audioInfo, sizeof(audioInfo));
ZeroMemory(&waveInfo, sizeof(waveInfo));
// -- initialize the audio stream information --
audioInfo.fccType = streamtypeAUDIO;
audioInfo.dwQuality = (DWORD)-1;
audioInfo.dwScale = channelCount * ( sampleBits >> 3 );
audioInfo.dwRate = channelCount * ( sampleBits >> 3 ) * sampleRate;
audioInfo.dwInitialFrames = 1;
audioInfo.dwSampleSize = channelCount * ( sampleBits >> 3 );
audioInfo.dwSuggestedBufferSize = 0;
// -- initialize the audio stream information --
audioInfo.fccType = streamtypeAUDIO;
audioInfo.dwQuality = (DWORD)-1;
audioInfo.dwScale = channelCount * (sampleBits >> 3);
audioInfo.dwRate = channelCount * (sampleBits >> 3) * sampleRate;
audioInfo.dwInitialFrames = 1;
audioInfo.dwSampleSize = channelCount * (sampleBits >> 3);
audioInfo.dwSuggestedBufferSize = 0;
// -- create the audio stream --
err = AVIFileCreateStream(
m_file,
&m_audioStream,
&audioInfo
);
// -- create the audio stream --
err = AVIFileCreateStream(
m_file,
&m_audioStream,
&audioInfo);
if( FAILED( err ) ) {
m_failed = true;
return false;
}
if (FAILED(err)) {
m_failed = true;
return false;
}
// -- initialize the audio stream format --
waveInfo.wFormatTag = WAVE_FORMAT_PCM;
waveInfo.nChannels = channelCount;
waveInfo.nSamplesPerSec = sampleRate;
waveInfo.nAvgBytesPerSec = channelCount * (sampleBits >> 3) * sampleRate;
waveInfo.nBlockAlign = channelCount * (sampleBits >> 3);
waveInfo.wBitsPerSample = sampleBits;
waveInfo.cbSize = 0;
// -- initialize the audio stream format --
waveInfo.wFormatTag = WAVE_FORMAT_PCM;
waveInfo.nChannels = channelCount;
waveInfo.nSamplesPerSec = sampleRate;
waveInfo.nAvgBytesPerSec = channelCount * ( sampleBits >> 3 ) * sampleRate;
waveInfo.nBlockAlign = channelCount * ( sampleBits >> 3 );
waveInfo.wBitsPerSample = sampleBits;
waveInfo.cbSize = 0;
// -- set the audio stream format --
err = AVIStreamSetFormat(
m_audioStream,
0,
&waveInfo,
sizeof(waveInfo));
// -- set the audio stream format --
err = AVIStreamSetFormat(
m_audioStream,
0,
&waveInfo,
sizeof( waveInfo )
);
if (FAILED(err)) {
m_failed = true;
return false;
}
if( FAILED( err ) ) {
m_failed = true;
return false;
}
m_audioBlockAlign = channelCount * (sampleBits >> 3);
m_audioFrameSize = channelCount * (sampleBits >> 3) * (sampleRate / m_frameRate);
m_audioBlockAlign = channelCount * ( sampleBits >> 3 );
m_audioFrameSize = channelCount * ( sampleBits >> 3 ) * ( sampleRate / m_frameRate );
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;
err = AVIStreamWrite(
m_videoCompressed,
m_frameCounter,
1,
imageData,
m_videoFrameSize,
AVIIF_KEYFRAME,
NULL,
NULL
);
err = AVIStreamWrite(
m_videoCompressed,
m_frameCounter,
1,
imageData,
m_videoFrameSize,
AVIIF_KEYFRAME,
NULL,
NULL);
if( FAILED( err ) ) {
m_failed = true;
return false;
}
if (FAILED(err)) {
m_failed = true;
return false;
}
m_frameCounter++;
m_frameCounter++;
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;
err = AVIStreamWrite(
m_audioStream,
m_sampleCounter,
m_audioFrameSize / m_audioBlockAlign,
soundData,
m_audioFrameSize,
0,
NULL,
NULL
);
err = AVIStreamWrite(
m_audioStream,
m_sampleCounter,
m_audioFrameSize / m_audioBlockAlign,
soundData,
m_audioFrameSize,
0,
NULL,
NULL);
if( FAILED( err ) ) {
m_failed = true;
return false;
}
if (FAILED(err)) {
m_failed = true;
return false;
}
m_sampleCounter += m_audioFrameSize / m_audioBlockAlign;
m_sampleCounter += m_audioFrameSize / m_audioBlockAlign;
return true;
return true;
}

View File

@ -1,33 +1,32 @@
#include <vfw.h>
// info: recreate the whole AVIWrite object if any method fails
class AVIWrite
{
public:
AVIWrite();
virtual ~AVIWrite();
class AVIWrite {
public:
AVIWrite();
virtual ~AVIWrite();
bool CreateAVIFile(LPCTSTR filename);
bool CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits,
DWORD framesPerSecond, HWND parentWnd);
bool CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits,
HWND parentWnd);
bool AddVideoFrame(LPVOID imageData);
bool AddAudioFrame(LPVOID soundData);
bool CreateAVIFile(LPCTSTR filename);
bool CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits,
DWORD framesPerSecond, HWND parentWnd);
bool CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits,
HWND parentWnd);
bool AddVideoFrame(LPVOID imageData);
bool AddAudioFrame(LPVOID soundData);
private:
bool m_failed;
PAVIFILE m_file;
PAVISTREAM m_videoStream;
PAVISTREAM m_audioStream;
AVICOMPRESSOPTIONS m_videoCompSettings;
AVICOMPRESSOPTIONS m_audioCompSettings;
PAVISTREAM m_videoCompressed;
PAVISTREAM m_audioCompressed;
DWORD m_frameRate;
LONG m_frameCounter;
LONG m_sampleCounter;
LONG m_videoFrameSize;
LONG m_audioFrameSize;
WORD m_audioBlockAlign;
private:
bool m_failed;
PAVIFILE m_file;
PAVISTREAM m_videoStream;
PAVISTREAM m_audioStream;
AVICOMPRESSOPTIONS m_videoCompSettings;
AVICOMPRESSOPTIONS m_audioCompSettings;
PAVISTREAM m_videoCompressed;
PAVISTREAM m_audioCompressed;
DWORD m_frameRate;
LONG m_frameCounter;
LONG m_sampleCounter;
LONG m_videoFrameSize;
LONG m_audioFrameSize;
WORD m_audioBlockAlign;
};

View File

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "AboutDialog.h"
#include "../AutoBuild.h"
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -11,45 +11,42 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// AboutDialog dialog
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
: CDialog(AboutDialog::IDD, pParent)
: CDialog(AboutDialog::IDD, pParent)
{
m_version = _T(VBA_VERSION_STRING);
m_date = _T(__DATE__);
m_version = _T(VBA_VERSION_STRING);
m_date = _T(__DATE__);
}
void AboutDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AboutDialog)
DDX_Text(pDX, IDC_VERSION, m_version);
DDX_Control(pDX, IDC_URL, m_link);
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_DATE, m_date);
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AboutDialog)
DDX_Text(pDX, IDC_VERSION, m_version);
DDX_Control(pDX, IDC_URL, m_link);
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_DATE, m_date);
}
BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
//{{AFX_MSG_MAP(AboutDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(AboutDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// AboutDialog message handlers
BOOL AboutDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CDialog::OnInitDialog();
CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL);
if(p) {
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
}
CWnd* p = GetDlgItem(IDC_TRANSLATOR_URL);
if (p) {
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
}
m_link.SetWindowText("http://vba-m.com");
m_link.SetWindowText("http://vba-m.com");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -4,20 +4,19 @@
#include "resource.h"
#include "stdafx.h"
class AboutDialog : public CDialog
{
public:
AboutDialog(CWnd *pParent = NULL);
enum { IDD = IDD_ABOUT };
class AboutDialog : public CDialog {
public:
AboutDialog(CWnd* pParent = NULL);
enum { IDD = IDD_ABOUT };
protected:
virtual void DoDataExchange(CDataExchange *pDX);
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
private:
Hyperlink m_link;
Hyperlink m_translator;
CString m_version;
CString m_date;
private:
Hyperlink m_link;
Hyperlink m_translator;
CString m_version;
CString m_date;
};

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "vba.h"
#include "AccelEditor.h"
#include "CmdAccelOb.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -12,258 +12,254 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// AccelEditor dialog
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
: ResizeDlg(AccelEditor::IDD, pParent)
: ResizeDlg(AccelEditor::IDD, pParent)
{
//{{AFX_DATA_INIT(AccelEditor)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
mgr = theApp.winAccelMgr;
//{{AFX_DATA_INIT(AccelEditor)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
mgr = theApp.winAccelMgr;
}
void AccelEditor::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AccelEditor)
DDX_Control(pDX, IDC_CURRENTS, m_currents);
DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected);
DDX_Control(pDX, IDC_COMMANDS, m_commands);
DDX_Control(pDX, IDC_EDIT_KEY, m_key);
//}}AFX_DATA_MAP
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AccelEditor)
DDX_Control(pDX, IDC_CURRENTS, m_currents);
DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected);
DDX_Control(pDX, IDC_COMMANDS, m_commands);
DDX_Control(pDX, IDC_EDIT_KEY, m_key);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
//{{AFX_MSG_MAP(AccelEditor)
ON_BN_CLICKED(ID_OK, OnOk)
ON_LBN_SELCHANGE(IDC_COMMANDS, OnSelchangeCommands)
ON_BN_CLICKED(IDC_RESET, OnReset)
ON_BN_CLICKED(IDC_ASSIGN, OnAssign)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(AccelEditor)
ON_BN_CLICKED(ID_OK, OnOk)
ON_LBN_SELCHANGE(IDC_COMMANDS, OnSelchangeCommands)
ON_BN_CLICKED(IDC_RESET, OnReset)
ON_BN_CLICKED(IDC_ASSIGN, OnAssign)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// AccelEditor message handlers
BOOL AccelEditor::OnInitDialog()
{
CDialog::OnInitDialog();
CDialog::OnInitDialog();
DIALOG_SIZER_START( sz )
DIALOG_SIZER_ENTRY( IDC_STATIC1, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_STATIC2, DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_STATIC3, DS_MoveX | DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_ALREADY_AFFECTED, DS_MoveY)
DIALOG_SIZER_ENTRY( ID_OK, DS_MoveX)
DIALOG_SIZER_ENTRY( ID_CANCEL, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_ASSIGN, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_REMOVE, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_RESET, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY)
DIALOG_SIZER_ENTRY( IDC_COMMANDS, DS_SizeX | DS_SizeY)
DIALOG_SIZER_ENTRY( IDC_CURRENTS, DS_MoveX | DS_SizeY)
DIALOG_SIZER_ENTRY( IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
DIALOG_SIZER_START(sz)
DIALOG_SIZER_ENTRY(IDC_STATIC1, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_STATIC2, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_STATIC3, DS_MoveX | DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_ALREADY_AFFECTED, DS_MoveY)
DIALOG_SIZER_ENTRY(ID_OK, DS_MoveX)
DIALOG_SIZER_ENTRY(ID_CANCEL, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_ASSIGN, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_REMOVE, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_RESET, DS_MoveX)
DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
DIALOG_SIZER_ENTRY(IDC_COMMANDS, DS_SizeX | DS_SizeY)
DIALOG_SIZER_ENTRY(IDC_CURRENTS, DS_MoveX | DS_SizeY)
DIALOG_SIZER_ENTRY(IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
DIALOG_SIZER_END()
SetData(sz,
TRUE,
HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor",
NULL);
TRUE,
HKEY_CURRENT_USER,
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor",
NULL);
InitCommands();
InitCommands();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AccelEditor::InitCommands()
{
m_commands.ResetContent();
m_alreadyAffected.SetWindowText("");
m_commands.ResetContent();
m_alreadyAffected.SetWindowText("");
POSITION pos = mgr.m_mapAccelString.GetStartPosition();
POSITION pos = mgr.m_mapAccelString.GetStartPosition();
while(pos != NULL) {
CString command;
WORD wID;
mgr.m_mapAccelString.GetNextAssoc(pos, command, wID);
while (pos != NULL) {
CString command;
WORD wID;
mgr.m_mapAccelString.GetNextAssoc(pos, command, wID);
int index = m_commands.AddString(command);
m_commands.SetItemData(index, wID);
}
int index = m_commands.AddString(command);
m_commands.SetItemData(index, wID);
}
// Update the currents accels associated with the selected command
if (m_commands.SetCurSel(0) != LB_ERR)
OnSelchangeCommands();
// Update the currents accels associated with the selected command
if (m_commands.SetCurSel(0) != LB_ERR)
OnSelchangeCommands();
}
void AccelEditor::OnCancel()
{
EndDialog(FALSE);
EndDialog(FALSE);
}
void AccelEditor::OnOk()
{
EndDialog(TRUE);
EndDialog(TRUE);
}
void AccelEditor::OnSelchangeCommands()
{
// Check if some commands exist.
int index = m_commands.GetCurSel();
if (index == LB_ERR)
return;
// Check if some commands exist.
int index = m_commands.GetCurSel();
if (index == LB_ERR)
return;
WORD wIDCommand = LOWORD(m_commands.GetItemData(index));
m_currents.ResetContent();
WORD wIDCommand = LOWORD(m_commands.GetItemData(index));
m_currents.ResetContent();
CCmdAccelOb* pCmdAccel;
CCmdAccelOb* pCmdAccel;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
CAccelsOb* pAccel;
CString szBuffer;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
CAccelsOb* pAccel;
CString szBuffer;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
// Add the keys to the 'currents keys' listbox.
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
// and a pointer to the accel object.
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
// Add the keys to the 'currents keys' listbox.
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
// and a pointer to the accel object.
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
}
}
}
// Init the key editor
// m_pKey->ResetKey();
// Init the key editor
// m_pKey->ResetKey();
}
void AccelEditor::OnReset()
{
mgr.Default();
InitCommands(); // update the listboxes.
mgr.Default();
InitCommands(); // update the listboxes.
}
void AccelEditor::OnAssign()
{
// Control if it's not already affected
CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel;
WORD wIDCommand;
POSITION pos;
// Control if it's not already affected
CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel;
WORD wIDCommand;
POSITION pos;
WORD wKey;
bool bCtrl, bAlt, bShift;
WORD wKey;
bool bCtrl, bAlt, bShift;
if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
return; // no valid key, abort
if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
return; // no valid key, abort
int count = m_commands.GetCount();
int index;
for (index = 0; index < count; index++) {
int count = m_commands.GetCount();
int index;
for (index = 0; index < count; index++) {
wIDCommand = LOWORD(m_commands.GetItemData(index));
mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
wIDCommand = LOWORD(m_commands.GetItemData(index));
mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) {
// the key is already affected (in the same or other command)
m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand);
m_key.SetSel(0, -1);
return; // abort
}
pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) {
// the key is already affected (in the same or other command)
m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand);
m_key.SetSel(0, -1);
return; // abort
}
}
}
}
// OK, we can add the accel key in the currently selected group
index = m_commands.GetCurSel();
if (index == LB_ERR)
return;
// OK, we can add the accel key in the currently selected group
index = m_commands.GetCurSel();
if (index == LB_ERR)
return;
// Get the object who manage the accels list, associated to the command.
wIDCommand = LOWORD(m_commands.GetItemData(index));
// Get the object who manage the accels list, associated to the command.
wIDCommand = LOWORD(m_commands.GetItemData(index));
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE)
return;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE)
return;
BYTE cVirt = 0;
if (bCtrl)
cVirt |= FCONTROL;
if (bAlt)
cVirt |= FALT;
if (bShift)
cVirt |= FSHIFT;
BYTE cVirt = 0;
if (bCtrl)
cVirt |= FCONTROL;
if (bAlt)
cVirt |= FALT;
if (bShift)
cVirt |= FSHIFT;
cVirt |= FVIRTKEY;
cVirt |= FVIRTKEY;
// Create the new key...
pAccel = new CAccelsOb(cVirt, wKey, false);
ASSERT(pAccel != NULL);
// ...and add in the list.
pCmdAccel->m_Accels.AddTail(pAccel);
// Create the new key...
pAccel = new CAccelsOb(cVirt, wKey, false);
ASSERT(pAccel != NULL);
// ...and add in the list.
pCmdAccel->m_Accels.AddTail(pAccel);
// Update the listbox.
CString szBuffer;
pAccel->GetString(szBuffer);
// Update the listbox.
CString szBuffer;
pAccel->GetString(szBuffer);
index = m_currents.AddString(szBuffer);
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
index = m_currents.AddString(szBuffer);
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
// Reset the key editor.
m_key.ResetKey();
// Reset the key editor.
m_key.ResetKey();
}
void AccelEditor::OnRemove()
{
// Some controls
int indexCurrent = m_currents.GetCurSel();
if (indexCurrent == LB_ERR)
return;
// Some controls
int indexCurrent = m_currents.GetCurSel();
if (indexCurrent == LB_ERR)
return;
// 2nd part.
int indexCmd = m_commands.GetCurSel();
if (indexCmd == LB_ERR)
return;
// 2nd part.
int indexCmd = m_commands.GetCurSel();
if (indexCmd == LB_ERR)
return;
// Ref to the ID command
WORD wIDCommand = LOWORD(m_commands.GetItemData(indexCmd));
// Ref to the ID command
WORD wIDCommand = LOWORD(m_commands.GetItemData(indexCmd));
// Run through the accels,and control if it can be deleted.
CCmdAccelOb* pCmdAccel;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
CAccelsOb* pAccel;
CAccelsOb* pAccelCurrent = (CAccelsOb*)(m_currents.GetItemData(indexCurrent));
CString szBuffer;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
POSITION PrevPos;
while (pos != NULL) {
PrevPos = pos;
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel == pAccelCurrent) {
if (!pAccel->m_bLocked) {
// not locked, so we delete the key
pCmdAccel->m_Accels.RemoveAt(PrevPos);
delete pAccel;
// and update the listboxes/key editor/static text
m_currents.DeleteString(indexCurrent);
m_key.ResetKey();
m_alreadyAffected.SetWindowText("");
return;
} else {
systemMessage(0,"Unable to remove this\naccelerator (Locked)");
return;
// Run through the accels,and control if it can be deleted.
CCmdAccelOb* pCmdAccel;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
CAccelsOb* pAccel;
CAccelsOb* pAccelCurrent = (CAccelsOb*)(m_currents.GetItemData(indexCurrent));
CString szBuffer;
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
POSITION PrevPos;
while (pos != NULL) {
PrevPos = pos;
pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (pAccel == pAccelCurrent) {
if (!pAccel->m_bLocked) {
// not locked, so we delete the key
pCmdAccel->m_Accels.RemoveAt(PrevPos);
delete pAccel;
// and update the listboxes/key editor/static text
m_currents.DeleteString(indexCurrent);
m_key.ResetKey();
m_alreadyAffected.SetWindowText("");
return;
} else {
systemMessage(0, "Unable to remove this\naccelerator (Locked)");
return;
}
}
}
}
systemMessage(0, "internal error (CAccelDlgHelper::Remove : pAccel unavailable)");
return;
}
systemMessage(0,"internal error (CAccelDlgHelper::Remove : pAccel unavailable)");
return;
}
systemMessage(0,"internal error (CAccelDlgHelper::Remove : Lookup failed)");
systemMessage(0, "internal error (CAccelDlgHelper::Remove : Lookup failed)");
}

View File

@ -13,43 +13,42 @@
/////////////////////////////////////////////////////////////////////////////
// AccelEditor dialog
class AccelEditor : public ResizeDlg
{
// Construction
public:
CAcceleratorManager mgr;
void InitCommands();
AccelEditor(CWnd *pParent = NULL); // standard constructor
class AccelEditor : public ResizeDlg {
// Construction
public:
CAcceleratorManager mgr;
void InitCommands();
AccelEditor(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(AccelEditor)
enum { IDD = IDD_ACCEL_EDITOR };
CListBox m_currents;
CStatic m_alreadyAffected;
CListBox m_commands;
CKeyboardEdit m_key;
//}}AFX_DATA
// Dialog Data
//{{AFX_DATA(AccelEditor)
enum { IDD = IDD_ACCEL_EDITOR };
CListBox m_currents;
CStatic m_alreadyAffected;
CListBox m_commands;
CKeyboardEdit m_key;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(AccelEditor)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(AccelEditor)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(AccelEditor)
virtual BOOL OnInitDialog();
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnSelchangeCommands();
afx_msg void OnReset();
afx_msg void OnAssign();
afx_msg void OnRemove();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(AccelEditor)
virtual BOOL OnInitDialog();
afx_msg void OnCancel();
afx_msg void OnOk();
afx_msg void OnSelchangeCommands();
afx_msg void OnReset();
afx_msg void OnAssign();
afx_msg void OnRemove();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

File diff suppressed because it is too large Load Diff

View File

@ -37,112 +37,111 @@
// Helper map
#include <afxtempl.h> // MFC Templates extension
#ifndef CMapStringToWord
typedef CMap<CString, LPCSTR, WORD, WORD &> CMapStringToWord;
typedef CMap<CString, LPCSTR, WORD, WORD&> CMapStringToWord;
#endif
#ifndef CMapWordToCCmdAccelOb
typedef CMap<WORD, WORD &, CCmdAccelOb *, CCmdAccelOb *&> CMapWordToCCmdAccelOb;
typedef CMap<WORD, WORD&, CCmdAccelOb*, CCmdAccelOb*&> CMapWordToCCmdAccelOb;
#endif
//////////////////////////////////////////////////////////////////////
//
//
class CAcceleratorManager : public CObject
{
friend class AccelEditor;
class CAcceleratorManager : public CObject {
friend class AccelEditor;
public:
CAcceleratorManager();
virtual ~CAcceleratorManager();
public:
CAcceleratorManager();
virtual ~CAcceleratorManager();
// Operations
public:
void UpdateMenu(HMENU menu);
void UpdateMenu();
// Connection to the main application wnd
void Connect(CWnd *pWnd, bool bAutoSave = true);
// In/Out with the registry
bool Load(HKEY hRegKey, LPCTSTR szRegKey);
bool Load();
bool Write();
// Get the initials accels, not the user's
bool Default();
// Save a copy in the 2 maps called xxxSaved, which are used in case
// of Default(), to reload the defaults accels.
bool CreateDefaultTable();
bool IsDefaultTableAvailable()
{
return m_bDefaultTable;
}
bool IsMapStringCommandsEmpty()
{
if (m_mapAccelString.IsEmpty())
return true;
else
return false;
}
// Operations
public:
void UpdateMenu(HMENU menu);
void UpdateMenu();
// Connection to the main application wnd
void Connect(CWnd* pWnd, bool bAutoSave = true);
// In/Out with the registry
bool Load(HKEY hRegKey, LPCTSTR szRegKey);
bool Load();
bool Write();
// Get the initials accels, not the user's
bool Default();
// Save a copy in the 2 maps called xxxSaved, which are used in case
// of Default(), to reload the defaults accels.
bool CreateDefaultTable();
bool IsDefaultTableAvailable()
{
return m_bDefaultTable;
}
bool IsMapStringCommandsEmpty()
{
if (m_mapAccelString.IsEmpty())
return true;
else
return false;
}
// Registry access configuration
bool GetRegKey(HKEY &hRegKey, CString &szRegKey);
bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey);
bool IsAutoSave()
{
return m_bAutoSave;
}
void SetAutoSave(bool bAutoSave)
{
m_bAutoSave = bAutoSave;
}
// Registry access configuration
bool GetRegKey(HKEY& hRegKey, CString& szRegKey);
bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey);
bool IsAutoSave()
{
return m_bAutoSave;
}
void SetAutoSave(bool bAutoSave)
{
m_bAutoSave = bAutoSave;
}
// Helper fct, used for new menus strings
bool GetStringFromACCEL(ACCEL *pACCEL, CString &szAccel);
bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString &szAccel);
// Helper fct, used for new menus strings
bool GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel);
bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel);
// Update the ACCELS table in the application, from the specified
// datas in the manager.
bool UpdateWndTable();
// Update the ACCELS table in the application, from the specified
// datas in the manager.
bool UpdateWndTable();
// Modification helper fcts
bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, LPCTSTR szCommand,
bool bLocked = false);
bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
// Modification helper fcts
bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, LPCTSTR szCommand,
bool bLocked = false);
bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
bool DeleteEntry(LPCTSTR szCommand);
bool DeleteEntry(WORD wIDCommand);
bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
bool DeleteEntry(LPCTSTR szCommand);
bool DeleteEntry(WORD wIDCommand);
bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
// Affectation operator
CAcceleratorManager &operator=(const CAcceleratorManager &accelmgr);
// Affectation operator
CAcceleratorManager& operator=(const CAcceleratorManager& accelmgr);
public:
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Erase all the datas
void Reset();
// Internal affect fct.
bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked);
protected:
// Erase all the datas
void Reset();
// Internal affect fct.
bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked);
// Attributes
protected:
CWnd *m_pWndConnected;
// Attributes
protected:
CWnd* m_pWndConnected;
// User datas
CMapStringToWord m_mapAccelString;
CMapWordToCCmdAccelOb m_mapAccelTable;
// Default datas
CMapWordToCCmdAccelOb m_mapAccelTableSaved;
bool m_bDefaultTable;
// User datas
CMapStringToWord m_mapAccelString;
CMapWordToCCmdAccelOb m_mapAccelTable;
// Default datas
CMapWordToCCmdAccelOb m_mapAccelTableSaved;
bool m_bDefaultTable;
// Where the users datas will be saved in the registry
HKEY m_hRegKey;
CString m_szRegKey;
// if true, there is an auto-save in the registry, when the destructor is called
bool m_bAutoSave;
// Where the users datas will be saved in the registry
HKEY m_hRegKey;
CString m_szRegKey;
// if true, there is an auto-save in the registry, when the destructor is called
bool m_bAutoSave;
};
#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "vba.h"
#include "Associate.h"
#include "Reg.h"
#include "stdafx.h"
#include "vba.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -12,101 +12,98 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// Associate dialog
Associate::Associate(CWnd* pParent /*=NULL*/)
: CDialog(Associate::IDD, pParent)
: CDialog(Associate::IDD, pParent)
{
//{{AFX_DATA_INIT(Associate)
m_agb = FALSE;
m_bin = FALSE;
m_cgb = FALSE;
m_dmg = FALSE;
m_gb = FALSE;
m_gba = FALSE;
m_gbc = FALSE;
m_sgb = FALSE;
//}}AFX_DATA_INIT
//{{AFX_DATA_INIT(Associate)
m_agb = FALSE;
m_bin = FALSE;
m_cgb = FALSE;
m_dmg = FALSE;
m_gb = FALSE;
m_gba = FALSE;
m_gbc = FALSE;
m_sgb = FALSE;
//}}AFX_DATA_INIT
}
void Associate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Associate)
DDX_Check(pDX, IDC_AGB, m_agb);
DDX_Check(pDX, IDC_BIN, m_bin);
DDX_Check(pDX, IDC_CGB, m_cgb);
DDX_Check(pDX, IDC_DMG, m_dmg);
DDX_Check(pDX, IDC_GB, m_gb);
DDX_Check(pDX, IDC_GBA, m_gba);
DDX_Check(pDX, IDC_GBC, m_gbc);
DDX_Check(pDX, IDC_SGB, m_sgb);
//}}AFX_DATA_MAP
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Associate)
DDX_Check(pDX, IDC_AGB, m_agb);
DDX_Check(pDX, IDC_BIN, m_bin);
DDX_Check(pDX, IDC_CGB, m_cgb);
DDX_Check(pDX, IDC_DMG, m_dmg);
DDX_Check(pDX, IDC_GB, m_gb);
DDX_Check(pDX, IDC_GBA, m_gba);
DDX_Check(pDX, IDC_GBC, m_gbc);
DDX_Check(pDX, IDC_SGB, m_sgb);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Associate, CDialog)
//{{AFX_MSG_MAP(Associate)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(ID_OK, OnOk)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(Associate)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
ON_BN_CLICKED(ID_OK, OnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Associate message handlers
BOOL Associate::OnInitDialog()
{
CDialog::OnInitDialog();
CDialog::OnInitDialog();
CenterWindow();
CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Associate::OnCancel()
{
EndDialog(FALSE);
EndDialog(FALSE);
}
void Associate::OnOk()
{
UpdateData();
UpdateData();
int mask = 0;
if(m_gb)
mask |= 1;
if(m_dmg)
mask |= 2;
if(m_sgb)
mask |= 4;
if(m_cgb)
mask |= 8;
if(m_gbc)
mask |= 16;
if(m_gba)
mask |= 32;
if(m_agb)
mask |= 64;
if(m_bin)
mask |= 128;
if(mask) {
char applicationPath[2048];
CString commandPath;
LPCTSTR types[] = { "*.dmg", ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
GetModuleFileName(NULL, applicationPath, 2048);
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
regAssociateType("VisualBoyAdvance.Binary",
"Binary",
commandPath,
"%SystemRoot%\\system32\\SHELL32.dll,-13");
int mask = 0;
if (m_gb)
mask |= 1;
if (m_dmg)
mask |= 2;
if (m_sgb)
mask |= 4;
if (m_cgb)
mask |= 8;
if (m_gbc)
mask |= 16;
if (m_gba)
mask |= 32;
if (m_agb)
mask |= 64;
if (m_bin)
mask |= 128;
if (mask) {
char applicationPath[2048];
CString commandPath;
LPCTSTR types[] = { "*.dmg", ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
GetModuleFileName(NULL, applicationPath, 2048);
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
regAssociateType("VisualBoyAdvance.Binary",
"Binary",
commandPath,
"%SystemRoot%\\system32\\SHELL32.dll,-13");
for(int i = 0; i < 8; i++) {
if(mask & (1<<i)) {
regCreateFileType(types[i],"VisualBoyAdvance.Binary");
}
for (int i = 0; i < 8; i++) {
if (mask & (1 << i)) {
regCreateFileType(types[i], "VisualBoyAdvance.Binary");
}
}
}
}
EndDialog(TRUE);
EndDialog(TRUE);
}

View File

@ -10,41 +10,40 @@
/////////////////////////////////////////////////////////////////////////////
// Associate dialog
class Associate : public CDialog
{
// Construction
public:
Associate(CWnd *pParent = NULL); // standard constructor
class Associate : public CDialog {
// Construction
public:
Associate(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Associate)
enum { IDD = IDD_ASSOCIATIONS };
BOOL m_agb;
BOOL m_bin;
BOOL m_cgb;
BOOL m_dmg;
BOOL m_gb;
BOOL m_gba;
BOOL m_gbc;
BOOL m_sgb;
//}}AFX_DATA
// Dialog Data
//{{AFX_DATA(Associate)
enum { IDD = IDD_ASSOCIATIONS };
BOOL m_agb;
BOOL m_bin;
BOOL m_cgb;
BOOL m_dmg;
BOOL m_gb;
BOOL m_gba;
BOOL m_gbc;
BOOL m_sgb;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Associate)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Associate)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Associate)
virtual BOOL OnInitDialog();
afx_msg void OnCancel();
afx_msg void OnOk();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Associate)
virtual BOOL OnInitDialog();
afx_msg void OnCancel();
afx_msg void OnOk();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@ -1,191 +1,188 @@
#include "stdafx.h"
#include "VBA.h"
#include "stdafx.h"
#include "AudioCoreSettingsDlg.h"
#define MIN_VOLUME 0.0f
#define MAX_VOLUME 4.0f
// AudioCoreSettingsDlg dialog
IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog)
AudioCoreSettingsDlg::AudioCoreSettingsDlg(CWnd* pParent /*=NULL*/)
: CDialog(AudioCoreSettingsDlg::IDD, pParent)
, m_enabled( false )
, m_surround( false )
, m_declicking( false )
, m_sound_interpolation( false )
, m_echo( 0.0f )
, m_stereo( 0.0f )
, m_volume( 0.0f )
, m_sound_filtering( 0.0f )
, m_sample_rate( 0 )
, toolTip( NULL )
: CDialog(AudioCoreSettingsDlg::IDD, pParent)
, m_enabled(false)
, m_surround(false)
, m_declicking(false)
, m_sound_interpolation(false)
, m_echo(0.0f)
, m_stereo(0.0f)
, m_volume(0.0f)
, m_sound_filtering(0.0f)
, m_sample_rate(0)
, toolTip(NULL)
{
}
AudioCoreSettingsDlg::~AudioCoreSettingsDlg()
{
delete toolTip;
delete toolTip;
}
void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ENHANCE_SOUND, enhance_sound);
DDX_Control(pDX, IDC_SURROUND, surround);
DDX_Control(pDX, IDC_ECHO, echo);
DDX_Control(pDX, IDC_STEREO, stereo);
DDX_Control(pDX, IDC_VOLUME, volume);
DDX_Control(pDX, IDC_DECLICKING, declicking);
DDX_Control(pDX, IDC_SOUND_INTERPOLATION, sound_interpolation);
DDX_Control(pDX, IDC_SOUND_FILTERING, sound_filtering);
DDX_Control(pDX, IDC_SAMPLE_RATE, sample_rate);
DDX_Control(pDX, IDC_ENHANCE_SOUND, enhance_sound);
DDX_Control(pDX, IDC_SURROUND, surround);
DDX_Control(pDX, IDC_ECHO, echo);
DDX_Control(pDX, IDC_STEREO, stereo);
DDX_Control(pDX, IDC_VOLUME, volume);
DDX_Control(pDX, IDC_DECLICKING, declicking);
DDX_Control(pDX, IDC_SOUND_INTERPOLATION, sound_interpolation);
DDX_Control(pDX, IDC_SOUND_FILTERING, sound_filtering);
DDX_Control(pDX, IDC_SAMPLE_RATE, sample_rate);
if( pDX->m_bSaveAndValidate == TRUE ) {
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
m_surround = BST_CHECKED == surround.GetCheck();
m_declicking = BST_CHECKED == declicking.GetCheck();
m_sound_interpolation = BST_CHECKED == sound_interpolation.GetCheck();
m_echo = (float)echo.GetPos() / 100.0f;
m_stereo = (float)stereo.GetPos() / 100.0f;
m_volume = (float)volume.GetPos() / 100.0f;
m_sound_filtering = (float)sound_filtering.GetPos() / 100.0f;
m_sample_rate = (unsigned int)sample_rate.GetItemData( sample_rate.GetCurSel() );
}
if (pDX->m_bSaveAndValidate == TRUE) {
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
m_surround = BST_CHECKED == surround.GetCheck();
m_declicking = BST_CHECKED == declicking.GetCheck();
m_sound_interpolation = BST_CHECKED == sound_interpolation.GetCheck();
m_echo = (float)echo.GetPos() / 100.0f;
m_stereo = (float)stereo.GetPos() / 100.0f;
m_volume = (float)volume.GetPos() / 100.0f;
m_sound_filtering = (float)sound_filtering.GetPos() / 100.0f;
m_sample_rate = (unsigned int)sample_rate.GetItemData(sample_rate.GetCurSel());
}
}
BOOL AudioCoreSettingsDlg::OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
BOOL AudioCoreSettingsDlg::OnTtnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
TOOLTIPTEXT *t3 = (TOOLTIPTEXT *)pNMHDR; // dirty Windows API
BOOL i_provided_tooltip_with_text = TRUE;
TOOLTIPTEXT* t3 = (TOOLTIPTEXT*)pNMHDR; // dirty Windows API
BOOL i_provided_tooltip_with_text = TRUE;
if( !( t3->uFlags & TTF_IDISHWND ) ) {
return FALSE;
}
// even dirtier Windows API:
// t3->hdr.idFrom is actually a HWND, holy cow, why?
// The other case does not even occur.
int controlID = ::GetDlgCtrlID( (HWND)t3->hdr.idFrom );
CString res;
TCHAR buf[0x400]; // Use own string buffer because szText has an 80 char limit.
// We can't use a dynamic buffer size because Windows does some shady things with
// t3->lpszText at the end of this function, so we have no chance to free the buffer
// before the end of this function.
if (!(t3->uFlags & TTF_IDISHWND)) {
return FALSE;
}
// even dirtier Windows API:
// t3->hdr.idFrom is actually a HWND, holy cow, why?
// The other case does not even occur.
int controlID = ::GetDlgCtrlID((HWND)t3->hdr.idFrom);
CString res;
TCHAR buf[0x400]; // Use own string buffer because szText has an 80 char limit.
// We can't use a dynamic buffer size because Windows does some shady things with
// t3->lpszText at the end of this function, so we have no chance to free the buffer
// before the end of this function.
switch( controlID ) {
case IDC_VOLUME:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), volume.GetPos() );
break;
case IDC_ECHO:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), echo.GetPos() );
break;
case IDC_STEREO:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), stereo.GetPos() );
break;
case IDC_SOUND_FILTERING:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), sound_filtering.GetPos() );
break;
case IDC_DEFAULT_VOLUME:
res.LoadString( IDS_TOOLTIP_DEFAULT_VOLUME );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
case IDC_ENHANCE_SOUND:
res.LoadString( IDS_TOOLTIP_ENHANCE_SOUND );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
case IDC_SURROUND:
res.LoadString( IDS_TOOLTIP_SURROUND );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
case IDC_DECLICKING:
res.LoadString( IDS_TOOLTIP_DECLICKING );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
default:
i_provided_tooltip_with_text = FALSE;
break;
}
switch (controlID) {
case IDC_VOLUME:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), volume.GetPos());
break;
case IDC_ECHO:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), echo.GetPos());
break;
case IDC_STEREO:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), stereo.GetPos());
break;
case IDC_SOUND_FILTERING:
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), sound_filtering.GetPos());
break;
case IDC_DEFAULT_VOLUME:
res.LoadString(IDS_TOOLTIP_DEFAULT_VOLUME);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
case IDC_ENHANCE_SOUND:
res.LoadString(IDS_TOOLTIP_ENHANCE_SOUND);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
case IDC_SURROUND:
res.LoadString(IDS_TOOLTIP_SURROUND);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
case IDC_DECLICKING:
res.LoadString(IDS_TOOLTIP_DECLICKING);
_tcscpy_s(buf, _countof(buf), res.GetString());
t3->lpszText = buf;
break;
default:
i_provided_tooltip_with_text = FALSE;
break;
}
return i_provided_tooltip_with_text;
return i_provided_tooltip_with_text;
}
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
END_MESSAGE_MAP()
// AudioCoreSettingsDlg message handlers
BOOL AudioCoreSettingsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CDialog::OnInitDialog();
// Set up tooltip control
toolTip = new CToolTipCtrl;
toolTip->Create( this );
toolTip->AddTool( GetDlgItem( IDC_DEFAULT_VOLUME ) );
toolTip->AddTool( GetDlgItem( IDC_ENHANCE_SOUND ) );
toolTip->AddTool( GetDlgItem( IDC_SURROUND ) );
toolTip->AddTool( GetDlgItem( IDC_DECLICKING ) );
toolTip->Activate( TRUE );
// Set up tooltip control
toolTip = new CToolTipCtrl;
toolTip->Create(this);
toolTip->AddTool(GetDlgItem(IDC_DEFAULT_VOLUME));
toolTip->AddTool(GetDlgItem(IDC_ENHANCE_SOUND));
toolTip->AddTool(GetDlgItem(IDC_SURROUND));
toolTip->AddTool(GetDlgItem(IDC_DECLICKING));
toolTip->Activate(TRUE);
enhance_sound.SetCheck( m_enabled ? BST_CHECKED : BST_UNCHECKED );
enhance_sound.SetCheck(m_enabled ? BST_CHECKED : BST_UNCHECKED);
surround.SetCheck( m_surround ? BST_CHECKED : BST_UNCHECKED );
surround.SetCheck(m_surround ? BST_CHECKED : BST_UNCHECKED);
declicking.SetCheck( m_declicking ? BST_CHECKED : BST_UNCHECKED );
declicking.SetCheck(m_declicking ? BST_CHECKED : BST_UNCHECKED);
sound_interpolation.SetCheck( m_sound_interpolation ? BST_CHECKED : BST_UNCHECKED );
sound_interpolation.SetCheck(m_sound_interpolation ? BST_CHECKED : BST_UNCHECKED);
echo.SetRange( 0, 100 );
echo.SetPos( (int)( m_echo * 100.0f ) );
echo.SetRange(0, 100);
echo.SetPos((int)(m_echo * 100.0f));
stereo.SetRange( 0, 100 );
stereo.SetPos( (int)( m_stereo * 100.0f ) );
stereo.SetRange(0, 100);
stereo.SetPos((int)(m_stereo * 100.0f));
sound_filtering.SetRange( 0, 100 );
sound_filtering.SetPos( (int)( m_sound_filtering * 100.0f ) );
sound_filtering.SetRange(0, 100);
sound_filtering.SetPos((int)(m_sound_filtering * 100.0f));
volume.SetRange( (int)( MIN_VOLUME * 100.0f ), (int)( MAX_VOLUME * 100.0f ) );
volume.SetPos( (int)( m_volume * 100.0f ) );
volume.SetRange((int)(MIN_VOLUME * 100.0f), (int)(MAX_VOLUME * 100.0f));
volume.SetPos((int)(m_volume * 100.0f));
unsigned int rate = 44100;
CString temp;
for( int i = 0 ; i <= 2 ; i++ ) {
temp.Format( _T("%u Hz"), rate );
int id = sample_rate.AddString( temp.GetString() );
sample_rate.SetItemData( id, rate );
if( rate == m_sample_rate ) {
sample_rate.SetCurSel( id );
}
rate /= 2;
}
unsigned int rate = 44100;
CString temp;
for (int i = 0; i <= 2; i++) {
temp.Format(_T("%u Hz"), rate);
int id = sample_rate.AddString(temp.GetString());
sample_rate.SetItemData(id, rate);
if (rate == m_sample_rate) {
sample_rate.SetCurSel(id);
}
rate /= 2;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL AudioCoreSettingsDlg::PreTranslateMessage(MSG* pMsg)
{
// Required for enabling ToolTips in a modal dialog box.
if( NULL != toolTip ) {
toolTip->RelayEvent( pMsg );
}
// Required for enabling ToolTips in a modal dialog box.
if (NULL != toolTip) {
toolTip->RelayEvent(pMsg);
}
return CDialog::PreTranslateMessage(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
{
volume.SetPos( 100 );
volume.SetPos(100);
}

View File

@ -2,47 +2,46 @@
// AudioCoreSettingsDlg dialog
class AudioCoreSettingsDlg : public CDialog
{
DECLARE_DYNAMIC(AudioCoreSettingsDlg)
class AudioCoreSettingsDlg : public CDialog {
DECLARE_DYNAMIC(AudioCoreSettingsDlg)
public:
bool m_enabled;
bool m_surround;
bool m_declicking;
bool m_sound_interpolation;
float m_echo;
float m_stereo;
float m_volume;
float m_sound_filtering;
unsigned int m_sample_rate;
public:
bool m_enabled;
bool m_surround;
bool m_declicking;
bool m_sound_interpolation;
float m_echo;
float m_stereo;
float m_volume;
float m_sound_filtering;
unsigned int m_sample_rate;
AudioCoreSettingsDlg(CWnd *pParent = NULL); // standard constructor
virtual ~AudioCoreSettingsDlg();
AudioCoreSettingsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AudioCoreSettingsDlg();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG *pMsg);
afx_msg void OnBnClickedDefaultVolume();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedDefaultVolume();
// Dialog Data
enum { IDD = IDD_AUDIO_CORE_SETTINGS };
// Dialog Data
enum { IDD = IDD_AUDIO_CORE_SETTINGS };
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
afx_msg BOOL OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult); // Retrieve text for
// ToolTip
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg BOOL OnTtnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult); // Retrieve text for
// ToolTip
DECLARE_MESSAGE_MAP()
DECLARE_MESSAGE_MAP()
private:
CButton enhance_sound;
CButton surround;
CButton declicking;
CButton sound_interpolation;
CSliderCtrl echo;
CSliderCtrl stereo;
CSliderCtrl volume;
CSliderCtrl sound_filtering;
CToolTipCtrl *toolTip;
CComboBox sample_rate;
private:
CButton enhance_sound;
CButton surround;
CButton declicking;
CButton sound_interpolation;
CSliderCtrl echo;
CSliderCtrl stereo;
CSliderCtrl volume;
CSliderCtrl sound_filtering;
CToolTipCtrl* toolTip;
CComboBox sample_rate;
};

View File

@ -1,20 +1,19 @@
#include "stdafx.h"
#include "VBA.h"
#include "stdafx.h"
#include "BIOSDialog.h"
// BIOSDialog dialog
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/)
: CDialog(BIOSDialog::IDD, pParent)
, m_enableBIOS_GB(FALSE)
, m_enableBIOS_GBA(FALSE)
, m_skipLogo(FALSE)
, m_pathGB(_T(""))
, m_pathGBA(_T(""))
: CDialog(BIOSDialog::IDD, pParent)
, m_enableBIOS_GB(FALSE)
, m_enableBIOS_GBA(FALSE)
, m_skipLogo(FALSE)
, m_pathGB(_T(""))
, m_pathGBA(_T(""))
{
}
@ -24,115 +23,113 @@ BIOSDialog::~BIOSDialog()
void BIOSDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB);
DDX_Check(pDX, IDC_ENABLE_GBC_BIOS, m_enableBIOS_GBC);
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
DDX_Text(pDX, IDC_GBC_BIOS_PATH, m_pathGBC);
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
DDX_Control(pDX, IDC_GBC_BIOS_PATH, m_editGBC);
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
CDialog::DoDataExchange(pDX);
DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB);
DDX_Check(pDX, IDC_ENABLE_GBC_BIOS, m_enableBIOS_GBC);
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
DDX_Text(pDX, IDC_GBC_BIOS_PATH, m_pathGBC);
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
DDX_Control(pDX, IDC_GBC_BIOS_PATH, m_editGBC);
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
if( pDX->m_bSaveAndValidate == TRUE ) {
// disable BIOS usage when it does not exist
if( !fileExists( m_pathGBA ) ) {
m_enableBIOS_GBA = FALSE;
}
if( !fileExists( m_pathGBC ) ) {
m_enableBIOS_GBC = FALSE;
}
if( !fileExists( m_pathGB ) ) {
m_enableBIOS_GB = FALSE;
}
}
if (pDX->m_bSaveAndValidate == TRUE) {
// disable BIOS usage when it does not exist
if (!fileExists(m_pathGBA)) {
m_enableBIOS_GBA = FALSE;
}
if (!fileExists(m_pathGBC)) {
m_enableBIOS_GBC = FALSE;
}
if (!fileExists(m_pathGB)) {
m_enableBIOS_GB = FALSE;
}
}
}
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
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_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
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_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
END_MESSAGE_MAP()
// BIOSDialog message handlers
void BIOSDialog::OnBnClickedSelectGbBiosPath()
{
CString current;
m_editGB.GetWindowText( current );
if( !fileExists( current ) ) {
current = _T("");
}
CString current;
m_editGB.GetWindowText(current);
if (!fileExists(current)) {
current = _T("");
}
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0 );
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0);
if( IDOK == dlg.DoModal() ) {
m_editGB.SetWindowText( dlg.GetPathName() );
}
if (IDOK == dlg.DoModal()) {
m_editGB.SetWindowText(dlg.GetPathName());
}
}
void BIOSDialog::OnBnClickedSelectGbcBiosPath()
{
CString current;
m_editGBC.GetWindowText( current );
if( !fileExists( current ) ) {
current = _T("");
}
CString current;
m_editGBC.GetWindowText(current);
if (!fileExists(current)) {
current = _T("");
}
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0 );
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0);
if( IDOK == dlg.DoModal() ) {
m_editGBC.SetWindowText( dlg.GetPathName() );
}
if (IDOK == dlg.DoModal()) {
m_editGBC.SetWindowText(dlg.GetPathName());
}
}
void BIOSDialog::OnBnClickedSelectGbaBiosPath()
{
CString current;
m_editGBA.GetWindowText( current );
if( !fileExists( current ) ) {
current = _T("");
}
CString current;
m_editGBA.GetWindowText(current);
if (!fileExists(current)) {
current = _T("");
}
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0 );
CFileDialog dlg(
TRUE,
NULL,
current,
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
this,
0);
if( IDOK == dlg.DoModal() ) {
m_editGBA.SetWindowText( dlg.GetPathName() );
}
if (IDOK == dlg.DoModal()) {
m_editGBA.SetWindowText(dlg.GetPathName());
}
}
bool BIOSDialog::fileExists(CString& file)
{
CFileStatus stat;
BOOL retVal = CFile::GetStatus( file, stat );
bool noFile = false;
if( retVal == TRUE ) {
noFile |= ( stat.m_attribute & CFile::directory ) != 0;
}
return ( retVal == TRUE ) && !noFile;
CFileStatus stat;
BOOL retVal = CFile::GetStatus(file, stat);
bool noFile = false;
if (retVal == TRUE) {
noFile |= (stat.m_attribute & CFile::directory) != 0;
}
return (retVal == TRUE) && !noFile;
}

View File

@ -2,36 +2,35 @@
// BIOSDialog dialog
class BIOSDialog : public CDialog
{
DECLARE_DYNAMIC(BIOSDialog)
class BIOSDialog : public CDialog {
DECLARE_DYNAMIC(BIOSDialog)
public:
BIOSDialog(CWnd *pParent = NULL); // standard constructor
virtual ~BIOSDialog();
public:
BIOSDialog(CWnd* pParent = NULL); // standard constructor
virtual ~BIOSDialog();
// Dialog Data
enum { IDD = IDD_BIOS };
// Dialog Data
enum { IDD = IDD_BIOS };
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
private:
CEdit m_editGB;
CEdit m_editGBC;
CEdit m_editGBA;
bool fileExists(CString &file);
afx_msg void OnBnClickedSelectGbBiosPath();
afx_msg void OnBnClickedSelectGbcBiosPath();
afx_msg void OnBnClickedSelectGbaBiosPath();
DECLARE_MESSAGE_MAP()
private:
CEdit m_editGB;
CEdit m_editGBC;
CEdit m_editGBA;
bool fileExists(CString& file);
afx_msg void OnBnClickedSelectGbBiosPath();
afx_msg void OnBnClickedSelectGbcBiosPath();
afx_msg void OnBnClickedSelectGbaBiosPath();
public:
BOOL m_enableBIOS_GB;
BOOL m_enableBIOS_GBC;
BOOL m_enableBIOS_GBA;
BOOL m_skipLogo;
CString m_pathGB;
CString m_pathGBC;
CString m_pathGBA;
public:
BOOL m_enableBIOS_GB;
BOOL m_enableBIOS_GBC;
BOOL m_enableBIOS_GBA;
BOOL m_skipLogo;
CString m_pathGB;
CString m_pathGBC;
CString m_pathGBA;
};

View File

@ -1,6 +1,6 @@
#include "BitmapControl.h"
#include "stdafx.h"
#include "vba.h"
#include "BitmapControl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -15,110 +15,108 @@ bool BitmapControl::isRegistered = false;
IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
BitmapControl::BitmapControl()
BitmapControl::BitmapControl()
{
w = 0;
h = 0;
data = NULL;
bmpInfo = NULL;
stretch = false;
registerClass();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 0;
SetScrollSizes(MM_TEXT, sizeTotal);
w = 0;
h = 0;
data = NULL;
bmpInfo = NULL;
stretch = false;
registerClass();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 0;
SetScrollSizes(MM_TEXT, sizeTotal);
}
BitmapControl::~BitmapControl()
{
}
BEGIN_MESSAGE_MAP(BitmapControl, CScrollView)
//{{AFX_MSG_MAP(BitmapControl)
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(BitmapControl)
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BitmapControl drawing
void BitmapControl::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void BitmapControl::OnDraw(CDC* dc)
{
RECT r;
GetClientRect(&r);
int w1 = r.right - r.left;
int h1 = r.bottom - r.top;
CDC memDC;
memDC.CreateCompatibleDC(dc);
if(!stretch) {
if(w > w1)
w1 = w;
if(h > h1)
h1 = h;
}
CBitmap bitmap, *pOldBitmap;
bitmap.CreateCompatibleBitmap(dc, w1, h1);
pOldBitmap = memDC.SelectObject(&bitmap);
if(stretch) {
bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h;
RECT r;
GetClientRect(&r);
int w1 = r.right - r.left;
int h1 = r.bottom - r.top;
CDC memDC;
memDC.CreateCompatibleDC(dc);
if (!stretch) {
if (w > w1)
w1 = w;
if (h > h1)
h1 = h;
}
CBitmap bitmap, *pOldBitmap;
bitmap.CreateCompatibleBitmap(dc, w1, h1);
pOldBitmap = memDC.SelectObject(&bitmap);
if (stretch) {
bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h;
StretchDIBits(memDC.GetSafeHdc(),
0,
0,
w1,
h1,
0,
0,
w,
h,
data,
bmpInfo,
DIB_RGB_COLORS,
SRCCOPY);
} else {
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
StretchDIBits(memDC.GetSafeHdc(),
0,
0,
w1,
h1,
0,
0,
w,
h,
data,
bmpInfo,
DIB_RGB_COLORS,
SRCCOPY);
} else {
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h;
SetDIBitsToDevice(memDC.GetSafeHdc(),
0,
0,
w,
h,
0,
0,
0,
h,
data,
bmpInfo,
DIB_RGB_COLORS);
}
bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h;
SetDIBitsToDevice(memDC.GetSafeHdc(),
0,
0,
w,
h,
0,
0,
0,
h,
data,
bmpInfo,
DIB_RGB_COLORS);
}
dc->BitBlt(0,0,w1,h1,
&memDC,0,0,SRCCOPY);
if (boxreigon.right != 0 && boxreigon.bottom != 0)
{
CBrush br = CBrush(RGB(255, 0, 0));
dc->FrameRect(&boxreigon, &br);
}
memDC.SelectObject(pOldBitmap);
dc->BitBlt(0, 0, w1, h1,
&memDC, 0, 0, SRCCOPY);
bitmap.DeleteObject();
memDC.DeleteDC();
if (boxreigon.right != 0 && boxreigon.bottom != 0) {
CBrush br = CBrush(RGB(255, 0, 0));
dc->FrameRect(&boxreigon, &br);
}
memDC.SelectObject(pOldBitmap);
bitmap.DeleteObject();
memDC.DeleteDC();
}
/////////////////////////////////////////////////////////////////////////////
@ -127,12 +125,12 @@ void BitmapControl::OnDraw(CDC* dc)
#ifdef _DEBUG
void BitmapControl::AssertValid() const
{
CScrollView::AssertValid();
CScrollView::AssertValid();
}
void BitmapControl::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
CScrollView::Dump(dc);
}
#endif //_DEBUG
@ -141,141 +139,134 @@ void BitmapControl::Dump(CDumpContext& dc) const
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
return TRUE;
}
void BitmapControl::OnSize(UINT nType, int cx, int cy)
{
if(!stretch)
CScrollView::OnSize(nType, cx, cy);
if (!stretch)
CScrollView::OnSize(nType, cx, cy);
}
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
{
GetParent()->SendMessage(WM_BITMAPCLICK,
GetDlgCtrlID(),
0);
GetParent()->SendMessage(WM_BITMAPCLICK,
GetDlgCtrlID(),
0);
if(!data)
return;
int x = pt.x;
int y = pt.y;
if (!data)
return;
int x = pt.x;
int y = pt.y;
WPARAM point;
WPARAM point;
if(stretch) {
RECT rect;
GetClientRect(&rect);
if (stretch) {
RECT rect;
GetClientRect(&rect);
int height = rect.bottom - rect.top;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
int width = rect.right - rect.left;
int xx = (x * w) / width;
int yy = (y * h) / height;
int xx = (x * w) / width;
int yy = (y * h) / height;
point = xx | (yy<<16);
point = xx | (yy << 16);
int xxx = xx / 8;
int yyy = yy / 8;
int xxx = xx / 8;
int yyy = yy / 8;
for(int i = 0; i < 8; i++) {
memcpy(&colors[i*3*8], &data[xxx * 8 * 3 +
w * yyy * 8 * 3 +
i * w * 3], 8 * 3);
for (int i = 0; i < 8; i++) {
memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
}
} else {
POINT p;
p.x = GetScrollPos(SB_HORZ);
p.y = GetScrollPos(SB_VERT);
p.x += x;
p.y += y;
if (p.x >= w || p.y >= h)
return;
point = p.x | (p.y << 16);
int xxx = p.x / 8;
int yyy = p.y / 8;
for (int i = 0; i < 8; i++) {
memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
}
}
} else {
POINT p;
p.x = GetScrollPos(SB_HORZ);
p.y = GetScrollPos(SB_VERT);
p.x += x;
p.y += y;
if(p.x >= w ||
p.y >= h)
return;
point = p.x | (p.y<<16);
int xxx = p.x / 8;
int yyy = p.y / 8;
for(int i = 0; i < 8; i++) {
memcpy(&colors[i*3*8], &data[xxx * 8 * 3 +
w * yyy * 8 * 3 +
i * w * 3], 8 * 3);
}
}
GetParent()->SendMessage(WM_MAPINFO,
point,
(LPARAM)colors);
GetParent()->SendMessage(WM_MAPINFO,
point,
(LPARAM)colors);
}
void BitmapControl::setBmpInfo(BITMAPINFO *info)
void BitmapControl::setBmpInfo(BITMAPINFO* info)
{
bmpInfo = info;
bmpInfo = info;
}
void BitmapControl::setData(u8 *d)
void BitmapControl::setData(u8* d)
{
data = d;
data = d;
}
void BitmapControl::setSize(int w1, int h1)
{
if(w != w1 || h != h1) {
w = w1;
h = h1;
SIZE s;
s.cx = w;
s.cy = h;
SetScrollSizes(MM_TEXT, s);
}
if (w != w1 || h != h1) {
w = w1;
h = h1;
SIZE s;
s.cx = w;
s.cy = h;
SetScrollSizes(MM_TEXT, s);
}
}
void BitmapControl::setSelectedRectangle(int x, int y, int width, int height)
{
boxreigon.left = x;
boxreigon.right = x + width;
boxreigon.top = y;
boxreigon.bottom = y + height;
boxreigon.left = x;
boxreigon.right = x + width;
boxreigon.top = y;
boxreigon.bottom = y + height;
}
void BitmapControl::refresh()
{
Invalidate();
Invalidate();
}
void BitmapControl::registerClass()
{
if(!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaBitmapControl";
AfxRegisterClass(&wc);
isRegistered = true;
}
if (!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaBitmapControl";
AfxRegisterClass(&wc);
isRegistered = true;
}
}
void BitmapControl::setStretch(bool b)
{
if(b != stretch) {
stretch = b;
Invalidate();
}
if (b != stretch) {
stretch = b;
Invalidate();
}
}
bool BitmapControl::getStretch()
{
return stretch;
return stretch;
}
void BitmapControl::PostNcDestroy()

View File

@ -16,61 +16,60 @@
/////////////////////////////////////////////////////////////////////////////
// BitmapControl view
class BitmapControl : public CScrollView
{
public:
BitmapControl(); // protected constructor used by dynamic creation
protected:
DECLARE_DYNCREATE(BitmapControl)
class BitmapControl : public CScrollView {
public:
BitmapControl(); // protected constructor used by dynamic creation
protected:
DECLARE_DYNCREATE(BitmapControl)
// Attributes
public:
// Operations
public:
void setStretch(bool b);
void refresh();
void setSize(int w1, int h1);
void setSelectedRectangle(int x, int y, int width, int height);
void setData(u8 *d);
void setBmpInfo(BITMAPINFO *info);
static bool isRegistered;
// Attributes
public:
// Operations
public:
void setStretch(bool b);
void refresh();
void setSize(int w1, int h1);
void setSelectedRectangle(int x, int y, int width, int height);
void setData(u8* d);
void setBmpInfo(BITMAPINFO* info);
static bool isRegistered;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(BitmapControl)
protected:
virtual void OnDraw(CDC *pDC); // overridden to draw this view
virtual void OnInitialUpdate(); // first time after construct
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(BitmapControl)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual void OnInitialUpdate(); // first time after construct
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
public:
bool getStretch();
virtual ~BitmapControl();
// Implementation
public:
bool getStretch();
virtual ~BitmapControl();
protected:
protected:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(BitmapControl)
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void registerClass();
bool stretch;
u8 colors[3 * 64];
BITMAPINFO *bmpInfo;
u8 *data;
int h;
int w;
RECT boxreigon;
// Generated message map functions
//{{AFX_MSG(BitmapControl)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void registerClass();
bool stretch;
u8 colors[3 * 64];
BITMAPINFO* bmpInfo;
u8* data;
int h;
int w;
RECT boxreigon;
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -19,17 +19,17 @@
// BugReport.cpp : implementation file
//
#include "BugReport.h"
#include "stdafx.h"
#include "vba.h"
#include "BugReport.h"
#include "../agb/agbprint.h"
#include "../AutoBuild.h"
#include "../agb/GBA.h"
#include "../Globals.h"
#include "../Port.h"
#include "../RTC.h"
#include "../Sound.h"
#include "../agb/GBA.h"
#include "../agb/agbprint.h"
#include "../dmg/gbCheats.h"
#include "../dmg/gbGlobals.h"
@ -42,204 +42,200 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// BugReport dialog
BugReport::BugReport(CWnd* pParent /*=NULL*/)
: CDialog(BugReport::IDD, pParent)
: CDialog(BugReport::IDD, pParent)
{
//{{AFX_DATA_INIT(BugReport)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
//{{AFX_DATA_INIT(BugReport)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void BugReport::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(BugReport)
DDX_Control(pDX, IDC_BUG_REPORT, m_report);
//}}AFX_DATA_MAP
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(BugReport)
DDX_Control(pDX, IDC_BUG_REPORT, m_report);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(BugReport, CDialog)
//{{AFX_MSG_MAP(BugReport)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(ID_OK, OnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(BugReport)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(ID_OK, OnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BugReport message handlers
void BugReport::OnCopy()
{
OpenClipboard();
OpenClipboard();
EmptyClipboard();
CString report;
m_report.GetWindowText(report);
EmptyClipboard();
CString report;
m_report.GetWindowText(report);
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
(report.GetLength() + 1) * sizeof(CHAR));
if (hglbCopy == NULL) {
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
(report.GetLength() + 1) * sizeof(CHAR));
if (hglbCopy == NULL) {
CloseClipboard();
return;
}
// Lock the handle and copy the text to the buffer.
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
memcpy(lptstrCopy, (const char*)report,
report.GetLength() * sizeof(CHAR));
lptstrCopy[report.GetLength()] = (TCHAR)0; // null character
GlobalUnlock(hglbCopy);
// Place the handle on the clipboard.
SetClipboardData(CF_TEXT, hglbCopy);
CloseClipboard();
return;
}
// Lock the handle and copy the text to the buffer.
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
memcpy(lptstrCopy, (const char *)report,
report.GetLength() * sizeof(CHAR));
lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character
GlobalUnlock(hglbCopy);
// Place the handle on the clipboard.
SetClipboardData(CF_TEXT, hglbCopy);
CloseClipboard();
systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
}
void BugReport::OnOk()
{
EndDialog(TRUE);
EndDialog(TRUE);
}
BOOL BugReport::OnInitDialog()
{
CDialog::OnInitDialog();
CDialog::OnInitDialog();
CenterWindow();
CenterWindow();
CString report = createReport();
CString report = createReport();
m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
m_report.SetWindowText(report);
m_report.SetWindowText(report);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
return TRUE; // return TRUE unless you set the focus to a control
// 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;
va_list valist;
CString buffer;
va_list valist;
va_start(valist, format);
buffer.FormatV(format, valist);
va_end(valist);
report += buffer;
va_start(valist, format);
buffer.FormatV(format, valist);
va_end(valist);
report += buffer;
}
CString BugReport::createReport()
{
theApp.winCheckFullscreen();
theApp.winCheckFullscreen();
CString report = "";
AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING);
AppendFormat(report, "Emu Type : %s\r\n",
CString report = "";
AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING);
AppendFormat(report, "Emu Type : %s\r\n",
#ifdef DEBUG
"Debug Version"
"Debug Version"
#else
"Release Version"
"Release Version"
#endif
);
);
if(emulating) {
AppendFormat(report, "File : %s\r\n", theApp.szFile);
if (emulating) {
AppendFormat(report, "File : %s\r\n", theApp.szFile);
char buffer[20];
if(theApp.cartridgeType == 0) {
u32 check = 0;
for(int i = 0; i < 0x4000; i += 4) {
check += *((u32 *)&bios[i]);
}
AppendFormat(report, "BIOS Checksum: %08X\r\n", check);
char buffer[20];
if (theApp.cartridgeType == 0) {
u32 check = 0;
for (int i = 0; i < 0x4000; i += 4) {
check += *((u32*)&bios[i]);
}
AppendFormat(report, "BIOS Checksum: %08X\r\n", check);
strncpy(buffer, (const char *)&rom[0xa0], 12);
buffer[12] = 0;
AppendFormat(report, "Internal name: %s\r\n", buffer);
strncpy(buffer, (const char*)&rom[0xa0], 12);
buffer[12] = 0;
AppendFormat(report, "Internal name: %s\r\n", buffer);
strncpy(buffer, (const char *)&rom[0xac], 4);
buffer[4] = 0;
AppendFormat(report, "Game code : %s\r\n", buffer);
strncpy(buffer, (const char*)&rom[0xac], 4);
buffer[4] = 0;
AppendFormat(report, "Game code : %s\r\n", buffer);
CString res = "";
u32 *p = (u32 *)rom;
u32 *end = (u32 *)((char *)rom+theApp.romSize);
while(p < end) {
u32 d = READ32LE(p);
CString res = "";
u32* p = (u32*)rom;
u32* end = (u32*)((char*)rom + theApp.romSize);
while (p < end) {
u32 d = READ32LE(p);
if(d == 0x52504545) {
if(memcmp(p, "EEPROM_", 7) == 0) {
res += (const char *)p;
res += ' ';
}
} else if (d == 0x4D415253) {
if(memcmp(p, "SRAM_", 5) == 0) {
res += (const char *)p;
res += ' ';
}
} else if (d == 0x53414C46) {
if(memcmp(p, "FLASH1M_", 8) == 0) {
res += (const char *)p;
res += ' ';
}
} else if(memcmp(p, "FLASH", 5) == 0) {
res += (const char *)p;
res += ' ';
} else if (d == 0x52494953) {
if(memcmp(p, "SIIRTC_V", 8) == 0) {
res += (const char *)p;
res += ' ';
}
if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {
res += (const char*)p;
res += ' ';
}
} else if (d == 0x4D415253) {
if (memcmp(p, "SRAM_", 5) == 0) {
res += (const char*)p;
res += ' ';
}
} else if (d == 0x53414C46) {
if (memcmp(p, "FLASH1M_", 8) == 0) {
res += (const char*)p;
res += ' ';
}
} else if (memcmp(p, "FLASH", 5) == 0) {
res += (const char*)p;
res += ' ';
} else if (d == 0x52494953) {
if (memcmp(p, "SIIRTC_V", 8) == 0) {
res += (const char*)p;
res += ' ';
}
}
p++;
}
if (res.GetLength() > 0)
AppendFormat(report, "Cart Save : %s\r\n", res);
} else if (theApp.cartridgeType == 1) {
strncpy(buffer, (const char*)&gbRom[0x134], 15);
buffer[15] = 0;
AppendFormat(report, "Game title : %s\r\n", buffer);
}
p++;
}
if(res.GetLength() > 0)
AppendFormat(report, "Cart Save : %s\r\n", res);
} else if(theApp.cartridgeType == 1) {
strncpy(buffer, (const char *)&gbRom[0x134], 15);
buffer[15] = 0;
AppendFormat(report, "Game title : %s\r\n", buffer);
}
}
AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile);
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod);
AppendFormat(report, "Color depth : %d\r\n", systemColorDepth);
AppendFormat(report, "Red shift : %08x\r\n", systemRedShift);
AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
AppendFormat(report, "Save type : %d (%d)\r\n",
theApp.winSaveType, cpuSaveType);
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
theApp.winFlashSize, flashSize);
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
rtcIsEnabled());
AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled());
AppendFormat(report, "Speed toggle : %d\r\n", theApp.speedupToggle);
AppendFormat(report, "Synchronize : %d\r\n", synchronize);
AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag);
AppendFormat(report, "Channels : %04x\r\n", soundGetEnable() & 0x30f);
AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync);
AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority);
AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
AppendFormat(report, "Cheats : %d\r\n", cheatsNumber);
AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber);
AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType);
AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile);
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod);
AppendFormat(report, "Color depth : %d\r\n", systemColorDepth);
AppendFormat(report, "Red shift : %08x\r\n", systemRedShift);
AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
AppendFormat(report, "Save type : %d (%d)\r\n",
theApp.winSaveType, cpuSaveType);
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
theApp.winFlashSize, flashSize);
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
rtcIsEnabled());
AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled());
AppendFormat(report, "Speed toggle : %d\r\n", theApp.speedupToggle);
AppendFormat(report, "Synchronize : %d\r\n", synchronize);
AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag);
AppendFormat(report, "Channels : %04x\r\n", soundGetEnable() & 0x30f);
AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync);
AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority);
AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
AppendFormat(report, "Cheats : %d\r\n", cheatsNumber);
AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber);
AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType);
return report;
return report;
}

View File

@ -29,36 +29,35 @@
/////////////////////////////////////////////////////////////////////////////
// BugReport dialog
class BugReport : public CDialog
{
// Construction
public:
BugReport(CWnd *pParent = NULL); // standard constructor
class BugReport : public CDialog {
// Construction
public:
BugReport(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(BugReport)
enum { IDD = IDD_BUG_REPORT };
CEdit m_report;
//}}AFX_DATA
// Dialog Data
//{{AFX_DATA(BugReport)
enum { IDD = IDD_BUG_REPORT };
CEdit m_report;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(BugReport)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(BugReport)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CString createReport();
// Implementation
protected:
CString createReport();
// Generated message map functions
//{{AFX_MSG(BugReport)
afx_msg void OnCopy();
afx_msg void OnOk();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Generated message map functions
//{{AFX_MSG(BugReport)
afx_msg void OnCopy();
afx_msg void OnOk();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@ -26,146 +26,144 @@
//
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CmdAccelOb.h"
#include "stdafx.h"
////////////////////////////////////////////////////////////////////////
//
//
MAPVIRTKEYS mapVirtKeys[] = {
{VK_LBUTTON, "VK_LBUTTON"},
{VK_RBUTTON, "VK_RBUTTON"},
{VK_CANCEL, "VK_CANCEL"},
{VK_MBUTTON, "VK_MBUTTON"},
{VK_BACK, "BACK"},
{VK_TAB, "TAB"},
{VK_CLEAR, "VK_CLEAR"},
{VK_RETURN, "RETURN"},
{VK_SHIFT, "SHIFT"},
{VK_CONTROL, "CONTROL"},
{VK_MENU, "MENU"},
{VK_PAUSE, "PAUSE"},
{VK_CAPITAL, "CAPITAL"},
{VK_ESCAPE, "ESCAPE"},
{VK_SPACE, "SPACE"},
{VK_PRIOR, "PRIOR"},
{VK_NEXT, "NEXT"},
{VK_END, "END"},
{VK_HOME, "HOME"},
{VK_LEFT, "LEFT"},
{VK_UP, "UP"},
{VK_RIGHT, "RIGHT"},
{VK_DOWN, "DOWN"},
{VK_SELECT, "VK_SELECT"},
{VK_PRINT, "PRINT"},
{VK_EXECUTE, "EXECUTE"},
{VK_SNAPSHOT, "SNAPSHOT"},
{VK_INSERT, "INSERT"},
{VK_DELETE, "DELETE"},
{VK_HELP, "VK_HELP"},
{WORD('0'), "0"},
{WORD('1'), "1"},
{WORD('2'), "2"},
{WORD('3'), "3"},
{WORD('4'), "4"},
{WORD('5'), "5"},
{WORD('6'), "6"},
{WORD('7'), "7"},
{WORD('8'), "8"},
{WORD('9'), "9"},
{WORD('A'), "A"},
{WORD('B'), "B"},
{WORD('C'), "C"},
{WORD('D'), "D"},
{WORD('E'), "E"},
{WORD('F'), "F"},
{WORD('G'), "G"},
{WORD('H'), "H"},
{WORD('I'), "I"},
{WORD('J'), "J"},
{WORD('K'), "K"},
{WORD('L'), "L"},
{WORD('M'), "M"},
{WORD('N'), "N"},
{WORD('O'), "O"},
{WORD('P'), "P"},
{WORD('Q'), "Q"},
{WORD('R'), "R"},
{WORD('S'), "S"},
{WORD('T'), "T"},
{WORD('U'), "U"},
{WORD('V'), "V"},
{WORD('W'), "W"},
{WORD('X'), "X"},
{WORD('Y'), "Y"},
{WORD('Z'), "Z"},
{VK_LWIN, "VK_LWIN"},
{VK_RWIN, "VK_RWIN"},
{VK_APPS, "VK_APPS"},
{VK_NUMPAD0, "NUMPAD0"},
{VK_NUMPAD1, "NUMPAD1"},
{VK_NUMPAD2, "NUMPAD2"},
{VK_NUMPAD3, "NUMPAD3"},
{VK_NUMPAD4, "NUMPAD4"},
{VK_NUMPAD5, "NUMPAD5"},
{VK_NUMPAD6, "NUMPAD6"},
{VK_NUMPAD7, "NUMPAD7"},
{VK_NUMPAD8, "NUMPAD8"},
{VK_NUMPAD9, "NUMPAD9"},
{VK_MULTIPLY, "MULTIPLY"},
{VK_ADD, "ADD"},
{VK_SEPARATOR, "SEPARATOR"},
{VK_SUBTRACT, "SUBTRACT"},
{VK_DECIMAL, "DECIMAL"},
{VK_DIVIDE, "DIVIDE"},
{VK_F1, "F1"},
{VK_F2, "F2"},
{VK_F3, "F3"},
{VK_F4, "F4"},
{VK_F5, "F5"},
{VK_F6, "F6"},
{VK_F7, "F7"},
{VK_F8, "F8"},
{VK_F9, "F9"},
{VK_F10, "F10"},
{VK_F11, "F11"},
{VK_F12, "F12"},
{VK_F13, "F13"},
{VK_F14, "F14"},
{VK_F15, "F15"},
{VK_F16, "F16"},
{VK_F17, "F17"},
{VK_F18, "F18"},
{VK_F19, "F19"},
{VK_F20, "F20"},
{VK_F21, "F21"},
{VK_F22, "F22"},
{VK_F23, "F23"},
{VK_F24, "F24"},
{VK_NUMLOCK, "NUMLOCK"},
{VK_SCROLL, "VK_SCROLL"},
{VK_ATTN, "VK_ATTN"},
{VK_CRSEL, "VK_CRSEL"},
{VK_EXSEL, "VK_EXSEL"},
{VK_EREOF, "VK_EREOF"},
{VK_PLAY, "VK_PLAY"},
{VK_ZOOM, "VK_ZOOM"},
{VK_NONAME, "VK_NONAME"},
{VK_PA1, "VK_PA1"},
{VK_OEM_CLEAR, "VK_OEM_CLEAR"},
{ VK_LBUTTON, "VK_LBUTTON" },
{ VK_RBUTTON, "VK_RBUTTON" },
{ VK_CANCEL, "VK_CANCEL" },
{ VK_MBUTTON, "VK_MBUTTON" },
{ VK_BACK, "BACK" },
{ VK_TAB, "TAB" },
{ VK_CLEAR, "VK_CLEAR" },
{ VK_RETURN, "RETURN" },
{ VK_SHIFT, "SHIFT" },
{ VK_CONTROL, "CONTROL" },
{ VK_MENU, "MENU" },
{ VK_PAUSE, "PAUSE" },
{ VK_CAPITAL, "CAPITAL" },
{ VK_ESCAPE, "ESCAPE" },
{ VK_SPACE, "SPACE" },
{ VK_PRIOR, "PRIOR" },
{ VK_NEXT, "NEXT" },
{ VK_END, "END" },
{ VK_HOME, "HOME" },
{ VK_LEFT, "LEFT" },
{ VK_UP, "UP" },
{ VK_RIGHT, "RIGHT" },
{ VK_DOWN, "DOWN" },
{ VK_SELECT, "VK_SELECT" },
{ VK_PRINT, "PRINT" },
{ VK_EXECUTE, "EXECUTE" },
{ VK_SNAPSHOT, "SNAPSHOT" },
{ VK_INSERT, "INSERT" },
{ VK_DELETE, "DELETE" },
{ VK_HELP, "VK_HELP" },
{ WORD('0'), "0" },
{ WORD('1'), "1" },
{ WORD('2'), "2" },
{ WORD('3'), "3" },
{ WORD('4'), "4" },
{ WORD('5'), "5" },
{ WORD('6'), "6" },
{ WORD('7'), "7" },
{ WORD('8'), "8" },
{ WORD('9'), "9" },
{ WORD('A'), "A" },
{ WORD('B'), "B" },
{ WORD('C'), "C" },
{ WORD('D'), "D" },
{ WORD('E'), "E" },
{ WORD('F'), "F" },
{ WORD('G'), "G" },
{ WORD('H'), "H" },
{ WORD('I'), "I" },
{ WORD('J'), "J" },
{ WORD('K'), "K" },
{ WORD('L'), "L" },
{ WORD('M'), "M" },
{ WORD('N'), "N" },
{ WORD('O'), "O" },
{ WORD('P'), "P" },
{ WORD('Q'), "Q" },
{ WORD('R'), "R" },
{ WORD('S'), "S" },
{ WORD('T'), "T" },
{ WORD('U'), "U" },
{ WORD('V'), "V" },
{ WORD('W'), "W" },
{ WORD('X'), "X" },
{ WORD('Y'), "Y" },
{ WORD('Z'), "Z" },
{ VK_LWIN, "VK_LWIN" },
{ VK_RWIN, "VK_RWIN" },
{ VK_APPS, "VK_APPS" },
{ VK_NUMPAD0, "NUMPAD0" },
{ VK_NUMPAD1, "NUMPAD1" },
{ VK_NUMPAD2, "NUMPAD2" },
{ VK_NUMPAD3, "NUMPAD3" },
{ VK_NUMPAD4, "NUMPAD4" },
{ VK_NUMPAD5, "NUMPAD5" },
{ VK_NUMPAD6, "NUMPAD6" },
{ VK_NUMPAD7, "NUMPAD7" },
{ VK_NUMPAD8, "NUMPAD8" },
{ VK_NUMPAD9, "NUMPAD9" },
{ VK_MULTIPLY, "MULTIPLY" },
{ VK_ADD, "ADD" },
{ VK_SEPARATOR, "SEPARATOR" },
{ VK_SUBTRACT, "SUBTRACT" },
{ VK_DECIMAL, "DECIMAL" },
{ VK_DIVIDE, "DIVIDE" },
{ VK_F1, "F1" },
{ VK_F2, "F2" },
{ VK_F3, "F3" },
{ VK_F4, "F4" },
{ VK_F5, "F5" },
{ VK_F6, "F6" },
{ VK_F7, "F7" },
{ VK_F8, "F8" },
{ VK_F9, "F9" },
{ VK_F10, "F10" },
{ VK_F11, "F11" },
{ VK_F12, "F12" },
{ VK_F13, "F13" },
{ VK_F14, "F14" },
{ VK_F15, "F15" },
{ VK_F16, "F16" },
{ VK_F17, "F17" },
{ VK_F18, "F18" },
{ VK_F19, "F19" },
{ VK_F20, "F20" },
{ VK_F21, "F21" },
{ VK_F22, "F22" },
{ VK_F23, "F23" },
{ VK_F24, "F24" },
{ VK_NUMLOCK, "NUMLOCK" },
{ VK_SCROLL, "VK_SCROLL" },
{ VK_ATTN, "VK_ATTN" },
{ VK_CRSEL, "VK_CRSEL" },
{ VK_EXSEL, "VK_EXSEL" },
{ VK_EREOF, "VK_EREOF" },
{ VK_PLAY, "VK_PLAY" },
{ VK_ZOOM, "VK_ZOOM" },
{ VK_NONAME, "VK_NONAME" },
{ VK_PA1, "VK_PA1" },
{ VK_OEM_CLEAR, "VK_OEM_CLEAR" },
};
////////////////////////////////////////////////////////////////////////
//
//
MAPVIRTKEYS mapVirtSysKeys[] = {
{FCONTROL, "Ctrl"},
{FALT, "Alt"},
{FSHIFT, "Shift"},
{ FCONTROL, "Ctrl" },
{ FALT, "Alt" },
{ FSHIFT, "Shift" },
};
////////////////////////////////////////////////////////////////////////
// helper fct for external access
////////////////////////////////////////////////////////////////////////
@ -173,20 +171,17 @@ MAPVIRTKEYS mapVirtSysKeys[] = {
//
TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
{
for (int index = 0; index < sizeof(mapVirtKeys)/sizeof(mapVirtKeys[0]); index++) {
if (mapVirtKeys[index].wKey == wKey)
return mapVirtKeys[index].szKey;
}
return NULL;
for (int index = 0; index < sizeof(mapVirtKeys) / sizeof(mapVirtKeys[0]); index++) {
if (mapVirtKeys[index].wKey == wKey)
return mapVirtKeys[index].szKey;
}
return NULL;
}
////////////////////////////////////////////////////////////////////////
//
#define DEFAULT_ACCEL 0x01
#define USER_ACCEL 0x02
#define DEFAULT_ACCEL 0x01
#define USER_ACCEL 0x02
////////////////////////////////////////////////////////////////////////
//
@ -195,62 +190,57 @@ TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
//
CAccelsOb::CAccelsOb()
{
m_cVirt = 0;
m_wKey = 0;
m_bLocked = false;
m_cVirt = 0;
m_wKey = 0;
m_bLocked = false;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
{
ASSERT(pFrom != NULL);
ASSERT(pFrom != NULL);
m_cVirt = pFrom->m_cVirt;
m_wKey = pFrom->m_wKey;
m_bLocked = pFrom->m_bLocked;
m_cVirt = pFrom->m_cVirt;
m_wKey = pFrom->m_wKey;
m_bLocked = pFrom->m_bLocked;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
{
m_cVirt = cVirt;
m_wKey = wKey;
m_bLocked = bLocked;
m_cVirt = cVirt;
m_wKey = wKey;
m_bLocked = bLocked;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb::CAccelsOb(LPACCEL pACCEL)
{
ASSERT(pACCEL != NULL);
ASSERT(pACCEL != NULL);
m_cVirt = pACCEL->fVirt;
m_wKey = pACCEL->key;
m_bLocked = false;
m_cVirt = pACCEL->fVirt;
m_wKey = pACCEL->key;
m_bLocked = false;
}
////////////////////////////////////////////////////////////////////////
//
//
CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
{
m_cVirt = from.m_cVirt;
m_wKey = from.m_wKey;
m_bLocked = from.m_bLocked;
m_cVirt = from.m_cVirt;
m_wKey = from.m_wKey;
m_bLocked = from.m_bLocked;
return *this;
return *this;
}
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
@ -258,83 +248,79 @@ CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
//
void CAccelsOb::GetString(CString& szBuffer)
{
szBuffer = "";
// in case of the object is not assigned, we avoid error messages
if (m_wKey == 0)
return;
szBuffer = "";
// in case of the object is not assigned, we avoid error messages
if (m_wKey == 0)
return;
// modifiers part
int i;
for (i = 0; i < sizetable(mapVirtSysKeys); i++) {
if (m_cVirt & mapVirtSysKeys[i].wKey) {
szBuffer += mapVirtSysKeys[i].szKey;
szBuffer += "+";
// modifiers part
int i;
for (i = 0; i < sizetable(mapVirtSysKeys); i++) {
if (m_cVirt & mapVirtSysKeys[i].wKey) {
szBuffer += mapVirtSysKeys[i].szKey;
szBuffer += "+";
}
}
}
// and virtual key part
for (i = 0; i < sizetable(mapVirtKeys); i++) {
if (m_wKey == mapVirtKeys[i].wKey) {
szBuffer += mapVirtKeys[i].szKey;
return;
// and virtual key part
for (i = 0; i < sizetable(mapVirtKeys); i++) {
if (m_wKey == mapVirtKeys[i].wKey) {
szBuffer += mapVirtKeys[i].szKey;
return;
}
}
}
AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
}
////////////////////////////////////////////////////////////////////////
//
//
bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
{
// CString szTemp;
// GetString(szTemp);
// CString szTemp;
// GetString(szTemp);
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
bool bRet = (bCtrl == m_bCtrl);
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
bool bRet = (bCtrl == m_bCtrl);
bool m_bAlt = (m_cVirt & FALT) ? true : false;
bRet &= (bAlt == m_bAlt);
bool m_bAlt = (m_cVirt & FALT) ? true : false;
bRet &= (bAlt == m_bAlt);
bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
bRet &= (bShift == m_bShift);
bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
bRet &= (bShift == m_bShift);
bRet &= static_cast<bool>(m_wKey == wKey);
bRet &= static_cast<bool>(m_wKey == wKey);
return bRet;
return bRet;
}
////////////////////////////////////////////////////////////////////////
//
//
DWORD CAccelsOb::GetData()
{
BYTE cLocalCodes = 0;
if (m_bLocked)
cLocalCodes = DEFAULT_ACCEL;
else
cLocalCodes = USER_ACCEL;
BYTE cLocalCodes = 0;
if (m_bLocked)
cLocalCodes = DEFAULT_ACCEL;
else
cLocalCodes = USER_ACCEL;
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
return MAKELONG(m_wKey, bCodes);
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
return MAKELONG(m_wKey, bCodes);
}
////////////////////////////////////////////////////////////////////////
//
//
bool CAccelsOb::SetData(DWORD dwDatas)
{
m_wKey = LOWORD(dwDatas);
m_wKey = LOWORD(dwDatas);
WORD bCodes = HIWORD(dwDatas);
m_cVirt = LOBYTE(bCodes);
WORD bCodes = HIWORD(dwDatas);
m_cVirt = LOBYTE(bCodes);
BYTE cLocalCodes = HIBYTE(bCodes);
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
return true;
BYTE cLocalCodes = HIBYTE(bCodes);
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
return true;
}
////////////////////////////////////////////////////////////////////////
@ -345,7 +331,7 @@ bool CAccelsOb::SetData(DWORD dwDatas)
//
void CAccelsOb::AssertValid() const
{
CObject::AssertValid();
CObject::AssertValid();
}
////////////////////////////////////////////////////////////////////////
@ -353,10 +339,9 @@ void CAccelsOb::AssertValid() const
//
void CAccelsOb::Dump(CDumpContext& dc) const
{
dc << "\t\t";
CObject::Dump(dc);
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
dc << "\t\t";
CObject::Dump(dc);
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
}
#endif
@ -369,47 +354,43 @@ CCmdAccelOb::CCmdAccelOb()
{
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
{
ASSERT(szCommand != NULL);
ASSERT(szCommand != NULL);
m_wIDCommand = wIDCommand;
m_szCommand = szCommand;
m_wIDCommand = wIDCommand;
m_szCommand = szCommand;
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
{
ASSERT(szCommand != NULL);
ASSERT(szCommand != NULL);
m_wIDCommand = wIDCommand;
m_szCommand = szCommand;
m_wIDCommand = wIDCommand;
m_szCommand = szCommand;
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb::~CCmdAccelOb()
{
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL)
delete m_Accels.GetNext(pos);
m_Accels.RemoveAll();
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL)
delete m_Accels.GetNext(pos);
m_Accels.RemoveAll();
}
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
@ -417,76 +398,72 @@ CCmdAccelOb::~CCmdAccelOb()
//
void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
{
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Add(CAccelsOb* pAccel)
{
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
////////////////////////////////////////////////////////////////////////
//
//
CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
{
Reset();
Reset();
m_wIDCommand = from.m_wIDCommand;
m_szCommand = from.m_szCommand;
m_wIDCommand = from.m_wIDCommand;
m_szCommand = from.m_szCommand;
CAccelsOb* pAccel;
POSITION pos = from.m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = DEBUG_NEW CAccelsOb(from.m_Accels.GetNext(pos));
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
return *this;
CAccelsOb* pAccel;
POSITION pos = from.m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = DEBUG_NEW CAccelsOb(from.m_Accels.GetNext(pos));
ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel);
}
return *this;
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::DeleteUserAccels()
{
CAccelsOb* pAccel;
POSITION prevPos;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
prevPos = pos;
pAccel = m_Accels.GetNext(pos);
if (!pAccel->m_bLocked) {
delete pAccel;
m_Accels.RemoveAt(prevPos);
CAccelsOb* pAccel;
POSITION prevPos;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
prevPos = pos;
pAccel = m_Accels.GetNext(pos);
if (!pAccel->m_bLocked) {
delete pAccel;
m_Accels.RemoveAt(prevPos);
}
}
}
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Reset()
{
m_wIDCommand = 0;
m_szCommand = "Empty command";
m_wIDCommand = 0;
m_szCommand = "Empty command";
CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = m_Accels.GetNext(pos);
delete pAccel;
}
CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = m_Accels.GetNext(pos);
delete pAccel;
}
}
////////////////////////////////////////////////////////////////////////
@ -497,31 +474,30 @@ void CCmdAccelOb::Reset()
//
void CCmdAccelOb::AssertValid() const
{
// call base class function first
CObject::AssertValid();
// call base class function first
CObject::AssertValid();
}
////////////////////////////////////////////////////////////////////////
//
//
void CCmdAccelOb::Dump( CDumpContext& dc ) const
void CCmdAccelOb::Dump(CDumpContext& dc) const
{
// call base class function first
dc << "\t";
CObject::Dump( dc );
// call base class function first
dc << "\t";
CObject::Dump(dc);
// now do the stuff for our specific class
dc << "\tIDCommand = " << m_wIDCommand;
dc << "\n\tszCommand = " << m_szCommand;
dc << "\n\tAccelerators = {\n";
// now do the stuff for our specific class
dc << "\tIDCommand = " << m_wIDCommand;
dc << "\n\tszCommand = " << m_szCommand;
dc << "\n\tAccelerators = {\n";
CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = m_Accels.GetNext(pos);
dc << pAccel;
}
dc << "\t}\n";
CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) {
pAccel = m_Accels.GetNext(pos);
dc << pAccel;
}
dc << "\t}\n";
}
#endif

View File

@ -34,8 +34,8 @@
//
//
typedef struct tagMAPVIRTKEYS {
WORD wKey;
TCHAR szKey[15];
WORD wKey;
TCHAR szKey[15];
} MAPVIRTKEYS, *PMAPVIRTKEYS;
////////////////////////////////////////////////////////////////////////
@ -46,65 +46,63 @@ typedef struct tagMAPVIRTKEYS {
////////////////////////////////////////////////////////////////////////
//
//
class CAccelsOb : public CObject
{
public:
CAccelsOb();
CAccelsOb(CAccelsOb *pFrom);
CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false);
CAccelsOb(LPACCEL pACCEL);
class CAccelsOb : public CObject {
public:
CAccelsOb();
CAccelsOb(CAccelsOb* pFrom);
CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false);
CAccelsOb(LPACCEL pACCEL);
public:
CAccelsOb &operator=(const CAccelsOb &from);
public:
CAccelsOb& operator=(const CAccelsOb& from);
void GetString(CString &szBuffer);
bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift);
DWORD GetData();
bool SetData(DWORD dwDatas);
void GetString(CString& szBuffer);
bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift);
DWORD GetData();
bool SetData(DWORD dwDatas);
public:
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
public:
BYTE m_cVirt;
WORD m_wKey;
bool m_bLocked;
public:
BYTE m_cVirt;
WORD m_wKey;
bool m_bLocked;
};
//////////////////////////////////////////////////////////////////////
//
//
class CCmdAccelOb : public CObject
{
public:
CCmdAccelOb();
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand,
bool bLocked = false);
~CCmdAccelOb();
class CCmdAccelOb : public CObject {
public:
CCmdAccelOb();
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand,
bool bLocked = false);
~CCmdAccelOb();
public:
void Add(CAccelsOb *pAccel);
void Add(BYTE cVirt, WORD wKey, bool bLocked = false);
void Reset();
void DeleteUserAccels();
public:
void Add(CAccelsOb* pAccel);
void Add(BYTE cVirt, WORD wKey, bool bLocked = false);
void Reset();
void DeleteUserAccels();
CCmdAccelOb &operator=(const CCmdAccelOb &from);
CCmdAccelOb& operator=(const CCmdAccelOb& from);
public:
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
public:
WORD m_wIDCommand;
CString m_szCommand;
public:
WORD m_wIDCommand;
CString m_szCommand;
CList<CAccelsOb *, CAccelsOb *&> m_Accels;
CList<CAccelsOb*, CAccelsOb*&> m_Accels;
};
////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
#include "ColorButton.h"
#include "stdafx.h"
#include "vba.h"
#include "ColorButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -15,85 +15,83 @@ bool ColorButton::isRegistered = false;
ColorButton::ColorButton()
{
color = 0;
registerClass();
color = 0;
registerClass();
}
ColorButton::~ColorButton()
{
}
BEGIN_MESSAGE_MAP(ColorButton, CButton)
//{{AFX_MSG_MAP(ColorButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(ColorButton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// ColorButton message handlers
void ColorButton::PreSubclassWindow()
{
SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW);
CWnd::PreSubclassWindow();
SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW);
CWnd::PreSubclassWindow();
}
void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(lpDrawItemStruct);
ASSERT(lpDrawItemStruct);
int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7;
int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7;
HDC dc = lpDrawItemStruct->hDC;
UINT state = lpDrawItemStruct->itemState;
RECT rect = lpDrawItemStruct->rcItem;
HDC dc = lpDrawItemStruct->hDC;
UINT state = lpDrawItemStruct->itemState;
RECT rect = lpDrawItemStruct->rcItem;
SIZE margins;
margins.cx = ::GetSystemMetrics(SM_CXEDGE);
margins.cy = ::GetSystemMetrics(SM_CYEDGE);
SIZE margins;
margins.cx = ::GetSystemMetrics(SM_CXEDGE);
margins.cy = ::GetSystemMetrics(SM_CYEDGE);
if(GetState() & BST_PUSHED)
DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT);
else
DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
if (GetState() & BST_PUSHED)
DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT);
else
DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
InflateRect(&rect, -margins.cx, -margins.cy);
InflateRect(&rect, -margins.cx, -margins.cy);
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ?
::GetSysColor(COLOR_3DFACE) : RGB(r,g,b));
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? ::GetSysColor(COLOR_3DFACE) : RGB(r, g, b));
FillRect(dc, &rect, br);
FillRect(dc, &rect, br);
if(state & ODS_FOCUS) {
InflateRect(&rect, -1, -1);
DrawFocusRect(dc, &rect);
}
if (state & ODS_FOCUS) {
InflateRect(&rect, -1, -1);
DrawFocusRect(dc, &rect);
}
DeleteObject(br);
DeleteObject(br);
}
void ColorButton::setColor(u16 c)
{
color = c;
Invalidate();
color = c;
Invalidate();
}
void ColorButton::registerClass()
{
if(!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaColorButton";
AfxRegisterClass(&wc);
isRegistered = true;
}
if (!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaColorButton";
AfxRegisterClass(&wc);
isRegistered = true;
}
}

View File

@ -11,41 +11,40 @@
/////////////////////////////////////////////////////////////////////////////
// ColorButton window
class ColorButton : public CButton
{
// Construction
public:
ColorButton();
class ColorButton : public CButton {
// Construction
public:
ColorButton();
// Attributes
public:
// Operations
static bool isRegistered;
// Attributes
public:
// Operations
static bool isRegistered;
public:
void PreSubclassWindow();
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
public:
void PreSubclassWindow();
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorButton)
//}}AFX_VIRTUAL
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorButton)
//}}AFX_VIRTUAL
// Implementation
public:
void setColor(u16 c);
u16 color;
virtual ~ColorButton();
// Implementation
public:
void setColor(u16 c);
u16 color;
virtual ~ColorButton();
void registerClass();
void registerClass();
// Generated message map functions
protected:
//{{AFX_MSG(ColorButton)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Generated message map functions
protected:
//{{AFX_MSG(ColorButton)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
#include "ColorControl.h"
#include "stdafx.h"
#include "vba.h"
#include "ColorControl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -15,68 +15,66 @@ bool ColorControl::isRegistered = false;
ColorControl::ColorControl()
{
color = 0;
registerClass();
color = 0;
registerClass();
}
ColorControl::~ColorControl()
{
}
BEGIN_MESSAGE_MAP(ColorControl, CWnd)
//{{AFX_MSG_MAP(ColorControl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//{{AFX_MSG_MAP(ColorControl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// ColorControl message handlers
void ColorControl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CPaintDC dc(this); // device context for painting
}
BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
{
int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7;
int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7;
CBrush br;
br.CreateSolidBrush(RGB(r,g,b));
CBrush br;
br.CreateSolidBrush(RGB(r, g, b));
RECT rect;
GetClientRect(&rect);
pDC->FillRect(&rect,&br);
pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
br.DeleteObject();
return TRUE;
RECT rect;
GetClientRect(&rect);
pDC->FillRect(&rect, &br);
pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
br.DeleteObject();
return TRUE;
}
void ColorControl::setColor(u16 c)
{
color = c;
Invalidate();
color = c;
Invalidate();
}
void ColorControl::registerClass()
{
if(!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaColorControl";
AfxRegisterClass(&wc);
isRegistered = true;
}
if (!isRegistered) {
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "VbaColorControl";
AfxRegisterClass(&wc);
isRegistered = true;
}
}

View File

@ -11,39 +11,38 @@
/////////////////////////////////////////////////////////////////////////////
// ColorControl window
class ColorControl : public CWnd
{
// Construction
public:
ColorControl();
class ColorControl : public CWnd {
// Construction
public:
ColorControl();
// Attributes
public:
// Operations
static bool isRegistered;
// Attributes
public:
// Operations
static bool isRegistered;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorControl)
//}}AFX_VIRTUAL
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ColorControl)
//}}AFX_VIRTUAL
// Implementation
public:
void setColor(u16 c);
u16 color;
virtual ~ColorControl();
// Implementation
public:
void setColor(u16 c);
u16 color;
virtual ~ColorControl();
// Generated message map functions
protected:
//{{AFX_MSG(ColorControl)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void registerClass();
// Generated message map functions
protected:
//{{AFX_MSG(ColorControl)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void registerClass();
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,232 +1,231 @@
#include "stdafx.h"
#include "AcceleratorManager.h"
#include "resource.h"
#include "stdafx.h"
#include <afxres.h>
#include <afxtempl.h> // MFC Templates extension
#include <afxtempl.h> // MFC Templates extension
#ifndef CMapStringToWord
typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord;
typedef CMap<CString, LPCSTR, WORD, WORD&> CMapStringToWord;
#endif
static CMapStringToWord winAccelStrings;
static bool initialized = false;
struct {
const char *command;
WORD id;
const char* command;
WORD id;
} winAccelCommands[] = {
{ "FileOpenGBA", ID_FILE_OPEN_GBA },
{ "FileOpenGBC", ID_FILE_OPEN_GBC },
{ "FileOpenGB", ID_FILE_OPEN_GB },
{ "FileLoadDotCode", ID_FILE_LOAD_DOTCODE },
{ "FileSaveDotCode", ID_FILE_SAVE_DOTCODE },
{ "FileLoad", ID_FILE_LOAD },
{ "FileSave", ID_FILE_SAVE },
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
{ "FileRecentReset", ID_FILE_RECENT_RESET },
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
{ "FileRecent01", ID_FILE_MRU_FILE1 },
{ "FileRecent02", ID_FILE_MRU_FILE2 },
{ "FileRecent03", ID_FILE_MRU_FILE3 },
{ "FileRecent04", ID_FILE_MRU_FILE4 },
{ "FileRecent05", ID_FILE_MRU_FILE5 },
{ "FileRecent06", ID_FILE_MRU_FILE6 },
{ "FileRecent07", ID_FILE_MRU_FILE7 },
{ "FileRecent08", ID_FILE_MRU_FILE8 },
{ "FileRecent09", ID_FILE_MRU_FILE9 },
{ "FileRecent10", ID_FILE_MRU_FILE10 },
{ "FilePause", ID_FILE_PAUSE },
{ "FileReset", ID_FILE_RESET },
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
{ "FileImportGamesharkActionReplaySnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
{ "FileToggleFullscreen", ID_FILE_TOGGLEMENU },
{ "FileClose", ID_FILE_CLOSE },
{ "FileExit", ID_FILE_EXIT },
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
{ "OptionsVideoX5", ID_OPTIONS_VIDEO_X5 },
{ "OptionsVideoX6", ID_OPTIONS_VIDEO_X6 },
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
{ "OptionsVideoLayersBG0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
{ "OptionsVideoLayersBG1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
{ "OptionsVideoLayersBG2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
{ "OptionsVideoLayersBG3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
{ "OptionsVideoLayersReset", ID_OPTIONS_VIDEO_LAYERS_RESET },
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
{ "OptionsEmulatorGameOverrides", ID_OPTIONS_EMULATOR_GAMEOVERRIDES },
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorSaveDetectNow", ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW },
{ "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
{ "OptionsFilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL },
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
{ "OptionsFilterxBRZ2x", ID_OPTIONS_FILTER_XBRZ2X },
{ "OptionsFilterxBRZ3x", ID_OPTIONS_FILTER_XBRZ3X },
{ "OptionsFilterxBRZ4x", ID_OPTIONS_FILTER_XBRZ4X },
{ "OptionsFilterxBRZ5x", ID_OPTIONS_FILTER_XBRZ5X },
{ "OptionsFilterxBRZ6x", ID_OPTIONS_FILTER_XBRZ6X },
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
{ "CheatsList", ID_CHEATS_CHEATLIST },
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
{ "ToolsDebugGDBConfigurePort", ID_TOOLS_DEBUG_CONFIGUREPORT },
{ "ToolsDebugGDBBreakOnLoad", ID_TOOLS_DEBUG_BREAKONLOAD },
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
{ "ToolsLogging", ID_TOOLS_LOGGING },
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
{ "ToolsRewind", ID_TOOLS_REWIND },
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
{ "HelpBugReport", ID_HELP_BUGREPORT },
{ "HelpFAQ", ID_HELP_FAQ },
{ "HelpAbout", ID_HELP_ABOUT },
{ "SystemMinimize", ID_SYSTEM_MINIMIZE }
{ "FileOpenGBA", ID_FILE_OPEN_GBA },
{ "FileOpenGBC", ID_FILE_OPEN_GBC },
{ "FileOpenGB", ID_FILE_OPEN_GB },
{ "FileLoadDotCode", ID_FILE_LOAD_DOTCODE },
{ "FileSaveDotCode", ID_FILE_SAVE_DOTCODE },
{ "FileLoad", ID_FILE_LOAD },
{ "FileSave", ID_FILE_SAVE },
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
{ "FileRecentReset", ID_FILE_RECENT_RESET },
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
{ "FileRecent01", ID_FILE_MRU_FILE1 },
{ "FileRecent02", ID_FILE_MRU_FILE2 },
{ "FileRecent03", ID_FILE_MRU_FILE3 },
{ "FileRecent04", ID_FILE_MRU_FILE4 },
{ "FileRecent05", ID_FILE_MRU_FILE5 },
{ "FileRecent06", ID_FILE_MRU_FILE6 },
{ "FileRecent07", ID_FILE_MRU_FILE7 },
{ "FileRecent08", ID_FILE_MRU_FILE8 },
{ "FileRecent09", ID_FILE_MRU_FILE9 },
{ "FileRecent10", ID_FILE_MRU_FILE10 },
{ "FilePause", ID_FILE_PAUSE },
{ "FileReset", ID_FILE_RESET },
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
{ "FileImportGamesharkActionReplaySnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
{ "FileToggleFullscreen", ID_FILE_TOGGLEMENU },
{ "FileClose", ID_FILE_CLOSE },
{ "FileExit", ID_FILE_EXIT },
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
{ "OptionsVideoX5", ID_OPTIONS_VIDEO_X5 },
{ "OptionsVideoX6", ID_OPTIONS_VIDEO_X6 },
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
{ "OptionsVideoLayersBG0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
{ "OptionsVideoLayersBG1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
{ "OptionsVideoLayersBG2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
{ "OptionsVideoLayersBG3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
{ "OptionsVideoLayersReset", ID_OPTIONS_VIDEO_LAYERS_RESET },
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
{ "OptionsEmulatorGameOverrides", ID_OPTIONS_EMULATOR_GAMEOVERRIDES },
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
{ "OptionsEmulatorSaveDetectNow", ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW },
{ "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
{ "OptionsFilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL },
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
{ "OptionsFilterxBRZ2x", ID_OPTIONS_FILTER_XBRZ2X },
{ "OptionsFilterxBRZ3x", ID_OPTIONS_FILTER_XBRZ3X },
{ "OptionsFilterxBRZ4x", ID_OPTIONS_FILTER_XBRZ4X },
{ "OptionsFilterxBRZ5x", ID_OPTIONS_FILTER_XBRZ5X },
{ "OptionsFilterxBRZ6x", ID_OPTIONS_FILTER_XBRZ6X },
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
{ "CheatsList", ID_CHEATS_CHEATLIST },
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
{ "ToolsDebugGDBConfigurePort", ID_TOOLS_DEBUG_CONFIGUREPORT },
{ "ToolsDebugGDBBreakOnLoad", ID_TOOLS_DEBUG_BREAKONLOAD },
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
{ "ToolsLogging", ID_TOOLS_LOGGING },
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
{ "ToolsRewind", ID_TOOLS_REWIND },
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
{ "HelpBugReport", ID_HELP_BUGREPORT },
{ "HelpFAQ", ID_HELP_FAQ },
{ "HelpAbout", ID_HELP_ABOUT },
{ "SystemMinimize", ID_SYSTEM_MINIMIZE }
};
bool winAccelGetID(const char *command, WORD& id)
bool winAccelGetID(const char* command, WORD& id)
{
if(!initialized) {
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
if (!initialized) {
int count = sizeof(winAccelCommands) / sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) {
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
for (int i = 0; i < count; i++) {
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
}
initialized = true;
}
initialized = true;
}
return winAccelStrings.Lookup(command, id) ? true : false;
return winAccelStrings.Lookup(command, id) ? true : false;
}
void winAccelAddCommands(CAcceleratorManager& mgr)
{
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) {
if(!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
}
int count = sizeof(winAccelCommands) / sizeof(winAccelCommands[0]);
for (int i = 0; i < count; i++) {
if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,13 @@
#include "stdafx.h"
#include "VBA.h"
#include "Input.h"
#include "Reg.h"
#include "VBA.h"
#include "WinResUtil.h"
#include "stdafx.h"
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#pragma comment( lib, "dinput8" )
#pragma comment( lib, "dxguid" )
#pragma comment(lib, "dinput8")
#pragma comment(lib, "dxguid")
#ifdef _DEBUG
#define new DEBUG_NEW
@ -16,13 +15,13 @@
static char THIS_FILE[] = __FILE__;
#endif
extern void directXMessage(const char *);
extern void winlog(const char *msg,...);
extern void directXMessage(const char*);
extern void winlog(const char* msg, ...);
#define POV_UP 1
#define POV_DOWN 2
#define POV_UP 1
#define POV_DOWN 2
#define POV_RIGHT 4
#define POV_LEFT 8
#define POV_LEFT 8
class DirectInput : public Input {
public:
@ -61,156 +60,147 @@ struct deviceInfo {
};
};
static deviceInfo *currentDevice = NULL;
static deviceInfo* currentDevice = NULL;
static int numDevices = 1;
static deviceInfo *pDevices = NULL;
static deviceInfo* pDevices = NULL;
static LPDIRECTINPUT8 pDirectInput = NULL;
static int axisNumber = 0;
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] =
{
DIK_LEFT, DIK_RIGHT,
DIK_UP, DIK_DOWN,
DIK_X, DIK_Z,
DIK_RETURN,DIK_BACK,
DIK_A, DIK_S,
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] = {
DIK_LEFT, DIK_RIGHT,
DIK_UP, DIK_DOWN,
DIK_X, DIK_Z,
DIK_RETURN, DIK_BACK,
DIK_A, DIK_S,
DIK_SPACE, DIK_F12,
DIK_C,
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,
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, "");
int curPos= 0;
CString TxtKeyList = regQueryStringValue(name, "");
int curPos = 0;
CString resToken=TxtKeyList.Tokenize(",",curPos);
while (resToken != "")
{
Keys.AddTail(atoi(resToken));
resToken= TxtKeyList.Tokenize(",",curPos);
};
CString resToken = TxtKeyList.Tokenize(",", curPos);
while (resToken != "") {
Keys.AddTail(atoi(resToken));
resToken = TxtKeyList.Tokenize(",", curPos);
};
}
void winReadKey(const char *name, int num, KeyList& Keys)
void winReadKey(const char* name, int num, KeyList& Keys)
{
char buffer[80];
char buffer[80];
sprintf(buffer, "Joy%d_%s", num, name);
winReadKey(buffer, Keys);
sprintf(buffer, "Joy%d_%s", num, name);
winReadKey(buffer, Keys);
}
void winReadKeys()
{
for(int i = 0; i < JOYPADS; i++) {
winReadKey("Left", i, theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]);
winReadKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
winReadKey("Up", i, theApp.input->joypaddata[JOYPAD(i,KEY_UP)]);
winReadKey("Down", i, theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]);
winReadKey("A", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]);
winReadKey("B", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]);
winReadKey("L", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]);
winReadKey("R", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]);
winReadKey("Start", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]);
winReadKey("Select", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]);
winReadKey("Speed", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]);
winReadKey("Capture", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]);
winReadKey("GS", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]);
}
winReadKey("Motion_Left", theApp.input->joypaddata[MOTION(KEY_LEFT)]);
winReadKey("Motion_Right", theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
winReadKey("Motion_Up", theApp.input->joypaddata[MOTION(KEY_UP)]);
winReadKey("Motion_Down", theApp.input->joypaddata[MOTION(KEY_DOWN)]);
for (int i = 0; i < JOYPADS; i++) {
winReadKey("Left", i, theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]);
winReadKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
winReadKey("Up", i, theApp.input->joypaddata[JOYPAD(i, KEY_UP)]);
winReadKey("Down", i, theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]);
winReadKey("A", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]);
winReadKey("B", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]);
winReadKey("L", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]);
winReadKey("R", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]);
winReadKey("Start", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]);
winReadKey("Select", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]);
winReadKey("Speed", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]);
winReadKey("Capture", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]);
winReadKey("GS", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]);
}
winReadKey("Motion_Left", theApp.input->joypaddata[MOTION(KEY_LEFT)]);
winReadKey("Motion_Right", theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
winReadKey("Motion_Up", theApp.input->joypaddata[MOTION(KEY_UP)]);
winReadKey("Motion_Down", theApp.input->joypaddata[MOTION(KEY_DOWN)]);
}
void winSaveKey(char *name, KeyList& value)
void winSaveKey(char* name, KeyList& value)
{
CString txtKeys;
CString txtKeys;
POSITION p = value.GetHeadPosition();
while(p!=NULL)
{
CString tmp;
tmp.Format("%d", value.GetNext(p));
txtKeys+=tmp;
if (p!=NULL)
txtKeys+=",";
}
regSetStringValue(name, txtKeys);
POSITION p = value.GetHeadPosition();
while (p != NULL) {
CString tmp;
tmp.Format("%d", value.GetNext(p));
txtKeys += tmp;
if (p != NULL)
txtKeys += ",";
}
regSetStringValue(name, txtKeys);
}
static void winSaveKey(char *name, int num, KeyList& value)
static void winSaveKey(char* name, int num, KeyList& value)
{
char buffer[80];
char buffer[80];
sprintf(buffer, "Joy%d_%s", num, name);
winSaveKey(buffer, value);
sprintf(buffer, "Joy%d_%s", num, name);
winSaveKey(buffer, value);
}
void winSaveKeys()
{
for(int i = 0; i < JOYPADS; i++) {
winSaveKey("Left", i, theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]);
winSaveKey("Right", i, theApp.input->joypaddata[JOYPAD(i,KEY_RIGHT)]);
winSaveKey("Up", i, theApp.input->joypaddata[JOYPAD(i,KEY_UP)]);
winSaveKey("Speed", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]);
winSaveKey("Capture", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]);
winSaveKey("GS", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]);
winSaveKey("Down", i, theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]);
winSaveKey("A", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]);
winSaveKey("B", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]);
winSaveKey("L", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]);
winSaveKey("R", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]);
winSaveKey("Start", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]);
winSaveKey("Select", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]);
}
regSetDwordValue("joyVersion", 1);
for (int i = 0; i < JOYPADS; i++) {
winSaveKey("Left", i, theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]);
winSaveKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
winSaveKey("Up", i, theApp.input->joypaddata[JOYPAD(i, KEY_UP)]);
winSaveKey("Speed", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]);
winSaveKey("Capture", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]);
winSaveKey("GS", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]);
winSaveKey("Down", i, theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]);
winSaveKey("A", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]);
winSaveKey("B", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]);
winSaveKey("L", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]);
winSaveKey("R", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]);
winSaveKey("Start", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]);
winSaveKey("Select", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]);
}
regSetDwordValue("joyVersion", 1);
winSaveKey("Motion_Left",
theApp.input->joypaddata[MOTION(KEY_LEFT)]);
winSaveKey("Motion_Right",
theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
winSaveKey("Motion_Up",
theApp.input->joypaddata[MOTION(KEY_UP)]);
winSaveKey("Motion_Down",
theApp.input->joypaddata[MOTION(KEY_DOWN)]);
winSaveKey("Motion_Left",
theApp.input->joypaddata[MOTION(KEY_LEFT)]);
winSaveKey("Motion_Right",
theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
winSaveKey("Motion_Up",
theApp.input->joypaddata[MOTION(KEY_UP)]);
winSaveKey("Motion_Down",
theApp.input->joypaddata[MOTION(KEY_DOWN)]);
}
static BOOL CALLBACK EnumPovsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
VOID* pContext )
static BOOL CALLBACK EnumPovsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi,
VOID* pContext)
{
return DIENUM_CONTINUE;
}
static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
LPVOID lpvContext)
LPVOID lpvContext)
{
ZeroMemory(&pDevices[numDevices],sizeof(deviceInfo));
ZeroMemory(&pDevices[numDevices], sizeof(deviceInfo));
HRESULT hRet = pDirectInput->CreateDevice(pInst->guidInstance,
&pDevices[numDevices].device,
NULL);
&pDevices[numDevices].device,
NULL);
if (hRet != DI_OK)
return DIENUM_STOP;
DIDEVCAPS caps;
caps.dwSize=sizeof(DIDEVCAPS);
caps.dwSize = sizeof(DIDEVCAPS);
hRet = pDevices[numDevices].device->GetCapabilities(&caps);
if (hRet == DI_OK) {
if (caps.dwFlags & DIDC_POLLEDDATAFORMAT ||
caps.dwFlags & DIDC_POLLEDDEVICE)
if (caps.dwFlags & DIDC_POLLEDDATAFORMAT || caps.dwFlags & DIDC_POLLEDDEVICE)
pDevices[numDevices].isPolled = TRUE;
pDevices[numDevices].nButtons = caps.dwButtons;
@ -224,15 +214,13 @@ static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
}
}
numDevices++;
return DIENUM_CONTINUE;
}
BOOL CALLBACK DIEnumDevicesCallback2(LPCDIDEVICEINSTANCE pInst,
LPVOID lpvContext)
LPVOID lpvContext)
{
numDevices++;
@ -257,37 +245,34 @@ static int getPovState(DWORD value)
static void checkKeys()
{
LONG_PTR dev = 0;
int i;
LONG_PTR dev = 0;
int i;
for(i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++)
{
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
theApp.input->joypaddata[i].AddTail(defvalues[i]);
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
while(p!=NULL)
{
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
if (k > 0 && DEVICEOF(k) < numDevices)
pDevices[DEVICEOF(k)].needed = true;
}
}
for (i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++) {
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
theApp.input->joypaddata[i].AddTail(defvalues[i]);
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
while (p != NULL) {
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
if (k > 0 && DEVICEOF(k) < numDevices)
pDevices[DEVICEOF(k)].needed = true;
}
}
}
#define KEYDOWN(buffer,key) (buffer[key] & 0x80)
#define KEYDOWN(buffer, key) (buffer[key] & 0x80)
static bool readKeyboard()
{
if (pDevices[0].needed) {
HRESULT hret = pDevices[0].device->
GetDeviceState(256,
(LPVOID)pDevices[0].data);
HRESULT hret = pDevices[0].device->GetDeviceState(256,
(LPVOID)pDevices[0].data);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
hret = pDevices[0].device->Acquire();
if (hret != DI_OK)
return false;
hret = pDevices[0].device->GetDeviceState(256,(LPVOID)pDevices[0].data);
hret = pDevices[0].device->GetDeviceState(256, (LPVOID)pDevices[0].data);
}
return hret == DI_OK;
@ -301,9 +286,8 @@ static bool readJoystick(int joy)
if (pDevices[joy].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
HRESULT hret = pDevices[joy].device->
GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state);
HRESULT hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
hret = pDevices[joy].device->Acquire();
@ -313,9 +297,8 @@ static bool readJoystick(int joy)
if (pDevices[joy].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
hret = pDevices[joy].device->
GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state);
hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
(LPVOID)&pDevices[joy].state);
}
}
@ -337,8 +320,7 @@ static void checkKeyboard()
return;
}
hret = pDevices[0].device->
GetDeviceState(256, (LPVOID)keystate);
hret = pDevices[0].device->GetDeviceState(256, (LPVOID)keystate);
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
return;
@ -346,9 +328,10 @@ static void checkKeyboard()
if (hret == DI_OK) {
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)) {
SendMessage(GetFocus(), JOYCONFIG_MESSAGE,0,i);
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, 0, i);
break;
}
}
@ -360,18 +343,17 @@ static void checkJoypads()
{
DIDEVICEOBJECTINSTANCE di;
ZeroMemory(&di,sizeof(DIDEVICEOBJECTINSTANCE));
ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
int i =0;
int i = 0;
DIJOYSTATE joystick;
for (i = 1; i < numDevices; i++) {
HRESULT hret = pDevices[i].device->Acquire();
if (pDevices[i].isPolled)
((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll();
@ -387,10 +369,11 @@ static void checkJoypads()
for (j = 0; j < pDevices[i].nButtons; j++) {
if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j])
& joystick.rgbButtons[j]) & 0x80) {
& joystick.rgbButtons[j])
& 0x80) {
HWND focus = GetFocus();
SendMessage(focus, JOYCONFIG_MESSAGE, i,j+128);
SendMessage(focus, JOYCONFIG_MESSAGE, i, j + 128);
}
}
@ -398,30 +381,30 @@ static void checkJoypads()
LONG value = pDevices[i].axis[j].center;
LONG old = 0;
const DWORD offset = pDevices[i].axis[j].offset;
value = *(LONG*)(((char*)&joystick.lX) + offset);
old = *(LONG*)(((char*)&pDevices[i].state.lX) + offset);
const DWORD offset = pDevices[i].axis[j].offset;
value = *(LONG*)(((char*)&joystick.lX) + offset);
old = *(LONG*)(((char*)&pDevices[i].state.lX) + offset);
if (value != old) {
if (value < pDevices[i].axis[j].negative)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<1));
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 1));
else if (value > pDevices[i].axis[j].positive)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<1)+1);
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 1) + 1);
}
}
for (j = 0;j < 4 && j < pDevices[i].nPovs; j++) {
for (j = 0; j < 4 && j < pDevices[i].nPovs; j++) {
if (LOWORD(pDevices[i].state.rgdwPOV[j]) != LOWORD(joystick.rgdwPOV[j])) {
int state = getPovState(joystick.rgdwPOV[j]);
if (state & POV_UP)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x20);
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x20);
else if (state & POV_DOWN)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x21);
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x21);
else if (state & POV_RIGHT)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x22);
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x22);
else if (state & POV_LEFT)
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x23);
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j << 2) + 0x23);
}
}
@ -436,15 +419,15 @@ BOOL checkKey(LONG_PTR key)
LONG_PTR k = (key & 255);
if (dev == 0) {
return KEYDOWN(pDevices[0].data,k);
} else if (dev >= numDevices) {
return FALSE;
} else {
return KEYDOWN(pDevices[0].data, k);
} else if (dev >= numDevices) {
return FALSE;
} else {
if (k < 16) {
LONG_PTR axis = k >> 1;
LONG value = pDevices[dev].axis[axis].center;
value = *(LONG*)(((char*)&pDevices[dev].state.lX) + pDevices[dev].axis[axis].offset);
value = *(LONG*)(((char*)&pDevices[dev].state.lX) + pDevices[dev].axis[axis].offset);
if (k & 1)
return value > pDevices[dev].axis[axis].positive;
@ -454,26 +437,25 @@ BOOL checkKey(LONG_PTR key)
int state = getPovState(pDevices[dev].state.rgdwPOV[hat]);
BOOL res = FALSE;
res = state & (1 << (k & 3));
res = state & (1 << (k & 3));
return res;
} else if (k >= 128) {
return pDevices[dev].state.rgbButtons[k-128] & 0x80;
} else if (k >= 128) {
return pDevices[dev].state.rgbButtons[k - 128] & 0x80;
}
}
return FALSE;
}
BOOL checkKey(KeyList &k)
BOOL checkKey(KeyList& k)
{
POSITION p = k.GetHeadPosition();
while(p!=NULL)
{
if (checkKey(k.GetNext(p)))
return TRUE;
}
return FALSE;
POSITION p = k.GetHeadPosition();
while (p != NULL) {
if (checkKey(k.GetNext(p)))
return TRUE;
}
return FALSE;
}
DirectInput::DirectInput()
@ -485,7 +467,7 @@ DirectInput::~DirectInput()
saveSettings();
if (pDirectInput != NULL) {
if (pDevices) {
for (int i = 0; i < numDevices ; i++) {
for (int i = 0; i < numDevices; i++) {
if (pDevices[i].device) {
pDevices[i].device->Unacquire();
pDevices[i].device->Release();
@ -503,44 +485,40 @@ DirectInput::~DirectInput()
bool DirectInput::initialize()
{
HRESULT hr;
hr = DirectInput8Create(
GetModuleHandle( NULL ),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(LPVOID *)&pDirectInput,
NULL );
ASSERT( hr == DI_OK );
if( hr != DI_OK ) return false;
HRESULT hr;
hr = DirectInput8Create(
GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(LPVOID*)&pDirectInput,
NULL);
ASSERT(hr == DI_OK);
if (hr != DI_OK)
return false;
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
DIEnumDevicesCallback2,
NULL,
DIEDFL_ATTACHEDONLY);
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
DIEnumDevicesCallback2,
NULL,
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);
pDevices[0].isPolled = false;
pDevices[0].needed = true;
pDevices[0].first = true;
pDevices[0].needed = true;
pDevices[0].first = true;
if (hr != DI_OK) {
return false;
}
numDevices = 1;
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
DIEnumDevicesCallback,
NULL,
DIEDFL_ATTACHEDONLY);
DIEnumDevicesCallback,
NULL,
DIEDFL_ATTACHEDONLY);
if (hr != DI_OK) {
return false;
@ -556,45 +534,41 @@ bool DirectInput::initialize()
for (i = 1; i < numDevices; i++) {
pDevices[i].device->SetDataFormat(&c_dfDIJoystick);
pDevices[i].needed = false;
pDevices[i].first = true;
pDevices[i].first = true;
currentDevice = &pDevices[i];
axisNumber = 0;
// get up to 6 axes and 2 sliders
DIPROPRANGE range;
range.diph.dwSize = sizeof(range);
range.diph.dwHeaderSize = sizeof(range.diph);
range.diph.dwHow = DIPH_BYOFFSET;
// get up to 6 axes and 2 sliders
DIPROPRANGE range;
range.diph.dwSize = sizeof(range);
range.diph.dwHeaderSize = sizeof(range.diph);
range.diph.dwHow = DIPH_BYOFFSET;
// screw EnumObjects, just go through all the axis offsets and try to GetProperty
// this should be more foolproof, less code, and probably faster
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG))
{
range.diph.dwObj = offset;
// try to set some nice power of 2 values (8192)
range.lMin = -(1 << 13);
range.lMax = (1 << 13);
pDevices[i].device->SetProperty(DIPROP_RANGE, &range.diph);
// but i guess not all devices support setting range
// so i getproperty right afterward incase it didn't set :P
// this also checks that the axis is present
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph)))
{
const LONG center = (range.lMin + range.lMax)/2;
const LONG threshold = (range.lMax - center)/2;
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG)) {
range.diph.dwObj = offset;
// try to set some nice power of 2 values (8192)
range.lMin = -(1 << 13);
range.lMax = (1 << 13);
pDevices[i].device->SetProperty(DIPROP_RANGE, &range.diph);
// but i guess not all devices support setting range
// so i getproperty right afterward incase it didn't set :P
// this also checks that the axis is present
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph))) {
const LONG center = (range.lMin + range.lMax) / 2;
const LONG threshold = (range.lMax - center) / 2;
currentDevice->axis[axisNumber].center = center;
currentDevice->axis[axisNumber].negative = center - threshold;
currentDevice->axis[axisNumber].positive = center + threshold;
currentDevice->axis[axisNumber].offset = offset;
currentDevice->axis[axisNumber].center = center;
currentDevice->axis[axisNumber].negative = center - threshold;
currentDevice->axis[axisNumber].positive = center + threshold;
currentDevice->axis[axisNumber].offset = offset;
++axisNumber;
}
}
++axisNumber;
}
}
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
currentDevice = NULL;
}
@ -620,71 +594,71 @@ bool DirectInput::readDevices()
u32 DirectInput::readDevice(int which)
{
u32 res = 0;
int i = joypadDefault;
if(which >= 0 && which <= 3)
i = which;
u32 res = 0;
int i = joypadDefault;
if (which >= 0 && which <= 3)
i = which;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]))
res |= 1;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]))
res |= 2;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]))
res |= 4;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]))
res |= 8;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_RIGHT)]))
res |= 16;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]))
res |= 32;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_UP)]))
res |= 64;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]))
res |= 128;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]))
res |= 256;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]))
res |= 512;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]))
res |= 1;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]))
res |= 2;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]))
res |= 4;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]))
res |= 8;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]))
res |= 16;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]))
res |= 32;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_UP)]))
res |= 64;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]))
res |= 128;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]))
res |= 256;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]))
res |= 512;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]))
res |= 4096;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]))
res |= 4096;
if(autoFire) {
res &= (~autoFire);
if(autoFireToggle)
res |= autoFire;
autoFireToggle = !autoFireToggle;
}
// disallow L+R or U+D of being pressed at the same time
if((res & 48) == 48)
res &= ~16;
if((res & 192) == 192)
res &= ~128;
if(movieRecording) {
if(i == joypadDefault) {
if(res != movieLastJoypad) {
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
fwrite(&res, 1, sizeof(res), theApp.movieFile);
movieLastJoypad = res;
}
if (autoFire) {
res &= (~autoFire);
if (autoFireToggle)
res |= autoFire;
autoFireToggle = !autoFireToggle;
}
}
if(moviePlaying) {
if(movieFrame == moviePlayFrame) {
movieLastJoypad = movieNextJoypad;
theApp.movieReadNext();
}
res = movieLastJoypad;
}
// we don't record speed up or screen capture buttons
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]) || speedupToggle)
res |= 1024;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
res |= 2048;
return res;
// disallow L+R or U+D of being pressed at the same time
if ((res & 48) == 48)
res &= ~16;
if ((res & 192) == 192)
res &= ~128;
if (movieRecording) {
if (i == joypadDefault) {
if (res != movieLastJoypad) {
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
fwrite(&res, 1, sizeof(res), theApp.movieFile);
movieLastJoypad = res;
}
}
}
if (moviePlaying) {
if (movieFrame == moviePlayFrame) {
movieLastJoypad = movieNextJoypad;
theApp.movieReadNext();
}
res = movieLastJoypad;
}
// we don't record speed up or screen capture buttons
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]) || speedupToggle)
res |= 1024;
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]))
res |= 2048;
return res;
}
CString DirectInput::getKeyName(LONG_PTR key)
@ -694,31 +668,30 @@ CString DirectInput::getKeyName(LONG_PTR key)
DIDEVICEOBJECTINSTANCE di;
ZeroMemory(&di,sizeof(DIDEVICEOBJECTINSTANCE));
ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
CString winBuffer = winResLoadString(IDS_ERROR);
if (d == 0) {
pDevices[0].device->GetObjectInfo( &di, (DWORD)key, DIPH_BYOFFSET );
pDevices[0].device->GetObjectInfo(&di, (DWORD)key, DIPH_BYOFFSET);
winBuffer = di.tszName;
} else if (d < numDevices) {
if (k < 16)
{
pDevices[d].device->GetObjectInfo(&di,
pDevices[d].axis[k>>1].offset,
DIPH_BYOFFSET);
if (k & 1)
winBuffer.Format("Joy %d %s +", d, di.tszName);
else
winBuffer.Format("Joy %d %s -", d, di.tszName);
} else if (d < numDevices) {
if (k < 16) {
pDevices[d].device->GetObjectInfo(&di,
pDevices[d].axis[k >> 1].offset,
DIPH_BYOFFSET);
if (k & 1)
winBuffer.Format("Joy %d %s +", d, di.tszName);
else
winBuffer.Format("Joy %d %s -", d, di.tszName);
} else if (k < 48) {
LONG_PTR hat = (k >> 2) & 3;
pDevices[d].device->GetObjectInfo(&di,
(DWORD)DIJOFS_POV(hat),
DIPH_BYOFFSET);
char *dir = "up";
(DWORD)DIJOFS_POV(hat),
DIPH_BYOFFSET);
char* dir = "up";
LONG_PTR dd = k & 3;
if (dd == 1)
dir = "down";
@ -729,16 +702,14 @@ CString DirectInput::getKeyName(LONG_PTR key)
winBuffer.Format("Joy %d %s %s", d, di.tszName, dir);
} else {
pDevices[d].device->GetObjectInfo(&di,
(DWORD)DIJOFS_BUTTON(k-128),
DIPH_BYOFFSET);
winBuffer.Format(winResLoadString(IDS_JOY_BUTTON),d,di.tszName);
(DWORD)DIJOFS_BUTTON(k - 128),
DIPH_BYOFFSET);
winBuffer.Format(winResLoadString(IDS_JOY_BUTTON), d, di.tszName);
}
} else {
// Joystick isn't plugged in. We can't decipher k, so just show its value.
winBuffer.Format("Joy %d (%d)", d, k);
}
else
{
// Joystick isn't plugged in. We can't decipher k, so just show its value.
winBuffer.Format("Joy %d (%d)", d, k);
}
return winBuffer;
}
@ -750,65 +721,64 @@ void DirectInput::checkKeys()
void DirectInput::checkMotionKeys()
{
if(checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
sunBars--;
if (sunBars < 1)
sunBars = 1;
if (checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
sunBars--;
if (sunBars < 1)
sunBars = 1;
sensorX += 3;
if(sensorX > 2197)
sensorX = 2197;
if(sensorX < 2047)
sensorX = 2057;
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
sunBars++;
if (sunBars > 100)
sunBars = 100;
sensorX += 3;
if (sensorX > 2197)
sensorX = 2197;
if (sensorX < 2047)
sensorX = 2057;
} else if (checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
sunBars++;
if (sunBars > 100)
sunBars = 100;
sensorX -= 3;
if(sensorX < 1897)
sensorX = 1897;
if(sensorX > 2047)
sensorX = 2037;
} else if(sensorX > 2047) {
sensorX -= 2;
if(sensorX < 2047)
sensorX = 2047;
} else {
sensorX += 2;
if(sensorX > 2047)
sensorX = 2047;
}
sensorX -= 3;
if (sensorX < 1897)
sensorX = 1897;
if (sensorX > 2047)
sensorX = 2037;
} else if (sensorX > 2047) {
sensorX -= 2;
if (sensorX < 2047)
sensorX = 2047;
} else {
sensorX += 2;
if (sensorX > 2047)
sensorX = 2047;
}
if(checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
sensorY += 3;
if(sensorY > 2197)
sensorY = 2197;
if(sensorY < 2047)
sensorY = 2057;
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
sensorY -= 3;
if(sensorY < 1897)
sensorY = 1897;
if(sensorY > 2047)
sensorY = 2037;
} else if(sensorY > 2047) {
sensorY -= 2;
if(sensorY < 2047)
sensorY = 2047;
} else {
sensorY += 2;
if(sensorY > 2047)
sensorY = 2047;
}
if (checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
sensorY += 3;
if (sensorY > 2197)
sensorY = 2197;
if (sensorY < 2047)
sensorY = 2057;
} else if (checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
sensorY -= 3;
if (sensorY < 1897)
sensorY = 1897;
if (sensorY > 2047)
sensorY = 2037;
} else if (sensorY > 2047) {
sensorY -= 2;
if (sensorY < 2047)
sensorY = 2047;
} else {
sensorY += 2;
if (sensorY > 2047)
sensorY = 2047;
}
}
Input *newDirectInput()
Input* newDirectInput()
{
return new DirectInput;
}
void DirectInput::checkDevices()
{
checkJoypads();

View File

@ -10,10 +10,10 @@
// Internals
#include "../System.h"
#include "../common/SoundDriver.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "../gba/Sound.h"
#include "../common/SoundDriver.h"
// DirectSound8
#define DIRECTSOUND_VERSION 0x0800
@ -21,296 +21,284 @@
extern bool soundBufferLow;
class DirectSound : public SoundDriver
{
class DirectSound : public SoundDriver {
private:
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
LPDIRECTSOUNDBUFFER dsbSecondary; // Secondary DirectSound buffer
LPDIRECTSOUNDNOTIFY8 dsbNotify;
HANDLE dsbEvent;
WAVEFORMATEX wfx; // Primary buffer wave format
int soundBufferLen;
int soundBufferTotalLen;
unsigned int soundNextPosition;
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
LPDIRECTSOUNDBUFFER dsbSecondary; // Secondary DirectSound buffer
LPDIRECTSOUNDNOTIFY8 dsbNotify;
HANDLE dsbEvent;
WAVEFORMATEX wfx; // Primary buffer wave format
int soundBufferLen;
int soundBufferTotalLen;
unsigned int soundNextPosition;
public:
DirectSound();
virtual ~DirectSound();
DirectSound();
virtual ~DirectSound();
bool init(long sampleRate); // initialize the primary and secondary sound buffer
void pause(); // pause the secondary sound buffer
void reset(); // stop and reset the secondary sound buffer
void resume(); // resume the secondary sound buffer
void write(u16 * finalWave, int length); // write the emulated sound to the secondary sound buffer
bool init(long sampleRate); // initialize the primary and secondary sound buffer
void pause(); // pause the secondary sound buffer
void reset(); // stop and reset the secondary sound buffer
void resume(); // resume the secondary sound buffer
void write(u16* finalWave, int length); // write the emulated sound to the secondary sound buffer
};
DirectSound::DirectSound()
{
pDirectSound = NULL;
dsbPrimary = NULL;
dsbSecondary = NULL;
dsbNotify = NULL;
dsbEvent = NULL;
pDirectSound = NULL;
dsbPrimary = NULL;
dsbSecondary = NULL;
dsbNotify = NULL;
dsbEvent = NULL;
soundBufferTotalLen = 14700;
soundNextPosition = 0;
soundBufferTotalLen = 14700;
soundNextPosition = 0;
}
DirectSound::~DirectSound()
{
if(dsbNotify) {
dsbNotify->Release();
dsbNotify = NULL;
}
if (dsbNotify) {
dsbNotify->Release();
dsbNotify = NULL;
}
if(dsbEvent) {
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
if (dsbEvent) {
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
if(pDirectSound) {
if(dsbPrimary) {
dsbPrimary->Release();
dsbPrimary = NULL;
}
if (pDirectSound) {
if (dsbPrimary) {
dsbPrimary->Release();
dsbPrimary = NULL;
}
if(dsbSecondary) {
dsbSecondary->Release();
dsbSecondary = NULL;
}
if (dsbSecondary) {
dsbSecondary->Release();
dsbSecondary = NULL;
}
pDirectSound->Release();
pDirectSound = NULL;
}
pDirectSound->Release();
pDirectSound = NULL;
}
}
bool DirectSound::init(long sampleRate)
{
HRESULT hr;
DWORD freq;
DSBUFFERDESC dsbdesc;
int i;
HRESULT hr;
DWORD freq;
DSBUFFERDESC dsbdesc;
int i;
hr = CoCreateInstance( CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID *)&pDirectSound );
if( hr != S_OK ) {
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
return false;
}
hr = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID*)&pDirectSound);
if (hr != S_OK) {
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr);
return false;
}
pDirectSound->Initialize( &DSDEVID_DefaultPlayback );
if( hr != DS_OK ) {
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
return false;
}
pDirectSound->Initialize(&DSDEVID_DefaultPlayback);
if (hr != DS_OK) {
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr);
return false;
}
if( FAILED( hr = pDirectSound->SetCooperativeLevel( theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE ) ) ) {
systemMessage( IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr );
return false;
}
if (FAILED(hr = pDirectSound->SetCooperativeLevel(theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE))) {
systemMessage(IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr);
return false;
}
// Create primary sound buffer
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if (dsoundDisableHardwareAcceleration) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
// Create primary sound buffer
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if( dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbPrimary, NULL))) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
return false;
}
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbPrimary, NULL ) ) ) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
return false;
}
freq = sampleRate;
// calculate the number of samples per frame first
// then multiply it with the size of a sample frame (16 bit * stereo)
soundBufferLen = (freq / 60) * 4;
soundBufferTotalLen = soundBufferLen * 10;
soundNextPosition = 0;
freq = sampleRate;
// calculate the number of samples per frame first
// then multiply it with the size of a sample frame (16 bit * stereo)
soundBufferLen = ( freq / 60 ) * 4;
soundBufferTotalLen = soundBufferLen * 10;
soundNextPosition = 0;
ZeroMemory(&wfx, sizeof(WAVEFORMATEX));
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = freq;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 2;
wfx.nSamplesPerSec = freq;
wfx.wBitsPerSample = 16;
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if (FAILED(hr = dsbPrimary->SetFormat(&wfx))) {
systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr);
return false;
}
if( FAILED( hr = dsbPrimary->SetFormat( &wfx ) ) ) {
systemMessage( IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr );
return false;
}
// Create secondary sound buffer
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
if (dsoundDisableHardwareAcceleration) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
dsbdesc.dwBufferBytes = soundBufferTotalLen;
dsbdesc.lpwfxFormat = &wfx;
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))) {
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr);
return false;
}
// Create secondary sound buffer
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
if( dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
dsbdesc.dwBufferBytes = soundBufferTotalLen;
dsbdesc.lpwfxFormat = &wfx;
if (FAILED(hr = dsbSecondary->SetCurrentPosition(0))) {
systemMessage(0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr);
return false;
}
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbSecondary, NULL ) ) ) {
systemMessage( IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr );
return false;
}
if (SUCCEEDED(hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify))) {
dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
DSBPOSITIONNOTIFY notify[10];
for (i = 0; i < 10; i++) {
notify[i].dwOffset = i * soundBufferLen;
notify[i].hEventNotify = dsbEvent;
}
if( FAILED( hr = dsbSecondary->SetCurrentPosition( 0 ) ) ) {
systemMessage( 0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr );
return false;
}
if (FAILED(dsbNotify->SetNotificationPositions(10, notify))) {
dsbNotify->Release();
dsbNotify = NULL;
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
}
// Play primary buffer
if (FAILED(hr = dsbPrimary->Play(0, 0, DSBPLAY_LOOPING))) {
systemMessage(IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr);
return false;
}
if( SUCCEEDED( hr = dsbSecondary->QueryInterface( IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify ) ) ) {
dsbEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
DSBPOSITIONNOTIFY notify[10];
for( i = 0; i < 10; i++ ) {
notify[i].dwOffset = i * soundBufferLen;
notify[i].hEventNotify = dsbEvent;
}
if( FAILED( dsbNotify->SetNotificationPositions( 10, notify ) ) ) {
dsbNotify->Release();
dsbNotify = NULL;
CloseHandle(dsbEvent);
dsbEvent = NULL;
}
}
// Play primary buffer
if( FAILED( hr = dsbPrimary->Play( 0, 0, DSBPLAY_LOOPING ) ) ) {
systemMessage( IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr );
return false;
}
return true;
return true;
}
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()
{
if( dsbSecondary == NULL ) return;
if (dsbSecondary == NULL)
return;
dsbSecondary->Stop();
dsbSecondary->Stop();
dsbSecondary->SetCurrentPosition( 0 );
dsbSecondary->SetCurrentPosition(0);
soundNextPosition = 0;
soundNextPosition = 0;
}
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;
DWORD status = 0;
DWORD play = 0;
LPVOID lpvPtr1;
DWORD dwBytes1 = 0;
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
HRESULT hr;
DWORD status = 0;
DWORD play = 0;
LPVOID lpvPtr1;
DWORD dwBytes1 = 0;
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
if (!speedup && throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if (status & DSBSTATUS_PLAYING) {
if (!soundPaused) {
while (true) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ? play - soundNextPosition : soundBufferTotalLen - soundNextPosition + play);
if( !speedup && throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) {
if( !soundPaused ) {
while( true ) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ?
play - soundNextPosition :
soundBufferTotalLen - soundNextPosition + play);
if (BufferLeft > soundBufferLen) {
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if(BufferLeft > soundBufferLen)
{
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if(dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
}/* else {
if (dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
} /* else {
// TODO: remove?
setsoundPaused(true);
}*/
}
}
// Obtain memory address of write block.
// This will be in two parts if the block wraps around.
if (DSERR_BUFFERLOST == (hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0))) {
// If DSERR_BUFFERLOST is returned, restore and retry lock.
dsbSecondary->Restore();
hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0);
}
// Obtain memory address of write block.
// This will be in two parts if the block wraps around.
if( DSERR_BUFFERLOST == ( hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0 ) ) ) {
// If DSERR_BUFFERLOST is returned, restore and retry lock.
dsbSecondary->Restore();
hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0 );
}
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
if (SUCCEEDED(hr)) {
// Write to pointers.
CopyMemory(lpvPtr1, finalWave, dwBytes1);
if (lpvPtr2) {
CopyMemory(lpvPtr2, finalWave + dwBytes1, dwBytes2);
}
if( SUCCEEDED( hr ) ) {
// Write to pointers.
CopyMemory( lpvPtr1, finalWave, dwBytes1 );
if ( lpvPtr2 ) {
CopyMemory( lpvPtr2, finalWave + dwBytes1, dwBytes2 );
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock( lpvPtr1, dwBytes1, lpvPtr2, dwBytes2 );
} else {
systemMessage( 0, _T("dsbSecondary->Lock() failed: %08x"), hr );
return;
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);
} else {
systemMessage(0, _T("dsbSecondary->Lock() failed: %08x"), hr);
return;
}
}
SoundDriver *newDirectSound()
SoundDriver* newDirectSound()
{
return new DirectSound();
return new DirectSound();
}

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