commit
0047fa1a69
|
@ -482,7 +482,7 @@ void BIOS_EReader_ScanCard(int swi_num)
|
|||
}
|
||||
dotcodepointer++;
|
||||
|
||||
if ((dotcodepointer == dotcodeinterleave)) {
|
||||
if (dotcodepointer == dotcodeinterleave) {
|
||||
switch (dotcodeinterleave) {
|
||||
case 0x1C:
|
||||
j = 0x724;
|
||||
|
|
|
@ -29,7 +29,7 @@ int cpuSaveType = 0;
|
|||
int skipSaveGameBattery = 0;
|
||||
int skipSaveGameCheats = 0;
|
||||
int useBios = 0;
|
||||
int cheatsEnabled = 1;
|
||||
int cheatsEnabled = 0;
|
||||
int layerSettings = 0xff00;
|
||||
int layerEnable = 0xff00;
|
||||
bool speedup = false;
|
||||
|
|
|
@ -40,9 +40,8 @@ static retro_environment_t environ_cb;
|
|||
|
||||
static bool enableRtc;
|
||||
static bool can_dupe;
|
||||
unsigned device_type = 0;
|
||||
int emulating = 0;
|
||||
static int controller_layout[2] = { 0, 0 };
|
||||
static unsigned controller_layout = 0;
|
||||
|
||||
uint8_t libretro_save_buf[0x20000 + 0x2000]; /* Workaround for broken-by-design GBA save semantics. */
|
||||
|
||||
|
@ -65,9 +64,6 @@ int systemFrameSkip = 0;
|
|||
int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
|
||||
int systemSpeed = 0;
|
||||
|
||||
//uint64_t startTime = 0;
|
||||
//uint32_t renderedFrames = 0;
|
||||
|
||||
void (*dbgOutput)(const char* s, uint32_t addr);
|
||||
void (*dbgSignal)(int sig, int number);
|
||||
|
||||
|
@ -75,10 +71,10 @@ void* retro_get_memory_data(unsigned id)
|
|||
{
|
||||
if (id == RETRO_MEMORY_SAVE_RAM)
|
||||
return libretro_save_buf;
|
||||
if (id == RETRO_MEMORY_SYSTEM_RAM)
|
||||
return workRAM;
|
||||
if (id == RETRO_MEMORY_VIDEO_RAM)
|
||||
return vram;
|
||||
if (id == RETRO_MEMORY_SYSTEM_RAM)
|
||||
return workRAM;
|
||||
if (id == RETRO_MEMORY_VIDEO_RAM)
|
||||
return vram;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -87,10 +83,10 @@ size_t retro_get_memory_size(unsigned id)
|
|||
{
|
||||
if (id == RETRO_MEMORY_SAVE_RAM)
|
||||
return libretro_save_size;
|
||||
if (id == RETRO_MEMORY_SYSTEM_RAM)
|
||||
return 0x40000;
|
||||
if (id == RETRO_MEMORY_VIDEO_RAM)
|
||||
return 0x20000;
|
||||
if (id == RETRO_MEMORY_SYSTEM_RAM)
|
||||
return 0x40000;
|
||||
if (id == RETRO_MEMORY_VIDEO_RAM)
|
||||
return 0x20000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -164,22 +160,24 @@ void retro_set_input_state(retro_input_state_t cb)
|
|||
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
if (port > 0) return; // GBA Only supports 1 controller
|
||||
|
||||
log_cb(RETRO_LOG_INFO, "Controller %d'\n", device);
|
||||
switch (device) {
|
||||
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
case RETRO_DEVICE_GBA:
|
||||
default:
|
||||
controller_layout[port] = 0;
|
||||
controller_layout = 0;
|
||||
break;
|
||||
case RETRO_DEVICE_GBA_ALT1:
|
||||
controller_layout[port] = 1;
|
||||
controller_layout = 1;
|
||||
break;
|
||||
case RETRO_DEVICE_GBA_ALT2:
|
||||
controller_layout[port] = 2;
|
||||
controller_layout = 2;
|
||||
break;
|
||||
case RETRO_DEVICE_NONE:
|
||||
controller_layout[port] = -1;
|
||||
controller_layout = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +187,7 @@ void retro_set_environment(retro_environment_t cb)
|
|||
environ_cb = cb;
|
||||
|
||||
struct retro_variable variables[] = {
|
||||
{ "vbam_solarsensor", "Solar Sensor Level; 0|1|2|3|4|5|6|7|8|9|10" },
|
||||
{ "vbam_usebios", "Use BIOS file (Restart); disabled|enabled" },
|
||||
{ "vbam_layer_1", "Show layer 1; enabled|disabled" },
|
||||
{ "vbam_layer_2", "Show layer 2; enabled|disabled" },
|
||||
|
@ -205,12 +204,11 @@ void retro_set_environment(retro_environment_t cb)
|
|||
{ "GBA Joypad", RETRO_DEVICE_GBA },
|
||||
{ "Alt Joypad YB", RETRO_DEVICE_GBA_ALT1 },
|
||||
{ "Alt Joypad AB", RETRO_DEVICE_GBA_ALT2 },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
static const struct retro_controller_info ports[] = {{ port_1, 3 },{ NULL,0 }};
|
||||
|
||||
|
||||
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
||||
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
|
||||
}
|
||||
|
@ -446,6 +444,7 @@ static void gba_init(void)
|
|||
flashSize = 0x10000;
|
||||
enableRtc = false;
|
||||
mirroringEnable = false;
|
||||
|
||||
#ifdef FRONTEND_SUPPORTS_RGB565
|
||||
systemColorDepth = 16;
|
||||
systemRedShift = 11;
|
||||
|
@ -476,10 +475,7 @@ static void gba_init(void)
|
|||
soundInit();
|
||||
soundSetSampleRate(32000);
|
||||
|
||||
if (usebios && biosfile[0])
|
||||
CPUInit(biosfile, true);
|
||||
else
|
||||
CPUInit(0, false);
|
||||
CPUInit(biosfile, usebios);
|
||||
|
||||
CPUReset();
|
||||
|
||||
|
@ -504,46 +500,51 @@ void retro_reset(void)
|
|||
CPUReset();
|
||||
}
|
||||
|
||||
static const unsigned binds[] = {
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_R,
|
||||
RETRO_DEVICE_ID_JOYPAD_L
|
||||
#define MAX_BUTTONS 10
|
||||
static const unsigned binds[3][MAX_BUTTONS] = {
|
||||
{
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_R,
|
||||
RETRO_DEVICE_ID_JOYPAD_L
|
||||
},
|
||||
{
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_Y,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_R,
|
||||
RETRO_DEVICE_ID_JOYPAD_L
|
||||
},
|
||||
{
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_R,
|
||||
RETRO_DEVICE_ID_JOYPAD_L
|
||||
}
|
||||
};
|
||||
|
||||
static const unsigned binds1[] = {
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_Y,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_R,
|
||||
RETRO_DEVICE_ID_JOYPAD_L
|
||||
};
|
||||
|
||||
static const unsigned binds2[] = {
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_SELECT,
|
||||
RETRO_DEVICE_ID_JOYPAD_START,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_R,
|
||||
RETRO_DEVICE_ID_JOYPAD_L
|
||||
};
|
||||
static void systemUpdateSolarSensor(int level);
|
||||
|
||||
static unsigned has_frame;
|
||||
static uint8_t sensorDarkness = 0xE8;
|
||||
static uint8_t sensorDarknessLevel = 0; // so we can adjust sensor from gamepad
|
||||
|
||||
static void update_variables(void)
|
||||
{
|
||||
|
@ -575,6 +576,15 @@ static void update_variables(void)
|
|||
bool newval = (strcmp(var.value, "enabled") == 0);
|
||||
usebios = newval;
|
||||
}
|
||||
|
||||
var.key = "vbam_solarsensor";
|
||||
var.value = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
sensorDarknessLevel = atoi(var.value);
|
||||
systemUpdateSolarSensor(sensorDarknessLevel);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FINAL_VERSION
|
||||
|
@ -586,11 +596,37 @@ static void update_variables(void)
|
|||
void retro_run(void)
|
||||
{
|
||||
bool updated = false;
|
||||
static bool buttonpressed = false;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
|
||||
update_variables();
|
||||
|
||||
poll_cb();
|
||||
|
||||
// Update solar sensor level by gamepad buttons, default L2/R2
|
||||
if (buttonpressed)
|
||||
{
|
||||
buttonpressed = input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2) ||
|
||||
input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2))
|
||||
{
|
||||
sensorDarknessLevel++;
|
||||
if (sensorDarknessLevel > 10)
|
||||
sensorDarknessLevel = 10;
|
||||
systemUpdateSolarSensor(sensorDarknessLevel);
|
||||
buttonpressed = true;
|
||||
}
|
||||
else if (input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2))
|
||||
{
|
||||
if (sensorDarknessLevel)
|
||||
sensorDarknessLevel--;
|
||||
systemUpdateSolarSensor(sensorDarknessLevel);
|
||||
buttonpressed = true;
|
||||
}
|
||||
} // end of solar sensor update
|
||||
|
||||
has_frame = 0;
|
||||
|
||||
do {
|
||||
|
@ -615,6 +651,7 @@ bool retro_unserialize(const void* data, size_t size)
|
|||
|
||||
void retro_cheat_reset(void)
|
||||
{
|
||||
cheatsEnabled = 1;
|
||||
cheatsDeleteAll(false);
|
||||
}
|
||||
|
||||
|
@ -724,6 +761,8 @@ bool retro_load_game(const struct retro_game_info *game)
|
|||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "Solar Sensor (Darker)" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "Solar Sensor (Lighter)" },
|
||||
|
||||
{ 0 },
|
||||
};
|
||||
|
@ -765,10 +804,11 @@ bool retro_load_game(const struct retro_game_info *game)
|
|||
}
|
||||
|
||||
bool retro_load_game_special(
|
||||
unsigned game_type,
|
||||
const struct retro_game_info *info, size_t num_info
|
||||
)
|
||||
{ return false; }
|
||||
unsigned game_type,
|
||||
const struct retro_game_info *info, size_t num_info)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
extern unsigned g_audio_frames;
|
||||
static unsigned g_video_frames;
|
||||
|
@ -791,8 +831,15 @@ void systemOnWriteDataToSoundBuffer(const uint16_t* finalWave, int length)
|
|||
{
|
||||
}
|
||||
|
||||
void systemOnSoundShutdown() {}
|
||||
bool systemCanChangeSoundQuality() { return true; }
|
||||
void systemOnSoundShutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool systemCanChangeSoundQuality()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef FRONTEND_SUPPORTS_RGB565
|
||||
#define BPP 2
|
||||
|
@ -853,27 +900,55 @@ uint32_t systemReadJoypad(int which)
|
|||
if (which == -1)
|
||||
which = 0;
|
||||
|
||||
unsigned ControllerLayout = controller_layout;
|
||||
uint32_t J = 0;
|
||||
|
||||
for (unsigned i = 0; i < 10; i++) {
|
||||
if (controller_layout[0] == 1)
|
||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds1[i]) << i;
|
||||
else if (controller_layout[0] == 2)
|
||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds2[i]) << i;
|
||||
else if (controller_layout[0] == -1)
|
||||
break;
|
||||
else
|
||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds[i]) << i;
|
||||
}
|
||||
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
||||
J |= input_cb(which, RETRO_DEVICE_JOYPAD, 0, binds[ControllerLayout][i]) << i;
|
||||
|
||||
// Do not allow opposing directions
|
||||
if ((J & 0x30) == 0x30)
|
||||
J &= ~(0x30);
|
||||
else if ((J & 0xC0) == 0xC0)
|
||||
J &= ~(0xC0);
|
||||
|
||||
return J;
|
||||
}
|
||||
|
||||
bool systemReadJoypads() { return true; }
|
||||
static void systemUpdateSolarSensor(int v)
|
||||
{
|
||||
int value = 0;
|
||||
switch (v)
|
||||
{
|
||||
case 1: value = 0x06; break;
|
||||
case 2: value = 0x0E; break;
|
||||
case 3: value = 0x18; break;
|
||||
case 4: value = 0x20; break;
|
||||
case 5: value = 0x28; break;
|
||||
case 6: value = 0x38; break;
|
||||
case 7: value = 0x48; break;
|
||||
case 8: value = 0x60; break;
|
||||
case 9: value = 0x78; break;
|
||||
case 10: value = 0x98; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
void systemUpdateMotionSensor() {}
|
||||
sensorDarkness = 0xE8 - value;
|
||||
}
|
||||
|
||||
uint8_t systemGetSensorDarkness() { return 0; }
|
||||
bool systemReadJoypads()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void systemUpdateMotionSensor()
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t systemGetSensorDarkness()
|
||||
{
|
||||
return sensorDarkness;
|
||||
}
|
||||
|
||||
void systemCartridgeRumble(bool)
|
||||
{
|
||||
|
@ -900,6 +975,5 @@ uint32_t systemGetClock()
|
|||
SoundDriver* systemSoundInit()
|
||||
{
|
||||
soundShutdown();
|
||||
|
||||
return new SoundRetro();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue