-
Notifications
You must be signed in to change notification settings - Fork 0
/
vera.c
47 lines (36 loc) · 1.21 KB
/
vera.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
#include <cx16.h>
// https://github.com/mwiedmann/cx16CodingInC/blob/main/Chapter07-MapBase/main.c
#define MAPBASE_TILE_COUNT 128*64
void main() {
// Here is the address we know Layer 1 MapBase is using
unsigned long mapBaseAddr = 0x1B000;
unsigned char fore, back, curchar;
// Note we need a `short` here because there are more than 255 tiles
unsigned short i;
// Point to the MapBase address so we can write to VRAM
VERA.address = mapBaseAddr;
VERA.address_hi = mapBaseAddr>>16;
// Set the Increment Mode, turn on bit 4
VERA.address_hi |= 0b10000;
// Start at colors 1 and 0
fore = 1;
back = 0;
curchar = 0;
// Write out @ characters to the entire MapBase
for (i=0; i<MAPBASE_TILE_COUNT; i++) {
VERA.data0 = curchar++; // Index for the @ character
// Color index 0 for background (black)
// Color index 1 for foreground (white)
VERA.data0 = fore | back<<4;
fore++;
if (fore > 15) {
// Skip color 0 for foreground so we get a good
// variety of fore/back color combos.
fore = 1;
}
back++;
if (back > 15) {
back = 0;
}
}
}