Newer
Older
if(keyval <= 0xffff) {
if(sdl_keynext+1==sdl_key) {
sdl_beep();
return;
}
if((sdl_keynext+2==sdl_key) && keyval > 0xff) {
if(keyval==CIO_KEY_MOUSE)
sdl_pending_mousekeys++;
else
sdl_beep();
return;
}
sdl_keybuf[sdl_keynext++]=keyval & 0xff;
if(keyval>0xff) {
sdl_keybuf[sdl_keynext++]=keyval >> 8;
}
}
/* Called from event thread only */
int sdl_load_font(char *filename)
{
static char current_filename[MAX_PATH];
unsigned char *font;
unsigned int fontsize;
int fw;
int fh;
int ch;
int x;
int y;
int charrow;
int charcol;
SDL_Rect r;
FILE *fontfile;
if(sdl_current_font==-99 || sdl_current_font>(sizeof(conio_fontdata)/sizeof(struct conio_font_data_struct)-2)) {
for(x=0; conio_fontdata[x].desc != NULL; x++) {
if(!strcmp(conio_fontdata[x].desc, "Codepage 437 English")) {
sdl_current_font=x;
break;
}
}
if(conio_fontdata[x].desc==NULL)
sdl_current_font=0;
if(sdl_current_font==-1)
filename=current_filename;
else if(conio_fontdata[sdl_current_font].desc==NULL)
return(-1);
fh=vstat.charheight;
fw=vstat.charwidth/8+(vstat.charwidth%8?1:0);
fontsize=fw*fh*256*sizeof(unsigned char);
if((font=(unsigned char *)malloc(fontsize))==NULL) {
return(-1);
if(filename != NULL) {
if(flength(filename)!=fontsize) {
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
if((fontfile=fopen(filename,"rb"))==NULL) {
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
if(fread(font, 1, fontsize, fontfile)!=fontsize) {
free(font);
fclose(fontfile);
return(-1);
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
}
fclose(fontfile);
sdl_current_font=-1;
if(filename != current_filename)
SAFECOPY(current_filename,filename);
}
else {
switch(vstat.charwidth) {
case 8:
switch(vstat.charheight) {
case 8:
if(conio_fontdata[sdl_current_font].eight_by_eight==NULL) {
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
memcpy(font, conio_fontdata[sdl_current_font].eight_by_eight, fontsize);
break;
case 14:
if(conio_fontdata[sdl_current_font].eight_by_fourteen==NULL) {
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
memcpy(font, conio_fontdata[sdl_current_font].eight_by_fourteen, fontsize);
break;
case 16:
if(conio_fontdata[sdl_current_font].eight_by_sixteen==NULL) {
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
memcpy(font, conio_fontdata[sdl_current_font].eight_by_sixteen, fontsize);
break;
default:
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
break;
default:
sdl.mutexV(sdl_vstatlock);
free(font);
return(-1);
}
}
if(sdl_font!=NULL)
sdl_font=sdl.CreateRGBSurface(SDL_SWSURFACE, vstat.charwidth*vstat.scaling, vstat.charheight*256*vstat.scaling, 8, 0, 0, 0, 0);
if(sdl_font == NULL) {
free(font);
return(-1);
}
else {
for(ch=0; ch<256; ch++) {
for(charrow=0; charrow<vstat.charheight; charrow++) {
for(charcol=0; charcol<vstat.charwidth; charcol++) {
if(font[(ch*vstat.charheight+charrow)*fw+(charcol/8)] & (0x80 >> (charcol%8))) {
r.x=charcol*vstat.scaling;
r.y=(ch*vstat.charheight+charrow)*vstat.scaling;
r.w=vstat.scaling;
r.h=vstat.scaling;
}
}
}
}
free(font);
lastfg=-1;
lastbg=-1;
return(0);
}
/* Called from events thread only */
int sdl_setup_colours(SDL_Surface *surf, int xor)
{
int i;
int ret=0;
SDL_Color co[16];
for(i=0; i<16; i++) {
co[i^xor].r=dac_default[vstat.palette[i]].red;
co[i^xor].g=dac_default[vstat.palette[i]].green;
co[i^xor].b=dac_default[vstat.palette[i]].blue;
sdl.mutexV(sdl_vstatlock);
sdl.SetColors(surf, co, 0, 16);
return(ret);
}
/* Called from events thread only */
void sdl_draw_cursor(void)
{
SDL_Rect src;
SDL_Rect dst;
int x;
int y;
if(vstat.blink && vstat.curs_start<=vstat.curs_end) {
dst.x=0;
dst.y=0;
src.x=vstat.curs_col*vstat.charwidth*vstat.scaling;
src.y=(vstat.curs_row*vstat.charheight+vstat.curs_start)*vstat.scaling;
src.w=dst.w=vstat.charwidth*vstat.scaling;
src.h=dst.h=(vstat.curs_end-vstat.curs_start+1)*vstat.scaling;
sdl_setup_colours(sdl_cursor, 0);
sdl_setup_colours(sdl_cursor, vstat.currattr&0x07);
lastcursor_x=vstat.curs_col;
lastcursor_y=vstat.curs_row;
}
}
/* Called from event thread */
/* ONLY Called from sdl_full_screen_redraw() which holds the mutex... */
int sdl_draw_one_char(unsigned short sch, unsigned int x, unsigned int y, struct video_stats *vs)
{
SDL_Color co;
SDL_Rect src;
SDL_Rect dst;
unsigned char ch;
ch=(sch >> 8) & 0x0f;
if(lastfg!=ch) {
co.r=dac_default[vs->palette[ch]].red;
co.g=dac_default[vs->palette[ch]].green;
co.b=dac_default[vs->palette[ch]].blue;
lastfg=ch;
}
ch=(sch >> 12) & 0x07;
if(lastbg!=ch) {
co.r=dac_default[vs->palette[ch]].red;
co.g=dac_default[vs->palette[ch]].green;
co.b=dac_default[vs->palette[ch]].blue;
lastbg=ch;
}
dst.x=x*vs->charwidth*vs->scaling;
dst.y=y*vs->charheight*vs->scaling;
dst.w=vs->charwidth*vs->scaling;
dst.h=vs->charheight*vs->scaling;
src.x=0;
src.w=vs->charwidth*vs->scaling;
src.h=vs->charheight*vs->scaling;
src.y=vs->charheight*vs->scaling;
ch=sch & 0xff;
if((sch >>15) && !(vs->blink))
src.y *= ' ';
else
src.y *= ch;
if(sdl_font != NULL)
}
/* Called from event thread only, */
{
static int last_blink;
int x;
int y;
unsigned int pos;
unsigned short *p;
static unsigned short *vmemcopies[2]={ NULL, NULL };
static SDL_Rect *rects=NULL;
static int this_new=0;
static unsigned short *last_vmem=NULL;
int rcount=0;
static struct video_stats vs;
int redraw_cursor=0;
int lastlineupdated=0;
int lastcharupdated=0;
if(vs.cols!=vstat.cols || vs.rows != vstat.rows || vmemcopies[0]==NULL || vmemcopies[1]==NULL || rects==NULL) {
FREE_AND_NULL(vmemcopies[0]);
if((vmemcopies[0]=(unsigned short *)malloc(vstat.cols*vstat.rows*sizeof(unsigned short)))==NULL) {
sdl.mutexV(sdl_vstatlock);
return(-1);
}
FREE_AND_NULL(vmemcopies[1]);
if((vmemcopies[1]=(unsigned short *)malloc(vstat.cols*vstat.rows*sizeof(unsigned short)))==NULL) {
sdl.mutexV(sdl_vstatlock);
return(-1);
}
FREE_AND_NULL(rects);
if((rects=(SDL_Rect *)malloc(sizeof(SDL_Rect)*vstat.cols*vstat.rows))==NULL) {
sdl.mutexV(sdl_vstatlock);
return(-1);
}
}
this_new = (this_new+1) % 2;
newvmem=vmemcopies[this_new];
memcpy(&vs, &vstat, sizeof(vs));
memcpy(newvmem, vs.vmem, vs.cols*vs.rows*sizeof(unsigned short));
sdl_updated=1;
/* Redraw all chars */
pos=0;
if(last_vmem==NULL)
force=1;
if(last_blink != vs.blink
|| lastcursor_x!=vs.curs_col
|| lastcursor_y!=vs.curs_row)
redraw_cursor=1;
for(y=0;y<vs.rows;y++) {
for(x=0;x<vs.cols;x++) {
|| (last_vmem[pos] != newvmem[pos])
|| (last_blink != vs.blink && newvmem[pos]>>15)
|| (redraw_cursor && ((lastcursor_x==x && lastcursor_y==y) || (vs.curs_col==x && vs.curs_row==y)))
sdl_draw_one_char(newvmem[pos],x,y,&vs);
if(lastcharupdated) {
rects[rcount-1].w+=vs.charwidth*vs.scaling;
lastcharupdated++;
}
else {
rects[rcount].x=x*vs.charwidth*vs.scaling;
rects[rcount].y=y*vs.charheight*vs.scaling;
rects[rcount].w=vs.charwidth*vs.scaling;
rects[rcount++].h=vs.charheight*vs.scaling;
lastcharupdated++;
}
if(!redraw_cursor && x==vs.curs_col && y==vs.curs_row)
redraw_cursor=1;
else
lastcharupdated=0;
pos++;
}
if(lastcharupdated==vs.cols) {
if(lastlineupdated) {
rcount--;
rects[rcount-1].h+=vs.charheight*vs.scaling;
}
else
lastlineupdated=1;
}
else
lastlineupdated=0;
lastcharupdated=0;
last_blink=vs.blink;
last_vmem=newvmem;
}
unsigned int cp437_convert(unsigned int unicode)
{
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
switch(unicode) {
case 0x00c7:
return(0x80);
case 0x00fc:
return(0x81);
case 0x00e9:
return(0x82);
case 0x00e2:
return(0x83);
case 0x00e4:
return(0x84);
case 0x00e0:
return(0x85);
case 0x00e5:
return(0x86);
case 0x00e7:
return(0x87);
case 0x00ea:
return(0x88);
case 0x00eb:
return(0x89);
case 0x00e8:
return(0x8a);
case 0x00ef:
return(0x8b);
case 0x00ee:
return(0x8c);
case 0x00ec:
return(0x8d);
case 0x00c4:
return(0x8e);
case 0x00c5:
return(0x8f);
case 0x00c9:
return(0x90);
case 0x00e6:
return(0x91);
case 0x00c6:
return(0x92);
case 0x00f4:
return(0x93);
case 0x00f6:
return(0x94);
case 0x00f2:
return(0x95);
case 0x00fb:
return(0x96);
case 0x00f9:
return(0x97);
case 0x00ff:
return(0x98);
case 0x00d6:
return(0x99);
case 0x00dc:
return(0x9a);
case 0x00a2:
return(0x9b);
case 0x00a3:
return(0x9c);
case 0x00a5:
return(0x9d);
case 0x20a7:
return(0x9e);
case 0x0192:
return(0x9f);
case 0x00e1:
return(0xa0);
case 0x00ed:
return(0xa1);
case 0x00f3:
return(0xa2);
case 0x00fa:
return(0xa3);
case 0x00f1:
return(0xa4);
case 0x00d1:
return(0xa5);
case 0x00aa:
return(0xa6);
case 0x00ba:
return(0xa7);
case 0x00bf:
return(0xa8);
case 0x2310:
return(0xa9);
case 0x00ac:
return(0xaa);
case 0x00bd:
return(0xab);
case 0x00bc:
return(0xac);
case 0x00a1:
return(0xad);
case 0x00ab:
return(0xae);
case 0x00bb:
return(0xaf);
case 0x2591:
return(0xb0);
case 0x2592:
return(0xb1);
case 0x2593:
return(0xb2);
case 0x2502:
return(0xb3);
case 0x2524:
return(0xb4);
case 0x2561:
return(0xb5);
case 0x2562:
return(0xb6);
case 0x2556:
return(0xb7);
case 0x2555:
return(0xb8);
case 0x2563:
return(0xb9);
case 0x2551:
return(0xba);
case 0x2557:
return(0xbb);
case 0x255d:
return(0xbc);
case 0x255c:
return(0xbd);
case 0x255b:
return(0xbe);
case 0x2510:
return(0xbf);
case 0x2514:
return(0xc0);
case 0x2534:
return(0xc1);
case 0x252c:
return(0xc2);
case 0x251c:
return(0xc3);
case 0x2500:
return(0xc4);
case 0x253c:
return(0xc5);
case 0x255e:
return(0xc6);
case 0x255f:
return(0xc7);
case 0x255a:
return(0xc8);
case 0x2554:
return(0xc9);
case 0x2569:
return(0xca);
case 0x2566:
return(0xcb);
case 0x2560:
return(0xcc);
case 0x2550:
return(0xcd);
case 0x256c:
return(0xce);
case 0x2567:
return(0xcf);
case 0x2568:
return(0xd0);
case 0x2564:
return(0xd1);
case 0x2565:
return(0xd2);
case 0x2559:
return(0xd3);
case 0x2558:
return(0xd4);
case 0x2552:
return(0xd5);
case 0x2553:
return(0xd6);
case 0x256b:
return(0xd7);
case 0x256a:
return(0xd8);
case 0x2518:
return(0xd9);
case 0x250c:
return(0xda);
case 0x2588:
return(0xdb);
case 0x2584:
return(0xdc);
case 0x258c:
return(0xdd);
case 0x2590:
return(0xde);
case 0x2580:
return(0xdf);
case 0x03b1:
return(0xe0);
case 0x00df:
return(0xe1);
case 0x0393:
return(0xe2);
case 0x03c0:
return(0xe3);
case 0x03a3:
return(0xe4);
case 0x03c3:
return(0xe5);
case 0x00b5:
return(0xe6);
case 0x03c4:
return(0xe7);
case 0x03a6:
return(0xe8);
case 0x0398:
return(0xe9);
case 0x03a9:
return(0xea);
case 0x03b4:
return(0xeb);
case 0x221e:
return(0xec);
case 0x03c6:
return(0xed);
case 0x03b5:
return(0xee);
case 0x2229:
return(0xef);
case 0x2261:
return(0xf0);
case 0x00b1:
return(0xf1);
case 0x2265:
return(0xf2);
case 0x2264:
return(0xf3);
case 0x2320:
return(0xf4);
case 0x2321:
return(0xf5);
case 0x00f7:
return(0xf6);
case 0x2248:
return(0xf7);
case 0x00b0:
return(0xf8);
case 0x2219:
return(0xf9);
case 0x00b7:
return(0xfa);
case 0x221a:
return(0xfb);
case 0x207f:
return(0xfc);
case 0x00b2:
return(0xfd);
case 0x25a0:
return(0xfe);
case 0x00a0:
return(0xff);
}
return(0x01ffff);
}
/* Called from event thread only */
unsigned int sdl_get_char_code(unsigned int keysym, unsigned int mod, unsigned int unicode)
keysym=SDLK_BACKSPACE;
if((!unicode) || (mod & (KMOD_META|KMOD_ALT))) {
for(i=0;sdl_keyval[i].keysym;i++) {
if(sdl_keyval[i].keysym==keysym) {
if(mod & KMOD_CTRL)
expect=sdl_keyval[i].ctrl;
else if(mod & KMOD_SHIFT)
expect=sdl_keyval[i].shift;
else
expect=sdl_keyval[i].key;
/*
* Apparently, Win32 SDL doesn't interpret keypad with numlock...
* So, do that here. *sigh*
*/
if(keysym >= SDLK_KP0 && keysym <= SDLK_KP_EQUALS
&& (mod & KMOD_NUM)
&& (!(mod & (KMOD_CTRL|KMOD_SHIFT|KMOD_ALT|KMOD_META) ))) {
switch(keysym) {
return('=');
}
}
/* "Extended" syms are always right */
if(!unicode)
return(expect);
if(sdl_keyval[i].key > 255)
return(expect);
/*
* If we don't know that this key should
* return the unicode translation, then
* we're not right and this is prolly
* an AltGr sequence.
*/
return(cp437_convert(unicode));
}
/* Mouse event/keyboard thread */
{
while(1) {
if(mouse_wait())
sdl_add_key(CIO_KEY_MOUSE);
}
}
/* Event Thread */
int sdl_video_event_thread(void *data)
{
SDL_Event ev;
while(1) {
if(sdl.WaitEvent(&ev)==1) {
switch (ev.type) {
case SDL_ACTIVEEVENT: /* Focus change */
break;
case SDL_KEYDOWN: /* Keypress */
sdl_add_key(sdl_get_char_code(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode));
break;
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_MOUSE_MOVE,ev.motion.x/(vstat.charwidth*vstat.scaling)+1,ev.motion.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
case SDL_MOUSEBUTTONDOWN:
if(!ciolib_mouse_initialized)
break;
switch(ev.button.button) {
case SDL_BUTTON_LEFT:
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_BUTTON_PRESS(1),ev.button.x/(vstat.charwidth*vstat.scaling)+1,ev.button.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
break;
case SDL_BUTTON_MIDDLE:
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_BUTTON_PRESS(2),ev.button.x/(vstat.charwidth*vstat.scaling)+1,ev.button.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
break;
case SDL_BUTTON_RIGHT:
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_BUTTON_PRESS(3),ev.button.x/(vstat.charwidth*vstat.scaling)+1,ev.button.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
break;
break;
case SDL_MOUSEBUTTONUP:
if(!ciolib_mouse_initialized)
break;
switch(ev.button.button) {
case SDL_BUTTON_LEFT:
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_BUTTON_RELEASE(1),ev.button.x/(vstat.charwidth*vstat.scaling)+1,ev.button.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
break;
case SDL_BUTTON_MIDDLE:
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_BUTTON_RELEASE(2),ev.button.x/(vstat.charwidth*vstat.scaling)+1,ev.button.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
break;
case SDL_BUTTON_RIGHT:
sdl.mutexP(sdl_vstatlock);
ciomouse_gotevent(CIOLIB_BUTTON_RELEASE(3),ev.button.x/(vstat.charwidth*vstat.scaling)+1,ev.button.y/(vstat.charheight*vstat.scaling)+1);
sdl.mutexV(sdl_vstatlock);
break;
}
break;
case SDL_QUIT:
return(sdl_exitcode);
case SDL_VIDEORESIZE:
if(ev.resize.w > 0 && ev.resize.h > 0) {
sdl.mutexP(sdl_vstatlock);
vstat.scaling=(int)(ev.resize.w/(vstat.charwidth*vstat.cols));
if(vstat.scaling < 1)
vstat.scaling=1;

deuce
committed
vstat.charwidth*vstat.cols*vstat.scaling
,vstat.charheight*vstat.rows*vstat.scaling

deuce
committed
);

deuce
committed
else

deuce
committed
vstat.charwidth*vstat.cols*vstat.scaling
,vstat.charheight*vstat.rows*vstat.scaling
,8

deuce
committed
);
if(!strcmp(driver,"Quartz"))
sdl_using_quartz=TRUE;
}
sdl_cursor=sdl.CreateRGBSurface(SDL_SWSURFACE, vstat.charwidth*vstat.scaling, vstat.charheight*vstat.scaling, 8, 0, 0, 0, 0);
/* Update font. */
sdl_load_font(NULL);
sdl_setup_colours(win,0);
}
else if(sdl_init_good) {
ev.type=SDL_QUIT;
sdl_exitcode=1;
sdl.mutexV(sdl_vstatlock);
}
break;
case SDL_VIDEOEXPOSE:
break;
case SDL_USEREVENT: {
/* Tell SDL to do various stuff... */
switch(ev.user.code) {
case SDL_USEREVENT_QUIT:
sdl_ufunc_retval=0;
sdl.SemPost(sdl_ufunc_ret);
case SDL_USEREVENT_LOADFONT:
sdl_ufunc_retval=sdl_load_font((char *)ev.user.data1);
FREE_AND_NULL(ev.user.data1);
sdl.SemPost(sdl_ufunc_ret);
break;
case SDL_USEREVENT_SETNAME:
sdl.WM_SetCaption((char *)ev.user.data1,(char *)ev.user.data1);
free(ev.user.data1);
break;
case SDL_USEREVENT_SETICON:
if(sdl_icon != NULL)
sdl.FreeSurface(sdl_icon);
sdl_icon=sdl.CreateRGBSurfaceFrom(ev.user.data1
, *(unsigned long *)ev.user.data2
, *(unsigned long *)ev.user.data2
, 32
, *(unsigned long *)ev.user.data2*4
, *(DWORD *)"\377\0\0\0"
, *(DWORD *)"\0\377\0\0"
, *(DWORD *)"\0\0\377\0"
, *(DWORD *)"\0\0\0\377"
);
sdl.WM_SetIcon(sdl_icon,NULL);
free(ev.user.data2);
break;
case SDL_USEREVENT_SETTITLE:
sdl.WM_SetCaption((char *)ev.user.data1,NULL);
free(ev.user.data1);
break;
case SDL_USEREVENT_SETVIDMODE:
sdl.mutexP(sdl_vstatlock);
if(fullscreen)
win=sdl.SetVideoMode(
vstat.charwidth*vstat.cols*vstat.scaling
,vstat.charheight*vstat.rows*vstat.scaling
,8
);
else
win=sdl.SetVideoMode(
vstat.charwidth*vstat.cols*vstat.scaling
,vstat.charheight*vstat.rows*vstat.scaling
,8
);
if(win!=NULL) {
#if (defined(__MACH__) && defined(__APPLE__))
char driver[16];
#endif
vstat.scaling=(int)(win->w/(vstat.charwidth*vstat.cols));
if(vstat.scaling < 1)
vstat.scaling=1;
sdl_setup_colours(win,0);
if(sdl_cursor!=NULL)
sdl.FreeSurface(sdl_cursor);
sdl_cursor=sdl.CreateRGBSurface(SDL_SWSURFACE, vstat.charwidth*vstat.scaling, vstat.charheight*vstat.scaling, 8, 0, 0, 0, 0);
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
else if(sdl_init_good) {
ev.type=SDL_QUIT;
sdl_exitcode=1;
sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, 0xffffffff);
}
free(ev.user.data1);
free(ev.user.data2);
sdl.mutexV(sdl_vstatlock);
break;
case SDL_USEREVENT_HIDEMOUSE:
sdl.ShowCursor(SDL_DISABLE);
break;
case SDL_USEREVENT_SHOWMOUSE:
sdl.ShowCursor(SDL_ENABLE);
break;
case SDL_USEREVENT_INIT:
if(!sdl_init_good) {
if(sdl.WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO) {
if(win != NULL) {
sdl.EnableUNICODE(1);
sdl.EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
blinker_thread=sdl.CreateThread(sdl_blinker_thread, NULL);
mouse_thread=sdl.CreateThread(sdl_mouse_thread, NULL);
case SDL_USEREVENT_COPY:
#if (defined(__MACH__) && defined(__APPLE__))
if(sdl_using_quartz) {
ScrapRef scrap;
sdl.mutexP(sdl_copybuf_mutex);
if(sdl_copybuf!=NULL) {
if(!ClearCurrentScrap()) { /* purge the current contents of the scrap. */
if(!GetCurrentScrap(&scrap)) { /* obtain a reference to the current scrap. */
PutScrapFlavor(scrap, kScrapFlavorTypeText, kScrapFlavorMaskTranslated /* kScrapFlavorMaskNone */, strlen(sdl_copybuf), sdl_copybuf); /* write the data to the scrap */
}
}
}
FREE_AND_NULL(sdl_copybuf);
sdl.mutexV(sdl_copybuf_mutex);
break;
}
#endif
#if !defined(NO_X) && defined(__unix__)
if(sdl_x11available && sdl_using_x11()) {
SDL_SysWMinfo wmi;
SDL_VERSION(&(wmi.version));
sdl.GetWMInfo(&wmi);
sdl_x11.XSetSelectionOwner(wmi.info.x11.display, CONSOLE_CLIPBOARD, wmi.info.x11.window, CurrentTime);
break;
}
#endif
case SDL_USEREVENT_PASTE:
#if (defined(__MACH__) && defined(__APPLE__))
if(sdl_using_quartz) {
ScrapRef scrap;
UInt32 fl;
Size scraplen;
FREE_AND_NULL(sdl_pastebuf);
if(!GetCurrentScrap(&scrap)) { /* obtain a reference to the current scrap. */
if(!GetScrapFlavorFlags(scrap, kScrapFlavorTypeText, &fl) && (fl & kScrapFlavorMaskTranslated)) {
if(!GetScrapFlavorSize(scrap, kScrapFlavorTypeText, &scraplen)) {
sdl_pastebuf=(char *)malloc(scraplen+1);
if(sdl_pastebuf!=NULL) {
if(GetScrapFlavorData(scrap, kScrapFlavorTypeText, &scraplen, sdl_pastebuf)) {
FREE_AND_NULL(sdl_pastebuf);
}
sdl.SemPost(sdl_pastebuf_set);
sdl.SemWait(sdl_pastebuf_copied);
break;
#if !defined(NO_X) && defined(__unix__)
if(sdl_x11available && sdl_using_x11()) {
Window sowner=None;
SDL_SysWMinfo wmi;
SDL_VERSION(&(wmi.version));