~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/lib/formats/cpis_dsk.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*********************************************************************
2
 
 
3
 
    formats/cpis_dsk.c
4
 
 
5
 
    Telenova Compis disk images
6
 
 
7
 
*********************************************************************/
8
 
 
9
 
#include <string.h>
10
 
 
11
 
#include "formats/cpis_dsk.h"
12
 
#include "formats/basicdsk.h"
13
 
 
14
 
 
15
 
static int compis_get_tracks_and_sectors(floppy_image *floppy, int *tracks, int *sectors)
16
 
{
17
 
        switch(floppy_image_size(floppy)) {
18
 
        case 0x50000:   /* 320 KB */
19
 
                *tracks = 40;
20
 
                *sectors = 8;
21
 
                break;
22
 
 
23
 
        case 0x5a000:   /* 360 KB */
24
 
                *tracks = 40;
25
 
                *sectors = 9;
26
 
                break;
27
 
 
28
 
        case 0xa0000:   /* 640 KB */
29
 
                *tracks = 80;
30
 
                *sectors = 8;
31
 
                break;
32
 
 
33
 
        case 0xb4000:   /* 720 KB */
34
 
                *tracks = 80;
35
 
                *sectors = 9;
36
 
                break;
37
 
 
38
 
        case 0x12c000:  /* 1200 KB */
39
 
                *tracks = 80;
40
 
                *sectors = 15;
41
 
                break;
42
 
 
43
 
        default:
44
 
                return 0;
45
 
        }
46
 
        return 1;
47
 
}
48
 
 
49
 
 
50
 
 
51
 
static FLOPPY_IDENTIFY(compis_dsk_identify)
52
 
{
53
 
        int dummy;
54
 
        *vote = compis_get_tracks_and_sectors(floppy, &dummy, &dummy) ? 100 : 0;
55
 
        return FLOPPY_ERROR_SUCCESS;
56
 
}
57
 
 
58
 
 
59
 
 
60
 
static FLOPPY_CONSTRUCT(compis_dsk_construct)
61
 
{
62
 
        struct basicdsk_geometry geometry;
63
 
 
64
 
        memset(&geometry, 0, sizeof(geometry));
65
 
        geometry.heads = 1;
66
 
        geometry.first_sector_id = 1;
67
 
        geometry.sector_length = 512;
68
 
 
69
 
        if (params)
70
 
        {
71
 
                /* create */
72
 
                geometry.tracks = option_resolution_lookup_int(params, PARAM_TRACKS);
73
 
                geometry.sectors = option_resolution_lookup_int(params, PARAM_SECTORS);
74
 
        }
75
 
        else
76
 
        {
77
 
                /* open */
78
 
                if (!compis_get_tracks_and_sectors(floppy, &geometry.tracks, &geometry.sectors))
79
 
                        return FLOPPY_ERROR_INVALIDIMAGE;
80
 
        }
81
 
 
82
 
        return basicdsk_construct(floppy, &geometry);
83
 
}
84
 
 
85
 
 
86
 
 
87
 
/* ----------------------------------------------------------------------- */
88
 
 
89
 
FLOPPY_OPTIONS_START( compis )
90
 
        FLOPPY_OPTION( compis_dsk, "dsk",               "Compis floppy disk image",     compis_dsk_identify, compis_dsk_construct, NULL,
91
 
                TRACKS(40/[80])
92
 
                SECTORS(8/[9]/15))
93
 
FLOPPY_OPTIONS_END