Skip to content

Latest commit

 

History

History
201 lines (157 loc) · 4.56 KB

SDL_xbios_st.c

File metadata and controls

201 lines (157 loc) · 4.56 KB
 
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
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
ST/STE Xbios video functions
Patrice Mandin
*/
#include <mint/cookie.h>
#include <mint/osbind.h>
#include "../SDL_sysvideo.h"
#include "../ataricommon/SDL_atarimxalloc_c.h"
#include "../ataricommon/SDL_ataric2p_s.h"
#include "SDL_xbios.h"
static const xbiosmode_t stmodes[]={
{ST_LOW>>8,320,200,4, XBIOSMODE_C2P}
};
static void listModes(_THIS, int actually_add);
static void saveMode(_THIS, SDL_PixelFormat *vformat);
static void setMode_ST(_THIS, xbiosmode_t *new_video_mode);
static void setMode_STE(_THIS, xbiosmode_t *new_video_mode);
static void restoreMode(_THIS);
Aug 3, 2014
Aug 3, 2014
48
static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp);
49
50
51
52
53
54
55
56
57
58
59
static void swapVbuffers(_THIS);
static int allocVbuffers(_THIS, int num_buffers, int bufsize);
static void freeVbuffers(_THIS);
static int setColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
void SDL_XBIOS_VideoInit_ST(_THIS, unsigned long cookie_cvdo)
{
XBIOS_listModes = listModes;
XBIOS_saveMode = saveMode;
XBIOS_setMode = setMode_ST;
XBIOS_restoreMode = restoreMode;
Aug 3, 2014
Aug 3, 2014
60
XBIOS_getLineWidth = getLineWidth;
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
XBIOS_swapVbuffers = swapVbuffers;
XBIOS_allocVbuffers = allocVbuffers;
XBIOS_freeVbuffers = freeVbuffers;
this->SetColors = setColors;
if ((cookie_cvdo>>16) == VDO_STE) {
XBIOS_setMode = setMode_STE;
}
}
static void listModes(_THIS, int actually_add)
{
SDL_XBIOS_AddMode(this, actually_add, &stmodes[0]);
}
static void saveMode(_THIS, SDL_PixelFormat *vformat)
{
short *oldpalette;
int i;
XBIOS_oldvbase=Physbase();
XBIOS_oldvmode=Getrez();
switch(XBIOS_oldvmode << 8) {
case ST_LOW:
XBIOS_oldnumcol=16;
break;
case ST_MED:
XBIOS_oldnumcol=4;
break;
case ST_HIGH:
XBIOS_oldnumcol=2;
break;
}
oldpalette= (short *) XBIOS_oldpalette;
for (i=0;i<XBIOS_oldnumcol;i++) {
*oldpalette++=Setcolor(i,-1);
}
}
static void setMode_ST(_THIS, xbiosmode_t *new_video_mode)
{
int i;
Setscreen(-1,XBIOS_screens[0],-1);
Setscreen(-1,-1,new_video_mode->number);
/* Reset palette, 8 shades of gray with a bit of green interleaved */
for (i=0;i<16;i++) {
TT_palette[i]= ((i>>1)<<8) | (((i*8)/17)<<4) | (i>>1);
}
Setpalette(TT_palette);
}
static void setMode_STE(_THIS, xbiosmode_t *new_video_mode)
{
int i;
Setscreen(-1,XBIOS_screens[0],-1);
Setscreen(-1,-1,new_video_mode->number);
/* Reset palette, 16 shades of gray */
for (i=0;i<16;i++) {
int c;
c=((i&1)<<3)|((i>>1)&7);
TT_palette[i]=(c<<8)|(c<<4)|c;
}
Setpalette(TT_palette);
}
static void restoreMode(_THIS)
{
Setscreen(-1,XBIOS_oldvbase,XBIOS_oldvmode);
if (XBIOS_oldnumcol) {
Setpalette(XBIOS_oldpalette);
}
}
Aug 3, 2014
Aug 3, 2014
145
146
147
148
149
static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp)
{
return (width * (((bpp==15) ? 16 : bpp)>>3));
}
150
151
152
153
154
155
156
157
158
159
static void swapVbuffers(_THIS)
{
Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
}
static int allocVbuffers(_THIS, int num_buffers, int bufsize)
{
int i;
for (i=0; i<num_buffers; i++) {
Sep 22, 2017
Sep 22, 2017
160
XBIOS_screensmem[i] = Atari_SysMalloc(bufsize+256, MX_STRAM);
161
162
163
164
165
if (XBIOS_screensmem[i]==NULL) {
SDL_SetError("Can not allocate %d KB for buffer %d", bufsize>>10, i);
return (0);
}
Sep 22, 2017
Sep 22, 2017
166
SDL_memset(XBIOS_screensmem[i], 0, bufsize+256);
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
XBIOS_screens[i]=(void *) (( (long) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL);
}
return (1);
}
static void freeVbuffers(_THIS)
{
int i;
for (i=0;i<2;i++) {
if (XBIOS_screensmem[i]) {
Mfree(XBIOS_screensmem[i]);
}
XBIOS_screensmem[i]=NULL;
}
}
static int setColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
int i, r,g,b;
for (i=0;i<ncolors;i++) {
r = colors[i].r;
g = colors[i].g;
b = colors[i].b;
TT_palette[firstcolor+i]=((r*30)+(g*59)+(b*11))/100;
}
SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */
return(1);
}