llvm-mos-sdk
cx16.h
Go to the documentation of this file.
1 // Copyright 2022 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 // Originally from cc65. Modified from original version.
7 
8 // clang-format off
9 
10 /*****************************************************************************/
11 /* */
12 /* cx16.h */
13 /* */
14 /* CX16 system-specific definitions */
15 /* For prerelease 39 */
16 /* */
17 /* */
18 /* This software is provided "as-is", without any expressed or implied */
19 /* warranty. In no event will the authors be held liable for any damages */
20 /* arising from the use of this software. */
21 /* */
22 /* Permission is granted to anyone to use this software for any purpose, */
23 /* including commercial applications, and to alter it and redistribute it */
24 /* freely, subject to the following restrictions: */
25 /* */
26 /* 1. The origin of this software must not be misrepresented; you must not */
27 /* claim that you wrote the original software. If you use this software */
28 /* in a product, an acknowledgment in the product documentation would be */
29 /* appreciated, but is not required. */
30 /* 2. Altered source versions must be plainly marked as such, and must not */
31 /* be misrepresented as being the original software. */
32 /* 3. This notice may not be removed or altered from any source */
33 /* distribution. */
34 /* */
35 /*****************************************************************************/
36 
37 #ifndef _CX16_H
38 #define _CX16_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* Check for errors */
45 #ifndef __CX16__
46 # error This module may be used only when compiling for the CX16!
47 #endif
48 
49 
50 
51 /*****************************************************************************/
52 /* Data */
53 /*****************************************************************************/
54 
55 
56 
57 /* Additional output character codes */
58 #define CH_COLOR_SWAP 0x01
59 #define CH_UNDERLINE 0x04
60 #define CH_WHITE 0x05
61 #define CH_BOLD 0x06
62 #define CH_BACKSPACE 0x08
63 #define CH_ITALIC 0x0B
64 #define CH_OUTLINE 0x0C
65 #define CH_FONT_ISO 0x0F
66 #define CH_RED 0x1C
67 #define CH_GREEN 0x1E
68 #define CH_BLUE 0x1F
69 #define CH_ORANGE 0x81
70 #define CH_FONT_PET 0x8F
71 #define CH_BLACK 0x90
72 #define CH_ATTR_CLEAR 0x92
73 #define CH_BROWN 0x95
74 #define CH_PINK 0x96
75 #define CH_LIGHTRED CH_PINK
76 #define CH_GRAY1 0x97
77 #define CH_GRAY2 0x98
78 #define CH_LIGHTGREEN 0x99
79 #define CH_LIGHTBLUE 0x9A
80 #define CH_GRAY3 0x9B
81 #define CH_PURPLE 0x9C
82 #define CH_YELLOW 0x9E
83 #define CH_CYAN 0x9F
84 #define CH_SHIFT_SPACE 0xA0
85 
86 /* Additional key defines */
87 #define CH_SHIFT_TAB 0x18
88 #define CH_HELP 0x84
89 #define CH_F1 0x85
90 #define CH_F2 0x89
91 #define CH_F3 0x86
92 #define CH_F4 0x8A
93 #define CH_F5 0x87
94 #define CH_F6 0x8B
95 #define CH_F7 0x88
96 #define CH_F8 0x8C
97 #define CH_F9 0x10
98 #define CH_F10 0x15
99 #define CH_F11 0x16
100 #define CH_F12 0x17
101 
102 /* Color defines */
103 #define COLOR_BLACK 0x00
104 #define COLOR_WHITE 0x01
105 #define COLOR_RED 0x02
106 #define COLOR_CYAN 0x03
107 #define COLOR_PURPLE 0x04
108 #define COLOR_GREEN 0x05
109 #define COLOR_BLUE 0x06
110 #define COLOR_YELLOW 0x07
111 #define COLOR_ORANGE 0x08
112 #define COLOR_BROWN 0x09
113 #define COLOR_PINK 0x0A
114 #define COLOR_LIGHTRED COLOR_PINK
115 #define COLOR_GRAY1 0x0B
116 #define COLOR_GRAY2 0x0C
117 #define COLOR_LIGHTGREEN 0x0D
118 #define COLOR_LIGHTBLUE 0x0E
119 #define COLOR_GRAY3 0x0F
120 
121 /* NES controller masks for joy_read() */
122 
123 #define JOY_BTN_1_MASK 0x80
124 #define JOY_BTN_2_MASK 0x40
125 #define JOY_BTN_3_MASK 0x20
126 #define JOY_BTN_4_MASK 0x10
127 #define JOY_UP_MASK 0x08
128 #define JOY_DOWN_MASK 0x04
129 #define JOY_LEFT_MASK 0x02
130 #define JOY_RIGHT_MASK 0x01
131 
132 #define JOY_BTN_A_MASK JOY_BTN_1_MASK
133 #define JOY_BTN_B_MASK JOY_BTN_2_MASK
134 #define JOY_SELECT_MASK JOY_BTN_3_MASK
135 #define JOY_START_MASK JOY_BTN_4_MASK
136 
137 #define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
138 #define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
139 #define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
140 #define JOY_START(v) ((v) & JOY_START_MASK)
141 
142 #define JOY_FIRE2_MASK JOY_BTN_2_MASK
143 #define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK)
144 
145 /* Additional mouse button mask */
146 #define MOUSE_BTN_MIDDLE 0x02
147 
148 /* get_tv() return codes
149 ** set_tv() argument codes
150 ** NOTE: llvm-mos-sdk added newer 240P modes
151 */
152 enum {
153  TV_NONE = 0x00,
169 };
170 
171 /* Video modes for videomode() */
172 #define VIDEOMODE_80x60 0x00
173 #define VIDEOMODE_80x30 0x01
174 #define VIDEOMODE_40x60 0x02
175 #define VIDEOMODE_40x30 0x03
176 #define VIDEOMODE_40x15 0x04
177 #define VIDEOMODE_20x30 0x05
178 #define VIDEOMODE_20x15 0x06
179 #define VIDEOMODE_80COL VIDEOMODE_80x60
180 #define VIDEOMODE_40COL VIDEOMODE_40x30
181 #define VIDEOMODE_320x240 0x80
182 #define VIDEOMODE_SWAP (-1)
183 
184 /* VERA's address increment/decrement numbers */
185 enum {
186  VERA_DEC_0 = ((0 << 1) | 1) << 3,
187  VERA_DEC_1 = ((1 << 1) | 1) << 3,
188  VERA_DEC_2 = ((2 << 1) | 1) << 3,
189  VERA_DEC_4 = ((3 << 1) | 1) << 3,
190  VERA_DEC_8 = ((4 << 1) | 1) << 3,
191  VERA_DEC_16 = ((5 << 1) | 1) << 3,
192  VERA_DEC_32 = ((6 << 1) | 1) << 3,
193  VERA_DEC_64 = ((7 << 1) | 1) << 3,
194  VERA_DEC_128 = ((8 << 1) | 1) << 3,
195  VERA_DEC_256 = ((9 << 1) | 1) << 3,
196  VERA_DEC_512 = ((10 << 1) | 1) << 3,
197  VERA_DEC_40 = ((11 << 1) | 1) << 3,
198  VERA_DEC_80 = ((12 << 1) | 1) << 3,
199  VERA_DEC_160 = ((13 << 1) | 1) << 3,
200  VERA_DEC_320 = ((14 << 1) | 1) << 3,
201  VERA_DEC_640 = ((15 << 1) | 1) << 3,
202  VERA_INC_0 = ((0 << 1) | 0) << 3,
203  VERA_INC_1 = ((1 << 1) | 0) << 3,
204  VERA_INC_2 = ((2 << 1) | 0) << 3,
205  VERA_INC_4 = ((3 << 1) | 0) << 3,
206  VERA_INC_8 = ((4 << 1) | 0) << 3,
207  VERA_INC_16 = ((5 << 1) | 0) << 3,
208  VERA_INC_32 = ((6 << 1) | 0) << 3,
209  VERA_INC_64 = ((7 << 1) | 0) << 3,
210  VERA_INC_128 = ((8 << 1) | 0) << 3,
211  VERA_INC_256 = ((9 << 1) | 0) << 3,
212  VERA_INC_512 = ((10 << 1) | 0) << 3,
213  VERA_INC_40 = ((11 << 1) | 0) << 3,
214  VERA_INC_80 = ((12 << 1) | 0) << 3,
215  VERA_INC_160 = ((13 << 1) | 0) << 3,
216  VERA_INC_320 = ((14 << 1) | 0) << 3,
217  VERA_INC_640 = ((15 << 1) | 0) << 3
218 };
219 
220 /* VERA's interrupt flags */
221 #define VERA_IRQ_VSYNC 0b00000001
222 #define VERA_IRQ_RASTER 0b00000010
223 #define VERA_IRQ_SPR_COLL 0b00000100
224 #define VERA_IRQ_AUDIO_LOW 0b00001000
225 
226 /* Define hardware. */
227 
228 #define RAM_BANK (*(volatile unsigned char *)0x00)
229 #define ROM_BANK (*(volatile unsigned char *)0x01)
230 
231 #include <_6522.h>
232 #define VIA1 (*(volatile struct __6522 *)0x9F00)
233 #define VIA2 (*(volatile struct __6522 *)0x9F10)
234 
235 /* A structure with the Video Enhanced Retro Adapter's external registers */
236 struct __vera {
237  unsigned short address; /* Address for data ports */
238  unsigned char address_hi;
239  unsigned char data0; /* Data port 0 */
240  unsigned char data1; /* Data port 1 */
241  unsigned char control; /* Control register */
242  unsigned char irq_enable; /* Interrupt enable bits */
243  unsigned char irq_flags; /* Interrupt flags */
244  unsigned char irq_raster; /* Line where IRQ will occur */
245  union {
246  struct { /* Visible when DCSEL flag = 0 */
247  unsigned char video; /* Flags to enable video layers */
248  unsigned char hscale; /* Horizontal scale factor */
249  unsigned char vscale; /* Vertical scale factor */
250  unsigned char border; /* Border color (NTSC mode) */
251  };
252  struct { /* Visible when DCSEL flag = 1 */
253  unsigned char hstart; /* Horizontal start position */
254  unsigned char hstop; /* Horizontal stop position */
255  unsigned char vstart; /* Vertical start position */
256  unsigned char vstop; /* Vertical stop position */
257  };
258  struct { /* Visible when DCSEL flag = 2 */
259  unsigned char fxctrl;
260  unsigned char fxtilebase;
261  unsigned char fxmapbase;
262  unsigned char fxmult;
263  };
264  struct { /* Visible when DCSEL flag = 3 */
265  unsigned char fxxincrl;
266  unsigned char fxxincrh;
267  unsigned char fxyincrl;
268  unsigned char fxyincrh;
269  };
270  struct { /* Visible when DCSEL flag = 4 */
271  unsigned char fxxposl;
272  unsigned char fxxposh;
273  unsigned char fxyposl;
274  unsigned char fxyposh;
275  };
276  struct { /* Visible when DCSEL flag = 5 */
277  unsigned char fxxposs;
278  unsigned char fxyposs;
279  unsigned char fxpolyfilll;
280  unsigned char fxpolyfillh;
281  };
282  struct { /* Visible when DCSEL flag = 6 */
283  unsigned char fxcachel;
284  unsigned char fxcachem;
285  unsigned char fxcacheh;
286  unsigned char fxcacheu;
287  };
288  struct { /* Visible when DCSEL flag = 63 */
289  unsigned char dcver0;
290  unsigned char dcver1;
291  unsigned char dcver2;
292  unsigned char dcver3;
293  };
294  } display;
295  struct {
296  unsigned char config; /* Layer map geometry */
297  unsigned char mapbase; /* Map data address */
298  unsigned char tilebase; /* Tile address and geometry */
299  unsigned int hscroll; /* Smooth scroll horizontal offset */
300  unsigned int vscroll; /* Smooth scroll vertical offset */
301  } layer0;
302  struct {
303  unsigned char config;
304  unsigned char mapbase;
305  unsigned char tilebase;
306  unsigned int hscroll;
307  unsigned int vscroll;
308  } layer1;
309  struct {
310  unsigned char control; /* PCM format */
311  unsigned char rate; /* Sample rate */
312  unsigned char data; /* PCM output queue */
313  } audio; /* Pulse-Code Modulation registers */
314  struct {
315  unsigned char data;
316  unsigned char control;
317  } spi; /* SD card interface */
318 };
319 #define VERA (*(volatile struct __vera *)0x9F20)
320 
321 /* Audio chip */
322 struct __ym2151 {
323  union {
324  unsigned char reg; /* Register number for data */
325  unsigned char status; /* Busy flag */
326  };
327  unsigned char data;
328 };
329 #define YM2151 (*(volatile struct __ym2151 *)0x9F40)
330 
331 /* A structure with the x16emu's settings registers */
332 struct __emul {
333  unsigned char debug; /* Boolean: debugging enabled */
334  unsigned char vera_action; /* Boolean: displaying VERA activity */
335  unsigned char keyboard; /* Boolean: displaying typed keys */
336  unsigned char echo; /* How to send Kernal output to host */
337  unsigned char save_on_exit; /* Boolean: save machine state on exit */
338  unsigned char gif_method; /* How GIF movie is being recorded */
339  unsigned char const unused1[2];
340  unsigned long const cycle_count; /* Running total of CPU cycles (8 MHz.) */
341  unsigned char const unused2[1];
342  unsigned char const keymap; /* Keyboard layout number */
343  char const detect[2]; /* "16" if running on x16emu */
344 };
345 #define EMULATOR (*(volatile struct __emul *)0x9FB0)
346 
347 /* An array window into the half Mebibyte or two Mebibytes of banked RAM */
348 #define BANK_RAM ((volatile unsigned char *)0xA000)
349 
350 /*****************************************************************************/
351 /* CX16 kernal functions */
352 /*****************************************************************************/
353 
354 /* Kernel function structure type definitions */
355 typedef struct
356 {
357  unsigned char year, mon, day, hour, min, sec, jif;
358 } cx16_date_time_t; /* cx16_k_clock_get_date_time() */
359 
360 typedef struct
361 {
362  unsigned int width, height;
363  unsigned char depth;
364 } cx16_fb_info_t; /* cx16_k_fb_get_info_depth() */
365 
366 typedef struct
367 {
368  void *fb_init;
369  void *fb_get_info;
382 } graph_fb_functions_t; /* cx16_k_graph_init() */
383 
384 typedef struct
385 {
386  int x, y;
387 } graph_pos_t; /* fb_graph_put_char() */
388 
389 typedef struct
390 {
391  int x, y;
392 } mouse_pos_t; /* cx16_k_mouse_get() */
393 
394 typedef struct
395 {
396  unsigned char mode, columns, rows;
397 } screen_mode_info_t; /* cx16_k_screen_mode_get() */
398 
399 /* Kernal-level functions */
400 unsigned char cx16_k_bsave(void *startaddr, void *endaddr_plusone) __attribute__((leaf)); // returns 0 on success
401 void cx16_k_clock_get_date_time(cx16_date_time_t *datetime_ptr) __attribute__((leaf));
402 void cx16_k_clock_set_date_time(unsigned char year, unsigned char mon, unsigned char day, unsigned char hour, unsigned char min, unsigned char sec, unsigned char jif) __attribute__((leaf));
403 unsigned char cx16_k_console_get_char(void) __attribute__((leaf));
404 void cx16_k_console_init(unsigned int x, unsigned int y, unsigned int width, unsigned int height) __attribute__((leaf));
405 void cx16_k_console_put_char(unsigned char c, unsigned char wrapwordflag) __attribute__((leaf));
406 void cx16_k_console_put_image(void *imageaddr, unsigned int width, unsigned int height) __attribute__((leaf));
407 void cx16_k_console_set_paging_message(void *msgaddr) __attribute__((leaf));
408 void cx16_k_enter_basic(unsigned char coldstart) __attribute__((noreturn));
409 unsigned long cx16_k_entropy_get(void) __attribute__((leaf)); // returns 24-bit value
410 void cx16_k_fb_cursor_next_line(unsigned int x) __attribute__((leaf));
411 void cx16_k_fb_cursor_position(unsigned int x, unsigned int y) __attribute__((leaf));
412 void cx16_k_fb_fill_pixels(unsigned int count, unsigned int step, unsigned char color) __attribute__((leaf));
413 void cx16_k_fb_filter_pixels(void *filterfunc, unsigned int count) __attribute__((leaf));
414 void cx16_k_fb_get_info(cx16_fb_info_t *info_ptr) __attribute__((leaf));
415 unsigned char fb_get_pixel(void) __attribute__((leaf));
416 void cx16_k_fb_get_pixels(void *pixeladdr, unsigned int count) __attribute__((leaf));
417 void cx16_k_fb_init(void) __attribute__((leaf));
418 void cx16_k_fb_move_pixels(unsigned int sx, unsigned int sy, unsigned int tx, unsigned int ty, unsigned int count) __attribute__((leaf));
419 void cx16_k_fb_set_8_pixels(unsigned char pattern, unsigned char color) __attribute__((leaf));
420 void cx16_k_fb_set_8_pixels_opaque(unsigned char pattern, unsigned char mask, unsigned char color1, unsigned char color2) __attribute__((leaf));
421 void cx16_k_fb_set_palette(void *paladdr, unsigned char index, unsigned char count __attribute__((leaf)));
422 void cx16_k_graph_clear(void) __attribute__((leaf));
423 void cx16_k_graph_draw_image(unsigned int x, unsigned int y, void *imageaddr, unsigned int width, unsigned int height) __attribute__((leaf));
424 void cx16_k_graph_draw_line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2) __attribute__((leaf));
425 void cx16_k_graph_draw_oval(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int corner_radius, unsigned char fillflag) __attribute__((leaf));
426 void cx16_k_graph_draw_rect(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int corner_radius, unsigned char fillflag __attribute__((leaf)));
427 long cx16_k_graph_get_char_size(unsigned char c, unsigned char style) __attribute__((leaf)); // if printable returns info (0x00bbwwhh), else negative style byte (0xFF0000ss)
428 void cx16_k_graph_init(graph_fb_functions_t *fb_funcs_ptr) __attribute__((leaf));
429 void cx16_k_graph_move_rect(unsigned int sx, unsigned int sy, unsigned int tx, unsigned int ty, unsigned int width, unsigned int height) __attribute__((leaf));
430 void cx16_k_graph_put_char(graph_pos_t *pos_ptr, unsigned char c) __attribute__((leaf));
431 void cx16_k_graph_set_colors(unsigned char stroke, unsigned char fill, unsigned char background) __attribute__((leaf));
432 void cx16_k_graph_set_font(void *fontaddr) __attribute__((leaf));
433 void cx16_k_graph_set_window(unsigned int x, unsigned int y, unsigned int width, unsigned int height) __attribute__((leaf));
434 int cx16_k_i2c_read_byte(unsigned char device, unsigned char offset) __attribute__((leaf)); // returns negative on error
435 int cx16_k_i2c_write_byte(unsigned char device, unsigned char offset, unsigned char byte) __attribute__((leaf)); // return negative on error
436 long cx16_k_joystick_get(unsigned char sticknum) __attribute__((leaf)); // returns $YYYYXXAA (see docs, result negative if joystick not present)
437 void cx16_k_joystick_scan(void) __attribute__((leaf));
438 unsigned char cx16_k_kbdbuf_get_modifiers(void) __attribute__((leaf));
439 int cx16_k_kbdbuf_peek(unsigned char *index_ptr) __attribute__((leaf)); // returns negative if empty, if index_ptr non-NULL set contents to queue length
440 void cx16_k_kbdbuf_put(unsigned char c) __attribute__((leaf));
441 const char* cx16_k_keymap_get_id(void) __attribute__((leaf));
442 unsigned char cx16_k_keymap_set(const char* identifier) __attribute__((leaf)); // returns 0 on success
443 long cx16_k_macptr(unsigned char count, unsigned char noadvance, void *destaddr) __attribute__((leaf)); // return negative if not supported
444 void cx16_k_memory_copy(void *source, void *target, unsigned int num_bytes) __attribute__((leaf));
445 unsigned int cx16_k_memory_crc(void *dataaddr, unsigned int num_bytes) __attribute__((leaf));
446 void cx16_k_memory_decompress(void *inaddr, void *outaddr) __attribute__((leaf));
447 void cx16_k_memory_fill(void *addr, unsigned int num_bytes, unsigned char value) __attribute__((leaf));
448 void cx16_k_monitor(void) __attribute__((noreturn));
449 void cx16_k_mouse_config(unsigned char showmouse, unsigned char xsize8, unsigned char ysize8) __attribute__((leaf));
450 unsigned char cx16_k_mouse_get(mouse_pos_t *mouse_pos_ptr) __attribute__((leaf)); // returns mouse button byte
451 void cx16_k_mouse_scan(void) __attribute__((leaf));
452 unsigned long cx16_k_rdtim(void) __attribute__((leaf));
453 unsigned char cx16_k_screen_mode_get(screen_mode_info_t *info_ptr) __attribute__((leaf)); // returns 0 on success
454 unsigned char cx16_k_screen_mode_set(unsigned char mode) __attribute__((leaf)); // returns 0 on success
455 void cx16_k_screen_set_charset(unsigned char charset_type, void *charsetaddr) __attribute__((leaf));
456 unsigned char cx16_k_sprite_set_image(unsigned char num, unsigned char w, unsigned char h, unsigned char maskflag, void *imageaddr, void *maskaddr, unsigned char bpp) __attribute__((leaf)); // returns 0 on success
457 unsigned char cx16_k_sprite_set_position(unsigned char sprnum, unsigned int xpos, unsigned int ypos) __attribute__((leaf)); // returns 0 on success
458 
459 /* cc65 compatible cx16 functions */
460 
461 /* Return the number of 8K RAM banks that the machine has */
462 /* at 0xA000-0xBFFF using MEMTOP (64=512K up to 256=2MB) */
463 unsigned short get_numbanks(void) __attribute__((leaf)); // return number of 8K RAM banks at 0xA000-0xBFFF (64=512K up to 256=2MB)
464 
465 /* Get the ROM build version.
466 ** -1 -- custom build
467 ** Negative -- prerelease build
468 ** Positive -- release build
469 */
470 signed char get_ostype(void) __attribute__((leaf)); // return ROM build version (negative pre-release, -1=custom)
471 
472 /* Return the video signal type that the machine is using.
473 ** Return a TV_xx constant.
474 */
475 unsigned char get_tv(void) __attribute__((leaf)); // return TV_* enum constant for current video signal type
476 
477 /* Set the video signal type that the machine will use.
478 ** Call with a TV_xx constant.
479 ** NOTE: Be careful, can overrides user setting for current monitor type (set in config menu)
480 */
481 void set_tv(unsigned char type) __attribute__((leaf)); // set video signal type using TV_* enum constant
482 
483 /* Display the layers that are "named" by the bit flags in layers.
484 ** A value of 0b01 shows layer 0, a value of 0b10 shows layer 1,
485 ** a value of 0b11 shows both layers. Return the previous value.
486 */
487 unsigned char vera_layer_enable(unsigned char layers) __attribute__((leaf)); // enable/disable VERA layers 0/1 (bits 0/1), returns previous
488 
489 /* Enable the sprite engine when mode is non-zero (true);
490 ** disable sprites when mode is zero. Return the previous mode.
491 */
492 unsigned char vera_sprites_enable(unsigned char enable) __attribute__((leaf)); // enable/disable VERA sprites (0=off, non-zero=on), returns previous
493 
494 /* Set the video mode, return the old mode.
495 ** Return -1 if Mode isn't valid.
496 ** Call with one of the VIDEOMODE_xx constants.
497 */
498 signed char videomode(signed char mode) __attribute__((leaf)); // set video mode using VIDEOMODE_* enum constant, returns previous or -1 if error
499 
500 /* Get a byte from a location in VERA's internal address space. */
501 unsigned char vpeek(unsigned long addr) __attribute__((leaf)); // read byte from VERA VRAM address
502 
503 /* Put a byte into a location in VERA's internal address space.
504 ** (addr is second instead of first for the sake of code efficiency.)
505 */
506 void vpoke(unsigned char data, unsigned long addr) __attribute__((leaf)); // write byte value to VERA VRAM address
507 
508 void waitvsync(void); // wait for the vertical blank interrupt
509 
510 #ifdef __cplusplus
511 }
512 #endif
513 #endif // _CX16_H
get_ostype
signed char get_ostype(void) __attribute__((leaf))
get_numbanks
unsigned short get_numbanks(void) __attribute__((leaf))
videomode
signed char videomode(signed char mode) __attribute__((leaf))
cx16_k_kbdbuf_peek
int cx16_k_kbdbuf_peek(unsigned char *index_ptr) __attribute__((leaf))
cx16_k_joystick_scan
void cx16_k_joystick_scan(void) __attribute__((leaf))
VERA_DEC_64
@ VERA_DEC_64
Definition: cx16.h:193
cx16_k_memory_decompress
void cx16_k_memory_decompress(void *inaddr, void *outaddr) __attribute__((leaf))
cx16_k_graph_draw_oval
void cx16_k_graph_draw_oval(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int corner_radius, unsigned char fillflag) __attribute__((leaf))
cx16_k_fb_get_pixels
void cx16_k_fb_get_pixels(void *pixeladdr, unsigned int count) __attribute__((leaf))
VERA_DEC_160
@ VERA_DEC_160
Definition: cx16.h:199
VERA_INC_8
@ VERA_INC_8
Definition: cx16.h:206
VERA_INC_4
@ VERA_INC_4
Definition: cx16.h:205
cx16_k_graph_draw_image
void cx16_k_graph_draw_image(unsigned int x, unsigned int y, void *imageaddr, unsigned int width, unsigned int height) __attribute__((leaf))
cx16_k_monitor
void cx16_k_monitor(void) __attribute__((noreturn))
cx16_k_rdtim
unsigned long cx16_k_rdtim(void) __attribute__((leaf))
cx16_k_kbdbuf_put
void cx16_k_kbdbuf_put(unsigned char c) __attribute__((leaf))
data
char const void * data
Definition: neslib.h:92
cx16_fb_info_t
Definition: cx16.h:360
VERA_INC_256
@ VERA_INC_256
Definition: cx16.h:211
cx16_k_keymap_set
unsigned char cx16_k_keymap_set(const char *identifier) __attribute__((leaf))
VERA_INC_128
@ VERA_INC_128
Definition: cx16.h:210
fb_get_pixel
unsigned char fb_get_pixel(void) __attribute__((leaf))
TV_NTSC_COLOR
@ TV_NTSC_COLOR
Definition: cx16.h:155
cx16_k_fb_cursor_next_line
void cx16_k_fb_cursor_next_line(unsigned int x) __attribute__((leaf))
VERA_DEC_4
@ VERA_DEC_4
Definition: cx16.h:189
graph_fb_functions_t::fb_get_info
void * fb_get_info
Definition: cx16.h:369
TV_VGA2_240P
@ TV_VGA2_240P
Definition: cx16.h:166
cx16_k_joystick_get
long cx16_k_joystick_get(unsigned char sticknum) __attribute__((leaf))
cx16_k_graph_put_char
void cx16_k_graph_put_char(graph_pos_t *pos_ptr, unsigned char c) __attribute__((leaf))
VERA_INC_80
@ VERA_INC_80
Definition: cx16.h:214
graph_fb_functions_t::fb_set_pixel
void * fb_set_pixel
Definition: cx16.h:375
vera_sprites_enable
unsigned char vera_sprites_enable(unsigned char enable) __attribute__((leaf))
graph_pos_t
Definition: cx16.h:384
VERA_DEC_16
@ VERA_DEC_16
Definition: cx16.h:191
VERA_INC_2
@ VERA_INC_2
Definition: cx16.h:204
VERA_DEC_640
@ VERA_DEC_640
Definition: cx16.h:201
TV_VGA_240P
@ TV_VGA_240P
Definition: cx16.h:162
VERA_INC_512
@ VERA_INC_512
Definition: cx16.h:212
VERA_INC_64
@ VERA_INC_64
Definition: cx16.h:209
cx16_k_console_set_paging_message
void cx16_k_console_set_paging_message(void *msgaddr) __attribute__((leaf))
graph_fb_functions_t::fb_cursor_next_line
void * fb_cursor_next_line
Definition: cx16.h:372
mouse_pos_t
Definition: cx16.h:389
cx16_k_console_get_char
unsigned char cx16_k_console_get_char(void) __attribute__((leaf))
cx16_k_i2c_write_byte
int cx16_k_i2c_write_byte(unsigned char device, unsigned char offset, unsigned char byte) __attribute__((leaf))
VERA_INC_640
@ VERA_INC_640
Definition: cx16.h:217
TV_NTSC_MONO_240P
@ TV_NTSC_MONO_240P
Definition: cx16.h:167
VERA_INC_32
@ VERA_INC_32
Definition: cx16.h:208
y1
byte byte byte y1
Definition: api.h:72
h
byte byte byte byte h
Definition: api.h:27
cx16_k_fb_set_8_pixels
void cx16_k_fb_set_8_pixels(unsigned char pattern, unsigned char color) __attribute__((leaf))
cx16_k_graph_set_font
void cx16_k_graph_set_font(void *fontaddr) __attribute__((leaf))
graph_fb_functions_t::fb_set_palette
void * fb_set_palette
Definition: cx16.h:370
TV_NTSC_MONO
@ TV_NTSC_MONO
Definition: cx16.h:159
cx16_k_graph_move_rect
void cx16_k_graph_move_rect(unsigned int sx, unsigned int sy, unsigned int tx, unsigned int ty, unsigned int width, unsigned int height) __attribute__((leaf))
get_tv
unsigned char get_tv(void) __attribute__((leaf))
cx16_k_console_init
void cx16_k_console_init(unsigned int x, unsigned int y, unsigned int width, unsigned int height) __attribute__((leaf))
TV_NTSC_COLOR_240P
@ TV_NTSC_COLOR_240P
Definition: cx16.h:163
cx16_k_clock_get_date_time
void cx16_k_clock_get_date_time(cx16_date_time_t *datetime_ptr) __attribute__((leaf))
vpeek
unsigned char vpeek(unsigned long addr) __attribute__((leaf))
TV_NONE2
@ TV_NONE2
Definition: cx16.h:157
cx16_k_sprite_set_image
unsigned char cx16_k_sprite_set_image(unsigned char num, unsigned char w, unsigned char h, unsigned char maskflag, void *imageaddr, void *maskaddr, unsigned char bpp) __attribute__((leaf))
index
char index
Definition: nesdoug.h:113
graph_fb_functions_t::fb_cursor_position
void * fb_cursor_position
Definition: cx16.h:371
cx16_k_fb_set_8_pixels_opaque
void cx16_k_fb_set_8_pixels_opaque(unsigned char pattern, unsigned char mask, unsigned char color1, unsigned char color2) __attribute__((leaf))
cx16_k_i2c_read_byte
int cx16_k_i2c_read_byte(unsigned char device, unsigned char offset) __attribute__((leaf))
graph_fb_functions_t::fb_fill_pixels
void * fb_fill_pixels
Definition: cx16.h:379
VERA_DEC_1
@ VERA_DEC_1
Definition: cx16.h:187
TV_VGA
@ TV_VGA
Definition: cx16.h:154
graph_fb_functions_t::fb_get_pixels
void * fb_get_pixels
Definition: cx16.h:374
count
const void uint16_t count
Definition: memory.h:58
cx16_date_time_t::year
unsigned char year
Definition: cx16.h:357
VERA_DEC_0
@ VERA_DEC_0
Definition: cx16.h:186
VERA_DEC_32
@ VERA_DEC_32
Definition: cx16.h:192
graph_fb_functions_t::fb_move_pixels
void * fb_move_pixels
Definition: cx16.h:381
VERA_DEC_128
@ VERA_DEC_128
Definition: cx16.h:194
VERA_INC_1
@ VERA_INC_1
Definition: cx16.h:203
x
byte x
Definition: api.h:26
cx16_k_sprite_set_position
unsigned char cx16_k_sprite_set_position(unsigned char sprnum, unsigned int xpos, unsigned int ypos) __attribute__((leaf))
cx16_k_graph_clear
void cx16_k_graph_clear(void) __attribute__((leaf))
x1
byte byte x1
Definition: api.h:72
VERA_INC_320
@ VERA_INC_320
Definition: cx16.h:216
cx16_k_graph_get_char_size
long cx16_k_graph_get_char_size(unsigned char c, unsigned char style) __attribute__((leaf))
TV_VGA2
@ TV_VGA2
Definition: cx16.h:158
y
byte byte y
Definition: api.h:26
screen_mode_info_t
Definition: cx16.h:394
graph_fb_functions_t::fb_init
void * fb_init
Definition: cx16.h:368
cx16_k_fb_cursor_position
void cx16_k_fb_cursor_position(unsigned int x, unsigned int y) __attribute__((leaf))
graph_fb_functions_t::fb_get_pixel
void * fb_get_pixel
Definition: cx16.h:373
VERA_DEC_8
@ VERA_DEC_8
Definition: cx16.h:190
cx16_k_graph_draw_line
void cx16_k_graph_draw_line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2) __attribute__((leaf))
TV_RGB2
@ TV_RGB2
Definition: cx16.h:160
cx16_k_keymap_get_id
const char * cx16_k_keymap_get_id(void) __attribute__((leaf))
cx16_k_bsave
unsigned char cx16_k_bsave(void *startaddr, void *endaddr_plusone) __attribute__((leaf))
VERA_DEC_256
@ VERA_DEC_256
Definition: cx16.h:195
cx16_k_mouse_scan
void cx16_k_mouse_scan(void) __attribute__((leaf))
VERA_DEC_512
@ VERA_DEC_512
Definition: cx16.h:196
cx16_k_memory_crc
unsigned int cx16_k_memory_crc(void *dataaddr, unsigned int num_bytes) __attribute__((leaf))
cx16_k_fb_fill_pixels
void cx16_k_fb_fill_pixels(unsigned int count, unsigned int step, unsigned char color) __attribute__((leaf))
VERA_INC_0
@ VERA_INC_0
Definition: cx16.h:202
cx16_k_mouse_config
void cx16_k_mouse_config(unsigned char showmouse, unsigned char xsize8, unsigned char ysize8) __attribute__((leaf))
TV_NONE_240P
@ TV_NONE_240P
Definition: cx16.h:161
VERA_INC_160
@ VERA_INC_160
Definition: cx16.h:215
TV_RGB
@ TV_RGB
Definition: cx16.h:156
graph_fb_functions_t::fb_set_8_pixels
void * fb_set_8_pixels
Definition: cx16.h:377
vpoke
void vpoke(unsigned char data, unsigned long addr) __attribute__((leaf))
VERA_DEC_2
@ VERA_DEC_2
Definition: cx16.h:188
cx16_k_fb_get_info
void cx16_k_fb_get_info(cx16_fb_info_t *info_ptr) __attribute__((leaf))
cx16_k_graph_draw_rect
void cx16_k_graph_draw_rect(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int corner_radius, unsigned char fillflag __attribute__((leaf)))
w
byte byte byte w
Definition: api.h:26
cx16_fb_info_t::depth
unsigned char depth
Definition: cx16.h:363
cx16_k_graph_set_colors
void cx16_k_graph_set_colors(unsigned char stroke, unsigned char fill, unsigned char background) __attribute__((leaf))
cx16_k_memory_fill
void cx16_k_memory_fill(void *addr, unsigned int num_bytes, unsigned char value) __attribute__((leaf))
cx16_k_memory_copy
void cx16_k_memory_copy(void *source, void *target, unsigned int num_bytes) __attribute__((leaf))
cx16_date_time_t
Definition: cx16.h:355
VERA_INC_40
@ VERA_INC_40
Definition: cx16.h:213
cx16_k_fb_set_palette
void cx16_k_fb_set_palette(void *paladdr, unsigned char index, unsigned char count __attribute__((leaf)))
graph_fb_functions_t::fb_set_8_pixels_opaque
void * fb_set_8_pixels_opaque
Definition: cx16.h:378
VERA_INC_16
@ VERA_INC_16
Definition: cx16.h:207
cx16_k_clock_set_date_time
void cx16_k_clock_set_date_time(unsigned char year, unsigned char mon, unsigned char day, unsigned char hour, unsigned char min, unsigned char sec, unsigned char jif) __attribute__((leaf))
graph_fb_functions_t::fb_filter_pixels
void * fb_filter_pixels
Definition: cx16.h:380
cx16_fb_info_t::width
unsigned int width
Definition: cx16.h:362
cx16_k_mouse_get
unsigned char cx16_k_mouse_get(mouse_pos_t *mouse_pos_ptr) __attribute__((leaf))
waitvsync
void waitvsync(void)
cx16_k_console_put_image
void cx16_k_console_put_image(void *imageaddr, unsigned int width, unsigned int height) __attribute__((leaf))
set_tv
void set_tv(unsigned char type) __attribute__((leaf))
address
uint8_t uint16_t address
Definition: bios.h:180
mouse_pos_t::y
int y
Definition: cx16.h:391
cx16_k_graph_set_window
void cx16_k_graph_set_window(unsigned int x, unsigned int y, unsigned int width, unsigned int height) __attribute__((leaf))
cx16_k_enter_basic
void cx16_k_enter_basic(unsigned char coldstart) __attribute__((noreturn))
graph_fb_functions_t::fb_set_pixels
void * fb_set_pixels
Definition: cx16.h:376
TV_RGB2_240P
@ TV_RGB2_240P
Definition: cx16.h:168
cx16_k_fb_init
void cx16_k_fb_init(void) __attribute__((leaf))
graph_pos_t::y
int y
Definition: cx16.h:386
cx16_k_fb_filter_pixels
void cx16_k_fb_filter_pixels(void *filterfunc, unsigned int count) __attribute__((leaf))
TV_NONE
@ TV_NONE
Definition: cx16.h:153
VERA_DEC_40
@ VERA_DEC_40
Definition: cx16.h:197
cx16_k_fb_move_pixels
void cx16_k_fb_move_pixels(unsigned int sx, unsigned int sy, unsigned int tx, unsigned int ty, unsigned int count) __attribute__((leaf))
VERA_DEC_320
@ VERA_DEC_320
Definition: cx16.h:200
_6522.h
VERA_DEC_80
@ VERA_DEC_80
Definition: cx16.h:198
cx16_k_screen_mode_set
unsigned char cx16_k_screen_mode_set(unsigned char mode) __attribute__((leaf))
cx16_k_graph_init
void cx16_k_graph_init(graph_fb_functions_t *fb_funcs_ptr) __attribute__((leaf))
cx16_k_kbdbuf_get_modifiers
unsigned char cx16_k_kbdbuf_get_modifiers(void) __attribute__((leaf))
TV_NONE2_240P
@ TV_NONE2_240P
Definition: cx16.h:165
mode
const void uint16_t uint8_t mode
Definition: memory.h:58
vera_layer_enable
unsigned char vera_layer_enable(unsigned char layers) __attribute__((leaf))
TV_RGB_240P
@ TV_RGB_240P
Definition: cx16.h:164
cx16_k_screen_set_charset
void cx16_k_screen_set_charset(unsigned char charset_type, void *charsetaddr) __attribute__((leaf))
screen_mode_info_t::rows
unsigned char rows
Definition: cx16.h:396
cx16_k_console_put_char
void cx16_k_console_put_char(unsigned char c, unsigned char wrapwordflag) __attribute__((leaf))
cx16_k_macptr
long cx16_k_macptr(unsigned char count, unsigned char noadvance, void *destaddr) __attribute__((leaf))
graph_fb_functions_t
Definition: cx16.h:366
c
byte byte c
Definition: api.h:59
cx16_k_screen_mode_get
unsigned char cx16_k_screen_mode_get(screen_mode_info_t *info_ptr) __attribute__((leaf))
cx16_k_entropy_get
unsigned long cx16_k_entropy_get(void) __attribute__((leaf))