From 66f44817604f4fc3d8be6f45b4e903a361a71e88 Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sat, 9 Mar 2013 10:00:42 +0000 Subject: [PATCH] Stop in instant load --- src/computer.c | 27 +++++++++++++++++++-------- src/computer.h | 2 ++ src/emulator.c | 2 +- src/gui_sdl.c | 8 ++++++-- src/menus.c | 12 ++++++++---- src/tape.c | 14 +++++++++++--- 6 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/computer.c b/src/computer.c index 95d3670..91452b5 100644 --- a/src/computer.c +++ b/src/computer.c @@ -117,6 +117,8 @@ void computer_init () { //Called only on start-up ordenador.tape_readed = 0; ordenador.tape_stop = 1; // tape stop + ordenador.tape_stop_fast = 1; // tape stop + ordenador.stop_tape_start_countdown =0; ordenador.tape_fast_load = 1; // fast load by default ordenador.rewind_on_reset = 1; //Rewound on reset by default ordenador.pause_instant_load = 0; @@ -562,7 +564,7 @@ inline void show_screen (int tstados) { if ((ordenador.turbo_state == 0) || (curr_frames%7 == 0)) ordenador.readkeyboard = 1; curr_frames++; if (ordenador.tape_start_countdwn==1) ordenador.tape_stop=0; //Autoplay - if (ordenador.tape_start_countdwn>0) ordenador.tape_start_countdwn--; + if ((ordenador.tape_start_countdwn>0)&&(ordenador.stop_tape_start_countdown ==0)) ordenador.tape_start_countdwn--; if (ordenador.pause_fastload_countdwn>0) ordenador.pause_fastload_countdwn--; } return; @@ -668,7 +670,7 @@ inline void show_screen (int tstados) { if (ordenador.tape_start_countdwn==1) ordenador.tape_stop=0; //Autoplay - if (ordenador.tape_start_countdwn>0) ordenador.tape_start_countdwn--; + if ((ordenador.tape_start_countdwn>0)&&(ordenador.stop_tape_start_countdown ==0)) ordenador.tape_start_countdwn--; if (ordenador.pause_fastload_countdwn>0) ordenador.pause_fastload_countdwn--; if (ordenador.mustlock) { @@ -711,7 +713,7 @@ inline void show_screen_precision (int tstados) { ordenador.readkeyboard = 1; curr_frames++; if (ordenador.tape_start_countdwn==1) ordenador.tape_stop=0; //Autoplay - if (ordenador.tape_start_countdwn>0) ordenador.tape_start_countdwn--; + if ((ordenador.tape_start_countdwn>0)&&(ordenador.stop_tape_start_countdown ==0)) ordenador.tape_start_countdwn--; if (ordenador.pause_fastload_countdwn>0) ordenador.pause_fastload_countdwn--; } //if (ordenador.tstados_counter > 31) ordenador.interr = 0; @@ -915,7 +917,7 @@ inline void show_screen_precision (int tstados) { if (ordenador.tape_start_countdwn==1) ordenador.tape_stop=0; //Autoplay - if (ordenador.tape_start_countdwn>0) ordenador.tape_start_countdwn--; + if ((ordenador.tape_start_countdwn>0)&&(ordenador.stop_tape_start_countdown ==0)) ordenador.tape_start_countdwn--; if (ordenador.pause_fastload_countdwn>0) ordenador.pause_fastload_countdwn--; if (ordenador.mustlock) { @@ -1244,12 +1246,15 @@ inline void read_keyboard () { case SDLK_F5: // STOP tape //if ((ordenador.tape_fast_load == 0)) ordenador.tape_stop = 1; - ordenador.tape_start_countdwn=0; + ordenador.tape_stop_fast = 1; + ordenador.stop_tape_start_countdown = 1; break; case SDLK_F6: // PLAY tape - //if (ordenador.tape_fast_load == 0) + if (ordenador.tape_fast_load == 0) ordenador.tape_stop = 0; + ordenador.tape_stop_fast = 0; + ordenador.stop_tape_start_countdown = 0; break; case SDLK_F9: @@ -1552,8 +1557,12 @@ inline void read_keyboard () { ordenador.s15 = (ordenador.s15 & 0xE0)| (ordenador.k15 ^ 0x1F); ordenador.js = ordenador.jk; - if (joybutton_matrix[0][SDLK_F6] && (ordenador.tape_fast_load == 0)) - ordenador.tape_stop = 0; //Play the tape + if (joybutton_matrix[0][SDLK_F6]) //Play the tape + { + ordenador.tape_stop_fast = 0; + if (ordenador.tape_fast_load == 0) ordenador.tape_stop = 0; + ordenador.stop_tape_start_countdown = 0; + } //Virtual Keyboard @@ -1707,6 +1716,8 @@ void ResetComputer () { microdrive_reset(); ordenador.tape_stop = 1; + ordenador.tape_stop_fast = 1; + ordenador.stop_tape_start_countdown = 0; if (ordenador.rewind_on_reset) { diff --git a/src/computer.h b/src/computer.h index 2778621..354df1b 100644 --- a/src/computer.h +++ b/src/computer.h @@ -168,6 +168,8 @@ struct computer { enum tapmodes tape_current_mode; enum block_type next_block; unsigned char tape_stop; // 1=tape stop + unsigned char tape_stop_fast; // 1=tape stop + unsigned char stop_tape_start_countdown; // 1=tape stop start countdown enum taptypes tape_file_type; unsigned int tape_counter0; unsigned int tape_counter1; diff --git a/src/emulator.c b/src/emulator.c index 5166b0c..ed4dc97 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -1546,7 +1546,7 @@ int main(int argc,char *argv[]) { /* if PC is 0x056c, a call to LD_BYTES has been made, so if FAST_LOAD is 1, we must load the block in memory and return */ - if((!ordenador.mdr_paged)&&(PC==0x056c) && (ordenador.tape_fast_load==1)) { + if((!ordenador.mdr_paged)&&(PC==0x056c) && (ordenador.tape_fast_load==1)&&(ordenador.tape_stop_fast == 0)) { if (ordenador.tap_file!=NULL) { if (ordenador.pause_fastload_countdwn==0) diff --git a/src/gui_sdl.c b/src/gui_sdl.c index 9a6c131..18e2bf0 100644 --- a/src/gui_sdl.c +++ b/src/gui_sdl.c @@ -439,18 +439,22 @@ static int manage_tape(int which) retorno=-1; break; case 2: //Play - //if (ordenador.tape_fast_load == 0) + if (ordenador.tape_fast_load == 0) ordenador.tape_stop = 0; + ordenador.tape_stop_fast = 0; + ordenador.stop_tape_start_countdown = 0; retorno=-1; break; case 3: //Stop //if (ordenador.tape_fast_load == 0) ordenador.tape_stop = 1; - ordenador.tape_start_countdwn=0; + ordenador.tape_stop_fast = 1; + ordenador.stop_tape_start_countdown = 1; retorno=-1; break; case 4: //Rewind ordenador.tape_stop=1; + ordenador.tape_stop_fast = 1; ordenador.tape_start_countdwn=0; if(ordenador.tap_file!=NULL) { ordenador.tape_current_mode=TAP_TRASH; diff --git a/src/menus.c b/src/menus.c index c490995..9100bd0 100644 --- a/src/menus.c +++ b/src/menus.c @@ -631,13 +631,16 @@ void taps_menu() { case SDLK_ESCAPE: // to exit the help fin=0; break; - case SDLK_1: - //ordenador.tape_stop=1; + case SDLK_1: //select tape + ordenador.tape_stop=1; + ordenador.tape_stop_fast = 1; + ordenador.tape_start_countdwn=0; select_tapfile(); break; - case SDLK_2: + case SDLK_2: //rewind tape fin=0; ordenador.tape_stop=1; + ordenador.tape_stop_fast = 1; ordenador.tape_start_countdwn=0; if(ordenador.tap_file!=NULL) { ordenador.tape_current_mode=TAP_TRASH; @@ -646,8 +649,9 @@ void taps_menu() { sprintf(ordenador.osd_text,"Tape rewound"); ordenador.osd_time=50; break; - case SDLK_3: + case SDLK_3: //Instant load settings ordenador.tape_stop=1; + ordenador.tape_stop_fast = 1; ordenador.tape_start_countdwn=0; ordenador.tape_fast_load=1-ordenador.tape_fast_load; if(ordenador.tap_file!=NULL) { diff --git a/src/tape.c b/src/tape.c index f128f2c..6f66f79 100644 --- a/src/tape.c +++ b/src/tape.c @@ -83,6 +83,7 @@ inline void tape_read_tap (FILE * fichero, int tstados) { sprintf (ordenador.osd_text, "No tape selected"); ordenador.osd_time = 100; ordenador.tape_stop=1; //Stop the tape + ordenador.tape_stop_fast=1; //Stop the tape return; } @@ -189,6 +190,7 @@ inline void tape_read_tap (FILE * fichero, int tstados) { case TAP_STOP: ordenador.tape_current_mode = TAP_TRASH; // initialize ordenador.tape_stop = 1; // pause it + ordenador.tape_stop_fast = 1; // pause it break; default: break; @@ -209,6 +211,7 @@ inline void tape_read_tzx (FILE * fichero, int tstados) { sprintf (ordenador.osd_text, "No tape selected"); ordenador.osd_time = 100; ordenador.tape_stop=1; //Stop the tape + ordenador.tape_stop_fast = 1; // pause it return; } @@ -445,7 +448,7 @@ inline void tape_read_tzx (FILE * fichero, int tstados) { retval=fread(&value,1,1,fichero); if(ordenador.mode128k==0) { ordenador.tape_stop = 1; - ordenador.tape_start_countdwn=0; + ordenador.tape_stop_fast = 1; // pause it return; } break; @@ -633,6 +636,7 @@ inline void tape_read_tzx (FILE * fichero, int tstados) { ordenador.tape_current_mode = TAP_TRASH; // read new block ordenador.next_block= NOBLOCK; ordenador.tape_stop = 1; + ordenador.tape_stop_fast = 1; // pause it } break; case TZX_PURE_TONE: @@ -663,6 +667,7 @@ inline void tape_read_tzx (FILE * fichero, int tstados) { ordenador.tape_current_mode = TAP_TRASH; // initialize ordenador.next_block= NOBLOCK; ordenador.tape_stop = 1; // pause it + ordenador.tape_stop_fast = 1; // pause it break; default: break; @@ -681,6 +686,7 @@ void rewind_tape(FILE *fichero,unsigned char pause) { retval=fread(&value,1,1,ordenador.tap_file); // jump over the header ordenador.next_block= NOBLOCK; ordenador.tape_stop=pause; + ordenador.tape_stop_fast=pause; if (pause) ordenador.tape_start_countdwn=0; //Stop tape play countdown } @@ -1044,7 +1050,9 @@ void fastload_block_tzx (FILE * fichero) { break; case 0x2A: // pause if 48K - retorno=2; + ordenador.tape_stop_fast=1; + fseek(fichero, byte_position, SEEK_SET); + return; break; case 0x30: // text description @@ -1107,7 +1115,7 @@ void fastload_block_tzx (FILE * fichero) { if (retorno==2) { fseek(fichero, byte_position, SEEK_SET); - ordenador.tape_stop=1; //Start the tape + ordenador.tape_stop=0; //Start the tape return; }