Added Joypad as joystick function, added saving of all configurations and buttons, added some keys in virtual keyboard, fixed some small bugs.

This commit is contained in:
fabio.olimpieri 2012-05-06 10:37:14 +00:00
parent efcfba2ebf
commit 8f718942d4
9 changed files with 175 additions and 58 deletions

View File

@ -32,25 +32,25 @@
#define K(name, sdl_code) \ #define K(name, sdl_code) \
{ name, "SDLK_"name, sdl_code, 0 ,0,0} { name, sdl_code, 0 ,0, 0}
#define N(name, key_name, sdl_code) \
{ name, "SDLK_"key_name, sdl_code, 0,0,0 }
#define KNL() \ #define KNL() \
{ NULL, NULL, 0, 0 ,0,0} { NULL, 0, 0 ,0, 0}
#define KEY_COLS 10 #define KEY_COLS 10
#define KEY_ROWS 5 #define KEY_ROWS 6
extern struct computer ordenador; extern struct computer ordenador;
void clean_screen();
//TO DO Key_name and name are not necessary //TO DO Key_name and name are not necessary
static virtkey_t keys[KEY_COLS * KEY_ROWS] = { static virtkey_t keys[KEY_COLS * KEY_ROWS] = {
K("1",49),K("2",50), K("3",51), K("4",52), K("5",53), K("6",54), K("7",55), K("8",56), K("9",57), K("0",48), K(" 1",SDLK_1),K(" 2",SDLK_2), K(" 3",SDLK_3), K(" 4",SDLK_4), K(" 5",SDLK_5), K(" 6",SDLK_6), K(" 7",SDLK_7), K(" 8",SDLK_8), K(" 9",SDLK_9), K(" 0",SDLK_0),
K("Q",113), K("W",119), K("E",101), K("R",114), K("T",116), K("Y",121), K("U",117), K("I",105), K("O",111), K("P",112), K(" Q",SDLK_q), K(" W",SDLK_w), K(" E",SDLK_e), K(" R",SDLK_r), K(" T",SDLK_t), K(" Y",SDLK_y), K(" U",SDLK_u), K(" I",SDLK_i), K(" O",SDLK_o), K(" P",SDLK_p),
K("A",97), K("S",115), K("D",100), K("F",102), K("G",103), K("H",104), K("J",106), K("K",107), K("L",108),N("Enter","RETURN",13), K(" A",SDLK_a), K(" S",SDLK_s), K(" D",SDLK_d), K(" F",SDLK_f), K(" G",SDLK_g), K(" H",SDLK_h), K(" J",SDLK_j), K(" K",SDLK_k), K(" L",SDLK_l),K("Enter",SDLK_RETURN),
N("Caps","LSHIFT",304),K("Z",122),K("X",120),K("C",99), K("V",118), K("B",98), K("N",110), K("M",109), N("Sym","LCTRL",306),N("Space","SPACE",32), K("Caps",SDLK_LSHIFT),K(" Z",SDLK_z),K(" X",SDLK_x),K(" C",SDLK_c), K(" V",SDLK_v), K(" B",SDLK_b), K(" N",SDLK_n), K(" M",SDLK_m), K("Sym",SDLK_LCTRL),K("Space",SDLK_SPACE),
N("Ext","TAB",9), K("None",0),N("Del","BACKSPACE",8),K(",",44),K(".",46),N("Fire","LALT",308), K("UP",273),K("DOWN",274), K("LEFT",276),K("RIGHT",275)}; K("Ext",SDLK_TAB),K(" ,",SDLK_COMMA),K(" .",SDLK_PERIOD), K(" ;",SDLK_SEMICOLON), K(" \"",SDLK_QUOTEDBL),KNL(),K(" Up",SDLK_UP),K("Down",SDLK_DOWN), K("Left",SDLK_LEFT),K("Right",SDLK_RIGHT),
K("None",0),K("Done",1),K("Fire",SDLK_LALT),K("Del",SDLK_BACKSPACE),KNL(),KNL(),KNL(),KNL(),KNL(),KNL()};
void VirtualKeyboard_init(SDL_Surface *screen, TTF_Font *font) void VirtualKeyboard_init(SDL_Surface *screen, TTF_Font *font)
{ {
@ -151,7 +151,11 @@ struct virtkey *get_key_internal()
else if (k & KEY_SELECT) else if (k & KEY_SELECT)
{ {
virtkey_t *key = &keys[ VirtualKeyboard.sel_y * KEY_COLS + VirtualKeyboard.sel_x ]; virtkey_t *key = &keys[ VirtualKeyboard.sel_y * KEY_COLS + VirtualKeyboard.sel_x ];
/*
if (key->sdl_code == 1) // "Done"
if (keys[3 * KEY_COLS + 0 ].is_done) {key->sdl_code = 304; return key; } //Caps Shit
else if (keys[3 * KEY_COLS + 8 ].is_done) {key->sdl_code = 306; return key; } //Sym Shit
*/
if ((key->sdl_code == 304) && !keys[3 * KEY_COLS + 8 ].is_done) if ((key->sdl_code == 304) && !keys[3 * KEY_COLS + 8 ].is_done)
keys[3 * KEY_COLS + 0 ].is_done = !keys[3 * KEY_COLS + 0 ].is_done; //Caps Shit keys[3 * KEY_COLS + 0 ].is_done = !keys[3 * KEY_COLS + 0 ].is_done; //Caps Shit
else if ((key->sdl_code == 306) && !keys[3 * KEY_COLS + 0 ].is_done) else if ((key->sdl_code == 306) && !keys[3 * KEY_COLS + 0 ].is_done)
@ -170,7 +174,7 @@ struct virtkey *get_key_internal()
struct virtkey* get_key() struct virtkey* get_key()
{ {
virtkey_t *key; virtkey_t *key;
SDL_Rect rect = {32, 128, FULL_DISPLAY_X-64, FULL_DISPLAY_Y-272}; SDL_Rect rect = {32, 120, FULL_DISPLAY_X-64, FULL_DISPLAY_Y-250};
keys[3 * KEY_COLS + 0 ].is_done = 0; //Caps Shit keys[3 * KEY_COLS + 0 ].is_done = 0; //Caps Shit
keys[3 * KEY_COLS + 8 ].is_done = 0; //Sym Shift keys[3 * KEY_COLS + 8 ].is_done = 0; //Sym Shift
@ -178,6 +182,8 @@ struct virtkey* get_key()
SDL_FillRect(VirtualKeyboard.screen, &rect, SDL_MapRGB(ordenador.screen->format, 0xff, 0xff, 0xff)); SDL_FillRect(VirtualKeyboard.screen, &rect, SDL_MapRGB(ordenador.screen->format, 0xff, 0xff, 0xff));
key = get_key_internal(); key = get_key_internal();
clean_screen();
return key; return key;
} }

View File

@ -27,8 +27,7 @@
typedef struct virtkey typedef struct virtkey
{ {
const char *name; //It is not necessary in FBZX Wii const char *name;
const char *ev_name; //It is not necessary in FBZX Wii
int sdl_code; int sdl_code;
int is_done; int is_done;
int caps_on; int caps_on;

View File

@ -713,7 +713,7 @@ inline void read_keyboard () {
enum joystate_y {JOY_CENTER_Y, JOY_UP, JOY_DOWN}; enum joystate_y {JOY_CENTER_Y, JOY_UP, JOY_DOWN};
int joy_axis_x[2],joy_axis_y[2], joy_n, joybutton_n; int joy_axis_x[2],joy_axis_y[2], joy_n, joybutton_n;
static unsigned char joybutton_matrix[2][322]; static unsigned char joybutton_matrix[2][322];
unsigned char status_hat; unsigned char status_hat[2];
int fire_on[2]; int fire_on[2];
fire_on[0]=0; fire_on[0]=0;
fire_on[1]=0; fire_on[1]=0;
@ -764,11 +764,14 @@ inline void read_keyboard () {
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], joybutton_n); SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], joybutton_n);
} }
//JOY HAT //JOY HAT
status_hat = SDL_JoystickGetHat(ordenador.joystick_sdl[joy_n], 0); status_hat[joy_n] = SDL_JoystickGetHat(ordenador.joystick_sdl[joy_n], 0);
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][18])] = (status_hat & SDL_HAT_UP); if(!ordenador.joypad_as_joystick[joy_n])
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][19])] = (status_hat & SDL_HAT_DOWN); {
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][20])] = (status_hat & SDL_HAT_LEFT); joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][18])] = (status_hat[joy_n] & SDL_HAT_UP);
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][21])] = (status_hat & SDL_HAT_RIGHT); joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][19])] = (status_hat[joy_n] & SDL_HAT_DOWN);
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][20])] = (status_hat[joy_n] & SDL_HAT_LEFT);
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][21])] = (status_hat[joy_n] & SDL_HAT_RIGHT);
}
} }
//Keyboard buffer //Keyboard buffer
@ -790,7 +793,7 @@ inline void read_keyboard () {
joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer])]=1; joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer])]=1;
ordenador.kbd_buffer_pointer--; ordenador.kbd_buffer_pointer--;
countdown=15; countdown=8;
} }
@ -844,7 +847,7 @@ inline void read_keyboard () {
ordenador.keyboard_buffer[0][1]= SDLK_F6; //F6 ordenador.keyboard_buffer[0][1]= SDLK_F6; //F6
ordenador.keyboard_buffer[1][1]= 0; ordenador.keyboard_buffer[1][1]= 0;
ordenador.kbd_buffer_pointer=6; ordenador.kbd_buffer_pointer=6;
countdown=15; countdown=8;
break; break;
case SDLK_F10: // Reset emulator case SDLK_F10: // Reset emulator
@ -889,7 +892,9 @@ inline void read_keyboard () {
} }
} }
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++) for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
{
if (!ordenador.joypad_as_joystick[joy_n])
{ //No Joypad
switch (ordenador.joystick[joy_n]) { switch (ordenador.joystick[joy_n]) {
case 0: // cursor case 0: // cursor
if (ordenador.joy_axis_y_state[joy_n] == JOY_UP) ordenador.k12|= 8; if (ordenador.joy_axis_y_state[joy_n] == JOY_UP) ordenador.k12|= 8;
@ -923,7 +928,44 @@ inline void read_keyboard () {
if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.k12|= 1; fire_on[joy_n]=1;}//fire button if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.k12|= 1; fire_on[joy_n]=1;}//fire button
break; break;
} }
} }
else
{ //Joypad as Joystick
switch (ordenador.joystick[joy_n]) {
case 0: // cursor
if (status_hat[joy_n] & SDL_HAT_UP) ordenador.k12|= 8;
if (status_hat[joy_n] & SDL_HAT_DOWN) ordenador.k12|= 16;
if (status_hat[joy_n] & SDL_HAT_RIGHT) ordenador.k12|= 4;
if (status_hat[joy_n] & SDL_HAT_LEFT) ordenador.k11|= 16;
if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.k12|= 1; fire_on[joy_n]=1;}//fire button
break;
case 1: //Kempston
if (status_hat[joy_n] & SDL_HAT_UP) ordenador.jk|= 8;
if (status_hat[joy_n] & SDL_HAT_DOWN) ordenador.jk|= 4;
if (status_hat[joy_n] & SDL_HAT_RIGHT) ordenador.jk|= 1;
if (status_hat[joy_n] & SDL_HAT_LEFT) ordenador.jk|= 2;
if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.jk |= 16; fire_on[joy_n]=1;}//fire button
break;
case 2: // sinclair 1
if (status_hat[joy_n] & SDL_HAT_UP) ordenador.k11|= 8;
if (status_hat[joy_n] & SDL_HAT_DOWN) ordenador.k11|= 4;
if (status_hat[joy_n] & SDL_HAT_RIGHT) ordenador.k11|= 2;
if (status_hat[joy_n] & SDL_HAT_LEFT) ordenador.k11|= 1;
if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.k11|= 16;fire_on[joy_n]=1;} //fire button
break;
case 3: // sinclair 2
if (status_hat[joy_n] & SDL_HAT_UP) ordenador.k12|= 2;
if (status_hat[joy_n] & SDL_HAT_DOWN) ordenador.k12|= 4;
if (status_hat[joy_n] & SDL_HAT_RIGHT) ordenador.k12|= 8;
if (status_hat[joy_n] & SDL_HAT_LEFT) ordenador.k12|= 16;
if (joybutton_matrix[joy_n][SDLK_LALT]) {ordenador.k12|= 1; fire_on[joy_n]=1;}//fire button
break;
}
}
#ifdef GEKKO #ifdef GEKKO
//Wiimote Rumble //Wiimote Rumble
@ -976,7 +1018,9 @@ inline void read_keyboard () {
if (ordenador.key[SDLK_n] || joybutton_matrix[0][SDLK_n] || joybutton_matrix[1][SDLK_n]) ordenador.k15|=8; if (ordenador.key[SDLK_n] || joybutton_matrix[0][SDLK_n] || joybutton_matrix[1][SDLK_n]) ordenador.k15|=8;
if (ordenador.key[SDLK_b] || joybutton_matrix[0][SDLK_b] || joybutton_matrix[1][SDLK_b]) ordenador.k15|=16; if (ordenador.key[SDLK_b] || joybutton_matrix[0][SDLK_b] || joybutton_matrix[1][SDLK_b]) ordenador.k15|=16;
if (ordenador.key[SDLK_PERIOD] || joybutton_matrix[0][SDLK_PERIOD] || joybutton_matrix[1][SDLK_PERIOD]) ordenador.k15|=6; if (ordenador.key[SDLK_PERIOD] || joybutton_matrix[0][SDLK_PERIOD] || joybutton_matrix[1][SDLK_PERIOD]) ordenador.k15|=6;
if (ordenador.key[SDLK_COMMA]|| joybutton_matrix[0][SDLK_COMMA] || joybutton_matrix[1][SDLK_COMMA]) ordenador.k15|=10; if (ordenador.key[SDLK_COMMA]|| joybutton_matrix[0][SDLK_COMMA] || joybutton_matrix[1][SDLK_COMMA]) ordenador.k15|=10;
if (ordenador.key[SDLK_SEMICOLON]|| joybutton_matrix[0][SDLK_SEMICOLON] || joybutton_matrix[1][SDLK_SEMICOLON]) {ordenador.k13|=2; ordenador.k15|=2;}
if (ordenador.key[SDLK_QUOTEDBL]|| joybutton_matrix[0][SDLK_QUOTEDBL] || joybutton_matrix[1][SDLK_QUOTEDBL]) {ordenador.k13|=1; ordenador.k15|=2;}
if (ordenador.key[SDLK_RETURN] || joybutton_matrix[0][SDLK_RETURN] || joybutton_matrix[1][SDLK_RETURN]) ordenador.k14|=1; if (ordenador.key[SDLK_RETURN] || joybutton_matrix[0][SDLK_RETURN] || joybutton_matrix[1][SDLK_RETURN]) ordenador.k14|=1;
if (ordenador.key[SDLK_l] || joybutton_matrix[0][SDLK_l] || joybutton_matrix[1][SDLK_l]) ordenador.k14|=2; if (ordenador.key[SDLK_l] || joybutton_matrix[0][SDLK_l] || joybutton_matrix[1][SDLK_l]) ordenador.k14|=2;
@ -1384,7 +1428,7 @@ void set_volume (unsigned char volume) {
ordenador.volume = vol2; ordenador.volume = vol2;
for (bucle = 0; bucle < 4; bucle++) { for (bucle = 0; bucle < 4; bucle++) {
ordenador.sample0[bucle] = 0; //ordenador.sample0[bucle] = 0;
ordenador.sample1[bucle] = 0; ordenador.sample1[bucle] = 0;
ordenador.sample1b[bucle] = 0; ordenador.sample1b[bucle] = 0;
} }

View File

@ -97,14 +97,14 @@ struct computer {
int tst_sample; // number of tstates per sample int tst_sample; // number of tstates per sample
int freq; // frequency for reproduction int freq; // frequency for reproduction
int format; // 0: 8 bits, 1: 16 bits LSB, 2: 16 bits MSB int format; // 0: 8 bits, 1: 16 bits LSB, 2: 16 bits MSB
signed char sign; // 0: unsigned; 1: signed signed char sign; // 0: unsigned; -128: signed
int channels; // number of channels int channels; // number of channels
int buffer_len; // sound buffer length (in samples) int buffer_len; // sound buffer length (in samples)
int increment; // cuantity to add to jump to the next sample int increment; // quantity to add to jump to the next sample
unsigned char volume; // volume unsigned char volume; // volume
unsigned char sample1[4]; // buffer with precalculated sample 1 (for buzzer) unsigned char sample1[4]; // buffer with precalculated sample 1 (for buzzer) -currently not used
unsigned char sample1b[4]; // buffer with prec. sample 1 (for AY-3-8912) unsigned char sample1b[4]; // buffer with prec. sample 1 (for AY-3-8912)
unsigned char sample0[4]; // buffer with precalculated sample 0 //unsigned char sample0[4]; // buffer with precalculated sample 0
unsigned char sound_bit; unsigned char sound_bit;
unsigned int tstados_counter_sound; unsigned int tstados_counter_sound;
unsigned char *current_buffer; unsigned char *current_buffer;
@ -204,8 +204,8 @@ struct computer {
SDL_Joystick *joystick_sdl[2]; SDL_Joystick *joystick_sdl[2];
unsigned char joy_axis_x_state[2]; unsigned char joy_axis_x_state[2];
unsigned char joy_axis_y_state[2]; unsigned char joy_axis_y_state[2];
//unsigned char joy_fire[2];
unsigned int joybuttonkey[2][22]; unsigned int joybuttonkey[2][22];
unsigned char joypad_as_joystick[2];
unsigned char rumble[2]; unsigned char rumble[2];
}; };

View File

@ -337,8 +337,8 @@ void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hw
printf("Init sound 2\n"); printf("Init sound 2\n");
ordenador.tst_sample=3500000/ordenador.freq; ordenador.tst_sample=3500000/ordenador.freq;
printf("Set volume\n"); //printf("Set volume\n");
set_volume(70); //set_volume(70);
printf("Return init\n"); printf("Return init\n");
} }
@ -394,7 +394,8 @@ void load_main_game(char *nombre) {
void save_config(struct computer *object) { void save_config(struct computer *object) {
char config_path[1024]; char config_path[1024];
int length; int length;
unsigned char key, joy_n;
FILE *fconfig; FILE *fconfig;
strcpy(config_path,getenv("HOME")); strcpy(config_path,getenv("HOME"));
@ -415,16 +416,29 @@ void save_config(struct computer *object) {
fprintf(fconfig,"doublescan=%c%c",48+object->dblscan,10); fprintf(fconfig,"doublescan=%c%c",48+object->dblscan,10);
fprintf(fconfig,"volume=%c%c",65+(object->volume/4),10); fprintf(fconfig,"volume=%c%c",65+(object->volume/4),10);
fprintf(fconfig,"bw=%c%c",48+object->bw,10); fprintf(fconfig,"bw=%c%c",48+object->bw,10);
fprintf(fconfig,"tap_fast=%c%c",48+object->tape_fast_load,10);
fprintf(fconfig,"joypad1=%c%c",48+object->joypad_as_joystick[0],10);
fprintf(fconfig,"joypad2=%c%c",48+object->joypad_as_joystick[1],10);
fprintf(fconfig,"rumble1=%c%c",48+object->rumble[0],10);
fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10);
for (joy_n=0; joy_n<2; joy_n++)
for (key=0; key<22; key++)
fprintf(fconfig,"joybutton_%c_%c=%.3d%c",joy_n+48,key+97, object->joybuttonkey[joy_n][key],10);
fclose(fconfig); fclose(fconfig);
} }
void load_config(struct computer *object) { void load_config(struct computer *object) {
char config_path[1024]; char config_path[1024];
char line[1024],carac,done; char line[1024],carac,done;
int length,pos; int length,pos, key_sdl=0;;
FILE *fconfig; FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,joystick1=255,joystick2=255,ay_emul=255,mdr_active=255,dblscan=255,bw=255; unsigned char volume=255,mode128k=255,issue=255,joystick1=255,joystick2=255,ay_emul=255,mdr_active=255,
dblscan=255,bw=255, tap_fast=0, joypad1=0, joypad2=0, rumble1=0, rumble2=0, joy_n=0, key_n=0;
strcpy(config_path,getenv("HOME")); strcpy(config_path,getenv("HOME"));
length=strlen(config_path); length=strlen(config_path);
@ -468,12 +482,12 @@ void load_config(struct computer *object) {
issue=line[6]-'0'; issue=line[6]-'0';
continue; continue;
} }
if (!strncmp(line,"joystick1=",9)) { if (!strncmp(line,"joystick1=",10)) {
joystick1=line[9]-'0'; joystick1=line[10]-'0';
continue; continue;
} }
if (!strncmp(line,"joystick2=",9)) { if (!strncmp(line,"joystick2=",10)) {
joystick2=line[9]-'0'; joystick2=line[10]-'0';
continue; continue;
} }
if (!strncmp(line,"ay_sound=",9)) { if (!strncmp(line,"ay_sound=",9)) {
@ -496,6 +510,32 @@ void load_config(struct computer *object) {
bw=(line[3]-'0'); bw=(line[3]-'0');
continue; continue;
} }
if (!strncmp(line,"tap_fast=",9)) {
tap_fast=(line[9]-'0');
continue;
}
if (!strncmp(line,"joypad1=",8)) {
joypad1=line[8]-'0';
continue;
}
if (!strncmp(line,"joypad2=",8)) {
joypad2=line[8]-'0';
continue;
}
if (!strncmp(line,"rumble1=",8)) {
rumble1=line[8]-'0';
continue;
}
if (!strncmp(line,"rumble2=",8)) {
rumble2=line[8]-'0';
continue;
}
if (!strncmp(line,"joybutton_",10)) {
sscanf(line, "joybutton_%c_%c=%3d",&joy_n ,&key_n, &key_sdl);
if ((joy_n<50) && (joy_n>47) && (key_n<119) && (key_n>96))
object->joybuttonkey[joy_n-48][key_n-97]=key_sdl;
continue;
}
} }
if (mode128k<5) { if (mode128k<5) {
@ -526,7 +566,22 @@ void load_config(struct computer *object) {
object->volume=volume; object->volume=volume;
set_volume(volume); set_volume(volume);
} }
if (tap_fast<2) {
object->tape_fast_load=tap_fast;
}
if (joypad1<2) {
object->joypad_as_joystick[0]=joypad1;
}
if (joypad2<2) {
object->joypad_as_joystick[1]=joypad2;
}
if (rumble1<2) {
object->rumble[0]=rumble1;
}
if (rumble2<2) {
object->rumble[1]=rumble2;
}
fclose(fconfig); fclose(fconfig);
} }
@ -581,6 +636,10 @@ int main(int argc,char *argv[]) {
printf("Computer init\n"); printf("Computer init\n");
printf("Modo: %d\n",ordenador.mode128k); printf("Modo: %d\n",ordenador.mode128k);
printf("Set volume\n");
set_volume(70);
// load current config // load current config
load_config(&ordenador); load_config(&ordenador);
printf("Modo: %d\n",ordenador.mode128k); printf("Modo: %d\n",ordenador.mode128k);

View File

@ -50,6 +50,7 @@ extern FILE *fdebug;
#endif #endif
extern int countdown; extern int countdown;
void clean_screen();
static const char *main_menu_messages[] = { static const char *main_menu_messages[] = {
@ -98,9 +99,11 @@ static const char *input_messages[] = {
/*06*/ "Bind key to Classic", /*06*/ "Bind key to Classic",
/*07*/ "^|a|b|x|y|L|R|Zl|Zr|-", /*07*/ "^|a|b|x|y|L|R|Zl|Zr|-",
/*08*/ "Bind key to Pad", /*08*/ "Bind key to Pad",
/*09*/ "^|UP|DOWN|LEFT|RIGHT", /*09*/ "^|Up|Down|Left|Right",
/*10*/ "Rumble", /*10*/ "Use Joypad as Joystick",
/*11*/ "^|On|Off", /*11*/ "^|On|Off",
/*12*/ "Rumble",
/*13*/ "^|On|Off",
NULL, NULL,
}; };
@ -236,7 +239,7 @@ static void manage_tape(int which)
break; break;
case 1: //Emulate load "" case 1: //Emulate load ""
ordenador.kbd_buffer_pointer=6; ordenador.kbd_buffer_pointer=6;
countdown=15; countdown=8;
ordenador.keyboard_buffer[0][6]= SDLK_1; //Edit ordenador.keyboard_buffer[0][6]= SDLK_1; //Edit
ordenador.keyboard_buffer[1][6]= SDLK_LSHIFT; ordenador.keyboard_buffer[1][6]= SDLK_LSHIFT;
ordenador.keyboard_buffer[0][5]= SDLK_j; //Load ordenador.keyboard_buffer[0][5]= SDLK_j; //Load
@ -348,7 +351,7 @@ static void emulation_settings(void)
if (submenus[0] != submenus_old[0]) ResetComputer(); else if (submenus[0] != submenus_old[0]) ResetComputer(); else
ordenador.ay_emul = !submenus[6]; ordenador.ay_emul = !submenus[6];
ordenador.volume = submenus[1]*8; ordenador.volume = submenus[1]*8; //I should use set_volume() ?
ordenador.tape_fast_load = !submenus[2]; ordenador.tape_fast_load = !submenus[2];
ordenador.turbo = !submenus[3]; ordenador.turbo = !submenus[3];
@ -386,7 +389,7 @@ static void input_options(int joy)
const unsigned int pad_to_sdl[] = {18, 19, 20, 21}; const unsigned int pad_to_sdl[] = {18, 19, 20, 21};
int joy_key = 1; int joy_key = 1;
unsigned int sdl_key; unsigned int sdl_key;
unsigned int submenus[6]; unsigned int submenus[7];
int opt; int opt;
struct virtkey *virtualkey; struct virtkey *virtualkey;
@ -394,7 +397,8 @@ static void input_options(int joy)
memset(submenus, 0, sizeof(submenus)); memset(submenus, 0, sizeof(submenus));
submenus[0] = ordenador.joystick[joy]; submenus[0] = ordenador.joystick[joy];
submenus[5] = !ordenador.rumble[joy]; submenus[5] = !ordenador.joypad_as_joystick[joy];
submenus[6] = !ordenador.rumble[joy];
opt = menu_select_title("Input menu", opt = menu_select_title("Input menu",
input_messages, submenus); input_messages, submenus);
@ -402,9 +406,10 @@ static void input_options(int joy)
return; return;
ordenador.joystick[joy] = submenus[0]; ordenador.joystick[joy] = submenus[0];
ordenador.rumble[joy] = !submenus[5]; ordenador.joypad_as_joystick[joy] = !submenus[5];
ordenador.rumble[joy] = !submenus[6];
if (opt == 0 || opt == 10) if (opt == 0 || opt == 10|| opt == 12)
return; return;
virtualkey = get_key(); virtualkey = get_key();
@ -412,6 +417,11 @@ static void input_options(int joy)
return; return;
sdl_key = virtualkey->sdl_code; sdl_key = virtualkey->sdl_code;
if (virtualkey->sdl_code==1) //"Done" selected
{if (virtualkey->caps_on) sdl_key = 304; //Caps Shit
else if (virtualkey->sym_on) sdl_key = 306; //Sym Shit
else return; }
switch(opt) switch(opt)
{ {
case 2: // wiimote case 2: // wiimote
@ -744,7 +754,7 @@ void virtual_keyboard(void)
if (key) {key_code = key->sdl_code;} else return; if (key) {key_code = key->sdl_code;} else return;
ordenador.kbd_buffer_pointer=1; ordenador.kbd_buffer_pointer=1;
countdown=15; countdown=8;
ordenador.keyboard_buffer[0][1]= key_code; ordenador.keyboard_buffer[0][1]= key_code;
if (key->caps_on) ordenador.keyboard_buffer[1][1]= SDLK_LSHIFT; if (key->caps_on) ordenador.keyboard_buffer[1][1]= SDLK_LSHIFT;
else if (key->sym_on) ordenador.keyboard_buffer[1][1]= SDLK_LCTRL; else if (key->sym_on) ordenador.keyboard_buffer[1][1]= SDLK_LCTRL;
@ -896,4 +906,6 @@ void main_menu()
} }
} while (opt == 5 || opt == 7 || opt == 8 || opt == 12); } while (opt == 5 || opt == 7 || opt == 8 || opt == 12);
clean_screen();
} }

View File

@ -1887,8 +1887,6 @@ void keyboard_menu() {
wait_key(); wait_key();
clean_screen(); clean_screen();
} }
void clean_screen() { void clean_screen() {

View File

@ -81,7 +81,6 @@ int sound_init() {
ordenador.sign=0; ordenador.sign=0;
ordenador.format=0; ordenador.format=0;
ordenador.channels=1; ordenador.channels=1;
ordenador.channels = 1;
ordenador.freq=48000; ordenador.freq=48000;
ordenador.buffer_len=4800; // will wait 1/10 second ordenador.buffer_len=4800; // will wait 1/10 second
return (0); return (0);
@ -183,8 +182,8 @@ int sound_init_asnd() {
ASND_Init(); ASND_Init();
ASND_Pause(0); ASND_Pause(0);
ordenador.sign=0; ordenador.sign=0;
ordenador.format=0; ordenador.format=0; //8 bit
ordenador.channels=1; ordenador.channels=1; //mono
ordenador.freq=48000; ordenador.freq=48000;
ordenador.buffer_len=4096; ordenador.buffer_len=4096;
started_sound_asnd = 0; started_sound_asnd = 0;
@ -497,7 +496,7 @@ void sound_play() {
case SOUND_ASND: // ASND case SOUND_ASND: // ASND
if (!started_sound_asnd) { if (!started_sound_asnd) {
ASND_SetVoice(1,VOICE_MONO_8BIT,48000,0,sound[0],ordenador.buffer_len, ASND_SetVoice(1,VOICE_MONO_8BIT,48000,0,sound[0],ordenador.buffer_len,
ordenador.volume, ordenador.volume, callback); MID_VOLUME, MID_VOLUME, callback);
started_sound_asnd = 1; started_sound_asnd = 1;
} }
//Double buffer //Double buffer

View File

@ -288,7 +288,7 @@ inline void play_sound (unsigned int tstados) {
while (ordenador.tstados_counter_sound >= ordenador.tst_sample) { while (ordenador.tstados_counter_sound >= ordenador.tst_sample) {
ordenador.tstados_counter_sound -= ordenador.tst_sample; ordenador.tstados_counter_sound -= ordenador.tst_sample;
if (sound_type!=1) if (sound_type!=1) //!SOUND_OSS
for (bucle = 0; bucle < ordenador.increment; bucle++) { for (bucle = 0; bucle < ordenador.increment; bucle++) {
sample_v = ordenador.sample1b[bucle]; sample_v = ordenador.sample1b[bucle];
if ((ordenador.sound_bit) && (sample_v)) { if ((ordenador.sound_bit) && (sample_v)) {