diff options
author | twinaphex | 2013-01-10 03:06:17 +0100 |
---|---|---|
committer | twinaphex | 2013-01-10 03:06:17 +0100 |
commit | e5f4d90401d099d5191f95e9f771ab5a81c87ed8 (patch) | |
tree | 8de3efcfd7bf5111ea62a43ecd7db558f2ec8350 /plugins | |
parent | ac7b2a33ddb2392582c50d29c772e9e99cd762c9 (diff) | |
parent | d77e74383a9134e51c31607cfddf4dcd3535a0ae (diff) | |
download | pcsx_rearmed-e5f4d90401d099d5191f95e9f771ab5a81c87ed8.tar.gz pcsx_rearmed-e5f4d90401d099d5191f95e9f771ab5a81c87ed8.tar.bz2 pcsx_rearmed-e5f4d90401d099d5191f95e9f771ab5a81c87ed8.zip |
Merge git://github.com/notaz/pcsx_rearmed
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/dfsound/spu.c | 67 | ||||
-rw-r--r-- | plugins/dfxvideo/gpulib_if.c | 15 | ||||
-rw-r--r-- | plugins/gpu-gles/gpulib_if.c | 15 | ||||
-rw-r--r-- | plugins/gpu_neon/psx_gpu/psx_gpu_parse.c | 22 | ||||
-rw-r--r-- | plugins/gpu_unai/gpulib_if.cpp | 12 | ||||
-rw-r--r-- | plugins/gpulib/gpu.c | 71 | ||||
-rw-r--r-- | plugins/gpulib/vout_pl.c | 1 |
7 files changed, 135 insertions, 68 deletions
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 9f91b8b..b89ab1a 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -444,24 +444,30 @@ static int decode_block(int ch) { unsigned char *start; int predict_nr,shift_factor,flags; + int stop = 0; int ret = 0; - start=s_chan[ch].pCurr; // set up the current pos + start = s_chan[ch].pCurr; // set up the current pos + if(start == spuMemC) // ? + stop = 1; if(s_chan[ch].prevflags&1) // 1: stop/loop { if(!(s_chan[ch].prevflags&2)) - { - dwChannelOn&=~(1<<ch); // -> turn everything off - s_chan[ch].bStop=1; - s_chan[ch].ADSRX.EnvelopeVol=0; - } + stop = 1; start = s_chan[ch].pLoop; } else ret = check_irq(ch, start); // hack, see check_irq below.. + if(stop) + { + dwChannelOn &= ~(1<<ch); // -> turn everything off + s_chan[ch].bStop = 1; + s_chan[ch].ADSRX.EnvelopeVol = 0; + } + predict_nr=(int)start[0]; shift_factor=predict_nr&0xf; predict_nr >>= 4; @@ -665,12 +671,13 @@ static void noinline do_decode_bufs(int which, int start, int count) { const int *src = ChanBuf + start; unsigned short *dst = &spuMem[0x800/2 + which*0x400/2]; - int cursor = decode_pos; + int cursor = decode_pos + start; while (count-- > 0) { + cursor &= 0x1ff; dst[cursor] = *src++; - cursor = (cursor + 1) & 0x1ff; + cursor++; } // decode_pos is updated and irqs are checked later, after voice loop @@ -689,25 +696,18 @@ static int do_samples(int forced_updates) int ch,d,silentch; int bIRQReturn=0; + // ok, at the beginning we are looking if there is + // enuff free place in the dsound/oss buffer to + // fill in new data, or if there is a new channel to start. + // if not, we return until enuff free place is available + // /a new channel gets started + + if(!forced_updates && out_current->busy()) // still enuff data in sound buffer? + return 0; + while(!bIRQReturn) { - // ok, at the beginning we are looking if there is - // enuff free place in the dsound/oss buffer to - // fill in new data, or if there is a new channel to start. - // if not, we wait (thread) or return (timer/spuasync) - // until enuff free place is available/a new channel gets - // started - - if(!forced_updates && out_current->busy()) // still enuff data in sound buffer? - { - return 0; - } - cycles_since_update = 0; - if(forced_updates > 0) - forced_updates--; - - //--------------------------------------------------// continue from irq handling in timer mode? ns_from=0; ns_to=NSSIZE; @@ -777,9 +777,9 @@ static int do_samples(int forced_updates) // no need for bIRQReturn since the channel is silent skip_block(ch); - if(start == s_chan[ch].pCurr) + if(start == s_chan[ch].pCurr || start - spuMemC < 0x1000) { - // looping on self + // looping on self or stopped(?) dwChannelDead |= 1<<ch; s_chan[ch].spos = 0; break; @@ -872,12 +872,21 @@ static int do_samples(int forced_updates) // feed the sound // wanna have around 1/60 sec (16.666 ms) updates - if (iCycle++ > 16/FRAG_MSECS) + if (iCycle++ >= 16/FRAG_MSECS) { - out_current->feed(pSpuBuffer, - ((unsigned char *)pS) - ((unsigned char *)pSpuBuffer)); + out_current->feed(pSpuBuffer, (unsigned char *)pS - pSpuBuffer); pS = (short *)pSpuBuffer; iCycle = 0; + + if(!forced_updates && out_current->busy()) + break; + } + + if(forced_updates > 0) + { + forced_updates--; + if(forced_updates == 0 && out_current->busy()) + break; } } diff --git a/plugins/dfxvideo/gpulib_if.c b/plugins/dfxvideo/gpulib_if.c index d98520c..01b8dde 100644 --- a/plugins/dfxvideo/gpulib_if.c +++ b/plugins/dfxvideo/gpulib_if.c @@ -342,7 +342,12 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) while(1) { - if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end) + if(list_position >= list_end) { + cmd = -1; + goto breakloop; + } + + if((*list_position & 0xf000f000) == 0x50005000) break; list_position++; @@ -360,7 +365,12 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) while(1) { - if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end) + if(list_position >= list_end) { + cmd = -1; + goto breakloop; + } + + if((*list_position & 0xf000f000) == 0x50005000) break; list_position += 2; @@ -386,6 +396,7 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) } } +breakloop: gpu.ex_regs[1] &= ~0x1ff; gpu.ex_regs[1] |= lGPUstatusRet & 0x1ff; diff --git a/plugins/gpu-gles/gpulib_if.c b/plugins/gpu-gles/gpulib_if.c index 068dc41..2090553 100644 --- a/plugins/gpu-gles/gpulib_if.c +++ b/plugins/gpu-gles/gpulib_if.c @@ -549,7 +549,12 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) while(1) { - if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end) + if(list_position >= list_end) { + cmd = -1; + goto breakloop; + } + + if((*list_position & 0xf000f000) == 0x50005000) break; list_position++; @@ -567,7 +572,12 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) while(1) { - if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end) + if(list_position >= list_end) { + cmd = -1; + goto breakloop; + } + + if((*list_position & 0xf000f000) == 0x50005000) break; list_position += 2; @@ -593,6 +603,7 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) } } +breakloop: gpu.ex_regs[1] &= ~0x1ff; gpu.ex_regs[1] |= lGPUstatusRet & 0x1ff; diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c index a364eef..ffa9b9a 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c @@ -435,7 +435,10 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_command) num_vertexes++; if(list_position >= list_end) - break; + { + current_command = (u32)-1; + goto breakloop; + } xy = *list_position; if((xy & 0xF000F000) == 0x50005000) @@ -496,7 +499,10 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_command) num_vertexes++; if(list_position >= list_end) - break; + { + current_command = (u32)-1; + goto breakloop; + } color = list_position[0]; if((color & 0xF000F000) == 0x50005000) @@ -774,9 +780,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_command) } } -#ifdef PCSX breakloop: -#endif if (last_command != NULL) *last_command = current_command; return list - list_start; @@ -1193,7 +1197,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, num_vertexes++; if(list_position >= list_end) - break; + { + current_command = (u32)-1; + goto breakloop; + } xy = *list_position; if((xy & 0xF000F000) == 0x50005000) @@ -1259,7 +1266,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, num_vertexes++; if(list_position >= list_end) - break; + { + current_command = (u32)-1; + goto breakloop; + } color = list_position[0]; if((color & 0xF000F000) == 0x50005000) diff --git a/plugins/gpu_unai/gpulib_if.cpp b/plugins/gpu_unai/gpulib_if.cpp index de16721..0d506bc 100644 --- a/plugins/gpu_unai/gpulib_if.cpp +++ b/plugins/gpu_unai/gpulib_if.cpp @@ -307,7 +307,11 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) gpuDrawLF(gpuPixelDrivers [ (Blending_Mode | Masking | Blending | (PixelMSB>>3)) >> 1]); num_vertexes++; - if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end) + if(list_position >= list_end) { + cmd = -1; + goto breakloop; + } + if((*list_position & 0xf000f000) == 0x50005000) break; } @@ -338,7 +342,11 @@ int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) gpuDrawLG(gpuPixelDrivers [ (Blending_Mode | Masking | Blending | (PixelMSB>>3)) >> 1]); num_vertexes++; - if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end) + if(list_position >= list_end) { + cmd = -1; + goto breakloop; + } + if((*list_position & 0xf000f000) == 0x50005000) break; } diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index b300c88..337e27a 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -68,10 +68,11 @@ static noinline void update_width(void) static noinline void update_height(void) { + // TODO: emulate this properly.. int sh = gpu.screen.y2 - gpu.screen.y1; if (gpu.status.dheight) sh *= 2; - if (sh <= 0) + if (sh <= 0 || sh > gpu.screen.vres) sh = gpu.screen.vres; gpu.screen.h = sh; @@ -367,46 +368,62 @@ static void finish_vram_transfer(int is_read) static noinline int do_cmd_list_skip(uint32_t *data, int count, int *last_cmd) { - int cmd = 0, pos = 0, len, dummy; + int cmd = 0, pos = 0, len, dummy, v; int skip = 1; gpu.frameskip.pending_fill[0] = 0; - // XXX: polylines are not properly handled while (pos < count && skip) { uint32_t *list = data + pos; cmd = list[0] >> 24; len = 1 + cmd_lengths[cmd]; - if (cmd == 0x02) { - if ((list[2] & 0x3ff) > gpu.screen.w || ((list[2] >> 16) & 0x1ff) > gpu.screen.h) - // clearing something large, don't skip - do_cmd_list(list, 3, &dummy); - else - memcpy(gpu.frameskip.pending_fill, list, 3 * 4); - } - else if ((cmd & 0xf4) == 0x24) { - // flat textured prim - gpu.ex_regs[1] &= ~0x1ff; - gpu.ex_regs[1] |= list[4] & 0x1ff; - } - else if ((cmd & 0xf4) == 0x34) { - // shaded textured prim - gpu.ex_regs[1] &= ~0x1ff; - gpu.ex_regs[1] |= list[5] & 0x1ff; + switch (cmd) { + case 0x02: + if ((list[2] & 0x3ff) > gpu.screen.w || ((list[2] >> 16) & 0x1ff) > gpu.screen.h) + // clearing something large, don't skip + do_cmd_list(list, 3, &dummy); + else + memcpy(gpu.frameskip.pending_fill, list, 3 * 4); + break; + case 0x24 ... 0x27: + case 0x2c ... 0x2f: + case 0x34 ... 0x37: + case 0x3c ... 0x3f: + gpu.ex_regs[1] &= ~0x1ff; + gpu.ex_regs[1] |= list[4 + ((cmd >> 4) & 1)] & 0x1ff; + break; + case 0x48 ... 0x4F: + for (v = 3; pos + v < count; v++) + { + if ((list[v] & 0xf000f000) == 0x50005000) + break; + } + len += v - 3; + break; + case 0x58 ... 0x5F: + for (v = 4; pos + v < count; v += 2) + { + if ((list[v] & 0xf000f000) == 0x50005000) + break; + } + len += v - 4; + break; + default: + if (cmd == 0xe3) + skip = decide_frameskip_allow(list[0]); + if ((cmd & 0xf8) == 0xe0) + gpu.ex_regs[cmd & 7] = list[0]; + break; } - else if (cmd == 0xe3) - skip = decide_frameskip_allow(list[0]); - - if ((cmd & 0xf8) == 0xe0) - gpu.ex_regs[cmd & 7] = list[0]; if (pos + len > count) { cmd = -1; break; // incomplete cmd } - if (cmd == 0xa0 || cmd == 0xc0) + if (0xa0 <= cmd && cmd <= 0xdf) break; // image i/o + pos += len; } @@ -432,9 +449,9 @@ static noinline int do_cmd_buffer(uint32_t *data, int count) } cmd = data[pos] >> 24; - if (cmd == 0xa0 || cmd == 0xc0) { + if (0xa0 <= cmd && cmd <= 0xdf) { // consume vram write/read cmd - start_vram_transfer(data[pos + 1], data[pos + 2], cmd == 0xc0); + start_vram_transfer(data[pos + 1], data[pos + 2], (cmd & 0xe0) == 0xc0); pos += 3; continue; } diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 49f53d6..5af0762 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -106,6 +106,7 @@ long GPUopen(void **unused) cbs->pl_vout_open(); check_mode_change(1); + vout_update(); return 0; } |