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,16 +20,15 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GameBoyAdvanceCheatEditDialog
|
* GameBoyAdvanceCheatEditDialog
|
||||||
*
|
*
|
||||||
* A unified cheat editing dialog for multiple code types.
|
* A unified cheat editing dialog for multiple code types.
|
||||||
*/
|
*/
|
||||||
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog)
|
: Gtk::Dialog(_pstDialog)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
|
refBuilder->get_widget("CheatDescEntry", m_poCheatDescEntry);
|
||||||
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
|
refBuilder->get_widget("CheatTypeComboBox", m_poCheatTypeComboBox);
|
||||||
|
@ -60,8 +59,7 @@ ECheatType CheatEditDialog::vGetType()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
|
Gtk::TreeModel::iterator iter = m_poCheatTypeComboBox->get_active();
|
||||||
|
|
||||||
if (iter)
|
if (iter) {
|
||||||
{
|
|
||||||
Gtk::TreeModel::Row row = *iter;
|
Gtk::TreeModel::Row row = *iter;
|
||||||
|
|
||||||
return row[m_oTypeModel.iType];
|
return row[m_oTypeModel.iType];
|
||||||
|
@ -70,13 +68,12 @@ ECheatType CheatEditDialog::vGetType()
|
||||||
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;
|
||||||
|
@ -95,8 +92,7 @@ void CheatEditDialog::vSetWindow(VBA::Window * _poWindow)
|
||||||
m_poCheatTypeComboBox->set_active(CheatGeneric);
|
m_poCheatTypeComboBox->set_active(CheatGeneric);
|
||||||
}
|
}
|
||||||
// GameBoy
|
// GameBoy
|
||||||
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB)
|
else if (m_poWindow->eGetCartridge() == VBA::Window::CartridgeGB) {
|
||||||
{
|
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
||||||
|
|
||||||
row[m_oTypeModel.iType] = CheatGS;
|
row[m_oTypeModel.iType] = CheatGS;
|
||||||
|
@ -116,7 +112,8 @@ void CheatEditDialog::vOnApply()
|
||||||
response(Gtk::RESPONSE_APPLY);
|
response(Gtk::RESPONSE_APPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatEditDialog::vOnCancel() {
|
void CheatEditDialog::vOnCancel()
|
||||||
|
{
|
||||||
response(Gtk::RESPONSE_CANCEL);
|
response(Gtk::RESPONSE_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,15 @@
|
||||||
|
|
||||||
#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);
|
||||||
|
@ -48,26 +50,25 @@ class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
||||||
Gtk::TreeModelColumn<ECheatType> iType;
|
Gtk::TreeModelColumn<ECheatType> iType;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CheatEditDialog : public Gtk::Dialog
|
class CheatEditDialog : public Gtk::Dialog {
|
||||||
{
|
public:
|
||||||
public:
|
CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
CheatEditDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
|
|
||||||
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
|
Glib::RefPtr<Gtk::TextBuffer> vGetCode();
|
||||||
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;
|
||||||
|
|
|
@ -24,11 +24,10 @@
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog)
|
: Gtk::Dialog(_pstDialog)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
|
refBuilder->get_widget("CheatOpenButton", m_poCheatOpenButton);
|
||||||
refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
|
refBuilder->get_widget("CheatSaveButton", m_poCheatSaveButton);
|
||||||
|
@ -74,15 +73,13 @@ void CheatListDialog::vOnCheatListOpen()
|
||||||
|
|
||||||
oDialog.set_current_folder(Glib::get_home_dir());
|
oDialog.set_current_folder(Glib::get_home_dir());
|
||||||
|
|
||||||
while (oDialog.run() == Gtk::RESPONSE_OK)
|
while (oDialog.run() == Gtk::RESPONSE_OK) {
|
||||||
{
|
|
||||||
// delete existing cheats before loading the list
|
// delete existing cheats before loading the list
|
||||||
vRemoveAllCheats();
|
vRemoveAllCheats();
|
||||||
|
|
||||||
m_poCheatListStore->clear();
|
m_poCheatListStore->clear();
|
||||||
|
|
||||||
if (vCheatListOpen(oDialog.get_filename().c_str()))
|
if (vCheatListOpen(oDialog.get_filename().c_str())) {
|
||||||
{
|
|
||||||
vUpdateList();
|
vUpdateList();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +103,7 @@ 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);
|
||||||
|
@ -121,8 +118,7 @@ void CheatListDialog::vOnCheatRemove()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected();
|
Gtk::TreeModel::iterator iter = m_poCheatTreeView->get_selection()->get_selected();
|
||||||
|
|
||||||
if (iter)
|
if (iter) {
|
||||||
{
|
|
||||||
Gtk::TreeModel::Row row = *iter;
|
Gtk::TreeModel::Row row = *iter;
|
||||||
|
|
||||||
vRemoveCheat(row[m_oRecordModel.iIndex]);
|
vRemoveCheat(row[m_oRecordModel.iIndex]);
|
||||||
|
@ -142,8 +138,7 @@ void CheatListDialog::vOnCheatMarkAll()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children();
|
Gtk::TreeModel::Children cListEntries = m_poCheatListStore->children();
|
||||||
|
|
||||||
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++)
|
for (Gtk::TreeModel::iterator iter = cListEntries.begin(); iter; iter++) {
|
||||||
{
|
|
||||||
Gtk::TreeModel::Row row = *iter;
|
Gtk::TreeModel::Row row = *iter;
|
||||||
|
|
||||||
row[m_oRecordModel.bEnabled] = bMark;
|
row[m_oRecordModel.bEnabled] = bMark;
|
||||||
|
@ -165,7 +160,7 @@ void CheatListDialog::vOnCheatToggled(Glib::ustring const& string_path)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,9 @@
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord {
|
||||||
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
public:
|
||||||
{
|
|
||||||
public:
|
|
||||||
ListCheatCodeColumns()
|
ListCheatCodeColumns()
|
||||||
{
|
{
|
||||||
add(iIndex);
|
add(iIndex);
|
||||||
|
@ -46,17 +44,17 @@ class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
||||||
Gtk::TreeModelColumn<Glib::ustring> uDesc;
|
Gtk::TreeModelColumn<Glib::ustring> uDesc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CheatListDialog : public Gtk::Dialog
|
class CheatListDialog : public Gtk::Dialog {
|
||||||
{
|
public:
|
||||||
public:
|
CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder);
|
||||||
CheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr<Gtk::Builder> &refBuilder);
|
void vSetWindow(VBA::Window* _poWindow);
|
||||||
void vSetWindow(VBA::Window *_poWindow);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
|
virtual void vAddCheat(Glib::ustring sDesc, ECheatType type,
|
||||||
Glib::RefPtr<Gtk::TextBuffer> buffer) = 0;
|
Glib::RefPtr<Gtk::TextBuffer> buffer)
|
||||||
virtual bool vCheatListOpen(const char *file) = 0;
|
= 0;
|
||||||
virtual void vCheatListSave(const char *file) = 0;
|
virtual bool vCheatListOpen(const char* file) = 0;
|
||||||
|
virtual void vCheatListSave(const char* file) = 0;
|
||||||
virtual void vRemoveCheat(int index) = 0;
|
virtual void vRemoveCheat(int index) = 0;
|
||||||
virtual void vRemoveAllCheats() = 0;
|
virtual void vRemoveAllCheats() = 0;
|
||||||
virtual void vToggleCheat(int index, bool enable) = 0;
|
virtual void vToggleCheat(int index, bool enable) = 0;
|
||||||
|
@ -65,24 +63,24 @@ class CheatListDialog : public Gtk::Dialog
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,182 +23,150 @@
|
||||||
#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)
|
}
|
||||||
|
|
||||||
|
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 true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Section::vSetKey(const string & _rsKey, const string & _rsValue)
|
void Section::vSetKey(const string& _rsKey, const string& _rsValue)
|
||||||
{
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->m_sKey == _rsKey)
|
|
||||||
{
|
{
|
||||||
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->m_sKey == _rsKey) {
|
||||||
it->m_sValue = _rsValue;
|
it->m_sValue = _rsValue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push_back(Line(_rsKey, _rsValue));
|
push_back(Line(_rsKey, _rsValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
string Section::sGetKey(const string & _rsKey) const
|
string Section::sGetKey(const string& _rsKey) const
|
||||||
{
|
|
||||||
for (const_iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->m_sKey == _rsKey)
|
|
||||||
{
|
{
|
||||||
|
for (const_iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->m_sKey == _rsKey) {
|
||||||
return it->m_sValue;
|
return it->m_sValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw KeyNotFound(m_sName, _rsKey);
|
throw KeyNotFound(m_sName, _rsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Section::vRemoveKey(const string & _rsKey)
|
void Section::vRemoveKey(const string& _rsKey)
|
||||||
{
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->m_sKey == _rsKey)
|
|
||||||
{
|
{
|
||||||
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->m_sKey == _rsKey) {
|
||||||
erase(it);
|
erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File::File()
|
File::File()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
File::File(const string & _rsFile)
|
File::File(const string& _rsFile)
|
||||||
{
|
{
|
||||||
vLoad(_rsFile);
|
vLoad(_rsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
File::~File()
|
File::~File()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::bSectionExists(const string & _rsName)
|
bool File::bSectionExists(const string& _rsName)
|
||||||
{
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->sGetName() == _rsName)
|
|
||||||
{
|
{
|
||||||
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->sGetName() == _rsName) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Section * File::poAddSection(const string & _rsName)
|
Section* File::poAddSection(const string& _rsName)
|
||||||
{
|
|
||||||
Section * poSection = NULL;
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->sGetName() == _rsName)
|
|
||||||
{
|
{
|
||||||
|
Section* poSection = NULL;
|
||||||
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->sGetName() == _rsName) {
|
||||||
poSection = &(*it);
|
poSection = &(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (poSection == NULL)
|
if (poSection == NULL) {
|
||||||
{
|
|
||||||
push_back(Section(_rsName));
|
push_back(Section(_rsName));
|
||||||
poSection = &back();
|
poSection = &back();
|
||||||
}
|
}
|
||||||
return poSection;
|
return poSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
Section * File::poGetSection(const string & _rsName)
|
Section* File::poGetSection(const string& _rsName)
|
||||||
{
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->sGetName() == _rsName)
|
|
||||||
{
|
{
|
||||||
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->sGetName() == _rsName) {
|
||||||
return &(*it);
|
return &(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw SectionNotFound(_rsName);
|
throw SectionNotFound(_rsName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::vRemoveSection(const string & _rsName)
|
void File::vRemoveSection(const string& _rsName)
|
||||||
{
|
|
||||||
for (iterator it = begin(); it != end(); it++)
|
|
||||||
{
|
|
||||||
if (it->sGetName() == _rsName)
|
|
||||||
{
|
{
|
||||||
|
for (iterator it = begin(); it != end(); it++) {
|
||||||
|
if (it->sGetName() == _rsName) {
|
||||||
erase(it);
|
erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::vLoad(const string & _rsFile,
|
void File::vLoad(const string& _rsFile,
|
||||||
bool _bAddSection,
|
bool _bAddSection,
|
||||||
bool _bAddKey)
|
bool _bAddKey)
|
||||||
{
|
{
|
||||||
string sBuffer = Glib::file_get_contents(_rsFile);
|
string sBuffer = Glib::file_get_contents(_rsFile);
|
||||||
Section * poSection = NULL;
|
Section* poSection = NULL;
|
||||||
char ** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
|
char** lines = g_strsplit(sBuffer.c_str(), "\n", 0);
|
||||||
char * tmp;
|
char* tmp;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (lines[i])
|
while (lines[i]) {
|
||||||
{
|
if (lines[i][0] == '[') {
|
||||||
if (lines[i][0] == '[')
|
if ((tmp = strchr(lines[i], ']'))) {
|
||||||
{
|
|
||||||
if ((tmp = strchr(lines[i], ']')))
|
|
||||||
{
|
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
if (_bAddSection)
|
if (_bAddSection) {
|
||||||
{
|
|
||||||
poSection = poAddSection(&lines[i][1]);
|
poSection = poAddSection(&lines[i][1]);
|
||||||
}
|
} else {
|
||||||
else
|
try {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
poSection = poGetSection(&lines[i][1]);
|
poSection = poGetSection(&lines[i][1]);
|
||||||
}
|
} catch (...) {
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
poSection = NULL;
|
poSection = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (lines[i][0] != '#' && poSection != NULL) {
|
||||||
else if (lines[i][0] != '#' && poSection != NULL)
|
if ((tmp = strchr(lines[i], '='))) {
|
||||||
{
|
|
||||||
if ((tmp = strchr(lines[i], '=')))
|
|
||||||
{
|
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
tmp++;
|
tmp++;
|
||||||
if (_bAddKey || poSection->bKeyExists(lines[i]))
|
if (_bAddKey || poSection->bKeyExists(lines[i])) {
|
||||||
{
|
|
||||||
poSection->vSetKey(lines[i], tmp);
|
poSection->vSetKey(lines[i], tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,56 +174,52 @@ void File::vLoad(const string & _rsFile,
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
g_strfreev(lines);
|
g_strfreev(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::vSave(const string & _rsFile)
|
void File::vSave(const string& _rsFile)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<IOChannel> poFile = IOChannel::create_from_file(_rsFile, "w");
|
Glib::RefPtr<IOChannel> poFile = IOChannel::create_from_file(_rsFile, "w");
|
||||||
poFile->set_encoding("");
|
poFile->set_encoding("");
|
||||||
|
|
||||||
for (const_iterator poSection = begin();
|
for (const_iterator poSection = begin();
|
||||||
poSection != end();
|
poSection != end();
|
||||||
poSection++)
|
poSection++) {
|
||||||
{
|
|
||||||
string sName = "[" + poSection->sGetName() + "]\n";
|
string sName = "[" + poSection->sGetName() + "]\n";
|
||||||
poFile->write(sName);
|
poFile->write(sName);
|
||||||
|
|
||||||
for (Section::const_iterator poLine = poSection->begin();
|
for (Section::const_iterator poLine = poSection->begin();
|
||||||
poLine != poSection->end();
|
poLine != poSection->end();
|
||||||
poLine++)
|
poLine++) {
|
||||||
{
|
|
||||||
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
|
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
|
||||||
poFile->write(sLine);
|
poFile->write(sLine);
|
||||||
}
|
}
|
||||||
poFile->write("\n");
|
poFile->write("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::vClear()
|
void File::vClear()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & _roOut, const File & _roFile)
|
std::ostream& operator<<(std::ostream& _roOut, const File& _roFile)
|
||||||
{
|
{
|
||||||
for (File::const_iterator poSection = _roFile.begin();
|
for (File::const_iterator poSection = _roFile.begin();
|
||||||
poSection != _roFile.end();
|
poSection != _roFile.end();
|
||||||
poSection++)
|
poSection++) {
|
||||||
{
|
|
||||||
string sName = "[" + poSection->sGetName() + "]\n";
|
string sName = "[" + poSection->sGetName() + "]\n";
|
||||||
_roOut << sName;
|
_roOut << sName;
|
||||||
|
|
||||||
for (Section::const_iterator poLine = poSection->begin();
|
for (Section::const_iterator poLine = poSection->begin();
|
||||||
poLine != poSection->end();
|
poLine != poSection->end();
|
||||||
poLine++)
|
poLine++) {
|
||||||
{
|
|
||||||
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
|
string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n";
|
||||||
_roOut << sLine;
|
_roOut << sLine;
|
||||||
}
|
}
|
||||||
_roOut << "\n";
|
_roOut << "\n";
|
||||||
}
|
}
|
||||||
return _roOut;
|
return _roOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -23,12 +23,9 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
namespace Config {
|
||||||
namespace Config
|
class NotFound {
|
||||||
{
|
|
||||||
class NotFound
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~NotFound()
|
virtual ~NotFound()
|
||||||
{
|
{
|
||||||
|
@ -38,12 +35,12 @@ class NotFound
|
||||||
NotFound()
|
NotFound()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SectionNotFound : public NotFound
|
class SectionNotFound : public NotFound {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
SectionNotFound(const std::string &_rsName) : m_sName(_rsName)
|
SectionNotFound(const std::string& _rsName)
|
||||||
|
: m_sName(_rsName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~SectionNotFound()
|
virtual ~SectionNotFound()
|
||||||
|
@ -57,13 +54,13 @@ class SectionNotFound : public NotFound
|
||||||
|
|
||||||
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_sKey(_rsKey)
|
: m_sSection(_rsSection)
|
||||||
|
, m_sKey(_rsKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~KeyNotFound()
|
virtual ~KeyNotFound()
|
||||||
|
@ -82,35 +79,35 @@ class KeyNotFound : public NotFound
|
||||||
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;
|
||||||
|
@ -134,21 +131,20 @@ class Section : private std::list<Line>
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_sName;
|
std::string m_sName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class File : private std::list<Section>
|
class File : private std::list<Section> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
File();
|
File();
|
||||||
File(const std::string &_rsFile);
|
File(const std::string& _rsFile);
|
||||||
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
|
||||||
|
@ -171,13 +167,14 @@ class File : private std::list<Section>
|
||||||
{
|
{
|
||||||
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++) {
|
||||||
|
@ -187,10 +184,11 @@ template <typename T> void Section::vSetKey(const std::string &_rsKey, const T &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push_back(Line(_rsKey, oOut.str()));
|
push_back(Line(_rsKey, oOut.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> T Section::oGetKey(const std::string &_rsKey) const
|
template <typename T>
|
||||||
{
|
T Section::oGetKey(const std::string& _rsKey) const
|
||||||
|
{
|
||||||
T oValue;
|
T oValue;
|
||||||
for (const_iterator it = begin(); it != end(); it++) {
|
for (const_iterator it = begin(); it != end(); it++) {
|
||||||
if (it->m_sKey == _rsKey) {
|
if (it->m_sKey == _rsKey) {
|
||||||
|
@ -200,7 +198,7 @@ template <typename T> T Section::oGetKey(const std::string &_rsKey) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw KeyNotFound(m_sName, _rsKey);
|
throw KeyNotFound(m_sName, _rsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Config
|
} // namespace Config
|
||||||
} // namespace VBA
|
} // namespace VBA
|
||||||
|
|
|
@ -22,11 +22,9 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] =
|
const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] = {
|
||||||
{
|
|
||||||
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
|
{ "gba_roms", N_("GBA roms :"), "GBARomsDirEntry" },
|
||||||
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
|
{ "gb_roms", N_("GB roms :"), "GBRomsDirEntry" },
|
||||||
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
|
{ "batteries", N_("Batteries :"), "BatteriesDirEntry" },
|
||||||
|
@ -35,33 +33,31 @@ const DirectoriesConfigDialog::SDirEntry DirectoriesConfigDialog::m_astDirs[] =
|
||||||
{ "captures", N_("Captures :"), "CapturesDirEntry" }
|
{ "captures", N_("Captures :"), "CapturesDirEntry" }
|
||||||
};
|
};
|
||||||
|
|
||||||
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section * _poConfig) :
|
DirectoriesConfigDialog::DirectoriesConfigDialog(Config::Section* _poConfig)
|
||||||
Gtk::Dialog(_("Directories config"), true),
|
: Gtk::Dialog(_("Directories config"), true)
|
||||||
m_poConfig(_poConfig)
|
, m_poConfig(_poConfig)
|
||||||
{
|
{
|
||||||
Gtk::Table * poTable = Gtk::manage( new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
|
Gtk::Table* poTable = Gtk::manage(new Gtk::Table(G_N_ELEMENTS(m_astDirs), 2, false));
|
||||||
poTable->set_border_width(5);
|
poTable->set_border_width(5);
|
||||||
poTable->set_spacings(5);
|
poTable->set_spacings(5);
|
||||||
|
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(m_astDirs); i++) {
|
||||||
{
|
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END));
|
||||||
Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(gettext(m_astDirs[i].m_csLabel), Gtk::ALIGN_END) );
|
m_poButtons[i] = Gtk::manage(new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
|
||||||
m_poButtons[i] = Gtk::manage( new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) );
|
|
||||||
m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey));
|
m_poButtons[i]->set_current_folder(m_poConfig->sGetKey(m_astDirs[i].m_csKey));
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,21 +18,20 @@
|
||||||
|
|
||||||
#include "displayconfig.h"
|
#include "displayconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/radiobutton.h>
|
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
#include <gtkmm/radiobutton.h>
|
#include <gtkmm/radiobutton.h>
|
||||||
|
#include <gtkmm/radiobutton.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
|
refBuilder->get_widget("FiltersComboBox", m_poFiltersComboBox);
|
||||||
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
|
refBuilder->get_widget("IBFiltersComboBox", m_poIBFiltersComboBox);
|
||||||
|
@ -46,13 +45,11 @@ DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
|
||||||
m_poOutputOpenGLRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputOpenGL));
|
m_poOutputOpenGLRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputOpenGL));
|
||||||
m_poOutputCairoRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputCairo));
|
m_poOutputCairoRadioButton->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &DisplayConfigDialog::vOnOutputChanged), VBA::Window::OutputCairo));
|
||||||
|
|
||||||
|
|
||||||
// Populate the filters combobox
|
// Populate the filters combobox
|
||||||
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
|
Glib::RefPtr<Gtk::ListStore> poFiltersListStore;
|
||||||
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
|
poFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("FiltersListStore"));
|
||||||
|
|
||||||
for (guint i = FirstFilter; i <= LastFilter; i++)
|
for (guint i = FirstFilter; i <= LastFilter; i++) {
|
||||||
{
|
|
||||||
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
|
Gtk::TreeModel::Row row = *(poFiltersListStore->append());
|
||||||
row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
|
row->set_value(0, std::string(pcsGetFilterName((EFilter)i)));
|
||||||
}
|
}
|
||||||
|
@ -61,14 +58,13 @@ DisplayConfigDialog::DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
|
||||||
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
|
Glib::RefPtr<Gtk::ListStore> poIBFiltersListStore;
|
||||||
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
|
poIBFiltersListStore = Glib::RefPtr<Gtk::ListStore>::cast_static(refBuilder->get_object("IBFiltersListStore"));
|
||||||
|
|
||||||
for (guint i = FirstFilterIB; i <= LastFilterIB; i++)
|
for (guint i = FirstFilterIB; i <= LastFilterIB; i++) {
|
||||||
{
|
|
||||||
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
|
Gtk::TreeModel::Row row = *(poIBFiltersListStore->append());
|
||||||
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
|
row->set_value(0, std::string(pcsGetFilterIBName((EFilterIB)i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -84,8 +80,7 @@ void DisplayConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window *
|
||||||
|
|
||||||
// Set the default output module
|
// Set the default output module
|
||||||
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
|
VBA::Window::EVideoOutput _eOutput = (VBA::Window::EVideoOutput)m_poConfig->oGetKey<int>("output");
|
||||||
switch (_eOutput)
|
switch (_eOutput) {
|
||||||
{
|
|
||||||
case VBA::Window::OutputOpenGL:
|
case VBA::Window::OutputOpenGL:
|
||||||
m_poOutputOpenGLRadioButton->set_active();
|
m_poOutputOpenGLRadioButton->set_active();
|
||||||
break;
|
break;
|
||||||
|
@ -98,8 +93,7 @@ void DisplayConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window *
|
||||||
void DisplayConfigDialog::vOnFilterChanged()
|
void DisplayConfigDialog::vOnFilterChanged()
|
||||||
{
|
{
|
||||||
int iFilter = m_poFiltersComboBox->get_active_row_number();
|
int iFilter = m_poFiltersComboBox->get_active_row_number();
|
||||||
if (iFilter >= 0)
|
if (iFilter >= 0) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("filter2x", iFilter);
|
m_poConfig->vSetKey("filter2x", iFilter);
|
||||||
m_poWindow->vApplyConfigFilter();
|
m_poWindow->vApplyConfigFilter();
|
||||||
}
|
}
|
||||||
|
@ -108,8 +102,7 @@ void DisplayConfigDialog::vOnFilterChanged()
|
||||||
void DisplayConfigDialog::vOnFilterIBChanged()
|
void DisplayConfigDialog::vOnFilterIBChanged()
|
||||||
{
|
{
|
||||||
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
|
int iFilterIB = m_poIBFiltersComboBox->get_active_row_number();
|
||||||
if (iFilterIB >= 0)
|
if (iFilterIB >= 0) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("filterIB", iFilterIB);
|
m_poConfig->vSetKey("filterIB", iFilterIB);
|
||||||
m_poWindow->vApplyConfigFilterIB();
|
m_poWindow->vApplyConfigFilterIB();
|
||||||
}
|
}
|
||||||
|
@ -122,12 +115,10 @@ void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
|
||||||
if (_eOutput == eOldOutput)
|
if (_eOutput == eOldOutput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active())
|
if (_eOutput == VBA::Window::OutputOpenGL && m_poOutputOpenGLRadioButton->get_active()) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
|
m_poConfig->vSetKey("output", VBA::Window::OutputOpenGL);
|
||||||
m_poWindow->vApplyConfigScreenArea();
|
m_poWindow->vApplyConfigScreenArea();
|
||||||
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active())
|
} else if (_eOutput == VBA::Window::OutputCairo && m_poOutputCairoRadioButton->get_active()) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
|
m_poConfig->vSetKey("output", VBA::Window::OutputCairo);
|
||||||
m_poWindow->vApplyConfigScreenArea();
|
m_poWindow->vApplyConfigScreenArea();
|
||||||
}
|
}
|
||||||
|
@ -136,8 +127,7 @@ void DisplayConfigDialog::vOnOutputChanged(VBA::Window::EVideoOutput _eOutput)
|
||||||
void DisplayConfigDialog::vOnScaleChanged()
|
void DisplayConfigDialog::vOnScaleChanged()
|
||||||
{
|
{
|
||||||
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
|
int iScale = m_poDefaultScaleComboBox->get_active_row_number() + 1;
|
||||||
if (iScale > 0)
|
if (iScale > 0) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("scale", iScale);
|
m_poConfig->vSetKey("scale", iScale);
|
||||||
m_poWindow->vUpdateScreen();
|
m_poWindow->vUpdateScreen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,45 +19,42 @@
|
||||||
#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_("None"), 1, { 0, 0 } },
|
||||||
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
|
{ N_("2xSaI"), 2, { _2xSaI, _2xSaI32 } },
|
||||||
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
|
{ N_("Super 2xSaI"), 2, { Super2xSaI, Super2xSaI32 } },
|
||||||
|
@ -76,9 +73,7 @@ static const astFilters[] =
|
||||||
struct {
|
struct {
|
||||||
char m_csName[30];
|
char m_csName[30];
|
||||||
FilterIB m_apvFunc[2];
|
FilterIB m_apvFunc[2];
|
||||||
}
|
} static const astFiltersIB[] = {
|
||||||
static const astFiltersIB[] =
|
|
||||||
{
|
|
||||||
{ N_("None"), { 0, 0 } },
|
{ N_("None"), { 0, 0 } },
|
||||||
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
|
{ N_("Smart interframe blending"), { SmartIB, SmartIB32 } },
|
||||||
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
|
{ N_("Interframe motion blur"), { MotionBlurIB, MotionBlurIB32 } }
|
||||||
|
|
|
@ -24,10 +24,9 @@
|
||||||
|
|
||||||
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,
|
||||||
|
@ -55,13 +54,14 @@ enum EFilterIB {
|
||||||
LastFilterIB = FilterIBMotionBlur
|
LastFilterIB = FilterIBMotionBlur
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EFilterDepth { FilterDepth16, FilterDepth32 };
|
enum EFilterDepth { FilterDepth16,
|
||||||
|
FilterDepth32 };
|
||||||
|
|
||||||
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
|
Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth);
|
||||||
const char *pcsGetFilterName(const EFilter _eFilter);
|
const char* pcsGetFilterName(const EFilter _eFilter);
|
||||||
|
|
||||||
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,11 +21,10 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyAdvanceCheatListDialog::GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
CheatListDialog(_pstDialog, refBuilder)
|
: CheatListDialog(_pstDialog, refBuilder)
|
||||||
{
|
{
|
||||||
vUpdateList();
|
vUpdateList();
|
||||||
}
|
}
|
||||||
|
@ -34,19 +33,16 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
|
||||||
{
|
{
|
||||||
int previous = cheatsNumber;
|
int previous = cheatsNumber;
|
||||||
|
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
// Generic Code
|
// Generic Code
|
||||||
case CheatGeneric:
|
case CheatGeneric: {
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> tokens;
|
std::vector<Glib::ustring> tokens;
|
||||||
|
|
||||||
vTokenize(buffer->get_text(), tokens);
|
vTokenize(buffer->get_text(), tokens);
|
||||||
|
|
||||||
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
||||||
it != tokens.end();
|
it != tokens.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
|
||||||
Glib::ustring sToken = it->uppercase();
|
Glib::ustring sToken = it->uppercase();
|
||||||
|
|
||||||
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
|
cheatsAddCheatCode(sToken.c_str(), sDesc.c_str());
|
||||||
|
@ -56,8 +52,7 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
|
||||||
}
|
}
|
||||||
// Gameshark Advance & CodeBreaker Advance
|
// Gameshark Advance & CodeBreaker Advance
|
||||||
case CheatGSA:
|
case CheatGSA:
|
||||||
case CheatCBA:
|
case CheatCBA: {
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> tokens;
|
std::vector<Glib::ustring> tokens;
|
||||||
|
|
||||||
Glib::ustring sToken;
|
Glib::ustring sToken;
|
||||||
|
@ -68,35 +63,27 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
|
||||||
|
|
||||||
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
||||||
it != tokens.end();
|
it != tokens.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
|
||||||
|
|
||||||
sToken = it->uppercase();
|
sToken = it->uppercase();
|
||||||
const char *cToken = sToken.c_str();
|
const char* cToken = sToken.c_str();
|
||||||
|
|
||||||
if (sToken.size() == 16)
|
if (sToken.size() == 16)
|
||||||
cheatsAddGSACode(cToken, sDesc.c_str(), false);
|
cheatsAddGSACode(cToken, sDesc.c_str(), false);
|
||||||
else if (sToken.size() == 12)
|
else if (sToken.size() == 12) {
|
||||||
{
|
sCode = sToken.substr(0, 8);
|
||||||
sCode = sToken.substr(0,8);
|
|
||||||
sCode += " ";
|
sCode += " ";
|
||||||
sCode += sToken.substr(9,4);
|
sCode += sToken.substr(9, 4);
|
||||||
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
|
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
|
||||||
}
|
} else if (sPart.empty())
|
||||||
else
|
|
||||||
if (sPart.empty())
|
|
||||||
sPart = sToken;
|
sPart = sToken;
|
||||||
else
|
else {
|
||||||
{
|
if (sToken.size() == 4) {
|
||||||
if (sToken.size() == 4)
|
|
||||||
{
|
|
||||||
sCode = sPart;
|
sCode = sPart;
|
||||||
sCode += " ";
|
sCode += " ";
|
||||||
sCode += cToken;
|
sCode += cToken;
|
||||||
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
|
cheatsAddCBACode(sCode.c_str(), sDesc.c_str());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
sCode = sPart + sToken;
|
sCode = sPart + sToken;
|
||||||
cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true);
|
cheatsAddGSACode(sCode.c_str(), sDesc.c_str(), true);
|
||||||
}
|
}
|
||||||
|
@ -112,25 +99,28 @@ void GameBoyAdvanceCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType ty
|
||||||
vUpdateList(previous);
|
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)
|
if (enable)
|
||||||
cheatsEnable(index);
|
cheatsEnable(index);
|
||||||
else
|
else
|
||||||
|
@ -139,8 +129,7 @@ void GameBoyAdvanceCheatListDialog::vToggleCheat(int index, bool enable) {
|
||||||
|
|
||||||
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
|
void GameBoyAdvanceCheatListDialog::vUpdateList(int previous)
|
||||||
{
|
{
|
||||||
for (int i = previous; i < cheatsNumber; i++)
|
for (int i = previous; i < cheatsNumber; i++) {
|
||||||
{
|
|
||||||
// Add row for each newly added cheat
|
// Add row for each newly added cheat
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
||||||
|
|
||||||
|
|
|
@ -25,18 +25,16 @@
|
||||||
#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);
|
||||||
|
|
|
@ -20,12 +20,11 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
|
refBuilder->get_widget("SaveTypeComboBox", m_poSaveTypeComboBox);
|
||||||
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
|
refBuilder->get_widget("FlashSizeComboBox", m_poFlashSizeComboBox);
|
||||||
|
@ -40,7 +39,7 @@ GameBoyAdvanceConfigDialog::GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, co
|
||||||
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;
|
||||||
|
@ -49,12 +48,9 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
|
||||||
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
|
m_poSaveTypeComboBox->set_active(eDefaultSaveType);
|
||||||
|
|
||||||
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
|
int iDefaultFlashSize = m_poConfig->oGetKey<int>("flash_size");
|
||||||
if (iDefaultFlashSize == 128)
|
if (iDefaultFlashSize == 128) {
|
||||||
{
|
|
||||||
m_poFlashSizeComboBox->set_active(1);
|
m_poFlashSizeComboBox->set_active(1);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_poFlashSizeComboBox->set_active(0);
|
m_poFlashSizeComboBox->set_active(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +61,7 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
|
||||||
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
|
std::string sBios = m_poConfig->oGetKey<std::string>("bios_file");
|
||||||
m_poBiosFileChooserButton->set_filename(sBios);
|
m_poBiosFileChooserButton->set_filename(sBios);
|
||||||
|
|
||||||
const char * acsPattern[] =
|
const char* acsPattern[] = {
|
||||||
{
|
|
||||||
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
|
"*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]",
|
||||||
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
|
"*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]"
|
||||||
};
|
};
|
||||||
|
@ -78,8 +73,7 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
|
||||||
|
|
||||||
Gtk::FileFilter oBiosFilter;
|
Gtk::FileFilter oBiosFilter;
|
||||||
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
|
oBiosFilter.set_name(_("Gameboy Advance BIOS"));
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
|
||||||
{
|
|
||||||
oBiosFilter.add_pattern(acsPattern[i]);
|
oBiosFilter.add_pattern(acsPattern[i]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -89,8 +83,7 @@ void GameBoyAdvanceConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Wi
|
||||||
|
|
||||||
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
|
const Glib::RefPtr<Gtk::FileFilter> oBiosFilter = Gtk::FileFilter::create();
|
||||||
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
|
oBiosFilter->set_name(_("Gameboy Advance BIOS"));
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) {
|
||||||
{
|
|
||||||
oBiosFilter->add_pattern(acsPattern[i]);
|
oBiosFilter->add_pattern(acsPattern[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,12 +106,9 @@ void GameBoyAdvanceConfigDialog::vOnSaveTypeChanged()
|
||||||
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
|
void GameBoyAdvanceConfigDialog::vOnFlashSizeChanged()
|
||||||
{
|
{
|
||||||
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
|
int iFlashSize = m_poFlashSizeComboBox->get_active_row_number();
|
||||||
if (iFlashSize == 0)
|
if (iFlashSize == 0) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("flash_size", 64);
|
m_poConfig->vSetKey("flash_size", 64);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("flash_size", 128);
|
m_poConfig->vSetKey("flash_size", 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,11 +21,10 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyCheatListDialog::GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
CheatListDialog(_pstDialog, refBuilder)
|
: CheatListDialog(_pstDialog, refBuilder)
|
||||||
{
|
{
|
||||||
vUpdateList();
|
vUpdateList();
|
||||||
}
|
}
|
||||||
|
@ -34,19 +33,16 @@ void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Gli
|
||||||
{
|
{
|
||||||
int previous = gbCheatNumber;
|
int previous = gbCheatNumber;
|
||||||
|
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
// GameShark
|
// GameShark
|
||||||
case CheatGS:
|
case CheatGS: {
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> tokens;
|
std::vector<Glib::ustring> tokens;
|
||||||
|
|
||||||
vTokenize(buffer->get_text(), tokens);
|
vTokenize(buffer->get_text(), tokens);
|
||||||
|
|
||||||
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
||||||
it != tokens.end();
|
it != tokens.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
|
||||||
Glib::ustring sToken = it->uppercase();
|
Glib::ustring sToken = it->uppercase();
|
||||||
|
|
||||||
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
|
gbAddGsCheat(sToken.c_str(), sDesc.c_str());
|
||||||
|
@ -55,16 +51,14 @@ void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Gli
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// GameGenie
|
// GameGenie
|
||||||
case CheatGG:
|
case CheatGG: {
|
||||||
{
|
|
||||||
std::vector<Glib::ustring> tokens;
|
std::vector<Glib::ustring> tokens;
|
||||||
|
|
||||||
vTokenize(buffer->get_text(), tokens);
|
vTokenize(buffer->get_text(), tokens);
|
||||||
|
|
||||||
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
for (std::vector<Glib::ustring>::iterator it = tokens.begin();
|
||||||
it != tokens.end();
|
it != tokens.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
|
||||||
Glib::ustring sToken = it->uppercase();
|
Glib::ustring sToken = it->uppercase();
|
||||||
|
|
||||||
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
|
gbAddGgCheat(sToken.c_str(), sDesc.c_str());
|
||||||
|
@ -79,12 +73,12 @@ void GameBoyCheatListDialog::vAddCheat(Glib::ustring sDesc, ECheatType type, Gli
|
||||||
vUpdateList(previous);
|
vUpdateList(previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameBoyCheatListDialog::vCheatListOpen(const char *file)
|
bool GameBoyCheatListDialog::vCheatListOpen(const char* file)
|
||||||
{
|
{
|
||||||
return gbCheatsLoadCheatList(file);
|
return gbCheatsLoadCheatList(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vCheatListSave(const char *file)
|
void GameBoyCheatListDialog::vCheatListSave(const char* file)
|
||||||
{
|
{
|
||||||
gbCheatsSaveCheatList(file);
|
gbCheatsSaveCheatList(file);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +93,8 @@ void GameBoyCheatListDialog::vRemoveAllCheats()
|
||||||
gbCheatRemoveAll();
|
gbCheatRemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable) {
|
void GameBoyCheatListDialog::vToggleCheat(int index, bool enable)
|
||||||
|
{
|
||||||
if (enable)
|
if (enable)
|
||||||
gbCheatEnable(index);
|
gbCheatEnable(index);
|
||||||
else
|
else
|
||||||
|
@ -108,8 +103,7 @@ void GameBoyCheatListDialog::vToggleCheat(int index, bool enable) {
|
||||||
|
|
||||||
void GameBoyCheatListDialog::vUpdateList(int previous)
|
void GameBoyCheatListDialog::vUpdateList(int previous)
|
||||||
{
|
{
|
||||||
for (int i = previous; i < gbCheatNumber; i++)
|
for (int i = previous; i < gbCheatNumber; i++) {
|
||||||
{
|
|
||||||
// Add row for each newly added cheat
|
// Add row for each newly added cheat
|
||||||
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
||||||
|
|
||||||
|
|
|
@ -22,17 +22,15 @@
|
||||||
#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);
|
||||||
|
|
|
@ -18,17 +18,15 @@
|
||||||
|
|
||||||
#include "gameboyconfig.h"
|
#include "gameboyconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
static const VBA::Window::EEmulatorType aEmulatorType[] =
|
static const VBA::Window::EEmulatorType aEmulatorType[] = {
|
||||||
{
|
|
||||||
VBA::Window::EmulatorAuto,
|
VBA::Window::EmulatorAuto,
|
||||||
VBA::Window::EmulatorCGB,
|
VBA::Window::EmulatorCGB,
|
||||||
VBA::Window::EmulatorSGB,
|
VBA::Window::EmulatorSGB,
|
||||||
|
@ -37,9 +35,9 @@ static const VBA::Window::EEmulatorType aEmulatorType[] =
|
||||||
VBA::Window::EmulatorSGB2
|
VBA::Window::EmulatorSGB2
|
||||||
};
|
};
|
||||||
|
|
||||||
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
|
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
|
||||||
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
|
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
|
||||||
|
@ -54,7 +52,7 @@ GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
|
||||||
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;
|
||||||
|
|
|
@ -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,18 +18,17 @@
|
||||||
|
|
||||||
#include "generalconfig.h"
|
#include "generalconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton);
|
refBuilder->get_widget("PauseWhenInactiveCheckButton", m_poPauseWhenInactiveCheckButton);
|
||||||
refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton);
|
refBuilder->get_widget("FrameSkipAutomaticCheckButton", m_poFrameSkipAutomaticCheckButton);
|
||||||
|
@ -40,10 +39,9 @@ PreferencesDialog::PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr<G
|
||||||
m_poFrameSkipAutomaticCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
|
m_poFrameSkipAutomaticCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
|
||||||
m_poFrameSkipLevelSpinButton->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
|
m_poFrameSkipLevelSpinButton->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnFrameskipChanged));
|
||||||
m_poSpeedIndicatorComboBox->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnSpeedIndicatorChanged));
|
m_poSpeedIndicatorComboBox->signal_changed().connect(sigc::mem_fun(*this, &PreferencesDialog::vOnSpeedIndicatorChanged));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow)
|
void PreferencesDialog::vSetConfig(Config::Section* _poConfig, VBA::Window* _poWindow)
|
||||||
{
|
{
|
||||||
m_poConfig = _poConfig;
|
m_poConfig = _poConfig;
|
||||||
m_poWindow = _poWindow;
|
m_poWindow = _poWindow;
|
||||||
|
@ -78,12 +76,9 @@ void PreferencesDialog::vOnFrameskipChanged()
|
||||||
{
|
{
|
||||||
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
|
bool bAutoFrameskip = m_poFrameSkipAutomaticCheckButton->get_active();
|
||||||
|
|
||||||
if (bAutoFrameskip)
|
if (bAutoFrameskip) {
|
||||||
{
|
|
||||||
m_poConfig->vSetKey("frameskip", "auto");
|
m_poConfig->vSetKey("frameskip", "auto");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
|
int iFrameskip = m_poFrameSkipLevelSpinButton->get_value();
|
||||||
m_poConfig->vSetKey("frameskip", iFrameskip);
|
m_poConfig->vSetKey("frameskip", iFrameskip);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,11 +23,9 @@
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
|
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = {
|
||||||
{
|
|
||||||
{ KEY_UP, N_("Up :") },
|
{ KEY_UP, N_("Up :") },
|
||||||
{ KEY_DOWN, N_("Down :") },
|
{ KEY_DOWN, N_("Down :") },
|
||||||
{ KEY_LEFT, N_("Left :") },
|
{ KEY_LEFT, N_("Left :") },
|
||||||
|
@ -44,18 +42,18 @@ const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
|
||||||
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
|
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
|
||||||
};
|
};
|
||||||
|
|
||||||
JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :
|
JoypadConfigDialog::JoypadConfigDialog(Config::Section* _poConfig)
|
||||||
Gtk::Dialog(_("Joypad config"), true),
|
: Gtk::Dialog(_("Joypad config"), true)
|
||||||
m_oTitleHBox(false, 5),
|
, m_oTitleHBox(false, 5)
|
||||||
m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END),
|
, m_oTitleLabel(_("Joypad :"), Gtk::ALIGN_END)
|
||||||
m_oDefaultJoypad(_("Default joypad")),
|
, m_oDefaultJoypad(_("Default joypad"))
|
||||||
m_oTable(G_N_ELEMENTS(m_astKeys), 2, false),
|
, m_oTable(G_N_ELEMENTS(m_astKeys), 2, false)
|
||||||
m_iCurrentEntry(-1),
|
, m_iCurrentEntry(-1)
|
||||||
m_bUpdating(false),
|
, m_bUpdating(false)
|
||||||
m_ePad(PAD_MAIN),
|
, m_ePad(PAD_MAIN)
|
||||||
m_poConfig(_poConfig)
|
, m_poConfig(_poConfig)
|
||||||
{
|
{
|
||||||
// Joypad selection
|
// Joypad selection
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
m_oTitleCombo.append_text("1");
|
m_oTitleCombo.append_text("1");
|
||||||
m_oTitleCombo.append_text("2");
|
m_oTitleCombo.append_text("2");
|
||||||
|
@ -72,12 +70,11 @@ JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :
|
||||||
m_oTitleHBox.pack_start(m_oTitleCombo);
|
m_oTitleHBox.pack_start(m_oTitleCombo);
|
||||||
|
|
||||||
// Joypad buttons
|
// Joypad buttons
|
||||||
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++)
|
for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++) {
|
||||||
{
|
Gtk::Label* poLabel = Gtk::manage(new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END));
|
||||||
Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(gettext(m_astKeys[i].m_csKeyName), Gtk::ALIGN_END) );
|
Gtk::Entry* poEntry = Gtk::manage(new Gtk::Entry());
|
||||||
Gtk::Entry * poEntry = Gtk::manage( new Gtk::Entry() );
|
m_oTable.attach(*poLabel, 0, 1, i, i + 1);
|
||||||
m_oTable.attach(* poLabel, 0, 1, i, i + 1);
|
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(
|
||||||
|
@ -102,9 +99,9 @@ JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :
|
||||||
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");
|
||||||
|
|
||||||
|
@ -121,60 +118,55 @@ void JoypadConfigDialog::vUpdateEntries()
|
||||||
m_bUpdating = true;
|
m_bUpdating = true;
|
||||||
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
|
m_oDefaultJoypad.set_active(inputGetDefaultJoypad() == m_ePad);
|
||||||
|
|
||||||
for (guint i = 0; i < m_oEntries.size(); i++)
|
for (guint i = 0; i < m_oEntries.size(); i++) {
|
||||||
{
|
|
||||||
std::string csName;
|
std::string csName;
|
||||||
|
|
||||||
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
|
guint uiKeyval = inputGetKeymap(m_ePad, m_astKeys[i].m_eKeyFlag);
|
||||||
int dev = uiKeyval >> 16;
|
int dev = uiKeyval >> 16;
|
||||||
if (dev == 0)
|
if (dev == 0) {
|
||||||
{
|
|
||||||
csName = gdk_keyval_name(uiKeyval);
|
csName = gdk_keyval_name(uiKeyval);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int what = uiKeyval & 0xffff;
|
int what = uiKeyval & 0xffff;
|
||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
os << _("Joy ") << dev;
|
os << _("Joy ") << dev;
|
||||||
|
|
||||||
if(what >= 128)
|
if (what >= 128) {
|
||||||
{
|
|
||||||
// joystick button
|
// joystick button
|
||||||
int button = what - 128;
|
int button = what - 128;
|
||||||
os << _(" Button ") << button;
|
os << _(" Button ") << button;
|
||||||
}
|
} else if (what < 0x20) {
|
||||||
else if (what < 0x20)
|
|
||||||
{
|
|
||||||
// joystick axis
|
// joystick axis
|
||||||
int dir = what & 1;
|
int dir = what & 1;
|
||||||
what >>= 1;
|
what >>= 1;
|
||||||
os << _(" Axis ") << what << (dir?'-':'+');
|
os << _(" Axis ") << what << (dir ? '-' : '+');
|
||||||
}
|
} else if (what < 0x30) {
|
||||||
else if (what < 0x30)
|
|
||||||
{
|
|
||||||
// joystick hat
|
// joystick hat
|
||||||
int dir = (what & 3);
|
int dir = (what & 3);
|
||||||
what = (what & 15);
|
what = (what & 15);
|
||||||
what >>= 2;
|
what >>= 2;
|
||||||
os << _(" Hat ") << what << " ";
|
os << _(" Hat ") << what << " ";
|
||||||
switch (dir)
|
switch (dir) {
|
||||||
{
|
case 0:
|
||||||
case 0: os << _("Up"); break;
|
os << _("Up");
|
||||||
case 1: os << _("Down"); break;
|
break;
|
||||||
case 2: os << _("Right"); break;
|
case 1:
|
||||||
case 3: os << _("Left"); break;
|
os << _("Down");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
os << _("Right");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
os << _("Left");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
csName = os.str();
|
csName = os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (csName.empty())
|
if (csName.empty()) {
|
||||||
{
|
|
||||||
m_oEntries[i]->set_text(_("<Undefined>"));
|
m_oEntries[i]->set_text(_("<Undefined>"));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_oEntries[i]->set_text(csName);
|
m_oEntries[i]->set_text(csName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +174,7 @@ void JoypadConfigDialog::vUpdateEntries()
|
||||||
m_bUpdating = false;
|
m_bUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus * _pstEvent,
|
bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus* _pstEvent,
|
||||||
guint _uiEntry)
|
guint _uiEntry)
|
||||||
{
|
{
|
||||||
m_iCurrentEntry = _uiEntry;
|
m_iCurrentEntry = _uiEntry;
|
||||||
|
@ -190,17 +182,16 @@ bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus * _pstEvent,
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,24 +213,21 @@ 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)
|
||||||
|
return;
|
||||||
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
|
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
|
||||||
vUpdateEntries();
|
vUpdateEntries();
|
||||||
|
|
||||||
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size())
|
if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) {
|
||||||
{
|
|
||||||
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
|
m_oEntries[m_iCurrentEntry + 1]->grab_focus();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_poOkButton->grab_focus();
|
m_poOkButton->grab_focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,17 +235,15 @@ void JoypadConfigDialog::vOnInputEvent(const SDL_Event &event)
|
||||||
bool JoypadConfigDialog::bOnConfigIdle()
|
bool JoypadConfigDialog::bOnConfigIdle()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event)) {
|
||||||
{
|
switch (event.type) {
|
||||||
switch(event.type)
|
|
||||||
{
|
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_JOYAXISMOTION:
|
||||||
if (abs(event.jaxis.value) < 16384) continue;
|
if (abs(event.jaxis.value) < 16384)
|
||||||
|
continue;
|
||||||
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|
if (event.jaxis.which != m_oPreviousEvent.jaxis.which
|
||||||
|| event.jaxis.axis != m_oPreviousEvent.jaxis.axis
|
|| event.jaxis.axis != m_oPreviousEvent.jaxis.axis
|
||||||
|| (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
|
|| (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
|
||||||
|| (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0))
|
|| (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0)) {
|
||||||
{
|
|
||||||
vOnInputEvent(event);
|
vOnInputEvent(event);
|
||||||
m_oPreviousEvent = event;
|
m_oPreviousEvent = event;
|
||||||
}
|
}
|
||||||
|
@ -268,8 +254,7 @@ bool JoypadConfigDialog::bOnConfigIdle()
|
||||||
vEmptyEventQueue();
|
vEmptyEventQueue();
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_JOYHATMOTION:
|
||||||
if (event.jhat.value)
|
if (event.jhat.value) {
|
||||||
{
|
|
||||||
vOnInputEvent(event);
|
vOnInputEvent(event);
|
||||||
vEmptyEventQueue();
|
vEmptyEventQueue();
|
||||||
}
|
}
|
||||||
|
@ -284,27 +269,21 @@ void JoypadConfigDialog::vEmptyEventQueue()
|
||||||
{
|
{
|
||||||
// Empty the SDL event queue
|
// Empty the SDL event queue
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while(SDL_PollEvent(&event));
|
while (SDL_PollEvent(&event))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoypadConfigDialog::vOnJoypadSelect()
|
void JoypadConfigDialog::vOnJoypadSelect()
|
||||||
{
|
{
|
||||||
std::string oText = m_oTitleCombo.get_active_text();
|
std::string oText = m_oTitleCombo.get_active_text();
|
||||||
|
|
||||||
if (oText == "1")
|
if (oText == "1") {
|
||||||
{
|
|
||||||
m_ePad = PAD_1;
|
m_ePad = PAD_1;
|
||||||
}
|
} else if (oText == "2") {
|
||||||
else if (oText == "2")
|
|
||||||
{
|
|
||||||
m_ePad = PAD_2;
|
m_ePad = PAD_2;
|
||||||
}
|
} else if (oText == "3") {
|
||||||
else if (oText == "3")
|
|
||||||
{
|
|
||||||
m_ePad = PAD_3;
|
m_ePad = PAD_3;
|
||||||
}
|
} else if (oText == "4") {
|
||||||
else if (oText == "4")
|
|
||||||
{
|
|
||||||
m_ePad = PAD_4;
|
m_ePad = PAD_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,14 +295,12 @@ void JoypadConfigDialog::vOnJoypadSelect()
|
||||||
|
|
||||||
void JoypadConfigDialog::vOnDefaultJoypadSelect()
|
void JoypadConfigDialog::vOnDefaultJoypadSelect()
|
||||||
{
|
{
|
||||||
if (m_bUpdating) return;
|
if (m_bUpdating)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_oDefaultJoypad.get_active())
|
if (m_oDefaultJoypad.get_active()) {
|
||||||
{
|
|
||||||
inputSetDefaultJoypad(m_ePad);
|
inputSetDefaultJoypad(m_ePad);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
inputSetDefaultJoypad(PAD_MAIN);
|
inputSetDefaultJoypad(PAD_MAIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,26 +33,24 @@
|
||||||
#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:
|
|
||||||
JoypadConfigDialog(Config::Section *_poConfig);
|
|
||||||
virtual ~JoypadConfigDialog();
|
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;
|
||||||
|
@ -61,15 +59,15 @@ class JoypadConfigDialog : public Gtk::Dialog
|
||||||
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();
|
||||||
|
|
|
@ -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,12 +28,12 @@
|
||||||
// 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;
|
||||||
|
@ -70,12 +70,9 @@ int main(int argc, char * argv[])
|
||||||
|
|
||||||
oContext.set_main_group(oGroup);
|
oContext.set_main_group(oGroup);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
oContext.parse(argc, argv);
|
oContext.parse(argc, argv);
|
||||||
}
|
} catch (const Glib::Error& e) {
|
||||||
catch (const Glib::Error& e)
|
|
||||||
{
|
|
||||||
Gtk::MessageDialog oDialog(e.what(),
|
Gtk::MessageDialog oDialog(e.what(),
|
||||||
false,
|
false,
|
||||||
Gtk::MESSAGE_ERROR,
|
Gtk::MESSAGE_ERROR,
|
||||||
|
@ -84,8 +81,7 @@ int main(int argc, char * argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bShowVersion)
|
if (bShowVersion) {
|
||||||
{
|
|
||||||
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
|
g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -95,14 +91,11 @@ int main(int argc, char * argv[])
|
||||||
std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");
|
std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui");
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::Builder> poXml;
|
Glib::RefPtr<Gtk::Builder> poXml;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
poXml = Gtk::Builder::create();
|
poXml = Gtk::Builder::create();
|
||||||
poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
|
poXml->add_from_file(sGtkBuilderFile, "accelgroup1");
|
||||||
poXml->add_from_file(sGtkBuilderFile, "MainWindow");
|
poXml->add_from_file(sGtkBuilderFile, "MainWindow");
|
||||||
}
|
} catch (const Gtk::BuilderError& e) {
|
||||||
catch (const Gtk::BuilderError & e)
|
|
||||||
{
|
|
||||||
Gtk::MessageDialog oDialog(e.what(),
|
Gtk::MessageDialog oDialog(e.what(),
|
||||||
false,
|
false,
|
||||||
Gtk::MESSAGE_ERROR,
|
Gtk::MESSAGE_ERROR,
|
||||||
|
@ -111,15 +104,13 @@ int main(int argc, char * argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBA::Window * poWindow = NULL;
|
VBA::Window* poWindow = NULL;
|
||||||
poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
|
poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow);
|
||||||
|
|
||||||
if (listRemaining.size() == 1)
|
if (listRemaining.size() == 1) {
|
||||||
{
|
|
||||||
// Display the window before loading the file
|
// Display the window before loading the file
|
||||||
poWindow->show();
|
poWindow->show();
|
||||||
while (Gtk::Main::events_pending())
|
while (Gtk::Main::events_pending()) {
|
||||||
{
|
|
||||||
Gtk::Main::iteration();
|
Gtk::Main::iteration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,20 @@
|
||||||
|
|
||||||
#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);
|
||||||
|
|
||||||
|
@ -40,12 +41,12 @@ void ScreenAreaCairo::vDrawPixels(u8 * _puiData)
|
||||||
}
|
}
|
||||||
|
|
||||||
#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);
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ bool ScreenAreaCairo::on_expose_event(GdkEventExpose * _pstEvent)
|
||||||
//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);
|
||||||
|
@ -70,18 +71,18 @@ bool ScreenAreaCairo::on_expose_event(GdkEventExpose * _pstEvent)
|
||||||
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);
|
||||||
|
@ -100,8 +101,7 @@ bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context> &poContext)
|
||||||
|
|
||||||
void ScreenAreaCairo::vDrawBlackScreen()
|
void ScreenAreaCairo::vDrawBlackScreen()
|
||||||
{
|
{
|
||||||
if (m_puiPixels && get_realized())
|
if (m_puiPixels && get_realized()) {
|
||||||
{
|
|
||||||
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
||||||
queue_draw_area(0, 0, get_width(), get_height());
|
queue_draw_area(0, 0, get_width(), get_height());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,24 +22,22 @@
|
||||||
|
|
||||||
#include "screenarea.h"
|
#include "screenarea.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ScreenAreaCairo : public ScreenArea {
|
||||||
class ScreenAreaCairo : public ScreenArea
|
public:
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
|
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
|
||||||
void vDrawPixels(u8 *_puiData);
|
void vDrawPixels(u8* _puiData);
|
||||||
void vDrawBlackScreen();
|
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;
|
||||||
|
|
|
@ -21,23 +21,22 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
template<typename T> T min( T x, T y ) { return x < y ? x : y; }
|
template <typename T>
|
||||||
template<typename T> T max( T x, T y ) { return x > y ? x : y; }
|
T min(T x, T y) { return x < y ? x : y; }
|
||||||
|
template <typename T>
|
||||||
|
T max(T x, T y) { return x > y ? x : y; }
|
||||||
|
|
||||||
ScreenAreaGl::ScreenAreaGl(int _iWidth, int _iHeight, int _iScale) :
|
ScreenAreaGl::ScreenAreaGl(int _iWidth, int _iHeight, int _iScale)
|
||||||
ScreenArea(_iWidth, _iHeight, _iScale),
|
: ScreenArea(_iWidth, _iHeight, _iScale)
|
||||||
m_uiScreenTexture(0),
|
, m_uiScreenTexture(0)
|
||||||
m_iTextureSize(0)
|
, m_iTextureSize(0)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gdk::GL::Config> glconfig;
|
Glib::RefPtr<Gdk::GL::Config> glconfig;
|
||||||
|
|
||||||
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB |
|
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DOUBLE);
|
||||||
Gdk::GL::MODE_DOUBLE);
|
if (!glconfig) {
|
||||||
if (!glconfig)
|
|
||||||
{
|
|
||||||
fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
|
fprintf(stderr, _("*** OpenGL : Cannot open display.\n"));
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
@ -52,8 +51,10 @@ void ScreenAreaGl::vUpdateTexture()
|
||||||
// Calculate the new texture size as a the smallest working power of two
|
// Calculate the new texture size as a the smallest working power of two
|
||||||
// TODO: Support the ARB_texture_rectangle extension
|
// TODO: Support the ARB_texture_rectangle extension
|
||||||
int iExpX = 0, iExpY = 0;
|
int iExpX = 0, iExpY = 0;
|
||||||
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX);
|
for (int i = m_iScaledWidth; i; i >>= 1, ++iExpX)
|
||||||
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY);
|
;
|
||||||
|
for (int i = m_iScaledHeight; i; i >>= 1, ++iExpY)
|
||||||
|
;
|
||||||
int iNewTextureSize = 1 << max(iExpX, iExpY);
|
int iNewTextureSize = 1 << max(iExpX, iExpY);
|
||||||
|
|
||||||
// Notify the system if the texture size changed
|
// Notify the system if the texture size changed
|
||||||
|
@ -100,7 +101,7 @@ void ScreenAreaGl::on_realize()
|
||||||
glwindow->gl_end();
|
glwindow->gl_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenAreaGl::vDrawPixels(u8 * _puiData)
|
void ScreenAreaGl::vDrawPixels(u8* _puiData)
|
||||||
{
|
{
|
||||||
ScreenArea::vDrawPixels(_puiData);
|
ScreenArea::vDrawPixels(_puiData);
|
||||||
|
|
||||||
|
@ -109,8 +110,7 @@ void ScreenAreaGl::vDrawPixels(u8 * _puiData)
|
||||||
|
|
||||||
void ScreenAreaGl::vDrawBlackScreen()
|
void ScreenAreaGl::vDrawBlackScreen()
|
||||||
{
|
{
|
||||||
if (m_puiPixels && get_realized())
|
if (m_puiPixels && get_realized()) {
|
||||||
{
|
|
||||||
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
|
||||||
queue_draw_area(0, 0, get_width(), get_height());
|
queue_draw_area(0, 0, get_width(), get_height());
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,8 @@ void ScreenAreaGl::vOnWidgetResize()
|
||||||
int iWidth = get_width();
|
int iWidth = get_width();
|
||||||
int iHeight = get_height();
|
int iHeight = get_height();
|
||||||
|
|
||||||
float fScreenAspect = (float) m_iScaledWidth / m_iScaledHeight,
|
float fScreenAspect = (float)m_iScaledWidth / m_iScaledHeight,
|
||||||
fWindowAspect = (float) iWidth / iHeight;
|
fWindowAspect = (float)iWidth / iHeight;
|
||||||
|
|
||||||
if (!glwindow->gl_begin(get_gl_context()))
|
if (!glwindow->gl_begin(get_gl_context()))
|
||||||
return;
|
return;
|
||||||
|
@ -142,7 +142,7 @@ void ScreenAreaGl::vOnWidgetResize()
|
||||||
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;
|
||||||
|
@ -151,7 +151,7 @@ bool ScreenAreaGl::on_expose_event(GdkEventExpose * _pstEvent)
|
||||||
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);
|
||||||
|
@ -159,12 +159,12 @@ bool ScreenAreaGl::on_expose_event(GdkEventExpose * _pstEvent)
|
||||||
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();
|
||||||
|
|
||||||
|
|
|
@ -23,21 +23,19 @@
|
||||||
#include "screenarea.h"
|
#include "screenarea.h"
|
||||||
#include <gtkmm/gl/widget.h>
|
#include <gtkmm/gl/widget.h>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
|
||||||
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl>
|
public:
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
|
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
|
||||||
void vDrawPixels(u8 *_puiData);
|
void vDrawPixels(u8* _puiData);
|
||||||
void vDrawBlackScreen();
|
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;
|
||||||
|
|
||||||
|
|
|
@ -21,19 +21,18 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <glibmm/main.h>
|
#include <glibmm/main.h>
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) :
|
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale)
|
||||||
m_iFilterScale(1),
|
: m_iFilterScale(1)
|
||||||
m_vFilter2x(NULL),
|
, m_vFilter2x(NULL)
|
||||||
m_vFilterIB(NULL),
|
, m_vFilterIB(NULL)
|
||||||
m_puiPixels(NULL),
|
, m_puiPixels(NULL)
|
||||||
m_puiDelta(NULL),
|
, m_puiDelta(NULL)
|
||||||
m_iScaledWidth(_iWidth),
|
, m_iScaledWidth(_iWidth)
|
||||||
m_iScaledHeight(_iHeight),
|
, m_iScaledHeight(_iHeight)
|
||||||
m_bEnableRender(true),
|
, m_bEnableRender(true)
|
||||||
m_bShowCursor(true)
|
, m_bShowCursor(true)
|
||||||
{
|
{
|
||||||
g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
|
g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);
|
||||||
|
|
||||||
|
@ -58,19 +57,16 @@ ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) :
|
||||||
|
|
||||||
ScreenArea::~ScreenArea()
|
ScreenArea::~ScreenArea()
|
||||||
{
|
{
|
||||||
if (m_puiPixels)
|
if (m_puiPixels) {
|
||||||
{
|
|
||||||
delete[] m_puiPixels;
|
delete[] m_puiPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_puiDelta)
|
if (m_puiDelta) {
|
||||||
{
|
|
||||||
delete[] m_puiDelta;
|
delete[] m_puiDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||||
if (m_poEmptyCursor != NULL)
|
if (m_poEmptyCursor != NULL) {
|
||||||
{
|
|
||||||
delete m_poEmptyCursor;
|
delete m_poEmptyCursor;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -82,8 +78,7 @@ void ScreenArea::vSetSize(int _iWidth, int _iHeight)
|
||||||
{
|
{
|
||||||
g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
|
g_return_if_fail(_iWidth >= 1 && _iHeight >= 1);
|
||||||
|
|
||||||
if (_iWidth != m_iWidth || _iHeight != m_iHeight)
|
if (_iWidth != m_iWidth || _iHeight != m_iHeight) {
|
||||||
{
|
|
||||||
m_iWidth = _iWidth;
|
m_iWidth = _iWidth;
|
||||||
m_iHeight = _iHeight;
|
m_iHeight = _iHeight;
|
||||||
vUpdateSize();
|
vUpdateSize();
|
||||||
|
@ -94,8 +89,7 @@ void ScreenArea::vSetScale(int _iScale)
|
||||||
{
|
{
|
||||||
g_return_if_fail(_iScale >= 1);
|
g_return_if_fail(_iScale >= 1);
|
||||||
|
|
||||||
if (_iScale == 1)
|
if (_iScale == 1) {
|
||||||
{
|
|
||||||
vSetFilter(FilterNone);
|
vSetFilter(FilterNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +102,7 @@ void ScreenArea::vSetFilter(EFilter _eFilter)
|
||||||
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
|
m_vFilter2x = pvGetFilter(_eFilter, FilterDepth32);
|
||||||
|
|
||||||
m_iFilterScale = 1;
|
m_iFilterScale = 1;
|
||||||
if (m_vFilter2x != NULL)
|
if (m_vFilter2x != NULL) {
|
||||||
{
|
|
||||||
m_iFilterScale = 2;
|
m_iFilterScale = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,27 +143,25 @@ void ScreenArea::vShowCursor()
|
||||||
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;
|
||||||
|
@ -182,44 +173,38 @@ bool ScreenArea::bOnCursorTimeout()
|
||||||
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 {
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
|
memcpy(m_puiPixels, _puiData + iSrcPitch, m_iHeight * iSrcPitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenArea::vUpdateSize()
|
void ScreenArea::vUpdateSize()
|
||||||
{
|
{
|
||||||
if (m_puiPixels)
|
if (m_puiPixels) {
|
||||||
{
|
|
||||||
delete[] m_puiPixels;
|
delete[] m_puiPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_puiDelta)
|
if (m_puiDelta) {
|
||||||
{
|
|
||||||
delete[] m_puiDelta;
|
delete[] m_puiDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +221,7 @@ void ScreenArea::vUpdateSize()
|
||||||
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();
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,9 @@
|
||||||
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
class ScreenArea : public Gtk::DrawingArea {
|
||||||
class ScreenArea : public Gtk::DrawingArea
|
public:
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
|
ScreenArea(int _iWidth, int _iHeight, int _iScale = 1);
|
||||||
virtual ~ScreenArea();
|
virtual ~ScreenArea();
|
||||||
|
|
||||||
|
@ -38,14 +36,14 @@ class ScreenArea : public Gtk::DrawingArea
|
||||||
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()
|
||||||
{
|
{
|
||||||
|
@ -59,8 +57,8 @@ class ScreenArea : public Gtk::DrawingArea
|
||||||
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;
|
||||||
|
@ -68,7 +66,7 @@ class ScreenArea : public Gtk::DrawingArea
|
||||||
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
|
||||||
|
|
|
@ -18,18 +18,17 @@
|
||||||
|
|
||||||
#include "soundconfig.h"
|
#include "soundconfig.h"
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/frame.h>
|
#include <gtkmm/frame.h>
|
||||||
#include <gtkmm/liststore.h>
|
#include <gtkmm/liststore.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder)
|
||||||
Gtk::Dialog(_pstDialog),
|
: Gtk::Dialog(_pstDialog)
|
||||||
m_poConfig(0)
|
, m_poConfig(0)
|
||||||
{
|
{
|
||||||
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
|
refBuilder->get_widget("VolumeComboBox", m_poVolumeComboBox);
|
||||||
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
|
refBuilder->get_widget("RateComboBox", m_poRateComboBox);
|
||||||
|
@ -38,7 +37,7 @@ SoundConfigDialog::SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr<G
|
||||||
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;
|
||||||
|
@ -58,8 +57,7 @@ void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _p
|
||||||
m_poVolumeComboBox->set_active(3);
|
m_poVolumeComboBox->set_active(3);
|
||||||
|
|
||||||
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
|
long iSoundSampleRate = m_poConfig->oGetKey<long>("sample_rate");
|
||||||
switch (iSoundSampleRate)
|
switch (iSoundSampleRate) {
|
||||||
{
|
|
||||||
case 11025:
|
case 11025:
|
||||||
m_poRateComboBox->set_active(0);
|
m_poRateComboBox->set_active(0);
|
||||||
break;
|
break;
|
||||||
|
@ -79,8 +77,7 @@ void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _p
|
||||||
void SoundConfigDialog::vOnVolumeChanged()
|
void SoundConfigDialog::vOnVolumeChanged()
|
||||||
{
|
{
|
||||||
int iVolume = m_poVolumeComboBox->get_active_row_number();
|
int iVolume = m_poVolumeComboBox->get_active_row_number();
|
||||||
switch (iVolume)
|
switch (iVolume) {
|
||||||
{
|
|
||||||
case 0: // Mute
|
case 0: // Mute
|
||||||
m_poConfig->vSetKey("mute", true);
|
m_poConfig->vSetKey("mute", true);
|
||||||
m_poConfig->vSetKey("volume", 1.0f);
|
m_poConfig->vSetKey("volume", 1.0f);
|
||||||
|
@ -111,8 +108,7 @@ void SoundConfigDialog::vOnVolumeChanged()
|
||||||
void SoundConfigDialog::vOnRateChanged()
|
void SoundConfigDialog::vOnRateChanged()
|
||||||
{
|
{
|
||||||
int iRate = m_poRateComboBox->get_active_row_number();
|
int iRate = m_poRateComboBox->get_active_row_number();
|
||||||
switch (iRate)
|
switch (iRate) {
|
||||||
{
|
|
||||||
case 0: // 11 KHz
|
case 0: // 11 KHz
|
||||||
m_poConfig->vSetKey("sample_rate", 11025);
|
m_poConfig->vSetKey("sample_rate", 11025);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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,12 +16,12 @@
|
||||||
// along with this program; if not, write to the Free Software Foundation,
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "../sdl/inputSDL.h"
|
|
||||||
#include "../gba/Sound.h"
|
|
||||||
#include "../common/SoundSDL.h"
|
#include "../common/SoundSDL.h"
|
||||||
|
#include "../gba/Sound.h"
|
||||||
|
#include "../sdl/inputSDL.h"
|
||||||
|
|
||||||
#include "window.h"
|
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
// Required vars, used by the emulator core
|
// Required vars, used by the emulator core
|
||||||
//
|
//
|
||||||
|
@ -39,24 +39,26 @@ 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()
|
||||||
|
@ -71,26 +73,30 @@ u32 systemReadJoypad(int joy)
|
||||||
|
|
||||||
void systemShowSpeed(int _iSpeed)
|
void systemShowSpeed(int _iSpeed)
|
||||||
{
|
{
|
||||||
GUI()->vShowSpeed(_iSpeed);
|
GUI()
|
||||||
|
->vShowSpeed(_iSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void system10Frames(int _iRate)
|
void system10Frames(int _iRate)
|
||||||
{
|
{
|
||||||
GUI()->vComputeFrameskip(_iRate);
|
GUI()
|
||||||
|
->vComputeFrameskip(_iRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemFrame()
|
void systemFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
|
@ -128,7 +134,7 @@ void systemCartridgeRumble(bool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemGbPrint(u8 * _puiData,
|
void systemGbPrint(u8* _puiData,
|
||||||
int _iLen,
|
int _iLen,
|
||||||
int _iPages,
|
int _iPages,
|
||||||
int _iFeed,
|
int _iFeed,
|
||||||
|
@ -137,7 +143,7 @@ void systemGbPrint(u8 * _puiData,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemScreenMessage(const char * _csMsg)
|
void systemScreenMessage(const char* _csMsg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +161,7 @@ void systemGbBorderOn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundDriver * systemSoundInit()
|
SoundDriver* systemSoundInit()
|
||||||
{
|
{
|
||||||
soundShutdown();
|
soundShutdown();
|
||||||
|
|
||||||
|
@ -166,7 +172,7 @@ void systemOnSoundShutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
|
void systemOnWriteDataToSoundBuffer(const u16* finalWave, int length)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,12 +184,12 @@ 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;
|
||||||
|
|
|
@ -18,43 +18,36 @@
|
||||||
|
|
||||||
#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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
|
Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());
|
||||||
|
|
||||||
if (_bCaseSensitive)
|
if (_bCaseSensitive) {
|
||||||
{
|
if (_rsSuffix == sEnd) {
|
||||||
if (_rsSuffix == sEnd)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (_rsSuffix.lowercase() == sEnd.lowercase()) {
|
||||||
{
|
|
||||||
if (_rsSuffix.lowercase() == sEnd.lowercase())
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,8 +64,7 @@ void vTokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens)
|
||||||
// Find first "non-delimiter".
|
// Find first "non-delimiter".
|
||||||
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
|
Glib::ustring::size_type pos = source.find_first_of(delimiters, lastPos);
|
||||||
|
|
||||||
while (Glib::ustring::npos != pos || std:: string::npos != lastPos)
|
while (Glib::ustring::npos != pos || std::string::npos != lastPos) {
|
||||||
{
|
|
||||||
// Found a token, add it to the vector.
|
// Found a token, add it to the vector.
|
||||||
tokens.push_back(source.substr(lastPos, pos - lastPos));
|
tokens.push_back(source.substr(lastPos, pos - lastPos));
|
||||||
// Skip delimiters. Note the "not_of"
|
// Skip delimiters. Note the "not_of"
|
||||||
|
|
|
@ -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__
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
107
src/gtk/window.h
107
src/gtk/window.h
|
@ -34,24 +34,25 @@
|
||||||
#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,
|
||||||
|
@ -62,7 +63,12 @@ class Window : public Gtk::Window
|
||||||
EmulatorSGB2
|
EmulatorSGB2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ESaveType { SaveAuto, SaveEEPROM, SaveSRAM, SaveFlash, SaveEEPROMSensor, SaveNone };
|
enum ESaveType { SaveAuto,
|
||||||
|
SaveEEPROM,
|
||||||
|
SaveSRAM,
|
||||||
|
SaveFlash,
|
||||||
|
SaveEEPROMSensor,
|
||||||
|
SaveNone };
|
||||||
|
|
||||||
// GB/GBA screen sizes
|
// GB/GBA screen sizes
|
||||||
const int m_iGBScreenWidth;
|
const int m_iGBScreenWidth;
|
||||||
|
@ -72,9 +78,9 @@ class Window : public Gtk::Window
|
||||||
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);
|
||||||
|
@ -101,14 +107,19 @@ class Window : public Gtk::Window
|
||||||
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();
|
||||||
|
@ -116,11 +127,11 @@ class Window : public Gtk::Window
|
||||||
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();
|
||||||
|
@ -135,19 +146,19 @@ class Window : public Gtk::Window
|
||||||
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;
|
||||||
|
@ -172,24 +183,24 @@ class Window : public Gtk::Window
|
||||||
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;
|
||||||
|
@ -198,21 +209,21 @@ class Window : public Gtk::Window
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -233,8 +244,8 @@ class Window : public Gtk::Window
|
||||||
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();
|
||||||
|
@ -242,9 +253,9 @@ class Window : public Gtk::Window
|
||||||
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();
|
||||||
|
|
|
@ -20,45 +20,43 @@
|
||||||
|
|
||||||
#include <glibmm/convert.h>
|
#include <glibmm/convert.h>
|
||||||
#include <glibmm/fileutils.h>
|
#include <glibmm/fileutils.h>
|
||||||
#include <glibmm/miscutils.h>
|
|
||||||
#include <glibmm/main.h>
|
#include <glibmm/main.h>
|
||||||
|
#include <glibmm/miscutils.h>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#include <gtkmm/stock.h>
|
|
||||||
#include <gtkmm/messagedialog.h>
|
|
||||||
#include <gtkmm/aboutdialog.h>
|
#include <gtkmm/aboutdialog.h>
|
||||||
#include <gtkmm/builder.h>
|
#include <gtkmm/builder.h>
|
||||||
|
#include <gtkmm/messagedialog.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "../Util.h"
|
||||||
#include "../common/ConfigManager.h"
|
#include "../common/ConfigManager.h"
|
||||||
#include "../gba/GBA.h"
|
|
||||||
#include "../gba/Sound.h"
|
|
||||||
#include "../gb/gb.h"
|
#include "../gb/gb.h"
|
||||||
#include "../gb/gbGlobals.h"
|
#include "../gb/gbGlobals.h"
|
||||||
#include "../Util.h"
|
#include "../gba/GBA.h"
|
||||||
|
#include "../gba/Sound.h"
|
||||||
#include "../sdl/inputSDL.h"
|
#include "../sdl/inputSDL.h"
|
||||||
|
|
||||||
#include "tools.h"
|
|
||||||
#include "intl.h"
|
|
||||||
#include "joypadconfig.h"
|
|
||||||
#include "directoriesconfig.h"
|
#include "directoriesconfig.h"
|
||||||
#include "displayconfig.h"
|
#include "displayconfig.h"
|
||||||
#include "soundconfig.h"
|
|
||||||
#include "gameboyconfig.h"
|
|
||||||
#include "gameboyadvanceconfig.h"
|
|
||||||
#include "generalconfig.h"
|
|
||||||
#include "gameboyadvancecheatlist.h"
|
#include "gameboyadvancecheatlist.h"
|
||||||
|
#include "gameboyadvanceconfig.h"
|
||||||
#include "gameboycheatlist.h"
|
#include "gameboycheatlist.h"
|
||||||
|
#include "gameboyconfig.h"
|
||||||
|
#include "generalconfig.h"
|
||||||
|
#include "intl.h"
|
||||||
|
#include "joypadconfig.h"
|
||||||
|
#include "soundconfig.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
namespace VBA
|
namespace VBA {
|
||||||
{
|
|
||||||
|
|
||||||
void Window::vOnMenuEnter()
|
void Window::vOnMenuEnter()
|
||||||
{
|
{
|
||||||
if (emulating && ! m_bPaused)
|
if (emulating && !m_bPaused) {
|
||||||
{
|
|
||||||
vStopEmu();
|
vStopEmu();
|
||||||
soundPause();
|
soundPause();
|
||||||
}
|
}
|
||||||
|
@ -66,8 +64,7 @@ void Window::vOnMenuEnter()
|
||||||
|
|
||||||
void Window::vOnMenuExit()
|
void Window::vOnMenuExit()
|
||||||
{
|
{
|
||||||
if (emulating && ! m_bPaused)
|
if (emulating && !m_bPaused) {
|
||||||
{
|
|
||||||
vStartEmu();
|
vStartEmu();
|
||||||
soundResume();
|
soundResume();
|
||||||
}
|
}
|
||||||
|
@ -75,10 +72,8 @@ void Window::vOnMenuExit()
|
||||||
|
|
||||||
void Window::vOnFileOpen()
|
void Window::vOnFileOpen()
|
||||||
{
|
{
|
||||||
while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK)
|
while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK) {
|
||||||
{
|
if (bLoadROM(m_poFileOpenDialog->get_filename())) {
|
||||||
if (bLoadROM(m_poFileOpenDialog->get_filename()))
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,12 +88,9 @@ void Window::vOnFileLoad()
|
||||||
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
||||||
|
|
||||||
if (sSaveDir == "")
|
if (sSaveDir == "") {
|
||||||
{
|
|
||||||
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
oDialog.set_current_folder(sSaveDir);
|
oDialog.set_current_folder(sSaveDir);
|
||||||
oDialog.add_shortcut_folder(sSaveDir);
|
oDialog.add_shortcut_folder(sSaveDir);
|
||||||
}
|
}
|
||||||
|
@ -115,10 +107,8 @@ void Window::vOnFileLoad()
|
||||||
|
|
||||||
oDialog.add_filter(oSaveFilter);
|
oDialog.add_filter(oSaveFilter);
|
||||||
|
|
||||||
while (oDialog.run() == Gtk::RESPONSE_OK)
|
while (oDialog.run() == Gtk::RESPONSE_OK) {
|
||||||
{
|
if (m_stEmulator.emuReadState(oDialog.get_filename().c_str())) {
|
||||||
if (m_stEmulator.emuReadState(oDialog.get_filename().c_str()))
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,12 +123,9 @@ void Window::vOnFileSave()
|
||||||
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
||||||
|
|
||||||
if (sSaveDir == "")
|
if (sSaveDir == "") {
|
||||||
{
|
|
||||||
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
oDialog.set_current_folder(sSaveDir);
|
oDialog.set_current_folder(sSaveDir);
|
||||||
oDialog.add_shortcut_folder(sSaveDir);
|
oDialog.add_shortcut_folder(sSaveDir);
|
||||||
}
|
}
|
||||||
|
@ -156,29 +143,24 @@ void Window::vOnFileSave()
|
||||||
|
|
||||||
oDialog.add_filter(oSaveFilter);
|
oDialog.add_filter(oSaveFilter);
|
||||||
|
|
||||||
while (oDialog.run() == Gtk::RESPONSE_OK)
|
while (oDialog.run() == Gtk::RESPONSE_OK) {
|
||||||
{
|
|
||||||
Glib::ustring sFile = oDialog.get_filename();
|
Glib::ustring sFile = oDialog.get_filename();
|
||||||
if (! bHasSuffix(sFile, ".sgm", false))
|
if (!bHasSuffix(sFile, ".sgm", false)) {
|
||||||
{
|
|
||||||
sFile += ".sgm";
|
sFile += ".sgm";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
|
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) {
|
||||||
{
|
|
||||||
Gtk::MessageDialog oConfirmDialog(*this,
|
Gtk::MessageDialog oConfirmDialog(*this,
|
||||||
_("File already exists. Overwrite it?"),
|
_("File already exists. Overwrite it?"),
|
||||||
false,
|
false,
|
||||||
Gtk::MESSAGE_QUESTION,
|
Gtk::MESSAGE_QUESTION,
|
||||||
Gtk::BUTTONS_YES_NO);
|
Gtk::BUTTONS_YES_NO);
|
||||||
if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
|
if (oConfirmDialog.run() != Gtk::RESPONSE_YES) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_stEmulator.emuWriteState(sFile.c_str()))
|
if (m_stEmulator.emuWriteState(sFile.c_str())) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,23 +171,20 @@ void Window::vOnLoadGameMostRecent()
|
||||||
int iMostRecent = -1;
|
int iMostRecent = -1;
|
||||||
time_t uiTimeMax = 0;
|
time_t uiTimeMax = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++) {
|
||||||
{
|
if (!m_astGameSlot[i].m_bEmpty
|
||||||
if (! m_astGameSlot[i].m_bEmpty
|
&& (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax)) {
|
||||||
&& (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax))
|
|
||||||
{
|
|
||||||
iMostRecent = i;
|
iMostRecent = i;
|
||||||
uiTimeMax = m_astGameSlot[i].m_uiTime;
|
uiTimeMax = m_astGameSlot[i].m_uiTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iMostRecent >= 0)
|
if (iMostRecent >= 0) {
|
||||||
{
|
|
||||||
vOnLoadGame(iMostRecent + 1);
|
vOnLoadGame(iMostRecent + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI)
|
void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem* _poCMI)
|
||||||
{
|
{
|
||||||
m_poCoreConfig->vSetKey("load_game_auto", _poCMI->get_active());
|
m_poCoreConfig->vSetKey("load_game_auto", _poCMI->get_active());
|
||||||
}
|
}
|
||||||
|
@ -213,8 +192,7 @@ void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI)
|
||||||
void Window::vOnLoadGame(int _iSlot)
|
void Window::vOnLoadGame(int _iSlot)
|
||||||
{
|
{
|
||||||
int i = _iSlot - 1;
|
int i = _iSlot - 1;
|
||||||
if (! m_astGameSlot[i].m_bEmpty)
|
if (!m_astGameSlot[i].m_bEmpty) {
|
||||||
{
|
|
||||||
m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str());
|
m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str());
|
||||||
m_poFilePauseItem->set_active(false);
|
m_poFilePauseItem->set_active(false);
|
||||||
}
|
}
|
||||||
|
@ -225,22 +203,17 @@ void Window::vOnSaveGameOldest()
|
||||||
int iOldest = -1;
|
int iOldest = -1;
|
||||||
time_t uiTimeMin = 0;
|
time_t uiTimeMin = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++) {
|
||||||
{
|
if (!m_astGameSlot[i].m_bEmpty
|
||||||
if (! m_astGameSlot[i].m_bEmpty
|
&& (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin)) {
|
||||||
&& (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin))
|
|
||||||
{
|
|
||||||
iOldest = i;
|
iOldest = i;
|
||||||
uiTimeMin = m_astGameSlot[i].m_uiTime;
|
uiTimeMin = m_astGameSlot[i].m_uiTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iOldest >= 0)
|
if (iOldest >= 0) {
|
||||||
{
|
|
||||||
vOnSaveGame(iOldest + 1);
|
vOnSaveGame(iOldest + 1);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
vOnSaveGame(1);
|
vOnSaveGame(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,18 +225,14 @@ void Window::vOnSaveGame(int _iSlot)
|
||||||
vUpdateGameSlots();
|
vUpdateGameSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI)
|
void Window::vOnFilePauseToggled(Gtk::CheckMenuItem* _poCMI)
|
||||||
{
|
{
|
||||||
m_bPaused = _poCMI->get_active();
|
m_bPaused = _poCMI->get_active();
|
||||||
if (emulating)
|
if (emulating) {
|
||||||
{
|
if (m_bPaused) {
|
||||||
if (m_bPaused)
|
|
||||||
{
|
|
||||||
vStopEmu();
|
vStopEmu();
|
||||||
soundPause();
|
soundPause();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
vStartEmu();
|
vStartEmu();
|
||||||
soundResume();
|
soundResume();
|
||||||
}
|
}
|
||||||
|
@ -272,8 +241,7 @@ void Window::vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI)
|
||||||
|
|
||||||
void Window::vOnFileReset()
|
void Window::vOnFileReset()
|
||||||
{
|
{
|
||||||
if (emulating)
|
if (emulating) {
|
||||||
{
|
|
||||||
m_stEmulator.emuReset();
|
m_stEmulator.emuReset();
|
||||||
m_poFilePauseItem->set_active(false);
|
m_poFilePauseItem->set_active(false);
|
||||||
}
|
}
|
||||||
|
@ -283,8 +251,7 @@ void Window::vOnRecentFile()
|
||||||
{
|
{
|
||||||
Glib::ustring sURI = m_poRecentChooserMenu->get_current_uri();
|
Glib::ustring sURI = m_poRecentChooserMenu->get_current_uri();
|
||||||
|
|
||||||
if (!sURI.empty())
|
if (!sURI.empty()) {
|
||||||
{
|
|
||||||
std::string sFileName = Glib::filename_from_uri(sURI);
|
std::string sFileName = Glib::filename_from_uri(sURI);
|
||||||
bLoadROM(sFileName);
|
bLoadROM(sFileName);
|
||||||
}
|
}
|
||||||
|
@ -299,12 +266,9 @@ void Window::vOnFileScreenCapture()
|
||||||
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
|
||||||
|
|
||||||
if (sCaptureDir == "")
|
if (sCaptureDir == "") {
|
||||||
{
|
|
||||||
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
oDialog.set_current_folder(sCaptureDir);
|
oDialog.set_current_folder(sCaptureDir);
|
||||||
oDialog.add_shortcut_folder(sCaptureDir);
|
oDialog.add_shortcut_folder(sCaptureDir);
|
||||||
}
|
}
|
||||||
|
@ -322,31 +286,26 @@ void Window::vOnFileScreenCapture()
|
||||||
|
|
||||||
oDialog.add_filter(oPngFilter);
|
oDialog.add_filter(oPngFilter);
|
||||||
|
|
||||||
while (oDialog.run() == Gtk::RESPONSE_OK)
|
while (oDialog.run() == Gtk::RESPONSE_OK) {
|
||||||
{
|
|
||||||
Glib::ustring sFile = oDialog.get_filename();
|
Glib::ustring sFile = oDialog.get_filename();
|
||||||
Glib::ustring sExt = ".png";
|
Glib::ustring sExt = ".png";
|
||||||
|
|
||||||
if (! bHasSuffix(sFile, sExt, false))
|
if (!bHasSuffix(sFile, sExt, false)) {
|
||||||
{
|
|
||||||
sFile += sExt;
|
sFile += sExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS))
|
if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) {
|
||||||
{
|
|
||||||
Gtk::MessageDialog oConfirmDialog(*this,
|
Gtk::MessageDialog oConfirmDialog(*this,
|
||||||
_("File already exists. Overwrite it?"),
|
_("File already exists. Overwrite it?"),
|
||||||
false,
|
false,
|
||||||
Gtk::MESSAGE_QUESTION,
|
Gtk::MESSAGE_QUESTION,
|
||||||
Gtk::BUTTONS_YES_NO);
|
Gtk::BUTTONS_YES_NO);
|
||||||
if (oConfirmDialog.run() != Gtk::RESPONSE_YES)
|
if (oConfirmDialog.run() != Gtk::RESPONSE_YES) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_stEmulator.emuWritePNG(sFile.c_str()))
|
if (m_stEmulator.emuWritePNG(sFile.c_str())) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,8 +313,7 @@ void Window::vOnFileScreenCapture()
|
||||||
|
|
||||||
void Window::vOnFileClose()
|
void Window::vOnFileClose()
|
||||||
{
|
{
|
||||||
if (m_eCartridge != CartridgeNone)
|
if (m_eCartridge != CartridgeNone) {
|
||||||
{
|
|
||||||
soundPause();
|
soundPause();
|
||||||
vStopEmu();
|
vStopEmu();
|
||||||
vSetDefaultTitle();
|
vSetDefaultTitle();
|
||||||
|
@ -375,10 +333,9 @@ void Window::vOnFileClose()
|
||||||
|
|
||||||
vUpdateGameSlots();
|
vUpdateGameSlots();
|
||||||
|
|
||||||
for (std::list<Gtk::Widget *>::iterator it = m_listSensitiveWhenPlaying.begin();
|
for (std::list<Gtk::Widget*>::iterator it = m_listSensitiveWhenPlaying.begin();
|
||||||
it != m_listSensitiveWhenPlaying.end();
|
it != m_listSensitiveWhenPlaying.end();
|
||||||
it++)
|
it++) {
|
||||||
{
|
|
||||||
(*it)->set_sensitive(false);
|
(*it)->set_sensitive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +375,7 @@ void Window::vOnDisplayConfigure()
|
||||||
std::string sUiFile = sGetUiFilePath("display.ui");
|
std::string sUiFile = sGetUiFilePath("display.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
DisplayConfigDialog * poDialog = 0;
|
DisplayConfigDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("DisplayConfigDialog", poDialog);
|
poBuilder->get_widget_derived("DisplayConfigDialog", poDialog);
|
||||||
poDialog->vSetConfig(m_poDisplayConfig, this);
|
poDialog->vSetConfig(m_poDisplayConfig, this);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
|
@ -431,7 +388,7 @@ void Window::vOnSoundConfigure()
|
||||||
std::string sUiFile = sGetUiFilePath("sound.ui");
|
std::string sUiFile = sGetUiFilePath("sound.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
SoundConfigDialog * poDialog = 0;
|
SoundConfigDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("SoundConfigDialog", poDialog);
|
poBuilder->get_widget_derived("SoundConfigDialog", poDialog);
|
||||||
poDialog->vSetConfig(m_poSoundConfig, this);
|
poDialog->vSetConfig(m_poSoundConfig, this);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
|
@ -444,7 +401,7 @@ void Window::vOnGameBoyConfigure()
|
||||||
std::string sUiFile = sGetUiFilePath("gameboy.ui");
|
std::string sUiFile = sGetUiFilePath("gameboy.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
GameBoyConfigDialog * poDialog = 0;
|
GameBoyConfigDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("GameBoyConfigDialog", poDialog);
|
poBuilder->get_widget_derived("GameBoyConfigDialog", poDialog);
|
||||||
poDialog->vSetConfig(m_poCoreConfig, this);
|
poDialog->vSetConfig(m_poCoreConfig, this);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
|
@ -457,7 +414,7 @@ void Window::vOnGameBoyAdvanceConfigure()
|
||||||
std::string sUiFile = sGetUiFilePath("gameboyadvance.ui");
|
std::string sUiFile = sGetUiFilePath("gameboyadvance.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
GameBoyAdvanceConfigDialog * poDialog = 0;
|
GameBoyAdvanceConfigDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("GameBoyAdvanceConfigDialog", poDialog);
|
poBuilder->get_widget_derived("GameBoyAdvanceConfigDialog", poDialog);
|
||||||
poDialog->vSetConfig(m_poCoreConfig, this);
|
poDialog->vSetConfig(m_poCoreConfig, this);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
|
@ -470,7 +427,7 @@ void Window::vOnGeneralConfigure()
|
||||||
std::string sUiFile = sGetUiFilePath("preferences.ui");
|
std::string sUiFile = sGetUiFilePath("preferences.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
PreferencesDialog * poDialog = 0;
|
PreferencesDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("PreferencesDialog", poDialog);
|
poBuilder->get_widget_derived("PreferencesDialog", poDialog);
|
||||||
poDialog->vSetConfig(m_poCoreConfig, this);
|
poDialog->vSetConfig(m_poCoreConfig, this);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
|
@ -480,24 +437,21 @@ void Window::vOnGeneralConfigure()
|
||||||
|
|
||||||
void Window::vOnCheatList()
|
void Window::vOnCheatList()
|
||||||
{
|
{
|
||||||
if (m_eCartridge == CartridgeGBA)
|
if (m_eCartridge == CartridgeGBA) {
|
||||||
{
|
|
||||||
std::string sUiFile = sGetUiFilePath("cheatlist.ui");
|
std::string sUiFile = sGetUiFilePath("cheatlist.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
GameBoyAdvanceCheatListDialog * poDialog = 0;
|
GameBoyAdvanceCheatListDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("CheatListDialog", poDialog);
|
poBuilder->get_widget_derived("CheatListDialog", poDialog);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
poDialog->vSetWindow(this);
|
poDialog->vSetWindow(this);
|
||||||
poDialog->run();
|
poDialog->run();
|
||||||
poDialog->hide();
|
poDialog->hide();
|
||||||
}
|
} else if (m_eCartridge == CartridgeGB) {
|
||||||
else if (m_eCartridge == CartridgeGB)
|
|
||||||
{
|
|
||||||
std::string sUiFile = sGetUiFilePath("cheatlist.ui");
|
std::string sUiFile = sGetUiFilePath("cheatlist.ui");
|
||||||
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
Glib::RefPtr<Gtk::Builder> poBuilder = Gtk::Builder::create_from_file(sUiFile);
|
||||||
|
|
||||||
GameBoyCheatListDialog * poDialog = 0;
|
GameBoyCheatListDialog* poDialog = 0;
|
||||||
poBuilder->get_widget_derived("CheatListDialog", poDialog);
|
poBuilder->get_widget_derived("CheatListDialog", poDialog);
|
||||||
poDialog->set_transient_for(*this);
|
poDialog->set_transient_for(*this);
|
||||||
poDialog->vSetWindow(this);
|
poDialog->vSetWindow(this);
|
||||||
|
@ -506,12 +460,11 @@ void Window::vOnCheatList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::vOnCheatDisableToggled(Gtk::CheckMenuItem * _poCMI)
|
void Window::vOnCheatDisableToggled(Gtk::CheckMenuItem* _poCMI)
|
||||||
{
|
{
|
||||||
if (m_eCartridge == CartridgeGB) {
|
if (m_eCartridge == CartridgeGB) {
|
||||||
cheatsEnabled = !cheatsEnabled;
|
cheatsEnabled = !cheatsEnabled;
|
||||||
}
|
} else if (m_eCartridge == CartridgeGBA) {
|
||||||
else if (m_eCartridge == CartridgeGBA) {
|
|
||||||
cheatsEnabled = !cheatsEnabled;
|
cheatsEnabled = !cheatsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,13 +521,13 @@ void Window::vOnHelpAbout()
|
||||||
|
|
||||||
bool Window::bOnEmuRewind()
|
bool Window::bOnEmuRewind()
|
||||||
{
|
{
|
||||||
if( !m_rewind_load_q.empty() ) {
|
if (!m_rewind_load_q.empty()) {
|
||||||
// load a rewind save state
|
// load a rewind save state
|
||||||
char *psavestate = m_rewind_load_q.front();
|
char* psavestate = m_rewind_load_q.front();
|
||||||
//memset(m_psavestate, 0x0, SZSTATE);
|
//memset(m_psavestate, 0x0, SZSTATE);
|
||||||
long szstate = *((long*)psavestate); // first there is size
|
long szstate = *((long*)psavestate); // first there is size
|
||||||
//memmove(m_psavestate, psavestate+sizeof(szstate), szstate-sizeof(szstate));
|
//memmove(m_psavestate, psavestate+sizeof(szstate), szstate-sizeof(szstate));
|
||||||
if (m_stEmulator.emuReadMemState(psavestate+sizeof(szstate), szstate)) {
|
if (m_stEmulator.emuReadMemState(psavestate + sizeof(szstate), szstate)) {
|
||||||
// the save state is now used so delete it and we have more space
|
// the save state is now used so delete it and we have more space
|
||||||
m_rewind_load_q.pop_front();
|
m_rewind_load_q.pop_front();
|
||||||
delete[] psavestate;
|
delete[] psavestate;
|
||||||
|
@ -587,9 +540,10 @@ bool Window::bOnEmuRewind()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::bOnEmuSaveStateRewind() {
|
bool Window::bOnEmuSaveStateRewind()
|
||||||
|
{
|
||||||
// check if we're disabled
|
// check if we're disabled
|
||||||
char *psavestate;
|
char* psavestate;
|
||||||
if (m_state_count_max == 0u) {
|
if (m_state_count_max == 0u) {
|
||||||
return false;
|
return false;
|
||||||
} else if (m_rewind_load_q.size() >= m_state_count_max) { // check if we can reserve more memory for save states
|
} else if (m_rewind_load_q.size() >= m_state_count_max) { // check if we can reserve more memory for save states
|
||||||
|
@ -604,11 +558,11 @@ bool Window::bOnEmuSaveStateRewind() {
|
||||||
if (m_stEmulator.emuWriteMemState(m_psavestate, SZSTATE, resize)) {
|
if (m_stEmulator.emuWriteMemState(m_psavestate, SZSTATE, resize)) {
|
||||||
/*resize*=2; // if tell does not return correct size this leverage factor is needed
|
/*resize*=2; // if tell does not return correct size this leverage factor is needed
|
||||||
if (resize > SZSTATE) resize = SZSTATE;*/
|
if (resize > SZSTATE) resize = SZSTATE;*/
|
||||||
g_assert( resize <= (int) SZSTATE );
|
g_assert(resize <= (int)SZSTATE);
|
||||||
resize+=(sizeof(resize)*8); // some leverage
|
resize += (sizeof(resize) * 8); // some leverage
|
||||||
psavestate = new char[resize];
|
psavestate = new char[resize];
|
||||||
memmove(psavestate, &resize, sizeof(resize)); // pack size first
|
memmove(psavestate, &resize, sizeof(resize)); // pack size first
|
||||||
memmove(psavestate+sizeof(resize), m_psavestate, resize-sizeof(resize)); // then actual save data
|
memmove(psavestate + sizeof(resize), m_psavestate, resize - sizeof(resize)); // then actual save data
|
||||||
//printf("Wrote %p (%li bytes %i %i)\n", psavestate, resize, *((long*)psavestate), sizeof(resize));
|
//printf("Wrote %p (%li bytes %i %i)\n", psavestate, resize, *((long*)psavestate), sizeof(resize));
|
||||||
m_rewind_load_q.push_front(psavestate);
|
m_rewind_load_q.push_front(psavestate);
|
||||||
return true;
|
return true;
|
||||||
|
@ -625,33 +579,30 @@ bool Window::bOnEmuIdle()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::on_focus_in_event(GdkEventFocus * _pstEvent)
|
bool Window::on_focus_in_event(GdkEventFocus* _pstEvent)
|
||||||
{
|
{
|
||||||
if (emulating && !m_bPaused)
|
if (emulating && !m_bPaused) {
|
||||||
{
|
|
||||||
vStartEmu();
|
vStartEmu();
|
||||||
soundResume();
|
soundResume();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::on_focus_out_event(GdkEventFocus * _pstEvent)
|
bool Window::on_focus_out_event(GdkEventFocus* _pstEvent)
|
||||||
{
|
{
|
||||||
if (emulating
|
if (emulating
|
||||||
&& !m_bPaused
|
&& !m_bPaused
|
||||||
&& m_poCoreConfig->oGetKey<bool>("pause_when_inactive"))
|
&& m_poCoreConfig->oGetKey<bool>("pause_when_inactive")) {
|
||||||
{
|
|
||||||
vStopEmu();
|
vStopEmu();
|
||||||
soundPause();
|
soundPause();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
bool Window::on_key_press_event(GdkEventKey* _pstEvent)
|
||||||
{
|
{
|
||||||
// The menu accelerators are disabled when it is hidden
|
// The menu accelerators are disabled when it is hidden
|
||||||
if (_pstEvent->keyval == GDK_KEY_F11 && !m_poMenuBar->is_visible())
|
if (_pstEvent->keyval == GDK_KEY_F11 && !m_poMenuBar->is_visible()) {
|
||||||
{
|
|
||||||
vToggleFullscreen();
|
vToggleFullscreen();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -659,7 +610,8 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
||||||
// Rewind key CTRL+B
|
// Rewind key CTRL+B
|
||||||
if (m_state_count_max > 0u && (_pstEvent->state & GDK_CONTROL_MASK) && _pstEvent->keyval == GDK_KEY_b) {
|
if (m_state_count_max > 0u && (_pstEvent->state & GDK_CONTROL_MASK) && _pstEvent->keyval == GDK_KEY_b) {
|
||||||
// disable saves first and then connect new handler
|
// disable saves first and then connect new handler
|
||||||
if (m_oEmuRewindSig.connected()) m_oEmuRewindSig.disconnect();
|
if (m_oEmuRewindSig.connected())
|
||||||
|
m_oEmuRewindSig.disconnect();
|
||||||
m_state_count_max = 0u;
|
m_state_count_max = 0u;
|
||||||
//return this->bOnEmuRewind();
|
//return this->bOnEmuRewind();
|
||||||
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuRewind),
|
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuRewind),
|
||||||
|
@ -680,12 +632,13 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
||||||
return Gtk::Window::on_key_press_event(_pstEvent);
|
return Gtk::Window::on_key_press_event(_pstEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::on_key_release_event(GdkEventKey * _pstEvent)
|
bool Window::on_key_release_event(GdkEventKey* _pstEvent)
|
||||||
{
|
{
|
||||||
// Rewind key CTRL+B
|
// Rewind key CTRL+B
|
||||||
if (_pstEvent->keyval == GDK_KEY_b /*&& !(_pstEvent->state & GDK_CONTROL_MASK)*/) {
|
if (_pstEvent->keyval == GDK_KEY_b /*&& !(_pstEvent->state & GDK_CONTROL_MASK)*/) {
|
||||||
// connect save handler back
|
// connect save handler back
|
||||||
if (m_oEmuRewindSig.connected()) m_oEmuRewindSig.disconnect();
|
if (m_oEmuRewindSig.connected())
|
||||||
|
m_oEmuRewindSig.disconnect();
|
||||||
m_state_count_max = m_poCoreConfig->oGetKey<unsigned short>("rewind_count_max");
|
m_state_count_max = m_poCoreConfig->oGetKey<unsigned short>("rewind_count_max");
|
||||||
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuSaveStateRewind), m_rewind_interval);
|
m_oEmuRewindSig = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Window::bOnEmuSaveStateRewind), m_rewind_interval);
|
||||||
return true;
|
return true;
|
||||||
|
@ -701,14 +654,12 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent)
|
||||||
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
|
event.key.keysym.sym = (SDL_Keycode)_pstEvent->keyval;
|
||||||
inputProcessSDLEvent(event);
|
inputProcessSDLEvent(event);
|
||||||
|
|
||||||
|
|
||||||
return Gtk::Window::on_key_release_event(_pstEvent);
|
return Gtk::Window::on_key_release_event(_pstEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::on_window_state_event(GdkEventWindowState* _pstEvent)
|
bool Window::on_window_state_event(GdkEventWindowState* _pstEvent)
|
||||||
{
|
{
|
||||||
if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
|
||||||
{
|
|
||||||
m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
|
m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,7 +24,7 @@ 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;
|
||||||
|
@ -33,7 +33,6 @@ void SoundRetro::write(u16 * finalWave, int length)
|
||||||
g_audio_frames += frames;
|
g_audio_frames += frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SoundRetro::init(long sampleRate)
|
bool SoundRetro::init(long sampleRate)
|
||||||
{
|
{
|
||||||
g_audio_frames = 0;
|
g_audio_frames = 0;
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
|
|
||||||
#include "../common/SoundDriver.h"
|
#include "../common/SoundDriver.h"
|
||||||
|
|
||||||
class SoundRetro : public SoundDriver
|
class SoundRetro : public SoundDriver {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
SoundRetro();
|
SoundRetro();
|
||||||
virtual ~SoundRetro();
|
virtual ~SoundRetro();
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ class SoundRetro : public SoundDriver
|
||||||
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,12 +27,12 @@ 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;
|
||||||
|
@ -40,32 +40,29 @@ void utilPutDword(u8 *p, u32 value)
|
||||||
*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) ||
|
|
||||||
(_stricmp(p, ".bin") == 0) ||
|
|
||||||
(_stricmp(p, ".elf") == 0))
|
|
||||||
return true;
|
return true;
|
||||||
if(_stricmp(p, ".mb") == 0) {
|
if (_stricmp(p, ".mb") == 0) {
|
||||||
cpuIsMultiBoot = true;
|
cpuIsMultiBoot = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,17 +72,13 @@ bool utilIsGBAImage(const char * file)
|
||||||
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) ||
|
|
||||||
(_stricmp(p, ".gbc") == 0) ||
|
|
||||||
(_stricmp(p, ".cgb") == 0) ||
|
|
||||||
(_stricmp(p, ".sgb") == 0))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,21 +87,21 @@ bool utilIsGBImage(const char * file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
@ -118,28 +111,26 @@ IMAGE_TYPE utilFindType(const char *file)
|
||||||
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"),
|
systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"),
|
||||||
"data");
|
"data");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -151,47 +142,47 @@ uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data,
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void utilGBAFindSave(const uint8_t *data, const int size)
|
void utilGBAFindSave(const uint8_t* data, const int size)
|
||||||
{
|
{
|
||||||
uint32_t *p = (uint32_t *)data;
|
uint32_t* p = (uint32_t*)data;
|
||||||
uint32_t *end = (uint32_t *)(data + size);
|
uint32_t* end = (uint32_t*)(data + size);
|
||||||
int saveType = 0;
|
int saveType = 0;
|
||||||
int flashSize = 0x10000;
|
int flashSize = 0x10000;
|
||||||
bool rtcFound = false;
|
bool rtcFound = false;
|
||||||
|
|
||||||
while(p < end) {
|
while (p < end) {
|
||||||
uint32_t d = READ32LE(p);
|
uint32_t d = READ32LE(p);
|
||||||
|
|
||||||
if(d == 0x52504545) {
|
if (d == 0x52504545) {
|
||||||
if(memcmp(p, "EEPROM_", 7) == 0) {
|
if (memcmp(p, "EEPROM_", 7) == 0) {
|
||||||
if(saveType == 0)
|
if (saveType == 0)
|
||||||
saveType = 3;
|
saveType = 3;
|
||||||
}
|
}
|
||||||
} else if (d == 0x4D415253) {
|
} else if (d == 0x4D415253) {
|
||||||
if(memcmp(p, "SRAM_", 5) == 0) {
|
if (memcmp(p, "SRAM_", 5) == 0) {
|
||||||
if(saveType == 0)
|
if (saveType == 0)
|
||||||
saveType = 1;
|
saveType = 1;
|
||||||
}
|
}
|
||||||
} else if (d == 0x53414C46) {
|
} else if (d == 0x53414C46) {
|
||||||
if(memcmp(p, "FLASH1M_", 8) == 0) {
|
if (memcmp(p, "FLASH1M_", 8) == 0) {
|
||||||
if(saveType == 0) {
|
if (saveType == 0) {
|
||||||
saveType = 2;
|
saveType = 2;
|
||||||
flashSize = 0x20000;
|
flashSize = 0x20000;
|
||||||
}
|
}
|
||||||
} else if(memcmp(p, "FLASH", 5) == 0) {
|
} else if (memcmp(p, "FLASH", 5) == 0) {
|
||||||
if(saveType == 0) {
|
if (saveType == 0) {
|
||||||
saveType = 2;
|
saveType = 2;
|
||||||
flashSize = 0x10000;
|
flashSize = 0x10000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (d == 0x52494953) {
|
} else if (d == 0x52494953) {
|
||||||
if(memcmp(p, "SIIRTC_V", 8) == 0)
|
if (memcmp(p, "SIIRTC_V", 8) == 0)
|
||||||
rtcFound = true;
|
rtcFound = true;
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
// if no matches found, then set it to NONE
|
// if no matches found, then set it to NONE
|
||||||
if(saveType == 0) {
|
if (saveType == 0) {
|
||||||
saveType = 5;
|
saveType = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,66 +193,59 @@ void utilGBAFindSave(const uint8_t *data, const int size)
|
||||||
|
|
||||||
void utilUpdateSystemColorMaps(bool lcd)
|
void utilUpdateSystemColorMaps(bool lcd)
|
||||||
{
|
{
|
||||||
switch(systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 16:
|
case 16: {
|
||||||
{
|
for (int i = 0; i < 0x10000; i++) {
|
||||||
for(int i = 0; i < 0x10000; i++) {
|
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
|
||||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
|
||||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
|
||||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
|
||||||
}
|
}
|
||||||
if (lcd) gbafilter_pal(systemColorMap16, 0x10000);
|
if (lcd)
|
||||||
}
|
gbafilter_pal(systemColorMap16, 0x10000);
|
||||||
break;
|
} break;
|
||||||
case 24:
|
case 24:
|
||||||
case 32:
|
case 32: {
|
||||||
{
|
for (int i = 0; i < 0x10000; i++) {
|
||||||
for(int i = 0; i < 0x10000; i++) {
|
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift);
|
||||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
|
||||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
|
||||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
|
||||||
}
|
}
|
||||||
if (lcd) gbafilter_pal32(systemColorMap32, 0x10000);
|
if (lcd)
|
||||||
}
|
gbafilter_pal32(systemColorMap32, 0x10000);
|
||||||
break;
|
} 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));
|
||||||
|
@ -269,16 +253,15 @@ int utilReadIntMem(const uint8_t *& data)
|
||||||
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,9 +8,13 @@
|
||||||
#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:
|
||||||
|
@ -27,7 +31,7 @@ static const char *save_type_to_string(enum save_type 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)
|
||||||
|
@ -37,7 +41,7 @@ static bool scan_section(const uint8_t *data, unsigned size)
|
||||||
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;
|
||||||
|
@ -54,8 +58,7 @@ static enum save_type detect_save_type(const uint8_t *data, unsigned size)
|
||||||
if (scan_section(data, 0x20000))
|
if (scan_section(data, 0x20000))
|
||||||
return FLASH_128K;
|
return FLASH_128K;
|
||||||
|
|
||||||
if (scan_section(data + 0x20000, 512) &&
|
if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512))
|
||||||
!scan_section(data + 0x20000 + 512, 0x20000 - 512))
|
|
||||||
return EEPROM_512B;
|
return EEPROM_512B;
|
||||||
if (scan_section(data + 0x20000, 0x2000))
|
if (scan_section(data + 0x20000, 0x2000))
|
||||||
return EEPROM_8K;
|
return EEPROM_8K;
|
||||||
|
@ -64,9 +67,9 @@ static enum save_type detect_save_type(const uint8_t *data, unsigned size)
|
||||||
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) {
|
||||||
|
@ -98,7 +101,7 @@ static void dump_srm(FILE *file, const uint8_t *data, enum save_type type)
|
||||||
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:
|
||||||
|
@ -124,14 +127,14 @@ static void dump_sav(FILE *file, const uint8_t *data, enum save_type type)
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -141,7 +144,7 @@ int main(int argc, char *argv[])
|
||||||
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;
|
||||||
|
@ -150,9 +153,9 @@ int main(int argc, char *argv[])
|
||||||
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';
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "libretro.h"
|
|
||||||
#include "SoundRetro.h"
|
#include "SoundRetro.h"
|
||||||
|
#include "libretro.h"
|
||||||
|
|
||||||
#include "../Util.h"
|
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
#include "../Util.h"
|
||||||
|
#include "../apu/Blip_Buffer.h"
|
||||||
|
#include "../apu/Gb_Apu.h"
|
||||||
|
#include "../apu/Gb_Oscs.h"
|
||||||
#include "../common/Port.h"
|
#include "../common/Port.h"
|
||||||
#include "../common/Types.h"
|
#include "../common/Types.h"
|
||||||
#include "../gba/RTC.h"
|
|
||||||
#include "../gba/GBAGfx.h"
|
|
||||||
#include "../gba/bios.h"
|
|
||||||
#include "../gba/Flash.h"
|
|
||||||
#include "../gba/EEprom.h"
|
|
||||||
#include "../gba/Sound.h"
|
|
||||||
#include "../apu/Blip_Buffer.h"
|
|
||||||
#include "../apu/Gb_Oscs.h"
|
|
||||||
#include "../apu/Gb_Apu.h"
|
|
||||||
#include "../gba/Globals.h"
|
|
||||||
#include "../gba/Cheats.h"
|
#include "../gba/Cheats.h"
|
||||||
|
#include "../gba/EEprom.h"
|
||||||
|
#include "../gba/Flash.h"
|
||||||
|
#include "../gba/GBAGfx.h"
|
||||||
|
#include "../gba/Globals.h"
|
||||||
|
#include "../gba/RTC.h"
|
||||||
|
#include "../gba/Sound.h"
|
||||||
|
#include "../gba/bios.h"
|
||||||
|
|
||||||
#define RETRO_DEVICE_GBA RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
|
#define RETRO_DEVICE_GBA RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
|
||||||
#define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
#define RETRO_DEVICE_GBA_ALT1 RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1)
|
||||||
|
@ -39,7 +39,7 @@ extern uint64_t joy;
|
||||||
static bool can_dupe;
|
static bool can_dupe;
|
||||||
unsigned device_type = 0;
|
unsigned device_type = 0;
|
||||||
int emulating = 0;
|
int emulating = 0;
|
||||||
static int controller_layout[2] = {0,0};
|
static int controller_layout[2] = { 0, 0 };
|
||||||
|
|
||||||
uint8_t libretro_save_buf[0x20000 + 0x2000]; /* Workaround for broken-by-design GBA save semantics. */
|
uint8_t libretro_save_buf[0x20000 + 0x2000]; /* Workaround for broken-by-design GBA save semantics. */
|
||||||
|
|
||||||
|
@ -63,10 +63,10 @@ int systemSpeed = 0;
|
||||||
u64 startTime = 0;
|
u64 startTime = 0;
|
||||||
u32 renderedFrames = 0;
|
u32 renderedFrames = 0;
|
||||||
|
|
||||||
void (*dbgOutput)(const char *s, u32 addr);
|
void (*dbgOutput)(const char* s, u32 addr);
|
||||||
void (*dbgSignal)(int sig, int number);
|
void (*dbgSignal)(int sig, int number);
|
||||||
|
|
||||||
void *retro_get_memory_data(unsigned id)
|
void* retro_get_memory_data(unsigned id)
|
||||||
{
|
{
|
||||||
if (id == RETRO_MEMORY_SAVE_RAM)
|
if (id == RETRO_MEMORY_SAVE_RAM)
|
||||||
return libretro_save_buf;
|
return libretro_save_buf;
|
||||||
|
@ -82,7 +82,7 @@ size_t retro_get_memory_size(unsigned id)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool scan_area(const uint8_t *data, unsigned size)
|
static bool scan_area(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)
|
||||||
|
@ -93,36 +93,25 @@ static bool scan_area(const uint8_t *data, unsigned size)
|
||||||
|
|
||||||
static void adjust_save_ram()
|
static void adjust_save_ram()
|
||||||
{
|
{
|
||||||
if (scan_area(libretro_save_buf, 512) &&
|
if (scan_area(libretro_save_buf, 512) && !scan_area(libretro_save_buf + 512, sizeof(libretro_save_buf) - 512)) {
|
||||||
!scan_area(libretro_save_buf + 512, sizeof(libretro_save_buf) - 512))
|
|
||||||
{
|
|
||||||
libretro_save_size = 512;
|
libretro_save_size = 512;
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Detecting EEprom 8kbit\n");
|
log_cb(RETRO_LOG_INFO, "Detecting EEprom 8kbit\n");
|
||||||
}
|
} else if (scan_area(libretro_save_buf, 0x2000) && !scan_area(libretro_save_buf + 0x2000, sizeof(libretro_save_buf) - 0x2000)) {
|
||||||
else if (scan_area(libretro_save_buf, 0x2000) &&
|
|
||||||
!scan_area(libretro_save_buf + 0x2000, sizeof(libretro_save_buf) - 0x2000))
|
|
||||||
{
|
|
||||||
libretro_save_size = 0x2000;
|
libretro_save_size = 0x2000;
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Detecting EEprom 64kbit\n");
|
log_cb(RETRO_LOG_INFO, "Detecting EEprom 64kbit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (scan_area(libretro_save_buf, 0x10000) &&
|
else if (scan_area(libretro_save_buf, 0x10000) && !scan_area(libretro_save_buf + 0x10000, sizeof(libretro_save_buf) - 0x10000)) {
|
||||||
!scan_area(libretro_save_buf + 0x10000, sizeof(libretro_save_buf) - 0x10000))
|
|
||||||
{
|
|
||||||
libretro_save_size = 0x10000;
|
libretro_save_size = 0x10000;
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Detecting Flash 512kbit\n");
|
log_cb(RETRO_LOG_INFO, "Detecting Flash 512kbit\n");
|
||||||
}
|
} else if (scan_area(libretro_save_buf, 0x20000) && !scan_area(libretro_save_buf + 0x20000, sizeof(libretro_save_buf) - 0x20000)) {
|
||||||
else if (scan_area(libretro_save_buf, 0x20000) &&
|
|
||||||
!scan_area(libretro_save_buf + 0x20000, sizeof(libretro_save_buf) - 0x20000))
|
|
||||||
{
|
|
||||||
libretro_save_size = 0x20000;
|
libretro_save_size = 0x20000;
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Detecting Flash 1Mbit\n");
|
log_cb(RETRO_LOG_INFO, "Detecting Flash 1Mbit\n");
|
||||||
}
|
} else if (log_cb)
|
||||||
else if (log_cb)
|
|
||||||
log_cb(RETRO_LOG_INFO, "Did not detect any particular SRAM type.\n");
|
log_cb(RETRO_LOG_INFO, "Did not detect any particular SRAM type.\n");
|
||||||
|
|
||||||
if (libretro_save_size == 512 || libretro_save_size == 0x2000)
|
if (libretro_save_size == 512 || libretro_save_size == 0x2000)
|
||||||
|
@ -131,7 +120,6 @@ static void adjust_save_ram()
|
||||||
flashSaveMemory = libretro_save_buf;
|
flashSaveMemory = libretro_save_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned retro_api_version(void)
|
unsigned retro_api_version(void)
|
||||||
{
|
{
|
||||||
return RETRO_API_VERSION;
|
return RETRO_API_VERSION;
|
||||||
|
@ -143,7 +131,8 @@ void retro_set_video_refresh(retro_video_refresh_t cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_set_audio_sample(retro_audio_sample_t cb)
|
void retro_set_audio_sample(retro_audio_sample_t cb)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
|
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
|
||||||
{
|
{
|
||||||
|
@ -163,8 +152,7 @@ void retro_set_input_state(retro_input_state_t cb)
|
||||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||||
{
|
{
|
||||||
log_cb(RETRO_LOG_INFO, "Controller %d'\n", device);
|
log_cb(RETRO_LOG_INFO, "Controller %d'\n", device);
|
||||||
switch(device)
|
switch (device) {
|
||||||
{
|
|
||||||
|
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
case RETRO_DEVICE_GBA:
|
case RETRO_DEVICE_GBA:
|
||||||
|
@ -189,7 +177,6 @@ void retro_set_environment(retro_environment_t cb)
|
||||||
|
|
||||||
struct retro_variable variables[] = {
|
struct retro_variable variables[] = {
|
||||||
|
|
||||||
|
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -199,15 +186,13 @@ void retro_set_environment(retro_environment_t cb)
|
||||||
{ "Alt Joypad AB", RETRO_DEVICE_GBA_ALT2 },
|
{ "Alt Joypad AB", RETRO_DEVICE_GBA_ALT2 },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct retro_controller_info ports[] = {{ port_1, 4 },{ 0,0 }};
|
static const struct retro_controller_info ports[] = { { port_1, 4 }, { 0, 0 } };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
||||||
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_get_system_info(struct retro_system_info *info)
|
void retro_get_system_info(struct retro_system_info* info)
|
||||||
{
|
{
|
||||||
info->need_fullpath = false;
|
info->need_fullpath = false;
|
||||||
info->valid_extensions = "gba";
|
info->valid_extensions = "gba";
|
||||||
|
@ -216,7 +201,7 @@ void retro_get_system_info(struct retro_system_info *info)
|
||||||
info->block_extract = false;
|
info->block_extract = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_get_system_av_info(struct retro_system_av_info *info)
|
void retro_get_system_av_info(struct retro_system_av_info* info)
|
||||||
{
|
{
|
||||||
info->geometry.base_width = 240;
|
info->geometry.base_width = 240;
|
||||||
info->geometry.base_height = 160;
|
info->geometry.base_height = 160;
|
||||||
|
@ -239,11 +224,11 @@ void retro_init(void)
|
||||||
|
|
||||||
#ifdef FRONTEND_SUPPORTS_RGB565
|
#ifdef FRONTEND_SUPPORTS_RGB565
|
||||||
enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565;
|
enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565;
|
||||||
if(environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && log_cb)
|
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Frontend supports RGB565 - will use that instead of XRGB1555.\n");
|
log_cb(RETRO_LOG_INFO, "Frontend supports RGB565 - will use that instead of XRGB1555.\n");
|
||||||
#else
|
#else
|
||||||
enum retro_pixel_format rgb8888 = RETRO_PIXEL_FORMAT_XRGB8888;
|
enum retro_pixel_format rgb8888 = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||||
if(environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb8888) && log_cb)
|
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb8888) && log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Frontend supports XRGB8888 - will use that instead of XRGB1555.\n");
|
log_cb(RETRO_LOG_INFO, "Frontend supports XRGB8888 - will use that instead of XRGB1555.\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -262,113 +247,113 @@ typedef struct {
|
||||||
|
|
||||||
static const ini_t gbaover[256] = {
|
static const ini_t gbaover[256] = {
|
||||||
//romtitle, romid flash save rtc mirror bios
|
//romtitle, romid flash save rtc mirror bios
|
||||||
{"2 Games in 1 - Dragon Ball Z - The Legacy of Goku I & II (USA)", "BLFE", 0, 1, 0, 0, 0},
|
{ "2 Games in 1 - Dragon Ball Z - The Legacy of Goku I & II (USA)", "BLFE", 0, 1, 0, 0, 0 },
|
||||||
{"2 Games in 1 - Dragon Ball Z - Buu's Fury + Dragon Ball GT - Transformation (USA)", "BUFE", 0, 1, 0, 0, 0},
|
{ "2 Games in 1 - Dragon Ball Z - Buu's Fury + Dragon Ball GT - Transformation (USA)", "BUFE", 0, 1, 0, 0, 0 },
|
||||||
{"Boktai - The Sun Is in Your Hand (Europe)(En,Fr,De,Es,It)", "U3IP", 0, 0, 1, 0, 0},
|
{ "Boktai - The Sun Is in Your Hand (Europe)(En,Fr,De,Es,It)", "U3IP", 0, 0, 1, 0, 0 },
|
||||||
{"Boktai - The Sun Is in Your Hand (USA)", "U3IE", 0, 0, 1, 0, 0},
|
{ "Boktai - The Sun Is in Your Hand (USA)", "U3IE", 0, 0, 1, 0, 0 },
|
||||||
{"Boktai 2 - Solar Boy Django (USA)", "U32E", 0, 0, 1, 0, 0},
|
{ "Boktai 2 - Solar Boy Django (USA)", "U32E", 0, 0, 1, 0, 0 },
|
||||||
{"Boktai 2 - Solar Boy Django (Europe)(En,Fr,De,Es,It)", "U32P", 0, 0, 1, 0, 0},
|
{ "Boktai 2 - Solar Boy Django (Europe)(En,Fr,De,Es,It)", "U32P", 0, 0, 1, 0, 0 },
|
||||||
{"Bokura no Taiyou - Taiyou Action RPG (Japan)", "U3IJ", 0, 0, 1, 0, 0},
|
{ "Bokura no Taiyou - Taiyou Action RPG (Japan)", "U3IJ", 0, 0, 1, 0, 0 },
|
||||||
{"Card e-Reader+ (Japan)", "PSAJ", 131072, 0, 0, 0, 0},
|
{ "Card e-Reader+ (Japan)", "PSAJ", 131072, 0, 0, 0, 0 },
|
||||||
{"Classic NES Series - Bomberman (USA, Europe)", "FBME", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Bomberman (USA, Europe)", "FBME", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Castlevania (USA, Europe)", "FADE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Castlevania (USA, Europe)", "FADE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Donkey Kong (USA, Europe)", "FDKE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Donkey Kong (USA, Europe)", "FDKE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Dr. Mario (USA, Europe)", "FDME", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Dr. Mario (USA, Europe)", "FDME", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Excitebike (USA, Europe)", "FEBE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Excitebike (USA, Europe)", "FEBE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Legend of Zelda (USA, Europe)", "FZLE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Legend of Zelda (USA, Europe)", "FZLE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Ice Climber (USA, Europe)", "FICE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Ice Climber (USA, Europe)", "FICE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Metroid (USA, Europe)", "FMRE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Metroid (USA, Europe)", "FMRE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Pac-Man (USA, Europe)", "FP7E", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Pac-Man (USA, Europe)", "FP7E", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Super Mario Bros. (USA, Europe)", "FSME", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Super Mario Bros. (USA, Europe)", "FSME", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Xevious (USA, Europe)", "FXVE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Xevious (USA, Europe)", "FXVE", 0, 1, 0, 1, 0 },
|
||||||
{"Classic NES Series - Zelda II - The Adventure of Link (USA, Europe)", "FLBE", 0, 1, 0, 1, 0},
|
{ "Classic NES Series - Zelda II - The Adventure of Link (USA, Europe)", "FLBE", 0, 1, 0, 1, 0 },
|
||||||
{"Digi Communication 2 - Datou! Black Gemagema Dan (Japan)", "BDKJ", 0, 1, 0, 0, 0},
|
{ "Digi Communication 2 - Datou! Black Gemagema Dan (Japan)", "BDKJ", 0, 1, 0, 0, 0 },
|
||||||
{"e-Reader (USA)", "PSAE", 131072, 0, 0, 0, 0},
|
{ "e-Reader (USA)", "PSAE", 131072, 0, 0, 0, 0 },
|
||||||
{"Dragon Ball GT - Transformation (USA)", "BT4E", 0, 1, 0, 0, 0},
|
{ "Dragon Ball GT - Transformation (USA)", "BT4E", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - Buu's Fury (USA)", "BG3E", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - Buu's Fury (USA)", "BG3E", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - Taiketsu (Europe)(En,Fr,De,Es,It)", "BDBP", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - Taiketsu (Europe)(En,Fr,De,Es,It)", "BDBP", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - Taiketsu (USA)", "BDBE", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - Taiketsu (USA)", "BDBE", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - The Legacy of Goku II International (Japan)", "ALFJ", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - The Legacy of Goku II International (Japan)", "ALFJ", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - The Legacy of Goku II (Europe)(En,Fr,De,Es,It)", "ALFP", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - The Legacy of Goku II (Europe)(En,Fr,De,Es,It)", "ALFP", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - The Legacy of Goku II (USA)", "ALFE", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - The Legacy of Goku II (USA)", "ALFE", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - The Legacy Of Goku (Europe)(En,Fr,De,Es,It)", "ALGP", 0, 1, 0, 0, 0},
|
{ "Dragon Ball Z - The Legacy Of Goku (Europe)(En,Fr,De,Es,It)", "ALGP", 0, 1, 0, 0, 0 },
|
||||||
{"Dragon Ball Z - The Legacy of Goku (USA)", "ALGE", 131072, 1, 0, 0, 0},
|
{ "Dragon Ball Z - The Legacy of Goku (USA)", "ALGE", 131072, 1, 0, 0, 0 },
|
||||||
{"F-Zero - Climax (Japan)", "BFTJ", 131072, 0, 0, 0, 0},
|
{ "F-Zero - Climax (Japan)", "BFTJ", 131072, 0, 0, 0, 0 },
|
||||||
{"Famicom Mini Vol. 01 - Super Mario Bros. (Japan)", "FMBJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 01 - Super Mario Bros. (Japan)", "FMBJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 12 - Clu Clu Land (Japan)", "FCLJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 12 - Clu Clu Land (Japan)", "FCLJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 13 - Balloon Fight (Japan)", "FBFJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 13 - Balloon Fight (Japan)", "FBFJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 14 - Wrecking Crew (Japan)", "FWCJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 14 - Wrecking Crew (Japan)", "FWCJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 15 - Dr. Mario (Japan)", "FDMJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 15 - Dr. Mario (Japan)", "FDMJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 16 - Dig Dug (Japan)", "FTBJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 16 - Dig Dug (Japan)", "FTBJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 17 - Takahashi Meijin no Boukenjima (Japan)", "FTBJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 17 - Takahashi Meijin no Boukenjima (Japan)", "FTBJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 18 - Makaimura (Japan)", "FMKJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 18 - Makaimura (Japan)", "FMKJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 19 - Twin Bee (Japan)", "FTWJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 19 - Twin Bee (Japan)", "FTWJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 20 - Ganbare Goemon! Karakuri Douchuu (Japan)", "FGGJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 20 - Ganbare Goemon! Karakuri Douchuu (Japan)", "FGGJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 21 - Super Mario Bros. 2 (Japan)", "FM2J", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 21 - Super Mario Bros. 2 (Japan)", "FM2J", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 22 - Nazo no Murasame Jou (Japan)", "FNMJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 22 - Nazo no Murasame Jou (Japan)", "FNMJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 23 - Metroid (Japan)", "FMRJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 23 - Metroid (Japan)", "FMRJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 24 - Hikari Shinwa - Palthena no Kagami (Japan)", "FPTJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 24 - Hikari Shinwa - Palthena no Kagami (Japan)", "FPTJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 25 - The Legend of Zelda 2 - Link no Bouken (Japan)","FLBJ",0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 25 - The Legend of Zelda 2 - Link no Bouken (Japan)", "FLBJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 26 - Famicom Mukashi Banashi - Shin Onigashima - Zen Kou Hen (Japan)","FFMJ",0,1,0, 1, 0},
|
{ "Famicom Mini Vol. 26 - Famicom Mukashi Banashi - Shin Onigashima - Zen Kou Hen (Japan)", "FFMJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 27 - Famicom Tantei Club - Kieta Koukeisha - Zen Kou Hen (Japan)","FTKJ",0,1,0, 1, 0},
|
{ "Famicom Mini Vol. 27 - Famicom Tantei Club - Kieta Koukeisha - Zen Kou Hen (Japan)", "FTKJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 28 - Famicom Tantei Club Part II - Ushiro ni Tatsu Shoujo - Zen Kou Hen (Japan)","FTUJ",0,1,0,1,0},
|
{ "Famicom Mini Vol. 28 - Famicom Tantei Club Part II - Ushiro ni Tatsu Shoujo - Zen Kou Hen (Japan)", "FTUJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 29 - Akumajou Dracula (Japan)", "FADJ", 0, 1, 0, 1, 0},
|
{ "Famicom Mini Vol. 29 - Akumajou Dracula (Japan)", "FADJ", 0, 1, 0, 1, 0 },
|
||||||
{"Famicom Mini Vol. 30 - SD Gundam World - Gachapon Senshi Scramble Wars (Japan)","FSDJ",0,1, 0, 1, 0},
|
{ "Famicom Mini Vol. 30 - SD Gundam World - Gachapon Senshi Scramble Wars (Japan)", "FSDJ", 0, 1, 0, 1, 0 },
|
||||||
{"Game Boy Wars Advance 1+2 (Japan)", "BGWJ", 131072, 0, 0, 0, 0},
|
{ "Game Boy Wars Advance 1+2 (Japan)", "BGWJ", 131072, 0, 0, 0, 0 },
|
||||||
{"Golden Sun - The Lost Age (USA)", "AGFE", 65536, 0, 0, 1, 0},
|
{ "Golden Sun - The Lost Age (USA)", "AGFE", 65536, 0, 0, 1, 0 },
|
||||||
{"Golden Sun (USA)", "AGSE", 65536, 0, 0, 1, 0},
|
{ "Golden Sun (USA)", "AGSE", 65536, 0, 0, 1, 0 },
|
||||||
{"Koro Koro Puzzle - Happy Panechu! (Japan)", "KHPJ", 0, 4, 0, 0, 0},
|
{ "Koro Koro Puzzle - Happy Panechu! (Japan)", "KHPJ", 0, 4, 0, 0, 0 },
|
||||||
{"Mario vs. Donkey Kong (Europe)", "BM5P", 0, 3, 0, 0, 0},
|
{ "Mario vs. Donkey Kong (Europe)", "BM5P", 0, 3, 0, 0, 0 },
|
||||||
{"Pocket Monsters - Emerald (Japan)", "BPEJ", 131072, 0, 1, 0, 0},
|
{ "Pocket Monsters - Emerald (Japan)", "BPEJ", 131072, 0, 1, 0, 0 },
|
||||||
{"Pocket Monsters - Fire Red (Japan)", "BPRJ", 131072, 0, 0, 0, 0},
|
{ "Pocket Monsters - Fire Red (Japan)", "BPRJ", 131072, 0, 0, 0, 0 },
|
||||||
{"Pocket Monsters - Leaf Green (Japan)", "BPGJ", 131072, 0, 0, 0, 0},
|
{ "Pocket Monsters - Leaf Green (Japan)", "BPGJ", 131072, 0, 0, 0, 0 },
|
||||||
{"Pocket Monsters - Ruby (Japan)", "AXVJ", 131072, 0, 1, 0, 0},
|
{ "Pocket Monsters - Ruby (Japan)", "AXVJ", 131072, 0, 1, 0, 0 },
|
||||||
{"Pocket Monsters - Sapphire (Japan)", "AXPJ", 131072, 0, 1, 0, 0},
|
{ "Pocket Monsters - Sapphire (Japan)", "AXPJ", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon Mystery Dungeon - Red Rescue Team (USA, Australia)", "B24E", 131072, 0, 0, 0, 0},
|
{ "Pokemon Mystery Dungeon - Red Rescue Team (USA, Australia)", "B24E", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon Mystery Dungeon - Red Rescue Team (En,Fr,De,Es,It)", "B24P", 131072, 0, 0, 0, 0},
|
{ "Pokemon Mystery Dungeon - Red Rescue Team (En,Fr,De,Es,It)", "B24P", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Blattgruene Edition (Germany)", "BPGD", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Blattgruene Edition (Germany)", "BPGD", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Edicion Rubi (Spain)", "AXVS", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Edicion Rubi (Spain)", "AXVS", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Edicion Esmeralda (Spain)", "BPES", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Edicion Esmeralda (Spain)", "BPES", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Edicion Rojo Fuego (Spain)", "BPRS", 131072, 1, 0, 0, 0},
|
{ "Pokemon - Edicion Rojo Fuego (Spain)", "BPRS", 131072, 1, 0, 0, 0 },
|
||||||
{"Pokemon - Edicion Verde Hoja (Spain)", "BPGS", 131072, 1, 0, 0, 0},
|
{ "Pokemon - Edicion Verde Hoja (Spain)", "BPGS", 131072, 1, 0, 0, 0 },
|
||||||
{"Pokemon - Eidicion Zafiro (Spain)", "AXPS", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Eidicion Zafiro (Spain)", "AXPS", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Emerald Version (USA, Europe)", "BPEE", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Emerald Version (USA, Europe)", "BPEE", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Feuerrote Edition (Germany)", "BPRD", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Feuerrote Edition (Germany)", "BPRD", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Fire Red Version (USA, Europe)", "BPRE", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Fire Red Version (USA, Europe)", "BPRE", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Leaf Green Version (USA, Europe)", "BPGE", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Leaf Green Version (USA, Europe)", "BPGE", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Rubin Edition (Germany)", "AXVD", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Rubin Edition (Germany)", "AXVD", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Ruby Version (USA, Europe)", "AXVE", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Ruby Version (USA, Europe)", "AXVE", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Sapphire Version (USA, Europe)", "AXPE", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Sapphire Version (USA, Europe)", "AXPE", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Saphir Edition (Germany)", "AXPD", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Saphir Edition (Germany)", "AXPD", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Smaragd Edition (Germany)", "BPED", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Smaragd Edition (Germany)", "BPED", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Version Emeraude (France)", "BPEF", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Version Emeraude (France)", "BPEF", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Version Rouge Feu (France)", "BPRF", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Version Rouge Feu (France)", "BPRF", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Version Rubis (France)", "AXVF", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Version Rubis (France)", "AXVF", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Version Saphir (France)", "AXPF", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Version Saphir (France)", "AXPF", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Version Vert Feuille (France)", "BPGF", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Version Vert Feuille (France)", "BPGF", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Versione Rubino (Italy)", "AXVI", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Versione Rubino (Italy)", "AXVI", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Versione Rosso Fuoco (Italy)", "BPRI", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Versione Rosso Fuoco (Italy)", "BPRI", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Versione Smeraldo (Italy)", "BPEI", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Versione Smeraldo (Italy)", "BPEI", 131072, 0, 1, 0, 0 },
|
||||||
{"Pokemon - Versione Verde Foglia (Italy)", "BPGI", 131072, 0, 0, 0, 0},
|
{ "Pokemon - Versione Verde Foglia (Italy)", "BPGI", 131072, 0, 0, 0, 0 },
|
||||||
{"Pokemon - Versione Zaffiro (Italy)", "AXPI", 131072, 0, 1, 0, 0},
|
{ "Pokemon - Versione Zaffiro (Italy)", "AXPI", 131072, 0, 1, 0, 0 },
|
||||||
{"Rockman EXE 4.5 - Real Operation (Japan)", "BR4J", 0, 0, 1, 0, 0},
|
{ "Rockman EXE 4.5 - Real Operation (Japan)", "BR4J", 0, 0, 1, 0, 0 },
|
||||||
{"Rocky (Europe)(En,Fr,De,Es,It)", "AROP", 0, 1, 0, 0, 0},
|
{ "Rocky (Europe)(En,Fr,De,Es,It)", "AROP", 0, 1, 0, 0, 0 },
|
||||||
{"Rocky (USA)(En,Fr,De,Es,It)", "AR8e", 0, 1, 0, 0, 0},
|
{ "Rocky (USA)(En,Fr,De,Es,It)", "AR8e", 0, 1, 0, 0, 0 },
|
||||||
{"Sennen Kazoku (Japan)", "BKAJ", 131072, 0, 1, 0, 0},
|
{ "Sennen Kazoku (Japan)", "BKAJ", 131072, 0, 1, 0, 0 },
|
||||||
{"Shin Bokura no Taiyou - Gyakushuu no Sabata (Japan)", "U33J", 0, 1, 1, 0, 0},
|
{ "Shin Bokura no Taiyou - Gyakushuu no Sabata (Japan)", "U33J", 0, 1, 1, 0, 0 },
|
||||||
{"Super Mario Advance 4 (Japan)", "AX4J", 131072, 0, 0, 0, 0},
|
{ "Super Mario Advance 4 (Japan)", "AX4J", 131072, 0, 0, 0, 0 },
|
||||||
{"Super Mario Advance 4 - Super Mario Bros. 3 (Europe)(En,Fr,De,Es,It)","AX4P", 131072, 0, 0, 0, 0},
|
{ "Super Mario Advance 4 - Super Mario Bros. 3 (Europe)(En,Fr,De,Es,It)", "AX4P", 131072, 0, 0, 0, 0 },
|
||||||
{"Super Mario Advance 4 - Super Mario Bros 3 - Super Mario Advance 4 v1.1 (USA)","AX4E",131072,0,0,0,0},
|
{ "Super Mario Advance 4 - Super Mario Bros 3 - Super Mario Advance 4 v1.1 (USA)", "AX4E", 131072, 0, 0, 0, 0 },
|
||||||
{"Top Gun - Combat Zones (USA)(En,Fr,De,Es,It)", "A2YE", 0, 5, 0, 0, 0},
|
{ "Top Gun - Combat Zones (USA)(En,Fr,De,Es,It)", "A2YE", 0, 5, 0, 0, 0 },
|
||||||
{"Yoshi's Universal Gravitation (Europe)(En,Fr,De,Es,It)", "KYGP", 0, 4, 0, 0, 0},
|
{ "Yoshi's Universal Gravitation (Europe)(En,Fr,De,Es,It)", "KYGP", 0, 4, 0, 0, 0 },
|
||||||
{"Yoshi no Banyuuinryoku (Japan)", "KYGJ", 0, 4, 0, 0, 0},
|
{ "Yoshi no Banyuuinryoku (Japan)", "KYGJ", 0, 4, 0, 0, 0 },
|
||||||
{"Yoshi - Topsy-Turvy (USA)", "KYGE", 0, 1, 0, 0, 0},
|
{ "Yoshi - Topsy-Turvy (USA)", "KYGE", 0, 1, 0, 0, 0 },
|
||||||
{"Yu-Gi-Oh! GX - Duel Academy (USA)", "BYGE", 0, 2, 0, 0, 1},
|
{ "Yu-Gi-Oh! GX - Duel Academy (USA)", "BYGE", 0, 2, 0, 0, 1 },
|
||||||
{"Yu-Gi-Oh! - Ultimate Masters - 2006 (Europe)(En,Jp,Fr,De,Es,It)", "BY6P", 0, 2, 0, 0, 0},
|
{ "Yu-Gi-Oh! - Ultimate Masters - 2006 (Europe)(En,Jp,Fr,De,Es,It)", "BY6P", 0, 2, 0, 0, 0 },
|
||||||
{"Zoku Bokura no Taiyou - Taiyou Shounen Django (Japan)", "U32J", 0, 0, 1, 0, 0}
|
{ "Zoku Bokura no Taiyou - Taiyou Shounen Django (Japan)", "U32J", 0, 0, 1, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void load_image_preferences (void)
|
static void load_image_preferences(void)
|
||||||
{
|
{
|
||||||
char buffer[5];
|
char buffer[5];
|
||||||
buffer[0] = rom[0xac];
|
buffer[0] = rom[0xac];
|
||||||
|
@ -383,24 +368,21 @@ static void load_image_preferences (void)
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int found_no = 0;
|
int found_no = 0;
|
||||||
|
|
||||||
for(int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++) {
|
||||||
{
|
if (!strcmp(gbaover[i].romid, buffer)) {
|
||||||
if(!strcmp(gbaover[i].romid, buffer))
|
|
||||||
{
|
|
||||||
found = true;
|
found = true;
|
||||||
found_no = i;
|
found_no = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found)
|
if (found) {
|
||||||
{
|
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "Found ROM in vba-over list.\n");
|
log_cb(RETRO_LOG_INFO, "Found ROM in vba-over list.\n");
|
||||||
|
|
||||||
enableRtc = gbaover[found_no].rtcEnabled;
|
enableRtc = gbaover[found_no].rtcEnabled;
|
||||||
|
|
||||||
if(gbaover[found_no].flashSize != 0)
|
if (gbaover[found_no].flashSize != 0)
|
||||||
flashSize = gbaover[found_no].flashSize;
|
flashSize = gbaover[found_no].flashSize;
|
||||||
else
|
else
|
||||||
flashSize = 65536;
|
flashSize = 65536;
|
||||||
|
@ -410,8 +392,7 @@ static void load_image_preferences (void)
|
||||||
mirroringEnable = gbaover[found_no].mirroringEnabled;
|
mirroringEnable = gbaover[found_no].mirroringEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_cb)
|
if (log_cb) {
|
||||||
{
|
|
||||||
log_cb(RETRO_LOG_INFO, "RTC = %d.\n", enableRtc);
|
log_cb(RETRO_LOG_INFO, "RTC = %d.\n", enableRtc);
|
||||||
log_cb(RETRO_LOG_INFO, "flashSize = %d.\n", flashSize);
|
log_cb(RETRO_LOG_INFO, "flashSize = %d.\n", flashSize);
|
||||||
log_cb(RETRO_LOG_INFO, "cpuSaveType = %d.\n", cpuSaveType);
|
log_cb(RETRO_LOG_INFO, "cpuSaveType = %d.\n", cpuSaveType);
|
||||||
|
@ -437,7 +418,6 @@ static void gba_init(void)
|
||||||
systemBlueShift = 3;
|
systemBlueShift = 3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
utilUpdateSystemColorMaps(false);
|
utilUpdateSystemColorMaps(false);
|
||||||
|
|
||||||
if (cpuSaveType == 0)
|
if (cpuSaveType == 0)
|
||||||
|
@ -447,10 +427,10 @@ static void gba_init(void)
|
||||||
|
|
||||||
load_image_preferences();
|
load_image_preferences();
|
||||||
|
|
||||||
if(flashSize == 0x10000 || flashSize == 0x20000)
|
if (flashSize == 0x10000 || flashSize == 0x20000)
|
||||||
flashSetSize(flashSize);
|
flashSetSize(flashSize);
|
||||||
|
|
||||||
if(enableRtc)
|
if (enableRtc)
|
||||||
rtcEnable(enableRtc);
|
rtcEnable(enableRtc);
|
||||||
|
|
||||||
doMirroring(mirroringEnable);
|
doMirroring(mirroringEnable);
|
||||||
|
@ -463,7 +443,7 @@ static void gba_init(void)
|
||||||
|
|
||||||
soundReset();
|
soundReset();
|
||||||
|
|
||||||
uint8_t * state_buf = (uint8_t*)malloc(2000000);
|
uint8_t* state_buf = (uint8_t*)malloc(2000000);
|
||||||
serialize_size = CPUWriteState(state_buf, 2000000);
|
serialize_size = CPUWriteState(state_buf, 2000000);
|
||||||
free(state_buf);
|
free(state_buf);
|
||||||
|
|
||||||
|
@ -525,7 +505,6 @@ static unsigned has_frame;
|
||||||
|
|
||||||
static void update_variables(void)
|
static void update_variables(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FINAL_VERSION
|
#ifdef FINAL_VERSION
|
||||||
|
@ -542,12 +521,11 @@ void retro_run(void)
|
||||||
|
|
||||||
poll_cb();
|
poll_cb();
|
||||||
|
|
||||||
|
|
||||||
has_frame = 0;
|
has_frame = 0;
|
||||||
|
|
||||||
do{
|
do {
|
||||||
CPULoop(TICKS);
|
CPULoop(TICKS);
|
||||||
}while(!has_frame);
|
} while (!has_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t retro_serialize_size(void)
|
size_t retro_serialize_size(void)
|
||||||
|
@ -555,12 +533,12 @@ size_t retro_serialize_size(void)
|
||||||
return serialize_size;
|
return serialize_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retro_serialize(void *data, size_t size)
|
bool retro_serialize(void* data, size_t size)
|
||||||
{
|
{
|
||||||
return CPUWriteState((uint8_t*)data, size);
|
return CPUWriteState((uint8_t*)data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retro_unserialize(const void *data, size_t size)
|
bool retro_unserialize(const void* data, size_t size)
|
||||||
{
|
{
|
||||||
return CPUReadState((uint8_t*)data, size);
|
return CPUReadState((uint8_t*)data, size);
|
||||||
}
|
}
|
||||||
|
@ -570,7 +548,7 @@ void retro_cheat_reset(void)
|
||||||
cheatsDeleteAll(false);
|
cheatsDeleteAll(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
void retro_cheat_set(unsigned index, bool enabled, const char* code)
|
||||||
{
|
{
|
||||||
const char *begin, *c;
|
const char *begin, *c;
|
||||||
|
|
||||||
|
@ -583,7 +561,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||||
if (*c != '+' && *c != '\0')
|
if (*c != '+' && *c != '\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char buf[32] = {0};
|
char buf[32] = { 0 };
|
||||||
int len = c - begin;
|
int len = c - begin;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -597,12 +575,12 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||||
if (len == 16)
|
if (len == 16)
|
||||||
cheatsAddGSACode(buf, "", false);
|
cheatsAddGSACode(buf, "", false);
|
||||||
else {
|
else {
|
||||||
char *space = strrchr(buf, ' ');
|
char* space = strrchr(buf, ' ');
|
||||||
if (space != NULL) {
|
if (space != NULL) {
|
||||||
if ((buf + len - space - 1) == 4)
|
if ((buf + len - space - 1) == 4)
|
||||||
cheatsAddCBACode(buf, "");
|
cheatsAddCBACode(buf, "");
|
||||||
else {
|
else {
|
||||||
memmove(space, space+1, strlen(space+1)+1);
|
memmove(space, space + 1, strlen(space + 1) + 1);
|
||||||
cheatsAddGSACode(buf, "", true);
|
cheatsAddGSACode(buf, "", true);
|
||||||
}
|
}
|
||||||
} else if (log_cb)
|
} else if (log_cb)
|
||||||
|
@ -612,7 +590,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||||
} while (*c++);
|
} while (*c++);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retro_load_game(const struct retro_game_info *game)
|
bool retro_load_game(const struct retro_game_info* game)
|
||||||
{
|
{
|
||||||
update_variables();
|
update_variables();
|
||||||
|
|
||||||
|
@ -639,28 +617,57 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||||
|
|
||||||
struct retro_memory_descriptor desc[9];
|
struct retro_memory_descriptor desc[9];
|
||||||
memset(desc, 0, sizeof(desc));
|
memset(desc, 0, sizeof(desc));
|
||||||
desc[0].start=0x03000000; desc[0].select=0xFF000000; desc[0].len=0x8000; desc[0].ptr=internalRAM;//fast WRAM
|
desc[0].start = 0x03000000;
|
||||||
desc[1].start=0x02000000; desc[1].select=0xFF000000; desc[1].len=0x40000; desc[1].ptr=workRAM;//slow WRAM
|
desc[0].select = 0xFF000000;
|
||||||
desc[2].start=0x0E000000; desc[2].select=0xFF000000; desc[2].len=libretro_save_size; desc[2].ptr=flashSaveMemory;//SRAM
|
desc[0].len = 0x8000;
|
||||||
desc[3].start=0x08000000; desc[3].select=0xFC000000; desc[3].len=0x2000000; desc[3].ptr=rom;//ROM, parts 1 and 2
|
desc[0].ptr = internalRAM; //fast WRAM
|
||||||
desc[3].flags=RETRO_MEMDESC_CONST;//we need two mappings since its size is not a power of 2
|
desc[1].start = 0x02000000;
|
||||||
desc[4].start=0x0C000000; desc[4].select=0xFE000000; desc[4].len=0x2000000; desc[4].ptr=rom;//ROM part 3
|
desc[1].select = 0xFF000000;
|
||||||
desc[4].flags=RETRO_MEMDESC_CONST;
|
desc[1].len = 0x40000;
|
||||||
desc[5].start=0x00000000; desc[5].select=0xFF000000; desc[5].len=0x4000; desc[5].ptr=bios;//BIOS
|
desc[1].ptr = workRAM; //slow WRAM
|
||||||
desc[5].flags=RETRO_MEMDESC_CONST;
|
desc[2].start = 0x0E000000;
|
||||||
desc[6].start=0x06000000; desc[6].select=0xFF000000; desc[6].len=0x18000; desc[6].ptr=vram;//VRAM
|
desc[2].select = 0xFF000000;
|
||||||
desc[7].start=0x07000000; desc[7].select=0xFF000000; desc[7].len=0x400; desc[7].ptr=paletteRAM;//palettes
|
desc[2].len = libretro_save_size;
|
||||||
desc[8].start=0x05000000; desc[8].select=0xFF000000; desc[8].len=0x400; desc[8].ptr=oam;//OAM
|
desc[2].ptr = flashSaveMemory; //SRAM
|
||||||
struct retro_memory_map retromap={ desc, sizeof(desc)/sizeof(*desc) };
|
desc[3].start = 0x08000000;
|
||||||
if (ret) environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap);
|
desc[3].select = 0xFC000000;
|
||||||
|
desc[3].len = 0x2000000;
|
||||||
|
desc[3].ptr = rom; //ROM, parts 1 and 2
|
||||||
|
desc[3].flags = RETRO_MEMDESC_CONST; //we need two mappings since its size is not a power of 2
|
||||||
|
desc[4].start = 0x0C000000;
|
||||||
|
desc[4].select = 0xFE000000;
|
||||||
|
desc[4].len = 0x2000000;
|
||||||
|
desc[4].ptr = rom; //ROM part 3
|
||||||
|
desc[4].flags = RETRO_MEMDESC_CONST;
|
||||||
|
desc[5].start = 0x00000000;
|
||||||
|
desc[5].select = 0xFF000000;
|
||||||
|
desc[5].len = 0x4000;
|
||||||
|
desc[5].ptr = bios; //BIOS
|
||||||
|
desc[5].flags = RETRO_MEMDESC_CONST;
|
||||||
|
desc[6].start = 0x06000000;
|
||||||
|
desc[6].select = 0xFF000000;
|
||||||
|
desc[6].len = 0x18000;
|
||||||
|
desc[6].ptr = vram; //VRAM
|
||||||
|
desc[7].start = 0x07000000;
|
||||||
|
desc[7].select = 0xFF000000;
|
||||||
|
desc[7].len = 0x400;
|
||||||
|
desc[7].ptr = paletteRAM; //palettes
|
||||||
|
desc[8].start = 0x05000000;
|
||||||
|
desc[8].select = 0xFF000000;
|
||||||
|
desc[8].len = 0x400;
|
||||||
|
desc[8].ptr = oam; //OAM
|
||||||
|
struct retro_memory_map retromap = { desc, sizeof(desc) / sizeof(*desc) };
|
||||||
|
if (ret)
|
||||||
|
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retro_load_game_special(
|
bool retro_load_game_special(
|
||||||
unsigned game_type,
|
unsigned game_type,
|
||||||
const struct retro_game_info *info, size_t num_info
|
const struct retro_game_info* info, size_t num_info)
|
||||||
)
|
{
|
||||||
{ return false; }
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
extern unsigned g_audio_frames;
|
extern unsigned g_audio_frames;
|
||||||
static unsigned g_video_frames;
|
static unsigned g_video_frames;
|
||||||
|
@ -679,7 +686,7 @@ unsigned retro_get_region(void)
|
||||||
return RETRO_REGION_NTSC;
|
return RETRO_REGION_NTSC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemOnWriteDataToSoundBuffer(const u16 *finalWave, int length)
|
void systemOnWriteDataToSoundBuffer(const u16* finalWave, int length)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,7 +732,6 @@ void systemMessage(int, const char* fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int systemGetSensorX(void)
|
int systemGetSensorX(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -748,13 +754,12 @@ u32 systemReadJoypad(int which)
|
||||||
|
|
||||||
u32 J = 0;
|
u32 J = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < 10; i++)
|
for (unsigned i = 0; i < 10; i++) {
|
||||||
{
|
if (controller_layout[0] == 1)
|
||||||
if(controller_layout[0] == 1)
|
|
||||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds1[i]) << i;
|
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds1[i]) << i;
|
||||||
else if(controller_layout[0] == 2)
|
else if (controller_layout[0] == 2)
|
||||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds2[i]) << i;
|
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds2[i]) << i;
|
||||||
else if(controller_layout[0] == -1)
|
else if (controller_layout[0] == -1)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds[i]) << i;
|
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds[i]) << i;
|
||||||
|
@ -773,15 +778,15 @@ void systemCartridgeRumble(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemPauseOnFrame() { return false; }
|
bool systemPauseOnFrame() { return false; }
|
||||||
void systemGbPrint(u8 *data,int pages, int feed, int palette, int contrast) {}
|
void systemGbPrint(u8* data, int pages, int feed, int palette, int contrast) {}
|
||||||
void systemScreenCapture(int a) {}
|
void systemScreenCapture(int a) {}
|
||||||
void systemScreenMessage(const char*msg)
|
void systemScreenMessage(const char* msg)
|
||||||
{
|
{
|
||||||
if (log_cb)
|
if (log_cb)
|
||||||
log_cb(RETRO_LOG_INFO, "%s\n", msg);
|
log_cb(RETRO_LOG_INFO, "%s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemSetTitle(const char *title) {}
|
void systemSetTitle(const char* title) {}
|
||||||
void systemShowSpeed(int speed) {}
|
void systemShowSpeed(int speed) {}
|
||||||
void system10Frames(int rate) {}
|
void system10Frames(int rate) {}
|
||||||
|
|
||||||
|
@ -790,7 +795,7 @@ u32 systemGetClock()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundDriver *systemSoundInit()
|
SoundDriver* systemSoundInit()
|
||||||
{
|
{
|
||||||
soundShutdown();
|
soundShutdown();
|
||||||
|
|
||||||
|
|
|
@ -61,20 +61,27 @@ static const unsigned long crc_table[256] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
||||||
#define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf);
|
#define DO2_CRC32(buf) \
|
||||||
#define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf);
|
DO1_CRC32(buf); \
|
||||||
#define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf);
|
DO1_CRC32(buf);
|
||||||
|
#define DO4_CRC32(buf) \
|
||||||
|
DO2_CRC32(buf); \
|
||||||
|
DO2_CRC32(buf);
|
||||||
|
#define DO8_CRC32(buf) \
|
||||||
|
DO4_CRC32(buf); \
|
||||||
|
DO4_CRC32(buf);
|
||||||
|
|
||||||
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len)
|
unsigned long crc32(unsigned long crc, const unsigned char* buf, unsigned int len)
|
||||||
{
|
{
|
||||||
if (buf == 0) return 0L;
|
if (buf == 0)
|
||||||
|
return 0L;
|
||||||
crc = crc ^ 0xffffffffL;
|
crc = crc ^ 0xffffffffL;
|
||||||
while (len >= 8)
|
while (len >= 8) {
|
||||||
{
|
|
||||||
DO8_CRC32(buf);
|
DO8_CRC32(buf);
|
||||||
len -= 8;
|
len -= 8;
|
||||||
}
|
}
|
||||||
if (len) do {
|
if (len)
|
||||||
|
do {
|
||||||
DO1_CRC32(buf);
|
DO1_CRC32(buf);
|
||||||
} while (--len);
|
} while (--len);
|
||||||
return crc ^ 0xffffffffL;
|
return crc ^ 0xffffffffL;
|
||||||
|
@ -85,4 +92,3 @@ unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int le
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
861
src/sdl/SDL.cpp
861
src/sdl/SDL.cpp
File diff suppressed because it is too large
Load Diff
1597
src/sdl/debugger.cpp
1597
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);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
972
src/sdl/expr.cpp
972
src/sdl/expr.cpp
File diff suppressed because it is too large
Load Diff
|
@ -16,44 +16,44 @@
|
||||||
// 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);
|
||||||
|
@ -64,10 +64,10 @@ Node *exprNodeIdentifier()
|
||||||
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;
|
||||||
|
@ -77,14 +77,14 @@ bool exprNodeIdentifierResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeIdentifierPrint(Node *n)
|
void exprNodeIdentifierPrint(Node* n)
|
||||||
{
|
{
|
||||||
printf("%s", n->name);
|
printf("%s", n->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeNumber()
|
Node* exprNodeNumber()
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
|
|
||||||
exprNodeClean(n);
|
exprNodeClean(n);
|
||||||
n->location = atoi(yytext);
|
n->location = atoi(yytext);
|
||||||
|
@ -95,19 +95,19 @@ Node *exprNodeNumber()
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeNumberResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeNumberResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeNumberPrint(Node *n)
|
void exprNodeNumberPrint(Node* n)
|
||||||
{
|
{
|
||||||
printf("%d", n->location);
|
printf("%d", n->location);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeStar(Node *exp)
|
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;
|
||||||
|
@ -117,14 +117,14 @@ Node *exprNodeStar(Node *exp)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeStarResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeStarResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
if(n->expression->resolve(n->expression, f, u)) {
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
if(n->expression->type->type == TYPE_pointer) {
|
if (n->expression->type->type == TYPE_pointer) {
|
||||||
n->location = n->expression->location;
|
n->location = n->expression->location;
|
||||||
if(n->expression->locType == LOCATION_memory) {
|
if (n->expression->locType == LOCATION_memory) {
|
||||||
n->location = debuggerReadMemory(n->location);
|
n->location = debuggerReadMemory(n->location);
|
||||||
} else if(n->expression->locType == LOCATION_register) {
|
} else if (n->expression->locType == LOCATION_register) {
|
||||||
n->location = reg[n->expression->location].I;
|
n->location = reg[n->expression->location].I;
|
||||||
} else {
|
} else {
|
||||||
n->location = n->expression->location;
|
n->location = n->expression->location;
|
||||||
|
@ -139,15 +139,15 @@ bool exprNodeStarResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeStarPrint(Node *n)
|
void exprNodeStarPrint(Node* n)
|
||||||
{
|
{
|
||||||
printf("*");
|
printf("*");
|
||||||
n->expression->print(n->expression);
|
n->expression->print(n->expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeDot(Node *exp, Node *ident)
|
Node* exprNodeDot(Node* exp, Node* ident)
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
exprNodeClean(n);
|
exprNodeClean(n);
|
||||||
|
|
||||||
n->expression = exp;
|
n->expression = exp;
|
||||||
|
@ -158,23 +158,22 @@ Node *exprNodeDot(Node *exp, Node *ident)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeDotResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
if(n->expression->resolve(n->expression, f, u)) {
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
TypeEnum tt = n->expression->type->type;
|
TypeEnum tt = n->expression->type->type;
|
||||||
|
|
||||||
if(tt == TYPE_struct ||
|
if (tt == TYPE_struct || tt == TYPE_union) {
|
||||||
tt == TYPE_union) {
|
|
||||||
u32 loc = n->expression->location;
|
u32 loc = n->expression->location;
|
||||||
Type *t = n->expression->type;
|
Type* t = n->expression->type;
|
||||||
int count = t->structure->memberCount;
|
int count = t->structure->memberCount;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(i < count) {
|
while (i < count) {
|
||||||
Member *m = &t->structure->members[i];
|
Member* m = &t->structure->members[i];
|
||||||
if(strcmp(m->name, n->name) == 0) {
|
if (strcmp(m->name, n->name) == 0) {
|
||||||
// found member
|
// found member
|
||||||
n->type = m->type;
|
n->type = m->type;
|
||||||
if(tt == TYPE_struct) {
|
if (tt == TYPE_struct) {
|
||||||
n->location = elfDecodeLocation(f, m->location, &n->locType,
|
n->location = elfDecodeLocation(f, m->location, &n->locType,
|
||||||
loc);
|
loc);
|
||||||
n->objLocation = loc;
|
n->objLocation = loc;
|
||||||
|
@ -196,15 +195,15 @@ bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeDotPrint(Node *n)
|
void exprNodeDotPrint(Node* n)
|
||||||
{
|
{
|
||||||
n->expression->print(n->expression);
|
n->expression->print(n->expression);
|
||||||
printf(".%s", n->name);
|
printf(".%s", n->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeArrow(Node *exp, Node *ident)
|
Node* exprNodeArrow(Node* exp, Node* ident)
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
exprNodeClean(n);
|
exprNodeClean(n);
|
||||||
|
|
||||||
n->expression = exp;
|
n->expression = exp;
|
||||||
|
@ -215,28 +214,27 @@ Node *exprNodeArrow(Node *exp, Node *ident)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeArrowResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
if(n->expression->resolve(n->expression, f, u)) {
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
TypeEnum tt = n->expression->type->type;
|
TypeEnum tt = n->expression->type->type;
|
||||||
if(tt != TYPE_pointer) {
|
if (tt != TYPE_pointer) {
|
||||||
printf("Object not of pointer type\n");
|
printf("Object not of pointer type\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tt = n->expression->type->pointer->type;
|
tt = n->expression->type->pointer->type;
|
||||||
|
|
||||||
if(tt == TYPE_struct ||
|
if (tt == TYPE_struct || tt == TYPE_union) {
|
||||||
tt == TYPE_union) {
|
|
||||||
u32 loc = debuggerReadMemory(n->expression->location);
|
u32 loc = debuggerReadMemory(n->expression->location);
|
||||||
Type *t = n->expression->type->pointer;
|
Type* t = n->expression->type->pointer;
|
||||||
int count = t->structure->memberCount;
|
int count = t->structure->memberCount;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(i < count) {
|
while (i < count) {
|
||||||
Member *m = &t->structure->members[i];
|
Member* m = &t->structure->members[i];
|
||||||
if(strcmp(m->name, n->name) == 0) {
|
if (strcmp(m->name, n->name) == 0) {
|
||||||
// found member
|
// found member
|
||||||
n->type = m->type;
|
n->type = m->type;
|
||||||
if(tt == TYPE_struct) {
|
if (tt == TYPE_struct) {
|
||||||
n->location = elfDecodeLocation(f, m->location, &n->locType,
|
n->location = elfDecodeLocation(f, m->location, &n->locType,
|
||||||
loc);
|
loc);
|
||||||
n->objLocation = loc;
|
n->objLocation = loc;
|
||||||
|
@ -258,15 +256,15 @@ bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeArrowPrint(Node *n)
|
void exprNodeArrowPrint(Node* n)
|
||||||
{
|
{
|
||||||
n->expression->print(n->expression);
|
n->expression->print(n->expression);
|
||||||
printf("->%s", n->name);
|
printf("->%s", n->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeAddr(Node *exp)
|
Node* exprNodeAddr(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;
|
||||||
|
@ -276,14 +274,14 @@ Node *exprNodeAddr(Node *exp)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeAddrResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeAddrResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
if(n->expression->resolve(n->expression, f, u)) {
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
if(n->expression->locType == LOCATION_memory) {
|
if (n->expression->locType == LOCATION_memory) {
|
||||||
n->location = n->expression->location;
|
n->location = n->expression->location;
|
||||||
n->locType = LOCATION_value;
|
n->locType = LOCATION_value;
|
||||||
n->type = &exprNodeType;
|
n->type = &exprNodeType;
|
||||||
} else if(n->expression->locType == LOCATION_register) {
|
} else if (n->expression->locType == LOCATION_register) {
|
||||||
printf("Value is in register %d\n", n->expression->location);
|
printf("Value is in register %d\n", n->expression->location);
|
||||||
} else {
|
} else {
|
||||||
printf("Direct value is %d\n", n->location);
|
printf("Direct value is %d\n", n->location);
|
||||||
|
@ -293,15 +291,15 @@ bool exprNodeAddrResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeAddrPrint(Node *n)
|
void exprNodeAddrPrint(Node* n)
|
||||||
{
|
{
|
||||||
printf("*");
|
printf("*");
|
||||||
n->expression->print(n->expression);
|
n->expression->print(n->expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeSizeof(Node *exp)
|
Node* exprNodeSizeof(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;
|
||||||
|
@ -311,9 +309,9 @@ Node *exprNodeSizeof(Node *exp)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeSizeofResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeSizeofResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
if(n->expression->resolve(n->expression, f, u)) {
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
n->location = n->expression->type->size;
|
n->location = n->expression->type->size;
|
||||||
n->locType = LOCATION_value;
|
n->locType = LOCATION_value;
|
||||||
n->type = &exprNodeType;
|
n->type = &exprNodeType;
|
||||||
|
@ -322,16 +320,16 @@ bool exprNodeSizeofResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeSizeofPrint(Node *n)
|
void exprNodeSizeofPrint(Node* n)
|
||||||
{
|
{
|
||||||
printf("sizeof(");
|
printf("sizeof(");
|
||||||
n->expression->print(n->expression);
|
n->expression->print(n->expression);
|
||||||
printf(")");
|
printf(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *exprNodeArray(Node *exp, Node *number)
|
Node* exprNodeArray(Node* exp, Node* number)
|
||||||
{
|
{
|
||||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
Node* n = (Node*)calloc(1, sizeof(Node));
|
||||||
exprNodeClean(n);
|
exprNodeClean(n);
|
||||||
|
|
||||||
n->expression = exp;
|
n->expression = exp;
|
||||||
|
@ -342,50 +340,48 @@ Node *exprNodeArray(Node *exp, Node *number)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int exprNodeGetSize(Array *a, int index)
|
int exprNodeGetSize(Array* a, int index)
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
if(index == a->maxBounds) {
|
if (index == a->maxBounds) {
|
||||||
return a->type->size;
|
return a->type->size;
|
||||||
} else {
|
} else {
|
||||||
int size = a->bounds[a->maxBounds-1] * a->type->size;
|
int size = a->bounds[a->maxBounds - 1] * a->type->size;
|
||||||
|
|
||||||
for(int i = index; i < a->maxBounds-1; i++) {
|
for (int i = index; i < a->maxBounds - 1; i++) {
|
||||||
size *= a->bounds[i];
|
size *= a->bounds[i];
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
|
bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
|
||||||
{
|
{
|
||||||
if(n->expression->resolve(n->expression, f, u)) {
|
if (n->expression->resolve(n->expression, f, u)) {
|
||||||
TypeEnum tt = n->expression->type->type;
|
TypeEnum tt = n->expression->type->type;
|
||||||
if(tt != TYPE_array &&
|
if (tt != TYPE_array && tt != TYPE_pointer) {
|
||||||
tt != TYPE_pointer) {
|
|
||||||
printf("Object not of array or pointer type\n");
|
printf("Object not of array or pointer type\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tt == TYPE_array) {
|
if (tt == TYPE_array) {
|
||||||
Array *a = n->expression->type->array;
|
Array* a = n->expression->type->array;
|
||||||
|
|
||||||
u32 loc = n->expression->location;
|
u32 loc = n->expression->location;
|
||||||
Type *t = a->type;
|
Type* t = a->type;
|
||||||
if(a->maxBounds > 1) {
|
if (a->maxBounds > 1) {
|
||||||
int index = n->expression->index;
|
int index = n->expression->index;
|
||||||
|
|
||||||
if(index == a->maxBounds) {
|
if (index == a->maxBounds) {
|
||||||
printf("Too many indices for array\n");
|
printf("Too many indices for array\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((index+1) < a->maxBounds) {
|
if ((index + 1) < a->maxBounds) {
|
||||||
n->type = n->expression->type;
|
n->type = n->expression->type;
|
||||||
n->index = index+1;
|
n->index = index + 1;
|
||||||
n->locType = LOCATION_memory;
|
n->locType = LOCATION_memory;
|
||||||
n->location = n->expression->location +
|
n->location = n->expression->location + n->value * exprNodeGetSize(a, index);
|
||||||
n->value * exprNodeGetSize(a, index);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,9 +389,9 @@ bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
n->location = loc + n->value * t->size;
|
n->location = loc + n->value * t->size;
|
||||||
n->locType = LOCATION_memory;
|
n->locType = LOCATION_memory;
|
||||||
} else {
|
} else {
|
||||||
Type *t = n->expression->type->pointer;
|
Type* t = n->expression->type->pointer;
|
||||||
u32 loc = n->expression->location;
|
u32 loc = n->expression->location;
|
||||||
if(n->expression->locType == LOCATION_register)
|
if (n->expression->locType == LOCATION_register)
|
||||||
loc = reg[loc].I;
|
loc = reg[loc].I;
|
||||||
else
|
else
|
||||||
loc = debuggerReadMemory(loc);
|
loc = debuggerReadMemory(loc);
|
||||||
|
@ -408,7 +404,7 @@ bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exprNodeArrayPrint(Node *n)
|
void exprNodeArrayPrint(Node* n)
|
||||||
{
|
{
|
||||||
n->expression->print(n->expression);
|
n->expression->print(n->expression);
|
||||||
printf("[%d]", n->value);
|
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*
|
||||||
|
|
|
@ -22,49 +22,49 @@
|
||||||
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Screen filters
|
// Screen filters
|
||||||
//
|
//
|
||||||
|
|
||||||
extern int Init_2xSaI(u32);
|
extern int Init_2xSaI(u32);
|
||||||
extern void hq2x_init(unsigned);
|
extern void hq2x_init(unsigned);
|
||||||
extern bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth);
|
extern bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth);
|
||||||
|
|
||||||
extern void sdlStretch1x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void sdlStretch1x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void sdlStretch2x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void sdlStretch2x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void sdlStretch3x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void sdlStretch3x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void sdlStretch4x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void sdlStretch4x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void _2xSaI(u8*,u32,u8*,u8*,u32,int,int);
|
extern void _2xSaI(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void _2xSaI32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void _2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Super2xSaI(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Super2xSaI(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Super2xSaI32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Super2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int);
|
extern void SuperEagle(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void SuperEagle32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void SuperEagle32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Pixelate(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Pixelate(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Pixelate32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Pixelate32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void AdMame2x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void AdMame2x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void AdMame2x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void AdMame2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Bilinear(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Bilinear(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Bilinear32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Bilinear32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void BilinearPlus(u8*,u32,u8*,u8*,u32,int,int);
|
extern void BilinearPlus(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void BilinearPlus32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void BilinearPlus32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Scanlines(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Scanlines(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void Scanlines32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void Scanlines32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void ScanlinesTV(u8*,u32,u8*,u8*,u32,int,int);
|
extern void ScanlinesTV(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void ScanlinesTV32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void ScanlinesTV32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void hq2x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void hq2x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void hq2x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void hq2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void lq2x(u8*,u32,u8*,u8*,u32,int,int);
|
extern void lq2x(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void lq2x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void lq2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void hq3x16(u8*,u32,u8*,u8*,u32,int,int);
|
extern void hq3x16(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void hq4x16(u8*,u32,u8*,u8*,u32,int,int);
|
extern void hq4x16(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void hq3x32_32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void hq3x32_32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void hq4x32_32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void hq4x32_32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void xbrz2x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void xbrz2x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void xbrz3x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void xbrz3x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void xbrz4x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void xbrz4x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void xbrz5x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void xbrz5x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
extern void xbrz6x32(u8*,u32,u8*,u8*,u32,int,int);
|
extern void xbrz6x32(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
|
|
||||||
struct FilterDesc {
|
struct FilterDesc {
|
||||||
char name[30];
|
char name[30];
|
||||||
|
@ -146,9 +146,12 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth)
|
||||||
case k2xSaI:
|
case k2xSaI:
|
||||||
case kSuper2xSaI:
|
case kSuper2xSaI:
|
||||||
case kSuperEagle:
|
case kSuperEagle:
|
||||||
if (colorDepth == 15) Init_2xSaI(555);
|
if (colorDepth == 15)
|
||||||
else if (colorDepth == 16) Init_2xSaI(565);
|
Init_2xSaI(555);
|
||||||
else Init_2xSaI(colorDepth);
|
else if (colorDepth == 16)
|
||||||
|
Init_2xSaI(565);
|
||||||
|
else
|
||||||
|
Init_2xSaI(colorDepth);
|
||||||
break;
|
break;
|
||||||
case khq2x:
|
case khq2x:
|
||||||
case klq2x:
|
case klq2x:
|
||||||
|
@ -161,14 +164,14 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth)
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Interframe blending filters
|
// Interframe blending filters
|
||||||
//
|
//
|
||||||
|
|
||||||
extern void SmartIB(u8*,u32,int,int);
|
extern void SmartIB(u8*, u32, int, int);
|
||||||
extern void SmartIB32(u8*,u32,int,int);
|
extern void SmartIB32(u8*, u32, int, int);
|
||||||
extern void MotionBlurIB(u8*,u32,int,int);
|
extern void MotionBlurIB(u8*, u32, int, int);
|
||||||
extern void MotionBlurIB32(u8*,u32,int,int);
|
extern void MotionBlurIB32(u8*, u32, int, int);
|
||||||
|
|
||||||
struct IFBFilterDesc {
|
struct IFBFilterDesc {
|
||||||
char name[30];
|
char name[30];
|
||||||
|
@ -208,89 +211,86 @@ char* getIFBFilterName(const IFBFilter f)
|
||||||
return (char*)IFBFilters[f].name;
|
return (char*)IFBFilters[f].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Optimized stretchers implementation
|
// Optimized stretchers implementation
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef C_CORE
|
#ifndef C_CORE
|
||||||
u8 sdlStretcher[16384];
|
u8 sdlStretcher[16384];
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define SDL_CALL_STRETCHER \
|
#define SDL_CALL_STRETCHER \
|
||||||
{\
|
{ \
|
||||||
__asm mov eax, stretcher\
|
__asm mov eax, stretcher __asm mov edi, destPtr __asm mov esi, srcPtr __asm call eax \
|
||||||
__asm mov edi, destPtr\
|
|
||||||
__asm mov esi, srcPtr\
|
|
||||||
__asm call eax\
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define SDL_CALL_STRETCHER \
|
#define SDL_CALL_STRETCHER \
|
||||||
asm volatile("call *%%eax"::"a" (stretcher),"S" (srcPtr),"D" (dstPtr))
|
asm volatile("call *%%eax" ::"a"(stretcher), "S"(srcPtr), "D"(dstPtr))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SDL_LONG(val) \
|
#define SDL_LONG(val) \
|
||||||
*((u32 *)&sdlStretcher[sdlStretcherPos]) = val;\
|
*((u32*)&sdlStretcher[sdlStretcherPos]) = val; \
|
||||||
sdlStretcherPos+=4;
|
sdlStretcherPos += 4;
|
||||||
|
|
||||||
#define SDL_AND_EAX(val) \
|
#define SDL_AND_EAX(val) \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x25;\
|
sdlStretcher[sdlStretcherPos++] = 0x25; \
|
||||||
SDL_LONG(val);
|
SDL_LONG(val);
|
||||||
|
|
||||||
#define SDL_AND_EBX(val) \
|
#define SDL_AND_EBX(val) \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x81;\
|
sdlStretcher[sdlStretcherPos++] = 0x81; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xe3;\
|
sdlStretcher[sdlStretcherPos++] = 0xe3; \
|
||||||
SDL_LONG(val);
|
SDL_LONG(val);
|
||||||
|
|
||||||
#define SDL_OR_EAX_EBX \
|
#define SDL_OR_EAX_EBX \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x09;\
|
sdlStretcher[sdlStretcherPos++] = 0x09; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xd8;
|
sdlStretcher[sdlStretcherPos++] = 0xd8;
|
||||||
|
|
||||||
#define SDL_LOADL_EBX \
|
#define SDL_LOADL_EBX \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x8b;\
|
sdlStretcher[sdlStretcherPos++] = 0x8b; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x1f;
|
sdlStretcher[sdlStretcherPos++] = 0x1f;
|
||||||
|
|
||||||
#define SDL_LOADW \
|
#define SDL_LOADW \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x66;\
|
sdlStretcher[sdlStretcherPos++] = 0x66; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x8b;\
|
sdlStretcher[sdlStretcherPos++] = 0x8b; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x06;\
|
sdlStretcher[sdlStretcherPos++] = 0x06; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
sdlStretcher[sdlStretcherPos++] = 0x83; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xc6;\
|
sdlStretcher[sdlStretcherPos++] = 0xc6; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x02;
|
sdlStretcher[sdlStretcherPos++] = 0x02;
|
||||||
|
|
||||||
#define SDL_LOADL \
|
#define SDL_LOADL \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x8b;\
|
sdlStretcher[sdlStretcherPos++] = 0x8b; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x06;\
|
sdlStretcher[sdlStretcherPos++] = 0x06; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
sdlStretcher[sdlStretcherPos++] = 0x83; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xc6;\
|
sdlStretcher[sdlStretcherPos++] = 0xc6; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x04;
|
sdlStretcher[sdlStretcherPos++] = 0x04;
|
||||||
|
|
||||||
#define SDL_LOADL2 \
|
#define SDL_LOADL2 \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x8b;\
|
sdlStretcher[sdlStretcherPos++] = 0x8b; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x06;\
|
sdlStretcher[sdlStretcherPos++] = 0x06; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
sdlStretcher[sdlStretcherPos++] = 0x83; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xc6;\
|
sdlStretcher[sdlStretcherPos++] = 0xc6; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x03;
|
sdlStretcher[sdlStretcherPos++] = 0x03;
|
||||||
|
|
||||||
#define SDL_STOREW \
|
#define SDL_STOREW \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x66;\
|
sdlStretcher[sdlStretcherPos++] = 0x66; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x89;\
|
sdlStretcher[sdlStretcherPos++] = 0x89; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x07;\
|
sdlStretcher[sdlStretcherPos++] = 0x07; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
sdlStretcher[sdlStretcherPos++] = 0x83; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xc7;\
|
sdlStretcher[sdlStretcherPos++] = 0xc7; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x02;
|
sdlStretcher[sdlStretcherPos++] = 0x02;
|
||||||
|
|
||||||
#define SDL_STOREL \
|
#define SDL_STOREL \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x89;\
|
sdlStretcher[sdlStretcherPos++] = 0x89; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x07;\
|
sdlStretcher[sdlStretcherPos++] = 0x07; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
sdlStretcher[sdlStretcherPos++] = 0x83; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xc7;\
|
sdlStretcher[sdlStretcherPos++] = 0xc7; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x04;
|
sdlStretcher[sdlStretcherPos++] = 0x04;
|
||||||
|
|
||||||
#define SDL_STOREL2 \
|
#define SDL_STOREL2 \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x89;\
|
sdlStretcher[sdlStretcherPos++] = 0x89; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x07;\
|
sdlStretcher[sdlStretcherPos++] = 0x07; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
sdlStretcher[sdlStretcherPos++] = 0x83; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xc7;\
|
sdlStretcher[sdlStretcherPos++] = 0xc7; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x03;
|
sdlStretcher[sdlStretcherPos++] = 0x03;
|
||||||
|
|
||||||
#define SDL_RET \
|
#define SDL_RET \
|
||||||
|
@ -327,40 +327,40 @@ u8 sdlStretcher[16384];
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x5f;
|
sdlStretcher[sdlStretcherPos++] = 0x5f;
|
||||||
|
|
||||||
#define SDL_MOV_ECX(val) \
|
#define SDL_MOV_ECX(val) \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xb9;\
|
sdlStretcher[sdlStretcherPos++] = 0xb9; \
|
||||||
SDL_LONG(val);
|
SDL_LONG(val);
|
||||||
|
|
||||||
#define SDL_REP_MOVSB \
|
#define SDL_REP_MOVSB \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xf3;\
|
sdlStretcher[sdlStretcherPos++] = 0xf3; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xa4;
|
sdlStretcher[sdlStretcherPos++] = 0xa4;
|
||||||
|
|
||||||
#define SDL_REP_MOVSW \
|
#define SDL_REP_MOVSW \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xf3;\
|
sdlStretcher[sdlStretcherPos++] = 0xf3; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0x66;\
|
sdlStretcher[sdlStretcherPos++] = 0x66; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xa5;
|
sdlStretcher[sdlStretcherPos++] = 0xa5;
|
||||||
|
|
||||||
#define SDL_REP_MOVSL \
|
#define SDL_REP_MOVSL \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xf3;\
|
sdlStretcher[sdlStretcherPos++] = 0xf3; \
|
||||||
sdlStretcher[sdlStretcherPos++] = 0xa5;
|
sdlStretcher[sdlStretcherPos++] = 0xa5;
|
||||||
|
|
||||||
void sdlMakeStretcher(int width, int sizeOption)
|
void sdlMakeStretcher(int width, int sizeOption)
|
||||||
{
|
{
|
||||||
int sdlStretcherPos;
|
int sdlStretcherPos;
|
||||||
sdlStretcherPos = 0;
|
sdlStretcherPos = 0;
|
||||||
switch(systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 16:
|
case 16:
|
||||||
if(sizeOption) {
|
if (sizeOption) {
|
||||||
SDL_PUSH_EAX;
|
SDL_PUSH_EAX;
|
||||||
SDL_PUSH_ESI;
|
SDL_PUSH_ESI;
|
||||||
SDL_PUSH_EDI;
|
SDL_PUSH_EDI;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
SDL_LOADW;
|
SDL_LOADW;
|
||||||
SDL_STOREW;
|
SDL_STOREW;
|
||||||
SDL_STOREW;
|
SDL_STOREW;
|
||||||
if(sizeOption > 1) {
|
if (sizeOption > 1) {
|
||||||
SDL_STOREW;
|
SDL_STOREW;
|
||||||
}
|
}
|
||||||
if(sizeOption > 2) {
|
if (sizeOption > 2) {
|
||||||
SDL_STOREW;
|
SDL_STOREW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,29 +381,29 @@ void sdlMakeStretcher(int width, int sizeOption)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
if(sizeOption) {
|
if (sizeOption) {
|
||||||
SDL_PUSH_EAX;
|
SDL_PUSH_EAX;
|
||||||
SDL_PUSH_ESI;
|
SDL_PUSH_ESI;
|
||||||
SDL_PUSH_EDI;
|
SDL_PUSH_EDI;
|
||||||
int w = width - 1;
|
int w = width - 1;
|
||||||
for(int i = 0; i < w; i++) {
|
for (int i = 0; i < w; i++) {
|
||||||
SDL_LOADL2;
|
SDL_LOADL2;
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
if(sizeOption > 1) {
|
if (sizeOption > 1) {
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
}
|
}
|
||||||
if(sizeOption > 2) {
|
if (sizeOption > 2) {
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// need to write the last one
|
// need to write the last one
|
||||||
SDL_LOADL2;
|
SDL_LOADL2;
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
if(sizeOption > 1) {
|
if (sizeOption > 1) {
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
}
|
}
|
||||||
if(sizeOption > 2) {
|
if (sizeOption > 2) {
|
||||||
SDL_STOREL2;
|
SDL_STOREL2;
|
||||||
}
|
}
|
||||||
SDL_AND_EAX(0x00ffffff);
|
SDL_AND_EAX(0x00ffffff);
|
||||||
|
@ -421,7 +421,7 @@ void sdlMakeStretcher(int width, int sizeOption)
|
||||||
SDL_PUSH_ESI;
|
SDL_PUSH_ESI;
|
||||||
SDL_PUSH_EDI;
|
SDL_PUSH_EDI;
|
||||||
SDL_PUSH_ECX;
|
SDL_PUSH_ECX;
|
||||||
SDL_MOV_ECX(3*width);
|
SDL_MOV_ECX(3 * width);
|
||||||
SDL_REP_MOVSB;
|
SDL_REP_MOVSB;
|
||||||
SDL_POP_ECX;
|
SDL_POP_ECX;
|
||||||
SDL_POP_EDI;
|
SDL_POP_EDI;
|
||||||
|
@ -430,18 +430,18 @@ void sdlMakeStretcher(int width, int sizeOption)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
if(sizeOption) {
|
if (sizeOption) {
|
||||||
SDL_PUSH_EAX;
|
SDL_PUSH_EAX;
|
||||||
SDL_PUSH_ESI;
|
SDL_PUSH_ESI;
|
||||||
SDL_PUSH_EDI;
|
SDL_PUSH_EDI;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
SDL_LOADL;
|
SDL_LOADL;
|
||||||
SDL_STOREL;
|
SDL_STOREL;
|
||||||
SDL_STOREL;
|
SDL_STOREL;
|
||||||
if(sizeOption > 1) {
|
if (sizeOption > 1) {
|
||||||
SDL_STOREL;
|
SDL_STOREL;
|
||||||
}
|
}
|
||||||
if(sizeOption > 2) {
|
if (sizeOption > 2) {
|
||||||
SDL_STOREL;
|
SDL_STOREL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,49 +466,49 @@ void sdlMakeStretcher(int width, int sizeOption)
|
||||||
|
|
||||||
#else // C_CORE
|
#else // C_CORE
|
||||||
|
|
||||||
void (*sdlStretcher)(u8 *, u8*, int) = 0;
|
void (*sdlStretcher)(u8*, u8*, int) = 0;
|
||||||
|
|
||||||
#define SDL_CALL_STRETCHER \
|
#define SDL_CALL_STRETCHER \
|
||||||
sdlStretcher(srcPtr, dstPtr, width)
|
sdlStretcher(srcPtr, dstPtr, width)
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void sdlStretchx1(u8 *src, u8 *dest, int width)
|
void sdlStretchx1(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
T *s = (T *)src;
|
T* s = (T*)src;
|
||||||
T *d = (T *)dest;
|
T* d = (T*)dest;
|
||||||
for(int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void sdlStretchx2(u8 *src, u8 *dest, int width)
|
void sdlStretchx2(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
T *s = (T *)src;
|
T* s = (T*)src;
|
||||||
T *d = (T *)dest;
|
T* d = (T*)dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void sdlStretchx3(u8 *src, u8 *dest, int width)
|
void sdlStretchx3(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
T *s = (T *)src;
|
T* s = (T*)src;
|
||||||
T *d = (T *)dest;
|
T* d = (T*)dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void sdlStretchx4(u8 *src, u8 *dest, int width)
|
void sdlStretchx4(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
T *s = (T *)src;
|
T* s = (T*)src;
|
||||||
T *d = (T *)dest;
|
T* d = (T*)dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
|
@ -516,92 +516,92 @@ void sdlStretchx4(u8 *src, u8 *dest, int width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*sdlStretcher16[4])(u8 *, u8 *, int) = {
|
void (*sdlStretcher16[4])(u8*, u8*, int) = {
|
||||||
sdlStretchx1<u16>,
|
sdlStretchx1<u16>,
|
||||||
sdlStretchx2<u16>,
|
sdlStretchx2<u16>,
|
||||||
sdlStretchx3<u16>,
|
sdlStretchx3<u16>,
|
||||||
sdlStretchx4<u16>
|
sdlStretchx4<u16>
|
||||||
};
|
};
|
||||||
|
|
||||||
void (*sdlStretcher32[4])(u8 *, u8 *, int) = {
|
void (*sdlStretcher32[4])(u8*, u8*, int) = {
|
||||||
sdlStretchx1<u32>,
|
sdlStretchx1<u32>,
|
||||||
sdlStretchx2<u32>,
|
sdlStretchx2<u32>,
|
||||||
sdlStretchx3<u32>,
|
sdlStretchx3<u32>,
|
||||||
sdlStretchx4<u32>
|
sdlStretchx4<u32>
|
||||||
};
|
};
|
||||||
|
|
||||||
void sdlStretch24x1(u8 *src, u8 *dest, int width)
|
void sdlStretch24x1(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
u8 *s = src;
|
u8* s = src;
|
||||||
u8 *d = dest;
|
u8* d = dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlStretch24x2(u8 *src, u8 *dest, int width)
|
void sdlStretch24x2(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
u8 *s = (u8 *)src;
|
u8* s = (u8*)src;
|
||||||
u8 *d = (u8 *)dest;
|
u8* d = (u8*)dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlStretch24x3(u8 *src, u8 *dest, int width)
|
void sdlStretch24x3(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
u8 *s = (u8 *)src;
|
u8* s = (u8*)src;
|
||||||
u8 *d = (u8 *)dest;
|
u8* d = (u8*)dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlStretch24x4(u8 *src, u8 *dest, int width)
|
void sdlStretch24x4(u8* src, u8* dest, int width)
|
||||||
{
|
{
|
||||||
u8 *s = (u8 *)src;
|
u8* s = (u8*)src;
|
||||||
u8 *d = (u8 *)dest;
|
u8* d = (u8*)dest;
|
||||||
for(int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
*d++ = *(s+1);
|
*d++ = *(s + 1);
|
||||||
*d++ = *(s+2);
|
*d++ = *(s + 2);
|
||||||
s += 3;
|
s += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*sdlStretcher24[4])(u8 *, u8 *, int) = {
|
void (*sdlStretcher24[4])(u8*, u8*, int) = {
|
||||||
sdlStretch24x1,
|
sdlStretch24x1,
|
||||||
sdlStretch24x2,
|
sdlStretch24x2,
|
||||||
sdlStretch24x3,
|
sdlStretch24x3,
|
||||||
|
@ -615,7 +615,7 @@ bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth)
|
||||||
#ifndef C_CORE
|
#ifndef C_CORE
|
||||||
sdlMakeStretcher(srcWidth, sizeMultiplier);
|
sdlMakeStretcher(srcWidth, sizeMultiplier);
|
||||||
#else
|
#else
|
||||||
switch(colorDepth) {
|
switch (colorDepth) {
|
||||||
case 16:
|
case 16:
|
||||||
sdlStretcher = sdlStretcher16[sizeMultiplier];
|
sdlStretcher = sdlStretcher16[sizeMultiplier];
|
||||||
break;
|
break;
|
||||||
|
@ -632,23 +632,25 @@ bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlStretch1x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) {
|
void sdlStretch1x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
#ifndef C_CORE
|
#ifndef C_CORE
|
||||||
u32 *stretcher = (u32 *)sdlStretcher;
|
u32* stretcher = (u32*)sdlStretcher;
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
srcPtr += srcPitch;
|
srcPtr += srcPitch;
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void sdlStretch2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) {
|
void sdlStretch2x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
#ifndef C_CORE
|
#ifndef C_CORE
|
||||||
u32 *stretcher = (u32 *)sdlStretcher;
|
u32* stretcher = (u32*)sdlStretcher;
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
|
@ -656,12 +658,13 @@ void sdlStretch2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void sdlStretch3x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) {
|
void sdlStretch3x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
#ifndef C_CORE
|
#ifndef C_CORE
|
||||||
u32 *stretcher = (u32 *)sdlStretcher;
|
u32* stretcher = (u32*)sdlStretcher;
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
|
@ -671,12 +674,13 @@ void sdlStretch3x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void sdlStretch4x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) {
|
void sdlStretch4x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
#ifndef C_CORE
|
#ifndef C_CORE
|
||||||
u32 *stretcher = (u32 *)sdlStretcher;
|
u32* stretcher = (u32*)sdlStretcher;
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
SDL_CALL_STRETCHER;
|
SDL_CALL_STRETCHER;
|
||||||
|
@ -688,5 +692,3 @@ void sdlStretch4x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32
|
||||||
dstPtr += dstPitch;
|
dstPtr += dstPitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ enum Filter {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
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. */
|
||||||
|
|
||||||
char *optarg = NULL;
|
char* optarg = NULL;
|
||||||
|
|
||||||
/* 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
|
||||||
|
@ -145,7 +145,7 @@ int __getopt_initialized = 0;
|
||||||
If this is zero, or a null string, it means resume the scan
|
If this is zero, or a null string, it means resume the scan
|
||||||
by advancing to the next ARGV-element. */
|
by advancing to the next ARGV-element. */
|
||||||
|
|
||||||
static char *nextchar;
|
static char* nextchar;
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message
|
/* Callers store zero here to inhibit the error message
|
||||||
for unrecognized options. */
|
for unrecognized options. */
|
||||||
|
@ -187,10 +187,12 @@ int optopt = '?';
|
||||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||||
|
|
||||||
static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
|
static enum { REQUIRE_ORDER,
|
||||||
|
PERMUTE,
|
||||||
|
RETURN_IN_ORDER } ordering;
|
||||||
|
|
||||||
/* Value of POSIXLY_CORRECT environment variable. */
|
/* Value of POSIXLY_CORRECT environment variable. */
|
||||||
static char *posixly_correct;
|
static char* posixly_correct;
|
||||||
|
|
||||||
#ifdef __GNU_LIBRARY__
|
#ifdef __GNU_LIBRARY__
|
||||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||||
|
@ -213,15 +215,15 @@ static char *posixly_correct;
|
||||||
whose names are inconsistent. */
|
whose names are inconsistent. */
|
||||||
|
|
||||||
#ifndef getenv
|
#ifndef getenv
|
||||||
extern char *getenv();
|
extern char* getenv();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *my_index(str, chr) const char *str;
|
static char* my_index(str, chr) const char* str;
|
||||||
int chr;
|
int chr;
|
||||||
{
|
{
|
||||||
while (*str) {
|
while (*str) {
|
||||||
if (*str == chr)
|
if (*str == chr)
|
||||||
return (char *)str;
|
return (char*)str;
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -235,7 +237,7 @@ int chr;
|
||||||
#if (!defined __STDC__ || !__STDC__) && !defined strlen
|
#if (!defined __STDC__ || !__STDC__) && !defined strlen
|
||||||
/* gcc with -traditional declares the built-in strlen to return int,
|
/* gcc with -traditional declares the built-in strlen to return int,
|
||||||
and has done so at least since version 2.4.5. -- rms. */
|
and has done so at least since version 2.4.5. -- rms. */
|
||||||
extern int strlen(const char *);
|
extern int strlen(const char*);
|
||||||
#endif /* not __STDC__ */
|
#endif /* not __STDC__ */
|
||||||
#endif /* __GNUC__ */
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
@ -255,18 +257,18 @@ static int last_nonopt;
|
||||||
indicating ARGV elements that should not be considered arguments. */
|
indicating ARGV elements that should not be considered arguments. */
|
||||||
|
|
||||||
/* Defined in getopt_init.c */
|
/* Defined in getopt_init.c */
|
||||||
extern char *__getopt_nonoption_flags;
|
extern char* __getopt_nonoption_flags;
|
||||||
|
|
||||||
static int nonoption_flags_max_len;
|
static int nonoption_flags_max_len;
|
||||||
static int nonoption_flags_len;
|
static int nonoption_flags_len;
|
||||||
|
|
||||||
static int original_argc;
|
static int original_argc;
|
||||||
static char *const *original_argv;
|
static char* const* original_argv;
|
||||||
|
|
||||||
/* Make sure the environment variable bash 2.0 puts in the environment
|
/* Make sure the environment variable bash 2.0 puts in the environment
|
||||||
is valid for the getopt call we must make sure that the ARGV passed
|
is valid for the getopt call we must make sure that the ARGV passed
|
||||||
to getopt is that one passed to the process. */
|
to getopt is that one passed to the process. */
|
||||||
static void __attribute__((unused)) store_args_and_env(int argc, char *const *argv)
|
static void __attribute__((unused)) store_args_and_env(int argc, char* const* argv)
|
||||||
{
|
{
|
||||||
/* XXX This is no good solution. We should rather copy the args so
|
/* XXX This is no good solution. We should rather copy the args so
|
||||||
that we can compare them later. But we must not use malloc(3). */
|
that we can compare them later. But we must not use malloc(3). */
|
||||||
|
@ -297,15 +299,15 @@ text_set_element(__libc_subinit, store_args_and_env);
|
||||||
the new indices of the non-options in ARGV after they are moved. */
|
the new indices of the non-options in ARGV after they are moved. */
|
||||||
|
|
||||||
#if defined __STDC__ && __STDC__
|
#if defined __STDC__ && __STDC__
|
||||||
static void exchange(char **);
|
static void exchange(char**);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void exchange(argv) char **argv;
|
static void exchange(argv) char** argv;
|
||||||
{
|
{
|
||||||
int bottom = first_nonopt;
|
int bottom = first_nonopt;
|
||||||
int middle = last_nonopt;
|
int middle = last_nonopt;
|
||||||
int top = optind;
|
int top = optind;
|
||||||
char *tem;
|
char* tem;
|
||||||
|
|
||||||
/* Exchange the shorter segment with the far end of the longer segment.
|
/* Exchange the shorter segment with the far end of the longer segment.
|
||||||
That puts the shorter segment into the right place.
|
That puts the shorter segment into the right place.
|
||||||
|
@ -319,7 +321,7 @@ static void exchange(argv) char **argv;
|
||||||
if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) {
|
if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) {
|
||||||
/* We must extend the array. The user plays games with us and
|
/* We must extend the array. The user plays games with us and
|
||||||
presents new arguments. */
|
presents new arguments. */
|
||||||
char *new_str = malloc(top + 1);
|
char* new_str = malloc(top + 1);
|
||||||
if (new_str == NULL)
|
if (new_str == NULL)
|
||||||
nonoption_flags_len = nonoption_flags_max_len = 0;
|
nonoption_flags_len = nonoption_flags_max_len = 0;
|
||||||
else {
|
else {
|
||||||
|
@ -375,11 +377,11 @@ static void exchange(argv) char **argv;
|
||||||
/* Initialize the internal data when the first call is made. */
|
/* Initialize the internal data when the first call is made. */
|
||||||
|
|
||||||
#if defined __STDC__ && __STDC__
|
#if defined __STDC__ && __STDC__
|
||||||
static const char *_getopt_initialize(int, char *const *, const char *);
|
static const char* _getopt_initialize(int, char* const*, const char*);
|
||||||
#endif
|
#endif
|
||||||
static const char *_getopt_initialize(argc, argv, optstring) int argc;
|
static const char* _getopt_initialize(argc, argv, optstring) int argc;
|
||||||
char *const *argv;
|
char* const* argv;
|
||||||
const char *optstring;
|
const char* optstring;
|
||||||
{
|
{
|
||||||
/* Start processing options with ARGV-element 1 (since ARGV-element 0
|
/* Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||||
is the program name); the sequence of previously skipped
|
is the program name); the sequence of previously skipped
|
||||||
|
@ -410,11 +412,11 @@ const char *optstring;
|
||||||
if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0')
|
if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0')
|
||||||
nonoption_flags_max_len = -1;
|
nonoption_flags_max_len = -1;
|
||||||
else {
|
else {
|
||||||
const char *orig_str = __getopt_nonoption_flags;
|
const char* orig_str = __getopt_nonoption_flags;
|
||||||
int len = nonoption_flags_max_len = strlen(orig_str);
|
int len = nonoption_flags_max_len = strlen(orig_str);
|
||||||
if (nonoption_flags_max_len < argc)
|
if (nonoption_flags_max_len < argc)
|
||||||
nonoption_flags_max_len = argc;
|
nonoption_flags_max_len = argc;
|
||||||
__getopt_nonoption_flags = (char *)malloc(nonoption_flags_max_len);
|
__getopt_nonoption_flags = (char*)malloc(nonoption_flags_max_len);
|
||||||
if (__getopt_nonoption_flags == NULL)
|
if (__getopt_nonoption_flags == NULL)
|
||||||
nonoption_flags_max_len = -1;
|
nonoption_flags_max_len = -1;
|
||||||
else
|
else
|
||||||
|
@ -488,10 +490,10 @@ const char *optstring;
|
||||||
long-named options. */
|
long-named options. */
|
||||||
|
|
||||||
int _getopt_internal(argc, argv, optstring, longopts, longind, long_only) int argc;
|
int _getopt_internal(argc, argv, optstring, longopts, longind, long_only) int argc;
|
||||||
char *const *argv;
|
char* const* argv;
|
||||||
const char *optstring;
|
const char* optstring;
|
||||||
const struct option *longopts;
|
const struct option* longopts;
|
||||||
int *longind;
|
int* longind;
|
||||||
int long_only;
|
int long_only;
|
||||||
{
|
{
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
@ -509,8 +511,7 @@ int long_only;
|
||||||
is only used when the used in the GNU libc. */
|
is only used when the used in the GNU libc. */
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
#define NONOPTION_P \
|
#define NONOPTION_P \
|
||||||
(argv[optind][0] != '-' || argv[optind][1] == '\0' || \
|
(argv[optind][0] != '-' || argv[optind][1] == '\0' || (optind < nonoption_flags_len && __getopt_nonoption_flags[optind] == '1'))
|
||||||
(optind < nonoption_flags_len && __getopt_nonoption_flags[optind] == '1'))
|
|
||||||
#else
|
#else
|
||||||
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||||
#endif
|
#endif
|
||||||
|
@ -530,7 +531,7 @@ int long_only;
|
||||||
exchange them so that the options come first. */
|
exchange them so that the options come first. */
|
||||||
|
|
||||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||||
exchange((char **)argv);
|
exchange((char**)argv);
|
||||||
else if (last_nonopt != optind)
|
else if (last_nonopt != optind)
|
||||||
first_nonopt = optind;
|
first_nonopt = optind;
|
||||||
|
|
||||||
|
@ -551,7 +552,7 @@ int long_only;
|
||||||
optind++;
|
optind++;
|
||||||
|
|
||||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||||
exchange((char **)argv);
|
exchange((char**)argv);
|
||||||
else if (first_nonopt == last_nonopt)
|
else if (first_nonopt == last_nonopt)
|
||||||
first_nonopt = optind;
|
first_nonopt = optind;
|
||||||
last_nonopt = argc;
|
last_nonopt = argc;
|
||||||
|
@ -601,12 +602,10 @@ int long_only;
|
||||||
|
|
||||||
This distinction seems to be the most useful approach. */
|
This distinction seems to be the most useful approach. */
|
||||||
|
|
||||||
if (longopts != NULL &&
|
if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index(optstring, argv[optind][1]))))) {
|
||||||
(argv[optind][1] == '-' ||
|
char* nameend;
|
||||||
(long_only && (argv[optind][2] || !my_index(optstring, argv[optind][1]))))) {
|
const struct option* p;
|
||||||
char *nameend;
|
const struct option* pfound = NULL;
|
||||||
const struct option *p;
|
|
||||||
const struct option *pfound = NULL;
|
|
||||||
int exact = 0;
|
int exact = 0;
|
||||||
int ambig = 0;
|
int ambig = 0;
|
||||||
int indfound = -1;
|
int indfound = -1;
|
||||||
|
@ -619,8 +618,7 @@ int long_only;
|
||||||
or abbreviated matches. */
|
or abbreviated matches. */
|
||||||
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
||||||
if (!strncmp(p->name, nextchar, nameend - nextchar)) {
|
if (!strncmp(p->name, nextchar, nameend - nextchar)) {
|
||||||
if ((unsigned int)(nameend - nextchar) ==
|
if ((unsigned int)(nameend - nextchar) == (unsigned int)strlen(p->name)) {
|
||||||
(unsigned int)strlen(p->name)) {
|
|
||||||
/* Exact match found. */
|
/* Exact match found. */
|
||||||
pfound = p;
|
pfound = p;
|
||||||
indfound = option_index;
|
indfound = option_index;
|
||||||
|
@ -707,8 +705,7 @@ int long_only;
|
||||||
or the option starts with '--' or is not a valid short
|
or the option starts with '--' or is not a valid short
|
||||||
option, then it's an error.
|
option, then it's an error.
|
||||||
Otherwise interpret it as a short option. */
|
Otherwise interpret it as a short option. */
|
||||||
if (!long_only || argv[optind][1] == '-' ||
|
if (!long_only || argv[optind][1] == '-' || my_index(optstring, *nextchar) == NULL) {
|
||||||
my_index(optstring, *nextchar) == NULL) {
|
|
||||||
if (opterr) {
|
if (opterr) {
|
||||||
if (argv[optind][1] == '-')
|
if (argv[optind][1] == '-')
|
||||||
/* --option */
|
/* --option */
|
||||||
|
@ -724,7 +721,7 @@ int long_only;
|
||||||
argv[optind][0],
|
argv[optind][0],
|
||||||
nextchar);
|
nextchar);
|
||||||
}
|
}
|
||||||
nextchar = (char *)"";
|
nextchar = (char*)"";
|
||||||
optind++;
|
optind++;
|
||||||
optopt = 0;
|
optopt = 0;
|
||||||
return '?';
|
return '?';
|
||||||
|
@ -735,7 +732,7 @@ int long_only;
|
||||||
|
|
||||||
{
|
{
|
||||||
char c = *nextchar++;
|
char c = *nextchar++;
|
||||||
char *temp = my_index(optstring, c);
|
char* temp = my_index(optstring, c);
|
||||||
|
|
||||||
/* Increment `optind' when we start to process its last character. */
|
/* Increment `optind' when we start to process its last character. */
|
||||||
if (*nextchar == '\0')
|
if (*nextchar == '\0')
|
||||||
|
@ -760,9 +757,9 @@ int long_only;
|
||||||
}
|
}
|
||||||
/* Convenience. Treat POSIX -W foo same as long option --foo */
|
/* Convenience. Treat POSIX -W foo same as long option --foo */
|
||||||
if (temp[0] == 'W' && temp[1] == ';') {
|
if (temp[0] == 'W' && temp[1] == ';') {
|
||||||
char *nameend;
|
char* nameend;
|
||||||
const struct option *p;
|
const struct option* p;
|
||||||
const struct option *pfound = NULL;
|
const struct option* pfound = NULL;
|
||||||
int exact = 0;
|
int exact = 0;
|
||||||
int ambig = 0;
|
int ambig = 0;
|
||||||
int indfound = 0;
|
int indfound = 0;
|
||||||
|
@ -914,10 +911,10 @@ int long_only;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getopt(argc, argv, optstring) int argc;
|
int getopt(argc, argv, optstring) int argc;
|
||||||
char *const *argv;
|
char* const* argv;
|
||||||
const char *optstring;
|
const char* optstring;
|
||||||
{
|
{
|
||||||
return _getopt_internal(argc, argv, optstring, (const struct option *)0, (int *)0, 0);
|
return _getopt_internal(argc, argv, optstring, (const struct option*)0, (int*)0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Not ELIDE_CODE. */
|
#endif /* Not ELIDE_CODE. */
|
||||||
|
@ -928,7 +925,7 @@ const char *optstring;
|
||||||
the above definition of `getopt'. */
|
the above definition of `getopt'. */
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -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,14 +81,14 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,20 +108,20 @@ 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();
|
||||||
|
|
|
@ -65,10 +65,10 @@
|
||||||
#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);
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ 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;
|
||||||
|
|
|
@ -29,26 +29,22 @@ 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;
|
||||||
|
|
||||||
|
@ -59,10 +55,11 @@ static uint32_t joypad[5][SDLBUTTONS_NUM] = {
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ SDLK_LEFT, SDLK_RIGHT,
|
{
|
||||||
|
SDLK_LEFT, SDLK_RIGHT,
|
||||||
SDLK_UP, SDLK_DOWN,
|
SDLK_UP, SDLK_DOWN,
|
||||||
SDLK_z, SDLK_x,
|
SDLK_z, SDLK_x,
|
||||||
SDLK_RETURN,SDLK_BACKSPACE,
|
SDLK_RETURN, SDLK_BACKSPACE,
|
||||||
SDLK_a, SDLK_s,
|
SDLK_a, SDLK_s,
|
||||||
SDLK_SPACE, SDLK_F12,
|
SDLK_SPACE, SDLK_F12,
|
||||||
SDLK_q, SDLK_w,
|
SDLK_q, SDLK_w,
|
||||||
|
@ -77,50 +74,33 @@ static uint32_t defaultMotion[4] = {
|
||||||
SDLK_KP_4, SDLK_KP_6, SDLK_KP_8, SDLK_KP_2
|
SDLK_KP_4, SDLK_KP_6, SDLK_KP_8, SDLK_KP_2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static uint32_t sdlGetHatCode(const SDL_Event& event)
|
||||||
static uint32_t sdlGetHatCode(const SDL_Event &event)
|
|
||||||
{
|
{
|
||||||
if (!event.jhat.value) return 0;
|
if (!event.jhat.value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
((event.jhat.which + 1) << 16) |
|
((event.jhat.which + 1) << 16) | 32 | (event.jhat.hat << 2) | (event.jhat.value & SDL_HAT_UP ? 0 : event.jhat.value & SDL_HAT_DOWN ? 1 : event.jhat.value & SDL_HAT_RIGHT ? 2 : event.jhat.value & SDL_HAT_LEFT ? 3 : 0));
|
||||||
32 |
|
|
||||||
(event.jhat.hat << 2) |
|
|
||||||
(
|
|
||||||
event.jhat.value & SDL_HAT_UP ? 0 :
|
|
||||||
event.jhat.value & SDL_HAT_DOWN ? 1 :
|
|
||||||
event.jhat.value & SDL_HAT_RIGHT ? 2 :
|
|
||||||
event.jhat.value & SDL_HAT_LEFT ? 3 : 0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t sdlGetButtonCode(const SDL_Event &event)
|
static uint32_t sdlGetButtonCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
((event.jbutton.which + 1) << 16) |
|
((event.jbutton.which + 1) << 16) | (event.jbutton.button + 0x80));
|
||||||
(event.jbutton.button + 0x80)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t sdlGetAxisCode(const SDL_Event &event)
|
static uint32_t sdlGetAxisCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384) return 0;
|
if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
((event.jaxis.which + 1) << 16) |
|
((event.jaxis.which + 1) << 16) | (event.jaxis.axis << 1) | (event.jaxis.value > 16384 ? 1 : event.jaxis.value < -16384 ? 0 : 0));
|
||||||
(event.jaxis.axis << 1) |
|
|
||||||
(
|
|
||||||
event.jaxis.value > 16384 ? 1 :
|
|
||||||
event.jaxis.value < -16384 ? 0 : 0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t inputGetEventCode(const SDL_Event &event)
|
uint32_t inputGetEventCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch (event.type) {
|
||||||
{
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
return event.key.keysym.sym;
|
return event.key.keysym.sym;
|
||||||
|
@ -160,8 +140,7 @@ bool inputGetAutoFire(EKey key)
|
||||||
{
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
|
|
||||||
switch (key)
|
switch (key) {
|
||||||
{
|
|
||||||
case KEY_BUTTON_A:
|
case KEY_BUTTON_A:
|
||||||
mask = 1 << 0;
|
mask = 1 << 0;
|
||||||
break;
|
break;
|
||||||
|
@ -185,8 +164,7 @@ bool inputToggleAutoFire(EKey key)
|
||||||
{
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
|
|
||||||
switch (key)
|
switch (key) {
|
||||||
{
|
|
||||||
case KEY_BUTTON_A:
|
case KEY_BUTTON_A:
|
||||||
mask = 1 << 0;
|
mask = 1 << 0;
|
||||||
break;
|
break;
|
||||||
|
@ -203,13 +181,10 @@ bool inputToggleAutoFire(EKey key)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(autoFire & mask)
|
if (autoFire & mask) {
|
||||||
{
|
|
||||||
autoFire &= ~mask;
|
autoFire &= ~mask;
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
autoFire |= mask;
|
autoFire |= mask;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -218,17 +193,17 @@ 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++) {
|
for (i = 0; i < 4; i++) {
|
||||||
//if((motion[i] & 0xffff0000) == 0) {
|
//if((motion[i] & 0xffff0000) == 0) {
|
||||||
if(key == motion[i])
|
if (key == motion[i])
|
||||||
sdlMotionButtons[i] = down;
|
sdlMotionButtons[i] = down;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
@ -239,26 +214,26 @@ static void sdlUpdateJoyButton(int which,
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,17 +245,17 @@ static void sdlUpdateJoyHat(int which,
|
||||||
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;
|
||||||
|
@ -299,16 +274,16 @@ static void sdlUpdateJoyHat(int which,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
@ -333,26 +308,26 @@ static void sdlUpdateJoyAxis(int which,
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,22 +339,22 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,28 +365,27 @@ static bool sdlCheckJoyKey(int key)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +394,7 @@ void inputInitJoysticks()
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ok)
|
if (!ok)
|
||||||
joypad[j][i] = joypad[PAD_DEFAULT][i];
|
joypad[j][i] = joypad[PAD_DEFAULT][i];
|
||||||
else
|
else
|
||||||
usesJoy = true;
|
usesJoy = true;
|
||||||
|
@ -428,15 +402,15 @@ void inputInitJoysticks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int dev = motion[i] >> 16;
|
int dev = motion[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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,28 +419,29 @@ void inputInitJoysticks()
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ok)
|
if (!ok)
|
||||||
motion[i] = defaultMotion[i];
|
motion[i] = defaultMotion[i];
|
||||||
else
|
else
|
||||||
usesJoy = true;
|
usesJoy = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(usesJoy)
|
if (usesJoy)
|
||||||
SDL_JoystickEventState(SDL_ENABLE);
|
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) sdlUpdateKey(event.key.keysym.sym, true);
|
if (!event.key.keysym.mod)
|
||||||
|
sdlUpdateKey(event.key.keysym.sym, true);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (!event.key.keysym.mod) sdlUpdateKey(event.key.keysym.sym, false);
|
if (!event.key.keysym.mod)
|
||||||
|
sdlUpdateKey(event.key.keysym.sym, false);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_JOYHATMOTION:
|
||||||
sdlUpdateJoyHat(event.jhat.which,
|
sdlUpdateJoyHat(event.jhat.which,
|
||||||
|
@ -491,50 +466,50 @@ 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
|
||||||
|
@ -551,47 +526,47 @@ uint32_t inputReadJoypad(int which)
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,4 +590,3 @@ EPad inputGetDefaultJoypad()
|
||||||
{
|
{
|
||||||
return sdlDefaultJoypad;
|
return sdlDefaultJoypad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,12 @@ enum EKey {
|
||||||
KEY_BUTTON_AUTO_B
|
KEY_BUTTON_AUTO_B
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EPad { PAD_MAIN, PAD_1 = PAD_MAIN, PAD_2, PAD_3, PAD_4, PAD_DEFAULT };
|
enum EPad { PAD_MAIN,
|
||||||
|
PAD_1 = PAD_MAIN,
|
||||||
|
PAD_2,
|
||||||
|
PAD_3,
|
||||||
|
PAD_4,
|
||||||
|
PAD_DEFAULT };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the joysticks needed by the keymap. Verify that the keymap is compatible
|
* Init the joysticks needed by the keymap. Verify that the keymap is compatible
|
||||||
|
@ -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
|
||||||
|
|
118
src/sdl/text.cpp
118
src/sdl/text.cpp
|
@ -25,22 +25,22 @@
|
||||||
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;
|
||||||
|
@ -48,101 +48,93 @@ void drawText(u8 *screen, int pitch, int x, int y,
|
||||||
inc = 4;
|
inc = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
screen += x*inc;
|
screen += x * inc;
|
||||||
|
|
||||||
switch(systemColorDepth) {
|
switch (systemColorDepth) {
|
||||||
case 16:
|
case 16: {
|
||||||
{
|
while (*string) {
|
||||||
while(*string) {
|
|
||||||
char c = *string++;
|
char c = *string++;
|
||||||
u8 *scr = screen;
|
u8* scr = screen;
|
||||||
|
|
||||||
u16 mask = ~RGB_LOW_BITS_MASK;
|
u16 mask = ~RGB_LOW_BITS_MASK;
|
||||||
int h, w;
|
int h, w;
|
||||||
u16 *s = (u16 *)scr;
|
u16* s = (u16*)scr;
|
||||||
for (h = 0; h < 8; h++) {
|
for (h = 0; h < 8; h++) {
|
||||||
for (w = 0; w < 8; w++, s++) {
|
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 = ((0xf) << systemRedShift) + ((*s & mask) >> 1);
|
||||||
((*s & mask) >>1);
|
|
||||||
} else {
|
} else {
|
||||||
if(on)
|
if (on)
|
||||||
*s = (0x1f) << systemRedShift;
|
*s = (0x1f) << systemRedShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scr += pitch;
|
scr += pitch;
|
||||||
s = (u16 *)scr;
|
s = (u16*)scr;
|
||||||
}
|
}
|
||||||
screen += inc*8;
|
screen += inc * 8;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case 24: {
|
||||||
case 24:
|
while (*string) {
|
||||||
{
|
|
||||||
while(*string) {
|
|
||||||
char c = *string++;
|
char c = *string++;
|
||||||
u8 *scr = screen;
|
u8* scr = screen;
|
||||||
|
|
||||||
int h, w;
|
int h, w;
|
||||||
u8 *s = (u8 *)scr;
|
u8* s = (u8*)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 += 3) {
|
||||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
int on = (fontdata2[(c << 3) + h] >> w) & 1;
|
||||||
|
|
||||||
if(trans) {
|
if (trans) {
|
||||||
if(on) {
|
if (on) {
|
||||||
u32 color = (0x1f) << systemRedShift;
|
u32 color = (0x1f) << systemRedShift;
|
||||||
*s = ((color & 255)>>1)+(*s>>1);
|
*s = ((color & 255) >> 1) + (*s >> 1);
|
||||||
*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
|
*(s + 1) = (((color >> 8) & 255) >> 1) + (*(s + 1) >> 1);
|
||||||
*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
|
*(s + 2) = (((color >> 16) & 255) >> 1) + (*(s + 2) >> 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(on) {
|
if (on) {
|
||||||
u32 color = (0x1f) << systemRedShift;
|
u32 color = (0x1f) << systemRedShift;
|
||||||
*s = (color & 255);
|
*s = (color & 255);
|
||||||
*(s+1) = (color >> 8) & 255;
|
*(s + 1) = (color >> 8) & 255;
|
||||||
*(s+2) = (color >> 16) & 255;
|
*(s + 2) = (color >> 16) & 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scr += pitch;
|
scr += pitch;
|
||||||
s = (u8 *)scr;
|
s = (u8*)scr;
|
||||||
}
|
}
|
||||||
screen += inc*8;
|
screen += inc * 8;
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case 32: {
|
||||||
case 32:
|
while (*string) {
|
||||||
{
|
|
||||||
while(*string) {
|
|
||||||
char c = *string++;
|
char c = *string++;
|
||||||
u8 *scr = screen;
|
u8* scr = screen;
|
||||||
|
|
||||||
int h, w;
|
int h, w;
|
||||||
u32 mask = 0xfefefe;
|
u32 mask = 0xfefefe;
|
||||||
u32 *s = (u32 *)scr;
|
u32* s = (u32*)scr;
|
||||||
for (h = 0; h < 8; h++) {
|
for (h = 0; h < 8; h++) {
|
||||||
for (w = 0; w < 8; w++, s++) {
|
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);
|
*s = ((0xf) << systemRedShift) + ((*s & mask) >> 1);
|
||||||
} else {
|
} else {
|
||||||
if(on)
|
if (on)
|
||||||
*s = (0x1f) << systemRedShift;
|
*s = (0x1f) << systemRedShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scr += pitch;
|
scr += pitch;
|
||||||
s = (u32 *)scr;
|
s = (u32*)scr;
|
||||||
}
|
}
|
||||||
screen += inc*8;
|
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,8 +1,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "AVIWrite.h"
|
#include "AVIWrite.h"
|
||||||
#pragma comment( lib, "Vfw32" )
|
#pragma comment(lib, "Vfw32")
|
||||||
|
|
||||||
|
|
||||||
AVIWrite::AVIWrite()
|
AVIWrite::AVIWrite()
|
||||||
{
|
{
|
||||||
|
@ -10,8 +9,8 @@ AVIWrite::AVIWrite()
|
||||||
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;
|
||||||
|
@ -24,36 +23,35 @@ AVIWrite::AVIWrite()
|
||||||
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;
|
||||||
|
|
||||||
|
@ -62,10 +60,9 @@ bool AVIWrite::CreateAVIFile( LPCTSTR filename )
|
||||||
&m_file,
|
&m_file,
|
||||||
filename,
|
filename,
|
||||||
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
|
OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE,
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -73,18 +70,18 @@ bool AVIWrite::CreateAVIFile( LPCTSTR filename )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// colorBits: 16, 24 or 32
|
// colorBits: 16, 24 or 32
|
||||||
bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd )
|
bool AVIWrite::CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd)
|
||||||
{
|
{
|
||||||
if( m_videoStream || m_failed ) return false;
|
if (m_videoStream || m_failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT err = 0;
|
HRESULT err = 0;
|
||||||
AVISTREAMINFO videoInfo;
|
AVISTREAMINFO videoInfo;
|
||||||
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 --
|
||||||
|
@ -92,119 +89,110 @@ bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorB
|
||||||
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 --
|
// -- ask for compression settings --
|
||||||
if( AVISaveOptions(
|
if (AVISaveOptions(
|
||||||
parentWnd,
|
parentWnd,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
&m_videoStream,
|
&m_videoStream,
|
||||||
settings ) )
|
settings)) {
|
||||||
{
|
|
||||||
err = AVIMakeCompressedStream(
|
err = AVIMakeCompressedStream(
|
||||||
&m_videoCompressed,
|
&m_videoCompressed,
|
||||||
m_videoStream,
|
m_videoStream,
|
||||||
settings[0],
|
settings[0],
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
AVISaveOptionsFree( 1, settings );
|
AVISaveOptionsFree(1, settings);
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AVISaveOptionsFree( 1, settings );
|
AVISaveOptionsFree(1, settings);
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- initialize the video stream format --
|
// -- initialize the video stream format --
|
||||||
bitmapInfo.biSize = sizeof( bitmapInfo );
|
bitmapInfo.biSize = sizeof(bitmapInfo);
|
||||||
bitmapInfo.biWidth = imageWidth;
|
bitmapInfo.biWidth = imageWidth;
|
||||||
bitmapInfo.biHeight = imageHeight;
|
bitmapInfo.biHeight = imageHeight;
|
||||||
bitmapInfo.biBitCount = colorBits;
|
bitmapInfo.biBitCount = colorBits;
|
||||||
bitmapInfo.biPlanes = 1;
|
bitmapInfo.biPlanes = 1;
|
||||||
bitmapInfo.biCompression = BI_RGB;
|
bitmapInfo.biCompression = BI_RGB;
|
||||||
bitmapInfo.biSizeImage = imageWidth * imageHeight * ( colorBits >> 3 );
|
bitmapInfo.biSizeImage = imageWidth * imageHeight * (colorBits >> 3);
|
||||||
|
|
||||||
// -- set the video stream format --
|
// -- set the video stream format --
|
||||||
err = AVIStreamSetFormat(
|
err = AVIStreamSetFormat(
|
||||||
m_videoCompressed,
|
m_videoCompressed,
|
||||||
0,
|
0,
|
||||||
&bitmapInfo,
|
&bitmapInfo,
|
||||||
bitmapInfo.biSize + ( bitmapInfo.biClrUsed * sizeof( RGBQUAD ) )
|
bitmapInfo.biSize + (bitmapInfo.biClrUsed * sizeof(RGBQUAD)));
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_frameRate = framesPerSecond;
|
m_frameRate = framesPerSecond;
|
||||||
m_videoFrameSize = imageWidth * imageHeight * ( colorBits >> 3 );
|
m_videoFrameSize = imageWidth * imageHeight * (colorBits >> 3);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// call AddVideoStream() first
|
// call AddVideoStream() first
|
||||||
// channelCount: max. 2
|
// channelCount: max. 2
|
||||||
// sampleBits: max. 16
|
// sampleBits: max. 16
|
||||||
bool AVIWrite::CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd )
|
bool AVIWrite::CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd)
|
||||||
{
|
{
|
||||||
if( m_audioStream || m_failed ) return false;
|
if (m_audioStream || m_failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT err = 0;
|
HRESULT err = 0;
|
||||||
AVISTREAMINFO audioInfo;
|
AVISTREAMINFO audioInfo;
|
||||||
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 --
|
// -- initialize the audio stream format --
|
||||||
waveInfo.wFormatTag = WAVE_FORMAT_PCM;
|
waveInfo.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
waveInfo.nChannels = channelCount;
|
waveInfo.nChannels = channelCount;
|
||||||
waveInfo.nSamplesPerSec = sampleRate;
|
waveInfo.nSamplesPerSec = sampleRate;
|
||||||
waveInfo.nAvgBytesPerSec = channelCount * ( sampleBits >> 3 ) * sampleRate;
|
waveInfo.nAvgBytesPerSec = channelCount * (sampleBits >> 3) * sampleRate;
|
||||||
waveInfo.nBlockAlign = channelCount * ( sampleBits >> 3 );
|
waveInfo.nBlockAlign = channelCount * (sampleBits >> 3);
|
||||||
waveInfo.wBitsPerSample = sampleBits;
|
waveInfo.wBitsPerSample = sampleBits;
|
||||||
waveInfo.cbSize = 0;
|
waveInfo.cbSize = 0;
|
||||||
|
|
||||||
|
@ -213,24 +201,23 @@ bool AVIWrite::CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD samp
|
||||||
m_audioStream,
|
m_audioStream,
|
||||||
0,
|
0,
|
||||||
&waveInfo,
|
&waveInfo,
|
||||||
sizeof( waveInfo )
|
sizeof(waveInfo));
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_audioBlockAlign = channelCount * ( sampleBits >> 3 );
|
m_audioBlockAlign = channelCount * (sampleBits >> 3);
|
||||||
m_audioFrameSize = channelCount * ( sampleBits >> 3 ) * ( sampleRate / m_frameRate );
|
m_audioFrameSize = channelCount * (sampleBits >> 3) * (sampleRate / m_frameRate);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AVIWrite::AddVideoFrame(LPVOID imageData)
|
||||||
bool AVIWrite::AddVideoFrame( LPVOID imageData )
|
|
||||||
{
|
{
|
||||||
if( !m_videoStream || m_failed ) return false;
|
if (!m_videoStream || m_failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT err = 0;
|
HRESULT err = 0;
|
||||||
|
|
||||||
|
@ -242,10 +229,9 @@ bool AVIWrite::AddVideoFrame( LPVOID imageData )
|
||||||
m_videoFrameSize,
|
m_videoFrameSize,
|
||||||
AVIIF_KEYFRAME,
|
AVIIF_KEYFRAME,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -255,10 +241,10 @@ bool AVIWrite::AddVideoFrame( LPVOID imageData )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AVIWrite::AddAudioFrame(LPVOID soundData)
|
||||||
bool AVIWrite::AddAudioFrame( LPVOID soundData )
|
|
||||||
{
|
{
|
||||||
if( !m_audioStream || m_failed ) return false;
|
if (!m_audioStream || m_failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT err = 0;
|
HRESULT err = 0;
|
||||||
|
|
||||||
|
@ -270,10 +256,9 @@ bool AVIWrite::AddAudioFrame( LPVOID soundData )
|
||||||
m_audioFrameSize,
|
m_audioFrameSize,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL);
|
||||||
);
|
|
||||||
|
|
||||||
if( FAILED( err ) ) {
|
if (FAILED(err)) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#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();
|
||||||
|
|
||||||
|
@ -15,7 +14,7 @@ class AVIWrite
|
||||||
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;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
#include "../AutoBuild.h"
|
#include "../AutoBuild.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -11,7 +11,6 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AboutDialog dialog
|
// AboutDialog dialog
|
||||||
|
|
||||||
|
|
||||||
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
|
AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(AboutDialog::IDD, pParent)
|
: CDialog(AboutDialog::IDD, pParent)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +18,6 @@ AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/)
|
||||||
m_date = _T(__DATE__);
|
m_date = _T(__DATE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AboutDialog::DoDataExchange(CDataExchange* pDX)
|
void AboutDialog::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
|
@ -30,21 +28,20 @@ void AboutDialog::DoDataExchange(CDataExchange* pDX)
|
||||||
DDX_Text(pDX, IDC_DATE, m_date);
|
DDX_Text(pDX, IDC_DATE, m_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
|
BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
|
||||||
//{{AFX_MSG_MAP(AboutDialog)
|
//{{AFX_MSG_MAP(AboutDialog)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,17 @@
|
||||||
#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;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "vba.h"
|
|
||||||
#include "AccelEditor.h"
|
#include "AccelEditor.h"
|
||||||
#include "CmdAccelOb.h"
|
#include "CmdAccelOb.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "vba.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -12,7 +12,6 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// AccelEditor dialog
|
// AccelEditor dialog
|
||||||
|
|
||||||
|
|
||||||
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
|
AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
|
||||||
: ResizeDlg(AccelEditor::IDD, pParent)
|
: ResizeDlg(AccelEditor::IDD, pParent)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +21,6 @@ AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/)
|
||||||
mgr = theApp.winAccelMgr;
|
mgr = theApp.winAccelMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AccelEditor::DoDataExchange(CDataExchange* pDX)
|
void AccelEditor::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
|
@ -34,39 +32,38 @@ void AccelEditor::DoDataExchange(CDataExchange* pDX)
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
|
BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
|
||||||
//{{AFX_MSG_MAP(AccelEditor)
|
//{{AFX_MSG_MAP(AccelEditor)
|
||||||
ON_BN_CLICKED(ID_OK, OnOk)
|
ON_BN_CLICKED(ID_OK, OnOk)
|
||||||
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,
|
||||||
|
@ -88,7 +85,7 @@ void AccelEditor::InitCommands()
|
||||||
|
|
||||||
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);
|
||||||
|
@ -140,7 +137,6 @@ void AccelEditor::OnSelchangeCommands()
|
||||||
}
|
}
|
||||||
// Init the key editor
|
// Init the key editor
|
||||||
// m_pKey->ResetKey();
|
// m_pKey->ResetKey();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccelEditor::OnReset()
|
void AccelEditor::OnReset()
|
||||||
|
@ -257,13 +253,13 @@ void AccelEditor::OnRemove()
|
||||||
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)");
|
systemMessage(0, "internal error (CAccelDlgHelper::Remove : pAccel unavailable)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
systemMessage(0,"internal error (CAccelDlgHelper::Remove : Lookup failed)");
|
systemMessage(0, "internal error (CAccelDlgHelper::Remove : Lookup failed)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,12 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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)
|
||||||
|
@ -33,12 +32,12 @@ class AccelEditor : public ResizeDlg
|
||||||
// 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();
|
||||||
|
|
|
@ -26,20 +26,18 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "VBA.h"
|
#include "VBA.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "AcceleratorManager.h"
|
#include "AcceleratorManager.h"
|
||||||
#include "Reg.h"
|
#include "Reg.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#undef THIS_FILE
|
#undef THIS_FILE
|
||||||
static char THIS_FILE[]=__FILE__;
|
static char THIS_FILE[] = __FILE__;
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Constructor/Destructor
|
// Constructor/Destructor
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -55,7 +53,6 @@ CAcceleratorManager::CAcceleratorManager()
|
||||||
m_bDefaultTable = false;
|
m_bDefaultTable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -70,7 +67,6 @@ CAcceleratorManager::~CAcceleratorManager()
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Internal fcts
|
// Internal fcts
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -96,7 +92,6 @@ void CAcceleratorManager::Reset()
|
||||||
m_mapAccelTableSaved.RemoveAll();
|
m_mapAccelTableSaved.RemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -119,8 +114,7 @@ bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTS
|
||||||
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
||||||
while (pos != NULL) {
|
while (pos != NULL) {
|
||||||
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
||||||
if (pAccel->m_cVirt == cVirt &&
|
if (pAccel->m_cVirt == cVirt && pAccel->m_wKey == wKey)
|
||||||
pAccel->m_wKey == wKey)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// Adding the accelerator
|
// Adding the accelerator
|
||||||
|
@ -136,7 +130,6 @@ bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTS
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Debug fcts
|
// Debug fcts
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -174,7 +167,6 @@ void CAcceleratorManager::Dump(CDumpContext& dc) const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -187,7 +179,6 @@ void CAcceleratorManager::Connect(CWnd* pWnd, bool bAutoSave)
|
||||||
m_bAutoSave = bAutoSave;
|
m_bAutoSave = bAutoSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -201,7 +192,6 @@ bool CAcceleratorManager::GetRegKey(HKEY& hRegKey, CString& szRegKey)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -215,7 +205,6 @@ bool CAcceleratorManager::SetRegKey(HKEY hRegKey, LPCTSTR szRegKey)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Update the application's ACCELs table
|
// Update the application's ACCELs table
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -285,7 +274,6 @@ bool CAcceleratorManager::UpdateWndTable()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Create/Destroy accelerators
|
// Create/Destroy accelerators
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -314,7 +302,6 @@ bool CAcceleratorManager::DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wKey)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -337,7 +324,6 @@ bool CAcceleratorManager::DeleteEntry(WORD wIDCommand)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -352,7 +338,6 @@ bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -363,7 +348,6 @@ bool CAcceleratorManager::SetAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTS
|
||||||
return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked);
|
return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -389,7 +373,6 @@ bool CAcceleratorManager::AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bo
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -409,7 +392,6 @@ bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Get a string from the ACCEL definition
|
// Get a string from the ACCEL definition
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -428,7 +410,6 @@ bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -443,7 +424,6 @@ bool CAcceleratorManager::GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& sz
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Copy function
|
// Copy function
|
||||||
//
|
//
|
||||||
|
@ -493,19 +473,19 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
||||||
info.dwOSVersionInfoSize = sizeof(info);
|
info.dwOSVersionInfoSize = sizeof(info);
|
||||||
GetVersionEx(&info);
|
GetVersionEx(&info);
|
||||||
|
|
||||||
if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
||||||
MENUITEMINFO info;
|
MENUITEMINFO info;
|
||||||
char ss[128];
|
char ss[128];
|
||||||
ZeroMemory(&info, sizeof(info));
|
ZeroMemory(&info, sizeof(info));
|
||||||
info.cbSize = sizeof(info) - sizeof(HBITMAP);
|
info.cbSize = sizeof(info) - sizeof(HBITMAP);
|
||||||
info.fMask = MIIM_ID | MIIM_SUBMENU;
|
info.fMask = MIIM_ID | MIIM_SUBMENU;
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
GetMenuItemInfo(menu, i, TRUE, &info);
|
GetMenuItemInfo(menu, i, TRUE, &info);
|
||||||
|
|
||||||
if(info.hSubMenu != NULL) {
|
if (info.hSubMenu != NULL) {
|
||||||
UpdateMenu(info.hSubMenu);
|
UpdateMenu(info.hSubMenu);
|
||||||
} else {
|
} else {
|
||||||
if(info.wID != (UINT)-1) {
|
if (info.wID != (UINT)-1) {
|
||||||
MENUITEMINFO info2;
|
MENUITEMINFO info2;
|
||||||
ZeroMemory(&info2, sizeof(info2));
|
ZeroMemory(&info2, sizeof(info2));
|
||||||
info2.cbSize = sizeof(info2) - sizeof(HBITMAP);
|
info2.cbSize = sizeof(info2) - sizeof(HBITMAP);
|
||||||
|
@ -515,16 +495,16 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
||||||
GetMenuItemInfo(menu, i, MF_BYPOSITION, &info2);
|
GetMenuItemInfo(menu, i, MF_BYPOSITION, &info2);
|
||||||
CString str = ss;
|
CString str = ss;
|
||||||
int index = str.Find('\t');
|
int index = str.Find('\t');
|
||||||
if(index != -1)
|
if (index != -1)
|
||||||
str = str.Left(index);
|
str = str.Left(index);
|
||||||
|
|
||||||
WORD command = info.wID;
|
WORD command = info.wID;
|
||||||
|
|
||||||
CCmdAccelOb *o;
|
CCmdAccelOb* o;
|
||||||
if(m_mapAccelTable.Lookup(command, o)) {
|
if (m_mapAccelTable.Lookup(command, o)) {
|
||||||
if(o->m_Accels.GetCount()) {
|
if (o->m_Accels.GetCount()) {
|
||||||
POSITION pos = o->m_Accels.GetHeadPosition();
|
POSITION pos = o->m_Accels.GetHeadPosition();
|
||||||
CAccelsOb *accel = o->m_Accels.GetNext(pos);
|
CAccelsOb* accel = o->m_Accels.GetNext(pos);
|
||||||
|
|
||||||
CString s;
|
CString s;
|
||||||
accel->GetString(s);
|
accel->GetString(s);
|
||||||
|
@ -532,7 +512,7 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
||||||
str += s;
|
str += s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(str != ss)
|
if (str != ss)
|
||||||
ModifyMenu(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
|
ModifyMenu(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,13 +525,13 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
||||||
ZeroMemory(&info, sizeof(info));
|
ZeroMemory(&info, sizeof(info));
|
||||||
info.cbSize = sizeof(info);
|
info.cbSize = sizeof(info);
|
||||||
info.fMask = MIIM_ID | MIIM_SUBMENU;
|
info.fMask = MIIM_ID | MIIM_SUBMENU;
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
GetMenuItemInfo(menu, i, TRUE, &info);
|
GetMenuItemInfo(menu, i, TRUE, &info);
|
||||||
|
|
||||||
if(info.hSubMenu != NULL) {
|
if (info.hSubMenu != NULL) {
|
||||||
UpdateMenu(info.hSubMenu);
|
UpdateMenu(info.hSubMenu);
|
||||||
} else {
|
} else {
|
||||||
if(info.wID != (WORD)-1) {
|
if (info.wID != (WORD)-1) {
|
||||||
MENUITEMINFOW info2;
|
MENUITEMINFOW info2;
|
||||||
ZeroMemory(&info2, sizeof(info2));
|
ZeroMemory(&info2, sizeof(info2));
|
||||||
info2.cbSize = sizeof(info2);
|
info2.cbSize = sizeof(info2);
|
||||||
|
@ -562,17 +542,17 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
||||||
|
|
||||||
wcscpy(str, ss);
|
wcscpy(str, ss);
|
||||||
|
|
||||||
wchar_t *p = wcschr(str, '\t');
|
wchar_t* p = wcschr(str, '\t');
|
||||||
if(p)
|
if (p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
CCmdAccelOb *o;
|
CCmdAccelOb* o;
|
||||||
WORD command = info.wID;
|
WORD command = info.wID;
|
||||||
if(m_mapAccelTable.Lookup(command, o)) {
|
if (m_mapAccelTable.Lookup(command, o)) {
|
||||||
if(o->m_Accels.GetCount()) {
|
if (o->m_Accels.GetCount()) {
|
||||||
POSITION pos = o->m_Accels.GetHeadPosition();
|
POSITION pos = o->m_Accels.GetHeadPosition();
|
||||||
|
|
||||||
CAccelsOb *accel = o->m_Accels.GetNext(pos);
|
CAccelsOb* accel = o->m_Accels.GetNext(pos);
|
||||||
|
|
||||||
CString s;
|
CString s;
|
||||||
accel->GetString(s);
|
accel->GetString(s);
|
||||||
|
@ -582,13 +562,13 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
||||||
temp[1] = 0;
|
temp[1] = 0;
|
||||||
wcscat(str, temp);
|
wcscat(str, temp);
|
||||||
p = temp;
|
p = temp;
|
||||||
for(const char *sp = s; *sp; sp++)
|
for (const char* sp = s; *sp; sp++)
|
||||||
*p++ = *sp;
|
*p++ = *sp;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
wcscat(str, temp);
|
wcscat(str, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(wcscmp(str,ss))
|
if (wcscmp(str, ss))
|
||||||
ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
|
ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,27 +588,27 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
|
||||||
m_hRegKey = hRegKey;
|
m_hRegKey = hRegKey;
|
||||||
m_szRegKey = szRegKey;
|
m_szRegKey = szRegKey;
|
||||||
|
|
||||||
DWORD data[2048/sizeof(DWORD)];
|
DWORD data[2048 / sizeof(DWORD)];
|
||||||
|
|
||||||
DWORD len = sizeof(data);
|
DWORD len = sizeof(data);
|
||||||
if(regQueryBinaryValue("keyboard", (char *)data, len)) {
|
if (regQueryBinaryValue("keyboard", (char*)data, len)) {
|
||||||
int count = len/sizeof(DWORD);
|
int count = len / sizeof(DWORD);
|
||||||
|
|
||||||
CCmdAccelOb* pCmdAccel;
|
CCmdAccelOb* pCmdAccel;
|
||||||
CAccelsOb* pAccel;
|
CAccelsOb* pAccel;
|
||||||
DWORD dwIDAccelData, dwAccelData;
|
DWORD dwIDAccelData, dwAccelData;
|
||||||
BOOL bExistID;
|
BOOL bExistID;
|
||||||
int iIndex = 0;
|
int iIndex = 0;
|
||||||
if(count) {
|
if (count) {
|
||||||
WORD wKey;
|
WORD wKey;
|
||||||
POSITION pos = m_mapAccelTable.GetStartPosition();
|
POSITION pos = m_mapAccelTable.GetStartPosition();
|
||||||
|
|
||||||
while(pos != NULL) {
|
while (pos != NULL) {
|
||||||
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
|
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
|
||||||
pCmdAccel->DeleteUserAccels();
|
pCmdAccel->DeleteUserAccels();
|
||||||
}
|
}
|
||||||
|
|
||||||
while(iIndex < count) {
|
while (iIndex < count) {
|
||||||
dwIDAccelData = data[iIndex++];
|
dwIDAccelData = data[iIndex++];
|
||||||
|
|
||||||
WORD wIDCommand = LOWORD(dwIDAccelData);
|
WORD wIDCommand = LOWORD(dwIDAccelData);
|
||||||
|
@ -654,7 +634,6 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -670,7 +649,6 @@ bool CAcceleratorManager::Load()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -709,13 +687,13 @@ bool CAcceleratorManager::Write()
|
||||||
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
|
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
|
||||||
|
|
||||||
INT_PTR count = AccelsDatasArray.GetSize();
|
INT_PTR count = AccelsDatasArray.GetSize();
|
||||||
DWORD *data = (DWORD *)malloc(count * sizeof(DWORD));
|
DWORD* data = (DWORD*)malloc(count * sizeof(DWORD));
|
||||||
ASSERT(data != NULL);
|
ASSERT(data != NULL);
|
||||||
|
|
||||||
for(int index = 0; index < count; index++)
|
for (int index = 0; index < count; index++)
|
||||||
data[index] = AccelsDatasArray[index];
|
data[index] = AccelsDatasArray[index];
|
||||||
|
|
||||||
regSetBinaryValue("keyboard", (char *)data, (int)(count*sizeof(DWORD)));
|
regSetBinaryValue("keyboard", (char*)data, (int)(count * sizeof(DWORD)));
|
||||||
|
|
||||||
AccelsDatasArray.RemoveAll();
|
AccelsDatasArray.RemoveAll();
|
||||||
CmdDatasArray.RemoveAll();
|
CmdDatasArray.RemoveAll();
|
||||||
|
@ -725,7 +703,6 @@ bool CAcceleratorManager::Write()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Defaults values management.
|
// Defaults values management.
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -773,7 +750,6 @@ bool CAcceleratorManager::CreateDefaultTable()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
|
@ -37,30 +37,29 @@
|
||||||
// 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();
|
||||||
|
@ -83,7 +82,7 @@ class CAcceleratorManager : public CObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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()
|
||||||
{
|
{
|
||||||
|
@ -95,8 +94,8 @@ class CAcceleratorManager : public CObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -113,23 +112,23 @@ class CAcceleratorManager : public CObject
|
||||||
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;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "vba.h"
|
|
||||||
#include "Associate.h"
|
#include "Associate.h"
|
||||||
#include "Reg.h"
|
#include "Reg.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "vba.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -12,7 +12,6 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Associate dialog
|
// Associate dialog
|
||||||
|
|
||||||
|
|
||||||
Associate::Associate(CWnd* pParent /*=NULL*/)
|
Associate::Associate(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(Associate::IDD, pParent)
|
: CDialog(Associate::IDD, pParent)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +27,6 @@ Associate::Associate(CWnd* pParent /*=NULL*/)
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Associate::DoDataExchange(CDataExchange* pDX)
|
void Associate::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
|
@ -44,15 +42,14 @@ void Associate::DoDataExchange(CDataExchange* pDX)
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(Associate, CDialog)
|
BEGIN_MESSAGE_MAP(Associate, CDialog)
|
||||||
//{{AFX_MSG_MAP(Associate)
|
//{{AFX_MSG_MAP(Associate)
|
||||||
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
||||||
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()
|
||||||
|
@ -75,23 +72,23 @@ 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" };
|
||||||
|
@ -102,9 +99,9 @@ void Associate::OnOk()
|
||||||
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,10 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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)
|
||||||
|
@ -32,12 +31,12 @@ class Associate : public CDialog
|
||||||
// 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();
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
#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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
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();
|
||||||
|
@ -54,59 +53,59 @@ void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
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:
|
||||||
|
@ -117,13 +116,11 @@ BOOL AudioCoreSettingsDlg::OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResul
|
||||||
return i_provided_tooltip_with_text;
|
return i_provided_tooltip_with_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
|
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
|
||||||
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
|
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
|
||||||
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
|
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
// AudioCoreSettingsDlg message handlers
|
// AudioCoreSettingsDlg message handlers
|
||||||
|
|
||||||
BOOL AudioCoreSettingsDlg::OnInitDialog()
|
BOOL AudioCoreSettingsDlg::OnInitDialog()
|
||||||
|
@ -132,41 +129,41 @@ BOOL AudioCoreSettingsDlg::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;
|
||||||
}
|
}
|
||||||
|
@ -178,8 +175,8 @@ BOOL AudioCoreSettingsDlg::OnInitDialog()
|
||||||
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);
|
||||||
|
@ -187,5 +184,5 @@ BOOL AudioCoreSettingsDlg::PreTranslateMessage(MSG* pMsg)
|
||||||
|
|
||||||
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
|
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
|
||||||
{
|
{
|
||||||
volume.SetPos( 100 );
|
volume.SetPos(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -17,24 +16,24 @@ class AudioCoreSettingsDlg : public CDialog
|
||||||
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;
|
||||||
|
@ -43,6 +42,6 @@ class AudioCoreSettingsDlg : public CDialog
|
||||||
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,9 +1,8 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "VBA.h"
|
#include "VBA.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "BIOSDialog.h"
|
#include "BIOSDialog.h"
|
||||||
|
|
||||||
|
|
||||||
// BIOSDialog dialog
|
// BIOSDialog dialog
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
|
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
|
||||||
|
@ -36,35 +35,33 @@ void BIOSDialog::DoDataExchange(CDataExchange* pDX)
|
||||||
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("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,18 +72,18 @@ void BIOSDialog::OnBnClickedSelectGbBiosPath()
|
||||||
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("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,18 +94,18 @@ void BIOSDialog::OnBnClickedSelectGbcBiosPath()
|
||||||
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("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,20 +116,20 @@ void BIOSDialog::OnBnClickedSelectGbaBiosPath()
|
||||||
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,31 +2,30 @@
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
|
@ -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,7 +15,7 @@ bool BitmapControl::isRegistered = false;
|
||||||
|
|
||||||
IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
|
IMPLEMENT_DYNCREATE(BitmapControl, CScrollView)
|
||||||
|
|
||||||
BitmapControl::BitmapControl()
|
BitmapControl::BitmapControl()
|
||||||
{
|
{
|
||||||
w = 0;
|
w = 0;
|
||||||
h = 0;
|
h = 0;
|
||||||
|
@ -32,16 +32,15 @@ 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()
|
||||||
|
@ -62,16 +61,16 @@ void BitmapControl::OnDraw(CDC* dc)
|
||||||
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;
|
||||||
|
|
||||||
|
@ -107,11 +106,10 @@ void BitmapControl::OnDraw(CDC* dc)
|
||||||
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)
|
if (boxreigon.right != 0 && boxreigon.bottom != 0) {
|
||||||
{
|
|
||||||
CBrush br = CBrush(RGB(255, 0, 0));
|
CBrush br = CBrush(RGB(255, 0, 0));
|
||||||
dc->FrameRect(&boxreigon, &br);
|
dc->FrameRect(&boxreigon, &br);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +144,7 @@ BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,14 +154,14 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
||||||
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);
|
||||||
|
|
||||||
|
@ -173,15 +171,13 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
||||||
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 {
|
} else {
|
||||||
POINT p;
|
POINT p;
|
||||||
|
@ -191,41 +187,37 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
||||||
p.x += x;
|
p.x += x;
|
||||||
p.y += y;
|
p.y += y;
|
||||||
|
|
||||||
if(p.x >= w ||
|
if (p.x >= w || p.y >= h)
|
||||||
p.y >= h)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
point = p.x | (p.y<<16);
|
point = p.x | (p.y << 16);
|
||||||
|
|
||||||
int xxx = p.x / 8;
|
int xxx = p.x / 8;
|
||||||
int yyy = p.y / 8;
|
int yyy = p.y / 8;
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
memcpy(&colors[i*3*8], &data[xxx * 8 * 3 +
|
memcpy(&colors[i * 3 * 8], &data[xxx * 8 * 3 + w * yyy * 8 * 3 + i * w * 3], 8 * 3);
|
||||||
w * yyy * 8 * 3 +
|
|
||||||
i * w * 3], 8 * 3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetParent()->SendMessage(WM_MAPINFO,
|
GetParent()->SendMessage(WM_MAPINFO,
|
||||||
point,
|
point,
|
||||||
(LPARAM)colors);
|
(LPARAM)colors);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapControl::setBmpInfo(BITMAPINFO *info)
|
void BitmapControl::setBmpInfo(BITMAPINFO* info)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -246,10 +238,9 @@ 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;
|
||||||
|
@ -267,7 +258,7 @@ void BitmapControl::registerClass()
|
||||||
|
|
||||||
void BitmapControl::setStretch(bool b)
|
void BitmapControl::setStretch(bool b)
|
||||||
{
|
{
|
||||||
if(b != stretch) {
|
if (b != stretch) {
|
||||||
stretch = b;
|
stretch = b;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,58 +16,57 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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,7 +42,6 @@ static char THIS_FILE[] = __FILE__;
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// BugReport dialog
|
// BugReport dialog
|
||||||
|
|
||||||
|
|
||||||
BugReport::BugReport(CWnd* pParent /*=NULL*/)
|
BugReport::BugReport(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(BugReport::IDD, pParent)
|
: CDialog(BugReport::IDD, pParent)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +50,6 @@ BugReport::BugReport(CWnd* pParent /*=NULL*/)
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BugReport::DoDataExchange(CDataExchange* pDX)
|
void BugReport::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
|
@ -60,15 +58,14 @@ void BugReport::DoDataExchange(CDataExchange* pDX)
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(BugReport, CDialog)
|
BEGIN_MESSAGE_MAP(BugReport, CDialog)
|
||||||
//{{AFX_MSG_MAP(BugReport)
|
//{{AFX_MSG_MAP(BugReport)
|
||||||
ON_BN_CLICKED(IDC_COPY, OnCopy)
|
ON_BN_CLICKED(IDC_COPY, OnCopy)
|
||||||
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()
|
||||||
|
@ -89,9 +86,9 @@ void BugReport::OnCopy()
|
||||||
// Lock the handle and copy the text to the buffer.
|
// Lock the handle and copy the text to the buffer.
|
||||||
|
|
||||||
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
|
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
|
||||||
memcpy(lptstrCopy, (const char *)report,
|
memcpy(lptstrCopy, (const char*)report,
|
||||||
report.GetLength() * sizeof(CHAR));
|
report.GetLength() * sizeof(CHAR));
|
||||||
lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character
|
lptstrCopy[report.GetLength()] = (TCHAR)0; // null character
|
||||||
GlobalUnlock(hglbCopy);
|
GlobalUnlock(hglbCopy);
|
||||||
|
|
||||||
// Place the handle on the clipboard.
|
// Place the handle on the clipboard.
|
||||||
|
@ -123,8 +120,7 @@ BOOL BugReport::OnInitDialog()
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AppendFormat(CString& report, const char* format, ...)
|
||||||
static void AppendFormat(CString& report, const char *format, ...)
|
|
||||||
{
|
{
|
||||||
CString buffer;
|
CString buffer;
|
||||||
va_list valist;
|
va_list valist;
|
||||||
|
@ -149,61 +145,61 @@ CString BugReport::createReport()
|
||||||
#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++;
|
p++;
|
||||||
}
|
}
|
||||||
if(res.GetLength() > 0)
|
if (res.GetLength() > 0)
|
||||||
AppendFormat(report, "Cart Save : %s\r\n", res);
|
AppendFormat(report, "Cart Save : %s\r\n", res);
|
||||||
} else if(theApp.cartridgeType == 1) {
|
} else if (theApp.cartridgeType == 1) {
|
||||||
strncpy(buffer, (const char *)&gbRom[0x134], 15);
|
strncpy(buffer, (const char*)&gbRom[0x134], 15);
|
||||||
buffer[15] = 0;
|
buffer[15] = 0;
|
||||||
AppendFormat(report, "Game title : %s\r\n", buffer);
|
AppendFormat(report, "Game title : %s\r\n", buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,10 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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)
|
||||||
|
@ -44,12 +43,12 @@ class BugReport : public CDialog
|
||||||
// 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
|
||||||
|
|
|
@ -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,21 +171,18 @@ 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
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -200,7 +195,6 @@ CAccelsOb::CAccelsOb()
|
||||||
m_bLocked = false;
|
m_bLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -213,7 +207,6 @@ CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
|
||||||
m_bLocked = pFrom->m_bLocked;
|
m_bLocked = pFrom->m_bLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -224,7 +217,6 @@ CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
|
||||||
m_bLocked = bLocked;
|
m_bLocked = bLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -237,7 +229,6 @@ CAccelsOb::CAccelsOb(LPACCEL pACCEL)
|
||||||
m_bLocked = false;
|
m_bLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -250,7 +241,6 @@ CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -281,7 +271,6 @@ void CAccelsOb::GetString(CString& szBuffer)
|
||||||
AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
|
AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -290,7 +279,6 @@ bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
|
||||||
// CString szTemp;
|
// CString szTemp;
|
||||||
// GetString(szTemp);
|
// GetString(szTemp);
|
||||||
|
|
||||||
|
|
||||||
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
|
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
|
||||||
bool bRet = (bCtrl == m_bCtrl);
|
bool bRet = (bCtrl == m_bCtrl);
|
||||||
|
|
||||||
|
@ -305,7 +293,6 @@ bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -321,7 +308,6 @@ DWORD CAccelsOb::GetData()
|
||||||
return MAKELONG(m_wKey, bCodes);
|
return MAKELONG(m_wKey, bCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -356,7 +342,6 @@ void CAccelsOb::Dump(CDumpContext& dc) const
|
||||||
dc << "\t\t";
|
dc << "\t\t";
|
||||||
CObject::Dump(dc);
|
CObject::Dump(dc);
|
||||||
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
|
dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -369,7 +354,6 @@ CCmdAccelOb::CCmdAccelOb()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -381,7 +365,6 @@ CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
|
||||||
m_szCommand = szCommand;
|
m_szCommand = szCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -397,7 +380,6 @@ CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szComma
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -409,7 +391,6 @@ CCmdAccelOb::~CCmdAccelOb()
|
||||||
m_Accels.RemoveAll();
|
m_Accels.RemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -422,7 +403,6 @@ void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked)
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -432,7 +412,6 @@ void CCmdAccelOb::Add(CAccelsOb* pAccel)
|
||||||
m_Accels.AddTail(pAccel);
|
m_Accels.AddTail(pAccel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -453,7 +432,6 @@ CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -472,7 +450,6 @@ void CCmdAccelOb::DeleteUserAccels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -501,15 +478,14 @@ void CCmdAccelOb::AssertValid() const
|
||||||
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;
|
||||||
|
|
|
@ -46,29 +46,28 @@ 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;
|
||||||
|
@ -77,34 +76,33 @@ class CAccelsOb : public CObject
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
class CCmdAccelOb : public CObject
|
class CCmdAccelOb : public CObject {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
CCmdAccelOb();
|
CCmdAccelOb();
|
||||||
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
|
CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand);
|
||||||
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
|
||||||
|
@ -23,14 +23,13 @@ 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()
|
||||||
|
@ -55,19 +54,18 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -83,14 +81,14 @@ void ColorButton::setColor(u16 c)
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -11,18 +11,17 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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);
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ class ColorButton : public CButton
|
||||||
//}}AFX_VIRTUAL
|
//}}AFX_VIRTUAL
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
void setColor(u16 c);
|
void setColor(u16 c);
|
||||||
u16 color;
|
u16 color;
|
||||||
virtual ~ColorButton();
|
virtual ~ColorButton();
|
||||||
|
@ -40,7 +39,7 @@ class ColorButton : public CButton
|
||||||
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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
#include "ColorControl.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "ColorControl.h"
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
|
@ -23,16 +23,14 @@ 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()
|
||||||
|
@ -47,11 +45,11 @@ BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
|
||||||
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;
|
||||||
|
@ -65,7 +63,7 @@ void ColorControl::setColor(u16 c)
|
||||||
|
|
||||||
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;
|
||||||
|
@ -73,7 +71,7 @@ void ColorControl::registerClass()
|
||||||
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);
|
||||||
|
|
|
@ -11,38 +11,37 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// 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,18 +1,18 @@
|
||||||
#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 },
|
||||||
|
@ -206,12 +206,12 @@ struct {
|
||||||
{ "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;
|
||||||
|
@ -222,11 +222,10 @@ bool winAccelGetID(const char *command, WORD& id)
|
||||||
|
|
||||||
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++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if(!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
|
if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
|
||||||
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
|
mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
#ifndef NO_D3D
|
#ifndef NO_D3D
|
||||||
|
|
||||||
#pragma comment( lib, "d3d9" )
|
#pragma comment(lib, "d3d9")
|
||||||
#pragma comment( lib, "d3dx9" )
|
#pragma comment(lib, "d3dx9")
|
||||||
#pragma comment( lib, "DxErr" )
|
#pragma comment(lib, "DxErr")
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
|
||||||
#include "MainWnd.h"
|
|
||||||
#include "FullscreenSettings.h"
|
#include "FullscreenSettings.h"
|
||||||
|
#include "MainWnd.h"
|
||||||
|
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
#include "../gba/GBA.h"
|
|
||||||
#include "../gba/Globals.h"
|
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../gb/gbGlobals.h"
|
#include "../gb/gbGlobals.h"
|
||||||
|
#include "../gba/GBA.h"
|
||||||
|
#include "../gba/Globals.h"
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
// Direct3D
|
// Direct3D
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define D3D_DEBUG_INFO
|
#define D3D_DEBUG_INFO
|
||||||
#endif
|
#endif
|
||||||
#define DIRECT3D_VERSION 0x0900
|
#define DIRECT3D_VERSION 0x0900
|
||||||
#include <d3d9.h> // main include file
|
|
||||||
#include <D3dx9core.h> // required for font rendering
|
#include <D3dx9core.h> // required for font rendering
|
||||||
#include <Dxerr.h> // contains debug functions
|
#include <Dxerr.h> // contains debug functions
|
||||||
|
#include <d3d9.h> // main include file
|
||||||
|
|
||||||
extern int Init_2xSaI(u32); // initializes all pixel filters
|
extern int Init_2xSaI(u32); // initializes all pixel filters
|
||||||
extern int systemSpeed;
|
extern int systemSpeed;
|
||||||
|
@ -36,7 +36,7 @@ extern int systemSpeed;
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
#undef THIS_FILE
|
#undef THIS_FILE
|
||||||
static char THIS_FILE[] = __FILE__;
|
static char THIS_FILE[] = __FILE__;
|
||||||
extern void log(const char *,...);
|
extern void log(const char*, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MMX
|
#ifdef MMX
|
||||||
|
@ -45,19 +45,19 @@ extern bool detectMMX();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct PFTHREAD_DATA {
|
struct PFTHREAD_DATA {
|
||||||
void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int);
|
void (*filterFunction)(u8*, u32, u8*, u8*, u32, int, int);
|
||||||
u8 *sourcePointer;
|
u8* sourcePointer;
|
||||||
u32 sourcePitch;
|
u32 sourcePitch;
|
||||||
u8 *deltaPointer;
|
u8* deltaPointer;
|
||||||
u8* destPointer;
|
u8* destPointer;
|
||||||
u32 destPitch;
|
u32 destPitch;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
DWORD WINAPI pfthread_func( LPVOID lpParameter )
|
DWORD WINAPI pfthread_func(LPVOID lpParameter)
|
||||||
{
|
{
|
||||||
PFTHREAD_DATA *data = (PFTHREAD_DATA*)lpParameter;
|
PFTHREAD_DATA* data = (PFTHREAD_DATA*)lpParameter;
|
||||||
|
|
||||||
data->filterFunction(
|
data->filterFunction(
|
||||||
data->sourcePointer,
|
data->sourcePointer,
|
||||||
|
@ -66,7 +66,7 @@ DWORD WINAPI pfthread_func( LPVOID lpParameter )
|
||||||
data->destPointer,
|
data->destPointer,
|
||||||
data->destPitch,
|
data->destPitch,
|
||||||
data->width,
|
data->width,
|
||||||
data->height );
|
data->height);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -87,10 +87,10 @@ private:
|
||||||
unsigned int textureSize;
|
unsigned int textureSize;
|
||||||
RECT destRect;
|
RECT destRect;
|
||||||
bool failed;
|
bool failed;
|
||||||
ID3DXFont *pFont;
|
ID3DXFont* pFont;
|
||||||
bool rectangleFillsScreen;
|
bool rectangleFillsScreen;
|
||||||
PFTHREAD_DATA *pfthread_data;
|
PFTHREAD_DATA* pfthread_data;
|
||||||
HANDLE *hThreads;
|
HANDLE* hThreads;
|
||||||
unsigned int nThreads;
|
unsigned int nThreads;
|
||||||
|
|
||||||
struct VERTEX {
|
struct VERTEX {
|
||||||
|
@ -109,8 +109,8 @@ private:
|
||||||
|
|
||||||
void createFont();
|
void createFont();
|
||||||
void destroyFont();
|
void destroyFont();
|
||||||
bool clearTexture( LPDIRECT3DTEXTURE9 texture, size_t textureHeight );
|
bool clearTexture(LPDIRECT3DTEXTURE9 texture, size_t textureHeight);
|
||||||
void createTexture( unsigned int textureWidth, unsigned int textureHeight );
|
void createTexture(unsigned int textureWidth, unsigned int textureHeight);
|
||||||
void destroyTexture();
|
void destroyTexture();
|
||||||
void calculateDestRect();
|
void calculateDestRect();
|
||||||
bool resetDevice();
|
bool resetDevice();
|
||||||
|
@ -126,13 +126,12 @@ public:
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual void render();
|
virtual void render();
|
||||||
|
|
||||||
virtual bool changeRenderSize( int w, int h );
|
virtual bool changeRenderSize(int w, int h);
|
||||||
virtual void resize( int w, int h );
|
virtual void resize(int w, int h);
|
||||||
virtual void setOption( const char *option, int value );
|
virtual void setOption(const char* option, int value);
|
||||||
virtual bool selectFullScreenMode( VIDEO_MODE &mode );
|
virtual bool selectFullScreenMode(VIDEO_MODE& mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Direct3DDisplay::Direct3DDisplay()
|
Direct3DDisplay::Direct3DDisplay()
|
||||||
{
|
{
|
||||||
initialized = false;
|
initialized = false;
|
||||||
|
@ -153,10 +152,10 @@ Direct3DDisplay::Direct3DDisplay()
|
||||||
pfthread_data = NULL;
|
pfthread_data = NULL;
|
||||||
hThreads = NULL;
|
hThreads = NULL;
|
||||||
nThreads = theApp.maxCpuCores;
|
nThreads = theApp.maxCpuCores;
|
||||||
if( nThreads > 8 ) nThreads = 8;
|
if (nThreads > 8)
|
||||||
|
nThreads = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Direct3DDisplay::~Direct3DDisplay()
|
Direct3DDisplay::~Direct3DDisplay()
|
||||||
{
|
{
|
||||||
cleanup();
|
cleanup();
|
||||||
|
@ -166,8 +165,8 @@ void Direct3DDisplay::prepareDisplayMode()
|
||||||
{
|
{
|
||||||
// Change display mode
|
// Change display mode
|
||||||
memset(&dpp, 0, sizeof(dpp));
|
memset(&dpp, 0, sizeof(dpp));
|
||||||
dpp.Windowed = !( videoOption >= VIDEO_320x240 );
|
dpp.Windowed = !(videoOption >= VIDEO_320x240);
|
||||||
if( !dpp.Windowed ) {
|
if (!dpp.Windowed) {
|
||||||
dpp.BackBufferFormat = (fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
|
dpp.BackBufferFormat = (fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
|
||||||
} else {
|
} else {
|
||||||
dpp.BackBufferFormat = mode.Format;
|
dpp.BackBufferFormat = mode.Format;
|
||||||
|
@ -178,15 +177,14 @@ void Direct3DDisplay::prepareDisplayMode()
|
||||||
dpp.BackBufferWidth = !dpp.Windowed ? fsWidth : surfaceSizeX;
|
dpp.BackBufferWidth = !dpp.Windowed ? fsWidth : surfaceSizeX;
|
||||||
dpp.BackBufferHeight = !dpp.Windowed ? fsHeight : surfaceSizeY;
|
dpp.BackBufferHeight = !dpp.Windowed ? fsHeight : surfaceSizeY;
|
||||||
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
|
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
|
||||||
dpp.FullScreen_RefreshRateInHz = ( dpp.Windowed == TRUE ) ? 0 : fsFrequency;
|
dpp.FullScreen_RefreshRateInHz = (dpp.Windowed == TRUE) ? 0 : fsFrequency;
|
||||||
dpp.Flags = 0;
|
dpp.Flags = 0;
|
||||||
dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||||
// D3DPRESENT_INTERVAL_ONE means VSync ON
|
// D3DPRESENT_INTERVAL_ONE means VSync ON
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// make debugging full screen easier
|
// make debugging full screen easier
|
||||||
if( dpp.Windowed == FALSE ) {
|
if (dpp.Windowed == FALSE) {
|
||||||
dpp.Windowed = TRUE;
|
dpp.Windowed = TRUE;
|
||||||
dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||||
dpp.BackBufferCount = 0;
|
dpp.BackBufferCount = 0;
|
||||||
|
@ -194,60 +192,58 @@ void Direct3DDisplay::prepareDisplayMode()
|
||||||
dpp.Flags = 0;
|
dpp.Flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE( _T("prepareDisplayMode:\n") );
|
TRACE(_T("prepareDisplayMode:\n"));
|
||||||
TRACE( _T("%i x %i @ %iHz:\n"), dpp.BackBufferWidth, dpp.BackBufferHeight, dpp.FullScreen_RefreshRateInHz );
|
TRACE(_T("%i x %i @ %iHz:\n"), dpp.BackBufferWidth, dpp.BackBufferHeight, dpp.FullScreen_RefreshRateInHz);
|
||||||
TRACE( _T("Buffer Count: %i\n"), dpp.BackBufferCount+1 );
|
TRACE(_T("Buffer Count: %i\n"), dpp.BackBufferCount + 1);
|
||||||
TRACE( _T("VSync: %i\n"), dpp.PresentationInterval==D3DPRESENT_INTERVAL_ONE );
|
TRACE(_T("VSync: %i\n"), dpp.PresentationInterval == D3DPRESENT_INTERVAL_ONE);
|
||||||
TRACE( _T("LOCKABLE_BACKBUFFER: %i\n\n"), dpp.Flags==D3DPRESENTFLAG_LOCKABLE_BACKBUFFER );
|
TRACE(_T("LOCKABLE_BACKBUFFER: %i\n\n"), dpp.Flags == D3DPRESENTFLAG_LOCKABLE_BACKBUFFER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::cleanup()
|
void Direct3DDisplay::cleanup()
|
||||||
{
|
{
|
||||||
if( hThreads ) {
|
if (hThreads) {
|
||||||
free( hThreads );
|
free(hThreads);
|
||||||
hThreads = NULL;
|
hThreads = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pfthread_data ) {
|
if (pfthread_data) {
|
||||||
free( pfthread_data );
|
free(pfthread_data);
|
||||||
pfthread_data = NULL;
|
pfthread_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyFont();
|
destroyFont();
|
||||||
destroyTexture();
|
destroyTexture();
|
||||||
|
|
||||||
if( pDevice ) {
|
if (pDevice) {
|
||||||
pDevice->Release();
|
pDevice->Release();
|
||||||
pDevice = NULL;
|
pDevice = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pD3D ) {
|
if (pD3D) {
|
||||||
pD3D->Release();
|
pD3D->Release();
|
||||||
pD3D = NULL;
|
pD3D = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Direct3DDisplay::initialize()
|
bool Direct3DDisplay::initialize()
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
TRACE( _T("Initializing Direct3D renderer {\n") );
|
TRACE(_T("Initializing Direct3D renderer {\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// load Direct3D v9
|
// load Direct3D v9
|
||||||
pD3D = Direct3DCreate9( D3D_SDK_VERSION );
|
pD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
|
|
||||||
if(pD3D == NULL) {
|
if (pD3D == NULL) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("Error creating Direct3D object"), 0 );
|
DXTRACE_ERR_MSGBOX(_T("Error creating Direct3D object"), 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pD3D->GetAdapterDisplayMode(fsAdapter, &mode);
|
pD3D->GetAdapterDisplayMode(fsAdapter, &mode);
|
||||||
screenFormat = mode.Format;
|
screenFormat = mode.Format;
|
||||||
|
|
||||||
switch(mode.Format) {
|
switch (mode.Format) {
|
||||||
case D3DFMT_X8R8G8B8:
|
case D3DFMT_X8R8G8B8:
|
||||||
systemColorDepth = 32;
|
systemColorDepth = 32;
|
||||||
systemRedShift = 19;
|
systemRedShift = 19;
|
||||||
|
@ -270,26 +266,23 @@ bool Direct3DDisplay::initialize()
|
||||||
Init_2xSaI(555);
|
Init_2xSaI(555);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DXTRACE_ERR_MSGBOX( _T("Unsupport D3D format"), 0 );
|
DXTRACE_ERR_MSGBOX(_T("Unsupport D3D format"), 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fsColorDepth = systemColorDepth;
|
fsColorDepth = systemColorDepth;
|
||||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MMX
|
#ifdef MMX
|
||||||
if(!disableMMX) {
|
if (!disableMMX) {
|
||||||
cpu_mmx = theApp.detectMMX();
|
cpu_mmx = theApp.detectMMX();
|
||||||
} else {
|
} else {
|
||||||
cpu_mmx = 0;
|
cpu_mmx = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
theApp.updateFilter();
|
theApp.updateFilter();
|
||||||
theApp.updateIFB();
|
theApp.updateIFB();
|
||||||
|
|
||||||
|
|
||||||
// create device
|
// create device
|
||||||
// Direct3D will use the selected full screen adapter for windowed mode as well
|
// Direct3D will use the selected full screen adapter for windowed mode as well
|
||||||
prepareDisplayMode();
|
prepareDisplayMode();
|
||||||
|
@ -298,67 +291,67 @@ bool Direct3DDisplay::initialize()
|
||||||
fsAdapter,
|
fsAdapter,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
theApp.m_pMainWnd->GetSafeHwnd(),
|
theApp.m_pMainWnd->GetSafeHwnd(),
|
||||||
D3DCREATE_FPU_PRESERVE |
|
D3DCREATE_FPU_PRESERVE | D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
|
||||||
&dpp,
|
&dpp,
|
||||||
&pDevice);
|
&pDevice);
|
||||||
if( FAILED( hret ) ) {
|
if (FAILED(hret)) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("Error creating Direct3D device"), hret );
|
DXTRACE_ERR_MSGBOX(_T("Error creating Direct3D device"), hret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
createFont();
|
createFont();
|
||||||
// width and height will be set from a prior call to changeRenderSize() before initialize()
|
// width and height will be set from a prior call to changeRenderSize() before initialize()
|
||||||
createTexture( width, height );
|
createTexture(width, height);
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
setOption( _T("d3dFilter"), theApp.d3dFilter );
|
setOption(_T("d3dFilter"), theApp.d3dFilter);
|
||||||
setOption( _T("motionBlur"), theApp.d3dMotionBlur );
|
setOption(_T("motionBlur"), theApp.d3dMotionBlur);
|
||||||
|
|
||||||
// create pfthread_data
|
// create pfthread_data
|
||||||
pfthread_data = (PFTHREAD_DATA*)malloc( sizeof(PFTHREAD_DATA) * nThreads );
|
pfthread_data = (PFTHREAD_DATA*)malloc(sizeof(PFTHREAD_DATA) * nThreads);
|
||||||
if( !pfthread_data ) {
|
if (!pfthread_data) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create thread handles
|
// create thread handles
|
||||||
hThreads = (HANDLE*)malloc( sizeof(HANDLE) * nThreads );
|
hThreads = (HANDLE*)malloc(sizeof(HANDLE) * nThreads);
|
||||||
if( !hThreads ) {
|
if (!hThreads) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(failed) return false;
|
if (failed)
|
||||||
|
return false;
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
TRACE( _T("} Finished Direct3D renderer initialization\n\n") );
|
TRACE(_T("} Finished Direct3D renderer initialization\n\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::clear()
|
void Direct3DDisplay::clear()
|
||||||
{
|
{
|
||||||
if( pDevice ) {
|
if (pDevice) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
pDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0xFF,0x00,0xFF), 0.0f, 0 );
|
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0xFF, 0x00, 0xFF), 0.0f, 0);
|
||||||
#else
|
#else
|
||||||
pDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0x00,0x00,0x00), 0.0f, 0 );
|
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0x00, 0x00, 0x00), 0.0f, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::render()
|
void Direct3DDisplay::render()
|
||||||
{
|
{
|
||||||
if( failed ) return;
|
if (failed)
|
||||||
if(!pDevice) return;
|
return;
|
||||||
|
if (!pDevice)
|
||||||
|
return;
|
||||||
|
|
||||||
// Multi-Tasking fix
|
// Multi-Tasking fix
|
||||||
HRESULT hr = pDevice->TestCooperativeLevel();
|
HRESULT hr = pDevice->TestCooperativeLevel();
|
||||||
if( FAILED( hr ) ) {
|
if (FAILED(hr)) {
|
||||||
switch( hr ) {
|
switch (hr) {
|
||||||
case D3DERR_DEVICELOST:
|
case D3DERR_DEVICELOST:
|
||||||
// The device has been lost but cannot be reset at this time.
|
// The device has been lost but cannot be reset at this time.
|
||||||
// Therefore, rendering is not possible.
|
// Therefore, rendering is not possible.
|
||||||
|
@ -368,12 +361,12 @@ void Direct3DDisplay::render()
|
||||||
resetDevice();
|
resetDevice();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
DXTRACE_ERR( _T("ERROR: D3D device has serious problems"), hr );
|
DXTRACE_ERR(_T("ERROR: D3D device has serious problems"), hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !rectangleFillsScreen ) {
|
if (!rectangleFillsScreen) {
|
||||||
// performance: clear only when you must
|
// performance: clear only when you must
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
@ -384,17 +377,17 @@ void Direct3DDisplay::render()
|
||||||
D3DLOCKED_RECT lr;
|
D3DLOCKED_RECT lr;
|
||||||
const RECT target = { 0, 0, width, height };
|
const RECT target = { 0, 0, width, height };
|
||||||
|
|
||||||
if( FAILED( hr = tempImage->LockRect( 0, &lr, &target, 0 ) ) ) {
|
if (FAILED(hr = tempImage->LockRect(0, &lr, &target, 0))) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
|
DXTRACE_ERR_MSGBOX(_T("Can not lock texture"), hr);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
u32 pitch = sizeX * ( systemColorDepth >> 3 ) + 4;
|
u32 pitch = sizeX * (systemColorDepth >> 3) + 4;
|
||||||
|
|
||||||
if( theApp.filterFunction ) {
|
if (theApp.filterFunction) {
|
||||||
if( filterMT ) {
|
if (filterMT) {
|
||||||
u8 *start = pix + pitch;
|
u8* start = pix + pitch;
|
||||||
int src_height_per_thread = sizeY / nThreads;
|
int src_height_per_thread = sizeY / nThreads;
|
||||||
int src_height_remaining = sizeY - ( ( sizeY / nThreads ) * nThreads );
|
int src_height_remaining = sizeY - ((sizeY / nThreads) * nThreads);
|
||||||
u32 src_bytes_per_thread = pitch * src_height_per_thread;
|
u32 src_bytes_per_thread = pitch * src_height_per_thread;
|
||||||
|
|
||||||
int dst_height_per_thread = src_height_per_thread * filterMagnification;
|
int dst_height_per_thread = src_height_per_thread * filterMagnification;
|
||||||
|
@ -409,14 +402,14 @@ void Direct3DDisplay::render()
|
||||||
|
|
||||||
// configure thread
|
// configure thread
|
||||||
pfthread_data[i].filterFunction = theApp.filterFunction;
|
pfthread_data[i].filterFunction = theApp.filterFunction;
|
||||||
pfthread_data[i].sourcePointer = start + ( i * src_bytes_per_thread );
|
pfthread_data[i].sourcePointer = start + (i * src_bytes_per_thread);
|
||||||
pfthread_data[i].sourcePitch = pitch;
|
pfthread_data[i].sourcePitch = pitch;
|
||||||
pfthread_data[i].deltaPointer = (u8*)theApp.delta; // TODO: check if thread-safe
|
pfthread_data[i].deltaPointer = (u8*)theApp.delta; // TODO: check if thread-safe
|
||||||
pfthread_data[i].destPointer = ( (u8*)lr.pBits ) + ( i * dst_bytes_per_thread );
|
pfthread_data[i].destPointer = ((u8*)lr.pBits) + (i * dst_bytes_per_thread);
|
||||||
pfthread_data[i].destPitch = lr.Pitch;
|
pfthread_data[i].destPitch = lr.Pitch;
|
||||||
pfthread_data[i].width = sizeX;
|
pfthread_data[i].width = sizeX;
|
||||||
|
|
||||||
if( i == ( nThreads - 1 ) ) {
|
if (i == (nThreads - 1)) {
|
||||||
// last thread
|
// last thread
|
||||||
pfthread_data[i].height = src_height_per_thread + src_height_remaining;
|
pfthread_data[i].height = src_height_per_thread + src_height_remaining;
|
||||||
} else {
|
} else {
|
||||||
|
@ -431,20 +424,20 @@ void Direct3DDisplay::render()
|
||||||
pfthread_func,
|
pfthread_func,
|
||||||
&pfthread_data[i],
|
&pfthread_data[i],
|
||||||
0,
|
0,
|
||||||
NULL );
|
NULL);
|
||||||
assert( hThreads[i] != NULL );
|
assert(hThreads[i] != NULL);
|
||||||
} while ( i-- );
|
} while (i--);
|
||||||
|
|
||||||
// Wait until every thread has finished.
|
// Wait until every thread has finished.
|
||||||
WaitForMultipleObjects(
|
WaitForMultipleObjects(
|
||||||
nThreads,
|
nThreads,
|
||||||
hThreads,
|
hThreads,
|
||||||
TRUE,
|
TRUE,
|
||||||
INFINITE );
|
INFINITE);
|
||||||
|
|
||||||
// Close all thread handles.
|
// Close all thread handles.
|
||||||
for( i = 0 ; i < nThreads ; i++ ) {
|
for (i = 0; i < nThreads; i++) {
|
||||||
CloseHandle( hThreads[i] );
|
CloseHandle(hThreads[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// multi-threading disabled
|
// multi-threading disabled
|
||||||
|
@ -455,67 +448,61 @@ void Direct3DDisplay::render()
|
||||||
(u8*)lr.pBits,
|
(u8*)lr.pBits,
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
sizeX,
|
sizeX,
|
||||||
sizeY
|
sizeY);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// pixel filter disabled
|
// pixel filter disabled
|
||||||
switch( systemColorDepth )
|
switch (systemColorDepth) {
|
||||||
{
|
|
||||||
case 32:
|
case 32:
|
||||||
cpyImg32(
|
cpyImg32(
|
||||||
(unsigned char *)lr.pBits,
|
(unsigned char*)lr.pBits,
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
pix + pitch,
|
pix + pitch,
|
||||||
pitch,
|
pitch,
|
||||||
sizeX,
|
sizeX,
|
||||||
sizeY
|
sizeY);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
cpyImg16(
|
cpyImg16(
|
||||||
(unsigned char *)lr.pBits,
|
(unsigned char*)lr.pBits,
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
pix + pitch,
|
pix + pitch,
|
||||||
pitch,
|
pitch,
|
||||||
sizeX,
|
sizeX,
|
||||||
sizeY
|
sizeY);
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempImage->UnlockRect( 0 );
|
tempImage->UnlockRect(0);
|
||||||
pDevice->UpdateTexture( tempImage, emulatedImage[ mbCurrentTexture ] );
|
pDevice->UpdateTexture(tempImage, emulatedImage[mbCurrentTexture]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!theApp.d3dMotionBlur) {
|
||||||
if( !theApp.d3dMotionBlur ) {
|
|
||||||
// draw the current frame to the screen
|
// draw the current frame to the screen
|
||||||
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] );
|
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
|
||||||
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
|
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||||
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
|
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX));
|
||||||
} else {
|
} else {
|
||||||
// Motion Blur enabled
|
// Motion Blur enabled
|
||||||
if( !mbTextureEmpty ) {
|
if (!mbTextureEmpty) {
|
||||||
// draw previous frame to the screen
|
// draw previous frame to the screen
|
||||||
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ^ 1 ] );
|
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture ^ 1]);
|
||||||
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
|
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||||
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
|
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX));
|
||||||
// draw the current frame with transparency to the screen
|
// draw the current frame with transparency to the screen
|
||||||
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] );
|
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
|
||||||
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 );
|
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
|
||||||
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, transpVertices, sizeof(TRANSP_VERTEX) );
|
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, transpVertices, sizeof(TRANSP_VERTEX));
|
||||||
} else {
|
} else {
|
||||||
mbTextureEmpty = false;
|
mbTextureEmpty = false;
|
||||||
// draw the current frame to the screen
|
// draw the current frame to the screen
|
||||||
pDevice->SetTexture( 0, emulatedImage[ mbCurrentTexture ] );
|
pDevice->SetTexture(0, emulatedImage[mbCurrentTexture]);
|
||||||
pDevice->SetFVF( D3DFVF_XYZRHW | D3DFVF_TEX1 );
|
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||||
pDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
|
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX));
|
||||||
}
|
}
|
||||||
mbCurrentTexture ^= 1; // switch current texture
|
mbCurrentTexture ^= 1; // switch current texture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// render speed and status messages
|
// render speed and status messages
|
||||||
D3DCOLOR color;
|
D3DCOLOR color;
|
||||||
RECT r;
|
RECT r;
|
||||||
|
@ -524,22 +511,22 @@ void Direct3DDisplay::render()
|
||||||
r.right = dpp.BackBufferWidth - 1;
|
r.right = dpp.BackBufferWidth - 1;
|
||||||
r.bottom = dpp.BackBufferHeight - 1;
|
r.bottom = dpp.BackBufferHeight - 1;
|
||||||
|
|
||||||
if( showSpeed && ( videoOption > VIDEO_6X ) ) {
|
if (showSpeed && (videoOption > VIDEO_6X)) {
|
||||||
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
|
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
if( showSpeed == 1 ) {
|
if (showSpeed == 1) {
|
||||||
sprintf( buffer, "%3d%%", systemSpeed );
|
sprintf(buffer, "%3d%%", systemSpeed);
|
||||||
} else {
|
} else {
|
||||||
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames );
|
sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFont->DrawText( NULL, buffer, -1, &r, DT_CENTER | DT_TOP, color );
|
pFont->DrawText(NULL, buffer, -1, &r, DT_CENTER | DT_TOP, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( screenMessage ) {
|
if (screenMessage) {
|
||||||
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
|
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
|
||||||
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages && pFont ) {
|
if (((GetTickCount() - theApp.screenMessageTime) < 3000) && !disableStatusMessages && pFont) {
|
||||||
pFont->DrawText( NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color );
|
pFont->DrawText(NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color);
|
||||||
} else {
|
} else {
|
||||||
screenMessage = false;
|
screenMessage = false;
|
||||||
}
|
}
|
||||||
|
@ -547,51 +534,45 @@ void Direct3DDisplay::render()
|
||||||
|
|
||||||
pDevice->EndScene();
|
pDevice->EndScene();
|
||||||
|
|
||||||
pDevice->Present( NULL, NULL, NULL, NULL );
|
pDevice->Present(NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Direct3DDisplay::changeRenderSize(int w, int h)
|
||||||
bool Direct3DDisplay::changeRenderSize( int w, int h )
|
|
||||||
{
|
{
|
||||||
if( (w != width) || (h != height) ) {
|
if ((w != width) || (h != height)) {
|
||||||
width = (unsigned int)w;
|
width = (unsigned int)w;
|
||||||
height = (unsigned int)h;
|
height = (unsigned int)h;
|
||||||
if( pDevice ) {
|
if (pDevice) {
|
||||||
destroyTexture();
|
destroyTexture();
|
||||||
createTexture( width, height );
|
createTexture(width, height);
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Direct3DDisplay::resize(int w, int h)
|
||||||
void Direct3DDisplay::resize( int w, int h )
|
|
||||||
{
|
{
|
||||||
if( !initialized ) {
|
if (!initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (w != dpp.BackBufferWidth) ||
|
if ((w != dpp.BackBufferWidth) || (h != dpp.BackBufferHeight) || (videoOption > VIDEO_6X)) {
|
||||||
(h != dpp.BackBufferHeight) ||
|
|
||||||
(videoOption > VIDEO_6X) ) {
|
|
||||||
resetDevice();
|
resetDevice();
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Direct3DDisplay::selectFullScreenMode(VIDEO_MODE& mode)
|
||||||
bool Direct3DDisplay::selectFullScreenMode( VIDEO_MODE &mode )
|
|
||||||
{
|
{
|
||||||
FullscreenSettings dlg;
|
FullscreenSettings dlg;
|
||||||
dlg.setAPI( this->getType() );
|
dlg.setAPI(this->getType());
|
||||||
INT_PTR ret = dlg.DoModal();
|
INT_PTR ret = dlg.DoModal();
|
||||||
if( ret == IDOK ) {
|
if (ret == IDOK) {
|
||||||
mode.adapter = dlg.m_device;
|
mode.adapter = dlg.m_device;
|
||||||
switch( dlg.m_colorDepth )
|
switch (dlg.m_colorDepth) {
|
||||||
{
|
|
||||||
case 30:
|
case 30:
|
||||||
// TODO: support
|
// TODO: support
|
||||||
return false;
|
return false;
|
||||||
|
@ -613,13 +594,12 @@ bool Direct3DDisplay::selectFullScreenMode( VIDEO_MODE &mode )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::createFont()
|
void Direct3DDisplay::createFont()
|
||||||
{
|
{
|
||||||
if( !pFont ) {
|
if (!pFont) {
|
||||||
HRESULT hr = D3DXCreateFont(
|
HRESULT hr = D3DXCreateFont(
|
||||||
pDevice,
|
pDevice,
|
||||||
dpp.BackBufferHeight/20, // dynamic font size
|
dpp.BackBufferHeight / 20, // dynamic font size
|
||||||
0,
|
0,
|
||||||
FW_BOLD,
|
FW_BOLD,
|
||||||
1,
|
1,
|
||||||
|
@ -629,61 +609,57 @@ void Direct3DDisplay::createFont()
|
||||||
DEFAULT_QUALITY,
|
DEFAULT_QUALITY,
|
||||||
DEFAULT_PITCH || FF_DONTCARE,
|
DEFAULT_PITCH || FF_DONTCARE,
|
||||||
_T("Arial"),
|
_T("Arial"),
|
||||||
&pFont );
|
&pFont);
|
||||||
if( FAILED( hr ) ) {
|
if (FAILED(hr)) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("createFont failed"), hr );
|
DXTRACE_ERR_MSGBOX(_T("createFont failed"), hr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::destroyFont()
|
void Direct3DDisplay::destroyFont()
|
||||||
{
|
{
|
||||||
if( pFont ) {
|
if (pFont) {
|
||||||
pFont->Release();
|
pFont->Release();
|
||||||
pFont = NULL;
|
pFont = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// fill texture completely with black
|
// fill texture completely with black
|
||||||
bool Direct3DDisplay::clearTexture( LPDIRECT3DTEXTURE9 texture, size_t textureHeight )
|
bool Direct3DDisplay::clearTexture(LPDIRECT3DTEXTURE9 texture, size_t textureHeight)
|
||||||
{
|
{
|
||||||
D3DLOCKED_RECT lr;
|
D3DLOCKED_RECT lr;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if( FAILED( hr = texture->LockRect( 0, &lr, NULL, 0 ) ) ) {
|
if (FAILED(hr = texture->LockRect(0, &lr, NULL, 0))) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
|
DXTRACE_ERR_MSGBOX(_T("Can not lock texture"), hr);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
memset( lr.pBits, 0x00, lr.Pitch * textureHeight );
|
memset(lr.pBits, 0x00, lr.Pitch * textureHeight);
|
||||||
texture->UnlockRect( 0 );
|
texture->UnlockRect(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// when either textureWidth or textureHeight is 0, last texture size will be used
|
// when either textureWidth or textureHeight is 0, last texture size will be used
|
||||||
void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int textureHeight )
|
void Direct3DDisplay::createTexture(unsigned int textureWidth, unsigned int textureHeight)
|
||||||
{
|
{
|
||||||
if( ( textureWidth != 0 ) && ( textureHeight != 0 ) ) {
|
if ((textureWidth != 0) && (textureHeight != 0)) {
|
||||||
// calculate next possible square texture size
|
// calculate next possible square texture size
|
||||||
textureSize = 1;
|
textureSize = 1;
|
||||||
unsigned int reqSizeMin = ( textureWidth > textureHeight ) ? textureWidth : textureHeight;
|
unsigned int reqSizeMin = (textureWidth > textureHeight) ? textureWidth : textureHeight;
|
||||||
while( textureSize < reqSizeMin ) {
|
while (textureSize < reqSizeMin) {
|
||||||
textureSize <<= 1; // multiply by 2
|
textureSize <<= 1; // multiply by 2
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// do not recalculate texture size
|
// do not recalculate texture size
|
||||||
|
|
||||||
if( textureSize == 0 ) {
|
if (textureSize == 0) {
|
||||||
DXTRACE_MSG( _T("Error: createTexture: textureSize == 0") );
|
DXTRACE_MSG(_T("Error: createTexture: textureSize == 0"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tempImage) {
|
||||||
if( !tempImage ) {
|
|
||||||
HRESULT hr = pDevice->CreateTexture(
|
HRESULT hr = pDevice->CreateTexture(
|
||||||
textureSize, textureSize,
|
textureSize, textureSize,
|
||||||
1, // 1 level, no mipmaps
|
1, // 1 level, no mipmaps
|
||||||
|
@ -691,20 +667,19 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
|
||||||
dpp.BackBufferFormat,
|
dpp.BackBufferFormat,
|
||||||
D3DPOOL_SYSTEMMEM,
|
D3DPOOL_SYSTEMMEM,
|
||||||
&tempImage,
|
&tempImage,
|
||||||
NULL );
|
NULL);
|
||||||
|
|
||||||
if( FAILED( hr ) ) {
|
if (FAILED(hr)) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("createTexture(temp) failed"), hr );
|
DXTRACE_ERR_MSGBOX(_T("createTexture(temp) failed"), hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize whole texture with black since we might see
|
// initialize whole texture with black since we might see
|
||||||
// the initial noise when using bilinear texture filtering
|
// the initial noise when using bilinear texture filtering
|
||||||
clearTexture( tempImage, textureSize );
|
clearTexture(tempImage, textureSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!emulatedImage[0]) {
|
||||||
if( !emulatedImage[0] ) {
|
|
||||||
HRESULT hr = pDevice->CreateTexture(
|
HRESULT hr = pDevice->CreateTexture(
|
||||||
textureSize, textureSize,
|
textureSize, textureSize,
|
||||||
1, // 1 level, no mipmaps
|
1, // 1 level, no mipmaps
|
||||||
|
@ -712,15 +687,15 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
|
||||||
dpp.BackBufferFormat,
|
dpp.BackBufferFormat,
|
||||||
D3DPOOL_DEFAULT,
|
D3DPOOL_DEFAULT,
|
||||||
&emulatedImage[0],
|
&emulatedImage[0],
|
||||||
NULL );
|
NULL);
|
||||||
|
|
||||||
if( FAILED( hr ) ) {
|
if (FAILED(hr)) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("createTexture(0) failed"), hr );
|
DXTRACE_ERR_MSGBOX(_T("createTexture(0) failed"), hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !emulatedImage[1] && theApp.d3dMotionBlur ) {
|
if (!emulatedImage[1] && theApp.d3dMotionBlur) {
|
||||||
HRESULT hr = pDevice->CreateTexture(
|
HRESULT hr = pDevice->CreateTexture(
|
||||||
textureSize, textureSize,
|
textureSize, textureSize,
|
||||||
1,
|
1,
|
||||||
|
@ -728,10 +703,10 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
|
||||||
dpp.BackBufferFormat,
|
dpp.BackBufferFormat,
|
||||||
D3DPOOL_DEFAULT,
|
D3DPOOL_DEFAULT,
|
||||||
&emulatedImage[1],
|
&emulatedImage[1],
|
||||||
NULL );
|
NULL);
|
||||||
|
|
||||||
if( FAILED( hr ) ) {
|
if (FAILED(hr)) {
|
||||||
DXTRACE_ERR_MSGBOX( _T("createTexture(1) failed"), hr );
|
DXTRACE_ERR_MSGBOX(_T("createTexture(1) failed"), hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,29 +714,27 @@ void Direct3DDisplay::createTexture( unsigned int textureWidth, unsigned int tex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::destroyTexture()
|
void Direct3DDisplay::destroyTexture()
|
||||||
{
|
{
|
||||||
if( tempImage ) {
|
if (tempImage) {
|
||||||
tempImage->Release();
|
tempImage->Release();
|
||||||
tempImage = NULL;
|
tempImage = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( emulatedImage[0] ) {
|
if (emulatedImage[0]) {
|
||||||
emulatedImage[0]->Release();
|
emulatedImage[0]->Release();
|
||||||
emulatedImage[0] = NULL;
|
emulatedImage[0] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( emulatedImage[1] ) {
|
if (emulatedImage[1]) {
|
||||||
emulatedImage[1]->Release();
|
emulatedImage[1]->Release();
|
||||||
emulatedImage[1] = NULL;
|
emulatedImage[1] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Direct3DDisplay::calculateDestRect()
|
void Direct3DDisplay::calculateDestRect()
|
||||||
{
|
{
|
||||||
if( fullScreenStretch ) {
|
if (fullScreenStretch) {
|
||||||
rectangleFillsScreen = true; // no clear() necessary
|
rectangleFillsScreen = true; // no clear() necessary
|
||||||
destRect.left = 0;
|
destRect.left = 0;
|
||||||
destRect.top = 0;
|
destRect.top = 0;
|
||||||
|
@ -772,28 +745,25 @@ void Direct3DDisplay::calculateDestRect()
|
||||||
float scaleX = (float)dpp.BackBufferWidth / (float)width;
|
float scaleX = (float)dpp.BackBufferWidth / (float)width;
|
||||||
float scaleY = (float)dpp.BackBufferHeight / (float)height;
|
float scaleY = (float)dpp.BackBufferHeight / (float)height;
|
||||||
float min = (scaleX < scaleY) ? scaleX : scaleY;
|
float min = (scaleX < scaleY) ? scaleX : scaleY;
|
||||||
if( maxScale && (min > maxScale) ) {
|
if (maxScale && (min > maxScale)) {
|
||||||
min = (float)maxScale;
|
min = (float)maxScale;
|
||||||
}
|
}
|
||||||
destRect.left = 0;
|
destRect.left = 0;
|
||||||
destRect.top = 0;
|
destRect.top = 0;
|
||||||
destRect.right = (LONG)(width * min);
|
destRect.right = (LONG)(width * min);
|
||||||
destRect.bottom = (LONG)(height * min);
|
destRect.bottom = (LONG)(height * min);
|
||||||
if( destRect.right != dpp.BackBufferWidth ) {
|
if (destRect.right != dpp.BackBufferWidth) {
|
||||||
LONG diff = (dpp.BackBufferWidth - destRect.right) / 2;
|
LONG diff = (dpp.BackBufferWidth - destRect.right) / 2;
|
||||||
destRect.left += diff;
|
destRect.left += diff;
|
||||||
destRect.right += diff;
|
destRect.right += diff;
|
||||||
}
|
}
|
||||||
if( destRect.bottom != dpp.BackBufferHeight ) {
|
if (destRect.bottom != dpp.BackBufferHeight) {
|
||||||
LONG diff = (dpp.BackBufferHeight - destRect.bottom) / 2;
|
LONG diff = (dpp.BackBufferHeight - destRect.bottom) / 2;
|
||||||
destRect.top += diff;
|
destRect.top += diff;
|
||||||
destRect.bottom += diff;
|
destRect.bottom += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( destRect.left == 0 ) &&
|
if ((destRect.left == 0) && (destRect.top == 0) && (destRect.right == dpp.BackBufferWidth) && (destRect.bottom == dpp.BackBufferHeight)) {
|
||||||
( destRect.top == 0 ) &&
|
|
||||||
( destRect.right == dpp.BackBufferWidth ) &&
|
|
||||||
( destRect.bottom == dpp.BackBufferHeight ) ) {
|
|
||||||
rectangleFillsScreen = true;
|
rectangleFillsScreen = true;
|
||||||
} else {
|
} else {
|
||||||
rectangleFillsScreen = false;
|
rectangleFillsScreen = false;
|
||||||
|
@ -830,9 +800,9 @@ void Direct3DDisplay::calculateDestRect()
|
||||||
Vertices[3].tx = textureX;
|
Vertices[3].tx = textureX;
|
||||||
Vertices[3].ty = 0.0f;
|
Vertices[3].ty = 0.0f;
|
||||||
|
|
||||||
if( theApp.d3dMotionBlur ) {
|
if (theApp.d3dMotionBlur) {
|
||||||
// configure semi-transparent triangles
|
// configure semi-transparent triangles
|
||||||
D3DCOLOR semiTrans = D3DCOLOR_ARGB( 0x7F, 0xFF, 0xFF, 0xFF );
|
D3DCOLOR semiTrans = D3DCOLOR_ARGB(0x7F, 0xFF, 0xFF, 0xFF);
|
||||||
transpVertices[0].x = Vertices[0].x;
|
transpVertices[0].x = Vertices[0].x;
|
||||||
transpVertices[0].y = Vertices[0].y;
|
transpVertices[0].y = Vertices[0].y;
|
||||||
transpVertices[0].z = Vertices[0].z;
|
transpVertices[0].z = Vertices[0].z;
|
||||||
|
@ -864,97 +834,93 @@ void Direct3DDisplay::calculateDestRect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Direct3DDisplay::setOption(const char* option, int value)
|
||||||
void Direct3DDisplay::setOption( const char *option, int value )
|
|
||||||
{
|
{
|
||||||
if( !_tcscmp( option, _T("vsync") ) ) {
|
if (!_tcscmp(option, _T("vsync"))) {
|
||||||
// value of theApp.vsync has already been changed by the menu handler
|
// value of theApp.vsync has already been changed by the menu handler
|
||||||
// 'value' has the same value as theApp.vsync
|
// 'value' has the same value as theApp.vsync
|
||||||
resetDevice();
|
resetDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !_tcscmp( option, _T("tripleBuffering") ) ) {
|
if (!_tcscmp(option, _T("tripleBuffering"))) {
|
||||||
// value of theApp.tripleBuffering has already been changed by the menu handler
|
// value of theApp.tripleBuffering has already been changed by the menu handler
|
||||||
// 'value' has the same value as theApp.tripleBuffering
|
// 'value' has the same value as theApp.tripleBuffering
|
||||||
resetDevice();
|
resetDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !_tcscmp( option, _T("d3dFilter") ) ) {
|
if (!_tcscmp(option, _T("d3dFilter"))) {
|
||||||
switch( value )
|
switch (value) {
|
||||||
{
|
|
||||||
case 0: //point
|
case 0: //point
|
||||||
pDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
|
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||||
pDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
|
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||||
break;
|
break;
|
||||||
case 1: //linear
|
case 1: //linear
|
||||||
pDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
|
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
pDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
|
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !_tcscmp( option, _T("maxScale") ) ) {
|
if (!_tcscmp(option, _T("maxScale"))) {
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !_tcscmp( option, _T("fullScreenStretch") ) ) {
|
if (!_tcscmp(option, _T("fullScreenStretch"))) {
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !_tcscmp( option, _T("motionBlur") ) ) {
|
if (!_tcscmp(option, _T("motionBlur"))) {
|
||||||
switch( value )
|
switch (value) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
mbCurrentTexture = 0;
|
mbCurrentTexture = 0;
|
||||||
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
|
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// enable vertex alpha blending
|
// enable vertex alpha blending
|
||||||
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
pDevice->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1 );
|
pDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||||
pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
|
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
|
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||||
// apply vertex alpha values to texture
|
// apply vertex alpha values to texture
|
||||||
pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
|
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
createTexture( 0, 0 ); // create the second texture
|
createTexture(0, 0); // create the second texture
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Direct3DDisplay::resetDevice()
|
bool Direct3DDisplay::resetDevice()
|
||||||
{
|
{
|
||||||
if( !pDevice ) return false;
|
if (!pDevice)
|
||||||
|
return false;
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
if( pFont ) {
|
if (pFont) {
|
||||||
// prepares font for reset
|
// prepares font for reset
|
||||||
pFont->OnLostDevice();
|
pFont->OnLostDevice();
|
||||||
}
|
}
|
||||||
destroyTexture();
|
destroyTexture();
|
||||||
prepareDisplayMode();
|
prepareDisplayMode();
|
||||||
|
|
||||||
if( FAILED( hr = pDevice->Reset( &dpp ) ) ) {
|
if (FAILED(hr = pDevice->Reset(&dpp))) {
|
||||||
DXTRACE_ERR( _T("pDevice->Reset failed\n"), hr );
|
DXTRACE_ERR(_T("pDevice->Reset failed\n"), hr);
|
||||||
failed = true;
|
failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pFont ) {
|
if (pFont) {
|
||||||
// re-aquires font resources
|
// re-aquires font resources
|
||||||
pFont->OnResetDevice();
|
pFont->OnResetDevice();
|
||||||
}
|
}
|
||||||
createTexture( 0, 0 );
|
createTexture(0, 0);
|
||||||
setOption( _T("d3dFilter"), theApp.d3dFilter );
|
setOption(_T("d3dFilter"), theApp.d3dFilter);
|
||||||
setOption( _T("motionBlur"), theApp.d3dMotionBlur );
|
setOption(_T("motionBlur"), theApp.d3dMotionBlur);
|
||||||
failed = false;
|
failed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IDisplay* newDirect3DDisplay()
|
||||||
IDisplay *newDirect3DDisplay()
|
|
||||||
{
|
{
|
||||||
return new Direct3DDisplay();
|
return new Direct3DDisplay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,8 +15,8 @@
|
||||||
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
|
||||||
|
@ -61,45 +60,39 @@ 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] = {
|
||||||
|
|
||||||
|
|
||||||
LONG_PTR defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] =
|
|
||||||
{
|
|
||||||
DIK_LEFT, DIK_RIGHT,
|
DIK_LEFT, DIK_RIGHT,
|
||||||
DIK_UP, DIK_DOWN,
|
DIK_UP, DIK_DOWN,
|
||||||
DIK_X, DIK_Z,
|
DIK_X, DIK_Z,
|
||||||
DIK_RETURN,DIK_BACK,
|
DIK_RETURN, DIK_BACK,
|
||||||
DIK_A, DIK_S,
|
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];
|
||||||
|
|
||||||
|
@ -107,24 +100,23 @@ void winReadKey(const char *name, int num, KeyList& Keys)
|
||||||
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)]);
|
||||||
|
@ -132,23 +124,22 @@ void winReadKeys()
|
||||||
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];
|
||||||
|
|
||||||
|
@ -158,20 +149,20 @@ static void winSaveKey(char *name, int num, KeyList& 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);
|
||||||
|
|
||||||
|
@ -185,8 +176,8 @@ void winSaveKeys()
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +185,7 @@ static BOOL CALLBACK EnumPovsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
|
||||||
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,
|
||||||
|
@ -204,13 +195,12 @@ static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
|
||||||
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,10 +214,8 @@ static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
numDevices++;
|
numDevices++;
|
||||||
|
|
||||||
|
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,13 +248,11 @@ static void checkKeys()
|
||||||
LONG_PTR dev = 0;
|
LONG_PTR dev = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++)
|
for (i = 0; i < (sizeof(theApp.input->joypaddata) / sizeof(theApp.input->joypaddata[0])); i++) {
|
||||||
{
|
|
||||||
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
|
if (theApp.input->joypaddata[i].IsEmpty() && defvalues[i])
|
||||||
theApp.input->joypaddata[i].AddTail(defvalues[i]);
|
theApp.input->joypaddata[i].AddTail(defvalues[i]);
|
||||||
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
|
POSITION p = theApp.input->joypaddata[i].GetHeadPosition();
|
||||||
while(p!=NULL)
|
while (p != NULL) {
|
||||||
{
|
|
||||||
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
|
LONG_PTR k = theApp.input->joypaddata[i].GetNext(p);
|
||||||
if (k > 0 && DEVICEOF(k) < numDevices)
|
if (k > 0 && DEVICEOF(k) < numDevices)
|
||||||
pDevices[DEVICEOF(k)].needed = true;
|
pDevices[DEVICEOF(k)].needed = true;
|
||||||
|
@ -274,20 +260,19 @@ static void checkKeys()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#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,8 +286,7 @@ static bool readJoystick(int joy)
|
||||||
if (pDevices[joy].isPolled)
|
if (pDevices[joy].isPolled)
|
||||||
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
||||||
|
|
||||||
HRESULT hret = pDevices[joy].device->
|
HRESULT hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
|
||||||
GetDeviceState(sizeof(DIJOYSTATE),
|
|
||||||
(LPVOID)&pDevices[joy].state);
|
(LPVOID)&pDevices[joy].state);
|
||||||
|
|
||||||
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
||||||
|
@ -313,8 +297,7 @@ static bool readJoystick(int joy)
|
||||||
if (pDevices[joy].isPolled)
|
if (pDevices[joy].isPolled)
|
||||||
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll();
|
||||||
|
|
||||||
hret = pDevices[joy].device->
|
hret = pDevices[joy].device->GetDeviceState(sizeof(DIJOYSTATE),
|
||||||
GetDeviceState(sizeof(DIJOYSTATE),
|
|
||||||
(LPVOID)&pDevices[joy].state);
|
(LPVOID)&pDevices[joy].state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,8 +320,7 @@ static void checkKeyboard()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hret = pDevices[0].device->
|
hret = pDevices[0].device->GetDeviceState(256, (LPVOID)keystate);
|
||||||
GetDeviceState(256, (LPVOID)keystate);
|
|
||||||
|
|
||||||
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
|
||||||
return;
|
return;
|
||||||
|
@ -346,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,24 +387,24 @@ static void checkJoypads()
|
||||||
|
|
||||||
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,7 +419,7 @@ 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 {
|
||||||
|
@ -458,18 +441,17 @@ BOOL checkKey(LONG_PTR key)
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
@ -506,25 +488,23 @@ bool DirectInput::initialize()
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = DirectInput8Create(
|
hr = DirectInput8Create(
|
||||||
GetModuleHandle( NULL ),
|
GetModuleHandle(NULL),
|
||||||
DIRECTINPUT_VERSION,
|
DIRECTINPUT_VERSION,
|
||||||
IID_IDirectInput8,
|
IID_IDirectInput8,
|
||||||
(LPVOID *)&pDirectInput,
|
(LPVOID*)&pDirectInput,
|
||||||
NULL );
|
NULL);
|
||||||
ASSERT( hr == DI_OK );
|
ASSERT(hr == DI_OK);
|
||||||
if( hr != DI_OK ) return false;
|
if (hr != DI_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||||
DIEnumDevicesCallback2,
|
DIEnumDevicesCallback2,
|
||||||
NULL,
|
NULL,
|
||||||
DIEDFL_ATTACHEDONLY);
|
DIEDFL_ATTACHEDONLY);
|
||||||
|
|
||||||
|
pDevices = (deviceInfo*)calloc(numDevices, sizeof(deviceInfo));
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -533,7 +513,6 @@ bool DirectInput::initialize()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
numDevices = 1;
|
numDevices = 1;
|
||||||
|
|
||||||
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||||
|
@ -541,7 +520,6 @@ bool DirectInput::initialize()
|
||||||
NULL,
|
NULL,
|
||||||
DIEDFL_ATTACHEDONLY);
|
DIEDFL_ATTACHEDONLY);
|
||||||
|
|
||||||
|
|
||||||
if (hr != DI_OK) {
|
if (hr != DI_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -567,8 +545,7 @@ bool DirectInput::initialize()
|
||||||
range.diph.dwHow = DIPH_BYOFFSET;
|
range.diph.dwHow = DIPH_BYOFFSET;
|
||||||
// screw EnumObjects, just go through all the axis offsets and try to GetProperty
|
// screw EnumObjects, just go through all the axis offsets and try to GetProperty
|
||||||
// this should be more foolproof, less code, and probably faster
|
// this should be more foolproof, less code, and probably faster
|
||||||
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG))
|
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0); offset += sizeof(LONG)) {
|
||||||
{
|
|
||||||
range.diph.dwObj = offset;
|
range.diph.dwObj = offset;
|
||||||
// try to set some nice power of 2 values (8192)
|
// try to set some nice power of 2 values (8192)
|
||||||
range.lMin = -(1 << 13);
|
range.lMin = -(1 << 13);
|
||||||
|
@ -577,10 +554,9 @@ bool DirectInput::initialize()
|
||||||
// but i guess not all devices support setting range
|
// but i guess not all devices support setting range
|
||||||
// so i getproperty right afterward incase it didn't set :P
|
// so i getproperty right afterward incase it didn't set :P
|
||||||
// this also checks that the axis is present
|
// this also checks that the axis is present
|
||||||
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph)))
|
if (SUCCEEDED(pDevices[i].device->GetProperty(DIPROP_RANGE, &range.diph))) {
|
||||||
{
|
const LONG center = (range.lMin + range.lMax) / 2;
|
||||||
const LONG center = (range.lMin + range.lMax)/2;
|
const LONG threshold = (range.lMax - center) / 2;
|
||||||
const LONG threshold = (range.lMax - center)/2;
|
|
||||||
|
|
||||||
currentDevice->axis[axisNumber].center = center;
|
currentDevice->axis[axisNumber].center = center;
|
||||||
currentDevice->axis[axisNumber].negative = center - threshold;
|
currentDevice->axis[axisNumber].negative = center - threshold;
|
||||||
|
@ -589,12 +565,10 @@ bool DirectInput::initialize()
|
||||||
|
|
||||||
++axisNumber;
|
++axisNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
|
currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);
|
||||||
|
|
||||||
|
|
||||||
currentDevice = NULL;
|
currentDevice = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,66 +596,66 @@ 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
|
// 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(movieRecording) {
|
if (movieRecording) {
|
||||||
if(i == joypadDefault) {
|
if (i == joypadDefault) {
|
||||||
if(res != movieLastJoypad) {
|
if (res != movieLastJoypad) {
|
||||||
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
|
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
|
||||||
fwrite(&res, 1, sizeof(res), theApp.movieFile);
|
fwrite(&res, 1, sizeof(res), theApp.movieFile);
|
||||||
movieLastJoypad = res;
|
movieLastJoypad = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(moviePlaying) {
|
if (moviePlaying) {
|
||||||
if(movieFrame == moviePlayFrame) {
|
if (movieFrame == moviePlayFrame) {
|
||||||
movieLastJoypad = movieNextJoypad;
|
movieLastJoypad = movieNextJoypad;
|
||||||
theApp.movieReadNext();
|
theApp.movieReadNext();
|
||||||
}
|
}
|
||||||
res = movieLastJoypad;
|
res = movieLastJoypad;
|
||||||
}
|
}
|
||||||
// we don't record speed up or screen capture buttons
|
// we don't record speed up or screen capture buttons
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]) || speedupToggle)
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_SPEED)]) || speedupToggle)
|
||||||
res |= 1024;
|
res |= 1024;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
|
if (checkKey(theApp.input->joypaddata[JOYPAD(i, KEY_BUTTON_CAPTURE)]))
|
||||||
res |= 2048;
|
res |= 2048;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -694,20 +668,19 @@ 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);
|
||||||
|
@ -718,7 +691,7 @@ CString DirectInput::getKeyName(LONG_PTR key)
|
||||||
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,13 +702,11 @@ 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 {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Joystick isn't plugged in. We can't decipher k, so just show its value.
|
// Joystick isn't plugged in. We can't decipher k, so just show its value.
|
||||||
winBuffer.Format("Joy %d (%d)", d, k);
|
winBuffer.Format("Joy %d (%d)", d, k);
|
||||||
}
|
}
|
||||||
|
@ -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,8 +21,7 @@
|
||||||
|
|
||||||
extern bool soundBufferLow;
|
extern bool soundBufferLow;
|
||||||
|
|
||||||
class DirectSound : public SoundDriver
|
class DirectSound : public SoundDriver {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
|
LPDIRECTSOUND8 pDirectSound; // DirectSound interface
|
||||||
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
|
LPDIRECTSOUNDBUFFER dsbPrimary; // Primary DirectSound buffer
|
||||||
|
@ -42,10 +41,9 @@ public:
|
||||||
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;
|
||||||
|
@ -58,26 +56,25 @@ DirectSound::DirectSound()
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +84,6 @@ DirectSound::~DirectSound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DirectSound::init(long sampleRate)
|
bool DirectSound::init(long sampleRate)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -95,33 +91,32 @@ bool DirectSound::init(long sampleRate)
|
||||||
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
|
// Create primary sound buffer
|
||||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||||
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||||
if( dsoundDisableHardwareAcceleration ) {
|
if (dsoundDisableHardwareAcceleration) {
|
||||||
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbPrimary, NULL ) ) ) {
|
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbPrimary, NULL))) {
|
||||||
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
|
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("Cannot CreateSoundBuffer %08x"), hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -129,11 +124,11 @@ bool DirectSound::init(long sampleRate)
|
||||||
freq = sampleRate;
|
freq = sampleRate;
|
||||||
// calculate the number of samples per frame first
|
// calculate the number of samples per frame first
|
||||||
// then multiply it with the size of a sample frame (16 bit * stereo)
|
// then multiply it with the size of a sample frame (16 bit * stereo)
|
||||||
soundBufferLen = ( freq / 60 ) * 4;
|
soundBufferLen = (freq / 60) * 4;
|
||||||
soundBufferTotalLen = soundBufferLen * 10;
|
soundBufferTotalLen = soundBufferLen * 10;
|
||||||
soundNextPosition = 0;
|
soundNextPosition = 0;
|
||||||
|
|
||||||
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
|
ZeroMemory(&wfx, sizeof(WAVEFORMATEX));
|
||||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
wfx.nChannels = 2;
|
wfx.nChannels = 2;
|
||||||
wfx.nSamplesPerSec = freq;
|
wfx.nSamplesPerSec = freq;
|
||||||
|
@ -141,42 +136,40 @@ bool DirectSound::init(long sampleRate)
|
||||||
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
||||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||||
|
|
||||||
if( FAILED( hr = dsbPrimary->SetFormat( &wfx ) ) ) {
|
if (FAILED(hr = dsbPrimary->SetFormat(&wfx))) {
|
||||||
systemMessage( IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr );
|
systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY, _T("CreateSoundBuffer(primary) failed %08x"), hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create secondary sound buffer
|
// Create secondary sound buffer
|
||||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
ZeroMemory(&dsbdesc, sizeof(DSBUFFERDESC));
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
|
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
|
||||||
if( dsoundDisableHardwareAcceleration ) {
|
if (dsoundDisableHardwareAcceleration) {
|
||||||
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
||||||
}
|
}
|
||||||
dsbdesc.dwBufferBytes = soundBufferTotalLen;
|
dsbdesc.dwBufferBytes = soundBufferTotalLen;
|
||||||
dsbdesc.lpwfxFormat = &wfx;
|
dsbdesc.lpwfxFormat = &wfx;
|
||||||
|
|
||||||
if( FAILED( hr = pDirectSound->CreateSoundBuffer( &dsbdesc, &dsbSecondary, NULL ) ) ) {
|
if (FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))) {
|
||||||
systemMessage( IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr );
|
systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, _T("CreateSoundBuffer(secondary) failed %08x"), hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FAILED( hr = dsbSecondary->SetCurrentPosition( 0 ) ) ) {
|
if (FAILED(hr = dsbSecondary->SetCurrentPosition(0))) {
|
||||||
systemMessage( 0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr );
|
systemMessage(0, _T("dsbSecondary->SetCurrentPosition failed %08x"), hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify))) {
|
||||||
if( SUCCEEDED( hr = dsbSecondary->QueryInterface( IID_IDirectSoundNotify8, (LPVOID*)&dsbNotify ) ) ) {
|
dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
dsbEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
|
|
||||||
DSBPOSITIONNOTIFY notify[10];
|
DSBPOSITIONNOTIFY notify[10];
|
||||||
for( i = 0; i < 10; i++ ) {
|
for (i = 0; i < 10; i++) {
|
||||||
notify[i].dwOffset = i * soundBufferLen;
|
notify[i].dwOffset = i * soundBufferLen;
|
||||||
notify[i].hEventNotify = dsbEvent;
|
notify[i].hEventNotify = dsbEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FAILED( dsbNotify->SetNotificationPositions( 10, notify ) ) ) {
|
if (FAILED(dsbNotify->SetNotificationPositions(10, notify))) {
|
||||||
dsbNotify->Release();
|
dsbNotify->Release();
|
||||||
dsbNotify = NULL;
|
dsbNotify = NULL;
|
||||||
CloseHandle(dsbEvent);
|
CloseHandle(dsbEvent);
|
||||||
|
@ -184,53 +177,52 @@ bool DirectSound::init(long sampleRate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Play primary buffer
|
// Play primary buffer
|
||||||
if( FAILED( hr = dsbPrimary->Play( 0, 0, DSBPLAY_LOOPING ) ) ) {
|
if (FAILED(hr = dsbPrimary->Play(0, 0, DSBPLAY_LOOPING))) {
|
||||||
systemMessage( IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr );
|
systemMessage(IDS_CANNOT_PLAY_PRIMARY, _T("Cannot Play primary %08x"), hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSound::pause()
|
void DirectSound::pause()
|
||||||
{
|
{
|
||||||
if( dsbSecondary == NULL ) return;
|
if (dsbSecondary == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
DWORD status;
|
DWORD status;
|
||||||
|
|
||||||
dsbSecondary->GetStatus( &status );
|
dsbSecondary->GetStatus(&status);
|
||||||
|
|
||||||
if( status & DSBSTATUS_PLAYING ) dsbSecondary->Stop();
|
if (status & DSBSTATUS_PLAYING)
|
||||||
|
dsbSecondary->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSound::reset()
|
void DirectSound::reset()
|
||||||
{
|
{
|
||||||
if( dsbSecondary == NULL ) return;
|
if (dsbSecondary == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
dsbSecondary->Stop();
|
dsbSecondary->Stop();
|
||||||
|
|
||||||
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;
|
HRESULT hr;
|
||||||
DWORD status = 0;
|
DWORD status = 0;
|
||||||
|
@ -240,46 +232,42 @@ void DirectSound::write(u16 * finalWave, int length)
|
||||||
LPVOID lpvPtr2;
|
LPVOID lpvPtr2;
|
||||||
DWORD dwBytes2 = 0;
|
DWORD dwBytes2 = 0;
|
||||||
|
|
||||||
if( !speedup && throttle && !gba_joybus_active) {
|
if (!speedup && throttle && !gba_joybus_active) {
|
||||||
hr = dsbSecondary->GetStatus(&status);
|
hr = dsbSecondary->GetStatus(&status);
|
||||||
if( status & DSBSTATUS_PLAYING ) {
|
if (status & DSBSTATUS_PLAYING) {
|
||||||
if( !soundPaused ) {
|
if (!soundPaused) {
|
||||||
while( true ) {
|
while (true) {
|
||||||
dsbSecondary->GetCurrentPosition(&play, NULL);
|
dsbSecondary->GetCurrentPosition(&play, NULL);
|
||||||
int BufferLeft = ((soundNextPosition <= play) ?
|
int BufferLeft = ((soundNextPosition <= play) ? play - soundNextPosition : soundBufferTotalLen - soundNextPosition + play);
|
||||||
play - soundNextPosition :
|
|
||||||
soundBufferTotalLen - soundNextPosition + play);
|
|
||||||
|
|
||||||
if(BufferLeft > soundBufferLen)
|
if (BufferLeft > soundBufferLen) {
|
||||||
{
|
|
||||||
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
|
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
|
||||||
soundBufferLow = true;
|
soundBufferLow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
soundBufferLow = false;
|
soundBufferLow = false;
|
||||||
|
|
||||||
if(dsbEvent) {
|
if (dsbEvent) {
|
||||||
WaitForSingleObject(dsbEvent, 50);
|
WaitForSingleObject(dsbEvent, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}/* else {
|
} /* else {
|
||||||
// TODO: remove?
|
// TODO: remove?
|
||||||
setsoundPaused(true);
|
setsoundPaused(true);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Obtain memory address of write block.
|
// Obtain memory address of write block.
|
||||||
// This will be in two parts if the block wraps around.
|
// This will be in two parts if the block wraps around.
|
||||||
if( DSERR_BUFFERLOST == ( hr = dsbSecondary->Lock(
|
if (DSERR_BUFFERLOST == (hr = dsbSecondary->Lock(
|
||||||
soundNextPosition,
|
soundNextPosition,
|
||||||
soundBufferLen,
|
soundBufferLen,
|
||||||
&lpvPtr1,
|
&lpvPtr1,
|
||||||
&dwBytes1,
|
&dwBytes1,
|
||||||
&lpvPtr2,
|
&lpvPtr2,
|
||||||
&dwBytes2,
|
&dwBytes2,
|
||||||
0 ) ) ) {
|
0))) {
|
||||||
// If DSERR_BUFFERLOST is returned, restore and retry lock.
|
// If DSERR_BUFFERLOST is returned, restore and retry lock.
|
||||||
dsbSecondary->Restore();
|
dsbSecondary->Restore();
|
||||||
hr = dsbSecondary->Lock(
|
hr = dsbSecondary->Lock(
|
||||||
|
@ -289,28 +277,28 @@ void DirectSound::write(u16 * finalWave, int length)
|
||||||
&dwBytes1,
|
&dwBytes1,
|
||||||
&lpvPtr2,
|
&lpvPtr2,
|
||||||
&dwBytes2,
|
&dwBytes2,
|
||||||
0 );
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
soundNextPosition += soundBufferLen;
|
soundNextPosition += soundBufferLen;
|
||||||
soundNextPosition = soundNextPosition % soundBufferTotalLen;
|
soundNextPosition = soundNextPosition % soundBufferTotalLen;
|
||||||
|
|
||||||
if( SUCCEEDED( hr ) ) {
|
if (SUCCEEDED(hr)) {
|
||||||
// Write to pointers.
|
// Write to pointers.
|
||||||
CopyMemory( lpvPtr1, finalWave, dwBytes1 );
|
CopyMemory(lpvPtr1, finalWave, dwBytes1);
|
||||||
if ( lpvPtr2 ) {
|
if (lpvPtr2) {
|
||||||
CopyMemory( lpvPtr2, finalWave + dwBytes1, dwBytes2 );
|
CopyMemory(lpvPtr2, finalWave + dwBytes1, dwBytes2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the data back to DirectSound.
|
// Release the data back to DirectSound.
|
||||||
hr = dsbSecondary->Unlock( lpvPtr1, dwBytes1, lpvPtr2, dwBytes2 );
|
hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);
|
||||||
} else {
|
} else {
|
||||||
systemMessage( 0, _T("dsbSecondary->Lock() failed: %08x"), hr );
|
systemMessage(0, _T("dsbSecondary->Lock() failed: %08x"), hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundDriver *newDirectSound()
|
SoundDriver* newDirectSound()
|
||||||
{
|
{
|
||||||
return new DirectSound();
|
return new DirectSound();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "vba.h"
|
|
||||||
#include "Directories.h"
|
#include "Directories.h"
|
||||||
#include "Reg.h"
|
#include "Reg.h"
|
||||||
#include "WinResUtil.h"
|
#include "WinResUtil.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "vba.h"
|
||||||
|
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
@ -18,10 +18,10 @@ static char THIS_FILE[] = __FILE__;
|
||||||
static int CALLBACK browseCallbackProc(HWND hWnd, UINT msg,
|
static int CALLBACK browseCallbackProc(HWND hWnd, UINT msg,
|
||||||
LPARAM l, LPARAM data)
|
LPARAM l, LPARAM data)
|
||||||
{
|
{
|
||||||
char *buffer = (char *)data;
|
char* buffer = (char*)data;
|
||||||
switch(msg) {
|
switch (msg) {
|
||||||
case BFFM_INITIALIZED:
|
case BFFM_INITIALIZED:
|
||||||
if(buffer[0])
|
if (buffer[0])
|
||||||
SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer);
|
SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -35,7 +35,6 @@ Directories::Directories(CWnd* pParent /*=NULL*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Directories::DoDataExchange(CDataExchange* pDX)
|
void Directories::DoDataExchange(CDataExchange* pDX)
|
||||||
{
|
{
|
||||||
CDialog::DoDataExchange(pDX);
|
CDialog::DoDataExchange(pDX);
|
||||||
|
@ -47,17 +46,16 @@ void Directories::DoDataExchange(CDataExchange* pDX)
|
||||||
DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath);
|
DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(Directories, CDialog)
|
BEGIN_MESSAGE_MAP(Directories, CDialog)
|
||||||
ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir)
|
ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir)
|
||||||
ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir)
|
ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir)
|
||||||
ON_BN_CLICKED(IDC_GBROM_DIR, OnGbromDir)
|
ON_BN_CLICKED(IDC_GBROM_DIR, OnGbromDir)
|
||||||
ON_BN_CLICKED(IDC_ROM_DIR, OnRomDir)
|
ON_BN_CLICKED(IDC_ROM_DIR, OnRomDir)
|
||||||
ON_BN_CLICKED(IDC_SAVE_DIR, OnSaveDir)
|
ON_BN_CLICKED(IDC_SAVE_DIR, OnSaveDir)
|
||||||
ON_BN_CLICKED(IDC_GBCROM_DIR, OnGbcromDir)
|
ON_BN_CLICKED(IDC_GBCROM_DIR, OnGbcromDir)
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Directories message handlers
|
// Directories message handlers
|
||||||
|
|
||||||
BOOL Directories::OnInitDialog()
|
BOOL Directories::OnInitDialog()
|
||||||
|
@ -66,27 +64,27 @@ BOOL Directories::OnInitDialog()
|
||||||
CString p;
|
CString p;
|
||||||
|
|
||||||
p = regQueryStringValue("romdir", NULL);
|
p = regQueryStringValue("romdir", NULL);
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
GetDlgItem(IDC_ROM_PATH)->SetWindowText(p);
|
GetDlgItem(IDC_ROM_PATH)->SetWindowText(p);
|
||||||
|
|
||||||
p = regQueryStringValue("gbcromdir", NULL);
|
p = regQueryStringValue("gbcromdir", NULL);
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
GetDlgItem(IDC_GBCROM_PATH)->SetWindowText(p);
|
GetDlgItem(IDC_GBCROM_PATH)->SetWindowText(p);
|
||||||
|
|
||||||
p = regQueryStringValue("gbromdir", NULL);
|
p = regQueryStringValue("gbromdir", NULL);
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
GetDlgItem(IDC_GBROM_PATH)->SetWindowText(p);
|
GetDlgItem(IDC_GBROM_PATH)->SetWindowText(p);
|
||||||
|
|
||||||
p = regQueryStringValue("batteryDir", NULL);
|
p = regQueryStringValue("batteryDir", NULL);
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
GetDlgItem(IDC_BATTERY_PATH)->SetWindowText( p);
|
GetDlgItem(IDC_BATTERY_PATH)->SetWindowText(p);
|
||||||
|
|
||||||
p = regQueryStringValue("saveDir", NULL);
|
p = regQueryStringValue("saveDir", NULL);
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
GetDlgItem(IDC_SAVE_PATH)->SetWindowText(p);
|
GetDlgItem(IDC_SAVE_PATH)->SetWindowText(p);
|
||||||
|
|
||||||
p = regQueryStringValue("captureDir", NULL);
|
p = regQueryStringValue("captureDir", NULL);
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
GetDlgItem(IDC_CAPTURE_PATH)->SetWindowText(p);
|
GetDlgItem(IDC_CAPTURE_PATH)->SetWindowText(p);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -98,7 +96,7 @@ void Directories::OnBatteryDir()
|
||||||
{
|
{
|
||||||
m_batteryPath.GetWindowText(initialFolderDir);
|
m_batteryPath.GetWindowText(initialFolderDir);
|
||||||
CString p = browseForDir(winResLoadString(IDS_SELECT_BATTERY_DIR));
|
CString p = browseForDir(winResLoadString(IDS_SELECT_BATTERY_DIR));
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
m_batteryPath.SetWindowText(p);
|
m_batteryPath.SetWindowText(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +104,7 @@ void Directories::OnCaptureDir()
|
||||||
{
|
{
|
||||||
m_capturePath.GetWindowText(initialFolderDir);
|
m_capturePath.GetWindowText(initialFolderDir);
|
||||||
CString p = browseForDir(winResLoadString(IDS_SELECT_CAPTURE_DIR));
|
CString p = browseForDir(winResLoadString(IDS_SELECT_CAPTURE_DIR));
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
m_capturePath.SetWindowText(p);
|
m_capturePath.SetWindowText(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +112,7 @@ void Directories::OnGbromDir()
|
||||||
{
|
{
|
||||||
m_gbromPath.GetWindowText(initialFolderDir);
|
m_gbromPath.GetWindowText(initialFolderDir);
|
||||||
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
|
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
m_gbromPath.SetWindowText(p);
|
m_gbromPath.SetWindowText(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +120,7 @@ void Directories::OnGbcromDir()
|
||||||
{
|
{
|
||||||
m_gbcromPath.GetWindowText(initialFolderDir);
|
m_gbcromPath.GetWindowText(initialFolderDir);
|
||||||
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
|
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
m_gbcromPath.SetWindowText(p);
|
m_gbcromPath.SetWindowText(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +128,7 @@ void Directories::OnRomDir()
|
||||||
{
|
{
|
||||||
m_romPath.GetWindowText(initialFolderDir);
|
m_romPath.GetWindowText(initialFolderDir);
|
||||||
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
|
CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR));
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
m_romPath.SetWindowText(p);
|
m_romPath.SetWindowText(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +136,7 @@ void Directories::OnSaveDir()
|
||||||
{
|
{
|
||||||
m_savePath.GetWindowText(initialFolderDir);
|
m_savePath.GetWindowText(initialFolderDir);
|
||||||
CString p = browseForDir(winResLoadString(IDS_SELECT_SAVE_DIR));
|
CString p = browseForDir(winResLoadString(IDS_SELECT_SAVE_DIR));
|
||||||
if(!p.IsEmpty())
|
if (!p.IsEmpty())
|
||||||
m_savePath.SetWindowText(p);
|
m_savePath.SetWindowText(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,86 +149,85 @@ void Directories::OnOK()
|
||||||
{
|
{
|
||||||
CDialog::OnOK();
|
CDialog::OnOK();
|
||||||
|
|
||||||
char baseDir[MAX_PATH+1];
|
char baseDir[MAX_PATH + 1];
|
||||||
char temp[MAX_PATH+1];
|
char temp[MAX_PATH + 1];
|
||||||
GetModuleFileName( NULL, baseDir, MAX_PATH );
|
GetModuleFileName(NULL, baseDir, MAX_PATH);
|
||||||
baseDir[MAX_PATH] = '\0'; // for security reasons
|
baseDir[MAX_PATH] = '\0'; // for security reasons
|
||||||
PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash
|
PathRemoveFileSpec(baseDir); // removes the trailing file name and backslash
|
||||||
|
|
||||||
|
|
||||||
CString buffer;
|
CString buffer;
|
||||||
|
|
||||||
m_romPath.GetWindowText(buffer);
|
m_romPath.GetWindowText(buffer);
|
||||||
if( !buffer.IsEmpty() )
|
if (!buffer.IsEmpty())
|
||||||
regSetStringValue( "romdir", buffer );
|
regSetStringValue("romdir", buffer);
|
||||||
if( buffer[0] == '.' ) {
|
if (buffer[0] == '.') {
|
||||||
strcpy( temp, baseDir );
|
strcpy(temp, baseDir);
|
||||||
strcat( temp, "\\" );
|
strcat(temp, "\\");
|
||||||
strcat( temp, buffer );
|
strcat(temp, buffer);
|
||||||
buffer = temp;
|
buffer = temp;
|
||||||
}
|
}
|
||||||
if( !directoryDoesExist( buffer ) )
|
if (!directoryDoesExist(buffer))
|
||||||
SHCreateDirectoryEx( NULL, buffer, NULL );
|
SHCreateDirectoryEx(NULL, buffer, NULL);
|
||||||
|
|
||||||
m_gbcromPath.GetWindowText(buffer);
|
m_gbcromPath.GetWindowText(buffer);
|
||||||
if( !buffer.IsEmpty() )
|
if (!buffer.IsEmpty())
|
||||||
regSetStringValue( "gbcromdir", buffer );
|
regSetStringValue("gbcromdir", buffer);
|
||||||
if( buffer[0] == '.' ) {
|
if (buffer[0] == '.') {
|
||||||
strcpy( temp, baseDir );
|
strcpy(temp, baseDir);
|
||||||
strcat( temp, "\\" );
|
strcat(temp, "\\");
|
||||||
strcat( temp, buffer );
|
strcat(temp, buffer);
|
||||||
buffer = temp;
|
buffer = temp;
|
||||||
}
|
}
|
||||||
if( !directoryDoesExist( buffer ) )
|
if (!directoryDoesExist(buffer))
|
||||||
SHCreateDirectoryEx( NULL, buffer, NULL );
|
SHCreateDirectoryEx(NULL, buffer, NULL);
|
||||||
|
|
||||||
m_gbromPath.GetWindowText(buffer);
|
m_gbromPath.GetWindowText(buffer);
|
||||||
if( !buffer.IsEmpty() )
|
if (!buffer.IsEmpty())
|
||||||
regSetStringValue( "gbromdir", buffer );
|
regSetStringValue("gbromdir", buffer);
|
||||||
if( buffer[0] == '.' ) {
|
if (buffer[0] == '.') {
|
||||||
strcpy( temp, baseDir );
|
strcpy(temp, baseDir);
|
||||||
strcat( temp, "\\" );
|
strcat(temp, "\\");
|
||||||
strcat( temp, buffer );
|
strcat(temp, buffer);
|
||||||
buffer = temp;
|
buffer = temp;
|
||||||
}
|
}
|
||||||
if( !directoryDoesExist( buffer ) )
|
if (!directoryDoesExist(buffer))
|
||||||
SHCreateDirectoryEx( NULL, buffer, NULL );
|
SHCreateDirectoryEx(NULL, buffer, NULL);
|
||||||
|
|
||||||
m_batteryPath.GetWindowText(buffer);
|
m_batteryPath.GetWindowText(buffer);
|
||||||
if( !buffer.IsEmpty() )
|
if (!buffer.IsEmpty())
|
||||||
regSetStringValue( "batteryDir", buffer );
|
regSetStringValue("batteryDir", buffer);
|
||||||
if( buffer[0] == '.' ) {
|
if (buffer[0] == '.') {
|
||||||
strcpy( temp, baseDir );
|
strcpy(temp, baseDir);
|
||||||
strcat( temp, "\\" );
|
strcat(temp, "\\");
|
||||||
strcat( temp, buffer );
|
strcat(temp, buffer);
|
||||||
buffer = temp;
|
buffer = temp;
|
||||||
}
|
}
|
||||||
if( !directoryDoesExist( buffer ) )
|
if (!directoryDoesExist(buffer))
|
||||||
SHCreateDirectoryEx( NULL, buffer, NULL );
|
SHCreateDirectoryEx(NULL, buffer, NULL);
|
||||||
|
|
||||||
m_savePath.GetWindowText(buffer);
|
m_savePath.GetWindowText(buffer);
|
||||||
if( !buffer.IsEmpty() )
|
if (!buffer.IsEmpty())
|
||||||
regSetStringValue( "saveDir", buffer );
|
regSetStringValue("saveDir", buffer);
|
||||||
if( buffer[0] == '.' ) {
|
if (buffer[0] == '.') {
|
||||||
strcpy( temp, baseDir );
|
strcpy(temp, baseDir);
|
||||||
strcat( temp, "\\" );
|
strcat(temp, "\\");
|
||||||
strcat( temp, buffer );
|
strcat(temp, buffer);
|
||||||
buffer = temp;
|
buffer = temp;
|
||||||
}
|
}
|
||||||
if( !directoryDoesExist( buffer ) )
|
if (!directoryDoesExist(buffer))
|
||||||
SHCreateDirectoryEx( NULL, buffer, NULL );
|
SHCreateDirectoryEx(NULL, buffer, NULL);
|
||||||
|
|
||||||
m_capturePath.GetWindowText(buffer);
|
m_capturePath.GetWindowText(buffer);
|
||||||
if( !buffer.IsEmpty() )
|
if (!buffer.IsEmpty())
|
||||||
regSetStringValue( "captureDir", buffer );
|
regSetStringValue("captureDir", buffer);
|
||||||
if( buffer[0] == '.' ) {
|
if (buffer[0] == '.') {
|
||||||
strcpy( temp, baseDir );
|
strcpy(temp, baseDir);
|
||||||
strcat( temp, "\\" );
|
strcat(temp, "\\");
|
||||||
strcat( temp, buffer );
|
strcat(temp, buffer);
|
||||||
buffer = temp;
|
buffer = temp;
|
||||||
}
|
}
|
||||||
if( !directoryDoesExist( buffer ) )
|
if (!directoryDoesExist(buffer))
|
||||||
SHCreateDirectoryEx( NULL, buffer, NULL );
|
SHCreateDirectoryEx(NULL, buffer, NULL);
|
||||||
|
|
||||||
EndDialog(TRUE);
|
EndDialog(TRUE);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +240,7 @@ CString Directories::browseForDir(CString title)
|
||||||
|
|
||||||
CString res;
|
CString res;
|
||||||
|
|
||||||
if(SUCCEEDED(SHGetMalloc(&pMalloc))) {
|
if (SUCCEEDED(SHGetMalloc(&pMalloc))) {
|
||||||
BROWSEINFO bi;
|
BROWSEINFO bi;
|
||||||
ZeroMemory(&bi, sizeof(bi));
|
ZeroMemory(&bi, sizeof(bi));
|
||||||
bi.hwndOwner = m_hWnd;
|
bi.hwndOwner = m_hWnd;
|
||||||
|
@ -255,8 +252,8 @@ CString Directories::browseForDir(CString title)
|
||||||
|
|
||||||
pidl = SHBrowseForFolder(&bi);
|
pidl = SHBrowseForFolder(&bi);
|
||||||
|
|
||||||
if(pidl) {
|
if (pidl) {
|
||||||
if(SHGetPathFromIDList(pidl, buffer)) {
|
if (SHGetPathFromIDList(pidl, buffer)) {
|
||||||
res = buffer;
|
res = buffer;
|
||||||
}
|
}
|
||||||
pMalloc->Free(pidl);
|
pMalloc->Free(pidl);
|
||||||
|
@ -267,7 +264,7 @@ CString Directories::browseForDir(CString title)
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if the directory does exist
|
// returns true if the directory does exist
|
||||||
bool Directories::directoryDoesExist(const char *directory)
|
bool Directories::directoryDoesExist(const char* directory)
|
||||||
{
|
{
|
||||||
HANDLE hDir;
|
HANDLE hDir;
|
||||||
hDir = CreateFile(
|
hDir = CreateFile(
|
||||||
|
@ -277,8 +274,8 @@ bool Directories::directoryDoesExist(const char *directory)
|
||||||
NULL,
|
NULL,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
FILE_FLAG_BACKUP_SEMANTICS,
|
FILE_FLAG_BACKUP_SEMANTICS,
|
||||||
NULL );
|
NULL);
|
||||||
bool retval = (hDir == INVALID_HANDLE_VALUE) ? false : true;
|
bool retval = (hDir == INVALID_HANDLE_VALUE) ? false : true;
|
||||||
CloseHandle( hDir );
|
CloseHandle(hDir);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue