00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00065 #if !defined(INCLUDED_S3Trio64_H_)
00066 #define INCLUDED_S3Trio64_H_
00067
00068 #include "VGA.h"
00069 #include "gui/vga.h"
00070
00071
00072 #define VIDEO_RAM_SIZE 22
00073 #define CRTC_MAX 0x57
00074
00083 class CS3Trio64 : public CVGA, public Poco::Runnable
00084 {
00085 public:
00086 virtual int SaveState(FILE* f);
00087 virtual int RestoreState(FILE* f);
00088 virtual void check_state();
00089 virtual void WriteMem_Legacy(int index, u32 address, int dsize, u32 data);
00090 virtual u32 ReadMem_Legacy(int index, u32 address, int dsize);
00091
00092 virtual void WriteMem_Bar(int func, int bar, u32 address, int dsize,
00093 u32 data);
00094 virtual u32 ReadMem_Bar(int func, int bar, u32 address, int dsize);
00095
00096 CS3Trio64(CConfigurator* cfg, class CSystem* c, int pcibus, int pcidev);
00097 virtual ~CS3Trio64();
00098
00099 void update(void);
00100 virtual void run(void);
00101
00102 virtual u8 get_actl_palette_idx(u8 index);
00103 virtual void redraw_area(unsigned x0, unsigned y0, unsigned width,
00104 unsigned height);
00105
00106 virtual void init();
00107 virtual void start_threads();
00108 virtual void stop_threads();
00109 private:
00110 u32 mem_read(u32 address, int dsize);
00111 void mem_write(u32 address, int dsize, u32 data);
00112
00113 u32 io_read(u32 address, int dsize);
00114 void io_write(u32 address, int dsize, u32 data);
00115
00116 void io_write_b(u32 address, u8 data);
00117
00118 void write_b_3c0(u8 data);
00119 void write_b_3c2(u8 data);
00120 void write_b_3c4(u8 data);
00121 void write_b_3c5(u8 data);
00122 void write_b_3c6(u8 data);
00123 void write_b_3c7(u8 data);
00124 void write_b_3c8(u8 data);
00125 void write_b_3c9(u8 data);
00126 void write_b_3ce(u8 data);
00127 void write_b_3cf(u8 data);
00128 void write_b_3d4(u8 data);
00129 void write_b_3d5(u8 data);
00130
00131 u8 read_b_3c0();
00132 u8 read_b_3c1();
00133 u8 read_b_3c2();
00134 u8 read_b_3c3();
00135 u8 read_b_3c4();
00136 u8 read_b_3c5();
00137 u8 read_b_3c9();
00138 u8 read_b_3ca();
00139 u8 read_b_3cc();
00140 u8 read_b_3cf();
00141 u8 read_b_3d4();
00142 u8 read_b_3d5();
00143 u8 read_b_3da();
00144
00145 u32 legacy_read(u32 address, int dsize);
00146 void legacy_write(u32 address, int dsize, u32 data);
00147
00148 u32 rom_read(u32 address, int dsize);
00149
00150 void determine_screen_dimensions(unsigned* piHeight, unsigned* piWidth);
00151
00152 char bios_message[200];
00153 int bios_message_size;
00154
00155 void vga_mem_write(u32 addr, u8 value);
00156 u8 vga_mem_read(u32 addr);
00157
00158 Poco::Thread * myThread;
00159 bool StopThread;
00160
00162 struct SS3_state
00163 {
00164 bool vga_enabled;
00165 bool vga_mem_updated;
00166 u16 charmap_address;
00167 bool x_dotclockdiv2;
00168 bool y_doublescan;
00169 unsigned line_offset;
00170 unsigned line_compare;
00171 unsigned vertical_display_end;
00172 u8 text_snapshot[32 * 1024];
00173 bool vga_tile_updated[BX_NUM_X_TILES][BX_NUM_Y_TILES];
00174 u8* memory;
00175 u32 memsize;
00176 u8 last_bpp;
00177 u8 tile[X_TILESIZE * Y_TILESIZE * 4];
00178 unsigned x_tilesize;
00179 unsigned y_tilesize;
00180
00181 struct SS3_attr
00182 {
00183 bool flip_flop;
00184 unsigned address;
00185 bool video_enabled;
00186 u8 palette_reg[16];
00187 u8 overscan_color;
00188 u8 color_plane_enable;
00189 u8 horiz_pel_panning;
00190 u8 color_select;
00191 struct SS3_mode
00192 {
00193 bool graphics_alpha;
00194 bool display_type;
00195 bool enable_line_graphics;
00196 bool blink_intensity;
00197 bool pixel_panning_compat;
00198 bool pixel_clock_select;
00199 bool internal_palette_size;
00200 } mode_ctrl;
00201 } attribute_ctrl;
00202
00203 struct SS3_misc
00204 {
00205 bool color_emulation;
00206
00207
00208 bool enable_ram;
00209 u8 clock_select;
00210 bool select_high_bank;
00211
00212
00213 bool horiz_sync_pol;
00214 bool vert_sync_pol;
00215
00216
00217
00218
00219
00220
00221 } misc_output;
00222
00223 struct SS3_seq
00224 {
00225 u8 index;
00226 u8 map_mask;
00227 bool map_mask_bit[4];
00228 bool reset1;
00229 bool reset2;
00230 u8 reg1;
00231 u8 char_map_select;
00232 bool extended_mem;
00233 bool odd_even;
00234 bool chain_four;
00235 } sequencer;
00236
00237 struct SS3_pel
00238 {
00239 u8 write_data_register;
00240 u8 write_data_cycle;
00241 u8 read_data_register;
00242 u8 read_data_cycle;
00243 u8 dac_state;
00244 struct SS3_pel_data
00245 {
00246 u8 red;
00247 u8 green;
00248 u8 blue;
00249 } data[256];
00250 u8 mask;
00251 } pel;
00252
00253 struct SS3_gfx
00254 {
00255 u8 index;
00256 u8 set_reset;
00257 u8 enable_set_reset;
00258 u8 color_compare;
00259 u8 data_rotate;
00260 u8 raster_op;
00261 u8 read_map_select;
00262 u8 write_mode;
00263 bool read_mode;
00264 bool odd_even;
00265 bool chain_odd_even;
00266 u8 shift_reg;
00267 bool graphics_alpha;
00268 u8 memory_mapping;
00269
00270
00271
00272
00273 u8 color_dont_care;
00274 u8 bitmask;
00275 u8 latch[4];
00276 } graphics_ctrl;
00277
00278 struct SS3_crtc
00279 {
00280 u8 address;
00281 u8 reg[0x20];
00282 bool write_protect;
00283 } CRTC;
00284 } state;
00285 };
00286 #endif // !defined(INCLUDED_S3Trio64_H_)