mirror of
https://github.com/stevenhowes/CTheEscape.git
synced 2026-05-26 15:53:29 +01:00
Very WIP PCM sound support
This commit is contained in:
@@ -2,4 +2,5 @@ Set TheEsc$Dir <Obey$Dir>
|
|||||||
IconSprites <TheEsc$Dir>.!Sprites
|
IconSprites <TheEsc$Dir>.!Sprites
|
||||||
WimpSlot -min 256k -max 256k
|
WimpSlot -min 256k -max 256k
|
||||||
Dir <TheEsc$Dir>
|
Dir <TheEsc$Dir>
|
||||||
|
RmEnsure DataVox 3.69 RmLoad <TheEsc$Dir>.DataVox
|
||||||
Run <TheEsc$Dir>.!RunImage
|
Run <TheEsc$Dir>.!RunImage
|
||||||
Binary file not shown.
Binary file not shown.
@@ -73,6 +73,10 @@ o.Intro: c.Intro
|
|||||||
o.Intro: h.Graphics
|
o.Intro: h.Graphics
|
||||||
o.Mission1: c.Mission1
|
o.Mission1: c.Mission1
|
||||||
o.Mission1: h.Graphics
|
o.Mission1: h.Graphics
|
||||||
|
o.Mission1: h.Sound
|
||||||
|
o.Mission1: C:h.swis
|
||||||
|
o.Mission1: C:h.kernel
|
||||||
|
o.Mission1: C:h.kernel
|
||||||
o.Mission2: c.Mission2
|
o.Mission2: c.Mission2
|
||||||
o.Mission2: h.Graphics
|
o.Mission2: h.Graphics
|
||||||
o.Mission2: C:h.swis
|
o.Mission2: C:h.swis
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
|
||||||
#define SKIP_INTRO
|
#define SKIP_INTRO
|
||||||
#define SKIP_MISSION1
|
//#define SKIP_MISSION1
|
||||||
//#define SKIP_MISSION2
|
//#define SKIP_MISSION2
|
||||||
|
|
||||||
// SWI Registers
|
// SWI Registers
|
||||||
@@ -51,6 +51,10 @@ void exitfunc () {
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
free(fontbuffer);
|
free(fontbuffer);
|
||||||
free(tilebuffer);
|
free(tilebuffer);
|
||||||
|
|
||||||
|
inreg.r[0] = 4;
|
||||||
|
inreg.r[1] = 0;
|
||||||
|
_kernel_swi (DataVox_Unset, &inreg, &outreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|||||||
+37
-1
@@ -1,4 +1,7 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "Sound.h"
|
||||||
|
#include "swis.h"
|
||||||
|
#include <kernel.h>
|
||||||
|
|
||||||
#define PLAYER_Y_START 100
|
#define PLAYER_Y_START 100
|
||||||
#define PLAYER_X_SPEED 10
|
#define PLAYER_X_SPEED 10
|
||||||
@@ -11,6 +14,9 @@
|
|||||||
extern sound_composition_save(char *filename);
|
extern sound_composition_save(char *filename);
|
||||||
extern sound_composition_load(char *filename);
|
extern sound_composition_load(char *filename);
|
||||||
|
|
||||||
|
extern _kernel_swi_regs inreg;
|
||||||
|
extern _kernel_swi_regs outreg;
|
||||||
|
|
||||||
enum sprite_e{player_ship, durno_ship, ship_trgt, durno_ship2, ship2_trgt, player_shipl,player_shipr,explode_start,explode_shp2,explode_shp3,explode_end,photon1,photon2,plasma1,plasma2};
|
enum sprite_e{player_ship, durno_ship, ship_trgt, durno_ship2, ship2_trgt, player_shipl,player_shipr,explode_start,explode_shp2,explode_shp3,explode_end,photon1,photon2,plasma1,plasma2};
|
||||||
char *sprites[] = {"player_ship","durno_ship","ship_trgt","durno_ship2","ship2_trgt","player_shipl","player_shipr","explode_shp1","explode_shp2","explode_shp3","explode_shp4","photon1","photon2","plasma1","plasma2"};
|
char *sprites[] = {"player_ship","durno_ship","ship_trgt","durno_ship2","ship2_trgt","player_shipl","player_shipr","explode_shp1","explode_shp2","explode_shp3","explode_shp4","photon1","photon2","plasma1","plasma2"};
|
||||||
|
|
||||||
@@ -140,6 +146,12 @@ void game_spawn_projectile(int id, int Px, int Py, int Vx, int Vy, enum sprite_e
|
|||||||
Projectiles[id].nextframe = tick + 10;
|
Projectiles[id].nextframe = tick + 10;
|
||||||
Projectiles[id].damage = damage;
|
Projectiles[id].damage = damage;
|
||||||
Projectiles[id].collidable = 1;
|
Projectiles[id].collidable = 1;
|
||||||
|
// Play it
|
||||||
|
inreg.r[0] = 4;
|
||||||
|
inreg.r[1] = -15;
|
||||||
|
inreg.r[2] = 1;
|
||||||
|
inreg.r[3] = 1;
|
||||||
|
_kernel_swi (Sound_Control, &inreg, &outreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -785,7 +797,31 @@ void game_setup_audio()
|
|||||||
sound_set_voice(1,"WaveSynth-Beep");
|
sound_set_voice(1,"WaveSynth-Beep");
|
||||||
sound_set_voice(2,"Percussion-Noise");
|
sound_set_voice(2,"Percussion-Noise");
|
||||||
sound_set_voice(3,"Percussion-Soft");
|
sound_set_voice(3,"Percussion-Soft");
|
||||||
sound_set_voice(4,"Percussion-Noise");
|
sound_set_voice(4,"DataVox-Voice");
|
||||||
|
sound_pcm_loadsample("sounds.torpedo");
|
||||||
|
|
||||||
|
|
||||||
|
inreg.r[0] = 4;
|
||||||
|
inreg.r[1] = (int) audiobuffer;
|
||||||
|
inreg.r[2] = (int) audiobuffer + 20000;
|
||||||
|
_kernel_swi (DataVox_SetMemory, &inreg, &outreg);
|
||||||
|
|
||||||
|
// Unsigned 8-bit PCM
|
||||||
|
inreg.r[0] = 4;
|
||||||
|
inreg.r[1] = 1;
|
||||||
|
_kernel_swi (DataVox_Type, &inreg, &outreg);
|
||||||
|
|
||||||
|
// Not timed
|
||||||
|
inreg.r[0] = 4;
|
||||||
|
inreg.r[1] = 0;
|
||||||
|
_kernel_swi (DataVox_Timed, &inreg, &outreg);
|
||||||
|
|
||||||
|
// Bitrate
|
||||||
|
inreg.r[0] = 4;
|
||||||
|
inreg.r[1] = 4000; // I was expecting this to be 125 to 8KHz but.... No idea
|
||||||
|
_kernel_swi (DataVox_Pitch, &inreg, &outreg);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_draw_hud()
|
void game_draw_hud()
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ void game2_setup()
|
|||||||
game2_loadmap("m2_map");
|
game2_loadmap("m2_map");
|
||||||
game2_loadsmarttiles("m2_smart");
|
game2_loadsmarttiles("m2_smart");
|
||||||
game2_loadareanames("m2_areas");
|
game2_loadareanames("m2_areas");
|
||||||
|
|
||||||
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
|
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ int composition_startcent = -1;
|
|||||||
|
|
||||||
struct CompositionElement composition[COMPOSITION_MAX];
|
struct CompositionElement composition[COMPOSITION_MAX];
|
||||||
|
|
||||||
|
unsigned char audiobuffer[20000];
|
||||||
|
|
||||||
char *notes[] = {"AX","A#","BX","CX","C#","DX","D#","EX","FX","F#","GX","G#"};
|
char *notes[] = {"AX","A#","BX","CX","C#","DX","D#","EX","FX","F#","GX","G#"};
|
||||||
|
|
||||||
void sound_on()
|
void sound_on()
|
||||||
@@ -195,3 +197,36 @@ int sound_composition_incomplete()
|
|||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sound_pcm_loadsample(char* filename)
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
|
||||||
|
memset(audiobuffer,0x00,20000);
|
||||||
|
|
||||||
|
// Attempt to get file info
|
||||||
|
inreg.r[0] = 5;
|
||||||
|
inreg.r[1] = (int) filename;
|
||||||
|
_kernel_swi(OS_File,&inreg,&outreg);
|
||||||
|
|
||||||
|
// Length will be in R4 if it exists
|
||||||
|
length = outreg.r[4];
|
||||||
|
|
||||||
|
if(length > sizeof(audiobuffer))
|
||||||
|
{
|
||||||
|
screen_nobuffer();
|
||||||
|
while (1)
|
||||||
|
printf("Sample exceeds %d bytes (%d bytes) object type is %d\n",sizeof(audiobuffer),length,outreg.r[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to get file info
|
||||||
|
inreg.r[0] = 16;
|
||||||
|
inreg.r[1] = (int) filename;
|
||||||
|
inreg.r[2] = (int) audiobuffer;
|
||||||
|
inreg.r[3] = 0;
|
||||||
|
|
||||||
|
_kernel_swi(OS_File,&inreg,&outreg);
|
||||||
|
|
||||||
|
// Fill remainder of array with final byte
|
||||||
|
memset(audiobuffer + length,audiobuffer[length-1],sizeof(audiobuffer)-length);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,42 @@
|
|||||||
#define COMPOSITION_MAX 128
|
#define COMPOSITION_MAX 128
|
||||||
|
|
||||||
|
#define DataVox_Type 0x44380
|
||||||
|
#define DataVox_Timed 0x44381
|
||||||
|
#define DataVox_Pitch 0x44382
|
||||||
|
#define DataVox_ReadPitch 0x44383
|
||||||
|
#define DataVox_ReadTimer 0x44384
|
||||||
|
#define DataVox_ReadType 0x44385
|
||||||
|
#define DataVox_SetMemory 0x44386
|
||||||
|
#define DataVox_ReadMemory 0x44387
|
||||||
|
#define DataVox_ReadAddress 0x44388
|
||||||
|
#define DataVox_SetRepeat 0x44389
|
||||||
|
#define DataVox_ReadRepeat 0x4438A
|
||||||
|
#define DataVox_SetReverse 0x4438B
|
||||||
|
#define DataVox_ReadReverse 0x4438C
|
||||||
|
#define DataVox_PitchToSample 0x4438D
|
||||||
|
#define DataVox_SampleToPitch 0x4438E
|
||||||
|
#define DataVox_Duplicate 0x4438F
|
||||||
|
#define DataVox_Unset 0x44390
|
||||||
|
#define DataVox_ConvertByte 0x44391
|
||||||
|
#define DataVox_ReadBufferFlag 0x44392
|
||||||
|
#define DataVox_AllocateChannel 0x44393
|
||||||
|
#define DataVox_DeAllocateChannel 0x44394
|
||||||
|
#define DataVox_RequestChannel 0x44395
|
||||||
|
#define DataVox_ChannelsFree 0x44396
|
||||||
|
#define DataVox_ConvertArea 0x44397
|
||||||
|
#define DataVox_ChannelFreeMap 0x44398
|
||||||
|
#define DataVox_UpCallHandler 0x44399
|
||||||
|
#define DataVox_FlushKeys 0x4439A
|
||||||
|
#define DataVox_VoiceActive 0x4439B
|
||||||
|
#define DataVox_SystemSpeed 0x4439C
|
||||||
|
#define DataVox_Version 0x4439D
|
||||||
|
#define DataVox_SlaveChannel 0x4439E
|
||||||
|
#define DataVox_ReadMaster 0x4439F
|
||||||
|
#define DataVox_ReadUpCallStatus 0x443A0
|
||||||
|
#define DataVox_SetUpCallStatus 0x443A1
|
||||||
|
#define DataVox_AdjustMemory 0x443A2
|
||||||
|
#define DataVox_SetInternalPitch 0x443A3
|
||||||
|
|
||||||
struct CompositionElement {
|
struct CompositionElement {
|
||||||
signed short int Start;
|
signed short int Start;
|
||||||
unsigned char Note;
|
unsigned char Note;
|
||||||
@@ -8,3 +45,5 @@ struct CompositionElement {
|
|||||||
/*unsigned char word alignment*/
|
/*unsigned char word alignment*/
|
||||||
unsigned short int Length;
|
unsigned short int Length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern unsigned char audiobuffer[20000];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user