Mercurial > hg > sidinfo
annotate sidlib.h @ 86:e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Needs refactoring.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 11 Feb 2016 23:21:26 +0200 |
parents | 4c0ecb078591 |
children | c5ff71d64e53 |
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 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Written by Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
73
2b2376f1b0cc
Update copyright years. Yay. It's 2016!
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
4 * (C) Copyright 2014-2016 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 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 // Some constants |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 #define PSID_MAGIC_LEN 4 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 #define PSID_STR_LEN 32 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 #define 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
|
23 #define PSID_BUFFER2_SIZE (1024) |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
24 |
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 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
|
27 { |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 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
|
32 } SIDLibSLDBNode; |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
33 |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
34 |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
35 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
|
36 { |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
37 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
|
38 **pindex; |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
39 size_t n; |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
40 } SIDLibSLDB; |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 typedef struct |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 { |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 char magic[PSID_MAGIC_LEN + 1]; // "PSID" / "RSID" magic identifier |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 uint16_t |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 version, // Version number |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 dataOffset, // Start of actual c64 data in file |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 loadAddress, // Loading address |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 initAddress, // Initialization address |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 playAddress, // Play one frame |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 nSongs, // Number of subsongs |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 startSong; // Default starting song |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 uint32_t speed; // Speed |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 char sidName[PSID_STR_LEN + 1]; // Descriptive text-fields, ASCIIZ |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 char sidAuthor[PSID_STR_LEN + 1]; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 char sidCopyright[PSID_STR_LEN + 1]; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 // PSIDv2 data |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 uint16_t flags; // Flags |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 uint8_t startPage, pageLength; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 uint16_t reserved; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 // Extra data |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 BOOL isRSID; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 size_t dataSize; // Total size of data - header |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 th_md5hash_t hash; // Songlength database hash |
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 } PSIDHeader; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 enum |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 { |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 PSF_PLAYER_TYPE = 0x0001, // 0 = built-in, 1 = Compute! SIDPlayer MUS |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 PSF_PLAYSID_TUNE = 0x0002, // 0 = Real C64-compatible, 1 = PlaySID specific (v2NG) |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 PSF_CLOCK_UNKNOWN = 0x0000, // Video standard used (v2NG) |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 PSF_CLOCK_PAL = 0x0004, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 PSF_CLOCK_NTSC = 0x0008, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 PSF_CLOCK_ANY = 0x000c, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 PSF_CLOCK_MASK = 0x000c, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 PSF_MODEL_UNKNOWN = 0x0000, // SID model (v2NG) |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 PSF_MODEL_MOS6581 = 0x0010, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 PSF_MODEL_MOS8580 = 0x0020, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 PSF_MODEL_ANY = 0x0030, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 PSF_MODEL_MASK = 0x0030, |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 }; |
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 |
74 | 90 |
91 // | |
92 // Functions | |
93 // | |
85
4c0ecb078591
Rename various variables and functions and change relevant places to use the
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
94 int si_read_sid_file(th_ioctx *ctx, PSIDHeader *psid); |
74 | 95 |
85
4c0ecb078591
Rename various variables and functions and change relevant places to use the
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
96 const char * si_get_sid_clock_str(const int flags); |
4c0ecb078591
Rename various variables and functions and change relevant places to use the
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
97 const char * si_get_sid_model_str(const int flags); |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 |
86
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
99 int si_sldb_read(th_ioctx *ctx, SIDLibSLDB *dbh); |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
100 int si_sldb_build_index(SIDLibSLDB *dbh); |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
101 void si_sldb_free(SIDLibSLDB *dbh); |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
102 SIDLibSLDBNode *si_sldb_get_by_hash(SIDLibSLDB *dbh, th_md5hash_t hash); |
e1ff9cd27a84
Initial port of songlength database (SLDB) handling code from XMMS-SID to here.
Matti Hamalainen <ccr@tnsp.org>
parents:
85
diff
changeset
|
103 |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 |
72 | 105 #ifdef __cplusplus |
106 } | |
107 #endif | |
70
4779bbec2f28
Split some functionality into sidlib.[ch].
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 #endif // SIDLIB_H |