diff options
author | Franklin Wei <git@fwei.tk> | 2017-01-21 15:18:31 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-12-23 21:01:26 -0500 |
commit | a855d6202536ff28e5aae4f22a0f31d8f5b325d0 (patch) | |
tree | 8c75f224dd64ed360505afa8843d016b0d75000b /apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c | |
parent | 01c6dcf6c7b9bb1ad2fa0450f99bacc5f3d3e04b (diff) | |
download | rockbox-a855d6202536ff28e5aae4f22a0f31d8f5b325d0.tar.gz rockbox-a855d6202536ff28e5aae4f22a0f31d8f5b325d0.zip |
Port of Duke Nukem 3D
This ports Fabien Sanglard's Chocolate Duke to run on a version of SDL
for Rockbox.
Change-Id: I8f2c4c78af19de10c1633ed7bb7a997b43256dd9
Diffstat (limited to 'apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c')
-rw-r--r-- | apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c new file mode 100644 index 0000000000..232500f7ae --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * XBIOS mouse & joystick vectors | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #include <mint/osbind.h> | ||
31 | |||
32 | #include "../../events/SDL_events_c.h" | ||
33 | #include "SDL_atarisuper.h" | ||
34 | #include "SDL_xbiosevents_c.h" | ||
35 | #include "SDL_xbiosinterrupt_s.h" | ||
36 | |||
37 | /* Variables */ | ||
38 | |||
39 | int SDL_AtariXbios_enabled=0; | ||
40 | |||
41 | /* Local variables */ | ||
42 | |||
43 | static _KBDVECS *kbdvecs; /* Pointer to access system vectors */ | ||
44 | static Uint16 atari_prevmouseb; /* buttons */ | ||
45 | |||
46 | /* Functions */ | ||
47 | |||
48 | void SDL_AtariXbios_InstallVectors(int vectors_mask) | ||
49 | { | ||
50 | void *oldpile; | ||
51 | |||
52 | /* Clear variables */ | ||
53 | SDL_AtariXbios_mouselock = | ||
54 | SDL_AtariXbios_mouseb = | ||
55 | SDL_AtariXbios_mousex = | ||
56 | SDL_AtariXbios_mousey = | ||
57 | SDL_AtariXbios_joystick = | ||
58 | atari_prevmouseb = 0; | ||
59 | |||
60 | if (vectors_mask==0) { | ||
61 | SDL_AtariXbios_enabled=0; | ||
62 | return; | ||
63 | } | ||
64 | |||
65 | /* Read IKBD vectors base */ | ||
66 | kbdvecs=Kbdvbase(); | ||
67 | |||
68 | /* Go to supervisor mode */ | ||
69 | oldpile=(void *)Super(0); | ||
70 | |||
71 | /* Install our vectors */ | ||
72 | SDL_AtariXbios_Install( | ||
73 | kbdvecs, | ||
74 | (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL, | ||
75 | (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL | ||
76 | ); | ||
77 | |||
78 | /* Back to user mode */ | ||
79 | SuperToUser(oldpile); | ||
80 | |||
81 | SDL_AtariXbios_enabled=1; | ||
82 | } | ||
83 | |||
84 | void SDL_AtariXbios_RestoreVectors(void) | ||
85 | { | ||
86 | void *oldpile; | ||
87 | |||
88 | if (SDL_AtariXbios_enabled==0) { | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | /* Read IKBD vectors base */ | ||
93 | kbdvecs=Kbdvbase(); | ||
94 | |||
95 | /* Go to supervisor mode */ | ||
96 | oldpile=(void *)Super(NULL); | ||
97 | |||
98 | /* Reinstall system vector */ | ||
99 | SDL_AtariXbios_Restore(kbdvecs); | ||
100 | |||
101 | /* Back to user mode */ | ||
102 | SuperToUser(oldpile); | ||
103 | } | ||
104 | |||
105 | static int atari_GetButton(int button) | ||
106 | { | ||
107 | switch(button) | ||
108 | { | ||
109 | case 0: | ||
110 | return SDL_BUTTON_RIGHT; | ||
111 | break; | ||
112 | case 1: | ||
113 | default: | ||
114 | return SDL_BUTTON_LEFT; | ||
115 | break; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents) | ||
120 | { | ||
121 | if (SDL_AtariXbios_enabled==0) { | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | /* Mouse motion ? */ | ||
126 | if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { | ||
127 | SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); | ||
128 | SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; | ||
129 | } | ||
130 | |||
131 | /* Mouse button ? */ | ||
132 | if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) { | ||
133 | int i; | ||
134 | |||
135 | for (i=0;i<2;i++) { | ||
136 | int curbutton, prevbutton; | ||
137 | |||
138 | curbutton = SDL_AtariXbios_mouseb & (1<<i); | ||
139 | prevbutton = atari_prevmouseb & (1<<i); | ||
140 | |||
141 | if (curbutton && !prevbutton) { | ||
142 | SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | ||
143 | } | ||
144 | if (!curbutton && prevbutton) { | ||
145 | SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | ||
146 | } | ||
147 | } | ||
148 | atari_prevmouseb = SDL_AtariXbios_mouseb; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition) | ||
153 | { | ||
154 | SDL_AtariXbios_mouselock = lockPosition; | ||
155 | } | ||