Autoload tap file sent with arguments, vk does not stop emulation, installation in usb device, ordering case insensitive, image fast loadind

This commit is contained in:
fabio.olimpieri 2013-01-16 20:07:44 +00:00
parent 186cfb045c
commit c5487fa51d
9 changed files with 365 additions and 120 deletions

View File

@ -51,7 +51,7 @@ extern FILE *fdebug;
#endif #endif
#endif #endif
static SDL_Surface *image_kbd, *image_sym, *image_caps,*image_kbd_small, *image_sym_small, *image_caps_small ; static SDL_Surface *image_kbd, *image_sym, *image_caps,*image_kbd_small, *image_sym_small, *image_caps_small, *tmp_surface ;
static int vkb_is_init; static int vkb_is_init;
extern struct computer ordenador; extern struct computer ordenador;
@ -71,29 +71,44 @@ void VirtualKeyboard_init(SDL_Surface *screen)
VirtualKeyboard.sel_y = 100; VirtualKeyboard.sel_y = 100;
vkb_is_init = -1; vkb_is_init = -1;
image_kbd=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard.png"); tmp_surface=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard.png");
image_sym=IMG_Load("/fbzx-wii/fbzx/symbol_shift.png"); if (tmp_surface == NULL) {printf("Impossible to load keyboard image\n"); return;}
image_caps=IMG_Load("/fbzx-wii/fbzx/caps_shift.png"); image_kbd=SDL_DisplayFormat(tmp_surface);
SDL_FreeSurface (tmp_surface);
image_kbd_small=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard_small.png");
image_sym_small=IMG_Load("/fbzx-wii/fbzx/symbol_shift_small.png");
image_caps_small=IMG_Load("/fbzx-wii/fbzx/caps_shift_small.png");
if (image_kbd == NULL) {printf("Impossible to load keyboard image\n"); return;} tmp_surface=IMG_Load("/fbzx-wii/fbzx/symbol_shift.png");
if (image_sym == NULL) {printf("Impossible to load symbol shift image\n"); return;} if (tmp_surface == NULL) {printf("Impossible to load symbol shift image\n"); return;}
if (image_caps == NULL) {printf("Impossible to load caps shift image\n"); return;} image_sym=SDL_DisplayFormat(tmp_surface);
SDL_FreeSurface (tmp_surface);
if (image_kbd_small == NULL) {printf("Impossible to load keyboard small image\n"); return;}
if (image_sym_small == NULL) {printf("Impossible to load symbol small shift image\n"); return;} tmp_surface=IMG_Load("/fbzx-wii/fbzx/caps_shift.png");
if (image_caps_small == NULL) {printf("Impossible to load caps shift small image\n"); return;} if (tmp_surface == NULL) {printf("Impossible to load caps shift image\n"); return;}
image_caps=SDL_DisplayFormat(tmp_surface);
SDL_FreeSurface (tmp_surface);
tmp_surface=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard_small.png");
if (tmp_surface == NULL) {printf("Impossible to load keyboard small image\n"); return;}
image_kbd_small=SDL_DisplayFormat(tmp_surface);
SDL_FreeSurface (tmp_surface);
tmp_surface=IMG_Load("/fbzx-wii/fbzx/symbol_shift_small.png");
if (tmp_surface == NULL) {printf("Impossible to load symbol shift small image\n"); return;}
image_sym_small=SDL_DisplayFormat(tmp_surface);
SDL_FreeSurface (tmp_surface);
tmp_surface=IMG_Load("/fbzx-wii/fbzx/caps_shift_small.png");
if (tmp_surface == NULL) {printf("Impossible to load caps shift small image\n"); return;}
image_caps_small=SDL_DisplayFormat(tmp_surface);
SDL_FreeSurface (tmp_surface);
memset(VirtualKeyboard.buf, 0, sizeof(VirtualKeyboard.buf)); memset(VirtualKeyboard.buf, 0, sizeof(VirtualKeyboard.buf));
vkb_is_init = 1; vkb_is_init = 1;
} }
void draw() void draw_vk()
{ {
SDL_Rect dst_rect = {VirtualKeyboard.sel_x/RATIO, VirtualKeyboard.sel_y/RATIO, 0, 0}; SDL_Rect dst_rect = {VirtualKeyboard.sel_x/RATIO, VirtualKeyboard.sel_y/RATIO, 0, 0};
@ -116,7 +131,7 @@ void draw()
} }
struct virtkey *get_key_internal(int vk) struct virtkey *get_key_internal()
{ {
while(1) while(1)
{ {
@ -127,12 +142,12 @@ struct virtkey *get_key_internal(int vk)
int border_x = VirtualKeyboard.sel_x/RATIO; int border_x = VirtualKeyboard.sel_x/RATIO;
int border_y = VirtualKeyboard.sel_y/RATIO; int border_y = VirtualKeyboard.sel_y/RATIO;
draw(); draw_vk();
SDL_Flip(VirtualKeyboard.screen); SDL_Flip(VirtualKeyboard.screen);
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
k = menu_wait_key_press(vk); k = menu_wait_key_press();
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
@ -148,10 +163,11 @@ struct virtkey *get_key_internal(int vk)
i = y/key_h*KEY_COLS + x/key_w; i = y/key_h*KEY_COLS + x/key_w;
#ifdef GEKKO
WPAD_Rumble(0, 1); WPAD_Rumble(0, 1);
SDL_Delay(50); SDL_Delay(90);
WPAD_Rumble(0, 0); WPAD_Rumble(0, 0);
#endif
virtkey_t *key = &keys[i]; virtkey_t *key = &keys[i];
@ -170,7 +186,7 @@ struct virtkey *get_key_internal(int vk)
return NULL; return NULL;
} }
struct virtkey* get_key(int vk) struct virtkey* get_key()
{ {
virtkey_t *key; virtkey_t *key;
@ -179,8 +195,98 @@ struct virtkey* get_key(int vk)
keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit
keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift
key = get_key_internal(vk); key = get_key_internal();
return key; return key;
} }
void virtkey_ir_run(void)
{
int key_code;
int x,y,xm, ym, i=0;
int key_w = 50/RATIO;
int key_h = 64/RATIO;
int border_x = VirtualKeyboard.sel_x/RATIO;
int border_y = VirtualKeyboard.sel_y/RATIO;
int key = 0;
SDL_Joystick *joy;
static int joy_bottons_last[4];
static char countdown_rumble=0;
#ifdef GEKKO
if (countdown_rumble > 0) {countdown_rumble--; if (countdown_rumble==0) WPAD_Rumble(0, 0);}
#endif
joy = ordenador.joystick_sdl[0];
if ((SDL_JoystickGetButton(joy, 0) && !joy_bottons_last[0]) || /* A */
(SDL_JoystickGetButton(joy, 3) && !joy_bottons_last[1]) || /* 2 */
(SDL_JoystickGetButton(joy, 9) && !joy_bottons_last[2]) || /* CA */
(SDL_JoystickGetButton(joy, 10) && !joy_bottons_last[3])) /* CB */
key = KEY_SELECT;
joy_bottons_last[0]=SDL_JoystickGetButton(joy, 0) ; /* A */
joy_bottons_last[1] =SDL_JoystickGetButton(joy, 3) ; /* 2 */
joy_bottons_last[2] =SDL_JoystickGetButton(joy, 9) ; /* CA */
joy_bottons_last[3] =SDL_JoystickGetButton(joy, 10) ; /* CB */
if (key==KEY_SELECT)
{
SDL_GetMouseState(&xm, &ym);
x = (xm-border_x);
y = (ym-border_y);
if ((x>0)&&(x< KEY_COLS*key_w)&&(y>0)&&(y< KEY_ROWS*key_h))
{
#ifdef GEKKO
WPAD_Rumble(0, 1);
#endif
countdown_rumble=5;
i = y/key_h*KEY_COLS + x/key_w;
virtkey_t *key = &keys[i];
if ((key->sdl_code == SDLK_LSHIFT) && !keys[3 * KEY_COLS + 8 ].is_on)
keys[3 * KEY_COLS + 0 ].is_on = !keys[3 * KEY_COLS + 0 ].is_on; //Caps Shit
else if ((key->sdl_code == SDLK_LCTRL) && !keys[3 * KEY_COLS + 0 ].is_on)
keys[3 * KEY_COLS + 8 ].is_on = !keys[3 * KEY_COLS + 8 ].is_on; //Sym Shift
else {
key->caps_on = keys[3 * KEY_COLS + 0 ].is_on;
key->sym_on = keys[3 * KEY_COLS + 8 ].is_on;
keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit
keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift
}
key_code = key->sdl_code;
ordenador.kbd_buffer_pointer=1;
countdown_buffer=8;
ordenador.keyboard_buffer[0][1]= key_code;
if (key->caps_on) ordenador.keyboard_buffer[1][1]= SDLK_LSHIFT;
else if (key->sym_on) ordenador.keyboard_buffer[1][1]= SDLK_LCTRL;
else ordenador.keyboard_buffer[1][1]= 0;
printf ("Push Event: keycode %d\n", key_code);
SDL_ShowCursor(SDL_DISABLE);
draw_vk();
SDL_ShowCursor(SDL_ENABLE);
}
}
}
void virtkey_ir_activate(void)
{
ordenador.vk_is_active=1;
VirtualKeyboard.sel_x = 64;
VirtualKeyboard.sel_y = 90;
draw_vk();
SDL_ShowCursor(SDL_ENABLE);
}
void virtkey_ir_deactivate(void)
{
ordenador.vk_is_active=0;
SDL_ShowCursor(SDL_DISABLE);
}

View File

@ -45,10 +45,11 @@ struct Virtual_Keyboard
} VirtualKeyboard; } VirtualKeyboard;
void VirtualKeyboard_init(SDL_Surface *screen); void VirtualKeyboard_init(SDL_Surface *screen);
struct virtkey* get_key(int vk); struct virtkey* get_key();
struct virtkey* get_key_internal(int vk); struct virtkey* get_key_internal();
void draw(); void draw_vk();
void select_next_kb(int dx, int dy); void select_next_kb(int dx, int dy);
void toggle_shift(); void toggle_shift();
void virtkey_ir_run();
void virtkey_ir_activate(void);
void virtkey_ir_deactivate(void);

View File

@ -159,6 +159,7 @@ void computer_init () { //Called only on start-up
ordenador.tape_loop_counter = 0; ordenador.tape_loop_counter = 0;
ordenador.kbd_buffer_pointer = 0; ordenador.kbd_buffer_pointer = 0;
ordenador.vk_is_active=0;
ordenador.key = SDL_GetKeyState(NULL); ordenador.key = SDL_GetKeyState(NULL);
ordenador.joybuttonkey[0][0]=SDLK_LALT; //Fire button to wiimote1 button A ordenador.joybuttonkey[0][0]=SDLK_LALT; //Fire button to wiimote1 button A
ordenador.joybuttonkey[1][0]=SDLK_LALT; //Fire button to wiimote1 button A ordenador.joybuttonkey[1][0]=SDLK_LALT; //Fire button to wiimote1 button A
@ -579,9 +580,9 @@ inline void show_screen (int tstados) {
// is border // is border
if (ordenador.ulaplus) { if (ordenador.ulaplus) {
paint_pixels (255, ordenador.border+24, 0); // paint 8 pixels with BORDER color paint_pixels (255, ordenador.border+24, 0,1); // paint 8 pixels with BORDER color
} else { } else {
paint_pixels (255, ordenador.border, 0); // paint 8 pixels with BORDER color paint_pixels (255, ordenador.border, 0,1); // paint 8 pixels with BORDER color
} }
ordenador.bus_value = 255; ordenador.bus_value = 255;
@ -619,9 +620,9 @@ inline void show_screen (int tstados) {
ordenador.p_translt2++; ordenador.p_translt2++;
if ((fflash) && (ordenador.flash)) if ((fflash) && (ordenador.flash))
paint_pixels (temporal3, paper, ink); // if FLASH, invert PAPER and INK paint_pixels (temporal3, paper, ink,(!ordenador.vk_is_active)||(ordenador.currline>ordenador.last_line_kb)||(ordenador.currline<ordenador.first_line_kb)); // if FLASH, invert PAPER and INK
else else
paint_pixels (temporal3, ink, paper); paint_pixels (temporal3, ink, paper,(!ordenador.vk_is_active)||(ordenador.currline>ordenador.last_line_kb)||(ordenador.currline<ordenador.first_line_kb));
} }
} }
@ -724,9 +725,9 @@ inline void show_screen_precision (int tstados) {
if (ordenador.pixels_octect==0) ordenador.border_sampled = ordenador.border; if (ordenador.pixels_octect==0) ordenador.border_sampled = ordenador.border;
if (ordenador.ulaplus) { if (ordenador.ulaplus) {
paint_pixels_precision (255, ordenador.border_sampled+24, 0); // paint 2 pixels with BORDER color paint_pixels_precision (255, ordenador.border_sampled+24, 0,1); // paint 2 pixels with BORDER color
} else { } else {
paint_pixels_precision (255, ordenador.border_sampled, 0); // paint 2 pixels with BORDER color paint_pixels_precision (255, ordenador.border_sampled, 0,1); // paint 2 pixels with BORDER color
} }
ordenador.bus_value = 255; ordenador.bus_value = 255;
@ -858,9 +859,9 @@ inline void show_screen_precision (int tstados) {
if ((fflash) && (ordenador.flash)) if ((fflash) && (ordenador.flash))
paint_pixels_precision (temporal3, paper, ink); // if FLASH, invert PAPER and INK paint_pixels_precision (temporal3, paper, ink, (!ordenador.vk_is_active)||(ordenador.currline>ordenador.last_line_kb) ||(ordenador.currline<ordenador.first_line_kb)); // if FLASH, invert PAPER and INK
else else
paint_pixels_precision (temporal3, ink, paper); paint_pixels_precision (temporal3, ink, paper, (!ordenador.vk_is_active)||(ordenador.currline>ordenador.last_line_kb) ||(ordenador.currline<ordenador.first_line_kb));
} }
} }
@ -926,7 +927,7 @@ inline void show_screen_precision (int tstados) {
} }
inline void paint_pixels (unsigned char octet,unsigned char ink, unsigned char paper) { inline void paint_pixels (unsigned char octet,unsigned char ink, unsigned char paper, unsigned char draw) {
static int bucle,valor,*p; static int bucle,valor,*p;
static unsigned char mask; static unsigned char mask;
@ -934,6 +935,9 @@ inline void paint_pixels (unsigned char octet,unsigned char ink, unsigned char p
mask = 0x80; mask = 0x80;
for (bucle = 0; bucle < 8; bucle++) { for (bucle = 0; bucle < 8; bucle++) {
if (draw)
{
valor = (octet & mask) ? (int) ink : (int) paper; valor = (octet & mask) ? (int) ink : (int) paper;
p=(colors+valor); p=(colors+valor);
@ -954,6 +958,22 @@ inline void paint_pixels (unsigned char octet,unsigned char ink, unsigned char p
default: default:
break; break;
} }
}
else
{
switch (ordenador.npixels)
{
case 2:
ordenador.pixel+=ordenador.next_pixel;
break;
case 4:
ordenador.pixel+=ordenador.next_pixel;
break;
default:
break;
}
}
ordenador.pixel+=ordenador.next_pixel; ordenador.pixel+=ordenador.next_pixel;
mask = ((mask >> 1) & 0x7F); mask = ((mask >> 1) & 0x7F);
@ -961,7 +981,7 @@ inline void paint_pixels (unsigned char octet,unsigned char ink, unsigned char p
} }
inline void paint_pixels_precision (unsigned char octet,unsigned char ink, unsigned char paper) { inline void paint_pixels_precision (unsigned char octet,unsigned char ink, unsigned char paper, unsigned char draw) {
static int bucle,valor,*p; static int bucle,valor,*p;
static unsigned char mask; static unsigned char mask;
@ -969,6 +989,8 @@ inline void paint_pixels_precision (unsigned char octet,unsigned char ink, unsig
if (ordenador.pixels_octect==0) mask = 0x80; if (ordenador.pixels_octect==0) mask = 0x80;
for (bucle = 0; bucle < 2; bucle++) { for (bucle = 0; bucle < 2; bucle++) {
if (draw)
{
valor = (octet & mask) ? (int) ink : (int) paper; valor = (octet & mask) ? (int) ink : (int) paper;
p=(colors+valor); p=(colors+valor);
@ -989,6 +1011,21 @@ inline void paint_pixels_precision (unsigned char octet,unsigned char ink, unsig
default: default:
break; break;
} }
}
else
{
switch (ordenador.npixels)
{
case 2:
ordenador.pixel+=ordenador.next_pixel;
break;
case 4:
ordenador.pixel+=ordenador.next_pixel;
break;
default:
break;
}
}
ordenador.pixel+=ordenador.next_pixel; ordenador.pixel+=ordenador.next_pixel;
@ -1005,7 +1042,7 @@ inline void paint_one_pixel(unsigned char *colour,unsigned char *address)
} }
#else #else
inline void paint_one_pixel(unsigned char *colour,unsigned char *address) { inline void paint_one_pixel(unsigned char *colour,unsigned char *address ) {
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
switch(ordenador.bpp) { switch(ordenador.bpp) {
@ -1058,7 +1095,6 @@ inline void read_keyboard () {
fire_on[0]=0; fire_on[0]=0;
fire_on[1]=0; fire_on[1]=0;
static int countdown_kb;
ordenador.k8 = ordenador.k9 = ordenador.k10 = ordenador.k11 = ordenador.k8 = ordenador.k9 = ordenador.k10 = ordenador.k11 =
ordenador.k12 = ordenador.k13 = ordenador.k14 = ordenador.k12 = ordenador.k13 = ordenador.k14 =
@ -1076,32 +1112,19 @@ inline void read_keyboard () {
SDL_JoystickUpdate(); SDL_JoystickUpdate();
if (ordenador.vk_auto) if (SDL_JoystickGetButton(ordenador.joystick_sdl[0], 6) ||//Wii button "Home"
{ SDL_JoystickGetButton(ordenador.joystick_sdl[0], 19))
if (countdown_kb>0) countdown_kb--; {if (ordenador.vk_is_active) virtkey_ir_deactivate();main_menu(); }
#ifdef GEKKO
WPADData *wd;
wd = WPAD_Data(0);
if ((wd->ir.valid)&&(!countdown_kb)) {virtual_keyboard();countdown_kb=20;}
#else
int x=0,y=0 ;
SDL_GetRelativeMouseState(&x,&y);
if ((x||y)&&(!countdown_kb)) {virtual_keyboard();countdown_kb=30;}
#endif
}
if (!ordenador.vk_is_active) {
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++) for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
{ {
joy_axis_x[joy_n] = SDL_JoystickGetAxis(ordenador.joystick_sdl[joy_n], 0); joy_axis_x[joy_n] = SDL_JoystickGetAxis(ordenador.joystick_sdl[joy_n], 0);
joy_axis_y[joy_n] = SDL_JoystickGetAxis(ordenador.joystick_sdl[joy_n], 1); joy_axis_y[joy_n] = SDL_JoystickGetAxis(ordenador.joystick_sdl[joy_n], 1);
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6) ||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 19)) main_menu(); //Wii button "Home"
if ((!ordenador.vk_auto) &&(SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 5) ||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 18))) virtual_keyboard(); //Wii button "+"
if (joy_axis_x[joy_n] > 16384) ordenador.joy_axis_x_state[joy_n] = JOY_RIGHT; if (joy_axis_x[joy_n] > 16384) ordenador.joy_axis_x_state[joy_n] = JOY_RIGHT;
else if (joy_axis_x[joy_n] < -16384) ordenador.joy_axis_x_state[joy_n] = JOY_LEFT; else if (joy_axis_x[joy_n] < -16384) ordenador.joy_axis_x_state[joy_n] = JOY_LEFT;
@ -1140,12 +1163,13 @@ inline void read_keyboard () {
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][21])] = (status_hat[joy_n] & SDL_HAT_RIGHT); joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][21])] = (status_hat[joy_n] & SDL_HAT_RIGHT);
} }
} }
}
//Keyboard buffer //Keyboard buffer
if (countdown) if (countdown_buffer)
{ {
if (countdown <5) if (countdown_buffer <5)
{ {
joybutton_matrix[0][(ordenador.keyboard_buffer[0][ordenador.kbd_buffer_pointer+1])]=0; joybutton_matrix[0][(ordenador.keyboard_buffer[0][ordenador.kbd_buffer_pointer+1])]=0;
joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer+1])]=0; joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer+1])]=0;
@ -1157,18 +1181,25 @@ inline void read_keyboard () {
joybutton_matrix[0][(ordenador.keyboard_buffer[0][ordenador.kbd_buffer_pointer+1])]=1; joybutton_matrix[0][(ordenador.keyboard_buffer[0][ordenador.kbd_buffer_pointer+1])]=1;
joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer+1])]=1; joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer+1])]=1;
} }
countdown--; countdown_buffer--;
} }
else if (ordenador.kbd_buffer_pointer) else if (ordenador.kbd_buffer_pointer)
{ {
joybutton_matrix[0][(ordenador.keyboard_buffer[0][ordenador.kbd_buffer_pointer])]=1; if (ordenador.kbd_buffer_pointer<KB_BUFFER_LENGHT)
joybutton_matrix[0][(ordenador.keyboard_buffer[1][ordenador.kbd_buffer_pointer])]=1; {
joybutton_matrix[0][(ordenador.keyboard_buffer[0][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=8; countdown_buffer=8;
}
else
{
ordenador.kbd_buffer_pointer--;
countdown_buffer=0;
}
} }
temporal_io = (unsigned int) pevento->key.keysym.sym; temporal_io = (unsigned int) pevento->key.keysym.sym;
if (pevento->type == SDL_KEYDOWN) if (pevento->type == SDL_KEYDOWN)
@ -1242,7 +1273,7 @@ inline void read_keyboard () {
} }
countdown=8; countdown_buffer=8;
break; break;
case SDLK_F10: // Reset emulator case SDLK_F10: // Reset emulator
@ -1474,7 +1505,47 @@ inline void read_keyboard () {
if (joybutton_matrix[0][SDLK_F6] && ((ordenador.tape_fast_load == 0) || (ordenador.tape_file_type==TAP_TZX))) if (joybutton_matrix[0][SDLK_F6] && ((ordenador.tape_fast_load == 0) || (ordenador.tape_file_type==TAP_TZX)))
ordenador.pause = 0; //Play the tape ordenador.pause = 0; //Play the tape
return;
//Virtual Keyboard
//VK activation/deactivation
static char old_plus_button;
char plus_button;
plus_button= SDL_JoystickGetButton(ordenador.joystick_sdl[0], 5) || //Wii button "+"
SDL_JoystickGetButton(ordenador.joystick_sdl[0], 18);
if (!ordenador.vk_auto && plus_button && !old_plus_button)
{if (!ordenador.vk_is_active) virtkey_ir_activate(); else virtkey_ir_deactivate();}
if (ordenador.vk_auto)
{
#ifdef GEKKO
WPADData *wd;
wd = WPAD_Data(0); //only wiimote 0
if ((wd->ir.valid)&&(!ordenador.vk_is_active)) virtkey_ir_activate();
if ((!wd->ir.valid)&&(ordenador.vk_is_active)) virtkey_ir_deactivate();
#else
int x=0,y=0 ;
SDL_GetRelativeMouseState(&x,&y);
if (x||y)
{
ordenador.vk_is_active=1;
SDL_ShowCursor(SDL_ENABLE);
}
else
{
ordenador.vk_is_active=0;
SDL_ShowCursor(SDL_DISABLE);
}
#endif
}
old_plus_button = plus_button;
if (ordenador.vk_is_active) virtkey_ir_run();
} }
// resets the computer and loads the right ROMs // resets the computer and loads the right ROMs
@ -1577,6 +1648,8 @@ void ResetComputer () {
ordenador.start_screen=45; ordenador.start_screen=45;
break; break;
} }
ordenador.first_line_kb=ordenador.first_line + 90/2;
ordenador.last_line_kb=ordenador.first_line + 90/2 + 306/2;
ordenador.last_selected_poke_file[0]='\0'; ordenador.last_selected_poke_file[0]='\0';

View File

@ -26,13 +26,15 @@
// #define MUT // #define MUT
#define KB_BUFFER_LENGHT 10
extern char salir; extern char salir;
enum tapmodes {TAP_GUIDE, TAP_DATA, TAP_PAUSE, TAP_TRASH, TAP_STOP, TAP_PAUSE2, TZX_PURE_TONE, enum tapmodes {TAP_GUIDE, TAP_DATA, TAP_PAUSE, TAP_TRASH, TAP_STOP, TAP_PAUSE2, TZX_PURE_TONE,
TZX_SEQ_PULSES, TAP_FINAL_BIT, TAP_PAUSE3}; TZX_SEQ_PULSES, TAP_FINAL_BIT, TAP_PAUSE3};
enum taptypes {TAP_TAP, TAP_TZX}; enum taptypes {TAP_TAP, TAP_TZX};
int countdown; int countdown_buffer;
struct computer { struct computer {
@ -67,6 +69,8 @@ struct computer {
int next_scanline; // cuantity to add to pass to the next scanline int next_scanline; // cuantity to add to pass to the next scanline
int first_line; // first line to start to paint int first_line; // first line to start to paint
int last_line; // last line to paint int last_line; // last line to paint
int first_line_kb; // first line to start to paint the keyboard
int last_line_kb; // last line to paint the keyboard
int first_pixel; // first pixel of a line to paint int first_pixel; // first pixel of a line to paint
int last_pixel; // last pixel of a line to paint int last_pixel; // last pixel of a line to paint
int next_pixel; // next pixel int next_pixel; // next pixel
@ -221,7 +225,7 @@ struct computer {
unsigned char turbo; unsigned char turbo;
unsigned char turbo_state; unsigned char turbo_state;
unsigned int keyboard_buffer[2][10]; unsigned int keyboard_buffer[2][KB_BUFFER_LENGHT];
unsigned int kbd_buffer_pointer; unsigned int kbd_buffer_pointer;
unsigned char *key; unsigned char *key;
unsigned char joystick_number; unsigned char joystick_number;
@ -232,6 +236,7 @@ struct computer {
unsigned char joypad_as_joystick[2]; unsigned char joypad_as_joystick[2];
unsigned char rumble[2]; unsigned char rumble[2];
unsigned char vk_auto; unsigned char vk_auto;
unsigned char vk_is_active;
unsigned char port; //SD, USB, SMB or FTP unsigned char port; //SD, USB, SMB or FTP
unsigned char smb_enable; unsigned char smb_enable;
unsigned char SmbUser[32]; unsigned char SmbUser[32];
@ -252,8 +257,8 @@ void computer_init();
void register_screen(SDL_Surface *); void register_screen(SDL_Surface *);
inline void show_screen(int); inline void show_screen(int);
inline void show_screen_precision(int); inline void show_screen_precision(int);
inline void paint_pixels(unsigned char, unsigned char, unsigned char); inline void paint_pixels(unsigned char, unsigned char, unsigned char, unsigned char draw);
inline void paint_pixels_precision(unsigned char, unsigned char, unsigned char); inline void paint_pixels_precision(unsigned char, unsigned char, unsigned char,unsigned char draw);
inline void read_keyboard(); inline void read_keyboard();
void fill_audio(void *udata,Uint8 *,int); void fill_audio(void *udata,Uint8 *,int);
void set_volume(unsigned char); void set_volume(unsigned char);

View File

@ -81,6 +81,7 @@ unsigned int jump_frames,curr_frames;
static SDL_Surface *image; static SDL_Surface *image;
unsigned char sdismount = 0;
unsigned char usbismount = 0; unsigned char usbismount = 0;
unsigned char networkisinit = 0; unsigned char networkisinit = 0;
unsigned char smbismount = 0; unsigned char smbismount = 0;
@ -626,6 +627,55 @@ void load_main_game(char *nombre) {
ordenador.tape_file_type = TAP_TAP; ordenador.tape_file_type = TAP_TAP;
rewind_tape(ordenador.tap_file,1); rewind_tape(ordenador.tap_file,1);
} }
//Emulate load ""
if (ordenador.mode128k==4) //Spanish 128k
{
ordenador.keyboard_buffer[0][9]= 0;
ordenador.keyboard_buffer[1][9]= 0;
ordenador.keyboard_buffer[0][8]= SDLK_l;
ordenador.keyboard_buffer[1][8]= 0;
ordenador.keyboard_buffer[0][7]= SDLK_o;
ordenador.keyboard_buffer[1][7]= 0;
ordenador.keyboard_buffer[0][6]= SDLK_a;
ordenador.keyboard_buffer[1][6]= 0;
ordenador.keyboard_buffer[0][5]= SDLK_d;
ordenador.keyboard_buffer[1][5]= 0;
ordenador.keyboard_buffer[0][4]= SDLK_p; //"
ordenador.keyboard_buffer[1][4]= SDLK_LCTRL;
ordenador.keyboard_buffer[0][3]= SDLK_p; //"
ordenador.keyboard_buffer[1][3]= SDLK_LCTRL;
ordenador.keyboard_buffer[0][2]= SDLK_RETURN; // Return
ordenador.keyboard_buffer[1][2]= 0;
ordenador.keyboard_buffer[0][1]= SDLK_F6; //F6 - play
ordenador.keyboard_buffer[1][1]= 0;
ordenador.kbd_buffer_pointer=100;
}
else
{
ordenador.keyboard_buffer[0][9]= 0;
ordenador.keyboard_buffer[1][9]= 0;
ordenador.keyboard_buffer[0][8]= 0;
ordenador.keyboard_buffer[1][8]= 0;
ordenador.keyboard_buffer[0][7]= 0;
ordenador.keyboard_buffer[1][7]= 0;
ordenador.keyboard_buffer[0][6]= 0;
ordenador.keyboard_buffer[1][6]= 0;
ordenador.keyboard_buffer[0][5]= SDLK_j; //Load
ordenador.keyboard_buffer[1][5]= 0;
ordenador.keyboard_buffer[0][4]= SDLK_p; //"
ordenador.keyboard_buffer[1][4]= SDLK_LCTRL;
ordenador.keyboard_buffer[0][3]= SDLK_p; //"
ordenador.keyboard_buffer[1][3]= SDLK_LCTRL;
ordenador.keyboard_buffer[0][2]= SDLK_RETURN; // Return
ordenador.keyboard_buffer[1][2]= 0;
ordenador.keyboard_buffer[0][1]= SDLK_F6; //F6
ordenador.keyboard_buffer[1][1]= 0;
ordenador.kbd_buffer_pointer=100; //Delay the insertion in the buffer
}
countdown_buffer=0;
return; return;
} }
} }
@ -1031,7 +1081,7 @@ int load_config(struct computer *object, char *filename) {
if (rumble2<2) { if (rumble2<2) {
object->rumble[1]=rumble2; object->rumble[1]=rumble2;
} }
if (port<4) { if (port<5) {
object->port=port; object->port=port;
} }
if (autoconf<2) { if (autoconf<2) {
@ -1084,15 +1134,24 @@ int main(int argc,char *argv[]) {
setenv("HOME", "/fbzx-wii", 1); setenv("HOME", "/fbzx-wii", 1);
//initialize libfat library //initialize libfat library
if (!fatInitDefault()) if (fatInitDefault())
{ printf("FAT subsytem initialized\n");
else
printf("Couldn't initialize fat subsytem\n");
DIR *dp;
dp = opendir ("sd:/");
if (dp) sdismount = 1; else sdismount = 0;
if (sdismount)
printf("SD FAT subsytem initialized\n");
else
printf("Couldn't initialize SD fat subsytem\n"); printf("Couldn't initialize SD fat subsytem\n");
exit(0); if (sdismount) closedir (dp);
}
else
printf("SD FAT subsytem initialized\n");
usbismount = InitUSB();
#endif #endif
@ -1256,7 +1315,6 @@ int main(int argc,char *argv[]) {
if (ordenador.zaurus_mini==0) if (load_zxspectrum_picture()) SDL_FreeSurface (image); if (ordenador.zaurus_mini==0) if (load_zxspectrum_picture()) SDL_FreeSurface (image);
#ifdef GEKKO #ifdef GEKKO
usbismount = InitUSB();
load_config_network(&ordenador); load_config_network(&ordenador);
@ -1315,15 +1373,19 @@ int main(int argc,char *argv[]) {
else {printf("Can't make tmp directory\n"); tmpismade=0;} else {printf("Can't make tmp directory\n"); tmpismade=0;}
#ifdef GEKKO #ifdef GEKKO
if ((ordenador.port==1)&&usbismount) { if ((ordenador.port==1)&&sdismount) {
strcpy(path_snaps,"sd:/");
strcpy(path_taps,"sd:/");
}
if ((ordenador.port==2)&&usbismount) {
strcpy(path_snaps,"usb:/"); strcpy(path_snaps,"usb:/");
strcpy(path_taps,"usb:/"); strcpy(path_taps,"usb:/");
} }
if ((ordenador.port==2)&&smbismount) { if ((ordenador.port==3)&&smbismount) {
strcpy(path_snaps,"smb:/"); strcpy(path_snaps,"smb:/");
strcpy(path_taps,"smb:/"); strcpy(path_taps,"smb:/");
} }
if ((ordenador.port==3)&&ftpismount) { if ((ordenador.port==4)&&ftpismount) {
strcpy(path_snaps,"ftp:"); strcpy(path_snaps,"ftp:");
strcpy(path_taps,"ftp:"); strcpy(path_taps,"ftp:");
} }

View File

@ -42,7 +42,7 @@ extern char path_poke[2049];
extern char path_tmp[2049]; extern char path_tmp[2049];
extern unsigned int colors[80]; extern unsigned int colors[80];
extern unsigned int jump_frames,curr_frames; extern unsigned int jump_frames,curr_frames;
extern unsigned char usbismount, smbismount, tmpismade, ftpismount,networkisinit; extern unsigned char sdismount, usbismount, smbismount, tmpismade, ftpismount,networkisinit;
void SDL_Fullscreen_Switch(void); void SDL_Fullscreen_Switch(void);
void load_rom(char); void load_rom(char);

View File

@ -50,7 +50,7 @@ extern FILE *fdebug;
#define MAX_POKE 20 #define MAX_POKE 20
#define MAX_TRAINER 50 #define MAX_TRAINER 50
extern int countdown; extern int countdown_buffer;
void clean_screen(); void clean_screen();
@ -154,7 +154,7 @@ static const char *tools_messages[] = {
/*05*/ "Load poke file", /*05*/ "Load poke file",
/*06*/ " ", /*06*/ " ",
/*07*/ "Port", /*07*/ "Port",
/*08*/ "^|sd|usb|smb|ftp", /*08*/ "^|default|sd|usb|smb|ftp",
/*09*/ " ", /*09*/ " ",
/*10*/ "Auto virtual keyboard", /*10*/ "Auto virtual keyboard",
/*11*/ "^|on|off", /*11*/ "^|on|off",
@ -377,7 +377,7 @@ static int manage_tape(int which)
insert_tape(); insert_tape();
break; break;
case 1: //Emulate load "" case 1: //Emulate load ""
countdown=8; countdown_buffer=8;
if (ordenador.mode128k==4) //Spanish 128k if (ordenador.mode128k==4) //Spanish 128k
{ {
ordenador.keyboard_buffer[0][8]= SDLK_l; ordenador.keyboard_buffer[0][8]= SDLK_l;
@ -712,7 +712,7 @@ static void input_options(int joy)
VirtualKeyboard.sel_x = 64; VirtualKeyboard.sel_x = 64;
VirtualKeyboard.sel_y = 90; VirtualKeyboard.sel_y = 90;
virtualkey = get_key(0); virtualkey = get_key();
if (virtualkey == NULL) if (virtualkey == NULL)
return; return;
sdl_key = virtualkey->sdl_code; sdl_key = virtualkey->sdl_code;
@ -1074,7 +1074,7 @@ static void set_port(int which)
switch (which) switch (which)
{ {
case 0: //PORT_SD case 0: //PORT_DEFAULT
strcpy(path_snaps,getenv("HOME")); strcpy(path_snaps,getenv("HOME"));
length=strlen(path_snaps); length=strlen(path_snaps);
if ((length>0)&&(path_snaps[length-1]!='/')) strcat(path_snaps,"/"); if ((length>0)&&(path_snaps[length-1]!='/')) strcat(path_snaps,"/");
@ -1089,7 +1089,18 @@ static void set_port(int which)
strcat(path_scr2,"scr2"); strcat(path_scr2,"scr2");
ordenador.port = which; ordenador.port = which;
break; break;
case 1: //PORT_USB case 1: //PORT_SD
if (sdismount) {
strcpy(path_snaps,"sd:/");
strcpy(path_taps,"sd:/");
strcpy(path_poke,"sd:/");
strcpy(path_scr1,"sd:/");
strcpy(path_scr2,"sd:/");
ordenador.port = which;}
else
msgInfo("SD is not mounted",3000,NULL);
break;
case 2: //PORT_USB
if (usbismount) { if (usbismount) {
strcpy(path_snaps,"usb:/"); strcpy(path_snaps,"usb:/");
strcpy(path_taps,"usb:/"); strcpy(path_taps,"usb:/");
@ -1100,7 +1111,7 @@ static void set_port(int which)
else else
msgInfo("USB is not mounted",3000,NULL); msgInfo("USB is not mounted",3000,NULL);
break; break;
case 2: //PORT_SMB case 3: //PORT_SMB
if (!smbismount) if (!smbismount)
{ {
msgInfo("Try to mount SMB",0,NULL); msgInfo("Try to mount SMB",0,NULL);
@ -1118,7 +1129,7 @@ static void set_port(int which)
else else
msgInfo("SMB is not mounted",3000,NULL); msgInfo("SMB is not mounted",3000,NULL);
break; break;
case 3: //PORT_FTP case 4: //PORT_FTP
if (!ftpismount) if (!ftpismount)
{ {
msgInfo("Try to mount FTP",0,NULL); msgInfo("Try to mount FTP",0,NULL);
@ -1295,7 +1306,7 @@ int parse_poke (const char *filename)
k=0; k=0;
while (!((k & KEY_ESCAPE)||(k & KEY_SELECT))) while (!((k & KEY_ESCAPE)||(k & KEY_SELECT)))
{k = menu_wait_key_press(0);} {k = menu_wait_key_press();}
banner.y=y; banner.y=y;
@ -1366,7 +1377,7 @@ int parse_poke (const char *filename)
k=0; k=0;
while (!(k & KEY_ESCAPE)&&(ritorno==0)) while (!(k & KEY_ESCAPE)&&(ritorno==0))
{k = menu_wait_key_press(0);} {k = menu_wait_key_press();}
fclose(fpoke); fclose(fpoke);
if (ritorno==0) strcpy(ordenador.last_selected_poke_file,filename); if (ritorno==0) strcpy(ordenador.last_selected_poke_file,filename);
@ -1492,11 +1503,11 @@ void virtual_keyboard(void)
VirtualKeyboard.sel_x = 64; VirtualKeyboard.sel_x = 64;
VirtualKeyboard.sel_y = 90; VirtualKeyboard.sel_y = 90;
virtkey_t *key =get_key(1); virtkey_t *key =get_key();
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=8; countdown_buffer=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;

View File

@ -142,7 +142,7 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00)); SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00));
menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-12/RATIO, Y+42/RATIO, "OK",20); menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-12/RATIO, Y+42/RATIO, "OK",20);
SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w, brc.h); SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w, brc.h);
while (!(KEY_SELECT & menu_wait_key_press(0))) {} while (!(KEY_SELECT & menu_wait_key_press())) {}
} }
@ -216,7 +216,7 @@ int msgYesNo(char *text, int default_opt, int x, int y)
SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w,brc.h); SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w,brc.h);
//SDL_Flip(real_screen); //SDL_Flip(real_screen);
key = menu_wait_key_press(0); key = menu_wait_key_press();
if (key & KEY_SELECT) if (key & KEY_SELECT)
{ {
return default_opt; return default_opt;
@ -248,7 +248,7 @@ static int cmpstringp(const void *p1, const void *p2)
return -1; return -1;
if (*p1_s != '[' && *p2_s == '[') if (*p1_s != '[' && *p2_s == '[')
return 1; return 1;
return strcmp(* (char * const *) p1, * (char * const *) p2); return strcasecmp(* (char * const *) p1, * (char * const *) p2);
} }
/* Return true if name ends with ext (for filenames) */ /* Return true if name ends with ext (for filenames) */
@ -920,7 +920,7 @@ static void menu_fini(menu_t *p_menu)
free(p_menu->p_submenus); free(p_menu->p_submenus);
} }
uint32_t menu_wait_key_press(int vk) uint32_t menu_wait_key_press()
{ {
SDL_Event ev; SDL_Event ev;
uint32_t keys = 0; uint32_t keys = 0;
@ -934,19 +934,6 @@ uint32_t menu_wait_key_press(int vk)
static int joy_bottons_last[2][8]; static int joy_bottons_last[2][8];
SDL_JoystickUpdate(); SDL_JoystickUpdate();
if (ordenador.vk_auto)
{
#ifdef GEKKO
WPADData *wd;
wd = WPAD_Data(0);
if (vk&&!(wd->ir.valid)) return KEY_ESCAPE;
#else
int x=0,y=0 ;
SDL_GetRelativeMouseState(&x,&y);
if ((x<20||y<20||(x>FULL_DISPLAY_X-20)||y>FULL_DISPLAY_Y-20)) return KEY_ESCAPE;
#endif
}
/* Wii-specific, sorry */ /* Wii-specific, sorry */
for (nr = 0; nr < ordenador.joystick_number; nr++) { for (nr = 0; nr < ordenador.joystick_number; nr++) {
joy = ordenador.joystick_sdl[nr]; joy = ordenador.joystick_sdl[nr];
@ -1088,7 +1075,7 @@ static int menu_select_internal(SDL_Surface *screen,
menu_draw(screen, p_menu, 0, font_size, draw_scr); menu_draw(screen, p_menu, 0, font_size, draw_scr);
SDL_Flip(screen); SDL_Flip(screen);
keys = menu_wait_key_press(0); keys = menu_wait_key_press();
if (keys & KEY_UP) if (keys & KEY_UP)
select_next(p_menu, 0, -1, 1); select_next(p_menu, 0, -1, 1);
@ -1443,7 +1430,7 @@ int ask_value_sdl(int *final_value,int y_coord,int max_value) {
VirtualKeyboard.sel_x = 64; VirtualKeyboard.sel_x = 64;
VirtualKeyboard.sel_y = 155; VirtualKeyboard.sel_y = 155;
virtualkey = get_key(0); virtualkey = get_key();
if (virtualkey == NULL) return(0); if (virtualkey == NULL) return(0);
if (virtualkey->sdl_code==1) break; //done, retorno -1 if (virtualkey->sdl_code==1) break; //done, retorno -1
sdl_key = virtualkey->sdl_code; sdl_key = virtualkey->sdl_code;
@ -1572,7 +1559,7 @@ int ask_filename_sdl(char *nombre_final,int y_coord,char *extension, char *path,
VirtualKeyboard.sel_x = 64; VirtualKeyboard.sel_x = 64;
VirtualKeyboard.sel_y = 155; VirtualKeyboard.sel_y = 155;
virtualkey = get_key(0); virtualkey = get_key();
if (virtualkey == NULL) return(2); if (virtualkey == NULL) return(2);
sdl_key = virtualkey->sdl_code; sdl_key = virtualkey->sdl_code;

View File

@ -54,7 +54,7 @@ int menu_select(const char **pp_msgs, int *p_submenus);
const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr); const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr);
uint32_t menu_wait_key_press(int vk); uint32_t menu_wait_key_press();
void msgKill(SDL_Rect *rc); void msgKill(SDL_Rect *rc);
int msgInfo(char *text, int duration, SDL_Rect *rc); int msgInfo(char *text, int duration, SDL_Rect *rc);