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