forked from AmigaPorts/libSDL12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDL_amigasas.c
183 lines (137 loc) · 7.72 KB
/
SDL_amigasas.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/******************************************************************************/
/* */
/* includes */
/* */
/******************************************************************************/
#include <exec/types.h>
#include <proto/exec.h>
#include "mydebug.h"
/******************************************************************************/
/* */
/* global declarations */
/* */
/******************************************************************************/
extern struct ExecBase *SysBase;
extern struct DosLibrary *DOSBase;
extern struct Library *UtilityBase;
/******************************************************************************/
/* */
/* user library initialization */
/* */
/* !!! CAUTION: This function may run in a forbidden state !!! */
/* */
/******************************************************************************/
int __saveds __asm
__UserLibInit(register __a6 struct Library *libbase) {
/* required !!! */
SysBase = *(struct ExecBase **)4;
D(bug("***SDL.library init: %lx\n", libbase));
if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 39L))) {
D(bug("unable to open dos.library\n"));
return 1;
}
if ( !(UtilityBase = OpenLibrary("utility.library", 37L))) {
D(bug("***unable to open utility.library.\n"));
CloseLibrary((struct Library *)DOSBase);
return 1;
}
return 0;
}
/******************************************************************************/
/* */
/* user library cleanup */
/* */
/* !!! CAUTION: This function runs in a forbidden state !!! */
/* */
/******************************************************************************/
void __saveds __asm
__UserLibCleanup(register __a6 struct Library *myLib) {
D(bug("***SDL.library cleanup\n"));
CloseLibrary(UtilityBase);
CloseLibrary((struct Library *)DOSBase);
}
/******************************************************************************/
/* */
/* library dependent function(s) */
/* */
/******************************************************************************/
#define ADDTABL_0(x) \
__saveds __asm LIB##x(void) \
{ \
extern __stdargs long x(void); \
return x(); \
}
#define ADDTABL_1(x, y) \
__saveds __asm LIB##x(register __##y long arg1) \
{ \
extern __stdargs long x(long); \
return x(arg1); \
}
#define ADDTABL_2(x, y, z) \
__saveds __asm LIB##x(register __##y long arg1, register __##z long arg2) \
{ \
extern __stdargs long x(long, long); \
return x(arg1, arg2); \
}
#define ADDTABL_3(x, y, z, t) \
__saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3) \
{ \
extern __stdargs long x(long, long, long); \
return x(arg1, arg2, arg3); \
}
#define ADDTABL_4(x, y, z, t, v) \
__saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3, register __##v long arg4) \
{ \
extern __stdargs long x(long, long, long, long); \
return x(arg1, arg2, arg3, arg4); \
}
#define ADDTABL_5(x, y, z, t, v, k) \
__saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3, register __##v long arg4, register __##k long arg5) \
{ \
extern __stdargs long x(long, long, long, long, long); \
return x(arg1, arg2, arg3, arg4, arg5); \
}
ADDTABL_1(SDL_Init, d0) /* One Argument in d0 */
ADDTABL_0(SDL_Quit)
ADDTABL_1(SDL_InitSubSystem, d0)
ADDTABL_1(SDL_QuitSubSystem, d0)
ADDTABL_1(SDL_WasInit, d0)
ADDTABL_0(SDL_GetError)
ADDTABL_2(SDL_RWFromFile, a0, d0)
ADDTABL_2(SDL_RWFromFP, a0, d0)
ADDTABL_2(SDL_RWFromMem, a0, d0)
// video
ADDTABL_2(SDL_LoadBMP_RW, a0, d0)
ADDTABL_3(SDL_SetColorKey, a0, d0, d1)
ADDTABL_1(SDL_DisplayFormat, a0)
ADDTABL_1(SDL_FreeSurface, a0)
ADDTABL_3(SDL_FillRect, a0, a1, d0)
ADDTABL_4(SDL_UpperBlit, a0, d0, a1, d1)
ADDTABL_1(SDL_Flip, a0)
ADDTABL_3(SDL_UpdateRects, a0, d0, a1)
ADDTABL_5(SDL_UpdateRect, a0, d0, d1, d2, d3)
ADDTABL_0(SDL_GetVideoInfo)
ADDTABL_4(SDL_SetVideoMode, d0, d1, d2, d3)
ADDTABL_4(SDL_MapRGB, a0, d0, d1, d2)
// timer
ADDTABL_0(SDL_GetTicks)
ADDTABL_1(SDL_Delay, d0)
// events
ADDTABL_1(SDL_PollEvent, a0)
ADDTABL_1(SDL_WaitEvent, a0)
ADDTABL_4(SDL_PeepEvents, a0, d0, d1, d2)
/******************************************************************************/
/* */
/* endtable marker (required!) */
/* */
/******************************************************************************/
// ADDTABL_END()
void _XCEXIT(void) {
D(bug("Warning SDL.library attempted exit, sleeping forever!\n"));
Wait(0); // resto in wait forever
}
/******************************************************************************/
/* */
/* end of simplelib.c */
/* */
/******************************************************************************/