Updated lazyusf, mostly (unused by this plugin) HLE audio code

CQTexperiment
Chris Moeller 2014-04-02 17:54:43 -07:00
parent 299704cc24
commit e6da9d6db7
14 changed files with 423 additions and 383 deletions

View File

@ -10,17 +10,13 @@
8378416A18C6E56B002C4FE5 /* alist.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378415418C6E56B002C4FE5 /* alist.c */; };
8378416B18C6E56B002C4FE5 /* alist.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378415518C6E56B002C4FE5 /* alist.h */; };
8378416C18C6E56B002C4FE5 /* alist_audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378415618C6E56B002C4FE5 /* alist_audio.c */; };
8378416D18C6E56B002C4FE5 /* alist_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378415718C6E56B002C4FE5 /* alist_internal.h */; };
8378416E18C6E56B002C4FE5 /* alist_naudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378415818C6E56B002C4FE5 /* alist_naudio.c */; };
8378416F18C6E56B002C4FE5 /* alist_nead.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378415918C6E56B002C4FE5 /* alist_nead.c */; };
8378417018C6E56B002C4FE5 /* arithmetics.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378415A18C6E56B002C4FE5 /* arithmetics.h */; };
8378417318C6E56B002C4FE5 /* cicx105.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378415D18C6E56B002C4FE5 /* cicx105.c */; };
8378417418C6E56B002C4FE5 /* cicx105.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378415E18C6E56B002C4FE5 /* cicx105.h */; };
8378417518C6E56B002C4FE5 /* jpeg.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378415F18C6E56B002C4FE5 /* jpeg.c */; };
8378417618C6E56B002C4FE5 /* jpeg.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378416018C6E56B002C4FE5 /* jpeg.h */; };
8378417B18C6E56B002C4FE5 /* mp3.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378416518C6E56B002C4FE5 /* mp3.c */; };
8378417C18C6E56B002C4FE5 /* musyx.c in Sources */ = {isa = PBXBuildFile; fileRef = 8378416618C6E56B002C4FE5 /* musyx.c */; };
8378417D18C6E56B002C4FE5 /* musyx.h in Headers */ = {isa = PBXBuildFile; fileRef = 8378416718C6E56B002C4FE5 /* musyx.h */; };
837841C018C847B2002C4FE5 /* audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 837841B818C847B2002C4FE5 /* audio.c */; };
837841C118C847B2002C4FE5 /* audio.h in Headers */ = {isa = PBXBuildFile; fileRef = 837841B918C847B2002C4FE5 /* audio.h */; };
837841C418C847B2002C4FE5 /* memory.c in Sources */ = {isa = PBXBuildFile; fileRef = 837841BC18C847B2002C4FE5 /* memory.c */; };
@ -110,23 +106,20 @@
83C8B6F818AF58090071B040 /* usf_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6A818AF58080071B040 /* usf_internal.h */; };
83C8B6F918AF58090071B040 /* usf.c in Sources */ = {isa = PBXBuildFile; fileRef = 83C8B6A918AF58080071B040 /* usf.c */; };
83C8B6FA18AF58090071B040 /* usf.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8B6AA18AF58080071B040 /* usf.h */; settings = {ATTRIBUTES = (Public, ); }; };
83FBECBA18ECE86B00311448 /* ucodes.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FBECB918ECE86B00311448 /* ucodes.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
8378415418C6E56B002C4FE5 /* alist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = alist.c; sourceTree = "<group>"; };
8378415518C6E56B002C4FE5 /* alist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alist.h; sourceTree = "<group>"; };
8378415618C6E56B002C4FE5 /* alist_audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = alist_audio.c; sourceTree = "<group>"; };
8378415718C6E56B002C4FE5 /* alist_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alist_internal.h; sourceTree = "<group>"; };
8378415818C6E56B002C4FE5 /* alist_naudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = alist_naudio.c; sourceTree = "<group>"; };
8378415918C6E56B002C4FE5 /* alist_nead.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = alist_nead.c; sourceTree = "<group>"; };
8378415A18C6E56B002C4FE5 /* arithmetics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = arithmetics.h; sourceTree = "<group>"; };
8378415D18C6E56B002C4FE5 /* cicx105.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cicx105.c; sourceTree = "<group>"; };
8378415E18C6E56B002C4FE5 /* cicx105.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cicx105.h; sourceTree = "<group>"; };
8378415F18C6E56B002C4FE5 /* jpeg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = jpeg.c; sourceTree = "<group>"; };
8378416018C6E56B002C4FE5 /* jpeg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jpeg.h; sourceTree = "<group>"; };
8378416518C6E56B002C4FE5 /* mp3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mp3.c; sourceTree = "<group>"; };
8378416618C6E56B002C4FE5 /* musyx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = musyx.c; sourceTree = "<group>"; };
8378416718C6E56B002C4FE5 /* musyx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = musyx.h; sourceTree = "<group>"; };
837841B818C847B2002C4FE5 /* audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = audio.c; sourceTree = "<group>"; };
837841B918C847B2002C4FE5 /* audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio.h; sourceTree = "<group>"; };
837841BC18C847B2002C4FE5 /* memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = memory.c; sourceTree = "<group>"; };
@ -218,6 +211,7 @@
83C8B6A918AF58080071B040 /* usf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = usf.c; sourceTree = "<group>"; };
83C8B6AA18AF58080071B040 /* usf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = usf.h; sourceTree = "<group>"; };
83C8B6FD18AF59E70071B040 /* lazyusf-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "lazyusf-Info.plist"; sourceTree = "<group>"; };
83FBECB918ECE86B00311448 /* ucodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ucodes.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -234,6 +228,7 @@
8378415318C6E56B002C4FE5 /* rsp_hle */ = {
isa = PBXGroup;
children = (
83FBECB918ECE86B00311448 /* ucodes.h */,
83A2248E18CAC28500FE4173 /* hle_external.h */,
83A2248F18CAC28500FE4173 /* hle_internal.h */,
83A2249018CAC28500FE4173 /* hle.c */,
@ -246,17 +241,13 @@
8378415418C6E56B002C4FE5 /* alist.c */,
8378415518C6E56B002C4FE5 /* alist.h */,
8378415618C6E56B002C4FE5 /* alist_audio.c */,
8378415718C6E56B002C4FE5 /* alist_internal.h */,
8378415818C6E56B002C4FE5 /* alist_naudio.c */,
8378415918C6E56B002C4FE5 /* alist_nead.c */,
8378415A18C6E56B002C4FE5 /* arithmetics.h */,
8378415D18C6E56B002C4FE5 /* cicx105.c */,
8378415E18C6E56B002C4FE5 /* cicx105.h */,
8378415F18C6E56B002C4FE5 /* jpeg.c */,
8378416018C6E56B002C4FE5 /* jpeg.h */,
8378416518C6E56B002C4FE5 /* mp3.c */,
8378416618C6E56B002C4FE5 /* musyx.c */,
8378416718C6E56B002C4FE5 /* musyx.h */,
);
path = rsp_hle;
sourceTree = "<group>";
@ -298,8 +289,8 @@
children = (
8378415318C6E56B002C4FE5 /* rsp_hle */,
83C8B6FD18AF59E70071B040 /* lazyusf-Info.plist */,
83C8B65918AF58080071B040 /* audio.c */,
83C8B65A18AF58080071B040 /* audio.h */,
83C8B65918AF58080071B040 /* audio.c */,
83C8B65B18AF58080071B040 /* config.h */,
83C8B65C18AF58080071B040 /* cpu.c */,
83C8B65D18AF58080071B040 /* cpu.h */,
@ -415,9 +406,7 @@
files = (
83C8B6FA18AF58090071B040 /* usf.h in Headers */,
83C8B6AC18AF58080071B040 /* audio.h in Headers */,
8378416D18C6E56B002C4FE5 /* alist_internal.h in Headers */,
837841C118C847B2002C4FE5 /* audio.h in Headers */,
8378417618C6E56B002C4FE5 /* jpeg.h in Headers */,
83C8B6B118AF58080071B040 /* dma.h in Headers */,
83A2249518CAC28500FE4173 /* hle.h in Headers */,
83C8B6AD18AF58080071B040 /* config.h in Headers */,
@ -452,7 +441,6 @@
83C8B6D218AF58080071B040 /* vge.h in Headers */,
83C8B6C518AF58080071B040 /* su.h in Headers */,
83C8B6C218AF58080071B040 /* execute.h in Headers */,
8378417418C6E56B002C4FE5 /* cicx105.h in Headers */,
83C8B6E518AF58080071B040 /* vnop.h in Headers */,
83C8B6E418AF58080071B040 /* vne.h in Headers */,
83C8B6D418AF58080071B040 /* vmacf.h in Headers */,
@ -466,7 +454,6 @@
83C8B6D018AF58080071B040 /* vcr.h in Headers */,
8378416B18C6E56B002C4FE5 /* alist.h in Headers */,
83C8B6EA18AF58090071B040 /* vrcph.h in Headers */,
8378417D18C6E56B002C4FE5 /* musyx.h in Headers */,
83C8B6F818AF58090071B040 /* usf_internal.h in Headers */,
83C8B6EE18AF58090071B040 /* vrsql.h in Headers */,
83C8B6D118AF58080071B040 /* veq.h in Headers */,
@ -478,6 +465,7 @@
83C8B6DA18AF58080071B040 /* vmadn.h in Headers */,
83C8B6E218AF58080071B040 /* vmulu.h in Headers */,
83C8B6CC18AF58080071B040 /* vaddc.h in Headers */,
83FBECBA18ECE86B00311448 /* ucodes.h in Headers */,
83C8B6D518AF58080071B040 /* vmacq.h in Headers */,
83C8B6C418AF58080071B040 /* rsp.h in Headers */,
83C8B6E918AF58080071B040 /* vrcp.h in Headers */,

View File

@ -29,7 +29,7 @@
#include <stdint.h>
#include <string.h>
#include "alist_internal.h"
#include "alist.h"
#include "arithmetics.h"
#include "audio.h"
#include "hle_external.h"
@ -56,6 +56,17 @@ static int16_t* sample(struct hle_t* hle, unsigned pos)
return (int16_t*)hle->alist_buffer + (pos ^ S);
}
static uint8_t* alist_u8(struct hle_t* hle, uint16_t dmem)
{
return u8(hle->alist_buffer, dmem);
}
static int16_t* alist_s16(struct hle_t* hle, uint16_t dmem)
{
return (int16_t*)u16(hle->alist_buffer, dmem);
}
static void sample_mix(int16_t* dst, int16_t src, int16_t gain)
{
*dst = clamp_s16(*dst + ((src * gain) >> 15));
@ -139,7 +150,7 @@ void alist_set_address(struct hle_t* hle, uint32_t so, uint32_t *segments, size_
void alist_clear(struct hle_t* hle, uint16_t dmem, uint16_t count)
{
while(count != 0) {
hle->alist_buffer[(dmem++)^S8] = 0;
*alist_u8(hle, dmem++) = 0;
--count;
}
}
@ -165,7 +176,7 @@ void alist_save(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t cou
void alist_move(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count)
{
while (count != 0) {
hle->alist_buffer[(dmemo++)^S8] = hle->alist_buffer[(dmemi++)^S8];
*alist_u8(hle, dmemo++) = *alist_u8(hle, dmemi++);
--count;
}
}
@ -173,7 +184,7 @@ void alist_move(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t coun
void alist_copy_every_other_sample(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count)
{
while (count != 0) {
*(uint16_t*)(hle->alist_buffer + (dmemo^S8)) = *(uint16_t*)(hle->alist_buffer + (dmemi^S8));
*alist_s16(hle, dmemo) = *alist_s16(hle, dmemi);
dmemo += 2;
dmemi += 4;
--count;
@ -349,6 +360,85 @@ void alist_envmix_exp(
memcpy(hle->dram + address, (uint8_t *)save_buffer, 80);
}
void alist_envmix_ge(
struct hle_t* hle,
bool init,
bool aux,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address)
{
unsigned k;
size_t n = (aux) ? 4 : 2;
const int16_t* const in = (int16_t*)(hle->alist_buffer + dmemi);
int16_t* const dl = (int16_t*)(hle->alist_buffer + dmem_dl);
int16_t* const dr = (int16_t*)(hle->alist_buffer + dmem_dr);
int16_t* const wl = (int16_t*)(hle->alist_buffer + dmem_wl);
int16_t* const wr = (int16_t*)(hle->alist_buffer + dmem_wr);
struct ramp_t ramps[2];
short save_buffer[40];
if (init) {
ramps[0].value = (vol[0] << 16);
ramps[1].value = (vol[1] << 16);
ramps[0].target = (target[0] << 16);
ramps[1].target = (target[1] << 16);
ramps[0].step = rate[0];
ramps[1].step = rate[1];
} else {
memcpy((uint8_t *)save_buffer, (hle->dram + address), 80);
wet = *(int16_t *)(save_buffer + 0); /* 0-1 */
dry = *(int16_t *)(save_buffer + 2); /* 2-3 */
ramps[0].target = *(int32_t *)(save_buffer + 4); /* 4-5 */
ramps[1].target = *(int32_t *)(save_buffer + 6); /* 6-7 */
ramps[0].step = *(int32_t *)(save_buffer + 8); /* 8-9 (save_buffer is a 16bit pointer) */
ramps[1].step = *(int32_t *)(save_buffer + 10); /* 10-11 */
/* *(int32_t *)(save_buffer + 12);*/ /* 12-13 */
/* *(int32_t *)(save_buffer + 14);*/ /* 14-15 */
ramps[0].value = *(int32_t *)(save_buffer + 16); /* 12-13 */
ramps[1].value = *(int32_t *)(save_buffer + 18); /* 14-15 */
}
count >>= 1;
for (k = 0; k < count; ++k) {
int16_t gains[4];
int16_t* buffers[4];
int16_t l_vol = ramp_step(&ramps[0]);
int16_t r_vol = ramp_step(&ramps[1]);
buffers[0] = dl + (k^S);
buffers[1] = dr + (k^S);
buffers[2] = wl + (k^S);
buffers[3] = wr + (k^S);
gains[0] = clamp_s16((l_vol * dry + 0x4000) >> 15);
gains[1] = clamp_s16((r_vol * dry + 0x4000) >> 15);
gains[2] = clamp_s16((l_vol * wet + 0x4000) >> 15);
gains[3] = clamp_s16((r_vol * wet + 0x4000) >> 15);
alist_envmix_mix(n, buffers, gains, in[k^S]);
}
*(int16_t *)(save_buffer + 0) = wet; /* 0-1 */
*(int16_t *)(save_buffer + 2) = dry; /* 2-3 */
*(int32_t *)(save_buffer + 4) = ramps[0].target; /* 4-5 */
*(int32_t *)(save_buffer + 6) = ramps[1].target; /* 6-7 */
*(int32_t *)(save_buffer + 8) = ramps[0].step; /* 8-9 (save_buffer is a 16bit pointer) */
*(int32_t *)(save_buffer + 10) = ramps[1].step; /* 10-11 */
/**(int32_t *)(save_buffer + 12);*/ /* 12-13 */
/**(int32_t *)(save_buffer + 14);*/ /* 14-15 */
*(int32_t *)(save_buffer + 16) = ramps[0].value; /* 12-13 */
*(int32_t *)(save_buffer + 18) = ramps[1].value; /* 14-15 */
memcpy(hle->dram + address, (uint8_t *)save_buffer, 80);
}
void alist_envmix_lin(
struct hle_t* hle,
bool init,
@ -627,7 +717,7 @@ static unsigned int adpcm_predict_frame_4bits(struct hle_t* hle,
unsigned int rshift = (scale < 12) ? 12 - scale : 0;
for(i = 0; i < 8; ++i) {
uint8_t byte = hle->alist_buffer[(dmemi++)^S8];
uint8_t byte = *alist_u8(hle, dmemi++);
*(dst++) = adpcm_predict_sample(byte, 0xf0, 8, rshift);
*(dst++) = adpcm_predict_sample(byte, 0x0f, 12, rshift);
@ -643,7 +733,7 @@ static unsigned int adpcm_predict_frame_2bits(struct hle_t* hle,
unsigned int rshift = (scale < 14) ? 14 - scale : 0;
for(i = 0; i < 4; ++i) {
uint8_t byte = hle->alist_buffer[(dmemi++)^S8];
uint8_t byte = *alist_u8(hle, dmemi++);
*(dst++) = adpcm_predict_sample(byte, 0xc0, 8, rshift);
*(dst++) = adpcm_predict_sample(byte, 0x30, 10, rshift);
@ -681,11 +771,11 @@ void alist_adpcm(
dram_load_u16(hle, (uint16_t*)last_frame, (loop) ? loop_address : last_frame_address, 16);
for(i = 0; i < 16; ++i, dmemo += 2)
*(int16_t*)(hle->alist_buffer + (dmemo ^ S16)) = last_frame[i];
*alist_s16(hle, dmemo) = last_frame[i];
while (count != 0) {
int16_t frame[16];
uint8_t code = hle->alist_buffer[(dmemi++)^S8];
uint8_t code = *alist_u8(hle, dmemi++);
unsigned char scale = (code & 0xf0) >> 4;
const int16_t* const cb_entry = codebook + ((code & 0xf) << 4);
@ -695,7 +785,7 @@ void alist_adpcm(
adpcm_compute_residuals(last_frame + 8, frame + 8, cb_entry, last_frame + 6 , 8);
for(i = 0; i < 16; ++i, dmemo += 2)
*(int16_t*)(hle->alist_buffer + (dmemo ^ S16)) = last_frame[i];
*alist_s16(hle, dmemo) = last_frame[i];
count -= 32;
}
@ -858,9 +948,8 @@ void alist_polef(
{
int16_t frame[8];
for(i = 0; i < 8; ++i, dmemi += 2) {
frame[i] = *(int16_t*)(hle->alist_buffer + (dmemi ^ S16));
}
for(i = 0; i < 8; ++i, dmemi += 2)
frame[i] = *alist_s16(hle, dmemi);
for(i = 0; i < 8; ++i) {
int32_t accu = frame[i] * gain;

View File

@ -19,107 +19,146 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef ALIST_H
#define ALIST_H
#ifndef ALIST_INTERNAL_H
#define ALIST_INTERNAL_H
#ifndef _MSC_VER
#include <stdbool.h>
#else
#include "mystdbool.h"
#endif
#include <stdint.h>
enum { N_SEGMENTS = 16 };
/* alist_audio state */
struct alist_audio_t {
/* segments */
uint32_t segments[N_SEGMENTS];
/* main buffers */
uint16_t in;
uint16_t out;
uint16_t count;
/* auxiliary buffers */
uint16_t dry_right;
uint16_t wet_left;
uint16_t wet_right;
/* gains */
int16_t dry;
int16_t wet;
/* envelopes (0:left, 1:right) */
int16_t vol[2];
int16_t target[2];
int32_t rate[2];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
};
/* alist_naudio state */
struct alist_naudio_t {
/* gains */
int16_t dry;
int16_t wet;
/* envelopes (0:left, 1:right) */
int16_t vol[2];
int16_t target[2];
int32_t rate[2];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
};
/* alist_nead state */
struct alist_nead_t {
/* main buffers */
uint16_t in;
uint16_t out;
uint16_t count;
/* envmixer ramps */
uint16_t env_values[3];
uint16_t env_steps[3];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
/* filter audio command state */
uint16_t filter_count;
uint32_t filter_lut_address[2];
};
#include <stddef.h>
struct hle_t;
void alist_process_audio (struct hle_t* hle);
void alist_process_audio_ge(struct hle_t* hle);
void alist_process_audio_bc(struct hle_t* hle);
typedef void (*acmd_callback_t)(struct hle_t* hle, uint32_t w1, uint32_t w2);
void alist_process_nead_mk (struct hle_t* hle);
void alist_process_nead_sfj (struct hle_t* hle);
void alist_process_nead_sf (struct hle_t* hle);
void alist_process_nead_fz (struct hle_t* hle);
void alist_process_nead_wrjb(struct hle_t* hle);
void alist_process_nead_ys (struct hle_t* hle);
void alist_process_nead_1080(struct hle_t* hle);
void alist_process_nead_oot (struct hle_t* hle);
void alist_process_nead_mm (struct hle_t* hle);
void alist_process_nead_mmb (struct hle_t* hle);
void alist_process_nead_ac (struct hle_t* hle);
void alist_process(struct hle_t* hle, const acmd_callback_t abi[], unsigned int abi_size);
uint32_t alist_get_address(struct hle_t* hle, uint32_t so, const uint32_t *segments, size_t n);
void alist_set_address(struct hle_t* hle, uint32_t so, uint32_t *segments, size_t n);
void alist_clear(struct hle_t* hle, uint16_t dmem, uint16_t count);
void alist_load(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count);
void alist_save(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count);
void alist_move(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_copy_every_other_sample(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_repeat64(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint8_t count);
void alist_copy_blocks(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t block_size, uint8_t count);
void alist_interleave(struct hle_t* hle, uint16_t dmemo, uint16_t left, uint16_t right, uint16_t count);
void alist_process_naudio (struct hle_t* hle);
void alist_process_naudio_bk (struct hle_t* hle);
void alist_process_naudio_dk (struct hle_t* hle);
void alist_process_naudio_mp3 (struct hle_t* hle);
void alist_process_naudio_cbfd(struct hle_t* hle);
void alist_envmix_exp(
struct hle_t* hle,
bool init,
bool aux,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_ge(
struct hle_t* hle,
bool init,
bool aux,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_lin(
struct hle_t* hle,
bool init,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_nead(
struct hle_t* hle,
bool swap_wet_LR,
uint16_t dmem_dl,
uint16_t dmem_dr,
uint16_t dmem_wl,
uint16_t dmem_wr,
uint16_t dmemi,
unsigned count,
uint16_t *env_values,
uint16_t *env_steps,
const int16_t *xors);
void alist_mix(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count, int16_t gain);
void alist_multQ44(struct hle_t* hle, uint16_t dmem, uint16_t count, int8_t gain);
void alist_add(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_adpcm(
struct hle_t* hle,
bool init,
bool loop,
bool two_bit_per_sample,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
const int16_t* codebook,
uint32_t loop_address,
uint32_t last_frame_address);
void alist_resample(
struct hle_t* hle,
bool init,
bool flag2,
uint16_t dmemo, uint16_t dmemi, uint16_t count,
uint32_t pitch, uint32_t address);
void alist_resample_zoh(
struct hle_t* hle,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
uint32_t pitch,
uint32_t pitch_accu);
void alist_filter(
struct hle_t* hle,
uint16_t dmem,
uint16_t count,
uint32_t address,
const uint32_t* lut_address);
void alist_polef(
struct hle_t* hle,
bool init,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
uint16_t gain,
int16_t* table,
uint32_t address);
/*
* Audio flags
*/
#define A_INIT 0x01
#define A_CONTINUE 0x00
#define A_LOOP 0x02
#define A_OUT 0x02
#define A_LEFT 0x02
#define A_RIGHT 0x00
#define A_VOL 0x04
#define A_RATE 0x00
#define A_AUX 0x08
#define A_NOAUX 0x00
#define A_MAIN 0x00
#define A_MIX 0x10
#endif

View File

@ -29,7 +29,7 @@
#include <stdint.h>
#include <string.h>
#include "alist_internal.h"
#include "alist.h"
#include "hle_internal.h"
#include "memory.h"
@ -86,6 +86,25 @@ static void ENVMIXER(struct hle_t* hle, uint32_t w1, uint32_t w2)
address);
}
static void ENVMIXER_GE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
uint32_t address = get_address(hle, w2);
alist_envmix_ge(
hle,
flags & A_INIT,
flags & A_AUX,
hle->alist_audio.out, hle->alist_audio.dry_right,
hle->alist_audio.wet_left, hle->alist_audio.wet_right,
hle->alist_audio.in, hle->alist_audio.count,
hle->alist_audio.dry, hle->alist_audio.wet,
hle->alist_audio.vol,
hle->alist_audio.target,
hle->alist_audio.rate,
address);
}
static void RESAMPLE(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
uint8_t flags = (w1 >> 16);
@ -265,9 +284,8 @@ void alist_process_audio(struct hle_t* hle)
void alist_process_audio_ge(struct hle_t* hle)
{
/* TODO: see what differs from alist_process_audio */
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER,
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER_GE,
LOADBUFF, RESAMPLE, SAVEBUFF, SEGMENT,
SETBUFF, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, POLEF, SETLOOP
@ -279,9 +297,8 @@ void alist_process_audio_ge(struct hle_t* hle)
void alist_process_audio_bc(struct hle_t* hle)
{
/* TODO: see what differs from alist_process_audio */
static const acmd_callback_t ABI[0x10] = {
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER,
SPNOOP, ADPCM , CLEARBUFF, ENVMIXER_GE,
LOADBUFF, RESAMPLE, SAVEBUFF, SEGMENT,
SETBUFF, SETVOL, DMEMMOVE, LOADADPCM,
MIXER, INTERLEAVE, POLEF, SETLOOP

View File

@ -1,151 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - alist_internal.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef ALIST_INTERNAL_H
#define ALIST_INTERNAL_H
#ifndef _MSC_VER
#include <stdbool.h>
#else
#include "mystdbool.h"
#endif
#include <stdint.h>
#include <stddef.h>
struct hle_t;
typedef void (*acmd_callback_t)(struct hle_t* hle, uint32_t w1, uint32_t w2);
void alist_process(struct hle_t* hle, const acmd_callback_t abi[], unsigned int abi_size);
uint32_t alist_get_address(struct hle_t* hle, uint32_t so, const uint32_t *segments, size_t n);
void alist_set_address(struct hle_t* hle, uint32_t so, uint32_t *segments, size_t n);
void alist_clear(struct hle_t* hle, uint16_t dmem, uint16_t count);
void alist_load(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count);
void alist_save(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count);
void alist_move(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_copy_every_other_sample(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_repeat64(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint8_t count);
void alist_copy_blocks(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t block_size, uint8_t count);
void alist_interleave(struct hle_t* hle, uint16_t dmemo, uint16_t left, uint16_t right, uint16_t count);
void alist_envmix_exp(
struct hle_t* hle,
bool init,
bool aux,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_lin(
struct hle_t* hle,
bool init,
uint16_t dmem_dl, uint16_t dmem_dr,
uint16_t dmem_wl, uint16_t dmem_wr,
uint16_t dmemi, uint16_t count,
int16_t dry, int16_t wet,
const int16_t *vol,
const int16_t *target,
const int32_t *rate,
uint32_t address);
void alist_envmix_nead(
struct hle_t* hle,
bool swap_wet_LR,
uint16_t dmem_dl,
uint16_t dmem_dr,
uint16_t dmem_wl,
uint16_t dmem_wr,
uint16_t dmemi,
unsigned count,
uint16_t *env_values,
uint16_t *env_steps,
const int16_t *xors);
void alist_mix(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count, int16_t gain);
void alist_multQ44(struct hle_t* hle, uint16_t dmem, uint16_t count, int8_t gain);
void alist_add(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count);
void alist_adpcm(
struct hle_t* hle,
bool init,
bool loop,
bool two_bit_per_sample,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
const int16_t* codebook,
uint32_t loop_address,
uint32_t last_frame_address);
void alist_resample(
struct hle_t* hle,
bool init,
bool flag2,
uint16_t dmemo, uint16_t dmemi, uint16_t count,
uint32_t pitch, uint32_t address);
void alist_resample_zoh(
struct hle_t* hle,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
uint32_t pitch,
uint32_t pitch_accu);
void alist_filter(
struct hle_t* hle,
uint16_t dmem,
uint16_t count,
uint32_t address,
const uint32_t* lut_address);
void alist_polef(
struct hle_t* hle,
bool init,
uint16_t dmemo,
uint16_t dmemi,
uint16_t count,
uint16_t gain,
int16_t* table,
uint32_t address);
/*
* Audio flags
*/
#define A_INIT 0x01
#define A_CONTINUE 0x00
#define A_LOOP 0x02
#define A_OUT 0x02
#define A_LEFT 0x02
#define A_RIGHT 0x00
#define A_VOL 0x04
#define A_RATE 0x00
#define A_AUX 0x08
#define A_NOAUX 0x00
#define A_MAIN 0x00
#define A_MIX 0x10
#endif

View File

@ -28,7 +28,7 @@
#endif
#include <stdint.h>
#include "alist_internal.h"
#include "alist.h"
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"
@ -250,6 +250,14 @@ static void MP3ADDY(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
}
static void MP3(struct hle_t* hle, uint32_t w1, uint32_t w2)
{
unsigned index = (w1 & 0x1e);
uint32_t address = (w2 & 0xffffff);
mp3_task(hle, index, address);
}
/* global functions */
void alist_process_naudio(struct hle_t* hle)
{

View File

@ -28,7 +28,7 @@
#endif
#include <stdint.h>
#include "alist_internal.h"
#include "alist.h"
#include "hle_external.h"
#include "hle_internal.h"
#include "memory.h"

View File

@ -1,30 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - cicx105.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2012 Bobby Smiles *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef CICX105_H
#define CICX105_H
struct hle_t;
void cicx105_ucode(struct hle_t* hle);
#endif

View File

@ -36,10 +36,7 @@
#include "hle_internal.h"
#include "memory.h"
#include "alist.h"
#include "cicx105.h"
#include "jpeg.h"
#include "musyx.h"
#include "ucodes.h"
#define min(a,b) (((a) < (b)) ? (a) : (b))

View File

@ -24,7 +24,7 @@
#include <stdint.h>
#include "alist.h"
#include "ucodes.h"
/* rsp hle internal state - internal usage only */
struct hle_t

View File

@ -1,32 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - jpeg.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2012 Bobby Smiles *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef JPEG_H
#define JPEG_H
struct hle_t;
void jpeg_decode_PS0(struct hle_t* hle);
void jpeg_decode_PS(struct hle_t* hle);
void jpeg_decode_OB(struct hle_t* hle);
#endif

View File

@ -200,7 +200,7 @@ static void MP3AB0(int32_t* v)
static void InnerLoop(struct hle_t* hle);
void MP3(struct hle_t* hle, uint32_t w1, uint32_t w2)
void mp3_task(struct hle_t* hle, unsigned int index, uint32_t address)
{
/* Initialization Code */
uint32_t readPtr; /* s5 */
@ -211,10 +211,9 @@ void MP3(struct hle_t* hle, uint32_t w1, uint32_t w2)
/* I think these are temporary storage buffers */
hle->mp3_t6 = 0x08A0;
hle->mp3_t5 = 0x0AC0;
hle->mp3_t4 = (w1 & 0x1E);
hle->mp3_t4 = index;
writePtr = w2 & 0xFFFFFF;
readPtr = writePtr;
writePtr = readPtr = address;
/* Just do that for efficiency... may remove and use directly later anyway */
memcpy(hle->mp3_buffer + 0xCE8, hle->dram + readPtr, 8);
/* This must be a header byte or whatnot */

View File

@ -1,30 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - musyx.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2013 Bobby Smiles *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef MUSYX_H
#define MUSYX_H
struct hle_t;
void musyx_v1_task(struct hle_t* hle);
void musyx_v2_task(struct hle_t* hle);
#endif

View File

@ -0,0 +1,146 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-rsp-hle - ucodes.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2014 Bobby Smiles *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef UCODES_H
#define UCODES_H
#include <stdint.h>
struct hle_t;
/* cic_x105 ucode */
void cicx105_ucode(struct hle_t* hle);
/* audio list ucodes - audio */
enum { N_SEGMENTS = 16 };
struct alist_audio_t {
/* segments */
uint32_t segments[N_SEGMENTS];
/* main buffers */
uint16_t in;
uint16_t out;
uint16_t count;
/* auxiliary buffers */
uint16_t dry_right;
uint16_t wet_left;
uint16_t wet_right;
/* gains */
int16_t dry;
int16_t wet;
/* envelopes (0:left, 1:right) */
int16_t vol[2];
int16_t target[2];
int32_t rate[2];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
};
void alist_process_audio (struct hle_t* hle);
void alist_process_audio_ge(struct hle_t* hle);
void alist_process_audio_bc(struct hle_t* hle);
/* audio list ucodes - naudio */
struct alist_naudio_t {
/* gains */
int16_t dry;
int16_t wet;
/* envelopes (0:left, 1:right) */
int16_t vol[2];
int16_t target[2];
int32_t rate[2];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
};
void alist_process_naudio (struct hle_t* hle);
void alist_process_naudio_bk (struct hle_t* hle);
void alist_process_naudio_dk (struct hle_t* hle);
void alist_process_naudio_mp3 (struct hle_t* hle);
void alist_process_naudio_cbfd(struct hle_t* hle);
/* audio list ucodes - nead */
struct alist_nead_t {
/* main buffers */
uint16_t in;
uint16_t out;
uint16_t count;
/* envmixer ramps */
uint16_t env_values[3];
uint16_t env_steps[3];
/* ADPCM loop point address */
uint32_t loop;
/* storage for ADPCM table and polef coefficients */
int16_t table[16 * 8];
/* filter audio command state */
uint16_t filter_count;
uint32_t filter_lut_address[2];
};
void alist_process_nead_mk (struct hle_t* hle);
void alist_process_nead_sfj (struct hle_t* hle);
void alist_process_nead_sf (struct hle_t* hle);
void alist_process_nead_fz (struct hle_t* hle);
void alist_process_nead_wrjb(struct hle_t* hle);
void alist_process_nead_ys (struct hle_t* hle);
void alist_process_nead_1080(struct hle_t* hle);
void alist_process_nead_oot (struct hle_t* hle);
void alist_process_nead_mm (struct hle_t* hle);
void alist_process_nead_mmb (struct hle_t* hle);
void alist_process_nead_ac (struct hle_t* hle);
/* mp3 ucode */
void mp3_task(struct hle_t* hle, unsigned int index, uint32_t address);
/* musyx ucodes */
void musyx_v1_task(struct hle_t* hle);
void musyx_v2_task(struct hle_t* hle);
/* jpeg ucodes */
void jpeg_decode_PS0(struct hle_t* hle);
void jpeg_decode_PS(struct hle_t* hle);
void jpeg_decode_OB(struct hle_t* hle);
#endif