comparison src/video/ataricommon/SDL_xbiosevents.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents d910939febfa
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
33 #include "SDL_xbiosevents_c.h" 33 #include "SDL_xbiosevents_c.h"
34 #include "SDL_xbiosinterrupt_s.h" 34 #include "SDL_xbiosinterrupt_s.h"
35 35
36 /* Variables */ 36 /* Variables */
37 37
38 int SDL_AtariXbios_enabled=0; 38 int SDL_AtariXbios_enabled = 0;
39 39
40 /* Local variables */ 40 /* Local variables */
41 41
42 static _KBDVECS *kbdvecs; /* Pointer to access system vectors */ 42 static _KBDVECS *kbdvecs; /* Pointer to access system vectors */
43 static Uint16 atari_prevmouseb; /* buttons */ 43 static Uint16 atari_prevmouseb; /* buttons */
44 44
45 /* Functions */ 45 /* Functions */
46 46
47 void SDL_AtariXbios_InstallVectors(int vectors_mask) 47 void
48 SDL_AtariXbios_InstallVectors (int vectors_mask)
48 { 49 {
49 void *oldpile; 50 void *oldpile;
50 51
51 /* Clear variables */ 52 /* Clear variables */
52 SDL_AtariXbios_mouseb = 53 SDL_AtariXbios_mouseb =
53 SDL_AtariXbios_mousex = 54 SDL_AtariXbios_mousex =
54 SDL_AtariXbios_mousey = 55 SDL_AtariXbios_mousey =
55 SDL_AtariXbios_joystick = 56 SDL_AtariXbios_joystick = atari_prevmouseb = 0;
56 atari_prevmouseb = 0;
57 57
58 if (vectors_mask==0) { 58 if (vectors_mask == 0) {
59 SDL_AtariXbios_enabled=0; 59 SDL_AtariXbios_enabled = 0;
60 return; 60 return;
61 } 61 }
62 62
63 /* Read IKBD vectors base */ 63 /* Read IKBD vectors base */
64 kbdvecs=Kbdvbase(); 64 kbdvecs = Kbdvbase ();
65 65
66 /* Go to supervisor mode */ 66 /* Go to supervisor mode */
67 oldpile=(void *)Super(0); 67 oldpile = (void *) Super (0);
68 68
69 /* Install our vectors */ 69 /* Install our vectors */
70 SDL_AtariXbios_Install( 70 SDL_AtariXbios_Install (kbdvecs,
71 kbdvecs, 71 (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ?
72 (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL, 72 SDL_AtariXbios_MouseVector : NULL,
73 (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL 73 (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ?
74 ); 74 SDL_AtariXbios_JoystickVector : NULL);
75 75
76 /* Back to user mode */ 76 /* Back to user mode */
77 Super(oldpile); 77 Super (oldpile);
78 78
79 SDL_AtariXbios_enabled=1; 79 SDL_AtariXbios_enabled = 1;
80 } 80 }
81 81
82 void SDL_AtariXbios_RestoreVectors(void) 82 void
83 SDL_AtariXbios_RestoreVectors (void)
83 { 84 {
84 void *oldpile; 85 void *oldpile;
85 86
86 if (SDL_AtariXbios_enabled==0) { 87 if (SDL_AtariXbios_enabled == 0) {
87 return; 88 return;
88 } 89 }
89 90
90 /* Read IKBD vectors base */ 91 /* Read IKBD vectors base */
91 kbdvecs=Kbdvbase(); 92 kbdvecs = Kbdvbase ();
92 93
93 /* Go to supervisor mode */ 94 /* Go to supervisor mode */
94 oldpile=(void *)Super(NULL); 95 oldpile = (void *) Super (NULL);
95 96
96 /* Reinstall system vector */ 97 /* Reinstall system vector */
97 SDL_AtariXbios_Restore(kbdvecs); 98 SDL_AtariXbios_Restore (kbdvecs);
98 99
99 /* Back to user mode */ 100 /* Back to user mode */
100 Super(oldpile); 101 Super (oldpile);
101 } 102 }
102 103
103 static int atari_GetButton(int button) 104 static int
105 atari_GetButton (int button)
104 { 106 {
105 switch(button) 107 switch (button) {
106 { 108 case 0:
107 case 0: 109 return SDL_BUTTON_RIGHT;
108 return SDL_BUTTON_RIGHT; 110 break;
109 break; 111 case 1:
110 case 1: 112 default:
111 default: 113 return SDL_BUTTON_LEFT;
112 return SDL_BUTTON_LEFT; 114 break;
113 break; 115 }
114 }
115 } 116 }
116 117
117 void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents) 118 void
119 SDL_AtariXbios_PostMouseEvents (_THIS, SDL_bool buttonEvents)
118 { 120 {
119 if (SDL_AtariXbios_enabled==0) { 121 if (SDL_AtariXbios_enabled == 0) {
120 return; 122 return;
121 } 123 }
122 124
123 /* Mouse motion ? */ 125 /* Mouse motion ? */
124 if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { 126 if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
125 SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); 127 SDL_PrivateMouseMotion (0, 1, SDL_AtariXbios_mousex,
126 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; 128 SDL_AtariXbios_mousey);
127 } 129 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
128 130 }
129 /* Mouse button ? */
130 if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
131 int i;
132 131
133 for (i=0;i<2;i++) { 132 /* Mouse button ? */
134 int curbutton, prevbutton; 133 if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
134 int i;
135 135
136 curbutton = SDL_AtariXbios_mouseb & (1<<i); 136 for (i = 0; i < 2; i++) {
137 prevbutton = atari_prevmouseb & (1<<i); 137 int curbutton, prevbutton;
138 138
139 if (curbutton && !prevbutton) { 139 curbutton = SDL_AtariXbios_mouseb & (1 << i);
140 SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); 140 prevbutton = atari_prevmouseb & (1 << i);
141 } 141
142 if (!curbutton && prevbutton) { 142 if (curbutton && !prevbutton) {
143 SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); 143 SDL_PrivateMouseButton (SDL_PRESSED,
144 } 144 atari_GetButton (i), 0, 0);
145 } 145 }
146 atari_prevmouseb = SDL_AtariXbios_mouseb; 146 if (!curbutton && prevbutton) {
147 } 147 SDL_PrivateMouseButton (SDL_RELEASED,
148 atari_GetButton (i), 0, 0);
149 }
150 }
151 atari_prevmouseb = SDL_AtariXbios_mouseb;
152 }
148 } 153 }
154
155 /* vi: set ts=4 sw=4 expandtab: */