Previous 15994 Revisions Next

r1858 Saturday 8th March, 2008 at 11:35:58 UTC by Robbbert
[TRS80]Fixed 32-char mode, decoded LNW80 chr rom
[src/mess/drivers]trs80.c
[src/mess/includes]trs80.h
[src/mess/machine]trs80.c
[src/mess/video]trs80.c

src/mess/includes/trs80.h
r1857r1858
2626MACHINE_START( trs80 );
2727MACHINE_RESET( trs80 );
2828DRIVER_INIT( trs80 );
29DRIVER_INIT( lnw80 );
2930
3031WRITE8_HANDLER ( trs80_port_ff_w );
3132READ8_HANDLER ( trs80_port_ff_r );
src/mess/video/trs80.c
r1857r1858
55  Functions to emulate the video hardware of the TRS80.
66
77***************************************************************************/
8
98#include "driver.h"
109#include "includes/trs80.h"
1110
12
1311#define FW  TRS80_FONT_W
1412#define FH  TRS80_FONT_H
1513
1614/***************************************************************************
1715  Statics for this module
1816***************************************************************************/
19static tilemap *dblwidth_tilemap;
20static tilemap *normwidth_tilemap;
21static tilemap *current_tilemap;
22static const UINT8 *translate;
23static int color;
17static int width_store = 10;  // bodgy value to force an initial resize
2418
25/***************************************************************************
26  Tilemap callbacks
27***************************************************************************/
2819
29static 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
38static 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
4720/***************************************************************************
48  Start the video hardware emulation.
49***************************************************************************/
50VIDEO_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.
7122  Do NOT call osd_update_display() from this function,
7223  it will be called by the main emulation engine.
7324***************************************************************************/
7425VIDEO_UPDATE( trs80 )
7526{
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;
7731
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)
13433   {
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);
13736   }
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   }
14048   return 0;
14149}
14250
r1857r1858
14654
14755WRITE8_HANDLER( trs80_videoram_w )
14856{
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;
15558}
59
src/mess/machine/trs80.c
r1857r1858
323323   }
324324}
325325
326DRIVER_INIT( lnw80 )
327{
328//   UINT8 *FNT = memory_region(REGION_GFX1);
329//   int i, y;
330
331//   for( i = 0x000; i < 0x080; i++ )
332//   {
333//      /* copy eight lines from the character generator */
334//      for (y = 0; y < 8; y++)
335//         FNT[i*FH+y] = FNT[0x0800+i*8+y] << 3;
336//      /* wipe out the lower lines (no descenders!) */
337//      for (y = 8; y < FH; y++)
338//         FNT[i*FH+y] = 0;
339//   }
340//   /* setup the 2x3 chunky block graphics (two times 64 characters) */
341//   for( i = 0x080; i < 0x100; i++ )
342//   {
343//      UINT8 b0, b1, b2, b3, b4, b5;
344//      b0 = (i & 0x01) ? 0xe0 : 0x00;
345//      b1 = (i & 0x02) ? 0x1c : 0x00;
346//      b2 = (i & 0x04) ? 0xe0 : 0x00;
347//      b3 = (i & 0x08) ? 0x1c : 0x00;
348//      b4 = (i & 0x10) ? 0xe0 : 0x00;
349//      b5 = (i & 0x20) ? 0x1c : 0x00;
350//
351//      FNT[i*FH+ 0] = FNT[i*FH+ 1] = FNT[i*FH+ 2] = FNT[i*FH+ 3] = b0 | b1;
352//      FNT[i*FH+ 4] = FNT[i*FH+ 5] = FNT[i*FH+ 6] = FNT[i*FH+ 7] = b2 | b3;
353//      FNT[i*FH+ 8] = FNT[i*FH+ 9] = FNT[i*FH+10] = FNT[i*FH+11] = b4 | b5;
354//   }
355}
356
326357MACHINE_START( trs80 )
327358{
328359   wd17xx_init(WD_TYPE_179X,trs80_fdc_callback, NULL);
src/mess/drivers/trs80.c
r1857r1858
112112ADDRESS_MAP_END
113113
114114static ADDRESS_MAP_START( io_level1, ADDRESS_SPACE_IO, 8 )
115   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
115116   AM_RANGE(0xfe, 0xfe) AM_READ(trs80_port_xx_r)
116117   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_port_ff_r, trs80_port_ff_w)
117118ADDRESS_MAP_END
r1857r1858
134135ADDRESS_MAP_END
135136
136137static ADDRESS_MAP_START( io_model1, ADDRESS_SPACE_IO, 8 )
138   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
137139   AM_RANGE(0xfe, 0xfe) AM_READ(trs80_port_xx_r)
138140   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_port_ff_r, trs80_port_ff_w)
139141ADDRESS_MAP_END
r1857r1858
146148ADDRESS_MAP_END
147149
148150static ADDRESS_MAP_START( io_model3, ADDRESS_SPACE_IO, 8 )
151   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
149152   AM_RANGE(0xe0, 0xe3) AM_READWRITE(trs80_irq_status_r, trs80_irq_mask_w)
150153   AM_RANGE(0xe4, 0xe4)   AM_WRITE(trs80_motor_w)
151154   AM_RANGE(0xf0, 0xf0) AM_READWRITE(trs80_wd179x_r, wd17xx_command_w)
r1857r1858
296299   8*FH         /* every char takes FH bytes */
297300};
298301
299static const gfx_layout trs80_charlayout_double_width =
302static const gfx_layout lnw80_charlayout_normal_width =
300303{
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 },
307310   /* 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 */
311313};
312314
313315static 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 )
316317GFXDECODE_END
317318
319static GFXDECODE_START( lnw80 )
320   GFXDECODE_ENTRY( REGION_GFX1, 0, lnw80_charlayout_normal_width, 0, 1 )
321GFXDECODE_END
318322
323
319324static const INT16 speaker_levels[3] = {0.0*32767,0.46*32767,0.85*32767};
320325
321326static const struct Speaker_interface speaker_interface =
r1857r1858
348353   MDRV_PALETTE_LENGTH(2)
349354   MDRV_PALETTE_INIT(black_and_white)
350355
351   MDRV_VIDEO_START( trs80 )
352356   MDRV_VIDEO_UPDATE( trs80 )
353357
354358   /* sound hardware */
r1857r1858
366370   MDRV_CPU_IO_MAP( io_model1, 0 )
367371MACHINE_DRIVER_END
368372
373static MACHINE_DRIVER_START( lnw80 )
374   MDRV_IMPORT_FROM( model1 )
375   MDRV_GFXDECODE( lnw80 )
376MACHINE_DRIVER_END
369377
378
370379static MACHINE_DRIVER_START( model3 )
371380   MDRV_IMPORT_FROM( level1 )
372381   MDRV_CPU_MODIFY( "main" )
r1857r1858
432441   ROM_LOAD("lnw_c1.bin", 0x2800, 0x0800, CRC(ed547445) SHA1(20102de89a3ee4a65366bc2d62be94da984a156b))
433442
434443   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))
436445ROM_END
437446
438447ROM_START(trs80m3)
r1857r1858
526535COMP( 1978, trs80l2,  trs80,    0,      model1,   trs80, trs80,    trs8012,   "Tandy Radio Shack",  "TRS-80 Model I (Radio Shack Level II Basic)" , 0)
527536COMP( 1978, trs80l2a, trs80,    0,      model1,   trs80, trs80,    trs8012,   "Tandy Radio Shack",  "TRS-80 Model I (R/S L2 Basic)" , 0)
528537COMP( 1980, sys80,    trs80,    0,      model1,   trs80, trs80,    trs8012,   "EACA Computers Ltd.","System-80" , 0)
529COMP( 1981, lnw80,    trs80,    0,      model1,   trs80, trs80,    trs8012,   "LNW Research","LNW-80", GAME_NOT_WORKING )
538COMP( 1981, lnw80,    trs80,    0,      lnw80,    trs80, lnw80,    trs8012,   "LNW Research","LNW-80", 0 )
530539COMP( 1980, trs80m3,  trs80,    0,      model3,   trs80, trs80,    trs8012,   "Tandy Radio Shack",  "TRS-80 Model III", GAME_NOT_WORKING )
531540COMP( 1980, trs80m4,  trs80,    0,      model3,   trs80, trs80,    trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4", GAME_NOT_WORKING )
532541

Previous 15994 Revisions Next


© 1998-2018 The MESS Team