diff --git a/Makefile b/Makefile index de4cf30..f68bb82 100644 --- a/Makefile +++ b/Makefile @@ -125,9 +125,15 @@ dist: $(BUILD) cp meta.xml $@/apps/fbzx-wii/meta.xml cp icon.png $@/apps/fbzx-wii/icon.png cp spectrum-roms/* $@/fbzx-wii/spectrum-roms - cp keymap.bmp $@/fbzx-wii/fbzx - cp ZXSpectrum48k.png $@/fbzx-wii/fbzx - cp FreeMono.ttf $@/fbzx-wii/fbzx + cp images/keymap.bmp $@/fbzx-wii/fbzx + cp images/Spectrum_keyboard.png $@/fbzx-wii/fbzx + cp images/symbol_shift.png $@/fbzx-wii/fbzx + cp images/caps_shift.png $@/fbzx-wii/fbzx + cp images/Spectrum_keyboard_small.png $@/fbzx-wii/fbzx + cp images/symbol_shift_small.png $@/fbzx-wii/fbzx + cp images/caps_shift_small.png $@/fbzx-wii/fbzx + cp images/ZXSpectrum48k.png $@/fbzx-wii/fbzx + cp images/FreeMono.ttf $@/fbzx-wii/fbzx cp fbzx.net $@/fbzx-wii cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS VERSIONS.wii $@/apps/fbzx-wii/doc touch $@/fbzx-wii/tapes/dummy diff --git a/README b/README index 0ee3bca..cfd4789 100644 --- a/README +++ b/README @@ -125,7 +125,8 @@ computers can run FBZX under X without problem. The PC keyboard works exactly like the Spectrum keyboard (but only numbers and letters). ENTER key is Return, CAPS SHIFT is in both Shift keys, and SYMBOL SHIFT is in both Control keys. Delete, ',' and '.' works too. I hope to add -'extended keys' in a near future (in FBZX it is TAB button). +'extended keys' in a near future (in FBZX Wii 'extended keys' is 'TAB' button +and 'Edit' is 'INS' button). Whit ESC you exit FBZX. @@ -182,13 +183,13 @@ since the emulator intercepts the call to SA-BYTES). Each new block is added at the end of the file, but only if the SAVE operation is enabled for this file. -HOW WORKS THE FAST SPEED LOAD AND SAVE FOR TAP FILES? +HOW WORKS THE INSTANT LOAD AND SAVE FOR TAP FILES? Just type LOAD "" in the emulator (or choose the TAPE LOADER option in the 128K menu) and the tape will automagically load. This only works with programs that uses the ROM to load all the blocks. If you have a TAP file with a program that -uses a custom routine to load the blocks, then you must use the NORMAL SPEED. -To do this, press F3 to go to the TAP menu and choose NORMAL SPEED. Then return +uses a custom routine to load the blocks, then you must use the NORMAL LOAD. +To do this, press F3 to go to the TAP menu and choose NORMAL LOAD. Then return to the emulation (with ESC) and use LOAD "" (or the TAPE LOADER option). Finally, put the tape in Play with F6. You can stop the tape with F5 and start it again with F6 as many times you want. @@ -199,13 +200,13 @@ tape when you want with the right option in the TAP menu (F3 key). In a near future a block manager will be added, in order to allow the user to choose a block into the TAP file (thinking in multistage games). -Remember that the Fast Speed is available only for TAP files, not in TZX. In -the last case you can go to the SETTINGS menu (F4) and change the TURBO mode -to FAST, so the tape will load faster, and then change again to NORMAL. +Remember that the INSTANT LOAD is available only for TAP files, not in TZX. In +the last case you can go to the SETTINGS menu (F4) and enable the TURBO auto mode, +so the tape will load faster. -The FAST SPEED applies when saving too. The SAVE operation is done ALWAYS -when SA-BYTES (in the Spectrum ROM) is called. The difference between FAST and -normal SAVE is that FAST returns inmediately, and NORMAL calls the original +The INSTANT LOAD applies when saving too. The SAVE operation is done ALWAYS +when SA-BYTES (in the Spectrum ROM) is called. The difference between INSTANT and +normal SAVE is that INSTANT returns inmediately, and NORMAL calls the original routine. This means that, if you abort the save command, the block will be saved in the TAP file anyway. diff --git a/VERSIONS.wii b/VERSIONS.wii index 3377953..f2aa95e 100644 --- a/VERSIONS.wii +++ b/VERSIONS.wii @@ -1,3 +1,12 @@ +version 7: + * Added auto turbo mode + * Added graphical virtual keyboard using wii pointer + * Added B button as escape + * Fixed bug in file list management + + -- Fabio Olimpieri Dec 30 2012 + + version 6: * Added mdr and tape file creation menu * Added poke menu diff --git a/fbzx.net b/fbzx.net index ce4b8cd..ba816a7 100644 --- a/fbzx.net +++ b/fbzx.net @@ -7,7 +7,7 @@ share_name=FOLDER smb_ip=192.168.0.1 # FTP configuration - +# set to 1 to enable FTP ftp_enable=0 # WOS FTPUser=anonymous diff --git a/fbzx.smb b/fbzx.smb deleted file mode 100644 index 9dad265..0000000 --- a/fbzx.smb +++ /dev/null @@ -1,7 +0,0 @@ -# SMB configuration -# set to 1 to enable smb -smb_enable=0 -user=USER -password=PASSWORD -share_name=FOLDER -smb_ip=192.168.0.1 diff --git a/FreeMono.ttf b/images/FreeMono.ttf similarity index 100% rename from FreeMono.ttf rename to images/FreeMono.ttf diff --git a/images/Spectrum_keyboard.png b/images/Spectrum_keyboard.png new file mode 100644 index 0000000..dbb0a18 Binary files /dev/null and b/images/Spectrum_keyboard.png differ diff --git a/images/Spectrum_keyboard_small.png b/images/Spectrum_keyboard_small.png new file mode 100644 index 0000000..426d4ff Binary files /dev/null and b/images/Spectrum_keyboard_small.png differ diff --git a/ZXSpectrum48k.png b/images/ZXSpectrum48k.png similarity index 100% rename from ZXSpectrum48k.png rename to images/ZXSpectrum48k.png diff --git a/images/caps_shift.png b/images/caps_shift.png new file mode 100644 index 0000000..0fa3a06 Binary files /dev/null and b/images/caps_shift.png differ diff --git a/images/caps_shift_small.png b/images/caps_shift_small.png new file mode 100644 index 0000000..d1e8e74 Binary files /dev/null and b/images/caps_shift_small.png differ diff --git a/keymap.bmp b/images/keymap.bmp similarity index 100% rename from keymap.bmp rename to images/keymap.bmp diff --git a/images/symbol_shift.png b/images/symbol_shift.png new file mode 100644 index 0000000..d995522 Binary files /dev/null and b/images/symbol_shift.png differ diff --git a/images/symbol_shift_small.png b/images/symbol_shift_small.png new file mode 100644 index 0000000..9ad77d8 Binary files /dev/null and b/images/symbol_shift_small.png differ diff --git a/meta.xml b/meta.xml index d31a553..77874b0 100644 --- a/meta.xml +++ b/meta.xml @@ -2,8 +2,8 @@ FBZX Wii Oibaf - 6.0 - 20120819 + 7.0 + 20121230 ZX Spectrum Emulator A ZX Spectrum emulator for FrameBuffer written by Sergio Costas, see http://www.rastersoft.com/fbzx.html. The port to Wii was done by Fabio Olimpieri. @@ -12,9 +12,9 @@ USAGE ------ Put .z80 and .sna files in /fbzx-wii/snapshots or .tap and .tzx files in /fbzx-wii/tapes on your SD card. -Press the home button to access the in-game menu. Press 1 to select an item and 2 to escape. +Press the home button to access the in-game menu. Press 1 or A to select an item and 2 or B to escape. -Press the "+" button to access the virtual keyboard. +Press the "+" button to access the virtual keyboard which uses the IR pointer. The in-game menu allows you to insert tapes, load them and configure the display, joysticks etc. @@ -22,16 +22,15 @@ The easiest way to play a game is to load a snapshot (.z80 and .sna files). You can also insert a tape file (.tap and .tzx) and then load the file in the tape menu (it simulates the command Load ""). -If you have problems with a .tap file, likely the TAP file has a program which uses a custom routine to load the blocks; in this case, try to disbale the "Tap fast speed" function. +If you have problems with a .tap file, likely the TAP file has a program which uses a custom routine to load the blocks; in this case, try to disable the "Tap instant load" function. -If you want to speed up the tape file loading (both for .tzx file and .tap file with "tap fast speed" disabled), try to enable "turbo mode" which speeds up the emulator by 3 or by 5. -In this case, do not forget to revert to normal speed after the loading. +If you want to speed up the tape file loading (both for .tzx file and .tap file with "tap instant load" disabled), try to enable "auto turbo mode" which speeds up the emulator while loading. It is possible to set precision emulation required by some demo graphic programs. Turbo mode is disable in this mode. The general preferences are saved (joystick type, machine, buttons bindings, etc.) from the main in-game menu and they are loaded on start-up. -You can also save the game preferences which can be automatically loaded with the tape/snapshot if the related option is set . +You can also save the game preferences which can be automatically loaded with the tape/snapshot if the related option is set. You can also load a file from a usb disk, from your PC and from Internet via FTP using a wi-fi connection. For the wi-fi you should set the parameters in fbzx.net file. diff --git a/src/VirtualKeyboard.c b/src/VirtualKeyboard.c index 2ce8ba8..340ca1e 100644 --- a/src/VirtualKeyboard.c +++ b/src/VirtualKeyboard.c @@ -29,6 +29,8 @@ #include "computer.h" #include "VirtualKeyboard.h" #include "menu_sdl.h" +#include +#include #define K(name, sdl_code) \ @@ -38,7 +40,19 @@ #define KEY_COLS 10 -#define KEY_ROWS 6 +#define KEY_ROWS 5 + +#ifdef DEBUG +extern FILE *fdebug; +#define printf(...) fprintf(fdebug,__VA_ARGS__) +#else + #ifdef GEKKO + #define printf(...) + #endif +#endif + +static SDL_Surface *image_kbd, *image_sym, *image_caps,*image_kbd_small, *image_sym_small, *image_caps_small ; +static int vkb_is_init; extern struct computer ordenador; void clean_screen(); @@ -49,96 +63,70 @@ static virtkey_t keys[KEY_COLS * KEY_ROWS] = { 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",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), 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), - 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()}; + K("Ext",SDLK_TAB),K("Edit",SDLK_INSERT),K("Del",SDLK_BACKSPACE),K("None",0), K("Done",1), K("Fire",SDLK_LALT) ,K(" Up",SDLK_UP),K("Down",SDLK_DOWN), K("Left",SDLK_LEFT),K("Right",SDLK_RIGHT)}; -void VirtualKeyboard_init(SDL_Surface *screen, TTF_Font *font) +void VirtualKeyboard_init(SDL_Surface *screen) { VirtualKeyboard.screen = screen; - VirtualKeyboard.font = font; - VirtualKeyboard.sel_x = 0; - VirtualKeyboard.sel_y = 0; + VirtualKeyboard.sel_x = 64; + VirtualKeyboard.sel_y = 100; + vkb_is_init = -1; + + image_kbd=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard.png"); + image_sym=IMG_Load("/fbzx-wii/fbzx/symbol_shift.png"); + image_caps=IMG_Load("/fbzx-wii/fbzx/caps_shift.png"); + + 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;} + if (image_sym == NULL) {printf("Impossible to load symbol shift image\n"); return;} + if (image_caps == NULL) {printf("Impossible to load caps shift image\n"); return;} + + 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;} + if (image_caps_small == NULL) {printf("Impossible to load caps shift small image\n"); return;} + memset(VirtualKeyboard.buf, 0, sizeof(VirtualKeyboard.buf)); + vkb_is_init = 1; } void draw() { - int y,x; - int screen_w = VirtualKeyboard.screen->w; - int screen_h = VirtualKeyboard.screen->h; - int key_w = 54/RATIO; - int key_h = 36/RATIO; - int border_x = (screen_w - (key_w * KEY_COLS)) / 2; - int border_y = (screen_h - (key_h * KEY_ROWS)) / 2 + 50/RATIO; - SDL_Rect bg_rect = {border_x, border_y, - key_w * KEY_COLS, key_h * KEY_ROWS}; - - SDL_FillRect(VirtualKeyboard.screen, &bg_rect, - SDL_MapRGB(ordenador.screen->format, 0xff, 0xff, 0xff)); - - for (y = 0; y < KEY_ROWS; y++ ) - { - for (x = 0; x < KEY_COLS; x++ ) - { - int which = y * KEY_COLS + x; - virtkey_t key = keys[which]; - int r = 64, g = 64, b = 64; - const char *what = key.name; - - /* Skip empty positions */ - if (key.name == NULL) - continue; - - if ( key.is_done ) - r = 255; - if ( (x == VirtualKeyboard.sel_x && y == VirtualKeyboard.sel_y)) - g = 200; - - menu_print_font(VirtualKeyboard.screen, r, g, b, - x * key_w + border_x, y * key_h + border_y, - what, 16); - } - } + + SDL_Rect dst_rect = {VirtualKeyboard.sel_x/RATIO, VirtualKeyboard.sel_y/RATIO, 0, 0}; + + if (RATIO == 1) SDL_BlitSurface(image_kbd, NULL, ordenador.screen, &dst_rect); + else SDL_BlitSurface(image_kbd_small, NULL, ordenador.screen, &dst_rect); + + dst_rect.x = (VirtualKeyboard.sel_x+10)/RATIO; + dst_rect.y = (VirtualKeyboard.sel_y+200)/RATIO; + if (keys[3 * KEY_COLS + 0 ].is_on) + {if (RATIO == 1) SDL_BlitSurface(image_caps, NULL, ordenador.screen, &dst_rect); + else SDL_BlitSurface(image_caps_small, NULL, ordenador.screen, &dst_rect);} + + + dst_rect.x = (VirtualKeyboard.sel_x+402)/RATIO; + dst_rect.y = (VirtualKeyboard.sel_y+200)/RATIO; + if (keys[3 * KEY_COLS + 8 ].is_on) + {if (RATIO == 1) SDL_BlitSurface(image_sym, NULL, ordenador.screen, &dst_rect); + else SDL_BlitSurface(image_sym_small, NULL, ordenador.screen, &dst_rect);} } -void select_next_kb(int dx, int dy) -{ - int next_x = (VirtualKeyboard.sel_x + dx) % KEY_COLS; - int next_y = (VirtualKeyboard.sel_y + dy) % KEY_ROWS; - virtkey_t key; - - if (next_x < 0) - next_x = KEY_COLS + next_x; - if (next_y < 0) - next_y = KEY_ROWS + next_y; - VirtualKeyboard.sel_x = next_x; - VirtualKeyboard.sel_y = next_y; - - key = keys[ next_y * KEY_COLS + next_x ]; - - /* Skip the empty spots */ - if (key.name == NULL) - { - if (dy != 0) /* Look left */ - select_next_kb(-1, 0); - else - select_next_kb(dx, dy); - } -} struct virtkey *get_key_internal() { while(1) { uint32_t k; - int x,y,i=0; - int screen_w = VirtualKeyboard.screen->w; - int screen_h = VirtualKeyboard.screen->h; - int key_w = 54/RATIO; - int key_h = 36/RATIO; - int border_x = (screen_w - (key_w * KEY_COLS)) / 2; - int border_y = (screen_h - (key_h * KEY_ROWS)) / 2 + 50/RATIO; + 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; draw(); SDL_Flip(VirtualKeyboard.screen); @@ -149,35 +137,32 @@ struct virtkey *get_key_internal() SDL_ShowCursor(SDL_DISABLE); - if (k & KEY_UP) - select_next_kb(0, -1); - else if (k & KEY_DOWN) - select_next_kb(0, 1); - else if (k & KEY_LEFT) - select_next_kb(-1, 0); - else if (k & KEY_RIGHT) - select_next_kb(1, 0); - else if (k & KEY_ESCAPE) - return NULL; + if (k & KEY_ESCAPE) return NULL; else if (k & KEY_SELECT) { - if (!(k & KEY_SELECT_A)) i= VirtualKeyboard.sel_y * KEY_COLS + VirtualKeyboard.sel_x; - else - { - SDL_GetMouseState(&x, &y); - i= (y-border_y+10/RATIO)/key_h * KEY_COLS + (x-border_x+10/RATIO)/key_w; - if ((i<0)||(i>=KEY_COLS * KEY_ROWS)) i=KEY_COLS * KEY_ROWS - 1; //NULL - } + + SDL_GetMouseState(&xm, &ym); + x = (xm-border_x); + y = (ym-border_y); + if ((x<0)||(x>= KEY_COLS*key_w)) continue; + if ((y<0)||(y>= KEY_ROWS*key_h)) continue; + + i = y/key_h*KEY_COLS + x/key_w; + + + WPAD_Rumble(0, 1); + SDL_Delay(50); + WPAD_Rumble(0, 0); virtkey_t *key = &keys[i]; - 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 - else if ((key->sdl_code == 306) && !keys[3 * KEY_COLS + 0 ].is_done) - keys[3 * KEY_COLS + 8 ].is_done = !keys[3 * KEY_COLS + 8 ].is_done; //Sym Shift + if ((key->sdl_code == 304) && !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 == 306) && !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_done; - key->sym_on = keys[3 * KEY_COLS + 8 ].is_done; + key->caps_on = keys[3 * KEY_COLS + 0 ].is_on; + key->sym_on = keys[3 * KEY_COLS + 8 ].is_on; return key; } } @@ -189,16 +174,13 @@ struct virtkey *get_key_internal() struct virtkey* get_key() { virtkey_t *key; - SDL_Rect rect = {32/RATIO, (120+50)/RATIO, FULL_DISPLAY_X-64/RATIO, FULL_DISPLAY_Y-250/RATIO}; - keys[3 * KEY_COLS + 0 ].is_done = 0; //Caps Shit - keys[3 * KEY_COLS + 8 ].is_done = 0; //Sym Shift - - SDL_FillRect(VirtualKeyboard.screen, &rect, SDL_MapRGB(ordenador.screen->format, 0xff, 0xff, 0xff)); + if (vkb_is_init != 1) return NULL; + + keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit + keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift key = get_key_internal(); - - SDL_FillRect(VirtualKeyboard.screen, &rect, SDL_MapRGB(ordenador.screen->format, 0, 0, 0)); return key; } diff --git a/src/VirtualKeyboard.h b/src/VirtualKeyboard.h index defde62..0e08958 100644 --- a/src/VirtualKeyboard.h +++ b/src/VirtualKeyboard.h @@ -29,7 +29,7 @@ typedef struct virtkey { const char *name; int sdl_code; - int is_done; + int is_on; int caps_on; int sym_on; } virtkey_t; @@ -38,14 +38,13 @@ typedef struct virtkey struct Virtual_Keyboard { SDL_Surface *screen; - TTF_Font *font; int sel_x; int sel_y; char buf[255]; } VirtualKeyboard; -void VirtualKeyboard_init(SDL_Surface *screen, TTF_Font *font); +void VirtualKeyboard_init(SDL_Surface *screen); struct virtkey* get_key(); struct virtkey* get_key_internal(); void draw(); diff --git a/src/computer.c b/src/computer.c index 26e5ea1..e1ad96b 100644 --- a/src/computer.c +++ b/src/computer.c @@ -1382,10 +1382,10 @@ inline void read_keyboard () { if (ordenador.key[SDLK_m] || joybutton_matrix[0][SDLK_m] || joybutton_matrix[1][SDLK_m]) ordenador.k15|=4; 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_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_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_PERIOD]) ordenador.k15|=6; + if (ordenador.key[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_l] || joybutton_matrix[0][SDLK_l] || joybutton_matrix[1][SDLK_l]) ordenador.k14|=2; @@ -1436,6 +1436,7 @@ inline void read_keyboard () { if (ordenador.key[SDLK_RIGHT]) {ordenador.k12 |=4;ordenador.k8|=1;} if (ordenador.key[SDLK_TAB]|| joybutton_matrix[0][SDLK_TAB] || joybutton_matrix[1][SDLK_TAB]) {ordenador.k15|=2;ordenador.k8|=1;} //Extended mode + if (ordenador.key[SDLK_INSERT]|| joybutton_matrix[0][SDLK_INSERT] || joybutton_matrix[1][SDLK_INSERT]) {ordenador.k11|=1;ordenador.k8|=1;} //Edit ordenador.s8 = (ordenador.s8 & 0xE0) | (ordenador.k8 ^ 0x1F); ordenador.s9 = (ordenador.s9 & 0xE0) | (ordenador.k9 ^ 0x1F); diff --git a/src/gui_sdl.c b/src/gui_sdl.c index d3143ed..b623ac6 100644 --- a/src/gui_sdl.c +++ b/src/gui_sdl.c @@ -147,20 +147,18 @@ static const char *microdrive_messages[] = { }; static const char *tools_messages[] = { - /*00*/ "Show keyboard", + /*00*/ "Save SCR", /*01*/ " ", - /*02*/ "Save SCR", + /*02*/ "Load SCR", /*03*/ " ", - /*04*/ "Load SCR", + /*04*/ "Insert poke", /*05*/ " ", - /*06*/ "Insert poke", + /*06*/ "Load poke file", /*07*/ " ", - /*08*/ "Load poke file", - /*09*/ " ", - /*10*/ "Port", - /*11*/ "^|sd|usb|smb|ftp", - /*12*/ " ", - /*13*/ "Help", + /*08*/ "Port", + /*09*/ "^|sd|usb|smb|ftp", + /*10*/ " ", + /*11*/ "Help", NULL }; @@ -665,6 +663,7 @@ static void input_options(int joy) struct virtkey *virtualkey; + do { memset(submenus, 0, sizeof(submenus)); submenus[0] = ordenador.joystick[joy]; @@ -683,6 +682,9 @@ static void input_options(int joy) if (opt == 0 || opt == 10|| opt == 12) return; + VirtualKeyboard.sel_x = 64; + VirtualKeyboard.sel_y = 90; + virtualkey = get_key(); if (virtualkey == NULL) return; @@ -708,6 +710,8 @@ static void input_options(int joy) } setup_joystick(joy, sdl_key, joy_key); + } while (opt == 2 || opt == 4 || opt == 6 || opt == 8); + } @@ -881,29 +885,6 @@ static void microdrive() break; } } -void show_keyboard_layout() { - - FILE *fichero; - int bucle1,bucle2,retval; - unsigned char *buffer,valor; - - buffer=screen->pixels; - - fichero=myfopen("fbzx/keymap.bmp","r"); - if (fichero==NULL) { - msgInfo("Keymap picture not found",3000,NULL); - return; - } - - for (bucle1=0;bucle1<344;bucle1++) - for(bucle2=0;bucle2<640;bucle2++) { - retval=fscanf(fichero,"%c",&valor); - paint_one_pixel((unsigned char *)(colors+valor),buffer); - buffer+=ordenador.bpp; - } - SDL_Flip(ordenador.screen); - menu_wait_key_press(); -} static void load_scr() { @@ -1360,22 +1341,19 @@ static void tools() switch(opt) { - case 0: // Show keyboard - if (ordenador.zaurus_mini == 0) show_keyboard_layout(); else msgInfo("No picture available in 320X240 resolution",3000,NULL); - break; - case 2: // Save SCR + case 0: // Save SCR save_scr(); break; - case 4: // Load SCR + case 2: // Load SCR load_scr(); break; - case 6: // Insert poke + case 4: // Insert poke do_poke_sdl(); break; - case 8: // Load poke file + case 6: // Load poke file load_poke_file(); break; - case 13: + case 11: help(); break; default: @@ -1388,6 +1366,9 @@ void virtual_keyboard(void) { int key_code; + VirtualKeyboard.sel_x = 64; + VirtualKeyboard.sel_y = 90; + virtkey_t *key =get_key(); if (key) {key_code = key->sdl_code;} else return; diff --git a/src/menu_sdl.c b/src/menu_sdl.c index e2903ad..e0da362 100644 --- a/src/menu_sdl.c +++ b/src/menu_sdl.c @@ -335,10 +335,11 @@ static const char **get_file_list_zip(const char *path) static const char **get_file_list(const char *base_dir) { DIR *d = opendir(base_dir); - const char **file_list; + const char **file_list, **realloc_file_list; int cur = 0; struct dirent *de; int cnt = 16; + int i; if (!d) return NULL; @@ -381,9 +382,15 @@ static const char **get_file_list(const char *base_dir) if (cur > cnt - 2) { cnt = cnt + 32; - file_list = (const char**)realloc(file_list, cnt * sizeof(char*)); - if (!file_list) + realloc_file_list = (const char**)realloc(file_list, cnt * sizeof(char*)); + if (realloc_file_list) file_list = realloc_file_list; else + { + /* Cleanup everything - file_list is NULL-terminated */ + for ( i = 0; file_list[i]; i++ ) + free((void*)file_list[i]); + free(file_list); return NULL; + } } } closedir(d); @@ -806,9 +813,8 @@ uint32_t menu_wait_key_press(void) else if( axis1 > 15000 ) keys |= KEY_DOWN; - if (!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[nr][0]) /* A */ - {keys |= KEY_SELECT; keys |= KEY_SELECT_A;} - if ((!SDL_JoystickGetButton(joy, 3) && joy_bottons_last[nr][1]) || /* 2 */ + if ((!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[nr][0]) || /* A */ + (!SDL_JoystickGetButton(joy, 3) && joy_bottons_last[nr][1]) || /* 2 */ (!SDL_JoystickGetButton(joy, 9) && joy_bottons_last[nr][2]) || /* CA */ (!SDL_JoystickGetButton(joy, 10) && joy_bottons_last[nr][3])) /* CB */ keys |= KEY_SELECT; @@ -1259,8 +1265,8 @@ void font_init() void menu_init(SDL_Surface *screen) { real_screen = screen; - if (FULL_DISPLAY_X == 640) VirtualKeyboard_init(screen, menu_font16); //prima c'era il font 16 alt - else VirtualKeyboard_init(screen, menu_font8); + + VirtualKeyboard_init(screen); is_inited = 1; } @@ -1286,6 +1292,9 @@ int ask_value_sdl(int *final_value,int y_coord,int max_value) { sprintf (nombre2, " %d\177 ", value); print_string (videomem, nombre2, -1, y_coord, 15, 0, ancho); + VirtualKeyboard.sel_x = 64; + VirtualKeyboard.sel_y = 155; + virtualkey = get_key(); if (virtualkey == NULL) return(2); sdl_key = virtualkey->sdl_code; @@ -1411,6 +1420,9 @@ int ask_filename_sdl(char *nombre_final,int y_coord,char *extension, char *path, sprintf (nombre2, " %s.%s ", nombre,extension); print_string (videomem, nombre2, -1, y_coord, 15, 0, ancho); + VirtualKeyboard.sel_x = 64; + VirtualKeyboard.sel_y = 155; + virtualkey = get_key(); if (virtualkey == NULL) return(2); sdl_key = virtualkey->sdl_code; diff --git a/src/menu_sdl.h b/src/menu_sdl.h index 3101a1c..a13e99c 100644 --- a/src/menu_sdl.h +++ b/src/menu_sdl.h @@ -38,7 +38,6 @@ #define KEY_PAGEDOWN 64 #define KEY_PAGEUP 128 #define KEY_HELP 256 -#define KEY_SELECT_A 512 int FULL_DISPLAY_X; //640 int FULL_DISPLAY_Y; //480 diff --git a/src/menus.c b/src/menus.c index 69e2289..e99b403 100644 --- a/src/menus.c +++ b/src/menus.c @@ -601,7 +601,7 @@ void taps_menu() { print_string(fbuffer,"rewind TAP/TZX file",62,100,15,0,ancho); print_string(fbuffer,"3:",14,140,12,0,ancho); - print_string(fbuffer,"fast/normal speed",62,140,15,0,ancho); + print_string(fbuffer,"instant/normal load",62,140,15,0,ancho); print_string(fbuffer,"4:",14,180,12,0,ancho); print_string(fbuffer,"write protection",62,180,15,0,ancho);