Commit 33fb0536 authored by Sergio Costas's avatar Sergio Costas

Passed all the code through uncrustify

parent 85e33c3d
This diff is collapsed.
...@@ -22,23 +22,21 @@ ...@@ -22,23 +22,21 @@
#include "z80free/Z80free.h" #include "z80free/Z80free.h"
struct z80snapshot { struct z80snapshot {
byte A, F, B, C, D, E, H, L, AA, FF, BB, CC, DD, EE, HH, LL, R, I, IFF1, IFF2, Imode;
byte A,F,B,C,D,E,H,L,AA,FF,BB,CC,DD,EE,HH,LL,R,I,IFF1,IFF2,Imode; bool issue_3;
bool issue_3; word PC, IX, IY, SP;
word PC,IX,IY,SP; byte type; // bit 0/1: 48K/128K/+3
byte type; // bit 0/1: 48K/128K/+3 byte border; // border color
byte border; // border color byte pager; // content of pagination register in 128K mode
byte pager; // content of pagination register in 128K mode unsigned char page[12][16384];
unsigned char page[12][16384]; unsigned int found_pages; // bit=1: page exists. bit=0: page don't exists.
unsigned int found_pages; // bit=1: page exists. bit=0: page don't exists. unsigned char ay_regs[16];
unsigned char ay_regs[16]; unsigned char ay_latch;
unsigned char ay_latch; unsigned char joystick;
unsigned char joystick;
}; };
int save_z80(char *); int save_z80(char *);
int load_z80(const char *); int load_z80(const char *);
int load_sna(const char *); int load_sna(const char *);
void load_snap(struct z80snapshot *); void load_snap(struct z80snapshot *);
void uncompress_z80(FILE *,int,unsigned char *); void uncompress_z80(FILE *, int, unsigned char *);
...@@ -12,31 +12,30 @@ using namespace std; ...@@ -12,31 +12,30 @@ using namespace std;
#include <stdlib.h> #include <stdlib.h>
#include "cmdline.hh" #include "cmdline.hh"
CMDLine::CMDLine(int argc,char **argv) { CMDLine::CMDLine(int argc, char **argv) {
int argumento; int argumento;
this->nosound = false; this->nosound = false;
this->mini = false; this->mini = false;
this->pulse = false; this->pulse = false;
this->alsa = false; this->alsa = false;
this->oss = false; this->oss = false;
this->rotate = false; this->rotate = false;
this->fs = false; this->fs = false;
this->hw = false; this->hw = false;
this->db = false; this->db = false;
this->ds = false; this->ds = false;
this->bw = false; this->bw = false;
this->color = false; this->color = false;
this->ss = false; this->ss = false;
this->jump = 0; this->jump = 0;
this->setres = false; this->setres = false;
this->gamefile = ""; this->gamefile = "";
argumento = 0; argumento = 0;
while(argumento<argc) { while (argumento < argc) {
if ((0==strcmp(argv[argumento],"-h"))||(0==strcmp(argv[argumento],"--help"))) { if ((0 == strcmp(argv[argumento], "-h")) || (0 == strcmp(argv[argumento], "--help"))) {
printf("\nUsage: fbzx [-nosound] "); printf("\nUsage: fbzx [-nosound] ");
#ifdef D_SOUND_ALSA #ifdef D_SOUND_ALSA
printf("[-alsa] "); printf("[-alsa] ");
...@@ -73,65 +72,64 @@ CMDLine::CMDLine(int argc,char **argv) { ...@@ -73,65 +72,64 @@ CMDLine::CMDLine(int argc,char **argv) {
printf(" -setres: when setting fullscreen mode, try to change the screen resolution\n"); printf(" -setres: when setting fullscreen mode, try to change the screen resolution\n");
printf(" gamefile: an optional .Z80 snapshot or .TAP/.TZX tape file\n\n"); printf(" gamefile: an optional .Z80 snapshot or .TAP/.TZX tape file\n\n");
exit(0); exit(0);
} else if(0==strcmp(argv[argumento],"-nosound")) { } else if (0 == strcmp(argv[argumento], "-nosound")) {
this->nosound = true; this->nosound = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-mini")) { } else if (0 == strcmp(argv[argumento], "-mini")) {
this->mini = true; this->mini = true;
argumento++; argumento++;
#ifdef D_SOUND_PULSE #ifdef D_SOUND_PULSE
} else if(0==strcmp(argv[argumento],"-pulse")) { } else if (0 == strcmp(argv[argumento], "-pulse")) {
this->pulse = true; this->pulse = true;
argumento++; argumento++;
#endif #endif
#ifdef D_SOUND_ALSA #ifdef D_SOUND_ALSA
} else if(0==strcmp(argv[argumento],"-alsa")) { } else if (0 == strcmp(argv[argumento], "-alsa")) {
this->alsa = true; this->alsa = true;
argumento++; argumento++;
#endif #endif
#ifdef D_SOUND_OSS #ifdef D_SOUND_OSS
} else if(0==strcmp(argv[argumento],"-oss")) { } else if (0 == strcmp(argv[argumento], "-oss")) {
this->oss = true; this->oss = true;
argumento++; argumento++;
#endif #endif
} else if(0==strcmp(argv[argumento],"-rotate")) { } else if (0 == strcmp(argv[argumento], "-rotate")) {
this->rotate = true; this->rotate = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-fs")) { } else if (0 == strcmp(argv[argumento], "-fs")) {
this->fs = true; this->fs = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-setres")) { } else if (0 == strcmp(argv[argumento], "-setres")) {
this->setres = true; this->setres = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-hw")) { } else if (0 == strcmp(argv[argumento], "-hw")) {
this->hw = true; this->hw = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-db")) { } else if (0 == strcmp(argv[argumento], "-db")) {
this->db = true; this->db = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-ds")) { } else if (0 == strcmp(argv[argumento], "-ds")) {
this->ds = true; this->ds = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-bw")) { } else if (0 == strcmp(argv[argumento], "-bw")) {
this->bw = true; this->bw = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-color")) { } else if (0 == strcmp(argv[argumento], "-color")) {
this->color = true; this->color = true;
argumento++; argumento++;
} else if(0==strcmp(argv[argumento],"-ss")) { } else if (0 == strcmp(argv[argumento], "-ss")) {
this->ss = true; this->ss = true;
argumento++; argumento++;
} else if(0==strncmp(argv[argumento],"-jump",5)) { } else if (0 == strncmp(argv[argumento], "-jump", 5)) {
/*jump_frames=(int)(argv[argumento][5]); /*jump_frames=(int)(argv[argumento][5]);
jump_frames-=48;*/ * jump_frames-=48;*/
this->jump = (int)(argv[argumento][5]); this->jump = (int) (argv[argumento][5]);
this->jump -= '0'; this->jump -= '0';
argumento++; argumento++;
} else { } else {
this->gamefile = argv[argumento]; this->gamefile = argv[argumento];
//strcpy(this->gamefile,argv[argumento]); // strcpy(this->gamefile,argv[argumento]);
argumento++; argumento++;
} }
} }
} }
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
#define SRC_CMDLINE_HH_ #define SRC_CMDLINE_HH_
class CMDLine { class CMDLine {
public: public:
bool nosound; bool nosound;
bool mini; bool mini;
bool pulse; bool pulse;
...@@ -29,11 +27,7 @@ public: ...@@ -29,11 +27,7 @@ public:
int jump; int jump;
string gamefile; string gamefile;
CMDLine(int argc,char **argv); CMDLine(int argc, char **argv);
}; };
#endif /* SRC_CMDLINE_HH_ */ #endif /* SRC_CMDLINE_HH_ */
This diff is collapsed.
...@@ -31,21 +31,40 @@ ...@@ -31,21 +31,40 @@
// #define MUT // #define MUT
#define CONTENTION_RD 3 #define CONTENTION_RD 3
#define CONTENTION_WR 3 #define CONTENTION_WR 3
#define CONTENTION_IN 3 #define CONTENTION_IN 3
#define CONTENTION_OUT 3 #define CONTENTION_OUT 3
extern char salir; extern char salir;
extern class computer *ordenador; extern class computer *ordenador;
enum tapmodes {TAP_GUIDE, TAP_DATA, TAP_PAUSE, TAP_TRASH, TAP_STOP, TAP_PAUSE2, TZX_PURE_TONE, enum tapmodes {
TZX_SEQ_PULSES, TAP_FINAL_BIT, TAP_PAUSE3}; TAP_GUIDE,
TAP_DATA,
TAP_PAUSE,
TAP_TRASH,
TAP_STOP,
TAP_PAUSE2,
TZX_PURE_TONE,
TZX_SEQ_PULSES,
TAP_FINAL_BIT,
TAP_PAUSE3
};
enum taptypes {TAP_TAP, TAP_TZX}; enum taptypes {
TAP_TAP,
TAP_TZX
};
enum CurrentMode {MODE_48K, MODE_128K, MODE_P2, MODE_P3, MODE_128K_SPA}; enum CurrentMode {
MODE_48K,
MODE_128K,
MODE_P2,
MODE_P3,
MODE_128K_SPA
};
class computer : public Signals { class computer : public Signals {
public: public:
...@@ -56,12 +75,12 @@ public: ...@@ -56,12 +75,12 @@ public:
bool bw; bool bw;
int memcontended_zone; // memory contended tstates from this instant up to the next non-contended block int memcontended_zone; // memory 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 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) int contended_cicles; // cicles used during contention (must not be counted after ending the execution of an instruction)
// Linux joystick private global variables // Linux joystick private global variables
unsigned char updown,leftright; unsigned char updown, leftright;
// Sound variables // Sound variables
unsigned char sound_bit; unsigned char sound_bit;
...@@ -75,26 +94,25 @@ public: ...@@ -75,26 +94,25 @@ public:
enum CurrentMode current_mode; enum CurrentMode current_mode;
unsigned char port254; unsigned char port254;
// tape global variables // tape global variables
string current_tap; string current_tap;
bool tape_write; // FALSE can't write; TRUE can write bool tape_write; // FALSE can't write; TRUE can write
bool tape_fast_load; // FALSE normal load; TRUE fast load bool tape_fast_load; // FALSE normal load; TRUE fast load
// pagination global variables // pagination global variables
unsigned char mport1,mport2; // ports for memory management (128K and +3) unsigned char mport1, mport2; // ports for memory management (128K and +3)
unsigned int video_offset; // 0 for page 5, and 32768 for page 7 unsigned int video_offset; // 0 for page 5, and 32768 for page 7
unsigned char *block0,*block1,*block2,*block3; // pointers for memory access (one for each 16K block). unsigned char *block0, *block1, *block2, *block3; // pointers for memory access (one for each 16K block).
unsigned char page48k; // 1 if the 48K ROM page is currently paged into unsigned char page48k; // 1 if the 48K ROM page is currently paged into
// public // public
unsigned char memoria[196608]; // memory (12 pages of 16K each one). 4 for ROM, and 8 for RAM unsigned char memoria[196608]; // memory (12 pages of 16K each one). 4 for ROM, and 8 for RAM
unsigned char shadowrom[8192]; // space for Interface I's ROMs unsigned char shadowrom[8192]; // space for Interface I's ROMs
unsigned char interr; unsigned char interr;
unsigned char other_ret; // 0=no change; 1=memory returns RET (201) unsigned char other_ret; // 0=no change; 1=memory returns RET (201)
bool turbo; bool turbo;
bool turbo_play; bool turbo_play;
...@@ -106,10 +124,10 @@ public: ...@@ -106,10 +124,10 @@ public:
void emulate(int); void emulate(int);
void do_contention(bool io, word addr); void do_contention(bool io, word addr);
uint8_t read_memory(uint16_t Addr); uint8_t read_memory(uint16_t Addr);
void write_memory (uint16_t Addr, uint8_t Value); void write_memory(uint16_t Addr, uint8_t Value);
}; };
void fill_audio(void *udata,Uint8 *,int); void fill_audio(void *udata, Uint8 *, int);
void ResetComputer(); void ResetComputer();
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -11,13 +11,17 @@ ...@@ -11,13 +11,17 @@
#include <inttypes.h> #include <inttypes.h>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
enum JOYSTICK_TYPE { JOYSTICK_CURSOR, JOYSTICK_KEMPSTON, JOYSTICK_SINCLAIR1, JOYSTICK_SINCLAIR2}; enum JOYSTICK_TYPE {
JOYSTICK_CURSOR,
JOYSTICK_KEMPSTON,
JOYSTICK_SINCLAIR1,
JOYSTICK_SINCLAIR2
};
class Keyboard { class Keyboard {
// keyboard private global variables // keyboard private global variables
uint8_t k8,k9,k10,k11,k12,k13,k14,k15; uint8_t k8, k9, k10, k11, k12, k13, k14, k15;
uint8_t readed; uint8_t readed;
// kempston joystick private global variables // kempston joystick private global variables
...@@ -29,7 +33,7 @@ public: ...@@ -29,7 +33,7 @@ public:
void reset(); void reset();
void read_keyboard(SDL_Event *); void read_keyboard(SDL_Event *);
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;
enum JOYSTICK_TYPE 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;
...@@ -43,5 +47,4 @@ public: ...@@ -43,5 +47,4 @@ public:
extern class Keyboard *keyboard; extern class Keyboard *keyboard;
#endif /* SRC_KEYBOARD_HH_ */ #endif /* SRC_KEYBOARD_HH_ */
This diff is collapsed.
...@@ -28,15 +28,20 @@ ...@@ -28,15 +28,20 @@
#define D_SOUND_OSS #define D_SOUND_OSS
#endif #endif
#define FILTER_SAMPLES 8 #define FILTER_SAMPLES 8
enum e_soundtype {SOUND_NO, SOUND_OSS, SOUND_ALSA, SOUND_PULSEAUDIO, SOUND_AUTOMATIC}; enum e_soundtype {
SOUND_NO,
SOUND_OSS,
SOUND_ALSA,
SOUND_PULSEAUDIO,
SOUND_AUTOMATIC
};
extern class LLSound *llsound; extern class LLSound *llsound;
class LLSound { class LLSound {
uint8_t format; // 0: 8 bits, 1: 16 bits LSB, 2: 16 bits MSB
uint8_t format; // 0: 8 bits, 1: 16 bits LSB, 2: 16 bits MSB
uint8_t channels; // number of channels uint8_t channels; // number of channels
#ifdef D_SOUND_OSS #ifdef D_SOUND_OSS
...@@ -48,20 +53,20 @@ class LLSound { ...@@ -48,20 +53,20 @@ class LLSound {
#ifdef D_SOUND_PULSE #ifdef D_SOUND_PULSE
int init_pulse(); int init_pulse();
#endif #endif
void remove_dc(unsigned char *sound_buffer,int size); void remove_dc(unsigned char *sound_buffer, int size);
int init_sound(); int init_sound();
void show_volume(); void show_volume();
public: public:
uint32_t freq; // frequency for reproduction uint32_t freq; // frequency for reproduction
uint32_t tst_sample; // number of tstates per sample uint32_t tst_sample; // number of tstates per sample
int8_t sign; // 0: unsigned; 1: signed int8_t sign; // 0: unsigned; 1: signed
bool sound_aborted; bool sound_aborted;
unsigned char *sound; unsigned char *sound;
unsigned char *current_buffer; unsigned char *current_buffer;
uint32_t buffer_len; // sound buffer length (in samples) uint32_t buffer_len; // sound buffer length (in samples)
uint32_t increment; // cuantity to add to jump to the next sample uint32_t increment; // cuantity to add to jump to the next sample
uint8_t volume; // volume uint8_t volume; // volume
enum e_soundtype sound_type; enum e_soundtype sound_type;
LLSound(enum e_soundtype); LLSound(enum e_soundtype);
...@@ -69,6 +74,7 @@ public: ...@@ -69,6 +74,7 @@ public:
void play(); void play();
void increase_volume(); void increase_volume();
void decrease_volume(); void decrease_volume();
void set_volume(uint8_t); void set_volume(uint8_t);
void set_speed(bool); void set_speed(bool);
}; };
......
This diff is collapsed.
...@@ -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/>.
* *
*/ */
using namespace std; using namespace std;
...@@ -24,23 +24,30 @@ using namespace std; ...@@ -24,23 +24,30 @@ using namespace std;
class fichero { class fichero {
public: public:
string nombre; // filename (for files and directories) string nombre; // filename (for files and directories)
string nombrepath; // filename with path string nombrepath; // filename with path
int tipo; // file type (0=file, 1=directory, 2=parent directory) int tipo; // file type (0=file, 1=directory, 2=parent directory)
struct fichero *next; struct fichero *next;
struct fichero *prev; struct fichero *prev;
}; };
#define CURSOR_ELEMENT '_' #define CURSOR_ELEMENT '_'
enum LOAD_FILE_TYPES {FILETYPE_Z80, FILETYPE_TAP_TZX, FILETYPE_MDR, FILETYPE_SCR}; enum LOAD_FILE_TYPES {
FILETYPE_Z80,
FILETYPE_TAP_TZX,
FILETYPE_MDR,
FILETYPE_SCR
};
void help_menu(); void help_menu();
void load_z80file(); void load_z80file();
char *select_file(string,char *,enum LOAD_FILE_TYPES);
class fichero *read_directory(char *,enum LOAD_FILE_TYPES); char * select_file(string, char *, enum LOAD_FILE_TYPES);
class fichero *read_directory(char *, enum LOAD_FILE_TYPES);
unsigned int wait_key(); unsigned int wait_key();
void print_files(class fichero *,int,int);
void print_files(class fichero *, int, int);
void delete_filelist(class fichero *); void delete_filelist(class fichero *);
void select_tapfile(); void select_tapfile();
void save_z80file(); void save_z80file();
...@@ -53,9 +60,9 @@ void create_mdrfile(); ...@@ -53,9 +60,9 @@ void create_mdrfile();
void microdrive_menu(); void microdrive_menu();
void keyboard_menu(); void keyboard_menu();
void load_scrfile(); void load_scrfile();
int ask_filename(char *nombre,int y_coord,string extension, char*path); int ask_filename(char *nombre, int y_coord, string extension, char *path);
void create_scrfile(); void create_scrfile();
void do_poke(); void do_poke();
int ask_value(int *final_value,int y_coord,int max_value); int ask_value(int *final_value, int y_coord, int max_value);
void tools_menu(); void tools_menu();
int launch_menu(unsigned int key_pressed); int launch_menu(unsigned int key_pressed);
...@@ -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 "microdrive.hh" #include "microdrive.hh"
...@@ -27,52 +27,47 @@ ...@@ -27,52 +27,47 @@
class Microdrive *microdrive; class Microdrive *microdrive;
Microdrive::Microdrive() { Microdrive::Microdrive() {
int bucle; int bucle;
this->trash = 0; this->trash = 0;
this->mdr_active = 0; this->mdr_active = 0;
this->mdr_paged = 0; this->mdr_paged = 0;
for(bucle=0;bucle<137922;bucle++)
this->mdr_cartridge[bucle]=0xFF; // cartridge erased
this->mdr_cartridge[137922]=0; // but not write-protected
this->mdr_tapehead=0;
this->mdr_drive = 0; // no motor on
this->mdr_old_STATUS=0x00; // default -> no down edge
this->mdr_modified=0; // not modified
this->mdr_current_mdr[0]=0; // no cartridge
this->mdr_gap = 15;
this->mdr_nogap = 15;
this->mdr_bytes = 0;
this->mdr_maxbytes = 0;
for (bucle = 0; bucle < 137922; bucle++) {
this->mdr_cartridge[bucle] = 0xFF; // cartridge erased
}
this->mdr_cartridge[137922] = 0; // but not write-protected
this->mdr_tapehead = 0;
this->mdr_drive = 0; // no motor on
this->mdr_old_STATUS = 0x00; // default -> no down edge
this->mdr_modified = 0; // not modified
this->mdr_current_mdr[0] = 0; // no cartridge
this->mdr_gap = 15;
this->mdr_nogap = 15;
this->mdr_bytes = 0;
this->mdr_maxbytes = 0;
} }
void Microdrive::reset() { void Microdrive::reset() {
this->mdr_gap = 15;
this->mdr_gap = 15; this->mdr_nogap = 15;
this->mdr_nogap = 15;
this->mdr_tapehead = 0; // head is at start position this->mdr_tapehead = 0; // head is at start position
} }
void Microdrive::emulate(int tstados) { void Microdrive::emulate(int tstados) {
// still nothing to do here // still nothing to do here
} }
byte Microdrive::in(word Port) { byte Microdrive::in(word Port) {
byte retorno; byte retorno;
/* allow access to the port only if motor 1 is ON and there's a file open */ /* allow access to the port only if motor 1 is ON and there's a file open */
if(((Port|0xFFE7) == 0xFFE7)&&(this->mdr_drive==0x01)&&(this->mdr_current_mdr[0])) { if (((Port | 0xFFE7) == 0xFFE7) && (this->mdr_drive == 0x01) && (this->mdr_current_mdr[0])) {
if(this->mdr_bytes<this->mdr_maxbytes) { if (this->mdr_bytes < this->mdr_maxbytes) {
retorno=this->mdr_cartridge[this->mdr_tapehead]; retorno = this->mdr_cartridge[this->mdr_tapehead];
this->trash = retorno; this->trash = retorno;
this->increment_head(); this->increment_head();
} else { } else {
...@@ -81,152 +76,147 @@ byte Microdrive::in(word Port) { ...@@ -81,152 +76,147 @@ byte Microdrive::in(word Port) {
this->mdr_bytes++; this->mdr_bytes++;
return (retorno); return (retorno);
} }
if((Port|0xFFE7) == 0xFFEF) { if ((Port | 0xFFE7) == 0xFFEF) {
if((this->mdr_drive==0x01)&&(this->mdr_current_mdr[0])) { // motor 1 ON and file selected if ((this->mdr_drive == 0x01) </