src/mess/video/newbrain.c
| r4172 | r4173 | |
| 3 | 3 | |
| 4 | 4 | static VIDEO_START( newbrain ) |
| 5 | 5 | { |
| 6 | | // newbrain_state *state = machine->driver_data; |
| 6 | newbrain_state *state = machine->driver_data; |
| 7 | 7 | |
| 8 | /* find memory regions */ |
| 9 | |
| 10 | state->char_rom = memory_region(machine, "chargen"); |
| 11 | |
| 8 | 12 | /* register for state saving */ |
| 9 | 13 | |
| 10 | 14 | // state_save_register_global(machine, state->); |
| 11 | 15 | } |
| 12 | 16 | |
| 17 | static void newbrain_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 18 | { |
| 19 | newbrain_state *state = machine->driver_data; |
| 20 | |
| 21 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 22 | |
| 23 | int y, sx; |
| 24 | int columns = (state->tvctl & NEWBRAIN_VIDEO_80L) ? 80 : 40; |
| 25 | int excess = (state->tvctl & NEWBRAIN_VIDEO_32_40) ? 24 : 4; |
| 26 | int ucr = (state->tvctl & NEWBRAIN_VIDEO_UCR) ? 1 : 0; |
| 27 | int fs = (state->tvctl & NEWBRAIN_VIDEO_FS) ? 1 : 0; |
| 28 | int rv = (state->tvctl & NEWBRAIN_VIDEO_RV) ? 1 : 0; |
| 29 | int gr = 0; |
| 30 | |
| 31 | UINT16 videoram_addr = state->tvram; |
| 32 | UINT8 rc = 0; |
| 33 | |
| 34 | for (y = 0; y < 250; y++) |
| 35 | { |
| 36 | int x = 0; |
| 37 | |
| 38 | for (sx = 0; sx < columns; sx++) |
| 39 | { |
| 40 | int bit; |
| 41 | |
| 42 | UINT8 videoram_data = memory_read_byte_8le(program, videoram_addr + sx); |
| 43 | UINT8 charrom_data; |
| 44 | |
| 45 | if (gr) |
| 46 | { |
| 47 | /* render video ram data */ |
| 48 | charrom_data = videoram_data; |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | /* render character rom data */ |
| 53 | UINT16 charrom_addr = (rc << 8) | ((BIT(videoram_data, 7) & fs) << 7) | (videoram_data & 0x7f); |
| 54 | charrom_data = state->char_rom[charrom_addr & 0xfff]; |
| 55 | |
| 56 | if ((videoram_data & 0x80) && !fs) |
| 57 | { |
| 58 | /* invert character */ |
| 59 | charrom_data ^= 0xff; |
| 60 | } |
| 61 | |
| 62 | if ((videoram_data & 0x60) && !ucr) |
| 63 | { |
| 64 | /* strip bit D0 */ |
| 65 | charrom_data &= 0xfe; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | for (bit = 0; bit < 8; bit++) |
| 70 | { |
| 71 | int color = BIT(charrom_data, 7) ^ rv; |
| 72 | |
| 73 | *BITMAP_ADDR16(bitmap, y, x++) = color; |
| 74 | |
| 75 | if (columns == 40) |
| 76 | { |
| 77 | *BITMAP_ADDR16(bitmap, y, x++) = color; |
| 78 | } |
| 79 | |
| 80 | charrom_data <<= 1; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /* increase row counter */ |
| 85 | rc++; |
| 86 | |
| 87 | if (rc == (ucr ? 8 : 10)) |
| 88 | { |
| 89 | /* reset row counter */ |
| 90 | rc = 0; |
| 91 | |
| 92 | videoram_addr += columns; |
| 93 | videoram_addr += excess; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 13 | 98 | static VIDEO_UPDATE( newbrain ) |
| 14 | 99 | { |
| 100 | newbrain_state *state = screen->machine->driver_data; |
| 101 | |
| 102 | if (state->enrg1 & NEWBRAIN_ENRG1_TVP) |
| 103 | { |
| 104 | newbrain_update(screen->machine, bitmap, cliprect); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | bitmap_fill(bitmap, cliprect, 0); |
| 109 | } |
| 110 | |
| 15 | 111 | return 0; |
| 16 | 112 | } |
| 17 | 113 | |
| r4172 | r4173 | |
| 22 | 118 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 23 | 119 | MDRV_SCREEN_REFRESH_RATE(50) |
| 24 | 120 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 25 | | MDRV_SCREEN_SIZE(640, 400) |
| 26 | | MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 399) |
| 121 | MDRV_SCREEN_SIZE(640, 250) |
| 122 | MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 249) |
| 27 | 123 | |
| 28 | 124 | MDRV_PALETTE_LENGTH(2) |
| 29 | 125 | MDRV_PALETTE_INIT(black_and_white) |
src/mess/includes/newbrain.h
| r4172 | r4173 | |
| 11 | 11 | #define FDC_Z80_TAG "416" |
| 12 | 12 | #define NEC765_TAG "418" |
| 13 | 13 | |
| 14 | | #define NEWBRAIN_VIDEO_RV 0x01 |
| 15 | | #define NEWBRAIN_VIDEO_FS 0x02 |
| 16 | | #define NEWBRAIN_VIDEO_32_40 0x04 |
| 17 | | #define NEWBRAIN_VIDEO_UCR 0x08 |
| 18 | | #define NEWBRAIN_VIDEO_80L 0x40 |
| 14 | #define NEWBRAIN_ENRG1_CLK 0x01 |
| 15 | #define NEWBRAIN_ENRG1_TVP 0x04 |
| 16 | #define NEWBRAIN_ENRG1_CTS 0x10 |
| 17 | #define NEWBRAIN_ENRG1_DO 0x20 |
| 18 | #define NEWBRAIN_ENRG1_PO 0x80 |
| 19 | #define NEWBRAIN_ENRG1_UST_BIT_1_MASK 0x30 |
| 20 | #define NEWBRAIN_ENRG1_UST_BIT_0_MASK 0xc0 |
| 19 | 21 | |
| 22 | #define NEWBRAIN_VIDEO_RV 0x01 |
| 23 | #define NEWBRAIN_VIDEO_FS 0x02 |
| 24 | #define NEWBRAIN_VIDEO_32_40 0x04 |
| 25 | #define NEWBRAIN_VIDEO_UCR 0x08 |
| 26 | #define NEWBRAIN_VIDEO_80L 0x40 |
| 27 | |
| 20 | 28 | typedef struct _newbrain_state newbrain_state; |
| 21 | 29 | struct _newbrain_state |
| 22 | 30 | { |
| r4172 | r4173 | |
| 58 | 66 | int tvcnsl; /* TV console required */ |
| 59 | 67 | int tvctl; /* TV control register */ |
| 60 | 68 | UINT16 tvram; /* TV start address */ |
| 69 | UINT8 *char_rom; /* character ROM */ |
| 61 | 70 | |
| 62 | 71 | /* user bus state */ |
| 63 | 72 | UINT8 user; |
src/mess/drivers/newbrain.c
| r4172 | r4173 | |
| 42 | 42 | |
| 43 | 43 | TODO: |
| 44 | 44 | |
| 45 | - make it boot! |
| 46 | - video excess |
| 45 | 47 | - escape key |
| 46 | 48 | - COP420 microbus |
| 47 | | - video |
| 48 | 49 | - tape |
| 49 | 50 | - layout for the 16-segment displays |
| 50 | 51 | |
| r4172 | r4173 | |
| 70 | 71 | |
| 71 | 72 | /* Enable/Status */ |
| 72 | 73 | |
| 73 | | #define NEWBRAIN_ENRG1_CLK 0x01 |
| 74 | | #define NEWBRAIN_ENRG1_TVP 0x04 |
| 75 | | #define NEWBRAIN_ENRG1_CTS 0x10 |
| 76 | | #define NEWBRAIN_ENRG1_DO 0x20 |
| 77 | | #define NEWBRAIN_ENRG1_PO 0x80 |
| 78 | | #define NEWBRAIN_ENRG1_UST_BIT_1_MASK 0x30 |
| 79 | | #define NEWBRAIN_ENRG1_UST_BIT_0_MASK 0xc0 |
| 80 | | |
| 81 | 74 | static WRITE8_HANDLER( enrg1_w ) |
| 82 | 75 | { |
| 83 | 76 | /* |
| r4172 | r4173 | |
| 487 | 480 | |
| 488 | 481 | /* Video */ |
| 489 | 482 | |
| 483 | static void newbrain_tvram_w(running_machine *machine, UINT8 data, int a6) |
| 484 | { |
| 485 | newbrain_state *state = machine->driver_data; |
| 486 | |
| 487 | /* latch video address counter bits A5-A0 */ |
| 488 | state->tvram = (state->tvctl & NEWBRAIN_VIDEO_80L) ? 0x04 : 0x02; |
| 489 | |
| 490 | /* latch video address counter bit A6 */ |
| 491 | state->tvram |= a6 << 6; |
| 492 | |
| 493 | /* latch data to video address counter bits A14-A7 */ |
| 494 | state->tvram = (data << 7); |
| 495 | } |
| 496 | |
| 490 | 497 | static READ8_HANDLER( tvl_r ) |
| 491 | 498 | { |
| 492 | | newbrain_state *state = space->machine->driver_data; |
| 499 | UINT8 data = 0xff; |
| 493 | 500 | |
| 494 | | if (offset) |
| 495 | | { |
| 496 | | state->tvram = 0xff; |
| 497 | | } |
| 498 | | else |
| 499 | | { |
| 500 | | state->tvram = 0x1ff; |
| 501 | | } |
| 501 | newbrain_tvram_w(space->machine, data, !offset); |
| 502 | 502 | |
| 503 | | return 0xff; |
| 503 | return data; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | static WRITE8_HANDLER( tvl_w ) |
| 507 | 507 | { |
| 508 | | newbrain_state *state = space->machine->driver_data; |
| 509 | | |
| 510 | | if (offset) |
| 511 | | { |
| 512 | | state->tvram = data; |
| 513 | | } |
| 514 | | else |
| 515 | | { |
| 516 | | state->tvram = 0x100 | data; |
| 517 | | } |
| 508 | newbrain_tvram_w(space->machine, data, !offset); |
| 518 | 509 | } |
| 519 | 510 | |
| 520 | 511 | static WRITE8_HANDLER( tvctl_w ) |
| r4172 | r4173 | |
| 1439 | 1430 | ROM_LOAD( "d417-2.rom", 0x0000, 0x2000, CRC(e8bda8b9) SHA1(c85a76a5ff7054f4ef4a472ce99ebaed1abd269c) ) |
| 1440 | 1431 | |
| 1441 | 1432 | ROM_REGION( 0x1000, "chargen", 0 ) |
| 1442 | | ROM_LOAD( "8248r7.453", 0x0000, 0x1000, NO_DUMP ) |
| 1433 | ROM_LOAD( "8248r7.453", 0x0000, 0x1000, BAD_DUMP CRC(46ecbc65) SHA1(3fe064d49a4de5e3b7383752e98ad35a674e26dd) ) |
| 1443 | 1434 | ROM_END |
| 1444 | 1435 | |
| 1445 | 1436 | ROM_START( newbraim ) |
| r4172 | r4173 | |
| 1451 | 1442 | ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP ) |
| 1452 | 1443 | |
| 1453 | 1444 | ROM_REGION( 0x1000, "chargen", 0 ) |
| 1454 | | ROM_LOAD( "8248r7.453", 0x0000, 0x1000, NO_DUMP ) |
| 1445 | ROM_LOAD( "8248r7.453", 0x0000, 0x1000, BAD_DUMP CRC(46ecbc65) SHA1(3fe064d49a4de5e3b7383752e98ad35a674e26dd) ) |
| 1455 | 1446 | ROM_END |
| 1456 | 1447 | |
| 1457 | 1448 | ROM_START( newbraia ) |
| r4172 | r4173 | |
| 1479 | 1470 | ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP ) |
| 1480 | 1471 | |
| 1481 | 1472 | ROM_REGION( 0x1000, "chargen", 0 ) |
| 1482 | | ROM_LOAD( "8248r7.453", 0x0000, 0x1000, NO_DUMP ) |
| 1473 | ROM_LOAD( "8248r7.453", 0x0000, 0x1000, BAD_DUMP CRC(46ecbc65) SHA1(3fe064d49a4de5e3b7383752e98ad35a674e26dd) ) |
| 1483 | 1474 | ROM_END |
| 1484 | 1475 | |
| 1485 | 1476 | #define rom_newbraiv rom_newbraia |