mirror of
https://github.com/orangeglo/gbnp.git
synced 2026-10-02 03:36:37 -05:00
Add limited single game map support
This commit is contained in:
@@ -71,6 +71,7 @@ let app = new Vue({
|
||||
filename: 'GBNP',
|
||||
mapData: '',
|
||||
romData: '',
|
||||
singleRomMapData: '',
|
||||
fontIndex: 0,
|
||||
forceDMG: false,
|
||||
englishPatch: false,
|
||||
@@ -96,7 +97,23 @@ let app = new Vue({
|
||||
mapEnabled: function() {
|
||||
return this.cartType == 0;
|
||||
},
|
||||
romOverflow: function() { return this.processor.romOverflow(); }
|
||||
romOverflow: function() { return this.processor.romOverflow(); },
|
||||
overflowClassMsg: function() {
|
||||
if (this.processor.roms.length === 1 && this.processor.roms[0].paddedRomSizeKB() === 1024) {
|
||||
return { class: 'single-rom', msg: "Game only (no menu)" };
|
||||
} else if (this.romOverflow) {
|
||||
return { class: 'overflow', msg: "Limit is 7 blocks" };
|
||||
}
|
||||
return { class: null, msg: null };
|
||||
},
|
||||
singleRomMapEnabled: function() {
|
||||
return this.mapEnabled
|
||||
&& this.processor.roms.length === 1
|
||||
&& this.processor.roms[0].paddedRomSizeKB() <= 1024;
|
||||
},
|
||||
singleRomFilename: function() {
|
||||
return this.processor.roms[0] ? this.processor.roms[0].title : '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
roms: function() { this.processor.roms = this.roms; },
|
||||
@@ -169,6 +186,13 @@ let app = new Vue({
|
||||
this.mapData = URL.createObjectURL(new Blob([this.processor.mapData()]));
|
||||
}
|
||||
},
|
||||
downloadSingleRomMapFile: function(e) {
|
||||
this.processor.roms = this.roms; // in case they got out of sync
|
||||
if (this.cartType == 0) { // regular power cart only
|
||||
if (this.singleRomMapData) { URL.revokeObjectURL(this.singleRomMapData) }
|
||||
this.singleRomMapData = URL.createObjectURL(new Blob([this.processor.mapData(true)]));
|
||||
}
|
||||
},
|
||||
downloadRomFile: function(e) {
|
||||
this.processor.roms = this.roms; // in case they got out of sync
|
||||
if (this.romData) { URL.revokeObjectURL(this.romData) }
|
||||
|
||||
@@ -239,17 +239,20 @@ class Processor {
|
||||
return (this.romUsedKB() > 896);
|
||||
}
|
||||
|
||||
mapData() {
|
||||
mapData(singleRom = false) {
|
||||
const mapBuffer = new ArrayBuffer(128);
|
||||
const mapFile = new FileSeeker(mapBuffer);
|
||||
|
||||
// write mbc type, rom size, and ram size for menu
|
||||
mapFile.writeBytes([0xA8, 0, 0]);
|
||||
|
||||
// write mbc type, rom size, and ram size for each rom
|
||||
let romOffset = 128;
|
||||
let romOffset = 0;
|
||||
let ramOffset = 0;
|
||||
|
||||
if (!singleRom) {
|
||||
// write mbc type, rom size, and ram size for menu
|
||||
mapFile.writeBytes([0xA8, 0, 0]);
|
||||
romOffset += 128;
|
||||
}
|
||||
|
||||
// write mbc type, rom size, and ram size for each rom
|
||||
for (let i = 0; i < this.roms.length; i++) {
|
||||
let rom = this.roms[i];
|
||||
let bits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] // 16
|
||||
|
||||
Reference in New Issue
Block a user