-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvideo.cc
3496 lines (2794 loc) · 105 KB
/
video.cc
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
/****************************************************************************/
/* Beebem - (c) David Alan Gilbert 1994 */
/* ------------------------------------ */
/* This program may be distributed freely within the following restrictions:*/
/* */
/* 1) You may not charge for this program or for any part of it. */
/* 2) This copyright message must be distributed with all copies. */
/* 3) This program must be distributed complete with source code. Binary */
/* only distribution is not permitted. */
/* 4) The author offers no warrenties, or guarentees etc. - you use it at */
/* your own risk. If it messes something up or destroys your computer */
/* thats YOUR problem. */
/* 5) You may use small sections of code from this program in your own */
/* applications - but you must acknowledge its use. If you plan to use */
/* large sections then please ask the author. */
/* */
/* If you do not agree with any of the above then please do not use this */
/* program. */
/* Please report any problems to the author at beebem@treblig.org */
/****************************************************************************/
/* Video handling - David Alan Gilbert */
/* Version 2 - 24/12/94 - Designed to emulate start of frame interrupt
correctly */
/* Mike Wyatt 7/6/97 - Added cursor display and Win32 port */
/* Richard Gellman 4/2/2001 AAAARGH SHADOW RAM! HELP! */
#define CHAR_WIDTH 8 //12
#define CHAR_HEIGHT 9 //20
//--#if HAVE_CONFIG_H
//--# include <config.h>
//--#endif
//--#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
//--#include "6502core.h"
//--#include "beebmem.h"
//--#include "beebwin.h"
//--#include "main.h"
//--#include "sysvia.h"
//--#include "video.h"
//--#include "uefstate.h"
//--#include "beebsound.h"
//--#include "debug.h"
//--#include "teletext.h"
//++
#include <iostream>
#include <stdlib.h>
#include <SDL.h>
#include "6502core.h"
#include "beebmem.h"
#include "beebwin.h"
#include "main.h"
#include "mode7font.h"
#include "sysvia.h"
#include "video.h"
#ifdef USE_DMA
#include "dma.h"
#endif
#include "beebconfig.h"
#include "beebconfig_data.h"
#include "uefstate.h"
#include "virtualkeyboard.h"
#ifdef BEEB_DOTIME
#include <sys/times.h>
#ifdef SUNOS
#include <sys/param.h>
#endif
#ifdef HPUX
#include <unistd.h>
#endif
#endif
/* Handle SDL surface locking:
*/
extern SDL_Surface *frame_buffer_p;
extern SDL_Surface *rgb_surface;
#define LOCK(s) {if(SDL_MUSTLOCK(s))(void)SDL_LockSurface(s);}
#define UNLOCK(s) {if(SDL_MUSTLOCK(s))(void)SDL_UnlockSurface(s);}
//<----
//++
unsigned int FrameCount=0;
//<-
//++
int IsTeletext=0;
//<-
#ifdef BEEB_DOTIME
#include <sys/times.h>
#ifdef SUNOS
#include <sys/param.h>
#endif
#ifdef HPUX
#include <unistd.h>
#endif
#endif
//++
#include "sdl.h"
//#include "user_config.h"
//<+
using namespace std;
/* Bit assignments in control reg:
0 - Flash colour (0=first colour, 1=second)
1 - Teletext select (0=on chip serialiser, 1=teletext)
2,3 - Bytes per line (2,3=1,1 is 80, 1,0=40, 0,1=20, 0,0=10)
4 - CRTC Clock chip select (0 = low frequency, 1= high frequency)
5,6 - Cursor width in bytes (0,0 = 1 byte, 0,1=not defined, 1,0=2, 1,1=4)
7 - Master cursor width (if set causes large cursor)
*/
EightUChars FastTable[256];
SixteenUChars FastTableDWidth[256]; /* For mode 4,5,6 */
int FastTable_Valid=0;
NarrowResolution FastTableSDL[256];
WideResolution FastTableDWidthSDL[256]; /* For modes 4, 5 and 6 */
typedef void (*LineRoutinePtr)(void);
LineRoutinePtr LineRoutine;
/* Translates middle bits of VideoULA_ControlReg to number of colours */
static int NColsLookup[]={16, 4, 2, 0 /* Not supported 16? */, 0, 16, 4, 2}; /* Based on AUG 379 */
unsigned char VideoULA_ControlReg=0x9c;
unsigned char VideoULA_Palette[16];
unsigned char CRTCControlReg=0;
unsigned char CRTC_HorizontalTotal=127; /* R0 */
unsigned char CRTC_HorizontalDisplayed=80; /* R1 */
unsigned char CRTC_HorizontalSyncPos=98; /* R2 */
unsigned char CRTC_SyncWidth=0x28; /* R3 - top 4 bits are Vertical (in scan lines) and bottom 4 are horizontal in characters */
unsigned char CRTC_VerticalTotal=38; /* R4 */
unsigned char CRTC_VerticalTotalAdjust=0; /* R5 */
unsigned char CRTC_VerticalDisplayed=32; /* R6 */
unsigned char CRTC_VerticalSyncPos=34; /* R7 */
unsigned char CRTC_InterlaceAndDelay=0; /* R8 - 0,1 are interlace modes, 4,5 display blanking delay, 6,7 cursor blanking delay */
unsigned char CRTC_ScanLinesPerChar=7; /* R9 */
unsigned char CRTC_CursorStart=0; /* R10 */
unsigned char CRTC_CursorEnd=0; /* R11 */
unsigned char CRTC_ScreenStartHigh=6; /* R12 */
unsigned char CRTC_ScreenStartLow=0; /* R13 */
unsigned char CRTC_CursorPosHigh=0; /* R14 */
unsigned char CRTC_CursorPosLow=0; /* R15 */
unsigned char CRTC_LightPenHigh=0; /* R16 */
unsigned char CRTC_LightPenLow=0; /* R17 */
/* New hardware cursor variables:
*/
int CursorX = 0;
int CursorY = 0;
int CursorH = 0;
int CursorW = 0;
int CursorO = 0;
#define AdjustVideo NewAdjustVideo
void NewAdjustVideo();
unsigned int ActualScreenWidth=640;
int InitialOffset=0;
long ScreenAdjust=0; // Mode 7 Defaults.
long VScreenAdjust=0;
int VStart,HStart;
unsigned char HSyncModifier=9;
unsigned char TeletextEnabled;
char TeletextStyle=1; // Defines wether teletext will skip intermediate lines in order to speed up
int THalfMode=0; // 1 if to use half-mode (TeletextStyle=1 all the time)
int CurY=-1;
FILE *crtclog;
int ova,ovn; // mem ptr buffers
/* CharLine counts from the 'reference point' - i.e. the point at which we reset the address pointer - NOT
the point of the sync. If it is -ve its actually in the adjust time */
typedef struct {
int Addr; /* Address of start of next visible character line in beeb memory - raw */
int StartAddr; /* Address of start of first character line in beeb memory - raw */
int PixmapLine; /* Current line in the pixmap */
int FirstPixmapLine; /* The first pixmap line where something is visible. Used to eliminate the
blank virtical retrace lines at the top of the screen. */
int PreviousFirstPixmapLine; /* The first pixmap line on the previous frame */
int LastPixmapLine; /* The last pixmap line where something is visible. Used to eliminate the
blank virtical retrace lines at the bottom of the screen. */
int PreviousLastPixmapLine; /* The last pixmap line on the previous frame */
int IsTeletext; /* This frame is a teletext frame - do things differently */
char *DataPtr; /* Pointer into host memory of video data */
int CharLine; /* 6845 counts in characters vertically - 0 at the top , incs by 1 - -1 means we are in the bit before the actual display starts */
int InCharLineUp; /* Scanline within a character line - counts up*/
int VSyncState; // Cannot =0 in MSVC $NRM; /* When >0 VSync is high */
} VideoStateT;
static VideoStateT VideoState;
int VideoTriggerCount=9999; /* Number of cycles before next scanline service */
/* first subscript is graphics flag (1 for graphics,2 for separated graphics), next is character, then scanline */
/* character is (valu &127)-32 */
static unsigned int EM7Font[3][96][20]; // 20 rows to account for "half pixels"
static int Mode7FlashOn=1; /* True if a flashing character in mode 7 is on */
static int Mode7DoubleHeightFlags[80]; /* Pessimistic size for this flags - if 1 then corresponding character on NEXT line is top half */
static int CurrentLineBottom=0;
static int NextLineBottom=0; // 1 if the next line of double height should be bottoms only
/* Flash every half second(?) i.e. 25 x 50Hz fields */
// No. On time is longer than off time. - according to my datasheet, its 0.75Hz with 3:1 ON:OFF ratio. - Richard Gellman
// cant see that myself.. i think it means on for 0.75 secs, off for 0.25 secs
#define MODE7FLASHFREQUENCY 25
#define MODE7ONFIELDS 37
#define MODE7OFFFIELDS 13
unsigned char CursorOnFields,CursorOffFields;
int CursorFieldCount=32;
unsigned char CursorOnState=1;
int Mode7FlashTrigger=MODE7ONFIELDS;
/* If 1 then refresh on every display, else refresh every n'th display */
int Video_RefreshFrequency=1;
/* The number of the current frame - starts at Video_RefreshFrequency - at 0 actually refresh */
static int FrameNum=0;
//++
int time_slept=0;
//<-
WideResolution* GetWideScanlineSDL(int y, int *BytesToGo);
NarrowResolution* GetNarrowScanlineSDL(int y, int *BytesToGo);
static void LowLevelDoScanLineNarrow();
static void LowLevelDoScanLineWide();
static void LowLevelDoScanLineNarrowNot4Bytes();
static void LowLevelDoScanLineWideNot4Bytes();
static void LowLevelDoScanLineNarrowSDL();
static void LowLevelDoScanLineNarrowNot4BytesSDL();
static void LowLevelDoScanLineWideSDL();
static void LowLevelDoScanLineWideNot4BytesSDL();
static void DoFastTable16SDL(void);
static void DoFastTable16XStep8SDL(void);
static void DoFastTable4SDL(void);
static void DoFastTable4XStep4SDL(void);
static void DoFastTable2SDL(void);
static void DoFastTable2XStep2SDL(void);
static int IsFlippedMode(void);
static void VideoAddCursor(void);
//$$ void AdjustVideo();
void VideoAddLEDs(void);
//+>
//## Just for now.. Hack to fudge scanline width in graphic/teletext code:
//## Dave Eggleston - will go when video support is rewritten.
//--static int screen_width;
//--static void set_screen_width(void)
//--{
//--// screen_width = fullscreen;
//--
//--// switch (fullscreen?cfg_Fullscreen_Resolution:cfg_Windowed_Resolution) {
//-- switch (mainWin->IsFullScreen()?cfg_Fullscreen_Resolution:cfg_Windowed_Resolution) {
//-- case RESOLUTION_640X512:
//-- case RESOLUTION_640X480_S:
//-- case RESOLUTION_640X480_V:
//-- screen_width=640;
//-- break;
//-- default:
//-- screen_width=320;
//-- }
//--}
//<+
void rgb_blit()
{
SDL_BlitSurface(frame_buffer_p, NULL, rgb_surface, NULL);
SDL_UpdateRect(rgb_surface, 0, 0, 0, 0);
}
// A 'Chunky Mode' get pixel routine:
static inline int GetPixel_8(SDL_Surface *surface_p, int x, int y)
{
Uint8 *p;
if (surface_p == NULL) return 0;
if (x<0 || x>surface_p->w) return 0;
if (y<0 || y>surface_p->h) return 0;
if (surface_p->format->BytesPerPixel != 1) return 0;
p = (Uint8*) surface_p->pixels+y*surface_p->pitch+x;
return (int) *p;
}
// This does the same thing as the Windows Mode7 font loader
// but does it using .bmp files for easier editing.
static void BuldMode7Font_8x9(void) {
SDL_Surface *f_p;
unsigned int m7cc, m7cy, m7cx, m7cr, p;
f_p = SDL_LoadBMP(config.files.teletext_font_loc);
if (f_p == NULL) {
fprintf(stderr, "Couldn't open teletext font [%s].\n", config.files.teletext_font_loc);
exit(10);
}
for(m7cc=0; m7cc<96; m7cc++) {
for(m7cy=0; m7cy<9; m7cy++) {
m7cr=0;
for(m7cx=0; m7cx<8; m7cx++) {
if ( (p=GetPixel_8(f_p, m7cx, m7cy+(9*m7cc) /* *(m7cc*9) */))==1) {
//printf("*");
if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
m7cr|=(1<<(8-m7cx));
else
m7cr|=(1<<(m7cx));
}// else {
// printf("_");
//}
}
//printf("\t%X\n", m7cr);
EM7Font[0][m7cc][m7cy]=m7cr;
EM7Font[1][m7cc][m7cy]=m7cr;
EM7Font[2][m7cc][m7cy]=m7cr;
}
//printf("\n");
}
unsigned int row1,row2,row3; // row builders for mode 7 graphics
// Now fill in the graphics - this is built from an algorithm, but has certain lines/columns
// blanked for separated graphics.
for (m7cc=0;m7cc<96;m7cc++) {
// here's how it works: top two blocks: 1 & 2
// middle two blocks: 4 & 8
// bottom two blocks: 16 & 64
// its only a grpahics character if bit 5 (32) is clear.
if (!(m7cc & 32)) {
row1=0; row2=0; row3=0;
// left block has a value of 4032, right 63 and both 4095
// if (m7cc & 1) row1|=4032;
// if (m7cc & 2) row1|=63;
// if (m7cc & 4) row2|=4032;
// if (m7cc & 8) row2|=63;
// if (m7cc & 16) row3|=4032;
// if (m7cc & 64) row3|=63;
if (m7cc & 1) row1|=0xf0;
if (m7cc & 2) row1|=0x0f;
if (m7cc & 4) row2|=0xf0;
if (m7cc & 8) row2|=0x0f;
if (m7cc & 16) row3|=0xf0;
if (m7cc & 64) row3|=0x0f;
// now input these values into the array
// top row of blocks - continuous
// EM7Font[1][m7cc][0]=EM7Font[1][m7cc][1]=EM7Font[1][m7cc][2]=row1;
// EM7Font[1][m7cc][3]=EM7Font[1][m7cc][4]=EM7Font[1][m7cc][5]=row1;
EM7Font[1][m7cc][0]=EM7Font[1][m7cc][1]=EM7Font[1][m7cc][2]=row1;
// Separated
//row1&=975; // insert gaps
row1&=0xEE;
EM7Font[2][m7cc][0]=EM7Font[2][m7cc][1]=row1;
EM7Font[2][m7cc][2]=0;
// EM7Font[2][m7cc][0]=EM7Font[2][m7cc][1]=EM7Font[2][m7cc][2]=row1;
// EM7Font[2][m7cc][3]=row1; EM7Font[2][m7cc][4]=EM7Font[2][m7cc][5]=0;
// middle row of blocks - continuous
// EM7Font[1][m7cc][6]=EM7Font[1][m7cc][7]=EM7Font[1][m7cc][8]=row2;
// EM7Font[1][m7cc][9]=EM7Font[1][m7cc][10]=EM7Font[1][m7cc][11]=row2;
// EM7Font[1][m7cc][12]=EM7Font[1][m7cc][13]=row2;
EM7Font[1][m7cc][3]=EM7Font[1][m7cc][4]=EM7Font[1][m7cc][5]=row2;
// Separated
//row2&=975; // insert gaps
row2&=0xEE;
EM7Font[2][m7cc][3]=EM7Font[2][m7cc][4]=row2;
EM7Font[2][m7cc][5]=0;
// EM7Font[2][m7cc][6]=EM7Font[2][m7cc][7]=EM7Font[2][m7cc][8]=row2;
// EM7Font[2][m7cc][9]=EM7Font[2][m7cc][10]=EM7Font[2][m7cc][11]=row2;
// EM7Font[2][m7cc][12]=EM7Font[2][m7cc][13]=0;
// Bottom row - continuous
// EM7Font[1][m7cc][14]=EM7Font[1][m7cc][15]=EM7Font[1][m7cc][16]=row3;
// EM7Font[1][m7cc][17]=EM7Font[1][m7cc][18]=EM7Font[1][m7cc][19]=row3;
EM7Font[1][m7cc][6]=EM7Font[1][m7cc][7]=EM7Font[1][m7cc][8]=row3;
// Separated
//row3&=975; // insert gaps
row3&=0xEE;
EM7Font[2][m7cc][6]=EM7Font[2][m7cc][7]=row3;
EM7Font[2][m7cc][8]=0;
// EM7Font[2][m7cc][14]=EM7Font[2][m7cc][15]=EM7Font[2][m7cc][16]=row3;
// EM7Font[2][m7cc][17]=row3; EM7Font[2][m7cc][18]=EM7Font[2][m7cc][19]=0;
} // check for valid char to modify
} // character loop.
}
//static void BuildMode7Font_12x20(void) {
//}
/*-------------------------------------------------------------------------------------------------------------*/
//--static void BuildMode7Font(void) {
//-- FILE *m7File;
//-- unsigned char m7cc,m7cy;
//-- unsigned int m7cb;
//-- unsigned int row1,row2,row3; // row builders for mode 7 graphics
//-- char TxtFnt[256];
//-- /* cout <<"Building mode 7 font data structures\n"; */
//-- // Build enhanced mode 7 font
//--
//-- BuldMode7Font_8x9();
//-- return;
//--
//--
//--//////////////////////////////
//-- unsigned char *p = (unsigned char*) frame_buffer_p->pixels;
//--//////////////////////////////
//--
//--
//--//->
//--//-- strcpy(TxtFnt,RomPath);
//--//-- strcat(TxtFnt,"teletext.fnt");
//--//++
//--// strcpy(TxtFnt, DATA_DIR);
//--// strcat(TxtFnt, "/resources/teletext.fnt");
//--
//-- GetLocation_teletext(TxtFnt, 256);
//-- pINFO(dL"Loading teletext font: '%s'", dR, TxtFnt);
//--//<-
//--
//-- m7File=fopen(TxtFnt,"rb");
//-- if (m7File == NULL)
//-- {
//-- char errstr[200];
//-- sprintf(errstr, "Cannot open Teletext font file teletext.fnt");
//-- MessageBox(GETHWND,errstr,"BBC Emulator",MB_OK|MB_ICONERROR);
//-- exit(1);
//-- }
//-- for (m7cc=32;m7cc<=127;m7cc++) {
//-- for (m7cy=0;m7cy<=17;m7cy++) {
//-- m7cb=fgetc(m7File);
//-- m7cb|=fgetc(m7File)<<8;
//-- EM7Font[0][m7cc-32][m7cy+2]=m7cb<<2;
//-- EM7Font[1][m7cc-32][m7cy+2]=m7cb<<2;
//-- EM7Font[2][m7cc-32][m7cy+2]=m7cb<<2;
//--
//-- for(int i=0; i<16; i++) {
//-- int c = (m7cb >> (15-i)) & 1;
//-- printf("%c", c == 1 ? '*' : '_');
//-- }
//-- printf("\n");
//-- }
//-- EM7Font[0][m7cc-32][0]=EM7Font[1][m7cc-32][0]=EM7Font[2][m7cc-32][0]=0;
//-- EM7Font[0][m7cc-32][1]=EM7Font[1][m7cc-32][1]=EM7Font[2][m7cc-32][1]=0;
//--
//-- EM7Font[0][m7cc-32][0]=EM7Font[0][m7cc-32][1];
//-- EM7Font[0][m7cc-32][1]=EM7Font[0][m7cc-32][3];
//-- EM7Font[0][m7cc-32][2]=EM7Font[0][m7cc-32][5];
//-- EM7Font[0][m7cc-32][3]=EM7Font[0][m7cc-32][7];
//-- EM7Font[0][m7cc-32][4]=EM7Font[0][m7cc-32][9];
//-- EM7Font[0][m7cc-32][5]=EM7Font[0][m7cc-32][11];
//-- EM7Font[0][m7cc-32][6]=EM7Font[0][m7cc-32][13];
//-- EM7Font[0][m7cc-32][7]=EM7Font[0][m7cc-32][15];
//--
//-- }
//--
//-- fclose(m7File);
//-- // Now fill in the graphics - this is built from an algorithm, but has certain lines/columns
//-- // blanked for separated graphics.
//-- for (m7cc=0;m7cc<96;m7cc++) {
//-- // here's how it works: top two blocks: 1 & 2
//-- // middle two blocks: 4 & 8
//-- // bottom two blocks: 16 & 64
//-- // its only a grpahics character if bit 5 (32) is clear.
//-- if (!(m7cc & 32)) {
//-- row1=0; row2=0; row3=0;
//-- // left block has a value of 4032, right 63 and both 4095
//-- if (m7cc & 1) row1|=4032;
//-- if (m7cc & 2) row1|=63;
//-- if (m7cc & 4) row2|=4032;
//-- if (m7cc & 8) row2|=63;
//-- if (m7cc & 16) row3|=4032;
//-- if (m7cc & 64) row3|=63;
//-- // now input these values into the array
//-- // top row of blocks - continuous
//-- EM7Font[1][m7cc][0]=EM7Font[1][m7cc][1]=EM7Font[1][m7cc][2]=row1;
//-- EM7Font[1][m7cc][3]=EM7Font[1][m7cc][4]=EM7Font[1][m7cc][5]=row1;
//-- // Separated
//-- row1&=975; // insert gaps
//-- EM7Font[2][m7cc][0]=EM7Font[2][m7cc][1]=EM7Font[2][m7cc][2]=row1;
//-- EM7Font[2][m7cc][3]=row1; EM7Font[2][m7cc][4]=EM7Font[2][m7cc][5]=0;
//-- // middle row of blocks - continuous
//-- EM7Font[1][m7cc][6]=EM7Font[1][m7cc][7]=EM7Font[1][m7cc][8]=row2;
//-- EM7Font[1][m7cc][9]=EM7Font[1][m7cc][10]=EM7Font[1][m7cc][11]=row2;
//-- EM7Font[1][m7cc][12]=EM7Font[1][m7cc][13]=row2;
//-- // Separated
//-- row2&=975; // insert gaps
//-- EM7Font[2][m7cc][6]=EM7Font[2][m7cc][7]=EM7Font[2][m7cc][8]=row2;
//-- EM7Font[2][m7cc][9]=EM7Font[2][m7cc][10]=EM7Font[2][m7cc][11]=row2;
//-- EM7Font[2][m7cc][12]=EM7Font[2][m7cc][13]=0;
//-- // Bottom row - continuous
//-- EM7Font[1][m7cc][14]=EM7Font[1][m7cc][15]=EM7Font[1][m7cc][16]=row3;
//-- EM7Font[1][m7cc][17]=EM7Font[1][m7cc][18]=EM7Font[1][m7cc][19]=row3;
//-- // Separated
//-- row3&=975; // insert gaps
//-- EM7Font[2][m7cc][14]=EM7Font[2][m7cc][15]=EM7Font[2][m7cc][16]=row3;
//-- EM7Font[2][m7cc][17]=row3; EM7Font[2][m7cc][18]=EM7Font[2][m7cc][19]=0;
//-- } // check for valid char to modify
//-- } // character loop.
//--}; /* BuildMode7Font */
/*-------------------------------------------------------------------------------------------------------------*/
static void DoFastTable16(void) {
unsigned int beebpixvl,beebpixvr;
unsigned int bplvopen,bplvtotal;
unsigned char tmp;
for(beebpixvl=0;beebpixvl<16;beebpixvl++) {
bplvopen=((beebpixvl & 8)?128:0) |
((beebpixvl & 4)?32:0) |
((beebpixvl & 2)?8:0) |
((beebpixvl & 1)?2:0);
for(beebpixvr=0;beebpixvr<16;beebpixvr++) {
bplvtotal=bplvopen |
((beebpixvr & 8)?64:0) |
((beebpixvr & 4)?16:0) |
((beebpixvr & 2)?4:0) |
((beebpixvr & 1)?1:0);
tmp=VideoULA_Palette[beebpixvl];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTable[bplvtotal].data[0]=FastTable[bplvtotal].data[1]=
FastTable[bplvtotal].data[2]=FastTable[bplvtotal].data[3]=mainWin->cols[tmp];
// FastTable[bplvtotal].data[0] = mainWin->cols[tmp];
// FastTable[bplvtotal].data[1]=0;
// FastTable[bplvtotal].data[2]=0;
// FastTable[bplvtotal].data[3]=0;
tmp=VideoULA_Palette[beebpixvr];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTable[bplvtotal].data[4]=FastTable[bplvtotal].data[5]=
FastTable[bplvtotal].data[6]=FastTable[bplvtotal].data[7]=mainWin->cols[tmp];
// FastTable[bplvtotal].data[4]=mainWin->cols[tmp];
// FastTable[bplvtotal].data[5]=0;
// FastTable[bplvtotal].data[6]=0;
// FastTable[bplvtotal].data[7]=0;
}; /* beebpixr */
}; /* beebpixl */
}; /* DoFastTable16 */
// [HERE] Mode 2
static void DoFastTable16SDL(void) {
unsigned int beebpixvl,beebpixvr;
unsigned int bplvopen,bplvtotal;
unsigned char tmp;
for(beebpixvl=0;beebpixvl<16;beebpixvl++) {
bplvopen=((beebpixvl & 8)?128:0) |
((beebpixvl & 4)?32:0) |
((beebpixvl & 2)?8:0) |
((beebpixvl & 1)?2:0);
for(beebpixvr=0;beebpixvr<16;beebpixvr++) {
bplvtotal=bplvopen |
((beebpixvr & 8)?64:0) |
((beebpixvr & 4)?16:0) |
((beebpixvr & 2)?4:0) |
((beebpixvr & 1)?1:0);
tmp=VideoULA_Palette[beebpixvl];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableSDL[bplvtotal].data[3]=FastTableSDL[bplvtotal].data[2]=mainWin->cols[tmp];
else
FastTableSDL[bplvtotal].data[0]=FastTableSDL[bplvtotal].data[1]=mainWin->cols[tmp];
tmp=VideoULA_Palette[beebpixvr];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableSDL[bplvtotal].data[1]=FastTableSDL[bplvtotal].data[0]=mainWin->cols[tmp];
else
FastTableSDL[bplvtotal].data[2]=FastTableSDL[bplvtotal].data[3]=mainWin->cols[tmp];
}; /* beebpixr */
}; /* beebpixl */
}; /* DoFastTable16 */
/*-------------------------------------------------------------------------------------------------------------*/
static void DoFastTable16XStep8(void) {
unsigned int beebpixvl,beebpixvr;
unsigned int bplvopen,bplvtotal;
unsigned char tmp;
for(beebpixvl=0;beebpixvl<16;beebpixvl++) {
bplvopen=((beebpixvl & 8)?128:0) |
((beebpixvl & 4)?32:0) |
((beebpixvl & 2)?8:0) |
((beebpixvl & 1)?2:0);
for(beebpixvr=0;beebpixvr<16;beebpixvr++) {
bplvtotal=bplvopen |
((beebpixvr & 8)?64:0) |
((beebpixvr & 4)?16:0) |
((beebpixvr & 2)?4:0) |
((beebpixvr & 1)?1:0);
tmp=VideoULA_Palette[beebpixvl];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTableDWidth[bplvtotal].data[0]=FastTableDWidth[bplvtotal].data[1]=
FastTableDWidth[bplvtotal].data[2]=FastTableDWidth[bplvtotal].data[3]=
FastTableDWidth[bplvtotal].data[4]=FastTableDWidth[bplvtotal].data[5]=
FastTableDWidth[bplvtotal].data[6]=FastTableDWidth[bplvtotal].data[7]=mainWin->cols[tmp];
// FastTableDWidth[bplvtotal].data[0]=mainWin->cols[tmp];
// FastTableDWidth[bplvtotal].data[1]=0;
// FastTableDWidth[bplvtotal].data[2]=0;
// FastTableDWidth[bplvtotal].data[3]=0;
// FastTableDWidth[bplvtotal].data[4]=0;
// FastTableDWidth[bplvtotal].data[5]=0;
// FastTableDWidth[bplvtotal].data[6]=0;
// FastTableDWidth[bplvtotal].data[7]=0;
//
tmp=VideoULA_Palette[beebpixvr];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTableDWidth[bplvtotal].data[8]=FastTableDWidth[bplvtotal].data[9]=
FastTableDWidth[bplvtotal].data[10]=FastTableDWidth[bplvtotal].data[11]=
FastTableDWidth[bplvtotal].data[12]=FastTableDWidth[bplvtotal].data[13]=
FastTableDWidth[bplvtotal].data[14]=FastTableDWidth[bplvtotal].data[15]=mainWin->cols[tmp];
// FastTableDWidth[bplvtotal].data[8]=mainWin->cols[tmp];
// FastTableDWidth[bplvtotal].data[9]=0;
// FastTableDWidth[bplvtotal].data[10]=0;
// FastTableDWidth[bplvtotal].data[11]=0;
// FastTableDWidth[bplvtotal].data[12]=0;
// FastTableDWidth[bplvtotal].data[13]=0;
// FastTableDWidth[bplvtotal].data[14]=0;
// FastTableDWidth[bplvtotal].data[15]=0;
//
}; /* beebpixr */
}; /* beebpixl */
}; /* DoFastTable16XStep8 */
static void DoFastTable16XStep8SDL(void) {
unsigned int beebpixvl,beebpixvr;
unsigned int bplvopen,bplvtotal;
unsigned char tmp;
for(beebpixvl=0;beebpixvl<16;beebpixvl++) {
bplvopen=((beebpixvl & 8)?128:0) |
((beebpixvl & 4)?32:0) |
((beebpixvl & 2)?8:0) |
((beebpixvl & 1)?2:0);
for(beebpixvr=0;beebpixvr<16;beebpixvr++) {
bplvtotal=bplvopen |
((beebpixvr & 8)?64:0) |
((beebpixvr & 4)?16:0) |
((beebpixvr & 2)?4:0) |
((beebpixvr & 1)?1:0);
tmp=VideoULA_Palette[beebpixvl];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableDWidthSDL[bplvtotal].data[4]=FastTableDWidthSDL[bplvtotal].data[5]=FastTableDWidthSDL[bplvtotal].data[6]=FastTableDWidthSDL[bplvtotal].data[7]=mainWin->cols[tmp];
else
FastTableDWidthSDL[bplvtotal].data[0]=FastTableDWidthSDL[bplvtotal].data[1]=
FastTableDWidthSDL[bplvtotal].data[2]=FastTableDWidthSDL[bplvtotal].data[3]=mainWin->cols[tmp];
tmp=VideoULA_Palette[beebpixvr];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableDWidthSDL[bplvtotal].data[0]=FastTableDWidthSDL[bplvtotal].data[1]=FastTableDWidthSDL[bplvtotal].data[2]=FastTableDWidthSDL[bplvtotal].data[3]=mainWin->cols[tmp];
else
FastTableDWidthSDL[bplvtotal].data[4]=FastTableDWidthSDL[bplvtotal].data[5]=
FastTableDWidthSDL[bplvtotal].data[6]=FastTableDWidthSDL[bplvtotal].data[7]=mainWin->cols[tmp];
}; /* beebpixr */
}; /* beebpixl */
}; /* DoFastTable16XStep8 */
/*-------------------------------------------------------------------------------------------------------------*/
/* Some guess work and experimentation has determined that the left most pixel uses bits 7,5,3,1 for the */
/* palette address, the next uses 6,4,2,0, the next uses 5,3,1,H (H=High), then 5,2,0,H */
static void DoFastTable4(void) {
unsigned char tmp;
unsigned long beebpixv,pentry;
for(beebpixv=0;beebpixv<256;beebpixv++) {
pentry=((beebpixv & 128)?8:0)
| ((beebpixv & 32)?4:0)
| ((beebpixv & 8)?2:0)
| ((beebpixv & 2)?1:0);
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTable[beebpixv].data[0]=FastTable[beebpixv].data[1]=mainWin->cols[tmp];
// FastTable[beebpixv].data[0]=mainWin->cols[tmp];
// FastTable[beebpixv].data[1]=0;
//
pentry=((beebpixv & 64)?8:0)
| ((beebpixv & 16)?4:0)
| ((beebpixv & 4)?2:0)
| ((beebpixv & 1)?1:0);
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTable[beebpixv].data[2]=FastTable[beebpixv].data[3]=mainWin->cols[tmp];
// FastTable[beebpixv].data[2]=mainWin->cols[tmp];
// FastTable[beebpixv].data[3]=0;
//
pentry=((beebpixv & 32)?8:0)
| ((beebpixv & 8)?4:0)
| ((beebpixv & 2)?2:0)
| 1;
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTable[beebpixv].data[4]=FastTable[beebpixv].data[5]=mainWin->cols[tmp];
// FastTable[beebpixv].data[4]=mainWin->cols[tmp];
// FastTable[beebpixv].data[5]=0;
//
pentry=((beebpixv & 16)?8:0)
| ((beebpixv & 4)?4:0)
| ((beebpixv & 1)?2:0)
| 1;
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTable[beebpixv].data[6]=FastTable[beebpixv].data[7]=mainWin->cols[tmp];
// FastTable[beebpixv].data[6]=mainWin->cols[tmp];
// FastTable[beebpixv].data[7]=0;
//
}; /* beebpixv */
}; /* DoFastTable4 */
static void DoFastTable4SDL(void) {
unsigned char tmp;
unsigned long beebpixv,pentry;
for(beebpixv=0;beebpixv<256;beebpixv++) {
pentry=((beebpixv & 128)?8:0)
| ((beebpixv & 32)?4:0)
| ((beebpixv & 8)?2:0)
| ((beebpixv & 2)?1:0);
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableSDL[beebpixv].data[3]=mainWin->cols[tmp];
else
FastTableSDL[beebpixv].data[0]=mainWin->cols[tmp];
pentry=((beebpixv & 64)?8:0)
| ((beebpixv & 16)?4:0)
| ((beebpixv & 4)?2:0)
| ((beebpixv & 1)?1:0);
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableSDL[beebpixv].data[2]=mainWin->cols[tmp];
else
FastTableSDL[beebpixv].data[1]=mainWin->cols[tmp];
pentry=((beebpixv & 32)?8:0)
| ((beebpixv & 8)?4:0)
| ((beebpixv & 2)?2:0)
| 1;
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableSDL[beebpixv].data[1]=mainWin->cols[tmp];
else
FastTableSDL[beebpixv].data[2]=mainWin->cols[tmp];
pentry=((beebpixv & 16)?8:0)
| ((beebpixv & 4)?4:0)
| ((beebpixv & 1)?2:0)
| 1;
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
if ( IsFlippedMode() )
FastTableSDL[beebpixv].data[0]=mainWin->cols[tmp];
else
FastTableSDL[beebpixv].data[3]=mainWin->cols[tmp];
}; /* beebpixv */
}; /* DoFastTable4 */
/*-------------------------------------------------------------------------------------------------------------*/
/* Some guess work and experimentation has determined that the left most pixel uses bits 7,5,3,1 for the */
/* palette address, the next uses 6,4,2,0, the next uses 5,3,1,H (H=High), then 5,2,0,H */
static void DoFastTable4XStep4(void) {
unsigned char tmp;
unsigned long beebpixv,pentry;
for(beebpixv=0;beebpixv<256;beebpixv++) {
pentry=((beebpixv & 128)?8:0)
| ((beebpixv & 32)?4:0)
| ((beebpixv & 8)?2:0)
| ((beebpixv & 2)?1:0);
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTableDWidth[beebpixv].data[0]=FastTableDWidth[beebpixv].data[1]=
FastTableDWidth[beebpixv].data[2]=FastTableDWidth[beebpixv].data[3]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[0]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[1]=0;
// FastTableDWidth[beebpixv].data[2]=0;
// FastTableDWidth[beebpixv].data[3]=0;
//
pentry=((beebpixv & 64)?8:0)
| ((beebpixv & 16)?4:0)
| ((beebpixv & 4)?2:0)
| ((beebpixv & 1)?1:0);
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTableDWidth[beebpixv].data[4]=FastTableDWidth[beebpixv].data[5]=
FastTableDWidth[beebpixv].data[6]=FastTableDWidth[beebpixv].data[7]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[4]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[5]=0;
// FastTableDWidth[beebpixv].data[6]=0;
// FastTableDWidth[beebpixv].data[7]=0;
//
pentry=((beebpixv & 32)?8:0)
| ((beebpixv & 8)?4:0)
| ((beebpixv & 2)?2:0)
| 1;
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTableDWidth[beebpixv].data[8]=FastTableDWidth[beebpixv].data[9]=
FastTableDWidth[beebpixv].data[10]=FastTableDWidth[beebpixv].data[11]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[8]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[9]=0;
// FastTableDWidth[beebpixv].data[10]=0;
// FastTableDWidth[beebpixv].data[11]=0;
//
pentry=((beebpixv & 16)?8:0)
| ((beebpixv & 4)?4:0)
| ((beebpixv & 1)?2:0)
| 1;
tmp=VideoULA_Palette[pentry];
if (tmp>7) {
tmp&=7;
if (VideoULA_ControlReg & 1) tmp^=7;
};
// [HERE]
FastTableDWidth[beebpixv].data[12]=FastTableDWidth[beebpixv].data[13]=
FastTableDWidth[beebpixv].data[14]=FastTableDWidth[beebpixv].data[15]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[12]=mainWin->cols[tmp];
// FastTableDWidth[beebpixv].data[13]=0;
// FastTableDWidth[beebpixv].data[14]=0;