mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-16 20:39:15 +01:00
Fixed sound, binding of keys, saving of prefs etc
This commit is contained in:
parent
6e6aea5e54
commit
5f4fb38944
@ -27,6 +27,9 @@
|
||||
#include "ROlib.h"
|
||||
#endif
|
||||
|
||||
#ifdef GEKKO
|
||||
#define PREFS_PATH "/apps/frodo/frodorc"
|
||||
#endif
|
||||
|
||||
// false: Frodo, true: FrodoSC
|
||||
extern bool IsFrodoSC;
|
||||
|
@ -120,7 +120,6 @@ void C64::select_disc(Prefs *np)
|
||||
|
||||
file_list = (char**)malloc(cnt * sizeof(char*));
|
||||
file_list[cur++] = strdup("None");
|
||||
file_list[cur++] = strdup("..");
|
||||
file_list[cur] = NULL;
|
||||
|
||||
for (de = readdir(d);
|
||||
@ -128,8 +127,8 @@ void C64::select_disc(Prefs *np)
|
||||
de = readdir(d))
|
||||
{
|
||||
/* FIXME! Add directories */
|
||||
if (strstr(de->d_name, ".d64") ||
|
||||
strstr(de->d_name, ".t64"))
|
||||
if (strstr(de->d_name, ".d64") || strstr(de->d_name, ".D64") ||
|
||||
strstr(de->d_name, ".t64") || strstr(de->d_name, ".T64"))
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -160,8 +159,9 @@ void C64::select_disc(Prefs *np)
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(np->DrivePath[0], name, 255);
|
||||
if (strstr(name, ".d64"))
|
||||
snprintf(np->DrivePath[0], 255, "%s/%s",
|
||||
this->base_dir, name);
|
||||
if (strstr(name, ".d64") || strstr(name, ".D64"))
|
||||
np->DriveType[0] = DRVTYPE_D64;
|
||||
else
|
||||
np->DriveType[0] = DRVTYPE_T64;
|
||||
@ -275,7 +275,7 @@ void C64::VBlank(bool draw_frame)
|
||||
int kc = get_kc_from_char(auto_seq[this->fake_key_type][this->fake_key_index], &shifted);
|
||||
|
||||
TheDisplay->FakeKeyPress(kc, shifted, TheCIA1->KeyMatrix,
|
||||
TheCIA1->RevMatrix, &joykey);
|
||||
TheCIA1->RevMatrix);
|
||||
|
||||
this->fake_key_keytime --;
|
||||
if (this->fake_key_keytime == 0)
|
||||
@ -369,9 +369,12 @@ void C64::open_close_joysticks(bool oldjoy1, bool oldjoy2, bool newjoy1, bool ne
|
||||
uint8 C64::poll_joystick(int port)
|
||||
{
|
||||
#ifdef GEKKO
|
||||
Uint32 held = WPAD_ButtonsHeld(port);
|
||||
Uint32 held;
|
||||
uint8 j = 0xff;
|
||||
|
||||
WPAD_ScanPads();
|
||||
|
||||
held = WPAD_ButtonsHeld(port);
|
||||
if (held & WPAD_BUTTON_UP)
|
||||
j &= 0xfb; // Left
|
||||
if (held & WPAD_BUTTON_DOWN)
|
||||
@ -385,21 +388,22 @@ uint8 C64::poll_joystick(int port)
|
||||
if (held & WPAD_BUTTON_HOME)
|
||||
this->enter_menu();
|
||||
|
||||
static int maboo = 0;
|
||||
if ( (held & WPAD_BUTTON_A) && ThePrefs.JoystickKeyBinding[0])
|
||||
TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[0],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);
|
||||
TheDisplay->FakeKeyPressRepeat(ThePrefs.JoystickKeyBinding[0],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix);
|
||||
if ( (held & WPAD_BUTTON_B) && ThePrefs.JoystickKeyBinding[1])
|
||||
TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[1],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);
|
||||
TheDisplay->FakeKeyPressRepeat(ThePrefs.JoystickKeyBinding[1],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix);
|
||||
if ( (held & WPAD_BUTTON_PLUS) && ThePrefs.JoystickKeyBinding[2])
|
||||
TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[2],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);
|
||||
TheDisplay->FakeKeyPressRepeat(ThePrefs.JoystickKeyBinding[2],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix);
|
||||
if ( (held & WPAD_BUTTON_MINUS) && ThePrefs.JoystickKeyBinding[3])
|
||||
TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[3],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);
|
||||
TheDisplay->FakeKeyPressRepeat(ThePrefs.JoystickKeyBinding[3],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix);
|
||||
if ( (held & WPAD_BUTTON_1) && ThePrefs.JoystickKeyBinding[4])
|
||||
TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[4],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);
|
||||
TheDisplay->FakeKeyPressRepeat(ThePrefs.JoystickKeyBinding[4],
|
||||
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix);
|
||||
|
||||
|
||||
return j;
|
||||
@ -536,7 +540,9 @@ void C64::thread_func(void)
|
||||
break;
|
||||
}
|
||||
|
||||
this->NewPrefs(np);
|
||||
ThePrefs = *np;
|
||||
ThePrefs.Save(PREFS_PATH);
|
||||
|
||||
this->have_a_break = false;
|
||||
}
|
||||
|
@ -66,8 +66,11 @@ public:
|
||||
void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick);
|
||||
#endif
|
||||
#if defined(HAVE_SDL)
|
||||
void FakeKeyPress(int kc, bool shift, uint8 *CIA_key_matrix,
|
||||
uint8 *CIA_rev_matrix, uint8 *joystick);
|
||||
void FakeKeyPressRepeat(int kc, bool shift, uint8 *CIA_key_matrix,
|
||||
uint8 *CIA_rev_matrix);
|
||||
|
||||
void FakeKeyPress(int kc, bool shift, uint8 *CIA_key_matrix,
|
||||
uint8 *CIA_rev_matrix);
|
||||
#endif
|
||||
bool NumLock(void);
|
||||
void InitColors(uint8 *colors);
|
||||
|
@ -307,8 +307,24 @@ int C64Display::BitmapXMod(void)
|
||||
return screen->pitch;
|
||||
}
|
||||
|
||||
void C64Display::FakeKeyPressRepeat(int kc, bool shift, uint8 *CIA_key_matrix, uint8 *CIA_rev_matrix)
|
||||
{
|
||||
static int cnt = 5;
|
||||
|
||||
if (cnt > 0) {
|
||||
this->FakeKeyPress(-1, shift, CIA_key_matrix, CIA_rev_matrix);
|
||||
cnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->FakeKeyPress(kc, shift, CIA_key_matrix, CIA_rev_matrix);
|
||||
cnt = 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void C64Display::FakeKeyPress(int kc, bool shift, uint8 *CIA_key_matrix,
|
||||
uint8 *CIA_rev_matrix, uint8 *joystick)
|
||||
uint8 *CIA_rev_matrix)
|
||||
{
|
||||
// Clear matrices
|
||||
for (int i = 0; i < 8; i ++)
|
||||
|
@ -14,36 +14,46 @@
|
||||
|
||||
static int divisor = 0;
|
||||
static int to_output = 0;
|
||||
static int buffer_pos = 0;
|
||||
|
||||
void DigitalRenderer::fill_audio(Uint8 *stream, int len)
|
||||
{
|
||||
int cnt = 0;
|
||||
int cnt = 0;
|
||||
int bytes_to_write = to_output * sizeof(Uint16);
|
||||
int buf_size = this->sndbufsize * sizeof(Uint16);
|
||||
|
||||
/* Wii is stereo-only, so divide the buffer by two */
|
||||
len = len / 2;
|
||||
memset(stream, 0, len);
|
||||
if (to_output <= 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
while (cnt < bytes_to_write && cnt < len)
|
||||
{
|
||||
int datalen = buf_size;
|
||||
int datalen = buf_size;
|
||||
static Uint16 real_buf[4096];
|
||||
int i;
|
||||
|
||||
if (datalen > bytes_to_write)
|
||||
datalen = bytes_to_write;
|
||||
datalen = bytes_to_write;
|
||||
|
||||
if (datalen > len - cnt)
|
||||
datalen = len - cnt;
|
||||
if (datalen > len - cnt)
|
||||
datalen = len - cnt;
|
||||
|
||||
calc_buffer(sound_buffer, datalen);
|
||||
memcpy(stream + cnt, (Uint8*)this->sound_buffer, datalen);
|
||||
calc_buffer(sound_buffer, datalen);
|
||||
/* ... and calculate a real stereo buffer */
|
||||
for (i = 0; i < datalen; i++)
|
||||
{
|
||||
real_buf[i*2] = sound_buffer[i];
|
||||
real_buf[i*2+1] = sound_buffer[i];
|
||||
}
|
||||
/* and output it */
|
||||
memcpy(stream + cnt*2, (Uint8*)real_buf, datalen * 2);
|
||||
cnt += datalen;
|
||||
}
|
||||
if (to_output - cnt / 2 <= 0)
|
||||
to_output = 0;
|
||||
}
|
||||
if (to_output - cnt / 2 <= 0)
|
||||
to_output = 0;
|
||||
else
|
||||
to_output -= cnt / 2;
|
||||
to_output -= cnt / 2;
|
||||
}
|
||||
|
||||
void DigitalRenderer::fill_audio_helper(void *udata, Uint8 *stream, int len)
|
||||
|
@ -12,8 +12,6 @@
|
||||
|
||||
extern int init_graphics(void);
|
||||
|
||||
#define PREFS_PATH "/apps/frodo/frodorc"
|
||||
|
||||
/*
|
||||
* Create application object and start it
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user