FC2ブログ
2011/12/24

JPCPS CWCHEAT


ろむでおもいだしたけどPSPにもたしかエミュがあったな。動作はまちまちっぽいけど、みっくみくはPVぐらいなら問題ないのか、ものによっては20万のじおんCPUでもあれっぽけど。改造コードたいおうとかいてあっtど,SVNみるとUSERSPACEがベースアドレスか?ためしたけどがーべじだかであどれすがかわってるのかも FIXED(STATIC) USERSPACEじゃねえのか?それともintになってるからLONGじゃないとたらないとか、64bitだし。debugeerはおかしくなったりしていまいち使えないか。

//JPCPS_CWCHEAT対応 0x0,0x1,0x2,0x3,0x4,0x5,0x7 0x6ポインタがみ対応まあJAVもC#めもりぶっったくのはCと違ってあつかいずらいからな、comm - 0x10000000じゃなくて comm & 0x0FFFFFFFでもよさそうだけど
for (int i = 0; i < codes.length; i++) {
comm = (int)Long.parseLong(codes[i].split(" ")[0].substring(2), 16);
arg = (int)Long.parseLong(codes[i].split(" ")[1].substring(2), 16);

if ((comm >> 28) == 0) { // 8-bit write.
int addr = MemoryMap.START_USERSPACE + comm;
if (Memory.isAddressGood(addr)) {
mem.write8(addr, (byte) arg);
}
} else if ((comm >> 28) == 0x1) { // 16-bit write.
int addr = MemoryMap.START_USERSPACE + (comm - 0x10000000);
if (Memory.isAddressGood(addr)) {
mem.write16(addr, (short) arg);
}
} else if ((comm >> 28) == 0x2) { // 32-bit write.
int addr = MemoryMap.START_USERSPACE + (comm - 0x20000000);
if (Memory.isAddressGood(addr)) {
mem.write32(addr, arg);
}
} else if ((comm >> 8) == 0x301000) { // 8-bit increment.
int addr = MemoryMap.START_USERSPACE + arg;
int data = (comm & 0xFF);
if (Memory.isAddressGood(addr)) {
byte tmp = (byte) (mem.read8(addr) + data);
mem.write8(addr, tmp);
}
} else if ((comm >> 8) == 0x302000) { // 8-bit decrement.
int addr = MemoryMap.START_USERSPACE + arg;
int data = (comm & 0xFF);
if (Memory.isAddressGood(addr)) {
byte tmp = (byte) (mem.read8(addr) - data);
mem.write8(addr, tmp);
}
} else if ((comm >> 16) == 0x3030) { // 16-bit increment.
int addr = MemoryMap.START_USERSPACE + arg;
int data = (comm & 0xFFFF);
if (Memory.isAddressGood(addr)) {
short tmp = (short) (mem.read16(addr) + data);
mem.write16(addr, tmp);
}
} else if ((comm >> 16) == 0x3040) { // 16-bit decrement.
int addr = MemoryMap.START_USERSPACE + arg;
int data = (comm & 0xFFFF);
if (Memory.isAddressGood(addr)) {
short tmp = (short) (mem.read16(addr) - data);
mem.write16(addr, tmp);
}
} else if (comm == 0x30500000) { // 32-bit increment.
int addr = MemoryMap.START_USERSPACE + arg;
int data = (int)Long.parseLong(codes[i + 1].split(" ")[0].substring(2), 16);
if (Memory.isAddressGood(addr)) {
int tmp = (mem.read32(addr) + data);
mem.write32(addr, tmp);
}
} else if (comm == 0x30600000) { // 32-bit decrement.
int addr = MemoryMap.START_USERSPACE + arg;
int data = (int)Long.parseLong(codes[i + 1].split(" ")[0].substring(2), 16);
if (Memory.isAddressGood(addr)) {
int tmp = (mem.read32(addr) - data);
mem.write32(addr, tmp);
}
} else if ((comm >> 28) == 0x7) { // Boolean commands.
int addr = MemoryMap.START_USERSPACE + (comm - 0x70000000);
if ((arg >> 16) == 0x0) { // 8-bit OR.
if (Memory.isAddressGood(addr)) {
byte val1 = (byte) (arg & 0xFF);
byte val2 = (byte) mem.read8(addr);
mem.write8(addr, (byte) (val1 | val2));
}
} else if ((arg >> 16) == 0x2) { // 8-bit AND.
if (Memory.isAddressGood(addr)) {
byte val1 = (byte) (arg & 0xFF);
byte val2 = (byte) mem.read8(addr);
mem.write8(addr, (byte) (val1 & val2));
}
} else if ((arg >> 16) == 0x4) { // 8-bit XOR.
if (Memory.isAddressGood(addr)) {
byte val1 = (byte) (arg & 0xFF);
byte val2 = (byte) mem.read8(addr);
mem.write8(addr, (byte) (val1 ^ val2));
}
} else if ((arg >> 16) == 0x1) { // 16-bit OR.
if (Memory.isAddressGood(addr)) {
short val1 = (short) (arg & 0xFFFF);
short val2 = (short) mem.read16(addr);
mem.write16(addr, (short) (val1 | val2));
}
} else if ((arg >> 16) == 0x3) { // 16-bit AND.
if (Memory.isAddressGood(addr)) {
short val1 = (short) (arg & 0xFFFF);
short val2 = (short) mem.read16(addr);
mem.write16(addr, (short) (val1 & val2));
}
} else if ((arg >> 16) == 0x5) { // 16-bit XOR.
if (Memory.isAddressGood(addr)) {
short val1 = (short) (arg & 0xFFFF);
short val2 = (short) mem.read16(addr);
mem.write16(addr, (short) (val1 ^ val2));
}
}
} else if ((comm >> 28) == 0x5) { // Memcpy command.
int srcAddr = MemoryMap.START_USERSPACE + (comm - 0x50000000);
int destAddr = (int)Long.parseLong(codes[i + 1].split(" ")[0].substring(2), 16);
if (Memory.isAddressGood(srcAddr) && Memory.isAddressGood(destAddr)) {
mem.memcpy(destAddr, srcAddr, arg);
}
} else if ((comm >> 28) == 0x4) { // 32-bit patch code.
int addr = MemoryMap.START_USERSPACE + (comm - 0x40000000);
int data = (int)Long.parseLong(codes[i + 1].split(" ")[0].substring(2), 16);
int dataAdd = (int)Long.parseLong(codes[i + 1].split(" ")[1].substring(2), 16);

int maxAddr = (arg >> 16) & 0xFFFF;
int stepAddr = (arg & 0xFFFF) * 4;
for (int a = 0; a < maxAddr; a++) {
if (Memory.isAddressGood(addr)) {
mem.write32(addr, data);
}
addr += stepAddr;
data += dataAdd;
}
} else if ((comm >> 28) == 0x8) { // 8-bit and 16-bit patch code.
int addr = MemoryMap.START_USERSPACE + (comm - 0x40000000);
int data = (int)Long.parseLong(codes[i + 1].split(" ")[0].substring(2), 16);
int dataAdd = (int)Long.parseLong(codes[i + 1].split(" ")[1].substring(2), 16);

int maxAddr = (arg >> 16) & 0xFFFF;
int stepAddr = (arg & 0xFFFF) * 4;
for (int a = 0; a < maxAddr; a++) {
if (Memory.isAddressGood(addr)) {
if ((data >> 16) == 0x1000) {
mem.write16(addr, (short) (data & 0xFFFF));
} else {
mem.write8(addr, (byte) (data & 0xFF));
}
}


//ぽいんたねた,SIRANE
else if ((comm >> 28) == 0x6) {
//long need big memorymap!!!
long addr = MemoryMap.START_USERSPACE + (comm & 0x01FFFFFFF);
uint32 pointer = (uint)Long.parseLong(codes[i + 1].split(" ")[0].substring(2), 16);
uint32 offset = (uint)Long.parseLong(codes[i + 1].split(" ")[1].substring(2), 16);

long temp = mem.read32(addr)+(MemoryMap.START_USERSPACE- 0x8800000);//C言語 *(unsinged int *)(temp)
uint bit = (pointer >>> 16)& 0xF;

if ((pointer & 0xFFFF)=1){
if (bit > 2) {
temp -=offset;
bit -=2;
}
else{
temp +=offset;
}
if (Memory.isAddressGood(tmp)) {
if (bit>=2){mem.write16(tmp, arg ));}
else if (bit=1){mem.write16(tmp, (short) (arg & 0xFFFF));}
else{mem.write8(addr, (byte) (tmp & 0xFF));}
}
addr += stepAddr;
data += dataAdd;
}

21:52 | JPCPSCOMMENT(0)TRACKBACK(0)  TOP