src/mess/video/upd3301.c
| r6857 | r6858 | |
| 1 | | /**********************************************************************
|
| 2 | | |
| 3 | | NEC uPD3301 Programmable CRT Controller emulation
|
| 4 | | |
| 5 | | Copyright MESS Team.
|
| 6 | | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | | |
| 8 | | **********************************************************************/
|
| 9 | | |
| 10 | | /*
|
| 11 | | |
| 12 | | TODO:
|
| 13 | | |
| 14 | | - attributes
|
| 15 | | - N interrupt
|
| 16 | | - light pen
|
| 17 | | - reset counters
|
| 18 | | - proper DMA timing (now the whole screen is transferred at the end of the frame,
|
| 19 | | accurate timing requires CCLK timer which kills performance)
|
| 20 | | |
| 21 | | */
|
| 22 | | |
| 23 | | #include "driver.h"
|
| 24 | | #include "upd3301.h"
|
| 25 | | |
| 26 | | /***************************************************************************
|
| 27 | | PARAMETERS
|
| 28 | | ***************************************************************************/
|
| 29 | | |
| 30 | | #define LOG 0
|
| 31 | | |
| 32 | | #define UPD3301_COMMAND_MASK 0xe0
|
| 33 | | #define UPD3301_COMMAND_RESET 0x00
|
| 34 | | #define UPD3301_COMMAND_START_DISPLAY 0x20
|
| 35 | | #define UPD3301_COMMAND_SET_INTERRUPT_MASK 0x40
|
| 36 | | #define UPD3301_COMMAND_READ_LIGHT_PEN 0x60 /* not supported */
|
| 37 | | #define UPD3301_COMMAND_LOAD_CURSOR_POSITION 0x80
|
| 38 | | #define UPD3301_COMMAND_RESET_INTERRUPT 0xa0
|
| 39 | | #define UPD3301_COMMAND_RESET_COUNTERS 0xc0 /* not supported */
|
| 40 | | |
| 41 | | #define UPD3301_STATUS_VE 0x10
|
| 42 | | #define UPD3301_STATUS_U 0x08 /* not supported */
|
| 43 | | #define UPD3301_STATUS_N 0x04 /* not supported */
|
| 44 | | #define UPD3301_STATUS_E 0x02
|
| 45 | | #define UPD3301_STATUS_LP 0x01 /* not supported */
|
| 46 | | |
| 47 | | enum
|
| 48 | | {
|
| 49 | | MODE_NONE,
|
| 50 | | MODE_RESET,
|
| 51 | | MODE_READ_LIGHT_PEN,
|
| 52 | | MODE_LOAD_CURSOR_POSITION,
|
| 53 | | MODE_RESET_COUNTERS
|
| 54 | | };
|
| 55 | | |
| 56 | | /***************************************************************************
|
| 57 | | TYPE DEFINITIONS
|
| 58 | | ***************************************************************************/
|
| 59 | | |
| 60 | | typedef struct _upd3301_t upd3301_t;
|
| 61 | | struct _upd3301_t
|
| 62 | | {
|
| 63 | | /* callbacks */
|
| 64 | | devcb_resolved_write_line out_int_func;
|
| 65 | | devcb_resolved_write_line out_drq_func;
|
| 66 | | devcb_resolved_write_line out_hrtc_func;
|
| 67 | | devcb_resolved_write_line out_vrtc_func;
|
| 68 | | upd3301_display_pixels_func display_func;
|
| 69 | | |
| 70 | | /* screen drawing */
|
| 71 | | const device_config *screen; /* screen */
|
| 72 | | bitmap_t *bitmap; /* bitmap */
|
| 73 | | int y; /* current scanline */
|
| 74 | | int hrtc; /* horizontal retrace */
|
| 75 | | int vrtc; /* vertical retrace */
|
| 76 | | |
| 77 | | /* live state */
|
| 78 | | int mode; /* command mode */
|
| 79 | | UINT8 status; /* status register */
|
| 80 | | int param_count; /* parameter count */
|
| 81 | | |
| 82 | | /* FIFOs */
|
| 83 | | UINT8 data_fifo[80][2]; /* row data FIFO */
|
| 84 | | UINT8 attr_fifo[40][2]; /* attribute FIFO */
|
| 85 | | int data_fifo_pos; /* row data FIFO position */
|
| 86 | | int attr_fifo_pos; /* attribute FIFO position */
|
| 87 | | int input_fifo; /* which FIFO is in input mode */
|
| 88 | | |
| 89 | | /* interrupts */
|
| 90 | | int mn; /* disable special character interrupt */
|
| 91 | | int me; /* disable end of screen interrupt */
|
| 92 | | int dma_mode; /* DMA mode */
|
| 93 | | |
| 94 | | /* screen geometry */
|
| 95 | | int width; /* character width */
|
| 96 | | int h; /* characters per line */
|
| 97 | | int b; /* cursor blink time */
|
| 98 | | int l; /* lines per screen */
|
| 99 | | int s; /* display every other line */
|
| 100 | | int c; /* cursor mode */
|
| 101 | | int r; /* lines per character */
|
| 102 | | int v; /* vertical blanking height */
|
| 103 | | int z; /* horizontal blanking width */
|
| 104 | | |
| 105 | | /* attributes */
|
| 106 | | int at1; /* */
|
| 107 | | int at0; /* */
|
| 108 | | int sc; /* */
|
| 109 | | int a; /* attributes per row */
|
| 110 | | int attr_blink; /* attribute blink */
|
| 111 | | int attr_frame; /* attribute blink frame counter */
|
| 112 | | |
| 113 | | /* cursor */
|
| 114 | | int cm; /* cursor visible */
|
| 115 | | int cx; /* cursor column */
|
| 116 | | int cy; /* cursor row */
|
| 117 | | int cursor_blink; /* cursor blink */
|
| 118 | | int cursor_frame; /* cursor blink frame counter */
|
| 119 | | |
| 120 | | /* timers */
|
| 121 | | emu_timer *vrtc_timer; /* vertical sync timer */
|
| 122 | | emu_timer *hrtc_timer; /* horizontal sync timer */
|
| 123 | | };
|
| 124 | | |
| 125 | | /***************************************************************************
|
| 126 | | INLINE FUNCTIONS
|
| 127 | | ***************************************************************************/
|
| 128 | | |
| 129 | | INLINE upd3301_t *get_safe_token(const device_config *device)
|
| 130 | | {
|
| 131 | | assert(device != NULL);
|
| 132 | | assert(device->token != NULL);
|
| 133 | | assert((device->type == UPD3301));
|
| 134 | | return (upd3301_t *)device->token;
|
| 135 | | }
|
| 136 | | |
| 137 | | INLINE const upd3301_interface *get_interface(const device_config *device)
|
| 138 | | {
|
| 139 | | assert(device != NULL);
|
| 140 | | assert((device->type == UPD3301));
|
| 141 | | return (const upd3301_interface *) device->static_config;
|
| 142 | | }
|
| 143 | | |
| 144 | | /***************************************************************************
|
| 145 | | IMPLEMENTATION
|
| 146 | | ***************************************************************************/
|
| 147 | | |
| 148 | | /*-------------------------------------------------
|
| 149 | | set_interrupt - set interrupt line state
|
| 150 | | -------------------------------------------------*/
|
| 151 | | |
| 152 | | static void set_interrupt(const device_config *device, int state)
|
| 153 | | {
|
| 154 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 155 | | |
| 156 | | if (LOG) logerror("UPD3301 '%s' Interrupt: %u\n", device->tag, state);
|
| 157 | | |
| 158 | | devcb_call_write_line(&upd3301->out_int_func, state);
|
| 159 | | |
| 160 | | if (!state)
|
| 161 | | {
|
| 162 | | upd3301->status &= ~(UPD3301_STATUS_N | UPD3301_STATUS_E);
|
| 163 | | }
|
| 164 | | }
|
| 165 | | |
| 166 | | /*-------------------------------------------------
|
| 167 | | set_drq - set data request line state
|
| 168 | | -------------------------------------------------*/
|
| 169 | | |
| 170 | | static void set_drq(const device_config *device, int state)
|
| 171 | | {
|
| 172 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 173 | | |
| 174 | | if (LOG) logerror("UPD3301 '%s' DRQ: %u\n", device->tag, state);
|
| 175 | | |
| 176 | | devcb_call_write_line(&upd3301->out_drq_func, state);
|
| 177 | | }
|
| 178 | | |
| 179 | | /*-------------------------------------------------
|
| 180 | | set_display - set display state
|
| 181 | | -------------------------------------------------*/
|
| 182 | | |
| 183 | | static void set_display(const device_config *device, int state)
|
| 184 | | {
|
| 185 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 186 | | |
| 187 | | if (state)
|
| 188 | | {
|
| 189 | | upd3301->status |= UPD3301_STATUS_VE;
|
| 190 | | }
|
| 191 | | else
|
| 192 | | {
|
| 193 | | upd3301->status &= ~UPD3301_STATUS_VE;
|
| 194 | | }
|
| 195 | | }
|
| 196 | | |
| 197 | | /*-------------------------------------------------
|
| 198 | | reset_counters - reset screen counters
|
| 199 | | -------------------------------------------------*/
|
| 200 | | |
| 201 | | static void reset_counters(const device_config *device)
|
| 202 | | {
|
| 203 | | set_interrupt(device, 0);
|
| 204 | | set_drq(device, 0);
|
| 205 | | }
|
| 206 | | |
| 207 | | /*-------------------------------------------------
|
| 208 | | update_hrtc_timer - update horizontal retrace
|
| 209 | | timer
|
| 210 | | -------------------------------------------------*/
|
| 211 | | |
| 212 | | static void update_hrtc_timer(upd3301_t *upd3301, int state)
|
| 213 | | {
|
| 214 | | int y = video_screen_get_vpos(upd3301->screen);
|
| 215 | | |
| 216 | | int next_x = state ? upd3301->h : 0;
|
| 217 | | int next_y = state ? y : ((y + 1) % ((upd3301->l + upd3301->v) * upd3301->width));
|
| 218 | | |
| 219 | | attotime duration = video_screen_get_time_until_pos(upd3301->screen, next_y, next_x);
|
| 220 | | |
| 221 | | timer_adjust_oneshot(upd3301->hrtc_timer, duration, !state);
|
| 222 | | }
|
| 223 | | |
| 224 | | /*-------------------------------------------------
|
| 225 | | update_vrtc_timer - update vertical retrace
|
| 226 | | timer
|
| 227 | | -------------------------------------------------*/
|
| 228 | | |
| 229 | | static void update_vrtc_timer(upd3301_t *upd3301, int state)
|
| 230 | | {
|
| 231 | | int next_y = state ? (upd3301->l * upd3301->r) : 0;
|
| 232 | | |
| 233 | | attotime duration = video_screen_get_time_until_pos(upd3301->screen, next_y, 0);
|
| 234 | | |
| 235 | | timer_adjust_oneshot(upd3301->vrtc_timer, duration, !state);
|
| 236 | | }
|
| 237 | | |
| 238 | | /*-------------------------------------------------
|
| 239 | | recompute_parameters - recompute screen
|
| 240 | | geometry parameters
|
| 241 | | -------------------------------------------------*/
|
| 242 | | |
| 243 | | static void recompute_parameters(const device_config *device)
|
| 244 | | {
|
| 245 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 246 | | |
| 247 | | int horiz_pix_total = (upd3301->h + upd3301->z) * upd3301->width;
|
| 248 | | int vert_pix_total = (upd3301->l + upd3301->v) * upd3301->r;
|
| 249 | | |
| 250 | | attoseconds_t refresh = HZ_TO_ATTOSECONDS(device->clock) * horiz_pix_total * vert_pix_total;
|
| 251 | | |
| 252 | | rectangle visarea;
|
| 253 | | |
| 254 | | visarea.min_x = 0;
|
| 255 | | visarea.min_y = 0;
|
| 256 | | visarea.max_x = (upd3301->h * upd3301->width) - 1;
|
| 257 | | visarea.max_y = (upd3301->l * upd3301->r) - 1;
|
| 258 | | |
| 259 | | if (LOG)
|
| 260 | | {
|
| 261 | | if (LOG) logerror("UPD3301 '%s' Screen: %u x %u @ %f Hz\n", device->tag, horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
|
| 262 | | if (LOG) logerror("UPD3301 '%s' Visible Area: (%u, %u) - (%u, %u)\n", device->tag, visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
|
| 263 | | }
|
| 264 | | |
| 265 | | video_screen_configure(upd3301->screen, horiz_pix_total, vert_pix_total, &visarea, refresh);
|
| 266 | | |
| 267 | | update_hrtc_timer(upd3301, 0);
|
| 268 | | update_vrtc_timer(upd3301, 0);
|
| 269 | | }
|
| 270 | | |
| 271 | | /*-------------------------------------------------
|
| 272 | | TIMER_CALLBACK( vrtc_tick )
|
| 273 | | -------------------------------------------------*/
|
| 274 | | |
| 275 | | static TIMER_CALLBACK( vrtc_tick )
|
| 276 | | {
|
| 277 | | const device_config *device = ptr;
|
| 278 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 279 | | |
| 280 | | //if (LOG) logerror("UPD3301 '%s' VRTC: %u\n", device->tag, param);
|
| 281 | | |
| 282 | | devcb_call_write_line(&upd3301->out_vrtc_func, param);
|
| 283 | | upd3301->vrtc = param;
|
| 284 | | |
| 285 | | if (param && !upd3301->me)
|
| 286 | | {
|
| 287 | | upd3301->status |= UPD3301_STATUS_E;
|
| 288 | | set_interrupt(device, 1);
|
| 289 | | }
|
| 290 | | |
| 291 | | update_vrtc_timer(upd3301, param);
|
| 292 | | }
|
| 293 | | |
| 294 | | /*-------------------------------------------------
|
| 295 | | TIMER_CALLBACK( hrtc_tick )
|
| 296 | | -------------------------------------------------*/
|
| 297 | | |
| 298 | | static TIMER_CALLBACK( hrtc_tick )
|
| 299 | | {
|
| 300 | | const device_config *device = ptr;
|
| 301 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 302 | | |
| 303 | | //if (LOG) logerror("UPD3301 '%s' HRTC: %u\n", device->tag, param);
|
| 304 | | |
| 305 | | devcb_call_write_line(&upd3301->out_hrtc_func, param);
|
| 306 | | upd3301->hrtc = param;
|
| 307 | | |
| 308 | | update_hrtc_timer(upd3301, param);
|
| 309 | | }
|
| 310 | | |
| 311 | | /*-------------------------------------------------
|
| 312 | | upd3301_r - register read
|
| 313 | | -------------------------------------------------*/
|
| 314 | | |
| 315 | | READ8_DEVICE_HANDLER( upd3301_r )
|
| 316 | | {
|
| 317 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 318 | | UINT8 data = 0;
|
| 319 | | |
| 320 | | switch (offset & 0x01)
|
| 321 | | {
|
| 322 | | case 0: /* data */
|
| 323 | | break;
|
| 324 | | |
| 325 | | case 1: /* status */
|
| 326 | | data = upd3301->status;
|
| 327 | | upd3301->status &= ~(UPD3301_STATUS_LP | UPD3301_STATUS_E |UPD3301_STATUS_N | UPD3301_STATUS_U);
|
| 328 | | break;
|
| 329 | | }
|
| 330 | | |
| 331 | | return data;
|
| 332 | | }
|
| 333 | | |
| 334 | | /*-------------------------------------------------
|
| 335 | | upd3301_w - register write
|
| 336 | | -------------------------------------------------*/
|
| 337 | | |
| 338 | | WRITE8_DEVICE_HANDLER( upd3301_w )
|
| 339 | | {
|
| 340 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 341 | | |
| 342 | | switch (offset & 0x01)
|
| 343 | | {
|
| 344 | | case 0: /* data */
|
| 345 | | switch (upd3301->mode)
|
| 346 | | {
|
| 347 | | case MODE_RESET:
|
| 348 | | switch (upd3301->param_count)
|
| 349 | | {
|
| 350 | | case 0:
|
| 351 | | upd3301->dma_mode = BIT(data, 7);
|
| 352 | | upd3301->h = (data & 0x7f) + 2;
|
| 353 | | if (LOG) logerror("UPD3301 '%s' DMA Mode: %s\n", device->tag, upd3301->dma_mode ? "character" : "burst");
|
| 354 | | if (LOG) logerror("UPD3301 '%s' H: %u\n", device->tag, upd3301->h);
|
| 355 | | break;
|
| 356 | | |
| 357 | | case 1:
|
| 358 | | upd3301->b = ((data >> 6) + 1) * 16;
|
| 359 | | upd3301->l = (data & 0x3f) + 1;
|
| 360 | | if (LOG) logerror("UPD3301 '%s' B: %u\n", device->tag, upd3301->b);
|
| 361 | | if (LOG) logerror("UPD3301 '%s' L: %u\n", device->tag, upd3301->l);
|
| 362 | | break;
|
| 363 | | |
| 364 | | case 2:
|
| 365 | | upd3301->s = BIT(data, 7);
|
| 366 | | upd3301->c = (data >> 4) & 0x03;
|
| 367 | | upd3301->r = (data & 0x1f) + 1;
|
| 368 | | if (LOG) logerror("UPD3301 '%s' S: %u\n", device->tag, upd3301->s);
|
| 369 | | if (LOG) logerror("UPD3301 '%s' C: %u\n", device->tag, upd3301->c);
|
| 370 | | if (LOG) logerror("UPD3301 '%s' R: %u\n", device->tag, upd3301->r);
|
| 371 | | break;
|
| 372 | | |
| 373 | | case 3:
|
| 374 | | upd3301->v = (data >> 5) + 1;
|
| 375 | | upd3301->z = (data & 0x1f) + 2;
|
| 376 | | if (LOG) logerror("UPD3301 '%s' V: %u\n", device->tag, upd3301->v);
|
| 377 | | if (LOG) logerror("UPD3301 '%s' Z: %u\n", device->tag, upd3301->z);
|
| 378 | | recompute_parameters(device);
|
| 379 | | break;
|
| 380 | | |
| 381 | | case 4:
|
| 382 | | upd3301->at1 = BIT(data, 7);
|
| 383 | | upd3301->at0 = BIT(data, 6);
|
| 384 | | upd3301->sc = BIT(data, 5);
|
| 385 | | upd3301->a = (data & 0x1f) + 1;
|
| 386 | | if (LOG) logerror("UPD3301 '%s' AT1: %u\n", device->tag, upd3301->at1);
|
| 387 | | if (LOG) logerror("UPD3301 '%s' AT0: %u\n", device->tag, upd3301->at0);
|
| 388 | | if (LOG) logerror("UPD3301 '%s' SC: %u\n", device->tag, upd3301->sc);
|
| 389 | | if (LOG) logerror("UPD3301 '%s' A: %u\n", device->tag, upd3301->a);
|
| 390 | | |
| 391 | | upd3301->mode = MODE_NONE;
|
| 392 | | break;
|
| 393 | | }
|
| 394 | | |
| 395 | | upd3301->param_count++;
|
| 396 | | break;
|
| 397 | | |
| 398 | | case MODE_LOAD_CURSOR_POSITION:
|
| 399 | | switch (upd3301->param_count)
|
| 400 | | {
|
| 401 | | case 0:
|
| 402 | | upd3301->cx = data & 0x7f;
|
| 403 | | if (LOG) logerror("UPD3301 '%s' CX: %u\n", device->tag, upd3301->cx);
|
| 404 | | break;
|
| 405 | | |
| 406 | | case 1:
|
| 407 | | upd3301->cy = data & 0x3f;
|
| 408 | | if (LOG) logerror("UPD3301 '%s' CY: %u\n", device->tag, upd3301->cy);
|
| 409 | | |
| 410 | | upd3301->mode = MODE_NONE;
|
| 411 | | break;
|
| 412 | | }
|
| 413 | | |
| 414 | | upd3301->param_count++;
|
| 415 | | break;
|
| 416 | | |
| 417 | | default:
|
| 418 | | if (LOG) logerror("UPD3301 '%s' Invalid Parameter Byte %02x!\n", device->tag, data);
|
| 419 | | }
|
| 420 | | break;
|
| 421 | | |
| 422 | | case 1: /* command */
|
| 423 | | upd3301->mode = MODE_NONE;
|
| 424 | | upd3301->param_count = 0;
|
| 425 | | |
| 426 | | switch (data & 0xe0)
|
| 427 | | {
|
| 428 | | case UPD3301_COMMAND_RESET:
|
| 429 | | if (LOG) logerror("UPD3301 '%s' Reset\n", device->tag);
|
| 430 | | upd3301->mode = MODE_RESET;
|
| 431 | | set_display(device, 0);
|
| 432 | | set_interrupt(device, 0);
|
| 433 | | break;
|
| 434 | | |
| 435 | | case UPD3301_COMMAND_START_DISPLAY:
|
| 436 | | if (LOG) logerror("UPD3301 '%s' Start Display\n", device->tag);
|
| 437 | | set_display(device, 1);
|
| 438 | | reset_counters(device);
|
| 439 | | break;
|
| 440 | | |
| 441 | | case UPD3301_COMMAND_SET_INTERRUPT_MASK:
|
| 442 | | if (LOG) logerror("UPD3301 '%s' Set Interrupt Mask\n", device->tag);
|
| 443 | | upd3301->me = BIT(data, 0);
|
| 444 | | upd3301->mn = BIT(data, 1);
|
| 445 | | if (LOG) logerror("UPD3301 '%s' ME: %u\n", device->tag, upd3301->me);
|
| 446 | | if (LOG) logerror("UPD3301 '%s' MN: %u\n", device->tag, upd3301->mn);
|
| 447 | | break;
|
| 448 | | |
| 449 | | case UPD3301_COMMAND_READ_LIGHT_PEN:
|
| 450 | | if (LOG) logerror("UPD3301 '%s' Read Light Pen\n", device->tag);
|
| 451 | | upd3301->mode = MODE_READ_LIGHT_PEN;
|
| 452 | | break;
|
| 453 | | |
| 454 | | case UPD3301_COMMAND_LOAD_CURSOR_POSITION:
|
| 455 | | if (LOG) logerror("UPD3301 '%s' Load Cursor Position\n", device->tag);
|
| 456 | | upd3301->mode = MODE_LOAD_CURSOR_POSITION;
|
| 457 | | upd3301->cm = BIT(data, 0);
|
| 458 | | if (LOG) logerror("UPD3301 '%s' CM: %u\n", device->tag, upd3301->cm);
|
| 459 | | break;
|
| 460 | | |
| 461 | | case UPD3301_COMMAND_RESET_INTERRUPT:
|
| 462 | | if (LOG) logerror("UPD3301 '%s' Reset Interrupt\n", device->tag);
|
| 463 | | set_interrupt(device, 0);
|
| 464 | | break;
|
| 465 | | |
| 466 | | case UPD3301_COMMAND_RESET_COUNTERS:
|
| 467 | | if (LOG) logerror("UPD3301 '%s' Reset Counters\n", device->tag);
|
| 468 | | upd3301->mode = MODE_RESET_COUNTERS;
|
| 469 | | reset_counters(device);
|
| 470 | | break;
|
| 471 | | }
|
| 472 | | break;
|
| 473 | | }
|
| 474 | | }
|
| 475 | | |
| 476 | | /*-------------------------------------------------
|
| 477 | | upd3301_lpen_w - light pen write
|
| 478 | | -------------------------------------------------*/
|
| 479 | | |
| 480 | | WRITE_LINE_DEVICE_HANDLER( upd3301_lpen_w )
|
| 481 | | {
|
| 482 | | }
|
| 483 | | |
| 484 | | /*-------------------------------------------------
|
| 485 | | upd3301_hrtc_r - horizontal retrace read
|
| 486 | | -------------------------------------------------*/
|
| 487 | | |
| 488 | | READ_LINE_DEVICE_HANDLER( upd3301_hrtc_r )
|
| 489 | | {
|
| 490 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 491 | | |
| 492 | | return upd3301->hrtc;
|
| 493 | | }
|
| 494 | | |
| 495 | | /*-------------------------------------------------
|
| 496 | | upd3301_vrtc_r - vertical retrace read
|
| 497 | | -------------------------------------------------*/
|
| 498 | | |
| 499 | | READ_LINE_DEVICE_HANDLER( upd3301_vrtc_r )
|
| 500 | | {
|
| 501 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 502 | | |
| 503 | | return upd3301->vrtc;
|
| 504 | | }
|
| 505 | | |
| 506 | | /*-------------------------------------------------
|
| 507 | | draw_row - draw character row
|
| 508 | | -------------------------------------------------*/
|
| 509 | | |
| 510 | | static void draw_row(const device_config *device, bitmap_t *bitmap)
|
| 511 | | {
|
| 512 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 513 | | int sx, lc;
|
| 514 | | |
| 515 | | for (lc = 0; lc < upd3301->r; lc++)
|
| 516 | | {
|
| 517 | | for (sx = 0; sx < upd3301->h; sx++)
|
| 518 | | {
|
| 519 | | int y = upd3301->y + lc;
|
| 520 | | UINT8 cc = upd3301->data_fifo[sx][!upd3301->input_fifo];
|
| 521 | | int hlgt = 0;
|
| 522 | | int rvv = 0;
|
| 523 | | int vsp = 0;
|
| 524 | | int sl0 = 0;
|
| 525 | | int sl12 = 0;
|
| 526 | | int csr = upd3301->cm && upd3301->cursor_blink && ((y / upd3301->r) == upd3301->cy) && (sx == upd3301->cx);
|
| 527 | | int gpa = 0;
|
| 528 | | |
| 529 | | upd3301->display_func(device, bitmap, y, sx, cc, lc, hlgt, rvv, vsp, sl0, sl12, csr, gpa);
|
| 530 | | }
|
| 531 | | }
|
| 532 | | |
| 533 | | upd3301->y += upd3301->r;
|
| 534 | | }
|
| 535 | | |
| 536 | | /*-------------------------------------------------
|
| 537 | | upd3301_dack_w - DMA acknowledge write
|
| 538 | | -------------------------------------------------*/
|
| 539 | | |
| 540 | | WRITE8_DEVICE_HANDLER( upd3301_dack_w )
|
| 541 | | {
|
| 542 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 543 | | |
| 544 | | if (upd3301->y >= (upd3301->l * upd3301->r))
|
| 545 | | {
|
| 546 | | return;
|
| 547 | | }
|
| 548 | | |
| 549 | | if (upd3301->data_fifo_pos < upd3301->h)
|
| 550 | | {
|
| 551 | | upd3301->data_fifo[upd3301->data_fifo_pos][upd3301->input_fifo] = data;
|
| 552 | | upd3301->data_fifo_pos++;
|
| 553 | | }
|
| 554 | | else
|
| 555 | | {
|
| 556 | | upd3301->attr_fifo[upd3301->attr_fifo_pos][upd3301->input_fifo] = data;
|
| 557 | | upd3301->attr_fifo_pos++;
|
| 558 | | }
|
| 559 | | |
| 560 | | if ((upd3301->data_fifo_pos == upd3301->h) && (upd3301->attr_fifo_pos == (upd3301->a << 1)))
|
| 561 | | {
|
| 562 | | upd3301->input_fifo = !upd3301->input_fifo;
|
| 563 | | upd3301->data_fifo_pos = 0;
|
| 564 | | upd3301->attr_fifo_pos = 0;
|
| 565 | | draw_row(device, upd3301->bitmap);
|
| 566 | | |
| 567 | | if (upd3301->y == (upd3301->l * upd3301->r))
|
| 568 | | {
|
| 569 | | /* end DMA transfer */
|
| 570 | | set_drq(device, 0);
|
| 571 | | }
|
| 572 | | }
|
| 573 | | }
|
| 574 | | |
| 575 | | /*-------------------------------------------------
|
| 576 | | upd3301_update - screen update
|
| 577 | | -------------------------------------------------*/
|
| 578 | | |
| 579 | | void upd3301_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
|
| 580 | | {
|
| 581 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 582 | | |
| 583 | | if (upd3301->status & UPD3301_STATUS_VE)
|
| 584 | | {
|
| 585 | | upd3301->y = 0;
|
| 586 | | upd3301->bitmap = bitmap;
|
| 587 | | upd3301->data_fifo_pos = 0;
|
| 588 | | upd3301->attr_fifo_pos = 0;
|
| 589 | | |
| 590 | | upd3301->cursor_frame++;
|
| 591 | | |
| 592 | | if (upd3301->cursor_frame == upd3301->b)
|
| 593 | | {
|
| 594 | | upd3301->cursor_frame = 0;
|
| 595 | | upd3301->cursor_blink = !upd3301->cursor_blink;
|
| 596 | | }
|
| 597 | | |
| 598 | | upd3301->attr_frame++;
|
| 599 | | |
| 600 | | if (upd3301->attr_frame == (upd3301->b << 1))
|
| 601 | | {
|
| 602 | | upd3301->attr_frame = 0;
|
| 603 | | upd3301->attr_blink = !upd3301->attr_blink;
|
| 604 | | }
|
| 605 | | |
| 606 | | /* start DMA transfer */
|
| 607 | | set_drq(device, 1);
|
| 608 | | }
|
| 609 | | else
|
| 610 | | {
|
| 611 | | bitmap_fill(bitmap, cliprect, get_black_pen(device->machine));
|
| 612 | | }
|
| 613 | | }
|
| 614 | | |
| 615 | | /*-------------------------------------------------
|
| 616 | | DEVICE_START( upd3301 )
|
| 617 | | -------------------------------------------------*/
|
| 618 | | |
| 619 | | static DEVICE_START( upd3301 )
|
| 620 | | {
|
| 621 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 622 | | const upd3301_interface *intf = get_interface(device);
|
| 623 | | |
| 624 | | /* resolve callbacks */
|
| 625 | | devcb_resolve_write_line(&upd3301->out_int_func, &intf->out_int_func, device);
|
| 626 | | devcb_resolve_write_line(&upd3301->out_drq_func, &intf->out_drq_func, device);
|
| 627 | | devcb_resolve_write_line(&upd3301->out_hrtc_func, &intf->out_hrtc_func, device);
|
| 628 | | devcb_resolve_write_line(&upd3301->out_vrtc_func, &intf->out_vrtc_func, device);
|
| 629 | | |
| 630 | | /* get the screen device */
|
| 631 | | upd3301->screen = devtag_get_device(device->machine, intf->screen_tag);
|
| 632 | | assert(upd3301->screen != NULL);
|
| 633 | | |
| 634 | | /* get character width */
|
| 635 | | upd3301->display_func = intf->display_func;
|
| 636 | | upd3301->width = intf->width;
|
| 637 | | |
| 638 | | /* create the timers */
|
| 639 | | upd3301->vrtc_timer = timer_alloc(device->machine, vrtc_tick, (void *)device);
|
| 640 | | upd3301->hrtc_timer = timer_alloc(device->machine, hrtc_tick, (void *)device);
|
| 641 | | |
| 642 | | /* register for state saving */
|
| 643 | | // state_save_register_device_item(device, 0, upd3301->);
|
| 644 | | }
|
| 645 | | |
| 646 | | /*-------------------------------------------------
|
| 647 | | DEVICE_RESET( upd3301 )
|
| 648 | | -------------------------------------------------*/
|
| 649 | | |
| 650 | | static DEVICE_RESET( upd3301 )
|
| 651 | | {
|
| 652 | | upd3301_t *upd3301 = get_safe_token(device);
|
| 653 | | |
| 654 | | /* set some initial values so PC8001 will boot */
|
| 655 | | upd3301->h = 80;
|
| 656 | | upd3301->l = 20;
|
| 657 | | upd3301->r = 10;
|
| 658 | | upd3301->v = 6;
|
| 659 | | upd3301->z = 32;
|
| 660 | | upd3301->status = 0;
|
| 661 | | |
| 662 | | set_interrupt(device, 0);
|
| 663 | | set_drq(device, 0);
|
| 664 | | |
| 665 | | recompute_parameters(device);
|
| 666 | | }
|
| 667 | | |
| 668 | | /*-------------------------------------------------
|
| 669 | | DEVICE_GET_INFO( upd3301 )
|
| 670 | | -------------------------------------------------*/
|
| 671 | | |
| 672 | | DEVICE_GET_INFO( upd3301 )
|
| 673 | | {
|
| 674 | | switch (state)
|
| 675 | | {
|
| 676 | | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 677 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(upd3301_t); break;
|
| 678 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
|
| 679 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
|
| 680 | | |
| 681 | | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 682 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(upd3301); break;
|
| 683 | | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 684 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(upd3301); break;
|
| 685 | | |
| 686 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 687 | | case DEVINFO_STR_NAME: strcpy(info->s, "NEC uPD3301"); break;
|
| 688 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "NEC uPD3301"); break;
|
| 689 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
| 690 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
| 691 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break;
|
| 692 | | }
|
| 693 | | }
|
| 1 | /********************************************************************** |
| 2 | |
| 3 | NEC uPD3301 Programmable CRT Controller emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | TODO: |
| 13 | |
| 14 | - attributes |
| 15 | - N interrupt |
| 16 | - light pen |
| 17 | - reset counters |
| 18 | - proper DMA timing (now the whole screen is transferred at the end of the frame, |
| 19 | accurate timing requires CCLK timer which kills performance) |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #include "driver.h" |
| 24 | #include "upd3301.h" |
| 25 | |
| 26 | /*************************************************************************** |
| 27 | PARAMETERS |
| 28 | ***************************************************************************/ |
| 29 | |
| 30 | #define LOG 0 |
| 31 | |
| 32 | #define UPD3301_COMMAND_MASK 0xe0 |
| 33 | #define UPD3301_COMMAND_RESET 0x00 |
| 34 | #define UPD3301_COMMAND_START_DISPLAY 0x20 |
| 35 | #define UPD3301_COMMAND_SET_INTERRUPT_MASK 0x40 |
| 36 | #define UPD3301_COMMAND_READ_LIGHT_PEN 0x60 /* not supported */ |
| 37 | #define UPD3301_COMMAND_LOAD_CURSOR_POSITION 0x80 |
| 38 | #define UPD3301_COMMAND_RESET_INTERRUPT 0xa0 |
| 39 | #define UPD3301_COMMAND_RESET_COUNTERS 0xc0 /* not supported */ |
| 40 | |
| 41 | #define UPD3301_STATUS_VE 0x10 |
| 42 | #define UPD3301_STATUS_U 0x08 /* not supported */ |
| 43 | #define UPD3301_STATUS_N 0x04 /* not supported */ |
| 44 | #define UPD3301_STATUS_E 0x02 |
| 45 | #define UPD3301_STATUS_LP 0x01 /* not supported */ |
| 46 | |
| 47 | enum |
| 48 | { |
| 49 | MODE_NONE, |
| 50 | MODE_RESET, |
| 51 | MODE_READ_LIGHT_PEN, |
| 52 | MODE_LOAD_CURSOR_POSITION, |
| 53 | MODE_RESET_COUNTERS |
| 54 | }; |
| 55 | |
| 56 | /*************************************************************************** |
| 57 | TYPE DEFINITIONS |
| 58 | ***************************************************************************/ |
| 59 | |
| 60 | typedef struct _upd3301_t upd3301_t; |
| 61 | struct _upd3301_t |
| 62 | { |
| 63 | /* callbacks */ |
| 64 | devcb_resolved_write_line out_int_func; |
| 65 | devcb_resolved_write_line out_drq_func; |
| 66 | devcb_resolved_write_line out_hrtc_func; |
| 67 | devcb_resolved_write_line out_vrtc_func; |
| 68 | upd3301_display_pixels_func display_func; |
| 69 | |
| 70 | /* screen drawing */ |
| 71 | const device_config *screen; /* screen */ |
| 72 | bitmap_t *bitmap; /* bitmap */ |
| 73 | int y; /* current scanline */ |
| 74 | int hrtc; /* horizontal retrace */ |
| 75 | int vrtc; /* vertical retrace */ |
| 76 | |
| 77 | /* live state */ |
| 78 | int mode; /* command mode */ |
| 79 | UINT8 status; /* status register */ |
| 80 | int param_count; /* parameter count */ |
| 81 | |
| 82 | /* FIFOs */ |
| 83 | UINT8 data_fifo[80][2]; /* row data FIFO */ |
| 84 | UINT8 attr_fifo[40][2]; /* attribute FIFO */ |
| 85 | int data_fifo_pos; /* row data FIFO position */ |
| 86 | int attr_fifo_pos; /* attribute FIFO position */ |
| 87 | int input_fifo; /* which FIFO is in input mode */ |
| 88 | |
| 89 | /* interrupts */ |
| 90 | int mn; /* disable special character interrupt */ |
| 91 | int me; /* disable end of screen interrupt */ |
| 92 | int dma_mode; /* DMA mode */ |
| 93 | |
| 94 | /* screen geometry */ |
| 95 | int width; /* character width */ |
| 96 | int h; /* characters per line */ |
| 97 | int b; /* cursor blink time */ |
| 98 | int l; /* lines per screen */ |
| 99 | int s; /* display every other line */ |
| 100 | int c; /* cursor mode */ |
| 101 | int r; /* lines per character */ |
| 102 | int v; /* vertical blanking height */ |
| 103 | int z; /* horizontal blanking width */ |
| 104 | |
| 105 | /* attributes */ |
| 106 | int at1; /* */ |
| 107 | int at0; /* */ |
| 108 | int sc; /* */ |
| 109 | int a; /* attributes per row */ |
| 110 | int attr_blink; /* attribute blink */ |
| 111 | int attr_frame; /* attribute blink frame counter */ |
| 112 | |
| 113 | /* cursor */ |
| 114 | int cm; /* cursor visible */ |
| 115 | int cx; /* cursor column */ |
| 116 | int cy; /* cursor row */ |
| 117 | int cursor_blink; /* cursor blink */ |
| 118 | int cursor_frame; /* cursor blink frame counter */ |
| 119 | |
| 120 | /* timers */ |
| 121 | emu_timer *vrtc_timer; /* vertical sync timer */ |
| 122 | emu_timer *hrtc_timer; /* horizontal sync timer */ |
| 123 | }; |
| 124 | |
| 125 | /*************************************************************************** |
| 126 | INLINE FUNCTIONS |
| 127 | ***************************************************************************/ |
| 128 | |
| 129 | INLINE upd3301_t *get_safe_token(const device_config *device) |
| 130 | { |
| 131 | assert(device != NULL); |
| 132 | assert(device->token != NULL); |
| 133 | assert((device->type == UPD3301)); |
| 134 | return (upd3301_t *)device->token; |
| 135 | } |
| 136 | |
| 137 | INLINE const upd3301_interface *get_interface(const device_config *device) |
| 138 | { |
| 139 | assert(device != NULL); |
| 140 | assert((device->type == UPD3301)); |
| 141 | return (const upd3301_interface *) device->static_config; |
| 142 | } |
| 143 | |
| 144 | /*************************************************************************** |
| 145 | IMPLEMENTATION |
| 146 | ***************************************************************************/ |
| 147 | |
| 148 | /*------------------------------------------------- |
| 149 | set_interrupt - set interrupt line state |
| 150 | -------------------------------------------------*/ |
| 151 | |
| 152 | static void set_interrupt(const device_config *device, int state) |
| 153 | { |
| 154 | upd3301_t *upd3301 = get_safe_token(device); |
| 155 | |
| 156 | if (LOG) logerror("UPD3301 '%s' Interrupt: %u\n", device->tag, state); |
| 157 | |
| 158 | devcb_call_write_line(&upd3301->out_int_func, state); |
| 159 | |
| 160 | if (!state) |
| 161 | { |
| 162 | upd3301->status &= ~(UPD3301_STATUS_N | UPD3301_STATUS_E); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /*------------------------------------------------- |
| 167 | set_drq - set data request line state |
| 168 | -------------------------------------------------*/ |
| 169 | |
| 170 | static void set_drq(const device_config *device, int state) |
| 171 | { |
| 172 | upd3301_t *upd3301 = get_safe_token(device); |
| 173 | |
| 174 | if (LOG) logerror("UPD3301 '%s' DRQ: %u\n", device->tag, state); |
| 175 | |
| 176 | devcb_call_write_line(&upd3301->out_drq_func, state); |
| 177 | } |
| 178 | |
| 179 | /*------------------------------------------------- |
| 180 | set_display - set display state |
| 181 | -------------------------------------------------*/ |
| 182 | |
| 183 | static void set_display(const device_config *device, int state) |
| 184 | { |
| 185 | upd3301_t *upd3301 = get_safe_token(device); |
| 186 | |
| 187 | if (state) |
| 188 | { |
| 189 | upd3301->status |= UPD3301_STATUS_VE; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | upd3301->status &= ~UPD3301_STATUS_VE; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /*------------------------------------------------- |
| 198 | reset_counters - reset screen counters |
| 199 | -------------------------------------------------*/ |
| 200 | |
| 201 | static void reset_counters(const device_config *device) |
| 202 | { |
| 203 | set_interrupt(device, 0); |
| 204 | set_drq(device, 0); |
| 205 | } |
| 206 | |
| 207 | /*------------------------------------------------- |
| 208 | update_hrtc_timer - update horizontal retrace |
| 209 | timer |
| 210 | -------------------------------------------------*/ |
| 211 | |
| 212 | static void update_hrtc_timer(upd3301_t *upd3301, int state) |
| 213 | { |
| 214 | int y = video_screen_get_vpos(upd3301->screen); |
| 215 | |
| 216 | int next_x = state ? upd3301->h : 0; |
| 217 | int next_y = state ? y : ((y + 1) % ((upd3301->l + upd3301->v) * upd3301->width)); |
| 218 | |
| 219 | attotime duration = video_screen_get_time_until_pos(upd3301->screen, next_y, next_x); |
| 220 | |
| 221 | timer_adjust_oneshot(upd3301->hrtc_timer, duration, !state); |
| 222 | } |
| 223 | |
| 224 | /*------------------------------------------------- |
| 225 | update_vrtc_timer - update vertical retrace |
| 226 | timer |
| 227 | -------------------------------------------------*/ |
| 228 | |
| 229 | static void update_vrtc_timer(upd3301_t *upd3301, int state) |
| 230 | { |
| 231 | int next_y = state ? (upd3301->l * upd3301->r) : 0; |
| 232 | |
| 233 | attotime duration = video_screen_get_time_until_pos(upd3301->screen, next_y, 0); |
| 234 | |
| 235 | timer_adjust_oneshot(upd3301->vrtc_timer, duration, !state); |
| 236 | } |
| 237 | |
| 238 | /*------------------------------------------------- |
| 239 | recompute_parameters - recompute screen |
| 240 | geometry parameters |
| 241 | -------------------------------------------------*/ |
| 242 | |
| 243 | static void recompute_parameters(const device_config *device) |
| 244 | { |
| 245 | upd3301_t *upd3301 = get_safe_token(device); |
| 246 | |
| 247 | int horiz_pix_total = (upd3301->h + upd3301->z) * upd3301->width; |
| 248 | int vert_pix_total = (upd3301->l + upd3301->v) * upd3301->r; |
| 249 | |
| 250 | attoseconds_t refresh = HZ_TO_ATTOSECONDS(device->clock) * horiz_pix_total * vert_pix_total; |
| 251 | |
| 252 | rectangle visarea; |
| 253 | |
| 254 | visarea.min_x = 0; |
| 255 | visarea.min_y = 0; |
| 256 | visarea.max_x = (upd3301->h * upd3301->width) - 1; |
| 257 | visarea.max_y = (upd3301->l * upd3301->r) - 1; |
| 258 | |
| 259 | if (LOG) |
| 260 | { |
| 261 | if (LOG) logerror("UPD3301 '%s' Screen: %u x %u @ %f Hz\n", device->tag, horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 262 | if (LOG) logerror("UPD3301 '%s' Visible Area: (%u, %u) - (%u, %u)\n", device->tag, visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y); |
| 263 | } |
| 264 | |
| 265 | video_screen_configure(upd3301->screen, horiz_pix_total, vert_pix_total, &visarea, refresh); |
| 266 | |
| 267 | update_hrtc_timer(upd3301, 0); |
| 268 | update_vrtc_timer(upd3301, 0); |
| 269 | } |
| 270 | |
| 271 | /*------------------------------------------------- |
| 272 | TIMER_CALLBACK( vrtc_tick ) |
| 273 | -------------------------------------------------*/ |
| 274 | |
| 275 | static TIMER_CALLBACK( vrtc_tick ) |
| 276 | { |
| 277 | const device_config *device = ptr; |
| 278 | upd3301_t *upd3301 = get_safe_token(device); |
| 279 | |
| 280 | //if (LOG) logerror("UPD3301 '%s' VRTC: %u\n", device->tag, param); |
| 281 | |
| 282 | devcb_call_write_line(&upd3301->out_vrtc_func, param); |
| 283 | upd3301->vrtc = param; |
| 284 | |
| 285 | if (param && !upd3301->me) |
| 286 | { |
| 287 | upd3301->status |= UPD3301_STATUS_E; |
| 288 | set_interrupt(device, 1); |
| 289 | } |
| 290 | |
| 291 | update_vrtc_timer(upd3301, param); |
| 292 | } |
| 293 | |
| 294 | /*------------------------------------------------- |
| 295 | TIMER_CALLBACK( hrtc_tick ) |
| 296 | -------------------------------------------------*/ |
| 297 | |
| 298 | static TIMER_CALLBACK( hrtc_tick ) |
| 299 | { |
| 300 | const device_config *device = ptr; |
| 301 | upd3301_t *upd3301 = get_safe_token(device); |
| 302 | |
| 303 | //if (LOG) logerror("UPD3301 '%s' HRTC: %u\n", device->tag, param); |
| 304 | |
| 305 | devcb_call_write_line(&upd3301->out_hrtc_func, param); |
| 306 | upd3301->hrtc = param; |
| 307 | |
| 308 | update_hrtc_timer(upd3301, param); |
| 309 | } |
| 310 | |
| 311 | /*------------------------------------------------- |
| 312 | upd3301_r - register read |
| 313 | -------------------------------------------------*/ |
| 314 | |
| 315 | READ8_DEVICE_HANDLER( upd3301_r ) |
| 316 | { |
| 317 | upd3301_t *upd3301 = get_safe_token(device); |
| 318 | UINT8 data = 0; |
| 319 | |
| 320 | switch (offset & 0x01) |
| 321 | { |
| 322 | case 0: /* data */ |
| 323 | break; |
| 324 | |
| 325 | case 1: /* status */ |
| 326 | data = upd3301->status; |
| 327 | upd3301->status &= ~(UPD3301_STATUS_LP | UPD3301_STATUS_E |UPD3301_STATUS_N | UPD3301_STATUS_U); |
| 328 | break; |
| 329 | } |
| 330 | |
| 331 | return data; |
| 332 | } |
| 333 | |
| 334 | /*------------------------------------------------- |
| 335 | upd3301_w - register write |
| 336 | -------------------------------------------------*/ |
| 337 | |
| 338 | WRITE8_DEVICE_HANDLER( upd3301_w ) |
| 339 | { |
| 340 | upd3301_t *upd3301 = get_safe_token(device); |
| 341 | |
| 342 | switch (offset & 0x01) |
| 343 | { |
| 344 | case 0: /* data */ |
| 345 | switch (upd3301->mode) |
| 346 | { |
| 347 | case MODE_RESET: |
| 348 | switch (upd3301->param_count) |
| 349 | { |
| 350 | case 0: |
| 351 | upd3301->dma_mode = BIT(data, 7); |
| 352 | upd3301->h = (data & 0x7f) + 2; |
| 353 | if (LOG) logerror("UPD3301 '%s' DMA Mode: %s\n", device->tag, upd3301->dma_mode ? "character" : "burst"); |
| 354 | if (LOG) logerror("UPD3301 '%s' H: %u\n", device->tag, upd3301->h); |
| 355 | break; |
| 356 | |
| 357 | case 1: |
| 358 | upd3301->b = ((data >> 6) + 1) * 16; |
| 359 | upd3301->l = (data & 0x3f) + 1; |
| 360 | if (LOG) logerror("UPD3301 '%s' B: %u\n", device->tag, upd3301->b); |
| 361 | if (LOG) logerror("UPD3301 '%s' L: %u\n", device->tag, upd3301->l); |
| 362 | break; |
| 363 | |
| 364 | case 2: |
| 365 | upd3301->s = BIT(data, 7); |
| 366 | upd3301->c = (data >> 4) & 0x03; |
| 367 | upd3301->r = (data & 0x1f) + 1; |
| 368 | if (LOG) logerror("UPD3301 '%s' S: %u\n", device->tag, upd3301->s); |
| 369 | if (LOG) logerror("UPD3301 '%s' C: %u\n", device->tag, upd3301->c); |
| 370 | if (LOG) logerror("UPD3301 '%s' R: %u\n", device->tag, upd3301->r); |
| 371 | break; |
| 372 | |
| 373 | case 3: |
| 374 | upd3301->v = (data >> 5) + 1; |
| 375 | upd3301->z = (data & 0x1f) + 2; |
| 376 | if (LOG) logerror("UPD3301 '%s' V: %u\n", device->tag, upd3301->v); |
| 377 | if (LOG) logerror("UPD3301 '%s' Z: %u\n", device->tag, upd3301->z); |
| 378 | recompute_parameters(device); |
| 379 | break; |
| 380 | |
| 381 | case 4: |
| 382 | upd3301->at1 = BIT(data, 7); |
| 383 | upd3301->at0 = BIT(data, 6); |
| 384 | upd3301->sc = BIT(data, 5); |
| 385 | upd3301->a = (data & 0x1f) + 1; |
| 386 | if (LOG) logerror("UPD3301 '%s' AT1: %u\n", device->tag, upd3301->at1); |
| 387 | if (LOG) logerror("UPD3301 '%s' AT0: %u\n", device->tag, upd3301->at0); |
| 388 | if (LOG) logerror("UPD3301 '%s' SC: %u\n", device->tag, upd3301->sc); |
| 389 | if (LOG) logerror("UPD3301 '%s' A: %u\n", device->tag, upd3301->a); |
| 390 | |
| 391 | upd3301->mode = MODE_NONE; |
| 392 | break; |
| 393 | } |
| 394 | |
| 395 | upd3301->param_count++; |
| 396 | break; |
| 397 | |
| 398 | case MODE_LOAD_CURSOR_POSITION: |
| 399 | switch (upd3301->param_count) |
| 400 | { |
| 401 | case 0: |
| 402 | upd3301->cx = data & 0x7f; |
| 403 | if (LOG) logerror("UPD3301 '%s' CX: %u\n", device->tag, upd3301->cx); |
| 404 | break; |
| 405 | |
| 406 | case 1: |
| 407 | upd3301->cy = data & 0x3f; |
| 408 | if (LOG) logerror("UPD3301 '%s' CY: %u\n", device->tag, upd3301->cy); |
| 409 | |
| 410 | upd3301->mode = MODE_NONE; |
| 411 | break; |
| 412 | } |
| 413 | |
| 414 | upd3301->param_count++; |
| 415 | break; |
| 416 | |
| 417 | default: |
| 418 | if (LOG) logerror("UPD3301 '%s' Invalid Parameter Byte %02x!\n", device->tag, data); |
| 419 | } |
| 420 | break; |
| 421 | |
| 422 | case 1: /* command */ |
| 423 | upd3301->mode = MODE_NONE; |
| 424 | upd3301->param_count = 0; |
| 425 | |
| 426 | switch (data & 0xe0) |
| 427 | { |
| 428 | case UPD3301_COMMAND_RESET: |
| 429 | if (LOG) logerror("UPD3301 '%s' Reset\n", device->tag); |
| 430 | upd3301->mode = MODE_RESET; |
| 431 | set_display(device, 0); |
| 432 | set_interrupt(device, 0); |
| 433 | break; |
| 434 | |
| 435 | case UPD3301_COMMAND_START_DISPLAY: |
| 436 | if (LOG) logerror("UPD3301 '%s' Start Display\n", device->tag); |
| 437 | set_display(device, 1); |
| 438 | reset_counters(device); |
| 439 | break; |
| 440 | |
| 441 | case UPD3301_COMMAND_SET_INTERRUPT_MASK: |
| 442 | if (LOG) logerror("UPD3301 '%s' Set Interrupt Mask\n", device->tag); |
| 443 | upd3301->me = BIT(data, 0); |
| 444 | upd3301->mn = BIT(data, 1); |
| 445 | if (LOG) logerror("UPD3301 '%s' ME: %u\n", device->tag, upd3301->me); |
| 446 | if (LOG) logerror("UPD3301 '%s' MN: %u\n", device->tag, upd3301->mn); |
| 447 | break; |
| 448 | |
| 449 | case UPD3301_COMMAND_READ_LIGHT_PEN: |
| 450 | if (LOG) logerror("UPD3301 '%s' Read Light Pen\n", device->tag); |
| 451 | upd3301->mode = MODE_READ_LIGHT_PEN; |
| 452 | break; |
| 453 | |
| 454 | case UPD3301_COMMAND_LOAD_CURSOR_POSITION: |
| 455 | if (LOG) logerror("UPD3301 '%s' Load Cursor Position\n", device->tag); |
| 456 | upd3301->mode = MODE_LOAD_CURSOR_POSITION; |
| 457 | upd3301->cm = BIT(data, 0); |
| 458 | if (LOG) logerror("UPD3301 '%s' CM: %u\n", device->tag, upd3301->cm); |
| 459 | break; |
| 460 | |
| 461 | case UPD3301_COMMAND_RESET_INTERRUPT: |
| 462 | if (LOG) logerror("UPD3301 '%s' Reset Interrupt\n", device->tag); |
| 463 | set_interrupt(device, 0); |
| 464 | break; |
| 465 | |
| 466 | case UPD3301_COMMAND_RESET_COUNTERS: |
| 467 | if (LOG) logerror("UPD3301 '%s' Reset Counters\n", device->tag); |
| 468 | upd3301->mode = MODE_RESET_COUNTERS; |
| 469 | reset_counters(device); |
| 470 | break; |
| 471 | } |
| 472 | break; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | /*------------------------------------------------- |
| 477 | upd3301_lpen_w - light pen write |
| 478 | -------------------------------------------------*/ |
| 479 | |
| 480 | WRITE_LINE_DEVICE_HANDLER( upd3301_lpen_w ) |
| 481 | { |
| 482 | } |
| 483 | |
| 484 | /*------------------------------------------------- |
| 485 | upd3301_hrtc_r - horizontal retrace read |
| 486 | -------------------------------------------------*/ |
| 487 | |
| 488 | READ_LINE_DEVICE_HANDLER( upd3301_hrtc_r ) |
| 489 | { |
| 490 | upd3301_t *upd3301 = get_safe_token(device); |
| 491 | |
| 492 | return upd3301->hrtc; |
| 493 | } |
| 494 | |
| 495 | /*------------------------------------------------- |
| 496 | upd3301_vrtc_r - vertical retrace read |
| 497 | -------------------------------------------------*/ |
| 498 | |
| 499 | READ_LINE_DEVICE_HANDLER( upd3301_vrtc_r ) |
| 500 | { |
| 501 | upd3301_t *upd3301 = get_safe_token(device); |
| 502 | |
| 503 | return upd3301->vrtc; |
| 504 | } |
| 505 | |
| 506 | /*------------------------------------------------- |
| 507 | draw_row - draw character row |
| 508 | -------------------------------------------------*/ |
| 509 | |
| 510 | static void draw_row(const device_config *device, bitmap_t *bitmap) |
| 511 | { |
| 512 | upd3301_t *upd3301 = get_safe_token(device); |
| 513 | int sx, lc; |
| 514 | |
| 515 | for (lc = 0; lc < upd3301->r; lc++) |
| 516 | { |
| 517 | for (sx = 0; sx < upd3301->h; sx++) |
| 518 | { |
| 519 | int y = upd3301->y + lc; |
| 520 | UINT8 cc = upd3301->data_fifo[sx][!upd3301->input_fifo]; |
| 521 | int hlgt = 0; |
| 522 | int rvv = 0; |
| 523 | int vsp = 0; |
| 524 | int sl0 = 0; |
| 525 | int sl12 = 0; |
| 526 | int csr = upd3301->cm && upd3301->cursor_blink && ((y / upd3301->r) == upd3301->cy) && (sx == upd3301->cx); |
| 527 | int gpa = 0; |
| 528 | |
| 529 | upd3301->display_func(device, bitmap, y, sx, cc, lc, hlgt, rvv, vsp, sl0, sl12, csr, gpa); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | upd3301->y += upd3301->r; |
| 534 | } |
| 535 | |
| 536 | /*------------------------------------------------- |
| 537 | upd3301_dack_w - DMA acknowledge write |
| 538 | -------------------------------------------------*/ |
| 539 | |
| 540 | WRITE8_DEVICE_HANDLER( upd3301_dack_w ) |
| 541 | { |
| 542 | upd3301_t *upd3301 = get_safe_token(device); |
| 543 | |
| 544 | if (upd3301->y >= (upd3301->l * upd3301->r)) |
| 545 | { |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | if (upd3301->data_fifo_pos < upd3301->h) |
| 550 | { |
| 551 | upd3301->data_fifo[upd3301->data_fifo_pos][upd3301->input_fifo] = data; |
| 552 | upd3301->data_fifo_pos++; |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | upd3301->attr_fifo[upd3301->attr_fifo_pos][upd3301->input_fifo] = data; |
| 557 | upd3301->attr_fifo_pos++; |
| 558 | } |
| 559 | |
| 560 | if ((upd3301->data_fifo_pos == upd3301->h) && (upd3301->attr_fifo_pos == (upd3301->a << 1))) |
| 561 | { |
| 562 | upd3301->input_fifo = !upd3301->input_fifo; |
| 563 | upd3301->data_fifo_pos = 0; |
| 564 | upd3301->attr_fifo_pos = 0; |
| 565 | draw_row(device, upd3301->bitmap); |
| 566 | |
| 567 | if (upd3301->y == (upd3301->l * upd3301->r)) |
| 568 | { |
| 569 | /* end DMA transfer */ |
| 570 | set_drq(device, 0); |
| 571 | } |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | /*------------------------------------------------- |
| 576 | upd3301_update - screen update |
| 577 | -------------------------------------------------*/ |
| 578 | |
| 579 | void upd3301_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 580 | { |
| 581 | upd3301_t *upd3301 = get_safe_token(device); |
| 582 | |
| 583 | if (upd3301->status & UPD3301_STATUS_VE) |
| 584 | { |
| 585 | upd3301->y = 0; |
| 586 | upd3301->bitmap = bitmap; |
| 587 | upd3301->data_fifo_pos = 0; |
| 588 | upd3301->attr_fifo_pos = 0; |
| 589 | |
| 590 | upd3301->cursor_frame++; |
| 591 | |
| 592 | if (upd3301->cursor_frame == upd3301->b) |
| 593 | { |
| 594 | upd3301->cursor_frame = 0; |
| 595 | upd3301->cursor_blink = !upd3301->cursor_blink; |
| 596 | } |
| 597 | |
| 598 | upd3301->attr_frame++; |
| 599 | |
| 600 | if (upd3301->attr_frame == (upd3301->b << 1)) |
| 601 | { |
| 602 | upd3301->attr_frame = 0; |
| 603 | upd3301->attr_blink = !upd3301->attr_blink; |
| 604 | } |
| 605 | |
| 606 | /* start DMA transfer */ |
| 607 | set_drq(device, 1); |
| 608 | } |
| 609 | else |
| 610 | { |
| 611 | bitmap_fill(bitmap, cliprect, get_black_pen(device->machine)); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | /*------------------------------------------------- |
| 616 | DEVICE_START( upd3301 ) |
| 617 | -------------------------------------------------*/ |
| 618 | |
| 619 | static DEVICE_START( upd3301 ) |
| 620 | { |
| 621 | upd3301_t *upd3301 = get_safe_token(device); |
| 622 | const upd3301_interface *intf = get_interface(device); |
| 623 | |
| 624 | /* resolve callbacks */ |
| 625 | devcb_resolve_write_line(&upd3301->out_int_func, &intf->out_int_func, device); |
| 626 | devcb_resolve_write_line(&upd3301->out_drq_func, &intf->out_drq_func, device); |
| 627 | devcb_resolve_write_line(&upd3301->out_hrtc_func, &intf->out_hrtc_func, device); |
| 628 | devcb_resolve_write_line(&upd3301->out_vrtc_func, &intf->out_vrtc_func, device); |
| 629 | |
| 630 | /* get the screen device */ |
| 631 | upd3301->screen = devtag_get_device(device->machine, intf->screen_tag); |
| 632 | assert(upd3301->screen != NULL); |
| 633 | |
| 634 | /* get character width */ |
| 635 | upd3301->display_func = intf->display_func; |
| 636 | upd3301->width = intf->width; |
| 637 | |
| 638 | /* create the timers */ |
| 639 | upd3301->vrtc_timer = timer_alloc(device->machine, vrtc_tick, (void *)device); |
| 640 | upd3301->hrtc_timer = timer_alloc(device->machine, hrtc_tick, (void *)device); |
| 641 | |
| 642 | /* register for state saving */ |
| 643 | // state_save_register_device_item(device, 0, upd3301->); |
| 644 | } |
| 645 | |
| 646 | /*------------------------------------------------- |
| 647 | DEVICE_RESET( upd3301 ) |
| 648 | -------------------------------------------------*/ |
| 649 | |
| 650 | static DEVICE_RESET( upd3301 ) |
| 651 | { |
| 652 | upd3301_t *upd3301 = get_safe_token(device); |
| 653 | |
| 654 | /* set some initial values so PC8001 will boot */ |
| 655 | upd3301->h = 80; |
| 656 | upd3301->l = 20; |
| 657 | upd3301->r = 10; |
| 658 | upd3301->v = 6; |
| 659 | upd3301->z = 32; |
| 660 | upd3301->status = 0; |
| 661 | |
| 662 | set_interrupt(device, 0); |
| 663 | set_drq(device, 0); |
| 664 | |
| 665 | recompute_parameters(device); |
| 666 | } |
| 667 | |
| 668 | /*------------------------------------------------- |
| 669 | DEVICE_GET_INFO( upd3301 ) |
| 670 | -------------------------------------------------*/ |
| 671 | |
| 672 | DEVICE_GET_INFO( upd3301 ) |
| 673 | { |
| 674 | switch (state) |
| 675 | { |
| 676 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 677 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(upd3301_t); break; |
| 678 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 679 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 680 | |
| 681 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 682 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(upd3301); break; |
| 683 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 684 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(upd3301); break; |
| 685 | |
| 686 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 687 | case DEVINFO_STR_NAME: strcpy(info->s, "NEC uPD3301"); break; |
| 688 | case DEVINFO_STR_FAMILY: strcpy(info->s, "NEC uPD3301"); break; |
| 689 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 690 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 691 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 692 | } |
| 693 | } |
src/mess/video/rmnimbus.c
| r6857 | r6858 | |
| 1 | | /*
|
| 2 | | video/rmnimbus.c
|
| 3 | | |
| 4 | | Research machines Nimbus.
|
| 5 | | |
| 6 | | 2009-11-14, P.Harvey-Smith.
|
| 7 | | |
| 8 | | This is my best guess implementation of the operation of the Nimbus |
| 9 | | video system.
|
| 10 | | |
| 11 | | On the real machine, the Video chip has a block of 64K of memory which is
|
| 12 | | completely seperate from the main 80186 memory. |
| 13 | | |
| 14 | | The main CPU write to the video chip via a series of registers in the |
| 15 | | 0x0000 to 0x002F reigon, the video chip then manages all video memory |
| 16 | | from there.
|
| 17 | | |
| 18 | | As I cannot find a datasheet for the vide chip marked |
| 19 | | MB61H201 Fujitsu RML 12835 GCV, I have had to determine most of its
|
| 20 | | operation by disassembling the Nimbus bios and by writing experemental
|
| 21 | | code on the real machine. |
| 22 | | */
|
| 23 | | |
| 24 | | #include "driver.h"
|
| 25 | | #include "video/border.h"
|
| 26 | | #include "memory.h"
|
| 27 | | #include "debug/debugcpu.h"
|
| 28 | | #include "debug/debugcon.h"
|
| 29 | | #include "includes/rmnimbus.h"
|
| 30 | | #include "mame.h"
|
| 31 | | |
| 32 | | #include "debug/debugcpu.h"
|
| 33 | | #include "debug/debugcon.h"
|
| 34 | | |
| 35 | | UINT8 video_mem[SCREEN_WIDTH_PIXELS][SCREEN_HEIGHT_LINES];
|
| 36 | | |
| 37 | | #define WIDTH_MASK 0x07
|
| 38 | | #define XOR_MASK 0x08
|
| 39 | | #define MASK_4080 0x10
|
| 40 | | |
| 41 | | // Offsets of nimbus video registers within register array
|
| 42 | | |
| 43 | | #define NO_VIDREGS (0x30/2)
|
| 44 | | #define reg000 0x00
|
| 45 | | #define reg002 0x01
|
| 46 | | #define reg004 0x02
|
| 47 | | #define reg006 0x03
|
| 48 | | #define reg008 0x04
|
| 49 | | #define reg00A 0x05
|
| 50 | | #define reg00C 0x06
|
| 51 | | #define reg00E 0x07
|
| 52 | | #define reg010 0x08
|
| 53 | | #define reg012 0x09
|
| 54 | | #define reg014 0x0A
|
| 55 | | #define reg016 0x0B
|
| 56 | | #define reg018 0x0C
|
| 57 | | #define reg01A 0x0D
|
| 58 | | #define reg01C 0x0E
|
| 59 | | #define reg01E 0x0F
|
| 60 | | #define reg020 0x10
|
| 61 | | #define reg022 0x11 |
| 62 | | #define reg024 0x12
|
| 63 | | #define reg026 0x13
|
| 64 | | #define reg028 0x14
|
| 65 | | #define reg02A 0x15
|
| 66 | | #define reg02C 0x16
|
| 67 | | #define reg02E 0x17
|
| 68 | | |
| 69 | | #define FG_COLOUR (vidregs[reg024]&0x0F)
|
| 70 | | #define BG_COLOUR ((vidregs[reg024]&0xF0)>>4)
|
| 71 | | |
| 72 | | #define IS_80COL (vidregs[reg026]&MASK_4080)
|
| 73 | | #define IS_XOR (vidregs[reg022]&XOR_MASK)
|
| 74 | | |
| 75 | | |
| 76 | | UINT16 vidregs[NO_VIDREGS];
|
| 77 | | |
| 78 | | UINT8 bpp; // Bits / pixel
|
| 79 | | UINT8 ppb; // Pixels / byte
|
| 80 | | UINT16 pixel_mask;
|
| 81 | | UINT8 border_colour;
|
| 82 | | |
| 83 | | int debug_on;
|
| 84 | | |
| 85 | | static void set_pixel(UINT16 x, UINT16 y, UINT8 colour);
|
| 86 | | static void write_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width);
|
| 87 | | static void write_pixel_data(UINT16 x, UINT16 y, UINT16 data);
|
| 88 | | static void move_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width);
|
| 89 | | static void write_reg_004(void);
|
| 90 | | static void write_reg_010(void);
|
| 91 | | static void write_reg_012(void);
|
| 92 | | static void write_reg_014(void);
|
| 93 | | static void write_reg_01A(void);
|
| 94 | | static void write_reg_026(void);
|
| 95 | | |
| 96 | | static void video_debug(running_machine *machine, int ref, int params, const char *param[]);
|
| 97 | | static void video_regdump(running_machine *machine, int ref, int params, const char *param[]);
|
| 98 | | |
| 99 | | /*
|
| 100 | | I'm not sure which of thes return values on a real machine, so for the time being I'm going
|
| 101 | | to return the values for all of them, it doesn't seem to hurt !
|
| 102 | | */
|
| 103 | | |
| 104 | | READ16_HANDLER (nimbus_video_io_r)
|
| 105 | | {
|
| 106 | | int pc=cpu_get_pc(space->cpu);
|
| 107 | | UINT16 result;
|
| 108 | | |
| 109 | | switch (offset)
|
| 110 | | {
|
| 111 | | case reg000 : result=vidregs[reg000]; break;
|
| 112 | | case reg002 : result=vidregs[reg002]; break;
|
| 113 | | case reg004 : result=vidregs[reg004]; break;
|
| 114 | | case reg006 : result=vidregs[reg006]; break;
|
| 115 | | case reg008 : result=vidregs[reg008]; break;
|
| 116 | | case reg00A : result=vidregs[reg00A]; break;
|
| 117 | | case reg00C : result=vidregs[reg00C]; break;
|
| 118 | | case reg00E : result=vidregs[reg00E]; break;
|
| 119 | | |
| 120 | | case reg010 : result=vidregs[reg010]; break;
|
| 121 | | case reg012 : result=vidregs[reg012]; break;
|
| 122 | | case reg014 : result=vidregs[reg014]; break;
|
| 123 | | case reg016 : result=vidregs[reg016]; break;
|
| 124 | | case reg018 : result=vidregs[reg018]; break;
|
| 125 | | case reg01A : result=vidregs[reg01A]; break;
|
| 126 | | case reg01C : result=vidregs[reg01C]; break;
|
| 127 | | case reg01E : result=vidregs[reg01E]; break;
|
| 128 | | |
| 129 | | case reg020 : result=vidregs[reg020]; break;
|
| 130 | | case reg022 : result=vidregs[reg022]; break;
|
| 131 | | case reg024 : result=vidregs[reg024]; break;
|
| 132 | | case reg026 : result=vidregs[reg026]; break;
|
| 133 | | case reg028 : result=vidregs[reg028]; break;
|
| 134 | | case reg02A : result=vidregs[reg02A]; break;
|
| 135 | | case reg02C : result=vidregs[reg02C]; break;
|
| 136 | | case reg02E : result=vidregs[reg02E]; break;
|
| 137 | | default : result=0; break;
|
| 138 | | }
|
| 139 | | |
| 140 | | if(debug_on & DEBUG_TEXT)
|
| 141 | | logerror("Nimbus video IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2),mem_mask,result);
|
| 142 | | |
| 143 | | return result;
|
| 144 | | }
|
| 145 | | |
| 146 | | /*
|
| 147 | | Write to the video registers, the default action is to write to the array of registers.
|
| 148 | | If a register also needs some special action call the action function for that register.
|
| 149 | | |
| 150 | | Incase anyone wonders about the DEBUG_DB statement, this allows me to log which registers |
| 151 | | are being written to and then play them back at the real machine, this has helped greatly
|
| 152 | | in figuring out what the video registers do.
|
| 153 | | |
| 154 | | */
|
| 155 | | |
| 156 | | WRITE16_HANDLER (nimbus_video_io_w)
|
| 157 | | {
|
| 158 | | int pc=cpu_get_pc(space->cpu);
|
| 159 | | |
| 160 | | if(debug_on & DEBUG_TEXT)
|
| 161 | | logerror("Nimbus video IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2),mem_mask);
|
| 162 | | |
| 163 | | if(debug_on & DEBUG_DB)
|
| 164 | | logerror("dw %05X,%05X\n",(offset*2),data);
|
| 165 | | |
| 166 | | |
| 167 | | switch (offset)
|
| 168 | | {
|
| 169 | | case reg000 : vidregs[reg000]=data; break;
|
| 170 | | case reg002 : vidregs[reg002]=data; break;
|
| 171 | | case reg004 : vidregs[reg004]=data; write_reg_004(); break;
|
| 172 | | case reg006 : vidregs[reg006]=data; break;
|
| 173 | | case reg008 : vidregs[reg008]=data; break;
|
| 174 | | case reg00A : vidregs[reg00A]=data; break;
|
| 175 | | case reg00C : vidregs[reg00C]=data; break;
|
| 176 | | case reg00E : vidregs[reg00E]=data; break;
|
| 177 | | |
| 178 | | case reg010 : vidregs[reg010]=data; write_reg_010(); break;
|
| 179 | | case reg012 : vidregs[reg012]=data; write_reg_012(); break;
|
| 180 | | case reg014 : vidregs[reg014]=data; write_reg_014(); break;
|
| 181 | | case reg016 : vidregs[reg016]=data; break;
|
| 182 | | case reg018 : vidregs[reg018]=data; break;
|
| 183 | | case reg01A : vidregs[reg01A]=data; write_reg_01A(); break;
|
| 184 | | case reg01C : vidregs[reg01C]=data; break;
|
| 185 | | case reg01E : vidregs[reg01E]=data; break;
|
| 186 | | |
| 187 | | case reg020 : vidregs[reg020]=data; break;
|
| 188 | | case reg022 : vidregs[reg022]=data; break;
|
| 189 | | case reg024 : vidregs[reg024]=data; break;
|
| 190 | | case reg026 : vidregs[reg026]=data; write_reg_026(); break;
|
| 191 | | case reg028 : vidregs[reg028]=data; break;
|
| 192 | | case reg02A : vidregs[reg02A]=data; break;
|
| 193 | | case reg02C : vidregs[reg02C]=data; break;
|
| 194 | | case reg02E : vidregs[reg02E]=data; break;
|
| 195 | | |
| 196 | | default : break;
|
| 197 | | }
|
| 198 | | }
|
| 199 | | |
| 200 | | static void set_pixel(UINT16 x, UINT16 y, UINT8 colour)
|
| 201 | | {
|
| 202 | | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL))
|
| 203 | | logerror("set_pixel(x=%04X, y=%04X, colour=%04X), IS_XOR=%02X\n",x,y,colour,IS_XOR);
|
| 204 | | |
| 205 | | |
| 206 | | if((x<SCREEN_WIDTH_PIXELS) && (y<SCREEN_HEIGHT_LINES))
|
| 207 | | {
|
| 208 | | if(IS_XOR)
|
| 209 | | video_mem[x][y]^=colour;
|
| 210 | | else
|
| 211 | | video_mem[x][y]=colour;
|
| 212 | | }
|
| 213 | | }
|
| 214 | | |
| 215 | | static void write_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width)
|
| 216 | | {
|
| 217 | | UINT16 mask;
|
| 218 | | UINT16 pixel_x;
|
| 219 | | UINT16 colour;
|
| 220 | | UINT8 shifts;
|
| 221 | | |
| 222 | | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL))
|
| 223 | | logerror("write_pixel_line(x=%04X, y=%04X, data=%04X, width=%02X, bpp=%02X, pixel_mask=%02X)\n",x,y,data,width,bpp,pixel_mask);
|
| 224 | | |
| 225 | | shifts=width-bpp; |
| 226 | | |
| 227 | | for(mask=pixel_mask, pixel_x=(x*(width/bpp)); mask>0; mask=(mask>>bpp), pixel_x++)
|
| 228 | | {
|
| 229 | | if(bpp==1)
|
| 230 | | colour=(data & mask) ? FG_COLOUR : BG_COLOUR;
|
| 231 | | else
|
| 232 | | colour=(data & mask) >> shifts;
|
| 233 | | |
| 234 | | //logerror("write_pixel_line: data=%04X, mask=%04X, shifts=%02X, bpp=%02X colour=%02X\n",data,mask,shifts,bpp,colour); |
| 235 | | |
| 236 | | if(IS_80COL)
|
| 237 | | {
|
| 238 | | set_pixel(pixel_x,y,colour);
|
| 239 | | }
|
| 240 | | else
|
| 241 | | {
|
| 242 | | set_pixel((pixel_x*2),y,colour);
|
| 243 | | set_pixel((pixel_x*2)+1,y,colour);
|
| 244 | | }
|
| 245 | | shifts-=bpp;
|
| 246 | | }
|
| 247 | | }
|
| 248 | | |
| 249 | | static void move_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width)
|
| 250 | | {
|
| 251 | | UINT16 pixelno;
|
| 252 | | UINT16 pixelx;
|
| 253 | | |
| 254 | | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL))
|
| 255 | | logerror("move_pixel_line(x=%04X, y=%04X, data=%04X, width=%02X)\n",x,y,data,width);
|
| 256 | |
|
| 257 | | for(pixelno=0;pixelno<width;pixelno++)
|
| 258 | | {
|
| 259 | | pixelx=(x*width)+pixelno;
|
| 260 | | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL))
|
| 261 | | logerror("pixelx=%04X\n",pixelx);
|
| 262 | | video_mem[pixelx][vidregs[reg020]]=video_mem[pixelx][y];
|
| 263 | | }
|
| 264 | | }
|
| 265 | | |
| 266 | | |
| 267 | | /* |
| 268 | | The values in the bottom 3 bits of reg022 seem to determine the number of bits per pixel
|
| 269 | | for following operations.
|
| 270 | | |
| 271 | | The values that I have decoded so far are :
|
| 272 | | |
| 273 | | 000 1bpp, foreground and background colours taken from reg024
|
| 274 | | 001 2bpp, using the first 4 colours of the pallette
|
| 275 | | 010 |
| 276 | | 011 |
| 277 | | 100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with the lower byte
|
| 278 | | containing the pixel data for two pixels.
|
| 279 | | 101
|
| 280 | | 110 4bpp, 16 bit word containing the pixel data for 4 pixels.
|
| 281 | | 111
|
| 282 | | |
| 283 | | Bit 3 of reg022 is as follows :
|
| 284 | | |
| 285 | | 0 pixels are written from supplied colour data
|
| 286 | | 1 pixels are xor'ed onto the screen
|
| 287 | | */
|
| 288 | | |
| 289 | | static void write_pixel_data(UINT16 x, UINT16 y, UINT16 data)
|
| 290 | | { |
| 291 | | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL))
|
| 292 | | logerror("write_pixel_data(x=%04X, y=%04X, data=%04X), reg022=%04X\n",x,y,data,vidregs[reg022]);
|
| 293 | | |
| 294 | | if(IS_80COL)
|
| 295 | | {
|
| 296 | | switch (vidregs[reg022] & WIDTH_MASK)
|
| 297 | | {
|
| 298 | | case 0x00 : bpp=1; pixel_mask=0x8000;
|
| 299 | | write_pixel_line(x,y,data,16); |
| 300 | | break;
|
| 301 | | |
| 302 | | case 0x01 : bpp=1; pixel_mask=0x80;
|
| 303 | | write_pixel_line(x,y,data,8); |
| 304 | | break;
|
| 305 | | |
| 306 | | case 0x02 : bpp=1; pixel_mask=0x0080;
|
| 307 | | write_pixel_line(x,y,data,8); break;
|
| 308 | | |
| 309 | | case 0x03 : bpp=1; |
| 310 | | set_pixel(x,y,FG_COLOUR); |
| 311 | | break; |
| 312 | | |
| 313 | | case 0x04 : bpp=2; pixel_mask=0xC0;
|
| 314 | | write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8); |
| 315 | | break;
|
| 316 | | |
| 317 | | case 0x05 : move_pixel_line(x,y,data,8);
|
| 318 | | break;
|
| 319 | | |
| 320 | | case 0x06 : bpp=2; pixel_mask=0xC000;
|
| 321 | | write_pixel_line(x,y,data,16); |
| 322 | | break;
|
| 323 | | |
| 324 | | case 0x07 : bpp=1; |
| 325 | | set_pixel(x,y,FG_COLOUR);
|
| 326 | | break;
|
| 327 | | }
|
| 328 | | }
|
| 329 | | else
|
| 330 | | {
|
| 331 | | switch (vidregs[reg022] & WIDTH_MASK)
|
| 332 | | {
|
| 333 | | case 0x00 : bpp=1; pixel_mask=0x0080;
|
| 334 | | write_pixel_line(x,y,data,8); |
| 335 | | break;
|
| 336 | | |
| 337 | | case 0x01 : bpp=2; pixel_mask=0xC0;
|
| 338 | | write_pixel_line(x,y,data,8); |
| 339 | | break;
|
| 340 | | |
| 341 | | case 0x02 : bpp=1; pixel_mask=0x0080;
|
| 342 | | write_pixel_line(x,y,data,8); break;
|
| 343 | | |
| 344 | | case 0x03 : bpp=1; |
| 345 | | set_pixel(x,y,FG_COLOUR); |
| 346 | | break; |
| 347 | | |
| 348 | | case 0x04 : bpp=4; pixel_mask=0xF0;
|
| 349 | | write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8); |
| 350 | | break;
|
| 351 | | |
| 352 | | case 0x05 : move_pixel_line(x,y,data,16);
|
| 353 | | break;
|
| 354 | | |
| 355 | | case 0x06 : bpp=4; pixel_mask=0xF000;
|
| 356 | | write_pixel_line(x,y,data,16); |
| 357 | | break;
|
| 358 | | |
| 359 | | case 0x07 : bpp=1; |
| 360 | | set_pixel(x,y,FG_COLOUR);
|
| 361 | | break;
|
| 362 | | }
|
| 363 | | }
|
| 364 | | }
|
| 365 | | |
| 366 | | static void write_reg_004(void)
|
| 367 | | {
|
| 368 | | vidregs[reg002]=0;
|
| 369 | | vidregs[reg00C]++;
|
| 370 | | }
|
| 371 | | |
| 372 | | static void write_reg_010(void)
|
| 373 | | {
|
| 374 | | write_pixel_data(vidregs[reg002],vidregs[reg00C],vidregs[reg010]); |
| 375 | | }
|
| 376 | | |
| 377 | | static void write_reg_012(void)
|
| 378 | | {
|
| 379 | | // I dunno if this is actually what is happening as the regs seem to be write only....
|
| 380 | | // doing this however does seem to make some programs (worms from the welcom disk)
|
| 381 | | // work correctly.
|
| 382 | | if(IS_80COL)
|
| 383 | | vidregs[reg002]=vidregs[reg012];
|
| 384 | | else
|
| 385 | | vidregs[reg002]=vidregs[reg012]/2; |
| 386 | | |
| 387 | | write_pixel_data(vidregs[reg012],vidregs[reg00C],FG_COLOUR);
|
| 388 | | }
|
| 389 | | |
| 390 | | static void write_reg_014(void)
|
| 391 | | { |
| 392 | | write_pixel_data(vidregs[reg002],++vidregs[reg00C],vidregs[reg014]);
|
| 393 | | }
|
| 394 | | |
| 395 | | static void write_reg_01A(void)
|
| 396 | | {
|
| 397 | | write_pixel_data(++vidregs[reg002],vidregs[reg00C],vidregs[reg01A]); |
| 398 | | }
|
| 399 | | |
| 400 | | /*
|
| 401 | | bits 0..3 of reg026 contain the border colour.
|
| 402 | | bit 5 contains the 40/80 column (320/640 pixel) flag.
|
| 403 | | */
|
| 404 | | |
| 405 | | static void write_reg_026(void)
|
| 406 | | {
|
| 407 | | border_colour=vidregs[reg026] & 0x0F;
|
| 408 | | |
| 409 | | if(debug_on & DEBUG_TEXT)
|
| 410 | | logerror("reg 026 write, border_colour=%02X\n",border_colour);
|
| 411 | | }
|
| 412 | | |
| 413 | | static void video_debug(running_machine *machine, int ref, int params, const char *param[])
|
| 414 | | {
|
| 415 | | if(params>0)
|
| 416 | | {
|
| 417 | | sscanf(param[0],"%d",&debug_on); |
| 418 | | }
|
| 419 | | else
|
| 420 | | {
|
| 421 | | debug_console_printf(machine,"Error usage : nimbus_vid_debug <debuglevel>\n");
|
| 422 | | debug_console_printf(machine,"Current debuglevel=%02X\n",debug_on);
|
| 423 | | }
|
| 424 | | }
|
| 425 | | |
| 426 | | static void video_regdump(running_machine *machine, int ref, int params, const char *param[])
|
| 427 | | {
|
| 428 | | int regno;
|
| 429 | | |
| 430 | | for(regno=0;regno<0x08;regno++)
|
| 431 | | debug_console_printf(machine,"reg%03X=%04X reg%03X=%04X reg%03X=%04X\n",
|
| 432 | | regno*2,vidregs[regno],
|
| 433 | | (regno+0x08)*2,vidregs[regno+0x08],
|
| 434 | | (regno+0x10)*2,vidregs[regno+0x10]);
|
| 435 | | }
|
| 436 | | |
| 437 | | VIDEO_START( nimbus )
|
| 438 | | {
|
| 439 | | debug_on=0;
|
| 440 | | |
| 441 | | logerror("VIDEO_START\n");
|
| 442 | | |
| 443 | | if (machine->debug_flags & DEBUG_FLAG_ENABLED)
|
| 444 | | {
|
| 445 | | debug_console_register_command(machine, "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug);
|
| 446 | | debug_console_register_command(machine, "nimbus_vid_regdump", CMDFLAG_NONE, 0, 0, 1, video_regdump);
|
| 447 | | }
|
| 448 | | }
|
| 449 | | |
| 450 | | VIDEO_RESET( nimbus )
|
| 451 | | {
|
| 452 | | // When we reset clear the video registers and video memory.
|
| 453 | | memset(&vidregs,0x00,sizeof(vidregs));
|
| 454 | | memset(&video_mem,0,sizeof(video_mem)); |
| 455 | | |
| 456 | | bpp=4; // bits per pixel
|
| 457 | | logerror("Video reset\n");
|
| 458 | | }
|
| 459 | | |
| 460 | | VIDEO_EOF( nimbus )
|
| 461 | | {
|
| 462 | | |
| 463 | | // logerror("VIDEO_EOF( nimbus )\n");
|
| 464 | | }
|
| 465 | | |
| 466 | | VIDEO_UPDATE( nimbus )
|
| 467 | | {
|
| 468 | | int XCoord;
|
| 469 | | int YCoord = video_screen_get_vpos(screen);
|
| 470 | |
|
| 471 | | for(XCoord=0;XCoord<SCREEN_WIDTH_PIXELS;XCoord++)
|
| 472 | | {
|
| 473 | | *BITMAP_ADDR16(bitmap, YCoord, XCoord)=video_mem[XCoord][YCoord];
|
| 474 | | }
|
| 475 | | |
| 476 | | vidregs[reg028]++;
|
| 477 | | if((vidregs[reg028] & 0x000F)>0x0A)
|
| 478 | | vidregs[reg028]&=0xFFF0;
|
| 479 | | |
| 480 | | return 0;
|
| 481 | | }
|
| 482 | | |
| 1 | /* |
| 2 | video/rmnimbus.c |
| 3 | |
| 4 | Research machines Nimbus. |
| 5 | |
| 6 | 2009-11-14, P.Harvey-Smith. |
| 7 | |
| 8 | This is my best guess implementation of the operation of the Nimbus |
| 9 | video system. |
| 10 | |
| 11 | On the real machine, the Video chip has a block of 64K of memory which is |
| 12 | completely seperate from the main 80186 memory. |
| 13 | |
| 14 | The main CPU write to the video chip via a series of registers in the |
| 15 | 0x0000 to 0x002F reigon, the video chip then manages all video memory |
| 16 | from there. |
| 17 | |
| 18 | As I cannot find a datasheet for the vide chip marked |
| 19 | MB61H201 Fujitsu RML 12835 GCV, I have had to determine most of its |
| 20 | operation by disassembling the Nimbus bios and by writing experemental |
| 21 | code on the real machine. |
| 22 | */ |
| 23 | |
| 24 | #include "driver.h" |
| 25 | #include "video/border.h" |
| 26 | #include "memory.h" |
| 27 | #include "debug/debugcpu.h" |
| 28 | #include "debug/debugcon.h" |
| 29 | #include "includes/rmnimbus.h" |
| 30 | #include "mame.h" |
| 31 | |
| 32 | #include "debug/debugcpu.h" |
| 33 | #include "debug/debugcon.h" |
| 34 | |
| 35 | UINT8 video_mem[SCREEN_WIDTH_PIXELS][SCREEN_HEIGHT_LINES]; |
| 36 | |
| 37 | #define WIDTH_MASK 0x07 |
| 38 | #define XOR_MASK 0x08 |
| 39 | #define MASK_4080 0x10 |
| 40 | |
| 41 | // Offsets of nimbus video registers within register array |
| 42 | |
| 43 | #define NO_VIDREGS (0x30/2) |
| 44 | #define reg000 0x00 |
| 45 | #define reg002 0x01 |
| 46 | #define reg004 0x02 |
| 47 | #define reg006 0x03 |
| 48 | #define reg008 0x04 |
| 49 | #define reg00A 0x05 |
| 50 | #define reg00C 0x06 |
| 51 | #define reg00E 0x07 |
| 52 | #define reg010 0x08 |
| 53 | #define reg012 0x09 |
| 54 | #define reg014 0x0A |
| 55 | #define reg016 0x0B |
| 56 | #define reg018 0x0C |
| 57 | #define reg01A 0x0D |
| 58 | #define reg01C 0x0E |
| 59 | #define reg01E 0x0F |
| 60 | #define reg020 0x10 |
| 61 | #define reg022 0x11 |
| 62 | #define reg024 0x12 |
| 63 | #define reg026 0x13 |
| 64 | #define reg028 0x14 |
| 65 | #define reg02A 0x15 |
| 66 | #define reg02C 0x16 |
| 67 | #define reg02E 0x17 |
| 68 | |
| 69 | #define FG_COLOUR (vidregs[reg024]&0x0F) |
| 70 | #define BG_COLOUR ((vidregs[reg024]&0xF0)>>4) |
| 71 | |
| 72 | #define IS_80COL (vidregs[reg026]&MASK_4080) |
| 73 | #define IS_XOR (vidregs[reg022]&XOR_MASK) |
| 74 | |
| 75 | |
| 76 | UINT16 vidregs[NO_VIDREGS]; |
| 77 | |
| 78 | UINT8 bpp; // Bits / pixel |
| 79 | UINT8 ppb; // Pixels / byte |
| 80 | UINT16 pixel_mask; |
| 81 | UINT8 border_colour; |
| 82 | |
| 83 | int debug_on; |
| 84 | |
| 85 | static void set_pixel(UINT16 x, UINT16 y, UINT8 colour); |
| 86 | static void write_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width); |
| 87 | static void write_pixel_data(UINT16 x, UINT16 y, UINT16 data); |
| 88 | static void move_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width); |
| 89 | static void write_reg_004(void); |
| 90 | static void write_reg_010(void); |
| 91 | static void write_reg_012(void); |
| 92 | static void write_reg_014(void); |
| 93 | static void write_reg_01A(void); |
| 94 | static void write_reg_026(void); |
| 95 | |
| 96 | static void video_debug(running_machine *machine, int ref, int params, const char *param[]); |
| 97 | static void video_regdump(running_machine *machine, int ref, int params, const char *param[]); |
| 98 | |
| 99 | /* |
| 100 | I'm not sure which of thes return values on a real machine, so for the time being I'm going |
| 101 | to return the values for all of them, it doesn't seem to hurt ! |
| 102 | */ |
| 103 | |
| 104 | READ16_HANDLER (nimbus_video_io_r) |
| 105 | { |
| 106 | int pc=cpu_get_pc(space->cpu); |
| 107 | UINT16 result; |
| 108 | |
| 109 | switch (offset) |
| 110 | { |
| 111 | case reg000 : result=vidregs[reg000]; break; |
| 112 | case reg002 : result=vidregs[reg002]; break; |
| 113 | case reg004 : result=vidregs[reg004]; break; |
| 114 | case reg006 : result=vidregs[reg006]; break; |
| 115 | case reg008 : result=vidregs[reg008]; break; |
| 116 | case reg00A : result=vidregs[reg00A]; break; |
| 117 | case reg00C : result=vidregs[reg00C]; break; |
| 118 | case reg00E : result=vidregs[reg00E]; break; |
| 119 | |
| 120 | case reg010 : result=vidregs[reg010]; break; |
| 121 | case reg012 : result=vidregs[reg012]; break; |
| 122 | case reg014 : result=vidregs[reg014]; break; |
| 123 | case reg016 : result=vidregs[reg016]; break; |
| 124 | case reg018 : result=vidregs[reg018]; break; |
| 125 | case reg01A : result=vidregs[reg01A]; break; |
| 126 | case reg01C : result=vidregs[reg01C]; break; |
| 127 | case reg01E : result=vidregs[reg01E]; break; |
| 128 | |
| 129 | case reg020 : result=vidregs[reg020]; break; |
| 130 | case reg022 : result=vidregs[reg022]; break; |
| 131 | case reg024 : result=vidregs[reg024]; break; |
| 132 | case reg026 : result=vidregs[reg026]; break; |
| 133 | case reg028 : result=vidregs[reg028]; break; |
| 134 | case reg02A : result=vidregs[reg02A]; break; |
| 135 | case reg02C : result=vidregs[reg02C]; break; |
| 136 | case reg02E : result=vidregs[reg02E]; break; |
| 137 | default : result=0; break; |
| 138 | } |
| 139 | |
| 140 | if(debug_on & DEBUG_TEXT) |
| 141 | logerror("Nimbus video IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2),mem_mask,result); |
| 142 | |
| 143 | return result; |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | Write to the video registers, the default action is to write to the array of registers. |
| 148 | If a register also needs some special action call the action function for that register. |
| 149 | |
| 150 | Incase anyone wonders about the DEBUG_DB statement, this allows me to log which registers |
| 151 | are being written to and then play them back at the real machine, this has helped greatly |
| 152 | in figuring out what the video registers do. |
| 153 | |
| 154 | */ |
| 155 | |
| 156 | WRITE16_HANDLER (nimbus_video_io_w) |
| 157 | { |
| 158 | int pc=cpu_get_pc(space->cpu); |
| 159 | |
| 160 | if(debug_on & DEBUG_TEXT) |
| 161 | logerror("Nimbus video IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2),mem_mask); |
| 162 | |
| 163 | if(debug_on & DEBUG_DB) |
| 164 | logerror("dw %05X,%05X\n",(offset*2),data); |
| 165 | |
| 166 | |
| 167 | switch (offset) |
| 168 | { |
| 169 | case reg000 : vidregs[reg000]=data; break; |
| 170 | case reg002 : vidregs[reg002]=data; break; |
| 171 | case reg004 : vidregs[reg004]=data; write_reg_004(); break; |
| 172 | case reg006 : vidregs[reg006]=data; break; |
| 173 | case reg008 : vidregs[reg008]=data; break; |
| 174 | case reg00A : vidregs[reg00A]=data; break; |
| 175 | case reg00C : vidregs[reg00C]=data; break; |
| 176 | case reg00E : vidregs[reg00E]=data; break; |
| 177 | |
| 178 | case reg010 : vidregs[reg010]=data; write_reg_010(); break; |
| 179 | case reg012 : vidregs[reg012]=data; write_reg_012(); break; |
| 180 | case reg014 : vidregs[reg014]=data; write_reg_014(); break; |
| 181 | case reg016 : vidregs[reg016]=data; break; |
| 182 | case reg018 : vidregs[reg018]=data; break; |
| 183 | case reg01A : vidregs[reg01A]=data; write_reg_01A(); break; |
| 184 | case reg01C : vidregs[reg01C]=data; break; |
| 185 | case reg01E : vidregs[reg01E]=data; break; |
| 186 | |
| 187 | case reg020 : vidregs[reg020]=data; break; |
| 188 | case reg022 : vidregs[reg022]=data; break; |
| 189 | case reg024 : vidregs[reg024]=data; break; |
| 190 | case reg026 : vidregs[reg026]=data; write_reg_026(); break; |
| 191 | case reg028 : vidregs[reg028]=data; break; |
| 192 | case reg02A : vidregs[reg02A]=data; break; |
| 193 | case reg02C : vidregs[reg02C]=data; break; |
| 194 | case reg02E : vidregs[reg02E]=data; break; |
| 195 | |
| 196 | default : break; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | static void set_pixel(UINT16 x, UINT16 y, UINT8 colour) |
| 201 | { |
| 202 | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL)) |
| 203 | logerror("set_pixel(x=%04X, y=%04X, colour=%04X), IS_XOR=%02X\n",x,y,colour,IS_XOR); |
| 204 | |
| 205 | |
| 206 | if((x<SCREEN_WIDTH_PIXELS) && (y<SCREEN_HEIGHT_LINES)) |
| 207 | { |
| 208 | if(IS_XOR) |
| 209 | video_mem[x][y]^=colour; |
| 210 | else |
| 211 | video_mem[x][y]=colour; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | static void write_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width) |
| 216 | { |
| 217 | UINT16 mask; |
| 218 | UINT16 pixel_x; |
| 219 | UINT16 colour; |
| 220 | UINT8 shifts; |
| 221 | |
| 222 | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL)) |
| 223 | logerror("write_pixel_line(x=%04X, y=%04X, data=%04X, width=%02X, bpp=%02X, pixel_mask=%02X)\n",x,y,data,width,bpp,pixel_mask); |
| 224 | |
| 225 | shifts=width-bpp; |
| 226 | |
| 227 | for(mask=pixel_mask, pixel_x=(x*(width/bpp)); mask>0; mask=(mask>>bpp), pixel_x++) |
| 228 | { |
| 229 | if(bpp==1) |
| 230 | colour=(data & mask) ? FG_COLOUR : BG_COLOUR; |
| 231 | else |
| 232 | colour=(data & mask) >> shifts; |
| 233 | |
| 234 | //logerror("write_pixel_line: data=%04X, mask=%04X, shifts=%02X, bpp=%02X colour=%02X\n",data,mask,shifts,bpp,colour); |
| 235 | |
| 236 | if(IS_80COL) |
| 237 | { |
| 238 | set_pixel(pixel_x,y,colour); |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | set_pixel((pixel_x*2),y,colour); |
| 243 | set_pixel((pixel_x*2)+1,y,colour); |
| 244 | } |
| 245 | shifts-=bpp; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | static void move_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width) |
| 250 | { |
| 251 | UINT16 pixelno; |
| 252 | UINT16 pixelx; |
| 253 | |
| 254 | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL)) |
| 255 | logerror("move_pixel_line(x=%04X, y=%04X, data=%04X, width=%02X)\n",x,y,data,width); |
| 256 | |
| 257 | for(pixelno=0;pixelno<width;pixelno++) |
| 258 | { |
| 259 | pixelx=(x*width)+pixelno; |
| 260 | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL)) |
| 261 | logerror("pixelx=%04X\n",pixelx); |
| 262 | video_mem[pixelx][vidregs[reg020]]=video_mem[pixelx][y]; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /* |
| 268 | The values in the bottom 3 bits of reg022 seem to determine the number of bits per pixel |
| 269 | for following operations. |
| 270 | |
| 271 | The values that I have decoded so far are : |
| 272 | |
| 273 | 000 1bpp, foreground and background colours taken from reg024 |
| 274 | 001 2bpp, using the first 4 colours of the pallette |
| 275 | 010 |
| 276 | 011 |
| 277 | 100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with the lower byte |
| 278 | containing the pixel data for two pixels. |
| 279 | 101 |
| 280 | 110 4bpp, 16 bit word containing the pixel data for 4 pixels. |
| 281 | 111 |
| 282 | |
| 283 | Bit 3 of reg022 is as follows : |
| 284 | |
| 285 | 0 pixels are written from supplied colour data |
| 286 | 1 pixels are xor'ed onto the screen |
| 287 | */ |
| 288 | |
| 289 | static void write_pixel_data(UINT16 x, UINT16 y, UINT16 data) |
| 290 | { |
| 291 | if(debug_on & (DEBUG_TEXT | DEBUG_PIXEL)) |
| 292 | logerror("write_pixel_data(x=%04X, y=%04X, data=%04X), reg022=%04X\n",x,y,data,vidregs[reg022]); |
| 293 | |
| 294 | if(IS_80COL) |
| 295 | { |
| 296 | switch (vidregs[reg022] & WIDTH_MASK) |
| 297 | { |
| 298 | case 0x00 : bpp=1; pixel_mask=0x8000; |
| 299 | write_pixel_line(x,y,data,16); |
| 300 | break; |
| 301 | |
| 302 | case 0x01 : bpp=1; pixel_mask=0x80; |
| 303 | write_pixel_line(x,y,data,8); |
| 304 | break; |
| 305 | |
| 306 | case 0x02 : bpp=1; pixel_mask=0x0080; |
| 307 | write_pixel_line(x,y,data,8); break; |
| 308 | |
| 309 | case 0x03 : bpp=1; |
| 310 | set_pixel(x,y,FG_COLOUR); |
| 311 | break; |
| 312 | |
| 313 | case 0x04 : bpp=2; pixel_mask=0xC0; |
| 314 | write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8); |
| 315 | break; |
| 316 | |
| 317 | case 0x05 : move_pixel_line(x,y,data,8); |
| 318 | break; |
| 319 | |
| 320 | case 0x06 : bpp=2; pixel_mask=0xC000; |
| 321 | write_pixel_line(x,y,data,16); |
| 322 | break; |
| 323 | |
| 324 | case 0x07 : bpp=1; |
| 325 | set_pixel(x,y,FG_COLOUR); |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | switch (vidregs[reg022] & WIDTH_MASK) |
| 332 | { |
| 333 | case 0x00 : bpp=1; pixel_mask=0x0080; |
| 334 | write_pixel_line(x,y,data,8); |
| 335 | break; |
| 336 | |
| 337 | case 0x01 : bpp=2; pixel_mask=0xC0; |
| 338 | write_pixel_line(x,y,data,8); |
| 339 | break; |
| 340 | |
| 341 | case 0x02 : bpp=1; pixel_mask=0x0080; |
| 342 | write_pixel_line(x,y,data,8); break; |
| 343 | |
| 344 | case 0x03 : bpp=1; |
| 345 | set_pixel(x,y,FG_COLOUR); |
| 346 | break; |
| 347 | |
| 348 | case 0x04 : bpp=4; pixel_mask=0xF0; |
| 349 | write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8); |
| 350 | break; |
| 351 | |
| 352 | case 0x05 : move_pixel_line(x,y,data,16); |
| 353 | break; |
| 354 | |
| 355 | case 0x06 : bpp=4; pixel_mask=0xF000; |
| 356 | write_pixel_line(x,y,data,16); |
| 357 | break; |
| 358 | |
| 359 | case 0x07 : bpp=1; |
| 360 | set_pixel(x,y,FG_COLOUR); |
| 361 | break; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | static void write_reg_004(void) |
| 367 | { |
| 368 | vidregs[reg002]=0; |
| 369 | vidregs[reg00C]++; |
| 370 | } |
| 371 | |
| 372 | static void write_reg_010(void) |
| 373 | { |
| 374 | write_pixel_data(vidregs[reg002],vidregs[reg00C],vidregs[reg010]); |
| 375 | } |
| 376 | |
| 377 | static void write_reg_012(void) |
| 378 | { |
| 379 | // I dunno if this is actually what is happening as the regs seem to be write only.... |
| 380 | // doing this however does seem to make some programs (worms from the welcom disk) |
| 381 | // work correctly. |
| 382 | if(IS_80COL) |
| 383 | vidregs[reg002]=vidregs[reg012]; |
| 384 | else |
| 385 | vidregs[reg002]=vidregs[reg012]/2; |
| 386 | |
| 387 | write_pixel_data(vidregs[reg012],vidregs[reg00C],FG_COLOUR); |
| 388 | } |
| 389 | |
| 390 | static void write_reg_014(void) |
| 391 | { |
| 392 | write_pixel_data(vidregs[reg002],++vidregs[reg00C],vidregs[reg014]); |
| 393 | } |
| 394 | |
| 395 | static void write_reg_01A(void) |
| 396 | { |
| 397 | write_pixel_data(++vidregs[reg002],vidregs[reg00C],vidregs[reg01A]); |
| 398 | } |
| 399 | |
| 400 | /* |
| 401 | bits 0..3 of reg026 contain the border colour. |
| 402 | bit 5 contains the 40/80 column (320/640 pixel) flag. |
| 403 | */ |
| 404 | |
| 405 | static void write_reg_026(void) |
| 406 | { |
| 407 | border_colour=vidregs[reg026] & 0x0F; |
| 408 | |
| 409 | if(debug_on & DEBUG_TEXT) |
| 410 | logerror("reg 026 write, border_colour=%02X\n",border_colour); |
| 411 | } |
| 412 | |
| 413 | static void video_debug(running_machine *machine, int ref, int params, const char *param[]) |
| 414 | { |
| 415 | if(params>0) |
| 416 | { |
| 417 | sscanf(param[0],"%d",&debug_on); |
| 418 | } |
| 419 | else |
| 420 | { |
| 421 | debug_console_printf(machine,"Error usage : nimbus_vid_debug <debuglevel>\n"); |
| 422 | debug_console_printf(machine,"Current debuglevel=%02X\n",debug_on); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | static void video_regdump(running_machine *machine, int ref, int params, const char *param[]) |
| 427 | { |
| 428 | int regno; |
| 429 | |
| 430 | for(regno=0;regno<0x08;regno++) |
| 431 | debug_console_printf(machine,"reg%03X=%04X reg%03X=%04X reg%03X=%04X\n", |
| 432 | regno*2,vidregs[regno], |
| 433 | (regno+0x08)*2,vidregs[regno+0x08], |
| 434 | (regno+0x10)*2,vidregs[regno+0x10]); |
| 435 | } |
| 436 | |
| 437 | VIDEO_START( nimbus ) |
| 438 | { |
| 439 | debug_on=0; |
| 440 | |
| 441 | logerror("VIDEO_START\n"); |
| 442 | |
| 443 | if (machine->debug_flags & DEBUG_FLAG_ENABLED) |
| 444 | { |
| 445 | debug_console_register_command(machine, "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug); |
| 446 | debug_console_register_command(machine, "nimbus_vid_regdump", CMDFLAG_NONE, 0, 0, 1, video_regdump); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | VIDEO_RESET( nimbus ) |
| 451 | { |
| 452 | // When we reset clear the video registers and video memory. |
| 453 | memset(&vidregs,0x00,sizeof(vidregs)); |
| 454 | memset(&video_mem,0,sizeof(video_mem)); |
| 455 | |
| 456 | bpp=4; // bits per pixel |
| 457 | logerror("Video reset\n"); |
| 458 | } |
| 459 | |
| 460 | VIDEO_EOF( nimbus ) |
| 461 | { |
| 462 | |
| 463 | // logerror("VIDEO_EOF( nimbus )\n"); |
| 464 | } |
| 465 | |
| 466 | VIDEO_UPDATE( nimbus ) |
| 467 | { |
| 468 | int XCoord; |
| 469 | int YCoord = video_screen_get_vpos(screen); |
| 470 | |
| 471 | for(XCoord=0;XCoord<SCREEN_WIDTH_PIXELS;XCoord++) |
| 472 | { |
| 473 | *BITMAP_ADDR16(bitmap, YCoord, XCoord)=video_mem[XCoord][YCoord]; |
| 474 | } |
| 475 | |
| 476 | vidregs[reg028]++; |
| 477 | if((vidregs[reg028] & 0x000F)>0x0A) |
| 478 | vidregs[reg028]&=0xFFF0; |
| 479 | |
| 480 | return 0; |
| 481 | } |
| 482 | |
src/mess/machine/c1571.c
| r6857 | r6858 | |
| 1 | | /**********************************************************************
|
| 2 | | |
| 3 | | Commodore 1570/1571/1571CR Single Disk Drive emulation
|
| 4 | | |
| 5 | | Copyright MESS Team.
|
| 6 | | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | | |
| 8 | | **********************************************************************/
|
| 9 | | |
| 10 | | #include "driver.h"
|
| 11 | | #include "c1571.h"
|
| 12 | | #include "cpu/m6502/m6502.h"
|
| 13 | | #include "devices/flopdrv.h"
|
| 14 | | #include "formats/g64_dsk.h"
|
| 15 | | #include "machine/6522via.h"
|
| 16 | | #include "machine/6526cia.h"
|
| 17 | | #include "machine/cbmiec.h"
|
| 18 | | #include "machine/wd17xx.h"
|
| 19 | | |
| 20 | | /***************************************************************************
|
| 21 | | PARAMETERS
|
| 22 | | ***************************************************************************/
|
| 23 | | |
| 24 | | #define LOG 0
|
| 25 | | |
| 26 | | #define M6502_TAG "u1"
|
| 27 | | #define M6522_0_TAG "u4"
|
| 28 | | #define M6522_1_TAG "u9"
|
| 29 | | #define M6526_TAG "u20"
|
| 30 | | #define WD1770_TAG "u11"
|
| 31 | | |
| 32 | | static const double C1571_BITRATE[4] =
|
| 33 | | {
|
| 34 | | XTAL_16MHz/13.0, /* tracks 1-17 */
|
| 35 | | XTAL_16MHz/14.0, /* tracks 18-24 */
|
| 36 | | XTAL_16MHz/15.0, /* tracks 25-30 */
|
| 37 | | XTAL_16MHz/16.0 /* tracks 31-42 */
|
| 38 | | };
|
| 39 | | |
| 40 | | #define SYNC_MARK 0x3ff /* 10 consecutive 1-bits */
|
| 41 | | |
| 42 | | #define TRACK_BUFFER_SIZE 8194 /* 2 bytes track length + maximum of 8192 bytes of GCR encoded data */
|
| 43 | | #define TRACK_DATA_START 2
|
| 44 | | |
| 45 | | /***************************************************************************
|
| 46 | | TYPE DEFINITIONS
|
| 47 | | ***************************************************************************/
|
| 48 | | |
| 49 | | typedef struct _c1571_t c1571_t;
|
| 50 | | struct _c1571_t
|
| 51 | | {
|
| 52 | | /* abstractions */
|
| 53 | | int address;
|
| 54 | | UINT8 track_buffer[TRACK_BUFFER_SIZE]; /* track data buffer */
|
| 55 | | int track_len; /* track length */
|
| 56 | | int buffer_pos; /* current byte position within track buffer */
|
| 57 | | int bit_pos; /* current bit position within track buffer byte */
|
| 58 | | int bit_count; /* current data byte bit counter */
|
| 59 | | UINT16 data; /* data shift register */
|
| 60 | | |
| 61 | | /* signals */
|
| 62 | | UINT8 yb; /* GCR data byte to write */
|
| 63 | | int byte; /* byte ready */
|
| 64 | | int atna; /* attention acknowledge */
|
| 65 | | int ds; /* density select */
|
| 66 | | int stp; /* stepping motor */
|
| 67 | | int soe; /* s? output enable */
|
| 68 | | int mode; /* mode (0 = write, 1 = read) */
|
| 69 | | |
| 70 | | int data_out;
|
| 71 | | int atn_ack;
|
| 72 | | |
| 73 | | /* interrupts */
|
| 74 | | int via0_irq; /* VIA #0 interrupt request */
|
| 75 | | int via1_irq; /* VIA #1 interrupt request */
|
| 76 | | int cia_irq; /* CIA interrupt request */
|
| 77 | | |
| 78 | | /* devices */
|
| 79 | | const device_config *cpu;
|
| 80 | | const device_config *via0;
|
| 81 | | const device_config *via1;
|
| 82 | | const device_config *cia;
|
| 83 | | const device_config *wd1770;
|
| 84 | | const device_config *serial_bus;
|
| 85 | | const device_config *image;
|
| 86 | | |
| 87 | | /* timers */
|
| 88 | | emu_timer *bit_timer;
|
| 89 | | };
|
| 90 | | |
| 91 | | /***************************************************************************
|
| 92 | | INLINE FUNCTIONS
|
| 93 | | ***************************************************************************/
|
| 94 | | |
| 95 | | INLINE c1571_t *get_safe_token(const device_config *device)
|
| 96 | | {
|
| 97 | | assert(device != NULL);
|
| 98 | | assert(device->token != NULL);
|
| 99 | | assert((device->type == C1570) || (device->type == C1571) || (device->type == C1571CR));
|
| 100 | | return (c1571_t *)device->token;
|
| 101 | | }
|
| 102 | | |
| 103 | | INLINE c1571_config *get_safe_config(const device_config *device)
|
| 104 | | {
|
| 105 | | assert(device != NULL);
|
| 106 | | assert((device->type == C1570) || (device->type == C1571) || (device->type == C1571CR));
|
| 107 | | return (c1571_config *)device->inline_config;
|
| 108 | | }
|
| 109 | | |
| 110 | | /***************************************************************************
|
| 111 | | IMPLEMENTATION
|
| 112 | | ***************************************************************************/
|
| 113 | | |
| 114 | | /*-------------------------------------------------
|
| 115 | | TIMER_CALLBACK( bit_tick )
|
| 116 | | -------------------------------------------------*/
|
| 117 | | |
| 118 | | static TIMER_CALLBACK( bit_tick )
|
| 119 | | {
|
| 120 | | const device_config *device = (device_config *)ptr;
|
| 121 | | c1571_t *c1571 = get_safe_token(device);
|
| 122 | | int byte = 0;
|
| 123 | | |
| 124 | | /* shift in data from the read head */
|
| 125 | | c1571->data <<= 1;
|
| 126 | | c1571->data |= BIT(c1571->track_buffer[c1571->buffer_pos], c1571->bit_pos);
|
| 127 | | c1571->bit_pos--;
|
| 128 | | c1571->bit_count++;
|
| 129 | | |
| 130 | | if (c1571->bit_pos < 0)
|
| 131 | | {
|
| 132 | | c1571->bit_pos = 7;
|
| 133 | | c1571->buffer_pos++;
|
| 134 | | |
| 135 | | if (c1571->buffer_pos > c1571->track_len + 1)
|
| 136 | | {
|
| 137 | | /* loop to the start of the track */
|
| 138 | | c1571->buffer_pos = TRACK_DATA_START;
|
| 139 | | }
|
| 140 | | }
|
| 141 | | |
| 142 | | if ((c1571->data & SYNC_MARK) == SYNC_MARK)
|
| 143 | | {
|
| 144 | | /* SYNC detected */
|
| 145 | | c1571->bit_count = 0;
|
| 146 | | }
|
| 147 | | |
| 148 | | if (c1571->bit_count > 7)
|
| 149 | | {
|
| 150 | | /* byte ready */
|
| 151 | | c1571->bit_count = 0;
|
| 152 | | byte = 1;
|
| 153 | | |
| 154 | | if (!(c1571->data & 0xff))
|
| 155 | | {
|
| 156 | | /* simulate weak bits with randomness */
|
| 157 | | c1571->data = (c1571->data & 0xff00) | (mame_rand(machine) & 0xff);
|
| 158 | | }
|
| 159 | | }
|
| 160 | | |
| 161 | | if (c1571->byte != byte)
|
| 162 | | {
|
| 163 | | int byte_ready = !(byte && c1571->soe);
|
| 164 | | |
| 165 | | cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
|
| 166 | | via_ca1_w(c1571->via1, 0, byte_ready);
|
| 167 | | |
| 168 | | c1571->byte = byte;
|
| 169 | | }
|
| 170 | | }
|
| 171 | | |
| 172 | | /*-------------------------------------------------
|
| 173 | | c1571_iec_atn_w - serial bus attention
|
| 174 | | -------------------------------------------------*/
|
| 175 | | |
| 176 | | WRITE_LINE_DEVICE_HANDLER( c1571_iec_atn_w )
|
| 177 | | {
|
| 178 | | c1571_t *c1571 = get_safe_token(device);
|
| 179 | | int data_out = !c1571->data_out && !(c1571->atn_ack ^ !state);
|
| 180 | | |
| 181 | | via_ca1_w(c1571->via0, 0, !state);
|
| 182 | | |
| 183 | | cbm_iec_data_w(c1571->serial_bus, device, data_out);
|
| 184 | | }
|
| 185 | | |
| 186 | | /*-------------------------------------------------
|
| 187 | | c1571_iec_reset_w - serial bus reset
|
| 188 | | -------------------------------------------------*/
|
| 189 | | |
| 190 | | WRITE_LINE_DEVICE_HANDLER( c1571_iec_reset_w )
|
| 191 | | {
|
| 192 | | if (!state)
|
| 193 | | {
|
| 194 | | device_reset(device);
|
| 195 | | }
|
| 196 | | }
|
| 197 | | |
| 198 | | /*-------------------------------------------------
|
| 199 | | ADDRESS_MAP( c1570_map )
|
| 200 | | -------------------------------------------------*/
|
| 201 | | |
| 202 | | static ADDRESS_MAP_START( c1570_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 203 | | AM_RANGE(0x0000, 0x07ff) AM_RAM
|
| 204 | | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
|
| 205 | | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
|
| 206 | | AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
|
| 207 | | AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, cia_r, cia_w)
|
| 208 | | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1570", 0)
|
| 209 | | ADDRESS_MAP_END
|
| 210 | | |
| 211 | | /*-------------------------------------------------
|
| 212 | | ADDRESS_MAP( c1571_map )
|
| 213 | | -------------------------------------------------*/
|
| 214 | | |
| 215 | | static ADDRESS_MAP_START( c1571_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 216 | | AM_RANGE(0x0000, 0x07ff) AM_RAM
|
| 217 | | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
|
| 218 | | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
|
| 219 | | AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
|
| 220 | | AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, cia_r, cia_w)
|
| 221 | | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571", 0)
|
| 222 | | ADDRESS_MAP_END
|
| 223 | | |
| 224 | | /*-------------------------------------------------
|
| 225 | | ADDRESS_MAP( c1571cr_map )
|
| 226 | | -------------------------------------------------*/
|
| 227 | | |
| 228 | | static ADDRESS_MAP_START( c1571cr_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 229 | | AM_RANGE(0x0000, 0x07ff) AM_RAM
|
| 230 | | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
|
| 231 | | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
|
| 232 | | // AM_RANGE(0x2000, 0x2005) 5710 FDC
|
| 233 | | // AM_RANGE(0x400c, 0x400e) 5710 CIA
|
| 234 | | // AM_RANGE(0x4010, 0x4017) 5710 CIA
|
| 235 | | // AM_RANGE(0x6000, 0x7fff) RAM mirrors
|
| 236 | | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571cr", 0)
|
| 237 | | ADDRESS_MAP_END
|
| 238 | | |
| 239 | | /*-------------------------------------------------
|
| 240 | | via6522_interface c1571_via0_intf
|
| 241 | | -------------------------------------------------*/
|
| 242 | | |
| 243 | | static WRITE_LINE_DEVICE_HANDLER( via0_irq_w )
|
| 244 | | {
|
| 245 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 246 | | |
| 247 | | c1571->via0_irq = state;
|
| 248 | | |
| 249 | | cpu_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE);
|
| 250 | | }
|
| 251 | | |
| 252 | | static READ8_DEVICE_HANDLER( via0_pa_r )
|
| 253 | | {
|
| 254 | | /*
|
| 255 | | |
| 256 | | bit description
|
| 257 | | |
| 258 | | PA0 TRK0 SNS
|
| 259 | | PA1 SER DIR
|
| 260 | | PA2 SIDE
|
| 261 | | PA3
|
| 262 | | PA4
|
| 263 | | PA5 _1/2 MHZ
|
| 264 | | PA6 ATN OUT
|
| 265 | | PA7 BYTE RDY
|
| 266 | | |
| 267 | | */
|
| 268 | | |
| 269 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 270 | | |
| 271 | | return floppy_tk00_r(c1571->image);
|
| 272 | | }
|
| 273 | | |
| 274 | | static WRITE8_DEVICE_HANDLER( via0_pa_w )
|
| 275 | | {
|
| 276 | | /*
|
| 277 | | |
| 278 | | bit description
|
| 279 | | |
| 280 | | PA0 TRK0 SNS
|
| 281 | | PA1 SER DIR
|
| 282 | | PA2 SIDE
|
| 283 | | PA3
|
| 284 | | PA4
|
| 285 | | PA5 _1/2 MHZ
|
| 286 | | PA6 ATN OUT
|
| 287 | | PA7 BYTE RDY
|
| 288 | | |
| 289 | | */
|
| 290 | | |
| 291 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 292 | | |
| 293 | | /* 1/2 MHz */
|
| 294 | | UINT32 clock = BIT(data, 5) ? XTAL_16MHz/8 : XTAL_16MHz/16;
|
| 295 | | |
| 296 | | device_set_clock(c1571->cpu, clock);
|
| 297 | | device_set_clock(c1571->cia, clock);
|
| 298 | | device_set_clock(c1571->via0, clock);
|
| 299 | | device_set_clock(c1571->via1, clock);
|
| 300 | | |
| 301 | | /* side */
|
| 302 | | wd17xx_set_side(c1571->wd1770, BIT(data, 2));
|
| 303 | | }
|
| 304 | | |
| 305 | | static READ8_DEVICE_HANDLER( via0_pb_r )
|
| 306 | | {
|
| 307 | | /*
|
| 308 | | |
| 309 | | bit description
|
| 310 | | |
| 311 | | PB0 DATA IN
|
| 312 | | PB1 DATA OUT
|
| 313 | | PB2 CLK IN
|
| 314 | | PB3 CLK OUT
|
| 315 | | PB4 ATN ACK
|
| 316 | | PB5 DEV# SEL
|
| 317 | | PB6 DEV# SEL
|
| 318 | | PB7 ATN IN
|
| 319 | | |
| 320 | | */
|
| 321 | | |
| 322 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 323 | | UINT8 data = 0;
|
| 324 | | |
| 325 | | /* data in */
|
| 326 | | data = !cbm_iec_data_r(c1571->serial_bus);
|
| 327 | | |
| 328 | | /* clock in */
|
| 329 | | data |= !cbm_iec_clk_r(c1571->serial_bus) << 2;
|
| 330 | | |
| 331 | | /* serial bus address */
|
| 332 | | data |= c1571->address << 5;
|
| 333 | | |
| 334 | | /* attention in */
|
| 335 | | data |= !cbm_iec_atn_r(c1571->serial_bus) << 7;
|
| 336 | | |
| 337 | | return data;
|
| 338 | | }
|
| 339 | | |
| 340 | | static WRITE8_DEVICE_HANDLER( via0_pb_w )
|
| 341 | | {
|
| 342 | | /*
|
| 343 | | |
| 344 | | bit description
|
| 345 | | |
| 346 | | PB0 DATA IN
|
| 347 | | PB1 DATA OUT
|
| 348 | | PB2 CLK IN
|
| 349 | | PB3 CLK OUT
|
| 350 | | PB4 ATN ACK
|
| 351 | | PB5 DEV# SEL
|
| 352 | | PB6 DEV# SEL
|
| 353 | | PB7 ATN IN
|
| 354 | | |
| 355 | | */
|
| 356 | | |
| 357 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 358 | | |
| 359 | | int data_out = BIT(data, 1);
|
| 360 | | int clk_out = BIT(data, 3);
|
| 361 | | int atn_ack = BIT(data, 4);
|
| 362 | | |
| 363 | | /* data out */
|
| 364 | | int serial_data = !data_out && !(atn_ack ^ !cbm_iec_atn_r(c1571->serial_bus));
|
| 365 | | cbm_iec_data_w(c1571->serial_bus, device->owner, serial_data);
|
| 366 | | c1571->data_out = data_out;
|
| 367 | | |
| 368 | | /* clock out */
|
| 369 | | cbm_iec_clk_w(c1571->serial_bus, device->owner, !clk_out);
|
| 370 | | |
| 371 | | /* attention acknowledge */
|
| 372 | | c1571->atn_ack = atn_ack;
|
| 373 | | }
|
| 374 | | |
| 375 | | static const via6522_interface c1571_via0_intf =
|
| 376 | | {
|
| 377 | | DEVCB_HANDLER(via0_pa_r),
|
| 378 | | DEVCB_HANDLER(via0_pb_r),
|
| 379 | | DEVCB_NULL,
|
| 380 | | DEVCB_NULL,
|
| 381 | | DEVCB_NULL,
|
| 382 | | DEVCB_NULL,
|
| 383 | | |
| 384 | | DEVCB_HANDLER(via0_pa_w),
|
| 385 | | DEVCB_HANDLER(via0_pb_w),
|
| 386 | | DEVCB_NULL, /* ATN IN */
|
| 387 | | DEVCB_NULL,
|
| 388 | | DEVCB_NULL, /* _WPRT */
|
| 389 | | DEVCB_NULL,
|
| 390 | | |
| 391 | | DEVCB_LINE(via0_irq_w)
|
| 392 | | };
|
| 393 | | |
| 394 | | /*-------------------------------------------------
|
| 395 | | via6522_interface c1571_via1_intf
|
| 396 | | -------------------------------------------------*/
|
| 397 | | |
| 398 | | static WRITE_LINE_DEVICE_HANDLER( via1_irq_w )
|
| 399 | | {
|
| 400 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 401 | | |
| 402 | | c1571->via1_irq = state;
|
| 403 | | |
| 404 | | cpu_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE);
|
| 405 | | }
|
| 406 | | |
| 407 | | static READ8_DEVICE_HANDLER( yb_r )
|
| 408 | | {
|
| 409 | | /*
|
| 410 | | |
| 411 | | bit description
|
| 412 | | |
| 413 | | PA0 YB0
|
| 414 | | PA1 YB1
|
| 415 | | PA2 YB2
|
| 416 | | PA3 YB3
|
| 417 | | PA4 YB4
|
| 418 | | PA5 YB5
|
| 419 | | PA6 YB6
|
| 420 | | PA7 YB7
|
| 421 | | |
| 422 | | */
|
| 423 | | |
| 424 | | return 0;
|
| 425 | | }
|
| 426 | | |
| 427 | | static WRITE8_DEVICE_HANDLER( yb_w )
|
| 428 | | {
|
| 429 | | /*
|
| 430 | | |
| 431 | | bit description
|
| 432 | | |
| 433 | | PA0 YB0
|
| 434 | | PA1 YB1
|
| 435 | | PA2 YB2
|
| 436 | | PA3 YB3
|
| 437 | | PA4 YB4
|
| 438 | | PA5 YB5
|
| 439 | | PA6 YB6
|
| 440 | | PA7 YB7
|
| 441 | | |
| 442 | | */
|
| 443 | | }
|
| 444 | | |
| 445 | | static READ8_DEVICE_HANDLER( via1_pb_r )
|
| 446 | | {
|
| 447 | | /*
|
| 448 | | |
| 449 | | bit signal description
|
| 450 | | |
| 451 | | PB0 STP0 stepping motor bit 0
|
| 452 | | PB1 STP1 stepping motor bit 1
|
| 453 | | PB2 MTR motor ON/OFF
|
| 454 | | PB3 ACT drive 0 LED
|
| 455 | | PB4 _WPRT write protect sense
|
| 456 | | PB5 DS0 density select 0
|
| 457 | | PB6 DS1 density select 1
|
| 458 | | PB7 _SYNC SYNC detect line
|
| 459 | | |
| 460 | | */
|
| 461 | | |
| 462 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 463 | | UINT8 data = 0;
|
| 464 | | |
| 465 | | /* write protect sense */
|
| 466 | | data |= !floppy_wpt_r(c1571->image) << 4;
|
| 467 | | |
| 468 | | /* SYNC detect line */
|
| 469 | | |
| 470 | | return data;
|
| 471 | | }
|
| 472 | | |
| 473 | | static WRITE8_DEVICE_HANDLER( via1_pb_w )
|
| 474 | | {
|
| 475 | | /*
|
| 476 | | |
| 477 | | bit signal description
|
| 478 | | |
| 479 | | PB0 STP0 stepping motor bit 0
|
| 480 | | PB1 STP1 stepping motor bit 1
|
| 481 | | PB2 MTR motor ON/OFF
|
| 482 | | PB3 ACT drive 0 LED
|
| 483 | | PB4 _WPRT write protect sense
|
| 484 | | PB5 DS0 density select 0
|
| 485 | | PB6 DS1 density select 1
|
| 486 | | PB7 _SYNC SYNC detect line
|
| 487 | | |
| 488 | | */
|
| 489 | | |
| 490 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 491 | | int stp = data & 0x03;
|
| 492 | | int ds = (data >> 5) & 0x03;
|
| 493 | | int mtr = BIT(data, 2);
|
| 494 | | |
| 495 | | /* stepper motor */
|
| 496 | | if (c1571->stp != stp)
|
| 497 | | {
|
| 498 | | int tracks = 0;
|
| 499 | | |
| 500 | | switch (c1571->stp)
|
| 501 | | {
|
| 502 | | case 0: if (stp == 1) tracks++; else if (stp == 3) tracks--; break;
|
| 503 | | case 1: if (stp == 2) tracks++; else if (stp == 0) tracks--; break;
|
| 504 | | case 2: if (stp == 3) tracks++; else if (stp == 1) tracks--; break;
|
| 505 | | case 3: if (stp == 0) tracks++; else if (stp == 2) tracks--; break;
|
| 506 | | }
|
| 507 | | |
| 508 | | if (tracks != 0)
|
| 509 | | {
|
| 510 | | c1571->track_len = TRACK_BUFFER_SIZE;
|
| 511 | | c1571->buffer_pos = TRACK_DATA_START;
|
| 512 | | c1571->bit_pos = 7;
|
| 513 | | c1571->bit_count = 0;
|
| 514 | | |
| 515 | | /* step read/write head */
|
| 516 | | floppy_drive_seek(c1571->image, tracks);
|
| 517 | | |
| 518 | | /* read track data */
|
| 519 | | floppy_drive_read_track_data_info_buffer(c1571->image, 0, c1571->track_buffer, &c1571->track_len);
|
| 520 | | |
| 521 | | /* extract track length */
|
| 522 | | c1571->track_len = (c1571->track_buffer[1] << 8) | c1571->track_buffer[0];
|
| 523 | | }
|
| 524 | | |
| 525 | | c1571->stp = stp;
|
| 526 | | }
|
| 527 | | |
| 528 | | /* spindle motor */
|
| 529 | | floppy_mon_w(c1571->image, !mtr);
|
| 530 | | timer_enable(c1571->bit_timer, mtr);
|
| 531 | | |
| 532 | | /* activity LED */
|
| 533 | | |
| 534 | | /* density select */
|
| 535 | | if (c1571->ds != ds)
|
| 536 | | {
|
| 537 | | timer_adjust_periodic(c1571->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C1571_BITRATE[ds]/4));
|
| 538 | | c1571->ds = ds;
|
| 539 | | }
|
| 540 | | }
|
| 541 | | |
| 542 | | static WRITE_LINE_DEVICE_HANDLER( soe_w )
|
| 543 | | {
|
| 544 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 545 | | int byte_ready = !(state && c1571->byte);
|
| 546 | | |
| 547 | | c1571->soe = state;
|
| 548 | | |
| 549 | | cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready);
|
| 550 | | via_ca1_w(device, 0, byte_ready);
|
| 551 | | }
|
| 552 | | |
| 553 | | static WRITE_LINE_DEVICE_HANDLER( mode_w )
|
| 554 | | {
|
| 555 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 556 | | |
| 557 | | c1571->mode = state;
|
| 558 | | }
|
| 559 | | |
| 560 | | static const via6522_interface c1571_via1_intf =
|
| 561 | | {
|
| 562 | | DEVCB_HANDLER(yb_r),
|
| 563 | | DEVCB_HANDLER(via1_pb_r),
|
| 564 | | DEVCB_NULL, /* BYTE READY */
|
| 565 | | DEVCB_NULL,
|
| 566 | | DEVCB_NULL,
|
| 567 | | DEVCB_NULL,
|
| 568 | | |
| 569 | | DEVCB_HANDLER(yb_w),
|
| 570 | | DEVCB_HANDLER(via1_pb_w),
|
| 571 | | DEVCB_NULL,
|
| 572 | | DEVCB_NULL,
|
| 573 | | DEVCB_LINE(soe_w),
|
| 574 | | DEVCB_LINE(mode_w),
|
| 575 | | |
| 576 | | DEVCB_LINE(via1_irq_w)
|
| 577 | | };
|
| 578 | | |
| 579 | | /*-------------------------------------------------
|
| 580 | | cia6526_interface c1571_cia_intf
|
| 581 | | -------------------------------------------------*/
|
| 582 | | |
| 583 | | static WRITE_LINE_DEVICE_HANDLER( cia_irq_w )
|
| 584 | | {
|
| 585 | | c1571_t *c1571 = get_safe_token(device->owner);
|
| 586 | | |
| 587 | | c1571->cia_irq = state;
|
| 588 | | |
| 589 | | cpu_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE);
|
| 590 | | }
|
| 591 | | |
| 592 | | static const cia6526_interface c1571_cia_intf =
|
| 593 | | {
|
| 594 | | DEVCB_LINE(cia_irq_w),
|
| 595 | | DEVCB_NULL,
|
| 596 | | 10, /* 1/10 second */
|
| 597 | | {
|
| 598 | | { DEVCB_NULL, DEVCB_NULL },
|
| 599 | | { DEVCB_NULL, DEVCB_NULL }
|
| 600 | | }
|
| 601 | | };
|
| 602 | | |
| 603 | | /*-------------------------------------------------
|
| 604 | | wd17xx_interface c1571_wd1770_intf
|
| 605 | | -------------------------------------------------*/
|
| 606 | | |
| 607 | | static const wd17xx_interface c1571_wd1770_intf =
|
| 608 | | {
|
| 609 | | DEVCB_NULL,
|
| 610 | | DEVCB_NULL,
|
| 611 | | { FLOPPY_0, NULL, NULL, NULL }
|
| 612 | | };
|
| 613 | | |
| 614 | | /*-------------------------------------------------
|
| 615 | | FLOPPY_OPTIONS( c1571 )
|
| 616 | | -------------------------------------------------*/
|
| 617 | | |
| 618 | | static FLOPPY_OPTIONS_START( c1571 )
|
| 619 | | FLOPPY_OPTION( c1571, "g64", "Commodore 1571 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
|
| 620 | | // FLOPPY_OPTION( c1571, "d64", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
|
| 621 | | // FLOPPY_OPTION( c1571, "d71", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
|
| 622 | | FLOPPY_OPTIONS_END
|
| 623 | | |
| 624 | | /*-------------------------------------------------
|
| 625 | | floppy_config c1570_floppy_config
|
| 626 | | -------------------------------------------------*/
|
| 627 | | |
| 628 | | static const floppy_config c1570_floppy_config =
|
| 629 | | {
|
| 630 | | DEVCB_NULL,
|
| 631 | | DEVCB_NULL,
|
| 632 | | DEVCB_NULL,
|
| 633 | | DEVCB_NULL,
|
| 634 | | DEVCB_NULL,
|
| 635 | | FLOPPY_DRIVE_SS_80,
|
| 636 | | FLOPPY_OPTIONS_NAME(c1571),
|
| 637 | | DO_NOT_KEEP_GEOMETRY
|
| 638 | | };
|
| 639 | | |
| 640 | | /*-------------------------------------------------
|
| 641 | | floppy_config c1571_floppy_config
|
| 642 | | -------------------------------------------------*/
|
| 643 | | |
| 644 | | static const floppy_config c1571_floppy_config =
|
| 645 | | {
|
| 646 | | DEVCB_NULL,
|
| 647 | | DEVCB_NULL,
|
| 648 | | DEVCB_NULL,
|
| 649 | | DEVCB_NULL,
|
| 650 | | DEVCB_NULL,
|
| 651 | | FLOPPY_DRIVE_DS_80,
|
| 652 | | FLOPPY_OPTIONS_NAME(c1571),
|
| 653 | | DO_NOT_KEEP_GEOMETRY
|
| 654 | | };
|
| 655 | | |
| 656 | | /*-------------------------------------------------
|
| 657 | | MACHINE_DRIVER( c1570 )
|
| 658 | | -------------------------------------------------*/
|
| 659 | | |
| 660 | | static MACHINE_DRIVER_START( c1570 )
|
| 661 | | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/8)
|
| 662 | | MDRV_CPU_PROGRAM_MAP(c1570_map)
|
| 663 | | |
| 664 | | MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/8, c1571_via0_intf)
|
| 665 | | MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/8, c1571_via1_intf)
|
| 666 | | MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/8, c1571_cia_intf)
|
| 667 | | MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf)
|
| 668 | | |
| 669 | | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1570_floppy_config)
|
| 670 | | MACHINE_DRIVER_END
|
| 671 | | |
| 672 | | /*-------------------------------------------------
|
| 673 | | MACHINE_DRIVER( c1571 )
|
| 674 | | -------------------------------------------------*/
|
| 675 | | |
| 676 | | static MACHINE_DRIVER_START( c1571 )
|
| 677 | | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/8)
|
| 678 | | MDRV_CPU_PROGRAM_MAP(c1571_map)
|
| 679 | | |
| 680 | | MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/8, c1571_via0_intf)
|
| 681 | | MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/8, c1571_via1_intf)
|
| 682 | | MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/8, c1571_cia_intf)
|
| 683 | | MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf)
|
| 684 | | |
| 685 | | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1571_floppy_config)
|
| 686 | | MACHINE_DRIVER_END
|
| 687 | | |
| 688 | | /*-------------------------------------------------
|
| 689 | | MACHINE_DRIVER( c1571cr )
|
| 690 | | -------------------------------------------------*/
|
| 691 | | |
| 692 | | static MACHINE_DRIVER_START( c1571cr )
|
| 693 | | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/8)
|
| 694 | | MDRV_CPU_PROGRAM_MAP(c1571cr_map)
|
| 695 | | |
| 696 | | MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/8, c1571_via0_intf)
|
| 697 | | MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/8, c1571_via1_intf)
|
| 698 | | MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/8, c1571_cia_intf)
|
| 699 | | MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf)
|
| 700 | | |
| 701 | | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1571_floppy_config)
|
| 702 | | MACHINE_DRIVER_END
|
| 703 | | |
| 704 | | /*-------------------------------------------------
|
| 705 | | ROM( c1570 )
|
| 706 | | -------------------------------------------------*/
|
| 707 | | |
| 708 | | ROM_START( c1570 )
|
| 709 | | ROM_REGION( 0x8000, "c1570", ROMREGION_LOADBYNAME )
|
| 710 | | ROM_LOAD( "315090-01.u2", 0x0000, 0x8000, CRC(5a0c7937) SHA1(5fc06dc82ff6840f183bd43a4d9b8a16956b2f56) )
|
| 711 | | ROM_END
|
| 712 | | |
| 713 | | /*-------------------------------------------------
|
| 714 | | ROM( c1571 )
|
| 715 | | -------------------------------------------------*/
|
| 716 | | |
| 717 | | ROM_START( c1571 )
|
| 718 | | ROM_REGION( 0x8000, "c1571", ROMREGION_LOADBYNAME )
|
| 719 | | ROM_LOAD( "310654-03.u2", 0x0000, 0x8000, CRC(3889b8b8) SHA1(e649ef4419d65829d2afd65e07d31f3ce147d6eb) )
|
| 720 | | ROM_LOAD( "310654-05.u2", 0x0000, 0x8000, CRC(5755bae3) SHA1(f1be619c106641a685f6609e4d43d6fc9eac1e70) )
|
| 721 | | ROM_END
|
| 722 | | |
| 723 | | /*-------------------------------------------------
|
| 724 | | ROM( c1571cr )
|
| 725 | | -------------------------------------------------*/
|
| 726 | | |
| 727 | | ROM_START( c1571cr )
|
| 728 | | ROM_REGION( 0x8000, "c1571cr", ROMREGION_LOADBYNAME )
|
| 729 | | ROM_LOAD( "318047-01.", 0x0000, 0x8000, CRC(f24efcc4) SHA1(14ee7a0fb7e1c59c51fbf781f944387037daa3ee) )
|
| 730 | | ROM_END
|
| 731 | | |
| 732 | | /*-------------------------------------------------
|
| 733 | | DEVICE_START( c1571 )
|
| 734 | | -------------------------------------------------*/
|
| 735 | | |
| 736 | | static DEVICE_START( c1571 )
|
| 737 | | {
|
| 738 | | c1571_t *c1571 = get_safe_token(device);
|
| 739 | | const c1571_config *config = get_safe_config(device);
|
| 740 | | |
| 741 | | /* set serial address */
|
| 742 | | assert((config->address > 7) && (config->address < 12));
|
| 743 | | c1571->address = config->address - 8;
|
| 744 | | |
| 745 | | /* find our CPU */
|
| 746 | | c1571->cpu = device_find_child_by_tag(device, M6502_TAG);
|
| 747 | | |
| 748 | | /* find devices */
|
| 749 | | c1571->via0 = device_find_child_by_tag(device, M6522_0_TAG);
|
| 750 | | c1571->via1 = device_find_child_by_tag(device, M6522_1_TAG);
|
| 751 | | c1571->cia = device_find_child_by_tag(device, M6526_TAG);
|
| 752 | | c1571->wd1770 = device_find_child_by_tag(device, WD1770_TAG);
|
| 753 | | c1571->serial_bus = devtag_get_device(device->machine, config->serial_bus_tag);
|
| 754 | | c1571->image = device_find_child_by_tag(device, FLOPPY_0);
|
| 755 | | |
| 756 | | /* set floppy density */
|
| 757 | | wd17xx_set_density(c1571->wd1770, DEN_MFM_LO);
|
| 758 | | |
| 759 | | /* allocate data timer */
|
| 760 | | c1571->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device);
|
| 761 | | |
| 762 | | /* register for state saving */
|
| 763 | | }
|
| 764 | | |
| 765 | | /*-------------------------------------------------
|
| 766 | | DEVICE_RESET( c1571 )
|
| 767 | | -------------------------------------------------*/
|
| 768 | | |
| 769 | | static DEVICE_RESET( c1571 )
|
| 770 | | {
|
| 771 | | c1571_t *c1571 = get_safe_token(device);
|
| 772 | | |
| 773 | | device_reset(c1571->cpu);
|
| 774 | | device_reset(c1571->via0);
|
| 775 | | device_reset(c1571->via1);
|
| 776 | | device_reset(c1571->cia);
|
| 777 | | device_reset(c1571->wd1770);
|
| 778 | | }
|
| 779 | | |
| 780 | | /*-------------------------------------------------
|
| 781 | | DEVICE_GET_INFO( c1570 )
|
| 782 | | -------------------------------------------------*/
|
| 783 | | |
| 784 | | DEVICE_GET_INFO( c1570 )
|
| 785 | | {
|
| 786 | | switch (state)
|
| 787 | | {
|
| 788 | | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 789 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(c1571_t); break;
|
| 790 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(c1571_config); break;
|
| 791 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
|
| 792 | | |
| 793 | | /* --- the following bits of info are returned as pointers --- */
|
| 794 | | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(c1570); break;
|
| 795 | | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(c1570); break;
|
| 796 | | |
| 797 | | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 798 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1571); break;
|
| 799 | | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 800 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1571); break;
|
| 801 | | |
| 802 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 803 | | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1570"); break;
|
| 804 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Commodore 1571"); break;
|
| 805 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
| 806 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
| 807 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break;
|
| 808 | | }
|
| 809 | | }
|
| 810 | | |
| 811 | | /*-------------------------------------------------
|
| 812 | | DEVICE_GET_INFO( c1571 )
|
| 813 | | -------------------------------------------------*/
|
| 814 | | |
| 815 | | DEVICE_GET_INFO( c1571 )
|
| 816 | | {
|
| 817 | | switch (state)
|
| 818 | | {
|
| 819 | | /* --- the following bits of info are returned as pointers --- */
|
| 820 | | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(c1571); break;
|
| 821 | | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(c1571); break;
|
| 822 | | |
| 823 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 824 | | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1571"); break;
|
| 825 | | |
| 826 | | default: DEVICE_GET_INFO_CALL(c1570); break;
|
| 827 | | }
|
| 828 | | }
|
| 829 | | |
| 830 | | /*-------------------------------------------------
|
| 831 | | DEVICE_GET_INFO( c1571cr )
|
| 832 | | -------------------------------------------------*/
|
| 833 | | |
| 834 | | DEVICE_GET_INFO( c1571cr )
|
| 835 | | {
|
| 836 | | switch (state)
|
| 837 | | {
|
| 838 | | /* --- the following bits of info are returned as pointers --- */
|
| 839 | | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(c1571cr); break;
|
| 840 | | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(c1571cr); break;
|
| 841 | | |
| 842 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 843 | | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1571CR"); break;
|
| 844 | | |
| 845 | | default: DEVICE_GET_INFO_CALL(c1570); break;
|
| 846 | | }
|
| 847 | | }
|
| 1 | /********************************************************************** |
| 2 | |
| 3 | Commodore 1570/1571/1571CR Single Disk Drive emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "driver.h" |
| 11 | #include "c1571.h" |
| 12 | #include "cpu/m6502/m6502.h" |
| 13 | #include "devices/flopdrv.h" |
| 14 | #include "formats/g64_dsk.h" |
| 15 | #include "machine/6522via.h" |
| 16 | #include "machine/6526cia.h" |
| 17 | #include "machine/cbmiec.h" |
| 18 | #include "machine/wd17xx.h" |
| 19 | |
| 20 | /*************************************************************************** |
| 21 | PARAMETERS |
| 22 | ***************************************************************************/ |
| 23 | |
| 24 | #define LOG 0 |
| 25 | |
| 26 | #define M6502_TAG "u1" |
| 27 | #define M6522_0_TAG "u4" |
| 28 | #define M6522_1_TAG "u9" |
| 29 | #define M6526_TAG "u20" |
| 30 | #define WD1770_TAG "u11" |
| 31 | |
| 32 | static const double C1571_BITRATE[4] = |
| 33 | { |
| 34 | XTAL_16MHz/13.0, /* tracks 1-17 */ |
| 35 | XTAL_16MHz/14.0, /* tracks 18-24 */ |
| 36 | XTAL_16MHz/15.0, /* tracks 25-30 */ |
| 37 | XTAL_16MHz/16.0 /* tracks 31-42 */ |
| 38 | }; |
| 39 | |
| 40 | #define SYNC_MARK 0x3ff /* 10 consecutive 1-bits */ |
| 41 | |
| 42 | #define TRACK_BUFFER_SIZE 8194 /* 2 bytes track length + maximum of 8192 bytes of GCR encoded data */ |
| 43 | #define TRACK_DATA_START 2 |
| 44 | |
| 45 | /*************************************************************************** |
| 46 | TYPE DEFINITIONS |
| 47 | ***************************************************************************/ |
| 48 | |
| 49 | typedef struct _c1571_t c1571_t; |
| 50 | struct _c1571_t |
| 51 | { |
| 52 | /* abstractions */ |
| 53 | int address; |
| 54 | UINT8 track_buffer[TRACK_BUFFER_SIZE]; /* track data buffer */ |
| 55 | int track_len; /* track length */ |
| 56 | int buffer_pos; /* current byte position within track buffer */ |
| 57 | int bit_pos; /* current bit position within track buffer byte */ |
| 58 | int bit_count; /* current data byte bit counter */ |
| 59 | UINT16 data; /* data shift register */ |
| 60 | |
| 61 | /* signals */ |
| 62 | UINT8 yb; /* GCR data byte to write */ |
| 63 | int byte; /* byte ready */ |
| 64 | int atna; /* attention acknowledge */ |
| 65 | int ds; /* density select */ |
| 66 | int stp; /* stepping motor */ |
| 67 | int soe; /* s? output enable */ |
| 68 | int mode; /* mode (0 = write, 1 = read) */ |
| 69 | |
| 70 | int data_out; |
| 71 | int atn_ack; |
| 72 | |
| 73 | /* interrupts */ |
| 74 | int via0_irq; /* VIA #0 interrupt request */ |
| 75 | int via1_irq; /* VIA #1 interrupt request */ |
| 76 | int cia_irq; /* CIA interrupt request */ |
| 77 | |
| 78 | /* devices */ |
| 79 | const device_config *cpu; |
| 80 | const device_config *via0; |
| 81 | const device_config *via1; |
| 82 | const device_config *cia; |
| 83 | const device_config *wd1770; |
| 84 | const device_config *serial_bus; |
| 85 | const device_config *image; |
| 86 | |
| 87 | /* timers */ |
| 88 | emu_timer *bit_timer; |
| 89 | }; |
| 90 | |
| 91 | /*************************************************************************** |
| 92 | INLINE FUNCTIONS |
| 93 | ***************************************************************************/ |
| 94 | |
| 95 | INLINE c1571_t *get_safe_token(const device_config *device) |
| 96 | { |
| 97 | assert(device != NULL); |
| 98 | assert(device->token != NULL); |
| 99 | assert((device->type == C1570) || (device->type == C1571) || (device->type == C1571CR)); |
| 100 | return (c1571_t *)device->token; |
| 101 | } |
| 102 | |
| 103 | INLINE c1571_config *get_safe_config(const device_config *device) |
| 104 | { |
| 105 | assert(device != NULL); |
| 106 | assert((device->type == C1570) || (device->type == C1571) || (device->type == C1571CR)); |
| 107 | return (c1571_config *)device->inline_config; |
| 108 | } |
| 109 | |
| 110 | /*************************************************************************** |
| 111 | IMPLEMENTATION |
| 112 | ***************************************************************************/ |
| 113 | |
| 114 | /*------------------------------------------------- |
| 115 | TIMER_CALLBACK( bit_tick ) |
| 116 | -------------------------------------------------*/ |
| 117 | |
| 118 | static TIMER_CALLBACK( bit_tick ) |
| 119 | { |
| 120 | const device_config *device = (device_config *)ptr; |
| 121 | c1571_t *c1571 = get_safe_token(device); |
| 122 | int byte = 0; |
| 123 | |
| 124 | /* shift in data from the read head */ |
| 125 | c1571->data <<= 1; |
| 126 | c1571->data |= BIT(c1571->track_buffer[c1571->buffer_pos], c1571->bit_pos); |
| 127 | c1571->bit_pos--; |
| 128 | c1571->bit_count++; |
| 129 | |
| 130 | if (c1571->bit_pos < 0) |
| 131 | { |
| 132 | c1571->bit_pos = 7; |
| 133 | c1571->buffer_pos++; |
| 134 | |
| 135 | if (c1571->buffer_pos > c1571->track_len + 1) |
| 136 | { |
| 137 | /* loop to the start of the track */ |
| 138 | c1571->buffer_pos = TRACK_DATA_START; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if ((c1571->data & SYNC_MARK) == SYNC_MARK) |
| 143 | { |
| 144 | /* SYNC detected */ |
| 145 | c1571->bit_count = 0; |
| 146 | } |
| 147 | |
| 148 | if (c1571->bit_count > 7) |
| 149 | { |
| 150 | /* byte ready */ |
| 151 | c1571->bit_count = 0; |
| 152 | byte = 1; |
| 153 | |
| 154 | if (!(c1571->data & 0xff)) |
| 155 | { |
| 156 | /* simulate weak bits with randomness */ |
| 157 | c1571->data = (c1571->data & 0xff00) | (mame_rand(machine) & 0xff); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if (c1571->byte != byte) |
| 162 | { |
| 163 | int byte_ready = !(byte && c1571->soe); |
| 164 | |
| 165 | cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready); |
| 166 | via_ca1_w(c1571->via1, 0, byte_ready); |
| 167 | |
| 168 | c1571->byte = byte; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /*------------------------------------------------- |
| 173 | c1571_iec_atn_w - serial bus attention |
| 174 | -------------------------------------------------*/ |
| 175 | |
| 176 | WRITE_LINE_DEVICE_HANDLER( c1571_iec_atn_w ) |
| 177 | { |
| 178 | c1571_t *c1571 = get_safe_token(device); |
| 179 | int data_out = !c1571->data_out && !(c1571->atn_ack ^ !state); |
| 180 | |
| 181 | via_ca1_w(c1571->via0, 0, !state); |
| 182 | |
| 183 | cbm_iec_data_w(c1571->serial_bus, device, data_out); |
| 184 | } |
| 185 | |
| 186 | /*------------------------------------------------- |
| 187 | c1571_iec_reset_w - serial bus reset |
| 188 | -------------------------------------------------*/ |
| 189 | |
| 190 | WRITE_LINE_DEVICE_HANDLER( c1571_iec_reset_w ) |
| 191 | { |
| 192 | if (!state) |
| 193 | { |
| 194 | device_reset(device); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | /*------------------------------------------------- |
| 199 | ADDRESS_MAP( c1570_map ) |
| 200 | -------------------------------------------------*/ |
| 201 | |
| 202 | static ADDRESS_MAP_START( c1570_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 203 | AM_RANGE(0x0000, 0x07ff) AM_RAM |
| 204 | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w) |
| 205 | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w) |
| 206 | AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w) |
| 207 | AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, cia_r, cia_w) |
| 208 | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1570", 0) |
| 209 | ADDRESS_MAP_END |
| 210 | |
| 211 | /*------------------------------------------------- |
| 212 | ADDRESS_MAP( c1571_map ) |
| 213 | -------------------------------------------------*/ |
| 214 | |
| 215 | static ADDRESS_MAP_START( c1571_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 216 | AM_RANGE(0x0000, 0x07ff) AM_RAM |
| 217 | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w) |
| 218 | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w) |
| 219 | AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w) |
| 220 | AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, cia_r, cia_w) |
| 221 | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571", 0) |
| 222 | ADDRESS_MAP_END |
| 223 | |
| 224 | /*------------------------------------------------- |
| 225 | ADDRESS_MAP( c1571cr_map ) |
| 226 | -------------------------------------------------*/ |
| 227 | |
| 228 | static ADDRESS_MAP_START( c1571cr_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 229 | AM_RANGE(0x0000, 0x07ff) AM_RAM |
| 230 | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w) |
| 231 | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w) |
| 232 | // AM_RANGE(0x2000, 0x2005) 5710 FDC |
| 233 | // AM_RANGE(0x400c, 0x400e) 5710 CIA |
| 234 | // AM_RANGE(0x4010, 0x4017) 5710 CIA |
| 235 | // AM_RANGE(0x6000, 0x7fff) RAM mirrors |
| 236 | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571cr", 0) |
| 237 | ADDRESS_MAP_END |
| 238 | |
| 239 | /*------------------------------------------------- |
| 240 | via6522_interface c1571_via0_intf |
| 241 | -------------------------------------------------*/ |
| 242 | |
| 243 | static WRITE_LINE_DEVICE_HANDLER( via0_irq_w ) |
| 244 | { |
| 245 | c1571_t *c1571 = get_safe_token(device->owner); |
| 246 | |
| 247 | c1571->via0_irq = state; |
| 248 | |
| 249 | cpu_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 250 | } |
| 251 | |
| 252 | static READ8_DEVICE_HANDLER( via0_pa_r ) |
| 253 | { |
| 254 | /* |
| 255 | |
| 256 | bit description |
| 257 | |
| 258 | PA0 TRK0 SNS |
| 259 | PA1 SER DIR |
| 260 | PA2 SIDE |
| 261 | PA3 |
| 262 | PA4 |
| 263 | PA5 _1/2 MHZ |
| 264 | PA6 ATN OUT |
| 265 | PA7 BYTE RDY |
| 266 | |
| 267 | */ |
| 268 | |
| 269 | c1571_t *c1571 = get_safe_token(device->owner); |
| 270 | |
| 271 | return floppy_tk00_r(c1571->image); |
| 272 | } |
| 273 | |
| 274 | static WRITE8_DEVICE_HANDLER( via0_pa_w ) |
| 275 | { |
| 276 | /* |
| 277 | |
| 278 | bit description |
| 279 | |
| 280 | PA0 TRK0 SNS |
| 281 | PA1 SER DIR |
| 282 | PA2 SIDE |
| 283 | PA3 |
| 284 | PA4 |
| 285 | PA5 _1/2 MHZ |
| 286 | PA6 ATN OUT |
| 287 | PA7 BYTE RDY |
| 288 | |
| 289 | */ |
| 290 | |
| 291 | c1571_t *c1571 = get_safe_token(device->owner); |
| 292 | |
| 293 | /* 1/2 MHz */ |
| 294 | UINT32 clock = BIT(data, 5) ? XTAL_16MHz/8 : XTAL_16MHz/16; |
| 295 | |
| 296 | device_set_clock(c1571->cpu, clock); |
| 297 | device_set_clock(c1571->cia, clock); |
| 298 | device_set_clock(c1571->via0, clock); |
| 299 | device_set_clock(c1571->via1, clock); |
| 300 | |
| 301 | /* side */ |
| 302 | wd17xx_set_side(c1571->wd1770, BIT(data, 2)); |
| 303 | } |
| 304 | |
| 305 | static READ8_DEVICE_HANDLER( via0_pb_r ) |
| 306 | { |
| 307 | /* |
| 308 | |
| 309 | bit description |
| 310 | |
| 311 | PB0 DATA IN |
| 312 | PB1 DATA OUT |
| 313 | PB2 CLK IN |
| 314 | PB3 CLK OUT |
| 315 | PB4 ATN ACK |
| 316 | PB5 DEV# SEL |
| 317 | PB6 DEV# SEL |
| 318 | PB7 ATN IN |
| 319 | |
| 320 | */ |
| 321 | |
| 322 | c1571_t *c1571 = get_safe_token(device->owner); |
| 323 | UINT8 data = 0; |
| 324 | |
| 325 | /* data in */ |
| 326 | data = !cbm_iec_data_r(c1571->serial_bus); |
| 327 | |
| 328 | /* clock in */ |
| 329 | data |= !cbm_iec_clk_r(c1571->serial_bus) << 2; |
| 330 | |
| 331 | /* serial bus address */ |
| 332 | data |= c1571->address << 5; |
| 333 | |
| 334 | /* attention in */ |
| 335 | data |= !cbm_iec_atn_r(c1571->serial_bus) << 7; |
| 336 | |
| 337 | return data; |
| 338 | } |
| 339 | |
| 340 | static WRITE8_DEVICE_HANDLER( via0_pb_w ) |
| 341 | { |
| 342 | /* |
| 343 | |
| 344 | bit description |
| 345 | |
| 346 | PB0 DATA IN |
| 347 | PB1 DATA OUT |
| 348 | PB2 CLK IN |
| 349 | PB3 CLK OUT |
| 350 | PB4 ATN ACK |
| 351 | PB5 DEV# SEL |
| 352 | PB6 DEV# SEL |
| 353 | PB7 ATN IN |
| 354 | |
| 355 | */ |
| 356 | |
| 357 | c1571_t *c1571 = get_safe_token(device->owner); |
| 358 | |
| 359 | int data_out = BIT(data, 1); |
| 360 | int clk_out = BIT(data, 3); |
| 361 | int atn_ack = BIT(data, 4); |
| 362 | |
| 363 | /* data out */ |
| 364 | int serial_data = !data_out && !(atn_ack ^ !cbm_iec_atn_r(c1571->serial_bus)); |
| 365 | cbm_iec_data_w(c1571->serial_bus, device->owner, serial_data); |
| 366 | c1571->data_out = data_out; |
| 367 | |
| 368 | /* clock out */ |
| 369 | cbm_iec_clk_w(c1571->serial_bus, device->owner, !clk_out); |
| 370 | |
| 371 | /* attention acknowledge */ |
| 372 | c1571->atn_ack = atn_ack; |
| 373 | } |
| 374 | |
| 375 | static const via6522_interface c1571_via0_intf = |
| 376 | { |
| 377 | DEVCB_HANDLER(via0_pa_r), |
| 378 | DEVCB_HANDLER(via0_pb_r), |
| 379 | DEVCB_NULL, |
| 380 | DEVCB_NULL, |
| 381 | DEVCB_NULL, |
| 382 | DEVCB_NULL, |
| 383 | |
| 384 | DEVCB_HANDLER(via0_pa_w), |
| 385 | DEVCB_HANDLER(via0_pb_w), |
| 386 | DEVCB_NULL, /* ATN IN */ |
| 387 | DEVCB_NULL, |
| 388 | DEVCB_NULL, /* _WPRT */ |
| 389 | DEVCB_NULL, |
| 390 | |
| 391 | DEVCB_LINE(via0_irq_w) |
| 392 | }; |
| 393 | |
| 394 | /*------------------------------------------------- |
| 395 | via6522_interface c1571_via1_intf |
| 396 | -------------------------------------------------*/ |
| 397 | |
| 398 | static WRITE_LINE_DEVICE_HANDLER( via1_irq_w ) |
| 399 | { |
| 400 | c1571_t *c1571 = get_safe_token(device->owner); |
| 401 | |
| 402 | c1571->via1_irq = state; |
| 403 | |
| 404 | cpu_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 405 | } |
| 406 | |
| 407 | static READ8_DEVICE_HANDLER( yb_r ) |
| 408 | { |
| 409 | /* |
| 410 | |
| 411 | bit description |
| 412 | |
| 413 | PA0 YB0 |
| 414 | PA1 YB1 |
| 415 | PA2 YB2 |
| 416 | PA3 YB3 |
| 417 | PA4 YB4 |
| 418 | PA5 YB5 |
| 419 | PA6 YB6 |
| 420 | PA7 YB7 |
| 421 | |
| 422 | */ |
| 423 | |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | static WRITE8_DEVICE_HANDLER( yb_w ) |
| 428 | { |
| 429 | /* |
| 430 | |
| 431 | bit description |
| 432 | |
| 433 | PA0 YB0 |
| 434 | PA1 YB1 |
| 435 | PA2 YB2 |
| 436 | PA3 YB3 |
| 437 | PA4 YB4 |
| 438 | PA5 YB5 |
| 439 | PA6 YB6 |
| 440 | PA7 YB7 |
| 441 | |
| 442 | */ |
| 443 | } |
| 444 | |
| 445 | static READ8_DEVICE_HANDLER( via1_pb_r ) |
| 446 | { |
| 447 | /* |
| 448 | |
| 449 | bit signal description |
| 450 | |
| 451 | PB0 STP0 stepping motor bit 0 |
| 452 | PB1 STP1 stepping motor bit 1 |
| 453 | PB2 MTR motor ON/OFF |
| 454 | PB3 ACT drive 0 LED |
| 455 | PB4 _WPRT write protect sense |
| 456 | PB5 DS0 density select 0 |
| 457 | PB6 DS1 density select 1 |
| 458 | PB7 _SYNC SYNC detect line |
| 459 | |
| 460 | */ |
| 461 | |
| 462 | c1571_t *c1571 = get_safe_token(device->owner); |
| 463 | UINT8 data = 0; |
| 464 | |
| 465 | /* write protect sense */ |
| 466 | data |= !floppy_wpt_r(c1571->image) << 4; |
| 467 | |
| 468 | /* SYNC detect line */ |
| 469 | |
| 470 | return data; |
| 471 | } |
| 472 | |
| 473 | static WRITE8_DEVICE_HANDLER( via1_pb_w ) |
| 474 | { |
| 475 | /* |
| 476 | |
| 477 | bit signal description |
| 478 | |
| 479 | PB0 STP0 stepping motor bit 0 |
| 480 | PB1 STP1 stepping motor bit 1 |
| 481 | PB2 MTR motor ON/OFF |
| 482 | PB3 ACT drive 0 LED |
| 483 | PB4 _WPRT write protect sense |
| 484 | PB5 DS0 density select 0 |
| 485 | PB6 DS1 density select 1 |
| 486 | PB7 _SYNC SYNC detect line |
| 487 | |
| 488 | */ |
| 489 | |
| 490 | c1571_t *c1571 = get_safe_token(device->owner); |
| 491 | int stp = data & 0x03; |
| 492 | int ds = (data >> 5) & 0x03; |
| 493 | int mtr = BIT(data, 2); |
| 494 | |
| 495 | /* stepper motor */ |
| 496 | if (c1571->stp != stp) |
| 497 | { |
| 498 | int tracks = 0; |
| 499 | |
| 500 | switch (c1571->stp) |
| 501 | { |
| 502 | case 0: if (stp == 1) tracks++; else if (stp == 3) tracks--; break; |
| 503 | case 1: if (stp == 2) tracks++; else if (stp == 0) tracks--; break; |
| 504 | case 2: if (stp == 3) tracks++; else if (stp == 1) tracks--; break; |
| 505 | case 3: if (stp == 0) tracks++; else if (stp == 2) tracks--; break; |
| 506 | } |
| 507 | |
| 508 | if (tracks != 0) |
| 509 | { |
| 510 | c1571->track_len = TRACK_BUFFER_SIZE; |
| 511 | c1571->buffer_pos = TRACK_DATA_START; |
| 512 | c1571->bit_pos = 7; |
| 513 | c1571->bit_count = 0; |
| 514 | |
| 515 | /* step read/write head */ |
| 516 | floppy_drive_seek(c1571->image, tracks); |
| 517 | |
| 518 | /* read track data */ |
| 519 | floppy_drive_read_track_data_info_buffer(c1571->image, 0, c1571->track_buffer, &c1571->track_len); |
| 520 | |
| 521 | /* extract track length */ |
| 522 | c1571->track_len = (c1571->track_buffer[1] << 8) | c1571->track_buffer[0]; |
| 523 | } |
| 524 | |
| 525 | c1571->stp = stp; |
| 526 | } |
| 527 | |
| 528 | /* spindle motor */ |
| 529 | floppy_mon_w(c1571->image, !mtr); |
| 530 | timer_enable(c1571->bit_timer, mtr); |
| 531 | |
| 532 | /* activity LED */ |
| 533 | |
| 534 | /* density select */ |
| 535 | if (c1571->ds != ds) |
| 536 | { |
| 537 | timer_adjust_periodic(c1571->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C1571_BITRATE[ds]/4)); |
| 538 | c1571->ds = ds; |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | static WRITE_LINE_DEVICE_HANDLER( soe_w ) |
| 543 | { |
| 544 | c1571_t *c1571 = get_safe_token(device->owner); |
| 545 | int byte_ready = !(state && c1571->byte); |
| 546 | |
| 547 | c1571->soe = state; |
| 548 | |
| 549 | cpu_set_input_line(c1571->cpu, M6502_SET_OVERFLOW, byte_ready); |
| 550 | via_ca1_w(device, 0, byte_ready); |
| 551 | } |
| 552 | |
| 553 | static WRITE_LINE_DEVICE_HANDLER( mode_w ) |
| 554 | { |
| 555 | c1571_t *c1571 = get_safe_token(device->owner); |
| 556 | |
| 557 | c1571->mode = state; |
| 558 | } |
| 559 | |
| 560 | static const via6522_interface c1571_via1_intf = |
| 561 | { |
| 562 | DEVCB_HANDLER(yb_r), |
| 563 | DEVCB_HANDLER(via1_pb_r), |
| 564 | DEVCB_NULL, /* BYTE READY */ |
| 565 | DEVCB_NULL, |
| 566 | DEVCB_NULL, |
| 567 | DEVCB_NULL, |
| 568 | |
| 569 | DEVCB_HANDLER(yb_w), |
| 570 | DEVCB_HANDLER(via1_pb_w), |
| 571 | DEVCB_NULL, |
| 572 | DEVCB_NULL, |
| 573 | DEVCB_LINE(soe_w), |
| 574 | DEVCB_LINE(mode_w), |
| 575 | |
| 576 | DEVCB_LINE(via1_irq_w) |
| 577 | }; |
| 578 | |
| 579 | /*------------------------------------------------- |
| 580 | cia6526_interface c1571_cia_intf |
| 581 | -------------------------------------------------*/ |
| 582 | |
| 583 | static WRITE_LINE_DEVICE_HANDLER( cia_irq_w ) |
| 584 | { |
| 585 | c1571_t *c1571 = get_safe_token(device->owner); |
| 586 | |
| 587 | c1571->cia_irq = state; |
| 588 | |
| 589 | cpu_set_input_line(c1571->cpu, INPUT_LINE_IRQ0, (c1571->via0_irq | c1571->via1_irq | c1571->cia_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 590 | } |
| 591 | |
| 592 | static const cia6526_interface c1571_cia_intf = |
| 593 | { |
| 594 | DEVCB_LINE(cia_irq_w), |
| 595 | DEVCB_NULL, |
| 596 | 10, /* 1/10 second */ |
| 597 | { |
| 598 | { DEVCB_NULL, DEVCB_NULL }, |
| 599 | { DEVCB_NULL, DEVCB_NULL } |
| 600 | } |
| 601 | }; |
| 602 | |
| 603 | /*------------------------------------------------- |
| 604 | wd17xx_interface c1571_wd1770_intf |
| 605 | -------------------------------------------------*/ |
| 606 | |
| 607 | static const wd17xx_interface c1571_wd1770_intf = |
| 608 | { |
| 609 | DEVCB_NULL, |
| 610 | DEVCB_NULL, |
| 611 | { FLOPPY_0, NULL, NULL, NULL } |
| 612 | }; |
| 613 | |
| 614 | /*------------------------------------------------- |
| 615 | FLOPPY_OPTIONS( c1571 ) |
| 616 | -------------------------------------------------*/ |
| 617 | |
| 618 | static FLOPPY_OPTIONS_START( c1571 ) |
| 619 | FLOPPY_OPTION( c1571, "g64", "Commodore 1571 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL ) |
| 620 | // FLOPPY_OPTION( c1571, "d64", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL ) |
| 621 | // FLOPPY_OPTION( c1571, "d71", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL ) |
| 622 | FLOPPY_OPTIONS_END |
| 623 | |
| 624 | /*------------------------------------------------- |
| 625 | floppy_config c1570_floppy_config |
| 626 | -------------------------------------------------*/ |
| 627 | |
| 628 | static const floppy_config c1570_floppy_config = |
| 629 | { |
| 630 | DEVCB_NULL, |
| 631 | DEVCB_NULL, |
| 632 | DEVCB_NULL, |
| 633 | DEVCB_NULL, |
| 634 | DEVCB_NULL, |
| 635 | FLOPPY_DRIVE_SS_80, |
| 636 | FLOPPY_OPTIONS_NAME(c1571), |
| 637 | DO_NOT_KEEP_GEOMETRY |
| 638 | }; |
| 639 | |
| 640 | /*------------------------------------------------- |
| 641 | floppy_config c1571_floppy_config |
| 642 | -------------------------------------------------*/ |
| 643 | |
| 644 | static const floppy_config c1571_floppy_config = |
| 645 | { |
| 646 | DEVCB_NULL, |
| 647 | DEVCB_NULL, |
| 648 | DEVCB_NULL, |
| 649 | DEVCB_NULL, |
| 650 | DEVCB_NULL, |
| 651 | FLOPPY_DRIVE_DS_80, |
| 652 | FLOPPY_OPTIONS_NAME(c1571), |
| 653 | DO_NOT_KEEP_GEOMETRY |
| 654 | }; |
| 655 | |
| 656 | /*------------------------------------------------- |
| 657 | MACHINE_DRIVER( c1570 ) |
| 658 | -------------------------------------------------*/ |
| 659 | |
| 660 | static MACHINE_DRIVER_START( c1570 ) |
| 661 | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/8) |
| 662 | MDRV_CPU_PROGRAM_MAP(c1570_map) |
| 663 | |
| 664 | MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/8, c1571_via0_intf) |
| 665 | MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/8, c1571_via1_intf) |
| 666 | MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/8, c1571_cia_intf) |
| 667 | MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf) |
| 668 | |
| 669 | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1570_floppy_config) |
| 670 | MACHINE_DRIVER_END |
| 671 | |
| 672 | /*------------------------------------------------- |
| 673 | MACHINE_DRIVER( c1571 ) |
| 674 | -------------------------------------------------*/ |
| 675 | |
| 676 | static MACHINE_DRIVER_START( c1571 ) |
| 677 | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/8) |
| 678 | MDRV_CPU_PROGRAM_MAP(c1571_map) |
| 679 | |
| 680 | MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/8, c1571_via0_intf) |
| 681 | MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/8, c1571_via1_intf) |
| 682 | MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/8, c1571_cia_intf) |
| 683 | MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf) |
| 684 | |
| 685 | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1571_floppy_config) |
| 686 | MACHINE_DRIVER_END |
| 687 | |
| 688 | /*------------------------------------------------- |
| 689 | MACHINE_DRIVER( c1571cr ) |
| 690 | -------------------------------------------------*/ |
| 691 | |
| 692 | static MACHINE_DRIVER_START( c1571cr ) |
| 693 | MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/8) |
| 694 | MDRV_CPU_PROGRAM_MAP(c1571cr_map) |
| 695 | |
| 696 | MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/8, c1571_via0_intf) |
| 697 | MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/8, c1571_via1_intf) |
| 698 | MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/8, c1571_cia_intf) |
| 699 | MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf) |
| 700 | |
| 701 | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c1571_floppy_config) |
| 702 | MACHINE_DRIVER_END |
| 703 | |
| 704 | /*------------------------------------------------- |
| 705 | ROM( c1570 ) |
| 706 | -------------------------------------------------*/ |
| 707 | |
| 708 | ROM_START( c1570 ) |
| 709 | ROM_REGION( 0x8000, "c1570", ROMREGION_LOADBYNAME ) |
| 710 | ROM_LOAD( "315090-01.u2", 0x0000, 0x8000, CRC(5a0c7937) SHA1(5fc06dc82ff6840f183bd43a4d9b8a16956b2f56) ) |
| 711 | ROM_END |
| 712 | |
| 713 | /*------------------------------------------------- |
| 714 | ROM( c1571 ) |
| 715 | -------------------------------------------------*/ |
| 716 | |
| 717 | ROM_START( c1571 ) |
| 718 | ROM_REGION( 0x8000, "c1571", ROMREGION_LOADBYNAME ) |
| 719 | ROM_LOAD( "310654-03.u2", 0x0000, 0x8000, CRC(3889b8b8) SHA1(e649ef4419d65829d2afd65e07d31f3ce147d6eb) ) |
| 720 | ROM_LOAD( "310654-05.u2", 0x0000, 0x8000, CRC(5755bae3) SHA1(f1be619c106641a685f6609e4d43d6fc9eac1e70) ) |
| 721 | ROM_END |
| 722 | |
| 723 | /*------------------------------------------------- |
| 724 | ROM( c1571cr ) |
| 725 | -------------------------------------------------*/ |
| 726 | |
| 727 | ROM_START( c1571cr ) |
| 728 | ROM_REGION( 0x8000, "c1571cr", ROMREGION_LOADBYNAME ) |
| 729 | ROM_LOAD( "318047-01.", 0x0000, 0x8000, CRC(f24efcc4) SHA1(14ee7a0fb7e1c59c51fbf781f944387037daa3ee) ) |
| 730 | ROM_END |
| 731 | |
| 732 | /*------------------------------------------------- |
| 733 | DEVICE_START( c1571 ) |
| 734 | -------------------------------------------------*/ |
| 735 | |
| 736 | static DEVICE_START( c1571 ) |
| 737 | { |
| 738 | c1571_t *c1571 = get_safe_token(device); |
| 739 | const c1571_config *config = get_safe_config(device); |
| 740 | |
| 741 | /* set serial address */ |
| 742 | assert((config->address > 7) && (config->address < 12)); |
| 743 | c1571->address = config->address - 8; |
| 744 | |
| 745 | /* find our CPU */ |
| 746 | c1571->cpu = device_find_child_by_tag(device, M6502_TAG); |
| 747 | |
| 748 | /* find devices */ |
| 749 | c1571->via0 = device_find_child_by_tag(device, M6522_0_TAG); |
| 750 | c1571->via1 = device_find_child_by_tag(device, M6522_1_TAG); |
| 751 | c1571->cia = device_find_child_by_tag(device, M6526_TAG); |
| 752 | c1571->wd1770 = device_find_child_by_tag(device, WD1770_TAG); |
| 753 | c1571->serial_bus = devtag_get_device(device->machine, config->serial_bus_tag); |
| 754 | c1571->image = device_find_child_by_tag(device, FLOPPY_0); |
| 755 | |
| 756 | /* set floppy density */ |
| 757 | wd17xx_set_density(c1571->wd1770, DEN_MFM_LO); |
| 758 | |
| 759 | /* allocate data timer */ |
| 760 | c1571->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device); |
| 761 | |
| 762 | /* register for state saving */ |
| 763 | } |
| 764 | |
| 765 | /*------------------------------------------------- |
| 766 | DEVICE_RESET( c1571 ) |
| 767 | -------------------------------------------------*/ |
| 768 | |
| 769 | static DEVICE_RESET( c1571 ) |
| 770 | { |
| 771 | c1571_t *c1571 = get_safe_token(device); |
| 772 | |
| 773 | device_reset(c1571->cpu); |
| 774 | device_reset(c1571->via0); |
| 775 | device_reset(c1571->via1); |
| 776 | device_reset(c1571->cia); |
| 777 | device_reset(c1571->wd1770); |
| 778 | } |
| 779 | |
| 780 | /*------------------------------------------------- |
| 781 | DEVICE_GET_INFO( c1570 ) |
| 782 | -------------------------------------------------*/ |
| 783 | |
| 784 | DEVICE_GET_INFO( c1570 ) |
| 785 | { |
| 786 | switch (state) |
| 787 | { |
| 788 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 789 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(c1571_t); break; |
| 790 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(c1571_config); break; |
| 791 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 792 | |
| 793 | /* --- the following bits of info are returned as pointers --- */ |
| 794 | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(c1570); break; |
| 795 | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(c1570); break; |
| 796 | |
| 797 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 798 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(c1571); break; |
| 799 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 800 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(c1571); break; |
| 801 | |
| 802 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 803 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1570"); break; |
| 804 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Commodore 1571"); break; |
| 805 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 806 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 807 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | /*------------------------------------------------- |
| 812 | DEVICE_GET_INFO( c1571 ) |
| 813 | -------------------------------------------------*/ |
| 814 | |
| 815 | DEVICE_GET_INFO( c1571 ) |
| 816 | { |
| 817 | switch (state) |
| 818 | { |
| 819 | /* --- the following bits of info are returned as pointers --- */ |
| 820 | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(c1571); break; |
| 821 | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(c1571); break; |
| 822 | |
| 823 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 824 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1571"); break; |
| 825 | |
| 826 | default: DEVICE_GET_INFO_CALL(c1570); break; |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | /*------------------------------------------------- |
| 831 | DEVICE_GET_INFO( c1571cr ) |
| 832 | -------------------------------------------------*/ |
| 833 | |
| 834 | DEVICE_GET_INFO( c1571cr ) |
| 835 | { |
| 836 | switch (state) |
| 837 | { |
| 838 | /* --- the following bits of info are returned as pointers --- */ |
| 839 | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(c1571cr); break; |
| 840 | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(c1571cr); break; |
| 841 | |
| 842 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 843 | case DEVINFO_STR_NAME: strcpy(info->s, "Commodore 1571CR"); break; |
| 844 | |
| 845 | default: DEVICE_GET_INFO_CALL(c1570); break; |
| 846 | } |
| 847 | } |
src/mess/machine/i8257.c
| r6857 | r6858 | |
| 1 | | /***************************************************************************
|
| 2 | | |
| 3 | | Intel 8257 Programmable DMA Controller emulation
|
| 4 | | |
| 5 | | Copyright MESS Team.
|
| 6 | | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | | |
| 8 | | ***************************************************************************/
|
| 9 | | |
| 10 | | /*
|
| 11 | | |
| 12 | | TODO:
|
| 13 | | |
| 14 | | - use cr/ar directly
|
| 15 | | |
| 16 | | */
|
| 17 | | |
| 18 | | #include "driver.h"
|
| 19 | | #include "i8257.h"
|
| 20 | | |
| 21 | | /***************************************************************************
|
| 22 | | CONSTANTS
|
| 23 | | ***************************************************************************/
|
| 24 | | |
| 25 | | #define LOG 0
|
| 26 | | |
| 27 | | #define I8257_STATUS_TC0 0x01
|
| 28 | | #define I8257_STATUS_TC1 0x02
|
| 29 | | #define I8257_STATUS_TC2 0x04
|
| 30 | | #define I8257_STATUS_TC3 0x08
|
| 31 | | #define I8257_STATUS_UP 0x10
|
| 32 | | |
| 33 | | #define I8257_MODE_EN0 0x01
|
| 34 | | #define I8257_MODE_EN1 0x02
|
| 35 | | #define I8257_MODE_EN2 0x04
|
| 36 | | #define I8257_MODE_EN3 0x08
|
| 37 | | #define I8257_MODE_RP 0x10
|
| 38 | | #define I8257_MODE_EW 0x20
|
| 39 | | #define I8257_MODE_TCS 0x40
|
| 40 | | #define I8257_MODE_AL 0x80
|
| 41 | | |
| 42 | | enum
|
| 43 | | {
|
| 44 | | STATE_SI,
|
| 45 | | STATE_S0,
|
| 46 | | STATE_S1,
|
| 47 | | STATE_S2,
|
| 48 | | STATE_S3,
|
| 49 | | STATE_SW,
|
| 50 | | STATE_SU,
|
| 51 | | STATE_S4
|
| 52 | | };
|
| 53 | | |
| 54 | | enum
|
| 55 | | {
|
| 56 | | MODE_VERIFY = 0,
|
| 57 | | MODE_WRITE,
|
| 58 | | MODE_READ,
|
| 59 | | MODE_ILLEGAL
|
| 60 | | };
|
| 61 | | |
| 62 | | /***************************************************************************
|
| 63 | | TYPE DEFINITIONS
|
| 64 | | ***************************************************************************/
|
| 65 | | |
| 66 | | typedef struct _dma8257_t i8257_t;
|
| 67 | | struct _dma8257_t
|
| 68 | | {
|
| 69 | | devcb_resolved_write_line out_hrq_func;
|
| 70 | | devcb_resolved_write_line out_tc_func;
|
| 71 | | devcb_resolved_write_line out_mark_func;
|
| 72 | | devcb_resolved_read8 in_memr_func[I8257_CHANNELS];
|
| 73 | | devcb_resolved_write8 out_memw_func[I8257_CHANNELS];
|
| 74 | | devcb_resolved_read8 in_ior_func[I8257_CHANNELS];
|
| 75 | | devcb_resolved_write8 out_iow_func[I8257_CHANNELS];
|
| 76 | | devcb_resolved_write_line out_dack_func[I8257_CHANNELS];
|
| 77 | | |
| 78 | | /* registers */
|
| 79 | | UINT8 mr; /* mode register */
|
| 80 | | UINT8 sr; /* status register */
|
| 81 | | UINT16 ar[I8257_CHANNELS]; /* address register */
|
| 82 | | UINT16 cr[I8257_CHANNELS]; /* count register */
|
| 83 | | int fl; /* first/last flip-flop */
|
| 84 | | |
| 85 | | /* inputs */
|
| 86 | | int drq[I8257_CHANNELS]; /* data request */
|
| 87 | | int hlda; /* hold acknowledge */
|
| 88 | | int ready; /* ready */
|
| 89 | | |
| 90 | | /* outputs */
|
| 91 | | int tc; /* terminal count */
|
| 92 | | int mark; /* mark */
|
| 93 | | |
| 94 | | /* transfer */
|
| 95 | | int state; /* DMA state */
|
| 96 | | int channel; /* current channel being serviced */
|
| 97 | | int priority; /* highest priority channel */
|
| 98 | | UINT8 data; /* DMA data */
|
| 99 | | UINT16 address; /* DMA address */
|
| 100 | | UINT16 count; /* DMA counter */
|
| 101 | | int mode; /* DMA transfer type */
|
| 102 | | |
| 103 | | /* timers */
|
| 104 | | emu_timer *dma_timer;
|
| 105 | | };
|
| 106 | | |
| 107 | | /***************************************************************************
|
| 108 | | INLINE FUNCTIONS
|
| 109 | | ***************************************************************************/
|
| 110 | | |
| 111 | | INLINE i8257_t *get_safe_token(const device_config *device)
|
| 112 | | {
|
| 113 | | assert(device != NULL);
|
| 114 | | assert(device->token != NULL);
|
| 115 | | assert(device->type == I8257);
|
| 116 | | return (i8257_t *) device->token;
|
| 117 | | }
|
| 118 | | |
| 119 | | INLINE const i8257_interface *get_interface(const device_config *device)
|
| 120 | | {
|
| 121 | | assert(device != NULL);
|
| 122 | | assert((device->type == I8257));
|
| 123 | | return (const i8257_interface *) device->static_config;
|
| 124 | | }
|
| 125 | | |
| 126 | | /***************************************************************************
|
| 127 | | IMPLEMENTATION
|
| 128 | | ***************************************************************************/
|
| 129 | | |
| 130 | | static void set_hrq(const device_config *device, int state)
|
| 131 | | {
|
| 132 | | i8257_t *i8257 = get_safe_token(device);
|
| 133 | | |
| 134 | | if (LOG) logerror("I8257 '%s' Hold Request: %u\n", device->tag, state);
|
| 135 | | |
| 136 | | devcb_call_write_line(&i8257->out_hrq_func, state);
|
| 137 | | }
|
| 138 | | |
| 139 | | static void set_tc(const device_config *device, int state)
|
| 140 | | {
|
| 141 | | i8257_t *i8257 = get_safe_token(device);
|
| 142 | | |
| 143 | | if (i8257->tc != state)
|
| 144 | | {
|
| 145 | | if (LOG) logerror("I8257 '%s' Terminal Count: %u\n", device->tag, state);
|
| 146 | | i8257->tc = state;
|
| 147 | | devcb_call_write_line(&i8257->out_tc_func, state);
|
| 148 | | }
|
| 149 | | }
|
| 150 | | |
| 151 | | static void set_mark(const device_config *device, int state)
|
| 152 | | {
|
| 153 | | i8257_t *i8257 = get_safe_token(device);
|
| 154 | | |
| 155 | | if (i8257->mark != state)
|
| 156 | | {
|
| 157 | | if (LOG) logerror("I8257 '%s' Mark: %u\n", device->tag, state);
|
| 158 | | i8257->mark = state;
|
| 159 | | devcb_call_write_line(&i8257->out_mark_func, state);
|
| 160 | | }
|
| 161 | | }
|
| 162 | | |
| 163 | | static void set_dack(const device_config *device, int active_channel)
|
| 164 | | {
|
| 165 | | i8257_t *i8257 = get_safe_token(device);
|
| 166 | | int ch;
|
| 167 | | |
| 168 | | for (ch = 0; ch < I8257_CHANNELS; ch++)
|
| 169 | | {
|
| 170 | | int state = (ch != active_channel);
|
| 171 | | |
| 172 | | if (LOG) logerror("I8257 '%s' DMA Acknowledge %u: %u\n", device->tag, ch, state);
|
| 173 | | |
| 174 | | devcb_call_write_line(&i8257->out_dack_func[ch], state);
|
| 175 | | }
|
| 176 | | }
|
| 177 | | |
| 178 | | static int sample_drq(const device_config *device)
|
| 179 | | {
|
| 180 | | i8257_t *i8257 = get_safe_token(device);
|
| 181 | | int ch;
|
| 182 | | |
| 183 | | for (ch = 0; ch < I8257_CHANNELS; ch++)
|
| 184 | | {
|
| 185 | | if (i8257->drq[ch] && BIT(i8257->mr, ch))
|
| 186 | | {
|
| 187 | | return 1;
|
| 188 | | }
|
| 189 | | }
|
| 190 | | |
| 191 | | return 0;
|
| 192 | | }
|
| 193 | | |
| 194 | | static void resolve_priorities(const device_config *device)
|
| 195 | | {
|
| 196 | | i8257_t *i8257 = get_safe_token(device);
|
| 197 | | int i;
|
| 198 | | |
| 199 | | for (i = 0; i < I8257_CHANNELS; i++)
|
| 200 | | {
|
| 201 | | int ch = (i + i8257->priority) % I8257_CHANNELS;
|
| 202 | | |
| 203 | | if (i8257->drq[ch] && BIT(i8257->mr, ch))
|
| 204 | | {
|
| 205 | | i8257->channel = ch;
|
| 206 | | i8257->address = i8257->ar[ch];
|
| 207 | | i8257->count = i8257->cr[ch] & 0x3fff;
|
| 208 | | i8257->mode = i8257->cr[ch] >> 14;
|
| 209 | | break;
|
| 210 | | }
|
| 211 | | }
|
| 212 | | }
|
| 213 | | |
| 214 | | static void dma_read(const device_config *device)
|
| 215 | | {
|
| 216 | | i8257_t *i8257 = get_safe_token(device);
|
| 217 | | |
| 218 | | switch (i8257->mode)
|
| 219 | | {
|
| 220 | | case MODE_VERIFY:
|
| 221 | | break;
|
| 222 | | |
| 223 | | case MODE_WRITE:
|
| 224 | | i8257->data = devcb_call_read8(&i8257->in_memr_func[i8257->channel], i8257->address);
|
| 225 | | if (LOG) logerror("I8257 '%s' DMA Memory Read %04x: %02x\n", device->tag, i8257->address, i8257->data);
|
| 226 | | break;
|
| 227 | | |
| 228 | | case MODE_READ:
|
| 229 | | i8257->data = devcb_call_read8(&i8257->in_ior_func[i8257->channel], i8257->address);
|
| 230 | | if (LOG) logerror("I8257 '%s' DMA I/O Read %04x: %02x\n", device->tag, i8257->address, i8257->data);
|
| 231 | | break;
|
| 232 | | |
| 233 | | case MODE_ILLEGAL:
|
| 234 | | break;
|
| 235 | | }
|
| 236 | | }
|
| 237 | | |
| 238 | | static void dma_write(const device_config *device)
|
| 239 | | {
|
| 240 | | i8257_t *i8257 = get_safe_token(device);
|
| 241 | | |
| 242 | | switch (i8257->mode)
|
| 243 | | {
|
| 244 | | case MODE_VERIFY:
|
| 245 | | break;
|
| 246 | | |
| 247 | | case MODE_WRITE:
|
| 248 | | devcb_call_write8(&i8257->out_iow_func[i8257->channel], i8257->address, i8257->data);
|
| 249 | | if (LOG) logerror("I8257 '%s' DMA I/O Write %04x: %02x\n", device->tag, i8257->address, i8257->data);
|
| 250 | | break;
|
| 251 | | |
| 252 | | case MODE_READ:
|
| 253 | | devcb_call_write8(&i8257->out_memw_func[i8257->channel], i8257->address, i8257->data);
|
| 254 | | if (LOG) logerror("I8257 '%s' DMA Memory Write %04x: %02x\n", device->tag, i8257->address, i8257->data);
|
| 255 | | break;
|
| 256 | | |
| 257 | | case MODE_ILLEGAL:
|
| 258 | | break;
|
| 259 | | }
|
| 260 | | }
|
| 261 | | |
| 262 | | /*-------------------------------------------------
|
| 263 | | TIMER_CALLBACK( dma_tick )
|
| 264 | | -------------------------------------------------*/
|
| 265 | | |
| 266 | | static TIMER_CALLBACK( dma_tick )
|
| 267 | | {
|
| 268 | | const device_config *device = (const device_config *)ptr;
|
| 269 | | i8257_t *i8257 = get_safe_token(device);
|
| 270 | | int drq = 0;
|
| 271 | | |
| 272 | | switch (i8257->state)
|
| 273 | | {
|
| 274 | | case STATE_SI:
|
| 275 | | /* sample DRQn lines */
|
| 276 | | drq = sample_drq(device);
|
| 277 | | |
| 278 | | /* set HRQ if DRQn = 1 */
|
| 279 | | if (drq)
|
| 280 | | {
|
| 281 | | set_hrq(device, 1);
|
| 282 | | i8257->state = STATE_S0;
|
| 283 | | }
|
| 284 | | break;
|
| 285 | | |
| 286 | | case STATE_S0:
|
| 287 | | /* sample HLDA */
|
| 288 | | if (i8257->hlda)
|
| 289 | | {
|
| 290 | | i8257->state = STATE_S1;
|
| 291 | | }
|
| 292 | | |
| 293 | | /* resolve DRQ priorities */
|
| 294 | | resolve_priorities(device);
|
| 295 | | break;
|
| 296 | | |
| 297 | | case STATE_S1:
|
| 298 | | /* present and data upper address */
|
| 299 | | /* present lower address */
|
| 300 | | i8257->state = STATE_S2;
|
| 301 | | break;
|
| 302 | | |
| 303 | | case STATE_S2:
|
| 304 | | /* activate DACKn */
|
| 305 | | set_dack(device, i8257->channel);
|
| 306 | | |
| 307 | | /* activate read command */
|
| 308 | | dma_read(device);
|
| 309 | | |
| 310 | | /* advanced write command */
|
| 311 | | if (i8257->mr & I8257_MODE_EW)
|
| 312 | | {
|
| 313 | | dma_write(device);
|
| 314 | | }
|
| 315 | | |
| 316 | | i8257->state = STATE_S3;
|
| 317 | | break;
|
| 318 | | |
| 319 | | case STATE_S3:
|
| 320 | | /* activate write command */
|
| 321 | | if (!(i8257->mr & I8257_MODE_EW))
|
| 322 | | {
|
| 323 | | dma_write(device);
|
| 324 | | }
|
| 325 | | |
| 326 | | i8257->address++;
|
| 327 | | i8257->count--;
|
| 328 | | |
| 329 | | /* activate MARK */
|
| 330 | | switch (i8257->count & 0xff)
|
| 331 | | {
|
| 332 | | case 0: case 0x80:
|
| 333 | | set_mark(device, 1);
|
| 334 | | break;
|
| 335 | | }
|
| 336 | | |
| 337 | | /* activate TC */
|
| 338 | | if (i8257->count == 0)
|
| 339 | | {
|
| 340 | | set_tc(device, 1);
|
| 341 | | }
|
| 342 | | |
| 343 | | if (!i8257->ready)
|
| 344 | | {
|
| 345 | | i8257->state = STATE_SW;
|
| 346 | | }
|
| 347 | | else if (i8257->tc && (i8257->channel == 2) && (i8257->mr & I8257_MODE_AL))
|
| 348 | | {
|
| 349 | | i8257->state = STATE_SU;
|
| 350 | | }
|
| 351 | | else
|
| 352 | | {
|
| 353 | | i8257->state = STATE_S4;
|
| 354 | | }
|
| 355 | | break;
|
| 356 | | |
| 357 | | case STATE_SW:
|
| 358 | | /* sample READY line */
|
| 359 | | if (i8257->ready)
|
| 360 | | {
|
| 361 | | if (i8257->tc && (i8257->channel == 2) && (i8257->mr & I8257_MODE_AL))
|
| 362 | | {
|
| 363 | | i8257->state = STATE_SU;
|
| 364 | | }
|
| 365 | | else
|
| 366 | | {
|
| 367 | | i8257->state = STATE_S4;
|
| 368 | | }
|
| 369 | | }
|
| 370 | | break;
|
| 371 | | |
| 372 | | case STATE_SU:
|
| 373 | | i8257->sr |= I8257_STATUS_UP;
|
| 374 | | |
| 375 | | /* auto load channel 2 parameters */
|
| 376 | | i8257->ar[2] = i8257->ar[3];
|
| 377 | | i8257->cr[2] = i8257->cr[3];
|
| 378 | | |
| 379 | | if (LOG)
|
| 380 | | {
|
| 381 | | logerror("I8257 '%s' DMA Channel 2 Address Register: %04x\n", device->tag, i8257->ar[2]);
|
| 382 | | logerror("I8257 '%s' DMA Channel 2 Count Register: %04x\n", device->tag, i8257->cr[2] & 0x3fff);
|
| 383 | | logerror("I8257 '%s' DMA Channel 2 Mode: %u\n", device->tag, i8257->cr[2] >> 14);
|
| 384 | | }
|
| 385 | | |
| 386 | | i8257->state = STATE_S4;
|
| 387 | | break;
|
| 388 | | |
| 389 | | case STATE_S4:
|
| 390 | | i8257->sr &= ~I8257_STATUS_UP;
|
| 391 | | |
| 392 | | if (i8257->tc)
|
| 393 | | {
|
| 394 | | /* reset enable for channel n if TC stop and TC are active */
|
| 395 | | if ((i8257->mr & I8257_MODE_TCS) &&
|
| 396 | | !((i8257->channel == 2) && (i8257->mr & I8257_MODE_AL)))
|
| 397 | | {
|
| 398 | | i8257->mr &= ~(1 << i8257->channel);
|
| 399 | | if (LOG) logerror("I8257 '%s' DMA Channel %u: disabled\n", device->tag, i8257->channel);
|
| 400 | | }
|
| 401 | | |
| 402 | | if (i8257->mr & I8257_MODE_RP)
|
| 403 | | {
|
| 404 | | i8257->priority = (i8257->channel + 1) % I8257_CHANNELS;
|
| 405 | | }
|
| 406 | | |
| 407 | | /* resolve DRQ priorities */
|
| 408 | | resolve_priorities(device);
|
| 409 | | }
|
| 410 | | |
| 411 | | /* deactivate DACKn, MARK and TC */
|
| 412 | | set_dack(device, -1);
|
| 413 | | set_mark(device, 0);
|
| 414 | | set_tc(device, 0);
|
| 415 | | |
| 416 | | /* sample DRQn */
|
| 417 | | drq = sample_drq(device);
|
| 418 | | |
| 419 | | /* reset HRQ if HLDA = 0 or DRQ = 0 */
|
| 420 | | if (!i8257->hlda || !drq)
|
| 421 | | {
|
| 422 | | set_hrq(device, 0);
|
| 423 | | i8257->state = STATE_SI;
|
| 424 | | timer_enable(i8257->dma_timer, 0);
|
| 425 | | }
|
| 426 | | else
|
| 427 | | {
|
| 428 | | i8257->state = STATE_S1;
|
| 429 | | }
|
| 430 | | break;
|
| 431 | | }
|
| 432 | | }
|
| 433 | | |
| 434 | | READ8_DEVICE_HANDLER( i8257_r )
|
| 435 | | {
|
| 436 | | i8257_t *i8257 = get_safe_token(device);
|
| 437 | | UINT8 data = 0;
|
| 438 | | int ch;
|
| 439 | | |
| 440 | | switch (offset & 0x0f)
|
| 441 | | {
|
| 442 | | case 0:
|
| 443 | | case 2:
|
| 444 | | case 4:
|
| 445 | | case 6:
|
| 446 | | ch = offset / 2;
|
| 447 | | |
| 448 | | if (i8257->fl)
|
| 449 | | {
|
| 450 | | data = i8257->ar[ch] >> 8;
|
| 451 | | }
|
| 452 | | else
|
| 453 | | {
|
| 454 | | data = i8257->ar[ch] & 0xff;
|
| 455 | | }
|
| 456 | | |
| 457 | | i8257->fl = !i8257->fl;
|
| 458 | | break;
|
| 459 | | |
| 460 | | case 1:
|
| 461 | | case 3:
|
| 462 | | case 5:
|
| 463 | | case 7:
|
| 464 | | ch = (offset - 1) / 2;
|
| 465 | | |
| 466 | | if (i8257->fl)
|
| 467 | | {
|
| 468 | | data = i8257->cr[ch] >> 8;
|
| 469 | | }
|
| 470 | | else
|
| 471 | | {
|
| 472 | | data = i8257->cr[ch] & 0xff;
|
| 473 | | }
|
| 474 | | |
| 475 | | i8257->fl = !i8257->fl;
|
| 476 | | break;
|
| 477 | | |
| 478 | | case 8:
|
| 479 | | data = i8257->sr;
|
| 480 | | i8257->sr &= ~(I8257_STATUS_TC3 | I8257_STATUS_TC2 | I8257_STATUS_TC1 | I8257_STATUS_TC0);
|
| 481 | | break;
|
| 482 | | }
|
| 483 | | |
| 484 | | return data;
|
| 485 | | }
|
| 486 | | |
| 487 | | WRITE8_DEVICE_HANDLER( i8257_w )
|
| 488 | | {
|
| 489 | | i8257_t *i8257 = get_safe_token(device);
|
| 490 | | int ch;
|
| 491 | | |
| 492 | | switch (offset & 0x0f)
|
| 493 | | {
|
| 494 | | case 0:
|
| 495 | | case 2:
|
| 496 | | case 4:
|
| 497 | | case 6:
|
| 498 | | ch = offset / 2;
|
| 499 | | |
| 500 | | if (i8257->fl)
|
| 501 | | {
|
| 502 | | i8257->ar[ch] = (data << 8) | (i8257->ar[ch] & 0xff);
|
| 503 | | if (LOG) logerror("I8257 '%s' DMA Channel %u Address Register: %04x\n", device->tag, ch, i8257->ar[ch]);
|
| 504 | | }
|
| 505 | | else
|
| 506 | | {
|
| 507 | | i8257->ar[ch] = (i8257->ar[ch] & 0xff00) | data;
|
| 508 | | }
|
| 509 | | |
| 510 | | if ((i8257->mr & I8257_MODE_AL) && (ch == 2))
|
| 511 | | {
|
| 512 | | i8257->ar[3] = i8257->ar[2];
|
| 513 | | }
|
| 514 | | |
| 515 | | i8257->fl = !i8257->fl;
|
| 516 | | break;
|
| 517 | | |
| 518 | | case 1:
|
| 519 | | case 3:
|
| 520 | | case 5:
|
| 521 | | case 7:
|
| 522 | | ch = (offset - 1) / 2;
|
| 523 | | |
| 524 | | if (i8257->fl)
|
| 525 | | {
|
| 526 | | i8257->cr[ch] = (data << 8) | (i8257->cr[ch] & 0xff);
|
| 527 | | if (LOG) logerror("I8257 '%s' DMA Channel %u Count Register: %04x\n", device->tag, ch, i8257->cr[ch] & 0x3fff);
|
| 528 | | if (LOG) logerror("I8257 '%s' DMA Channel %u Mode: %u\n", device->tag, ch, i8257->cr[ch] >> 14);
|
| 529 | | }
|
| 530 | | else
|
| 531 | | {
|
| 532 | | i8257->cr[ch] = (i8257->cr[ch] & 0xff00) | data;
|
| 533 | | }
|
| 534 | | |
| 535 | | if ((i8257->mr & I8257_MODE_AL) && (ch == 2))
|
| 536 | | {
|
| 537 | | i8257->cr[3] = i8257->cr[2];
|
| 538 | | }
|
| 539 | | |
| 540 | | i8257->fl = !i8257->fl;
|
| 541 | | break;
|
| 542 | | |
| 543 | | case 8:
|
| 544 | | i8257->mr = data;
|
| 545 | | i8257->fl = 0;
|
| 546 | | |
| 547 | | if ((i8257->state == STATE_SI) && sample_drq(device))
|
| 548 | | {
|
| 549 | | timer_enable(i8257->dma_timer, 1);
|
| 550 | | }
|
| 551 | | |
| 552 | | if (LOG)
|
| 553 | | {
|
| 554 | | logerror("I8257 '%s' DMA Channel 0: %s\n", device->tag, BIT(i8257->mr, 0) ? "enabled" : "disabled");
|
| 555 | | logerror("I8257 '%s' DMA Channel 1: %s\n", device->tag, BIT(i8257->mr, 1) ? "enabled" : "disabled");
|
| 556 | | logerror("I8257 '%s' DMA Channel 2: %s\n", device->tag, BIT(i8257->mr, 2) ? "enabled" : "disabled");
|
| 557 | | logerror("I8257 '%s' DMA Channel 3: %s\n", device->tag, BIT(i8257->mr, 3) ? "enabled" : "disabled");
|
| 558 | | if (BIT(i8257->mr, 4)) logerror("I8257 '%s' Rotating Priority\n", device->tag);
|
| 559 | | if (BIT(i8257->mr, 5)) logerror("I8257 '%s' Extended Write\n", device->tag);
|
| 560 | | if (BIT(i8257->mr, 6)) logerror("I8257 '%s' TC Stop\n", device->tag);
|
| 561 | | if (BIT(i8257->mr, 7)) logerror("I8257 '%s' Auto Load\n", device->tag);
|
| 562 | | }
|
| 563 | | break;
|
| 564 | | }
|
| 565 | | }
|
| 566 | | |
| 567 | | WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w )
|
| 568 | | {
|
| 569 | | i8257_t *i8257 = get_safe_token(device);
|
| 570 | | |
| 571 | | i8257->hlda = state;
|
| 572 | | |
| 573 | | if (LOG) logerror("I8257 '%s' Hold Acknowledge: %u\n", device->tag, state);
|
| 574 | | }
|
| 575 | | |
| 576 | | WRITE_LINE_DEVICE_HANDLER( i8257_ready_w )
|
| 577 | | {
|
| 578 | | i8257_t *i8257 = get_safe_token(device);
|
| 579 | | |
| 580 | | i8257->ready = state;
|
| 581 | | |
| 582 | | if (LOG) logerror("I8257 '%s' Ready: %u\n", device->tag, state);
|
| 583 | | }
|
| 584 | | |
| 585 | | static void drq_w(const device_config *device, int ch, int state)
|
| 586 | | {
|
| 587 | | i8257_t *i8257 = get_safe_token(device);
|
| 588 | | |
| 589 | | i8257->drq[ch] = state;
|
| 590 | | |
| 591 | | if (LOG) logerror("I8257 '%s' Data Request %u: %u\n", device->tag, ch, state);
|
| 592 | | |
| 593 | | if (state && (i8257->state == STATE_SI))
|
| 594 | | {
|
| 595 | | timer_enable(i8257->dma_timer, 1);
|
| 596 | | }
|
| 597 | | }
|
| 598 | | |
| 599 | | WRITE_LINE_DEVICE_HANDLER( i8257_drq0_w ) { drq_w(device, 0, state); }
|
| 600 | | WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w ) { drq_w(device, 1, state); }
|
| 601 | | WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w ) { drq_w(device, 2, state); }
|
| 602 | | WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w ) { drq_w(device, 3, state); }
|
| 603 | | |
| 604 | | /*-------------------------------------------------
|
| 605 | | DEVICE_START( i8257 )
|
| 606 | | -------------------------------------------------*/
|
| 607 | | |
| 608 | | static DEVICE_START( i8257 )
|
| 609 | | {
|
| 610 | | i8257_t *i8257 = get_safe_token(device);
|
| 611 | | i8257_interface *intf = (i8257_interface *)device->static_config;
|
| 612 | | int ch;
|
| 613 | | |
| 614 | | /* resolve callbacks */
|
| 615 | | devcb_resolve_write_line(&i8257->out_hrq_func, &intf->out_hrq_func, device);
|
| 616 | | devcb_resolve_write_line(&i8257->out_tc_func, &intf->out_tc_func, device);
|
| 617 | | devcb_resolve_write_line(&i8257->out_mark_func, &intf->out_mark_func, device);
|
| 618 | | |
| 619 | | for (ch = 0; ch < I8257_CHANNELS; ch++)
|
| 620 | | {
|
| 621 | | devcb_resolve_read8(&i8257->in_memr_func[ch], &intf->in_memr_func[ch], device);
|
| 622 | | devcb_resolve_write8(&i8257->out_memw_func[ch], &intf->out_memw_func[ch], device);
|
| 623 | | devcb_resolve_read8(&i8257->in_ior_func[ch], &intf->in_ior_func[ch], device);
|
| 624 | | devcb_resolve_write8(&i8257->out_iow_func[ch], &intf->out_iow_func[ch], device);
|
| 625 | | devcb_resolve_write_line(&i8257->out_dack_func[ch], &intf->out_dack_func[ch], device);
|
| 626 | | }
|
| 627 | | |
| 628 | | /* create the DMA timer */
|
| 629 | | i8257->dma_timer = timer_alloc(device->machine, dma_tick, (void *)device);
|
| 630 | | timer_adjust_periodic(i8257->dma_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock));
|
| 631 | | |
| 632 | | /* register for state saving */
|
| 633 | | state_save_register_device_item(device, 0, i8257->mr);
|
| 634 | | state_save_register_device_item(device, 0, i8257->sr);
|
| 635 | | state_save_register_device_item_array(device, 0, i8257->ar);
|
| 636 | | state_save_register_device_item_array(device, 0, i8257->cr);
|
| 637 | | state_save_register_device_item(device, 0, i8257->fl);
|
| 638 | | state_save_register_device_item_array(device, 0, i8257->drq);
|
| 639 | | state_save_register_device_item(device, 0, i8257->hlda);
|
| 640 | | state_save_register_device_item(device, 0, i8257->ready);
|
| 641 | | state_save_register_device_item(device, 0, i8257->tc);
|
| 642 | | state_save_register_device_item(device, 0, i8257->mark);
|
| 643 | | state_save_register_device_item(device, 0, i8257->state);
|
| 644 | | state_save_register_device_item(device, 0, i8257->channel);
|
| 645 | | state_save_register_device_item(device, 0, i8257->priority);
|
| 646 | | state_save_register_device_item(device, 0, i8257->data);
|
| 647 | | state_save_register_device_item(device, 0, i8257->address);
|
| 648 | | state_save_register_device_item(device, 0, i8257->count);
|
| 649 | | state_save_register_device_item(device, 0, i8257->mode);
|
| 650 | | }
|
| 651 | | |
| 652 | | /*-------------------------------------------------
|
| 653 | | DEVICE_RESET( i8257 )
|
| 654 | | -------------------------------------------------*/
|
| 655 | | |
| 656 | | static DEVICE_RESET( i8257 )
|
| 657 | | {
|
| 658 | | i8257_t *i8257 = get_safe_token(device);
|
| 659 | | |
| 660 | | i8257->fl = 0;
|
| 661 | | i8257->mr = 0;
|
| 662 | | i8257->sr = 0;
|
| 663 | | i8257->state = STATE_SI;
|
| 664 | | i8257->priority = 0;
|
| 665 | | i8257->ready = 1;
|
| 666 | | |
| 667 | | set_hrq(device, 0);
|
| 668 | | set_mark(device, 0);
|
| 669 | | set_tc(device, 0);
|
| 670 | | set_dack(device, -1);
|
| 671 | | |
| 672 | | timer_enable(i8257->dma_timer, 0);
|
| 673 | | }
|
| 674 | | |
| 675 | | /*-------------------------------------------------
|
| 676 | | DEVICE_GET_INFO( i8257 )
|
| 677 | | -------------------------------------------------*/
|
| 678 | | |
| 679 | | DEVICE_GET_INFO( i8257 )
|
| 680 | | {
|
| 681 | | switch (state)
|
| 682 | | {
|
| 683 | | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 684 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8257_t); break;
|
| 685 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
|
| 686 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
|
| 687 | | |
| 688 | | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 689 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8257); break;
|
| 690 | | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 691 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(i8257); break;
|
| 692 | | |
| 693 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 694 | | case DEVINFO_STR_NAME: strcpy(info->s, "Intel 8257"); break;
|
| 695 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Intel 8085"); break;
|
| 696 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
| 697 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
| 698 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break;
|
| 699 | | }
|
| 700 | | }
|
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Intel 8257 Programmable DMA Controller emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | TODO: |
| 13 | |
| 14 | - use cr/ar directly |
| 15 | |
| 16 | */ |
| 17 | |
| 18 | #include "driver.h" |
| 19 | #include "i8257.h" |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | CONSTANTS |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #define LOG 0 |
| 26 | |
| 27 | #define I8257_STATUS_TC0 0x01 |
| 28 | #define I8257_STATUS_TC1 0x02 |
| 29 | #define I8257_STATUS_TC2 0x04 |
| 30 | #define I8257_STATUS_TC3 0x08 |
| 31 | #define I8257_STATUS_UP 0x10 |
| 32 | |
| 33 | #define I8257_MODE_EN0 0x01 |
| 34 | #define I8257_MODE_EN1 0x02 |
| 35 | #define I8257_MODE_EN2 0x04 |
| 36 | #define I8257_MODE_EN3 0x08 |
| 37 | #define I8257_MODE_RP 0x10 |
| 38 | #define I8257_MODE_EW 0x20 |
| 39 | #define I8257_MODE_TCS 0x40 |
| 40 | #define I8257_MODE_AL 0x80 |
| 41 | |
| 42 | enum |
| 43 | { |
| 44 | STATE_SI, |
| 45 | STATE_S0, |
| 46 | STATE_S1, |
| 47 | STATE_S2, |
| 48 | STATE_S3, |
| 49 | STATE_SW, |
| 50 | STATE_SU, |
| 51 | STATE_S4 |
| 52 | }; |
| 53 | |
| 54 | enum |
| 55 | { |
| 56 | MODE_VERIFY = 0, |
| 57 | MODE_WRITE, |
| 58 | MODE_READ, |
| 59 | MODE_ILLEGAL |
| 60 | }; |
| 61 | |
| 62 | /*************************************************************************** |
| 63 | TYPE DEFINITIONS |
| 64 | ***************************************************************************/ |
| 65 | |
| 66 | typedef struct _dma8257_t i8257_t; |
| 67 | struct _dma8257_t |
| 68 | { |
| 69 | devcb_resolved_write_line out_hrq_func; |
| 70 | devcb_resolved_write_line out_tc_func; |
| 71 | devcb_resolved_write_line out_mark_func; |
| 72 | devcb_resolved_read8 in_memr_func[I8257_CHANNELS]; |
| 73 | devcb_resolved_write8 out_memw_func[I8257_CHANNELS]; |
| 74 | devcb_resolved_read8 in_ior_func[I8257_CHANNELS]; |
| 75 | devcb_resolved_write8 out_iow_func[I8257_CHANNELS]; |
| 76 | devcb_resolved_write_line out_dack_func[I8257_CHANNELS]; |
| 77 | |
| 78 | /* registers */ |
| 79 | UINT8 mr; /* mode register */ |
| 80 | UINT8 sr; /* status register */ |
| 81 | UINT16 ar[I8257_CHANNELS]; /* address register */ |
| 82 | UINT16 cr[I8257_CHANNELS]; /* count register */ |
| 83 | int fl; /* first/last flip-flop */ |
| 84 | |
| 85 | /* inputs */ |
| 86 | int drq[I8257_CHANNELS]; /* data request */ |
| 87 | int hlda; /* hold acknowledge */ |
| 88 | int ready; /* ready */ |
| 89 | |
| 90 | /* outputs */ |
| 91 | int tc; /* terminal count */ |
| 92 | int mark; /* mark */ |
| 93 | |
| 94 | /* transfer */ |
| 95 | int state; /* DMA state */ |
| 96 | int channel; /* current channel being serviced */ |
| 97 | int priority; /* highest priority channel */ |
| 98 | UINT8 data; /* DMA data */ |
| 99 | UINT16 address; /* DMA address */ |
| 100 | UINT16 count; /* DMA counter */ |
| 101 | int mode; /* DMA transfer type */ |
| 102 | |
| 103 | /* timers */ |
| 104 | emu_timer *dma_timer; |
| 105 | }; |
| 106 | |
| 107 | /*************************************************************************** |
| 108 | INLINE FUNCTIONS |
| 109 | ***************************************************************************/ |
| 110 | |
| 111 | INLINE i8257_t *get_safe_token(const device_config *device) |
| 112 | { |
| 113 | assert(device != NULL); |
| 114 | assert(device->token != NULL); |
| 115 | assert(device->type == I8257); |
| 116 | return (i8257_t *) device->token; |
| 117 | } |
| 118 | |
| 119 | INLINE const i8257_interface *get_interface(const device_config *device) |
| 120 | { |
| 121 | assert(device != NULL); |
| 122 | assert((device->type == I8257)); |
| 123 | return (const i8257_interface *) device->static_config; |
| 124 | } |
| 125 | |
| 126 | /*************************************************************************** |
| 127 | IMPLEMENTATION |
| 128 | ***************************************************************************/ |
| 129 | |
| 130 | static void set_hrq(const device_config *device, int state) |
| 131 | { |
| 132 | i8257_t *i8257 = get_safe_token(device); |
| 133 | |
| 134 | if (LOG) logerror("I8257 '%s' Hold Request: %u\n", device->tag, state); |
| 135 | |
| 136 | devcb_call_write_line(&i8257->out_hrq_func, state); |
| 137 | } |
| 138 | |
| 139 | static void set_tc(const device_config *device, int state) |
| 140 | { |
| 141 | i8257_t *i8257 = get_safe_token(device); |
| 142 | |
| 143 | if (i8257->tc != state) |
| 144 | { |
| 145 | if (LOG) logerror("I8257 '%s' Terminal Count: %u\n", device->tag, state); |
| 146 | i8257->tc = state; |
| 147 | devcb_call_write_line(&i8257->out_tc_func, state); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | static void set_mark(const device_config *device, int state) |
| 152 | { |
| 153 | i8257_t *i8257 = get_safe_token(device); |
| 154 | |
| 155 | if (i8257->mark != state) |
| 156 | { |
| 157 | if (LOG) logerror("I8257 '%s' Mark: %u\n", device->tag, state); |
| 158 | i8257->mark = state; |
| 159 | devcb_call_write_line(&i8257->out_mark_func, state); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | static void set_dack(const device_config *device, int active_channel) |
| 164 | { |
| 165 | i8257_t *i8257 = get_safe_token(device); |
| 166 | int ch; |
| 167 | |
| 168 | for (ch = 0; ch < I8257_CHANNELS; ch++) |
| 169 | { |
| 170 | int state = (ch != active_channel); |
| 171 | |
| 172 | if (LOG) logerror("I8257 '%s' DMA Acknowledge %u: %u\n", device->tag, ch, state); |
| 173 | |
| 174 | devcb_call_write_line(&i8257->out_dack_func[ch], state); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | static int sample_drq(const device_config *device) |
| 179 | { |
| 180 | i8257_t *i8257 = get_safe_token(device); |
| 181 | int ch; |
| 182 | |
| 183 | for (ch = 0; ch < I8257_CHANNELS; ch++) |
| 184 | { |
| 185 | if (i8257->drq[ch] && BIT(i8257->mr, ch)) |
| 186 | { |
| 187 | return 1; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | static void resolve_priorities(const device_config *device) |
| 195 | { |
| 196 | i8257_t *i8257 = get_safe_token(device); |
| 197 | int i; |
| 198 | |
| 199 | for (i = 0; i < I8257_CHANNELS; i++) |
| 200 | { |
| 201 | int ch = (i + i8257->priority) % I8257_CHANNELS; |
| 202 | |
| 203 | if (i8257->drq[ch] && BIT(i8257->mr, ch)) |
| 204 | { |
| 205 | i8257->channel = ch; |
| 206 | i8257->address = i8257->ar[ch]; |
| 207 | i8257->count = i8257->cr[ch] & 0x3fff; |
| 208 | i8257->mode = i8257->cr[ch] >> 14; |
| 209 | break; |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | static void dma_read(const device_config *device) |
| 215 | { |
| 216 | i8257_t *i8257 = get_safe_token(device); |
| 217 | |
| 218 | switch (i8257->mode) |
| 219 | { |
| 220 | case MODE_VERIFY: |
| 221 | break; |
| 222 | |
| 223 | case MODE_WRITE: |
| 224 | i8257->data = devcb_call_read8(&i8257->in_memr_func[i8257->channel], i8257->address); |
| 225 | if (LOG) logerror("I8257 '%s' DMA Memory Read %04x: %02x\n", device->tag, i8257->address, i8257->data); |
| 226 | break; |
| 227 | |
| 228 | case MODE_READ: |
| 229 | i8257->data = devcb_call_read8(&i8257->in_ior_func[i8257->channel], i8257->address); |
| 230 | if (LOG) logerror("I8257 '%s' DMA I/O Read %04x: %02x\n", device->tag, i8257->address, i8257->data); |
| 231 | break; |
| 232 | |
| 233 | case MODE_ILLEGAL: |
| 234 | break; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | static void dma_write(const device_config *device) |
| 239 | { |
| 240 | i8257_t *i8257 = get_safe_token(device); |
| 241 | |
| 242 | switch (i8257->mode) |
| 243 | { |
| 244 | case MODE_VERIFY: |
| 245 | break; |
| 246 | |
| 247 | case MODE_WRITE: |
| 248 | devcb_call_write8(&i8257->out_iow_func[i8257->channel], i8257->address, i8257->data); |
| 249 | if (LOG) logerror("I8257 '%s' DMA I/O Write %04x: %02x\n", device->tag, i8257->address, i8257->data); |
| 250 | break; |
| 251 | |
| 252 | case MODE_READ: |
| 253 | devcb_call_write8(&i8257->out_memw_func[i8257->channel], i8257->address, i8257->data); |
| 254 | if (LOG) logerror("I8257 '%s' DMA Memory Write %04x: %02x\n", device->tag, i8257->address, i8257->data); |
| 255 | break; |
| 256 | |
| 257 | case MODE_ILLEGAL: |
| 258 | break; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /*------------------------------------------------- |
| 263 | TIMER_CALLBACK( dma_tick ) |
| 264 | -------------------------------------------------*/ |
| 265 | |
| 266 | static TIMER_CALLBACK( dma_tick ) |
| 267 | { |
| 268 | const device_config *device = (const device_config *)ptr; |
| 269 | i8257_t *i8257 = get_safe_token(device); |
| 270 | int drq = 0; |
| 271 | |
| 272 | switch (i8257->state) |
| 273 | { |
| 274 | case STATE_SI: |
| 275 | /* sample DRQn lines */ |
| 276 | drq = sample_drq(device); |
| 277 | |
| 278 | /* set HRQ if DRQn = 1 */ |
| 279 | if (drq) |
| 280 | { |
| 281 | set_hrq(device, 1); |
| 282 | i8257->state = STATE_S0; |
| 283 | } |
| 284 | break; |
| 285 | |
| 286 | case STATE_S0: |
| 287 | /* sample HLDA */ |
| 288 | if (i8257->hlda) |
| 289 | { |
| 290 | i8257->state = STATE_S1; |
| 291 | } |
| 292 | |
| 293 | /* resolve DRQ priorities */ |
| 294 | resolve_priorities(device); |
| 295 | break; |
| 296 | |
| 297 | case STATE_S1: |
| 298 | /* present and data upper address */ |
| 299 | /* present lower address */ |
| 300 | i8257->state = STATE_S2; |
| 301 | break; |
| 302 | |
| 303 | case STATE_S2: |
| 304 | /* activate DACKn */ |
| 305 | set_dack(device, i8257->channel); |
| 306 | |
| 307 | /* activate read command */ |
| 308 | dma_read(device); |
| 309 | |
| 310 | /* advanced write command */ |
| 311 | if (i8257->mr & I8257_MODE_EW) |
| 312 | { |
| 313 | dma_write(device); |
| 314 | } |
| 315 | |
| 316 | i8257->state = STATE_S3; |
| 317 | break; |
| 318 | |
| 319 | case STATE_S3: |
| 320 | /* activate write command */ |
| 321 | if (!(i8257->mr & I8257_MODE_EW)) |
| 322 | { |
| 323 | dma_write(device); |
| 324 | } |
| 325 | |
| 326 | i8257->address++; |
| 327 | i8257->count--; |
| 328 | |
| 329 | /* activate MARK */ |
| 330 | switch (i8257->count & 0xff) |
| 331 | { |
| 332 | case 0: case 0x80: |
| 333 | set_mark(device, 1); |
| 334 | break; |
| 335 | } |
| 336 | |
| 337 | /* activate TC */ |
| 338 | if (i8257->count == 0) |
| 339 | { |
| 340 | set_tc(device, 1); |
| 341 | } |
| 342 | |
| 343 | if (!i8257->ready) |
| 344 | { |
| 345 | i8257->state = STATE_SW; |
| 346 | } |
| 347 | else if (i8257->tc && (i8257->channel == 2) && (i8257->mr & I8257_MODE_AL)) |
| 348 | { |
| 349 | i8257->state = STATE_SU; |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | i8257->state = STATE_S4; |
| 354 | } |
| 355 | break; |
| 356 | |
| 357 | case STATE_SW: |
| 358 | /* sample READY line */ |
| 359 | if (i8257->ready) |
| 360 | { |
| 361 | if (i8257->tc && (i8257->channel == 2) && (i8257->mr & I8257_MODE_AL)) |
| 362 | { |
| 363 | i8257->state = STATE_SU; |
| 364 | } |
| 365 | else |
| 366 | { |
| 367 | i8257->state = STATE_S4; |
| 368 | } |
| 369 | } |
| 370 | break; |
| 371 | |
| 372 | case STATE_SU: |
| 373 | i8257->sr |= I8257_STATUS_UP; |
| 374 | |
| 375 | /* auto load channel 2 parameters */ |
| 376 | i8257->ar[2] = i8257->ar[3]; |
| 377 | i8257->cr[2] = i8257->cr[3]; |
| 378 | |
| 379 | if (LOG) |
| 380 | { |
| 381 | logerror("I8257 '%s' DMA Channel 2 Address Register: %04x\n", device->tag, i8257->ar[2]); |
| 382 | logerror("I8257 '%s' DMA Channel 2 Count Register: %04x\n", device->tag, i8257->cr[2] & 0x3fff); |
| 383 | logerror("I8257 '%s' DMA Channel 2 Mode: %u\n", device->tag, i8257->cr[2] >> 14); |
| 384 | } |
| 385 | |
| 386 | i8257->state = STATE_S4; |
| 387 | break; |
| 388 | |
| 389 | case STATE_S4: |
| 390 | i8257->sr &= ~I8257_STATUS_UP; |
| 391 | |
| 392 | if (i8257->tc) |
| 393 | { |
| 394 | /* reset enable for channel n if TC stop and TC are active */ |
| 395 | if ((i8257->mr & I8257_MODE_TCS) && |
| 396 | !((i8257->channel == 2) && (i8257->mr & I8257_MODE_AL))) |
| 397 | { |
| 398 | i8257->mr &= ~(1 << i8257->channel); |
| 399 | if (LOG) logerror("I8257 '%s' DMA Channel %u: disabled\n", device->tag, i8257->channel); |
| 400 | } |
| 401 | |
| 402 | if (i8257->mr & I8257_MODE_RP) |
| 403 | { |
| 404 | i8257->priority = (i8257->channel + 1) % I8257_CHANNELS; |
| 405 | } |
| 406 | |
| 407 | /* resolve DRQ priorities */ |
| 408 | resolve_priorities(device); |
| 409 | } |
| 410 | |
| 411 | /* deactivate DACKn, MARK and TC */ |
| 412 | set_dack(device, -1); |
| 413 | set_mark(device, 0); |
| 414 | set_tc(device, 0); |
| 415 | |
| 416 | /* sample DRQn */ |
| 417 | drq = sample_drq(device); |
| 418 | |
| 419 | /* reset HRQ if HLDA = 0 or DRQ = 0 */ |
| 420 | if (!i8257->hlda || !drq) |
| 421 | { |
| 422 | set_hrq(device, 0); |
| 423 | i8257->state = STATE_SI; |
| 424 | timer_enable(i8257->dma_timer, 0); |
| 425 | } |
| 426 | else |
| 427 | { |
| 428 | i8257->state = STATE_S1; |
| 429 | } |
| 430 | break; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | READ8_DEVICE_HANDLER( i8257_r ) |
| 435 | { |
| 436 | i8257_t *i8257 = get_safe_token(device); |
| 437 | UINT8 data = 0; |
| 438 | int ch; |
| 439 | |
| 440 | switch (offset & 0x0f) |
| 441 | { |
| 442 | case 0: |
| 443 | case 2: |
| 444 | case 4: |
| 445 | case 6: |
| 446 | ch = offset / 2; |
| 447 | |
| 448 | if (i8257->fl) |
| 449 | { |
| 450 | data = i8257->ar[ch] >> 8; |
| 451 | } |
| 452 | else |
| 453 | { |
| 454 | data = i8257->ar[ch] & 0xff; |
| 455 | } |
| 456 | |
| 457 | i8257->fl = !i8257->fl; |
| 458 | break; |
| 459 | |
| 460 | case 1: |
| 461 | case 3: |
| 462 | case 5: |
| 463 | case 7: |
| 464 | ch = (offset - 1) / 2; |
| 465 | |
| 466 | if (i8257->fl) |
| 467 | { |
| 468 | data = i8257->cr[ch] >> 8; |
| 469 | } |
| 470 | else |
| 471 | { |
| 472 | data = i8257->cr[ch] & 0xff; |
| 473 | } |
| 474 | |
| 475 | i8257->fl = !i8257->fl; |
| 476 | break; |
| 477 | |
| 478 | case 8: |
| 479 | data = i8257->sr; |
| 480 | i8257->sr &= ~(I8257_STATUS_TC3 | I8257_STATUS_TC2 | I8257_STATUS_TC1 | I8257_STATUS_TC0); |
| 481 | break; |
| 482 | } |
| 483 | |
| 484 | return data; |
| 485 | } |
| 486 | |
| 487 | WRITE8_DEVICE_HANDLER( i8257_w ) |
| 488 | { |
| 489 | i8257_t *i8257 = get_safe_token(device); |
| 490 | int ch; |
| 491 | |
| 492 | switch (offset & 0x0f) |
| 493 | { |
| 494 | case 0: |
| 495 | case 2: |
| 496 | case 4: |
| 497 | case 6: |
| 498 | ch = offset / 2; |
| 499 | |
| 500 | if (i8257->fl) |
| 501 | { |
| 502 | i8257->ar[ch] = (data << 8) | (i8257->ar[ch] & 0xff); |
| 503 | if (LOG) logerror("I8257 '%s' DMA Channel %u Address Register: %04x\n", device->tag, ch, i8257->ar[ch]); |
| 504 | } |
| 505 | else |
| 506 | { |
| 507 | i8257->ar[ch] = (i8257->ar[ch] & 0xff00) | data; |
| 508 | } |
| 509 | |
| 510 | if ((i8257->mr & I8257_MODE_AL) && (ch == 2)) |
| 511 | { |
| 512 | i8257->ar[3] = i8257->ar[2]; |
| 513 | } |
| 514 | |
| 515 | i8257->fl = !i8257->fl; |
| 516 | break; |
| 517 | |
| 518 | case 1: |
| 519 | case 3: |
| 520 | case 5: |
| 521 | case 7: |
| 522 | ch = (offset - 1) / 2; |
| 523 | |
| 524 | if (i8257->fl) |
| 525 | { |
| 526 | i8257->cr[ch] = (data << 8) | (i8257->cr[ch] & 0xff); |
| 527 | if (LOG) logerror("I8257 '%s' DMA Channel %u Count Register: %04x\n", device->tag, ch, i8257->cr[ch] & 0x3fff); |
| 528 | if (LOG) logerror("I8257 '%s' DMA Channel %u Mode: %u\n", device->tag, ch, i8257->cr[ch] >> 14); |
| 529 | } |
| 530 | else |
| 531 | { |
| 532 | i8257->cr[ch] = (i8257->cr[ch] & 0xff00) | data; |
| 533 | } |
| 534 | |
| 535 | if ((i8257->mr & I8257_MODE_AL) && (ch == 2)) |
| 536 | { |
| 537 | i8257->cr[3] = i8257->cr[2]; |
| 538 | } |
| 539 | |
| 540 | i8257->fl = !i8257->fl; |
| 541 | break; |
| 542 | |
| 543 | case 8: |
| 544 | i8257->mr = data; |
| 545 | i8257->fl = 0; |
| 546 | |
| 547 | if ((i8257->state == STATE_SI) && sample_drq(device)) |
| 548 | { |
| 549 | timer_enable(i8257->dma_timer, 1); |
| 550 | } |
| 551 | |
| 552 | if (LOG) |
| 553 | { |
| 554 | logerror("I8257 '%s' DMA Channel 0: %s\n", device->tag, BIT(i8257->mr, 0) ? "enabled" : "disabled"); |
| 555 | logerror("I8257 '%s' DMA Channel 1: %s\n", device->tag, BIT(i8257->mr, 1) ? "enabled" : "disabled"); |
| 556 | logerror("I8257 '%s' DMA Channel 2: %s\n", device->tag, BIT(i8257->mr, 2) ? "enabled" : "disabled"); |
| 557 | logerror("I8257 '%s' DMA Channel 3: %s\n", device->tag, BIT(i8257->mr, 3) ? "enabled" : "disabled"); |
| 558 | if (BIT(i8257->mr, 4)) logerror("I8257 '%s' Rotating Priority\n", device->tag); |
| 559 | if (BIT(i8257->mr, 5)) logerror("I8257 '%s' Extended Write\n", device->tag); |
| 560 | if (BIT(i8257->mr, 6)) logerror("I8257 '%s' TC Stop\n", device->tag); |
| 561 | if (BIT(i8257->mr, 7)) logerror("I8257 '%s' Auto Load\n", device->tag); |
| 562 | } |
| 563 | break; |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w ) |
| 568 | { |
| 569 | i8257_t *i8257 = get_safe_token(device); |
| 570 | |
| 571 | i8257->hlda = state; |
| 572 | |
| 573 | if (LOG) logerror("I8257 '%s' Hold Acknowledge: %u\n", device->tag, state); |
| 574 | } |
| 575 | |
| 576 | WRITE_LINE_DEVICE_HANDLER( i8257_ready_w ) |
| 577 | { |
| 578 | i8257_t *i8257 = get_safe_token(device); |
| 579 | |
| 580 | i8257->ready = state; |
| 581 | |
| 582 | if (LOG) logerror("I8257 '%s' Ready: %u\n", device->tag, state); |
| 583 | } |
| 584 | |
| 585 | static void drq_w(const device_config *device, int ch, int state) |
| 586 | { |
| 587 | i8257_t *i8257 = get_safe_token(device); |
| 588 | |
| 589 | i8257->drq[ch] = state; |
| 590 | |
| 591 | if (LOG) logerror("I8257 '%s' Data Request %u: %u\n", device->tag, ch, state); |
| 592 | |
| 593 | if (state && (i8257->state == STATE_SI)) |
| 594 | { |
| 595 | timer_enable(i8257->dma_timer, 1); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | WRITE_LINE_DEVICE_HANDLER( i8257_drq0_w ) { drq_w(device, 0, state); } |
| 600 | WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w ) { drq_w(device, 1, state); } |
| 601 | WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w ) { drq_w(device, 2, state); } |
| 602 | WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w ) { drq_w(device, 3, state); } |
| 603 | |
| 604 | /*------------------------------------------------- |
| 605 | DEVICE_START( i8257 ) |
| 606 | -------------------------------------------------*/ |
| 607 | |
| 608 | static DEVICE_START( i8257 ) |
| 609 | { |
| 610 | i8257_t *i8257 = get_safe_token(device); |
| 611 | i8257_interface *intf = (i8257_interface *)device->static_config; |
| 612 | int ch; |
| 613 | |
| 614 | /* resolve callbacks */ |
| 615 | devcb_resolve_write_line(&i8257->out_hrq_func, &intf->out_hrq_func, device); |
| 616 | devcb_resolve_write_line(&i8257->out_tc_func, &intf->out_tc_func, device); |
| 617 | devcb_resolve_write_line(&i8257->out_mark_func, &intf->out_mark_func, device); |
| 618 | |
| 619 | for (ch = 0; ch < I8257_CHANNELS; ch++) |
| 620 | { |
| 621 | devcb_resolve_read8(&i8257->in_memr_func[ch], &intf->in_memr_func[ch], device); |
| 622 | devcb_resolve_write8(&i8257->out_memw_func[ch], &intf->out_memw_func[ch], device); |
| 623 | devcb_resolve_read8(&i8257->in_ior_func[ch], &intf->in_ior_func[ch], device); |
| 624 | devcb_resolve_write8(&i8257->out_iow_func[ch], &intf->out_iow_func[ch], device); |
| 625 | devcb_resolve_write_line(&i8257->out_dack_func[ch], &intf->out_dack_func[ch], device); |
| 626 | } |
| 627 | |
| 628 | /* create the DMA timer */ |
| 629 | i8257->dma_timer = timer_alloc(device->machine, dma_tick, (void *)device); |
| 630 | timer_adjust_periodic(i8257->dma_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock)); |
| 631 | |
| 632 | /* register for state saving */ |
| 633 | state_save_register_device_item(device, 0, i8257->mr); |
| 634 | state_save_register_device_item(device, 0, i8257->sr); |
| 635 | state_save_register_device_item_array(device, 0, i8257->ar); |
| 636 | state_save_register_device_item_array(device, 0, i8257->cr); |
| 637 | state_save_register_device_item(device, 0, i8257->fl); |
| 638 | state_save_register_device_item_array(device, 0, i8257->drq); |
| 639 | state_save_register_device_item(device, 0, i8257->hlda); |
| 640 | state_save_register_device_item(device, 0, i8257->ready); |
| 641 | state_save_register_device_item(device, 0, i8257->tc); |
| 642 | state_save_register_device_item(device, 0, i8257->mark); |
| 643 | state_save_register_device_item(device, 0, i8257->state); |
| 644 | state_save_register_device_item(device, 0, i8257->channel); |
| 645 | state_save_register_device_item(device, 0, i8257->priority); |
| 646 | state_save_register_device_item(device, 0, i8257->data); |
| 647 | state_save_register_device_item(device, 0, i8257->address); |
| 648 | state_save_register_device_item(device, 0, i8257->count); |
| 649 | state_save_register_device_item(device, 0, i8257->mode); |
| 650 | } |
| 651 | |
| 652 | /*------------------------------------------------- |
| 653 | DEVICE_RESET( i8257 ) |
| 654 | -------------------------------------------------*/ |
| 655 | |
| 656 | static DEVICE_RESET( i8257 ) |
| 657 | { |
| 658 | i8257_t *i8257 = get_safe_token(device); |
| 659 | |
| 660 | i8257->fl = 0; |
| 661 | i8257->mr = 0; |
| 662 | i8257->sr = 0; |
| 663 | i8257->state = STATE_SI; |
| 664 | i8257->priority = 0; |
| 665 | i8257->ready = 1; |
| 666 | |
| 667 | set_hrq(device, 0); |
| 668 | set_mark(device, 0); |
| 669 | set_tc(device, 0); |
| 670 | set_dack(device, -1); |
| 671 | |
| 672 | timer_enable(i8257->dma_timer, 0); |
| 673 | } |
| 674 | |
| 675 | /*------------------------------------------------- |
| 676 | DEVICE_GET_INFO( i8257 ) |
| 677 | -------------------------------------------------*/ |
| 678 | |
| 679 | DEVICE_GET_INFO( i8257 ) |
| 680 | { |
| 681 | switch (state) |
| 682 | { |
| 683 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 684 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8257_t); break; |
| 685 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 686 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 687 | |
| 688 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 689 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8257); break; |
| 690 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 691 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(i8257); break; |
| 692 | |
| 693 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 694 | case DEVINFO_STR_NAME: strcpy(info->s, "Intel 8257"); break; |
| 695 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Intel 8085"); break; |
| 696 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 697 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 698 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 699 | } |
| 700 | } |
src/mess/drivers/pc8001.c
| r6857 | r6858 | |
| 1 | | /*
|
| 2 | | |
| 3 | | http://www2.odn.ne.jp/~haf09260/Pc80/EnrPc.htm
|
| 4 | | http://home1.catvmics.ne.jp/~kanemoto/n80/inside.html
|
| 5 | | http://www.geocities.jp/retro_zzz/machines/nec/8001/index.html
|
| 6 | | |
| 7 | | */
|
| 8 | | |
| 9 | | /*
|
| 10 | | |
| 11 | | TODO:
|
| 12 | | |
| 13 | | - print time$/date$ stalls
|
| 14 | | - uPD3301 attributes
|
| 15 | | - PCG1000
|
| 16 | | - Intel 8251
|
| 17 | | - cassette
|
| 18 | | - floppy
|
| 19 | | - PC-8011
|
| 20 | | - PC-8021
|
| 21 | | - PC-8031
|
| 22 | | |
| 23 | | */
|
| 24 | | |
| 25 | | #include "driver.h"
|
| 26 | | #include "includes/pc8001.h"
|
| 27 | | #include "cpu/z80/z80.h"
|
| 28 | | #include "devices/cassette.h"
|
| 29 | | #include "devices/messram.h"
|
| 30 | | #include "machine/i8257.h"
|
| 31 | | #include "machine/ctronics.h"
|
| 32 | | #include "machine/i8214.h"
|
| 33 | | #include "machine/i8255a.h"
|
| 34 | | #include "machine/msm8251.h"
|
| 35 | | #include "machine/upd1990a.h"
|
| 36 | | #include "video/upd3301.h"
|
| 37 | | #include "sound/speaker.h"
|
| 38 | | |
| 39 | | /* Read/Write Handlers */
|
| 40 | | |
| 41 | | static WRITE8_HANDLER( port30_w )
|
| 42 | | {
|
| 43 | | /*
|
| 44 | | |
| 45 | | bit description
|
| 46 | | |
| 47 | | 0 characters per line (0=40, 1=80)
|
| 48 | | 1 color mode (0=color, 1=B&W)
|
| 49 | | 2 CMT CHIN
|
| 50 | | 3 CMT MOTOR (1=on)
|
| 51 | | 4 CMT BS1
|
| 52 | | 5 CMT BS2
|
| 53 | | 6 unused
|
| 54 | | 7 unused
|
| 55 | | |
| 56 | | */
|
| 57 | | |
| 58 | | pc8001_state *state = space->machine->driver_data;
|
| 59 | | |
| 60 | | /* characters per line */
|
| 61 | | state->width80 = BIT(data, 0);
|
| 62 | | |
| 63 | | /* color mode */
|
| 64 | | state->color = BIT(data, 1);
|
| 65 | | |
| 66 | | /* cassette motor */
|
| 67 | | cassette_change_state(state->cassette, BIT(data, 3) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
|
| 68 | | }
|
| 69 | | |
| 70 | | static WRITE8_HANDLER( pc8001mk2_port31_w )
|
| 71 | | {
|
| 72 | | /*
|
| 73 | | |
| 74 | | bit description
|
| 75 | | |
| 76 | | 0 expansion ROM (0=expansion, 1=N80)
|
| 77 | | 1 memory mode (0=ROM, 1=RAM)
|
| 78 | | 2 color mode (0=attribute, 1=B&W)
|
| 79 | | 3 graphics enable
|
| 80 | | 4 resolution (0=640x200, 1=320x200)
|
| 81 | | 5 background color
|
| 82 | | 6 background color
|
| 83 | | 7 background color
|
| 84 | | |
| 85 | | */
|
| 86 | | }
|
| 87 | | |
| 88 | | /* Memory Maps */
|
| 89 | | |
| 90 | | static ADDRESS_MAP_START( pc8001_mem, ADDRESS_SPACE_PROGRAM, 8 )
|
| 91 | | AM_RANGE(0x0000, 0x5fff) AM_RAMBANK("bank1")
|
| 92 | | AM_RANGE(0x6000, 0x7fff) AM_RAMBANK("bank2")
|
| 93 | | AM_RANGE(0x8000, 0xffff) AM_RAMBANK("bank3")
|
| 94 | | ADDRESS_MAP_END
|
| 95 | | |
| 96 | | static ADDRESS_MAP_START( pc8001_io, ADDRESS_SPACE_IO, 8 )
|
| 97 | | ADDRESS_MAP_GLOBAL_MASK(0xff)
|
| 98 | | ADDRESS_MAP_UNMAP_HIGH
|
| 99 | | AM_RANGE(0x00, 0x00) AM_READ_PORT("KEY0")
|
| 100 | | AM_RANGE(0x01, 0x01) AM_READ_PORT("KEY1")
|
| 101 | | AM_RANGE(0x02, 0x02) AM_READ_PORT("KEY2")
|
| 102 | | AM_RANGE(0x03, 0x03) AM_READ_PORT("KEY3")
|
| 103 | | AM_RANGE(0x04, 0x04) AM_READ_PORT("KEY4")
|
| 104 | | AM_RANGE(0x05, 0x05) AM_READ_PORT("KEY5")
|
| 105 | | AM_RANGE(0x06, 0x06) AM_READ_PORT("KEY6")
|
| 106 | | AM_RANGE(0x07, 0x07) AM_READ_PORT("KEY7")
|
| 107 | | AM_RANGE(0x08, 0x08) AM_READ_PORT("KEY8")
|
| 108 | | AM_RANGE(0x09, 0x09) AM_READ_PORT("KEY9")
|
| 109 | | AM_RANGE(0x10, 0x10) AM_MIRROR(0x0f) AM_WRITE_PORT("W10") /* also AM_DEVWRITE(CENTRONICS_TAG, centronics_data_w)*/
|
| 110 | | AM_RANGE(0x20, 0x20) AM_MIRROR(0x0e) AM_DEVREADWRITE(I8251_TAG, msm8251_data_r, msm8251_data_w)
|
| 111 | | AM_RANGE(0x21, 0x21) AM_MIRROR(0x0e) AM_DEVREADWRITE(I8251_TAG, msm8251_status_r, msm8251_control_w)
|
| 112 | | AM_RANGE(0x30, 0x30) AM_MIRROR(0x0f) AM_WRITE(port30_w)
|
| 113 | | AM_RANGE(0x40, 0x40) AM_MIRROR(0x0f) AM_READ_PORT("R40") AM_WRITE_PORT("W40")
|
| 114 | | AM_RANGE(0x50, 0x51) AM_DEVREADWRITE(UPD3301_TAG, upd3301_r, upd3301_w)
|
| 115 | | AM_RANGE(0x60, 0x68) AM_DEVREADWRITE(I8257_TAG, i8257_r, i8257_w)
|
| 116 | | // AM_RANGE(0x70, 0x7f) unused
|
| 117 | | // AM_RANGE(0x80, 0x80) AM_MIRROR(0x0f) AM_WRITE(pc8011_ext0_w)
|
| 118 | | // AM_RANGE(0x90, 0x90) AM_MIRROR(0x0f) AM_WRITE(pc8011_ext1_w)
|
| 119 | | // AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0f) AM_WRITE(pc8011_ext2_w)
|
| 120 | | // AM_RANGE(0xb0, 0xb0) AM_READ(pc8011_gpio8_r)
|
| 121 | | // AM_RANGE(0xb1, 0xb1) AM_WRITE(pc8011_gpio8_w)
|
| 122 | | // AM_RANGE(0xb2, 0xb2) AM_READ(pc8011_gpio4_r)
|
| 123 | | // AM_RANGE(0xb3, 0xb3) AM_WRITE(pc8011_gpio4_w)
|
| 124 | | // AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE(PC8011_CH1_I8251_TAG, msm8251_data_r, msm8251_data_w)
|
| 125 | | // AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE(PC8011_CH1_I8251_TAG, msm8251_status_r, msm8251_control_w)
|
| 126 | | // AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE(PC8011_CH2_I8251_TAG, msm8251_data_r, msm8251_data_w)
|
| 127 | | // AM_RANGE(0xc3, 0xc3) AM_DEVREADWRITE(PC8011_CH2_I8251_TAG, msm8251_status_r, msm8251_control_w)
|
| 128 | | // AM_RANGE(0xc8, 0xc8) RS-232 output enable?
|
| 129 | | // AM_RANGE(0xca, 0xca) RS-232 output disable?
|
| 130 | | // AM_RANGE(0xd0, 0xd3) AM_DEVREADWRITE(PC8011_IEEE488_I8255A_TAG, i8255a_r, i8255a_w)
|
| 131 | | // AM_RANGE(0xd8, 0xd8) AM_READ(pc8011_ieee488_control_signal_input_r)
|
| 132 | | // AM_RANGE(0xda, 0xda) AM_READ(pc8011_ieee488_bus_address_mode_r)
|
| 133 | | // AM_RANGE(0xdc, 0xdc) AM_WRITE(pc8011_ieee488_nrfd_w)
|
| 134 | | // AM_RANGE(0xde, 0xde) AM_WRITE(pc8011_ieee488_bus_mode_control_w)
|
| 135 | | // AM_RANGE(0xe0, 0xe3) AM_WRITE(expansion_storage_mode_w)
|
| 136 | | // AM_RANGE(0xe4, 0xe4) AM_MIRROR(0x01) AM_WRITE(irq_level_w)
|
| 137 | | // AM_RANGE(0xe6, 0xe6) AM_WRITE(irq_mask_w)
|
| 138 | | // AM_RANGE(0xe7, 0xe7) AM_WRITE(pc8012_memory_mode_w)
|
| 139 | | // AM_RANGE(0xe8, 0xfb) unused
|
| 140 | | AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE(I8255A_TAG, i8255a_r, i8255a_w)
|
| 141 | | ADDRESS_MAP_END
|
| 142 | | |
| 143 | | static ADDRESS_MAP_START( pc8001mk2_mem, ADDRESS_SPACE_PROGRAM, 8 )
|
| 144 | | AM_RANGE(0x0000, 0x5fff) AM_RAMBANK("bank1")
|
| 145 | | AM_RANGE(0x6000, 0x7fff) AM_RAMBANK("bank2")
|
| 146 | | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK("bank3")
|
| 147 | | AM_RANGE(0xc000, 0xffff) AM_RAMBANK("bank4")
|
| 148 | | ADDRESS_MAP_END
|
| 149 | | |
| 150 | | static ADDRESS_MAP_START( pc8001mk2_io, ADDRESS_SPACE_IO, 8 )
|
| 151 | | AM_IMPORT_FROM(pc8001_io)
|
| 152 | | AM_RANGE(0x30, 0x30) AM_WRITE(port30_w)
|
| 153 | | AM_RANGE(0x31, 0x31) AM_WRITE(pc8001mk2_port31_w)
|
| 154 | | // AM_RANGE(0x5c, 0x5c) AM_WRITE(pc8001mk2_gram_on_w)
|
| 155 | | // AM_RANGE(0x5f, 0x5f) AM_WRITE(pc8001mk2_gram_off_w)
|
| 156 | | // AM_RANGE(0xe8, 0xe8) kanji_address_lo_w, kanji_data_lo_r
|
| 157 | | // AM_RANGE(0xe9, 0xe9) kanji_address_hi_w, kanji_data_hi_r
|
| 158 | | // AM_RANGE(0xea, 0xea) kanji_readout_start_w
|
| 159 | | // AM_RANGE(0xeb, 0xeb) kanji_readout_end_w
|
| 160 | | // AM_RANGE(0xf3, 0xf3) DMA type disk unit interface selection port
|
| 161 | | // AM_RANGE(0xf4, 0xf4) DMA type 8 inch control
|
| 162 | | // AM_RANGE(0xf5, 0xf5) DMA type 8 inch margin control
|
| 163 | | // AM_RANGE(0xf6, 0xf6) DMA type 8 inch FDC status
|
| 164 | | // AM_RANGE(0xf7, 0xf7) DMA type 8 inch FDC data register
|
| 165 | | // AM_RANGE(0xf8, 0xf8) DMA type 5 inch control
|
| 166 | | // AM_RANGE(0xf9, 0xf9) DMA type 5 inch margin control
|
| 167 | | // AM_RANGE(0xfa, 0xfa) DMA type 5 inch FDC status
|
| 168 | | // AM_RANGE(0xfb, 0xfb) DMA type 5 inch FDC data register
|
| 169 | | ADDRESS_MAP_END
|
| 170 | | |
| 171 | | /* Input Ports */
|
| 172 | | |
| 173 | | static INPUT_PORTS_START( pc8001 )
|
| 174 | | PORT_START("KEY0")
|
| 175 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
|
| 176 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
|
| 177 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
|
| 178 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
|
| 179 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
|
| 180 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
|
| 181 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
|
| 182 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
|
| 183 | | |
| 184 | | PORT_START("KEY1")
|
| 185 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
|
| 186 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
|
| 187 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK))
|
| 188 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))
|
| 189 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad =") PORT_CODE(KEYCODE_PGUP)
|
| 190 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad ,") PORT_CODE(KEYCODE_PGDN)
|
| 191 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
|
| 192 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(13)
|
| 193 | | |
| 194 | | PORT_START("KEY2")
|
| 195 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@')
|
| 196 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
|
| 197 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
|
| 198 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
|
| 199 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
|
| 200 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
|
| 201 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
|
| 202 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
|
| 203 | | |
| 204 | | PORT_START("KEY3")
|
| 205 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
|
| 206 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
|
| 207 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
|
| 208 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
|
| 209 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
|
| 210 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
|
| 211 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
|
| 212 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
|
| 213 | | |
| 214 | | PORT_START("KEY4")
|
| 215 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
|
| 216 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
|
| 217 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
|
| 218 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
|
| 219 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
|
| 220 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
|
| 221 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
|
| 222 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
|
| 223 | | |
| 224 | | PORT_START("KEY5")
|
| 225 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
|
| 226 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
|
| 227 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
|
| 228 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('[') PORT_CHAR('{')
|
| 229 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xA5') PORT_CHAR('|')
|
| 230 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']') PORT_CHAR('}')
|
| 231 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^')
|
| 232 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
|
| 233 | | |
| 234 | | PORT_START("KEY6")
|
| 235 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
|
| 236 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
|
| 237 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
|
| 238 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
|
| 239 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
|
| 240 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
|
| 241 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
|
| 242 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
|
| 243 | | |
| 244 | | PORT_START("KEY7")
|
| 245 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
|
| 246 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
|
| 247 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
|
| 248 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
|
| 249 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
|
| 250 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
|
| 251 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
|
| 252 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(" _") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0) PORT_CHAR('_')
|
| 253 | | |
| 254 | | PORT_START("KEY8")
|
| 255 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Clr Home") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME))
|
| 256 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
|
| 257 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x92") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
|
| 258 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Del Ins") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_CHAR(UCHAR_MAMEKEY(INSERT))
|
| 259 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Grph") PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(F7))
|
| 260 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Kana") PORT_CODE(KEYCODE_LCONTROL) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(F6))
|
| 261 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
| 262 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2)
|
| 263 | | |
| 264 | | PORT_START("KEY9")
|
| 265 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
|
| 266 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))
|
| 267 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
|
| 268 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
|
| 269 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
|
| 270 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
|
| 271 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
| 272 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
|
| 273 | | |
| 274 | | PORT_START("DSW1")
|
| 275 | | |
| 276 | | PORT_START("W10")
|
| 277 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_c0_w)
|
| 278 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_c1_w)
|
| 279 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_c2_w)
|
| 280 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_data_in_w)
|
| 281 | | PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 282 | | |
| 283 | | PORT_START("R40")
|
| 284 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_busy_r)
|
| 285 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_ack_r)
|
| 286 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) // CMT CDIN
|
| 287 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL ) // EXP /EXTON
|
| 288 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(UPD1990A_TAG, upd1990a_data_out_r)
|
| 289 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(UPD3301_TAG, upd3301_vrtc_r)
|
| 290 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 291 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 292 | | |
| 293 | | PORT_START("W40")
|
| 294 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(CENTRONICS_TAG, centronics_strobe_w)
|
| 295 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_stb_w)
|
| 296 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_clk_w)
|
| 297 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) // CRT /CLDS CLK
|
| 298 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 299 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(SPEAKER_TAG, speaker_level_w)
|
| 300 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 301 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
|
| 302 | | INPUT_PORTS_END
|
| 303 | | |
| 304 | | /* Video */
|
| 305 | | |
| 306 | | static PALETTE_INIT( pc8001 )
|
| 307 | | {
|
| 308 | | }
|
| 309 | | |
| 310 | | static VIDEO_START( pc8001 )
|
| 311 | | {
|
| 312 | | pc8001_state *state = machine->driver_data;
|
| 313 | | |
| 314 | | /* find memory regions */
|
| 315 | | state->char_rom = memory_region(machine, "chargen");
|
| 316 | | }
|
| 317 | | |
| 318 | | static VIDEO_UPDATE( pc8001 )
|
| 319 | | {
|
| 320 | | pc8001_state *state = screen->machine->driver_data;
|
| 321 | | |
| 322 | | upd3301_update(state->upd3301, bitmap, cliprect);
|
| 323 | | |
| 324 | | return 0;
|
| 325 | | }
|
| 326 | | |
| 327 | | /* uPD3301 Interface */
|
| 328 | | |
| 329 | | static UPD3301_DISPLAY_PIXELS( pc8001_display_pixels )
|
| 330 | | {
|
| 331 | | pc8001_state *state = device->machine->driver_data;
|
| 332 | | |
| 333 | | UINT8 data = state->char_rom[(cc << 3) | lc];
|
| 334 | | int i;
|
| 335 | | |
| 336 | | if (lc >= 8) return;
|
| 337 | | if (csr) data = 0xff;
|
| 338 | | |
| 339 | | if (state->width80)
|
| 340 | | {
|
| 341 | | for (i = 0; i < 8; i++)
|
| 342 | | {
|
| 343 | | int color = BIT(data, 7) ^ rvv;
|
| 344 | | |
| 345 | | *BITMAP_ADDR16(bitmap, y, (sx * 8) + i) = color;
|
| 346 | | |
| 347 | | data <<= 1;
|
| 348 | | }
|
| 349 | | }
|
| 350 | | else
|
| 351 | | {
|
| 352 | | if (sx % 2) return;
|
| 353 | | |
| 354 | | for (i = 0; i < 8; i++)
|
| 355 | | {
|
| 356 | | int color = BIT(data, 7) ^ rvv;
|
| 357 | | |
| 358 | | *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2)) = color;
|
| 359 | | *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2) + 1) = color;
|
| 360 | | |
| 361 | | data <<= 1;
|
| 362 | | }
|
| 363 | | }
|
| 364 | | }
|
| 365 | | |
| 366 | | static UPD3301_INTERFACE( pc8001_upd3301_intf )
|
| 367 | | {
|
| 368 | | SCREEN_TAG,
|
| 369 | | 8,
|
| 370 | | pc8001_display_pixels,
|
| 371 | | DEVCB_NULL,
|
| 372 | | DEVCB_DEVICE_LINE(I8257_TAG, i8257_drq2_w),
|
| 373 | | DEVCB_NULL,
|
| 374 | | DEVCB_NULL
|
| 375 | | };
|
| 376 | | |
| 377 | | /* 8251 Interface */
|
| 378 | | |
| 379 | | static msm8251_interface pc8001_8251_intf =
|
| 380 | | {
|
| 381 | | NULL,
|
| 382 | | NULL,
|
| 383 | | NULL
|
| 384 | | };
|
| 385 | | |
| 386 | | /* 8255 Interface */
|
| 387 | | |
| 388 | | static I8255A_INTERFACE( pc8001_8255_intf )
|
| 389 | | {
|
| 390 | | DEVCB_NULL,
|
| 391 | | DEVCB_NULL,
|
| 392 | | DEVCB_NULL,
|
| 393 | | DEVCB_NULL,
|
| 394 | | DEVCB_NULL,
|
| 395 | | DEVCB_NULL
|
| 396 | | };
|
| 397 | | |
| 398 | | /* 8257 Interface */
|
| 399 | | |
| 400 | | static WRITE_LINE_DEVICE_HANDLER( hrq_w )
|
| 401 | | {
|
| 402 | | /* HACK - this should be connected to the BUSREQ line of Z80 */
|
| 403 | | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_HALT, state);
|
| 404 | | |
| 405 | | /* HACK - this should be connected to the BUSACK line of Z80 */
|
| 406 | | i8257_hlda_w(device, state);
|
| 407 | | }
|
| 408 | | |
| 409 | | static I8257_INTERFACE( pc8001_8257_intf )
|
| 410 | | {
|
| 411 | | DEVCB_LINE(hrq_w),
|
| 412 | | DEVCB_NULL,
|
| 413 | | DEVCB_NULL,
|
| 414 | | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
|
| 415 | | { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER(UPD3301_TAG, upd3301_dack_w), DEVCB_NULL },
|
| 416 | | I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_read_byte),
|
| 417 | | I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_write_byte),
|
| 418 | | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }
|
| 419 | | };
|
| 420 | | |
| 421 | | /* uPD1990A Interface */
|
| 422 | | |
| 423 | | static UPD1990A_INTERFACE( pc8001_upd1990a_intf )
|
| 424 | | {
|
| 425 | | DEVCB_NULL,
|
| 426 | | DEVCB_NULL
|
| 427 | | };
|
| 428 | | |
| 429 | | /* Machine Initialization */
|
| 430 | | |
| 431 | | static MACHINE_START( pc8001 )
|
| 432 | | {
|
| 433 | | pc8001_state *state = machine->driver_data;
|
| 434 | | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
|
| 435 | | const device_config *messram = devtag_get_device(machine, "messram");
|
| 436 | | |
| 437 | | /* look up devices */
|
| 438 | | state->i8257 = devtag_get_device(machine, I8257_TAG);
|
| 439 | | state->upd1990a = devtag_get_device(machine, UPD1990A_TAG);
|
| 440 | | state->upd3301 = devtag_get_device(machine, UPD3301_TAG);
|
| 441 | | state->speaker = devtag_get_device(machine, SPEAKER_TAG);
|
| 442 | | state->cassette = devtag_get_device(machine, CASSETTE_TAG);
|
| 443 | | state->centronics = devtag_get_device(machine, CENTRONICS_TAG);
|
| 444 | | |
| 445 | | /* initialize RTC */
|
| 446 | | upd1990a_cs_w(state->upd1990a, 1);
|
| 447 | | upd1990a_oe_w(state->upd1990a, 1);
|
| 448 | | |
| 449 | | /* initialize DMA */
|
| 450 | | i8257_ready_w(state->i8257, 1);
|
| 451 | | |
| 452 | | /* setup memory banking */
|
| 453 | | memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "n80"), 0);
|
| 454 | | memory_install_read_bank(program, 0x0000, 0x5fff, 0, 0, "bank1");
|
| 455 | | memory_unmap_write(program, 0x0000, 0x5fff, 0, 0);
|
| 456 | | |
| 457 | | switch (messram_get_size(messram))
|
| 458 | | {
|
| 459 | | case 16*1024:
|
| 460 | | memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram), 0);
|
| 461 | | memory_unmap_readwrite(program, 0x6000, 0xbfff, 0, 0);
|
| 462 | | memory_unmap_readwrite(program, 0x8000, 0xbfff, 0, 0);
|
| 463 | | memory_install_readwrite_bank(program, 0xc000, 0xffff, 0, 0, "bank3");
|
| 464 | | break;
|
| 465 | | |
| 466 | | case 32*1024:
|
| 467 | | memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram), 0);
|
| 468 | | memory_unmap_readwrite(program, 0x6000, 0xbfff, 0, 0);
|
| 469 | | memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank3");
|
| 470 | | break;
|
| 471 | | |
| 472 | | case 64*1024:
|
| 473 | | memory_configure_bank(machine, "bank1", 0, 1, messram_get_ptr(messram), 0);
|
| 474 | | memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(messram) + 0x6000, 0);
|
| 475 | | memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram) + 0x8000, 0);
|
| 476 | | memory_install_readwrite_bank(program, 0x0000, 0x5fff, 0, 0, "bank1");
|
| 477 | | memory_install_readwrite_bank(program, 0x6000, 0xbfff, 0, 0, "bank2");
|
| 478 | | memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank3");
|
| 479 | | memory_set_bank(machine, "bank2", 0);
|
| 480 | | break;
|
| 481 | | }
|
| 482 | | |
| 483 | | memory_set_bank(machine, "bank1", 1);
|
| 484 | | memory_set_bank(machine, "bank3", 0);
|
| 485 | | |
| 486 | | /* register for state saving */
|
| 487 | | // state_save_register_global(machine, state->);
|
| 488 | | }
|
| 489 | | |
| 490 | | static MACHINE_START( pc8001mk2 )
|
| 491 | | {
|
| 492 | | MACHINE_START_CALL(pc8001);
|
| 493 | | }
|
| 494 | | |
| 495 | | /* Cassette Configuration */
|
| 496 | | |
| 497 | | static const cassette_config pc8001_cassette_config =
|
| 498 | | {
|
| 499 | | cassette_default_formats,
|
| 500 | | NULL,
|
| 501 | | CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_MUTED
|
| 502 | | };
|
| 503 | | |
| 504 | | /* Machine Drivers */
|
| 505 | | |
| 506 | | static MACHINE_DRIVER_START( pc8001 )
|
| 507 | | MDRV_DRIVER_DATA(pc8001_state)
|
| 508 | | |
| 509 | | /* basic machine hardware */
|
| 510 | | MDRV_CPU_ADD(Z80_TAG, Z80, 4000000)
|
| 511 | | MDRV_CPU_PROGRAM_MAP(pc8001_mem)
|
| 512 | | MDRV_CPU_IO_MAP(pc8001_io)
|
| 513 | | MDRV_MACHINE_START(pc8001)
|
| 514 | | |
| 515 | | /* video hardware */
|
| 516 | | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
|
| 517 | | MDRV_SCREEN_REFRESH_RATE(60)
|
| 518 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
|
| 519 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
| 520 | | MDRV_SCREEN_SIZE(640, 220)
|
| 521 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1)
|
| 522 | | |
| 523 | | MDRV_PALETTE_LENGTH(8)
|
| 524 | | MDRV_PALETTE_INIT(pc8001)
|
| 525 | | |
| 526 | | MDRV_VIDEO_START(pc8001)
|
| 527 | | MDRV_VIDEO_UPDATE(pc8001)
|
| 528 | | |
| 529 | | /* sound hardware */
|
| 530 | | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 531 | | MDRV_SOUND_ADD(SPEAKER_TAG, SPEAKER, 0)
|
| 532 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
| 533 | | |
| 534 | | /* devices */
|
| 535 | | MDRV_MSM8251_ADD(I8251_TAG, pc8001_8251_intf)
|
| 536 | | MDRV_I8255A_ADD(I8255A_TAG, pc8001_8255_intf)
|
| 537 | | MDRV_I8257_ADD(I8257_TAG, 4000000, pc8001_8257_intf)
|
| 538 | | MDRV_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, pc8001_upd1990a_intf)
|
| 539 | | MDRV_UPD3301_ADD(UPD3301_TAG, 14318180, pc8001_upd3301_intf)
|
| 540 | | |
| 541 | | MDRV_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
|
| 542 | | MDRV_CASSETTE_ADD(CASSETTE_TAG, pc8001_cassette_config)
|
| 543 | | |
| 544 | | MDRV_RAM_ADD("messram")
|
| 545 | | MDRV_RAM_DEFAULT_SIZE("16K")
|
| 546 | | MDRV_RAM_EXTRA_OPTIONS("32K,64K")
|
| 547 | | MACHINE_DRIVER_END
|
| 548 | | |
| 549 | | static MACHINE_DRIVER_START( pc8001mk2 )
|
| 550 | | MDRV_IMPORT_FROM(pc8001)
|
| 551 | | |
| 552 | | MDRV_CPU_MODIFY(Z80_TAG)
|
| 553 | | MDRV_CPU_PROGRAM_MAP(pc8001mk2_mem)
|
| 554 | | MDRV_CPU_IO_MAP(pc8001mk2_io)
|
| 555 | | MDRV_MACHINE_START(pc8001mk2)
|
| 556 | | |
| 557 | | MDRV_RAM_MODIFY("messram")
|
| 558 | | MDRV_RAM_DEFAULT_SIZE("64K")
|
| 559 | | MACHINE_DRIVER_END
|
| 560 | | |
| 561 | | /* ROMs */
|
| 562 | | |
| 563 | | ROM_START( pc8001 )
|
| 564 | | ROM_REGION( 0x6000, "n80", 0 )
|
| 565 | | ROM_SYSTEM_BIOS( 0, "v101", "N-BASIC v1.01" )
|
| 566 | | ROMX_LOAD( "n80v101.rom", 0x00000, 0x6000, CRC(a2cc9f22) SHA1(6d2d838de7fea20ddf6601660d0525d5b17bf8a3), ROM_BIOS(1) )
|
| 567 | | ROM_SYSTEM_BIOS( 1, "v102", "N-BASIC v1.02" )
|
| 568 | | ROMX_LOAD( "n80v102.rom", 0x00000, 0x6000, CRC(ed01ca3f) SHA1(b34a98941499d5baf79e7c0e5578b81dbede4a58), ROM_BIOS(2) )
|
| 569 | | ROM_SYSTEM_BIOS( 2, "v110", "N-BASIC v1.10" )
|
| 570 | | ROMX_LOAD( "n80v110.rom", 0x00000, 0x6000, CRC(1e02d93f) SHA1(4603cdb7a3833e7feb257b29d8052c872369e713), ROM_BIOS(3) )
|
| 571 | | |
| 572 | | ROM_REGION( 0x800, "chargen", 0)
|
| 573 | | ROM_LOAD( "font.rom", 0x000, 0x800, CRC(56653188) SHA1(84b90f69671d4b72e8f219e1fe7cd667e976cf7f) )
|
| 574 | | ROM_END
|
| 575 | | |
| 576 | | ROM_START( pc8001mk2 )
|
| 577 | | ROM_REGION( 0x8000, "n80", 0 )
|
| 578 | | ROM_LOAD( "n80_2.rom", 0x00000, 0x8000, CRC(03cce7b6) SHA1(c12d34e42021110930fed45a8af98db52136f1fb) )
|
| 579 | | |
| 580 | | ROM_REGION( 0x800, "chargen", 0)
|
| 581 | | ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(56653188) SHA1(84b90f69671d4b72e8f219e1fe7cd667e976cf7f) )
|
| 582 | | |
| 583 | | ROM_REGION( 0x20000, "kanji", 0)
|
| 584 | | ROM_LOAD( "kanji1.rom", 0x00000, 0x20000, CRC(6178bd43) SHA1(82e11a177af6a5091dd67f50a2f4bafda84d6556) )
|
| 585 | | ROM_END
|
| 586 | | |
| 587 | | /* System Drivers */
|
| 588 | | |
| 589 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */
|
| 590 | | COMP( 1979, pc8001, 0, 0, pc8001, pc8001, 0, "NEC", "PC-8001", GAME_NOT_WORKING )
|
| 591 | | COMP( 1983, pc8001mk2, pc8001, 0, pc8001mk2, pc8001, 0, "NEC", "PC-8001mkII", GAME_NOT_WORKING )
|
| 1 | /* |
| 2 | |
| 3 | http://www2.odn.ne.jp/~haf09260/Pc80/EnrPc.htm |
| 4 | http://home1.catvmics.ne.jp/~kanemoto/n80/inside.html |
| 5 | http://www.geocities.jp/retro_zzz/machines/nec/8001/index.html |
| 6 | |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | |
| 11 | TODO: |
| 12 | |
| 13 | - print time$/date$ stalls |
| 14 | - uPD3301 attributes |
| 15 | - PCG1000 |
| 16 | - Intel 8251 |
| 17 | - cassette |
| 18 | - floppy |
| 19 | - PC-8011 |
| 20 | - PC-8021 |
| 21 | - PC-8031 |
| 22 | |
| 23 | */ |
| 24 | |
| 25 | #include "driver.h" |
| 26 | #include "includes/pc8001.h" |
| 27 | #include "cpu/z80/z80.h" |
| 28 | #include "devices/cassette.h" |
| 29 | #include "devices/messram.h" |
| 30 | #include "machine/i8257.h" |
| 31 | #include "machine/ctronics.h" |
| 32 | #include "machine/i8214.h" |
| 33 | #include "machine/i8255a.h" |
| 34 | #include "machine/msm8251.h" |
| 35 | #include "machine/upd1990a.h" |
| 36 | #include "video/upd3301.h" |
| 37 | #include "sound/speaker.h" |
| 38 | |
| 39 | /* Read/Write Handlers */ |
| 40 | |
| 41 | static WRITE8_HANDLER( port30_w ) |
| 42 | { |
| 43 | /* |
| 44 | |
| 45 | bit description |
| 46 | |
| 47 | 0 characters per line (0=40, 1=80) |
| 48 | 1 color mode (0=color, 1=B&W) |
| 49 | 2 CMT CHIN |
| 50 | 3 CMT MOTOR (1=on) |
| 51 | 4 CMT BS1 |
| 52 | 5 CMT BS2 |
| 53 | 6 unused |
| 54 | 7 unused |
| 55 | |
| 56 | */ |
| 57 | |
| 58 | pc8001_state *state = space->machine->driver_data; |
| 59 | |
| 60 | /* characters per line */ |
| 61 | state->width80 = BIT(data, 0); |
| 62 | |
| 63 | /* color mode */ |
| 64 | state->color = BIT(data, 1); |
| 65 | |
| 66 | /* cassette motor */ |
| 67 | cassette_change_state(state->cassette, BIT(data, 3) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 68 | } |
| 69 | |
| 70 | static WRITE8_HANDLER( pc8001mk2_port31_w ) |
| 71 | { |
| 72 | /* |
| 73 | |
| 74 | bit description |
| 75 | |
| 76 | 0 expansion ROM (0=expansion, 1=N80) |
| 77 | 1 memory mode (0=ROM, 1=RAM) |
| 78 | 2 color mode (0=attribute, 1=B&W) |
| 79 | 3 graphics enable |
| 80 | 4 resolution (0=640x200, 1=320x200) |
| 81 | 5 background color |
| 82 | 6 background color |
| 83 | 7 background color |
| 84 | |
| 85 | */ |
| 86 | } |
| 87 | |
| 88 | /* Memory Maps */ |
| 89 | |
| 90 | static ADDRESS_MAP_START( pc8001_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 91 | AM_RANGE(0x0000, 0x5fff) AM_RAMBANK("bank1") |
| 92 | AM_RANGE(0x6000, 0x7fff) AM_RAMBANK("bank2") |
| 93 | AM_RANGE(0x8000, 0xffff) AM_RAMBANK("bank3") |
| 94 | ADDRESS_MAP_END |
| 95 | |
| 96 | static ADDRESS_MAP_START( pc8001_io, ADDRESS_SPACE_IO, 8 ) |
| 97 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 98 | ADDRESS_MAP_UNMAP_HIGH |
| 99 | AM_RANGE(0x00, 0x00) AM_READ_PORT("KEY0") |
| 100 | AM_RANGE(0x01, 0x01) AM_READ_PORT("KEY1") |
| 101 | AM_RANGE(0x02, 0x02) AM_READ_PORT("KEY2") |
| 102 | AM_RANGE(0x03, 0x03) AM_READ_PORT("KEY3") |
| 103 | AM_RANGE(0x04, 0x04) AM_READ_PORT("KEY4") |
| 104 | AM_RANGE(0x05, 0x05) AM_READ_PORT("KEY5") |
| 105 | AM_RANGE(0x06, 0x06) AM_READ_PORT("KEY6") |
| 106 | AM_RANGE(0x07, 0x07) AM_READ_PORT("KEY7") |
| 107 | AM_RANGE(0x08, 0x08) AM_READ_PORT("KEY8") |
| 108 | AM_RANGE(0x09, 0x09) AM_READ_PORT("KEY9") |
| 109 | AM_RANGE(0x10, 0x10) AM_MIRROR(0x0f) AM_WRITE_PORT("W10") /* also AM_DEVWRITE(CENTRONICS_TAG, centronics_data_w)*/ |
| 110 | AM_RANGE(0x20, 0x20) AM_MIRROR(0x0e) AM_DEVREADWRITE(I8251_TAG, msm8251_data_r, msm8251_data_w) |
| 111 | AM_RANGE(0x21, 0x21) AM_MIRROR(0x0e) AM_DEVREADWRITE(I8251_TAG, msm8251_status_r, msm8251_control_w) |
| 112 | AM_RANGE(0x30, 0x30) AM_MIRROR(0x0f) AM_WRITE(port30_w) |
| 113 | AM_RANGE(0x40, 0x40) AM_MIRROR(0x0f) AM_READ_PORT("R40") AM_WRITE_PORT("W40") |
| 114 | AM_RANGE(0x50, 0x51) AM_DEVREADWRITE(UPD3301_TAG, upd3301_r, upd3301_w) |
| 115 | AM_RANGE(0x60, 0x68) AM_DEVREADWRITE(I8257_TAG, i8257_r, i8257_w) |
| 116 | // AM_RANGE(0x70, 0x7f) unused |
| 117 | // AM_RANGE(0x80, 0x80) AM_MIRROR(0x0f) AM_WRITE(pc8011_ext0_w) |
| 118 | // AM_RANGE(0x90, 0x90) AM_MIRROR(0x0f) AM_WRITE(pc8011_ext1_w) |
| 119 | // AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0f) AM_WRITE(pc8011_ext2_w) |
| 120 | // AM_RANGE(0xb0, 0xb0) AM_READ(pc8011_gpio8_r) |
| 121 | // AM_RANGE(0xb1, 0xb1) AM_WRITE(pc8011_gpio8_w) |
| 122 | // AM_RANGE(0xb2, 0xb2) AM_READ(pc8011_gpio4_r) |
| 123 | // AM_RANGE(0xb3, 0xb3) AM_WRITE(pc8011_gpio4_w) |
| 124 | // AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE(PC8011_CH1_I8251_TAG, msm8251_data_r, msm8251_data_w) |
| 125 | // AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE(PC8011_CH1_I8251_TAG, msm8251_status_r, msm8251_control_w) |
| 126 | // AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE(PC8011_CH2_I8251_TAG, msm8251_data_r, msm8251_data_w) |
| 127 | // AM_RANGE(0xc3, 0xc3) AM_DEVREADWRITE(PC8011_CH2_I8251_TAG, msm8251_status_r, msm8251_control_w) |
| 128 | // AM_RANGE(0xc8, 0xc8) RS-232 output enable? |
| 129 | // AM_RANGE(0xca, 0xca) RS-232 output disable? |
| 130 | // AM_RANGE(0xd0, 0xd3) AM_DEVREADWRITE(PC8011_IEEE488_I8255A_TAG, i8255a_r, i8255a_w) |
| 131 | // AM_RANGE(0xd8, 0xd8) AM_READ(pc8011_ieee488_control_signal_input_r) |
| 132 | // AM_RANGE(0xda, 0xda) AM_READ(pc8011_ieee488_bus_address_mode_r) |
| 133 | // AM_RANGE(0xdc, 0xdc) AM_WRITE(pc8011_ieee488_nrfd_w) |
| 134 | // AM_RANGE(0xde, 0xde) AM_WRITE(pc8011_ieee488_bus_mode_control_w) |
| 135 | // AM_RANGE(0xe0, 0xe3) AM_WRITE(expansion_storage_mode_w) |
| 136 | // AM_RANGE(0xe4, 0xe4) AM_MIRROR(0x01) AM_WRITE(irq_level_w) |
| 137 | // AM_RANGE(0xe6, 0xe6) AM_WRITE(irq_mask_w) |
| 138 | // AM_RANGE(0xe7, 0xe7) AM_WRITE(pc8012_memory_mode_w) |
| 139 | // AM_RANGE(0xe8, 0xfb) unused |
| 140 | AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE(I8255A_TAG, i8255a_r, i8255a_w) |
| 141 | ADDRESS_MAP_END |
| 142 | |
| 143 | static ADDRESS_MAP_START( pc8001mk2_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 144 | AM_RANGE(0x0000, 0x5fff) AM_RAMBANK("bank1") |
| 145 | AM_RANGE(0x6000, 0x7fff) AM_RAMBANK("bank2") |
| 146 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK("bank3") |
| 147 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK("bank4") |
| 148 | ADDRESS_MAP_END |
| 149 | |
| 150 | static ADDRESS_MAP_START( pc8001mk2_io, ADDRESS_SPACE_IO, 8 ) |
| 151 | AM_IMPORT_FROM(pc8001_io) |
| 152 | AM_RANGE(0x30, 0x30) AM_WRITE(port30_w) |
| 153 | AM_RANGE(0x31, 0x31) AM_WRITE(pc8001mk2_port31_w) |
| 154 | // AM_RANGE(0x5c, 0x5c) AM_WRITE(pc8001mk2_gram_on_w) |
| 155 | // AM_RANGE(0x5f, 0x5f) AM_WRITE(pc8001mk2_gram_off_w) |
| 156 | // AM_RANGE(0xe8, 0xe8) kanji_address_lo_w, kanji_data_lo_r |
| 157 | // AM_RANGE(0xe9, 0xe9) kanji_address_hi_w, kanji_data_hi_r |
| 158 | // AM_RANGE(0xea, 0xea) kanji_readout_start_w |
| 159 | // AM_RANGE(0xeb, 0xeb) kanji_readout_end_w |
| 160 | // AM_RANGE(0xf3, 0xf3) DMA type disk unit interface selection port |
| 161 | // AM_RANGE(0xf4, 0xf4) DMA type 8 inch control |
| 162 | // AM_RANGE(0xf5, 0xf5) DMA type 8 inch margin control |
| 163 | // AM_RANGE(0xf6, 0xf6) DMA type 8 inch FDC status |
| 164 | // AM_RANGE(0xf7, 0xf7) DMA type 8 inch FDC data register |
| 165 | // AM_RANGE(0xf8, 0xf8) DMA type 5 inch control |
| 166 | // AM_RANGE(0xf9, 0xf9) DMA type 5 inch margin control |
| 167 | // AM_RANGE(0xfa, 0xfa) DMA type 5 inch FDC status |
| 168 | // AM_RANGE(0xfb, 0xfb) DMA type 5 inch FDC data register |
| 169 | ADDRESS_MAP_END |
| 170 | |
| 171 | /* Input Ports */ |
| 172 | |
| 173 | static INPUT_PORTS_START( pc8001 ) |
| 174 | PORT_START("KEY0") |
| 175 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) |
| 176 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) |
| 177 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) |
| 178 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) |
| 179 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) |
| 180 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) |
| 181 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) |
| 182 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) |
| 183 | |
| 184 | PORT_START("KEY1") |
| 185 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) |
| 186 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) |
| 187 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) |
| 188 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) |
| 189 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad =") PORT_CODE(KEYCODE_PGUP) |
| 190 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad ,") PORT_CODE(KEYCODE_PGDN) |
| 191 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) |
| 192 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(13) |
| 193 | |
| 194 | PORT_START("KEY2") |
| 195 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') |
| 196 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 197 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 198 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 199 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 200 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 201 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') |
| 202 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') |
| 203 | |
| 204 | PORT_START("KEY3") |
| 205 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') |
| 206 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 207 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 208 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 209 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') |
| 210 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 211 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 212 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 213 | |
| 214 | PORT_START("KEY4") |
| 215 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 216 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') |
| 217 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') |
| 218 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 219 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') |
| 220 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 221 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 222 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') |
| 223 | |
| 224 | PORT_START("KEY5") |
| 225 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') |
| 226 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 227 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 228 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('[') PORT_CHAR('{') |
| 229 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xA5') PORT_CHAR('|') |
| 230 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']') PORT_CHAR('}') |
| 231 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') |
| 232 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') |
| 233 | |
| 234 | PORT_START("KEY6") |
| 235 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 236 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 237 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 238 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 239 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 240 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 241 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 242 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 243 | |
| 244 | PORT_START("KEY7") |
| 245 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 246 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 247 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') |
| 248 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') |
| 249 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 250 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 251 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 252 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(" _") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0) PORT_CHAR('_') |
| 253 | |
| 254 | PORT_START("KEY8") |
| 255 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Clr Home") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 256 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 257 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x92") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 258 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Del Ins") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 259 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Grph") PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 260 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Kana") PORT_CODE(KEYCODE_LCONTROL) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 261 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 262 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 263 | |
| 264 | PORT_START("KEY9") |
| 265 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 266 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 267 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 268 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 269 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 270 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 271 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 272 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 273 | |
| 274 | PORT_START("DSW1") |
| 275 | |
| 276 | PORT_START("W10") |
| 277 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_c0_w) |
| 278 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_c1_w) |
| 279 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_c2_w) |
| 280 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_data_in_w) |
| 281 | PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 282 | |
| 283 | PORT_START("R40") |
| 284 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_busy_r) |
| 285 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(CENTRONICS_TAG, centronics_ack_r) |
| 286 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) // CMT CDIN |
| 287 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL ) // EXP /EXTON |
| 288 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(UPD1990A_TAG, upd1990a_data_out_r) |
| 289 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE(UPD3301_TAG, upd3301_vrtc_r) |
| 290 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 291 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 292 | |
| 293 | PORT_START("W40") |
| 294 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(CENTRONICS_TAG, centronics_strobe_w) |
| 295 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_stb_w) |
| 296 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(UPD1990A_TAG, upd1990a_clk_w) |
| 297 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) // CRT /CLDS CLK |
| 298 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 299 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE(SPEAKER_TAG, speaker_level_w) |
| 300 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 301 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 302 | INPUT_PORTS_END |
| 303 | |
| 304 | /* Video */ |
| 305 | |
| 306 | static PALETTE_INIT( pc8001 ) |
| 307 | { |
| 308 | } |
| 309 | |
| 310 | static VIDEO_START( pc8001 ) |
| 311 | { |
| 312 | pc8001_state *state = machine->driver_data; |
| 313 | |
| 314 | /* find memory regions */ |
| 315 | state->char_rom = memory_region(machine, "chargen"); |
| 316 | } |
| 317 | |
| 318 | static VIDEO_UPDATE( pc8001 ) |
| 319 | { |
| 320 | pc8001_state *state = screen->machine->driver_data; |
| 321 | |
| 322 | upd3301_update(state->upd3301, bitmap, cliprect); |
| 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | /* uPD3301 Interface */ |
| 328 | |
| 329 | static UPD3301_DISPLAY_PIXELS( pc8001_display_pixels ) |
| 330 | { |
| 331 | pc8001_state *state = device->machine->driver_data; |
| 332 | |
| 333 | UINT8 data = state->char_rom[(cc << 3) | lc]; |
| 334 | int i; |
| 335 | |
| 336 | if (lc >= 8) return; |
| 337 | if (csr) data = 0xff; |
| 338 | |
| 339 | if (state->width80) |
| 340 | { |
| 341 | for (i = 0; i < 8; i++) |
| 342 | { |
| 343 | int color = BIT(data, 7) ^ rvv; |
| 344 | |
| 345 | *BITMAP_ADDR16(bitmap, y, (sx * 8) + i) = color; |
| 346 | |
| 347 | data <<= 1; |
| 348 | } |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | if (sx % 2) return; |
| 353 | |
| 354 | for (i = 0; i < 8; i++) |
| 355 | { |
| 356 | int color = BIT(data, 7) ^ rvv; |
| 357 | |
| 358 | *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2)) = color; |
| 359 | *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2) + 1) = color; |
| 360 | |
| 361 | data <<= 1; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | static UPD3301_INTERFACE( pc8001_upd3301_intf ) |
| 367 | { |
| 368 | SCREEN_TAG, |
| 369 | 8, |
| 370 | pc8001_display_pixels, |
| 371 | DEVCB_NULL, |
| 372 | DEVCB_DEVICE_LINE(I8257_TAG, i8257_drq2_w), |
| 373 | DEVCB_NULL, |
| 374 | DEVCB_NULL |
| 375 | }; |
| 376 | |
| 377 | /* 8251 Interface */ |
| 378 | |
| 379 | static msm8251_interface pc8001_8251_intf = |
| 380 | { |
| 381 | NULL, |
| 382 | NULL, |
| 383 | NULL |
| 384 | }; |
| 385 | |
| 386 | /* 8255 Interface */ |
| 387 | |
| 388 | static I8255A_INTERFACE( pc8001_8255_intf ) |
| 389 | { |
| 390 | DEVCB_NULL, |
| 391 | DEVCB_NULL, |
| 392 | DEVCB_NULL, |
| 393 | DEVCB_NULL, |
| 394 | DEVCB_NULL, |
| 395 | DEVCB_NULL |
| 396 | }; |
| 397 | |
| 398 | /* 8257 Interface */ |
| 399 | |
| 400 | static WRITE_LINE_DEVICE_HANDLER( hrq_w ) |
| 401 | { |
| 402 | /* HACK - this should be connected to the BUSREQ line of Z80 */ |
| 403 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_HALT, state); |
| 404 | |
| 405 | /* HACK - this should be connected to the BUSACK line of Z80 */ |
| 406 | i8257_hlda_w(device, state); |
| 407 | } |
| 408 | |
| 409 | static I8257_INTERFACE( pc8001_8257_intf ) |
| 410 | { |
| 411 | DEVCB_LINE(hrq_w), |
| 412 | DEVCB_NULL, |
| 413 | DEVCB_NULL, |
| 414 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }, |
| 415 | { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER(UPD3301_TAG, upd3301_dack_w), DEVCB_NULL }, |
| 416 | I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_read_byte), |
| 417 | I8257_MEMORY_HANDLER(Z80_TAG, PROGRAM, memory_write_byte), |
| 418 | { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL } |
| 419 | }; |
| 420 | |
| 421 | /* uPD1990A Interface */ |
| 422 | |
| 423 | static UPD1990A_INTERFACE( pc8001_upd1990a_intf ) |
| 424 | { |
| 425 | DEVCB_NULL, |
| 426 | DEVCB_NULL |
| 427 | }; |
| 428 | |
| 429 | /* Machine Initialization */ |
| 430 | |
| 431 | static MACHINE_START( pc8001 ) |
| 432 | { |
| 433 | pc8001_state *state = machine->driver_data; |
| 434 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 435 | const device_config *messram = devtag_get_device(machine, "messram"); |
| 436 | |
| 437 | /* look up devices */ |
| 438 | state->i8257 = devtag_get_device(machine, I8257_TAG); |
| 439 | state->upd1990a = devtag_get_device(machine, UPD1990A_TAG); |
| 440 | state->upd3301 = devtag_get_device(machine, UPD3301_TAG); |
| 441 | state->speaker = devtag_get_device(machine, SPEAKER_TAG); |
| 442 | state->cassette = devtag_get_device(machine, CASSETTE_TAG); |
| 443 | state->centronics = devtag_get_device(machine, CENTRONICS_TAG); |
| 444 | |
| 445 | /* initialize RTC */ |
| 446 | upd1990a_cs_w(state->upd1990a, 1); |
| 447 | upd1990a_oe_w(state->upd1990a, 1); |
| 448 | |
| 449 | /* initialize DMA */ |
| 450 | i8257_ready_w(state->i8257, 1); |
| 451 | |
| 452 | /* setup memory banking */ |
| 453 | memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "n80"), 0); |
| 454 | memory_install_read_bank(program, 0x0000, 0x5fff, 0, 0, "bank1"); |
| 455 | memory_unmap_write(program, 0x0000, 0x5fff, 0, 0); |
| 456 | |
| 457 | switch (messram_get_size(messram)) |
| 458 | { |
| 459 | case 16*1024: |
| 460 | memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram), 0); |
| 461 | memory_unmap_readwrite(program, 0x6000, 0xbfff, 0, 0); |
| 462 | memory_unmap_readwrite(program, 0x8000, 0xbfff, 0, 0); |
| 463 | memory_install_readwrite_bank(program, 0xc000, 0xffff, 0, 0, "bank3"); |
| 464 | break; |
| 465 | |
| 466 | case 32*1024: |
| 467 | memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram), 0); |
| 468 | memory_unmap_readwrite(program, 0x6000, 0xbfff, 0, 0); |
| 469 | memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank3"); |
| 470 | break; |
| 471 | |
| 472 | case 64*1024: |
| 473 | memory_configure_bank(machine, "bank1", 0, 1, messram_get_ptr(messram), 0); |
| 474 | memory_configure_bank(machine, "bank2", 0, 1, messram_get_ptr(messram) + 0x6000, 0); |
| 475 | memory_configure_bank(machine, "bank3", 0, 1, messram_get_ptr(messram) + 0x8000, 0); |
| 476 | memory_install_readwrite_bank(program, 0x0000, 0x5fff, 0, 0, "bank1"); |
| 477 | memory_install_readwrite_bank(program, 0x6000, 0xbfff, 0, 0, "bank2"); |
| 478 | memory_install_readwrite_bank(program, 0x8000, 0xffff, 0, 0, "bank3"); |
| 479 | memory_set_bank(machine, "bank2", 0); |
| 480 | break; |
| 481 | } |
| 482 | |
| 483 | memory_set_bank(machine, "bank1", 1); |
| 484 | memory_set_bank(machine, "bank3", 0); |
| 485 | |
| 486 | /* register for state saving */ |
| 487 | // state_save_register_global(machine, state->); |
| 488 | } |
| 489 | |
| 490 | static MACHINE_START( pc8001mk2 ) |
| 491 | { |
| 492 | MACHINE_START_CALL(pc8001); |
| 493 | } |
| 494 | |
| 495 | /* Cassette Configuration */ |
| 496 | |
| 497 | static const cassette_config pc8001_cassette_config = |
| 498 | { |
| 499 | cassette_default_formats, |
| 500 | NULL, |
| 501 | CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_MUTED |
| 502 | }; |
| 503 | |
| 504 | /* Machine Drivers */ |
| 505 | |
| 506 | static MACHINE_DRIVER_START( pc8001 ) |
| 507 | MDRV_DRIVER_DATA(pc8001_state) |
| 508 | |
| 509 | /* basic machine hardware */ |
| 510 | MDRV_CPU_ADD(Z80_TAG, Z80, 4000000) |
| 511 | MDRV_CPU_PROGRAM_MAP(pc8001_mem) |
| 512 | MDRV_CPU_IO_MAP(pc8001_io) |
| 513 | MDRV_MACHINE_START(pc8001) |
| 514 | |
| 515 | /* video hardware */ |
| 516 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 517 | MDRV_SCREEN_REFRESH_RATE(60) |
| 518 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 519 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 520 | MDRV_SCREEN_SIZE(640, 220) |
| 521 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1) |
| 522 | |
| 523 | MDRV_PALETTE_LENGTH(8) |
| 524 | MDRV_PALETTE_INIT(pc8001) |
| 525 | |
| 526 | MDRV_VIDEO_START(pc8001) |
| 527 | MDRV_VIDEO_UPDATE(pc8001) |
| 528 | |
| 529 | /* sound hardware */ |
| 530 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 531 | MDRV_SOUND_ADD(SPEAKER_TAG, SPEAKER, 0) |
| 532 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 533 | |
| 534 | /* devices */ |
| 535 | MDRV_MSM8251_ADD(I8251_TAG, pc8001_8251_intf) |
| 536 | MDRV_I8255A_ADD(I8255A_TAG, pc8001_8255_intf) |
| 537 | MDRV_I8257_ADD(I8257_TAG, 4000000, pc8001_8257_intf) |
| 538 | MDRV_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, pc8001_upd1990a_intf) |
| 539 | MDRV_UPD3301_ADD(UPD3301_TAG, 14318180, pc8001_upd3301_intf) |
| 540 | |
| 541 | MDRV_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics) |
| 542 | MDRV_CASSETTE_ADD(CASSETTE_TAG, pc8001_cassette_config) |
| 543 | |
| 544 | MDRV_RAM_ADD("messram") |
| 545 | MDRV_RAM_DEFAULT_SIZE("16K") |
| 546 | MDRV_RAM_EXTRA_OPTIONS("32K,64K") |
| 547 | MACHINE_DRIVER_END |
| 548 | |
| 549 | static MACHINE_DRIVER_START( pc8001mk2 ) |
| 550 | MDRV_IMPORT_FROM(pc8001) |
| 551 | |
| 552 | MDRV_CPU_MODIFY(Z80_TAG) |
| 553 | MDRV_CPU_PROGRAM_MAP(pc8001mk2_mem) |
| 554 | MDRV_CPU_IO_MAP(pc8001mk2_io) |
| 555 | MDRV_MACHINE_START(pc8001mk2) |
| 556 | |
| 557 | MDRV_RAM_MODIFY("messram") |
| 558 | MDRV_RAM_DEFAULT_SIZE("64K") |
| 559 | MACHINE_DRIVER_END |
| 560 | |
| 561 | /* ROMs */ |
| 562 | |
| 563 | ROM_START( pc8001 ) |
| 564 | ROM_REGION( 0x6000, "n80", 0 ) |
| 565 | ROM_SYSTEM_BIOS( 0, "v101", "N-BASIC v1.01" ) |
| 566 | ROMX_LOAD( "n80v101.rom", 0x00000, 0x6000, CRC(a2cc9f22) SHA1(6d2d838de7fea20ddf6601660d0525d5b17bf8a3), ROM_BIOS(1) ) |
| 567 | ROM_SYSTEM_BIOS( 1, "v102", "N-BASIC v1.02" ) |
| 568 | ROMX_LOAD( "n80v102.rom", 0x00000, 0x6000, CRC(ed01ca3f) SHA1(b34a98941499d5baf79e7c0e5578b81dbede4a58), ROM_BIOS(2) ) |
| 569 | ROM_SYSTEM_BIOS( 2, "v110", "N-BASIC v1.10" ) |
| 570 | ROMX_LOAD( "n80v110.rom", 0x00000, 0x6000, CRC(1e02d93f) SHA1(4603cdb7a3833e7feb257b29d8052c872369e713), ROM_BIOS(3) ) |
| 571 | |
| 572 | ROM_REGION( 0x800, "chargen", 0) |
| 573 | ROM_LOAD( "font.rom", 0x000, 0x800, CRC(56653188) SHA1(84b90f69671d4b72e8f219e1fe7cd667e976cf7f) ) |
| 574 | ROM_END |
| 575 | |
| 576 | ROM_START( pc8001mk2 ) |
| 577 | ROM_REGION( 0x8000, "n80", 0 ) |
| 578 | ROM_LOAD( "n80_2.rom", 0x00000, 0x8000, CRC(03cce7b6) SHA1(c12d34e42021110930fed45a8af98db52136f1fb) ) |
| 579 | |
| 580 | ROM_REGION( 0x800, "chargen", 0) |
| 581 | ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(56653188) SHA1(84b90f69671d4b72e8f219e1fe7cd667e976cf7f) ) |
| 582 | |
| 583 | ROM_REGION( 0x20000, "kanji", 0) |
| 584 | ROM_LOAD( "kanji1.rom", 0x00000, 0x20000, CRC(6178bd43) SHA1(82e11a177af6a5091dd67f50a2f4bafda84d6556) ) |
| 585 | ROM_END |
| 586 | |
| 587 | /* System Drivers */ |
| 588 | |
| 589 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 590 | COMP( 1979, pc8001, 0, 0, pc8001, pc8001, 0, "NEC", "PC-8001", GAME_NOT_WORKING ) |
| 591 | COMP( 1983, pc8001mk2, pc8001, 0, pc8001mk2, pc8001, 0, "NEC", "PC-8001mkII", GAME_NOT_WORKING ) |
src/mess/drivers/rmnimbus.c
| r6857 | r6858 | |
| 1 | | /*
|
| 2 | | drivers/rmnimbus.c
|
| 3 | | |
| 4 | | Research machines Nimbus.
|
| 5 | | |
| 6 | | 2009-11-14, P.Harvey-Smith.
|
| 7 | | |
| 8 | | */
|
| 9 | | |
| 10 | | #include "driver.h"
|
| 11 | | #include "image.h"
|
| 12 | | #include "cpu/i86/i86.h"
|
| 13 | | #include "cpu/mcs51/mcs51.h"
|
| 14 | | #include "devices/flopdrv.h"
|
| 15 | | #include "devices/messram.h"
|
| 16 | | #include "formats/flopimg.h"
|
| 17 | | #include "formats/pc_dsk.h"
|
| 18 | | #include "includes/rmnimbus.h"
|
| 19 | | #include "machine/z80sio.h"
|
| 20 | | |
| 21 | | static const unsigned char nimbus_palette[] =
|
| 22 | | {
|
| 23 | | /*normal brightness */
|
| 24 | | 0x00,0x00,0x00, /* black */
|
| 25 | | 0x00,0x00,0x80, /* blue */
|
| 26 | | 0x80,0x00,0x00, /* red */
|
| 27 | | 0x80,0x00,0x80, /* magenta */
|
| 28 | | 0x00,0x80,0x00, /* green */
|
| 29 | | 0x00,0x80,0x80, /* cyan */
|
| 30 | | 0x80,0x80,0x00, /* yellow */
|
| 31 | | 0x80,0x80,0x80, /* light grey */
|
| 32 | | |
| 33 | | /*enhanced brightness*/
|
| 34 | | 0x40,0x40,0x40, /* dark grey */
|
| 35 | | 0x00,0x00,0xFF, /* light blue */
|
| 36 | | 0xFF,0x00,0x00, /* light red */
|
| 37 | | 0xFF,0x00,0xFF, /* light magenta */
|
| 38 | | 0x00,0xFF,0x00, /* light green */
|
| 39 | | 0x00,0xFF,0xFF, /* light cyan */
|
| 40 | | 0xFF,0xFF,0x00, /* yellow */
|
| 41 | | 0xFF,0xFF,0xFF /* white */
|
| 42 | | };
|
| 43 | | |
| 44 | | static const floppy_config nimbus_floppy_config =
|
| 45 | | {
|
| 46 | | DEVCB_NULL,
|
| 47 | | DEVCB_NULL,
|
| 48 | | DEVCB_NULL,
|
| 49 | | DEVCB_NULL,
|
| 50 | | DEVCB_NULL,
|
| 51 | | FLOPPY_DRIVE_DS_80,
|
| 52 | | FLOPPY_OPTIONS_NAME(pc),
|
| 53 | | DO_NOT_KEEP_GEOMETRY
|
| 54 | | };
|
| 55 | | |
| 56 | | |
| 57 | | static ADDRESS_MAP_START(nimbus_mem, ADDRESS_SPACE_PROGRAM, 16)
|
| 58 | | AM_RANGE( 0x00000, 0xEFFFF ) AM_RAM
|
| 59 | | AM_RANGE( 0xF0000, 0xFFFFF ) AM_ROM |
| 60 | | ADDRESS_MAP_END
|
| 61 | | |
| 62 | | static ADDRESS_MAP_START(nimbus_io, ADDRESS_SPACE_IO, 16)
|
| 63 | | AM_RANGE( 0x0000, 0x002f) AM_READWRITE( nimbus_video_io_r, nimbus_video_io_w)
|
| 64 | | AM_RANGE( 0x0030, 0x00ef) AM_READWRITE( nimbus_io_r, nimbus_io_w)
|
| 65 | | AM_RANGE( 0X00f0, 0X00f7) AM_DEVREADWRITE8( Z80SIO_TAG, sio_r, sio_w, 0x00FF)
|
| 66 | | AM_RANGE( 0x0400, 0x041f) AM_READWRITE8( nimbus_fdc_r, nimbus_fdc_w, 0x00FF)
|
| 67 | | AM_RANGE( 0xff00, 0xffff) AM_READWRITE( i186_internal_port_r, i186_internal_port_w)/* CPU 80186 */
|
| 68 | | ADDRESS_MAP_END
|
| 69 | | |
| 70 | | static INPUT_PORTS_START( nimbus )
|
| 71 | | PORT_START("KEY0") /* Key row 0 scancodes 00..07 */
|
| 72 | | //PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
|
| 73 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED)
|
| 74 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(0x1B)
|
| 75 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
|
| 76 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2')
|
| 77 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
|
| 78 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4')
|
| 79 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5')
|
| 80 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6')
|
| 81 | | |
| 82 | | PORT_START("KEY1") /* Key row 1 scancodes 08..0F */
|
| 83 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_1) PORT_CHAR('7')
|
| 84 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_ESC) PORT_CHAR('8')
|
| 85 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_1) PORT_CHAR('9')
|
| 86 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_2) PORT_CHAR('0')
|
| 87 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')
|
| 88 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=')
|
| 89 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BSPACE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(0x08)
|
| 90 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR(0x09)
|
| 91 | | |
| 92 | | PORT_START("KEY2") /* Key row 2 scancodes 10..17 */
|
| 93 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
|
| 94 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('W')
|
| 95 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E')
|
| 96 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('R')
|
| 97 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('T')
|
| 98 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
|
| 99 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('U')
|
| 100 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('I')
|
| 101 | | |
| 102 | | PORT_START("KEY3") /* Key row 3 scancodes 18..1F */
|
| 103 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('O')
|
| 104 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P')
|
| 105 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')
|
| 106 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']')
|
| 107 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(0x0D)
|
| 108 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) // Ether control
|
| 109 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A')
|
| 110 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S')
|
| 111 | | |
| 112 | | PORT_START("KEY4") /* Key row 4 scancodes 20..27 */
|
| 113 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D')
|
| 114 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F')
|
| 115 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G')
|
| 116 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('H')
|
| 117 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('J')
|
| 118 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('K')
|
| 119 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L')
|
| 120 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(";") PORT_CODE(KEYCODE_COLON) PORT_CHAR(';')
|
| 121 | | |
| 122 | | PORT_START("KEY5") /* Key row 5 scancodes 28..2F */
|
| 123 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("#") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('#')
|
| 124 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\\") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')
|
| 125 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LSHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
| 126 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TILDE") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`')
|
| 127 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
|
| 128 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('X')
|
| 129 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
|
| 130 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V')
|
| 131 | |
|
| 132 | | |
| 133 | | PORT_START("KEY6") /* Key row 6 scancodes 30..37 */
|
| 134 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B')
|
| 135 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N')
|
| 136 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M')
|
| 137 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')
|
| 138 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.')
|
| 139 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/')
|
| 140 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RSHIFT") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_2)
|
| 141 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PRSCR") PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR('*')
|
| 142 | |
|
| 143 | | PORT_START("KEY7") /* Key row 7 scancodes 38..3F */
|
| 144 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ALT") PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT)
|
| 145 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
| 146 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CAPS") PORT_CODE(KEYCODE_CAPSLOCK) |
| 147 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1)
|
| 148 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2)
|
| 149 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3)
|
| 150 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4)
|
| 151 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5)
|
| 152 | | |
| 153 | |
|
| 154 | | PORT_START("KEY8") /* Key row 8 scancodes 40..47 */
|
| 155 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) |
| 156 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) |
| 157 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) |
| 158 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) |
| 159 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) |
| 160 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMLK") PORT_CODE(KEYCODE_NUMLOCK) |
| 161 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SCRLK") PORT_CODE(KEYCODE_SCRLOCK) |
| 162 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR('7')
|
| 163 | | |
| 164 | | PORT_START("KEY9") /* Key row 9 scancodes 48..4F */
|
| 165 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP8") PORT_CODE(KEYCODE_8_PAD) //PORT_CHAR('8')
|
| 166 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP9") PORT_CODE(KEYCODE_9_PAD) //PORT_CHAR('9')
|
| 167 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP-") PORT_CODE(KEYCODE_MINUS_PAD) //PORT_CHAR('-')
|
| 168 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP4") PORT_CODE(KEYCODE_4_PAD) //PORT_CHAR('4')
|
| 169 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP5") PORT_CODE(KEYCODE_5_PAD) //PORT_CHAR('5')
|
| 170 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) //PORT_CHAR('6')
|
| 171 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) //PORT_CHAR('+')
|
| 172 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) //PORT_CHAR('1')
|
| 173 | | |
| 174 | | PORT_START("KEY10") /* Key row 10 scancodes 50..57 */
|
| 175 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP2") PORT_CODE(KEYCODE_2_PAD) //PORT_CHAR('2')
|
| 176 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP3") PORT_CODE(KEYCODE_3_PAD) //PORT_CHAR('3')
|
| 177 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP0") PORT_CODE(KEYCODE_0_PAD) //PORT_CHAR('0')
|
| 178 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP.") PORT_CODE(KEYCODE_DEL_PAD) //PORT_CHAR('.')
|
| 179 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
| 180 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED)
|
| 181 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
|
| 182 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
| 183 | | //PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR('5')
|
| 184 | | //PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR('6')
|
| 185 | | //PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+')
|
| 186 | | //PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR('1')
|
| 187 | | INPUT_PORTS_END
|
| 188 | | |
| 189 | | static ADDRESS_MAP_START(nimbus_iocpu_mem, ADDRESS_SPACE_PROGRAM, 8)
|
| 190 | | ADDRESS_MAP_UNMAP_HIGH
|
| 191 | | AM_RANGE(0x0000, 0x1fff) AM_ROM
|
| 192 | | AM_RANGE(0x2000, 0x7fff) AM_RAM
|
| 193 | | //AM_RANGE(0x8000, 0x9fff) AM_ROM // EPROM
|
| 194 | | //AM_RANGE(0xc000, 0xdfff) // Expansion block
|
| 195 | | //AM_RANGE(0xe000, 0xffff) // Expansion block
|
| 196 | | ADDRESS_MAP_END
|
| 197 | | |
| 198 | | static ADDRESS_MAP_START( nimbus_iocpu_io , ADDRESS_SPACE_IO, 8)
|
| 199 | | ADDRESS_MAP_UNMAP_HIGH
|
| 200 | | AM_RANGE(0x0000, 0x7fff) AM_RAM
|
| 201 | | //AM_RANGE(0x8000, 0x9fff) AM_ROM // EPROM
|
| 202 | | //AM_RANGE(0xa000, 0xa003) AM_DEVREADWRITE("ppi8255", i8255a_r, i8255a_w) // PPI-8255
|
| 203 | | //AM_RANGE(0xc000, 0xdfff) // Expansion block
|
| 204 | | //AM_RANGE(0xe000, 0xffff) // Expansion block
|
| 205 | | ADDRESS_MAP_END
|
| 206 | | |
| 207 | | |
| 208 | | static PALETTE_INIT( nimbus )
|
| 209 | | {
|
| 210 | | int i;
|
| 211 | | |
| 212 | | for ( i = 0; i < sizeof(nimbus_palette) / 3; i++ ) {
|
| 213 | | palette_set_color_rgb(machine, i, nimbus_palette[i*3], nimbus_palette[i*3+1], nimbus_palette[i*3+2]);
|
| 214 | | }
|
| 215 | | }
|
| 216 | | |
| 217 | | |
| 218 | | static MACHINE_DRIVER_START( nimbus )
|
| 219 | | /* basic machine hardware */
|
| 220 | | MDRV_CPU_ADD(MAINCPU_TAG, I80186, 10000000)
|
| 221 | | MDRV_CPU_PROGRAM_MAP(nimbus_mem)
|
| 222 | | MDRV_CPU_IO_MAP(nimbus_io)
|
| 223 | |
|
| 224 | | MDRV_CPU_ADD(IOCPU_TAG, I8031, 8000000)
|
| 225 | | MDRV_CPU_PROGRAM_MAP(nimbus_iocpu_mem)
|
| 226 | | MDRV_CPU_IO_MAP(nimbus_iocpu_io)
|
| 227 | |
|
| 228 | | MDRV_MACHINE_START( nimbus )
|
| 229 | |
|
| 230 | | MDRV_MACHINE_RESET(nimbus)
|
| 231 | | |
| 232 | | /* video hardware */
|
| 233 | | MDRV_SCREEN_ADD("screen", RASTER)
|
| 234 | | MDRV_SCREEN_REFRESH_RATE(50)
|
| 235 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100))
|
| 236 | | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
|
| 237 | | |
| 238 | | MDRV_PALETTE_LENGTH(ARRAY_LENGTH(nimbus_palette) / 3)
|
| 239 | | MDRV_PALETTE_INIT( nimbus )
|
| 240 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
| 241 | | |
| 242 | | MDRV_SCREEN_SIZE(650, 260)
|
| 243 | | MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 249)
|
| 244 | |
|
| 245 | | MDRV_VIDEO_START(nimbus)
|
| 246 | | MDRV_VIDEO_UPDATE(nimbus)
|
| 247 | | MDRV_VIDEO_EOF(nimbus)
|
| 248 | | MDRV_VIDEO_RESET(nimbus)
|
| 249 | | |
| 250 | | |
| 251 | | MDRV_WD2793_ADD(FDC_TAG, nimbus_wd17xx_interface )
|
| 252 | | MDRV_FLOPPY_4_DRIVES_ADD(nimbus_floppy_config)
|
| 253 | | |
| 254 | | MDRV_RAM_ADD("messram")
|
| 255 | | MDRV_RAM_DEFAULT_SIZE("512K")
|
| 256 | | MDRV_RAM_EXTRA_OPTIONS("1024K,1536K")
|
| 257 | | |
| 258 | | /* Peripheral chips */
|
| 259 | | MDRV_Z80SIO_ADD(Z80SIO_TAG, 4000000, sio_intf)
|
| 260 | | MACHINE_DRIVER_END
|
| 261 | | |
| 262 | | |
| 263 | | ROM_START( nimbus )
|
| 264 | | ROM_REGION( 0x100000, MAINCPU_TAG, 0 )
|
| 265 | | |
| 266 | | // ROM_LOAD16_BYTE("sys1-1.31a-16128-1986-06-18.rom", 0x0001, 0x8000, CRC(6416eb05) SHA1(1b640163a7efbc24381c7b24976a8609c066959b))
|
| 267 | | // ROM_RELOAD(0xf0001,0x8000)
|
| 268 | | // ROM_LOAD16_BYTE("sys2-1.31a-16129-1986-06-18.rom", 0x0000, 0x8000, CRC(b224359d) SHA1(456bbe37afcd4429cca76ba2d6bd534dfda3fc9c))
|
| 269 | | // ROM_RELOAD(0xf0000,0x8000)
|
| 270 | | |
| 271 | | ROM_LOAD16_BYTE("sys-1-1.32f-22779-1989-10-20.rom", 0x0001, 0x8000, CRC(786c31e8) SHA1(da7f828f7f96087518bea1a3d89fee59b283b4ba))
|
| 272 | | ROM_RELOAD(0xf0001,0x8000)
|
| 273 | | ROM_LOAD16_BYTE("sys-2-1.32f-22779-1989-10-20.rom", 0x0000, 0x8000, CRC(0be3db64) SHA1(af806405ec6fbc20385705f90d5059a47de17b08))
|
| 274 | | ROM_RELOAD(0xf0000,0x8000)
|
| 275 | | |
| 276 | | ROM_REGION( 0x4000, IOCPU_TAG, 0 )
|
| 277 | | ROM_LOAD("hexec-v1.02u-13488-1985-10-29.rom", 0x0000, 0x1000, CRC(75c6adfd) SHA1(0f11e0b7386c6368d20e1fc7a6196d670f924825))
|
| 278 | | ROM_END
|
| 279 | | |
| 280 | | |
| 281 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */
|
| 282 | | COMP( 1986, nimbus, 0, 0, nimbus, nimbus, 0, "Research Machines", "nimbus", GAME_NO_SOUND | GAME_NOT_WORKING)
|
| 1 | /* |
| 2 | drivers/rmnimbus.c |
| 3 | |
| 4 | Research machines Nimbus. |
| 5 | |
| 6 | 2009-11-14, P.Harvey-Smith. |
| 7 | |
| 8 | */ |
| 9 | |
| 10 | #include "driver.h" |
| 11 | #include "image.h" |
| 12 | #include "cpu/i86/i86.h" |
| 13 | #include "cpu/mcs51/mcs51.h" |
| 14 | #include "devices/flopdrv.h" |
| 15 | #include "devices/messram.h" |
| 16 | #include "formats/flopimg.h" |
| 17 | #include "formats/pc_dsk.h" |
| 18 | #include "includes/rmnimbus.h" |
| 19 | #include "machine/z80sio.h" |
| 20 | |
| 21 | static const unsigned char nimbus_palette[] = |
| 22 | { |
| 23 | /*normal brightness */ |
| 24 | 0x00,0x00,0x00, /* black */ |
| 25 | 0x00,0x00,0x80, /* blue */ |
| 26 | 0x80,0x00,0x00, /* red */ |
| 27 | 0x80,0x00,0x80, /* magenta */ |
| 28 | 0x00,0x80,0x00, /* green */ |
| 29 | 0x00,0x80,0x80, /* cyan */ |
| 30 | 0x80,0x80,0x00, /* yellow */ |
| 31 | 0x80,0x80,0x80, /* light grey */ |
| 32 | |
| 33 | /*enhanced brightness*/ |
| 34 | 0x40,0x40,0x40, /* dark grey */ |
| 35 | 0x00,0x00,0xFF, /* light blue */ |
| 36 | 0xFF,0x00,0x00, /* light red */ |
| 37 | 0xFF,0x00,0xFF, /* light magenta */ |
| 38 | 0x00,0xFF,0x00, /* light green */ |
| 39 | 0x00,0xFF,0xFF, /* light cyan */ |
| 40 | 0xFF,0xFF,0x00, /* yellow */ |
| 41 | 0xFF,0xFF,0xFF /* white */ |
| 42 | }; |
| 43 | |
| 44 | static const floppy_config nimbus_floppy_config = |
| 45 | { |
| 46 | DEVCB_NULL, |
| 47 | DEVCB_NULL, |
| 48 | DEVCB_NULL, |
| 49 | DEVCB_NULL, |
| 50 | DEVCB_NULL, |
| 51 | FLOPPY_DRIVE_DS_80, |
| 52 | FLOPPY_OPTIONS_NAME(pc), |
| 53 | DO_NOT_KEEP_GEOMETRY |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | static ADDRESS_MAP_START(nimbus_mem, ADDRESS_SPACE_PROGRAM, 16) |
| 58 | AM_RANGE( 0x00000, 0xEFFFF ) AM_RAM |
| 59 | AM_RANGE( 0xF0000, 0xFFFFF ) AM_ROM |
| 60 | ADDRESS_MAP_END |
| 61 | |
| 62 | static ADDRESS_MAP_START(nimbus_io, ADDRESS_SPACE_IO, 16) |
| 63 | AM_RANGE( 0x0000, 0x002f) AM_READWRITE( nimbus_video_io_r, nimbus_video_io_w) |
| 64 | AM_RANGE( 0x0030, 0x00ef) AM_READWRITE( nimbus_io_r, nimbus_io_w) |
| 65 | AM_RANGE( 0X00f0, 0X00f7) AM_DEVREADWRITE8( Z80SIO_TAG, sio_r, sio_w, 0x00FF) |
| 66 | AM_RANGE( 0x0400, 0x041f) AM_READWRITE8( nimbus_fdc_r, nimbus_fdc_w, 0x00FF) |
| 67 | AM_RANGE( 0xff00, 0xffff) AM_READWRITE( i186_internal_port_r, i186_internal_port_w)/* CPU 80186 */ |
| 68 | ADDRESS_MAP_END |
| 69 | |
| 70 | static INPUT_PORTS_START( nimbus ) |
| 71 | PORT_START("KEY0") /* Key row 0 scancodes 00..07 */ |
| 72 | //PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 73 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) |
| 74 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(0x1B) |
| 75 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 76 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 77 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 78 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 79 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 80 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 81 | |
| 82 | PORT_START("KEY1") /* Key row 1 scancodes 08..0F */ |
| 83 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_1) PORT_CHAR('7') |
| 84 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_ESC) PORT_CHAR('8') |
| 85 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_1) PORT_CHAR('9') |
| 86 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_2) PORT_CHAR('0') |
| 87 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') |
| 88 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') |
| 89 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BSPACE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(0x08) |
| 90 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR(0x09) |
| 91 | |
| 92 | PORT_START("KEY2") /* Key row 2 scancodes 10..17 */ |
| 93 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 94 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 95 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 96 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 97 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 98 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 99 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 100 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 101 | |
| 102 | PORT_START("KEY3") /* Key row 3 scancodes 18..1F */ |
| 103 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 104 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 105 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') |
| 106 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') |
| 107 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(0x0D) |
| 108 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) // Ether control |
| 109 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 110 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 111 | |
| 112 | PORT_START("KEY4") /* Key row 4 scancodes 20..27 */ |
| 113 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 114 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 115 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 116 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 117 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| 118 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 119 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 120 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(";") PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') |
| 121 | |
| 122 | PORT_START("KEY5") /* Key row 5 scancodes 28..2F */ |
| 123 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("#") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('#') |
| 124 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\\") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') |
| 125 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LSHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 126 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TILDE") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') |
| 127 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 128 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 129 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 130 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 131 | |
| 132 | |
| 133 | PORT_START("KEY6") /* Key row 6 scancodes 30..37 */ |
| 134 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 135 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 136 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 137 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 138 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') |
| 139 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 140 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RSHIFT") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_2) |
| 141 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PRSCR") PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR('*') |
| 142 | |
| 143 | PORT_START("KEY7") /* Key row 7 scancodes 38..3F */ |
| 144 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ALT") PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT) |
| 145 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 146 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CAPS") PORT_CODE(KEYCODE_CAPSLOCK) |
| 147 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) |
| 148 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) |
| 149 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) |
| 150 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) |
| 151 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) |
| 152 | |
| 153 | |
| 154 | PORT_START("KEY8") /* Key row 8 scancodes 40..47 */ |
| 155 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) |
| 156 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) |
| 157 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) |
| 158 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) |
| 159 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) |
| 160 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMLK") PORT_CODE(KEYCODE_NUMLOCK) |
| 161 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SCRLK") PORT_CODE(KEYCODE_SCRLOCK) |
| 162 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR('7') |
| 163 | |
| 164 | PORT_START("KEY9") /* Key row 9 scancodes 48..4F */ |
| 165 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP8") PORT_CODE(KEYCODE_8_PAD) //PORT_CHAR('8') |
| 166 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP9") PORT_CODE(KEYCODE_9_PAD) //PORT_CHAR('9') |
| 167 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP-") PORT_CODE(KEYCODE_MINUS_PAD) //PORT_CHAR('-') |
| 168 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP4") PORT_CODE(KEYCODE_4_PAD) //PORT_CHAR('4') |
| 169 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP5") PORT_CODE(KEYCODE_5_PAD) //PORT_CHAR('5') |
| 170 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) //PORT_CHAR('6') |
| 171 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) //PORT_CHAR('+') |
| 172 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) //PORT_CHAR('1') |
| 173 | |
| 174 | PORT_START("KEY10") /* Key row 10 scancodes 50..57 */ |
| 175 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP2") PORT_CODE(KEYCODE_2_PAD) //PORT_CHAR('2') |
| 176 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP3") PORT_CODE(KEYCODE_3_PAD) //PORT_CHAR('3') |
| 177 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP0") PORT_CODE(KEYCODE_0_PAD) //PORT_CHAR('0') |
| 178 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP.") PORT_CODE(KEYCODE_DEL_PAD) //PORT_CHAR('.') |
| 179 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED) |
| 180 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED) |
| 181 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) |
| 182 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 183 | //PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR('5') |
| 184 | //PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR('6') |
| 185 | //PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+') |
| 186 | //PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR('1') |
| 187 | INPUT_PORTS_END |
| 188 | |
| 189 | static ADDRESS_MAP_START(nimbus_iocpu_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 190 | ADDRESS_MAP_UNMAP_HIGH |
| 191 | AM_RANGE(0x0000, 0x1fff) AM_ROM |
| 192 | AM_RANGE(0x2000, 0x7fff) AM_RAM |
| 193 | //AM_RANGE(0x8000, 0x9fff) AM_ROM // EPROM |
| 194 | //AM_RANGE(0xc000, 0xdfff) // Expansion block |
| 195 | //AM_RANGE(0xe000, 0xffff) // Expansion block |
| 196 | ADDRESS_MAP_END |
| 197 | |
| 198 | static ADDRESS_MAP_START( nimbus_iocpu_io , ADDRESS_SPACE_IO, 8) |
| 199 | ADDRESS_MAP_UNMAP_HIGH |
| 200 | AM_RANGE(0x0000, 0x7fff) AM_RAM |
| 201 | //AM_RANGE(0x8000, 0x9fff) AM_ROM // EPROM |
| 202 | //AM_RANGE(0xa000, 0xa003) AM_DEVREADWRITE("ppi8255", i8255a_r, i8255a_w) // PPI-8255 |
| 203 | //AM_RANGE(0xc000, 0xdfff) // Expansion block |
| 204 | //AM_RANGE(0xe000, 0xffff) // Expansion block |
| 205 | ADDRESS_MAP_END |
| 206 | |
| 207 | |
| 208 | static PALETTE_INIT( nimbus ) |
| 209 | { |
| 210 | int i; |
| 211 | |
| 212 | for ( i = 0; i < sizeof(nimbus_palette) / 3; i++ ) { |
| 213 | palette_set_color_rgb(machine, i, nimbus_palette[i*3], nimbus_palette[i*3+1], nimbus_palette[i*3+2]); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | |
| 218 | static MACHINE_DRIVER_START( nimbus ) |
| 219 | /* basic machine hardware */ |
| 220 | MDRV_CPU_ADD(MAINCPU_TAG, I80186, 10000000) |
| 221 | MDRV_CPU_PROGRAM_MAP(nimbus_mem) |
| 222 | MDRV_CPU_IO_MAP(nimbus_io) |
| 223 | |
| 224 | MDRV_CPU_ADD(IOCPU_TAG, I8031, 8000000) |
| 225 | MDRV_CPU_PROGRAM_MAP(nimbus_iocpu_mem) |
| 226 | MDRV_CPU_IO_MAP(nimbus_iocpu_io) |
| 227 | |
| 228 | MDRV_MACHINE_START( nimbus ) |
| 229 | |
| 230 | MDRV_MACHINE_RESET(nimbus) |
| 231 | |
| 232 | /* video hardware */ |
| 233 | MDRV_SCREEN_ADD("screen", RASTER) |
| 234 | MDRV_SCREEN_REFRESH_RATE(50) |
| 235 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100)) |
| 236 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) |
| 237 | |
| 238 | MDRV_PALETTE_LENGTH(ARRAY_LENGTH(nimbus_palette) / 3) |
| 239 | MDRV_PALETTE_INIT( nimbus ) |
| 240 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 241 | |
| 242 | MDRV_SCREEN_SIZE(650, 260) |
| 243 | MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 249) |
| 244 | |
| 245 | MDRV_VIDEO_START(nimbus) |
| 246 | MDRV_VIDEO_UPDATE(nimbus) |
| 247 | MDRV_VIDEO_EOF(nimbus) |
| 248 | MDRV_VIDEO_RESET(nimbus) |
| 249 | |
| 250 | |
| 251 | MDRV_WD2793_ADD(FDC_TAG, nimbus_wd17xx_interface ) |
| 252 | MDRV_FLOPPY_4_DRIVES_ADD(nimbus_floppy_config) |
| 253 | |
| 254 | MDRV_RAM_ADD("messram") |
| 255 | MDRV_RAM_DEFAULT_SIZE("512K") |
| 256 | MDRV_RAM_EXTRA_OPTIONS("1024K,1536K") |
| 257 | |
| 258 | /* Peripheral chips */ |
| 259 | MDRV_Z80SIO_ADD(Z80SIO_TAG, 4000000, sio_intf) |
| 260 | MACHINE_DRIVER_END |
| 261 | |
| 262 | |
| 263 | ROM_START( nimbus ) |
| 264 | ROM_REGION( 0x100000, MAINCPU_TAG, 0 ) |
| 265 | |
| 266 | // ROM_LOAD16_BYTE("sys1-1.31a-16128-1986-06-18.rom", 0x0001, 0x8000, CRC(6416eb05) SHA1(1b640163a7efbc24381c7b24976a8609c066959b)) |
| 267 | // ROM_RELOAD(0xf0001,0x8000) |
| 268 | // ROM_LOAD16_BYTE("sys2-1.31a-16129-1986-06-18.rom", 0x0000, 0x8000, CRC(b224359d) SHA1(456bbe37afcd4429cca76ba2d6bd534dfda3fc9c)) |
| 269 | // ROM_RELOAD(0xf0000,0x8000) |
| 270 | |
| 271 | ROM_LOAD16_BYTE("sys-1-1.32f-22779-1989-10-20.rom", 0x0001, 0x8000, CRC(786c31e8) SHA1(da7f828f7f96087518bea1a3d89fee59b283b4ba)) |
| 272 | ROM_RELOAD(0xf0001,0x8000) |
| 273 | ROM_LOAD16_BYTE("sys-2-1.32f-22779-1989-10-20.rom", 0x0000, 0x8000, CRC(0be3db64) SHA1(af806405ec6fbc20385705f90d5059a47de17b08)) |
| 274 | ROM_RELOAD(0xf0000,0x8000) |
| 275 | |
| 276 | ROM_REGION( 0x4000, IOCPU_TAG, 0 ) |
| 277 | ROM_LOAD("hexec-v1.02u-13488-1985-10-29.rom", 0x0000, 0x1000, CRC(75c6adfd) SHA1(0f11e0b7386c6368d20e1fc7a6196d670f924825)) |
| 278 | ROM_END |
| 279 | |
| 280 | |
| 281 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 282 | COMP( 1986, nimbus, 0, 0, nimbus, nimbus, 0, "Research Machines", "nimbus", GAME_NO_SOUND | GAME_NOT_WORKING) |