annotate src/sap/sapfile.c @ 156:f52e866d7d8e trunk

[svn] - use user-friendly names in most places
author nenolod
date Tue, 31 Oct 2006 12:35:04 -0800
parents 7804476ba85a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
142
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
1 /*
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
2 * SAP xmms plug-in.
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
3 * Copyright 2002/2003 by Michal 'Mikey' Szwaczko <mikey@scene.pl>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
4 *
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
5 * SAP Library ver. 1.56 by Adam Bienias
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
6 *
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
7 * This is free software. You can modify it and distribute it under the terms
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
8 * of the GNU General Public License. The verbatim text of the license can
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
9 * be found in file named COPYING in the source directory.
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
10 *
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
12 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
13 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
14 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
15 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
16 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
17 * OTHER DEALINGS IN THE SOFTWARE.
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
18 *
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
19 */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
20 #include <stdio.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
21 #include <stdlib.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
22 #include <sys/types.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
23 #include <sys/stat.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
24 #include <fcntl.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
25 #include <unistd.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
26 #include <string.h>
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
27
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
28 #include "sapfile.h"
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
29
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
30 int load_sap (char *fname) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
31
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
32 struct stat st;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
33 int i, k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
34
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
35 FILE *f;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
36
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
37 /* flush static buffers */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
38
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
39 memset(author, 0, 2048);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
40 memset(name, 0, 2048);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
41 memset(date, 0, 2048);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
42 memset(type, 0, 20);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
43
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
44 /* get filesize */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
45
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
46 if (stat(fname, &st) < 0)
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
47
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
48 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
49
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
50 filesize = st.st_size;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
51
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
52 /* open & read file into buffer */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
53
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
54 f = fopen(fname, "rb");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
55
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
56 if ( !f )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
57
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
58 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
59
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
60 fread(buffer, 1, filesize, f);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
61
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
62 fclose(f);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
63
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
64 /* check if it is a sap file */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
65
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
66 if (strncmp(buffer, "SAP", 3) != 0 )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
67
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
68 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
69
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
70 /* set headersize */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
71
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
72 for (i = 0; i < filesize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
73
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
74 if (buffer[i] == '\xFF' ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
75
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
76 headersize = i;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
77 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
78 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
79
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
80 if (buffer[i] != '\xFF' && i == filesize-1)
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
81
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
82 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
83 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
84
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
85 /* sanity checking done - parse the info tags
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
86 please someone rewrite this !!! :)
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
87 this code sux0r ... */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
88
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
89 /* check for author */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
90
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
91 k = 0;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
92
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
93 for (i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
94
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
95 if (strncmp(buffer + i, "AUTHOR", 6) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
96
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
97 i = i + 8;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
98
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
99 while (buffer[i] != '"' && buffer[i] != 0x0D && buffer[i] != 0x0A) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
100
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
101 author[k] = buffer[i];
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
102 k++; i++;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
103 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
104 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
105 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
106 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
107 sprintf(author, "%s", "");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
108 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
109
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
110 /* check for name */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
111
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
112 k = 0;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
113
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
114 for (i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
115
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
116 if ( strncmp(buffer + i, "NAME", 4) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
117
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
118 i = i + 6;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
119
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
120 while (buffer[i] != '"' && buffer[i] != 0x0D && buffer[i] != 0x0A) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
121
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
122 name[k] = buffer[i];
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
123 k++; i++;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
124 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
125 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
126 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
127 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
128 sprintf(name, "%s", "");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
129 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
130
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
131 /* check for date */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
132
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
133 k = 0;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
134
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
135 for(i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
136
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
137 if (strncmp(buffer + i, "DATE", 4) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
138
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
139 i = i + 6;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
140
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
141 while (buffer[i] != '"' && buffer[i] != 0x0D && buffer[i] != 0x0A) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
142
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
143 date[k] = buffer[i];
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
144 k++; i++;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
145 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
146 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
147 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
148 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
149 sprintf(date, "%s", "");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
150 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
151
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
152
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
153 /* check for stereo */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
154
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
155 for (i = 0; i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
156
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
157 if (strncmp(buffer + i, "STEREO", 6) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
158
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
159 is_stereo = 1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
160 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
161 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
162 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
163 is_stereo = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
164 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
165
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
166 /* check fastplay; */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
167
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
168 for (i = 0; i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
169
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
170 if (strncmp(buffer + i, "FASTPLAY", 8) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
171
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
172 k = strtol(&buffer[i + 1 + 8], NULL, 10);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
173
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
174 if ( k == 0 || k > 312 )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
175
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
176 /* illegal fastplay value */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
177 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
178
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
179 else
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
180
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
181 fastplay = k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
182
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
183 switch (k) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
184
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
185 case 156:
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
186
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
187 times_per_frame = 2;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
188 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
189
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
190 case 104:
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
191
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
192 times_per_frame = 3;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
193 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
194
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
195 case 78:
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
196
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
197 times_per_frame = 4;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
198 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
199
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
200 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
201 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
202 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
203 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
204 fastplay = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
205 times_per_frame = 1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
206 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
207
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
208 /* check songs */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
209 for (i = 0; i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
210
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
211 if (strncmp(buffer + i, "SONGS", 5) == 0) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
212
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
213 k = strtol(&buffer[i + 1 + 5], NULL, 10);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
214
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
215 if ( (k == 0) || (k > 0xffff) )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
216 /* illegal songs value */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
217 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
218 else
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
219
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
220 songs = k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
221 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
222 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
223 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
224 songs = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
225 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
226
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
227 /* check defsong */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
228 for (i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
229
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
230 if (strncmp(buffer + i, "DEFSONG", 7) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
231
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
232 k = strtol(&buffer[i + 1 + 7], NULL, 10);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
233
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
234 if ( (k < 0) || (k > 0xffff) )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
235 /* illegal defsong value */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
236 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
237
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
238 else
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
239
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
240 defsong = k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
241 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
242 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
243 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
244 defsong = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
245 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
246
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
247
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
248 /* check songtype */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
249 for (i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
250
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
251 if (strncmp(buffer + i, "TYPE", 4) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
252
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
253 i = i + 5;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
254
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
255 if (buffer[i] == 'B') {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
256 /* SAP documentation says
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
257 "any player" */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
258 sprintf(type, "Standard");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
259 type_h = 'B';
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
260 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
261 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
262
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
263 if (buffer[i] == 'S') {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
264
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
265 sprintf(type, "SoftSynth");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
266 type_h = 'S';
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
267 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
268 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
269
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
270 if (buffer[i] == 'D') {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
271
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
272 sprintf(type, "DigiSynth");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
273 type_h = 'D';
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
274 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
275 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
276
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
277 if (buffer[i] == 'C') {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
278
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
279 sprintf(type, "CMC Synth");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
280 type_h= 'C';
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
281 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
282 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
283
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
284 if (buffer[i] == 'M') {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
285 /* unsupported (?) */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
286 sprintf(type, "M-Type");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
287 type_h = 'M';
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
288 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
289 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
290
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
291 if (buffer[i] == 'R') {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
292 /* this is unsupported - perhaps we */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
293 /* should return -1 as for now */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
294 sprintf(type, "Regs");
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
295 type_h = 'R';
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
296 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
297 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
298 /* unsupported songtype */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
299 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
300 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
301 /* no type specified */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
302 if (i == headersize - 1) return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
303
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
304 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
305
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
306 /* msx_address */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
307 for (i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
308
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
309 if (strncmp(buffer + i, "MUSIC", 5) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
310
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
311 k = strtol(&buffer[i + 1 + 5], NULL, 16);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
312
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
313 if ( (k == 0) || (k > 0xffff) )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
314 /* illegal address */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
315 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
316 else
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
317
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
318 msx_address = k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
319 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
320 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
321 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
322 msx_address = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
323 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
324
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
325 /* ini address */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
326 for (i = 0;i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
327
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
328 if (strncmp(buffer + i, "INIT", 4) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
329
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
330 k = strtol(&buffer[i + 1 + 4], NULL, 16);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
331
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
332 if ( (k == 0) || (k > 0xffff) )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
333 /* illegal address */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
334 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
335 else
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
336
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
337 ini_address = k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
338 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
339 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
340 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
341 ini_address = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
342 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
343 /* player */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
344 for (i = 0; i < headersize; i++) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
345
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
346 if (strncmp(buffer + i,"PLAYER", 6) == 0 ) {
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
347
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
348 k = strtol(&buffer[i + 1 + 6], NULL, 16);
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
349
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
350 if ( (k == 0) || (k > 0xffff) )
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
351 /* illegal */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
352 return -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
353 else
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
354
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
355 plr_address = k;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
356 break;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
357 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
358 /* notfound */
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
359 plr_address = -1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
360 }
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
361
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
362 return 1;
c0b31cf2c7cd [svn] Atari XL SAP. This compiles anything but cleanly, but somehow still
asheldon
parents:
diff changeset
363 }