Added Stylus-like field 'Uptime', 'Downtime' and 'DblClick' to Pad and GuitarHero-Pad, cleaning and beautifying a lot of code

git-svn-id: svn://localhost/tmp/palibds/trunk@153 7b02e84e-43ec-46ad-a041-a6fe5633c533
This commit is contained in:
ogronau@web.de 2008-12-27 17:26:18 +00:00
parent 3cd1bd9b20
commit f2abd2b3b3
10 changed files with 409 additions and 365 deletions

View File

@ -12,27 +12,36 @@ int main(int argc, char ** argv)
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_InitGHPad(); // Call this first before using other GH controller functions
PA_SetAutoUpdateGHPadTimes(1); // Call this if you want to use Uptime, Downtime or DblClick
PA_InitText(1,0);
PA_InitText(0,0);
PA_OutputSimpleText(1, 0, 0, "GH Button Test");
PA_OutputSimpleText(1, 0, 1, "by BassAceGold");
PA_OutputSimpleText(1, 0, 3, "For each key, we'll show\n Newpress, Held, and Released");
PA_InitGHPad(); // Call this first before using other GH controller functions
PA_OutputSimpleText(1, 0, 3, "For each key, we'll show\nNewpress, Held, and Released");
PA_OutputSimpleText(0, 0, 3, "For each key, we'll show\nDblClick, Uptime and Downtime");
// Infinite loop to keep the program running
while (1)
{
// For each key, we'll show Newpress, Held, and Released
PA_OutputText(1, 3, 7, "Green : %d-%d-%d", GHPad.Newpress.Green, GHPad.Held.Green, GHPad.Released.Green);
PA_OutputText(1, 3, 8, "Red : %d-%d-%d", GHPad.Newpress.Red, GHPad.Held.Red, GHPad.Released.Red);
PA_OutputText(1, 3, 9, "Yellow : %d-%d-%d", GHPad.Newpress.Yellow, GHPad.Held.Yellow, GHPad.Released.Yellow);
PA_OutputText(1, 3, 10, "Blue : %d-%d-%d", GHPad.Newpress.Blue, GHPad.Held.Blue, GHPad.Released.Blue);
PA_OutputText(1, 3, 12, "Anykey : %d-%d-%d", GHPad.Newpress.Anykey, GHPad.Held.Anykey, GHPad.Released.Anykey);
PA_OutputText(1, 3, 7, "Green : %d-%d-%d", GHPad.Newpress.Green, GHPad.Held.Green, GHPad.Released.Green);
PA_OutputText(1, 3, 8, "Red : %d-%d-%d", GHPad.Newpress.Red, GHPad.Held.Red, GHPad.Released.Red);
PA_OutputText(1, 3, 9, "Yellow : %d-%d-%d", GHPad.Newpress.Yellow, GHPad.Held.Yellow, GHPad.Released.Yellow);
PA_OutputText(1, 3, 10, "Blue : %d-%d-%d", GHPad.Newpress.Blue, GHPad.Held.Blue, GHPad.Released.Blue);
// For each key, we'll show DblClick, Uptime and Downtime
PA_OutputText(0, 3, 7, "Green : %d-%d-%d ", GHPad.DblClick.Green, GHPad.Uptime.Green, GHPad.Downtime.Green);
PA_OutputText(0, 3, 8, "Red : %d-%d-%d ", GHPad.DblClick.Red, GHPad.Uptime.Red, GHPad.Downtime.Red);
PA_OutputText(0, 3, 9, "Yellow : %d-%d-%d ", GHPad.DblClick.Yellow, GHPad.Uptime.Yellow, GHPad.Downtime.Yellow);
PA_OutputText(0, 3, 10, "Blue : %d-%d-%d ", GHPad.DblClick.Blue, GHPad.Uptime.Blue, GHPad.Downtime.Blue);
PA_OutputText(0, 3, 12, "Anykey : %d-%d-%d ", GHPad.DblClick.Anykey, GHPad.Uptime.Anykey, GHPad.Downtime.Anykey);
if(GHPad.Held.Anykey) PA_OutputText(1, 3, 15, "anykeyworks");
else PA_OutputText(1, 3, 15, " ");
if(PA_DetectGHPad()) PA_OutputText(1, 3, 17, "Grip is inserted");
if (PA_DetectGHPad()) PA_OutputText(1, 3, 17, "Grip is inserted");
else PA_OutputText(1, 3, 17, " ");

View File

@ -7,43 +7,52 @@
#include <PA9.h> // Include for PA_Lib
char text[200]; // This will be our text...
// Function: main()
int main(int argc, char ** argv)
{
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_SetAutoUpdatePadTimes(1); // Call this if you want to use Uptime, Downtime or DblClick
PA_InitText(1, 0); // Initialise the text system on the top screen
PA_InitText(1, 0);
PA_InitText(0, 0);
PA_OutputSimpleText(1, 0, 3, "For each key, we'll show Newpress, Held, and Released");
PA_OutputSimpleText(1, 0, 3, "For each key, we'll show\nNewpress, Held, and Released");
PA_OutputSimpleText(0, 0, 3, "For each key, we'll show\nDblClick, Uptime and Downtime");
// Infinite loop to keep the program running
while (1)
{
// For each key, we'll show Newpress, Held, and Released
PA_OutputText(1, 3, 7, "Up : %d-%d-%d", Pad.Newpress.Up, Pad.Held.Up, Pad.Released.Up);
PA_OutputText(1, 3, 8, "Down : %d-%d-%d", Pad.Newpress.Down, Pad.Held.Down, Pad.Released.Down);
PA_OutputText(1, 3, 9, "Left : %d-%d-%d", Pad.Newpress.Left, Pad.Held.Left, Pad.Released.Left);
PA_OutputText(1, 3, 10, "Right : %d-%d-%d", Pad.Newpress.Right, Pad.Held.Right, Pad.Released.Right);
PA_OutputText(1, 3, 11, "A : %d-%d-%d", Pad.Newpress.A, Pad.Held.A, Pad.Released.A);
PA_OutputText(1, 3, 12, "B : %d-%d-%d", Pad.Newpress.B, Pad.Held.B, Pad.Released.B);
PA_OutputText(1, 3, 13, "X : %d-%d-%d", Pad.Newpress.X, Pad.Held.X, Pad.Released.X);
PA_OutputText(1, 3, 14, "Y : %d-%d-%d", Pad.Newpress.Y, Pad.Held.Y, Pad.Released.Y);
PA_OutputText(1, 3, 15, "L : %d-%d-%d", Pad.Newpress.L, Pad.Held.L, Pad.Released.L);
PA_OutputText(1, 3, 16, "R : %d-%d-%d", Pad.Newpress.R, Pad.Held.R, Pad.Released.R);
PA_OutputText(1, 3, 17, "Start : %d-%d-%d", Pad.Newpress.Start, Pad.Held.Start, Pad.Released.Start);
// For each key, we'll show Newpress, Held, and Released
PA_OutputText(1, 3, 7, "Up : %d-%d-%d", Pad.Newpress.Up, Pad.Held.Up, Pad.Released.Up);
PA_OutputText(1, 3, 8, "Down : %d-%d-%d", Pad.Newpress.Down, Pad.Held.Down, Pad.Released.Down);
PA_OutputText(1, 3, 9, "Left : %d-%d-%d", Pad.Newpress.Left, Pad.Held.Left, Pad.Released.Left);
PA_OutputText(1, 3, 10, "Right : %d-%d-%d", Pad.Newpress.Right, Pad.Held.Right, Pad.Released.Right);
PA_OutputText(1, 3, 11, "A : %d-%d-%d", Pad.Newpress.A, Pad.Held.A, Pad.Released.A);
PA_OutputText(1, 3, 12, "B : %d-%d-%d", Pad.Newpress.B, Pad.Held.B, Pad.Released.B);
PA_OutputText(1, 3, 13, "X : %d-%d-%d", Pad.Newpress.X, Pad.Held.X, Pad.Released.X);
PA_OutputText(1, 3, 14, "Y : %d-%d-%d", Pad.Newpress.Y, Pad.Held.Y, Pad.Released.Y);
PA_OutputText(1, 3, 15, "L : %d-%d-%d", Pad.Newpress.L, Pad.Held.L, Pad.Released.L);
PA_OutputText(1, 3, 16, "R : %d-%d-%d", Pad.Newpress.R, Pad.Held.R, Pad.Released.R);
PA_OutputText(1, 3, 17, "Start : %d-%d-%d", Pad.Newpress.Start, Pad.Held.Start, Pad.Released.Start);
PA_OutputText(1, 3, 18, "Select : %d-%d-%d", Pad.Newpress.Select, Pad.Held.Select, Pad.Released.Select);
PA_OutputText(1, 3, 20, "Anykey : %d-%d-%d", Pad.Newpress.Anykey, Pad.Held.Anykey, Pad.Released.Anykey);
PA_OutputText(1, 3, 20, "Anykey : %d-%d-%d", Pad.Newpress.Anykey, Pad.Held.Anykey, Pad.Released.Anykey); // Any key !
// For each key, we'll show DblClick, Uptime and Downtime
PA_OutputText(0, 3, 7, "Up : %d-%d-%d ", Pad.DblClick.Up, Pad.Uptime.Up, Pad.Downtime.Up);
PA_OutputText(0, 3, 8, "Down : %d-%d-%d ", Pad.DblClick.Down, Pad.Uptime.Down, Pad.Downtime.Down);
PA_OutputText(0, 3, 9, "Left : %d-%d-%d ", Pad.DblClick.Left, Pad.Uptime.Left, Pad.Downtime.Left);
PA_OutputText(0, 3, 10, "Right : %d-%d-%d ", Pad.DblClick.Right, Pad.Uptime.Right, Pad.Downtime.Right);
PA_OutputText(0, 3, 11, "A : %d-%d-%d ", Pad.DblClick.A, Pad.Uptime.A, Pad.Downtime.A);
PA_OutputText(0, 3, 12, "B : %d-%d-%d ", Pad.DblClick.B, Pad.Uptime.B, Pad.Downtime.B);
PA_OutputText(0, 3, 13, "X : %d-%d-%d ", Pad.DblClick.X, Pad.Uptime.X, Pad.Downtime.X);
PA_OutputText(0, 3, 14, "Y : %d-%d-%d ", Pad.DblClick.Y, Pad.Uptime.Y, Pad.Downtime.Y);
PA_OutputText(0, 3, 15, "L : %d-%d-%d ", Pad.DblClick.L, Pad.Uptime.L, Pad.Downtime.L);
PA_OutputText(0, 3, 16, "R : %d-%d-%d ", Pad.DblClick.R, Pad.Uptime.R, Pad.Downtime.R);
PA_OutputText(0, 3, 17, "Start : %d-%d-%d ", Pad.DblClick.Start, Pad.Uptime.Start, Pad.Downtime.Start);
PA_OutputText(0, 3, 18, "Select : %d-%d-%d ", Pad.DblClick.Select, Pad.Uptime.Select, Pad.Downtime.Select);
PA_OutputText(0, 3, 20, "Anykey : %d-%d-%d ", Pad.DblClick.Anykey, Pad.Uptime.Anykey, Pad.Downtime.Anykey);
PA_WaitForVBL();
}

View File

@ -7,6 +7,13 @@ extern "C" {
#include "PA9.h"
// Keyboard defines
#define PA_RIEN 0 // Si y'a rien, faudra faire comme si on appuye sur rien
#define PA_BACKSPACE 1 // On va dire que la touche backspace a pour valeur 1...
#define PA_CAPS 2 // 2 pour CAPS
#define PA_TAB 3 // tab...
#define PA_SHIFT 4 // etc
#define PA_ENTER '\n' // 3 pour Enter
extern u8 keyb_screen;
@ -70,14 +77,14 @@ void PA_InitKeyboard(u8 bg_number);
/*!
\def PA_InitCustomKeyboard(bg_number, keyb_custom)
\brief
\~english Initialise a custom Keyboard on a given background.
\~french Initialiser un clavier perso sur un fond donné
\~english Initialise a custom Keyboard on a given background.
\~french Initialiser un clavier perso sur un fond donné
\~\param bg_number
\~english Background number (0-3)
\~french Numéro du fond que l'on veut tourner (0-3)
\~\param keyb_custom
\~english Custom Keyboard name, converted as EasyBg
\~french Claviet perso, converti comme EasyBg
\~french Claviet perso, converti comme EasyBg
*/
#define PA_InitCustomKeyboard(bg_number, keyb_custom) {\
PA_LoadBgPal(keyb_screen, bg_number, (void*)keyb_custom##_Pal);\
@ -100,7 +107,7 @@ char PA_CheckKeyboard(void);
/*!
\fn extern inline void PA_ScrollKeyboardX(s16 x)
\brief
\~english Set the Keyboard's X position
\~english Set the Keyboard's X position
\~french Placer le Clavier à la position X
\~\param x
\~english X position...
@ -115,7 +122,7 @@ extern inline void PA_ScrollKeyboardX(s16 x) {
/*!
\fn extern inline void PA_ScrollKeyboardY(s16 y)
\brief
\~english Set the Keyboard's Y position
\~english Set the Keyboard's Y position
\~french Placer le Clavier à la position Y
\~\param y
\~english Y position...
@ -130,7 +137,7 @@ extern inline void PA_ScrollKeyboardY(s16 y) {
/*!
\fn extern inline void PA_ScrollKeyboardXY(s16 x, s16 y)
\brief
\~english Set the Keyboard's position
\~english Set the Keyboard's position
\~french Placer le Clavier à une position donnée
\~\param x
\~english X position...
@ -158,7 +165,7 @@ extern inline void PA_ScrollKeyboardXY(s16 x, s16 y) {
/*!
\fn extern inline void PA_KeyboardIn(s16 x, s16 y)
\brief
\~english Make the keyboard enter to position (x, y), scrolling from the bottom of the screen
\~english Make the keyboard enter to position (x, y), scrolling from the bottom of the screen
\~french Faire entrer le clavier à la position (x, y) en glissant depuis le bas de l'écran
\~\param x
\~english X position...
@ -167,14 +174,14 @@ extern inline void PA_ScrollKeyboardXY(s16 x, s16 y) {
\~english Y position...
\~french Position Y
*/
extern inline void PA_KeyboardIn(s16 x, s16 y){ // Faire rentrer le clavier...
extern inline void PA_KeyboardIn(s16 x, s16 y){ // Faire rentrer le clavier...
s16 i;
PA_ScrollKeyboardXY(x, 192); // On le sort et met en X. Puis on fait glisser...
for (i = 192; i > y; i-=8){
PA_ScrollKeyboardY(i);
PA_WaitForVBL();
}
PA_ScrollKeyboardY(y); // On amène pile au bon y...
PA_ScrollKeyboardY(y); // On amène pile au bon y...
}
@ -184,7 +191,7 @@ s16 i;
\~english Make the keyboard scroll out
\~french Faire sortir le clavier
*/
extern inline void PA_KeyboardOut(void){ // Faire sortir le clavier...
extern inline void PA_KeyboardOut(void){ // Faire sortir le clavier...
s16 i;
PA_EraseLastKey(); // Efface s'il reste une touche pressée...
for (i = Keyboard.ScrollY; i < 200; i+=8){
@ -208,7 +215,7 @@ void PA_ReloadKeyboardCol(void);
/*!
\fn extern inline void PA_SetKeyboardColor(u8 color1, u8 color2)
\brief
\~english You can change the color used by the keyboard...
\~english You can change the color used by the keyboard...
\~french On peut changer la couleur du clavier !
\~\param color1
\~english Normal color, 0 for blue, 1 for red, 2 for green
@ -234,7 +241,7 @@ extern inline void PA_SetKeyboardColor(u8 color1, u8 color2){
*/
extern inline void PA_SetKeyboardScreen(u8 screen){
keyb_screen = screen; // Top screen
}
}
/** @} */ // end of Keyboard

View File

@ -12,77 +12,52 @@ extern "C" {
Update the keys and stylus inputs
*/
//////////////////////////////////////////////////////////////////////
// Système pour les touches
// Système pour les touches
//////////////////////////////////////////////////////////////////////
// Keyboard defines
#define PA_BACKSPACE 1 // On va dire que la touche backspace a pour valeur 1...
#define PA_CAPS 2 // 2 pour CAPS
#define PA_ENTER '\n' // 3 pour Enter
#define PA_SHIFT 4 // etc
#define PA_RIEN 0 // Si y'a rien, faudra faire comme si on appuye sur rien
#define PA_TAB 3 // tab...
// Stylus and Pad definitions, will be used by the arm7 to auto-update positions...
typedef struct {
u8 A, B, X, Y, L, R, Up, Down, Right, Left, Start, Select, Anykey;
} PA_Pad;
extern u16 CompletePad, ExPad;
extern u8 pa_update_padtimes;
typedef struct {
PA_Pad Held, Released, Newpress; // Pressed si on appuye, Held si on garde appuyé, et Released si on relache
} Pads;
u8 A, B, X, Y, L, R, Up, Down, Right, Left, Start, Select, Anykey;
} PA_Pad_TruthValues_Struct;
typedef struct {
u8 Held, Released, Newpress, Newpress0;
s16 X, Y, altX, altY, Pressure, Vx, Vy, oldVx, oldVy, Downtime, Uptime, DblClick;
} PA_Stylus;
s32 A, B, X, Y, L, R, Up, Down, Right, Left, Start, Select, Anykey;
} PA_Pad_IntegerValues_Struct;
typedef struct {
PA_Pad_TruthValues_Struct Held, Released, Newpress, DblClick;
PA_Pad_IntegerValues_Struct Uptime, Downtime;
} PA_Pad_Struct;
typedef struct {
u8 Held, Released, Newpress, DblClick;
s16 Pressure, X, Y, Vx, Vy, altX, altY, oldVx, oldVy;
s32 Downtime, Uptime;
} PA_Stylus_Struct;
extern PA_Stylus Stylus;
extern PA_Stylus_Struct Stylus;
extern Pads Pad;
extern PA_Pad* PadPointer;
extern PA_Pad_Struct Pad;
// Structure pour les sprites que l'on déplace...
// Structure pour les sprites que l'on déplace...
typedef struct {
u8 Moving;
u8 Sprite;
s16 X, Y, Vx, Vy, NextVx, NextVy;
u8 Time; // Si trop longtemps sans bouger le sprite, il décroche...
u8 Time; // Si trop longtemps sans bouger le sprite, il décroche...
} PA_movingsprite;
extern PA_movingsprite PA_MovedSprite;
extern u8 PA_MoveSpriteType;
extern u8 PA_MoveSpriteType;
// Button info
/*
#define PA_UpdatePad() ExPad = CompletePad;\
CompletePad = ~(BUTTONS + (((IPC->buttons)&3) << 10));\
UPDATEPAD(Pad.Held, CompletePad);\
UPDATEPAD(Pad.Released, (ExPad & (~CompletePad)));\
UPDATEPAD(Pad.Newpress, (CompletePad & (~ExPad)));
#define PA_UpdateStylus() u8 temp = ((~IPC->buttons) >> 6) & 1;\
Stylus.Newpress = temp & (!Stylus.Held);\
Stylus.Released = (!temp) & Stylus.Held;\
Stylus.Held = temp;\
if(Stylus.Held)Stylus.altX = ((IPC->touchX - 0x0113) / 14);\
if(Stylus.Held)Stylus.altY = ((IPC->touchY - 0x00E0) / 19);\
if(Stylus.Held)Stylus.X = IPC->touchXpx;\
if(Stylus.Held)Stylus.Y = IPC->touchYpx;\
if(Stylus.Held)Stylus.Pressure = (((Stylus.X * IPC->touchZ2) >> 6) / IPC->touchZ1) - (Stylus.X >> 6);
*/
//#define BUTTON_AND 16384
//#define BUTTON_OR 0
/** @defgroup Keys Key input system
* Check which keys are pressed...
* @{
@ -93,17 +68,28 @@ extern u8 PA_MoveSpriteType;
/*! \fn void PA_UpdatePad(void)
\brief
\~english Update the Keypad, use it once per frame (in the VBL for example). You can then retrieve the held down keys with Pad.Held.A (or Up, Down...), Newly pressed keys with Pad.Newpress.R, and the just released keys with Pad.Released.Up...
\~french Permet de mettre à jour les touches appuyées. A utilisé une fois par frame (genre dans le vbl). On a ensuite accès aux touches pressées avec Pad.Held.A (ou Up, Down, L...), aux touches nouvellement pressées avec Pad.Newpress.R, et aux touches tout juste relachées avec Pad.Released.Up...
\~french Permet de mettre à jour les touches appuyées. A utilisé une fois par frame (genre dans le vbl). On a ensuite accès aux touches pressées avec Pad.Held.A (ou Up, Down, L...), aux touches nouvellement pressées avec Pad.Newpress.R, et aux touches tout juste relachées avec Pad.Released.Up...
*/
void PA_UpdatePad(void);
/*! \fn extern inline void PA_SetAutoUpdatePadTimes(u8 on)
\brief
\~english Decides if the number of frames each key is pressed/not pressed is automatically evaluated. You can then retrieve the number of frames each key is pressed with Pad.Downtime.A (or Up, Down...), the number of frames each key is not pressed with Pad.Uptime.A (...), and if any key was pressed two times fast enough with Pad.DblClick.A (...)
\~\param on
\~english 1 for on, 0 for off
*/
extern inline void PA_SetAutoUpdatePadTimes(u8 on)
{
pa_update_padtimes = on;
}
/*! \fn void PA_UpdateStylus(void)
\brief
\~english Update the Stylus position. You can then check if the stylus is current in use (Stylus.Held), newly pressed (Stylus.Newpress), or released (Stylus.Released), and get it's position (Stylus.X, Stylus.Y).
\~french Mettre à jour la position du stylet. On peut vérifier si le stylet est actuellement sur l'écran (Stylus.Held), tout just appuyé (Stylus.Newpress), ou relaché (Stylus.Released), et obtenir sa position (Stylus.X, Stylus.Y).
\~french Mettre à jour la position du stylet. On peut vérifier si le stylet est actuellement sur l'écran (Stylus.Held), tout just appuyé (Stylus.Newpress), ou relaché (Stylus.Released), et obtenir sa position (Stylus.X, Stylus.Y).
*/
void PA_UpdateStylus(void);
@ -112,10 +98,10 @@ void PA_UpdateStylus(void);
/*! \fn u8 PA_MoveSpritePix(u8 sprite)
\brief
\~english Move a sprite according to the stylus's position, only if you touch a sprite's pixel. This is similar to PA_MoveSprite, but slightly slower and requires PA_InitSpriteDraw(screen, sprite) before. The sprite will be 'hooked' if the stylus passes over it, and then they'll be linked together. Returns 1 if the sprite is moved. You can also get information from PA_MovedSprite.Moving (1 if you are moving a sprite), .Sprite (sprite moved), .X (X position of the top left corner of the sprite), .Y (Y position of the top left corner of the sprite), .Vx (horizontal speed ! useful if you want to make the sprite continue to move when you release the stylus...), and .Vy
\~french Déplacer un sprite en fonction du stylet, avec détection au pixel pret. Ceci est comme PA_MoveSprite, mais un peu plus lent, et nécessite PA_InitSpriteDraw(screen, sprite). Le sprite sera accroché si le stylet passe aud-dessus, puis il sera déplacé en fonction... Donne 1 si on a déplacé ce sprite, sinon 0. On peut ensuite récupérer des infos avec PA_MovedSprite.Moving (1 si on déplace un sprite), .Sprite (numéro du sprite déplacé), .X (position X du coin sup gauche du sprite), .Y (position Y du point sup gauche du sprite déplacé), .Vx (vitesse horizontale du sprite déplacé !! Utile si l'on veut que le sprite continue à se déplacer par la suite...), et .Vy
\~french Déplacer un sprite en fonction du stylet, avec détection au pixel pret. Ceci est comme PA_MoveSprite, mais un peu plus lent, et nécessite PA_InitSpriteDraw(screen, sprite). Le sprite sera accroché si le stylet passe aud-dessus, puis il sera déplacé en fonction... Donne 1 si on a déplacé ce sprite, sinon 0. On peut ensuite récupérer des infos avec PA_MovedSprite.Moving (1 si on déplace un sprite), .Sprite (numéro du sprite déplacé), .X (position X du coin sup gauche du sprite), .Y (position Y du point sup gauche du sprite déplacé), .Vx (vitesse horizontale du sprite déplacé !! Utile si l'on veut que le sprite continue à se déplacer par la suite...), et .Vy
\~\param sprite
\~english Object number in the sprite system
\~french Numéro de l'objet dans le systeme de sprite
\~french Numéro de l'objet dans le systeme de sprite
*/
u8 PA_MoveSpritePix(u8 sprite);
@ -128,10 +114,10 @@ u8 PA_MoveSpritePix(u8 sprite);
/*! \def PA_MoveSprite(sprite)
\brief
\~english Move a sprite according to the stylus's position. The sprite will be 'hooked' if the stylus passes over it, and then they'll be linked together. Returns 1 if the sprite is moved. You can also get information from PA_MovedSprite.Moving (1 if you are moving a sprite), .Sprite (sprite moved), .X (X position of the center of the sprite), .Y (Y position of the center of the sprite), .Vx (horizontal speed ! useful if you want to make the sprite continue to move when you release the stylus...), and .Vy
\~french Déplacer un sprite en fonction du stylet. Le sprite sera accroché si le stylet passe aud-dessus, puis il sera déplacé en fonction... Donne 1 si on a déplacé ce sprite, sinon 0. On peut ensuite récupérer des infos avec PA_MovedSprite.Moving (1 si on déplace un sprite), .Sprite (numéro du sprite déplacé), .X (position X du centre du sprite), .Y (position Y du centre du sprite déplacé), .Vx (vitesse horizontale du sprite déplacé !! Utile si l'on veut que le sprite continue à se déplacer par la suite...), et .Vy
\~french Déplacer un sprite en fonction du stylet. Le sprite sera accroché si le stylet passe aud-dessus, puis il sera déplacé en fonction... Donne 1 si on a déplacé ce sprite, sinon 0. On peut ensuite récupérer des infos avec PA_MovedSprite.Moving (1 si on déplace un sprite), .Sprite (numéro du sprite déplacé), .X (position X du centre du sprite), .Y (position Y du centre du sprite déplacé), .Vx (vitesse horizontale du sprite déplacé !! Utile si l'on veut que le sprite continue à se déplacer par la suite...), et .Vy
\~\param sprite
\~english Object number in the sprite system
\~french Numéro de l'objet dans le systeme de sprite
\~french Numéro de l'objet dans le systeme de sprite
*/
#define PA_MoveSprite(sprite) PA_MoveSpriteEx(PA_Screen, sprite, PA_GetSpriteLx(0, sprite), PA_GetSpriteLy(0, sprite))
@ -140,13 +126,13 @@ u8 PA_MoveSpritePix(u8 sprite);
/*! \fn u8 PA_MoveSpriteEx(u8 screen, u8 sprite, u8 lx, u8 ly)
\brief
\~english Move a sprite according to the stylus's position. See PA_MoveSprite for more details... The difference is that here you chose the sprite dimension (lx and ly), which is useful if the sprite is smaller than the DS standard sizes... (for example 20x20...). This will also limit the 'hooking' distance
\~french Déplacer un sprite en fonction du stylet. Voir PA_MoveSprite pour plus de détails. La différence est qu'ici on précise la largeur et la hauteur du sprite, utile si le sprite ne fait pas vraiment la meme taille que la taille standard DS (genre si c'est un sprite de 20x20). Ceci limitera donc aussi la distance d'accrochage
\~french Déplacer un sprite en fonction du stylet. Voir PA_MoveSprite pour plus de détails. La différence est qu'ici on précise la largeur et la hauteur du sprite, utile si le sprite ne fait pas vraiment la meme taille que la taille standard DS (genre si c'est un sprite de 20x20). Ceci limitera donc aussi la distance d'accrochage
\~\param screen
\~english On what screen to do it
\~french Sur quel écran le faire...
\~french Sur quel écran le faire...
\~\param sprite
\~english Object number in the sprite system
\~french Numéro de l'objet dans le systeme de sprite
\~french Numéro de l'objet dans le systeme de sprite
\~\param lx
\~english Sprite length
\~french Largeur du sprite
@ -160,10 +146,10 @@ u8 PA_MoveSpriteEx(u8 screen, u8 sprite, u8 lx, u8 ly);
/*! \fn u8 PA_MoveSpriteDistance(u8 sprite, u8 distance)
\brief
\~english Move a sprite according to the stylus's position. See PA_MoveSprite for more details... The difference is that here you chose the hooking distance in pixels
\~french Déplacer un sprite en fonction du stylet. Voir PA_MoveSprite pour plus de détails. La différence est qu'ici on précise la distance d'accrochage, en pixels
\~french Déplacer un sprite en fonction du stylet. Voir PA_MoveSprite pour plus de détails. La différence est qu'ici on précise la distance d'accrochage, en pixels
\~\param sprite
\~english Object number in the sprite system
\~french Numéro de l'objet dans le systeme de sprite
\~french Numéro de l'objet dans le systeme de sprite
\~\param distance
\~english Hooking distance
\~french Distance d'accrochage
@ -178,7 +164,7 @@ extern inline u8 PA_MoveSpriteDistance(u8 sprite, u8 distance){
/*! \fn void PA_UpdateMoveSprite(void)
\brief
\~english Update the moving sprite info. If you don't put this in the VBL (it already is in PA_InitVBL), then if you stop moving around a sprite, it might not be able to pick up other sprites...
\~french Met à jour les infos de déplacement de sprites... Si on ne met pas ca dans le VBL (c'est déjà dans PA_InitVBL), alors on risque de ne pas pouvoir déplacer d'autre sprite...
\~french Met à jour les infos de déplacement de sprites... Si on ne met pas ca dans le VBL (c'est déjà dans PA_InitVBL), alors on risque de ne pas pouvoir déplacer d'autre sprite...
*//*
extern inline void PA_UpdateMoveSprite(void) {
@ -193,21 +179,21 @@ extern inline void PA_UpdateMoveSprite(void) {
/*! \fn extern inline u8 PA_SpriteStylusOverEx(u8 sprite, u8 lx, u8 ly)
\brief
\~english Check if the stylus position is over a given sprite (stylus pressed or not)
\~french Vérifie si le stylet est placé au-dessus d'un sprite donné (que le stylet touche l'écran ou non)
\~french Vérifie si le stylet est placé au-dessus d'un sprite donné (que le stylet touche l'écran ou non)
\~\param sprite
\~english Sprite number in the sprite system
\~french Numéro du sprite dans le systeme de sprite
\~french Numéro du sprite dans le systeme de sprite
\~\param lx
\~english Wideness
\~french Largeur
\~\param ly
\~english Height
\~french Hauter
\~french Hauter
*/
extern inline u8 PA_SpriteStylusOverEx(u8 sprite, u8 lx, u8 ly){
s16 x = PA_GetSpriteX(PA_Screen, sprite); if(x > 256) x-= 512;
s16 y = PA_GetSpriteY(PA_Screen, sprite); if(y > 192) y-= 256;
s16 y = PA_GetSpriteY(PA_Screen, sprite); if(y > 192) y-= 256;
return ((Stylus.X > x) && (Stylus.X < x + lx)&& (Stylus.Y > y) && (Stylus.Y < y + ly));
}
@ -216,17 +202,17 @@ extern inline u8 PA_SpriteStylusOverEx(u8 sprite, u8 lx, u8 ly){
/*! \fn extern inline u8 PA_SpriteTouchedEx(u8 sprite, u8 lx, u8 ly)
\brief
\~english Check if a given sprite is touched. Returns 1 if touched... You can chose the width and height around the sprite
\~french Vérifie si l'on touche un sprite donné. Renvoie 1 si touché... On peut choisir la hauteur et la largeur autour du sprite
\~french Vérifie si l'on touche un sprite donné. Renvoie 1 si touché... On peut choisir la hauteur et la largeur autour du sprite
\~\param sprite
\~english Sprite number in the sprite system
\~french Numéro du sprite dans le systeme de sprite
\~french Numéro du sprite dans le systeme de sprite
\~\param lx
\~english Wideness
\~french Largeur
\~\param ly
\~english Height
\~french Hauter
\~french Hauter
*/
extern inline u8 PA_SpriteTouchedEx(u8 sprite, u8 lx, u8 ly){
return (Stylus.Held && PA_SpriteStylusOverEx(sprite, lx, ly));
@ -237,10 +223,10 @@ extern inline u8 PA_SpriteTouchedEx(u8 sprite, u8 lx, u8 ly){
/*! \fn extern inline u8 PA_SpriteTouched(u8 sprite)
\brief
\~english Check if a given sprite is touched. Returns 1 if touched...
\~french Vérifie si l'on touche un sprite donné. Renvoie 1 si touché...
\~french Vérifie si l'on touche un sprite donné. Renvoie 1 si touché...
\~\param sprite
\~english Sprite number in the sprite system
\~french Numéro du sprite dans le systeme de sprite
\~french Numéro du sprite dans le systeme de sprite
*/
extern inline u8 PA_SpriteTouched(u8 sprite) {
return PA_SpriteTouchedEx(sprite, PA_GetSpriteLx(PA_Screen, sprite), PA_GetSpriteLy(PA_Screen, sprite));
@ -251,10 +237,10 @@ extern inline u8 PA_SpriteTouched(u8 sprite) {
/*! \fn extern inline u8 PA_SpriteStylusOver(u8 sprite)
\brief
\~english Check if the stylus position is over a given sprite (stylus pressed or not)
\~french Vérifie si le stylet est placé au-dessus d'un sprite donné (que le stylet touche l'écran ou non)
\~french Vérifie si le stylet est placé au-dessus d'un sprite donné (que le stylet touche l'écran ou non)
\~\param sprite
\~english Sprite number in the sprite system
\~french Numéro du sprite dans le systeme de sprite
\~french Numéro du sprite dans le systeme de sprite
*/
extern inline u8 PA_SpriteStylusOver(u8 sprite) {
return PA_SpriteStylusOverEx(sprite, PA_GetSpriteLx(PA_Screen, sprite), PA_GetSpriteLy(PA_Screen, sprite));
@ -269,7 +255,7 @@ extern inline u8 PA_SpriteTouchedPix(u8 sprite){
if (spritey >= 220) spritey -=256; // normalize the y coordinate...
u16 x = Stylus.X - spritex;
u16 y = Stylus.Y - spritey;
return (Stylus.Held && (x < spriteanims[PA_Screen][sprite].lx) && (y < spriteanims[PA_Screen][sprite].ly) && PA_GetSpritePixel(PA_Screen, sprite, x, y));
}
@ -281,26 +267,26 @@ extern inline u8 PA_Sprite16cTouchedPix(u8 sprite){
if (spritey >= 220) spritey -=256; // normalize the y coordinate...
u16 x = Stylus.X - spritex;
u16 y = Stylus.Y - spritey;
return (Stylus.Held && (x < spriteanims[PA_Screen][sprite].lx) && (y < spriteanims[PA_Screen][sprite].ly) && PA_GetSprite16cPixel(PA_Screen, sprite, x, y));
}
/*! \def PA_StylusInZone(x1, y1, x2, y2)
\brief
\~english Check if the stylus is in a given zone... Returns 1 if yes, 0 if not
\~french Vérifie si le stylet est dans une zone délimitée donnée... Renvoie 1 si oui, 0 sinon
\~french Vérifie si le stylet est dans une zone délimitée donnée... Renvoie 1 si oui, 0 sinon
\~\param x1
\~english X value of the upper left corner
\~french Valeur X du coin supérieur gauche
\~french Valeur X du coin supérieur gauche
\~\param y1
\~english Y value of the upper left corner
\~french Valeur Y du coin supérieur gauche
\~french Valeur Y du coin supérieur gauche
\~\param x2
\~english X value of the lower right corner
\~french Valeur X du coin inférieur droit
\~french Valeur X du coin inférieur droit
\~\param y2
\~english Y value of the lower right corner
\~french Valeur Y du coin inférieur droit
\~french Valeur Y du coin inférieur droit
*/
#define PA_StylusInZone(x1, y1, x2, y2) ((Stylus.X>=x1)&&(Stylus.Y>=y1)&&(Stylus.X<x2)&&(Stylus.Y<y2))

View File

@ -33,52 +33,65 @@ extern "C" {
#define BUTTON_RED 32
#define BUTTON_GREEN 64
#define UPDATEGHPAD(type, pad) type.Green = (pad & BUTTON_GREEN)>>6;\
type.Red = (pad & BUTTON_RED) >> 5;\
type.Yellow = (pad & BUTTON_YELLOW) >> 4;\
type.Blue = (pad & BUTTON_BLUE) >> 3;\
type.Anykey = (!(!((pad&120))));
extern u16 GHCompletePad, GHExPad;
extern u8 gh_update_padtimes;
typedef struct {
u8 Green, Red, Yellow, Blue, Anykey;
} GH_Buttons;
u8 Green, Red, Yellow, Blue, Anykey;
} GH_Buttons_TruthValues_Struct;
typedef struct {
GH_Buttons Held, Released, Newpress; // Pressed si on appuye, Held si on garde appuyé, et Released si on relache
} GH_Pad;
extern GH_Pad GHPad;
extern u16 GHCompletePad, GHExPad, GHTempPad;
s32 Green, Red, Yellow, Blue, Anykey;
} GH_Buttons_IntegerValues_Struct;
typedef struct {
GH_Buttons_TruthValues_Struct Held, Released, Newpress, DblClick;
GH_Buttons_IntegerValues_Struct Uptime, Downtime;
} GH_Pad_Struct;
extern GH_Pad_Struct GHPad;
/*! \fn bool PA_DetectGHPad(void)
\brief
\~english Check to see if there's a Guitar Hero pad inserted in slot-2. Returns 1 if there is or 0 if there isn't.
\~french
\~french
*/
bool PA_DetectGHPad(void);
/*! \fn bool PA_InitGHPad(void)
\brief
\~english Set up the Guitar Hero pad for use. Returns a 1 if initialization was successful, or a 0 if it wasn't.
\~french
\~french
*/
bool PA_InitGHPad(void);
/*! \fn void PA_DeInitGHPad(void)
\brief
\~english De-initialize the Guitar Hero pad. It's recommended to call this when you won't be using the GH pad anymore.
\~french
\~french
*/
void PA_DeInitGHPad(void);
/*! \fn void PA_UpdateGHPad(void)
\brief
\~english Update the values of GHPad. But NOTE: you won't need it if you used PA_InitGHPad as it's done automatically every Vblank.
\~french
\~french
*/
void PA_UpdateGHPad(void);
/*! \fn extern inline void PA_SetAutoUpdateGHPadTimes(u8 on)
\brief
\~english Decides if the number of frames each key is pressed/not pressed is automatically evaluated. You can then retrieve the number of frames each key is pressed with Pad.Downtime.Green (or Red...), the number of frames each key is not pressed with Pad.Uptime.Green (...), and if any key was pressed two times fast enough with Pad.DblClick.Green (...)
\~\param on
\~english 1 for on, 0 for off
*/
extern inline void PA_SetAutoUpdateGHPadTimes(u8 on)
{
gh_update_padtimes = on;
}
#define PADDLE_LOW (*(vuint8*)0x0A000000)
@ -94,28 +107,28 @@ extern PaddleInfo Paddle;
/*! \fn bool PA_DetectPaddle(void)
\brief
\~english Check to see if there's a Taito Paddle inserted in slot-2. Return 1 if there is or 0 if there isn't.
\~french
\~french
*/
bool PA_DetectPaddle(void);
/*! \fn bool PA_InitPaddle(void)
\brief
\~english Set up the Taito Paddle for use. Returns a 1 if initialization was successful, or a 0 if it wasn't.
\~french
\~french
*/
bool PA_InitPaddle(void);
/*! \fn void PA_DeInitPaddle(void)
\brief
\~english De-initialize the Taito Paddle. It's recommended to call this when you won't be using the paddle anymore.
\~french
\~french
*/
void PA_DeInitPaddle(void);
/*! \fn void PA_UpdatePaddle(void)
\brief
\~english Update the values of Paddle. But NOTE: you won't need it if you used PA_InitPaddle as it's done automatically every Vblank.
\~french
\~french
*/
void PA_UpdatePaddle(void);

View File

@ -1,4 +1,3 @@
#ifdef __cplusplus
extern "C" {
#endif
@ -22,8 +21,8 @@ volatile PA_IPCType PA_IPC;
typedef struct {
s16 x, y, oldx, oldy, vx, vy; // Coordonnées
u8 stylus; // Si on déplace ou non
s16 x, y, oldx, oldy, vx, vy; // Coordonnées
u8 stylus; // Si on déplace ou non
u8 moving; // Si la boule est en mouvement ou non
} positions;
@ -33,7 +32,7 @@ typedef struct {
u32 PA_bgmap[2][4]; // Pointeur vers les maps, 4 maps par screen
u8 PA_Screen = 0;
s16 PA_ScreenSpace; // Espace entre les 2 écrans...+192
s16 PA_ScreenSpace; // Espace entre les 2 écrans...+192
PA_GifInfos PA_GifInfo;
@ -41,10 +40,10 @@ PA_GifInfos PA_GifInfo;
//Keypad stuff...
Pads Pad;
PA_Pad* PadPointer;
PA_Pad_Struct Pad;
PA_Stylus_Struct Stylus;
PA_Stylus Stylus;
PA_movingsprite PA_MovedSprite; // Pour les sprites que l'on bouge...
@ -55,18 +54,13 @@ u8 PA_MoveSpriteType = 0;
/*
typedef struct{
u8 snd_action[16]; // 0 - rien, 1 - play, 2 - stop, 3 - pause
u8 snd_action[16]; // 0 - rien, 1 - play, 2 - stop, 3 - pause
u8 snd_action[16]; // 0 - rien, 1 - play, 2 - stop, 3 - pause
}PA_IPCinfo;
PA_IPCinfo PA_IPC;*/
void PA_SetBrightness(u8 screen, s8 bright) {
u16 mode = 1 << 14;
@ -79,20 +73,11 @@ u16 mode = 1 << 14;
}
void PA_Nothing(void){}
void PA_Nothing(void)
{
}
#ifdef __cplusplus
}
#endif

View File

@ -1,4 +1,3 @@
#ifdef __cplusplus
extern "C" {
#endif
@ -16,13 +15,13 @@ extern const unsigned short PA_text_Pal[5] __attribute__ ((aligned (4)));
// Pour les fenetres
const s16 winfades[][4] = {
{4, 3, -4, -3},
{4, 0, -4, 0},
{8, 0, 0, 0},
{4, 0, -4, 0},
{8, 0, 0, 0},
{0, 0, -8, 0},
{0, 6, -8, 0},
{8, 0, 0, -6},
{0, 0, -8, -6},
{8, 6, 0, 0},
{0, 6, -8, 0},
{8, 0, 0, -6},
{0, 0, -8, -6},
{8, 6, 0, 0},
};
void PA_UpdateSpriteVBL(void);
@ -32,40 +31,40 @@ void PA_Init2D(void){
// Turn on the screens and 2D cores and switch to mode 0
powerON(POWER_ALL);
// POWER_CR = POWER_ALL_2D;
REG_POWERCNT &= ~SWITCH_SCREENS; // on s'assure que l'écran est bien
/*
VRAM_A_CR=VRAM_ENABLE|VRAM_A_MAIN_BG;
VRAM_B_CR=VRAM_ENABLE|VRAM_B_MAIN_SPRITE;
REG_POWERCNT &= ~SWITCH_SCREENS; // on s'assure que l'écran est bien
/*
VRAM_A_CR=VRAM_ENABLE|VRAM_A_MAIN_BG;
VRAM_B_CR=VRAM_ENABLE|VRAM_B_MAIN_SPRITE;
VRAM_C_CR=VRAM_ENABLE|VRAM_C_SUB_BG;
VRAM_D_CR=VRAM_ENABLE|VRAM_D_SUB_SPRITE; */
videoSetMode( MODE_0_2D |
videoSetMode( MODE_0_2D |
DISPLAY_SPR_ACTIVE | //turn on sprites
DISPLAY_SPR_1D | //this is used when in tile mode
DISPLAY_SPR_1D_SIZE_128|
DISPLAY_SPR_1D_BMP //and this in bitmap mode
);
videoSetModeSub( MODE_0_2D |
DISPLAY_SPR_ACTIVE | //turn on sprites
videoSetModeSub( MODE_0_2D |
DISPLAY_SPR_ACTIVE | //turn on sprites
DISPLAY_SPR_1D | //this is used when in tile mode
DISPLAY_SPR_1D_SIZE_128|
DISPLAY_SPR_1D_BMP //and this in bitmap mode
);
// DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP;
);
// DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP;
// SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP;
vramSetMainBanks(VRAM_A_MAIN_SPRITE,VRAM_B_MAIN_BG_0x06000000,VRAM_C_SUB_BG,VRAM_D_SUB_SPRITE);
// Sprite inits...
PA_ResetSpriteSys(); // Init's the sprite system
PA_InitSpriteExtPal(); // Init's sprite extended palettes
PA_ResetBgSys();
PA_InitBgExtPal(); // Init's bg extended palettes
// VBL Inits
SpriteVBL = PA_UpdateSpriteVBL;
@ -78,72 +77,79 @@ extern funcpointer PaddleVBL;
extern funcpointer GHPadVBL;
void PA_Init(void) {
s32 i;
for (i = 0; i < 130000>>2; i++) Blank[i] = 0;
void PA_Init(void)
{
s32 i;
for (i = 0; i < 130000>>2; i++) Blank[i] = 0;
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO
PA_Init2D();
pa_checklid = 1; // Autochecklid by default
PA_Init2D();
//WAIT_CR &= ~(1 << 7);
pa_checklid = 1; // Autochecklid by default
pa_update_padtimes = 0; // Don't update pad-times by default
gh_update_padtimes = 0; // Don't update GuitarHero-pad-times by default
Pad.Uptime.Up = 0; Pad.Downtime.Up = 0;
Pad.Uptime.Down = 0; Pad.Downtime.Down = 0;
Pad.Uptime.Left = 0; Pad.Downtime.Left = 0;
Pad.Uptime.Right = 0; Pad.Downtime.Right = 0;
Pad.Uptime.A = 0; Pad.Downtime.A = 0;
Pad.Uptime.B = 0; Pad.Downtime.B = 0;
Pad.Uptime.X = 0; Pad.Downtime.X = 0;
Pad.Uptime.Y = 0; Pad.Downtime.Y = 0;
Pad.Uptime.L = 0; Pad.Downtime.L = 0;
Pad.Uptime.R = 0; Pad.Downtime.R = 0;
Pad.Uptime.Start = 0; Pad.Downtime.Start = 0;
Pad.Uptime.Select = 0; Pad.Downtime.Select = 0;
Pad.Uptime.Anykey = 0; Pad.Downtime.Anykey = 0;
//WAIT_CR &= ~(1 << 7);
PA_VBLCountersReset();
PA_VBLCountersReset();
Stylus.X = 128;
Stylus.Y = 96;
Stylus.X = 128;
Stylus.Y = 96;
PA_VBLFunctionReset();
irqInit();
//PA_ResetInterrupts();
PA_VBLFunctionReset();
irqInit();
//PA_ResetInterrupts();
IPC->mailData = (u32)(&PA_IPC);
IPC->mailData = (u32)(&PA_IPC);
for (i = 0; i < 2; i++){
PA_SetBrightness(i, 0); // On affiche les écrans
for (i = 0; i < 2; i++){
PA_SetBrightness(i, 0); // On affiche les écrans
PA_font[i] = 0;
// #ifndef TEXT_ALLCHARACTERS
PA_textmap[i] = (u16*)PA_text_Map;
PA_texttiles[i] = (u8*)PA_text_Tiles;
PA_textpal[i] = (u16*)PA_text_Pal;
// #endif
/* #ifdef TEXT_ALLCHARACTERS
PA_textmap[i] = (u16*)PA_text2_Map;
PA_texttiles[i] = (u8*)PA_text2_Tiles;
PA_textpal[i] = (u16*)PA_text2_Pal;
#endif */
}
PA_font[i] = 0;
// #ifndef TEXT_ALLCHARACTERS
PA_textmap[i] = (u16*)PA_text_Map;
PA_texttiles[i] = (u8*)PA_text_Tiles;
PA_textpal[i] = (u16*)PA_text_Pal;
// #endif
/* #ifdef TEXT_ALLCHARACTERS
PA_textmap[i] = (u16*)PA_text2_Map;
PA_texttiles[i] = (u8*)PA_text2_Tiles;
PA_textpal[i] = (u16*)PA_text2_Pal;
#endif */
}
PA_UpdateUserInfo();
PA_ResetRecoSys(); // Reco system init
PA_SetScreenSpace(48); // Default spacing
PA_GifInfo.StartFrame = 0; // start from the beginning
PA_GifInfo.EndFrame = 10000; // random high number
MotionVBL = PA_Nothing;
PaddleVBL = PA_Nothing;
GHPadVBL = PA_Nothing;
PA_UpdateRTC();
//PA_SRand(35329 + PA_RTC.Minutes + PA_RTC.Seconds + PA_RTC.Hour + PA_RTC.Day);
PA_InitRand();
}
#ifdef __cplusplus
}
#endif

View File

@ -4,16 +4,17 @@ extern "C" {
#include "PA9.h"
extern const unsigned char keyboard_Tiles[10400];
extern const unsigned short keyboard_Map[4096];
extern const unsigned short keyboard_Palette[16];
/*
#include "keyboard.raw.c"
#include "keyboard.map.c"
#include "keyboard.pal.c"
*/
extern const unsigned char keyboard_Tiles[10400];
extern const unsigned short keyboard_Map[4096];
extern const unsigned short keyboard_Palette[16];
/*
const unsigned short keyboardPal1[16] = {
0x7c1f, 0x6f7b, 0x6318, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,

View File

@ -1,47 +1,39 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "PA9.h"
#include <arm9/PA_Keys.h>
//////////////////////////////////////////////////////////////////////
// Système de touches
// Système de touches
//////////////////////////////////////////////////////////////////////
#define UPDATEPAD(type, pad)\
type.A = pad & BUTTON_A;\
type.B = (pad & BUTTON_B) >> 1;\
type.Select = (pad & BUTTON_SELECT) >> 2;\
type.Start = (pad & BUTTON_START) >> 3;\
type.Right = (pad & BUTTON_RIGHT) >> 4;\
type.Left = (pad & BUTTON_LEFT) >> 5;\
type.Up = (pad & BUTTON_UP) >> 6;\
type.Down = (pad & BUTTON_DOWN) >> 7;\
type.R = (pad & BUTTON_R) >> 8;\
type.L = (pad & BUTTON_L) >> 9;\
type.X = (pad & BUTTON_X) >> 10;\
type.Y = (pad & BUTTON_Y) >> 11;\
type.Anykey = (!(!((pad&4095))));
extern u16 CompletePad, ExPad, TempPad;
#define UPDATEPAD(type, pad) type.A = pad & BUTTON_A;\
type.B = (pad & BUTTON_B) >> 1;\
type.Select = (pad & BUTTON_SELECT) >> 2;\
type.Start = (pad & BUTTON_START) >> 3;\
type.Right = (pad & BUTTON_RIGHT) >> 4;\
type.Left = (pad & BUTTON_LEFT) >> 5;\
type.Up = (pad & BUTTON_UP) >> 6;\
type.Down = (pad & BUTTON_DOWN) >> 7;\
type.R = (pad & BUTTON_R) >> 8;\
type.L = (pad & BUTTON_L) >> 9;\
type.X = (pad & BUTTON_X) >> 10;\
type.Y = (pad & BUTTON_Y) >> 11;\
type.Anykey = (!(!((pad&4095))));
/*
#define COPYPAD(new, old) new.A = old.A;\
new.B = old.B;\
new.Select = old.Select;\
new.Start = old.Start;\
new.Right = old.Right;\
new.Left = old.Left;\
new.Up = old.Up;\
new.Down = old.Down;\
new.R = old.R;\
new.L = old.L;\
new.X = old.X;\
new.Y = old.Y;*/
#define PA_BUTTONS (*(volatile u16*)0x04000130)
#define UPDATEPADTIMES(button)\
Pad.DblClick.button = Pad.Newpress.button && (Pad.Downtime.button + Pad.Uptime.button < 45);\
Pad.Downtime.button *= !Pad.Newpress.button;\
Pad.Downtime.button += Pad.Held.button;\
Pad.Uptime.button *= !Pad.Released.button;\
Pad.Uptime.button += !Pad.Held.button;
#define PA_BUTTONS (*(volatile u16*)0x04000130)
#ifndef REG_KEYCNT
#define REG_KEYCNT (*(volatile u16*)0x04000132)
@ -60,64 +52,71 @@ extern u16 CompletePad, ExPad, TempPad;
#define BUTTON_X 1024
#define BUTTON_Y 2048
u16 CompletePad, ExPad, TempPad;
void PA_UpdatePad(void) {
ExPad = CompletePad;
CompletePad = ~(PA_BUTTONS + (((IPC->buttons)&3) << 10));
UPDATEPAD(Pad.Held, CompletePad);
UPDATEPAD(Pad.Released, (ExPad & (~CompletePad)));
UPDATEPAD(Pad.Newpress, (CompletePad & (~ExPad)));
//PA_BackupPad();
//PA_OutputText(1,10,0,"up : %d%d",Pad.Newpress.Up, Pad.Held.Up);
//PA_OutputText(1,10,1,"up : %d%d",BackupPad.Newpress.Up, BackupPad.Held.Up);
u16 CompletePad, ExPad;
u8 pa_update_padtimes;
void PA_UpdatePad(void)
{
ExPad = CompletePad;
CompletePad = ~(PA_BUTTONS + (((IPC->buttons)&3) << 10));
UPDATEPAD(Pad.Released, (ExPad & (~CompletePad)));
UPDATEPAD(Pad.Newpress, (CompletePad & (~ExPad)));
UPDATEPAD(Pad.Held, CompletePad);
if (pa_update_padtimes)
{
UPDATEPADTIMES(A);
UPDATEPADTIMES(B);
UPDATEPADTIMES(Select);
UPDATEPADTIMES(Start);
UPDATEPADTIMES(Right);
UPDATEPADTIMES(Left);
UPDATEPADTIMES(Up);
UPDATEPADTIMES(Down);
UPDATEPADTIMES(R);
UPDATEPADTIMES(L);
UPDATEPADTIMES(X);
UPDATEPADTIMES(Y);
UPDATEPADTIMES(Anykey);
}
}
void PA_UpdateStylus(void) {
void PA_UpdateStylus(void)
{
//u8 temp = (((~IPC->buttons) << 6) & (1<<12));
u8 temp = ((~IPC->buttons) >> 6) & 1;
u8 temp = ((~IPC->buttons) >> 6) & 1;
Stylus.Pressure = (((IPC->touchXpx * IPC->touchZ2) >> 6) / IPC->touchZ1) - (IPC->touchXpx >> 6);
//if (Stylus.Pressure > 10) temp = 0; // limit to good pressures
Stylus.Released = ((!temp) & Stylus.Held);
Stylus.Newpress = temp & (!Stylus.Held);
Stylus.Held = temp;
Stylus.DblClick = Stylus.Newpress && (Stylus.Downtime+Stylus.Uptime < 45);
Stylus.Downtime *= !Stylus.Newpress; // = 0 if newpress
Stylus.Downtime += Stylus.Held;
Stylus.Uptime *= !Stylus.Released; // = 0 when released
Stylus.Uptime += !Stylus.Held;
if (Stylus.Held) { // On en met à jour que si on touche l'écran, histoire de pas avoir un truc faussé
if (Stylus.Held) // On en met à jour que si on touche l'écran, histoire de pas avoir un truc faussé
{
Stylus.altX = ((IPC->touchX - 0x0113) / 14);
Stylus.altY = ((IPC->touchY - 0x00E0) / 19);
if(Stylus.Newpress){
if (Stylus.Newpress)
{
Stylus.Vx = Stylus.oldVx = 0;
Stylus.Vy = Stylus.oldVy = 0;
}
else{// if (PA_Distance (Stylus.oldVx, Stylus.oldVy, Stylus.Vx, Stylus.Vy) < 2500){ // Limit speed change
else // if (PA_Distance (Stylus.oldVx, Stylus.oldVy, Stylus.Vx, Stylus.Vy) < 2500){ // Limit speed change
{
Stylus.oldVx = Stylus.Vx;
Stylus.oldVy = Stylus.Vy;
Stylus.oldVy = Stylus.Vy;
Stylus.Vx = IPC->touchXpx - Stylus.X;
Stylus.Vy = IPC->touchYpx - Stylus.Y;
Stylus.Vy = IPC->touchYpx - Stylus.Y;
// Stylus.X = IPC->touchXpx;
// Stylus.Y = IPC->touchYpx;
}
@ -125,23 +124,13 @@ u8 temp = ((~IPC->buttons) >> 6) & 1;
Stylus.Vx = Stylus.oldVx;
Stylus.Vy = Stylus.oldVy;
}*/
while (IPC->mailBusy);
while (IPC->mailBusy);
Stylus.X = IPC->touchXpx;
Stylus.Y = IPC->touchYpx;
Stylus.Y = IPC->touchYpx;
}
}
#ifdef __cplusplus
}
#endif

View File

@ -4,38 +4,73 @@ extern "C" {
#include "PA9.h"
GH_Pad GHPad;
#define UPDATEGHPAD(type, pad)\
type.Green = (pad & BUTTON_GREEN) >> 6;\
type.Red = (pad & BUTTON_RED) >> 5;\
type.Yellow = (pad & BUTTON_YELLOW) >> 4;\
type.Blue = (pad & BUTTON_BLUE) >> 3;\
type.Anykey = (!(!((pad&120))));
u16 GHCompletePad, GHExPad, GHTempPad;
#define UPDATEGHPADTIMES(button)\
GHPad.DblClick.button = GHPad.Newpress.button && (GHPad.Downtime.button + GHPad.Uptime.button < 45);\
GHPad.Downtime.button *= !GHPad.Newpress.button;\
GHPad.Downtime.button += GHPad.Held.button;\
GHPad.Uptime.button *= !GHPad.Released.button;\
GHPad.Uptime.button += !GHPad.Held.button;
GH_Pad_Struct GHPad;
u16 GHCompletePad, GHExPad;
u8 gh_update_padtimes;
extern funcpointer GHPadVBL;
bool PA_DetectGHPad(void){
WAIT_CR &= ~0x8080;
if((GBA_BUS[0] == 0xF9FF) && (GBA_BUS[1] == 0xF9FF) && (GBA_BUS[2] == 0xF9FF) && (GBA_BUS[3] == 0xF9FF)) return 1;
WAIT_CR &= ~0x8000;
return 0;
bool PA_DetectGHPad(void)
{
WAIT_CR &= ~0x8080;
if((GBA_BUS[0] == 0xF9FF) && (GBA_BUS[1] == 0xF9FF) && (GBA_BUS[2] == 0xF9FF) && (GBA_BUS[3] == 0xF9FF)) return 1;
WAIT_CR &= ~0x8000;
return 0;
}
bool PA_InitGHPad(void){
if(PA_DetectGHPad()) {
GHPadVBL = PA_UpdateGHPad;
return 1;
}
return 0;
bool PA_InitGHPad(void)
{
GHPad.Uptime.Green = 0; GHPad.Downtime.Green = 0;
GHPad.Uptime.Red = 0; GHPad.Downtime.Red = 0;
GHPad.Uptime.Yellow = 0; GHPad.Downtime.Yellow = 0;
GHPad.Uptime.Blue = 0; GHPad.Downtime.Blue = 0;
GHPad.Uptime.Anykey = 0; GHPad.Downtime.Anykey = 0;
if(PA_DetectGHPad())
{
GHPadVBL = PA_UpdateGHPad;
return 1;
}
return 0;
}
void PA_DeInitGHPad(void){
WAIT_CR &= ~0x8000;
GHPadVBL = PA_Nothing;
void PA_DeInitGHPad(void)
{
WAIT_CR &= ~0x8000;
GHPadVBL = PA_Nothing;
}
void PA_UpdateGHPad(void) {
GHExPad = GHCompletePad;
GHCompletePad = ~(GH_POLL );
UPDATEGHPAD(GHPad.Held, GHCompletePad);
UPDATEGHPAD(GHPad.Released, (GHExPad & (~GHCompletePad)));
UPDATEGHPAD(GHPad.Newpress, (GHCompletePad & (~GHExPad)));
void PA_UpdateGHPad(void)
{
GHExPad = GHCompletePad;
GHCompletePad = ~(GH_POLL );
UPDATEGHPAD(GHPad.Released, (GHExPad & (~GHCompletePad)));
UPDATEGHPAD(GHPad.Newpress, (GHCompletePad & (~GHExPad)));
UPDATEGHPAD(GHPad.Held, GHCompletePad);
if (gh_update_padtimes)
{
UPDATEGHPADTIMES(Green);
UPDATEGHPADTIMES(Red);
UPDATEGHPADTIMES(Yellow);
UPDATEGHPADTIMES(Blue);
UPDATEGHPADTIMES(Anykey);
}
}
@ -44,41 +79,45 @@ PaddleInfo Paddle;
extern funcpointer PaddleVBL;
bool PA_DetectPaddle(void){
WAIT_CR &= ~0x8080;
WAIT_CR |= 0x23;
if((GBA_BUS[0] == 0xEFFF) && (GBA_BUS[1] == 0xEFFF) && (GBA_BUS[2] == 0xEFFF) && (GBA_BUS[3] == 0xEFFF)) return 1;
WAIT_CR &= ~0x8000;
return 0;
bool PA_DetectPaddle(void)
{
WAIT_CR &= ~0x8080;
WAIT_CR |= 0x23;
if((GBA_BUS[0] == 0xEFFF) && (GBA_BUS[1] == 0xEFFF) && (GBA_BUS[2] == 0xEFFF) && (GBA_BUS[3] == 0xEFFF)) return 1;
WAIT_CR &= ~0x8000;
return 0;
}
bool PA_InitPaddle(void){
if(PA_DetectPaddle())
{
PaddleVBL = PA_UpdatePaddle;
return 1;
}
return 0;
bool PA_InitPaddle(void)
{
if(PA_DetectPaddle())
{
PaddleVBL = PA_UpdatePaddle;
return 1;
}
return 0;
}
void PA_DeInitPaddle(void){
WAIT_CR &= ~0x8000;
PaddleVBL = PA_Nothing;
void PA_DeInitPaddle(void)
{
WAIT_CR &= ~0x8000;
PaddleVBL = PA_Nothing;
}
void PA_UpdatePaddle(void) {
Paddle.OldLow = Paddle.Low;
Paddle.OldHigh = Paddle.High;
Paddle.OldCount = Paddle.Count;
void PA_UpdatePaddle(void)
{
Paddle.OldLow = Paddle.Low;
Paddle.OldHigh = Paddle.High;
Paddle.OldCount = Paddle.Count;
Paddle.Low = PADDLE_LOW;
Paddle.High = PADDLE_HIGH;
Paddle.Count = (Paddle.High<<8)+Paddle.Low;
Paddle.Low = PADDLE_LOW;
Paddle.High = PADDLE_HIGH;
Paddle.Count = (Paddle.High<<8)+Paddle.Low;
Paddle.Speed = Paddle.Count - Paddle.OldCount;
Paddle.Speed = Paddle.Count - Paddle.OldCount;
if(Paddle.High - Paddle.OldHigh == 15) Paddle.Speed -= 4096;
else if(Paddle.High - Paddle.OldHigh == -15) Paddle.Speed += 4096;
if(Paddle.High - Paddle.OldHigh == 15) Paddle.Speed -= 4096;
else if(Paddle.High - Paddle.OldHigh == -15) Paddle.Speed += 4096;
}