Commit 367a6623 authored by Sergio Costas's avatar Sergio Costas

First test for better contention

parent d838d4dc
......@@ -133,7 +133,7 @@ void computer::do_contention() {
return;
}
int ccicles=(this->cicles_counter-14335) % 8;
int ccicles = (this->cicles_counter - 14335) % 8;
if (ccicles>5) {
return;
......@@ -151,8 +151,6 @@ void ResetComputer () {
Z80free_reset (&procesador);
load_rom (ordenador->current_mode);
ordenador->updown=0;
ordenador->leftright=0;
......@@ -189,6 +187,8 @@ void Z80free_Wr (word Addr, byte Value) {
ordenador->do_contention();
}
ordenador->write_memory(Addr,Value);
ordenador->emulate(1);
ordenador->contended_cicles += 1;
}
void computer::write_memory (uint16_t Addr, uint8_t Value) {
......@@ -231,6 +231,8 @@ byte Z80free_Rd (word Addr) {
if ((Addr & 0xC000) == 0x4000) {
ordenador->do_contention();
}
ordenador->emulate(1);
ordenador->contended_cicles += 1;
return (ordenador->read_memory(Addr));
}
}
......
......@@ -52,6 +52,7 @@ public:
bool contended_zone; // 0-> no contention; 1-> contention possible
int cicles_counter; // counts how many pixel clock cicles passed since las interrupt
int contended_cicles; // cicles used during contention (must not be counted after ending the execution of an instruction)
// Linux joystick private global variables
......
......@@ -503,12 +503,13 @@ int main(int argc,char *argv[]) {
while(salir) {
do {
ordenador->contended_cicles = 0;
tstados=Z80free_ustep(&procesador);
if(tstados<0) {
printf("Error %X\n",procesador.PC);
exit(1);
}
ordenador->emulate(tstados); // execute the whole hardware emulation for that number of TSTATES
ordenador->emulate(tstados - ordenador->contended_cicles); // execute the whole hardware emulation for that number of TSTATES
} while(procesador.Status!=Z80XX);
PC=procesador.PC;
......@@ -524,10 +525,10 @@ int main(int argc,char *argv[]) {
}
continue;
}
/* if PC is 0x04C2, a call to SA_BYTES has been made, so if
we want to save to the TAP file, we do it */
if((!microdrive->mdr_paged) && ((PC==0x04C2) || (PC == 0x04C6)) && (ordenador->tape_write==1) && (ordenador->page48k == 1)) {
if(ordenador->current_tap == "") {
......@@ -573,24 +574,24 @@ int main(int argc,char *argv[]) {
ordenador->other_ret = 1; // next instruction must be RET
continue;
}
/* if ordenador->mdr_paged is 2, we have executed the RET at 0x0700, so
we have to return to the classic ROM */
if(microdrive->mdr_paged == 2) {
microdrive->mdr_paged = 0;
}
/* if PC is 0x0008 or 0x1708, and we have a microdrive, we have to page
the Interface 1 ROM */
if(((PC==0x0008)||(PC==0x1708))&&(microdrive->mdr_active)) {
microdrive->mdr_paged = 1;
}
/* if PC is 0x0700 and we have a microdrive, we have to unpage
the Interface 1 ROM after the last instruction */
if((PC==0x0700)&&(microdrive->mdr_active)) {
microdrive->mdr_paged = 2;
}
......
......@@ -205,8 +205,8 @@ void Screen::show_screen (int tstados) {
ordenador->cicles_counter += tstados;
if (curr_frames!=jump_frames) {
if (this->tstados_counter>=69888) {
this->tstados_counter-=69888;
if (this->tstados_counter >= 69888) {
this->tstados_counter -= 69888;
ordenador->interr = 1;
curr_frames++;
}
......@@ -230,9 +230,7 @@ void Screen::show_screen (int tstados) {
} else {
this->paint_pixels(255, this->border, 0); // paint 8 pixels with BORDER color
}
this->bus_value = 255;
} else {
// is user area. We search for ink and paper colours
......@@ -260,8 +258,9 @@ void Screen::show_screen (int tstados) {
if(this->screen_snow) {
temporal = ordenador->memoria[(((*this->p_translt) + (ordenador->video_offset))&0xFFFFFF00)+(procesador.R)]; // data with snow
this->screen_snow = false; // no more snow for now
} else
} else {
temporal = ordenador->memoria[(*this->p_translt) + ordenador->video_offset]; // data
}
this->p_translt++;
this->p_translt2++;
......
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