1
0
mirror of https://github.com/ksherlock/iigs.git synced 2024-11-24 00:30:46 +00:00
1 The Sound GLU
ksherlock edited this page 2020-07-02 22:24:45 -04:00

To program the DOC or build a wavetable in the Sound RAM, you must write command and data bytes to registers within the chip. This process is facilitated by the GLU, which serves as an interface between the microprocessor, the DOC, and the dedicated 64K—by—8-bit dynamic RAM. This interface allows the DOC chip to run independently of the rest of the system.

The Sound GLU contains

  • a Sound Control register
  • a data register
  • a pair of Address Pointer (high and low address) registers

These registers and their addresses are listed in Table 5-1 and described in detail in the sections that follow.

GLU Registers Address Type
Sound Control Register $c03c R/W
Data Register $c03d R/W
Address Pointer Register $c03e-$c03f R/W

The Sound Control register

The Sound Control register controls whether the microprocessor accesses the DOC internal registers or the Sound RAM. This register also controls whether or not the Address Pointer registers auto-increment, that is, increment automatically after every RAM read or write, thereby avoiding the necessity of reloading the pointers with addresses after each access. Figure 5-2 shows the format of the Sound Control register. Table 5-2 gives a description of each bit.

Warning: Do not use a read-modify-write command when altering bits in this register.

Bit Value Description
7 1 The DOC is busy; loop on this bit until it is clear.
0 When this bit is 0, the DOC is free. The DOC will respond to register reads and writes.
6 1 All accesses are to the dedicated 64K RAM.
0 All accesses are to the DOC
5 1 Address auto-incrementing is enabled.
0 Address auto-incrementing is disabled; Address Pointer registers hold the last value.
4 - Reserved; do not modify
3-0 - Volume control: SO is low volume, $F is high volume.

Data register

To load values into the DOC registers, write to the data register at $C03D. You also write to this register when you want to place values in Sound RAM. If the Sound Control register is set to access the DOC, writes to the data register will result in data bytes being loaded into the DOC register indicated by the Address Pointer registers. If the Sound Control register is set to access the Sound RAM, writes to the data register will result in data bytes being loaded into the Sound RAM address indicated by the Address Pointer registers.

Address Pointer registers

When accessing the Sound RAM (bit 6 set to 1 in the Sound Control register), the Address Pointer registers point to the address of the next byte in Sound RAM. The high-byte Address Pointer register contains the high 8 bits of the 16-bit address, and the low-byte register contains the low 8 bits.

When accessing the Sound DOC (bit 6 set to 0 in the Sound Control register), the high-byte Address Pointer register is ignored by the DOC, and the low-byte Address Pointer register points to the DOC register to be written or read from. Figure 5-3 shows the format of the Address Pointer registers.

Write operation

To write to the DOC or Sound RAM:

  1. Set the Sound Control register
  • to point to either the RAM or the DOC
  • to enable or disable auto-incrementing in the Address Pointer registers
  1. Then load the Address Pointer register with the beginning location into which data are to be written. Do this by writing the high byte of the address to the high-byte Address Pointer register at SC03F, and the low byte of the address to the low-byte Address Pointer register at $C03F.

Data now written to the data register will be transferred by the Sound GLU into the corresponding memory (if you are accessing RAM) or DOC register (if you are accessing the DOC).

If the auto-increment feature is enabled, the Address Pointer register is automatically incremented lo the next higher location or the register with the next higher address after each write to the data register.

Note: Do not use indexed addressing mode when reading data from or writing data to the data register. Indexed addressing mode generates a false read, which will cause the sound GLU to lose synchronization.

Read operation

The Sound RAM read operation is the same as the write operation with one exception: Reading from the data register lags by one read cycle. For example, if you want to read 10 bytes from the Sound RAM, select the RAM by setting the Sound Control register bit and enabling auto-incrementing. Then set the Address Pointer register to the starting address and read the data register 11 times, discarding the first byte read.