Commit 26b0f047 authored by Sergio Costas's avatar Sergio Costas

Moved more functions as class methods

parent 58df9d7a
......@@ -118,10 +118,10 @@ bool computer::callback_receiver(string signal_received, class Signals *object)
/* Returns the bus value when reading a port without a periferial */
byte bus_empty () {
byte computer::bus_empty () {
if (ordenador->mode128k != 3)
return (ordenador->bus_value);
return (screen->bus_value);
else
return (255); // +2A and +3 returns always 255
}
......@@ -129,7 +129,7 @@ byte bus_empty () {
/* calls all the routines that emulates the computer, runing them for 'tstados'
tstates */
void emulate (int tstados) {
void computer::emulate (int tstados) {
screen->show_screen (tstados);
play_ay (tstados);
......@@ -139,13 +139,33 @@ void emulate (int tstados) {
if (!OOTape->get_pause()) {
if (OOTape->read_signal() != 0) {
ordenador->sound_bit = 1;
this->sound_bit = 1;
} else {
ordenador->sound_bit = 0; // if not paused, asign SOUND_BIT the value of tape
this->sound_bit = 0; // if not paused, asign SOUND_BIT the value of tape
}
}
}
// check if there's contention and waits the right number of tstates
void computer::do_contention() {
if (!this->contended_zone)
return;
if (this->cicles_counter<14335) {
return;
}
int ccicles=(this->cicles_counter-14335)%8;
if (ccicles>5) {
return;
}
this->emulate(6-ccicles);
}
// Read the keyboard and stores the flags
......@@ -735,27 +755,6 @@ void ResetComputer () {
microdrive_reset();
}
// check if there's contention and waits the right number of tstates
void do_contention() {
if (!ordenador->contended_zone)
return;
if (ordenador->cicles_counter<14335) {
return;
}
int ccicles=(ordenador->cicles_counter-14335)%8;
if (ccicles>5) {
return;
}
emulate(6-ccicles);
}
void Z80free_Wr (register word Addr, register byte Value) {
switch (Addr & 0xC000) {
......@@ -767,7 +766,7 @@ void Z80free_Wr (register word Addr, register byte Value) {
break;
case 0x4000:
do_contention();
ordenador->do_contention();
*(ordenador->block1 + Addr) = (unsigned char) Value;
break;
......@@ -800,7 +799,7 @@ byte Z80free_Rd (register word Addr) {
break;
case 0x4000:
do_contention();
ordenador->do_contention();
return ((byte) (*(ordenador->block1 + Addr)));
break;
......@@ -828,17 +827,17 @@ void Z80free_Out (register word Port, register byte Value) {
register word maskport;
if (((Port&0x0001)==0)||((Port>=0x4000)&&(Port<0x8000))) {
do_contention();
ordenador->do_contention();
}
// ULAPlus
if (Port == 0xBF3B) {
do_contention();
ordenador->do_contention();
screen->set_ulaplus_register(Value);
return;
}
if (Port == 0xFF3B) {
do_contention();
ordenador->do_contention();
screen->set_ulaplus_value(Value);
}
......@@ -896,13 +895,13 @@ byte Z80free_In (register word Port) {
byte pines;
if (((Port&0x0001)==0)||((Port>=0x4000)&&(Port<0x8000))) {
do_contention();
ordenador->do_contention();
}
temporal_io = (unsigned int) Port;
if (Port == 0xFF3B) {
do_contention();
ordenador->do_contention();
return (screen->read_ulaplus_value());
}
......@@ -962,7 +961,7 @@ byte Z80free_In (register word Port) {
if(((Port &0x0018)!=0x0018)&&(ordenador->mdr_active))
return(microdrive_in(Port));
pines=bus_empty();
pines=ordenador->bus_empty();
return (pines);
}
......
......@@ -134,12 +134,13 @@ public:
computer();
~computer();
bool callback_receiver(string, class Signals *);
byte bus_empty();
void emulate(int);
void do_contention();
};
void read_keyboard(SDL_Event *pevento2);
void fill_audio(void *udata,Uint8 *,int);
void emulate(int);
void ResetComputer();
byte bus_empty();
#endif
......@@ -444,7 +444,7 @@ int main(int argc,char *argv[]) {
printf("Error %X\n",procesador.PC);
exit(1);
}
emulate(tstados); // execute the whole hardware emulation for that number of TSTATES
ordenador->emulate(tstados); // execute the whole hardware emulation for that number of TSTATES
} while(procesador.Status!=Z80XX);
PC=procesador.PC;
......@@ -492,7 +492,7 @@ int main(int argc,char *argv[]) {
if(ordenador->interr==1) {
read_keyboard (NULL); // read the physical keyboard
Z80free_INT(&procesador,bus_empty());
Z80free_INT(&procesador,ordenador->bus_empty());
ordenador->interr=0;
}
}
......
......@@ -187,7 +187,7 @@ to execute last instruction */
void Screen::show_screen (int tstados) {
static unsigned char temporal, ink, paper, fflash, tmp2;
static uint8_t temporal, ink, paper, fflash, tmp2;
if((procesador.I>=0x40)&&(procesador.I<=0x7F)) {
this->screen_snow = true;
......@@ -225,7 +225,7 @@ void Screen::show_screen (int tstados) {
this->paint_pixels(255, this->border, 0); // paint 8 pixels with BORDER color
}
ordenador->bus_value = 255;
this->bus_value = 255;
} else {
......@@ -234,7 +234,7 @@ void Screen::show_screen (int tstados) {
ordenador->contended_zone = true; // can have contention
temporal = ordenador->memoria[(*this->p_translt2) + ordenador->video_offset]; // attributes
ordenador->bus_value = temporal;
this->bus_value = temporal;
ink = temporal & 0x07; // ink colour
paper = (temporal >> 3) & 0x07; // paper colour
if (this->ulaplus) {
......
......@@ -48,6 +48,7 @@ class Screen {
public:
uint8_t border;
bool ulaplus; // ULAPlus inactive or active
uint8_t bus_value;
Screen();
void set_memory_pointers ();
......
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