@@ -35,7 +35,7 @@ function IndexedDb(){
35
35
}
36
36
}
37
37
38
- IndexedDb . prototype . load = function ( ) {
38
+ IndexedDb . prototype . load = function ( ) {
39
39
if ( db ) {
40
40
var tx = db . transaction ( 'configs' , 'readonly' ) ;
41
41
var store = tx . objectStore ( 'configs' ) ;
@@ -49,12 +49,34 @@ IndexedDb.prototype.load = function(){
49
49
} ) ;
50
50
}
51
51
52
+ this . loadJpRom ( ) ;
52
53
this . setFormValues ( ) ;
53
54
}
54
55
} else {
55
56
this . setFormValues ( ) ;
56
57
}
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
+ }
58
80
}
59
81
60
82
IndexedDb . prototype . setFormValues = function ( ) {
@@ -84,7 +106,7 @@ IndexedDb.prototype.save = function(tab){
84
106
var id = '' ;
85
107
if ( tab === 'create' )
86
108
id = '2' ;
87
- // TODO: add jp rom
109
+ this . saveJpRom ( ) ;
88
110
this . obj . quickswap = el ( 'checkbox-quickswap' + id ) . checked ;
89
111
this . obj . music = el ( 'checkbox-music' + id ) . checked ;
90
112
this . obj . resume = el ( 'checkbox-resume' + id ) . checked ;
@@ -110,4 +132,15 @@ IndexedDb.prototype.save = function(tab){
110
132
this . setFormValues ( ) ;
111
133
}
112
134
}
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
+ }
113
146
}
0 commit comments