Rewritten the event processing, added arrow keys emulation, file name in save snapshot menu

This commit is contained in:
fabio.olimpieri 2012-04-15 18:16:37 +00:00
parent c8973f8493
commit 449ed4a2da
5 changed files with 1676 additions and 1907 deletions

View File

@ -124,6 +124,7 @@ void computer_init () {
ordenador.tape_loop_counter = 0; ordenador.tape_loop_counter = 0;
ordenador.kbd_buffer_pointer = 0; ordenador.kbd_buffer_pointer = 0;
ordenador.key = SDL_GetKeyState(NULL);
} }
void computer_set_palete() { void computer_set_palete() {
@ -691,14 +692,19 @@ inline void paint_one_pixel(unsigned char *colour,unsigned char *address) {
// Read the keyboard and stores the flags // Read the keyboard and stores the flags
inline void read_keyboard (SDL_Event *pevento2) { inline void read_keyboard () {
unsigned int temporal_io; unsigned int temporal_io;
SDL_Event evento,evento2,*pevento; SDL_Event evento,*pevento;
Sint16 valor;
Uint8 eje;
static int countdown; static int countdown;
enum joystate_x {JOY_CENTER_X, JOY_LEFT, JOY_RIGHT};
enum joystate_y {JOY_CENTER_Y, JOY_UP, JOY_DOWN};
int joy_axis_x,joy_axis_y, joy_fire;
ordenador.k8 = ordenador.k9 = ordenador.k10 = ordenador.k11 =
ordenador.k12 = ordenador.k13 = ordenador.k14 =
ordenador.k15 = 0;
ordenador.jk = 0;
if (ordenador.kbd_buffer_pointer) if (ordenador.kbd_buffer_pointer)
{ {
@ -706,99 +712,64 @@ inline void read_keyboard (SDL_Event *pevento2) {
countdown--; countdown--;
else else
{ {
if (ordenador.kbd_buffer_pointer != 1) switch (ordenador.kbd_buffer_pointer)
{ {
SDL_PushEvent(&ordenador.keyboard_buffer[ordenador.kbd_buffer_pointer-2]); case 6: //Edit
ordenador.k8|=1;
ordenador.k11|=1;
break;
case 5: //Load
ordenador.k14|= 8;
break;
case 4: //"
ordenador.k15|= 2;
ordenador.k13|= 1;
break;
case 3: //"
ordenador.k15|= 2;
ordenador.k13|= 1;
break;
case 2: // Return
ordenador.k14|= 1;
break;
case 1:
if ((ordenador.tape_fast_load == 0) || (ordenador.tape_file_type==TAP_TZX))
ordenador.pause = 0;
break;
}
ordenador.kbd_buffer_pointer--; ordenador.kbd_buffer_pointer--;
countdown=5; countdown=5;
}
else
{
ordenador.kbd_buffer_pointer = 0;
if ((ordenador.tape_fast_load == 0) || (ordenador.tape_file_type==TAP_TZX))
ordenador.pause = 0;
}
} }
} }
if (pevento2==NULL) {
pevento=&evento; pevento=&evento;
if (!SDL_PollEvent (&evento)) SDL_PollEvent (&evento);
return;
} else {
pevento=pevento2;
}
if (pevento->type==SDL_QUIT) { if (pevento->type==SDL_QUIT) {
salir = 0; salir = 0;
return; return;
} }
if (pevento->type==SDL_JOYBUTTONDOWN) { SDL_JoystickUpdate();
pevento->type=SDL_KEYDOWN; joy_axis_x = SDL_JoystickGetAxis(ordenador.joystick_sdl[0], 0);
pevento->key.keysym.sym=SDLK_MENU; // emulate pressing the MENU key joy_axis_y = SDL_JoystickGetAxis(ordenador.joystick_sdl[0], 1);
} joy_fire = SDL_JoystickGetButton(ordenador.joystick_sdl[0], 0); //Wii button A
if (pevento->type==SDL_JOYBUTTONUP) { if (SDL_JoystickGetButton(ordenador.joystick_sdl[0], 6)) help_menu ();
pevento->type=SDL_KEYUP;
pevento->key.keysym.sym=SDLK_MENU; // emulate depressing the MENU key
}
if (pevento->type==SDL_JOYAXISMOTION) { if (joy_axis_x > 16384) ordenador.joy_axis_x_state[0] = JOY_RIGHT;
eje=pevento->jaxis.axis; else if (joy_axis_x < -16384) ordenador.joy_axis_x_state[0] = JOY_LEFT;
valor=pevento->jaxis.value; else ordenador.joy_axis_x_state[0] = JOY_CENTER_X;
evento2.type=SDL_KEYUP; if (joy_axis_y > 16384) ordenador.joy_axis_y_state[0] = JOY_DOWN;
if ((valor<16384)&&(valor>-16384)) { // JoyStick centered else if (joy_axis_y < -16384) ordenador.joy_axis_y_state[0] = JOY_UP;
pevento->type=SDL_KEYUP; else ordenador.joy_axis_y_state[0] = JOY_CENTER_Y;
if (eje==1) {
evento2.key.keysym.sym=SDLK_DOWN;
pevento->key.keysym.sym=SDLK_UP; // pull up both keys
read_keyboard(&evento2);
}
if (eje==0) {
evento2.key.keysym.sym=SDLK_LEFT;
pevento->key.keysym.sym=SDLK_RIGHT;
read_keyboard(&evento2);
}
} else { // JoyStick moved
if (eje==0) {
if (valor>=0) {
evento2.key.keysym.sym=SDLK_LEFT; // pull up LEFT
read_keyboard(&evento2);
pevento->key.keysym.sym=SDLK_RIGHT; // and press RIGHT
} else {
evento2.key.keysym.sym=SDLK_RIGHT; // pull up RIGHT
read_keyboard(&evento2);
pevento->key.keysym.sym=SDLK_LEFT; // and press LEFT
}
}
if (eje==1) {
if (valor<0) {
evento2.key.keysym.sym=SDLK_DOWN; // pull up DOWN
pevento->key.keysym.sym=SDLK_UP; // and press UP
read_keyboard(&evento2);
} else {
evento2.key.keysym.sym=SDLK_UP; // pull up UP
pevento->key.keysym.sym=SDLK_DOWN; // and press DOWN
read_keyboard(&evento2);
}
}
pevento->type=SDL_KEYDOWN;
}
}
if ((pevento->type != SDL_KEYDOWN) && (pevento->type != SDL_KEYUP))
return;
ordenador.k8 = ordenador.k9 = ordenador.k10 = ordenador.k11 =
ordenador.k12 = ordenador.k13 = ordenador.k14 =
ordenador.k15 = 0;
ordenador.jk = 0;
temporal_io = (unsigned int) pevento->key.keysym.sym; temporal_io = (unsigned int) pevento->key.keysym.sym;
if ((pevento->type==SDL_KEYUP)&&(temporal_io==SDLK_TAB)) { /*
if ((pevento->type==SDL_KEYDOWN)&&(temporal_io==SDLK_TAB)) {
if (ordenador.tab_extended==0) { if (ordenador.tab_extended==0) {
ordenador.tab_extended=1; ordenador.tab_extended=1;
strcpy(ordenador.osd_text,"Function Key mode on"); strcpy(ordenador.osd_text,"Function Key mode on");
@ -811,10 +782,7 @@ inline void read_keyboard (SDL_Event *pevento2) {
} }
} }
if ((pevento->type==SDL_KEYDOWN)&&(ordenador.tab_extended==1)) if ((pevento->type==SDL_KEYDOWN)&&(ordenador.tab_extended==1)) {
return;
if ((pevento->type==SDL_KEYUP)&&(ordenador.tab_extended==1)) {
ordenador.tab_extended=0; ordenador.tab_extended=0;
ordenador.osd_time=0; ordenador.osd_time=0;
switch(temporal_io) { switch(temporal_io) {
@ -856,9 +824,8 @@ inline void read_keyboard (SDL_Event *pevento2) {
break; break;
} }
} }
*/
if (pevento->type == SDL_KEYDOWN)
if (pevento->type == SDL_KEYUP)
switch (temporal_io) { switch (temporal_io) {
case SDLK_ESCAPE: // to exit from the emulator case SDLK_ESCAPE: // to exit from the emulator
if (ordenador.esc_again==0) { if (ordenador.esc_again==0) {
@ -892,43 +859,10 @@ inline void read_keyboard (SDL_Event *pevento2) {
break; break;
case SDLK_F9: case SDLK_F9:
//SDL_Fullscreen_Switch();
//Emulate load "" //Emulate load ""
ordenador.keyboard_buffer[9].key.keysym.sym=SDLK_j; ordenador.kbd_buffer_pointer=6;
ordenador.keyboard_buffer[9].type=SDL_KEYDOWN;
ordenador.keyboard_buffer[8].key.keysym.sym=SDLK_j;
ordenador.keyboard_buffer[8].type=SDL_KEYUP;
ordenador.keyboard_buffer[7].key.keysym.sym=SDLK_RCTRL;
ordenador.keyboard_buffer[7].type=SDL_KEYDOWN;
ordenador.keyboard_buffer[6].key.keysym.sym=SDLK_p;
ordenador.keyboard_buffer[6].type=SDL_KEYDOWN;
ordenador.keyboard_buffer[5].key.keysym.sym=SDLK_p;
ordenador.keyboard_buffer[5].type=SDL_KEYUP;
ordenador.keyboard_buffer[4].key.keysym.sym=SDLK_p;
ordenador.keyboard_buffer[4].type=SDL_KEYDOWN;
ordenador.keyboard_buffer[3].key.keysym.sym=SDLK_p;
ordenador.keyboard_buffer[3].type=SDL_KEYUP;
ordenador.keyboard_buffer[2].key.keysym.sym=SDLK_RCTRL;
ordenador.keyboard_buffer[2].type=SDL_KEYUP;
ordenador.keyboard_buffer[1].key.keysym.sym=SDLK_RETURN;
ordenador.keyboard_buffer[1].type=SDL_KEYDOWN;
ordenador.keyboard_buffer[0].key.keysym.sym=SDLK_RETURN;
ordenador.keyboard_buffer[0].type=SDL_KEYUP;
ordenador.kbd_buffer_pointer=11;
countdown=5; countdown=5;
break; break;
case SDLK_F10: // Reset emulator case SDLK_F10: // Reset emulator
@ -973,315 +907,107 @@ inline void read_keyboard (SDL_Event *pevento2) {
} }
} }
switch (ordenador.joystick) {
// test for joystick
switch (temporal_io) {
case SDLK_UP:
switch (ordenador.joystick) {
case 0: // cursor case 0: // cursor
temporal_io = SDLK_7; if (ordenador.joy_axis_y_state[0] == JOY_UP) ordenador.k12|= 8;
if (ordenador.joy_axis_y_state[0] == JOY_DOWN) ordenador.k12|= 16;
if (ordenador.joy_axis_x_state[0] == JOY_RIGHT)ordenador.k12|= 4;
if (ordenador.joy_axis_x_state[0] == JOY_LEFT) ordenador.k11|= 16;
if (joy_fire) ordenador.k12|= 1;
break; break;
case 1: case 1: //Kempston
ordenador.jk = 8; if (ordenador.joy_axis_y_state[0] == JOY_UP) ordenador.jk|= 8;
if (ordenador.joy_axis_y_state[0] == JOY_DOWN) ordenador.jk|= 4;
if (ordenador.joy_axis_x_state[0] == JOY_RIGHT) ordenador.jk|= 1;
if (ordenador.joy_axis_x_state[0] == JOY_LEFT) ordenador.jk|= 2;
if (joy_fire) ordenador.jk = 16;
break; break;
case 2: // sinclair 1 case 2: // sinclair 1
temporal_io = SDLK_4; if (ordenador.joy_axis_y_state[0] == JOY_UP) ordenador.k11|= 8;
if (ordenador.joy_axis_y_state[0] == JOY_DOWN)ordenador.k11|= 4;
if (ordenador.joy_axis_x_state[0] == JOY_RIGHT)ordenador.k11|= 2;
if (ordenador.joy_axis_x_state[0] == JOY_LEFT) ordenador.k11|= 1;
if (joy_fire) ordenador.k11|= 16;
break; break;
case 3: // sinclair 2 case 3: // sinclair 2
temporal_io = SDLK_9; if (ordenador.joy_axis_y_state[0] == JOY_UP) ordenador.k12|= 2;
if (ordenador.joy_axis_y_state[0] == JOY_DOWN)ordenador.k12|= 4;
if (ordenador.joy_axis_x_state[0] == JOY_RIGHT)ordenador.k12|= 8;
if (ordenador.joy_axis_x_state[0] == JOY_LEFT) ordenador.k12|= 16;
if (joy_fire) ordenador.k12|= 1;
break; break;
} }
break;
case SDLK_DOWN: if (ordenador.key[SDLK_SPACE]) ordenador.k15|=1;
switch (ordenador.joystick) { if (ordenador.key[SDLK_RCTRL]) ordenador.k15|=2;
case 0: // cursor if (ordenador.key[SDLK_LCTRL]) ordenador.k15|=2;
temporal_io = SDLK_6; if (ordenador.key[SDLK_m]) ordenador.k15|=4;
break; if (ordenador.key[SDLK_n]) ordenador.k15|=8;
if (ordenador.key[SDLK_b]) ordenador.k15|=16;
if (ordenador.key[SDLK_PERIOD]) ordenador.k15|=6;
if (ordenador.key[SDLK_COMMA]) ordenador.k15|=10;
case 1: if (ordenador.key[SDLK_RETURN]) ordenador.k14|=1;
ordenador.jk = 4; if (ordenador.key[SDLK_l]) ordenador.k14|=2;
break; if (ordenador.key[SDLK_k]) ordenador.k14|=4;
if (ordenador.key[SDLK_j]) ordenador.k14|=8;
if (ordenador.key[SDLK_h]) ordenador.k14|=16;
case 2: // sinclair 1 if (ordenador.key[SDLK_p]) ordenador.k13|=1;
temporal_io = SDLK_3; if (ordenador.key[SDLK_o]) ordenador.k13|=2;
break; if (ordenador.key[SDLK_i]) ordenador.k13|=4;
if (ordenador.key[SDLK_u]) ordenador.k13|=8;
if (ordenador.key[SDLK_y]) ordenador.k13|=16;
case 3: // sinclair 2 if (ordenador.key[SDLK_0]) ordenador.k12|=1;
temporal_io = SDLK_8; if (ordenador.key[SDLK_9]) ordenador.k12|=2;
break; if (ordenador.key[SDLK_8]) ordenador.k12|=4;
} if (ordenador.key[SDLK_7]) ordenador.k12|=8;
break; if (ordenador.key[SDLK_6]) ordenador.k12|=16;
if (ordenador.key[SDLK_BACKSPACE]) {ordenador.k12|=1; ordenador.k8 |=1;}
case SDLK_RIGHT: if (ordenador.key[SDLK_1]) ordenador.k11|=1;
switch (ordenador.joystick) { if (ordenador.key[SDLK_2]) ordenador.k11|=2;
case 0: // cursor if (ordenador.key[SDLK_3]) ordenador.k11|=4;
temporal_io = SDLK_8; if (ordenador.key[SDLK_4]) ordenador.k11|=8;
break; if (ordenador.key[SDLK_5]) ordenador.k11|=16;
case 1: if (ordenador.key[SDLK_q]) ordenador.k10|=1;
ordenador.jk = 1; if (ordenador.key[SDLK_w]) ordenador.k10|=2;
break; if (ordenador.key[SDLK_e]) ordenador.k10|=4;
if (ordenador.key[SDLK_r]) ordenador.k10|=8;
if (ordenador.key[SDLK_t]) ordenador.k10|=16;
case 2: // sinclair 1 if (ordenador.key[SDLK_a]) ordenador.k9 |=1;
temporal_io = SDLK_2; if (ordenador.key[SDLK_s]) ordenador.k9 |=2;
break; if (ordenador.key[SDLK_d]) ordenador.k9 |=4;
if (ordenador.key[SDLK_f]) ordenador.k9 |=8;
if (ordenador.key[SDLK_g]) ordenador.k9 |=16;
case 3: // sinclair 2 if (ordenador.key[SDLK_RSHIFT]) ordenador.k8 |=1;
temporal_io = SDLK_7; if (ordenador.key[SDLK_LSHIFT]) ordenador.k8 |=1;
break; if (ordenador.key[SDLK_z]) ordenador.k8 |=2;
if (ordenador.key[SDLK_x]) ordenador.k8 |=4;
if (ordenador.key[SDLK_c]) ordenador.k8 |=8;
if (ordenador.key[SDLK_v]) ordenador.k8 |=16;
} if (ordenador.key[SDLK_UP]) {ordenador.k12 |=8;ordenador.k8|=1;}
break; if (ordenador.key[SDLK_DOWN]) {ordenador.k12 |=16;ordenador.k8|=1;}
if (ordenador.key[SDLK_LEFT]) {ordenador.k11 |=16;ordenador.k8|=1;}
if (ordenador.key[SDLK_RIGHT]) {ordenador.k12 |=4;ordenador.k8|=1;}
case SDLK_LEFT: ordenador.s8 = (ordenador.s8 & 0xE0) | (ordenador.k8 ^ 0x1F);
switch (ordenador.joystick) { ordenador.s9 = (ordenador.s9 & 0xE0) | (ordenador.k9 ^ 0x1F);
case 0: // cursor ordenador.s10 = (ordenador.s10 & 0xE0)| (ordenador.k10 ^ 0x1F);
temporal_io = SDLK_5; ordenador.s11 = (ordenador.s11 & 0xE0)| (ordenador.k11 ^ 0x1F);
break; ordenador.s12 = (ordenador.s12 & 0xE0)| (ordenador.k12 ^ 0x1F);
ordenador.s13 = (ordenador.s13 & 0xE0)| (ordenador.k13 ^ 0x1F);
case 1: ordenador.s14 = (ordenador.s14 & 0xE0)| (ordenador.k14 ^ 0x1F);
ordenador.jk = 2; ordenador.s15 = (ordenador.s15 & 0xE0)| (ordenador.k15 ^ 0x1F);
break; ordenador.js = ordenador.jk;
case 2: // sinclair 1
temporal_io = SDLK_1;
break;
case 3: // sinclair 2
temporal_io = SDLK_6;
break;
}
break;
case SDLK_RALT:
case SDLK_RMETA:
case SDLK_LMETA:
case SDLK_RSUPER:
case SDLK_LSUPER:
case SDLK_MENU:
switch (ordenador.joystick) {
case 0: // cursor
temporal_io = SDLK_0;
break;
case 1:
ordenador.jk = 16;
break;
case 2: // sinclair 1
temporal_io = SDLK_5;
break;
case 3: // sinclair 2
temporal_io = SDLK_0;
break;
}
break;
}
switch (temporal_io) {
case SDLK_SPACE:
ordenador.k15 = 1;
break;
case SDLK_RCTRL:
case SDLK_LCTRL:
ordenador.k15 = 2;
break;
case SDLK_m:
ordenador.k15 = 4;
break;
case SDLK_n:
ordenador.k15 = 8;
break;
case SDLK_b:
ordenador.k15 = 16;
break;
case SDLK_RETURN:
ordenador.k14 = 1;
break;
case SDLK_l:
ordenador.k14 = 2;
break;
case SDLK_k:
ordenador.k14 = 4;
break;
case SDLK_j:
ordenador.k14 = 8;
break;
case SDLK_h:
ordenador.k14 = 16;
break;
case SDLK_p:
ordenador.k13 = 1;
break;
case SDLK_o:
ordenador.k13 = 2;
break;
case SDLK_i:
ordenador.k13 = 4;
break;
case SDLK_u:
ordenador.k13 = 8;
break;
case SDLK_y:
ordenador.k13 = 16;
break;
case SDLK_0:
ordenador.k12 = 1;
break;
case SDLK_9:
ordenador.k12 = 2;
break;
case SDLK_8:
ordenador.k12 = 4;
break;
case SDLK_7:
ordenador.k12 = 8;
break;
case SDLK_6:
ordenador.k12 = 16;
break;
case SDLK_1:
ordenador.k11 = 1;
break;
case SDLK_2:
ordenador.k11 = 2;
break;
case SDLK_3:
ordenador.k11 = 4;
break;
case SDLK_4:
ordenador.k11 = 8;
break;
case SDLK_5:
ordenador.k11 = 16;
break;
case SDLK_q:
ordenador.k10 = 1;
break;
case SDLK_w:
ordenador.k10 = 2;
break;
case SDLK_e:
ordenador.k10 = 4;
break;
case SDLK_r:
ordenador.k10 = 8;
break;
case SDLK_t:
ordenador.k10 = 16;
break;
case SDLK_a:
ordenador.k9 = 1;
break;
case SDLK_s:
ordenador.k9 = 2;
break;
case SDLK_d:
ordenador.k9 = 4;
break;
case SDLK_f:
ordenador.k9 = 8;
break;
case SDLK_g:
ordenador.k9 = 16;
break;
case SDLK_RSHIFT:
case SDLK_LSHIFT:
ordenador.k8 = 1;
break;
case SDLK_z:
ordenador.k8 = 2;
break;
case SDLK_x:
ordenador.k8 = 4;
break;
case SDLK_c:
ordenador.k8 = 8;
break;
case SDLK_v:
ordenador.k8 = 16;
break;
case SDLK_BACKSPACE:
ordenador.k12 = 1;
ordenador.k8 = 1;
break;
case SDLK_PERIOD:
ordenador.k15 = 6;
break;
case SDLK_COMMA:
ordenador.k15 = 10;
break;
}
if (pevento->type == SDL_KEYUP) {
ordenador.s8 |= ordenador.k8;
ordenador.s9 |= ordenador.k9;
ordenador.s10 |= ordenador.k10;
ordenador.s11 |= ordenador.k11;
ordenador.s12 |= ordenador.k12;
ordenador.s13 |= ordenador.k13;
ordenador.s14 |= ordenador.k14;
ordenador.s15 |= ordenador.k15;
ordenador.js &= (ordenador.jk ^ 255);
} else {
ordenador.s8 &= (ordenador.k8 ^ 255);
ordenador.s9 &= (ordenador.k9 ^ 255);
ordenador.s10 &= (ordenador.k10 ^ 255);
ordenador.s11 &= (ordenador.k11 ^ 255);
ordenador.s12 &= (ordenador.k12 ^ 255);
ordenador.s13 &= (ordenador.k13 ^ 255);
ordenador.s14 &= (ordenador.k14 ^ 255);
ordenador.s15 &= (ordenador.k15 ^ 255);
ordenador.js |= ordenador.jk;
}
return; return;
} }

View File

@ -193,8 +193,11 @@ struct computer {
unsigned char other_ret; // 0=no change; 1=memory returns RET (201) unsigned char other_ret; // 0=no change; 1=memory returns RET (201)
unsigned char turbo; unsigned char turbo;
SDL_Event keyboard_buffer[10];
unsigned int kbd_buffer_pointer; unsigned int kbd_buffer_pointer;
unsigned char *key;
SDL_Joystick *joystick_sdl[2];
int joy_axis_x_state[2];
int joy_axis_y_state[2];
}; };
void computer_init(); void computer_init();

View File

@ -219,7 +219,7 @@ void load_rom(char type) {
void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface) { void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface) {
int retorno,bucle,bucle2,valores,ret2; int retorno,bucle,bucle2,valores,ret2,joystick_number;
unsigned char value; unsigned char value;
//if (sound_type!=3) //if (sound_type!=3)
@ -239,8 +239,11 @@ void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hw
ordenador.use_js=1; ordenador.use_js=1;
if(SDL_NumJoysticks()>0){ if(SDL_NumJoysticks()>0){
// Open joystick // Open joystick
for (bucle=0;bucle<SDL_NumJoysticks();bucle++) { joystick_number = SDL_NumJoysticks();
if (NULL==SDL_JoystickOpen(bucle)) { if (joystick_number>2) joystick_number = 2; //Open max 2 joysticks
for (bucle=0;bucle<joystick_number;bucle++) {
ordenador.joystick_sdl [bucle] = SDL_JoystickOpen(bucle);
if (NULL==ordenador.joystick_sdl [bucle]) {
printf("Can't open joystick %d\n",bucle); printf("Can't open joystick %d\n",bucle);
} }
} }
@ -704,11 +707,11 @@ int main(int argc,char *argv[]) {
SDL_EventState(SDL_MOUSEMOTION,SDL_IGNORE); SDL_EventState(SDL_MOUSEMOTION,SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN,SDL_IGNORE); SDL_EventState(SDL_MOUSEBUTTONDOWN,SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP,SDL_IGNORE); SDL_EventState(SDL_MOUSEBUTTONUP,SDL_IGNORE);
SDL_EventState(SDL_JOYAXISMOTION,SDL_ENABLE); SDL_EventState(SDL_JOYAXISMOTION,SDL_IGNORE);
SDL_EventState(SDL_JOYBALLMOTION,SDL_ENABLE); SDL_EventState(SDL_JOYBALLMOTION,SDL_IGNORE);
SDL_EventState(SDL_JOYHATMOTION,SDL_ENABLE); SDL_EventState(SDL_JOYHATMOTION,SDL_IGNORE);
SDL_EventState(SDL_JOYBUTTONDOWN,SDL_ENABLE); SDL_EventState(SDL_JOYBUTTONDOWN,SDL_IGNORE);
SDL_EventState(SDL_JOYBUTTONUP,SDL_ENABLE); SDL_EventState(SDL_JOYBUTTONUP,SDL_IGNORE);
SDL_EventState(SDL_QUIT,SDL_ENABLE); SDL_EventState(SDL_QUIT,SDL_ENABLE);
SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE); SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE);
SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE); SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE);
@ -798,7 +801,7 @@ int main(int argc,char *argv[]) {
ordenador.mdr_paged = 2; ordenador.mdr_paged = 2;
if(ordenador.interr==1) { if(ordenador.interr==1) {
read_keyboard (NULL); // read the physical keyboard read_keyboard (); // read the physical keyboard
Z80free_INT(&procesador,bus_empty()); Z80free_INT(&procesador,bus_empty());
ordenador.interr=0; ordenador.interr=0;
} }

View File

@ -286,7 +286,7 @@ void settings_menu() {
ordenador.turbo = 0; ordenador.turbo = 0;
jump_frames=0; jump_frames=0;
} else { } else {
ordenador.tst_sample=12000000/ordenador.freq; //5,0 MHz max emulation speed for wii ordenador.tst_sample=12000000/ordenador.freq; //5,0 MHz max emulation speed for wii at full frames
ordenador.turbo = 1; ordenador.turbo = 1;
jump_frames=3; jump_frames=3;
} }
@ -308,7 +308,7 @@ void help_menu() {
clean_screen(); clean_screen();
print_string(fbuffer,"FBZX (2.7.0)",-1,20,15,0,ancho); print_string(fbuffer,"FBZX Wii (1.0)",-1,20,15,0,ancho);
print_string(fbuffer,"Available keys",-1,50,14,0,ancho); print_string(fbuffer,"Available keys",-1,50,14,0,ancho);
print_string(fbuffer,"Shift:Caps Shift Ctrl:Symbol Shift",-1,95,11,0,ancho); print_string(fbuffer,"Shift:Caps Shift Ctrl:Symbol Shift",-1,95,11,0,ancho);
@ -351,7 +351,7 @@ void help_menu() {
print_string(fbuffer,"ESC:",184,400,12,0,ancho); print_string(fbuffer,"ESC:",184,400,12,0,ancho);
print_string(fbuffer,"exit emulator",248,400,15,0,ancho); print_string(fbuffer,"exit emulator",248,400,15,0,ancho);
print_copy(fbuffer,ancho); //print_copy(fbuffer,ancho);
fin=1; fin=1;
do { do {
@ -484,7 +484,7 @@ void tools_menu() {
print_string(fbuffer,"ESC:",14,250,12,0,ancho); print_string(fbuffer,"ESC:",14,250,12,0,ancho);
print_string(fbuffer,"return emulator",78,250,15,0,ancho); print_string(fbuffer,"return emulator",78,250,15,0,ancho);
print_copy(fbuffer,ancho); //print_copy(fbuffer,ancho);
switch(wait_key()) { switch(wait_key()) {
case SDLK_ESCAPE: // to exit the help case SDLK_ESCAPE: // to exit the help
@ -539,7 +539,7 @@ void snapshots_menu() {
print_string(fbuffer,"ESC: \001\017return to emulator",-1,400,12,0,ancho); print_string(fbuffer,"ESC: \001\017return to emulator",-1,400,12,0,ancho);
print_copy(fbuffer,ancho); //print_copy(fbuffer,ancho);
fin=1; fin=1;
do { do {
@ -609,7 +609,7 @@ void taps_menu() {
print_string(fbuffer,"Current TAP/TZX file is:",-1,310,12,0,ancho); print_string(fbuffer,"Current TAP/TZX file is:",-1,310,12,0,ancho);
print_string(fbuffer,ordenador.current_tap,-1,330,12,0,ancho); print_string(fbuffer,ordenador.current_tap,-1,330,12,0,ancho);
print_copy(fbuffer,ancho); //print_copy(fbuffer,ancho);
if(ordenador.tape_fast_load) if(ordenador.tape_fast_load)
print_string(fbuffer,"Fast load enabled ",10,420,14,0,ancho); print_string(fbuffer,"Fast load enabled ",10,420,14,0,ancho);
@ -748,7 +748,7 @@ void create_tapfile() {
print_string(videomem,path_taps,0,152,12,0,ancho); print_string(videomem,path_taps,0,152,12,0,ancho);
retorno=ask_filename(nombre2,84,"tap",path_taps); retorno=ask_filename(nombre2,84,"tap",path_taps,NULL);
clean_screen(); clean_screen();
@ -821,7 +821,7 @@ void microdrive_menu() {
print_string(fbuffer,"Current MDR file is:",-1,300,12,0,ancho); print_string(fbuffer,"Current MDR file is:",-1,300,12,0,ancho);
print_string(fbuffer,ordenador.mdr_current_mdr,-1,320,12,0,ancho); print_string(fbuffer,ordenador.mdr_current_mdr,-1,320,12,0,ancho);
print_copy(fbuffer,ancho); //print_copy(fbuffer,ancho);
if(!ordenador.mdr_cartridge[137922]) if(!ordenador.mdr_cartridge[137922])
print_string(fbuffer,"Write enabled",-1,420,14,0,ancho); print_string(fbuffer,"Write enabled",-1,420,14,0,ancho);
@ -931,7 +931,7 @@ void create_mdrfile() {
print_string(videomem,"MDR file will be saved in:",-1,132,12,0,ancho); print_string(videomem,"MDR file will be saved in:",-1,132,12,0,ancho);
print_string(videomem,path_mdrs,0,152,12,0,ancho); print_string(videomem,path_mdrs,0,152,12,0,ancho);
retorno=ask_filename(nombre2,84,"mdr",path_mdrs); retorno=ask_filename(nombre2,84,"mdr",path_mdrs, NULL);
clean_screen(); clean_screen();
@ -984,6 +984,7 @@ void create_scrfile() {
int ancho,retorno,retval; int ancho,retorno,retval;
unsigned char nombre2[1024]; unsigned char nombre2[1024];
FILE *fichero; FILE *fichero;
char *name;
videomem=screen->pixels; videomem=screen->pixels;
ancho=screen->w; ancho=screen->w;
@ -996,7 +997,15 @@ void create_scrfile() {
print_string(videomem,"SCR file will be saved in:",-1,132,12,0,ancho); print_string(videomem,"SCR file will be saved in:",-1,132,12,0,ancho);
print_string(videomem,path_snaps,0,152,12,0,ancho); print_string(videomem,path_snaps,0,152,12,0,ancho);
retorno=ask_filename(nombre2,84,"scr",path_snaps); if (strlen(ordenador.current_tap))
{
name=strrchr(ordenador.current_tap,'/');
if (name) name++; else name = ordenador.current_tap;
}
else
name=NULL;
retorno=ask_filename(nombre2,84,"scr",path_snaps, name);
clean_screen(); clean_screen();
@ -1041,10 +1050,11 @@ void create_scrfile() {
} }
int ask_filename(char *nombre_final,int y_coord,char *extension, char *path) { int ask_filename(char *nombre_final,int y_coord,char *extension, char *path, char *name) {
int longitud,retorno; int longitud,retorno;
unsigned char nombre[37],nombre2[38]; unsigned char nombre[37],nombre2[38];
char *ptr;
unsigned char *videomem; unsigned char *videomem;
int ancho; int ancho;
@ -1052,11 +1062,30 @@ int ask_filename(char *nombre_final,int y_coord,char *extension, char *path) {
videomem=screen->pixels; videomem=screen->pixels;
ancho=screen->w; ancho=screen->w;
nombre[0]=127;
nombre[1]=0;
longitud=0;
retorno=0; retorno=0;
if (!name||(strlen(name)>36))
{
nombre[0]=127;
nombre[1]=0;
}
else
{
strcpy(nombre,name);
ptr = strrchr (nombre, '.');
if (ptr) //remove the extension
{
*ptr = 127;
*(ptr+1) = 0;
}
else
nombre[strlen(nombre)-1]=127;
nombre[strlen(nombre)]=0;
}
longitud=strlen(nombre)-1;
do { do {
sprintf (nombre2, " %s.%s ", nombre,extension); sprintf (nombre2, " %s.%s ", nombre,extension);
print_string (videomem, nombre2, -1, y_coord, 15, 0, ancho); print_string (videomem, nombre2, -1, y_coord, 15, 0, ancho);
@ -1452,6 +1481,7 @@ void save_z80file() {
unsigned char *videomem; unsigned char *videomem;
int ancho,retorno; int ancho,retorno;
unsigned char nombre2[1024]; unsigned char nombre2[1024];
char *name;
videomem=screen->pixels; videomem=screen->pixels;
ancho=screen->w; ancho=screen->w;
@ -1464,8 +1494,15 @@ void save_z80file() {
print_string(videomem,"Snapshot will be saved in:",-1,132,12,0,ancho); print_string(videomem,"Snapshot will be saved in:",-1,132,12,0,ancho);
print_string(videomem,path_snaps,0,152,12,0,ancho); print_string(videomem,path_snaps,0,152,12,0,ancho);
if (strlen(ordenador.current_tap))
{
name=strrchr(ordenador.current_tap,'/');
if (name) name++; else name = ordenador.current_tap;
}
else
name=NULL;
retorno=ask_filename(nombre2,84,"z80", path_snaps); retorno=ask_filename(nombre2,84,"z80", path_snaps, name);
clean_screen(); clean_screen();
@ -1845,7 +1882,7 @@ void keyboard_menu() {
buffer=buffer2-ordenador.bpp; buffer=buffer2-ordenador.bpp;
} }
} }
print_copy(screen->pixels,screen->w); //print_copy(screen->pixels,screen->w);
wait_key(); wait_key();
clean_screen(); clean_screen();
} }

View File

@ -45,7 +45,7 @@ void create_mdrfile();
void microdrive_menu(); void microdrive_menu();
void keyboard_menu(); void keyboard_menu();
void load_scrfile(); void load_scrfile();
int ask_filename(char *nombre,int y_coord,char *extension, char *path); int ask_filename(char *nombre,int y_coord,char *extension, char *path, char *name);
void create_scrfile(); void create_scrfile();
void do_poke(); void do_poke();
int ask_value(int *final_value,int y_coord,int max_value); int ask_value(int *final_value,int y_coord,int max_value);