diff --git a/hw/xbox/dsp/Makefile.objs b/hw/xbox/dsp/Makefile.objs index eb44da36e8..93a180dee6 100644 --- a/hw/xbox/dsp/Makefile.objs +++ b/hw/xbox/dsp/Makefile.objs @@ -1 +1 @@ -obj-y += dsp.o dsp_cpu.o +obj-y += dsp.o dsp_cpu.o dsp_dma.o diff --git a/hw/xbox/dsp/dsp.c b/hw/xbox/dsp/dsp.c index 06b8a6acdb..56b7585678 100644 --- a/hw/xbox/dsp/dsp.c +++ b/hw/xbox/dsp/dsp.c @@ -172,10 +172,11 @@ void dsp_run(DSPState* dsp, int cycles) } -void dsp_bootstrap(DSPState* dsp, const uint32_t* pram, size_t len) +void dsp_bootstrap(DSPState* dsp) { - assert(sizeof(dsp->core.pram) >= len); - memcpy(dsp->core.pram, pram, len); + // scratch memory is dma'd in to pram by the bootrom + dsp->dma.scratch_rw(dsp->dma.scratch_rw_opaque, + (uint8_t*)dsp->core.pram, 0, 0x600, false); } void dsp_start_frame(DSPState* dsp) diff --git a/hw/xbox/dsp/dsp.h b/hw/xbox/dsp/dsp.h index f2b014313d..0ea3d038de 100644 --- a/hw/xbox/dsp/dsp.h +++ b/hw/xbox/dsp/dsp.h @@ -32,7 +32,7 @@ typedef struct DSPState DSPState; typedef void (*dsp_scratch_rw_func)( - uint8_t* ptr, uint64_t addr, size_t len, bool dir); + void* opaque, uint8_t* ptr, uint64_t addr, size_t len, bool dir); /* Dsp commands */ DSPState* dsp_init(void* scratch_rw_opaque, dsp_scratch_rw_func scratch_rw); @@ -42,7 +42,7 @@ void dsp_reset(DSPState* dsp); void dsp_step(DSPState* dsp); void dsp_run(DSPState* dsp, int cycles); -void dsp_bootstrap(DSPState* dsp, const uint32_t* pmem, size_t len); +void dsp_bootstrap(DSPState* dsp); void dsp_start_frame(DSPState* dsp); diff --git a/hw/xbox/dsp/dsp_cpu.c b/hw/xbox/dsp/dsp_cpu.c index beadb4dd97..90e42bfaa3 100644 --- a/hw/xbox/dsp/dsp_cpu.c +++ b/hw/xbox/dsp/dsp_cpu.c @@ -359,6 +359,7 @@ void dsp56k_reset_cpu(dsp_core_t* dsp) { int i; if (!matches_initialised) { + matches_initialised = true; for (i=0; iexecuting_for_disasm = false; // start_time = SDL_GetTicks(); dsp->num_inst = 0; @@ -480,7 +479,7 @@ static uint16_t disasm_instruction(dsp_core_t* dsp, dsp_trace_disasm_t mode) static void disasm_reg_save(dsp_core_t* dsp) { memcpy(dsp->disasm_registers_save, dsp->registers , sizeof(dsp->disasm_registers_save)); -#if DSP_DISASM_REG_PC +#ifdef DSP_DISASM_REG_PC dsp->pc_save = dsp->pc; #endif } @@ -566,7 +565,7 @@ static void disasm_reg_compare(dsp_core_t* dsp) } } -#if DSP_DISASM_REG_PC +#ifdef DSP_DISASM_REG_PC if (pc_save != dsp->pc) { fprintf(stderr,"\tReg: pc $%04x -> $%04x\n", pc_save, dsp->pc); } diff --git a/hw/xbox/dsp/dsp_dma.c b/hw/xbox/dsp/dsp_dma.c index 9780a53852..75d2511b34 100644 --- a/hw/xbox/dsp/dsp_dma.c +++ b/hw/xbox/dsp/dsp_dma.c @@ -96,12 +96,11 @@ static void dsp_dma_run(DSPDMAState *s) uint8_t* scratch_buf = calloc(count, item_size); - assert(s->scratch_rw); - if (control & NODE_CONTROL_DIRECTION) { int i; for (i=0; icore, mem_space, mem_address+i); + uint32_t v = dsp56k_read_memory(s->core, + mem_space, mem_address+i); switch(item_size) { case 4: *(uint32_t*)(scratch_buf + i*4) = v; @@ -113,10 +112,12 @@ static void dsp_dma_run(DSPDMAState *s) } // write to scratch memory - s->scratch_rw(scratch_buf, scratch_addr, count*item_size, 1); + s->scratch_rw(s->scratch_rw_opaque, + scratch_buf, scratch_addr, count*item_size, 1); } else { // read from scratch memory - s->scratch_rw(scratch_buf, scratch_addr, count*item_size, 0); + s->scratch_rw(s->scratch_rw_opaque, + scratch_buf, scratch_addr, count*item_size, 0); int i; for (i=0; iinstr_cycle += 6; -} - static void emu_sub_imm(dsp_core_t* dsp) { uint32_t xx = (dsp->cur_inst >> 8) & BITMASK(6);