Previous 15994 Revisions Next

r4449 Tuesday 31st March, 2009 at 13:22:48 UTC by Robbbert
[TRS80] WIP
[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
r4448r4449
4646   UINT8 y,ra,chr,gfx,gfxbit;
4747   UINT16 sy=0,ma=0,x;
4848   UINT8 *FNT = memory_region(screen->machine, "gfx1");
49   UINT8 seven_bit = screen->machine->gamedrv->flags >> 24;
49   UINT8 seven_bit = (screen->machine->gamedrv->flags >> 24) & 1;
5050   static UINT8 size_store=0xff;
5151   static UINT8 cols=64,skip=1;
5252
r4448r4449
185185   UINT8 y,ra,chr,gfx,gfxbit;
186186   UINT16 sy=0,ma=0,x;
187187   UINT8 *FNT = memory_region(screen->machine, "gfx1");
188   UINT8 seven_bit = screen->machine->gamedrv->flags >> 24;
188   UINT8 seven_bit = (screen->machine->gamedrv->flags >> 24) & 1;
189189   static UINT8 size_store=0xff;
190190   static UINT8 cols=64,skip=1;
191191
src/mess/includes/trs80.h
r4448r4449
5353READ8_HANDLER ( trs80m4_e0_r );
5454
5555INTERRUPT_GEN( trs80_rtc_interrupt );
56INTERRUPT_GEN( trs80m4_rtc_interrupt );
5756INTERRUPT_GEN( trs80_fdc_interrupt );
5857
5958READ8_HANDLER( trs80_irq_status_r );
src/mess/machine/trs80.c
r4448r4449
3535
3636static UINT8 trs80_int=0;      /* interrupting devices */
3737static UINT8 trs80_mask= 0;      /* interrupt mask */
38static UINT8 trs80_nmi_mask= 0;      /* nmi mask */
3839static UINT8 trs80_port_ec=0;      /* bit d6..d1 of port EC to be read by port FF */
40static UINT8 trs80_tape_unit=1;      /* selected cassette unit (trs80l2 and sys80 only) (not implemented yet) */
41static UINT8 trs80_reg_load=1;      /* Controls what port EA will do */
42static UINT8 trs80_nmi_data=0;      /* Passes FDC int to NMI handler */
3943UINT8 trs80_mode = 0;         /* Control bits passed to video output routine */
4044
4145#define IRQ_M1_RTC      0x80   /* RTC on Model I */
r4448r4449
5660static UINT8 sector[4] = {0, };          /* current sector per drive */
5761#endif
5862
59static UINT8 trs80_reg_load=1;
60
6163#define MODEL4_MASTER_CLOCK 20275200
6264
6365static UINT8 cassette_data;
r4448r4449
7072
7173static TIMER_CALLBACK( cassette_data_callback )
7274{
75/* This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data".
76   1500 baud (trs80m3, trs80m4) is interrupt-driven and uses bit 0 of "cassette_data" */
77
7378   static double old_cassette_val;
7479   double new_val = cassette_input(trs80_cass);
7580
7681   /* Check for HI-LO transition */
7782   if ( old_cassette_val > -0.2 && new_val < -0.2 )
7883   {
79      cassette_data |= 0x80;
80      if (trs80_mask & CASS_FALL)
84      cassette_data |= 0x80;      /* 500 baud */
85      if (trs80_mask & CASS_FALL)   /* see if 1500 baud */
8186      {
8287         cassette_data = 0;
8388         trs80_int |= CASS_FALL;
r4448r4449
8792   else
8893   if ( old_cassette_val < -0.2 && new_val > -0.2 )
8994   {
90      if (trs80_mask & CASS_RISE)
95      if (trs80_mask & CASS_RISE)   /* 1500 baud */
9196      {
9297         cassette_data = 1;
9398         trs80_int |= CASS_RISE;
r4448r4449
176181   int dir_length; /* length of directory in sectors (aka DDGA) */
177182   int id = image_index_in_device(image);
178183
179    if (device_load_basicdsk_floppy(image) != INIT_PASS)
184   if (device_load_basicdsk_floppy(image) != INIT_PASS)
180185      return INIT_FAIL;
181186
182    if (image_index_in_device(image) == 0)        /* first floppy? */
187   if (image_index_in_device(image) == 0)        /* first floppy? */
183188   {
184189      image_fseek(image, 0, SEEK_SET);
185190      image_fread(image, pdrive, 2);
r4448r4449
254259
255260READ8_HANDLER( trs80m4_e0_r )
256261{
257/* Indicates which devices are interrupting - d2..d0 are emulated
262/* Indicates which devices are interrupting - d6..d3 not emulated.
258263   Whenever an interrupt occurs, this port is immediately read
259264   to find out which device requires service. Lowest-numbered
260265   bit takes precedence. We take this opportunity to clear the
r4448r4449
274279
275280READ8_HANDLER( trs80m4_e4_r )
276281{
277/* NMI status bits from the FDC - not emulated
282/* Indicates which devices are interrupting - not emulated.
283   Whenever an NMI occurs, this port is immediately read
284   to find out which device requires service. Lowest-numbered
285   bit takes precedence. We take this opportunity to clear the
286   cpu NMI line.
287
278288   d7 status of FDC INTREQ (0=true)
279289   d6 status of Motor Timeout (0=true)
280   d5 status of Reset signal (0=true) */
290   d5 status of Reset signal (0=true - this will reboot the computer) */
281291
282   return 0xff;
292   cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE);
293
294   return ~(trs80_nmi_mask & trs80_nmi_data);
295
296//   return 0xff;
283297}
284298
285299READ8_HANDLER( trs80m4_e8_r )
286300{
287/* These bits directly read pins on the RS-232 socket, and are not emulated
301/* not emulated
288302   d7 Clear-to-Send (CTS), Pin 5
289303   d6 Data-Set-Ready (DSR), pin 6
290304   d5 Carrier Detect (CD), pin 8
r4448r4449
335349
336350READ8_HANDLER( sys80_f9_r )
337351{
338/* UART Status Register (d4..d6 not emulated)
352/* UART Status Register - d6..d4 not emulated
339353   d7 Transmit buffer empty (inverted)
340354   d6 CTS pin
341355   d5 DSR pin
r4448r4449
372386/* Return of cassette data stream from tape
373387   d7 Low-speed data
374388   d6..d1 info from write of port EC
375   d0 High-speed data (not emulated yet) */
389   d0 High-speed data */
376390
377391   trs80_int &= 0xfc;   /* clear cassette interrupts */
378392
r4448r4449
382396
383397WRITE8_HANDLER( trs80m4_84_w )
384398{
385/* Hi-res graphics control (only d2,d3,d7 are emulated)
399/* Hi-res graphics control - d6..d4,d1..d0 not emulated
386400   d7 Page Control
387401   d6 Fix upper memory
388402   d5 Memory bit 1
389403   d4 Memory bit 0
390   d3 Invert Video (whole screen)
404   d3 Invert Video
391405   d2 80/64 width
392406   d1 Select bit 1
393407   d0 Select bit 0 */
r4448r4449
416430
417431WRITE8_HANDLER( trs80m4_e4_w )
418432{
419/* Disk to NMI interface (not emulated)
433/* Disk to NMI interface - not emulated
420434   d7 1=enable disk INTRQ to generate NMI
421435   d6 1=enable disk Motor Timeout to generate NMI */
436
437   trs80_nmi_mask = data;
422438}
423439
424440WRITE8_HANDLER( trs80m4_e8_w )
r4448r4449
457473{
458474   if (trs80_reg_load)
459475
460/* bits d7..d3 are UART control; d2..d0 directly adjust levels at the RS-232 socket - we emulate UART control only
476/* d2..d0 not emulated
461477   d7 Even Parity Enable ('1'=even, '0'=odd)
462478   d6='1',d5='1' for 8 bits
463479   d6='0',d5='1' for 7 bits
r4448r4449
481497   else
482498   {
483499
484/* These directly adjust levels at the RS-232 socket - not emulated
500/* not emulated
485501   d7,d6 Not used
486502   d5 Secondary Unassigned, pin 18
487503   d4 Secondary Transmit Data, pin 14
r4448r4449
525541
526542WRITE8_HANDLER( trs80m4_f4_w )
527543{
528/* Selection of drive and parameters - not emulated.
544/* Selection of drive and parameters - d7..d5 not emulated.
529545 A write also causes the selected drive motor to turn on for about 3 seconds.
530546 When the motor turns off, the drive is deselected.
531547   d7 1=MFM, 0=FM
r4448r4449
562578
563579WRITE8_HANDLER( sys80_f8_w )
564580{
565/* These adjust levels at the socket pins - not emulated
581/* not emulated
566582   d2 reset UART (XR pin)
567583   d1 DTR
568584   d0 RTS */
r4448r4449
572588{
573589/* not emulated
574590   d4 select internal or external cassette player */
591
592   trs80_tape_unit = (data & 0x10) ? 2 : 1;
575593}
576594
577595WRITE8_HANDLER( lnw80_fe_w )
578596{
579/* not emulated
597/* d3..d2 not emulated
580598   d3 bankswitch lower 16k between roms and hires ram
581599   d2 enable colour
582   d0 inverse video (whole screen) */
600   d0 inverse video */
583601
584602   trs80_mode = (trs80_mode & 0xf7) | ((data & 1) ? 8 : 0);
585603}
r4448r4449
618636
619637INTERRUPT_GEN( trs80_rtc_interrupt )
620638{
621   if (trs80_mask & IRQ_M1_RTC)
639/* This enables the processing of interrupts for the clock and the flashing cursor.
640   The OS counts one tick for each interrupt. The Model I has 40 ticks per
641   second, while the Model III/4 has 30. */
642
643   UINT8 system = (device->machine->gamedrv->flags >> 25) & 1;
644
645   if (system)   // Model 4
622646   {
647      if (trs80_mask & IRQ_M4_RTC)
648      {
649         trs80_int |= IRQ_M4_RTC;
650         cpu_set_input_line(device, 0, HOLD_LINE);
651      }
652   }
653   else      // Model 1
654   {
623655      trs80_int |= IRQ_M1_RTC;
624656      cpu_set_input_line(device, 0, HOLD_LINE);
625657   }
626658}
627659
628INTERRUPT_GEN( trs80m4_rtc_interrupt )
660static void trs80_fdc_interrupt_internal(running_machine *machine)
629661{
630/* This enables the processing of interrupts for the clock and the flashing cursor.
631   The OS counts one tick for each interrupt. There are 30 ticks per second. */
662   UINT8 system = (machine->gamedrv->flags >> 25) & 1;
632663
633   if (trs80_mask & IRQ_M4_RTC)
664   if (system)   // Model 4 does a NMI
634665   {
635      trs80_int |= IRQ_M4_RTC;
636      cpu_set_input_line(device, 0, HOLD_LINE);
666      trs80_nmi_data = 0x80;
667   //   cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, HOLD_LINE);
637668   }
638}
639
640static void trs80_fdc_interrupt_internal(running_machine *machine)
641{
642   if (trs80_mask & IRQ_M1_FDC)
669   else      // Model 1 does a IRQ
643670   {
644671      trs80_int |= IRQ_M1_FDC;
645672      cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE);
646673   }
647674}
648675
649INTERRUPT_GEN( trs80_fdc_interrupt )
676INTERRUPT_GEN( trs80_fdc_interrupt )   /* not used - should it be? */
650677{
651678   trs80_fdc_interrupt_internal(device->machine);
652679}
653680
654681static WD17XX_CALLBACK( trs80_fdc_callback )
655682{
683   UINT8 system = (device->machine->gamedrv->flags >> 25) & 1;
684
656685   switch (state)
657686   {
658687      case WD17XX_IRQ_CLR:
659         trs80_int &= ~IRQ_M1_FDC;
688         if (system) trs80_int &= ~IRQ_M1_FDC;
660689         break;
661690      case WD17XX_IRQ_SET:
662691         trs80_fdc_interrupt_internal(device->machine);
r4448r4449
700729/* not emulated
701730   01 for unit 1 (default
702731   02 for unit 2 */
732
733   trs80_tape_unit = data;
703734}
704735
705736READ8_HANDLER( trs80_irq_status_r )
706737{
738/* (trs80l2) Whenever an interrupt occurs, 37E0 is read to see what devices require service.
739   d7 = RTC
740   d6 = FDC
741   d2 = Communications (not emulated)
742   All interrupting devices are serviced in a single interrupt. There is a mask byte,
743   which is dealt with by the DOS. We take the opportunity to reset the cpu INT line. */
744
707745   int result = trs80_int;
708   trs80_int &= ~(IRQ_M1_RTC | IRQ_M1_FDC);
746   cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE);
747   trs80_int = 0;
709748   return result;
710749}
711750
r4448r4449
734773      drive = 3;
735774      head = 0;
736775      break;
776   /* These 3 combinations aren't documented */
737777   case 9:
738778      drive = 0;
739779      head = 1;
r4448r4449
761801 *************************************/
762802READ8_HANDLER( trs80_keyboard_r )
763803{
764   int result = 0;
804   UINT8 result = 0;
765805
766806   if (offset & 1)
767807      result |= input_port_read(space->machine, "LINE0");
src/mess/drivers/trs80.c
r4448r4449
447447   MDRV_CPU_MODIFY( "maincpu" )
448448   MDRV_CPU_PROGRAM_MAP( model3_map, 0 )
449449   MDRV_CPU_IO_MAP( model3_io, 0 )
450   MDRV_CPU_PERIODIC_INT(trs80m4_rtc_interrupt, 30)
450   MDRV_CPU_PERIODIC_INT(trs80_rtc_interrupt, 30)
451451   MDRV_VIDEO_UPDATE( trs80m4 )
452452   MDRV_SCREEN_MODIFY("screen")
453453   MDRV_SCREEN_SIZE(80*FW, 240)
r4448r4449
619619   CONFIG_DEVICE(trs8012_floppy_getinfo)
620620SYSTEM_CONFIG_END
621621
622
622/* Note - "1<<24" = needs 7-bit video; "1<<25" = Uses Model 4 IRQ system */
623623/*    YEAR  NAME      PARENT  COMPAT  MACHINE     INPUT    INIT      CONFIG       COMPANY  FULLNAME */
624624COMP( 1977, trs80,    0,   0,   trs80,    trs80,   0,        0,      "Tandy Radio Shack",  "TRS-80 Model I (Level I Basic)" , 0)
625625COMP( 1978, trs80l2,  trs80,   0,   model1,   trs80,   0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model I (Level II Basic)" , 1<<24)
626626COMP( 1983, radionic, trs80,   0,   radionic, trs80,   0,        trs8012,   "Komtek",  "Radionic" , 0)
627627COMP( 1980, sys80,    trs80,   0,   sys80,    trs80,   0,        trs8012,   "EACA Computers Ltd.","System-80" , 1<<24)
628628COMP( 1981, lnw80,    trs80,   0,   lnw80,    trs80m3, 0,        trs8012,   "LNW Research","LNW-80", 0 )
629COMP( 1980, trs80m3,  trs80,   0,   model3,   trs80m3, 0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model III", 0 )
630COMP( 1980, trs80m4,  trs80,   0,   model3,   trs80m3, 0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4", 0 )
631COMP( 1980, trs80m4p, trs80,   0,   model3,   trs80m3, 0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4P", GAME_NOT_WORKING )
629COMP( 1980, trs80m3,  trs80,   0,   model3,   trs80m3, 0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model III", 1<<25 )
630COMP( 1980, trs80m4,  trs80,   0,   model3,   trs80m3, 0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4", 1<<25 )
631COMP( 1980, trs80m4p, trs80,   0,   model3,   trs80m3, 0,        trs8012,   "Tandy Radio Shack",  "TRS-80 Model 4P", GAME_NOT_WORKING | 1<<25)
632632COMP( 1983, ht1080z,  trs80,   0,   ht1080z,  trs80,   0,        trs8012,   "Hiradastechnika Szovetkezet",  "HT-1080Z Series I" , 1<<24)
633633COMP( 1984, ht1080z2, trs80,   0,   ht1080z,  trs80,   0,        trs8012,   "Hiradastechnika Szovetkezet",  "HT-1080Z Series II" , 1<<24)
634634COMP( 1985, ht108064, trs80,   0,   ht1080z,  trs80,   0,        trs8012,   "Hiradastechnika Szovetkezet",  "HT-1080Z/64" , 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team