11-16-2018, 11:52 PM
I'm reading the code of Thor in the game "Another Day in hell" and Thor was a file for this called flash.c. I understand that this file overwrite the methods flasha and GetSavedData right?
I think that this can help me but I have a big doubt. I'm never learn assembly and I don't understand any values or vars, etc.
Loic, you say me that I only want to know the SAVEOFFSET and the BLOCK_NB. The saveoffset it's an array? How can I determinate the size in my case and how to set the value?
This is the code of Thor to do it.
I think that this can help me but I have a big doubt. I'm never learn assembly and I don't understand any values or vars, etc.
Loic, you say me that I only want to know the SAVEOFFSET and the BLOCK_NB. The saveoffset it's an array? How can I determinate the size in my case and how to set the value?
This is the code of Thor to do it.
Code:
#include "ngpc.h"
u8 data[256];
#define MAGIC_NB 0xcafebabe // java rules !
void flash(void *data)
{
__ASM("SAVEOFFSET EQU 0x1e0000");
__ASM("BLOCK_NB EQU 30");
__ASM("VECT_FLASHWRITE EQU 6");
__ASM("VECT_FLASHERS EQU 8");
__ASM("rWDCR EQU 0x6f");
__ASM("WD_CLR EQU 0x4e");
// Erase block first (mandatory) : 64kb for only 256 bytes
__ASM(" ld ra3,0");
__ASM(" ld rb3,BLOCK_NB");
__ASM(" ld rw3,VECT_FLASHERS");
__ASM(" ld (rWDCR),WD_CLR");
__ASM(" swi 1");
// Then write data
__ASM(" ld ra3,0");
__ASM(" ld rbc3,1"); // 256 bytes
__ASM(" ld xhl,(xsp+4)");
__ASM(" ld xhl3,xhl");
__ASM(" ld xde3,SAVEOFFSET");
__ASM(" ld rw3,VECT_FLASHWRITE");
__ASM(" ld (rWDCR),WD_CLR");
__ASM(" swi 1");
__ASM(" ld (rWDCR),WD_CLR");
}
void getSavedData()
{
u32 *ptr = (u32*)(0x200000+0x1e0000);
u32 *ptrData = (u32*)data;
u8 i;
if (*ptr == MAGIC_NB) // Data saved
{
for (i=0;i<64;i++)
ptrData[i] = ptr[i];
}
else // No data
{
ptrData[0] = MAGIC_NB;
for (i=1;i<64;i++)
ptrData[i] = 0;
}
}
