1 // license:LGPL-2.1+
2 // copyright-holders:Angelo Salese, Olivier Galibert
3 /*************************************************************************
4 
5     Taito Air System
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_TAITOAIR_H
9 #define MAME_INCLUDES_TAITOAIR_H
10 
11 #pragma once
12 
13 #include "cpu/tms32025/tms32025.h"
14 #include "machine/taitoio.h"
15 #include "machine/taitoio_yoke.h"
16 #include "video/tc0080vco.h"
17 #include "emupal.h"
18 #include "screen.h"
19 
20 enum { TAITOAIR_FRAC_SHIFT = 16, TAITOAIR_POLY_MAX_PT = 16 };
21 
22 struct taitoair_spoint {
23 	s32 x, y;
24 };
25 
26 struct taitoair_poly {
27 	struct taitoair_spoint p[TAITOAIR_POLY_MAX_PT];
28 	int pcount;
29 	u16 header;
30 };
31 
32 
33 class taitoair_state : public driver_device
34 {
35 public:
taitoair_state(const machine_config & mconfig,device_type type,const char * tag)36 	taitoair_state(const machine_config &mconfig, device_type type, const char *tag)
37 		: driver_device(mconfig, type, tag)
38 		, m_m68000_mainram(*this, "m68000_mainram")
39 		, m_line_ram(*this, "line_ram")
40 		, m_dsp_ram(*this, "dsp_ram")
41 		, m_paletteram(*this, "paletteram")
42 		, m_gradram(*this, "gradram")
43 		, m_tc0430grw(*this, "tc0430grw")
44 		, m_maincpu(*this, "maincpu")
45 		, m_audiocpu(*this, "audiocpu")
46 		, m_dsp(*this, "dsp")
47 		, m_tc0080vco(*this, "tc0080vco")
48 		, m_tc0220ioc(*this, "tc0220ioc")
49 		, m_yoke(*this, "yokectrl")
50 		, m_screen(*this, "screen")
51 		, m_palette(*this, "palette")
52 		, m_z80bank(*this, "z80bank")
53 	{ }
54 
55 	void airsys(machine_config &config);
56 
57 private:
58 	/* memory pointers */
59 	required_shared_ptr<u16> m_m68000_mainram;
60 	required_shared_ptr<u16> m_line_ram;
61 	required_shared_ptr<u16> m_dsp_ram;          // Shared 68000/TMS32025 RAM
62 	required_shared_ptr<u16> m_paletteram;
63 	required_shared_ptr<u16> m_gradram;
64 	required_shared_ptr<u16> m_tc0430grw;
65 
66 	/* video-related */
67 	taitoair_poly  m_q;
68 
69 	/* misc */
70 	int           m_dsp_hold_signal;
71 
72 	/* devices */
73 	required_device<cpu_device> m_maincpu;
74 	required_device<cpu_device> m_audiocpu;
75 	required_device<tms32025_device> m_dsp;
76 	required_device<tc0080vco_device> m_tc0080vco;
77 	required_device<tc0220ioc_device> m_tc0220ioc;
78 	required_device<taitoio_yoke_device> m_yoke;
79 	required_device<screen_device> m_screen;
80 	required_device<palette_device> m_palette;
81 
82 	required_memory_bank m_z80bank;
83 
84 	std::unique_ptr<bitmap_ind16> m_framebuffer[2];
85 
86 	/* 3d info */
87 	s16 m_frustumLeft;
88 	s16 m_frustumBottom;
89 	s16 m_eyecoordBuffer[4];  /* homogeneous */
90 
91 	bool m_gradbank;
92 
93 	u16 m_dsp_test_object_type;
94 	s16 m_dsp_test_or_clip, m_dsp_test_and_clip;
95 	s16 m_dsp_test_x, m_dsp_test_y, m_dsp_test_z;
96 
97 	void dsp_test_start_w(u16 data);
98 	void dsp_test_x_w(u16 data);
99 	void dsp_test_y_w(u16 data);
100 	void dsp_test_z_w(u16 data);
101 	u16 dsp_test_point_r();
102 	u16 dsp_test_or_clip_r();
103 	u16 dsp_test_and_clip_r();
104 
105 	s16 m_dsp_muldiv_a_1, m_dsp_muldiv_b_1, m_dsp_muldiv_c_1;
106 
107 	void dsp_muldiv_a_1_w(u16 data);
108 	void dsp_muldiv_b_1_w(u16 data);
109 	void dsp_muldiv_c_1_w(u16 data);
110 	u16 dsp_muldiv_1_r();
111 
112 	s16 m_dsp_muldiv_a_2, m_dsp_muldiv_b_2, m_dsp_muldiv_c_2;
113 
114 	void dsp_muldiv_a_2_w(u16 data);
115 	void dsp_muldiv_b_2_w(u16 data);
116 	void dsp_muldiv_c_2_w(u16 data);
117 	u16 dsp_muldiv_2_r();
118 
119 	//bitmap_ind16 *m_buffer3d;
120 	void system_control_w(offs_t offset, u16 data, u16 mem_mask = ~0);
121 	u16 lineram_r(offs_t offset);
122 	void lineram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
123 	u16 dspram_r(offs_t offset);
124 	void dspram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
125 	u16 dsp_HOLD_signal_r();
126 	void dsp_HOLDA_signal_w(offs_t offset, u16 data);
127 	void paletteram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
128 	void gradram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
129 	u16 stick_input_r(offs_t offset);
130 	u16 stick2_input_r(offs_t offset);
131 	void coin_control_w(u8 data);
132 	void sound_bankswitch_w(u8 data);
133 	void dsp_flags_w(offs_t offset, u16 data);
134 	void dma_regs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
135 
136 	virtual void machine_start() override;
137 	virtual void machine_reset() override;
138 	virtual void video_start() override;
139 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
140 	int draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
141 	int draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int start_offset);
142 	void fb_copy_op(void);
143 	void fb_fill_op(void);
144 	void fb_erase_op(void);
145 
146 	void fill_slope(bitmap_ind16 &bitmap, const rectangle &cliprect, u16 header, s32 x1, s32 x2, s32 sl1, s32 sl2, s32 y1, s32 y2, s32 *nx1, s32 *nx2);
147 	void fill_poly(bitmap_ind16 &bitmap, const rectangle &cliprect, const struct taitoair_poly *q);
148 
149 	void DSP_map_data(address_map &map);
150 	void DSP_map_program(address_map &map);
151 	void airsys_map(address_map &map);
152 	void sound_map(address_map &map);
153 };
154 
155 #endif // MAME_INCLUDES_TAITOAIR_H
156