Skip to content

Commit

Permalink
Provisional check for RAM writes during STE DMA sound playback
Browse files Browse the repository at this point in the history
  • Loading branch information
frno7 committed Jan 15, 2025
1 parent f337d75 commit f0e9d39
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/atari/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ extern const struct device sound_device;

void sound_sample(sound_sample_f sample, void *sample_arg);

void sound_check(u32 bus_address);

#endif /* ATARI_SOUND_H */
5 changes: 5 additions & 0 deletions lib/atari/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "atari/device.h"
#include "atari/exception-vector.h"
#include "atari/ram.h"
#include "atari/sound.h"
#include "atari/system-variable.h"

static u8 ram[4 * 1024 * 1024]; /* 4 MiB of RAM */
Expand All @@ -31,12 +32,16 @@ static u16 ram_rd_u16(const struct device *device, u32 dev_address)
static void ram_wr_u8(const struct device *device,
u32 dev_address, u8 data)
{
sound_check(dev_address);

ram[dev_address] = data;
}

static void ram_wr_u16(const struct device *device,
u32 dev_address, u16 data)
{
sound_check(dev_address);

ram[dev_address] = data >> 8;
ram[dev_address + 1] = data & 0xff;
}
Expand Down
15 changes: 15 additions & 0 deletions lib/atari/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,21 @@ void sound_sample(sound_sample_f sample, void *sample_arg)
output.sample_arg = sample_arg;
}

void sound_check(u32 bus_address)
{
/*
* FIXME: Provisional check for Quartet files such as Spaz that
* write to RAM during DMA playback.
*/
extern const struct device sound_device;
const struct device *device = &sound_device;

if (state.regs.ctrl.dma &&
state.start <= bus_address &&
bus_address < state.end)
sound_emit(device_cycle(device));
}

const struct device sound_device = {
.name = "snd",
.frequency = SOUND_FREQUENCY,
Expand Down

0 comments on commit f0e9d39

Please sign in to comment.