src/mess/video/trs80.c
| r1857 | r1858 | |
| 5 | 5 | Functions to emulate the video hardware of the TRS80. |
| 6 | 6 | |
| 7 | 7 | ***************************************************************************/ |
| 8 | | |
| 9 | 8 | #include "driver.h" |
| 10 | 9 | #include "includes/trs80.h" |
| 11 | 10 | |
| 12 | | |
| 13 | 11 | #define FW TRS80_FONT_W |
| 14 | 12 | #define FH TRS80_FONT_H |
| 15 | 13 | |
| 16 | 14 | /*************************************************************************** |
| 17 | 15 | Statics for this module |
| 18 | 16 | ***************************************************************************/ |
| 19 | | static tilemap *dblwidth_tilemap; |
| 20 | | static tilemap *normwidth_tilemap; |
| 21 | | static tilemap *current_tilemap; |
| 22 | | static const UINT8 *translate; |
| 23 | | static int color; |
| 17 | static int width_store = 10; // bodgy value to force an initial resize |
| 24 | 18 | |
| 25 | | /*************************************************************************** |
| 26 | | Tilemap callbacks |
| 27 | | ***************************************************************************/ |
| 28 | 19 | |
| 29 | | static TILE_GET_INFO(dblwidth_gettileinfo) |
| 30 | | { |
| 31 | | SET_TILE_INFO( |
| 32 | | 1, /* gfx */ |
| 33 | | translate[videoram[tile_index]], /* character */ |
| 34 | | color, /* color */ |
| 35 | | 0); /* flags */ |
| 36 | | } |
| 37 | | |
| 38 | | static TILE_GET_INFO(normwidth_gettileinfo) |
| 39 | | { |
| 40 | | SET_TILE_INFO( |
| 41 | | 0, /* gfx */ |
| 42 | | translate[videoram[tile_index]], /* character */ |
| 43 | | color, /* color */ |
| 44 | | 0); /* flags */ |
| 45 | | } |
| 46 | | |
| 47 | 20 | /*************************************************************************** |
| 48 | | Start the video hardware emulation. |
| 49 | | ***************************************************************************/ |
| 50 | | VIDEO_START( trs80 ) |
| 51 | | { |
| 52 | | dblwidth_tilemap = tilemap_create( |
| 53 | | dblwidth_gettileinfo, |
| 54 | | tilemap_scan_rows, |
| 55 | | FW * 2, FH, |
| 56 | | 64, videoram_size / 64); |
| 57 | | |
| 58 | | normwidth_tilemap = tilemap_create( |
| 59 | | normwidth_gettileinfo, |
| 60 | | tilemap_scan_rows, |
| 61 | | FW, FH, |
| 62 | | 64, videoram_size / 64); |
| 63 | | |
| 64 | | |
| 65 | | color = -1; |
| 66 | | current_tilemap = NULL; |
| 67 | | } |
| 68 | | |
| 69 | | /*************************************************************************** |
| 70 | | Draw the game screen in the given bitmap_t. |
| 21 | Draw the game screen in the given mame_bitmap. |
| 71 | 22 | Do NOT call osd_update_display() from this function, |
| 72 | 23 | it will be called by the main emulation engine. |
| 73 | 24 | ***************************************************************************/ |
| 74 | 25 | VIDEO_UPDATE( trs80 ) |
| 75 | 26 | { |
| 76 | | tilemap *new_tilemap; |
| 27 | int width = 64 - (trs80_port_ff & 8) * 4; |
| 28 | int skip = 3 - width / 32; |
| 29 | int i=0,x,y,chr; |
| 30 | int adj=readinputport(0)&0x40; |
| 77 | 31 | |
| 78 | | /* Special translation if video RAM with only 7 bits is present |
| 79 | | * I don't know if it's entirely correct, but it's close ;-) |
| 80 | | */ |
| 81 | | static const UINT8 translate_videoram[2][256] = { |
| 82 | | { |
| 83 | | 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, |
| 84 | | 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, |
| 85 | | 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
| 86 | | 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, |
| 87 | | 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, |
| 88 | | 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, |
| 89 | | 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, |
| 90 | | 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f, |
| 91 | | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, |
| 92 | | 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, |
| 93 | | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, |
| 94 | | 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, |
| 95 | | 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, |
| 96 | | 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, |
| 97 | | 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, |
| 98 | | 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff |
| 99 | | }, |
| 100 | | { |
| 101 | | 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, |
| 102 | | 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, |
| 103 | | 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, |
| 104 | | 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, |
| 105 | | 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, |
| 106 | | 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, |
| 107 | | 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, |
| 108 | | 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, |
| 109 | | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, |
| 110 | | 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, |
| 111 | | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, |
| 112 | | 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, |
| 113 | | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, |
| 114 | | 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, |
| 115 | | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, |
| 116 | | 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf} |
| 117 | | }; |
| 118 | | |
| 119 | | translate = translate_videoram[(input_port_0_r(0) & 0x40) ? 1 : 0]; |
| 120 | | |
| 121 | | if (readinputport(0) & 0x08) |
| 122 | | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); |
| 123 | | |
| 124 | | /* check for changed color settings */ |
| 125 | | if (color != (readinputport(0) & 3)) |
| 126 | | { |
| 127 | | color = readinputport(0) & 3; |
| 128 | | current_tilemap = NULL; |
| 129 | | } |
| 130 | | |
| 131 | | /* have we changed the tilemap? */ |
| 132 | | new_tilemap = (trs80_port_ff & 0x08) ? dblwidth_tilemap : normwidth_tilemap; |
| 133 | | if (current_tilemap != new_tilemap) |
| 32 | if (width != width_store) |
| 134 | 33 | { |
| 135 | | current_tilemap = new_tilemap; |
| 136 | | tilemap_mark_all_tiles_dirty(current_tilemap); |
| 34 | width_store = width; |
| 35 | video_screen_set_visarea(0, 0, width*FW-1, 0, 16*FH-1); |
| 137 | 36 | } |
| 138 | | |
| 139 | | tilemap_draw(bitmap, NULL, current_tilemap, 0, 0); |
| 37 | for (y = 0; y < 16; y++) |
| 38 | { |
| 39 | for (x = 0; x < 64; x+=skip) |
| 40 | { |
| 41 | i = y * 64 + x; |
| 42 | chr=videoram[i]; |
| 43 | if ((adj) && (chr < 32)) chr+=64; // 7-bit video handler |
| 44 | drawgfx( bitmap,machine->gfx[0],chr,0,0,0,x/skip*FW,y*FH, |
| 45 | &machine->screen[0].visarea,TRANSPARENCY_NONE,0); |
| 46 | } |
| 47 | } |
| 140 | 48 | return 0; |
| 141 | 49 | } |
| 142 | 50 | |
| r1857 | r1858 | |
| 146 | 54 | |
| 147 | 55 | WRITE8_HANDLER( trs80_videoram_w ) |
| 148 | 56 | { |
| 149 | | if (videoram[offset] != data) |
| 150 | | { |
| 151 | | videoram[offset] = data; |
| 152 | | if (current_tilemap) |
| 153 | | tilemap_mark_tile_dirty(current_tilemap, offset); |
| 154 | | } |
| 57 | videoram[offset] = data; |
| 155 | 58 | } |
| 59 | |
src/mess/drivers/trs80.c
| r1857 | r1858 | |
| 112 | 112 | ADDRESS_MAP_END |
| 113 | 113 | |
| 114 | 114 | static ADDRESS_MAP_START( io_level1, ADDRESS_SPACE_IO, 8 ) |
| 115 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 115 | 116 | AM_RANGE(0xfe, 0xfe) AM_READ(trs80_port_xx_r) |
| 116 | 117 | AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_port_ff_r, trs80_port_ff_w) |
| 117 | 118 | ADDRESS_MAP_END |
| r1857 | r1858 | |
| 134 | 135 | ADDRESS_MAP_END |
| 135 | 136 | |
| 136 | 137 | static ADDRESS_MAP_START( io_model1, ADDRESS_SPACE_IO, 8 ) |
| 138 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 137 | 139 | AM_RANGE(0xfe, 0xfe) AM_READ(trs80_port_xx_r) |
| 138 | 140 | AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_port_ff_r, trs80_port_ff_w) |
| 139 | 141 | ADDRESS_MAP_END |
| r1857 | r1858 | |
| 146 | 148 | ADDRESS_MAP_END |
| 147 | 149 | |
| 148 | 150 | static ADDRESS_MAP_START( io_model3, ADDRESS_SPACE_IO, 8 ) |
| 151 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 149 | 152 | AM_RANGE(0xe0, 0xe3) AM_READWRITE(trs80_irq_status_r, trs80_irq_mask_w) |
| 150 | 153 | AM_RANGE(0xe4, 0xe4) AM_WRITE(trs80_motor_w) |
| 151 | 154 | AM_RANGE(0xf0, 0xf0) AM_READWRITE(trs80_wd179x_r, wd17xx_command_w) |
| r1857 | r1858 | |
| 296 | 299 | 8*FH /* every char takes FH bytes */ |
| 297 | 300 | }; |
| 298 | 301 | |
| 299 | | static const gfx_layout trs80_charlayout_double_width = |
| 302 | static const gfx_layout lnw80_charlayout_normal_width = |
| 300 | 303 | { |
| 301 | | FW*2,FH, /* FW*2 x FH*3 characters */ |
| 302 | | 256, /* 256 characters */ |
| 303 | | 1, /* 1 bits per pixel */ |
| 304 | | { 0 }, /* no bitplanes; 1 bit per pixel */ |
| 305 | | /* x offsets double width: use each bit twice */ |
| 306 | | { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }, |
| 304 | 8, 8, /* 6 x 12 characters */ |
| 305 | 256, /* 256 characters */ |
| 306 | 1, /* 1 bits per pixel */ |
| 307 | { 0 }, /* no bitplanes; 1 bit per pixel */ |
| 308 | /* x offsets */ |
| 309 | { 5, 6, 1, 0, 2, 3, 4, 7 }, |
| 307 | 310 | /* y offsets */ |
| 308 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, |
| 309 | | 6*8, 7*8, 8*8, 9*8,10*8,11*8 }, |
| 310 | | 8*FH /* every char takes FH bytes */ |
| 311 | { 0*8, 0x200*8, 0x100*8, 0x300*8, 1*8, 0x201*8, 0x101*8, 0x301*8 }, |
| 312 | 2*8 /* every char takes FH bytes */ |
| 311 | 313 | }; |
| 312 | 314 | |
| 313 | 315 | static GFXDECODE_START( trs80 ) |
| 314 | | GFXDECODE_ENTRY( REGION_GFX1, 0, trs80_charlayout_normal_width, 0, 4 ) |
| 315 | | GFXDECODE_ENTRY( REGION_GFX1, 0, trs80_charlayout_double_width, 0, 4 ) |
| 316 | GFXDECODE_ENTRY( REGION_GFX1, 0, trs80_charlayout_normal_width, 0, 1 ) |
| 316 | 317 | GFXDECODE_END |
| 317 | 318 | |
| 319 | static GFXDECODE_START( lnw80 ) |
| 320 | GFXDECODE_ENTRY( REGION_GFX1, 0, lnw80_charlayout_normal_width, 0, 1 ) |
| 321 | GFXDECODE_END |
| 318 | 322 | |
| 323 | |
| 319 | 324 | static const INT16 speaker_levels[3] = {0.0*32767,0.46*32767,0.85*32767}; |
| 320 | 325 | |
| 321 | 326 | static const struct Speaker_interface speaker_interface = |
| r1857 | r1858 | |
| 348 | 353 | MDRV_PALETTE_LENGTH(2) |
| 349 | 354 | MDRV_PALETTE_INIT(black_and_white) |
| 350 | 355 | |
| 351 | | MDRV_VIDEO_START( trs80 ) |
| 352 | 356 | MDRV_VIDEO_UPDATE( trs80 ) |
| 353 | 357 | |
| 354 | 358 | /* sound hardware */ |
| r1857 | r1858 | |
| 366 | 370 | MDRV_CPU_IO_MAP( io_model1, 0 ) |
| 367 | 371 | MACHINE_DRIVER_END |
| 368 | 372 | |
| 373 | static MACHINE_DRIVER_START( lnw80 ) |
| 374 | MDRV_IMPORT_FROM( model1 ) |
| 375 | MDRV_GFXDECODE( lnw80 ) |
| 376 | MACHINE_DRIVER_END |
| 369 | 377 | |
| 378 | |
| 370 | 379 | static MACHINE_DRIVER_START( model3 ) |
| 371 | 380 | MDRV_IMPORT_FROM( level1 ) |
| 372 | 381 | MDRV_CPU_MODIFY( "main" ) |
| r1857 | r1858 | |
| 432 | 441 | ROM_LOAD("lnw_c1.bin", 0x2800, 0x0800, CRC(ed547445) SHA1(20102de89a3ee4a65366bc2d62be94da984a156b)) |
| 433 | 442 | |
| 434 | 443 | ROM_REGION(0x01000, REGION_GFX1,0) |
| 435 | | ROM_LOAD("lnw_chr.bin",0x0800, 0x0800, CRC(c89b27df) SHA1(be2a009a07e4378d070002a558705e9a0de59389)) |
| 444 | ROM_LOAD("lnw_chr.bin",0x0000, 0x0800, CRC(c89b27df) SHA1(be2a009a07e4378d070002a558705e9a0de59389)) |
| 436 | 445 | ROM_END |
| 437 | 446 | |
| 438 | 447 | ROM_START(trs80m3) |
| r1857 | r1858 | |
| 526 | 535 | COMP( 1978, trs80l2, trs80, 0, model1, trs80, trs80, trs8012, "Tandy Radio Shack", "TRS-80 Model I (Radio Shack Level II Basic)" , 0) |
| 527 | 536 | COMP( 1978, trs80l2a, trs80, 0, model1, trs80, trs80, trs8012, "Tandy Radio Shack", "TRS-80 Model I (R/S L2 Basic)" , 0) |
| 528 | 537 | COMP( 1980, sys80, trs80, 0, model1, trs80, trs80, trs8012, "EACA Computers Ltd.","System-80" , 0) |
| 529 | | COMP( 1981, lnw80, trs80, 0, model1, trs80, trs80, trs8012, "LNW Research","LNW-80", GAME_NOT_WORKING ) |
| 538 | COMP( 1981, lnw80, trs80, 0, lnw80, trs80, lnw80, trs8012, "LNW Research","LNW-80", 0 ) |
| 530 | 539 | COMP( 1980, trs80m3, trs80, 0, model3, trs80, trs80, trs8012, "Tandy Radio Shack", "TRS-80 Model III", GAME_NOT_WORKING ) |
| 531 | 540 | COMP( 1980, trs80m4, trs80, 0, model3, trs80, trs80, trs8012, "Tandy Radio Shack", "TRS-80 Model 4", GAME_NOT_WORKING ) |
| 532 | 541 | |