Skip to content

Latest commit

 

History

History
837 lines (708 loc) · 19.3 KB

SDL_xbios.c

File metadata and controls

837 lines (708 loc) · 19.3 KB
 
1
2
/*
SDL - Simple DirectMedia Layer
Jan 4, 2004
Jan 4, 2004
3
Copyright (C) 1997-2004 Sam Lantinga
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
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
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Xbios SDL video driver
*
* Patrice Mandin
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
/* Mint includes */
Dec 7, 2002
Dec 7, 2002
41
#include <mint/cookie.h>
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <mint/osbind.h>
#include <mint/falcon.h>
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
#include "SDL_pixels_c.h"
#include "SDL_events_c.h"
#include "SDL_ataric2p_s.h"
#include "SDL_atarievents_c.h"
#include "SDL_atarimxalloc_c.h"
#include "SDL_xbios.h"
#define XBIOS_VID_DRIVER_NAME "xbios"
Nov 12, 2003
Nov 12, 2003
60
61
/*#define DEBUG_VIDEO_XBIOS 1*/
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
/* Initialization/Query functions */
static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat);
static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
static void XBIOS_VideoQuit(_THIS);
/* Hardware surface functions */
static int XBIOS_AllocHWSurface(_THIS, SDL_Surface *surface);
static int XBIOS_LockHWSurface(_THIS, SDL_Surface *surface);
static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface);
static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface *surface);
static void XBIOS_FreeHWSurface(_THIS, SDL_Surface *surface);
static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
/* List of video modes */
/* ST modes */
static int xbiosnummodes_st=1;
static xbiosmode_t xbiosmodelist_st[]={
{ST_LOW>>8,320,200,4,SDL_FALSE}
};
/* TT modes */
static int xbiosnummodes_tt=2;
static xbiosmode_t xbiosmodelist_tt[]={
{TT_LOW,320,480,8,SDL_FALSE},
{TT_LOW,320,240,8,SDL_TRUE} /* Software double-lined mode */
};
/* Falcon RVB modes */
static int xbiosnummodes_f30rvb=16;
static xbiosmode_t xbiosmodelist_f30rvb[]={
{BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,SDL_FALSE},
{BPS16|OVERSCAN|VERTFLAG,384,480,16,SDL_FALSE},
Feb 7, 2004
Feb 7, 2004
97
{BPS16|COL80|VERTFLAG,640,400,16,SDL_FALSE},
98
{BPS16|VERTFLAG,320,400,16,SDL_FALSE},
Feb 7, 2004
Feb 7, 2004
99
100
101
{BPS16|COL80|OVERSCAN,768,240,16,SDL_FALSE},
{BPS16|OVERSCAN,384,240,16,SDL_FALSE},
{BPS16|COL80,640,200,16,SDL_FALSE},
102
103
104
105
{BPS16,320,200,16,SDL_FALSE},
{BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,SDL_FALSE},
{BPS8|OVERSCAN|VERTFLAG,384,480,8,SDL_FALSE},
Feb 7, 2004
Feb 7, 2004
106
{BPS8|COL80|VERTFLAG,640,400,8,SDL_FALSE},
107
{BPS8|VERTFLAG,320,400,8,SDL_FALSE},
Feb 7, 2004
Feb 7, 2004
108
109
110
{BPS8|COL80|OVERSCAN,768,240,8,SDL_FALSE},
{BPS8|OVERSCAN,384,240,8,SDL_FALSE},
{BPS8|COL80,640,200,8,SDL_FALSE},
111
112
113
114
115
116
117
118
119
120
121
{BPS8,320,200,8,SDL_FALSE}
};
/* Falcon VGA modes */
static int xbiosnummodes_f30vga=6;
static xbiosmode_t xbiosmodelist_f30vga[]={
{BPS16,320,480,16,SDL_FALSE},
{BPS16|VERTFLAG,320,240,16,SDL_FALSE},
{BPS8|COL80,640,480,8,SDL_FALSE},
{BPS8,320,480,8,SDL_FALSE},
Feb 7, 2004
Feb 7, 2004
122
{BPS8|COL80|VERTFLAG,640,240,8,SDL_FALSE},
123
124
125
126
127
128
129
130
131
132
133
134
{BPS8|VERTFLAG,320,240,8,SDL_FALSE}
};
/* To setup palette */
static unsigned short TT_palette[256];
static unsigned long F30_palette[256];
/* Xbios driver bootstrap functions */
static int XBIOS_Available(void)
{
Jan 31, 2004
Jan 31, 2004
135
136
137
138
139
140
141
unsigned long cookie_vdo, cookie_mil, cookie_hade;
/* Milan/Hades Atari clones do not have an Atari video chip */
if ( (Getcookie(C__MIL, &cookie_mil) == C_FOUND) ||
(Getcookie(C_hade, &cookie_hade) == C_FOUND) ) {
return 0;
}
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/* Cookie _VDO present ? if not, assume ST machine */
if (Getcookie(C__VDO, &cookie_vdo) != C_FOUND) {
cookie_vdo = VDO_ST << 16;
}
/* Test if we have a monochrome monitor plugged in */
switch( cookie_vdo >>16) {
case VDO_ST:
case VDO_STE:
if ( Getrez() == (ST_HIGH>>8) )
return 0;
break;
case VDO_TT:
if ( (EgetShift() & ES_MODE) == TT_HIGH)
return 0;
break;
case VDO_F30:
if ( Montype() == MONITOR_MONO)
return 0;
break;
default:
return 0;
}
return 1;
}
static void XBIOS_DeleteDevice(SDL_VideoDevice *device)
{
free(device->hidden);
free(device);
}
static SDL_VideoDevice *XBIOS_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
if ( device ) {
memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *)
malloc((sizeof *device->hidden));
}
if ( (device == NULL) || (device->hidden == NULL) ) {
SDL_OutOfMemory();
if ( device ) {
free(device);
}
return(0);
}
memset(device->hidden, 0, (sizeof *device->hidden));
/* Video functions */
device->VideoInit = XBIOS_VideoInit;
device->ListModes = XBIOS_ListModes;
device->SetVideoMode = XBIOS_SetVideoMode;
device->SetColors = XBIOS_SetColors;
device->UpdateRects = NULL;
device->VideoQuit = XBIOS_VideoQuit;
device->AllocHWSurface = XBIOS_AllocHWSurface;
device->LockHWSurface = XBIOS_LockHWSurface;
device->UnlockHWSurface = XBIOS_UnlockHWSurface;
device->FlipHWSurface = XBIOS_FlipHWSurface;
device->FreeHWSurface = XBIOS_FreeHWSurface;
/* Events */
device->InitOSKeymap = Atari_InitOSKeymap;
device->PumpEvents = Atari_PumpEvents;
device->free = XBIOS_DeleteDevice;
return device;
}
VideoBootStrap XBIOS_bootstrap = {
XBIOS_VID_DRIVER_NAME, "Atari Xbios driver",
XBIOS_Available, XBIOS_CreateDevice
};
static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
int i,j8,j16;
xbiosmode_t *current_mode;
/* Initialize all variables that we clean on shutdown */
memset (SDL_modelist, 0, sizeof(SDL_modelist));
/* Cookie _VDO present ? if not, assume ST machine */
if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) {
XBIOS_cvdo = VDO_ST << 16;
}
/* Allocate memory for old palette */
XBIOS_oldpalette = (void *)malloc(256*sizeof(long));
if ( !XBIOS_oldpalette ) {
SDL_SetError("Unable to allocate memory for old palette\n");
return(-1);
}
/* Initialize video mode list */
/* and save current screen status (palette, screen address, video mode) */
switch (XBIOS_cvdo >>16) {
case VDO_ST:
case VDO_STE:
{
short *oldpalette;
XBIOS_nummodes=xbiosnummodes_st;
XBIOS_modelist=xbiosmodelist_st;
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;
default:
XBIOS_oldnumcol=0;
break;
}
oldpalette= (short *) XBIOS_oldpalette;
for (i=0;i<XBIOS_oldnumcol;i++) {
*oldpalette++=Setcolor(i,-1);
}
vformat->BitsPerPixel = 8;
}
break;
case VDO_TT:
XBIOS_nummodes=xbiosnummodes_tt;
XBIOS_modelist=xbiosmodelist_tt;
XBIOS_oldvbase=Logbase();
XBIOS_oldvmode=EgetShift();
switch(XBIOS_oldvmode & ES_MODE) {
case TT_LOW:
XBIOS_oldnumcol=256;
break;
case ST_LOW:
case TT_MED:
XBIOS_oldnumcol=16;
break;
case ST_MED:
XBIOS_oldnumcol=4;
break;
case ST_HIGH:
case TT_HIGH:
XBIOS_oldnumcol=2;
break;
default:
XBIOS_oldnumcol=0;
break;
}
if (XBIOS_oldnumcol) {
EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
}
vformat->BitsPerPixel = 8;
break;
case VDO_F30:
switch (Montype())
{
case MONITOR_MONO:
/* Not usable */
break;
case MONITOR_RGB:
case MONITOR_TV:
XBIOS_nummodes = xbiosnummodes_f30rvb;
XBIOS_modelist = xbiosmodelist_f30rvb;
break;
case MONITOR_VGA:
XBIOS_nummodes = xbiosnummodes_f30vga;
XBIOS_modelist = xbiosmodelist_f30vga;
break;
}
XBIOS_oldvbase=Logbase();
XBIOS_oldvmode=Vsetmode(-1);
XBIOS_oldnumcol= 1<< (1 << (XBIOS_oldvmode & NUMCOLS));
if (XBIOS_oldnumcol > 256) {
XBIOS_oldnumcol = 0;
}
if (XBIOS_oldnumcol) {
VgetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
}
vformat->BitsPerPixel = 16;
/* Keep vga/rvb, and pal/ntsc bits */
current_mode = XBIOS_modelist;
for (i=0;i<XBIOS_nummodes;i++) {
Uint16 newvmode;
newvmode = current_mode->number;
newvmode &= ~(VGA|PAL);
newvmode |= XBIOS_oldvmode & (VGA|PAL);
current_mode->number = newvmode;
current_mode++;
}
break;
}
current_mode = XBIOS_modelist;
j8 = j16 = 0;
for (i=0;i<XBIOS_nummodes;i++) {
switch (current_mode->depth) {
case 4:
case 8:
SDL_modelist[0][j8] = malloc(sizeof(SDL_Rect));
SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0;
SDL_modelist[0][j8]->w = current_mode->width;
SDL_modelist[0][j8]->h = current_mode->height;
XBIOS_videomodes[0][j8]=current_mode;
current_mode++;
j8++;
break;
case 16:
SDL_modelist[1][j16] = malloc(sizeof(SDL_Rect));
SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0;
SDL_modelist[1][j16]->w = current_mode->width;
SDL_modelist[1][j16]->h = current_mode->height;
XBIOS_videomodes[1][j16]=current_mode;
current_mode++;
j16++;
break;
}
}
SDL_modelist[0][j8] = NULL;
SDL_modelist[1][j16] = NULL;
XBIOS_screens[0]=NULL;
XBIOS_screens[1]=NULL;
XBIOS_shadowscreen=NULL;
/* Update hardware info */
this->info.hw_available = 1;
this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM);
/* Init chunky to planar routine */
Nov 12, 2003
Nov 12, 2003
394
SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
395
396
397
398
399
400
401
402
403
/* We're done! */
return(0);
}
static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
{
/* 8 bits -> list 0 */
/* 16 bits -> list 1 */
Sep 3, 2003
Sep 3, 2003
404
if ((format->BitsPerPixel != 8) && (format->BitsPerPixel !=16)) {
Sep 2, 2003
Sep 2, 2003
405
406
407
return NULL;
}
Sep 3, 2003
Sep 3, 2003
408
return(SDL_modelist[(format->BitsPerPixel)>>4]);
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
}
static void XBIOS_FreeBuffers(_THIS)
{
int i;
for (i=0;i<2;i++) {
if (XBIOS_screensmem[i]!=NULL) {
Mfree(XBIOS_screensmem[i]);
XBIOS_screensmem[i]=NULL;
}
}
if (XBIOS_shadowscreen!=NULL) {
Mfree(XBIOS_shadowscreen);
XBIOS_shadowscreen=NULL;
}
}
static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
int width, int height, int bpp, Uint32 flags)
{
int mode, new_depth;
int i;
xbiosmode_t *new_video_mode;
Uint32 new_screen_size;
Uint32 modeflags;
/* Free current buffers */
XBIOS_FreeBuffers(this);
Feb 7, 2004
Feb 7, 2004
440
441
442
443
/* Limit bpp */
if (bpp>16) {
bpp = 16;
}
444
bpp >>= 4;
Feb 7, 2004
Feb 7, 2004
445
446
/* Search if the mode exists (width, height, bpp) */
447
448
449
450
451
452
453
454
455
456
457
458
for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) {
if ( (SDL_modelist[bpp][mode]->w == width) &&
(SDL_modelist[bpp][mode]->h == height) ) {
break;
}
}
if ( SDL_modelist[bpp][mode] == NULL ) {
SDL_SetError("Couldn't find requested mode in list");
return(NULL);
}
Oct 5, 2002
Oct 5, 2002
459
modeflags = SDL_FULLSCREEN;
460
461
462
463
464
/* Allocate needed buffers: simple/double buffer and shadow surface */
new_video_mode = XBIOS_videomodes[bpp][mode];
new_depth = new_video_mode->depth;
if (new_depth == 4) {
Nov 12, 2003
Nov 12, 2003
465
SDL_Atari_C2pConvert = SDL_Atari_C2pConvert4;
466
467
468
new_depth=8;
modeflags |= SDL_SWSURFACE;
} else if (new_depth == 8) {
Nov 12, 2003
Nov 12, 2003
469
SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
Oct 5, 2002
Oct 5, 2002
470
modeflags |= SDL_SWSURFACE|SDL_HWPALETTE;
471
472
473
474
475
476
477
478
479
480
481
482
483
484
} else {
modeflags |= SDL_HWSURFACE;
}
new_screen_size = width * height * ((new_depth)>>3);
new_screen_size += 256; /* To align on a 256 byte adress */
if (new_depth == 8) {
XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM);
if (XBIOS_shadowscreen == NULL) {
SDL_SetError("XBIOS_SetVideoMode: Not enough memory for shadow surface");
return (NULL);
}
Feb 27, 2002
Feb 27, 2002
485
memset(XBIOS_shadowscreen, 0, new_screen_size);
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
}
/* Output buffer needs to be twice in size for the software double-line mode */
XBIOS_doubleline = SDL_FALSE;
if (new_video_mode->doubleline) {
new_screen_size <<= 1;
XBIOS_doubleline = SDL_TRUE;
}
XBIOS_screensmem[0] = Atari_SysMalloc(new_screen_size, MX_STRAM);
if (XBIOS_screensmem[0]==NULL) {
XBIOS_FreeBuffers(this);
SDL_SetError("XBIOS_SetVideoMode: Not enough memory for video buffer");
return (NULL);
}
Feb 27, 2002
Feb 27, 2002
502
memset(XBIOS_screensmem[0], 0, new_screen_size);
503
504
505
506
507
508
509
510
511
512
513
514
XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL);
/* Double buffer ? */
if (flags & SDL_DOUBLEBUF) {
XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM);
if (XBIOS_screensmem[1]==NULL) {
XBIOS_FreeBuffers(this);
SDL_SetError("XBIOS_SetVideoMode: Not enough memory for double buffer");
return (NULL);
}
Feb 27, 2002
Feb 27, 2002
515
memset(XBIOS_screensmem[1], 0, new_screen_size);
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL);
modeflags |= SDL_DOUBLEBUF;
}
/* Allocate the new pixel format for the screen */
if ( ! SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0) ) {
XBIOS_FreeBuffers(this);
SDL_SetError("Couldn't allocate new pixel format for requested mode");
return(NULL);
}
current->flags = modeflags;
current->w = XBIOS_width = width;
current->h = XBIOS_height = height;
current->pitch = (width * new_depth)>>3;
/* this is for C2P conversion */
XBIOS_pitch = (new_video_mode->width * new_video_mode->depth)>>3;
if (new_depth == 8)
current->pixels = XBIOS_shadowscreen;
else
current->pixels = XBIOS_screens[0];
XBIOS_fbnum = 0;
/* Now set the video mode */
Nov 12, 2003
Nov 12, 2003
544
#ifndef DEBUG_VIDEO_XBIOS
545
Setscreen(-1,XBIOS_screens[0],-1);
Nov 12, 2003
Nov 12, 2003
546
#endif
547
548
549
switch(XBIOS_cvdo >> 16) {
case VDO_ST:
Nov 12, 2003
Nov 12, 2003
550
#ifndef DEBUG_VIDEO_XBIOS
551
Setscreen(-1,-1,new_video_mode->number);
Nov 12, 2003
Nov 12, 2003
552
#endif
553
554
555
556
557
558
559
560
561
562
563
564
/* Reset palette */
for (i=0;i<16;i++) {
int c;
c = ((i>>1)<<8) | ((i>>1)<<4) | (i>>1);
if ((i & 1) && (i<15))
c += (1<<4);
if (i==14)
c -= 1<<8;
TT_palette[i]= c;
}
Nov 12, 2003
Nov 12, 2003
565
#ifndef DEBUG_VIDEO_XBIOS
566
Setpalette(TT_palette);
Nov 12, 2003
Nov 12, 2003
567
#endif
568
569
break;
case VDO_STE:
Nov 12, 2003
Nov 12, 2003
570
#ifndef DEBUG_VIDEO_XBIOS
571
Setscreen(-1,-1,new_video_mode->number);
Nov 12, 2003
Nov 12, 2003
572
#endif
573
574
575
576
577
578
579
580
/* Reset palette */
for (i=0;i<16;i++)
{
int c;
c=((i&1)<<3)|((i>>1)&7);
TT_palette[i]=(c<<8)|(c<<4)|c;
}
Nov 12, 2003
Nov 12, 2003
581
#ifndef DEBUG_VIDEO_XBIOS
582
Setpalette(TT_palette);
Nov 12, 2003
Nov 12, 2003
583
#endif
584
585
break;
case VDO_TT:
Nov 12, 2003
Nov 12, 2003
586
#ifndef DEBUG_VIDEO_XBIOS
587
EsetShift(new_video_mode->number);
Nov 12, 2003
Nov 12, 2003
588
#endif
589
590
break;
case VDO_F30:
Nov 12, 2003
Nov 12, 2003
591
#ifndef DEBUG_VIDEO_XBIOS
592
Vsetmode(new_video_mode->number);
Nov 12, 2003
Nov 12, 2003
593
#endif
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
break;
}
Vsync();
this->UpdateRects = XBIOS_UpdateRects;
return (current);
}
/* We don't actually allow hardware surfaces other than the main one */
static int XBIOS_AllocHWSurface(_THIS, SDL_Surface *surface)
{
return(-1);
}
static void XBIOS_FreeHWSurface(_THIS, SDL_Surface *surface)
{
return;
}
static int XBIOS_LockHWSurface(_THIS, SDL_Surface *surface)
{
return(0);
}
static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface *surface)
{
return;
}
static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
{
SDL_Surface *surface;
Mar 22, 2002
Mar 22, 2002
628
629
630
surface = this->screen;
Mar 22, 2002
Mar 22, 2002
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
if ((surface->format->BitsPerPixel) == 8) {
void *destscr;
int destx;
int i;
/* Center on destination screen */
destscr = XBIOS_screens[XBIOS_fbnum];
destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1);
destx = (XBIOS_width - surface->w) >> 1;
destx &= ~15;
destscr += destx;
for (i=0;i<numrects;i++) {
void *source,*destination;
int x1,x2;
x1 = rects[i].x & ~15;
Mar 26, 2002
Mar 26, 2002
648
649
650
651
x2 = rects[i].x+rects[i].w;
if (x2 & 15) {
x2 = (x2 | 15) +1;
}
Mar 22, 2002
Mar 22, 2002
652
653
654
655
656
657
658
659
660
661
source = surface->pixels;
source += surface->pitch * rects[i].y;
source += x1;
destination = destscr;
destination += XBIOS_pitch * rects[i].y;
destination += x1;
/* Convert chunky to planar screen */
Nov 12, 2003
Nov 12, 2003
662
SDL_Atari_C2pConvert(
Mar 22, 2002
Mar 22, 2002
663
664
665
666
667
668
669
670
671
672
673
source,
destination,
x2-x1,
rects[i].h,
XBIOS_doubleline,
surface->pitch,
XBIOS_pitch
);
}
}
Nov 12, 2003
Nov 12, 2003
674
#ifndef DEBUG_VIDEO_XBIOS
Mar 22, 2002
Mar 22, 2002
675
Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
Nov 12, 2003
Nov 12, 2003
676
#endif
Mar 22, 2002
Mar 22, 2002
677
678
679
680
681
682
683
684
Vsync();
if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
XBIOS_fbnum ^= 1;
if ((surface->format->BitsPerPixel) > 8) {
surface->pixels=XBIOS_screens[XBIOS_fbnum];
}
}
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
}
static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
{
if ((surface->format->BitsPerPixel) == 8) {
void *destscr;
int destx;
/* Center on destination screen */
destscr = XBIOS_screens[XBIOS_fbnum];
destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1);
destx = (XBIOS_width - surface->w) >> 1;
destx &= ~15;
destscr += destx;
/* Convert chunky to planar screen */
Nov 12, 2003
Nov 12, 2003
701
702
703
704
705
706
707
708
#ifdef DEBUG_VIDEO_XBIOS
printf("C2p:\n");
printf(" Source: Adr=0x%08x, Pitch=%d\n", surface->pixels, surface->pitch);
printf(" Dest: Adr=0x%08x, Pitch=%d\n", destscr, XBIOS_pitch);
printf(" Size: %dx%d, dblline=%d\n", surface->w, surface->h, XBIOS_doubleline);
fflush(stdout);
#endif
SDL_Atari_C2pConvert(
709
710
711
712
713
714
715
716
717
718
surface->pixels,
destscr,
surface->w,
surface->h,
XBIOS_doubleline,
surface->pitch,
XBIOS_pitch
);
}
Nov 12, 2003
Nov 12, 2003
719
#ifndef DEBUG_VIDEO_XBIOS
720
Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
Nov 12, 2003
Nov 12, 2003
721
#endif
722
723
724
Vsync();
if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
Mar 20, 2002
Mar 20, 2002
725
726
727
728
XBIOS_fbnum ^= 1;
if ((surface->format->BitsPerPixel) > 8) {
surface->pixels=XBIOS_screens[XBIOS_fbnum];
}
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
}
return(0);
}
static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
int i;
int r,v,b;
switch( XBIOS_cvdo >> 16) {
case VDO_ST:
case VDO_STE:
for (i=0;i<ncolors;i++)
{
r = colors[i].r;
v = colors[i].g;
b = colors[i].b;
TT_palette[firstcolor+i]=((r*30)+(v*59)+(b*11))/100;
}
Nov 12, 2003
Nov 12, 2003
750
SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */
751
752
753
754
755
756
757
758
759
760
break;
case VDO_TT:
for(i = 0; i < ncolors; i++)
{
r = colors[i].r;
v = colors[i].g;
b = colors[i].b;
TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4);
}
Nov 12, 2003
Nov 12, 2003
761
#ifndef DEBUG_VIDEO_XBIOS
762
EsetPalette(firstcolor,ncolors,TT_palette);
Nov 12, 2003
Nov 12, 2003
763
#endif
764
765
766
767
768
769
770
771
772
773
break;
case VDO_F30:
for(i = 0; i < ncolors; i++)
{
r = colors[i].r;
v = colors[i].g;
b = colors[i].b;
F30_palette[i]=(r<<16)|(v<<8)|b;
}
Nov 12, 2003
Nov 12, 2003
774
#ifndef DEBUG_VIDEO_XBIOS
775
VsetRGB(firstcolor,ncolors,F30_palette);
Nov 12, 2003
Nov 12, 2003
776
#endif
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
break;
}
return(1);
}
/* Note: If we are terminated, this could be called in the middle of
another SDL video routine -- notably UpdateRects.
*/
static void XBIOS_VideoQuit(_THIS)
{
int i,j;
Atari_ShutdownEvents();
/* Restore video mode and palette */
Feb 7, 2004
Feb 7, 2004
793
#ifndef DEBUG_VIDEO_XBIOS
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
switch(XBIOS_cvdo >> 16) {
case VDO_ST:
case VDO_STE:
Setscreen(-1,XBIOS_oldvbase,XBIOS_oldvmode);
if (XBIOS_oldnumcol) {
Setpalette(XBIOS_oldpalette);
}
break;
case VDO_TT:
Setscreen(-1,XBIOS_oldvbase,-1);
EsetShift(XBIOS_oldvmode);
if (XBIOS_oldnumcol) {
EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
}
break;
case VDO_F30:
Setscreen(-1, XBIOS_oldvbase, -1);
Vsetmode(XBIOS_oldvmode);
if (XBIOS_oldnumcol) {
VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
}
break;
}
Vsync();
Feb 7, 2004
Feb 7, 2004
818
#endif
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
if (XBIOS_oldpalette) {
free(XBIOS_oldpalette);
XBIOS_oldpalette=NULL;
}
XBIOS_FreeBuffers(this);
/* Free mode list */
for (j=0;j<NUM_MODELISTS;j++) {
for (i=0;i<SDL_NUMMODES;i++) {
if (SDL_modelist[j][i]!=NULL) {
free(SDL_modelist[j][i]);
SDL_modelist[j][i]=NULL;
}
}
}
this->screen->pixels = NULL;
}