FS#12756 by Marek Salaba - update Czech translation
[maemo-rb.git] / apps / plugins / zxbox / zxbox.c
blob81a79dc70ab65ee374e4f38c1489210b8128ba33
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"
23 #include "spkey_p.h"
24 #include "spkey.h"
26 spkeyboard kb_mkey;
27 bool exit_requested=false;
28 bool clear_kbd=0;
29 extern bool zxbox_menu(void);
31 /* DUMMIES ... to clean */
32 int privatemap;
33 int use_shm = 0;
34 int small_screen,pause_on_iconify;
35 int vga_pause_bg;
37 #include "keymaps.h"
38 #include "zxvid_com.h"
39 #include "spmain.h"
40 #include "spperif.h"
42 struct zxbox_settings settings;
44 /* doesn't fit into .ibss */
45 unsigned char image_array [ HEIGHT * WIDTH ];
47 static int previous_state;
49 #ifdef USE_GREY
50 GREY_INFO_STRUCT_IRAM
51 static unsigned char *gbuf;
52 static size_t gbuf_size = 0;
53 #endif
55 long video_frames IBSS_ATTR = 0 ;
56 long start_time IBSS_ATTR = 0;
58 enum plugin_status plugin_start(const void* parameter)
60 #if LCD_DEPTH > 1
61 rb->lcd_set_backdrop(NULL);
62 #endif
63 rb->splash(HZ, "Welcome to ZXBox");
66 sp_init();
68 #ifdef USE_GREY
69 /* get the remainder of the plugin buffer */
70 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
71 #ifdef USE_BUFFERED_GREY
72 grey_init(gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH,
73 LCD_HEIGHT, NULL);
74 #else
75 grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL);
76 #endif /* USE_BUFFERED_GREY */
77 /* switch on greyscale overlay */
78 grey_show(true);
79 #endif /* USE_GREY */
82 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
83 rb->cpu_boost(true);
84 #endif
86 start_time = *rb->current_tick;
88 #ifdef RB_PROFILE
89 rb->profile_thread();
90 #endif
92 start_spectemu(parameter);
94 #ifdef RB_PROFILE
95 rb->profstop();
96 #endif
98 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
99 rb->cpu_boost(false);
100 #endif
102 #ifdef USE_GREY
103 grey_show(false);
104 grey_release();
105 #endif
107 #if CONFIG_CODEC == SWCODEC && !defined SIMULATOR
108 rb->pcm_play_stop();
109 #endif
111 return PLUGIN_OK;
114 void init_spect_key(void)
116 clear_keystates();
117 init_basekeys();
120 void spkb_process_events( int evenframe )
123 if(evenframe){
124 int ki;
125 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
126 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
127 if (rb->button_hold())
129 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
130 rb->cpu_boost(false);
131 #endif
132 exit_requested=1;
133 #ifdef USE_GREY
134 grey_show(false);
135 #endif
136 return;
138 #endif
139 int buttons = rb->button_status();
140 if ( buttons == previous_state )
141 return;
142 previous_state = buttons;
143 #if (CONFIG_KEYPAD != IPOD_4G_PAD) && (CONFIG_KEYPAD != IPOD_3G_PAD) && \
144 (CONFIG_KEYPAD != IPOD_1G2G_PAD)
145 if (buttons & ZX_MENU)
147 #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
148 rb->cpu_boost(false);
149 #endif
150 exit_requested=1;
151 #ifdef USE_GREY
152 grey_show(false);
153 #endif
154 return;
156 #endif
157 spkb_state_changed = 1;
158 if (settings.kempston){
159 if ( buttons & ZX_RIGHT ){
160 ki = KS_TO_KEY(SK_KP_Right);
161 spkb_kbstate[ki].state = 1;
163 else if (buttons & ZX_LEFT){
164 ki = KS_TO_KEY(SK_KP_Left);
165 spkb_kbstate[ki].state = 1;
168 else{
169 ki = KS_TO_KEY(SK_KP_Right);
170 spkb_kbstate[ki].state = 0;
171 ki = KS_TO_KEY(SK_KP_Left);
172 spkb_kbstate[ki].state = 0;
175 if ( buttons & ZX_UP ){
176 ki = KS_TO_KEY(SK_KP_Up);
177 spkb_kbstate[ki].state = 1;
179 else if (buttons & ZX_DOWN){
180 ki = KS_TO_KEY(SK_KP_Down);
181 spkb_kbstate[ki].state = 1;
183 else{
184 ki = KS_TO_KEY(SK_KP_Up);
185 spkb_kbstate[ki].state = 0;
186 ki = KS_TO_KEY(SK_KP_Down);
187 spkb_kbstate[ki].state = 0;
190 if ( buttons & ZX_SELECT ){
191 ki = KS_TO_KEY(SK_KP_Insert);
192 spkb_kbstate[ki].state = 1;
194 else{
195 ki = KS_TO_KEY(SK_KP_Insert);
196 spkb_kbstate[ki].state = 0;
200 else {
202 if ( buttons & ZX_RIGHT ){
203 ki = KS_TO_KEY(intkeys[3]);
204 spkb_kbstate[ki].state = 1;
206 else{
207 ki = KS_TO_KEY(intkeys[3]);
208 spkb_kbstate[ki].state = 0;
211 if ( buttons & ZX_LEFT ){
212 ki = KS_TO_KEY(intkeys[2]);
213 spkb_kbstate[ki].state = 1;
215 else{
216 ki = KS_TO_KEY(intkeys[2]);
217 spkb_kbstate[ki].state = 0;
220 if ( buttons & ZX_UP ){
221 ki = KS_TO_KEY(intkeys[0]);
222 spkb_kbstate[ki].state = 1;
224 else{
225 ki = KS_TO_KEY(intkeys[0]);
226 spkb_kbstate[ki].state = 0;
229 if ( buttons & ZX_DOWN ){
230 ki = KS_TO_KEY(intkeys[1]);
231 spkb_kbstate[ki].state = 1;
233 else{
234 ki = KS_TO_KEY(intkeys[1]);
235 spkb_kbstate[ki].state = 0;
238 if ( buttons & ZX_SELECT ){
239 ki = KS_TO_KEY(intkeys[4]);
240 spkb_kbstate[ki].state = 1;
242 else{
243 ki = KS_TO_KEY(intkeys[4]);
244 spkb_kbstate[ki].state = 0;
247 process_keys();
251 void press_key(int c){
252 spkb_state_changed = 1;
253 int ki;
254 if ( c == 'E' )
255 ki = KS_TO_KEY(SK_KP_Enter);
256 else if (c == 'S' )
257 ki = KS_TO_KEY(SK_KP_Space);
258 else
259 ki = KS_TO_KEY(c);
260 spkb_kbstate[ki].state = 1;
261 process_keys();