Go to the documentation of this file.
9 #ifndef _PCE_CD_BIOS_H_
10 #define _PCE_CD_BIOS_H_
111 __attribute__((noreturn))
void pce_cdb_start(
void);
178 __attribute__((noreturn))
void pce_cdb_cd_exec(
pce_sector_t sector,
244 #define PCE_CDB_SUBQ_TYPE_2CH 0x0
245 #define PCE_CDB_SUBQ_TYPE_4CH 0x4
246 #define PCE_CDB_SUBQ_TYPE_DATA 0x8
247 #define PCE_CDB_SUBQ_TYPE_MASK 0xC
248 #define PCE_CDB_SUBQ_SCMS 0x2
249 #define PCE_CDB_SUBQ_PRE_EMPHASIS 0x1
497 #define PCE_CDB_VDC_BG_WIDTH_32 (0)
498 #define PCE_CDB_VDC_BG_WIDTH_64 (1)
499 #define PCE_CDB_VDC_BG_WIDTH_128 (2)
500 #define PCE_CDB_VDC_BG_HEIGHT_32 (0 << 2)
501 #define PCE_CDB_VDC_BG_HEIGHT_64 (1 << 2)
502 #define PCE_CDB_VDC_BG_SIZE_32_32 \
503 (PCE_CDB_VDC_BG_WIDTH_32 | PCE_CDB_VDC_BG_HEIGHT_32)
504 #define PCE_CDB_VDC_BG_SIZE_64_32 \
505 (PCE_CDB_VDC_BG_WIDTH_64 | PCE_CDB_VDC_BG_HEIGHT_32)
506 #define PCE_CDB_VDC_BG_SIZE_128_32 \
507 (PCE_CDB_VDC_BG_WIDTH_128 | PCE_CDB_VDC_BG_HEIGHT_32)
508 #define PCE_CDB_VDC_BG_SIZE_32_64 \
509 (PCE_CDB_VDC_BG_WIDTH_32 | PCE_CDB_VDC_BG_HEIGHT_64)
510 #define PCE_CDB_VDC_BG_SIZE_64_64 \
511 (PCE_CDB_VDC_BG_WIDTH_64 | PCE_CDB_VDC_BG_HEIGHT_64)
512 #define PCE_CDB_VDC_BG_SIZE_128_64 \
513 (PCE_CDB_VDC_BG_WIDTH_128 | PCE_CDB_VDC_BG_HEIGHT_64)
522 #define PCE_CDB_VDC_CLOCK_5MHZ 0
523 #define PCE_CDB_VDC_CLOCK_7MHZ 1
537 #define PCE_CDB_VDC_COPY_1 0
538 #define PCE_CDB_VDC_COPY_32 1
539 #define PCE_CDB_VDC_COPY_64 2
540 #define PCE_CDB_VDC_COPY_128 3
616 #define PCE_CDB_SPR_INDEX ((volatile uint8_t *)0x2216)
617 #define PCE_CDB_SPRITE ((volatile vdc_sprite_t *)0x2217)
618 #define PCE_CDB_SPR_Y ((volatile uint16_t *)0x2217)
619 #define PCE_CDB_SPR_Y_LO ((volatile uint8_t *)0x2217)
620 #define PCE_CDB_SPR_Y_HI ((volatile uint8_t *)0x2218)
621 #define PCE_CDB_SPR_X ((volatile uint16_t *)0x2219)
622 #define PCE_CDB_SPR_X_LO ((volatile uint8_t *)0x2219)
623 #define PCE_CDB_SPR_X_HI ((volatile uint8_t *)0x221A)
624 #define PCE_CDB_SPR_PATTERN ((volatile uint16_t *)0x221B)
625 #define PCE_CDB_SPR_PATTERN_LO ((volatile uint8_t *)0x221B)
626 #define PCE_CDB_SPR_PATTERN_HI ((volatile uint8_t *)0x221C)
627 #define PCE_CDB_SPR_ATTR ((volatile uint16_t *)0x221D)
628 #define PCE_CDB_SPR_ATTR_LO ((volatile uint8_t *)0x221D)
629 #define PCE_CDB_SPR_ATTR_HI ((volatile uint8_t *)0x221E)
uint8_t end
Definition: cpm.h:194
struct pce_cdb_subq_data pce_cdb_subq_data_t
struct pce_cdb_divmod_u16_result pce_cdb_divmod_u16_result_t
@ PCE_CDB_MASK_IRQ_VDC
Definition: bios.h:94
@ PCE_CDB_NOT_AUDIO_TRACK
Definition: bios.h:33
@ PCE_CDB_LOCATION_TYPE_TRACK
Definition: bios.h:123
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_buff...
bool pce_cdb_vram_in_use(void)
Check if VRAM is currently in use by a CD BIOS command.
@ PCE_CDB_SUCCESS
Definition: bios.h:26
pce_cdb_divmod_s16_result_t pce_cdb_divmod_s16(int16_t a, int16_t b)
Perform a 16/16 signed division/modulo.
void pce_cdb_vdc_sprite_table_set_vram_addr(uint16_t address)
Set the VRAM sprite table location.
::uint16_t uint16_t
Definition: cstdint:22
pce_cdb_adpcm_status_flags
Definition: bios.h:445
pcd_cdb_irq_vector
Definition: bios.h:82
pce_sector_t track_time
Definition: bios.h:256
uint8_t pce_cdb_bin_to_bcd(uint8_t value)
Convert a binary number to a BCD number.
@ PCE_CDB_SUBCODE_T
Definition: bios.h:302
int16_t quot
Definition: bios.h:708
uint8_t control
Definition: bios.h:253
@ PCE_CDB_MASK_IRQ_EXTERNAL
Definition: bios.h:93
struct pce_cdb_divmod_s16_result pce_cdb_divmod_s16_result_t
@ PCE_CDB_ID_HBLANK
Definition: bios.h:87
uint8_t index
Definition: bios.h:255
uint8_t second
Definition: bios.h:275
uint8_t pce_cdb_cd_read_toc_lead_out_time(pce_cdb_toc_data_t *buffer)
@ PCE_CDB_ADDRESS_BYTES
An address in the local address space (length specified in bytes).
Definition: bios.h:47
pce_cdb_divmod_u16_result_t pce_cdb_divmod_u16(uint16_t a, uint16_t b)
Perform a 16/16 unsigned division/modulo.
void pce_cdb_vdc_set_copy(uint8_t mode)
Set the automatic increment for VRAM addresses to a given mode.
uint8_t pce_cdb_cd_not_ready(void)
Check if the CD drive is ready.
uint8_t hi
Definition: bios.h:278
@ PCE_CDB_CDDA_SEARCH_PLAY_BLOCK
Definition: bios.h:208
@ PCE_CDB_INVALID_PARAMETER
Definition: bios.h:37
@ PCE_CDB_ID_IRQ_EXTERNAL
Definition: bios.h:83
@ PCE_CDB_NOT_READY
Definition: bios.h:27
void pce_cdb_colors_bg_none(void)
Clear the background palette RAM buffer.
uint8_t minute
Definition: bios.h:275
@ PCE_CDB_VRAM_DMA_REPEAT_SATB
Definition: bios.h:638
uint32_t pce_cdb_mul_u16(uint16_t a, uint16_t b)
Perform a 16x16->32 unsigned multiplication.
@ PCE_CDB_MASK_HBLANK_NO_BIOS
Definition: bios.h:98
@ PCE_CDB_LOCATION_TYPE_TIME
Definition: bios.h:122
@ PCE_CDB_MASK_HBLANK
Definition: bios.h:97
uint8_t track
Definition: bios.h:272
@ PCE_CDB_VRAM_DMA_SRC_INC
Definition: bios.h:634
uint8_t pce_cdb_cd_read_toc_track_time(pce_cdb_toc_data_t *buffer, uint8_t track_id)
uint8_t pce_cdb_cdda_read_subcode_q(pce_cdb_subq_data_t *buffer)
Read CD audio Subcode Q (timing) data.
uint8_t pce_cdb_cd_read_toc_track_count(pce_cdb_toc_data_t *buffer)
@ PCE_CDB_ID_VBLANK
Definition: bios.h:88
@ PCE_CDB_FADER_PCM_2_5_SEC
Definition: bios.h:329
int16_t rem
Definition: bios.h:709
@ PCE_CDB_ID_IRQ_VDC
Definition: bios.h:84
uint8_t uint16_t uint16_t length
Definition: bios.h:181
pce_cdb_address_type
Definition: bios.h:43
uint16_t pce_cdb_mul_u8(uint8_t a, uint8_t b)
Perform an 8x8->16 unsigned multiplication.
pce_cdb_subcode
Definition: bios.h:298
::uint8_t uint8_t
Definition: cstdint:21
@ PCE_CDB_INVALID_ADDRESS
Definition: bios.h:36
uint8_t md
Definition: bios.h:278
@ PCE_CDB_FADER_PCM_6_SEC
Definition: bios.h:327
@ PCE_CDB_VRAM_DMA_DEST_DEC
Definition: bios.h:637
void pce_cdb_vdc_irq_scanline_enable(void)
Enable the scanline IRQ.
@ PCE_CDB_FADER_ADPCM_6_SEC
Definition: bios.h:328
@ PCE_CDB_SUBCODE_S
Definition: bios.h:303
@ PCE_CDB_NOT_DATA_TRACK
Definition: bios.h:34
void pce_cdb_colors_sprite_at(void *address, uint8_t count)
Set the location of the sprite palette RAM buffer.
@ PCE_CDB_BASE_SET_SECOND
Definition: bios.h:131
void pce_cdb_irq_enable(uint8_t mask)
Enable the specified IRQs.
@ PCE_CDB_VRAM_DMA_IRQ_SATB_DONE
Definition: bios.h:632
uint8_t control
Definition: bios.h:281
uint8_t pce_cdb_cdda_search(pce_sector_t sector, uint8_t mode)
Search for a CD audio track.
@ PCE_CDB_SEEK_ERROR
Definition: bios.h:31
@ PCE_CDB_END_OF_DISK
Definition: bios.h:38
uint8_t pce_cdb_sqrt(uint16_t a)
Calculate the square root of a given value.
void pce_cdb_vdc_irq_vblank_disable(void)
Disable the veritcal blank IRQ.
@ PCE_CDB_SUBCODE_W
Definition: bios.h:299
@ PCE_CDB_CDDA_SEARCH_PAUSE_NONBLOCK
Definition: bios.h:207
::int8_t int8_t
Definition: cstdint:7
@ PCE_CDB_SUBCODE_V
Definition: bios.h:300
char channel
Definition: famitone2.h:31
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.
@ PCE_CDB_BANK_MPR6
Bank number (uses MPR6).
Definition: bios.h:71
@ PCE_CDB_FADER_NONE
Definition: bios.h:326
void pce_cdb_cd_base(pce_sector_t base, uint8_t mode)
Set the starting sector, used as an offset for future BIOS calls.
@ PCE_CDB_BASE_SET_FIRST
Definition: bios.h:130
pcd_cdb_irq_vector_mask
Definition: bios.h:92
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.
@ PCE_CDB_SUBCODE_P
Definition: bios.h:306
void pce_cdb_adpcm_stop(void)
Stop ADPCM playback.
uint16_t pce_cdb_version(void)
Get the CD BIOS version.
const void uint16_t count
Definition: memory.h:58
@ PCE_CDB_LOCATION_TYPE_CURRENT
Definition: bios.h:124
@ PCE_CDB_LOCATION_TYPE_SECTOR
Definition: bios.h:121
bool pce_cdb_vdc_set_resolution(uint8_t clock, uint8_t width_tiles, uint8_t height_tiles)
Set the video resolution.
void pce_cdb_vdc_set_bg_row_copy(void)
Set the automatic increment for VRAM addresses to write one word per background row.
int16_t pce_cdb_mul_s8(int8_t a, int8_t b)
Perform an 8x8->16 signed multiplication.
void pce_cdb_vdc_vram_write_at(uint16_t addr)
Set the VRAM write address.
uint8_t pce_cdb_adpcm_stream(pce_sector_t sector, pce_sector_t length, uint8_t divider)
Begin ADPCM sample playback streamed from CD.
@ PCE_CDB_ADDRESS
An address in the local address space.
Definition: bios.h:51
@ PCE_CDB_MASK_NMI
Definition: bios.h:96
@ PCE_CDB_BANK_MPR5
Bank number (uses MPR5).
Definition: bios.h:67
void pce_cdb_vdc_configure_dma(uint8_t value)
Configure VRAM DMA.
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.
void pce_cdb_vdc_bg_enable(void)
Enable the background layer.
uint8_t pce_cdb_bcd_to_bin(uint8_t value)
Convert a BCD number to a binary number.
unsigned size
Definition: neslib.h:185
@ ADPCM_BUFFER_UNDER_HALF
The ADPCM controller has under 50% of the buffer.
Definition: bios.h:457
void pce_cdb_vdc_sprite_table_put(void)
Put a sprite to the VRAM sprite table.
void pce_cdb_vdc_irq_vblank_enable(void)
Enable the veritcal blank IRQ.
void pce_cdb_vdc_sprite_enable(void)
Enable the sprite layer.
uint16_t pce_cdb_adpcm_status(void)
Query the ADPCM status.
@ PCE_CDB_ADPCM_REPEAT
Loop ADPCM sample.
Definition: bios.h:403
void pce_cdb_adpcm_reset(void)
Reset the ADPCM controller.
uint8_t lo
Definition: bios.h:278
@ PCE_CDB_ID_IRQ_TIMER
Definition: bios.h:85
@ PCE_CDB_CDDA_PLAY_ONE_SHOT
Definition: bios.h:186
@ PCE_CDB_SUBCODE_R
Definition: bios.h:304
::int16_t int16_t
Definition: cstdint:8
@ PCE_CDB_CDDA_PLAY_REPEAT
Definition: bios.h:185
@ PCE_CDB_READ_ERROR
Definition: bios.h:30
@ PCE_CDB_VRAM_DMA_SRC_DEC
Definition: bios.h:635
void pce_cdb_vdc_irq_scanline_set(uint16_t line)
Set the scanline #, on which the scanline IRQ should be emitted.
@ PCE_CDB_VRAM_DMA_IRQ_DONE
Definition: bios.h:633
@ PCE_CDB_BANK_MPR4
Bank number (uses MPR4).
Definition: bios.h:63
bool pce_cdb_colors_set(void)
Queue a color transfer from the RAM buffers to the VCE.
uint8_t pce_cdb_cd_read_toc_track_sector(pce_cdb_toc_data_t *buffer, uint8_t track_id)
@ PCE_CDB_VRAM_BYTES
VRAM address (length specified in bytes).
Definition: bios.h:75
@ PCE_CDB_HEADER_READ_ERROR
Definition: bios.h:32
void pce_cdb_vdc_bg_sprite_enable(void)
Enable the background and sprite layer.
@ PCE_CDB_BASE_SET_NONE
Definition: bios.h:132
@ PCE_CDB_MASK_IRQ_TIMER
Definition: bios.h:95
@ PCE_CDB_ID_SOFT_RESET
Definition: bios.h:89
void pce_cdb_colors_sprite_none(void)
Clear the sprite palette RAM buffer.
pce_cdb_fader_mode
Definition: bios.h:325
void pce_cdb_vdc_bg_disable(void)
Disable the background layer.
@ PCE_CDB_MASK_VBLANK
Definition: bios.h:99
@ PCE_CDB_ID_NMI
Definition: bios.h:86
pce_cdb_vdc_vram_dma_flags
Definition: bios.h:631
void pce_cdb_cd_seek(pce_sector_t sector)
Seek the CD drive to the specified sector.
@ PCE_CDB_SUBCODE_U
Definition: bios.h:301
uint8_t pce_cdb_cd_scan(void)
Initialize information about the currently inserted CD.
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.
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.
@ PCE_CDB_CDDA_PLAY_PREVIOUS
Definition: bios.h:188
bool pce_cdb_cd_read_subcode_bits(uint8_t *buffer)
Read the current CD subcode bits.
struct pce_cdb_toc_data pce_cdb_toc_data_t
pce_cdb_error_code
Definition: bios.h:25
uint8_t address_type
Definition: bios.h:179
void pce_cdb_vdc_sprite_disable(void)
Disable the sprite layer.
@ PCE_CDB_VRAM
VRAM address.
Definition: bios.h:79
uint8_t uint16_t address
Definition: bios.h:180
@ PCE_CDB_LOCATION_TYPE_UNTIL_END
Definition: bios.h:125
uint8_t frame
Definition: bios.h:275
@ PCE_CDB_CDDA_SEARCH_PLAY_NONBLOCK
Definition: bios.h:209
void pce_cdb_vdc_irq_scanline_disable(void)
Disable the scanline IRQ.
@ PCE_CDB_CDDA_SEARCH_PAUSE_BLOCK
Definition: bios.h:206
@ ADPCM_BUSY
If any of these bits are set, the ADPCM controller is busy.
Definition: bios.h:449
@ PCE_CDB_VRAM_DMA_DEST_INC
Definition: bios.h:636
uint8_t status
Definition: bios.h:252
@ PCE_CDB_NOT_PLAYING_AUDIO
Definition: bios.h:40
void pce_cdb_wait_vblank(void)
Wait for VBlank.
@ PCE_CDB_SUBCODE_Q
Definition: bios.h:305
uint16_t pce_cdb_cdda_read_sample(uint8_t channel)
Read the currently played CD audio sample.
@ PCE_CDB_ADPCM_ONE_SHOT
Play ADPCM sample once.
Definition: bios.h:399
@ PCE_CDB_INVALID_PARAMETER_LIST
Definition: bios.h:39
uint8_t track
Definition: bios.h:254
uint8_t track_end
Definition: bios.h:272
@ PCD_CDB_DRIVE_OPEN
Definition: bios.h:29
uint8_t pce_cdb_cd_busy(void)
Check if the CD drive is busy.
@ PCE_CDB_BANK_MPR2
Bank number (uses MPR2).
Definition: bios.h:55
void pce_cdb_vdc_bg_set_size(uint8_t size)
Set the BG size to the specified value.
pce_cdb_base_set_mode
Definition: bios.h:128
void pce_cdb_vdc_bg_sprite_disable(void)
Disable the background and sprite layer.
pce_cdb_adpcm_mode
Definition: bios.h:395
uint8_t pce_cdb_adpcm_continue(uint8_t mode)
Continue existing ADPCM sample playback.
@ PCE_CDB_CDDA_PLAY_MUTE
Definition: bios.h:184
void pce_cdb_irq_disable(uint8_t mask)
Disable the specified IRQs.
uint8_t pce_cdb_cdda_pause(void)
Pause CD audio playback.
void pce_cdb_fader(uint8_t mode)
Configure the CD unit's audio fader.
@ PCE_CDB_MASK_VBLANK_NO_BIOS
Definition: bios.h:100
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.
bool pce_cdb_ram_query(uint8_t *bank_start, uint8_t *bank_size)
Query for the presence of additional RAM.
@ PCE_CDB_INVALID_COMMAND
Definition: bios.h:35
::uint32_t uint32_t
Definition: cstdint:23
pce_cdb_location_type
Definition: bios.h:120
@ PCE_CDB_NO_DISC
Definition: bios.h:28
bool pce_cdb_colors_read(void)
Queue a color transfer from the VCE to the RAM buffers.
@ ADPCM_STOPPED
The ADPCM controller is not playing audio.
Definition: bios.h:453
const void uint16_t uint8_t mode
Definition: memory.h:58
uint16_t rem
Definition: bios.h:704
@ PCE_CDB_FADER_ADPCM_2_5_SEC
Definition: bios.h:330
@ PCE_CDB_BASE_SET_BOTH
Definition: bios.h:129
@ PCE_CDB_BANK_MPR3
Bank number (uses MPR3).
Definition: bios.h:59
pce_sector_t total_time
Definition: bios.h:257
uint8_t pce_cdb_cd_reset(void)
Reset the CD drive.
@ PCE_CDB_CDDA_PLAY_NOT_BUSY
Definition: bios.h:187
pce_cdb_cdda_search_mode
Definition: bios.h:205
void pce_cdb_vdc_sprite_table_clear(void)
Clear the VRAM sprite table.
void pce_cdb_vdc_vram_read_at(uint16_t addr)
Set the VRAM read address.
void pce_cdb_vdc_set_bg_column_copy(void)
Set the automatic increment for VRAM addresses to write one word per background column.
void pce_cdb_irq_set(uint8_t type, void(*irq_handler)(void))
Set the IRQ handler for a given interrupt.
void pce_cdb_colors_bg_at(void *address, uint8_t count)
Set the location of the background palette RAM buffer.
uint16_t quot
Definition: bios.h:703
pce_cdb_cdda_play_mode
Definition: bios.h:183