make non-zlib save compression possible
[pcsx_rearmed.git] / libpcsxcore / psxbios.c
index cad69b3..fdc129e 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "psxbios.h"
 #include "psxhw.h"
+#include "gpu.h"
+#include <zlib.h>
 
 #undef SysPrintf
 #define SysPrintf if (Config.PsxOut) printf
@@ -804,8 +806,8 @@ void psxBios_qsort() { // 0x31
 }
 
 void psxBios_malloc() { // 0x33
-       unsigned int *chunk, *newchunk;
-       unsigned int dsize, csize, cstat;
+       unsigned int *chunk, *newchunk = NULL;
+       unsigned int dsize = 0, csize, cstat;
        int colflag;
 #ifdef PSXBIOS_LOG
        PSXBIOS_LOG("psxBios_%s\n", biosA0n[0x33]);
@@ -875,7 +877,7 @@ void psxBios_malloc() { // 0x33
                // split free chunk
                *chunk = SWAP32(dsize);
                newchunk = (u32*)((uptr)chunk + dsize + 4);
-               *newchunk = SWAP32((csize - dsize - 4) & 0xfffffffc | 1);
+               *newchunk = SWAP32(((csize - dsize - 4) & 0xfffffffc) | 1);
        }
 
        // return pointer to allocated memory
@@ -938,7 +940,7 @@ void psxBios_InitHeap() { // 0x39
        heap_end = (u32 *)((u8 *)heap_addr + size);
        *heap_addr = SWAP32(size | 1);
 
-       SysPrintf("InitHeap %x,%x : %x %x\n",a0,a1, (uptr)heap_addr-(uptr)psxM, size);
+       SysPrintf("InitHeap %x,%x : %x %x\n",a0,a1, (int)((uptr)heap_addr-(uptr)psxM), size);
 
        pc0 = ra;
 }
@@ -1010,7 +1012,7 @@ _start:
 
        memcpy((char*)PSXM(sp), save, 4 * 4);
 
-       SysPrintf(tmp);
+       SysPrintf("%s", tmp);
 
        pc0 = ra;
 }
@@ -1118,6 +1120,7 @@ void psxBios_mem2vram() { // 0x47
 
 void psxBios_SendGPU() { // 0x48
        GPU_writeStatus(a0);
+       gpuSyncPluginSR();
        pc0 = ra;
 }
 
@@ -1818,7 +1821,7 @@ void psxBios_putchar() { // 3d
 }
 
 void psxBios_puts() { // 3e/3f
-       SysPrintf(Ra0);
+       SysPrintf("%s", Ra0);
        pc0 = ra;
 }