-
Notifications
You must be signed in to change notification settings - Fork 1
/
vdp_setgraphics.c
29 lines (26 loc) · 1.27 KB
/
vdp_setgraphics.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
// VDP code for the TI-99/4A by Tursi
// You can copy this file and use it at will if it's useful
#include "vdp.h"
// setting up standard screen modes - blanks the screen and returns the unblank command
// interrupts are also disabled. Unblank will re-enable them, too, write it to VDP_REG_MODE1
unsigned char set_graphics_raw(unsigned char sprite_mode) {
// this layout is untested but should match editor/assembler's
unsigned char unblank = VDP_MODE1_16K | VDP_MODE1_UNBLANK | VDP_MODE1_INT | sprite_mode;
VDP_SET_REGISTER(VDP_REG_MODE1, VDP_MODE1_16K); // no need to OR in the sprite mode for now
// because we blanked the display, we don't have to worry about VDP timing for the rest of this
VDP_SET_REGISTER(VDP_REG_MODE0, 0);
VDP_SET_REGISTER(VDP_REG_SIT, 0x00); gImage = 0x000;
VDP_SET_REGISTER(VDP_REG_CT, 0x0e); gColor = 0x380;
VDP_SET_REGISTER(VDP_REG_PDT, 0x01); gPattern = 0x800;
VDP_SET_REGISTER(VDP_REG_SAL, 0x06); gSprite = 0x300; vdpchar(gSprite, 0xd0);
VDP_SET_REGISTER(VDP_REG_SDT, 0x01); gSpritePat = 0x800;
nTextRow = 736;
nTextEnd = 767;
nTextPos = nTextRow;
vdpmemset(gImage, ' ', nTextEnd+1);
return unblank;
}
void set_graphics(unsigned char sprite_mode) {
unsigned char x = set_graphics_raw(sprite_mode);
VDP_SET_REGISTER(VDP_REG_MODE1, x);
}