Integrated the changes by PheeL for Caanoo support
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1629 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
dbac6dcfe3
commit
bd13dd93b1
@ -38,7 +38,7 @@
|
|||||||
#include "sdlscreen.h"
|
#include "sdlscreen.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
#if defined(__VBCC__)||defined(__GP2X__)
|
#if defined(__VBCC__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
#define M_PI 3.141592653589793238462643
|
#define M_PI 3.141592653589793238462643
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
92
src/global.h
92
src/global.h
@ -955,34 +955,80 @@ GFX2_GLOBAL SDL_Joystick* Joystick;
|
|||||||
/// It was chosen to not conflict with any SDL key number.
|
/// It was chosen to not conflict with any SDL key number.
|
||||||
#define KEY_JOYBUTTON (SDLK_LAST+4)
|
#define KEY_JOYBUTTON (SDLK_LAST+4)
|
||||||
|
|
||||||
/// Button definitions for the gp2x
|
/// The joystick axis are {X,Y} - on all platforms so far.
|
||||||
#define GP2X_BUTTON_UP (0)
|
/// If there is ever a platform where they are reversed, put
|
||||||
#define GP2X_BUTTON_DOWN (4)
|
/// these lines in each platform "case" below.
|
||||||
#define GP2X_BUTTON_LEFT (2)
|
#define JOYSTICK_AXIS_X (0)
|
||||||
#define GP2X_BUTTON_RIGHT (6)
|
#define JOYSTICK_AXIS_Y (1)
|
||||||
#define GP2X_BUTTON_UPLEFT (1)
|
|
||||||
#define GP2X_BUTTON_UPRIGHT (7)
|
|
||||||
#define GP2X_BUTTON_DOWNLEFT (3)
|
|
||||||
#define GP2X_BUTTON_DOWNRIGHT (5)
|
|
||||||
#define GP2X_BUTTON_CLICK (18)
|
|
||||||
#define GP2X_BUTTON_A (12)
|
|
||||||
#define GP2X_BUTTON_B (13)
|
|
||||||
#define GP2X_BUTTON_Y (14)
|
|
||||||
#define GP2X_BUTTON_X (15)
|
|
||||||
#define GP2X_BUTTON_L (10)
|
|
||||||
#define GP2X_BUTTON_R (11)
|
|
||||||
#define GP2X_BUTTON_START (8)
|
|
||||||
#define GP2X_BUTTON_SELECT (9)
|
|
||||||
#define GP2X_BUTTON_VOLUP (16)
|
|
||||||
#define GP2X_BUTTON_VOLDOWN (17)
|
|
||||||
|
|
||||||
#ifdef __gp2x__
|
#ifdef __GP2X__
|
||||||
#define KEY_ESC (KEY_JOYBUTTON+GP2X_BUTTON_X)
|
|
||||||
|
#define JOYSTICK_THRESHOLD (4096)
|
||||||
|
|
||||||
|
/// Button definitions for the gp2x
|
||||||
|
#define GP2X_BUTTON_UP (0)
|
||||||
|
#define GP2X_BUTTON_DOWN (4)
|
||||||
|
#define GP2X_BUTTON_LEFT (2)
|
||||||
|
#define GP2X_BUTTON_RIGHT (6)
|
||||||
|
#define GP2X_BUTTON_UPLEFT (1)
|
||||||
|
#define GP2X_BUTTON_UPRIGHT (7)
|
||||||
|
#define GP2X_BUTTON_DOWNLEFT (3)
|
||||||
|
#define GP2X_BUTTON_DOWNRIGHT (5)
|
||||||
|
#define GP2X_BUTTON_CLICK (18)
|
||||||
|
#define GP2X_BUTTON_A (12)
|
||||||
|
#define GP2X_BUTTON_B (13)
|
||||||
|
#define GP2X_BUTTON_Y (14)
|
||||||
|
#define GP2X_BUTTON_X (15)
|
||||||
|
#define GP2X_BUTTON_L (10)
|
||||||
|
#define GP2X_BUTTON_R (11)
|
||||||
|
#define GP2X_BUTTON_START (8)
|
||||||
|
#define GP2X_BUTTON_SELECT (9)
|
||||||
|
#define GP2X_BUTTON_VOLUP (16)
|
||||||
|
#define GP2X_BUTTON_VOLDOWN (17)
|
||||||
|
|
||||||
|
#define KEY_ESC (KEY_JOYBUTTON+GP2X_BUTTON_X)
|
||||||
|
#elif defined(__WIZ__)
|
||||||
|
/// Button definitions for the Wiz
|
||||||
|
#define WIZ_BUTTON_UP (0)
|
||||||
|
#define WIZ_BUTTON_DOWN (4)
|
||||||
|
#define WIZ_BUTTON_LEFT (2)
|
||||||
|
#define WIZ_BUTTON_RIGHT (6)
|
||||||
|
#define WIZ_BUTTON_UPLEFT (1)
|
||||||
|
#define WIZ_BUTTON_UPRIGHT (7)
|
||||||
|
#define WIZ_BUTTON_DOWNLEFT (3)
|
||||||
|
#define WIZ_BUTTON_DOWNRIGHT (5)
|
||||||
|
#define WIZ_BUTTON_L (10)
|
||||||
|
#define WIZ_BUTTON_R (11)
|
||||||
|
#define WIZ_BUTTON_A (12)
|
||||||
|
#define WIZ_BUTTON_B (13)
|
||||||
|
#define WIZ_BUTTON_X (14)
|
||||||
|
#define WIZ_BUTTON_Y (15)
|
||||||
|
#define WIZ_BUTTON_MENU (8)
|
||||||
|
#define WIZ_BUTTON_SELECT (9)
|
||||||
|
#define WIZ_BUTTON_VOLUP (16)
|
||||||
|
#define WIZ_BUTTON_VOLDOWN (17)
|
||||||
|
|
||||||
|
#define KEY_ESC (KEY_JOYBUTTON+WIZ_BUTTON_X)
|
||||||
|
#elif __CAANOO__
|
||||||
|
/// Button definitions for the Caanoo
|
||||||
|
#define CAANOO_BUTTON_A (0)
|
||||||
|
#define CAANOO_BUTTON_X (1)
|
||||||
|
#define CAANOO_BUTTON_B (2)
|
||||||
|
#define CAANOO_BUTTON_Y (3)
|
||||||
|
#define CAANOO_BUTTON_L (4)
|
||||||
|
#define CAANOO_BUTTON_R (5)
|
||||||
|
#define CAANOO_BUTTON_HOME (6)
|
||||||
|
#define CAANOO_BUTTON_HOLD (7)
|
||||||
|
#define CAANOO_BUTTON_I (8)
|
||||||
|
#define CAANOO_BUTTON_II (9)
|
||||||
|
#define CAANOO_BUTTON_JOY (10)
|
||||||
|
|
||||||
|
#define KEY_ESC (KEY_JOYBUTTON+CAANOO_BUTTON_HOME)
|
||||||
#else
|
#else
|
||||||
///
|
///
|
||||||
/// This is the key identifier for ESC. When hard-coding keyboard shortcuts
|
/// This is the key identifier for ESC. When hard-coding keyboard shortcuts
|
||||||
/// for buttons, etc. we use this instead of SDLK_ESCAPE,
|
/// for buttons, etc. we use this instead of SDLK_ESCAPE,
|
||||||
/// so the GP2X port can get a joybutton equivalent of it.
|
/// so the console ports can get a joybutton equivalent of it.
|
||||||
#define KEY_ESC SDLK_ESCAPE
|
#define KEY_ESC SDLK_ESCAPE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__VBCC__)||defined(__GP2X__)
|
#if defined(__VBCC__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
#define M_PI 3.141592653589793238462643
|
#define M_PI 3.141592653589793238462643
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -435,6 +435,10 @@ static const T_Help_table helptable_credits[] =
|
|||||||
HELP_TEXT ("")
|
HELP_TEXT ("")
|
||||||
HELP_TEXT (" Luc Schrijvers (Begasus)")
|
HELP_TEXT (" Luc Schrijvers (Begasus)")
|
||||||
HELP_TEXT ("")
|
HELP_TEXT ("")
|
||||||
|
HELP_BOLD (" WIZ & CAANOO PORT")
|
||||||
|
HELP_TEXT ("")
|
||||||
|
HELP_TEXT (" PheeL")
|
||||||
|
HELP_TEXT ("")
|
||||||
HELP_TEXT ("")
|
HELP_TEXT ("")
|
||||||
HELP_TEXT (" ... made it work on your favourite toaster")
|
HELP_TEXT (" ... made it work on your favourite toaster")
|
||||||
HELP_TEXT ("")
|
HELP_TEXT ("")
|
||||||
|
|||||||
174
src/input.c
174
src/input.c
@ -34,6 +34,7 @@
|
|||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "buttons.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "loadsave.h"
|
#include "loadsave.h"
|
||||||
|
|
||||||
@ -81,19 +82,53 @@ short Mouse_virtual_y_position;
|
|||||||
short Mouse_virtual_width;
|
short Mouse_virtual_width;
|
||||||
short Mouse_virtual_height;
|
short Mouse_virtual_height;
|
||||||
|
|
||||||
// TODO: move to config
|
// Joystick/pad configurations for the various console ports.
|
||||||
#ifdef __GP2X__
|
// See the #else for the documentation of fields.
|
||||||
short Joybutton_shift=GP2X_BUTTON_L; // Button number that serves as a "shift" modifier
|
// TODO: Make these user-settable somehow.
|
||||||
short Joybutton_control=GP2X_BUTTON_R; // Button number that serves as a "ctrl" modifier
|
#if defined(__GP2X__)
|
||||||
short Joybutton_alt=GP2X_BUTTON_CLICK; // Button number that serves as a "alt" modifier
|
|
||||||
short Joybutton_left_click=GP2X_BUTTON_B; // Button number that serves as left click
|
#define JOYSTICK_THRESHOLD (4096)
|
||||||
short Joybutton_right_click=GP2X_BUTTON_Y; // Button number that serves as right-click
|
short Joybutton_shift=GP2X_BUTTON_L;
|
||||||
#else
|
short Joybutton_control=GP2X_BUTTON_R;
|
||||||
short Joybutton_shift=-1; // Button number that serves as a "shift" modifier
|
short Joybutton_alt=GP2X_BUTTON_CLICK;
|
||||||
short Joybutton_control=-1; // Button number that serves as a "ctrl" modifier
|
short Joybutton_left_click=GP2X_BUTTON_B;
|
||||||
short Joybutton_alt=-1; // Button number that serves as a "alt" modifier
|
short Joybutton_right_click=GP2X_BUTTON_Y;
|
||||||
short Joybutton_left_click=0; // Button number that serves as left click
|
|
||||||
short Joybutton_right_click=0; // Button number that serves as right-click
|
#elif defined(__WIZ__)
|
||||||
|
|
||||||
|
#define JOYSTICK_THRESHOLD (4096)
|
||||||
|
short Joybutton_shift=WIZ_BUTTON_X;
|
||||||
|
short Joybutton_control=WIZ_BUTTON_SELECT;
|
||||||
|
short Joybutton_alt=WIZ_BUTTON_Y;
|
||||||
|
short Joybutton_left_click=WIZ_BUTTON_A;
|
||||||
|
short Joybutton_right_click=WIZ_BUTTON_B;
|
||||||
|
|
||||||
|
#elif defined(__CAANOO__)
|
||||||
|
|
||||||
|
#define JOYSTICK_THRESHOLD (4096)
|
||||||
|
short Joybutton_shift=CAANOO_BUTTON_L;
|
||||||
|
short Joybutton_control=CAANOO_BUTTON_R;
|
||||||
|
short Joybutton_alt=CAANOO_BUTTON_Y;
|
||||||
|
short Joybutton_left_click=CAANOO_BUTTON_A;
|
||||||
|
short Joybutton_right_click=CAANOO_BUTTON_B;
|
||||||
|
|
||||||
|
#else // Default : Any joystick on a computer platform
|
||||||
|
///
|
||||||
|
/// This is the sensitivity threshold for the directional
|
||||||
|
/// pad of a cheap digital joypad on the PC. It has been set through
|
||||||
|
/// trial and error : If value is too large then the movement is
|
||||||
|
/// randomly interrupted; if the value is too low the cursor will
|
||||||
|
/// move by itself, controlled by parasits.
|
||||||
|
#define JOYSTICK_THRESHOLD (1000)
|
||||||
|
|
||||||
|
/// A button that is marked as "modifier" will
|
||||||
|
short Joybutton_shift=-1; ///< Button number that serves as a "shift" modifier; -1 for none
|
||||||
|
short Joybutton_control=-1; ///< Button number that serves as a "ctrl" modifier; -1 for none
|
||||||
|
short Joybutton_alt=-1; ///< Button number that serves as a "alt" modifier; -1 for none
|
||||||
|
|
||||||
|
short Joybutton_left_click=0; ///< Button number that serves as left click; -1 for none
|
||||||
|
short Joybutton_right_click=1; ///< Button number that serves as right-click; -1 for none
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int Has_shortcut(word function)
|
int Has_shortcut(word function)
|
||||||
@ -502,7 +537,7 @@ int Handle_joystick_press(SDL_JoyButtonEvent event)
|
|||||||
Input_new_mouse_K=2;
|
Input_new_mouse_K=2;
|
||||||
return Move_cursor_with_constraints();
|
return Move_cursor_with_constraints();
|
||||||
}
|
}
|
||||||
#ifdef __GP2X__
|
#if defined(__GP2X__)
|
||||||
switch(event.button)
|
switch(event.button)
|
||||||
{
|
{
|
||||||
case GP2X_BUTTON_UP:
|
case GP2X_BUTTON_UP:
|
||||||
@ -529,8 +564,77 @@ int Handle_joystick_press(SDL_JoyButtonEvent event)
|
|||||||
case GP2X_BUTTON_UPLEFT:
|
case GP2X_BUTTON_UPLEFT:
|
||||||
Directional_up_left=1;
|
Directional_up_left=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
#elif __WIZ__
|
||||||
|
switch(event.button)
|
||||||
|
{
|
||||||
|
case WIZ_BUTTON_UP:
|
||||||
|
Directional_up=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_UPRIGHT:
|
||||||
|
Directional_up_right=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_RIGHT:
|
||||||
|
Directional_right=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_DOWNRIGHT:
|
||||||
|
Directional_down_right=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_DOWN:
|
||||||
|
Directional_down=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_DOWNLEFT:
|
||||||
|
Directional_down_left=1;
|
||||||
|
case WIZ_BUTTON_LEFT:
|
||||||
|
Directional_left=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_UPLEFT:
|
||||||
|
Directional_up_left=1;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_MENU:
|
||||||
|
{
|
||||||
|
SDL_Event Event;
|
||||||
|
Event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&Event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_L:
|
||||||
|
if(!Windows_open)
|
||||||
|
Button_Undo();
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_R:
|
||||||
|
if(!Windows_open)
|
||||||
|
Button_Redo();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#elif __CAANOO__
|
||||||
|
switch(event.button)
|
||||||
|
{
|
||||||
|
case CAANOO_BUTTON_HOME:
|
||||||
|
{
|
||||||
|
SDL_Event Event;
|
||||||
|
|
||||||
|
Event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&Event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAANOO_BUTTON_I:
|
||||||
|
if(!Windows_open)
|
||||||
|
Button_Undo();
|
||||||
|
break;
|
||||||
|
case CAANOO_BUTTON_II:
|
||||||
|
if(!Windows_open)
|
||||||
|
Button_Redo();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Key = (KEY_JOYBUTTON+event.button)|Key_modifiers(SDL_GetModState());
|
Key = (KEY_JOYBUTTON+event.button)|Key_modifiers(SDL_GetModState());
|
||||||
@ -567,7 +671,7 @@ int Handle_joystick_release(SDL_JoyButtonEvent event)
|
|||||||
return Move_cursor_with_constraints();
|
return Move_cursor_with_constraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GP2X__
|
#if defined(__GP2X__)
|
||||||
switch(event.button)
|
switch(event.button)
|
||||||
{
|
{
|
||||||
case GP2X_BUTTON_UP:
|
case GP2X_BUTTON_UP:
|
||||||
@ -595,30 +699,58 @@ int Handle_joystick_release(SDL_JoyButtonEvent event)
|
|||||||
Directional_up_left=0;
|
Directional_up_left=0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#elif defined(__WIZ__)
|
||||||
|
switch(event.button)
|
||||||
|
{
|
||||||
|
case WIZ_BUTTON_UP:
|
||||||
|
Directional_up=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_UPRIGHT:
|
||||||
|
Directional_up_right=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_RIGHT:
|
||||||
|
Directional_right=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_DOWNRIGHT:
|
||||||
|
Directional_down_right=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_DOWN:
|
||||||
|
Directional_down=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_DOWNLEFT:
|
||||||
|
Directional_down_left=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_LEFT:
|
||||||
|
Directional_left=0;
|
||||||
|
break;
|
||||||
|
case WIZ_BUTTON_UPLEFT:
|
||||||
|
Directional_up_left=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return Move_cursor_with_constraints();
|
return Move_cursor_with_constraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle_joystick_movement(SDL_JoyAxisEvent event)
|
void Handle_joystick_movement(SDL_JoyAxisEvent event)
|
||||||
{
|
{
|
||||||
if (event.axis==0) // X
|
if (event.axis==JOYSTICK_AXIS_X)
|
||||||
{
|
{
|
||||||
Directional_right=Directional_left=0;
|
Directional_right=Directional_left=0;
|
||||||
if (event.value<-1000)
|
if (event.value<-JOYSTICK_THRESHOLD)
|
||||||
{
|
{
|
||||||
Directional_left=1;
|
Directional_left=1;
|
||||||
}
|
}
|
||||||
else if (event.value>1000)
|
else if (event.value>JOYSTICK_THRESHOLD)
|
||||||
Directional_right=1;
|
Directional_right=1;
|
||||||
}
|
}
|
||||||
else if (event.axis==1) // Y
|
else if (event.axis==JOYSTICK_AXIS_Y)
|
||||||
{
|
{
|
||||||
Directional_up=Directional_down=0;
|
Directional_up=Directional_down=0;
|
||||||
if (event.value<-1000)
|
if (event.value<-JOYSTICK_THRESHOLD)
|
||||||
{
|
{
|
||||||
Directional_up=1;
|
Directional_up=1;
|
||||||
}
|
}
|
||||||
else if (event.value>1000)
|
else if (event.value>JOYSTICK_THRESHOLD)
|
||||||
Directional_down=1;
|
Directional_down=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
|
Copyright 2010 A Filyanov
|
||||||
Copyright 2009 Franck Charlet
|
Copyright 2009 Franck Charlet
|
||||||
Copyright 2008 Yves Rizoud
|
Copyright 2008 Yves Rizoud
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
@ -465,9 +466,9 @@ const char * Key_name(word key)
|
|||||||
|
|
||||||
key=key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT);
|
key=key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT);
|
||||||
|
|
||||||
|
#if defined(__GP2X__)
|
||||||
if (key>=KEY_JOYBUTTON && key<=KEY_JOYBUTTON+18)
|
if (key>=KEY_JOYBUTTON && key<=KEY_JOYBUTTON+18)
|
||||||
{
|
{
|
||||||
#ifdef __GP2X__
|
|
||||||
|
|
||||||
char *button_name;
|
char *button_name;
|
||||||
switch(key-KEY_JOYBUTTON)
|
switch(key-KEY_JOYBUTTON)
|
||||||
@ -494,7 +495,47 @@ const char * Key_name(word key)
|
|||||||
default: sprintf(buffer+strlen(buffer), "[B%d]", key);return buffer;
|
default: sprintf(buffer+strlen(buffer), "[B%d]", key);return buffer;
|
||||||
}
|
}
|
||||||
strcat(buffer,button_name);
|
strcat(buffer,button_name);
|
||||||
#else
|
#elif defined(__WIZ__)
|
||||||
|
if (Key>=KEY_JOYBUTTON && Key<=KEY_JOYBUTTON+17)
|
||||||
|
{
|
||||||
|
char *button_name;
|
||||||
|
switch(Key-KEY_JOYBUTTON)
|
||||||
|
{
|
||||||
|
case WIZ_BUTTON_A: button_name="[A]"; break;
|
||||||
|
case WIZ_BUTTON_X: button_name="[X]"; break;
|
||||||
|
case WIZ_BUTTON_B: button_name="[B]"; break;
|
||||||
|
case WIZ_BUTTON_Y: button_name="[Y]"; break;
|
||||||
|
case WIZ_BUTTON_L: button_name="[L]"; break;
|
||||||
|
case WIZ_BUTTON_R: button_name="[R]"; break;
|
||||||
|
case WIZ_BUTTON_MENU: button_name="[MENU]"; break;
|
||||||
|
case WIZ_BUTTON_SELECT: button_name="[SELECT]"; break;
|
||||||
|
case WIZ_BUTTON_VOLUP: button_name="[VOL UP]"; break;
|
||||||
|
case WIZ_BUTTON_VOLDOWN: button_name="[VOL DOWN]"; break;
|
||||||
|
default: sprintf(buffer+strlen(buffer), "[B%d]", Key);return buffer;
|
||||||
|
}
|
||||||
|
strcat(buffer,button_name);
|
||||||
|
#elif defined(__CAANOO__)
|
||||||
|
if (Key>=KEY_JOYBUTTON && Key<=KEY_JOYBUTTON+10)
|
||||||
|
{
|
||||||
|
char *button_name;
|
||||||
|
switch(Key-KEY_JOYBUTTON)
|
||||||
|
{
|
||||||
|
case CAANOO_BUTTON_A: button_name="[A]"; break;
|
||||||
|
case CAANOO_BUTTON_X: button_name="[X]"; break;
|
||||||
|
case CAANOO_BUTTON_B: button_name="[B]"; break;
|
||||||
|
case CAANOO_BUTTON_Y: button_name="[Y]"; break;
|
||||||
|
case CAANOO_BUTTON_L: button_name="[L]"; break;
|
||||||
|
case CAANOO_BUTTON_R: button_name="[R]"; break;
|
||||||
|
case CAANOO_BUTTON_HOME: button_name="[HOME]"; break;
|
||||||
|
case CAANOO_BUTTON_HOLD: button_name="[HOLD]"; break;
|
||||||
|
case CAANOO_BUTTON_I: button_name="[BUTTON I]"; break;
|
||||||
|
case CAANOO_BUTTON_II: button_name="[BUTTON II]"; break;
|
||||||
|
case CAANOO_BUTTON_JOY: button_name="[THUMB JOY]"; break;
|
||||||
|
default: sprintf(buffer+strlen(buffer), "[B%d]", Key);return buffer;
|
||||||
|
}
|
||||||
|
strcat(buffer,button_name);
|
||||||
|
#else
|
||||||
|
{
|
||||||
sprintf(buffer+strlen(buffer), "[B%d]", key-KEY_JOYBUTTON);
|
sprintf(buffer+strlen(buffer), "[B%d]", key-KEY_JOYBUTTON);
|
||||||
#endif
|
#endif
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
|
Copyright 2010 A Filyanov
|
||||||
Copyright 2009 Petter Lindquist
|
Copyright 2009 Petter Lindquist
|
||||||
Copyright 2008 Yves Rizoud
|
Copyright 2008 Yves Rizoud
|
||||||
Copyright 2008 Franck Charlet
|
Copyright 2008 Franck Charlet
|
||||||
@ -652,7 +653,7 @@ void Load_image(T_IO_Context *context)
|
|||||||
|
|
||||||
case CONTEXT_SURFACE:
|
case CONTEXT_SURFACE:
|
||||||
if (Convert_24b_bitmap_to_256(context->Surface->pixels,context->Buffer_image_24b,context->Width,context->Height,context->Palette))
|
if (Convert_24b_bitmap_to_256(context->Surface->pixels,context->Buffer_image_24b,context->Width,context->Height,context->Palette))
|
||||||
File_error=1;
|
File_error=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -977,8 +978,30 @@ void Load_SDL_Image(T_IO_Context *context)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Hi/Trucolor
|
{
|
||||||
Pre_load(context, surface->w, surface->h, file_size ,FORMAT_ALL_IMAGES, PIXEL_SIMPLE, 1);
|
// Hi/Trucolor
|
||||||
|
///Sorry, but i give up! It needs a hard debug. So, a simply workaround here. Unfortunately it doubling memory usage by conversion surface :(
|
||||||
|
#if defined(__WIZ__) || defined(__CAANOO__)
|
||||||
|
SDL_Surface *pNewSurface;
|
||||||
|
SDL_PixelFormat pixfmt;
|
||||||
|
#endif
|
||||||
|
Pre_load(context, surface->w, surface->h, file_size ,FORMAT_ALL_IMAGES, PIXEL_SIMPLE, 1);
|
||||||
|
#if defined(__WIZ__) || defined(__CAANOO__)
|
||||||
|
memcpy(&pixfmt, surface->format, sizeof(SDL_PixelFormat));
|
||||||
|
pixfmt.BitsPerPixel = 32;
|
||||||
|
pixfmt.BytesPerPixel = 4;
|
||||||
|
|
||||||
|
pNewSurface = SDL_ConvertSurface(surface, &pixfmt, SDL_SWSURFACE);
|
||||||
|
if (pNewSurface == NULL)
|
||||||
|
{
|
||||||
|
File_error=1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_FreeSurface(surface);
|
||||||
|
surface = pNewSurface;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (y_pos=0; y_pos<context->Height; y_pos++)
|
for (y_pos=0; y_pos<context->Height; y_pos++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// There is no WM on the GP2X...
|
// There is no WM on the GP2X...
|
||||||
#ifndef __GP2X__
|
#if !defined(__GP2X__) && !defined(__WIZ__) && !defined(__CAANOO__)
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -887,6 +887,12 @@ void Program_shutdown(void)
|
|||||||
Error(ERROR_MISSING_DIRECTORY);
|
Error(ERROR_MISSING_DIRECTORY);
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
|
#if defined(__GP2X__) || defined(__gp2x__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
|
chdir("/usr/gp2x");
|
||||||
|
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
91
src/op_c.c
91
src/op_c.c
@ -2,6 +2,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
|
Copyright 2010 A Filyanov
|
||||||
Copyright 2007 Adrien Destugues
|
Copyright 2007 Adrien Destugues
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
@ -30,6 +31,8 @@
|
|||||||
#include "op_c.h"
|
#include "op_c.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
|
int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
|
||||||
|
|
||||||
/// Convert RGB to HSL.
|
/// Convert RGB to HSL.
|
||||||
/// Both input and output are in the 0..255 range to use in the palette screen
|
/// Both input and output are in the 0..255 range to use in the palette screen
|
||||||
void RGB_to_HSL(int r,int g,int b,byte * hr,byte * sr,byte* lr)
|
void RGB_to_HSL(int r,int g,int b,byte * hr,byte * sr,byte* lr)
|
||||||
@ -1352,6 +1355,10 @@ static const byte precision_24b[]=
|
|||||||
// Give this one a 24b source, get back the 256c bitmap and its palette
|
// Give this one a 24b source, get back the 256c bitmap and its palette
|
||||||
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
|
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
|
||||||
{
|
{
|
||||||
|
#if defined(__GP2X__) || defined(__gp2x__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
|
return Convert_24b_bitmap_to_256_fast(dest, source, width, height, palette);
|
||||||
|
|
||||||
|
#else
|
||||||
T_Conversion_table * table; // table de conversion
|
T_Conversion_table * table; // table de conversion
|
||||||
int ip; // index de précision pour la conversion
|
int ip; // index de précision pour la conversion
|
||||||
|
|
||||||
@ -1373,7 +1380,91 @@ int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Really small, fast and ugly converter(just for handhelds)
|
||||||
|
#include "global.h"
|
||||||
|
#include "limits.h"
|
||||||
|
#include "engine.h"
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
extern void Set_palette_fake_24b(T_Palette palette);
|
||||||
|
|
||||||
|
/// Really small, fast and dirty convertor(just for handhelds)
|
||||||
|
int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
|
||||||
|
{
|
||||||
|
T_Components * palette_fake24b;
|
||||||
|
int px_pos, py_pos;
|
||||||
|
int size, size_percent, size_percent_progress;
|
||||||
|
int delta, delta_old;
|
||||||
|
int i, idx, progress_counter;
|
||||||
|
char progress_str[8];
|
||||||
|
SDL_Rect pw;
|
||||||
|
|
||||||
|
Set_palette_fake_24b(palette);
|
||||||
|
palette_fake24b = palette;
|
||||||
|
|
||||||
|
Open_window(80, 30, "Progress");
|
||||||
|
pw.x = Window_pos_X;
|
||||||
|
pw.y = Window_pos_Y;
|
||||||
|
pw.w = Window_width * Menu_factor_X;
|
||||||
|
pw.h = Window_height* Menu_factor_Y;
|
||||||
|
Window_rectangle(pw.x, pw.y, pw.w, pw.h, MC_Light);
|
||||||
|
px_pos = (pw.w / (2 * Menu_factor_X)) - 10;
|
||||||
|
py_pos = (pw.h / (2 * Menu_factor_Y)) + 1;
|
||||||
|
|
||||||
|
progress_counter = 0;
|
||||||
|
size = width*height;
|
||||||
|
size_percent = size / 100;
|
||||||
|
size_percent_progress = size - 1;
|
||||||
|
|
||||||
|
while(size--)
|
||||||
|
{
|
||||||
|
//Progress counter update
|
||||||
|
if(size_percent_progress == size)
|
||||||
|
{
|
||||||
|
size_percent_progress = size - size_percent;
|
||||||
|
progress_counter++;
|
||||||
|
//Because of integer division it less of resolution and need to be checked for small files
|
||||||
|
//(maybe you can do a more smart checking or use a float values)
|
||||||
|
progress_counter = progress_counter > 100 ? 100 : progress_counter;
|
||||||
|
snprintf(progress_str, sizeof(progress_str), "%d%%", progress_counter);
|
||||||
|
Print_in_window(px_pos, py_pos, (const char *)progress_str, MC_Black, MC_Light);
|
||||||
|
|
||||||
|
SDL_LockSurface(Screen_SDL);
|
||||||
|
SDL_UpdateRect(Screen_SDL, pw.x, pw.y, pw.w, pw.h);
|
||||||
|
SDL_UnlockSurface(Screen_SDL);
|
||||||
|
}
|
||||||
|
|
||||||
|
palette = palette_fake24b;
|
||||||
|
delta = delta_old = INT_MAX;
|
||||||
|
//Searching for most suitable colour in palette
|
||||||
|
for(i=idx=0; i<256; i++)
|
||||||
|
{
|
||||||
|
//A HUGE field for optimizations lies here
|
||||||
|
|
||||||
|
//Compute delta beetween current and palette colours.
|
||||||
|
//(calling function 3 times in a row is a lame, i know)
|
||||||
|
delta = abs(source->R - palette->R) + abs(source->G - palette->G) + abs(source->B - palette->B);
|
||||||
|
|
||||||
|
if(delta < delta_old)
|
||||||
|
{
|
||||||
|
delta_old = delta;
|
||||||
|
idx = i;
|
||||||
|
//Most suitable color found - step out from loop
|
||||||
|
if(delta == 0) break;
|
||||||
|
}
|
||||||
|
palette++;
|
||||||
|
}
|
||||||
|
//Set palette color index to destination bitmap
|
||||||
|
*dest = idx;
|
||||||
|
source++;
|
||||||
|
dest++;
|
||||||
|
}
|
||||||
|
Close_window();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(__AROS__) || defined(__BEOS__) || defined(__MORPHOS__) || defined(__GP2X__) || defined(__amigaos__)
|
#if defined(__AROS__) || defined(__BEOS__) || defined(__MORPHOS__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__amigaos__)
|
||||||
// These platforms don't have realpath().
|
// These platforms don't have realpath().
|
||||||
// We use the following implementation, found in:
|
// We use the following implementation, found in:
|
||||||
// http://amiga.sourceforge.net/amigadevhelp/FUNCTIONS/GeekGadgets/realpath/ex02_realpath.c
|
// http://amiga.sourceforge.net/amigadevhelp/FUNCTIONS/GeekGadgets/realpath/ex02_realpath.c
|
||||||
@ -17,7 +17,7 @@
|
|||||||
// the path. So this implementation is limited, it's really better to
|
// the path. So this implementation is limited, it's really better to
|
||||||
// use realpath() if your platform has it.
|
// use realpath() if your platform has it.
|
||||||
|
|
||||||
#if defined(__GP2X__) || defined(__amigaos__)
|
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__amigaos__)
|
||||||
// This is a random default value ...
|
// This is a random default value ...
|
||||||
#define PATH_MAX 32768
|
#define PATH_MAX 32768
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
14
src/setup.c
14
src/setup.c
@ -44,7 +44,7 @@
|
|||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
#if defined(__GP2X__)
|
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
// This is a random default value ...
|
// This is a random default value ...
|
||||||
#define PATH_MAX 32768
|
#define PATH_MAX 32768
|
||||||
#endif
|
#endif
|
||||||
@ -115,7 +115,7 @@ void Set_data_directory(const char * program_dir, char * data_dir)
|
|||||||
#if defined(__macosx__)
|
#if defined(__macosx__)
|
||||||
strcat(data_dir,"Contents/Resources/");
|
strcat(data_dir,"Contents/Resources/");
|
||||||
// On GP2X, executable is not in bin/
|
// On GP2X, executable is not in bin/
|
||||||
#elif defined (__gp2x__)
|
#elif defined (__GP2X__) || defined (__gp2x__) || defined (__WIZ__) || defined (__CAANOO__)
|
||||||
strcat(data_dir,"share/grafx2/");
|
strcat(data_dir,"share/grafx2/");
|
||||||
// All other targets, program is in a "bin" subdirectory
|
// All other targets, program is in a "bin" subdirectory
|
||||||
#else
|
#else
|
||||||
@ -140,7 +140,7 @@ void Set_config_directory(const char * program_dir, char * config_dir)
|
|||||||
#if defined(__amigaos4__) || defined(__AROS__)
|
#if defined(__amigaos4__) || defined(__AROS__)
|
||||||
strcpy(config_dir,"PROGDIR:");
|
strcpy(config_dir,"PROGDIR:");
|
||||||
// GP2X
|
// GP2X
|
||||||
#elif defined(__GP2X__)
|
#elif defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
// On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is
|
// On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is
|
||||||
// on an internal flash chip. So, keep these settings locals.
|
// on an internal flash chip. So, keep these settings locals.
|
||||||
strcpy(config_dir,program_dir);
|
strcpy(config_dir,program_dir);
|
||||||
@ -149,9 +149,9 @@ void Set_config_directory(const char * program_dir, char * config_dir)
|
|||||||
|
|
||||||
// In priority: check root directory
|
// In priority: check root directory
|
||||||
strcpy(config_dir, program_dir);
|
strcpy(config_dir, program_dir);
|
||||||
// On all these targets except OSX and GP2X, the executable is in ./bin
|
// On all the remaining targets except OSX, the executable is in ./bin
|
||||||
#if !defined(__macosx__) && !defined(__gp2x__)
|
#if !defined(__macosx__)
|
||||||
strcat(config_dir, "../");
|
strcat(config_dir, "../");
|
||||||
#endif
|
#endif
|
||||||
strcpy(filename, config_dir);
|
strcpy(filename, config_dir);
|
||||||
strcat(filename, "gfx2.cfg");
|
strcat(filename, "gfx2.cfg");
|
||||||
@ -203,7 +203,7 @@ void Set_config_directory(const char * program_dir, char * config_dir)
|
|||||||
{
|
{
|
||||||
// Echec: on se rabat sur le repertoire de l'executable.
|
// Echec: on se rabat sur le repertoire de l'executable.
|
||||||
strcpy(config_dir,program_dir);
|
strcpy(config_dir,program_dir);
|
||||||
#if !defined(__macosx__) && !defined(__gp2x__)
|
#if defined(__macosx__)
|
||||||
strcat(config_dir, "../");
|
strcat(config_dir, "../");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -494,7 +494,7 @@ void Display_layerbar(void)
|
|||||||
x_off=Menu_bars[MENUBAR_LAYERS].Skin_width;
|
x_off=Menu_bars[MENUBAR_LAYERS].Skin_width;
|
||||||
for (current_button=0; current_button<button_number; current_button++)
|
for (current_button=0; current_button<button_number; current_button++)
|
||||||
{
|
{
|
||||||
word x_pos;
|
word x_pos=0;
|
||||||
word y_pos;
|
word y_pos;
|
||||||
word sprite_index;
|
word sprite_index;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user