annotate Plugins/Input/sexypsf/Misc.c @ 701:d539e5c5f730 trunk

[svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
author chainsaw
date Sun, 26 Feb 2006 13:08:35 -0800
parents f26682a2825b
children 61e7332e0652
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
1 /* Pcsx - Pc Psx Emulator
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
2 * Copyright (C) 1999-2002 Pcsx Team
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
3 *
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
7 * (at your option) any later version.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
8 *
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
12 * GNU General Public License for more details.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
13 *
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
17 */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
18
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
19 #include <stdio.h>
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
20 #include <string.h>
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
21 #include <stdlib.h>
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
22 #include <stdarg.h>
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
23
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
24 #include "PsxCommon.h"
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
25 #include "driver.h"
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
26
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
27 // LOAD STUFF
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
28
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
29 typedef struct {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
30 unsigned char id[8];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
31 u32 text;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
32 u32 data;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
33 u32 pc0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
34 u32 gp0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
35 u32 t_addr;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
36 u32 t_size;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
37 u32 d_addr;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
38 u32 d_size;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
39 u32 b_addr;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
40 u32 b_size;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
41 u32 S_addr;//normal must a s not a S but error (???)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
42 u32 s_size;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
43 u32 SavedSP;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
44 u32 SavedFP;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
45 u32 SavedGP;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
46 u32 SavedRA;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
47 u32 SavedS0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
48 } PACKSTRUCT EXE_HEADER;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
49
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
50 static long TimeToMS(const char *str)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
51 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
52 int x,c=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
53 int acc=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
54 char s[100];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
55
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
56 strncpy(s,str,100);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
57 s[99]=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
58
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
59 for(x=strlen(s);x>=0;x--)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
60 if(s[x]=='.' || s[x]==',')
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
61 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
62 acc=atoi(s+x+1);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
63 s[x]=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
64 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
65 else if(s[x]==':')
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
66 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
67 if(c==0) acc+=atoi(s+x+1)*10;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
68 else if(c==1) acc+=atoi(s+x+(x?1:0))*10*60;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
69 c++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
70 s[x]=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
71 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
72 else if(x==0)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
73 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
74 if(c==0) acc+=atoi(s+x)*10;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
75 else if(c==1) acc+=atoi(s+x)*10*60;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
76 else if(c==2) acc+=atoi(s+x)*10*60*60;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
77 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
78 acc*=100; // To milliseconds.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
79 return(acc);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
80 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
81
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
82 char *GetFileWithBase(char *f, char *newfile)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
83 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
84 static char *ret;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
85 char *tp1;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
86
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
87 #if PSS_STYLE==1
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
88 tp1=((char *)strrchr(f,'/'));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
89 #else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
90 tp1=((char *)strrchr(f,'\\'));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
91 #if PSS_STYLE!=3
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
92 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
93 char *tp3;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
94
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
95 tp3=((char *)strrchr(f,'/'));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
96 if(tp1<tp3) tp1=tp3;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
97 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
98 #endif
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
99 #endif
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
100 if(!tp1)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
101 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
102 ret=malloc(strlen(newfile)+1);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
103 strcpy(ret,newfile);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
104 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
105 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
106 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
107 ret=malloc(tp1-f+2+strlen(newfile)); // 1(NULL), 1(/).
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
108 memcpy(ret,f,tp1-f);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
109 ret[tp1-f]='/';
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
110 ret[tp1-f+1]=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
111 strcat(ret,newfile);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
112 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
113 return(ret);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
114 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
115
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
116 static int GetKeyVal(char *buf, char **key, char **val)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
117 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
118 char *tmp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
119
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
120 tmp=buf;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
121
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
122 /* First, convert any weirdo ASCII characters to spaces. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
123 while(*tmp++) if(*tmp>0 && *tmp<0x20) *tmp=0x20;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
124
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
125 /* Strip off white space off end of string(which should be the "value"). */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
126 for(tmp=buf+strlen(buf)-1;tmp>=buf;tmp--)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
127 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
128 if(*tmp != 0x20) break;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
129 *tmp=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
130 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
131
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
132 /* Now, search for the first non-whitespace character. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
133 while(*buf == 0x20) buf++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
134
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
135 tmp=buf;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
136 while((*buf != 0x20) && (*buf != '='))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
137 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
138 if(!*buf) return(0); /* Null character. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
139 buf++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
140 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
141
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
142 /* Allocate memory, copy string, and terminate string. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
143 if(!(*key=malloc(buf-tmp+1))) return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
144 strncpy(*key,tmp,buf-tmp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
145 (*key)[(buf-tmp)]=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
146
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
147 /* Search for "=" character. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
148 while(*buf != '=')
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
149 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
150 if(!*buf) return(0); /* Null character. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
151 buf++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
152 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
153
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
154 buf++; /* Skip over equals character. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
155
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
156 /* Remove leading whitespace on value. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
157 while(*buf == 0x20)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
158 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
159 if(!*buf) return(0); /* Null character. */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
160 buf++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
161 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
162
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
163 /* Allocate memory, and copy string over. Trailing whitespace was eliminated
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
164 earlier.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
165 */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
166
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
167 if(!(*val=malloc(strlen(buf)+1))) return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
168 strcpy(*val,buf);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
169
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
170 //puts(*key);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
171 //puts(*val);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
172
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
173 return(1);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
174 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
175
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
176 static void FreeTags(PSFTAG *tags)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
177 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
178 while(tags)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
179 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
180 PSFTAG *tmp=tags->next;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
181
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
182 free(tags->key);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
183 free(tags->value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
184 free(tags);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
185
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
186 tags=tmp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
187 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
188 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
189
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
190 static void AddKV(PSFTAG **tag, char *key, char *val)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
191 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
192 PSFTAG *tmp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
193
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
194 tmp=malloc(sizeof(PSFTAG));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
195 memset(tmp,0,sizeof(PSFTAG));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
196
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
197 tmp->key=key;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
198 tmp->value=val;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
199 tmp->next=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
200
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
201 if(!*tag) *tag=tmp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
202 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
203 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
204 PSFTAG *rec;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
205 rec=*tag;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
206 while(rec->next) rec=rec->next;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
207 rec->next=tmp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
208 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
209
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
210 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
211
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
212 typedef struct {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
213 int num;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
214 char *value;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
215 } LIBNCACHE;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
216
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
217 static int ccomp(const void *v1, const void *v2)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
218 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
219 const LIBNCACHE *a1,*a2;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
220 a1=v1; a2=v2;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
221
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
222 return(a1->num - a2->num);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
223 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
224
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
225 static PSFINFO *LoadPSF(char *path, int level, int type) // Type==1 for just info load.
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
226 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
227 FILE *fp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
228 EXE_HEADER tmpHead;
640
f26682a2825b [svn] Addresses most of the warnings in the code, and uses a -W CFLAG to disable the non-null checks. From external contributor Harald van Dijk (Gentoo).
chainsaw
parents: 335
diff changeset
229 unsigned char *in,*out=0;
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
230 u8 head[4];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
231 u32 reserved;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
232 u32 complen;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
233 u32 crc32;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
234 uLongf outlen;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
235 PSFINFO *psfi;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
236 PSFINFO *tmpi;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
237
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
238 if(!(fp=fopen(path,"rb")))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
239 {
335
e089ce1ba088 [svn] further paranoia (try to explain why the crash happened, if one happens -- as sexypsf explodes if it cant find the psflib)
nenolod
parents: 333
diff changeset
240 printf("path %s failed to load\n", path);
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
241 return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
242 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
243
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
244 fread(head,1,4,fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
245 if(memcmp(head,"PSF\x01",4)) return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
246
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
247 psfi=malloc(sizeof(PSFINFO));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
248 memset(psfi,0,sizeof(PSFINFO));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
249 psfi->stop=~0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
250 psfi->fade=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
251
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
252 fread(&reserved,1,4,fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
253 fread(&complen,1,4,fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
254 complen=BFLIP32(complen);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
255
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
256 fread(&crc32,1,4,fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
257 crc32=BFLIP32(crc32);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
258
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
259 fseek(fp,reserved,SEEK_CUR);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
260
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
261 if(type)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
262 fseek(fp,complen,SEEK_CUR);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
263 else
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
264 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
265 in=malloc(complen);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
266 out=malloc(1024*1024*2+0x800);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
267 fread(in,1,complen,fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
268 outlen=1024*1024*2;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
269 uncompress(out,&outlen,in,complen);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
270 free(in);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
271 memcpy(&tmpHead,out,sizeof(EXE_HEADER));
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
272 psxRegs.pc = BFLIP32(tmpHead.pc0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
273 psxRegs.GPR.n.gp = BFLIP32(tmpHead.gp0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
274 psxRegs.GPR.n.sp = BFLIP32(tmpHead.S_addr);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
275 if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
276
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
277 if(level)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
278 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
279 LoadPSXMem(BFLIP32(tmpHead.t_addr),BFLIP32(tmpHead.t_size),out+0x800);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
280 free(out);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
281 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
282 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
283
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
284 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
285 u8 tagdata[5];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
286 if(fread(tagdata,1,5,fp)==5)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
287 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
288 if(!memcmp(tagdata,"[TAG]",5))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
289 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
290 char linebuf[1024];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
291
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 640
diff changeset
292 while(fgets(linebuf,1024,fp))
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
293 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
294 int x;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
295 char *key=0,*value=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
296
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
297 if(!GetKeyVal(linebuf,&key,&value))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
298 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
299 if(key) free(key);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
300 if(value) free(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
301 continue;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
302 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
303
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
304 AddKV(&psfi->tags,key,value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
305
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
306 if(!level)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
307 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
308 static char *yoinks[8]={"title","artist","game","year","genre",
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
309 "copyright","psfby","comment"};
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
310 char **yoinks2[8]={&psfi->title,&psfi->artist,&psfi->game,&psfi->year,&psfi->genre,
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
311 &psfi->copyright,&psfi->psfby,&psfi->comment};
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
312 for(x=0;x<8;x++)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
313 if(!strcasecmp(key,yoinks[x]))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
314 *yoinks2[x]=value;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
315 if(!strcasecmp(key,"length"))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
316 psfi->stop=TimeToMS(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
317 else if(!strcasecmp(key,"fade"))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
318 psfi->fade=TimeToMS(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
319 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
320
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
321 if(!strcasecmp(key,"_lib") && !type)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
322 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
323 char *tmpfn;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
324 /* Load file name "value" from the directory specified in
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
325 the full path(directory + file name) "path"
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
326 */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
327 tmpfn=GetFileWithBase(path,value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
328 if(!(tmpi=LoadPSF(tmpfn,level+1,0)))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
329 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
330 free(key);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
331 free(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
332 free(tmpfn);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
333 if(!level) free(out);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
334 fclose(fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
335 FreeTags(psfi->tags);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
336 free(psfi);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
337 return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
338 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
339 FreeTags(tmpi->tags);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
340 free(tmpi);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
341 free(tmpfn);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
342 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
343 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
344 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
345 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
346 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
347
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
348 fclose(fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
349
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
350 /* Now, if we're at level 0(main PSF), load the main executable, and any libN stuff */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
351 if(!level && !type)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
352 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
353 LoadPSXMem(BFLIP32(tmpHead.t_addr),BFLIP32(tmpHead.t_size),out+0x800);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
354 free(out);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
355 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
356
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
357 if(!type) /* Load libN */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
358 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
359 LIBNCACHE *cache;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
360 PSFTAG *tag;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
361 unsigned int libncount=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
362 unsigned int cur=0;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
363
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
364 tag=psfi->tags;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
365 while(tag)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
366 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
367 if(!strncasecmp(tag->key,"_lib",4) && tag->key[4])
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
368 libncount++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
369 tag=tag->next;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
370 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
371
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
372 if(libncount)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
373 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
374 cache=malloc(sizeof(LIBNCACHE)*libncount);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
375
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
376 tag=psfi->tags;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
377 while(tag)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
378 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
379 if(!strncasecmp(tag->key,"_lib",4) && tag->key[4])
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
380 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
381 cache[cur].num=atoi(&tag->key[4]);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
382 cache[cur].value=tag->value;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
383 cur++;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
384 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
385 tag=tag->next;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
386 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
387 qsort(cache, libncount, sizeof(LIBNCACHE), ccomp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
388 for(cur=0;cur<libncount;cur++)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
389 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
390 u32 ba[3];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
391 char *tmpfn;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
392
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
393 if(cache[cur].num < 2) continue;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
394
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
395 ba[0]=psxRegs.pc;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
396 ba[1]=psxRegs.GPR.n.gp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
397 ba[2]=psxRegs.GPR.n.sp;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
398
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
399 /* Load file name "value" from the directory specified in
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
400 the full path(directory + file name) "path"
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
401 */
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
402 tmpfn=GetFileWithBase(path,cache[cur].value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
403 if(!(tmpi=LoadPSF(tmpfn,level+1,0)))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
404 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
405 //free(key);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
406 //free(value);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
407 //free(tmpfn);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
408 //fclose(fp);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
409 //return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
410 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
411 free(tmpfn);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
412 FreeTags(tmpi->tags);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
413 free(tmpi);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
414
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
415 psxRegs.pc=ba[0];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
416 psxRegs.GPR.n.gp=ba[1];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
417 psxRegs.GPR.n.sp=ba[2];
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
418 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
419 free(cache);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
420
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
421 } // if(libncount)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
422
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
423 } // if(!type)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
424
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
425 return(psfi);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
426 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
427
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
428 void sexypsf_freepsfinfo(PSFINFO *info)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
429 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
430 FreeTags(info->tags);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
431 free(info);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
432 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
433
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
434 PSFINFO *sexypsf_getpsfinfo(char *path)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
435 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
436 PSFINFO *ret;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
437 if(!(ret=LoadPSF(path,0,1))) return(0);
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 640
diff changeset
438 if(ret->stop==(u32)~0) ret->fade=0;
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
439 ret->length=ret->stop+ret->fade;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
440 return(ret);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
441 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
442
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
443 PSFINFO *sexypsf_load(char *path)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
444 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
445 PSFINFO *ret;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
446
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
447 psxInit();
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
448 psxReset();
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
449
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
450 SPUinit();
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
451 SPUopen();
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
452
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
453 if(!(ret=LoadPSF(path,0,0)))
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
454 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
455 psxShutdown();
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
456 return(0);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
457 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
458
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 640
diff changeset
459 if(ret->stop==(u32)~0) ret->fade=0; // Infinity+anything is still infinity...or is it?
333
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
460 SPUsetlength(ret->stop,ret->fade);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
461 ret->length=ret->stop+ret->fade;
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
462
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
463 return(ret);
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
464 }
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
465
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
466 void sexypsf_execute(void)
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
467 {
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
468 psxCpu->Execute();
42cdc99e395a [svn] Now that the build system is ready, upload the plugin code.
chainsaw
parents:
diff changeset
469 }