git @ Cat's Eye Technologies linapple / 3b74e44
Merge branch '2.1.1-catseye' into userdir-vs-assets Chris Pressey 6 years ago
8 changed file(s) with 31 addition(s) and 80 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.
1111 #define LINAPPLE_VERSION 2
1212
1313 #include <curl/curl.h>
14
15 extern FILE * spMono,*spStereo;
1614
1715 extern char VERSIONSTRING[]; // Contructed in WinMain()
1816
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 ChangeToUserDirectory();
2727 bool ValidateUserDirectory();
2828 bool CopyFile(std::string source, std::string dest);
2929 std::string GetUserFilePath();
30 std::string GetRegistryPath();
3031 protected:
3132 std::string GetHomePath();
3233 std::string GetInstallPath();
3334 private:
3435 std::string m_optsFilePath;
36 std::string m_regFilePath;
3537 };
3638
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);
782782 }
783783
784784
785 FILE *spMono, *spStereo;
786
787785 //---------------------------------------------------------------------------
788786
789787 int main(int argc, char * lpCmdLine[])
794792
795793 // GPH: The very first thing we do is attempt to grab the needed configuration files and put them in the user's folder.
796794 Config config;
797 if (!config.ValidateUserDirectory()) {
798 return 1;
799 }
800 config.ChangeToUserDirectory();
801
795 config.ValidateUserDirectory();
802796
803797 // reading FullScreen and Boot from conf file?
804798 bool bSetFullScreen = false;
805799 bool bBoot = false;
806800
807 registry = fopen(REGISTRY, "rt"); // open conf file (linapple.conf by default)
808 spMono = fopen("speakersmono.pcm","wb");
809 spStereo = fopen("speakersstereo.pcm","wb");
801 registry = fopen(config.GetRegistryPath().c_str(), "rt"); // open conf file (linapple.conf by default)
810802
811803 LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
812804 LPSTR szImageName_drive2 = NULL;
10991091 {
11001092 fclose(registry); //close conf file (linapple.conf by default)
11011093 }
1102 fclose(spMono);
1103 fclose(spStereo);
11041094
11051095 SDL_Quit();
11061096 // CURL routines
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);
2424 return m_optsFilePath.c_str();
2525 }
2626
27 void Config::ChangeToUserDirectory()
27 std::string Config::GetRegistryPath()
2828 {
29 if(chdir((GetHomePath() + USER_DIRECTORY_NAME).c_str()))
30 {
31 cout << "Cannot switch to user directory ('" << GetUserFilePath().c_str() << "')" << std::endl;
32 }
29 m_regFilePath = GetUserFilePath() + REGISTRY_NAME;
30 return m_regFilePath.c_str();
3331 }
3432
3533 // Simple POSIX file copy