Home Download Musics Developers
API Sources Tools File Format Technicals

Amiga Paula emulator.
[io68 library documentation.]

Detailed Description

Paula emulator (Amiga soundchip).

About Amiga hardware registers
Amiga hardware registers could have a different address for read and write access. It is the case for DMA control register (DMACON).

Registers could be (B)yte or (W)ord wide.

Some hardware registers work with a SET/CLEAR bit. When writing these registers the value is not copied as is. The operation depends on the value of S the most signifiant bit (#15).
  • If S is SET then all others setted bits are setted (bitwise OR).
  • If S is CLEAR then all others setted bits are cleared (bitwise NAND).


file  paula_io.h
 Paula IO plugin header.

file  paulaemul.h
 Paula emulator header.

Data Structures

struct  paulav_t
 Paula voice information data structure. More...

Amiga interruption registers

All hardware registers involved with interruption handling use the same bit organisation :
  • bit 7 Audio channel A
  • bit 8 Audio channel B
  • bit 9 Audio channel C
  • bit 10 Audio channel D
  • bit 14 Master interrupt

#define PAULA_INTREQR   0x1E
 Interruption request read.

#define PAULA_INTREQRH   0x1E
 Interruption request read MSB.

#define PAULA_INTREQRL   0x1F
 Interruption request read LSB.

#define PAULA_INTREQ   0x9C
 Interruption request write.

#define PAULA_INTREQH   0x9C
 Interruption request write MSB.

#define PAULA_INTREQL   0x9D
 Interruption request write LSB.

#define PAULA_INTENAR   0x1C
 Interruption enable read.

#define PAULA_INTENARH   0x1C
 Interruption enable read MSB.

#define PAULA_INTENARL   0x1D
 Interruption enable read LSB.

#define PAULA_INTENA   0x9A
 Interruption enable write.

#define PAULA_INTENAH   0x9A
 Interruption enable write MSB.

#define PAULA_INTENAL   0x9B
 Interruption enable write LSB.

Amiga DMA registers.

Amiga DMA control register bits :
  • bit 0 Audio DMA channel A
  • bit 1 Audio DMA channel B
  • bit 2 Audio DMA channel C
  • bit 3 Audio DMA channel D
  • bit 9 General DMA

#define PAULA_DMACONR   0x02
 DMA control read.

#define PAULA_DMACONRH   0x02
 DMA control read MSB.

#define PAULA_DMACONRL   0x03
 DMA control read LSB.

#define PAULA_DMACON   0x96
 DMA control write.

#define PAULA_DMACONH   0x96
 DMA control write MSB.

#define PAULA_DMACONL   0x97
 DMA control write LSB.

The Audio & Disk Control Registers.

  • 07 USE3PN Use audio channel 3 to modulate nothing.
  • 06 USE2P3 Use audio channel 2 to modulate period of channel 3.
  • 05 USE1P2 Use audio channel 1 to modulate period of channel 2.
  • 04 USE0P1 Use audio channel 0 to modulate period of channel 1.
  • 03 USE3VN Use audio channel 3 to modulate nothing.
  • 02 USE2V3 Use audio channel 2 to modulate volume of channel 3.
  • 01 USE1V2 Use audio channel 1 to modulate volume of channel 2.
  • 00 USE0V1 Use audio channel 0 to modulate volume of channel 1.

If both period/volume are modulated on the same channel, the period and volume will be alternated. First word xxxxxxxx V6-V0, Second word P15-P0 (etc).

#define PAULA_ADKCON   0x9E
 Audio, disk, control write.

#define PAULA_ADKCONR   0x10
 Audio, disk, control read.

#define PAULA_ADKCONRH   0x10
 Audio, disk, control write.

#define PAULA_ADKCONRL   0x11
 Audio, disk, control write.

Amiga Paula registers.

#define PAULA_VOICE(I)   ((0xA+(I))<<4)
 Paula channel I register base.

#define PAULA_VOICEA   0xA0
 Paula channel A register base.

#define PAULA_VOICEB   0xB0
 Paula channel B register base.

#define PAULA_VOICEC   0xC0
 Paula channel C register base.

#define PAULA_VOICED   0xD0
 Paula channel D register base.

Amiga Paula frequencies (PAL).

#define PAULA_PER   2.79365E-7
 Paula period (1 cycle duration).

#define PAULA_FRQ   3579610.53837
 Paula frequency (1/PAULA_PER).

Initialization functions.

unsigned int PL_sampling_rate (unsigned int f)
 Set/Get sampling rate.

int PL_reset (void)
 Paula hardware reset.

int PL_init (void)
 Paula first one first initialization.

Emulation functions

void PL_mix (u32 *b, u8 *mem68, int n)
 Execute Paula emulation.

Paula (Amiga soundchip) IO plugin

io68_t paula_io
 Paula IO plugin instance.

Internal Paula emulation data.

u8 paula []
 Paula regiter data storage.

paulav_t paulav []
 Paula voices(channel) table (4 voices).

int paula_dmacon
 Shadow DMACON.

int paula_intena
 Shadow INTENA.

int paula_intreq
 Shadow INTREQ.

int paula_adkcon
 Shadow ADKCON.

int paula_interpol
 Interpolation mode [0:none 1:linear].


#define PAULA_VHPOSR   0x06
 Amiga Vertical/Horizontal electron bean position.

#define PAULA_CT_FIX   13
 Counter fixed point precision 13+19(512kb)=>32 bit.

Function Documentation

unsigned int PL_sampling_rate unsigned int  f  ) 

Set/Get sampling rate.

The PL_sampling_rate() function set Paula emulator sampling rate. f is given in hz. If f is 0 the current replay is return.

f sampling rate in hz (0 to get current value).
new sampling rate

int PL_reset void   ) 

Paula hardware reset.

The PL_reset() reset function perform a Paula reset. It performs following operations :

  • all registers zeroed
  • all internal voices set to dummy 2 samples len address.
  • general DMA enabled
  • all audio DMA disabled
  • interrupt master enabled
  • all audio interrupt disbled

error-code (always success)

0 Success

int PL_init void   ) 

Paula first one first initialization.

The PL_init() must be call before all other PL functions. It performs following operations:

  • Init output level (volume) table.
  • Hardware reset
  • Set replay frequency to default (44100 Hz) if not already set

error-code (always success)

0 Success

See also:

void PL_mix u32 b,
u8 mem68,
int  n

Execute Paula emulation.

The PL_mix() function processes sample mixing with current internal parameters for n samples. Mixed samples are stored in a large enough (at least n) 32 bit pcm buffer pointed by b. mem68 is a pointer to the 68K memory buffer. The Paula emulator assume that this buffer is at least the size of the Amiga "chip" RAM. This implies at leat 512Kb and PCM data must be in the first 512Kb.

b Pointer to destination 32-bit data buffer
mem68 Pointer to 68K memory buffer start address
n Number of sample to mix in b buffer