Permalink
Browse files

Now with pausing and other niceties

  • Loading branch information...
sik
sik committed Jul 23, 2017
1 parent a679ba3 commit 3aacf3d2cedfdeca49ceb57533389870bfc688a9
View
16 README
@@ -7,12 +7,18 @@
| | |_ |_ ___ | | | | | | | |
| |_______ |_ |___| _| | | | | |_ |_____| _|
|___________| |________| |___| |___| |_________|
___ ___ _ _ ___ __ ___ ___ ___ _ ___ ___ _ _ _
| _| | | | | \ | _| | _| | | _| | | | | |
| |_| | | | | | | | | | |_| | | |_| | | | |_ _ _ ___ ___ | | | | |
___ ___ _ _ ___ __ ___ ___ ___ _ ___ ___ _ ___
| _| | | | | \ | _| | _| | | _| | | | _|
| |_| | | | | | | | | | |_| | | |_| | | | |_ _ _ ___ ___ | | | |_
|_ | | | | | | | | | | _| | | | | | | | _| | | | __| _ \ | | |_ |
_| | | | | | | | | | | |_| | | | | | | | |_ | | | __| /_ | |_ | |
|___|___|___|_|_|__/ |___|_|_|___|_|_|_|___| \_/|___|_|_\_| |_|_| |_|
_| | | | | | | | | | | |_| | | | | | | | |_ | | | __| /_ | |_ _| |
|___|___|___|_|_|__/ |___|_|_|___|_|_|_|___| \_/|___|_|_\_| |_|_|___|
=============================================================================
WARNING: if you used Echo_SetVolumeEx in Echo 1.4, beware that the ABI
changed to require 16 bytes instead of 13. Currently the extra bytes are
ignored, but consider adapting your code (just set them to zeroes).
=============================================================================
Binary file not shown.
View
Binary file not shown.
View
117 c/echo.c
@@ -98,7 +98,7 @@ void echo_init(const void **list) {
// Set up global volume
int i;
for (i = 0; i < 12; i++)
for (i = 0; i < 16; i++)
z80_ram[0x1FE0+i] = 0;
z80_ram[0x1FEC] = 1;
z80_ram[0x1FF1] = 1;
@@ -120,15 +120,19 @@ void echo_send_command(uint8_t cmd) {
Z80_REQUEST();
// Is Echo busy yet?
while (z80_ram[0x1FFF] != 0x00) {
Z80_RELEASE();
DELAY();
Z80_REQUEST();
volatile uint8_t *ptr = &z80_ram[0x1FFC]
if (ptr[3] != 0x00) {
ptr -= 4;
while (ptr[3] != 0x00) {
Z80_RELEASE();
DELAY();
Z80_REQUEST();
}
}
// Write the command
z80_ram[0x1FFF] = cmd;
ptr[3] = cmd;
// Done with the Z80
Z80_RELEASE();
}
@@ -151,21 +155,25 @@ void echo_send_command_addr(uint8_t cmd, const void *addr) {
Z80_REQUEST();
// Is Echo busy yet?
while (z80_ram[0x1FFF] != 0x00) {
Z80_RELEASE();
DELAY();
Z80_REQUEST();
volatile uint8_t *ptr = &z80_ram[0x1FFC]
if (ptr[3] != 0x00) {
ptr -= 4;
while (ptr[3] != 0x00) {
Z80_RELEASE();
DELAY();
Z80_REQUEST();
}
}
// Write the command
z80_ram[0x1FFF] = cmd;
z80_ram[0x1FFD] = param;
ptr[3] = cmd;
ptr[1] = param;
param >>= 8;
z80_ram[0x1FFE] = param | 0x80;
ptr[2] = param | 0x80;
param >>= 7;
param = (param & 0x7F) | (param >> 1 & 0x80);
z80_ram[0x1FFC] = param;
ptr[0] = param;
// Done with the Z80
Z80_RELEASE();
}
@@ -183,17 +191,20 @@ void echo_send_command_byte(uint8_t cmd, uint8_t byte) {
Z80_REQUEST();
// Is Echo busy yet?
while (z80_ram[0x1FFF] != 0x00) {
Z80_RELEASE();
int16_t i;
for (i = 0x3FF; i >= 0; i--);
Z80_REQUEST();
volatile uint8_t *ptr = &z80_ram[0x1FFC]
if (ptr[3] != 0x00) {
ptr -= 4;
while (ptr[3] != 0x00) {
Z80_RELEASE();
DELAY();
Z80_REQUEST();
}
}
// Write the command
z80_ram[0x1FFF] = cmd;
z80_ram[0x1FFC] = byte;
ptr[3] = cmd;
ptr[0] = byte;
// Done with the Z80
Z80_RELEASE();
}
@@ -218,16 +229,23 @@ void echo_stop_bgm(void) {
echo_send_command(ECHO_CMD_STOPBGM);
}
//***************************************************************************
// echo_pause_bgm
// Pauses background music playback.
//***************************************************************************
void echo_pause_bgm(void) {
echo_send_command(ECHO_CMD_PAUSEBGM);
}
//***************************************************************************
// echo_resume_bgm
// Resumes background music playback.
//***************************************************************************
/*
void echo_resume_bgm(void) {
echo_send_command(ECHO_CMD_RESUMEBGM);
}
*/
//***************************************************************************
// echo_play_sfx
@@ -328,7 +346,7 @@ void echo_set_volume_ex(const uint8_t *ptr) {
// Store the new volume values
int i;
for (i = 0; i < 13; i++)
for (i = 0; i < 16; i++)
z80_ram[0x1FE0+i] = ptr[i];
// Tell Echo to update all the volumes
@@ -363,7 +381,7 @@ uint16_t echo_get_status(void) {
// Retrieve status from Z80 RAM
uint16_t status = 0;
status = z80_ram[0x1FF0];
if (z80_ram[0x1FFF] != 0)
if (z80_ram[0x1FFB] != 0)
status |= ECHO_STAT_BUSY;
if (z80_ram[0x1F00] != 0xFF)
status |= ECHO_STAT_DIRBUSY;
@@ -374,3 +392,46 @@ uint16_t echo_get_status(void) {
// Return status
return status;
}
//***************************************************************************
// echo_get_flags
// Gets the current values of the flags.
//---------------------------------------------------------------------------
// return: bitmask with flags
//***************************************************************************
uint8_t echo_get_flags(void)
{
Z80_REQUEST();
uint8_t flags = z80_ram[0x1FF2];
Z88_RELEASE();
return flags;
}
//***************************************************************************
// echo_set_flags
// Sets flags from the 68000.
//---------------------------------------------------------------------------
// param flags: bitmask of flags to be set (1 = set, 0 = intact)
//***************************************************************************
void echo_set_flags(uint8_t flags)
{
Z80_REQUEST();
z80_ram[0x1FF2] |= flags;
Z80_RELEASE();
}
//***************************************************************************
// echo_clear_flags
// Clears flags from the 68000.
//---------------------------------------------------------------------------
// param flags: bitmask of flags to be cleared (1 = clear, 0 = intact)
//***************************************************************************
void echo_clear_flags(uint8_t flags)
{
Z80_REQUEST();
z80_ram[0x1FF2] &= ~flags;
Z80_RELEASE();
}
View
@@ -14,6 +14,7 @@ enum {
ECHO_CMD_STOPBGM, /* 0x05 - Stop BGM playback */
ECHO_CMD_RESUMEBGM, /* 0x06 - Resume BGM playback */
ECHO_CMD_SETPCMRATE, /* 0x07 - Set PCM rate */
ECHO_CMD_PAUSEBGM, /* 0x08 - Pause BGM playback */
};
/* Echo status flags */
@@ -23,20 +24,24 @@ enum {
#define ECHO_STAT_BUSY 0x8000 /* Echo still didn't parse command */
/* Function prototypes */
void echo_init(const void **);
void echo_play_bgm(const void *);
void echo_init(const void **list);
void echo_play_bgm(const void *esf);
void echo_stop_bgm(void);
/*void echo_resume_bgm(void);*/
void echo_play_sfx(const void *);
void echo_pause_bgm(void);
void echo_resume_bgm(void);
void echo_play_sfx(const void *esf);
void echo_stop_sfx(void);
void echo_play_direct(const void *);
void echo_set_volume(uint8_t);
void echo_set_volume_ex(const uint8_t *);
void echo_set_pcm_rate(uint8_t);
void echo_play_direct(const void *esf);
void echo_set_volume(uint8_t vol);
void echo_set_volume_ex(const uint8_t *vol_list);
void echo_set_pcm_rate(uint8_t rate);
uint16_t echo_get_status(void);
void echo_send_command(uint8_t);
void echo_send_command_addr(uint8_t, const void *);
void echo_send_command_byte(uint8_t, uint8_t);
uint8_t echo_get_flags(void);
void echo_set_flags(uint8_t flags);
void echo_clear_flags(uint8_t flags);
void echo_send_command(uint8_t cmd);
void echo_send_command_addr(uint8_t cmd, const void *addr);
void echo_send_command_byte(uint8_t cmd, uint8_t byte);
/* Deprecated functions */
static void (* const echo_send_command_ex)(uint8_t, const void *) =
Oops, something went wrong.

0 comments on commit 3aacf3d

Please sign in to comment.