OSDN Git Service

ae8eff5abc9e481357b5bebed958b3bec6b359db
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc9801 / display.h
1 /*
2         NEC PC-9801 Emulator 'ePC-9801'
3         NEC PC-9801E/F/M Emulator 'ePC-9801E'
4         NEC PC-9801U Emulator 'ePC-9801U'
5         NEC PC-9801VF Emulator 'ePC-9801VF'
6         NEC PC-9801VM Emulator 'ePC-9801VM'
7         NEC PC-9801VX Emulator 'ePC-9801VX'
8         NEC PC-9801RA Emulator 'ePC-9801RA'
9         NEC PC-98XA Emulator 'ePC-98XA'
10         NEC PC-98XL Emulator 'ePC-98XL'
11         NEC PC-98RL Emulator 'ePC-98RL'
12         NEC PC-98DO Emulator 'ePC-98DO'
13
14         Author : Takeda.Toshiya
15         Date   : 2010.09.16-
16
17         [ display ]
18 */
19
20 #ifndef _DISPLAY_H_
21 #define _DISPLAY_H_
22
23 #include "../vm.h"
24 #include "../../emu.h"
25 #include "../device.h"
26
27 class UPD7220;
28
29 class DISPLAY : public DEVICE
30 {
31 private:
32         DEVICE *d_pic;
33         UPD7220 *d_gdc_chr, *d_gdc_gfx;
34         uint8_t *ra_chr;
35         uint8_t *ra_gfx, *cs_gfx;
36         
37         uint8_t tvram[0x4000];
38 #if !defined(SUPPORT_HIRESO)
39 #if defined(SUPPORT_2ND_VRAM)
40         uint8_t vram[0x40000];
41 #else
42         uint8_t vram[0x20000];
43 #endif
44 #else
45         uint8_t vram[0x80000];
46 #endif
47         
48 #if defined(SUPPORT_2ND_VRAM) && !defined(SUPPORT_HIRESO)
49         uint8_t vram_disp_sel;
50         uint8_t vram_draw_sel;
51 #endif
52         uint8_t *vram_disp_b;
53         uint8_t *vram_disp_r;
54         uint8_t *vram_disp_g;
55 #if defined(SUPPORT_16_COLORS)
56         uint8_t *vram_disp_e;
57 #endif
58         uint8_t *vram_draw;
59         
60         scrntype_t palette_chr[8];
61         scrntype_t palette_gfx8[8];
62         uint8_t digipal[4];
63 #if defined(SUPPORT_16_COLORS)
64         scrntype_t palette_gfx16[16];
65         uint8_t anapal[16][3], anapal_sel;
66 #endif
67         
68         uint8_t crtv;
69         uint8_t scroll[6];
70         uint8_t modereg1[8];
71 #if defined(SUPPORT_16_COLORS)
72         uint8_t modereg2[128];
73 #endif
74 #if defined(SUPPORT_GRCG)
75         uint8_t grcg_mode, grcg_tile_ptr, grcg_tile[4];
76 #endif
77 #if defined(SUPPORT_EGC)
78         typedef union {
79                 uint8_t b[2];
80                 uint16_t w;
81         } egcword_t;
82         typedef union {
83                 uint8_t b[4][2];
84                 uint16_t w[4];
85                 uint32_t d[2];
86                 uint64_t q;
87         } egcquad_t;
88         
89         uint16_t egc_access;
90         uint16_t egc_fgbg;
91         uint16_t egc_ope;
92         uint16_t egc_fg;
93         egcword_t egc_mask;
94         uint16_t egc_bg;
95         uint16_t egc_sft;
96         uint16_t egc_leng;
97         egcquad_t egc_lastvram;
98         egcquad_t egc_patreg;
99         egcquad_t egc_fgc;
100         egcquad_t egc_bgc;
101         int egc_func;
102         uint32_t egc_remain;
103         uint32_t egc_stack;
104         uint8_t* egc_inptr;
105         uint8_t* egc_outptr;
106
107         int tmp_inptr_ofs;
108         int tmp_outptr_ofs;
109         
110         egcword_t egc_mask2;
111         egcword_t egc_srcmask;
112         uint8_t egc_srcbit;
113         uint8_t egc_dstbit;
114         uint8_t egc_sft8bitl;
115         uint8_t egc_sft8bitr;
116         uint8_t egc_buf[528];   /* 4096/8 + 4*4 */
117         egcquad_t egc_vram_src;
118         egcquad_t egc_vram_data;
119 #endif
120         
121 #if !defined(SUPPORT_HIRESO)
122         #define FONT_SIZE       16
123         #define FONT_WIDTH      8
124         #define FONT_HEIGHT     16
125 #else
126         #define FONT_SIZE       48
127         #define FONT_WIDTH      14
128         #define FONT_HEIGHT     24
129 #endif
130         #define KANJI_2ND_OFS   (FONT_SIZE * 0x80)
131         #define KANJI_FONT_SIZE (FONT_SIZE * 2)
132         #define ANK_FONT_OFS    (KANJI_FONT_SIZE * 0x4000)
133         
134         uint8_t font[ANK_FONT_OFS + FONT_SIZE * 0x400];
135         uint16_t font_code;
136         uint8_t font_line;
137 //      uint16_t font_lr;
138         
139         uint8_t screen_chr[SCREEN_HEIGHT][SCREEN_WIDTH + 1];
140         uint8_t screen_gfx[SCREEN_HEIGHT][SCREEN_WIDTH];
141         
142 #if !defined(SUPPORT_HIRESO)
143         void kanji_copy(uint8_t *dst, uint8_t *src, int from, int to);
144 #else
145         void ank_copy(int code, uint8_t *pattern);
146         void kanji_copy(int first, int second, uint8_t *pattern);
147 #endif
148 #if defined(SUPPORT_GRCG)
149         void grcg_writeb(uint32_t addr1, uint32_t data);
150         void grcg_writew(uint32_t addr1, uint32_t data);
151         uint32_t grcg_readb(uint32_t addr1);
152         uint32_t grcg_readw(uint32_t addr1);
153 #endif
154 #if defined(SUPPORT_EGC)
155         void egc_shift();
156         void egc_sftb_upn_sub(uint32_t ext);
157         void egc_sftb_dnn_sub(uint32_t ext);
158         void egc_sftb_upr_sub(uint32_t ext);
159         void egc_sftb_dnr_sub(uint32_t ext);
160         void egc_sftb_upl_sub(uint32_t ext);
161         void egc_sftb_dnl_sub(uint32_t ext);
162         void egc_sftb_upn0(uint32_t ext);
163         void egc_sftw_upn0();
164         void egc_sftb_dnn0(uint32_t ext);
165         void egc_sftw_dnn0();
166         void egc_sftb_upr0(uint32_t ext);
167         void egc_sftw_upr0();
168         void egc_sftb_dnr0(uint32_t ext);
169         void egc_sftw_dnr0();
170         void egc_sftb_upl0(uint32_t ext);
171         void egc_sftw_upl0();
172         void egc_sftb_dnl0(uint32_t ext);
173         void egc_sftw_dnl0();
174         void egc_sftb(int func, uint32_t ext);
175         void egc_sftw(int func);
176         void egc_shiftinput_byte(uint32_t ext);
177         void egc_shiftinput_incw();
178         void egc_shiftinput_decw();
179         uint64_t egc_ope_00(uint8_t ope, uint32_t addr);
180         uint64_t egc_ope_0f(uint8_t ope, uint32_t addr);
181         uint64_t egc_ope_c0(uint8_t ope, uint32_t addr);
182         uint64_t egc_ope_f0(uint8_t ope, uint32_t addr);
183         uint64_t egc_ope_fc(uint8_t ope, uint32_t addr);
184         uint64_t egc_ope_ff(uint8_t ope, uint32_t addr);
185         uint64_t egc_ope_nd(uint8_t ope, uint32_t addr);
186         uint64_t egc_ope_np(uint8_t ope, uint32_t addr);
187         uint64_t egc_ope_xx(uint8_t ope, uint32_t addr);
188         uint64_t egc_opefn(uint32_t func, uint8_t ope, uint32_t addr);
189         uint64_t egc_opeb(uint32_t addr, uint8_t value);
190         uint64_t egc_opew(uint32_t addr, uint16_t value);
191         uint32_t egc_readb(uint32_t addr1);
192         uint32_t egc_readw(uint32_t addr1);
193         void egc_writeb(uint32_t addr1, uint8_t value);
194         void egc_writew(uint32_t addr1, uint16_t value);
195 #endif
196         void draw_chr_screen();
197         void draw_gfx_screen();
198         
199 public:
200         DISPLAY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
201         {
202                 memset(tvram, 0, sizeof(tvram));
203                 set_device_name(_T("Display"));
204         }
205         ~DISPLAY() {}
206         
207         // common functions
208         void initialize();
209         void release();
210         void reset();
211         void event_frame();
212         void write_io8(uint32_t addr, uint32_t data);
213         uint32_t read_io8(uint32_t addr);
214         void write_memory_mapped_io8(uint32_t addr, uint32_t data);
215         void write_memory_mapped_io16(uint32_t addr, uint32_t data);
216         uint32_t read_memory_mapped_io8(uint32_t addr);
217         uint32_t read_memory_mapped_io16(uint32_t addr);
218         void write_dma_io8(uint32_t addr, uint32_t data);
219         void write_dma_io16(uint32_t addr, uint32_t data);
220         uint32_t read_dma_io8(uint32_t addr);
221         uint32_t read_dma_io16(uint32_t addr);
222         bool process_state(FILEIO* state_fio, bool loading);
223         
224         // unique functions
225         void set_context_pic(DEVICE *device)
226         {
227                 d_pic = device;
228         }
229         void set_context_gdc_chr(UPD7220 *device, uint8_t *ra)
230         {
231                 d_gdc_chr = device;
232                 ra_chr = ra;
233         }
234         void set_context_gdc_gfx(UPD7220 *device, uint8_t *ra, uint8_t *cs)
235         {
236                 d_gdc_gfx = device;
237                 ra_gfx = ra; cs_gfx = cs;
238         }
239         void sound_bios_ok()
240         {
241                 tvram[0x3fee] = 8;
242         }
243         void draw_screen();
244 };
245
246 #endif
247