forked from buricco/marduk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtms9918.c
696 lines (569 loc) · 17.2 KB
/
tms9918.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
/*
* Copyright (c) 2021 Troy Schrapel.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following condition: The
* above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "tms9918.h"
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#define VRAM_SIZE (1 << 14) /* 16KB */
#define GRAPHICS_NUM_COLS 32
#define GRAPHICS_NUM_ROWS 24
#define GRAPHICS_CHAR_WIDTH 8
#define TEXT_NUM_COLS 40
#define TEXT_NUM_ROWS 24
#define TEXT_CHAR_WIDTH 6
#define MAX_SPRITES 32
#define SPRITE_ATTR_BYTES 4
#define LAST_SPRITE_VPOS 0xD0
#define MAX_SCANLINE_SPRITES 4
#define STATUS_INT 0x80
#define STATUS_5S 0x40
#define STATUS_COL 0x20
/* PRIVATE DATA STRUCTURE
* ---------------------------------------- */
struct vrEmuTMS9918_s
{
uint8_t vram[VRAM_SIZE];
uint8_t registers[TMS_NUM_REGISTERS];
uint8_t status;
uint8_t lastMode;
uint16_t currentAddress;
vrEmuTms9918Mode mode;
uint8_t rowSpriteBits[TMS9918_PIXELS_X];
};
/* Function: tmsMode
* --------------------
* return the current mode
*/
static vrEmuTms9918Mode tmsMode(VrEmuTms9918* tms9918)
{
if (tms9918->registers[TMS_REG_0] & 0x02)
{
return TMS_MODE_GRAPHICS_II;
}
switch ((tms9918->registers[TMS_REG_1] & 0x18) >> 3)
{
case 0:
return TMS_MODE_GRAPHICS_I;
case 1:
return TMS_MODE_MULTICOLOR;
case 2:
return TMS_MODE_TEXT;
}
return TMS_MODE_GRAPHICS_I;
}
/* Function: tmsSpriteSize
* --------------------
* sprite size (0 = 8x8, 1 = 16x16)
*/
static inline bool tmsSpriteSize(VrEmuTms9918* tms9918)
{
return tms9918->registers[TMS_REG_1] & 0x02;
}
/* Function: tmsSpriteMagnification
* --------------------
* sprite size (0 = 1x, 1 = 2x)
*/
static inline bool tmsSpriteMag(VrEmuTms9918* tms9918)
{
return tms9918->registers[TMS_REG_1] & 0x01;
}
/* Function: tmsNameTableAddr
* --------------------
* name table base address
*/
static inline uint16_t tmsNameTableAddr(VrEmuTms9918* tms9918)
{
return (tms9918->registers[TMS_REG_2] & 0x0f) << 10;
}
/* Function: tmsColorTableAddr
* --------------------
* color table base address
*/
static inline uint16_t tmsColorTableAddr(VrEmuTms9918* tms9918)
{
if (tms9918->mode == TMS_MODE_GRAPHICS_II)
return (tms9918->registers[TMS_REG_3] & 0x80) << 6;
return tms9918->registers[TMS_REG_3] << 6;
}
/* Function: tmsPatternTableAddr
* --------------------
* pattern table base address
*/
static inline uint16_t tmsPatternTableAddr(VrEmuTms9918* tms9918)
{
if (tms9918->mode == TMS_MODE_GRAPHICS_II)
return (tms9918->registers[TMS_REG_4] & 0x04) << 11;
return (tms9918->registers[TMS_REG_4] & 0x07) << 11;
}
/* Function: tmsSpriteAttrTableAddr
* --------------------
* sprite attribute table base address
*/
static inline uint16_t tmsSpriteAttrTableAddr(VrEmuTms9918* tms9918)
{
return (tms9918->registers[TMS_REG_5] & 0x7f) << 7;
}
/* Function: tmsSpritePatternTableAddr
* --------------------
* sprite pattern table base address
*/
static inline uint16_t tmsSpritePatternTableAddr(VrEmuTms9918* tms9918)
{
return (tms9918->registers[TMS_REG_6] & 0x07) << 11;
}
/* Function: tmsBgColor
* --------------------
* background color
*/
static inline vrEmuTms9918Color tmsMainBgColor(VrEmuTms9918* tms9918)
{
return (vrEmuTms9918Color)((vrEmuTms9918DisplayEnabled(tms9918)
? tms9918->registers[TMS_REG_7]
: TMS_BLACK) & 0x0f);
}
/* Function: tmsFgColor
* --------------------
* foreground color
*/
static inline vrEmuTms9918Color tmsMainFgColor(VrEmuTms9918* tms9918)
{
vrEmuTms9918Color c = (vrEmuTms9918Color)(tms9918->registers[TMS_REG_7] >> 4);
return c == TMS_TRANSPARENT ? tmsMainBgColor(tms9918) : c;
}
/* Function: tmsFgColor
* --------------------
* foreground color
*/
static inline vrEmuTms9918Color tmsFgColor(VrEmuTms9918* tms9918, uint8_t colorByte)
{
vrEmuTms9918Color c = (vrEmuTms9918Color)(colorByte >> 4);
return c == TMS_TRANSPARENT ? tmsMainBgColor(tms9918) : c;
}
/* Function: tmsBgColor
* --------------------
* background color
*/
static inline vrEmuTms9918Color tmsBgColor(VrEmuTms9918* tms9918, uint8_t colorByte)
{
vrEmuTms9918Color c = (vrEmuTms9918Color)(colorByte & 0x0f);
return c == TMS_TRANSPARENT ? tmsMainBgColor(tms9918) : c;
}
/* Function: vrEmuTms9918New
* --------------------
* create a new TMS9918
*/
VrEmuTms9918* vrEmuTms9918New()
{
VrEmuTms9918* tms9918 = (VrEmuTms9918*)malloc(sizeof(VrEmuTms9918));
if (tms9918 != NULL)
{
vrEmuTms9918Reset(tms9918);
}
return tms9918;
}
/* Function: vrEmuTms9918Reset
* --------------------
* reset the new TMS9918
*/
void vrEmuTms9918Reset(VrEmuTms9918* tms9918)
{
if (tms9918)
{
/* initialization */
tms9918->currentAddress = 0;
tms9918->lastMode = 0;
tms9918->status = 0;
memset(tms9918->registers, 0, sizeof(tms9918->registers));
memset(tms9918->vram, 0xff, sizeof(tms9918->vram));
}
}
/* Function: vrEmuTms9918Destroy
* --------------------
* destroy a TMS9918
*
* tms9918: tms9918 object to destroy / clean up
*/
void vrEmuTms9918Destroy(VrEmuTms9918* tms9918)
{
if (tms9918)
{
/* destruction */
free(tms9918);
}
}
/* Function: vrEmuTms9918WriteAddr
* --------------------
* write an address (mode = 1) to the tms9918
*
* data: the data (DB0 -> DB7) to send
*/
void vrEmuTms9918WriteAddr(VrEmuTms9918* tms9918, uint8_t data)
{
if (tms9918->lastMode)
{
/* second address byte */
if (data & 0x80) /* register */
{
tms9918->registers[data & 0x07] = tms9918->currentAddress & 0xff;
tms9918->mode = tmsMode(tms9918);
}
else /* address */
{
tms9918->currentAddress |= ((data & 0x3f) << 8);
}
tms9918->lastMode = 0;
}
else
{
tms9918->currentAddress = data;
tms9918->lastMode = 1;
}
}
/* Function: vrEmuTms9918WriteData
* --------------------
* write data (mode = 0) to the tms9918
*
* data: the data (DB0 -> DB7) to send
*/
void vrEmuTms9918WriteData(VrEmuTms9918* tms9918, uint8_t data)
{
tms9918->vram[(tms9918->currentAddress++) & 0x3fff] = data;
}
/* Function: vrEmuTms9918ReadStatus
* --------------------
* read from the status register
*/
uint8_t vrEmuTms9918ReadStatus(VrEmuTms9918* tms9918)
{
uint8_t tmpStatus = tms9918->status;
tms9918->status = 0;
return tmpStatus;
}
/* Function: vrEmuTms9918ReadData
* --------------------
* read data (mode = 0) from the tms9918
*/
uint8_t vrEmuTms9918ReadData(VrEmuTms9918* tms9918)
{
return tms9918->vram[(tms9918->currentAddress++) & 0x3fff];
}
/* Function: vrEmuTms9918ReadDataNoInc
* --------------------
* read data (mode = 0) from the tms9918
*/
uint8_t vrEmuTms9918ReadDataNoInc(VrEmuTms9918* tms9918)
{
return tms9918->vram[tms9918->currentAddress & 0x3fff];
}
/* Function: vrEmuTms9918OutputSprites
* ----------------------------------------
* Output Sprites to a scanline
*/
static void vrEmuTms9918OutputSprites(VrEmuTms9918* tms9918, uint8_t y, uint8_t pixels[TMS9918_PIXELS_X])
{
int spriteSizePx = (tmsSpriteSize(tms9918) ? 16 : 8) * (tmsSpriteMag(tms9918) ? 2 : 1);
uint16_t spriteAttrTableAddr = tmsSpriteAttrTableAddr(tms9918);
uint16_t spritePatternAddr = tmsSpritePatternTableAddr(tms9918);
int spritesShown = 0;
if (y == 0)
{
tms9918->status = 0;
}
for (int i = 0; i < MAX_SPRITES; ++i)
{
int spriteAttrAddr = spriteAttrTableAddr + i * SPRITE_ATTR_BYTES;
int vPos = tms9918->vram[spriteAttrAddr];
/* stop processing when vPos == LAST_SPRITE_VPOS */
if (vPos == LAST_SPRITE_VPOS)
{
if ((tms9918->status & STATUS_5S) == 0)
{
tms9918->status |= i;
}
break;
}
/* check if sprite position is in the -31 to 0 range */
if (vPos > (uint8_t)-32)
{
vPos -= 256;
}
vPos += 1;
int patternRow = y - vPos;
if (tmsSpriteMag(tms9918))
{
patternRow /= 2;
}
/* check if sprite is visible on this line */
if (patternRow < 0 || patternRow >= (tmsSpriteSize(tms9918) ? 16 : 8))
continue;
vrEmuTms9918Color spriteColor = tms9918->vram[spriteAttrAddr + 3] & 0x0f;
if (spritesShown == 0)
{
/* if we're showing the first sprite, clear the bit buffer */
memset(tms9918->rowSpriteBits, 0, TMS9918_PIXELS_X);
}
/* have we exceeded the scanline sprite limit? */
if (++spritesShown > MAX_SCANLINE_SPRITES)
{
if ((tms9918->status & STATUS_5S) == 0)
{
tms9918->status |= STATUS_5S | i;
}
break;
}
/* sprite is visible on this line */
uint8_t patternName = tms9918->vram[spriteAttrAddr + 2];
uint16_t patternOffset = spritePatternAddr + patternName * 8 + (uint16_t)patternRow;
int hPos = tms9918->vram[spriteAttrAddr + 1];
if (tms9918->vram[spriteAttrAddr + 3] & 0x80) /* check early clock bit */
{
hPos -= 32;
}
uint8_t patternByte = tms9918->vram[patternOffset];
int screenBit = 0;
int patternBit = 0;
for (int screenX = hPos; screenX < (hPos + spriteSizePx); ++screenX, ++screenBit)
{
if (screenX >= TMS9918_PIXELS_X)
{
break;
}
if (screenX >= 0)
{
if (patternByte & (0x80 >> patternBit))
{
/* we still process transparent sprites, since they're used in 5S and collistion checks */
if (spriteColor != TMS_TRANSPARENT)
{
pixels[screenX] = spriteColor;
}
if (tms9918->rowSpriteBits[screenX])
{
tms9918->status |= STATUS_COL;
}
tms9918->rowSpriteBits[screenX] = 1;
}
}
if (!tmsSpriteMag(tms9918) || (screenBit & 0x01))
{
if (++patternBit == 8) /* from A -> C or B -> D of large sprite */
{
patternBit = 0;
patternByte = tms9918->vram[patternOffset + 16];
}
}
}
}
}
/* Function: vrEmuTms9918GraphicsIScanLine
* ----------------------------------------
* generate a Graphics I mode scanline
*/
static void vrEmuTms9918GraphicsIScanLine(VrEmuTms9918* tms9918, uint8_t y, uint8_t pixels[TMS9918_PIXELS_X])
{
uint8_t textRow = y >> 3;
int patternRow = y % 8;
uint16_t namesAddr = tmsNameTableAddr(tms9918) + textRow * GRAPHICS_NUM_COLS;
uint16_t patternBaseAddr = tmsPatternTableAddr(tms9918);
uint16_t colorBaseAddr = tmsColorTableAddr(tms9918);
int pixelIndex = -1;
for (int tileX = 0; tileX < GRAPHICS_NUM_COLS; ++tileX)
{
int pattern = tms9918->vram[namesAddr + tileX];
uint8_t patternByte = tms9918->vram[patternBaseAddr + pattern * 8 + patternRow];
uint8_t colorByte = tms9918->vram[colorBaseAddr + pattern / 8];
vrEmuTms9918Color fgColor = tmsFgColor(tms9918, colorByte);
vrEmuTms9918Color bgColor = tmsBgColor(tms9918, colorByte);
for (int i = 0; i < GRAPHICS_CHAR_WIDTH; ++i)
{
pixels[++pixelIndex] = (uint8_t)((patternByte & 0x80) ? fgColor : bgColor);
patternByte <<= 1;
}
}
vrEmuTms9918OutputSprites(tms9918, y, pixels);
}
/* Function: vrEmuTms9918GraphicsIIScanLine
* ----------------------------------------
* generate a Graphics II mode scanline
*/
static void vrEmuTms9918GraphicsIIScanLine(VrEmuTms9918* tms9918, uint8_t y, uint8_t pixels[TMS9918_PIXELS_X])
{
uint8_t textRow = y >> 3;
int patternRow = y % 8;
uint16_t namesAddr = tmsNameTableAddr(tms9918) + textRow * GRAPHICS_NUM_COLS;
int pageThird = (textRow & 0x18) >> 3; /* which page? 0-2 */
uint16_t pageOffset = pageThird << 11; /* offset (0, 0x800 or 0x1000) */
bool invalidGfxII = (tms9918->registers[TMS_REG_4] & 0x03) != 0x03 ||
(tms9918->registers[TMS_REG_3] & 0x7f) != 0x7f;
if (invalidGfxII)
{
pageOffset = 0;
}
uint16_t patternBaseAddr = tmsPatternTableAddr(tms9918) + pageOffset;
uint16_t colorBaseAddr = tmsColorTableAddr(tms9918) + pageOffset;
int pixelIndex = -1;
for (int tileX = 0; tileX < GRAPHICS_NUM_COLS; ++tileX)
{
int pattern = tms9918->vram[namesAddr + tileX];
if (invalidGfxII)
{
pattern &= 0x07;
}
uint8_t patternByte = tms9918->vram[patternBaseAddr + pattern * 8 + patternRow];
uint8_t colorByte = tms9918->vram[colorBaseAddr + pattern * 8 + patternRow];
vrEmuTms9918Color fgColor = tmsFgColor(tms9918, colorByte);
vrEmuTms9918Color bgColor = tmsBgColor(tms9918, colorByte);
for (int i = 0; i < GRAPHICS_CHAR_WIDTH; ++i)
{
pixels[++pixelIndex] = (uint8_t)((patternByte & 0x80) ? fgColor : bgColor);
patternByte <<= 1;
}
}
vrEmuTms9918OutputSprites(tms9918, y, pixels);
}
/* Function: vrEmuTms9918TextScanLine
* ----------------------------------------
* generate a Text mode scanline
*/
static void vrEmuTms9918TextScanLine(VrEmuTms9918* tms9918, uint8_t y, uint8_t pixels[TMS9918_PIXELS_X])
{
uint8_t textRow = y >> 3;
int patternRow = y % 8;
uint16_t namesAddr = tmsNameTableAddr(tms9918) + textRow * TEXT_NUM_COLS;
vrEmuTms9918Color bgColor = tmsMainBgColor(tms9918);
vrEmuTms9918Color fgColor = tmsMainFgColor(tms9918);
int pixelIndex = -1;
/* fill the first 8 pixels with bg color */
while (++pixelIndex < 8)
{
pixels[pixelIndex] = bgColor;
}
--pixelIndex;
for (int tileX = 0; tileX < TEXT_NUM_COLS; ++tileX)
{
int pattern = tms9918->vram[namesAddr + tileX];
uint8_t patternByte = tms9918->vram[tmsPatternTableAddr(tms9918) + pattern * 8 + patternRow];
for (int i = 0; i < TEXT_CHAR_WIDTH; ++i)
{
pixels[++pixelIndex] = (uint8_t)((patternByte & 0x80) ? fgColor : bgColor);
patternByte <<= 1;
}
}
while (++pixelIndex < TMS9918_PIXELS_X)
{
pixels[pixelIndex] = bgColor;
}
}
/* Function: vrEmuTms9918MulticolorScanLine
* ----------------------------------------
* generate a Multicolor mode scanline
*/
static void vrEmuTms9918MulticolorScanLine(VrEmuTms9918* tms9918, uint8_t y, uint8_t pixels[TMS9918_PIXELS_X])
{
uint8_t textRow = y >> 3;
int patternRow = (y / 4) % 2 + (textRow % 4) * 2;
uint16_t namesAddr = tmsNameTableAddr(tms9918) + textRow * GRAPHICS_NUM_COLS;
int pixelIndex = -1;
for (int tileX = 0; tileX < GRAPHICS_NUM_COLS; ++tileX)
{
int pattern = tms9918->vram[namesAddr + tileX];
uint8_t colorByte = tms9918->vram[tmsPatternTableAddr(tms9918) + pattern * 8 + patternRow];
for (int i = 0; i < 4; ++i) pixels[++pixelIndex] = tmsFgColor(tms9918, colorByte);
for (int i = 0; i < 4; ++i) pixels[++pixelIndex] = tmsBgColor(tms9918, colorByte);
}
vrEmuTms9918OutputSprites(tms9918, y, pixels);
}
/* Function: vrEmuTms9918ScanLine
* ----------------------------------------
* generate a scanline
*/
void vrEmuTms9918ScanLine(VrEmuTms9918* tms9918, uint8_t y, uint8_t pixels[TMS9918_PIXELS_X])
{
if (tms9918 == NULL)
return;
if (!vrEmuTms9918DisplayEnabled(tms9918) || y >= TMS9918_PIXELS_Y)
{
memset(pixels, tmsMainBgColor(tms9918), TMS9918_PIXELS_X);
return;
}
switch (tms9918->mode)
{
case TMS_MODE_GRAPHICS_I:
vrEmuTms9918GraphicsIScanLine(tms9918, y, pixels);
break;
case TMS_MODE_GRAPHICS_II:
vrEmuTms9918GraphicsIIScanLine(tms9918, y, pixels);
break;
case TMS_MODE_TEXT:
vrEmuTms9918TextScanLine(tms9918, y, pixels);
break;
case TMS_MODE_MULTICOLOR:
vrEmuTms9918MulticolorScanLine(tms9918, y, pixels);
break;
}
if (y == TMS9918_PIXELS_Y - 1)
{
tms9918->status |= STATUS_INT;
}
}
/* Function: vrEmuTms9918RegValue
* ----------------------------------------
* return a reigister value
*/
uint8_t vrEmuTms9918RegValue(VrEmuTms9918 * tms9918, vrEmuTms9918Register reg)
{
if (tms9918 == NULL)
return 0;
return tms9918->registers[reg & 0x07];
}
/* Function: vrEmuTms9918WriteRegValue
* ----------------------------------------
* write a reigister value
*/
void vrEmuTms9918WriteRegValue(VrEmuTms9918* tms9918, vrEmuTms9918Register reg, uint8_t value)
{
if (tms9918 != NULL)
{
tms9918->registers[reg & 0x07] = value;
tms9918->mode = tmsMode(tms9918);
}
}
/* Function: vrEmuTms9918VramValue
* ----------------------------------------
* return a value from vram
*/
uint8_t vrEmuTms9918VramValue(VrEmuTms9918* tms9918, uint16_t addr)
{
if (tms9918 == NULL)
return 0;
return tms9918->vram[addr & 0x3fff];
}
/* Function: vrEmuTms9918DisplayEnabled
* --------------------
* check BLANK flag
*/
bool vrEmuTms9918DisplayEnabled(VrEmuTms9918* tms9918)
{
if (tms9918 == NULL)
return false;
return tms9918->registers[TMS_REG_1] & 0x40;
}