@@ -12,7 +12,7 @@ $("#fileupload").change(function() {
12
12
13
13
$ ( "#randomizeRom" ) . click ( function ( ) {
14
14
seedGenerator ( document . getElementById ( "seed" ) . value . toUpperCase ( ) ) ;
15
- flagGenerator ( document . getElementById ( "flags" ) . value . toUpperCase ( ) ) ;
15
+ flagGenerator ( ) ;
16
16
var file = document . getElementById ( "fileupload" ) . files [ 0 ] ;
17
17
var reader = new FileReader ( ) ;
18
18
reader . onloadend = function ( e ) {
@@ -63,64 +63,84 @@ function seedGenerator(custom = null) {
63
63
}
64
64
}
65
65
66
- function flagGenerator ( custom = null ) {
66
+ function checkboxes ( ) {
67
+ var f = document . getElementById ( "flags" ) . value ;
68
+ var flags = parseInt ( f , 16 ) ;
69
+ $ ( "#randomizeLevels" ) . prop ( "checked" , function ( ) {
70
+ return ( flags & 0x001 ) != 0 ;
71
+ } ) . checkboxradio ( 'refresh' ) ;
72
+ $ ( "#swapExits" ) . prop ( "checked" , function ( ) {
73
+ return ( flags & 0x002 ) != 0 ;
74
+ } ) . checkboxradio ( 'refresh' ) ;
75
+ $ ( "#randomizeBosses" ) . prop ( "checked" , function ( ) {
76
+ return ( flags & 0x004 ) != 0 ;
77
+ } ) . checkboxradio ( 'refresh' ) ;
78
+ $ ( "#randomizeEnemies" ) . prop ( "checked" , function ( ) {
79
+ return ( flags & 0x008 ) != 0 ;
80
+ } ) . checkboxradio ( 'refresh' ) ;
81
+ $ ( "#randomizePowerups" ) . prop ( "checked" , function ( ) {
82
+ return ( flags & 0x010 ) != 0 ;
83
+ } ) . checkboxradio ( 'refresh' ) ;
84
+ $ ( "#randomizePlatforms" ) . prop ( "checked" , function ( ) {
85
+ return ( flags & 0x020 ) != 0 ;
86
+ } ) . checkboxradio ( 'refresh' ) ;
87
+ $ ( "#randomizePhysics" ) . prop ( "checked" , function ( ) {
88
+ return ( flags & 0x040 ) != 0 ;
89
+ } ) . checkboxradio ( 'refresh' ) ;
90
+ $ ( "#randomizeScrolling" ) . prop ( "checked" , function ( ) {
91
+ return ( flags & 0x080 ) != 0 ;
92
+ } ) . checkboxradio ( 'refresh' ) ;
93
+ $ ( "#randomizeMusic" ) . prop ( "checked" , function ( ) {
94
+ return ( flags & 0x100 ) != 0 ;
95
+ } ) . checkboxradio ( 'refresh' ) ;
96
+ $ ( "#beastMode" ) . prop ( "checked" , function ( ) {
97
+ return ( flags & 0x200 ) != 0 ;
98
+ } ) . checkboxradio ( 'refresh' ) ;
99
+ }
100
+
101
+ function flagGenerator ( ) {
67
102
var flags = 0 ;
68
- if ( custom != null && ( parseInt ( custom , 16 ) . toString ( 16 ) . toUpperCase ( ) === custom ) && custom . length == 3 ) {
69
- flags = parseInt ( custom , 16 ) ;
70
- doLevels = ( flags & 0x001 ) != 0 ;
71
- doExits = ( flags & 0x002 ) != 0 ;
72
- doBosses = ( flags & 0x004 ) != 0 ;
73
- doEnemies = ( flags & 0x008 ) != 0 ;
74
- doPowerups = ( flags & 0x010 ) != 0 ;
75
- doPlatforms = ( flags & 0x020 ) != 0 ;
76
- doPhysics = ( flags & 0x040 ) != 0 ;
77
- doScrolling = ( flags & 0x080 ) != 0 ;
78
- doMusic = ( flags & 0x100 ) != 0 ;
79
- beastMode = ( flags & 0x200 ) != 0 ;
80
- document . getElementById ( "flags" ) . value = custom . toUpperCase ( ) ;
81
- } else {
82
- if ( document . getElementById ( "randomizeLevels" ) . checked ) {
83
- doLevels = true ;
84
- flags |= 0x001 ;
85
- }
86
- if ( document . getElementById ( "swapExits" ) . checked ) {
87
- doExits = true ;
88
- flags |= 0x002 ;
89
- }
90
- if ( document . getElementById ( "randomizeBosses" ) . checked ) {
91
- doBosses = true ;
92
- flags |= 0x004 ;
93
- }
94
- if ( document . getElementById ( "randomizeEnemies" ) . checked ) {
95
- doEnemies = true ;
96
- flags |= 0x008 ;
97
- }
98
- if ( document . getElementById ( "randomizePowerups" ) . checked ) {
99
- doPowerups = true ;
100
- flags |= 0x010 ;
101
- }
102
- if ( document . getElementById ( "randomizePlatforms" ) . checked ) {
103
- doPlatforms = true ;
104
- flags |= 0x020 ;
105
- }
106
- if ( document . getElementById ( "randomizePhysics" ) . checked ) {
107
- doPhysics = true ;
108
- flags |= 0x040 ;
109
- }
110
- if ( document . getElementById ( "randomizeScrolling" ) . checked ) {
111
- doScrolling = true ;
112
- flags |= 0x080 ;
113
- }
114
- if ( document . getElementById ( "randomizeMusic" ) . checked ) {
115
- doMusic = true ;
116
- flags |= 0x100 ;
117
- }
118
- if ( document . getElementById ( "beastMode" ) . checked ) {
119
- beastMode = true ;
120
- flags |= 0x200 ;
121
- }
122
- document . getElementById ( "flags" ) . value = ( "00" + flags . toString ( 16 ) . toUpperCase ( ) ) . substr ( - 3 ) ;
103
+ if ( document . getElementById ( "randomizeLevels" ) . checked ) {
104
+ doLevels = true ;
105
+ flags |= 0x001 ;
106
+ }
107
+ if ( document . getElementById ( "swapExits" ) . checked ) {
108
+ doExits = true ;
109
+ flags |= 0x002 ;
110
+ }
111
+ if ( document . getElementById ( "randomizeBosses" ) . checked ) {
112
+ doBosses = true ;
113
+ flags |= 0x004 ;
114
+ }
115
+ if ( document . getElementById ( "randomizeEnemies" ) . checked ) {
116
+ doEnemies = true ;
117
+ flags |= 0x008 ;
118
+ }
119
+ if ( document . getElementById ( "randomizePowerups" ) . checked ) {
120
+ doPowerups = true ;
121
+ flags |= 0x010 ;
122
+ }
123
+ if ( document . getElementById ( "randomizePlatforms" ) . checked ) {
124
+ doPlatforms = true ;
125
+ flags |= 0x020 ;
126
+ }
127
+ if ( document . getElementById ( "randomizePhysics" ) . checked ) {
128
+ doPhysics = true ;
129
+ flags |= 0x040 ;
130
+ }
131
+ if ( document . getElementById ( "randomizeScrolling" ) . checked ) {
132
+ doScrolling = true ;
133
+ flags |= 0x080 ;
134
+ }
135
+ if ( document . getElementById ( "randomizeMusic" ) . checked ) {
136
+ doMusic = true ;
137
+ flags |= 0x100 ;
138
+ }
139
+ if ( document . getElementById ( "beastMode" ) . checked ) {
140
+ beastMode = true ;
141
+ flags |= 0x200 ;
123
142
}
143
+ document . getElementById ( "flags" ) . value = ( "00" + flags . toString ( 16 ) . toUpperCase ( ) ) . substr ( - 3 ) ;
124
144
} ;
125
145
126
146
function doRandomize ( buffer ) {
@@ -156,7 +176,10 @@ function doRandomize(buffer) {
156
176
randomizeBossHealth ( rom ) ;
157
177
}
158
178
checksum ( rom ) ;
179
+ var flags = document . getElementById ( "flags" ) . value ;
180
+ document . getElementById ( "romVersion" ) . innerHTML = "sml2r.download/?s=" + prng . printSeed + "&f=" + flags ;
181
+ $ ( "#romVersion" ) . addClass ( 'clickable' ) ;
159
182
var ifDx = rom [ 0x148 ] == 0x05 ? "DX-" : "" ;
160
- var filename = "sml2r-" + ifDx + prng . printSeed + "-" + document . getElementById ( " flags" ) . value + ".gb" ;
183
+ var filename = "sml2r-" + ifDx + prng . printSeed + "-" + flags + ".gb" ;
161
184
saveAs ( new Blob ( [ buffer ] , { type : "octet/stream" } ) , filename ) ;
162
185
}
0 commit comments