Update the discussion of themeing in the manual, and put a note in the wps tags appen...
[kugel-rb.git] / apps / plugins / zxbox / zxbox.c
blobf33b51b9f650111eb386d6a914032e3e94ed2a85
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2006 Anton Romanov
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "zxconfig.h"
24 PLUGIN_HEADER
25 PLUGIN_IRAM_DECLARE
27 #include "spkey_p.h"
29 spkeyboard kb_mkey;
30 bool exit_requested=false;
31 bool clear_kbd=0;
32 extern bool zxbox_menu(void);
34 /* DUMMIES ... to clean */
35 unsigned int scrmul=0;
36 int privatemap;
37 int use_shm = 0;
38 int small_screen,pause_on_iconify;
39 int vga_pause_bg;
41 #include "keymaps.h"
42 #include "zxvid_com.h"
43 #include "spmain.h"
44 #include "spperif.h"
46 struct zxbox_settings settings;
48 /* doesn't fit into .ibss */
49 unsigned char image_array [ HEIGHT * WIDTH ];
51 static int previous_state;
53 #ifdef USE_GREY
54 GREY_INFO_STRUCT_IRAM
55 static unsigned char *gbuf;
56 static size_t gbuf_size = 0;
57 #endif
59 long video_frames IBSS_ATTR = 0 ;
60 long start_time IBSS_ATTR = 0;
62 enum plugin_status plugin_start(const void* parameter)
64 PLUGIN_IRAM_INIT(rb)
66 #if LCD_DEPTH > 1
67 rb->lcd_set_backdrop(NULL);
68 #endif
69 rb->splash(HZ, "Welcome to ZXBox");
72 sp_init();
74 #ifdef USE_GREY
75 /* get the remainder of the plugin buffer */
76 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
77 #ifdef USE_BUFFERED_GREY
78 grey_init(gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH,
79 LCD_HEIGHT, NULL);
80 #else
81 grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL);
82 #endif /* USE_BUFFERED_GREY */
83 /* switch on greyscale overlay */
84 grey_show(true);
85 #endif /* USE_GREY */
88 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
89 rb->cpu_boost(true);
90 #endif
92 start_time = *rb->current_tick;
94 #ifdef RB_PROFILE
95 rb->profile_thread();
96 #endif
98 start_spectemu(parameter);
100 #ifdef RB_PROFILE
101 rb->profstop();
102 #endif
104 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
105 rb->cpu_boost(false);
106 #endif
108 #ifdef USE_GREY
109 grey_show(false);
110 grey_release();
111 #endif
113 #if CONFIG_CODEC == SWCODEC && !defined SIMULATOR
114 rb->pcm_play_stop();
115 #endif
117 return PLUGIN_OK;
120 void init_spect_key(void)
122 clear_keystates();
123 init_basekeys();
126 void spkb_process_events( int evenframe )
129 if(evenframe){
130 int ki;
131 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
132 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
133 if (rb->button_hold())
135 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
136 rb->cpu_boost(false);
137 #endif
138 exit_requested=1;
139 #ifdef USE_GREY
140 grey_show(false);
141 #endif
142 return;
144 #endif
145 int buttons = rb->button_status();
146 if ( buttons == previous_state )
147 return;
148 previous_state = buttons;
149 #if (CONFIG_KEYPAD != IPOD_4G_PAD) && (CONFIG_KEYPAD != IPOD_3G_PAD) && \
150 (CONFIG_KEYPAD != IPOD_1G2G_PAD)
151 if (buttons & ZX_MENU)
153 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
154 rb->cpu_boost(false);
155 #endif
156 exit_requested=1;
157 #ifdef USE_GREY
158 grey_show(false);
159 #endif
160 return;
162 #endif
163 spkb_state_changed = 1;
164 if (settings.kempston){
165 if ( buttons & ZX_RIGHT ){
166 ki = KS_TO_KEY(SK_KP_Right);
167 spkb_kbstate[ki].state = 1;
169 else if (buttons & ZX_LEFT){
170 ki = KS_TO_KEY(SK_KP_Left);
171 spkb_kbstate[ki].state = 1;
174 else{
175 ki = KS_TO_KEY(SK_KP_Right);
176 spkb_kbstate[ki].state = 0;
177 ki = KS_TO_KEY(SK_KP_Left);
178 spkb_kbstate[ki].state = 0;
181 if ( buttons & ZX_UP ){
182 ki = KS_TO_KEY(SK_KP_Up);
183 spkb_kbstate[ki].state = 1;
185 else if (buttons & ZX_DOWN){
186 ki = KS_TO_KEY(SK_KP_Down);
187 spkb_kbstate[ki].state = 1;
189 else{
190 ki = KS_TO_KEY(SK_KP_Up);
191 spkb_kbstate[ki].state = 0;
192 ki = KS_TO_KEY(SK_KP_Down);
193 spkb_kbstate[ki].state = 0;
196 if ( buttons & ZX_SELECT ){
197 ki = KS_TO_KEY(SK_KP_Insert);
198 spkb_kbstate[ki].state = 1;
200 else{
201 ki = KS_TO_KEY(SK_KP_Insert);
202 spkb_kbstate[ki].state = 0;
206 else {
208 if ( buttons & ZX_RIGHT ){
209 ki = KS_TO_KEY(intkeys[3]);
210 spkb_kbstate[ki].state = 1;
212 else{
213 ki = KS_TO_KEY(intkeys[3]);
214 spkb_kbstate[ki].state = 0;
217 if ( buttons & ZX_LEFT ){
218 ki = KS_TO_KEY(intkeys[2]);
219 spkb_kbstate[ki].state = 1;
221 else{
222 ki = KS_TO_KEY(intkeys[2]);
223 spkb_kbstate[ki].state = 0;
226 if ( buttons & ZX_UP ){
227 ki = KS_TO_KEY(intkeys[0]);
228 spkb_kbstate[ki].state = 1;
230 else{
231 ki = KS_TO_KEY(intkeys[0]);
232 spkb_kbstate[ki].state = 0;
235 if ( buttons & ZX_DOWN ){
236 ki = KS_TO_KEY(intkeys[1]);
237 spkb_kbstate[ki].state = 1;
239 else{
240 ki = KS_TO_KEY(intkeys[1]);
241 spkb_kbstate[ki].state = 0;
244 if ( buttons & ZX_SELECT ){
245 ki = KS_TO_KEY(intkeys[4]);
246 spkb_kbstate[ki].state = 1;
248 else{
249 ki = KS_TO_KEY(intkeys[4]);
250 spkb_kbstate[ki].state = 0;
253 process_keys();
257 void press_key(int c){
258 spkb_state_changed = 1;
259 int ki;
260 if ( c == 'E' )
261 ki = KS_TO_KEY(SK_KP_Enter);
262 else if (c == 'S' )
263 ki = KS_TO_KEY(SK_KP_Space);
264 else
265 ki = KS_TO_KEY(c);
266 spkb_kbstate[ki].state = 1;
267 process_keys();