Previous 15994 Revisions Next

r4459 Sunday 5th April, 2009 at 10:02:30 UTC by Robbbert
[TRS80] WIP - lnw80 graphics modes
[src/mess/drivers]trs80.c
[src/mess/includes]trs80.h
[src/mess/machine]trs80.c
[src/mess/video]trs80.c

src/mess/video/trs80.c
r4458r4459
2020
2121static UINT16 start_address=0;
2222static UINT8 crtc_reg;
23static UINT8 trs80_size_store;
2324
2425WRITE8_HANDLER( trs80m4_88_w )
2526{
r4458r4459
4445}
4546
4647
48VIDEO_START( trs80 )
49{
50   trs80_size_store = 0xff;
51   trs80_mode &= 2;
52}
53
54
4755/* 7 or 8-bit video, 32/64 characters per line = trs80, trs80l2, sys80 */
4856VIDEO_UPDATE( trs80 )
4957{
5058   UINT8 y,ra,chr,gfx,gfxbit;
5159   UINT16 sy=0,ma=0,x;
5260   UINT8 *FNT = memory_region(screen->machine, "gfx1");
53   static UINT8 size_store=0xff;
54   static UINT8 cols=64,skip=1;
61   UINT8 cols = (trs80_mode & 1) ? 32 : 64;
62   UINT8 skip = (trs80_mode & 1) ? 2 : 1;
5563
56   if ((trs80_mode & 0x7f) != size_store)
64   if (trs80_mode != trs80_size_store)
5765   {
58      size_store = trs80_mode & 0x7f;
59      cols = (trs80_mode & 1) ? 32 : 64;
60      skip = (trs80_mode & 1) ? 2 : 1;
66      trs80_size_store = trs80_mode & 1;
6167      video_screen_set_visarea(screen, 0, cols*FW-1, 0, 16*FH-1);
6268   }
6369
r4458r4459
115121   UINT8 y,ra,chr,gfx,gfxbit;
116122   UINT16 sy=0,ma=0,x;
117123   UINT8 *FNT = memory_region(screen->machine, "gfx1");
118   static UINT8 size_store=0xff;
119   static UINT8 cols=64,rows=16,skip=1,s_cols,lines=12;
124   UINT8 skip=1;
125   UINT8 cols = (trs80_mode & 4) ? 80 : 64;
126   UINT8 rows = (trs80_mode & 4) ? 24 : 16;
127   UINT8 lines = (trs80_mode & 4) ? 10 : 12;
128   UINT8 s_cols = cols;
120129
121   if ((trs80_mode & 0x7f) != size_store)
130   if (trs80_mode & 1)
122131   {
123      size_store = trs80_mode & 0x7f;
124      s_cols = cols = (trs80_mode & 4) ? 80 : 64;
125      rows = (trs80_mode & 4) ? 24 : 16;
126      lines = (trs80_mode & 4) ? 10 : 12;
132      s_cols >>= 1;
133      skip = 2;
134   }
127135
128      if (trs80_mode & 1)
129      {
130         s_cols >>= 1;
131         skip = 2;
132      }
136   if ((trs80_mode & 0x7f) != trs80_size_store)
137   {
138      trs80_size_store = trs80_mode & 5;
133139      video_screen_set_visarea(screen, 0, s_cols*FW-1, 0, rows*lines-1);
134140   }
135141
r4458r4459
188194   UINT8 y,ra,chr,gfx,gfxbit;
189195   UINT16 sy=0,ma=0,x;
190196   UINT8 *FNT = memory_region(screen->machine, "gfx1");
191   static UINT8 size_store=0xff;
192   static UINT8 cols=64,skip=1;
197   UINT8 cols = (trs80_mode & 1) ? 32 : 64;
198   UINT8 skip = (trs80_mode & 1) ? 2 : 1;
193199
194   if ((trs80_mode & 0x7f) != size_store)
200   if (trs80_mode != trs80_size_store)
195201   {
196      size_store = trs80_mode & 0x7f;
197      cols = (trs80_mode & 1) ? 32 : 64;
198      skip = (trs80_mode & 1) ? 2 : 1;
202      trs80_size_store = trs80_mode & 1;
199203      video_screen_set_visarea(screen, 0, cols*FW-1, 0, 16*FH-1);
200204   }
201205
r4458r4459
247251VIDEO_UPDATE( lnw80 )
248252{
249253   const UINT16 rows[] = { 0, 0x200, 0x100, 0x300, 1, 0x201, 0x101, 0x301 };
250   UINT8 y,ra,chr,gfx,gfxbit,bg=7,fg=0;
251   UINT16 sy=0,ma=0,x;
254   UINT8 chr,gfx,gfxbit,bg=7,fg=0;
255   UINT16 sy=0,ma=0,x,y,ra;
252256   UINT8 *FNT = memory_region(screen->machine, "gfx1");
253   static UINT8 size_store=0xff;
254   static UINT8 cols=64;
255
257   UINT8 cols = (trs80_mode & 0x10) ? 80 : 64;
258   
256259   /* Although the OS can select 32-character mode, it is not supported by hardware */
257   if ((trs80_mode & 0x7f) != size_store)
260   if (trs80_mode != trs80_size_store)
258261   {
259      size_store = trs80_mode & 0x7f;
260      cols = (trs80_mode & 16) ? 80 : 64;
262      trs80_size_store = trs80_mode & 0x10;
261263      video_screen_set_visarea(screen, 0, cols*FW-1, 0, 16*FH-1);
262264   }
263265
r4458r4459
315317         break;
316318
317319      case 0x10:               // MODE 1
318#if 0   // not ready yet
319320         for (y = 0x40; y < 0x400; y+=0x40)
320321         {
321322            for (ra = 0x400; ra < 0x3000; ra+=0x400)
r4458r4459
326327               {
327328                  gfx = gfxram[ y | x | ra];     
328329                  /* Display 6 pixels in normal region */
330                  *p = ( gfx & 0x01 ) ? fg : bg; p++;
331                  *p = ( gfx & 0x02 ) ? fg : bg; p++;
329332                  *p = ( gfx & 0x04 ) ? fg : bg; p++;
330                  *p = ( gfx & 0x02 ) ? fg : bg; p++;
331                  *p = ( gfx & 0x40 ) ? fg : bg; p++;
332                  *p = ( gfx & 0x80 ) ? fg : bg; p++;
333                  *p = ( gfx & 0x08 ) ? fg : bg; p++;
334                  *p = ( gfx & 0x10 ) ? fg : bg; p++;
333335                  *p = ( gfx & 0x20 ) ? fg : bg; p++;
334                  *p = ( gfx & 0x08 ) ? fg : bg; p++;
335336               }
336337
337338               for (x = 0; x < 0x10; x++)
338339               {
339                  gfx = gfxram[ 0x3000 | x | ra & 0xc00 | (ra & 0x3000) >> 8];     
340                  gfx = gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)];     
340341                  /* Display 6 pixels in extended region */
342                  *p = ( gfx & 0x01 ) ? fg : bg; p++;
343                  *p = ( gfx & 0x02 ) ? fg : bg; p++;
341344                  *p = ( gfx & 0x04 ) ? fg : bg; p++;
342                  *p = ( gfx & 0x02 ) ? fg : bg; p++;
343                  *p = ( gfx & 0x40 ) ? fg : bg; p++;
344                  *p = ( gfx & 0x80 ) ? fg : bg; p++;
345                  *p = ( gfx & 0x08 ) ? fg : bg; p++;
346                  *p = ( gfx & 0x10 ) ? fg : bg; p++;
345347                  *p = ( gfx & 0x20 ) ? fg : bg; p++;
346                  *p = ( gfx & 0x08 ) ? fg : bg; p++;
347348               }
348349            }
349350         }
350#endif
351351         break;
352
352353      case 0x20:               // MODE 2
354         /* it seems the text video ram can have an effect in this mode,
355            not explained clearly, so not emulated */
356         for (y = 0x40; y < 0x400; y+=0x40)
357         {
358            for (ra = 0x400; ra < 0x3000; ra+=0x400)
359            {
360               UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
361
362               for (x = 0; x < 0x40; x++)
363               {
364                  gfx = gfxram[ y | x | ra];     
365                  /* Display 6 pixels in normal region */
366                  fg = (gfx & 0x38) >> 3;
367                  *p = fg; p++;
368                  *p = fg; p++;
369                  *p = fg; p++;
370                  fg = gfx & 0x07;
371                  *p = fg; p++;
372                  *p = fg; p++;
373                  *p = fg; p++;
374               }
375            }
376         }
353377         break;
378
354379      case 0x30:               // MODE 3
380         /* the manual does not explain at all how colour is determined
381            for the extended area. Further, the background colour
382            is not mentioned anywhere. Black is assumed. */
383         for (y = 0x40; y < 0x400; y+=0x40)
384         {
385            for (ra = 0x400; ra < 0x3000; ra+=0x400)
386            {
387               UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
388
389               for (x = 0; x < 0x40; x++)
390               {
391                  gfx = gfxram[ y | x | ra];
392                  fg = (videoram[ 0x3c00 | x | y ] & 0x38) >> 3;     
393                  /* Display 6 pixels in normal region */
394                  *p = ( gfx & 0x01 ) ? fg : bg; p++;
395                  *p = ( gfx & 0x02 ) ? fg : bg; p++;
396                  *p = ( gfx & 0x04 ) ? fg : bg; p++;
397                  fg = videoram[ 0x3c00 | x | y ] & 0x07;     
398                  *p = ( gfx & 0x08 ) ? fg : bg; p++;
399                  *p = ( gfx & 0x10 ) ? fg : bg; p++;
400                  *p = ( gfx & 0x20 ) ? fg : bg; p++;
401               }
402
403               for (x = 0; x < 0x10; x++)
404               {
405                  gfx = gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)];     
406                  fg = (gfxram[ 0x3c00 | x | y ] & 0x38) >> 3;     
407                  /* Display 6 pixels in extended region */
408                  *p = ( gfx & 0x01 ) ? fg : bg; p++;
409                  *p = ( gfx & 0x02 ) ? fg : bg; p++;
410                  *p = ( gfx & 0x04 ) ? fg : bg; p++;
411                  fg = gfxram[ 0x3c00 | x | y ] & 0x07;     
412                  *p = ( gfx & 0x08 ) ? fg : bg; p++;
413                  *p = ( gfx & 0x10 ) ? fg : bg; p++;
414                  *p = ( gfx & 0x20 ) ? fg : bg; p++;
415               }
416            }
417         }
355418         break;
356419   }
357420   return 0;
r4458r4459
363426   UINT8 y,ra,chr,gfx;
364427   UINT16 sy=0,ma=0,x;
365428   UINT8 *FNT = memory_region(screen->machine, "gfx1");
366   static UINT8 size_store=0xff;
367   static UINT8 cols=64,skip=1;
429   UINT8 cols = (trs80_mode & 1) ? 32 : 64;
430   UINT8 skip = (trs80_mode & 1) ? 2 : 1;
368431
369   if ((trs80_mode & 0x7f) != size_store)
432   if (trs80_mode != trs80_size_store)
370433   {
371      size_store = trs80_mode & 0x7f;
372      cols = (trs80_mode & 1) ? 32 : 64;
373      skip = (trs80_mode & 1) ? 2 : 1;
434      trs80_size_store = trs80_mode & 1;
374435      video_screen_set_visarea(screen, 0, cols*8-1, 0, 16*16-1);
375436   }
376437
r4458r4459
420481   videoram[offset] = data;
421482}
422483
423/***************************************************************************
424  Write to graphics ram
425***************************************************************************/
426#if 0               // not ready yet
427READ8_HANDLER( trs80_gfxram_r )
428{
429   return gfxram[offset];
430}
431484
432WRITE8_HANDLER( trs80_gfxram_w )
433{
434   gfxram[offset] = data;
435}
436#endif
437
438485/***************************************************************************
439486  Palettes
440487***************************************************************************/
src/mess/includes/trs80.h
r4458r4459
1919extern const wd17xx_interface trs80_wd17xx_interface;
2020extern UINT8 trs80_mode;
2121extern UINT8 trs80_model4;
22extern UINT8 *gfxram;
2223
2324DEVICE_IMAGE_LOAD( trs80_floppy );
2425QUICKLOAD_LOAD( trs80_cmd );
2526
2627MACHINE_RESET( trs80 );
2728
29WRITE8_HANDLER ( lnw80_w );
2830WRITE8_HANDLER ( trs80_ff_w );
2931WRITE8_HANDLER ( lnw80_fe_w );
3032WRITE8_HANDLER ( sys80_fe_w );
r4458r4459
4143WRITE8_HANDLER ( trs80m4_90_w );
4244WRITE8_HANDLER ( trs80m4_88_w );
4345WRITE8_HANDLER ( trs80m4_84_w );
46READ8_HANDLER ( lnw80_r );
4447READ8_HANDLER ( lnw80_fe_r );
4548READ8_HANDLER ( trs80_ff_r );
4649READ8_HANDLER ( trs80_fe_r );
r4458r4459
6770WRITE8_HANDLER( trs80_motor_w );
6871
6972READ8_HANDLER( trs80_keyboard_r );
73READ8_DEVICE_HANDLER (trs80_wd179x_r);
7074
7175
7276/*----------- defined in video/trs80.c -----------*/
7377
78VIDEO_START( trs80 );
7479VIDEO_UPDATE( trs80 );
7580VIDEO_UPDATE( model1 );
7681VIDEO_UPDATE( ht1080z );
src/mess/machine/trs80.c
r4458r4459
4040static UINT8 trs80_tape_unit=1;      /* selected cassette unit (trs80l2 and sys80 only) (not implemented yet) */
4141static UINT8 trs80_reg_load=1;      /* Controls what port EA will do */
4242static UINT8 trs80_nmi_data=0xff;   /* Passes FDC int to NMI handler */
43static UINT8 lnw80_port_fe=0xf0;   /* LNW80 video control bits */
4443UINT8 trs80_mode = 0;         /* Control bits passed to video output routine */
4544
4645#define IRQ_M1_RTC      0x80   /* RTC on Model I */
r4458r4459
253252}
254253
255254
255
256256/*************************************
257257 *
258258 *            Port handlers.
259259 *
260260 *************************************/
261261
262/* lnw80 can switch out all the devices, roms and video ram to be replaced by graphics ram. */
263READ8_HANDLER( lnw80_r )
264{
265   UINT8 *ROM = memory_region(space->machine, "maincpu");
266   if (trs80_mode & 0x40)
267      return gfxram[offset];
268   else
269   if (offset <= 0x3000)
270      return ROM[offset];
271   else
272   if (offset < 0x37e4)
273      return trs80_irq_status_r(space, 0);
274   else
275   if (offset < 0x37e8)
276      return 0xff;
277   else
278   if (offset < 0x37ec)
279      return trs80_printer_r(space, 0);
280   else
281   if (offset == 0x37ec)
282      return trs80_wd179x_r(trs80_fdc, 0);
283   else
284   if (offset == 0x37ed)
285      return wd17xx_track_r(trs80_fdc, 0);
286   else
287   if (offset == 0x37ee)
288      return wd17xx_sector_r(trs80_fdc, 0);
289   else
290   if (offset == 0x37ef)
291      return wd17xx_data_r(trs80_fdc, 0);
292   else
293   if (offset < 0x3800)
294      return 0xff;
295   else
296   if (offset < 0x3c00)
297      return trs80_keyboard_r(space, offset & 0xff);
298   else
299      return videoram[offset&0x3ff];
300}
301
302WRITE8_HANDLER( lnw80_w )
303{
304   if (trs80_mode & 0x40)
305      gfxram[offset] = data;
306   else
307   if (offset < 0x37e0)
308      return;
309   else
310   if (offset < 0x37e4)
311      trs80_motor_w(space, 0, data);
312   else
313   if (offset < 0x37e8)
314      return;
315   else
316   if (offset < 0x37ec)
317      trs80_printer_w(space, 0, data);
318   else
319   if (offset == 0x37ec)
320      wd17xx_command_w(trs80_fdc, 0, data);
321   else
322   if (offset == 0x37ed)
323      wd17xx_track_w(trs80_fdc, 0, data);
324   else
325   if (offset == 0x37ee)
326      wd17xx_sector_w(trs80_fdc, 0, data);
327   else
328   if (offset == 0x37ef)
329      wd17xx_data_w(trs80_fdc, 0, data);
330   else
331   if (offset < 0x3c00)
332      return;
333   else
334      videoram[offset&0x3ff]=data;
335}
336
337
262338READ8_HANDLER( trs80m4_e0_r )
263339{
264340/* Indicates which devices are interrupting - d6..d3 not emulated.
r4458r4459
373449
374450READ8_HANDLER( lnw80_fe_r )
375451{
376   return lnw80_port_fe | 0xf0;
452   return ((trs80_mode & 0x78) >> 3) | 0xf0;
377453}
378454
379455READ8_HANDLER( trs80_ff_r )
r4458r4459
529605   d2 Mode Select (0=64 chars, 1=32chars)
530606   d1 Cassette Motor (1=On) */
531607
532   static UINT8 settings=0xff;
533   UINT8 changed = data ^ settings;
608   cpu_set_clock(space->machine->cpu[0], data & 0x40 ? MODEL4_MASTER_CLOCK/5 : MODEL4_MASTER_CLOCK/10);
534609
535   if (changed & 0x40)
536      cpu_set_clock(space->machine->cpu[0], data & 0x40 ? MODEL4_MASTER_CLOCK/5 : MODEL4_MASTER_CLOCK/10);
537
538610   trs80_mode = (trs80_mode & 0xfe) | ((data & 4) ? 1 : 0);
539611
540   if (changed & 0x02)
541      cassette_change_state( trs80_cass, ( data & 2 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR );
612   cassette_change_state( trs80_cass, ( data & 2 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR );
542613
543   settings = data;
544614   trs80_port_ec = data & 0x7e;
545615}
546616
r4458r4459
606676   d0 inverse video (entire screen) */
607677
608678   trs80_mode = (trs80_mode & 0x87) | ((data & 0x0f) << 3);
609   lnw80_port_fe = data;
610679}
611680
612681WRITE8_HANDLER( trs80_ff_w )
r4458r4459
713782 *                 *
714783 *************************************/
715784
785READ8_DEVICE_HANDLER (trs80_wd179x_r)
786{
787   if (input_port_read(device->machine, "CONFIG") & 0x80)
788      return wd17xx_status_r(device, offset);
789   else
790      return 0xff;
791}
792
716793READ8_HANDLER ( trs80_printer_r )
717794{
718795   /* Bit 7 - 1 = Busy; 0 = Not Busy
r4458r4459
780857      drive = 3;
781858      head = 0;
782859      break;
783   /* These 3 combinations aren't documented */
860   /* These 3 combinations aren't official. Some manufacturers of double-sided disks
861      used drive select 4 to indicate the other side. */
784862   case 9:
785863      drive = 0;
786864      head = 1;
src/mess/drivers/trs80.c
r4458r4459
144144#include "devices/cassette.h"
145145#include "formats/trs_cas.h"
146146
147UINT8 *gfxram;
147148UINT8 trs80_model4;
148149
149static READ8_DEVICE_HANDLER (trs80_wd179x_r)
150{
151   if (input_port_read(device->machine, "CONFIG") & 0x80)
152      return wd17xx_status_r(device, offset);
153   else
154      return 0xff;
155}
156
157150static ADDRESS_MAP_START( trs80_map, ADDRESS_SPACE_PROGRAM, 8 )
158151   AM_RANGE(0x0000, 0x0fff) AM_ROM
159152   AM_RANGE(0x3800, 0x38ff) AM_READ(trs80_keyboard_r)
r4458r4459
196189   AM_RANGE(0xff, 0xff) AM_READWRITE(trs80_ff_r, trs80_ff_w)
197190ADDRESS_MAP_END
198191
192static ADDRESS_MAP_START( lnw80_map, ADDRESS_SPACE_PROGRAM, 8 )
193   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(lnw80_r, lnw80_w)
194   AM_RANGE(0x4000, 0xffff) AM_RAM
195ADDRESS_MAP_END
196
199197static ADDRESS_MAP_START( lnw80_io, ADDRESS_SPACE_IO, 8 )
200198   ADDRESS_MAP_GLOBAL_MASK(0xff)
201199   AM_RANGE(0xe8, 0xe8) AM_READWRITE(trs80m4_e8_r, trs80m4_e8_w)
r4458r4459
425423   MDRV_PALETTE_LENGTH(2)
426424   MDRV_PALETTE_INIT(black_and_white)
427425
426   MDRV_VIDEO_START( trs80 )
428427   MDRV_VIDEO_UPDATE( trs80 )
429428
430429   /* sound hardware */
r4458r4459
481480static MACHINE_DRIVER_START( lnw80 )
482481   MDRV_IMPORT_FROM( model1 )
483482   MDRV_CPU_MODIFY( "maincpu" )
484   MDRV_CPU_PROGRAM_MAP( model1_map, 0 )
483   MDRV_CPU_PROGRAM_MAP( lnw80_map, 0 )
485484   MDRV_CPU_IO_MAP( lnw80_io, 0 )
486485
487486   MDRV_PALETTE_LENGTH(8)
r4458r4459
567566
568567   ROM_REGION(0x00800, "gfx1",0)
569568   ROM_LOAD("lnw_chr.bin",  0x0000, 0x0800, CRC(c89b27df) SHA1(be2a009a07e4378d070002a558705e9a0de59389))
569
570   ROM_REGION(0x04400, "gfx2",0)
571   ROM_FILL(0, 0x4400, 0xff)   /* 0x4000 for gfxram + 0x400 for videoram */
570572ROM_END
571573
572574ROM_START(trs80m3)
r4458r4459
640642   trs80_model4 = 1;
641643}
642644
645static DRIVER_INIT( lnw80 )
646{
647   trs80_mode = 0;
648   trs80_model4 = 0;
649   gfxram = memory_region(machine, "gfx2");
650   videoram = memory_region(machine, "gfx2")+0x4000;
651}
652
643653static void trs8012_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
644654{
645655   /* floppy */
r4458r4459
667677COMP( 1978, trs80l2,  trs80,   0,   model1,   trs80,   trs80l2,  trs8012,   "Tandy Radio Shack",  "TRS-80 Model I (Level II Basic)" , 0 )
668678COMP( 1983, radionic, trs80,   0,   radionic, trs80,   trs80,    trs8012,   "Komtek",  "Radionic" , 0 )
669679COMP( 1980, sys80,    trs80,   0,   sys80,    trs80,   trs80l2,  trs8012,   "EACA Computers Ltd.","System-80" , 0 )
670COMP( 1981, lnw80,    trs80,   0,   lnw80,    trs80m3, trs80,    trs8012,   "LNW Research","LNW-80", 0 )
680COMP( 1981, lnw80,    trs80,   0,   lnw80,    trs80m3, lnw80,    trs8012,   "LNW Research","LNW-80", 0 )
671681COMP( 1980, trs80m3,  trs80,   0,   model3,   trs80m3, trs80m4,  trs8012,   "Tandy Radio Shack",  "TRS-80 Model III", 0 )
672682COMP( 1980, trs80m4,  trs80,   0,   model3,   trs80m3, trs80m4,  trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4", 0 )
673683COMP( 1980, trs80m4p, trs80,   0,   model3,   trs80m3, trs80m4,  trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4P", GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team