Commit 490ce4b3 authored by Sergio Costas's avatar Sergio Costas

More clean of unused variables and more code moved inside its class

parent c534fc47
...@@ -51,21 +51,21 @@ void emulate (int tstados) { ...@@ -51,21 +51,21 @@ void emulate (int tstados) {
if((procesador.I>=0x40)&&(procesador.I<=0x7F)) { if((procesador.I>=0x40)&&(procesador.I<=0x7F)) {
ordenador.screen_snow=1; ordenador.screen_snow=1;
} else } else {
ordenador.screen_snow=0; ordenador.screen_snow=0;
}
show_screen (tstados); show_screen (tstados);
play_ay (tstados); play_ay (tstados);
play_sound (tstados); play_sound (tstados);
//tape_read (ordenador.tap_file, tstados);
ordenador.OOTape.play(tstados); ordenador.OOTape.play(tstados);
ordenador.tape_readed = (ordenador.OOTape.read_signal() == 0) ? 0 : 1;
microdrive_emulate(tstados); microdrive_emulate(tstados);
if (!ordenador.pause) {
if (ordenador.tape_readed) if (!ordenador.OOTape.get_pause()) {
if (ordenador.OOTape.read_signal() != 0) {
ordenador.sound_bit = 1; ordenador.sound_bit = 1;
else } else {
ordenador.sound_bit = 0; // if not paused, asign SOUND_BIT the value of tape ordenador.sound_bit = 0; // if not paused, asign SOUND_BIT the value of tape
}
} }
} }
...@@ -80,10 +80,7 @@ void computer_init () { ...@@ -80,10 +80,7 @@ void computer_init () {
ordenador.mode128k = 0; ordenador.mode128k = 0;
ordenador.joystick = 0; ordenador.joystick = 0;
ordenador.tape_readed = 0;
ordenador.pause = 1; // tape stop
ordenador.tape_fast_load = 1; // fast load by default ordenador.tape_fast_load = 1; // fast load by default
ordenador.tape_current_mode = TAP_TRASH;
ordenador.tap_file = NULL; ordenador.tap_file = NULL;
ordenador.osd_text[0] = 0; ordenador.osd_text[0] = 0;
...@@ -119,15 +116,13 @@ void computer_init () { ...@@ -119,15 +116,13 @@ void computer_init () {
ordenador.ayval_n = 0; ordenador.ayval_n = 0;
ordenador.ay_envel_value = 0; ordenador.ay_envel_value = 0;
ordenador.ay_envel_way = 0; ordenador.ay_envel_way = 0;
ordenador.tape_loop_counter = 0;
} }
/* Registers the screen surface where the Spectrum will put the picture, /* Registers the screen surface where the Spectrum will put the picture,
prepares the palette and creates two arrays (translate and translate2) prepares the palette and creates two arrays (translate and translate2)
that gives the memory address for each scan */ that gives the memory address for each scan */
void register_screen (SDL_Surface * pantalla) { void register_screen () {
//int resx,resy; //int resx,resy;
int bucle, bucle2, bucle3, bucle4, bucle5; int bucle, bucle2, bucle3, bucle4, bucle5;
...@@ -213,7 +208,8 @@ void register_screen (SDL_Surface * pantalla) { ...@@ -213,7 +208,8 @@ void register_screen (SDL_Surface * pantalla) {
llscreen->set_paletes(ordenador.bw); llscreen->set_paletes(ordenador.bw);
ordenador.pixel = ((unsigned char *) (pantalla->pixels)) + ordenador.init_line; ordenador.base_pixel = ((unsigned char *) (llscreen->llscreen->pixels));
ordenador.pixel = ordenador.base_pixel + ordenador.init_line;
ordenador.interr = 0; ordenador.interr = 0;
ordenador.p_translt = ordenador.translate; ordenador.p_translt = ordenador.translate;
...@@ -440,7 +436,7 @@ void show_screen (int tstados) { ...@@ -440,7 +436,7 @@ void show_screen (int tstados) {
ordenador.currline = 0; ordenador.currline = 0;
ordenador.interr = 1; ordenador.interr = 1;
ordenador.cicles_counter=0; ordenador.cicles_counter=0;
ordenador.pixel = ((unsigned char *) (llscreen->screen->pixels))+ordenador.init_line; // +ordenador.init_line; ordenador.pixel = ordenador.base_pixel+ordenador.init_line;
ordenador.p_translt = ordenador.translate; ordenador.p_translt = ordenador.translate;
ordenador.p_translt2 = ordenador.translate2; ordenador.p_translt2 = ordenador.translate2;
ordenador.contador_flash++; ordenador.contador_flash++;
...@@ -656,12 +652,10 @@ void read_keyboard (SDL_Event *pevento2) { ...@@ -656,12 +652,10 @@ void read_keyboard (SDL_Event *pevento2) {
break; break;
case SDLK_F5: // STOP tape case SDLK_F5: // STOP tape
ordenador.pause = 1;
ordenador.OOTape.set_pause(true); ordenador.OOTape.set_pause(true);
break; break;
case SDLK_F6: // PLAY tape case SDLK_F6: // PLAY tape
ordenador.pause = 0;
ordenador.OOTape.set_pause(false); ordenador.OOTape.set_pause(false);
break; break;
...@@ -671,11 +665,8 @@ void read_keyboard (SDL_Event *pevento2) { ...@@ -671,11 +665,8 @@ void read_keyboard (SDL_Event *pevento2) {
case SDLK_F10: // Reset emulator case SDLK_F10: // Reset emulator
ResetComputer (); ResetComputer ();
ordenador.pause = 1; ordenador.OOTape.set_pause(true);
if (ordenador.tap_file != NULL) { ordenador.OOTape.rewind();
ordenador.tape_current_mode = TAP_TRASH;
ordenador.OOTape.rewind();
}
break; break;
case SDLK_F11: // lower volume case SDLK_F11: // lower volume
...@@ -1214,7 +1205,7 @@ void Z80free_Out (register word Port, register byte Value) { ...@@ -1214,7 +1205,7 @@ void Z80free_Out (register word Port, register byte Value) {
ordenador.port254 = (unsigned char) Value; ordenador.port254 = (unsigned char) Value;
ordenador.border = (((unsigned char) Value) & 0x07); ordenador.border = (((unsigned char) Value) & 0x07);
if (ordenador.pause) { if (ordenador.OOTape.get_pause()) {
if (Value & 0x10) if (Value & 0x10)
ordenador.sound_bit = 1; ordenador.sound_bit = 1;
else else
...@@ -1293,7 +1284,7 @@ byte Z80free_In (register word Port) { ...@@ -1293,7 +1284,7 @@ byte Z80free_In (register word Port) {
if (!(temporal_io & 0x8000)) if (!(temporal_io & 0x8000))
pines &= ordenador.s15; pines &= ordenador.s15;
if (ordenador.pause) { if (ordenador.OOTape.get_pause()) {
if (ordenador.issue == 2) { if (ordenador.issue == 2) {
if (ordenador.port254 & 0x18) if (ordenador.port254 & 0x18)
pines |= 0x40; pines |= 0x40;
......
...@@ -40,12 +40,8 @@ struct computer { ...@@ -40,12 +40,8 @@ struct computer {
unsigned int temporal_io; unsigned int temporal_io;
// screen private global variables // screen private global variables
//SDL_Surface *screen;
unsigned char *screenbuffer;
unsigned int screen_width;
unsigned int translate[6144],translate2[6144]; unsigned int translate[6144],translate2[6144];
unsigned char zaurus_mini; unsigned char zaurus_mini;
unsigned char text_mini;
unsigned char dblscan; unsigned char dblscan;
unsigned char bw; unsigned char bw;
...@@ -53,6 +49,7 @@ struct computer { ...@@ -53,6 +49,7 @@ struct computer {
unsigned int *p_translt,*p_translt2; unsigned int *p_translt,*p_translt2;
unsigned char *pixel; // current address unsigned char *pixel; // current address
unsigned char *base_pixel;
char border,flash; char border,flash;
int currline,currpix; int currline,currpix;
...@@ -89,7 +86,6 @@ struct computer { ...@@ -89,7 +86,6 @@ struct computer {
// Linux joystick private global variables // Linux joystick private global variables
unsigned char use_js;
unsigned char updown,leftright; unsigned char updown,leftright;
// sound global variables // sound global variables
...@@ -134,31 +130,9 @@ struct computer { ...@@ -134,31 +130,9 @@ struct computer {
// tape global variables // tape global variables
enum tapmodes tape_current_mode;
unsigned char pause; // 1=tape stop
enum taptypes tape_file_type;
unsigned int tape_counter0;
unsigned int tape_counter1;
unsigned int tape_counter_rep;
unsigned char tape_byte;
unsigned char tape_bit;
unsigned char tape_readed;
unsigned int tape_byte_counter;
unsigned int tape_pause_at_end;
FILE *tap_file; FILE *tap_file;
unsigned char tape_fast_load; // 0 normal load; 1 fast load unsigned char tape_fast_load; // 0 normal load; 1 fast load
char current_tap[2049]; char current_tap[2049];
unsigned char tape_current_bit;
unsigned int tape_block_level;
unsigned int tape_sync_level0;
unsigned int tape_sync_level1;
unsigned int tape_bit0_level;
unsigned int tape_bit1_level;
unsigned char tape_bits_at_end;
unsigned int tape_loop_counter;
long tape_loop_pos;
unsigned char tape_write; // 0 can't write; 1 can write unsigned char tape_write; // 0 can't write; 1 can write
// Microdrive global variables // Microdrive global variables
...@@ -202,7 +176,7 @@ struct computer { ...@@ -202,7 +176,7 @@ struct computer {
}; };
void computer_init(); void computer_init();
void register_screen(SDL_Surface *); void register_screen();
void show_screen(int); void show_screen(int);
void paint_pixels(unsigned char, unsigned char, unsigned char); void paint_pixels(unsigned char, unsigned char, unsigned char);
void read_keyboard(SDL_Event *pevento2); void read_keyboard(SDL_Event *pevento2);
......
...@@ -219,13 +219,10 @@ void end_system() { ...@@ -219,13 +219,10 @@ void end_system() {
sound_close(); sound_close();
if(ordenador.mustlock) delete(llscreen);
SDL_UnlockSurface(llscreen->screen);
if(ordenador.tap_file!=NULL) if(ordenador.tap_file!=NULL)
fclose(ordenador.tap_file); fclose(ordenador.tap_file);
SDL_Quit();
} }
void load_main_game(char *nombre) { void load_main_game(char *nombre) {
...@@ -541,7 +538,7 @@ int main(int argc,char *argv[]) { ...@@ -541,7 +538,7 @@ int main(int argc,char *argv[]) {
} }
init_sound(); init_sound();
printf("Modo: %d\n",ordenador.mode128k); printf("Modo: %d\n",ordenador.mode128k);
register_screen(llscreen->screen); register_screen();
printf("Screen registered\n"); printf("Screen registered\n");
printf("Modo: %d\n",ordenador.mode128k); printf("Modo: %d\n",ordenador.mode128k);
if(fullscreen) { if(fullscreen) {
...@@ -550,9 +547,6 @@ int main(int argc,char *argv[]) { ...@@ -550,9 +547,6 @@ int main(int argc,char *argv[]) {
SDL_WM_SetCaption("FBZX",""); SDL_WM_SetCaption("FBZX","");
ordenador.interr=0; ordenador.interr=0;
ordenador.screenbuffer=(unsigned char *)llscreen->screen->pixels;
ordenador.screen_width=llscreen->screen->w;
// assign initial values for PATH variables // assign initial values for PATH variables
strcpy(path_snaps,getenv("HOME")); strcpy(path_snaps,getenv("HOME"));
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
extern char debug_var; extern char debug_var;
//extern SDL_Surface *screen;
extern Z80FREE procesador; extern Z80FREE procesador;
extern struct computer ordenador; extern struct computer ordenador;
extern unsigned char *sound[NUM_SNDBUF]; extern unsigned char *sound[NUM_SNDBUF];
......
...@@ -608,28 +608,20 @@ void taps_menu() { ...@@ -608,28 +608,20 @@ void taps_menu() {
fin=0; fin=0;
break; break;
case SDLK_1: case SDLK_1:
ordenador.pause=1; ordenador.OOTape.set_pause(true);
select_tapfile(); select_tapfile();
ordenador.OOTape.rewind();
break; break;
case SDLK_2: case SDLK_2:
fin=0; fin=0;
ordenador.pause=1; ordenador.OOTape.set_pause(true);
if(ordenador.tap_file!=NULL) { ordenador.OOTape.rewind();
ordenador.tape_current_mode=TAP_TRASH;
ordenador.OOTape.rewind();
//rewind_tape(ordenador.tap_file,1);
}
sprintf(ordenador.osd_text,"Tape rewinded"); sprintf(ordenador.osd_text,"Tape rewinded");
ordenador.osd_time=50; ordenador.osd_time=50;
break; break;
case SDLK_3: case SDLK_3:
ordenador.pause=1; ordenador.OOTape.set_pause(true);
ordenador.tape_fast_load=1-ordenador.tape_fast_load; ordenador.tape_fast_load = 1-ordenador.tape_fast_load;
if(ordenador.tap_file!=NULL) {
/*ordenador.tape_current_mode=TAP_TRASH;
rewind_tape(ordenador.tap_file,1);*/
ordenador.OOTape.rewind();
}
break; break;
case SDLK_4: case SDLK_4:
ordenador.tape_write=1-ordenador.tape_write; ordenador.tape_write=1-ordenador.tape_write;
...@@ -661,9 +653,6 @@ void select_tapfile() { ...@@ -661,9 +653,6 @@ void select_tapfile() {
rewind_tape(ordenador.tap_file,1); rewind_tape(ordenador.tap_file,1);
}*/ }*/
ordenador.tape_current_bit=0;
ordenador.tape_current_mode=TAP_TRASH;
llscreen->print_string("Choose the TAPE file to load",-1,32,13,0); llscreen->print_string("Choose the TAPE file to load",-1,32,13,0);
filename=select_file(path_taps,FILETYPE_TAP_TZX); filename=select_file(path_taps,FILETYPE_TAP_TZX);
...@@ -754,7 +743,6 @@ void create_tapfile() { ...@@ -754,7 +743,6 @@ void create_tapfile() {
} }
ordenador.tape_write=1; // allow to write ordenador.tape_write=1; // allow to write
strcpy(ordenador.current_tap,nombre2); strcpy(ordenador.current_tap,nombre2);
ordenador.tape_file_type = TAP_TAP;
switch(retorno) { switch(retorno) {
case 0: case 0:
break; break;
...@@ -1791,7 +1779,7 @@ unsigned int wait_key() { ...@@ -1791,7 +1779,7 @@ unsigned int wait_key() {
fin=1; fin=1;
do { do {
SDL_Flip(llscreen->screen); llscreen->do_flip();
if(!SDL_WaitEvent(&evento)) if(!SDL_WaitEvent(&evento))
continue; continue;
......
...@@ -617,6 +617,10 @@ void Tape::set_pause(bool pause) { ...@@ -617,6 +617,10 @@ void Tape::set_pause(bool pause) {
this->paused = pause; this->paused = pause;
} }
bool Tape::get_pause() {
return this->paused;
}
enum FastLoadReturn Tape::fast_read(uint8_t *data, uint16_t &length,uint8_t flag) { enum FastLoadReturn Tape::fast_read(uint8_t *data, uint16_t &length,uint8_t flag) {
uint8_t block_flag; uint8_t block_flag;
......
...@@ -83,6 +83,12 @@ public: ...@@ -83,6 +83,12 @@ public:
* @param pause TRUE to pause the tape, FALSE to release it * @param pause TRUE to pause the tape, FALSE to release it
*/ */
void set_pause(bool pause); void set_pause(bool pause);
/**
* Returns whether the tape is paused or not
* @return TRUE if paused; FALSE if not paused
*/
bool get_pause();
/** /**
* Reads the current signal being "emited" by the tape. * Reads the current signal being "emited" by the tape.
* @return the current signal value, which can be 0 or 1. * @return the current signal value, which can be 0 or 1.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment