Mercurial > hg > sidinfo
annotate sidlib.h @ 223:a76276ff7ba8
Rename PSID_* constant defines to SIDLIB_PSID_*.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Dec 2019 12:15:51 +0200 |
parents | 3a01518fffe0 |
children | 4bec78f45188 |
rev | line source |
---|---|
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * SIDInfoLib - Way too simplistic PSID/RSID file library |
171
d86ade7d0dfd
Change copyright blurbs slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
214 | 4 * (C) Copyright 2014-2019 Tecnic Software productions (TNSP) |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 */ |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 #ifndef SIDLIB_H |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #define SIDLIB_H 1 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include "th_util.h" |
85
4c0ecb078591
Rename various variables and functions and change relevant places to use the
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
10 #include "th_ioctx.h" |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 #include "th_crypto.h" |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 |
85
4c0ecb078591
Rename various variables and functions and change relevant places to use the
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
13 |
72 | 14 #ifdef __cplusplus |
15 extern "C" { | |
16 #endif | |
17 | |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
220 | 19 // |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 // Some constants |
220 | 21 // |
223
a76276ff7ba8
Rename PSID_* constant defines to SIDLIB_PSID_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
22 #define SIDLIB_PSID_MAGIC_LEN 4 |
a76276ff7ba8
Rename PSID_* constant defines to SIDLIB_PSID_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
23 #define SIDLIB_PSID_STR_LEN 32 |
a76276ff7ba8
Rename PSID_* constant defines to SIDLIB_PSID_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
24 #define SIDLIB_PSID_BUFFER_SIZE (1024 * 16) |
86
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
25 |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
26 |
220 | 27 enum |
28 { | |
29 // Player flags | |
30 PSF_PLAYER_TYPE = 0x01, // 0 = built-in, 1 = Compute! SIDPlayer MUS | |
31 PSF_PLAYSID_TUNE = 0x02, // 0 = Real C64-compatible, 1 = PlaySID specific (v2NG) | |
32 | |
33 // Video standard used (v2NG+) | |
34 PSF_CLOCK_UNKNOWN = 0x00, | |
35 PSF_CLOCK_PAL = 0x01, | |
36 PSF_CLOCK_NTSC = 0x02, | |
37 PSF_CLOCK_ANY = 0x03, | |
38 PSF_CLOCK_MASK = 0x03, | |
39 | |
40 // SID model (v2NG+) | |
41 PSF_MODEL_UNKNOWN = 0x00, | |
42 PSF_MODEL_MOS6581 = 0x01, | |
43 PSF_MODEL_MOS8580 = 0x02, | |
44 PSF_MODEL_ANY = 0x03, | |
45 PSF_MODEL_MASK = 0x03, | |
46 }; | |
47 | |
48 | |
49 // | |
50 // Structures | |
51 // | |
86
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
52 typedef struct _SIDLibSLDBNode |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
53 { |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
54 th_md5hash_t hash; // MD5 hash-digest |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
55 int nlengths; // Number of lengths |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
56 int *lengths; // Lengths in seconds |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
57 struct _SIDLibSLDBNode *prev, *next; |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
58 } SIDLibSLDBNode; |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
59 |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
60 |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
61 typedef struct |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
62 { |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
63 SIDLibSLDBNode *nodes, |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
64 **pindex; |
100 | 65 size_t nnodes; |
86
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
66 } SIDLibSLDB; |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 typedef struct |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 { |
223
a76276ff7ba8
Rename PSID_* constant defines to SIDLIB_PSID_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
222
diff
changeset
|
71 char magic[SIDLIB_PSID_MAGIC_LEN + 1]; // "PSID" / "RSID" magic identifier |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 uint16_t |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 version, // Version number |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 dataOffset, // Start of actual c64 data in file |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 loadAddress, // Loading address |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 initAddress, // Initialization address |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 playAddress, // Play one frame |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 nSongs, // Number of subsongs |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 startSong; // Default starting song |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 uint32_t speed; // Speed |
128
2636185649c6
Add si_fread_str() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
81 char *sidName; // Descriptive text-fields, ASCIIZ |
2636185649c6
Add si_fread_str() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
82 char *sidAuthor; |
2636185649c6
Add si_fread_str() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
83 char *sidCopyright; |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 |
144 | 85 // PSIDv2+ data |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 uint16_t flags; // Flags |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 uint8_t startPage, pageLength; |
133
9cfa0553e7f9
Add support for reading PSID/RSID v4 in sidlib.
Matti Hamalainen <ccr@tnsp.org>
parents:
132
diff
changeset
|
88 uint8_t sid2Addr, sid3Addr; |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 // Extra data |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 BOOL isRSID; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 size_t dataSize; // Total size of data - header |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 th_md5hash_t hash; // Songlength database hash |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 |
88
c5ff71d64e53
More work on sidlib SLDB code.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
95 SIDLibSLDBNode *lengths; // Songlength information node pointer |
c5ff71d64e53
More work on sidlib SLDB code.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
96 |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 } PSIDHeader; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 |
74 | 100 // |
101 // Functions | |
102 // | |
222
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
103 BOOL sidlib_read_sid_file(th_ioctx *ctx, PSIDHeader **ppsid, const BOOL newSLDB); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
104 void sidlib_free_sid_file(PSIDHeader *psid); |
74 | 105 |
222
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
106 const char * sidlib_get_sid_clock_str(const int flags); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
107 const char * sidlib_get_sid_model_str(const int flags); |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 |
222
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
109 SIDLibSLDB * sidlib_sldb_new(void); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
110 int sidlib_sldb_read(th_ioctx *ctx, SIDLibSLDB *dbh); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
111 int sidlib_sldb_build_index(SIDLibSLDB *dbh); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
112 void sidlib_sldb_free(SIDLibSLDB *dbh); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
113 SIDLibSLDBNode * sidlib_sldb_get_by_hash(SIDLibSLDB *dbh, th_md5hash_t hash); |
86
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
114 |
222
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
115 int sidlib_sldb_read_bin(th_ioctx *ctx, SIDLibSLDB *dbh); |
3a01518fffe0
Rename sidlib functions from si_* prefix to sidlib_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
116 int sidlib_sldb_write_bin(th_ioctx *ctx, const SIDLibSLDB *dbh); |
101
9d4d1783800b
Add si_sldb_{read,write}_bin() functions to write and read a binary format
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
117 |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 |
72 | 119 #ifdef __cplusplus |
120 } | |
121 #endif | |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 #endif // SIDLIB_H |