30
30
/*************************************
34
*************************************/
36
static int color_mode;
37
static rgb_t vector_color;
38
static INT16 lastx, lasty;
39
static UINT8 last_control;
43
/*************************************
47
34
*************************************/
49
36
void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift)
51
const rectangle &visarea = device->machine->primary_screen->visible_area();
38
cinemat_state *state = device->machine().driver_data<cinemat_state>();
39
const rectangle &visarea = device->machine().primary_screen->visible_area();
52
40
int intensity = 0xff;
54
42
/* adjust for slop */
62
50
intensity = 0x1ff * shift / 8;
64
52
/* move to the starting position if we're not there already */
65
if (sx != lastx || sy != lasty)
66
vector_add_point(device->machine, sx << 16, sy << 16, 0, 0);
53
if (sx != state->m_lastx || sy != state->m_lasty)
54
vector_add_point(device->machine(), sx << 16, sy << 16, 0, 0);
68
56
/* draw the vector */
69
vector_add_point(device->machine, ex << 16, ey << 16, vector_color, intensity);
57
vector_add_point(device->machine(), ex << 16, ey << 16, state->m_vector_color, intensity);
71
59
/* remember the last point */
84
72
WRITE8_HANDLER(cinemat_vector_control_w)
74
cinemat_state *state = space->machine().driver_data<cinemat_state>();
87
cpu_device *cpu = space->machine->device<cpu_device>("maincpu");
76
cpu_device *cpu = space->machine().device<cpu_device>("maincpu");
78
switch (state->m_color_mode)
91
80
case COLOR_BILEVEL:
92
81
/* color is either bright or dim, selected by the value sent to the port */
93
vector_color = (data & 1) ? MAKE_RGB(0x80,0x80,0x80) : MAKE_RGB(0xff,0xff,0xff);
82
state->m_vector_color = (data & 1) ? MAKE_RGB(0x80,0x80,0x80) : MAKE_RGB(0xff,0xff,0xff);
96
85
case COLOR_16LEVEL:
97
86
/* on the rising edge of the data value, latch bits 0-3 of the */
98
87
/* X register as the intensity */
99
if (data != last_control && data)
88
if (data != state->m_last_control && data)
101
90
int xval = cpu->state(CCPU_X) & 0x0f;
102
91
i = (xval + 1) * 255 / 16;
103
vector_color = MAKE_RGB(i,i,i);
92
state->m_vector_color = MAKE_RGB(i,i,i);
107
96
case COLOR_64LEVEL:
108
97
/* on the rising edge of the data value, latch bits 2-7 of the */
109
98
/* X register as the intensity */
110
if (data != last_control && data)
99
if (data != state->m_last_control && data)
112
101
int xval = cpu->state(CCPU_X);
113
102
xval = (~xval >> 2) & 0x3f;
114
103
i = (xval + 1) * 255 / 64;
115
vector_color = MAKE_RGB(i,i,i);
104
state->m_vector_color = MAKE_RGB(i,i,i);
120
109
/* on the rising edge of the data value, latch the X register */
121
110
/* as 4-4-4 BGR values */
122
if (data != last_control && data)
111
if (data != state->m_last_control && data)
124
113
int xval = cpu->state(CCPU_X);
125
114
r = (~xval >> 0) & 0x0f;
128
117
g = g * 255 / 15;
129
118
b = (~xval >> 8) & 0x0f;
130
119
b = b * 255 / 15;
131
vector_color = MAKE_RGB(r,g,b);
120
state->m_vector_color = MAKE_RGB(r,g,b);
137
static int lastx, lasty;
139
126
/* on the falling edge of the data value, remember the original X,Y values */
140
127
/* they will be restored on the rising edge; this is to simulate the fact */
141
128
/* that the Rockola color hardware did not overwrite the beam X,Y position */
142
129
/* on an IV instruction if data == 0 here */
143
if (data != last_control && !data)
130
if (data != state->m_last_control && !data)
145
lastx = cpu->state(CCPU_X);
146
lasty = cpu->state(CCPU_Y);
132
state->m_qb3_lastx = cpu->state(CCPU_X);
133
state->m_qb3_lasty = cpu->state(CCPU_Y);
149
136
/* on the rising edge of the data value, latch the Y register */
150
137
/* as 2-3-3 BGR values */
151
if (data != last_control && data)
138
if (data != state->m_last_control && data)
153
140
int yval = cpu->state(CCPU_Y);
154
141
r = (~yval >> 0) & 0x07;
158
145
b = (~yval >> 6) & 0x03;
160
vector_color = MAKE_RGB(r,g,b);
147
state->m_vector_color = MAKE_RGB(r,g,b);
162
149
/* restore the original X,Y values */
163
cpu->set_state(CCPU_X, lastx);
164
cpu->set_state(CCPU_Y, lasty);
150
cpu->set_state(CCPU_X, state->m_qb3_lastx);
151
cpu->set_state(CCPU_Y, state->m_qb3_lasty);
170
157
/* remember the last value */
158
state->m_last_control = data;
182
169
VIDEO_START( cinemat_bilevel )
184
color_mode = COLOR_BILEVEL;
171
cinemat_state *state = machine.driver_data<cinemat_state>();
172
state->m_color_mode = COLOR_BILEVEL;
185
173
VIDEO_START_CALL(vector);
189
177
VIDEO_START( cinemat_16level )
191
color_mode = COLOR_16LEVEL;
179
cinemat_state *state = machine.driver_data<cinemat_state>();
180
state->m_color_mode = COLOR_16LEVEL;
192
181
VIDEO_START_CALL(vector);
196
185
VIDEO_START( cinemat_64level )
198
color_mode = COLOR_64LEVEL;
187
cinemat_state *state = machine.driver_data<cinemat_state>();
188
state->m_color_mode = COLOR_64LEVEL;
199
189
VIDEO_START_CALL(vector);
203
193
VIDEO_START( cinemat_color )
205
color_mode = COLOR_RGB;
195
cinemat_state *state = machine.driver_data<cinemat_state>();
196
state->m_color_mode = COLOR_RGB;
206
197
VIDEO_START_CALL(vector);
210
201
VIDEO_START( cinemat_qb3color )
212
color_mode = COLOR_QB3;
203
cinemat_state *state = machine.driver_data<cinemat_state>();
204
state->m_color_mode = COLOR_QB3;
213
205
VIDEO_START_CALL(vector);
222
214
*************************************/
224
VIDEO_UPDATE( cinemat )
216
SCREEN_UPDATE( cinemat )
226
VIDEO_UPDATE_CALL(vector);
218
SCREEN_UPDATE_CALL(vector);
227
219
vector_clear_list();
229
ccpu_wdt_timer_trigger(screen->machine->device("maincpu"));
221
ccpu_wdt_timer_trigger(screen->machine().device("maincpu"));
240
232
*************************************/
242
VIDEO_UPDATE( spacewar )
234
SCREEN_UPDATE( spacewar )
244
int sw_option = input_port_read(screen->machine, "INPUTS");
236
int sw_option = input_port_read(screen->machine(), "INPUTS");
246
VIDEO_UPDATE_CALL(cinemat);
238
SCREEN_UPDATE_CALL(cinemat);
248
240
/* set the state of the artwork */
249
241
output_set_value("pressed3", (~sw_option >> 0) & 1);