Commit eab52917 authored by Sergio Costas's avatar Sergio Costas

Merge branch 'better_contention'

parents d838d4dc 4403d930
......@@ -5,7 +5,7 @@ Priority: optional
Build-Depends: build-essential, make, libpulse-dev, libasound2-dev, libsdl1.2-dev
Package: fbzx
Version: 3.1.0
Version: 3.2.0
Architecture: any
Depends: libpulse0,libasound2,libsdl1.2debian,spectrum-roms (>=20081224-1)
Homepage: http://www.rastersoft.com/fbzx.html
......
* Version 3.2.0
* Better memory contention
* Fixed pause block in TZX files
* Version 3.1.0
* Added Kempston Mouse emulation
* Added block 30 support for TZX files
......
Name: fbzx
Version: 3.1.0
Version: 3.2.0
Release: 1
License: GPL3
Summary: A Sinclair ZX Spectrum emulator
......
......@@ -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(CONTENTION_WR);
ordenador->contended_cicles += CONTENTION_WR;
}
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(CONTENTION_RD);
ordenador->contended_cicles += CONTENTION_RD;
return (ordenador->read_memory(Addr));
}
}
......@@ -265,6 +267,8 @@ void Z80free_Out (word Port, byte Value) {
// Microdrive access
register word maskport;
ordenador->emulate(CONTENTION_OUT);
ordenador->contended_cicles += CONTENTION_OUT;
if (((Port&0x0001)==0)||((Port>=0x4000)&&(Port<0x8000))) {
if (ordenador->current_mode != MODE_P3) {
......@@ -335,6 +339,8 @@ byte Z80free_In (word Port) {
static unsigned int temporal_io;
byte pines;
ordenador->emulate(CONTENTION_IN);
ordenador->contended_cicles += CONTENTION_IN;
if (((Port&0x0001)==0)||((Port>=0x4000)&&(Port<0x8000))) {
if (ordenador->current_mode != MODE_P3) {
ordenador->do_contention();
......
......@@ -31,6 +31,11 @@
// #define MUT
#define CONTENTION_RD 3
#define CONTENTION_WR 3
#define CONTENTION_IN 3
#define CONTENTION_OUT 3
extern char salir;
extern class computer *ordenador;
......@@ -52,6 +57,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;
}
......
......@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#include <inttypes.h>
......
......@@ -56,7 +56,7 @@ void help_menu() {
llscreen->clear_screen();
llscreen->print_string("FBZX (3.1.0)",-1,1,15,0);
llscreen->print_string("FBZX (3.2.0)",-1,1,15,0);
llscreen->print_string("Available keys",-1,2,14,0);
llscreen->print_string("Shift:Caps Shift Ctrl:Symbol Shift",-1,4,11,0);
......
......@@ -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++;
......
......@@ -1074,7 +1074,7 @@ public:
return this->next->save_block(file);
}
}
bool read_block(ifstream *file) {
bool load_block(ifstream *file) {
uint16_t length;
// read pilot pulse duration
......@@ -1424,7 +1424,6 @@ bool Tape::load_tzx(string filename) {
break;
case 0x20: // Pause block
block = new PauseBlock(this);
printf("Pause block\n");
break;
case 0x21: // group start
block = new GroupStartBlock();
......@@ -1445,7 +1444,7 @@ bool Tape::load_tzx(string filename) {
block = new InfoBlock();
break;
default:
printf("Block unknown: %X\n",block_type);
printf("Unknown block number: %X\n",block_type);
file->close();
delete (file);
return true;
......
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