llvm-mos-sdk
vdc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Adrian "asie" Siekierka
3  *
4  * Licensed under the Apache License, Version 2.0 with LLVM Exceptions,
5  * See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
6  * information.
7  */
8 
9 #ifndef _PCE_VDC_H_
10 #define _PCE_VDC_H_
11 
12 #include <stdbool.h>
13 #include <stdint.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
23 #define VDC_SPRITE_COLOR(n) ((n))
24 #define VDC_SPRITE_COLOR_MASK (0xF)
25 #define VDC_SPRITE_BG 0
26 #define VDC_SPRITE_FG (0x1 << 7)
27 #define VDC_SPRITE_WIDTH_16 0
28 #define VDC_SPRITE_WIDTH_32 (0x1 << 8)
29 #define VDC_SPRITE_WIDTH_MASK (0x1 << 8)
30 #define VDC_SPRITE_HEIGHT_16 0
31 #define VDC_SPRITE_HEIGHT_32 (0x1 << 12)
32 #define VDC_SPRITE_HEIGHT_64 (0x3 << 12)
33 #define VDC_SPRITE_HEIGHT_MASK (0x3 << 12)
34 #define VDC_SPRITE_FLIP_X (0x1 << 11)
35 #define VDC_SPRITE_FLIP_Y (0x1 << 15)
36 
37 typedef struct {
42 } vdc_sprite_t;
43 
51 
59 
63 void pce_vdc_set_copy_word(void);
68 void pce_vdc_set_copy_row(void);
69 
73 void pce_vdc_set_copy_32_words(void);
79 
83 void pce_vdc_set_copy_64_words(void);
89 
99 
107 void pce_vdc_copy_to_vram(uint16_t dest, const void *source, uint16_t length);
108 
116 void pce_vdc_copy_from_vram(void *dest, uint16_t source, uint16_t length);
117 
132 void pce_vdc_dma_start(uint8_t mode, uint16_t source, uint16_t dest,
133  uint16_t length);
134 
138 bool pce_vdc_dma_finished(void);
139 
148 void pce_vdc_set_width_tiles(uint8_t tiles, uint8_t vce_flags);
149 void pce_vdc_set_width(uint16_t pixels, uint8_t vce_flags);
150 
156 void pce_vdc_set_height(uint8_t lines);
157 void pce_vdc_set_resolution(uint16_t width_pixels, uint8_t height_pixels,
158  uint8_t vce_flags);
159 
165 void pce_vdc_bg_set_size(uint8_t value);
166 
173 
179 void pce_vdc_enable(uint8_t value);
180 
186 void pce_vdc_disable(uint8_t value);
187 
191 void pce_vdc_bg_enable(void);
192 
196 void pce_vdc_bg_disable(void);
197 
201 void pce_vdc_sprite_enable(void);
202 
206 void pce_vdc_sprite_disable(void);
207 
211 void pce_vdc_irq_scanline_enable(void);
212 
217 
222 
227 
232 
237 
241 void pce_vdc_irq_vblank_enable(void);
242 
246 void pce_vdc_irq_vblank_disable(void);
247 
255 bool pce_sgx_detect(void);
256 
262 void pce_sgx_vdc_init(void);
263 
267 void pce_sgx_vdc1_set(void);
268 
272 void pce_sgx_vdc2_set(void);
273 
278 void pce_sgx_vdc_set(uint8_t id);
279 
283 volatile uint8_t *pce_sgx_vdc_get_index(void);
284 
288 volatile uint16_t *pce_sgx_vdc_get_data(void);
289 
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif /* _PCE_VDC_H_ */
pce_sgx_vdc_get_data
volatile uint16_t * pce_sgx_vdc_get_data(void)
SuperGrafx: Get the current VDC's data port location.
pce_vdc_irq_vblank_disable
void pce_vdc_irq_vblank_disable(void)
Disable the veritcal blank IRQ.
pce_sgx_vdc_set
void pce_sgx_vdc_set(uint8_t id)
SuperGrafx: Set the specified VDC as the current VDC for pce_vdc functions.
std::uint16_t
::uint16_t uint16_t
Definition: cstdint:22
data
char const void * data
Definition: neslib.h:92
pce_sgx_vdc2_set
void pce_sgx_vdc2_set(void)
SuperGrafx: Set the VDC2 as the current VDC for pce_vdc functions.
pce_vdc_irq_sprite_overflow_disable
void pce_vdc_irq_sprite_overflow_disable(void)
Disable the sprite overflow IRQ.
pce_vdc_set_copy_64_words
void pce_vdc_set_copy_64_words(void)
Set the VDC's copy method to copy every 64th word.
pce_vdc_set_width
void pce_vdc_set_width(uint16_t pixels, uint8_t vce_flags)
pce_vdc_enable
void pce_vdc_enable(uint8_t value)
Enable VDC control flags.
pce_sgx_vdc_get_index
volatile uint8_t * pce_sgx_vdc_get_index(void)
SuperGrafx: Get the current VDC's index port location.
pce_vdc_set_copy_column_64
void pce_vdc_set_copy_column_64(void)
Set the VDC's copy method to copy every column for a 64-wide display. Alias for pce_vdc_set_copy_64_w...
pce_vdc_irq_vblank_enable
void pce_vdc_irq_vblank_enable(void)
Enable the veritcal blank IRQ.
length
uint8_t uint16_t uint16_t length
Definition: bios.h:181
pce_vdc_sprite_set_table_start
void pce_vdc_sprite_set_table_start(uint16_t loc)
Set the sprite attribute table location.
std::uint8_t
::uint8_t uint8_t
Definition: cstdint:21
pce_vdc_sprite_enable
void pce_vdc_sprite_enable(void)
Enable the sprite layer.
pce_vdc_irq_sprite_collide_enable
void pce_vdc_irq_sprite_collide_enable(void)
Enable the sprite collision IRQ.
pce_vdc_copy_from_vram
void pce_vdc_copy_from_vram(void *dest, uint16_t source, uint16_t length)
Copy data from VRAM to RAM.
index
char index
Definition: nesdoug.h:113
vdc_sprite_t::pattern
uint16_t pattern
Definition: vdc.h:40
pce_vdc_irq_sprite_overflow_enable
void pce_vdc_irq_sprite_overflow_enable(void)
Enable the sprite overflow IRQ.
pce_vdc_irq_sprite_collide_disable
void pce_vdc_irq_sprite_collide_disable(void)
Disable the sprite collision IRQ.
vdc_sprite_t::attr
uint16_t attr
Definition: vdc.h:41
pce_vdc_sprite_disable
void pce_vdc_sprite_disable(void)
Disable the sprite layer.
pce_vdc_dma_start
void pce_vdc_dma_start(uint8_t mode, uint16_t source, uint16_t dest, uint16_t length)
Start a DMA operation on the VDC.
pce_vdc_set_copy_32_words
void pce_vdc_set_copy_32_words(void)
Set the VDC's copy method to copy every 32nd word.
pce_vdc_set_width_tiles
void pce_vdc_set_width_tiles(uint8_t tiles, uint8_t vce_flags)
Set the VDC width, in tiles.
pce_vdc_poke
void pce_vdc_poke(uint8_t index, uint16_t data)
Write a value to the VDC port.
pce_vdc_set_copy_column_128
void pce_vdc_set_copy_column_128(void)
Set the VDC's copy method to copy every column for a 128-wide display. Alias for pce_vdc_set_copy_128...
pce_vdc_set_height
void pce_vdc_set_height(uint8_t lines)
Set the VDC height, in raster lines.
pce_sgx_vdc1_set
void pce_sgx_vdc1_set(void)
SuperGrafx: Set the VDC1 as the current VDC for pce_vdc functions.
pce_vdc_bg_set_size
void pce_vdc_bg_set_size(uint8_t value)
Set the VDC background size.
pce_vdc_copy_to_vram
void pce_vdc_copy_to_vram(uint16_t dest, const void *source, uint16_t length)
Copy data from RAM to VRAM.
vdc_sprite_t::y
uint16_t y
Definition: vdc.h:38
pce_vdc_irq_scanline_disable
void pce_vdc_irq_scanline_disable(void)
Disable the scanline IRQ.
vdc_sprite_t
Definition: vdc.h:37
pce_sgx_detect
bool pce_sgx_detect(void)
SuperGrafx: Check for presence.
pce_vdc_set_resolution
void pce_vdc_set_resolution(uint16_t width_pixels, uint8_t height_pixels, uint8_t vce_flags)
pce_vdc_bg_disable
void pce_vdc_bg_disable(void)
Disable the background layer.
pce_vdc_bg_enable
void pce_vdc_bg_enable(void)
Enable the background layer.
pce_vdc_irq_scanline_enable
void pce_vdc_irq_scanline_enable(void)
Enable the scanline IRQ.
vdc_sprite_t::x
uint16_t x
Definition: vdc.h:39
pce_vdc_disable
void pce_vdc_disable(uint8_t value)
Disable VDC control flags.
pce_vdc_set_copy_128_words
void pce_vdc_set_copy_128_words(void)
Set the VDC's copy method to copy every 128th word.
pce_vdc_set_copy_word
void pce_vdc_set_copy_word(void)
Set the VDC's copy method to copy every word.
pce_vdc_set_copy_row
void pce_vdc_set_copy_row(void)
Set the VDC's copy method to copy every row. Alias for pce_vdc_set_copy_word .
pce_vdc_set_copy_column_32
void pce_vdc_set_copy_column_32(void)
Set the VDC's copy method to copy every column for a 32-wide display. Alias for pce_vdc_set_copy_32_w...
mode
const void uint16_t uint8_t mode
Definition: memory.h:58
pce_vdc_peek
uint16_t pce_vdc_peek(uint8_t index)
Read a value from the VDC port.
pce_vdc_dma_finished
bool pce_vdc_dma_finished(void)
Check if the DMA operation has finished.
pce_sgx_vdc_init
void pce_sgx_vdc_init(void)
SuperGrafx: Initialize the second VDC.