llvm-mos-sdk
Classes | Macros | Typedefs | Enumerations | Functions | Variables
bios.h File Reference
#include "types.h"
#include <pce.h>
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for bios.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pce_cdb_subq_data
 
struct  pce_cdb_toc_data
 
struct  pce_cdb_divmod_u16_result
 
struct  pce_cdb_divmod_s16_result
 

Macros

#define PCE_CDB_SUBQ_TYPE_2CH   0x0
 
#define PCE_CDB_SUBQ_TYPE_4CH   0x4
 
#define PCE_CDB_SUBQ_TYPE_DATA   0x8
 
#define PCE_CDB_SUBQ_TYPE_MASK   0xC
 
#define PCE_CDB_SUBQ_SCMS   0x2
 
#define PCE_CDB_SUBQ_PRE_EMPHASIS   0x1
 
#define PCE_CDB_VDC_BG_WIDTH_32   (0)
 
#define PCE_CDB_VDC_BG_WIDTH_64   (1)
 
#define PCE_CDB_VDC_BG_WIDTH_128   (2)
 
#define PCE_CDB_VDC_BG_HEIGHT_32   (0 << 2)
 
#define PCE_CDB_VDC_BG_HEIGHT_64   (1 << 2)
 
#define PCE_CDB_VDC_BG_SIZE_32_32   (PCE_CDB_VDC_BG_WIDTH_32 | PCE_CDB_VDC_BG_HEIGHT_32)
 
#define PCE_CDB_VDC_BG_SIZE_64_32   (PCE_CDB_VDC_BG_WIDTH_64 | PCE_CDB_VDC_BG_HEIGHT_32)
 
#define PCE_CDB_VDC_BG_SIZE_128_32   (PCE_CDB_VDC_BG_WIDTH_128 | PCE_CDB_VDC_BG_HEIGHT_32)
 
#define PCE_CDB_VDC_BG_SIZE_32_64   (PCE_CDB_VDC_BG_WIDTH_32 | PCE_CDB_VDC_BG_HEIGHT_64)
 
#define PCE_CDB_VDC_BG_SIZE_64_64   (PCE_CDB_VDC_BG_WIDTH_64 | PCE_CDB_VDC_BG_HEIGHT_64)
 
#define PCE_CDB_VDC_BG_SIZE_128_64   (PCE_CDB_VDC_BG_WIDTH_128 | PCE_CDB_VDC_BG_HEIGHT_64)
 
#define PCE_CDB_VDC_CLOCK_5MHZ   0
 
#define PCE_CDB_VDC_CLOCK_7MHZ   1
 
#define PCE_CDB_VDC_COPY_1   0
 
#define PCE_CDB_VDC_COPY_32   1
 
#define PCE_CDB_VDC_COPY_64   2
 
#define PCE_CDB_VDC_COPY_128   3
 
#define PCE_CDB_SPR_INDEX   ((volatile uint8_t *)0x2216)
 
#define PCE_CDB_SPRITE   ((volatile vdc_sprite_t *)0x2217)
 
#define PCE_CDB_SPR_Y   ((volatile uint16_t *)0x2217)
 
#define PCE_CDB_SPR_Y_LO   ((volatile uint8_t *)0x2217)
 
#define PCE_CDB_SPR_Y_HI   ((volatile uint8_t *)0x2218)
 
#define PCE_CDB_SPR_X   ((volatile uint16_t *)0x2219)
 
#define PCE_CDB_SPR_X_LO   ((volatile uint8_t *)0x2219)
 
#define PCE_CDB_SPR_X_HI   ((volatile uint8_t *)0x221A)
 
#define PCE_CDB_SPR_PATTERN   ((volatile uint16_t *)0x221B)
 
#define PCE_CDB_SPR_PATTERN_LO   ((volatile uint8_t *)0x221B)
 
#define PCE_CDB_SPR_PATTERN_HI   ((volatile uint8_t *)0x221C)
 
#define PCE_CDB_SPR_ATTR   ((volatile uint16_t *)0x221D)
 
#define PCE_CDB_SPR_ATTR_LO   ((volatile uint8_t *)0x221D)
 
#define PCE_CDB_SPR_ATTR_HI   ((volatile uint8_t *)0x221E)
 

Typedefs

typedef struct pce_cdb_subq_data pce_cdb_subq_data_t
 
typedef struct pce_cdb_toc_data pce_cdb_toc_data_t
 
typedef struct pce_cdb_divmod_u16_result pce_cdb_divmod_u16_result_t
 
typedef struct pce_cdb_divmod_s16_result pce_cdb_divmod_s16_result_t
 

Enumerations

enum  pce_cdb_error_code {
  PCE_CDB_SUCCESS = 0x00, PCE_CDB_NOT_READY = 0x04, PCE_CDB_NO_DISC = 0x0B, PCD_CDB_DRIVE_OPEN = 0x0D,
  PCE_CDB_READ_ERROR = 0x11, PCE_CDB_SEEK_ERROR = 0x15, PCE_CDB_HEADER_READ_ERROR = 0x16, PCE_CDB_NOT_AUDIO_TRACK = 0x1C,
  PCE_CDB_NOT_DATA_TRACK = 0x1D, PCE_CDB_INVALID_COMMAND = 0x20, PCE_CDB_INVALID_ADDRESS = 0x21, PCE_CDB_INVALID_PARAMETER = 0x22,
  PCE_CDB_END_OF_DISK = 0x25, PCE_CDB_INVALID_PARAMETER_LIST = 0x2A, PCE_CDB_NOT_PLAYING_AUDIO = 0x2C
}
 
enum  pce_cdb_address_type {
  PCE_CDB_ADDRESS_BYTES = 0x00, PCE_CDB_ADDRESS = 0x01, PCE_CDB_BANK_MPR2 = 0x02, PCE_CDB_BANK_MPR3 = 0x03,
  PCE_CDB_BANK_MPR4 = 0x04, PCE_CDB_BANK_MPR5 = 0x05, PCE_CDB_BANK_MPR6 = 0x06, PCE_CDB_VRAM_BYTES = 0xFE,
  PCE_CDB_VRAM = 0xFF
}
 
enum  pcd_cdb_irq_vector {
  PCE_CDB_ID_IRQ_EXTERNAL = 0x00, PCE_CDB_ID_IRQ_VDC = 0x01, PCE_CDB_ID_IRQ_TIMER = 0x02, PCE_CDB_ID_NMI = 0x03,
  PCE_CDB_ID_HBLANK = 0x04, PCE_CDB_ID_VBLANK = 0x05, PCE_CDB_ID_SOFT_RESET = 0x06
}
 
enum  pcd_cdb_irq_vector_mask {
  PCE_CDB_MASK_IRQ_EXTERNAL = 0x01, PCE_CDB_MASK_IRQ_VDC = 0x02, PCE_CDB_MASK_IRQ_TIMER = 0x04, PCE_CDB_MASK_NMI = 0x08,
  PCE_CDB_MASK_HBLANK = 0x10, PCE_CDB_MASK_HBLANK_NO_BIOS = 0x20, PCE_CDB_MASK_VBLANK = 0x40, PCE_CDB_MASK_VBLANK_NO_BIOS = 0x80
}
 
enum  pce_cdb_location_type {
  PCE_CDB_LOCATION_TYPE_SECTOR = 0x00, PCE_CDB_LOCATION_TYPE_TIME = 0x40, PCE_CDB_LOCATION_TYPE_TRACK = 0x80, PCE_CDB_LOCATION_TYPE_CURRENT = 0xC0,
  PCE_CDB_LOCATION_TYPE_UNTIL_END = 0xC0
}
 
enum  pce_cdb_base_set_mode { PCE_CDB_BASE_SET_BOTH = 0, PCE_CDB_BASE_SET_FIRST = 1, PCE_CDB_BASE_SET_SECOND = 2, PCE_CDB_BASE_SET_NONE = 3 }
 
enum  pce_cdb_cdda_play_mode {
  PCE_CDB_CDDA_PLAY_MUTE = 0, PCE_CDB_CDDA_PLAY_REPEAT = 1, PCE_CDB_CDDA_PLAY_ONE_SHOT = 2, PCE_CDB_CDDA_PLAY_NOT_BUSY = 3,
  PCE_CDB_CDDA_PLAY_PREVIOUS = 4
}
 
enum  pce_cdb_cdda_search_mode { PCE_CDB_CDDA_SEARCH_PAUSE_BLOCK = 0, PCE_CDB_CDDA_SEARCH_PAUSE_NONBLOCK = 1, PCE_CDB_CDDA_SEARCH_PLAY_BLOCK = 2, PCE_CDB_CDDA_SEARCH_PLAY_NONBLOCK = 3 }
 
enum  pce_cdb_subcode {
  PCE_CDB_SUBCODE_W = 0x01, PCE_CDB_SUBCODE_V = 0x02, PCE_CDB_SUBCODE_U = 0x04, PCE_CDB_SUBCODE_T = 0x08,
  PCE_CDB_SUBCODE_S = 0x10, PCE_CDB_SUBCODE_R = 0x20, PCE_CDB_SUBCODE_Q = 0x40, PCE_CDB_SUBCODE_P = 0x80
}
 
enum  pce_cdb_fader_mode {
  PCE_CDB_FADER_NONE = 0x00, PCE_CDB_FADER_PCM_6_SEC = 0x08, PCE_CDB_FADER_ADPCM_6_SEC = 0x0A, PCE_CDB_FADER_PCM_2_5_SEC = 0x0C,
  PCE_CDB_FADER_ADPCM_2_5_SEC = 0x0E
}
 
enum  pce_cdb_adpcm_mode { PCE_CDB_ADPCM_ONE_SHOT = 0x00, PCE_CDB_ADPCM_REPEAT = 0x80 }
 
enum  pce_cdb_adpcm_status_flags { ADPCM_BUSY = 0x00FF, ADPCM_STOPPED = 0x0100, ADPCM_BUFFER_UNDER_HALF = 0x0400 }
 
enum  pce_cdb_vdc_vram_dma_flags {
  PCE_CDB_VRAM_DMA_IRQ_SATB_DONE = 0x01, PCE_CDB_VRAM_DMA_IRQ_DONE = 0x02, PCE_CDB_VRAM_DMA_SRC_INC = 0x00, PCE_CDB_VRAM_DMA_SRC_DEC = 0x04,
  PCE_CDB_VRAM_DMA_DEST_INC = 0x00, PCE_CDB_VRAM_DMA_DEST_DEC = 0x08, PCE_CDB_VRAM_DMA_REPEAT_SATB = 0x10
}
 

Functions

bool pce_cdb_vram_in_use (void)
 Check if VRAM is currently in use by a CD BIOS command. More...
 
uint8_t pce_cdb_cd_reset (void)
 Reset the CD drive. More...
 
void pce_cdb_cd_base (pce_sector_t base, uint8_t mode)
 Set the starting sector, used as an offset for future BIOS calls. More...
 
uint8_t pce_cdb_cd_read (pce_sector_t sector, uint8_t address_type, uint16_t address, uint16_t length)
 Read sectors from the CD drive. More...
 
void pce_cdb_cd_seek (pce_sector_t sector)
 Seek the CD drive to the specified sector. More...
 
uint8_t pce_cdb_cdda_play (uint8_t start_type, pce_sector_t start, uint8_t end_type, pce_sector_t end, uint8_t mode)
 Play CD audio. More...
 
uint8_t pce_cdb_cdda_search (pce_sector_t sector, uint8_t mode)
 Search for a CD audio track. More...
 
uint8_t pce_cdb_cdda_pause (void)
 Pause CD audio playback. More...
 
uint8_t pce_cdb_cd_busy (void)
 Check if the CD drive is busy. More...
 
uint8_t pce_cdb_cd_not_ready (void)
 Check if the CD drive is ready. More...
 
uint8_t pce_cdb_cdda_read_subcode_q (pce_cdb_subq_data_t *buffer)
 Read CD audio Subcode Q (timing) data. More...
 
uint8_t pce_cdb_cd_read_toc_track_count (pce_cdb_toc_data_t *buffer)
 
uint8_t pce_cdb_cd_read_toc_lead_out_time (pce_cdb_toc_data_t *buffer)
 
uint8_t pce_cdb_cd_read_toc_track_time (pce_cdb_toc_data_t *buffer, uint8_t track_id)
 
uint8_t pce_cdb_cd_read_toc_track_sector (pce_cdb_toc_data_t *buffer, uint8_t track_id)
 
uint8_t pce_cdb_cd_scan (void)
 Initialize information about the currently inserted CD. More...
 
bool pce_cdb_cd_read_subcode_bits (uint8_t *buffer)
 Read the current CD subcode bits. More...
 
uint16_t pce_cdb_cdda_read_sample (uint8_t channel)
 Read the currently played CD audio sample. More...
 
void pce_cdb_fader (uint8_t mode)
 Configure the CD unit's audio fader. More...
 
void pce_cdb_adpcm_reset (void)
 Reset the ADPCM controller. More...
 
uint8_t pce_cdb_adpcm_read_from_cd (pce_sector_t sector, uint8_t length, uint16_t address)
 Read ADPCM data from CD to the ADPCM buffer. More...
 
uint8_t pce_cdb_adpcm_read_next_cd (pce_sector_t sector, uint8_t length)
 Read ADPCM data from CD to the ADPCM buffer, continuing where the previous pce_cdb_adpcm_read_cd_buffer or read_next_cd_buffer command left off. More...
 
uint8_t pce_cdb_adpcm_write_to_ram (uint16_t source, uint8_t dest_type, uint16_t dest, uint16_t length)
 Copy ADPCM data from the ADPCM buffer to RAM. More...
 
uint8_t pce_cdb_adpcm_read_from_ram (uint8_t source_type, uint16_t source, uint16_t dest, uint16_t length)
 Copy ADPCM data from RAM to the ADPCM buffer. More...
 
uint8_t pce_cdb_adpcm_play (uint16_t address, uint16_t length, uint8_t divider, uint8_t mode)
 Begin ADPCM sample playback from the ADPCM buffer. More...
 
uint8_t pce_cdb_adpcm_continue (uint8_t mode)
 Continue existing ADPCM sample playback. More...
 
uint8_t pce_cdb_adpcm_stream (pce_sector_t sector, pce_sector_t length, uint8_t divider)
 Begin ADPCM sample playback streamed from CD. More...
 
void pce_cdb_adpcm_stop (void)
 Stop ADPCM playback. More...
 
uint16_t pce_cdb_adpcm_status (void)
 Query the ADPCM status. More...
 
uint16_t pce_cdb_version (void)
 Get the CD BIOS version. More...
 
void pce_cdb_irq_set (uint8_t type, void(*irq_handler)(void))
 Set the IRQ handler for a given interrupt. More...
 
void pce_cdb_irq_enable (uint8_t mask)
 Enable the specified IRQs. More...
 
void pce_cdb_irq_disable (uint8_t mask)
 Disable the specified IRQs. More...
 
void pce_cdb_vdc_bg_set_size (uint8_t size)
 Set the BG size to the specified value. More...
 
bool pce_cdb_vdc_set_resolution (uint8_t clock, uint8_t width_tiles, uint8_t height_tiles)
 Set the video resolution. More...
 
void pce_cdb_vdc_set_copy (uint8_t mode)
 Set the automatic increment for VRAM addresses to a given mode. More...
 
void pce_cdb_vdc_set_bg_column_copy (void)
 Set the automatic increment for VRAM addresses to write one word per background column. More...
 
void pce_cdb_vdc_set_bg_row_copy (void)
 Set the automatic increment for VRAM addresses to write one word per background row. More...
 
void pce_cdb_wait_vblank (void)
 Wait for VBlank. More...
 
void pce_cdb_vdc_irq_scanline_enable (void)
 Enable the scanline IRQ. More...
 
void pce_cdb_vdc_irq_scanline_disable (void)
 Disable the scanline IRQ. More...
 
void pce_cdb_vdc_irq_vblank_enable (void)
 Enable the veritcal blank IRQ. More...
 
void pce_cdb_vdc_irq_vblank_disable (void)
 Disable the veritcal blank IRQ. More...
 
void pce_cdb_vdc_bg_enable (void)
 Enable the background layer. More...
 
void pce_cdb_vdc_bg_disable (void)
 Disable the background layer. More...
 
void pce_cdb_vdc_sprite_enable (void)
 Enable the sprite layer. More...
 
void pce_cdb_vdc_sprite_disable (void)
 Disable the sprite layer. More...
 
void pce_cdb_vdc_bg_sprite_enable (void)
 Enable the background and sprite layer. More...
 
void pce_cdb_vdc_bg_sprite_disable (void)
 Disable the background and sprite layer. More...
 
void pce_cdb_vdc_configure_dma (uint8_t value)
 Configure VRAM DMA. More...
 
void pce_cdb_vdc_sprite_table_set_vram_addr (uint16_t address)
 Set the VRAM sprite table location. More...
 
void pce_cdb_vdc_sprite_table_clear (void)
 Clear the VRAM sprite table. More...
 
void pce_cdb_vdc_sprite_table_put (void)
 Put a sprite to the VRAM sprite table. More...
 
void pce_cdb_vdc_irq_scanline_set (uint16_t line)
 Set the scanline #, on which the scanline IRQ should be emitted. More...
 
void pce_cdb_vdc_vram_read_at (uint16_t addr)
 Set the VRAM read address. More...
 
void pce_cdb_vdc_vram_write_at (uint16_t addr)
 Set the VRAM write address. More...
 
uint8_t pce_cdb_bin_to_bcd (uint8_t value)
 Convert a binary number to a BCD number. More...
 
uint8_t pce_cdb_bcd_to_bin (uint8_t value)
 Convert a BCD number to a binary number. More...
 
uint16_t pce_cdb_mul_u8 (uint8_t a, uint8_t b)
 Perform an 8x8->16 unsigned multiplication. More...
 
int16_t pce_cdb_mul_s8 (int8_t a, int8_t b)
 Perform an 8x8->16 signed multiplication. More...
 
uint32_t pce_cdb_mul_u16 (uint16_t a, uint16_t b)
 Perform a 16x16->32 unsigned multiplication. More...
 
pce_cdb_divmod_u16_result_t pce_cdb_divmod_u16 (uint16_t a, uint16_t b)
 Perform a 16/16 unsigned division/modulo. More...
 
pce_cdb_divmod_s16_result_t pce_cdb_divmod_s16 (int16_t a, int16_t b)
 Perform a 16/16 signed division/modulo. More...
 
uint8_t pce_cdb_sqrt (uint16_t a)
 Calculate the square root of a given value. More...
 
bool pce_cdb_ram_query (uint8_t *bank_start, uint8_t *bank_size)
 Query for the presence of additional RAM. More...
 
void pce_cdb_colors_bg_none (void)
 Clear the background palette RAM buffer. More...
 
void pce_cdb_colors_bg_at (void *address, uint8_t count)
 Set the location of the background palette RAM buffer. More...
 
void pce_cdb_colors_sprite_none (void)
 Clear the sprite palette RAM buffer. More...
 
void pce_cdb_colors_sprite_at (void *address, uint8_t count)
 Set the location of the sprite palette RAM buffer. More...
 
bool pce_cdb_colors_read (void)
 Queue a color transfer from the VCE to the RAM buffers. More...
 
bool pce_cdb_colors_set (void)
 Queue a color transfer from the RAM buffers to the VCE. More...
 

Variables

uint8_t address_type
 
uint8_t uint16_t address
 
uint8_t uint16_t uint16_t length
 

Detailed Description

Functionality related to the CD BIOS.

Macro Definition Documentation

◆ PCE_CDB_SPR_ATTR

#define PCE_CDB_SPR_ATTR   ((volatile uint16_t *)0x221D)

◆ PCE_CDB_SPR_ATTR_HI

#define PCE_CDB_SPR_ATTR_HI   ((volatile uint8_t *)0x221E)

◆ PCE_CDB_SPR_ATTR_LO

#define PCE_CDB_SPR_ATTR_LO   ((volatile uint8_t *)0x221D)

◆ PCE_CDB_SPR_INDEX

#define PCE_CDB_SPR_INDEX   ((volatile uint8_t *)0x2216)

◆ PCE_CDB_SPR_PATTERN

#define PCE_CDB_SPR_PATTERN   ((volatile uint16_t *)0x221B)

◆ PCE_CDB_SPR_PATTERN_HI

#define PCE_CDB_SPR_PATTERN_HI   ((volatile uint8_t *)0x221C)

◆ PCE_CDB_SPR_PATTERN_LO

#define PCE_CDB_SPR_PATTERN_LO   ((volatile uint8_t *)0x221B)

◆ PCE_CDB_SPR_X

#define PCE_CDB_SPR_X   ((volatile uint16_t *)0x2219)

◆ PCE_CDB_SPR_X_HI

#define PCE_CDB_SPR_X_HI   ((volatile uint8_t *)0x221A)

◆ PCE_CDB_SPR_X_LO

#define PCE_CDB_SPR_X_LO   ((volatile uint8_t *)0x2219)

◆ PCE_CDB_SPR_Y

#define PCE_CDB_SPR_Y   ((volatile uint16_t *)0x2217)

◆ PCE_CDB_SPR_Y_HI

#define PCE_CDB_SPR_Y_HI   ((volatile uint8_t *)0x2218)

◆ PCE_CDB_SPR_Y_LO

#define PCE_CDB_SPR_Y_LO   ((volatile uint8_t *)0x2217)

◆ PCE_CDB_SPRITE

#define PCE_CDB_SPRITE   ((volatile vdc_sprite_t *)0x2217)

◆ PCE_CDB_SUBQ_PRE_EMPHASIS

#define PCE_CDB_SUBQ_PRE_EMPHASIS   0x1

◆ PCE_CDB_SUBQ_SCMS

#define PCE_CDB_SUBQ_SCMS   0x2

◆ PCE_CDB_SUBQ_TYPE_2CH

#define PCE_CDB_SUBQ_TYPE_2CH   0x0

◆ PCE_CDB_SUBQ_TYPE_4CH

#define PCE_CDB_SUBQ_TYPE_4CH   0x4

◆ PCE_CDB_SUBQ_TYPE_DATA

#define PCE_CDB_SUBQ_TYPE_DATA   0x8

◆ PCE_CDB_SUBQ_TYPE_MASK

#define PCE_CDB_SUBQ_TYPE_MASK   0xC

◆ PCE_CDB_VDC_BG_HEIGHT_32

#define PCE_CDB_VDC_BG_HEIGHT_32   (0 << 2)

◆ PCE_CDB_VDC_BG_HEIGHT_64

#define PCE_CDB_VDC_BG_HEIGHT_64   (1 << 2)

◆ PCE_CDB_VDC_BG_SIZE_128_32

#define PCE_CDB_VDC_BG_SIZE_128_32   (PCE_CDB_VDC_BG_WIDTH_128 | PCE_CDB_VDC_BG_HEIGHT_32)

◆ PCE_CDB_VDC_BG_SIZE_128_64

#define PCE_CDB_VDC_BG_SIZE_128_64   (PCE_CDB_VDC_BG_WIDTH_128 | PCE_CDB_VDC_BG_HEIGHT_64)

◆ PCE_CDB_VDC_BG_SIZE_32_32

#define PCE_CDB_VDC_BG_SIZE_32_32   (PCE_CDB_VDC_BG_WIDTH_32 | PCE_CDB_VDC_BG_HEIGHT_32)

◆ PCE_CDB_VDC_BG_SIZE_32_64

#define PCE_CDB_VDC_BG_SIZE_32_64   (PCE_CDB_VDC_BG_WIDTH_32 | PCE_CDB_VDC_BG_HEIGHT_64)

◆ PCE_CDB_VDC_BG_SIZE_64_32

#define PCE_CDB_VDC_BG_SIZE_64_32   (PCE_CDB_VDC_BG_WIDTH_64 | PCE_CDB_VDC_BG_HEIGHT_32)

◆ PCE_CDB_VDC_BG_SIZE_64_64

#define PCE_CDB_VDC_BG_SIZE_64_64   (PCE_CDB_VDC_BG_WIDTH_64 | PCE_CDB_VDC_BG_HEIGHT_64)

◆ PCE_CDB_VDC_BG_WIDTH_128

#define PCE_CDB_VDC_BG_WIDTH_128   (2)

◆ PCE_CDB_VDC_BG_WIDTH_32

#define PCE_CDB_VDC_BG_WIDTH_32   (0)

◆ PCE_CDB_VDC_BG_WIDTH_64

#define PCE_CDB_VDC_BG_WIDTH_64   (1)

◆ PCE_CDB_VDC_CLOCK_5MHZ

#define PCE_CDB_VDC_CLOCK_5MHZ   0

◆ PCE_CDB_VDC_CLOCK_7MHZ

#define PCE_CDB_VDC_CLOCK_7MHZ   1

◆ PCE_CDB_VDC_COPY_1

#define PCE_CDB_VDC_COPY_1   0

◆ PCE_CDB_VDC_COPY_128

#define PCE_CDB_VDC_COPY_128   3

◆ PCE_CDB_VDC_COPY_32

#define PCE_CDB_VDC_COPY_32   1

◆ PCE_CDB_VDC_COPY_64

#define PCE_CDB_VDC_COPY_64   2

Typedef Documentation

◆ pce_cdb_divmod_s16_result_t

◆ pce_cdb_divmod_u16_result_t

◆ pce_cdb_subq_data_t

◆ pce_cdb_toc_data_t

Enumeration Type Documentation

◆ pcd_cdb_irq_vector

Enumerator
PCE_CDB_ID_IRQ_EXTERNAL 
PCE_CDB_ID_IRQ_VDC 
PCE_CDB_ID_IRQ_TIMER 
PCE_CDB_ID_NMI 
PCE_CDB_ID_HBLANK 
PCE_CDB_ID_VBLANK 
PCE_CDB_ID_SOFT_RESET 

◆ pcd_cdb_irq_vector_mask

Enumerator
PCE_CDB_MASK_IRQ_EXTERNAL 
PCE_CDB_MASK_IRQ_VDC 
PCE_CDB_MASK_IRQ_TIMER 
PCE_CDB_MASK_NMI 
PCE_CDB_MASK_HBLANK 
PCE_CDB_MASK_HBLANK_NO_BIOS 
PCE_CDB_MASK_VBLANK 
PCE_CDB_MASK_VBLANK_NO_BIOS 

◆ pce_cdb_address_type

Enumerator
PCE_CDB_ADDRESS_BYTES 

An address in the local address space (length specified in bytes).

PCE_CDB_ADDRESS 

An address in the local address space.

PCE_CDB_BANK_MPR2 

Bank number (uses MPR2).

PCE_CDB_BANK_MPR3 

Bank number (uses MPR3).

PCE_CDB_BANK_MPR4 

Bank number (uses MPR4).

PCE_CDB_BANK_MPR5 

Bank number (uses MPR5).

PCE_CDB_BANK_MPR6 

Bank number (uses MPR6).

PCE_CDB_VRAM_BYTES 

VRAM address (length specified in bytes).

PCE_CDB_VRAM 

VRAM address.

◆ pce_cdb_adpcm_mode

Enumerator
PCE_CDB_ADPCM_ONE_SHOT 

Play ADPCM sample once.

PCE_CDB_ADPCM_REPEAT 

Loop ADPCM sample.

◆ pce_cdb_adpcm_status_flags

Enumerator
ADPCM_BUSY 

If any of these bits are set, the ADPCM controller is busy.

ADPCM_STOPPED 

The ADPCM controller is not playing audio.

ADPCM_BUFFER_UNDER_HALF 

The ADPCM controller has under 50% of the buffer.

◆ pce_cdb_base_set_mode

Enumerator
PCE_CDB_BASE_SET_BOTH 
PCE_CDB_BASE_SET_FIRST 
PCE_CDB_BASE_SET_SECOND 
PCE_CDB_BASE_SET_NONE 

◆ pce_cdb_cdda_play_mode

Enumerator
PCE_CDB_CDDA_PLAY_MUTE 
PCE_CDB_CDDA_PLAY_REPEAT 
PCE_CDB_CDDA_PLAY_ONE_SHOT 
PCE_CDB_CDDA_PLAY_NOT_BUSY 
PCE_CDB_CDDA_PLAY_PREVIOUS 

◆ pce_cdb_cdda_search_mode

Enumerator
PCE_CDB_CDDA_SEARCH_PAUSE_BLOCK 
PCE_CDB_CDDA_SEARCH_PAUSE_NONBLOCK 
PCE_CDB_CDDA_SEARCH_PLAY_BLOCK 
PCE_CDB_CDDA_SEARCH_PLAY_NONBLOCK 

◆ pce_cdb_error_code

Enumerator
PCE_CDB_SUCCESS 
PCE_CDB_NOT_READY 
PCE_CDB_NO_DISC 
PCD_CDB_DRIVE_OPEN 
PCE_CDB_READ_ERROR 
PCE_CDB_SEEK_ERROR 
PCE_CDB_HEADER_READ_ERROR 
PCE_CDB_NOT_AUDIO_TRACK 
PCE_CDB_NOT_DATA_TRACK 
PCE_CDB_INVALID_COMMAND 
PCE_CDB_INVALID_ADDRESS 
PCE_CDB_INVALID_PARAMETER 
PCE_CDB_END_OF_DISK 
PCE_CDB_INVALID_PARAMETER_LIST 
PCE_CDB_NOT_PLAYING_AUDIO 

◆ pce_cdb_fader_mode

Enumerator
PCE_CDB_FADER_NONE 
PCE_CDB_FADER_PCM_6_SEC 
PCE_CDB_FADER_ADPCM_6_SEC 
PCE_CDB_FADER_PCM_2_5_SEC 
PCE_CDB_FADER_ADPCM_2_5_SEC 

◆ pce_cdb_location_type

Enumerator
PCE_CDB_LOCATION_TYPE_SECTOR 
PCE_CDB_LOCATION_TYPE_TIME 
PCE_CDB_LOCATION_TYPE_TRACK 
PCE_CDB_LOCATION_TYPE_CURRENT 
PCE_CDB_LOCATION_TYPE_UNTIL_END 

◆ pce_cdb_subcode

Enumerator
PCE_CDB_SUBCODE_W 
PCE_CDB_SUBCODE_V 
PCE_CDB_SUBCODE_U 
PCE_CDB_SUBCODE_T 
PCE_CDB_SUBCODE_S 
PCE_CDB_SUBCODE_R 
PCE_CDB_SUBCODE_Q 
PCE_CDB_SUBCODE_P 

◆ pce_cdb_vdc_vram_dma_flags

Enumerator
PCE_CDB_VRAM_DMA_IRQ_SATB_DONE 
PCE_CDB_VRAM_DMA_IRQ_DONE 
PCE_CDB_VRAM_DMA_SRC_INC 
PCE_CDB_VRAM_DMA_SRC_DEC 
PCE_CDB_VRAM_DMA_DEST_INC 
PCE_CDB_VRAM_DMA_DEST_DEC 
PCE_CDB_VRAM_DMA_REPEAT_SATB 

Function Documentation

◆ pce_cdb_adpcm_continue()

uint8_t pce_cdb_adpcm_continue ( uint8_t  mode)

Continue existing ADPCM sample playback.

Parameters
modepce_cdb_adpcm_mode
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_adpcm_play()

uint8_t pce_cdb_adpcm_play ( uint16_t  address,
uint16_t  length,
uint8_t  divider,
uint8_t  mode 
)

Begin ADPCM sample playback from the ADPCM buffer.

Parameters
addressThe starting address in the ADPCM buffer to play from.
lengthThe length, in bytes, to play.
dividerThe divider value - PCD_ADPCM_DIVIDER_HZ
modepce_cdb_adpcm_mode
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_adpcm_read_from_cd()

uint8_t pce_cdb_adpcm_read_from_cd ( pce_sector_t  sector,
uint8_t  length,
uint16_t  address 
)

Read ADPCM data from CD to the ADPCM buffer.

Parameters
sectorThe starting sector to read from.
lengthThe length, in sectors, to read.
addressThe target ADPCM buffer address.
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_adpcm_read_from_ram()

uint8_t pce_cdb_adpcm_read_from_ram ( uint8_t  source_type,
uint16_t  source,
uint16_t  dest,
uint16_t  length 
)

Copy ADPCM data from RAM to the ADPCM buffer.

Parameters
source_typepce_cdb_address_type (only byte/bank variants).
sourceSource address.
destDestination address (ADPCM buffer).
lengthLength, in bytes.
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_adpcm_read_next_cd()

uint8_t pce_cdb_adpcm_read_next_cd ( pce_sector_t  sector,
uint8_t  length 
)

Read ADPCM data from CD to the ADPCM buffer, continuing where the previous pce_cdb_adpcm_read_cd_buffer or read_next_cd_buffer command left off.

Parameters
sectorThe starting sector to read from.
lengthThe length, in sectors, to read.
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_adpcm_reset()

void pce_cdb_adpcm_reset ( void  )

Reset the ADPCM controller.

◆ pce_cdb_adpcm_status()

uint16_t pce_cdb_adpcm_status ( void  )

Query the ADPCM status.

Returns
uint16_t pce_cdb_adpcm_status_flags

◆ pce_cdb_adpcm_stop()

void pce_cdb_adpcm_stop ( void  )

Stop ADPCM playback.

◆ pce_cdb_adpcm_stream()

uint8_t pce_cdb_adpcm_stream ( pce_sector_t  sector,
pce_sector_t  length,
uint8_t  divider 
)

Begin ADPCM sample playback streamed from CD.

Parameters
sectorThe starting sector to read from.
lengthThe length, in sectors, to play.
dividerThe divider value - PCD_ADPCM_DIVIDER_HZ
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_adpcm_write_to_ram()

uint8_t pce_cdb_adpcm_write_to_ram ( uint16_t  source,
uint8_t  dest_type,
uint16_t  dest,
uint16_t  length 
)

Copy ADPCM data from the ADPCM buffer to RAM.

Parameters
sourceSource address (ADPCM buffer).
dest_typepce_cdb_address_type (only byte/bank variants).
destDestination address.
lengthLength, in bytes.
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_bcd_to_bin()

uint8_t pce_cdb_bcd_to_bin ( uint8_t  value)

Convert a BCD number to a binary number.

Parameters
valueBCD number (0x00-0x99)
Returns
Binary value, or 0xFF if the value was out of range.

◆ pce_cdb_bin_to_bcd()

uint8_t pce_cdb_bin_to_bcd ( uint8_t  value)

Convert a binary number to a BCD number.

Parameters
valueBinary number (0x00-0x63)
Returns
BCD value, or 0xFF if the value was out of range.

◆ pce_cdb_cd_base()

void pce_cdb_cd_base ( pce_sector_t  base,
uint8_t  mode 
)

Set the starting sector, used as an offset for future BIOS calls.

The CD BIOS supports two sets of starting sectors, which can be used in case one of the CD's areas becomes too damaged to read.

Parameters
baseThe base sector.
modeThe operation mode; pce_cdb_location_type , pce_cdb_base_set_mode

◆ pce_cdb_cd_busy()

uint8_t pce_cdb_cd_busy ( void  )

Check if the CD drive is busy.

Returns
uint8_t Zero if not busy, non-zero otherwise.

◆ pce_cdb_cd_not_ready()

uint8_t pce_cdb_cd_not_ready ( void  )

Check if the CD drive is ready.

Returns
uint8_t Zero if ready, non-zero otherwise.

◆ pce_cdb_cd_read()

uint8_t pce_cdb_cd_read ( pce_sector_t  sector,
uint8_t  address_type,
uint16_t  address,
uint16_t  length 
)

Read sectors from the CD drive.

Parameters
sectorThe starting sector to read from.
address_typepce_cdb_address_type
addressThe address to write to.
lengthThe data length, in sectors unless otherwise specified by the address type.
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_cd_read_subcode_bits()

bool pce_cdb_cd_read_subcode_bits ( uint8_t *  buffer)

Read the current CD subcode bits.

Parameters
bufferpce_cdb_subcode
Returns
True if the read was successful.

◆ pce_cdb_cd_read_toc_lead_out_time()

uint8_t pce_cdb_cd_read_toc_lead_out_time ( pce_cdb_toc_data_t buffer)

◆ pce_cdb_cd_read_toc_track_count()

uint8_t pce_cdb_cd_read_toc_track_count ( pce_cdb_toc_data_t buffer)

◆ pce_cdb_cd_read_toc_track_sector()

uint8_t pce_cdb_cd_read_toc_track_sector ( pce_cdb_toc_data_t buffer,
uint8_t  track_id 
)

◆ pce_cdb_cd_read_toc_track_time()

uint8_t pce_cdb_cd_read_toc_track_time ( pce_cdb_toc_data_t buffer,
uint8_t  track_id 
)

◆ pce_cdb_cd_reset()

uint8_t pce_cdb_cd_reset ( void  )

Reset the CD drive.

Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_cd_scan()

uint8_t pce_cdb_cd_scan ( void  )

Initialize information about the currently inserted CD.

Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_cd_seek()

void pce_cdb_cd_seek ( pce_sector_t  sector)

Seek the CD drive to the specified sector.

Parameters
sectorThe sector to seek to.

◆ pce_cdb_cdda_pause()

uint8_t pce_cdb_cdda_pause ( void  )

Pause CD audio playback.

Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_cdda_play()

uint8_t pce_cdb_cdda_play ( uint8_t  start_type,
pce_sector_t  start,
uint8_t  end_type,
pce_sector_t  end,
uint8_t  mode 
)

Play CD audio.

Parameters
start_typepce_cdb_location_type
startStarting location.
end_typepce_cdb_location_type
endEnding location.
modepce_cdb_cdda_play_mode
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_cdda_read_sample()

uint16_t pce_cdb_cdda_read_sample ( uint8_t  channel)

Read the currently played CD audio sample.

Parameters
channel0 for right channel, 1 for left channel.
Returns
uint16_t The sample read.

◆ pce_cdb_cdda_read_subcode_q()

uint8_t pce_cdb_cdda_read_subcode_q ( pce_cdb_subq_data_t buffer)

Read CD audio Subcode Q (timing) data.

Parameters
bufferThe data buffer to store the result in.
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_cdda_search()

uint8_t pce_cdb_cdda_search ( pce_sector_t  sector,
uint8_t  mode 
)

Search for a CD audio track.

Parameters
sectorThe location to find.
modeThe operation mode; pce_cdb_location_type , pce_cdb_cdda_search_mode
Returns
uint8_t pce_cdb_error_code

◆ pce_cdb_colors_bg_at()

void pce_cdb_colors_bg_at ( void *  address,
uint8_t  count 
)

Set the location of the background palette RAM buffer.

Parameters
addressRAM buffer address.
countPalette count.

◆ pce_cdb_colors_bg_none()

void pce_cdb_colors_bg_none ( void  )

Clear the background palette RAM buffer.

◆ pce_cdb_colors_read()

bool pce_cdb_colors_read ( void  )

Queue a color transfer from the VCE to the RAM buffers.

Configure the RAM buffers and size using the remaining pce_cdb_colors methods.

Returns
true Color transfer successfully queued.
false Ongoing color transfer; wait for the next VBlank, then try again.

◆ pce_cdb_colors_set()

bool pce_cdb_colors_set ( void  )

Queue a color transfer from the RAM buffers to the VCE.

Configure the RAM buffers and size using the remaining pce_cdb_colors methods.

Returns
true Color transfer successfully queued.
false Ongoing color transfer; wait for the next VBlank, then try again.

◆ pce_cdb_colors_sprite_at()

void pce_cdb_colors_sprite_at ( void *  address,
uint8_t  count 
)

Set the location of the sprite palette RAM buffer.

Parameters
addressRAM buffer address.
countPalette count.

◆ pce_cdb_colors_sprite_none()

void pce_cdb_colors_sprite_none ( void  )

Clear the sprite palette RAM buffer.

◆ pce_cdb_divmod_s16()

pce_cdb_divmod_s16_result_t pce_cdb_divmod_s16 ( int16_t  a,
int16_t  b 
)

Perform a 16/16 signed division/modulo.

◆ pce_cdb_divmod_u16()

pce_cdb_divmod_u16_result_t pce_cdb_divmod_u16 ( uint16_t  a,
uint16_t  b 
)

Perform a 16/16 unsigned division/modulo.

◆ pce_cdb_fader()

void pce_cdb_fader ( uint8_t  mode)

Configure the CD unit's audio fader.

Parameters
modepce_cdb_fader_mode

◆ pce_cdb_irq_disable()

void pce_cdb_irq_disable ( uint8_t  mask)

Disable the specified IRQs.

Parameters
maskpce_cdb_irq_vector_mask

◆ pce_cdb_irq_enable()

void pce_cdb_irq_enable ( uint8_t  mask)

Enable the specified IRQs.

Parameters
maskpce_cdb_irq_vector_mask

◆ pce_cdb_irq_set()

void pce_cdb_irq_set ( uint8_t  type,
void(*)(void)  irq_handler 
)

Set the IRQ handler for a given interrupt.

Parameters
typepce_cdb_irq_vector
irq_handlerThe function to call for the given IRQ.

◆ pce_cdb_mul_s8()

int16_t pce_cdb_mul_s8 ( int8_t  a,
int8_t  b 
)

Perform an 8x8->16 signed multiplication.

◆ pce_cdb_mul_u16()

uint32_t pce_cdb_mul_u16 ( uint16_t  a,
uint16_t  b 
)

Perform a 16x16->32 unsigned multiplication.

◆ pce_cdb_mul_u8()

uint16_t pce_cdb_mul_u8 ( uint8_t  a,
uint8_t  b 
)

Perform an 8x8->16 unsigned multiplication.

◆ pce_cdb_ram_query()

bool pce_cdb_ram_query ( uint8_t *  bank_start,
uint8_t *  bank_size 
)

Query for the presence of additional RAM.

Since
CD BIOS 3.00
Parameters
bank_startThe starting bank index for additional RAM.
bank_size
  • bits 0-6: The amount of additional RAM, in 64K units.
Returns
true Additional RAM is present.
false Additional RAM is not present.

◆ pce_cdb_sqrt()

uint8_t pce_cdb_sqrt ( uint16_t  a)

Calculate the square root of a given value.

◆ pce_cdb_vdc_bg_disable()

void pce_cdb_vdc_bg_disable ( void  )

Disable the background layer.

◆ pce_cdb_vdc_bg_enable()

void pce_cdb_vdc_bg_enable ( void  )

Enable the background layer.

◆ pce_cdb_vdc_bg_set_size()

void pce_cdb_vdc_bg_set_size ( uint8_t  size)

Set the BG size to the specified value.

Parameters
sizeBG size.

◆ pce_cdb_vdc_bg_sprite_disable()

void pce_cdb_vdc_bg_sprite_disable ( void  )

Disable the background and sprite layer.

◆ pce_cdb_vdc_bg_sprite_enable()

void pce_cdb_vdc_bg_sprite_enable ( void  )

Enable the background and sprite layer.

◆ pce_cdb_vdc_configure_dma()

void pce_cdb_vdc_configure_dma ( uint8_t  value)

Configure VRAM DMA.

Parameters
valueVRAM DMA flags. pce_cdb_vdc_vram_dma_flags

◆ pce_cdb_vdc_irq_scanline_disable()

void pce_cdb_vdc_irq_scanline_disable ( void  )

Disable the scanline IRQ.

◆ pce_cdb_vdc_irq_scanline_enable()

void pce_cdb_vdc_irq_scanline_enable ( void  )

Enable the scanline IRQ.

◆ pce_cdb_vdc_irq_scanline_set()

void pce_cdb_vdc_irq_scanline_set ( uint16_t  line)

Set the scanline #, on which the scanline IRQ should be emitted.

Parameters
lineScanline #.

◆ pce_cdb_vdc_irq_vblank_disable()

void pce_cdb_vdc_irq_vblank_disable ( void  )

Disable the veritcal blank IRQ.

◆ pce_cdb_vdc_irq_vblank_enable()

void pce_cdb_vdc_irq_vblank_enable ( void  )

Enable the veritcal blank IRQ.

◆ pce_cdb_vdc_set_bg_column_copy()

void pce_cdb_vdc_set_bg_column_copy ( void  )

Set the automatic increment for VRAM addresses to write one word per background column.

◆ pce_cdb_vdc_set_bg_row_copy()

void pce_cdb_vdc_set_bg_row_copy ( void  )

Set the automatic increment for VRAM addresses to write one word per background row.

◆ pce_cdb_vdc_set_copy()

void pce_cdb_vdc_set_copy ( uint8_t  mode)

Set the automatic increment for VRAM addresses to a given mode.

Parameters
modeThe copying mode to set.

◆ pce_cdb_vdc_set_resolution()

bool pce_cdb_vdc_set_resolution ( uint8_t  clock,
uint8_t  width_tiles,
uint8_t  height_tiles 
)

Set the video resolution.

Parameters
clock0 for 5MHz, 1 for 7MHz
width_tilesWidth, in tiles.
height_tilesHeight, in tiles.
Returns
true Video resolution change successful.
false Video resolution change error.

◆ pce_cdb_vdc_sprite_disable()

void pce_cdb_vdc_sprite_disable ( void  )

Disable the sprite layer.

◆ pce_cdb_vdc_sprite_enable()

void pce_cdb_vdc_sprite_enable ( void  )

Enable the sprite layer.

◆ pce_cdb_vdc_sprite_table_clear()

void pce_cdb_vdc_sprite_table_clear ( void  )

Clear the VRAM sprite table.

◆ pce_cdb_vdc_sprite_table_put()

void pce_cdb_vdc_sprite_table_put ( void  )

Put a sprite to the VRAM sprite table.

◆ pce_cdb_vdc_sprite_table_set_vram_addr()

void pce_cdb_vdc_sprite_table_set_vram_addr ( uint16_t  address)

Set the VRAM sprite table location.

Parameters
addressSprite table location, in VRAM.

◆ pce_cdb_vdc_vram_read_at()

void pce_cdb_vdc_vram_read_at ( uint16_t  addr)

Set the VRAM read address.

Parameters
addrAddress in VRAM.

◆ pce_cdb_vdc_vram_write_at()

void pce_cdb_vdc_vram_write_at ( uint16_t  addr)

Set the VRAM write address.

Parameters
addrAddress in VRAM.

◆ pce_cdb_version()

uint16_t pce_cdb_version ( void  )

Get the CD BIOS version.

Returns
uint16_t BIOS version; high eight bits for major, low eight bits for minor.

◆ pce_cdb_vram_in_use()

bool pce_cdb_vram_in_use ( void  )

Check if VRAM is currently in use by a CD BIOS command.

◆ pce_cdb_wait_vblank()

void pce_cdb_wait_vblank ( void  )

Wait for VBlank.

Variable Documentation

◆ address

uint8_t uint16_t address

◆ address_type

uint8_t address_type

◆ length

uint8_t uint16_t uint16_t length