Ram Hack On The Wiki


namco

Member
Joined
Mar 22, 2006
Messages
409
Age
40
Location
Manchester, UK
Website
www.stupendous-stuff.com
I'm a little confused of which values to reset regarding the below code:

CODE

static const unsigned short MEMTIMEX0 = 0x3802;
static const unsigned short MEMTIMEX1 = 0x3804;

union memtimex0_t {
struct {
unsigned int tRCD : 4; // default = 2
unsigned int tRP : 4; // default = 15
unsigned int tRFC : 4; // default = 4
unsigned int tMRD : 4; // default = 4
} s;
unsigned short i;
};

union memtimex1_t {
struct {
unsigned int tWR : 4; // default = 2
unsigned int tRAS : 4; // default = 7
unsigned int tRC : 4; // default = 10
unsigned int LAT : 1; // default = 1; apparently readonly
unsigned int reserved : 2; // readonly

// Write: Set 1 to set new SDRAM mode parameter;
// Read: 0 = complete, 1 = busy
unsigned int ModeStatusSet : 1;
} s;
unsigned short i;
};

void ramhack()
{
memtimex0_t t0;
t0.i = memreg16(MEMTIMEX0);
t0.s.tRCD = 1;
t0.s.tRP = 1;
t0.s.tRFC = 0;
t0.s.tMRD = 0;
memreg16(MEMTIMEX0) = t0.i;

memtimex1_t t1;
t1.i = memreg16(MEMTIMEX1);
t1.s.tWR = 0;
t1.s.tRAS = 3;
t1.s.tRC = 5;

// The docs say to write 1 to set new mode
// parameter but seems to work without?
t1.s.ModeStatusSet = 1;
memreg16(MEMTIMEX1) = t1.i;

// Wait until mode is set. May not be necessary?
do {
t1.i = memreg16(MEMTIMEX1);
} while (t1.s.ModeStatusSet);
}



do I make another function like:

CODE

void unramhack()
{
memtimex0_t t0;
t0.i = memreg16(MEMTIMEX0);
t0.s.tRCD = 2; // default values
t0.s.tRP = 15; // default values
t0.s.tRFC = 4;
t0.s.tMRD = 4;
memreg16(MEMTIMEX0) = t0.i;
}



and run it before exit??

Thanks.
 

Trenki

Member
Joined
Jun 15, 2006
Messages
114
Age
39
Location
South Tyrol, Italy
Website
www.trenki.net
The default values specified in the comments in the above source code were taken from the MMSP2 Documentation and as we all know may not necessarily be correct.

You can use the cpu-lcd-ram whatever tweak tool to inspect the actual values in the registers after boot (note, you will have to subtract 1 since the register values are 0 based while this tool has 1 as its smallest value) or you can read the values from the register yourself.

I would say you simply make a function which reads the current register values from both register and stores them somewhere and then adapt the function so set new register values to simply take the stored register values instead of some fixed ones.
 
Top