Commit ef0c596e authored by Sergio Costas's avatar Sergio Costas

Now allows to run in TURBO mode when the tape is playing, and return to NORMAL...

Now allows to run in TURBO mode when the tape is playing, and return to NORMAL mode when the tape is paused

Moved spk_ay to its own class
parent a3f65fe1
2.99.1
*Now allows to run in TURBO mode when the tape is playing, and return to NORMAL mode when the tape is paused
*More C++ refactoring
2.99.0
*Refactor in C++
*Allows to use fast-load with some parts of TZX files too
......
......@@ -51,9 +51,10 @@ computer::computer() {
this->issue = 3;
this->mode128k = 0;
this->turbo = false;
this->turbo_play = true;
this->tape_write = false;
this->tape_fast_load = true; // fast load by default
this->tape_fast_load = false; // don't fast load by default
this->other_ret = 0;
......
......@@ -89,6 +89,7 @@ public:
unsigned char other_ret; // 0=no change; 1=memory returns RET (201)
bool turbo;
bool turbo_play;
computer();
~computer();
......
......@@ -189,7 +189,7 @@ void load_main_game(const char *nombre) {
}
}
void save_config(struct computer *object) {
void save_config() {
char config_path[1024];
int length;
......@@ -204,24 +204,26 @@ void save_config(struct computer *object) {
if (fconfig==NULL) {
return;
}
fprintf(fconfig,"mode=%c%c",48+object->mode128k,10);
fprintf(fconfig,"issue=%c%c",48+object->issue,10);
fprintf(fconfig,"mode=%c%c",48+ordenador->mode128k,10);
fprintf(fconfig,"issue=%c%c",48+ordenador->issue,10);
fprintf(fconfig,"joystick=%c%c",48+keyboard->joystick,10);
fprintf(fconfig,"ay_sound=%c%c",48+spk_ay->ay_emul,10);
fprintf(fconfig,"interface1=%c%c",48+microdrive->mdr_active,10);
fprintf(fconfig,"doublescan=%c%c",object->dblscan ? '1' : '0',10);
fprintf(fconfig,"doublescan=%c%c",ordenador->dblscan ? '1' : '0',10);
fprintf(fconfig,"volume=%c%c",65+(llsound->volume/4),10);
fprintf(fconfig,"bw=%c%c",object->bw ? '1' : '0',10);
fprintf(fconfig,"bw=%c%c",ordenador->bw ? '1' : '0',10);
fprintf(fconfig,"fast=%c%c",ordenador->tape_fast_load ? '1' : '0',10);
fprintf(fconfig,"turboload=%c%c",ordenador->turbo_play ? '1' : '0',10);
fclose(fconfig);
}
void load_config(struct computer *object) {
void load_config() {
char config_path[1024];
char line[1024],carac,done;
int length,pos;
FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,joystick=255,ay_emul=255,mdr_active=255,dblscan=255,bw=255;
unsigned char volume=255,mode128k=255,issue=255,joystick=255,ay_emul=255,mdr_active=255,dblscan=255,bw,fast,turboload=255;
strcpy(config_path,getenv("HOME"));
length=strlen(config_path);
......@@ -288,13 +290,21 @@ void load_config(struct computer *object) {
bw=(line[3]-'0');
continue;
}
if (!strncmp(line,"fast=",5)) {
fast=(line[5]-'0');
continue;
}
if (!strncmp(line,"turboload=",10)) {
turboload=(line[10]-'0');
continue;
}
}
if (mode128k<5) {
object->mode128k=mode128k;
ordenador->mode128k=mode128k;
}
if (issue<4) {
object->issue=issue;
ordenador->issue=issue;
}
if (joystick<4) {
keyboard->joystick=joystick;
......@@ -306,10 +316,16 @@ void load_config(struct computer *object) {
microdrive->mdr_active=mdr_active;
}
if (dblscan<2) {
object->dblscan = dblscan==0 ? false : true;
ordenador->dblscan = dblscan==0 ? false : true;
}
if (bw<2) {
object->bw = bw==0 ? false : true;
ordenador->bw = bw==0 ? false : true;
}
if (fast<2) {
ordenador->tape_fast_load = fast==0 ? false : true;
}
if (turboload<2) {
ordenador->turbo_play = turboload==0 ? false : true;
}
if (volume<255) {
llsound->set_volume(volume);
......@@ -357,7 +373,7 @@ int main(int argc,char *argv[]) {
microdrive = new Microdrive();
spk_ay = new SPK_AY();
load_config(ordenador);
load_config();
ordenador->zaurus_mini = 0;
if (parse.mini) {
......@@ -539,7 +555,7 @@ int main(int argc,char *argv[]) {
}
}
save_config(ordenador);
save_config();
return 0;
}
......
......@@ -210,10 +210,16 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
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:
......
......@@ -83,6 +83,15 @@ LLSound::LLSound(enum e_soundtype sound_type) {
printf("Return init\n");
}
void LLSound::set_speed(bool turbo) {
if(turbo){
this->tst_sample = 1000000000 / this->freq;
} else {
this->tst_sample = 3500000 / this->freq;
}
}
int LLSound::init_sound() {
if (this->sound_type != SOUND_AUTOMATIC) {
......
......@@ -51,13 +51,6 @@ class LLSound {
void show_volume();
public:
LLSound(enum e_soundtype);
~LLSound();
void play();
void increase_volume();
void decrease_volume();
void set_volume(uint8_t);
uint32_t freq; // frequency for reproduction
uint32_t tst_sample; // number of tstates per sample
int8_t sign; // 0: unsigned; 1: signed
......@@ -67,9 +60,15 @@ public:
uint32_t buffer_len; // sound buffer length (in samples)
uint32_t increment; // cuantity to add to jump to the next sample
uint8_t volume; // volume
enum e_soundtype sound_type;
LLSound(enum e_soundtype);
~LLSound();
void play();
void increase_volume();
void decrease_volume();
void set_volume(uint8_t);
void set_speed(bool);
};
extern volatile unsigned char *sdl_sound_buffer;
......
......@@ -55,7 +55,7 @@ void help_menu() {
llscreen->clear_screen();
llscreen->print_string("FBZX (2.99.0)",-1,1,15,0);
llscreen->print_string("FBZX (2.99.1)",-1,1,15,0);
llscreen->print_string("Available keys",-1,2,14,0);
llscreen->print_string("Shift:Caps Shift Ctrl:Symbol Shift",-1,4,11,0);
......@@ -330,16 +330,21 @@ void settings_menu() {
break;
case SDLK_t:
if(ordenador->turbo){
llsound->tst_sample = 3500000 / llsound->freq;
ordenador->turbo = false;
} else {
llsound->tst_sample = 100000000 / llsound->freq;
ordenador->turbo = true;
}
llsound->set_speed(ordenador->turbo);
}
} while(fin);
llscreen->clear_screen();
if ((ordenador->turbo_play) && (!OOTape->get_pause())) {
llsound->set_speed(true);
} else {
llsound->set_speed(ordenador->turbo);
}
}
......@@ -553,22 +558,29 @@ void taps_menu() {
llscreen->print_string("5: \001\017create empty TAP file",14,8,12,0);
llscreen->print_string("6: \001\017Fast mode when playing tape",320,8,12,0);
llscreen->print_string("ESC: \001\017return to emulator",14,12,12,0);
llscreen->print_string("Current TAP/TZX file is:",-1,19,12,0);
llscreen->print_string(ordenador->current_tap,-1,20,15,0);
llscreen->print_string("Current TAP/TZX file is:",-1,17,12,0);
llscreen->print_string(ordenador->current_tap,-1,18,15,0);
print_copy();
if(ordenador->tape_fast_load)
llscreen->print_string("Fast load enabled",10,-4,14,0);
llscreen->print_string("Fast load \001\014enabled",10,-6,14,0);
else
llscreen->print_string("Fast load disabled",10,-4,14,0);
llscreen->print_string("Fast load \001\012disabled",10,-6,14,0);
if(ordenador->tape_write)
llscreen->print_string("Write enabled",390,-4,14,0);
llscreen->print_string("Write \001\014enabled",390,-6,14,0);
else
llscreen->print_string("Write disabled",390,-4,14,0);
llscreen->print_string("Write \001\012disabled",390,-6,14,0);
if(ordenador->turbo_play)
llscreen->print_string("Turbo while playing \001\014enabled",10,-4,14,0);
else
llscreen->print_string("Turbo while playing \001\012disabled",10,-4,14,0);
switch(wait_key()) {
case SDLK_ESCAPE: // to exit the help
......@@ -594,6 +606,9 @@ void taps_menu() {
case SDLK_5:
create_tapfile();
break;
case SDLK_6:
ordenador->turbo_play = ordenador->turbo_play ? false : true;
break;
default:
break;
}
......
......@@ -223,7 +223,7 @@ void SPK_AY::play_ay (int tstados) {
if (!noise_period) noise_period = 1;
if (tone_period_a * llsound->freq<110841) //Freq_camp > cpufreq/(2*16*tone_period)
if (tone_period_a * llsound->freq < 110841) //Freq_camp > cpufreq/(2*16*tone_period)
this->aych_a =1;
else
{
......@@ -236,7 +236,7 @@ void SPK_AY::play_ay (int tstados) {
}
}
if (tone_period_b * llsound->freq<110841) //Freq_camp > cpufreq/(2*16*tone_period)
if (tone_period_b * llsound->freq < 110841) //Freq_camp > cpufreq/(2*16*tone_period)
this->aych_b =1;
else
{
......@@ -249,7 +249,7 @@ void SPK_AY::play_ay (int tstados) {
}
}
if (tone_period_c * llsound->freq<110841) //Freq_camp > cpufreq/(2*16*tone_period)
if (tone_period_c * llsound->freq < 110841) //Freq_camp > cpufreq/(2*16*tone_period)
this->aych_c =1;
else
{
......
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