aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authorgameblabla2019-07-18 02:01:34 +0200
committergameblabla2019-07-18 02:01:34 +0200
commit391b1d5b1fe4f68676835058af609535feb798a9 (patch)
tree3336d8496fe740c7552eb31e1bdb6cc676ed46b4 /libpcsxcore
parentf42e1e9003d052bcfcadd5955d2396f11ea0f3c5 (diff)
downloadpcsx_rearmed-391b1d5b1fe4f68676835058af609535feb798a9.tar.gz
pcsx_rearmed-391b1d5b1fe4f68676835058af609535feb798a9.tar.bz2
pcsx_rearmed-391b1d5b1fe4f68676835058af609535feb798a9.zip
psxbios: Better realloc implementation
This should be closer to the real behaviour as described by nocash. It doesn't do any bcopy though but it shouldn't be too much different other than that.
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/psxbios.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c
index 90c11ae..fc28ff8 100644
--- a/libpcsxcore/psxbios.c
+++ b/libpcsxcore/psxbios.c
@@ -1010,9 +1010,24 @@ void psxBios_realloc() { // 0x38
#endif
a0 = block;
- psxBios_free();
- a0 = size;
- psxBios_malloc();
+ /* If "old_buf" is zero, executes malloc(new_size), and returns r2=new_buf (or 0=failed). */
+ if (block == 0)
+ {
+ psxBios_malloc();
+ }
+ /* Else, if "new_size" is zero, executes free(old_buf), and returns r2=garbage. */
+ else if (size == 0)
+ {
+ psxBios_free();
+ }
+ /* Else, executes malloc(new_size), bcopy(old_buf,new_buf,new_size), and free(old_buf), and returns r2=new_buf (or 0=failed). */
+ /* Note that it is not quite implemented this way here. */
+ else
+ {
+ psxBios_free();
+ a0 = size;
+ psxBios_malloc();
+ }
}