Support for ABC stereo, fixed bug in SNA format

This commit is contained in:
fabio.olimpieri 2012-08-14 21:31:45 +00:00
parent acc37ba021
commit c993740080
8 changed files with 212 additions and 141 deletions

View File

@ -506,15 +506,11 @@ int load_sna(char *filename) {
snap->IY=((word)tempo[15])+256*((word)tempo[16]); snap->IY=((word)tempo[15])+256*((word)tempo[16]);
snap->IX=((word)tempo[17])+256*((word)tempo[18]); snap->IX=((word)tempo[17])+256*((word)tempo[18]);
if (tempo[19]&0x01) { if (tempo[19]&0x04) {
snap->IFF1=1; snap->IFF1=1;
} else {
snap->IFF1=0;
}
if (tempo[19]&0x02) {
snap->IFF2=1; snap->IFF2=1;
} else { } else {
snap->IFF1=0;
snap->IFF2=0; snap->IFF2=0;
} }
@ -525,7 +521,7 @@ int load_sna(char *filename) {
snap->Imode=tempo[25]; snap->Imode=tempo[25];
snap->border=tempo[26]; snap->border=tempo[26];
if (type==0) { if (type==0) { //48k
v1=tempo[23]; v1=tempo[23];
v2=tempo[24]; v2=tempo[24];
@ -547,7 +543,7 @@ int load_sna(char *filename) {
memcpy(snap->page[0],tempo+27,16384); memcpy(snap->page[0],tempo+27,16384);
memcpy(snap->page[1],tempo+16411,16384); memcpy(snap->page[1],tempo+16411,16384);
memcpy(snap->page[2],tempo+32795,16384); memcpy(snap->page[2],tempo+32795,16384);
} else { } else { //128k
snap->PC=((word)tempo2[0])+256*((word)tempo2[1]); snap->PC=((word)tempo2[0])+256*((word)tempo2[1]);
memcpy(snap->page[5],tempo+27,16384); memcpy(snap->page[5],tempo+27,16384);
memcpy(snap->page[2],tempo+16411,16384); memcpy(snap->page[2],tempo+16411,16384);

View File

@ -172,6 +172,7 @@ void computer_init () { //Called only on start-up
ordenador.last_selected_poke_file[0]='\0'; ordenador.last_selected_poke_file[0]='\0';
ordenador.npixels=4; ordenador.npixels=4;
ordenador.progressive=0; ordenador.progressive=0;
ordenador.audio_mode=2; //ACB
} }
void computer_set_palete() { void computer_set_palete() {
@ -460,7 +461,7 @@ void register_screen (SDL_Surface * pantalla) {
ordenador.current_buffer = 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_cuantity = 0;
ordenador.sound_current_value = 0; //ordenador.sound_current_value = 0;
update_npixels(); update_npixels();
} }
@ -1553,6 +1554,8 @@ void ResetComputer () {
ordenador.last_selected_poke_file[0]='\0'; ordenador.last_selected_poke_file[0]='\0';
ordenador.tst_sample=ordenador.cpufreq/ordenador.freq;
microdrive_reset(); microdrive_reset();
} }

View File

@ -129,13 +129,14 @@ struct computer {
unsigned int aych_a,aych_b,aych_c,aych_n,aych_envel; // counters for AY emulation unsigned int aych_a,aych_b,aych_c,aych_n,aych_envel; // counters for AY emulation
unsigned char ayval_a,ayval_b,ayval_c,ayval_n; unsigned char ayval_a,ayval_b,ayval_c,ayval_n;
unsigned char ay_emul; // 0: no AY emulation; 1: AY emulation unsigned char ay_emul; // 0: no AY emulation; 1: AY emulation
unsigned char audio_mode; //mono, ABC, ACB, BAC
unsigned char vol_a,vol_b,vol_c; unsigned char vol_a,vol_b,vol_c;
unsigned int tst_ay; unsigned int tst_ay;
unsigned int tst_ay2; unsigned int tst_ay2;
unsigned int ay_latch; unsigned int ay_latch;
signed char ay_envel_value; signed char ay_envel_value;
unsigned char ay_envel_way; unsigned char ay_envel_way;
unsigned char sound_current_value; //unsigned char sound_current_value;
unsigned int wr; unsigned int wr;
unsigned int r_fetch; unsigned int r_fetch;
unsigned int io; unsigned int io;

View File

@ -486,7 +486,6 @@ int bucle, bucle2,ret2;
ordenador.increment=ordenador.channels; ordenador.increment=ordenador.channels;
for(bucle2=0;bucle2<NUM_SNDBUF;bucle2++) { for(bucle2=0;bucle2<NUM_SNDBUF;bucle2++) {
//sound[bucle2]=(unsigned char *)malloc(ordenador.buffer_len*ordenador.increment+8);
//ASND Required alligned memory with padding //ASND Required alligned memory with padding
sound[bucle2]=(unsigned char *)memalign(32,ordenador.buffer_len*ordenador.increment+32); sound[bucle2]=(unsigned char *)memalign(32,ordenador.buffer_len*ordenador.increment+32);
for(bucle=0;bucle<ordenador.buffer_len*ordenador.increment+4;bucle++) for(bucle=0;bucle<ordenador.buffer_len*ordenador.increment+4;bucle++)
@ -495,8 +494,6 @@ int bucle, bucle2,ret2;
printf("Init sound 2\n"); printf("Init sound 2\n");
ordenador.tst_sample=ordenador.cpufreq/ordenador.freq; ordenador.tst_sample=ordenador.cpufreq/ordenador.freq;
//printf("Set volume\n");
//set_volume(70);
} }
void end_system() { void end_system() {
@ -564,6 +561,7 @@ int save_config(struct computer *object, char *filename) {
fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10); fprintf(fconfig,"joystick1=%c%c",48+object->joystick[0],10);
fprintf(fconfig,"joystick2=%c%c",48+object->joystick[1],10); fprintf(fconfig,"joystick2=%c%c",48+object->joystick[1],10);
fprintf(fconfig,"ay_sound=%c%c",48+object->ay_emul,10); fprintf(fconfig,"ay_sound=%c%c",48+object->ay_emul,10);
fprintf(fconfig,"audio_mode=%c%c",48+object->audio_mode,10);
fprintf(fconfig,"interface1=%c%c",48+object->mdr_active,10); fprintf(fconfig,"interface1=%c%c",48+object->mdr_active,10);
fprintf(fconfig,"doublescan=%c%c",48+object->dblscan,10); fprintf(fconfig,"doublescan=%c%c",48+object->dblscan,10);
fprintf(fconfig,"framerate=%c%c",48+jump_frames,10); fprintf(fconfig,"framerate=%c%c",48+jump_frames,10);
@ -699,7 +697,7 @@ int load_config(struct computer *object, char *filename) {
int pos, key_sdl=0; int pos, key_sdl=0;
FILE *fconfig; FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,ay_emul=255,mdr_active=255, 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, 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; joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255;
if (filename) strcpy(config_path,filename); if (filename) strcpy(config_path,filename);
@ -758,6 +756,10 @@ int load_config(struct computer *object, char *filename) {
ay_emul=line[9]-'0'; ay_emul=line[9]-'0';
continue; continue;
} }
if (!strncmp(line,"audio_mode=",11)) {
audio_mode=line[11]-'0';
continue;
}
if (!strncmp(line,"interface1=",11)) { if (!strncmp(line,"interface1=",11)) {
mdr_active=line[11]-'0'; mdr_active=line[11]-'0';
continue; continue;
@ -844,6 +846,9 @@ int load_config(struct computer *object, char *filename) {
if (ay_emul<2) { if (ay_emul<2) {
object->ay_emul=ay_emul; object->ay_emul=ay_emul;
} }
if (audio_mode<4) {
object->audio_mode=audio_mode;
}
if (mdr_active<2) { if (mdr_active<2) {
object->mdr_active=mdr_active; object->mdr_active=mdr_active;
} }

View File

@ -67,11 +67,11 @@ static const char *main_menu_messages[] = {
/*06*/ "^|Wiimote1|Wiimote2", /*06*/ "^|Wiimote1|Wiimote2",
/*07*/ "Emulation settings", /*07*/ "Emulation settings",
/*08*/ "Screen settings", /*08*/ "Screen settings",
/*09*/ "Confs files", /*09*/ "Audio settings",
/*10*/ "Microdrive", /*10*/ "Config files",
/*11*/ "Tools", /*11*/ "Microdrive",
/*12*/ "Reset", /*12*/ "Tools",
/*13*/ "Help", /*13*/ "Reset",
/*14*/ "Quit", /*14*/ "Quit",
NULL NULL
}; };
@ -79,18 +79,27 @@ static const char *main_menu_messages[] = {
static const char *emulation_messages[] = { static const char *emulation_messages[] = {
/*00*/ "Emulated machine", /*00*/ "Emulated machine",
/*01*/ "^|48k_2|48K_3|128k|+2|+2A/+3|128K_Sp|NTSC", /*01*/ "^|48k_2|48K_3|128k|+2|+2A/+3|128K_Sp|NTSC",
/*02*/ "Volume", /*02*/ "Frame rate",
/*03*/ "^|0|1|2|3|4|5|6|7|max", /*03*/ "^|100%|50%|33%|25%|20%",
/*04*/ "Frame rate", /*04*/ "Tap fast speed",
/*05*/ "^|100%|50%|33%|25%|20%", /*05*/ "^|on|off",
/*06*/ "Tap fast speed", /*06*/ "Turbo mode",
/*07*/ "^|on|off", /*07*/ "^|off|speed|ultraspeed",
/*08*/ "Turbo mode", /*08*/ "Precision",
/*09*/ "^|off|speed|ultraspeed", /*09*/ "^|on|off",
/*10*/ "Precision", NULL
/*11*/ "^|on|off", };
/*12*/ "AY-3-8912 Emulation",
/*13*/ "^|on|off", static const char *audio_messages[] = {
/*00*/ "Volume",
/*01*/ "^|0|1|2|3|4|5|6|7|max",
/*02*/ " ",
/*03*/ "AY-3-8912 Emulation",
/*04*/ "^|on|off",
/*05*/ " ",
/*06*/ "Audio mode",
/*07*/ "^|mono|ABC|ACB|BAC",
NULL NULL
}; };
@ -152,6 +161,8 @@ static const char *tools_messages[] = {
/*09*/ " ", /*09*/ " ",
/*10*/ "Port", /*10*/ "Port",
/*11*/ "^|sd|usb|smb", /*11*/ "^|sd|usb|smb",
/*12*/ " ",
/*13*/ "Help",
NULL NULL
}; };
@ -480,21 +491,20 @@ static void set_machine_model(int which)
static void emulation_settings(void) static void emulation_settings(void)
{ {
unsigned int submenus[7],submenus_old[7]; unsigned int submenus[5],submenus_old[5];
int opt, i; int opt, i;
unsigned char old_mode, old_videosystem; unsigned char old_mode, old_videosystem;
memset(submenus, 0, sizeof(submenus)); memset(submenus, 0, sizeof(submenus));
submenus[0] = get_machine_model(); submenus[0] = get_machine_model();
submenus[1] = ordenador.volume/2; submenus[1] = jump_frames;
submenus[2] = jump_frames; submenus[2] = !ordenador.tape_fast_load;
submenus[3] = !ordenador.tape_fast_load; submenus[3] = ordenador.turbo;
submenus[4] = ordenador.turbo; submenus[4] = !ordenador.precision;
submenus[5] = !ordenador.precision;
submenus[6] = !ordenador.ay_emul;
for (i=0; i<7; i++) submenus_old[i] = submenus[i];
for (i=0; i<5; i++) submenus_old[i] = submenus[i];
old_mode=ordenador.mode128k; old_mode=ordenador.mode128k;
old_videosystem = ordenador.videosystem; old_videosystem = ordenador.videosystem;
@ -504,16 +514,14 @@ static void emulation_settings(void)
return; return;
set_machine_model(submenus[0]); set_machine_model(submenus[0]);
if ((old_mode!=ordenador.mode128k)||(old_videosystem!=ordenador.videosystem)) ResetComputer(); else if ((old_mode!=ordenador.mode128k)||(old_videosystem!=ordenador.videosystem)) ResetComputer();
ordenador.ay_emul = !submenus[6];
ordenador.volume = submenus[1]*2; //I should use set_volume() ? jump_frames = submenus[1];
jump_frames = submenus[2]; ordenador.tape_fast_load = !submenus[2];
ordenador.tape_fast_load = !submenus[3]; ordenador.turbo = submenus[3];
ordenador.turbo = submenus[4];
curr_frames=0; curr_frames=0;
if (submenus[4] != submenus_old[4]) if (submenus[3] != submenus_old[3])
{ {
switch(ordenador.turbo) switch(ordenador.turbo)
{ {
@ -536,7 +544,34 @@ static void emulation_settings(void)
} }
} }
if (ordenador.turbo==0) ordenador.precision = !submenus[5]; if (ordenador.turbo==0) ordenador.precision = !submenus[4];
}
static void audio_settings(void)
{
unsigned int submenus[3];
int opt;
memset(submenus, 0, sizeof(submenus));
submenus[0] = ordenador.volume/2;
submenus[1] = !ordenador.ay_emul;
submenus[2] = ordenador.audio_mode;
opt = menu_select_title("Audio settings menu",
audio_messages, submenus);
if (opt < 0)
return;
ordenador.volume = submenus[0]*2;
ordenador.ay_emul = !submenus[1];
ordenador.audio_mode = submenus[2];
} }
static void save_load_general_configurations(int); static void save_load_general_configurations(int);
@ -1251,6 +1286,11 @@ void load_poke_file()
} }
static void help(void)
{
menu_select_title("FBZX-WII help",
help_messages, NULL);
}
static void tools() static void tools()
{ {
@ -1268,6 +1308,8 @@ static void tools()
set_port(submenus[0]); set_port(submenus[0]);
do
{
switch(opt) switch(opt)
{ {
case 0: // Show keyboard case 0: // Show keyboard
@ -1285,9 +1327,13 @@ static void tools()
case 8: // Load poke file case 8: // Load poke file
load_poke_file(); load_poke_file();
break; break;
case 10:
help();
break;
default: default:
break; break;
} }
} while (opt == 10);
} }
@ -1549,12 +1595,6 @@ static void manage_configurations()
} }
static void help(void)
{
menu_select_title("FBZX-WII help",
help_messages, NULL);
}
void main_menu() void main_menu()
{ {
int submenus[3]; int submenus[3];
@ -1586,15 +1626,18 @@ void main_menu()
screen_settings(); screen_settings();
break; break;
case 9: case 9:
manage_configurations(); audio_settings();
break; break;
case 10: case 10:
microdrive(); manage_configurations();
break; break;
case 11: case 11:
tools(); microdrive();
break; break;
case 12: case 12:
tools();
break;
case 13:
ResetComputer (); ResetComputer ();
ordenador.pause = 1; ordenador.pause = 1;
if (ordenador.tap_file != NULL) { if (ordenador.tap_file != NULL) {
@ -1602,9 +1645,6 @@ void main_menu()
rewind_tape (ordenador.tap_file,1); rewind_tape (ordenador.tap_file,1);
} }
break; break;
case 13:
help();
break;
case 14: case 14:
if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO))
{salir = 0;} {salir = 0;}
@ -1612,7 +1652,7 @@ void main_menu()
default: default:
break; break;
} }
} while (opt == 5 || opt == 7 || opt == 10 || opt == 13); } while (opt == 4 || opt == 7 || opt == 11);
clean_screen(); clean_screen();

View File

@ -2002,9 +2002,9 @@ if (freq == 0)
if (ordenador.videosystem==0) ordenador.cpufreq = 3500000; if (ordenador.videosystem==0) ordenador.cpufreq = 3500000;
else ordenador.cpufreq = 3527500; else ordenador.cpufreq = 3527500;
break; break;
case 3: // +2A/+3
case 1: // 128K case 1: // 128K
case 2: // +2 case 2: // +2
case 3: // +2A/+3
case 4: // spanish 128K case 4: // spanish 128K
ordenador.cpufreq = 3546900; ordenador.cpufreq = 3546900;
break; break;

View File

@ -183,7 +183,7 @@ int sound_init_asnd() {
ASND_Pause(0); ASND_Pause(0);
ordenador.sign=0; ordenador.sign=0;
ordenador.format=0; //8 bit ordenador.format=0; //8 bit
ordenador.channels=1; //mono ordenador.channels=2; //stereo
ordenador.freq=48000; ordenador.freq=48000;
ordenador.buffer_len=4096; ordenador.buffer_len=4096;
started_sound_asnd = 0; started_sound_asnd = 0;
@ -495,17 +495,17 @@ void sound_play() {
#ifdef GEKKO #ifdef GEKKO
case SOUND_ASND: // ASND case SOUND_ASND: // ASND
if (!started_sound_asnd) { if (!started_sound_asnd) {
ASND_SetVoice(1,VOICE_MONO_8BIT_U,48000,0,sound[0],ordenador.buffer_len, ASND_SetVoice(1,VOICE_STEREO_8BIT_U,ordenador.freq,0,sound[0],ordenador.buffer_len*ordenador.increment,
MID_VOLUME, MID_VOLUME, callback); MID_VOLUME, MID_VOLUME, callback);
started_sound_asnd = 1; started_sound_asnd = 1;
} }
//Double buffer //Double buffer
while (!ASND_TestVoiceBufferReady(1)){}; //Wait for one buffer to be free while (!ASND_TestVoiceBufferReady(1)){}; //Wait for one buffer to be free
if (!ASND_TestPointer (1, sound[0])) if (!ASND_TestPointer (1, sound[0]))
{ASND_AddVoice(1,sound[0],ordenador.buffer_len); {ASND_AddVoice(1,sound[0],ordenador.buffer_len*ordenador.increment);
ordenador.current_buffer = sound[0]; } ordenador.current_buffer = sound[0]; }
else else
{ASND_AddVoice(1,sound[1],ordenador.buffer_len); {ASND_AddVoice(1,sound[1],ordenador.buffer_len*ordenador.increment);
ordenador.current_buffer = sound[1]; } ordenador.current_buffer = sound[1]; }
return; return;

View File

@ -187,8 +187,8 @@ inline void play_ay (unsigned int tstados) {
if (!noise_period) noise_period = 1; if (!noise_period) noise_period = 1;
if (tone_period_a*ordenador.freq<110841) //Freq_camp > cpufreq/(2*16*tone_period) if (tone_period_a<6) //max 20KHz
ordenador.aych_a =1; ordenador.ayval_a =1;
else else
{ {
if (ordenador.aych_a<tone_period_a) if (ordenador.aych_a<tone_period_a)
@ -200,8 +200,8 @@ inline void play_ay (unsigned int tstados) {
} }
} }
if (tone_period_b*ordenador.freq<110841) //Freq_camp > cpufreq/(2*16*tone_period) if (tone_period_b<6) //max 20KHz
ordenador.aych_b =1; ordenador.ayval_b =1;
else else
{ {
if (ordenador.aych_b<tone_period_b) if (ordenador.aych_b<tone_period_b)
@ -213,8 +213,8 @@ inline void play_ay (unsigned int tstados) {
} }
} }
if (tone_period_c*ordenador.freq<110841) //Freq_camp > cpufreq/(2*16*tone_period) if (tone_period_c<6) //max 20KHz
ordenador.aych_c =1; ordenador.ayval_c =1;
else else
{ {
if (ordenador.aych_c<tone_period_c) if (ordenador.aych_c<tone_period_c)
@ -262,59 +262,9 @@ inline void play_ay (unsigned int tstados) {
noise >>= 1 ; noise >>= 1 ;
ordenador.aych_n =0; ordenador.aych_n =0;
}
// Volume
//Each channel max 51
if (ordenador.ay_registers[8] & 0x10)
ordenador.vol_a =
(unsigned char) (levels[ordenador.ay_envel_value]*(unsigned int) ordenador.volume/80);
else
ordenador.vol_a =
(unsigned char) (levels[ordenador.ay_registers[8] &0x0F]*(unsigned int) ordenador.volume/80);
if (ordenador.ay_registers[10] & 0x10)
ordenador.vol_c =
(unsigned char) (levels[ordenador.ay_envel_value] *(unsigned int) ordenador.volume/80);
else
ordenador.vol_c =
(unsigned char) (levels[ordenador.ay_registers[10] & 0x0F] *(unsigned int) ordenador.volume/80);
if (ordenador.ay_registers[9] & 0x10)
ordenador.vol_b =
(unsigned char) (levels[ordenador.ay_envel_value] *(unsigned int) ordenador.volume/80);
else
ordenador.vol_b =
(unsigned char)(levels[ordenador.ay_registers[9] &0x0F] *(unsigned int) ordenador.volume/80);
} }
}
/* Creates the sound buffer during the TSTADOS tstate that the Z80 used to
execute last instruction */
inline void play_sound (unsigned int tstados) {
int bucle;
int value;
unsigned char sample_v;
ordenador.tstados_counter_sound += tstados;
while (ordenador.tstados_counter_sound >= ordenador.tst_sample) {
ordenador.tstados_counter_sound -= ordenador.tst_sample;
if (sound_type!=1) //!SOUND_OSS
for (bucle = 0; bucle < ordenador.increment; bucle++) {
sample_v = ordenador.sample1b[bucle];
if (ordenador.sound_bit && sample_v)
//Sound bit volume max 96
ordenador.sound_current_value=ordenador.volume*6;
else ordenador.sound_current_value=0;
value = ordenador.sound_current_value;
//Mixer //Mixer
@ -331,22 +281,98 @@ inline void play_sound (unsigned int tstados) {
// into the ON state (see above); and it has no effect if the volume is 0. // into the ON state (see above); and it has no effect if the volume is 0.
// If the volume is 0, increase the counter, but don't touch the output. // If the volume is 0, increase the counter, but don't touch the output.
if (ordenador.ay_emul) { // if emulation is ON, emulate it if ((ordenador.ayval_a || (ordenador.ay_registers[7] & 0x01))&&(ordenador.ayval_n || (ordenador.ay_registers[7] & 0x08)))
//ordenador.ayval_n = 1; {
if (sample_v &&((ordenador.ayval_a || (ordenador.ay_registers[7] & 0x01))&&(ordenador.ayval_n || (ordenador.ay_registers[7] & 0x08)))) if (ordenador.ay_registers[8] & 0x10)
value += (int) ordenador.vol_a; ordenador.vol_a = levels[ordenador.ay_envel_value];
if (sample_v &&((ordenador.ayval_b || (ordenador.ay_registers[7] & 0x02))&&(ordenador.ayval_n || (ordenador.ay_registers[7] & 0x10)))) else
value += (int) ordenador.vol_b; ordenador.vol_a = levels[ordenador.ay_registers[8] &0x0F];
if (sample_v &&((ordenador.ayval_c || (ordenador.ay_registers[7] & 0x04))&&(ordenador.ayval_n || (ordenador.ay_registers[7] & 0x20)))) }
value += (int) ordenador.vol_c; else ordenador.vol_a = 0;
if ((ordenador.ayval_b || (ordenador.ay_registers[7] & 0x02))&&(ordenador.ayval_n || (ordenador.ay_registers[7] & 0x10)))
{
if (ordenador.ay_registers[9] & 0x10)
ordenador.vol_b = levels[ordenador.ay_envel_value];
else
ordenador.vol_b = levels[ordenador.ay_registers[9] &0x0F];
} }
if (value > 255) else ordenador.vol_b = 0;
value = 255;
sample_v = (unsigned char)(value - (unsigned int)ordenador.sign); if ((ordenador.ayval_c || (ordenador.ay_registers[7] & 0x04))&&(ordenador.ayval_n || (ordenador.ay_registers[7] & 0x20)))
*ordenador.current_buffer = sample_v; {
if (ordenador.ay_registers[10] & 0x10)
ordenador.vol_c = levels[ordenador.ay_envel_value];
else
ordenador.vol_c = levels[ordenador.ay_registers[10] & 0x0F];
}
else ordenador.vol_c = 0;
}
}
/* Creates the sound buffer during the TSTADOS tstate that the Z80 used to
execute last instruction */
inline void play_sound (unsigned int tstados) {
int value, lvalue, rvalue;
ordenador.tstados_counter_sound += tstados;
while (ordenador.tstados_counter_sound >= ordenador.tst_sample) {
ordenador.tstados_counter_sound -= ordenador.tst_sample;
if (ordenador.sound_bit) value=ordenador.volume*6; //Sound bit volume max 96
else value=0;
//Each channel max 51
if (ordenador.ay_emul)
{
switch (ordenador.audio_mode)
{
case 0: //Mono
lvalue = value + (ordenador.vol_a + ordenador.vol_b +ordenador.vol_c)*ordenador.volume/80;
rvalue = value + (ordenador.vol_a + ordenador.vol_b +ordenador.vol_c)*ordenador.volume/80;
break;
case 1: //ABC
lvalue = value + (ordenador.vol_a*2 + ordenador.vol_b)*ordenador.volume/80;
rvalue = value + (ordenador.vol_b + ordenador.vol_c*2)*ordenador.volume/80;
break;
case 2: //ACB
lvalue = value + (ordenador.vol_a*2 + ordenador.vol_c)*ordenador.volume/80;
rvalue = value + (ordenador.vol_c + ordenador.vol_b*2)*ordenador.volume/80;
break;
case 3: //BAC
lvalue = value + (ordenador.vol_b*2 + ordenador.vol_a)*ordenador.volume/80;
rvalue = value + (ordenador.vol_a + ordenador.vol_c*2)*ordenador.volume/80;
break;
default: //No emulation
rvalue = value;
lvalue = value;
break;
}
}
else
{
rvalue = value;
lvalue = value;
}
/*
if (rvalue > 255) rvalue = 255;
if (lvalue > 255) lvalue = 255;
*/
*ordenador.current_buffer = (unsigned char)(rvalue - (unsigned int)ordenador.sign);
ordenador.current_buffer++; ordenador.current_buffer++;
} *ordenador.current_buffer = (unsigned char)(lvalue - (unsigned int)ordenador.sign);
ordenador.current_buffer++;
ordenador.sound_cuantity++; ordenador.sound_cuantity++;
if (ordenador.sound_cuantity == ordenador.buffer_len) { // buffer filled if (ordenador.sound_cuantity == ordenador.buffer_len) { // buffer filled