Added joystick support. Probably needs more work

This commit is contained in:
teuf
2001-04-17 21:59:48 +00:00
parent eb4e911dd8
commit 22653ebef9
3 changed files with 403 additions and 85 deletions

View File

@@ -1,12 +1,203 @@
04/04/2001 zsKnight <zsknight@zsnes.com>
* Fixed up new graphics engine memory leak, thanks to Trac for
reporting this!
* Updated version # in ui.asm
2001-04-17 teuf
04/04/2001 Erik Bourget <ebourg@po-box.mcgill.ca>
* made it compile cleanly up to linking on unix machines
(fixed up some filename case problems, backslash->forward
slash issues)
* i don't know if this will break DOS stuff. I assume it won't
because some files asked for include files with the forward
slash.
* src/linux/sdllink.c: Added some preliminary joystick support
2001-04-17 07:29 theoddone33
* src/linux/zloaderw.c: Removed __NO_GETOPT, since the getopt stuff
is fixed now.
2001-04-17 06:14 theoddone33
* src/cfgload.asm: Fixed GameDirectory in the config
2001-04-17 05:43 theoddone33
* src/: cpu/dspproc.asm, gui/menu.asm, linux/winintrf.asm: Case
changes
2001-04-17 05:06 theoddone33
* src/: ui.asm, gui/guiload.inc, linux/sdllink.c,
linux/winintrf.asm, linux/zfilew.c: Load dialog fixed up, big
thanks to relnev Remaining keys fixed in dialog
2001-04-16 21:53 theoddone33
* src/linux/sdllink.c: clearwin works
2001-04-16 20:38 theoddone33
* src/linux/sdllink.c: More changes to the Keyboard things, most
keys work in dialogs now.
2001-04-16 08:05 theoddone33
* src/linux/sdllink.c: major changes. relnev got auto bpp detect
working and implemented the remaining vidmodes. I started work on
getting dialogs to work right.
2001-04-16 04:39 theoddone33
* src/gui/: gui.asm, guimisc.inc: case fixes on the movie
extentions
2001-04-16 02:02 theoddone33
* linux/AUTHORS, src/gui/guiload.inc, src/linux/zfilew.c: Start of
an authors file for those that have contributed to the Linux port.
The start of additions from MrGrim's tree.
2001-04-15 20:53 theoddone33
* src/: ui.asm, linux/sdllink.c, linux/zloaderw.c: This will
hopefully fix problems people have been having with getopt
2001-04-15 10:21 zsknight
* src/gui/gui.asm: Win2k zip crash bug fix by Matthew Kendora
(memory leak bug fix)
2001-04-15 10:18 zsknight
* src/: cpu/execute.asm, dos/debug.asm: Added SPC7110 logger
2001-04-15 10:14 zsknight
* src/cpu/65816d.inc: Fixed b flag setting in BRK instruction in
6502 emulation mode
2001-04-15 10:10 zsknight
* src/gui/: gui.asm, guimouse.inc, guiwindp.inc: GUI Addition for
Cubic Spline Sound Interpolation selection [Thanks AntiResonance!]
2001-04-15 10:08 zsknight
* src/cpu/dspproc.asm: Cubic Spline Sound Interpolation [from
AntiResonance]
2001-04-15 09:58 zsknight
* src/video/: newgfx16.asm, newgfx.asm: Variable write size error
[Thanks TRAC!]
2001-04-15 09:49 zsknight
* src/link.win32: Updated to link the recent zip objects properly
2001-04-15 09:35 zsknight
* src/: makefile.dos, makefile.win: Updated dos/win makefiles for
the updated zip sources by teuf.
2001-04-15 09:33 zsknight
* src/ui.asm: Removed unnecessary extern for windows port
compatibility
2001-04-15 09:31 zsknight
* src/zip/: zlib.h, zzip.c, unzip.c, unzip.h, zconf.h: Added ZIP
Sources
2001-04-15 03:23 theoddone33
* src/: init.asm, ui.asm, linux/winintrf.asm, linux/zfilew.c,
linux/zloaderw.c: various fixes, the most significant being that
saving state now works.
2001-04-14 21:07 theoddone33
* src/: ui.asm, linux/sdllink.c, linux/zloaderw.c: Added
eviltypeguy's significant patch to fixup command line arguments.
Added a __NO_GETOPT define until we can find a resolution for
ragweed's problems Added a patch from relnev to fix some sound
problems where too many sounds are playing at once.
2001-04-14 18:45 theoddone33
* src/linux/sdllink.c: Keys now map correctly
2001-04-14 03:49 theoddone33
* src/linux/sdllink.c: Fix GUI updating
2001-04-14 03:22 theoddone33
* src/linux/sdllink.c: Some more stuff from relnev, 640x480 enabled
2001-04-14 03:09 theoddone33
* src/linux/sdllink.c: Large speed increase suggested by relnev
2001-04-12 05:03 theoddone33
* src/linux/sdllink.c: Fixed non-AT&T syntax in some inline.
2001-04-10 06:43 theoddone33
* src/linux/sdllink.c: sound fix
2001-04-10 06:38 theoddone33
* src/win/Zsnes.ico: Fix corrupted file
2001-04-10 06:28 theoddone33
* src/: cfgload.asm, endmem.asm, fixsin.h, init.asm, macros.mac,
makefile.dos, makefile.linux, ui.asm, vcache.asm, chips/dsp1emu.c,
chips/dsp1proc.asm, chips/fxemu2.asm, chips/fxemu2b.asm,
chips/fxemu2c.asm, chips/fxtable.asm, chips/sa1proc.asm,
chips/sa1regs.asm, chips/sfxproc.asm, cpu/65816dc.inc,
cpu/addrni.asm, cpu/dma.asm, cpu/dsp.asm, cpu/dspproc.asm,
cpu/e65816.inc, cpu/execute.asm, cpu/irq.asm, cpu/memory.asm,
cpu/regs.inc, cpu/spc700.asm, cpu/stable.asm, cpu/table.asm,
cpu/tableb.asm, cpu/tablec.asm, dos/debug.asm, dos/gppro.asm,
dos/initvid.asm, dos/joy.asm, dos/modemrtn.asm, dos/sw.asm,
dos/vesa12.asm, dos/vesa2.asm, gui/gui.asm, gui/guiwindp.inc,
gui/menu.asm, video/2xsaiw.asm, video/copyvid.inc,
video/m716text.asm, video/makev16b.asm, video/makev16t.asm,
video/makevid.asm, video/mode7.asm, video/mode716.asm,
video/mode716b.asm, video/mode716d.asm, video/mode716e.asm,
video/mode716t.asm, video/mode7ext.asm, video/mv16tms.asm,
video/newg162.asm, video/newgfx.asm, video/newgfx16.asm,
video/newgfx2.asm, video/procvid.asm: Linux commits
2001-04-10 05:52 theoddone33
* src/linux/: copyvwin.asm, protect.c, resource.h, sdllink.c,
winintrf.asm, zfilew.c, zipxw.c, zloaderw.c, zsnes.rc, ztcp.c:
adding linux stuff
2001-04-06 00:47 zsknight
* src/video/: newgfx16.asm, newgfx.asm: New graphics engine leak
fix (Thanks Trac!)
2001-04-06 00:46 zsknight
* src/ui.asm: ZSNES Version # update
2001-04-06 00:45 zsknight
* ChangeLog: New graphics engine leak / ZSNES Version # update
2001-04-05 12:45 teuf
* src/obj/: dosbuff.o, ipx.o, unzip.o, unzip.obj, zipx.o, zzip.o,
zzip.obj: This time, these files should be ok
2001-04-05 12:42 teuf
* src/obj/: dosbuff.o, ipx.o, unzip.o, unzip.obj, zipx.o, zzip.o,
zzip.obj: I stupidly corrupted those files just before the
release...
2001-04-05 00:36 zsknight
* src/gui/guiwindp.inc: Changed version # (Winv0.85 -> Winv0.86)
2001-04-05 00:34 zsknight
* src/ui.asm: Changed version # (v1.17 -> v1.18)

View File

@@ -1,4 +1,3 @@
#ifdef __LINUX__ // AH
#include <stdio.h>
#include <unistd.h>
@@ -82,7 +81,6 @@ LPDIRECTINPUTDEVICE MouseInput;
LPDIRECTINPUTDEVICE KeyboardInput;
LPDIRECTINPUTDEVICE7 JoystickInput[4];
DIJOYSTATE js[4];
#endif // __LINUX__
DWORD X1Disable[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
DWORD X2Disable[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
@@ -101,17 +99,29 @@ DWORD S02Disable[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
DWORD S11Disable[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
DWORD S12Disable[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
#endif // __LINUX__
DWORD CurrentJoy=0;
#ifdef __LINUX__
extern signed long JoyMaxX;
extern signed long JoyMaxY;
extern signed long JoyMinX;
extern signed long JoyMinY;
extern signed long JoyX;
extern signed long JoyY;
SDL_Joystick *JoystickInput[4];
#endif //__LINUX__
DWORD BitDepth;
BYTE BackColor=0;
DEVMODE mode;
int DTimerCheck;
float MouseMinX=0;
/*float MouseMinX=0;
float MouseMaxX=256;
float MouseMinY=0;
float MouseMaxY=223;
float MouseMaxY=223;*/
int MouseX;
int MouseY;
float MouseMoveX;
@@ -144,7 +154,9 @@ DWORD InputEn=0;
BOOL InputAcquire(void)
{
#ifdef __LINUX__ // AH
STUB_FUNCTION;
// STUB_FUNCTION;
InputEn=1;
return TRUE;
#else // __WIN32__
if(JoystickInput[0]) JoystickInput[0]->Acquire();
if(JoystickInput[1]) JoystickInput[1]->Acquire();
@@ -154,14 +166,17 @@ BOOL InputAcquire(void)
if(MouseInput) MouseInput->Acquire();
if(KeyboardInput) KeyboardInput->Acquire();
InputEn=1;
return TRUE;
return TRUE;
#endif // __LINUX__
}
BOOL InputDeAcquire(void)
{
#ifdef __LINUX__ // AH
STUB_FUNCTION;
// STUB_FUNCTION;
InputEn=0;
return TRUE;
#else // __WIN32__
if(MouseInput) { MouseInput->Unacquire(); }
if(KeyboardInput) KeyboardInput->Unacquire();
@@ -169,9 +184,10 @@ BOOL InputDeAcquire(void)
if(JoystickInput[1]) JoystickInput[1]->Unacquire();
if(JoystickInput[2]) JoystickInput[2]->Unacquire();
if(JoystickInput[3]) JoystickInput[3]->Unacquire();
#endif // __LINUX__
InputEn=0;
return TRUE;
return TRUE;
#endif // __LINUX__
}
unsigned char keyboardhit=0;
@@ -201,30 +217,84 @@ void ProcessKeyBuf(int scancode);
int Main_Proc(void)
{
// TODO: Main event loop
SDL_Event event;
// TODO: Main event loop
SDL_Event event;
Uint8 JoyButton;
//STUB_FUNCTION;
while (SDL_PollEvent(&event)) {
switch(event.type)
{
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_LSHIFT ||
event.key.keysym.sym == SDLK_RSHIFT)
shiftptr = 1;
if (event.key.keysym.scancode-8 > 0) {
if (pressed[event.key.keysym.scancode-8]!=2)
pressed[event.key.keysym.scancode-8]=1;
ProcessKeyBuf(event.key.keysym.sym);
}
break;
//STUB_FUNCTION;
while (SDL_PollEvent(&event)) {
switch(event.type)
{
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_LSHIFT ||
event.key.keysym.sym == SDLK_RSHIFT)
shiftptr = 1;
if (event.key.keysym.scancode-8 > 0) {
if (pressed[event.key.keysym.scancode-8]!=2)
pressed[event.key.keysym.scancode-8]=1;
ProcessKeyBuf(event.key.keysym.sym);
}
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_LSHIFT ||
event.key.keysym.sym == SDLK_RSHIFT)
shiftptr = 0;
if (event.key.keysym.scancode-8 > 0)
pressed[event.key.keysym.scancode-8]=0;
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_LSHIFT ||
event.key.keysym.sym == SDLK_RSHIFT)
shiftptr = 0;
if (event.key.keysym.scancode-8 > 0)
pressed[event.key.keysym.scancode-8]=0;
break;
case SDL_MOUSEMOTION:
MouseX = event.motion.x;
MouseY = event.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
MouseButton = MouseButton | event.button.button;
break;
case SDL_MOUSEBUTTONUP:
MouseButton = MouseButton & ~event.button.button;
break;
case SDL_JOYAXISMOTION:
CurrentJoy = event.jaxis.which;
if( event.jaxis.axis == 0) {
if (event.jaxis.value < JoyMinX) {
pressed[0x100 + CurrentJoy*32 + 1] = 1;
printf("Joystick left : %d\n", event.jaxis.value);
} else if (event.jaxis.value > JoyMaxX) {
pressed[0x100 + CurrentJoy*32 + 0] = 1;
printf("Joystick right : %d\n", event.jaxis.value);
} else {
pressed[0x100 + CurrentJoy*32 + 1] = 0;
pressed[0x100 + CurrentJoy*32 + 0] = 0;
}
}
if( event.jaxis.axis == 1) {
if (event.jaxis.value < JoyMinY) {
pressed[0x100 + CurrentJoy*32 + 3] = 1;
printf("Joystick up : %d\n", event.jaxis.value);
} else if (event.jaxis.value > JoyMaxY) {
pressed[0x100 + CurrentJoy*32 + 2] = 1;
printf("Joystick down : %d\n", event.jaxis.value);
} else {
pressed[0x100 + CurrentJoy*32 + 3] = 0;
pressed[0x100 + CurrentJoy*32 + 2] = 0;
}
}
break;
case SDL_JOYBUTTONDOWN:
CurrentJoy = event.jbutton.which;
JoyButton = event.jbutton.button;
pressed[0x100 + CurrentJoy*32 + 16 + JoyButton] = 1;
printf("Button %u pressed on joystick %u\n", JoyButton, CurrentJoy);
break;
case SDL_JOYBUTTONUP:
pressed[0x100 + CurrentJoy*32 + 16 + JoyButton] = 0;
break;
default: break;
}
}
return TRUE;
@@ -776,8 +846,64 @@ ReInitSound()
#ifdef __LINUX__ // AH
BOOL InitJoystickInput(void)
{
STUB_FUNCTION;
return TRUE;
int i;
SDL_Event *event;
STUB_FUNCTION;
for (i=0; i<4; i++)
JoystickInput[i]=NULL;
// If it is possible to use SDL_NumJoysticks
// before initialising SDL_INIT_JOYSTICK then
// this call can be replaced with SDL_InitSubSystem
if (!SDL_NumJoysticks()) {
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return;
}
SDL_JoystickEventState(SDL_ENABLE);
for (i=0; i<SDL_NumJoysticks(); i++)
JoystickInput[i]=SDL_JoystickOpen(i);
/* if your joystick doesn't work correctly, you may want to
* change these values
*/
JoyMaxX = 100;
JoyMinX = -100;
JoyMaxY = 100;
JoyMinY = -100;
/*the goal of this piece of code is to autocalibrate the joystick
* but for the moment it segfaults
*/
/*
JoyMaxX = 0;
JoyMinX = 0;
JoyMaxY = 0;
JoyMinY = 0;
JoyX = 0;
JoyY = 0;
while ((JoyX == 0) || (JoyY == 0)) {
SDL_WaitEvent(event);
if (event->type == SDL_JOYAXISMOTION) {
if (event->jaxis.axis == 0) {
JoyX = event->jaxis.value;
if (JoyX < 0) JoyX = -JoyX;
JoyMaxX = 2*JoyX;
JoyMinX = -2*JoyX;
}
if (event->jaxis.axis == 1) {
JoyY = event->jaxis.value;
if (JoyY < 0) JoyY = -JoyY;
JoyMaxY = 2*JoyY;
JoyMinY = -2*JoyY;
}
}
}
printf("Joystick initialised\n");
printf("MinX : %d MaxX : %d\n", JoyMinX, JoyMaxX);
printf("MinY : %d MaxY : %d\n", JoyMinY, JoyMaxY);
*/
return TRUE;
}
#else // __WIN32__
BOOL FAR PASCAL InitJoystickInput(LPCDIDEVICEINSTANCE pdinst, LPVOID pvRef)
@@ -983,9 +1109,10 @@ DirectX 7.0a or higher located at www.microsoft.com/directx \0");
BOOL InitInput()
{
char message1[256];
#ifdef __LINUX__ // AH
STUB_FUNCTION;
char message1[256];
#ifdef __LINUX__ // AH
STUB_FUNCTION;
InitJoystickInput();
#else // __WIN32__
HRESULT hr;
@@ -1192,7 +1319,6 @@ int startgame(void)
}
/* Need to handle situations where BPP is not what we can handle */
SDL_WM_SetCaption ("ZSNES Linux","ZSNES");
SDL_ShowCursor(0);
@@ -1602,7 +1728,7 @@ SM_CYSCREEN )-WindowHeight);
ShowWindow(hMainWindow, SW_SHOWNORMAL);
SetWindowText(hMainWindow,"ZSNESWIN");
InitInput();
InitJoystickInput();
InitSound();
TestJoy();
}
@@ -1742,9 +1868,10 @@ void UpdateSound(void *userdata, Uint8 *stream, int len)
if (T36HZEnabled) {
Buffer[i]=0;
} else {
if(DSPBuffer[i]>32767)Buffer[i]=32767;
else if(DSPBuffer[i]<-32767)Buffer[i]=-32767;
else Buffer[i]=DSPBuffer[i];
// if(DSPBuffer[i]>32767)Buffer[i]=32767;
// else if(DSPBuffer[i]<-32767)Buffer[i]=-32767;
// else Buffer[i]=DSPBuffer[i];
Buffer[i]=DSPBuffer[i] & 0xFFFF;
}
}
@@ -1781,7 +1908,7 @@ void UpdateVFrame(void)
//STUB_FUNCTION;
Main_Proc();
WinUpdateDevices();
// WinUpdateDevices();
CheckTimers();
if (DTimerCheck == 1)

View File

@@ -1359,7 +1359,7 @@ SECTION .text
; convert it back when writing to it back.
NEWSYM UpdateDevices ; One-time input device init
call WinUpdateDevices
; call WinUpdateDevices
; call DosUpdateDevices
ret
@@ -1505,42 +1505,42 @@ NEWSYM Get_MouseData ; Returns both pressed and coordinates
ret
NEWSYM Set_MouseXMax ; Sets the X boundaries (ecx = left, edx = right)
pushad
or ecx,0FFFh
push ecx
call SetMouseMinX
pop ecx
or edx,0FFFh
push edx
call SetMouseMaxX
pop edx
popad
; pushad
; or ecx,0FFFh
; push ecx
; call SetMouseMinX
; pop ecx
; or edx,0FFFh
; push edx
; call SetMouseMaxX
; pop edx
; popad
ret
NEWSYM Set_MouseYMax ; Sets the Y boundaries (ecx = left, edx = right)
pushad
or ecx,0FFFh
push ecx
call SetMouseMinY
pop ecx
or edx,0FFFh
push edx
call SetMouseMaxY
pop edx
popad
; pushad
; or ecx,0FFFh
; push ecx
; call SetMouseMinY
; pop ecx
; or edx,0FFFh
; push edx
; call SetMouseMaxY
; pop edx
; popad
ret
NEWSYM Set_MousePosition ; Sets Mouse Position (x:cx,y:dx)
pushad
or ecx,0FFFFh
push ecx
call SetMouseX
pop ecx
push edx
or edx,0FFFFh
call SetMouseY
pop edx
popad
; pushad
; or ecx,0FFFFh
; push ecx
; call SetMouseX
; pop ecx
; push edx
; or edx,0FFFFh
; call SetMouseY
; pop edx
; popad
ret
NEWSYM Get_MousePositionDisplacement