OSDN Git Service

[VM][FM77AV][MB61VH010] Fix line putting.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fm7 / mb61vh010.h
1 /*
2  * FM77AV/FM16β ALU [mb61vh010.h]
3  *
4  * Author: K.Ohta <whatisthis.sowhat _at_ gmail.com>
5  * License: GPLv2
6  * History:
7  *   Mar 28, 2015 : Initial
8  *
9  */
10
11 #ifndef _VM_FM77AV_16beta_ALU_H_
12 #define _VM_FM77AV_16beta_ALU_H_
13
14
15 #include "../device.h"
16 #include "../memory.h"
17 #include "fm7_common.h"
18
19 enum {
20         ALU_CMDREG = 0,
21         ALU_LOGICAL_COLOR,
22         ALU_WRITE_MASKREG,
23         ALU_CMP_STATUS_REG,
24         ALU_BANK_DISABLE,
25         ALU_TILEPAINT_B,
26         ALU_TILEPAINT_R,
27         ALU_TILEPAINT_G,
28         ALU_TILEPAINT_L,
29         ALU_OFFSET_REG_HIGH,
30         ALU_OFFSET_REG_LO,
31         ALU_LINEPATTERN_REG_HIGH,
32         ALU_LINEPATTERN_REG_LO,
33         ALU_LINEPOS_START_X_HIGH,
34         ALU_LINEPOS_START_X_LOW,  
35         ALU_LINEPOS_START_Y_HIGH,
36         ALU_LINEPOS_START_Y_LOW,  
37         ALU_LINEPOS_END_X_HIGH,
38         ALU_LINEPOS_END_X_LOW,  
39         ALU_LINEPOS_END_Y_HIGH,
40         ALU_LINEPOS_END_Y_LOW,
41         ALU_CMPDATA_REG = 0x10000,
42         ALU_WRITE_PROXY = 0x20000,
43 };
44
45 enum {
46         SIG_ALU_BUSYSTAT = 1,
47 };
48
49 enum {
50         EVENT_MB61VH010_BUSY_ON = 0,
51         EVENT_MB61VH010_BUSY_OFF
52 };
53
54 class MB61VH010: public DEVICE {
55
56  protected:
57         EMU *p_emu;
58         VM *p_vm;
59         DEVICE *target;
60         
61         // Registers
62         uint8 command_reg;        // D410 (RW)
63         uint8 color_reg;          // D411 (RW)
64         uint8 mask_reg;           // D412 (RW)
65         uint8 cmp_status_reg;     // D413 (RO)
66         uint8 cmp_color_data[8]; // D413-D41A (WO)
67         uint8 bank_disable_reg;   // D41B (RW)
68         uint8 tile_reg[4];        // D41C-D41F (WO)
69         
70         pair  line_addr_offset; // D420-D421 (WO)
71         pair  line_pattern;     // D422-D423 (WO)
72         pair  line_xbegin;      // D424-D425 (WO)
73         pair  line_ybegin;      // D426-D427 (WO)
74         pair  line_xend;        // D428-D429 (WO)
75         pair  line_yend;        // D42A-D42B (WO)
76         
77         bool busy_flag;
78         int eventid_busy;
79
80         uint32 planes;
81         uint32 total_bytes;
82         bool is_400line;
83         uint32 screen_width;
84         uint32 screen_height;
85         uint32 oldaddr;
86         uint32 alu_addr;
87
88         pair line_style;
89         
90         // ALU COMMANDS
91         uint8 do_read(uint32 addr,  uint32 bank);
92         uint8 do_write(uint32 addr, uint32 bank, uint8 data);
93         uint8 do_pset(uint32 addr);
94         uint8 do_blank(uint32 addr);
95         uint8 do_or(uint32 addr);
96         uint8 do_and(uint32 addr);
97         uint8 do_xor(uint32 addr);
98         uint8 do_not(uint32 addr);
99         uint8 do_tilepaint(uint32 addr);
100         uint8 do_compare(uint32 addr);
101         uint8 do_alucmds(uint32 addr);
102         void do_alucmds_dmyread(uint32 addr);
103         bool put_dot(int x, int y);
104
105         // LINE
106         void do_line(void);
107  public:
108         MB61VH010(VM *parent_vm, EMU *parent_emu);
109         ~MB61VH010();
110
111         void event_callback(int event_id, int err);
112         void write_data8(uint32 id, uint32 data);
113         uint32 read_data8(uint32 addr);
114         uint32 read_signal(int id); 
115         void initialize(void);
116         void reset(void);
117         //void update_config(void);
118         
119         void set_context_memory(DEVICE *p)
120         {
121                 target = p;
122         }
123 };      
124
125
126 #endif // _VM_FM77AV_16beta_ALU_H_