libmsx
C library for MSX
Loading...
Searching...
No Matches

Device interface for Konami SCC/SCC+ sound cartridge. More...

#include <stdint.h>
+ Include dependency graph for scc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SCC_Waveform
 The structure of the SCC/SCC+ 32-byte waveform data register. More...
 
struct  SCC_Channel
 Device interface for a sound channel of SCC/SCC+ sound chip. More...
 
struct  SCC_Device
 Device interface for SCC/SCC+ sound chip. More...
 
struct  SCC
 SCC Handle. More...
 

Macros

#define SCC_H_
 

Functions

uint8_t SCC_inspect (uint8_t slot)
 MSX Inspect whether SCC/SCC+ is on the given slot.
 
uint8_t SCC_find (struct SCC *scc)
 MSX Find SCC/SCC+ sound chip.
 
void SCC_set_mode (struct SCC *scc, uint8_t mode)
 MSX Set the SCC handle to SCC compatible mode or SCC+ mode.
 
uint8_t SCC_get_mode (struct SCC *scc)
 MSX Check which mode the SCC handle is set to.
 
void SCC_enable (const struct SCC *scc)
 MSX Enable SCC/SCC+ sound chip.
 
void SCC_disable (const struct SCC *scc)
 MSX Disable SCC/SCC+ sound chip.
 

Detailed Description

Device interface for Konami SCC/SCC+ sound cartridge.

Example
The following code detects the Konami SCC/SCC+ sound chip and plays a triangular wave test tone if detected.

// -*- coding: utf-8-unix -*-
/*
* Copyright (c) 2021-2024 Daishi Mori (mori0091)
*
* This software is released under the MIT License.\n
* See https://github.com/mori0091/libmsx/blob/main/LICENSE
*
* GitHub libmsx project\n
* https://github.com/mori0091/libmsx
*/
#include <string.h>
#include <msx.h>
#include <scc.h>
const int8_t triangle[32] = {
0, 16, 32, 48, 64, 80, 96, 112,
127, 112, 96, 80, 64, 48, 32, 16,
0, -16, -32, -48, -64, -80, -96, -112,
-128, -112, -96, -80, -64, -48, -32, -16,
};
static struct SCC scc;
void test_SCC(void) {
if (!scc.slot) return;
SCC_enable(&scc);
{
uint8_t slot_p2 = msx_get_slot((void *)0x8000);
msx_ENASLT(scc.slot, (void *)0x8000);
{
memcpy((void *)scc.device->channels[0].wo_waveform, triangle, 32);
*scc.device->rw_channel_mask = 0x01; // unmute ch1
*scc.device->channels[0].rw_volume = 15;
*scc.device->channels[0].rw_fdr = 0x11d; // O4 G
}
msx_ENASLT(slot_p2, (void *)0x8000);
__asm__("ei");
}
SCC_disable(&scc);
}
void main(void) {
if (SCC_find(&scc)) {
test_SCC();
}
for (;;) {
}
}
void msx_ENASLT(uint8_t slot, void *addr)
MSX BIOS : ENASLT (0024H / MAIN).
uint8_t msx_get_slot(void *addr)
MSX Get the current slot of a 16KiB page that including the given address.
void await_vsync(void)
MSX Waits for next VSYNC interrupt.
void SCC_enable(const struct SCC *scc)
MSX Enable SCC/SCC+ sound chip.
uint8_t SCC_find(struct SCC *scc)
MSX Find SCC/SCC+ sound chip.
void SCC_disable(const struct SCC *scc)
MSX Disable SCC/SCC+ sound chip.
SCC Handle.
Definition scc.h:106
Using #include <msx.h> includes almost all C header files in libmsx, for ease to use.
Device interface for Konami SCC/SCC+ sound cartridge.

Definition in file scc.h.

Macro Definition Documentation

◆ SCC_H_

#define SCC_H_

Definition at line 29 of file scc.h.