-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsdl_video.c
1720 lines (1613 loc) · 61.9 KB
/
sdl_video.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
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* sz81 Copyright (C) 2007-2011 Thunor <thunorsif@hotmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Includes */
#include "sdl_engine.h"
#include "common.h"
#include "zx81.h"
/* Defines */
/* Variables */
//unsigned char vga_graphmemory[64 * 1024]; // Sorry about that!
unsigned char vga_graphmemory[800 * 600];
extern ZX81 zx81;
char *runtime_options_text0[24];
char *runtime_options_text1[24];
char *runtime_options_text2[24];
char *runtime_options_text3[24];
video_ video;
/* \x1 means that a value needs to be placed here.
* \x2 means to invert the colours.
* \x80 to \x95 are Sinclair graphics characters.
* \x96 to \x97 are up and down </> equivalents */
char *runtime_options_text0[24] = {
"\x2 Hardware Options 1/4 \x2",
"",
"Machine Model:",
"",
" (\x1 \x1) ZX80 (\x1 \x1) ZX81",
"",
"RAM Size \x90\x2<\x2\x85 \x1 K \x90\x2>\x2\x85",
"",
"M1NOT:",
"",
" (\x1 \x1) No (\x1 \x1) Yes",
"",
"Frameskip\x90\x2<\x2\x85 \x1 \x90\x2>\x2\x85",
"",
#ifdef ENABLE_EMULATION_SPEED_ADJUST
"Emu Speed\x90\x2<\x2\x85\x1 %\x90\x2>\x2\x85",
#else
"",
#endif
"",
"WRX:",
" (\x1 \x1) No (\x1 \x1) Yes",
"UDG:",
" (\x1 \x1) No (\x1 \x1) Yes",
"",
"\x1 ",
"",
" Save Exit Next\x90\x2>\x2\x85"
};
char *runtime_options_text1[24] = {
"\x2 Sound Options 2/4 \x2",
"",
"Sound Device:",
"",
" (\x1 \x1) None",
"",
" (\x1 \x1) AY Chip Based",
"",
" (\x1 \x1) Quicksilva Sound Board",
"",
" (\x1 \x1) BI-PAK ZON X-81",
"",
" (\x1 \x1) Unreal",
"",
" (\x1 \x1) VSYNC (TV Speaker)",
"",
"",
"",
"",
"",
"",
"\x1 ",
"",
"\x90\x2<\x2\x85" "Back Save Exit Next\x90\x2>\x2\x85"
};
char *runtime_options_text2[24] = {
"\x2 GUI Options 3/4 \x2",
"",
"Volume \x90\x2<\x2\x85 \x1 \x90\x2>\x2\x85",
"",
"Key Repeat:",
"",
" Delay \x90\x2<\x2\x85\x1 ms\x90\x2>\x2\x85",
"",
" Interval\x90\x2<\x2\x85\x1 ms\x90\x2>\x2\x85",
"",
"Colours:",
"",
" Fore:R\x90\x2<\x2\x85\x1 \x90\x2>\x2\x85 Back:R\x90\x2<\x2\x85\x1 \x90\x2>\x2\x85",
"",
" G\x90\x2<\x2\x85\x1 \x90\x2>\x2\x85 G\x90\x2<\x2\x85\x1 \x90\x2>\x2\x85",
"",
" B\x90\x2<\x2\x85\x1 \x90\x2>\x2\x85 B\x90\x2<\x2\x85\x1 \x90\x2>\x2\x85",
"",
"",
"",
"",
"\x1 ",
"",
"\x90\x2<\x2\x85" "Back Save Exit Next\x90\x2>\x2\x85"
};
char *runtime_options_text3[24] = {
"\x2 Joystick Options 4/4 \x2",
"",
"Axis Dead Zone\x90\x2<\x2\x85\x1 \%\x90\x2>\x2\x85",
"",
"Joystick Configurator:",
"",
" Selector u/d/l/r and hit are",
" the minimum requirements.",
"",
" \x92\x2---\x2\x84 \x92\x2---\x2\x84",
" \x92\x81 \x82\x83\x83\x83\x83\x83\x83\x81 \x82\x84",
" \x86 \x8e \x8e \x91",
" \x85 \x88\x8b\x88 \x89\x8a\x89\x8a /\x83 \x90",
" \x85\x90\x8b\x2O\x2\x8b\x85 \x90\x85/\x90\x85\x90",
" \x85 \x88\x8b\x88 \x90\x2.\x2\x85\x90\x2>\x2\x85 \x8e/ \x90",
" \x91 \x83 \x83 \x86",
" \x82\x84 \x92\x8e\x8e\x8e\x8e\x8e\x8e\x84 \x92\x81",
" \x82\x83\x83\x83\x81 \x82\x83\x83\x83\x81",
" \x1 ",
" \x1 ",
"",
"\x1 ",
"",
"\x90\x2<\x2\x85" "Back Save Exit "
};
char save_state_dialog_icons[72] = {
0x00, 0x18, 0x28, 0x08, 0x08, 0x08, 0x3e, 0x00,
0x00, 0x3c, 0x42, 0x02, 0x3c, 0x40, 0x7e, 0x00,
0x00, 0x3c, 0x42, 0x0c, 0x02, 0x42, 0x3c, 0x00,
0x00, 0x08, 0x18, 0x28, 0x48, 0x7e, 0x08, 0x00,
0x00, 0x7e, 0x40, 0x7c, 0x02, 0x42, 0x3c, 0x00,
0x00, 0x3c, 0x40, 0x7c, 0x42, 0x42, 0x3c, 0x00,
0x00, 0x7e, 0x02, 0x04, 0x08, 0x10, 0x10, 0x00,
0x00, 0x3c, 0x42, 0x3c, 0x42, 0x42, 0x3c, 0x00,
0x00, 0x3c, 0x42, 0x42, 0x3e, 0x02, 0x3c, 0x00
};
char dialog_icons[32] = {
0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x38, 0x00,
0x00, 0x3c, 0x42, 0x04, 0x08, 0x00, 0x08, 0x00,
0x00, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x00
};
/* Function prototypes */
/***************************************************************************
* Set Video Mode *
***************************************************************************/
/* This can be called multiple times and it is if the resolution is switched.
*
* On exit: returns TRUE on error
* else FALSE */
int sdl_video_setmode(void) {
int original_xres = video.xres;
int count;
/* Try the requested video resolution and if it's unavailable
* try the next one down and continue until one is accepted.
* Note: I first used SDL_VideoModeOK() but it didn't work on
* my Zaurus so it's probably best to use brute force.
*
* sz81 uses alpha and so it must use an SDL_SWSURFACE */
do {
video.screen = SDL_SetVideoMode(video.xres, video.yres, 16,
SDL_SWSURFACE | SDL_ANYFORMAT | video.fullscreen);
if (video.screen == NULL) {
fprintf(stderr, "%s: Cannot set video mode: %i x %i: %s\n",
__func__, video.xres, video.yres, SDL_GetError());
cycle_resolutions();
}
} while (video.screen == NULL && video.xres != original_xres);
if (video.screen == NULL) exit(1); /* Can't continue */
#ifdef SDL_DEBUG_VIDEO
printf("%s: video.screen->format->BitsPerPixel=%i\n", __func__,
video.screen->format->BitsPerPixel);
#endif
/* Hide the mouse pointer for certain devices */
#if defined(PLATFORM_GP2X) || defined(PLATFORM_ZAURUS)
SDL_ShowCursor(SDL_DISABLE);
#endif
/* Set-up the emulator's screen offset - not used at the moment */
if (video.bigscreen) {
sdl_emulator.xoffset = (video.xres - 400 * video.scale) / 2;
sdl_emulator.yoffset = (video.yres - 300 * video.scale) / 2;
} else {
sdl_emulator.xoffset = (video.xres - 320 * video.scale) / 2;
sdl_emulator.yoffset = (video.yres - 240 * video.scale) / 2;
}
#ifdef SDL_DEBUG_VIDEO
printf("%s: sdl_emulator.xoffset=%i sdl_emulator.yoffset=%i\n",
__func__, sdl_emulator.xoffset, sdl_emulator.yoffset);
#endif
/* Set-up runtime options' screen offset */
for (count = 0; count < MAX_RUNTIME_OPTIONS; count++) {
runtime_options[count].xoffset = (video.xres - 256 * video.scale) / 2;
if (runtime_options[count].xoffset < 0) runtime_options[count].xoffset = 0;
runtime_options[count].yoffset = (video.yres - 192 * video.scale) / 2;
if (runtime_options[count].yoffset < 0) runtime_options[count].yoffset = 0;
}
/* Set-up the load file dialog's screen offset */
load_file_dialog.xoffset = (video.xres - 256 * video.scale) / 2;
if (load_file_dialog.xoffset < 0) load_file_dialog.xoffset = 0;
load_file_dialog.yoffset = (video.yres - 192 * video.scale) / 2;
if (load_file_dialog.yoffset < 0) load_file_dialog.yoffset = 0;
/* Set-up the save state dialog's screen offset */
save_state_dialog.xoffset = (video.screen->w - 15 * 8 * video.scale) / 2;
save_state_dialog.yoffset = (video.screen->h - 17 * 8 * video.scale) / 2;
/* The dynamic dialog's screen offset is set-up in hotspots_resize */
/* Set-up the fonts */
if (fonts_init()) exit(1);
/* Set-up the sz81 icons */
if (sz81icons_init()) exit(1);
/* Set-up the virtual keyboard */
if (vkeyb_init()) exit(1);
/* Set-up the control bar */
if (control_bar_init()) exit(1);
/* Resize all hotspots for the current screen dimensions.
* The hotspots will not have yet been initialised the very first
* time here, but they will have been on subsequent visits and so a
* check needs to be performed which will skip it on the first visit */
if (hotspots[HS_VKEYB_VKEYB].gid == HS_GRP_VKEYB) hotspots_resize(HS_GRP_ALL);
/* Prepare to redraw everything */
video.redraw = TRUE;
return FALSE;
}
/***************************************************************************
* VGA Get Graph Mem *
***************************************************************************/
/* On exit: returns a pointer to the graphics memory */
unsigned char *vga_getgraphmem(void) {
return vga_graphmemory;
}
void sdl_set_redraw_video() {
video.redraw = TRUE;
}
int cvtChroma(unsigned char c) {
int crgb=0;
#ifdef ZXMORE
switch (c) {
case 0x00 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x00,0x00); break;
case 0x01 : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xbf,0xdf); break;
case 0x02 : crgb=SDL_MapRGB(video.screen->format, 0xdf,0xbf,0xbf); break;
case 0x03 : crgb=SDL_MapRGB(video.screen->format, 0xdf,0xbf,0xdf); break;
case 0x04 : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xdf,0xbf); break;
case 0x05 : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xdf,0xdf); break;
case 0x06 : crgb=SDL_MapRGB(video.screen->format, 0xdf,0xdf,0xbf); break;
case 0x07 : crgb=SDL_MapRGB(video.screen->format, 0xdf,0xdf,0xdf); break;
case 0x08 : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xbf,0xbf); break;
case 0x09 : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xbf,0xff); break;
case 0x0a : crgb=SDL_MapRGB(video.screen->format, 0xff,0xbf,0xbf); break;
case 0x0b : crgb=SDL_MapRGB(video.screen->format, 0xff,0xbf,0xff); break;
case 0x0c : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xff,0xbf); break;
case 0x0d : crgb=SDL_MapRGB(video.screen->format, 0xbf,0xff,0xff); break;
case 0x0e : crgb=SDL_MapRGB(video.screen->format, 0xff,0xff,0xbf); break;
case 0x0f : crgb=SDL_MapRGB(video.screen->format, 0xff,0xff,0xff); break;
}
#else
switch (c) {
case 0x00 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x00,0x00); break;
case 0x01 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x00,0x7f); break;
case 0x02 : crgb=SDL_MapRGB(video.screen->format, 0x7f,0x00,0x00); break;
case 0x03 : crgb=SDL_MapRGB(video.screen->format, 0x7f,0x00,0x7f); break;
case 0x04 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x7f,0x00); break;
case 0x05 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x7f,0x7f); break;
case 0x06 : crgb=SDL_MapRGB(video.screen->format, 0x7f,0x7f,0x00); break;
case 0x07 : crgb=SDL_MapRGB(video.screen->format, 0x7f,0x7f,0x7f); break;
case 0x08 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x00,0x00); break;
case 0x09 : crgb=SDL_MapRGB(video.screen->format, 0x00,0x00,0xff); break;
case 0x0a : crgb=SDL_MapRGB(video.screen->format, 0xff,0x00,0x00); break;
case 0x0b : crgb=SDL_MapRGB(video.screen->format, 0xff,0x00,0xff); break;
case 0x0c : crgb=SDL_MapRGB(video.screen->format, 0x00,0xff,0x00); break;
case 0x0d : crgb=SDL_MapRGB(video.screen->format, 0x00,0xff,0xff); break;
case 0x0e : crgb=SDL_MapRGB(video.screen->format, 0xff,0xff,0x00); break;
case 0x0f : crgb=SDL_MapRGB(video.screen->format, 0xff,0xff,0xff); break;
}
#endif
return crgb;
}
/***************************************************************************
* Update Video *
***************************************************************************/
/* This does the following things :-
*
* Firstly the component executive is called to check everything is up-to-date.
* It'll redraw the entire screen if video.redraw is TRUE.
* The emulator's 8 bit 320x240 or 400x300 VGA memory is scaled-up into the SDL screen surface.
* Possibly the load selector, vkeyb, control bar, runtime options and associated
* hotspots will require overlaying */
void sdl_video_update(void) {
Uint32 colourRGB, fg_colourRGB, bg_colourRGB, colour0RGB, colour1RGB;
int srcx, srcy, desx, desy, count, offset, invertcolours;
int mrgx1, mrgx2, mrgy1, mrgy2;
Uint32 fg_colour, bg_colour, *screen_pixels_32;
int xpos, ypos, xmask, ybyte;
SDL_Surface *renderedtext;
Uint16 *screen_pixels_16;
char text[33], *direntry;
SDL_Rect dstrect;
#ifdef SDL_DEBUG_FONTS
struct bmpfont *ptrfont;
int fontcount;
#endif
#ifdef SDL_DEBUG_TIMING
static Uint32 lasttime = 0;
static int Hz = 0;
Hz++;
if (SDL_GetTicks() - lasttime >= 1000) {
printf("%s=%iHz\n", __func__, Hz);
lasttime = SDL_GetTicks();
Hz = 0;
}
#endif
/* Monitor and manage component states */
sdl_component_executive();
/* Prepare the colours we shall be using (these remain unchanged throughout) */
if (!sdl_emulator.invert) {
fg_colourRGB = SDL_MapRGB(video.screen->format, colours.emu_fg >> 16 & 0xff,
colours.emu_fg >> 8 & 0xff, colours.emu_fg & 0xff);
bg_colourRGB = SDL_MapRGB(video.screen->format, colours.emu_bg >> 16 & 0xff,
colours.emu_bg >> 8 & 0xff, colours.emu_bg & 0xff);
colour0RGB = fg_colourRGB;
colour1RGB = bg_colourRGB;
fg_colour = colours.emu_fg;
bg_colour = colours.emu_bg;
} else {
fg_colourRGB = SDL_MapRGB(video.screen->format, colours.emu_bg >> 16 & 0xff,
colours.emu_bg >> 8 & 0xff, colours.emu_bg & 0xff);
bg_colourRGB = SDL_MapRGB(video.screen->format, colours.emu_fg >> 16 & 0xff,
colours.emu_fg >> 8 & 0xff, colours.emu_fg & 0xff);
colour0RGB = bg_colourRGB;
colour1RGB = fg_colourRGB;
fg_colour = colours.emu_bg;
bg_colour = colours.emu_fg;
}
/* Should everything be redrawn? */
if (video.redraw) {
video.redraw = FALSE;
/* Wipe the entire screen surface */
if (chromamode) {
colourRGB = cvtChroma(bordercolour);
} else {
#ifdef SDL_DEBUG_VIDEO
colourRGB = SDL_MapRGB(video.screen->format, 0x0, 0x80, 0xc0);
#else
colourRGB = bg_colourRGB;
#endif
}
if (SDL_FillRect(video.screen, NULL, colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
}
/* Is the emulator's output being rendered? */
if (sdl_emulator.state) {
if (SDL_MUSTLOCK(video.screen)) SDL_LockSurface(video.screen);
screen_pixels_16 = video.screen->pixels;
screen_pixels_32 = video.screen->pixels;
/* Set-up destination y coordinates */
desx = sdl_emulator.xoffset;
desy = sdl_emulator.yoffset;
if (video.bigscreen) {
mrgx1 = mrgx2 = 0;
mrgy1 = mrgy2 = 0;
} else {
mrgx1 = (video.xres/video.scale - 256) / 2;
mrgy1 = (video.yres/video.scale - 192) / 2;
mrgx1 = (13+58-2-32)*2 - mrgx1;
mrgy1 = 55+2 - mrgy1;
mrgx2 = 400 - mrgx1 - video.xres/video.scale;
mrgy2 = 300 - mrgy1 - video.yres/video.scale;
}
if (mrgx1<0) mrgx2 = 0;
if (mrgx2<0) mrgx2 = 0;
if (mrgy1<0) mrgy1 = 0;
if (mrgy2<0) mrgy2 = 0;
desy = 0;
for (srcy = mrgy1; srcy < 300-mrgy2; srcy++) {
desx = 0;
for (srcx = mrgx1; srcx < 400-mrgx2; srcx++) {
/* Get 8 bit source pixel and convert to RGB */
if (chromamode) {
colourRGB = cvtChroma(vga_graphmemory[srcy * 400 + srcx]);
} else {
if (vga_graphmemory[srcy * 400 + srcx] == 0) {
colourRGB = colour0RGB;
} else {
colourRGB = colour1RGB;
}
}
if (video.screen->format->BitsPerPixel == 16) {
/* Write the destination pixel[s] */
screen_pixels_16[desy * video.xres + desx] = colourRGB;
if (video.scale > 1) {
/* x2 scaling */
screen_pixels_16[desy * video.xres + desx + 1] = colourRGB;
screen_pixels_16[(desy + 1) * video.xres + desx] = colourRGB;
screen_pixels_16[(desy + 1) * video.xres + desx + 1] = colourRGB;
if (video.scale > 2) {
/* x3 scaling */
screen_pixels_16[desy * video.xres + desx + 2] = colourRGB;
screen_pixels_16[(desy + 1) * video.xres + desx + 2] = colourRGB;
screen_pixels_16[(desy + 2) * video.xres + desx] = colourRGB;
screen_pixels_16[(desy + 2) * video.xres + desx + 1] = colourRGB;
screen_pixels_16[(desy + 2) * video.xres + desx + 2] = colourRGB;
}
}
} else if (video.screen->format->BitsPerPixel == 32) {
/* Write the destination pixel[s] */
screen_pixels_32[desy * video.xres + desx] = colourRGB;
if (video.scale > 1) {
/* x2 scaling */
screen_pixels_32[desy * video.xres + desx + 1] = colourRGB;
screen_pixels_32[(desy + 1) * video.xres + desx] = colourRGB;
screen_pixels_32[(desy + 1) * video.xres + desx + 1] = colourRGB;
if (video.scale > 2) {
/* x3 scaling */
screen_pixels_32[desy * video.xres + desx + 2] = colourRGB;
screen_pixels_32[(desy + 1) * video.xres + desx + 2] = colourRGB;
screen_pixels_32[(desy + 2) * video.xres + desx] = colourRGB;
screen_pixels_32[(desy + 2) * video.xres + desx + 1] = colourRGB;
screen_pixels_32[(desy + 2) * video.xres + desx + 2] = colourRGB;
}
}
}
desx += video.scale;
}
desy += video.scale;
}
if (SDL_MUSTLOCK(video.screen)) SDL_UnlockSurface(video.screen);
/* Has the user paused the emulator? */
if (sdl_emulator.paused) {
/* Draw the shadow */
dstrect.w = 8 * 8 * video.scale; dstrect.h = 3 * 8 * video.scale;
dstrect.x = (video.screen->w - dstrect.w) / 2;
dstrect.y = (video.screen->h - dstrect.h) / 2;
draw_shadow(dstrect, 170); /* 66% */
/* Render the text using a transparent background */
renderedtext = BMF_RenderText(BMF_FONT_ZX82, " Paused ", colours.emu_bg,
colours.colour_key);
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
dstrect.x = (video.screen->w - dstrect.w) / 2;
dstrect.y = (video.screen->h - dstrect.h) / 2;
/* Blit it to the screen */
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
}
}
/* Is the save state dialog being rendered? */
if (save_state_dialog.state) {
srcx = save_state_dialog.xoffset;
srcy = save_state_dialog.yoffset;
/* Draw the vertical bars */
dstrect.x = srcx; dstrect.y = srcy + 1 * 8 * video.scale;
dstrect.w = 0.5 * 8 * video.scale; dstrect.h = 13 * 8 * video.scale;
for (count = 0; count < 4; count++) {
if (SDL_FillRect(video.screen, &dstrect, fg_colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
dstrect.x += 4.5 * 8 * video.scale;
}
/* Draw the horizontal bars */
dstrect.x = srcx; dstrect.y = srcy + 5 * 8 * video.scale;
dstrect.w = 14 * 8 * video.scale; dstrect.h = 0.5 * 8 * video.scale;
for (count = 0; count < 3; count++) {
if (SDL_FillRect(video.screen, &dstrect, fg_colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
if (count < 2) dstrect.y += 4.5 * 8 * video.scale;
}
dstrect.y += 1.5 * 8 * video.scale;
if (SDL_FillRect(video.screen, &dstrect, fg_colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
/* Draw the right-hand and bottom shadows */
for (count = 0; count < 2; count++) {
if (count == 0) {
dstrect.x = srcx + 14 * 8 * video.scale;
dstrect.y = srcy + 8 * video.scale;
dstrect.w = 8 * video.scale;
dstrect.h = 15 * 8 * video.scale;
} else {
dstrect.x = srcx + 8 * video.scale;
dstrect.y = srcy + 16 * 8 * video.scale;
dstrect.w = 14 * 8 * video.scale;
dstrect.h = 8 * video.scale;
}
draw_shadow(dstrect, 64); /* 25% */
}
/* Draw the title bar */
if (save_state_dialog.mode == SSTATE_MODE_SAVE) {
strcpy(text, " Save State ");
} else {
strcpy(text, " Load State ");
}
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = srcx; dstrect.y = srcy;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* Draw the controls */
strcpy(text, " Exit ");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = srcx; dstrect.y = srcy + 14.5 * 8 * video.scale;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* Draw the slot backgrounds */
dstrect.y = srcy + 1 * 8 * video.scale;
for (ypos = 0; ypos < 3; ypos++) {
dstrect.x = srcx + 0.5 * 8 * video.scale;
for (xpos = 0; xpos < 3; xpos++) {
if (!save_state_dialog.slots[ypos * 3 + xpos]) {
colourRGB = bg_colourRGB;
} else {
colourRGB = fg_colourRGB;
}
dstrect.w = 4 * 8 * video.scale; dstrect.h = 4 * 8 * video.scale;
if (SDL_FillRect(video.screen, &dstrect, colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
dstrect.x += 4.5 * 8 * video.scale;
}
dstrect.y += 4.5 * 8 * video.scale;
}
/* Draw the slot text */
for (ypos = 0; ypos < 3; ypos++) {
for (xpos = 0; xpos < 3; xpos++) {
dstrect.y = srcy + 1 * 8 * video.scale + ypos * 4.5 * 8 * video.scale;
for (ybyte = 0; ybyte < 8; ybyte++) {
dstrect.x = srcx + 0.5 * 8 * video.scale + xpos * 4.5 * 8 * video.scale;
for (xmask = 0x80; xmask >= 1; xmask >>= 1) {
if (save_state_dialog_icons[(ypos * 3 + xpos) * 8 + ybyte] & xmask) {
if (!save_state_dialog.slots[ypos * 3 + xpos]) {
colourRGB = fg_colourRGB;
} else {
colourRGB = bg_colourRGB;
}
dstrect.w = 0.5 * 8 * video.scale; dstrect.h = 0.5 * 8 * video.scale;
if (SDL_FillRect(video.screen, &dstrect, colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
}
dstrect.x += 0.5 * 8 * video.scale;
}
dstrect.y += 0.5 * 8 * video.scale;
}
}
}
}
/* Is the load file dialog being rendered? */
if (load_file_dialog.state) {
srcx = load_file_dialog.xoffset;
srcy = load_file_dialog.yoffset;
/* Draw the background minus the header and nav control lines */
dstrect.x = srcx; dstrect.y = srcy + 8 * video.scale;
dstrect.w = 256 * video.scale; dstrect.h = 176 * video.scale;
if (SDL_FillRect(video.screen, &dstrect, bg_colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
/* Draw the header */
strcpy(text, " Load File ");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = srcx; dstrect.y = srcy;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* Write the details */
sprintf(text, "%i/%i ", load_file_dialog.dirlist_selected + 1,
load_file_dialog.dirlist_count);
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = srcx + 32 * 8 * video.scale - renderedtext->w; dstrect.y = srcy;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* Write the directory list */
for (count = load_file_dialog.dirlist_top;
count < load_file_dialog.dirlist_top + 20 && count < load_file_dialog.dirlist_count;
count++) {
direntry = load_file_dialog.dirlist +
load_file_dialog.dirlist_sizeof * count;
/* Truncate filenames longer than 30 chars */
if (strlen(direntry) <= 30) {
strcpy(text, direntry);
} else {
strncpy(text, direntry, 15);
text[15] = '~'; text[16] = 0;
strcat(text, direntry + strlen(direntry) - 14);
}
/* Render the text highlighting the selected item */
if (count == load_file_dialog.dirlist_selected) {
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
} else {
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, fg_colour, bg_colour);
}
dstrect.x = srcx; dstrect.y = srcy +
(count - load_file_dialog.dirlist_top + 2) * 8 * video.scale;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
}
/* Draw the controls */
strcpy(text, " Load Exit ");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, fg_colour, bg_colour);
dstrect.x = srcx; dstrect.y = srcy + 23 * 8 * video.scale;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* Draw the vertical scrollbar */
/* Up button */
strcpy(text, "\x96");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = hotspots[HS_LDFILE_SBUP].hl_x;
dstrect.y = hotspots[HS_LDFILE_SBUP].hl_y;
dstrect.w = dstrect.h = 1 * 8 * video.scale;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* Down button */
strcpy(text, "\x97");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = hotspots[HS_LDFILE_SBDOWN].hl_x;
dstrect.y = hotspots[HS_LDFILE_SBDOWN].hl_y;
dstrect.w = dstrect.h = 1 * 8 * video.scale;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
/* PgUp/PgDn i.e. the scrollbar background */
strcpy(text, "\x88");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, fg_colour, bg_colour);
dstrect.x = hotspots[HS_LDFILE_SBPGUP].hl_x;
dstrect.w = dstrect.h = 1 * 8 * video.scale;
for (count = 0; count < 18; count++) {
dstrect.y = hotspots[HS_LDFILE_SBPGUP].hl_y + count * 8 * video.scale;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
}
SDL_FreeSurface(renderedtext);
/* Scrollbar handle */
dstrect.x = hotspots[HS_LDFILE_SBHDLE].hl_x;
dstrect.y = hotspots[HS_LDFILE_SBHDLE].hl_y;
dstrect.w = hotspots[HS_LDFILE_SBHDLE].hl_w;
dstrect.h = hotspots[HS_LDFILE_SBHDLE].hl_h;
if (SDL_FillRect(video.screen, &dstrect, fg_colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
/* Scrollbar handle middle */
strcpy(text, "=");
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
dstrect.x = hotspots[HS_LDFILE_SBHDLE].hl_x;
dstrect.y = hotspots[HS_LDFILE_SBHDLE].hl_y +
hotspots[HS_LDFILE_SBHDLE].hl_h / 2 - 0.5 * 8 * video.scale;
dstrect.w = dstrect.h = 1 * 8 * video.scale;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
}
/* Are the virtual keyboard and control bar being rendered? */
if (vkeyb.state) {
if (vkeyb.alpha) {
dstrect.x = vkeyb.xoffset; dstrect.y = vkeyb.yoffset;
dstrect.w = vkeyb.scaled->w; dstrect.h = vkeyb.scaled->h;
if (SDL_BlitSurface (vkeyb.scaled, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__,
SDL_GetError ());
exit(1);
}
}
/* Show the control bar */
dstrect.x = control_bar.xoffset; dstrect.y = control_bar.yoffset;
dstrect.w = control_bar.scaled->w; dstrect.h = control_bar.scaled->h;
if (SDL_BlitSurface (control_bar.scaled, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
}
/* Are the runtime options being rendered? */
if (runtime_options_which() < MAX_RUNTIME_OPTIONS) {
srcx = runtime_options[runtime_options_which()].xoffset;
srcy = runtime_options[runtime_options_which()].yoffset;
/* Draw the background minus the header and nav control lines */
dstrect.x = srcx; dstrect.y = srcy + 8 * video.scale;
dstrect.w = 256 * video.scale; dstrect.h = 176 * video.scale;
if (SDL_FillRect(video.screen, &dstrect, bg_colourRGB) < 0) {
fprintf(stderr, "%s: FillRect error: %s\n", __func__, SDL_GetError ());
exit(1);
}
/* Draw the static text */
invertcolours = FALSE;
for (desy = 0; desy < 24; desy++) {
dstrect.x = srcx; desx = 0;
for (;;) {
do {
text[0] = runtime_options[runtime_options_which()].text[desy][desx++];
/* Invert the colours */
if (text[0] == 2) invertcolours = !invertcolours;
} while (text[0] == 1 || text[0] == 2);
if (text[0]) {
text[1] = 0; /* Null terminate the string */
if (!invertcolours) {
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, fg_colour, bg_colour);
} else {
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
}
dstrect.y = srcy + desy * 8 * video.scale;
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
} else {
break; /* Process next row */
}
dstrect.x += 8 * video.scale;
}
}
/* Write the values at specific positions */
count = 0;
for (desy = 0; desy < 24; desy++) {
dstrect.x = srcx; desx = 0;
for (;;) {
do {
text[0] = runtime_options[runtime_options_which()].text[desy][desx++];
/* Invert the colours */
if (text[0] == 2) invertcolours = !invertcolours;
} while (text[0] == 2);
if (text[0] == 1) {
text[0] = 0; /* Erase it as we might put a value in it */
if (runtime_options[0].state) {
/* The colour inversion here is conditional and so there are
* two \x1's embedded within the text. The first \x1 will
* always draw a char which may be colour inverted, and the
* second \x1 will revert the colour if it was inverted */
if (count >= 0 && count <= 3) {
if (count == 0 || count == 2) strcpy(text, "O");
if ((count <= 1 && runopts_emulator_model) ||
(count >= 2 && !runopts_emulator_model)) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count == 4) {
sprintf(text, "%2i", runopts_emulator_ramsize);
} else if (count >= 5 && count <= 8) {
if (count == 5 || count == 7) strcpy(text, "O");
if ((count <= 6 && !runopts_emulator_m1not) ||
(count >= 7 && runopts_emulator_m1not)) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count == 9) {
sprintf(text, "%1i", sdl_emulator.frameskip);
#ifdef ENABLE_EMULATION_SPEED_ADJUST
} else if (count == 10) {
sprintf(text, "%4i", 2000 / runopts_emulator_speed);
} else if (count == 19) {
#else
} else if (count == 18) {
#endif
if (runopts_is_a_reset_scheduled())
strcpy(text, "* A reset is scheduled on save *");
}
// WRX and UDG
#ifdef ENABLE_EMULATION_SPEED_ADJUST
if (count >= 11 && count<=18) {
if (count >= 11 && count <= 12 && runopts_emulator_wrx != HIRESWRX)
invertcolours = !invertcolours;
if (count >= 13 && count <= 14 && runopts_emulator_wrx == HIRESWRX)
invertcolours = !invertcolours;
if (count >= 15 && count <= 16 && runopts_emulator_chrgen!=CHRGENCHR16 )
invertcolours = !invertcolours;
if (count >= 17 && count <=18 && runopts_emulator_chrgen==CHRGENCHR16 )
invertcolours = !invertcolours;
if (count==11 || count==13 || count==15 || count==17)
strcpy(text, "O");
}
#else
if (count >= 10 && count<=17) {
if (count >= 10 && count <= 11 && runopts_emulator_wrx != HIRESWRX)
invertcolours = !invertcolours;
if (count >= 12 && count <= 13 && runopts_emulator_wrx == HIRESWRX)
invertcolours = !invertcolours;
if (count >= 14 && count <= 15 && runopts_emulator_chrgen!=CHRGENCHR16 )
invertcolours = !invertcolours;
if (count >= 16 && count <=17 && runopts_emulator_chrgen==CHRGENCHR16 )
invertcolours = !invertcolours;
if (count==10 || count==12 || count==14 || count==16)
strcpy(text, "O");
}
#endif
} else if (runtime_options[1].state) {
/* The colour inversion here is conditional and so there are
* two \x1's embedded within the text. The first \x1 will
* always draw a char which may be colour inverted, and the
* second \x1 will revert the colour if it was inverted */
if (count >= 0 && count <= 1) {
if (!(count % 2)) strcpy(text, "O");
if (runopts_sound_device == DEVICE_NONE) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count >= 2 && count <= 3) {
if (!(count % 2)) strcpy(text, "O");
if (runopts_sound_device == DEVICE_QUICKSILVA ||
runopts_sound_device == DEVICE_ZONX) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count >= 4 && count <= 5) {
if (!(count % 2)) strcpy(text, "O");
if (runopts_sound_device == DEVICE_QUICKSILVA) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count >= 6 && count <= 7) {
if (!(count % 2)) strcpy(text, "O");
if (runopts_sound_device == DEVICE_ZONX) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count >= 8 && count <= 9) {
if (!(count % 2)) strcpy(text, "X");
if (runopts_sound_ay_unreal) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count >= 10 && count <= 11) {
if (!(count % 2)) strcpy(text, "O");
if (runopts_sound_device == DEVICE_VSYNC) {
/* Invert the colours */
invertcolours = !invertcolours;
}
} else if (count == 12) {
#ifdef OSS_SOUND_SUPPORT
if (runopts_is_a_reset_scheduled())
strcpy(text, "* A reset is scheduled on save *");
#else
strcpy(text, "* Sound support isn't built in *");
#endif
}
} else if (runtime_options[2].state) {
if (count == 0) {
sprintf(text, "%3i", sdl_sound.volume);
} else if (count == 1) {
sprintf(text, "%3i", sdl_key_repeat.delay);
} else if (count == 2) {
sprintf(text, "%3i", sdl_key_repeat.interval);
} else if (count == 3) {
sprintf(text, "%02x", colours.emu_fg >> 16 & 0xff);
} else if (count == 4) {
sprintf(text, "%02x", colours.emu_bg >> 16 & 0xff);
} else if (count == 5) {
sprintf(text, "%02x", colours.emu_fg >> 8 & 0xff);
} else if (count == 6) {
sprintf(text, "%02x", colours.emu_bg >> 8 & 0xff);
} else if (count == 7) {
sprintf(text, "%02x", colours.emu_fg & 0xff);
} else if (count == 8) {
sprintf(text, "%02x", colours.emu_bg & 0xff);
} else if (count == 9) {
if (runopts_is_a_reset_scheduled())
strcpy(text, "* A reset is scheduled on save *");
}
} else if (runtime_options[3].state) {
if (count == 0) {
sprintf(text, "%2i", joystick_dead_zone);
} else if (count >= 1 && count <= 2) {
sprintf(text, "%s", joy_cfg.text[count - 1]);
} else if (count == 3) {
if (!joystick) {
strcpy(text, "* A joystick is not plugged in *");
} else if (runopts_is_a_reset_scheduled()) {
strcpy(text, "* A reset is scheduled on save *");
}
}
}
if (text[0]) { /* Let's not go to that place - again ;) */
dstrect.y = srcy + desy * 8 * video.scale;
if (!invertcolours) {
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, fg_colour, bg_colour);
} else {
renderedtext = BMF_RenderText(BMF_FONT_ZX82, text, bg_colour, fg_colour);
}
dstrect.w = renderedtext->w; dstrect.h = renderedtext->h;
if (SDL_BlitSurface (renderedtext, NULL, video.screen, &dstrect) < 0) {
fprintf(stderr, "%s: BlitSurface error: %s\n", __func__, SDL_GetError ());
exit(1);
}
SDL_FreeSurface(renderedtext);
}
count++; desx++;
} else if (text[0] == 0) {
break; /* Process next row */
}
dstrect.x += 8 * video.scale;