src/mess/video/mbee.c
| r7975 | r7976 | |
| 4 | 4 | video hardware |
| 5 | 5 | Juergen Buchmueller <pullmoll@t-online.de>, Dec 1999 |
| 6 | 6 | |
| 7 | Tests of keyboard. Start mbeeic. |
| 8 | |
| 9 | 1. Load ASTEROIDS PLUS, stay in attract mode, hold down spacebar, |
| 10 | it should only fire bullets. If it sometimes starts turning, |
| 11 | thrusting or using the shield, then there is a problem. |
| 12 | |
| 13 | 2. Load SCAVENGER and make sure it doesn't go to the next level |
| 14 | until you find the Exit. |
| 15 | |
| 16 | 3. At the Basic prompt, type in EDASM press enter. At the memory size |
| 17 | prompt press enter. Now, make sure the keyboard works properly. |
| 18 | |
| 19 | |
| 20 | The keyboard can be accessed either by using the transparent-mode |
| 21 | registers, or by monitoring the lightpen registers, or by monitoring |
| 22 | the lightpen strobe bit in the status register. |
| 23 | |
| 24 | Edasm is an example of the latter; it is therefore necessary to do a |
| 25 | keyboard scan whenever the status is read. |
| 26 | |
| 7 | 27 | ****************************************************************************/ |
| 8 | 28 | |
| 9 | 29 | #include "emu.h" |
| 10 | 30 | #include "includes/mbee.h" |
| 11 | 31 | |
| 32 | #define MBEE_WAIT_TIME 5000 |
| 12 | 33 | |
| 13 | 34 | typedef struct { // CRTC 6545 |
| 14 | 35 | UINT8 horizontal_total; |
| r7975 | r7976 | |
| 43 | 64 | static UINT8 m6545_color_bank = 0; |
| 44 | 65 | static UINT8 m6545_video_bank = 0; |
| 45 | 66 | static UINT8 mbee_pcg_color_latch = 0; |
| 67 | static int mbee_wait_time = 0; |
| 46 | 68 | |
| 47 | 69 | UINT8 *mbee_pcgram; |
| 48 | 70 | static UINT8 *colorram; |
| r7975 | r7976 | |
| 85 | 107 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 86 | 108 | |
| 87 | 109 | /* The direction keys are used by the pc85 menu. Do not know what uses the "insert" key. */ |
| 88 | | static int keyboard_matrix_r(running_machine *machine, int offs) |
| 110 | static void keyboard_matrix_r(running_machine *machine, int offs) |
| 89 | 111 | { |
| 90 | 112 | int port = (offs >> 7) & 7; |
| 91 | 113 | int bit = (offs >> 4) & 7; |
| r7975 | r7976 | |
| 125 | 147 | crt.lpen_lo = offs & 0xff; |
| 126 | 148 | crt.lpen_hi = (offs >> 8) & 0x03; |
| 127 | 149 | crt.lpen_strobe = 1; |
| 128 | | // logerror("mbee keyboard_matrix_r $%03X (port:%d bit:%d) = %d\n", offs, port, bit, data); |
| 129 | 150 | } |
| 130 | | return data; |
| 131 | 151 | } |
| 132 | 152 | |
| 133 | 153 | READ8_HANDLER ( mbee_color_bank_r ) |
| r7975 | r7976 | |
| 187 | 207 | |
| 188 | 208 | static void m6545_update_strobe(running_machine *machine, int param) |
| 189 | 209 | { |
| 190 | | /*int data = */keyboard_matrix_r(machine, param); |
| 210 | keyboard_matrix_r(machine, param); |
| 191 | 211 | crt.update_strobe = 1; |
| 192 | | // if( data ) |
| 193 | | // logerror("6545 update_strobe_cb $%04X = $%02X\n", param, data); |
| 194 | 212 | } |
| 195 | 213 | |
| 196 | 214 | READ8_HANDLER ( m6545_status_r ) |
| r7975 | r7976 | |
| 199 | 217 | const rectangle *visarea = video_screen_get_visible_area(screen); |
| 200 | 218 | |
| 201 | 219 | int data = 0, y = video_screen_get_vpos(space->machine->primary_screen); |
| 220 | int x = video_screen_get_hpos(space->machine->primary_screen); |
| 202 | 221 | |
| 222 | if (!mbee_wait_time) |
| 223 | m6545_update_strobe(space->machine, x+y*64); |
| 224 | |
| 203 | 225 | if( y < visarea->min_y || |
| 204 | 226 | y > visarea->max_y ) |
| 205 | 227 | data |= 0x20; /* vertical blanking */ |
| r7975 | r7976 | |
| 207 | 229 | data |= 0x40; /* lpen register full */ |
| 208 | 230 | if( crt.update_strobe ) |
| 209 | 231 | data |= 0x80; /* update strobe has occured */ |
| 210 | | // logerror("6545 status_r $%02X\n", data); |
| 232 | |
| 211 | 233 | return data; |
| 212 | 234 | } |
| 213 | 235 | |
| r7975 | r7976 | |
| 255 | 277 | data = crt.cursor_address_lo; |
| 256 | 278 | break; |
| 257 | 279 | case 16: |
| 258 | | // logerror("6545 lpen_hi_r $%02X (lpen:%d upd:%d)\n", crt.lpen_hi, crt.lpen_strobe, crt.update_strobe); |
| 259 | 280 | crt.lpen_strobe = 0; |
| 260 | 281 | crt.update_strobe = 0; |
| 261 | 282 | data = crt.lpen_hi; |
| 262 | 283 | break; |
| 263 | 284 | case 17: |
| 264 | | // logerror("6545 lpen_lo_r $%02X (lpen:%d upd:%d)\n", crt.lpen_lo, crt.lpen_strobe, crt.update_strobe); |
| 265 | 285 | crt.lpen_strobe = 0; |
| 266 | 286 | crt.update_strobe = 0; |
| 267 | 287 | data = crt.lpen_lo; |
| 268 | 288 | break; |
| 269 | 289 | case 18: |
| 270 | | // logerror("6545 transp_hi_r $%02X\n", crt.transp_hi); |
| 271 | 290 | data = crt.transp_hi; |
| 272 | 291 | break; |
| 273 | 292 | case 19: |
| 274 | | // logerror("6545 transp_lo_r $%02X\n", crt.transp_lo); |
| 275 | 293 | data = crt.transp_lo; |
| 276 | 294 | break; |
| 277 | 295 | case 31: |
| 278 | 296 | /* shared memory latch */ |
| 279 | 297 | addr = (crt.transp_hi << 8) | crt.transp_lo; |
| 280 | | // logerror("6545 transp_latch $%04X\n", addr); |
| 281 | 298 | m6545_update_strobe(space->machine, addr); |
| 282 | 299 | break; |
| 283 | 300 | default: |
| r7975 | r7976 | |
| 388 | 405 | case 18: |
| 389 | 406 | data &= 63; |
| 390 | 407 | crt.transp_hi = data; |
| 391 | | // logerror("6545 transp_hi_w $%02X\n", data); |
| 392 | 408 | break; |
| 393 | 409 | case 19: |
| 394 | 410 | crt.transp_lo = data; |
| 395 | | // logerror("6545 transp_lo_w $%02X\n", data); |
| 411 | mbee_wait_time = MBEE_WAIT_TIME; |
| 396 | 412 | break; |
| 397 | 413 | case 31: |
| 398 | 414 | /* shared memory latch */ |
| 399 | 415 | addr = (crt.transp_hi << 8) | crt.transp_lo; |
| 400 | | // logerror("6545 transp_latch $%04X\n", addr); |
| 401 | 416 | m6545_update_strobe(space->machine, addr); |
| 402 | 417 | break; |
| 403 | 418 | default: |
| r7975 | r7976 | |
| 497 | 512 | UINT8 inv=0; |
| 498 | 513 | mem = (x + screen_home) & 0x7ff; |
| 499 | 514 | chr = screen->machine->generic.videoram.u8[mem]; |
| 500 | | if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x); // actually happens for every scanline of every character, but imposes too much unnecessary overhead */ |
| 515 | |
| 516 | if ((x & 15) == 0) |
| 517 | { |
| 518 | if (mbee_wait_time) |
| 519 | mbee_wait_time--; |
| 520 | else |
| 521 | m6545_update_strobe(screen->machine, x); |
| 522 | } |
| 523 | |
| 501 | 524 | /* process cursor */ |
| 502 | 525 | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 503 | 526 | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| r7975 | r7976 | |
| 547 | 570 | mem = (x + screen_home) & 0x7ff; |
| 548 | 571 | chr = screen->machine->generic.videoram.u8[mem]; |
| 549 | 572 | col = colorram[mem] | colourm; // read a byte of colour |
| 550 | | if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x); // actually happens for every scanline of every character, but imposes too much unnecessary overhead */ |
| 551 | 573 | |
| 574 | if ((x & 15) == 0) |
| 575 | { |
| 576 | if (mbee_wait_time) |
| 577 | mbee_wait_time--; |
| 578 | else |
| 579 | m6545_update_strobe(screen->machine, x); |
| 580 | } |
| 581 | |
| 552 | 582 | /* process cursor */ |
| 553 | 583 | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 554 | 584 | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
src/mess/drivers/pegasus.c
| r7975 | r7976 | |
| 296 | 296 | static DEVICE_IMAGE_LOAD( pegasus_cart_3 ) |
| 297 | 297 | { |
| 298 | 298 | image_fread(image, memory_region(image->machine, "maincpu") + 0x2000, 0x1000); |
| 299 | pegasus_decrypt_rom( image->machine, 0x2000 ); |
| 300 | |
| 301 | return INIT_PASS; |
| 302 | } |
| 303 | |
| 304 | static DEVICE_IMAGE_LOAD( pegasus_cart_4 ) |
| 305 | { |
| 306 | image_fread(image, memory_region(image->machine, "maincpu") + 0xc000, 0x1000); |
| 299 | 307 | pegasus_decrypt_rom( image->machine, 0xc000 ); |
| 300 | 308 | |
| 301 | 309 | return INIT_PASS; |
| 302 | 310 | } |
| 303 | 311 | |
| 312 | static DEVICE_IMAGE_LOAD( pegasus_cart_5 ) |
| 313 | { |
| 314 | image_fread(image, memory_region(image->machine, "maincpu") + 0xd000, 0x1000); |
| 315 | pegasus_decrypt_rom( image->machine, 0xd000 ); |
| 316 | |
| 317 | return INIT_PASS; |
| 318 | } |
| 319 | |
| 304 | 320 | static MACHINE_START( pegasus ) |
| 305 | 321 | { |
| 306 | 322 | pegasus_cass = devtag_get_device(machine, "cassette"); |
| r7975 | r7976 | |
| 350 | 366 | MDRV_CARTSLOT_ADD("cart3") |
| 351 | 367 | MDRV_CARTSLOT_EXTENSION_LIST("bin") |
| 352 | 368 | MDRV_CARTSLOT_LOAD(pegasus_cart_3) |
| 369 | MDRV_CARTSLOT_ADD("cart4") |
| 370 | MDRV_CARTSLOT_EXTENSION_LIST("bin") |
| 371 | MDRV_CARTSLOT_LOAD(pegasus_cart_4) |
| 372 | MDRV_CARTSLOT_ADD("cart5") |
| 373 | MDRV_CARTSLOT_EXTENSION_LIST("bin") |
| 374 | MDRV_CARTSLOT_LOAD(pegasus_cart_5) |
| 353 | 375 | MDRV_CASSETTE_ADD( "cassette", pegasus_cassette_config ) |
| 354 | 376 | MACHINE_DRIVER_END |
| 355 | 377 | |