|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"#include "blitzobj.h"#include "blitzexec.h"#include <exec/io.h>#include <exec/memory.h>#include <utility/tagitem.h>#include <devices/ahi.h>Data Structures | |
| struct | reqtags |
Macros | |
| #define | ID(a, b, c, d) |
| #define | LONGAT(p) |
| #define | WORDAT(p) |
| #define | MAXBODY 131071 |
| #define | LVO_OpenDevice (-444) |
| #define | LVO_DoIO (-456) |
| #define | LVO_SendIO (-462) |
| #define | LVO_AHI_AllocAudioRequestA (-120) |
| #define | LVO_AHI_AudioRequestA (-126) |
| #define | LVO_AHI_FreeAudioRequest (-132) |
| #define | MIN_AHI_VERSION 4 |
| #define | AHI_TAGBASE 0x80000000UL |
| #define | AHIR_SCREEN (AHI_TAGBASE + 201) |
| #define | AHIR_INITIALLEFTEDGE (AHI_TAGBASE + 240) |
| #define | AHIR_INITIALTOPEDGE (AHI_TAGBASE + 241) |
| #define | AHIR_INITIALWIDTH (AHI_TAGBASE + 242) |
| #define | AHIR_INITIALHEIGHT (AHI_TAGBASE + 243) |
| #define | AHIR_INITIALAUDIOID (AHI_TAGBASE + 244) |
| #define | AHIR_INITIALMIXFREQ (AHI_TAGBASE + 245) |
| #define | AHIR_DOMIXFREQ (AHI_TAGBASE + 260) |
| #define | reqcall(lvo, req) |
Functions | |
| void | risoundlib2_loadsounds (void) |
| void | risoundlib2_libinit (void) |
| void | risoundlib2_libfinit (void) |
| void | _OpenAHI (void) |
| void | _OpenAHI2 (void) |
| void | _CloseAHI (void) |
| void | _PlaySoundAHI (void) |
| void | _PlaySoundAHI1 (void) |
| void | _PlaySoundAHI2 (void) |
| void | _PlayRawAHI (void) |
| void | _PlayRawAHI1 (void) |
| void | _PlayRawAHI2 (void) |
| void | _AHIOutputRequest1 (void) |
| void | _AHIOutputRequest2 (void) |
| void | _AHIOutputRequest3 (void) |
| void | _AHIOutputRequest4 (void) |
| void | _AHIOutputRequest5 (void) |
| void | _AHIOutputRequest6 (void) |
| void | _AHIRequestedID (void) |
| void | _AHIRequestedFreq (void) |
| static ULONG | periodfreq (UWORD period) |
| The playing frequency of a sound object: 3579545 / its period (+4). | |
| static ULONG | c_libinit (void) |
| init: create the message port and the AHI request. | |
| static void | ahitakeback (void) |
| Take back the sound PlaySoundAHI sent: abort it if it still plays, then WaitIO (which also removes its reply from the port). | |
| static void | c_closeahi (void) |
| CloseAHI: stop a running sound, close ahi.device; the request and the port stay. | |
| static void | c_libfinit (void) |
| finit: close the device (c_closeahi()), delete the request and the port. | |
| BB_BOOL | c_openahi2 (ULONG unit, ULONG id) |
| OpenAHI unit,deviceID: open ahi.device with the library's request. | |
| BB_BOOL | c_openahi (ULONG unit) |
| OpenAHI unit: c_openahi2() with the device ID AHI_DEFAULT_ID. | |
| ULONG | c_playsound2 (ULONG vol, ULONG bal, struct bb_sound *obj) |
| PlaySoundAHI sound,volume,balance: play a sound object through ahi.device. | |
| ULONG | c_playsound1 (ULONG vol, struct bb_sound *obj) |
| PlaySoundAHI sound,volume: c_playsound2() with the balance centred (0x8000). | |
| ULONG | c_playsound (struct bb_sound *obj) |
| PlaySoundAHI sound: c_playsound2() with full volume (0x10000), centred. | |
| ULONG | c_playraw2 (ULONG data, ULONG len, ULONG freq, ULONG vol, ULONG bal) |
| PlayRawAHI address,length,frequency,volume,balance: play raw 8 bit data through ahi.device. | |
| ULONG | c_playraw1 (ULONG data, ULONG len, ULONG freq, ULONG vol) |
| PlayRawAHI address,length,frequency,volume: c_playraw2() centred (0x8000). | |
| ULONG | c_playraw (ULONG data, ULONG len, ULONG freq) |
| PlayRawAHI address,length,frequency: c_playraw2() at full volume, centred. | |
| ULONG | c_outreq6 (ULONG x, ULONG y, ULONG w, ULONG h, ULONG id, ULONG freq, const ULONG *scr) |
| AHIOutputRequest x,y,width,height,modeid,frequency: AHI's audio mode requester. | |
| ULONG | c_outreq1 (const ULONG *scr) |
| AHIOutputRequest: c_outreq6() with x, y, width, height -1 and mode id, frequency 0. | |
| ULONG | c_outreq2 (ULONG id, const ULONG *scr) |
| AHIOutputRequest modeid: c_outreq6() with x, y, width, height -1, frequency 0. | |
| ULONG | c_outreq3 (ULONG id, ULONG freq, const ULONG *scr) |
| AHIOutputRequest modeid,frequency: c_outreq6() with x, y, width, height -1. | |
| ULONG | c_outreq4 (ULONG x, ULONG y, ULONG w, ULONG h, const ULONG *scr) |
| AHIOutputRequest x,y,width,height: c_outreq6() with mode id and frequency 0. | |
| ULONG | c_outreq5 (ULONG x, ULONG y, ULONG w, ULONG h, ULONG id, const ULONG *scr) |
| AHIOutputRequest x,y,width,height,modeid: c_outreq6() with frequency 0. | |
| ULONG | c_requestedid (void) |
| AHIRequestedID: the audio mode id chosen in AHIOutputRequest. | |
| ULONG | c_requestedfreq (void) |
| AHIRequestedFreq: the mixing frequency chosen in AHIOutputRequest. | |
| static BB_BOOL | loadsounds_c (ULONG sound, UBYTE *sram, struct bb_sound *saddr) |
| CludgeSound sound#,address: make a sound object of an 8SVX file in memory. | |
Variables | |
| static struct reqtags | ahireqtags |
| static ULONG | reqaudioid = (ULONG)-1 |
| static ULONG | reqmixfreq |
| static ULONG | deviceunit |
| static ULONG | deviceid |
| static struct MsgPort * | ahimsgport |
| static struct AHIRequest * | ahiiorequest |
| static ULONG | ahidevice |
| static BOOL | ahisent |
| static struct Device * | ahibase |
| static char | ahiname [] = "ahi.device" |
| #define AHI_TAGBASE 0x80000000UL |
| #define AHIR_DOMIXFREQ (AHI_TAGBASE + 260) |
| #define AHIR_INITIALAUDIOID (AHI_TAGBASE + 244) |
| #define AHIR_INITIALHEIGHT (AHI_TAGBASE + 243) |
| #define AHIR_INITIALLEFTEDGE (AHI_TAGBASE + 240) |
| #define AHIR_INITIALMIXFREQ (AHI_TAGBASE + 245) |
| #define AHIR_INITIALTOPEDGE (AHI_TAGBASE + 241) |
| #define AHIR_INITIALWIDTH (AHI_TAGBASE + 242) |
| #define AHIR_SCREEN (AHI_TAGBASE + 201) |
| #define LONGAT | ( | p | ) |
| #define LVO_AHI_AllocAudioRequestA (-120) |
| #define LVO_AHI_AudioRequestA (-126) |
| #define LVO_AHI_FreeAudioRequest (-132) |
| #define LVO_DoIO (-456) |
| #define LVO_OpenDevice (-444) |
| #define LVO_SendIO (-462) |
| #define MAXBODY 131071 |
| #define MIN_AHI_VERSION 4 |
| #define reqcall | ( | lvo, | |
| req ) |
| #define WORDAT | ( | p | ) |
| void _AHIOutputRequest1 | ( | void | ) |
| void _AHIOutputRequest2 | ( | void | ) |
| void _AHIOutputRequest3 | ( | void | ) |
| void _AHIOutputRequest4 | ( | void | ) |
| void _AHIOutputRequest5 | ( | void | ) |
| void _AHIOutputRequest6 | ( | void | ) |
| void _AHIRequestedFreq | ( | void | ) |
| void _AHIRequestedID | ( | void | ) |
| void _CloseAHI | ( | void | ) |
| void _OpenAHI | ( | void | ) |
| void _OpenAHI2 | ( | void | ) |
| void _PlayRawAHI | ( | void | ) |
| void _PlayRawAHI1 | ( | void | ) |
| void _PlayRawAHI2 | ( | void | ) |
| void _PlaySoundAHI | ( | void | ) |
| void _PlaySoundAHI1 | ( | void | ) |
| void _PlaySoundAHI2 | ( | void | ) |
|
static |
Take back the sound PlaySoundAHI sent: abort it if it still plays, then WaitIO (which also removes its reply from the port).
Fixed (#933): the original sent its one request again without waiting for the one before or removing its reply, and finit left everything open while it was in use. Only a request this library sent with SendIO is waited for, so it never blocks on one the device never had.
|
static |
CloseAHI: stop a running sound, close ahi.device; the request and the port stay.
Fixed (#927): the original's CloseAHI was finit, which deleted the request and the port, so that a later OpenAHI used request 0. Nothing without a request. A sound that plays is aborted (fixed: #933, the original left everything open while the request was in use); CloseDevice if ahidevice is set (fixed: #924, never set in the original); then ahibase = 0.
|
static |
finit: close the device (c_closeahi()), delete the request and the port.
Nothing without the port; without a request (init could not make it) no CheckIO (fixed: #927, the original's CheckIO of address 0). A sound that plays is aborted first (fixed: #933). Then DeleteIORequest, DeleteMsgPort.
|
static |
init: create the message port and the AHI request.
CreateMsgPort, then CreateIORequest of a struct AHIRequest (80 bytes) on that port. Both are exec V36 calls: below exec V36 (Kickstart 1.x) port and request stay 0, and the commands fail (OpenAHI 0); fixed (#1139), the original called them there (offsets behind exec's jump table: a crash at the program's start). Port and request made before and not deleted by finit (CloseAHI keeps them, fixed: #927) stay.
| BB_BOOL c_openahi | ( | ULONG | unit | ) |
OpenAHI unit: c_openahi2() with the device ID AHI_DEFAULT_ID.
| unit | d0: the AHI unit |
| BB_BOOL c_openahi2 | ( | ULONG | unit, |
| ULONG | id ) |
OpenAHI unit,deviceID: open ahi.device with the library's request.
Sets ahir_Version to 4 (MIN_AHI_VERSION) and calls OpenDevice ("ahi.device", unit, request, 0); on success io_Device becomes the library base for the requester calls. The device ID is stored but not used. A second OpenAHI while it is open returns 0 (fixed: #924, the original never set ahidevice and opened the open request again). Fixed (#927): without a request (init could not make it) the result is 0; the original wrote ahir_Version to address 48 and passed request 0 to OpenDevice (also after CloseAHI, which deleted the request).
| unit | d0: the AHI unit |
| id | d1: the device (audio mode) ID, unused |
| ULONG c_outreq1 | ( | const ULONG * | scr | ) |
AHIOutputRequest: c_outreq6() with x, y, width, height -1 and mode id, frequency 0.
| scr | a0: the used screen object of screenslib (its first long the struct Screen), 0 without one (!libs screenslib,ua0) |
| ULONG c_outreq2 | ( | ULONG | id, |
| const ULONG * | scr ) |
AHIOutputRequest modeid: c_outreq6() with x, y, width, height -1, frequency 0.
The entry "AudioID" of the original, for the form with 1 argument (fixed: #928; the original gave it to the form with 4 arguments, x, y, width and height replaced by -1, the mode id whatever d4 held).
| id | d0: the mode id |
| scr | a0: the used screen object of screenslib (its first long the struct Screen), 0 without one (!libs screenslib,ua0) |
| ULONG c_outreq3 | ( | ULONG | id, |
| ULONG | freq, | ||
| const ULONG * | scr ) |
AHIOutputRequest modeid,frequency: c_outreq6() with x, y, width, height -1.
The entry "AudioID, Frequency" of the original, for the form with 2 arguments (fixed: #928; the original gave it to the form with 1 argument, which was lost, mode id and frequency whatever d4/d5 held).
| id | d0: the mode id |
| freq | d1: the frequency |
| scr | a0: the used screen object of screenslib (its first long the struct Screen), 0 without one (!libs screenslib,ua0) |
| ULONG c_outreq4 | ( | ULONG | x, |
| ULONG | y, | ||
| ULONG | w, | ||
| ULONG | h, | ||
| const ULONG * | scr ) |
AHIOutputRequest x,y,width,height: c_outreq6() with mode id and frequency 0.
The entry "X,Y,WIDTH,HEIGHT" of the original, for the form with 4 arguments (fixed: #928; the original gave it to the form with 2 arguments, width and height whatever d2/d3 held).
| x | d0: the left edge |
| y | d1: the top edge |
| w | d2: the width |
| h | d3: the height |
| scr | a0: the used screen object of screenslib (its first long the struct Screen), 0 without one (!libs screenslib,ua0) |
| ULONG c_outreq5 | ( | ULONG | x, |
| ULONG | y, | ||
| ULONG | w, | ||
| ULONG | h, | ||
| ULONG | id, | ||
| const ULONG * | scr ) |
AHIOutputRequest x,y,width,height,modeid: c_outreq6() with frequency 0.
| x | d0: the left edge |
| y | d1: the top edge |
| w | d2: the width |
| h | d3: the height |
| id | d4: the mode id |
| scr | a0: the used screen object of screenslib (its first long the struct Screen), 0 without one (!libs screenslib,ua0) |
| ULONG c_outreq6 | ( | ULONG | x, |
| ULONG | y, | ||
| ULONG | w, | ||
| ULONG | h, | ||
| ULONG | id, | ||
| ULONG | freq, | ||
| const ULONG * | scr ) |
AHIOutputRequest x,y,width,height,modeid,frequency: AHI's audio mode requester.
Writes the arguments into the data of the tag list's initial left edge, top edge, width, height, audio id and mix frequency (offsets 4, 12, 20, 28, 36, 44; fixed: #931, the original wrote the last four to 16, 20, 24, 28, over the tag ids of width and height), then AHIR_Screen = the struct Screen of the used screen object (its first long; 0 without one: AHI's default; fixed: #929, the original never set it), then AHI_AllocAudioRequestA and AHI_AudioRequestA (no tags). A confirmed requester's choice (ahiam_AudioID, ahiam_MixFreq) is kept for AHIRequestedID/AHIRequestedFreq (fixed: #934), and the requester is freed again (AHI_FreeAudioRequest; fixed: #930, the original allocated one per call and never freed one).
| x | d0: the initial left edge |
| y | d1: the initial top edge |
| w | d2: the initial width |
| h | d3: the initial height |
| id | d4: the initial audio mode id |
| freq | d5: the initial mixing frequency |
| scr | a0: the used screen object of screenslib (its first long the struct Screen), 0 without one (!libs screenslib,ua0) |
| ULONG c_playraw | ( | ULONG | data, |
| ULONG | len, | ||
| ULONG | freq ) |
| ULONG c_playraw1 | ( | ULONG | data, |
| ULONG | len, | ||
| ULONG | freq, | ||
| ULONG | vol ) |
| ULONG c_playraw2 | ( | ULONG | data, |
| ULONG | len, | ||
| ULONG | freq, | ||
| ULONG | vol, | ||
| ULONG | bal ) |
PlayRawAHI address,length,frequency,volume,balance: play raw 8 bit data through ahi.device.
Without ahi.device (ahidevice, fixed: #924 - the original never set it and never played) returns 0. Takes back a sound of PlaySoundAHI (fixed: #933), then CMD_WRITE as AHIST_M8S with ahir_Link 0 and priority 0 (fixed: #924) through DoIO: it returns when the data has been played (the data may be a temporary buffer).
| data | d0: the sample data |
| len | d1: its length in bytes |
| freq | d2: the frequency |
| vol | d3: the volume (Fixed 16.16) |
| bal | d4: the stereo position (Fixed) |
| ULONG c_playsound | ( | struct bb_sound * | obj | ) |
PlaySoundAHI sound: c_playsound2() with full volume (0x10000), centred.
| obj | a0: audiolib's sound object |
| ULONG c_playsound1 | ( | ULONG | vol, |
| struct bb_sound * | obj ) |
PlaySoundAHI sound,volume: c_playsound2() with the balance centred (0x8000).
| vol | d1: the volume (Fixed 16.16) |
| obj | a0: audiolib's sound object |
| ULONG c_playsound2 | ( | ULONG | vol, |
| ULONG | bal, | ||
| struct bb_sound * | obj ) |
PlaySoundAHI sound,volume,balance: play a sound object through ahi.device.
Without ahi.device (ahidevice, fixed: #924 - the original never set it and never played) returns 0. Takes back the sound sent before (abort if it still plays, WaitIO; fixed: #933), then CMD_WRITE of the sample as 8 bit mono (AHIST_M8S), the length in bytes = the object's length in words (+6) x 2 (fixed: #932), the frequency 3579545 / the object's period (fixed: #926), ahir_Link 0 and priority 0 (set for every write: the device trashes them, fixed: #924), through SendIO.
| vol | d1: the volume (Fixed 16.16, 0x10000 = full) |
| bal | d2: the stereo position (Fixed, 0x8000 = centre) |
| obj | a0: audiolib's sound object (!libs audiolib,ia0|pd0) |
| ULONG c_requestedfreq | ( | void | ) |
AHIRequestedFreq: the mixing frequency chosen in AHIOutputRequest.
The ahiam_MixFreq of the last confirmed requester, 0 before one (fixed: #934; the original returned the data of the initial tag AHIR_InitialMixFreq).
| ULONG c_requestedid | ( | void | ) |
AHIRequestedID: the audio mode id chosen in AHIOutputRequest.
The ahiam_AudioID of the last confirmed requester, -1 before one (fixed: #934; the original returned the data of the initial tag AHIR_InitialAudioID).
CludgeSound sound#,address: make a sound object of an 8SVX file in memory.
risoundlib's routine: checks "8SVX" at +8 and "VHDR" at +12, takes the rate from the VHDR, the period 3579545 / rate, finds the BODY among the first seven chunks, frees the object's old sample (memlib globfree; not DecodeSound's in-place "cL" data, fixed: #945; after the checks, the pointer cleared, fixed: #831) and copies the BODY to chip memory (memlib globalloc). Fixed (#926): nothing is written behind the 16 byte object (the original's rate at +16). Fixed (#925): mark (+14) is cleared again, as in risoundlib; Fixed (#832): the rate is samplesPerSec (VHDR data + 12); Fixed (#830): rate 0 gives 0; Fixed (#828): the chunk walk skips the pad bytes and stays inside the FORM; Fixed (#829): the whole BODY is copied, an empty one or one of 131072 bytes or more gives 0.
| sound | d0: sound# (its upper word goes into globfree's d0) |
| sram | d1: the 8SVX file in memory |
| saddr | a0: audiolib's sound object |
|
static |
The playing frequency of a sound object: 3579545 / its period (+4).
Fixed (#926): the original read the word +16 that CludgeSound wrote behind the object; the period works for every sound object (LoadSound, DecodeSound, InitSound, CludgeSound) and gives the pitch Sound plays. Two DIVU.w steps (a library cannot link the division of libgcc).
| period | the object's period |
| void risoundlib2_libfinit | ( | void | ) |
| void risoundlib2_libinit | ( | void | ) |
| void risoundlib2_loadsounds | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |