Commit 1dc943b1 authored by Sergio Costas's avatar Sergio Costas

Now it emulates better the specific contention points

parent 0b6c18e9
......@@ -62,7 +62,7 @@ computer::computer() {
this->sound_bit = 0;
this->memcontended_zone = 0;
this->iocontended_zone = 0;
this->cicles_counter=0;
this->interr = 0;
......@@ -131,17 +131,16 @@ void computer::emulate (int tstados) {
void computer::do_contention(bool io, word addr) {
if (this->memcontended_zone == 0) {
return;
}
if (ordenador->current_mode == MODE_P3) {
if (((addr & 0xC000) == 0x4000) && (this->memcontended_zone != 0)) {
if ((addr & 0xC000) == 0x4000) {
this->emulate(this->memcontended_zone);
}
} else {
if (io && (this->iocontended_zone != 0) && ((addr & 0x0001) == 0)) {
this->emulate(this->iocontended_zone);
} else {
if (((addr & 0xC000) == 0x4000) && (this->memcontended_zone != 0)) {
this->emulate(this->memcontended_zone);
}
if ((io && ((addr & 0x0001) == 0)) || ((addr & 0xC000) == 0x4000)) {
this->emulate(this->memcontended_zone);
}
}
}
......
......@@ -56,7 +56,6 @@ public:
bool bw;
int memcontended_zone; // memory contended tstates from this instant up to the next non-contended block
int iocontended_zone; // I/O contended tstates from this instant up to the next non-contended block
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)
......
......@@ -230,10 +230,11 @@ void Screen::show_screen (int tstados) {
Z80free_INTserved(&procesador);
}
}
if ((this->tstados_counter % 4) == 0) {
if ((this->tstados_counter < (this->tstates_bordertop)) || (this->tstados_counter >= this->tstates_borderbottom) || ((this->tstados_counter % this->pixancho) >= 128)) {
this->bus_value = 0xFF;
ordenador->memcontended_zone = 0; // no contention here
if ((this->tstados_counter % 4) == this->offset) {
if ((this->tstados_counter < this->tstates_bordertop) || (this->tstados_counter >= this->tstates_borderbottom) || ((this->tstados_counter % this->pixancho) >= 128)) {
// is border
this->bus_value = 255;
if (this->ulaplus) {
this->paint_pixels(255, this->border+24, 0); // paint 8 pixels with BORDER color
} else {
......@@ -246,41 +247,24 @@ void Screen::show_screen (int tstados) {
}
}
if ((this->tstados_counter < this->tstate_contention) || (this->tstados_counter >= this->tstate_contention2)) {
ordenador->memcontended_zone = 0; // no contention here
ordenador->iocontended_zone = 0;
this->bus_value = 0xFF;
} else {
if ((this->tstados_counter >= this->tstate_contention) && (this->tstados_counter < this->tstate_contention2)) {
int p;
if (((this->tstados_counter - this->tstate_contention) % this->pixancho) < 128) {
int zone = ((this->tstados_counter - this->tstate_contention)% this->pixancho) % 8;
switch(zone) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
ordenador->iocontended_zone = 6 - zone;
break;
case 6:
ordenador->iocontended_zone = 0;
break;
case 7:
ordenador->iocontended_zone = 0;
break;
}
switch(zone) {
case 0:
case 5:
this->bus_value = 0xFF;
ordenador->memcontended_zone = 6 - zone;
break;
case 1:
case 3:
ordenador->memcontended_zone = 6 - zone;
p = *this->p_translt;
this->bus_value = ordenador->memoria[p + ordenador->video_offset];
if ((!this->screen_snow) || (rand() % 8)) {
this->bus_value = ordenador->memoria[p + ordenador->video_offset];
} else {
this->bus_value = ordenador->memoria[p + ordenador->video_offset - 1];
}
this->p_translt++;
this->user_pixels = this->bus_value;
break;
......@@ -313,16 +297,10 @@ void Screen::show_screen (int tstados) {
}
}
break;
default:
this->bus_value = 0xFF;
ordenador->memcontended_zone = 0;
ordenador->iocontended_zone = 0;
break;
}
} else {
ordenador->memcontended_zone = 0; // no contention here
ordenador->iocontended_zone = 0;
this->bus_value = 0xFF;
if (this->offset_p3 != 0) {
ordenador->memcontended_zone = (15 - (zone + this->offset_p3)) % 8;
}
}
}
......@@ -412,18 +390,30 @@ void Screen::reset(uint8_t model) {
this->pixancho = 224;
this->pixalto = 312;
this->pixborde_top = 64;
break;
this->tstate_contention = 14335;
this->offset = 2;
this->offset_p3 = 0;
break;
case MODE_128K:
case MODE_P2:
case MODE_P3:
case MODE_128K_SPA:
this->pixborde_top = 63;
this->pixancho = 228;
this->pixalto = 311;
break;
this->tstate_contention = 14361;
this->offset = 0;
this->offset_p3 = 0;
break;
case MODE_P3:
this->pixborde_top = 63;
this->pixancho = 228;
this->pixalto = 311;
this->tstate_contention = 14359;
this->offset = 2;
this->offset_p3 = 6;
break;
}
printf("Reset\n");
this->tstate_contention = this->pixborde_top * this->pixancho - 3;
this->tstados_counter = 0;
ordenador->cicles_counter = 0;
this->pixel = this->base_pixel + this->init_line;
......
......@@ -47,6 +47,8 @@ class Screen {
int tstates_borderbottom;
int tstate_contention;
int tstate_contention2;
int offset;
int offset_p3;
int tstates_screen;
bool screen_snow; // 0-> no emulate snow; 1-> emulate snow
......
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