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

Passed all the code through uncrustify

parent 85e33c3d
This diff is collapsed.
......@@ -22,10 +22,9 @@
#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;
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;
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
......@@ -34,11 +33,10 @@ struct z80snapshot {
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,8 +12,7 @@ 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;
......@@ -35,8 +34,8 @@ CMDLine::CMDLine(int argc,char **argv) {
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.
......@@ -40,12 +40,31 @@ 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:
......@@ -61,7 +80,7 @@ public:
// Linux joystick private global variables
unsigned char updown,leftright;
unsigned char updown, leftright;
// Sound variables
unsigned char sound_bit;
......@@ -75,7 +94,6 @@ public:
enum CurrentMode current_mode;
unsigned char port254;
// tape global variables
string current_tap;
......@@ -84,9 +102,9 @@ public:
// 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 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
// public
......@@ -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.
......@@ -13,7 +13,6 @@
class Keyboard *keyboard;
Keyboard::Keyboard() {
this->s8 = this->s9 = this->s10 = this->s11 = this->s12 = this->s13 = this->s14 = this->s15 = 0xFF;
this->k8 = this->k9 = this->k10 = this->k11 = this->k12 = this->k13 = this->k14 = this->k15 = 0;
this->tab_extended = false;
......@@ -32,130 +31,134 @@ Keyboard::Keyboard() {
}
void Keyboard::reset() {
this->s8|=0x1F;
this->s9|=0x1F;
this->s10|=0x1F;
this->s11|=0x1F;
this->s12|=0x1F;
this->s13|=0x1F;
this->s14|=0x1F;
this->s15|=0x1F;
this->js=0;
this->s8 |= 0x1F;
this->s9 |= 0x1F;
this->s10 |= 0x1F;
this->s11 |= 0x1F;
this->s12 |= 0x1F;
this->s13 |= 0x1F;
this->s14 |= 0x1F;
this->s15 |= 0x1F;
this->js = 0;
}
// Read the keyboard and mouse, and stores the flags
void Keyboard::read_keyboard (SDL_Event *pevento2) {
void Keyboard::read_keyboard(SDL_Event *pevento2) {
unsigned int temporal_io;
SDL_Event evento,evento2,*pevento;
SDL_Event evento, evento2, *pevento;
Sint16 valor;
Uint8 eje;
if (pevento2==NULL) {
pevento=&evento;
if (!SDL_PollEvent (&evento))
if (pevento2 == NULL) {
pevento = &evento;
if (!SDL_PollEvent(&evento)) {
return;
}
} else {
pevento=pevento2;
pevento = pevento2;
}
if (pevento->type==SDL_QUIT) {
if (pevento->type == SDL_QUIT) {
salir = 0;
return;
}
if (pevento->type==SDL_MOUSEMOTION) {
if (pevento->type == SDL_MOUSEMOTION) {
this->mouse_x += pevento->motion.xrel;
this->mouse_y += pevento->motion.yrel;
return;
}
if (pevento->type==SDL_MOUSEBUTTONDOWN) {
if (pevento->type == SDL_MOUSEBUTTONDOWN) {
switch (pevento->button.button) {
case SDL_BUTTON_LEFT:
this->mouse_left = true;
break;
case SDL_BUTTON_MIDDLE:
this->mouse_center = true;
break;
case SDL_BUTTON_RIGHT:
this->mouse_right = true;
break;
}
}
if (pevento->type==SDL_MOUSEBUTTONUP) {
if (pevento->type == SDL_MOUSEBUTTONUP) {
switch (pevento->button.button) {
case SDL_BUTTON_LEFT:
this->mouse_left = false;
break;
case SDL_BUTTON_MIDDLE:
this->mouse_center = false;
break;
case SDL_BUTTON_RIGHT:
this->mouse_right = false;
break;
}
}
if (pevento->type==SDL_JOYBUTTONDOWN) {
pevento->type=SDL_KEYDOWN;
pevento->key.keysym.sym=SDLK_MENU; // emulate pressing the MENU key
if (pevento->type == SDL_JOYBUTTONDOWN) {
pevento->type = SDL_KEYDOWN;
pevento->key.keysym.sym = SDLK_MENU; // emulate pressing the MENU key
}
if (pevento->type==SDL_JOYBUTTONUP) {
pevento->type=SDL_KEYUP;
pevento->key.keysym.sym=SDLK_MENU; // emulate depressing the MENU key
if (pevento->type == SDL_JOYBUTTONUP) {
pevento->type = SDL_KEYUP;
pevento->key.keysym.sym = SDLK_MENU; // emulate depressing the MENU key
}
if (pevento->type==SDL_JOYAXISMOTION) {
eje=pevento->jaxis.axis;
valor=pevento->jaxis.value;
if (pevento->type == SDL_JOYAXISMOTION) {
eje = pevento->jaxis.axis;
valor = pevento->jaxis.value;
evento2.type=SDL_KEYUP;
if ((valor<16384)&&(valor>-16384)) { // JoyStick centered
pevento->type=SDL_KEYUP;
if (eje==1) {
evento2.key.keysym.sym=SDLK_DOWN;
pevento->key.keysym.sym=SDLK_UP; // pull up both keys
evento2.type = SDL_KEYUP;
if ((valor < 16384) && (valor > -16384)) { // JoyStick centered
pevento->type = SDL_KEYUP;
if (eje == 1) {
evento2.key.keysym.sym = SDLK_DOWN;
pevento->key.keysym.sym = SDLK_UP; // pull up both keys
read_keyboard(&evento2);
}
if (eje==0) {
evento2.key.keysym.sym=SDLK_LEFT;
pevento->key.keysym.sym=SDLK_RIGHT;
if (eje == 0) {
evento2.key.keysym.sym = SDLK_LEFT;
pevento->key.keysym.sym = SDLK_RIGHT;
read_keyboard(&evento2);
}
} else { // JoyStick moved
if (eje==0) {
if (valor>=0) {
evento2.key.keysym.sym=SDLK_LEFT; // pull up LEFT
if (eje == 0) {
if (valor >= 0) {
evento2.key.keysym.sym = SDLK_LEFT; // pull up LEFT
read_keyboard(&evento2);
pevento->key.keysym.sym=SDLK_RIGHT; // and press RIGHT
pevento->key.keysym.sym = SDLK_RIGHT; // and press RIGHT
} else {
evento2.key.keysym.sym=SDLK_RIGHT; // pull up RIGHT
evento2.key.keysym.sym = SDLK_RIGHT; // pull up RIGHT
read_keyboard(&evento2);
pevento->key.keysym.sym=SDLK_LEFT; // and press LEFT
pevento->key.keysym.sym = SDLK_LEFT; // and press LEFT
}
}
if (eje==1) {
if (valor<0) {
evento2.key.keysym.sym=SDLK_DOWN; // pull up DOWN
pevento->key.keysym.sym=SDLK_UP; // and press UP
if (eje == 1) {
if (valor < 0) {
evento2.key.keysym.sym = SDLK_DOWN; // pull up DOWN
pevento->key.keysym.sym = SDLK_UP; // and press UP
read_keyboard(&evento2);
} else {
evento2.key.keysym.sym=SDLK_UP; // pull up UP
pevento->key.keysym.sym=SDLK_DOWN; // and press DOWN
evento2.key.keysym.sym = SDLK_UP; // pull up UP
pevento->key.keysym.sym = SDLK_DOWN; // and press DOWN
read_keyboard(&evento2);
}
}
pevento->type=SDL_KEYDOWN;
pevento->type = SDL_KEYDOWN;
}
}
if ((pevento->type != SDL_KEYDOWN) && (pevento->type != SDL_KEYUP))
if ((pevento->type != SDL_KEYDOWN) && (pevento->type != SDL_KEYUP)) {
return;
}
this->k8 = this->k9 = this->k10 = this->k11 =
this->k12 = this->k13 = this->k14 =
......@@ -164,10 +167,10 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
temporal_io = (unsigned int) pevento->key.keysym.sym;
if ((pevento->type==SDL_KEYUP)&&(temporal_io==SDLK_TAB)) {
if ((pevento->type == SDL_KEYUP) && (temporal_io == SDLK_TAB)) {
if (!this->tab_extended) {
this->tab_extended = true;
osd->set_message("Function Key mode on",2000);
osd->set_message("Function Key mode on", 2000);
return;
} else {
this->tab_extended = false;
......@@ -176,67 +179,81 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
}
}
if ((pevento->type==SDL_KEYDOWN)&&(this->tab_extended))
if ((pevento->type == SDL_KEYDOWN) && (this->tab_extended)) {
return;
}
if ((pevento->type==SDL_KEYUP)&&(this->tab_extended)) {
if ((pevento->type == SDL_KEYUP) && (this->tab_extended)) {
this->tab_extended = false;
osd->clear_message();
switch(temporal_io) {
switch (temporal_io) {
case SDLK_1:
temporal_io=SDLK_F1;
temporal_io = SDLK_F1;
break;
case SDLK_2:
temporal_io=SDLK_F2;
temporal_io = SDLK_F2;
break;
case SDLK_3:
temporal_io=SDLK_F3;
temporal_io = SDLK_F3;
break;
case SDLK_4:
temporal_io=SDLK_F4;
temporal_io = SDLK_F4;
break;
case SDLK_5:
temporal_io=SDLK_F5;
temporal_io = SDLK_F5;
break;
case SDLK_6:
temporal_io=SDLK_F6;
temporal_io = SDLK_F6;
break;
case SDLK_7:
temporal_io=SDLK_F7;
temporal_io = SDLK_F7;
break;
case SDLK_8:
temporal_io=SDLK_F8;
temporal_io = SDLK_F8;
break;
case SDLK_9:
temporal_io=SDLK_F9;
temporal_io = SDLK_F9;
break;
case SDLK_0:
temporal_io=SDLK_F10;
temporal_io = SDLK_F10;
break;
case SDLK_o:
temporal_io=SDLK_F11;
temporal_io = SDLK_F11;
break;
case SDLK_p:
temporal_io=SDLK_F12;
temporal_io = SDLK_F12;
break;
}
}
if (pevento->type == SDL_KEYUP)
if (pevento->type == SDL_KEYUP) {
switch (temporal_io) {
case SDLK_ESCAPE: // to exit from the emulator
if (!this->esc_again) {
this->esc_again = true;
osd->set_message("ESC again to exit",2000);
} else
osd->set_message("ESC again to exit", 2000);
} else {
salir = 0;
}
return;
break;
case SDLK_F1:
help_menu (); // shows the help menu
help_menu(); // shows the help menu
break;
case SDLK_F2:
......@@ -266,7 +283,7 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
break;
case SDLK_F10: // Reset emulator
ResetComputer ();
ResetComputer();
OOTape->set_pause(true);
OOTape->rewind();
break;
......@@ -279,27 +296,30 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
llsound->increase_volume();
break;
}
}
// reorder joystick if screen is rotated
if(ordenador->zaurus_mini==2) {
switch(temporal_io) {
if (ordenador->zaurus_mini == 2) {
switch (temporal_io) {
case SDLK_UP:
temporal_io=SDLK_LEFT;
temporal_io = SDLK_LEFT;
break;
case SDLK_LEFT:
temporal_io=SDLK_DOWN;
temporal_io = SDLK_DOWN;
break;
case SDLK_DOWN:
temporal_io=SDLK_RIGHT;
temporal_io = SDLK_RIGHT;
break;
case SDLK_RIGHT:
temporal_io=SDLK_UP;
temporal_io = SDLK_UP;
break;
}
}
// test for joystick
switch (temporal_io) {
......@@ -360,7 +380,6 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
case 3: // sinclair 2
temporal_io = SDLK_6;
break;
}
break;
......@@ -410,7 +429,6 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
}
switch (temporal_io) {
case SDLK_SPACE:
this->k15 = 1;
break;
......@@ -577,13 +595,14 @@ void Keyboard::read_keyboard (SDL_Event *pevento2) {
this->k12 = 1;
this->k8 = 1;
break;
case SDLK_PERIOD:
this->k15 = 6;
break;
case SDLK_COMMA:
this->k15 = 10;
break;
}
if (pevento->type == SDL_KEYUP) {
......
......@@ -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.
......@@ -30,12 +30,17 @@
#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 channels; // number of channels
......@@ -48,7 +53,7 @@ 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();
......@@ -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.
......@@ -33,14 +33,21 @@ public:
#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 *);