-
Notifications
You must be signed in to change notification settings - Fork 0
/
vecops.c
69 lines (51 loc) · 1.12 KB
/
vecops.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
#include <string.h>
#include "vecops.h"
word dvgwrofs; // write offset for DVG buffer
#define dvgram ((word*)0x2000)
void dvgclear(void) {
memset(dvgram, 0x20, 0x800); // HALTs
}
void dvgreset(void) {
dvgwrofs = 0;
}
void dvgstart(void) {
asm("sta $8840"); // strobe DVGSTART
}
void dvgwrite(word w) {
dvgram[dvgwrofs] = w;
++dvgwrofs;
}
void VCTR(int dx, int dy, byte bright) {
dvgwrite((dy & 0x1fff));
dvgwrite(((bright & 7) << 13) | (dx & 0x1fff));
}
void SVEC(signed char dx, signed char dy, byte bright) {
dvgwrite(0x4000 | (dx & 0x1f) | ((bright&7)<<5) | ((dy & 0x1f)<<8));
}
void JSRL(word offset) {
dvgwrite(0xa000 | offset);
}
void JMPL(word offset) {
dvgwrite(0xe000 | offset);
}
void RTSL(void) {
dvgwrite(0xc000);
}
void CNTR(void) {
dvgwrite(0x8000);
}
void HALT(void) {
dvgwrite(0x2000);
}
void STAT(byte rgb, byte intens) {
dvgwrite(0x6000 | ((intens & 0xf)<<4) | (rgb & 7));
}
void STAT_sparkle(byte intens) {
dvgwrite(0x6800 | ((intens & 0xf)<<4));
}
void SCAL(word scale) {
dvgwrite(0x7000 | scale);
}
void JSRPTR(const word* dvgrom) {
JSRL(((word)dvgrom - 0x2000) >> 1);
}