Previous 15994 Revisions Next

r5633 Monday 7th September, 2009 at 15:04:08 UTC by Miodrag Milanović
Floppy cleanup for Atari ST
[src/mess]mess.mak
[src/mess/drivers]atarist.c
[src/mess/formats]atarist_dsk.c* atarist_dsk.h*

src/mess/mess.mak
r5632r5633
610610   $(MAME_AUDIO)/jaguar.o      \
611611   $(MAME_VIDEO)/jaguar.o      \
612612   $(MESS_FORMATS)/a26_cas.o   \
613   $(MESS_FORMATS)/atarist_dsk.o   \
613614   $(MESS_DRIVERS)/atarist.o    \
614615   $(MESS_VIDEO)/atarist.o    \
615616   $(MESS_DRIVERS)/lynx.o      \
src/mess/formats/atarist_dsk.c
r0r5633
1/*********************************************************************
2
3   formats/atarist_dsk.c
4
5   Atari ST disk images
6
7*********************************************************************/
8
9#include <string.h>
10
11#include "formats/atarist_dsk.h"
12#include "formats/basicdsk.h"
13
14static FLOPPY_IDENTIFY(atarist_dsk_identify)
15{
16   *vote = 100;
17   return FLOPPY_ERROR_SUCCESS;
18}
19
20static FLOPPY_CONSTRUCT(atarist_dsk_construct)
21{
22   struct basicdsk_geometry geometry;
23   int heads = 0;
24   int tracks = 0;   
25   int sectors = 0;
26   UINT8 bootsector[512];
27
28   floppy_image_read(floppy, bootsector, 0, 512);
29   sectors = bootsector[0x18];
30   heads = bootsector[0x1a];
31   tracks = (bootsector[0x13] | (bootsector[0x14] << 8)) / sectors / heads;
32   
33   memset(&geometry, 0, sizeof(geometry));
34   geometry.heads = heads;
35   geometry.first_sector_id = 1;
36   geometry.sector_length = 512;
37   geometry.tracks = tracks;
38   geometry.sectors = sectors;
39   return basicdsk_construct(floppy, &geometry);   
40}
41
42/* ----------------------------------------------------------------------- */
43
44FLOPPY_OPTIONS_START( atarist )
45   FLOPPY_OPTION( atarist, "st",      "Atari ST floppy disk image",   atarist_dsk_identify, atarist_dsk_construct, NULL)
46FLOPPY_OPTIONS_END
47
src/mess/formats/atarist_dsk.h
r0r5633
1/*********************************************************************
2
3   formats/atarist_dsk.h
4
5   atarist disk images
6
7*********************************************************************/
8
9#ifndef ATARIST_DSK_H
10#define ATARIST_DSK_H
11
12#include "formats/flopimg.h"
13
14/**************************************************************************/
15
16FLOPPY_OPTIONS_EXTERN(atarist);
17
18#endif /* ATARIST_DSK_H */
src/mess/drivers/atarist.c
r5632r5633
22#include "video/atarist.h"
33#include "cpu/m68000/m68000.h"
44#include "cpu/m6800/m6800.h"
5#include "devices/basicdsk.h"
5#include "formats/atarist_dsk.h"
6#include "devices/mflopimg.h"
67#include "devices/cartslot.h"
78#include "machine/ctronics.h"
89#include "includes/serial.h"
r5632r5633
20982099ROM_END
20992100
21002101/* System Configuration */
2101
2102static DEVICE_IMAGE_LOAD( atarist_floppy )
2103{
2104   if (image_has_been_created(image))
2105      return INIT_FAIL;
2106
2107   if (device_load_basicdsk_floppy(image) == INIT_PASS)
2108   {
2109      UINT8 bootsector[512];
2110      image_fseek(image, 0, SEEK_SET);
2111
2112      if (image_fread(image, bootsector, 512))
2113      {
2114         int sectors = bootsector[0x18];
2115         int heads = bootsector[0x1a];
2116         int tracks = (bootsector[0x13] | (bootsector[0x14] << 8)) / sectors / heads;
2117
2118         /* drive, tracks, heads, sectors per track, sector length, first sector id, offset track zero, track skipping */
2119         basicdsk_set_geometry(image, tracks, heads, sectors, 512, 1, 0, FALSE);
2120
2121         return INIT_PASS;
2122      }
2123   }
2124
2125   return INIT_FAIL;
2126}
2127
21282102static void atarist_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
21292103{
21302104   /* floppy */
21312105   switch(state)
21322106   {
21332107      /* --- the following bits of info are returned as 64-bit signed integers --- */
2134      case MESS_DEVINFO_INT_COUNT:               info->i = 2; break;
2108      case MESS_DEVINFO_INT_COUNT:                     info->i = 2; break;
21352109
21362110      /* --- the following bits of info are returned as pointers to data or functions --- */
2137      case MESS_DEVINFO_PTR_LOAD:                  info->load = DEVICE_IMAGE_LOAD_NAME(atarist_floppy); break;
2111      case MESS_DEVINFO_PTR_FLOPPY_OPTIONS:            info->p = (void *) floppyoptions_atarist; break;
21382112
2139      /* --- the following bits of info are returned as NULL-terminated strings --- */
2140      case MESS_DEVINFO_STR_FILE_EXTENSIONS:         strcpy(info->s = device_temp_str(), "st"); break;
2141
2142      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
2113      default:                              floppy_device_getinfo(devclass, state, info); break;
21432114   }
21442115}
2145
21462116static DEVICE_IMAGE_LOAD( atarist_serial )
21472117{
21482118   /* filename specified */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team