summaryrefslogtreecommitdiff
path: root/libsidplay2/sidplay-libs-2.1.0/libsidutils/src/smm0.h
blob: fca6109270ac809b1c8ed3331f71a94722414ab0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
                          smm0.h  -  sidusage file support
                             -------------------
    begin                : Tues Nov 19 2002
    copyright            : (C) 2002 by Simon White
    email                : sidplay2@yahoo.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _smm0_h_
#define _smm0_h_

#include <string.h>

// IFF IDs
#define BUILD_ID(a, b, c, d) ((uint) a << 24 | \
                              (uint) b << 16 | \
                              (uint) c << 8  | \
                              (uint) d)

#define FORM_ID BUILD_ID('F','O','R','M')
#define SMM0_ID BUILD_ID('S','M','M','0')
#define INF0_ID BUILD_ID('I','N','F','0')
#define ERR0_ID BUILD_ID('E','R','R','0')
#define TIME_ID BUILD_ID('T','I','M','E')
#define MD5_ID  BUILD_ID('M','D','5',' ')
#define BODY_ID BUILD_ID('B','O','D','Y')

// Future Versions
#define SMM1_ID BUILD_ID('S','M','M','1')
#define SMM2_ID BUILD_ID('S','M','M','2')
#define SMM3_ID BUILD_ID('S','M','M','3')
#define SMM4_ID BUILD_ID('S','M','M','4')
#define SMM5_ID BUILD_ID('S','M','M','5')
#define SMM6_ID BUILD_ID('S','M','M','6')
#define SMM7_ID BUILD_ID('S','M','M','7')
#define SMM8_ID BUILD_ID('S','M','M','8')
#define SMM9_ID BUILD_ID('S','M','M','9')

struct Chunk
{
    uint_least32_t length;
};

struct IffHeader: public Chunk
{
    uint8_t type[4]; // Should be SMM0

    IffHeader()
    {
        memset (this, 0, sizeof (IffHeader));
        length = sizeof(IffHeader) - sizeof(Chunk);
    }
};

struct Inf_v0: public Chunk
{
    uint8_t startAddr[2];
    uint8_t stopAddr[2];

    Inf_v0()
    {
        memset (this, 0, sizeof (Inf_v0));
        length = sizeof(Inf_v0) - sizeof(Chunk);
    }
};

struct Err_v0: public Chunk
{
    uint8_t flags[2];

    Err_v0()
    {
        memset (this, 0, sizeof (Err_v0));
        length = sizeof(Err_v0) - sizeof(Chunk);
    }
};

struct Md5: public Chunk
{
    uint8_t key[32];

    Md5()
    {
        memset (this, 0, sizeof (Md5));
        length = sizeof(Md5) - sizeof(Chunk);
    }
};

struct Time: public Chunk
{
    uint8_t stamp[2];

    Time()
    {
        memset (this, 0, sizeof (Time));
        length = sizeof(Time) - sizeof(Chunk);
    }
};

struct Body: public Chunk
{
    struct usage
    {
      uint8_t page;
      uint8_t flags[256];
    } usage[256];

    Body()
    {   // Don't set length as is variable
        memset (this, 0, sizeof (Body));
    }
};

struct Smm_v0
{
    IffHeader header;
    Inf_v0    info;
    Err_v0    error;
    Md5       md5;
    Time      time;
    Body      body;
};

#endif // _smm0_h_