Auto turbo mode, B button as escape, IR wiimote in virtual keyboard

This commit is contained in:
fabio.olimpieri 2012-12-27 15:39:35 +00:00
parent badba6a9d7
commit e1ebc8a118
9 changed files with 88 additions and 32 deletions

View File

@ -132,12 +132,23 @@ struct virtkey *get_key_internal()
while(1) while(1)
{ {
uint32_t k; 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;
draw(); draw();
SDL_Flip(VirtualKeyboard.screen); SDL_Flip(VirtualKeyboard.screen);
SDL_ShowCursor(SDL_ENABLE);
k = menu_wait_key_press(); k = menu_wait_key_press();
SDL_ShowCursor(SDL_DISABLE);
if (k & KEY_UP) if (k & KEY_UP)
select_next_kb(0, -1); select_next_kb(0, -1);
else if (k & KEY_DOWN) else if (k & KEY_DOWN)
@ -150,7 +161,15 @@ struct virtkey *get_key_internal()
return NULL; return NULL;
else if (k & KEY_SELECT) else if (k & KEY_SELECT)
{ {
virtkey_t *key = &keys[ VirtualKeyboard.sel_y * KEY_COLS + VirtualKeyboard.sel_x ]; 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
}
virtkey_t *key = &keys[i];
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

View File

@ -108,6 +108,8 @@ void computer_init () { //Called only on start-up
ordenador.joystick[1] = 0; // Cursor ordenador.joystick[1] = 0; // Cursor
ordenador.rumble[0] = 0; ordenador.rumble[0] = 0;
ordenador.rumble[1] = 0; ordenador.rumble[1] = 0;
ordenador.turbo = 0;
ordenador.turbo_state = 0;
ordenador.precision = 0; ordenador.precision = 0;
ordenador.tape_readed = 0; ordenador.tape_readed = 0;
@ -549,7 +551,7 @@ inline void show_screen (int tstados) {
if (ordenador.tstados_counter>=ordenador.tstatodos_frame) { if (ordenador.tstados_counter>=ordenador.tstatodos_frame) {
ordenador.tstados_counter-=ordenador.tstatodos_frame; ordenador.tstados_counter-=ordenador.tstatodos_frame;
ordenador.interr = 1; ordenador.interr = 1;
if ((ordenador.turbo == 0) || (curr_frames%7 == 0)) ordenador.readkeyboard = 1; if ((ordenador.turbo_state == 0) || (curr_frames%7 == 0)) ordenador.readkeyboard = 1;
curr_frames++; curr_frames++;
} }
return; return;
@ -678,7 +680,7 @@ inline void show_screen (int tstados) {
} }
} }
//Write the screen from 14339 state //Write the screen from 14339 state for 48K and from 14365 for 128k
inline void show_screen_precision (int tstados) { inline void show_screen_precision (int tstados) {
@ -1507,8 +1509,8 @@ void ResetComputer () {
ordenador.lower_border_line = 64 + 192; ordenador.lower_border_line = 64 + 192;
ordenador.cpufreq = 3500000; ordenador.cpufreq = 3500000;
ordenador.tstatodos_frame= 69888; ordenador.tstatodos_frame= 69888;
ordenador.start_contention = 14335; //ordenador.start_contention = 14335;
ordenador.end_contention = 14335+224*192; //ordenador.end_contention = 14335+224*192;
ordenador.first_line = 40; ordenador.first_line = 40;
ordenador.last_line = 280; ordenador.last_line = 280;
} }
@ -1519,8 +1521,8 @@ void ResetComputer () {
ordenador.lower_border_line = 40 + 192; ordenador.lower_border_line = 40 + 192;
ordenador.cpufreq = 3527500; ordenador.cpufreq = 3527500;
ordenador.tstatodos_frame= 59136; ordenador.tstatodos_frame= 59136;
ordenador.start_contention = 8959; //ordenador.start_contention = 8959;
ordenador.end_contention = 8959+224*192; //ordenador.end_contention = 8959+224*192;
ordenador.first_line = 16; ordenador.first_line = 16;
ordenador.last_line = 256; ordenador.last_line = 256;
} }
@ -1543,8 +1545,8 @@ void ResetComputer () {
ordenador.lower_border_line = 63 + 192; ordenador.lower_border_line = 63 + 192;
ordenador.cpufreq = 3546900; ordenador.cpufreq = 3546900;
ordenador.tstatodos_frame= 70908; ordenador.tstatodos_frame= 70908;
ordenador.start_contention = 14361; //ordenador.start_contention = 14361;
ordenador.end_contention = 14361+228*192; //ordenador.end_contention = 14361+228*192;
ordenador.first_line = 40; ordenador.first_line = 40;
ordenador.last_line = 280; ordenador.last_line = 280;
ordenador.start_screen=45; ordenador.start_screen=45;

View File

@ -78,8 +78,8 @@ struct computer {
int tstatodos_frame; //number of tstados per frame int tstatodos_frame; //number of tstados per frame
int pixels_octect; //2 bits in the octect int pixels_octect; //2 bits in the octect
int pixels_word; //2 bits in the word int pixels_word; //2 bits in the word
int start_contention; //start tstados for contention //int start_contention; //start tstados for contention
int end_contention; //end tstados for contention //int end_contention; //end tstados for contention
unsigned char screen_snow; // 0-> no emulate snow; 1-> emulate snow unsigned char screen_snow; // 0-> no emulate snow; 1-> emulate snow
unsigned char fetch_state; unsigned char fetch_state;
@ -219,6 +219,7 @@ 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;
unsigned char turbo_state;
unsigned int keyboard_buffer[2][10]; unsigned int keyboard_buffer[2][10];
unsigned int kbd_buffer_pointer; unsigned int kbd_buffer_pointer;
unsigned char *key; unsigned char *key;

View File

@ -661,6 +661,7 @@ int save_config(struct computer *object, char *filename) {
fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10); fprintf(fconfig,"rumble2=%c%c",48+object->rumble[1],10);
fprintf(fconfig,"port=%c%c",48+object->port,10); fprintf(fconfig,"port=%c%c",48+object->port,10);
fprintf(fconfig,"autoconf=%c%c",48+object->autoconf,10); fprintf(fconfig,"autoconf=%c%c",48+object->autoconf,10);
fprintf(fconfig,"turbo=%c%c",48+object->turbo,10);
for (joy_n=0; joy_n<2; joy_n++) for (joy_n=0; joy_n<2; joy_n++)
@ -829,7 +830,7 @@ int load_config(struct computer *object, char *filename) {
FILE *fconfig; FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,ay_emul=255,mdr_active=255, unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,ay_emul=255,mdr_active=255,
dblscan=255,framerate =255, screen =255, text=255, precision=255, bw=255, tap_fast=255, audio_mode=255, dblscan=255,framerate =255, screen =255, text=255, precision=255, bw=255, tap_fast=255, audio_mode=255,
joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255; joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255, turbo=225;
if (filename) strcpy(config_path,filename); if (filename) strcpy(config_path,filename);
else return -2; else return -2;
@ -951,6 +952,10 @@ int load_config(struct computer *object, char *filename) {
autoconf=line[9]-'0'; autoconf=line[9]-'0';
continue; continue;
} }
if (!strncmp(line,"turbo=",6)) {
turbo=line[6]-'0';
continue;
}
if (!strncmp(line,"joybutton_",10)) { if (!strncmp(line,"joybutton_",10)) {
sscanf(line, "joybutton_%c_%c=%3d",&joy_n ,&key_n, &key_sdl); 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)) if ((joy_n<50) && (joy_n>47) && (key_n<119) && (key_n>96))
@ -1026,6 +1031,9 @@ int load_config(struct computer *object, char *filename) {
if (autoconf<2) { if (autoconf<2) {
object->autoconf=autoconf; object->autoconf=autoconf;
} }
if (turbo<2) {
object->turbo=turbo;
}
fclose(fconfig); fclose(fconfig);
return 0; return 0;

View File

@ -79,10 +79,10 @@ static const char *emulation_messages[] = {
/*01*/ "^|48k_2|48K_3|128k|+2|+2A/+3|128K_Sp|NTSC", /*01*/ "^|48k_2|48K_3|128k|+2|+2A/+3|128K_Sp|NTSC",
/*02*/ "Frame rate", /*02*/ "Frame rate",
/*03*/ "^|100%|50%|33%|25%|20%", /*03*/ "^|100%|50%|33%|25%|20%",
/*04*/ "Tap fast speed", /*04*/ "Tap instant load",
/*05*/ "^|on|off", /*05*/ "^|on|off",
/*06*/ "Turbo mode", /*06*/ "Turbo mode",
/*07*/ "^|off|speed|ultraspeed", /*07*/ "^|off|auto|fast|ultrafast",
/*08*/ "Precision", /*08*/ "Precision",
/*09*/ "^|on|off", /*09*/ "^|on|off",
NULL NULL
@ -523,19 +523,24 @@ static void emulation_settings(void)
{ {
switch(ordenador.turbo) switch(ordenador.turbo)
{ {
case 1: //auto
ordenador.precision =0;
case 0: //off case 0: //off
update_frequency(0); //set machine frequency update_frequency(0); //set machine frequency
jump_frames=0; jump_frames=0;
ordenador.turbo_state=0;
break; break;
case 1: //speed case 2: //fast
update_frequency(10000000); update_frequency(10000000);
jump_frames=4; jump_frames=4;
ordenador.precision =0; ordenador.precision =0;
ordenador.turbo_state=2;
break; break;
case 2: //ultra speed case 3: //ultra fast
update_frequency(15000000); update_frequency(15000000);
jump_frames=24; jump_frames=24;
ordenador.precision =0; ordenador.precision =0;
ordenador.turbo_state=3;
break; break;
default: default:
break; break;
@ -550,6 +555,7 @@ static void emulation_settings(void)
update_frequency(0); update_frequency(0);
jump_frames=0; jump_frames=0;
ordenador.turbo =0; ordenador.turbo =0;
ordenador.turbo_state=0;
} }
} }
} }

View File

@ -774,7 +774,7 @@ uint32_t menu_wait_key_press(void)
SDL_Joystick *joy; SDL_Joystick *joy;
static int joy_keys_changed; static int joy_keys_changed;
static int joy_keys_last; static int joy_keys_last;
static int joy_bottons_last[2][7]; static int joy_bottons_last[2][8];
SDL_JoystickUpdate(); SDL_JoystickUpdate();
/* Wii-specific, sorry */ /* Wii-specific, sorry */
for (nr = 0; nr < ordenador.joystick_number; nr++) { for (nr = 0; nr < ordenador.joystick_number; nr++) {
@ -806,14 +806,16 @@ uint32_t menu_wait_key_press(void)
else if( axis1 > 15000 ) keys |= KEY_DOWN; else if( axis1 > 15000 ) keys |= KEY_DOWN;
if ((!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[nr][0]) || /* A */ if (!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[nr][0]) /* A */
(!SDL_JoystickGetButton(joy, 3) && joy_bottons_last[nr][1]) || /* 2 */ {keys |= KEY_SELECT; keys |= KEY_SELECT_A;}
if ((!SDL_JoystickGetButton(joy, 3) && joy_bottons_last[nr][1]) || /* 2 */
(!SDL_JoystickGetButton(joy, 9) && joy_bottons_last[nr][2]) || /* CA */ (!SDL_JoystickGetButton(joy, 9) && joy_bottons_last[nr][2]) || /* CA */
(!SDL_JoystickGetButton(joy, 10) && joy_bottons_last[nr][3])) /* CB */ (!SDL_JoystickGetButton(joy, 10) && joy_bottons_last[nr][3])) /* CB */
keys |= KEY_SELECT; keys |= KEY_SELECT;
if ((!SDL_JoystickGetButton(joy, 2) && joy_bottons_last[nr][4]) || /* 1 */ if ((!SDL_JoystickGetButton(joy, 2) && joy_bottons_last[nr][4]) || /* 1 */
(!SDL_JoystickGetButton(joy, 11) && joy_bottons_last[nr][5]) || /* CX */ (!SDL_JoystickGetButton(joy, 11) && joy_bottons_last[nr][5]) || /* CX */
(!SDL_JoystickGetButton(joy, 12) && joy_bottons_last[nr][6])) /* CY */ (!SDL_JoystickGetButton(joy, 12) && joy_bottons_last[nr][6])|| /* CY */
(!SDL_JoystickGetButton(joy, 1) && joy_bottons_last[nr][7])) /* B */
keys |= KEY_ESCAPE; keys |= KEY_ESCAPE;
if (SDL_JoystickGetButton(joy, 5) != 0 || /* + */ if (SDL_JoystickGetButton(joy, 5) != 0 || /* + */
SDL_JoystickGetButton(joy, 18) != 0) /* C+ */ SDL_JoystickGetButton(joy, 18) != 0) /* C+ */
@ -829,6 +831,7 @@ uint32_t menu_wait_key_press(void)
joy_bottons_last[nr][4] =SDL_JoystickGetButton(joy, 2) ; /* 1 */ joy_bottons_last[nr][4] =SDL_JoystickGetButton(joy, 2) ; /* 1 */
joy_bottons_last[nr][5] =SDL_JoystickGetButton(joy, 11) ; /* CX */ joy_bottons_last[nr][5] =SDL_JoystickGetButton(joy, 11) ; /* CX */
joy_bottons_last[nr][6] =SDL_JoystickGetButton(joy, 12) ; /* CY */ joy_bottons_last[nr][6] =SDL_JoystickGetButton(joy, 12) ; /* CY */
joy_bottons_last[nr][7] =SDL_JoystickGetButton(joy, 1) ; /* B */
} }
joy_keys_changed = keys != joy_keys_last; joy_keys_changed = keys != joy_keys_last;
@ -885,7 +888,7 @@ uint32_t menu_wait_key_press(void)
if (keys != 0) if (keys != 0)
break; break;
SDL_Delay(100); SDL_Delay(50);
} }
return keys; return keys;
} }

View File

@ -38,6 +38,7 @@
#define KEY_PAGEDOWN 64 #define KEY_PAGEDOWN 64
#define KEY_PAGEUP 128 #define KEY_PAGEUP 128
#define KEY_HELP 256 #define KEY_HELP 256
#define KEY_SELECT_A 512
int FULL_DISPLAY_X; //640 int FULL_DISPLAY_X; //640
int FULL_DISPLAY_Y; //480 int FULL_DISPLAY_Y; //480

View File

@ -153,9 +153,9 @@ void settings_menu() {
print_string(fbuffer,texto,-1,125,12,0,ancho); print_string(fbuffer,texto,-1,125,12,0,ancho);
if(ordenador.turbo) if(ordenador.turbo)
sprintf(texto,"TURBO mode: enabled"); sprintf(texto,"TURBO auto mode: enabled");
else else
sprintf(texto,"TURBO mode: disabled"); sprintf(texto,"TURBO auto mode: disabled");
print_string(fbuffer,texto,-1,145,14,0,ancho); print_string(fbuffer,texto,-1,145,14,0,ancho);
if (ordenador.bw) { if (ordenador.bw) {
@ -288,14 +288,13 @@ void settings_menu() {
break; break;
case SDLK_t: case SDLK_t:
curr_frames=0; curr_frames=0;
update_frequency(0); //set deafult machine frequency
jump_frames=0;
ordenador.turbo_state = 0;
if(ordenador.turbo){ if(ordenador.turbo){
update_frequency(0); //set machine frequency
ordenador.turbo = 0; ordenador.turbo = 0;
jump_frames=0;
} else { } else {
update_frequency(10000000); //5,0 MHz max emulation speed for wii at full frames ordenador.turbo = 1; //Auto mode
ordenador.turbo = 1;
jump_frames=4;
} }
break; break;
} }

View File

@ -33,7 +33,24 @@ char elbit=0;
inline void tape_read(FILE *fichero, int tstados) { inline void tape_read(FILE *fichero, int tstados) {
if(ordenador.pause) if(ordenador.pause)
return; {
if ((ordenador.turbo_state != 0)&&(ordenador.turbo==1))
{
update_frequency(0); //set machine frequency
jump_frames=0;
ordenador.turbo_state = 0;
}
return;
}
//Auto ultra fast mode
if ((ordenador.turbo_state != 3)&&(ordenador.turbo==1))
{
update_frequency(15000000);
jump_frames=24;
ordenador.precision =0;
ordenador.turbo_state = 3;
}
if(ordenador.tape_file_type == TAP_TAP) if(ordenador.tape_file_type == TAP_TAP)
tape_read_tap(fichero,tstados); tape_read_tap(fichero,tstados);