-
Notifications
You must be signed in to change notification settings - Fork 1
/
vdp.h
157 lines (146 loc) · 5.38 KB
/
vdp.h
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
/*
* Title: AGON VDP - VDP c header interface
* Author: Jeroen Venema
* Created: 20/10/2022
* Last Updated: 20/10/2023
*
* Modinfo:
* 20/10/2022: Initial version: text/graphics functions
* 22/10/2022: Bitmap/Sprite functions added
* 23/03/2023: vdp_getMode function added, VDP 23,0,n commands changed to MOS 1.03
* 26/03/2023: pagedMode support, setPaletteColor support
* xx/10/2023: Added VDP 1.04 video mode defines
* 20/10/2023: JH - Added vdp_setLogicalCoords() and buffer swap
* 02/01/2023: JH - Added vdp_bitmapSendData16() to upload 16-colour paletted images
*/
#include <defines.h>
#include "mos-interface.h"
#include "stdint.h"
#ifndef VDP_H
#define VDP_H
// DEFAULT COLOR INDEXES
enum {
BLACK = 0,
DARK_RED,
DARK_GREEN,
DARK_YELLOW,
DARK_BLUE,
DARK_MAGENTA,
DARK_CYAN,
DARK_WHITE,
BRIGHT_BLACK,
BRIGHT_RED,
BRIGHT_GREEN,
BRIGHT_YELLOW,
BRIGHT_BLUE,
BRIGHT_MAGENTA,
BRIGHT_CYAN,
BRIGHT_WHITE
};
// VDP modes
#define VDPMODE_640x480_16C 0
#define VDPMODE_640x480_4C 1
#define VDPMODE_640x480_4C_DB 129
#define VDPMODE_640x480_2C 2
#define VDPMODE_640x480_2C_DB 130
#define VDPMODE_640x240_64C 3
#define VDPMODE_640x240_16C 4
#define VDPMODE_640x240_16C_DB 132
#define VDPMODE_640x240_4C 5
#define VDPMODE_640x240_4C_DB 133
#define VDPMODE_640x240_2C 6
#define VDPMODE_640x240_2C_DB 134
#define VDPMODE_320x240_64C 8
#define VDPMODE_320x240_64C_DB 136
#define VDPMODE_320x240_16C 9
#define VDPMODE_320x240_16C_DB 137
#define VDPMODE_320x240_4C 10
#define VDPMODE_320x240_4C_DB 138
#define VDPMODE_320x240_2C 11
#define VDPMODE_320x240_2C_DB 139
#define VDPMODE_320x200_64C 12
#define VDPMODE_320x200_64C_DB 140
#define VDPMODE_320x200_16C 13
#define VDPMODE_320x200_16C_DB 141
#define VDPMODE_320x200_4C 14
#define VDPMODE_320x200_4C_DB 142
#define VDPMODE_320x200_2C 15
#define VDPMODE_320x200_2C_DB 143
#define VDPMODE_800x600_4C 16
#define VDPMODE_800x600_2C 17
#define VDPMODE_1024x768_2C 18
#define VDPMODE_DEFAULT 1
// Generic
void vdp_mode(unsigned char mode);
void vdp_getMode(void);
//
// extent: 0 = current text window, 1 = entire screen
// direction: 0 = right, 1 = left, 2 = down, 3 = up
// speed: number of pixels to scroll
void vdp_scroll(unsigned char extent, unsigned char direction, unsigned char speed);
// Switch buffers (double-buffered mode)
void vdp_switchBuffers();
// Text VDP functions
void vdp_cls();
void vdp_cursorHome();
void vdp_cursorUp();
void vdp_cursorGoto(unsigned char x, unsigned char y);
UINT8 vdp_cursorGetXpos(void);
UINT8 vdp_cursorGetYpos(void);
void vdp_cursorDisable(void);
void vdp_cursorEnable(void);
char vdp_asciiCodeAt(unsigned char x, unsigned char y);
void vdp_setpagedMode(bool mode);
void vdp_fgcolour(unsigned char colorindex);
void vdp_bgcolour(unsigned char colorindex);
// Redefine ASCII character number c with 8 bytes at data pointer
// VDU 23, c, n1, n2, n3, n4, n5, n6, n7, n8: Redefine a display character
// Parameters:
// - c: The character to redefine
void vdp_redefineChar(unsigned char c, UINT8 *data);
// Graphic VDP functions
void vdp_setLogicalCoords(unsigned char n); // JH
void vdp_clearGraphics();
void vdp_graphicsViewport(unsigned int left, unsigned int bottom, unsigned int right, unsigned int top); // JH 2023-10-23
void vdp_resetViewports(); // JH 2023-10-23
void vdp_plotColour(unsigned char colorindex);
void vdp_plotSetOrigin(unsigned int x, unsigned int y);
void vdp_plotMoveTo(unsigned int x, unsigned int y);
void vdp_plotLineTo(unsigned int x, unsigned int y);
void vdp_plotPoint(unsigned int x, unsigned int y);
void vdp_plotTriangle(unsigned int x, unsigned int y);
void vdp_plotCircleRadius(unsigned int r);
void vdp_plotCircleCircumference(unsigned int x, unsigned int y);
void vdp_plotFilledRectangle(unsigned int x, unsigned int y);
// Bitmap VDP functions
void vdp_bitmapSelect(UINT8 id);
void vdp_bitmapSendDataSelected(UINT16 width, UINT16 height, UINT32 *data);
void vdp_bitmapSendData(UINT8 id, UINT16 width, UINT16 height, UINT32 *data);
void vdp_bitmapSendData16(UINT8 id, UINT16 width, UINT16 height, UINT8 *data, UINT32 *palette);
void vdp_bitmapDrawSelected(UINT16 x, UINT16 y);
void vdp_bitmapDraw(UINT8 id, UINT16 x, UINT16 y);
void vdp_bitmapCreateSolidColorSelected(UINT16 width, UINT16 height, UINT32 abgr);
void vdp_bitmapCreateSolidColor(UINT8 id, UINT16 width, UINT16 height, UINT32 abgr);
// Sprite VDP functions
void vdp_spriteSelect(UINT8 id);
void vdp_spriteClearFramesSelected(void);
void vdp_spriteClearFrames(UINT8 bitmapid);
void vdp_spriteAddFrameSelected(UINT8 bitmapid);
void vdp_spriteAddFrame(UINT8 id, UINT8 bitmapid);
void vdp_spriteNextFrameSelected(void);
void vdp_spriteNextFrame(UINT8 id);
void vdp_spritePreviousFrameSelected(void);
void vdp_spritePreviousFrame(UINT8 id);
void vdp_spriteSetFrameSelected(UINT8 framenumber);
void vdp_spriteSetFrame(UINT8 id, UINT8 framenumber);
void vdp_spriteShowSelected(void);
void vdp_spriteShow(UINT8 id);
void vdp_spriteHideSelected(void);
void vdp_spriteHide(UINT8 id);
void vdp_spriteMoveToSelected(UINT16 x, UINT16 y);
void vdp_spriteMoveTo(UINT8 id, UINT16 x, UINT16 y);
void vdp_spriteMoveBySelected(UINT16 x, UINT16 y);
void vdp_spriteMoveBy(UINT8 id, UINT16 x, UINT16 y);
void vdp_spriteActivateTotal(UINT8 number);
void vdp_spriteRefresh(void);
#endif VDP_H