Skip to content

Commit b75fad9

Browse files
committed
Save vanilla ROM
1 parent 2e3aa65 commit b75fad9

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ <h1>Adjuster</h1>
184184

185185
<div id="tab1" class="tab">
186186
<h1>Patcher + Adjuster</h1>
187-
<div class="row">
188-
<div class="leftcol"><label for="input-file-jp" >JP 1.0 ROM file:</label></div>
187+
<div class="row" id="row-input-file-jp">
188+
<div class="leftcol"><label for="input-file-jp">JP 1.0 ROM file:</label></div>
189189
<div class="rightcol">
190190
<input type="file" id="input-file-jp" accept=".sfc" />
191191
</div>

js/indexedDb.js

+36-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function IndexedDb(){
3535
}
3636
}
3737

38-
IndexedDb.prototype.load = function(){
38+
IndexedDb.prototype.load = function(){
3939
if (db) {
4040
var tx = db.transaction('configs', 'readonly');
4141
var store = tx.objectStore('configs');
@@ -49,12 +49,34 @@ IndexedDb.prototype.load = function(){
4949
});
5050
}
5151

52+
this.loadJpRom();
5253
this.setFormValues();
5354
}
5455
} else {
5556
this.setFormValues();
5657
}
57-
58+
}
59+
60+
IndexedDb.prototype.loadJpRom = function(){
61+
if(this.obj.jp_file){
62+
try{
63+
var bin = atob(this.obj.jp_file);
64+
var array = new Uint8Array(bin.length);
65+
for(var k=0; k<bin.length; k++){
66+
array[k] = bin.charCodeAt(k);
67+
}
68+
var storedRom = new MarcFile(array);
69+
var crc = padZeroes(crc32(storedRom, 0), 4);
70+
if(crc==='3322effc'){
71+
romFile1 = storedRom;
72+
jpCrc = crc;
73+
el('row-input-file-jp').style.display = 'none';
74+
}else{
75+
this.obj.jp_file = null;
76+
}
77+
}
78+
catch(e){}
79+
}
5880
}
5981

6082
IndexedDb.prototype.setFormValues = function(){
@@ -84,7 +106,7 @@ IndexedDb.prototype.save = function(tab){
84106
var id = '';
85107
if (tab==='create')
86108
id='2';
87-
// TODO: add jp rom
109+
this.saveJpRom();
88110
this.obj.quickswap = el('checkbox-quickswap'+id).checked;
89111
this.obj.music = el('checkbox-music'+id).checked;
90112
this.obj.resume = el('checkbox-resume'+id).checked;
@@ -110,4 +132,15 @@ IndexedDb.prototype.save = function(tab){
110132
this.setFormValues();
111133
}
112134
}
135+
}
136+
137+
IndexedDb.prototype.saveJpRom = function(){
138+
if(!this.obj.jp_file && romFile1 && jpCrc==='3322effc'){
139+
var bin = '';
140+
var array = romFile1._u8array;
141+
for(var k=0; k<array.length; k++){
142+
bin += String.fromCharCode(array[k]);
143+
}
144+
this.obj.jp_file = btoa(bin);
145+
}
113146
}

tourney.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ <h1>Adjuster</h1>
157157

158158
<div id="tab0" class="tab">
159159
<h1>Door Async League Generator</h1>
160-
<div class="row">
161-
<div class="leftcol"><label for="input-file-jp" >JP 1.0 ROM file:</label></div>
160+
<div class="row" id="row-input-file-jp">
161+
<div class="leftcol"><label for="input-file-jp">JP 1.0 ROM file:</label></div>
162162
<div class="rightcol">
163163
<input type="file" id="input-file-jp" accept=".sfc" />
164164
</div>

0 commit comments

Comments
 (0)