1 /*
2 
3 Copyright 2021, dettus@dettus.net
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9    list of conditions and the following disclaimer.
10 
11 2. Redistributions in binary form must reproduce the above copyright notice,
12    this list of conditions and the following disclaimer in the documentation
13    and/or other materials provided with the distribution.
14 
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 
27 */
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include "dMagnetic_helpscreens.h"
32 #include "dMagnetic_pathnames.h"
33 #include "version.h"
34 
35 #define	NUMGAMES	7
36 #define	NUMPLATFORMS	10
37 
38 #define	PLATFORM_MAG		(1<<0)
39 #define	PLATFORM_GFX		(1<<1)
40 #define	PLATFORM_MSDOS		(1<<2)
41 #define	PLATFORM_TWORSC		(1<<3)
42 #define	PLATFORM_D64		(1<<4)
43 #define	PLATFORM_AMSTRADCPC	(1<<5)
44 #define	PLATFORM_SPECTRUM	(1<<6)
45 #define	PLATFORM_ARCHIMEDES	(1<<7)
46 #define	PLATFORM_ATARIXL	(1<<8)
47 #define	PLATFORM_APPLEII	(1<<9)
48 
49 typedef	struct _tPlatformInfo
50 {
51 	char* name;
52 	char* dir;
53 	char* suffix;
54 	char uppercase;
55 	char special;
56 	int disksexpected;	// some games require komma seperated names for the images. PAWN1.D64,PAWN2.D64, for example
57 	int active;
58 	unsigned short mask;
59 	char *cmdline;
60 } tPlatformInfo;
61 typedef struct _tGameInfo
62 {
63 	char *name;
64 	char *description;
65 	char *maggfxname;
66 	int disknum;
67 	int special;
68 	char *specialPrefix;
69 	unsigned short ported;
70 } tGameInfo;
71 
72 const tPlatformInfo	cdMagnetic_platformInfo[NUMPLATFORMS]={
73 	{"mag",		PATH_USR_LOCAL_SHARE_GAMES"magneticscrolls/",	".mag"	,0,0,1,1,	PLATFORM_MAG,		"-mag MAGFILE.mag"},
74 	{"gfx",		PATH_USR_LOCAL_SHARE_GAMES"magneticscrolls/",	".gfx"	,0,0,1,1,	PLATFORM_GFX,		"-gfx GFXFILE.gfx"},
75 	{"msdos",	"/MSDOS/C/",					""	,1,0,1,0,	PLATFORM_MSDOS,		"-msdosdir DIRECTORY/"},
76 	{"tworsc",	PATH_USR_LOCAL_SHARE"games/",			"TWO.RSC",0,1,1,0,	PLATFORM_TWORSC,	"-tworsc DIRECTORY/TWO.RSC"},
77 	{"d64",		"/8/",						".D64"	,1,0,2,0,	PLATFORM_D64,		"-d64 IMAGE1.d64,IMAGE2.d64"},
78 	{"amstradcpc",	"/dsk/amstradcpc/",				".DSK"	,1,0,2,0,	PLATFORM_AMSTRADCPC,	"-amstradcpc IMAGE1.DSK,IMAGE2.DSK"},
79 	{"spectrum",	"/dsk/spectrum/",				".DSK"	,0,0,1,0,	PLATFORM_SPECTRUM,	"-spectrum IMAGE.DSK"},
80 	{"archimedes",	"/adf/",					".adf"	,0,0,1,0,	PLATFORM_ARCHIMEDES,	"-archimedes IMAGE.adf"},
81 	{"atarixl",	"/atr/",					".ATR"	,1,0,2,0,	PLATFORM_ATARIXL,	"-atarixl IMAGE1.atr,IMAGE2.atr"},
82 	{"appleii",	"/appleii/",					".NIB"	,1,0,3,0,	PLATFORM_APPLEII,	"-appleii IMAGE1.NIB,IMAGE2.NIB,IMAGE3.NIB"}
83 };
84 const tGameInfo		cdMagnetic_gameInfo[NUMGAMES]={
85 	{"pawn",	"The Pawn",		"pawn",		2,0,""			,PLATFORM_MAG|PLATFORM_GFX|PLATFORM_MSDOS|PLATFORM_D64|PLATFORM_AMSTRADCPC|PLATFORM_SPECTRUM|PLATFORM_ARCHIMEDES|PLATFORM_ATARIXL                |PLATFORM_APPLEII},
86 	{"guild",	"The Guild of Thieves",	"guild",	2,1,"MSC/G"		,PLATFORM_MAG|PLATFORM_GFX|PLATFORM_MSDOS|PLATFORM_D64|PLATFORM_AMSTRADCPC|PLATFORM_SPECTRUM|PLATFORM_ARCHIMEDES|PLATFORM_ATARIXL|PLATFORM_TWORSC|PLATFORM_APPLEII},
87 	{"jinxter",	"Jinxter",		"jinxter",	2,0,""			,PLATFORM_MAG|PLATFORM_GFX|PLATFORM_MSDOS|PLATFORM_D64|PLATFORM_AMSTRADCPC|PLATFORM_SPECTRUM|PLATFORM_ARCHIMEDES|PLATFORM_ATARIXL                |PLATFORM_APPLEII},
88 	{"corruption",	"Corruption",		"corrupt",	3,1,"MSC/C"		,PLATFORM_MAG|PLATFORM_GFX|PLATFORM_MSDOS|PLATFORM_D64|PLATFORM_AMSTRADCPC|PLATFORM_SPECTRUM|PLATFORM_ARCHIMEDES                 |PLATFORM_TWORSC|PLATFORM_APPLEII},
89 	{"fish",	"Fish!",		"fish",		2,1,"MSC/F"		,PLATFORM_MAG|PLATFORM_GFX|PLATFORM_MSDOS|PLATFORM_D64|PLATFORM_AMSTRADCPC|PLATFORM_SPECTRUM|PLATFORM_ARCHIMEDES                 |PLATFORM_TWORSC},
90 	{"myth",	"Myth",			"myth",		1,0,""			,PLATFORM_MAG|PLATFORM_GFX|PLATFORM_MSDOS|PLATFORM_D64|PLATFORM_AMSTRADCPC|PLATFORM_SPECTRUM                                                     },
91 	{"wonderland",	"Wonderland",		"wonder",	1,1,"wonderland/"	,PLATFORM_MAG|PLATFORM_GFX                                                                                                       |PLATFORM_TWORSC},
92 };
93 
dMagnetic_helpscreens_header()94 void dMagnetic_helpscreens_header()
95 {
96 	fprintf(stderr,"*** dMagnetic %d.%d%d\n",VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION);
97 	fprintf(stderr,"*** Use at your own risk\n");
98 	fprintf(stderr,"*** (C)opyright 2021 by dettus@dettus.net\n");
99 	fprintf(stderr,"*****************************************\n");
100 	fprintf(stderr,"\n");
101 }
dMagnetic_helpscreens_license()102 void dMagnetic_helpscreens_license()
103 {
104 	printf("Copyright 2021, dettus@dettus.net\n");
105 	printf("\n");
106 	printf("Redistribution and use in source and binary forms, with or without modification,\n");
107 	printf("are permitted provided that the following conditions are met:\n");
108 	printf("\n");
109 	printf("1. Redistributions of source code must retain the above copyright notice, this \n");
110 	printf("   list of conditions and the following disclaimer.\n");
111 	printf("\n");
112 	printf("2. Redistributions in binary form must reproduce the above copyright notice, \n");
113 	printf("   this list of conditions and the following disclaimer in the documentation \n");
114 	printf("   and/or other materials provided with the distribution.\n");
115 	printf("\n");
116 	printf("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n");
117 	printf("ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \n");
118 	printf("WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \n");
119 	printf("DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE \n");
120 	printf("FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL \n");
121 	printf("DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR \n");
122 	printf("SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \n");
123 	printf("CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, \n");
124 	printf("OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \n");
125 	printf("OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n");
126 	printf("\n");
127 }
dMagnetic_helpscreens_help(char * argv0)128 void dMagnetic_helpscreens_help(char* argv0)
129 {
130 	int i;
131 	printf("To start a game, run\n");
132 	printf("%s [-ini dMagnetic.ini] GAME\n",argv0);
133 	printf("where GAME is one of \n  [");
134 	for (i=0;i<NUMGAMES;i++)
135 	{
136 		if (i) printf(" ");
137 		printf("%s",cdMagnetic_gameInfo[i].name);
138 	}
139 	printf("]");
140 	printf("\n");
141 	printf("\n");
142 	printf("PARAMETERS TO RUN THE GAME\n");
143 	printf("-ini dMagnetic.ini          to provide an inifile\n");
144 	printf("-mag MAGFILE.mag            to provide the game binary directly\n");
145 	printf("-gfx GFXFILE.gfx            to provide the game graphics directly\n");
146 	printf("-msdosdir DIR/              to provide the game binaries from MSDOS\n");
147 	printf("-tworsc DIR/TWO.RSC         to use resource files from Wonderland\n");
148 	printf("                            or The Magnetic Scrolls Collection Vol.1\n");
149 	printf("-d64 m1.d64,m2.d64          or use the D64 images. (Separated by ,)\n");
150 	printf("-amstradcpc 1.DSK,2.DSK     or use the DSK images. (Separated by ,)\n");
151 	printf("-spectrum image.DSK         or use DSK images from the Spectrum+3\n");
152 	printf("-archimedes image.adf       or use adf/adl images from the Archimedes\n");
153 	printf("-atarixl 1.ATR,2.ATR        or use .atr images from the AtariXL\n");
154 	printf("-appleii 1.NIB,2.NIB,3.NIB  or use .nib images for the Apple ][\n");
155 	printf("-appleii 1.2MG,2.2MG,3.2MG  or use .2MG images for the Apple ][\n");
156 	printf("-appleii 1.WOZ,2.WOZ,3.WOZ  or use .woz images for the Apple ][\n");
157 	printf("\n");
158 	printf("OPTIONAL PARAMETERS\n");
159 	printf("-rmode RANDOMMODE  where mode is one of\n  [");
160 	printf("pseudo ");
161 	printf("real");
162 	printf("]");
163 	printf("\n");
164 	printf("-rseed RANDOMSEED  to set the random seed between 1 and %d\n",0x7fffffff);
165 
166 	printf("-vrows ROWS        to set the number of rows for the pictures\n");
167 	printf("-vcols COLUMNS     to set the number of columns for the pictures\n");
168 	printf("-vmode MODE        where mode is one of\n  [");
169 	printf("none");
170 	printf(" monochrome");
171 	printf(" monochrome_inv");
172 	printf(" low_ansi");
173 	printf(" low_ansi2");
174 	printf(" high_ansi\n  ");
175 	printf(" high_ansi2");
176 	printf(" sixel");
177 	printf(" utf");
178 	printf("]");
179 	printf("\n");
180 	printf("-vlog LOGFILE      to write a log of the commands used\n");
181 	printf("-vecho             to reprint the commands (useful for | tee)\n");
182 	printf("\n");
183 	printf("The sixel output mode can be customized with the following parameters\n");
184 	printf("-sres 1024x768     render the pictures in this resolution\n");
185 	printf("-sforce            force the resolution (ignore the aspect ratio)\n");
186 
187 	printf(" OTHER PARAMETERS\n");
188 	printf(" -bsd shows the license\n");
189 	printf(" -dumpmag GAME.mag -dumpgfx GAME.gfx writes the internal game data\n");
190 	printf(" -ega prefers EGA images\n");
191 	printf(" -help shows this help\n");
192 	printf(" -helpini shows an example dMagnetic.ini file\n");
193 	printf(" --version shows %d.%d%d\n",VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION);
194 
195 }
dMagnetic_helpscreens_helpini()196 void dMagnetic_helpscreens_helpini()
197 {
198 	int i,j;
199 	printf(";Maybe you need to create a file called dMagnetic.ini\n");
200 	printf(";Place it in your home directory, with the following content:\n");
201 	printf(";\n");
202 	printf(";-------------------------------------------------------------------------------\n");
203 	printf(";you can download the files from https://msmemorial.if-legends.org/magnetic.php\n");
204 	printf("[FILES]\n");
205 
206 	for (i=0;i<NUMGAMES;i++)
207 	{
208 		for (j=0;j<NUMPLATFORMS;j++)
209 		{
210 			if (cdMagnetic_gameInfo[i].ported&cdMagnetic_platformInfo[j].mask)
211 			{
212 				int k;
213 				char uppercase[16];
214 				for (k=0;k<strlen(cdMagnetic_gameInfo[i].name)+1;k++)
215 				{
216 					uppercase[k]=cdMagnetic_gameInfo[i].name[k]&0x5f;
217 				}
218 				if (!cdMagnetic_platformInfo[j].active) printf(";");
219 				printf("%s%s=",cdMagnetic_gameInfo[i].name,cdMagnetic_platformInfo[j].name);
220 				if (cdMagnetic_platformInfo[j].special)
221 				{
222 					printf("%s",cdMagnetic_platformInfo[j].dir);
223 					printf("%s",cdMagnetic_gameInfo[i].specialPrefix);
224 					printf("%s",cdMagnetic_platformInfo[j].suffix);
225 				} else {
226 					int l;
227 					int num;
228 					num=(cdMagnetic_platformInfo[j].disksexpected<cdMagnetic_gameInfo[i].disknum)?cdMagnetic_platformInfo[j].disksexpected:cdMagnetic_gameInfo[i].disknum;
229 					for (l=0;l<num;l++)
230 					{
231 						if (l) printf(",");
232 						printf("%s",cdMagnetic_platformInfo[j].dir);
233 						printf("%s",cdMagnetic_platformInfo[j].uppercase?uppercase:cdMagnetic_gameInfo[i].maggfxname);
234 						if (num!=1) printf("%d",(l+1));
235 						printf("%s",cdMagnetic_platformInfo[j].suffix);
236 					}
237 
238 				}
239 				printf("\n");
240 			}
241 		}
242 	}
243 
244 	printf("\n");
245 	printf("[RANDOM]\n");
246 	printf("mode=pseudo\n");
247 	printf(";mode=real\n");
248 	printf("seed=12345\n");
249 	printf("\n");
250 	printf("[DEFAULTGUI]\n");
251 	printf("rows=40\n");
252 	printf("columns=120\n");
253 	printf(";align=left\n");
254 	printf("align=block\n");
255 	printf(";align=right\n");
256 	printf(";mode=none\n");
257 	printf(";mode=monochrome\n");
258 	printf(";mode=monochrome_inv\n");
259 	printf(";mode=low_ansi\n");
260 	printf("mode=low_ansi2\n");
261 	printf(";mode=high_ansi\n");
262 	printf(";mode=high_ansi2\n");
263 	printf(";mode=sixel\n");
264 	printf(";mode=utf\n");
265 	printf(";low_ansi_characters=\\\\/|=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
266 	printf("low_ansi_characters=\\\\/|=L#TX\n");
267 	printf("monochrome_characters=\\ .,-=oxOX@$\n");
268 	printf("sixel_resolution=800x600\n");
269 	printf("sixel_forceresolution=No\n");
270 	printf(";-------------------------------------------------------------------------------\n");
271 }
dMagnetic_helpscreens_loaderfailed(char * argv0)272 void dMagnetic_helpscreens_loaderfailed(char* argv0)
273 {
274 	int i;
275 	fprintf(stderr,"Please run with %s [-ini dMagnetic.ini] GAME\n",argv0);
276 	fprintf(stderr," where GAME is one of\n");
277 	for (i=0;i<NUMGAMES;i++)
278 	{
279 		fprintf(stderr,"    %-10s to play \"%s\"\n",cdMagnetic_gameInfo[i].name,cdMagnetic_gameInfo[i].description);
280 	}
281 	fprintf(stderr,"\n");
282 	fprintf(stderr,"or one of the following\n");
283 	fprintf(stderr,"\n");
284 	for (i=0;i<NUMPLATFORMS;i++)
285 	{
286 		fprintf(stderr,"%s %s\n",argv0,cdMagnetic_platformInfo[i].cmdline);
287 	}
288 	fprintf(stderr,"\n");
289 	fprintf(stderr,"You can get the .mag and .gfx files from\n");
290 	fprintf(stderr," https://msmemorial.if-legends.org/\n");
291 	fprintf(stderr,"\n");
292 	fprintf(stderr,"To get a more detailed help, please run\n");
293 	fprintf(stderr," %s --help\n",argv0);
294 }
295