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:
parent
1f37311a4a
commit
1944613131
|
@ -1,7 +1,7 @@
|
||||||
#include "../common/Types.h"
|
#include "../common/Types.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
u8* gbMemoryMap[16];
|
uint8_t* gbMemoryMap[16];
|
||||||
|
|
||||||
int gbRomSizeMask = 0;
|
int gbRomSizeMask = 0;
|
||||||
int gbRomSize = 0;
|
int gbRomSize = 0;
|
||||||
|
@ -9,24 +9,24 @@ int gbRamSizeMask = 0;
|
||||||
int gbRamSize = 0;
|
int gbRamSize = 0;
|
||||||
int gbTAMA5ramSize = 0;
|
int gbTAMA5ramSize = 0;
|
||||||
|
|
||||||
u8* gbMemory = NULL;
|
uint8_t* gbMemory = NULL;
|
||||||
u8* gbVram = NULL;
|
uint8_t* gbVram = NULL;
|
||||||
u8* gbRom = NULL;
|
uint8_t* gbRom = NULL;
|
||||||
u8* gbRam = NULL;
|
uint8_t* gbRam = NULL;
|
||||||
u8* gbWram = NULL;
|
uint8_t* gbWram = NULL;
|
||||||
u16* gbLineBuffer = NULL;
|
uint16_t* gbLineBuffer = NULL;
|
||||||
u8* gbTAMA5ram = NULL;
|
uint8_t* gbTAMA5ram = NULL;
|
||||||
|
|
||||||
u16 gbPalette[128];
|
uint16_t gbPalette[128];
|
||||||
u8 gbBgp[4] = { 0, 1, 2, 3 };
|
uint8_t gbBgp[4] = { 0, 1, 2, 3 };
|
||||||
u8 gbObp0[4] = { 0, 1, 2, 3 };
|
uint8_t gbObp0[4] = { 0, 1, 2, 3 };
|
||||||
u8 gbObp1[4] = { 0, 1, 2, 3 };
|
uint8_t gbObp1[4] = { 0, 1, 2, 3 };
|
||||||
int gbWindowLine = -1;
|
int gbWindowLine = -1;
|
||||||
|
|
||||||
bool genericflashcardEnable = false;
|
bool genericflashcardEnable = false;
|
||||||
int gbCgbMode = 0;
|
int gbCgbMode = 0;
|
||||||
|
|
||||||
u16 gbColorFilter[32768];
|
uint16_t gbColorFilter[32768];
|
||||||
int gbColorOption = 0;
|
int gbColorOption = 0;
|
||||||
int gbPaletteOption = 0;
|
int gbPaletteOption = 0;
|
||||||
int gbEmulatorType = 0;
|
int gbEmulatorType = 0;
|
||||||
|
@ -37,4 +37,4 @@ int gbBorderRowSkip = 0;
|
||||||
int gbBorderColumnSkip = 0;
|
int gbBorderColumnSkip = 0;
|
||||||
int gbDmaTicks = 0;
|
int gbDmaTicks = 0;
|
||||||
|
|
||||||
u8 (*gbSerialFunction)(u8) = NULL;
|
uint8_t (*gbSerialFunction)(uint8_t) = NULL;
|
||||||
|
|
|
@ -7,20 +7,20 @@ extern int gbRamSize;
|
||||||
extern int gbRamSizeMask;
|
extern int gbRamSizeMask;
|
||||||
extern int gbTAMA5ramSize;
|
extern int gbTAMA5ramSize;
|
||||||
|
|
||||||
extern u8* bios;
|
extern uint8_t* bios;
|
||||||
|
|
||||||
extern u8* gbRom;
|
extern uint8_t* gbRom;
|
||||||
extern u8* gbRam;
|
extern uint8_t* gbRam;
|
||||||
extern u8* gbVram;
|
extern uint8_t* gbVram;
|
||||||
extern u8* gbWram;
|
extern uint8_t* gbWram;
|
||||||
extern u8* gbMemory;
|
extern uint8_t* gbMemory;
|
||||||
extern u16* gbLineBuffer;
|
extern uint16_t* gbLineBuffer;
|
||||||
extern u8* gbTAMA5ram;
|
extern uint8_t* gbTAMA5ram;
|
||||||
|
|
||||||
extern u8* gbMemoryMap[16];
|
extern uint8_t* gbMemoryMap[16];
|
||||||
|
|
||||||
extern int gbFrameSkip;
|
extern int gbFrameSkip;
|
||||||
extern u16 gbColorFilter[32768];
|
extern uint16_t gbColorFilter[32768];
|
||||||
extern int gbColorOption;
|
extern int gbColorOption;
|
||||||
extern int gbPaletteOption;
|
extern int gbPaletteOption;
|
||||||
extern int gbEmulatorType;
|
extern int gbEmulatorType;
|
||||||
|
@ -30,32 +30,32 @@ extern int gbCgbMode;
|
||||||
extern int gbSgbMode;
|
extern int gbSgbMode;
|
||||||
extern int gbWindowLine;
|
extern int gbWindowLine;
|
||||||
extern int gbSpeed;
|
extern int gbSpeed;
|
||||||
extern u8 gbBgp[4];
|
extern uint8_t gbBgp[4];
|
||||||
extern u8 gbObp0[4];
|
extern uint8_t gbObp0[4];
|
||||||
extern u8 gbObp1[4];
|
extern uint8_t gbObp1[4];
|
||||||
extern u16 gbPalette[128];
|
extern uint16_t gbPalette[128];
|
||||||
extern bool gbScreenOn;
|
extern bool gbScreenOn;
|
||||||
extern bool gbDrawWindow;
|
extern bool gbDrawWindow;
|
||||||
extern u8 gbSCYLine[300];
|
extern uint8_t gbSCYLine[300];
|
||||||
// gbSCXLine is used for the emulation (bug) of the SX change
|
// gbSCXLine is used for the emulation (bug) of the SX change
|
||||||
// found in the Artic Zone game.
|
// found in the Artic Zone game.
|
||||||
extern u8 gbSCXLine[300];
|
extern uint8_t gbSCXLine[300];
|
||||||
// gbBgpLine is used for the emulation of the
|
// gbBgpLine is used for the emulation of the
|
||||||
// Prehistorik Man's title screen scroller.
|
// Prehistorik Man's title screen scroller.
|
||||||
extern u8 gbBgpLine[300];
|
extern uint8_t gbBgpLine[300];
|
||||||
extern u8 gbObp0Line[300];
|
extern uint8_t gbObp0Line[300];
|
||||||
extern u8 gbObp1Line[300];
|
extern uint8_t gbObp1Line[300];
|
||||||
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
|
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
|
||||||
extern u8 gbSpritesTicks[300];
|
extern uint8_t gbSpritesTicks[300];
|
||||||
|
|
||||||
extern u8 register_LCDC;
|
extern uint8_t register_LCDC;
|
||||||
extern u8 register_LY;
|
extern uint8_t register_LY;
|
||||||
extern u8 register_SCY;
|
extern uint8_t register_SCY;
|
||||||
extern u8 register_SCX;
|
extern uint8_t register_SCX;
|
||||||
extern u8 register_WY;
|
extern uint8_t register_WY;
|
||||||
extern u8 register_WX;
|
extern uint8_t register_WX;
|
||||||
extern u8 register_VBK;
|
extern uint8_t register_VBK;
|
||||||
extern u8 oldRegister_WY;
|
extern uint8_t oldRegister_WY;
|
||||||
|
|
||||||
extern int emulating;
|
extern int emulating;
|
||||||
extern bool genericflashcardEnable;
|
extern bool genericflashcardEnable;
|
||||||
|
@ -68,6 +68,6 @@ extern int gbDmaTicks;
|
||||||
extern void gbRenderLine();
|
extern void gbRenderLine();
|
||||||
extern void gbDrawSprites(bool);
|
extern void gbDrawSprites(bool);
|
||||||
|
|
||||||
extern u8 (*gbSerialFunction)(u8);
|
extern uint8_t (*gbSerialFunction)(uint8_t);
|
||||||
|
|
||||||
#endif // GBGLOBALS_H
|
#endif // GBGLOBALS_H
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "../common/Port.h"
|
#include "../common/Port.h"
|
||||||
#include "gb.h"
|
#include "gb.h"
|
||||||
#include "gbGlobals.h"
|
#include "gbGlobals.h"
|
||||||
u8 gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
uint8_t gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
const u8 gbDisabledRam[8] = { 0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf };
|
const uint8_t gbDisabledRam[8] = { 0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf };
|
||||||
extern int gbGBCColorType;
|
extern int gbGBCColorType;
|
||||||
extern gbRegister PC;
|
extern gbRegister PC;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ mapperMBC1 gbDataMBC1 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// MBC1 ROM write registers
|
// MBC1 ROM write registers
|
||||||
void mapperMBC1ROM(u16 address, u8 value)
|
void mapperMBC1ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ void mapperMBC1ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC1 RAM write
|
// MBC1 RAM write
|
||||||
void mapperMBC1RAM(u16 address, u8 value)
|
void mapperMBC1RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (gbDataMBC1.mapperRAMEnable) {
|
if (gbDataMBC1.mapperRAMEnable) {
|
||||||
if (gbRamSize) {
|
if (gbRamSize) {
|
||||||
|
@ -164,7 +164,7 @@ void mapperMBC1RAM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC1 read RAM
|
// MBC1 read RAM
|
||||||
u8 mapperMBC1ReadRAM(u16 address)
|
uint8_t mapperMBC1ReadRAM(uint16_t address)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (gbDataMBC1.mapperRAMEnable)
|
if (gbDataMBC1.mapperRAMEnable)
|
||||||
|
@ -237,7 +237,7 @@ mapperMBC2 gbDataMBC2 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// MBC2 ROM write registers
|
// MBC2 ROM write registers
|
||||||
void mapperMBC2ROM(u16 address, u8 value)
|
void mapperMBC2ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
switch (address & 0x6000) {
|
switch (address & 0x6000) {
|
||||||
case 0x0000: // RAM enable
|
case 0x0000: // RAM enable
|
||||||
|
@ -269,7 +269,7 @@ void mapperMBC2ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC2 RAM write
|
// MBC2 RAM write
|
||||||
void mapperMBC2RAM(u16 address, u8 value)
|
void mapperMBC2RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (gbDataMBC2.mapperRAMEnable) {
|
if (gbDataMBC2.mapperRAMEnable) {
|
||||||
if (gbRamSize && address < 0xa200) {
|
if (gbRamSize && address < 0xa200) {
|
||||||
|
@ -353,7 +353,7 @@ void memoryUpdateMBC3Clock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC3 ROM write registers
|
// MBC3 ROM write registers
|
||||||
void mapperMBC3ROM(u16 address, u8 value)
|
void mapperMBC3ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ void mapperMBC3ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC3 RAM write
|
// MBC3 RAM write
|
||||||
void mapperMBC3RAM(u16 address, u8 value)
|
void mapperMBC3RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (gbDataMBC3.mapperRAMEnable) {
|
if (gbDataMBC3.mapperRAMEnable) {
|
||||||
if (gbDataMBC3.mapperRAMBank != -1) {
|
if (gbDataMBC3.mapperRAMBank != -1) {
|
||||||
|
@ -447,7 +447,7 @@ void mapperMBC3RAM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC3 read RAM
|
// MBC3 read RAM
|
||||||
u8 mapperMBC3ReadRAM(u16 address)
|
uint8_t mapperMBC3ReadRAM(uint16_t address)
|
||||||
{
|
{
|
||||||
if (gbDataMBC3.mapperRAMEnable) {
|
if (gbDataMBC3.mapperRAMEnable) {
|
||||||
if (gbDataMBC3.mapperRAMBank != -1) {
|
if (gbDataMBC3.mapperRAMBank != -1) {
|
||||||
|
@ -520,7 +520,7 @@ mapperMBC5 gbDataMBC5 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// MBC5 ROM write registers
|
// MBC5 ROM write registers
|
||||||
void mapperMBC5ROM(u16 address, u8 value)
|
void mapperMBC5ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ void mapperMBC5ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC5 RAM write
|
// MBC5 RAM write
|
||||||
void mapperMBC5RAM(u16 address, u8 value)
|
void mapperMBC5RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (gbDataMBC5.mapperRAMEnable) {
|
if (gbDataMBC5.mapperRAMEnable) {
|
||||||
if (gbRamSize) {
|
if (gbRamSize) {
|
||||||
|
@ -591,7 +591,7 @@ void mapperMBC5RAM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC5 read RAM
|
// MBC5 read RAM
|
||||||
u8 mapperMBC5ReadRAM(u16 address)
|
uint8_t mapperMBC5ReadRAM(uint16_t address)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (gbDataMBC5.mapperRAMEnable)
|
if (gbDataMBC5.mapperRAMEnable)
|
||||||
|
@ -652,7 +652,7 @@ mapperMBC7 gbDataMBC7 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// MBC7 ROM write registers
|
// MBC7 ROM write registers
|
||||||
void mapperMBC7ROM(u16 address, u8 value)
|
void mapperMBC7ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ void mapperMBC7ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC7 read RAM
|
// MBC7 read RAM
|
||||||
u8 mapperMBC7ReadRAM(u16 address)
|
uint8_t mapperMBC7ReadRAM(uint16_t address)
|
||||||
{
|
{
|
||||||
switch (address & 0xa0f0) {
|
switch (address & 0xa0f0) {
|
||||||
case 0xa000:
|
case 0xa000:
|
||||||
|
@ -738,7 +738,7 @@ u8 mapperMBC7ReadRAM(u16 address)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC7 RAM write
|
// MBC7 RAM write
|
||||||
void mapperMBC7RAM(u16 address, u8 value)
|
void mapperMBC7RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (address == 0xa080) {
|
if (address == 0xa080) {
|
||||||
// special processing needed
|
// special processing needed
|
||||||
|
@ -827,7 +827,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
||||||
} else if ((gbDataMBC7.address >> 6) == 2) {
|
} else if ((gbDataMBC7.address >> 6) == 2) {
|
||||||
if (gbDataMBC7.writeEnable) {
|
if (gbDataMBC7.writeEnable) {
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
WRITE16LE((u16*)&gbMemory[0xa000 + i * 2], 0xffff);
|
WRITE16LE((uint16_t*)&gbMemory[0xa000 + i * 2], 0xffff);
|
||||||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||||
}
|
}
|
||||||
gbDataMBC7.state = 5;
|
gbDataMBC7.state = 5;
|
||||||
|
@ -901,7 +901,7 @@ mapperHuC1 gbDataHuC1 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// HuC1 ROM write registers
|
// HuC1 ROM write registers
|
||||||
void mapperHuC1ROM(u16 address, u8 value)
|
void mapperHuC1ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ void mapperHuC1ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HuC1 RAM write
|
// HuC1 RAM write
|
||||||
void mapperHuC1RAM(u16 address, u8 value)
|
void mapperHuC1RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (gbDataHuC1.mapperRAMEnable) {
|
if (gbDataHuC1.mapperRAMEnable) {
|
||||||
if (gbRamSize) {
|
if (gbRamSize) {
|
||||||
|
@ -995,7 +995,7 @@ mapperHuC3 gbDataHuC3 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// HuC3 ROM write registers
|
// HuC3 ROM write registers
|
||||||
void mapperHuC3ROM(u16 address, u8 value)
|
void mapperHuC3ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -1039,7 +1039,7 @@ void mapperHuC3ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HuC3 read RAM
|
// HuC3 read RAM
|
||||||
u8 mapperHuC3ReadRAM(u16 address)
|
uint8_t mapperHuC3ReadRAM(uint16_t address)
|
||||||
{
|
{
|
||||||
if (gbDataHuC3.mapperRAMFlag > 0x0b && gbDataHuC3.mapperRAMFlag < 0x0e) {
|
if (gbDataHuC3.mapperRAMFlag > 0x0b && gbDataHuC3.mapperRAMFlag < 0x0e) {
|
||||||
if (gbDataHuC3.mapperRAMFlag != 0x0c)
|
if (gbDataHuC3.mapperRAMFlag != 0x0c)
|
||||||
|
@ -1050,7 +1050,7 @@ u8 mapperHuC3ReadRAM(u16 address)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HuC3 RAM write
|
// HuC3 RAM write
|
||||||
void mapperHuC3RAM(u16 address, u8 value)
|
void mapperHuC3RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int* p;
|
int* p;
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ void memoryUpdateTAMA5Clock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TAMA5 RAM write
|
// TAMA5 RAM write
|
||||||
void mapperTAMA5RAM(u16 address, u8 value)
|
void mapperTAMA5RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if ((address & 0xffff) <= 0xa001) {
|
if ((address & 0xffff) <= 0xa001) {
|
||||||
switch (address & 1) {
|
switch (address & 1) {
|
||||||
|
@ -1390,7 +1390,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
||||||
if ((value & 0x0e) == 0x0c) {
|
if ((value & 0x0e) == 0x0c) {
|
||||||
gbDataTAMA5.mapperRamByteSelect = gbDataTAMA5.mapperCommands[6] | (gbDataTAMA5.mapperCommands[7] << 4);
|
gbDataTAMA5.mapperRamByteSelect = gbDataTAMA5.mapperCommands[6] | (gbDataTAMA5.mapperCommands[7] << 4);
|
||||||
|
|
||||||
u8 byte = gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect];
|
uint8_t byte = gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect];
|
||||||
|
|
||||||
gbMemoryMap[0xa][0] = (value & 1) ? byte >> 4 : byte & 0x0f;
|
gbMemoryMap[0xa][0] = (value & 1) ? byte >> 4 : byte & 0x0f;
|
||||||
|
|
||||||
|
@ -1413,7 +1413,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TAMA5 read RAM
|
// TAMA5 read RAM
|
||||||
u8 mapperTAMA5ReadRAM(u16 address)
|
uint8_t mapperTAMA5ReadRAM(uint16_t address)
|
||||||
{
|
{
|
||||||
return gbMemoryMap[address >> 12][address & 0xfff];
|
return gbMemoryMap[address >> 12][address & 0xfff];
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1448,7 @@ mapperMMM01 gbDataMMM01 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// MMM01 ROM write registers
|
// MMM01 ROM write registers
|
||||||
void mapperMMM01ROM(u16 address, u8 value)
|
void mapperMMM01ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
@ -1518,7 +1518,7 @@ void mapperMMM01ROM(u16 address, u8 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MMM01 RAM write
|
// MMM01 RAM write
|
||||||
void mapperMMM01RAM(u16 address, u8 value)
|
void mapperMMM01RAM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
if (gbDataMMM01.mapperRAMEnable) {
|
if (gbDataMMM01.mapperRAMEnable) {
|
||||||
if (gbRamSize) {
|
if (gbRamSize) {
|
||||||
|
@ -1558,7 +1558,7 @@ void memoryUpdateMapMMM01()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameGenie ROM write registers
|
// GameGenie ROM write registers
|
||||||
void mapperGGROM(u16 address, u8 value)
|
void mapperGGROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
switch (address & 0x6000) {
|
switch (address & 0x6000) {
|
||||||
case 0x0000: // RAM enable register
|
case 0x0000: // RAM enable register
|
||||||
|
@ -1577,7 +1577,7 @@ void mapperGGROM(u16 address, u8 value)
|
||||||
// GS3 Used to emulate the GS V3.0 rom bank switching
|
// GS3 Used to emulate the GS V3.0 rom bank switching
|
||||||
mapperGS3 gbDataGS3 = { 1 }; // ROM bank
|
mapperGS3 gbDataGS3 = { 1 }; // ROM bank
|
||||||
|
|
||||||
void mapperGS3ROM(u16 address, u8 value)
|
void mapperGS3ROM(uint16_t address, uint8_t value)
|
||||||
{
|
{
|
||||||
int tmpAddress = 0;
|
int tmpAddress = 0;
|
||||||
|
|
||||||
|
|
|
@ -144,35 +144,35 @@ extern mapperTAMA5 gbDataTAMA5;
|
||||||
extern mapperMMM01 gbDataMMM01;
|
extern mapperMMM01 gbDataMMM01;
|
||||||
extern mapperGS3 gbDataGS3;
|
extern mapperGS3 gbDataGS3;
|
||||||
|
|
||||||
void mapperMBC1ROM(u16, u8);
|
void mapperMBC1ROM(uint16_t, uint8_t);
|
||||||
void mapperMBC1RAM(u16, u8);
|
void mapperMBC1RAM(uint16_t, uint8_t);
|
||||||
u8 mapperMBC1ReadRAM(u16);
|
uint8_t mapperMBC1ReadRAM(uint16_t);
|
||||||
void mapperMBC2ROM(u16, u8);
|
void mapperMBC2ROM(uint16_t, uint8_t);
|
||||||
void mapperMBC2RAM(u16, u8);
|
void mapperMBC2RAM(uint16_t, uint8_t);
|
||||||
void mapperMBC3ROM(u16, u8);
|
void mapperMBC3ROM(uint16_t, uint8_t);
|
||||||
void mapperMBC3RAM(u16, u8);
|
void mapperMBC3RAM(uint16_t, uint8_t);
|
||||||
u8 mapperMBC3ReadRAM(u16);
|
uint8_t mapperMBC3ReadRAM(uint16_t);
|
||||||
void mapperMBC5ROM(u16, u8);
|
void mapperMBC5ROM(uint16_t, uint8_t);
|
||||||
void mapperMBC5RAM(u16, u8);
|
void mapperMBC5RAM(uint16_t, uint8_t);
|
||||||
u8 mapperMBC5ReadRAM(u16);
|
uint8_t mapperMBC5ReadRAM(uint16_t);
|
||||||
void mapperMBC7ROM(u16, u8);
|
void mapperMBC7ROM(uint16_t, uint8_t);
|
||||||
void mapperMBC7RAM(u16, u8);
|
void mapperMBC7RAM(uint16_t, uint8_t);
|
||||||
u8 mapperMBC7ReadRAM(u16);
|
uint8_t mapperMBC7ReadRAM(uint16_t);
|
||||||
void mapperHuC1ROM(u16, u8);
|
void mapperHuC1ROM(uint16_t, uint8_t);
|
||||||
void mapperHuC1RAM(u16, u8);
|
void mapperHuC1RAM(uint16_t, uint8_t);
|
||||||
void mapperHuC3ROM(u16, u8);
|
void mapperHuC3ROM(uint16_t, uint8_t);
|
||||||
void mapperHuC3RAM(u16, u8);
|
void mapperHuC3RAM(uint16_t, uint8_t);
|
||||||
u8 mapperHuC3ReadRAM(u16);
|
uint8_t mapperHuC3ReadRAM(uint16_t);
|
||||||
void mapperTAMA5RAM(u16, u8);
|
void mapperTAMA5RAM(uint16_t, uint8_t);
|
||||||
u8 mapperTAMA5ReadRAM(u16);
|
uint8_t mapperTAMA5ReadRAM(uint16_t);
|
||||||
void memoryUpdateTAMA5Clock();
|
void memoryUpdateTAMA5Clock();
|
||||||
void mapperMMM01ROM(u16, u8);
|
void mapperMMM01ROM(uint16_t, uint8_t);
|
||||||
void mapperMMM01RAM(u16, u8);
|
void mapperMMM01RAM(uint16_t, uint8_t);
|
||||||
void mapperGGROM(u16, u8);
|
void mapperGGROM(uint16_t, uint8_t);
|
||||||
void mapperGS3ROM(u16, u8);
|
void mapperGS3ROM(uint16_t, uint8_t);
|
||||||
// extern void (*mapper)(u16,u8);
|
// extern void (*mapper)(uint16_t,uint8_t);
|
||||||
// extern void (*mapperRAM)(u16,u8);
|
// extern void (*mapperRAM)(uint16_t,uint8_t);
|
||||||
// extern u8 (*mapperReadRAM)(u16);
|
// extern uint8_t (*mapperReadRAM)(uint16_t);
|
||||||
|
|
||||||
extern void memoryUpdateMapMBC1();
|
extern void memoryUpdateMapMBC1();
|
||||||
extern void memoryUpdateMapMBC2();
|
extern void memoryUpdateMapMBC2();
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
u8 gbPrinterStatus = 0;
|
uint8_t gbPrinterStatus = 0;
|
||||||
int gbPrinterState = 0;
|
int gbPrinterState = 0;
|
||||||
u8 gbPrinterData[0x280 * 9];
|
uint8_t gbPrinterData[0x280 * 9];
|
||||||
u8 gbPrinterPacket[0x400];
|
uint8_t gbPrinterPacket[0x400];
|
||||||
int gbPrinterCount = 0;
|
int gbPrinterCount = 0;
|
||||||
int gbPrinterDataCount = 0;
|
int gbPrinterDataCount = 0;
|
||||||
int gbPrinterDataSize = 0;
|
int gbPrinterDataSize = 0;
|
||||||
|
@ -13,7 +13,7 @@ int gbPrinterResult = 0;
|
||||||
|
|
||||||
bool gbPrinterCheckCRC()
|
bool gbPrinterCheckCRC()
|
||||||
{
|
{
|
||||||
u16 crc = 0;
|
uint16_t crc = 0;
|
||||||
|
|
||||||
for (int i = 2; i < (6 + gbPrinterDataSize); i++) {
|
for (int i = 2; i < (6 + gbPrinterDataSize); i++) {
|
||||||
crc += gbPrinterPacket[i];
|
crc += gbPrinterPacket[i];
|
||||||
|
@ -61,7 +61,7 @@ void gbPrinterShowData()
|
||||||
pal[3].b = 0;
|
pal[3].b = 0;
|
||||||
set_palette(pal);
|
set_palette(pal);
|
||||||
acquire_screen();
|
acquire_screen();
|
||||||
u8 *data = gbPrinterData;
|
uint8_t *data = gbPrinterData;
|
||||||
for(int y = 0; y < 0x12; y++) {
|
for(int y = 0; y < 0x12; y++) {
|
||||||
for(int x = 0; x < 0x14; x++) {
|
for(int x = 0; x < 0x14; x++) {
|
||||||
for(int k = 0; k < 8; k++) {
|
for(int k = 0; k < 8; k++) {
|
||||||
|
@ -89,11 +89,11 @@ void gbPrinterReceiveData()
|
||||||
{
|
{
|
||||||
int i = gbPrinterDataCount;
|
int i = gbPrinterDataCount;
|
||||||
if (gbPrinterPacket[3]) { // compressed
|
if (gbPrinterPacket[3]) { // compressed
|
||||||
u8* data = &gbPrinterPacket[6];
|
uint8_t* data = &gbPrinterPacket[6];
|
||||||
u8* dest = &gbPrinterData[gbPrinterDataCount];
|
uint8_t* dest = &gbPrinterData[gbPrinterDataCount];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while (len < gbPrinterDataSize) {
|
while (len < gbPrinterDataSize) {
|
||||||
u8 control = *data++;
|
uint8_t control = *data++;
|
||||||
if (control & 0x80) { // repeated data
|
if (control & 0x80) { // repeated data
|
||||||
control &= 0x7f;
|
control &= 0x7f;
|
||||||
control += 2;
|
control += 2;
|
||||||
|
@ -139,7 +139,7 @@ void gbPrinterCommand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 gbPrinterSend(u8 b)
|
uint8_t gbPrinterSend(uint8_t b)
|
||||||
{
|
{
|
||||||
switch (gbPrinterState) {
|
switch (gbPrinterState) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
|
||||||
u8 gbPrinterSend(u8 b);
|
uint8_t gbPrinterSend(uint8_t b);
|
||||||
|
|
||||||
#endif // GBPRINTER_H
|
#endif // GBPRINTER_H
|
||||||
|
|
222
src/gb/gbSGB.cpp
222
src/gb/gbSGB.cpp
|
@ -7,7 +7,7 @@
|
||||||
#include "gb.h"
|
#include "gb.h"
|
||||||
#include "gbGlobals.h"
|
#include "gbGlobals.h"
|
||||||
|
|
||||||
extern u8* pix;
|
extern uint8_t* pix;
|
||||||
extern bool speedup;
|
extern bool speedup;
|
||||||
extern bool gbSgbResetFlag;
|
extern bool gbSgbResetFlag;
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ extern bool gbSgbResetFlag;
|
||||||
#define GBSGB_RESET 1
|
#define GBSGB_RESET 1
|
||||||
#define GBSGB_PACKET_TRANSMIT 2
|
#define GBSGB_PACKET_TRANSMIT 2
|
||||||
|
|
||||||
u8* gbSgbBorderChar = NULL;
|
uint8_t* gbSgbBorderChar = NULL;
|
||||||
u8* gbSgbBorder = NULL;
|
uint8_t* gbSgbBorder = NULL;
|
||||||
|
|
||||||
int gbSgbCGBSupport = 0;
|
int gbSgbCGBSupport = 0;
|
||||||
int gbSgbMask = 0;
|
int gbSgbMask = 0;
|
||||||
|
@ -25,30 +25,30 @@ int gbSgbPacketState = GBSGB_NONE;
|
||||||
int gbSgbBit = 0;
|
int gbSgbBit = 0;
|
||||||
int gbSgbPacketTimeout = 0;
|
int gbSgbPacketTimeout = 0;
|
||||||
int GBSGB_PACKET_TIMEOUT = 66666;
|
int GBSGB_PACKET_TIMEOUT = 66666;
|
||||||
u8 gbSgbPacket[16 * 7];
|
uint8_t gbSgbPacket[16 * 7];
|
||||||
int gbSgbPacketNBits = 0;
|
int gbSgbPacketNBits = 0;
|
||||||
int gbSgbPacketByte = 0;
|
int gbSgbPacketByte = 0;
|
||||||
int gbSgbPacketNumber = 0;
|
int gbSgbPacketNumber = 0;
|
||||||
int gbSgbMultiplayer = 0;
|
int gbSgbMultiplayer = 0;
|
||||||
int gbSgbFourPlayers = 0;
|
int gbSgbFourPlayers = 0;
|
||||||
u8 gbSgbNextController = 0x0f;
|
uint8_t gbSgbNextController = 0x0f;
|
||||||
u8 gbSgbReadingController = 0;
|
uint8_t gbSgbReadingController = 0;
|
||||||
u16 gbSgbSCPPalette[4 * 512];
|
uint16_t gbSgbSCPPalette[4 * 512];
|
||||||
u8 gbSgbATF[20 * 18];
|
uint8_t gbSgbATF[20 * 18];
|
||||||
u8 gbSgbATFList[45 * 20 * 18];
|
uint8_t gbSgbATFList[45 * 20 * 18];
|
||||||
u8 gbSgbScreenBuffer[4160];
|
uint8_t gbSgbScreenBuffer[4160];
|
||||||
|
|
||||||
inline void gbSgbDraw24Bit(u8* p, u16 v)
|
inline void gbSgbDraw24Bit(uint8_t* p, uint16_t v)
|
||||||
{
|
{
|
||||||
memcpy(p, &systemColorMap32[v], 3);
|
memcpy(p, &systemColorMap32[v], 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void gbSgbDraw32Bit(u32* p, u16 v)
|
inline void gbSgbDraw32Bit(uint32_t* p, uint16_t v)
|
||||||
{
|
{
|
||||||
*p = systemColorMap32[v];
|
*p = systemColorMap32[v];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void gbSgbDraw16Bit(u16* p, u16 v)
|
inline void gbSgbDraw16Bit(uint16_t* p, uint16_t v)
|
||||||
{
|
{
|
||||||
*p = systemColorMap16[v];
|
*p = systemColorMap16[v];
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ void gbSgbReset()
|
||||||
|
|
||||||
void gbSgbInit()
|
void gbSgbInit()
|
||||||
{
|
{
|
||||||
gbSgbBorderChar = (u8*)malloc(32 * 256);
|
gbSgbBorderChar = (uint8_t*)malloc(32 * 256);
|
||||||
gbSgbBorder = (u8*)malloc(2048);
|
gbSgbBorder = (uint8_t*)malloc(2048);
|
||||||
|
|
||||||
gbSgbReset();
|
gbSgbReset();
|
||||||
}
|
}
|
||||||
|
@ -108,13 +108,13 @@ void gbSgbShutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSgbFillScreen(u16 color)
|
void gbSgbFillScreen(uint16_t color)
|
||||||
{
|
{
|
||||||
switch (systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 16: {
|
case 16: {
|
||||||
for (int y = 0; y < 144; y++) {
|
for (int y = 0; y < 144; y++) {
|
||||||
int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 2) + gbBorderColumnSkip;
|
int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 2) + gbBorderColumnSkip;
|
||||||
u16* dest = (u16*)pix + yLine;
|
uint16_t* dest = (uint16_t*)pix + yLine;
|
||||||
for (register int x = 0; x < 160; x++)
|
for (register int x = 0; x < 160; x++)
|
||||||
gbSgbDraw16Bit(dest++, color);
|
gbSgbDraw16Bit(dest++, color);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ void gbSgbFillScreen(u16 color)
|
||||||
case 24: {
|
case 24: {
|
||||||
for (int y = 0; y < 144; y++) {
|
for (int y = 0; y < 144; y++) {
|
||||||
int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip + gbBorderColumnSkip;
|
int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip + gbBorderColumnSkip;
|
||||||
u8* dest = (u8*)pix + yLine * 3;
|
uint8_t* dest = (uint8_t*)pix + yLine * 3;
|
||||||
for (register int x = 0; x < 160; x++) {
|
for (register int x = 0; x < 160; x++) {
|
||||||
gbSgbDraw24Bit(dest, color);
|
gbSgbDraw24Bit(dest, color);
|
||||||
dest += 3;
|
dest += 3;
|
||||||
|
@ -132,7 +132,7 @@ void gbSgbFillScreen(u16 color)
|
||||||
case 32: {
|
case 32: {
|
||||||
for (int y = 0; y < 144; y++) {
|
for (int y = 0; y < 144; y++) {
|
||||||
int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 1) + gbBorderColumnSkip;
|
int yLine = (y + gbBorderRowSkip + 1) * (gbBorderLineSkip + 1) + gbBorderColumnSkip;
|
||||||
u32* dest = (u32*)pix + yLine;
|
uint32_t* dest = (uint32_t*)pix + yLine;
|
||||||
for (register int x = 0; x < 160; x++) {
|
for (register int x = 0; x < 160; x++) {
|
||||||
gbSgbDraw32Bit(dest++, color);
|
gbSgbDraw32Bit(dest++, color);
|
||||||
}
|
}
|
||||||
|
@ -145,12 +145,12 @@ void gbSgbFillScreen(u16 color)
|
||||||
|
|
||||||
void gbSgbRenderScreenToBuffer()
|
void gbSgbRenderScreenToBuffer()
|
||||||
{
|
{
|
||||||
u16 mapAddress = 0x9800;
|
uint16_t mapAddress = 0x9800;
|
||||||
|
|
||||||
if (register_LCDC & 0x08)
|
if (register_LCDC & 0x08)
|
||||||
mapAddress = 0x9c00;
|
mapAddress = 0x9c00;
|
||||||
|
|
||||||
u16 patternAddress = 0x8800;
|
uint16_t patternAddress = 0x8800;
|
||||||
|
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void gbSgbRenderScreenToBuffer()
|
||||||
flag = 0;
|
flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* toAddress = gbSgbScreenBuffer;
|
uint8_t* toAddress = gbSgbScreenBuffer;
|
||||||
|
|
||||||
for (int i = 0; i < 13; i++) {
|
for (int i = 0; i < 13; i++) {
|
||||||
for (int j = 0; j < 20; j++) {
|
for (int j = 0; j < 20; j++) {
|
||||||
|
@ -181,36 +181,36 @@ void gbSgbRenderScreenToBuffer()
|
||||||
|
|
||||||
void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
||||||
{
|
{
|
||||||
u16* dest = (u16*)pix + ((y + 1) * (256 + 2)) + x;
|
uint16_t* dest = (uint16_t*)pix + ((y + 1) * (256 + 2)) + x;
|
||||||
u8* dest8 = (u8*)pix + ((y * 256) + x) * 3;
|
uint8_t* dest8 = (uint8_t*)pix + ((y * 256) + x) * 3;
|
||||||
u32* dest32 = (u32*)pix + ((y + 1) * 257) + x;
|
uint32_t* dest32 = (uint32_t*)pix + ((y + 1) * 257) + x;
|
||||||
|
|
||||||
u8* tileAddress = &gbSgbBorderChar[tile * 32];
|
uint8_t* tileAddress = &gbSgbBorderChar[tile * 32];
|
||||||
u8* tileAddress2 = &gbSgbBorderChar[tile * 32 + 16];
|
uint8_t* tileAddress2 = &gbSgbBorderChar[tile * 32 + 16];
|
||||||
|
|
||||||
u8 l = 8;
|
uint8_t l = 8;
|
||||||
|
|
||||||
u8 palette = ((attr >> 2) & 7);
|
uint8_t palette = ((attr >> 2) & 7);
|
||||||
|
|
||||||
if (palette < 4)
|
if (palette < 4)
|
||||||
palette += 4;
|
palette += 4;
|
||||||
|
|
||||||
palette *= 16;
|
palette *= 16;
|
||||||
|
|
||||||
u8 xx = 0;
|
uint8_t xx = 0;
|
||||||
u8 yy = 0;
|
uint8_t yy = 0;
|
||||||
|
|
||||||
int flipX = attr & 0x40;
|
int flipX = attr & 0x40;
|
||||||
int flipY = attr & 0x80;
|
int flipY = attr & 0x80;
|
||||||
|
|
||||||
while (l > 0) {
|
while (l > 0) {
|
||||||
u8 mask = 0x80;
|
uint8_t mask = 0x80;
|
||||||
u8 a = *tileAddress++;
|
uint8_t a = *tileAddress++;
|
||||||
u8 b = *tileAddress++;
|
uint8_t b = *tileAddress++;
|
||||||
u8 c = *tileAddress2++;
|
uint8_t c = *tileAddress2++;
|
||||||
u8 d = *tileAddress2++;
|
uint8_t d = *tileAddress2++;
|
||||||
|
|
||||||
u8 yyy;
|
uint8_t yyy;
|
||||||
if (!flipY)
|
if (!flipY)
|
||||||
yyy = yy;
|
yyy = yy;
|
||||||
else
|
else
|
||||||
|
@ -218,7 +218,7 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
||||||
|
|
||||||
while (mask > 0) {
|
while (mask > 0) {
|
||||||
|
|
||||||
u8 color = 0;
|
uint8_t color = 0;
|
||||||
if (a & mask)
|
if (a & mask)
|
||||||
color++;
|
color++;
|
||||||
if (b & mask)
|
if (b & mask)
|
||||||
|
@ -229,14 +229,14 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
||||||
color += 8;
|
color += 8;
|
||||||
|
|
||||||
if (color || (y + yy < 40 || y + yy >= 184) || (x + xx < 48 || x + xx >= 208)) {
|
if (color || (y + yy < 40 || y + yy >= 184) || (x + xx < 48 || x + xx >= 208)) {
|
||||||
u8 xxx;
|
uint8_t xxx;
|
||||||
|
|
||||||
if (!flipX)
|
if (!flipX)
|
||||||
xxx = xx;
|
xxx = xx;
|
||||||
else
|
else
|
||||||
xxx = 7 - xx;
|
xxx = 7 - xx;
|
||||||
|
|
||||||
u16 cc;
|
uint16_t cc;
|
||||||
if (color) {
|
if (color) {
|
||||||
cc = gbPalette[palette + color];
|
cc = gbPalette[palette + color];
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,12 +270,12 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
||||||
void gbSgbRenderBorder()
|
void gbSgbRenderBorder()
|
||||||
{
|
{
|
||||||
if (gbBorderOn) {
|
if (gbBorderOn) {
|
||||||
u8* fromAddress = gbSgbBorder;
|
uint8_t* fromAddress = gbSgbBorder;
|
||||||
|
|
||||||
for (u8 y = 0; y < 28; y++) {
|
for (uint8_t y = 0; y < 28; y++) {
|
||||||
for (u8 x = 0; x < 32; x++) {
|
for (uint8_t x = 0; x < 32; x++) {
|
||||||
u8 tile = *fromAddress++;
|
uint8_t tile = *fromAddress++;
|
||||||
u8 attr = *fromAddress++;
|
uint8_t attr = *fromAddress++;
|
||||||
|
|
||||||
gbSgbDrawBorderTile(x * 8, y * 8, tile, attr);
|
gbSgbDrawBorderTile(x * 8, y * 8, tile, attr);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ void gbSgbPicture()
|
||||||
|
|
||||||
memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048);
|
memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048);
|
||||||
|
|
||||||
u16* paletteAddr = (u16*)&gbSgbScreenBuffer[2048];
|
uint16_t* paletteAddr = (uint16_t*)&gbSgbScreenBuffer[2048];
|
||||||
|
|
||||||
for (int i = 64; i < 128; i++) {
|
for (int i = 64; i < 128; i++) {
|
||||||
gbPalette[i] = READ16LE(paletteAddr++);
|
gbPalette[i] = READ16LE(paletteAddr++);
|
||||||
|
@ -317,9 +317,9 @@ void gbSgbPicture()
|
||||||
gbSgbCGBSupport = 0;
|
gbSgbCGBSupport = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSgbSetPalette(int a, int b, u16* p)
|
void gbSgbSetPalette(int a, int b, uint16_t* p)
|
||||||
{
|
{
|
||||||
u16 bit00 = READ16LE(p++);
|
uint16_t bit00 = READ16LE(p++);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < 4; i++) {
|
for (i = 1; i < 4; i++) {
|
||||||
|
@ -339,7 +339,7 @@ void gbSgbScpPalette()
|
||||||
{
|
{
|
||||||
gbSgbRenderScreenToBuffer();
|
gbSgbRenderScreenToBuffer();
|
||||||
|
|
||||||
u16* fromAddress = (u16*)gbSgbScreenBuffer;
|
uint16_t* fromAddress = (uint16_t*)gbSgbScreenBuffer;
|
||||||
|
|
||||||
for (int i = 0; i < 512 * 4; i++) {
|
for (int i = 0; i < 512 * 4; i++) {
|
||||||
gbSgbSCPPalette[i] = READ16LE(fromAddress++);
|
gbSgbSCPPalette[i] = READ16LE(fromAddress++);
|
||||||
|
@ -363,19 +363,19 @@ void gbSgbSetATF(int n)
|
||||||
|
|
||||||
void gbSgbSetPalette()
|
void gbSgbSetPalette()
|
||||||
{
|
{
|
||||||
u16 pal = READ16LE((((u16*)&gbSgbPacket[1]))) & 511;
|
uint16_t pal = READ16LE((((uint16_t*)&gbSgbPacket[1]))) & 511;
|
||||||
memcpy(&gbPalette[0], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
|
memcpy(&gbPalette[0], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
|
||||||
|
|
||||||
pal = READ16LE((((u16*)&gbSgbPacket[3]))) & 511;
|
pal = READ16LE((((uint16_t*)&gbSgbPacket[3]))) & 511;
|
||||||
memcpy(&gbPalette[4], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
|
memcpy(&gbPalette[4], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
|
||||||
|
|
||||||
pal = READ16LE((((u16*)&gbSgbPacket[5]))) & 511;
|
pal = READ16LE((((uint16_t*)&gbSgbPacket[5]))) & 511;
|
||||||
memcpy(&gbPalette[8], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
|
memcpy(&gbPalette[8], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
|
||||||
|
|
||||||
pal = READ16LE((((u16*)&gbSgbPacket[7]))) & 511;
|
pal = READ16LE((((uint16_t*)&gbSgbPacket[7]))) & 511;
|
||||||
memcpy(&gbPalette[12], &gbSgbSCPPalette[pal * 4], 4 * sizeof(u16));
|
memcpy(&gbPalette[12], &gbSgbSCPPalette[pal * 4], 4 * sizeof(uint16_t));
|
||||||
|
|
||||||
u8 atf = gbSgbPacket[9];
|
uint8_t atf = gbSgbPacket[9];
|
||||||
|
|
||||||
if (atf & 0x80) {
|
if (atf & 0x80) {
|
||||||
gbSgbSetATF(atf & 0x3f);
|
gbSgbSetATF(atf & 0x3f);
|
||||||
|
@ -390,26 +390,26 @@ void gbSgbSetPalette()
|
||||||
|
|
||||||
void gbSgbAttributeBlock()
|
void gbSgbAttributeBlock()
|
||||||
{
|
{
|
||||||
u8* fromAddress = &gbSgbPacket[1];
|
uint8_t* fromAddress = &gbSgbPacket[1];
|
||||||
|
|
||||||
u8 nDataSet = *fromAddress++;
|
uint8_t nDataSet = *fromAddress++;
|
||||||
if (nDataSet > 12)
|
if (nDataSet > 12)
|
||||||
nDataSet = 12;
|
nDataSet = 12;
|
||||||
if (nDataSet == 0)
|
if (nDataSet == 0)
|
||||||
nDataSet = 1;
|
nDataSet = 1;
|
||||||
|
|
||||||
while (nDataSet) {
|
while (nDataSet) {
|
||||||
u8 controlCode = (*fromAddress++) & 7;
|
uint8_t controlCode = (*fromAddress++) & 7;
|
||||||
u8 paletteDesignation = (*fromAddress++) & 0x3f;
|
uint8_t paletteDesignation = (*fromAddress++) & 0x3f;
|
||||||
u8 startH = (*fromAddress++) & 0x1f;
|
uint8_t startH = (*fromAddress++) & 0x1f;
|
||||||
u8 startV = (*fromAddress++) & 0x1f;
|
uint8_t startV = (*fromAddress++) & 0x1f;
|
||||||
u8 endH = (*fromAddress++) & 0x1f;
|
uint8_t endH = (*fromAddress++) & 0x1f;
|
||||||
u8 endV = (*fromAddress++) & 0x1f;
|
uint8_t endV = (*fromAddress++) & 0x1f;
|
||||||
|
|
||||||
u8* toAddress = gbSgbATF;
|
uint8_t* toAddress = gbSgbATF;
|
||||||
|
|
||||||
for (u8 y = 0; y < 18; y++) {
|
for (uint8_t y = 0; y < 18; y++) {
|
||||||
for (u8 x = 0; x < 20; x++) {
|
for (uint8_t x = 0; x < 20; x++) {
|
||||||
if (x < startH || y < startV || x > endH || y > endV) {
|
if (x < startH || y < startV || x > endH || y > endV) {
|
||||||
// outside
|
// outside
|
||||||
if (controlCode & 0x04)
|
if (controlCode & 0x04)
|
||||||
|
@ -432,7 +432,7 @@ void gbSgbAttributeBlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSgbSetColumnPalette(u8 col, u8 p)
|
void gbSgbSetColumnPalette(uint8_t col, uint8_t p)
|
||||||
{
|
{
|
||||||
// if(col < 0)
|
// if(col < 0)
|
||||||
// col = 0;
|
// col = 0;
|
||||||
|
@ -441,15 +441,15 @@ void gbSgbSetColumnPalette(u8 col, u8 p)
|
||||||
|
|
||||||
p &= 3;
|
p &= 3;
|
||||||
|
|
||||||
u8* toAddress = &gbSgbATF[col];
|
uint8_t* toAddress = &gbSgbATF[col];
|
||||||
|
|
||||||
for (u8 y = 0; y < 18; y++) {
|
for (uint8_t y = 0; y < 18; y++) {
|
||||||
*toAddress = p;
|
*toAddress = p;
|
||||||
toAddress += 20;
|
toAddress += 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSgbSetRowPalette(u8 row, u8 p)
|
void gbSgbSetRowPalette(uint8_t row, uint8_t p)
|
||||||
{
|
{
|
||||||
// if(row < 0)
|
// if(row < 0)
|
||||||
// row = 0;
|
// row = 0;
|
||||||
|
@ -458,26 +458,26 @@ void gbSgbSetRowPalette(u8 row, u8 p)
|
||||||
|
|
||||||
p &= 3;
|
p &= 3;
|
||||||
|
|
||||||
u8* toAddress = &gbSgbATF[row * 20];
|
uint8_t* toAddress = &gbSgbATF[row * 20];
|
||||||
|
|
||||||
for (u8 x = 0; x < 20; x++) {
|
for (uint8_t x = 0; x < 20; x++) {
|
||||||
*toAddress++ = p;
|
*toAddress++ = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSgbAttributeDivide()
|
void gbSgbAttributeDivide()
|
||||||
{
|
{
|
||||||
u8 control = gbSgbPacket[1];
|
uint8_t control = gbSgbPacket[1];
|
||||||
u8 coord = gbSgbPacket[2];
|
uint8_t coord = gbSgbPacket[2];
|
||||||
u8 colorBR = control & 3;
|
uint8_t colorBR = control & 3;
|
||||||
u8 colorAL = (control >> 2) & 3;
|
uint8_t colorAL = (control >> 2) & 3;
|
||||||
u8 colorOL = (control >> 4) & 3;
|
uint8_t colorOL = (control >> 4) & 3;
|
||||||
|
|
||||||
if (control & 0x40) {
|
if (control & 0x40) {
|
||||||
if (coord > 17)
|
if (coord > 17)
|
||||||
coord = 17;
|
coord = 17;
|
||||||
|
|
||||||
for (u8 i = 0; i < 18; i++) {
|
for (uint8_t i = 0; i < 18; i++) {
|
||||||
if (i < coord)
|
if (i < coord)
|
||||||
gbSgbSetRowPalette(i, colorAL);
|
gbSgbSetRowPalette(i, colorAL);
|
||||||
else if (i > coord)
|
else if (i > coord)
|
||||||
|
@ -489,7 +489,7 @@ void gbSgbAttributeDivide()
|
||||||
if (coord > 19)
|
if (coord > 19)
|
||||||
coord = 19;
|
coord = 19;
|
||||||
|
|
||||||
for (u8 i = 0; i < 20; i++) {
|
for (uint8_t i = 0; i < 20; i++) {
|
||||||
if (i < coord)
|
if (i < coord)
|
||||||
gbSgbSetColumnPalette(i, colorAL);
|
gbSgbSetColumnPalette(i, colorAL);
|
||||||
else if (i > coord)
|
else if (i > coord)
|
||||||
|
@ -502,17 +502,17 @@ void gbSgbAttributeDivide()
|
||||||
|
|
||||||
void gbSgbAttributeLine()
|
void gbSgbAttributeLine()
|
||||||
{
|
{
|
||||||
u8* fromAddress = &gbSgbPacket[1];
|
uint8_t* fromAddress = &gbSgbPacket[1];
|
||||||
|
|
||||||
u8 nDataSet = *fromAddress++;
|
uint8_t nDataSet = *fromAddress++;
|
||||||
|
|
||||||
if (nDataSet > 0x6e)
|
if (nDataSet > 0x6e)
|
||||||
nDataSet = 0x6e;
|
nDataSet = 0x6e;
|
||||||
|
|
||||||
while (nDataSet) {
|
while (nDataSet) {
|
||||||
u8 line = *fromAddress++;
|
uint8_t line = *fromAddress++;
|
||||||
u8 num = line & 0x1f;
|
uint8_t num = line & 0x1f;
|
||||||
u8 pal = (line >> 5) & 0x03;
|
uint8_t pal = (line >> 5) & 0x03;
|
||||||
if (line & 0x80) {
|
if (line & 0x80) {
|
||||||
if (num > 17)
|
if (num > 17)
|
||||||
num = 17;
|
num = 17;
|
||||||
|
@ -528,22 +528,22 @@ void gbSgbAttributeLine()
|
||||||
|
|
||||||
void gbSgbAttributeCharacter()
|
void gbSgbAttributeCharacter()
|
||||||
{
|
{
|
||||||
u8 startH = gbSgbPacket[1] & 0x1f;
|
uint8_t startH = gbSgbPacket[1] & 0x1f;
|
||||||
u8 startV = gbSgbPacket[2] & 0x1f;
|
uint8_t startV = gbSgbPacket[2] & 0x1f;
|
||||||
int nDataSet = READ16LE(((u16*)&gbSgbPacket[3]));
|
int nDataSet = READ16LE(((uint16_t*)&gbSgbPacket[3]));
|
||||||
int style = gbSgbPacket[5] & 1;
|
int style = gbSgbPacket[5] & 1;
|
||||||
if (startH > 19)
|
if (startH > 19)
|
||||||
startH = 19;
|
startH = 19;
|
||||||
if (startV > 17)
|
if (startV > 17)
|
||||||
startV = 17;
|
startV = 17;
|
||||||
|
|
||||||
u8 s = 6;
|
uint8_t s = 6;
|
||||||
u8* fromAddress = &gbSgbPacket[6];
|
uint8_t* fromAddress = &gbSgbPacket[6];
|
||||||
u8 v = *fromAddress++;
|
uint8_t v = *fromAddress++;
|
||||||
|
|
||||||
if (style) {
|
if (style) {
|
||||||
while (nDataSet) {
|
while (nDataSet) {
|
||||||
u8 p = (v >> s) & 3;
|
uint8_t p = (v >> s) & 3;
|
||||||
gbSgbATF[startV * 20 + startH] = p;
|
gbSgbATF[startV * 20 + startH] = p;
|
||||||
startV++;
|
startV++;
|
||||||
if (startV == 18) {
|
if (startV == 18) {
|
||||||
|
@ -563,7 +563,7 @@ void gbSgbAttributeCharacter()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (nDataSet) {
|
while (nDataSet) {
|
||||||
u8 p = (v >> s) & 3;
|
uint8_t p = (v >> s) & 3;
|
||||||
gbSgbATF[startV * 20 + startH] = p;
|
gbSgbATF[startV * 20 + startH] = p;
|
||||||
startH++;
|
startH++;
|
||||||
if (startH == 20) {
|
if (startH == 20) {
|
||||||
|
@ -588,13 +588,13 @@ void gbSgbSetATFList()
|
||||||
{
|
{
|
||||||
gbSgbRenderScreenToBuffer();
|
gbSgbRenderScreenToBuffer();
|
||||||
|
|
||||||
u8* fromAddress = gbSgbScreenBuffer;
|
uint8_t* fromAddress = gbSgbScreenBuffer;
|
||||||
u8* toAddress = gbSgbATFList;
|
uint8_t* toAddress = gbSgbATFList;
|
||||||
|
|
||||||
for (int i = 0; i < 45; i++) {
|
for (int i = 0; i < 45; i++) {
|
||||||
for (int j = 0; j < 90; j++) {
|
for (int j = 0; j < 90; j++) {
|
||||||
u8 v = *fromAddress++;
|
uint8_t v = *fromAddress++;
|
||||||
u8 s = 6;
|
uint8_t s = 6;
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
s = 6;
|
s = 6;
|
||||||
for (int k = 0; k < 4; k++) {
|
for (int k = 0; k < 4; k++) {
|
||||||
|
@ -616,7 +616,7 @@ void gbSgbMaskEnable()
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
gbSgbFillScreen(0x0000);
|
gbSgbFillScreen(0x0000);
|
||||||
// memset(&gbPalette[0], 0, 128*sizeof(u16));
|
// memset(&gbPalette[0], 0, 128*sizeof(uint16_t));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
gbSgbFillScreen(gbPalette[0]);
|
gbSgbFillScreen(gbPalette[0]);
|
||||||
|
@ -684,16 +684,16 @@ void gbSgbCommand()
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
gbSgbSetPalette(0, 1, (u16*)&gbSgbPacket[1]);
|
gbSgbSetPalette(0, 1, (uint16_t*)&gbSgbPacket[1]);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
gbSgbSetPalette(2, 3, (u16*)&gbSgbPacket[1]);
|
gbSgbSetPalette(2, 3, (uint16_t*)&gbSgbPacket[1]);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
gbSgbSetPalette(0, 3, (u16*)&gbSgbPacket[1]);
|
gbSgbSetPalette(0, 3, (uint16_t*)&gbSgbPacket[1]);
|
||||||
break;
|
break;
|
||||||
case 0x03:
|
case 0x03:
|
||||||
gbSgbSetPalette(1, 2, (u16*)&gbSgbPacket[1]);
|
gbSgbSetPalette(1, 2, (uint16_t*)&gbSgbPacket[1]);
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
gbSgbAttributeBlock();
|
gbSgbAttributeBlock();
|
||||||
|
@ -740,7 +740,7 @@ void gbSgbResetPacketState()
|
||||||
gbSgbPacketTimeout = 0;
|
gbSgbPacketTimeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSgbDoBitTransfer(u8 value)
|
void gbSgbDoBitTransfer(uint8_t value)
|
||||||
{
|
{
|
||||||
value = value & 0x30;
|
value = value & 0x30;
|
||||||
switch (gbSgbPacketState) {
|
switch (gbSgbPacketState) {
|
||||||
|
@ -841,8 +841,8 @@ variable_desc gbSgbSaveStruct[] = {
|
||||||
{ &gbSgbPacketByte, sizeof(int) },
|
{ &gbSgbPacketByte, sizeof(int) },
|
||||||
{ &gbSgbPacketNumber, sizeof(int) },
|
{ &gbSgbPacketNumber, sizeof(int) },
|
||||||
{ &gbSgbMultiplayer, sizeof(int) },
|
{ &gbSgbMultiplayer, sizeof(int) },
|
||||||
{ &gbSgbNextController, sizeof(u8) },
|
{ &gbSgbNextController, sizeof(uint8_t) },
|
||||||
{ &gbSgbReadingController, sizeof(u8) },
|
{ &gbSgbReadingController, sizeof(uint8_t) },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -854,8 +854,8 @@ variable_desc gbSgbSaveStructV3[] = {
|
||||||
{ &gbSgbPacketByte, sizeof(int) },
|
{ &gbSgbPacketByte, sizeof(int) },
|
||||||
{ &gbSgbPacketNumber, sizeof(int) },
|
{ &gbSgbPacketNumber, sizeof(int) },
|
||||||
{ &gbSgbMultiplayer, sizeof(int) },
|
{ &gbSgbMultiplayer, sizeof(int) },
|
||||||
{ &gbSgbNextController, sizeof(u8) },
|
{ &gbSgbNextController, sizeof(uint8_t) },
|
||||||
{ &gbSgbReadingController, sizeof(u8) },
|
{ &gbSgbReadingController, sizeof(uint8_t) },
|
||||||
{ &gbSgbFourPlayers, sizeof(int) },
|
{ &gbSgbFourPlayers, sizeof(int) },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
@ -869,7 +869,7 @@ void gbSgbSaveGame(gzFile gzFile)
|
||||||
|
|
||||||
utilGzWrite(gzFile, gbSgbPacket, 16 * 7);
|
utilGzWrite(gzFile, gbSgbPacket, 16 * 7);
|
||||||
|
|
||||||
utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
|
utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(uint16_t));
|
||||||
utilGzWrite(gzFile, gbSgbATF, 20 * 18);
|
utilGzWrite(gzFile, gbSgbATF, 20 * 18);
|
||||||
utilGzWrite(gzFile, gbSgbATFList, 45 * 20 * 18);
|
utilGzWrite(gzFile, gbSgbATFList, 45 * 20 * 18);
|
||||||
}
|
}
|
||||||
|
@ -890,7 +890,7 @@ void gbSgbReadGame(gzFile gzFile, int version)
|
||||||
|
|
||||||
utilGzRead(gzFile, gbSgbPacket, 16 * 7);
|
utilGzRead(gzFile, gbSgbPacket, 16 * 7);
|
||||||
|
|
||||||
utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
|
utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(uint16_t));
|
||||||
utilGzRead(gzFile, gbSgbATF, 20 * 18);
|
utilGzRead(gzFile, gbSgbATF, 20 * 18);
|
||||||
utilGzRead(gzFile, gbSgbATFList, 45 * 20 * 18);
|
utilGzRead(gzFile, gbSgbATFList, 45 * 20 * 18);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,18 @@ void gbSgbShutdown();
|
||||||
void gbSgbCommand();
|
void gbSgbCommand();
|
||||||
void gbSgbResetPacketState();
|
void gbSgbResetPacketState();
|
||||||
void gbSgbReset();
|
void gbSgbReset();
|
||||||
void gbSgbDoBitTransfer(u8);
|
void gbSgbDoBitTransfer(uint8_t);
|
||||||
void gbSgbSaveGame(gzFile);
|
void gbSgbSaveGame(gzFile);
|
||||||
void gbSgbReadGame(gzFile, int version);
|
void gbSgbReadGame(gzFile, int version);
|
||||||
void gbSgbRenderBorder();
|
void gbSgbRenderBorder();
|
||||||
|
|
||||||
extern u8 gbSgbATF[20 * 18];
|
extern uint8_t gbSgbATF[20 * 18];
|
||||||
extern int gbSgbMode;
|
extern int gbSgbMode;
|
||||||
extern int gbSgbMask;
|
extern int gbSgbMask;
|
||||||
extern int gbSgbMultiplayer;
|
extern int gbSgbMultiplayer;
|
||||||
extern u8 gbSgbNextController;
|
extern uint8_t gbSgbNextController;
|
||||||
extern int gbSgbPacketTimeout;
|
extern int gbSgbPacketTimeout;
|
||||||
extern u8 gbSgbReadingController;
|
extern uint8_t gbSgbReadingController;
|
||||||
extern int gbSgbFourPlayers;
|
extern int gbSgbFourPlayers;
|
||||||
|
|
||||||
#endif // GBSGB_H
|
#endif // GBSGB_H
|
||||||
|
|
|
@ -29,7 +29,7 @@ static inline blip_time_t blip_time()
|
||||||
return (SOUND_CLOCK_TICKS - soundTicks) * ticks_to_time;
|
return (SOUND_CLOCK_TICKS - soundTicks) * ticks_to_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 gbSoundRead(u16 address)
|
uint8_t gbSoundRead(uint16_t address)
|
||||||
{
|
{
|
||||||
if (gb_apu && address >= NR10 && address <= 0xFF3F)
|
if (gb_apu && address >= NR10 && address <= 0xFF3F)
|
||||||
return gb_apu->read_register(blip_time(), address);
|
return gb_apu->read_register(blip_time(), address);
|
||||||
|
@ -37,7 +37,7 @@ u8 gbSoundRead(u16 address)
|
||||||
return gbMemory[address];
|
return gbMemory[address];
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbSoundEvent(register u16 address, register int data)
|
void gbSoundEvent(register uint16_t address, register int data)
|
||||||
{
|
{
|
||||||
gbMemory[address] = data;
|
gbMemory[address] = data;
|
||||||
|
|
||||||
|
@ -326,9 +326,9 @@ static variable_desc gbsound_format2[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static variable_desc gbsound_format3[] = {
|
static variable_desc gbsound_format3[] = {
|
||||||
SKIP(u8[2 * 735], soundBuffer),
|
SKIP(uint8_t[2 * 735], soundBuffer),
|
||||||
SKIP(u8[2 * 735], soundBuffer),
|
SKIP(uint8_t[2 * 735], soundBuffer),
|
||||||
SKIP(u16[735], soundFinalWave),
|
SKIP(uint16_t[735], soundFinalWave),
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ static variable_desc gb_state[] = {
|
||||||
LOAD(int, state.version), // room_for_expansion will be used by later versions
|
LOAD(int, state.version), // room_for_expansion will be used by later versions
|
||||||
|
|
||||||
// APU
|
// APU
|
||||||
LOAD(u8[0x40], state.apu.regs), // last values written to registers and wave RAM (both banks)
|
LOAD(uint8_t[0x40], state.apu.regs), // last values written to registers and wave RAM (both banks)
|
||||||
LOAD(int, state.apu.frame_time), // clocks until next frame sequencer action
|
LOAD(int, state.apu.frame_time), // clocks until next frame sequencer action
|
||||||
LOAD(int, state.apu.frame_phase), // next step frame sequencer will run
|
LOAD(int, state.apu.frame_phase), // next step frame sequencer will run
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,11 @@ extern gb_effects_config_t gb_effects_config; // current configuration
|
||||||
void gbSoundReset();
|
void gbSoundReset();
|
||||||
|
|
||||||
// Emulates write to sound hardware
|
// Emulates write to sound hardware
|
||||||
void gbSoundEvent(u16 address, int data);
|
void gbSoundEvent(uint16_t address, int data);
|
||||||
#define SOUND_EVENT gbSoundEvent
|
#define SOUND_EVENT gbSoundEvent
|
||||||
|
|
||||||
// Emulates read from sound hardware
|
// Emulates read from sound hardware
|
||||||
u8 gbSoundRead(u16 address);
|
uint8_t gbSoundRead(uint16_t address);
|
||||||
|
|
||||||
// Notifies emulator that SOUND_CLOCK_TICKS clocks have passed
|
// Notifies emulator that SOUND_CLOCK_TICKS clocks have passed
|
||||||
void gbSoundTick();
|
void gbSoundTick();
|
||||||
|
|
|
@ -20,104 +20,101 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GameBoyAdvanceCheatEditDialog
|
* GameBoyAdvanceCheatEditDialog
|
||||||
*
|
*
|
||||||
* A unified cheat editing dialog for multiple code types.
|
* A unified cheat editing dialog for multiple code types.
|
||||||
*/
|
*/
|
||||||
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog)
|
: Gtk::Dialog(_pstDialog)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
|
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
|
||||||
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
|
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
|
||||||
refBuilder->get_widget("CheatInputTextView", m_poCheatInputTextView);
|
refBuilder->get_widget("CheatInputTextView", m_poCheatInputTextView);
|
||||||
refBuilder->get_widget("CheatApplyButton", m_poCheatApplyButton);
|
refBuilder->get_widget("CheatApplyButton", m_poCheatApplyButton);
|
||||||
refBuilder->get_widget("CheatCancelButton", m_poCheatCancelButton);
|
refBuilder->get_widget("CheatCancelButton", m_poCheatCancelButton);
|
||||||
|
|
||||||
// Tree View model
|
// Tree View model
|
||||||
m_poCheatTypeStore = Gtk::ListStore::create(m_oTypeModel);
|
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_poCheatApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnApply));
|
||||||
m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel));
|
m_poCheatCancelButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatEditDialog::vOnCancel));
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TextBuffer> CheatEditDialog::vGetCode()
|
Glib::RefPtr<Gtk::TextBuffer> CheatEditDialog::vGetCode()
|
||||||
{
|
{
|
||||||
return m_poCheatInputTextView->get_buffer();
|
return m_poCheatInputTextView->get_buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring CheatEditDialog::vGetDesc()
|
Glib::ustring CheatEditDialog::vGetDesc()
|
||||||
{
|
{
|
||||||
return m_poCheatDescEntry->get_text();
|
return m_poCheatDescEntry->get_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
ECheatType CheatEditDialog::vGetType()
|
ECheatType CheatEditDialog::vGetType()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
|
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
|
||||||
|
|
||||||
if (iter)
|
if (iter) {
|
||||||
{
|
Gtk::TreeModel::Row row = *iter;
|
||||||
Gtk::TreeModel::Row row = *iter;
|
|
||||||
|
|
||||||
return row[m_oTypeModel.iType];
|
return row[m_oTypeModel.iType];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CheatGeneric;
|
return CheatGeneric;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatEditDialog::vSetWindow(VBA::Window * _poWindow)
|
void CheatEditDialog::vSetWindow(VBA::Window* _poWindow)
|
||||||
{
|
{
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
|
||||||
// GameBoy Advance
|
// GameBoy Advance
|
||||||
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA)
|
if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGBA) {
|
||||||
{
|
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
|
||||||
|
|
||||||
row[m_oTypeModel.iType] = CheatGeneric;
|
row[m_oTypeModel.iType] = CheatGeneric;
|
||||||
row[m_oTypeModel.uText] = _("Generic Code");
|
row[m_oTypeModel.uText] = _("Generic Code");
|
||||||
|
|
||||||
row = *(m_poCheatTypeStore->append());
|
row = *(m_poCheatTypeStore->append());
|
||||||
|
|
||||||
row[m_oTypeModel.iType] = CheatGSA;
|
row[m_oTypeModel.iType] = CheatGSA;
|
||||||
row[m_oTypeModel.uText] = _("Gameshark Advance");
|
row[m_oTypeModel.uText] = _("Gameshark Advance");
|
||||||
|
|
||||||
row = *(m_poCheatTypeStore->append());
|
row = *(m_poCheatTypeStore->append());
|
||||||
|
|
||||||
row[m_oTypeModel.iType] = CheatCBA;
|
row[m_oTypeModel.iType] = CheatCBA;
|
||||||
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
|
row[m_oTypeModel.uText] = _("CodeBreaker Advance");
|
||||||
|
|
||||||
m_poCheatTypeComboBox->set_active(CheatGeneric);
|
m_poCheatTypeComboBox->set_active(CheatGeneric);
|
||||||
}
|
}
|
||||||
// GameBoy
|
// GameBoy
|
||||||
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB)
|
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB) {
|
||||||
{
|
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
|
||||||
|
|
||||||
row[m_oTypeModel.iType] = CheatGS;
|
row[m_oTypeModel.iType] = CheatGS;
|
||||||
row[m_oTypeModel.uText] = _("GameShark");
|
row[m_oTypeModel.uText] = _("GameShark");
|
||||||
|
|
||||||
row = *(m_poCheatTypeStore->append());
|
row = *(m_poCheatTypeStore->append());
|
||||||
|
|
||||||
row[m_oTypeModel.iType] = CheatGG;
|
row[m_oTypeModel.iType] = CheatGG;
|
||||||
row[m_oTypeModel.uText] = _("GameGenie");
|
row[m_oTypeModel.uText] = _("GameGenie");
|
||||||
|
|
||||||
m_poCheatTypeComboBox->set_active(0);
|
m_poCheatTypeComboBox->set_active(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatEditDialog::vOnApply()
|
void CheatEditDialog::vOnApply()
|
||||||
{
|
{
|
||||||
response(Gtk::RESPONSE_APPLY);
|
response(Gtk::RESPONSE_APPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatEditDialog::vOnCancel() {
|
void CheatEditDialog::vOnCancel()
|
||||||
response(Gtk::RESPONSE_CANCEL);
|
{
|
||||||
|
response(Gtk::RESPONSE_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -27,50 +27,51 @@
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
enum ECheatType { CheatGeneric,
|
||||||
enum ECheatType { CheatGeneric, CheatGSA, CheatCBA, CheatGS, CheatGG };
|
CheatGSA,
|
||||||
|
CheatCBA,
|
||||||
|
CheatGS,
|
||||||
|
CheatGG };
|
||||||
|
|
||||||
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
|
||||||
{
|
public:
|
||||||
public:
|
EditCheatCodeColumns()
|
||||||
EditCheatCodeColumns()
|
{
|
||||||
{
|
add(uText);
|
||||||
add(uText);
|
add(iType);
|
||||||
add(iType);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
~EditCheatCodeColumns()
|
~EditCheatCodeColumns()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::TreeModelColumn<Glib::ustring> uText;
|
Gtk::TreeModelColumn<Glib::ustring> uText;
|
||||||
Gtk::TreeModelColumn<ECheatType> iType;
|
Gtk::TreeModelColumn<ECheatType> iType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CheatEditDialog : public Gtk::Dialog
|
class CheatEditDialog : public Gtk::Dialog {
|
||||||
{
|
public:
|
||||||
public:
|
CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
CheatEditDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
|
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
|
||||||
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
|
Glib::ustring vGetDesc();
|
||||||
Glib::ustring vGetDesc();
|
ECheatType vGetType();
|
||||||
ECheatType vGetType();
|
void vSetWindow(VBA::Window* _poWindow);
|
||||||
void vSetWindow(VBA::Window *_poWindow);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void vOnApply();
|
void vOnApply();
|
||||||
void vOnCancel();
|
void vOnCancel();
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Gtk::Entry *m_poCheatDescEntry;
|
Gtk::Entry* m_poCheatDescEntry;
|
||||||
Gtk::ComboBox *m_poCheatTypeComboBox;
|
Gtk::ComboBox* m_poCheatTypeComboBox;
|
||||||
Gtk::TextView *m_poCheatInputTextView;
|
Gtk::TextView* m_poCheatInputTextView;
|
||||||
Gtk::Button *m_poCheatApplyButton;
|
Gtk::Button* m_poCheatApplyButton;
|
||||||
Gtk::Button *m_poCheatCancelButton;
|
Gtk::Button* m_poCheatCancelButton;
|
||||||
Glib::RefPtr<Gtk::TextBuffer> m_poCheatInputBuffer;
|
Glib::RefPtr<Gtk::TextBuffer> m_poCheatInputBuffer;
|
||||||
Glib::RefPtr<Gtk::ListStore> m_poCheatTypeStore;
|
Glib::RefPtr<Gtk::ListStore> m_poCheatTypeStore;
|
||||||
EditCheatCodeColumns m_oTypeModel;
|
EditCheatCodeColumns m_oTypeModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -24,150 +24,145 @@
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
#include <vector>
|
#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) :
|
// Tree View model
|
||||||
Gtk::Dialog(_pstDialog)
|
m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);
|
||||||
{
|
|
||||||
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_poCheatTreeView->set_model(m_poCheatListStore);
|
||||||
m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);
|
|
||||||
|
|
||||||
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)
|
m_poCheatTreeView->append_column("Description", m_oRecordModel.uDesc);
|
||||||
pColumn->add_attribute(pRenderer->property_active(), m_oRecordModel.bEnabled);
|
|
||||||
|
|
||||||
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));
|
bMark = false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatListDialog::vOnCheatListOpen()
|
void CheatListDialog::vOnCheatListOpen()
|
||||||
{
|
{
|
||||||
Gtk::FileChooserDialog oDialog(*this, _("Open cheat list"));
|
Gtk::FileChooserDialog oDialog(*this, _("Open cheat list"));
|
||||||
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
||||||
|
|
||||||
oDialog.set_current_folder(Glib::get_home_dir());
|
oDialog.set_current_folder(Glib::get_home_dir());
|
||||||
|
|
||||||
while (oDialog.run() == Gtk::RESPONSE_OK)
|
while (oDialog.run() == Gtk::RESPONSE_OK) {
|
||||||
{
|
// delete existing cheats before loading the list
|
||||||
// delete existing cheats before loading the list
|
vRemoveAllCheats();
|
||||||
vRemoveAllCheats();
|
|
||||||
|
|
||||||
m_poCheatListStore->clear();
|
m_poCheatListStore->clear();
|
||||||
|
|
||||||
if (vCheatListOpen(oDialog.get_filename().c_str()))
|
if (vCheatListOpen(oDialog.get_filename().c_str())) {
|
||||||
{
|
vUpdateList();
|
||||||
vUpdateList();
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatListDialog::vOnCheatListSave()
|
void CheatListDialog::vOnCheatListSave()
|
||||||
{
|
{
|
||||||
Gtk::FileChooserDialog sDialog(*this, _("Save cheat list"));
|
Gtk::FileChooserDialog sDialog(*this, _("Save cheat list"));
|
||||||
sDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
sDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
sDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
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)
|
if (sDialog.run() == Gtk::RESPONSE_OK)
|
||||||
vCheatListSave(sDialog.get_filename().c_str());
|
vCheatListSave(sDialog.get_filename().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatListDialog::vOnCheatAdd()
|
void CheatListDialog::vOnCheatAdd()
|
||||||
{
|
{
|
||||||
std::string sUiFile = VBA::Window::sGetUiFilePath("cheatedit.ui");
|
std::string sUiFile = VBA::Window::sGetUiFilePath("cheatedit.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
CheatEditDialog * poDialog = 0;
|
CheatEditDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("CheatEditDialog", poDialog);
|
poBuilder->get_widget_derived("CheatEditDialog", poDialog);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
poDialog->vSetWindow(m_poWindow);
|
poDialog->vSetWindow(m_poWindow);
|
||||||
int response = poDialog->run();
|
int response = poDialog->run();
|
||||||
poDialog->hide();
|
poDialog->hide();
|
||||||
|
|
||||||
if (response == Gtk::RESPONSE_APPLY)
|
if (response == Gtk::RESPONSE_APPLY)
|
||||||
vAddCheat(poDialog->vGetDesc(), poDialog->vGetType(), poDialog->vGetCode());
|
vAddCheat(poDialog->vGetDesc(), poDialog->vGetType(), poDialog->vGetCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatListDialog::vOnCheatRemove()
|
void CheatListDialog::vOnCheatRemove()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected();
|
Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected();
|
||||||
|
|
||||||
if (iter)
|
if (iter) {
|
||||||
{
|
Gtk::TreeModel::Row row = *iter;
|
||||||
Gtk::TreeModel::Row row = *iter;
|
|
||||||
|
|
||||||
vRemoveCheat(row[m_oRecordModel.iIndex]);
|
vRemoveCheat(row[m_oRecordModel.iIndex]);
|
||||||
|
|
||||||
m_poCheatListStore->erase(iter);
|
m_poCheatListStore->erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatListDialog::vOnCheatRemoveAll()
|
void CheatListDialog::vOnCheatRemoveAll()
|
||||||
{
|
{
|
||||||
vRemoveAllCheats();
|
vRemoveAllCheats();
|
||||||
|
|
||||||
m_poCheatListStore->clear();
|
m_poCheatListStore->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatListDialog::vOnCheatMarkAll()
|
void CheatListDialog::vOnCheatMarkAll()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children();
|
Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children();
|
||||||
|
|
||||||
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++)
|
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++) {
|
||||||
{
|
Gtk::TreeModel::Row row = *iter;
|
||||||
Gtk::TreeModel::Row row = *iter;
|
|
||||||
|
|
||||||
row[m_oRecordModel.bEnabled] = bMark;
|
row[m_oRecordModel.bEnabled] = bMark;
|
||||||
|
|
||||||
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)
|
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
|
} // namespace VBA
|
||||||
|
|
|
@ -25,66 +25,64 @@
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
|
||||||
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
public:
|
||||||
{
|
ListCheatCodeColumns()
|
||||||
public:
|
{
|
||||||
ListCheatCodeColumns()
|
add(iIndex);
|
||||||
{
|
add(bEnabled);
|
||||||
add(iIndex);
|
add(uDesc);
|
||||||
add(bEnabled);
|
}
|
||||||
add(uDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
~ListCheatCodeColumns()
|
~ListCheatCodeColumns()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::TreeModelColumn<int> iIndex;
|
Gtk::TreeModelColumn<int> iIndex;
|
||||||
Gtk::TreeModelColumn<bool> bEnabled;
|
Gtk::TreeModelColumn<bool> bEnabled;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> uDesc;
|
Gtk::TreeModelColumn<Glib::ustring> uDesc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CheatListDialog : public Gtk::Dialog
|
class CheatListDialog : public Gtk::Dialog {
|
||||||
{
|
public:
|
||||||
public:
|
CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
CheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
|
void vSetWindow(VBA::Window* _poWindow);
|
||||||
void vSetWindow(VBA::Window *_poWindow);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
|
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
|
||||||
Glib::RefPtr<Gtk::TextBuffer> buffer) = 0;
|
Glib::RefPtr<Gtk::TextBuffer> buffer)
|
||||||
virtual bool vCheatListOpen(const char *file) = 0;
|
= 0;
|
||||||
virtual void vCheatListSave(const char *file) = 0;
|
virtual bool vCheatListOpen(const char* file) = 0;
|
||||||
virtual void vRemoveCheat(int index) = 0;
|
virtual void vCheatListSave(const char* file) = 0;
|
||||||
virtual void vRemoveAllCheats() = 0;
|
virtual void vRemoveCheat(int index) = 0;
|
||||||
virtual void vToggleCheat(int index, bool enable) = 0;
|
virtual void vRemoveAllCheats() = 0;
|
||||||
virtual void vUpdateList(int previous = 0) = 0;
|
virtual void vToggleCheat(int index, bool enable) = 0;
|
||||||
|
virtual void vUpdateList(int previous = 0) = 0;
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::ListStore> m_poCheatListStore;
|
Glib::RefPtr<Gtk::ListStore> m_poCheatListStore;
|
||||||
ListCheatCodeColumns m_oRecordModel;
|
ListCheatCodeColumns m_oRecordModel;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void vOnCheatListOpen();
|
void vOnCheatListOpen();
|
||||||
void vOnCheatListSave();
|
void vOnCheatListSave();
|
||||||
void vOnCheatAdd();
|
void vOnCheatAdd();
|
||||||
void vOnCheatRemove();
|
void vOnCheatRemove();
|
||||||
void vOnCheatRemoveAll();
|
void vOnCheatRemoveAll();
|
||||||
void vOnCheatMarkAll();
|
void vOnCheatMarkAll();
|
||||||
void vOnCheatToggled(Glib::ustring const &string_path);
|
void vOnCheatToggled(Glib::ustring const& string_path);
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Gtk::ToolButton *m_poCheatOpenButton;
|
Gtk::ToolButton* m_poCheatOpenButton;
|
||||||
Gtk::ToolButton *m_poCheatSaveButton;
|
Gtk::ToolButton* m_poCheatSaveButton;
|
||||||
Gtk::ToolButton *m_poCheatAddButton;
|
Gtk::ToolButton* m_poCheatAddButton;
|
||||||
Gtk::ToolButton *m_poCheatRemoveButton;
|
Gtk::ToolButton* m_poCheatRemoveButton;
|
||||||
Gtk::ToolButton *m_poCheatRemoveAllButton;
|
Gtk::ToolButton* m_poCheatRemoveAllButton;
|
||||||
Gtk::ToolButton *m_poCheatMarkAllButton;
|
Gtk::ToolButton* m_poCheatMarkAllButton;
|
||||||
Gtk::TreeView *m_poCheatTreeView;
|
Gtk::TreeView* m_poCheatTreeView;
|
||||||
|
|
||||||
bool bMark;
|
bool bMark;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -23,239 +23,203 @@
|
||||||
#include <glibmm/fileutils.h>
|
#include <glibmm/fileutils.h>
|
||||||
#include <glibmm/iochannel.h>
|
#include <glibmm/iochannel.h>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
namespace Config {
|
||||||
namespace Config
|
|
||||||
{
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using Glib::IOChannel;
|
using Glib::IOChannel;
|
||||||
|
|
||||||
Line::Line(const string & _rsKey, const string & _rsValue) :
|
Line::Line(const string& _rsKey, const string& _rsValue)
|
||||||
m_sKey(_rsKey),
|
: m_sKey(_rsKey)
|
||||||
m_sValue(_rsValue)
|
, m_sValue(_rsValue)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Section::Section(const string & _rsName) :
|
|
||||||
m_sName(_rsName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Section::bKeyExists(const string & _rsKey)
|
|
||||||
{
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->m_sKey == _rsKey)
|
|
||||||
{
|
{
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Section::vSetKey(const string & _rsKey, const string & _rsValue)
|
Section::Section(const string& _rsName)
|
||||||
{
|
: m_sName(_rsName)
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->m_sKey == _rsKey)
|
|
||||||
{
|
{
|
||||||
it->m_sValue = _rsValue;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
push_back(Line(_rsKey, _rsValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
string Section::sGetKey(const string & _rsKey) const
|
bool Section::bKeyExists(const string& _rsKey)
|
||||||
{
|
|
||||||
for (const_iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->m_sKey == _rsKey)
|
|
||||||
{
|
{
|
||||||
return it->m_sValue;
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
}
|
if (it->m_sKey == _rsKey) {
|
||||||
}
|
return true;
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
else
|
return false;
|
||||||
{
|
}
|
||||||
try
|
|
||||||
{
|
void Section::vSetKey(const string& _rsKey, const string& _rsValue)
|
||||||
poSection = poGetSection(&lines[i][1]);
|
{
|
||||||
}
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
catch (...)
|
if (it->m_sKey == _rsKey) {
|
||||||
{
|
it->m_sValue = _rsValue;
|
||||||
poSection = NULL;
|
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], '=')))
|
for (const_iterator it = begin(); it != end(); it++) {
|
||||||
{
|
if (it->m_sKey == _rsKey) {
|
||||||
*tmp = '\0';
|
return it->m_sValue;
|
||||||
tmp++;
|
}
|
||||||
if (_bAddKey || poSection->bKeyExists(lines[i]))
|
|
||||||
{
|
|
||||||
poSection->vSetKey(lines[i], tmp);
|
|
||||||
}
|
}
|
||||||
}
|
throw KeyNotFound(m_sName, _rsKey);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
|
||||||
g_strfreev(lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
void File::vSave(const string & _rsFile)
|
void Section::vRemoveKey(const string& _rsKey)
|
||||||
{
|
|
||||||
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";
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
poFile->write(sLine);
|
if (it->m_sKey == _rsKey) {
|
||||||
|
erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
poFile->write("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void File::vClear()
|
File::File()
|
||||||
{
|
|
||||||
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";
|
|
||||||
}
|
File::File(const string& _rsFile)
|
||||||
return _roOut;
|
{
|
||||||
}
|
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 Config
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -23,27 +23,24 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
namespace Config {
|
||||||
namespace Config
|
class NotFound {
|
||||||
{
|
public:
|
||||||
class NotFound
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~NotFound()
|
virtual ~NotFound()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NotFound()
|
NotFound()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SectionNotFound : public NotFound
|
class SectionNotFound : public NotFound {
|
||||||
{
|
public:
|
||||||
public:
|
SectionNotFound(const std::string& _rsName)
|
||||||
SectionNotFound(const std::string &_rsName) : m_sName(_rsName)
|
: m_sName(_rsName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~SectionNotFound()
|
virtual ~SectionNotFound()
|
||||||
|
@ -52,18 +49,18 @@ class SectionNotFound : public NotFound
|
||||||
|
|
||||||
inline std::string sGetName() const
|
inline std::string sGetName() const
|
||||||
{
|
{
|
||||||
return m_sName;
|
return m_sName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_sName;
|
std::string m_sName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeyNotFound : public NotFound
|
class KeyNotFound : public NotFound {
|
||||||
{
|
public:
|
||||||
public:
|
KeyNotFound(const std::string& _rsSection, const std::string& _rsKey)
|
||||||
KeyNotFound(const std::string &_rsSection, const std::string &_rsKey)
|
: m_sSection(_rsSection)
|
||||||
: m_sSection(_rsSection), m_sKey(_rsKey)
|
, m_sKey(_rsKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~KeyNotFound()
|
virtual ~KeyNotFound()
|
||||||
|
@ -72,135 +69,136 @@ class KeyNotFound : public NotFound
|
||||||
|
|
||||||
inline std::string sGetSection() const
|
inline std::string sGetSection() const
|
||||||
{
|
{
|
||||||
return m_sSection;
|
return m_sSection;
|
||||||
}
|
}
|
||||||
inline std::string sGetKey() const
|
inline std::string sGetKey() const
|
||||||
{
|
{
|
||||||
return m_sKey;
|
return m_sKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_sSection;
|
std::string m_sSection;
|
||||||
std::string m_sKey;
|
std::string m_sKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Line
|
class Line {
|
||||||
{
|
public:
|
||||||
public:
|
Line(const std::string& _rsKey, const std::string& _rsValue);
|
||||||
Line(const std::string &_rsKey, const std::string &_rsValue);
|
|
||||||
|
|
||||||
std::string m_sKey;
|
std::string m_sKey;
|
||||||
std::string m_sValue;
|
std::string m_sValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Section : private std::list<Line>
|
class Section : private std::list<Line> {
|
||||||
{
|
public:
|
||||||
public:
|
explicit Section(const std::string& _rsName);
|
||||||
explicit Section(const std::string &_rsName);
|
|
||||||
|
|
||||||
inline std::string sGetName() const
|
inline std::string sGetName() const
|
||||||
{
|
{
|
||||||
return m_sName;
|
return m_sName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bKeyExists(const std::string &_rsKey);
|
bool bKeyExists(const std::string& _rsKey);
|
||||||
void vSetKey(const std::string &_rsKey, const std::string &_rsValue);
|
void vSetKey(const std::string& _rsKey, const std::string& _rsValue);
|
||||||
std::string sGetKey(const std::string &_rsKey) const;
|
std::string sGetKey(const std::string& _rsKey) const;
|
||||||
void vRemoveKey(const std::string &_rsKey);
|
void vRemoveKey(const std::string& _rsKey);
|
||||||
|
|
||||||
template <typename T> void vSetKey(const std::string &_rsKey, const T &_rValue);
|
template <typename T>
|
||||||
|
void vSetKey(const std::string& _rsKey, const T& _rValue);
|
||||||
|
|
||||||
template <typename T> T oGetKey(const std::string &_rsKey) const;
|
template <typename T>
|
||||||
|
T oGetKey(const std::string& _rsKey) const;
|
||||||
|
|
||||||
// read only
|
// read only
|
||||||
typedef std::list<Line>::const_iterator const_iterator;
|
typedef std::list<Line>::const_iterator const_iterator;
|
||||||
inline const_iterator begin() const
|
inline const_iterator begin() const
|
||||||
{
|
{
|
||||||
return std::list<Line>::begin();
|
return std::list<Line>::begin();
|
||||||
}
|
}
|
||||||
inline const_iterator end() const
|
inline const_iterator end() const
|
||||||
{
|
{
|
||||||
return std::list<Line>::end();
|
return std::list<Line>::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline iterator begin()
|
inline iterator begin()
|
||||||
{
|
{
|
||||||
return std::list<Line>::begin();
|
return std::list<Line>::begin();
|
||||||
}
|
}
|
||||||
inline iterator end()
|
inline iterator end()
|
||||||
{
|
{
|
||||||
return std::list<Line>::end();
|
return std::list<Line>::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_sName;
|
std::string m_sName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class File : private std::list<Section>
|
class File : private std::list<Section> {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
File();
|
File();
|
||||||
File(const std::string &_rsFile);
|
File(const std::string& _rsFile);
|
||||||
virtual ~File();
|
virtual ~File();
|
||||||
|
|
||||||
bool bSectionExists(const std::string &_rsName);
|
bool bSectionExists(const std::string& _rsName);
|
||||||
Section *poAddSection(const std::string &_rsName);
|
Section* poAddSection(const std::string& _rsName);
|
||||||
Section *poGetSection(const std::string &_rsName);
|
Section* poGetSection(const std::string& _rsName);
|
||||||
void vRemoveSection(const std::string &_rsName);
|
void vRemoveSection(const std::string& _rsName);
|
||||||
void vLoad(const std::string &_rsFile, bool _bAddSection = true, bool _bAddKey = true);
|
void vLoad(const std::string& _rsFile, bool _bAddSection = true, bool _bAddKey = true);
|
||||||
void vSave(const std::string &_rsFile);
|
void vSave(const std::string& _rsFile);
|
||||||
void vClear();
|
void vClear();
|
||||||
|
|
||||||
// read only
|
// read only
|
||||||
typedef std::list<Section>::const_iterator const_iterator;
|
typedef std::list<Section>::const_iterator const_iterator;
|
||||||
inline const_iterator begin() const
|
inline const_iterator begin() const
|
||||||
{
|
{
|
||||||
return std::list<Section>::begin();
|
return std::list<Section>::begin();
|
||||||
}
|
}
|
||||||
inline const_iterator end() const
|
inline const_iterator end() const
|
||||||
{
|
{
|
||||||
return std::list<Section>::end();
|
return std::list<Section>::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline iterator begin()
|
inline iterator begin()
|
||||||
{
|
{
|
||||||
return std::list<Section>::begin();
|
return std::list<Section>::begin();
|
||||||
}
|
}
|
||||||
inline iterator end()
|
inline iterator end()
|
||||||
{
|
{
|
||||||
return std::list<Section>::end();
|
return std::list<Section>::end();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
std::ostream &operator<<(std::ostream &_roOut, const File &_roConfig);
|
std::ostream& operator<<(std::ostream& _roOut, const File& _roConfig);
|
||||||
|
|
||||||
template <typename T> void Section::vSetKey(const std::string &_rsKey, const T &_rValue)
|
template <typename T>
|
||||||
{
|
void Section::vSetKey(const std::string& _rsKey, const T& _rValue)
|
||||||
|
{
|
||||||
std::ostringstream oOut;
|
std::ostringstream oOut;
|
||||||
oOut << _rValue;
|
oOut << _rValue;
|
||||||
for (iterator it = begin(); it != end(); it++) {
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
if (it->m_sKey == _rsKey) {
|
if (it->m_sKey == _rsKey) {
|
||||||
it->m_sValue = oOut.str();
|
it->m_sValue = oOut.str();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push_back(Line(_rsKey, oOut.str()));
|
push_back(Line(_rsKey, oOut.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> T Section::oGetKey(const std::string &_rsKey) const
|
template <typename T>
|
||||||
{
|
T Section::oGetKey(const std::string& _rsKey) const
|
||||||
|
{
|
||||||
T oValue;
|
T oValue;
|
||||||
for (const_iterator it = begin(); it != end(); it++) {
|
for (const_iterator it = begin(); it != end(); it++) {
|
||||||
if (it->m_sKey == _rsKey) {
|
if (it->m_sKey == _rsKey) {
|
||||||
std::istringstream oIn(it->m_sValue);
|
std::istringstream oIn(it->m_sValue);
|
||||||
oIn >> oValue;
|
oIn >> oValue;
|
||||||
return oValue;
|
return oValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw KeyNotFound(m_sName, _rsKey);
|
throw KeyNotFound(m_sName, _rsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -22,48 +22,44 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] =
|
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = {
|
||||||
{
|
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
|
||||||
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
|
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
|
||||||
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
|
|
||||||
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
|
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
|
||||||
{ "cheats", N_("Cheats :"), "CheatsDirEntry" },
|
{ "cheats", N_("Cheats :"), "CheatsDirEntry" },
|
||||||
{ "saves", N_("Saves :"), "SavesDirEntry" },
|
{ "saves", N_("Saves :"), "SavesDirEntry" },
|
||||||
{ "captures", N_("Captures :"), "CapturesDirEntry" }
|
{ "captures", N_("Captures :"), "CapturesDirEntry" }
|
||||||
};
|
};
|
||||||
|
|
||||||
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section * _poConfig) :
|
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section* _poConfig)
|
||||||
Gtk::Dialog(_("Directories config"), true),
|
: Gtk::Dialog(_("Directories config"), true)
|
||||||
m_poConfig(_poConfig)
|
, m_poConfig(_poConfig)
|
||||||
{
|
{
|
||||||
Gtk::Table * poTable = Gtk::manage( new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
|
Gtk::Table* poTable = Gtk::manage(new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
|
||||||
poTable->set_border_width(5);
|
poTable->set_border_width(5);
|
||||||
poTable->set_spacings(5);
|
poTable->set_spacings(5);
|
||||||
|
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
|
||||||
{
|
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END));
|
||||||
Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END) );
|
m_poButtons[i] = Gtk::manage(new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
|
||||||
m_poButtons[i] = Gtk::manage( new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) );
|
m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey));
|
||||||
m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey));
|
|
||||||
|
|
||||||
poTable->attach(* poLabel, 0, 1, i, i + 1);
|
poTable->attach(*poLabel, 0, 1, i, i + 1);
|
||||||
poTable->attach(* m_poButtons[i], 1, 2, i, i + 1);
|
poTable->attach(*m_poButtons[i], 1, 2, i, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
|
add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
|
||||||
get_vbox()->pack_start(* poTable);
|
get_vbox()->pack_start(*poTable);
|
||||||
show_all_children();
|
show_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoriesConfigDialog::on_response(int response_id)
|
void DirectoriesConfigDialog::on_response(int response_id)
|
||||||
{
|
{
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
|
||||||
{
|
m_poConfig->vSetKey(m_astDirs[i].m_csKey, m_poButtons[i]->get_current_folder());
|
||||||
m_poConfig->vSetKey(m_astDirs[i].m_csKey, m_poButtons[i]->get_current_folder());
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -26,26 +26,24 @@
|
||||||
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class DirectoriesConfigDialog : public Gtk::Dialog {
|
||||||
class DirectoriesConfigDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
DirectoriesConfigDialog(Config::Section* _poConfig);
|
||||||
public:
|
|
||||||
DirectoriesConfigDialog(Config::Section *_poConfig);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_response(int response_id);
|
void on_response(int response_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SDirEntry {
|
struct SDirEntry {
|
||||||
const char *m_csKey;
|
const char* m_csKey;
|
||||||
const char *m_csLabel;
|
const char* m_csLabel;
|
||||||
const char *m_csFileChooserButton;
|
const char* m_csFileChooserButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
static const SDirEntry m_astDirs[];
|
static const SDirEntry m_astDirs[];
|
||||||
Gtk::FileChooserButton *m_poButtons[6];
|
Gtk::FileChooserButton* m_poButtons[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -18,129 +18,119 @@
|
||||||
|
|
||||||
#include "displayconfig.h"
|
#include "displayconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/radiobutton.h>
|
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
#include <gtkmm/radiobutton.h>
|
#include <gtkmm/radiobutton.h>
|
||||||
|
#include <gtkmm/radiobutton.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
|
|
||||||
|
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
|
: 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) :
|
m_poFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterChanged));
|
||||||
Gtk::Dialog(_pstDialog),
|
m_poIBFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterIBChanged));
|
||||||
m_poConfig(0)
|
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));
|
||||||
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
|
m_poOutputCairoRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputCairo));
|
||||||
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));
|
// Populate the filters combobox
|
||||||
m_poIBFiltersComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnFilterIBChanged));
|
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
|
||||||
m_poDefaultScaleComboBox->signal_changed().connect(sigc::mem_fun(*this, &DisplayConfigDialog::vOnScaleChanged));
|
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
|
||||||
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));
|
|
||||||
|
|
||||||
|
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
|
// Populate the interframe blending filters combobox
|
||||||
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
|
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
|
||||||
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
|
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
|
||||||
|
|
||||||
for (guint i = FirstFilter; i <= LastFilter; i++)
|
for (guint i = FirstFilterIB; i <= LastFilterIB; i++) {
|
||||||
{
|
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
|
||||||
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
|
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
|
||||||
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)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
|
void DisplayConfigDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
|
||||||
{
|
{
|
||||||
m_poConfig = _poConfig;
|
m_poConfig = _poConfig;
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
|
||||||
int iDefaultFilter = m_poConfig->oGetKey<int>("filter2x");
|
int iDefaultFilter = m_poConfig->oGetKey<int>("filter2x");
|
||||||
m_poFiltersComboBox->set_active(iDefaultFilter);
|
m_poFiltersComboBox->set_active(iDefaultFilter);
|
||||||
|
|
||||||
int iDefaultFilterIB = m_poConfig->oGetKey<int>("filterIB");
|
int iDefaultFilterIB = m_poConfig->oGetKey<int>("filterIB");
|
||||||
m_poIBFiltersComboBox->set_active(iDefaultFilterIB);
|
m_poIBFiltersComboBox->set_active(iDefaultFilterIB);
|
||||||
|
|
||||||
int iDefaultScale = m_poConfig->oGetKey<int>("scale");
|
int iDefaultScale = m_poConfig->oGetKey<int>("scale");
|
||||||
m_poDefaultScaleComboBox->set_active(iDefaultScale - 1);
|
m_poDefaultScaleComboBox->set_active(iDefaultScale - 1);
|
||||||
|
|
||||||
// Set the default output module
|
// Set the default output module
|
||||||
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
|
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
|
||||||
switch (_eOutput)
|
switch (_eOutput) {
|
||||||
{
|
|
||||||
case VBA::Window::OutputOpenGL:
|
case VBA::Window::OutputOpenGL:
|
||||||
m_poOutputOpenGLRadioButton->set_active();
|
m_poOutputOpenGLRadioButton->set_active();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
m_poOutputCairoRadioButton->set_active();
|
m_poOutputCairoRadioButton->set_active();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayConfigDialog::vOnFilterChanged()
|
void DisplayConfigDialog::vOnFilterChanged()
|
||||||
{
|
{
|
||||||
int iFilter = m_poFiltersComboBox->get_active_row_number();
|
int iFilter = m_poFiltersComboBox->get_active_row_number();
|
||||||
if (iFilter >= 0)
|
if (iFilter >= 0) {
|
||||||
{
|
m_poConfig->vSetKey("filter2x", iFilter);
|
||||||
m_poConfig->vSetKey("filter2x", iFilter);
|
m_poWindow->vApplyConfigFilter();
|
||||||
m_poWindow->vApplyConfigFilter();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayConfigDialog::vOnFilterIBChanged()
|
void DisplayConfigDialog::vOnFilterIBChanged()
|
||||||
{
|
{
|
||||||
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
|
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
|
||||||
if (iFilterIB >= 0)
|
if (iFilterIB >= 0) {
|
||||||
{
|
m_poConfig->vSetKey("filterIB", iFilterIB);
|
||||||
m_poConfig->vSetKey("filterIB", iFilterIB);
|
m_poWindow->vApplyConfigFilterIB();
|
||||||
m_poWindow->vApplyConfigFilterIB();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
|
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)
|
if (_eOutput == eOldOutput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active())
|
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active()) {
|
||||||
{
|
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
|
||||||
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
|
m_poWindow->vApplyConfigScreenArea();
|
||||||
m_poWindow->vApplyConfigScreenArea();
|
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active()) {
|
||||||
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active())
|
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
|
||||||
{
|
m_poWindow->vApplyConfigScreenArea();
|
||||||
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
|
}
|
||||||
m_poWindow->vApplyConfigScreenArea();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayConfigDialog::vOnScaleChanged()
|
void DisplayConfigDialog::vOnScaleChanged()
|
||||||
{
|
{
|
||||||
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
|
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
|
||||||
if (iScale > 0)
|
if (iScale > 0) {
|
||||||
{
|
m_poConfig->vSetKey("scale", iScale);
|
||||||
m_poConfig->vSetKey("scale", iScale);
|
m_poWindow->vUpdateScreen();
|
||||||
m_poWindow->vUpdateScreen();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -27,29 +27,27 @@
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class DisplayConfigDialog : public Gtk::Dialog {
|
||||||
class DisplayConfigDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
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:
|
private:
|
||||||
void vOnFilterChanged();
|
void vOnFilterChanged();
|
||||||
void vOnFilterIBChanged();
|
void vOnFilterIBChanged();
|
||||||
void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput);
|
void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput);
|
||||||
void vOnScaleChanged();
|
void vOnScaleChanged();
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
Gtk::ComboBox *m_poFiltersComboBox;
|
Gtk::ComboBox* m_poFiltersComboBox;
|
||||||
Gtk::ComboBox *m_poIBFiltersComboBox;
|
Gtk::ComboBox* m_poIBFiltersComboBox;
|
||||||
Gtk::ComboBox *m_poDefaultScaleComboBox;
|
Gtk::ComboBox* m_poDefaultScaleComboBox;
|
||||||
Gtk::RadioButton *m_poOutputOpenGLRadioButton;
|
Gtk::RadioButton* m_poOutputOpenGLRadioButton;
|
||||||
Gtk::RadioButton *m_poOutputCairoRadioButton;
|
Gtk::RadioButton* m_poOutputCairoRadioButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -19,89 +19,84 @@
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
void _2xSaI (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 _2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void Super2xSaI (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 Super2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void SuperEagle (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 SuperEagle32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void Pixelate (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 Pixelate32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void AdMame2x (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 AdMame2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void Bilinear (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 Bilinear32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void BilinearPlus (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 BilinearPlus32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void Scanlines (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 Scanlines32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void ScanlinesTV (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 ScanlinesTV32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void hq2x (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 hq2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void lq2x (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 lq2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
void xbrz2x32 (u8 *, u32, u8 *, u8 *, u32, int, int);
|
void xbrz2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
|
|
||||||
void SmartIB (u8 *, u32, int, int);
|
void SmartIB(u8*, u32, int, int);
|
||||||
void SmartIB32 (u8 *, u32, int, int);
|
void SmartIB32(u8*, u32, int, int);
|
||||||
void MotionBlurIB (u8 *, u32, int, int);
|
void MotionBlurIB(u8*, u32, int, int);
|
||||||
void MotionBlurIB32(u8 *, u32, int, int);
|
void MotionBlurIB32(u8*, u32, int, int);
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char m_csName[30];
|
char m_csName[30];
|
||||||
int m_iEnlargeFactor;
|
int m_iEnlargeFactor;
|
||||||
Filter m_apvFunc[2];
|
Filter m_apvFunc[2];
|
||||||
}
|
} static const astFilters[] = {
|
||||||
static const astFilters[] =
|
{ N_("None"), 1, { 0, 0 } },
|
||||||
{
|
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
|
||||||
{ N_("None"), 1, { 0, 0 } },
|
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
|
||||||
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
|
{ N_("Super Eagle"), 2, { SuperEagle, SuperEagle32 } },
|
||||||
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
|
{ N_("Pixelate"), 2, { Pixelate, Pixelate32 } },
|
||||||
{ N_("Super Eagle"), 2, { SuperEagle, SuperEagle32 } },
|
{ N_("AdvanceMAME Scale2x"), 2, { AdMame2x, AdMame2x32 } },
|
||||||
{ N_("Pixelate"), 2, { Pixelate, Pixelate32 } },
|
{ N_("Bilinear"), 2, { Bilinear, Bilinear32 } },
|
||||||
{ N_("AdvanceMAME Scale2x"), 2, { AdMame2x, AdMame2x32 } },
|
{ N_("Bilinear Plus"), 2, { BilinearPlus, BilinearPlus32 } },
|
||||||
{ N_("Bilinear"), 2, { Bilinear, Bilinear32 } },
|
{ N_("Scanlines"), 2, { Scanlines, Scanlines32 } },
|
||||||
{ N_("Bilinear Plus"), 2, { BilinearPlus, BilinearPlus32 } },
|
{ N_("TV Mode"), 2, { ScanlinesTV, ScanlinesTV32 } },
|
||||||
{ N_("Scanlines"), 2, { Scanlines, Scanlines32 } },
|
{ N_("hq2x"), 2, { hq2x, hq2x32 } },
|
||||||
{ N_("TV Mode"), 2, { ScanlinesTV, ScanlinesTV32 } },
|
{ N_("lq2x"), 2, { lq2x, lq2x32 } },
|
||||||
{ N_("hq2x"), 2, { hq2x, hq2x32 } },
|
{ N_("xbrz2x"), 2, { 0, xbrz2x32 } }
|
||||||
{ N_("lq2x"), 2, { lq2x, lq2x32 } },
|
|
||||||
{ N_("xbrz2x"), 2, { 0, xbrz2x32 } }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char m_csName[30];
|
char m_csName[30];
|
||||||
FilterIB m_apvFunc[2];
|
FilterIB m_apvFunc[2];
|
||||||
}
|
} static const astFiltersIB[] = {
|
||||||
static const astFiltersIB[] =
|
{ N_("None"), { 0, 0 } },
|
||||||
{
|
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
|
||||||
{ N_("None"), { 0, 0 } },
|
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
|
||||||
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
|
|
||||||
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth)
|
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth)
|
||||||
{
|
{
|
||||||
return astFilters[_eFilter].m_apvFunc[_eDepth];
|
return astFilters[_eFilter].m_apvFunc[_eDepth];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* pcsGetFilterName(const EFilter _eFilter)
|
const char* pcsGetFilterName(const EFilter _eFilter)
|
||||||
{
|
{
|
||||||
return gettext(astFilters[_eFilter].m_csName);
|
return gettext(astFilters[_eFilter].m_csName);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth)
|
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth)
|
||||||
{
|
{
|
||||||
return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth];
|
return astFiltersIB[_eFilterIB].m_apvFunc[_eDepth];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB)
|
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB)
|
||||||
{
|
{
|
||||||
return gettext(astFiltersIB[_eFilterIB].m_csName);
|
return gettext(astFiltersIB[_eFilterIB].m_csName);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -24,44 +24,44 @@
|
||||||
|
|
||||||
int Init_2xSaI(u32);
|
int Init_2xSaI(u32);
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
typedef void (*Filter)(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
typedef void (*Filter)(u8 *, u32, u8 *, u8 *, u32, int, int);
|
typedef void (*FilterIB)(u8*, u32, int, int);
|
||||||
typedef void (*FilterIB)(u8 *, u32, int, int);
|
|
||||||
|
|
||||||
enum EFilter {
|
enum EFilter {
|
||||||
FirstFilter,
|
FirstFilter,
|
||||||
FilterNone = FirstFilter,
|
FilterNone = FirstFilter,
|
||||||
Filter2xSaI,
|
Filter2xSaI,
|
||||||
FilterSuper2xSaI,
|
FilterSuper2xSaI,
|
||||||
FilterSuperEagle,
|
FilterSuperEagle,
|
||||||
FilterPixelate,
|
FilterPixelate,
|
||||||
FilterAdMame2x,
|
FilterAdMame2x,
|
||||||
FilterBilinear,
|
FilterBilinear,
|
||||||
FilterBilinearPlus,
|
FilterBilinearPlus,
|
||||||
FilterScanlines,
|
FilterScanlines,
|
||||||
FilterScanlinesTV,
|
FilterScanlinesTV,
|
||||||
FilterHq2x,
|
FilterHq2x,
|
||||||
FilterLq2x,
|
FilterLq2x,
|
||||||
FilterxBRZ2x,
|
FilterxBRZ2x,
|
||||||
LastFilter = FilterxBRZ2x
|
LastFilter = FilterxBRZ2x
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EFilterIB {
|
enum EFilterIB {
|
||||||
FirstFilterIB,
|
FirstFilterIB,
|
||||||
FilterIBNone = FirstFilterIB,
|
FilterIBNone = FirstFilterIB,
|
||||||
FilterIBSmart,
|
FilterIBSmart,
|
||||||
FilterIBMotionBlur,
|
FilterIBMotionBlur,
|
||||||
LastFilterIB = FilterIBMotionBlur
|
LastFilterIB = FilterIBMotionBlur
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EFilterDepth { FilterDepth16, FilterDepth32 };
|
enum EFilterDepth { FilterDepth16,
|
||||||
|
FilterDepth32 };
|
||||||
|
|
||||||
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
|
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
|
||||||
const char *pcsGetFilterName(const EFilter _eFilter);
|
const char* pcsGetFilterName(const EFilter _eFilter);
|
||||||
|
|
||||||
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth);
|
FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth);
|
||||||
const char *pcsGetFilterIBName(const EFilterIB _eFilterIB);
|
const char* pcsGetFilterIBName(const EFilterIB _eFilterIB);
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
||||||
|
|
|
@ -21,133 +21,122 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
CheatListDialog(_pstDialog, refBuilder)
|
: CheatListDialog(_pstDialog, refBuilder)
|
||||||
{
|
{
|
||||||
vUpdateList();
|
vUpdateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
|
void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
|
||||||
{
|
{
|
||||||
int previous = cheatsNumber;
|
int previous = cheatsNumber;
|
||||||
|
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
// Generic Code
|
||||||
// Generic Code
|
case CheatGeneric: {
|
||||||
case CheatGeneric:
|
std::vector<Glib::ustring> tokens;
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> tokens;
|
|
||||||
|
|
||||||
vTokenize(buffer->get_text(), tokens);
|
vTokenize(buffer->get_text(), tokens);
|
||||||
|
|
||||||
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
||||||
it != tokens.end();
|
it != tokens.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
Glib::ustring sToken = it->uppercase();
|
||||||
Glib::ustring sToken = it->uppercase();
|
|
||||||
|
|
||||||
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
|
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
|
||||||
}
|
|
||||||
|
|
||||||
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 = "";
|
|
||||||
}
|
}
|
||||||
} // end of loop
|
|
||||||
|
|
||||||
} // end of case
|
break;
|
||||||
default:; // silence warnings
|
}
|
||||||
} // end of switch
|
// 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) {
|
void GameBoyAdvanceCheatListDialog::vRemoveCheat(int index)
|
||||||
cheatsDelete(index, false);
|
{
|
||||||
|
cheatsDelete(index, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceCheatListDialog::vRemoveAllCheats() {
|
void GameBoyAdvanceCheatListDialog::vRemoveAllCheats()
|
||||||
cheatsDeleteAll(false);
|
{
|
||||||
|
cheatsDeleteAll(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable) {
|
void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable)
|
||||||
if (enable)
|
{
|
||||||
cheatsEnable(index);
|
if (enable)
|
||||||
else
|
cheatsEnable(index);
|
||||||
cheatsDisable(index);
|
else
|
||||||
|
cheatsDisable(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
|
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
|
||||||
{
|
{
|
||||||
for (int i = previous; i < cheatsNumber; i++)
|
for (int i = previous; i < cheatsNumber; i++) {
|
||||||
{
|
// Add row for each newly added cheat
|
||||||
// Add row for each newly added cheat
|
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
|
||||||
|
|
||||||
row[m_oRecordModel.iIndex] = i;
|
row[m_oRecordModel.iIndex] = i;
|
||||||
row[m_oRecordModel.bEnabled] = cheatsList[i].enabled;
|
row[m_oRecordModel.bEnabled] = cheatsList[i].enabled;
|
||||||
row[m_oRecordModel.uDesc] = cheatsList[i].desc;
|
row[m_oRecordModel.uDesc] = cheatsList[i].desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -25,22 +25,20 @@
|
||||||
#include "../gba/Globals.h"
|
#include "../gba/Globals.h"
|
||||||
#include "cheatlist.h"
|
#include "cheatlist.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class GameBoyAdvanceCheatListDialog : public CheatListDialog {
|
||||||
class GameBoyAdvanceCheatListDialog : public CheatListDialog
|
public:
|
||||||
{
|
GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog,
|
||||||
public:
|
const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
GameBoyAdvanceCheatListDialog(GtkDialog *_pstDialog,
|
|
||||||
const Glib::RefPtr<Gtk::Builder> &refBuilder);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
|
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
|
||||||
bool vCheatListOpen(const char *file);
|
bool vCheatListOpen(const char* file);
|
||||||
void vCheatListSave(const char *file);
|
void vCheatListSave(const char* file);
|
||||||
void vRemoveCheat(int index);
|
void vRemoveCheat(int index);
|
||||||
void vRemoveAllCheats();
|
void vRemoveAllCheats();
|
||||||
void vToggleCheat(int index, bool enable);
|
void vToggleCheat(int index, bool enable);
|
||||||
void vUpdateList(int previous = 0);
|
void vUpdateList(int previous = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -20,128 +20,118 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
|
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
|
||||||
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
|
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
|
||||||
refBuilder->get_widget("BiosCheckButton", m_poBiosCheckButton);
|
refBuilder->get_widget("BiosCheckButton", m_poBiosCheckButton);
|
||||||
refBuilder->get_widget("BiosFileChooserButton", m_poBiosFileChooserButton);
|
refBuilder->get_widget("BiosFileChooserButton", m_poBiosFileChooserButton);
|
||||||
refBuilder->get_widget("RTCCheckButton", m_poRTCCheckButton);
|
refBuilder->get_widget("RTCCheckButton", m_poRTCCheckButton);
|
||||||
|
|
||||||
m_poSaveTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnSaveTypeChanged));
|
m_poSaveTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnSaveTypeChanged));
|
||||||
m_poFlashSizeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnFlashSizeChanged));
|
m_poFlashSizeComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnFlashSizeChanged));
|
||||||
m_poBiosCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnUseBiosChanged));
|
m_poBiosCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnUseBiosChanged));
|
||||||
m_poBiosFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged));
|
m_poBiosFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged));
|
||||||
m_poRTCCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyAdvanceConfigDialog::vOnEnableRTCChanged));
|
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_poConfig = _poConfig;
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
|
||||||
VBA::Window::ESaveType eDefaultSaveType = (VBA::Window::ESaveType)m_poConfig->oGetKey<int>("save_type");
|
VBA::Window::ESaveType eDefaultSaveType = (VBA::Window::ESaveType)m_poConfig->oGetKey<int>("save_type");
|
||||||
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
|
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
|
||||||
|
|
||||||
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
|
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
|
||||||
if (iDefaultFlashSize == 128)
|
if (iDefaultFlashSize == 128) {
|
||||||
{
|
m_poFlashSizeComboBox->set_active(1);
|
||||||
m_poFlashSizeComboBox->set_active(1);
|
} else {
|
||||||
}
|
m_poFlashSizeComboBox->set_active(0);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
m_poFlashSizeComboBox->set_active(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bUseBios = m_poConfig->oGetKey<bool>("use_bios_file");
|
bool bUseBios = m_poConfig->oGetKey<bool>("use_bios_file");
|
||||||
m_poBiosCheckButton->set_active(bUseBios);
|
m_poBiosCheckButton->set_active(bUseBios);
|
||||||
m_poBiosFileChooserButton->set_sensitive(bUseBios);
|
m_poBiosFileChooserButton->set_sensitive(bUseBios);
|
||||||
|
|
||||||
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
|
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
|
||||||
m_poBiosFileChooserButton->set_filename(sBios);
|
m_poBiosFileChooserButton->set_filename(sBios);
|
||||||
|
|
||||||
const char * acsPattern[] =
|
const char* acsPattern[] = {
|
||||||
{
|
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
|
||||||
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
|
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
|
||||||
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
|
};
|
||||||
};
|
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
Gtk::FileFilter oAllFilter;
|
Gtk::FileFilter oAllFilter;
|
||||||
oAllFilter.set_name(_("All files"));
|
oAllFilter.set_name(_("All files"));
|
||||||
oAllFilter.add_pattern("*");
|
oAllFilter.add_pattern("*");
|
||||||
|
|
||||||
Gtk::FileFilter oBiosFilter;
|
Gtk::FileFilter oBiosFilter;
|
||||||
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
|
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
|
||||||
{
|
oBiosFilter.add_pattern(acsPattern[i]);
|
||||||
oBiosFilter.add_pattern(acsPattern[i]);
|
}
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
const Glib::RefPtr<Gtk::FileFilter> oAllFilter = Gtk::FileFilter::create();
|
const Glib::RefPtr<Gtk::FileFilter> oAllFilter = Gtk::FileFilter::create();
|
||||||
oAllFilter->set_name(_("All files"));
|
oAllFilter->set_name(_("All files"));
|
||||||
oAllFilter->add_pattern("*");
|
oAllFilter->add_pattern("*");
|
||||||
|
|
||||||
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
|
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
|
||||||
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
|
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
|
||||||
{
|
oBiosFilter->add_pattern(acsPattern[i]);
|
||||||
oBiosFilter->add_pattern(acsPattern[i]);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_poBiosFileChooserButton->add_filter(oAllFilter);
|
m_poBiosFileChooserButton->add_filter(oAllFilter);
|
||||||
m_poBiosFileChooserButton->add_filter(oBiosFilter);
|
m_poBiosFileChooserButton->add_filter(oBiosFilter);
|
||||||
m_poBiosFileChooserButton->set_filter(oBiosFilter);
|
m_poBiosFileChooserButton->set_filter(oBiosFilter);
|
||||||
|
|
||||||
bool bEnableRTC = m_poConfig->oGetKey<bool>("enable_rtc");
|
bool bEnableRTC = m_poConfig->oGetKey<bool>("enable_rtc");
|
||||||
m_poRTCCheckButton->set_active(bEnableRTC);
|
m_poRTCCheckButton->set_active(bEnableRTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceConfigDialog::vOnSaveTypeChanged()
|
void GameBoyAdvanceConfigDialog::vOnSaveTypeChanged()
|
||||||
{
|
{
|
||||||
int iSaveType = m_poSaveTypeComboBox->get_active_row_number();
|
int iSaveType = m_poSaveTypeComboBox->get_active_row_number();
|
||||||
m_poConfig->vSetKey("save_type", iSaveType);
|
m_poConfig->vSetKey("save_type", iSaveType);
|
||||||
m_poWindow->vApplyConfigGBASaveType();
|
m_poWindow->vApplyConfigGBASaveType();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
|
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
|
||||||
{
|
{
|
||||||
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
|
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
|
||||||
if (iFlashSize == 0)
|
if (iFlashSize == 0) {
|
||||||
{
|
m_poConfig->vSetKey("flash_size", 64);
|
||||||
m_poConfig->vSetKey("flash_size", 64);
|
} else {
|
||||||
}
|
m_poConfig->vSetKey("flash_size", 128);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("flash_size", 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_poWindow->vApplyConfigGBAFlashSize();
|
m_poWindow->vApplyConfigGBAFlashSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceConfigDialog::vOnUseBiosChanged()
|
void GameBoyAdvanceConfigDialog::vOnUseBiosChanged()
|
||||||
{
|
{
|
||||||
bool bUseBios = m_poBiosCheckButton->get_active();
|
bool bUseBios = m_poBiosCheckButton->get_active();
|
||||||
m_poConfig->vSetKey("use_bios_file", bUseBios);
|
m_poConfig->vSetKey("use_bios_file", bUseBios);
|
||||||
m_poBiosFileChooserButton->set_sensitive(bUseBios);
|
m_poBiosFileChooserButton->set_sensitive(bUseBios);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged()
|
void GameBoyAdvanceConfigDialog::vOnBiosSelectionChanged()
|
||||||
{
|
{
|
||||||
std::string sBios = m_poBiosFileChooserButton->get_filename();
|
std::string sBios = m_poBiosFileChooserButton->get_filename();
|
||||||
m_poConfig->vSetKey("bios_file", sBios);
|
m_poConfig->vSetKey("bios_file", sBios);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyAdvanceConfigDialog::vOnEnableRTCChanged()
|
void GameBoyAdvanceConfigDialog::vOnEnableRTCChanged()
|
||||||
{
|
{
|
||||||
bool bEnableRTC = m_poRTCCheckButton->get_active();
|
bool bEnableRTC = m_poRTCCheckButton->get_active();
|
||||||
m_poConfig->vSetKey("enable_rtc", bEnableRTC);
|
m_poConfig->vSetKey("enable_rtc", bEnableRTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -26,31 +26,29 @@
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class GameBoyAdvanceConfigDialog : public Gtk::Dialog {
|
||||||
class GameBoyAdvanceConfigDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog,
|
||||||
public:
|
const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
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:
|
private:
|
||||||
void vOnSaveTypeChanged();
|
void vOnSaveTypeChanged();
|
||||||
void vOnFlashSizeChanged();
|
void vOnFlashSizeChanged();
|
||||||
void vOnUseBiosChanged();
|
void vOnUseBiosChanged();
|
||||||
void vOnBiosSelectionChanged();
|
void vOnBiosSelectionChanged();
|
||||||
void vOnEnableRTCChanged();
|
void vOnEnableRTCChanged();
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
Gtk::ComboBox *m_poSaveTypeComboBox;
|
Gtk::ComboBox* m_poSaveTypeComboBox;
|
||||||
Gtk::ComboBox *m_poFlashSizeComboBox;
|
Gtk::ComboBox* m_poFlashSizeComboBox;
|
||||||
Gtk::CheckButton *m_poBiosCheckButton;
|
Gtk::CheckButton* m_poBiosCheckButton;
|
||||||
Gtk::FileChooserButton *m_poBiosFileChooserButton;
|
Gtk::FileChooserButton* m_poBiosFileChooserButton;
|
||||||
Gtk::CheckButton *m_poRTCCheckButton;
|
Gtk::CheckButton* m_poRTCCheckButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -21,102 +21,96 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
CheatListDialog(_pstDialog, refBuilder)
|
: CheatListDialog(_pstDialog, refBuilder)
|
||||||
{
|
{
|
||||||
vUpdateList();
|
vUpdateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
|
void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer)
|
||||||
{
|
{
|
||||||
int previous = gbCheatNumber;
|
int previous = gbCheatNumber;
|
||||||
|
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
// GameShark
|
||||||
// GameShark
|
case CheatGS: {
|
||||||
case CheatGS:
|
std::vector<Glib::ustring> tokens;
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> tokens;
|
|
||||||
|
|
||||||
vTokenize(buffer->get_text(), tokens);
|
vTokenize(buffer->get_text(), tokens);
|
||||||
|
|
||||||
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
||||||
it != tokens.end();
|
it != tokens.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
Glib::ustring sToken = it->uppercase();
|
||||||
Glib::ustring sToken = it->uppercase();
|
|
||||||
|
|
||||||
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
|
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
// GameGenie
|
||||||
|
case CheatGG: {
|
||||||
|
std::vector<Glib::ustring> tokens;
|
||||||
|
|
||||||
break;
|
vTokenize(buffer->get_text(), tokens);
|
||||||
}
|
|
||||||
// GameGenie
|
|
||||||
case CheatGG:
|
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> 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();
|
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
|
||||||
it != tokens.end();
|
}
|
||||||
it++)
|
|
||||||
{
|
|
||||||
Glib::ustring sToken = it->uppercase();
|
|
||||||
|
|
||||||
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
|
break;
|
||||||
}
|
}
|
||||||
|
default:; // silence warnings
|
||||||
|
}
|
||||||
|
// end of switch
|
||||||
|
|
||||||
break;
|
vUpdateList(previous);
|
||||||
}
|
|
||||||
default:; // silence warnings
|
|
||||||
}
|
|
||||||
// end of switch
|
|
||||||
|
|
||||||
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)
|
void GameBoyCheatListDialog::vRemoveCheat(int index)
|
||||||
{
|
{
|
||||||
gbCheatRemove(index);
|
gbCheatRemove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vRemoveAllCheats()
|
void GameBoyCheatListDialog::vRemoveAllCheats()
|
||||||
{
|
{
|
||||||
gbCheatRemoveAll();
|
gbCheatRemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable) {
|
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable)
|
||||||
if (enable)
|
{
|
||||||
gbCheatEnable(index);
|
if (enable)
|
||||||
else
|
gbCheatEnable(index);
|
||||||
gbCheatDisable(index);
|
else
|
||||||
|
gbCheatDisable(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vUpdateList(int previous)
|
void GameBoyCheatListDialog::vUpdateList(int previous)
|
||||||
{
|
{
|
||||||
for (int i = previous; i < gbCheatNumber; i++)
|
for (int i = previous; i < gbCheatNumber; i++) {
|
||||||
{
|
// Add row for each newly added cheat
|
||||||
// Add row for each newly added cheat
|
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
|
||||||
|
|
||||||
row[m_oRecordModel.iIndex] = i;
|
row[m_oRecordModel.iIndex] = i;
|
||||||
row[m_oRecordModel.bEnabled] = gbCheatList[i].enabled;
|
row[m_oRecordModel.bEnabled] = gbCheatList[i].enabled;
|
||||||
row[m_oRecordModel.uDesc] = gbCheatList[i].cheatDesc;
|
row[m_oRecordModel.uDesc] = gbCheatList[i].cheatDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -22,21 +22,19 @@
|
||||||
#include "../gb/gbCheats.h"
|
#include "../gb/gbCheats.h"
|
||||||
#include "cheatlist.h"
|
#include "cheatlist.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class GameBoyCheatListDialog : public CheatListDialog {
|
||||||
class GameBoyCheatListDialog : public CheatListDialog
|
public:
|
||||||
{
|
GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
public:
|
|
||||||
GameBoyCheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
|
void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr<Gtk::TextBuffer> buffer);
|
||||||
bool vCheatListOpen(const char *file);
|
bool vCheatListOpen(const char* file);
|
||||||
void vCheatListSave(const char *file);
|
void vCheatListSave(const char* file);
|
||||||
void vRemoveCheat(int index);
|
void vRemoveCheat(int index);
|
||||||
void vRemoveAllCheats();
|
void vRemoveAllCheats();
|
||||||
void vToggleCheat(int index, bool enable);
|
void vToggleCheat(int index, bool enable);
|
||||||
void vUpdateList(int previous = 0);
|
void vUpdateList(int previous = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -18,97 +18,95 @@
|
||||||
|
|
||||||
#include "gameboyconfig.h"
|
#include "gameboyconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
static const VBA::Window::EEmulatorType aEmulatorType[] =
|
static const VBA::Window::EEmulatorType aEmulatorType[] = {
|
||||||
{
|
VBA::Window::EmulatorAuto,
|
||||||
VBA::Window::EmulatorAuto,
|
VBA::Window::EmulatorCGB,
|
||||||
VBA::Window::EmulatorCGB,
|
VBA::Window::EmulatorSGB,
|
||||||
VBA::Window::EmulatorSGB,
|
VBA::Window::EmulatorGB,
|
||||||
VBA::Window::EmulatorGB,
|
VBA::Window::EmulatorGBA,
|
||||||
VBA::Window::EmulatorGBA,
|
VBA::Window::EmulatorSGB2
|
||||||
VBA::Window::EmulatorSGB2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
|
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
|
||||||
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
|
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
|
||||||
refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton);
|
refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton);
|
||||||
refBuilder->get_widget("BootRomCheckButton", m_poBootRomCheckButton);
|
refBuilder->get_widget("BootRomCheckButton", m_poBootRomCheckButton);
|
||||||
refBuilder->get_widget("BootRomFileChooserButton", m_poBootRomFileChooserButton);
|
refBuilder->get_widget("BootRomFileChooserButton", m_poBootRomFileChooserButton);
|
||||||
|
|
||||||
m_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged));
|
m_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged));
|
||||||
m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged));
|
m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged));
|
||||||
m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged));
|
m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged));
|
||||||
m_poBootRomCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnUseBootRomChanged));
|
m_poBootRomCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnUseBootRomChanged));
|
||||||
m_poBootRomFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBootRomSelectionChanged));
|
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_poConfig = _poConfig;
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
|
||||||
VBA::Window::EEmulatorType eDefaultEmulatorType = (VBA::Window::EEmulatorType)m_poConfig->oGetKey<int>("emulator_type");
|
VBA::Window::EEmulatorType eDefaultEmulatorType = (VBA::Window::EEmulatorType)m_poConfig->oGetKey<int>("emulator_type");
|
||||||
m_poSystemComboBox->set_active(aEmulatorType[eDefaultEmulatorType]);
|
m_poSystemComboBox->set_active(aEmulatorType[eDefaultEmulatorType]);
|
||||||
|
|
||||||
bool bBorder = m_poConfig->oGetKey<bool>("gb_border");
|
bool bBorder = m_poConfig->oGetKey<bool>("gb_border");
|
||||||
m_poBorderCheckButton->set_active(bBorder);
|
m_poBorderCheckButton->set_active(bBorder);
|
||||||
|
|
||||||
bool bPrinter = m_poConfig->oGetKey<bool>("gb_printer");
|
bool bPrinter = m_poConfig->oGetKey<bool>("gb_printer");
|
||||||
m_poPrinterCheckButton->set_active(bPrinter);
|
m_poPrinterCheckButton->set_active(bPrinter);
|
||||||
|
|
||||||
bool bUseBootRom = m_poConfig->oGetKey<bool>("gb_use_bios_file");
|
bool bUseBootRom = m_poConfig->oGetKey<bool>("gb_use_bios_file");
|
||||||
m_poBootRomCheckButton->set_active(bUseBootRom);
|
m_poBootRomCheckButton->set_active(bUseBootRom);
|
||||||
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
|
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
|
||||||
|
|
||||||
std::string sBootRom = m_poConfig->oGetKey<std::string>("gb_bios_file");
|
std::string sBootRom = m_poConfig->oGetKey<std::string>("gb_bios_file");
|
||||||
m_poBootRomFileChooserButton->set_filename(sBootRom);
|
m_poBootRomFileChooserButton->set_filename(sBootRom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyConfigDialog::vOnSystemChanged()
|
void GameBoyConfigDialog::vOnSystemChanged()
|
||||||
{
|
{
|
||||||
int iSystem = m_poSystemComboBox->get_active_row_number();
|
int iSystem = m_poSystemComboBox->get_active_row_number();
|
||||||
m_poConfig->vSetKey("emulator_type", aEmulatorType[iSystem]);
|
m_poConfig->vSetKey("emulator_type", aEmulatorType[iSystem]);
|
||||||
|
|
||||||
m_poWindow->vApplyConfigGBSystem();
|
m_poWindow->vApplyConfigGBSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyConfigDialog::vOnBorderChanged()
|
void GameBoyConfigDialog::vOnBorderChanged()
|
||||||
{
|
{
|
||||||
bool bBorder = m_poBorderCheckButton->get_active();
|
bool bBorder = m_poBorderCheckButton->get_active();
|
||||||
m_poConfig->vSetKey("gb_border", bBorder);
|
m_poConfig->vSetKey("gb_border", bBorder);
|
||||||
m_poWindow->vApplyConfigGBBorder();
|
m_poWindow->vApplyConfigGBBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyConfigDialog::vOnPrinterChanged()
|
void GameBoyConfigDialog::vOnPrinterChanged()
|
||||||
{
|
{
|
||||||
bool bPrinter = m_poPrinterCheckButton->get_active();
|
bool bPrinter = m_poPrinterCheckButton->get_active();
|
||||||
m_poConfig->vSetKey("gb_printer", bPrinter);
|
m_poConfig->vSetKey("gb_printer", bPrinter);
|
||||||
m_poWindow->vApplyConfigGBPrinter();
|
m_poWindow->vApplyConfigGBPrinter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyConfigDialog::vOnUseBootRomChanged()
|
void GameBoyConfigDialog::vOnUseBootRomChanged()
|
||||||
{
|
{
|
||||||
bool bUseBootRom = m_poBootRomCheckButton->get_active();
|
bool bUseBootRom = m_poBootRomCheckButton->get_active();
|
||||||
m_poConfig->vSetKey("gb_use_bios_file", bUseBootRom);
|
m_poConfig->vSetKey("gb_use_bios_file", bUseBootRom);
|
||||||
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
|
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyConfigDialog::vOnBootRomSelectionChanged()
|
void GameBoyConfigDialog::vOnBootRomSelectionChanged()
|
||||||
{
|
{
|
||||||
std::string sBootRom = m_poBootRomFileChooserButton->get_filename();
|
std::string sBootRom = m_poBootRomFileChooserButton->get_filename();
|
||||||
m_poConfig->vSetKey("gb_bios_file", sBootRom);
|
m_poConfig->vSetKey("gb_bios_file", sBootRom);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -26,30 +26,28 @@
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class GameBoyConfigDialog : public Gtk::Dialog {
|
||||||
class GameBoyConfigDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
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:
|
private:
|
||||||
void vOnSystemChanged();
|
void vOnSystemChanged();
|
||||||
void vOnBorderChanged();
|
void vOnBorderChanged();
|
||||||
void vOnPrinterChanged();
|
void vOnPrinterChanged();
|
||||||
void vOnUseBootRomChanged();
|
void vOnUseBootRomChanged();
|
||||||
void vOnBootRomSelectionChanged();
|
void vOnBootRomSelectionChanged();
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
Gtk::ComboBox *m_poSystemComboBox;
|
Gtk::ComboBox* m_poSystemComboBox;
|
||||||
Gtk::CheckButton *m_poBorderCheckButton;
|
Gtk::CheckButton* m_poBorderCheckButton;
|
||||||
Gtk::CheckButton *m_poPrinterCheckButton;
|
Gtk::CheckButton* m_poPrinterCheckButton;
|
||||||
Gtk::CheckButton *m_poBootRomCheckButton;
|
Gtk::CheckButton* m_poBootRomCheckButton;
|
||||||
Gtk::FileChooserButton *m_poBootRomFileChooserButton;
|
Gtk::FileChooserButton* m_poBootRomFileChooserButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -18,87 +18,82 @@
|
||||||
|
|
||||||
#include "generalconfig.h"
|
#include "generalconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
|
|
||||||
|
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
|
: 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) :
|
m_poPauseWhenInactiveCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnPauseWhenInactiveChanged));
|
||||||
Gtk::Dialog(_pstDialog),
|
m_poFrameSkipAutomaticCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
|
||||||
m_poConfig(0)
|
m_poFrameSkipLevelSpinButton->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
|
||||||
{
|
m_poSpeedIndicatorComboBox->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnSpeedIndicatorChanged));
|
||||||
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));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
|
void PreferencesDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
|
||||||
{
|
{
|
||||||
m_poConfig = _poConfig;
|
m_poConfig = _poConfig;
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
|
||||||
bool bPauseWhenInactive = m_poConfig->oGetKey<bool>("pause_when_inactive");
|
bool bPauseWhenInactive = m_poConfig->oGetKey<bool>("pause_when_inactive");
|
||||||
m_poPauseWhenInactiveCheckButton->set_active(bPauseWhenInactive);
|
m_poPauseWhenInactiveCheckButton->set_active(bPauseWhenInactive);
|
||||||
|
|
||||||
std::string sFrameskip = m_poConfig->oGetKey<std::string>("frameskip");
|
std::string sFrameskip = m_poConfig->oGetKey<std::string>("frameskip");
|
||||||
int iFrameskip = 0;
|
int iFrameskip = 0;
|
||||||
bool bAutoFrameskip = false;
|
bool bAutoFrameskip = false;
|
||||||
|
|
||||||
if (sFrameskip == "auto")
|
|
||||||
bAutoFrameskip = true;
|
|
||||||
else
|
|
||||||
iFrameskip = m_poConfig->oGetKey<int>("frameskip");
|
|
||||||
|
|
||||||
m_poFrameSkipAutomaticCheckButton->set_active(bAutoFrameskip);
|
if (sFrameskip == "auto")
|
||||||
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
|
bAutoFrameskip = true;
|
||||||
m_poFrameSkipLevelSpinButton->set_value(iFrameskip);
|
else
|
||||||
|
iFrameskip = m_poConfig->oGetKey<int>("frameskip");
|
||||||
|
|
||||||
int iShowSpeed = m_poConfig->oGetKey<int>("show_speed");
|
m_poFrameSkipAutomaticCheckButton->set_active(bAutoFrameskip);
|
||||||
m_poSpeedIndicatorComboBox->set_active(iShowSpeed);
|
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()
|
void PreferencesDialog::vOnPauseWhenInactiveChanged()
|
||||||
{
|
{
|
||||||
bool bPauseWhenInactive = m_poPauseWhenInactiveCheckButton->get_active();
|
bool bPauseWhenInactive = m_poPauseWhenInactiveCheckButton->get_active();
|
||||||
m_poConfig->vSetKey("pause_when_inactive", bPauseWhenInactive);
|
m_poConfig->vSetKey("pause_when_inactive", bPauseWhenInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::vOnFrameskipChanged()
|
void PreferencesDialog::vOnFrameskipChanged()
|
||||||
{
|
{
|
||||||
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
|
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
|
||||||
|
|
||||||
if (bAutoFrameskip)
|
if (bAutoFrameskip) {
|
||||||
{
|
m_poConfig->vSetKey("frameskip", "auto");
|
||||||
m_poConfig->vSetKey("frameskip", "auto");
|
} else {
|
||||||
}
|
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
|
||||||
else
|
m_poConfig->vSetKey("frameskip", iFrameskip);
|
||||||
{
|
}
|
||||||
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
|
|
||||||
m_poConfig->vSetKey("frameskip", iFrameskip);
|
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
|
||||||
}
|
|
||||||
|
m_poWindow->vApplyConfigFrameskip();
|
||||||
m_poFrameSkipLevelSpinButton->set_sensitive(!bAutoFrameskip);
|
|
||||||
|
|
||||||
m_poWindow->vApplyConfigFrameskip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::vOnSpeedIndicatorChanged()
|
void PreferencesDialog::vOnSpeedIndicatorChanged()
|
||||||
{
|
{
|
||||||
int iShowSpeed = m_poSpeedIndicatorComboBox->get_active_row_number();
|
int iShowSpeed = m_poSpeedIndicatorComboBox->get_active_row_number();
|
||||||
m_poConfig->vSetKey<int>("show_speed", iShowSpeed);
|
m_poConfig->vSetKey<int>("show_speed", iShowSpeed);
|
||||||
|
|
||||||
m_poWindow->vApplyConfigShowSpeed();
|
m_poWindow->vApplyConfigShowSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -26,27 +26,25 @@
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class PreferencesDialog : public Gtk::Dialog {
|
||||||
class PreferencesDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
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:
|
private:
|
||||||
void vOnPauseWhenInactiveChanged();
|
void vOnPauseWhenInactiveChanged();
|
||||||
void vOnFrameskipChanged();
|
void vOnFrameskipChanged();
|
||||||
void vOnSpeedIndicatorChanged();
|
void vOnSpeedIndicatorChanged();
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
Gtk::CheckButton *m_poPauseWhenInactiveCheckButton;
|
Gtk::CheckButton* m_poPauseWhenInactiveCheckButton;
|
||||||
Gtk::CheckButton *m_poFrameSkipAutomaticCheckButton;
|
Gtk::CheckButton* m_poFrameSkipAutomaticCheckButton;
|
||||||
Gtk::SpinButton *m_poFrameSkipLevelSpinButton;
|
Gtk::SpinButton* m_poFrameSkipLevelSpinButton;
|
||||||
Gtk::ComboBox *m_poSpeedIndicatorComboBox;
|
Gtk::ComboBox* m_poSpeedIndicatorComboBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -23,309 +23,286 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
|
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = {
|
||||||
{
|
{ KEY_UP, N_("Up :") },
|
||||||
{ KEY_UP, N_("Up :") },
|
{ KEY_DOWN, N_("Down :") },
|
||||||
{ KEY_DOWN, N_("Down :") },
|
{ KEY_LEFT, N_("Left :") },
|
||||||
{ KEY_LEFT, N_("Left :") },
|
{ KEY_RIGHT, N_("Right :") },
|
||||||
{ KEY_RIGHT, N_("Right :") },
|
{ KEY_BUTTON_A, N_("Button A :") },
|
||||||
{ KEY_BUTTON_A, N_("Button A :") },
|
{ KEY_BUTTON_B, N_("Button B :") },
|
||||||
{ KEY_BUTTON_B, N_("Button B :") },
|
{ KEY_BUTTON_L, N_("Button L :") },
|
||||||
{ KEY_BUTTON_L, N_("Button L :") },
|
{ KEY_BUTTON_R, N_("Button R :") },
|
||||||
{ KEY_BUTTON_R, N_("Button R :") },
|
{ KEY_BUTTON_SELECT, N_("Select :") },
|
||||||
{ KEY_BUTTON_SELECT, N_("Select :") },
|
{ KEY_BUTTON_START, N_("Start :") },
|
||||||
{ KEY_BUTTON_START, N_("Start :") },
|
{ KEY_BUTTON_SPEED, N_("Speed :") },
|
||||||
{ KEY_BUTTON_SPEED, N_("Speed :") },
|
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
|
||||||
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
|
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
|
||||||
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
|
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
|
||||||
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :
|
JoypadConfigDialog::JoypadConfigDialog(Config::Section* _poConfig)
|
||||||
Gtk::Dialog(_("Joypad config"), true),
|
: Gtk::Dialog(_("Joypad config"), true)
|
||||||
m_oTitleHBox(false, 5),
|
, m_oTitleHBox(false, 5)
|
||||||
m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END),
|
, m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END)
|
||||||
m_oDefaultJoypad(_("Default joypad")),
|
, m_oDefaultJoypad(_("Default joypad"))
|
||||||
m_oTable(G_N_ELEMENTS(m_astKeys), 2, false),
|
, m_oTable(G_N_ELEMENTS(m_astKeys), 2, false)
|
||||||
m_iCurrentEntry(-1),
|
, m_iCurrentEntry(-1)
|
||||||
m_bUpdating(false),
|
, m_bUpdating(false)
|
||||||
m_ePad(PAD_MAIN),
|
, m_ePad(PAD_MAIN)
|
||||||
m_poConfig(_poConfig)
|
, m_poConfig(_poConfig)
|
||||||
{
|
{
|
||||||
// Joypad selection
|
// Joypad selection
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
m_oTitleCombo.append_text("1");
|
m_oTitleCombo.append_text("1");
|
||||||
m_oTitleCombo.append_text("2");
|
m_oTitleCombo.append_text("2");
|
||||||
m_oTitleCombo.append_text("3");
|
m_oTitleCombo.append_text("3");
|
||||||
m_oTitleCombo.append_text("4");
|
m_oTitleCombo.append_text("4");
|
||||||
#else
|
#else
|
||||||
m_oTitleCombo.append("1");
|
m_oTitleCombo.append("1");
|
||||||
m_oTitleCombo.append("2");
|
m_oTitleCombo.append("2");
|
||||||
m_oTitleCombo.append("3");
|
m_oTitleCombo.append("3");
|
||||||
m_oTitleCombo.append("4");
|
m_oTitleCombo.append("4");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_oTitleHBox.pack_start(m_oTitleLabel, Gtk::PACK_SHRINK);
|
m_oTitleHBox.pack_start(m_oTitleLabel, Gtk::PACK_SHRINK);
|
||||||
m_oTitleHBox.pack_start(m_oTitleCombo);
|
m_oTitleHBox.pack_start(m_oTitleCombo);
|
||||||
|
|
||||||
// Joypad buttons
|
// Joypad buttons
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++) {
|
||||||
{
|
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END));
|
||||||
Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END) );
|
Gtk::Entry* poEntry = Gtk::manage(new Gtk::Entry());
|
||||||
Gtk::Entry * poEntry = Gtk::manage( new Gtk::Entry() );
|
m_oTable.attach(*poLabel, 0, 1, i, i + 1);
|
||||||
m_oTable.attach(* poLabel, 0, 1, i, i + 1);
|
m_oTable.attach(*poEntry, 1, 2, i, i + 1);
|
||||||
m_oTable.attach(* poEntry, 1, 2, i, i + 1);
|
m_oEntries.push_back(poEntry);
|
||||||
m_oEntries.push_back(poEntry);
|
|
||||||
|
|
||||||
poEntry->signal_focus_in_event().connect(sigc::bind(
|
poEntry->signal_focus_in_event().connect(sigc::bind(
|
||||||
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn), i));
|
sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusIn), i));
|
||||||
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
|
poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dialog validation button
|
// Dialog validation button
|
||||||
m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
|
m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
m_oTitleHBox.set_border_width(5);
|
m_oTitleHBox.set_border_width(5);
|
||||||
m_oTable.set_border_width(5);
|
m_oTable.set_border_width(5);
|
||||||
m_oTable.set_spacings(5);
|
m_oTable.set_spacings(5);
|
||||||
get_vbox()->set_spacing(5);
|
get_vbox()->set_spacing(5);
|
||||||
get_vbox()->pack_start(m_oTitleHBox);
|
get_vbox()->pack_start(m_oTitleHBox);
|
||||||
get_vbox()->pack_start(m_oSeparator);
|
get_vbox()->pack_start(m_oSeparator);
|
||||||
get_vbox()->pack_start(m_oDefaultJoypad);
|
get_vbox()->pack_start(m_oDefaultJoypad);
|
||||||
get_vbox()->pack_start(m_oTable);
|
get_vbox()->pack_start(m_oTable);
|
||||||
|
|
||||||
// Signals and default values
|
// Signals and default values
|
||||||
m_oConfigSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
|
m_oConfigSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle),
|
||||||
50);
|
50);
|
||||||
m_oDefaultJoypad.signal_toggled().connect(sigc::mem_fun(*this,
|
m_oDefaultJoypad.signal_toggled().connect(sigc::mem_fun(*this,
|
||||||
&JoypadConfigDialog::vOnDefaultJoypadSelect) );
|
&JoypadConfigDialog::vOnDefaultJoypadSelect));
|
||||||
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
|
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
|
||||||
&JoypadConfigDialog::vOnJoypadSelect) );
|
&JoypadConfigDialog::vOnJoypadSelect));
|
||||||
|
|
||||||
m_oTitleCombo.set_active_text("1");
|
m_oTitleCombo.set_active_text("1");
|
||||||
|
|
||||||
show_all_children();
|
show_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
JoypadConfigDialog::~JoypadConfigDialog()
|
JoypadConfigDialog::~JoypadConfigDialog()
|
||||||
{
|
{
|
||||||
m_oConfigSig.disconnect();
|
m_oConfigSig.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadConfigDialog::vUpdateEntries()
|
void JoypadConfigDialog::vUpdateEntries()
|
||||||
{
|
{
|
||||||
m_bUpdating = true;
|
m_bUpdating = true;
|
||||||
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
|
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
|
||||||
|
|
||||||
for (guint i = 0; i < m_oEntries.size(); i++)
|
for (guint i = 0; i < m_oEntries.size(); i++) {
|
||||||
{
|
std::string csName;
|
||||||
std::string csName;
|
|
||||||
|
|
||||||
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
|
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
|
||||||
int dev = uiKeyval >> 16;
|
int dev = uiKeyval >> 16;
|
||||||
if (dev == 0)
|
if (dev == 0) {
|
||||||
{
|
csName = gdk_keyval_name(uiKeyval);
|
||||||
csName = gdk_keyval_name(uiKeyval);
|
} else {
|
||||||
}
|
int what = uiKeyval & 0xffff;
|
||||||
else
|
std::stringstream os;
|
||||||
{
|
os << _("Joy ") << dev;
|
||||||
int what = uiKeyval & 0xffff;
|
|
||||||
std::stringstream os;
|
|
||||||
os << _("Joy ") << dev;
|
|
||||||
|
|
||||||
if(what >= 128)
|
if (what >= 128) {
|
||||||
{
|
// joystick button
|
||||||
// joystick button
|
int button = what - 128;
|
||||||
int button = what - 128;
|
os << _(" Button ") << button;
|
||||||
os << _(" Button ") << button;
|
} else if (what < 0x20) {
|
||||||
}
|
// joystick axis
|
||||||
else if (what < 0x20)
|
int dir = what & 1;
|
||||||
{
|
what >>= 1;
|
||||||
// joystick axis
|
os << _(" Axis ") << what << (dir ? '-' : '+');
|
||||||
int dir = what & 1;
|
} else if (what < 0x30) {
|
||||||
what >>= 1;
|
// joystick hat
|
||||||
os << _(" Axis ") << what << (dir?'-':'+');
|
int dir = (what & 3);
|
||||||
}
|
what = (what & 15);
|
||||||
else if (what < 0x30)
|
what >>= 2;
|
||||||
{
|
os << _(" Hat ") << what << " ";
|
||||||
// joystick hat
|
switch (dir) {
|
||||||
int dir = (what & 3);
|
case 0:
|
||||||
what = (what & 15);
|
os << _("Up");
|
||||||
what >>= 2;
|
break;
|
||||||
os << _(" Hat ") << what << " ";
|
case 1:
|
||||||
switch (dir)
|
os << _("Down");
|
||||||
{
|
break;
|
||||||
case 0: os << _("Up"); break;
|
case 2:
|
||||||
case 1: os << _("Down"); break;
|
os << _("Right");
|
||||||
case 2: os << _("Right"); break;
|
break;
|
||||||
case 3: os << _("Left"); 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_bUpdating = false;
|
||||||
{
|
|
||||||
m_oEntries[i]->set_text(_("<Undefined>"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_oEntries[i]->set_text(csName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bUpdating = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus * _pstEvent,
|
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus* _pstEvent,
|
||||||
guint _uiEntry)
|
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)
|
if (m_iCurrentEntry < 0) {
|
||||||
{
|
return Gtk::Window::on_key_press_event(_pstEvent);
|
||||||
return Gtk::Window::on_key_press_event(_pstEvent);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Forward the keyboard event by faking a SDL event
|
// Forward the keyboard event by faking a SDL event
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_KEYDOWN;
|
event.type = SDL_KEYDOWN;
|
||||||
//event.key.timestamp = SDL_GetTicks();
|
//event.key.timestamp = SDL_GetTicks();
|
||||||
//event.key.windowID = 0;
|
//event.key.windowID = 0;
|
||||||
//event.key.repeat = 0;
|
//event.key.repeat = 0;
|
||||||
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
|
//event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
|
||||||
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
|
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
|
||||||
vOnInputEvent(event);
|
vOnInputEvent(event);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadConfigDialog::on_response(int response_id)
|
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)
|
if (m_iCurrentEntry < 0) {
|
||||||
{
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int code = inputGetEventCode(event);
|
int code = inputGetEventCode(event);
|
||||||
if (!code) return;
|
if (!code)
|
||||||
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
|
return;
|
||||||
vUpdateEntries();
|
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
|
||||||
|
vUpdateEntries();
|
||||||
|
|
||||||
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size())
|
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) {
|
||||||
{
|
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
|
||||||
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
|
} else {
|
||||||
}
|
m_poOkButton->grab_focus();
|
||||||
else
|
}
|
||||||
{
|
|
||||||
m_poOkButton->grab_focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JoypadConfigDialog::bOnConfigIdle()
|
bool JoypadConfigDialog::bOnConfigIdle()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event)) {
|
||||||
{
|
switch (event.type) {
|
||||||
switch(event.type)
|
case SDL_JOYAXISMOTION:
|
||||||
{
|
if (abs(event.jaxis.value) < 16384)
|
||||||
case SDL_JOYAXISMOTION:
|
continue;
|
||||||
if (abs(event.jaxis.value) < 16384) continue;
|
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|
||||||
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|
|| event.jaxis.axis != m_oPreviousEvent.jaxis.axis
|
||||||
|| event.jaxis.axis != m_oPreviousEvent.jaxis.axis
|
|| (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
|
||||||
|| (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
|
|| (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0)) {
|
||||||
|| (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0))
|
vOnInputEvent(event);
|
||||||
{
|
m_oPreviousEvent = event;
|
||||||
vOnInputEvent(event);
|
}
|
||||||
m_oPreviousEvent = event;
|
vEmptyEventQueue();
|
||||||
}
|
break;
|
||||||
vEmptyEventQueue();
|
case SDL_JOYBUTTONUP:
|
||||||
break;
|
vOnInputEvent(event);
|
||||||
case SDL_JOYBUTTONUP:
|
vEmptyEventQueue();
|
||||||
vOnInputEvent(event);
|
break;
|
||||||
vEmptyEventQueue();
|
case SDL_JOYHATMOTION:
|
||||||
break;
|
if (event.jhat.value) {
|
||||||
case SDL_JOYHATMOTION:
|
vOnInputEvent(event);
|
||||||
if (event.jhat.value)
|
vEmptyEventQueue();
|
||||||
{
|
}
|
||||||
vOnInputEvent(event);
|
break;
|
||||||
vEmptyEventQueue();
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadConfigDialog::vEmptyEventQueue()
|
void JoypadConfigDialog::vEmptyEventQueue()
|
||||||
{
|
{
|
||||||
// Empty the SDL event queue
|
// Empty the SDL event queue
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_PollEvent(&event));
|
while (SDL_PollEvent(&event))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadConfigDialog::vOnJoypadSelect()
|
void JoypadConfigDialog::vOnJoypadSelect()
|
||||||
{
|
{
|
||||||
std::string oText = m_oTitleCombo.get_active_text();
|
std::string oText = m_oTitleCombo.get_active_text();
|
||||||
|
|
||||||
if (oText == "1")
|
if (oText == "1") {
|
||||||
{
|
m_ePad = PAD_1;
|
||||||
m_ePad = PAD_1;
|
} else if (oText == "2") {
|
||||||
}
|
m_ePad = PAD_2;
|
||||||
else if (oText == "2")
|
} else if (oText == "3") {
|
||||||
{
|
m_ePad = PAD_3;
|
||||||
m_ePad = PAD_2;
|
} else if (oText == "4") {
|
||||||
}
|
m_ePad = PAD_4;
|
||||||
else if (oText == "3")
|
}
|
||||||
{
|
|
||||||
m_ePad = PAD_3;
|
|
||||||
}
|
|
||||||
else if (oText == "4")
|
|
||||||
{
|
|
||||||
m_ePad = PAD_4;
|
|
||||||
}
|
|
||||||
|
|
||||||
vEmptyEventQueue();
|
vEmptyEventQueue();
|
||||||
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
|
memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent));
|
||||||
|
|
||||||
vUpdateEntries();
|
vUpdateEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadConfigDialog::vOnDefaultJoypadSelect()
|
void JoypadConfigDialog::vOnDefaultJoypadSelect()
|
||||||
{
|
{
|
||||||
if (m_bUpdating) return;
|
if (m_bUpdating)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_oDefaultJoypad.get_active())
|
if (m_oDefaultJoypad.get_active()) {
|
||||||
{
|
inputSetDefaultJoypad(m_ePad);
|
||||||
inputSetDefaultJoypad(m_ePad);
|
} else {
|
||||||
}
|
inputSetDefaultJoypad(PAD_MAIN);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
inputSetDefaultJoypad(PAD_MAIN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -33,49 +33,47 @@
|
||||||
#include "../sdl/inputSDL.h"
|
#include "../sdl/inputSDL.h"
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class JoypadConfigDialog : public Gtk::Dialog {
|
||||||
class JoypadConfigDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
JoypadConfigDialog(Config::Section* _poConfig);
|
||||||
public:
|
virtual ~JoypadConfigDialog();
|
||||||
JoypadConfigDialog(Config::Section *_poConfig);
|
|
||||||
virtual ~JoypadConfigDialog();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool bOnEntryFocusIn(GdkEventFocus *_pstEvent, guint _uiEntry);
|
bool bOnEntryFocusIn(GdkEventFocus* _pstEvent, guint _uiEntry);
|
||||||
bool bOnEntryFocusOut(GdkEventFocus *_pstEvent);
|
bool bOnEntryFocusOut(GdkEventFocus* _pstEvent);
|
||||||
|
|
||||||
void vOnInputEvent(const SDL_Event &event);
|
void vOnInputEvent(const SDL_Event& event);
|
||||||
bool on_key_press_event(GdkEventKey *_pstEvent);
|
bool on_key_press_event(GdkEventKey* _pstEvent);
|
||||||
void on_response(int response_id);
|
void on_response(int response_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SJoypadKey {
|
struct SJoypadKey {
|
||||||
const EKey m_eKeyFlag;
|
const EKey m_eKeyFlag;
|
||||||
const char *m_csKeyName;
|
const char* m_csKeyName;
|
||||||
};
|
};
|
||||||
|
|
||||||
Gtk::HBox m_oTitleHBox;
|
Gtk::HBox m_oTitleHBox;
|
||||||
Gtk::Label m_oTitleLabel;
|
Gtk::Label m_oTitleLabel;
|
||||||
Gtk::ComboBoxText m_oTitleCombo;
|
Gtk::ComboBoxText m_oTitleCombo;
|
||||||
Gtk::HSeparator m_oSeparator;
|
Gtk::HSeparator m_oSeparator;
|
||||||
Gtk::CheckButton m_oDefaultJoypad;
|
Gtk::CheckButton m_oDefaultJoypad;
|
||||||
Gtk::Table m_oTable;
|
Gtk::Table m_oTable;
|
||||||
Gtk::Button *m_poOkButton;
|
Gtk::Button* m_poOkButton;
|
||||||
std::vector<Gtk::Entry *> m_oEntries;
|
std::vector<Gtk::Entry*> m_oEntries;
|
||||||
gint m_iCurrentEntry;
|
gint m_iCurrentEntry;
|
||||||
bool m_bUpdating;
|
bool m_bUpdating;
|
||||||
static const SJoypadKey m_astKeys[];
|
static const SJoypadKey m_astKeys[];
|
||||||
sigc::connection m_oConfigSig;
|
sigc::connection m_oConfigSig;
|
||||||
SDL_Event m_oPreviousEvent;
|
SDL_Event m_oPreviousEvent;
|
||||||
EPad m_ePad;
|
EPad m_ePad;
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
|
|
||||||
bool bOnConfigIdle();
|
bool bOnConfigIdle();
|
||||||
void vOnJoypadSelect();
|
void vOnJoypadSelect();
|
||||||
void vOnDefaultJoypadSelect();
|
void vOnDefaultJoypadSelect();
|
||||||
void vUpdateEntries();
|
void vUpdateEntries();
|
||||||
void vEmptyEventQueue();
|
void vEmptyEventQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
157
src/gtk/main.cpp
157
src/gtk/main.cpp
|
@ -16,10 +16,10 @@
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include <gtkmm/main.h>
|
|
||||||
#include <gtkmm/window.h>
|
|
||||||
#include <gtkmm/messagedialog.h>
|
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
|
#include <gtkmm/main.h>
|
||||||
|
#include <gtkmm/messagedialog.h>
|
||||||
|
#include <gtkmm/window.h>
|
||||||
|
|
||||||
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
|
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
#include <gtkmm/gl/init.h>
|
#include <gtkmm/gl/init.h>
|
||||||
|
@ -28,106 +28,97 @@
|
||||||
// this will be ifdefed soon
|
// this will be ifdefed soon
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#include "window.h"
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
int systemDebug = 0;
|
int systemDebug = 0;
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
bool bShowVersion = false;
|
bool bShowVersion = false;
|
||||||
Glib::OptionGroup::vecustrings listRemaining;
|
Glib::OptionGroup::vecustrings listRemaining;
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain("gvbam", LOCALEDIR);
|
bindtextdomain("gvbam", LOCALEDIR);
|
||||||
textdomain("gvbam");
|
textdomain("gvbam");
|
||||||
#endif // ENABLE_NLS
|
#endif // ENABLE_NLS
|
||||||
//will be ifdefed
|
//will be ifdefed
|
||||||
XInitThreads();
|
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)
|
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
Gtk::GL::init(argc, argv);
|
Gtk::GL::init(argc, argv);
|
||||||
#endif // USE_OPENGL
|
#endif // USE_OPENGL
|
||||||
|
|
||||||
Glib::OptionContext oContext;
|
Glib::OptionContext oContext;
|
||||||
Glib::OptionGroup oGroup("main_group", _("Main VBA-M options"));
|
Glib::OptionGroup oGroup("main_group", _("Main VBA-M options"));
|
||||||
|
|
||||||
Glib::OptionEntry oVersion;
|
Glib::OptionEntry oVersion;
|
||||||
oVersion.set_long_name("version");
|
oVersion.set_long_name("version");
|
||||||
oVersion.set_short_name('v');
|
oVersion.set_short_name('v');
|
||||||
oVersion.set_description(_("Output version information."));
|
oVersion.set_description(_("Output version information."));
|
||||||
oGroup.add_entry(oVersion, bShowVersion);
|
oGroup.add_entry(oVersion, bShowVersion);
|
||||||
|
|
||||||
Glib::OptionEntry oFileName;
|
Glib::OptionEntry oFileName;
|
||||||
oFileName.set_long_name(G_OPTION_REMAINING);
|
oFileName.set_long_name(G_OPTION_REMAINING);
|
||||||
oFileName.set_description(G_OPTION_REMAINING);
|
oFileName.set_description(G_OPTION_REMAINING);
|
||||||
oGroup.add_entry(oFileName, listRemaining);
|
oGroup.add_entry(oFileName, listRemaining);
|
||||||
|
|
||||||
oContext.set_main_group(oGroup);
|
oContext.set_main_group(oGroup);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
oContext.parse(argc, argv);
|
||||||
oContext.parse(argc, argv);
|
} catch (const Glib::Error& e) {
|
||||||
}
|
Gtk::MessageDialog oDialog(e.what(),
|
||||||
catch (const Glib::Error& e)
|
false,
|
||||||
{
|
Gtk::MESSAGE_ERROR,
|
||||||
Gtk::MessageDialog oDialog(e.what(),
|
Gtk::BUTTONS_OK);
|
||||||
false,
|
oDialog.run();
|
||||||
Gtk::MESSAGE_ERROR,
|
return 1;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
poWindow->bLoadROM(listRemaining[0]);
|
if (bShowVersion) {
|
||||||
}
|
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
Gtk::Main::run(*poWindow);
|
Gtk::Window::set_default_icon_name("vbam");
|
||||||
delete poWindow;
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,100 +20,100 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
template<typename T> T min( T x, T y ) { return x < y ? x : y; }
|
template <typename T>
|
||||||
template<typename T> T max( T x, T y ) { return x > y ? x : y; }
|
T min(T x, T y) { return x < y ? x : y; }
|
||||||
|
template <typename T>
|
||||||
|
T max(T x, T y) { return x > y ? x : y; }
|
||||||
|
|
||||||
ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale) :
|
ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale)
|
||||||
ScreenArea(_iWidth, _iHeight, _iScale)
|
: ScreenArea(_iWidth, _iHeight, _iScale)
|
||||||
{
|
{
|
||||||
vUpdateSize();
|
vUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
#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);
|
DrawingArea::on_expose_event(_pstEvent);
|
||||||
Cairo::RefPtr< Cairo::ImageSurface > poImage;
|
Cairo::RefPtr<Cairo::ImageSurface> poImage;
|
||||||
Cairo::RefPtr< Cairo::SurfacePattern > poPattern;
|
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
|
||||||
Cairo::RefPtr< Cairo::Context > poContext;
|
Cairo::RefPtr<Cairo::Context> poContext;
|
||||||
Cairo::Matrix oMatrix;
|
Cairo::Matrix oMatrix;
|
||||||
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
|
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->set_identity_matrix();
|
||||||
poContext->scale(m_dScaleFactor, m_dScaleFactor);
|
poContext->scale(m_dScaleFactor, m_dScaleFactor);
|
||||||
|
|
||||||
poImage = Cairo::ImageSurface::create((u8 *)m_puiPixels, Cairo::FORMAT_RGB24,
|
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
|
||||||
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
|
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
|
||||||
|
|
||||||
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
|
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
|
||||||
poPattern = Cairo::SurfacePattern::create(poImage);
|
poPattern = Cairo::SurfacePattern::create(poImage);
|
||||||
poPattern->set_filter(Cairo::FILTER_NEAREST);
|
poPattern->set_filter(Cairo::FILTER_NEAREST);
|
||||||
//poPattern->set_matrix (oMatrix);
|
//poPattern->set_matrix (oMatrix);
|
||||||
poContext->set_source_rgb(0.0, 0.0, 0.0);
|
poContext->set_source_rgb(0.0, 0.0, 0.0);
|
||||||
poContext->paint();
|
poContext->paint();
|
||||||
|
|
||||||
poContext->set_source(poPattern);
|
poContext->set_source(poPattern);
|
||||||
poContext->paint();
|
poContext->paint();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#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);
|
DrawingArea::on_draw(poContext);
|
||||||
Cairo::RefPtr< Cairo::ImageSurface > poImage;
|
Cairo::RefPtr<Cairo::ImageSurface> poImage;
|
||||||
Cairo::RefPtr< Cairo::SurfacePattern > poPattern;
|
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
|
||||||
Cairo::Matrix oMatrix;
|
Cairo::Matrix oMatrix;
|
||||||
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
|
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
|
||||||
|
|
||||||
//poContext->set_identity_matrix();
|
//poContext->set_identity_matrix();
|
||||||
poContext->scale(m_dScaleFactor, m_dScaleFactor);
|
poContext->scale(m_dScaleFactor, m_dScaleFactor);
|
||||||
|
|
||||||
poImage = Cairo::ImageSurface::create((u8 *)m_puiPixels, Cairo::FORMAT_RGB24,
|
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
|
||||||
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
|
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
|
||||||
|
|
||||||
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
|
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
|
||||||
poPattern = Cairo::SurfacePattern::create(poImage);
|
poPattern = Cairo::SurfacePattern::create(poImage);
|
||||||
poPattern->set_filter(Cairo::FILTER_NEAREST);
|
poPattern->set_filter(Cairo::FILTER_NEAREST);
|
||||||
//poPattern->set_matrix (oMatrix);
|
//poPattern->set_matrix (oMatrix);
|
||||||
poContext->set_source_rgb(0.0, 0.0, 0.0);
|
poContext->set_source_rgb(0.0, 0.0, 0.0);
|
||||||
poContext->paint();
|
poContext->paint();
|
||||||
|
|
||||||
poContext->set_source(poPattern);
|
poContext->set_source(poPattern);
|
||||||
poContext->paint();
|
poContext->paint();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ScreenAreaCairo::vDrawBlackScreen()
|
void ScreenAreaCairo::vDrawBlackScreen()
|
||||||
{
|
{
|
||||||
if (m_puiPixels && get_realized())
|
if (m_puiPixels && get_realized()) {
|
||||||
{
|
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
||||||
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
queue_draw_area(0, 0, get_width(), get_height());
|
||||||
queue_draw_area(0, 0, get_width(), get_height());
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenAreaCairo::vOnWidgetResize()
|
void ScreenAreaCairo::vOnWidgetResize()
|
||||||
{
|
{
|
||||||
m_dScaleFactor = min<double>(get_height() / (double)m_iHeight, get_width() / (double)m_iWidth);
|
m_dScaleFactor = min<double>(get_height() / (double)m_iHeight, get_width() / (double)m_iWidth);
|
||||||
m_dScaleFactor /= m_iFilterScale;
|
m_dScaleFactor /= m_iFilterScale;
|
||||||
|
|
||||||
m_iAreaTop = (get_height() / m_dScaleFactor - m_iHeight * 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;
|
m_iAreaLeft = (get_width() / m_dScaleFactor - m_iWidth * m_iFilterScale) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -22,27 +22,25 @@
|
||||||
|
|
||||||
#include "screenarea.h"
|
#include "screenarea.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ScreenAreaCairo : public ScreenArea {
|
||||||
class ScreenAreaCairo : public ScreenArea
|
public:
|
||||||
{
|
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
|
||||||
public:
|
void vDrawPixels(u8* _puiData);
|
||||||
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
|
void vDrawBlackScreen();
|
||||||
void vDrawPixels(u8 *_puiData);
|
|
||||||
void vDrawBlackScreen();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
bool on_expose_event(GdkEventExpose *_pstEvent);
|
bool on_expose_event(GdkEventExpose* _pstEvent);
|
||||||
#else
|
#else
|
||||||
bool on_draw(const Cairo::RefPtr<Cairo::Context> &poContext);
|
bool on_draw(const Cairo::RefPtr<Cairo::Context>& poContext);
|
||||||
#endif
|
#endif
|
||||||
void vOnWidgetResize();
|
void vOnWidgetResize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_dScaleFactor;
|
double m_dScaleFactor;
|
||||||
int m_iAreaTop;
|
int m_iAreaTop;
|
||||||
int m_iAreaLeft;
|
int m_iAreaLeft;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -21,62 +21,63 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T min(T x, T y) { return x < y ? x : y; }
|
||||||
|
template <typename T>
|
||||||
|
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; }
|
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DOUBLE);
|
||||||
template<typename T> T max( T x, T y ) { return x > y ? x : y; }
|
if (!glconfig) {
|
||||||
|
fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
|
||||||
ScreenAreaGl::ScreenAreaGl(int _iWidth, int _iHeight, int _iScale) :
|
throw std::exception();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_gl_capability(glconfig);
|
set_gl_capability(glconfig);
|
||||||
|
|
||||||
vUpdateSize();
|
vUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenAreaGl::vUpdateTexture()
|
void ScreenAreaGl::vUpdateTexture()
|
||||||
{
|
{
|
||||||
// Calculate the new texture size as a the smallest working power of two
|
// Calculate the new texture size as a the smallest working power of two
|
||||||
// TODO: Support the ARB_texture_rectangle extension
|
// TODO: Support the ARB_texture_rectangle extension
|
||||||
int iExpX = 0, iExpY = 0;
|
int iExpX = 0, iExpY = 0;
|
||||||
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX);
|
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX)
|
||||||
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY);
|
;
|
||||||
int iNewTextureSize = 1 << max(iExpX, iExpY);
|
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY)
|
||||||
|
;
|
||||||
|
int iNewTextureSize = 1 << max(iExpX, iExpY);
|
||||||
|
|
||||||
// Notify the system if the texture size changed
|
// Notify the system if the texture size changed
|
||||||
if (iNewTextureSize != m_iTextureSize) {
|
if (iNewTextureSize != m_iTextureSize) {
|
||||||
m_iTextureSize = iNewTextureSize;
|
m_iTextureSize = iNewTextureSize;
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iNewTextureSize, iNewTextureSize,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iNewTextureSize, iNewTextureSize,
|
||||||
0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenAreaGl::on_realize()
|
void ScreenAreaGl::on_realize()
|
||||||
{
|
{
|
||||||
Gtk::DrawingArea::on_realize();
|
Gtk::DrawingArea::on_realize();
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
if (!glwindow->gl_begin(get_gl_context()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (glIsTexture(m_uiScreenTexture))
|
if (glIsTexture(m_uiScreenTexture))
|
||||||
glDeleteTextures(1, &m_uiScreenTexture);
|
glDeleteTextures(1, &m_uiScreenTexture);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -97,96 +98,95 @@ void ScreenAreaGl::on_realize()
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
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()
|
void ScreenAreaGl::vDrawBlackScreen()
|
||||||
{
|
{
|
||||||
if (m_puiPixels && get_realized())
|
if (m_puiPixels && get_realized()) {
|
||||||
{
|
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
||||||
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
queue_draw_area(0, 0, get_width(), get_height());
|
||||||
queue_draw_area(0, 0, get_width(), get_height());
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenAreaGl::vOnWidgetResize()
|
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 iWidth = get_width();
|
||||||
int iHeight = get_height();
|
int iHeight = get_height();
|
||||||
|
|
||||||
float fScreenAspect = (float) m_iScaledWidth / m_iScaledHeight,
|
|
||||||
fWindowAspect = (float) iWidth / iHeight;
|
|
||||||
|
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
float fScreenAspect = (float)m_iScaledWidth / m_iScaledHeight,
|
||||||
return;
|
fWindowAspect = (float)iWidth / iHeight;
|
||||||
|
|
||||||
|
if (!glwindow->gl_begin(get_gl_context()))
|
||||||
|
return;
|
||||||
|
|
||||||
if (fWindowAspect == fScreenAspect)
|
if (fWindowAspect == fScreenAspect)
|
||||||
glViewport(0, 0, iWidth, iHeight);
|
glViewport(0, 0, iWidth, iHeight);
|
||||||
else if (fWindowAspect < fScreenAspect) {
|
else if (fWindowAspect < fScreenAspect) {
|
||||||
int iAspectHeight = (int)(iWidth / fScreenAspect);
|
int iAspectHeight = (int)(iWidth / fScreenAspect);
|
||||||
glViewport(0, (iHeight - iAspectHeight) / 2, iWidth, iAspectHeight);
|
glViewport(0, (iHeight - iAspectHeight) / 2, iWidth, iAspectHeight);
|
||||||
} else {
|
} else {
|
||||||
int iAspectWidth = (int)(iHeight * fScreenAspect);
|
int iAspectWidth = (int)(iHeight * fScreenAspect);
|
||||||
glViewport((iWidth - iAspectWidth) / 2, 0, iAspectWidth, iHeight);
|
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)
|
if (!m_bEnableRender)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
if (!glwindow->gl_begin(get_gl_context()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
glClear( GL_COLOR_BUFFER_BIT );
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_iScaledWidth + 1);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_iScaledWidth + 1);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_iScaledWidth + 1, m_iScaledHeight,
|
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);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
glTexCoord2f(0.0f, 0.0f);
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
glVertex3i(0, 0, 0);
|
glVertex3i(0, 0, 0);
|
||||||
glTexCoord2f(m_iScaledWidth / (GLfloat) m_iTextureSize, 0.0f);
|
glTexCoord2f(m_iScaledWidth / (GLfloat)m_iTextureSize, 0.0f);
|
||||||
glVertex3i(1, 0, 0);
|
glVertex3i(1, 0, 0);
|
||||||
glTexCoord2f(0.0f, m_iScaledHeight / (GLfloat) m_iTextureSize);
|
glTexCoord2f(0.0f, m_iScaledHeight / (GLfloat)m_iTextureSize);
|
||||||
glVertex3i(0, 1, 0);
|
glVertex3i(0, 1, 0);
|
||||||
glTexCoord2f(m_iScaledWidth / (GLfloat) m_iTextureSize,
|
glTexCoord2f(m_iScaledWidth / (GLfloat)m_iTextureSize,
|
||||||
m_iScaledHeight / (GLfloat) m_iTextureSize);
|
m_iScaledHeight / (GLfloat)m_iTextureSize);
|
||||||
glVertex3i(1, 1, 0);
|
glVertex3i(1, 1, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glwindow->swap_buffers();
|
glwindow->swap_buffers();
|
||||||
|
|
||||||
glwindow->gl_end();
|
glwindow->gl_end();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenAreaGl::vOnSizeUpdated()
|
void ScreenAreaGl::vOnSizeUpdated()
|
||||||
{
|
{
|
||||||
if (!get_realized())
|
if (!get_realized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
if (!glwindow->gl_begin(get_gl_context()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vUpdateTexture();
|
vUpdateTexture();
|
||||||
|
|
||||||
glwindow->gl_end();
|
glwindow->gl_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -23,26 +23,24 @@
|
||||||
#include "screenarea.h"
|
#include "screenarea.h"
|
||||||
#include <gtkmm/gl/widget.h>
|
#include <gtkmm/gl/widget.h>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
|
||||||
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl>
|
public:
|
||||||
{
|
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
|
||||||
public:
|
void vDrawPixels(u8* _puiData);
|
||||||
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
|
void vDrawBlackScreen();
|
||||||
void vDrawPixels(u8 *_puiData);
|
|
||||||
void vDrawBlackScreen();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_realize();
|
void on_realize();
|
||||||
bool on_expose_event(GdkEventExpose *_pstEvent);
|
bool on_expose_event(GdkEventExpose* _pstEvent);
|
||||||
void vOnWidgetResize();
|
void vOnWidgetResize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint m_uiScreenTexture;
|
GLuint m_uiScreenTexture;
|
||||||
int m_iTextureSize;
|
int m_iTextureSize;
|
||||||
|
|
||||||
void vUpdateTexture();
|
void vUpdateTexture();
|
||||||
void vOnSizeUpdated();
|
void vOnSizeUpdated();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -21,231 +21,216 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <glibmm/main.h>
|
#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_iWidth = _iWidth;
|
||||||
m_iFilterScale(1),
|
m_iHeight = _iHeight;
|
||||||
m_vFilter2x(NULL),
|
m_iScale = _iScale;
|
||||||
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;
|
set_events(Gdk::EXPOSURE_MASK
|
||||||
m_iHeight = _iHeight;
|
| Gdk::POINTER_MOTION_MASK
|
||||||
m_iScale = _iScale;
|
| Gdk::ENTER_NOTIFY_MASK
|
||||||
|
| Gdk::LEAVE_NOTIFY_MASK);
|
||||||
|
|
||||||
set_events(Gdk::EXPOSURE_MASK
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, 8, 8);
|
||||||
| Gdk::POINTER_MOTION_MASK
|
pixbuf->fill(0);
|
||||||
| 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);
|
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 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
|
#else
|
||||||
m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0);
|
m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenArea::~ScreenArea()
|
ScreenArea::~ScreenArea()
|
||||||
{
|
{
|
||||||
if (m_puiPixels)
|
if (m_puiPixels) {
|
||||||
{
|
delete[] m_puiPixels;
|
||||||
delete[] m_puiPixels;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (m_puiDelta)
|
if (m_puiDelta) {
|
||||||
{
|
delete[] m_puiDelta;
|
||||||
delete[] m_puiDelta;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
if (m_poEmptyCursor != NULL)
|
if (m_poEmptyCursor != NULL) {
|
||||||
{
|
delete m_poEmptyCursor;
|
||||||
delete m_poEmptyCursor;
|
}
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
m_poEmptyCursor.reset();
|
m_poEmptyCursor.reset();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vSetSize(int _iWidth, int _iHeight)
|
void ScreenArea::vSetSize(int _iWidth, int _iHeight)
|
||||||
{
|
{
|
||||||
g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
|
g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
|
||||||
|
|
||||||
if (_iWidth != m_iWidth || _iHeight != m_iHeight)
|
if (_iWidth != m_iWidth || _iHeight != m_iHeight) {
|
||||||
{
|
m_iWidth = _iWidth;
|
||||||
m_iWidth = _iWidth;
|
m_iHeight = _iHeight;
|
||||||
m_iHeight = _iHeight;
|
vUpdateSize();
|
||||||
vUpdateSize();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vSetScale(int _iScale)
|
void ScreenArea::vSetScale(int _iScale)
|
||||||
{
|
{
|
||||||
g_return_if_fail(_iScale >= 1);
|
g_return_if_fail(_iScale >= 1);
|
||||||
|
|
||||||
if (_iScale == 1)
|
if (_iScale == 1) {
|
||||||
{
|
vSetFilter(FilterNone);
|
||||||
vSetFilter(FilterNone);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_iScale = _iScale;
|
m_iScale = _iScale;
|
||||||
vUpdateSize();
|
vUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vSetFilter(EFilter _eFilter)
|
void ScreenArea::vSetFilter(EFilter _eFilter)
|
||||||
{
|
{
|
||||||
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
|
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
|
||||||
|
|
||||||
m_iFilterScale = 1;
|
m_iFilterScale = 1;
|
||||||
if (m_vFilter2x != NULL)
|
if (m_vFilter2x != NULL) {
|
||||||
{
|
m_iFilterScale = 2;
|
||||||
m_iFilterScale = 2;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
vUpdateSize();
|
vUpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB)
|
void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB)
|
||||||
{
|
{
|
||||||
m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32);
|
m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vStartCursorTimeout()
|
void ScreenArea::vStartCursorTimeout()
|
||||||
{
|
{
|
||||||
m_oCursorSig.disconnect();
|
m_oCursorSig.disconnect();
|
||||||
m_oCursorSig = Glib::signal_timeout().connect(
|
m_oCursorSig = Glib::signal_timeout().connect(
|
||||||
sigc::mem_fun(*this, &ScreenArea::bOnCursorTimeout),
|
sigc::mem_fun(*this, &ScreenArea::bOnCursorTimeout),
|
||||||
2000);
|
2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vStopCursorTimeout()
|
void ScreenArea::vStopCursorTimeout()
|
||||||
{
|
{
|
||||||
m_oCursorSig.disconnect();
|
m_oCursorSig.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vHideCursor()
|
void ScreenArea::vHideCursor()
|
||||||
{
|
{
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
get_window()->set_cursor(*m_poEmptyCursor);
|
get_window()->set_cursor(*m_poEmptyCursor);
|
||||||
#else
|
#else
|
||||||
get_window()->set_cursor(m_poEmptyCursor);
|
get_window()->set_cursor(m_poEmptyCursor);
|
||||||
#endif
|
#endif
|
||||||
m_bShowCursor = false;
|
m_bShowCursor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vShowCursor()
|
void ScreenArea::vShowCursor()
|
||||||
{
|
{
|
||||||
get_window()->set_cursor();
|
get_window()->set_cursor();
|
||||||
m_bShowCursor = true;
|
m_bShowCursor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenArea::on_motion_notify_event(GdkEventMotion * _pstEvent)
|
bool ScreenArea::on_motion_notify_event(GdkEventMotion* _pstEvent)
|
||||||
{
|
{
|
||||||
if (! m_bShowCursor)
|
if (!m_bShowCursor) {
|
||||||
{
|
vShowCursor();
|
||||||
vShowCursor();
|
}
|
||||||
}
|
vStartCursorTimeout();
|
||||||
vStartCursorTimeout();
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenArea::on_enter_notify_event(GdkEventCrossing * _pstEvent)
|
bool ScreenArea::on_enter_notify_event(GdkEventCrossing* _pstEvent)
|
||||||
{
|
{
|
||||||
vStartCursorTimeout();
|
vStartCursorTimeout();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenArea::on_leave_notify_event(GdkEventCrossing * _pstEvent)
|
bool ScreenArea::on_leave_notify_event(GdkEventCrossing* _pstEvent)
|
||||||
{
|
{
|
||||||
vStopCursorTimeout();
|
vStopCursorTimeout();
|
||||||
if (! m_bShowCursor)
|
if (!m_bShowCursor) {
|
||||||
{
|
vShowCursor();
|
||||||
vShowCursor();
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenArea::bOnCursorTimeout()
|
bool ScreenArea::bOnCursorTimeout()
|
||||||
{
|
{
|
||||||
vHideCursor();
|
vHideCursor();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vDrawPixels(u8 * _puiData)
|
void ScreenArea::vDrawPixels(u8* _puiData)
|
||||||
{
|
{
|
||||||
const int iSrcPitch = (m_iWidth + 1) * sizeof(u32);
|
const int iSrcPitch = (m_iWidth + 1) * sizeof(u32);
|
||||||
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
|
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
|
||||||
|
|
||||||
if (m_vFilterIB != NULL)
|
if (m_vFilterIB != NULL) {
|
||||||
{
|
m_vFilterIB(_puiData + iSrcPitch,
|
||||||
m_vFilterIB(_puiData + iSrcPitch,
|
iSrcPitch,
|
||||||
iSrcPitch,
|
m_iWidth,
|
||||||
m_iWidth,
|
m_iHeight);
|
||||||
m_iHeight);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (m_vFilter2x != NULL)
|
if (m_vFilter2x != NULL) {
|
||||||
{
|
m_vFilter2x(_puiData + iSrcPitch,
|
||||||
m_vFilter2x(_puiData + iSrcPitch,
|
iSrcPitch,
|
||||||
iSrcPitch,
|
m_puiDelta,
|
||||||
m_puiDelta,
|
(u8*)m_puiPixels,
|
||||||
(u8 *)m_puiPixels,
|
iScaledPitch,
|
||||||
iScaledPitch,
|
m_iWidth,
|
||||||
m_iWidth,
|
m_iHeight);
|
||||||
m_iHeight);
|
} else {
|
||||||
}
|
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vUpdateSize()
|
void ScreenArea::vUpdateSize()
|
||||||
{
|
{
|
||||||
if (m_puiPixels)
|
if (m_puiPixels) {
|
||||||
{
|
delete[] m_puiPixels;
|
||||||
delete[] m_puiPixels;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (m_puiDelta)
|
if (m_puiDelta) {
|
||||||
{
|
delete[] m_puiDelta;
|
||||||
delete[] m_puiDelta;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_iScaledWidth = m_iFilterScale * m_iWidth;
|
m_iScaledWidth = m_iFilterScale * m_iWidth;
|
||||||
m_iScaledHeight = m_iFilterScale * m_iHeight;
|
m_iScaledHeight = m_iFilterScale * m_iHeight;
|
||||||
|
|
||||||
m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight];
|
m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight];
|
||||||
m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)];
|
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_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(u32));
|
||||||
memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * 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)
|
void ScreenArea::vSetEnableRender(bool _bEnable)
|
||||||
{
|
{
|
||||||
m_bEnableRender = _bEnable;
|
m_bEnableRender = _bEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -25,61 +25,59 @@
|
||||||
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ScreenArea : public Gtk::DrawingArea {
|
||||||
class ScreenArea : public Gtk::DrawingArea
|
public:
|
||||||
{
|
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
|
||||||
public:
|
virtual ~ScreenArea();
|
||||||
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
|
|
||||||
virtual ~ScreenArea();
|
|
||||||
|
|
||||||
void vSetSize(int _iWidth, int _iHeight);
|
void vSetSize(int _iWidth, int _iHeight);
|
||||||
void vSetScale(int _iScale);
|
void vSetScale(int _iScale);
|
||||||
void vSetFilter(EFilter _eFilter);
|
void vSetFilter(EFilter _eFilter);
|
||||||
void vSetFilterIB(EFilterIB _eFilterIB);
|
void vSetFilterIB(EFilterIB _eFilterIB);
|
||||||
void vSetEnableRender(bool _bEnable);
|
void vSetEnableRender(bool _bEnable);
|
||||||
virtual void vDrawPixels(u8 *_puiData);
|
virtual void vDrawPixels(u8* _puiData);
|
||||||
virtual void vDrawBlackScreen() = 0;
|
virtual void vDrawBlackScreen() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_motion_notify_event(GdkEventMotion *_pstEvent);
|
virtual bool on_motion_notify_event(GdkEventMotion* _pstEvent);
|
||||||
virtual bool on_enter_notify_event(GdkEventCrossing *_pstEvent);
|
virtual bool on_enter_notify_event(GdkEventCrossing* _pstEvent);
|
||||||
virtual bool on_leave_notify_event(GdkEventCrossing *_pstEvent);
|
virtual bool on_leave_notify_event(GdkEventCrossing* _pstEvent);
|
||||||
virtual bool on_configure_event(GdkEventConfigure *event);
|
virtual bool on_configure_event(GdkEventConfigure* event);
|
||||||
virtual bool bOnCursorTimeout();
|
virtual bool bOnCursorTimeout();
|
||||||
virtual void vOnSizeUpdated()
|
virtual void vOnSizeUpdated()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_iWidth;
|
int m_iWidth;
|
||||||
int m_iHeight;
|
int m_iHeight;
|
||||||
int m_iScale;
|
int m_iScale;
|
||||||
int m_iFilterScale;
|
int m_iFilterScale;
|
||||||
int m_iAreaWidth;
|
int m_iAreaWidth;
|
||||||
int m_iAreaHeight;
|
int m_iAreaHeight;
|
||||||
Filter m_vFilter2x;
|
Filter m_vFilter2x;
|
||||||
FilterIB m_vFilterIB;
|
FilterIB m_vFilterIB;
|
||||||
u32 *m_puiPixels;
|
u32* m_puiPixels;
|
||||||
u8 *m_puiDelta;
|
u8* m_puiDelta;
|
||||||
int m_iScaledWidth;
|
int m_iScaledWidth;
|
||||||
int m_iScaledHeight;
|
int m_iScaledHeight;
|
||||||
bool m_bEnableRender;
|
bool m_bEnableRender;
|
||||||
|
|
||||||
bool m_bShowCursor;
|
bool m_bShowCursor;
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
Gdk::Cursor *m_poEmptyCursor;
|
Gdk::Cursor* m_poEmptyCursor;
|
||||||
#else
|
#else
|
||||||
Glib::RefPtr<Gdk::Cursor> m_poEmptyCursor;
|
Glib::RefPtr<Gdk::Cursor> m_poEmptyCursor;
|
||||||
#endif
|
#endif
|
||||||
sigc::connection m_oCursorSig;
|
sigc::connection m_oCursorSig;
|
||||||
|
|
||||||
void vUpdateSize();
|
void vUpdateSize();
|
||||||
virtual void vOnWidgetResize() = 0;
|
virtual void vOnWidgetResize() = 0;
|
||||||
void vStartCursorTimeout();
|
void vStartCursorTimeout();
|
||||||
void vStopCursorTimeout();
|
void vStopCursorTimeout();
|
||||||
void vHideCursor();
|
void vHideCursor();
|
||||||
void vShowCursor();
|
void vShowCursor();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -18,117 +18,113 @@
|
||||||
|
|
||||||
#include "soundconfig.h"
|
#include "soundconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
|
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
|
||||||
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
|
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
|
||||||
|
|
||||||
m_poVolumeComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnVolumeChanged));
|
m_poVolumeComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnVolumeChanged));
|
||||||
m_poRateComboBox->signal_changed().connect(sigc::mem_fun(*this, &SoundConfigDialog::vOnRateChanged));
|
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_poConfig = _poConfig;
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
|
||||||
bool bMute = m_poConfig->oGetKey<bool>("mute");
|
bool bMute = m_poConfig->oGetKey<bool>("mute");
|
||||||
float fSoundVolume = m_poConfig->oGetKey<float>("volume");
|
float fSoundVolume = m_poConfig->oGetKey<float>("volume");
|
||||||
|
|
||||||
if (bMute)
|
if (bMute)
|
||||||
m_poVolumeComboBox->set_active(0);
|
m_poVolumeComboBox->set_active(0);
|
||||||
else if (0.0f <= fSoundVolume && fSoundVolume <= 0.25f)
|
else if (0.0f <= fSoundVolume && fSoundVolume <= 0.25f)
|
||||||
m_poVolumeComboBox->set_active(1);
|
m_poVolumeComboBox->set_active(1);
|
||||||
else if (0.25f < fSoundVolume && fSoundVolume <= 0.50f)
|
else if (0.25f < fSoundVolume && fSoundVolume <= 0.50f)
|
||||||
m_poVolumeComboBox->set_active(2);
|
m_poVolumeComboBox->set_active(2);
|
||||||
else if (1.0f < fSoundVolume && fSoundVolume <= 2.0f)
|
else if (1.0f < fSoundVolume && fSoundVolume <= 2.0f)
|
||||||
m_poVolumeComboBox->set_active(4);
|
m_poVolumeComboBox->set_active(4);
|
||||||
else
|
else
|
||||||
m_poVolumeComboBox->set_active(3);
|
m_poVolumeComboBox->set_active(3);
|
||||||
|
|
||||||
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
|
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
|
||||||
switch (iSoundSampleRate)
|
switch (iSoundSampleRate) {
|
||||||
{
|
|
||||||
case 11025:
|
case 11025:
|
||||||
m_poRateComboBox->set_active(0);
|
m_poRateComboBox->set_active(0);
|
||||||
break;
|
break;
|
||||||
case 22050:
|
case 22050:
|
||||||
m_poRateComboBox->set_active(1);
|
m_poRateComboBox->set_active(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case 44100:
|
case 44100:
|
||||||
m_poRateComboBox->set_active(2);
|
m_poRateComboBox->set_active(2);
|
||||||
break;
|
break;
|
||||||
case 48000:
|
case 48000:
|
||||||
m_poRateComboBox->set_active(3);
|
m_poRateComboBox->set_active(3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundConfigDialog::vOnVolumeChanged()
|
void SoundConfigDialog::vOnVolumeChanged()
|
||||||
{
|
{
|
||||||
int iVolume = m_poVolumeComboBox->get_active_row_number();
|
int iVolume = m_poVolumeComboBox->get_active_row_number();
|
||||||
switch (iVolume)
|
switch (iVolume) {
|
||||||
{
|
|
||||||
case 0: // Mute
|
case 0: // Mute
|
||||||
m_poConfig->vSetKey("mute", true);
|
m_poConfig->vSetKey("mute", true);
|
||||||
m_poConfig->vSetKey("volume", 1.0f);
|
m_poConfig->vSetKey("volume", 1.0f);
|
||||||
break;
|
break;
|
||||||
case 1: // 25 %
|
case 1: // 25 %
|
||||||
m_poConfig->vSetKey("mute", false);
|
m_poConfig->vSetKey("mute", false);
|
||||||
m_poConfig->vSetKey("volume", 0.25f);
|
m_poConfig->vSetKey("volume", 0.25f);
|
||||||
break;
|
break;
|
||||||
case 2: // 50 %
|
case 2: // 50 %
|
||||||
m_poConfig->vSetKey("mute", false);
|
m_poConfig->vSetKey("mute", false);
|
||||||
m_poConfig->vSetKey("volume", 0.50f);
|
m_poConfig->vSetKey("volume", 0.50f);
|
||||||
break;
|
break;
|
||||||
case 4: // 200 %
|
case 4: // 200 %
|
||||||
m_poConfig->vSetKey("mute", false);
|
m_poConfig->vSetKey("mute", false);
|
||||||
m_poConfig->vSetKey("volume", 2.00f);
|
m_poConfig->vSetKey("volume", 2.00f);
|
||||||
break;
|
break;
|
||||||
case 3: // 100 %
|
case 3: // 100 %
|
||||||
default:
|
default:
|
||||||
m_poConfig->vSetKey("mute", false);
|
m_poConfig->vSetKey("mute", false);
|
||||||
m_poConfig->vSetKey("volume", 1.00f);
|
m_poConfig->vSetKey("volume", 1.00f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_poWindow->vApplyConfigMute();
|
m_poWindow->vApplyConfigMute();
|
||||||
m_poWindow->vApplyConfigVolume();
|
m_poWindow->vApplyConfigVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundConfigDialog::vOnRateChanged()
|
void SoundConfigDialog::vOnRateChanged()
|
||||||
{
|
{
|
||||||
int iRate = m_poRateComboBox->get_active_row_number();
|
int iRate = m_poRateComboBox->get_active_row_number();
|
||||||
switch (iRate)
|
switch (iRate) {
|
||||||
{
|
|
||||||
case 0: // 11 KHz
|
case 0: // 11 KHz
|
||||||
m_poConfig->vSetKey("sample_rate", 11025);
|
m_poConfig->vSetKey("sample_rate", 11025);
|
||||||
break;
|
break;
|
||||||
case 1: // 22 KHz
|
case 1: // 22 KHz
|
||||||
m_poConfig->vSetKey("sample_rate", 22050);
|
m_poConfig->vSetKey("sample_rate", 22050);
|
||||||
break;
|
break;
|
||||||
case 2: // 44 KHz
|
case 2: // 44 KHz
|
||||||
default:
|
default:
|
||||||
m_poConfig->vSetKey("sample_rate", 44100);
|
m_poConfig->vSetKey("sample_rate", 44100);
|
||||||
break;
|
break;
|
||||||
case 3: // 48 KHz
|
case 3: // 48 KHz
|
||||||
m_poConfig->vSetKey("sample_rate", 48000);
|
m_poConfig->vSetKey("sample_rate", 48000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_poWindow->vApplyConfigSoundSampleRate();
|
m_poWindow->vApplyConfigSoundSampleRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -26,24 +26,22 @@
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class SoundConfigDialog : public Gtk::Dialog {
|
||||||
class SoundConfigDialog : public Gtk::Dialog
|
public:
|
||||||
{
|
SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
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:
|
private:
|
||||||
void vOnVolumeChanged();
|
void vOnVolumeChanged();
|
||||||
void vOnRateChanged();
|
void vOnRateChanged();
|
||||||
|
|
||||||
VBA::Window *m_poWindow;
|
VBA::Window* m_poWindow;
|
||||||
|
|
||||||
Config::Section *m_poConfig;
|
Config::Section* m_poConfig;
|
||||||
Gtk::ComboBox *m_poVolumeComboBox;
|
Gtk::ComboBox* m_poVolumeComboBox;
|
||||||
Gtk::ComboBox *m_poRateComboBox;
|
Gtk::ComboBox* m_poRateComboBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -16,81 +16,87 @@
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "../sdl/inputSDL.h"
|
|
||||||
#include "../gba/Sound.h"
|
|
||||||
#include "../common/SoundSDL.h"
|
#include "../common/SoundSDL.h"
|
||||||
|
#include "../gba/Sound.h"
|
||||||
|
#include "../sdl/inputSDL.h"
|
||||||
|
|
||||||
#include "window.h"
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
// Required vars, used by the emulator core
|
// Required vars, used by the emulator core
|
||||||
//
|
//
|
||||||
int systemRedShift;
|
int systemRedShift;
|
||||||
int systemGreenShift;
|
int systemGreenShift;
|
||||||
int systemBlueShift;
|
int systemBlueShift;
|
||||||
int systemColorDepth;
|
int systemColorDepth;
|
||||||
int systemVerbose;
|
int systemVerbose;
|
||||||
int systemSaveUpdateCounter;
|
int systemSaveUpdateCounter;
|
||||||
int systemFrameSkip;
|
int systemFrameSkip;
|
||||||
u32 systemColorMap32[0x10000];
|
u32 systemColorMap32[0x10000];
|
||||||
u16 systemColorMap16[0x10000];
|
u16 systemColorMap16[0x10000];
|
||||||
u16 systemGbPalette[24];
|
u16 systemGbPalette[24];
|
||||||
|
|
||||||
int emulating;
|
int emulating;
|
||||||
int RGB_LOW_BITS_MASK;
|
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_list args;
|
||||||
va_start(args, _csFormat);
|
va_start(args, _csFormat);
|
||||||
|
|
||||||
GUI()->vPopupErrorV(_(_csFormat), args);
|
GUI()
|
||||||
|
->vPopupErrorV(_(_csFormat), args);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemDrawScreen()
|
void systemDrawScreen()
|
||||||
{
|
{
|
||||||
GUI()->vDrawScreen();
|
GUI()
|
||||||
|
->vDrawScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemReadJoypads()
|
bool systemReadJoypads()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 systemReadJoypad(int joy)
|
u32 systemReadJoypad(int joy)
|
||||||
{
|
{
|
||||||
return inputReadJoypad(joy);
|
return inputReadJoypad(joy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemShowSpeed(int _iSpeed)
|
void systemShowSpeed(int _iSpeed)
|
||||||
{
|
{
|
||||||
GUI()->vShowSpeed(_iSpeed);
|
GUI()
|
||||||
|
->vShowSpeed(_iSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void system10Frames(int _iRate)
|
void system10Frames(int _iRate)
|
||||||
{
|
{
|
||||||
GUI()->vComputeFrameskip(_iRate);
|
GUI()
|
||||||
|
->vComputeFrameskip(_iRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemFrame()
|
void systemFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemSetTitle(const char * _csTitle)
|
void systemSetTitle(const char* _csTitle)
|
||||||
{
|
{
|
||||||
GUI()->set_title(_csTitle);
|
GUI()
|
||||||
|
->set_title(_csTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemScreenCapture(int _iNum)
|
void systemScreenCapture(int _iNum)
|
||||||
{
|
{
|
||||||
GUI()->vCaptureScreen(_iNum);
|
GUI()
|
||||||
|
->vCaptureScreen(_iNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 systemGetClock()
|
u32 systemGetClock()
|
||||||
|
@ -106,67 +112,67 @@ void systemUpdateMotionSensor()
|
||||||
|
|
||||||
u8 systemGetSensorDarkness()
|
u8 systemGetSensorDarkness()
|
||||||
{
|
{
|
||||||
return 0xE8;
|
return 0xE8;
|
||||||
}
|
}
|
||||||
|
|
||||||
int systemGetSensorX()
|
int systemGetSensorX()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int systemGetSensorY()
|
int systemGetSensorY()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int systemGetSensorZ()
|
int systemGetSensorZ()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemCartridgeRumble(bool)
|
void systemCartridgeRumble(bool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemGbPrint(u8 * _puiData,
|
void systemGbPrint(u8* _puiData,
|
||||||
int _iLen,
|
int _iLen,
|
||||||
int _iPages,
|
int _iPages,
|
||||||
int _iFeed,
|
int _iFeed,
|
||||||
int _iPalette,
|
int _iPalette,
|
||||||
int _iContrast)
|
int _iContrast)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemScreenMessage(const char * _csMsg)
|
void systemScreenMessage(const char* _csMsg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemCanChangeSoundQuality()
|
bool systemCanChangeSoundQuality()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemPauseOnFrame()
|
bool systemPauseOnFrame()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemGbBorderOn()
|
void systemGbBorderOn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundDriver * systemSoundInit()
|
SoundDriver* systemSoundInit()
|
||||||
{
|
{
|
||||||
soundShutdown();
|
soundShutdown();
|
||||||
|
|
||||||
return new SoundSDL();
|
return new SoundSDL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemOnSoundShutdown()
|
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) {
|
if (out == NULL) {
|
||||||
out = fopen("trace.log","w");
|
out = fopen("trace.log", "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
va_list valist;
|
va_list valist;
|
||||||
|
|
||||||
va_start(valist, defaultMsg);
|
va_start(valist, defaultMsg);
|
||||||
vfprintf(out, defaultMsg, valist);
|
vfprintf(out, defaultMsg, valist);
|
||||||
va_end(valist);
|
va_end(valist);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,68 +18,60 @@
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
std::string sCutSuffix(const std::string & _rsString,
|
std::string sCutSuffix(const std::string& _rsString,
|
||||||
const std::string & _rsSep)
|
const std::string& _rsSep)
|
||||||
{
|
{
|
||||||
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,
|
Glib::ustring sCutSuffix(const Glib::ustring& _rsString,
|
||||||
const Glib::ustring & _rsSep)
|
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,
|
bool bHasSuffix(const Glib::ustring& _rsString,
|
||||||
const Glib::ustring & _rsSuffix,
|
const Glib::ustring& _rsSuffix,
|
||||||
bool _bCaseSensitive)
|
bool _bCaseSensitive)
|
||||||
{
|
{
|
||||||
if (_rsSuffix.size() > _rsString.size())
|
if (_rsSuffix.size() > _rsString.size()) {
|
||||||
{
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
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)
|
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.
|
// Skip delimiters at beginning.
|
||||||
Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0);
|
Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0);
|
||||||
// Find first "non-delimiter".
|
// Find first "non-delimiter".
|
||||||
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
|
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
|
||||||
|
|
||||||
while (Glib::ustring::npos != pos || std:: string::npos != lastPos)
|
while (Glib::ustring::npos != pos || std::string::npos != lastPos) {
|
||||||
{
|
// Found a token, add it to the vector.
|
||||||
// Found a token, add it to the vector.
|
tokens.push_back(source.substr(lastPos, pos - lastPos));
|
||||||
tokens.push_back(source.substr(lastPos, pos - lastPos));
|
// Skip delimiters. Note the "not_of"
|
||||||
// Skip delimiters. Note the "not_of"
|
lastPos = source.find_first_not_of(delimiters, pos);
|
||||||
lastPos = source.find_first_not_of(delimiters, pos);
|
// Find next "non-delimiter"
|
||||||
// Find next "non-delimiter"
|
pos = source.find_first_of(delimiters, lastPos);
|
||||||
pos = source.find_first_of(delimiters, lastPos);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -24,16 +24,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
std::string sCutSuffix(const std::string& _rsString, const std::string& _rsSep = ".");
|
||||||
std::string sCutSuffix(const std::string &_rsString, const std::string &_rsSep = ".");
|
|
||||||
|
|
||||||
Glib::ustring sCutSuffix(const Glib::ustring &_rsString, const Glib::ustring &_rsSep = ".");
|
Glib::ustring sCutSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSep = ".");
|
||||||
|
|
||||||
bool bHasSuffix(const Glib::ustring &_rsString, const Glib::ustring &_rsSuffix,
|
bool bHasSuffix(const Glib::ustring& _rsString, const Glib::ustring& _rsSuffix,
|
||||||
bool _bCaseSensitive = true);
|
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__
|
#endif // __VBA_TOOLS_H__
|
||||||
|
|
2249
src/gtk/window.cpp
2249
src/gtk/window.cpp
File diff suppressed because it is too large
Load Diff
397
src/gtk/window.h
397
src/gtk/window.h
|
@ -34,231 +34,242 @@
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
#include "screenarea.h"
|
#include "screenarea.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class Window : public Gtk::Window {
|
||||||
class Window : public Gtk::Window
|
friend class Gtk::Builder;
|
||||||
{
|
|
||||||
friend class Gtk::Builder;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
inline static Window *poGetInstance()
|
inline static Window* poGetInstance()
|
||||||
{
|
{
|
||||||
return m_poInstance;
|
return m_poInstance;
|
||||||
}
|
}
|
||||||
static std::string sGetUiFilePath(const std::string &_sFileName);
|
static std::string sGetUiFilePath(const std::string& _sFileName);
|
||||||
|
|
||||||
enum ECartridge { CartridgeNone, CartridgeGB, CartridgeGBA };
|
enum ECartridge { CartridgeNone,
|
||||||
|
CartridgeGB,
|
||||||
|
CartridgeGBA };
|
||||||
|
|
||||||
enum EVideoOutput { OutputCairo, OutputOpenGL };
|
enum EVideoOutput { OutputCairo,
|
||||||
|
OutputOpenGL };
|
||||||
|
|
||||||
enum EEmulatorType {
|
enum EEmulatorType {
|
||||||
EmulatorAuto,
|
EmulatorAuto,
|
||||||
EmulatorCGB,
|
EmulatorCGB,
|
||||||
EmulatorSGB,
|
EmulatorSGB,
|
||||||
EmulatorGB,
|
EmulatorGB,
|
||||||
EmulatorGBA,
|
EmulatorGBA,
|
||||||
EmulatorSGB2
|
EmulatorSGB2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ESaveType { SaveAuto, SaveEEPROM, SaveSRAM, SaveFlash, SaveEEPROMSensor, SaveNone };
|
enum ESaveType { SaveAuto,
|
||||||
|
SaveEEPROM,
|
||||||
|
SaveSRAM,
|
||||||
|
SaveFlash,
|
||||||
|
SaveEEPROMSensor,
|
||||||
|
SaveNone };
|
||||||
|
|
||||||
// GB/GBA screen sizes
|
// GB/GBA screen sizes
|
||||||
const int m_iGBScreenWidth;
|
const int m_iGBScreenWidth;
|
||||||
const int m_iGBScreenHeight;
|
const int m_iGBScreenHeight;
|
||||||
const int m_iSGBScreenWidth;
|
const int m_iSGBScreenWidth;
|
||||||
const int m_iSGBScreenHeight;
|
const int m_iSGBScreenHeight;
|
||||||
const int m_iGBAScreenWidth;
|
const int m_iGBAScreenWidth;
|
||||||
const int m_iGBAScreenHeight;
|
const int m_iGBAScreenHeight;
|
||||||
|
|
||||||
bool bLoadROM(const std::string &_rsFile);
|
bool bLoadROM(const std::string& _rsFile);
|
||||||
void vPopupError(const char *_csFormat, ...);
|
void vPopupError(const char* _csFormat, ...);
|
||||||
void vPopupErrorV(const char *_csFormat, va_list _args);
|
void vPopupErrorV(const char* _csFormat, va_list _args);
|
||||||
void vDrawScreen();
|
void vDrawScreen();
|
||||||
void vComputeFrameskip(int _iRate);
|
void vComputeFrameskip(int _iRate);
|
||||||
void vShowSpeed(int _iSpeed);
|
void vShowSpeed(int _iSpeed);
|
||||||
void vCaptureScreen(int _iNum);
|
void vCaptureScreen(int _iNum);
|
||||||
void vApplyConfigFilter();
|
void vApplyConfigFilter();
|
||||||
void vApplyConfigFilterIB();
|
void vApplyConfigFilterIB();
|
||||||
void vApplyConfigScreenArea();
|
void vApplyConfigScreenArea();
|
||||||
void vApplyConfigMute();
|
void vApplyConfigMute();
|
||||||
void vApplyConfigVolume();
|
void vApplyConfigVolume();
|
||||||
void vApplyConfigSoundSampleRate();
|
void vApplyConfigSoundSampleRate();
|
||||||
void vApplyConfigGBSystem();
|
void vApplyConfigGBSystem();
|
||||||
void vApplyConfigGBBorder();
|
void vApplyConfigGBBorder();
|
||||||
void vApplyConfigGBPrinter();
|
void vApplyConfigGBPrinter();
|
||||||
void vApplyConfigGBASaveType();
|
void vApplyConfigGBASaveType();
|
||||||
void vApplyConfigGBAFlashSize();
|
void vApplyConfigGBAFlashSize();
|
||||||
void vApplyConfigGBARTC();
|
void vApplyConfigGBARTC();
|
||||||
void vApplyConfigFrameskip();
|
void vApplyConfigFrameskip();
|
||||||
void vApplyConfigShowSpeed();
|
void vApplyConfigShowSpeed();
|
||||||
void vApplyPerGameConfig();
|
void vApplyPerGameConfig();
|
||||||
void vUpdateScreen();
|
void vUpdateScreen();
|
||||||
|
|
||||||
inline ECartridge eGetCartridge() const
|
inline ECartridge eGetCartridge() const
|
||||||
{
|
{
|
||||||
return m_eCartridge;
|
return m_eCartridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Window(GtkWindow *_pstWindow, const Glib::RefPtr<Gtk::Builder> &_poXml);
|
Window(GtkWindow* _pstWindow, const Glib::RefPtr<Gtk::Builder>& _poXml);
|
||||||
|
|
||||||
enum EShowSpeed { ShowNone, ShowPercentage, ShowDetailed };
|
enum EShowSpeed { ShowNone,
|
||||||
|
ShowPercentage,
|
||||||
|
ShowDetailed };
|
||||||
|
|
||||||
enum ESoundStatus { SoundOff, SoundMute, SoundOn };
|
enum ESoundStatus { SoundOff,
|
||||||
|
SoundMute,
|
||||||
|
SoundOn };
|
||||||
|
|
||||||
enum EColorFormat { ColorFormatRGB, ColorFormatBGR };
|
enum EColorFormat { ColorFormatRGB,
|
||||||
|
ColorFormatBGR };
|
||||||
|
|
||||||
virtual void vOnMenuEnter();
|
virtual void vOnMenuEnter();
|
||||||
virtual void vOnMenuExit();
|
virtual void vOnMenuExit();
|
||||||
virtual void vOnFileOpen();
|
virtual void vOnFileOpen();
|
||||||
virtual void vOnFileLoad();
|
virtual void vOnFileLoad();
|
||||||
virtual void vOnFileSave();
|
virtual void vOnFileSave();
|
||||||
virtual void vOnLoadGameMostRecent();
|
virtual void vOnLoadGameMostRecent();
|
||||||
virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem *_poCMI);
|
virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem* _poCMI);
|
||||||
void vOnLoadGame(int _iSlot);
|
void vOnLoadGame(int _iSlot);
|
||||||
virtual void vOnSaveGameOldest();
|
virtual void vOnSaveGameOldest();
|
||||||
void vOnSaveGame(int _iSlot);
|
void vOnSaveGame(int _iSlot);
|
||||||
virtual void vOnFilePauseToggled(Gtk::CheckMenuItem *_poCMI);
|
virtual void vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI);
|
||||||
virtual void vOnFileReset();
|
virtual void vOnFileReset();
|
||||||
virtual void vOnRecentFile();
|
virtual void vOnRecentFile();
|
||||||
virtual void vOnFileScreenCapture();
|
virtual void vOnFileScreenCapture();
|
||||||
virtual void vOnFileClose();
|
virtual void vOnFileClose();
|
||||||
virtual void vOnFileExit();
|
virtual void vOnFileExit();
|
||||||
virtual void vOnVideoFullscreen();
|
virtual void vOnVideoFullscreen();
|
||||||
virtual void vOnDirectories();
|
virtual void vOnDirectories();
|
||||||
virtual void vOnGeneralConfigure();
|
virtual void vOnGeneralConfigure();
|
||||||
virtual void vOnJoypadConfigure();
|
virtual void vOnJoypadConfigure();
|
||||||
virtual void vOnDisplayConfigure();
|
virtual void vOnDisplayConfigure();
|
||||||
virtual void vOnSoundConfigure();
|
virtual void vOnSoundConfigure();
|
||||||
virtual void vOnGameBoyConfigure();
|
virtual void vOnGameBoyConfigure();
|
||||||
virtual void vOnGameBoyAdvanceConfigure();
|
virtual void vOnGameBoyAdvanceConfigure();
|
||||||
virtual void vOnCheatList();
|
virtual void vOnCheatList();
|
||||||
virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem *_poCMI);
|
virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem* _poCMI);
|
||||||
virtual void vOnHelpAbout();
|
virtual void vOnHelpAbout();
|
||||||
virtual bool bOnEmuIdle();
|
virtual bool bOnEmuIdle();
|
||||||
virtual bool bOnEmuSaveStateRewind();
|
virtual bool bOnEmuSaveStateRewind();
|
||||||
virtual bool bOnEmuRewind();
|
virtual bool bOnEmuRewind();
|
||||||
|
|
||||||
virtual bool on_focus_in_event(GdkEventFocus *_pstEvent);
|
virtual bool on_focus_in_event(GdkEventFocus* _pstEvent);
|
||||||
virtual bool on_focus_out_event(GdkEventFocus *_pstEvent);
|
virtual bool on_focus_out_event(GdkEventFocus* _pstEvent);
|
||||||
virtual bool on_key_press_event(GdkEventKey *_pstEvent);
|
virtual bool on_key_press_event(GdkEventKey* _pstEvent);
|
||||||
virtual bool on_key_release_event(GdkEventKey *_pstEvent);
|
virtual bool on_key_release_event(GdkEventKey* _pstEvent);
|
||||||
virtual bool on_window_state_event(GdkEventWindowState *_pstEvent);
|
virtual bool on_window_state_event(GdkEventWindowState* _pstEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Config limits
|
// Config limits
|
||||||
const int m_iFrameskipMin;
|
const int m_iFrameskipMin;
|
||||||
const int m_iFrameskipMax;
|
const int m_iFrameskipMax;
|
||||||
const int m_iScaleMin;
|
const int m_iScaleMin;
|
||||||
const int m_iScaleMax;
|
const int m_iScaleMax;
|
||||||
const int m_iShowSpeedMin;
|
const int m_iShowSpeedMin;
|
||||||
const int m_iShowSpeedMax;
|
const int m_iShowSpeedMax;
|
||||||
const int m_iSaveTypeMin;
|
const int m_iSaveTypeMin;
|
||||||
const int m_iSaveTypeMax;
|
const int m_iSaveTypeMax;
|
||||||
const int m_iSoundSampleRateMin;
|
const int m_iSoundSampleRateMin;
|
||||||
const int m_iSoundSampleRateMax;
|
const int m_iSoundSampleRateMax;
|
||||||
const float m_fSoundVolumeMin;
|
const float m_fSoundVolumeMin;
|
||||||
const float m_fSoundVolumeMax;
|
const float m_fSoundVolumeMax;
|
||||||
const int m_iEmulatorTypeMin;
|
const int m_iEmulatorTypeMin;
|
||||||
const int m_iEmulatorTypeMax;
|
const int m_iEmulatorTypeMax;
|
||||||
const int m_iFilter2xMin;
|
const int m_iFilter2xMin;
|
||||||
const int m_iFilter2xMax;
|
const int m_iFilter2xMax;
|
||||||
const int m_iFilterIBMin;
|
const int m_iFilterIBMin;
|
||||||
const int m_iFilterIBMax;
|
const int m_iFilterIBMax;
|
||||||
const EPad m_iJoypadMin;
|
const EPad m_iJoypadMin;
|
||||||
const EPad m_iJoypadMax;
|
const EPad m_iJoypadMax;
|
||||||
const int m_iVideoOutputMin;
|
const int m_iVideoOutputMin;
|
||||||
const int m_iVideoOutputMax;
|
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_sUserDataDir;
|
||||||
std::string m_sConfigFile;
|
std::string m_sConfigFile;
|
||||||
Config::File m_oConfig;
|
Config::File m_oConfig;
|
||||||
Config::Section *m_poDirConfig;
|
Config::Section* m_poDirConfig;
|
||||||
Config::Section *m_poCoreConfig;
|
Config::Section* m_poCoreConfig;
|
||||||
Config::Section *m_poDisplayConfig;
|
Config::Section* m_poDisplayConfig;
|
||||||
Config::Section *m_poSoundConfig;
|
Config::Section* m_poSoundConfig;
|
||||||
Config::Section *m_poInputConfig;
|
Config::Section* m_poInputConfig;
|
||||||
|
|
||||||
Gtk::FileChooserDialog *m_poFileOpenDialog;
|
Gtk::FileChooserDialog* m_poFileOpenDialog;
|
||||||
|
|
||||||
ScreenArea *m_poScreenArea;
|
ScreenArea* m_poScreenArea;
|
||||||
Gtk::CheckMenuItem *m_poFilePauseItem;
|
Gtk::CheckMenuItem* m_poFilePauseItem;
|
||||||
Gtk::MenuBar *m_poMenuBar;
|
Gtk::MenuBar* m_poMenuBar;
|
||||||
|
|
||||||
struct SGameSlot {
|
struct SGameSlot {
|
||||||
bool m_bEmpty;
|
bool m_bEmpty;
|
||||||
std::string m_sFile;
|
std::string m_sFile;
|
||||||
time_t m_uiTime;
|
time_t m_uiTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SJoypadKey {
|
struct SJoypadKey {
|
||||||
const char *m_csKey;
|
const char* m_csKey;
|
||||||
const EKey m_eKeyFlag;
|
const EKey m_eKeyFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SJoypadKey m_astJoypad[];
|
static const SJoypadKey m_astJoypad[];
|
||||||
|
|
||||||
Gtk::MenuItem *m_apoLoadGameItem[10];
|
Gtk::MenuItem* m_apoLoadGameItem[10];
|
||||||
Gtk::MenuItem *m_apoSaveGameItem[10];
|
Gtk::MenuItem* m_apoSaveGameItem[10];
|
||||||
SGameSlot m_astGameSlot[10];
|
SGameSlot m_astGameSlot[10];
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::RecentManager> m_poRecentManager;
|
Glib::RefPtr<Gtk::RecentManager> m_poRecentManager;
|
||||||
Gtk::MenuItem *m_poRecentMenu;
|
Gtk::MenuItem* m_poRecentMenu;
|
||||||
Gtk::RecentChooserMenu *m_poRecentChooserMenu;
|
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_bFullscreen;
|
||||||
int m_iScreenWidth;
|
int m_iScreenWidth;
|
||||||
int m_iScreenHeight;
|
int m_iScreenHeight;
|
||||||
int m_iFrameCount;
|
int m_iFrameCount;
|
||||||
|
|
||||||
std::string m_sRomFile;
|
std::string m_sRomFile;
|
||||||
ECartridge m_eCartridge;
|
ECartridge m_eCartridge;
|
||||||
EmulatedSystem m_stEmulator;
|
EmulatedSystem m_stEmulator;
|
||||||
bool m_bPaused;
|
bool m_bPaused;
|
||||||
bool m_bWasEmulating;
|
bool m_bWasEmulating;
|
||||||
bool m_bAutoFrameskip;
|
bool m_bAutoFrameskip;
|
||||||
EShowSpeed m_eShowSpeed;
|
EShowSpeed m_eShowSpeed;
|
||||||
|
|
||||||
/* State saving into memory & rewind to saved state */
|
/* State saving into memory & rewind to saved state */
|
||||||
u16 m_state_count_max;
|
u16 m_state_count_max;
|
||||||
u16 m_rewind_interval;
|
u16 m_rewind_interval;
|
||||||
static const u32 SZSTATE = 1024 * 512;
|
static const u32 SZSTATE = 1024 * 512;
|
||||||
std::deque<char *> m_rewind_load_q;
|
std::deque<char*> m_rewind_load_q;
|
||||||
char *m_psavestate;
|
char* m_psavestate;
|
||||||
|
|
||||||
void vInitSystem();
|
void vInitSystem();
|
||||||
void vUnInitSystem();
|
void vUnInitSystem();
|
||||||
void vInitSDL();
|
void vInitSDL();
|
||||||
void vInitConfig();
|
void vInitConfig();
|
||||||
void vCheckConfig();
|
void vCheckConfig();
|
||||||
void vInitColors(EColorFormat _eColorFormat);
|
void vInitColors(EColorFormat _eColorFormat);
|
||||||
void vLoadConfig(const std::string &_rsFile);
|
void vLoadConfig(const std::string& _rsFile);
|
||||||
void vSaveConfig(const std::string &_rsFile);
|
void vSaveConfig(const std::string& _rsFile);
|
||||||
void vHistoryAdd(const std::string &_rsFile);
|
void vHistoryAdd(const std::string& _rsFile);
|
||||||
void vApplyConfigJoypads();
|
void vApplyConfigJoypads();
|
||||||
void vSaveJoypadsToConfig();
|
void vSaveJoypadsToConfig();
|
||||||
void vDrawDefaultScreen();
|
void vDrawDefaultScreen();
|
||||||
void vSetDefaultTitle();
|
void vSetDefaultTitle();
|
||||||
void vCreateFileOpenDialog();
|
void vCreateFileOpenDialog();
|
||||||
void vLoadBattery();
|
void vLoadBattery();
|
||||||
void vLoadCheats();
|
void vLoadCheats();
|
||||||
void vSaveBattery();
|
void vSaveBattery();
|
||||||
void vSaveCheats();
|
void vSaveCheats();
|
||||||
void vStartEmu();
|
void vStartEmu();
|
||||||
void vStopEmu();
|
void vStopEmu();
|
||||||
void vUpdateGameSlots();
|
void vUpdateGameSlots();
|
||||||
void vToggleFullscreen();
|
void vToggleFullscreen();
|
||||||
void vSDLPollEvents();
|
void vSDLPollEvents();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,8 +15,8 @@
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "libretro.h"
|
|
||||||
#include "SoundRetro.h"
|
#include "SoundRetro.h"
|
||||||
|
#include "libretro.h"
|
||||||
unsigned g_audio_frames;
|
unsigned g_audio_frames;
|
||||||
extern retro_audio_sample_batch_t audio_batch_cb;
|
extern retro_audio_sample_batch_t audio_batch_cb;
|
||||||
|
|
||||||
|
@ -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;
|
const int16_t* wave = (const int16_t*)finalWave;
|
||||||
int frames = length >> 1;
|
int frames = length >> 1;
|
||||||
audio_batch_cb(wave, frames);
|
audio_batch_cb(wave, frames);
|
||||||
|
|
||||||
g_audio_frames += frames;
|
g_audio_frames += frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SoundRetro::init(long sampleRate)
|
bool SoundRetro::init(long sampleRate)
|
||||||
{
|
{
|
||||||
g_audio_frames = 0;
|
g_audio_frames = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundRetro::~SoundRetro()
|
SoundRetro::~SoundRetro()
|
||||||
|
|
|
@ -20,17 +20,16 @@
|
||||||
|
|
||||||
#include "../common/SoundDriver.h"
|
#include "../common/SoundDriver.h"
|
||||||
|
|
||||||
class SoundRetro : public SoundDriver
|
class SoundRetro : public SoundDriver {
|
||||||
{
|
public:
|
||||||
public:
|
SoundRetro();
|
||||||
SoundRetro();
|
virtual ~SoundRetro();
|
||||||
virtual ~SoundRetro();
|
|
||||||
|
|
||||||
virtual bool init(long sampleRate);
|
virtual bool init(long sampleRate);
|
||||||
virtual void pause();
|
virtual void pause();
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
virtual void resume();
|
virtual void resume();
|
||||||
virtual void write(u16 *finalWave, int length);
|
virtual void write(u16* finalWave, int length);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __VBA_SOUND_RETRO_H__
|
#endif // __VBA_SOUND_RETRO_H__
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "System.h"
|
|
||||||
#include "NLS.h"
|
#include "NLS.h"
|
||||||
|
#include "System.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include "common/Port.h"
|
||||||
#include "gba/Flash.h"
|
#include "gba/Flash.h"
|
||||||
#include "gba/GBA.h"
|
#include "gba/GBA.h"
|
||||||
#include "gba/Globals.h"
|
#include "gba/Globals.h"
|
||||||
#include "gba/RTC.h"
|
#include "gba/RTC.h"
|
||||||
#include "common/Port.h"
|
|
||||||
|
|
||||||
#include "gba/gbafilter.h"
|
|
||||||
#include "gb/gbGlobals.h"
|
#include "gb/gbGlobals.h"
|
||||||
|
#include "gba/gbafilter.h"
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -27,259 +27,242 @@ extern int systemBlueShift;
|
||||||
extern uint16_t systemColorMap16[0x10000];
|
extern uint16_t systemColorMap16[0x10000];
|
||||||
extern uint32_t systemColorMap32[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 & 255;
|
||||||
*p++ = (value >> 8) & 255;
|
*p++ = (value >> 8) & 255;
|
||||||
*p++ = (value >> 16) & 255;
|
*p++ = (value >> 16) & 255;
|
||||||
*p = (value >> 24) & 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 & 255;
|
||||||
*p = (value >> 8) & 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;
|
extern bool cpuIsMultiBoot;
|
||||||
|
|
||||||
bool utilIsGBAImage(const char * file)
|
bool utilIsGBAImage(const char* file)
|
||||||
{
|
{
|
||||||
cpuIsMultiBoot = false;
|
cpuIsMultiBoot = false;
|
||||||
if(strlen(file) > 4) {
|
if (strlen(file) > 4) {
|
||||||
const char * p = strrchr(file,'.');
|
const char* p = strrchr(file, '.');
|
||||||
|
|
||||||
if(p != NULL) {
|
if (p != NULL) {
|
||||||
if((_stricmp(p, ".agb") == 0) ||
|
if ((_stricmp(p, ".agb") == 0) || (_stricmp(p, ".gba") == 0) || (_stricmp(p, ".bin") == 0) || (_stricmp(p, ".elf") == 0))
|
||||||
(_stricmp(p, ".gba") == 0) ||
|
return true;
|
||||||
(_stricmp(p, ".bin") == 0) ||
|
if (_stricmp(p, ".mb") == 0) {
|
||||||
(_stricmp(p, ".elf") == 0))
|
cpuIsMultiBoot = true;
|
||||||
return true;
|
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) {
|
if (strlen(file) > 4) {
|
||||||
const char * p = strrchr(file,'.');
|
const char* p = strrchr(file, '.');
|
||||||
|
|
||||||
if(p != NULL) {
|
if (p != NULL) {
|
||||||
if((_stricmp(p, ".dmg") == 0) ||
|
if ((_stricmp(p, ".dmg") == 0) || (_stricmp(p, ".gb") == 0) || (_stricmp(p, ".gbc") == 0) || (_stricmp(p, ".cgb") == 0) || (_stricmp(p, ".sgb") == 0))
|
||||||
(_stricmp(p, ".gb") == 0) ||
|
return true;
|
||||||
(_stricmp(p, ".gbc") == 0) ||
|
}
|
||||||
(_stricmp(p, ".cgb") == 0) ||
|
|
||||||
(_stricmp(p, ".sgb") == 0))
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip .gz or .z off end
|
// 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
|
if (buffer != file) // allows conversion in place
|
||||||
strcpy(buffer, file);
|
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];
|
char buffer[2048];
|
||||||
if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead?
|
if (!utilIsImage(file)) // TODO: utilIsArchive() instead?
|
||||||
{
|
{
|
||||||
return IMAGE_UNKNOWN;
|
return IMAGE_UNKNOWN;
|
||||||
}
|
}
|
||||||
return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB;
|
return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int utilGetSize(int size)
|
static int utilGetSize(int size)
|
||||||
{
|
{
|
||||||
int res = 1;
|
int res = 1;
|
||||||
while(res < size)
|
while (res < size)
|
||||||
res <<= 1;
|
res <<= 1;
|
||||||
return res;
|
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;
|
FILE* fp = NULL;
|
||||||
char *buf = NULL;
|
char* buf = NULL;
|
||||||
|
|
||||||
fp = fopen(file,"rb");
|
fp = fopen(file, "rb");
|
||||||
fseek(fp, 0, SEEK_END); //go to end
|
fseek(fp, 0, SEEK_END); //go to end
|
||||||
size = ftell(fp); // get position at end (length)
|
size = ftell(fp); // get position at end (length)
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
|
|
||||||
uint8_t *image = data;
|
uint8_t* image = data;
|
||||||
if(image == NULL)
|
if (image == NULL) {
|
||||||
{
|
//allocate buffer memory if none was passed to the function
|
||||||
//allocate buffer memory if none was passed to the function
|
image = (uint8_t*)malloc(utilGetSize(size));
|
||||||
image = (uint8_t *)malloc(utilGetSize(size));
|
if (image == NULL) {
|
||||||
if(image == NULL)
|
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
|
||||||
{
|
"data");
|
||||||
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
|
return NULL;
|
||||||
"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;
|
|
||||||
}
|
}
|
||||||
} 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);
|
fread(image, 1, size, fp); // read into buffer
|
||||||
cpuSaveType = saveType;
|
fclose(fp);
|
||||||
flashSetSize(flashSize);
|
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)
|
void utilUpdateSystemColorMaps(bool lcd)
|
||||||
{
|
{
|
||||||
switch(systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 16:
|
case 16: {
|
||||||
{
|
for (int i = 0; i < 0x10000; i++) {
|
||||||
for(int i = 0; i < 0x10000; i++) {
|
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
|
||||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
}
|
||||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
if (lcd)
|
||||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
gbafilter_pal(systemColorMap16, 0x10000);
|
||||||
}
|
} break;
|
||||||
if (lcd) gbafilter_pal(systemColorMap16, 0x10000);
|
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.
|
// Check for existence of file.
|
||||||
bool utilFileExists( const char *filename )
|
bool utilFileExists(const char* filename)
|
||||||
{
|
{
|
||||||
FILE *f = fopen( filename, "r" );
|
FILE* f = fopen(filename, "r");
|
||||||
if( f == NULL ) {
|
if (f == NULL) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
fclose( f );
|
fclose(f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not endian safe, but VBA itself doesn't seem to care, so hey <_<
|
// 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));
|
memcpy(data, &val, sizeof(int));
|
||||||
data += 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);
|
memcpy(data, in_data, size);
|
||||||
data += size;
|
data += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void utilWriteDataMem(uint8_t *& data, variable_desc *desc)
|
void utilWriteDataMem(uint8_t*& data, variable_desc* desc)
|
||||||
{
|
{
|
||||||
while (desc->address)
|
while (desc->address) {
|
||||||
{
|
utilWriteMem(data, desc->address, desc->size);
|
||||||
utilWriteMem(data, desc->address, desc->size);
|
desc++;
|
||||||
desc++;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int utilReadIntMem(const uint8_t *& data)
|
int utilReadIntMem(const uint8_t*& data)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
memcpy(&res, data, sizeof(int));
|
memcpy(&res, data, sizeof(int));
|
||||||
data += sizeof(int);
|
data += sizeof(int);
|
||||||
return res;
|
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);
|
memcpy(buf, data, size);
|
||||||
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)
|
while (desc->address) {
|
||||||
{
|
utilReadMem(desc->address, data, desc->size);
|
||||||
utilReadMem(desc->address, data, desc->size);
|
desc++;
|
||||||
desc++;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,191 +8,194 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
enum save_type { EEPROM_512B, EEPROM_8K, FLASH_64K, FLASH_128K, SAVE_UNKNOWN };
|
enum save_type { EEPROM_512B,
|
||||||
|
EEPROM_8K,
|
||||||
|
FLASH_64K,
|
||||||
|
FLASH_128K,
|
||||||
|
SAVE_UNKNOWN };
|
||||||
|
|
||||||
static const char *save_type_to_string(enum save_type type)
|
static const char* save_type_to_string(enum save_type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EEPROM_512B:
|
case EEPROM_512B:
|
||||||
return "EEPROM 4kbit";
|
return "EEPROM 4kbit";
|
||||||
case EEPROM_8K:
|
case EEPROM_8K:
|
||||||
return "EEPROM 64kbit";
|
return "EEPROM 64kbit";
|
||||||
case FLASH_64K:
|
case FLASH_64K:
|
||||||
return "FLASH 512kbit";
|
return "FLASH 512kbit";
|
||||||
case FLASH_128K:
|
case FLASH_128K:
|
||||||
return "FLASH 1MBit";
|
return "FLASH 1MBit";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "Unknown type";
|
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++) {
|
for (unsigned i = 0; i < size; i++) {
|
||||||
if (data[i] != 0xff)
|
if (data[i] != 0xff)
|
||||||
return true;
|
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)
|
if (size == 512)
|
||||||
return EEPROM_512B;
|
return EEPROM_512B;
|
||||||
if (size == 0x2000)
|
if (size == 0x2000)
|
||||||
return EEPROM_8K;
|
return EEPROM_8K;
|
||||||
if (size == 0x10000)
|
if (size == 0x10000)
|
||||||
return FLASH_64K;
|
return FLASH_64K;
|
||||||
if (size == 0x20000)
|
if (size == 0x20000)
|
||||||
return FLASH_128K;
|
return FLASH_128K;
|
||||||
|
|
||||||
if (size == (0x20000 + 0x2000)) {
|
if (size == (0x20000 + 0x2000)) {
|
||||||
if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000))
|
if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000))
|
||||||
return FLASH_64K;
|
return FLASH_64K;
|
||||||
if (scan_section(data, 0x20000))
|
if (scan_section(data, 0x20000))
|
||||||
return FLASH_128K;
|
return FLASH_128K;
|
||||||
|
|
||||||
if (scan_section(data + 0x20000, 512) &&
|
if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512))
|
||||||
!scan_section(data + 0x20000 + 512, 0x20000 - 512))
|
return EEPROM_512B;
|
||||||
return EEPROM_512B;
|
if (scan_section(data + 0x20000, 0x2000))
|
||||||
if (scan_section(data + 0x20000, 0x2000))
|
return EEPROM_8K;
|
||||||
return EEPROM_8K;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
void* buf = malloc(0x20000 + 0x2000);
|
||||||
memset(buf, 0xff, 0x20000 + 0x2000);
|
memset(buf, 0xff, 0x20000 + 0x2000);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EEPROM_512B:
|
case EEPROM_512B:
|
||||||
fwrite(buf, 1, 0x20000, file);
|
fwrite(buf, 1, 0x20000, file);
|
||||||
fwrite(data, 1, 512, file);
|
fwrite(data, 1, 512, file);
|
||||||
fwrite(buf, 1, 0x2000 - 512, file);
|
fwrite(buf, 1, 0x2000 - 512, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EEPROM_8K:
|
case EEPROM_8K:
|
||||||
fwrite(buf, 1, 0x20000, file);
|
fwrite(buf, 1, 0x20000, file);
|
||||||
fwrite(data, 1, 0x2000, file);
|
fwrite(data, 1, 0x2000, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLASH_64K:
|
case FLASH_64K:
|
||||||
fwrite(data, 1, 0x10000, file);
|
fwrite(data, 1, 0x10000, file);
|
||||||
fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file);
|
fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLASH_128K:
|
case FLASH_128K:
|
||||||
fwrite(data, 1, 0x20000, file);
|
fwrite(data, 1, 0x20000, file);
|
||||||
fwrite(buf, 1, 0x2000, file);
|
fwrite(buf, 1, 0x2000, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
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) {
|
switch (type) {
|
||||||
case EEPROM_512B:
|
case EEPROM_512B:
|
||||||
fwrite(data + 0x20000, 1, 512, file);
|
fwrite(data + 0x20000, 1, 512, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EEPROM_8K:
|
case EEPROM_8K:
|
||||||
fwrite(data + 0x20000, 1, 0x2000, file);
|
fwrite(data + 0x20000, 1, 0x2000, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLASH_64K:
|
case FLASH_64K:
|
||||||
fwrite(data, 1, 0x10000, file);
|
fwrite(data, 1, 0x10000, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLASH_128K:
|
case FLASH_128K:
|
||||||
fwrite(data, 1, 0x20000, file);
|
fwrite(data, 1, 0x20000, file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// One shot cowboy code :)
|
// One shot cowboy code :)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *file = fopen(argv[1], "rb");
|
FILE* file = fopen(argv[1], "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]);
|
fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
long len = ftell(file);
|
long len = ftell(file);
|
||||||
rewind(file);
|
rewind(file);
|
||||||
|
|
||||||
uint8_t *buffer = malloc(len);
|
uint8_t* buffer = malloc(len);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
fprintf(stderr, "Failed to allocate memory!\n");
|
fprintf(stderr, "Failed to allocate memory!\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
fread(buffer, 1, len, file);
|
fread(buffer, 1, len, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
file = NULL;
|
file = NULL;
|
||||||
|
|
||||||
char *out_path = strdup(argv[1]);
|
char* out_path = strdup(argv[1]);
|
||||||
char *split = strrchr(out_path, '.');
|
char* split = strrchr(out_path, '.');
|
||||||
const char *ext = NULL;
|
const char* ext = NULL;
|
||||||
|
|
||||||
if (split) {
|
if (split) {
|
||||||
*split = '\0';
|
*split = '\0';
|
||||||
ext = split + 1;
|
ext = split + 1;
|
||||||
|
|
||||||
if (strcasecmp(ext, "srm") == 0)
|
if (strcasecmp(ext, "srm") == 0)
|
||||||
strcat(out_path, ".sav");
|
strcat(out_path, ".sav");
|
||||||
else if (strlen(ext) >= 3)
|
else if (strlen(ext) >= 3)
|
||||||
strcat(out_path, ".srm");
|
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);
|
|
||||||
else
|
else
|
||||||
dump_srm(file, buffer, type);
|
ext = NULL;
|
||||||
fclose(file);
|
}
|
||||||
|
|
||||||
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:
|
error:
|
||||||
if (file)
|
if (file)
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,78 +6,85 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const unsigned long crc_table[256] = {
|
static const unsigned long crc_table[256] = {
|
||||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||||
0x2d02ef8dL
|
0x2d02ef8dL
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
||||||
#define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf);
|
#define DO2_CRC32(buf) \
|
||||||
#define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf);
|
DO1_CRC32(buf); \
|
||||||
#define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf);
|
DO1_CRC32(buf);
|
||||||
|
#define DO4_CRC32(buf) \
|
||||||
|
DO2_CRC32(buf); \
|
||||||
|
DO2_CRC32(buf);
|
||||||
|
#define DO8_CRC32(buf) \
|
||||||
|
DO4_CRC32(buf); \
|
||||||
|
DO4_CRC32(buf);
|
||||||
|
|
||||||
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len)
|
unsigned long crc32(unsigned long crc, const unsigned char* buf, unsigned int len)
|
||||||
{
|
{
|
||||||
if (buf == 0) return 0L;
|
if (buf == 0)
|
||||||
crc = crc ^ 0xffffffffL;
|
return 0L;
|
||||||
while (len >= 8)
|
crc = crc ^ 0xffffffffL;
|
||||||
{
|
while (len >= 8) {
|
||||||
DO8_CRC32(buf);
|
DO8_CRC32(buf);
|
||||||
len -= 8;
|
len -= 8;
|
||||||
}
|
}
|
||||||
if (len) do {
|
if (len)
|
||||||
DO1_CRC32(buf);
|
do {
|
||||||
} while (--len);
|
DO1_CRC32(buf);
|
||||||
return crc ^ 0xffffffffL;
|
} while (--len);
|
||||||
|
return crc ^ 0xffffffffL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -85,4 +92,3 @@ unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int le
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
3169
src/sdl/SDL.cpp
3169
src/sdl/SDL.cpp
File diff suppressed because it is too large
Load Diff
4595
src/sdl/debugger.cpp
4595
src/sdl/debugger.cpp
File diff suppressed because it is too large
Load Diff
|
@ -18,5 +18,5 @@
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
extern void debuggerMain();
|
extern void debuggerMain();
|
||||||
extern void debuggerOutput(const char *, u32);
|
extern void debuggerOutput(const char*, u32);
|
||||||
extern void debuggerSignal(int, int);
|
extern void debuggerSignal(int, int);
|
||||||
|
|
1696
src/sdl/expr-lex.cpp
1696
src/sdl/expr-lex.cpp
File diff suppressed because it is too large
Load Diff
1798
src/sdl/expr.cpp
1798
src/sdl/expr.cpp
File diff suppressed because it is too large
Load Diff
|
@ -39,13 +39,13 @@
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
know about them. */
|
know about them. */
|
||||||
enum yytokentype {
|
enum yytokentype {
|
||||||
TOKEN_IDENTIFIER = 258,
|
TOKEN_IDENTIFIER = 258,
|
||||||
TOKEN_DOT = 259,
|
TOKEN_DOT = 259,
|
||||||
TOKEN_STAR = 260,
|
TOKEN_STAR = 260,
|
||||||
TOKEN_ARROW = 261,
|
TOKEN_ARROW = 261,
|
||||||
TOKEN_ADDR = 262,
|
TOKEN_ADDR = 262,
|
||||||
TOKEN_SIZEOF = 263,
|
TOKEN_SIZEOF = 263,
|
||||||
TOKEN_NUMBER = 264
|
TOKEN_NUMBER = 264
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
|
|
|
@ -16,400 +16,396 @@
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../common/Port.h"
|
||||||
#include "../gba/GBA.h"
|
#include "../gba/GBA.h"
|
||||||
#include "../gba/elf.h"
|
#include "../gba/elf.h"
|
||||||
#include "../common/Port.h"
|
|
||||||
#include "exprNode.h"
|
#include "exprNode.h"
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *yytext;
|
extern char* yytext;
|
||||||
|
|
||||||
#define debuggerReadMemory(addr) \
|
#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;
|
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()
|
void exprNodeCleanUp()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < exprNodeCleanUpCount; i++) {
|
for (int i = 0; i < exprNodeCleanUpCount; i++) {
|
||||||
free((void *)exprNodeCleanUpList[i]);
|
free((void*)exprNodeCleanUpList[i]);
|
||||||
}
|
}
|
||||||
exprNodeCleanUpCount = 0;
|
exprNodeCleanUpCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeIdentifier()
|
Node* exprNodeIdentifier()
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
n->name = strdup(yytext);
|
n->name = strdup(yytext);
|
||||||
|
|
||||||
exprNodeClean(n->name);
|
exprNodeClean(n->name);
|
||||||
exprNodeClean(n);
|
exprNodeClean(n);
|
||||||
|
|
||||||
n->print = exprNodeIdentifierPrint;
|
n->print = exprNodeIdentifierPrint;
|
||||||
n->resolve = exprNodeIdentifierResolve;
|
n->resolve = exprNodeIdentifierResolve;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeIdentifierResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeIdentifierResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
Object *o;
|
Object* o;
|
||||||
if(elfGetObject(n->name, f, u, &o)) {
|
if (elfGetObject(n->name, f, u, &o)) {
|
||||||
n->type = o->type;
|
n->type = o->type;
|
||||||
n->location = elfDecodeLocation(f, o->location, &n->locType);
|
n->location = elfDecodeLocation(f, o->location, &n->locType);
|
||||||
return true;
|
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;
|
|
||||||
} else {
|
} 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("*");
|
printf("%s", n->name);
|
||||||
n->expression->print(n->expression);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeDot(Node *exp, Node *ident)
|
Node* exprNodeNumber()
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
exprNodeClean(n);
|
|
||||||
|
|
||||||
n->expression = exp;
|
exprNodeClean(n);
|
||||||
n->name = ident->name;
|
n->location = atoi(yytext);
|
||||||
|
|
||||||
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;
|
|
||||||
n->type = &exprNodeType;
|
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 true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeSizeofPrint(Node *n)
|
void exprNodeNumberPrint(Node* n)
|
||||||
{
|
{
|
||||||
printf("sizeof(");
|
printf("%d", n->location);
|
||||||
n->expression->print(n->expression);
|
|
||||||
printf(")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeArray(Node *exp, Node *number)
|
Node* exprNodeStar(Node* exp)
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
exprNodeClean(n);
|
exprNodeClean(n);
|
||||||
|
|
||||||
n->expression = exp;
|
n->expression = exp;
|
||||||
n->value = number->location;
|
|
||||||
|
|
||||||
n->print = exprNodeArrayPrint;
|
n->print = exprNodeStarPrint;
|
||||||
n->resolve = exprNodeArrayResolve;
|
n->resolve = exprNodeStarResolve;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int exprNodeGetSize(Array *a, int index)
|
bool exprNodeStarResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
index++;
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
if(index == a->maxBounds) {
|
if (n->expression->type->type == TYPE_pointer) {
|
||||||
return a->type->size;
|
n->location = n->expression->location;
|
||||||
} else {
|
if (n->expression->locType == LOCATION_memory) {
|
||||||
int size = a->bounds[a->maxBounds-1] * a->type->size;
|
n->location = debuggerReadMemory(n->location);
|
||||||
|
} else if (n->expression->locType == LOCATION_register) {
|
||||||
for(int i = index; i < a->maxBounds-1; i++) {
|
n->location = reg[n->expression->location].I;
|
||||||
size *= a->bounds[i];
|
} else {
|
||||||
}
|
n->location = n->expression->location;
|
||||||
return size;
|
}
|
||||||
}
|
n->type = n->expression->type->pointer;
|
||||||
}
|
n->locType = LOCATION_memory;
|
||||||
|
return true;
|
||||||
bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
|
} else {
|
||||||
{
|
printf("Object is not of pointer type\n");
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if((index+1) < a->maxBounds) {
|
void exprNodeStarPrint(Node* n)
|
||||||
n->type = n->expression->type;
|
{
|
||||||
n->index = index+1;
|
printf("*");
|
||||||
n->locType = LOCATION_memory;
|
n->expression->print(n->expression);
|
||||||
n->location = n->expression->location +
|
}
|
||||||
n->value * exprNodeGetSize(a, index);
|
|
||||||
return true;
|
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;
|
return false;
|
||||||
n->location = loc + n->value * t->size;
|
}
|
||||||
n->locType = LOCATION_memory;
|
|
||||||
|
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 {
|
} else {
|
||||||
Type *t = n->expression->type->pointer;
|
int size = a->bounds[a->maxBounds - 1] * a->type->size;
|
||||||
u32 loc = n->expression->location;
|
|
||||||
if(n->expression->locType == LOCATION_register)
|
for (int i = index; i < a->maxBounds - 1; i++) {
|
||||||
loc = reg[loc].I;
|
size *= a->bounds[i];
|
||||||
else
|
}
|
||||||
loc = debuggerReadMemory(loc);
|
return size;
|
||||||
n->type = t;
|
|
||||||
n->location = loc + n->value * t->size;
|
|
||||||
n->locType = LOCATION_memory;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeArrayPrint(Node *n)
|
bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
n->expression->print(n->expression);
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
printf("[%d]", n->value);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,51 +18,51 @@
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
struct Node {
|
struct Node {
|
||||||
Type *type;
|
Type* type;
|
||||||
u32 location;
|
u32 location;
|
||||||
u32 objLocation;
|
u32 objLocation;
|
||||||
LocationType locType;
|
LocationType locType;
|
||||||
int value;
|
int value;
|
||||||
int index;
|
int index;
|
||||||
const char *name;
|
const char* name;
|
||||||
Node *expression;
|
Node* expression;
|
||||||
Member *member;
|
Member* member;
|
||||||
void (*print)(Node *);
|
void (*print)(Node*);
|
||||||
bool (*resolve)(Node *, Function *f, CompileUnit *u);
|
bool (*resolve)(Node*, Function* f, CompileUnit* u);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void exprNodeCleanUp();
|
extern void exprNodeCleanUp();
|
||||||
|
|
||||||
extern Node *exprNodeIdentifier();
|
extern Node* exprNodeIdentifier();
|
||||||
extern void exprNodeIdentifierPrint(Node *);
|
extern void exprNodeIdentifierPrint(Node*);
|
||||||
extern bool exprNodeIdentifierResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeIdentifierResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeNumber();
|
extern Node* exprNodeNumber();
|
||||||
extern void exprNodeNumberPrint(Node *);
|
extern void exprNodeNumberPrint(Node*);
|
||||||
extern bool exprNodeNumberResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeNumberResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeStar(Node *);
|
extern Node* exprNodeStar(Node*);
|
||||||
extern void exprNodeStarPrint(Node *);
|
extern void exprNodeStarPrint(Node*);
|
||||||
extern bool exprNodeStarResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeStarResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeDot(Node *, Node *);
|
extern Node* exprNodeDot(Node*, Node*);
|
||||||
extern void exprNodeDotPrint(Node *);
|
extern void exprNodeDotPrint(Node*);
|
||||||
extern bool exprNodeDotResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeDotResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeArrow(Node *, Node *);
|
extern Node* exprNodeArrow(Node*, Node*);
|
||||||
extern void exprNodeArrowPrint(Node *);
|
extern void exprNodeArrowPrint(Node*);
|
||||||
extern bool exprNodeArrowResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeArrowResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeAddr(Node *);
|
extern Node* exprNodeAddr(Node*);
|
||||||
extern void exprNodeAddrPrint(Node *);
|
extern void exprNodeAddrPrint(Node*);
|
||||||
extern bool exprNodeAddrResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeAddrResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeSizeof(Node *);
|
extern Node* exprNodeSizeof(Node*);
|
||||||
extern void exprNodeSizeofPrint(Node *);
|
extern void exprNodeSizeofPrint(Node*);
|
||||||
extern bool exprNodeSizeofResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeSizeofResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
extern Node *exprNodeArray(Node *, Node *);
|
extern Node* exprNodeArray(Node*, Node*);
|
||||||
extern void exprNodeArrayPrint(Node *);
|
extern void exprNodeArrayPrint(Node*);
|
||||||
extern bool exprNodeArrayResolve(Node *, Function *, CompileUnit *);
|
extern bool exprNodeArrayResolve(Node*, Function*, CompileUnit*);
|
||||||
|
|
||||||
#define YYSTYPE struct Node *
|
#define YYSTYPE struct Node*
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,33 +27,33 @@
|
||||||
|
|
||||||
// List of available filters
|
// List of available filters
|
||||||
enum Filter {
|
enum Filter {
|
||||||
kStretch1x,
|
kStretch1x,
|
||||||
kStretch2x,
|
kStretch2x,
|
||||||
k2xSaI,
|
k2xSaI,
|
||||||
kSuper2xSaI,
|
kSuper2xSaI,
|
||||||
kSuperEagle,
|
kSuperEagle,
|
||||||
kPixelate,
|
kPixelate,
|
||||||
kAdMame2x,
|
kAdMame2x,
|
||||||
kBilinear,
|
kBilinear,
|
||||||
kBilinearPlus,
|
kBilinearPlus,
|
||||||
kScanlines,
|
kScanlines,
|
||||||
kScanlinesTV,
|
kScanlinesTV,
|
||||||
klq2x,
|
klq2x,
|
||||||
khq2x,
|
khq2x,
|
||||||
xbrz2x,
|
xbrz2x,
|
||||||
kStretch3x,
|
kStretch3x,
|
||||||
khq3x,
|
khq3x,
|
||||||
xbrz3x,
|
xbrz3x,
|
||||||
kStretch4x,
|
kStretch4x,
|
||||||
khq4x,
|
khq4x,
|
||||||
xbrz4x,
|
xbrz4x,
|
||||||
xbrz5x,
|
xbrz5x,
|
||||||
xbrz6x,
|
xbrz6x,
|
||||||
kInvalidFilter
|
kInvalidFilter
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function pointer type for a filter function
|
// 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
|
// Initialize a filter and get the corresponding filter function pointer
|
||||||
FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth);
|
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);
|
int getFilterEnlargeFactor(const int f);
|
||||||
|
|
||||||
// Get the display name for a filter
|
// Get the display name for a filter
|
||||||
char *getFilterName(const int f);
|
char* getFilterName(const int f);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Interframe filters
|
// Interframe filters
|
||||||
//
|
//
|
||||||
|
|
||||||
// List of available IFB filters
|
// List of available IFB filters
|
||||||
enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter };
|
enum IFBFilter { kIFBNone,
|
||||||
|
kIBMotionBlur,
|
||||||
|
kIBSmart,
|
||||||
|
kInvalidIFBFilter };
|
||||||
|
|
||||||
// Function pointer type for an IFB filter function
|
// Function pointer type for an IFB filter function
|
||||||
typedef void (*IFBFilterFunc)(u8 *, u32, int, int);
|
typedef void (*IFBFilterFunc)(u8*, u32, int, int);
|
||||||
|
|
||||||
// Initialize an IFB filter and get the corresponding filter function pointer
|
// Initialize an IFB filter and get the corresponding filter function pointer
|
||||||
IFBFilterFunc initIFBFilter(const int f, const int colorDepth);
|
IFBFilterFunc initIFBFilter(const int f, const int colorDepth);
|
||||||
|
|
||||||
// Get the display name for an IFB filter
|
// Get the display name for an IFB filter
|
||||||
char *getIFBFilterName(const IFBFilter f);
|
char* getIFBFilterName(const IFBFilter f);
|
||||||
|
|
||||||
#endif // VBA_SDL_FILTERS_H
|
#endif // VBA_SDL_FILTERS_H
|
||||||
|
|
1029
src/sdl/getopt.c
1029
src/sdl/getopt.c
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
Also, when `ordering' is RETURN_IN_ORDER,
|
||||||
each non-option ARGV-element is returned here. */
|
each non-option ARGV-element is returned here. */
|
||||||
|
|
||||||
extern char *optarg;
|
extern char* optarg;
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
/* Index in ARGV of the next element to be scanned.
|
||||||
This is used for communication to and from the caller
|
This is used for communication to and from the caller
|
||||||
|
@ -81,15 +81,15 @@ extern int optopt;
|
||||||
|
|
||||||
struct option {
|
struct option {
|
||||||
#if defined(__STDC__) && __STDC__
|
#if defined(__STDC__) && __STDC__
|
||||||
const char *name;
|
const char* name;
|
||||||
#else
|
#else
|
||||||
char *name;
|
char* name;
|
||||||
#endif
|
#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. */
|
type mismatches in all the code that assumes it is an int. */
|
||||||
int has_arg;
|
int has_arg;
|
||||||
int *flag;
|
int* flag;
|
||||||
int val;
|
int val;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
/* 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
|
/* Many other libraries have conflicting prototypes for getopt, with
|
||||||
differences in the consts, in stdlib.h. To avoid compilation
|
differences in the consts, in stdlib.h. To avoid compilation
|
||||||
errors, only prototype getopt for the GNU C library. */
|
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__ */
|
#else /* not __GNU_LIBRARY__ */
|
||||||
#if !defined(HAVE_DECL_GETOPT)
|
#if !defined(HAVE_DECL_GETOPT)
|
||||||
extern int getopt();
|
extern int getopt();
|
||||||
#endif
|
#endif
|
||||||
#endif /* __GNU_LIBRARY__ */
|
#endif /* __GNU_LIBRARY__ */
|
||||||
extern int getopt_long(int argc, char *const *argv, const char *shortopts,
|
extern int getopt_long(int argc, char* const* argv, const char* shortopts,
|
||||||
const struct option *longopts, int *longind);
|
const struct option* longopts, int* longind);
|
||||||
extern int getopt_long_only(int argc, char *const *argv, const char *shortopts,
|
extern int getopt_long_only(int argc, char* const* argv, const char* shortopts,
|
||||||
const struct option *longopts, int *longind);
|
const struct option* longopts, int* longind);
|
||||||
|
|
||||||
/* Internal only. Users should not call this directly. */
|
/* Internal only. Users should not call this directly. */
|
||||||
extern int _getopt_internal(int argc, char *const *argv, const char *shortopts,
|
extern int _getopt_internal(int argc, char* const* argv, const char* shortopts,
|
||||||
const struct option *longopts, int *longind, int long_only);
|
const struct option* longopts, int* longind, int long_only);
|
||||||
#else /* not __STDC__ */
|
#else /* not __STDC__ */
|
||||||
extern int getopt();
|
extern int getopt();
|
||||||
extern int getopt_long();
|
extern int getopt_long();
|
||||||
extern int getopt_long_only();
|
extern int getopt_long_only();
|
||||||
|
|
|
@ -65,12 +65,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int getopt_long(argc, argv, options, long_options, opt_index) int argc;
|
int getopt_long(argc, argv, options, long_options, opt_index) int argc;
|
||||||
char *const *argv;
|
char* const* argv;
|
||||||
const char *options;
|
const char* options;
|
||||||
const struct option *long_options;
|
const struct option* long_options;
|
||||||
int *opt_index;
|
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.
|
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||||
|
@ -79,12 +79,12 @@ int *opt_index;
|
||||||
instead. */
|
instead. */
|
||||||
|
|
||||||
int getopt_long_only(argc, argv, options, long_options, opt_index) int argc;
|
int getopt_long_only(argc, argv, options, long_options, opt_index) int argc;
|
||||||
char *const *argv;
|
char* const* argv;
|
||||||
const char *options;
|
const char* options;
|
||||||
const struct option *long_options;
|
const struct option* long_options;
|
||||||
int *opt_index;
|
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. */
|
#endif /* Not ELIDE_CODE. */
|
||||||
|
@ -94,82 +94,82 @@ int *opt_index;
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(argc, argv) int argc;
|
int main(argc, argv) int argc;
|
||||||
char **argv;
|
char** argv;
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int digit_optind = 0;
|
int digit_optind = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int this_option_optind = optind ? optind : 1;
|
int this_option_optind = optind ? optind : 1;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] = { { "add", 1, 0, 0 },
|
static struct option long_options[] = { { "add", 1, 0, 0 },
|
||||||
{ "append", 0, 0, 0 },
|
{ "append", 0, 0, 0 },
|
||||||
{ "delete", 1, 0, 0 },
|
{ "delete", 1, 0, 0 },
|
||||||
{ "verbose", 0, 0, 0 },
|
{ "verbose", 0, 0, 0 },
|
||||||
{ "create", 0, 0, 0 },
|
{ "create", 0, 0, 0 },
|
||||||
{ "file", 1, 0, 0 },
|
{ "file", 1, 0, 0 },
|
||||||
{ 0, 0, 0, 0 } };
|
{ 0, 0, 0, 0 } };
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index);
|
c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0:
|
case 0:
|
||||||
printf("option %s", long_options[option_index].name);
|
printf("option %s", long_options[option_index].name);
|
||||||
if (optarg)
|
if (optarg)
|
||||||
printf(" with arg %s", optarg);
|
printf(" with arg %s", optarg);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
case '5':
|
case '5':
|
||||||
case '6':
|
case '6':
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||||
printf("digits occur in two different argv-elements.\n");
|
printf("digits occur in two different argv-elements.\n");
|
||||||
digit_optind = this_option_optind;
|
digit_optind = this_option_optind;
|
||||||
printf("option %c\n", c);
|
printf("option %c\n", c);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
printf("option a\n");
|
printf("option a\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
printf("option b\n");
|
printf("option b\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
printf("option c with value `%s'\n", optarg);
|
printf("option c with value `%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
printf("option d with value `%s'\n", optarg);
|
printf("option d with value `%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("?? getopt returned character code 0%o ??\n", c);
|
printf("?? getopt returned character code 0%o ??\n", c);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
printf("non-option ARGV-elements: ");
|
printf("non-option ARGV-elements: ");
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
printf("%s ", argv[optind++]);
|
printf("%s ", argv[optind++]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TEST */
|
#endif /* TEST */
|
||||||
|
|
|
@ -27,128 +27,108 @@ static void sdlUpdateJoyAxis(int which, int axis, int value);
|
||||||
static bool sdlCheckJoyKey(int key);
|
static bool sdlCheckJoyKey(int key);
|
||||||
|
|
||||||
static bool sdlButtons[4][SDLBUTTONS_NUM] = {
|
static bool sdlButtons[4][SDLBUTTONS_NUM] = {
|
||||||
{ false, false, false, false, false, false,
|
{ false, false, false, false, false, false,
|
||||||
false, false, false, false, false, false,
|
false, false, false, false, false, false,
|
||||||
false, false
|
false, false },
|
||||||
},
|
{ false, false, false, false, false, false,
|
||||||
{ false, false, false, false, false, false,
|
false, false, false, false, false, false,
|
||||||
false, false, false, false, false, false,
|
false, false },
|
||||||
false, false
|
{ false, false, false, false, false, false,
|
||||||
},
|
false, false, false, false, false, false,
|
||||||
{ false, false, false, false, false, false,
|
false, false },
|
||||||
false, false, false, false, false, false,
|
{ false, false, false, false, false, false,
|
||||||
false, false
|
false, false, false, false, false, false,
|
||||||
},
|
false, false }
|
||||||
{ false, false, false, false, false, false,
|
|
||||||
false, false, false, false, false, false,
|
|
||||||
false, false
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool sdlMotionButtons[4] = { false, false, false, false };
|
static bool sdlMotionButtons[4] = { false, false, false, false };
|
||||||
|
|
||||||
static int sdlNumDevices = 0;
|
static int sdlNumDevices = 0;
|
||||||
static SDL_Joystick **sdlDevices = NULL;
|
static SDL_Joystick** sdlDevices = NULL;
|
||||||
|
|
||||||
static EPad sdlDefaultJoypad = PAD_MAIN;
|
static EPad sdlDefaultJoypad = PAD_MAIN;
|
||||||
|
|
||||||
static int autoFireCountdown = 0;
|
static int autoFireCountdown = 0;
|
||||||
|
|
||||||
static uint32_t joypad[5][SDLBUTTONS_NUM] = {
|
static uint32_t joypad[5][SDLBUTTONS_NUM] = {
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 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_LEFT, SDLK_RIGHT,
|
||||||
SDLK_z, SDLK_x,
|
SDLK_UP, SDLK_DOWN,
|
||||||
SDLK_RETURN,SDLK_BACKSPACE,
|
SDLK_z, SDLK_x,
|
||||||
SDLK_a, SDLK_s,
|
SDLK_RETURN, SDLK_BACKSPACE,
|
||||||
SDLK_SPACE, SDLK_F12,
|
SDLK_a, SDLK_s,
|
||||||
SDLK_q, SDLK_w,
|
SDLK_SPACE, SDLK_F12,
|
||||||
}
|
SDLK_q, SDLK_w,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t motion[4] = {
|
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] = {
|
static uint32_t defaultMotion[4] = {
|
||||||
SDLK_KP_4, SDLK_KP_6, SDLK_KP_8, SDLK_KP_2
|
SDLK_KP_4, SDLK_KP_6, SDLK_KP_8, SDLK_KP_2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint32_t sdlGetHatCode(const SDL_Event& event)
|
||||||
static uint32_t sdlGetHatCode(const SDL_Event &event)
|
|
||||||
{
|
{
|
||||||
if (!event.jhat.value) return 0;
|
if (!event.jhat.value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
((event.jhat.which + 1) << 16) |
|
((event.jhat.which + 1) << 16) | 32 | (event.jhat.hat << 2) | (event.jhat.value & SDL_HAT_UP ? 0 : event.jhat.value & SDL_HAT_DOWN ? 1 : event.jhat.value & SDL_HAT_RIGHT ? 2 : event.jhat.value & SDL_HAT_LEFT ? 3 : 0));
|
||||||
32 |
|
|
||||||
(event.jhat.hat << 2) |
|
|
||||||
(
|
|
||||||
event.jhat.value & SDL_HAT_UP ? 0 :
|
|
||||||
event.jhat.value & SDL_HAT_DOWN ? 1 :
|
|
||||||
event.jhat.value & SDL_HAT_RIGHT ? 2 :
|
|
||||||
event.jhat.value & SDL_HAT_LEFT ? 3 : 0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t sdlGetButtonCode(const SDL_Event &event)
|
static uint32_t sdlGetButtonCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
((event.jbutton.which + 1) << 16) |
|
((event.jbutton.which + 1) << 16) | (event.jbutton.button + 0x80));
|
||||||
(event.jbutton.button + 0x80)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t sdlGetAxisCode(const SDL_Event &event)
|
static uint32_t sdlGetAxisCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384) return 0;
|
if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
((event.jaxis.which + 1) << 16) |
|
((event.jaxis.which + 1) << 16) | (event.jaxis.axis << 1) | (event.jaxis.value > 16384 ? 1 : event.jaxis.value < -16384 ? 0 : 0));
|
||||||
(event.jaxis.axis << 1) |
|
|
||||||
(
|
|
||||||
event.jaxis.value > 16384 ? 1 :
|
|
||||||
event.jaxis.value < -16384 ? 0 : 0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t inputGetEventCode(const SDL_Event &event)
|
uint32_t inputGetEventCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch (event.type) {
|
||||||
{
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYUP:
|
||||||
case SDL_KEYUP:
|
return event.key.keysym.sym;
|
||||||
return event.key.keysym.sym;
|
break;
|
||||||
break;
|
case SDL_JOYHATMOTION:
|
||||||
case SDL_JOYHATMOTION:
|
return sdlGetHatCode(event);
|
||||||
return sdlGetHatCode(event);
|
break;
|
||||||
break;
|
case SDL_JOYBUTTONDOWN:
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_JOYBUTTONUP:
|
||||||
case SDL_JOYBUTTONUP:
|
return sdlGetButtonCode(event);
|
||||||
return sdlGetButtonCode(event);
|
break;
|
||||||
break;
|
case SDL_JOYAXISMOTION:
|
||||||
case SDL_JOYAXISMOTION:
|
return sdlGetAxisCode(event);
|
||||||
return sdlGetAxisCode(event);
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
return 0;
|
||||||
return 0;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t inputGetKeymap(EPad pad, EKey key)
|
uint32_t inputGetKeymap(EPad pad, EKey key)
|
||||||
{
|
{
|
||||||
return joypad[pad][key];
|
return joypad[pad][key];
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetKeymap(EPad pad, EKey key, uint32_t code)
|
void inputSetKeymap(EPad pad, EKey key, uint32_t code)
|
||||||
{
|
{
|
||||||
joypad[pad][key] = code;
|
joypad[pad][key] = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetMotionKeymap(EKey key, uint32_t code)
|
void inputSetMotionKeymap(EKey key, uint32_t code)
|
||||||
|
@ -160,22 +140,21 @@ bool inputGetAutoFire(EKey key)
|
||||||
{
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
|
|
||||||
switch (key)
|
switch (key) {
|
||||||
{
|
case KEY_BUTTON_A:
|
||||||
case KEY_BUTTON_A:
|
mask = 1 << 0;
|
||||||
mask = 1 << 0;
|
break;
|
||||||
break;
|
case KEY_BUTTON_B:
|
||||||
case KEY_BUTTON_B:
|
mask = 1 << 1;
|
||||||
mask = 1 << 1;
|
break;
|
||||||
break;
|
case KEY_BUTTON_R:
|
||||||
case KEY_BUTTON_R:
|
mask = 1 << 8;
|
||||||
mask = 1 << 8;
|
break;
|
||||||
break;
|
case KEY_BUTTON_L:
|
||||||
case KEY_BUTTON_L:
|
mask = 1 << 9;
|
||||||
mask = 1 << 9;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return !(autoFire & mask);
|
return !(autoFire & mask);
|
||||||
|
@ -185,31 +164,27 @@ bool inputToggleAutoFire(EKey key)
|
||||||
{
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
|
|
||||||
switch (key)
|
switch (key) {
|
||||||
{
|
case KEY_BUTTON_A:
|
||||||
case KEY_BUTTON_A:
|
mask = 1 << 0;
|
||||||
mask = 1 << 0;
|
break;
|
||||||
break;
|
case KEY_BUTTON_B:
|
||||||
case KEY_BUTTON_B:
|
mask = 1 << 1;
|
||||||
mask = 1 << 1;
|
break;
|
||||||
break;
|
case KEY_BUTTON_R:
|
||||||
case KEY_BUTTON_R:
|
mask = 1 << 8;
|
||||||
mask = 1 << 8;
|
break;
|
||||||
break;
|
case KEY_BUTTON_L:
|
||||||
case KEY_BUTTON_L:
|
mask = 1 << 9;
|
||||||
mask = 1 << 9;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(autoFire & mask)
|
if (autoFire & mask) {
|
||||||
{
|
|
||||||
autoFire &= ~mask;
|
autoFire &= ~mask;
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
autoFire |= mask;
|
autoFire |= mask;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -217,402 +192,401 @@ bool inputToggleAutoFire(EKey key)
|
||||||
|
|
||||||
static void sdlUpdateKey(uint32_t key, bool down)
|
static void sdlUpdateKey(uint32_t key, bool down)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
for(i = 0 ; i < SDLBUTTONS_NUM; i++) {
|
for (i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
//if((joypad[j][i] & 0xffff0000) == 0) {
|
//if((joypad[j][i] & 0xffff0000) == 0) {
|
||||||
if(key == joypad[j][i])
|
if (key == joypad[j][i])
|
||||||
sdlButtons[j][i] = down;
|
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,
|
static void sdlUpdateJoyButton(int which,
|
||||||
int button,
|
int button,
|
||||||
bool pressed)
|
bool pressed)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
for(i = 0; i < SDLBUTTONS_NUM; i++) {
|
for (i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
int dev = (joypad[j][i] >> 16);
|
int dev = (joypad[j][i] >> 16);
|
||||||
int b = joypad[j][i] & 0xffff;
|
int b = joypad[j][i] & 0xffff;
|
||||||
if(dev) {
|
if (dev) {
|
||||||
dev--;
|
dev--;
|
||||||
|
|
||||||
if((dev == which) && (b >= 128) && (b == (button+128))) {
|
if ((dev == which) && (b >= 128) && (b == (button + 128))) {
|
||||||
sdlButtons[j][i] = pressed;
|
sdlButtons[j][i] = pressed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
for (i = 0; i < 4; i++) {
|
||||||
for(i = 0; i < 4; i++) {
|
int dev = (motion[i] >> 16);
|
||||||
int dev = (motion[i] >> 16);
|
int b = motion[i] & 0xffff;
|
||||||
int b = motion[i] & 0xffff;
|
if (dev) {
|
||||||
if(dev) {
|
dev--;
|
||||||
dev--;
|
|
||||||
|
|
||||||
if((dev == which) && (b >= 128) && (b == (button+128))) {
|
if ((dev == which) && (b >= 128) && (b == (button + 128))) {
|
||||||
sdlMotionButtons[i] = pressed;
|
sdlMotionButtons[i] = pressed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdlUpdateJoyHat(int which,
|
static void sdlUpdateJoyHat(int which,
|
||||||
int hat,
|
int hat,
|
||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
for(i = 0; i < SDLBUTTONS_NUM; i++) {
|
for (i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
int dev = (joypad[j][i] >> 16);
|
int dev = (joypad[j][i] >> 16);
|
||||||
int a = joypad[j][i] & 0xffff;
|
int a = joypad[j][i] & 0xffff;
|
||||||
if(dev) {
|
if (dev) {
|
||||||
dev--;
|
dev--;
|
||||||
|
|
||||||
if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
|
if ((dev == which) && (a >= 32) && (a < 48) && (((a & 15) >> 2) == hat)) {
|
||||||
int dir = a & 3;
|
int dir = a & 3;
|
||||||
int v = 0;
|
int v = 0;
|
||||||
switch(dir) {
|
switch (dir) {
|
||||||
case 0:
|
case 0:
|
||||||
v = value & SDL_HAT_UP;
|
v = value & SDL_HAT_UP;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
v = value & SDL_HAT_DOWN;
|
v = value & SDL_HAT_DOWN;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
v = value & SDL_HAT_RIGHT;
|
v = value & SDL_HAT_RIGHT;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
v = value & SDL_HAT_LEFT;
|
v = value & SDL_HAT_LEFT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sdlButtons[j][i] = (v ? true : false);
|
sdlButtons[j][i] = (v ? true : false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
for (i = 0; i < 4; i++) {
|
||||||
for(i = 0; i < 4; i++) {
|
int dev = (motion[i] >> 16);
|
||||||
int dev = (motion[i] >> 16);
|
int a = motion[i] & 0xffff;
|
||||||
int a = motion[i] & 0xffff;
|
if (dev) {
|
||||||
if(dev) {
|
dev--;
|
||||||
dev--;
|
|
||||||
|
|
||||||
if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
|
if ((dev == which) && (a >= 32) && (a < 48) && (((a & 15) >> 2) == hat)) {
|
||||||
int dir = a & 3;
|
int dir = a & 3;
|
||||||
int v = 0;
|
int v = 0;
|
||||||
switch(dir) {
|
switch (dir) {
|
||||||
case 0:
|
case 0:
|
||||||
v = value & SDL_HAT_UP;
|
v = value & SDL_HAT_UP;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
v = value & SDL_HAT_DOWN;
|
v = value & SDL_HAT_DOWN;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
v = value & SDL_HAT_RIGHT;
|
v = value & SDL_HAT_RIGHT;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
v = value & SDL_HAT_LEFT;
|
v = value & SDL_HAT_LEFT;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
sdlMotionButtons[i] = (v ? true : false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sdlMotionButtons[i] = (v ? true : false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdlUpdateJoyAxis(int which,
|
static void sdlUpdateJoyAxis(int which,
|
||||||
int axis,
|
int axis,
|
||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
for(i = 0; i < SDLBUTTONS_NUM; i++) {
|
for (i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
int dev = (joypad[j][i] >> 16);
|
int dev = (joypad[j][i] >> 16);
|
||||||
int a = joypad[j][i] & 0xffff;
|
int a = joypad[j][i] & 0xffff;
|
||||||
if(dev) {
|
if (dev) {
|
||||||
dev--;
|
dev--;
|
||||||
|
|
||||||
if((dev == which) && (a < 32) && ((a>>1) == axis)) {
|
if ((dev == which) && (a < 32) && ((a >> 1) == axis)) {
|
||||||
sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384);
|
sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
for (i = 0; i < 4; i++) {
|
||||||
for(i = 0; i < 4; i++) {
|
int dev = (motion[i] >> 16);
|
||||||
int dev = (motion[i] >> 16);
|
int a = motion[i] & 0xffff;
|
||||||
int a = motion[i] & 0xffff;
|
if (dev) {
|
||||||
if(dev) {
|
dev--;
|
||||||
dev--;
|
|
||||||
|
|
||||||
if((dev == which) && (a < 32) && ((a>>1) == axis)) {
|
if ((dev == which) && (a < 32) && ((a >> 1) == axis)) {
|
||||||
sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
|
sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sdlCheckJoyKey(int key)
|
static bool sdlCheckJoyKey(int key)
|
||||||
{
|
{
|
||||||
int dev = (key >> 16) - 1;
|
int dev = (key >> 16) - 1;
|
||||||
int what = key & 0xffff;
|
int what = key & 0xffff;
|
||||||
|
|
||||||
if(what >= 128) {
|
if (what >= 128) {
|
||||||
// joystick button
|
// joystick button
|
||||||
int button = what - 128;
|
int button = what - 128;
|
||||||
|
|
||||||
if(button >= SDL_JoystickNumButtons(sdlDevices[dev]))
|
if (button >= SDL_JoystickNumButtons(sdlDevices[dev]))
|
||||||
return false;
|
return false;
|
||||||
} else if (what < 0x20) {
|
} else if (what < 0x20) {
|
||||||
// joystick axis
|
// joystick axis
|
||||||
what >>= 1;
|
what >>= 1;
|
||||||
if(what >= SDL_JoystickNumAxes(sdlDevices[dev]))
|
if (what >= SDL_JoystickNumAxes(sdlDevices[dev]))
|
||||||
return false;
|
return false;
|
||||||
} else if (what < 0x30) {
|
} else if (what < 0x30) {
|
||||||
// joystick hat
|
// joystick hat
|
||||||
what = (what & 15);
|
what = (what & 15);
|
||||||
what >>= 2;
|
what >>= 2;
|
||||||
if(what >= SDL_JoystickNumHats(sdlDevices[dev]))
|
if (what >= SDL_JoystickNumHats(sdlDevices[dev]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no problem found
|
// no problem found
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputInitJoysticks()
|
void inputInitJoysticks()
|
||||||
{
|
{
|
||||||
// The main joypad has to be entirely defined
|
// The main joypad has to be entirely defined
|
||||||
for(int i = 0; i < SDLBUTTONS_NUM; i++) {
|
for (int i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
if (!joypad[PAD_MAIN][i])
|
if (!joypad[PAD_MAIN][i])
|
||||||
joypad[PAD_MAIN][i] = joypad[PAD_DEFAULT][i];
|
joypad[PAD_MAIN][i] = joypad[PAD_DEFAULT][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
sdlNumDevices = SDL_NumJoysticks();
|
sdlNumDevices = SDL_NumJoysticks();
|
||||||
|
|
||||||
if(sdlNumDevices)
|
if (sdlNumDevices)
|
||||||
sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices *
|
sdlDevices = (SDL_Joystick**)calloc(1, sdlNumDevices * sizeof(SDL_Joystick**));
|
||||||
sizeof(SDL_Joystick **));
|
bool usesJoy = false;
|
||||||
bool usesJoy = false;
|
|
||||||
|
|
||||||
for(int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
for(int i = 0; i < SDLBUTTONS_NUM; i++) {
|
for (int i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
int dev = joypad[j][i] >> 16;
|
int dev = joypad[j][i] >> 16;
|
||||||
if(dev) {
|
if (dev) {
|
||||||
dev--;
|
dev--;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
if(sdlDevices) {
|
if (sdlDevices) {
|
||||||
if(dev < sdlNumDevices) {
|
if (dev < sdlNumDevices) {
|
||||||
if(sdlDevices[dev] == NULL) {
|
if (sdlDevices[dev] == NULL) {
|
||||||
sdlDevices[dev] = SDL_JoystickOpen(dev);
|
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]);
|
if (!ok)
|
||||||
} else
|
motion[i] = defaultMotion[i];
|
||||||
ok = false;
|
else
|
||||||
|
usesJoy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ok)
|
|
||||||
joypad[j][i] = joypad[PAD_DEFAULT][i];
|
|
||||||
else
|
|
||||||
usesJoy = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++) {
|
if (usesJoy)
|
||||||
int dev = motion[i] >> 16;
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
switch (event.type) {
|
||||||
{
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYDOWN:
|
if (!event.key.keysym.mod)
|
||||||
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, true);
|
sdlUpdateKey(event.key.keysym.sym, true);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, false);
|
if (!event.key.keysym.mod)
|
||||||
break;
|
sdlUpdateKey(event.key.keysym.sym, false);
|
||||||
case SDL_JOYHATMOTION:
|
break;
|
||||||
sdlUpdateJoyHat(event.jhat.which,
|
case SDL_JOYHATMOTION:
|
||||||
event.jhat.hat,
|
sdlUpdateJoyHat(event.jhat.which,
|
||||||
event.jhat.value);
|
event.jhat.hat,
|
||||||
break;
|
event.jhat.value);
|
||||||
case SDL_JOYBUTTONDOWN:
|
break;
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_JOYBUTTONDOWN:
|
||||||
sdlUpdateJoyButton(event.jbutton.which,
|
case SDL_JOYBUTTONUP:
|
||||||
event.jbutton.button,
|
sdlUpdateJoyButton(event.jbutton.which,
|
||||||
event.jbutton.state == SDL_PRESSED);
|
event.jbutton.button,
|
||||||
break;
|
event.jbutton.state == SDL_PRESSED);
|
||||||
case SDL_JOYAXISMOTION:
|
break;
|
||||||
sdlUpdateJoyAxis(event.jaxis.which,
|
case SDL_JOYAXISMOTION:
|
||||||
event.jaxis.axis,
|
sdlUpdateJoyAxis(event.jaxis.which,
|
||||||
event.jaxis.value);
|
event.jaxis.axis,
|
||||||
break;
|
event.jaxis.value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t inputReadJoypad(int which)
|
uint32_t inputReadJoypad(int which)
|
||||||
{
|
{
|
||||||
int realAutoFire = autoFire;
|
int realAutoFire = autoFire;
|
||||||
|
|
||||||
if(which < 0 || which > 3)
|
if (which < 0 || which > 3)
|
||||||
which = sdlDefaultJoypad;
|
which = sdlDefaultJoypad;
|
||||||
|
|
||||||
uint32_t res = 0;
|
uint32_t res = 0;
|
||||||
|
|
||||||
if(sdlButtons[which][KEY_BUTTON_A])
|
if (sdlButtons[which][KEY_BUTTON_A])
|
||||||
res |= 1;
|
res |= 1;
|
||||||
if(sdlButtons[which][KEY_BUTTON_B])
|
if (sdlButtons[which][KEY_BUTTON_B])
|
||||||
res |= 2;
|
res |= 2;
|
||||||
if(sdlButtons[which][KEY_BUTTON_SELECT])
|
if (sdlButtons[which][KEY_BUTTON_SELECT])
|
||||||
res |= 4;
|
res |= 4;
|
||||||
if(sdlButtons[which][KEY_BUTTON_START])
|
if (sdlButtons[which][KEY_BUTTON_START])
|
||||||
res |= 8;
|
res |= 8;
|
||||||
if(sdlButtons[which][KEY_RIGHT])
|
if (sdlButtons[which][KEY_RIGHT])
|
||||||
res |= 16;
|
res |= 16;
|
||||||
if(sdlButtons[which][KEY_LEFT])
|
if (sdlButtons[which][KEY_LEFT])
|
||||||
res |= 32;
|
res |= 32;
|
||||||
if(sdlButtons[which][KEY_UP])
|
if (sdlButtons[which][KEY_UP])
|
||||||
res |= 64;
|
res |= 64;
|
||||||
if(sdlButtons[which][KEY_DOWN])
|
if (sdlButtons[which][KEY_DOWN])
|
||||||
res |= 128;
|
res |= 128;
|
||||||
if(sdlButtons[which][KEY_BUTTON_R])
|
if (sdlButtons[which][KEY_BUTTON_R])
|
||||||
res |= 256;
|
res |= 256;
|
||||||
if(sdlButtons[which][KEY_BUTTON_L])
|
if (sdlButtons[which][KEY_BUTTON_L])
|
||||||
res |= 512;
|
res |= 512;
|
||||||
if(sdlButtons[which][KEY_BUTTON_AUTO_A])
|
if (sdlButtons[which][KEY_BUTTON_AUTO_A])
|
||||||
realAutoFire ^= 1;
|
realAutoFire ^= 1;
|
||||||
if(sdlButtons[which][KEY_BUTTON_AUTO_B])
|
if (sdlButtons[which][KEY_BUTTON_AUTO_B])
|
||||||
realAutoFire ^= 2;
|
realAutoFire ^= 2;
|
||||||
|
|
||||||
// disallow L+R or U+D of being pressed at the same time
|
// disallow L+R or U+D of being pressed at the same time
|
||||||
if((res & 48) == 48)
|
if ((res & 48) == 48)
|
||||||
res &= ~16;
|
res &= ~16;
|
||||||
if((res & 192) == 192)
|
if ((res & 192) == 192)
|
||||||
res &= ~128;
|
res &= ~128;
|
||||||
|
|
||||||
if(sdlButtons[which][KEY_BUTTON_SPEED])
|
if (sdlButtons[which][KEY_BUTTON_SPEED])
|
||||||
res |= 1024;
|
res |= 1024;
|
||||||
if(sdlButtons[which][KEY_BUTTON_CAPTURE])
|
if (sdlButtons[which][KEY_BUTTON_CAPTURE])
|
||||||
res |= 2048;
|
res |= 2048;
|
||||||
|
|
||||||
if(realAutoFire) {
|
if (realAutoFire) {
|
||||||
res &= (~realAutoFire);
|
res &= (~realAutoFire);
|
||||||
if(autoFireToggle)
|
if (autoFireToggle)
|
||||||
res |= realAutoFire;
|
res |= realAutoFire;
|
||||||
autoFireCountdown--; // this needs decrementing even when autoFireToggle is toggled,
|
autoFireCountdown--; // this needs decrementing even when autoFireToggle is toggled,
|
||||||
// so that autoFireMaxCount==1 (the default) will alternate at the maximum possible
|
// 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
|
// frequency (every time this code is reached). Which is what it did before
|
||||||
// introducing autoFireCountdown.
|
// introducing autoFireCountdown.
|
||||||
if (autoFireCountdown <= 0) {
|
if (autoFireCountdown <= 0) {
|
||||||
autoFireToggle = !autoFireToggle;
|
autoFireToggle = !autoFireToggle;
|
||||||
autoFireCountdown = autoFireMaxCount;
|
autoFireCountdown = autoFireMaxCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputUpdateMotionSensor()
|
void inputUpdateMotionSensor()
|
||||||
{
|
{
|
||||||
if(sdlMotionButtons[KEY_LEFT]) {
|
if (sdlMotionButtons[KEY_LEFT]) {
|
||||||
sensorX += 3;
|
sensorX += 3;
|
||||||
if(sensorX > 2197)
|
if (sensorX > 2197)
|
||||||
sensorX = 2197;
|
sensorX = 2197;
|
||||||
if(sensorX < 2047)
|
if (sensorX < 2047)
|
||||||
sensorX = 2057;
|
sensorX = 2057;
|
||||||
} else if(sdlMotionButtons[KEY_RIGHT]) {
|
} else if (sdlMotionButtons[KEY_RIGHT]) {
|
||||||
sensorX -= 3;
|
sensorX -= 3;
|
||||||
if(sensorX < 1897)
|
if (sensorX < 1897)
|
||||||
sensorX = 1897;
|
sensorX = 1897;
|
||||||
if(sensorX > 2047)
|
if (sensorX > 2047)
|
||||||
sensorX = 2037;
|
sensorX = 2037;
|
||||||
} else if(sensorX > 2047) {
|
} else if (sensorX > 2047) {
|
||||||
sensorX -= 2;
|
sensorX -= 2;
|
||||||
if(sensorX < 2047)
|
if (sensorX < 2047)
|
||||||
sensorX = 2047;
|
sensorX = 2047;
|
||||||
} else {
|
} else {
|
||||||
sensorX += 2;
|
sensorX += 2;
|
||||||
if(sensorX > 2047)
|
if (sensorX > 2047)
|
||||||
sensorX = 2047;
|
sensorX = 2047;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sdlMotionButtons[KEY_UP]) {
|
if (sdlMotionButtons[KEY_UP]) {
|
||||||
sensorY += 3;
|
sensorY += 3;
|
||||||
if(sensorY > 2197)
|
if (sensorY > 2197)
|
||||||
sensorY = 2197;
|
sensorY = 2197;
|
||||||
if(sensorY < 2047)
|
if (sensorY < 2047)
|
||||||
sensorY = 2057;
|
sensorY = 2057;
|
||||||
} else if(sdlMotionButtons[KEY_DOWN]) {
|
} else if (sdlMotionButtons[KEY_DOWN]) {
|
||||||
sensorY -= 3;
|
sensorY -= 3;
|
||||||
if(sensorY < 1897)
|
if (sensorY < 1897)
|
||||||
sensorY = 1897;
|
sensorY = 1897;
|
||||||
if(sensorY > 2047)
|
if (sensorY > 2047)
|
||||||
sensorY = 2037;
|
sensorY = 2037;
|
||||||
} else if(sensorY > 2047) {
|
} else if (sensorY > 2047) {
|
||||||
sensorY -= 2;
|
sensorY -= 2;
|
||||||
if(sensorY < 2047)
|
if (sensorY < 2047)
|
||||||
sensorY = 2047;
|
sensorY = 2047;
|
||||||
} else {
|
} else {
|
||||||
sensorY += 2;
|
sensorY += 2;
|
||||||
if(sensorY > 2047)
|
if (sensorY > 2047)
|
||||||
sensorY = 2047;
|
sensorY = 2047;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int inputGetSensorX()
|
int inputGetSensorX()
|
||||||
{
|
{
|
||||||
return sensorX;
|
return sensorX;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inputGetSensorY()
|
int inputGetSensorY()
|
||||||
{
|
{
|
||||||
return sensorY;
|
return sensorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetDefaultJoypad(EPad pad)
|
void inputSetDefaultJoypad(EPad pad)
|
||||||
{
|
{
|
||||||
sdlDefaultJoypad = pad;
|
sdlDefaultJoypad = pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
EPad inputGetDefaultJoypad()
|
EPad inputGetDefaultJoypad()
|
||||||
{
|
{
|
||||||
return sdlDefaultJoypad;
|
return sdlDefaultJoypad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,23 +21,28 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
enum EKey {
|
enum EKey {
|
||||||
KEY_LEFT,
|
KEY_LEFT,
|
||||||
KEY_RIGHT,
|
KEY_RIGHT,
|
||||||
KEY_UP,
|
KEY_UP,
|
||||||
KEY_DOWN,
|
KEY_DOWN,
|
||||||
KEY_BUTTON_A,
|
KEY_BUTTON_A,
|
||||||
KEY_BUTTON_B,
|
KEY_BUTTON_B,
|
||||||
KEY_BUTTON_START,
|
KEY_BUTTON_START,
|
||||||
KEY_BUTTON_SELECT,
|
KEY_BUTTON_SELECT,
|
||||||
KEY_BUTTON_L,
|
KEY_BUTTON_L,
|
||||||
KEY_BUTTON_R,
|
KEY_BUTTON_R,
|
||||||
KEY_BUTTON_SPEED,
|
KEY_BUTTON_SPEED,
|
||||||
KEY_BUTTON_CAPTURE,
|
KEY_BUTTON_CAPTURE,
|
||||||
KEY_BUTTON_AUTO_A,
|
KEY_BUTTON_AUTO_A,
|
||||||
KEY_BUTTON_AUTO_B
|
KEY_BUTTON_AUTO_B
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EPad { PAD_MAIN, PAD_1 = PAD_MAIN, PAD_2, PAD_3, PAD_4, PAD_DEFAULT };
|
enum EPad { PAD_MAIN,
|
||||||
|
PAD_1 = PAD_MAIN,
|
||||||
|
PAD_2,
|
||||||
|
PAD_3,
|
||||||
|
PAD_4,
|
||||||
|
PAD_DEFAULT };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the joysticks needed by the keymap. Verify that the keymap is compatible
|
* Init the joysticks needed by the keymap. Verify that the keymap is compatible
|
||||||
|
@ -86,14 +91,14 @@ bool inputGetAutoFire(EKey key);
|
||||||
* Update the emulated pads state with a SDL event
|
* Update the emulated pads state with a SDL event
|
||||||
* @param SDL_Event An event that has just occured
|
* @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
|
* Get the keymap code corresponding to a SDL event
|
||||||
* @param SDL_Event An event that has just occured
|
* @param SDL_Event An event that has just occured
|
||||||
* @return Keymap code
|
* @return Keymap code
|
||||||
*/
|
*/
|
||||||
uint32_t inputGetEventCode(const SDL_Event &event);
|
uint32_t inputGetEventCode(const SDL_Event& event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the state of an emulated joypad
|
* Read the state of an emulated joypad
|
||||||
|
|
206
src/sdl/text.cpp
206
src/sdl/text.cpp
|
@ -25,124 +25,116 @@
|
||||||
extern int RGB_LOW_BITS_MASK;
|
extern int RGB_LOW_BITS_MASK;
|
||||||
|
|
||||||
static const u8 fontdata2[2048] = {
|
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, 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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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, 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,
|
void drawText(u8* screen, int pitch, int x, int y,
|
||||||
const char *string, bool trans)
|
const char* string, bool trans)
|
||||||
{
|
{
|
||||||
screen += y*pitch;
|
screen += y * pitch;
|
||||||
int inc = 2;
|
int inc = 2;
|
||||||
switch(systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 24:
|
case 24:
|
||||||
inc = 3;
|
inc = 3;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
inc = 4;
|
inc = 4;
|
||||||
break;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
screen += x * inc;
|
||||||
case 24:
|
|
||||||
{
|
|
||||||
while(*string) {
|
|
||||||
char c = *string++;
|
|
||||||
u8 *scr = screen;
|
|
||||||
|
|
||||||
int h, w;
|
switch (systemColorDepth) {
|
||||||
u8 *s = (u8 *)scr;
|
case 16: {
|
||||||
for (h = 0; h < 8; h++) {
|
while (*string) {
|
||||||
for (w = 0; w < 8; w++, s+=3) {
|
char c = *string++;
|
||||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
u8* scr = screen;
|
||||||
|
|
||||||
if(trans) {
|
u16 mask = ~RGB_LOW_BITS_MASK;
|
||||||
if(on) {
|
int h, w;
|
||||||
u32 color = (0x1f) << systemRedShift;
|
u16* s = (u16*)scr;
|
||||||
*s = ((color & 255)>>1)+(*s>>1);
|
for (h = 0; h < 8; h++) {
|
||||||
*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
|
for (w = 0; w < 8; w++, s++) {
|
||||||
*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
|
int on = (fontdata2[(c << 3) + h] >> w) & 1;
|
||||||
}
|
|
||||||
} else {
|
if (trans) {
|
||||||
if(on) {
|
if (on)
|
||||||
u32 color = (0x1f) << systemRedShift;
|
*s = ((0xf) << systemRedShift) + ((*s & mask) >> 1);
|
||||||
*s = (color & 255);
|
} else {
|
||||||
*(s+1) = (color >> 8) & 255;
|
if (on)
|
||||||
*(s+2) = (color >> 16) & 255;
|
*s = (0x1f) << systemRedShift;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
scr += pitch;
|
||||||
|
s = (u16*)scr;
|
||||||
}
|
}
|
||||||
}
|
screen += inc * 8;
|
||||||
scr += pitch;
|
|
||||||
s = (u8 *)scr;
|
|
||||||
}
|
}
|
||||||
screen += inc*8;
|
} break;
|
||||||
}
|
case 24: {
|
||||||
}
|
while (*string) {
|
||||||
break;
|
char c = *string++;
|
||||||
case 32:
|
u8* scr = screen;
|
||||||
{
|
|
||||||
while(*string) {
|
|
||||||
char c = *string++;
|
|
||||||
u8 *scr = screen;
|
|
||||||
|
|
||||||
int h, w;
|
int h, w;
|
||||||
u32 mask = 0xfefefe;
|
u8* s = (u8*)scr;
|
||||||
u32 *s = (u32 *)scr;
|
for (h = 0; h < 8; h++) {
|
||||||
for (h = 0; h < 8; h++) {
|
for (w = 0; w < 8; w++, s += 3) {
|
||||||
for (w = 0; w < 8; w++, s++) {
|
int on = (fontdata2[(c << 3) + h] >> w) & 1;
|
||||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
|
||||||
|
|
||||||
if(trans) {
|
if (trans) {
|
||||||
if(on)
|
if (on) {
|
||||||
*s = ((0xf) << systemRedShift) + ((*s & mask)>>1);
|
u32 color = (0x1f) << systemRedShift;
|
||||||
} else {
|
*s = ((color & 255) >> 1) + (*s >> 1);
|
||||||
if(on)
|
*(s + 1) = (((color >> 8) & 255) >> 1) + (*(s + 1) >> 1);
|
||||||
*s = (0x1f) << systemRedShift;
|
*(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;
|
||||||
}
|
}
|
||||||
}
|
screen += inc * 8;
|
||||||
scr += pitch;
|
|
||||||
s = (u32 *)scr;
|
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
extern void drawText(u8 *, int, int, int, const char *, bool);
|
extern void drawText(u8*, int, int, int, const char*, bool);
|
||||||
|
|
|
@ -1,284 +1,269 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "AVIWrite.h"
|
#include "AVIWrite.h"
|
||||||
#pragma comment( lib, "Vfw32" )
|
#pragma comment(lib, "Vfw32")
|
||||||
|
|
||||||
|
|
||||||
AVIWrite::AVIWrite()
|
AVIWrite::AVIWrite()
|
||||||
{
|
{
|
||||||
m_failed = false;
|
m_failed = false;
|
||||||
m_file = NULL;
|
m_file = NULL;
|
||||||
m_videoStream = NULL;
|
m_videoStream = NULL;
|
||||||
m_audioStream = NULL;
|
m_audioStream = NULL;
|
||||||
ZeroMemory( &m_videoCompSettings, sizeof( m_videoCompSettings ) );
|
ZeroMemory(&m_videoCompSettings, sizeof(m_videoCompSettings));
|
||||||
ZeroMemory( &m_audioCompSettings, sizeof( m_audioCompSettings ) );
|
ZeroMemory(&m_audioCompSettings, sizeof(m_audioCompSettings));
|
||||||
m_videoCompressed = NULL;
|
m_videoCompressed = NULL;
|
||||||
m_audioCompressed = NULL;
|
m_audioCompressed = NULL;
|
||||||
m_frameRate = 0;
|
m_frameRate = 0;
|
||||||
m_frameCounter = 0;
|
m_frameCounter = 0;
|
||||||
m_sampleCounter = 0;
|
m_sampleCounter = 0;
|
||||||
m_videoFrameSize = 0;
|
m_videoFrameSize = 0;
|
||||||
m_audioFrameSize = 0;
|
m_audioFrameSize = 0;
|
||||||
m_audioBlockAlign = 0;
|
m_audioBlockAlign = 0;
|
||||||
|
|
||||||
AVIFileInit();
|
AVIFileInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AVIWrite::~AVIWrite()
|
AVIWrite::~AVIWrite()
|
||||||
{
|
{
|
||||||
if( m_audioCompressed ) {
|
if (m_audioCompressed) {
|
||||||
AVIStreamRelease( m_audioCompressed );
|
AVIStreamRelease(m_audioCompressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_audioStream ) {
|
if (m_audioStream) {
|
||||||
AVIStreamRelease( m_audioStream );
|
AVIStreamRelease(m_audioStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_videoCompressed ) {
|
if (m_videoCompressed) {
|
||||||
AVIStreamRelease( m_videoCompressed );
|
AVIStreamRelease(m_videoCompressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_videoStream ) {
|
if (m_videoStream) {
|
||||||
AVIStreamRelease( m_videoStream );
|
AVIStreamRelease(m_videoStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_file ) {
|
if (m_file) {
|
||||||
AVIFileRelease( 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 --
|
// -- create the AVI file --
|
||||||
err = AVIFileOpen(
|
err = AVIFileOpen(
|
||||||
&m_file,
|
&m_file,
|
||||||
filename,
|
filename,
|
||||||
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
|
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// colorBits: 16, 24 or 32
|
// colorBits: 16, 24 or 32
|
||||||
bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd )
|
bool AVIWrite::CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd)
|
||||||
{
|
{
|
||||||
if( m_videoStream || m_failed ) return false;
|
if (m_videoStream || m_failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT err = 0;
|
HRESULT err = 0;
|
||||||
AVISTREAMINFO videoInfo;
|
AVISTREAMINFO videoInfo;
|
||||||
BITMAPINFOHEADER bitmapInfo;
|
BITMAPINFOHEADER bitmapInfo;
|
||||||
AVICOMPRESSOPTIONS *settings[1];
|
AVICOMPRESSOPTIONS* settings[1];
|
||||||
ZeroMemory( &videoInfo, sizeof( videoInfo ) );
|
ZeroMemory(&videoInfo, sizeof(videoInfo));
|
||||||
ZeroMemory( &bitmapInfo, sizeof( bitmapInfo ) );
|
ZeroMemory(&bitmapInfo, sizeof(bitmapInfo));
|
||||||
settings[0] = &m_videoCompSettings;
|
settings[0] = &m_videoCompSettings;
|
||||||
|
|
||||||
// -- initialize the video stream information --
|
// -- initialize the video stream information --
|
||||||
videoInfo.fccType = streamtypeVIDEO;
|
videoInfo.fccType = streamtypeVIDEO;
|
||||||
videoInfo.fccHandler = 0;
|
videoInfo.fccHandler = 0;
|
||||||
videoInfo.dwScale = 1;
|
videoInfo.dwScale = 1;
|
||||||
videoInfo.dwRate = framesPerSecond;
|
videoInfo.dwRate = framesPerSecond;
|
||||||
videoInfo.dwSuggestedBufferSize = imageWidth * imageHeight * ( colorBits >> 3 );
|
videoInfo.dwSuggestedBufferSize = imageWidth * imageHeight * (colorBits >> 3);
|
||||||
|
|
||||||
// -- create the video stream --
|
// -- create the video stream --
|
||||||
err = AVIFileCreateStream(
|
err = AVIFileCreateStream(
|
||||||
m_file,
|
m_file,
|
||||||
&m_videoStream,
|
&m_videoStream,
|
||||||
&videoInfo
|
&videoInfo);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- ask for compression settings --
|
||||||
|
if (AVISaveOptions(
|
||||||
|
parentWnd,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
&m_videoStream,
|
||||||
|
settings)) {
|
||||||
|
err = AVIMakeCompressedStream(
|
||||||
|
&m_videoCompressed,
|
||||||
|
m_videoStream,
|
||||||
|
settings[0],
|
||||||
|
NULL);
|
||||||
|
|
||||||
// -- ask for compression settings --
|
AVISaveOptionsFree(1, settings);
|
||||||
if( AVISaveOptions(
|
if (FAILED(err)) {
|
||||||
parentWnd,
|
m_failed = true;
|
||||||
0,
|
return false;
|
||||||
1,
|
}
|
||||||
&m_videoStream,
|
} else {
|
||||||
settings ) )
|
AVISaveOptionsFree(1, settings);
|
||||||
{
|
m_failed = true;
|
||||||
err = AVIMakeCompressedStream(
|
return false;
|
||||||
&m_videoCompressed,
|
}
|
||||||
m_videoStream,
|
|
||||||
settings[0],
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
AVISaveOptionsFree( 1, settings );
|
// -- initialize the video stream format --
|
||||||
if( FAILED( err ) ) {
|
bitmapInfo.biSize = sizeof(bitmapInfo);
|
||||||
m_failed = true;
|
bitmapInfo.biWidth = imageWidth;
|
||||||
return false;
|
bitmapInfo.biHeight = imageHeight;
|
||||||
}
|
bitmapInfo.biBitCount = colorBits;
|
||||||
} else {
|
bitmapInfo.biPlanes = 1;
|
||||||
AVISaveOptionsFree( 1, settings );
|
bitmapInfo.biCompression = BI_RGB;
|
||||||
m_failed = true;
|
bitmapInfo.biSizeImage = imageWidth * imageHeight * (colorBits >> 3);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// -- set the video stream format --
|
||||||
|
err = AVIStreamSetFormat(
|
||||||
|
m_videoCompressed,
|
||||||
|
0,
|
||||||
|
&bitmapInfo,
|
||||||
|
bitmapInfo.biSize + (bitmapInfo.biClrUsed * sizeof(RGBQUAD)));
|
||||||
|
|
||||||
// -- initialize the video stream format --
|
if (FAILED(err)) {
|
||||||
bitmapInfo.biSize = sizeof( bitmapInfo );
|
m_failed = true;
|
||||||
bitmapInfo.biWidth = imageWidth;
|
return false;
|
||||||
bitmapInfo.biHeight = imageHeight;
|
}
|
||||||
bitmapInfo.biBitCount = colorBits;
|
|
||||||
bitmapInfo.biPlanes = 1;
|
|
||||||
bitmapInfo.biCompression = BI_RGB;
|
|
||||||
bitmapInfo.biSizeImage = imageWidth * imageHeight * ( colorBits >> 3 );
|
|
||||||
|
|
||||||
// -- set the video stream format --
|
m_frameRate = framesPerSecond;
|
||||||
err = AVIStreamSetFormat(
|
m_videoFrameSize = imageWidth * imageHeight * (colorBits >> 3);
|
||||||
m_videoCompressed,
|
|
||||||
0,
|
|
||||||
&bitmapInfo,
|
|
||||||
bitmapInfo.biSize + ( bitmapInfo.biClrUsed * sizeof( RGBQUAD ) )
|
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
return true;
|
||||||
m_failed = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
m_frameRate = framesPerSecond;
|
|
||||||
m_videoFrameSize = imageWidth * imageHeight * ( colorBits >> 3 );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// call AddVideoStream() first
|
// call AddVideoStream() first
|
||||||
// channelCount: max. 2
|
// channelCount: max. 2
|
||||||
// sampleBits: max. 16
|
// sampleBits: max. 16
|
||||||
bool AVIWrite::CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd )
|
bool AVIWrite::CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd)
|
||||||
{
|
{
|
||||||
if( m_audioStream || m_failed ) return false;
|
if (m_audioStream || m_failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT err = 0;
|
HRESULT err = 0;
|
||||||
AVISTREAMINFO audioInfo;
|
AVISTREAMINFO audioInfo;
|
||||||
WAVEFORMATEX waveInfo;
|
WAVEFORMATEX waveInfo;
|
||||||
ZeroMemory( &audioInfo, sizeof( audioInfo ) );
|
ZeroMemory(&audioInfo, sizeof(audioInfo));
|
||||||
ZeroMemory( &waveInfo, sizeof( waveInfo ) );
|
ZeroMemory(&waveInfo, sizeof(waveInfo));
|
||||||
|
|
||||||
// -- initialize the audio stream information --
|
// -- initialize the audio stream information --
|
||||||
audioInfo.fccType = streamtypeAUDIO;
|
audioInfo.fccType = streamtypeAUDIO;
|
||||||
audioInfo.dwQuality = (DWORD)-1;
|
audioInfo.dwQuality = (DWORD)-1;
|
||||||
audioInfo.dwScale = channelCount * ( sampleBits >> 3 );
|
audioInfo.dwScale = channelCount * (sampleBits >> 3);
|
||||||
audioInfo.dwRate = channelCount * ( sampleBits >> 3 ) * sampleRate;
|
audioInfo.dwRate = channelCount * (sampleBits >> 3) * sampleRate;
|
||||||
audioInfo.dwInitialFrames = 1;
|
audioInfo.dwInitialFrames = 1;
|
||||||
audioInfo.dwSampleSize = channelCount * ( sampleBits >> 3 );
|
audioInfo.dwSampleSize = channelCount * (sampleBits >> 3);
|
||||||
audioInfo.dwSuggestedBufferSize = 0;
|
audioInfo.dwSuggestedBufferSize = 0;
|
||||||
|
|
||||||
// -- create the audio stream --
|
// -- create the audio stream --
|
||||||
err = AVIFileCreateStream(
|
err = AVIFileCreateStream(
|
||||||
m_file,
|
m_file,
|
||||||
&m_audioStream,
|
&m_audioStream,
|
||||||
&audioInfo
|
&audioInfo);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- initialize the audio stream format --
|
||||||
|
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 --
|
// -- set the audio stream format --
|
||||||
waveInfo.wFormatTag = WAVE_FORMAT_PCM;
|
err = AVIStreamSetFormat(
|
||||||
waveInfo.nChannels = channelCount;
|
m_audioStream,
|
||||||
waveInfo.nSamplesPerSec = sampleRate;
|
0,
|
||||||
waveInfo.nAvgBytesPerSec = channelCount * ( sampleBits >> 3 ) * sampleRate;
|
&waveInfo,
|
||||||
waveInfo.nBlockAlign = channelCount * ( sampleBits >> 3 );
|
sizeof(waveInfo));
|
||||||
waveInfo.wBitsPerSample = sampleBits;
|
|
||||||
waveInfo.cbSize = 0;
|
|
||||||
|
|
||||||
// -- set the audio stream format --
|
if (FAILED(err)) {
|
||||||
err = AVIStreamSetFormat(
|
m_failed = true;
|
||||||
m_audioStream,
|
return false;
|
||||||
0,
|
}
|
||||||
&waveInfo,
|
|
||||||
sizeof( waveInfo )
|
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
m_audioBlockAlign = channelCount * (sampleBits >> 3);
|
||||||
m_failed = true;
|
m_audioFrameSize = channelCount * (sampleBits >> 3) * (sampleRate / m_frameRate);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_audioBlockAlign = channelCount * ( sampleBits >> 3 );
|
return true;
|
||||||
m_audioFrameSize = channelCount * ( sampleBits >> 3 ) * ( sampleRate / m_frameRate );
|
|
||||||
|
|
||||||
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(
|
err = AVIStreamWrite(
|
||||||
m_videoCompressed,
|
m_videoCompressed,
|
||||||
m_frameCounter,
|
m_frameCounter,
|
||||||
1,
|
1,
|
||||||
imageData,
|
imageData,
|
||||||
m_videoFrameSize,
|
m_videoFrameSize,
|
||||||
AVIIF_KEYFRAME,
|
AVIIF_KEYFRAME,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
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(
|
err = AVIStreamWrite(
|
||||||
m_audioStream,
|
m_audioStream,
|
||||||
m_sampleCounter,
|
m_sampleCounter,
|
||||||
m_audioFrameSize / m_audioBlockAlign,
|
m_audioFrameSize / m_audioBlockAlign,
|
||||||
soundData,
|
soundData,
|
||||||
m_audioFrameSize,
|
m_audioFrameSize,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleCounter += m_audioFrameSize / m_audioBlockAlign;
|
m_sampleCounter += m_audioFrameSize / m_audioBlockAlign;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,32 @@
|
||||||
#include <vfw.h>
|
#include <vfw.h>
|
||||||
|
|
||||||
// info: recreate the whole AVIWrite object if any method fails
|
// info: recreate the whole AVIWrite object if any method fails
|
||||||
class AVIWrite
|
class AVIWrite {
|
||||||
{
|
public:
|
||||||
public:
|
AVIWrite();
|
||||||
AVIWrite();
|
virtual ~AVIWrite();
|
||||||
virtual ~AVIWrite();
|
|
||||||
|
|
||||||
bool CreateAVIFile(LPCTSTR filename);
|
bool CreateAVIFile(LPCTSTR filename);
|
||||||
bool CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits,
|
bool CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits,
|
||||||
DWORD framesPerSecond, HWND parentWnd);
|
DWORD framesPerSecond, HWND parentWnd);
|
||||||
bool CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits,
|
bool CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits,
|
||||||
HWND parentWnd);
|
HWND parentWnd);
|
||||||
bool AddVideoFrame(LPVOID imageData);
|
bool AddVideoFrame(LPVOID imageData);
|
||||||
bool AddAudioFrame(LPVOID soundData);
|
bool AddAudioFrame(LPVOID soundData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_failed;
|
bool m_failed;
|
||||||
PAVIFILE m_file;
|
PAVIFILE m_file;
|
||||||
PAVISTREAM m_videoStream;
|
PAVISTREAM m_videoStream;
|
||||||
PAVISTREAM m_audioStream;
|
PAVISTREAM m_audioStream;
|
||||||
AVICOMPRESSOPTIONS m_videoCompSettings;
|
AVICOMPRESSOPTIONS m_videoCompSettings;
|
||||||
AVICOMPRESSOPTIONS m_audioCompSettings;
|
AVICOMPRESSOPTIONS m_audioCompSettings;
|
||||||
PAVISTREAM m_videoCompressed;
|
PAVISTREAM m_videoCompressed;
|
||||||
PAVISTREAM m_audioCompressed;
|
PAVISTREAM m_audioCompressed;
|
||||||
DWORD m_frameRate;
|
DWORD m_frameRate;
|
||||||
LONG m_frameCounter;
|
LONG m_frameCounter;
|
||||||
LONG m_sampleCounter;
|
LONG m_sampleCounter;
|
||||||
LONG m_videoFrameSize;
|
LONG m_videoFrameSize;
|
||||||
LONG m_audioFrameSize;
|
LONG m_audioFrameSize;
|
||||||
WORD m_audioBlockAlign;
|
WORD m_audioBlockAlign;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
#include "../AutoBuild.h"
|
#include "../AutoBuild.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -11,45 +11,42 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AboutDialog dialog
|
// AboutDialog dialog
|
||||||
|
|
||||||
|
|
||||||
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
|
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(AboutDialog::IDD, pParent)
|
: CDialog(AboutDialog::IDD, pParent)
|
||||||
{
|
{
|
||||||
m_version = _T(VBA_VERSION_STRING);
|
m_version = _T(VBA_VERSION_STRING);
|
||||||
m_date = _T(__DATE__);
|
m_date = _T(__DATE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AboutDialog::DoDataExchange(CDataExchange* pDX)
|
void AboutDialog::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
//{{AFX_DATA_MAP(AboutDialog)
|
//{{AFX_DATA_MAP(AboutDialog)
|
||||||
DDX_Text(pDX, IDC_VERSION, m_version);
|
DDX_Text(pDX, IDC_VERSION, m_version);
|
||||||
DDX_Control(pDX, IDC_URL, m_link);
|
DDX_Control(pDX, IDC_URL, m_link);
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
DDX_Text(pDX, IDC_DATE, m_date);
|
DDX_Text(pDX, IDC_DATE, m_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
|
BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
|
||||||
//{{AFX_MSG_MAP(AboutDialog)
|
//{{AFX_MSG_MAP(AboutDialog)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AboutDialog message handlers
|
// AboutDialog message handlers
|
||||||
|
|
||||||
BOOL AboutDialog::OnInitDialog()
|
BOOL AboutDialog::OnInitDialog()
|
||||||
{
|
{
|
||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL);
|
CWnd* p = GetDlgItem(IDC_TRANSLATOR_URL);
|
||||||
if(p) {
|
if (p) {
|
||||||
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
|
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
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,19 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
class AboutDialog : public CDialog
|
class AboutDialog : public CDialog {
|
||||||
{
|
public:
|
||||||
public:
|
AboutDialog(CWnd* pParent = NULL);
|
||||||
AboutDialog(CWnd *pParent = NULL);
|
enum { IDD = IDD_ABOUT };
|
||||||
enum { IDD = IDD_ABOUT };
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange *pDX);
|
virtual void DoDataExchange(CDataExchange* pDX);
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Hyperlink m_link;
|
Hyperlink m_link;
|
||||||
Hyperlink m_translator;
|
Hyperlink m_translator;
|
||||||
CString m_version;
|
CString m_version;
|
||||||
CString m_date;
|
CString m_date;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "vba.h"
|
|
||||||
#include "AccelEditor.h"
|
#include "AccelEditor.h"
|
||||||
#include "CmdAccelOb.h"
|
#include "CmdAccelOb.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "vba.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -12,258 +12,254 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AccelEditor dialog
|
// AccelEditor dialog
|
||||||
|
|
||||||
|
|
||||||
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
|
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
|
||||||
: ResizeDlg(AccelEditor::IDD, pParent)
|
: ResizeDlg(AccelEditor::IDD, pParent)
|
||||||
{
|
{
|
||||||
//{{AFX_DATA_INIT(AccelEditor)
|
//{{AFX_DATA_INIT(AccelEditor)
|
||||||
// NOTE: the ClassWizard will add member initialization here
|
// NOTE: the ClassWizard will add member initialization here
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
mgr = theApp.winAccelMgr;
|
mgr = theApp.winAccelMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AccelEditor::DoDataExchange(CDataExchange* pDX)
|
void AccelEditor::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
//{{AFX_DATA_MAP(AccelEditor)
|
//{{AFX_DATA_MAP(AccelEditor)
|
||||||
DDX_Control(pDX, IDC_CURRENTS, m_currents);
|
DDX_Control(pDX, IDC_CURRENTS, m_currents);
|
||||||
DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected);
|
DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected);
|
||||||
DDX_Control(pDX, IDC_COMMANDS, m_commands);
|
DDX_Control(pDX, IDC_COMMANDS, m_commands);
|
||||||
DDX_Control(pDX, IDC_EDIT_KEY, m_key);
|
DDX_Control(pDX, IDC_EDIT_KEY, m_key);
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
|
BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
|
||||||
//{{AFX_MSG_MAP(AccelEditor)
|
//{{AFX_MSG_MAP(AccelEditor)
|
||||||
ON_BN_CLICKED(ID_OK, OnOk)
|
ON_BN_CLICKED(ID_OK, OnOk)
|
||||||
ON_LBN_SELCHANGE(IDC_COMMANDS, OnSelchangeCommands)
|
ON_LBN_SELCHANGE(IDC_COMMANDS, OnSelchangeCommands)
|
||||||
ON_BN_CLICKED(IDC_RESET, OnReset)
|
ON_BN_CLICKED(IDC_RESET, OnReset)
|
||||||
ON_BN_CLICKED(IDC_ASSIGN, OnAssign)
|
ON_BN_CLICKED(IDC_ASSIGN, OnAssign)
|
||||||
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
||||||
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
|
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AccelEditor message handlers
|
// AccelEditor message handlers
|
||||||
|
|
||||||
BOOL AccelEditor::OnInitDialog()
|
BOOL AccelEditor::OnInitDialog()
|
||||||
{
|
{
|
||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
DIALOG_SIZER_START( sz )
|
DIALOG_SIZER_START(sz)
|
||||||
DIALOG_SIZER_ENTRY( IDC_STATIC1, DS_MoveX)
|
DIALOG_SIZER_ENTRY(IDC_STATIC1, DS_MoveX)
|
||||||
DIALOG_SIZER_ENTRY( IDC_STATIC2, DS_MoveY)
|
DIALOG_SIZER_ENTRY(IDC_STATIC2, DS_MoveY)
|
||||||
DIALOG_SIZER_ENTRY( IDC_STATIC3, DS_MoveX | DS_MoveY)
|
DIALOG_SIZER_ENTRY(IDC_STATIC3, DS_MoveX | DS_MoveY)
|
||||||
DIALOG_SIZER_ENTRY( IDC_ALREADY_AFFECTED, DS_MoveY)
|
DIALOG_SIZER_ENTRY(IDC_ALREADY_AFFECTED, DS_MoveY)
|
||||||
DIALOG_SIZER_ENTRY( ID_OK, DS_MoveX)
|
DIALOG_SIZER_ENTRY(ID_OK, DS_MoveX)
|
||||||
DIALOG_SIZER_ENTRY( ID_CANCEL, DS_MoveX)
|
DIALOG_SIZER_ENTRY(ID_CANCEL, DS_MoveX)
|
||||||
DIALOG_SIZER_ENTRY( IDC_ASSIGN, DS_MoveX)
|
DIALOG_SIZER_ENTRY(IDC_ASSIGN, DS_MoveX)
|
||||||
DIALOG_SIZER_ENTRY( IDC_REMOVE, DS_MoveX)
|
DIALOG_SIZER_ENTRY(IDC_REMOVE, DS_MoveX)
|
||||||
DIALOG_SIZER_ENTRY( IDC_RESET, DS_MoveX)
|
DIALOG_SIZER_ENTRY(IDC_RESET, DS_MoveX)
|
||||||
DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY)
|
DIALOG_SIZER_ENTRY(IDC_CLOSE, DS_MoveY)
|
||||||
DIALOG_SIZER_ENTRY( IDC_COMMANDS, DS_SizeX | DS_SizeY)
|
DIALOG_SIZER_ENTRY(IDC_COMMANDS, DS_SizeX | DS_SizeY)
|
||||||
DIALOG_SIZER_ENTRY( IDC_CURRENTS, DS_MoveX | DS_SizeY)
|
DIALOG_SIZER_ENTRY(IDC_CURRENTS, DS_MoveX | DS_SizeY)
|
||||||
DIALOG_SIZER_ENTRY( IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
|
DIALOG_SIZER_ENTRY(IDC_EDIT_KEY, DS_MoveX | DS_MoveY)
|
||||||
DIALOG_SIZER_END()
|
DIALOG_SIZER_END()
|
||||||
|
|
||||||
SetData(sz,
|
SetData(sz,
|
||||||
TRUE,
|
TRUE,
|
||||||
HKEY_CURRENT_USER,
|
HKEY_CURRENT_USER,
|
||||||
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor",
|
"Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
InitCommands();
|
InitCommands();
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::InitCommands()
|
void AccelEditor::InitCommands()
|
||||||
{
|
{
|
||||||
m_commands.ResetContent();
|
m_commands.ResetContent();
|
||||||
m_alreadyAffected.SetWindowText("");
|
m_alreadyAffected.SetWindowText("");
|
||||||
|
|
||||||
POSITION pos = mgr.m_mapAccelString.GetStartPosition();
|
POSITION pos = mgr.m_mapAccelString.GetStartPosition();
|
||||||
|
|
||||||
while(pos != NULL) {
|
while (pos != NULL) {
|
||||||
CString command;
|
CString command;
|
||||||
WORD wID;
|
WORD wID;
|
||||||
mgr.m_mapAccelString.GetNextAssoc(pos, command, wID);
|
mgr.m_mapAccelString.GetNextAssoc(pos, command, wID);
|
||||||
|
|
||||||
int index = m_commands.AddString(command);
|
int index = m_commands.AddString(command);
|
||||||
m_commands.SetItemData(index, wID);
|
m_commands.SetItemData(index, wID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the currents accels associated with the selected command
|
// Update the currents accels associated with the selected command
|
||||||
if (m_commands.SetCurSel(0) != LB_ERR)
|
if (m_commands.SetCurSel(0) != LB_ERR)
|
||||||
OnSelchangeCommands();
|
OnSelchangeCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnCancel()
|
void AccelEditor::OnCancel()
|
||||||
{
|
{
|
||||||
EndDialog(FALSE);
|
EndDialog(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnOk()
|
void AccelEditor::OnOk()
|
||||||
{
|
{
|
||||||
EndDialog(TRUE);
|
EndDialog(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnSelchangeCommands()
|
void AccelEditor::OnSelchangeCommands()
|
||||||
{
|
{
|
||||||
// Check if some commands exist.
|
// Check if some commands exist.
|
||||||
int index = m_commands.GetCurSel();
|
int index = m_commands.GetCurSel();
|
||||||
if (index == LB_ERR)
|
if (index == LB_ERR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WORD wIDCommand = LOWORD(m_commands.GetItemData(index));
|
WORD wIDCommand = LOWORD(m_commands.GetItemData(index));
|
||||||
m_currents.ResetContent();
|
m_currents.ResetContent();
|
||||||
|
|
||||||
CCmdAccelOb* pCmdAccel;
|
CCmdAccelOb* pCmdAccel;
|
||||||
|
|
||||||
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
|
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
CString szBuffer;
|
CString szBuffer;
|
||||||
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
||||||
|
|
||||||
// Add the keys to the 'currents keys' listbox.
|
// Add the keys to the 'currents keys' listbox.
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
||||||
pAccel->GetString(szBuffer);
|
pAccel->GetString(szBuffer);
|
||||||
index = m_currents.AddString(szBuffer);
|
index = m_currents.AddString(szBuffer);
|
||||||
// and a pointer to the accel object.
|
// and a pointer to the accel object.
|
||||||
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
|
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// Init the key editor
|
||||||
// Init the key editor
|
// m_pKey->ResetKey();
|
||||||
// m_pKey->ResetKey();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnReset()
|
void AccelEditor::OnReset()
|
||||||
{
|
{
|
||||||
mgr.Default();
|
mgr.Default();
|
||||||
InitCommands(); // update the listboxes.
|
InitCommands(); // update the listboxes.
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnAssign()
|
void AccelEditor::OnAssign()
|
||||||
{
|
{
|
||||||
// Control if it's not already affected
|
// Control if it's not already affected
|
||||||
CCmdAccelOb* pCmdAccel;
|
CCmdAccelOb* pCmdAccel;
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
WORD wIDCommand;
|
WORD wIDCommand;
|
||||||
POSITION pos;
|
POSITION pos;
|
||||||
|
|
||||||
WORD wKey;
|
WORD wKey;
|
||||||
bool bCtrl, bAlt, bShift;
|
bool bCtrl, bAlt, bShift;
|
||||||
|
|
||||||
if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
|
if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift))
|
||||||
return; // no valid key, abort
|
return; // no valid key, abort
|
||||||
|
|
||||||
int count = m_commands.GetCount();
|
int count = m_commands.GetCount();
|
||||||
int index;
|
int index;
|
||||||
for (index = 0; index < count; index++) {
|
for (index = 0; index < count; index++) {
|
||||||
|
|
||||||
wIDCommand = LOWORD(m_commands.GetItemData(index));
|
wIDCommand = LOWORD(m_commands.GetItemData(index));
|
||||||
mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
|
mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
|
||||||
|
|
||||||
pos = pCmdAccel->m_Accels.GetHeadPosition();
|
pos = pCmdAccel->m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
||||||
if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) {
|
if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) {
|
||||||
// the key is already affected (in the same or other command)
|
// the key is already affected (in the same or other command)
|
||||||
m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand);
|
m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand);
|
||||||
m_key.SetSel(0, -1);
|
m_key.SetSel(0, -1);
|
||||||
return; // abort
|
return; // abort
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// OK, we can add the accel key in the currently selected group
|
// OK, we can add the accel key in the currently selected group
|
||||||
index = m_commands.GetCurSel();
|
index = m_commands.GetCurSel();
|
||||||
if (index == LB_ERR)
|
if (index == LB_ERR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the object who manage the accels list, associated to the command.
|
// Get the object who manage the accels list, associated to the command.
|
||||||
wIDCommand = LOWORD(m_commands.GetItemData(index));
|
wIDCommand = LOWORD(m_commands.GetItemData(index));
|
||||||
|
|
||||||
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE)
|
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BYTE cVirt = 0;
|
BYTE cVirt = 0;
|
||||||
if (bCtrl)
|
if (bCtrl)
|
||||||
cVirt |= FCONTROL;
|
cVirt |= FCONTROL;
|
||||||
if (bAlt)
|
if (bAlt)
|
||||||
cVirt |= FALT;
|
cVirt |= FALT;
|
||||||
if (bShift)
|
if (bShift)
|
||||||
cVirt |= FSHIFT;
|
cVirt |= FSHIFT;
|
||||||
|
|
||||||
cVirt |= FVIRTKEY;
|
cVirt |= FVIRTKEY;
|
||||||
|
|
||||||
// Create the new key...
|
// Create the new key...
|
||||||
pAccel = new CAccelsOb(cVirt, wKey, false);
|
pAccel = new CAccelsOb(cVirt, wKey, false);
|
||||||
ASSERT(pAccel != NULL);
|
ASSERT(pAccel != NULL);
|
||||||
// ...and add in the list.
|
// ...and add in the list.
|
||||||
pCmdAccel->m_Accels.AddTail(pAccel);
|
pCmdAccel->m_Accels.AddTail(pAccel);
|
||||||
|
|
||||||
// Update the listbox.
|
// Update the listbox.
|
||||||
CString szBuffer;
|
CString szBuffer;
|
||||||
pAccel->GetString(szBuffer);
|
pAccel->GetString(szBuffer);
|
||||||
|
|
||||||
index = m_currents.AddString(szBuffer);
|
index = m_currents.AddString(szBuffer);
|
||||||
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
|
m_currents.SetItemData(index, (DWORD_PTR)pAccel);
|
||||||
|
|
||||||
// Reset the key editor.
|
// Reset the key editor.
|
||||||
m_key.ResetKey();
|
m_key.ResetKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnRemove()
|
void AccelEditor::OnRemove()
|
||||||
{
|
{
|
||||||
// Some controls
|
// Some controls
|
||||||
int indexCurrent = m_currents.GetCurSel();
|
int indexCurrent = m_currents.GetCurSel();
|
||||||
if (indexCurrent == LB_ERR)
|
if (indexCurrent == LB_ERR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2nd part.
|
// 2nd part.
|
||||||
int indexCmd = m_commands.GetCurSel();
|
int indexCmd = m_commands.GetCurSel();
|
||||||
if (indexCmd == LB_ERR)
|
if (indexCmd == LB_ERR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ref to the ID command
|
// Ref to the ID command
|
||||||
WORD wIDCommand = LOWORD(m_commands.GetItemData(indexCmd));
|
WORD wIDCommand = LOWORD(m_commands.GetItemData(indexCmd));
|
||||||
|
|
||||||
// Run through the accels,and control if it can be deleted.
|
// Run through the accels,and control if it can be deleted.
|
||||||
CCmdAccelOb* pCmdAccel;
|
CCmdAccelOb* pCmdAccel;
|
||||||
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
|
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) {
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
CAccelsOb* pAccelCurrent = (CAccelsOb*)(m_currents.GetItemData(indexCurrent));
|
CAccelsOb* pAccelCurrent = (CAccelsOb*)(m_currents.GetItemData(indexCurrent));
|
||||||
CString szBuffer;
|
CString szBuffer;
|
||||||
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
||||||
POSITION PrevPos;
|
POSITION PrevPos;
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
PrevPos = pos;
|
PrevPos = pos;
|
||||||
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
||||||
if (pAccel == pAccelCurrent) {
|
if (pAccel == pAccelCurrent) {
|
||||||
if (!pAccel->m_bLocked) {
|
if (!pAccel->m_bLocked) {
|
||||||
// not locked, so we delete the key
|
// not locked, so we delete the key
|
||||||
pCmdAccel->m_Accels.RemoveAt(PrevPos);
|
pCmdAccel->m_Accels.RemoveAt(PrevPos);
|
||||||
delete pAccel;
|
delete pAccel;
|
||||||
// and update the listboxes/key editor/static text
|
// and update the listboxes/key editor/static text
|
||||||
m_currents.DeleteString(indexCurrent);
|
m_currents.DeleteString(indexCurrent);
|
||||||
m_key.ResetKey();
|
m_key.ResetKey();
|
||||||
m_alreadyAffected.SetWindowText("");
|
m_alreadyAffected.SetWindowText("");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
systemMessage(0,"Unable to remove this\naccelerator (Locked)");
|
systemMessage(0, "Unable to remove this\naccelerator (Locked)");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
systemMessage(0, "internal error (CAccelDlgHelper::Remove : pAccel unavailable)");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
systemMessage(0,"internal error (CAccelDlgHelper::Remove : pAccel unavailable)");
|
systemMessage(0, "internal error (CAccelDlgHelper::Remove : Lookup failed)");
|
||||||
return;
|
|
||||||
}
|
|
||||||
systemMessage(0,"internal error (CAccelDlgHelper::Remove : Lookup failed)");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,43 +13,42 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AccelEditor dialog
|
// AccelEditor dialog
|
||||||
|
|
||||||
class AccelEditor : public ResizeDlg
|
class AccelEditor : public ResizeDlg {
|
||||||
{
|
// Construction
|
||||||
// Construction
|
public:
|
||||||
public:
|
CAcceleratorManager mgr;
|
||||||
CAcceleratorManager mgr;
|
void InitCommands();
|
||||||
void InitCommands();
|
AccelEditor(CWnd* pParent = NULL); // standard constructor
|
||||||
AccelEditor(CWnd *pParent = NULL); // standard constructor
|
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
//{{AFX_DATA(AccelEditor)
|
//{{AFX_DATA(AccelEditor)
|
||||||
enum { IDD = IDD_ACCEL_EDITOR };
|
enum { IDD = IDD_ACCEL_EDITOR };
|
||||||
CListBox m_currents;
|
CListBox m_currents;
|
||||||
CStatic m_alreadyAffected;
|
CStatic m_alreadyAffected;
|
||||||
CListBox m_commands;
|
CListBox m_commands;
|
||||||
CKeyboardEdit m_key;
|
CKeyboardEdit m_key;
|
||||||
//}}AFX_DATA
|
//}}AFX_DATA
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
// ClassWizard generated virtual function overrides
|
// ClassWizard generated virtual function overrides
|
||||||
//{{AFX_VIRTUAL(AccelEditor)
|
//{{AFX_VIRTUAL(AccelEditor)
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
protected:
|
protected:
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
//{{AFX_MSG(AccelEditor)
|
//{{AFX_MSG(AccelEditor)
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
afx_msg void OnCancel();
|
afx_msg void OnCancel();
|
||||||
afx_msg void OnOk();
|
afx_msg void OnOk();
|
||||||
afx_msg void OnSelchangeCommands();
|
afx_msg void OnSelchangeCommands();
|
||||||
afx_msg void OnReset();
|
afx_msg void OnReset();
|
||||||
afx_msg void OnAssign();
|
afx_msg void OnAssign();
|
||||||
afx_msg void OnRemove();
|
afx_msg void OnRemove();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
||||||
//{{AFX_INSERT_LOCATION}}
|
//{{AFX_INSERT_LOCATION}}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,112 +37,111 @@
|
||||||
// Helper map
|
// Helper map
|
||||||
#include <afxtempl.h> // MFC Templates extension
|
#include <afxtempl.h> // MFC Templates extension
|
||||||
#ifndef CMapStringToWord
|
#ifndef CMapStringToWord
|
||||||
typedef CMap<CString, LPCSTR, WORD, WORD &> CMapStringToWord;
|
typedef CMap<CString, LPCSTR, WORD, WORD&> CMapStringToWord;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CMapWordToCCmdAccelOb
|
#ifndef CMapWordToCCmdAccelOb
|
||||||
typedef CMap<WORD, WORD &, CCmdAccelOb *, CCmdAccelOb *&> CMapWordToCCmdAccelOb;
|
typedef CMap<WORD, WORD&, CCmdAccelOb*, CCmdAccelOb*&> CMapWordToCCmdAccelOb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
class CAcceleratorManager : public CObject
|
class CAcceleratorManager : public CObject {
|
||||||
{
|
friend class AccelEditor;
|
||||||
friend class AccelEditor;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAcceleratorManager();
|
CAcceleratorManager();
|
||||||
virtual ~CAcceleratorManager();
|
virtual ~CAcceleratorManager();
|
||||||
|
|
||||||
// Operations
|
// Operations
|
||||||
public:
|
public:
|
||||||
void UpdateMenu(HMENU menu);
|
void UpdateMenu(HMENU menu);
|
||||||
void UpdateMenu();
|
void UpdateMenu();
|
||||||
// Connection to the main application wnd
|
// Connection to the main application wnd
|
||||||
void Connect(CWnd *pWnd, bool bAutoSave = true);
|
void Connect(CWnd* pWnd, bool bAutoSave = true);
|
||||||
// In/Out with the registry
|
// In/Out with the registry
|
||||||
bool Load(HKEY hRegKey, LPCTSTR szRegKey);
|
bool Load(HKEY hRegKey, LPCTSTR szRegKey);
|
||||||
bool Load();
|
bool Load();
|
||||||
bool Write();
|
bool Write();
|
||||||
// Get the initials accels, not the user's
|
// Get the initials accels, not the user's
|
||||||
bool Default();
|
bool Default();
|
||||||
// Save a copy in the 2 maps called xxxSaved, which are used in case
|
// Save a copy in the 2 maps called xxxSaved, which are used in case
|
||||||
// of Default(), to reload the defaults accels.
|
// of Default(), to reload the defaults accels.
|
||||||
bool CreateDefaultTable();
|
bool CreateDefaultTable();
|
||||||
bool IsDefaultTableAvailable()
|
bool IsDefaultTableAvailable()
|
||||||
{
|
{
|
||||||
return m_bDefaultTable;
|
return m_bDefaultTable;
|
||||||
}
|
}
|
||||||
bool IsMapStringCommandsEmpty()
|
bool IsMapStringCommandsEmpty()
|
||||||
{
|
{
|
||||||
if (m_mapAccelString.IsEmpty())
|
if (m_mapAccelString.IsEmpty())
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registry access configuration
|
// Registry access configuration
|
||||||
bool GetRegKey(HKEY &hRegKey, CString &szRegKey);
|
bool GetRegKey(HKEY& hRegKey, CString& szRegKey);
|
||||||
bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey);
|
bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey);
|
||||||
bool IsAutoSave()
|
bool IsAutoSave()
|
||||||
{
|
{
|
||||||
return m_bAutoSave;
|
return m_bAutoSave;
|
||||||
}
|
}
|
||||||
void SetAutoSave(bool bAutoSave)
|
void SetAutoSave(bool bAutoSave)
|
||||||
{
|
{
|
||||||
m_bAutoSave = bAutoSave;
|
m_bAutoSave = bAutoSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper fct, used for new menus strings
|
// Helper fct, used for new menus strings
|
||||||
bool GetStringFromACCEL(ACCEL *pACCEL, CString &szAccel);
|
bool GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel);
|
||||||
bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString &szAccel);
|
bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel);
|
||||||
|
|
||||||
// Update the ACCELS table in the application, from the specified
|
// Update the ACCELS table in the application, from the specified
|
||||||
// datas in the manager.
|
// datas in the manager.
|
||||||
bool UpdateWndTable();
|
bool UpdateWndTable();
|
||||||
|
|
||||||
// Modification helper fcts
|
// Modification helper fcts
|
||||||
bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, LPCTSTR szCommand,
|
bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, LPCTSTR szCommand,
|
||||||
bool bLocked = false);
|
bool bLocked = false);
|
||||||
bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
|
bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true);
|
||||||
bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
|
bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand);
|
||||||
|
|
||||||
bool DeleteEntry(LPCTSTR szCommand);
|
bool DeleteEntry(LPCTSTR szCommand);
|
||||||
bool DeleteEntry(WORD wIDCommand);
|
bool DeleteEntry(WORD wIDCommand);
|
||||||
bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
|
bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract);
|
||||||
|
|
||||||
// Affectation operator
|
// Affectation operator
|
||||||
CAcceleratorManager &operator=(const CAcceleratorManager &accelmgr);
|
CAcceleratorManager& operator=(const CAcceleratorManager& accelmgr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
virtual void AssertValid() const;
|
virtual void AssertValid() const;
|
||||||
virtual void Dump(CDumpContext &dc) const;
|
virtual void Dump(CDumpContext& dc) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Erase all the datas
|
// Erase all the datas
|
||||||
void Reset();
|
void Reset();
|
||||||
// Internal affect fct.
|
// Internal affect fct.
|
||||||
bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked);
|
bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked);
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
protected:
|
protected:
|
||||||
CWnd *m_pWndConnected;
|
CWnd* m_pWndConnected;
|
||||||
|
|
||||||
// User datas
|
// User datas
|
||||||
CMapStringToWord m_mapAccelString;
|
CMapStringToWord m_mapAccelString;
|
||||||
CMapWordToCCmdAccelOb m_mapAccelTable;
|
CMapWordToCCmdAccelOb m_mapAccelTable;
|
||||||
// Default datas
|
// Default datas
|
||||||
CMapWordToCCmdAccelOb m_mapAccelTableSaved;
|
CMapWordToCCmdAccelOb m_mapAccelTableSaved;
|
||||||
bool m_bDefaultTable;
|
bool m_bDefaultTable;
|
||||||
|
|
||||||
// Where the users datas will be saved in the registry
|
// Where the users datas will be saved in the registry
|
||||||
HKEY m_hRegKey;
|
HKEY m_hRegKey;
|
||||||
CString m_szRegKey;
|
CString m_szRegKey;
|
||||||
// if true, there is an auto-save in the registry, when the destructor is called
|
// if true, there is an auto-save in the registry, when the destructor is called
|
||||||
bool m_bAutoSave;
|
bool m_bAutoSave;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
|
#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "vba.h"
|
|
||||||
#include "Associate.h"
|
#include "Associate.h"
|
||||||
#include "Reg.h"
|
#include "Reg.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "vba.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -12,101 +12,98 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Associate dialog
|
// Associate dialog
|
||||||
|
|
||||||
|
|
||||||
Associate::Associate(CWnd* pParent /*=NULL*/)
|
Associate::Associate(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(Associate::IDD, pParent)
|
: CDialog(Associate::IDD, pParent)
|
||||||
{
|
{
|
||||||
//{{AFX_DATA_INIT(Associate)
|
//{{AFX_DATA_INIT(Associate)
|
||||||
m_agb = FALSE;
|
m_agb = FALSE;
|
||||||
m_bin = FALSE;
|
m_bin = FALSE;
|
||||||
m_cgb = FALSE;
|
m_cgb = FALSE;
|
||||||
m_dmg = FALSE;
|
m_dmg = FALSE;
|
||||||
m_gb = FALSE;
|
m_gb = FALSE;
|
||||||
m_gba = FALSE;
|
m_gba = FALSE;
|
||||||
m_gbc = FALSE;
|
m_gbc = FALSE;
|
||||||
m_sgb = FALSE;
|
m_sgb = FALSE;
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Associate::DoDataExchange(CDataExchange* pDX)
|
void Associate::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
//{{AFX_DATA_MAP(Associate)
|
//{{AFX_DATA_MAP(Associate)
|
||||||
DDX_Check(pDX, IDC_AGB, m_agb);
|
DDX_Check(pDX, IDC_AGB, m_agb);
|
||||||
DDX_Check(pDX, IDC_BIN, m_bin);
|
DDX_Check(pDX, IDC_BIN, m_bin);
|
||||||
DDX_Check(pDX, IDC_CGB, m_cgb);
|
DDX_Check(pDX, IDC_CGB, m_cgb);
|
||||||
DDX_Check(pDX, IDC_DMG, m_dmg);
|
DDX_Check(pDX, IDC_DMG, m_dmg);
|
||||||
DDX_Check(pDX, IDC_GB, m_gb);
|
DDX_Check(pDX, IDC_GB, m_gb);
|
||||||
DDX_Check(pDX, IDC_GBA, m_gba);
|
DDX_Check(pDX, IDC_GBA, m_gba);
|
||||||
DDX_Check(pDX, IDC_GBC, m_gbc);
|
DDX_Check(pDX, IDC_GBC, m_gbc);
|
||||||
DDX_Check(pDX, IDC_SGB, m_sgb);
|
DDX_Check(pDX, IDC_SGB, m_sgb);
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(Associate, CDialog)
|
BEGIN_MESSAGE_MAP(Associate, CDialog)
|
||||||
//{{AFX_MSG_MAP(Associate)
|
//{{AFX_MSG_MAP(Associate)
|
||||||
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
||||||
ON_BN_CLICKED(ID_OK, OnOk)
|
ON_BN_CLICKED(ID_OK, OnOk)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Associate message handlers
|
// Associate message handlers
|
||||||
|
|
||||||
BOOL Associate::OnInitDialog()
|
BOOL Associate::OnInitDialog()
|
||||||
{
|
{
|
||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
CenterWindow();
|
CenterWindow();
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
void Associate::OnCancel()
|
void Associate::OnCancel()
|
||||||
{
|
{
|
||||||
EndDialog(FALSE);
|
EndDialog(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Associate::OnOk()
|
void Associate::OnOk()
|
||||||
{
|
{
|
||||||
UpdateData();
|
UpdateData();
|
||||||
|
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
if(m_gb)
|
if (m_gb)
|
||||||
mask |= 1;
|
mask |= 1;
|
||||||
if(m_dmg)
|
if (m_dmg)
|
||||||
mask |= 2;
|
mask |= 2;
|
||||||
if(m_sgb)
|
if (m_sgb)
|
||||||
mask |= 4;
|
mask |= 4;
|
||||||
if(m_cgb)
|
if (m_cgb)
|
||||||
mask |= 8;
|
mask |= 8;
|
||||||
if(m_gbc)
|
if (m_gbc)
|
||||||
mask |= 16;
|
mask |= 16;
|
||||||
if(m_gba)
|
if (m_gba)
|
||||||
mask |= 32;
|
mask |= 32;
|
||||||
if(m_agb)
|
if (m_agb)
|
||||||
mask |= 64;
|
mask |= 64;
|
||||||
if(m_bin)
|
if (m_bin)
|
||||||
mask |= 128;
|
mask |= 128;
|
||||||
if(mask) {
|
if (mask) {
|
||||||
char applicationPath[2048];
|
char applicationPath[2048];
|
||||||
CString commandPath;
|
CString commandPath;
|
||||||
LPCTSTR types[] = { "*.dmg", ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
|
LPCTSTR types[] = { "*.dmg", ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
|
||||||
GetModuleFileName(NULL, applicationPath, 2048);
|
GetModuleFileName(NULL, applicationPath, 2048);
|
||||||
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
|
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
|
||||||
regAssociateType("VisualBoyAdvance.Binary",
|
regAssociateType("VisualBoyAdvance.Binary",
|
||||||
"Binary",
|
"Binary",
|
||||||
commandPath,
|
commandPath,
|
||||||
"%SystemRoot%\\system32\\SHELL32.dll,-13");
|
"%SystemRoot%\\system32\\SHELL32.dll,-13");
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
if(mask & (1<<i)) {
|
if (mask & (1 << i)) {
|
||||||
regCreateFileType(types[i],"VisualBoyAdvance.Binary");
|
regCreateFileType(types[i], "VisualBoyAdvance.Binary");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
EndDialog(TRUE);
|
||||||
EndDialog(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,41 +10,40 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Associate dialog
|
// Associate dialog
|
||||||
|
|
||||||
class Associate : public CDialog
|
class Associate : public CDialog {
|
||||||
{
|
// Construction
|
||||||
// Construction
|
public:
|
||||||
public:
|
Associate(CWnd* pParent = NULL); // standard constructor
|
||||||
Associate(CWnd *pParent = NULL); // standard constructor
|
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
//{{AFX_DATA(Associate)
|
//{{AFX_DATA(Associate)
|
||||||
enum { IDD = IDD_ASSOCIATIONS };
|
enum { IDD = IDD_ASSOCIATIONS };
|
||||||
BOOL m_agb;
|
BOOL m_agb;
|
||||||
BOOL m_bin;
|
BOOL m_bin;
|
||||||
BOOL m_cgb;
|
BOOL m_cgb;
|
||||||
BOOL m_dmg;
|
BOOL m_dmg;
|
||||||
BOOL m_gb;
|
BOOL m_gb;
|
||||||
BOOL m_gba;
|
BOOL m_gba;
|
||||||
BOOL m_gbc;
|
BOOL m_gbc;
|
||||||
BOOL m_sgb;
|
BOOL m_sgb;
|
||||||
//}}AFX_DATA
|
//}}AFX_DATA
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
// ClassWizard generated virtual function overrides
|
// ClassWizard generated virtual function overrides
|
||||||
//{{AFX_VIRTUAL(Associate)
|
//{{AFX_VIRTUAL(Associate)
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
protected:
|
protected:
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
//{{AFX_MSG(Associate)
|
//{{AFX_MSG(Associate)
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
afx_msg void OnCancel();
|
afx_msg void OnCancel();
|
||||||
afx_msg void OnOk();
|
afx_msg void OnOk();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
||||||
//{{AFX_INSERT_LOCATION}}
|
//{{AFX_INSERT_LOCATION}}
|
||||||
|
|
|
@ -1,191 +1,188 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "VBA.h"
|
#include "VBA.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "AudioCoreSettingsDlg.h"
|
#include "AudioCoreSettingsDlg.h"
|
||||||
|
|
||||||
#define MIN_VOLUME 0.0f
|
#define MIN_VOLUME 0.0f
|
||||||
#define MAX_VOLUME 4.0f
|
#define MAX_VOLUME 4.0f
|
||||||
|
|
||||||
|
|
||||||
// AudioCoreSettingsDlg dialog
|
// AudioCoreSettingsDlg dialog
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog)
|
IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog)
|
||||||
|
|
||||||
AudioCoreSettingsDlg::AudioCoreSettingsDlg(CWnd* pParent /*=NULL*/)
|
AudioCoreSettingsDlg::AudioCoreSettingsDlg(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(AudioCoreSettingsDlg::IDD, pParent)
|
: CDialog(AudioCoreSettingsDlg::IDD, pParent)
|
||||||
, m_enabled( false )
|
, m_enabled(false)
|
||||||
, m_surround( false )
|
, m_surround(false)
|
||||||
, m_declicking( false )
|
, m_declicking(false)
|
||||||
, m_sound_interpolation( false )
|
, m_sound_interpolation(false)
|
||||||
, m_echo( 0.0f )
|
, m_echo(0.0f)
|
||||||
, m_stereo( 0.0f )
|
, m_stereo(0.0f)
|
||||||
, m_volume( 0.0f )
|
, m_volume(0.0f)
|
||||||
, m_sound_filtering( 0.0f )
|
, m_sound_filtering(0.0f)
|
||||||
, m_sample_rate( 0 )
|
, m_sample_rate(0)
|
||||||
, toolTip( NULL )
|
, toolTip(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioCoreSettingsDlg::~AudioCoreSettingsDlg()
|
AudioCoreSettingsDlg::~AudioCoreSettingsDlg()
|
||||||
{
|
{
|
||||||
delete toolTip;
|
delete toolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
|
void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
|
|
||||||
DDX_Control(pDX, IDC_ENHANCE_SOUND, enhance_sound);
|
DDX_Control(pDX, IDC_ENHANCE_SOUND, enhance_sound);
|
||||||
DDX_Control(pDX, IDC_SURROUND, surround);
|
DDX_Control(pDX, IDC_SURROUND, surround);
|
||||||
DDX_Control(pDX, IDC_ECHO, echo);
|
DDX_Control(pDX, IDC_ECHO, echo);
|
||||||
DDX_Control(pDX, IDC_STEREO, stereo);
|
DDX_Control(pDX, IDC_STEREO, stereo);
|
||||||
DDX_Control(pDX, IDC_VOLUME, volume);
|
DDX_Control(pDX, IDC_VOLUME, volume);
|
||||||
DDX_Control(pDX, IDC_DECLICKING, declicking);
|
DDX_Control(pDX, IDC_DECLICKING, declicking);
|
||||||
DDX_Control(pDX, IDC_SOUND_INTERPOLATION, sound_interpolation);
|
DDX_Control(pDX, IDC_SOUND_INTERPOLATION, sound_interpolation);
|
||||||
DDX_Control(pDX, IDC_SOUND_FILTERING, sound_filtering);
|
DDX_Control(pDX, IDC_SOUND_FILTERING, sound_filtering);
|
||||||
DDX_Control(pDX, IDC_SAMPLE_RATE, sample_rate);
|
DDX_Control(pDX, IDC_SAMPLE_RATE, sample_rate);
|
||||||
|
|
||||||
if( pDX->m_bSaveAndValidate == TRUE ) {
|
if (pDX->m_bSaveAndValidate == TRUE) {
|
||||||
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
|
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
|
||||||
m_surround = BST_CHECKED == surround.GetCheck();
|
m_surround = BST_CHECKED == surround.GetCheck();
|
||||||
m_declicking = BST_CHECKED == declicking.GetCheck();
|
m_declicking = BST_CHECKED == declicking.GetCheck();
|
||||||
m_sound_interpolation = BST_CHECKED == sound_interpolation.GetCheck();
|
m_sound_interpolation = BST_CHECKED == sound_interpolation.GetCheck();
|
||||||
m_echo = (float)echo.GetPos() / 100.0f;
|
m_echo = (float)echo.GetPos() / 100.0f;
|
||||||
m_stereo = (float)stereo.GetPos() / 100.0f;
|
m_stereo = (float)stereo.GetPos() / 100.0f;
|
||||||
m_volume = (float)volume.GetPos() / 100.0f;
|
m_volume = (float)volume.GetPos() / 100.0f;
|
||||||
m_sound_filtering = (float)sound_filtering.GetPos() / 100.0f;
|
m_sound_filtering = (float)sound_filtering.GetPos() / 100.0f;
|
||||||
m_sample_rate = (unsigned int)sample_rate.GetItemData( sample_rate.GetCurSel() );
|
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
|
TOOLTIPTEXT* t3 = (TOOLTIPTEXT*)pNMHDR; // dirty Windows API
|
||||||
BOOL i_provided_tooltip_with_text = TRUE;
|
BOOL i_provided_tooltip_with_text = TRUE;
|
||||||
|
|
||||||
if( !( t3->uFlags & TTF_IDISHWND ) ) {
|
if (!(t3->uFlags & TTF_IDISHWND)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// even dirtier Windows API:
|
// even dirtier Windows API:
|
||||||
// t3->hdr.idFrom is actually a HWND, holy cow, why?
|
// t3->hdr.idFrom is actually a HWND, holy cow, why?
|
||||||
// The other case does not even occur.
|
// The other case does not even occur.
|
||||||
int controlID = ::GetDlgCtrlID( (HWND)t3->hdr.idFrom );
|
int controlID = ::GetDlgCtrlID((HWND)t3->hdr.idFrom);
|
||||||
CString res;
|
CString res;
|
||||||
TCHAR buf[0x400]; // Use own string buffer because szText has an 80 char limit.
|
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
|
// 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
|
// t3->lpszText at the end of this function, so we have no chance to free the buffer
|
||||||
// before the end of this function.
|
// before the end of this function.
|
||||||
|
|
||||||
switch( controlID ) {
|
switch (controlID) {
|
||||||
case IDC_VOLUME:
|
case IDC_VOLUME:
|
||||||
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), volume.GetPos() );
|
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), volume.GetPos());
|
||||||
break;
|
break;
|
||||||
case IDC_ECHO:
|
case IDC_ECHO:
|
||||||
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), echo.GetPos() );
|
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), echo.GetPos());
|
||||||
break;
|
break;
|
||||||
case IDC_STEREO:
|
case IDC_STEREO:
|
||||||
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), stereo.GetPos() );
|
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), stereo.GetPos());
|
||||||
break;
|
break;
|
||||||
case IDC_SOUND_FILTERING:
|
case IDC_SOUND_FILTERING:
|
||||||
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), sound_filtering.GetPos() );
|
_stprintf_s(t3->szText, _countof(t3->szText), _T( "%i%%" ), sound_filtering.GetPos());
|
||||||
break;
|
break;
|
||||||
case IDC_DEFAULT_VOLUME:
|
case IDC_DEFAULT_VOLUME:
|
||||||
res.LoadString( IDS_TOOLTIP_DEFAULT_VOLUME );
|
res.LoadString(IDS_TOOLTIP_DEFAULT_VOLUME);
|
||||||
_tcscpy_s( buf, _countof( buf ), res.GetString() );
|
_tcscpy_s(buf, _countof(buf), res.GetString());
|
||||||
t3->lpszText = buf;
|
t3->lpszText = buf;
|
||||||
break;
|
break;
|
||||||
case IDC_ENHANCE_SOUND:
|
case IDC_ENHANCE_SOUND:
|
||||||
res.LoadString( IDS_TOOLTIP_ENHANCE_SOUND );
|
res.LoadString(IDS_TOOLTIP_ENHANCE_SOUND);
|
||||||
_tcscpy_s( buf, _countof( buf ), res.GetString() );
|
_tcscpy_s(buf, _countof(buf), res.GetString());
|
||||||
t3->lpszText = buf;
|
t3->lpszText = buf;
|
||||||
break;
|
break;
|
||||||
case IDC_SURROUND:
|
case IDC_SURROUND:
|
||||||
res.LoadString( IDS_TOOLTIP_SURROUND );
|
res.LoadString(IDS_TOOLTIP_SURROUND);
|
||||||
_tcscpy_s( buf, _countof( buf ), res.GetString() );
|
_tcscpy_s(buf, _countof(buf), res.GetString());
|
||||||
t3->lpszText = buf;
|
t3->lpszText = buf;
|
||||||
break;
|
break;
|
||||||
case IDC_DECLICKING:
|
case IDC_DECLICKING:
|
||||||
res.LoadString( IDS_TOOLTIP_DECLICKING );
|
res.LoadString(IDS_TOOLTIP_DECLICKING);
|
||||||
_tcscpy_s( buf, _countof( buf ), res.GetString() );
|
_tcscpy_s(buf, _countof(buf), res.GetString());
|
||||||
t3->lpszText = buf;
|
t3->lpszText = buf;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
i_provided_tooltip_with_text = FALSE;
|
i_provided_tooltip_with_text = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i_provided_tooltip_with_text;
|
return i_provided_tooltip_with_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
|
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
|
||||||
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
|
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
|
||||||
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
|
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
// AudioCoreSettingsDlg message handlers
|
// AudioCoreSettingsDlg message handlers
|
||||||
|
|
||||||
BOOL AudioCoreSettingsDlg::OnInitDialog()
|
BOOL AudioCoreSettingsDlg::OnInitDialog()
|
||||||
{
|
{
|
||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
// Set up tooltip control
|
// Set up tooltip control
|
||||||
toolTip = new CToolTipCtrl;
|
toolTip = new CToolTipCtrl;
|
||||||
toolTip->Create( this );
|
toolTip->Create(this);
|
||||||
toolTip->AddTool( GetDlgItem( IDC_DEFAULT_VOLUME ) );
|
toolTip->AddTool(GetDlgItem(IDC_DEFAULT_VOLUME));
|
||||||
toolTip->AddTool( GetDlgItem( IDC_ENHANCE_SOUND ) );
|
toolTip->AddTool(GetDlgItem(IDC_ENHANCE_SOUND));
|
||||||
toolTip->AddTool( GetDlgItem( IDC_SURROUND ) );
|
toolTip->AddTool(GetDlgItem(IDC_SURROUND));
|
||||||
toolTip->AddTool( GetDlgItem( IDC_DECLICKING ) );
|
toolTip->AddTool(GetDlgItem(IDC_DECLICKING));
|
||||||
toolTip->Activate( TRUE );
|
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.SetRange(0, 100);
|
||||||
echo.SetPos( (int)( m_echo * 100.0f ) );
|
echo.SetPos((int)(m_echo * 100.0f));
|
||||||
|
|
||||||
stereo.SetRange( 0, 100 );
|
stereo.SetRange(0, 100);
|
||||||
stereo.SetPos( (int)( m_stereo * 100.0f ) );
|
stereo.SetPos((int)(m_stereo * 100.0f));
|
||||||
|
|
||||||
sound_filtering.SetRange( 0, 100 );
|
sound_filtering.SetRange(0, 100);
|
||||||
sound_filtering.SetPos( (int)( m_sound_filtering * 100.0f ) );
|
sound_filtering.SetPos((int)(m_sound_filtering * 100.0f));
|
||||||
|
|
||||||
volume.SetRange( (int)( MIN_VOLUME * 100.0f ), (int)( MAX_VOLUME * 100.0f ) );
|
volume.SetRange((int)(MIN_VOLUME * 100.0f), (int)(MAX_VOLUME * 100.0f));
|
||||||
volume.SetPos( (int)( m_volume * 100.0f ) );
|
volume.SetPos((int)(m_volume * 100.0f));
|
||||||
|
|
||||||
unsigned int rate = 44100;
|
unsigned int rate = 44100;
|
||||||
CString temp;
|
CString temp;
|
||||||
for( int i = 0 ; i <= 2 ; i++ ) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
temp.Format( _T("%u Hz"), rate );
|
temp.Format(_T("%u Hz"), rate);
|
||||||
int id = sample_rate.AddString( temp.GetString() );
|
int id = sample_rate.AddString(temp.GetString());
|
||||||
sample_rate.SetItemData( id, rate );
|
sample_rate.SetItemData(id, rate);
|
||||||
if( rate == m_sample_rate ) {
|
if (rate == m_sample_rate) {
|
||||||
sample_rate.SetCurSel( id );
|
sample_rate.SetCurSel(id);
|
||||||
}
|
}
|
||||||
rate /= 2;
|
rate /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL AudioCoreSettingsDlg::PreTranslateMessage(MSG* pMsg)
|
BOOL AudioCoreSettingsDlg::PreTranslateMessage(MSG* pMsg)
|
||||||
{
|
{
|
||||||
// Required for enabling ToolTips in a modal dialog box.
|
// Required for enabling ToolTips in a modal dialog box.
|
||||||
if( NULL != toolTip ) {
|
if (NULL != toolTip) {
|
||||||
toolTip->RelayEvent( pMsg );
|
toolTip->RelayEvent(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CDialog::PreTranslateMessage(pMsg);
|
return CDialog::PreTranslateMessage(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
|
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
|
||||||
{
|
{
|
||||||
volume.SetPos( 100 );
|
volume.SetPos(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,47 +2,46 @@
|
||||||
|
|
||||||
// AudioCoreSettingsDlg dialog
|
// AudioCoreSettingsDlg dialog
|
||||||
|
|
||||||
class AudioCoreSettingsDlg : public CDialog
|
class AudioCoreSettingsDlg : public CDialog {
|
||||||
{
|
DECLARE_DYNAMIC(AudioCoreSettingsDlg)
|
||||||
DECLARE_DYNAMIC(AudioCoreSettingsDlg)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
bool m_surround;
|
bool m_surround;
|
||||||
bool m_declicking;
|
bool m_declicking;
|
||||||
bool m_sound_interpolation;
|
bool m_sound_interpolation;
|
||||||
float m_echo;
|
float m_echo;
|
||||||
float m_stereo;
|
float m_stereo;
|
||||||
float m_volume;
|
float m_volume;
|
||||||
float m_sound_filtering;
|
float m_sound_filtering;
|
||||||
unsigned int m_sample_rate;
|
unsigned int m_sample_rate;
|
||||||
|
|
||||||
AudioCoreSettingsDlg(CWnd *pParent = NULL); // standard constructor
|
AudioCoreSettingsDlg(CWnd* pParent = NULL); // standard constructor
|
||||||
virtual ~AudioCoreSettingsDlg();
|
virtual ~AudioCoreSettingsDlg();
|
||||||
|
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
virtual BOOL PreTranslateMessage(MSG *pMsg);
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||||
afx_msg void OnBnClickedDefaultVolume();
|
afx_msg void OnBnClickedDefaultVolume();
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
enum { IDD = IDD_AUDIO_CORE_SETTINGS };
|
enum { IDD = IDD_AUDIO_CORE_SETTINGS };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
afx_msg BOOL OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult); // Retrieve text for
|
afx_msg BOOL OnTtnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult); // Retrieve text for
|
||||||
// ToolTip
|
// ToolTip
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CButton enhance_sound;
|
CButton enhance_sound;
|
||||||
CButton surround;
|
CButton surround;
|
||||||
CButton declicking;
|
CButton declicking;
|
||||||
CButton sound_interpolation;
|
CButton sound_interpolation;
|
||||||
CSliderCtrl echo;
|
CSliderCtrl echo;
|
||||||
CSliderCtrl stereo;
|
CSliderCtrl stereo;
|
||||||
CSliderCtrl volume;
|
CSliderCtrl volume;
|
||||||
CSliderCtrl sound_filtering;
|
CSliderCtrl sound_filtering;
|
||||||
CToolTipCtrl *toolTip;
|
CToolTipCtrl* toolTip;
|
||||||
CComboBox sample_rate;
|
CComboBox sample_rate;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "VBA.h"
|
#include "VBA.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "BIOSDialog.h"
|
#include "BIOSDialog.h"
|
||||||
|
|
||||||
|
|
||||||
// BIOSDialog dialog
|
// BIOSDialog dialog
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
|
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
|
||||||
|
|
||||||
BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/)
|
BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(BIOSDialog::IDD, pParent)
|
: CDialog(BIOSDialog::IDD, pParent)
|
||||||
, m_enableBIOS_GB(FALSE)
|
, m_enableBIOS_GB(FALSE)
|
||||||
, m_enableBIOS_GBA(FALSE)
|
, m_enableBIOS_GBA(FALSE)
|
||||||
, m_skipLogo(FALSE)
|
, m_skipLogo(FALSE)
|
||||||
, m_pathGB(_T(""))
|
, m_pathGB(_T(""))
|
||||||
, m_pathGBA(_T(""))
|
, m_pathGBA(_T(""))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,115 +23,113 @@ BIOSDialog::~BIOSDialog()
|
||||||
|
|
||||||
void BIOSDialog::DoDataExchange(CDataExchange* pDX)
|
void BIOSDialog::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB);
|
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_GBC_BIOS, m_enableBIOS_GBC);
|
||||||
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
|
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
|
||||||
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
|
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
|
||||||
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
|
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
|
||||||
DDX_Text(pDX, IDC_GBC_BIOS_PATH, m_pathGBC);
|
DDX_Text(pDX, IDC_GBC_BIOS_PATH, m_pathGBC);
|
||||||
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
|
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
|
||||||
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
|
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
|
||||||
DDX_Control(pDX, IDC_GBC_BIOS_PATH, m_editGBC);
|
DDX_Control(pDX, IDC_GBC_BIOS_PATH, m_editGBC);
|
||||||
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
|
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
|
||||||
|
|
||||||
if( pDX->m_bSaveAndValidate == TRUE ) {
|
if (pDX->m_bSaveAndValidate == TRUE) {
|
||||||
// disable BIOS usage when it does not exist
|
// disable BIOS usage when it does not exist
|
||||||
if( !fileExists( m_pathGBA ) ) {
|
if (!fileExists(m_pathGBA)) {
|
||||||
m_enableBIOS_GBA = FALSE;
|
m_enableBIOS_GBA = FALSE;
|
||||||
}
|
}
|
||||||
if( !fileExists( m_pathGBC ) ) {
|
if (!fileExists(m_pathGBC)) {
|
||||||
m_enableBIOS_GBC = FALSE;
|
m_enableBIOS_GBC = FALSE;
|
||||||
}
|
}
|
||||||
if( !fileExists( m_pathGB ) ) {
|
if (!fileExists(m_pathGB)) {
|
||||||
m_enableBIOS_GB = FALSE;
|
m_enableBIOS_GB = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
|
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
|
||||||
ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath)
|
ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath)
|
||||||
ON_BN_CLICKED(IDC_SELECT_GBC_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbcBiosPath)
|
ON_BN_CLICKED(IDC_SELECT_GBC_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbcBiosPath)
|
||||||
ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
|
ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
// BIOSDialog message handlers
|
// BIOSDialog message handlers
|
||||||
|
|
||||||
void BIOSDialog::OnBnClickedSelectGbBiosPath()
|
void BIOSDialog::OnBnClickedSelectGbBiosPath()
|
||||||
{
|
{
|
||||||
CString current;
|
CString current;
|
||||||
m_editGB.GetWindowText( current );
|
m_editGB.GetWindowText(current);
|
||||||
if( !fileExists( current ) ) {
|
if (!fileExists(current)) {
|
||||||
current = _T("");
|
current = _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFileDialog dlg(
|
CFileDialog dlg(
|
||||||
TRUE,
|
TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
current,
|
current,
|
||||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||||
this,
|
this,
|
||||||
0 );
|
0);
|
||||||
|
|
||||||
if( IDOK == dlg.DoModal() ) {
|
if (IDOK == dlg.DoModal()) {
|
||||||
m_editGB.SetWindowText( dlg.GetPathName() );
|
m_editGB.SetWindowText(dlg.GetPathName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BIOSDialog::OnBnClickedSelectGbcBiosPath()
|
void BIOSDialog::OnBnClickedSelectGbcBiosPath()
|
||||||
{
|
{
|
||||||
CString current;
|
CString current;
|
||||||
m_editGBC.GetWindowText( current );
|
m_editGBC.GetWindowText(current);
|
||||||
if( !fileExists( current ) ) {
|
if (!fileExists(current)) {
|
||||||
current = _T("");
|
current = _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFileDialog dlg(
|
CFileDialog dlg(
|
||||||
TRUE,
|
TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
current,
|
current,
|
||||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||||
this,
|
this,
|
||||||
0 );
|
0);
|
||||||
|
|
||||||
if( IDOK == dlg.DoModal() ) {
|
if (IDOK == dlg.DoModal()) {
|
||||||
m_editGBC.SetWindowText( dlg.GetPathName() );
|
m_editGBC.SetWindowText(dlg.GetPathName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BIOSDialog::OnBnClickedSelectGbaBiosPath()
|
void BIOSDialog::OnBnClickedSelectGbaBiosPath()
|
||||||
{
|
{
|
||||||
CString current;
|
CString current;
|
||||||
m_editGBA.GetWindowText( current );
|
m_editGBA.GetWindowText(current);
|
||||||
if( !fileExists( current ) ) {
|
if (!fileExists(current)) {
|
||||||
current = _T("");
|
current = _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFileDialog dlg(
|
CFileDialog dlg(
|
||||||
TRUE,
|
TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
current,
|
current,
|
||||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||||
this,
|
this,
|
||||||
0 );
|
0);
|
||||||
|
|
||||||
if( IDOK == dlg.DoModal() ) {
|
if (IDOK == dlg.DoModal()) {
|
||||||
m_editGBA.SetWindowText( dlg.GetPathName() );
|
m_editGBA.SetWindowText(dlg.GetPathName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BIOSDialog::fileExists(CString& file)
|
bool BIOSDialog::fileExists(CString& file)
|
||||||
{
|
{
|
||||||
CFileStatus stat;
|
CFileStatus stat;
|
||||||
BOOL retVal = CFile::GetStatus( file, stat );
|
BOOL retVal = CFile::GetStatus(file, stat);
|
||||||
bool noFile = false;
|
bool noFile = false;
|
||||||
if( retVal == TRUE ) {
|
if (retVal == TRUE) {
|
||||||
noFile |= ( stat.m_attribute & CFile::directory ) != 0;
|
noFile |= (stat.m_attribute & CFile::directory) != 0;
|
||||||
}
|
}
|
||||||
return ( retVal == TRUE ) && !noFile;
|
return (retVal == TRUE) && !noFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,36 +2,35 @@
|
||||||
|
|
||||||
// BIOSDialog dialog
|
// BIOSDialog dialog
|
||||||
|
|
||||||
class BIOSDialog : public CDialog
|
class BIOSDialog : public CDialog {
|
||||||
{
|
DECLARE_DYNAMIC(BIOSDialog)
|
||||||
DECLARE_DYNAMIC(BIOSDialog)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BIOSDialog(CWnd *pParent = NULL); // standard constructor
|
BIOSDialog(CWnd* pParent = NULL); // standard constructor
|
||||||
virtual ~BIOSDialog();
|
virtual ~BIOSDialog();
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
enum { IDD = IDD_BIOS };
|
enum { IDD = IDD_BIOS };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
private:
|
private:
|
||||||
CEdit m_editGB;
|
CEdit m_editGB;
|
||||||
CEdit m_editGBC;
|
CEdit m_editGBC;
|
||||||
CEdit m_editGBA;
|
CEdit m_editGBA;
|
||||||
bool fileExists(CString &file);
|
bool fileExists(CString& file);
|
||||||
afx_msg void OnBnClickedSelectGbBiosPath();
|
afx_msg void OnBnClickedSelectGbBiosPath();
|
||||||
afx_msg void OnBnClickedSelectGbcBiosPath();
|
afx_msg void OnBnClickedSelectGbcBiosPath();
|
||||||
afx_msg void OnBnClickedSelectGbaBiosPath();
|
afx_msg void OnBnClickedSelectGbaBiosPath();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BOOL m_enableBIOS_GB;
|
BOOL m_enableBIOS_GB;
|
||||||
BOOL m_enableBIOS_GBC;
|
BOOL m_enableBIOS_GBC;
|
||||||
BOOL m_enableBIOS_GBA;
|
BOOL m_enableBIOS_GBA;
|
||||||
BOOL m_skipLogo;
|
BOOL m_skipLogo;
|
||||||
CString m_pathGB;
|
CString m_pathGB;
|
||||||
CString m_pathGBC;
|
CString m_pathGBC;
|
||||||
CString m_pathGBA;
|
CString m_pathGBA;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
#include "BitmapControl.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "BitmapControl.h"
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -15,110 +15,108 @@ bool BitmapControl::isRegistered = false;
|
||||||
|
|
||||||
IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
|
IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
|
||||||
|
|
||||||
BitmapControl::BitmapControl()
|
BitmapControl::BitmapControl()
|
||||||
{
|
{
|
||||||
w = 0;
|
w = 0;
|
||||||
h = 0;
|
h = 0;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
bmpInfo = NULL;
|
bmpInfo = NULL;
|
||||||
stretch = false;
|
stretch = false;
|
||||||
registerClass();
|
registerClass();
|
||||||
CSize sizeTotal;
|
CSize sizeTotal;
|
||||||
sizeTotal.cx = sizeTotal.cy = 0;
|
sizeTotal.cx = sizeTotal.cy = 0;
|
||||||
SetScrollSizes(MM_TEXT, sizeTotal);
|
SetScrollSizes(MM_TEXT, sizeTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
BitmapControl::~BitmapControl()
|
BitmapControl::~BitmapControl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(BitmapControl, CScrollView)
|
BEGIN_MESSAGE_MAP(BitmapControl, CScrollView)
|
||||||
//{{AFX_MSG_MAP(BitmapControl)
|
//{{AFX_MSG_MAP(BitmapControl)
|
||||||
ON_WM_ERASEBKGND()
|
ON_WM_ERASEBKGND()
|
||||||
ON_WM_SIZE()
|
ON_WM_SIZE()
|
||||||
ON_WM_LBUTTONDOWN()
|
ON_WM_LBUTTONDOWN()
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// BitmapControl drawing
|
// BitmapControl drawing
|
||||||
|
|
||||||
void BitmapControl::OnInitialUpdate()
|
void BitmapControl::OnInitialUpdate()
|
||||||
{
|
{
|
||||||
CScrollView::OnInitialUpdate();
|
CScrollView::OnInitialUpdate();
|
||||||
|
|
||||||
CSize sizeTotal;
|
CSize sizeTotal;
|
||||||
// TODO: calculate the total size of this view
|
// TODO: calculate the total size of this view
|
||||||
sizeTotal.cx = sizeTotal.cy = 100;
|
sizeTotal.cx = sizeTotal.cy = 100;
|
||||||
SetScrollSizes(MM_TEXT, sizeTotal);
|
SetScrollSizes(MM_TEXT, sizeTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::OnDraw(CDC* dc)
|
void BitmapControl::OnDraw(CDC* dc)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
GetClientRect(&r);
|
GetClientRect(&r);
|
||||||
int w1 = r.right - r.left;
|
int w1 = r.right - r.left;
|
||||||
int h1 = r.bottom - r.top;
|
int h1 = r.bottom - r.top;
|
||||||
CDC memDC;
|
CDC memDC;
|
||||||
memDC.CreateCompatibleDC(dc);
|
memDC.CreateCompatibleDC(dc);
|
||||||
if(!stretch) {
|
if (!stretch) {
|
||||||
if(w > w1)
|
if (w > w1)
|
||||||
w1 = w;
|
w1 = w;
|
||||||
if(h > h1)
|
if (h > h1)
|
||||||
h1 = h;
|
h1 = h;
|
||||||
}
|
}
|
||||||
CBitmap bitmap, *pOldBitmap;
|
CBitmap bitmap, *pOldBitmap;
|
||||||
bitmap.CreateCompatibleBitmap(dc, w1, h1);
|
bitmap.CreateCompatibleBitmap(dc, w1, h1);
|
||||||
pOldBitmap = memDC.SelectObject(&bitmap);
|
pOldBitmap = memDC.SelectObject(&bitmap);
|
||||||
if(stretch) {
|
if (stretch) {
|
||||||
bmpInfo->bmiHeader.biWidth = w;
|
bmpInfo->bmiHeader.biWidth = w;
|
||||||
bmpInfo->bmiHeader.biHeight = -h;
|
bmpInfo->bmiHeader.biHeight = -h;
|
||||||
|
|
||||||
StretchDIBits(memDC.GetSafeHdc(),
|
StretchDIBits(memDC.GetSafeHdc(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
w1,
|
w1,
|
||||||
h1,
|
h1,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
w,
|
w,
|
||||||
h,
|
h,
|
||||||
data,
|
data,
|
||||||
bmpInfo,
|
bmpInfo,
|
||||||
DIB_RGB_COLORS,
|
DIB_RGB_COLORS,
|
||||||
SRCCOPY);
|
SRCCOPY);
|
||||||
} else {
|
} else {
|
||||||
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
|
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
|
||||||
|
|
||||||
bmpInfo->bmiHeader.biWidth = w;
|
bmpInfo->bmiHeader.biWidth = w;
|
||||||
bmpInfo->bmiHeader.biHeight = -h;
|
bmpInfo->bmiHeader.biHeight = -h;
|
||||||
SetDIBitsToDevice(memDC.GetSafeHdc(),
|
SetDIBitsToDevice(memDC.GetSafeHdc(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
w,
|
w,
|
||||||
h,
|
h,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
h,
|
h,
|
||||||
data,
|
data,
|
||||||
bmpInfo,
|
bmpInfo,
|
||||||
DIB_RGB_COLORS);
|
DIB_RGB_COLORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->BitBlt(0,0,w1,h1,
|
dc->BitBlt(0, 0, w1, h1,
|
||||||
&memDC,0,0,SRCCOPY);
|
&memDC, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
if (boxreigon.right != 0 && boxreigon.bottom != 0)
|
|
||||||
{
|
|
||||||
CBrush br = CBrush(RGB(255, 0, 0));
|
|
||||||
dc->FrameRect(&boxreigon, &br);
|
|
||||||
}
|
|
||||||
memDC.SelectObject(pOldBitmap);
|
|
||||||
|
|
||||||
bitmap.DeleteObject();
|
if (boxreigon.right != 0 && boxreigon.bottom != 0) {
|
||||||
memDC.DeleteDC();
|
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
|
#ifdef _DEBUG
|
||||||
void BitmapControl::AssertValid() const
|
void BitmapControl::AssertValid() const
|
||||||
{
|
{
|
||||||
CScrollView::AssertValid();
|
CScrollView::AssertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::Dump(CDumpContext& dc) const
|
void BitmapControl::Dump(CDumpContext& dc) const
|
||||||
{
|
{
|
||||||
CScrollView::Dump(dc);
|
CScrollView::Dump(dc);
|
||||||
}
|
}
|
||||||
#endif //_DEBUG
|
#endif //_DEBUG
|
||||||
|
|
||||||
|
@ -141,141 +139,134 @@ void BitmapControl::Dump(CDumpContext& dc) const
|
||||||
|
|
||||||
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
|
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::OnSize(UINT nType, int cx, int cy)
|
void BitmapControl::OnSize(UINT nType, int cx, int cy)
|
||||||
{
|
{
|
||||||
if(!stretch)
|
if (!stretch)
|
||||||
CScrollView::OnSize(nType, cx, cy);
|
CScrollView::OnSize(nType, cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
||||||
{
|
{
|
||||||
GetParent()->SendMessage(WM_BITMAPCLICK,
|
GetParent()->SendMessage(WM_BITMAPCLICK,
|
||||||
GetDlgCtrlID(),
|
GetDlgCtrlID(),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if(!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
int x = pt.x;
|
int x = pt.x;
|
||||||
int y = pt.y;
|
int y = pt.y;
|
||||||
|
|
||||||
WPARAM point;
|
WPARAM point;
|
||||||
|
|
||||||
if(stretch) {
|
if (stretch) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(&rect);
|
GetClientRect(&rect);
|
||||||
|
|
||||||
int height = rect.bottom - rect.top;
|
int height = rect.bottom - rect.top;
|
||||||
int width = rect.right - rect.left;
|
int width = rect.right - rect.left;
|
||||||
|
|
||||||
int xx = (x * w) / width;
|
int xx = (x * w) / width;
|
||||||
int yy = (y * h) / height;
|
int yy = (y * h) / height;
|
||||||
|
|
||||||
point = xx | (yy<<16);
|
point = xx | (yy << 16);
|
||||||
|
|
||||||
int xxx = xx / 8;
|
int xxx = xx / 8;
|
||||||
int yyy = yy / 8;
|
int yyy = yy / 8;
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
memcpy(&colors[i*3*8], &data[xxx * 8 * 3 +
|
memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
|
||||||
w * yyy * 8 * 3 +
|
}
|
||||||
i * w * 3], 8 * 3);
|
} else {
|
||||||
|
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)
|
void BitmapControl::setSize(int w1, int h1)
|
||||||
{
|
{
|
||||||
if(w != w1 || h != h1) {
|
if (w != w1 || h != h1) {
|
||||||
w = w1;
|
w = w1;
|
||||||
h = h1;
|
h = h1;
|
||||||
SIZE s;
|
SIZE s;
|
||||||
s.cx = w;
|
s.cx = w;
|
||||||
s.cy = h;
|
s.cy = h;
|
||||||
SetScrollSizes(MM_TEXT, s);
|
SetScrollSizes(MM_TEXT, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void BitmapControl::setSelectedRectangle(int x, int y, int width, int height)
|
void BitmapControl::setSelectedRectangle(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
boxreigon.left = x;
|
boxreigon.left = x;
|
||||||
boxreigon.right = x + width;
|
boxreigon.right = x + width;
|
||||||
boxreigon.top = y;
|
boxreigon.top = y;
|
||||||
boxreigon.bottom = y + height;
|
boxreigon.bottom = y + height;
|
||||||
}
|
}
|
||||||
void BitmapControl::refresh()
|
void BitmapControl::refresh()
|
||||||
{
|
{
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BitmapControl::registerClass()
|
void BitmapControl::registerClass()
|
||||||
{
|
{
|
||||||
if(!isRegistered) {
|
if (!isRegistered) {
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
||||||
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
|
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
|
||||||
wc.hInstance = AfxGetInstanceHandle();
|
wc.hInstance = AfxGetInstanceHandle();
|
||||||
wc.hIcon = NULL;
|
wc.hIcon = NULL;
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = "VbaBitmapControl";
|
wc.lpszClassName = "VbaBitmapControl";
|
||||||
AfxRegisterClass(&wc);
|
AfxRegisterClass(&wc);
|
||||||
isRegistered = true;
|
isRegistered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::setStretch(bool b)
|
void BitmapControl::setStretch(bool b)
|
||||||
{
|
{
|
||||||
if(b != stretch) {
|
if (b != stretch) {
|
||||||
stretch = b;
|
stretch = b;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitmapControl::getStretch()
|
bool BitmapControl::getStretch()
|
||||||
{
|
{
|
||||||
return stretch;
|
return stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::PostNcDestroy()
|
void BitmapControl::PostNcDestroy()
|
||||||
|
|
|
@ -16,61 +16,60 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// BitmapControl view
|
// BitmapControl view
|
||||||
|
|
||||||
class BitmapControl : public CScrollView
|
class BitmapControl : public CScrollView {
|
||||||
{
|
public:
|
||||||
public:
|
BitmapControl(); // protected constructor used by dynamic creation
|
||||||
BitmapControl(); // protected constructor used by dynamic creation
|
protected:
|
||||||
protected:
|
DECLARE_DYNCREATE(BitmapControl)
|
||||||
DECLARE_DYNCREATE(BitmapControl)
|
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
public:
|
public:
|
||||||
// Operations
|
// Operations
|
||||||
public:
|
public:
|
||||||
void setStretch(bool b);
|
void setStretch(bool b);
|
||||||
void refresh();
|
void refresh();
|
||||||
void setSize(int w1, int h1);
|
void setSize(int w1, int h1);
|
||||||
void setSelectedRectangle(int x, int y, int width, int height);
|
void setSelectedRectangle(int x, int y, int width, int height);
|
||||||
void setData(u8 *d);
|
void setData(u8* d);
|
||||||
void setBmpInfo(BITMAPINFO *info);
|
void setBmpInfo(BITMAPINFO* info);
|
||||||
static bool isRegistered;
|
static bool isRegistered;
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
// ClassWizard generated virtual function overrides
|
// ClassWizard generated virtual function overrides
|
||||||
//{{AFX_VIRTUAL(BitmapControl)
|
//{{AFX_VIRTUAL(BitmapControl)
|
||||||
protected:
|
protected:
|
||||||
virtual void OnDraw(CDC *pDC); // overridden to draw this view
|
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||||
virtual void OnInitialUpdate(); // first time after construct
|
virtual void OnInitialUpdate(); // first time after construct
|
||||||
virtual void PostNcDestroy();
|
virtual void PostNcDestroy();
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
bool getStretch();
|
bool getStretch();
|
||||||
virtual ~BitmapControl();
|
virtual ~BitmapControl();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
virtual void AssertValid() const;
|
virtual void AssertValid() const;
|
||||||
virtual void Dump(CDumpContext &dc) const;
|
virtual void Dump(CDumpContext& dc) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
//{{AFX_MSG(BitmapControl)
|
//{{AFX_MSG(BitmapControl)
|
||||||
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
|
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
private:
|
private:
|
||||||
void registerClass();
|
void registerClass();
|
||||||
bool stretch;
|
bool stretch;
|
||||||
u8 colors[3 * 64];
|
u8 colors[3 * 64];
|
||||||
BITMAPINFO *bmpInfo;
|
BITMAPINFO* bmpInfo;
|
||||||
u8 *data;
|
u8* data;
|
||||||
int h;
|
int h;
|
||||||
int w;
|
int w;
|
||||||
RECT boxreigon;
|
RECT boxreigon;
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -19,17 +19,17 @@
|
||||||
// BugReport.cpp : implementation file
|
// BugReport.cpp : implementation file
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "BugReport.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "BugReport.h"
|
|
||||||
|
|
||||||
#include "../agb/agbprint.h"
|
|
||||||
#include "../AutoBuild.h"
|
#include "../AutoBuild.h"
|
||||||
#include "../agb/GBA.h"
|
|
||||||
#include "../Globals.h"
|
#include "../Globals.h"
|
||||||
#include "../Port.h"
|
#include "../Port.h"
|
||||||
#include "../RTC.h"
|
#include "../RTC.h"
|
||||||
#include "../Sound.h"
|
#include "../Sound.h"
|
||||||
|
#include "../agb/GBA.h"
|
||||||
|
#include "../agb/agbprint.h"
|
||||||
#include "../dmg/gbCheats.h"
|
#include "../dmg/gbCheats.h"
|
||||||
#include "../dmg/gbGlobals.h"
|
#include "../dmg/gbGlobals.h"
|
||||||
|
|
||||||
|
@ -42,204 +42,200 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// BugReport dialog
|
// BugReport dialog
|
||||||
|
|
||||||
|
|
||||||
BugReport::BugReport(CWnd* pParent /*=NULL*/)
|
BugReport::BugReport(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(BugReport::IDD, pParent)
|
: CDialog(BugReport::IDD, pParent)
|
||||||
{
|
{
|
||||||
//{{AFX_DATA_INIT(BugReport)
|
//{{AFX_DATA_INIT(BugReport)
|
||||||
// NOTE: the ClassWizard will add member initialization here
|
// NOTE: the ClassWizard will add member initialization here
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BugReport::DoDataExchange(CDataExchange* pDX)
|
void BugReport::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
//{{AFX_DATA_MAP(BugReport)
|
//{{AFX_DATA_MAP(BugReport)
|
||||||
DDX_Control(pDX, IDC_BUG_REPORT, m_report);
|
DDX_Control(pDX, IDC_BUG_REPORT, m_report);
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(BugReport, CDialog)
|
BEGIN_MESSAGE_MAP(BugReport, CDialog)
|
||||||
//{{AFX_MSG_MAP(BugReport)
|
//{{AFX_MSG_MAP(BugReport)
|
||||||
ON_BN_CLICKED(IDC_COPY, OnCopy)
|
ON_BN_CLICKED(IDC_COPY, OnCopy)
|
||||||
ON_BN_CLICKED(ID_OK, OnOk)
|
ON_BN_CLICKED(ID_OK, OnOk)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// BugReport message handlers
|
// BugReport message handlers
|
||||||
|
|
||||||
void BugReport::OnCopy()
|
void BugReport::OnCopy()
|
||||||
{
|
{
|
||||||
OpenClipboard();
|
OpenClipboard();
|
||||||
|
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
CString report;
|
CString report;
|
||||||
m_report.GetWindowText(report);
|
m_report.GetWindowText(report);
|
||||||
|
|
||||||
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
|
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
|
||||||
(report.GetLength() + 1) * sizeof(CHAR));
|
(report.GetLength() + 1) * sizeof(CHAR));
|
||||||
if (hglbCopy == NULL) {
|
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();
|
CloseClipboard();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock the handle and copy the text to the buffer.
|
systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BugReport::OnOk()
|
void BugReport::OnOk()
|
||||||
{
|
{
|
||||||
EndDialog(TRUE);
|
EndDialog(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL BugReport::OnInitDialog()
|
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
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AppendFormat(CString& report, const char* format, ...)
|
||||||
static void AppendFormat(CString& report, const char *format, ...)
|
|
||||||
{
|
{
|
||||||
CString buffer;
|
CString buffer;
|
||||||
va_list valist;
|
va_list valist;
|
||||||
|
|
||||||
va_start(valist, format);
|
va_start(valist, format);
|
||||||
buffer.FormatV(format, valist);
|
buffer.FormatV(format, valist);
|
||||||
va_end(valist);
|
va_end(valist);
|
||||||
report += buffer;
|
report += buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString BugReport::createReport()
|
CString BugReport::createReport()
|
||||||
{
|
{
|
||||||
theApp.winCheckFullscreen();
|
theApp.winCheckFullscreen();
|
||||||
|
|
||||||
CString report = "";
|
CString report = "";
|
||||||
AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING);
|
AppendFormat(report, "Emu version : %s\r\n", VBA_VERSION_STRING);
|
||||||
AppendFormat(report, "Emu Type : %s\r\n",
|
AppendFormat(report, "Emu Type : %s\r\n",
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
"Debug Version"
|
"Debug Version"
|
||||||
#else
|
#else
|
||||||
"Release Version"
|
"Release Version"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
if(emulating) {
|
if (emulating) {
|
||||||
AppendFormat(report, "File : %s\r\n", theApp.szFile);
|
AppendFormat(report, "File : %s\r\n", theApp.szFile);
|
||||||
|
|
||||||
char buffer[20];
|
char buffer[20];
|
||||||
if(theApp.cartridgeType == 0) {
|
if (theApp.cartridgeType == 0) {
|
||||||
u32 check = 0;
|
u32 check = 0;
|
||||||
for(int i = 0; i < 0x4000; i += 4) {
|
for (int i = 0; i < 0x4000; i += 4) {
|
||||||
check += *((u32 *)&bios[i]);
|
check += *((u32*)&bios[i]);
|
||||||
}
|
}
|
||||||
AppendFormat(report, "BIOS Checksum: %08X\r\n", check);
|
AppendFormat(report, "BIOS Checksum: %08X\r\n", check);
|
||||||
|
|
||||||
strncpy(buffer, (const char *)&rom[0xa0], 12);
|
strncpy(buffer, (const char*)&rom[0xa0], 12);
|
||||||
buffer[12] = 0;
|
buffer[12] = 0;
|
||||||
AppendFormat(report, "Internal name: %s\r\n", buffer);
|
AppendFormat(report, "Internal name: %s\r\n", buffer);
|
||||||
|
|
||||||
strncpy(buffer, (const char *)&rom[0xac], 4);
|
strncpy(buffer, (const char*)&rom[0xac], 4);
|
||||||
buffer[4] = 0;
|
buffer[4] = 0;
|
||||||
AppendFormat(report, "Game code : %s\r\n", buffer);
|
AppendFormat(report, "Game code : %s\r\n", buffer);
|
||||||
|
|
||||||
CString res = "";
|
CString res = "";
|
||||||
u32 *p = (u32 *)rom;
|
u32* p = (u32*)rom;
|
||||||
u32 *end = (u32 *)((char *)rom+theApp.romSize);
|
u32* end = (u32*)((char*)rom + theApp.romSize);
|
||||||
while(p < end) {
|
while (p < end) {
|
||||||
u32 d = READ32LE(p);
|
u32 d = READ32LE(p);
|
||||||
|
|
||||||
if(d == 0x52504545) {
|
if (d == 0x52504545) {
|
||||||
if(memcmp(p, "EEPROM_", 7) == 0) {
|
if (memcmp(p, "EEPROM_", 7) == 0) {
|
||||||
res += (const char *)p;
|
res += (const char*)p;
|
||||||
res += ' ';
|
res += ' ';
|
||||||
}
|
}
|
||||||
} else if (d == 0x4D415253) {
|
} else if (d == 0x4D415253) {
|
||||||
if(memcmp(p, "SRAM_", 5) == 0) {
|
if (memcmp(p, "SRAM_", 5) == 0) {
|
||||||
res += (const char *)p;
|
res += (const char*)p;
|
||||||
res += ' ';
|
res += ' ';
|
||||||
}
|
}
|
||||||
} else if (d == 0x53414C46) {
|
} else if (d == 0x53414C46) {
|
||||||
if(memcmp(p, "FLASH1M_", 8) == 0) {
|
if (memcmp(p, "FLASH1M_", 8) == 0) {
|
||||||
res += (const char *)p;
|
res += (const char*)p;
|
||||||
res += ' ';
|
res += ' ';
|
||||||
}
|
}
|
||||||
} else if(memcmp(p, "FLASH", 5) == 0) {
|
} else if (memcmp(p, "FLASH", 5) == 0) {
|
||||||
res += (const char *)p;
|
res += (const char*)p;
|
||||||
res += ' ';
|
res += ' ';
|
||||||
} else if (d == 0x52494953) {
|
} else if (d == 0x52494953) {
|
||||||
if(memcmp(p, "SIIRTC_V", 8) == 0) {
|
if (memcmp(p, "SIIRTC_V", 8) == 0) {
|
||||||
res += (const char *)p;
|
res += (const char*)p;
|
||||||
res += ' ';
|
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, "Using BIOS : %d\r\n", theApp.useBiosFile);
|
||||||
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
|
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
|
||||||
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
|
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
|
||||||
AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
|
AppendFormat(report, "Throttle : %d\r\n", theApp.throttle);
|
||||||
AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
|
AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer);
|
||||||
AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
|
AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip);
|
||||||
AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
|
AppendFormat(report, "Video option : %d\r\n", theApp.videoOption);
|
||||||
AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod);
|
AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod);
|
||||||
AppendFormat(report, "Color depth : %d\r\n", systemColorDepth);
|
AppendFormat(report, "Color depth : %d\r\n", systemColorDepth);
|
||||||
AppendFormat(report, "Red shift : %08x\r\n", systemRedShift);
|
AppendFormat(report, "Red shift : %08x\r\n", systemRedShift);
|
||||||
AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
|
AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift);
|
||||||
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
|
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
|
||||||
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
|
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
|
||||||
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
|
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
|
||||||
AppendFormat(report, "Save type : %d (%d)\r\n",
|
AppendFormat(report, "Save type : %d (%d)\r\n",
|
||||||
theApp.winSaveType, cpuSaveType);
|
theApp.winSaveType, cpuSaveType);
|
||||||
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
|
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
|
||||||
theApp.winFlashSize, flashSize);
|
theApp.winFlashSize, flashSize);
|
||||||
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
|
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
|
||||||
rtcIsEnabled());
|
rtcIsEnabled());
|
||||||
AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled());
|
AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled());
|
||||||
AppendFormat(report, "Speed toggle : %d\r\n", theApp.speedupToggle);
|
AppendFormat(report, "Speed toggle : %d\r\n", theApp.speedupToggle);
|
||||||
AppendFormat(report, "Synchronize : %d\r\n", synchronize);
|
AppendFormat(report, "Synchronize : %d\r\n", synchronize);
|
||||||
AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag);
|
AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag);
|
||||||
AppendFormat(report, "Channels : %04x\r\n", soundGetEnable() & 0x30f);
|
AppendFormat(report, "Channels : %04x\r\n", soundGetEnable() & 0x30f);
|
||||||
AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync);
|
AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync);
|
||||||
AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority);
|
AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority);
|
||||||
AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
|
AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType);
|
||||||
AppendFormat(report, "Cheats : %d\r\n", cheatsNumber);
|
AppendFormat(report, "Cheats : %d\r\n", cheatsNumber);
|
||||||
AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber);
|
AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber);
|
||||||
AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType);
|
AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType);
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,36 +29,35 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// BugReport dialog
|
// BugReport dialog
|
||||||
|
|
||||||
class BugReport : public CDialog
|
class BugReport : public CDialog {
|
||||||
{
|
// Construction
|
||||||
// Construction
|
public:
|
||||||
public:
|
BugReport(CWnd* pParent = NULL); // standard constructor
|
||||||
BugReport(CWnd *pParent = NULL); // standard constructor
|
|
||||||
|
|
||||||
// Dialog Data
|
// Dialog Data
|
||||||
//{{AFX_DATA(BugReport)
|
//{{AFX_DATA(BugReport)
|
||||||
enum { IDD = IDD_BUG_REPORT };
|
enum { IDD = IDD_BUG_REPORT };
|
||||||
CEdit m_report;
|
CEdit m_report;
|
||||||
//}}AFX_DATA
|
//}}AFX_DATA
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
// ClassWizard generated virtual function overrides
|
// ClassWizard generated virtual function overrides
|
||||||
//{{AFX_VIRTUAL(BugReport)
|
//{{AFX_VIRTUAL(BugReport)
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
protected:
|
protected:
|
||||||
CString createReport();
|
CString createReport();
|
||||||
|
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
//{{AFX_MSG(BugReport)
|
//{{AFX_MSG(BugReport)
|
||||||
afx_msg void OnCopy();
|
afx_msg void OnCopy();
|
||||||
afx_msg void OnOk();
|
afx_msg void OnOk();
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
||||||
//{{AFX_INSERT_LOCATION}}
|
//{{AFX_INSERT_LOCATION}}
|
||||||
|
|
|
@ -26,146 +26,144 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "CmdAccelOb.h"
|
#include "CmdAccelOb.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
MAPVIRTKEYS mapVirtKeys[] = {
|
MAPVIRTKEYS mapVirtKeys[] = {
|
||||||
{VK_LBUTTON, "VK_LBUTTON"},
|
{ VK_LBUTTON, "VK_LBUTTON" },
|
||||||
{VK_RBUTTON, "VK_RBUTTON"},
|
{ VK_RBUTTON, "VK_RBUTTON" },
|
||||||
{VK_CANCEL, "VK_CANCEL"},
|
{ VK_CANCEL, "VK_CANCEL" },
|
||||||
{VK_MBUTTON, "VK_MBUTTON"},
|
{ VK_MBUTTON, "VK_MBUTTON" },
|
||||||
{VK_BACK, "BACK"},
|
{ VK_BACK, "BACK" },
|
||||||
{VK_TAB, "TAB"},
|
{ VK_TAB, "TAB" },
|
||||||
{VK_CLEAR, "VK_CLEAR"},
|
{ VK_CLEAR, "VK_CLEAR" },
|
||||||
{VK_RETURN, "RETURN"},
|
{ VK_RETURN, "RETURN" },
|
||||||
{VK_SHIFT, "SHIFT"},
|
{ VK_SHIFT, "SHIFT" },
|
||||||
{VK_CONTROL, "CONTROL"},
|
{ VK_CONTROL, "CONTROL" },
|
||||||
{VK_MENU, "MENU"},
|
{ VK_MENU, "MENU" },
|
||||||
{VK_PAUSE, "PAUSE"},
|
{ VK_PAUSE, "PAUSE" },
|
||||||
{VK_CAPITAL, "CAPITAL"},
|
{ VK_CAPITAL, "CAPITAL" },
|
||||||
{VK_ESCAPE, "ESCAPE"},
|
{ VK_ESCAPE, "ESCAPE" },
|
||||||
{VK_SPACE, "SPACE"},
|
{ VK_SPACE, "SPACE" },
|
||||||
{VK_PRIOR, "PRIOR"},
|
{ VK_PRIOR, "PRIOR" },
|
||||||
{VK_NEXT, "NEXT"},
|
{ VK_NEXT, "NEXT" },
|
||||||
{VK_END, "END"},
|
{ VK_END, "END" },
|
||||||
{VK_HOME, "HOME"},
|
{ VK_HOME, "HOME" },
|
||||||
{VK_LEFT, "LEFT"},
|
{ VK_LEFT, "LEFT" },
|
||||||
{VK_UP, "UP"},
|
{ VK_UP, "UP" },
|
||||||
{VK_RIGHT, "RIGHT"},
|
{ VK_RIGHT, "RIGHT" },
|
||||||
{VK_DOWN, "DOWN"},
|
{ VK_DOWN, "DOWN" },
|
||||||
{VK_SELECT, "VK_SELECT"},
|
{ VK_SELECT, "VK_SELECT" },
|
||||||
{VK_PRINT, "PRINT"},
|
{ VK_PRINT, "PRINT" },
|
||||||
{VK_EXECUTE, "EXECUTE"},
|
{ VK_EXECUTE, "EXECUTE" },
|
||||||
{VK_SNAPSHOT, "SNAPSHOT"},
|
{ VK_SNAPSHOT, "SNAPSHOT" },
|
||||||
{VK_INSERT, "INSERT"},
|
{ VK_INSERT, "INSERT" },
|
||||||
{VK_DELETE, "DELETE"},
|
{ VK_DELETE, "DELETE" },
|
||||||
{VK_HELP, "VK_HELP"},
|
{ VK_HELP, "VK_HELP" },
|
||||||
{WORD('0'), "0"},
|
{ WORD('0'), "0" },
|
||||||
{WORD('1'), "1"},
|
{ WORD('1'), "1" },
|
||||||
{WORD('2'), "2"},
|
{ WORD('2'), "2" },
|
||||||
{WORD('3'), "3"},
|
{ WORD('3'), "3" },
|
||||||
{WORD('4'), "4"},
|
{ WORD('4'), "4" },
|
||||||
{WORD('5'), "5"},
|
{ WORD('5'), "5" },
|
||||||
{WORD('6'), "6"},
|
{ WORD('6'), "6" },
|
||||||
{WORD('7'), "7"},
|
{ WORD('7'), "7" },
|
||||||
{WORD('8'), "8"},
|
{ WORD('8'), "8" },
|
||||||
{WORD('9'), "9"},
|
{ WORD('9'), "9" },
|
||||||
{WORD('A'), "A"},
|
{ WORD('A'), "A" },
|
||||||
{WORD('B'), "B"},
|
{ WORD('B'), "B" },
|
||||||
{WORD('C'), "C"},
|
{ WORD('C'), "C" },
|
||||||
{WORD('D'), "D"},
|
{ WORD('D'), "D" },
|
||||||
{WORD('E'), "E"},
|
{ WORD('E'), "E" },
|
||||||
{WORD('F'), "F"},
|
{ WORD('F'), "F" },
|
||||||
{WORD('G'), "G"},
|
{ WORD('G'), "G" },
|
||||||
{WORD('H'), "H"},
|
{ WORD('H'), "H" },
|
||||||
{WORD('I'), "I"},
|
{ WORD('I'), "I" },
|
||||||
{WORD('J'), "J"},
|
{ WORD('J'), "J" },
|
||||||
{WORD('K'), "K"},
|
{ WORD('K'), "K" },
|
||||||
{WORD('L'), "L"},
|
{ WORD('L'), "L" },
|
||||||
{WORD('M'), "M"},
|
{ WORD('M'), "M" },
|
||||||
{WORD('N'), "N"},
|
{ WORD('N'), "N" },
|
||||||
{WORD('O'), "O"},
|
{ WORD('O'), "O" },
|
||||||
{WORD('P'), "P"},
|
{ WORD('P'), "P" },
|
||||||
{WORD('Q'), "Q"},
|
{ WORD('Q'), "Q" },
|
||||||
{WORD('R'), "R"},
|
{ WORD('R'), "R" },
|
||||||
{WORD('S'), "S"},
|
{ WORD('S'), "S" },
|
||||||
{WORD('T'), "T"},
|
{ WORD('T'), "T" },
|
||||||
{WORD('U'), "U"},
|
{ WORD('U'), "U" },
|
||||||
{WORD('V'), "V"},
|
{ WORD('V'), "V" },
|
||||||
{WORD('W'), "W"},
|
{ WORD('W'), "W" },
|
||||||
{WORD('X'), "X"},
|
{ WORD('X'), "X" },
|
||||||
{WORD('Y'), "Y"},
|
{ WORD('Y'), "Y" },
|
||||||
{WORD('Z'), "Z"},
|
{ WORD('Z'), "Z" },
|
||||||
{VK_LWIN, "VK_LWIN"},
|
{ VK_LWIN, "VK_LWIN" },
|
||||||
{VK_RWIN, "VK_RWIN"},
|
{ VK_RWIN, "VK_RWIN" },
|
||||||
{VK_APPS, "VK_APPS"},
|
{ VK_APPS, "VK_APPS" },
|
||||||
{VK_NUMPAD0, "NUMPAD0"},
|
{ VK_NUMPAD0, "NUMPAD0" },
|
||||||
{VK_NUMPAD1, "NUMPAD1"},
|
{ VK_NUMPAD1, "NUMPAD1" },
|
||||||
{VK_NUMPAD2, "NUMPAD2"},
|
{ VK_NUMPAD2, "NUMPAD2" },
|
||||||
{VK_NUMPAD3, "NUMPAD3"},
|
{ VK_NUMPAD3, "NUMPAD3" },
|
||||||
{VK_NUMPAD4, "NUMPAD4"},
|
{ VK_NUMPAD4, "NUMPAD4" },
|
||||||
{VK_NUMPAD5, "NUMPAD5"},
|
{ VK_NUMPAD5, "NUMPAD5" },
|
||||||
{VK_NUMPAD6, "NUMPAD6"},
|
{ VK_NUMPAD6, "NUMPAD6" },
|
||||||
{VK_NUMPAD7, "NUMPAD7"},
|
{ VK_NUMPAD7, "NUMPAD7" },
|
||||||
{VK_NUMPAD8, "NUMPAD8"},
|
{ VK_NUMPAD8, "NUMPAD8" },
|
||||||
{VK_NUMPAD9, "NUMPAD9"},
|
{ VK_NUMPAD9, "NUMPAD9" },
|
||||||
{VK_MULTIPLY, "MULTIPLY"},
|
{ VK_MULTIPLY, "MULTIPLY" },
|
||||||
{VK_ADD, "ADD"},
|
{ VK_ADD, "ADD" },
|
||||||
{VK_SEPARATOR, "SEPARATOR"},
|
{ VK_SEPARATOR, "SEPARATOR" },
|
||||||
{VK_SUBTRACT, "SUBTRACT"},
|
{ VK_SUBTRACT, "SUBTRACT" },
|
||||||
{VK_DECIMAL, "DECIMAL"},
|
{ VK_DECIMAL, "DECIMAL" },
|
||||||
{VK_DIVIDE, "DIVIDE"},
|
{ VK_DIVIDE, "DIVIDE" },
|
||||||
{VK_F1, "F1"},
|
{ VK_F1, "F1" },
|
||||||
{VK_F2, "F2"},
|
{ VK_F2, "F2" },
|
||||||
{VK_F3, "F3"},
|
{ VK_F3, "F3" },
|
||||||
{VK_F4, "F4"},
|
{ VK_F4, "F4" },
|
||||||
{VK_F5, "F5"},
|
{ VK_F5, "F5" },
|
||||||
{VK_F6, "F6"},
|
{ VK_F6, "F6" },
|
||||||
{VK_F7, "F7"},
|
{ VK_F7, "F7" },
|
||||||
{VK_F8, "F8"},
|
{ VK_F8, "F8" },
|
||||||
{VK_F9, "F9"},
|
{ VK_F9, "F9" },
|
||||||
{VK_F10, "F10"},
|
{ VK_F10, "F10" },
|
||||||
{VK_F11, "F11"},
|
{ VK_F11, "F11" },
|
||||||
{VK_F12, "F12"},
|
{ VK_F12, "F12" },
|
||||||
{VK_F13, "F13"},
|
{ VK_F13, "F13" },
|
||||||
{VK_F14, "F14"},
|
{ VK_F14, "F14" },
|
||||||
{VK_F15, "F15"},
|
{ VK_F15, "F15" },
|
||||||
{VK_F16, "F16"},
|
{ VK_F16, "F16" },
|
||||||
{VK_F17, "F17"},
|
{ VK_F17, "F17" },
|
||||||
{VK_F18, "F18"},
|
{ VK_F18, "F18" },
|
||||||
{VK_F19, "F19"},
|
{ VK_F19, "F19" },
|
||||||
{VK_F20, "F20"},
|
{ VK_F20, "F20" },
|
||||||
{VK_F21, "F21"},
|
{ VK_F21, "F21" },
|
||||||
{VK_F22, "F22"},
|
{ VK_F22, "F22" },
|
||||||
{VK_F23, "F23"},
|
{ VK_F23, "F23" },
|
||||||
{VK_F24, "F24"},
|
{ VK_F24, "F24" },
|
||||||
{VK_NUMLOCK, "NUMLOCK"},
|
{ VK_NUMLOCK, "NUMLOCK" },
|
||||||
{VK_SCROLL, "VK_SCROLL"},
|
{ VK_SCROLL, "VK_SCROLL" },
|
||||||
{VK_ATTN, "VK_ATTN"},
|
{ VK_ATTN, "VK_ATTN" },
|
||||||
{VK_CRSEL, "VK_CRSEL"},
|
{ VK_CRSEL, "VK_CRSEL" },
|
||||||
{VK_EXSEL, "VK_EXSEL"},
|
{ VK_EXSEL, "VK_EXSEL" },
|
||||||
{VK_EREOF, "VK_EREOF"},
|
{ VK_EREOF, "VK_EREOF" },
|
||||||
{VK_PLAY, "VK_PLAY"},
|
{ VK_PLAY, "VK_PLAY" },
|
||||||
{VK_ZOOM, "VK_ZOOM"},
|
{ VK_ZOOM, "VK_ZOOM" },
|
||||||
{VK_NONAME, "VK_NONAME"},
|
{ VK_NONAME, "VK_NONAME" },
|
||||||
{VK_PA1, "VK_PA1"},
|
{ VK_PA1, "VK_PA1" },
|
||||||
{VK_OEM_CLEAR, "VK_OEM_CLEAR"},
|
{ VK_OEM_CLEAR, "VK_OEM_CLEAR" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
MAPVIRTKEYS mapVirtSysKeys[] = {
|
MAPVIRTKEYS mapVirtSysKeys[] = {
|
||||||
{FCONTROL, "Ctrl"},
|
{ FCONTROL, "Ctrl" },
|
||||||
{FALT, "Alt"},
|
{ FALT, "Alt" },
|
||||||
{FSHIFT, "Shift"},
|
{ FSHIFT, "Shift" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// helper fct for external access
|
// helper fct for external access
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -173,20 +171,17 @@ MAPVIRTKEYS mapVirtSysKeys[] = {
|
||||||
//
|
//
|
||||||
TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
|
TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < sizeof(mapVirtKeys)/sizeof(mapVirtKeys[0]); index++) {
|
for (int index = 0; index < sizeof(mapVirtKeys) / sizeof(mapVirtKeys[0]); index++) {
|
||||||
if (mapVirtKeys[index].wKey == wKey)
|
if (mapVirtKeys[index].wKey == wKey)
|
||||||
return mapVirtKeys[index].szKey;
|
return mapVirtKeys[index].szKey;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
#define DEFAULT_ACCEL 0x01
|
#define DEFAULT_ACCEL 0x01
|
||||||
#define USER_ACCEL 0x02
|
#define USER_ACCEL 0x02
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -195,62 +190,57 @@ TCHAR* mapVirtKeysStringFromWORD(WORD wKey)
|
||||||
//
|
//
|
||||||
CAccelsOb::CAccelsOb()
|
CAccelsOb::CAccelsOb()
|
||||||
{
|
{
|
||||||
m_cVirt = 0;
|
m_cVirt = 0;
|
||||||
m_wKey = 0;
|
m_wKey = 0;
|
||||||
m_bLocked = false;
|
m_bLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
|
CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
|
||||||
{
|
{
|
||||||
ASSERT(pFrom != NULL);
|
ASSERT(pFrom != NULL);
|
||||||
|
|
||||||
m_cVirt = pFrom->m_cVirt;
|
m_cVirt = pFrom->m_cVirt;
|
||||||
m_wKey = pFrom->m_wKey;
|
m_wKey = pFrom->m_wKey;
|
||||||
m_bLocked = pFrom->m_bLocked;
|
m_bLocked = pFrom->m_bLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
|
CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
|
||||||
{
|
{
|
||||||
m_cVirt = cVirt;
|
m_cVirt = cVirt;
|
||||||
m_wKey = wKey;
|
m_wKey = wKey;
|
||||||
m_bLocked = bLocked;
|
m_bLocked = bLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CAccelsOb::CAccelsOb(LPACCEL pACCEL)
|
CAccelsOb::CAccelsOb(LPACCEL pACCEL)
|
||||||
{
|
{
|
||||||
ASSERT(pACCEL != NULL);
|
ASSERT(pACCEL != NULL);
|
||||||
|
|
||||||
m_cVirt = pACCEL->fVirt;
|
m_cVirt = pACCEL->fVirt;
|
||||||
m_wKey = pACCEL->key;
|
m_wKey = pACCEL->key;
|
||||||
m_bLocked = false;
|
m_bLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
|
CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
|
||||||
{
|
{
|
||||||
m_cVirt = from.m_cVirt;
|
m_cVirt = from.m_cVirt;
|
||||||
m_wKey = from.m_wKey;
|
m_wKey = from.m_wKey;
|
||||||
m_bLocked = from.m_bLocked;
|
m_bLocked = from.m_bLocked;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -258,83 +248,79 @@ CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
|
||||||
//
|
//
|
||||||
void CAccelsOb::GetString(CString& szBuffer)
|
void CAccelsOb::GetString(CString& szBuffer)
|
||||||
{
|
{
|
||||||
szBuffer = "";
|
szBuffer = "";
|
||||||
// in case of the object is not assigned, we avoid error messages
|
// in case of the object is not assigned, we avoid error messages
|
||||||
if (m_wKey == 0)
|
if (m_wKey == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// modifiers part
|
// modifiers part
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < sizetable(mapVirtSysKeys); i++) {
|
for (i = 0; i < sizetable(mapVirtSysKeys); i++) {
|
||||||
if (m_cVirt & mapVirtSysKeys[i].wKey) {
|
if (m_cVirt & mapVirtSysKeys[i].wKey) {
|
||||||
szBuffer += mapVirtSysKeys[i].szKey;
|
szBuffer += mapVirtSysKeys[i].szKey;
|
||||||
szBuffer += "+";
|
szBuffer += "+";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// and virtual key part
|
||||||
// and virtual key part
|
for (i = 0; i < sizetable(mapVirtKeys); i++) {
|
||||||
for (i = 0; i < sizetable(mapVirtKeys); i++) {
|
if (m_wKey == mapVirtKeys[i].wKey) {
|
||||||
if (m_wKey == mapVirtKeys[i].wKey) {
|
szBuffer += mapVirtKeys[i].szKey;
|
||||||
szBuffer += mapVirtKeys[i].szKey;
|
return;
|
||||||
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)
|
bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
|
||||||
{
|
{
|
||||||
// CString szTemp;
|
// CString szTemp;
|
||||||
// GetString(szTemp);
|
// GetString(szTemp);
|
||||||
|
|
||||||
|
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
|
||||||
|
bool bRet = (bCtrl == m_bCtrl);
|
||||||
|
|
||||||
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
|
bool m_bAlt = (m_cVirt & FALT) ? true : false;
|
||||||
bool bRet = (bCtrl == m_bCtrl);
|
bRet &= (bAlt == m_bAlt);
|
||||||
|
|
||||||
bool m_bAlt = (m_cVirt & FALT) ? true : false;
|
bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
|
||||||
bRet &= (bAlt == m_bAlt);
|
bRet &= (bShift == m_bShift);
|
||||||
|
|
||||||
bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
|
bRet &= static_cast<bool>(m_wKey == wKey);
|
||||||
bRet &= (bShift == m_bShift);
|
|
||||||
|
|
||||||
bRet &= static_cast<bool>(m_wKey == wKey);
|
return bRet;
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
DWORD CAccelsOb::GetData()
|
DWORD CAccelsOb::GetData()
|
||||||
{
|
{
|
||||||
BYTE cLocalCodes = 0;
|
BYTE cLocalCodes = 0;
|
||||||
if (m_bLocked)
|
if (m_bLocked)
|
||||||
cLocalCodes = DEFAULT_ACCEL;
|
cLocalCodes = DEFAULT_ACCEL;
|
||||||
else
|
else
|
||||||
cLocalCodes = USER_ACCEL;
|
cLocalCodes = USER_ACCEL;
|
||||||
|
|
||||||
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
|
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
|
||||||
return MAKELONG(m_wKey, bCodes);
|
return MAKELONG(m_wKey, bCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
bool CAccelsOb::SetData(DWORD dwDatas)
|
bool CAccelsOb::SetData(DWORD dwDatas)
|
||||||
{
|
{
|
||||||
m_wKey = LOWORD(dwDatas);
|
m_wKey = LOWORD(dwDatas);
|
||||||
|
|
||||||
WORD bCodes = HIWORD(dwDatas);
|
WORD bCodes = HIWORD(dwDatas);
|
||||||
m_cVirt = LOBYTE(bCodes);
|
m_cVirt = LOBYTE(bCodes);
|
||||||
|
|
||||||
BYTE cLocalCodes = HIBYTE(bCodes);
|
BYTE cLocalCodes = HIBYTE(bCodes);
|
||||||
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
|
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -345,7 +331,7 @@ bool CAccelsOb::SetData(DWORD dwDatas)
|
||||||
//
|
//
|
||||||
void CAccelsOb::AssertValid() const
|
void CAccelsOb::AssertValid() const
|
||||||
{
|
{
|
||||||
CObject::AssertValid();
|
CObject::AssertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -353,10 +339,9 @@ void CAccelsOb::AssertValid() const
|
||||||
//
|
//
|
||||||
void CAccelsOb::Dump(CDumpContext& dc) const
|
void CAccelsOb::Dump(CDumpContext& dc) const
|
||||||
{
|
{
|
||||||
dc << "\t\t";
|
dc << "\t\t";
|
||||||
CObject::Dump(dc);
|
CObject::Dump(dc);
|
||||||
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
|
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -369,47 +354,43 @@ CCmdAccelOb::CCmdAccelOb()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
|
CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
|
||||||
{
|
{
|
||||||
ASSERT(szCommand != NULL);
|
ASSERT(szCommand != NULL);
|
||||||
|
|
||||||
m_wIDCommand = wIDCommand;
|
m_wIDCommand = wIDCommand;
|
||||||
m_szCommand = szCommand;
|
m_szCommand = szCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
|
CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
|
||||||
{
|
{
|
||||||
ASSERT(szCommand != NULL);
|
ASSERT(szCommand != NULL);
|
||||||
|
|
||||||
m_wIDCommand = wIDCommand;
|
m_wIDCommand = wIDCommand;
|
||||||
m_szCommand = szCommand;
|
m_szCommand = szCommand;
|
||||||
|
|
||||||
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
|
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
|
||||||
ASSERT(pAccel != NULL);
|
ASSERT(pAccel != NULL);
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CCmdAccelOb::~CCmdAccelOb()
|
CCmdAccelOb::~CCmdAccelOb()
|
||||||
{
|
{
|
||||||
POSITION pos = m_Accels.GetHeadPosition();
|
POSITION pos = m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL)
|
while (pos != NULL)
|
||||||
delete m_Accels.GetNext(pos);
|
delete m_Accels.GetNext(pos);
|
||||||
m_Accels.RemoveAll();
|
m_Accels.RemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -417,76 +398,72 @@ CCmdAccelOb::~CCmdAccelOb()
|
||||||
//
|
//
|
||||||
void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
|
void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
|
||||||
{
|
{
|
||||||
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
|
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
|
||||||
ASSERT(pAccel != NULL);
|
ASSERT(pAccel != NULL);
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
void CCmdAccelOb::Add(CAccelsOb* pAccel)
|
void CCmdAccelOb::Add(CAccelsOb* pAccel)
|
||||||
{
|
{
|
||||||
ASSERT(pAccel != NULL);
|
ASSERT(pAccel != NULL);
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
|
CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
m_wIDCommand = from.m_wIDCommand;
|
m_wIDCommand = from.m_wIDCommand;
|
||||||
m_szCommand = from.m_szCommand;
|
m_szCommand = from.m_szCommand;
|
||||||
|
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
POSITION pos = from.m_Accels.GetHeadPosition();
|
POSITION pos = from.m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
pAccel = DEBUG_NEW CAccelsOb(from.m_Accels.GetNext(pos));
|
pAccel = DEBUG_NEW CAccelsOb(from.m_Accels.GetNext(pos));
|
||||||
ASSERT(pAccel != NULL);
|
ASSERT(pAccel != NULL);
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
void CCmdAccelOb::DeleteUserAccels()
|
void CCmdAccelOb::DeleteUserAccels()
|
||||||
{
|
{
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
POSITION prevPos;
|
POSITION prevPos;
|
||||||
POSITION pos = m_Accels.GetHeadPosition();
|
POSITION pos = m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
prevPos = pos;
|
prevPos = pos;
|
||||||
pAccel = m_Accels.GetNext(pos);
|
pAccel = m_Accels.GetNext(pos);
|
||||||
if (!pAccel->m_bLocked) {
|
if (!pAccel->m_bLocked) {
|
||||||
delete pAccel;
|
delete pAccel;
|
||||||
m_Accels.RemoveAt(prevPos);
|
m_Accels.RemoveAt(prevPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
void CCmdAccelOb::Reset()
|
void CCmdAccelOb::Reset()
|
||||||
{
|
{
|
||||||
m_wIDCommand = 0;
|
m_wIDCommand = 0;
|
||||||
m_szCommand = "Empty command";
|
m_szCommand = "Empty command";
|
||||||
|
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
POSITION pos = m_Accels.GetHeadPosition();
|
POSITION pos = m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
pAccel = m_Accels.GetNext(pos);
|
pAccel = m_Accels.GetNext(pos);
|
||||||
delete pAccel;
|
delete pAccel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -497,31 +474,30 @@ void CCmdAccelOb::Reset()
|
||||||
//
|
//
|
||||||
void CCmdAccelOb::AssertValid() const
|
void CCmdAccelOb::AssertValid() const
|
||||||
{
|
{
|
||||||
// call base class function first
|
// call base class function first
|
||||||
CObject::AssertValid();
|
CObject::AssertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
void CCmdAccelOb::Dump( CDumpContext& dc ) const
|
void CCmdAccelOb::Dump(CDumpContext& dc) const
|
||||||
{
|
{
|
||||||
// call base class function first
|
// call base class function first
|
||||||
dc << "\t";
|
dc << "\t";
|
||||||
CObject::Dump( dc );
|
CObject::Dump(dc);
|
||||||
|
|
||||||
// now do the stuff for our specific class
|
// now do the stuff for our specific class
|
||||||
dc << "\tIDCommand = " << m_wIDCommand;
|
dc << "\tIDCommand = " << m_wIDCommand;
|
||||||
dc << "\n\tszCommand = " << m_szCommand;
|
dc << "\n\tszCommand = " << m_szCommand;
|
||||||
dc << "\n\tAccelerators = {\n";
|
dc << "\n\tAccelerators = {\n";
|
||||||
|
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
POSITION pos = m_Accels.GetHeadPosition();
|
POSITION pos = m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
pAccel = m_Accels.GetNext(pos);
|
pAccel = m_Accels.GetNext(pos);
|
||||||
dc << pAccel;
|
dc << pAccel;
|
||||||
}
|
}
|
||||||
dc << "\t}\n";
|
dc << "\t}\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
typedef struct tagMAPVIRTKEYS {
|
typedef struct tagMAPVIRTKEYS {
|
||||||
WORD wKey;
|
WORD wKey;
|
||||||
TCHAR szKey[15];
|
TCHAR szKey[15];
|
||||||
} MAPVIRTKEYS, *PMAPVIRTKEYS;
|
} MAPVIRTKEYS, *PMAPVIRTKEYS;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -46,65 +46,63 @@ typedef struct tagMAPVIRTKEYS {
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
class CAccelsOb : public CObject
|
class CAccelsOb : public CObject {
|
||||||
{
|
public:
|
||||||
public:
|
CAccelsOb();
|
||||||
CAccelsOb();
|
CAccelsOb(CAccelsOb* pFrom);
|
||||||
CAccelsOb(CAccelsOb *pFrom);
|
CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false);
|
||||||
CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false);
|
CAccelsOb(LPACCEL pACCEL);
|
||||||
CAccelsOb(LPACCEL pACCEL);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAccelsOb &operator=(const CAccelsOb &from);
|
CAccelsOb& operator=(const CAccelsOb& from);
|
||||||
|
|
||||||
void GetString(CString &szBuffer);
|
void GetString(CString& szBuffer);
|
||||||
bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift);
|
bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift);
|
||||||
DWORD GetData();
|
DWORD GetData();
|
||||||
bool SetData(DWORD dwDatas);
|
bool SetData(DWORD dwDatas);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
virtual void AssertValid() const;
|
virtual void AssertValid() const;
|
||||||
virtual void Dump(CDumpContext &dc) const;
|
virtual void Dump(CDumpContext& dc) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BYTE m_cVirt;
|
BYTE m_cVirt;
|
||||||
WORD m_wKey;
|
WORD m_wKey;
|
||||||
bool m_bLocked;
|
bool m_bLocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
class CCmdAccelOb : public CObject
|
class CCmdAccelOb : public CObject {
|
||||||
{
|
public:
|
||||||
public:
|
CCmdAccelOb();
|
||||||
CCmdAccelOb();
|
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
|
||||||
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
|
CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand,
|
||||||
CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand,
|
bool bLocked = false);
|
||||||
bool bLocked = false);
|
~CCmdAccelOb();
|
||||||
~CCmdAccelOb();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Add(CAccelsOb *pAccel);
|
void Add(CAccelsOb* pAccel);
|
||||||
void Add(BYTE cVirt, WORD wKey, bool bLocked = false);
|
void Add(BYTE cVirt, WORD wKey, bool bLocked = false);
|
||||||
void Reset();
|
void Reset();
|
||||||
void DeleteUserAccels();
|
void DeleteUserAccels();
|
||||||
|
|
||||||
CCmdAccelOb &operator=(const CCmdAccelOb &from);
|
CCmdAccelOb& operator=(const CCmdAccelOb& from);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
virtual void AssertValid() const;
|
virtual void AssertValid() const;
|
||||||
virtual void Dump(CDumpContext &dc) const;
|
virtual void Dump(CDumpContext& dc) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WORD m_wIDCommand;
|
WORD m_wIDCommand;
|
||||||
CString m_szCommand;
|
CString m_szCommand;
|
||||||
|
|
||||||
CList<CAccelsOb *, CAccelsOb *&> m_Accels;
|
CList<CAccelsOb*, CAccelsOb*&> m_Accels;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
#include "ColorButton.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "ColorButton.h"
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -15,85 +15,83 @@ bool ColorButton::isRegistered = false;
|
||||||
|
|
||||||
ColorButton::ColorButton()
|
ColorButton::ColorButton()
|
||||||
{
|
{
|
||||||
color = 0;
|
color = 0;
|
||||||
registerClass();
|
registerClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorButton::~ColorButton()
|
ColorButton::~ColorButton()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(ColorButton, CButton)
|
BEGIN_MESSAGE_MAP(ColorButton, CButton)
|
||||||
//{{AFX_MSG_MAP(ColorButton)
|
//{{AFX_MSG_MAP(ColorButton)
|
||||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// ColorButton message handlers
|
// ColorButton message handlers
|
||||||
|
|
||||||
void ColorButton::PreSubclassWindow()
|
void ColorButton::PreSubclassWindow()
|
||||||
{
|
{
|
||||||
SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW);
|
SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW);
|
||||||
CWnd::PreSubclassWindow();
|
CWnd::PreSubclassWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||||
{
|
{
|
||||||
ASSERT(lpDrawItemStruct);
|
ASSERT(lpDrawItemStruct);
|
||||||
|
|
||||||
int r = (color & 0x1f) << 3;
|
int r = (color & 0x1f) << 3;
|
||||||
int g = (color & 0x3e0) >> 2;
|
int g = (color & 0x3e0) >> 2;
|
||||||
int b = (color & 0x7c00) >> 7;
|
int b = (color & 0x7c00) >> 7;
|
||||||
|
|
||||||
HDC dc = lpDrawItemStruct->hDC;
|
HDC dc = lpDrawItemStruct->hDC;
|
||||||
UINT state = lpDrawItemStruct->itemState;
|
UINT state = lpDrawItemStruct->itemState;
|
||||||
RECT rect = lpDrawItemStruct->rcItem;
|
RECT rect = lpDrawItemStruct->rcItem;
|
||||||
|
|
||||||
SIZE margins;
|
SIZE margins;
|
||||||
margins.cx = ::GetSystemMetrics(SM_CXEDGE);
|
margins.cx = ::GetSystemMetrics(SM_CXEDGE);
|
||||||
margins.cy = ::GetSystemMetrics(SM_CYEDGE);
|
margins.cy = ::GetSystemMetrics(SM_CYEDGE);
|
||||||
|
|
||||||
if(GetState() & BST_PUSHED)
|
if (GetState() & BST_PUSHED)
|
||||||
DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT);
|
DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT);
|
||||||
else
|
else
|
||||||
DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
|
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) ?
|
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? ::GetSysColor(COLOR_3DFACE) : RGB(r, g, b));
|
||||||
::GetSysColor(COLOR_3DFACE) : RGB(r,g,b));
|
|
||||||
|
|
||||||
FillRect(dc, &rect, br);
|
FillRect(dc, &rect, br);
|
||||||
|
|
||||||
if(state & ODS_FOCUS) {
|
if (state & ODS_FOCUS) {
|
||||||
InflateRect(&rect, -1, -1);
|
InflateRect(&rect, -1, -1);
|
||||||
DrawFocusRect(dc, &rect);
|
DrawFocusRect(dc, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteObject(br);
|
DeleteObject(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorButton::setColor(u16 c)
|
void ColorButton::setColor(u16 c)
|
||||||
{
|
{
|
||||||
color = c;
|
color = c;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorButton::registerClass()
|
void ColorButton::registerClass()
|
||||||
{
|
{
|
||||||
if(!isRegistered) {
|
if (!isRegistered) {
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
||||||
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
|
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
|
||||||
wc.hInstance = AfxGetInstanceHandle();
|
wc.hInstance = AfxGetInstanceHandle();
|
||||||
wc.hIcon = LoadCursor(NULL, IDC_ARROW);
|
wc.hIcon = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = "VbaColorButton";
|
wc.lpszClassName = "VbaColorButton";
|
||||||
AfxRegisterClass(&wc);
|
AfxRegisterClass(&wc);
|
||||||
isRegistered = true;
|
isRegistered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,41 +11,40 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// ColorButton window
|
// ColorButton window
|
||||||
|
|
||||||
class ColorButton : public CButton
|
class ColorButton : public CButton {
|
||||||
{
|
// Construction
|
||||||
// Construction
|
public:
|
||||||
public:
|
ColorButton();
|
||||||
ColorButton();
|
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
public:
|
public:
|
||||||
// Operations
|
// Operations
|
||||||
static bool isRegistered;
|
static bool isRegistered;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void PreSubclassWindow();
|
void PreSubclassWindow();
|
||||||
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
// ClassWizard generated virtual function overrides
|
// ClassWizard generated virtual function overrides
|
||||||
//{{AFX_VIRTUAL(ColorButton)
|
//{{AFX_VIRTUAL(ColorButton)
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
void setColor(u16 c);
|
void setColor(u16 c);
|
||||||
u16 color;
|
u16 color;
|
||||||
virtual ~ColorButton();
|
virtual ~ColorButton();
|
||||||
|
|
||||||
void registerClass();
|
void registerClass();
|
||||||
|
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
protected:
|
protected:
|
||||||
//{{AFX_MSG(ColorButton)
|
//{{AFX_MSG(ColorButton)
|
||||||
// NOTE - the ClassWizard will add and remove member functions here.
|
// NOTE - the ClassWizard will add and remove member functions here.
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
#include "ColorControl.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "ColorControl.h"
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -15,68 +15,66 @@ bool ColorControl::isRegistered = false;
|
||||||
|
|
||||||
ColorControl::ColorControl()
|
ColorControl::ColorControl()
|
||||||
{
|
{
|
||||||
color = 0;
|
color = 0;
|
||||||
registerClass();
|
registerClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorControl::~ColorControl()
|
ColorControl::~ColorControl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(ColorControl, CWnd)
|
BEGIN_MESSAGE_MAP(ColorControl, CWnd)
|
||||||
//{{AFX_MSG_MAP(ColorControl)
|
//{{AFX_MSG_MAP(ColorControl)
|
||||||
ON_WM_PAINT()
|
ON_WM_PAINT()
|
||||||
ON_WM_ERASEBKGND()
|
ON_WM_ERASEBKGND()
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// ColorControl message handlers
|
// ColorControl message handlers
|
||||||
|
|
||||||
void ColorControl::OnPaint()
|
void ColorControl::OnPaint()
|
||||||
{
|
{
|
||||||
CPaintDC dc(this); // device context for painting
|
CPaintDC dc(this); // device context for painting
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
|
BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
|
||||||
{
|
{
|
||||||
int r = (color & 0x1f) << 3;
|
int r = (color & 0x1f) << 3;
|
||||||
int g = (color & 0x3e0) >> 2;
|
int g = (color & 0x3e0) >> 2;
|
||||||
int b = (color & 0x7c00) >> 7;
|
int b = (color & 0x7c00) >> 7;
|
||||||
|
|
||||||
CBrush br;
|
CBrush br;
|
||||||
br.CreateSolidBrush(RGB(r,g,b));
|
br.CreateSolidBrush(RGB(r, g, b));
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(&rect);
|
GetClientRect(&rect);
|
||||||
pDC->FillRect(&rect,&br);
|
pDC->FillRect(&rect, &br);
|
||||||
pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
|
pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);
|
||||||
br.DeleteObject();
|
br.DeleteObject();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorControl::setColor(u16 c)
|
void ColorControl::setColor(u16 c)
|
||||||
{
|
{
|
||||||
color = c;
|
color = c;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorControl::registerClass()
|
void ColorControl::registerClass()
|
||||||
{
|
{
|
||||||
if(!isRegistered) {
|
if (!isRegistered) {
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
||||||
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
|
wc.lpfnWndProc = (WNDPROC)::DefWindowProc;
|
||||||
wc.hInstance = AfxGetInstanceHandle();
|
wc.hInstance = AfxGetInstanceHandle();
|
||||||
wc.hIcon = NULL;
|
wc.hIcon = NULL;
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = "VbaColorControl";
|
wc.lpszClassName = "VbaColorControl";
|
||||||
AfxRegisterClass(&wc);
|
AfxRegisterClass(&wc);
|
||||||
isRegistered = true;
|
isRegistered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,39 +11,38 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// ColorControl window
|
// ColorControl window
|
||||||
|
|
||||||
class ColorControl : public CWnd
|
class ColorControl : public CWnd {
|
||||||
{
|
// Construction
|
||||||
// Construction
|
public:
|
||||||
public:
|
ColorControl();
|
||||||
ColorControl();
|
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
public:
|
public:
|
||||||
// Operations
|
// Operations
|
||||||
static bool isRegistered;
|
static bool isRegistered;
|
||||||
|
|
||||||
// Operations
|
// Operations
|
||||||
public:
|
public:
|
||||||
// Overrides
|
// Overrides
|
||||||
// ClassWizard generated virtual function overrides
|
// ClassWizard generated virtual function overrides
|
||||||
//{{AFX_VIRTUAL(ColorControl)
|
//{{AFX_VIRTUAL(ColorControl)
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
void setColor(u16 c);
|
void setColor(u16 c);
|
||||||
u16 color;
|
u16 color;
|
||||||
virtual ~ColorControl();
|
virtual ~ColorControl();
|
||||||
|
|
||||||
// Generated message map functions
|
// Generated message map functions
|
||||||
protected:
|
protected:
|
||||||
//{{AFX_MSG(ColorControl)
|
//{{AFX_MSG(ColorControl)
|
||||||
afx_msg void OnPaint();
|
afx_msg void OnPaint();
|
||||||
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
|
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
private:
|
private:
|
||||||
void registerClass();
|
void registerClass();
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1,232 +1,231 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "AcceleratorManager.h"
|
#include "AcceleratorManager.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
#include "stdafx.h"
|
||||||
#include <afxres.h>
|
#include <afxres.h>
|
||||||
|
|
||||||
#include <afxtempl.h> // MFC Templates extension
|
#include <afxtempl.h> // MFC Templates extension
|
||||||
#ifndef CMapStringToWord
|
#ifndef CMapStringToWord
|
||||||
typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord;
|
typedef CMap<CString, LPCSTR, WORD, WORD&> CMapStringToWord;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static CMapStringToWord winAccelStrings;
|
static CMapStringToWord winAccelStrings;
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *command;
|
const char* command;
|
||||||
WORD id;
|
WORD id;
|
||||||
} winAccelCommands[] = {
|
} winAccelCommands[] = {
|
||||||
{ "FileOpenGBA", ID_FILE_OPEN_GBA },
|
{ "FileOpenGBA", ID_FILE_OPEN_GBA },
|
||||||
{ "FileOpenGBC", ID_FILE_OPEN_GBC },
|
{ "FileOpenGBC", ID_FILE_OPEN_GBC },
|
||||||
{ "FileOpenGB", ID_FILE_OPEN_GB },
|
{ "FileOpenGB", ID_FILE_OPEN_GB },
|
||||||
{ "FileLoadDotCode", ID_FILE_LOAD_DOTCODE },
|
{ "FileLoadDotCode", ID_FILE_LOAD_DOTCODE },
|
||||||
{ "FileSaveDotCode", ID_FILE_SAVE_DOTCODE },
|
{ "FileSaveDotCode", ID_FILE_SAVE_DOTCODE },
|
||||||
{ "FileLoad", ID_FILE_LOAD },
|
{ "FileLoad", ID_FILE_LOAD },
|
||||||
{ "FileSave", ID_FILE_SAVE },
|
{ "FileSave", ID_FILE_SAVE },
|
||||||
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
|
{ "FileLoadGame01", ID_FILE_LOADGAME_SLOT1 },
|
||||||
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
|
{ "FileLoadGame02", ID_FILE_LOADGAME_SLOT2 },
|
||||||
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
|
{ "FileLoadGame03", ID_FILE_LOADGAME_SLOT3 },
|
||||||
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
|
{ "FileLoadGame04", ID_FILE_LOADGAME_SLOT4 },
|
||||||
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
|
{ "FileLoadGame05", ID_FILE_LOADGAME_SLOT5 },
|
||||||
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
|
{ "FileLoadGame06", ID_FILE_LOADGAME_SLOT6 },
|
||||||
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
|
{ "FileLoadGame07", ID_FILE_LOADGAME_SLOT7 },
|
||||||
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
|
{ "FileLoadGame08", ID_FILE_LOADGAME_SLOT8 },
|
||||||
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
|
{ "FileLoadGame09", ID_FILE_LOADGAME_SLOT9 },
|
||||||
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
|
{ "FileLoadGame10", ID_FILE_LOADGAME_SLOT10 },
|
||||||
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
|
{ "FileLoadGameAutoLoad", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT },
|
||||||
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
|
{ "FileLoadGameRecent", ID_FILE_LOADGAME_MOSTRECENT },
|
||||||
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
|
{ "FileSaveGame01", ID_FILE_SAVEGAME_SLOT1 },
|
||||||
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
|
{ "FileSaveGame02", ID_FILE_SAVEGAME_SLOT2 },
|
||||||
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
|
{ "FileSaveGame03", ID_FILE_SAVEGAME_SLOT3 },
|
||||||
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
|
{ "FileSaveGame04", ID_FILE_SAVEGAME_SLOT4 },
|
||||||
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
|
{ "FileSaveGame05", ID_FILE_SAVEGAME_SLOT5 },
|
||||||
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
|
{ "FileSaveGame06", ID_FILE_SAVEGAME_SLOT6 },
|
||||||
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
|
{ "FileSaveGame07", ID_FILE_SAVEGAME_SLOT7 },
|
||||||
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
|
{ "FileSaveGame08", ID_FILE_SAVEGAME_SLOT8 },
|
||||||
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
|
{ "FileSaveGame09", ID_FILE_SAVEGAME_SLOT9 },
|
||||||
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
|
{ "FileSaveGame10", ID_FILE_SAVEGAME_SLOT10 },
|
||||||
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
|
{ "FileSaveGameOldest", ID_FILE_SAVEGAME_OLDESTSLOT },
|
||||||
{ "FileRecentReset", ID_FILE_RECENT_RESET },
|
{ "FileRecentReset", ID_FILE_RECENT_RESET },
|
||||||
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
|
{ "FileRecentFreeze", ID_FILE_RECENT_FREEZE },
|
||||||
{ "FileRecent01", ID_FILE_MRU_FILE1 },
|
{ "FileRecent01", ID_FILE_MRU_FILE1 },
|
||||||
{ "FileRecent02", ID_FILE_MRU_FILE2 },
|
{ "FileRecent02", ID_FILE_MRU_FILE2 },
|
||||||
{ "FileRecent03", ID_FILE_MRU_FILE3 },
|
{ "FileRecent03", ID_FILE_MRU_FILE3 },
|
||||||
{ "FileRecent04", ID_FILE_MRU_FILE4 },
|
{ "FileRecent04", ID_FILE_MRU_FILE4 },
|
||||||
{ "FileRecent05", ID_FILE_MRU_FILE5 },
|
{ "FileRecent05", ID_FILE_MRU_FILE5 },
|
||||||
{ "FileRecent06", ID_FILE_MRU_FILE6 },
|
{ "FileRecent06", ID_FILE_MRU_FILE6 },
|
||||||
{ "FileRecent07", ID_FILE_MRU_FILE7 },
|
{ "FileRecent07", ID_FILE_MRU_FILE7 },
|
||||||
{ "FileRecent08", ID_FILE_MRU_FILE8 },
|
{ "FileRecent08", ID_FILE_MRU_FILE8 },
|
||||||
{ "FileRecent09", ID_FILE_MRU_FILE9 },
|
{ "FileRecent09", ID_FILE_MRU_FILE9 },
|
||||||
{ "FileRecent10", ID_FILE_MRU_FILE10 },
|
{ "FileRecent10", ID_FILE_MRU_FILE10 },
|
||||||
{ "FilePause", ID_FILE_PAUSE },
|
{ "FilePause", ID_FILE_PAUSE },
|
||||||
{ "FileReset", ID_FILE_RESET },
|
{ "FileReset", ID_FILE_RESET },
|
||||||
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
|
{ "FileImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE },
|
||||||
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
|
{ "FileImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE },
|
||||||
{ "FileImportGamesharkActionReplaySnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
|
{ "FileImportGamesharkActionReplaySnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT },
|
||||||
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
|
{ "FileExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE },
|
||||||
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
|
{ "FileExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT },
|
||||||
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
|
{ "FileScreenCapture", ID_FILE_SCREENCAPTURE },
|
||||||
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
|
{ "FileRomInformation", ID_FILE_ROMINFORMATION },
|
||||||
{ "FileToggleFullscreen", ID_FILE_TOGGLEMENU },
|
{ "FileToggleFullscreen", ID_FILE_TOGGLEMENU },
|
||||||
{ "FileClose", ID_FILE_CLOSE },
|
{ "FileClose", ID_FILE_CLOSE },
|
||||||
{ "FileExit", ID_FILE_EXIT },
|
{ "FileExit", ID_FILE_EXIT },
|
||||||
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
|
{ "OptionsFrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 },
|
||||||
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
|
{ "OptionsFrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 },
|
||||||
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
|
{ "OptionsFrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 },
|
||||||
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
|
{ "OptionsFrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 },
|
||||||
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
|
{ "OptionsFrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 },
|
||||||
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
|
{ "OptionsFrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 },
|
||||||
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
|
{ "OptionsFrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 },
|
||||||
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
|
{ "OptionsFrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 },
|
||||||
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
|
{ "OptionsFrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 },
|
||||||
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
|
{ "OptionsFrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 },
|
||||||
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
|
{ "OptionsThrottleNone", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE },
|
||||||
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
|
{ "OptionsThrottle025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 },
|
||||||
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
|
{ "OptionsThrottle050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 },
|
||||||
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
|
{ "OptionsThrottle100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100 },
|
||||||
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
|
{ "OptionsThrottle150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 },
|
||||||
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
|
{ "OptionsThrottle200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 },
|
||||||
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
|
{ "OptionsThrottleOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER },
|
||||||
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
|
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
|
||||||
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
|
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
|
||||||
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
|
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
|
||||||
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
|
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
|
||||||
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
|
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
|
||||||
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
|
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },
|
||||||
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
|
{ "OptionsVideoX3", ID_OPTIONS_VIDEO_X3 },
|
||||||
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
|
{ "OptionsVideoX4", ID_OPTIONS_VIDEO_X4 },
|
||||||
{ "OptionsVideoX5", ID_OPTIONS_VIDEO_X5 },
|
{ "OptionsVideoX5", ID_OPTIONS_VIDEO_X5 },
|
||||||
{ "OptionsVideoX6", ID_OPTIONS_VIDEO_X6 },
|
{ "OptionsVideoX6", ID_OPTIONS_VIDEO_X6 },
|
||||||
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
|
{ "OptionsVideo320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 },
|
||||||
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
|
{ "OptionsVideo640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 },
|
||||||
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
|
{ "OptionsVideo800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 },
|
||||||
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
|
{ "OptionsVideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN },
|
||||||
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
|
{ "OptionsVideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE },
|
||||||
{ "OptionsVideoLayersBG0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
|
{ "OptionsVideoLayersBG0", ID_OPTIONS_VIDEO_LAYERS_BG0 },
|
||||||
{ "OptionsVideoLayersBG1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
|
{ "OptionsVideoLayersBG1", ID_OPTIONS_VIDEO_LAYERS_BG1 },
|
||||||
{ "OptionsVideoLayersBG2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
|
{ "OptionsVideoLayersBG2", ID_OPTIONS_VIDEO_LAYERS_BG2 },
|
||||||
{ "OptionsVideoLayersBG3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
|
{ "OptionsVideoLayersBG3", ID_OPTIONS_VIDEO_LAYERS_BG3 },
|
||||||
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
|
{ "OptionsVideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ },
|
||||||
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
|
{ "OptionsVideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 },
|
||||||
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
|
{ "OptionsVideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 },
|
||||||
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
|
{ "OptionsVideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN },
|
||||||
{ "OptionsVideoLayersReset", ID_OPTIONS_VIDEO_LAYERS_RESET },
|
{ "OptionsVideoLayersReset", ID_OPTIONS_VIDEO_LAYERS_RESET },
|
||||||
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
|
{ "OptionsEmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE },
|
||||||
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
|
{ "OptionsEmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES },
|
||||||
{ "OptionsEmulatorGameOverrides", ID_OPTIONS_EMULATOR_GAMEOVERRIDES },
|
{ "OptionsEmulatorGameOverrides", ID_OPTIONS_EMULATOR_GAMEOVERRIDES },
|
||||||
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
|
{ "OptionsEmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE },
|
||||||
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
|
{ "OptionsEmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE },
|
||||||
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
|
{ "OptionsEmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED },
|
||||||
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
|
{ "OptionsEmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT },
|
||||||
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
|
{ "OptionsEmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE },
|
||||||
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
|
{ "OptionsEmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC },
|
||||||
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
|
{ "OptionsEmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM },
|
||||||
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
|
{ "OptionsEmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM },
|
||||||
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
|
{ "OptionsEmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH },
|
||||||
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
|
{ "OptionsEmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR },
|
||||||
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
|
{ "OptionsEmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K },
|
||||||
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
|
{ "OptionsEmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M },
|
||||||
{ "OptionsEmulatorSaveDetectNow", ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW },
|
{ "OptionsEmulatorSaveDetectNow", ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW },
|
||||||
{ "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
|
{ "OptionsEmulatorAutoApplyPatchFiles", ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES },
|
||||||
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
|
{ "OptionsEmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT },
|
||||||
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
|
{ "OptionsEmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK },
|
||||||
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
|
{ "OptionsEmulatorRewindInterval", ID_OPTIONS_EMULATOR_REWINDINTERVAL },
|
||||||
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
|
{ "OptionsSoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 },
|
||||||
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
|
{ "OptionsSoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 },
|
||||||
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
|
{ "OptionsSoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 },
|
||||||
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
|
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
|
||||||
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
|
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
|
||||||
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
|
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
|
||||||
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
|
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
|
||||||
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
|
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
|
||||||
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
|
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
|
||||||
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
|
{ "OptionsFilterNormal", ID_OPTIONS_FILTER_NORMAL },
|
||||||
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
|
{ "OptionsFilterTVMode", ID_OPTIONS_FILTER_TVMODE },
|
||||||
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
|
{ "OptionsFilter2xSaI", ID_OPTIONS_FILTER_2XSAI },
|
||||||
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
|
{ "OptionsFilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI },
|
||||||
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
|
{ "OptionsFilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE },
|
||||||
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
|
{ "OptionsFilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL },
|
||||||
{ "OptionsFilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL },
|
{ "OptionsFilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL },
|
||||||
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
|
{ "OptionsFilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X },
|
||||||
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
|
{ "OptionsFilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X },
|
||||||
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
|
{ "OptionsFilterBilinear", ID_OPTIONS_FILTER_BILINEAR },
|
||||||
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
|
{ "OptionsFilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS },
|
||||||
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
|
{ "OptionsFilterScanlines", ID_OPTIONS_FILTER_SCANLINES },
|
||||||
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
|
{ "OptionsFilterHq2x", ID_OPTIONS_FILTER_HQ2X },
|
||||||
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
|
{ "OptionsFilterLq2x", ID_OPTIONS_FILTER_LQ2X },
|
||||||
{ "OptionsFilterxBRZ2x", ID_OPTIONS_FILTER_XBRZ2X },
|
{ "OptionsFilterxBRZ2x", ID_OPTIONS_FILTER_XBRZ2X },
|
||||||
{ "OptionsFilterxBRZ3x", ID_OPTIONS_FILTER_XBRZ3X },
|
{ "OptionsFilterxBRZ3x", ID_OPTIONS_FILTER_XBRZ3X },
|
||||||
{ "OptionsFilterxBRZ4x", ID_OPTIONS_FILTER_XBRZ4X },
|
{ "OptionsFilterxBRZ4x", ID_OPTIONS_FILTER_XBRZ4X },
|
||||||
{ "OptionsFilterxBRZ5x", ID_OPTIONS_FILTER_XBRZ5X },
|
{ "OptionsFilterxBRZ5x", ID_OPTIONS_FILTER_XBRZ5X },
|
||||||
{ "OptionsFilterxBRZ6x", ID_OPTIONS_FILTER_XBRZ6X },
|
{ "OptionsFilterxBRZ6x", ID_OPTIONS_FILTER_XBRZ6X },
|
||||||
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
|
{ "OptionsFilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE },
|
||||||
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
|
{ "OptionsFilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR },
|
||||||
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
|
{ "OptionsFilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART },
|
||||||
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
|
{ "OptionsFilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX },
|
||||||
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
|
{ "OptionsJoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 },
|
||||||
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
|
{ "OptionsJoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 },
|
||||||
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
|
{ "OptionsJoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 },
|
||||||
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
|
{ "OptionsJoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 },
|
||||||
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
|
{ "OptionsJoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE },
|
||||||
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
|
{ "OptionsJoypadAutofireA", ID_OPTIONS_JOYPAD_AUTOFIRE_A },
|
||||||
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
|
{ "OptionsJoypadAutofireB", ID_OPTIONS_JOYPAD_AUTOFIRE_B },
|
||||||
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
|
{ "OptionsJoypadAutofireL", ID_OPTIONS_JOYPAD_AUTOFIRE_L },
|
||||||
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
|
{ "OptionsJoypadAutofireR", ID_OPTIONS_JOYPAD_AUTOFIRE_R },
|
||||||
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
|
{ "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS },
|
||||||
{ "CheatsList", ID_CHEATS_CHEATLIST },
|
{ "CheatsList", ID_CHEATS_CHEATLIST },
|
||||||
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
|
{ "CheatsLoad", ID_CHEATS_LOADCHEATLIST },
|
||||||
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
|
{ "CheatsSave", ID_CHEATS_SAVECHEATLIST },
|
||||||
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
|
{ "CheatsDisable", ID_CHEATS_DISABLECHEATS },
|
||||||
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
|
{ "ToolsDebugGDB", ID_TOOLS_DEBUG_GDB },
|
||||||
{ "ToolsDebugGDBConfigurePort", ID_TOOLS_DEBUG_CONFIGUREPORT },
|
{ "ToolsDebugGDBConfigurePort", ID_TOOLS_DEBUG_CONFIGUREPORT },
|
||||||
{ "ToolsDebugGDBBreakOnLoad", ID_TOOLS_DEBUG_BREAKONLOAD },
|
{ "ToolsDebugGDBBreakOnLoad", ID_TOOLS_DEBUG_BREAKONLOAD },
|
||||||
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
|
{ "ToolsDebugGDBBreak", ID_TOOLS_DEBUG_BREAK },
|
||||||
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
|
{ "ToolsDebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT },
|
||||||
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
|
{ "ToolsDisassemble", ID_TOOLS_DISASSEMBLE },
|
||||||
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
|
{ "ToolsIOViewer", ID_TOOLS_IOVIEWER },
|
||||||
{ "ToolsLogging", ID_TOOLS_LOGGING },
|
{ "ToolsLogging", ID_TOOLS_LOGGING },
|
||||||
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
|
{ "ToolsMapViewer", ID_TOOLS_MAPVIEW },
|
||||||
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
|
{ "ToolsMemoryViewer", ID_TOOLS_MEMORYVIEWER },
|
||||||
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
|
{ "ToolsOAMViewer", ID_TOOLS_OAMVIEWER },
|
||||||
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
|
{ "ToolsPaletteViewer", ID_TOOLS_PALETTEVIEW },
|
||||||
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
|
{ "ToolsTileViewer", ID_TOOLS_TILEVIEWER },
|
||||||
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
|
{ "ToolsNextFrame", ID_DEBUG_NEXTFRAME },
|
||||||
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
|
{ "ToolsRecordSoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING },
|
||||||
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
|
{ "ToolsRecordSoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING },
|
||||||
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
|
{ "ToolsRecordAVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING },
|
||||||
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
|
{ "ToolsRecordAVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING },
|
||||||
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
|
{ "ToolsRecordMovieStartRecording", ID_TOOLS_RECORD_STARTMOVIERECORDING },
|
||||||
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
|
{ "ToolsRecordMovieStopRecording", ID_TOOLS_RECORD_STOPMOVIERECORDING },
|
||||||
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
|
{ "ToolsPlayMovieStartPlaying", ID_TOOLS_PLAY_STARTMOVIEPLAYING },
|
||||||
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
|
{ "ToolsPlayMovieStopPlaying", ID_TOOLS_PLAY_STOPMOVIEPLAYING },
|
||||||
{ "ToolsRewind", ID_TOOLS_REWIND },
|
{ "ToolsRewind", ID_TOOLS_REWIND },
|
||||||
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
|
{ "ToolsCustomize", ID_TOOLS_CUSTOMIZE },
|
||||||
{ "HelpBugReport", ID_HELP_BUGREPORT },
|
{ "HelpBugReport", ID_HELP_BUGREPORT },
|
||||||
{ "HelpFAQ", ID_HELP_FAQ },
|
{ "HelpFAQ", ID_HELP_FAQ },
|
||||||
{ "HelpAbout", ID_HELP_ABOUT },
|
{ "HelpAbout", ID_HELP_ABOUT },
|
||||||
{ "SystemMinimize", ID_SYSTEM_MINIMIZE }
|
{ "SystemMinimize", ID_SYSTEM_MINIMIZE }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool winAccelGetID(const char *command, WORD& id)
|
bool winAccelGetID(const char* command, WORD& id)
|
||||||
{
|
{
|
||||||
if(!initialized) {
|
if (!initialized) {
|
||||||
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
|
int count = sizeof(winAccelCommands) / sizeof(winAccelCommands[0]);
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
|
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)
|
void winAccelAddCommands(CAcceleratorManager& mgr)
|
||||||
{
|
{
|
||||||
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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
|
@ -1,14 +1,13 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "VBA.h"
|
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "Reg.h"
|
#include "Reg.h"
|
||||||
|
#include "VBA.h"
|
||||||
#include "WinResUtil.h"
|
#include "WinResUtil.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#define DIRECTINPUT_VERSION 0x0800
|
#define DIRECTINPUT_VERSION 0x0800
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
#pragma comment( lib, "dinput8" )
|
#pragma comment(lib, "dinput8")
|
||||||
#pragma comment( lib, "dxguid" )
|
#pragma comment(lib, "dxguid")
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -16,13 +15,13 @@
|
||||||
static char THIS_FILE[] = __FILE__;
|
static char THIS_FILE[] = __FILE__;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void directXMessage(const char *);
|
extern void directXMessage(const char*);
|
||||||
extern void winlog(const char *msg,...);
|
extern void winlog(const char* msg, ...);
|
||||||
|
|
||||||
#define POV_UP 1
|
#define POV_UP 1
|
||||||
#define POV_DOWN 2
|
#define POV_DOWN 2
|
||||||
#define POV_RIGHT 4
|
#define POV_RIGHT 4
|
||||||
#define POV_LEFT 8
|
#define POV_LEFT 8
|
||||||
|
|
||||||
class DirectInput : public Input {
|
class DirectInput : public Input {
|
||||||
public:
|
public:
|
||||||
|
@ -61,156 +60,147 @@ struct deviceInfo {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static deviceInfo *currentDevice = NULL;
|
static deviceInfo* currentDevice = NULL;
|
||||||
static int numDevices = 1;
|
static int numDevices = 1;
|
||||||
static deviceInfo *pDevices = NULL;
|
static deviceInfo* pDevices = NULL;
|
||||||
static LPDIRECTINPUT8 pDirectInput = NULL;
|
static LPDIRECTINPUT8 pDirectInput = NULL;
|
||||||
static int axisNumber = 0;
|
static int axisNumber = 0;
|
||||||
|
|
||||||
|
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] = {
|
||||||
|
DIK_LEFT, DIK_RIGHT,
|
||||||
|
DIK_UP, DIK_DOWN,
|
||||||
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] =
|
DIK_X, DIK_Z,
|
||||||
{
|
DIK_RETURN, DIK_BACK,
|
||||||
DIK_LEFT, DIK_RIGHT,
|
DIK_A, DIK_S,
|
||||||
DIK_UP, DIK_DOWN,
|
|
||||||
DIK_X, DIK_Z,
|
|
||||||
DIK_RETURN,DIK_BACK,
|
|
||||||
DIK_A, DIK_S,
|
|
||||||
DIK_SPACE, DIK_F12,
|
DIK_SPACE, DIK_F12,
|
||||||
DIK_C,
|
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
|
DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void winReadKey(const char* name, KeyList& Keys)
|
||||||
void winReadKey(const char *name, KeyList& Keys)
|
|
||||||
{
|
{
|
||||||
CString TxtKeyList = regQueryStringValue(name, "");
|
CString TxtKeyList = regQueryStringValue(name, "");
|
||||||
int curPos= 0;
|
int curPos = 0;
|
||||||
|
|
||||||
CString resToken=TxtKeyList.Tokenize(",",curPos);
|
CString resToken = TxtKeyList.Tokenize(",", curPos);
|
||||||
while (resToken != "")
|
while (resToken != "") {
|
||||||
{
|
Keys.AddTail(atoi(resToken));
|
||||||
Keys.AddTail(atoi(resToken));
|
resToken = TxtKeyList.Tokenize(",", curPos);
|
||||||
resToken= TxtKeyList.Tokenize(",",curPos);
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
sprintf(buffer, "Joy%d_%s", num, name);
|
||||||
winReadKey(buffer, Keys);
|
winReadKey(buffer, Keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void winReadKeys()
|
void winReadKeys()
|
||||||
{
|
{
|
||||||
|
|
||||||
for(int i = 0; i < JOYPADS; i++) {
|
for (int i = 0; i < JOYPADS; i++) {
|
||||||
winReadKey("Left", i, theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]);
|
winReadKey("Left", i, theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]);
|
||||||
winReadKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
|
winReadKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
|
||||||
winReadKey("Up", i, theApp.input->joypaddata[JOYPAD(i,KEY_UP)]);
|
winReadKey("Up", i, theApp.input->joypaddata[JOYPAD(i, KEY_UP)]);
|
||||||
winReadKey("Down", i, theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]);
|
winReadKey("Down", i, theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]);
|
||||||
winReadKey("A", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]);
|
winReadKey("A", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]);
|
||||||
winReadKey("B", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]);
|
winReadKey("B", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]);
|
||||||
winReadKey("L", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]);
|
winReadKey("L", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]);
|
||||||
winReadKey("R", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]);
|
winReadKey("R", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]);
|
||||||
winReadKey("Start", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]);
|
winReadKey("Start", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]);
|
||||||
winReadKey("Select", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]);
|
winReadKey("Select", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]);
|
||||||
winReadKey("Speed", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]);
|
winReadKey("Speed", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]);
|
||||||
winReadKey("Capture", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]);
|
winReadKey("Capture", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]);
|
||||||
winReadKey("GS", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]);
|
winReadKey("GS", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]);
|
||||||
}
|
}
|
||||||
winReadKey("Motion_Left", theApp.input->joypaddata[MOTION(KEY_LEFT)]);
|
winReadKey("Motion_Left", theApp.input->joypaddata[MOTION(KEY_LEFT)]);
|
||||||
winReadKey("Motion_Right", theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
|
winReadKey("Motion_Right", theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
|
||||||
winReadKey("Motion_Up", theApp.input->joypaddata[MOTION(KEY_UP)]);
|
winReadKey("Motion_Up", theApp.input->joypaddata[MOTION(KEY_UP)]);
|
||||||
winReadKey("Motion_Down", theApp.input->joypaddata[MOTION(KEY_DOWN)]);
|
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();
|
POSITION p = value.GetHeadPosition();
|
||||||
while(p!=NULL)
|
while (p != NULL) {
|
||||||
{
|
CString tmp;
|
||||||
CString tmp;
|
tmp.Format("%d", value.GetNext(p));
|
||||||
tmp.Format("%d", value.GetNext(p));
|
txtKeys += tmp;
|
||||||
txtKeys+=tmp;
|
if (p != NULL)
|
||||||
if (p!=NULL)
|
txtKeys += ",";
|
||||||
txtKeys+=",";
|
}
|
||||||
}
|
regSetStringValue(name, 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);
|
sprintf(buffer, "Joy%d_%s", num, name);
|
||||||
winSaveKey(buffer, value);
|
winSaveKey(buffer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void winSaveKeys()
|
void winSaveKeys()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < JOYPADS; i++) {
|
for (int i = 0; i < JOYPADS; i++) {
|
||||||
winSaveKey("Left", i, theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]);
|
winSaveKey("Left", i, theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]);
|
||||||
winSaveKey("Right", i, theApp.input->joypaddata[JOYPAD(i,KEY_RIGHT)]);
|
winSaveKey("Right", i, theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]);
|
||||||
winSaveKey("Up", i, theApp.input->joypaddata[JOYPAD(i,KEY_UP)]);
|
winSaveKey("Up", i, theApp.input->joypaddata[JOYPAD(i, KEY_UP)]);
|
||||||
winSaveKey("Speed", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]);
|
winSaveKey("Speed", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]);
|
||||||
winSaveKey("Capture", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]);
|
winSaveKey("Capture", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]);
|
||||||
winSaveKey("GS", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]);
|
winSaveKey("GS", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]);
|
||||||
winSaveKey("Down", i, theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]);
|
winSaveKey("Down", i, theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]);
|
||||||
winSaveKey("A", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]);
|
winSaveKey("A", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]);
|
||||||
winSaveKey("B", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]);
|
winSaveKey("B", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]);
|
||||||
winSaveKey("L", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]);
|
winSaveKey("L", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]);
|
||||||
winSaveKey("R", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]);
|
winSaveKey("R", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]);
|
||||||
winSaveKey("Start", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]);
|
winSaveKey("Start", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]);
|
||||||
winSaveKey("Select", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]);
|
winSaveKey("Select", i, theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]);
|
||||||
}
|
}
|
||||||
regSetDwordValue("joyVersion", 1);
|
regSetDwordValue("joyVersion", 1);
|
||||||
|
|
||||||
winSaveKey("Motion_Left",
|
winSaveKey("Motion_Left",
|
||||||
theApp.input->joypaddata[MOTION(KEY_LEFT)]);
|
theApp.input->joypaddata[MOTION(KEY_LEFT)]);
|
||||||
winSaveKey("Motion_Right",
|
winSaveKey("Motion_Right",
|
||||||
theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
|
theApp.input->joypaddata[MOTION(KEY_RIGHT)]);
|
||||||
winSaveKey("Motion_Up",
|
winSaveKey("Motion_Up",
|
||||||
theApp.input->joypaddata[MOTION(KEY_UP)]);
|
theApp.input->joypaddata[MOTION(KEY_UP)]);
|
||||||
winSaveKey("Motion_Down",
|
winSaveKey("Motion_Down",
|
||||||
theApp.input->joypaddata[MOTION(KEY_DOWN)]);
|
theApp.input->joypaddata[MOTION(KEY_DOWN)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK EnumPovsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
|
static BOOL CALLBACK EnumPovsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi,
|
||||||
VOID* pContext )
|
VOID* pContext)
|
||||||
{
|
{
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
|
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,
|
HRESULT hRet = pDirectInput->CreateDevice(pInst->guidInstance,
|
||||||
&pDevices[numDevices].device,
|
&pDevices[numDevices].device,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (hRet != DI_OK)
|
if (hRet != DI_OK)
|
||||||
return DIENUM_STOP;
|
return DIENUM_STOP;
|
||||||
|
|
||||||
DIDEVCAPS caps;
|
DIDEVCAPS caps;
|
||||||
caps.dwSize=sizeof(DIDEVCAPS);
|
caps.dwSize = sizeof(DIDEVCAPS);
|
||||||
|
|
||||||
hRet = pDevices[numDevices].device->GetCapabilities(&caps);
|
hRet = pDevices[numDevices].device->GetCapabilities(&caps);
|
||||||
|
|
||||||
if (hRet == DI_OK) {
|
if (hRet == DI_OK) {
|
||||||
if (caps.dwFlags & DIDC_POLLEDDATAFORMAT ||
|
if (caps.dwFlags & DIDC_POLLEDDATAFORMAT || caps.dwFlags & DIDC_POLLEDDEVICE)
|
||||||
caps.dwFlags & DIDC_POLLEDDEVICE)
|
|
||||||
pDevices[numDevices].isPolled = TRUE;
|
pDevices[numDevices].isPolled = TRUE;
|
||||||
|
|
||||||
pDevices[numDevices].nButtons = caps.dwButtons;
|
pDevices[numDevices].nButtons = caps.dwButtons;
|
||||||
|
@ -224,15 +214,13 @@ static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
numDevices++;
|
numDevices++;
|
||||||
|
|
||||||
|
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK DIEnumDevicesCallback2(LPCDIDEVICEINSTANCE pInst,
|
BOOL CALLBACK DIEnumDevicesCallback2(LPCDIDEVICEINSTANCE pInst,
|
||||||
LPVOID lpvContext)
|
LPVOID lpvContext)
|
||||||
{
|
{
|
||||||
numDevices++;
|
numDevices++;
|
||||||
|
|
||||||
|
@ -257,37 +245,34 @@ static int getPovState(DWORD value)
|
||||||
|
|
||||||
static void checkKeys()
|
static void checkKeys()
|
||||||
{
|
{
|
||||||
LONG_PTR dev = 0;
|
LONG_PTR dev = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++)
|
for (i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++) {
|
||||||
{
|
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
|
||||||
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
|
theApp.input->joypaddata[i].AddTail(defvalues[i]);
|
||||||
theApp.input->joypaddata[i].AddTail(defvalues[i]);
|
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
|
||||||
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
|
while (p != NULL) {
|
||||||
while(p!=NULL)
|
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
|
||||||
{
|
if (k > 0 && DEVICEOF(k) < numDevices)
|
||||||
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
|
pDevices[DEVICEOF(k)].needed = true;
|
||||||
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()
|
static bool readKeyboard()
|
||||||
{
|
{
|
||||||
if (pDevices[0].needed) {
|
if (pDevices[0].needed) {
|
||||||
HRESULT hret = pDevices[0].device->
|
HRESULT hret = pDevices[0].device->GetDeviceState(256,
|
||||||
GetDeviceState(256,
|
(LPVOID)pDevices[0].data);
|
||||||
(LPVOID)pDevices[0].data);
|
|
||||||
|
|
||||||
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
||||||
hret = pDevices[0].device->Acquire();
|
hret = pDevices[0].device->Acquire();
|
||||||
if (hret != DI_OK)
|
if (hret != DI_OK)
|
||||||
return false;
|
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;
|
return hret == DI_OK;
|
||||||
|
@ -301,9 +286,8 @@ static bool readJoystick(int joy)
|
||||||
if (pDevices[joy].isPolled)
|
if (pDevices[joy].isPolled)
|
||||||
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
||||||
|
|
||||||
HRESULT hret = pDevices[joy].device->
|
HRESULT hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
|
||||||
GetDeviceState(sizeof(DIJOYSTATE),
|
(LPVOID)&pDevices[joy].state);
|
||||||
(LPVOID)&pDevices[joy].state);
|
|
||||||
|
|
||||||
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
||||||
hret = pDevices[joy].device->Acquire();
|
hret = pDevices[joy].device->Acquire();
|
||||||
|
@ -313,9 +297,8 @@ static bool readJoystick(int joy)
|
||||||
if (pDevices[joy].isPolled)
|
if (pDevices[joy].isPolled)
|
||||||
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
||||||
|
|
||||||
hret = pDevices[joy].device->
|
hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
|
||||||
GetDeviceState(sizeof(DIJOYSTATE),
|
(LPVOID)&pDevices[joy].state);
|
||||||
(LPVOID)&pDevices[joy].state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,8 +320,7 @@ static void checkKeyboard()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hret = pDevices[0].device->
|
hret = pDevices[0].device->GetDeviceState(256, (LPVOID)keystate);
|
||||||
GetDeviceState(256, (LPVOID)keystate);
|
|
||||||
|
|
||||||
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
||||||
return;
|
return;
|
||||||
|
@ -346,9 +328,10 @@ static void checkKeyboard()
|
||||||
|
|
||||||
if (hret == DI_OK) {
|
if (hret == DI_OK) {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
if (keystate[i] == pDevices[0].data[i]) continue;
|
if (keystate[i] == pDevices[0].data[i])
|
||||||
|
continue;
|
||||||
if (KEYDOWN(keystate, i)) {
|
if (KEYDOWN(keystate, i)) {
|
||||||
SendMessage(GetFocus(), JOYCONFIG_MESSAGE,0,i);
|
SendMessage(GetFocus(), JOYCONFIG_MESSAGE, 0, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,18 +343,17 @@ static void checkJoypads()
|
||||||
{
|
{
|
||||||
DIDEVICEOBJECTINSTANCE di;
|
DIDEVICEOBJECTINSTANCE di;
|
||||||
|
|
||||||
ZeroMemory(&di,sizeof(DIDEVICEOBJECTINSTANCE));
|
ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
|
||||||
|
|
||||||
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
|
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
|
||||||
|
|
||||||
int i =0;
|
int i = 0;
|
||||||
|
|
||||||
DIJOYSTATE joystick;
|
DIJOYSTATE joystick;
|
||||||
|
|
||||||
for (i = 1; i < numDevices; i++) {
|
for (i = 1; i < numDevices; i++) {
|
||||||
HRESULT hret = pDevices[i].device->Acquire();
|
HRESULT hret = pDevices[i].device->Acquire();
|
||||||
|
|
||||||
|
|
||||||
if (pDevices[i].isPolled)
|
if (pDevices[i].isPolled)
|
||||||
((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll();
|
((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll();
|
||||||
|
|
||||||
|
@ -387,10 +369,11 @@ static void checkJoypads()
|
||||||
|
|
||||||
for (j = 0; j < pDevices[i].nButtons; j++) {
|
for (j = 0; j < pDevices[i].nButtons; j++) {
|
||||||
if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j])
|
if (((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j])
|
||||||
& joystick.rgbButtons[j]) & 0x80) {
|
& joystick.rgbButtons[j])
|
||||||
|
& 0x80) {
|
||||||
HWND focus = GetFocus();
|
HWND focus = GetFocus();
|
||||||
|
|
||||||
SendMessage(focus, JOYCONFIG_MESSAGE, i,j+128);
|
SendMessage(focus, JOYCONFIG_MESSAGE, i, j + 128);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,30 +381,30 @@ static void checkJoypads()
|
||||||
LONG value = pDevices[i].axis[j].center;
|
LONG value = pDevices[i].axis[j].center;
|
||||||
LONG old = 0;
|
LONG old = 0;
|
||||||
|
|
||||||
const DWORD offset = pDevices[i].axis[j].offset;
|
const DWORD offset = pDevices[i].axis[j].offset;
|
||||||
value = *(LONG*)(((char*)&joystick.lX) + offset);
|
value = *(LONG*)(((char*)&joystick.lX) + offset);
|
||||||
old = *(LONG*)(((char*)&pDevices[i].state.lX) + offset);
|
old = *(LONG*)(((char*)&pDevices[i].state.lX) + offset);
|
||||||
|
|
||||||
if (value != old) {
|
if (value != old) {
|
||||||
if (value < pDevices[i].axis[j].negative)
|
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)
|
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])) {
|
if (LOWORD(pDevices[i].state.rgdwPOV[j]) != LOWORD(joystick.rgdwPOV[j])) {
|
||||||
int state = getPovState(joystick.rgdwPOV[j]);
|
int state = getPovState(joystick.rgdwPOV[j]);
|
||||||
|
|
||||||
if (state & POV_UP)
|
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)
|
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)
|
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)
|
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);
|
LONG_PTR k = (key & 255);
|
||||||
|
|
||||||
if (dev == 0) {
|
if (dev == 0) {
|
||||||
return KEYDOWN(pDevices[0].data,k);
|
return KEYDOWN(pDevices[0].data, k);
|
||||||
} else if (dev >= numDevices) {
|
} else if (dev >= numDevices) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
if (k < 16) {
|
if (k < 16) {
|
||||||
LONG_PTR axis = k >> 1;
|
LONG_PTR axis = k >> 1;
|
||||||
LONG value = pDevices[dev].axis[axis].center;
|
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)
|
if (k & 1)
|
||||||
return value > pDevices[dev].axis[axis].positive;
|
return value > pDevices[dev].axis[axis].positive;
|
||||||
|
@ -454,26 +437,25 @@ BOOL checkKey(LONG_PTR key)
|
||||||
int state = getPovState(pDevices[dev].state.rgdwPOV[hat]);
|
int state = getPovState(pDevices[dev].state.rgdwPOV[hat]);
|
||||||
BOOL res = FALSE;
|
BOOL res = FALSE;
|
||||||
|
|
||||||
res = state & (1 << (k & 3));
|
res = state & (1 << (k & 3));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
} else if (k >= 128) {
|
} else if (k >= 128) {
|
||||||
return pDevices[dev].state.rgbButtons[k-128] & 0x80;
|
return pDevices[dev].state.rgbButtons[k - 128] & 0x80;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL checkKey(KeyList &k)
|
BOOL checkKey(KeyList& k)
|
||||||
{
|
{
|
||||||
POSITION p = k.GetHeadPosition();
|
POSITION p = k.GetHeadPosition();
|
||||||
while(p!=NULL)
|
while (p != NULL) {
|
||||||
{
|
if (checkKey(k.GetNext(p)))
|
||||||
if (checkKey(k.GetNext(p)))
|
return TRUE;
|
||||||
return TRUE;
|
}
|
||||||
}
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectInput::DirectInput()
|
DirectInput::DirectInput()
|
||||||
|
@ -485,7 +467,7 @@ DirectInput::~DirectInput()
|
||||||
saveSettings();
|
saveSettings();
|
||||||
if (pDirectInput != NULL) {
|
if (pDirectInput != NULL) {
|
||||||
if (pDevices) {
|
if (pDevices) {
|
||||||
for (int i = 0; i < numDevices ; i++) {
|
for (int i = 0; i < numDevices; i++) {
|
||||||
if (pDevices[i].device) {
|
if (pDevices[i].device) {
|
||||||
pDevices[i].device->Unacquire();
|
pDevices[i].device->Unacquire();
|
||||||
pDevices[i].device->Release();
|
pDevices[i].device->Release();
|
||||||
|
@ -503,44 +485,40 @@ DirectInput::~DirectInput()
|
||||||
|
|
||||||
bool DirectInput::initialize()
|
bool DirectInput::initialize()
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = DirectInput8Create(
|
|
||||||
GetModuleHandle( NULL ),
|
|
||||||
DIRECTINPUT_VERSION,
|
|
||||||
IID_IDirectInput8,
|
|
||||||
(LPVOID *)&pDirectInput,
|
|
||||||
NULL );
|
|
||||||
ASSERT( hr == DI_OK );
|
|
||||||
if( hr != DI_OK ) return false;
|
|
||||||
|
|
||||||
|
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,
|
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||||
DIEnumDevicesCallback2,
|
DIEnumDevicesCallback2,
|
||||||
NULL,
|
NULL,
|
||||||
DIEDFL_ATTACHEDONLY);
|
DIEDFL_ATTACHEDONLY);
|
||||||
|
|
||||||
|
pDevices = (deviceInfo*)calloc(numDevices, sizeof(deviceInfo));
|
||||||
|
|
||||||
|
hr = pDirectInput->CreateDevice(GUID_SysKeyboard, &pDevices[0].device, NULL);
|
||||||
pDevices = (deviceInfo *)calloc(numDevices, sizeof(deviceInfo));
|
|
||||||
|
|
||||||
hr = pDirectInput->CreateDevice(GUID_SysKeyboard,&pDevices[0].device,NULL);
|
|
||||||
pDevices[0].isPolled = false;
|
pDevices[0].isPolled = false;
|
||||||
pDevices[0].needed = true;
|
pDevices[0].needed = true;
|
||||||
pDevices[0].first = true;
|
pDevices[0].first = true;
|
||||||
|
|
||||||
if (hr != DI_OK) {
|
if (hr != DI_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
numDevices = 1;
|
numDevices = 1;
|
||||||
|
|
||||||
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||||
DIEnumDevicesCallback,
|
DIEnumDevicesCallback,
|
||||||
NULL,
|
NULL,
|
||||||
DIEDFL_ATTACHEDONLY);
|
DIEDFL_ATTACHEDONLY);
|
||||||
|
|
||||||
|
|
||||||
if (hr != DI_OK) {
|
if (hr != DI_OK) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -556,45 +534,41 @@ bool DirectInput::initialize()
|
||||||
for (i = 1; i < numDevices; i++) {
|
for (i = 1; i < numDevices; i++) {
|
||||||
pDevices[i].device->SetDataFormat(&c_dfDIJoystick);
|
pDevices[i].device->SetDataFormat(&c_dfDIJoystick);
|
||||||
pDevices[i].needed = false;
|
pDevices[i].needed = false;
|
||||||
pDevices[i].first = true;
|
pDevices[i].first = true;
|
||||||
currentDevice = &pDevices[i];
|
currentDevice = &pDevices[i];
|
||||||
axisNumber = 0;
|
axisNumber = 0;
|
||||||
|
|
||||||
// get up to 6 axes and 2 sliders
|
// get up to 6 axes and 2 sliders
|
||||||
DIPROPRANGE range;
|
DIPROPRANGE range;
|
||||||
range.diph.dwSize = sizeof(range);
|
range.diph.dwSize = sizeof(range);
|
||||||
range.diph.dwHeaderSize = sizeof(range.diph);
|
range.diph.dwHeaderSize = sizeof(range.diph);
|
||||||
range.diph.dwHow = DIPH_BYOFFSET;
|
range.diph.dwHow = DIPH_BYOFFSET;
|
||||||
// screw EnumObjects, just go through all the axis offsets and try to GetProperty
|
// screw EnumObjects, just go through all the axis offsets and try to GetProperty
|
||||||
// this should be more foolproof, less code, and probably faster
|
// this should be more foolproof, less code, and probably faster
|
||||||
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG))
|
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG)) {
|
||||||
{
|
range.diph.dwObj = offset;
|
||||||
range.diph.dwObj = offset;
|
// try to set some nice power of 2 values (8192)
|
||||||
// try to set some nice power of 2 values (8192)
|
range.lMin = -(1 << 13);
|
||||||
range.lMin = -(1 << 13);
|
range.lMax = (1 << 13);
|
||||||
range.lMax = (1 << 13);
|
pDevices[i].device->SetProperty(DIPROP_RANGE, &range.diph);
|
||||||
pDevices[i].device->SetProperty(DIPROP_RANGE, &range.diph);
|
// but i guess not all devices support setting range
|
||||||
// but i guess not all devices support setting range
|
// so i getproperty right afterward incase it didn't set :P
|
||||||
// so i getproperty right afterward incase it didn't set :P
|
// this also checks that the axis is present
|
||||||
// this also checks that the axis is present
|
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph))) {
|
||||||
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph)))
|
const LONG center = (range.lMin + range.lMax) / 2;
|
||||||
{
|
const LONG threshold = (range.lMax - center) / 2;
|
||||||
const LONG center = (range.lMin + range.lMax)/2;
|
|
||||||
const LONG threshold = (range.lMax - center)/2;
|
|
||||||
|
|
||||||
currentDevice->axis[axisNumber].center = center;
|
currentDevice->axis[axisNumber].center = center;
|
||||||
currentDevice->axis[axisNumber].negative = center - threshold;
|
currentDevice->axis[axisNumber].negative = center - threshold;
|
||||||
currentDevice->axis[axisNumber].positive = center + threshold;
|
currentDevice->axis[axisNumber].positive = center + threshold;
|
||||||
currentDevice->axis[axisNumber].offset = offset;
|
currentDevice->axis[axisNumber].offset = offset;
|
||||||
|
|
||||||
++axisNumber;
|
++axisNumber;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
|
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
|
||||||
|
|
||||||
|
|
||||||
currentDevice = NULL;
|
currentDevice = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,71 +594,71 @@ bool DirectInput::readDevices()
|
||||||
|
|
||||||
u32 DirectInput::readDevice(int which)
|
u32 DirectInput::readDevice(int which)
|
||||||
{
|
{
|
||||||
u32 res = 0;
|
u32 res = 0;
|
||||||
int i = joypadDefault;
|
int i = joypadDefault;
|
||||||
if(which >= 0 && which <= 3)
|
if (which >= 0 && which <= 3)
|
||||||
i = which;
|
i = which;
|
||||||
|
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_A)]))
|
||||||
res |= 1;
|
res |= 1;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_B)]))
|
||||||
res |= 2;
|
res |= 2;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SELECT)]))
|
||||||
res |= 4;
|
res |= 4;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_START)]))
|
||||||
res |= 8;
|
res |= 8;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_RIGHT)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_RIGHT)]))
|
||||||
res |= 16;
|
res |= 16;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_LEFT)]))
|
||||||
res |= 32;
|
res |= 32;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_UP)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_UP)]))
|
||||||
res |= 64;
|
res |= 64;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_DOWN)]))
|
||||||
res |= 128;
|
res |= 128;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_R)]))
|
||||||
res |= 256;
|
res |= 256;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_L)]))
|
||||||
res |= 512;
|
res |= 512;
|
||||||
|
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_GS)]))
|
||||||
res |= 4096;
|
res |= 4096;
|
||||||
|
|
||||||
if(autoFire) {
|
if (autoFire) {
|
||||||
res &= (~autoFire);
|
res &= (~autoFire);
|
||||||
if(autoFireToggle)
|
if (autoFireToggle)
|
||||||
res |= autoFire;
|
res |= autoFire;
|
||||||
autoFireToggle = !autoFireToggle;
|
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(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)
|
CString DirectInput::getKeyName(LONG_PTR key)
|
||||||
|
@ -694,31 +668,30 @@ CString DirectInput::getKeyName(LONG_PTR key)
|
||||||
|
|
||||||
DIDEVICEOBJECTINSTANCE di;
|
DIDEVICEOBJECTINSTANCE di;
|
||||||
|
|
||||||
ZeroMemory(&di,sizeof(DIDEVICEOBJECTINSTANCE));
|
ZeroMemory(&di, sizeof(DIDEVICEOBJECTINSTANCE));
|
||||||
|
|
||||||
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
|
di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE);
|
||||||
|
|
||||||
CString winBuffer = winResLoadString(IDS_ERROR);
|
CString winBuffer = winResLoadString(IDS_ERROR);
|
||||||
|
|
||||||
if (d == 0) {
|
if (d == 0) {
|
||||||
pDevices[0].device->GetObjectInfo( &di, (DWORD)key, DIPH_BYOFFSET );
|
pDevices[0].device->GetObjectInfo(&di, (DWORD)key, DIPH_BYOFFSET);
|
||||||
winBuffer = di.tszName;
|
winBuffer = di.tszName;
|
||||||
} else if (d < numDevices) {
|
} else if (d < numDevices) {
|
||||||
if (k < 16)
|
if (k < 16) {
|
||||||
{
|
pDevices[d].device->GetObjectInfo(&di,
|
||||||
pDevices[d].device->GetObjectInfo(&di,
|
pDevices[d].axis[k >> 1].offset,
|
||||||
pDevices[d].axis[k>>1].offset,
|
DIPH_BYOFFSET);
|
||||||
DIPH_BYOFFSET);
|
if (k & 1)
|
||||||
if (k & 1)
|
winBuffer.Format("Joy %d %s +", d, di.tszName);
|
||||||
winBuffer.Format("Joy %d %s +", d, di.tszName);
|
else
|
||||||
else
|
winBuffer.Format("Joy %d %s -", d, di.tszName);
|
||||||
winBuffer.Format("Joy %d %s -", d, di.tszName);
|
|
||||||
} else if (k < 48) {
|
} else if (k < 48) {
|
||||||
LONG_PTR hat = (k >> 2) & 3;
|
LONG_PTR hat = (k >> 2) & 3;
|
||||||
pDevices[d].device->GetObjectInfo(&di,
|
pDevices[d].device->GetObjectInfo(&di,
|
||||||
(DWORD)DIJOFS_POV(hat),
|
(DWORD)DIJOFS_POV(hat),
|
||||||
DIPH_BYOFFSET);
|
DIPH_BYOFFSET);
|
||||||
char *dir = "up";
|
char* dir = "up";
|
||||||
LONG_PTR dd = k & 3;
|
LONG_PTR dd = k & 3;
|
||||||
if (dd == 1)
|
if (dd == 1)
|
||||||
dir = "down";
|
dir = "down";
|
||||||
|
@ -729,16 +702,14 @@ CString DirectInput::getKeyName(LONG_PTR key)
|
||||||
winBuffer.Format("Joy %d %s %s", d, di.tszName, dir);
|
winBuffer.Format("Joy %d %s %s", d, di.tszName, dir);
|
||||||
} else {
|
} else {
|
||||||
pDevices[d].device->GetObjectInfo(&di,
|
pDevices[d].device->GetObjectInfo(&di,
|
||||||
(DWORD)DIJOFS_BUTTON(k-128),
|
(DWORD)DIJOFS_BUTTON(k - 128),
|
||||||
DIPH_BYOFFSET);
|
DIPH_BYOFFSET);
|
||||||
winBuffer.Format(winResLoadString(IDS_JOY_BUTTON),d,di.tszName);
|
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;
|
return winBuffer;
|
||||||
}
|
}
|
||||||
|
@ -750,65 +721,64 @@ void DirectInput::checkKeys()
|
||||||
|
|
||||||
void DirectInput::checkMotionKeys()
|
void DirectInput::checkMotionKeys()
|
||||||
{
|
{
|
||||||
if(checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
|
if (checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
|
||||||
sunBars--;
|
sunBars--;
|
||||||
if (sunBars < 1)
|
if (sunBars < 1)
|
||||||
sunBars = 1;
|
sunBars = 1;
|
||||||
|
|
||||||
sensorX += 3;
|
sensorX += 3;
|
||||||
if(sensorX > 2197)
|
if (sensorX > 2197)
|
||||||
sensorX = 2197;
|
sensorX = 2197;
|
||||||
if(sensorX < 2047)
|
if (sensorX < 2047)
|
||||||
sensorX = 2057;
|
sensorX = 2057;
|
||||||
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
|
} else if (checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
|
||||||
sunBars++;
|
sunBars++;
|
||||||
if (sunBars > 100)
|
if (sunBars > 100)
|
||||||
sunBars = 100;
|
sunBars = 100;
|
||||||
|
|
||||||
sensorX -= 3;
|
sensorX -= 3;
|
||||||
if(sensorX < 1897)
|
if (sensorX < 1897)
|
||||||
sensorX = 1897;
|
sensorX = 1897;
|
||||||
if(sensorX > 2047)
|
if (sensorX > 2047)
|
||||||
sensorX = 2037;
|
sensorX = 2037;
|
||||||
} else if(sensorX > 2047) {
|
} else if (sensorX > 2047) {
|
||||||
sensorX -= 2;
|
sensorX -= 2;
|
||||||
if(sensorX < 2047)
|
if (sensorX < 2047)
|
||||||
sensorX = 2047;
|
sensorX = 2047;
|
||||||
} else {
|
} else {
|
||||||
sensorX += 2;
|
sensorX += 2;
|
||||||
if(sensorX > 2047)
|
if (sensorX > 2047)
|
||||||
sensorX = 2047;
|
sensorX = 2047;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
|
if (checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
|
||||||
sensorY += 3;
|
sensorY += 3;
|
||||||
if(sensorY > 2197)
|
if (sensorY > 2197)
|
||||||
sensorY = 2197;
|
sensorY = 2197;
|
||||||
if(sensorY < 2047)
|
if (sensorY < 2047)
|
||||||
sensorY = 2057;
|
sensorY = 2057;
|
||||||
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
|
} else if (checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
|
||||||
sensorY -= 3;
|
sensorY -= 3;
|
||||||
if(sensorY < 1897)
|
if (sensorY < 1897)
|
||||||
sensorY = 1897;
|
sensorY = 1897;
|
||||||
if(sensorY > 2047)
|
if (sensorY > 2047)
|
||||||
sensorY = 2037;
|
sensorY = 2037;
|
||||||
} else if(sensorY > 2047) {
|
} else if (sensorY > 2047) {
|
||||||
sensorY -= 2;
|
sensorY -= 2;
|
||||||
if(sensorY < 2047)
|
if (sensorY < 2047)
|
||||||
sensorY = 2047;
|
sensorY = 2047;
|
||||||
} else {
|
} else {
|
||||||
sensorY += 2;
|
sensorY += 2;
|
||||||
if(sensorY > 2047)
|
if (sensorY > 2047)
|
||||||
sensorY = 2047;
|
sensorY = 2047;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Input *newDirectInput()
|
Input* newDirectInput()
|
||||||
{
|
{
|
||||||
return new DirectInput;
|
return new DirectInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectInput::checkDevices()
|
void DirectInput::checkDevices()
|
||||||
{
|
{
|
||||||
checkJoypads();
|
checkJoypads();
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
// Internals
|
// Internals
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
#include "../common/SoundDriver.h"
|
||||||
#include "../gba/GBA.h"
|
#include "../gba/GBA.h"
|
||||||
#include "../gba/Globals.h"
|
#include "../gba/Globals.h"
|
||||||
#include "../gba/Sound.h"
|
#include "../gba/Sound.h"
|
||||||
#include "../common/SoundDriver.h"
|
|
||||||
|
|
||||||
// DirectSound8
|
// DirectSound8
|
||||||
#define DIRECTSOUND_VERSION 0x0800
|
#define DIRECTSOUND_VERSION 0x0800
|
||||||
|
@ -21,296 +21,284 @@
|
||||||
|
|
||||||
extern bool soundBufferLow;
|
extern bool soundBufferLow;
|
||||||
|
|
||||||
class DirectSound : public SoundDriver
|
class DirectSound : public SoundDriver {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
|
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
|
||||||
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
|
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
|
||||||
LPDIRECTSOUNDBUFFER dsbSecondary; // Secondary DirectSound buffer
|
LPDIRECTSOUNDBUFFER dsbSecondary; // Secondary DirectSound buffer
|
||||||
LPDIRECTSOUNDNOTIFY8 dsbNotify;
|
LPDIRECTSOUNDNOTIFY8 dsbNotify;
|
||||||
HANDLE dsbEvent;
|
HANDLE dsbEvent;
|
||||||
WAVEFORMATEX wfx; // Primary buffer wave format
|
WAVEFORMATEX wfx; // Primary buffer wave format
|
||||||
int soundBufferLen;
|
int soundBufferLen;
|
||||||
int soundBufferTotalLen;
|
int soundBufferTotalLen;
|
||||||
unsigned int soundNextPosition;
|
unsigned int soundNextPosition;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirectSound();
|
DirectSound();
|
||||||
virtual ~DirectSound();
|
virtual ~DirectSound();
|
||||||
|
|
||||||
bool init(long sampleRate); // initialize the primary and secondary sound buffer
|
bool init(long sampleRate); // initialize the primary and secondary sound buffer
|
||||||
void pause(); // pause the secondary sound buffer
|
void pause(); // pause the secondary sound buffer
|
||||||
void reset(); // stop and reset the secondary sound buffer
|
void reset(); // stop and reset the secondary sound buffer
|
||||||
void resume(); // resume 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
|
void write(u16* finalWave, int length); // write the emulated sound to the secondary sound buffer
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DirectSound::DirectSound()
|
DirectSound::DirectSound()
|
||||||
{
|
{
|
||||||
pDirectSound = NULL;
|
pDirectSound = NULL;
|
||||||
dsbPrimary = NULL;
|
dsbPrimary = NULL;
|
||||||
dsbSecondary = NULL;
|
dsbSecondary = NULL;
|
||||||
dsbNotify = NULL;
|
dsbNotify = NULL;
|
||||||
dsbEvent = NULL;
|
dsbEvent = NULL;
|
||||||
|
|
||||||
soundBufferTotalLen = 14700;
|
soundBufferTotalLen = 14700;
|
||||||
soundNextPosition = 0;
|
soundNextPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DirectSound::~DirectSound()
|
DirectSound::~DirectSound()
|
||||||
{
|
{
|
||||||
if(dsbNotify) {
|
if (dsbNotify) {
|
||||||
dsbNotify->Release();
|
dsbNotify->Release();
|
||||||
dsbNotify = NULL;
|
dsbNotify = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dsbEvent) {
|
if (dsbEvent) {
|
||||||
CloseHandle(dsbEvent);
|
CloseHandle(dsbEvent);
|
||||||
dsbEvent = NULL;
|
dsbEvent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pDirectSound) {
|
if (pDirectSound) {
|
||||||
if(dsbPrimary) {
|
if (dsbPrimary) {
|
||||||
dsbPrimary->Release();
|
dsbPrimary->Release();
|
||||||
dsbPrimary = NULL;
|
dsbPrimary = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dsbSecondary) {
|
if (dsbSecondary) {
|
||||||
dsbSecondary->Release();
|
dsbSecondary->Release();
|
||||||
dsbSecondary = NULL;
|
dsbSecondary = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDirectSound->Release();
|
pDirectSound->Release();
|
||||||
pDirectSound = NULL;
|
pDirectSound = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DirectSound::init(long sampleRate)
|
bool DirectSound::init(long sampleRate)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DWORD freq;
|
DWORD freq;
|
||||||
DSBUFFERDESC dsbdesc;
|
DSBUFFERDESC dsbdesc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
hr = CoCreateInstance( CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID *)&pDirectSound );
|
hr = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID*)&pDirectSound);
|
||||||
if( hr != S_OK ) {
|
if (hr != S_OK) {
|
||||||
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
|
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDirectSound->Initialize( &DSDEVID_DefaultPlayback );
|
pDirectSound->Initialize(&DSDEVID_DefaultPlayback);
|
||||||
if( hr != DS_OK ) {
|
if (hr != DS_OK) {
|
||||||
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
|
systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FAILED( hr = pDirectSound->SetCooperativeLevel( theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE ) ) ) {
|
if (FAILED(hr = pDirectSound->SetCooperativeLevel(theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE))) {
|
||||||
systemMessage( IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr );
|
systemMessage(IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr);
|
||||||
return false;
|
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
|
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbPrimary, NULL))) {
|
||||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
return false;
|
||||||
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
}
|
||||||
if( dsoundDisableHardwareAcceleration ) {
|
|
||||||
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbPrimary, NULL ) ) ) {
|
freq = sampleRate;
|
||||||
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
|
// calculate the number of samples per frame first
|
||||||
return false;
|
// then multiply it with the size of a sample frame (16 bit * stereo)
|
||||||
}
|
soundBufferLen = (freq / 60) * 4;
|
||||||
|
soundBufferTotalLen = soundBufferLen * 10;
|
||||||
|
soundNextPosition = 0;
|
||||||
|
|
||||||
freq = sampleRate;
|
ZeroMemory(&wfx, sizeof(WAVEFORMATEX));
|
||||||
// calculate the number of samples per frame first
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
// then multiply it with the size of a sample frame (16 bit * stereo)
|
wfx.nChannels = 2;
|
||||||
soundBufferLen = ( freq / 60 ) * 4;
|
wfx.nSamplesPerSec = freq;
|
||||||
soundBufferTotalLen = soundBufferLen * 10;
|
wfx.wBitsPerSample = 16;
|
||||||
soundNextPosition = 0;
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
||||||
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||||
|
|
||||||
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
|
if (FAILED(hr = dsbPrimary->SetFormat(&wfx))) {
|
||||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr);
|
||||||
wfx.nChannels = 2;
|
return false;
|
||||||
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 ) ) ) {
|
// Create secondary sound buffer
|
||||||
systemMessage( IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr );
|
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
|
||||||
return false;
|
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
|
if (FAILED(hr = dsbSecondary->SetCurrentPosition(0))) {
|
||||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
systemMessage(0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr);
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
return false;
|
||||||
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 ) ) ) {
|
if (SUCCEEDED(hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify))) {
|
||||||
systemMessage( IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr );
|
dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
return false;
|
DSBPOSITIONNOTIFY notify[10];
|
||||||
}
|
for (i = 0; i < 10; i++) {
|
||||||
|
notify[i].dwOffset = i * soundBufferLen;
|
||||||
|
notify[i].hEventNotify = dsbEvent;
|
||||||
|
}
|
||||||
|
|
||||||
if( FAILED( hr = dsbSecondary->SetCurrentPosition( 0 ) ) ) {
|
if (FAILED(dsbNotify->SetNotificationPositions(10, notify))) {
|
||||||
systemMessage( 0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr );
|
dsbNotify->Release();
|
||||||
return false;
|
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 ) ) ) {
|
return true;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSound::pause()
|
void DirectSound::pause()
|
||||||
{
|
{
|
||||||
if( dsbSecondary == NULL ) return;
|
if (dsbSecondary == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
DWORD status;
|
DWORD status;
|
||||||
|
|
||||||
dsbSecondary->GetStatus( &status );
|
dsbSecondary->GetStatus(&status);
|
||||||
|
|
||||||
if( status & DSBSTATUS_PLAYING ) dsbSecondary->Stop();
|
if (status & DSBSTATUS_PLAYING)
|
||||||
|
dsbSecondary->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSound::reset()
|
void DirectSound::reset()
|
||||||
{
|
{
|
||||||
if( dsbSecondary == NULL ) return;
|
if (dsbSecondary == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
dsbSecondary->Stop();
|
dsbSecondary->Stop();
|
||||||
|
|
||||||
dsbSecondary->SetCurrentPosition( 0 );
|
dsbSecondary->SetCurrentPosition(0);
|
||||||
|
|
||||||
soundNextPosition = 0;
|
soundNextPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSound::resume()
|
void DirectSound::resume()
|
||||||
{
|
{
|
||||||
if( dsbSecondary == NULL ) return;
|
if (dsbSecondary == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
dsbSecondary->Play( 0, 0, DSBPLAY_LOOPING );
|
dsbSecondary->Play(0, 0, DSBPLAY_LOOPING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DirectSound::write(u16* finalWave, int length)
|
||||||
void DirectSound::write(u16 * finalWave, int length)
|
|
||||||
{
|
{
|
||||||
if(!pDirectSound) return;
|
if (!pDirectSound)
|
||||||
|
return;
|
||||||
|
|
||||||
|
HRESULT hr;
|
||||||
|
DWORD status = 0;
|
||||||
|
DWORD play = 0;
|
||||||
|
LPVOID lpvPtr1;
|
||||||
|
DWORD dwBytes1 = 0;
|
||||||
|
LPVOID lpvPtr2;
|
||||||
|
DWORD dwBytes2 = 0;
|
||||||
|
|
||||||
HRESULT hr;
|
if (!speedup && throttle && !gba_joybus_active) {
|
||||||
DWORD status = 0;
|
hr = dsbSecondary->GetStatus(&status);
|
||||||
DWORD play = 0;
|
if (status & DSBSTATUS_PLAYING) {
|
||||||
LPVOID lpvPtr1;
|
if (!soundPaused) {
|
||||||
DWORD dwBytes1 = 0;
|
while (true) {
|
||||||
LPVOID lpvPtr2;
|
dsbSecondary->GetCurrentPosition(&play, NULL);
|
||||||
DWORD dwBytes2 = 0;
|
int BufferLeft = ((soundNextPosition <= play) ? play - soundNextPosition : soundBufferTotalLen - soundNextPosition + play);
|
||||||
|
|
||||||
if( !speedup && throttle && !gba_joybus_active) {
|
if (BufferLeft > soundBufferLen) {
|
||||||
hr = dsbSecondary->GetStatus(&status);
|
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
|
||||||
if( status & DSBSTATUS_PLAYING ) {
|
soundBufferLow = true;
|
||||||
if( !soundPaused ) {
|
break;
|
||||||
while( true ) {
|
}
|
||||||
dsbSecondary->GetCurrentPosition(&play, NULL);
|
soundBufferLow = false;
|
||||||
int BufferLeft = ((soundNextPosition <= play) ?
|
|
||||||
play - soundNextPosition :
|
|
||||||
soundBufferTotalLen - soundNextPosition + play);
|
|
||||||
|
|
||||||
if(BufferLeft > soundBufferLen)
|
if (dsbEvent) {
|
||||||
{
|
WaitForSingleObject(dsbEvent, 50);
|
||||||
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
|
}
|
||||||
soundBufferLow = true;
|
}
|
||||||
break;
|
}
|
||||||
}
|
} /* else {
|
||||||
soundBufferLow = false;
|
|
||||||
|
|
||||||
if(dsbEvent) {
|
|
||||||
WaitForSingleObject(dsbEvent, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}/* else {
|
|
||||||
// TODO: remove?
|
// TODO: remove?
|
||||||
setsoundPaused(true);
|
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.
|
soundNextPosition += soundBufferLen;
|
||||||
// This will be in two parts if the block wraps around.
|
soundNextPosition = soundNextPosition % soundBufferTotalLen;
|
||||||
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;
|
if (SUCCEEDED(hr)) {
|
||||||
soundNextPosition = soundNextPosition % soundBufferTotalLen;
|
// Write to pointers.
|
||||||
|
CopyMemory(lpvPtr1, finalWave, dwBytes1);
|
||||||
|
if (lpvPtr2) {
|
||||||
|
CopyMemory(lpvPtr2, finalWave + dwBytes1, dwBytes2);
|
||||||
|
}
|
||||||
|
|
||||||
if( SUCCEEDED( hr ) ) {
|
// Release the data back to DirectSound.
|
||||||
// Write to pointers.
|
hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);
|
||||||
CopyMemory( lpvPtr1, finalWave, dwBytes1 );
|
} else {
|
||||||
if ( lpvPtr2 ) {
|
systemMessage(0, _T("dsbSecondary->Lock() failed: %08x"), hr);
|
||||||
CopyMemory( lpvPtr2, finalWave + dwBytes1, dwBytes2 );
|
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
Loading…
Reference in New Issue