1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /* $Id: dos_programs.cpp,v 1.94 2009-06-12 20:10:09 c2woody Exp $ */
20
21 #include "dosbox.h"
22 #include <stdlib.h>
23 #include <string.h>
24 #include <ctype.h>
25 #include <string>
26 #include <vector>
27 #include "programs.h"
28 #include "support.h"
29 #include "drives.h"
30 #include "cross.h"
31 #include "regs.h"
32 #include "callback.h"
33 #include "cdrom.h"
34 #include "dos_system.h"
35 #include "dos_inc.h"
36 #include "bios.h"
37 #include "setup.h"
38 #include "control.h"
39
40
41 #if defined(OS2)
42 #define INCL DOSFILEMGR
43 #define INCL_DOSERRORS
44 #include "os2.h"
45 #endif
46
47 #if C_DEBUG
48 Bitu DEBUG_EnableDebugger(void);
49 #endif
50
51 void MSCDEX_SetCDInterface(int intNr, int forceCD);
52 static Bitu ZDRIVE_NUM = 25;
53
UnmountHelper(char umount)54 static const char* UnmountHelper(char umount) {
55 int i_drive;
56 if (umount < '0' || umount > 3+'0')
57 i_drive = toupper(umount) - 'A';
58 else
59 i_drive = umount - '0';
60
61 if (i_drive >= DOS_DRIVES || i_drive < 0)
62 return MSG_Get("PROGRAM_MOUNT_UMOUNT_NOT_MOUNTED");
63
64 if (i_drive < MAX_DISK_IMAGES && Drives[i_drive] == NULL && imageDiskList[i_drive] == NULL)
65 return MSG_Get("PROGRAM_MOUNT_UMOUNT_NOT_MOUNTED");
66
67 if (i_drive >= MAX_DISK_IMAGES && Drives[i_drive] == NULL)
68 return MSG_Get("PROGRAM_MOUNT_UMOUNT_NOT_MOUNTED");
69
70 if (Drives[i_drive]) {
71 switch (DriveManager::UnmountDrive(i_drive)) {
72 case 1: return MSG_Get("PROGRAM_MOUNT_UMOUNT_NO_VIRTUAL");
73 case 2: return MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS");
74 }
75 Drives[i_drive] = 0;
76 // mem_writeb(Real2Phys(dos.tables.mediaid)+i_drive*2,0); //0_74_3 0_74 series doesn't do this.
77 if (i_drive == DOS_GetDefaultDrive()) {
78 DOS_SetDrive(ZDRIVE_NUM);
79 }
80
81 }
82
83 if (i_drive < MAX_DISK_IMAGES && imageDiskList[i_drive]) {
84 delete imageDiskList[i_drive];
85 imageDiskList[i_drive] = NULL;
86 }
87
88 return MSG_Get("PROGRAM_MOUNT_UMOUNT_SUCCESS");
89 }
90
91 class MOUNT : public Program {
92 public:
ListMounts(void)93 void ListMounts(void) {
94 char name[DOS_NAMELENGTH_ASCII];Bit32u size;Bit16u date;Bit16u time;Bit8u attr;
95 /* Command uses dta so set it to our internal dta */
96 RealPt save_dta = dos.dta();
97 dos.dta(dos.tables.tempdta);
98 DOS_DTA dta(dos.dta());
99
100 WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_1"));
101 WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_FORMAT"),"Drive","Type","Label");
102 for(int p = 0;p < 8;p++) WriteOut("----------");
103
104 for (int d = 0;d < DOS_DRIVES;d++) {
105 if (!Drives[d]) continue;
106
107 char root[7] = {static_cast<char>('A'+d),':','\\','*','.','*',0};
108 bool ret = DOS_FindFirst(root,DOS_ATTR_VOLUME);
109 if (ret) {
110 dta.GetResult(name,size,date,time,attr);
111 DOS_FindNext(); //Mark entry as invalid
112 } else name[0] = 0;
113
114 /* Change 8.3 to 11.0 */
115 char* dot = strchr(name,'.');
116 if(dot && (dot - name == 8) ) {
117 name[8] = name[9];name[9] = name[10];name[10] = name[11];name[11] = 0;
118 }
119
120 root[1] = 0; //This way, the format string can be reused.
121 WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_FORMAT"),root, Drives[d]->GetInfo(),name);
122 }
123 dos.dta(save_dta);
124 }
125
Run(void)126 void Run(void) {
127 DOS_Drive * newdrive;char drive;
128 std::string label;
129 std::string umount;
130 std::string newz;
131
132 //Hack To allow long commandlines
133 ChangeToLongCmd();
134 /* Parse the command line */
135 /* if the command line is empty show current mounts */
136 if (!cmd->GetCount()) {
137 ListMounts();
138 return;
139 }
140
141 /* In secure mode don't allow people to change mount points.
142 * Neither mount nor unmount */
143 if(control->SecureMode()) {
144 WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
145 return;
146 }
147
148 /* Check for unmounting */
149 if (cmd->FindString("-u",umount,false)) {
150 WriteOut(UnmountHelper(umount[0]), toupper(umount[0]));
151 return;
152 }
153
154 /* Check for moving Z: */
155 /* Only allowing moving it once. It is merely a convenience added for the wine team */
156 if (ZDRIVE_NUM == 25 && cmd->FindString("-z", newz,false)) {
157 newz[0] = toupper(newz[0]);
158 int i_newz = newz[0] - 'A';
159 if (i_newz >= 0 && i_newz < DOS_DRIVES-1 && !Drives[i_newz]) {
160 ZDRIVE_NUM = i_newz;
161 /* remap drives */
162 Drives[i_newz] = Drives[25];
163 Drives[25] = 0;
164 DOS_Shell *fs = static_cast<DOS_Shell *>(first_shell); //dynamic ?
165 /* Update environment */
166 std::string line = "";
167 char ppp[2] = {newz[0],0};
168 std::string tempenv = ppp; tempenv += ":\\";
169 if (fs->GetEnvStr("PATH",line)){
170 std::string::size_type idx = line.find('=');
171 std::string value = line.substr(idx +1 , std::string::npos);
172 while ( (idx = value.find("Z:\\")) != std::string::npos ||
173 (idx = value.find("z:\\")) != std::string::npos )
174 value.replace(idx,3,tempenv);
175 line = value;
176 }
177 if (!line.size()) line = tempenv;
178 fs->SetEnv("PATH",line.c_str());
179 tempenv += "COMMAND.COM";
180 fs->SetEnv("COMSPEC",tempenv.c_str());
181
182 /* Update batch file if running from Z: (very likely: autoexec) */
183 if(fs->bf) {
184 std::string &name = fs->bf->filename;
185 if(name.length() >2 && name[0] == 'Z' && name[1] == ':') name[0] = newz[0];
186 }
187 /* Change the active drive */
188 if (DOS_GetDefaultDrive() == 25) DOS_SetDrive(i_newz);
189 }
190 return;
191 }
192 /* Show list of cdroms */
193 if (cmd->FindExist("-cd",false)) {
194 int num = SDL_CDNumDrives();
195 WriteOut(MSG_Get("PROGRAM_MOUNT_CDROMS_FOUND"),num);
196 for (int i=0; i<num; i++) {
197 WriteOut("%2d. %s\n",i,SDL_CDName(i));
198 };
199 return;
200 }
201
202 std::string type="dir";
203 cmd->FindString("-t",type,true);
204 bool iscdrom = (type =="cdrom"); //Used for mscdex bug cdrom label name emulation
205 if (type=="floppy" || type=="dir" || type=="cdrom") {
206 Bit16u sizes[4];
207 Bit8u mediaid;
208 std::string str_size;
209 if (type=="floppy") {
210 str_size="512,1,2880,2880";/* All space free */
211 mediaid=0xF0; /* Floppy 1.44 media */
212 } else if (type=="dir") {
213 // 512*127*16383==~1GB total size
214 // 512*127*4031==~250MB total free size
215 str_size="512,127,16383,4031";
216 mediaid=0xF8; /* Hard Disk */
217 } else if (type=="cdrom") {
218 str_size="2048,1,65535,0";
219 mediaid=0xF8; /* Hard Disk */
220 } else {
221 WriteOut(MSG_Get("PROGAM_MOUNT_ILL_TYPE"),type.c_str());
222 return;
223 }
224 /* Parse the free space in mb's (kb's for floppies) */
225 std::string mb_size;
226 if(cmd->FindString("-freesize",mb_size,true)) {
227 char teststr[1024];
228 Bit16u sizemb = static_cast<Bit16u>(atoi(mb_size.c_str()));
229 if (type=="floppy") {
230 sprintf(teststr,"512,1,2880,%d",sizemb*1024/(512*1));
231 } else {
232 sprintf(teststr,"512,127,16513,%d",sizemb*1024*1024/(512*127));
233 }
234 str_size=teststr;
235 }
236
237 cmd->FindString("-size",str_size,true);
238 char number[21] = { 0 };const char * scan = str_size.c_str();
239 Bitu index = 0;Bitu count = 0;
240 /* Parse the str_size string */
241 while (*scan && index < 20 && count < 4) {
242 if (*scan==',') {
243 number[index] = 0;
244 sizes[count++] = atoi(number);
245 index = 0;
246 } else number[index++] = *scan;
247 scan++;
248 }
249 if (count < 4) {
250 number[index] = 0; //always goes correct as index is max 20 at this point.
251 sizes[count] = atoi(number);
252 }
253
254 // get the drive letter
255 cmd->FindCommand(1,temp_line);
256 if ((temp_line.size() > 2) || ((temp_line.size()>1) && (temp_line[1]!=':'))) goto showusage;
257 int i_drive = toupper(temp_line[0]);
258 if (!isalpha(i_drive)) goto showusage;
259 if ((i_drive - 'A') >= DOS_DRIVES || (i_drive-'A') < 0 ) goto showusage;
260 drive = static_cast<char>(i_drive);
261
262 if (!cmd->FindCommand(2,temp_line)) goto showusage;
263 if (!temp_line.size()) goto showusage;
264 struct stat test;
265 //Win32 : strip tailing backslashes
266 //os2: some special drive check
267 //rest: substiture ~ for home
268 bool failed = false;
269 #if defined (WIN32) || defined(OS2)
270 /* Removing trailing backslash if not root dir so stat will succeed */
271 if(temp_line.size() > 3 && temp_line[temp_line.size()-1]=='\\') temp_line.erase(temp_line.size()-1,1);
272 if (stat(temp_line.c_str(),&test)) {
273 #endif
274 #if defined(WIN32)
275 // Nothing to do here.
276 #elif defined (OS2)
277 if (temp_line.size() <= 2) // Seems to be a drive.
278 {
279 failed = true;
280 HFILE cdrom_fd = 0;
281 ULONG ulAction = 0;
282
283 APIRET rc = DosOpen((unsigned char*)temp_line.c_str(), &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
284 OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L);
285 DosClose(cdrom_fd);
286 if (rc != NO_ERROR && rc != ERROR_NOT_READY)
287 {
288 failed = true;
289 } else {
290 failed = false;
291 }
292 }
293 }
294 if (failed) {
295 #else
296 if (stat(temp_line.c_str(),&test)) {
297 failed = true;
298 Cross::ResolveHomedir(temp_line);
299 //Try again after resolving ~
300 if(!stat(temp_line.c_str(),&test)) failed = false;
301 }
302 if(failed) {
303 #endif
304 WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_1"),temp_line.c_str());
305 return;
306 }
307 /* Not a switch so a normal directory/file */
308 if (!(test.st_mode & S_IFDIR)) {
309 #ifdef OS2
310 HFILE cdrom_fd = 0;
311 ULONG ulAction = 0;
312
313 APIRET rc = DosOpen((unsigned char*)temp_line.c_str(), &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
314 OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L);
315 DosClose(cdrom_fd);
316 if (rc != NO_ERROR && rc != ERROR_NOT_READY) {
317 WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str());
318 return;
319 }
320 #else
321 WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str());
322 return;
323 #endif
324 }
325
326 if (temp_line[temp_line.size()-1]!=CROSS_FILESPLIT) temp_line+=CROSS_FILESPLIT;
327 Bit8u bit8size=(Bit8u) sizes[1];
328 if (type=="cdrom") {
329 int num = -1;
330 cmd->FindInt("-usecd",num,true);
331 int error = 0;
332 if (cmd->FindExist("-aspi",false)) {
333 MSCDEX_SetCDInterface(CDROM_USE_ASPI, num);
334 } else if (cmd->FindExist("-ioctl_dio",false)) {
335 MSCDEX_SetCDInterface(CDROM_USE_IOCTL_DIO, num);
336 } else if (cmd->FindExist("-ioctl_dx",false)) {
337 MSCDEX_SetCDInterface(CDROM_USE_IOCTL_DX, num);
338 #if defined (WIN32)
339 } else if (cmd->FindExist("-ioctl_mci",false)) {
340 MSCDEX_SetCDInterface(CDROM_USE_IOCTL_MCI, num);
341 #endif
342 } else if (cmd->FindExist("-noioctl",false)) {
343 MSCDEX_SetCDInterface(CDROM_USE_SDL, num);
344 } else {
345 #if defined (WIN32)
346 // Check OS
347 OSVERSIONINFO osi;
348 osi.dwOSVersionInfoSize = sizeof(osi);
349 GetVersionEx(&osi);
350 if ((osi.dwPlatformId==VER_PLATFORM_WIN32_NT) && (osi.dwMajorVersion>5)) {
351 // Vista/above
352 MSCDEX_SetCDInterface(CDROM_USE_IOCTL_DX, num);
353 } else {
354 MSCDEX_SetCDInterface(CDROM_USE_IOCTL_DIO, num);
355 }
356 #else
357 MSCDEX_SetCDInterface(CDROM_USE_IOCTL_DIO, num);
358 #endif
359 }
360 newdrive = new cdromDrive(drive,temp_line.c_str(),sizes[0],bit8size,sizes[2],0,mediaid,error);
361 // Check Mscdex, if it worked out...
362 switch (error) {
363 case 0 : WriteOut(MSG_Get("MSCDEX_SUCCESS")); break;
364 case 1 : WriteOut(MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS")); break;
365 case 2 : WriteOut(MSG_Get("MSCDEX_ERROR_NOT_SUPPORTED")); break;
366 case 3 : WriteOut(MSG_Get("MSCDEX_ERROR_PATH")); break;
367 case 4 : WriteOut(MSG_Get("MSCDEX_TOO_MANY_DRIVES")); break;
368 case 5 : WriteOut(MSG_Get("MSCDEX_LIMITED_SUPPORT")); break;
369 default : WriteOut(MSG_Get("MSCDEX_UNKNOWN_ERROR")); break;
370 };
371 if (error && error!=5) {
372 delete newdrive;
373 return;
374 }
375 } else {
376 /* Give a warning when mount c:\ or the / */
377 #if defined (WIN32) || defined(OS2)
378 if( (temp_line == "c:\\") || (temp_line == "C:\\") ||
379 (temp_line == "c:/") || (temp_line == "C:/") )
380 WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_WIN"));
381 #else
382 if(temp_line == "/") WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_OTHER"));
383 #endif
384 newdrive=new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid);
385 }
386 } else {
387 WriteOut(MSG_Get("PROGRAM_MOUNT_ILL_TYPE"),type.c_str());
388 return;
389 }
390 if (Drives[drive-'A']) {
391 WriteOut(MSG_Get("PROGRAM_MOUNT_ALREADY_MOUNTED"),drive,Drives[drive-'A']->GetInfo());
392 if (newdrive) delete newdrive;
393 return;
394 }
395 if (!newdrive) E_Exit("DOS:Can't create drive");
396 Drives[drive-'A']=newdrive;
397 /* Set the correct media byte in the table */
398 mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,newdrive->GetMediaByte());
399 WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),drive,newdrive->GetInfo());
400 /* check if volume label is given and don't allow it to updated in the future */
401 if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str(),iscdrom,false);
402 /* For hard drives set the label to DRIVELETTER_Drive.
403 * For floppy drives set the label to DRIVELETTER_Floppy.
404 * This way every drive except cdroms should get a label.*/
405 else if(type == "dir") {
406 label = drive; label += "_DRIVE";
407 newdrive->dirCache.SetLabel(label.c_str(),iscdrom,true);
408 } else if(type == "floppy") {
409 label = drive; label += "_FLOPPY";
410 newdrive->dirCache.SetLabel(label.c_str(),iscdrom,true);
411 }
412 return;
413 showusage:
414 #if defined (WIN32) || defined(OS2)
415 WriteOut(MSG_Get("PROGRAM_MOUNT_USAGE"),"d:\\dosprogs","d:\\dosprogs");
416 #else
417 WriteOut(MSG_Get("PROGRAM_MOUNT_USAGE"),"~/dosprogs","~/dosprogs");
418 #endif
419 return;
420 }
421 };
422
MOUNT_ProgramStart(Program ** make)423 static void MOUNT_ProgramStart(Program * * make) {
424 *make=new MOUNT;
425 }
426
427 class MEM : public Program {
428 public:
Run(void)429 void Run(void) {
430 /* Show conventional Memory */
431 WriteOut("\n");
432
433 Bit16u umb_start=dos_infoblock.GetStartOfUMBChain();
434 Bit8u umb_flag=dos_infoblock.GetUMBChainState();
435 Bit8u old_memstrat=DOS_GetMemAllocStrategy()&0xff;
436 if (umb_start!=0xffff) {
437 if ((umb_flag&1)==1) DOS_LinkUMBsToMemChain(0);
438 DOS_SetMemAllocStrategy(0);
439 }
440
441 Bit16u seg,blocks;blocks=0xffff;
442 DOS_AllocateMemory(&seg,&blocks);
443 if ((machine==MCH_PCJR) && (real_readb(0x2000,0)==0x5a) && (real_readw(0x2000,1)==0) && (real_readw(0x2000,3)==0x7ffe)) {
444 WriteOut(MSG_Get("PROGRAM_MEM_CONVEN"),0x7ffe*16/1024);
445 } else WriteOut(MSG_Get("PROGRAM_MEM_CONVEN"),blocks*16/1024);
446
447 if (umb_start!=0xffff) {
448 DOS_LinkUMBsToMemChain(1);
449 DOS_SetMemAllocStrategy(0x40); // search in UMBs only
450
451 Bit16u largest_block=0,total_blocks=0,block_count=0;
452 for (;; block_count++) {
453 blocks=0xffff;
454 DOS_AllocateMemory(&seg,&blocks);
455 if (blocks==0) break;
456 total_blocks+=blocks;
457 if (blocks>largest_block) largest_block=blocks;
458 DOS_AllocateMemory(&seg,&blocks);
459 }
460
461 Bit8u current_umb_flag=dos_infoblock.GetUMBChainState();
462 if ((current_umb_flag&1)!=(umb_flag&1)) DOS_LinkUMBsToMemChain(umb_flag);
463 DOS_SetMemAllocStrategy(old_memstrat); // restore strategy
464
465 if (block_count>0) WriteOut(MSG_Get("PROGRAM_MEM_UPPER"),total_blocks*16/1024,block_count,largest_block*16/1024);
466 }
467
468 /* Test for and show free XMS */
469 reg_ax=0x4300;CALLBACK_RunRealInt(0x2f);
470 if (reg_al==0x80) {
471 reg_ax=0x4310;CALLBACK_RunRealInt(0x2f);
472 Bit16u xms_seg=SegValue(es);Bit16u xms_off=reg_bx;
473 reg_ah=8;
474 CALLBACK_RunRealFar(xms_seg,xms_off);
475 if (!reg_bl) {
476 WriteOut(MSG_Get("PROGRAM_MEM_EXTEND"),reg_dx);
477 }
478 }
479 /* Test for and show free EMS */
480 Bit16u handle;
481 char emm[9] = { 'E','M','M','X','X','X','X','0',0 };
482 if (DOS_OpenFile(emm,0,&handle)) {
483 DOS_CloseFile(handle);
484 reg_ah=0x42;
485 CALLBACK_RunRealInt(0x67);
486 WriteOut(MSG_Get("PROGRAM_MEM_EXPAND"),reg_bx*16);
487 }
488 }
489 };
490
491
MEM_ProgramStart(Program ** make)492 static void MEM_ProgramStart(Program * * make) {
493 *make=new MEM;
494 }
495
496 extern Bit32u floppytype;
497
498
499 class BOOT : public Program {
500 private:
501
getFSFile_mounted(char const * filename,Bit32u * ksize,Bit32u * bsize,Bit8u * error)502 FILE *getFSFile_mounted(char const* filename, Bit32u *ksize, Bit32u *bsize, Bit8u *error) {
503 //if return NULL then put in error the errormessage code if an error was requested
504 bool tryload = (*error)?true:false;
505 *error = 0;
506 Bit8u drive;
507 FILE *tmpfile;
508 char fullname[DOS_PATHLENGTH];
509
510 localDrive* ldp=0;
511 if (!DOS_MakeName(const_cast<char*>(filename),fullname,&drive)) return NULL;
512
513 try {
514 ldp=dynamic_cast<localDrive*>(Drives[drive]);
515 if(!ldp) return NULL;
516
517 tmpfile = ldp->GetSystemFilePtr(fullname, "rb");
518 if(tmpfile == NULL) {
519 if (!tryload) *error=1;
520 return NULL;
521 }
522
523 // get file size
524 fseek(tmpfile,0L, SEEK_END);
525 *ksize = (ftell(tmpfile) / 1024);
526 *bsize = ftell(tmpfile);
527 fclose(tmpfile);
528
529 tmpfile = ldp->GetSystemFilePtr(fullname, "rb+");
530 if(tmpfile == NULL) {
531 // if (!tryload) *error=2;
532 // return NULL;
533 WriteOut(MSG_Get("PROGRAM_BOOT_WRITE_PROTECTED"));
534 tmpfile = ldp->GetSystemFilePtr(fullname, "rb");
535 if(tmpfile == NULL) {
536 if (!tryload) *error=1;
537 return NULL;
538 }
539 }
540
541 return tmpfile;
542 }
543 catch(...) {
544 return NULL;
545 }
546 }
547
getFSFile(char const * filename,Bit32u * ksize,Bit32u * bsize,bool tryload=false)548 FILE *getFSFile(char const * filename, Bit32u *ksize, Bit32u *bsize,bool tryload=false) {
549 Bit8u error = tryload?1:0;
550 FILE* tmpfile = getFSFile_mounted(filename,ksize,bsize,&error);
551 if(tmpfile) return tmpfile;
552 //File not found on mounted filesystem. Try regular filesystem
553 std::string filename_s(filename);
554 Cross::ResolveHomedir(filename_s);
555 tmpfile = fopen_wrap(filename_s.c_str(),"rb+");
556 if(!tmpfile) {
557 if( (tmpfile = fopen_wrap(filename_s.c_str(),"rb")) ) {
558 //File exists; So can't be opened in correct mode => error 2
559 // fclose(tmpfile);
560 // if(tryload) error = 2;
561 WriteOut(MSG_Get("PROGRAM_BOOT_WRITE_PROTECTED"));
562 fseek(tmpfile,0L, SEEK_END);
563 *ksize = (ftell(tmpfile) / 1024);
564 *bsize = ftell(tmpfile);
565 return tmpfile;
566 }
567 // Give the delayed errormessages from the mounted variant (or from above)
568 if(error == 1) WriteOut(MSG_Get("PROGRAM_BOOT_NOT_EXIST"));
569 if(error == 2) WriteOut(MSG_Get("PROGRAM_BOOT_NOT_OPEN"));
570 return NULL;
571 }
572 fseek(tmpfile,0L, SEEK_END);
573 *ksize = (ftell(tmpfile) / 1024);
574 *bsize = ftell(tmpfile);
575 return tmpfile;
576 }
577
printError(void)578 void printError(void) {
579 WriteOut(MSG_Get("PROGRAM_BOOT_PRINT_ERROR"));
580 }
581
disable_umb_ems_xms(void)582 void disable_umb_ems_xms(void) {
583 Section* dos_sec = control->GetSection("dos");
584 dos_sec->ExecuteDestroy(false);
585 char test[20];
586 strcpy(test,"umb=false");
587 dos_sec->HandleInputline(test);
588 strcpy(test,"xms=false");
589 dos_sec->HandleInputline(test);
590 strcpy(test,"ems=false");
591 dos_sec->HandleInputline(test);
592 dos_sec->ExecuteInit(false);
593 }
594
595 public:
596
Run(void)597 void Run(void) {
598 //Hack To allow long commandlines
599 ChangeToLongCmd();
600 /* In secure mode don't allow people to boot stuff.
601 * They might try to corrupt the data on it */
602 if(control->SecureMode()) {
603 WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
604 return;
605 }
606
607 FILE *usefile_1=NULL;
608 FILE *usefile_2=NULL;
609 Bitu i=0;
610 Bit32u floppysize;
611 Bit32u rombytesize_1=0;
612 Bit32u rombytesize_2=0;
613 Bit8u drive = 'A';
614 std::string cart_cmd="";
615
616 if(!cmd->GetCount()) {
617 printError();
618 return;
619 }
620 while(i<cmd->GetCount()) {
621 if(cmd->FindCommand(i+1, temp_line)) {
622 if((temp_line == "-l") || (temp_line == "-L")) {
623 /* Specifying drive... next argument then is the drive */
624 i++;
625 if(cmd->FindCommand(i+1, temp_line)) {
626 drive=toupper(temp_line[0]);
627 if ((drive != 'A') && (drive != 'C') && (drive != 'D')) {
628 printError();
629 return;
630 }
631
632 } else {
633 printError();
634 return;
635 }
636 i++;
637 continue;
638 }
639
640 if((temp_line == "-e") || (temp_line == "-E")) {
641 /* Command mode for PCJr cartridges */
642 i++;
643 if(cmd->FindCommand(i + 1, temp_line)) {
644 for(size_t ct = 0;ct < temp_line.size();ct++) temp_line[ct] = toupper(temp_line[ct]);
645 cart_cmd = temp_line;
646 } else {
647 printError();
648 return;
649 }
650 i++;
651 continue;
652 }
653
654 if ( i >= MAX_SWAPPABLE_DISKS ) {
655 return; //TODO give a warning.
656 }
657 WriteOut(MSG_Get("PROGRAM_BOOT_IMAGE_OPEN"), temp_line.c_str());
658 Bit32u rombytesize;
659 FILE *usefile = getFSFile(temp_line.c_str(), &floppysize, &rombytesize);
660 if(usefile != NULL) {
661 if(diskSwap[i] != NULL) delete diskSwap[i];
662 diskSwap[i] = new imageDisk(usefile, (Bit8u *)temp_line.c_str(), floppysize, false);
663 if (usefile_1==NULL) {
664 usefile_1=usefile;
665 rombytesize_1=rombytesize;
666 } else {
667 usefile_2=usefile;
668 rombytesize_2=rombytesize;
669 }
670 } else {
671 WriteOut(MSG_Get("PROGRAM_BOOT_IMAGE_NOT_OPEN"), temp_line.c_str());
672 return;
673 }
674
675 }
676 i++;
677 }
678
679 swapPosition = 0;
680
681 swapInDisks();
682
683 if(imageDiskList[drive-65]==NULL) {
684 WriteOut(MSG_Get("PROGRAM_BOOT_UNABLE"), drive);
685 return;
686 }
687
688 bootSector bootarea;
689 imageDiskList[drive-65]->Read_Sector(0,0,1,(Bit8u *)&bootarea);
690 if ((bootarea.rawdata[0]==0x50) && (bootarea.rawdata[1]==0x43) && (bootarea.rawdata[2]==0x6a) && (bootarea.rawdata[3]==0x72)) {
691 if (machine!=MCH_PCJR) WriteOut(MSG_Get("PROGRAM_BOOT_CART_WO_PCJR"));
692 else {
693 Bit8u rombuf[65536];
694 Bits cfound_at=-1;
695 if (cart_cmd!="") {
696 /* read cartridge data into buffer */
697 fseek(usefile_1,0x200L, SEEK_SET);
698 fread(rombuf, 1, rombytesize_1-0x200, usefile_1);
699
700 char cmdlist[1024];
701 cmdlist[0]=0;
702 Bitu ct=6;
703 Bits clen=rombuf[ct];
704 char buf[257];
705 if (cart_cmd=="?") {
706 while (clen!=0) {
707 strncpy(buf,(char*)&rombuf[ct+1],clen);
708 buf[clen]=0;
709 upcase(buf);
710 strcat(cmdlist," ");
711 strcat(cmdlist,buf);
712 ct+=1+clen+3;
713 if (ct>sizeof(cmdlist)) break;
714 clen=rombuf[ct];
715 }
716 if (ct>6) {
717 WriteOut(MSG_Get("PROGRAM_BOOT_CART_LIST_CMDS"),cmdlist);
718 } else {
719 WriteOut(MSG_Get("PROGRAM_BOOT_CART_NO_CMDS"));
720 }
721 for(Bitu dct=0;dct<MAX_SWAPPABLE_DISKS;dct++) {
722 if(diskSwap[dct]!=NULL) {
723 delete diskSwap[dct];
724 diskSwap[dct]=NULL;
725 }
726 }
727 //fclose(usefile_1); //delete diskSwap closes the file
728 return;
729 } else {
730 while (clen!=0) {
731 strncpy(buf,(char*)&rombuf[ct+1],clen);
732 buf[clen]=0;
733 upcase(buf);
734 strcat(cmdlist," ");
735 strcat(cmdlist,buf);
736 ct+=1+clen;
737
738 if (cart_cmd==buf) {
739 cfound_at=ct;
740 break;
741 }
742
743 ct+=3;
744 if (ct>sizeof(cmdlist)) break;
745 clen=rombuf[ct];
746 }
747 if (cfound_at<=0) {
748 if (ct>6) {
749 WriteOut(MSG_Get("PROGRAM_BOOT_CART_LIST_CMDS"),cmdlist);
750 } else {
751 WriteOut(MSG_Get("PROGRAM_BOOT_CART_NO_CMDS"));
752 }
753 for(Bitu dct=0;dct<MAX_SWAPPABLE_DISKS;dct++) {
754 if(diskSwap[dct]!=NULL) {
755 delete diskSwap[dct];
756 diskSwap[dct]=NULL;
757 }
758 }
759 //fclose(usefile_1); //Delete diskSwap closes the file
760 return;
761 }
762 }
763 }
764
765 disable_umb_ems_xms();
766 void PreparePCJRCartRom(void);
767 PreparePCJRCartRom();
768
769 if (usefile_1==NULL) return;
770
771 Bit32u sz1,sz2;
772 FILE *tfile = getFSFile("system.rom", &sz1, &sz2, true);
773 if (tfile!=NULL) {
774 fseek(tfile, 0x3000L, SEEK_SET);
775 Bit32u drd=(Bit32u)fread(rombuf, 1, 0xb000, tfile);
776 if (drd==0xb000) {
777 for(i=0;i<0xb000;i++) phys_writeb(0xf3000+i,rombuf[i]);
778 }
779 fclose(tfile);
780 }
781
782 if (usefile_2!=NULL) {
783 fseek(usefile_2, 0x0L, SEEK_SET);
784 fread(rombuf, 1, 0x200, usefile_2);
785 PhysPt romseg_pt=host_readw(&rombuf[0x1ce])<<4;
786
787 /* read cartridge data into buffer */
788 fseek(usefile_2, 0x200L, SEEK_SET);
789 fread(rombuf, 1, rombytesize_2-0x200, usefile_2);
790 //fclose(usefile_2); //usefile_2 is in diskSwap structure which should be deleted to close the file
791
792 /* write cartridge data into ROM */
793 for(i=0;i<rombytesize_2-0x200;i++) phys_writeb(romseg_pt+i,rombuf[i]);
794 }
795
796 fseek(usefile_1, 0x0L, SEEK_SET);
797 fread(rombuf, 1, 0x200, usefile_1);
798 Bit16u romseg=host_readw(&rombuf[0x1ce]);
799
800 /* read cartridge data into buffer */
801 fseek(usefile_1,0x200L, SEEK_SET);
802 fread(rombuf, 1, rombytesize_1-0x200, usefile_1);
803 //fclose(usefile_1); //usefile_1 is in diskSwap structure which should be deleted to close the file
804
805 /* write cartridge data into ROM */
806 for(i=0;i<rombytesize_1-0x200;i++) phys_writeb((romseg<<4)+i,rombuf[i]);
807
808 //Close cardridges
809 for(Bitu dct=0;dct<MAX_SWAPPABLE_DISKS;dct++) {
810 if(diskSwap[dct]!=NULL) {
811 delete diskSwap[dct];
812 diskSwap[dct]=NULL;
813 }
814 }
815
816
817 if (cart_cmd=="") {
818 Bit32u old_int18=mem_readd(0x60);
819 /* run cartridge setup */
820 SegSet16(ds,romseg);
821 SegSet16(es,romseg);
822 SegSet16(ss,0x8000);
823 reg_esp=0xfffe;
824 CALLBACK_RunRealFar(romseg,0x0003);
825
826 Bit32u new_int18=mem_readd(0x60);
827 if (old_int18!=new_int18) {
828 /* boot cartridge (int18) */
829 SegSet16(cs,RealSeg(new_int18));
830 reg_ip = RealOff(new_int18);
831 }
832 } else {
833 if (cfound_at>0) {
834 /* run cartridge setup */
835 SegSet16(ds,dos.psp());
836 SegSet16(es,dos.psp());
837 CALLBACK_RunRealFar(romseg,cfound_at);
838 }
839 }
840 }
841 } else {
842 disable_umb_ems_xms();
843 void RemoveEMSPageFrame(void);
844 RemoveEMSPageFrame();
845 WriteOut(MSG_Get("PROGRAM_BOOT_BOOT"), drive);
846 for(i=0;i<512;i++) real_writeb(0, 0x7c00 + i, bootarea.rawdata[i]);
847
848 /* revector some dos-allocated interrupts */
849 real_writed(0,0x01*4,0xf000ff53);
850 real_writed(0,0x03*4,0xf000ff53);
851
852 SegSet16(cs, 0);
853 reg_ip = 0x7c00;
854 SegSet16(ds, 0);
855 SegSet16(es, 0);
856 /* set up stack at a safe place */
857 SegSet16(ss, 0x7000);
858 reg_esp = 0x100;
859 reg_esi = 0;
860 reg_ecx = 1;
861 reg_ebp = 0;
862 reg_eax = 0;
863 reg_edx = 0; //Head 0 drive 0
864 reg_ebx= 0x7c00; //Real code probably uses bx to load the image
865 }
866 }
867 };
868
BOOT_ProgramStart(Program ** make)869 static void BOOT_ProgramStart(Program * * make) {
870 *make=new BOOT;
871 }
872
873
874 #if C_DEBUG
875 class LDGFXROM : public Program {
876 public:
Run(void)877 void Run(void) {
878 if (!(cmd->FindCommand(1, temp_line))) return;
879
880 Bit8u drive;
881 char fullname[DOS_PATHLENGTH];
882
883 localDrive* ldp=0;
884 if (!DOS_MakeName((char *)temp_line.c_str(),fullname,&drive)) return;
885
886 try {
887 ldp=dynamic_cast<localDrive*>(Drives[drive]);
888 if(!ldp) return;
889
890 FILE *tmpfile = ldp->GetSystemFilePtr(fullname, "rb");
891 if(tmpfile == NULL) {
892 LOG_MSG("BIOS file not accessible.");
893 return;
894 }
895 fseek(tmpfile, 0L, SEEK_END);
896 if (ftell(tmpfile)>0x10000) {
897 LOG_MSG("BIOS file too large.");
898 return;
899 }
900 fseek(tmpfile, 0L, SEEK_SET);
901
902 PhysPt rom_base=PhysMake(0xc000,0);
903
904 Bit8u vga_buffer[0x10000];
905 Bitu data_written=0;
906 Bitu data_read=fread(vga_buffer, 1, 0x10000, tmpfile);
907 for (Bitu ct=0; ct<data_read; ct++) {
908 phys_writeb(rom_base+(data_written++),vga_buffer[ct]);
909 }
910 fclose(tmpfile);
911
912 rom_base=PhysMake(0xf000,0);
913 phys_writeb(rom_base+0xf065,0xcf);
914 }
915 catch(...) {
916 return;
917 }
918
919 reg_flags&=~FLAG_IF;
920 CALLBACK_RunRealFar(0xc000,0x0003);
921 }
922 };
923
LDGFXROM_ProgramStart(Program ** make)924 static void LDGFXROM_ProgramStart(Program * * make) {
925 *make=new LDGFXROM;
926 }
927 #endif
928
929
930 // LOADFIX
931
932 class LOADFIX : public Program {
933 public:
934 void Run(void);
935 };
936
Run(void)937 void LOADFIX::Run(void)
938 {
939 Bit16u commandNr = 1;
940 Bit16u kb = 64;
941 if (cmd->FindCommand(commandNr,temp_line)) {
942 if (temp_line[0]=='-') {
943 char ch = temp_line[1];
944 if ((*upcase(&ch)=='D') || (*upcase(&ch)=='F')) {
945 // Deallocate all
946 DOS_FreeProcessMemory(0x40);
947 WriteOut(MSG_Get("PROGRAM_LOADFIX_DEALLOCALL"),kb);
948 return;
949 } else {
950 // Set mem amount to allocate
951 kb = atoi(temp_line.c_str()+1);
952 if (kb==0) kb=64;
953 commandNr++;
954 }
955 }
956 }
957 // Allocate Memory
958 Bit16u segment;
959 Bit16u blocks = kb*1024/16;
960 if (DOS_AllocateMemory(&segment,&blocks)) {
961 DOS_MCB mcb((Bit16u)(segment-1));
962 mcb.SetPSPSeg(0x40); // use fake segment
963 WriteOut(MSG_Get("PROGRAM_LOADFIX_ALLOC"),kb);
964 // Prepare commandline...
965 if (cmd->FindCommand(commandNr++,temp_line)) {
966 // get Filename
967 char filename[128];
968 safe_strncpy(filename,temp_line.c_str(),128);
969 // Setup commandline
970 bool ok;
971 char args[256];
972 args[0] = 0;
973 do {
974 ok = cmd->FindCommand(commandNr++,temp_line);
975 if(sizeof(args)-strlen(args)-1 < temp_line.length()+1)
976 break;
977 strcat(args,temp_line.c_str());
978 strcat(args," ");
979 } while (ok);
980 // Use shell to start program
981 DOS_Shell shell;
982 shell.Execute(filename,args);
983 DOS_FreeMemory(segment);
984 WriteOut(MSG_Get("PROGRAM_LOADFIX_DEALLOC"),kb);
985 }
986 } else {
987 WriteOut(MSG_Get("PROGRAM_LOADFIX_ERROR"),kb);
988 }
989 }
990
LOADFIX_ProgramStart(Program ** make)991 static void LOADFIX_ProgramStart(Program * * make) {
992 *make=new LOADFIX;
993 }
994
995 // RESCAN
996
997 class RESCAN : public Program {
998 public:
999 void Run(void);
1000 };
1001
Run(void)1002 void RESCAN::Run(void)
1003 {
1004 // Get current drive
1005 Bit8u drive = DOS_GetDefaultDrive();
1006 if (Drives[drive]) {
1007 Drives[drive]->EmptyCache();
1008 WriteOut(MSG_Get("PROGRAM_RESCAN_SUCCESS"));
1009 }
1010 }
1011
RESCAN_ProgramStart(Program ** make)1012 static void RESCAN_ProgramStart(Program * * make) {
1013 *make=new RESCAN;
1014 }
1015
1016 class INTRO : public Program {
1017 public:
DisplayMount(void)1018 void DisplayMount(void) {
1019 /* Basic mounting has a version for each operating system.
1020 * This is done this way so both messages appear in the language file*/
1021 WriteOut(MSG_Get("PROGRAM_INTRO_MOUNT_START"));
1022 #if (WIN32)
1023 WriteOut(MSG_Get("PROGRAM_INTRO_MOUNT_WINDOWS"));
1024 #else
1025 WriteOut(MSG_Get("PROGRAM_INTRO_MOUNT_OTHER"));
1026 #endif
1027 WriteOut(MSG_Get("PROGRAM_INTRO_MOUNT_END"));
1028 }
1029
Run(void)1030 void Run(void) {
1031 /* Only run if called from the first shell (Xcom TFTD runs any intro file in the path) */
1032 if(DOS_PSP(dos.psp()).GetParent() != DOS_PSP(DOS_PSP(dos.psp()).GetParent()).GetParent()) return;
1033 if(cmd->FindExist("cdrom",false)) {
1034 WriteOut(MSG_Get("PROGRAM_INTRO_CDROM"));
1035 return;
1036 }
1037 if(cmd->FindExist("mount",false)) {
1038 WriteOut("\033[2J");//Clear screen before printing
1039 DisplayMount();
1040 return;
1041 }
1042 if(cmd->FindExist("special",false)) {
1043 WriteOut(MSG_Get("PROGRAM_INTRO_SPECIAL"));
1044 return;
1045 }
1046 /* Default action is to show all pages */
1047 WriteOut(MSG_Get("PROGRAM_INTRO"));
1048 Bit8u c;Bit16u n=1;
1049 DOS_ReadFile (STDIN,&c,&n);
1050 DisplayMount();
1051 DOS_ReadFile (STDIN,&c,&n);
1052 WriteOut(MSG_Get("PROGRAM_INTRO_CDROM"));
1053 DOS_ReadFile (STDIN,&c,&n);
1054 WriteOut(MSG_Get("PROGRAM_INTRO_SPECIAL"));
1055 }
1056 };
1057
INTRO_ProgramStart(Program ** make)1058 static void INTRO_ProgramStart(Program * * make) {
1059 *make=new INTRO;
1060 }
1061
1062 class IMGMOUNT : public Program {
1063 public:
Run(void)1064 void Run(void) {
1065 //Hack To allow long commandlines
1066 ChangeToLongCmd();
1067 /* In secure mode don't allow people to change imgmount points.
1068 * Neither mount nor unmount */
1069 if(control->SecureMode()) {
1070 WriteOut(MSG_Get("PROGRAM_CONFIG_SECURE_DISALLOW"));
1071 return;
1072 }
1073 DOS_Drive * newdrive = NULL;
1074 imageDisk * newImage = NULL;
1075 Bit32u imagesize;
1076 char drive;
1077 std::string label;
1078 std::vector<std::string> paths;
1079 std::string umount;
1080 /* Check for unmounting */
1081 if (cmd->FindString("-u",umount,false)) {
1082 WriteOut(UnmountHelper(umount[0]), toupper(umount[0]));
1083 return;
1084 }
1085
1086
1087 std::string type="hdd";
1088 std::string fstype="fat";
1089 cmd->FindString("-t",type,true);
1090 cmd->FindString("-fs",fstype,true);
1091 if(type == "cdrom") type = "iso"; //Tiny hack for people who like to type -t cdrom
1092 Bit8u mediaid;
1093 if (type=="floppy" || type=="hdd" || type=="iso") {
1094 Bit16u sizes[4];
1095 bool imgsizedetect=false;
1096
1097 std::string str_size;
1098 mediaid=0xF8;
1099
1100 if (type=="floppy") {
1101 mediaid=0xF0;
1102 } else if (type=="iso") {
1103 str_size="650,127,16513,1700";
1104 mediaid=0xF8;
1105 fstype = "iso";
1106 }
1107 cmd->FindString("-size",str_size,true);
1108 if ((type=="hdd") && (str_size.size()==0)) {
1109 imgsizedetect=true;
1110 } else {
1111 char number[21] = { 0 };const char * scan = str_size.c_str();
1112 Bitu index = 0;Bitu count = 0;
1113 /* Parse the str_size string */
1114 while (*scan && index < 20 && count < 4) {
1115 if (*scan==',') {
1116 number[index] = 0;
1117 sizes[count++] = atoi(number);
1118 index = 0;
1119 } else number[index++] = *scan;
1120 scan++;
1121 }
1122 if (count < 4) {
1123 number[index] = 0; //always goes correct as index is max 20 at this point.
1124 sizes[count] = atoi(number);
1125 }
1126 }
1127
1128 if(fstype=="fat" || fstype=="iso") {
1129 // get the drive letter
1130 if (!cmd->FindCommand(1,temp_line) || (temp_line.size() > 2) || ((temp_line.size()>1) && (temp_line[1]!=':'))) {
1131 WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
1132 return;
1133 }
1134 int i_drive = toupper(temp_line[0]);
1135 if (!isalpha(i_drive) || (i_drive - 'A') >= DOS_DRIVES || (i_drive - 'A') <0) {
1136 WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_DRIVE"));
1137 return;
1138 }
1139 drive = static_cast<char>(i_drive);
1140 } else if (fstype=="none") {
1141 cmd->FindCommand(1,temp_line);
1142 if ((temp_line.size() > 1) || (!isdigit(temp_line[0]))) {
1143 WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY2"));
1144 return;
1145 }
1146 drive=temp_line[0];
1147 if ((drive<'0') || (drive>=(MAX_DISK_IMAGES+'0'))) {
1148 WriteOut_NoParsing(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY2"));
1149 return;
1150 }
1151 } else {
1152 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_FORMAT_UNSUPPORTED"),fstype.c_str());
1153 return;
1154 }
1155
1156 // find all file parameters, assuming that all option parameters have been removed
1157 while(cmd->FindCommand((unsigned int)(paths.size() + 2), temp_line) && temp_line.size()) {
1158
1159 struct stat test;
1160 if (stat(temp_line.c_str(),&test)) {
1161 //See if it works if the ~ are written out
1162 std::string homedir(temp_line);
1163 Cross::ResolveHomedir(homedir);
1164 if(!stat(homedir.c_str(),&test)) {
1165 temp_line = homedir;
1166 } else {
1167 // convert dosbox filename to system filename
1168 char fullname[CROSS_LEN];
1169 char tmp[CROSS_LEN];
1170 safe_strncpy(tmp, temp_line.c_str(), CROSS_LEN);
1171
1172 Bit8u dummy;
1173 if (!DOS_MakeName(tmp, fullname, &dummy) || strncmp(Drives[dummy]->GetInfo(),"local directory",15)) {
1174 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_NON_LOCAL_DRIVE"));
1175 return;
1176 }
1177
1178 localDrive *ldp = dynamic_cast<localDrive*>(Drives[dummy]);
1179 if (ldp==NULL) {
1180 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_FILE_NOT_FOUND"));
1181 return;
1182 }
1183 ldp->GetSystemFilename(tmp, fullname);
1184 temp_line = tmp;
1185
1186 if (stat(temp_line.c_str(),&test)) {
1187 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_FILE_NOT_FOUND"));
1188 return;
1189 }
1190 }
1191 }
1192 if ((test.st_mode & S_IFDIR)) {
1193 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MOUNT"));
1194 return;
1195 }
1196 paths.push_back(temp_line);
1197 }
1198 if (paths.size() == 0) {
1199 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_SPECIFY_FILE"));
1200 return;
1201 }
1202 if (paths.size() == 1)
1203 temp_line = paths[0];
1204 if (paths.size() > 1 && fstype != "iso") {
1205 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MULTIPLE_NON_CUEISO_FILES"));
1206 return;
1207 }
1208
1209 if(fstype=="fat") {
1210 if (imgsizedetect) {
1211 FILE * diskfile = fopen_wrap(temp_line.c_str(), "rb+");
1212 if(!diskfile) {
1213 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_IMAGE"));
1214 return;
1215 }
1216 fseek(diskfile, 0L, SEEK_END);
1217 Bit32u fcsize = (Bit32u)(ftell(diskfile) / 512L);
1218 Bit8u buf[512];
1219 fseek(diskfile, 0L, SEEK_SET);
1220 if (fread(buf,sizeof(Bit8u),512,diskfile)<512) {
1221 fclose(diskfile);
1222 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_IMAGE"));
1223 return;
1224 }
1225 fclose(diskfile);
1226 if ((buf[510]!=0x55) || (buf[511]!=0xaa)) {
1227 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_GEOMETRY"));
1228 return;
1229 }
1230 Bitu sectors=(Bitu)(fcsize/(16*63));
1231 if (sectors*16*63!=fcsize) {
1232 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_GEOMETRY"));
1233 return;
1234 }
1235 sizes[0]=512; sizes[1]=63; sizes[2]=16; sizes[3]=sectors;
1236 LOG_MSG("autosized image file: %d:%d:%d:%d",sizes[0],sizes[1],sizes[2],sizes[3]);
1237 }
1238
1239 newdrive=new fatDrive(temp_line.c_str(),sizes[0],sizes[1],sizes[2],sizes[3],0);
1240 if(!(dynamic_cast<fatDrive*>(newdrive))->created_successfully) {
1241 delete newdrive;
1242 newdrive = 0;
1243 }
1244 } else if (fstype=="iso") {
1245 } else {
1246 FILE *newDisk = fopen_wrap(temp_line.c_str(), "rb+");
1247 fseek(newDisk,0L, SEEK_END);
1248 imagesize = (ftell(newDisk) / 1024);
1249
1250 newImage = new imageDisk(newDisk, (Bit8u *)temp_line.c_str(), imagesize, (imagesize > 2880));
1251 if(imagesize>2880) newImage->Set_Geometry(sizes[2],sizes[3],sizes[1],sizes[0]);
1252 }
1253 } else {
1254 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_TYPE_UNSUPPORTED"),type.c_str());
1255 return;
1256 }
1257
1258 if(fstype=="fat") {
1259 if (Drives[drive-'A']) {
1260 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_ALREADY_MOUNTED"));
1261 if (newdrive) delete newdrive;
1262 return;
1263 }
1264 if (!newdrive) {WriteOut(MSG_Get("PROGRAM_IMGMOUNT_CANT_CREATE"));return;}
1265 Drives[drive-'A']=newdrive;
1266 // Set the correct media byte in the table
1267 mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,mediaid);
1268 WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),drive,temp_line.c_str());
1269 if(((fatDrive *)newdrive)->loadedDisk->hardDrive) {
1270 if(imageDiskList[2] == NULL) {
1271 imageDiskList[2] = ((fatDrive *)newdrive)->loadedDisk;
1272 updateDPT();
1273 return;
1274 }
1275 if(imageDiskList[3] == NULL) {
1276 imageDiskList[3] = ((fatDrive *)newdrive)->loadedDisk;
1277 updateDPT();
1278 return;
1279 }
1280 }
1281 if(!((fatDrive *)newdrive)->loadedDisk->hardDrive) {
1282 imageDiskList[0] = ((fatDrive *)newdrive)->loadedDisk;
1283 }
1284 } else if (fstype=="iso") {
1285 if (Drives[drive-'A']) {
1286 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_ALREADY_MOUNTED"));
1287 return;
1288 }
1289 MSCDEX_SetCDInterface(CDROM_USE_SDL, -1);
1290 // create new drives for all images
1291 std::vector<DOS_Drive*> isoDisks;
1292 std::vector<std::string>::size_type i;
1293 std::vector<DOS_Drive*>::size_type ct;
1294 for (i = 0; i < paths.size(); i++) {
1295 int error = -1;
1296 DOS_Drive* newDrive = new isoDrive(drive, paths[i].c_str(), mediaid, error);
1297 isoDisks.push_back(newDrive);
1298 switch (error) {
1299 case 0 : break;
1300 case 1 : WriteOut(MSG_Get("MSCDEX_ERROR_MULTIPLE_CDROMS")); break;
1301 case 2 : WriteOut(MSG_Get("MSCDEX_ERROR_NOT_SUPPORTED")); break;
1302 case 3 : WriteOut(MSG_Get("MSCDEX_ERROR_OPEN")); break;
1303 case 4 : WriteOut(MSG_Get("MSCDEX_TOO_MANY_DRIVES")); break;
1304 case 5 : WriteOut(MSG_Get("MSCDEX_LIMITED_SUPPORT")); break;
1305 case 6 : WriteOut(MSG_Get("MSCDEX_INVALID_FILEFORMAT")); break;
1306 default : WriteOut(MSG_Get("MSCDEX_UNKNOWN_ERROR")); break;
1307 }
1308 // error: clean up and leave
1309 if (error) {
1310 for(ct = 0; ct < isoDisks.size(); ct++) {
1311 delete isoDisks[ct];
1312 }
1313 return;
1314 }
1315 }
1316 // Update DriveManager
1317 for(ct = 0; ct < isoDisks.size(); ct++) {
1318 DriveManager::AppendDisk(drive - 'A', isoDisks[ct]);
1319 }
1320 DriveManager::InitializeDrive(drive - 'A');
1321
1322 // Set the correct media byte in the table
1323 mem_writeb(Real2Phys(dos.tables.mediaid) + (drive - 'A') * 2, mediaid);
1324
1325 // Print status message (success)
1326 WriteOut(MSG_Get("MSCDEX_SUCCESS"));
1327 std::string tmp(paths[0]);
1328 for (i = 1; i < paths.size(); i++) {
1329 tmp += "; " + paths[i];
1330 }
1331 WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"), drive, tmp.c_str());
1332
1333 } else if (fstype=="none") {
1334 if(imageDiskList[drive-'0'] != NULL) delete imageDiskList[drive-'0'];
1335 imageDiskList[drive-'0'] = newImage;
1336 updateDPT();
1337 WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MOUNT_NUMBER"),drive-'0',temp_line.c_str());
1338 }
1339
1340 // check if volume label is given. be careful for cdrom
1341 //if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str());
1342 return;
1343 }
1344 };
1345
IMGMOUNT_ProgramStart(Program ** make)1346 void IMGMOUNT_ProgramStart(Program * * make) {
1347 *make=new IMGMOUNT;
1348 }
1349
1350
1351 Bitu DOS_SwitchKeyboardLayout(const char* new_layout, Bit32s& tried_cp);
1352 Bitu DOS_LoadKeyboardLayout(const char * layoutname, Bit32s codepage, const char * codepagefile);
1353 const char* DOS_GetLoadedLayout(void);
1354
1355 class KEYB : public Program {
1356 public:
1357 void Run(void);
1358 };
1359
Run(void)1360 void KEYB::Run(void) {
1361 if (cmd->FindCommand(1,temp_line)) {
1362 if (cmd->FindString("?",temp_line,false)) {
1363 WriteOut(MSG_Get("PROGRAM_KEYB_SHOWHELP"));
1364 } else {
1365 /* first parameter is layout ID */
1366 Bitu keyb_error=0;
1367 std::string cp_string;
1368 Bit32s tried_cp = -1;
1369 if (cmd->FindCommand(2,cp_string)) {
1370 /* second parameter is codepage number */
1371 tried_cp=atoi(cp_string.c_str());
1372 char cp_file_name[256];
1373 if (cmd->FindCommand(3,cp_string)) {
1374 /* third parameter is codepage file */
1375 strcpy(cp_file_name, cp_string.c_str());
1376 } else {
1377 /* no codepage file specified, use automatic selection */
1378 strcpy(cp_file_name, "auto");
1379 }
1380
1381 keyb_error=DOS_LoadKeyboardLayout(temp_line.c_str(), tried_cp, cp_file_name);
1382 } else {
1383 keyb_error=DOS_SwitchKeyboardLayout(temp_line.c_str(), tried_cp);
1384 }
1385 switch (keyb_error) {
1386 case KEYB_NOERROR:
1387 WriteOut(MSG_Get("PROGRAM_KEYB_NOERROR"),temp_line.c_str(),dos.loaded_codepage);
1388 break;
1389 case KEYB_FILENOTFOUND:
1390 WriteOut(MSG_Get("PROGRAM_KEYB_FILENOTFOUND"),temp_line.c_str());
1391 WriteOut(MSG_Get("PROGRAM_KEYB_SHOWHELP"));
1392 break;
1393 case KEYB_INVALIDFILE:
1394 WriteOut(MSG_Get("PROGRAM_KEYB_INVALIDFILE"),temp_line.c_str());
1395 break;
1396 case KEYB_LAYOUTNOTFOUND:
1397 WriteOut(MSG_Get("PROGRAM_KEYB_LAYOUTNOTFOUND"),temp_line.c_str(),tried_cp);
1398 break;
1399 case KEYB_INVALIDCPFILE:
1400 WriteOut(MSG_Get("PROGRAM_KEYB_INVCPFILE"),temp_line.c_str());
1401 WriteOut(MSG_Get("PROGRAM_KEYB_SHOWHELP"));
1402 break;
1403 default:
1404 LOG(LOG_DOSMISC,LOG_ERROR)("KEYB:Invalid returncode %x",keyb_error);
1405 break;
1406 }
1407 }
1408 } else {
1409 /* no parameter in the command line, just output codepage info and possibly loaded layout ID */
1410 const char* layout_name = DOS_GetLoadedLayout();
1411 if (layout_name==NULL) {
1412 WriteOut(MSG_Get("PROGRAM_KEYB_INFO"),dos.loaded_codepage);
1413 } else {
1414 WriteOut(MSG_Get("PROGRAM_KEYB_INFO_LAYOUT"),dos.loaded_codepage,layout_name);
1415 }
1416 }
1417 }
1418
KEYB_ProgramStart(Program ** make)1419 static void KEYB_ProgramStart(Program * * make) {
1420 *make=new KEYB;
1421 }
1422
1423
DOS_SetupPrograms(void)1424 void DOS_SetupPrograms(void) {
1425 /*Add Messages */
1426
1427 MSG_Add("PROGRAM_MOUNT_CDROMS_FOUND","CDROMs found: %d\n");
1428 MSG_Add("PROGRAM_MOUNT_STATUS_FORMAT","%-5s %-58s %-12s\n");
1429 MSG_Add("PROGRAM_MOUNT_STATUS_2","Drive %c is mounted as %s\n");
1430 MSG_Add("PROGRAM_MOUNT_STATUS_1","The currently mounted drives are:\n");
1431 MSG_Add("PROGRAM_MOUNT_ERROR_1","Directory %s doesn't exist.\n");
1432 MSG_Add("PROGRAM_MOUNT_ERROR_2","%s isn't a directory\n");
1433 MSG_Add("PROGRAM_MOUNT_ILL_TYPE","Illegal type %s\n");
1434 MSG_Add("PROGRAM_MOUNT_ALREADY_MOUNTED","Drive %c already mounted with %s\n");
1435 MSG_Add("PROGRAM_MOUNT_USAGE",
1436 "Usage \033[34;1mMOUNT Drive-Letter Local-Directory\033[0m\n"
1437 "For example: MOUNT c %s\n"
1438 "This makes the directory %s act as the C: drive inside DOSBox.\n"
1439 "The directory has to exist.\n");
1440 MSG_Add("PROGRAM_MOUNT_UMOUNT_NOT_MOUNTED","Drive %c isn't mounted.\n");
1441 MSG_Add("PROGRAM_MOUNT_UMOUNT_SUCCESS","Drive %c has successfully been removed.\n");
1442 MSG_Add("PROGRAM_MOUNT_UMOUNT_NO_VIRTUAL","Virtual Drives can not be unMOUNTed.\n");
1443 MSG_Add("PROGRAM_MOUNT_WARNING_WIN","\033[31;1mMounting c:\\ is NOT recommended. Please mount a (sub)directory next time.\033[0m\n");
1444 MSG_Add("PROGRAM_MOUNT_WARNING_OTHER","\033[31;1mMounting / is NOT recommended. Please mount a (sub)directory next time.\033[0m\n");
1445
1446 MSG_Add("PROGRAM_MEM_CONVEN","%10d Kb free conventional memory\n");
1447 MSG_Add("PROGRAM_MEM_EXTEND","%10d Kb free extended memory\n");
1448 MSG_Add("PROGRAM_MEM_EXPAND","%10d Kb free expanded memory\n");
1449 MSG_Add("PROGRAM_MEM_UPPER","%10d Kb free upper memory in %d blocks (largest UMB %d Kb)\n");
1450
1451 MSG_Add("PROGRAM_LOADFIX_ALLOC","%d kb allocated.\n");
1452 MSG_Add("PROGRAM_LOADFIX_DEALLOC","%d kb freed.\n");
1453 MSG_Add("PROGRAM_LOADFIX_DEALLOCALL","Used memory freed.\n");
1454 MSG_Add("PROGRAM_LOADFIX_ERROR","Memory allocation error.\n");
1455
1456 MSG_Add("MSCDEX_SUCCESS","MSCDEX installed.\n");
1457 MSG_Add("MSCDEX_ERROR_MULTIPLE_CDROMS","MSCDEX: Failure: Drive-letters of multiple CDRom-drives have to be continuous.\n");
1458 MSG_Add("MSCDEX_ERROR_NOT_SUPPORTED","MSCDEX: Failure: Not yet supported.\n");
1459 MSG_Add("MSCDEX_ERROR_OPEN","MSCDEX: Failure: Invalid file or unable to open.\n");
1460 MSG_Add("MSCDEX_TOO_MANY_DRIVES","MSCDEX: Failure: Too many CDRom-drives (max: 5). MSCDEX Installation failed.\n");
1461 MSG_Add("MSCDEX_LIMITED_SUPPORT","MSCDEX: Mounted subdirectory: limited support.\n");
1462 MSG_Add("MSCDEX_INVALID_FILEFORMAT","MSCDEX: Failure: File is either no iso/cue image or contains errors.\n");
1463 MSG_Add("MSCDEX_UNKNOWN_ERROR","MSCDEX: Failure: Unknown error.\n");
1464
1465 MSG_Add("PROGRAM_RESCAN_SUCCESS","Drive cache cleared.\n");
1466
1467 MSG_Add("PROGRAM_INTRO",
1468 "\033[2J\033[32;1mWelcome to DOSBox\033[0m, an x86 emulator with sound and graphics.\n"
1469 "DOSBox creates a shell for you which looks like old plain DOS.\n"
1470 "\n"
1471 "For information about basic mount type \033[34;1mintro mount\033[0m\n"
1472 "For information about CD-ROM support type \033[34;1mintro cdrom\033[0m\n"
1473 "For information about special keys type \033[34;1mintro special\033[0m\n"
1474 "For more information about DOSBox, go to \033[34;1mhttp://www.dosbox.com/wiki\033[0m\n"
1475 "\n"
1476 "\033[31;1mDOSBox will stop/exit without a warning if an error occured!\033[0m\n"
1477 "\n"
1478 "\n"
1479 );
1480 MSG_Add("PROGRAM_INTRO_MOUNT_START",
1481 "\033[32;1mHere are some commands to get you started:\033[0m\n"
1482 "Before you can use the files located on your own filesystem,\n"
1483 "You have to mount the directory containing the files.\n"
1484 "\n"
1485 );
1486 MSG_Add("PROGRAM_INTRO_MOUNT_WINDOWS",
1487 "\033[44;1m\xC9\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1488 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1489 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBB\n"
1490 "\xBA \033[32mmount c c:\\dosprogs\\\033[37m will create a C drive with c:\\dosprogs as contents.\xBA\n"
1491 "\xBA \xBA\n"
1492 "\xBA \033[32mc:\\dosprogs\\\033[37m is an example. Replace it with your own games directory. \033[37m \xBA\n"
1493 "\xC8\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1494 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1495 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBC\033[0m\n"
1496 );
1497 MSG_Add("PROGRAM_INTRO_MOUNT_OTHER",
1498 "\033[44;1m\xC9\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1499 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1500 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBB\n"
1501 "\xBA \033[32mmount c ~/dosprogs\033[37m will create a C drive with ~/dosprogs as contents.\xBA\n"
1502 "\xBA \xBA\n"
1503 "\xBA \033[32m~/dosprogs\033[37m is an example. Replace it with your own games directory.\033[37m \xBA\n"
1504 "\xC8\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1505 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD"
1506 "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xBC\033[0m\n"
1507 );
1508 MSG_Add("PROGRAM_INTRO_MOUNT_END",
1509 "When the mount has successfully completed you can type \033[34;1mc:\033[0m to go to your freshly\n"
1510 "mounted C-drive. Typing \033[34;1mdir\033[0m there will show its contents."
1511 " \033[34;1mcd\033[0m will allow you to\n"
1512 "enter a directory (recognised by the \033[33;1m[]\033[0m in a directory listing).\n"
1513 "You can run programs/files which end with \033[31m.exe .bat\033[0m and \033[31m.com\033[0m.\n"
1514 );
1515 MSG_Add("PROGRAM_INTRO_CDROM",
1516 "\033[2J\033[32;1mHow to mount a Real/Virtual CD-ROM Drive in DOSBox:\033[0m\n"
1517 "DOSBox provides CD-ROM emulation on several levels.\n"
1518 "\n"
1519 "The \033[33mbasic\033[0m level works on all CD-ROM drives and normal directories.\n"
1520 "It installs MSCDEX and marks the files read-only.\n"
1521 "Usually this is enough for most games:\n"
1522 "\033[34;1mmount d \033[0;31mD:\\\033[34;1m -t cdrom\033[0m or \033[34;1mmount d C:\\example -t cdrom\033[0m\n"
1523 "If it doesn't work you might have to tell DOSBox the label of the CD-ROM:\n"
1524 "\033[34;1mmount d C:\\example -t cdrom -label CDLABEL\033[0m\n"
1525 "\n"
1526 "The \033[33mnext\033[0m level adds some low-level support.\n"
1527 "Therefore only works on CD-ROM drives:\n"
1528 "\033[34;1mmount d \033[0;31mD:\\\033[34;1m -t cdrom -usecd \033[33m0\033[0m\n"
1529 "\n"
1530 "The \033[33mlast\033[0m level of support depends on your Operating System:\n"
1531 "For \033[1mWindows 2000\033[0m, \033[1mWindows XP\033[0m and \033[1mLinux\033[0m:\n"
1532 "\033[34;1mmount d \033[0;31mD:\\\033[34;1m -t cdrom -usecd \033[33m0 \033[34m-ioctl\033[0m\n"
1533 "For \033[1mWindows 9x\033[0m with a ASPI layer installed:\n"
1534 "\033[34;1mmount d \033[0;31mD:\\\033[34;1m -t cdrom -usecd \033[33m0 \033[34m-aspi\033[0m\n"
1535 "\n"
1536 "Replace \033[0;31mD:\\\033[0m with the location of your CD-ROM.\n"
1537 "Replace the \033[33;1m0\033[0m in \033[34;1m-usecd \033[33m0\033[0m with the number reported for your CD-ROM if you type:\n"
1538 "\033[34;1mmount -cd\033[0m\n"
1539 );
1540 MSG_Add("PROGRAM_INTRO_SPECIAL",
1541 "\033[2J\033[32;1mSpecial keys:\033[0m\n"
1542 "These are the default keybindings.\n"
1543 "They can be changed in the \033[33mkeymapper\033[0m.\n"
1544 "\n"
1545 "\033[33;1mALT-ENTER\033[0m : Go full screen and back.\n"
1546 "\033[33;1mALT-PAUSE\033[0m : Pause DOSBox.\n"
1547 "\033[33;1mCTRL-F1\033[0m : Start the \033[33mkeymapper\033[0m.\n"
1548 "\033[33;1mCTRL-F4\033[0m : Update directory cache for all drives! Swap mounted disk-image.\n"
1549 "\033[33;1mCTRL-ALT-F5\033[0m : Start/Stop creating a movie of the screen.\n"
1550 "\033[33;1mCTRL-F5\033[0m : Save a screenshot.\n"
1551 "\033[33;1mCTRL-F6\033[0m : Start/Stop recording sound output to a wave file.\n"
1552 "\033[33;1mCTRL-ALT-F7\033[0m : Start/Stop recording of OPL commands.\n"
1553 "\033[33;1mCTRL-ALT-F8\033[0m : Start/Stop the recording of raw MIDI commands.\n"
1554 "\033[33;1mCTRL-F7\033[0m : Decrease frameskip.\n"
1555 "\033[33;1mCTRL-F8\033[0m : Increase frameskip.\n"
1556 "\033[33;1mCTRL-F9\033[0m : Kill DOSBox.\n"
1557 "\033[33;1mCTRL-F10\033[0m : Capture/Release the mouse.\n"
1558 "\033[33;1mCTRL-F11\033[0m : Slow down emulation (Decrease DOSBox Cycles).\n"
1559 "\033[33;1mCTRL-F12\033[0m : Speed up emulation (Increase DOSBox Cycles).\n"
1560 "\033[33;1mALT-F12\033[0m : Unlock speed (turbo button/fast forward).\n"
1561 );
1562 MSG_Add("PROGRAM_BOOT_NOT_EXIST","Bootdisk file does not exist. Failing.\n");
1563 MSG_Add("PROGRAM_BOOT_NOT_OPEN","Cannot open bootdisk file. Failing.\n");
1564 MSG_Add("PROGRAM_BOOT_WRITE_PROTECTED","Image file is read-only! Might create problems.\n");
1565 MSG_Add("PROGRAM_BOOT_PRINT_ERROR","This command boots DOSBox from either a floppy or hard disk image.\n\n"
1566 "For this command, one can specify a succession of floppy disks swappable\n"
1567 "by pressing Ctrl-F4, and -l specifies the mounted drive to boot from. If\n"
1568 "no drive letter is specified, this defaults to booting from the A drive.\n"
1569 "The only bootable drive letters are A, C, and D. For booting from a hard\n"
1570 "drive (C or D), the image should have already been mounted using the\n"
1571 "\033[34;1mIMGMOUNT\033[0m command.\n\n"
1572 "The syntax of this command is:\n\n"
1573 "\033[34;1mBOOT [diskimg1.img diskimg2.img] [-l driveletter]\033[0m\n"
1574 );
1575 MSG_Add("PROGRAM_BOOT_UNABLE","Unable to boot off of drive %c");
1576 MSG_Add("PROGRAM_BOOT_IMAGE_OPEN","Opening image file: %s\n");
1577 MSG_Add("PROGRAM_BOOT_IMAGE_NOT_OPEN","Cannot open %s");
1578 MSG_Add("PROGRAM_BOOT_BOOT","Booting from drive %c...\n");
1579 MSG_Add("PROGRAM_BOOT_CART_WO_PCJR","PCjr cartridge found, but machine is not PCjr");
1580 MSG_Add("PROGRAM_BOOT_CART_LIST_CMDS","Available PCjr cartridge commandos:%s");
1581 MSG_Add("PROGRAM_BOOT_CART_NO_CMDS","No PCjr cartridge commandos found");
1582
1583 MSG_Add("PROGRAM_IMGMOUNT_SPECIFY_DRIVE","Must specify drive letter to mount image at.\n");
1584 MSG_Add("PROGRAM_IMGMOUNT_SPECIFY2","Must specify drive number (0 or 3) to mount image at (0,1=fda,fdb;2,3=hda,hdb).\n");
1585 MSG_Add("PROGRAM_IMGMOUNT_SPECIFY_GEOMETRY",
1586 "For \033[33mCD-ROM\033[0m images: \033[34;1mIMGMOUNT drive-letter location-of-image -t iso\033[0m\n"
1587 "\n"
1588 "For \033[33mhardrive\033[0m images: Must specify drive geometry for hard drives:\n"
1589 "bytes_per_sector, sectors_per_cylinder, heads_per_cylinder, cylinder_count.\n"
1590 "\033[34;1mIMGMOUNT drive-letter location-of-image -size bps,spc,hpc,cyl\033[0m\n");
1591 MSG_Add("PROGRAM_IMGMOUNT_INVALID_IMAGE","Could not load image file.\n"
1592 "Check that the path is correct and the image is accessible.\n");
1593 MSG_Add("PROGRAM_IMGMOUNT_INVALID_GEOMETRY","Could not extract drive geometry from image.\n"
1594 "Use parameter -size bps,spc,hpc,cyl to specify the geometry.\n");
1595 MSG_Add("PROGRAM_IMGMOUNT_TYPE_UNSUPPORTED","Type \"%s\" is unsupported. Specify \"hdd\" or \"floppy\" or\"iso\".\n");
1596 MSG_Add("PROGRAM_IMGMOUNT_FORMAT_UNSUPPORTED","Format \"%s\" is unsupported. Specify \"fat\" or \"iso\" or \"none\".\n");
1597 MSG_Add("PROGRAM_IMGMOUNT_SPECIFY_FILE","Must specify file-image to mount.\n");
1598 MSG_Add("PROGRAM_IMGMOUNT_FILE_NOT_FOUND","Image file not found.\n");
1599 MSG_Add("PROGRAM_IMGMOUNT_MOUNT","To mount directories, use the \033[34;1mMOUNT\033[0m command, not the \033[34;1mIMGMOUNT\033[0m command.\n");
1600 MSG_Add("PROGRAM_IMGMOUNT_ALREADY_MOUNTED","Drive already mounted at that letter.\n");
1601 MSG_Add("PROGRAM_IMGMOUNT_CANT_CREATE","Can't create drive from file.\n");
1602 MSG_Add("PROGRAM_IMGMOUNT_MOUNT_NUMBER","Drive number %d mounted as %s\n");
1603 MSG_Add("PROGRAM_IMGMOUNT_NON_LOCAL_DRIVE", "The image must be on a host or local drive.\n");
1604 MSG_Add("PROGRAM_IMGMOUNT_MULTIPLE_NON_CUEISO_FILES", "Using multiple files is only supported for cue/iso images.\n");
1605
1606 MSG_Add("PROGRAM_KEYB_INFO","Codepage %i has been loaded\n");
1607 MSG_Add("PROGRAM_KEYB_INFO_LAYOUT","Codepage %i has been loaded for layout %s\n");
1608 MSG_Add("PROGRAM_KEYB_SHOWHELP",
1609 "\033[32;1mKEYB\033[0m [keyboard layout ID[ codepage number[ codepage file]]]\n\n"
1610 "Some examples:\n"
1611 " \033[32;1mKEYB\033[0m: Display currently loaded codepage.\n"
1612 " \033[32;1mKEYB\033[0m sp: Load the spanish (SP) layout, use an appropriate codepage.\n"
1613 " \033[32;1mKEYB\033[0m sp 850: Load the spanish (SP) layout, use codepage 850.\n"
1614 " \033[32;1mKEYB\033[0m sp 850 mycp.cpi: Same as above, but use file mycp.cpi.\n");
1615 MSG_Add("PROGRAM_KEYB_NOERROR","Keyboard layout %s loaded for codepage %i\n");
1616 MSG_Add("PROGRAM_KEYB_FILENOTFOUND","Keyboard file %s not found\n\n");
1617 MSG_Add("PROGRAM_KEYB_INVALIDFILE","Keyboard file %s invalid\n");
1618 MSG_Add("PROGRAM_KEYB_LAYOUTNOTFOUND","No layout in %s for codepage %i\n");
1619 MSG_Add("PROGRAM_KEYB_INVCPFILE","None or invalid codepage file for layout %s\n\n");
1620
1621 /*regular setup*/
1622 PROGRAMS_MakeFile("MOUNT.COM",MOUNT_ProgramStart);
1623 PROGRAMS_MakeFile("MEM.COM",MEM_ProgramStart);
1624 PROGRAMS_MakeFile("LOADFIX.COM",LOADFIX_ProgramStart);
1625 PROGRAMS_MakeFile("RESCAN.COM",RESCAN_ProgramStart);
1626 PROGRAMS_MakeFile("INTRO.COM",INTRO_ProgramStart);
1627 PROGRAMS_MakeFile("BOOT.COM",BOOT_ProgramStart);
1628 #if C_DEBUG
1629 PROGRAMS_MakeFile("LDGFXROM.COM", LDGFXROM_ProgramStart);
1630 #endif
1631 PROGRAMS_MakeFile("IMGMOUNT.COM", IMGMOUNT_ProgramStart);
1632 PROGRAMS_MakeFile("KEYB.COM", KEYB_ProgramStart);
1633 }
1634