mirror of
https://github.com/orangeglo/gbnp.git
synced 2026-08-25 10:04:00 -05:00
Merge pull request #4 from orangeglo/single-game
Add limited single game map support
This commit is contained in:
13
index.html
13
index.html
@@ -84,11 +84,11 @@
|
||||
<td></td>
|
||||
<td>{{ processor.romTotalKB() + 'k' }}</td>
|
||||
<td>{{ processor.ramUsedKB() + 'k' }}</td>
|
||||
<td :class="{ overflow: romOverflow }">
|
||||
<td :class="overflowClassMsg.class">
|
||||
{{ processor.romUsedKB() / 128 + ' (' + processor.romUsedKB() + 'k)'}}
|
||||
</td>
|
||||
<td :class="{ overflow: romOverflow }">
|
||||
<span v-if="romOverflow">Limit is 7 blocks</span>
|
||||
<td :class="overflowClassMsg.class">
|
||||
<span v-if="overflowClassMsg.msg">{{overflowClassMsg.msg}}</span>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
@@ -169,6 +169,13 @@
|
||||
<a class='download-link' :download="filename + '.gb'" :href="downloadEnabled ? romData : null" type="application/octet-stream" v-on:click="downloadRomFile" :class="{ disabled: !downloadEnabled }">Download ROM File ({{filename}}.gb)</a>
|
||||
<br>
|
||||
<a class='download-link' v-if="mapEnabled" :download="filename + '.map'" :href="downloadEnabled ? mapData : null" type="application/octet-stream" v-on:click="downloadMapFile" :class="{ disabled: !downloadEnabled }">Download MAP File ({{filename}}.map)</a>
|
||||
|
||||
<div v-if="singleRomMapEnabled" class="single-rom-download">
|
||||
<div>If you want to flash {{singleRomFilename}} without the menu, you can use this MAP file to configure the cart to work with your ROM.</div>
|
||||
<a class='download-link' :download="singleRomFilename + '.map'" :href="singleRomMapData" type="application/octet-stream" v-on:click="downloadSingleRomMapFile">
|
||||
Download Single Game MAP File ({{singleRomFilename}}.map)
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user