Table of Contents
The GameTank's audio system, referred to as the Audio Coprocessor or ACP, is a 65C02-based subcomputer that computes PCM samples and outputs them to a digital-to-analog-converter.
The ACP consists of a 65C02 processor, a 4K dual-ported RAM that is shared with the main system's memory map, a programmable timer that triggers the 65C02's IRQ at regular intervals, an 8-bit DAC, and a buffer register.
The 4K dual-ported RAM encompasses the entirety of the memory that the ACP can address. The memory range $0000-$0FFF maps to the RAM and address above that will cycle over that range.
The same memory can be accessed by the main system's processor between addresses $3000-$3FFF, utilizing the second port of the SRAM.
Both systems can access this memory at the same time, therefore care should be taken to not write to the same location from both sides simultaneously, or perform a simultaneous read and write that may have unpredictable results.
The IRQ Generator
The ACP's programmable timer is used for triggering interrupts on the 65C02. This simplifies the task of making sure that audio samples are being emitted at a steady rate regardless of the complexity of the audio program.
The digital-to-analog-converter controls the voltage level that is emitted on the audio jack.
The DAC is not directly writable by the ACP. Any write by the ACP to an address at $8000 or above will also be mirrored to a buffer register. This buffer register is copied to the DAC at every IRQ signal.
Effective sample rate
The IRQ timer determines the sample rate by setting how many cycles lapse between DAC updates. The number of cycles is equal to the value of the register times four, since the IRQ timer is clocked at the main CPU frequency while the audio processor clock runs four times as fast.
The main CPU clock is the same as the NTSC color carrier frequency, approximately 3.5795Mhz or exactly 315/88 MHz. So the audio rate with the most cycles available will be 315000000/(256*88) = 13982 Hz
Conversely the IRQ rate can go as high as 3.5795MHz but without time for any CPU operations this isn't very useful