mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
psp bugfixes, tools
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@285 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
9d917eea21
commit
c5b61ac25d
4 changed files with 151 additions and 12 deletions
|
@ -448,7 +448,8 @@ PICO_INTERNAL void z80_pack(unsigned char *data)
|
|||
memcpy(data+4, &drZ80, 0x54);
|
||||
#elif defined(_USE_CZ80)
|
||||
*(int *)data = 0x00007a43; // "Cz"
|
||||
memcpy(data+4, &CZ80, (INT32)&CZ80.BasePC - (INT32)&CZ80);
|
||||
*(int *)(data+4) = Cz80_Get_Reg(&CZ80, CZ80_PC);
|
||||
memcpy(data+8, &CZ80, (INT32)&CZ80.BasePC - (INT32)&CZ80);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -476,9 +477,10 @@ PICO_INTERNAL void z80_unpack(unsigned char *data)
|
|||
z80_int(); // try to goto int handler, maybe we won't execute trash there?
|
||||
}
|
||||
#elif defined(_USE_CZ80)
|
||||
if (*(int *)data == 0x00007a43) // "Cz" save?
|
||||
memcpy(&CZ80, data+4, (INT32)&CZ80.BasePC - (INT32)&CZ80);
|
||||
else {
|
||||
if (*(int *)data == 0x00007a43) { // "Cz" save?
|
||||
memcpy(&CZ80, data+8, (INT32)&CZ80.BasePC - (INT32)&CZ80);
|
||||
Cz80_Set_Reg(&CZ80, CZ80_PC, *(int *)(data+4));
|
||||
} else {
|
||||
z80_reset();
|
||||
z80_int();
|
||||
}
|
||||
|
|
|
@ -485,7 +485,7 @@ static int sound_thread(SceSize args, void *argp)
|
|||
{
|
||||
int ret;
|
||||
|
||||
lprintf("sound_thread: started, priority %i\n", sceKernelGetThreadCurrentPriority());
|
||||
lprintf("sthr: started, priority %i\n", sceKernelGetThreadCurrentPriority());
|
||||
|
||||
while (!sound_thread_exit)
|
||||
{
|
||||
|
@ -521,6 +521,8 @@ static void sound_init(void)
|
|||
sound_sem = sceKernelCreateSema("sndsem", 0, 0, 1, NULL);
|
||||
if (sound_sem < 0) lprintf("sceKernelCreateSema() failed: %i\n", sound_sem);
|
||||
|
||||
samples_made = samples_done = 0;
|
||||
samples_block = SOUND_BLOCK_SIZE_NTSC; // make sure it goes to sema
|
||||
sound_thread_exit = 0;
|
||||
thid = sceKernelCreateThread("sndthread", sound_thread, 0x12, 0x10000, 0, NULL);
|
||||
if (thid >= 0)
|
||||
|
@ -683,13 +685,10 @@ static void RunEvents(unsigned int which)
|
|||
|
||||
vidResetMode();
|
||||
|
||||
if (PicoOpt&0x10) {
|
||||
strcpy(noticeMsg, " 8bit fast renderer");
|
||||
} else if (currentConfig.EmuOpt&0x80) {
|
||||
strcpy(noticeMsg, "16bit accurate renderer");
|
||||
} else {
|
||||
strcpy(noticeMsg, " 8bit accurate renderer");
|
||||
}
|
||||
if (PicoOpt&0x10)
|
||||
strcpy(noticeMsg, "fast renderer");
|
||||
else if (currentConfig.EmuOpt&0x80)
|
||||
strcpy(noticeMsg, "accurate renderer");
|
||||
|
||||
noticeMsgTime = sceKernelGetSystemTimeLow();
|
||||
}
|
||||
|
|
68
tools/compdecomp.c
Normal file
68
tools/compdecomp.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* :make compdecomp CFLAGS=-Wall LDFLAGS=-lz
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#define MEM_LIMIT (128*1024*1024)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
void *pi, *po = NULL;
|
||||
FILE *fi, *fo;
|
||||
int ret, si, so;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
printf("usage: %s <0|1> <infile> <outfile>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fi = fopen(argv[2], "rb");
|
||||
if (fi == NULL) return 2;
|
||||
|
||||
fseek(fi, 0, SEEK_END);
|
||||
si = ftell(fi);
|
||||
fseek(fi, 0, SEEK_SET);
|
||||
pi = malloc(si);
|
||||
if (pi == NULL) return 3;
|
||||
fread(pi, 1, si, fi);
|
||||
fclose(fi);
|
||||
|
||||
if (atoi(argv[1]))
|
||||
{
|
||||
// decompress
|
||||
so = si;
|
||||
do
|
||||
{
|
||||
so *= 16;
|
||||
if (so > MEM_LIMIT) return 4;
|
||||
po = realloc(po, so);
|
||||
if (po == NULL) return 5;
|
||||
ret = uncompress(po, (uLongf *) &so, pi, si);
|
||||
}
|
||||
while (ret == Z_BUF_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
// compress
|
||||
so = si + 1024;
|
||||
po = malloc(so);
|
||||
if (po == NULL) return 5;
|
||||
ret = compress2(po, (uLongf *) &so, pi, si, Z_BEST_COMPRESSION);
|
||||
}
|
||||
|
||||
if (ret == Z_OK)
|
||||
{
|
||||
fo = fopen(argv[3], "wb");
|
||||
if (fo == NULL) return 6;
|
||||
fwrite(po, 1, so, fo);
|
||||
fclose(fo);
|
||||
}
|
||||
|
||||
printf("result %i, size %i -> %i\n", ret, si, so);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
70
tools/mkt1.c
Normal file
70
tools/mkt1.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static FILE *fo = NULL;
|
||||
|
||||
static void out(int r, int is_last)
|
||||
{
|
||||
if (!is_last)
|
||||
{
|
||||
fprintf(fo, " or $t%i, $t%i, $a2\n", r, r);
|
||||
fprintf(fo, " sb $t%i, %i($a0)\n", r, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(fo, " or $t%i, $t%i, $a2\n", r, r);
|
||||
fprintf(fo, " jr $ra\n");
|
||||
fprintf(fo, " sb $t%i, %i($a0)\n", r, r);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char pattern_db[0x100];
|
||||
|
||||
static int check(unsigned char i)
|
||||
{
|
||||
if (!pattern_db[i]) {
|
||||
fprintf(fo, "tile%i%i%i%i%i%i%i%i:\n", (i&0x80)?1:0, (i&0x40)?1:0, (i&0x20)?1:0, (i&0x10)?1:0,
|
||||
(i&0x08)?1:0, (i&0x04)?1:0, (i&0x02)?1:0, (i&0x01)?1:0);
|
||||
pattern_db[i] = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
|
||||
fo = fopen("out.s", "w");
|
||||
if (!fo) return 1;
|
||||
|
||||
memset(pattern_db, 0, sizeof(pattern_db));
|
||||
|
||||
for (i = 0xff; i > 0; i--)
|
||||
{
|
||||
if (check(i)) continue;
|
||||
|
||||
if (i & 0x01) out(0, 0);
|
||||
check(i&0xfe);
|
||||
if (i & 0x02) out(1, 0);
|
||||
check(i&0xfc);
|
||||
if (i & 0x04) out(2, 0);
|
||||
check(i&0xf8);
|
||||
if (i & 0x08) out(3, 0);
|
||||
check(i&0xf0);
|
||||
if (i & 0x10) out(4, 0);
|
||||
check(i&0xe0);
|
||||
if (i & 0x20) out(5, 0);
|
||||
check(i&0xc0);
|
||||
if (i & 0x40) out(6, 0);
|
||||
check(i&0x80);
|
||||
if (i & 0x80) out(7, 1);
|
||||
}
|
||||
|
||||
fclose(fo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue