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 @@
#include "z80free/Z80free.h"
struct z80snapshot {
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;
word PC,IX,IY,SP;
byte type; // bit 0/1: 48K/128K/+3
byte border; // border color
byte pager; // content of pagination register in 128K mode
unsigned char page[12][16384];
unsigned int found_pages; // bit=1: page exists. bit=0: page don't exists.
unsigned char ay_regs[16];
unsigned char ay_latch;
unsigned char joystick;
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;
word PC, IX, IY, SP;
byte type; // bit 0/1: 48K/128K/+3
byte border; // border color
byte pager; // content of pagination register in 128K mode
unsigned char page[12][16384];
unsigned int found_pages; // bit=1: page exists. bit=0: page don't exists.
unsigned char ay_regs[16];
unsigned char ay_latch;
unsigned char joystick;
};
int save_z80(char *);
int load_z80(const char *);
int load_sna(const char *);
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;
#include <stdlib.h>
#include "cmdline.hh"
CMDLine::CMDLine(int argc,char **argv) {
CMDLine::CMDLine(int argc, char **argv) {
int argumento;
this->nosound = false;
this->mini = false;
this->pulse = false;
this->alsa = false;
this->oss = false;
this->rotate = false;
this->fs = false;
this->hw = false;
this->db = false;
this->ds = false;
this->bw = false;
this->color = false;
this->ss = false;
this->jump = 0;
this->setres = false;
this->nosound = false;
this->mini = false;
this->pulse = false;
this->alsa = false;
this->oss = false;
this->rotate = false;
this->fs = false;
this->hw = false;
this->db = false;
this->ds = false;
this->bw = false;
this->color = false;
this->ss = false;
this->jump = 0;
this->setres = false;
this->gamefile = "";
argumento = 0;
while(argumento<argc) {
if ((0==strcmp(argv[argumento],"-h"))||(0==strcmp(argv[argumento],"--help"))) {
while (argumento < argc) {
if ((0 == strcmp(argv[argumento], "-h")) || (0 == strcmp(argv[argumento], "--help"))) {
printf("\nUsage: fbzx [-nosound] ");
#ifdef D_SOUND_ALSA
printf("[-alsa] ");
......@@ -73,65 +72,64 @@ CMDLine::CMDLine(int argc,char **argv) {
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");
exit(0);
} else if(0==strcmp(argv[argumento],"-nosound")) {
} else if (0 == strcmp(argv[argumento], "-nosound")) {
this->nosound = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-mini")) {
} else if (0 == strcmp(argv[argumento], "-mini")) {
this->mini = true;
argumento++;
#ifdef D_SOUND_PULSE
} else if(0==strcmp(argv[argumento],"-pulse")) {
} else if (0 == strcmp(argv[argumento], "-pulse")) {
this->pulse = true;
argumento++;
#endif
#ifdef D_SOUND_ALSA
} else if(0==strcmp(argv[argumento],"-alsa")) {
} else if (0 == strcmp(argv[argumento], "-alsa")) {
this->alsa = true;
argumento++;
#endif
#ifdef D_SOUND_OSS
} else if(0==strcmp(argv[argumento],"-oss")) {
} else if (0 == strcmp(argv[argumento], "-oss")) {
this->oss = true;
argumento++;
#endif
} else if(0==strcmp(argv[argumento],"-rotate")) {
} else if (0 == strcmp(argv[argumento], "-rotate")) {
this->rotate = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-fs")) {
} else if (0 == strcmp(argv[argumento], "-fs")) {
this->fs = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-setres")) {
} else if (0 == strcmp(argv[argumento], "-setres")) {
this->setres = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-hw")) {
} else if (0 == strcmp(argv[argumento], "-hw")) {
this->hw = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-db")) {
} else if (0 == strcmp(argv[argumento], "-db")) {
this->db = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-ds")) {
} else if (0 == strcmp(argv[argumento], "-ds")) {
this->ds = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-bw")) {
} else if (0 == strcmp(argv[argumento], "-bw")) {
this->bw = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-color")) {
} else if (0 == strcmp(argv[argumento], "-color")) {
this->color = true;
argumento++;
} else if(0==strcmp(argv[argumento],"-ss")) {
} else if (0 == strcmp(argv[argumento], "-ss")) {
this->ss = true;
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-=48;*/
this->jump = (int)(argv[argumento][5]);
* jump_frames-=48;*/
this->jump = (int) (argv[argumento][5]);
this->jump -= '0';
argumento++;
} else {
this->gamefile = argv[argumento];
//strcpy(this->gamefile,argv[argumento]);
// strcpy(this->gamefile,argv[argumento]);
argumento++;
}
}
}
......@@ -9,9 +9,7 @@
#define SRC_CMDLINE_HH_
class CMDLine {
public:
bool nosound;
bool mini;
bool pulse;
......@@ -29,11 +27,7 @@ public:
int jump;
string gamefile;
CMDLine(int argc,char **argv);
CMDLine(int argc, char **argv);
};
#endif /* SRC_CMDLINE_HH_ */
This diff is collapsed.
......@@ -31,21 +31,40 @@
// #define MUT
#define CONTENTION_RD 3
#define CONTENTION_WR 3
#define CONTENTION_IN 3
#define CONTENTION_OUT 3
#define CONTENTION_RD 3
#define CONTENTION_WR 3
#define CONTENTION_IN 3
#define CONTENTION_OUT 3
extern char salir;
extern class computer *ordenador;
enum tapmodes {TAP_GUIDE, TAP_DATA, TAP_PAUSE, TAP_TRASH, TAP_STOP, TAP_PAUSE2, TZX_PURE_TONE,
TZX_SEQ_PULSES, TAP_FINAL_BIT, TAP_PAUSE3};
enum tapmodes {
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 {
public:
......@@ -56,12 +75,12 @@ public:
bool bw;
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 contended_cicles; // cicles used during contention (must not be counted after ending the execution of an instruction)
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
unsigned char updown,leftright;
unsigned char updown, leftright;
// Sound variables
unsigned char sound_bit;
......@@ -75,26 +94,25 @@ public:
enum CurrentMode current_mode;
unsigned char port254;
// tape global variables
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
// pagination global variables
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 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 mport1, mport2; // ports for memory management (128K and +3)
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 page48k; // 1 if the 48K ROM page is currently paged into
// public
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 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_play;
......@@ -106,10 +124,10 @@ public:
void emulate(int);
void do_contention(bool io, word 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();
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -11,13 +11,17 @@
#include <inttypes.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 {
// 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;
// kempston joystick private global variables
......@@ -29,7 +33,7 @@ public:
void reset();
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;
enum JOYSTICK_TYPE joystick; // 0=cursor, 1=kempston, 2=sinclair1, 3=sinclair2
int32_t mouse_x;
......@@ -43,5 +47,4 @@ public:
extern class Keyboard *keyboard;
#endif /* SRC_KEYBOARD_HH_ */
This diff is collapsed.
......@@ -28,15 +28,20 @@
#define D_SOUND_OSS
#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;
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
#ifdef D_SOUND_OSS
......@@ -48,20 +53,20 @@ class LLSound {
#ifdef D_SOUND_PULSE
int init_pulse();
#endif
void remove_dc(unsigned char *sound_buffer,int size);
void remove_dc(unsigned char *sound_buffer, int size);
int init_sound();
void show_volume();
public:
uint32_t freq; // frequency for reproduction
uint32_t freq; // frequency for reproduction
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;
unsigned char *sound;
unsigned char *current_buffer;
uint32_t buffer_len; // sound buffer length (in samples)
uint32_t increment; // cuantity to add to jump to the next sample
uint8_t volume; // volume
uint32_t increment; // cuantity to add to jump to the next sample
uint8_t volume; // volume
enum e_soundtype sound_type;
LLSound(enum e_soundtype);
......@@ -69,6 +74,7 @@ public:
void play();
void increase_volume();
void decrease_volume();
void set_volume(uint8_t);
void set_speed(bool);
};
......
This diff is collapsed.
......@@ -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/>.
*
*
*/
using namespace std;
......@@ -24,23 +24,30 @@ using namespace std;
class fichero {
public:
string nombre; // filename (for files and directories)
string nombre; // filename (for files and directories)
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 *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 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();
void print_files(class fichero *,int,int);
void print_files(class fichero *, int, int);
void delete_filelist(class fichero *);
void select_tapfile();
void save_z80file();
......@@ -53,9 +60,9 @@ void create_mdrfile();
void microdrive_menu();
void keyboard_menu();
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 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();
int launch_menu(unsigned int key_pressed);
......@@ -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 "microdrive.hh"
......@@ -27,52 +27,47 @@
class Microdrive *microdrive;
Microdrive::Microdrive() {
int bucle;
this->trash = 0;
this->mdr_active = 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;
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;
}
void Microdrive::reset() {
this->mdr_gap = 15;
this->mdr_nogap = 15;
this->mdr_gap = 15;
this->mdr_nogap = 15;
this->mdr_tapehead = 0; // head is at start position
}
void Microdrive::emulate(int tstados) {
// still nothing to do here
}
byte Microdrive::in(word Port) {
byte retorno;
/* 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(this->mdr_bytes<this->mdr_maxbytes) {
retorno=this->mdr_cartridge[this->mdr_tapehead];
if (((Port | 0xFFE7) == 0xFFE7) && (this->mdr_drive == 0x01) && (this->mdr_current_mdr[0])) {
if (this->mdr_bytes < this->mdr_maxbytes) {
retorno = this->mdr_cartridge[this->mdr_tapehead];
this->trash = retorno;
this->increment_head();
} else {
......@@ -81,152 +76,147 @@ byte Microdrive::in(word Port) {
this->mdr_bytes++;
return (retorno);
}
if((Port|0xFFE7) == 0xFFEF) {
if((this->mdr_drive==0x01)&&(this->mdr_current_mdr[0])) { // motor 1 ON and file selected
if(this->mdr_gap) {
retorno=0xFE; // GAP and SYNC high
if ((Port | 0xFFE7) == 0xFFEF) {
if ((this->mdr_drive == 0x01) && (this->mdr_current_mdr[0])) { // motor 1 ON and file selected
if (this->mdr_gap) {
retorno = 0xFE; // GAP and SYNC high
this->mdr_gap--;
} else {
retorno=0xF8; // GAP and SYNC low
if(this->mdr_nogap)
retorno = 0xF8; // GAP and SYNC low
if (this->mdr_nogap) {
this->mdr_nogap--;
else {
this->mdr_gap=15;
this->mdr_nogap=15;
} else {
this->mdr_gap = 15;
this->mdr_nogap = 15;
}
}
if(!this->mdr_cartridge[137922]) // if write protected
retorno|=0x01; // active bit
} else // motor 1 OFF
retorno=0xFF;
if (!this->mdr_cartridge[137922]) { // if write protected
retorno |= 0x01; // active bit
}
} else { // motor 1 OFF
retorno = 0xFF;
}
this->restart();
return (retorno);
}
if ((Port|0xFFE7)==0xFFF7) {
if ((Port | 0xFFE7) == 0xFFF7) {
this->restart();
return (0xFF);
}
return(0xFF);
}
void Microdrive::out(word Port,byte Value) {
return (0xFF);
}
void Microdrive::out(word Port, byte Value) {
/* 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((this->mdr_bytes>11)&&(this->mdr_bytes<(this->mdr_maxbytes+12))) {
this->mdr_cartridge[this->mdr_tapehead]=(unsigned int) Value;
if (((Port | 0xFFE7) == 0xFFE7) && (this->mdr_drive == 0x01) && (this->mdr_current_mdr[0])) {
if ((this->mdr_bytes > 11) && (this->mdr_bytes < (this->mdr_maxbytes + 12))) {
this->mdr_cartridge[this->mdr_tapehead] = (unsigned int) Value;
this->increment_head();
this->mdr_modified=1;
this->mdr_modified = 1;
}
this->mdr_bytes++;
return;
}
if((Port|0xFFE7)==0xFFEF) {
if(((Value&0x02)==0)&&((this->mdr_old_STATUS&0x02)==2)) { // edge down-> new bit for motor ON
this->mdr_drive = ((this->mdr_drive<<1)&0xFE); // rotate one drive
if(!(Value&0x01)) // if COM DATA is 0, we add a 1 bit to mdr_drive
if ((Port | 0xFFE7) == 0xFFEF) {
if (((Value & 0x02) == 0) && ((this->mdr_old_STATUS & 0x02) == 2)) { // edge down-> new bit for motor ON
this->mdr_drive = ((this->mdr_drive << 1) & 0xFE); // rotate one drive
if (!(Value & 0x01)) { // if COM DATA is 0, we add a 1 bit to mdr_drive
this->mdr_drive |= 0x01;
if(this->mdr_modified) { // if the cartridge has been modified, we store it in hard disk
}
if (this->mdr_modified) { // if the cartridge has been modified, we store it in hard disk
this->save_cartridge();
}
}
this->mdr_old_STATUS=Value;
this->mdr_old_STATUS = Value;
this->restart();
return;
}
if ((Port|0xFFE7)==0xFFF7) {
if ((Port | 0xFFE7) == 0xFFF7) {
this->restart();
return;
}
}
bool Microdrive::save_cartridge() {
FILE *mdr_file;
mdr_file=fopen(this->mdr_current_mdr,"wb"); // create for write
if(mdr_file==NULL) {
osd->set_message("Can't store the cartridge",3000);
mdr_file = fopen(this->mdr_current_mdr, "wb"); // create for write
if (mdr_file == NULL) {
osd->set_message("Can't store the cartridge", 3000);
return true;
}
fwrite(this->mdr_cartridge,137923,1,mdr_file); // save cartridge
fwrite(this->mdr_cartridge, 137923, 1, mdr_file); // save cartridge
fclose(mdr_file);
mdr_file=NULL;
this->mdr_modified=0;
mdr_file = NULL;
this->mdr_modified = 0;
return false;
}
void Microdrive::increment_head() { // gets the tape head to the next byte
this->mdr_tapehead++;
if(this->mdr_tapehead>137921)
this->mdr_tapehead=0;
if (this->mdr_tapehead > 137921) {
this->mdr_tapehead = 0;
}
}
void Microdrive::restart() { // there's an access to a port. Reset counters and relocate the head
// printf("Inicializado\n");
//printf("Inicializado\n");
while(((this->mdr_tapehead%543)!=0)&&((this->mdr_tapehead%543)!=15)) {
while (((this->mdr_tapehead % 543) != 0) && ((this->mdr_tapehead % 543) != 15)) {
this->increment_head(); // put head in the start of a block
}
this->mdr_bytes = 0; // reset current number of bytes written
if((this->mdr_tapehead%543)==0)
this->mdr_maxbytes = 15; // up to 15 bytes for header blocks
else
this->mdr_bytes = 0; // reset current number of bytes written
if ((this->mdr_tapehead % 543) == 0) {
this->mdr_maxbytes = 15; // up to 15 bytes for header blocks
} else {
this->mdr_maxbytes = 528; // up to 528 bytes for data blocks
}
}
int Microdrive::select_mdrfile(char *filename) {
<