src/mess/video/jagobj.c
| r5284 | r5285 | |
| 1 | | /***************************************************************************
|
| 2 | | |
| 3 | | Atari Jaguar object processor
|
| 4 | | |
| 5 | | ****************************************************************************/
|
| 6 | | |
| 7 | | #ifndef INCLUDE_OBJECT_PROCESSOR
|
| 8 | | #error jagobj.c is not directly compilable!
|
| 9 | | #endif
|
| 10 | | |
| 11 | | |
| 12 | | #define LOG_OBJECTS 0
|
| 13 | | |
| 14 | | |
| 15 | | static UINT16 *scanline;
|
| 16 | | static UINT16 *clutbase;
|
| 17 | | static UINT8 *blend_y, *blend_cc;
|
| 18 | | |
| 19 | | |
| 20 | | |
| 21 | | /*************************************
|
| 22 | | *
|
| 23 | | * Object processor init
|
| 24 | | *
|
| 25 | | *************************************/
|
| 26 | | |
| 27 | | void jagobj_init(running_machine *machine)
|
| 28 | | {
|
| 29 | | int i;
|
| 30 | | |
| 31 | | /* allocate memory for tables */
|
| 32 | | blend_y = auto_alloc_array(machine, UINT8, 256 * 256);
|
| 33 | | blend_cc = auto_alloc_array(machine, UINT8, 256 * 256);
|
| 34 | | |
| 35 | | /* fill tables */
|
| 36 | | for (i = 0; i < 256 * 256; i++)
|
| 37 | | {
|
| 38 | | int y = (i >> 8) & 0xff;
|
| 39 | | int dy = (INT8)i;
|
| 40 | | int c1 = (i >> 8) & 0x0f;
|
| 41 | | int dc1 = (INT8)(i << 4) >> 4;
|
| 42 | | int c2 = (i >> 12) & 0x0f;
|
| 43 | | int dc2 = (INT8)(i & 0xf0) >> 4;
|
| 44 | | |
| 45 | | y += dy;
|
| 46 | | if (y < 0) y = 0;
|
| 47 | | else if (y > 0xff) y = 0xff;
|
| 48 | | blend_y[i] = y;
|
| 49 | | |
| 50 | | c1 += dc1;
|
| 51 | | if (c1 < 0) c1 = 0;
|
| 52 | | else if (c1 > 0x0f) c1 = 0x0f;
|
| 53 | | c2 += dc2;
|
| 54 | | if (c2 < 0) c2 = 0;
|
| 55 | | else if (c2 > 0x0f) c2 = 0x0f;
|
| 56 | | blend_cc[i] = (c2 << 4) | c1;
|
| 57 | | }
|
| 58 | | }
|
| 59 | | |
| 60 | | |
| 61 | | |
| 62 | | /*************************************
|
| 63 | | *
|
| 64 | | * Blending function
|
| 65 | | *
|
| 66 | | *************************************/
|
| 67 | | |
| 68 | | #define BLEND(dst, src) \
|
| 69 | | (dst) = (blend_cc[((dst) & 0xff00) | (((src) >> 8) & 0xff)] << 8) | blend_y[(((dst) & 0xff) << 8) | ((src) & 0xff)];
|
| 70 | | |
| 71 | | |
| 72 | | |
| 73 | | /*************************************
|
| 74 | | *
|
| 75 | | * 4bpp bitmap renderers
|
| 76 | | *
|
| 77 | | *************************************/
|
| 78 | | |
| 79 | | INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
|
| 80 | | {
|
| 81 | | if (firstpix & 7)
|
| 82 | | {
|
| 83 | | UINT32 pixsrc = src[firstpix / 8];
|
| 84 | | while (firstpix & 7)
|
| 85 | | {
|
| 86 | | int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f;
|
| 87 | | if ((!(flags & 4) || pix) && (UINT32)xpos < 360)
|
| 88 | | {
|
| 89 | | if (!(flags & 2))
|
| 90 | | scanline[xpos] = clutbase[BYTE_XOR_BE(pix)];
|
| 91 | | else
|
| 92 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix)]);
|
| 93 | | }
|
| 94 | | xpos += dxpos;
|
| 95 | | firstpix++;
|
| 96 | | }
|
| 97 | | }
|
| 98 | | |
| 99 | | firstpix /= 8;
|
| 100 | | iwidth /= 8;
|
| 101 | | iwidth -= firstpix;
|
| 102 | | |
| 103 | | while (iwidth-- > 0)
|
| 104 | | {
|
| 105 | | UINT32 pix = src[firstpix++];
|
| 106 | | if (!(flags & 4) || pix)
|
| 107 | | {
|
| 108 | | if ((!(flags & 4) || (pix & 0xf0000000)) && (UINT32)xpos < 360)
|
| 109 | | {
|
| 110 | | if (!(flags & 2))
|
| 111 | | scanline[xpos] = clutbase[BYTE_XOR_BE(pix >> 28)];
|
| 112 | | else
|
| 113 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix >> 28)]);
|
| 114 | | }
|
| 115 | | xpos += dxpos;
|
| 116 | | |
| 117 | | if ((!(flags & 4) || (pix & 0x0f000000)) && (UINT32)xpos < 360)
|
| 118 | | {
|
| 119 | | if (!(flags & 2))
|
| 120 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 24) & 0x0f)];
|
| 121 | | else
|
| 122 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 24) & 0x0f)]);
|
| 123 | | }
|
| 124 | | xpos += dxpos;
|
| 125 | | |
| 126 | | if ((!(flags & 4) || (pix & 0x00f00000)) && (UINT32)xpos < 360)
|
| 127 | | {
|
| 128 | | if (!(flags & 2))
|
| 129 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 20) & 0x0f)];
|
| 130 | | else
|
| 131 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 20) & 0x0f)]);
|
| 132 | | }
|
| 133 | | xpos += dxpos;
|
| 134 | | |
| 135 | | if ((!(flags & 4) || (pix & 0x000f0000)) && (UINT32)xpos < 360)
|
| 136 | | {
|
| 137 | | if (!(flags & 2))
|
| 138 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 16) & 0x0f)];
|
| 139 | | else
|
| 140 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 16) & 0x0f)]);
|
| 141 | | }
|
| 142 | | xpos += dxpos;
|
| 143 | | |
| 144 | | if ((!(flags & 4) || (pix & 0x0000f000)) && (UINT32)xpos < 360)
|
| 145 | | {
|
| 146 | | if (!(flags & 2))
|
| 147 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 12) & 0x0f)];
|
| 148 | | else
|
| 149 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 12) & 0x0f)]);
|
| 150 | | }
|
| 151 | | xpos += dxpos;
|
| 152 | | |
| 153 | | if ((!(flags & 4) || (pix & 0x00000f00)) && (UINT32)xpos < 360)
|
| 154 | | {
|
| 155 | | if (!(flags & 2))
|
| 156 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 8) & 0x0f)];
|
| 157 | | else
|
| 158 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 8) & 0x0f)]);
|
| 159 | | }
|
| 160 | | xpos += dxpos;
|
| 161 | | |
| 162 | | if ((!(flags & 4) || (pix & 0x000000f0)) && (UINT32)xpos < 360)
|
| 163 | | {
|
| 164 | | if (!(flags & 2))
|
| 165 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 4) & 0x0f)];
|
| 166 | | else
|
| 167 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 4) & 0x0f)]);
|
| 168 | | }
|
| 169 | | xpos += dxpos;
|
| 170 | | |
| 171 | | if ((!(flags & 4) || (pix & 0x0000000f)) && (UINT32)xpos < 360)
|
| 172 | | {
|
| 173 | | if (!(flags & 2))
|
| 174 | | scanline[xpos] = clutbase[BYTE_XOR_BE(pix & 0x0f)];
|
| 175 | | else
|
| 176 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix & 0x0f)]);
|
| 177 | | }
|
| 178 | | xpos += dxpos;
|
| 179 | | }
|
| 180 | | else
|
| 181 | | xpos += 8 * dxpos;
|
| 182 | | }
|
| 183 | | }
|
| 184 | | |
| 185 | | static void bitmap_4_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 186 | | {
|
| 187 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 0, 1);
|
| 188 | | }
|
| 189 | | |
| 190 | | static void bitmap_4_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 191 | | {
|
| 192 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 1, -1);
|
| 193 | | }
|
| 194 | | |
| 195 | | static void bitmap_4_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 196 | | {
|
| 197 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 2, 1);
|
| 198 | | }
|
| 199 | | |
| 200 | | static void bitmap_4_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 201 | | {
|
| 202 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 3, -1);
|
| 203 | | }
|
| 204 | | |
| 205 | | static void bitmap_4_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 206 | | {
|
| 207 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 4, 1);
|
| 208 | | }
|
| 209 | | |
| 210 | | static void bitmap_4_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 211 | | {
|
| 212 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 5, -1);
|
| 213 | | }
|
| 214 | | |
| 215 | | static void bitmap_4_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 216 | | {
|
| 217 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 6, 1);
|
| 218 | | }
|
| 219 | | |
| 220 | | static void bitmap_4_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 221 | | {
|
| 222 | | bitmap_4_draw(firstpix, iwidth, src, xpos, 7, -1);
|
| 223 | | }
|
| 224 | | |
| 225 | | static void (*const bitmap4[8])(INT32, INT32, UINT32 *, INT32) =
|
| 226 | | {
|
| 227 | | bitmap_4_0,
|
| 228 | | bitmap_4_1,
|
| 229 | | bitmap_4_2,
|
| 230 | | bitmap_4_3,
|
| 231 | | bitmap_4_4,
|
| 232 | | bitmap_4_5,
|
| 233 | | bitmap_4_6,
|
| 234 | | bitmap_4_7
|
| 235 | | };
|
| 236 | | |
| 237 | | |
| 238 | | |
| 239 | | /*************************************
|
| 240 | | *
|
| 241 | | * 8bpp bitmap renderers
|
| 242 | | *
|
| 243 | | *************************************/
|
| 244 | | |
| 245 | | INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
|
| 246 | | {
|
| 247 | | if (firstpix & 3)
|
| 248 | | {
|
| 249 | | UINT32 pixsrc = src[firstpix / 4];
|
| 250 | | while (firstpix & 3)
|
| 251 | | {
|
| 252 | | UINT8 pix = pixsrc >> (8 * (~firstpix & 3));
|
| 253 | | if ((!(flags & 4) || pix) && (UINT32)xpos < 360)
|
| 254 | | {
|
| 255 | | if (!(flags & 2))
|
| 256 | | scanline[xpos] = clutbase[BYTE_XOR_BE(pix)];
|
| 257 | | else
|
| 258 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix)]);
|
| 259 | | }
|
| 260 | | xpos += dxpos;
|
| 261 | | firstpix++;
|
| 262 | | }
|
| 263 | | }
|
| 264 | | |
| 265 | | firstpix /= 4;
|
| 266 | | iwidth /= 4;
|
| 267 | | iwidth -= firstpix;
|
| 268 | | |
| 269 | | while (iwidth-- > 0)
|
| 270 | | {
|
| 271 | | UINT32 pix = src[firstpix++];
|
| 272 | | if (!(flags & 4) || pix)
|
| 273 | | {
|
| 274 | | if ((!(flags & 4) || (pix & 0xff000000)) && (UINT32)xpos < 360)
|
| 275 | | {
|
| 276 | | if (!(flags & 2))
|
| 277 | | scanline[xpos] = clutbase[BYTE_XOR_BE(pix >> 24)];
|
| 278 | | else
|
| 279 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix >> 24)]);
|
| 280 | | }
|
| 281 | | xpos += dxpos;
|
| 282 | | |
| 283 | | if ((!(flags & 4) || (pix & 0x00ff0000)) && (UINT32)xpos < 360)
|
| 284 | | {
|
| 285 | | if (!(flags & 2))
|
| 286 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 16) & 0xff)];
|
| 287 | | else
|
| 288 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 16) & 0xff)]);
|
| 289 | | }
|
| 290 | | xpos += dxpos;
|
| 291 | | |
| 292 | | if ((!(flags & 4) || (pix & 0x0000ff00)) && (UINT32)xpos < 360)
|
| 293 | | {
|
| 294 | | if (!(flags & 2))
|
| 295 | | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 8) & 0xff)];
|
| 296 | | else
|
| 297 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 8) & 0xff)]);
|
| 298 | | }
|
| 299 | | xpos += dxpos;
|
| 300 | | |
| 301 | | if ((!(flags & 4) || (pix & 0x000000ff)) && (UINT32)xpos < 360)
|
| 302 | | {
|
| 303 | | if (!(flags & 2))
|
| 304 | | scanline[xpos] = clutbase[BYTE_XOR_BE(pix & 0xff)];
|
| 305 | | else
|
| 306 | | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix & 0xff)]);
|
| 307 | | }
|
| 308 | | xpos += dxpos;
|
| 309 | | }
|
| 310 | | else
|
| 311 | | xpos += 4 * dxpos;
|
| 312 | | }
|
| 313 | | }
|
| 314 | | |
| 315 | | static void bitmap_8_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 316 | | {
|
| 317 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 0, 1);
|
| 318 | | }
|
| 319 | | |
| 320 | | static void bitmap_8_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 321 | | {
|
| 322 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 1, -1);
|
| 323 | | }
|
| 324 | | |
| 325 | | static void bitmap_8_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 326 | | {
|
| 327 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 2, 1);
|
| 328 | | }
|
| 329 | | |
| 330 | | static void bitmap_8_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 331 | | {
|
| 332 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 3, -1);
|
| 333 | | }
|
| 334 | | |
| 335 | | static void bitmap_8_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 336 | | {
|
| 337 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 4, 1);
|
| 338 | | }
|
| 339 | | |
| 340 | | static void bitmap_8_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 341 | | {
|
| 342 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 5, -1);
|
| 343 | | }
|
| 344 | | |
| 345 | | static void bitmap_8_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 346 | | {
|
| 347 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 6, 1);
|
| 348 | | }
|
| 349 | | |
| 350 | | static void bitmap_8_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 351 | | {
|
| 352 | | bitmap_8_draw(firstpix, iwidth, src, xpos, 7, -1);
|
| 353 | | }
|
| 354 | | |
| 355 | | static void (*const bitmap8[8])(INT32, INT32, UINT32 *, INT32) =
|
| 356 | | {
|
| 357 | | bitmap_8_0,
|
| 358 | | bitmap_8_1,
|
| 359 | | bitmap_8_2,
|
| 360 | | bitmap_8_3,
|
| 361 | | bitmap_8_4,
|
| 362 | | bitmap_8_5,
|
| 363 | | bitmap_8_6,
|
| 364 | | bitmap_8_7
|
| 365 | | };
|
| 366 | | |
| 367 | | |
| 368 | | |
| 369 | | /*************************************
|
| 370 | | *
|
| 371 | | * 16bpp bitmap renderers
|
| 372 | | *
|
| 373 | | *************************************/
|
| 374 | | |
| 375 | | INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
|
| 376 | | {
|
| 377 | | if (firstpix & 1)
|
| 378 | | {
|
| 379 | | UINT16 pix = src[firstpix / 2];
|
| 380 | | if ((!(flags & 4) || pix) && (UINT32)xpos < 360)
|
| 381 | | {
|
| 382 | | if (!(flags & 2))
|
| 383 | | scanline[xpos] = pix;
|
| 384 | | else
|
| 385 | | BLEND(scanline[xpos], pix);
|
| 386 | | }
|
| 387 | | xpos += dxpos;
|
| 388 | | }
|
| 389 | | |
| 390 | | firstpix /= 2;
|
| 391 | | iwidth /= 2;
|
| 392 | | iwidth -= firstpix;
|
| 393 | | |
| 394 | | while (iwidth-- > 0)
|
| 395 | | {
|
| 396 | | UINT32 pix = src[firstpix++];
|
| 397 | | if (!(flags & 4) || pix)
|
| 398 | | {
|
| 399 | | if ((!(flags & 4) || (pix >> 16)) && (UINT32)xpos < 360)
|
| 400 | | {
|
| 401 | | if (!(flags & 2))
|
| 402 | | scanline[xpos] = pix >> 16;
|
| 403 | | else
|
| 404 | | BLEND(scanline[xpos], pix >> 16);
|
| 405 | | }
|
| 406 | | xpos += dxpos;
|
| 407 | | |
| 408 | | if ((!(flags & 4) || (pix & 0xffff)) && (UINT32)xpos < 360)
|
| 409 | | {
|
| 410 | | if (!(flags & 2))
|
| 411 | | scanline[xpos] = pix;
|
| 412 | | else
|
| 413 | | BLEND(scanline[xpos], pix);
|
| 414 | | }
|
| 415 | | xpos += dxpos;
|
| 416 | | }
|
| 417 | | else
|
| 418 | | xpos += 2 * dxpos;
|
| 419 | | }
|
| 420 | | }
|
| 421 | | |
| 422 | | static void bitmap_16_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 423 | | {
|
| 424 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 0, 1);
|
| 425 | | }
|
| 426 | | |
| 427 | | static void bitmap_16_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 428 | | {
|
| 429 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 1, -1);
|
| 430 | | }
|
| 431 | | |
| 432 | | static void bitmap_16_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 433 | | {
|
| 434 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 2, 1);
|
| 435 | | }
|
| 436 | | |
| 437 | | static void bitmap_16_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 438 | | {
|
| 439 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 3, -1);
|
| 440 | | }
|
| 441 | | |
| 442 | | static void bitmap_16_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 443 | | {
|
| 444 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 4, 1);
|
| 445 | | }
|
| 446 | | |
| 447 | | static void bitmap_16_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 448 | | {
|
| 449 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 5, -1);
|
| 450 | | }
|
| 451 | | |
| 452 | | static void bitmap_16_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 453 | | {
|
| 454 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 6, 1);
|
| 455 | | }
|
| 456 | | |
| 457 | | static void bitmap_16_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
|
| 458 | | {
|
| 459 | | bitmap_16_draw(firstpix, iwidth, src, xpos, 7, -1);
|
| 460 | | }
|
| 461 | | |
| 462 | | static void (*const bitmap16[8])(INT32, INT32, UINT32 *, INT32) =
|
| 463 | | {
|
| 464 | | bitmap_16_0,
|
| 465 | | bitmap_16_1,
|
| 466 | | bitmap_16_2,
|
| 467 | | bitmap_16_3,
|
| 468 | | bitmap_16_4,
|
| 469 | | bitmap_16_5,
|
| 470 | | bitmap_16_6,
|
| 471 | | bitmap_16_7
|
| 472 | | };
|
| 473 | | |
| 474 | | |
| 475 | | |
| 476 | | INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
|
| 477 | | {
|
| 478 | | int ppl = 32 / depth;
|
| 479 | | UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)];
|
| 480 | | UINT8 pix = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
|
| 481 | | return pix;
|
| 482 | | }
|
| 483 | | |
| 484 | | |
| 485 | | |
| 486 | | /*************************************
|
| 487 | | *
|
| 488 | | * Standard bitmap processor
|
| 489 | | *
|
| 490 | | *************************************/
|
| 491 | | |
| 492 | | static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc, int logit)
|
| 493 | | {
|
| 494 | | /* extract minimal data */
|
| 495 | | UINT32 upper = objdata[0];
|
| 496 | | UINT32 lower = objdata[1];
|
| 497 | | UINT32 ypos = (lower >> 3) & 0x7ff;
|
| 498 | | UINT32 height = (lower >> 14) & 0x3ff;
|
| 499 | | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
|
| 500 | | UINT32 data = (upper >> 11);
|
| 501 | | UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3);
|
| 502 | | |
| 503 | | if (logit)
|
| 504 | | {
|
| 505 | | /* second phrase */
|
| 506 | | UINT32 upper2 = objdata[2];
|
| 507 | | UINT32 lower2 = objdata[3];
|
| 508 | | |
| 509 | | /* extract data */
|
| 510 | | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 511 | | UINT8 depth = 1 << ((lower2 >> 12) & 7);
|
| 512 | | UINT8 pitch = (lower2 >> 15) & 7;
|
| 513 | | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 514 | | INT32 iwidth = (lower2 >> 28) | ((upper2 & 0x3f) << 4);
|
| 515 | | UINT8 _index = (upper2 >> 6) & 0x3f;
|
| 516 | | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 517 | | UINT8 firstpix = (upper2 >> 17) & 0x3f;
|
| 518 | | |
| 519 | | logerror(" ypos=%X height=%X link=%06X data=%06X\n", ypos, height, link << 3, data << 3);
|
| 520 | | logerror(" xpos=%X depth=%X pitch=%X dwidth=%X iwidth=%X index=%X flags=%X firstpix=%X\n", xpos, depth, pitch, dwidth, iwidth, _index, flags, firstpix);
|
| 521 | | }
|
| 522 | | |
| 523 | | /* only render if valid */
|
| 524 | | if (vc >= ypos && height > 0 && src)
|
| 525 | | {
|
| 526 | | /* second phrase */
|
| 527 | | UINT32 upper2 = objdata[2];
|
| 528 | | UINT32 lower2 = objdata[3];
|
| 529 | | |
| 530 | | /* extract data */
|
| 531 | | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 532 | | UINT8 depthlog = (lower2 >> 12) & 7;
|
| 533 | | UINT8 pitch = (lower2 >> 15) & 7;
|
| 534 | | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 535 | | UINT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
|
| 536 | | UINT8 _index = (upper2 >> 5) & 0xfe;
|
| 537 | | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 538 | | UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
|
| 539 | | int i, dxpos = (flags & 1) ? -1 : 1;
|
| 540 | | |
| 541 | | /* preadjust for firstpix */
|
| 542 | | xpos += firstpix * dxpos;
|
| 543 | | |
| 544 | | /* switch off the depth */
|
| 545 | | switch (depthlog)
|
| 546 | | {
|
| 547 | | /* 1bpp case */
|
| 548 | | case 0:
|
| 549 | | {
|
| 550 | | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 551 | | clut += _index & 0xfe;
|
| 552 | | |
| 553 | | /* non-blending */
|
| 554 | | if (!(flags & 2))
|
| 555 | | {
|
| 556 | | for (i = firstpix; i < iwidth; i++)
|
| 557 | | {
|
| 558 | | UINT8 pix = lookup_pixel(src, i, pitch, 1);
|
| 559 | | |
| 560 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 561 | | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 562 | | xpos += dxpos;
|
| 563 | | }
|
| 564 | | }
|
| 565 | | |
| 566 | | /* blending */
|
| 567 | | else
|
| 568 | | {
|
| 569 | | for (i = firstpix; i < iwidth; i++)
|
| 570 | | {
|
| 571 | | UINT8 pix = lookup_pixel(src, i, pitch, 1);
|
| 572 | | |
| 573 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 574 | | BLEND(scanline[xpos], clut[BYTE_XOR_BE(pix)]);
|
| 575 | | xpos += dxpos;
|
| 576 | | }
|
| 577 | | }
|
| 578 | | break;
|
| 579 | | }
|
| 580 | | |
| 581 | | /* 2bpp case */
|
| 582 | | case 1:
|
| 583 | | {
|
| 584 | | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 585 | | clut += _index & 0xfc;
|
| 586 | | |
| 587 | | /* non-blending */
|
| 588 | | if (!(flags & 2))
|
| 589 | | {
|
| 590 | | for (i = firstpix; i < iwidth; i++)
|
| 591 | | {
|
| 592 | | UINT8 pix = lookup_pixel(src, i, pitch, 2);
|
| 593 | | |
| 594 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 595 | | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 596 | | xpos += dxpos;
|
| 597 | | }
|
| 598 | | }
|
| 599 | | |
| 600 | | /* blending */
|
| 601 | | else
|
| 602 | | {
|
| 603 | | for (i = firstpix; i < iwidth; i++)
|
| 604 | | {
|
| 605 | | UINT8 pix = lookup_pixel(src, i, pitch, 2);
|
| 606 | | |
| 607 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 608 | | BLEND(scanline[xpos], clut[BYTE_XOR_BE(pix)]);
|
| 609 | | xpos += dxpos;
|
| 610 | | }
|
| 611 | | }
|
| 612 | | break;
|
| 613 | | }
|
| 614 | | |
| 615 | | /* 4bpp case */
|
| 616 | | case 2:
|
| 617 | | /* only handle pitch=1 for now */
|
| 618 | | if (pitch != 1)
|
| 619 | | logerror("Unhandled pitch = %d\n", pitch);
|
| 620 | | |
| 621 | | clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf0);
|
| 622 | | (*bitmap4[flags & 7])(firstpix, iwidth, src, xpos);
|
| 623 | | break;
|
| 624 | | |
| 625 | | /* 8bpp case */
|
| 626 | | case 3:
|
| 627 | | /* only handle pitch=1 for now */
|
| 628 | | if (pitch != 1)
|
| 629 | | logerror("Unhandled pitch = %d\n", pitch);
|
| 630 | | |
| 631 | | clutbase = (UINT16 *)jaguar_gpu_clut;
|
| 632 | | (*bitmap8[flags & 7])(firstpix, iwidth, src, xpos);
|
| 633 | | break;
|
| 634 | | |
| 635 | | /* 16bpp case */
|
| 636 | | case 4:
|
| 637 | | /* only handle pitch=1 for now */
|
| 638 | | if (pitch != 1)
|
| 639 | | logerror("Unhandled pitch = %d\n", pitch);
|
| 640 | | |
| 641 | | (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos);
|
| 642 | | break;
|
| 643 | | |
| 644 | | default:
|
| 645 | | fprintf(stderr, "Standard bitmap: Unhandled bitmap source depth = %d\n", depthlog);
|
| 646 | | break;
|
| 647 | | }
|
| 648 | | |
| 649 | | /* decrement the height and add to the source data offset */
|
| 650 | | objdata[0] = upper + (dwidth << 11);
|
| 651 | | objdata[1] = lower - (1 << 14);
|
| 652 | | }
|
| 653 | | |
| 654 | | return (UINT32 *)get_jaguar_memory(machine, link << 3);
|
| 655 | | }
|
| 656 | | |
| 657 | | |
| 658 | | |
| 659 | | /*************************************
|
| 660 | | *
|
| 661 | | * Scaled bitmap object processor
|
| 662 | | *
|
| 663 | | *************************************/
|
| 664 | | |
| 665 | | static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata, int vc, int logit)
|
| 666 | | {
|
| 667 | | /* extract data */
|
| 668 | | UINT32 upper = objdata[0];
|
| 669 | | UINT32 lower = objdata[1];
|
| 670 | | UINT32 ypos = (lower >> 3) & 0x7ff;
|
| 671 | | UINT32 height = (lower >> 14) & 0x3ff;
|
| 672 | | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
|
| 673 | | UINT32 data = (upper >> 11);
|
| 674 | | UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3);
|
| 675 | | |
| 676 | | /* third phrase */
|
| 677 | | UINT32 lower3 = objdata[5];
|
| 678 | | INT32 remainder = (lower3 >> 16) & 0xff;
|
| 679 | | |
| 680 | | if (logit)
|
| 681 | | {
|
| 682 | | /* second phrase */
|
| 683 | | UINT32 upper2 = objdata[2];
|
| 684 | | UINT32 lower2 = objdata[3];
|
| 685 | | |
| 686 | | /* extract data */
|
| 687 | | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 688 | | UINT8 depth = 1 << ((lower2 >> 12) & 7);
|
| 689 | | UINT8 pitch = (lower2 >> 15) & 7;
|
| 690 | | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 691 | | INT32 iwidth = (lower2 >> 28) | ((upper2 & 0x3f) << 4);
|
| 692 | | UINT8 _index = (upper2 >> 6) & 0x3f;
|
| 693 | | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 694 | | UINT8 firstpix = (upper2 >> 17) & 0x3f;
|
| 695 | | |
| 696 | | INT32 hscale = lower3 & 0xff;
|
| 697 | | INT32 vscale = (lower3 >> 8) & 0xff;
|
| 698 | | |
| 699 | | logerror(" ypos=%X height=%X link=%06X data=%06X\n", ypos, height, link << 3, data << 3);
|
| 700 | | logerror(" xpos=%X depth=%X pitch=%X dwidth=%X iwidth=%X index=%X flags=%X firstpix=%X\n", xpos, depth, pitch, dwidth, iwidth, _index, flags, firstpix);
|
| 701 | | logerror(" hscale=%X vscale=%X remainder=%X\n", hscale, vscale, remainder);
|
| 702 | | }
|
| 703 | | |
| 704 | | /* only render if valid */
|
| 705 | | if (vc >= ypos && (height > 0 || remainder > 0) && src)
|
| 706 | | {
|
| 707 | | /* second phrase */
|
| 708 | | UINT32 upper2 = objdata[2];
|
| 709 | | UINT32 lower2 = objdata[3];
|
| 710 | | |
| 711 | | /* extract data */
|
| 712 | | INT32 xpos = (INT32)(lower2 << 20) >> 20;
|
| 713 | | UINT8 depthlog = (lower2 >> 12) & 7;
|
| 714 | | UINT8 pitch = (lower2 >> 15) & 7;
|
| 715 | | UINT32 dwidth = (lower2 >> 18) & 0x3ff;
|
| 716 | | INT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
|
| 717 | | UINT8 _index = (upper2 >> 5) & 0xfe;
|
| 718 | | UINT8 flags = (upper2 >> 13) & 0x0f;
|
| 719 | | UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
|
| 720 | | |
| 721 | | INT32 hscale = lower3 & 0xff;
|
| 722 | | INT32 vscale = (lower3 >> 8) & 0xff;
|
| 723 | | INT32 xleft = hscale;
|
| 724 | | int dxpos = (flags & 1) ? -1 : 1;
|
| 725 | | int xpix = firstpix, yinc;
|
| 726 | | |
| 727 | | /* only handle pitch=0 for now */
|
| 728 | | if (pitch != 1)
|
| 729 | | logerror("Unhandled pitch = %d\n", pitch);
|
| 730 | | if (flags & 2)
|
| 731 | | {
|
| 732 | | mame_printf_debug("Unhandled blend mode in scaled bitmap case\n");
|
| 733 | | logerror("Unhandled blend mode in scaled bitmap case\n");
|
| 734 | | }
|
| 735 | | |
| 736 | | /* preadjust for firstpix */
|
| 737 | | xpos += firstpix * dxpos;
|
| 738 | | |
| 739 | | /* ignore hscale = 0 */
|
| 740 | | if (hscale != 0)
|
| 741 | | {
|
| 742 | | /* switch off the depth */
|
| 743 | | switch (depthlog)
|
| 744 | | {
|
| 745 | | case 2:
|
| 746 | | {
|
| 747 | | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 748 | | clut += _index & 0xf0;
|
| 749 | | |
| 750 | | /* render in phrases */
|
| 751 | | while (xpix < iwidth)
|
| 752 | | {
|
| 753 | | UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f;
|
| 754 | | |
| 755 | | while (xleft > 0)
|
| 756 | | {
|
| 757 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 758 | | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 759 | | xpos += dxpos;
|
| 760 | | xleft -= 0x20;
|
| 761 | | }
|
| 762 | | while (xleft <= 0)
|
| 763 | | xleft += hscale, xpix++;
|
| 764 | | }
|
| 765 | | break;
|
| 766 | | }
|
| 767 | | |
| 768 | | case 3:
|
| 769 | | {
|
| 770 | | UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
|
| 771 | | |
| 772 | | /* render in phrases */
|
| 773 | | while (xpix < iwidth)
|
| 774 | | {
|
| 775 | | UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff;
|
| 776 | | |
| 777 | | while (xleft > 0)
|
| 778 | | {
|
| 779 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 780 | | scanline[xpos] = clut[BYTE_XOR_BE(pix)];
|
| 781 | | xpos += dxpos;
|
| 782 | | xleft -= 0x20;
|
| 783 | | }
|
| 784 | | while (xleft <= 0)
|
| 785 | | xleft += hscale, xpix++;
|
| 786 | | }
|
| 787 | | break;
|
| 788 | | }
|
| 789 | | |
| 790 | | case 4:
|
| 791 | | while (xpix < iwidth)
|
| 792 | | {
|
| 793 | | UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16);
|
| 794 | | |
| 795 | | while (xleft > 0)
|
| 796 | | {
|
| 797 | | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4)))
|
| 798 | | scanline[xpos] = pix;
|
| 799 | | xpos += dxpos;
|
| 800 | | xleft -= 0x20;
|
| 801 | | }
|
| 802 | | while (xleft <= 0)
|
| 803 | | xleft += hscale, xpix++;
|
| 804 | | }
|
| 805 | | break;
|
| 806 | | |
| 807 | | default:
|
| 808 | | fprintf(stderr, "Scaled Bitmap: Unhandled scaled bitmap source depth = %d\n", depthlog);
|
| 809 | | break;
|
| 810 | | }
|
| 811 | | }
|
| 812 | | |
| 813 | | /* handle Y scale */
|
| 814 | | remainder -= 0x20;
|
| 815 | | yinc = 0;
|
| 816 | | while (remainder <= 0 && vscale != 0)
|
| 817 | | remainder += vscale, yinc++;
|
| 818 | | if (yinc > height)
|
| 819 | | yinc = height, remainder = 0;
|
| 820 | | |
| 821 | | /* decrement the height and add to the source data offset */
|
| 822 | | objdata[0] = upper + yinc * (dwidth << 11);
|
| 823 | | objdata[1] = lower - yinc * (1 << 14);
|
| 824 | | objdata[5] = (lower3 & ~0xff0000) | ((remainder & 0xff) << 16);
|
| 825 | | }
|
| 826 | | |
| 827 | | return (UINT32 *)get_jaguar_memory(machine, link << 3);
|
| 828 | | }
|
| 829 | | |
| 830 | | |
| 831 | | |
| 832 | | /*************************************
|
| 833 | | *
|
| 834 | | * Branch object processor
|
| 835 | | *
|
| 836 | | *************************************/
|
| 837 | | |
| 838 | | static UINT32 *process_branch(running_machine *machine, UINT32 *objdata, int vc, int logit)
|
| 839 | | {
|
| 840 | | UINT32 upper = objdata[0];
|
| 841 | | UINT32 lower = objdata[1];
|
| 842 | | UINT32 ypos = (lower >> 3) & 0x7ff;
|
| 843 | | UINT32 cc = (lower >> 14) & 7;
|
| 844 | | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
|
| 845 | | int taken = 0;
|
| 846 | | |
| 847 | | #ifndef MESS
|
| 848 | | if ((ypos & 1) && ypos != 0x7ff)
|
| 849 | | fprintf(stderr, " branch cc=%d ypos=%X link=%06X - \n", cc, ypos, link << 3);
|
| 850 | | #endif
|
| 851 | | |
| 852 | | switch (cc)
|
| 853 | | {
|
| 854 | | /* 0: branch if ypos == vc or ypos == 0x7ff */
|
| 855 | | case 0:
|
| 856 | | if (logit) logerror(" branch if %X == vc or %X == 0x7ff to %06X\n", ypos, ypos, link << 3);
|
| 857 | | taken = (ypos == vc) || (ypos == 0x7ff);
|
| 858 | | break;
|
| 859 | | |
| 860 | | /* 1: branch if ypos > vc */
|
| 861 | | case 1:
|
| 862 | | if (logit) logerror(" branch if %X > vc to %06X\n", ypos, link << 3);
|
| 863 | | taken = (ypos > vc);
|
| 864 | | break;
|
| 865 | | |
| 866 | | /* 2: branch if ypos < vc */
|
| 867 | | case 2:
|
| 868 | | if (logit) logerror(" branch if %X < vc to %06X\n", ypos, link << 3);
|
| 869 | | taken = (ypos < vc);
|
| 870 | | break;
|
| 871 | | |
| 872 | | /* 3: branch if object processor flag is set */
|
| 873 | | case 3:
|
| 874 | | if (logit) logerror(" branch if object flag set to %06X\n", link << 3);
|
| 875 | | fprintf(stderr, "Unhandled branch!\n");
|
| 876 | | link = 0, taken = 1;
|
| 877 | | break;
|
| 878 | | |
| 879 | | /* 4: branch on second half of display line */
|
| 880 | | case 4:
|
| 881 | | if (logit) logerror(" branch if second half of line to %06X\n", link << 3);
|
| 882 | | taken = (vc & 1);
|
| 883 | | break;
|
| 884 | | |
| 885 | | default:
|
| 886 | | fprintf(stderr, "Invalid branch!\n");
|
| 887 | | link = 0, taken = 1;
|
| 888 | | break;
|
| 889 | | }
|
| 890 | | |
| 891 | | /* handle the branch */
|
| 892 | | return taken ? (UINT32 *)get_jaguar_memory(machine, link << 3) : (objdata + 2);
|
| 893 | | }
|
| 894 | | |
| 895 | | |
| 896 | | |
| 897 | | /*************************************
|
| 898 | | *
|
| 899 | | * Process object list
|
| 900 | | *
|
| 901 | | *************************************/
|
| 902 | | |
| 903 | | static void process_object_list(running_machine *machine, int vc, UINT16 *_scanline)
|
| 904 | | {
|
| 905 | | int done = 0, count = 0;
|
| 906 | | UINT32 *objdata;
|
| 907 | | int logit;
|
| 908 | | int x;
|
| 909 | | |
| 910 | | /* erase the scanline first */
|
| 911 | | scanline = _scanline;
|
| 912 | | for (x = 0; x < 360; x++)
|
| 913 | | scanline[x] = gpu_regs[BG];
|
| 914 | | |
| 915 | | logit = LOG_OBJECTS;
|
| 916 | | |
| 917 | | /* fetch the object pointer */
|
| 918 | | objdata = (UINT32 *)get_jaguar_memory(machine, (gpu_regs[OLP_H] << 16) | gpu_regs[OLP_L]);
|
| 919 | | while (!done && objdata && count++ < 100)
|
| 920 | | {
|
| 921 | | /* the low 3 bits determine the command */
|
| 922 | | switch (objdata[1] & 7)
|
| 923 | | {
|
| 924 | | /* bitmap object */
|
| 925 | | case 0:
|
| 926 | | if (logit)
|
| 927 | | logerror("bitmap = %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3]);
|
| 928 | | objdata = process_bitmap(machine, objdata, vc, logit);
|
| 929 | | break;
|
| 930 | | |
| 931 | | /* scaled bitmap object */
|
| 932 | | case 1:
|
| 933 | | if (logit)
|
| 934 | | logerror("scaled = %08X-%08X %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3], objdata[4], objdata[5]);
|
| 935 | | objdata = process_scaled_bitmap(machine, objdata, vc, logit);
|
| 936 | | break;
|
| 937 | | |
| 938 | | /* interrupt gpu - this is guesswork */
|
| 939 | | case 2:
|
| 940 | | {
|
| 941 | | done = 1;
|
| 942 | | |
| 943 | | if (logit)
|
| 944 | | logerror("int gpu = %08X-%08X\n", objdata[0], objdata[1]);
|
| 945 | | |
| 946 | | cpu_irq_state |= 4;
|
| 947 | | update_cpu_irq(machine);
|
| 948 | | break;
|
| 949 | | }
|
| 950 | | |
| 951 | | /* branch */
|
| 952 | | case 3:
|
| 953 | | if (logit)
|
| 954 | | logerror("branch = %08X-%08X\n", objdata[0], objdata[1]);
|
| 955 | | objdata = process_branch(machine, objdata, vc, logit);
|
| 956 | | break;
|
| 957 | | |
| 958 | | /* stop */
|
| 959 | | case 4:
|
| 960 | | {
|
| 961 | | int interrupt = (objdata[1] >> 3) & 1;
|
| 962 | | done = 1;
|
| 963 | | |
| 964 | | if (logit)
|
| 965 | | logerror("stop = %08X-%08X\n", objdata[0], objdata[1]);
|
| 966 | | if (interrupt)
|
| 967 | | {
|
| 968 | | #ifndef MESS
|
| 969 | | fprintf(stderr, "stop int=%d\n", interrupt);
|
| 970 | | #endif
|
| 971 | | cpu_irq_state |= 4;
|
| 972 | | update_cpu_irq(machine);
|
| 973 | | }
|
| 974 | | break;
|
| 975 | | }
|
| 976 | | |
| 977 | | default:
|
| 978 | | fprintf(stderr, "%08X %08X\n", objdata[0], objdata[1]);
|
| 979 | | done = 1;
|
| 980 | | break;
|
| 981 | | }
|
| 982 | | }
|
| 983 | | }
|
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Atari Jaguar object processor |
| 4 | |
| 5 | ****************************************************************************/ |
| 6 | |
| 7 | #ifndef INCLUDE_OBJECT_PROCESSOR |
| 8 | #error jagobj.c is not directly compilable! |
| 9 | #endif |
| 10 | |
| 11 | |
| 12 | #define LOG_OBJECTS 0 |
| 13 | |
| 14 | |
| 15 | static UINT16 *scanline; |
| 16 | static UINT16 *clutbase; |
| 17 | static UINT8 *blend_y, *blend_cc; |
| 18 | |
| 19 | |
| 20 | |
| 21 | /************************************* |
| 22 | * |
| 23 | * Object processor init |
| 24 | * |
| 25 | *************************************/ |
| 26 | |
| 27 | void jagobj_init(running_machine *machine) |
| 28 | { |
| 29 | int i; |
| 30 | |
| 31 | /* allocate memory for tables */ |
| 32 | blend_y = auto_alloc_array(machine, UINT8, 256 * 256); |
| 33 | blend_cc = auto_alloc_array(machine, UINT8, 256 * 256); |
| 34 | |
| 35 | /* fill tables */ |
| 36 | for (i = 0; i < 256 * 256; i++) |
| 37 | { |
| 38 | int y = (i >> 8) & 0xff; |
| 39 | int dy = (INT8)i; |
| 40 | int c1 = (i >> 8) & 0x0f; |
| 41 | int dc1 = (INT8)(i << 4) >> 4; |
| 42 | int c2 = (i >> 12) & 0x0f; |
| 43 | int dc2 = (INT8)(i & 0xf0) >> 4; |
| 44 | |
| 45 | y += dy; |
| 46 | if (y < 0) y = 0; |
| 47 | else if (y > 0xff) y = 0xff; |
| 48 | blend_y[i] = y; |
| 49 | |
| 50 | c1 += dc1; |
| 51 | if (c1 < 0) c1 = 0; |
| 52 | else if (c1 > 0x0f) c1 = 0x0f; |
| 53 | c2 += dc2; |
| 54 | if (c2 < 0) c2 = 0; |
| 55 | else if (c2 > 0x0f) c2 = 0x0f; |
| 56 | blend_cc[i] = (c2 << 4) | c1; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | |
| 61 | |
| 62 | /************************************* |
| 63 | * |
| 64 | * Blending function |
| 65 | * |
| 66 | *************************************/ |
| 67 | |
| 68 | #define BLEND(dst, src) \ |
| 69 | (dst) = (blend_cc[((dst) & 0xff00) | (((src) >> 8) & 0xff)] << 8) | blend_y[(((dst) & 0xff) << 8) | ((src) & 0xff)]; |
| 70 | |
| 71 | |
| 72 | |
| 73 | /************************************* |
| 74 | * |
| 75 | * 4bpp bitmap renderers |
| 76 | * |
| 77 | *************************************/ |
| 78 | |
| 79 | INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos) |
| 80 | { |
| 81 | if (firstpix & 7) |
| 82 | { |
| 83 | UINT32 pixsrc = src[firstpix / 8]; |
| 84 | while (firstpix & 7) |
| 85 | { |
| 86 | int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f; |
| 87 | if ((!(flags & 4) || pix) && (UINT32)xpos < 360) |
| 88 | { |
| 89 | if (!(flags & 2)) |
| 90 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix)]; |
| 91 | else |
| 92 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix)]); |
| 93 | } |
| 94 | xpos += dxpos; |
| 95 | firstpix++; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | firstpix /= 8; |
| 100 | iwidth /= 8; |
| 101 | iwidth -= firstpix; |
| 102 | |
| 103 | while (iwidth-- > 0) |
| 104 | { |
| 105 | UINT32 pix = src[firstpix++]; |
| 106 | if (!(flags & 4) || pix) |
| 107 | { |
| 108 | if ((!(flags & 4) || (pix & 0xf0000000)) && (UINT32)xpos < 360) |
| 109 | { |
| 110 | if (!(flags & 2)) |
| 111 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix >> 28)]; |
| 112 | else |
| 113 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix >> 28)]); |
| 114 | } |
| 115 | xpos += dxpos; |
| 116 | |
| 117 | if ((!(flags & 4) || (pix & 0x0f000000)) && (UINT32)xpos < 360) |
| 118 | { |
| 119 | if (!(flags & 2)) |
| 120 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 24) & 0x0f)]; |
| 121 | else |
| 122 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 24) & 0x0f)]); |
| 123 | } |
| 124 | xpos += dxpos; |
| 125 | |
| 126 | if ((!(flags & 4) || (pix & 0x00f00000)) && (UINT32)xpos < 360) |
| 127 | { |
| 128 | if (!(flags & 2)) |
| 129 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 20) & 0x0f)]; |
| 130 | else |
| 131 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 20) & 0x0f)]); |
| 132 | } |
| 133 | xpos += dxpos; |
| 134 | |
| 135 | if ((!(flags & 4) || (pix & 0x000f0000)) && (UINT32)xpos < 360) |
| 136 | { |
| 137 | if (!(flags & 2)) |
| 138 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 16) & 0x0f)]; |
| 139 | else |
| 140 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 16) & 0x0f)]); |
| 141 | } |
| 142 | xpos += dxpos; |
| 143 | |
| 144 | if ((!(flags & 4) || (pix & 0x0000f000)) && (UINT32)xpos < 360) |
| 145 | { |
| 146 | if (!(flags & 2)) |
| 147 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 12) & 0x0f)]; |
| 148 | else |
| 149 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 12) & 0x0f)]); |
| 150 | } |
| 151 | xpos += dxpos; |
| 152 | |
| 153 | if ((!(flags & 4) || (pix & 0x00000f00)) && (UINT32)xpos < 360) |
| 154 | { |
| 155 | if (!(flags & 2)) |
| 156 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 8) & 0x0f)]; |
| 157 | else |
| 158 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 8) & 0x0f)]); |
| 159 | } |
| 160 | xpos += dxpos; |
| 161 | |
| 162 | if ((!(flags & 4) || (pix & 0x000000f0)) && (UINT32)xpos < 360) |
| 163 | { |
| 164 | if (!(flags & 2)) |
| 165 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 4) & 0x0f)]; |
| 166 | else |
| 167 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 4) & 0x0f)]); |
| 168 | } |
| 169 | xpos += dxpos; |
| 170 | |
| 171 | if ((!(flags & 4) || (pix & 0x0000000f)) && (UINT32)xpos < 360) |
| 172 | { |
| 173 | if (!(flags & 2)) |
| 174 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix & 0x0f)]; |
| 175 | else |
| 176 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix & 0x0f)]); |
| 177 | } |
| 178 | xpos += dxpos; |
| 179 | } |
| 180 | else |
| 181 | xpos += 8 * dxpos; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | static void bitmap_4_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 186 | { |
| 187 | bitmap_4_draw(firstpix, iwidth, src, xpos, 0, 1); |
| 188 | } |
| 189 | |
| 190 | static void bitmap_4_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 191 | { |
| 192 | bitmap_4_draw(firstpix, iwidth, src, xpos, 1, -1); |
| 193 | } |
| 194 | |
| 195 | static void bitmap_4_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 196 | { |
| 197 | bitmap_4_draw(firstpix, iwidth, src, xpos, 2, 1); |
| 198 | } |
| 199 | |
| 200 | static void bitmap_4_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 201 | { |
| 202 | bitmap_4_draw(firstpix, iwidth, src, xpos, 3, -1); |
| 203 | } |
| 204 | |
| 205 | static void bitmap_4_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 206 | { |
| 207 | bitmap_4_draw(firstpix, iwidth, src, xpos, 4, 1); |
| 208 | } |
| 209 | |
| 210 | static void bitmap_4_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 211 | { |
| 212 | bitmap_4_draw(firstpix, iwidth, src, xpos, 5, -1); |
| 213 | } |
| 214 | |
| 215 | static void bitmap_4_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 216 | { |
| 217 | bitmap_4_draw(firstpix, iwidth, src, xpos, 6, 1); |
| 218 | } |
| 219 | |
| 220 | static void bitmap_4_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 221 | { |
| 222 | bitmap_4_draw(firstpix, iwidth, src, xpos, 7, -1); |
| 223 | } |
| 224 | |
| 225 | static void (*const bitmap4[8])(INT32, INT32, UINT32 *, INT32) = |
| 226 | { |
| 227 | bitmap_4_0, |
| 228 | bitmap_4_1, |
| 229 | bitmap_4_2, |
| 230 | bitmap_4_3, |
| 231 | bitmap_4_4, |
| 232 | bitmap_4_5, |
| 233 | bitmap_4_6, |
| 234 | bitmap_4_7 |
| 235 | }; |
| 236 | |
| 237 | |
| 238 | |
| 239 | /************************************* |
| 240 | * |
| 241 | * 8bpp bitmap renderers |
| 242 | * |
| 243 | *************************************/ |
| 244 | |
| 245 | INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos) |
| 246 | { |
| 247 | if (firstpix & 3) |
| 248 | { |
| 249 | UINT32 pixsrc = src[firstpix / 4]; |
| 250 | while (firstpix & 3) |
| 251 | { |
| 252 | UINT8 pix = pixsrc >> (8 * (~firstpix & 3)); |
| 253 | if ((!(flags & 4) || pix) && (UINT32)xpos < 360) |
| 254 | { |
| 255 | if (!(flags & 2)) |
| 256 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix)]; |
| 257 | else |
| 258 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix)]); |
| 259 | } |
| 260 | xpos += dxpos; |
| 261 | firstpix++; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | firstpix /= 4; |
| 266 | iwidth /= 4; |
| 267 | iwidth -= firstpix; |
| 268 | |
| 269 | while (iwidth-- > 0) |
| 270 | { |
| 271 | UINT32 pix = src[firstpix++]; |
| 272 | if (!(flags & 4) || pix) |
| 273 | { |
| 274 | if ((!(flags & 4) || (pix & 0xff000000)) && (UINT32)xpos < 360) |
| 275 | { |
| 276 | if (!(flags & 2)) |
| 277 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix >> 24)]; |
| 278 | else |
| 279 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix >> 24)]); |
| 280 | } |
| 281 | xpos += dxpos; |
| 282 | |
| 283 | if ((!(flags & 4) || (pix & 0x00ff0000)) && (UINT32)xpos < 360) |
| 284 | { |
| 285 | if (!(flags & 2)) |
| 286 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 16) & 0xff)]; |
| 287 | else |
| 288 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 16) & 0xff)]); |
| 289 | } |
| 290 | xpos += dxpos; |
| 291 | |
| 292 | if ((!(flags & 4) || (pix & 0x0000ff00)) && (UINT32)xpos < 360) |
| 293 | { |
| 294 | if (!(flags & 2)) |
| 295 | scanline[xpos] = clutbase[BYTE_XOR_BE((pix >> 8) & 0xff)]; |
| 296 | else |
| 297 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE((pix >> 8) & 0xff)]); |
| 298 | } |
| 299 | xpos += dxpos; |
| 300 | |
| 301 | if ((!(flags & 4) || (pix & 0x000000ff)) && (UINT32)xpos < 360) |
| 302 | { |
| 303 | if (!(flags & 2)) |
| 304 | scanline[xpos] = clutbase[BYTE_XOR_BE(pix & 0xff)]; |
| 305 | else |
| 306 | BLEND(scanline[xpos], clutbase[BYTE_XOR_BE(pix & 0xff)]); |
| 307 | } |
| 308 | xpos += dxpos; |
| 309 | } |
| 310 | else |
| 311 | xpos += 4 * dxpos; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | static void bitmap_8_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 316 | { |
| 317 | bitmap_8_draw(firstpix, iwidth, src, xpos, 0, 1); |
| 318 | } |
| 319 | |
| 320 | static void bitmap_8_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 321 | { |
| 322 | bitmap_8_draw(firstpix, iwidth, src, xpos, 1, -1); |
| 323 | } |
| 324 | |
| 325 | static void bitmap_8_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 326 | { |
| 327 | bitmap_8_draw(firstpix, iwidth, src, xpos, 2, 1); |
| 328 | } |
| 329 | |
| 330 | static void bitmap_8_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 331 | { |
| 332 | bitmap_8_draw(firstpix, iwidth, src, xpos, 3, -1); |
| 333 | } |
| 334 | |
| 335 | static void bitmap_8_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 336 | { |
| 337 | bitmap_8_draw(firstpix, iwidth, src, xpos, 4, 1); |
| 338 | } |
| 339 | |
| 340 | static void bitmap_8_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 341 | { |
| 342 | bitmap_8_draw(firstpix, iwidth, src, xpos, 5, -1); |
| 343 | } |
| 344 | |
| 345 | static void bitmap_8_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 346 | { |
| 347 | bitmap_8_draw(firstpix, iwidth, src, xpos, 6, 1); |
| 348 | } |
| 349 | |
| 350 | static void bitmap_8_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 351 | { |
| 352 | bitmap_8_draw(firstpix, iwidth, src, xpos, 7, -1); |
| 353 | } |
| 354 | |
| 355 | static void (*const bitmap8[8])(INT32, INT32, UINT32 *, INT32) = |
| 356 | { |
| 357 | bitmap_8_0, |
| 358 | bitmap_8_1, |
| 359 | bitmap_8_2, |
| 360 | bitmap_8_3, |
| 361 | bitmap_8_4, |
| 362 | bitmap_8_5, |
| 363 | bitmap_8_6, |
| 364 | bitmap_8_7 |
| 365 | }; |
| 366 | |
| 367 | |
| 368 | |
| 369 | /************************************* |
| 370 | * |
| 371 | * 16bpp bitmap renderers |
| 372 | * |
| 373 | *************************************/ |
| 374 | |
| 375 | INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos) |
| 376 | { |
| 377 | if (firstpix & 1) |
| 378 | { |
| 379 | UINT16 pix = src[firstpix / 2]; |
| 380 | if ((!(flags & 4) || pix) && (UINT32)xpos < 360) |
| 381 | { |
| 382 | if (!(flags & 2)) |
| 383 | scanline[xpos] = pix; |
| 384 | else |
| 385 | BLEND(scanline[xpos], pix); |
| 386 | } |
| 387 | xpos += dxpos; |
| 388 | } |
| 389 | |
| 390 | firstpix /= 2; |
| 391 | iwidth /= 2; |
| 392 | iwidth -= firstpix; |
| 393 | |
| 394 | while (iwidth-- > 0) |
| 395 | { |
| 396 | UINT32 pix = src[firstpix++]; |
| 397 | if (!(flags & 4) || pix) |
| 398 | { |
| 399 | if ((!(flags & 4) || (pix >> 16)) && (UINT32)xpos < 360) |
| 400 | { |
| 401 | if (!(flags & 2)) |
| 402 | scanline[xpos] = pix >> 16; |
| 403 | else |
| 404 | BLEND(scanline[xpos], pix >> 16); |
| 405 | } |
| 406 | xpos += dxpos; |
| 407 | |
| 408 | if ((!(flags & 4) || (pix & 0xffff)) && (UINT32)xpos < 360) |
| 409 | { |
| 410 | if (!(flags & 2)) |
| 411 | scanline[xpos] = pix; |
| 412 | else |
| 413 | BLEND(scanline[xpos], pix); |
| 414 | } |
| 415 | xpos += dxpos; |
| 416 | } |
| 417 | else |
| 418 | xpos += 2 * dxpos; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | static void bitmap_16_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 423 | { |
| 424 | bitmap_16_draw(firstpix, iwidth, src, xpos, 0, 1); |
| 425 | } |
| 426 | |
| 427 | static void bitmap_16_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 428 | { |
| 429 | bitmap_16_draw(firstpix, iwidth, src, xpos, 1, -1); |
| 430 | } |
| 431 | |
| 432 | static void bitmap_16_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 433 | { |
| 434 | bitmap_16_draw(firstpix, iwidth, src, xpos, 2, 1); |
| 435 | } |
| 436 | |
| 437 | static void bitmap_16_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 438 | { |
| 439 | bitmap_16_draw(firstpix, iwidth, src, xpos, 3, -1); |
| 440 | } |
| 441 | |
| 442 | static void bitmap_16_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 443 | { |
| 444 | bitmap_16_draw(firstpix, iwidth, src, xpos, 4, 1); |
| 445 | } |
| 446 | |
| 447 | static void bitmap_16_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 448 | { |
| 449 | bitmap_16_draw(firstpix, iwidth, src, xpos, 5, -1); |
| 450 | } |
| 451 | |
| 452 | static void bitmap_16_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 453 | { |
| 454 | bitmap_16_draw(firstpix, iwidth, src, xpos, 6, 1); |
| 455 | } |
| 456 | |
| 457 | static void bitmap_16_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 458 | { |
| 459 | bitmap_16_draw(firstpix, iwidth, src, xpos, 7, -1); |
| 460 | } |
| 461 | |
| 462 | static void (*const bitmap16[8])(INT32, INT32, UINT32 *, INT32) = |
| 463 | { |
| 464 | bitmap_16_0, |
| 465 | bitmap_16_1, |
| 466 | bitmap_16_2, |
| 467 | bitmap_16_3, |
| 468 | bitmap_16_4, |
| 469 | bitmap_16_5, |
| 470 | bitmap_16_6, |
| 471 | bitmap_16_7 |
| 472 | }; |
| 473 | |
| 474 | |
| 475 | |
| 476 | INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth) |
| 477 | { |
| 478 | int ppl = 32 / depth; |
| 479 | UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)]; |
| 480 | UINT8 pix = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1); |
| 481 | return pix; |
| 482 | } |
| 483 | |
| 484 | |
| 485 | |
| 486 | /************************************* |
| 487 | * |
| 488 | * Standard bitmap processor |
| 489 | * |
| 490 | *************************************/ |
| 491 | |
| 492 | static UINT32 *process_bitmap(running_machine *machine, UINT32 *objdata, int vc, int logit) |
| 493 | { |
| 494 | /* extract minimal data */ |
| 495 | UINT32 upper = objdata[0]; |
| 496 | UINT32 lower = objdata[1]; |
| 497 | UINT32 ypos = (lower >> 3) & 0x7ff; |
| 498 | UINT32 height = (lower >> 14) & 0x3ff; |
| 499 | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8); |
| 500 | UINT32 data = (upper >> 11); |
| 501 | UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3); |
| 502 | |
| 503 | if (logit) |
| 504 | { |
| 505 | /* second phrase */ |
| 506 | UINT32 upper2 = objdata[2]; |
| 507 | UINT32 lower2 = objdata[3]; |
| 508 | |
| 509 | /* extract data */ |
| 510 | INT32 xpos = (INT32)(lower2 << 20) >> 20; |
| 511 | UINT8 depth = 1 << ((lower2 >> 12) & 7); |
| 512 | UINT8 pitch = (lower2 >> 15) & 7; |
| 513 | UINT32 dwidth = (lower2 >> 18) & 0x3ff; |
| 514 | INT32 iwidth = (lower2 >> 28) | ((upper2 & 0x3f) << 4); |
| 515 | UINT8 _index = (upper2 >> 6) & 0x3f; |
| 516 | UINT8 flags = (upper2 >> 13) & 0x0f; |
| 517 | UINT8 firstpix = (upper2 >> 17) & 0x3f; |
| 518 | |
| 519 | logerror(" ypos=%X height=%X link=%06X data=%06X\n", ypos, height, link << 3, data << 3); |
| 520 | logerror(" xpos=%X depth=%X pitch=%X dwidth=%X iwidth=%X index=%X flags=%X firstpix=%X\n", xpos, depth, pitch, dwidth, iwidth, _index, flags, firstpix); |
| 521 | } |
| 522 | |
| 523 | /* only render if valid */ |
| 524 | if (vc >= ypos && height > 0 && src) |
| 525 | { |
| 526 | /* second phrase */ |
| 527 | UINT32 upper2 = objdata[2]; |
| 528 | UINT32 lower2 = objdata[3]; |
| 529 | |
| 530 | /* extract data */ |
| 531 | INT32 xpos = (INT32)(lower2 << 20) >> 20; |
| 532 | UINT8 depthlog = (lower2 >> 12) & 7; |
| 533 | UINT8 pitch = (lower2 >> 15) & 7; |
| 534 | UINT32 dwidth = (lower2 >> 18) & 0x3ff; |
| 535 | UINT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog); |
| 536 | UINT8 _index = (upper2 >> 5) & 0xfe; |
| 537 | UINT8 flags = (upper2 >> 13) & 0x0f; |
| 538 | UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog; |
| 539 | int i, dxpos = (flags & 1) ? -1 : 1; |
| 540 | |
| 541 | /* preadjust for firstpix */ |
| 542 | xpos += firstpix * dxpos; |
| 543 | |
| 544 | /* switch off the depth */ |
| 545 | switch (depthlog) |
| 546 | { |
| 547 | /* 1bpp case */ |
| 548 | case 0: |
| 549 | { |
| 550 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| 551 | clut += _index & 0xfe; |
| 552 | |
| 553 | /* non-blending */ |
| 554 | if (!(flags & 2)) |
| 555 | { |
| 556 | for (i = firstpix; i < iwidth; i++) |
| 557 | { |
| 558 | UINT8 pix = lookup_pixel(src, i, pitch, 1); |
| 559 | |
| 560 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 561 | scanline[xpos] = clut[BYTE_XOR_BE(pix)]; |
| 562 | xpos += dxpos; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | /* blending */ |
| 567 | else |
| 568 | { |
| 569 | for (i = firstpix; i < iwidth; i++) |
| 570 | { |
| 571 | UINT8 pix = lookup_pixel(src, i, pitch, 1); |
| 572 | |
| 573 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 574 | BLEND(scanline[xpos], clut[BYTE_XOR_BE(pix)]); |
| 575 | xpos += dxpos; |
| 576 | } |
| 577 | } |
| 578 | break; |
| 579 | } |
| 580 | |
| 581 | /* 2bpp case */ |
| 582 | case 1: |
| 583 | { |
| 584 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| 585 | clut += _index & 0xfc; |
| 586 | |
| 587 | /* non-blending */ |
| 588 | if (!(flags & 2)) |
| 589 | { |
| 590 | for (i = firstpix; i < iwidth; i++) |
| 591 | { |
| 592 | UINT8 pix = lookup_pixel(src, i, pitch, 2); |
| 593 | |
| 594 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 595 | scanline[xpos] = clut[BYTE_XOR_BE(pix)]; |
| 596 | xpos += dxpos; |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | /* blending */ |
| 601 | else |
| 602 | { |
| 603 | for (i = firstpix; i < iwidth; i++) |
| 604 | { |
| 605 | UINT8 pix = lookup_pixel(src, i, pitch, 2); |
| 606 | |
| 607 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 608 | BLEND(scanline[xpos], clut[BYTE_XOR_BE(pix)]); |
| 609 | xpos += dxpos; |
| 610 | } |
| 611 | } |
| 612 | break; |
| 613 | } |
| 614 | |
| 615 | /* 4bpp case */ |
| 616 | case 2: |
| 617 | /* only handle pitch=1 for now */ |
| 618 | if (pitch != 1) |
| 619 | logerror("Unhandled pitch = %d\n", pitch); |
| 620 | |
| 621 | clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf0); |
| 622 | (*bitmap4[flags & 7])(firstpix, iwidth, src, xpos); |
| 623 | break; |
| 624 | |
| 625 | /* 8bpp case */ |
| 626 | case 3: |
| 627 | /* only handle pitch=1 for now */ |
| 628 | if (pitch != 1) |
| 629 | logerror("Unhandled pitch = %d\n", pitch); |
| 630 | |
| 631 | clutbase = (UINT16 *)jaguar_gpu_clut; |
| 632 | (*bitmap8[flags & 7])(firstpix, iwidth, src, xpos); |
| 633 | break; |
| 634 | |
| 635 | /* 16bpp case */ |
| 636 | case 4: |
| 637 | /* only handle pitch=1 for now */ |
| 638 | if (pitch != 1) |
| 639 | logerror("Unhandled pitch = %d\n", pitch); |
| 640 | |
| 641 | (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos); |
| 642 | break; |
| 643 | |
| 644 | default: |
| 645 | fprintf(stderr, "Standard bitmap: Unhandled bitmap source depth = %d\n", depthlog); |
| 646 | break; |
| 647 | } |
| 648 | |
| 649 | /* decrement the height and add to the source data offset */ |
| 650 | objdata[0] = upper + (dwidth << 11); |
| 651 | objdata[1] = lower - (1 << 14); |
| 652 | } |
| 653 | |
| 654 | return (UINT32 *)get_jaguar_memory(machine, link << 3); |
| 655 | } |
| 656 | |
| 657 | |
| 658 | |
| 659 | /************************************* |
| 660 | * |
| 661 | * Scaled bitmap object processor |
| 662 | * |
| 663 | *************************************/ |
| 664 | |
| 665 | static UINT32 *process_scaled_bitmap(running_machine *machine, UINT32 *objdata, int vc, int logit) |
| 666 | { |
| 667 | /* extract data */ |
| 668 | UINT32 upper = objdata[0]; |
| 669 | UINT32 lower = objdata[1]; |
| 670 | UINT32 ypos = (lower >> 3) & 0x7ff; |
| 671 | UINT32 height = (lower >> 14) & 0x3ff; |
| 672 | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8); |
| 673 | UINT32 data = (upper >> 11); |
| 674 | UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3); |
| 675 | |
| 676 | /* third phrase */ |
| 677 | UINT32 lower3 = objdata[5]; |
| 678 | INT32 remainder = (lower3 >> 16) & 0xff; |
| 679 | |
| 680 | if (logit) |
| 681 | { |
| 682 | /* second phrase */ |
| 683 | UINT32 upper2 = objdata[2]; |
| 684 | UINT32 lower2 = objdata[3]; |
| 685 | |
| 686 | /* extract data */ |
| 687 | INT32 xpos = (INT32)(lower2 << 20) >> 20; |
| 688 | UINT8 depth = 1 << ((lower2 >> 12) & 7); |
| 689 | UINT8 pitch = (lower2 >> 15) & 7; |
| 690 | UINT32 dwidth = (lower2 >> 18) & 0x3ff; |
| 691 | INT32 iwidth = (lower2 >> 28) | ((upper2 & 0x3f) << 4); |
| 692 | UINT8 _index = (upper2 >> 6) & 0x3f; |
| 693 | UINT8 flags = (upper2 >> 13) & 0x0f; |
| 694 | UINT8 firstpix = (upper2 >> 17) & 0x3f; |
| 695 | |
| 696 | INT32 hscale = lower3 & 0xff; |
| 697 | INT32 vscale = (lower3 >> 8) & 0xff; |
| 698 | |
| 699 | logerror(" ypos=%X height=%X link=%06X data=%06X\n", ypos, height, link << 3, data << 3); |
| 700 | logerror(" xpos=%X depth=%X pitch=%X dwidth=%X iwidth=%X index=%X flags=%X firstpix=%X\n", xpos, depth, pitch, dwidth, iwidth, _index, flags, firstpix); |
| 701 | logerror(" hscale=%X vscale=%X remainder=%X\n", hscale, vscale, remainder); |
| 702 | } |
| 703 | |
| 704 | /* only render if valid */ |
| 705 | if (vc >= ypos && (height > 0 || remainder > 0) && src) |
| 706 | { |
| 707 | /* second phrase */ |
| 708 | UINT32 upper2 = objdata[2]; |
| 709 | UINT32 lower2 = objdata[3]; |
| 710 | |
| 711 | /* extract data */ |
| 712 | INT32 xpos = (INT32)(lower2 << 20) >> 20; |
| 713 | UINT8 depthlog = (lower2 >> 12) & 7; |
| 714 | UINT8 pitch = (lower2 >> 15) & 7; |
| 715 | UINT32 dwidth = (lower2 >> 18) & 0x3ff; |
| 716 | INT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog); |
| 717 | UINT8 _index = (upper2 >> 5) & 0xfe; |
| 718 | UINT8 flags = (upper2 >> 13) & 0x0f; |
| 719 | UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog; |
| 720 | |
| 721 | INT32 hscale = lower3 & 0xff; |
| 722 | INT32 vscale = (lower3 >> 8) & 0xff; |
| 723 | INT32 xleft = hscale; |
| 724 | int dxpos = (flags & 1) ? -1 : 1; |
| 725 | int xpix = firstpix, yinc; |
| 726 | |
| 727 | /* only handle pitch=0 for now */ |
| 728 | if (pitch != 1) |
| 729 | logerror("Unhandled pitch = %d\n", pitch); |
| 730 | if (flags & 2) |
| 731 | { |
| 732 | mame_printf_debug("Unhandled blend mode in scaled bitmap case\n"); |
| 733 | logerror("Unhandled blend mode in scaled bitmap case\n"); |
| 734 | } |
| 735 | |
| 736 | /* preadjust for firstpix */ |
| 737 | xpos += firstpix * dxpos; |
| 738 | |
| 739 | /* ignore hscale = 0 */ |
| 740 | if (hscale != 0) |
| 741 | { |
| 742 | /* switch off the depth */ |
| 743 | switch (depthlog) |
| 744 | { |
| 745 | case 2: |
| 746 | { |
| 747 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| 748 | clut += _index & 0xf0; |
| 749 | |
| 750 | /* render in phrases */ |
| 751 | while (xpix < iwidth) |
| 752 | { |
| 753 | UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f; |
| 754 | |
| 755 | while (xleft > 0) |
| 756 | { |
| 757 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 758 | scanline[xpos] = clut[BYTE_XOR_BE(pix)]; |
| 759 | xpos += dxpos; |
| 760 | xleft -= 0x20; |
| 761 | } |
| 762 | while (xleft <= 0) |
| 763 | xleft += hscale, xpix++; |
| 764 | } |
| 765 | break; |
| 766 | } |
| 767 | |
| 768 | case 3: |
| 769 | { |
| 770 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| 771 | |
| 772 | /* render in phrases */ |
| 773 | while (xpix < iwidth) |
| 774 | { |
| 775 | UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff; |
| 776 | |
| 777 | while (xleft > 0) |
| 778 | { |
| 779 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 780 | scanline[xpos] = clut[BYTE_XOR_BE(pix)]; |
| 781 | xpos += dxpos; |
| 782 | xleft -= 0x20; |
| 783 | } |
| 784 | while (xleft <= 0) |
| 785 | xleft += hscale, xpix++; |
| 786 | } |
| 787 | break; |
| 788 | } |
| 789 | |
| 790 | case 4: |
| 791 | while (xpix < iwidth) |
| 792 | { |
| 793 | UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16); |
| 794 | |
| 795 | while (xleft > 0) |
| 796 | { |
| 797 | if (xpos >= 0 && xpos < 360 && (pix || !(flags & 4))) |
| 798 | scanline[xpos] = pix; |
| 799 | xpos += dxpos; |
| 800 | xleft -= 0x20; |
| 801 | } |
| 802 | while (xleft <= 0) |
| 803 | xleft += hscale, xpix++; |
| 804 | } |
| 805 | break; |
| 806 | |
| 807 | default: |
| 808 | fprintf(stderr, "Scaled Bitmap: Unhandled scaled bitmap source depth = %d\n", depthlog); |
| 809 | break; |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | /* handle Y scale */ |
| 814 | remainder -= 0x20; |
| 815 | yinc = 0; |
| 816 | while (remainder <= 0 && vscale != 0) |
| 817 | remainder += vscale, yinc++; |
| 818 | if (yinc > height) |
| 819 | yinc = height, remainder = 0; |
| 820 | |
| 821 | /* decrement the height and add to the source data offset */ |
| 822 | objdata[0] = upper + yinc * (dwidth << 11); |
| 823 | objdata[1] = lower - yinc * (1 << 14); |
| 824 | objdata[5] = (lower3 & ~0xff0000) | ((remainder & 0xff) << 16); |
| 825 | } |
| 826 | |
| 827 | return (UINT32 *)get_jaguar_memory(machine, link << 3); |
| 828 | } |
| 829 | |
| 830 | |
| 831 | |
| 832 | /************************************* |
| 833 | * |
| 834 | * Branch object processor |
| 835 | * |
| 836 | *************************************/ |
| 837 | |
| 838 | static UINT32 *process_branch(running_machine *machine, UINT32 *objdata, int vc, int logit) |
| 839 | { |
| 840 | UINT32 upper = objdata[0]; |
| 841 | UINT32 lower = objdata[1]; |
| 842 | UINT32 ypos = (lower >> 3) & 0x7ff; |
| 843 | UINT32 cc = (lower >> 14) & 7; |
| 844 | UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8); |
| 845 | int taken = 0; |
| 846 | |
| 847 | #ifndef MESS |
| 848 | if ((ypos & 1) && ypos != 0x7ff) |
| 849 | fprintf(stderr, " branch cc=%d ypos=%X link=%06X - \n", cc, ypos, link << 3); |
| 850 | #endif |
| 851 | |
| 852 | switch (cc) |
| 853 | { |
| 854 | /* 0: branch if ypos == vc or ypos == 0x7ff */ |
| 855 | case 0: |
| 856 | if (logit) logerror(" branch if %X == vc or %X == 0x7ff to %06X\n", ypos, ypos, link << 3); |
| 857 | taken = (ypos == vc) || (ypos == 0x7ff); |
| 858 | break; |
| 859 | |
| 860 | /* 1: branch if ypos > vc */ |
| 861 | case 1: |
| 862 | if (logit) logerror(" branch if %X > vc to %06X\n", ypos, link << 3); |
| 863 | taken = (ypos > vc); |
| 864 | break; |
| 865 | |
| 866 | /* 2: branch if ypos < vc */ |
| 867 | case 2: |
| 868 | if (logit) logerror(" branch if %X < vc to %06X\n", ypos, link << 3); |
| 869 | taken = (ypos < vc); |
| 870 | break; |
| 871 | |
| 872 | /* 3: branch if object processor flag is set */ |
| 873 | case 3: |
| 874 | if (logit) logerror(" branch if object flag set to %06X\n", link << 3); |
| 875 | fprintf(stderr, "Unhandled branch!\n"); |
| 876 | link = 0, taken = 1; |
| 877 | break; |
| 878 | |
| 879 | /* 4: branch on second half of display line */ |
| 880 | case 4: |
| 881 | if (logit) logerror(" branch if second half of line to %06X\n", link << 3); |
| 882 | taken = (vc & 1); |
| 883 | break; |
| 884 | |
| 885 | default: |
| 886 | fprintf(stderr, "Invalid branch!\n"); |
| 887 | link = 0, taken = 1; |
| 888 | break; |
| 889 | } |
| 890 | |
| 891 | /* handle the branch */ |
| 892 | return taken ? (UINT32 *)get_jaguar_memory(machine, link << 3) : (objdata + 2); |
| 893 | } |
| 894 | |
| 895 | |
| 896 | |
| 897 | /************************************* |
| 898 | * |
| 899 | * Process object list |
| 900 | * |
| 901 | *************************************/ |
| 902 | |
| 903 | static void process_object_list(running_machine *machine, int vc, UINT16 *_scanline) |
| 904 | { |
| 905 | int done = 0, count = 0; |
| 906 | UINT32 *objdata; |
| 907 | int logit; |
| 908 | int x; |
| 909 | |
| 910 | /* erase the scanline first */ |
| 911 | scanline = _scanline; |
| 912 | for (x = 0; x < 360; x++) |
| 913 | scanline[x] = gpu_regs[BG]; |
| 914 | |
| 915 | logit = LOG_OBJECTS; |
| 916 | |
| 917 | /* fetch the object pointer */ |
| 918 | objdata = (UINT32 *)get_jaguar_memory(machine, (gpu_regs[OLP_H] << 16) | gpu_regs[OLP_L]); |
| 919 | while (!done && objdata && count++ < 100) |
| 920 | { |
| 921 | /* the low 3 bits determine the command */ |
| 922 | switch (objdata[1] & 7) |
| 923 | { |
| 924 | /* bitmap object */ |
| 925 | case 0: |
| 926 | if (logit) |
| 927 | logerror("bitmap = %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3]); |
| 928 | objdata = process_bitmap(machine, objdata, vc, logit); |
| 929 | break; |
| 930 | |
| 931 | /* scaled bitmap object */ |
| 932 | case 1: |
| 933 | if (logit) |
| 934 | logerror("scaled = %08X-%08X %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3], objdata[4], objdata[5]); |
| 935 | objdata = process_scaled_bitmap(machine, objdata, vc, logit); |
| 936 | break; |
| 937 | |
| 938 | /* interrupt gpu - this is guesswork */ |
| 939 | case 2: |
| 940 | { |
| 941 | done = 1; |
| 942 | |
| 943 | if (logit) |
| 944 | logerror("int gpu = %08X-%08X\n", objdata[0], objdata[1]); |
| 945 | |
| 946 | cpu_irq_state |= 4; |
| 947 | update_cpu_irq(machine); |
| 948 | break; |
| 949 | } |
| 950 | |
| 951 | /* branch */ |
| 952 | case 3: |
| 953 | if (logit) |
| 954 | logerror("branch = %08X-%08X\n", objdata[0], objdata[1]); |
| 955 | objdata = process_branch(machine, objdata, vc, logit); |
| 956 | break; |
| 957 | |
| 958 | /* stop */ |
| 959 | case 4: |
| 960 | { |
| 961 | int interrupt = (objdata[1] >> 3) & 1; |
| 962 | done = 1; |
| 963 | |
| 964 | if (logit) |
| 965 | logerror("stop = %08X-%08X\n", objdata[0], objdata[1]); |
| 966 | if (interrupt) |
| 967 | { |
| 968 | #ifndef MESS |
| 969 | fprintf(stderr, "stop int=%d\n", interrupt); |
| 970 | #endif |
| 971 | cpu_irq_state |= 4; |
| 972 | update_cpu_irq(machine); |
| 973 | } |
| 974 | break; |
| 975 | } |
| 976 | |
| 977 | default: |
| 978 | fprintf(stderr, "%08X %08X\n", objdata[0], objdata[1]); |
| 979 | done = 1; |
| 980 | break; |
| 981 | } |
| 982 | } |
| 983 | } |
src/mess/machine/e05a03.c
| r5284 | r5285 | |
| 1 | | /***************************************************************************
|
| 2 | | |
| 3 | | E05A03 Gate Array (used in the Epson LX-800)
|
| 4 | | |
| 5 | | ***************************************************************************/
|
| 6 | | |
| 7 | | #include "driver.h"
|
| 8 | | #include "e05a03.h"
|
| 9 | | |
| 10 | | |
| 11 | | /***************************************************************************
|
| 12 | | TYPE DEFINITIONS
|
| 13 | | ***************************************************************************/
|
| 14 | | |
| 15 | | typedef struct _e05a03_state e05a03_state;
|
| 16 | | struct _e05a03_state
|
| 17 | | {
|
| 18 | | /* 24-bit shift register, port 0x00, 0x01 and 0x02 */
|
| 19 | | UINT32 shift;
|
| 20 | | |
| 21 | | /* port 0x03 */
|
| 22 | | int busy_leading;
|
| 23 | | int busy_software;
|
| 24 | | int nlqlp;
|
| 25 | | int cndlp;
|
| 26 | | |
| 27 | | #if 0
|
| 28 | | int pe;
|
| 29 | | int pelp;
|
| 30 | | #endif
|
| 31 | | |
| 32 | | /* port 0x04 and 0x05 (9-bit) */
|
| 33 | | UINT16 printhead;
|
| 34 | | |
| 35 | | /* port 0x06 (4-bit) */
|
| 36 | | UINT8 pf_motor;
|
| 37 | | |
| 38 | | /* port 0x07 (4-bit) */
|
| 39 | | UINT8 cr_motor;
|
| 40 | | |
| 41 | | /* callbacks */
|
| 42 | | devcb_resolved_write_line out_nlq_lp_func; /* pin 2, nlq lamp output */
|
| 43 | | devcb_resolved_write_line out_pe_lp_func; /* pin 3, paper empty lamp output */
|
| 44 | | devcb_resolved_write_line out_reso_func; /* pin 25, reset output */
|
| 45 | | devcb_resolved_write_line out_pe_func; /* pin 35, centronics pe output */
|
| 46 | | devcb_resolved_read8 in_data_func; /* pin 47-54, centronics data input */
|
| 47 | | };
|
| 48 | | |
| 49 | | |
| 50 | | /*****************************************************************************
|
| 51 | | INLINE FUNCTIONS
|
| 52 | | *****************************************************************************/
|
| 53 | | |
| 54 | | INLINE e05a03_state *get_safe_token(const device_config *device)
|
| 55 | | {
|
| 56 | | assert(device != NULL);
|
| 57 | | assert(device->token != NULL);
|
| 58 | | assert(device->type == E05A03);
|
| 59 | | |
| 60 | | return (e05a03_state *)device->token;
|
| 61 | | }
|
| 62 | | |
| 63 | | |
| 64 | | /*****************************************************************************
|
| 65 | | DEVICE INTERFACE
|
| 66 | | *****************************************************************************/
|
| 67 | | |
| 68 | | static DEVICE_START( e05a03 )
|
| 69 | | {
|
| 70 | | e05a03_state *e05a03 = get_safe_token(device);
|
| 71 | | const e05a03_interface *intf = device->static_config;
|
| 72 | | |
| 73 | | /* validate some basic stuff */
|
| 74 | | assert(device->static_config != NULL);
|
| 75 | | |
| 76 | | /* resolve callbacks */
|
| 77 | | devcb_resolve_write_line(&e05a03->out_nlq_lp_func, &intf->out_nlq_lp_func, device);
|
| 78 | | devcb_resolve_write_line(&e05a03->out_pe_lp_func, &intf->out_pe_lp_func, device);
|
| 79 | | devcb_resolve_write_line(&e05a03->out_reso_func, &intf->out_reso_func, device);
|
| 80 | | devcb_resolve_write_line(&e05a03->out_pe_func, &intf->out_pe_func, device);
|
| 81 | | devcb_resolve_read8(&e05a03->in_data_func, &intf->in_data_func, device);
|
| 82 | | |
| 83 | | /* register for state saving */
|
| 84 | | state_save_register_device_item(device, 0, e05a03->shift);
|
| 85 | | state_save_register_device_item(device, 0, e05a03->busy_leading);
|
| 86 | | state_save_register_device_item(device, 0, e05a03->busy_software);
|
| 87 | | state_save_register_device_item(device, 0, e05a03->nlqlp);
|
| 88 | | state_save_register_device_item(device, 0, e05a03->cndlp);
|
| 89 | | #if 0
|
| 90 | | state_save_register_device_item(device, 0, e05a03->pe);
|
| 91 | | state_save_register_device_item(device, 0, e05a03->pelp);
|
| 92 | | #endif
|
| 93 | | state_save_register_device_item(device, 0, e05a03->printhead);
|
| 94 | | state_save_register_device_item(device, 0, e05a03->pf_motor);
|
| 95 | | state_save_register_device_item(device, 0, e05a03->cr_motor);
|
| 96 | | }
|
| 97 | | |
| 98 | | static DEVICE_RESET( e05a03 )
|
| 99 | | {
|
| 100 | | e05a03_state *e05a03 = get_safe_token(device);
|
| 101 | | |
| 102 | | e05a03->printhead = 0x00;
|
| 103 | | e05a03->pf_motor = 0x00;
|
| 104 | | e05a03->cr_motor = 0x0f;
|
| 105 | | |
| 106 | | devcb_call_write_line(&e05a03->out_pe_func, 0);
|
| 107 | | devcb_call_write_line(&e05a03->out_pe_lp_func, 1);
|
| 108 | | |
| 109 | | e05a03->busy_software = 1;
|
| 110 | | e05a03->nlqlp = 1;
|
| 111 | | e05a03->cndlp = 1;
|
| 112 | | }
|
| 113 | | |
| 114 | | DEVICE_GET_INFO( e05a03 )
|
| 115 | | {
|
| 116 | | switch (state)
|
| 117 | | {
|
| 118 | | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 119 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(e05a03_state); break;
|
| 120 | | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
|
| 121 | | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_OTHER; break;
|
| 122 | | |
| 123 | | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 124 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(e05a03); break;
|
| 125 | | case DEVINFO_FCT_STOP: /* Nothing */ break;
|
| 126 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(e05a03); break;
|
| 127 | | |
| 128 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 129 | | case DEVINFO_STR_NAME: strcpy(info->s, "E05A03"); break;
|
| 130 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Epson printer gate array"); break;
|
| 131 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
| 132 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
| 133 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break;
|
| 134 | | }
|
| 135 | | }
|
| 136 | | |
| 137 | | |
| 138 | | /***************************************************************************
|
| 139 | | IMPLEMENTATION
|
| 140 | | ***************************************************************************/
|
| 141 | | |
| 142 | | WRITE8_DEVICE_HANDLER( e05a03_w )
|
| 143 | | {
|
| 144 | | e05a03_state *e05a03 = get_safe_token(device);
|
| 145 | | |
| 146 | | logerror("%s: e05a03_w(%02x): %02x\n", cpuexec_describe_context(device->machine), offset, data);
|
| 147 | | |
| 148 | | switch (offset)
|
| 149 | | {
|
| 150 | | /* shift register */
|
| 151 | | case 0x00: e05a03->shift = (e05a03->shift & 0x00ffff) | (data << 16); break;
|
| 152 | | case 0x01: e05a03->shift = (e05a03->shift & 0xff00ff) | (data << 8); break;
|
| 153 | | case 0x02: e05a03->shift = (e05a03->shift & 0xffff00) | (data << 0); break;
|
| 154 | | |
| 155 | | case 0x03:
|
| 156 | | e05a03->busy_leading = BIT(data, 7);
|
| 157 | | e05a03->busy_software = BIT(data, 6);
|
| 158 | | e05a03->nlqlp = BIT(data, 4);
|
| 159 | | e05a03->cndlp = BIT(data, 3);
|
| 160 | | |
| 161 | | devcb_call_write_line(&e05a03->out_pe_func, BIT(data, 2));
|
| 162 | | devcb_call_write_line(&e05a03->out_pe_lp_func, !BIT(data, 2));
|
| 163 | | |
| 164 | | #if 0
|
| 165 | | e05a03->pe = BIT(data, 2);
|
| 166 | | e05a03->pelp = !BIT(data, 2);
|
| 167 | | #endif
|
| 168 | | |
| 169 | | break;
|
| 170 | | |
| 171 | | /* printhead */
|
| 172 | | case 0x04: e05a03->printhead = (e05a03->printhead & 0x100) | !data; break;
|
| 173 | | case 0x05: e05a03->printhead = (e05a03->printhead & 0x0ff) | (!(BIT(data, 7) << 8)); break;
|
| 174 | | |
| 175 | | /* paper feed and carriage motor phase data*/
|
| 176 | | case 0x06: e05a03->pf_motor = (data & 0xf0) >> 4; break;
|
| 177 | | case 0x07: e05a03->cr_motor = (data & 0x0f) >> 0; break;
|
| 178 | | }
|
| 179 | | }
|
| 180 | | |
| 181 | | READ8_DEVICE_HANDLER( e05a03_r )
|
| 182 | | {
|
| 183 | | e05a03_state *e05a03 = get_safe_token(device);
|
| 184 | | UINT8 result = 0;
|
| 185 | | |
| 186 | | logerror("%s: e05a03_r(%02x)\n", cpuexec_describe_context(device->machine), offset);
|
| 187 | | |
| 188 | | switch (offset)
|
| 189 | | {
|
| 190 | | case 0x00:
|
| 191 | | break;
|
| 192 | | |
| 193 | | case 0x01:
|
| 194 | | break;
|
| 195 | | |
| 196 | | case 0x02:
|
| 197 | | result = devcb_call_read8(&e05a03->in_data_func, 0);
|
| 198 | | break;
|
| 199 | | |
| 200 | | case 0x03:
|
| 201 | | result |= BIT(e05a03->shift, 23) << 7;
|
| 202 | | e05a03->shift <<= 1;
|
| 203 | | break;
|
| 204 | | }
|
| 205 | | |
| 206 | | return result;
|
| 207 | | }
|
| 208 | | |
| 209 | | /* home position signal */
|
| 210 | | WRITE_LINE_DEVICE_HANDLER( e05a03_home_w )
|
| 211 | | {
|
| 212 | | }
|
| 213 | | |
| 214 | | /* printhead solenoids trigger */
|
| 215 | | WRITE_LINE_DEVICE_HANDLER( e05a03_fire_w )
|
| 216 | | {
|
| 217 | | }
|
| 218 | | |
| 219 | | WRITE_LINE_DEVICE_HANDLER( e05a03_strobe_w )
|
| 220 | | {
|
| 221 | | }
|
| 222 | | |
| 223 | | READ_LINE_DEVICE_HANDLER( e05a03_busy_r )
|
| 224 | | {
|
| 225 | | return 1;
|
| 226 | | }
|
| 227 | | |
| 228 | | WRITE_LINE_DEVICE_HANDLER( e05a03_resi_w )
|
| 229 | | {
|
| 230 | | e05a03_state *e05a03 = get_safe_token(device);
|
| 231 | | |
| 232 | | if (!state)
|
| 233 | | {
|
| 234 | | device_reset_e05a03(device);
|
| 235 | | devcb_call_write_line(&e05a03->out_reso_func, 1);
|
| 236 | | }
|
| 237 | | }
|
| 238 | | |
| 239 | | WRITE_LINE_DEVICE_HANDLER( e05a03_init_w )
|
| 240 | | {
|
| 241 | | e05a03_resi_w(device, state);
|
| 242 | | }
|
| 1 | /*************************************************************************** |
| 2 | |
| 3 | E05A03 Gate Array (used in the Epson LX-800) |
| 4 | |
| 5 | ***************************************************************************/ |
| 6 | |
| 7 | #include "driver.h" |
| 8 | #include "e05a03.h" |
| 9 | |
| 10 | |
| 11 | /*************************************************************************** |
| 12 | TYPE DEFINITIONS |
| 13 | ***************************************************************************/ |
| 14 | |
| 15 | typedef struct _e05a03_state e05a03_state; |
| 16 | struct _e05a03_state |
| 17 | { |
| 18 | /* 24-bit shift register, port 0x00, 0x01 and 0x02 */ |
| 19 | UINT32 shift; |
| 20 | |
| 21 | /* port 0x03 */ |
| 22 | int busy_leading; |
| 23 | int busy_software; |
| 24 | int nlqlp; |
| 25 | int cndlp; |
| 26 | |
| 27 | #if 0 |
| 28 | int pe; |
| 29 | int pelp; |
| 30 | #endif |
| 31 | |
| 32 | /* port 0x04 and 0x05 (9-bit) */ |
| 33 | UINT16 printhead; |
| 34 | |
| 35 | /* port 0x06 (4-bit) */ |
| 36 | UINT8 pf_motor; |
| 37 | |
| 38 | /* port 0x07 (4-bit) */ |
| 39 | UINT8 cr_motor; |
| 40 | |
| 41 | /* callbacks */ |
| 42 | devcb_resolved_write_line out_nlq_lp_func; /* pin 2, nlq lamp output */ |
| 43 | devcb_resolved_write_line out_pe_lp_func; /* pin 3, paper empty lamp output */ |
| 44 | devcb_resolved_write_line out_reso_func; /* pin 25, reset output */ |
| 45 | devcb_resolved_write_line out_pe_func; /* pin 35, centronics pe output */ |
| 46 | devcb_resolved_read8 in_data_func; /* pin 47-54, centronics data input */ |
| 47 | }; |
| 48 | |
| 49 | |
| 50 | /***************************************************************************** |
| 51 | INLINE FUNCTIONS |
| 52 | *****************************************************************************/ |
| 53 | |
| 54 | INLINE e05a03_state *get_safe_token(const device_config *device) |
| 55 | { |
| 56 | assert(device != NULL); |
| 57 | assert(device->token != NULL); |
| 58 | assert(device->type == E05A03); |
| 59 | |
| 60 | return (e05a03_state *)device->token; |
| 61 | } |
| 62 | |
| 63 | |
| 64 | /***************************************************************************** |
| 65 | DEVICE INTERFACE |
| 66 | *****************************************************************************/ |
| 67 | |
| 68 | static DEVICE_START( e05a03 ) |
| 69 | { |
| 70 | e05a03_state *e05a03 = get_safe_token(device); |
| 71 | const e05a03_interface *intf = device->static_config; |
| 72 | |
| 73 | /* validate some basic stuff */ |
| 74 | assert(device->static_config != NULL); |
| 75 | |
| 76 | /* resolve callbacks */ |
| 77 | devcb_resolve_write_line(&e05a03->out_nlq_lp_func, &intf->out_nlq_lp_func, device); |
| 78 | devcb_resolve_write_line(&e05a03->out_pe_lp_func, &intf->out_pe_lp_func, device); |
| 79 | devcb_resolve_write_line(&e05a03->out_reso_func, &intf->out_reso_func, device); |
| 80 | devcb_resolve_write_line(&e05a03->out_pe_func, &intf->out_pe_func, device); |
| 81 | devcb_resolve_read8(&e05a03->in_data_func, &intf->in_data_func, device); |
| 82 | |
| 83 | /* register for state saving */ |
| 84 | state_save_register_device_item(device, 0, e05a03->shift); |
| 85 | state_save_register_device_item(device, 0, e05a03->busy_leading); |
| 86 | state_save_register_device_item(device, 0, e05a03->busy_software); |
| 87 | state_save_register_device_item(device, 0, e05a03->nlqlp); |
| 88 | state_save_register_device_item(device, 0, e05a03->cndlp); |
| 89 | #if 0 |
| 90 | state_save_register_device_item(device, 0, e05a03->pe); |
| 91 | state_save_register_device_item(device, 0, e05a03->pelp); |
| 92 | #endif |
| 93 | state_save_register_device_item(device, 0, e05a03->printhead); |
| 94 | state_save_register_device_item(device, 0, e05a03->pf_motor); |
| 95 | state_save_register_device_item(device, 0, e05a03->cr_motor); |
| 96 | } |
| 97 | |
| 98 | static DEVICE_RESET( e05a03 ) |
| 99 | { |
| 100 | e05a03_state *e05a03 = get_safe_token(device); |
| 101 | |
| 102 | e05a03->printhead = 0x00; |
| 103 | e05a03->pf_motor = 0x00; |
| 104 | e05a03->cr_motor = 0x0f; |
| 105 | |
| 106 | devcb_call_write_line(&e05a03->out_pe_func, 0); |
| 107 | devcb_call_write_line(&e05a03->out_pe_lp_func, 1); |
| 108 | |
| 109 | e05a03->busy_software = 1; |
| 110 | e05a03->nlqlp = 1; |
| 111 | e05a03->cndlp = 1; |
| 112 | } |
| 113 | |
| 114 | DEVICE_GET_INFO( e05a03 ) |
| 115 | { |
| 116 | switch (state) |
| 117 | { |
| 118 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 119 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(e05a03_state); break; |
| 120 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 121 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_OTHER; break; |
| 122 | |
| 123 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 124 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(e05a03); break; |
| 125 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 126 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(e05a03); break; |
| 127 | |
| 128 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 129 | case DEVINFO_STR_NAME: strcpy(info->s, "E05A03"); break; |
| 130 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Epson printer gate array"); break; |
| 131 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 132 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 133 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | |
| 138 | /*************************************************************************** |
| 139 | IMPLEMENTATION |
| 140 | ***************************************************************************/ |
| 141 | |
| 142 | WRITE8_DEVICE_HANDLER( e05a03_w ) |
| 143 | { |
| 144 | e05a03_state *e05a03 = get_safe_token(device); |
| 145 | |
| 146 | logerror("%s: e05a03_w(%02x): %02x\n", cpuexec_describe_context(device->machine), offset, data); |
| 147 | |
| 148 | switch (offset) |
| 149 | { |
| 150 | /* shift register */ |
| 151 | case 0x00: e05a03->shift = (e05a03->shift & 0x00ffff) | (data << 16); break; |
| 152 | case 0x01: e05a03->shift = (e05a03->shift & 0xff00ff) | (data << 8); break; |
| 153 | case 0x02: e05a03->shift = (e05a03->shift & 0xffff00) | (data << 0); break; |
| 154 | |
| 155 | case 0x03: |
| 156 | e05a03->busy_leading = BIT(data, 7); |
| 157 | e05a03->busy_software = BIT(data, 6); |
| 158 | e05a03->nlqlp = BIT(data, 4); |
| 159 | e05a03->cndlp = BIT(data, 3); |
| 160 | |
| 161 | devcb_call_write_line(&e05a03->out_pe_func, BIT(data, 2)); |
| 162 | devcb_call_write_line(&e05a03->out_pe_lp_func, !BIT(data, 2)); |
| 163 | |
| 164 | #if 0 |
| 165 | e05a03->pe = BIT(data, 2); |
| 166 | e05a03->pelp = !BIT(data, 2); |
| 167 | #endif |
| 168 | |
| 169 | break; |
| 170 | |
| 171 | /* printhead */ |
| 172 | case 0x04: e05a03->printhead = (e05a03->printhead & 0x100) | !data; break; |
| 173 | case 0x05: e05a03->printhead = (e05a03->printhead & 0x0ff) | (!(BIT(data, 7) << 8)); break; |
| 174 | |
| 175 | /* paper feed and carriage motor phase data*/ |
| 176 | case 0x06: e05a03->pf_motor = (data & 0xf0) >> 4; break; |
| 177 | case 0x07: e05a03->cr_motor = (data & 0x0f) >> 0; break; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | READ8_DEVICE_HANDLER( e05a03_r ) |
| 182 | { |
| 183 | e05a03_state *e05a03 = get_safe_token(device); |
| 184 | UINT8 result = 0; |
| 185 | |
| 186 | logerror("%s: e05a03_r(%02x)\n", cpuexec_describe_context(device->machine), offset); |
| 187 | |
| 188 | switch (offset) |
| 189 | { |
| 190 | case 0x00: |
| 191 | break; |
| 192 | |
| 193 | case 0x01: |
| 194 | break; |
| 195 | |
| 196 | case 0x02: |
| 197 | result = devcb_call_read8(&e05a03->in_data_func, 0); |
| 198 | break; |
| 199 | |
| 200 | case 0x03: |
| 201 | result |= BIT(e05a03->shift, 23) << 7; |
| 202 | e05a03->shift <<= 1; |
| 203 | break; |
| 204 | } |
| 205 | |
| 206 | return result; |
| 207 | } |
| 208 | |
| 209 | /* home position signal */ |
| 210 | WRITE_LINE_DEVICE_HANDLER( e05a03_home_w ) |
| 211 | { |
| 212 | } |
| 213 | |
| 214 | /* printhead solenoids trigger */ |
| 215 | WRITE_LINE_DEVICE_HANDLER( e05a03_fire_w ) |
| 216 | { |
| 217 | } |
| 218 | |
| 219 | WRITE_LINE_DEVICE_HANDLER( e05a03_strobe_w ) |
| 220 | { |
| 221 | } |
| 222 | |
| 223 | READ_LINE_DEVICE_HANDLER( e05a03_busy_r ) |
| 224 | { |
| 225 | return 1; |
| 226 | } |
| 227 | |
| 228 | WRITE_LINE_DEVICE_HANDLER( e05a03_resi_w ) |
| 229 | { |
| 230 | e05a03_state *e05a03 = get_safe_token(device); |
| 231 | |
| 232 | if (!state) |
| 233 | { |
| 234 | device_reset_e05a03(device); |
| 235 | devcb_call_write_line(&e05a03->out_reso_func, 1); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | WRITE_LINE_DEVICE_HANDLER( e05a03_init_w ) |
| 240 | { |
| 241 | e05a03_resi_w(device, state); |
| 242 | } |
src/mess/machine/exidy.c
| r5284 | r5285 | |
| 1 | | /******************************************************************************
|
| 2 | | |
| 3 | | Exidy Sorcerer machine functions
|
| 4 | | |
| 5 | | *******************************************************************************/
|
| 6 | | |
| 7 | | #include "driver.h"
|
| 8 | | #include "sound/speaker.h"
|
| 9 | | #include "sound/wave.h"
|
| 10 | | #include "machine/ctronics.h"
|
| 11 | | #include "devices/basicdsk.h"
|
| 12 | | #include "devices/cassette.h"
|
| 13 | | #include "devices/snapquik.h"
|
| 14 | | #include "devices/cartslot.h"
|
| 15 | | #include "machine/ay31015.h"
|
| 16 | | #include "includes/exidy.h"
|
| 17 | | |
| 18 | | |
| 19 | | static const device_config *exidy_ay31015;
|
| 20 | | |
| 21 | | |
| 22 | | static DEVICE_IMAGE_LOAD( exidy_floppy )
|
| 23 | | {
|
| 24 | | if (device_load_basicdsk_floppy(image)==INIT_PASS)
|
| 25 | | {
|
| 26 | | /* not correct */
|
| 27 | | basicdsk_set_geometry(image, 80, 2, 9, 512, 1, 0, FALSE);
|
| 28 | | return INIT_PASS;
|
| 29 | | }
|
| 30 | | |
| 31 | | return INIT_FAIL;
|
| 32 | | }
|
| 33 | | |
| 34 | | |
| 35 | | static UINT8 exidy_fe = 0xff;
|
| 36 | | static UINT8 exidy_keyboard_line;
|
| 37 | | |
| 38 | | #if 0
|
| 39 | | |
| 40 | | The serial code (which was never connected to the outside) is disabled for now.
|
| 41 | | |
| 42 | | /* timer for exidy serial chip transmit and receive */
|
| 43 | | //static emu_timer *serial_timer;
|
| 44 | | |
| 45 | | //static TIMER_CALLBACK(exidy_serial_timer_callback)
|
| 46 | | //{
|
| 47 | | /* if rs232 is enabled, uart is connected to clock defined by bit6 of port fe.
|
| 48 | | Transmit and receive clocks are connected to the same clock */
|
| 49 | | |
| 50 | | /* if rs232 is disabled, receive clock is linked to cassette hardware */
|
| 51 | | // if (exidy_fe & 0x80)
|
| 52 | | // {
|
| 53 | | connect to rs232
|
| 54 | | // }
|
| 55 | | //}
|
| 56 | | #endif
|
| 57 | | |
| 58 | | |
| 59 | | /* timer to read cassette waveforms */
|
| 60 | | static emu_timer *cassette_timer;
|
| 61 | | |
| 62 | | |
| 63 | | static const device_config *cassette_device_image(running_machine *machine)
|
| 64 | | {
|
| 65 | | if (exidy_fe & 0x20)
|
| 66 | | return devtag_get_device(machine, "cassette2");
|
| 67 | | else
|
| 68 | | return devtag_get_device(machine, "cassette1");
|
| 69 | | }
|
| 70 | | |
| 71 | | |
| 72 | | static struct {
|
| 73 | | struct {
|
| 74 | | int length; /* time cassette level is at input.level */
|
| 75 | | int level; /* cassette level */
|
| 76 | | int bit; /* bit being read */
|
| 77 | | } input;
|
| 78 | | struct {
|
| 79 | | int length; /* time cassette level is at output.level */
|
| 80 | | int level; /* cassette level */
|
| 81 | | int bit; /* bit to to output */
|
| 82 | | } output;
|
| 83 | | } cass_data;
|
| 84 | | |
| 85 | | |
| 86 | | static TIMER_CALLBACK(exidy_cassette_tc)
|
| 87 | | {
|
| 88 | | UINT8 cass_ws = 0;
|
| 89 | | switch (exidy_fe & 0xc0) /*/ bit 7 low indicates cassette */
|
| 90 | | {
|
| 91 | | case 0x00: /* Cassette 300 baud */
|
| 92 | | |
| 93 | | /* loading a tape - this is basically the same as the super80.
|
| 94 | | We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */
|
| 95 | | |
| 96 | | cass_data.input.length++;
|
| 97 | | |
| 98 | | cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0;
|
| 99 | | |
| 100 | | if (cass_ws != cass_data.input.level)
|
| 101 | | {
|
| 102 | | cass_data.input.level = cass_ws;
|
| 103 | | cass_data.input.bit = ((cass_data.input.length < 0x6) || (cass_data.input.length > 0x20)) ? 1 : 0;
|
| 104 | | cass_data.input.length = 0;
|
| 105 | | ay31015_set_input_pin( exidy_ay31015, AY31015_SI, cass_data.input.bit );
|
| 106 | | }
|
| 107 | | |
| 108 | | /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies.
|
| 109 | | Synchronisation of the frequency pulses to the uart is extremely important. */
|
| 110 | | |
| 111 | | cass_data.output.length++;
|
| 112 | | if (!(cass_data.output.length & 0x1f))
|
| 113 | | {
|
| 114 | | cass_ws = ay31015_get_output_pin( exidy_ay31015, AY31015_SO );
|
| 115 | | if (cass_ws != cass_data.output.bit)
|
| 116 | | {
|
| 117 | | cass_data.output.bit = cass_ws;
|
| 118 | | cass_data.output.length = 0;
|
| 119 | | }
|
| 120 | | }
|
| 121 | | |
| 122 | | if (!(cass_data.output.length & 3))
|
| 123 | | {
|
| 124 | | if (!((cass_data.output.bit == 0) && (cass_data.output.length & 4)))
|
| 125 | | {
|
| 126 | | cass_data.output.level ^= 1; // toggle output state, except on 2nd half of low bit
|
| 127 | | cassette_output(cassette_device_image(machine), cass_data.output.level ? -1.0 : +1.0);
|
| 128 | | }
|
| 129 | | }
|
| 130 | | return;
|
| 131 | | |
| 132 | | case 0x40: /* Cassette 1200 baud */
|
| 133 | | /* loading a tape */
|
| 134 | | cass_data.input.length++;
|
| 135 | | |
| 136 | | cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0;
|
| 137 | | |
| 138 | | if (cass_ws != cass_data.input.level || cass_data.input.length == 10)
|
| 139 | | {
|
| 140 | | cass_data.input.bit = ((cass_data.input.length < 10) || (cass_data.input.length > 0x20)) ? 1 : 0;
|
| 141 | | if ( cass_ws != cass_data.input.level )
|
| 142 | | {
|
| 143 | | cass_data.input.length = 0;
|
| 144 | | cass_data.input.level = cass_ws;
|
| 145 | | }
|
| 146 | | ay31015_set_input_pin( exidy_ay31015, AY31015_SI, cass_data.input.bit );
|
| 147 | | }
|
| 148 | | |
| 149 | | /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */
|
| 150 | | |
| 151 | | cass_data.output.length++;
|
| 152 | | if (!(cass_data.output.length & 0x07))
|
| 153 | | {
|
| 154 | | cass_ws = ay31015_get_output_pin( exidy_ay31015, AY31015_SO );
|
| 155 | | if (cass_ws != cass_data.output.bit)
|
| 156 | | {
|
| 157 | | cass_data.output.bit = cass_ws;
|
| 158 | | cass_data.output.length = 0;
|
| 159 | | }
|
| 160 | | }
|
| 161 | | |
| 162 | | if (!(cass_data.output.length & 7))
|
| 163 | | {
|
| 164 | | if (!((cass_data.output.bit == 0) && (cass_data.output.length & 8)))
|
| 165 | | {
|
| 166 | | cass_data.output.level ^= 1; // toggle output state, except on 2nd half of low bit
|
| 167 | | cassette_output(cassette_device_image(machine), cass_data.output.level ? -1.0 : +1.0);
|
| 168 | | }
|
| 169 | | }
|
| 170 | | return;
|
| 171 | | }
|
| 172 | | }
|
| 173 | | |
| 174 | | |
| 175 | | /* after the first 4 bytes have been read from ROM, switch the ram back in */
|
| 176 | | static TIMER_CALLBACK( exidy_reset )
|
| 177 | | {
|
| 178 | | memory_set_bank(machine, 1, 0);
|
| 179 | | }
|
| 180 | | |
| 181 | | WRITE8_HANDLER(exidy_fc_w)
|
| 182 | | {
|
| 183 | | ay31015_set_transmit_data( exidy_ay31015, data );
|
| 184 | | }
|
| 185 | | |
| 186 | | |
| 187 | | WRITE8_HANDLER(exidy_fd_w)
|
| 188 | | {
|
| 189 | | /* Translate data to control signals */
|
| 190 | | |
| 191 | | ay31015_set_input_pin( exidy_ay31015, AY31015_CS, 0 );
|
| 192 | | ay31015_set_input_pin( exidy_ay31015, AY31015_NB1, ( data & 0x01 ) ? 1 : 0 );
|
| 193 | | ay31015_set_input_pin( exidy_ay31015, AY31015_NB2, ( data & 0x02 ) ? 1 : 0 );
|
| 194 | | ay31015_set_input_pin( exidy_ay31015, AY31015_TSB, ( data & 0x04 ) ? 1 : 0 );
|
| 195 | | ay31015_set_input_pin( exidy_ay31015, AY31015_EPS, ( data & 0x08 ) ? 1 : 0 );
|
| 196 | | ay31015_set_input_pin( exidy_ay31015, AY31015_NP, ( data & 0x10 ) ? 1 : 0 );
|
| 197 | | ay31015_set_input_pin( exidy_ay31015, AY31015_CS, 1 );
|
| 198 | | }
|
| 199 | | |
| 200 | | #define EXIDY_CASSETTE_MOTOR_MASK ((1<<4)|(1<<5))
|
| 201 | | |
| 202 | | |
| 203 | | WRITE8_HANDLER(exidy_fe_w)
|
| 204 | | {
|
| 205 | | UINT8 changed_bits = (exidy_fe ^ data) & 0xf0;
|
| 206 | | exidy_fe = data;
|
| 207 | | |
| 208 | | /* bits 0..3 */
|
| 209 | | exidy_keyboard_line = data & 0x0f;
|
| 210 | | |
| 211 | | if (!changed_bits) return;
|
| 212 | | |
| 213 | | /* bits 4..5 */
|
| 214 | | /* does user want to hear the sound? */
|
| 215 | | if ((input_port_read(space->machine, "CONFIG") & 8) && (data & EXIDY_CASSETTE_MOTOR_MASK))
|
| 216 | | {
|
| 217 | | if (data & 0x20)
|
| 218 | | {
|
| 219 | | cassette_change_state(devtag_get_device(space->machine, "cassette1"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
|
| 220 | | cassette_change_state(devtag_get_device(space->machine, "cassette2"), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
|
| 221 | | }
|
| 222 | | else
|
| 223 | | {
|
| 224 | | cassette_change_state(devtag_get_device(space->machine, "cassette2"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
|
| 225 | | cassette_change_state(devtag_get_device(space->machine, "cassette1"), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
|
| 226 | | }
|
| 227 | | }
|
| 228 | | else
|
| 229 | | {
|
| 230 | | cassette_change_state(devtag_get_device(space->machine, "cassette2"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
|
| 231 | | cassette_change_state(devtag_get_device(space->machine, "cassette1"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
|
| 232 | | }
|
| 233 | | |
| 234 | | /* cassette 1 motor */
|
| 235 | | cassette_change_state(devtag_get_device(space->machine, "cassette1"),
|
| 236 | | (data & 0x10) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
|
| 237 | | |
| 238 | | /* cassette 2 motor */
|
| 239 | | cassette_change_state(devtag_get_device(space->machine, "cassette2"),
|
| 240 | | (data & 0x20) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
|
| 241 | | |
| 242 | | if ((data & EXIDY_CASSETTE_MOTOR_MASK) && (~data & 0x80))
|
| 243 | | timer_adjust_periodic(cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(19200));
|
| 244 | | else
|
| 245 | | timer_adjust_oneshot(cassette_timer, attotime_zero, 0);
|
| 246 | | |
| 247 | | /* bit 6 */
|
| 248 | | if (changed_bits & 0x40)
|
| 249 | | {
|
| 250 | | ay31015_set_receiver_clock( exidy_ay31015, (data & 0x40) ? 19200.0 : 4800.0);
|
| 251 | | ay31015_set_transmitter_clock( exidy_ay31015, (data & 0x40) ? 19200.0 : 4800.0);
|
| 252 | | }
|
| 253 | | |
| 254 | | /* bit 7 */
|
| 255 | | if (changed_bits & 0x80)
|
| 256 | | {
|
| 257 | | if (data & 0x80)
|
| 258 | | {
|
| 259 | | /* connect to serial device (not yet emulated) */
|
| 260 | | // timer_adjust_periodic(serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud_rate));
|
| 261 | | }
|
| 262 | | else
|
| 263 | | {
|
| 264 | | /* connect to tape */
|
| 265 | | // hd6402_connect(&cassette_serial_connection);
|
| 266 | | }
|
| 267 | | }
|
| 268 | | }
|
| 269 | | |
| 270 | | WRITE8_HANDLER(exidy_ff_w)
|
| 271 | | {
|
| 272 | | const device_config *printer = devtag_get_device(space->machine, "centronics");
|
| 273 | | const device_config *speaker = devtag_get_device(space->machine, "speaker");
|
| 274 | | /* reading the config switch */
|
| 275 | | switch (input_port_read(space->machine, "CONFIG") & 0x06)
|
| 276 | | {
|
| 277 | | case 0: /* speaker */
|
| 278 | | speaker_level_w(speaker, (data) ? 1 : 0);
|
| 279 | | break;
|
| 280 | | |
| 281 | | case 2: /* Centronics 7-bit printer */
|
| 282 | | /* bit 7 = strobe, bit 6..0 = data */
|
| 283 | | centronics_strobe_w(printer, (~data>>7) & 0x01);
|
| 284 | | centronics_data_w(printer, 0, data & 0x7f);
|
| 285 | | break;
|
| 286 | | |
| 287 | | case 4: /* 8-bit parallel output */
|
| 288 | | /* hardware strobe driven from port select, bit 7..0 = data */
|
| 289 | | centronics_strobe_w(printer, 1);
|
| 290 | | centronics_data_w(printer, 0, data);
|
| 291 | | centronics_strobe_w(printer, 0);
|
| 292 | | break;
|
| 293 | | }
|
| 294 | | }
|
| 295 | | |
| 296 | | READ8_HANDLER(exidy_fc_r)
|
| 297 | | {
|
| 298 | | UINT8 data = ay31015_get_received_data( exidy_ay31015 );
|
| 299 | | ay31015_set_input_pin( exidy_ay31015, AY31015_RDAV, 0 );
|
| 300 | | ay31015_set_input_pin( exidy_ay31015, AY31015_RDAV, 1 );
|
| 301 | | return data;
|
| 302 | | }
|
| 303 | | |
| 304 | | READ8_HANDLER(exidy_fd_r)
|
| 305 | | {
|
| 306 | | /* set unused bits high */
|
| 307 | | UINT8 data = 0xe0;
|
| 308 | | |
| 309 | | ay31015_set_input_pin( exidy_ay31015, AY31015_SWE, 0 );
|
| 310 | | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_TBMT ) ? 0x01 : 0;
|
| 311 | | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_DAV ) ? 0x02 : 0;
|
| 312 | | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_OR ) ? 0x04 : 0;
|
| 313 | | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_FE ) ? 0x08 : 0;
|
| 314 | | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_PE ) ? 0x10 : 0;
|
| 315 | | ay31015_set_input_pin( exidy_ay31015, AY31015_SWE, 1 );
|
| 316 | | |
| 317 | | return data;
|
| 318 | | }
|
| 319 | | |
| 320 | | READ8_HANDLER(exidy_fe_r)
|
| 321 | | {
|
| 322 | | /* bits 6..7
|
| 323 | | - hardware handshakes from user port
|
| 324 | | - not emulated
|
| 325 | | - tied high, allowing PARIN and PAROUT bios routines to run */
|
| 326 | | |
| 327 | | UINT8 data = 0xc0;
|
| 328 | | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
|
| 329 | | "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15" };
|
| 330 | | |
| 331 | | /* bit 5 - vsync (inverted) */
|
| 332 | | data |= (((~input_port_read(space->machine, "VS")) & 0x01)<<5);
|
| 333 | | |
| 334 | | /* bits 4..0 - keyboard data */
|
| 335 | | data |= (input_port_read(space->machine, keynames[exidy_keyboard_line]) & 0x1f);
|
| 336 | | |
| 337 | | return data;
|
| 338 | | }
|
| 339 | | |
| 340 | | READ8_HANDLER(exidy_ff_r)
|
| 341 | | {
|
| 342 | | /* The use of the parallel port as a general purpose port is not emulated.
|
| 343 | | Currently the only use is to read the printer status in the Centronics CENDRV bios routine.
|
| 344 | | This uses bit 7. The other bits have been set high (=nothing plugged in).
|
| 345 | | This fixes those games that use a joystick. */
|
| 346 | | |
| 347 | | const device_config *printer = devtag_get_device(space->machine, "centronics");
|
| 348 | | UINT8 data=0x7f;
|
| 349 | | |
| 350 | | /* bit 7 = printer busy
|
| 351 | | 0 = printer is not busy */
|
| 352 | | |
| 353 | | data |= centronics_busy_r(printer) << 7;
|
| 354 | | |
| 355 | | return data;
|
| 356 | | }
|
| 357 | | |
| 358 | | |
| 359 | | |
| 360 | | /**********************************************************************************************************/
|
| 361 | | |
| 362 | | Z80BIN_EXECUTE( exidy )
|
| 363 | | {
|
| 364 | | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
| 365 | | |
| 366 | | if ((execute_address >= 0xc000) && (execute_address <= 0xdfff) && (memory_read_byte(space, 0xdffa) != 0xc3))
|
| 367 | | return; /* can't run a program if the cartridge isn't in */
|
| 368 | | |
| 369 | | /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run.
|
| 370 | | 1. A start address of 01D5 indicates a basic program which needs its pointers fixed up.
|
| 371 | | 2. If autorunning, jump to C689 (command processor), else jump to C3DD (READY prompt).
|
| 372 | | Important addresses:
|
| 373 | | 01D5 = start (load) address of a conventional basic program
|
| 374 | | C858 = an autorun basic program will have this exec address on the tape
|
| 375 | | C3DD = part of basic that displays READY and lets user enter input */
|
| 376 | | |
| 377 | | if ((start_address == 0x1d5) || (execute_address == 0xc858))
|
| 378 | | {
|
| 379 | | UINT8 i, data[]={
|
| 380 | | 0xcd, 0x26, 0xc4, // CALL C426 ;set up other pointers
|
| 381 | | 0x21, 0xd4, 1, // LD HL,01D4 ;start of program address (used by C689)
|
| 382 | | 0x36, 0, // LD (HL),00 ;make sure dummy end-of-line is there
|
| 383 | | 0xc3, 0x89, 0xc6,}; // JP C689 ;run program
|
| 384 | | |
| 385 | | for (i = 0; i < ARRAY_LENGTH(data); i++)
|
| 386 | | memory_write_byte(space, 0xf01f + i, data[i]);
|
| 387 | | |
| 388 | | if (!autorun)
|
| 389 | | memory_write_word_16le(space, 0xf028,0xc3dd);
|
| 390 | | |
| 391 | | /* tell BASIC where program ends */
|
| 392 | | memory_write_byte(space, 0x1b7, (end_address >> 0) & 0xff);
|
| 393 | | memory_write_byte(space, 0x1b8, (end_address >> 8) & 0xff);
|
| 394 | | |
| 395 | | if ((execute_address != 0xc858) && autorun)
|
| 396 | | memory_write_word_16le(space, 0xf028, execute_address);
|
| 397 | | |
| 398 | | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), REG_GENPC, 0xf01f);
|
| 399 | | }
|
| 400 | | else
|
| 401 | | {
|
| 402 | | if (autorun)
|
| 403 | | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), REG_GENPC, execute_address);
|
| 404 | | }
|
| 405 | | }
|
| 406 | | |
| 407 | | void exidy_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
|
| 408 | | {
|
| 409 | | /* floppy */
|
| 410 | | switch(state)
|
| 411 | | {
|
| 412 | | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 413 | | case MESS_DEVINFO_INT_COUNT: info->i = 4; break;
|
| 414 | | |
| 415 | | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 416 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(exidy_floppy); break;
|
| 417 | | |
| 418 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 419 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break;
|
| 420 | | |
| 421 | | default: legacybasicdsk_device_getinfo(devclass, state, info); break;
|
| 422 | | }
|
| 423 | | }
|
| 424 | | |
| 425 | | MACHINE_START( exidyd )
|
| 426 | | {
|
| 427 | | // serial_timer = timer_alloc(machine, exidy_serial_timer_callback, NULL);
|
| 428 | | cassette_timer = timer_alloc(machine, exidy_cassette_tc, NULL);
|
| 429 | | }
|
| 430 | | |
| 431 | | MACHINE_START( exidy )
|
| 432 | | {
|
| 433 | | MACHINE_START_CALL( exidyd );
|
| 434 | | }
|
| 435 | | |
| 436 | | MACHINE_RESET( exidyd )
|
| 437 | | {
|
| 438 | | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
|
| 439 | | |
| 440 | | /* Initialize cassette interface */
|
| 441 | | cass_data.output.length = 0;
|
| 442 | | cass_data.output.level = 1;
|
| 443 | | cass_data.input.length = 0;
|
| 444 | | cass_data.input.bit = 1;
|
| 445 | | |
| 446 | | exidy_ay31015 = devtag_get_device(machine, "ay_3_1015");
|
| 447 | | |
| 448 | | exidy_fe_w(space, 0, 0);
|
| 449 | | |
| 450 | | timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, exidy_reset);
|
| 451 | | memory_set_bank(machine, 1, 1);
|
| 452 | | }
|
| 453 | | |
| 454 | | MACHINE_RESET( exidy )
|
| 455 | | {
|
| 456 | | floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80);
|
| 457 | | MACHINE_RESET_CALL( exidyd );
|
| 458 | | }
|
| 1 | /****************************************************************************** |
| 2 | |
| 3 | Exidy Sorcerer machine functions |
| 4 | |
| 5 | *******************************************************************************/ |
| 6 | |
| 7 | #include "driver.h" |
| 8 | #include "sound/speaker.h" |
| 9 | #include "sound/wave.h" |
| 10 | #include "machine/ctronics.h" |
| 11 | #include "devices/basicdsk.h" |
| 12 | #include "devices/cassette.h" |
| 13 | #include "devices/snapquik.h" |
| 14 | #include "devices/cartslot.h" |
| 15 | #include "machine/ay31015.h" |
| 16 | #include "includes/exidy.h" |
| 17 | |
| 18 | |
| 19 | static const device_config *exidy_ay31015; |
| 20 | |
| 21 | |
| 22 | static DEVICE_IMAGE_LOAD( exidy_floppy ) |
| 23 | { |
| 24 | if (device_load_basicdsk_floppy(image)==INIT_PASS) |
| 25 | { |
| 26 | /* not correct */ |
| 27 | basicdsk_set_geometry(image, 80, 2, 9, 512, 1, 0, FALSE); |
| 28 | return INIT_PASS; |
| 29 | } |
| 30 | |
| 31 | return INIT_FAIL; |
| 32 | } |
| 33 | |
| 34 | |
| 35 | static UINT8 exidy_fe = 0xff; |
| 36 | static UINT8 exidy_keyboard_line; |
| 37 | |
| 38 | #if 0 |
| 39 | |
| 40 | The serial code (which was never connected to the outside) is disabled for now. |
| 41 | |
| 42 | /* timer for exidy serial chip transmit and receive */ |
| 43 | //static emu_timer *serial_timer; |
| 44 | |
| 45 | //static TIMER_CALLBACK(exidy_serial_timer_callback) |
| 46 | //{ |
| 47 | /* if rs232 is enabled, uart is connected to clock defined by bit6 of port fe. |
| 48 | Transmit and receive clocks are connected to the same clock */ |
| 49 | |
| 50 | /* if rs232 is disabled, receive clock is linked to cassette hardware */ |
| 51 | // if (exidy_fe & 0x80) |
| 52 | // { |
| 53 | connect to rs232 |
| 54 | // } |
| 55 | //} |
| 56 | #endif |
| 57 | |
| 58 | |
| 59 | /* timer to read cassette waveforms */ |
| 60 | static emu_timer *cassette_timer; |
| 61 | |
| 62 | |
| 63 | static const device_config *cassette_device_image(running_machine *machine) |
| 64 | { |
| 65 | if (exidy_fe & 0x20) |
| 66 | return devtag_get_device(machine, "cassette2"); |
| 67 | else |
| 68 | return devtag_get_device(machine, "cassette1"); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | static struct { |
| 73 | struct { |
| 74 | int length; /* time cassette level is at input.level */ |
| 75 | int level; /* cassette level */ |
| 76 | int bit; /* bit being read */ |
| 77 | } input; |
| 78 | struct { |
| 79 | int length; /* time cassette level is at output.level */ |
| 80 | int level; /* cassette level */ |
| 81 | int bit; /* bit to to output */ |
| 82 | } output; |
| 83 | } cass_data; |
| 84 | |
| 85 | |
| 86 | static TIMER_CALLBACK(exidy_cassette_tc) |
| 87 | { |
| 88 | UINT8 cass_ws = 0; |
| 89 | switch (exidy_fe & 0xc0) /*/ bit 7 low indicates cassette */ |
| 90 | { |
| 91 | case 0x00: /* Cassette 300 baud */ |
| 92 | |
| 93 | /* loading a tape - this is basically the same as the super80. |
| 94 | We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */ |
| 95 | |
| 96 | cass_data.input.length++; |
| 97 | |
| 98 | cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0; |
| 99 | |
| 100 | if (cass_ws != cass_data.input.level) |
| 101 | { |
| 102 | cass_data.input.level = cass_ws; |
| 103 | cass_data.input.bit = ((cass_data.input.length < 0x6) || (cass_data.input.length > 0x20)) ? 1 : 0; |
| 104 | cass_data.input.length = 0; |
| 105 | ay31015_set_input_pin( exidy_ay31015, AY31015_SI, cass_data.input.bit ); |
| 106 | } |
| 107 | |
| 108 | /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies. |
| 109 | Synchronisation of the frequency pulses to the uart is extremely important. */ |
| 110 | |
| 111 | cass_data.output.length++; |
| 112 | if (!(cass_data.output.length & 0x1f)) |
| 113 | { |
| 114 | cass_ws = ay31015_get_output_pin( exidy_ay31015, AY31015_SO ); |
| 115 | if (cass_ws != cass_data.output.bit) |
| 116 | { |
| 117 | cass_data.output.bit = cass_ws; |
| 118 | cass_data.output.length = 0; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | if (!(cass_data.output.length & 3)) |
| 123 | { |
| 124 | if (!((cass_data.output.bit == 0) && (cass_data.output.length & 4))) |
| 125 | { |
| 126 | cass_data.output.level ^= 1; // toggle output state, except on 2nd half of low bit |
| 127 | cassette_output(cassette_device_image(machine), cass_data.output.level ? -1.0 : +1.0); |
| 128 | } |
| 129 | } |
| 130 | return; |
| 131 | |
| 132 | case 0x40: /* Cassette 1200 baud */ |
| 133 | /* loading a tape */ |
| 134 | cass_data.input.length++; |
| 135 | |
| 136 | cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0; |
| 137 | |
| 138 | if (cass_ws != cass_data.input.level || cass_data.input.length == 10) |
| 139 | { |
| 140 | cass_data.input.bit = ((cass_data.input.length < 10) || (cass_data.input.length > 0x20)) ? 1 : 0; |
| 141 | if ( cass_ws != cass_data.input.level ) |
| 142 | { |
| 143 | cass_data.input.length = 0; |
| 144 | cass_data.input.level = cass_ws; |
| 145 | } |
| 146 | ay31015_set_input_pin( exidy_ay31015, AY31015_SI, cass_data.input.bit ); |
| 147 | } |
| 148 | |
| 149 | /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */ |
| 150 | |
| 151 | cass_data.output.length++; |
| 152 | if (!(cass_data.output.length & 0x07)) |
| 153 | { |
| 154 | cass_ws = ay31015_get_output_pin( exidy_ay31015, AY31015_SO ); |
| 155 | if (cass_ws != cass_data.output.bit) |
| 156 | { |
| 157 | cass_data.output.bit = cass_ws; |
| 158 | cass_data.output.length = 0; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (!(cass_data.output.length & 7)) |
| 163 | { |
| 164 | if (!((cass_data.output.bit == 0) && (cass_data.output.length & 8))) |
| 165 | { |
| 166 | cass_data.output.level ^= 1; // toggle output state, except on 2nd half of low bit |
| 167 | cassette_output(cassette_device_image(machine), cass_data.output.level ? -1.0 : +1.0); |
| 168 | } |
| 169 | } |
| 170 | return; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | |
| 175 | /* after the first 4 bytes have been read from ROM, switch the ram back in */ |
| 176 | static TIMER_CALLBACK( exidy_reset ) |
| 177 | { |
| 178 | memory_set_bank(machine, 1, 0); |
| 179 | } |
| 180 | |
| 181 | WRITE8_HANDLER(exidy_fc_w) |
| 182 | { |
| 183 | ay31015_set_transmit_data( exidy_ay31015, data ); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | WRITE8_HANDLER(exidy_fd_w) |
| 188 | { |
| 189 | /* Translate data to control signals */ |
| 190 | |
| 191 | ay31015_set_input_pin( exidy_ay31015, AY31015_CS, 0 ); |
| 192 | ay31015_set_input_pin( exidy_ay31015, AY31015_NB1, ( data & 0x01 ) ? 1 : 0 ); |
| 193 | ay31015_set_input_pin( exidy_ay31015, AY31015_NB2, ( data & 0x02 ) ? 1 : 0 ); |
| 194 | ay31015_set_input_pin( exidy_ay31015, AY31015_TSB, ( data & 0x04 ) ? 1 : 0 ); |
| 195 | ay31015_set_input_pin( exidy_ay31015, AY31015_EPS, ( data & 0x08 ) ? 1 : 0 ); |
| 196 | ay31015_set_input_pin( exidy_ay31015, AY31015_NP, ( data & 0x10 ) ? 1 : 0 ); |
| 197 | ay31015_set_input_pin( exidy_ay31015, AY31015_CS, 1 ); |
| 198 | } |
| 199 | |
| 200 | #define EXIDY_CASSETTE_MOTOR_MASK ((1<<4)|(1<<5)) |
| 201 | |
| 202 | |
| 203 | WRITE8_HANDLER(exidy_fe_w) |
| 204 | { |
| 205 | UINT8 changed_bits = (exidy_fe ^ data) & 0xf0; |
| 206 | exidy_fe = data; |
| 207 | |
| 208 | /* bits 0..3 */ |
| 209 | exidy_keyboard_line = data & 0x0f; |
| 210 | |
| 211 | if (!changed_bits) return; |
| 212 | |
| 213 | /* bits 4..5 */ |
| 214 | /* does user want to hear the sound? */ |
| 215 | if ((input_port_read(space->machine, "CONFIG") & 8) && (data & EXIDY_CASSETTE_MOTOR_MASK)) |
| 216 | { |
| 217 | if (data & 0x20) |
| 218 | { |
| 219 | cassette_change_state(devtag_get_device(space->machine, "cassette1"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); |
| 220 | cassette_change_state(devtag_get_device(space->machine, "cassette2"), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER); |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | cassette_change_state(devtag_get_device(space->machine, "cassette2"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); |
| 225 | cassette_change_state(devtag_get_device(space->machine, "cassette1"), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER); |
| 226 | } |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | cassette_change_state(devtag_get_device(space->machine, "cassette2"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); |
| 231 | cassette_change_state(devtag_get_device(space->machine, "cassette1"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); |
| 232 | } |
| 233 | |
| 234 | /* cassette 1 motor */ |
| 235 | cassette_change_state(devtag_get_device(space->machine, "cassette1"), |
| 236 | (data & 0x10) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 237 | |
| 238 | /* cassette 2 motor */ |
| 239 | cassette_change_state(devtag_get_device(space->machine, "cassette2"), |
| 240 | (data & 0x20) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 241 | |
| 242 | if ((data & EXIDY_CASSETTE_MOTOR_MASK) && (~data & 0x80)) |
| 243 | timer_adjust_periodic(cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(19200)); |
| 244 | else |
| 245 | timer_adjust_oneshot(cassette_timer, attotime_zero, 0); |
| 246 | |
| 247 | /* bit 6 */ |
| 248 | if (changed_bits & 0x40) |
| 249 | { |
| 250 | ay31015_set_receiver_clock( exidy_ay31015, (data & 0x40) ? 19200.0 : 4800.0); |
| 251 | ay31015_set_transmitter_clock( exidy_ay31015, (data & 0x40) ? 19200.0 : 4800.0); |
| 252 | } |
| 253 | |
| 254 | /* bit 7 */ |
| 255 | if (changed_bits & 0x80) |
| 256 | { |
| 257 | if (data & 0x80) |
| 258 | { |
| 259 | /* connect to serial device (not yet emulated) */ |
| 260 | // timer_adjust_periodic(serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud_rate)); |
| 261 | } |
| 262 | else |
| 263 | { |
| 264 | /* connect to tape */ |
| 265 | // hd6402_connect(&cassette_serial_connection); |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | WRITE8_HANDLER(exidy_ff_w) |
| 271 | { |
| 272 | const device_config *printer = devtag_get_device(space->machine, "centronics"); |
| 273 | const device_config *speaker = devtag_get_device(space->machine, "speaker"); |
| 274 | /* reading the config switch */ |
| 275 | switch (input_port_read(space->machine, "CONFIG") & 0x06) |
| 276 | { |
| 277 | case 0: /* speaker */ |
| 278 | speaker_level_w(speaker, (data) ? 1 : 0); |
| 279 | break; |
| 280 | |
| 281 | case 2: /* Centronics 7-bit printer */ |
| 282 | /* bit 7 = strobe, bit 6..0 = data */ |
| 283 | centronics_strobe_w(printer, (~data>>7) & 0x01); |
| 284 | centronics_data_w(printer, 0, data & 0x7f); |
| 285 | break; |
| 286 | |
| 287 | case 4: /* 8-bit parallel output */ |
| 288 | /* hardware strobe driven from port select, bit 7..0 = data */ |
| 289 | centronics_strobe_w(printer, 1); |
| 290 | centronics_data_w(printer, 0, data); |
| 291 | centronics_strobe_w(printer, 0); |
| 292 | break; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | READ8_HANDLER(exidy_fc_r) |
| 297 | { |
| 298 | UINT8 data = ay31015_get_received_data( exidy_ay31015 ); |
| 299 | ay31015_set_input_pin( exidy_ay31015, AY31015_RDAV, 0 ); |
| 300 | ay31015_set_input_pin( exidy_ay31015, AY31015_RDAV, 1 ); |
| 301 | return data; |
| 302 | } |
| 303 | |
| 304 | READ8_HANDLER(exidy_fd_r) |
| 305 | { |
| 306 | /* set unused bits high */ |
| 307 | UINT8 data = 0xe0; |
| 308 | |
| 309 | ay31015_set_input_pin( exidy_ay31015, AY31015_SWE, 0 ); |
| 310 | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_TBMT ) ? 0x01 : 0; |
| 311 | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_DAV ) ? 0x02 : 0; |
| 312 | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_OR ) ? 0x04 : 0; |
| 313 | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_FE ) ? 0x08 : 0; |
| 314 | data |= ay31015_get_output_pin( exidy_ay31015, AY31015_PE ) ? 0x10 : 0; |
| 315 | ay31015_set_input_pin( exidy_ay31015, AY31015_SWE, 1 ); |
| 316 | |
| 317 | return data; |
| 318 | } |
| 319 | |
| 320 | READ8_HANDLER(exidy_fe_r) |
| 321 | { |
| 322 | /* bits 6..7 |
| 323 | - hardware handshakes from user port |
| 324 | - not emulated |
| 325 | - tied high, allowing PARIN and PAROUT bios routines to run */ |
| 326 | |
| 327 | UINT8 data = 0xc0; |
| 328 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", |
| 329 | "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15" }; |
| 330 | |
| 331 | /* bit 5 - vsync (inverted) */ |
| 332 | data |= (((~input_port_read(space->machine, "VS")) & 0x01)<<5); |
| 333 | |
| 334 | /* bits 4..0 - keyboard data */ |
| 335 | data |= (input_port_read(space->machine, keynames[exidy_keyboard_line]) & 0x1f); |
| 336 | |
| 337 | return data; |
| 338 | } |
| 339 | |
| 340 | READ8_HANDLER(exidy_ff_r) |
| 341 | { |
| 342 | /* The use of the parallel port as a general purpose port is not emulated. |
| 343 | Currently the only use is to read the printer status in the Centronics CENDRV bios routine. |
| 344 | This uses bit 7. The other bits have been set high (=nothing plugged in). |
| 345 | This fixes those games that use a joystick. */ |
| 346 | |
| 347 | const device_config *printer = devtag_get_device(space->machine, "centronics"); |
| 348 | UINT8 data=0x7f; |
| 349 | |
| 350 | /* bit 7 = printer busy |
| 351 | 0 = printer is not busy */ |
| 352 | |
| 353 | data |= centronics_busy_r(printer) << 7; |
| 354 | |
| 355 | return data; |
| 356 | } |
| 357 | |
| 358 | |
| 359 | |
| 360 | /**********************************************************************************************************/ |
| 361 | |
| 362 | Z80BIN_EXECUTE( exidy ) |
| 363 | { |
| 364 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 365 | |
| 366 | if ((execute_address >= 0xc000) && (execute_address <= 0xdfff) && (memory_read_byte(space, 0xdffa) != 0xc3)) |
| 367 | return; /* can't run a program if the cartridge isn't in */ |
| 368 | |
| 369 | /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run. |
| 370 | 1. A start address of 01D5 indicates a basic program which needs its pointers fixed up. |
| 371 | 2. If autorunning, jump to C689 (command processor), else jump to C3DD (READY prompt). |
| 372 | Important addresses: |
| 373 | 01D5 = start (load) address of a conventional basic program |
| 374 | C858 = an autorun basic program will have this exec address on the tape |
| 375 | C3DD = part of basic that displays READY and lets user enter input */ |
| 376 | |
| 377 | if ((start_address == 0x1d5) || (execute_address == 0xc858)) |
| 378 | { |
| 379 | UINT8 i, data[]={ |
| 380 | 0xcd, 0x26, 0xc4, // CALL C426 ;set up other pointers |
| 381 | 0x21, 0xd4, 1, // LD HL,01D4 ;start of program address (used by C689) |
| 382 | 0x36, 0, // LD (HL),00 ;make sure dummy end-of-line is there |
| 383 | 0xc3, 0x89, 0xc6,}; // JP C689 ;run program |
| 384 | |
| 385 | for (i = 0; i < ARRAY_LENGTH(data); i++) |
| 386 | memory_write_byte(space, 0xf01f + i, data[i]); |
| 387 | |
| 388 | if (!autorun) |
| 389 | memory_write_word_16le(space, 0xf028,0xc3dd); |
| 390 | |
| 391 | /* tell BASIC where program ends */ |
| 392 | memory_write_byte(space, 0x1b7, (end_address >> 0) & 0xff); |
| 393 | memory_write_byte(space, 0x1b8, (end_address >> 8) & 0xff); |
| 394 | |
| 395 | if ((execute_address != 0xc858) && autorun) |
| 396 | memory_write_word_16le(space, 0xf028, execute_address); |
| 397 | |
| 398 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), REG_GENPC, 0xf01f); |
| 399 | } |
| 400 | else |
| 401 | { |
| 402 | if (autorun) |
| 403 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), REG_GENPC, execute_address); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | void exidy_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 408 | { |
| 409 | /* floppy */ |
| 410 | switch(state) |
| 411 | { |
| 412 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 413 | case MESS_DEVINFO_INT_COUNT: info->i = 4; break; |
| 414 | |
| 415 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 416 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(exidy_floppy); break; |
| 417 | |
| 418 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 419 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 420 | |
| 421 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | MACHINE_START( exidyd ) |
| 426 | { |
| 427 | // serial_timer = timer_alloc(machine, exidy_serial_timer_callback, NULL); |
| 428 | cassette_timer = timer_alloc(machine, exidy_cassette_tc, NULL); |
| 429 | } |
| 430 | |
| 431 | MACHINE_START( exidy ) |
| 432 | { |
| 433 | MACHINE_START_CALL( exidyd ); |
| 434 | } |
| 435 | |
| 436 | MACHINE_RESET( exidyd ) |
| 437 | { |
| 438 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 439 | |
| 440 | /* Initialize cassette interface */ |
| 441 | cass_data.output.length = 0; |
| 442 | cass_data.output.level = 1; |
| 443 | cass_data.input.length = 0; |
| 444 | cass_data.input.bit = 1; |
| 445 | |
| 446 | exidy_ay31015 = devtag_get_device(machine, "ay_3_1015"); |
| 447 | |
| 448 | exidy_fe_w(space, 0, 0); |
| 449 | |
| 450 | timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, exidy_reset); |
| 451 | memory_set_bank(machine, 1, 1); |
| 452 | } |
| 453 | |
| 454 | MACHINE_RESET( exidy ) |
| 455 | { |
| 456 | floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |
| 457 | MACHINE_RESET_CALL( exidyd ); |
| 458 | } |
src/mess/drivers/bw12.c
| r5284 | r5285 | |
| 1 | | /***************************************************************************
|
| 2 | |
|
| 3 | | Bondwell 12/14
|
| 4 | | |
| 5 | | 12/05/2009 Skeleton driver.
|
| 6 | | |
| 7 | | - Z80A CPU 4MHz
|
| 8 | | - 64KB RAM (BW 12), 128KB RAM (BW 14)
|
| 9 | | - 4KB ROM System
|
| 10 | | - NEC765A Floppy controller
|
| 11 | | - 2 x 5.25" Floppy drives 48 tpi SSDD (BW 12), DSDD (BW 14)
|
| 12 | | - MC6845 Video controller
|
| 13 | | - 2KB RAM Video buffer
|
| 14 | | - 4KB ROM Character set
|
| 15 | | - Z80SIO Serial interface
|
| 16 | | - MC6821 Parallel interface
|
| 17 | | - I8253 Counter-timer |
| 18 | | - MC1408 8-bit DAC sound
|
| 19 | | - KB3600 PRO (AY-5-3600 PRO) Keyboard controller
|
| 20 | | |
| 21 | | http://www.eld.leidenuniv.nl/~moene/Home/sitemap/
|
| 22 | | http://www.baltissen.org/newhtm/schemas.htm
|
| 23 | | |
| 24 | | ****************************************************************************/
|
| 25 | | |
| 26 | | #include "driver.h"
|
| 27 | | #include "includes/bw12.h"
|
| 28 | | #include "cpu/z80/z80.h"
|
| 29 | | #include "devices/basicdsk.h"
|
| 30 | | #include "machine/6821pia.h"
|
| 31 | | #include "machine/ctronics.h"
|
| 32 | | #include "machine/nec765.h"
|
| 33 | | #include "machine/pit8253.h"
|
| 34 | | #include "machine/rescap.h"
|
| 35 | | #include "machine/z80sio.h"
|
| 36 | | #include "machine/kb3600.h"
|
| 37 | | #include "video/mc6845.h"
|
| 38 | | #include "sound/dac.h"
|
| 39 | | |
| 40 | | /*
|
| 41 | | |
| 42 | | TODO:
|
| 43 | | |
| 44 | | - Osborne 1 DD disk format
|
| 45 | | - floppy motor off timer
|
| 46 | | |
| 47 | | */
|
| 48 | | |
| 49 | | INLINE const device_config *get_floppy_image(running_machine *machine, int drive)
|
| 50 | | {
|
| 51 | | return image_from_devtype_and_index(machine, IO_FLOPPY, drive);
|
| 52 | | }
|
| 53 | | |
| 54 | | static void bw12_bankswitch(running_machine *machine)
|
| 55 | | {
|
| 56 | | bw12_state *state = machine->driver_data;
|
| 57 | | |
| 58 | | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
|
| 59 | | |
| 60 | | switch (state->bank)
|
| 61 | | {
|
| 62 | | case 0: /* ROM */
|
| 63 | | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_UNMAP);
|
| 64 | | break;
|
| 65 | | |
| 66 | | case 1: /* BK0 */
|
| 67 | | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_BANK(1));
|
| 68 | | break;
|
| 69 | | |
| 70 | | case 2: /* BK1 */
|
| 71 | | case 3: /* BK2 */
|
| 72 | | if (mess_ram_size > 64*1024)
|
| 73 | | {
|
| 74 | | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_BANK(1));
|
| 75 | | }
|
| 76 | | else
|
| 77 | | {
|
| 78 | | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
|
| 79 | | }
|
| 80 | | break;
|
| 81 | | }
|
| 82 | | |
| 83 | | memory_set_bank(machine, 1, state->bank);
|
| 84 | | }
|
| 85 | | |
| 86 | | static TIMER_CALLBACK( floppy_motor_off_tick )
|
| 87 | | {
|
| 88 | | bw12_state *state = machine->driver_data;
|
| 89 | | |
| 90 | | floppy_drive_set_motor_state(get_floppy_image(machine, 0), 0);
|
| 91 | | floppy_drive_set_motor_state(get_floppy_image(machine, 1), 0);
|
| 92 | | floppy_drive_set_ready_state(get_floppy_image(machine, 0), 0, 0);
|
| 93 | | floppy_drive_set_ready_state(get_floppy_image(machine, 1), 0, 0);
|
| 94 | | |
| 95 | | state->motor_on = 0;
|
| 96 | | }
|
| 97 | | |
| 98 | | static void bw12_set_floppy_motor_off_timer(running_machine *machine)
|
| 99 | | {
|
| 100 | | bw12_state *state = machine->driver_data;
|
| 101 | | |
| 102 | | if (state->motor0 || state->motor1)
|
| 103 | | {
|
| 104 | | state->motor_on = 1;
|
| 105 | | timer_enable(state->floppy_motor_off_timer, 0);
|
| 106 | | }
|
| 107 | | else
|
| 108 | | {
|
| 109 | | /* trigger floppy motor off NE556 timer */
|
| 110 | | /*
|
| 111 | | |
| 112 | | R18 = RES_K(100)
|
| 113 | | C11 = CAP_U(4.7)
|
| 114 | | |
| 115 | | */
|
| 116 | | timer_adjust_oneshot(state->floppy_motor_off_timer, attotime_zero, 0);
|
| 117 | | }
|
| 118 | | }
|
| 119 | | |
| 120 | | static void ls259_w(running_machine *machine, int address, int data)
|
| 121 | | {
|
| 122 | | bw12_state *state = machine->driver_data;
|
| 123 | | |
| 124 | | switch (address)
|
| 125 | | {
|
| 126 | | case 0: /* LS138 A0 */
|
| 127 | | state->bank = (state->bank & 0x02) | data;
|
| 128 | | bw12_bankswitch(machine);
|
| 129 | | break;
|
| 130 | | |
| 131 | | case 1: /* LS138 A1 */
|
| 132 | | state->bank = (data << 1) | (state->bank & 0x01);
|
| 133 | | bw12_bankswitch(machine);
|
| 134 | | break;
|
| 135 | | |
| 136 | | case 2: /* not connected */
|
| 137 | | break;
|
| 138 | | |
| 139 | | case 3: /* _INIT */
|
| 140 | | break;
|
| 141 | | |
| 142 | | case 4: /* CAP LOCK */
|
| 143 | | output_set_led_value(0, data);
|
| 144 | | break;
|
| 145 | | |
| 146 | | case 5: /* MOTOR 0 */
|
| 147 | | state->motor0 = data;
|
| 148 | | |
| 149 | | if (data)
|
| 150 | | {
|
| 151 | | floppy_drive_set_motor_state(get_floppy_image(machine, 0), 1);
|
| 152 | | floppy_drive_set_ready_state(get_floppy_image(machine, 0), 1, 0);
|
| 153 | | }
|
| 154 | | |
| 155 | | bw12_set_floppy_motor_off_timer(machine);
|
| 156 | | break;
|
| 157 | | |
| 158 | | case 6: /* MOTOR 1 */
|
| 159 | | state->motor1 = data;
|
| 160 | | |
| 161 | | if (data)
|
| 162 | | {
|
| 163 | | floppy_drive_set_motor_state(get_floppy_image(machine, 1), 1);
|
| 164 | | floppy_drive_set_ready_state(get_floppy_image(machine, 1), 1, 0);
|
| 165 | | }
|
| 166 | | |
| 167 | | bw12_set_floppy_motor_off_timer(machine);
|
| 168 | | break;
|
| 169 | | |
| 170 | | case 7: /* FDC TC */
|
| 171 | | nec765_set_tc_state(state->nec765, data);
|
| 172 | | break;
|
| 173 | | }
|
| 174 | | }
|
| 175 | | |
| 176 | | static WRITE8_HANDLER( bw12_ls259_w )
|
| 177 | | {
|
| 178 | | int d = BIT(offset, 0);
|
| 179 | | int a = (offset >> 1) & 0x07;
|
| 180 | | |
| 181 | | ls259_w(space->machine, a, d);
|
| 182 | | }
|
| 183 | | |
| 184 | | static READ8_HANDLER( bw12_ls259_r )
|
| 185 | | {
|
| 186 | | bw12_ls259_w(space, offset, 0);
|
| 187 | | |
| 188 | | return 0;
|
| 189 | | }
|
| 190 | | |
| 191 | | /* Memory Maps */
|
| 192 | | |
| 193 | | static ADDRESS_MAP_START( bw12_mem, ADDRESS_SPACE_PROGRAM, 8 )
|
| 194 | | AM_RANGE(0x0000, 0x7fff) AM_RAMBANK(1)
|
| 195 | | AM_RANGE(0x8000, 0xf7ff) AM_RAM
|
| 196 | | AM_RANGE(0xf800, 0xffff) AM_RAM AM_BASE_MEMBER(bw12_state, video_ram)
|
| 197 | | ADDRESS_MAP_END
|
| 198 | | |
| 199 | | static ADDRESS_MAP_START( bw12_io, ADDRESS_SPACE_IO, 8 )
|
| 200 | | ADDRESS_MAP_GLOBAL_MASK(0xff)
|
| 201 | | AM_RANGE(0x00, 0x0f) AM_READWRITE(bw12_ls259_r, bw12_ls259_w)
|
| 202 | | AM_RANGE(0x10, 0x10) AM_MIRROR(0x0e) AM_DEVWRITE(MC6845_TAG, mc6845_address_w)
|
| 203 | | AM_RANGE(0x11, 0x11) AM_MIRROR(0x0e) AM_DEVREADWRITE(MC6845_TAG, mc6845_register_r, mc6845_register_w)
|
| 204 | | AM_RANGE(0x20, 0x20) AM_MIRROR(0x0e) AM_DEVREAD(NEC765_TAG, nec765_status_r)
|
| 205 | | AM_RANGE(0x21, 0x21) AM_MIRROR(0x0e) AM_DEVREADWRITE(NEC765_TAG, nec765_data_r, nec765_data_w)
|
| 206 | | AM_RANGE(0x30, 0x33) AM_MIRROR(0x0c) AM_DEVREADWRITE(PIA6821_TAG, pia6821_r, pia6821_w)
|
| 207 | | AM_RANGE(0x40, 0x40) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w)
|
| 208 | | AM_RANGE(0x41, 0x41) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w)
|
| 209 | | AM_RANGE(0x42, 0x42) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w)
|
| 210 | | AM_RANGE(0x43, 0x43) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w)
|
| 211 | | AM_RANGE(0x50, 0x50) AM_MIRROR(0x0f) AM_DEVWRITE(MC1408_TAG, dac_w)
|
| 212 | | AM_RANGE(0x60, 0x63) AM_MIRROR(0x0c) AM_DEVREADWRITE(PIT8253_TAG, pit8253_r, pit8253_w)
|
| 213 | | ADDRESS_MAP_END
|
| 214 | | |
| 215 | | /* Input Ports */
|
| 216 | | |
| 217 | | static INPUT_PORTS_START( bw12 )
|
| 218 | | /*
|
| 219 | | |
| 220 | | KB3600 PRO2 Keyboard matrix
|
| 221 | | |
| 222 | | | Y0 | Y1 | Y2 | Y3 | Y4 | Y5 | Y6 | Y7 | Y8 | Y9 |
|
| 223 | | | | | | | | | | | | |
|
| 224 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 225 | | X0 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
|
| 226 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 227 | | X1 | U | I | O | P | Q | W | E | R | T | Y |
|
| 228 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 229 | | X2 | F15 | F16 | RET | N. | SP | LOCK| F11 | F12 | F13 | F14 |
|
| 230 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 231 | | X3 | F7 | F8 | F9 | F10 | F1 | F2 | F3 | F4 | F5 | F6 |
|
| 232 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 233 | | X4 | LEFT|RIGHT| N3 | BS | @ | | - | ] | UP | DOWN|
|
| 234 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 235 | | X5 | N9 | CL | N2 | LF | DEL | HT |ARROW| [ | N7 | N8 |
|
| 236 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 237 | | X6 | M | , | . | / | Z | X | C | V | B | N |
|
| 238 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 239 | | X7 | J | K | L | ; | A | S | D | F | G | H |
|
| 240 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 241 | | X8 | N6 | - | N1 | N0 | ESC | | : | NRET| N4 | N5 |
|
| 242 | | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
| 243 | | |
| 244 | | */
|
| 245 | | |
| 246 | | PORT_START("X0")
|
| 247 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
|
| 248 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
|
| 249 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
|
| 250 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('|')
|
| 251 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
|
| 252 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
|
| 253 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
|
| 254 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
|
| 255 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
|
| 256 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
|
| 257 | | |
| 258 | | PORT_START("X1")
|
| 259 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
|
| 260 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
|
| 261 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
|
| 262 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
|
| 263 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
|
| 264 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
|
| 265 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
|
| 266 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
|
| 267 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
|
| 268 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
|
| 269 | | |
| 270 | | PORT_START("X2")
|
| 271 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F15")
|
| 272 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F16")
|
| 273 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
|
| 274 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD)
|
| 275 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
| 276 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK)
|
| 277 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11") PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11))
|
| 278 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F12") PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12))
|
| 279 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13")
|
| 280 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F14")
|
| 281 | | |
| 282 | | PORT_START("X3")
|
| 283 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
|
| 284 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
|
| 285 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))
|
| 286 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))
|
| 287 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))
|
| 288 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
|
| 289 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
|
| 290 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
|
| 291 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
|
| 292 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
|
| 293 | | |
| 294 | | PORT_START("X4")
|
| 295 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
|
| 296 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x92") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
|
| 297 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 3") PORT_CODE(KEYCODE_3_PAD)
|
| 298 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("BS") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
|
| 299 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('@') PORT_CHAR('\\')
|
| 300 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 301 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') PORT_CHAR('=')
|
| 302 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
|
| 303 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
|
| 304 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x93") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
|
| 305 | | |
| 306 | | PORT_START("X5")
|
| 307 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 9") PORT_CODE(KEYCODE_9_PAD)
|
| 308 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CL")
|
| 309 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 2") PORT_CODE(KEYCODE_2_PAD)
|
| 310 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LF")
|
| 311 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("DEL") PORT_CODE(KEYCODE_DEL)
|
| 312 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HT")
|
| 313 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~')
|
| 314 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
|
| 315 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 7") PORT_CODE(KEYCODE_7_PAD)
|
| 316 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 8") PORT_CODE(KEYCODE_8_PAD)
|
| 317 | | |
| 318 | | PORT_START("X6")
|
| 319 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
|
| 320 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
|
| 321 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
|
| 322 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
|
| 323 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
|
| 324 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
|
| 325 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
|
| 326 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
|
| 327 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
|
| 328 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
|
| 329 | | |
| 330 | | PORT_START("X7")
|
| 331 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
|
| 332 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
|
| 333 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
|
| 334 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
|
| 335 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
|
| 336 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
|
| 337 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
|
| 338 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
|
| 339 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
|
| 340 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
|
| 341 | | |
| 342 | | PORT_START("X8")
|
| 343 | | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 6") PORT_CODE(KEYCODE_6_PAD)
|
| 344 | | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
|
| 345 | | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 1") PORT_CODE(KEYCODE_1_PAD)
|
| 346 | | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 0") PORT_CODE(KEYCODE_0_PAD)
|
| 347 | | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC)
|
| 348 | | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_UNUSED )
|
| 349 | | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
|
| 350 | | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad RET") PORT_CODE(KEYCODE_ENTER_PAD)
|
| 351 | | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 4") PORT_CODE(KEYCODE_4_PAD)
|
| 352 | | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 5") PORT_CODE(KEYCODE_5_PAD)
|
| 353 | | |
| 354 | | PORT_START("MODIFIERS")
|
| 355 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
| 356 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL))
|
| 357 | | INPUT_PORTS_END
|
| 358 | | |
| 359 | | /* Video */
|
| 360 | | |
| 361 | | static MC6845_UPDATE_ROW( bw12_update_row )
|
| 362 | | {
|
| 363 | | bw12_state *state = device->machine->driver_data;
|
| 364 | | |
| 365 | | int column, bit;
|
| 366 | | |
| 367 | | for (column = 0; column < x_count; column++)
|
| 368 | | {
|
| 369 | | UINT8 code = state->video_ram[((ma + column) & BW12_VIDEORAM_MASK)];
|
| 370 | | UINT16 addr = code << 4 | (ra & 0x0f);
|
| 371 | | UINT8 data = state->char_rom[addr & BW12_CHARROM_MASK];
|
| 372 | | |
| 373 | | if (column == cursor_x)
|
| 374 | | {
|
| 375 | | data = 0xff;
|
| 376 | | }
|
| 377 | | |
| 378 | | for (bit = 0; bit < 8; bit++)
|
| 379 | | {
|
| 380 | | int x = (column * 8) + bit;
|
| 381 | | int color = BIT(data, 7);
|
| 382 | | |
| 383 | | *BITMAP_ADDR16(bitmap, y, x) = color;
|
| 384 | | |
| 385 | | data <<= 1;
|
| 386 | | }
|
| 387 | | }
|
| 388 | | }
|
| 389 | | |
| 390 | | static const mc6845_interface bw12_mc6845_interface =
|
| 391 | | {
|
| 392 | | SCREEN_TAG,
|
| 393 | | 8,
|
| 394 | | NULL,
|
| 395 | | bw12_update_row,
|
| 396 | | NULL,
|
| 397 | | DEVCB_NULL,
|
| 398 | | DEVCB_NULL,
|
| 399 | | DEVCB_NULL,
|
| 400 | | DEVCB_NULL,
|
| 401 | | NULL
|
| 402 | | };
|
| 403 | | |
| 404 | | static VIDEO_START( bw12 )
|
| 405 | | {
|
| 406 | | bw12_state *state = machine->driver_data;
|
| 407 | | |
| 408 | | /* find devices */
|
| 409 | | state->mc6845 = devtag_get_device(machine, MC6845_TAG);
|
| 410 | | |
| 411 | | /* find memory regions */
|
| 412 | | state->char_rom = memory_region(machine, "chargen");
|
| 413 | | }
|
| 414 | | |
| 415 | | static VIDEO_UPDATE( bw12 )
|
| 416 | | {
|
| 417 | | bw12_state *state = screen->machine->driver_data;
|
| 418 | | |
| 419 | | mc6845_update(state->mc6845, bitmap, cliprect);
|
| 420 | | |
| 421 | | return 0;
|
| 422 | | }
|
| 423 | | |
| 424 | | /* NEC765 Interface */
|
| 425 | | |
| 426 | | static NEC765_INTERRUPT( bw12_nec765_interrupt )
|
| 427 | | {
|
| 428 | | bw12_state *driver_state = device->machine->driver_data;
|
| 429 | | |
| 430 | | driver_state->fdcint = state;
|
| 431 | | }
|
| 432 | | |
| 433 | | static NEC765_GET_IMAGE( bw12_nec765_get_image )
|
| 434 | | {
|
| 435 | | switch (floppy_index)
|
| 436 | | {
|
| 437 | | case 1: /* drive A */
|
| 438 | | return get_floppy_image(device->machine, 0);
|
| 439 | | |
| 440 | | case 2: /* drive B */
|
| 441 | | return get_floppy_image(device->machine, 1);
|
| 442 | | |
| 443 | | default:
|
| 444 | | return NULL;
|
| 445 | | }
|
| 446 | | }
|
| 447 | | |
| 448 | | static const struct nec765_interface bw12_nec765_interface =
|
| 449 | | {
|
| 450 | | bw12_nec765_interrupt, /* interrupt */
|
| 451 | | NULL, /* DMA request */
|
| 452 | | bw12_nec765_get_image, /* image lookup */
|
| 453 | | NEC765_RDY_PIN_CONNECTED /* ready pin */
|
| 454 | | };
|
| 455 | | |
| 456 | | /* PIA6821 Interface */
|
| 457 | | |
| 458 | | static WRITE_LINE_DEVICE_HANDLER( bw12_interrupt )
|
| 459 | | {
|
| 460 | | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, state);
|
| 461 | | }
|
| 462 | | |
| 463 | | static READ8_DEVICE_HANDLER( bw12_pia6821_pa_r )
|
| 464 | | {
|
| 465 | | /*
|
| 466 | | |
| 467 | | bit description
|
| 468 | | |
| 469 | | PA0 Input from Centronics BUSY status
|
| 470 | | PA1 Input from Centronics ERROR status
|
| 471 | | PA2 Input from Centronics PAPER OUT status
|
| 472 | | PA3 Input from FDC MOTOR
|
| 473 | | PA4 Input from PIT OUT2
|
| 474 | | PA5 Input from keyboard strobe
|
| 475 | | PA6 Input from keyboard serial data
|
| 476 | | PA7 Input from FDC interrupt
|
| 477 | | |
| 478 | | */
|
| 479 | |
|
| 480 | | bw12_state *state = device->machine->driver_data;
|
| 481 | |
|
| 482 | | UINT8 data = 0;
|
| 483 | | |
| 484 | | data |= centronics_busy_r(state->centronics);
|
| 485 | | data |= (centronics_fault_r(state->centronics) << 1);
|
| 486 | | data |= (centronics_pe_r(state->centronics) << 2);
|
| 487 | | data |= (state->motor_on << 3);
|
| 488 | | data |= (state->pit_out2 << 4);
|
| 489 | | data |= (state->key_stb << 5);
|
| 490 | | data |= (state->key_sin << 6);
|
| 491 | | data |= (state->fdcint << 7);
|
| 492 | | |
| 493 | | return data;
|
| 494 | | }
|
| 495 | | |
| 496 | | static READ_LINE_DEVICE_HANDLER( bw12_pia6821_ca1_r )
|
| 497 | | {
|
| 498 | | bw12_state *state = device->machine->driver_data;
|
| 499 | | |
| 500 | | return centronics_ack_r(state->centronics);
|
| 501 | | }
|
| 502 | | |
| 503 | | static WRITE_LINE_DEVICE_HANDLER( bw12_pia6821_ca2_w )
|
| 504 | | {
|
| 505 | | bw12_state *driver_state = device->machine->driver_data;
|
| 506 | | |
| 507 | | centronics_strobe_w(driver_state->centronics, state);
|
| 508 | | }
|
| 509 | | |
| 510 | | static READ_LINE_DEVICE_HANDLER( bw12_pia6821_cb1_r )
|
| 511 | | {
|
| 512 | | bw12_state *state = device->machine->driver_data;
|
| 513 | | |
| 514 | | return state->key_stb;
|
| 515 | | }
|
| 516 | | |
| 517 | | static WRITE_LINE_DEVICE_HANDLER( bw12_pia6821_cb2_w )
|
| 518 | | {
|
| 519 | | bw12_state *driver_state = device->machine->driver_data;
|
| 520 | | |
| 521 | | if (state)
|
| 522 | | {
|
| 523 | | /* keyboard shift clock */
|
| 524 | | driver_state->key_shift++;
|
| 525 | | |
| 526 | | if (driver_state->key_shift < 10)
|
| 527 | | {
|
| 528 | | driver_state->key_sin = driver_state->key_data[driver_state->key_shift];
|
| 529 | | }
|
| 530 | | }
|
| 531 | | }
|
| 532 | | |
| 533 | | static const pia6821_interface bw12_pia_config =
|
| 534 | | {
|
| 535 | | DEVCB_HANDLER(bw12_pia6821_pa_r), /* port A input */
|
| 536 | | DEVCB_NULL, /* port B input */
|
| 537 | | DEVCB_LINE(bw12_pia6821_ca1_r), /* CA1 input */
|
| 538 | | DEVCB_LINE(bw12_pia6821_cb1_r), /* CB1 input */
|
| 539 | | DEVCB_NULL, /* CA2 input */
|
| 540 | | DEVCB_NULL, /* CB2 input */
|
| 541 | | DEVCB_NULL, /* port A output */
|
| 542 | | DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w), /* port B output */
|
| 543 | | DEVCB_LINE(bw12_pia6821_ca2_w), /* CA2 output */
|
| 544 | | DEVCB_LINE(bw12_pia6821_cb2_w), /* CB2 output */
|
| 545 | | DEVCB_LINE(bw12_interrupt), /* IRQA output */
|
| 546 | | DEVCB_LINE(bw12_interrupt) /* IRQB output */
|
| 547 | | };
|
| 548 | | |
| 549 | | /* Centronics Interface */
|
| 550 | | |
| 551 | | static const centronics_interface bw12_centronics_intf =
|
| 552 | | {
|
| 553 | | 0, /* is IBM PC? */
|
| 554 | | DEVCB_DEVICE_HANDLER(PIA6821_TAG, pia6821_ca1_w), /* ACK output */
|
| 555 | | DEVCB_NULL, /* BUSY output */
|
| 556 | | DEVCB_NULL /* NOT BUSY output */
|
| 557 | | };
|
| 558 | | |
| 559 | | /* Z80-SIO/0 Interface */
|
| 560 | | |
| 561 | | static const z80sio_interface bw12_z80sio_intf =
|
| 562 | | {
|
| 563 | | bw12_interrupt, /* interrupt handler */
|
| 564 | | 0, /* DTR changed handler */
|
| 565 | | 0, /* RTS changed handler */
|
| 566 | | 0, /* BREAK changed handler */
|
| 567 | | 0, /* transmit handler - which channel is this for? */
|
| 568 | | 0 /* receive handler - which channel is this for? */
|
| 569 | | };
|
| 570 | | |
| 571 | | /* PIT8253 Interface */
|
| 572 | | |
| 573 | | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out0_w )
|
| 574 | | {
|
| 575 | | /* Z80-SIO TxCA, RxCA */
|
| 576 | | }
|
| 577 | | |
| 578 | | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out1_w )
|
| 579 | | {
|
| 580 | | /* Z80-SIO RxTxCB */
|
| 581 | | }
|
| 582 | | |
| 583 | | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out2_w )
|
| 584 | | {
|
| 585 | | bw12_state *driver_state = device->machine->driver_data;
|
| 586 | | |
| 587 | | /* PIA6821 PA4 */
|
| 588 | | driver_state->pit_out2 = state;
|
| 589 | | }
|
| 590 | | |
| 591 | | static const struct pit8253_config bw12_pit8253_intf =
|
| 592 | | {
|
| 593 | | {
|
| 594 | | {
|
| 595 | | XTAL_1_8432MHz,
|
| 596 | | bw12_pit8253_out0_w,
|
| 597 | | },
|
| 598 | | {
|
| 599 | | XTAL_1_8432MHz,
|
| 600 | | bw12_pit8253_out1_w,
|
| 601 | | },
|
| 602 | | {
|
| 603 | | XTAL_1_8432MHz,
|
| 604 | | bw12_pit8253_out2_w,
|
| 605 | | }
|
| 606 | | }
|
| 607 | | };
|
| 608 | | |
| 609 | | /* AY-5-3600-PRO-002 Interface */
|
| 610 | | |
| 611 | | static AY3600_Y_READ( bw2_ay3600_y_r )
|
| 612 | | {
|
| 613 | | UINT16 data = 0;
|
| 614 | | |
| 615 | | switch (x)
|
| 616 | | {
|
| 617 | | case 0: data = input_port_read(device->machine, "X0"); break;
|
| 618 | | case 1: data = input_port_read(device->machine, "X1"); break;
|
| 619 | | case 2: data = input_port_read(device->machine, "X2"); break;
|
| 620 | | case 3: data = input_port_read(device->machine, "X3"); break;
|
| 621 | | case 4: data = input_port_read(device->machine, "X4"); break;
|
| 622 | | case 5: data = input_port_read(device->machine, "X5"); break;
|
| 623 | | case 6: data = input_port_read(device->machine, "X6"); break;
|
| 624 | | case 7: data = input_port_read(device->machine, "X7"); break;
|
| 625 | | case 8: data = input_port_read(device->machine, "X8"); break;
|
| 626 | | }
|
| 627 | | |
| 628 | | return data;
|
| 629 | | }
|
| 630 | | |
| 631 | | static READ_LINE_DEVICE_HANDLER( bw2_ay3600_shift_r )
|
| 632 | | {
|
| 633 | | return BIT(input_port_read(device->machine, "MODIFIERS"), 0);
|
| 634 | | }
|
| 635 | | |
| 636 | | static READ_LINE_DEVICE_HANDLER( bw2_ay3600_control_r )
|
| 637 | | {
|
| 638 | | return BIT(input_port_read(device->machine, "MODIFIERS"), 1);
|
| 639 | | }
|
| 640 | | |
| 641 | | static WRITE_LINE_DEVICE_HANDLER( bw2_ay3600_data_ready_w )
|
| 642 | | {
|
| 643 | | bw12_state *driver_state = device->machine->driver_data;
|
| 644 | | |
| 645 | | driver_state->key_stb = state;
|
| 646 | | |
| 647 | | pia6821_cb1_w(driver_state->pia6821, 0, state);
|
| 648 | | |
| 649 | | if (state)
|
| 650 | | {
|
| 651 | | UINT16 data = ay3600_b_r(device);
|
| 652 | | |
| 653 | | driver_state->key_data[0] = BIT(data, 6);
|
| 654 | | driver_state->key_data[1] = BIT(data, 3);
|
| 655 | | driver_state->key_data[2] = BIT(data, 1);
|
| 656 | | driver_state->key_data[3] = BIT(data, 0);
|
| 657 | | driver_state->key_data[4] = BIT(data, 2);
|
| 658 | | driver_state->key_data[5] = BIT(data, 4);
|
| 659 | | driver_state->key_data[6] = BIT(data, 5);
|
| 660 | | driver_state->key_data[7] = BIT(data, 7);
|
| 661 | | driver_state->key_data[8] = BIT(data, 8);
|
| 662 | | |
| 663 | | driver_state->key_shift = 0;
|
| 664 | | driver_state->key_sin = driver_state->key_data[driver_state->key_shift];
|
| 665 | | }
|
| 666 | | }
|
| 667 | | |
| 668 | | static AY3600_INTERFACE( bw12_ay3600_intf )
|
| 669 | | {
|
| 670 | | bw2_ay3600_y_r, /* Y input */
|
| 671 | | DEVCB_LINE(bw2_ay3600_shift_r), /* shift */
|
| 672 | | DEVCB_LINE(bw2_ay3600_control_r), /* control */
|
| 673 | | DEVCB_LINE(bw2_ay3600_data_ready_w), /* data ready */
|
| 674 | | DEVCB_NULL /* any key down */
|
| 675 | | };
|
| 676 | | |
| 677 | | /* Machine Initialization */
|
| 678 | | |
| 679 | | static MACHINE_START( bw12 )
|
| 680 | | {
|
| 681 | | bw12_state *state = machine->driver_data;
|
| 682 | | |
| 683 | | /* find devices */
|
| 684 | | state->pia6821 = devtag_get_device(machine, PIA6821_TAG);
|
| 685 | | state->nec765 = devtag_get_device(machine, NEC765_TAG);
|
| 686 | | state->centronics = devtag_get_device(machine, CENTRONICS_TAG);
|
| 687 | | |
| 688 | | /* allocate floppy motor off timer */
|
| 689 | | state->floppy_motor_off_timer = timer_alloc(machine, floppy_motor_off_tick, NULL);
|
| 690 | |
|
| 691 | | /* setup memory banking */
|
| 692 | | memory_configure_bank(machine, 1, 0, 1, memory_region(machine, Z80_TAG), 0);
|
| 693 | | memory_configure_bank(machine, 1, 1, 1, mess_ram, 0);
|
| 694 | | memory_configure_bank(machine, 1, 2, 2, mess_ram + 0x10000, 0x8000);
|
| 695 | | |
| 696 | | /* register for state saving */
|
| 697 | | state_save_register_global(machine, state->bank);
|
| 698 | | state_save_register_global(machine, state->pit_out2);
|
| 699 | | state_save_register_global_array(machine, state->key_data);
|
| 700 | | state_save_register_global(machine, state->key_sin);
|
| 701 | | state_save_register_global(machine, state->key_stb);
|
| 702 | | state_save_register_global(machine, state->key_shift);
|
| 703 | | state_save_register_global(machine, state->fdcint);
|
| 704 | | state_save_register_global(machine, state->motor_on);
|
| 705 | | state_save_register_global(machine, state->motor0);
|
| 706 | | state_save_register_global(machine, state->motor1);
|
| 707 | | }
|
| 708 | | |
| 709 | | static MACHINE_RESET( bw12 )
|
| 710 | | {
|
| 711 | | int i;
|
| 712 | | |
| 713 | | for (i = 0; i < 8; i++)
|
| 714 | | {
|
| 715 | | ls259_w(machine, i, 0);
|
| 716 | | }
|
| 717 | | }
|
| 718 | | |
| 719 | | /* Machine Driver */
|
| 720 | | |
| 721 | | static MACHINE_DRIVER_START( bw12 )
|
| 722 | | MDRV_DRIVER_DATA(bw12_state)
|
| 723 | | |
| 724 | | /* basic machine hardware */
|
| 725 | | MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/4)
|
| 726 | | MDRV_CPU_PROGRAM_MAP(bw12_mem)
|
| 727 | | MDRV_CPU_IO_MAP(bw12_io)
|
| 728 | | |
| 729 | | MDRV_MACHINE_START(bw12)
|
| 730 | | MDRV_MACHINE_RESET(bw12)
|
| 731 | |
|
| 732 | | /* video hardware */
|
| 733 | | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
|
| 734 | | MDRV_SCREEN_REFRESH_RATE(60)
|
| 735 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
|
| 736 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
| 737 | | MDRV_SCREEN_SIZE(640, 200)
|
| 738 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1)
|
| 739 | | |
| 740 | | MDRV_PALETTE_LENGTH(2)
|
| 741 | | MDRV_PALETTE_INIT(monochrome_amber)
|
| 742 | | |
| 743 | | MDRV_VIDEO_START(bw12)
|
| 744 | | MDRV_VIDEO_UPDATE(bw12)
|
| 745 | | |
| 746 | | MDRV_MC6845_ADD(MC6845_TAG, MC6845, XTAL_16MHz/8, bw12_mc6845_interface)
|
| 747 | |
|
| 748 | | /* sound hardware */
|
| 749 | | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 750 | | |
| 751 | | MDRV_SOUND_ADD(MC1408_TAG, DAC, 0)
|
| 752 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
| 753 | | |
| 754 | | /* devices */
|
| 755 | | MDRV_NEC765A_ADD(NEC765_TAG, bw12_nec765_interface)
|
| 756 | | MDRV_PIA6821_ADD(PIA6821_TAG, bw12_pia_config)
|
| 757 | | MDRV_Z80SIO_ADD(Z80SIO_TAG, XTAL_16MHz/4, bw12_z80sio_intf) /* Z80-SIO/0 */
|
| 758 | | MDRV_PIT8253_ADD(PIT8253_TAG, bw12_pit8253_intf)
|
| 759 | | MDRV_AY3600PRO002_ADD(AY3600_TAG, bw12_ay3600_intf)
|
| 760 | | |
| 761 | | /* printer */
|
| 762 | | MDRV_CENTRONICS_ADD(CENTRONICS_TAG, bw12_centronics_intf)
|
| 763 | | MACHINE_DRIVER_END
|
| 764 | | |
| 765 | | /* ROMs */
|
| 766 | | |
| 767 | | ROM_START( bw12 )
|
| 768 | | ROM_REGION( 0x10000, Z80_TAG, 0 )
|
| 769 | | ROM_LOAD( "bw14boot.ic41", 0x0000, 0x1000, CRC(782fe341) SHA1(eefe5ad6b1ef77a1caf0af743b74de5fa1c4c19d) )
|
| 770 | | |
| 771 | | ROM_REGION(0x1000, "chargen", 0)
|
| 772 | | ROM_LOAD( "bw14char.ic1", 0x0000, 0x1000, CRC(f9dd68b5) SHA1(50132b759a6d84c22c387c39c0f57535cd380411) )
|
| 773 | | ROM_END
|
| 774 | | |
| 775 | | #define rom_bw14 rom_bw12
|
| 776 | | |
| 777 | | /* System Configurations */
|
| 778 | | |
| 779 | | static DEVICE_IMAGE_LOAD( bw12_floppy )
|
| 780 | | {
|
| 781 | | if (image_has_been_created(image))
|
| 782 | | {
|
| 783 | | return INIT_FAIL;
|
| 784 | | }
|
| 785 | | |
| 786 | | if (DEVICE_IMAGE_LOAD_NAME(basicdsk_floppy)(image) == INIT_PASS)
|
| 787 | | {
|
| 788 | | switch (image_length(image))
|
| 789 | | {
|
| 790 | | case 40*1*18*256: /* 180KB BW 12 SSDD */
|
| 791 | | basicdsk_set_geometry(image, 40, 1, 18, 256, 0, 0, FALSE);
|
| 792 | | break;
|
| 793 | | |
| 794 | | case 40*2*18*256: /* 360KB BW 14 DSDD */
|
| 795 | | basicdsk_set_geometry(image, 40, 2, 18, 256, 0, 0, FALSE);
|
| 796 | | break;
|
| 797 | | |
| 798 | | case 40*1*17*256: /* SVI-328 SSDD */
|
| 799 | | basicdsk_set_geometry(image, 40, 1, 17, 256, 0, 0, FALSE);
|
| 800 | | break;
|
| 801 | | |
| 802 | | case 40*2*17*256: /* SVI-328 DSDD */
|
| 803 | | basicdsk_set_geometry(image, 40, 2, 17, 256, 0, 0, FALSE);
|
| 804 | | break;
|
| 805 | | |
| 806 | | case 40*1*10*512: /* Kaypro II SSDD */
|
| 807 | | basicdsk_set_geometry(image, 40, 1, 10, 512, 0, 0, FALSE);
|
| 808 | | break;
|
| 809 | | |
| 810 | | default:
|
| 811 | | return INIT_FAIL;
|
| 812 | | }
|
| 813 | | |
| 814 | | return INIT_PASS;
|
| 815 | | }
|
| 816 | | |
| 817 | | return INIT_FAIL;
|
| 818 | | }
|
| 819 | | |
| 820 | | static void bw12_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
|
| 821 | | {
|
| 822 | | switch (state)
|
| 823 | | {
|
| 824 | | /* --- the following bits of info are returned as 64-bit signed integers --- */
|
| 825 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break;
|
| 826 | | |
| 827 | | /* --- the following bits of info are returned as pointers to data or functions --- */
|
| 828 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(bw12_floppy); break;
|
| 829 | | |
| 830 | | /* --- the following bits of info are returned as NULL-terminated strings --- */
|
| 831 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break;
|
| 832 | | |
| 833 | | default: legacybasicdsk_device_getinfo(devclass, state, info); break;
|
| 834 | | }
|
| 835 | | }
|
| 836 | | |
| 837 | | static SYSTEM_CONFIG_START( bw12 )
|
| 838 | | CONFIG_RAM_DEFAULT( 64 * 1024 )
|
| 839 | | CONFIG_DEVICE( bw12_floppy_getinfo )
|
| 840 | | SYSTEM_CONFIG_END
|
| 841 | | |
| 842 | | static SYSTEM_CONFIG_START( bw14 )
|
| 843 | | CONFIG_RAM_DEFAULT( 128 * 1024 )
|
| 844 | | CONFIG_DEVICE( bw12_floppy_getinfo )
|
| 845 | | SYSTEM_CONFIG_END
|
| 846 | | |
| 847 | | /* System Drivers */
|
| 848 | | |
| 849 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */
|
| 850 | | COMP( 1984, bw12, 0, 0, bw12, bw12, 0, bw12, "Bondwell International Limited", "Bondwell 12", GAME_SUPPORTS_SAVE )
|
| 851 | | COMP( 1984, bw14, bw12, 0, bw12, bw12, 0, bw14, "Bondwell International Limited", "Bondwell 14", GAME_SUPPORTS_SAVE )
|
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Bondwell 12/14 |
| 4 | |
| 5 | 12/05/2009 Skeleton driver. |
| 6 | |
| 7 | - Z80A CPU 4MHz |
| 8 | - 64KB RAM (BW 12), 128KB RAM (BW 14) |
| 9 | - 4KB ROM System |
| 10 | - NEC765A Floppy controller |
| 11 | - 2 x 5.25" Floppy drives 48 tpi SSDD (BW 12), DSDD (BW 14) |
| 12 | - MC6845 Video controller |
| 13 | - 2KB RAM Video buffer |
| 14 | - 4KB ROM Character set |
| 15 | - Z80SIO Serial interface |
| 16 | - MC6821 Parallel interface |
| 17 | - I8253 Counter-timer |
| 18 | - MC1408 8-bit DAC sound |
| 19 | - KB3600 PRO (AY-5-3600 PRO) Keyboard controller |
| 20 | |
| 21 | http://www.eld.leidenuniv.nl/~moene/Home/sitemap/ |
| 22 | http://www.baltissen.org/newhtm/schemas.htm |
| 23 | |
| 24 | ****************************************************************************/ |
| 25 | |
| 26 | #include "driver.h" |
| 27 | #include "includes/bw12.h" |
| 28 | #include "cpu/z80/z80.h" |
| 29 | #include "devices/basicdsk.h" |
| 30 | #include "machine/6821pia.h" |
| 31 | #include "machine/ctronics.h" |
| 32 | #include "machine/nec765.h" |
| 33 | #include "machine/pit8253.h" |
| 34 | #include "machine/rescap.h" |
| 35 | #include "machine/z80sio.h" |
| 36 | #include "machine/kb3600.h" |
| 37 | #include "video/mc6845.h" |
| 38 | #include "sound/dac.h" |
| 39 | |
| 40 | /* |
| 41 | |
| 42 | TODO: |
| 43 | |
| 44 | - Osborne 1 DD disk format |
| 45 | - floppy motor off timer |
| 46 | |
| 47 | */ |
| 48 | |
| 49 | INLINE const device_config *get_floppy_image(running_machine *machine, int drive) |
| 50 | { |
| 51 | return image_from_devtype_and_index(machine, IO_FLOPPY, drive); |
| 52 | } |
| 53 | |
| 54 | static void bw12_bankswitch(running_machine *machine) |
| 55 | { |
| 56 | bw12_state *state = machine->driver_data; |
| 57 | |
| 58 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 59 | |
| 60 | switch (state->bank) |
| 61 | { |
| 62 | case 0: /* ROM */ |
| 63 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_UNMAP); |
| 64 | break; |
| 65 | |
| 66 | case 1: /* BK0 */ |
| 67 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_BANK(1)); |
| 68 | break; |
| 69 | |
| 70 | case 2: /* BK1 */ |
| 71 | case 3: /* BK2 */ |
| 72 | if (mess_ram_size > 64*1024) |
| 73 | { |
| 74 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_BANK(1)); |
| 75 | } |
| 76 | else |
| 77 | { |
| 78 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 79 | } |
| 80 | break; |
| 81 | } |
| 82 | |
| 83 | memory_set_bank(machine, 1, state->bank); |
| 84 | } |
| 85 | |
| 86 | static TIMER_CALLBACK( floppy_motor_off_tick ) |
| 87 | { |
| 88 | bw12_state *state = machine->driver_data; |
| 89 | |
| 90 | floppy_drive_set_motor_state(get_floppy_image(machine, 0), 0); |
| 91 | floppy_drive_set_motor_state(get_floppy_image(machine, 1), 0); |
| 92 | floppy_drive_set_ready_state(get_floppy_image(machine, 0), 0, 0); |
| 93 | floppy_drive_set_ready_state(get_floppy_image(machine, 1), 0, 0); |
| 94 | |
| 95 | state->motor_on = 0; |
| 96 | } |
| 97 | |
| 98 | static void bw12_set_floppy_motor_off_timer(running_machine *machine) |
| 99 | { |
| 100 | bw12_state *state = machine->driver_data; |
| 101 | |
| 102 | if (state->motor0 || state->motor1) |
| 103 | { |
| 104 | state->motor_on = 1; |
| 105 | timer_enable(state->floppy_motor_off_timer, 0); |
| 106 | } |
| 107 | else |
| 108 | { |
| 109 | /* trigger floppy motor off NE556 timer */ |
| 110 | /* |
| 111 | |
| 112 | R18 = RES_K(100) |
| 113 | C11 = CAP_U(4.7) |
| 114 | |
| 115 | */ |
| 116 | timer_adjust_oneshot(state->floppy_motor_off_timer, attotime_zero, 0); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | static void ls259_w(running_machine *machine, int address, int data) |
| 121 | { |
| 122 | bw12_state *state = machine->driver_data; |
| 123 | |
| 124 | switch (address) |
| 125 | { |
| 126 | case 0: /* LS138 A0 */ |
| 127 | state->bank = (state->bank & 0x02) | data; |
| 128 | bw12_bankswitch(machine); |
| 129 | break; |
| 130 | |
| 131 | case 1: /* LS138 A1 */ |
| 132 | state->bank = (data << 1) | (state->bank & 0x01); |
| 133 | bw12_bankswitch(machine); |
| 134 | break; |
| 135 | |
| 136 | case 2: /* not connected */ |
| 137 | break; |
| 138 | |
| 139 | case 3: /* _INIT */ |
| 140 | break; |
| 141 | |
| 142 | case 4: /* CAP LOCK */ |
| 143 | output_set_led_value(0, data); |
| 144 | break; |
| 145 | |
| 146 | case 5: /* MOTOR 0 */ |
| 147 | state->motor0 = data; |
| 148 | |
| 149 | if (data) |
| 150 | { |
| 151 | floppy_drive_set_motor_state(get_floppy_image(machine, 0), 1); |
| 152 | floppy_drive_set_ready_state(get_floppy_image(machine, 0), 1, 0); |
| 153 | } |
| 154 | |
| 155 | bw12_set_floppy_motor_off_timer(machine); |
| 156 | break; |
| 157 | |
| 158 | case 6: /* MOTOR 1 */ |
| 159 | state->motor1 = data; |
| 160 | |
| 161 | if (data) |
| 162 | { |
| 163 | floppy_drive_set_motor_state(get_floppy_image(machine, 1), 1); |
| 164 | floppy_drive_set_ready_state(get_floppy_image(machine, 1), 1, 0); |
| 165 | } |
| 166 | |
| 167 | bw12_set_floppy_motor_off_timer(machine); |
| 168 | break; |
| 169 | |
| 170 | case 7: /* FDC TC */ |
| 171 | nec765_set_tc_state(state->nec765, data); |
| 172 | break; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | static WRITE8_HANDLER( bw12_ls259_w ) |
| 177 | { |
| 178 | int d = BIT(offset, 0); |
| 179 | int a = (offset >> 1) & 0x07; |
| 180 | |
| 181 | ls259_w(space->machine, a, d); |
| 182 | } |
| 183 | |
| 184 | static READ8_HANDLER( bw12_ls259_r ) |
| 185 | { |
| 186 | bw12_ls259_w(space, offset, 0); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /* Memory Maps */ |
| 192 | |
| 193 | static ADDRESS_MAP_START( bw12_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 194 | AM_RANGE(0x0000, 0x7fff) AM_RAMBANK(1) |
| 195 | AM_RANGE(0x8000, 0xf7ff) AM_RAM |
| 196 | AM_RANGE(0xf800, 0xffff) AM_RAM AM_BASE_MEMBER(bw12_state, video_ram) |
| 197 | ADDRESS_MAP_END |
| 198 | |
| 199 | static ADDRESS_MAP_START( bw12_io, ADDRESS_SPACE_IO, 8 ) |
| 200 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 201 | AM_RANGE(0x00, 0x0f) AM_READWRITE(bw12_ls259_r, bw12_ls259_w) |
| 202 | AM_RANGE(0x10, 0x10) AM_MIRROR(0x0e) AM_DEVWRITE(MC6845_TAG, mc6845_address_w) |
| 203 | AM_RANGE(0x11, 0x11) AM_MIRROR(0x0e) AM_DEVREADWRITE(MC6845_TAG, mc6845_register_r, mc6845_register_w) |
| 204 | AM_RANGE(0x20, 0x20) AM_MIRROR(0x0e) AM_DEVREAD(NEC765_TAG, nec765_status_r) |
| 205 | AM_RANGE(0x21, 0x21) AM_MIRROR(0x0e) AM_DEVREADWRITE(NEC765_TAG, nec765_data_r, nec765_data_w) |
| 206 | AM_RANGE(0x30, 0x33) AM_MIRROR(0x0c) AM_DEVREADWRITE(PIA6821_TAG, pia6821_r, pia6821_w) |
| 207 | AM_RANGE(0x40, 0x40) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w) |
| 208 | AM_RANGE(0x41, 0x41) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w) |
| 209 | AM_RANGE(0x42, 0x42) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w) |
| 210 | AM_RANGE(0x43, 0x43) AM_MIRROR(0x0c) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w) |
| 211 | AM_RANGE(0x50, 0x50) AM_MIRROR(0x0f) AM_DEVWRITE(MC1408_TAG, dac_w) |
| 212 | AM_RANGE(0x60, 0x63) AM_MIRROR(0x0c) AM_DEVREADWRITE(PIT8253_TAG, pit8253_r, pit8253_w) |
| 213 | ADDRESS_MAP_END |
| 214 | |
| 215 | /* Input Ports */ |
| 216 | |
| 217 | static INPUT_PORTS_START( bw12 ) |
| 218 | /* |
| 219 | |
| 220 | KB3600 PRO2 Keyboard matrix |
| 221 | |
| 222 | | Y0 | Y1 | Y2 | Y3 | Y4 | Y5 | Y6 | Y7 | Y8 | Y9 | |
| 223 | | | | | | | | | | | | |
| 224 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 225 | X0 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | |
| 226 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 227 | X1 | U | I | O | P | Q | W | E | R | T | Y | |
| 228 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 229 | X2 | F15 | F16 | RET | N. | SP | LOCK| F11 | F12 | F13 | F14 | |
| 230 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 231 | X3 | F7 | F8 | F9 | F10 | F1 | F2 | F3 | F4 | F5 | F6 | |
| 232 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 233 | X4 | LEFT|RIGHT| N3 | BS | @ | | - | ] | UP | DOWN| |
| 234 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 235 | X5 | N9 | CL | N2 | LF | DEL | HT |ARROW| [ | N7 | N8 | |
| 236 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 237 | X6 | M | , | . | / | Z | X | C | V | B | N | |
| 238 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 239 | X7 | J | K | L | ; | A | S | D | F | G | H | |
| 240 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 241 | X8 | N6 | - | N1 | N0 | ESC | | : | NRET| N4 | N5 | |
| 242 | ----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| |
| 243 | |
| 244 | */ |
| 245 | |
| 246 | PORT_START("X0") |
| 247 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 248 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 249 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 250 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('|') |
| 251 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 252 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 253 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 254 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 255 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 256 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 257 | |
| 258 | PORT_START("X1") |
| 259 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 260 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 261 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 262 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 263 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') |
| 264 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') |
| 265 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 266 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') |
| 267 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') |
| 268 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 269 | |
| 270 | PORT_START("X2") |
| 271 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F15") |
| 272 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F16") |
| 273 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 274 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD) |
| 275 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 276 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK) |
| 277 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11") PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11)) |
| 278 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F12") PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12)) |
| 279 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13") |
| 280 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F14") |
| 281 | |
| 282 | PORT_START("X3") |
| 283 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 284 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 285 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 286 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 287 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 288 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 289 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 290 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 291 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 292 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 293 | |
| 294 | PORT_START("X4") |
| 295 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 296 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x92") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 297 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 3") PORT_CODE(KEYCODE_3_PAD) |
| 298 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("BS") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 299 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('@') PORT_CHAR('\\') |
| 300 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 301 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') PORT_CHAR('=') |
| 302 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') |
| 303 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 304 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x93") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 305 | |
| 306 | PORT_START("X5") |
| 307 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 9") PORT_CODE(KEYCODE_9_PAD) |
| 308 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CL") |
| 309 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 2") PORT_CODE(KEYCODE_2_PAD) |
| 310 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LF") |
| 311 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("DEL") PORT_CODE(KEYCODE_DEL) |
| 312 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HT") |
| 313 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~') |
| 314 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') |
| 315 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 7") PORT_CODE(KEYCODE_7_PAD) |
| 316 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 8") PORT_CODE(KEYCODE_8_PAD) |
| 317 | |
| 318 | PORT_START("X6") |
| 319 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 320 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 321 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 322 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 323 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 324 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') |
| 325 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 326 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 327 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 328 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 329 | |
| 330 | PORT_START("X7") |
| 331 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 332 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 333 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') |
| 334 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') |
| 335 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 336 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 337 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 338 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') |
| 339 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') |
| 340 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') |
| 341 | |
| 342 | PORT_START("X8") |
| 343 | PORT_BIT( 0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 6") PORT_CODE(KEYCODE_6_PAD) |
| 344 | PORT_BIT( 0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') |
| 345 | PORT_BIT( 0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 1") PORT_CODE(KEYCODE_1_PAD) |
| 346 | PORT_BIT( 0x008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 0") PORT_CODE(KEYCODE_0_PAD) |
| 347 | PORT_BIT( 0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) |
| 348 | PORT_BIT( 0x020, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 349 | PORT_BIT( 0x040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') |
| 350 | PORT_BIT( 0x080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad RET") PORT_CODE(KEYCODE_ENTER_PAD) |
| 351 | PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 4") PORT_CODE(KEYCODE_4_PAD) |
| 352 | PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Keypad 5") PORT_CODE(KEYCODE_5_PAD) |
| 353 | |
| 354 | PORT_START("MODIFIERS") |
| 355 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 356 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) |
| 357 | INPUT_PORTS_END |
| 358 | |
| 359 | /* Video */ |
| 360 | |
| 361 | static MC6845_UPDATE_ROW( bw12_update_row ) |
| 362 | { |
| 363 | bw12_state *state = device->machine->driver_data; |
| 364 | |
| 365 | int column, bit; |
| 366 | |
| 367 | for (column = 0; column < x_count; column++) |
| 368 | { |
| 369 | UINT8 code = state->video_ram[((ma + column) & BW12_VIDEORAM_MASK)]; |
| 370 | UINT16 addr = code << 4 | (ra & 0x0f); |
| 371 | UINT8 data = state->char_rom[addr & BW12_CHARROM_MASK]; |
| 372 | |
| 373 | if (column == cursor_x) |
| 374 | { |
| 375 | data = 0xff; |
| 376 | } |
| 377 | |
| 378 | for (bit = 0; bit < 8; bit++) |
| 379 | { |
| 380 | int x = (column * 8) + bit; |
| 381 | int color = BIT(data, 7); |
| 382 | |
| 383 | *BITMAP_ADDR16(bitmap, y, x) = color; |
| 384 | |
| 385 | data <<= 1; |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | static const mc6845_interface bw12_mc6845_interface = |
| 391 | { |
| 392 | SCREEN_TAG, |
| 393 | 8, |
| 394 | NULL, |
| 395 | bw12_update_row, |
| 396 | NULL, |
| 397 | DEVCB_NULL, |
| 398 | DEVCB_NULL, |
| 399 | DEVCB_NULL, |
| 400 | DEVCB_NULL, |
| 401 | NULL |
| 402 | }; |
| 403 | |
| 404 | static VIDEO_START( bw12 ) |
| 405 | { |
| 406 | bw12_state *state = machine->driver_data; |
| 407 | |
| 408 | /* find devices */ |
| 409 | state->mc6845 = devtag_get_device(machine, MC6845_TAG); |
| 410 | |
| 411 | /* find memory regions */ |
| 412 | state->char_rom = memory_region(machine, "chargen"); |
| 413 | } |
| 414 | |
| 415 | static VIDEO_UPDATE( bw12 ) |
| 416 | { |
| 417 | bw12_state *state = screen->machine->driver_data; |
| 418 | |
| 419 | mc6845_update(state->mc6845, bitmap, cliprect); |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | /* NEC765 Interface */ |
| 425 | |
| 426 | static NEC765_INTERRUPT( bw12_nec765_interrupt ) |
| 427 | { |
| 428 | bw12_state *driver_state = device->machine->driver_data; |
| 429 | |
| 430 | driver_state->fdcint = state; |
| 431 | } |
| 432 | |
| 433 | static NEC765_GET_IMAGE( bw12_nec765_get_image ) |
| 434 | { |
| 435 | switch (floppy_index) |
| 436 | { |
| 437 | case 1: /* drive A */ |
| 438 | return get_floppy_image(device->machine, 0); |
| 439 | |
| 440 | case 2: /* drive B */ |
| 441 | return get_floppy_image(device->machine, 1); |
| 442 | |
| 443 | default: |
| 444 | return NULL; |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | static const struct nec765_interface bw12_nec765_interface = |
| 449 | { |
| 450 | bw12_nec765_interrupt, /* interrupt */ |
| 451 | NULL, /* DMA request */ |
| 452 | bw12_nec765_get_image, /* image lookup */ |
| 453 | NEC765_RDY_PIN_CONNECTED /* ready pin */ |
| 454 | }; |
| 455 | |
| 456 | /* PIA6821 Interface */ |
| 457 | |
| 458 | static WRITE_LINE_DEVICE_HANDLER( bw12_interrupt ) |
| 459 | { |
| 460 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_IRQ0, state); |
| 461 | } |
| 462 | |
| 463 | static READ8_DEVICE_HANDLER( bw12_pia6821_pa_r ) |
| 464 | { |
| 465 | /* |
| 466 | |
| 467 | bit description |
| 468 | |
| 469 | PA0 Input from Centronics BUSY status |
| 470 | PA1 Input from Centronics ERROR status |
| 471 | PA2 Input from Centronics PAPER OUT status |
| 472 | PA3 Input from FDC MOTOR |
| 473 | PA4 Input from PIT OUT2 |
| 474 | PA5 Input from keyboard strobe |
| 475 | PA6 Input from keyboard serial data |
| 476 | PA7 Input from FDC interrupt |
| 477 | |
| 478 | */ |
| 479 | |
| 480 | bw12_state *state = device->machine->driver_data; |
| 481 | |
| 482 | UINT8 data = 0; |
| 483 | |
| 484 | data |= centronics_busy_r(state->centronics); |
| 485 | data |= (centronics_fault_r(state->centronics) << 1); |
| 486 | data |= (centronics_pe_r(state->centronics) << 2); |
| 487 | data |= (state->motor_on << 3); |
| 488 | data |= (state->pit_out2 << 4); |
| 489 | data |= (state->key_stb << 5); |
| 490 | data |= (state->key_sin << 6); |
| 491 | data |= (state->fdcint << 7); |
| 492 | |
| 493 | return data; |
| 494 | } |
| 495 | |
| 496 | static READ_LINE_DEVICE_HANDLER( bw12_pia6821_ca1_r ) |
| 497 | { |
| 498 | bw12_state *state = device->machine->driver_data; |
| 499 | |
| 500 | return centronics_ack_r(state->centronics); |
| 501 | } |
| 502 | |
| 503 | static WRITE_LINE_DEVICE_HANDLER( bw12_pia6821_ca2_w ) |
| 504 | { |
| 505 | bw12_state *driver_state = device->machine->driver_data; |
| 506 | |
| 507 | centronics_strobe_w(driver_state->centronics, state); |
| 508 | } |
| 509 | |
| 510 | static READ_LINE_DEVICE_HANDLER( bw12_pia6821_cb1_r ) |
| 511 | { |
| 512 | bw12_state *state = device->machine->driver_data; |
| 513 | |
| 514 | return state->key_stb; |
| 515 | } |
| 516 | |
| 517 | static WRITE_LINE_DEVICE_HANDLER( bw12_pia6821_cb2_w ) |
| 518 | { |
| 519 | bw12_state *driver_state = device->machine->driver_data; |
| 520 | |
| 521 | if (state) |
| 522 | { |
| 523 | /* keyboard shift clock */ |
| 524 | driver_state->key_shift++; |
| 525 | |
| 526 | if (driver_state->key_shift < 10) |
| 527 | { |
| 528 | driver_state->key_sin = driver_state->key_data[driver_state->key_shift]; |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | static const pia6821_interface bw12_pia_config = |
| 534 | { |
| 535 | DEVCB_HANDLER(bw12_pia6821_pa_r), /* port A input */ |
| 536 | DEVCB_NULL, /* port B input */ |
| 537 | DEVCB_LINE(bw12_pia6821_ca1_r), /* CA1 input */ |
| 538 | DEVCB_LINE(bw12_pia6821_cb1_r), /* CB1 input */ |
| 539 | DEVCB_NULL, /* CA2 input */ |
| 540 | DEVCB_NULL, /* CB2 input */ |
| 541 | DEVCB_NULL, /* port A output */ |
| 542 | DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w), /* port B output */ |
| 543 | DEVCB_LINE(bw12_pia6821_ca2_w), /* CA2 output */ |
| 544 | DEVCB_LINE(bw12_pia6821_cb2_w), /* CB2 output */ |
| 545 | DEVCB_LINE(bw12_interrupt), /* IRQA output */ |
| 546 | DEVCB_LINE(bw12_interrupt) /* IRQB output */ |
| 547 | }; |
| 548 | |
| 549 | /* Centronics Interface */ |
| 550 | |
| 551 | static const centronics_interface bw12_centronics_intf = |
| 552 | { |
| 553 | 0, /* is IBM PC? */ |
| 554 | DEVCB_DEVICE_HANDLER(PIA6821_TAG, pia6821_ca1_w), /* ACK output */ |
| 555 | DEVCB_NULL, /* BUSY output */ |
| 556 | DEVCB_NULL /* NOT BUSY output */ |
| 557 | }; |
| 558 | |
| 559 | /* Z80-SIO/0 Interface */ |
| 560 | |
| 561 | static const z80sio_interface bw12_z80sio_intf = |
| 562 | { |
| 563 | bw12_interrupt, /* interrupt handler */ |
| 564 | 0, /* DTR changed handler */ |
| 565 | 0, /* RTS changed handler */ |
| 566 | 0, /* BREAK changed handler */ |
| 567 | 0, /* transmit handler - which channel is this for? */ |
| 568 | 0 /* receive handler - which channel is this for? */ |
| 569 | }; |
| 570 | |
| 571 | /* PIT8253 Interface */ |
| 572 | |
| 573 | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out0_w ) |
| 574 | { |
| 575 | /* Z80-SIO TxCA, RxCA */ |
| 576 | } |
| 577 | |
| 578 | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out1_w ) |
| 579 | { |
| 580 | /* Z80-SIO RxTxCB */ |
| 581 | } |
| 582 | |
| 583 | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out2_w ) |
| 584 | { |
| 585 | bw12_state *driver_state = device->machine->driver_data; |
| 586 | |
| 587 | /* PIA6821 PA4 */ |
| 588 | driver_state->pit_out2 = state; |
| 589 | } |
| 590 | |
| 591 | static const struct pit8253_config bw12_pit8253_intf = |
| 592 | { |
| 593 | { |
| 594 | { |
| 595 | XTAL_1_8432MHz, |
| 596 | bw12_pit8253_out0_w, |
| 597 | }, |
| 598 | { |
| 599 | XTAL_1_8432MHz, |
| 600 | bw12_pit8253_out1_w, |
| 601 | }, |
| 602 | { |
| 603 | XTAL_1_8432MHz, |
| 604 | bw12_pit8253_out2_w, |
| 605 | } |
| 606 | } |
| 607 | }; |
| 608 | |
| 609 | /* AY-5-3600-PRO-002 Interface */ |
| 610 | |
| 611 | static AY3600_Y_READ( bw2_ay3600_y_r ) |
| 612 | { |
| 613 | UINT16 data = 0; |
| 614 | |
| 615 | switch (x) |
| 616 | { |
| 617 | case 0: data = input_port_read(device->machine, "X0"); break; |
| 618 | case 1: data = input_port_read(device->machine, "X1"); break; |
| 619 | case 2: data = input_port_read(device->machine, "X2"); break; |
| 620 | case 3: data = input_port_read(device->machine, "X3"); break; |
| 621 | case 4: data = input_port_read(device->machine, "X4"); break; |
| 622 | case 5: data = input_port_read(device->machine, "X5"); break; |
| 623 | case 6: data = input_port_read(device->machine, "X6"); break; |
| 624 | case 7: data = input_port_read(device->machine, "X7"); break; |
| 625 | case 8: data = input_port_read(device->machine, "X8"); break; |
| 626 | } |
| 627 | |
| 628 | return data; |
| 629 | } |
| 630 | |
| 631 | static READ_LINE_DEVICE_HANDLER( bw2_ay3600_shift_r ) |
| 632 | { |
| 633 | return BIT(input_port_read(device->machine, "MODIFIERS"), 0); |
| 634 | } |
| 635 | |
| 636 | static READ_LINE_DEVICE_HANDLER( bw2_ay3600_control_r ) |
| 637 | { |
| 638 | return BIT(input_port_read(device->machine, "MODIFIERS"), 1); |
| 639 | } |
| 640 | |
| 641 | static WRITE_LINE_DEVICE_HANDLER( bw2_ay3600_data_ready_w ) |
| 642 | { |
| 643 | bw12_state *driver_state = device->machine->driver_data; |
| 644 | |
| 645 | driver_state->key_stb = state; |
| 646 | |
| 647 | pia6821_cb1_w(driver_state->pia6821, 0, state); |
| 648 | |
| 649 | if (state) |
| 650 | { |
| 651 | UINT16 data = ay3600_b_r(device); |
| 652 | |
| 653 | driver_state->key_data[0] = BIT(data, 6); |
| 654 | driver_state->key_data[1] = BIT(data, 3); |
| 655 | driver_state->key_data[2] = BIT(data, 1); |
| 656 | driver_state->key_data[3] = BIT(data, 0); |
| 657 | driver_state->key_data[4] = BIT(data, 2); |
| 658 | driver_state->key_data[5] = BIT(data, 4); |
| 659 | driver_state->key_data[6] = BIT(data, 5); |
| 660 | driver_state->key_data[7] = BIT(data, 7); |
| 661 | driver_state->key_data[8] = BIT(data, 8); |
| 662 | |
| 663 | driver_state->key_shift = 0; |
| 664 | driver_state->key_sin = driver_state->key_data[driver_state->key_shift]; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | static AY3600_INTERFACE( bw12_ay3600_intf ) |
| 669 | { |
| 670 | bw2_ay3600_y_r, /* Y input */ |
| 671 | DEVCB_LINE(bw2_ay3600_shift_r), /* shift */ |
| 672 | DEVCB_LINE(bw2_ay3600_control_r), /* control */ |
| 673 | DEVCB_LINE(bw2_ay3600_data_ready_w), /* data ready */ |
| 674 | DEVCB_NULL /* any key down */ |
| 675 | }; |
| 676 | |
| 677 | /* Machine Initialization */ |
| 678 | |
| 679 | static MACHINE_START( bw12 ) |
| 680 | { |
| 681 | bw12_state *state = machine->driver_data; |
| 682 | |
| 683 | /* find devices */ |
| 684 | state->pia6821 = devtag_get_device(machine, PIA6821_TAG); |
| 685 | state->nec765 = devtag_get_device(machine, NEC765_TAG); |
| 686 | state->centronics = devtag_get_device(machine, CENTRONICS_TAG); |
| 687 | |
| 688 | /* allocate floppy motor off timer */ |
| 689 | state->floppy_motor_off_timer = timer_alloc(machine, floppy_motor_off_tick, NULL); |
| 690 | |
| 691 | /* setup memory banking */ |
| 692 | memory_configure_bank(machine, 1, 0, 1, memory_region(machine, Z80_TAG), 0); |
| 693 | memory_configure_bank(machine, 1, 1, 1, mess_ram, 0); |
| 694 | memory_configure_bank(machine, 1, 2, 2, mess_ram + 0x10000, 0x8000); |
| 695 | |
| 696 | /* register for state saving */ |
| 697 | state_save_register_global(machine, state->bank); |
| 698 | state_save_register_global(machine, state->pit_out2); |
| 699 | state_save_register_global_array(machine, state->key_data); |
| 700 | state_save_register_global(machine, state->key_sin); |
| 701 | state_save_register_global(machine, state->key_stb); |
| 702 | state_save_register_global(machine, state->key_shift); |
| 703 | state_save_register_global(machine, state->fdcint); |
| 704 | state_save_register_global(machine, state->motor_on); |
| 705 | state_save_register_global(machine, state->motor0); |
| 706 | state_save_register_global(machine, state->motor1); |
| 707 | } |
| 708 | |
| 709 | static MACHINE_RESET( bw12 ) |
| 710 | { |
| 711 | int i; |
| 712 | |
| 713 | for (i = 0; i < 8; i++) |
| 714 | { |
| 715 | ls259_w(machine, i, 0); |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | /* Machine Driver */ |
| 720 | |
| 721 | static MACHINE_DRIVER_START( bw12 ) |
| 722 | MDRV_DRIVER_DATA(bw12_state) |
| 723 | |
| 724 | /* basic machine hardware */ |
| 725 | MDRV_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/4) |
| 726 | MDRV_CPU_PROGRAM_MAP(bw12_mem) |
| 727 | MDRV_CPU_IO_MAP(bw12_io) |
| 728 | |
| 729 | MDRV_MACHINE_START(bw12) |
| 730 | MDRV_MACHINE_RESET(bw12) |
| 731 | |
| 732 | /* video hardware */ |
| 733 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER) |
| 734 | MDRV_SCREEN_REFRESH_RATE(60) |
| 735 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 736 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 737 | MDRV_SCREEN_SIZE(640, 200) |
| 738 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1) |
| 739 | |
| 740 | MDRV_PALETTE_LENGTH(2) |
| 741 | MDRV_PALETTE_INIT(monochrome_amber) |
| 742 | |
| 743 | MDRV_VIDEO_START(bw12) |
| 744 | MDRV_VIDEO_UPDATE(bw12) |
| 745 | |
| 746 | MDRV_MC6845_ADD(MC6845_TAG, MC6845, XTAL_16MHz/8, bw12_mc6845_interface) |
| 747 | |
| 748 | /* sound hardware */ |
| 749 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 750 | |
| 751 | MDRV_SOUND_ADD(MC1408_TAG, DAC, 0) |
| 752 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 753 | |
| 754 | /* devices */ |
| 755 | MDRV_NEC765A_ADD(NEC765_TAG, bw12_nec765_interface) |
| 756 | MDRV_PIA6821_ADD(PIA6821_TAG, bw12_pia_config) |
| 757 | MDRV_Z80SIO_ADD(Z80SIO_TAG, XTAL_16MHz/4, bw12_z80sio_intf) /* Z80-SIO/0 */ |
| 758 | MDRV_PIT8253_ADD(PIT8253_TAG, bw12_pit8253_intf) |
| 759 | MDRV_AY3600PRO002_ADD(AY3600_TAG, bw12_ay3600_intf) |
| 760 | |
| 761 | /* printer */ |
| 762 | MDRV_CENTRONICS_ADD(CENTRONICS_TAG, bw12_centronics_intf) |
| 763 | MACHINE_DRIVER_END |
| 764 | |
| 765 | /* ROMs */ |
| 766 | |
| 767 | ROM_START( bw12 ) |
| 768 | ROM_REGION( 0x10000, Z80_TAG, 0 ) |
| 769 | ROM_LOAD( "bw14boot.ic41", 0x0000, 0x1000, CRC(782fe341) SHA1(eefe5ad6b1ef77a1caf0af743b74de5fa1c4c19d) ) |
| 770 | |
| 771 | ROM_REGION(0x1000, "chargen", 0) |
| 772 | ROM_LOAD( "bw14char.ic1", 0x0000, 0x1000, CRC(f9dd68b5) SHA1(50132b759a6d84c22c387c39c0f57535cd380411) ) |
| 773 | ROM_END |
| 774 | |
| 775 | #define rom_bw14 rom_bw12 |
| 776 | |
| 777 | /* System Configurations */ |
| 778 | |
| 779 | static DEVICE_IMAGE_LOAD( bw12_floppy ) |
| 780 | { |
| 781 | if (image_has_been_created(image)) |
| 782 | { |
| 783 | return INIT_FAIL; |
| 784 | } |
| 785 | |
| 786 | if (DEVICE_IMAGE_LOAD_NAME(basicdsk_floppy)(image) == INIT_PASS) |
| 787 | { |
| 788 | switch (image_length(image)) |
| 789 | { |
| 790 | case 40*1*18*256: /* 180KB BW 12 SSDD */ |
| 791 | basicdsk_set_geometry(image, 40, 1, 18, 256, 0, 0, FALSE); |
| 792 | break; |
| 793 | |
| 794 | case 40*2*18*256: /* 360KB BW 14 DSDD */ |
| 795 | basicdsk_set_geometry(image, 40, 2, 18, 256, 0, 0, FALSE); |
| 796 | break; |
| 797 | |
| 798 | case 40*1*17*256: /* SVI-328 SSDD */ |
| 799 | basicdsk_set_geometry(image, 40, 1, 17, 256, 0, 0, FALSE); |
| 800 | break; |
| 801 | |
| 802 | case 40*2*17*256: /* SVI-328 DSDD */ |
| 803 | basicdsk_set_geometry(image, 40, 2, 17, 256, 0, 0, FALSE); |
| 804 | break; |
| 805 | |
| 806 | case 40*1*10*512: /* Kaypro II SSDD */ |
| 807 | basicdsk_set_geometry(image, 40, 1, 10, 512, 0, 0, FALSE); |
| 808 | break; |
| 809 | |
| 810 | default: |
| 811 | return INIT_FAIL; |
| 812 | } |
| 813 | |
| 814 | return INIT_PASS; |
| 815 | } |
| 816 | |
| 817 | return INIT_FAIL; |
| 818 | } |
| 819 | |
| 820 | static void bw12_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 821 | { |
| 822 | switch (state) |
| 823 | { |
| 824 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 825 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 826 | |
| 827 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 828 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(bw12_floppy); break; |
| 829 | |
| 830 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 831 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 832 | |
| 833 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | static SYSTEM_CONFIG_START( bw12 ) |
| 838 | CONFIG_RAM_DEFAULT( 64 * 1024 ) |
| 839 | CONFIG_DEVICE( bw12_floppy_getinfo ) |
| 840 | SYSTEM_CONFIG_END |
| 841 | |
| 842 | static SYSTEM_CONFIG_START( bw14 ) |
| 843 | CONFIG_RAM_DEFAULT( 128 * 1024 ) |
| 844 | CONFIG_DEVICE( bw12_floppy_getinfo ) |
| 845 | SYSTEM_CONFIG_END |
| 846 | |
| 847 | /* System Drivers */ |
| 848 | |
| 849 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 850 | COMP( 1984, bw12, 0, 0, bw12, bw12, 0, bw12, "Bondwell International Limited", "Bondwell 12", GAME_SUPPORTS_SAVE ) |
| 851 | COMP( 1984, bw14, bw12, 0, bw12, bw12, 0, bw14, "Bondwell International Limited", "Bondwell 14", GAME_SUPPORTS_SAVE ) |