computer.hh 3.32 KB
Newer Older
Sergio Costas's avatar
Sergio Costas committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Copyright 2003-2009 (C) Raster Software Vigo (Sergio Costas)
 * This file is part of FBZX
 *
 * FBZX is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * FBZX is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 *
Sergio Costas's avatar
Sergio Costas committed
18 19 20 21 22
 */

#ifndef computer_h
#define computer_h

23 24
#include <SDL2/SDL.h>
#include <SDL2/SDL_thread.h>
Sergio Costas's avatar
Sergio Costas committed
25 26

#include "tape.hh"
Sergio Costas's avatar
Sergio Costas committed
27
#include "z80free/Z80free.h"
28
#include "llscreen.hh"
29
#include "signals.hh"
30
#include "screen.hh"
Sergio Costas's avatar
Sergio Costas committed
31 32 33

// #define MUT

34 35 36 37
#define CONTENTION_RD     3
#define CONTENTION_WR     3
#define CONTENTION_IN     3
#define CONTENTION_OUT    3
38

Sergio Costas's avatar
Sergio Costas committed
39 40
extern char salir;

41 42
extern class computer *ordenador;

43 44 45 46 47 48 49 50 51 52 53 54
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
};
55

56 57 58 59
enum taptypes {
	TAP_TAP,
	TAP_TZX
};
Sergio Costas's avatar
Sergio Costas committed
60

61 62 63 64 65 66 67
enum CurrentMode {
	MODE_48K,
	MODE_128K,
	MODE_P2,
	MODE_P3,
	MODE_128K_SPA
};
68

69 70
class computer : public Signals {
public:
Sergio Costas's avatar
Sergio Costas committed
71 72 73
	unsigned int temporal_io;

	unsigned char zaurus_mini;
74 75
	bool dblscan;
	bool bw;
Sergio Costas's avatar
Sergio Costas committed
76

Sergio Costas's avatar
Sergio Costas committed
77
	int memcontended_zone; // memory contended tstates from this instant up to the next non-contended block
78 79
	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)
80

Sergio Costas's avatar
Sergio Costas committed
81 82
	// Linux joystick private global variables

83
	unsigned char updown, leftright;
Sergio Costas's avatar
Sergio Costas committed
84

85
	// Sound variables
Sergio Costas's avatar
Sergio Costas committed
86 87 88 89 90 91
	unsigned char sound_bit;

	// bus global variables

	unsigned char bus_counter;
	unsigned char bus_value;
92
	unsigned char bus_value2;
93 94
	bool issue_3; // 2= 48K issue 2, 3= 48K issue 3
	enum CurrentMode current_mode;
Sergio Costas's avatar
Sergio Costas committed
95 96 97 98
	unsigned char port254;

	// tape global variables

99
	string current_tap;
100
	bool tape_write;     // FALSE can't write; TRUE can write
101
	bool tape_fast_load; // FALSE normal load; TRUE fast load
Sergio Costas's avatar
Sergio Costas committed
102 103 104

	// pagination global variables

105 106 107 108
	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
Sergio Costas's avatar
Sergio Costas committed
109 110 111 112 113 114

	// 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;
115
	unsigned char other_ret;       // 0=no change; 1=memory returns RET (201)
Sergio Costas's avatar
Sergio Costas committed
116

117
	bool turbo;
118
	bool turbo_play;
119 120 121 122

	computer();
	~computer();
	bool callback_receiver(string, class Signals *);
123 124
	byte bus_empty();
	void emulate(int);
Sergio Costas's avatar
Sergio Costas committed
125
	void do_contention(bool io, word addr);
126
	uint8_t read_memory(uint16_t Addr);
127
	void write_memory(uint16_t Addr, uint8_t Value);
Sergio Costas's avatar
Sergio Costas committed
128 129
};

130
void fill_audio(void *udata, Uint8 *, int);
Sergio Costas's avatar
Sergio Costas committed
131 132 133
void ResetComputer();

#endif