DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
include/pc98_gdc.h
00001 
00002 #define PC98_GDC_FIFO_SIZE      32      /* taken from Neko Project II, but what is it really? */
00003 #define GDC_COMMAND_BYTE        0x100
00004 
00005 enum {
00006     GDC_MASTER=0,
00007     GDC_SLAVE=1
00008 };
00009 
00010 // VOPBIT_* source: Neko Project II
00011 
00012 // operate:             bit0    access page
00013 //                              bit1    egc enable
00014 //                              bit2    grcg bit6
00015 //                              bit3    grcg bit7
00016 //                              bit4    analog enable (16/256-color mode). 8-color mode if not.
00017 //                              bit5    pc9821 vga
00018 
00019 enum {
00020         VOPBIT_ACCESS   = 0,
00021         VOPBIT_EGC              = 1,
00022         VOPBIT_GRCG             = 2,
00023         VOPBIT_ANALOG   = 4,
00024         VOPBIT_VGA              = 5,
00025     VOPBIT_PEGC_PLANAR = 6
00026 };
00027 
00028 union pc98_tile {
00029     uint8_t                 b[2];
00030     uint16_t                w;
00031 };
00032 
00033 struct PC98_GDC_state {
00034     PC98_GDC_state();
00035     void reset_fifo(void);
00036     void reset_rfifo(void);
00037     void flush_fifo_old(void);
00038     bool write_fifo(const uint16_t c);
00039     bool write_rfifo(const uint8_t c);
00040     bool write_fifo_command(const unsigned char c);
00041     bool write_fifo_param(const unsigned char c);
00042     bool rfifo_has_content(void);
00043     uint8_t read_status(void);
00044     uint8_t rfifo_read_data(void);
00045     void idle_proc(void);
00046 
00047     void force_fifo_complete(void);
00048     void take_cursor_char_setup(unsigned char bi);
00049     void take_cursor_pos(unsigned char bi);
00050     void take_reset_sync_parameters(void);
00051     void cursor_advance(void);
00052 
00053     void begin_frame(void);
00054     void next_line(void);
00055 
00056     void load_display_partition(void);
00057     void next_display_partition(void);
00058 
00059     size_t fifo_can_read(void);
00060     bool fifo_empty(void);
00061     Bit16u read_fifo(void);
00062 
00063     /* NTS:
00064      *
00065      * We're following the Neko Project II method of FIFO emulation BUT
00066      * I wonder if the GDC maintains two FIFOs and allows stacking params
00067      * in one and commands in another....? */
00068 
00069     uint8_t                 cmd_parm_tmp[8];            /* temp storage before accepting params */
00070 
00071     uint8_t                 rfifo[PC98_GDC_FIFO_SIZE];
00072     uint8_t                 rfifo_read,rfifo_write;
00073 
00074     uint16_t                fifo[PC98_GDC_FIFO_SIZE];   /* NTS: Neko Project II uses one big FIFO for command and data, which makes sense to me */
00075     uint8_t                 fifo_read,fifo_write;
00076 
00077     uint8_t                 param_ram[16];
00078     uint8_t                 param_ram_wptr;
00079 
00080     uint16_t                scan_address;
00081     uint8_t                 row_height;
00082     uint8_t                 row_line;
00083 
00084     uint8_t                 display_partition;
00085     uint16_t                display_partition_rem_lines;
00086     uint8_t                 display_partition_mask;
00087 
00088     uint16_t                active_display_lines;       /* AL (translated) */
00089     uint16_t                active_display_words_per_line;/* AW bits (translated) */
00090     uint16_t                display_pitch;
00091     uint8_t                 horizontal_sync_width;      /* HS (translated) */
00092     uint8_t                 vertical_sync_width;        /* VS (translated) */
00093     uint8_t                 horizontal_front_porch_width;/* HFP (translated) */
00094     uint8_t                 horizontal_back_porch_width;/* HBP (translated) */
00095     uint8_t                 vertical_front_porch_width; /* VFP (translated) */
00096     uint8_t                 vertical_back_porch_width;  /* VBP (translated) */
00097     uint8_t                 display_mode;               /* CG bits */
00098             /* CG = 00 = mixed graphics & character
00099              * CG = 01 = graphics mode
00100              * CG = 10 = character mode
00101              * CG = 11 = invalid */
00102     uint8_t                 video_framing;              /* IS bits */
00103             /* IS = 00 = non-interlaced
00104              * IS = 01 = invalid
00105              * IS = 10 = interlaced repeat field for character displays
00106              * IS = 11 = interlaced */
00107     uint8_t                 current_command;
00108     uint8_t                 proc_step;
00109     uint8_t                 cursor_blink_state;
00110     uint8_t                 cursor_blink_count;         /* count from 0 to BR - 1 */
00111     uint8_t                 cursor_blink_rate;          /* BR */
00112     bool                    draw_only_during_retrace;   /* F bits */
00113     bool                    dynamic_ram_refresh;        /* D bits */
00114     bool                    master_sync;                /* master source generation */
00115     bool                    display_enable;
00116     bool                    cursor_enable;
00117     bool                    cursor_blink;
00118     bool                    IM_bit;                     /* display partition, IM bit */
00119     bool                    idle;
00120 
00121     bool                    doublescan;                 /* 200-line as 400-line */
00122 };
00123 
00124 typedef union pc98_tile             egc_quad[4];
00125 
00126 extern bool                         gdc_analog;
00127 
00128 extern uint32_t                     pc98_text_palette[8];
00129 
00130 extern struct PC98_GDC_state        pc98_gdc[2];
00131 extern egc_quad                     pc98_gdc_tiles;
00132 extern uint8_t                      pc98_gdc_vramop;
00133 extern uint8_t                      pc98_gdc_modereg;
00134