Sfoglia il codice sorgente

Rewrote .load() method.

master
Bryan Miller 5 anni fa
parent
commit
30f95044b1
1 ha cambiato i file con 16 aggiunte e 13 eliminazioni
  1. +16
    -13
      src/memory/mmc.js

+ 16
- 13
src/memory/mmc.js Vedi File

@@ -64,10 +64,10 @@ class MMC extends IMem{
set address(a){
if (a >= 0 && a < this.size){
this.__addr = a;
offset = 0;
let offset = 0;
for (let s=0; s < this.__switches.length; s++){
if (a >= offset && a < offset + this.__switches[s].mem.size){
this.__sidx = b;
this.__sidx = s;
this.__switches[s].mem.address = a - offset;
break;
} else {
@@ -77,7 +77,10 @@ class MMC extends IMem{
}
}

get byte(){return (this.__switches.length > 0) ? this.__switches[this.__sidx].mem.byte : -1;}
get byte(){
return (this.__switches.length > 0) ? this.__switches[this.__sidx].mem.byte : -1;
}

set byte(b){
if (this.__switches.length > 0){
this.__switches[this.__sidx].mem.byte = b;
@@ -88,18 +91,18 @@ class MMC extends IMem{
if (addr < 0 || addr > this.size)
throw new RangeError("Memory address out of range.");
let offset = 0;
for (let i = 0; i < this.__switches.length; i++){
let mem = this.__switches[i].mem;
let od = data;
if (addr >= offset && addr < offset + mem.size){
if ((addr - offset) + d.length >= mem.size)
od = data.slice(0, mem.size);
mem.load(addr - offset, od);
let doff = 0;
let addre = addr + data.length;
for (let s = 0; s < this.__switches.length; s++){
let mem = this.__switches[s].mem;
if (addr < offset + mem.size && addre >= offset){
let a = (addr > offset) ? addr - offset : 0;
let dlen = (mem.size - a < data.length - doff) ?
mem.size - a : data.length - doff;
mem.load(a, data.slice(doff, doff + dlen));
doff += dlen;
}
data = data.slice(mem.size);
offset += mem.size;
if (d.length > 0)
addr = offset;
}
return this;
}

Loading…
Annulla
Salva