notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gpu_neon: unbreak sprites in enhanced res
[pcsx_rearmed.git]
/
libpcsxcore
/
mdec.c
diff --git
a/libpcsxcore/mdec.c
b/libpcsxcore/mdec.c
index
bed4e53
..
38b03e1
100644
(file)
--- a/
libpcsxcore/mdec.c
+++ b/
libpcsxcore/mdec.c
@@
-32,7
+32,12
@@
* 320x240x16@60Hz => 9.216 MB/s
* so 2.0 to 4.0 should be fine.
*/
* 320x240x16@60Hz => 9.216 MB/s
* so 2.0 to 4.0 should be fine.
*/
-#define MDEC_BIAS 2.0f
+
+/*
+ * >= 10 for Galerians
+ * <= 18 for "Disney's Treasure Planet"
+ */
+#define MDEC_BIAS 10
#define DSIZE 8
#define DSIZE2 (DSIZE * DSIZE)
#define DSIZE 8
#define DSIZE2 (DSIZE * DSIZE)
@@
-222,8
+227,8
@@
struct _pending_dma1 {
static struct {
u32 reg0;
u32 reg1;
static struct {
u32 reg0;
u32 reg1;
- u16 * rl;
- u16 * rl_end;
+
const
u16 * rl;
+
const
u16 * rl_end;
u8 * block_buffer_pos;
u8 block_buffer[16*16*3];
struct _pending_dma1 pending_dma1;
u8 * block_buffer_pos;
u8 block_buffer[16*16*3];
struct _pending_dma1 pending_dma1;
@@
-253,7
+258,7
@@
static int aanscales[DSIZE2] = {
289301, 401273, 377991, 340183, 289301, 227303, 156569, 79818
};
289301, 401273, 377991, 340183, 289301, 227303, 156569, 79818
};
-static void iqtab_init(int *iqtab, unsigned char *iq_y) {
+static void iqtab_init(int *iqtab,
const
unsigned char *iq_y) {
int i;
for (i = 0; i < DSIZE2; i++) {
int i;
for (i = 0; i < DSIZE2; i++) {
@@
-263,7
+268,7
@@
static void iqtab_init(int *iqtab, unsigned char *iq_y) {
#define MDEC_END_OF_DATA 0xfe00
#define MDEC_END_OF_DATA 0xfe00
-static
unsigned short *rl2blk(int *blk,
unsigned short *mdec_rl) {
+static
const unsigned short *rl2blk(int *blk, const
unsigned short *mdec_rl) {
int i, k, q_scale, rl, used_col;
int *iqtab;
int i, k, q_scale, rl, used_col;
int *iqtab;
@@
-467,10
+472,12
@@
u32 mdecRead1(void) {
}
void psxDma0(u32 adr, u32 bcr, u32 chcr) {
}
void psxDma0(u32 adr, u32 bcr, u32 chcr) {
- int cmd = mdec.reg0;
+ u32 cmd = mdec.reg0, words_max = 0;
+ const void *mem;
int size;
if (chcr != 0x01000201) {
int size;
if (chcr != 0x01000201) {
+ log_unhandled("mdec0: invalid dma %08x\n", chcr);
return;
}
return;
}
@@
-479,19
+486,25
@@
void psxDma0(u32 adr, u32 bcr, u32 chcr) {
size = (bcr >> 16) * (bcr & 0xffff);
size = (bcr >> 16) * (bcr & 0xffff);
+ adr &= ~3;
+ mem = getDmaRam(adr, &words_max);
+ if (mem == INVALID_PTR || size > words_max) {
+ log_unhandled("bad dma0 madr %x\n", adr);
+ HW_DMA0_CHCR &= SWAP32(~0x01000000);
+ return;
+ }
+
switch (cmd >> 28) {
switch (cmd >> 28) {
- case 0x3: // decode
- mdec.rl =
(u16 *) PSXM(adr)
;
+ case 0x3: // decode
15/24bpp
+ mdec.rl =
mem
;
/* now the mdec is busy till all data are decoded */
mdec.reg1 |= MDEC1_BUSY;
/* detect the end of decoding */
mdec.rl_end = mdec.rl + (size * 2);
/* sanity check */
/* now the mdec is busy till all data are decoded */
mdec.reg1 |= MDEC1_BUSY;
/* detect the end of decoding */
mdec.rl_end = mdec.rl + (size * 2);
/* sanity check */
- if(mdec.rl_end <= mdec.rl) {
- MDECINDMA_INT( size / 4 );
- return;
- }
+ if(mdec.rl_end <= mdec.rl)
+ break;
/* process the pending dma1 */
if(mdec.pending_dma1.adr){
/* process the pending dma1 */
if(mdec.pending_dma1.adr){
@@
-503,30
+516,25
@@
void psxDma0(u32 adr, u32 bcr, u32 chcr) {
case 0x4: // quantization table upload
{
case 0x4: // quantization table upload
{
-
u8 *p = (u8 *)PSXM(adr)
;
+
const u8 *p = mem
;
// printf("uploading new quantization table\n");
// printmatrixu8(p);
// printmatrixu8(p + 64);
iqtab_init(iq_y, p);
iqtab_init(iq_uv, p + 64);
}
// printf("uploading new quantization table\n");
// printmatrixu8(p);
// printmatrixu8(p + 64);
iqtab_init(iq_y, p);
iqtab_init(iq_uv, p + 64);
}
-
- MDECINDMA_INT( size / 4 );
- return;
+ break;
case 0x6: // cosine table
// printf("mdec cosine table\n");
case 0x6: // cosine table
// printf("mdec cosine table\n");
-
- MDECINDMA_INT( size / 4 );
- return;
+ break;
default:
default:
-
// printf("mdec unknown command\n"
);
+
log_unhandled("mdec: unknown command %08x\n", cmd
);
break;
}
break;
}
- HW_DMA0_CHCR &= SWAP32(~0x01000000);
- DMA_INTERRUPT(0);
+ set_event(PSXINT_MDECINDMA, size);
}
void mdec0Interrupt()
}
void mdec0Interrupt()
@@
-542,18
+550,19
@@
void mdec0Interrupt()
#define SIZE_OF_16B_BLOCK (16*16*2)
void psxDma1(u32 adr, u32 bcr, u32 chcr) {
#define SIZE_OF_16B_BLOCK (16*16*2)
void psxDma1(u32 adr, u32 bcr, u32 chcr) {
+ u32 words, words_max = 0;
int blk[DSIZE2 * 6];
u8 * image;
int size;
int blk[DSIZE2 * 6];
u8 * image;
int size;
- int dmacnt;
- if (chcr != 0x01000200) return;
+ if (chcr != 0x01000200) {
+ log_unhandled("mdec1: invalid dma %08x\n", chcr);
+ return;
+ }
-
size
= (bcr >> 16) * (bcr & 0xffff);
+
words
= (bcr >> 16) * (bcr & 0xffff);
/* size in byte */
/* size in byte */
- size *= 4;
- /* I guess the memory speed is limitating */
- dmacnt = size;
+ size = words * 4;
if (!(mdec.reg1 & MDEC1_BUSY)) {
/* add to pending */
if (!(mdec.reg1 & MDEC1_BUSY)) {
/* add to pending */
@@
-561,9
+570,16
@@
void psxDma1(u32 adr, u32 bcr, u32 chcr) {
mdec.pending_dma1.bcr = bcr;
mdec.pending_dma1.chcr = chcr;
/* do not free the dma */
mdec.pending_dma1.bcr = bcr;
mdec.pending_dma1.chcr = chcr;
/* do not free the dma */
- } else {
+ return;
+ }
- image = (u8 *)PSXM(adr);
+ adr &= ~3;
+ image = getDmaRam(adr, &words_max);
+ if (image == INVALID_PTR || words > words_max) {
+ log_unhandled("bad dma1 madr %x\n", adr);
+ HW_DMA1_CHCR &= SWAP32(~0x01000000);
+ return;
+ }
if (mdec.reg0 & MDEC0_RGB24) {
/* 16 bits decoding
if (mdec.reg0 & MDEC0_RGB24) {
/* 16 bits decoding
@@
-623,10
+639,13
@@
void psxDma1(u32 adr, u32 bcr, u32 chcr) {
mdec.block_buffer_pos = mdec.block_buffer + size;
}
}
mdec.block_buffer_pos = mdec.block_buffer + size;
}
}
+ if (size < 0)
+ log_unhandled("mdec: bork\n");
/* define the power of mdec */
/* define the power of mdec */
- MDECOUTDMA_INT((int) ((dmacnt* MDEC_BIAS)));
- }
+ set_event(PSXINT_MDECOUTDMA, words * MDEC_BIAS);
+ /* some CPU stalling */
+ psxRegs.cycle += words;
}
void mdec1Interrupt() {
}
void mdec1Interrupt() {
@@
-655,6
+674,7
@@
void mdec1Interrupt() {
*/
/* MDEC_END_OF_DATA avoids read outside memory */
*/
/* MDEC_END_OF_DATA avoids read outside memory */
+ //printf("mdec left %zd, v=%04x\n", mdec.rl_end - mdec.rl, *(mdec.rl));
if (mdec.rl >= mdec.rl_end || SWAP16(*(mdec.rl)) == MDEC_END_OF_DATA) {
mdec.reg1 &= ~(MDEC1_STP|MDEC1_BUSY);
if (HW_DMA0_CHCR & SWAP32(0x01000000))
if (mdec.rl >= mdec.rl_end || SWAP16(*(mdec.rl)) == MDEC_END_OF_DATA) {
mdec.reg1 &= ~(MDEC1_STP|MDEC1_BUSY);
if (HW_DMA0_CHCR & SWAP32(0x01000000))
@@
-672,27
+692,26
@@
void mdec1Interrupt() {
}
int mdecFreeze(void *f, int Mode) {
}
int mdecFreeze(void *f, int Mode) {
- u8 *base = (u8 *)
&psxM[0x100000]
;
+ u8 *base = (u8 *)
psxM
;
u32 v;
gzfreeze(&mdec.reg0, sizeof(mdec.reg0));
gzfreeze(&mdec.reg1, sizeof(mdec.reg1));
u32 v;
gzfreeze(&mdec.reg0, sizeof(mdec.reg0));
gzfreeze(&mdec.reg1, sizeof(mdec.reg1));
- // old code used to save raw pointers..
v = (u8 *)mdec.rl - base;
gzfreeze(&v, sizeof(v));
v = (u8 *)mdec.rl - base;
gzfreeze(&v, sizeof(v));
- mdec.rl = (u16 *)(base + (v & 0xffffe));
+ mdec.rl = (u16 *)(base + (v & 0x
1
ffffe));
v = (u8 *)mdec.rl_end - base;
gzfreeze(&v, sizeof(v));
v = (u8 *)mdec.rl_end - base;
gzfreeze(&v, sizeof(v));
- mdec.rl_end = (u16 *)(base + (v & 0xffffe));
+ mdec.rl_end = (u16 *)(base + (v & 0x
1
ffffe));
v = 0;
if (mdec.block_buffer_pos)
v = 0;
if (mdec.block_buffer_pos)
- v = mdec.block_buffer_pos -
base
;
+ v = mdec.block_buffer_pos -
mdec.block_buffer
;
gzfreeze(&v, sizeof(v));
mdec.block_buffer_pos = 0;
gzfreeze(&v, sizeof(v));
mdec.block_buffer_pos = 0;
- if (v)
- mdec.block_buffer_pos =
base + (v & 0xfffff)
;
+ if (v
&& v < sizeof(mdec.block_buffer)
)
+ mdec.block_buffer_pos =
mdec.block_buffer
;
gzfreeze(&mdec.block_buffer, sizeof(mdec.block_buffer));
gzfreeze(&mdec.pending_dma1, sizeof(mdec.pending_dma1));
gzfreeze(&mdec.block_buffer, sizeof(mdec.block_buffer));
gzfreeze(&mdec.pending_dma1, sizeof(mdec.pending_dma1));