Commit fd2397c2 authored by Sergio Costas's avatar Sergio Costas

Added support for Kempston Mouse

Added support for block 30h in TZX files

Some code cleanups
parent 19c4daea
...@@ -5,7 +5,7 @@ Priority: optional ...@@ -5,7 +5,7 @@ Priority: optional
Build-Depends: build-essential, make, libpulse-dev, libasound2-dev, libsdl1.2-dev Build-Depends: build-essential, make, libpulse-dev, libasound2-dev, libsdl1.2-dev
Package: fbzx Package: fbzx
Version: 3.0.0 Version: 3.1.0
Architecture: any Architecture: any
Depends: libpulse0,libasound2,libsdl1.2debian,spectrum-roms (>=20081224-1) Depends: libpulse0,libasound2,libsdl1.2debian,spectrum-roms (>=20081224-1)
Homepage: http://www.rastersoft.com/fbzx.html Homepage: http://www.rastersoft.com/fbzx.html
......
* Version 3.1.0
* Added Kempston Mouse emulation
* Added block 30 support for TZX files
* Version 3.0.0 * Version 3.0.0
* Now allows to run in TURBO mode when the tape is playing, and return to NORMAL mode when the tape is paused * Now allows to run in TURBO mode when the tape is playing, and return to NORMAL mode when the tape is paused
* Sorts the files and folders alphabetically * Sorts the files and folders alphabetically
......
Name: fbzx Name: fbzx
Version: 3.0.0 Version: 3.1.0
Release: 1 Release: 1
License: GPL3 License: GPL3
Summary: A Sinclair ZX Spectrum emulator Summary: A Sinclair ZX Spectrum emulator
......
...@@ -55,7 +55,7 @@ llscreen.o: llscreen.cpp osd.hh font.h llscreen.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 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 $(CPP) $(CPPFLAGS) -o llsound.o llsound.cpp
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 menus.o: menus.cpp mouse.hh z80free/Z80free.h spk_ay.hh microdrive.hh 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 $(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 microdrive.o: microdrive.cpp osd.hh emulator.hh screen.hh z80free/Z80free.h computer.hh signals.hh llscreen.hh tape.hh microdrive.hh
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "cargador.hh" #include "cargador.hh"
...@@ -121,13 +121,13 @@ int save_z80(char *filename) { ...@@ -121,13 +121,13 @@ int save_z80(char *filename) {
if (ordenador->issue == 2) if (ordenador->issue == 2)
value |= 4; value |= 4;
switch (keyboard->joystick) { switch (keyboard->joystick) {
case 1: case JOYSTICK_KEMPSTON:
value |= 64; value |= 64;
break; break;
case 2: case JOYSTICK_SINCLAIR1:
value |= 128; value |= 128;
break; break;
case 3: case JOYSTICK_SINCLAIR2:
value |= 192; value |= 192;
break; break;
} }
...@@ -603,7 +603,20 @@ void load_snap(struct z80snapshot *snap) { ...@@ -603,7 +603,20 @@ void load_snap(struct z80snapshot *snap) {
break; break;
} }
keyboard->joystick = snap->joystick; switch (snap->joystick) {
case 0:
keyboard->joystick = JOYSTICK_CURSOR;
break;
case 1:
keyboard->joystick = JOYSTICK_KEMPSTON;
break;
case 2:
keyboard->joystick = JOYSTICK_SINCLAIR1;
break;
case 3:
keyboard->joystick = JOYSTICK_SINCLAIR2;
break;
}
procesador.Rm.br.A = snap->A; procesador.Rm.br.A = snap->A;
procesador.Rm.br.F = snap->F; procesador.Rm.br.F = snap->F;
......
...@@ -215,6 +215,7 @@ void save_config() { ...@@ -215,6 +215,7 @@ void save_config() {
fprintf(fconfig,"bw=%c%c",ordenador->bw ? '1' : '0',10); fprintf(fconfig,"bw=%c%c",ordenador->bw ? '1' : '0',10);
fprintf(fconfig,"fast=%c%c",ordenador->tape_fast_load ? '1' : '0',10); fprintf(fconfig,"fast=%c%c",ordenador->tape_fast_load ? '1' : '0',10);
fprintf(fconfig,"turboload=%c%c",ordenador->turbo_play ? '1' : '0',10); fprintf(fconfig,"turboload=%c%c",ordenador->turbo_play ? '1' : '0',10);
fprintf(fconfig,"mouse=%c%c",mouse->enabled ? '1' : '0',10);
fclose(fconfig); fclose(fconfig);
} }
...@@ -224,7 +225,7 @@ void load_config() { ...@@ -224,7 +225,7 @@ void load_config() {
char line[1024],carac,done; char line[1024],carac,done;
int length,pos; int length,pos;
FILE *fconfig; FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,joystick=255,ay_emul=255,mdr_active=255,dblscan=255,bw,fast,turboload=255; unsigned char volume=255,mode128k=255,issue=255,joystick=255,ay_emul=255,mdr_active=255,dblscan=255,bw=255,fast=255,turboload=255,mouse_enabled=255;
strcpy(config_path,getenv("HOME")); strcpy(config_path,getenv("HOME"));
length=strlen(config_path); length=strlen(config_path);
...@@ -299,6 +300,10 @@ void load_config() { ...@@ -299,6 +300,10 @@ void load_config() {
turboload=(line[10]-'0'); turboload=(line[10]-'0');
continue; continue;
} }
if (!strncmp(line,"mouse=",6)) {
mouse_enabled=(line[6]-'0');
continue;
}
} }
if (mode128k<5) { if (mode128k<5) {
...@@ -308,7 +313,20 @@ void load_config() { ...@@ -308,7 +313,20 @@ void load_config() {
ordenador->issue=issue; ordenador->issue=issue;
} }
if (joystick<4) { if (joystick<4) {
keyboard->joystick=joystick; switch (joystick) {
case 0:
keyboard->joystick = JOYSTICK_CURSOR;
break;
case 1:
keyboard->joystick = JOYSTICK_KEMPSTON;
break;
case 2:
keyboard->joystick = JOYSTICK_SINCLAIR1;
break;
case 3:
keyboard->joystick = JOYSTICK_SINCLAIR2;
break;
}
} }
if (ay_emul<2) { if (ay_emul<2) {
spk_ay->ay_emul=ay_emul; spk_ay->ay_emul=ay_emul;
...@@ -328,6 +346,9 @@ void load_config() { ...@@ -328,6 +346,9 @@ void load_config() {
if (turboload<2) { if (turboload<2) {
ordenador->turbo_play = turboload==0 ? false : true; ordenador->turbo_play = turboload==0 ? false : true;
} }
if (mouse_enabled<2) {
mouse->enabled = mouse_enabled==0 ? false : true;
}
if (volume<255) { if (volume<255) {
llsound->set_volume(volume); llsound->set_volume(volume);
} }
......
...@@ -23,7 +23,7 @@ Keyboard::Keyboard() { ...@@ -23,7 +23,7 @@ Keyboard::Keyboard() {
this->jk = 0x00; this->jk = 0x00;
this->readed = 0; this->readed = 0;
this->joystick = 0; this->joystick = JOYSTICK_CURSOR;
this->mouse_x = 0; this->mouse_x = 0;
this->mouse_y = 0; this->mouse_y = 0;
this->mouse_left = false; this->mouse_left = false;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <inttypes.h> #include <inttypes.h>
#include <SDL/SDL.h> #include <SDL/SDL.h>
enum JOYSTICK_TYPE { JOYSTICK_CURSOR, JOYSTICK_KEMPSTON, JOYSTICK_SINCLAIR1, JOYSTICK_SINCLAIR2};
class Keyboard { class Keyboard {
// keyboard private global variables // keyboard private global variables
...@@ -29,7 +31,7 @@ public: ...@@ -29,7 +31,7 @@ public:
uint8_t s8,s9,s10,s11,s12,s13,s14,s15; uint8_t s8,s9,s10,s11,s12,s13,s14,s15;
uint8_t js; uint8_t js;
uint8_t joystick; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2 enum JOYSTICK_TYPE joystick; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2
int32_t mouse_x; int32_t mouse_x;
int32_t mouse_y; int32_t mouse_y;
bool mouse_left; bool mouse_left;
......
...@@ -534,7 +534,7 @@ void LLScreen::clear_screen() { ...@@ -534,7 +534,7 @@ void LLScreen::clear_screen() {
// prints the string CADENA in X,Y (centered if X=-1), with colors COLOR and BACK // prints the string CADENA in X,Y (centered if X=-1), with colors COLOR and BACK
void LLScreen::print_string(string o_cadena, int16_t x, int16_t y, uint8_t ink, uint8_t paper) { void LLScreen::print_string(string o_cadena, int16_t x, float y, uint8_t ink, uint8_t paper) {
int length, ncarac, bucle, xx; int length, ncarac, bucle, xx;
uint16_t xxx, yyy; uint16_t xxx, yyy;
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
LLScreen(int16_t resx, int16_t resy, uint8_t depth, bool fullscreen, bool dblbuffer, bool hwsurface); LLScreen(int16_t resx, int16_t resy, uint8_t depth, bool fullscreen, bool dblbuffer, bool hwsurface);
~LLScreen(); ~LLScreen();
ifstream *myfopen(string,ios_base::openmode); ifstream *myfopen(string,ios_base::openmode);
void print_string(string message, int16_t x, int16_t y, uint8_t ink, uint8_t paper); void print_string(string message, int16_t x, float y, uint8_t ink, uint8_t paper);
void set_paletes(bool); void set_paletes(bool);
void paint_one_pixel(uint8_t value,unsigned char *address); void paint_one_pixel(uint8_t value,unsigned char *address);
void fullscreen_switch(); void fullscreen_switch();
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -38,13 +38,14 @@ ...@@ -38,13 +38,14 @@
#include "keyboard.hh" #include "keyboard.hh"
#include "microdrive.hh" #include "microdrive.hh"
#include "spk_ay.hh" #include "spk_ay.hh"
#include "mouse.hh"
// shows the settings menu // shows the settings menu
void print_copy() { void print_copy() {
llscreen->print_string("(C) 2012 Fabio Olimpieri",-1,-1,13,0); llscreen->print_string("(C) 2012 Fabio Olimpieri",-1,-1,13,0);
llscreen->print_string("(C) 2003-2015 Raster Software Vigo",-1,-2,13,0); llscreen->print_string("(C) 2003-2016 Raster Software Vigo",-1,-2,13,0);
} }
// shows the help menu // shows the help menu
...@@ -55,7 +56,7 @@ void help_menu() { ...@@ -55,7 +56,7 @@ void help_menu() {
llscreen->clear_screen(); llscreen->clear_screen();
llscreen->print_string("FBZX (3.0.0)",-1,1,15,0); llscreen->print_string("FBZX (3.1.0)",-1,1,15,0);
llscreen->print_string("Available keys",-1,2,14,0); llscreen->print_string("Available keys",-1,2,14,0);
llscreen->print_string("Shift:Caps Shift Ctrl:Symbol Shift",-1,4,11,0); llscreen->print_string("Shift:Caps Shift Ctrl:Symbol Shift",-1,4,11,0);
...@@ -155,106 +156,115 @@ void settings_menu() { ...@@ -155,106 +156,115 @@ void settings_menu() {
switch(ordenador->mode128k) { switch(ordenador->mode128k) {
case 0: case 0:
if(ordenador->issue==2) if(ordenador->issue==2)
sprintf(texto,"Mode: 48K issue2"); sprintf(texto,"Mode: \001\01648K issue2");
else else
sprintf(texto,"Mode: 48K issue3"); sprintf(texto,"Mode: \001\01648K issue3");
break; break;
case 1: case 1:
sprintf(texto,"Mode: Sinclair 128K"); sprintf(texto,"Mode: \001\016Sinclair 128K");
break; break;
case 2: case 2:
sprintf(texto,"Mode: Amstrad +2"); sprintf(texto,"Mode: \001\016Amstrad +2");
break; break;
case 3: case 3:
sprintf(texto,"Mode: Amstrad +2A/+3"); sprintf(texto,"Mode: \001\016Amstrad +2A/+3");
break; break;
case 4: case 4:
sprintf(texto,"Mode: Spanish 128K"); sprintf(texto,"Mode: \001\016Spanish 128K");
break; break;
} }
llscreen->print_string(texto,-1,2,14,0); llscreen->print_string(texto,-1,2,15,0);
switch(keyboard->joystick) { switch(keyboard->joystick) {
case 0: case 0:
sprintf(texto,"Joystick emulation: Cursor"); sprintf(texto,"Joystick emulation: \001\016Cursor");
break; break;
case 1: case 1:
sprintf(texto,"Joystick emulation: Kempston"); sprintf(texto,"Joystick emulation: \001\016Kempston");
break; break;
case 2: case 2:
sprintf(texto,"Joystick emulation: Sinclair (1)"); sprintf(texto,"Joystick emulation: \001\016Sinclair (1)");
break; break;
case 3: case 3:
sprintf(texto,"Joystick emulation: Sinclair (2)"); sprintf(texto,"Joystick emulation: \001\016Sinclair (2)");
break; break;
} }
llscreen->print_string(texto,-1,3,13,0); llscreen->print_string(texto,-1,3.2,15,0);
if(spk_ay->ay_emul) if(spk_ay->ay_emul)
sprintf(texto,"AY-3-8912 Emulation: enabled"); sprintf(texto,"AY-3-8912 Emulation: \001\014enabled");
else else
sprintf(texto,"AY-3-8912 Emulation: disabled"); sprintf(texto,"AY-3-8912 Emulation: \001\013disabled");
llscreen->print_string(texto,-1,4,11,0); llscreen->print_string(texto,-1,4.4,15,0);
if(microdrive->mdr_active) if(microdrive->mdr_active)
sprintf(texto,"Interface I Emulation: enabled"); sprintf(texto,"Interface I Emulation: \001\014enabled");
else else
sprintf(texto,"Interface I Emulation: disabled"); sprintf(texto,"Interface I Emulation: \001\013disabled");
llscreen->print_string(texto,-1,5,15,0); llscreen->print_string(texto,-1,5.6,15,0);
if(ordenador->dblscan) if(ordenador->dblscan)
sprintf(texto,"Double scan: enabled"); sprintf(texto,"Double scan: \001\014enabled");
else else
sprintf(texto,"Double scan: disabled"); sprintf(texto,"Double scan: \001\013disabled");
llscreen->print_string(texto,-1,6,12,0); llscreen->print_string(texto,-1,6.8,15,0);
if(ordenador->turbo) if(ordenador->turbo)
sprintf(texto,"TURBO mode: enabled"); sprintf(texto,"TURBO mode: \001\014enabled");
else else
sprintf(texto,"TURBO mode: disabled"); sprintf(texto,"TURBO mode: \001\013disabled");
llscreen->print_string(texto,-1,7,14,0); llscreen->print_string(texto,-1,8,15,0);
if (ordenador->bw) { if (ordenador->bw) {
llscreen->print_string("TV Set: \001\011B\001\012&\001\014W",-1,8,15,0); llscreen->print_string("TV Set: \001\011B\001\012&\001\014W",-1,9.2,15,0);
} else { } else {
llscreen->print_string("TV Set: \001\012C\001\014o\001\015l\001\016o\001\013r",-1,8,15,0); llscreen->print_string("TV Set: \001\012C\001\014o\001\015l\001\016o\001\013r",-1,9.2,15,0);
} }
llscreen->print_string("1: \001\01748K issue2",30,10,12,0); if(mouse->enabled) {
sprintf(texto,"Kempston Mouse: \001\014enabled");
} else {
sprintf(texto,"Kempston Mouse: \001\013disabled");
}
llscreen->print_string(texto,-1,10.4,15,0);
llscreen->print_string("1: \001\01748K issue2",30,15,12,0);
llscreen->print_string("2: \001\01748K issue3",213,15,12,0);
llscreen->print_string("2: \001\01748K issue3",213,10,12,0); llscreen->print_string("3: \001\017Sinclair 128K",426,15,12,0);
llscreen->print_string("3: \001\017Sinclair 128K",426,10,12,0); llscreen->print_string("4: \001\017Amstrad +2",30,16.5,12,0);
llscreen->print_string("4: \001\017Amstrad +2",30,12,12,0); llscreen->print_string("5: \001\017Amstrad +2A/+3",213,16.5,12,0);
llscreen->print_string("5: \001\017Amstrad +2A/+3",213,12,12,0); llscreen->print_string("6: \001\017Spanish 128K",426,16.5,12,0);
llscreen->print_string("6: \001\017Spanish 128K",426,12,12,0); llscreen->print_string("7: \001\017Cursor",30,18,12,0);
llscreen->print_string("7: \001\017Cursor",30,14,12,0); llscreen->print_string("8: \001\017Kempston",213,18,12,0);
llscreen->print_string("8: \001\017Kempston",213,14,12,0); llscreen->print_string("9: \001\017Sinclair (1)",426,18,12,0);
llscreen->print_string("9: \001\017Sinclair (1)",426,14,12,0); llscreen->print_string("0: \001\017Sinclair (2)",30,19.5,12,0);
llscreen->print_string("0: \001\017Sinclair (2)",30,16,12,0); llscreen->print_string("I: \001\017Interface I",213,19.5,12,0);
llscreen->print_string("I: \001\017Interface I",213,16,12,0); llscreen->print_string("A: \001\017AY emulation",426,19.5,12,0);
llscreen->print_string("A: \001\017AY emulation",426,16,12,0); llscreen->print_string("T: \001\017TURBO mode",30,21,12,0);
llscreen->print_string("T: \001\017TURBO mode",30,18,12,0); llscreen->print_string("D: \001\017Double Scan",213,21,12,0);
llscreen->print_string("D: \001\017Double Scan",213,18,12,0); llscreen->print_string("V: \001\017TV Set mode",426,21,12,0);
llscreen->print_string("V: \001\017TV Set mode",426,18,12,0); llscreen->print_string("K: \001\017Kempston Mouse",30,22.5,12,0);
llscreen->print_string("ESC: \001\017return to emulator",-1,22,12,0); llscreen->print_string("ESC: \001\017return to emulator",-1,24,12,0);
print_copy(); print_copy();
...@@ -301,16 +311,17 @@ void settings_menu() { ...@@ -301,16 +311,17 @@ void settings_menu() {
ResetComputer(); ResetComputer();
break; break;
case SDLK_7: case SDLK_7:
keyboard->joystick=0; keyboard->joystick=JOYSTICK_CURSOR;
break; break;
case SDLK_8: case SDLK_8:
keyboard->joystick=1; keyboard->joystick=JOYSTICK_KEMPSTON;
mouse->enabled = false; // Kempston joystick and Kempston mouse are incompatible
break; break;
case SDLK_9: case SDLK_9:
keyboard->joystick=2; keyboard->joystick=JOYSTICK_SINCLAIR1;
break; break;
case SDLK_0: case SDLK_0:
keyboard->joystick=3; keyboard->joystick=JOYSTICK_SINCLAIR2;
break; break;
case SDLK_i: case SDLK_i:
if(ordenador->mode128k!=3) { if(ordenador->mode128k!=3) {
...@@ -335,6 +346,16 @@ void settings_menu() { ...@@ -335,6 +346,16 @@ void settings_menu() {
ordenador->turbo = true; ordenador->turbo = true;
} }
llsound->set_speed(ordenador->turbo); llsound->set_speed(ordenador->turbo);
break;
case SDLK_k:
if(mouse->enabled) {
mouse->enabled = false;
} else {
mouse->enabled = true;
if (keyboard->joystick == JOYSTICK_KEMPSTON) {
keyboard->joystick = JOYSTICK_CURSOR; // Kempston joystick and Kempston mouse are incompatible
}
}
} }
} while(fin); } while(fin);
......
...@@ -15,27 +15,21 @@ void Mouse::reset() { ...@@ -15,27 +15,21 @@ void Mouse::reset() {
this->x = 0; this->x = 0;
this->y = 0; this->y = 0;
this->button = 255; this->button = 255;
this->enabled = true;
} }
Mouse::Mouse() { Mouse::Mouse() {
this->enabled = false;
this->reset(); this->reset();
} }
void Mouse::emulate(int tstates) { void Mouse::emulate(int tstates) {
unsigned int diffx = keyboard->mouse_x - this->posx; uint8_t diffx = (keyboard->mouse_x - this->posx)/2;
unsigned int diffy = keyboard->mouse_y - this->posy; uint8_t diffy = (keyboard->mouse_y - this->posy)/2;
this->posx = keyboard->mouse_x; this->posx = keyboard->mouse_x;
this->posy = keyboard->mouse_y; this->posy = keyboard->mouse_y;
if (diffx < 2) {
diffx=0;
}
if (diffy < 2) {
diffy=0;
}
this->x += diffx; this->x += diffx;
this->y -= diffy; this->y -= diffy;
this->button = 255; this->button = 255;
......
...@@ -392,4 +392,3 @@ uint8_t Screen::read_ulaplus_value() { ...@@ -392,4 +392,3 @@ uint8_t Screen::read_ulaplus_value() {
} }
return 0; return 0;
} }
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