Commit a3f65fe1 authored by Sergio Costas's avatar Sergio Costas

Put AY emulation in its own class

Fixed source indentation
parent cc35484e
......@@ -34,7 +34,7 @@ Z80free_codesDDCB.o: z80free/Z80free_codesDDCB.c z80free/Z80free.h
Z80free_codesFDCB.o: z80free/Z80free_codesFDCB.c z80free/Z80free.h
$(CC) -o Z80free_codesFDCB.o z80free/Z80free_codesFDCB.c
cargador.o: cargador.cpp keyboard.hh emulator.hh screen.hh osd.hh z80free/Z80free.h computer.hh signals.hh llscreen.hh tape.hh cargador.hh
cargador.o: cargador.cpp spk_ay.hh keyboard.hh emulator.hh screen.hh osd.hh z80free/Z80free.h computer.hh signals.hh llscreen.hh tape.hh cargador.hh
$(CPP) $(CPPFLAGS) -o cargador.o cargador.cpp
cmdline.o: cmdline.cpp cmdline.hh
......@@ -43,7 +43,7 @@ cmdline.o: cmdline.cpp cmdline.hh
computer.o: computer.cpp z80free/Z80free.h llsound.hh keyboard.hh computer.hh screen.hh signals.hh llscreen.hh tape.hh emulator.hh osd.hh spk_ay.hh microdrive.hh menus.hh
$(CPP) $(CPPFLAGS) -o computer.o computer.cpp
emulator.o: emulator.cpp keyboard.hh llsound.hh cmdline.hh computer.hh screen.hh signals.hh llscreen.hh z80free/Z80free.h tape.hh emulator.hh osd.hh microdrive.hh menus.hh cargador.hh
emulator.o: emulator.cpp spk_ay.hh keyboard.hh llsound.hh cmdline.hh computer.hh screen.hh signals.hh llscreen.hh z80free/Z80free.h tape.hh emulator.hh osd.hh microdrive.hh menus.hh cargador.hh
$(CPP) $(CPPFLAGS) -o emulator.o emulator.cpp
keyboard.o: keyboard.cpp menus.hh llscreen.hh llsound.hh computer.hh screen.hh signals.hh z80free/Z80free.h tape.hh emulator.hh osd.hh keyboard.hh
......@@ -55,7 +55,7 @@ llscreen.o: llscreen.cpp osd.hh font.h llscreen.hh
llsound.o: llsound.cpp emulator.hh screen.hh osd.hh z80free/Z80free.h computer.hh signals.hh llscreen.hh tape.hh llsound.hh
$(CPP) $(CPPFLAGS) -o llsound.o llsound.cpp
menus.o: menus.cpp microdrive.hh z80free/Z80free.h keyboard.hh llsound.hh llscreen.hh menus.hh tape.hh signals.hh emulator.hh screen.hh osd.hh computer.hh cargador.hh
menus.o: menus.cpp spk_ay.hh microdrive.hh z80free/Z80free.h keyboard.hh llsound.hh llscreen.hh menus.hh tape.hh signals.hh emulator.hh screen.hh osd.hh computer.hh cargador.hh
$(CPP) $(CPPFLAGS) -o menus.o menus.cpp
microdrive.o: microdrive.cpp osd.hh emulator.hh screen.hh z80free/Z80free.h computer.hh signals.hh llscreen.hh tape.hh microdrive.hh
......@@ -70,7 +70,7 @@ screen.o: screen.cpp keyboard.hh computer.hh screen.hh signals.hh llscreen.hh z8
signals.o: signals.cpp signals.hh
$(CPP) $(CPPFLAGS) -o signals.o signals.cpp
spk_ay.o: spk_ay.cpp llsound.hh computer.hh screen.hh signals.hh llscreen.hh z80free/Z80free.h tape.hh emulator.hh osd.hh
spk_ay.o: spk_ay.cpp spk_ay.hh llsound.hh computer.hh screen.hh signals.hh llscreen.hh z80free/Z80free.h tape.hh emulator.hh osd.hh
$(CPP) $(CPPFLAGS) -o spk_ay.o spk_ay.cpp
tape.o: tape.cpp z80free/Z80free.h tape.hh signals.hh emulator.hh screen.hh osd.hh computer.hh llscreen.hh
......
This diff is collapsed.
......@@ -51,43 +51,18 @@ computer::computer() {
this->issue = 3;
this->mode128k = 0;
this->turbo = false;
this->sound_bit = 0;
this->tape_write = false;
this->tape_fast_load = true; // fast load by default
this->other_ret = 0;
for (bucle = 0; bucle < 16; bucle++)
this->ay_registers[bucle] = 0;
this->ay_emul = 0;
this->aych_a = 0;
this->aych_b = 0;
this->aych_c = 0;
this->aych_n = 0;
this->aych_envel = 0;
this->vol_a = 0;
this->vol_b = 0;
this->vol_c = 0;
this->tst_ay = 0;
this->tst_ay2 = 0;
this->ayval_a = 0;
this->ayval_b = 0;
this->ayval_c = 0;
this->ayval_n = 0;
this->ay_envel_value = 0;
this->ay_envel_way = 0;
this->sound_bit = 0;
this->contended_zone = false;
this->no_contention = false;
this->cicles_counter=0;
this->tstados_counter_sound = 0;
this->num_buff = 0; // first buffer
this->sound_cuantity = 0;
this->sound_current_value = 0;
this->interr = 0;
OOTape->register_signal("pause_tape",this);
......@@ -128,8 +103,8 @@ byte computer::bus_empty () {
void computer::emulate (int tstados) {
screen->show_screen (tstados);
play_ay (tstados);
play_sound (tstados);
spk_ay->play_ay (tstados);
spk_ay->play_sound (tstados);
OOTape->play(tstados);
microdrive->emulate(tstados);
......@@ -173,19 +148,7 @@ void ResetComputer () {
Z80free_reset (&procesador);
load_rom (ordenador->mode128k);
// reset the AY-3-8912
for (bucle = 0; bucle < 16; bucle++)
ordenador->ay_registers[bucle] = 0;
ordenador->aych_a = 0;
ordenador->aych_b = 0;
ordenador->aych_c = 0;
ordenador->aych_n = 0;
ordenador->aych_envel = 0;
ordenador->vol_a = 0;
ordenador->vol_b = 0;
ordenador->vol_c = 0;
ordenador->updown=0;
ordenador->leftright=0;
......@@ -210,6 +173,7 @@ void ResetComputer () {
Z80free_Out (0x7FFD, 0);
break;
}
spk_ay->reset();
keyboard->reset();
screen->reset(ordenador->mode128k);
microdrive->reset();
......@@ -338,13 +302,12 @@ void Z80free_Out (register word Port, register byte Value) {
// Sound chip (AY-3-8912)
if (((Port|maskport) == 0xFFFD)&&(ordenador->ay_emul))
ordenador->ay_latch = ((unsigned int) (Value & 0x0F));
if (((Port|maskport) == 0xFFFD) && (spk_ay->ay_emul)) {
spk_ay->set_latch(Value &0x0F);
}
if (((Port|maskport) == 0xBFFD)&&(ordenador->ay_emul)) {
ordenador->ay_registers[ordenador->ay_latch] = (unsigned char) Value;
if (ordenador->ay_latch == 13)
ordenador->ay_envel_way = 2; // start cycle
if (((Port|maskport) == 0xBFFD)&&(spk_ay->ay_emul)) {
spk_ay->set_value(Value);
}
}
......@@ -413,8 +376,8 @@ byte Z80free_In (register word Port) {
}
}
if ((temporal_io == 0xFFFD)&&(ordenador->ay_emul))
return (ordenador->ay_registers[ordenador->ay_latch]);
if ((temporal_io == 0xFFFD)&&(spk_ay->ay_emul))
return (spk_ay->get_value());
// Microdrive access
......
......@@ -56,22 +56,8 @@ public:
unsigned char updown,leftright;
// sound global variables
// Sound variables
unsigned char sound_bit;
unsigned int tstados_counter_sound;
unsigned char num_buff;
unsigned int sound_cuantity; // counter for the buffer
unsigned char ay_registers[16]; // registers for the 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 ay_emul; // 0: no AY emulation; 1: AY emulation
unsigned char vol_a,vol_b,vol_c;
unsigned int tst_ay;
unsigned int tst_ay2;
unsigned int ay_latch;
signed char ay_envel_value;
unsigned char ay_envel_way;
unsigned char sound_current_value;
// bus global variables
......
......@@ -34,6 +34,7 @@
#include "cmdline.hh"
#include "llsound.hh"
#include "keyboard.hh"
#include "spk_ay.hh"
char debug_var=1;
......@@ -206,7 +207,7 @@ void save_config(struct computer *object) {
fprintf(fconfig,"mode=%c%c",48+object->mode128k,10);
fprintf(fconfig,"issue=%c%c",48+object->issue,10);
fprintf(fconfig,"joystick=%c%c",48+keyboard->joystick,10);
fprintf(fconfig,"ay_sound=%c%c",48+object->ay_emul,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,"volume=%c%c",65+(llsound->volume/4),10);
......@@ -299,7 +300,7 @@ void load_config(struct computer *object) {
keyboard->joystick=joystick;
}
if (ay_emul<2) {
object->ay_emul=ay_emul;
spk_ay->ay_emul=ay_emul;
}
if (mdr_active<2) {
microdrive->mdr_active=mdr_active;
......@@ -354,6 +355,7 @@ int main(int argc,char *argv[]) {
keyboard = new Keyboard();
ordenador = new computer();
microdrive = new Microdrive();
spk_ay = new SPK_AY();
load_config(ordenador);
......
......@@ -37,6 +37,7 @@
#include "llsound.hh"
#include "keyboard.hh"
#include "microdrive.hh"
#include "spk_ay.hh"
// shows the settings menu
......@@ -190,7 +191,7 @@ void settings_menu() {
}
llscreen->print_string(texto,-1,3,13,0);
if(ordenador->ay_emul)
if(spk_ay->ay_emul)
sprintf(texto,"AY-3-8912 Emulation: enabled");
else
sprintf(texto,"AY-3-8912 Emulation: disabled");
......@@ -265,38 +266,38 @@ void settings_menu() {
case SDLK_1:
ordenador->issue=2;
ordenador->mode128k=0;
ordenador->ay_emul=0;
spk_ay->ay_emul=0;
ResetComputer();
break;
case SDLK_2:
ordenador->issue=3;
ordenador->mode128k=0;
ordenador->ay_emul=0;
spk_ay->ay_emul=0;
ResetComputer();
break;
case SDLK_3:
ordenador->issue=3;
ordenador->mode128k=1;
ordenador->ay_emul=1;
spk_ay->ay_emul=1;
ResetComputer();
break;
case SDLK_4:
ordenador->issue=3;
ordenador->mode128k=2;
ordenador->ay_emul=1;
spk_ay->ay_emul=1;
ResetComputer();
break;
case SDLK_5:
ordenador->issue=3;
ordenador->mode128k=3;
ordenador->ay_emul=1;
spk_ay->ay_emul=1;
microdrive->mdr_active=0;
ResetComputer();
break;
case SDLK_6:
ordenador->issue=3;
ordenador->mode128k=4;
ordenador->ay_emul=1;
spk_ay->ay_emul=1;
ResetComputer();
break;
case SDLK_7:
......@@ -321,7 +322,7 @@ void settings_menu() {
ordenador->dblscan = !ordenador->dblscan;
break;
case SDLK_a:
ordenador->ay_emul=1-ordenador->ay_emul;
spk_ay->ay_emul=1 - spk_ay->ay_emul;
break;
case SDLK_v:
ordenador->bw = !ordenador->bw;
......
This diff is collapsed.
......@@ -17,10 +17,42 @@
*
*/
#include <inttypes.h>
#ifndef H_SPK_AY
#define H_SPK_AY
void play_ay (int);
void play_sound (int);
class SPK_AY {
unsigned int tstados_counter_sound;
unsigned char num_buff;
unsigned int sound_cuantity; // counter for the buffer
unsigned char ay_registers[16]; // registers for the 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 vol_a,vol_b,vol_c;
unsigned int tst_ay;
unsigned int tst_ay2;
uint8_t ay_latch;
signed char ay_envel_value;
unsigned char ay_envel_way;
unsigned char sound_current_value;
public:
unsigned char ay_emul; // 0: no AY emulation; 1: AY emulation
SPK_AY();
void play_ay (int);
void play_sound (int);
void reset();
void set_latch(byte);
void set_value(byte);
byte get_latch();
byte get_value();
byte get_value(int);
};
extern class SPK_AY *spk_ay;
#endif
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