5
5
// and get rid of the functions themselves
6
6
/* beautify ignore:start */
7
7
8
- var _BE = true, _LE = false; //endianness for read_int16+
8
+ const _BE = true, _LE = false; //endianness for read_int16+
9
9
//little-endian = reversed notation (Intel, ZX Spectrum),
10
10
//big-endian = direct notation (TCP/IP, Motorola, Amiga)
11
11
//For the BitReader Object, BE is MSB and LE is LSB (intuitively)
12
- var CS_ALL = true, CS_BEST = false; //charStat needall
13
- var TOEOF = -1; //use for the size parameter in findSignature
12
+ const CS_ALL = true, CS_BEST = false; //charStat needall
13
+ const TOEOF = -1; //use for the size parameter in findSignature
14
14
15
15
// ---------- START OF PRE-v3.06 CODE --------------------
16
16
@@ -70,19 +70,19 @@ const CP866 = "⌂"+ //DOS Cyrillic
70
70
'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'+
71
71
'абвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐'+
72
72
'└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀'+
73
- 'рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■ ';
73
+ 'рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■ ';
74
74
const CP1251 = "⌂"+
75
75
"ЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—・™љ›њќћџ"+
76
- " ЎўЈ¤Ґ¦§Ё©Є«¬®Ї°±Ііґµ¶·ё№є»јЅѕї"+
76
+ " ЎўЈ¤Ґ¦§Ё©Є«¬®Ї°±Ііґµ¶·ё№є»јЅѕї"+
77
77
"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"+
78
78
"абвгдежзийклмнопрстуфхцчшщъыьэюя";
79
79
const CP1252 = "⌂"+ //aka. Western aka. ISO-8859-1
80
80
"€・‚ƒ„…†‡ˆ‰Š‹Œ・Ž・・‘’“”•–—˜™š›œ・žŸ"+
81
- " ¡¢£¤¥¦§¨©ª«¬・®¯°±²³´µ¶·¸¹º»¼½¾¿"+
81
+ " ¡¢£¤¥¦§¨©ª«¬・®¯°±²³´µ¶·¸¹º»¼½¾¿"+
82
82
"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß"+
83
83
"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
84
84
const KOI8R = "⌂"+ //aka. RFC 1489, Morse code based
85
- '─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷'+
85
+ '─│┌┐└┘├┤┬┴┼▀▄█▌▐░▒▓⌠■∙√≈≤≥ ⌡°²·÷'+
86
86
'═║╒ё╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡Ё╢╣╤╥╦╧╨╩╪╫╬©'+
87
87
'юабцдефгхийклмнопярстужвьызшэщчъ'+
88
88
'ЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ';
@@ -93,12 +93,12 @@ const JISX0201 = "⌂"+
93
93
"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
94
94
const CPAmiga = "⫽"+ // alternatively, "▒""
95
95
"абвгдежзийклмнопрстуфхцчшщъыьэюя"+ //0x80~0x9F display Cyrillics, just to fill the void
96
- " ¡¢£¤¥¦§¨©ª«¬–®¯°±²³´µ¶·¸¹º»¼½¾¿"+
96
+ " ¡¢£¤¥¦§¨©ª«¬–®¯°±²³´µ¶·¸¹º»¼½¾¿"+
97
97
"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß"+
98
98
"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
99
99
const CPRISCOS = "⌂"+
100
100
"€Ŵŵ◰﯀Ŷŷ�⇦⇨⇩⇧…™‰•‘’‹›“”„–—−Œœ†‡fifl"+
101
- " ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿"+
101
+ " ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿"+
102
102
"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß"+
103
103
"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
104
104
const CPAtariST = "⌂"+
@@ -118,7 +118,16 @@ const CPSpeccy = ['©', //too SPECIAL with all the tokens-for-characters, gotta
118
118
const Chars0to1F = "・☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼"; //#0 is a small dot from Japanese
119
119
const Chars0to1FLF = "・☺☻♥♦♣♠•◘○\x0A♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼";
120
120
const Chars0to1FCRLF = "・☺☻♥♦♣♠•◘○\x0A♂♀\x0D♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼";
121
- const Chars0to1FSpeccy = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; //not mixing... // emit errors on the latest js
121
+ const Chars0to1FSpeccy = "\0\1\2\3\4\5,📝⬅➡⬇⬆⌫\x0A№\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; //not mixing...
122
+
123
+
124
+ // a replacement for the duration of the regression in File.readBytes:
125
+ function readU8Array(offset,length,ztospace) {
126
+ if(typeof ztospace === 'undefined') ztospace = false;
127
+ var r = [];
128
+ for(var i=0; i < length; i++) r.push(ztospace==0? X.U8(offset+i): X.U8(offset+i) > 0? X.U8(offset+i): 0x20);
129
+ return r
130
+ }
122
131
123
132
/**
124
133
* Decode a 1-byte encoding from a byte array using the 128-byte-long table given,
@@ -170,7 +179,7 @@ function decEncoding(ansi, dectbl, zstop, tbl01F) {
170
179
* @returns {String} a string value usable with js.
171
180
*/
172
181
function decAnsi(ofs, len, dectbl, zstop, tbl01F) {
173
- return(decEncoding(X.readBytes (ofs,len), dectbl, zstop, tbl01F))
182
+ return(decEncoding(readU8Array (ofs,len), dectbl, zstop, tbl01F))
174
183
}
175
184
176
185
@@ -640,30 +649,6 @@ function toBase64(buf) {
640
649
return r
641
650
}
642
651
643
- /**
644
- * If it's an Amiga hunk file, proceeds to process hunks
645
- * @returns {Int} -1 in case of errors, otherwise expected size
646
- */
647
- function calcAmigaFileSize() {
648
- if(!X.c("000003F3")) return -1; //is it an Amiga hunk file?
649
- var p = 4, x = sz = i = reslibs = 0, sizes = [], load = true;
650
- //library strings:
651
- while(p < X.Sz()) {
652
- x = X.U32(4,_BE); p += 4; if(!reslibs && x) load = false; if(x) reslibs++; else break; p += 4*x
653
- }
654
- var hunks = X.U32(p+8,_BE) - X.U32(p+4,_BE) + 1; p += 12;
655
- sOption(hunks+' hunks')
656
- //hunk table:
657
- for(i=0; i < hunks && p < X.Sz(); i++,p+=4) {
658
- var t = X.U32(p,_BE), add = (t>>30) == 3? 4: 0; t &= 0x3FFFFFFF; t <<= 2; t += add;
659
- _log('@'+Hex(p)+' hunk#'+i+' = '+Hex(t));
660
- sizes.push(t); sz += t
661
- }
662
- //traverse hunks:
663
- sz += p; //if(sz >= X.Sz()) return -1;
664
- return sz
665
- }
666
-
667
652
function _logBase64(buf) { //simply plops the buffer contents into log stream with a suitable MIME header
668
653
var fn = File.getFileBaseName()+'.'+File.getFileCompleteSuffix();
669
654
_log('MIME-Version: 1.0\nContent-Type: application/octet-stream; name="'+fn+'.dec"\n'+
@@ -684,7 +669,7 @@ function _logText(buf) { //same but as text put through CP866, or all file with
684
669
if(typeof buf === 'object') {
685
670
var bf = buf, i = 0; for(; i < buf.length; i++) if(bf[i] == 0) bf[i] = 0x20
686
671
}
687
- _log(decEncoding((typeof buf === 'undefined'? X.readBytes (0,X.Sz(),true): bf), CP866, Chars0to1F));
672
+ _log(decEncoding((typeof buf === 'undefined'? readU8Array (0,X.Sz(),true): bf), CP866, Chars0to1F));
688
673
_log('--->8-')
689
674
}
690
675
0 commit comments