S3Trio64.h

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
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 /* video card has 4M of ram */
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];           // current text snapshot
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;    /* 0 = address, 1 = data-write */
00184         unsigned  address;      /* register number */
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;  // 1=color emulation, base address = 3Dx
00206 
00207         // 0=mono emulation,  base address = 3Bx
00208         bool  enable_ram;       // enable CPU access to video memory if set
00209         u8    clock_select;     // 0=25Mhz 1=28Mhz
00210         bool  select_high_bank; // when in odd/even modes, select
00211 
00212         // high 64k bank if set
00213         bool  horiz_sync_pol;   // bit6: negative if set
00214         bool  vert_sync_pol;    // bit7: negative if set
00215 
00216         //   bit7,bit6 represent number of lines on display:
00217         //   0 = reserved
00218         //   1 = 400 lines
00219         //   2 = 350 lines
00220         //   3 - 480 lines
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;   /* 0, 1, 2 */
00241         u8  read_data_register;
00242         u8  read_data_cycle;    /* 0, 1, 2 */
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;   /* 0 = use A0000-BFFFF
00269                                  * 1 = use A0000-AFFFF EGA/VGA graphics modes
00270                                  * 2 = use B0000-B7FFF Monochrome modes
00271                                  * 3 = use B8000-BFFFF CGA modes
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_)

SourceForge.net Logo
Project space on SourceForge.net