Cirrus.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 
00066 #if !defined(INCLUDED_Cirrus_H_)
00067 #define INCLUDED_Cirrus_H_
00068 
00069 #include "VGA.h"
00070 #include "gui/vga.h"
00071 
00072 /* video card has 4M of ram */
00073 #define VIDEO_RAM_SIZE  22
00074 #define CRTC_MAX        0x57
00075 
00084 class CCirrus : public CVGA, public Poco::Runnable
00085 {
00086   public:
00087     virtual int   SaveState(FILE* f);
00088     virtual int   RestoreState(FILE* f);
00089     virtual void  check_state();
00090     virtual void  WriteMem_Legacy(int index, u32 address, int dsize, u32 data);
00091     virtual u32   ReadMem_Legacy(int index, u32 address, int dsize);
00092 
00093     virtual void  WriteMem_Bar(int func, int bar, u32 address, int dsize,
00094                                u32 data);
00095     virtual u32   ReadMem_Bar(int func, int bar, u32 address, int dsize);
00096 
00097     CCirrus(CConfigurator* cfg, class CSystem* c, int pcibus, int pcidev);
00098     virtual       ~CCirrus();
00099 
00100     void          update(void);
00101     void          run(void);
00102 
00103     virtual void  init();
00104     virtual void  start_threads();
00105     virtual void  stop_threads();
00106 
00107     virtual u8    get_actl_palette_idx(u8 index);
00108     virtual void  redraw_area(unsigned x0, unsigned y0, unsigned width,
00109                               unsigned height);
00110   private:
00111     u32   mem_read(u32 address, int dsize);
00112     void  mem_write(u32 address, int dsize, u32 data);
00113 
00114     u32   io_read(u32 address, int dsize);
00115     void  io_write(u32 address, int dsize, u32 data);
00116 
00117     void  io_write_b(u32 address, u8 data);
00118 
00119     void  write_b_3c0(u8 data);
00120     void  write_b_3c2(u8 data);
00121     void  write_b_3c4(u8 data);
00122     void  write_b_3c5(u8 data);
00123     void  write_b_3c6(u8 data);
00124     void  write_b_3c7(u8 data);
00125     void  write_b_3c8(u8 data);
00126     void  write_b_3c9(u8 data);
00127     void  write_b_3ce(u8 data);
00128     void  write_b_3cf(u8 data);
00129     void  write_b_3d4(u8 data);
00130     void  write_b_3d5(u8 data);
00131 
00132     u8    read_b_3c0();
00133     u8    read_b_3c1();
00134     u8    read_b_3c2();
00135     u8    read_b_3c3();
00136     u8    read_b_3c4();
00137     u8    read_b_3c5();
00138     u8    read_b_3c9();
00139     u8    read_b_3ca();
00140     u8    read_b_3cc();
00141     u8    read_b_3cf();
00142     u8    read_b_3d4();
00143     u8    read_b_3d5();
00144     u8    read_b_3da();
00145 
00146     u32   legacy_read(u32 address, int dsize);
00147     void  legacy_write(u32 address, int dsize, u32 data);
00148 
00149     u32   rom_read(u32 address, int dsize);
00150 
00151     void  determine_screen_dimensions(unsigned* piHeight, unsigned* piWidth);
00152 
00153     char  bios_message[200];
00154     int   bios_message_size;
00155 
00156     void  vga_mem_write(u32 addr, u8 value);
00157     u8    vga_mem_read(u32 addr);
00158 
00159     Poco::Thread * myThread;
00160     bool  StopThread;
00161 
00163     struct SCirrus_state
00164     {
00165 
00166       //      u8 disabled;
00167       //      u8 framebuffer[1<<VIDEO_RAM_SIZE];
00168       //      u8 legacybuffer[131072];
00169       //      u64 video_base;
00170       bool      vga_enabled;
00171       bool      vga_mem_updated;
00172       u16       charmap_address;
00173       bool      x_dotclockdiv2;
00174       bool      y_doublescan;
00175       unsigned  line_offset;
00176       unsigned  line_compare;
00177       unsigned  vertical_display_end;
00178 
00179       //      u8 vga_memory[256 * 1024];
00180       u8        text_snapshot[32 * 1024];           // current text snapshot
00181       bool      vga_tile_updated[BX_NUM_X_TILES][BX_NUM_Y_TILES];
00182       u8*       memory;
00183       u32       memsize;
00184       u8        last_bpp;
00185       u8        tile[X_TILESIZE * Y_TILESIZE * 4];  
00186       unsigned  x_tilesize;
00187       unsigned  y_tilesize;
00188 
00189       struct SCirrus_attr
00190       {
00191         bool      flip_flop;    /* 0 = address, 1 = data-write */
00192         unsigned  address;      /* register number */
00193         bool      video_enabled;
00194         u8        palette_reg[16];
00195         u8        overscan_color;
00196         u8        color_plane_enable;
00197         u8        horiz_pel_panning;
00198         u8        color_select;
00199         struct SCirrus_mode
00200         {
00201           bool  graphics_alpha;
00202           bool  display_type;
00203           bool  enable_line_graphics;
00204           bool  blink_intensity;
00205           bool  pixel_panning_compat;
00206           bool  pixel_clock_select;
00207           bool  internal_palette_size;
00208         } mode_ctrl;
00209       } attribute_ctrl;
00210 
00211       struct SCirrus_misc
00212       {
00213         bool  color_emulation;  // 1=color emulation, base address = 3Dx
00214 
00215         // 0=mono emulation,  base address = 3Bx
00216         bool  enable_ram;       // enable CPU access to video memory if set
00217         u8    clock_select;     // 0=25Mhz 1=28Mhz
00218         bool  select_high_bank; // when in odd/even modes, select
00219 
00220         // high 64k bank if set
00221         bool  horiz_sync_pol;   // bit6: negative if set
00222         bool  vert_sync_pol;    // bit7: negative if set
00223 
00224         //   bit7,bit6 represent number of lines on display:
00225         //   0 = reserved
00226         //   1 = 400 lines
00227         //   2 = 350 lines
00228         //   3 - 480 lines
00229       } misc_output;
00230 
00231       struct SCirrus_seq
00232       {
00233         u8    index;
00234         u8    map_mask;
00235         bool  map_mask_bit[4];
00236         bool  reset1;
00237         bool  reset2;
00238         u8    reg1;
00239         u8    char_map_select;
00240         bool  extended_mem;
00241         bool  odd_even;
00242         bool  chain_four;
00243       } sequencer;
00244 
00245       struct SCirus_pel
00246       {
00247         u8  write_data_register;
00248         u8  write_data_cycle;   /* 0, 1, 2 */
00249         u8  read_data_register;
00250         u8  read_data_cycle;    /* 0, 1, 2 */
00251         u8  dac_state;
00252         struct SCirrus_peldata
00253         {
00254           u8  red;
00255           u8  green;
00256           u8  blue;
00257         } data[256];
00258         u8  mask;
00259       } pel;
00260 
00261       struct SCirrus_gfx
00262       {
00263         u8    index;
00264         u8    set_reset;
00265         u8    enable_set_reset;
00266         u8    color_compare;
00267         u8    data_rotate;
00268         u8    raster_op;
00269         u8    read_map_select;
00270         u8    write_mode;
00271         bool  read_mode;
00272         bool  odd_even;
00273         bool  chain_odd_even;
00274         u8    shift_reg;
00275         bool  graphics_alpha;
00276         u8    memory_mapping;   /* 0 = use A0000-BFFFF
00277                                  * 1 = use A0000-AFFFF EGA/VGA graphics modes
00278                                  * 2 = use B0000-B7FFF Monochrome modes
00279                                  * 3 = use B8000-BFFFF CGA modes
00280                                  */
00281         u8    color_dont_care;
00282         u8    bitmask;
00283         u8    latch[4];
00284       } graphics_ctrl;
00285 
00286       struct SCirrus_crtc
00287       {
00288         u8    address;
00289         u8    reg[0x20];
00290         bool  write_protect;
00291       } CRTC;
00292     } state;
00293 };
00294 #endif // !defined(INCLUDED_Cirrus_H_)

SourceForge.net Logo
Project space on SourceForge.net