Previous 15994 Revisions Next

r1474 Tuesday 1st January, 2008 at 16:58:06 UTC by Nathan Woods
[TI99] More floppy cleanups; fixed TI99_8 regression and made the floppy
drive usable. (bug #1450) [Michael Zapf]
[docs]messnew.txt
[src/mess/devices]mflopimg.c mflopimg.h
[src/mess/drivers]ti99_4x.c ti99_8.c
[src/mess/machine]99_dsk.c 99_dsk.h geneve.c ti99_4x.c ti99_4x.h

src/mess/devices/mflopimg.c
r1473r1474
6060   { FLOPPY_ERROR_INVALIDIMAGE,   IMAGE_ERROR_INVALIDIMAGE }
6161};
6262
63static int flopimg_keep_geometry;   /* hack for TI-99 - please fix when possible */
64
65
66
6763/***************************************************************************
6864    IMPLEMENTATION
6965***************************************************************************/
r1473r1474
263259
264260static int device_init_floppy(mess_image *image)
265261{
266    flopimg_keep_geometry = FALSE;
267262    if (!image_alloctag(image, FLOPPY_TAG, sizeof(mess_flopimg)))
268263      return INIT_FAIL;
269264   return floppy_drive_init(image, &mess_floppy_interface);
r1473r1474
279274   const struct FloppyFormat *floppy_options;
280275   int floppy_flags, i;
281276   const char *extension;
277   int keep_geometry = 0;
282278
283279   /* look up instance data */
284280   flopimg = get_flopimg(image);
r1473r1474
304300      if (err)
305301         goto error;
306302   }
303       
304   /* if we can get head and track counts, then set the geometry accordingly
305      However, at least the ti99 system family requires that medium track
306      count and drive track count be handled separately.
307      It is possible to insert a 40 track medium in an 80 track drive; the
308      TI controllers read the track count from sector 0 and automatically
309      apply double steps. Setting the track count of the drive to the
310      medium track count will then lead to unreachable tracks.
311   */
312   keep_geometry = (int)device_get_info_int(&image_device(image)->devclass, DEVINFO_INT_KEEP_DRIVE_GEOMETRY);
307313
308   /* if we can get head and track counts, then set the geometry accordingly */
309   if (!flopimg_keep_geometry
314   if (!keep_geometry
310315            && floppy_callbacks(flopimg->floppy)->get_heads_per_disk
311316      && floppy_callbacks(flopimg->floppy)->get_tracks_per_disk)
312317   {
r1473r1474
378383   flopimg->tracktranslate_proc = proc;
379384}
380385
381
382/************
383 *  Another hack for ti99: Drive track count may differ from medium track count.
384 *  It is possible to insert a 40 track medium in an 80 track drive; the TI
385 *  controllers read the track count from sector 0 and automatically
386 *  apply double steps. Setting the track count of the drive to the medium
387 *  track count will lead to unreachable tracks.
388 *  This function is called from 99_dsk.c to switch off the lines in
389 *  internal_floppy_device_load which set the drive geometry to the medium
390 *  geometry.
391 *************/
392void floppy_keep_drive_geometry(void)
393{
394   assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT, "Can only call floppy_keep_drive_geometry at init time!");
395   flopimg_keep_geometry = TRUE;
396}
397
398
399
400386/*************************************
401387 *
402388 *   Device specification function
r1473r1474
428414         info->i = count;
429415         break;
430416
417      case DEVINFO_INT_KEEP_DRIVE_GEOMETRY:
418         info->i = 0;
419         break;
420
431421      /* --- the following bits of info are returned as NULL-terminated strings --- */
432422      case DEVINFO_STR_FILE_EXTENSIONS:
433423         /* retrieve the floppy options */
src/mess/devices/mflopimg.h
r1473r1474
1414
1515enum
1616{
17   DEVINFO_PTR_FLOPPY_OPTIONS = DEVINFO_PTR_DEV_SPECIFIC
17   DEVINFO_PTR_FLOPPY_OPTIONS = DEVINFO_PTR_DEV_SPECIFIC,
18   DEVINFO_INT_KEEP_DRIVE_GEOMETRY = DEVINFO_INT_DEV_SPECIFIC
1819};
1920
2021floppy_image *flopimg_get_image(mess_image *image);
r1473r1474
2728/* hack for TI99; replace this when we think of something better */
2829void floppy_install_tracktranslate_proc(mess_image *image, int (*proc)(mess_image *image, floppy_image *floppy, int physical_track));
2930
30/* another hack for TI99: Drive track count may differ from medium track count. */
31void floppy_keep_drive_geometry(void);
32
3331#endif /* MFLOPIMG_H */
src/mess/machine/99_dsk.c
r1473r1474
3434#include "devices/mflopimg.h"
3535
3636#define MAX_FLOPPIES 4
37#define TI99DSK_TAG   "ti99dsktag"
3738
3839static int use_80_track_drives;
3940
41/* defines for DRQ_IRQ_status */
42enum
43{
44   fdc_IRQ = 1,
45   fdc_DRQ = 2
46};
47
48/* current state of the DRQ and IRQ lines */
49static int DRQ_IRQ_status;
50
51/* when TRUE the CPU is halted while DRQ/IRQ are true */
52static int DSKhold;
53/* disk selection bits */
54static int DSEL;
55/* currently selected disk unit */
56static int DSKnum;
57/* current side */
58static int DSKside;
59/* 1 if motor is on */
60static int DVENA;
61/* on rising edge, sets DVENA for 4.23 seconds on rising edge */
62static int motor_on;
63/* count 4.23s from rising edge of motor_on */
64void *motor_on_timer;
65
66/*
67   call this when the state of DSKhold or DRQ/IRQ or DVENA change
68
69   Emulation is faulty because the CPU is actually stopped in the midst of
70   instruction, at the end of the memory access
71*/
72static void fdc_handle_hold(void)
73{
74   if (DSKhold && (!DRQ_IRQ_status) && DVENA)
75      cpunum_set_input_line(0, INPUT_LINE_HALT, ASSERT_LINE);
76   else
77      cpunum_set_input_line(0, INPUT_LINE_HALT, CLEAR_LINE);
78}
79
80/*
81   callback called at the end of DVENA pulse
82*/
83static TIMER_CALLBACK(motor_on_timer_callback)
84{
85   DVENA = 0;
86   fdc_handle_hold();
87}
88
4089typedef struct ti99_geometry
4190{
4291   UINT8 sides;
r1473r1474
4594   UINT8 density;
4695} ti99_geometry;
4796
97static void hfdc_int_callback(int which, int state);
98static int hfdc_select_callback(int which, select_mode_t select_mode, int select_line, int gpos);
99static UINT8 hfdc_dma_read_callback(int which, offs_t offset);
100static void hfdc_dma_write_callback(int which, offs_t offset, UINT8 data);
48101
49#define TI99DSK_TAG   "ti99dsktag"
102static const smc92x4_intf hfdc_intf =
103{
104   hfdc_select_callback,
105   hfdc_dma_read_callback,
106   hfdc_dma_write_callback,
107   hfdc_int_callback
108};
50109
51110/*
52111   Convert physical sector address to sector offset in disk image
r1473r1474
76135static int ti99_tracktranslate(mess_image *image, floppy_image *floppy, int physical_track)
77136{
78137   struct ti99_geometry *geometry;
79
80138   geometry = floppy_tag(floppy, TI99DSK_TAG);
81139
82140   if (use_80_track_drives && (geometry->tracksperside <= 40))
r1473r1474
267325   int success;
268326   floperr_t err;
269327
270        /* Prevents internal_floppy_device_load (mflopimg) to set the drive
271           geometry to the medium geometry. TI disk controllers determine the
272           number of tracks from a field in sector 0, and if the medium has
273           40 tracks but the drive has 80, the DSR ROM automatically
274           double-steps the tracks.
275        */
276        floppy_keep_drive_geometry();
277
278328   geometry1 = floppy_create_tag(floppy, TI99DSK_TAG, sizeof(*geometry1));
279329
280330   ti99_guess_geometry(floppy, geometry1, NULL, &success);
r1473r1474
312362   }
313363}
314364
365/*
366   callback called whenever DRQ/IRQ state change
367*/
368static void fdc_callback(wd17xx_state_t event, void *param)
369{
370   switch (event)
371   {
372   case WD17XX_IRQ_CLR:
373      DRQ_IRQ_status &= ~fdc_IRQ;
374      ti99_peb_set_ilb_bit(intb_fdc_bit, 0);
375      break;
376   case WD17XX_IRQ_SET:
377      DRQ_IRQ_status |= fdc_IRQ;
378      ti99_peb_set_ilb_bit(intb_fdc_bit, 1);
379      break;
380   case WD17XX_DRQ_CLR:
381      DRQ_IRQ_status &= ~fdc_DRQ;
382      break;
383   case WD17XX_DRQ_SET:
384      DRQ_IRQ_status |= fdc_DRQ;
385      break;
386   }
315387
388   fdc_handle_hold();
389}
390
391/*
392   Initializes all available controllers. This routine is only used in the
393   init state of the emulator. During the normal operation, only the
394   reset routines are used.
395*/
396void ti99_floppy_controllers_init_all(void)
397{
398   /* initialize the controller chip for TI FDC, CC, BwG */
399   wd17xx_init(WD_TYPE_179X, fdc_callback, NULL);
400
401   /* initialize the controller chip for HFDC */
402   smc92x4_init(0, & hfdc_intf);
403
404   ti99_install_tracktranslate_procs();
405
406   motor_on_timer = timer_alloc(motor_on_timer_callback, NULL);
407   
408   /* initialize the RTC for BwG and HFDC */
409   mm58274c_init(1, 1);
410}
411
316412/*===========================================================================*/
317413/*
318414   TI99/4(a) Floppy disk controller card emulation
r1473r1474
329425/* pointer to the fdc ROM data */
330426static UINT8 *ti99_disk_DSR;
331427
332/* when TRUE the CPU is halted while DRQ/IRQ are true */
333static int DSKhold;
334
335/* defines for DRQ_IRQ_status */
336enum
337{
338   fdc_IRQ = 1,
339   fdc_DRQ = 2
340};
341
342/* current state of the DRQ and IRQ lines */
343static int DRQ_IRQ_status;
344
345/* disk selection bits */
346static int DSEL;
347/* currently selected disk unit */
348static int DSKnum;
349/* current side */
350static int DSKside;
351
352/* 1 if motor is on */
353static int DVENA;
354/* on rising edge, sets DVENA for 4.23 seconds on rising edge */
355static int motor_on;
356/* count 4.23s from rising edge of motor_on */
357static void *motor_on_timer;
358
359428static const ti99_peb_card_handlers_t fdc_handlers =
360429{
361430   fdc_cru_r,
r1473r1474
364433   fdc_mem_w
365434};
366435
367
368436/*
369437   Reset fdc card, set up handlers
370438*/
371void ti99_fdc_init(void)
372{
373   wd17xx_init(WD_TYPE_179X, fdc_callback, NULL);      /* initialize the floppy disk controller */
374   ti99_install_tracktranslate_procs();
375   motor_on_timer = timer_alloc(motor_on_timer_callback, NULL);
376   use_80_track_drives = FALSE;
377}
378
379/*
380   Reset fdc card, set up handlers
381*/
382439void ti99_fdc_reset(void)
383440{
384441   ti99_disk_DSR = memory_region(region_dsr) + offset_fdc_dsr;
r1473r1474
388445
389446   DVENA = 0;
390447   motor_on = 0;
448
449   use_80_track_drives = FALSE;
450
391451   ti99_peb_set_card_handlers(0x1100, & fdc_handlers);
392452   wd17xx_reset();      /* resets the fdc */
393453   wd17xx_set_density(DEN_FM_LO);
394454}
395455
396
397456/*
398   call this when the state of DSKhold or DRQ/IRQ or DVENA change
399
400   Emulation is faulty because the CPU is actually stopped in the midst of instruction, at
401   the end of the memory access
402*/
403static void fdc_handle_hold(void)
404{
405   if (DSKhold && (!DRQ_IRQ_status) && DVENA)
406      cpunum_set_input_line(0, INPUT_LINE_HALT, ASSERT_LINE);
407   else
408      cpunum_set_input_line(0, INPUT_LINE_HALT, CLEAR_LINE);
409}
410
411/*
412   callback called whenever DRQ/IRQ state change
413*/
414static void fdc_callback(wd17xx_state_t event, void *param)
415{
416   switch (event)
417   {
418   case WD17XX_IRQ_CLR:
419      DRQ_IRQ_status &= ~fdc_IRQ;
420      ti99_peb_set_ilb_bit(intb_fdc_bit, 0);
421      break;
422   case WD17XX_IRQ_SET:
423      DRQ_IRQ_status |= fdc_IRQ;
424      ti99_peb_set_ilb_bit(intb_fdc_bit, 1);
425      break;
426   case WD17XX_DRQ_CLR:
427      DRQ_IRQ_status &= ~fdc_DRQ;
428      break;
429   case WD17XX_DRQ_SET:
430      DRQ_IRQ_status |= fdc_DRQ;
431      break;
432   }
433
434   fdc_handle_hold();
435}
436
437/*
438   callback called at the end of DVENA pulse
439*/
440static TIMER_CALLBACK(motor_on_timer_callback)
441{
442   DVENA = 0;
443   fdc_handle_hold();
444}
445
446/*
447457   Read disk CRU interface
448458
449459   bit 0: HLD pin
r1473r1474
632642   ccfdc_mem_w
633643};
634644
635
636/*
637   Reset fdc card, set up handlers
638*/
639void ti99_ccfdc_init(void)
640{
641   wd17xx_init(WD_TYPE_179X, fdc_callback, NULL);      /* initialize the floppy disk controller */
642   motor_on_timer = timer_alloc(motor_on_timer_callback, NULL);
643   ti99_install_tracktranslate_procs();
644   use_80_track_drives = FALSE;
645}
646
647645void ti99_ccfdc_reset(void)
648646{
649647   ti99_disk_DSR = memory_region(region_dsr) + offset_ccfdc_dsr;
r1473r1474
654652   DVENA = 0;
655653   motor_on = 0;
656654
655   use_80_track_drives = FALSE;
656
657657   ti99_peb_set_card_handlers(0x1100, & ccfdc_handlers);
658658
659659   wd17xx_reset();      /* initialize the floppy disk controller */
r1473r1474
853853/*
854854   Reset fdc card, set up handlers
855855*/
856void ti99_bwg_init(void)
857{
858   wd17xx_init(WD_TYPE_179X, fdc_callback, NULL);      /* initialize the floppy disk controller */
859   mm58274c_init(1, 1);   /* initialize the RTC */
860   motor_on_timer = timer_alloc(motor_on_timer_callback, NULL);
861   ti99_install_tracktranslate_procs();
862   use_80_track_drives = FALSE;
863}
864
865856void ti99_bwg_reset(void)
866857{
867858   ti99_disk_DSR = memory_region(region_dsr) + offset_bwg_dsr;
r1473r1474
876867
877868   DVENA = 0;
878869   motor_on = 0;
870       
871        use_80_track_drives = FALSE;
872       
879873   ti99_peb_set_card_handlers(0x1100, & bwg_handlers);
880874
881875   wd17xx_reset();      /* initialize the floppy disk controller */
r1473r1474
10661060            break;
10671061         }
10681062   }
1069
10701063   return reply;
10711064}
10721065
r1473r1474
11501143static UINT8 *hfdc_ram;
11511144static int hfdc_irq_state;
11521145
1153
1154static int hfdc_select_callback(int which, select_mode_t select_mode, int select_line, int gpos);
1155static UINT8 hfdc_dma_read_callback(int which, offs_t offset);
1156static void hfdc_dma_write_callback(int which, offs_t offset, UINT8 data);
1157static void hfdc_int_callback(int which, int state);
1158
1159static const smc92x4_intf hfdc_intf =
1160{
1161   hfdc_select_callback,
1162   hfdc_dma_read_callback,
1163   hfdc_dma_write_callback,
1164   hfdc_int_callback
1165};
1166
11671146/*
11681147   Select the correct HFDC disk units.
11691148   floppy disks are selected by the 4 gpos instead of the select lines.
r1473r1474
12461225/*
12471226   Reset fdc card, set up handlers
12481227*/
1249void ti99_hfdc_init(void)
1250{
1251   /* initialize the floppy disk controller */
1252   smc92x4_init(0, & hfdc_intf);
1253   mm58274c_init(1, 1);   /* initialize the RTC */
1254   motor_on_timer = timer_alloc(motor_on_timer_callback, NULL);
1255   ti99_install_tracktranslate_procs();
1256   use_80_track_drives = TRUE;
1257}
1258
1259
12601228void ti99_hfdc_reset(void)
12611229{
12621230   ti99_disk_DSR = memory_region(region_dsr) + offset_hfdc_dsr;
r1473r1474
12741242
12751243   ti99_peb_set_card_handlers(0x1100, & hfdc_handlers);
12761244
1245   use_80_track_drives = TRUE;
1246
12771247   smc92x4_reset(0);
12781248}
12791249
src/mess/machine/99_dsk.h
r1473r1474
11FLOPPY_OPTIONS_EXTERN(ti99);
22
3void ti99_fdc_init(void);
3void ti99_floppy_controllers_init_all(void);
44void ti99_fdc_reset(void);
55#if HAS_99CCFDC
6void ti99_ccfdc_init(void);
76void ti99_ccfdc_reset(void);
87#endif
9void ti99_bwg_init(void);
108void ti99_bwg_reset(void);
11void ti99_hfdc_init(void);
129void ti99_hfdc_reset(void);
src/mess/machine/geneve.c
r1473r1474
208208           how the switches are set. Later we use the configuration switches to
209209           determine which one to use. */
210210   ti99_peb_init();
211        ti99_fdc_init();
212#if HAS_99CCFDC
213   ti99_ccfdc_init();
214#endif
215   ti99_bwg_init();
216   ti99_hfdc_init();
211        ti99_floppy_controllers_init_all();
217212        ti99_ide_init();
218213        ti99_rs232_init();
219214   ti99_usbsm_init();
src/mess/machine/ti99_4x.c
r1473r1474
5353#include <math.h>
5454#include "driver.h"
5555#include "tms9901.h"
56#include "video/tms9928a.h"
5756#include "video/v9938.h"
5857#include "audio/spchroms.h"
5958#include "devices/cassette.h"
r1473r1474
108107static void ti99_myarcxram_init(void);
109108static void ti99_evpc_reset(void);
110109
111static void ti99_common_init(const TMS9928a_interface *intf);
112
113
114110/*
115111   pointer to extended RAM area
116112*/
r1473r1474
713709
714710MACHINE_START( ti99_4ev_60hz)
715711{
716   tms9901_init(0, & tms9901reset_param_ti99_4x);
717       ti99_peb_init();
718        ti99_fdc_init();
719#if HAS_99CCFDC
720   ti99_ccfdc_init();
721#endif
722   ti99_bwg_init();
723   ti99_hfdc_init();
724        ti99_ide_init();
725        ti99_rs232_init();
726   ti99_hsgpl_init();
727   ti99_usbsm_init();
712    /* has an own VDP, so skip initing the VDP */
713    ti99_common_init(0);
728714}
729715
730static void ti99_common_init(const TMS9928a_interface *gfxparm) {
716void ti99_common_init(const TMS9928a_interface *gfxparm)
717{
718    if (ti99_model==model_99_8) {
719        tms9901_init(0, &tms9901reset_param_ti99_8);
720    }
721    else {
722   tms9901_init(0,  &tms9901reset_param_ti99_4x);
723    }
724   if (gfxparm!=0) TMS9928A_configure(gfxparm);
731725
732   tms9901_init(0, & tms9901reset_param_ti99_4x);
733
734   TMS9928A_configure(gfxparm);
735
736726        /* Initialize all. Actually, at this point, we don't know
737727           how the switches are set. Later we use the configuration switches to
738728           determine which one to use. */
739729   ti99_peb_init();
740        ti99_fdc_init();
741#if HAS_99CCFDC
742   ti99_ccfdc_init();
743#endif
744   ti99_bwg_init();
745   ti99_hfdc_init();
730        ti99_floppy_controllers_init_all();
746731        ti99_ide_init();
747732        ti99_rs232_init();
748733   ti99_hsgpl_init();
src/mess/machine/ti99_4x.h
r1473r1474
11/*
22   header file for machine/ti99_4x.c
33*/
4#include "video/tms9928a.h"
45
56/* defines */
67
r1473r1474
171172void ti99_4ev_hblank_interrupt(void);
172173
173174void set_hsgpl_crdena(int data);
175void ti99_common_init(const TMS9928a_interface *gfxparm);
174176
175177READ16_HANDLER ( ti99_nop_8_r );
176178WRITE16_HANDLER ( ti99_nop_8_w );
src/mess/drivers/ti99_8.c
r1473r1474
148148
149149#include "driver.h"
150150#include "inputx.h"
151#include "video/tms9928a.h"
152151
153152#include "machine/ti99_4x.h"
154153#include "machine/tms9901.h"
r1473r1474
366365{
367366   TMS99x8A,
368367   0x4000,
369   0, 0,
368   15, 15,
370369   tms9901_set_int2
371370};
372371
373372static MACHINE_START(ti99_8_60hz)
374373{
375   TMS9928A_configure(&tms9118_interface);
374    ti99_common_init(&tms9118_interface);
376375}
377376
378377static const TMS9928a_interface tms9129_interface =
379378{
380379   TMS9929A,
381380   0x4000,
382   0, 0,
381   13, 13,
383382   tms9901_set_int2
384383};
385384
386385static MACHINE_START(ti99_8_50hz)
387386{
388   TMS9928A_configure(&tms9129_interface);
387    ti99_common_init(&tms9129_interface);
389388}
390389
391390static const struct tms9995reset_param ti99_8_processor_config =
src/mess/drivers/ti99_4x.c
r1473r1474
2121#include "driver.h"
2222#include "inputx.h"
2323#include "video/generic.h"
24#include "video/tms9928a.h"
2524#include "video/v9938.h"
26
2725#include "machine/ti99_4x.h"
2826#include "machine/tms9901.h"
2927#include "audio/spchroms.h"
r1473r1474
822820      /* --- the following bits of info are returned as 64-bit signed integers --- */
823821      case DEVINFO_INT_COUNT:                     info->i = 4; break;
824822
823                /* Used within mflopimg.c. */
824                case DEVINFO_INT_KEEP_DRIVE_GEOMETRY:                                  info->i = 1; break;
825825      /* --- the following bits of info are returned as pointers to data or functions --- */
826826      case DEVINFO_PTR_FLOPPY_OPTIONS:            info->p = (void *) floppyoptions_ti99; break;
827827
docs/messnew.txt
r1473r1474
88
99System Driver Changes:
1010----------------------
11(none)
11- [TI99] More floppy cleanups; fixed TI99_8 regression and made the floppy
12  drive usable.  (bug #1450)  [Michael Zapf]
1213
1314
1415

Previous 15994 Revisions Next


© 1998-2018 The MESS Team