This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_gemvideo.c
208 lines (166 loc) · 5.41 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2006 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
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20
21
Sam Lantinga
slouken@libsdl.org
*/
22
#include "SDL_config.h"
23
24
/*
25
26
27
28
29
30
GEM video driver
Patrice Mandin
and work from
Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
*/
31
32
33
34
35
/* Mint includes */
#include <gem.h>
#include <gemx.h>
#include <mint/osbind.h>
36
#include <mint/cookie.h>
37
38
39
#include "SDL_video.h"
#include "SDL_mouse.h"
40
41
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
42
43
44
45
#include "SDL_gemvideo.h"
/* Initialization/Query functions */
46
static int GEM_VideoInit(_THIS);
47
48
static void GEM_VideoQuit(_THIS);
49
50
static void GEM_GL_SwapBuffers(_THIS);
51
52
53
static int
GEM_Available(void)
54
{
55
56
57
/* Test if AES available */
if (appl_init() == -1)
return 0;
58
59
60
appl_exit();
return 1;
61
62
}
63
64
static void
GEM_DeleteDevice(SDL_VideoDevice * device)
65
{
66
67
68
SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
SDL_free(device->driverdata);
69
SDL_free(device);
70
71
}
72
73
static SDL_VideoDevice *
GEM_CreateDevice(int devindex)
74
{
75
SDL_VideoDevice *device;
76
SDL_VideoData *data;
77
78
/* Initialize all variables that we clean on shutdown */
79
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
80
if (device) {
81
data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
82
}
83
if (!device || !data) {
84
85
86
87
SDL_OutOfMemory();
if (device) {
SDL_free(device);
}
88
return NULL;
89
}
90
device->driverdata = data;
91
92
93
94
/* Set the function pointers */
device->VideoInit = GEM_VideoInit;
device->VideoQuit = GEM_VideoQuit;
95
96
device->GetDisplayModes = GEM_GetDisplayModes;
device->SetDisplayMode = GEM_SetDisplayMode;
97
98
device->PumpEvents = GEM_PumpEvents;
99
100
101
102
103
104
105
106
107
108
109
110
111
112
device->CreateWindow = GEM_CreateWindow;
device->CreateWindowFrom = GEM_CreateWindowFrom;
device->SetWindowTitle = GEM_SetWindowTitle;
device->SetWindowPosition = GEM_SetWindowPosition;
device->SetWindowSize = GEM_SetWindowSize;
device->ShowWindow = GEM_ShowWindow;
device->HideWindow = GEM_HideWindow;
device->RaiseWindow = GEM_RaiseWindow;
device->MaximizeWindow = GEM_MaximizeWindow;
device->MinimizeWindow = GEM_MinimizeWindow;
device->RestoreWindow = GEM_RestoreWindow;
device->SetWindowGrab = GEM_SetWindowGrab;
device->DestroyWindow = GEM_DestroyWindow;
device->GetWindowWMInfo = GEM_GetWindowWMInfo;
113
114
#if SDL_VIDEO_OPENGL
115
116
device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
117
device->GL_CreateContext = SDL_AtariGL_CreateContext;
118
device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
119
120
121
122
device->GL_SetSwapInterval = SDL_AtariGL_SetSwapInterval;
device->GL_GetSwapInterval = SDL_AtariGL_GetSwapInterval;
device->GL_SwapWindow = GEM_GL_SwapWindow;
device->GL_DeleteContext = SDL_AtariGL_DeleteContext;
123
124
#endif
125
device->free = GEM_DeleteDevice;
126
127
return device;
128
129
130
}
VideoBootStrap GEM_bootstrap = {
131
"gem", "Atari GEM video driver",
132
GEM_Available, GEM_CreateDevice
133
134
};
135
int
136
GEM_VideoInit(_THIS)
137
{
138
int i;
139
short work_in[12], work_out[272], dummy;
140
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
141
142
143
144
145
146
147
148
/* Open AES (Application Environment Services) */
if (appl_init() == -1) {
fprintf(stderr, "Can not open AES\n");
return 1;
}
/* Read version and features */
149
150
if (aes_global[0] >= 0x0410) {
short ap_gout[4];
151
152
153
data->wfeatures = 0;
if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2],
154
&ap_gout[3]) == 0) {
155
data->wfeatures = ap_gout[0];
156
157
158
159
}
}
/* Ask VDI physical workstation handle opened by AES */
160
data->vdi_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
161
162
163
164
165
166
167
/* Open virtual VDI workstation */
work_in[0] = Getrez() + 2;
for (i = 1; i < 10; i++)
work_in[i] = 1;
work_in[10] = 2;
168
169
v_opnvwk(work_in, &(data->vdi_handle), work_out);
if (data->vdi_handle == 0) {
170
171
172
173
174
175
fprintf(stderr, "Can not open VDI virtual workstation\n");
return 1;
}
/* Set mouse cursor to arrow */
graf_mouse(ARROW, NULL);
176
177
/* Setup VDI fill functions */
178
179
180
vsf_color(data->vdi_handle, 0);
vsf_interior(data->vdi_handle, 1);
vsf_perimeter(data->vdi_handle, 0);
181
182
GEM_InitModes(_this);
183
184
185
GEM_InitKeyboard(_this);
GEM_InitMouse(_this);
186
187
return (0);
188
189
}
190
191
void
GEM_VideoQuit(_THIS)
192
{
193
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
194
195
196
GEM_QuitMouse(_this);
GEM_QuitKeyboard(_this);
197
198
GEM_QuitModes(_this);
199
200
/* Close VDI workstation */
201
202
if (data->vdi_handle) {
v_clsvwk(data->vdi_handle);
203
204
}
205
appl_exit();
206
207
}
208
/* vi: set ts=4 sw=4 expandtab: */