Rikku2000
Member
- Joined
- Jul 2, 2010
- Messages
- 348
Denn SNES9X für Dingux auf dem CAANOO Nutzen
/* ===================================(caanoo.h) */
- Als erstes, erstellen wir eine neu Datei für die CAANOO Tasten.
- Datei: "caanoo.h"
/* ===================================(keydef.h) */
- Jetzt, andern wir die keydef.h Datei
Ändere:
Mit:
/* ===================================(unix.cpp) */
- Jetzt editieren wir die Header Datei.
Ändere:
Mit:
- Suche jetzt: "keyssnes"
Ändere:
Mit:
- Suche weiter nach: "S9xInitInputDevices"
Ändere:
Mit:
Suche weiter nach: "void S9xProcessEvents (bool8_32 block)"
Ändere:
Mit:
Suche weiter nach: "uint32 S9xReadJoypad (int which1)"
Andere:
Mit:
/* ===================================(svga.cpp) */
- Jetzt editieren wir die Header Datei.
Ändere:
Mit:
- Suche jetzt: "keyssnes"
Ändere:
Mit:
Suche weiter nach: "S9xInitDisplay"
- In "S9xInitDisplay" suche nach: "SDL_INIT"
Ändere:
Mit:
- Jetzt geh ein paar Zeilen runter
Ändere:
Mit:
- Jetzt sind wir Fertig mit der Portirung und können denn SNES9X Emulator auf
den Caanoo spielen.
Download:
Binary
Source
Have FUN, Rikku2000
/* ===================================(caanoo.h) */
- Als erstes, erstellen wir eine neu Datei für die CAANOO Tasten.
- Datei: "caanoo.h"
Code:
/*
Caanoo Keys
*/
#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_START 6
#define CAANOO_BUTTON_SELECT 9
#define CAANOO_BUTTON_UP 11
#define CAANOO_BUTTON_DOWN 12
#define CAANOO_BUTTON_LEFT 13
#define CAANOO_BUTTON_RIGHT 14
- Jetzt, andern wir die keydef.h Datei
Ändere:
Code:
#define A_1 0
#define B_1 1
#define X_1 2
#define Y_1 3
#define L_1 4
#define R_1 5
#define A_2 6
#define B_2 7
#define X_2 8
#define Y_2 9
#define L_2 10
#define R_2 11
#define START_1 12
#define SELECT_1 13
#define START_2 14
#define SELECT_2 15
#define UP_1 16
#define DOWN_1 17
#define LEFT_1 18
#define RIGHT_1 19
#define UP_2 20
#define DOWN_2 21
#define LEFT_2 22
#define RIGHT_2 23
#define LU_2 24
#define LD_2 25
#define RU_2 26
#define RD_2 27
#define ACCEL 50
#define QUIT 51
#define HELP 52
#define SHIFTL 30
#define SHIFTR 31
#define CTRLL 32
#define CTRLR 33
Code:
#define A_1 0
#define X_1 1
#define B_1 2
#define Y_1 3
#define L_1 4
#define R_1 5
#define START_1 6
#define SELECT_1 9
#define UP_1 11
#define DOWN_1 12
#define LEFT_1 13
#define RIGHT_1 14
#define ACCEL 50
#define QUIT 51
#define HELP 52
#define SHIFTL 30
#define SHIFTR 31
#define CTRLL 32
#define CTRLR 33
- Jetzt editieren wir die Header Datei.
Ändere:
Code:
#include "dingoo.h"
Code:
#include "caanoo.h"
- Suche jetzt: "keyssnes"
Ändere:
Code:
uint8 *keyssnes;
Code:
SDL_Joystick* keyssnes;
- Suche weiter nach: "S9xInitInputDevices"
Ändere:
Code:
void S9xInitInputDevices () {
memset(sfc_key, 0, 256);
sfc_key[QUIT] = SDLK_a;
sfc_key[A_1] = DINGOO_BUTTON_A;
sfc_key[B_1] = DINGOO_BUTTON_B;
sfc_key[X_1] = DINGOO_BUTTON_X;
sfc_key[Y_1] = DINGOO_BUTTON_Y;
sfc_key[L_1] = DINGOO_BUTTON_L;
sfc_key[R_1] = DINGOO_BUTTON_R;
sfc_key[START_1] = DINGOO_BUTTON_START;
sfc_key[SELECT_1] = DINGOO_BUTTON_SELECT;
sfc_key[LEFT_1] = DINGOO_BUTTON_LEFT;
sfc_key[RIGHT_1] = DINGOO_BUTTON_RIGHT;
sfc_key[UP_1] = DINGOO_BUTTON_UP;
sfc_key[DOWN_1] = DINGOO_BUTTON_DOWN;
sfc_key[LEFT_2] = SDLK_g;
sfc_key[RIGHT_2] = SDLK_j;
sfc_key[UP_2] = SDLK_u;
sfc_key[DOWN_2] = SDLK_n;
sfc_key[LU_2] = SDLK_y;
sfc_key[LD_2] = SDLK_b;
sfc_key[RU_2] = SDLK_i;
sfc_key[RD_2] = SDLK_m;
sfc_key[QUIT] = SDLK_d;
sfc_key[ACCEL] = SDLK_u;
int i = 0;
char *envp, *j;
envp = j = getenv ("S9XKEYS");
if (envp) {
do {
if (j = strchr(envp, ','))
*j = 0;
if (i == 0) sfc_key[QUIT] = atoi(envp);
else if (i == 1) sfc_key[A_1] = atoi(envp);
else if (i == 2) sfc_key[B_1] = atoi(envp);
else if (i == 3) sfc_key[X_1] = atoi(envp);
else if (i == 4) sfc_key[Y_1] = atoi(envp);
else if (i == 5) sfc_key[L_1] = atoi(envp);
else if (i == 6) sfc_key[R_1] = atoi(envp);
else if (i == 7) sfc_key[START_1] = atoi(envp);
else if (i == 8) sfc_key[SELECT_1] = atoi(envp);
else if (i == 9) sfc_key[LEFT_2] = atoi(envp);
else if (i == 10) sfc_key[RIGHT_2] = atoi(envp);
else if (i == 11) sfc_key[UP_2] = atoi(envp);
else if (i == 12) sfc_key[DOWN_2] = atoi(envp);
else if (i == 13) sfc_key[LU_2] = atoi(envp);
else if (i == 14) sfc_key[LD_2] = atoi(envp);
else if (i == 15) sfc_key[RU_2] = atoi(envp);
else if (i == 16) sfc_key[RD_2] = atoi(envp);
envp = j + 1;
++i;
} while(j);
}
}
Code:
void S9xInitInputDevices () {
memset(sfc_key, 0, 256);
sfc_key[QUIT] = SDLK_a;
sfc_key[A_1] = CAANOO_BUTTON_A;
sfc_key[B_1] = CAANOO_BUTTON_B;
sfc_key[X_1] = CAANOO_BUTTON_X;
sfc_key[Y_1] = CAANOO_BUTTON_Y;
sfc_key[L_1] = CAANOO_BUTTON_L;
sfc_key[R_1] = CAANOO_BUTTON_R;
sfc_key[START_1] = CAANOO_BUTTON_START;
sfc_key[SELECT_1] = CAANOO_BUTTON_SELECT;
sfc_key[LEFT_1] = CAANOO_BUTTON_LEFT;
sfc_key[RIGHT_1] = CAANOO_BUTTON_RIGHT;
sfc_key[UP_1] = CAANOO_BUTTON_UP;
sfc_key[DOWN_1] = CAANOO_BUTTON_DOWN;
sfc_key[QUIT] = SDLK_d;
sfc_key[ACCEL] = SDLK_u;
int i = 0;
char *envp, *j;
envp = j = getenv ("S9XKEYS");
if (envp) {
do {
if (j = strchr(envp, ','))
*j = 0;
if (i == 0) sfc_key[QUIT] = atoi(envp);
else if (i == 1) sfc_key[A_1] = atoi(envp);
else if (i == 2) sfc_key[B_1] = atoi(envp);
else if (i == 3) sfc_key[X_1] = atoi(envp);
else if (i == 4) sfc_key[Y_1] = atoi(envp);
else if (i == 5) sfc_key[L_1] = atoi(envp);
else if (i == 6) sfc_key[R_1] = atoi(envp);
else if (i == 7) sfc_key[START_1] = atoi(envp);
else if (i == 8) sfc_key[SELECT_1] = atoi(envp);
envp = j + 1;
++i;
} while(j);
}
}
Suche weiter nach: "void S9xProcessEvents (bool8_32 block)"
Ändere:
Code:
void S9xProcessEvents (bool8_32 block) {
SDL_Event event;
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_KEYDOWN:
keyssnes = SDL_GetKeyState(NULL);
if ((keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED) && (keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[B_1]] == SDL_PRESSED))
S9xReset();
else if ( (keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED) &&(keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[X_1]] == SDL_PRESSED) )
S9xExit();
else if ( (keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[R_1]] == SDL_PRESSED) ) {
char fname[256], ext[20];
gp2x_sound_volume(0, 0);
sprintf(ext, ".00%d", SaveSlotNum);
strcpy(fname, S9xGetFilename (ext));
S9xFreezeGame (fname);
capt_screenshot();
sprintf(ext, ".s0%d", SaveSlotNum);
strcpy(fname, S9xGetFilename (ext));
save_screenshot(fname);
gp2x_sound_volume(vol, vol);
} else if ( (keyssnes[sfc_key[START_1]] == SDL_PRESSED) && (keyssnes[sfc_key[L_1]] == SDL_PRESSED) ) {
char fname[256], ext[8];
gp2x_sound_volume(0, 0);
sprintf(ext, ".00%d", SaveSlotNum);
strcpy(fname, S9xGetFilename (ext));
S9xLoadSnapshot (fname);
gp2x_sound_volume(vol, vol);
} else if ((keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED)&&(keyssnes[sfc_key[B_1]] == SDL_PRESSED) ) {
gp2x_sound_volume(0, 0);
menu_loop();
gp2x_sound_volume(vol, vol);
}
break;
case SDL_KEYUP:
keyssnes = SDL_GetKeyState(NULL);
}
}
}
Code:
void S9xProcessEvents (bool8_32 block) {
SDL_Event event;
while(SDL_PollEvent(&event)) {
switch (event.type) {
keyssnes = SDL_JoystickOpen(0);
case SDL_JOYBUTTONDOWN:
switch(event.jbutton.button) {
if (SDL_JoystickGetButton(keyssnes, 9) && SDL_JoystickGetButton(keyssnes, 6) && SDL_JoystickGetButton(keyssnes, 2))
S9xReset();
/* My Crap in here ... */
}
break;
case SDL_JOYBUTTONUP:
switch(event.jbutton.button) {
}
break;
}
}
}
Andere:
Code:
uint32 S9xReadJoypad (int which1) {
uint32 val=0x80000000;
if (keyssnes[sfc_key[L_1]] == SDL_PRESSED) val |= SNES_TL_MASK;
if (keyssnes[sfc_key[R_1]] == SDL_PRESSED) val |= SNES_TR_MASK;
if (keyssnes[sfc_key[X_1]] == SDL_PRESSED) val |= SNES_X_MASK;
if (keyssnes[sfc_key[Y_1]] == SDL_PRESSED) val |= SNES_Y_MASK;
if (keyssnes[sfc_key[B_1]] == SDL_PRESSED) val |= SNES_B_MASK;
if (keyssnes[sfc_key[A_1]] == SDL_PRESSED) val |= SNES_A_MASK;
if (keyssnes[sfc_key[START_1]] == SDL_PRESSED) val |= SNES_START_MASK;
if (keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED) val |= SNES_SELECT_MASK;
if (keyssnes[sfc_key[UP_1]] == SDL_PRESSED) val |= SNES_UP_MASK;
if (keyssnes[sfc_key[DOWN_1]] == SDL_PRESSED) val |= SNES_DOWN_MASK;
if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED) val |= SNES_LEFT_MASK;
if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED) val |= SNES_RIGHT_MASK;
if (keyssnes[sfc_key[UP_2]] == SDL_PRESSED) val |= SNES_UP_MASK;
if (keyssnes[sfc_key[DOWN_2]] == SDL_PRESSED) val |= SNES_DOWN_MASK;
if (keyssnes[sfc_key[LEFT_2]] == SDL_PRESSED) val |= SNES_LEFT_MASK;
if (keyssnes[sfc_key[RIGHT_2]] == SDL_PRESSED) val |= SNES_RIGHT_MASK;
if (keyssnes[sfc_key[LU_2]] == SDL_PRESSED) val |= SNES_LEFT_MASK | SNES_UP_MASK;
if (keyssnes[sfc_key[LD_2]] == SDL_PRESSED) val |= SNES_LEFT_MASK | SNES_DOWN_MASK;
if (keyssnes[sfc_key[RU_2]] == SDL_PRESSED) val |= SNES_RIGHT_MASK | SNES_UP_MASK;
if (keyssnes[sfc_key[RD_2]] == SDL_PRESSED) val |= SNES_RIGHT_MASK | SNES_DOWN_MASK;
return(val);
}
Code:
uint32 S9xReadJoypad (int which1) {
uint32 val=0x80000000;
if (SDL_JoystickGetButton(keyssnes, 4)) val |= SNES_TL_MASK;
if (SDL_JoystickGetButton(keyssnes, 5)) val |= SNES_TR_MASK;
if (SDL_JoystickGetButton(keyssnes, 1)) val |= SNES_X_MASK;
if (SDL_JoystickGetButton(keyssnes, 3)) val |= SNES_Y_MASK;
if (SDL_JoystickGetButton(keyssnes, 2)) val |= SNES_B_MASK;
if (SDL_JoystickGetButton(keyssnes, 0)) val |= SNES_A_MASK;
if (SDL_JoystickGetButton(keyssnes, 6)) val |= SNES_START_MASK;
if (SDL_JoystickGetButton(keyssnes, 9)) val |= SNES_SELECT_MASK;
if (SDL_JoystickGetAxis(keyssnes, 1) < -20000) val |= SNES_UP_MASK;
if (SDL_JoystickGetAxis(keyssnes, 1) > 20000) val |= SNES_DOWN_MASK;
if (SDL_JoystickGetAxis(keyssnes, 0) < -20000) val |= SNES_LEFT_MASK;
if (SDL_JoystickGetAxis(keyssnes, 0) > 20000) val |= SNES_RIGHT_MASK;
return(val);
}
- Jetzt editieren wir die Header Datei.
Ändere:
Code:
#include "dingoo.h"
Code:
#include "caanoo.h"
- Suche jetzt: "keyssnes"
Ändere:
Code:
extern uint8 *keyssnes;
Code:
extern SDL_Joystick* keyssnes;
Suche weiter nach: "S9xInitDisplay"
- In "S9xInitDisplay" suche nach: "SDL_INIT"
Ändere:
Code:
if (SDL_Init(SDL_INIT_VIDEO|(Settings.NextAPUEnabled ? SDL_INIT_AUDIO : 0)) < 0 ) {
Code:
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|(Settings.NextAPUEnabled ? SDL_INIT_AUDIO : 0)) < 0 ) {
- Jetzt geh ein paar Zeilen runter
Ändere:
Code:
keyssnes = SDL_GetKeyState(NULL);
Code:
keyssnes = SDL_JoystickOpen(0);
- Jetzt sind wir Fertig mit der Portirung und können denn SNES9X Emulator auf
den Caanoo spielen.
Download:
Binary
Source
Have FUN, Rikku2000