git @ Cat's Eye Technologies linapple / e7c88c9
Merge branch 'allow-relative-path-in-cmdline' into 2.1.1-catseye Chris Pressey 6 years ago
8 changed file(s) with 30 addition(s) and 83 deletion(s). Raw diff Collapse all Expand all
+0
-34
Command-line.md less more
0 # LinApple #
1 ## Command-line fork ##
2
3 This is a fork of the LinApple Apple ][e emulator for Linux. This fork allows certain options to be specified from the command line when running LinApple.
4
5 Currently, the following command line options are available:
6
7 * -d1: Specifies a disk image to load into FDD1 (drive 0)
8 * -d2: Specifies a disk image to load into FDD1 (drive 1)
9 * -f: Specifies that the emulator should run in fullscreen mode
10 * -b : Specifies that benchmark should be loaded
11 * -l: Logs output to a file called AppleWin.log
12 * -m: Disables direct sound
13 * -autoboot: Boots the system automatically, rather than displaying the splash screen
14
15 When specifying disk images, the full path should be used (e.g. `linapple -d1 /home/myname/disks/MYSTHOUS.DSK`
16
17 Currently, only the options to specify disks start in fullscreen, and auto boot have been tested.
18
19 This fork is far from perfect, and has not been tested extensively. The main purpose is to allow users to set up custom shell scripts which they may use to automatically load
20 certain Apple ][ games or programs with the click of a button. While this need is met by this fork, extensive testing has not been performed to ensure new bugs were not
21 introduced by these changes.
22
23 A simple script can be set up to run an Apple ][ game or program by combining the -d1, -f, and -autoboot options, for example:
24
25 linapple -d1 /path/to/disk/image -f -autoboot
26
27 ### TODO ###
28
29 1. Testing is needed to make sure the other command line options are working correctly. Currently, only the -d1, -d2, and -f options have been tested.
30 2. Extensive testing is needed to ensure that these changes have not inadvertently broken other features of the program. Unfortunately, a test suite did not come with the
31 original code, so I have not been able to test this.
32 3. Add a command line switch which allows the user to specify different configuration files.
33
1212
1313 ## Command Line Switches
1414
15 * -d1: Specifies a disk image to load into FDD1 (drive 0)
16 * -d2: Specifies a disk image to load into FDD1 (drive 1)
17 * -f: Specifies that the emulator should run in fullscreen mode
18 * -b : Specifies that benchmark should be loaded
19 * -l: Logs output to a file called AppleWin.log
20 * -m: Disables direct sound
21 * -autoboot: Boots the system automatically, rather than displaying the splash screen
22
23 When specifying disk images, the full path should be used. e.g. `linapple -d1 /home/myname/disks/MYSTHOUS.DSK`
24
25 Currently, only the options to specify disks start in fullscreen, and auto boot have been tested.
15 * `-d1 path/to/image1.dsk`: Specifies a disk image to load into FDD1 (drive 0)
16 * `-d2 path/to/image2.dsk`: Specifies a disk image to load into FDD1 (drive 1)
17 * `-f`: Specifies that the emulator should run in fullscreen mode
18 * `-b`: Specifies that benchmark should be loaded (untested)
19 * `-l`: Logs output to a file called AppleWin.log (untested)
20 * `-m`: Disables direct sound (untested)
21 * `-autoboot`: Boots the system automatically, rather than displaying the splash screen
2622
2723 ## Using LinApple
2824
9187
9288 List the current program in memory.
9389
94 ## Other
95 This fork is far from perfect, and has not been tested extensively. The main purpose is to allow users to set up custom
96 shell scripts which they may use to automatically load certain Apple ][ games or programs with the click of a button.
97 While this need is met by this fork, extensive testing has not been performed to ensure new bugs were not introduced by
98 these changes.
90 ### Command-line options
9991
100 A simple script can be set up to run an Apple ][ game or program by combining the -d1, -f, and -autoboot options, for example:
92 Support for command-line options was originally added to linapple to allow users to set up
93 custom shell scripts to automatically load certain Apple ][ programs with the click of a
94 button, but it is evolving towards conventional command-line usage.
95
96 For example, to have linapple start in fullscreen and automatically boot the disk
97 `example.dsk`, you can open a shell and run
10198
10299 ```bash
103 linapple -d1 /path/to/disk/image -f -autoboot
100 linapple -d1 example.dsk -f -autoboot
104101 ```
105102
106 ## Todo
103 This command could also be placed in a shell script, which could be started from an
104 icon or menu on the desktop, etc.
107105
108 * Testing is needed to make sure the other command line options are working correctly. Currently, only the -d1, -d2, and
109 -f options have been tested.
110 * Extensive testing is needed to ensure that these changes have not inadvertently broken other features of the program.
111 Unfortunately, a test suite did not come with the original code, so we have not been able to test this.
106 Note that extensive testing has not been performed on all command-line options.
107
108 #### TODO
109
112110 * Add a command line switch which allows the user to specify different configuration files.
00 #pragma once
11
2 // configuration file
3 #define REGISTRY "linapple.conf"
42 extern FILE * registry; // our opened file
53
64 BOOL RegLoadString (LPCTSTR,LPCTSTR,BOOL,char**,DWORD);
66 #include <string>
77
88 #define USER_DIRECTORY_NAME "/linapple/"
9 #define REGISTRY_NAME "linapple.conf"
910 #define CONF_DIRECTORY_NAME "/conf/"
1011 #define SAVED_DIRECTORY_NAME "/saved/"
1112 #define FTP_DIRECTORY_NAME "/ftp/"
2324 Config();
2425 ~Config() {};
2526
26 void ChangeToHomeDirectory();
27 void ChangeToUserDirectory();
2827 bool ValidateUserDirectory();
2928 bool CopyFile(std::string source, std::string dest);
3029 std::string GetUserFilePath();
30 std::string GetRegistryPath();
3131 protected:
3232 std::string GetHomePath();
3333 std::string GetInstallPath();
3434 private:
3535 std::string m_optsFilePath;
36 std::string m_regFilePath;
3637 };
3738
454454
455455 if(registry==NULL)
456456 {
457 printf("File " REGISTRY " could not be opened. Using default configuration.\n");
457 printf("Registry file (linapple.conf) could not be opened. Using default configuration.\n");
458458 return;
459459 }
460460 LOAD(TEXT("Computer Emulation"),&dwComputerType);
795795 // GPH: The very first thing we do is attempt to grab the needed configuration files and put them in the user's folder.
796796 Config config;
797797 config.ValidateUserDirectory();
798 config.ChangeToUserDirectory();
799
800798
801799 // reading FullScreen and Boot from conf file?
802800 bool bSetFullScreen = false;
803801 bool bBoot = false;
804802
805 registry = fopen(REGISTRY, "rt"); // open conf file (linapple.conf by default)
803 registry = fopen(config.GetRegistryPath().c_str(), "rt"); // open conf file (linapple.conf by default)
806804 spMono = fopen("speakersmono.pcm","wb");
807805 spStereo = fopen("speakersstereo.pcm","wb");
808806
212212 fseek(tempf, 0, SEEK_SET);
213213 // fclose(tempf);
214214 // return;
215 // FIXME if you re-enable this code, you will need to call config.GetRegistryPath() here instead!
215216 registry = fopen(REGISTRY, "w+t"); // erase if been
216217 while(fgets(line, BUFSIZE, tempf)) {
217218 fputs(line, registry);
18861886
18871887 //===========================================================================
18881888 void VideoInitialize () {
1889 Config config;
1890 config.ChangeToUserDirectory();
1891
18921889 // CREATE A BUFFER FOR AN IMAGE OF THE LAST DRAWN MEMORY
18931890 vidlastmem = (LPBYTE)VirtualAlloc(NULL,0x10000,MEM_COMMIT,PAGE_READWRITE);
18941891 ZeroMemory(vidlastmem,0x10000);
2424 return m_optsFilePath.c_str();
2525 }
2626
27 void Config::ChangeToHomeDirectory()
27 std::string Config::GetRegistryPath()
2828 {
29 if(chdir(GetHomePath().c_str()))
30 {
31 // TODO: LOG ERROR
32 cout << "Cannot switch to home directory ('" << GetHomePath().c_str() << "')" << std::endl;
33 }
34 }
35
36 void Config::ChangeToUserDirectory()
37 {
38 if(chdir(GetUserFilePath().c_str()))
39 {
40
41 cout << "Cannot switch to user directory ('" << GetUserFilePath().c_str() << "')" << std::endl;
42 }
29 m_regFilePath = GetUserFilePath() + REGISTRY_NAME;
30 return m_regFilePath.c_str();
4331 }
4432
4533 // Simple POSIX file copy