summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/rockboy.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-01-20 13:05:52 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-01-20 13:05:52 +0000
commit137fb6cb9f0478303610443b95ae0a106f0a17d1 (patch)
tree9ac6685589536bc7c84962db8398fddf9d2b3154 /apps/plugins/rockboy/rockboy.c
parentc05cd1676f323f1346099f436aaa0212fd18e178 (diff)
downloadrockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.tar.gz
rockbox-137fb6cb9f0478303610443b95ae0a106f0a17d1.zip
Karl Kurbjun's patch #1407719:
Here's another patch for rockboy that adds automatic frameskip (it's pretty rough as I haven't figured out an accurate timer), fullscreen support on the H300, and a bit of assembly and some IRAM stuff. I'm not sure if I'm doing the IRAM stuff correct though as it doesn't seem to make much of a difference if any. I've also added a statistics option that will show how many frames per second the gameboy is seeing (not what the player is getting) and what the frameskip is at. When you enable stats sometimes you have to go back into the menu and then come out to clear erronous values. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8397 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/rockboy.c')
-rw-r--r--apps/plugins/rockboy/rockboy.c78
1 files changed, 75 insertions, 3 deletions
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index a7e9bfb8f1..f6dea0eeea 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -39,6 +39,8 @@ char *errormsg;
39int gnuboy_main(char *rom); 39int gnuboy_main(char *rom);
40void pcm_close(void); 40void pcm_close(void);
41 41
42#define optionname "options"
43
42void die(char *message, ...) 44void die(char *message, ...)
43{ 45{
44 shut=1; 46 shut=1;
@@ -74,6 +76,74 @@ void setmallocpos(void *pointer)
74 audio_buffer_free = audio_bufferpointer - audio_bufferbase; 76 audio_buffer_free = audio_bufferpointer - audio_bufferbase;
75} 77}
76 78
79void setoptions (void) {
80 int fd;
81 DIR* dir;
82 char optionsave[sizeof(savedir)+sizeof(optionname)];
83
84 dir=opendir(savedir);
85 if(!dir)
86 mkdir(savedir,0);
87 else
88 closedir(dir);
89
90 snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname);
91
92 fd = open(optionsave, O_RDONLY);
93 if(fd < 0) // no options to read, set defaults
94 {
95#if (CONFIG_KEYPAD == IRIVER_H100_PAD)
96 options.A=BUTTON_ON;
97 options.B=BUTTON_OFF;
98 options.START=BUTTON_REC;
99 options.SELECT=BUTTON_SELECT;
100 options.MENU=BUTTON_MODE;
101
102#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
103 options.A=BUTTON_REC;
104 options.B=BUTTON_MODE;
105 options.START=BUTTON_ON;
106 options.SELECT=BUTTON_SELECT;
107 options.MENU=BUTTON_OFF;
108
109#elif CONFIG_KEYPAD == RECORDER_PAD
110 options.A=BUTTON_F1;
111 options.B=BUTTON_F2;
112 options.START=BUTTON_F3;
113 options.SELECT=BUTTON_PLAY;
114 options.MENU=BUTTON_OFF;
115
116#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
117 options.A=BUTTON_PLAY;
118 options.B=BUTTON_EQ;
119 options.START=BUTTON_MODE;
120 options.SELECT=(BUTTON_SELECT | BUTTON_REL);
121 options.MENU=(BUTTON_SELECT | BUTTON_REPEAT);
122#endif
123
124 options.maxskip=4;
125 options.fps=0;
126 options.showstats=0;
127 options.fullscreen=1;
128 options.sound=1;
129 }
130 else
131 read(fd,&options, sizeof(options));
132
133 close(fd);
134}
135
136void savesettings(void)
137{
138 int fd;
139 char optionsave[sizeof(savedir)+sizeof(optionname)];
140
141 snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname);
142 fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC);
143 write(fd,&options, sizeof(options));
144 close(fd);
145}
146
77/* this is the plugin entry point */ 147/* this is the plugin entry point */
78enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 148enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
79{ 149{
@@ -96,7 +166,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
96 < audio_buffer_free) 166 < audio_buffer_free)
97 audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase; 167 audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase;
98#endif 168#endif
99 169 setoptions();
100#ifdef USE_IRAM 170#ifdef USE_IRAM
101 memcpy(iramstart, iramcopy, iramend-iramstart); 171 memcpy(iramstart, iramcopy, iramend-iramstart);
102 memset(iedata, 0, iend - iedata); 172 memset(iedata, 0, iend - iedata);
@@ -110,11 +180,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
110 gnuboy_main(parameter); 180 gnuboy_main(parameter);
111 181
112 if(shut&&!cleanshut) { 182 if(shut&&!cleanshut) {
113 rb->splash(HZ*2, true, errormsg); 183 rb->splash(HZ/2, true, errormsg);
114 return PLUGIN_ERROR; 184 return PLUGIN_ERROR;
115 } 185 }
116 pcm_close(); 186 pcm_close();
117 rb->splash(HZ*2, true, "Shutting down.. byebye ^^"); 187 rb->splash(HZ/2, true, "Shutting down");
188
189 savesettings();
118 190
119 cleanup(); 191 cleanup();
120 192