Commit 807ad0ce authored by Sergio Costas's avatar Sergio Costas

Merge branch 'use_stdint'

parents de4aa7fd fc5a6bdc
......@@ -15,7 +15,7 @@ all:
cd src && $(MAKE)
clean:
rm -f src/fbzx src/*.o src/*~
rm -f src/fbzx src/*.o src/*~ src/z80free/*.o
install:
rm -f $(PREFIX2)/bin/fbzx
......@@ -29,7 +29,7 @@ install:
cp data/keymap.bmp $(PREFIX2)/share/fbzx
cp data/fbzx.desktop $(PREFIX2)/share/applications
cp data/fbzx.svg $(PREFIX2)/share/pixmaps
cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS.md $(PREFIX2)/share/doc/fbzx/
cp AMSTRAD CAPABILITIES COPYING FAQ README.md README.TZX HISTORY.md $(PREFIX2)/share/doc/fbzx/
cp fbzx.appdata.xml $(PREFIX2)/share/appdata/
chmod 644 $(PREFIX2)/share/fbzx/*
chmod 644 $(PREFIX2)/share/doc/fbzx/*
......
FLAGS = -O2
FLAGS = -O2 -Wall
CC=g++ -c $(FLAGS)
CPP=g++ -c $(FLAGS)
......
......@@ -86,12 +86,12 @@ int save_z80(char *filename) {
}
fprintf(fichero, "%c%c%c%c%c%c", procesador.Rm.br.A, procesador.Rm.br.F,
procesador.Rm.br.C, procesador.Rm.br.B, procesador.Rm.br.L,
procesador.Rm.br.H); // AF, BC and HL
procesador.Rm.br.H); // AF, BC and HL
if (ordenador->current_mode == MODE_48K) { // 48K
fprintf(fichero, "%c%c", (byte) (procesador.PC & 0x0FF), (byte) ((procesador.PC >> 8) & 0xFF)); // PC
if (ordenador->current_mode == MODE_48K) { // 48K
fprintf(fichero, "%c%c", (uint8_t) (procesador.PC & 0x0FF), (uint8_t) ((procesador.PC >> 8) & 0xFF)); // PC
} else {
fprintf(fichero, "%c%c", 0, 0); // 128K
fprintf(fichero, "%c%c", 0, 0); // 128K
}
fprintf(fichero, "%c%c", procesador.Rm.br.P, procesador.Rm.br.S); // SP
......@@ -133,6 +133,9 @@ int save_z80(char *filename) {
case JOYSTICK_SINCLAIR2:
value |= 192;
break;
default:
break;
}
fprintf(fichero, "%c", value);
......@@ -146,8 +149,8 @@ int save_z80(char *filename) {
// 128K
fprintf(fichero, "%c%c", 23, 0); // Z80 file v2.01
fprintf(fichero, "%c%c", (byte) (procesador.PC & 0x0FF),
(byte) ((procesador.PC >> 8) & 0x0FF)); // PC
fprintf(fichero, "%c%c", (uint8_t) (procesador.PC & 0x0FF),
(uint8_t) ((procesador.PC >> 8) & 0x0FF)); // PC
fprintf(fichero, "%c", 3); // hardware mode=3
fprintf(fichero, "%c", ordenador->mport1); // content of 0x7FFD latch
fprintf(fichero, "%c%c", 0, 0); // no If1, no emulation of any kind
......@@ -281,16 +284,16 @@ int load_z80(const char *filename) {
snap->L = tempo[4];
snap->H = tempo[5];
if (type) {
snap->PC = ((word) tempo2[2]) + 256 * ((word) tempo2[3]);
snap->PC = ((uint16_t) tempo2[2]) + 256 * ((uint16_t) tempo2[3]);
for (bucle = 0; bucle < 16; bucle++) {
snap->ay_regs[bucle] = tempo2[9 + bucle];
}
snap->ay_latch = tempo2[8];
} else {
snap->PC = ((word) tempo[6]) + 256 * ((word) tempo[7]);
snap->PC = ((uint16_t) tempo[6]) + 256 * ((uint16_t) tempo[7]);
}
snap->SP = ((word) tempo[8]) + 256 * ((word) tempo[9]);
snap->SP = ((uint16_t) tempo[8]) + 256 * ((uint16_t) tempo[9]);
snap->I = tempo[10];
snap->R = (tempo[11] & 0x7F);
......@@ -321,8 +324,8 @@ int load_z80(const char *filename) {
snap->HH = tempo[20];
snap->AA = tempo[21];
snap->FF = tempo[22];
snap->IY = ((word) tempo[23]) + 256 * ((word) tempo[24]);
snap->IX = ((word) tempo[25]) + 256 * ((word) tempo[26]);
snap->IY = ((uint16_t) tempo[23]) + 256 * ((uint16_t) tempo[24]);
snap->IX = ((uint16_t) tempo[25]) + 256 * ((uint16_t) tempo[26]);
if (tempo[27] != 0) {
snap->IFF1 = 1;
......@@ -535,8 +538,8 @@ int load_sna(const char *filename) {
snap->C = tempo[13];
snap->B = tempo[14];
snap->IY = ((word) tempo[15]) + 256 * ((word) tempo[16]);
snap->IX = ((word) tempo[17]) + 256 * ((word) tempo[18]);
snap->IY = ((uint16_t) tempo[15]) + 256 * ((uint16_t) tempo[16]);
snap->IX = ((uint16_t) tempo[17]) + 256 * ((uint16_t) tempo[18]);
if (tempo[19] & 0x01) {
snap->IFF1 = 1;
......@@ -553,7 +556,7 @@ int load_sna(const char *filename) {
snap->R = tempo[20];
snap->F = tempo[21];
snap->A = tempo[22];
snap->SP = ((word) tempo[23]) + 256 * ((word) tempo[24]);
snap->SP = ((uint16_t) tempo[23]) + 256 * ((uint16_t) tempo[24]);
snap->Imode = tempo[25];
snap->border = tempo[26];
......@@ -571,7 +574,7 @@ int load_sna(const char *filename) {
}
addr -= 16384;
addr += 27;
snap->PC = ((word) tempo[addr]) + 256 * ((word) tempo[addr + 1]);
snap->PC = ((uint16_t) tempo[addr]) + 256 * ((uint16_t) tempo[addr + 1]);
tempo[addr] = 0;
tempo[addr + 1] = 0;
snap->SP += 2;
......@@ -580,7 +583,7 @@ int load_sna(const char *filename) {
memcpy(snap->page[1], tempo + 16411, 16384);
memcpy(snap->page[2], tempo + 32795, 16384);
} else {
snap->PC = ((word) tempo2[0]) + 256 * ((word) tempo2[1]);
snap->PC = ((uint16_t) tempo2[0]) + 256 * ((uint16_t) tempo2[1]);
memcpy(snap->page[5], tempo + 27, 16384);
memcpy(snap->page[2], tempo + 16411, 16384);
v1 = tempo[2];
......
......@@ -22,12 +22,12 @@
#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;
uint8_t 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
uint16_t PC, IX, IY, SP;
uint8_t type; // bit 0/1: 48K/128K/+3
uint8_t border; // border color
uint8_t 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];
......
......@@ -40,8 +40,6 @@
class computer *ordenador;
computer::computer() {
int bucle;
this->dblscan = false;
this->bw = false;
......@@ -91,7 +89,7 @@ bool computer::callback_receiver(string signal_received, class Signals *object)
/* Returns the bus value when reading a port without a periferial */
byte computer::bus_empty() {
uint8_t computer::bus_empty() {
if (ordenador->current_mode != MODE_P3) {
return (screen->get_bus_value(this->cicles_counter));
} else {
......@@ -125,7 +123,7 @@ void computer::emulate(int tstados) {
// check if there's contention and waits the right number of tstates
void computer::do_contention(bool io, word addr) {
void computer::do_contention(bool io, uint16_t addr) {
if (this->memcontended_zone == 0) {
return;
}
......@@ -160,6 +158,9 @@ void computer::do_contention(bool io, word addr) {
return;
}
break;
default:
break;
}
}
if ((addr & 0xC000) == 0x4000) {
......@@ -175,8 +176,6 @@ void computer::do_contention(bool io, word addr) {
// resets the computer and loads the right ROMs
void ResetComputer() {
static int bucle;
Z80free_reset(&procesador);
load_rom(ordenador->current_mode);
......@@ -219,7 +218,7 @@ void extra_contention() {
procesador.subtstates = 0;
}
void Z80free_Wr(word Addr, byte Value) {
void Z80free_Wr(uint16_t Addr, uint8_t Value) {
extra_contention();
ordenador->do_contention(false, Addr);
ordenador->write_memory(Addr, Value);
......@@ -249,11 +248,11 @@ void computer::write_memory(uint16_t Addr, uint8_t Value) {
}
}
byte Z80free_Rd(word Addr) {
uint8_t Z80free_Rd(uint16_t Addr) {
extra_contention();
if ((microdrive->mdr_active) && (microdrive->mdr_paged) && (Addr < 8192)) { // Interface I
return ((byte) ordenador->shadowrom[Addr]);
return ((uint8_t) ordenador->shadowrom[Addr]);
}
if (ordenador->other_ret == 1) {
......@@ -268,22 +267,22 @@ byte Z80free_Rd(word Addr) {
uint8_t computer::read_memory(uint16_t Addr) {
switch (Addr & 0xC000) {
case 0x0000:
return ((byte) (*(ordenador->block0 + Addr)));
return ((uint8_t) (*(ordenador->block0 + Addr)));
break;
case 0x4000:
return ((byte) (*(ordenador->block1 + Addr)));
return ((uint8_t) (*(ordenador->block1 + Addr)));
break;
case 0x8000:
return ((byte) (*(ordenador->block2 + Addr)));
return ((uint8_t) (*(ordenador->block2 + Addr)));
break;
case 0xC000:
return ((byte) (*(ordenador->block3 + Addr)));
return ((uint8_t) (*(ordenador->block3 + Addr)));
break;
......@@ -294,10 +293,10 @@ uint8_t computer::read_memory(uint16_t Addr) {
}
}
void Z80free_Out(word Port, byte Value) {
void Z80free_Out(uint16_t Port, uint8_t Value) {
// Microdrive access
word maskport;
uint16_t maskport;
extra_contention();
if (ordenador->current_mode != MODE_P3) {
......@@ -361,9 +360,9 @@ void Z80free_Out(word Port, byte Value) {
}
}
byte Z80free_In(word Port) {
uint8_t Z80free_In(uint16_t Port) {
static unsigned int temporal_io;
byte pines;
uint8_t pines;
extra_contention();
if (ordenador->current_mode != MODE_P3) {
......
......@@ -120,9 +120,9 @@ public:
computer();
~computer();
bool callback_receiver(string, class Signals *);
byte bus_empty();
uint8_t bus_empty();
void emulate(int);
void do_contention(bool io, word addr);
void do_contention(bool io, uint16_t addr);
uint8_t read_memory(uint16_t Addr);
void write_memory(uint16_t Addr, uint8_t Value);
};
......
......@@ -378,9 +378,9 @@ void load_config() {
}
int main(int argc, char *argv[]) {
int bucle, tstados, argumento, length;
string gamefile;
word PC = 0;
int bucle, tstados, length;
string gamefile;
uint16_t PC = 0;
CMDLine parse(argc, argv);
......@@ -674,7 +674,7 @@ void do_fast_load() {
if ((size == 0) || (procesador.Rm.wr.DE == 0)) {
break;
}
ordenador->write_memory(procesador.Rm.wr.IX, (byte) data[counter]); // store the byte
ordenador->write_memory(procesador.Rm.wr.IX, (uint8_t) data[counter]); // store the byte
procesador.Rm.wr.IX++;
procesador.Rm.wr.DE--;
counter++;
......
......@@ -224,26 +224,18 @@ uint8_t LLScreen::printchar(uint8_t carac, int16_t x, int16_t y, uint8_t color,
uint8_t width;
uint8_t width2;
uint8_t height;
uint8_t height2;
int8_t left;
int8_t top;
int8_t right;
int8_t bottom;
uint8_t * counter;
int8_t * counter2;
carac -= 32;
offset = charset.offsets[carac];
counter = charset.data + offset;
width = *(counter++);
height = *(counter++);
counter2 = (int8_t *) counter;
left = *(counter2++);
top = *(counter2++);
right = *(counter2++);
bottom = *(counter2++);
counter += 4;
offset = charset.offsets[carac];
counter = charset.data + offset;
width = *(counter++);
height = *(counter++);
counter++;
top = *counter;
counter += 3;
// y+=charset.max_top;
lugar = this->memory + (y * this->width + x);
......@@ -254,7 +246,7 @@ uint8_t LLScreen::printchar(uint8_t carac, int16_t x, int16_t y, uint8_t color,
width2 = width + 1;
}
for (bucle1 = 0; bucle1 < this->cheight; bucle1++) {
for (bucle1 = 0; bucle1 < (int) this->cheight; bucle1++) {
lugar2 = lugar;
if (bucle1 + y >= 480) {
break;
......@@ -311,8 +303,8 @@ void LLScreen::paint_picture(string filename) {
}
void LLScreen::clear_screen() {
int bucle;
uint32_t *buffer;
unsigned int bucle;
uint32_t * buffer;
buffer = this->memory;
......@@ -324,7 +316,8 @@ void LLScreen::clear_screen() {
// 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, float y, uint8_t ink, uint8_t paper) {
int length, ncarac, bucle, xx;
unsigned int length;
int ncarac, bucle, xx;
uint16_t xxx, yyy;
unsigned char *cadena = (unsigned char *) o_cadena.c_str();
unsigned char *str2;
......
......@@ -51,7 +51,8 @@ pa_simple *pulse_s;
#endif
LLSound::LLSound(enum e_soundtype sound_type) {
int bucle, bucle2, ret2;
unsigned int bucle;
int ret2;
this->sound_type = sound_type;
ret2 = this->init_sound(); // check all sound systems
......
This diff is collapsed.
......@@ -22,6 +22,8 @@ using namespace std;
#include "llscreen.hh"
#define MAX_FILE_LENGTH 256
class fichero {
public:
string nombre; // filename (for files and directories)
......
......@@ -60,8 +60,8 @@ void Microdrive::emulate(int tstados) {
// still nothing to do here
}
byte Microdrive::in(word Port) {
byte retorno;
uint8_t Microdrive::in(uint16_t Port) {
uint8_t retorno;
/* allow access to the port only if motor 1 is ON and there's a file open */
......@@ -110,7 +110,7 @@ byte Microdrive::in(word Port) {
return (0xFF);
}
void Microdrive::out(word Port, byte Value) {
void Microdrive::out(uint16_t Port, uint8_t 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])) {
......
......@@ -36,16 +36,16 @@ class Microdrive {
uint32_t mdr_nogap; // TSTATEs remaining for next GAP
uint8_t mdr_cartridge[137923]; // current cartridge
uint8_t mdr_drive; // current drive
byte mdr_old_STATUS; // to detect an edge in COM CLK
uint8_t mdr_old_STATUS; // to detect an edge in COM CLK
uint8_t mdr_modified; // if a sector is stored, this change to know that it must be stored in the file
byte trash;
uint8_t trash;
public:
Microdrive();
void reset();
byte in(word);
void out(word, byte);
uint8_t in(uint16_t);
void out(uint16_t, uint8_t);
void emulate(int);
int select_mdrfile(char *);
int new_mdrfile(char *);
......
......@@ -10,16 +10,16 @@ class Mouse {
int posy;
public:
byte x;
byte y;
byte button;
uint8_t x;
uint8_t y;
uint8_t button;
bool enabled;
Mouse();
void reset();
void emulate(int);
byte in(word);
uint8_t in(uint16_t);
};
extern class Mouse *mouse;
......
......@@ -18,7 +18,7 @@ OSD::OSD() {
void OSD::set_message(string text, uint32_t ms) {
this->text = text;
this->lines = 1;
for (int loop = 0; loop < text.length(); loop++) {
for (unsigned int loop = 0; loop < text.length(); loop++) {
if (text[loop] == '\n') {
this->lines++;
}
......
......@@ -43,8 +43,8 @@ Screen::Screen() {
this->flash = 0;
this->screen_snow = false;
this->bus_value = 255;
int height;
int width;
int height = 640;
int width = 480;
switch (ordenador->zaurus_mini) {
case 0:
......@@ -210,7 +210,7 @@ uint8_t Screen::get_bus_value(int tstates) {
* to execute last instruction */
void Screen::show_screen(int tstados) {
static uint8_t temporal, ink, paper, fflash, tmp2;
static uint8_t ink, paper, fflash, tmp2;
static int loop;
if ((procesador.I >= 0x40) && (procesador.I <= 0x7F)) {
......@@ -348,7 +348,6 @@ void Screen::show_screen(int tstados) {
void Screen::paint_pixels(uint8_t octet, uint8_t ink, uint8_t paper) {
static int bucle, valor;
static unsigned int *p;
static unsigned char mask;
if (((this->currpix >= (this->last_column))) || (this->currline < this->first_line) || (this->pixel >= this->max_pixel)) {
......
......@@ -329,26 +329,26 @@ void SPK_AY::reset() {
this->vol_c = 0;
}
void SPK_AY::set_latch(byte Value) {
void SPK_AY::set_latch(uint8_t Value) {
this->ay_latch = (Value & 0x0F);
}
void SPK_AY::set_value(byte Value) {
void SPK_AY::set_value(uint8_t Value) {
this->ay_registers[this->ay_latch] = (unsigned char) Value;
if (this->ay_latch == 13) {
this->ay_envel_way = 2; // start cycle
}
}
byte SPK_AY::get_value() {
uint8_t SPK_AY::get_value() {
return (this->ay_registers[this->ay_latch]);
}
byte SPK_AY::get_value(int v) {
uint8_t SPK_AY::get_value(int v) {
return (this->ay_registers[v]);
}
byte SPK_AY::get_latch() {
uint8_t SPK_AY::get_latch() {
return (this->ay_latch);
}
......@@ -356,9 +356,9 @@ byte SPK_AY::get_latch() {
* execute last instruction */
void SPK_AY::play_sound(int tstados) {
int bucle;
int value;
uint8_t sample_v;
unsigned int bucle;
int value;
uint8_t sample_v;
this->tstados_counter_sound += tstados;
......
......@@ -46,11 +46,11 @@ public:
void play_sound(int);
void reset();
void set_latch(byte);
void set_value(byte);
byte get_latch();
byte get_value();
byte get_value(int);
void set_latch(uint8_t);
void set_value(uint8_t);
uint8_t get_latch();
uint8_t get_value();
uint8_t get_value(int);
};
extern class SPK_AY *spk_ay;
......
......@@ -56,7 +56,6 @@ protected:
bool read_16bit(ifstream *file, uint16_t&value) {
uint8_t data[2];
size_t retval;
file->read((char *) data, 2);
if (file->eof()) {
......@@ -69,7 +68,6 @@ protected:
bool write_16bit(ofstream *file, uint16_t value) {
uint8_t data[2];
size_t retval;
data[0] = (uint8_t) (value % 256);
data[1] = (uint8_t) (value / 256);
......@@ -79,7 +77,6 @@ protected:
bool read_24bit(ifstream *file, uint32_t&value) {
uint8_t data[3];
size_t retval;
file->read((char *) data, 3);
if (file->eof()) {
......@@ -92,7 +89,6 @@ protected:
bool write_24bit(ofstream *file, uint32_t value) {
uint8_t data[3];
size_t retval;
data[0] = (uint8_t) (value % 256);
data[1] = (uint8_t) ((value / 256) % 256);
......@@ -104,7 +100,6 @@ protected:
bool read_string(ifstream *file, string&value) {
uint8_t length;
char data[256];
size_t retval;
if (this->read_8bit(file, length)) {
return true;
......@@ -121,8 +116,6 @@ protected:
bool write_string(ofstream *file, string value) {
uint8_t length;
char data[256];
size_t retval;
length = (uint8_t) value.length();
if (this->write_8bit(file, length)) {
......@@ -358,7 +351,7 @@ protected:
uint32_t loop;
bool allow_fast_load;
int pointer;
unsigned int pointer;
enum TURBOBLOCK_states {
TURBOBLOCK_GUIDE,
......@@ -467,7 +460,6 @@ public:
}
TAPBlock(uint8_t *data, uint16_t size) : FullBlock() {
size_t retval;
this->next = NULL;
this->data = new uint8_t[size];
......@@ -515,7 +507,6 @@ public:
bool load_block(ifstream *file) {
uint16_t size;
size_t retval;
if (this->read_16bit(file, size)) {
return true;
......@@ -558,7 +549,6 @@ public:
}
TZXBlock(uint8_t *data, uint16_t size) : FullBlock() {
size_t retval;
this->next = NULL;
this->data = new uint8_t[size];
......@@ -595,7 +585,6 @@ public:
bool load_block(ifstream *file) {
uint16_t size;
uint16_t pause;
size_t retval;
// read pause duration
if (this->read_16bit(file, pause)) {
......@@ -702,7 +691,6 @@ public:
}
bool load_block(ifstream *file) {
size_t retval;
uint16_t pause;
// read pilot pulse duration
......@@ -771,7 +759,7 @@ class PureDataBlock : public TapeBlock {
uint8_t bit;
uint8_t bit_counter;
int pointer;
unsigned int pointer;
public:
~PureDataBlock() {
......@@ -808,8 +796,8 @@ public:
}
bool load_block(ifstream *file) {
int loop;
uint16_t lpause;
unsigned int loop;
uint16_t lpause;
// read pulse lengths
if (this->read_16bit(file, this->zero)) {
return true;
......@@ -971,8 +959,8 @@ public:
}
bool load_block(ifstream *file) {
uint8_t loop;
uint16_t pulses[255];
uint8_t loop;
// read repetitions
if (this->read_8bit(file, this->npulses)) {
return true;
......@@ -1037,7 +1025,6 @@ public:
}
bool load_block(ifstream *file) {
uint16_t length;
// read pilot pulse duration
if (this->read_16bit(file, this->length)) {
return true;
......@@ -1172,8 +1159,6 @@ public:
}
bool load_block(ifstream *file) {
size_t retval;
if (this->read_16bit(file, this->size)) {
return true;
}
......@@ -1223,8 +1208,6 @@ public:
}
bool load_block(ifstream *file) {
size_t retval;
if (this->read_8bit(file, this->size)) {
return true;
}
......@@ -1330,7 +1313,6 @@ bool Tape::load_tzx(string filename) {
ifstream * file;
uint8_t block_type;
uint8_t tmpdata[10];
size_t retval;
class TapeBlock *block;
file = new ifstream(filename.c_str(), ios::in | ios::binary);
......
CC = gcc -c -O1 -Wall
CCo = gcc -O1 -Wall
CC = gcc -c -O2 -Wall
CCo = gcc -O2 -Wall
all: z80free_tester
clean:
rm -f *.o z80free_tester
z80free_tester: z80free_tester.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o
$(CCo) -o z80free_tester z80free_tester.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o
......
This diff is collapsed.
......@@ -18,146 +18,145 @@
*
*/