Patch #1417462 by Dan Everton - Improved SDL simulator
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8546 a1c6a512-1295-4272-9138-f99709370657
|
|
@ -71,7 +71,11 @@ typedef struct mydir MYDIR;
|
||||||
#if 1 /* maybe this needs disabling for MSVC... */
|
#if 1 /* maybe this needs disabling for MSVC... */
|
||||||
static unsigned int rockbox2sim(int opt)
|
static unsigned int rockbox2sim(int opt)
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
int newopt = O_BINARY;
|
||||||
|
#else
|
||||||
int newopt = 0;
|
int newopt = 0;
|
||||||
|
#endif
|
||||||
if(opt & 1)
|
if(opt & 1)
|
||||||
newopt |= O_WRONLY;
|
newopt |= O_WRONLY;
|
||||||
if(opt & 2)
|
if(opt & 2)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@
|
||||||
|
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(SDL)
|
#if defined(SDL)
|
||||||
|
#include "lcd-sdl.h"
|
||||||
|
#elif defined(WIN32)
|
||||||
#include "lcd-win32.h"
|
#include "lcd-win32.h"
|
||||||
#else
|
#else
|
||||||
#include "lcd-x11.h"
|
#include "lcd-x11.h"
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ SOURCES = $(SRC)
|
||||||
|
|
||||||
DIRS = .
|
DIRS = .
|
||||||
|
|
||||||
CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS)
|
CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS) -W -Wall
|
||||||
|
|
||||||
OUTFILE = $(BUILDDIR)/libsim.a
|
OUTFILE = $(BUILDDIR)/libsim.a
|
||||||
|
|
||||||
|
|
@ -48,13 +48,19 @@ all: $(OUTFILE)
|
||||||
|
|
||||||
include $(TOOLSDIR)/make.inc
|
include $(TOOLSDIR)/make.inc
|
||||||
|
|
||||||
clean:
|
$(OUTFILE): $(OBJS) $(BUILDDIR)/UI256.bmp
|
||||||
@echo "cleaning sim"
|
|
||||||
@$(RM) $(OBJS) *~ core $(OUTFILE) $(DEPFILE)
|
|
||||||
@$(MAKE) -C $(SIMCOMMON) clean
|
|
||||||
|
|
||||||
$(OUTFILE): $(OBJS)
|
|
||||||
@echo "AR $@"
|
@echo "AR $@"
|
||||||
@$(AR) ruv $@ $(OBJS) >/dev/null 2>&1
|
@$(AR) ruv $@ $(OBJS) >/dev/null 2>&1
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo "cleaning sim"
|
||||||
|
@$(RM) $(OBJS) *~ core $(OUTFILE) $(DEPFILE) \
|
||||||
|
$(BUILDDIR)/UI256.bmp $(DEPFILE)
|
||||||
|
@$(MAKE) -C $(SIMCOMMON) clean
|
||||||
|
|
||||||
|
################## Specific dependencies ##################
|
||||||
|
$(BUILDDIR)/UI256.bmp: UI-$(ARCHOS).bmp
|
||||||
|
@echo UI
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
-include $(DEPFILE)
|
-include $(DEPFILE)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
button-x11.c
|
button.c
|
||||||
kernel.c
|
kernel.c
|
||||||
lcd-x11.c
|
lcd-sdl.c
|
||||||
screenhack.c
|
|
||||||
thread.c
|
|
||||||
uisdl.c
|
|
||||||
sound.c
|
sound.c
|
||||||
|
thread-sdl.c
|
||||||
|
uisdl.c
|
||||||
|
|
|
||||||
BIN
uisimulator/sdl/UI-fmrecorder.bmp
Normal file
|
After Width: | Height: | Size: 231 KiB |
BIN
uisimulator/sdl/UI-gmini120.bmp
Normal file
|
After Width: | Height: | Size: 191 KiB |
BIN
uisimulator/sdl/UI-h100.bmp
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
uisimulator/sdl/UI-h120.bmp
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
uisimulator/sdl/UI-h300.bmp
Normal file
|
After Width: | Height: | Size: 164 KiB |
BIN
uisimulator/sdl/UI-ipodcolor.bmp
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
uisimulator/sdl/UI-ipodnano.bmp
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
uisimulator/sdl/UI-ondiofm.bmp
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
uisimulator/sdl/UI-ondiosp.bmp
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
uisimulator/sdl/UI-player.bmp
Normal file
|
After Width: | Height: | Size: 233 KiB |
BIN
uisimulator/sdl/UI-recorder.bmp
Normal file
|
After Width: | Height: | Size: 214 KiB |
BIN
uisimulator/sdl/UI-recorderv2.bmp
Normal file
|
After Width: | Height: | Size: 231 KiB |
|
|
@ -1,317 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
* \/ \/ \/ \/ \/
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002 by Björn Stenberg
|
|
||||||
*
|
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "config.h"
|
|
||||||
#include "button.h"
|
|
||||||
#include "kernel.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "backlight.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
extern int screenhack_handle_events(bool *release);
|
|
||||||
|
|
||||||
struct event_queue button_queue;
|
|
||||||
|
|
||||||
static int button_state = 0; /* keeps track of pressed keys */
|
|
||||||
static long lastbtn; /* Last valid button status */
|
|
||||||
|
|
||||||
/* how often we check to see if a button is pressed */
|
|
||||||
#define POLL_FREQUENCY HZ/25
|
|
||||||
|
|
||||||
/* how long until repeat kicks in */
|
|
||||||
#define REPEAT_START 8
|
|
||||||
|
|
||||||
/* the speed repeat starts at */
|
|
||||||
#define REPEAT_INTERVAL_START 4
|
|
||||||
|
|
||||||
/* speed repeat finishes at */
|
|
||||||
#define REPEAT_INTERVAL_FINISH 2
|
|
||||||
|
|
||||||
/* mostly copied from real button.c */
|
|
||||||
void button_read (void);
|
|
||||||
|
|
||||||
static void button_tick(void)
|
|
||||||
{
|
|
||||||
static int tick = 0;
|
|
||||||
static int count = 0;
|
|
||||||
static int repeat_speed = REPEAT_INTERVAL_START;
|
|
||||||
static int repeat_count = 0;
|
|
||||||
static bool repeat = false;
|
|
||||||
int diff;
|
|
||||||
int btn;
|
|
||||||
|
|
||||||
/* only poll every X ticks */
|
|
||||||
if ( ++tick >= POLL_FREQUENCY )
|
|
||||||
{
|
|
||||||
bool post = false;
|
|
||||||
button_read();
|
|
||||||
btn = button_state;
|
|
||||||
|
|
||||||
/* Find out if a key has been released */
|
|
||||||
diff = btn ^ lastbtn;
|
|
||||||
if(diff && (btn & diff) == 0)
|
|
||||||
{
|
|
||||||
queue_post(&button_queue, BUTTON_REL | diff, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( btn )
|
|
||||||
{
|
|
||||||
/* normal keypress */
|
|
||||||
if ( btn != lastbtn )
|
|
||||||
{
|
|
||||||
post = true;
|
|
||||||
repeat = false;
|
|
||||||
repeat_speed = REPEAT_INTERVAL_START;
|
|
||||||
|
|
||||||
}
|
|
||||||
else /* repeat? */
|
|
||||||
{
|
|
||||||
if ( repeat )
|
|
||||||
{
|
|
||||||
count--;
|
|
||||||
if (count == 0) {
|
|
||||||
post = true;
|
|
||||||
/* yes we have repeat */
|
|
||||||
repeat_speed--;
|
|
||||||
if (repeat_speed < REPEAT_INTERVAL_FINISH)
|
|
||||||
repeat_speed = REPEAT_INTERVAL_FINISH;
|
|
||||||
count = repeat_speed;
|
|
||||||
|
|
||||||
repeat_count++;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (count++ > REPEAT_START)
|
|
||||||
{
|
|
||||||
post = true;
|
|
||||||
repeat = true;
|
|
||||||
repeat_count = 0;
|
|
||||||
/* initial repeat */
|
|
||||||
count = REPEAT_INTERVAL_START;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( post )
|
|
||||||
{
|
|
||||||
if (repeat)
|
|
||||||
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
|
|
||||||
else
|
|
||||||
queue_post(&button_queue, btn, NULL);
|
|
||||||
#ifdef HAVE_REMOTE_LCD
|
|
||||||
if(btn & BUTTON_REMOTE)
|
|
||||||
remote_backlight_on();
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
backlight_on();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
repeat = false;
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
|
|
||||||
tick = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read SDL keys and translate to rockbox buttons
|
|
||||||
*/
|
|
||||||
|
|
||||||
void button_read (void)
|
|
||||||
{
|
|
||||||
int k;
|
|
||||||
bool release = false; /* is this a release event */
|
|
||||||
int ev = screenhack_handle_events(&release);
|
|
||||||
|
|
||||||
switch (ev)
|
|
||||||
{
|
|
||||||
case SDLK_KP4:
|
|
||||||
case SDLK_LEFT:
|
|
||||||
case SDLK_4:
|
|
||||||
k = BUTTON_LEFT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_KP6:
|
|
||||||
case SDLK_RIGHT:
|
|
||||||
case SDLK_6:
|
|
||||||
k = BUTTON_RIGHT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_KP8:
|
|
||||||
case SDLK_UP:
|
|
||||||
case SDLK_8:
|
|
||||||
#ifdef BUTTON_UP
|
|
||||||
k = BUTTON_UP;
|
|
||||||
#elif defined BUTTON_SCROLL_BACK
|
|
||||||
k = BUTTON_SCROLL_BACK;
|
|
||||||
#elif defined BUTTON_PLAY
|
|
||||||
k = BUTTON_PLAY;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_KP2:
|
|
||||||
case SDLK_DOWN:
|
|
||||||
case SDLK_2:
|
|
||||||
#ifdef BUTTON_DOWN
|
|
||||||
k = BUTTON_DOWN;
|
|
||||||
#elif defined BUTTON_SCROLL_FWD
|
|
||||||
k = BUTTON_SCROLL_FWD;
|
|
||||||
#elif defined BUTTON_STOP
|
|
||||||
k = BUTTON_STOP;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef BUTTON_ON
|
|
||||||
case SDLK_KP_PLUS:
|
|
||||||
case SDLK_q:
|
|
||||||
k = BUTTON_ON;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_OFF
|
|
||||||
case SDLK_KP_ENTER:
|
|
||||||
case SDLK_a:
|
|
||||||
k = BUTTON_OFF;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_POWER
|
|
||||||
case SDLK_KP_MINUS:
|
|
||||||
case SDLK_p:
|
|
||||||
k = BUTTON_POWER;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_F1
|
|
||||||
case SDLK_KP_DIVIDE:
|
|
||||||
case SDLK_F1:
|
|
||||||
k = BUTTON_F1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_KP_MULTIPLY:
|
|
||||||
case SDLK_F2:
|
|
||||||
k = BUTTON_F2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_KP_MINUS:
|
|
||||||
case SDLK_F3:
|
|
||||||
k = BUTTON_F3;
|
|
||||||
break;
|
|
||||||
#elif defined(BUTTON_REC)
|
|
||||||
case SDLK_KP_DIVIDE:
|
|
||||||
case SDLK_F1:
|
|
||||||
k = BUTTON_REC;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case SDLK_KP5:
|
|
||||||
case SDLK_5:
|
|
||||||
case SDLK_SPACE:
|
|
||||||
#ifdef BUTTON_PLAY
|
|
||||||
k = BUTTON_PLAY;
|
|
||||||
#elif defined(BUTTON_SELECT)
|
|
||||||
k = BUTTON_SELECT;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
case SDLK_7:
|
|
||||||
if(!release)
|
|
||||||
screen_dump();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case SDLK_KP_PERIOD:
|
|
||||||
case SDLK_INSERT:
|
|
||||||
#ifdef BUTTON_MENU
|
|
||||||
k = BUTTON_MENU;
|
|
||||||
#elif defined(BUTTON_MODE)
|
|
||||||
k = BUTTON_MODE;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
k = 0;
|
|
||||||
if(ev)
|
|
||||||
DEBUGF("received ev %d\n", ev);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (release)
|
|
||||||
button_state &= ~k;
|
|
||||||
else
|
|
||||||
button_state |= k;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Again copied from real button.c... */
|
|
||||||
|
|
||||||
long button_get(bool block)
|
|
||||||
{
|
|
||||||
struct event ev;
|
|
||||||
|
|
||||||
if ( block || !queue_empty(&button_queue) )
|
|
||||||
{
|
|
||||||
queue_wait(&button_queue, &ev);
|
|
||||||
return ev.id;
|
|
||||||
}
|
|
||||||
return BUTTON_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
long button_get_w_tmo(int ticks)
|
|
||||||
{
|
|
||||||
struct event ev;
|
|
||||||
queue_wait_w_tmo(&button_queue, &ev, ticks);
|
|
||||||
return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void button_init(void)
|
|
||||||
{
|
|
||||||
tick_add_task(button_tick);
|
|
||||||
}
|
|
||||||
|
|
||||||
int button_status(void)
|
|
||||||
{
|
|
||||||
return lastbtn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void button_clear_queue(void)
|
|
||||||
{
|
|
||||||
queue_clear(&button_queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAS_BUTTON_HOLD
|
|
||||||
bool button_hold(void) {
|
|
||||||
/* temp fix for hold button on irivers */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAS_REMOTE_BUTTON_HOLD
|
|
||||||
bool remote_button_hold(void) {
|
|
||||||
/* temp fix for hold button on irivers */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
275
uisimulator/sdl/button.c
Normal file
|
|
@ -0,0 +1,275 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002 by Felix Arends
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "uisdl.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "button.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
#include "backlight.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
/* how long until repeat kicks in */
|
||||||
|
#define REPEAT_START 6
|
||||||
|
|
||||||
|
/* the speed repeat starts at */
|
||||||
|
#define REPEAT_INTERVAL_START 4
|
||||||
|
|
||||||
|
/* speed repeat finishes at */
|
||||||
|
#define REPEAT_INTERVAL_FINISH 2
|
||||||
|
|
||||||
|
struct event_queue button_queue;
|
||||||
|
|
||||||
|
static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
|
||||||
|
|
||||||
|
void button_event(int key, bool pressed)
|
||||||
|
{
|
||||||
|
bool post = false;
|
||||||
|
int new_btn = 0;
|
||||||
|
int diff = 0;
|
||||||
|
static int count = 0;
|
||||||
|
static int lastbtn;
|
||||||
|
static int repeat_speed = REPEAT_INTERVAL_START;
|
||||||
|
static int repeat_count = 0;
|
||||||
|
static bool repeat = false;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case SDLK_KP4:
|
||||||
|
case SDLK_LEFT:
|
||||||
|
new_btn = BUTTON_LEFT;
|
||||||
|
break;
|
||||||
|
case SDLK_KP6:
|
||||||
|
case SDLK_RIGHT:
|
||||||
|
new_btn = BUTTON_RIGHT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_KP8:
|
||||||
|
case SDLK_UP:
|
||||||
|
#ifdef BUTTON_UP
|
||||||
|
new_btn = BUTTON_UP;
|
||||||
|
#elif defined BUTTON_SCROLL_FWD
|
||||||
|
new_btn = BUTTON_SCROLL_FWD;
|
||||||
|
#elif defined BUTTON_PLAY
|
||||||
|
new_btn = BUTTON_PLAY;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_KP2:
|
||||||
|
case SDLK_DOWN:
|
||||||
|
#ifdef BUTTON_DOWN
|
||||||
|
new_btn = BUTTON_DOWN;
|
||||||
|
#elif defined BUTTON_SCROLL_BACK
|
||||||
|
new_btn = BUTTON_SCROLL_BACK;
|
||||||
|
#elif defined BUTTON_STOP
|
||||||
|
new_btn = BUTTON_STOP;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_KP_PLUS:
|
||||||
|
#ifdef BUTTON_ON
|
||||||
|
new_btn = BUTTON_ON;
|
||||||
|
#elif defined(BUTTON_SELECT) && defined(BUTTON_PLAY)
|
||||||
|
new_btn = BUTTON_PLAY;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef BUTTON_OFF
|
||||||
|
case SDLK_RETURN:
|
||||||
|
new_btn = BUTTON_OFF;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BUTTON_F1
|
||||||
|
case SDLK_KP_DIVIDE:
|
||||||
|
case SDLK_F1:
|
||||||
|
new_btn = BUTTON_F1;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_MULTIPLY:
|
||||||
|
case SDLK_F2:
|
||||||
|
new_btn = BUTTON_F2;
|
||||||
|
break;
|
||||||
|
case SDLK_KP_MINUS:
|
||||||
|
case SDLK_F3:
|
||||||
|
new_btn = BUTTON_F3;
|
||||||
|
break;
|
||||||
|
#elif defined(BUTTON_REC)
|
||||||
|
case SDLK_KP_DIVIDE:
|
||||||
|
case SDLK_F1:
|
||||||
|
new_btn = BUTTON_REC;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case SDLK_KP5:
|
||||||
|
case SDLK_SPACE:
|
||||||
|
#if defined(BUTTON_PLAY) && !defined(BUTTON_SELECT)
|
||||||
|
new_btn = BUTTON_PLAY;
|
||||||
|
#elif defined(BUTTON_SELECT)
|
||||||
|
new_btn = BUTTON_SELECT;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
case SDLK_KP0:
|
||||||
|
case SDLK_F5:
|
||||||
|
if(pressed)
|
||||||
|
{
|
||||||
|
screen_dump();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case SDLK_PERIOD:
|
||||||
|
case SDLK_INSERT:
|
||||||
|
#ifdef BUTTON_MENU
|
||||||
|
new_btn = BUTTON_MENU;
|
||||||
|
#elif defined(BUTTON_MODE)
|
||||||
|
new_btn = BUTTON_MODE;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pressed)
|
||||||
|
btn |= new_btn;
|
||||||
|
else
|
||||||
|
btn &= ~new_btn;
|
||||||
|
|
||||||
|
/* Lots of stuff copied from real button.c. Not good, I think... */
|
||||||
|
|
||||||
|
/* Find out if a key has been released */
|
||||||
|
diff = btn ^ lastbtn;
|
||||||
|
|
||||||
|
if(diff && (btn & diff) == 0)
|
||||||
|
{
|
||||||
|
queue_post(&button_queue, BUTTON_REL | diff, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( btn )
|
||||||
|
{
|
||||||
|
/* normal keypress */
|
||||||
|
if ( btn != lastbtn )
|
||||||
|
{
|
||||||
|
post = true;
|
||||||
|
repeat = false;
|
||||||
|
repeat_speed = REPEAT_INTERVAL_START;
|
||||||
|
|
||||||
|
}
|
||||||
|
else /* repeat? */
|
||||||
|
{
|
||||||
|
if ( repeat )
|
||||||
|
{
|
||||||
|
count--;
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
post = true;
|
||||||
|
/* yes we have repeat */
|
||||||
|
repeat_speed--;
|
||||||
|
if (repeat_speed < REPEAT_INTERVAL_FINISH)
|
||||||
|
repeat_speed = REPEAT_INTERVAL_FINISH;
|
||||||
|
count = repeat_speed;
|
||||||
|
|
||||||
|
repeat_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (count++ > REPEAT_START)
|
||||||
|
{
|
||||||
|
post = true;
|
||||||
|
repeat = true;
|
||||||
|
repeat_count = 0;
|
||||||
|
/* initial repeat */
|
||||||
|
count = REPEAT_INTERVAL_START;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( post )
|
||||||
|
{
|
||||||
|
if(repeat)
|
||||||
|
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
|
||||||
|
else
|
||||||
|
queue_post(&button_queue, btn, NULL);
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
if(btn & BUTTON_REMOTE)
|
||||||
|
remote_backlight_on();
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
backlight_on();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
repeat = false;
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Again copied from real button.c... */
|
||||||
|
|
||||||
|
long button_get(bool block)
|
||||||
|
{
|
||||||
|
struct event ev;
|
||||||
|
|
||||||
|
if ( block || !queue_empty(&button_queue) ) {
|
||||||
|
queue_wait(&button_queue, &ev);
|
||||||
|
return ev.id;
|
||||||
|
}
|
||||||
|
return BUTTON_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
long button_get_w_tmo(int ticks)
|
||||||
|
{
|
||||||
|
struct event ev;
|
||||||
|
queue_wait_w_tmo(&button_queue, &ev, ticks);
|
||||||
|
return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void button_init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int button_status(void)
|
||||||
|
{
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void button_clear_queue(void)
|
||||||
|
{
|
||||||
|
queue_clear(&button_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_BUTTON_HOLD
|
||||||
|
bool button_hold(void) {
|
||||||
|
/* temp fix for hold button on irivers */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_REMOTE_BUTTON_HOLD
|
||||||
|
bool remote_button_hold(void) {
|
||||||
|
/* temp fix for hold button on irivers */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 by Jens Arnold
|
* Copyright (C) 2002 by Felix Arends
|
||||||
*
|
*
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
|
@ -17,11 +17,18 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stdlib.h>
|
||||||
|
#include "uisdl.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "thread-sdl.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
/* (Daniel 2002-10-31) Mingw32 requires this errno variable to be present.
|
||||||
|
I'm not quite sure why and I don't know if this breaks the MSVC compile.
|
||||||
|
If it does, we should put this within #ifdef __MINGW32__ */
|
||||||
|
int errno;
|
||||||
|
|
||||||
static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
|
static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
|
||||||
|
|
||||||
int set_irq_level (int level)
|
int set_irq_level (int level)
|
||||||
|
|
@ -148,6 +155,7 @@ int tick_remove_task(void (*f)(void))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Implement mutexes for win32 */
|
||||||
void mutex_init(struct mutex *m)
|
void mutex_init(struct mutex *m)
|
||||||
{
|
{
|
||||||
(void)m;
|
(void)m;
|
||||||
|
|
@ -162,4 +170,3 @@ void mutex_unlock(struct mutex *m)
|
||||||
{
|
{
|
||||||
(void)m;
|
(void)m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
291
uisimulator/sdl/lcd-sdl.c
Normal file
|
|
@ -0,0 +1,291 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Dan Everton
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "uisdl.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "lcd-playersim.h"
|
||||||
|
|
||||||
|
SDL_Surface* lcd_surface;
|
||||||
|
|
||||||
|
#if LCD_DEPTH == 16
|
||||||
|
#else
|
||||||
|
SDL_Color lcd_palette[(1<<LCD_DEPTH)];
|
||||||
|
SDL_Color lcd_color_zero = {UI_LCD_BGCOLORLIGHT, 0};
|
||||||
|
SDL_Color lcd_color_max = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
SDL_Surface *remote_surface;
|
||||||
|
SDL_Color remote_palette[(1<<LCD_REMOTE_DEPTH)];
|
||||||
|
SDL_Color remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0};
|
||||||
|
SDL_Color remote_color_max = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void lcd_update (void)
|
||||||
|
{
|
||||||
|
/* update a full screen rect */
|
||||||
|
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_update_rect(int x_start, int y_start, int width, int height)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
int xmax, ymax;
|
||||||
|
|
||||||
|
ymax = y_start + height;
|
||||||
|
xmax = x_start + width;
|
||||||
|
|
||||||
|
if(xmax > LCD_WIDTH)
|
||||||
|
xmax = LCD_WIDTH;
|
||||||
|
if(ymax >= LCD_HEIGHT)
|
||||||
|
ymax = LCD_HEIGHT;
|
||||||
|
|
||||||
|
SDL_LockSurface(lcd_surface);
|
||||||
|
|
||||||
|
int bpp = lcd_surface->format->BytesPerPixel;
|
||||||
|
|
||||||
|
for (x = x_start; x < xmax; x++)
|
||||||
|
{
|
||||||
|
for (y = y_start; y < ymax; y++)
|
||||||
|
{
|
||||||
|
Uint8 *p = (Uint8 *)lcd_surface->pixels + y * lcd_surface->pitch + x * bpp;
|
||||||
|
|
||||||
|
#if LCD_DEPTH == 1
|
||||||
|
*(Uint32 *)p = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
|
||||||
|
#elif LCD_DEPTH == 2
|
||||||
|
*(Uint32 *)p = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
|
||||||
|
#elif LCD_DEPTH == 16
|
||||||
|
#if LCD_PIXELFORMAT == RGB565SWAPPED
|
||||||
|
unsigned bits = lcd_framebuffer[y][x];
|
||||||
|
*(Uint32 *)p = (bits >> 8) | (bits << 8);
|
||||||
|
#else
|
||||||
|
*(Uint32 *)p = lcd_framebuffer[y][x];
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockSurface(lcd_surface);
|
||||||
|
|
||||||
|
SDL_Rect src = {x_start, y_start, xmax, ymax};
|
||||||
|
SDL_Rect dest = {UI_LCD_POSX + x_start, UI_LCD_POSY + y_start, xmax, ymax};
|
||||||
|
|
||||||
|
|
||||||
|
SDL_BlitSurface(lcd_surface, &src, gui_surface, &dest);
|
||||||
|
SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
|
||||||
|
SDL_Flip(gui_surface);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
|
||||||
|
extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
|
||||||
|
|
||||||
|
void lcd_remote_update (void)
|
||||||
|
{
|
||||||
|
lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_remote_update_rect(int x_start, int y_start,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
int xmax, ymax;
|
||||||
|
|
||||||
|
ymax = y_start + height;
|
||||||
|
xmax = x_start + width;
|
||||||
|
|
||||||
|
if(xmax > LCD_REMOTE_WIDTH)
|
||||||
|
xmax = LCD_REMOTE_WIDTH;
|
||||||
|
if(ymax >= LCD_REMOTE_HEIGHT)
|
||||||
|
ymax = LCD_REMOTE_HEIGHT;
|
||||||
|
|
||||||
|
SDL_LockSurface(remote_surface);
|
||||||
|
|
||||||
|
int bpp = remote_surface->format->BytesPerPixel;
|
||||||
|
|
||||||
|
for (x = x_start; x < xmax; x++)
|
||||||
|
for (y = y_start; y < ymax; y++)
|
||||||
|
{
|
||||||
|
Uint8 *p = (Uint8 *)remote_surface->pixels + y * remote_surface->pitch + x * bpp;
|
||||||
|
|
||||||
|
*(Uint32 *)p = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockSurface(remote_surface);
|
||||||
|
|
||||||
|
SDL_Rect src = {x_start, y_start, xmax, ymax};
|
||||||
|
SDL_Rect dest = {UI_REMOTE_POSX + x_start, UI_REMOTE_POSY + y_start, xmax, ymax};
|
||||||
|
|
||||||
|
SDL_BlitSurface(remote_surface, &src, gui_surface, &dest);
|
||||||
|
SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
|
||||||
|
SDL_Flip(gui_surface);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_REMOTE_LCD */
|
||||||
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
|
/* Defined in lcd-playersim.c */
|
||||||
|
extern void lcd_print_char(int x, int y);
|
||||||
|
extern bool lcd_display_redraw;
|
||||||
|
extern unsigned char hardware_buffer_lcd[11][2];
|
||||||
|
static unsigned char lcd_buffer_copy[11][2];
|
||||||
|
|
||||||
|
void lcd_update(void)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
bool changed = false;
|
||||||
|
SDL_Rect dest = {UI_LCD_POSX, UI_LCD_POSY, UI_LCD_WIDTH, UI_LCD_HEIGHT};
|
||||||
|
|
||||||
|
for (y = 0; y < 2; y++)
|
||||||
|
{
|
||||||
|
for (x = 0; x < 11; x++)
|
||||||
|
{
|
||||||
|
if (lcd_display_redraw ||
|
||||||
|
lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
|
||||||
|
{
|
||||||
|
lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
|
||||||
|
lcd_print_char(x, y);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
SDL_BlitSurface(lcd_surface, NULL, gui_surface, &dest);
|
||||||
|
SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
|
||||||
|
SDL_Flip(gui_surface);
|
||||||
|
}
|
||||||
|
lcd_display_redraw = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawdots(int color, struct coordinate *points, int count)
|
||||||
|
{
|
||||||
|
int bpp = lcd_surface->format->BytesPerPixel;
|
||||||
|
|
||||||
|
SDL_LockSurface(lcd_surface);
|
||||||
|
|
||||||
|
while (count--)
|
||||||
|
{
|
||||||
|
Uint8 *p = (Uint8 *)lcd_surface->pixels + (points[count].y) * lcd_surface->pitch + (points[count].x) * bpp;
|
||||||
|
|
||||||
|
*p = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockSurface(lcd_surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawrectangles(int color, struct rectangle *points, int count)
|
||||||
|
{
|
||||||
|
int bpp = lcd_surface->format->BytesPerPixel;
|
||||||
|
|
||||||
|
SDL_LockSurface(lcd_surface);
|
||||||
|
|
||||||
|
while (count--)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int ix;
|
||||||
|
int iy;
|
||||||
|
|
||||||
|
for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
|
||||||
|
{
|
||||||
|
for (y = points[count].y, iy = 0; iy < points[count].height; y++, iy++)
|
||||||
|
{
|
||||||
|
Uint8 *p = (Uint8 *)lcd_surface->pixels + y * lcd_surface->pitch + x * bpp;
|
||||||
|
|
||||||
|
*p = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockSurface(lcd_surface);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_LCD_CHARCELLS */
|
||||||
|
|
||||||
|
#if LCD_DEPTH <= 8
|
||||||
|
/* set a range of bitmap indices to a gradient from startcolour to endcolour */
|
||||||
|
void lcdcolors(int index, int count, SDL_Color *start, SDL_Color *end)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
count--;
|
||||||
|
for (i = 0; i <= count; i++)
|
||||||
|
{
|
||||||
|
lcd_palette[i+index].r = start->r
|
||||||
|
+ (end->r - start->r) * i / count;
|
||||||
|
lcd_palette[i+index].g = start->g
|
||||||
|
+ (end->g - start->g) * i / count;
|
||||||
|
lcd_palette[i+index].b = start->b
|
||||||
|
+ (end->b - start->b) * i / count;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetPalette(lcd_surface, SDL_LOGPAL|SDL_PHYSPAL, lcd_palette, index, count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
/* set a range of bitmap indices to a gradient from startcolour to endcolour */
|
||||||
|
void lcdremotecolors(int index, int count, SDL_Color *start, SDL_Color *end)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
count--;
|
||||||
|
for (i = 0; i <= count; i++)
|
||||||
|
{
|
||||||
|
remote_palette[i+index].r = start->r
|
||||||
|
+ (end->r - start->r) * i / count;
|
||||||
|
remote_palette[i+index].g = start->g
|
||||||
|
+ (end->g - start->g) * i / count;
|
||||||
|
remote_palette[i+index].b = start->b
|
||||||
|
+ (end->b - start->b) * i / count;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetPalette(remote_surface, SDL_LOGPAL|SDL_PHYSPAL, remote_palette, index, count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* initialise simulator lcd driver */
|
||||||
|
void simlcdinit(void)
|
||||||
|
{
|
||||||
|
#if LCD_DEPTH == 16
|
||||||
|
lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH, LCD_HEIGHT, 16,
|
||||||
|
0, 0, 0, 0);
|
||||||
|
#else
|
||||||
|
lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH, LCD_HEIGHT, 8,
|
||||||
|
0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LCD_DEPTH <= 8
|
||||||
|
lcdcolors(0, (1<<LCD_DEPTH), &lcd_color_zero, &lcd_color_max);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, 8,
|
||||||
|
0, 0, 0, 0);
|
||||||
|
|
||||||
|
lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH), &remote_color_zero, &remote_color_max);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
39
uisimulator/sdl/lcd-sdl.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Dan Everton
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __LCDSDL_H__
|
||||||
|
#define __LCDSDL_H__
|
||||||
|
|
||||||
|
#include "uisdl.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
|
extern SDL_Surface* lcd_surface;
|
||||||
|
#if LCD_DEPTH <= 8
|
||||||
|
extern SDL_Color lcd_palette[(1<<LCD_DEPTH)];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
extern SDL_Surface* remote_surface;
|
||||||
|
extern SDL_Color remote_palette[(1<<LCD_REMOTE_DEPTH)];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void simlcdinit(void);
|
||||||
|
|
||||||
|
#endif // #ifndef __LCDSDL_H__
|
||||||
|
|
||||||
|
|
@ -1,212 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
* \/ \/ \/ \/ \/
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
|
|
||||||
*
|
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "screenhack.h"
|
|
||||||
#include "system.h"
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Specific implementations for X11, using the generic LCD API and data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "lcd-x11.h"
|
|
||||||
#include "lcd-playersim.h"
|
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
extern SDL_Surface *surface;
|
|
||||||
|
|
||||||
extern void screen_resized(int width, int height);
|
|
||||||
extern bool lcd_display_redraw;
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
#if LCD_DEPTH==16
|
|
||||||
fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH*2];
|
|
||||||
#else
|
|
||||||
fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void lcd_update (void)
|
|
||||||
{
|
|
||||||
/* update a full screen rect */
|
|
||||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcd_update_rect(int x_start, int y_start,
|
|
||||||
int width, int height)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int p=0;
|
|
||||||
int xmax;
|
|
||||||
int ymax;
|
|
||||||
int colors[LCD_WIDTH * LCD_HEIGHT];
|
|
||||||
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
|
||||||
counter++, x_start, y_start, width, height);
|
|
||||||
#endif
|
|
||||||
ymax = y_start + height;
|
|
||||||
xmax = x_start + width;
|
|
||||||
|
|
||||||
if(xmax > LCD_WIDTH)
|
|
||||||
xmax = LCD_WIDTH;
|
|
||||||
if(ymax >= LCD_HEIGHT)
|
|
||||||
ymax = LCD_HEIGHT;
|
|
||||||
|
|
||||||
for (x = x_start; x < xmax; x++)
|
|
||||||
for (y = y_start; y < ymax; y++)
|
|
||||||
{
|
|
||||||
#if LCD_DEPTH == 1
|
|
||||||
Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255);
|
|
||||||
Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0);
|
|
||||||
points[p].x = x + MARGIN_X;
|
|
||||||
points[p].y = y + MARGIN_Y;
|
|
||||||
colors[p] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1) ? sdl_black : sdl_white;
|
|
||||||
#elif LCD_DEPTH == 2
|
|
||||||
unsigned gray = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3) * 85;
|
|
||||||
points[p].x = x + MARGIN_X;
|
|
||||||
points[p].y = y + MARGIN_Y;
|
|
||||||
colors[p] = SDL_MapRGB(surface->format, 255-gray, 255-gray, 255-gray);
|
|
||||||
#elif LCD_DEPTH == 16
|
|
||||||
#if LCD_PIXELFORMAT == RGB565SWAPPED
|
|
||||||
unsigned short pixel = swap16(lcd_framebuffer[y][x]);
|
|
||||||
unsigned r = ((pixel >> 11) & 0x1f) << 3;
|
|
||||||
unsigned g = ((pixel >> 5) & 0x3f) << 2;
|
|
||||||
unsigned b = (pixel & 0x1f) << 3;
|
|
||||||
points[p].x = x + MARGIN_X;
|
|
||||||
points[p].y = y + MARGIN_Y;
|
|
||||||
colors[p] = SDL_MapRGB(surface->format, r, g, b);
|
|
||||||
#else
|
|
||||||
unsigned r = ((lcd_framebuffer[y][x] >> 11) & 0x1f) << 3;
|
|
||||||
unsigned g = ((lcd_framebuffer[y][x] >> 5) & 0x3f) << 2;
|
|
||||||
unsigned b = ((lcd_framebuffer[y][x]) & 0x1f) << 3;
|
|
||||||
points[p].x = x + MARGIN_X;
|
|
||||||
points[p].y = y + MARGIN_Y;
|
|
||||||
colors[p] = SDL_MapRGB(surface->format, r, g, b);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
dots(colors, &points[0], p);
|
|
||||||
/* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
|
|
||||||
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
|
||||||
lcd_display_redraw=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LCD_REMOTE_HEIGHT
|
|
||||||
extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
|
|
||||||
unsigned char lcd_remote_framebuffer_copy[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
|
|
||||||
|
|
||||||
#define REMOTE_START_Y (LCD_HEIGHT + 2*MARGIN_Y)
|
|
||||||
|
|
||||||
void lcd_remote_update (void)
|
|
||||||
{
|
|
||||||
lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcd_remote_update_rect(int x_start, int y_start,
|
|
||||||
int width, int height)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int p=0;
|
|
||||||
int xmax;
|
|
||||||
int ymax;
|
|
||||||
struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
|
|
||||||
int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
|
|
||||||
Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255);
|
|
||||||
Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
|
||||||
counter++, x_start, y_start, width, height);
|
|
||||||
#endif
|
|
||||||
ymax = y_start + height;
|
|
||||||
xmax = x_start + width;
|
|
||||||
|
|
||||||
if(xmax > LCD_REMOTE_WIDTH)
|
|
||||||
xmax = LCD_REMOTE_WIDTH;
|
|
||||||
if(ymax >= LCD_REMOTE_HEIGHT)
|
|
||||||
ymax = LCD_REMOTE_HEIGHT;
|
|
||||||
|
|
||||||
for (x = x_start; x < xmax; x++)
|
|
||||||
for (y = y_start; y < ymax; y++) {
|
|
||||||
colors[p] = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1) ? sdl_black : sdl_white;
|
|
||||||
points[p].x = x + MARGIN_X;
|
|
||||||
points[p].y = y + MARGIN_Y + REMOTE_START_Y;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
dots(colors, &points[0], p);
|
|
||||||
/* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
|
|
||||||
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
|
||||||
lcd_display_redraw=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
|
||||||
|
|
||||||
/* Defined in lcd-playersim.c */
|
|
||||||
extern void lcd_print_char(int x, int y);
|
|
||||||
extern unsigned char lcd_buffer[2][11];
|
|
||||||
|
|
||||||
extern unsigned char hardware_buffer_lcd[11][2];
|
|
||||||
static unsigned char lcd_buffer_copy[11][2];
|
|
||||||
|
|
||||||
void lcd_update (void)
|
|
||||||
{
|
|
||||||
bool changed=false;
|
|
||||||
int x, y;
|
|
||||||
for (y=0; y<2; y++) {
|
|
||||||
for (x=0; x<11; x++) {
|
|
||||||
if (lcd_display_redraw ||
|
|
||||||
lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y]) {
|
|
||||||
lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
|
|
||||||
lcd_print_char(x, y);
|
|
||||||
changed=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (changed)
|
|
||||||
{
|
|
||||||
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
lcd_display_redraw=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,232 +0,0 @@
|
||||||
/* xscreensaver, Copyright (c) 1992, 1995, 1997, 1998
|
|
||||||
* Jamie Zawinski <jwz@jwz.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
||||||
* documentation for any purpose is hereby granted without fee, provided that
|
|
||||||
* the above copyright notice appear in all copies and that both that
|
|
||||||
* copyright notice and this permission notice appear in supporting
|
|
||||||
* documentation. No representations are made about the suitability of this
|
|
||||||
* software for any purpose. It is provided "as is" without express or
|
|
||||||
* implied warranty.
|
|
||||||
*
|
|
||||||
* And remember: X Windows is to graphics hacking as roman numerals are to
|
|
||||||
* the square root of pi.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This file contains simple code to open a window or draw on the root.
|
|
||||||
The idea being that, when writing a graphics hack, you can just link
|
|
||||||
with this .o to get all of the uninteresting junk out of the way.
|
|
||||||
|
|
||||||
- create a procedure `screenhack(dpy, window)'
|
|
||||||
|
|
||||||
- create a variable `char *progclass' which names this program's
|
|
||||||
resource class.
|
|
||||||
|
|
||||||
- create a variable `char defaults []' for the default resources, and
|
|
||||||
null-terminate it.
|
|
||||||
|
|
||||||
- create a variable `XrmOptionDescRec options[]' for the command-line,
|
|
||||||
and null-terminate it.
|
|
||||||
|
|
||||||
And that's it...
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <SDL.h>
|
|
||||||
#include "lcd-x11.h"
|
|
||||||
#include "screenhack.h"
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifndef isupper
|
|
||||||
# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
|
||||||
#endif
|
|
||||||
#ifndef _tolower
|
|
||||||
# define _tolower(c) ((c) - 'A' + 'a')
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define KEYBOARD_GENERIC \
|
|
||||||
"Keyboard Rockbox\n" \
|
|
||||||
"-------- ------------\n" \
|
|
||||||
"4, Left LEFT\n" \
|
|
||||||
"6, Right RIGHT\n"
|
|
||||||
|
|
||||||
#if CONFIG_KEYPAD == PLAYER_PAD
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"8, Up PLAY\n" \
|
|
||||||
"2, Down STOP\n" \
|
|
||||||
"+, Q ON\n" \
|
|
||||||
"., INS MENU\n"
|
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == RECORDER_PAD
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"8, Up UP\n" \
|
|
||||||
"2, Down DOWN\n" \
|
|
||||||
"5, Space PLAY\n" \
|
|
||||||
"+, Q ON\n" \
|
|
||||||
"Enter, A OFF\n" \
|
|
||||||
"/, (F1) F1\n" \
|
|
||||||
"*, (F2) F2\n" \
|
|
||||||
"-, (F3) F3\n"
|
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"8, Up UP\n" \
|
|
||||||
"2, Down DOWN\n" \
|
|
||||||
"., INS MENU\n" \
|
|
||||||
"Enter, A OFF\n"
|
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == IRIVER_H100_PAD
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"8, Up UP\n" \
|
|
||||||
"2, Down DOWN\n" \
|
|
||||||
"5, Space SELECT\n" \
|
|
||||||
"+, Q ON\n" \
|
|
||||||
"Enter, A OFF\n" \
|
|
||||||
"., INS MODE\n" \
|
|
||||||
"/, (F1) RECORD\n"
|
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == IRIVER_H300_PAD
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"8, Up UP\n" \
|
|
||||||
"2, Down DOWN\n" \
|
|
||||||
"4, Left LEFT\n" \
|
|
||||||
"6, Right RIGHT\n" \
|
|
||||||
"5, Space SELECT\n" \
|
|
||||||
"+, Q ON\n" \
|
|
||||||
"Enter, A OFF\n" \
|
|
||||||
"., INS MODE\n" \
|
|
||||||
"/, (F1) RECORD\n"
|
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == GMINI100_PAD
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"8, Up UP\n" \
|
|
||||||
"2, Down DOWN\n" \
|
|
||||||
"5, Space PLAY\n" \
|
|
||||||
"+, Q ON\n" \
|
|
||||||
"Enter, A OFF\n" \
|
|
||||||
"., INS MENU\n"
|
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"[not written yet]"
|
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
|
|
||||||
#define KEYBOARD_SPECIFIC \
|
|
||||||
"[not written yet]"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
SDL_Surface *surface;
|
|
||||||
|
|
||||||
char having_new_lcd = true;
|
|
||||||
|
|
||||||
extern int display_zoom;
|
|
||||||
|
|
||||||
/* Dead-trivial event handling.
|
|
||||||
*/
|
|
||||||
int screenhack_handle_event(SDL_Event *event, bool *release)
|
|
||||||
{
|
|
||||||
int key = 0;
|
|
||||||
|
|
||||||
*release = false;
|
|
||||||
|
|
||||||
switch (event->type) {
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
{
|
|
||||||
key = event->key.keysym.sym;
|
|
||||||
*release = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SDL_KEYUP:
|
|
||||||
{
|
|
||||||
key = event->key.keysym.sym;
|
|
||||||
*release = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SDL_QUIT:
|
|
||||||
{
|
|
||||||
SDL_Quit();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
int screenhack_handle_events(bool *release)
|
|
||||||
{
|
|
||||||
int key = 0;
|
|
||||||
SDL_Event event;
|
|
||||||
|
|
||||||
if (SDL_PollEvent(&event)) {
|
|
||||||
key = screenhack_handle_event(&event, release);
|
|
||||||
}
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int window_width;
|
|
||||||
int window_height;
|
|
||||||
|
|
||||||
if (argc > 1)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
for (x=1; x<argc; x++) {
|
|
||||||
if (!strcmp("--old_lcd", argv[x])) {
|
|
||||||
having_new_lcd=false;
|
|
||||||
printf("Using old LCD layout.\n");
|
|
||||||
} else if (!strcmp("--zoom", argv[x])) {
|
|
||||||
if (++x < argc) {
|
|
||||||
display_zoom=atoi(argv[x]);
|
|
||||||
printf("Window zoom is %d\n", display_zoom);
|
|
||||||
if (display_zoom < 1 || display_zoom > 5) {
|
|
||||||
printf("fatal: --zoom argument must be between 1 and 5\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("fatal: --zoom requires an integer argument\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("rockboxui\n");
|
|
||||||
printf("Arguments:\n");
|
|
||||||
printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
|
|
||||||
printf(" --zoom [1-5]\t window zoom\n");
|
|
||||||
printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window_width = (LCD_WIDTH + 2*MARGIN_X) * display_zoom;
|
|
||||||
window_height = (LCD_HEIGHT + 2*MARGIN_Y) * display_zoom;
|
|
||||||
#ifdef LCD_REMOTE_HEIGHT
|
|
||||||
window_height += (LCD_REMOTE_HEIGHT + 2*MARGIN_Y) * display_zoom;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)) {
|
|
||||||
fprintf(stderr, "fatal: %s", SDL_GetError());
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
atexit(SDL_Quit);
|
|
||||||
|
|
||||||
if ((surface = SDL_SetVideoMode(window_width, window_height, 24, 0)) == NULL) {
|
|
||||||
fprintf(stderr, "fatal: %s", SDL_GetError());
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
screenhack(); /* doesn't return */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski <jwz@jwz.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
||||||
* documentation for any purpose is hereby granted without fee, provided that
|
|
||||||
* the above copyright notice appear in all copies and that both that
|
|
||||||
* copyright notice and this permission notice appear in supporting
|
|
||||||
* documentation. No representations are made about the suitability of this
|
|
||||||
* software for any purpose. It is provided "as is" without express or
|
|
||||||
* implied warranty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SCREENHACK_H__
|
|
||||||
#define __SCREENHACK_H__
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#ifdef __hpux
|
|
||||||
/* Which of the ten billion standards does values.h belong to?
|
|
||||||
What systems always have it? */
|
|
||||||
# include <values.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
extern void screenhack();
|
|
||||||
extern int screenhack_handle_event(SDL_Event*, bool *);
|
|
||||||
extern int screenhack_handle_events(bool *);
|
|
||||||
extern void screen_redraw();
|
|
||||||
extern void screen_resized();
|
|
||||||
|
|
||||||
#endif /* __SCREENHACK_H__ */
|
|
||||||
|
|
@ -21,24 +21,15 @@
|
||||||
|
|
||||||
#ifdef ROCKBOX_HAS_SIMSOUND /* play sound in sim enabled */
|
#ifdef ROCKBOX_HAS_SIMSOUND /* play sound in sim enabled */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <memory.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include "uisdl.h"
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
//static Uint8 *audio_chunk;
|
|
||||||
static int audio_len;
|
static int audio_len;
|
||||||
static char *audio_pos;
|
static char *audio_pos;
|
||||||
SDL_sem* sem;
|
SDL_sem* sem;
|
||||||
|
|
||||||
/* The audio function callback takes the following parameters:
|
|
||||||
stream: A pointer to the audio buffer to be filled
|
|
||||||
len: The length (in bytes) of the audio buffer
|
|
||||||
*/
|
|
||||||
void mixaudio(void *udata, Uint8 *stream, int len)
|
void mixaudio(void *udata, Uint8 *stream, int len)
|
||||||
{
|
{
|
||||||
(void)udata;
|
(void)udata;
|
||||||
|
|
@ -59,8 +50,6 @@ void mixaudio(void *udata, Uint8 *stream, int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int sim_sound_init(void)
|
int sim_sound_init(void)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec fmt;
|
SDL_AudioSpec fmt;
|
||||||
|
|
@ -80,12 +69,9 @@ int sim_sound_init(void)
|
||||||
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
|
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_PauseAudio(0);
|
SDL_PauseAudio(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//...
|
|
||||||
|
|
||||||
//SDL_CloseAudio();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sound_playback_thread(void *p)
|
int sound_playback_thread(void *p)
|
||||||
|
|
@ -97,12 +83,12 @@ int sound_playback_thread(void* p)
|
||||||
(void)p;
|
(void)p;
|
||||||
|
|
||||||
while(sndret)
|
while(sndret)
|
||||||
sleep(100000); /* wait forever, can't play sound! */
|
SDL_Delay(100000); /* wait forever, can't play sound! */
|
||||||
|
|
||||||
do {
|
do {
|
||||||
while(!sound_get_pcm)
|
while(!sound_get_pcm)
|
||||||
/* TODO: fix a fine thread-synch mechanism here */
|
/* TODO: fix a fine thread-synch mechanism here */
|
||||||
usleep(10000);
|
SDL_Delay(100);
|
||||||
do {
|
do {
|
||||||
sound_get_pcm(&buf, &size);
|
sound_get_pcm(&buf, &size);
|
||||||
if(!size) {
|
if(!size) {
|
||||||
|
|
@ -111,11 +97,13 @@ int sound_playback_thread(void* p)
|
||||||
}
|
}
|
||||||
audio_pos = buf; // TODO: is this safe?
|
audio_pos = buf; // TODO: is this safe?
|
||||||
audio_len = size;
|
audio_len = size;
|
||||||
//printf("len: %i\n",audio_len);
|
|
||||||
if(SDL_SemWait(sem))
|
if(SDL_SemWait(sem))
|
||||||
fprintf(stderr,"Couldn't wait: %s",SDL_GetError());
|
fprintf(stderr,"Couldn't wait: %s",SDL_GetError());
|
||||||
} while(size);
|
} while(size);
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ROCKBOX_HAS_SIMSOUND */
|
#endif /* ROCKBOX_HAS_SIMSOUND */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,36 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002 by Felix Arends
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __SPRINTF_H__
|
||||||
|
#define __SPRINTF_H__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int rockbox_snprintf (char *buf, size_t size, const char *fmt, ...);
|
int snprintf (char *buf, size_t size, const char *fmt, ...);
|
||||||
int rockbox_vsnprintf (char *buf, int size, const char *fmt, va_list ap);
|
char *strtok_r (char *, const char *, char **);
|
||||||
int rockbox_fprintf (int fd, const char *fmt, ...);
|
|
||||||
|
|
||||||
#ifndef NO_REDEFINES_PLEASE
|
int rockbox_fprintf (int fd, const char *fmt, ...);
|
||||||
#define snprintf rockbox_snprintf
|
|
||||||
#define vsnprintf rockbox_vsnprintf
|
|
||||||
#define fprintf rockbox_fprintf
|
#define fprintf rockbox_fprintf
|
||||||
#endif
|
|
||||||
|
int rockbox_vsnprintf (char *buf, int size, const char *fmt, va_list ap);
|
||||||
|
#define vsnprintf rockbox_vsnprintf
|
||||||
|
|
||||||
|
#endif /* __SPRINTF_H__ */
|
||||||
|
|
|
||||||
78
uisimulator/sdl/thread-sdl.c
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Dan Everton
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <SDL_thread.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "thread-sdl.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
SDL_Thread *threads[256];
|
||||||
|
int threadCount = 0;
|
||||||
|
long current_tick = 0;
|
||||||
|
SDL_mutex *m;
|
||||||
|
|
||||||
|
void yield(void)
|
||||||
|
{
|
||||||
|
SDL_mutexV(m);
|
||||||
|
SDL_Delay(1);
|
||||||
|
SDL_mutexP(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sim_sleep(int ticks)
|
||||||
|
{
|
||||||
|
SDL_mutexV(m);
|
||||||
|
SDL_Delay((1000/HZ) * ticks);
|
||||||
|
SDL_mutexP(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
int runthread(void *data)
|
||||||
|
{
|
||||||
|
SDL_mutexV(m);
|
||||||
|
((void(*)())data) ();
|
||||||
|
SDL_mutexV(m);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int create_thread(void (*fp)(void), void* sp, int stk_size)
|
||||||
|
{
|
||||||
|
/** Avoid compiler warnings */
|
||||||
|
(void)sp;
|
||||||
|
(void)stk_size;
|
||||||
|
|
||||||
|
if (threadCount == 256) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
threads[threadCount++] = SDL_CreateThread(runthread, fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_threads(void)
|
||||||
|
{
|
||||||
|
m = SDL_CreateMutex();
|
||||||
|
|
||||||
|
if (SDL_mutexP(m) == -1) {
|
||||||
|
fprintf(stderr, "Couldn't lock mutex\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
|
* Copyright (C) 2006 Dan Everton
|
||||||
*
|
*
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
|
@ -17,10 +17,7 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define MARGIN_X 3
|
extern SDL_Thread* threads[256];
|
||||||
#define MARGIN_Y 3
|
extern int threadCount;
|
||||||
|
extern SDL_mutex* mutex;
|
||||||
/* include the "real" lcd.h file here */
|
|
||||||
#include <lcd.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* \/ \/ \/ \/ \/
|
* \/ \/ \/ \/ \/
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
|
* Copyright (C) 2006 by Daniel Everton <dan@iocaine.org>
|
||||||
*
|
*
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
|
@ -16,211 +16,170 @@
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include "autoconf.h"
|
||||||
#include <sys/types.h>
|
#include "uisdl.h"
|
||||||
#include <sys/stat.h>
|
#include "button.h"
|
||||||
#include <fcntl.h>
|
#include "thread.h"
|
||||||
|
#include "thread-sdl.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
#include <errno.h>
|
// extern functions
|
||||||
#include <ctype.h>
|
extern void app_main (void *); // mod entry point
|
||||||
#include <time.h>
|
extern void new_key(int key);
|
||||||
|
extern void sim_tick_tasks(void);
|
||||||
|
|
||||||
#include <SDL.h>
|
void button_event(int key, bool pressed);
|
||||||
|
|
||||||
#include "config.h"
|
SDL_Surface *gui_surface;
|
||||||
#include "screenhack.h"
|
|
||||||
|
|
||||||
#include "version.h"
|
SDL_Thread *gui_thread;
|
||||||
|
SDL_TimerID tick_timer_id;
|
||||||
#include "lcd-x11.h"
|
#ifdef ROCKBOX_HAS_SIMSOUND
|
||||||
#include "lcd-playersim.h"
|
SDL_Thread *sound_thread;
|
||||||
|
|
||||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
|
||||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
|
||||||
|
|
||||||
#define PROGNAME "rockboxui"
|
|
||||||
|
|
||||||
/* -- -- */
|
|
||||||
|
|
||||||
extern SDL_Surface *surface;
|
|
||||||
|
|
||||||
int display_zoom=2;
|
|
||||||
|
|
||||||
bool lcd_display_redraw=true;
|
|
||||||
|
|
||||||
char *progclass = "rockboxui";
|
|
||||||
|
|
||||||
void init_window ()
|
|
||||||
{
|
|
||||||
/* stub */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* used for the player sim */
|
|
||||||
void drawdots(int color, struct coordinate *points, int count)
|
|
||||||
{
|
|
||||||
SDL_Rect rect;
|
|
||||||
|
|
||||||
while (count--) {
|
|
||||||
rect.x = points[count].x * display_zoom;
|
|
||||||
rect.y = points[count].y * display_zoom;
|
|
||||||
rect.w = display_zoom;
|
|
||||||
rect.h = display_zoom;
|
|
||||||
|
|
||||||
SDL_FillRect(surface, &rect, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawrect(int color, int x1, int y1, int x2, int y2)
|
|
||||||
{
|
|
||||||
SDL_Rect rect;
|
|
||||||
|
|
||||||
rect.x = x1 * display_zoom;
|
|
||||||
rect.y = y1 * display_zoom;
|
|
||||||
rect.w = (x2-x1) * display_zoom;
|
|
||||||
rect.h = (y2-y1) * display_zoom;
|
|
||||||
|
|
||||||
SDL_FillRect(surface, &rect, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void help(void)
|
|
||||||
{
|
|
||||||
printf(PROGNAME " " ROCKBOXUI_VERSION " " __DATE__ "\n"
|
|
||||||
"usage: " PROGNAME "\n");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dots(int *colors, struct coordinate *points, int count)
|
bool lcd_display_redraw=true; // Used for player simulator
|
||||||
|
char having_new_lcd=true; // Used for player simulator
|
||||||
|
|
||||||
|
long start_tick;
|
||||||
|
|
||||||
|
Uint32 tick_timer(Uint32 interval, void *param)
|
||||||
{
|
{
|
||||||
int bpp = surface->format->BytesPerPixel;
|
long new_tick;
|
||||||
|
|
||||||
if (SDL_MUSTLOCK(surface)) {
|
(void) interval;
|
||||||
if (SDL_LockSurface(surface)) {
|
(void) param;
|
||||||
fprintf(stderr, "cannot lock surface: %s", SDL_GetError());
|
|
||||||
exit(-1);
|
new_tick = (SDL_GetTicks() - start_tick) * HZ / 1000;
|
||||||
|
|
||||||
|
if (new_tick != current_tick)
|
||||||
|
{
|
||||||
|
long i;
|
||||||
|
for (i = new_tick - current_tick; i > 0; i--)
|
||||||
|
sim_tick_tasks();
|
||||||
|
current_tick = new_tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_message_loop(void)
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
while(!done && SDL_WaitEvent(&event))
|
||||||
|
{
|
||||||
|
switch(event.type)
|
||||||
|
{
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
button_event(event.key.keysym.sym, true);
|
||||||
|
break;
|
||||||
|
case SDL_KEYUP:
|
||||||
|
button_event(event.key.keysym.sym, false);
|
||||||
|
break;
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//printf("Unhandled event\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (count--) {
|
bool gui_startup()
|
||||||
int x_off, y_off;
|
{
|
||||||
|
SDL_Surface *picture_surface;
|
||||||
|
|
||||||
for (x_off = 0; x_off < display_zoom; x_off++) {
|
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER)) {
|
||||||
for (y_off = 0; y_off < display_zoom; y_off++) {
|
fprintf(stderr, "fatal: %s", SDL_GetError());
|
||||||
int x = points[count].x*display_zoom + x_off;
|
return false;
|
||||||
int y = points[count].y*display_zoom + y_off;
|
}
|
||||||
|
|
||||||
Uint8 *p = (Uint8 *) surface->pixels + y * surface->pitch + x * bpp;
|
atexit(SDL_Quit);
|
||||||
|
|
||||||
switch (bpp) {
|
if ((gui_surface = SDL_SetVideoMode(UI_WIDTH, UI_HEIGHT, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
|
||||||
case 1:
|
fprintf(stderr, "fatal: %s", SDL_GetError());
|
||||||
*p = colors[count];
|
return false;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case 2:
|
SDL_WM_SetCaption(UI_TITLE, NULL);
|
||||||
*(Uint16 *)p = colors[count];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
simlcdinit();
|
||||||
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
|
|
||||||
p[0] = (colors[count] >> 16) & 0xff;
|
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
p[1] = (colors[count] >> 8) & 0xff;
|
|
||||||
p[2] = (colors[count]) & 0xff;
|
picture_surface = SDL_LoadBMP("UI256.bmp");
|
||||||
|
if (picture_surface == NULL) {
|
||||||
|
fprintf(stderr, "warn: %s", SDL_GetError());
|
||||||
} else {
|
} else {
|
||||||
p[2] = (colors[count] >> 16) & 0xff;
|
SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
|
||||||
p[1] = (colors[count] >> 8) & 0xff;
|
SDL_UpdateRect(gui_surface, 0, 0, 0, 0);
|
||||||
p[0] = (colors[count]) & 0xff;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
*(Uint32 *)p = colors[count];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_MUSTLOCK(surface)) {
|
start_tick = SDL_GetTicks();
|
||||||
SDL_UnlockSurface(surface);
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
bool gui_shutdown()
|
||||||
}
|
|
||||||
|
|
||||||
/* this is where the applicaton starts */
|
|
||||||
extern void app_main(void);
|
|
||||||
|
|
||||||
void screenhack()
|
|
||||||
{
|
{
|
||||||
#if 0
|
int i;
|
||||||
Bool helpme;
|
|
||||||
|
|
||||||
/* This doesn't work, but I don't know why (Daniel 1999-12-01) */
|
SDL_KillThread(gui_thread);
|
||||||
helpme = get_boolean_resource ("help", "Boolean");
|
SDL_RemoveTimer(tick_timer_id);
|
||||||
if(helpme)
|
#ifdef ROCKBOX_HAS_SIMSOUND
|
||||||
help();
|
SDL_KillThread(sound_thread);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf(PROGNAME " " ROCKBOXUI_VERSION " (" __DATE__ ")\n");
|
for (i = 0; i < threadCount; i++)
|
||||||
|
|
||||||
init_window();
|
|
||||||
|
|
||||||
screen_redraw();
|
|
||||||
|
|
||||||
app_main();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* used for the player sim */
|
|
||||||
void drawrectangles(int color, struct rectangle *points, int count)
|
|
||||||
{
|
{
|
||||||
SDL_Rect rect;
|
SDL_KillThread(threads[i]);
|
||||||
Uint32 sdl_white = SDL_MapRGB(surface->format, 255, 255, 255);
|
|
||||||
Uint32 sdl_black = SDL_MapRGB(surface->format, 0, 0, 0);
|
|
||||||
|
|
||||||
while (count--) {
|
|
||||||
rect.x = points[count].x * display_zoom;
|
|
||||||
rect.y = points[count].y * display_zoom;
|
|
||||||
rect.w = points[count].width * display_zoom;
|
|
||||||
rect.h = points[count].height * display_zoom;
|
|
||||||
|
|
||||||
SDL_FillRect(surface, &rect, color ? sdl_white : sdl_black);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void screen_redraw()
|
/**
|
||||||
|
* Thin wrapper around normal app_main() to stop gcc complaining about types.
|
||||||
|
*/
|
||||||
|
int sim_app_main(void *param)
|
||||||
{
|
{
|
||||||
/* draw a border around the screen */
|
app_main(param);
|
||||||
int X1 = 0;
|
|
||||||
int Y1 = 0;
|
|
||||||
int X2 = LCD_WIDTH + 2*MARGIN_X - 1;
|
|
||||||
int Y2 = LCD_HEIGHT + 2*MARGIN_Y - 1;
|
|
||||||
|
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X1, Y1, X2, Y1+1);
|
return 0;
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X2, Y1, X2+1, Y2);
|
}
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X1, Y2, X2, Y2+1);
|
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), X1, Y1, X1+1, Y2);
|
|
||||||
|
|
||||||
lcd_display_redraw = true;
|
int main(int argc, char *argv[])
|
||||||
lcd_update();
|
{
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
|
||||||
#ifdef LCD_REMOTE_HEIGHT
|
if (!gui_startup())
|
||||||
/* draw a border around the remote LCD screen */
|
return -1;
|
||||||
int RX1 = 0;
|
|
||||||
int RY1 = Y2 + 1;
|
|
||||||
int RX2 = LCD_REMOTE_WIDTH + 2*MARGIN_X - 1;
|
|
||||||
int RY2 = RY1 + LCD_REMOTE_HEIGHT + 2*MARGIN_Y - 1;
|
|
||||||
|
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX1, RY1, RX2, RY1+1);
|
gui_thread = SDL_CreateThread(sim_app_main, NULL);
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX2, RY1, RX2+1, RY2);
|
if (gui_thread == NULL) {
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX1, RY2, RX2, RY2+1);
|
printf("Error creating GUI thread!\n");
|
||||||
drawrect(SDL_MapRGB(surface->format, 255, 255, 255), RX1, RY1, RX1+1, RY2);
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
lcd_display_redraw = true;
|
tick_timer_id = SDL_AddTimer(10, tick_timer, NULL);
|
||||||
lcd_remote_update();
|
|
||||||
|
#ifdef ROCKBOX_HAS_SIMSOUND
|
||||||
|
sound_thread = SDL_CreateThread(sound_playback_thread, NULL);
|
||||||
|
if (sound_thread == NULL) {
|
||||||
|
printf("Error creating sound thread!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gui_message_loop();
|
||||||
|
|
||||||
|
return gui_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||