Go to the documentation of this file.
48 # error This module may be used only when compiling for the CX16!
60 #define CH_COLOR_SWAP 0x01
61 #define CH_UNDERLINE 0x04
64 #define CH_BACKSPACE 0x08
65 #define CH_ITALIC 0x0B
66 #define CH_OUTLINE 0x0C
67 #define CH_FONT_ISO 0x0F
71 #define CH_ORANGE 0x81
72 #define CH_FONT_PET 0x8F
74 #define CH_ATTR_CLEAR 0x92
77 #define CH_LIGHTRED CH_PINK
80 #define CH_LIGHTGREEN 0x99
81 #define CH_LIGHTBLUE 0x9A
83 #define CH_PURPLE 0x9C
84 #define CH_YELLOW 0x9E
86 #define CH_SHIFT_SPACE 0xA0
89 #define CH_SHIFT_TAB 0x18
105 #define COLOR_BLACK 0x00
106 #define COLOR_WHITE 0x01
107 #define COLOR_RED 0x02
108 #define COLOR_CYAN 0x03
109 #define COLOR_PURPLE 0x04
110 #define COLOR_GREEN 0x05
111 #define COLOR_BLUE 0x06
112 #define COLOR_YELLOW 0x07
113 #define COLOR_ORANGE 0x08
114 #define COLOR_BROWN 0x09
115 #define COLOR_PINK 0x0A
116 #define COLOR_LIGHTRED COLOR_PINK
117 #define COLOR_GRAY1 0x0B
118 #define COLOR_GRAY2 0x0C
119 #define COLOR_LIGHTGREEN 0x0D
120 #define COLOR_LIGHTBLUE 0x0E
121 #define COLOR_GRAY3 0x0F
124 enum :
unsigned char {
142 #define JOY_KEYBOARD 0
143 #define JOY_SNES_PORT1 1
144 #define JOY_SNES_PORT2 2
145 #define JOY_SNES_PORT3 3
146 #define JOY_SNES_PORT4 4
168 bool north()
const {
return !(data0 &
JOY_UP_MASK); }
174 bool south_east()
const {
182 #define MOUSE_BTN_MIDDLE 0x02
188 enum :
unsigned char {
208 #define VIDEOMODE_80x60 0x00
209 #define VIDEOMODE_80x30 0x01
210 #define VIDEOMODE_40x60 0x02
211 #define VIDEOMODE_40x30 0x03
212 #define VIDEOMODE_40x15 0x04
213 #define VIDEOMODE_20x30 0x05
214 #define VIDEOMODE_20x15 0x06
215 #define VIDEOMODE_80COL VIDEOMODE_80x60
216 #define VIDEOMODE_40COL VIDEOMODE_40x30
217 #define VIDEOMODE_320x240 0x80
218 #define VIDEOMODE_SWAP (-1)
221 enum :
unsigned char {
257 #define VERA_IRQ_VSYNC 0b00000001
258 #define VERA_IRQ_RASTER 0b00000010
259 #define VERA_IRQ_SPR_COLL 0b00000100
260 #define VERA_IRQ_AUDIO_LOW 0b00001000
263 enum :
unsigned char {
284 #define RAM_BANK (*(volatile unsigned char *)0x00)
285 #define ROM_BANK (*(volatile unsigned char *)0x01)
288 #define VIA1 (*(volatile struct __6522 *)0x9F00)
289 #define VIA2 (*(volatile struct __6522 *)0x9F10)
294 unsigned char address_hi;
297 unsigned char control;
298 unsigned char irq_enable;
299 unsigned char irq_flags;
300 unsigned char irq_raster;
304 unsigned char hscale;
305 unsigned char vscale;
306 unsigned char border;
309 unsigned char hstart;
311 unsigned char vstart;
315 unsigned char fxctrl;
316 unsigned char fxtilebase;
317 unsigned char fxmapbase;
318 unsigned char fxmult;
321 unsigned char fxxincrl;
322 unsigned char fxxincrh;
323 unsigned char fxyincrl;
324 unsigned char fxyincrh;
327 unsigned char fxxposl;
328 unsigned char fxxposh;
329 unsigned char fxyposl;
330 unsigned char fxyposh;
333 unsigned char fxxposs;
334 unsigned char fxyposs;
335 unsigned char fxpolyfilll;
336 unsigned char fxpolyfillh;
339 unsigned char fxcachel;
340 unsigned char fxcachem;
341 unsigned char fxcacheh;
342 unsigned char fxcacheu;
345 unsigned char dcver0;
346 unsigned char dcver1;
347 unsigned char dcver2;
348 unsigned char dcver3;
352 unsigned char config;
353 unsigned char mapbase;
354 unsigned char tilebase;
355 unsigned int hscroll;
356 unsigned int vscroll;
359 unsigned char config;
360 unsigned char mapbase;
361 unsigned char tilebase;
362 unsigned int hscroll;
363 unsigned int vscroll;
366 unsigned char control;
372 unsigned char control;
375 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201103L)
376 static_assert(
sizeof(
struct __vera) == 32,
"struct __vera must be 32 bytes");
379 #define VERA (*(volatile struct __vera *)0x9F20)
385 unsigned char status;
389 #define YM2151 (*(volatile struct __ym2151 *)0x9F40)
396 unsigned char freq_lo;
397 unsigned char freq_hi;
400 unsigned char volume;
401 unsigned char waveform;
403 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201103L)
404 static_assert(
sizeof(
struct __vera_psg) == 4,
"struct __vera_psg must be 4 bytes");
410 unsigned char vera_action;
411 unsigned char keyboard;
413 unsigned char save_on_exit;
414 unsigned char gif_method;
415 unsigned char wav_method;
416 unsigned char cmd_key_off;
417 unsigned long const cycle_count;
418 unsigned char const unused2[1];
419 unsigned char const keymap;
420 char const detect[2];
422 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201103L)
423 static_assert(
sizeof(
struct __emul) == 16,
"struct __emul must be 16 bytes");
426 #define EMULATOR (*(volatile struct __emul *)0x9FB0)
429 #define BANK_RAM ((volatile unsigned char *)0xA000)
481 unsigned char cx16_k_bsave(
void *startaddr,
void *endaddr_plusone) __attribute__((leaf));
483 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));
485 void cx16_k_console_init(
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height) __attribute__((leaf));
499 void cx16_k_fb_move_pixels(
unsigned int sx,
unsigned int sy,
unsigned int tx,
unsigned int ty,
unsigned int count) __attribute__((leaf));
501 void cx16_k_fb_set_8_pixels_opaque(
unsigned char pattern,
unsigned char mask,
unsigned char color1,
unsigned char color2) __attribute__((leaf));
504 void cx16_k_graph_draw_image(
unsigned int x,
unsigned int y,
void *imageaddr,
unsigned int width,
unsigned int height) __attribute__((leaf));
506 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));
507 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));
510 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));
512 void cx16_k_graph_set_colors(
unsigned char stroke,
unsigned char fill,
unsigned char background) __attribute__((leaf));
514 void cx16_k_graph_set_window(
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height) __attribute__((leaf));
516 int cx16_k_i2c_write_byte(
unsigned char device,
unsigned char offset,
unsigned char byte) __attribute__((leaf));
531 __attribute__((leaf));
536 long cx16_k_macptr(
unsigned char count,
unsigned char noadvance,
void *destaddr) __attribute__((leaf));
537 void cx16_k_memory_copy(
void *source,
void *target,
unsigned int num_bytes) __attribute__((leaf));
538 unsigned int cx16_k_memory_crc(
void *dataaddr,
unsigned int num_bytes) __attribute__((leaf));
540 void cx16_k_memory_fill(
void *addr,
unsigned int num_bytes,
unsigned char value) __attribute__((leaf));
542 void cx16_k_mouse_config(
unsigned char showmouse,
unsigned char xsize8,
unsigned char ysize8) __attribute__((leaf));
549 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));
556 unsigned short get_numbanks(
void) __attribute__((leaf));
563 signed char get_ostype(
void) __attribute__((leaf));
568 unsigned char get_tv(
void) __attribute__((leaf));
574 void set_tv(
unsigned char type) __attribute__((leaf));
591 signed char videomode(
signed char mode) __attribute__((leaf));
594 unsigned char vpeek(
unsigned long addr) __attribute__((leaf));
599 void vpoke(
unsigned char data,
unsigned long addr) __attribute__((leaf));
Status of SNES joystick populated by cx16_k_joystick_get();.
Definition: cx16.h:149
signed char get_ostype(void) __attribute__((leaf))
@ VERA_INC_512
Definition: cx16.h:248
@ JOY_BTN_X_MASK
Definition: cx16.h:136
unsigned short get_numbanks(void) __attribute__((leaf))
@ JOY_START_MASK
Definition: cx16.h:129
unsigned short data
data0 and data1 combined
Definition: cx16.h:155
signed char videomode(signed char mode) __attribute__((leaf))
int cx16_k_kbdbuf_peek(unsigned char *index_ptr) __attribute__((leaf))
void cx16_k_joystick_scan(void) __attribute__((leaf))
void cx16_k_memory_decompress(void *inaddr, void *outaddr) __attribute__((leaf))
@ VERA_INC_16
Definition: cx16.h:243
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))
JoyState cx16_k_joystick_get(unsigned char joystick_num)
@ JOY_LEFT_MASK
Definition: cx16.h:132
@ JOY_BTN_B_MASK
Definition: cx16.h:126
void cx16_k_fb_get_pixels(void *pixeladdr, unsigned int count) __attribute__((leaf))
@ VERA_INC_4
Definition: cx16.h:241
@ VERA_DEC_1
Definition: cx16.h:223
@ ROM_BANNEX
BASIC Annex (code for some added BASIC functions)
Definition: cx16.h:276
void cx16_k_graph_draw_image(unsigned int x, unsigned int y, void *imageaddr, unsigned int width, unsigned int height) __attribute__((leaf))
void cx16_k_monitor(void) __attribute__((noreturn))
@ VERA_DEC_160
Definition: cx16.h:235
unsigned long cx16_k_rdtim(void) __attribute__((leaf))
void cx16_k_kbdbuf_put(unsigned char c) __attribute__((leaf))
@ TV_VGA
Definition: cx16.h:190
@ TV_NTSC_MONO_240P
Definition: cx16.h:203
char const void * data
Definition: neslib.h:92
unsigned char cx16_k_keymap_set(const char *identifier) __attribute__((leaf))
@ JOY_SELECT_MASK
Definition: cx16.h:128
@ TV_NONE2_240P
Definition: cx16.h:201
@ VERA_INC_160
Definition: cx16.h:251
unsigned char fb_get_pixel(void) __attribute__((leaf))
void cx16_k_fb_cursor_next_line(unsigned int x) __attribute__((leaf))
void * fb_get_info
Definition: cx16.h:450
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))
@ TV_VGA2
Definition: cx16.h:194
@ ROM_X16EDIT1
The built-in text editor.
Definition: cx16.h:277
void cx16_k_graph_put_char(graph_pos_t *pos_ptr, unsigned char c) __attribute__((leaf))
@ JOY_FIRE_RIGHT_MASK
Definition: cx16.h:138
@ ROM_BASLOAD
A transpiler that converts BASLOAD dialect to BASIC V2.
Definition: cx16.h:279
void * fb_set_pixel
Definition: cx16.h:456
@ VERA_INC_64
Definition: cx16.h:245
unsigned char vera_sprites_enable(unsigned char enable) __attribute__((leaf))
@ VERA_DEC_4
Definition: cx16.h:225
@ VERA_INC_2
Definition: cx16.h:240
@ TV_RGB
Definition: cx16.h:192
void cx16_k_console_set_paging_message(void *msgaddr) __attribute__((leaf))
@ VERA_DEC_8
Definition: cx16.h:226
@ TV_RGB2_240P
Definition: cx16.h:204
@ VERA_INC_40
Definition: cx16.h:249
void * fb_cursor_next_line
Definition: cx16.h:453
@ TV_NONE
Definition: cx16.h:189
unsigned char cx16_k_console_get_char(void) __attribute__((leaf))
int cx16_k_i2c_write_byte(unsigned char device, unsigned char offset, unsigned char byte) __attribute__((leaf))
@ ROM_AUDIO
Audio API routines.
Definition: cx16.h:274
@ TV_RGB_240P
Definition: cx16.h:200
byte byte byte y1
Definition: api.h:72
byte byte byte byte h
Definition: api.h:27
void cx16_k_fb_set_8_pixels(unsigned char pattern, unsigned char color) __attribute__((leaf))
void cx16_k_graph_set_font(void *fontaddr) __attribute__((leaf))
void * fb_set_palette
Definition: cx16.h:451
@ VERA_DEC_80
Definition: cx16.h:234
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))
@ VERA_DEC_64
Definition: cx16.h:229
unsigned char get_tv(void) __attribute__((leaf))
@ VERA_DEC_256
Definition: cx16.h:231
@ JOY_FIRE_LEFT_MASK
Definition: cx16.h:137
void cx16_k_console_init(unsigned int x, unsigned int y, unsigned int width, unsigned int height) __attribute__((leaf))
@ VERA_INC_320
Definition: cx16.h:252
void cx16_k_clock_get_date_time(cx16_date_time_t *datetime_ptr) __attribute__((leaf))
unsigned char vpeek(unsigned long addr) __attribute__((leaf))
@ JOY_BTN_Y_MASK
Definition: cx16.h:127
unsigned char data1
Bits: A X FireL FireR 1 1 1 1.
Definition: cx16.h:153
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))
@ ROM_X16EDIT2
The built-in text editor.
Definition: cx16.h:278
char index
Definition: nesdoug.h:113
void * fb_cursor_position
Definition: cx16.h:452
void cx16_k_fb_set_8_pixels_opaque(unsigned char pattern, unsigned char mask, unsigned char color1, unsigned char color2) __attribute__((leaf))
int cx16_k_i2c_read_byte(unsigned char device, unsigned char offset) __attribute__((leaf))
void * fb_fill_pixels
Definition: cx16.h:460
@ TV_RGB2
Definition: cx16.h:196
@ JOY_RIGHT_MASK
Definition: cx16.h:133
void * fb_get_pixels
Definition: cx16.h:455
const void uint16_t count
Definition: memory.h:58
unsigned char year
Definition: cx16.h:438
@ VERA_DEC_640
Definition: cx16.h:237
bool detached
True if joystick is disconnected.
Definition: cx16.h:157
void * fb_move_pixels
Definition: cx16.h:462
@ TV_NTSC_COLOR_240P
Definition: cx16.h:199
byte x
Definition: api.h:26
unsigned char cx16_k_sprite_set_position(unsigned char sprnum, unsigned int xpos, unsigned int ypos) __attribute__((leaf))
void cx16_k_graph_clear(void) __attribute__((leaf))
byte byte x1
Definition: api.h:72
long cx16_k_graph_get_char_size(unsigned char c, unsigned char style) __attribute__((leaf))
@ VERA_DEC_0
Definition: cx16.h:222
byte byte y
Definition: api.h:26
void * fb_init
Definition: cx16.h:449
void cx16_k_fb_cursor_position(unsigned int x, unsigned int y) __attribute__((leaf))
@ VERA_DEC_512
Definition: cx16.h:232
void * fb_get_pixel
Definition: cx16.h:454
void cx16_k_graph_draw_line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2) __attribute__((leaf))
const char * cx16_k_keymap_get_id(void) __attribute__((leaf))
unsigned char cx16_k_bsave(void *startaddr, void *endaddr_plusone) __attribute__((leaf))
@ VERA_DEC_128
Definition: cx16.h:230
@ TV_NTSC_MONO
Definition: cx16.h:195
void cx16_k_mouse_scan(void) __attribute__((leaf))
@ TV_VGA2_240P
Definition: cx16.h:202
unsigned int cx16_k_memory_crc(void *dataaddr, unsigned int num_bytes) __attribute__((leaf))
@ VERA_INC_256
Definition: cx16.h:247
void cx16_k_fb_fill_pixels(unsigned int count, unsigned int step, unsigned char color) __attribute__((leaf))
@ VERA_DEC_16
Definition: cx16.h:227
void cx16_k_fb_set_palette(void *paladdr, unsigned char index, unsigned char count) __attribute__((leaf))
void cx16_k_mouse_config(unsigned char showmouse, unsigned char xsize8, unsigned char ysize8) __attribute__((leaf))
@ VERA_INC_0
Definition: cx16.h:238
@ ROM_KERNAL
KERNAL operating system and drivers.
Definition: cx16.h:264
void * fb_set_8_pixels
Definition: cx16.h:458
@ ROM_UTIL
System Configuration (Date/Time, Display Preferences)
Definition: cx16.h:275
void vpoke(unsigned char data, unsigned long addr) __attribute__((leaf))
void cx16_k_fb_get_info(cx16_fb_info_t *info_ptr) __attribute__((leaf))
byte byte byte w
Definition: api.h:26
@ ROM_CHARSET
PETSCII and ISO character sets (uploaded into VRAM)
Definition: cx16.h:270
unsigned char depth
Definition: cx16.h:444
@ ROM_GRAPH
Kernal graph and font routines.
Definition: cx16.h:272
void cx16_k_graph_set_colors(unsigned char stroke, unsigned char fill, unsigned char background) __attribute__((leaf))
@ VERA_INC_128
Definition: cx16.h:246
@ JOY_BTN_A_MASK
Definition: cx16.h:135
void cx16_k_memory_fill(void *addr, unsigned int num_bytes, unsigned char value) __attribute__((leaf))
@ TV_VGA_240P
Definition: cx16.h:198
unsigned char data0
Bits: B Y Select Start Up Down Left Right.
Definition: cx16.h:152
void cx16_k_memory_copy(void *source, void *target, unsigned int num_bytes) __attribute__((leaf))
@ VERA_INC_8
Definition: cx16.h:242
void * fb_set_8_pixels_opaque
Definition: cx16.h:459
@ ROM_CMDRDOS
The computer-based CMDR-DOS for FAT32 SD cards.
Definition: cx16.h:266
@ ROM_DEMO
Demo routines.
Definition: cx16.h:273
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))
void * fb_filter_pixels
Definition: cx16.h:461
@ VERA_DEC_320
Definition: cx16.h:236
unsigned int width
Definition: cx16.h:443
unsigned char cx16_k_mouse_get(mouse_pos_t *mouse_pos_ptr) __attribute__((leaf))
@ VERA_INC_32
Definition: cx16.h:244
@ TV_NONE2
Definition: cx16.h:193
void cx16_k_console_put_image(void *imageaddr, unsigned int width, unsigned int height) __attribute__((leaf))
void set_tv(unsigned char type) __attribute__((leaf))
uint8_t uint16_t address
Definition: bios.h:180
int y
Definition: cx16.h:472
void cx16_k_graph_set_window(unsigned int x, unsigned int y, unsigned int width, unsigned int height) __attribute__((leaf))
@ ROM_MONITOR
Machine Language Monitor.
Definition: cx16.h:269
void cx16_k_enter_basic(unsigned char coldstart) __attribute__((noreturn))
void * fb_set_pixels
Definition: cx16.h:457
@ VERA_DEC_32
Definition: cx16.h:228
void cx16_k_fb_init(void) __attribute__((leaf))
@ VERA_INC_80
Definition: cx16.h:250
int y
Definition: cx16.h:467
@ VERA_DEC_2
Definition: cx16.h:224
@ ROM_DIAG
Memory diagnostic.
Definition: cx16.h:271
@ TV_NTSC_COLOR
Definition: cx16.h:191
void cx16_k_fb_filter_pixels(void *filterfunc, unsigned int count) __attribute__((leaf))
void cx16_k_fb_move_pixels(unsigned int sx, unsigned int sy, unsigned int tx, unsigned int ty, unsigned int count) __attribute__((leaf))
unsigned char cx16_k_screen_mode_set(unsigned char mode) __attribute__((leaf))
void cx16_k_graph_init(graph_fb_functions_t *fb_funcs_ptr) __attribute__((leaf))
@ ROM_BASIC
BASIC interpreter.
Definition: cx16.h:268
unsigned char cx16_k_kbdbuf_get_modifiers(void) __attribute__((leaf))
@ VERA_INC_1
Definition: cx16.h:239
@ TV_NONE_240P
Definition: cx16.h:197
@ JOY_UP_MASK
Definition: cx16.h:130
@ ROM_FAT32
The FAT32 driver itself.
Definition: cx16.h:267
const void uint16_t uint8_t mode
Definition: memory.h:58
unsigned char vera_layer_enable(unsigned char layers) __attribute__((leaf))
@ VERA_DEC_40
Definition: cx16.h:233
void cx16_k_screen_set_charset(unsigned char charset_type, void *charsetaddr) __attribute__((leaf))
unsigned char rows
Definition: cx16.h:477
@ ROM_KEYBD
Keyboard layout tables.
Definition: cx16.h:265
void cx16_k_console_put_char(unsigned char c, unsigned char wrapwordflag) __attribute__((leaf))
@ VERA_INC_640
Definition: cx16.h:253
long cx16_k_macptr(unsigned char count, unsigned char noadvance, void *destaddr) __attribute__((leaf))
@ JOY_DOWN_MASK
Definition: cx16.h:131
byte byte c
Definition: api.h:59
unsigned char cx16_k_screen_mode_get(screen_mode_info_t *info_ptr) __attribute__((leaf))
unsigned long cx16_k_entropy_get(void) __attribute__((leaf))