src/mess/video/vectrex.c
| r2386 | r2387 | |
| 8 | 8 | #include "sound/dac.h" |
| 9 | 9 | |
| 10 | 10 | |
| 11 | | #define RAMP_DELAY 6.333e-6 |
| 12 | | #define SH_DELAY RAMP_DELAY |
| 11 | #define ANALOG_DELAY 7800 |
| 12 | #define NVECT 10000 |
| 13 | 13 | |
| 14 | | #define VEC_SHIFT 16 |
| 15 | | #define INT_PER_CLOCK 600 |
| 16 | | #define VECTREX_CLOCK 1500000 |
| 14 | #define INT_PER_CLOCK 550 |
| 17 | 15 | |
| 18 | | #define PORTB 0 |
| 19 | | #define PORTA 1 |
| 20 | | |
| 21 | 16 | #ifndef M_SQRT1_2 |
| 22 | 17 | #define M_SQRT1_2 0.70710678118654752440 |
| 23 | 18 | #endif |
| 24 | 19 | |
| 25 | 20 | /********************************************************************* |
| 26 | | Local variables |
| 27 | | *********************************************************************/ |
| 21 | |
| 22 | Enums and typedefs |
| 23 | |
| 24 | *********************************************************************/ |
| 25 | |
| 26 | enum { |
| 27 | PORTB = 0, |
| 28 | PORTA |
| 29 | }; |
| 30 | |
| 31 | enum { |
| 32 | A_X = 0, |
| 33 | A_ZR, |
| 34 | A_Z, |
| 35 | A_AUDIO, |
| 36 | A_Y, |
| 37 | }; |
| 38 | |
| 39 | typedef struct _vectrex_point |
| 40 | { |
| 41 | int x; int y; |
| 42 | rgb_t col; |
| 43 | int intensity; |
| 44 | } vectrex_point; |
| 45 | |
| 46 | |
| 47 | /********************************************************************* |
| 48 | |
| 49 | Prototypes |
| 50 | |
| 51 | *********************************************************************/ |
| 52 | |
| 28 | 53 | static WRITE8_HANDLER ( v_via_pa_w ); |
| 29 | 54 | static WRITE8_HANDLER( v_via_pb_w ); |
| 30 | 55 | static WRITE8_HANDLER ( v_via_ca2_w ); |
| 31 | 56 | static WRITE8_HANDLER ( v_via_cb2_w ); |
| 32 | 57 | |
| 58 | |
| 59 | /********************************************************************* |
| 60 | |
| 61 | Local variables |
| 62 | |
| 63 | *********************************************************************/ |
| 64 | |
| 33 | 65 | static const struct via6522_interface vectrex_via6522_interface = |
| 34 | 66 | { |
| 35 | 67 | v_via_pa_r, v_via_pb_r, /* read PA/B */ |
| r2386 | r2387 | |
| 40 | 72 | }; |
| 41 | 73 | |
| 42 | 74 | static int x_center, y_center, x_max, y_max; |
| 43 | | static int x_int, y_int; /* X, Y integrators IC LF347*/ |
| 44 | | static int lightpen_down=0, pen_x, pen_y; /* Lightpen position */ |
| 75 | static int x_int, y_int; /* X, Y integrators */ |
| 76 | static int lightpen_down, pen_x, pen_y; /* Lightpen position */ |
| 45 | 77 | static emu_timer *lp_t; |
| 46 | | static int blank; |
| 78 | static emu_timer *refresh; |
| 79 | static UINT8 blank; |
| 80 | static UINT8 ramp; |
| 81 | static INT8 analog[5]; |
| 82 | static int vectrex_point_index; |
| 83 | static int display_start, display_end; |
| 84 | static vectrex_point vectrex_points[NVECT]; |
| 47 | 85 | |
| 48 | | /* Analog signals: 0 : X-axis sample and hold IC LF347 |
| 49 | | * coupled by the MUX CD4052 |
| 50 | | * 1 : Y-axis sample and hold IC LF347 |
| 51 | | * 2 : "0" reference charge capacitor |
| 52 | | * 3 : Z-axis (brightness signal) sample and hold IC LF347 |
| 53 | | * 4 : MPU sound resistive netowrk |
| 54 | | */ |
| 86 | void (*vector_add_point_function) (int, int, rgb_t, int) = vectrex_add_point; |
| 55 | 87 | |
| 56 | | #define ASIG_Y 0 |
| 57 | | #define ASIG_X 1 |
| 58 | | #define ASIG_ZR 2 |
| 59 | | #define ASIG_Z 3 |
| 60 | | #define ASIG_MPU 4 |
| 61 | 88 | |
| 62 | | #define NVECT 10000 |
| 89 | /********************************************************************* |
| 63 | 90 | |
| 64 | | static int analog_sig[5]; |
| 91 | Lightpen |
| 65 | 92 | |
| 66 | | static double start_time; |
| 67 | | static int last_point_x, last_point_y, last_point_z, last_point=0; |
| 68 | | static double last_point_starttime; |
| 69 | | static float z_factor; |
| 70 | | static int vectrex_point_index = 0; |
| 71 | | static double vectrex_persistance = 0.05; |
| 93 | *********************************************************************/ |
| 72 | 94 | |
| 73 | | struct vectrex_point |
| 95 | static TIMER_CALLBACK(lightpen_trigger) |
| 74 | 96 | { |
| 75 | | int x; int y; |
| 76 | | rgb_t col; |
| 77 | | int intensity; |
| 78 | | double time; |
| 79 | | }; |
| 80 | | |
| 81 | | static struct vectrex_point vectrex_points[NVECT]; |
| 82 | | void (*vector_add_point_function) (int, int, rgb_t, int) = vectrex_add_point; |
| 83 | | |
| 84 | | void vectrex_add_point (int x, int y, rgb_t color, int intensity) |
| 85 | | { |
| 86 | | struct vectrex_point *newpoint; |
| 87 | | |
| 88 | | vectrex_point_index = (vectrex_point_index+1) % NVECT; |
| 89 | | newpoint = &vectrex_points[vectrex_point_index]; |
| 90 | | |
| 91 | | newpoint->x = x; |
| 92 | | newpoint->y = y; |
| 93 | | newpoint->col = color; |
| 94 | | newpoint->intensity = intensity; |
| 95 | | newpoint->time = attotime_to_double(timer_get_time()); |
| 96 | | } |
| 97 | | |
| 98 | | /********************************************************************* |
| 99 | | Lightpen |
| 100 | | *********************************************************************/ |
| 101 | | static void lightpen_trigger(running_machine *machine) |
| 102 | | { |
| 103 | 97 | if (vectrex_lightpen_port & 1) |
| 104 | 98 | { |
| 105 | | via_0_ca1_w(machine, 0, 1); |
| 106 | | via_0_ca1_w(machine, 0, 0); |
| 99 | via_set_input_ca1(0, 1); |
| 100 | via_set_input_ca1(0, 0); |
| 107 | 101 | } |
| 102 | |
| 108 | 103 | if (vectrex_lightpen_port & 2) |
| 109 | 104 | { |
| 110 | 105 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, PULSE_LINE); |
| 111 | 106 | } |
| 112 | 107 | } |
| 113 | 108 | |
| 114 | | static TIMER_CALLBACK(lightpen_trigger_callback) |
| 115 | | { |
| 116 | | lightpen_trigger(machine); |
| 117 | | } |
| 118 | | |
| 119 | 109 | static int lightpen_check (void) |
| 120 | 110 | { |
| 121 | | int dx,dy; |
| 122 | | if (lightpen_down) |
| 111 | int dx, dy; |
| 112 | if (vectrex_lightpen_port != 0) |
| 123 | 113 | { |
| 124 | | dx=abs(pen_x-x_int); |
| 125 | | dy=abs(pen_y-y_int); |
| 126 | | if (dx<500000 && dy<500000) |
| 127 | | return 1; |
| 114 | lightpen_down = readinputportbytag("LPENCONF") & 0x10; |
| 115 | |
| 116 | if (lightpen_down) |
| 117 | { |
| 118 | pen_x = readinputportbytag("LPENX") * (x_max / 0xff); |
| 119 | pen_y = readinputportbytag("LPENY") * (y_max / 0xff); |
| 120 | |
| 121 | dx = abs(pen_x - x_int); |
| 122 | dy = abs(pen_y - y_int); |
| 123 | if (dx < 500000 && dy < 500000) |
| 124 | return 1; |
| 125 | } |
| 128 | 126 | } |
| 127 | else |
| 128 | lightpen_down = 0; |
| 129 | |
| 129 | 130 | return 0; |
| 130 | 131 | } |
| 131 | 132 | |
| 132 | | static void lightpen_show (running_machine *machine) |
| 133 | | { |
| 134 | | int color; |
| 133 | /********************************************************************* |
| 135 | 134 | |
| 136 | | if (vectrex_lightpen_port != 0) |
| 135 | VIA T2 configuration |
| 136 | |
| 137 | We need to snoop the frequency of VIA timer 2 here since most |
| 138 | vectrex games use that timer for steady screen refresh. Even if the |
| 139 | game stops T2 we continue refreshing the screen with the last known |
| 140 | frequency. Note that we quickly get out of sync in this case and the |
| 141 | screen will start flickering (see cut scenes in Spike). |
| 142 | |
| 143 | Note that the timer can be adjusted to the full period each time T2 |
| 144 | is restarted. This behaviour avoids flicker in most games. Some |
| 145 | games like mine 3d don't work well with this scheme though and show |
| 146 | severe jerking. So the second option is to leave the current period |
| 147 | alone (if the new period isn't shorter) and change only the next |
| 148 | full period. |
| 149 | |
| 150 | *********************************************************************/ |
| 151 | |
| 152 | WRITE8_HANDLER(vectrex_via_w) |
| 153 | { |
| 154 | static UINT16 counter; |
| 155 | attotime period; |
| 156 | |
| 157 | switch (offset) |
| 137 | 158 | { |
| 138 | | if (input_port_read_indexed(machine, 6)&0x10) |
| 139 | | { |
| 140 | | lightpen_down=1; |
| 141 | | color=0x00ff0000; |
| 142 | | } |
| 143 | | else |
| 144 | | { |
| 145 | | lightpen_down=0; |
| 146 | | color=0x00ffffff; |
| 147 | | } |
| 159 | case 8: |
| 160 | counter = (counter & 0xff00) | data; |
| 161 | break; |
| 148 | 162 | |
| 149 | | pen_x = input_port_read_indexed(machine, 8)*(x_max/0xff); |
| 150 | | pen_y = input_port_read_indexed(machine, 7)*(y_max/0xff); |
| 163 | case 9: |
| 164 | counter = (counter & 0x00ff) | (data << 8); |
| 151 | 165 | |
| 152 | | vector_add_point(pen_x-250000,pen_y-250000,0,0xff); |
| 153 | | vector_add_point(pen_x+250000,pen_y+250000,color,0xff); |
| 154 | | vector_add_point(pen_x+250000,pen_y-250000,0,0xff); |
| 155 | | vector_add_point(pen_x-250000,pen_y+250000,color,0xff); |
| 166 | period = attotime_mul(ATTOTIME_IN_HZ(cpunum_get_clock(0)), counter); |
| 167 | |
| 168 | if (vectrex_reset_refresh) |
| 169 | timer_adjust_periodic(refresh, period, 0, period); |
| 170 | else |
| 171 | timer_adjust_periodic(refresh, |
| 172 | attotime_min(period, timer_timeleft(refresh)), |
| 173 | 0, |
| 174 | period); |
| 175 | break; |
| 156 | 176 | } |
| 157 | | else |
| 158 | | lightpen_down=0; |
| 177 | via_write(0, offset, data); |
| 159 | 178 | } |
| 160 | 179 | |
| 180 | |
| 161 | 181 | /********************************************************************* |
| 162 | | Screen updating |
| 163 | | *********************************************************************/ |
| 182 | |
| 183 | Screen refresh |
| 184 | |
| 185 | *********************************************************************/ |
| 186 | |
| 187 | static TIMER_CALLBACK ( vectrex_refresh ) |
| 188 | { |
| 189 | /* Refresh only marks the range of vectors which will be drawn |
| 190 | * during the next VIDEO_UPDATE. */ |
| 191 | display_start = display_end; |
| 192 | display_end = vectrex_point_index; |
| 193 | } |
| 194 | |
| 164 | 195 | VIDEO_UPDATE( vectrex ) |
| 165 | 196 | { |
| 166 | | int i, v; |
| 167 | | double starttime; |
| 197 | int i; |
| 168 | 198 | |
| 169 | 199 | vectrex_configuration(); |
| 170 | | lightpen_show(screen->machine); |
| 171 | 200 | |
| 172 | | starttime = attotime_to_double(timer_get_time()) - vectrex_persistance; |
| 173 | | if (starttime < 0) starttime = 0; |
| 174 | | i = vectrex_point_index; |
| 175 | | |
| 176 | | /* Find the oldest vector we want to display */ |
| 177 | | for (v=0; ((vectrex_points[i].time > starttime) && (v < NVECT)); v++) |
| 178 | | { |
| 179 | | i--; |
| 180 | | if (i<0) i = NVECT - 1; |
| 181 | | } |
| 182 | | |
| 183 | 201 | /* start black */ |
| 184 | | vector_add_point(vectrex_points[i].x, vectrex_points[i].y, vectrex_points[i].col, 0); |
| 202 | vector_add_point(vectrex_points[display_start].x, |
| 203 | vectrex_points[display_start].y, |
| 204 | vectrex_points[display_start].col, |
| 205 | 0); |
| 185 | 206 | |
| 186 | | while (i != vectrex_point_index) |
| 207 | for (i = display_start; i != display_end; i = (i + 1) % NVECT) |
| 187 | 208 | { |
| 188 | | vector_add_point(vectrex_points[i].x,vectrex_points[i].y,vectrex_points[i].col, vectrex_points[i].intensity); |
| 189 | | i = (i+1) % NVECT; |
| 209 | vector_add_point(vectrex_points[i].x, |
| 210 | vectrex_points[i].y, |
| 211 | vectrex_points[i].col, |
| 212 | vectrex_points[i].intensity); |
| 190 | 213 | } |
| 191 | 214 | |
| 192 | 215 | VIDEO_UPDATE_CALL(vector); |
| r2386 | r2387 | |
| 194 | 217 | return 0; |
| 195 | 218 | } |
| 196 | 219 | |
| 220 | |
| 197 | 221 | /********************************************************************* |
| 198 | | Vector functions |
| 199 | | *********************************************************************/ |
| 222 | |
| 223 | Vector functions |
| 224 | |
| 225 | *********************************************************************/ |
| 226 | |
| 227 | void vectrex_add_point (int x, int y, rgb_t color, int intensity) |
| 228 | { |
| 229 | vectrex_point *newpoint; |
| 230 | |
| 231 | vectrex_point_index = (vectrex_point_index+1) % NVECT; |
| 232 | newpoint = &vectrex_points[vectrex_point_index]; |
| 233 | |
| 234 | newpoint->x = x; |
| 235 | newpoint->y = y; |
| 236 | newpoint->col = color; |
| 237 | newpoint->intensity = intensity; |
| 238 | } |
| 239 | |
| 200 | 240 | void vectrex_add_point_stereo (int x, int y, rgb_t color, int intensity) |
| 201 | 241 | { |
| 202 | 242 | if (vectrex_imager_status == 2) /* left = 1, right = 2 */ |
| 203 | | vectrex_add_point ((int)(y*M_SQRT1_2), (int)(((x_max-x)*M_SQRT1_2)+y_center), color, intensity); |
| 243 | vectrex_add_point ((int)(y * M_SQRT1_2)+ x_center, |
| 244 | (int)(((x_max - x) * M_SQRT1_2)), |
| 245 | color, |
| 246 | intensity); |
| 204 | 247 | else |
| 205 | | vectrex_add_point ((int)(y*M_SQRT1_2), (int)((x_max-x)*M_SQRT1_2), color, intensity); |
| 248 | vectrex_add_point ((int)(y * M_SQRT1_2), |
| 249 | (int)((x_max - x) * M_SQRT1_2), |
| 250 | color, |
| 251 | intensity); |
| 206 | 252 | } |
| 207 | 253 | |
| 208 | | INLINE void vectrex_zero_integrators(void) |
| 254 | static TIMER_CALLBACK (vectrex_zero_integrators) |
| 209 | 255 | { |
| 210 | | if (last_point) |
| 211 | | vector_add_point_function (last_point_x, last_point_y, vectrex_beam_color, |
| 212 | | MIN((int)(last_point_z*((attotime_to_double(timer_get_time())-last_point_starttime)*3E4)),255)); |
| 213 | | last_point = 0; |
| 214 | | |
| 215 | | x_int=x_center+(analog_sig[ASIG_ZR]*INT_PER_CLOCK); |
| 216 | | y_int=y_center+(analog_sig[ASIG_ZR]*INT_PER_CLOCK); |
| 256 | x_int = x_center + (analog[A_ZR] * INT_PER_CLOCK); |
| 257 | y_int = y_center + (analog[A_ZR] * INT_PER_CLOCK); |
| 217 | 258 | vector_add_point_function (x_int, y_int, vectrex_beam_color, 0); |
| 218 | 259 | } |
| 219 | 260 | |
| 220 | | INLINE void vectrex_dot(void) |
| 261 | static void update_vectors (void) |
| 221 | 262 | { |
| 222 | | if (!last_point) |
| 263 | static attotime start_time; |
| 264 | int length; |
| 265 | |
| 266 | if (!ramp) |
| 223 | 267 | { |
| 224 | | last_point_x = x_int; |
| 225 | | last_point_y = y_int; |
| 226 | | last_point_z = analog_sig[ASIG_Z] > 0? (int)(analog_sig[ASIG_Z] * z_factor): 0; |
| 227 | | last_point_starttime = attotime_to_double(timer_get_time()); |
| 228 | | last_point = 1; |
| 268 | length = cpunum_get_clock(0) * INT_PER_CLOCK |
| 269 | * attotime_to_double(attotime_sub(timer_get_time(), start_time)); |
| 270 | |
| 271 | x_int += length * (analog[A_X] + analog[A_ZR]); |
| 272 | y_int += length * (analog[A_Y] + analog[A_ZR]); |
| 273 | |
| 274 | vector_add_point_function(x_int, y_int, vectrex_beam_color, 2 * analog[A_Z] * blank); |
| 229 | 275 | } |
| 276 | else |
| 277 | { |
| 278 | if (blank) |
| 279 | vector_add_point_function(x_int, y_int, vectrex_beam_color, 2 * analog[A_Z]); |
| 280 | } |
| 281 | |
| 282 | start_time = timer_get_time(); |
| 230 | 283 | } |
| 231 | 284 | |
| 232 | | INLINE void vectrex_solid_line(double int_time, int blank) |
| 285 | |
| 286 | /********************************************************************* |
| 287 | |
| 288 | Delayed signals |
| 289 | |
| 290 | The RAMP signal is delayed wrt. beam blanking. Getting this right |
| 291 | is important for text placement, the maze in Clean Sweep and many |
| 292 | other games. |
| 293 | |
| 294 | *********************************************************************/ |
| 295 | |
| 296 | static TIMER_CALLBACK(update_signal) |
| 233 | 297 | { |
| 234 | | int z = analog_sig[ASIG_Z] > 0? (int)(analog_sig[ASIG_Z]*z_factor): 0; |
| 235 | | int length = (int)(VECTREX_CLOCK * INT_PER_CLOCK * int_time); |
| 298 | update_vectors(); |
| 236 | 299 | |
| 237 | | /* The BIOS draws lines as follows: First put a pattern in the VIA SR (this causes a dot). Then |
| 238 | | * turn on RAMP and let the integrators do their job (this causes a line to be drawn). |
| 239 | | * Obviously this first dot isn't needed so we optimize it away :) but we have to take care |
| 240 | | * not to optimize _all_ dots, that's why we do draw the dot if the following line is |
| 241 | | * black (a move). */ |
| 242 | | if (last_point && (!blank || !z)) |
| 243 | | vector_add_point_function(last_point_x, last_point_y, vectrex_beam_color, |
| 244 | | MIN((int)(last_point_z*((attotime_to_double(timer_get_time())-last_point_starttime)*3E4)),255)); |
| 245 | | last_point = 0; |
| 246 | | |
| 247 | | x_int += (int)(length * (analog_sig[ASIG_X] - analog_sig[ASIG_ZR])); |
| 248 | | y_int += (int)(length * (analog_sig[ASIG_Y] + analog_sig[ASIG_ZR])); |
| 249 | | vector_add_point_function(x_int, y_int, vectrex_beam_color, z * blank); |
| 300 | if (ptr) |
| 301 | * (UINT8 *) ptr = param; |
| 250 | 302 | } |
| 251 | 303 | |
| 304 | |
| 252 | 305 | /********************************************************************* |
| 253 | | Startup and stop |
| 254 | | *********************************************************************/ |
| 306 | |
| 307 | Startup |
| 308 | |
| 309 | *********************************************************************/ |
| 310 | |
| 255 | 311 | VIDEO_START( vectrex ) |
| 256 | 312 | { |
| 257 | 313 | const device_config *screen = video_screen_first(machine->config); |
| 258 | 314 | const rectangle *visarea = video_screen_get_visible_area(screen); |
| 259 | 315 | |
| 260 | | x_center=((visarea->max_x |
| 261 | | -visarea->min_x) / 2) << VEC_SHIFT; |
| 262 | | y_center=((visarea->max_y |
| 263 | | -visarea->min_y) / 2) << VEC_SHIFT; |
| 264 | | x_max = visarea->max_x << VEC_SHIFT; |
| 265 | | y_max = visarea->max_y << VEC_SHIFT; |
| 316 | x_center=((visarea->max_x - visarea->min_x) / 2) << 16; |
| 317 | y_center=((visarea->max_y - visarea->min_y) / 2) << 16; |
| 318 | x_max = visarea->max_x << 16; |
| 319 | y_max = visarea->max_y << 16; |
| 266 | 320 | |
| 267 | 321 | via_config(0, &vectrex_via6522_interface); |
| 268 | 322 | via_reset(); |
| 269 | | z_factor = 2; |
| 270 | 323 | |
| 271 | 324 | imager_freq = 1; |
| 272 | 325 | |
| 273 | | imager_timer = timer_alloc(vectrex_imager_right_eye, NULL); |
| 274 | | timer_adjust_periodic(imager_timer, ATTOTIME_IN_HZ(imager_freq), 2, ATTOTIME_IN_HZ(imager_freq)); |
| 326 | imager_timer = timer_alloc(vectrex_imager_eye, NULL); |
| 327 | timer_adjust_periodic(imager_timer, |
| 328 | ATTOTIME_IN_HZ(imager_freq), |
| 329 | 2, |
| 330 | ATTOTIME_IN_HZ(imager_freq)); |
| 275 | 331 | |
| 276 | | lp_t = timer_alloc(lightpen_trigger_callback, NULL); |
| 332 | lp_t = timer_alloc(lightpen_trigger, NULL); |
| 277 | 333 | |
| 334 | /* Switch off crosshairs since most games don't use lightpen */ |
| 335 | crosshair_toggle(machine); |
| 336 | |
| 337 | refresh = timer_alloc(vectrex_refresh, NULL); |
| 338 | |
| 278 | 339 | VIDEO_START_CALL(vector); |
| 279 | 340 | } |
| 280 | 341 | |
| 281 | 342 | |
| 282 | 343 | /********************************************************************* |
| 283 | | VIA interface functions |
| 284 | | *********************************************************************/ |
| 285 | | INLINE void vectrex_multiplexer (int mux) |
| 344 | |
| 345 | VIA interface functions |
| 346 | |
| 347 | *********************************************************************/ |
| 348 | |
| 349 | static void vectrex_multiplexer (int mux) |
| 286 | 350 | { |
| 287 | | analog_sig[mux + 1]=(signed char)vectrex_via_out[PORTA]; |
| 288 | | if (mux == 3) |
| 289 | | DAC_data_w(0,(signed char)vectrex_via_out[PORTA]+0x80); |
| 351 | timer_set(ATTOTIME_IN_NSEC(ANALOG_DELAY), &analog[mux], vectrex_via_out[PORTA], update_signal); |
| 352 | |
| 353 | if (mux == A_AUDIO) |
| 354 | DAC_data_w(0, vectrex_via_out[PORTA]); |
| 290 | 355 | } |
| 291 | 356 | |
| 292 | 357 | static WRITE8_HANDLER ( v_via_pb_w ) |
| r2386 | r2387 | |
| 294 | 359 | if (!(data & 0x80)) |
| 295 | 360 | { |
| 296 | 361 | /* RAMP is active */ |
| 297 | | if ((vectrex_via_out[PORTB] & 0x80)) |
| 362 | if ((ramp & 0x80)) |
| 298 | 363 | { |
| 299 | 364 | /* RAMP was inactive before */ |
| 300 | | start_time = attotime_to_double(timer_get_time())+RAMP_DELAY; |
| 301 | 365 | |
| 302 | 366 | if (lightpen_down) |
| 303 | 367 | { |
| 304 | 368 | /* Simple lin. algebra to check if pen is near |
| 305 | | * the line defined by (ASIG_X,ASIG_Y). |
| 369 | * the line defined by (A_X,A_Y). |
| 306 | 370 | * If that is the case, set a timer which goes |
| 307 | 371 | * off when the beam reaches the pen. Exact |
| 308 | 372 | * timing is important here. |
| r2386 | r2387 | |
| 320 | 384 | * a |
| 321 | 385 | */ |
| 322 | 386 | double a2, b2, ab, d2; |
| 323 | | ab = (double)(pen_x-x_int)*analog_sig[ASIG_X] |
| 324 | | +(double)(pen_y-y_int)*analog_sig[ASIG_Y]; |
| 325 | | if (ab>0) |
| 387 | ab = (pen_x - x_int) * analog[A_X] |
| 388 | +(pen_y - y_int) * analog[A_Y]; |
| 389 | if (ab > 0) |
| 326 | 390 | { |
| 327 | | a2 = (analog_sig[ASIG_X]*analog_sig[ASIG_X] |
| 328 | | +analog_sig[ASIG_Y]*analog_sig[ASIG_Y]); |
| 329 | | b2 = (double)(pen_x-x_int)*(pen_x-x_int) |
| 330 | | +(double)(pen_y-y_int)*(pen_y-y_int); |
| 331 | | d2=b2-ab*ab/a2; |
| 332 | | if (d2<2e10 && analog_sig[ASIG_Z]*blank>0) |
| 333 | | timer_adjust_oneshot(lp_t, double_to_attotime(ab/a2/(VECTREX_CLOCK*INT_PER_CLOCK)), 0); |
| 391 | a2 = (double)(analog[A_X] * analog[A_X] |
| 392 | +(double)analog[A_Y] * analog[A_Y]); |
| 393 | b2 = (double)(pen_x - x_int) * (pen_x - x_int) |
| 394 | +(double)(pen_y - y_int) * (pen_y - y_int); |
| 395 | d2 = b2 - ab * ab / a2; |
| 396 | if (d2 < 2e10 && analog[A_Z] * blank > 0) |
| 397 | timer_adjust_oneshot(lp_t, double_to_attotime(ab / a2 / (cpunum_get_clock(0) * INT_PER_CLOCK)), 0); |
| 334 | 398 | } |
| 335 | 399 | } |
| 336 | 400 | } |
| 337 | 401 | |
| 338 | 402 | if (!(data & 0x1) && (vectrex_via_out[PORTB] & 0x1)) |
| 403 | { |
| 339 | 404 | /* MUX has been enabled */ |
| 340 | | /* This is a rare case used by some new games */ |
| 341 | | { |
| 342 | | double time_now = attotime_to_double(timer_get_time())+SH_DELAY; |
| 343 | | vectrex_solid_line(time_now-start_time, blank); |
| 344 | | start_time = time_now; |
| 405 | timer_set(ATTOTIME_IN_NSEC(ANALOG_DELAY), NULL, 0, update_signal); |
| 345 | 406 | } |
| 346 | 407 | } |
| 347 | 408 | else |
| 348 | 409 | { |
| 349 | 410 | /* RAMP is inactive */ |
| 350 | | if (!(vectrex_via_out[PORTB] & 0x80)) |
| 411 | if (!(ramp & 0x80)) |
| 351 | 412 | { |
| 352 | | /* RAMP was active before - we can draw the line */ |
| 353 | | vectrex_solid_line(attotime_to_double(timer_get_time())-start_time+RAMP_DELAY, blank); |
| 354 | 413 | /* Cancel running timer, line already finished */ |
| 355 | 414 | if (lightpen_down) |
| 356 | 415 | timer_adjust_oneshot(lp_t, attotime_never, 0); |
| r2386 | r2387 | |
| 360 | 419 | /* Sound */ |
| 361 | 420 | if (data & 0x10) |
| 362 | 421 | { |
| 363 | | /* BDIR active, PSG latches */ |
| 364 | 422 | if (data & 0x08) /* BC1 (do we select a reg or write it ?) */ |
| 365 | 423 | AY8910_control_port_0_w(machine, 0, vectrex_via_out[PORTA]); |
| 366 | 424 | else |
| r2386 | r2387 | |
| 368 | 426 | } |
| 369 | 427 | |
| 370 | 428 | if (!(data & 0x1) && (vectrex_via_out[PORTB] & 0x1)) |
| 371 | | /* MUX has been enabled, so check with which signal the MUX |
| 372 | | * coulpes the DAC output. */ |
| 373 | 429 | vectrex_multiplexer ((data >> 1) & 0x3); |
| 374 | 430 | |
| 375 | 431 | vectrex_via_out[PORTB] = data; |
| 432 | timer_set(ATTOTIME_IN_NSEC(ANALOG_DELAY), &ramp, data & 0x80, update_signal); |
| 376 | 433 | } |
| 377 | 434 | |
| 378 | 435 | static WRITE8_HANDLER ( v_via_pa_w ) |
| 379 | 436 | { |
| 380 | | double time_now; |
| 437 | /* DAC output always goes to Y integrator */ |
| 438 | vectrex_via_out[PORTA] = data; |
| 439 | timer_set(ATTOTIME_IN_NSEC(ANALOG_DELAY), &analog[A_Y], data, update_signal); |
| 381 | 440 | |
| 382 | | if (!(vectrex_via_out[PORTB] & 0x80)) /* RAMP active (low) ? */ |
| 383 | | { |
| 384 | | /* The game changes the sample and hold ICs (X/Y axis) |
| 385 | | * during line draw (curved vectors) |
| 386 | | * Draw the vector with the current settings |
| 387 | | * before updating the signals. |
| 388 | | */ |
| 389 | | time_now = attotime_to_double(timer_get_time()) + SH_DELAY; |
| 390 | | vectrex_solid_line(time_now - start_time, blank); |
| 391 | | start_time = time_now; |
| 392 | | } |
| 393 | | /* DAC output always goes into Y integrator */ |
| 394 | | vectrex_via_out[PORTA] = analog_sig[ASIG_Y] = (signed char)data; |
| 395 | | |
| 396 | 441 | if (!(vectrex_via_out[PORTB] & 0x1)) |
| 397 | | /* MUX is enabled, so check with which signal the MUX |
| 398 | | * coulpes the DAC output. */ |
| 399 | 442 | vectrex_multiplexer ((vectrex_via_out[PORTB] >> 1) & 0x3); |
| 400 | 443 | } |
| 401 | 444 | |
| 402 | 445 | static WRITE8_HANDLER ( v_via_ca2_w ) |
| 403 | 446 | { |
| 404 | | if (!data) /* ~ZERO low ? Then zero integrators*/ |
| 405 | | vectrex_zero_integrators(); |
| 447 | if (!data) |
| 448 | timer_set(ATTOTIME_IN_NSEC(ANALOG_DELAY), NULL, 0, vectrex_zero_integrators); |
| 406 | 449 | } |
| 407 | 450 | |
| 408 | 451 | static WRITE8_HANDLER ( v_via_cb2_w ) |
| 409 | 452 | { |
| 410 | | double time_now; |
| 411 | | if (blank != data) |
| 453 | static UINT8 cb2 = 0; |
| 454 | |
| 455 | if (cb2 != data) |
| 412 | 456 | { |
| 413 | | if (vectrex_via_out[PORTB] & 0x80) |
| 414 | | { |
| 415 | | /* RAMP inactive */ |
| 416 | | /* This generates a dot (here we take the dwell time into account) */ |
| 417 | | |
| 418 | | if (data) |
| 419 | | vectrex_dot(); |
| 420 | | } |
| 421 | | else |
| 422 | | { |
| 423 | | /* RAMP active |
| 424 | | * Take MAX because RAMP is slower than BLANK |
| 425 | | */ |
| 426 | | time_now = MAX(attotime_to_double(timer_get_time()),start_time); |
| 427 | | vectrex_solid_line(time_now - start_time, blank); |
| 428 | | start_time = time_now; |
| 429 | | } |
| 430 | 457 | if (data & lightpen_check()) |
| 431 | | lightpen_trigger(machine); |
| 458 | timer_set(attotime_zero, NULL, 0, lightpen_trigger); |
| 432 | 459 | |
| 433 | | blank = data; |
| 460 | timer_set(attotime_zero, &blank, data, update_signal); |
| 461 | cb2 = data; |
| 434 | 462 | } |
| 435 | 463 | } |
| 436 | 464 | |
| 465 | |
| 437 | 466 | /***************************************************************** |
| 438 | 467 | |
| 439 | | RA+A Spectrum I+ |
| 468 | RA+A Spectrum I+ |
| 440 | 469 | |
| 441 | 470 | *****************************************************************/ |
| 442 | 471 | |
| r2386 | r2387 | |
| 450 | 479 | WRITE8_HANDLER( raaspec_led_w ) |
| 451 | 480 | { |
| 452 | 481 | logerror("Spectrum I+ LED: %i%i%i%i%i%i%i%i\n", |
| 453 | | (data>>7)&0x1, (data>>6)&0x1, (data>>5)&0x1, (data>>4)&0x1, |
| 454 | | (data>>3)&0x1, (data>>2)&0x1, (data>>1)&0x1, data&0x1); |
| 482 | (data>>7)&0x1, (data>>6)&0x1, (data>>5)&0x1, (data>>4)&0x1, |
| 483 | (data>>3)&0x1, (data>>2)&0x1, (data>>1)&0x1, data&0x1); |
| 455 | 484 | } |
| 456 | 485 | |
| 457 | 486 | VIDEO_START( raaspec ) |
| r2386 | r2387 | |
| 459 | 488 | const device_config *screen = video_screen_first(machine->config); |
| 460 | 489 | const rectangle *visarea = video_screen_get_visible_area(screen); |
| 461 | 490 | |
| 462 | | x_center=((visarea->max_x |
| 463 | | -visarea->min_x)/2) << VEC_SHIFT; |
| 464 | | y_center=((visarea->max_y |
| 465 | | -visarea->min_y)/2) << VEC_SHIFT; |
| 466 | | x_max = visarea->max_x << VEC_SHIFT; |
| 467 | | y_max = visarea->max_y << VEC_SHIFT; |
| 491 | x_center=((visarea->max_x - visarea->min_x) / 2) << 16; |
| 492 | y_center=((visarea->max_y - visarea->min_y) / 2) << 16; |
| 493 | x_max = visarea->max_x << 16; |
| 494 | y_max = visarea->max_y << 16; |
| 468 | 495 | |
| 469 | 496 | via_config(0, &spectrum1_via6522_interface); |
| 470 | 497 | via_reset(); |
| 471 | | z_factor = 2; |
| 498 | refresh = timer_alloc(vectrex_refresh, NULL); |
| 472 | 499 | |
| 473 | 500 | raaspec_led_w(machine, 0, 0xff); |
| 474 | 501 | |
src/mess/machine/vectrex.c
| r2386 | r2387 | |
| 17 | 17 | #define PORTB 0 |
| 18 | 18 | #define PORTA 1 |
| 19 | 19 | |
| 20 | |
| 20 | 21 | /********************************************************************* |
| 21 | | Global variables |
| 22 | | *********************************************************************/ |
| 22 | |
| 23 | Global variables |
| 24 | |
| 25 | *********************************************************************/ |
| 26 | |
| 23 | 27 | unsigned char vectrex_via_out[2]; |
| 24 | | rgb_t vectrex_beam_color = RGB_WHITE; /* the color of the vectrex beam */ |
| 25 | | int vectrex_imager_status = 0; /* 0 = off, 1 = right eye, 2 = left eye */ |
| 28 | rgb_t vectrex_beam_color = RGB_WHITE; /* the color of the vectrex beam */ |
| 29 | int vectrex_imager_status = 0; /* 0 = off, 1 = right eye, 2 = left eye */ |
| 26 | 30 | double imager_freq; |
| 27 | 31 | emu_timer *imager_timer; |
| 28 | 32 | int vectrex_lightpen_port=0; |
| 29 | | UINT8 *vectrex_ram_base; |
| 30 | | size_t vectrex_ram_size; |
| 33 | int vectrex_reset_refresh; |
| 31 | 34 | |
| 35 | |
| 32 | 36 | /********************************************************************* |
| 33 | | Local variables |
| 34 | | *********************************************************************/ |
| 35 | 37 | |
| 38 | Local variables |
| 39 | |
| 40 | *********************************************************************/ |
| 41 | |
| 36 | 42 | /* Colors for right and left eye */ |
| 37 | 43 | static rgb_t imager_colors[6] = |
| 38 | 44 | { |
| r2386 | r2387 | |
| 41 | 47 | |
| 42 | 48 | /* Starting points of the three colors */ |
| 43 | 49 | /* Values taken from J. Nelson's drawings*/ |
| 44 | | //static const double narrow_escape_angles[3] = {0,0.15277778, 0.34444444}; |
| 45 | | //static const double minestorm_3d_angles[3] = {0,0.16111111, 0.18888888}; |
| 46 | | //static const double crazy_coaster_angles[3] = {0,0.15277778, 0.34444444}; |
| 47 | 50 | |
| 48 | | static const double minestorm_3d_angles[3] = {0,0.1692, 0.2086}; |
| 49 | | static const double narrow_escape_angles[3] = {0,0.1631, 0.3305}; |
| 50 | | static const double crazy_coaster_angles[3] = {0,0.1631, 0.3305}; |
| 51 | static const double minestorm_3d_angles[3] = {0, 0.1692, 0.2086}; |
| 52 | static const double narrow_escape_angles[3] = {0, 0.1631, 0.3305}; |
| 53 | static const double crazy_coaster_angles[3] = {0, 0.1631, 0.3305}; |
| 51 | 54 | |
| 52 | 55 | |
| 53 | 56 | static const double unknown_game_angles[3] = {0,0.16666666, 0.33333333}; |
| 54 | 57 | static const double *vectrex_imager_angles = unknown_game_angles; |
| 55 | | static unsigned char vectrex_imager_pinlevel=0x00; |
| 58 | static unsigned char vectrex_imager_pinlevel; |
| 56 | 59 | |
| 57 | 60 | static int vectrex_verify_cart (char *data) |
| 58 | 61 | { |
| r2386 | r2387 | |
| 63 | 66 | return IMAGE_VERIFY_FAIL; |
| 64 | 67 | } |
| 65 | 68 | |
| 69 | |
| 66 | 70 | /********************************************************************* |
| 67 | | ROM load and id functions |
| 68 | | *********************************************************************/ |
| 71 | |
| 72 | ROM load and id functions |
| 73 | |
| 74 | *********************************************************************/ |
| 75 | |
| 69 | 76 | DEVICE_IMAGE_LOAD( vectrex_cart ) |
| 70 | 77 | { |
| 71 | 78 | image_fread(image, memory_region(REGION_CPU1), 0x8000); |
| r2386 | r2387 | |
| 77 | 84 | return INIT_FAIL; |
| 78 | 85 | } |
| 79 | 86 | |
| 87 | /* If VIA T2 starts, reset refresh timer. |
| 88 | This is the best strategy for most games. */ |
| 89 | vectrex_reset_refresh = 1; |
| 90 | |
| 80 | 91 | vectrex_imager_angles = narrow_escape_angles; |
| 81 | 92 | |
| 82 | 93 | /* let's do this 3D detection with a strcmp using data inside the cart images */ |
| r2386 | r2387 | |
| 96 | 107 | if (!memcmp(memory_region(REGION_CPU1)+0x11,"3D MINE STORM",13)) |
| 97 | 108 | { |
| 98 | 109 | vectrex_imager_angles = minestorm_3d_angles; |
| 110 | |
| 111 | /* Don't reset T2 each time it's written. |
| 112 | This would cause jerking in mine3. */ |
| 113 | vectrex_reset_refresh = 0; |
| 99 | 114 | } |
| 100 | 115 | |
| 101 | 116 | return INIT_PASS; |
| 102 | 117 | } |
| 103 | 118 | |
| 119 | |
| 104 | 120 | /********************************************************************* |
| 105 | | Vectrex configuration (mainly 3D Imager) |
| 106 | | *********************************************************************/ |
| 121 | |
| 122 | Vectrex configuration (mainly 3D Imager) |
| 123 | |
| 124 | *********************************************************************/ |
| 125 | |
| 107 | 126 | void vectrex_configuration(void) |
| 108 | 127 | { |
| 109 | | unsigned char cport = input_port_read_indexed(Machine, 5); |
| 128 | unsigned char cport = readinputportbytag("3DCONF"); |
| 110 | 129 | |
| 111 | 130 | /* Vectrex 'dipswitch' configuration */ |
| 112 | 131 | |
| r2386 | r2387 | |
| 183 | 202 | vectrex_beam_color = RGB_WHITE; |
| 184 | 203 | imager_colors[0]=imager_colors[1]=imager_colors[2]=imager_colors[3]=imager_colors[4]=imager_colors[5]=RGB_WHITE; |
| 185 | 204 | } |
| 186 | | vectrex_lightpen_port = (input_port_read_indexed(Machine, 6) & 0x03); |
| 205 | vectrex_lightpen_port = readinputportbytag("LPENCONF") & 0x03; |
| 187 | 206 | } |
| 188 | 207 | |
| 189 | 208 | /********************************************************************* |
| 190 | | VIA interface functions |
| 191 | | *********************************************************************/ |
| 209 | |
| 210 | VIA interface functions |
| 211 | |
| 212 | *********************************************************************/ |
| 213 | |
| 192 | 214 | void v_via_irq (int level) |
| 193 | 215 | { |
| 194 | 216 | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, level); |
| r2386 | r2387 | |
| 197 | 219 | READ8_HANDLER( v_via_pb_r ) |
| 198 | 220 | { |
| 199 | 221 | int pot; |
| 200 | | pot = input_port_read_indexed(machine, ((vectrex_via_out[PORTB] & 0x6)>>1) + 1) - 0x80; |
| 222 | pot = readinputport(((vectrex_via_out[PORTB] & 0x6) >> 1)) - 0x80; |
| 201 | 223 | |
| 202 | 224 | if (pot > (signed char)vectrex_via_out[PORTA]) |
| 203 | 225 | vectrex_via_out[PORTB] |= 0x20; |
| r2386 | r2387 | |
| 214 | 236 | { |
| 215 | 237 | vectrex_via_out[PORTA] = AY8910_read_port_0_r(machine, 0) |
| 216 | 238 | & ~(vectrex_imager_pinlevel & 0x80); |
| 217 | | vectrex_imager_pinlevel &= ~0x80; |
| 218 | 239 | } |
| 219 | 240 | return vectrex_via_out[PORTA]; |
| 220 | 241 | } |
| 221 | 242 | |
| 222 | 243 | READ8_HANDLER( s1_via_pb_r ) |
| 223 | 244 | { |
| 224 | | return (vectrex_via_out[PORTB] & ~0x40) | ((input_port_read_indexed(machine, 1) & 0x1)<<6); |
| 245 | return (vectrex_via_out[PORTB] & ~0x40) | (readinputportbytag("COIN") & 0x40); |
| 225 | 246 | } |
| 226 | 247 | |
| 248 | |
| 227 | 249 | /********************************************************************* |
| 228 | | 3D Imager support |
| 229 | | *********************************************************************/ |
| 250 | |
| 251 | 3D Imager support |
| 252 | |
| 253 | *********************************************************************/ |
| 254 | |
| 230 | 255 | static TIMER_CALLBACK(vectrex_imager_change_color) |
| 231 | 256 | { |
| 232 | 257 | vectrex_beam_color = param; |
| 233 | 258 | } |
| 234 | 259 | |
| 235 | | TIMER_CALLBACK(vectrex_imager_right_eye) |
| 260 | static TIMER_CALLBACK(update_level) |
| 236 | 261 | { |
| 262 | if (ptr) |
| 263 | * (UINT8 *) ptr = param; |
| 264 | } |
| 265 | |
| 266 | TIMER_CALLBACK(vectrex_imager_eye) |
| 267 | { |
| 237 | 268 | int coffset; |
| 238 | | double rtime = (1.0/imager_freq); |
| 269 | double rtime = (1.0 / imager_freq); |
| 239 | 270 | |
| 240 | 271 | if (vectrex_imager_status > 0) |
| 241 | 272 | { |
| 242 | 273 | vectrex_imager_status = param; |
| 243 | | coffset = param>1?3:0; |
| 274 | coffset = param > 1? 3: 0; |
| 244 | 275 | timer_set (double_to_attotime(rtime * vectrex_imager_angles[0]), NULL, imager_colors[coffset+2], vectrex_imager_change_color); |
| 245 | 276 | timer_set (double_to_attotime(rtime * vectrex_imager_angles[1]), NULL, imager_colors[coffset+1], vectrex_imager_change_color); |
| 246 | 277 | timer_set (double_to_attotime(rtime * vectrex_imager_angles[2]), NULL, imager_colors[coffset], vectrex_imager_change_color); |
| 247 | 278 | |
| 248 | 279 | if (param == 2) |
| 249 | 280 | { |
| 250 | | timer_set (double_to_attotime(rtime * 0.50), NULL, 1, vectrex_imager_right_eye); |
| 281 | timer_set (double_to_attotime(rtime * 0.50), NULL, 1, vectrex_imager_eye); |
| 251 | 282 | |
| 252 | 283 | /* Index hole sensor is connected to IO7 which triggers also CA1 of VIA */ |
| 253 | | via_0_ca1_w(machine, 0, 1); |
| 254 | | via_0_ca1_w(machine, 0, 0); |
| 284 | via_set_input_ca1(0, 1); |
| 285 | via_set_input_ca1(0, 0); |
| 255 | 286 | vectrex_imager_pinlevel |= 0x80; |
| 287 | timer_set (double_to_attotime(rtime / 360.0), &vectrex_imager_pinlevel, 0, update_level); |
| 256 | 288 | } |
| 257 | 289 | } |
| 258 | 290 | } |
| r2386 | r2387 | |
| 278 | 310 | |
| 279 | 311 | if (wavel < 1) |
| 280 | 312 | { |
| 281 | | /* The Vectrex sends a stream of pulses which controls the speed of |
| 313 | /* The Vectrex sends a stream of pulses which control the speed of |
| 282 | 314 | the motor using Pulse Width Modulation. Guessed parameters are MMI |
| 283 | 315 | (mass moment of inertia) of the color wheel, DAMPC (damping coefficient) |
| 284 | 316 | of the whole thing and some constants of the motor's torque/speed curve. |
| 285 | 317 | pwl is the negative pulse width and wavel is the whole wavelength. */ |
| 286 | 318 | |
| 287 | 319 | ang_acc = (50.0 - 1.55 * imager_freq) / MMI; |
| 288 | | imager_freq += ang_acc * pwl + DAMPC*imager_freq/MMI * wavel; |
| 320 | imager_freq += ang_acc * pwl + DAMPC * imager_freq / MMI * wavel; |
| 289 | 321 | |
| 290 | 322 | if (imager_freq > 1) |
| 291 | 323 | { |
| 292 | 324 | timer_adjust_periodic(imager_timer, |
| 293 | | double_to_attotime(MIN(1.0/imager_freq, attotime_to_double(timer_timeleft(imager_timer)))), |
| 294 | | 2, |
| 295 | | ATTOTIME_IN_HZ(imager_freq)); |
| 325 | double_to_attotime(MIN(1.0 / imager_freq, attotime_to_double(timer_timeleft(imager_timer)))), |
| 326 | 2, |
| 327 | double_to_attotime(1.0 / imager_freq)); |
| 296 | 328 | } |
| 297 | 329 | } |
| 298 | 330 | } |
| r2386 | r2387 | |
| 305 | 337 | |
| 306 | 338 | DRIVER_INIT( vectrex ) |
| 307 | 339 | { |
| 308 | | int i; |
| 309 | | |
| 310 | | /* Set the whole cart ROM area to 1. This is needed to work around a bug (?) |
| 311 | | * in Minestorm where the exec-rom attempts to access a vector list here. |
| 312 | | * 1 signals the end of the vector list. |
| 340 | /* |
| 341 | * Uninitialized RAM needs to return 0xff. Otherwise the mines in |
| 342 | * the first level of Minestorm are not evenly distributed. |
| 313 | 343 | */ |
| 314 | | if (vectrex_verify_cart((char*)memory_region(REGION_CPU1)) == IMAGE_VERIFY_FAIL) |
| 315 | | { |
| 316 | | memset (memory_region(REGION_CPU1), 1, 0x8000); |
| 317 | | } |
| 318 | 344 | |
| 319 | | for (i = 0; i < vectrex_ram_size; i++) |
| 320 | | vectrex_ram_base[i] = mame_rand(machine); |
| 345 | memset(vectorram, 0xff, vectorram_size); |
| 321 | 346 | } |
src/mess/drivers/vectrex.c
| r2386 | r2387 | |
| 17 | 17 | |
| 18 | 18 | static ADDRESS_MAP_START( vectrex_map , ADDRESS_SPACE_PROGRAM, 8) |
| 19 | 19 | AM_RANGE( 0x0000, 0x7fff) AM_ROM |
| 20 | | AM_RANGE( 0xc800, 0xcbff) AM_RAM AM_MIRROR( 0x0400 ) AM_BASE(&vectrex_ram_base) AM_SIZE(&vectrex_ram_size) |
| 21 | | AM_RANGE( 0xd000, 0xd7ff) AM_READWRITE( via_0_r, via_0_w ) |
| 20 | AM_RANGE( 0xc800, 0xcbff) AM_RAM AM_MIRROR( 0x0400 ) AM_BASE(&vectorram) AM_SIZE(&vectorram_size) |
| 21 | AM_RANGE( 0xd000, 0xd7ff) AM_READWRITE( via_0_r, vectrex_via_w ) |
| 22 | 22 | AM_RANGE( 0xe000, 0xffff) AM_ROM |
| 23 | 23 | ADDRESS_MAP_END |
| 24 | 24 | |
| 25 | 25 | static INPUT_PORTS_START( vectrex ) |
| 26 | | PORT_START |
| 26 | PORT_START_TAG("CONTR1X") |
| 27 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) |
| 28 | |
| 29 | PORT_START_TAG("CONTR1Y") |
| 30 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE |
| 31 | |
| 32 | PORT_START_TAG("CONTR2X") |
| 33 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_PLAYER(2) |
| 34 | |
| 35 | PORT_START_TAG("CONTR2Y") |
| 36 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(2) |
| 37 | |
| 38 | PORT_START_TAG("BUTTONS") |
| 27 | 39 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1) |
| 28 | 40 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1) |
| 29 | 41 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(1) |
| r2386 | r2387 | |
| 33 | 45 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(2) |
| 34 | 46 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(2) |
| 35 | 47 | |
| 36 | | PORT_START /* IN1 */ |
| 37 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0,255) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) |
| 38 | | |
| 39 | | PORT_START /* IN2 */ |
| 40 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0,255) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE |
| 41 | | |
| 42 | | PORT_START /* IN3 */ |
| 43 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0,255) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_PLAYER(2) |
| 44 | | |
| 45 | | PORT_START /* IN4 */ |
| 46 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0,255) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(2) |
| 47 | | |
| 48 | | PORT_START /* IN5 */ |
| 48 | PORT_START_TAG("3DCONF") |
| 49 | 49 | PORT_DIPNAME( 0x01, 0x00, "3D Imager") |
| 50 | 50 | PORT_DIPSETTING(0x00, DEF_STR ( Off )) |
| 51 | 51 | PORT_DIPSETTING(0x01, DEF_STR ( On )) |
| r2386 | r2387 | |
| 65 | 65 | PORT_DIPSETTING(0x60, "Blue") |
| 66 | 66 | PORT_DIPSETTING(0x80, "Color") |
| 67 | 67 | |
| 68 | | PORT_START /* IN6 */ |
| 68 | PORT_START_TAG("LPENCONF") |
| 69 | 69 | PORT_DIPNAME( 0x03, 0x00, "Lightpen") |
| 70 | 70 | PORT_DIPSETTING(0x00, DEF_STR ( Off )) |
| 71 | 71 | PORT_DIPSETTING(0x01, "left port") |
| 72 | 72 | PORT_DIPSETTING(0x02, "right port") |
| 73 | 73 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5) PORT_CODE(MOUSECODE_BUTTON1) |
| 74 | 74 | |
| 75 | | PORT_START /* Lightpen - X AXIS */ |
| 76 | | PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(1) PORT_PLAYER(1) |
| 75 | PORT_START_TAG("LPENY") |
| 76 | PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(Y, 1, 0, 0) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(1) PORT_PLAYER(1) |
| 77 | 77 | |
| 78 | | PORT_START /* Lightpen - Y AXIS */ |
| 79 | | PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(1) PORT_PLAYER(1) |
| 78 | PORT_START_TAG("LPENX") |
| 79 | PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(X, 1, 0, 0) PORT_MINMAX(0,0xff) PORT_SENSITIVITY(35) PORT_KEYDELTA(1) PORT_REVERSE PORT_PLAYER(1) |
| 80 | 80 | |
| 81 | | |
| 82 | 81 | INPUT_PORTS_END |
| 83 | 82 | |
| 84 | 83 | |
| 85 | 84 | |
| 86 | 85 | static const struct AY8910interface ay8910_interface = |
| 87 | 86 | { |
| 88 | | input_port_0_r, |
| 87 | input_port_4_r, |
| 89 | 88 | 0, |
| 90 | 89 | vectrex_psg_port_w, |
| 91 | 90 | 0 |
| r2386 | r2387 | |
| 94 | 93 | |
| 95 | 94 | static MACHINE_DRIVER_START( vectrex ) |
| 96 | 95 | /* basic machine hardware */ |
| 97 | | MDRV_CPU_ADD_TAG("main", M6809, 1500000) /* 1.5 Mhz */ |
| 96 | MDRV_CPU_ADD_TAG("main", M6809, XTAL_6MHz/4) |
| 98 | 97 | MDRV_CPU_PROGRAM_MAP(vectrex_map, 0) |
| 99 | 98 | |
| 100 | 99 | MDRV_SCREEN_ADD("main", VECTOR) |
| 101 | 100 | MDRV_SCREEN_REFRESH_RATE(60) |
| 102 | 101 | |
| 103 | | /* video hardware */ |
| 102 | /* video hardware */ |
| 104 | 103 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 105 | 104 | MDRV_SCREEN_SIZE(400, 300) |
| 106 | 105 | MDRV_SCREEN_VISIBLE_AREA(0, 399, 0, 299) |
| 107 | | MDRV_PALETTE_LENGTH(256 + 32768) |
| 108 | | /*MDRV_ASPECT_RATIO(3, 4)*/ |
| 109 | 106 | |
| 110 | 107 | MDRV_VIDEO_START( vectrex ) |
| 111 | 108 | MDRV_VIDEO_UPDATE( vectrex ) |
| r2386 | r2387 | |
| 125 | 122 | switch(state) |
| 126 | 123 | { |
| 127 | 124 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 128 | | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 125 | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 129 | 126 | |
| 130 | 127 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 131 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(vectrex_cart); break; |
| 128 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(vectrex_cart); break; |
| 132 | 129 | |
| 133 | 130 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 134 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "bin,gam,vec"); break; |
| 131 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "bin,gam,vec"); break; |
| 135 | 132 | |
| 136 | | default: cartslot_device_getinfo(devclass, state, info); break; |
| 133 | default: cartslot_device_getinfo(devclass, state, info); break; |
| 137 | 134 | } |
| 138 | 135 | } |
| 139 | 136 | |
| r2386 | r2387 | |
| 142 | 139 | SYSTEM_CONFIG_END |
| 143 | 140 | |
| 144 | 141 | ROM_START(vectrex) |
| 145 | | ROM_REGION(0x10000,REGION_CPU1, 0) |
| 146 | | ROM_LOAD("system.img", 0xe000, 0x2000, CRC(ba13fb57) SHA1(65d07426b520ddd3115d40f255511e0fd2e20ae7)) |
| 142 | ROM_REGION(0x10000,REGION_CPU1, 0) |
| 143 | ROM_LOAD("system.img", 0xe000, 0x2000, CRC(ba13fb57) SHA1(65d07426b520ddd3115d40f255511e0fd2e20ae7)) |
| 147 | 144 | ROM_END |
| 148 | 145 | |
| 149 | 146 | |
| r2386 | r2387 | |
| 186 | 183 | AM_RANGE( 0x0000, 0x7fff) AM_ROM |
| 187 | 184 | AM_RANGE( 0x8000, 0x87ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) |
| 188 | 185 | AM_RANGE( 0xa000, 0xa000) AM_WRITE( raaspec_led_w ) |
| 189 | | AM_RANGE( 0xc800, 0xcbff) AM_RAM AM_RAM AM_MIRROR( 0x0400 ) |
| 190 | | AM_RANGE( 0xd000, 0xd7ff) AM_READWRITE ( via_0_r, via_0_w) |
| 186 | AM_RANGE( 0xc800, 0xcbff) AM_RAM AM_MIRROR( 0x0400 ) AM_BASE(&vectorram) AM_SIZE(&vectorram_size) |
| 187 | AM_RANGE( 0xd000, 0xd7ff) AM_READWRITE ( via_0_r, vectrex_via_w) |
| 191 | 188 | AM_RANGE( 0xe000, 0xffff) AM_ROM |
| 192 | 189 | ADDRESS_MAP_END |
| 193 | 190 | |
| 194 | 191 | static INPUT_PORTS_START( raaspec ) |
| 195 | | PORT_START |
| 196 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 192 | PORT_START_TAG("LPENCONF") |
| 193 | PORT_START_TAG("LPENY") |
| 194 | PORT_START_TAG("LPENX") |
| 195 | PORT_START_TAG("3DCONF") |
| 196 | PORT_START_TAG("BUTTONS") |
| 197 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 197 | 198 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) |
| 198 | 199 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) |
| 199 | 200 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) |
| r2386 | r2387 | |
| 201 | 202 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) |
| 202 | 203 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) |
| 203 | 204 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON8 ) |
| 204 | | |
| 205 | | PORT_START |
| 206 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SELECT ) |
| 207 | | |
| 205 | PORT_START_TAG("COIN") |
| 206 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 ) |
| 208 | 207 | INPUT_PORTS_END |
| 209 | 208 | |
| 210 | 209 | |
| r2386 | r2387 | |
| 214 | 213 | MDRV_CPU_PROGRAM_MAP( raaspec_map, 0 ) |
| 215 | 214 | MDRV_NVRAM_HANDLER(generic_0fill) |
| 216 | 215 | |
| 217 | | MDRV_PALETTE_LENGTH(254) |
| 218 | | |
| 219 | 216 | MDRV_VIDEO_START( raaspec ) |
| 220 | 217 | MACHINE_DRIVER_END |
| 221 | 218 | |
| r2386 | r2387 | |
| 232 | 229 | ***************************************************************************/ |
| 233 | 230 | |
| 234 | 231 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 235 | | CONS( 1982, vectrex, 0, 0, vectrex, vectrex, vectrex, vectrex, "General Consumer Electronics", "Vectrex" , ROT270) |
| 236 | | CONS( 1984, raaspec, vectrex, 0, raaspec, raaspec, 0, NULL, "Roy Abel & Associates", "Spectrum I+" , ROT270) |
| 232 | CONS( 1982, vectrex, 0, 0, vectrex, vectrex, vectrex, vectrex, "General Consumer Electronics", "Vectrex" , ROT270) |
| 233 | CONS( 1984, raaspec, vectrex, 0, raaspec, raaspec, vectrex, NULL, "Roy Abel & Associates", "Spectrum I+" , ROT270) |