From cdf10766edf1e6e1e15f3b080f91cb6310d94eb3 Mon Sep 17 00:00:00 2001 From: Evan Barger Date: Mon, 18 Jan 2021 21:47:16 -0500 Subject: [PATCH] Add limited single game map support --- index.html | 13 ++++++++++--- script/app.js | 26 +++++++++++++++++++++++++- script/gbnp.js | 15 +++++++++------ style/style.css | 8 ++++++++ 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 13bb12b..d2c970a 100644 --- a/index.html +++ b/index.html @@ -84,11 +84,11 @@ {{ processor.romTotalKB() + 'k' }} {{ processor.ramUsedKB() + 'k' }} - + {{ processor.romUsedKB() / 128 + ' (' + processor.romUsedKB() + 'k)'}} - - Limit is 7 blocks + + {{overflowClassMsg.msg}} @@ -169,6 +169,13 @@ Download ROM File ({{filename}}.gb)
Download MAP File ({{filename}}.map) + +
+
If you want to flash {{singleRomFilename}} without the menu, you can use this MAP file to configure the cart to work with your ROM.
+ + Download Single Game MAP File ({{singleRomFilename}}.map) + +
diff --git a/script/app.js b/script/app.js index aaa3899..9fd12b3 100644 --- a/script/app.js +++ b/script/app.js @@ -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) } diff --git a/script/gbnp.js b/script/gbnp.js index e2f1153..bd6e0e1 100644 --- a/script/gbnp.js +++ b/script/gbnp.js @@ -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 diff --git a/style/style.css b/style/style.css index e5e849e..be8743f 100644 --- a/style/style.css +++ b/style/style.css @@ -129,6 +129,10 @@ td.overflow { background-color: red; } +td.single-rom { + background-color: orange; +} + thead tr { border-bottom: 1px solid #ddd; } @@ -215,3 +219,7 @@ noscript { min-width: 250px; margin-right: 20px; } + +.single-rom-download { + margin-top: 1.5rem; +}