Merge branch 'allow-relative-path-in-cmdline' into 2.1.1-catseye
Chris Pressey
6 years ago
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 |
12 | 12 | |
13 | 13 | ## Command Line Switches |
14 | 14 | |
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 | |
26 | 22 | |
27 | 23 | ## Using LinApple |
28 | 24 | |
91 | 87 | |
92 | 88 | List the current program in memory. |
93 | 89 | |
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 | |
99 | 91 | |
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 | |
101 | 98 | |
102 | 99 | ```bash |
103 | linapple -d1 /path/to/disk/image -f -autoboot | |
100 | linapple -d1 example.dsk -f -autoboot | |
104 | 101 | ``` |
105 | 102 | |
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. | |
107 | 105 | |
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 | ||
112 | 110 | * Add a command line switch which allows the user to specify different configuration files. |
0 | 0 | #pragma once |
1 | 1 | |
2 | // configuration file | |
3 | #define REGISTRY "linapple.conf" | |
4 | 2 | extern FILE * registry; // our opened file |
5 | 3 | |
6 | 4 | BOOL RegLoadString (LPCTSTR,LPCTSTR,BOOL,char**,DWORD); |
6 | 6 | #include <string> |
7 | 7 | |
8 | 8 | #define USER_DIRECTORY_NAME "/linapple/" |
9 | #define REGISTRY_NAME "linapple.conf" | |
9 | 10 | #define CONF_DIRECTORY_NAME "/conf/" |
10 | 11 | #define SAVED_DIRECTORY_NAME "/saved/" |
11 | 12 | #define FTP_DIRECTORY_NAME "/ftp/" |
23 | 24 | Config(); |
24 | 25 | ~Config() {}; |
25 | 26 | |
26 | void ChangeToHomeDirectory(); | |
27 | void ChangeToUserDirectory(); | |
28 | 27 | bool ValidateUserDirectory(); |
29 | 28 | bool CopyFile(std::string source, std::string dest); |
30 | 29 | std::string GetUserFilePath(); |
30 | std::string GetRegistryPath(); | |
31 | 31 | protected: |
32 | 32 | std::string GetHomePath(); |
33 | 33 | std::string GetInstallPath(); |
34 | 34 | private: |
35 | 35 | std::string m_optsFilePath; |
36 | std::string m_regFilePath; | |
36 | 37 | }; |
37 | 38 |
454 | 454 | |
455 | 455 | if(registry==NULL) |
456 | 456 | { |
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"); | |
458 | 458 | return; |
459 | 459 | } |
460 | 460 | LOAD(TEXT("Computer Emulation"),&dwComputerType); |
795 | 795 | // GPH: The very first thing we do is attempt to grab the needed configuration files and put them in the user's folder. |
796 | 796 | Config config; |
797 | 797 | config.ValidateUserDirectory(); |
798 | config.ChangeToUserDirectory(); | |
799 | ||
800 | 798 | |
801 | 799 | // reading FullScreen and Boot from conf file? |
802 | 800 | bool bSetFullScreen = false; |
803 | 801 | bool bBoot = false; |
804 | 802 | |
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) | |
806 | 804 | spMono = fopen("speakersmono.pcm","wb"); |
807 | 805 | spStereo = fopen("speakersstereo.pcm","wb"); |
808 | 806 |
212 | 212 | fseek(tempf, 0, SEEK_SET); |
213 | 213 | // fclose(tempf); |
214 | 214 | // return; |
215 | // FIXME if you re-enable this code, you will need to call config.GetRegistryPath() here instead! | |
215 | 216 | registry = fopen(REGISTRY, "w+t"); // erase if been |
216 | 217 | while(fgets(line, BUFSIZE, tempf)) { |
217 | 218 | fputs(line, registry); |
1886 | 1886 | |
1887 | 1887 | //=========================================================================== |
1888 | 1888 | void VideoInitialize () { |
1889 | Config config; | |
1890 | config.ChangeToUserDirectory(); | |
1891 | ||
1892 | 1889 | // CREATE A BUFFER FOR AN IMAGE OF THE LAST DRAWN MEMORY |
1893 | 1890 | vidlastmem = (LPBYTE)VirtualAlloc(NULL,0x10000,MEM_COMMIT,PAGE_READWRITE); |
1894 | 1891 | ZeroMemory(vidlastmem,0x10000); |
24 | 24 | return m_optsFilePath.c_str(); |
25 | 25 | } |
26 | 26 | |
27 | void Config::ChangeToHomeDirectory() | |
27 | std::string Config::GetRegistryPath() | |
28 | 28 | { |
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(); | |
43 | 31 | } |
44 | 32 | |
45 | 33 | // Simple POSIX file copy |