OSDN Git Service

[VM][COMMON_VM] Include IO:: class to common_vm.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz1p17.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2015.12.24-
6
7         [ MZ-1P17 ]
8
9         Modify : Hideki Suga
10         Date   : 2016.03.18-
11
12         [ MZ-80P3 / MZ-80P4 ]
13 */
14
15 #ifndef _MZ1P17_H_
16 #define _MZ1P17_H_
17
18 #include "vm.h"
19 #include "../emu.h"
20 #include "device.h"
21
22 #define MZ1P17_MODE_MZ1         0
23 #define MZ1P17_MODE_MZ2         1
24 #define MZ1P17_MODE_MZ3         2
25 #define MZ1P17_MODE_X1          3
26 #define MZ1P17_MODE_MZ80P4      4
27
28 // for correct super/sub script mode
29 //#define PIXEL_PER_INCH        720
30 // for correct 1/120 inch scroll
31 #define PIXEL_PER_INCH  360
32 // for correct 1/180 inch dots
33 //#define PIXEL_PER_INCH        180
34 #define DOT_PER_INCH    180
35 #define DOT_SCALE       (PIXEL_PER_INCH / DOT_PER_INCH)
36
37 class FIFO;
38
39 class MZ1P17 : public DEVICE
40 {
41 private:
42         outputs_t outputs_busy;
43         outputs_t outputs_ack;
44         
45         int value, busy_id, ack_id, wait_frames;
46         bool strobe, res, busy, ack;
47         
48         bitmap_t bitmap_paper;
49         bitmap_t bitmap_line[4];
50         font_t font;
51         int space_left, space_top;
52         
53         bool ank[256][16][8];
54         bool gaiji[3][94][48][48];              // 0x78-0x7a,0x21-0x7e
55         bool htab[1440 * DOT_SCALE];
56         struct {
57                 int y;
58                 bool active;
59         } vtab[14];
60         
61         FIFO *fifo;
62         
63         int lf_pitch;
64         bool prev_esc_6;
65         int margin_left, margin_right;
66         int pitch_mode;
67         int script_mode;
68         bool kanji_mode, kanji_half, hiragana_mode;
69         bool bold, underline, reverse, vertical;
70         
71         bool ank_double_x, ank_double_y;
72         bool kanji_double_x, kanji_double_y;
73         int kanji_pitch, kanji_half_pitch;
74         
75         int dest_line_x, dest_paper_y;
76         int color_mode;
77         bool double_y_printed;
78         bool line_printed, paper_printed;
79         int paper_index, written_length;
80         _TCHAR base_path[_MAX_PATH];
81         
82         void set_busy(bool value);
83         void set_ack(bool value);
84         void process_mz1();
85         void process_mz2();
86         void process_mz3();
87         void process_x1();
88         void process_mz80p4();
89         void draw_char(uint16_t code);
90         void draw_dot(bitmap_t *bitmap, int x, int y, int width, int height, uint8_t r, uint8_t g, uint8_t b);
91         void scroll(int value);
92         void finish();
93         void finish_line();
94         void finish_paper();
95         
96 public:
97         MZ1P17(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
98         {
99                 initialize_output_signals(&outputs_busy);
100                 initialize_output_signals(&outputs_ack);
101                 set_device_name(_T("MZ-1P17 KANJI THERMAL PRINTER"));
102         }
103         ~MZ1P17() {}
104         
105         // common functions
106         void initialize();
107         void release();
108         void reset();
109         void event_frame();
110         void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
111         uint32_t __FASTCALL read_signal(int ch);
112         void event_callback(int event_id, int err);
113         bool process_state(FILEIO* state_fio, bool loading);
114         
115         // unique functions
116         void set_context_busy(DEVICE* device, int id, uint32_t mask)
117         {
118                 register_output_signal(&outputs_busy, device, id, mask);
119         }
120         void set_context_ack(DEVICE* device, int id, uint32_t mask)
121         {
122                 register_output_signal(&outputs_ack, device, id, mask);
123         }
124         int mode;
125 };
126
127 #endif
128