notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libretro: fix unexpected reloc type 0x03 error on Raspberry Pi 3
[picodrive.git]
/
platform
/
libretro
/
libretro.c
diff --git
a/platform/libretro/libretro.c
b/platform/libretro/libretro.c
index
1b914d5
..
934b685
100644
(file)
--- a/
platform/libretro/libretro.c
+++ b/
platform/libretro/libretro.c
@@
-692,7
+692,16
@@
bool retro_unserialize(const void *data, size_t size)
return ret == 0;
}
return ret == 0;
}
-/* cheats - TODO */
+typedef struct patch
+{
+ unsigned int addr;
+ unsigned short data;
+ unsigned char comp;
+} patch;
+
+extern void decode(char *buff, patch *dest);
+extern uint16_t m68k_read16(uint32_t a);
+extern void m68k_write16(uint32_t a, uint16_t d);
void retro_cheat_reset(void)
{
void retro_cheat_reset(void)
{
@@
-702,12
+711,13
@@
void retro_cheat_reset(void)
for (i = 0; i < PicoPatchCount; i++)
{
addr = PicoPatches[i].addr;
for (i = 0; i < PicoPatchCount; i++)
{
addr = PicoPatches[i].addr;
- if (addr < Pico.romsize)
+ if (addr < Pico.romsize)
{
if (PicoPatches[i].active)
*(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old;
if (PicoPatches[i].active)
*(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old;
- else
+ } else {
if (PicoPatches[i].active)
m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
if (PicoPatches[i].active)
m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
+ }
}
PicoPatchUnload();
}
PicoPatchUnload();
@@
-715,21
+725,19
@@
void retro_cheat_reset(void)
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
- struct patch
- {
- unsigned int addr;
- unsigned short data;
- } pt;
- int array_len = 0;
+ patch pt;
+ int array_len = PicoPatchCount;
+ char codeCopy[256];
char *buff;
char *buff;
- //TODO: Split multi-line codes properly
- buff = strtok(code,"+");
+ if (code=='\0') return;
+ strcpy(codeCopy,code);
+ buff = strtok(codeCopy,"+");
- while (buff)
+ while (buff
!= NULL
)
{
decode(buff, &pt);
{
decode(buff, &pt);
- if (pt.addr == (u
nsigned int)-1 || pt.data == (unsigned short)
-1)
+ if (pt.addr == (u
int32_t) -1 || pt.data == (uint16_t)
-1)
{
log_cb(RETRO_LOG_ERROR,"CHEATS: Invalid code: %s\n",buff);
return;
{
log_cb(RETRO_LOG_ERROR,"CHEATS: Invalid code: %s\n",buff);
return;
@@
-750,15
+758,17
@@
void retro_cheat_set(unsigned index, bool enabled, const char *code)
}
strcpy(PicoPatches[PicoPatchCount].code, buff);
}
strcpy(PicoPatches[PicoPatchCount].code, buff);
- PicoPatches[PicoPatchCount].name[51] = "";
PicoPatches[PicoPatchCount].active = enabled;
PicoPatches[PicoPatchCount].addr = pt.addr;
PicoPatches[PicoPatchCount].data = pt.data;
PicoPatches[PicoPatchCount].active = enabled;
PicoPatches[PicoPatchCount].addr = pt.addr;
PicoPatches[PicoPatchCount].data = pt.data;
+ PicoPatches[PicoPatchCount].comp = pt.comp;
if (PicoPatches[PicoPatchCount].addr < Pico.romsize)
if (PicoPatches[PicoPatchCount].addr < Pico.romsize)
- PicoPatches[PicoPatchCount].data_old = *(u
nsigned shor
t *)(Pico.rom + PicoPatches[PicoPatchCount].addr);
+ PicoPatches[PicoPatchCount].data_old = *(u
int16_
t *)(Pico.rom + PicoPatches[PicoPatchCount].addr);
else
else
- PicoPatches[PicoPatchCount].data_old = (u
nsigned shor
t) m68k_read16(PicoPatches[PicoPatchCount].addr);
+ PicoPatches[PicoPatchCount].data_old = (u
int16_
t) m68k_read16(PicoPatches[PicoPatchCount].addr);
PicoPatchCount++;
PicoPatchCount++;
+
+ buff = strtok(NULL,"+");
}
}
}
}
@@
-1116,7
+1126,7
@@
void *retro_get_memory_data(unsigned type)
break;
case RETRO_MEMORY_SYSTEM_RAM:
if (PicoAHW & PAHW_SMS)
break;
case RETRO_MEMORY_SYSTEM_RAM:
if (PicoAHW & PAHW_SMS)
- data = Pico.
vramb
;
+ data = Pico.
zram
;
else
data = Pico.ram;
break;
else
data = Pico.ram;
break;
@@
-1152,7
+1162,7
@@
size_t retro_get_memory_size(unsigned type)
case RETRO_MEMORY_SYSTEM_RAM:
if (PicoAHW & PAHW_SMS)
case RETRO_MEMORY_SYSTEM_RAM:
if (PicoAHW & PAHW_SMS)
- return
sizeof(Pico.vramb)
;
+ return
0x2000
;
else
return sizeof(Pico.ram);
else
return sizeof(Pico.ram);