void settings_menu() { unsigned char *fbuffer,fin; unsigned char texto[41]; int ancho=screen->w; fbuffer=screen->pixels; fin=1; texto[0]=0; do { clean_screen(); print_string(fbuffer,"Current settings",-1,20,15,0,ancho); switch(ordenador.mode128k) { case 0: if(ordenador.issue==2) sprintf(texto,"Mode: 48K issue2"); else sprintf(texto,"Mode: 48K issue3"); break; case 1: sprintf(texto,"Mode: Sinclair 128K"); break; case 2: sprintf(texto,"Mode: Amstrad +2"); break; case 3: sprintf(texto,"Mode: Amstrad +2A/+3"); break; case 4: sprintf(texto,"Mode: Spanish 128K"); break; } print_string(fbuffer,texto,-1,45,14,0,ancho); switch(ordenador.joystick[0]) { case 0: sprintf(texto,"Joystick emulation: Cursor"); break; case 1: sprintf(texto,"Joystick emulation: Kempston"); break; case 2: sprintf(texto,"Joystick emulation: Sinclair (1)"); break; case 3: sprintf(texto,"Joystick emulation: Sinclair (2)"); break; } print_string(fbuffer,texto,-1,65,13,0,ancho); if(ordenador.ay_emul) sprintf(texto,"AY-3-8912 Emulation: enabled"); else sprintf(texto,"AY-3-8912 Emulation: disabled"); print_string(fbuffer,texto,-1,85,11,0,ancho); if(ordenador.mdr_active) sprintf(texto,"Interface I Emulation: enabled"); else sprintf(texto,"Interface I Emulation: disabled"); print_string(fbuffer,texto,-1,105,15,0,ancho); if(ordenador.dblscan) sprintf(texto,"Double scan: enabled"); else sprintf(texto,"Double scan: disabled"); print_string(fbuffer,texto,-1,125,12,0,ancho); if(ordenador.turbo) sprintf(texto,"TURBO auto mode: enabled"); else sprintf(texto,"TURBO auto mode: disabled"); print_string(fbuffer,texto,-1,145,14,0,ancho); switch (ordenador.bw) { case 0: default: print_string(fbuffer,"TV Set: \001\012C\001\014o\001\011l\001\016o\001\013r",-1,165,15,0,ancho); break; case 1: print_string(fbuffer,"TV Set: \001\011B\001\012&\001\014W",-1,165,15,0,ancho); break; case 2: print_string(fbuffer,"TV Set: \001\014Green",-1,165,15,0,ancho); break; } print_string(fbuffer,"1:",30,190,12,0,ancho); print_string(fbuffer,"48K issue2",78,190,15,0,ancho); print_string(fbuffer,"2:",350,190,12,0,ancho); print_string(fbuffer,"48K issue3",398,190,15,0,ancho); print_string(fbuffer,"3:",30,220,12,0,ancho); print_string(fbuffer,"Sinclair 128K",78,220,15,0,ancho); print_string(fbuffer,"4:",350,220,12,0,ancho); print_string(fbuffer,"Amstrad +2",398,220,15,0,ancho); print_string(fbuffer,"5:",30,250,12,0,ancho); print_string(fbuffer,"Amstrad +2A/+3",78,250,15,0,ancho); print_string(fbuffer,"6:",350,250,12,0,ancho); print_string(fbuffer,"Spanish 128K",398,250,15,0,ancho); print_string(fbuffer,"7:",30,280,12,0,ancho); print_string(fbuffer,"Cursor",78,280,15,0,ancho); print_string(fbuffer,"8:",350,280,12,0,ancho); print_string(fbuffer,"Kempston",398,280,15,0,ancho); print_string(fbuffer,"9:",30,310,12,0,ancho); print_string(fbuffer,"Sinclair (1)",78,310,15,0,ancho); print_string(fbuffer,"0:",350,310,12,0,ancho); print_string(fbuffer,"Sinclair (2)",398,310,15,0,ancho); print_string(fbuffer,"I:",30,340,12,0,ancho); print_string(fbuffer,"Interface I",78,340,15,0,ancho); print_string(fbuffer,"D:",350,340,12,0,ancho); print_string(fbuffer,"Double Scan",398,340,15,0,ancho); print_string(fbuffer,"A:",350,370,12,0,ancho); print_string(fbuffer,"AY emulation",398,370,15,0,ancho); print_string(fbuffer,"T:",30,370,12,0,ancho); print_string(fbuffer,"TURBO mode",78,370,15,0,ancho); print_string(fbuffer,"V:",30,400,12,0,ancho); print_string(fbuffer,"TV Set mode",78,400,15,0,ancho); #ifndef GEKKO print_string(fbuffer,"F:",350,400,12,0,ancho); print_string(fbuffer,"Full screen",398,400,15,0,ancho); #endif print_string(fbuffer,"ESC:",168,450,12,0,ancho); print_string(fbuffer,"return emulator",232,450,15,0,ancho); switch(wait_key()) { case SDLK_ESCAPE: case SDLK_RETURN: fin=0; break; case SDLK_1: ordenador.issue=2; ordenador.mode128k=0; ordenador.ay_emul=0; ResetComputer(); break; case SDLK_2: ordenador.issue=3; ordenador.mode128k=0; ordenador.ay_emul=0; ResetComputer(); break; case SDLK_3: ordenador.issue=3; ordenador.mode128k=1; ordenador.ay_emul=1; ordenador.videosystem=0; ordenador.currah_active = 0; ResetComputer(); break; case SDLK_4: ordenador.issue=3; ordenador.mode128k=2; ordenador.ay_emul=1; ordenador.videosystem=0; ordenador.currah_active = 0; ResetComputer(); break; case SDLK_5: ordenador.issue=3; ordenador.mode128k=3; ordenador.ay_emul=1; ordenador.videosystem=0; ordenador.mdr_active=0; ordenador.currah_active = 0; ResetComputer(); break; case SDLK_6: ordenador.issue=3; ordenador.mode128k=4; ordenador.ay_emul=1; ordenador.videosystem=0; ordenador.currah_active = 0; ResetComputer(); break; case SDLK_7: ordenador.joystick[0]=0; break; case SDLK_8: ordenador.joystick[0]=1; break; case SDLK_9: ordenador.joystick[0]=2; break; case SDLK_0: ordenador.joystick[0]=3; break; case SDLK_i: if(ordenador.mode128k!=3) { ordenador.mdr_active=1-ordenador.mdr_active; ResetComputer(); } break; case SDLK_d: ordenador.dblscan=1-ordenador.dblscan; update_npixels(); break; case SDLK_a: ordenador.ay_emul=1-ordenador.ay_emul; break; case SDLK_v: ordenador.bw=(ordenador.bw+1)%3; computer_set_palete(); break; case SDLK_t: curr_frames=0; update_frequency(0); //set deafult machine frequency jump_frames=0; ordenador.turbo_state = 0; if(ordenador.turbo){ ordenador.turbo = 0; } else { ordenador.turbo = 1; //Auto mode } break; #ifndef GEKKO case SDLK_f: SDL_Fullscreen_Switch(); break; #endif } } while(fin); clean_screen(); }
void Keyboard::read_keyboard (SDL_Event *pevento2) { unsigned int temporal_io; SDL_Event evento,evento2,*pevento; Sint16 valor; Uint8 eje; if (pevento2==NULL) { pevento=&evento; if (!SDL_PollEvent (&evento)) return; } else { pevento=pevento2; } if (pevento->type==SDL_QUIT) { salir = 0; return; } if (pevento->type==SDL_MOUSEMOTION) { this->mouse_x += pevento->motion.xrel; this->mouse_y += pevento->motion.yrel; return; } if (pevento->type==SDL_MOUSEBUTTONDOWN) { switch (pevento->button.button) { case SDL_BUTTON_LEFT: this->mouse_left = true; break; case SDL_BUTTON_MIDDLE: this->mouse_center = true; break; case SDL_BUTTON_RIGHT: this->mouse_right = true; break; } } if (pevento->type==SDL_MOUSEBUTTONUP) { switch (pevento->button.button) { case SDL_BUTTON_LEFT: this->mouse_left = false; break; case SDL_BUTTON_MIDDLE: this->mouse_center = false; break; case SDL_BUTTON_RIGHT: this->mouse_right = false; break; } } if (pevento->type==SDL_JOYBUTTONDOWN) { pevento->type=SDL_KEYDOWN; pevento->key.keysym.sym=SDLK_MENU; // emulate pressing the MENU key } if (pevento->type==SDL_JOYBUTTONUP) { pevento->type=SDL_KEYUP; pevento->key.keysym.sym=SDLK_MENU; // emulate depressing the MENU key } if (pevento->type==SDL_JOYAXISMOTION) { eje=pevento->jaxis.axis; valor=pevento->jaxis.value; evento2.type=SDL_KEYUP; if ((valor<16384)&&(valor>-16384)) { // JoyStick centered pevento->type=SDL_KEYUP; 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; this->k8 = this->k9 = this->k10 = this->k11 = this->k12 = this->k13 = this->k14 = this->k15 = 0; this->jk = 0; temporal_io = (unsigned int) pevento->key.keysym.sym; if ((pevento->type==SDL_KEYUP)&&(temporal_io==SDLK_TAB)) { if (!this->tab_extended) { this->tab_extended = true; osd->set_message("Function Key mode on",2000); return; } else { this->tab_extended = false; osd->clear_message(); return; } } if ((pevento->type==SDL_KEYDOWN)&&(this->tab_extended)) return; if ((pevento->type==SDL_KEYUP)&&(this->tab_extended)) { this->tab_extended = false; osd->clear_message(); switch(temporal_io) { case SDLK_1: temporal_io=SDLK_F1; break; case SDLK_2: temporal_io=SDLK_F2; break; case SDLK_3: temporal_io=SDLK_F3; break; case SDLK_4: temporal_io=SDLK_F4; break; case SDLK_5: temporal_io=SDLK_F5; break; case SDLK_6: temporal_io=SDLK_F6; break; case SDLK_7: temporal_io=SDLK_F7; break; case SDLK_8: temporal_io=SDLK_F8; break; case SDLK_9: temporal_io=SDLK_F9; break; case SDLK_0: temporal_io=SDLK_F10; break; case SDLK_o: temporal_io=SDLK_F11; break; case SDLK_p: temporal_io=SDLK_F12; break; } } if (pevento->type == SDL_KEYUP) switch (temporal_io) { case SDLK_ESCAPE: // to exit from the emulator if (!this->esc_again) { this->esc_again = true; osd->set_message("ESC again to exit",2000); } else salir = 0; return; break; case SDLK_F1: help_menu (); // shows the help menu break; case SDLK_F2: case SDLK_F3: case SDLK_F4: case SDLK_F7: case SDLK_F8: launch_menu(temporal_io); break; case SDLK_F5: // STOP tape OOTape->set_pause(true); llsound->set_speed(ordenador->turbo); break; case SDLK_F6: // PLAY tape OOTape->set_pause(false); if (ordenador->turbo_play) { llsound->set_speed(true); } else { llsound->set_speed(ordenador->turbo); } break; case SDLK_F9: llscreen->fullscreen_switch(); break; case SDLK_F10: // Reset emulator ResetComputer (); OOTape->set_pause(true); OOTape->rewind(); break; case SDLK_F11: // lower volume llsound->decrease_volume(); break; case SDLK_F12: // upper volume llsound->increase_volume(); break; } // reorder joystick if screen is rotated if(ordenador->zaurus_mini==2) { switch(temporal_io) { case SDLK_UP: temporal_io=SDLK_LEFT; break; case SDLK_LEFT: temporal_io=SDLK_DOWN; break; case SDLK_DOWN: temporal_io=SDLK_RIGHT; break; case SDLK_RIGHT: temporal_io=SDLK_UP; break; } } // test for joystick switch (temporal_io) { case SDLK_UP: switch (this->joystick) { case 0: // cursor temporal_io = SDLK_7; break; case 1: this->jk = 8; break; case 2: // sinclair 1 temporal_io = SDLK_4; break; case 3: // sinclair 2 temporal_io = SDLK_9; break; } break; case SDLK_DOWN: switch (this->joystick) { case 0: // cursor temporal_io = SDLK_6; break; case 1: this->jk = 4; break; case 2: // sinclair 1 temporal_io = SDLK_3; break; case 3: // sinclair 2 temporal_io = SDLK_8; break; } break; case SDLK_RIGHT: switch (this->joystick) { case 0: // cursor temporal_io = SDLK_8; break; case 1: this->jk = 1; break; case 2: // sinclair 1 temporal_io = SDLK_1; break; case 3: // sinclair 2 temporal_io = SDLK_6; break; } break; case SDLK_LEFT: switch (this->joystick) { case 0: // cursor temporal_io = SDLK_5; break; case 1: this->jk = 2; break; case 2: // sinclair 1 temporal_io = SDLK_2; break; case 3: // sinclair 2 temporal_io = SDLK_7; break; } break; case SDLK_RALT: case SDLK_RMETA: case SDLK_LMETA: case SDLK_RSUPER: case SDLK_LSUPER: case SDLK_MENU: switch (this->joystick) { case 0: // cursor temporal_io = SDLK_0; break; case 1: this->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: this->k15 = 1; break; case SDLK_RCTRL: case SDLK_LCTRL: this->k15 = 2; break; case SDLK_m: this->k15 = 4; break; case SDLK_n: this->k15 = 8; break; case SDLK_b: this->k15 = 16; break; case SDLK_RETURN: this->k14 = 1; break; case SDLK_l: this->k14 = 2; break; case SDLK_k: this->k14 = 4; break; case SDLK_j: this->k14 = 8; break; case SDLK_h: this->k14 = 16; break; case SDLK_p: this->k13 = 1; break; case SDLK_o: this->k13 = 2; break; case SDLK_i: this->k13 = 4; break; case SDLK_u: this->k13 = 8; break; case SDLK_y: this->k13 = 16; break; case SDLK_0: this->k12 = 1; break; case SDLK_9: this->k12 = 2; break; case SDLK_8: this->k12 = 4; break; case SDLK_7: this->k12 = 8; break; case SDLK_6: this->k12 = 16; break; case SDLK_1: this->k11 = 1; break; case SDLK_2: this->k11 = 2; break; case SDLK_3: this->k11 = 4; break; case SDLK_4: this->k11 = 8; break; case SDLK_5: this->k11 = 16; break; case SDLK_q: this->k10 = 1; break; case SDLK_w: this->k10 = 2; break; case SDLK_e: this->k10 = 4; break; case SDLK_r: this->k10 = 8; break; case SDLK_t: this->k10 = 16; break; case SDLK_a: this->k9 = 1; break; case SDLK_s: this->k9 = 2; break; case SDLK_d: this->k9 = 4; break; case SDLK_f: this->k9 = 8; break; case SDLK_g: this->k9 = 16; break; case SDLK_RSHIFT: case SDLK_LSHIFT: this->k8 = 1; break; case SDLK_z: this->k8 = 2; break; case SDLK_x: this->k8 = 4; break; case SDLK_c: this->k8 = 8; break; case SDLK_v: this->k8 = 16; break; case SDLK_BACKSPACE: this->k12 = 1; this->k8 = 1; break; case SDLK_PERIOD: this->k15 = 6; break; case SDLK_COMMA: this->k15 = 10; break; } if (pevento->type == SDL_KEYUP) { this->s8 |= this->k8; this->s9 |= this->k9; this->s10 |= this->k10; this->s11 |= this->k11; this->s12 |= this->k12; this->s13 |= this->k13; this->s14 |= this->k14; this->s15 |= this->k15; this->js &= (this->jk ^ 255); } else { this->s8 &= (this->k8 ^ 255); this->s9 &= (this->k9 ^ 255); this->s10 &= (this->k10 ^ 255); this->s11 &= (this->k11 ^ 255); this->s12 &= (this->k12 ^ 255); this->s13 &= (this->k13 ^ 255); this->s14 &= (this->k14 ^ 255); this->s15 &= (this->k15 ^ 255); this->js |= this->jk; } return; }
void load_snap(struct z80snapshot *snap) { int bucle; switch(snap->type) { case 0: // 48k cmpt.mode128k=0; // 48K mode cmpt.issue=snap->issue; ResetComputer(); break; case 1: // 128k cmpt.mode128k=1; //2; // +2 mode cmpt.issue=3; ResetComputer(); // printf("Pager: %X\n",snap->pager); OutZ80(0x7FFD,snap->pager); break; default: break; } _z80_set_A(snap->A); #ifdef MASCARA_AF _z80_set_F(snap->F&MASCARA_AF); #else _z80_set_F(snap->F); #endif _z80_set_B(snap->B); _z80_set_C(snap->C); _z80_set_D(snap->D); _z80_set_E(snap->E); _z80_set_H(snap->H); _z80_set_L(snap->L); _z80_set_A1(snap->AA); _z80_set_F1(snap->FF); _z80_set_B1(snap->BB); _z80_set_C1(snap->CC); _z80_set_D1(snap->DD); _z80_set_E1(snap->EE); _z80_set_H1(snap->HH); _z80_set_L1(snap->LL); _z80_set_IX(snap->IX); _z80_set_IY(snap->IY); _z80_set_SP(snap->SP); _z80_set_PC(snap->PC); _z80_set_I(snap->I); _z80_set_R(snap->R&0x7F); #ifdef USE_RAZE z80_set_reg(Z80_REG_IFF1,snap->IFF1); z80_set_reg(Z80_REG_IFF2,snap->IFF2); z80_set_reg(Z80_REG_IM,snap->Imode); if (snap->IFF1) z80_set_reg(Z80_REG_IRQLine,1); #else if(snap->IFF1) #ifdef USE_YAZE yaze_IFF|=3; #else procesador.IFF|=(IFF_1|IFF_EI); #endif if(snap->IFF2) #ifdef USE_YAZE yaze_IFF|=2; #else procesador.IFF|=IFF_2; #endif switch(snap->Imode) { case 0: #ifdef USE_YAZE yaze_IFF&=~3; #else procesador.IFF&=~(IFF_IM1|IFF_IM2); #endif break; case 1: #ifdef USE_YAZE yaze_IFF=(yaze_IFF&~2)|1; #else procesador.IFF=(procesador.IFF&~IFF_IM2)|IFF_IM1; #endif break; case 2: #ifdef USE_YAZE yaze_IFF=(yaze_IFF&~1)|2; #else procesador.IFF=(procesador.IFF&~IFF_IM1)|IFF_IM2; #endif break; } #endif cmpt.border=snap->border+16; switch(snap->type) { case 0: // 48K for(bucle=0;bucle<16384;bucle++) { cmpt.memoria[bucle+147456]=snap->page[0][bucle]; cmpt.memoria[bucle+98304]=snap->page[1][bucle]; cmpt.memoria[bucle+114688]=snap->page[2][bucle]; } cmpt.ay_emul=0; break; case 1: // 128K for(bucle=0;bucle<16384;bucle++) { cmpt.memoria[bucle+65536]=snap->page[0][bucle]; cmpt.memoria[bucle+81920]=snap->page[1][bucle]; cmpt.memoria[bucle+98304]=snap->page[2][bucle]; cmpt.memoria[bucle+114688]=snap->page[3][bucle]; cmpt.memoria[bucle+131072]=snap->page[4][bucle]; cmpt.memoria[bucle+147456]=snap->page[5][bucle]; cmpt.memoria[bucle+163840]=snap->page[6][bucle]; cmpt.memoria[bucle+180224]=snap->page[7][bucle]; } cmpt.ay_emul=-1; for(bucle=0;bucle<16;bucle++) cmpt.ay_registers[bucle]=snap->ay_regs[bucle]; cmpt.ay_latch=snap->ay_latch; break; default: break; } setChanges(); }