2006-09-15 11:11:16 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Anton Romanov
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-09-15 11:11:16 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "zxconfig.h"
|
|
|
|
#include "spkey_p.h"
|
2012-02-15 21:32:43 +00:00
|
|
|
#include "spkey.h"
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
spkeyboard kb_mkey;
|
|
|
|
bool exit_requested=false;
|
|
|
|
bool clear_kbd=0;
|
|
|
|
extern bool zxbox_menu(void);
|
|
|
|
|
|
|
|
/* DUMMIES ... to clean */
|
|
|
|
int privatemap;
|
|
|
|
int use_shm = 0;
|
|
|
|
int small_screen,pause_on_iconify;
|
|
|
|
int vga_pause_bg;
|
|
|
|
|
|
|
|
#include "keymaps.h"
|
|
|
|
#include "zxvid_com.h"
|
|
|
|
#include "spmain.h"
|
|
|
|
#include "spperif.h"
|
|
|
|
|
|
|
|
struct zxbox_settings settings;
|
|
|
|
|
|
|
|
/* doesn't fit into .ibss */
|
|
|
|
unsigned char image_array [ HEIGHT * WIDTH ];
|
|
|
|
|
|
|
|
static int previous_state;
|
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
#ifdef USE_GREY
|
2008-01-13 00:11:43 +00:00
|
|
|
GREY_INFO_STRUCT_IRAM
|
2006-09-15 11:11:16 +00:00
|
|
|
static unsigned char *gbuf;
|
2007-04-21 18:38:25 +00:00
|
|
|
static size_t gbuf_size = 0;
|
2006-09-15 11:11:16 +00:00
|
|
|
#endif
|
|
|
|
|
2006-09-25 09:44:10 +00:00
|
|
|
long video_frames IBSS_ATTR = 0 ;
|
|
|
|
long start_time IBSS_ATTR = 0;
|
2006-09-15 11:11:16 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2006-09-15 11:11:16 +00:00
|
|
|
{
|
2008-05-31 08:48:06 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-11-15 06:14:27 +00:00
|
|
|
rb->lcd_set_backdrop(NULL);
|
2008-05-31 08:48:06 +00:00
|
|
|
#endif
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ, "Welcome to ZXBox");
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
|
2006-09-25 09:44:10 +00:00
|
|
|
sp_init();
|
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
#ifdef USE_GREY
|
2006-09-15 11:11:16 +00:00
|
|
|
/* get the remainder of the plugin buffer */
|
|
|
|
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
|
2008-01-04 23:42:38 +00:00
|
|
|
#ifdef USE_BUFFERED_GREY
|
2009-01-16 10:34:40 +00:00
|
|
|
grey_init(gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH,
|
2008-04-04 22:13:53 +00:00
|
|
|
LCD_HEIGHT, NULL);
|
2006-09-15 11:11:16 +00:00
|
|
|
#else
|
2009-01-16 10:34:40 +00:00
|
|
|
grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL);
|
2008-01-04 23:42:38 +00:00
|
|
|
#endif /* USE_BUFFERED_GREY */
|
|
|
|
/* switch on greyscale overlay */
|
|
|
|
grey_show(true);
|
|
|
|
#endif /* USE_GREY */
|
2006-09-15 11:11:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
|
|
|
rb->cpu_boost(true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
start_time = *rb->current_tick;
|
2006-09-25 09:44:10 +00:00
|
|
|
|
|
|
|
#ifdef RB_PROFILE
|
|
|
|
rb->profile_thread();
|
|
|
|
#endif
|
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
start_spectemu(parameter);
|
|
|
|
|
2006-09-25 09:44:10 +00:00
|
|
|
#ifdef RB_PROFILE
|
|
|
|
rb->profstop();
|
|
|
|
#endif
|
|
|
|
|
2006-09-15 11:11:16 +00:00
|
|
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
|
|
|
rb->cpu_boost(false);
|
|
|
|
#endif
|
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
#ifdef USE_GREY
|
|
|
|
grey_show(false);
|
|
|
|
grey_release();
|
2006-09-15 11:11:16 +00:00
|
|
|
#endif
|
|
|
|
|
2007-02-17 23:51:07 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR
|
2006-09-15 11:11:16 +00:00
|
|
|
rb->pcm_play_stop();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_spect_key(void)
|
|
|
|
{
|
|
|
|
clear_keystates();
|
|
|
|
init_basekeys();
|
|
|
|
}
|
|
|
|
|
|
|
|
void spkb_process_events( int evenframe )
|
|
|
|
{
|
|
|
|
|
|
|
|
if(evenframe){
|
|
|
|
int ki;
|
2007-07-27 09:57:27 +00:00
|
|
|
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-09-15 11:11:16 +00:00
|
|
|
if (rb->button_hold())
|
|
|
|
{
|
|
|
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
|
|
|
rb->cpu_boost(false);
|
|
|
|
#endif
|
|
|
|
exit_requested=1;
|
2008-01-04 23:42:38 +00:00
|
|
|
#ifdef USE_GREY
|
|
|
|
grey_show(false);
|
2006-09-15 11:11:16 +00:00
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
int buttons = rb->button_status();
|
|
|
|
if ( buttons == previous_state )
|
|
|
|
return;
|
|
|
|
previous_state = buttons;
|
2007-07-27 09:57:27 +00:00
|
|
|
#if (CONFIG_KEYPAD != IPOD_4G_PAD) && (CONFIG_KEYPAD != IPOD_3G_PAD) && \
|
|
|
|
(CONFIG_KEYPAD != IPOD_1G2G_PAD)
|
2006-09-15 11:11:16 +00:00
|
|
|
if (buttons & ZX_MENU)
|
|
|
|
{
|
|
|
|
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
|
|
|
rb->cpu_boost(false);
|
|
|
|
#endif
|
|
|
|
exit_requested=1;
|
2008-01-04 23:42:38 +00:00
|
|
|
#ifdef USE_GREY
|
|
|
|
grey_show(false);
|
2006-09-15 11:11:16 +00:00
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
spkb_state_changed = 1;
|
|
|
|
if (settings.kempston){
|
|
|
|
if ( buttons & ZX_RIGHT ){
|
|
|
|
ki = KS_TO_KEY(SK_KP_Right);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else if (buttons & ZX_LEFT){
|
|
|
|
ki = KS_TO_KEY(SK_KP_Left);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(SK_KP_Right);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
ki = KS_TO_KEY(SK_KP_Left);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
if ( buttons & ZX_UP ){
|
|
|
|
ki = KS_TO_KEY(SK_KP_Up);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else if (buttons & ZX_DOWN){
|
|
|
|
ki = KS_TO_KEY(SK_KP_Down);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(SK_KP_Up);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
ki = KS_TO_KEY(SK_KP_Down);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
|
2015-12-27 17:14:41 +00:00
|
|
|
if ( buttons & ZX_SELECT
|
|
|
|
#ifdef ZX_SELECT2
|
|
|
|
|| buttons & ZX_SELECT2
|
|
|
|
#endif
|
|
|
|
){
|
2006-09-15 11:11:16 +00:00
|
|
|
ki = KS_TO_KEY(SK_KP_Insert);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(SK_KP_Insert);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if ( buttons & ZX_RIGHT ){
|
|
|
|
ki = KS_TO_KEY(intkeys[3]);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(intkeys[3]);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( buttons & ZX_LEFT ){
|
|
|
|
ki = KS_TO_KEY(intkeys[2]);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(intkeys[2]);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( buttons & ZX_UP ){
|
|
|
|
ki = KS_TO_KEY(intkeys[0]);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(intkeys[0]);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( buttons & ZX_DOWN ){
|
|
|
|
ki = KS_TO_KEY(intkeys[1]);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(intkeys[1]);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( buttons & ZX_SELECT ){
|
|
|
|
ki = KS_TO_KEY(intkeys[4]);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ki = KS_TO_KEY(intkeys[4]);
|
|
|
|
spkb_kbstate[ki].state = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
process_keys();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void press_key(int c){
|
|
|
|
spkb_state_changed = 1;
|
|
|
|
int ki;
|
|
|
|
if ( c == 'E' )
|
|
|
|
ki = KS_TO_KEY(SK_KP_Enter);
|
|
|
|
else if (c == 'S' )
|
|
|
|
ki = KS_TO_KEY(SK_KP_Space);
|
|
|
|
else
|
|
|
|
ki = KS_TO_KEY(c);
|
|
|
|
spkb_kbstate[ki].state = 1;
|
|
|
|
process_keys();
|
|
|
|
}
|
|
|
|
|