diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-06-29 20:44:53 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-06-29 20:44:53 +0200 |
commit | 013f0d807ca2185b643b165d6f51a44147181411 (patch) | |
tree | 6e40ef36371209be65bdde276266bd171bb1a235 /plugins/ao | |
parent | a255ff9f91e27fa06152210953e2cb35e52f37a9 (diff) |
ao plugin: aica code is now reentrant
Diffstat (limited to 'plugins/ao')
-rw-r--r-- | plugins/ao/eng_dsf/aica.c | 44 | ||||
-rw-r--r-- | plugins/ao/eng_dsf/aica.h | 7 | ||||
-rw-r--r-- | plugins/ao/eng_dsf/arm7.c | 6 | ||||
-rw-r--r-- | plugins/ao/eng_dsf/arm7.h | 1 | ||||
-rw-r--r-- | plugins/ao/eng_dsf/dc_hw.c | 18 | ||||
-rw-r--r-- | plugins/ao/eng_dsf/eng_dsf.c | 7 |
6 files changed, 36 insertions, 47 deletions
diff --git a/plugins/ao/eng_dsf/aica.c b/plugins/ao/eng_dsf/aica.c index dc7cdf0b..1878f45b 100644 --- a/plugins/ao/eng_dsf/aica.c +++ b/plugins/ao/eng_dsf/aica.c @@ -203,18 +203,18 @@ struct _AICA struct _AICADSP DSP; struct sARM7 *cpu; -}; -static struct _AICA *AllocedAICA; + INT16 *bufferl; + INT16 *bufferr; -static const float SDLT[16]={-1000000.0,-42.0,-39.0,-36.0,-33.0,-30.0,-27.0,-24.0,-21.0,-18.0,-15.0,-12.0,-9.0,-6.0,-3.0,0.0}; + int length; -static INT16 *bufferl; -static INT16 *bufferr; + signed short *RBUFDST; //this points to where the sample will be stored in the RingBuf +}; -static int length; +//static struct _AICA *AllocedAICA; -static signed short *RBUFDST; //this points to where the sample will be stored in the RingBuf +static const float SDLT[16]={-1000000.0,-42.0,-39.0,-36.0,-33.0,-30.0,-27.0,-24.0,-21.0,-18.0,-15.0,-12.0,-9.0,-6.0,-3.0,0.0}; static unsigned char DecodeSCI(struct _AICA *AICA, unsigned char irq) { @@ -702,7 +702,7 @@ static void AICA_UpdateReg(struct _AICA *AICA, int reg) break; case 0x8: case 0x9: - AICA_MidiIn(0, AICA->udata.data[0x8/2]&0xff, 0); + AICA_MidiIn(AICA, 0, AICA->udata.data[0x8/2]&0xff, 0); break; case 0x12: case 0x13: @@ -1131,8 +1131,8 @@ static void AICA_DoMasterSamples(struct _AICA *AICA, int nsamples) INT16 *bufr,*bufl; int sl, s, i; - bufr=bufferr; - bufl=bufferl; + bufr=AICA->bufferr; + bufl=AICA->bufferl; for(s=0;s<nsamples;++s) { @@ -1145,7 +1145,7 @@ static void AICA_DoMasterSamples(struct _AICA *AICA, int nsamples) { struct _SLOT *slot=AICA->Slots+sl; slot->mslc = (MSLC(AICA)==sl); - RBUFDST=AICA->RINGBUF+AICA->BUFPTR; + AICA->RBUFDST=AICA->RINGBUF+AICA->BUFPTR; if(AICA->Slots[sl].active) { unsigned int Enc; @@ -1193,12 +1193,11 @@ int AICA_IRQCB(void *param) return -1; } -void AICA_Update(void *param, INT16 **inputs, INT16 **buf, int samples) +void AICA_Update(struct _AICA *AICA, void *param, INT16 **inputs, INT16 **buf, int samples) { - struct _AICA *AICA = AllocedAICA; - bufferl = buf[0]; - bufferr = buf[1]; - length = samples; + AICA->bufferl = buf[0]; + AICA->bufferr = buf[1]; + AICA->length = samples; AICA_DoMasterSamples(AICA, samples); } @@ -1223,19 +1222,16 @@ void *aica_start(const void *config) // AICA->stream = stream_create(0, 2, 44100, AICA, AICA_Update); } - AllocedAICA = AICA; - return AICA; } -void aica_stop(void) +void aica_stop(struct _AICA *AICA) { - free(AllocedAICA); + free(AICA); } -void AICA_set_ram_base(int which, void *base) +void AICA_set_ram_base(struct _AICA *AICA, int which, void *base) { - struct _AICA *AICA = AllocedAICA; if (AICA) { AICA->AICARAM = base; @@ -1245,7 +1241,6 @@ void AICA_set_ram_base(int which, void *base) READ16_HANDLER( AICA_0_r ) { - struct _AICA *AICA = AllocedAICA; UINT16 res = AICA_r16(AICA, offset*2); // printf("Read AICA @ %x => %x (PC=%x, R5=%x)\n", offset*2, res, arm7_get_register(15), arm7_get_register(5)); @@ -1257,7 +1252,6 @@ extern UINT32* stv_scu; WRITE16_HANDLER( AICA_0_w ) { - struct _AICA *AICA = AllocedAICA; UINT16 tmp; tmp = AICA_r16(AICA, offset*2); @@ -1267,14 +1261,12 @@ WRITE16_HANDLER( AICA_0_w ) WRITE16_HANDLER( AICA_MidiIn ) { - struct _AICA *AICA = AllocedAICA; AICA->MidiStack[AICA->MidiW++]=data; AICA->MidiW &= 15; } READ16_HANDLER( AICA_MidiOutR ) { - struct _AICA *AICA = AllocedAICA; unsigned char val; val=AICA->MidiStack[AICA->MidiR++]; diff --git a/plugins/ao/eng_dsf/aica.h b/plugins/ao/eng_dsf/aica.h index a3b1c3c8..5a1b52ca 100644 --- a/plugins/ao/eng_dsf/aica.h +++ b/plugins/ao/eng_dsf/aica.h @@ -26,12 +26,14 @@ struct AICAinterface void (*irq_callback[MAX_AICA])(struct sARM7 *cpu, int state); /* irq callback */ }; +struct _AICA; + int AICA_sh_start(struct AICAinterface *intf); void AICA_sh_stop(void); void scsp_stop(void); -#define READ16_HANDLER(name) data16_t name(offs_t offset, data16_t mem_mask) -#define WRITE16_HANDLER(name) void name(offs_t offset, data16_t data, data16_t mem_mask) +#define READ16_HANDLER(name) data16_t name(struct _AICA *AICA, offs_t offset, data16_t mem_mask) +#define WRITE16_HANDLER(name) void name(struct _AICA *AICA, offs_t offset, data16_t data, data16_t mem_mask) // AICA register access READ16_HANDLER( AICA_0_r ); @@ -44,5 +46,6 @@ WRITE16_HANDLER( AICA_MidiIn ); READ16_HANDLER( AICA_MidiOutR ); void *aica_start(const void *config); +void AICA_Update(struct _AICA *AICA, void *param, INT16 **inputs, INT16 **buf, int samples); #endif diff --git a/plugins/ao/eng_dsf/arm7.c b/plugins/ao/eng_dsf/arm7.c index 570bf56a..0bc35705 100644 --- a/plugins/ao/eng_dsf/arm7.c +++ b/plugins/ao/eng_dsf/arm7.c @@ -25,12 +25,6 @@ static void Reset (struct sARM7 *cpu); //-------------------------------------------------------------------------- - //-------------------------------------------------------------------------- - // public variables - - /** ARM7 state. */ -struct sARM7 ARM7; - // private variables /** Table for decoding bit-coded mode to zero based index. */ diff --git a/plugins/ao/eng_dsf/arm7.h b/plugins/ao/eng_dsf/arm7.h index dea6aa26..3c9a47db 100644 --- a/plugins/ao/eng_dsf/arm7.h +++ b/plugins/ao/eng_dsf/arm7.h @@ -120,6 +120,7 @@ struct sARM7 uint8 dc_ram[8*1024*1024]; struct AICAinterface aica_interface; + struct _AICA *AICA; }; //-------------------------------------------------------------------------- diff --git a/plugins/ao/eng_dsf/dc_hw.c b/plugins/ao/eng_dsf/dc_hw.c index d0dc87fd..6c810b37 100644 --- a/plugins/ao/eng_dsf/dc_hw.c +++ b/plugins/ao/eng_dsf/dc_hw.c @@ -46,7 +46,7 @@ uint8 dc_read8(struct sARM7 *cpu, int addr) if ((addr >= 0x800000) && (addr <= 0x807fff)) { - int foo = AICA_0_r((addr-0x800000)/2, 0); + int foo = AICA_0_r(cpu->AICA, (addr-0x800000)/2, 0); if (addr & 1) { @@ -71,7 +71,7 @@ uint16 dc_read16(struct sARM7 *cpu, int addr) if ((addr >= 0x800000) && (addr <= 0x807fff)) { - return AICA_0_r((addr-0x800000)/2, 0); + return AICA_0_r(cpu->AICA, (addr-0x800000)/2, 0); } printf("R16 @ %x\n", addr); @@ -88,7 +88,7 @@ uint32 dc_read32(struct sARM7 *cpu, int addr) if ((addr >= 0x800000) && (addr <= 0x807fff)) { addr &= 0x7fff; - return AICA_0_r(addr/2, 0) & 0xffff; + return AICA_0_r(cpu->AICA, addr/2, 0) & 0xffff; } // printf("R32 @ %x\n", addr); @@ -107,9 +107,9 @@ void dc_write8(struct sARM7 *cpu, int addr, uint8 data) { addr -= 0x800000; if ((addr & 1)) - AICA_0_w(addr>>1, data<<8, 0x00ff); + AICA_0_w(cpu->AICA, addr>>1, data<<8, 0x00ff); else - AICA_0_w(addr>>1, data, 0xff00); + AICA_0_w(cpu->AICA, addr>>1, data, 0xff00); return; } @@ -127,7 +127,7 @@ void dc_write16(struct sARM7 *cpu, int addr, uint16 data) if ((addr >= 0x800000) && (addr <= 0x807fff)) { - AICA_0_w((addr-0x800000)/2, data, 0); + AICA_0_w(cpu->AICA, (addr-0x800000)/2, data, 0); return; } @@ -148,8 +148,8 @@ void dc_write32(struct sARM7 *cpu, int addr, uint32 data) if ((addr >= 0x800000) && (addr <= 0x807fff)) { addr -= 0x800000; - AICA_0_w((addr>>1), data&0xffff, 0x0000); - AICA_0_w((addr>>1)+1, data>>16, 0x0000); + AICA_0_w(cpu->AICA, (addr>>1), data&0xffff, 0x0000); + AICA_0_w(cpu->AICA, (addr>>1)+1, data>>16, 0x0000); return; } @@ -173,6 +173,6 @@ static struct AICAinterface aica_interface = cpu->aica_interface.mixing_level[0] = YM3012_VOL(100, MIXER_PAN_LEFT, 100, MIXER_PAN_RIGHT); cpu->aica_interface.irq_callback[0] = aica_irq; cpu->aica_interface.cpu = cpu; - aica_start(&cpu->aica_interface); + cpu->AICA = aica_start(&cpu->aica_interface); } diff --git a/plugins/ao/eng_dsf/eng_dsf.c b/plugins/ao/eng_dsf/eng_dsf.c index e0edb383..18109ba0 100644 --- a/plugins/ao/eng_dsf/eng_dsf.c +++ b/plugins/ao/eng_dsf/eng_dsf.c @@ -17,7 +17,9 @@ #include "eng_protos.h" #include "corlett.h" #include "dc_hw.h" +#include "cpuintrf.h" #include "aica.h" +#include "aicadsp.h" #define DEBUG_LOADER (1) #define DK_CORE (1) @@ -35,9 +37,6 @@ typedef struct { struct sARM7 *cpu; } dsf_synth_t; -//void *aica_start(const void *config); -void AICA_Update(void *param, INT16 **inputs, INT16 **buf, int samples); - void *dsf_start(const char *path, uint8 *buffer, uint32 length) { dsf_synth_t *s = malloc (sizeof (dsf_synth_t)); @@ -193,7 +192,7 @@ int32 dsf_gen(void *handle, int16 *buffer, uint32 samples) #endif stereo[0] = &output[opos]; stereo[1] = &output2[opos]; - AICA_Update(NULL, NULL, stereo, 1); + AICA_Update(s->cpu->AICA, NULL, NULL, stereo, 1); opos++; } |