summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/micro3d.h
blob: 7e0a4d704d2a71d673f226eb8cdec2f4812715a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*************************************************************************

     Microprose Games 3D hardware

*************************************************************************/

#include "devlegcy.h"
#include "cpu/tms34010/tms34010.h"


#define HOST_MONITOR_DISPLAY        0
#define VGB_MONITOR_DISPLAY         0
#define DRMATH_MONITOR_DISPLAY      0

class micro3d_state : public driver_device
{
public:
	micro3d_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag),
		m_shared_ram(*this, "shared_ram"),
		m_mac_sram(*this, "mac_sram"),
		m_micro3d_sprite_vram(*this, "sprite_vram")
	{ }

	required_shared_ptr<UINT16> m_shared_ram;
	device_t            *m_duart68681;
	UINT8               m_m68681_tx0;

	/* Sound */
	UINT8               m_sound_port_latch[4];
	UINT8               m_dac_data;

	/* TI UART */
	UINT8               m_ti_uart[9];
	int                 m_ti_uart_mode_cycle;
	int                 m_ti_uart_sync_cycle;

	/* ADC */
	UINT8               m_adc_val;

	/* Hardware version-check latch for BOTSS 1.1a */
	UINT8               m_botss_latch;

	/* MAC */
	required_shared_ptr<UINT32> m_mac_sram;
	UINT32              m_sram_r_addr;
	UINT32              m_sram_w_addr;
	UINT32              m_vtx_addr;
	UINT32              m_mrab11;
	UINT32              m_mac_stat;
	UINT32              m_mac_inst;

	/* 2D video */
	required_shared_ptr<UINT16> m_micro3d_sprite_vram;
	UINT16              m_creg;
	UINT16              m_xfer3dk;

	/* 3D pipeline */
	UINT32              m_pipe_data;
	UINT32              m_pipeline_state;
	INT32               m_vtx_fifo[512];
	UINT32              m_fifo_idx;
	UINT32              m_draw_cmd;
	int                 m_draw_state;
	INT32               m_x_min;
	INT32               m_x_max;
	INT32               m_y_min;
	INT32               m_y_max;
	INT32               m_z_min;
	INT32               m_z_max;
	INT32               m_x_mid;
	INT32               m_y_mid;
	int                 m_dpram_bank;
	UINT32              m_draw_dpram[1024];
	UINT16              *m_frame_buffers[2];
	UINT16              *m_tmp_buffer;
	int                 m_drawing_buffer;
	int                 m_display_buffer;

	DECLARE_WRITE16_MEMBER(micro3d_ti_uart_w);
	DECLARE_READ16_MEMBER(micro3d_ti_uart_r);
	DECLARE_WRITE32_MEMBER(micro3d_scc_w);
	DECLARE_READ32_MEMBER(micro3d_scc_r);
	DECLARE_READ16_MEMBER(micro3d_tms_host_r);
	DECLARE_WRITE16_MEMBER(micro3d_tms_host_w);
	DECLARE_WRITE32_MEMBER(micro3d_mac1_w);
	DECLARE_READ32_MEMBER(micro3d_mac2_r);
	DECLARE_WRITE32_MEMBER(micro3d_mac2_w);
	DECLARE_READ16_MEMBER(micro3d_encoder_h_r);
	DECLARE_READ16_MEMBER(micro3d_encoder_l_r);
	DECLARE_READ16_MEMBER(micro3d_adc_r);
	DECLARE_WRITE16_MEMBER(micro3d_adc_w);
	DECLARE_READ16_MEMBER(botss_140000_r);
	DECLARE_READ16_MEMBER(botss_180000_r);
	DECLARE_WRITE16_MEMBER(micro3d_reset_w);
	DECLARE_WRITE16_MEMBER(host_drmath_int_w);
	DECLARE_WRITE32_MEMBER(micro3d_shared_w);
	DECLARE_READ32_MEMBER(micro3d_shared_r);
	DECLARE_WRITE32_MEMBER(drmath_int_w);
	DECLARE_WRITE32_MEMBER(drmath_intr2_ack);
	DECLARE_WRITE16_MEMBER(micro3d_clut_w);
	DECLARE_WRITE16_MEMBER(micro3d_creg_w);
	DECLARE_WRITE16_MEMBER(micro3d_xfer3dk_w);
	DECLARE_WRITE32_MEMBER(micro3d_fifo_w);
	DECLARE_WRITE32_MEMBER(micro3d_alt_fifo_w);
	DECLARE_READ32_MEMBER(micro3d_pipe_r);
	DECLARE_CUSTOM_INPUT_MEMBER(botss_hwchk_r);
	DECLARE_WRITE8_MEMBER(micro3d_snd_dac_a);
	DECLARE_WRITE8_MEMBER(micro3d_snd_dac_b);
	DECLARE_WRITE8_MEMBER(micro3d_sound_io_w);
	DECLARE_READ8_MEMBER(micro3d_sound_io_r);
	DECLARE_DRIVER_INIT(micro3d);
	DECLARE_DRIVER_INIT(botss);
	virtual void machine_reset();
	virtual void video_start();
	virtual void video_reset();
	INTERRUPT_GEN_MEMBER(micro3d_vblank);
	TIMER_CALLBACK_MEMBER(mac_done_callback);
	TIMER_CALLBACK_MEMBER(adc_done_callback);
	DECLARE_WRITE8_MEMBER(micro3d_upd7759_w);
	DECLARE_WRITE8_MEMBER(data_from_i8031);
	DECLARE_READ8_MEMBER(data_to_i8031);
};

struct micro3d_vtx
{
	INT32 x, y, z;
};


/*----------- defined in machine/micro3d.c -----------*/

void micro3d_duart_irq_handler(device_t *device, int state, UINT8 vector);
UINT8 micro3d_duart_input_r(device_t *device);
void micro3d_duart_output_w(device_t *device, UINT8 data);
void micro3d_duart_tx(device_t *device, int channel, UINT8 data);

/*----------- defined in audio/micro3d.c -----------*/

void micro3d_noise_sh_w(running_machine &machine, UINT8 data);

class micro3d_sound_device : public device_t,
									public device_sound_interface
{
public:
	micro3d_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	~micro3d_sound_device() { global_free(m_token); }

	// access to legacy token
	void *token() const { assert(m_token != NULL); return m_token; }
protected:
	// device-level overrides
	virtual void device_config_complete();
	virtual void device_start();
	virtual void device_reset();

	// sound stream update overrides
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
private:
	// internal state
	void *m_token;
};

extern const device_type MICRO3D;

/*----------- defined in video/micro3d.c -----------*/
void micro3d_tms_interrupt(device_t *device, int state);
void micro3d_scanline_update(screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms34010_display_params *params);