diff --git a/spectrum-roms/opense.rom b/spectrum-roms/opense.rom new file mode 100644 index 0000000..267b78d Binary files /dev/null and b/spectrum-roms/opense.rom differ diff --git a/src/computer.c b/src/computer.c index c25e0fa..d0254c2 100644 --- a/src/computer.c +++ b/src/computer.c @@ -557,7 +557,7 @@ void register_screen (SDL_Surface * pantalla) { ordenador.tstados_counter_sound = 0; ordenador.current_buffer = sound[0]; - ordenador.num_buff = 0; // first buffer + //ordenador.num_buff = 0; // first buffer ordenador.sound_cuantity = 0; //ordenador.sound_current_value = 0; @@ -1190,6 +1190,7 @@ inline void paint_one_pixel(unsigned char *colour,unsigned char *address ) { inline void read_keyboard () { unsigned int temporal_io; + unsigned char model128k; SDL_Event evento,*pevento; enum joystate_x {JOY_CENTER_X, JOY_LEFT, JOY_RIGHT}; enum joystate_y {JOY_CENTER_Y, JOY_UP, JOY_DOWN}; @@ -1346,7 +1347,15 @@ inline void read_keyboard () { case SDLK_F9: //Emulate load "" countdown_buffer=8; - switch (ordenador.mode128k) + model128k = ordenador.mode128k; + + if ((ordenador.mport1 & 0x10)&&(ordenador.mode128k!=4)) //ROM 48k + model128k =0; + + if ((ordenador.mode128k==0)&&(ordenador.se_basic)) + model128k =4; + + switch (model128k) { case 4://Spanish 128k ordenador.keyboard_buffer[0][8]= SDLK_l; @@ -1371,16 +1380,6 @@ inline void read_keyboard () { case 2: //+2 case 1: //128k ordenador.kbd_buffer_pointer=2; - if (ordenador.mport1 & 0x10) //ROM 48k - { - 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.kbd_buffer_pointer=5; - } ordenador.keyboard_buffer[0][2]= SDLK_RETURN; // Return ordenador.keyboard_buffer[1][2]= 0; ordenador.keyboard_buffer[0][1]= SDLK_F6; //F6 - play diff --git a/src/computer.h b/src/computer.h index 28a7b45..aae1a8f 100644 --- a/src/computer.h +++ b/src/computer.h @@ -133,7 +133,7 @@ struct computer { unsigned char sound_bit_mic; unsigned int tstados_counter_sound; unsigned int *current_buffer; - unsigned char num_buff; + //unsigned char num_buff; unsigned int sound_cuantity; // counter for the buffer unsigned char ay_registers[16]; // registers for the AY emulation unsigned int aych_a,aych_b,aych_c,aych_n,aych_envel; // counters for AY emulation @@ -162,6 +162,7 @@ struct computer { unsigned char issue; // 2= 48K issue 2, 3= 48K issue 3 unsigned char mode128k; // 0=48K, 1=128K, 2=+2, 3=+3 4=sp unsigned char videosystem; //0=PAL, 1=NTSC + unsigned char se_basic; //0=0ff; 1=0n unsigned char joystick[2]; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2, 4=Fuller, 5=QAOP unsigned char port254; diff --git a/src/emulator.c b/src/emulator.c index a1174f4..4c5baa6 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -394,7 +394,7 @@ void load_rom(char type) { switch(type) { case 0: - filenames[0]="spectrum-roms/48.rom"; + if (ordenador.se_basic) filenames[0]="spectrum-roms/opense.rom"; else filenames[0]="spectrum-roms/48.rom"; filenames[1]=NULL; if (rom_cartridge[0]) retval = load_rom_cartridge(); else retval=load_a_rom(filenames); if (retval) { @@ -761,6 +761,7 @@ int save_config(struct computer *object, char *filename) { fprintf(fconfig,"mode=%c%c",48+object->mode128k,10); fprintf(fconfig,"issue=%c%c",48+object->issue,10); fprintf(fconfig,"ntsc=%c%c",48+object->videosystem,10); + fprintf(fconfig,"se_basic=%c%c",48+object->se_basic,10); fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10); fprintf(fconfig,"joystick2=%c%c",48+object->joystick[1],10); fprintf(fconfig,"ay_sound=%c%c",48+object->ay_emul,10); @@ -956,7 +957,7 @@ int load_config(struct computer *object, char *filename) { 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, joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255, turbo=225, vk_auto=255, vk_rumble=255, - rewind_on_reset=255, pause_instant_load =255, ignore_z80_joy_conf=255, gui_sound=255, fuller_box_sound=255, currah_active = 255; + rewind_on_reset=255, pause_instant_load =255, ignore_z80_joy_conf=255, gui_sound=255, fuller_box_sound=255, currah_active = 255, se_basic =255; if (filename) strcpy(config_path,filename); else return -2; @@ -1002,6 +1003,10 @@ int load_config(struct computer *object, char *filename) { ntsc=line[5]-'0'; continue; } + if (!strncmp(line,"se_basic=",9)) { + se_basic=line[9]-'0'; + continue; + } if (!strncmp(line,"joystick1=",10)) { joystick1=line[10]-'0'; continue; @@ -1131,6 +1136,9 @@ int load_config(struct computer *object, char *filename) { if (ntsc<2) { object->videosystem=ntsc; } + if (se_basic<2) { + object->se_basic=se_basic; + } if (joystick1<6) { object->joystick[0]=joystick1; } diff --git a/src/gui_sdl.c b/src/gui_sdl.c index 087caf3..7373d00 100644 --- a/src/gui_sdl.c +++ b/src/gui_sdl.c @@ -87,11 +87,14 @@ static const char *emulation_messages[] = { /*03*/ "48K model", /*04*/ "^|issue2|issue3", /*05*/ " ", - /*06*/ "Frame rate", - /*07*/ "^|100%|50%|33%|25%|20%", - /*08*/ " ", - /*09*/ "Precision", - /*10*/ "^|on|off", + /*06*/ "Open SE Basic", + /*07*/ "^|on|off", + /*08*/ " ", + /*09*/ "Frame rate", + /*10*/ "^|100%|50%|33%|25%|20%", + /*11*/ " ", + /*12*/ "Precision", + /*13*/ "^|on|off", NULL }; @@ -427,6 +430,7 @@ void create_tapfile_sdl() { static int manage_tape(int which) { int retorno=0; //Stay in menu as default + unsigned char model128k; switch (which) { case 0: //Insert @@ -434,7 +438,15 @@ static int manage_tape(int which) break; case 1: //Emulate load "" countdown_buffer=8; - switch (ordenador.mode128k) + model128k = ordenador.mode128k; + + if ((ordenador.mport1 & 0x10)&&(ordenador.mode128k!=4)) //ROM 48k + model128k =0; + + if ((ordenador.mode128k==0)&&(ordenador.se_basic)) + model128k =4; + + switch (model128k) { case 4://Spanish 128k ordenador.keyboard_buffer[0][8]= SDLK_l; @@ -459,16 +471,6 @@ static int manage_tape(int which) case 2: //+2 case 1: //128k ordenador.kbd_buffer_pointer=2; - if (ordenador.mport1 & 0x10) //ROM 48k - { - 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.kbd_buffer_pointer=5; - } ordenador.keyboard_buffer[0][2]= SDLK_RETURN; // Return ordenador.keyboard_buffer[1][2]= 0; ordenador.keyboard_buffer[0][1]= SDLK_F6; //F6 - play @@ -588,7 +590,7 @@ static void set_machine_model(int which) static int emulation_settings(void) { - unsigned int submenus[4],submenus_old[4]; + unsigned int submenus[5],submenus_old[5]; int opt, i, retorno; unsigned char old_mode, old_videosystem; @@ -598,10 +600,11 @@ static int emulation_settings(void) submenus[0] = get_machine_model(); submenus[1] = ordenador.issue-2; - submenus[2] = jump_frames; - submenus[3] = !ordenador.precision; + submenus[2] = !ordenador.se_basic; + submenus[3] = jump_frames; + submenus[4] = !ordenador.precision; - for (i=0; i<4; i++) submenus_old[i] = submenus[i]; + for (i=0; i<5; i++) submenus_old[i] = submenus[i]; old_mode=ordenador.mode128k; old_videosystem = ordenador.videosystem; @@ -617,11 +620,15 @@ static int emulation_settings(void) if (ordenador.mode128k==0) ordenador.issue= submenus[1]+2; else ordenador.issue = 3; - jump_frames = submenus[2]; + ordenador.se_basic = !submenus[2]; - if (submenus[3] != submenus_old[3]) + if (submenus[2]!=submenus_old[2]) {ResetComputer ();retorno=-2;} + + jump_frames = submenus[3]; + + if (submenus[3] != submenus_old[4]) { - ordenador.precision = !submenus[3]; + ordenador.precision = !submenus[4]; ordenador.precision_old=ordenador.precision; if (ordenador.turbo_state!=1) //Tape is not loading with auto mode if (ordenador.precision) @@ -996,6 +1003,9 @@ void load_mdr_file(void) if ((ordenador.mport1 & 0x10)&&(ordenador.mode128k!=4)) //ROM 48k model128k =0; + if ((ordenador.mode128k==0)&&(ordenador.se_basic)) + model128k =4; + //Emulate load *"m";1;"run" countdown_buffer=8; ordenador.kbd_buffer_pointer=17; @@ -1934,7 +1944,7 @@ static void save_load_general_configurations(int which) { int retorno; - unsigned char old_bw,old_mode, old_currah; + unsigned char old_bw,old_mode, old_currah, old_se_basic; char config_path[MAX_PATH_LENGTH]; int length; FILE *fconfig; @@ -1963,10 +1973,12 @@ static void save_load_general_configurations(int which) old_bw = ordenador.bw; old_mode= ordenador.mode128k; old_currah = ordenador.currah_active; + old_se_basic = ordenador.se_basic; if (!load_config(&ordenador,config_path)) msgInfo("General confs loaded",3000,NULL); if (old_bw!=ordenador.bw) computer_set_palete(); if (ordenador.currah_rom_unavailable) ordenador.currah_active =0; - if ((old_mode != ordenador.mode128k)||(old_currah != ordenador.currah_active)) ResetComputer(); + if ((old_mode != ordenador.mode128k)||(old_currah != ordenador.currah_active)|| + (old_se_basic != ordenador.se_basic)) ResetComputer(); break; } else // Delete config file