这里是下面链接到它的一些匿名的内部功能,似乎每个开关2个数组索引的JavaScript代码,他们似乎还有些太超值了,但我不知道在哪里,他们都回到memoryReadJumpCompile()
函数或这两个数组指数的。
他们很有可能将reuturning实际数组索引和函数名编译似乎每次你打电话任何这些数组索引,他们将重新评估与它们相关的一些新的结果的功能仍然不知道在哪里,结果是存储如果实际指数的保持功能,我最好的猜测是实际的数组索引就像函数名和它们是由另一段代码,其中前所未有其他指数的被地方称为代码,但可以说,前2个例数组索引返回。
this.memoryHighReader[0] = this.memoryReader[0xFF00]
因此,他们都成为了同样的事情,我发现,它就会在指令执行器进行处理,像这样
case 242:
a.registerA = a.memoryHighReader[a.registerC](a, a.registerC);
break;
GameBoyCore.prototype.memoryReadJumpCompile = function () {
//...
else if (index >= 0xFF00) {
switch (index) {
case 0xFF00:
//JOYPAD:
this.memoryHighReader[0] = this.memoryReader[0xFF00] = function (parentObj, address) {
return 0xC0 | parentObj.memory[0xFF00]; //Top nibble returns as set.
}
break;
case 0xFF01:
//SB
this.memoryHighReader[0x01] = this.memoryReader[0xFF01] = function (parentObj, address) {
return (parentObj.memory[0xFF02] < 0x80) ? parentObj.memory[0xFF01] : 0xFF;
}
break;
case 0xFF02:
//SC
if (this.cGBC) {
this.memoryHighReader[0x02] = this.memoryReader[0xFF02] = function (parentObj, address) {
return ((parentObj.serialTimer <= 0) ? 0x7C : 0xFC) | parentObj.memory[0xFF02];
}
}
else {
this.memoryHighReader[0x02] = this.memoryReader[0xFF02] = function (parentObj, address) {
return ((parentObj.serialTimer <= 0) ? 0x7E : 0xFE) | parentObj.memory[0xFF02];
}
}
break;
}
}
以上的JavaScript几乎像Java,但我不明白如何将转换function(parentObj, address) {...}
在memoryReadJumpCompile
什么最简单的方法将其转换为Java,而无需使用任何接口。 我想用一个switch()
以下是我迄今为止在Java中(因为我用精缩JavaScript版本时,我开始将它不使用十六进制字母)
public void memoryReadJumpCompile() {
for (var a = 0; a <= 65535; a++) {
if (a < 16384) {
this.memoryReader[a] = this.memoryReadNormal;
} else {
if (a < 32768) {
this.memoryReader[a] = this.memoryReadROM;
} else {
if (a < 38912) {
this.memoryReader[a] = (this.cGBC) ? this.VRAMDATAReadCGBCPU : this.VRAMDATAReadDMGCPU;
} else {
if (a < 40960) {
this.memoryReader[a] = (this.cGBC) ? this.VRAMCHRReadCGBCPU : this.VRAMCHRReadDMGCPU;
} else {
if (a >= 40960 && a < 49152) {
if ((this.numRAMBanks == 1 / 16 && a < 41472) || this.numRAMBanks >= 1) {
if (this.cMBC7) {
this.memoryReader[a] = this.memoryReadMBC7;
} else {
if (!this.cMBC3) {
this.memoryReader[a] = this.memoryReadMBC;
} else {
this.memoryReader[a] = this.memoryReadMBC3;
}
}
} else {
this.memoryReader[a] = this.memoryReadBAD;
}
} else {
if (a >= 49152 && a < 57344) {
if (!this.cGBC || a < 53248) {
this.memoryReader[a] = this.memoryReadNormal;
} else {
this.memoryReader[a] = this.memoryReadGBCMemory;
}
} else {
if (a >= 57344 && a < 65024) {
if (!this.cGBC || a < 61440) {
this.memoryReader[a] = this.memoryReadECHONormal;
} else {
this.memoryReader[a] = this.memoryReadECHOGBCMemory;
}
} else {
if (a < 65184) {
this.memoryReader[a] = this.memoryReadOAM;
} else {
if (this.cGBC && a >= 65184 && a < 65280) {
this.memoryReader[a] = this.memoryReadNormal;
} else {
if (a >= 65280) {
switch (a) {
case 65280:
this.memoryHighReader[0] = this.memoryReader[65280] = function(c, b) {
return 192 | c.memory[65280];
};
break;
case 65281:
this.memoryHighReader[1] = this.memoryReader[65281] = function(c, b) {
return (c.memory[65282] < 128) ? c.memory[65281] : 255;
};
break;
case 65282:
if (this.cGBC) {
this.memoryHighReader[2] = this.memoryReader[65282] = function(c, b) {
return ((c.serialTimer <= 0) ? 124 : 252) | c.memory[65282];
}
} else {
this.memoryHighReader[2] = this.memoryReader[65282] = function(c, b) {
return ((c.serialTimer <= 0) ? 126 : 254) | c.memory[65282];
}
}
break;
case 65283:
this.memoryHighReader[3] = this.memoryReader[65283] = this.memoryReadBAD;
break;
case 65284:
this.memoryHighReader[4] = this.memoryReader[65284] = function(c, b) {
c.memory[65284] = (c.memory[65284] + (c.DIVTicks >> 8)) & 255;
c.DIVTicks &= 255;
return c.memory[65284];
};
break;
case 65285:
case 65286:
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
this.memoryReader[a] = this.memoryReadNormal;
break;
case 65287:
this.memoryHighReader[7] = this.memoryReader[65287] = function(c, b) {
return 248 | c.memory[65287];
};
break;
case 65288:
case 65289:
case 65290:
case 65291:
case 65292:
case 65293:
case 65294:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadBAD;
break;
case 65295:
this.memoryHighReader[15] = this.memoryReader[65295] = function(c, b) {
return 224 | c.interruptsRequested;
};
break;
case 65296:
this.memoryHighReader[16] = this.memoryReader[65296] = function(c, b) {
return 128 | c.memory[65296];
};
break;
case 65297:
this.memoryHighReader[17] = this.memoryReader[65297] = function(c, b) {
return 63 | c.memory[65297];
};
break;
case 65298:
this.memoryHighReader[18] = this.memoryHighReadNormal;
this.memoryReader[65298] = this.memoryReadNormal;
break;
case 65299:
this.memoryHighReader[19] = this.memoryReader[65299] = this.memoryReadBAD;
break;
case 65300:
this.memoryHighReader[20] = this.memoryReader[65300] = function(c, b) {
return 191 | c.memory[65300];
};
break;
case 65301:
this.memoryHighReader[21] = this.memoryReadBAD;
this.memoryReader[65301] = this.memoryReadBAD;
break;
case 65302:
this.memoryHighReader[22] = this.memoryReader[65302] = function(c, b) {
return 63 | c.memory[65302];
};
break;
case 65303:
this.memoryHighReader[23] = this.memoryHighReadNormal;
this.memoryReader[65303] = this.memoryReadNormal;
break;
case 65304:
this.memoryHighReader[24] = this.memoryReader[65304] = this.memoryReadBAD;
break;
case 65305:
this.memoryHighReader[25] = this.memoryReader[65305] = function(c, b) {
return 191 | c.memory[65305];
};
break;
case 65306:
this.memoryHighReader[26] = this.memoryReader[65306] = function(c, b) {
return 127 | c.memory[65306];
};
break;
case 65307:
this.memoryHighReader[27] = this.memoryReader[65307] = this.memoryReadBAD;
break;
case 65308:
this.memoryHighReader[28] = this.memoryReader[65308] = function(c, b) {
return 159 | c.memory[65308];
};
break;
case 65309:
this.memoryHighReader[29] = this.memoryReader[65309] = this.memoryReadBAD;
break;
case 65310:
this.memoryHighReader[30] = this.memoryReader[65310] = function(c, b) {
return 191 | c.memory[65310];
};
break;
case 65311:
case 65312:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadBAD;
break;
case 65313:
case 65314:
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
this.memoryReader[a] = this.memoryReadNormal;
break;
case 65315:
this.memoryHighReader[35] = this.memoryReader[65315] = function(c, b) {
return 191 | c.memory[65315];
};
break;
case 65316:
case 65317:
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
this.memoryReader[a] = this.memoryReadNormal;
break;
case 65318:
this.memoryHighReader[38] = this.memoryReader[65318] = function(c, b) {
c.audioJIT();
return 112 | c.memory[65318];
};
break;
case 65319:
case 65320:
case 65321:
case 65322:
case 65323:
case 65324:
case 65325:
case 65326:
case 65327:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadBAD;
break;
case 65328:
case 65329:
case 65330:
case 65331:
case 65332:
case 65333:
case 65334:
case 65335:
case 65336:
case 65337:
case 65338:
case 65339:
case 65340:
case 65341:
case 65342:
case 65343:
this.memoryReader[a] = function(c, b) {
return (c.channel3canPlay) ? c.memory[65280 | (c.channel3lastSampleLookup >> 1)] : c.memory[b];
};
this.memoryHighReader[a & 255] = function(c, b) {
return (c.channel3canPlay) ? c.memory[65280 | (c.channel3lastSampleLookup >> 1)] : c.memory[65280 | b];
};
break;
case 65344:
this.memoryHighReader[64] = this.memoryHighReadNormal;
this.memoryReader[65344] = this.memoryReadNormal;
break;
case 65345:
this.memoryHighReader[65] = this.memoryReader[65345] = function(c, b) {
return 128 | c.memory[65345] | c.modeSTAT;
};
break;
case 65346:
this.memoryHighReader[66] = this.memoryReader[65346] = function(c, b) {
return c.backgroundY;
};
break;
case 65347:
this.memoryHighReader[67] = this.memoryReader[65347] = function(c, b) {
return c.backgroundX;
};
break;
case 65348:
this.memoryHighReader[68] = this.memoryReader[65348] = function(c, b) {
return ((c.LCDisOn) ? c.memory[65348] : 0);
};
break;
case 65349:
case 65350:
case 65351:
case 65352:
case 65353:
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
this.memoryReader[a] = this.memoryReadNormal;
break;
case 65354:
this.memoryHighReader[74] = this.memoryReader[65354] = function(c, b) {
return c.windowY;
};
break;
case 65355:
this.memoryHighReader[75] = this.memoryHighReadNormal;
this.memoryReader[65355] = this.memoryReadNormal;
break;
case 65356:
this.memoryHighReader[76] = this.memoryReader[65356] = this.memoryReadBAD;
break;
case 65357:
this.memoryHighReader[77] = this.memoryHighReadNormal;
this.memoryReader[65357] = this.memoryReadNormal;
break;
case 65358:
this.memoryHighReader[78] = this.memoryReader[65358] = this.memoryReadBAD;
break;
case 65359:
this.memoryHighReader[79] = this.memoryReader[65359] = function(c, b) {
return c.currVRAMBank;
};
break;
case 65360:
case 65361:
case 65362:
case 65363:
case 65364:
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
this.memoryReader[a] = this.memoryReadNormal;
break;
case 65365:
if (this.cGBC) {
this.memoryHighReader[85] = this.memoryReader[65365] = function(c, b) {
if (!c.LCDisOn && c.hdmaRunning) {
c.DMAWrite((c.memory[65365] & 127) + 1);
c.memory[65365] = 255;
c.hdmaRunning = false;
}
return c.memory[65365];
}
} else {
this.memoryReader[65365] = this.memoryReadNormal;
this.memoryHighReader[85] = this.memoryHighReadNormal;
}
break;
case 65366:
if (this.cGBC) {
this.memoryHighReader[86] = this.memoryReader[65366] = function(c, b) {
return 60 | ((c.memory[65366] >= 192) ? (2 | (c.memory[65366] & 193)) : (c.memory[65366] & 195));
}
} else {
this.memoryReader[65366] = this.memoryReadNormal;
this.memoryHighReader[86] = this.memoryHighReadNormal;
}
break;
case 65367:
case 65368:
case 65369:
case 65370:
case 65371:
case 65372:
case 65373:
case 65374:
case 65375:
case 65376:
case 65377:
case 65378:
case 65379:
case 65380:
case 65381:
case 65382:
case 65383:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadBAD;
break;
case 65384:
case 65385:
case 65386:
case 65387:
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
this.memoryReader[a] = this.memoryReadNormal;
break;
case 65388:
if (this.cGBC) {
this.memoryHighReader[108] = this.memoryReader[65388] = function(c, b) {
return 254 | c.memory[65388];
}
} else {
this.memoryHighReader[108] = this.memoryReader[65388] = this.memoryReadBAD;
}
break;
case 65389:
case 65390:
case 65391:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadBAD;
break;
case 65392:
if (this.cGBC) {
this.memoryHighReader[112] = this.memoryReader[65392] = function(c, b) {
return 64 | c.memory[65392];
}
} else {
this.memoryHighReader[112] = this.memoryReader[65392] = this.memoryReadBAD;
}
break;
case 65393:
this.memoryHighReader[113] = this.memoryReader[65393] = this.memoryReadBAD;
break;
case 65394:
case 65395:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadNormal;
break;
case 65396:
if (this.cGBC) {
this.memoryHighReader[116] = this.memoryReader[65396] = this.memoryReadNormal;
} else {
this.memoryHighReader[116] = this.memoryReader[65396] = this.memoryReadBAD;
}
break;
case 65397:
this.memoryHighReader[117] = this.memoryReader[65397] = function(c, b) {
return 143 | c.memory[65397];
};
break;
case 65398:
case 65399:
this.memoryHighReader[a & 255] = this.memoryReader[a] = function(c, b) {
return 0;
};
break;
case 65400:
case 65401:
case 65402:
case 65403:
case 65404:
case 65405:
case 65406:
case 65407:
this.memoryHighReader[a & 255] = this.memoryReader[a] = this.memoryReadBAD;
break;
case 65535:
this.memoryHighReader[255] = this.memoryReader[65535] = function(c, b) {
return c.interruptsEnabled;
};
break;
default:
this.memoryReader[a] = this.memoryReadNormal;
this.memoryHighReader[a & 255] = this.memoryHighReadNormal;
}
} else {
this.memoryReader[a] = this.memoryReadBAD;
}
}
}
}
}
}
}
}
}
}
}
}