-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmsdat.html
More file actions
2417 lines (2232 loc) · 91.8 KB
/
Copy pathsmsdat.html
File metadata and controls
2417 lines (2232 loc) · 91.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>smsdat — SMS/GG Data Tools</title>
<style>
:root {
--bg:#1a1a1e; --panel:#25252c; --panel2:#2d2d36; --border:#3a3a45;
--fg:#e8e8ea; --muted:#8a8a95; --accent:#f0a020; --accent2:#5cb8ff;
--good:#4aaa4a; --warn:#e0a020; --bad:#e05050;
--bar-bg:#1f1f26; --bar-fill:#5cb8ff;
--bar-low:#4aaa4a; --bar-mid:#e0a020; --bar-high:#e05050;
--sym-code:#9cd48a; --sym-data:#e0a888; --sym-header:#c8a0e0;
--same-bg:#22262a; --same-fg:#4a5560;
--diff-bg:#5a2020; --diff-v1:#ffb0b0; --diff-v2:#a0ffa0;
--struct:#c060c0;
}
/* ========== Tab system ========== */
.app-tabs {
display:flex; gap:2px; margin-bottom:14px;
border-bottom:1px solid var(--border);
}
.app-tab {
background:transparent; color:var(--muted); border:0;
padding:10px 20px; cursor:pointer;
font-weight:600; font-size:12px;
border-radius:0; border-bottom:2px solid transparent;
letter-spacing:.5px; text-transform:uppercase;
transition:color .12s, border-color .12s;
}
.app-tab:hover { color:var(--fg); }
.app-tab.active {
color:var(--accent); border-bottom-color:var(--accent);
}
.tab-content[hidden] { display:none; }
* { box-sizing:border-box; }
body {
margin:0; padding:16px;
background:var(--bg); color:var(--fg);
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
font-size:13px;
}
h1 { margin:0 0 12px; font-size:18px; color:var(--accent); }
h2 { margin:0 0 8px; font-size:14px; color:var(--accent2); }
.top { margin-bottom:14px; }
.panel { background:var(--panel); border:1px solid var(--border); border-radius:6px; padding:12px; }
label { display:block; font-size:11px; color:var(--muted); margin-bottom:4px; text-transform:uppercase; letter-spacing:.5px; }
input[type=file] {
background:var(--panel2); color:var(--fg); border:1px solid var(--border);
border-radius:4px; padding:6px; width:100%; font-size:12px;
}
input[type=file]::file-selector-button {
background:var(--accent); color:#000; border:0; padding:4px 10px;
border-radius:3px; margin-right:8px; cursor:pointer; font-weight:600;
}
input[type=text] {
background:var(--panel2); color:var(--fg); border:1px solid var(--border);
border-radius:4px; padding:6px 10px; font-size:12px; min-width:220px;
font-family:inherit;
}
.row { margin-bottom:8px; }
.status { font-size:11px; color:var(--muted); margin-top:6px; min-height:14px; }
.status.ok { color:var(--good); }
.status.err { color:var(--bad); }
.controls {
display:flex; gap:12px; align-items:center; flex-wrap:wrap;
margin-bottom:12px;
}
button {
background:var(--accent); color:#000; border:0;
padding:8px 16px; border-radius:4px; cursor:pointer;
font-weight:600; font-size:12px;
}
button:disabled { background:#555; color:#888; cursor:not-allowed; }
button.sec { background:var(--panel2); color:var(--fg); border:1px solid var(--border); }
button.pick { display:block; width:100%; text-align:left; padding:8px 12px; font-weight:500; font-size:12px; }
button.pick:hover { border-color:var(--accent); }
.filters { display:flex; gap:14px; align-items:center; font-size:12px; flex-wrap:wrap; }
.filters label { display:inline-flex; align-items:center; gap:5px; margin:0; text-transform:none; letter-spacing:normal; color:var(--fg); font-size:12px; }
.summary {
padding:12px 14px; background:var(--panel); border:1px solid var(--border);
border-radius:6px; margin-bottom:14px; font-size:12px;
display:grid; grid-template-columns:repeat(auto-fit, minmax(160px, 1fr));
gap:12px;
}
.summary .stat { display:flex; flex-direction:column; gap:2px; }
.summary .stat .k { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.5px; }
.summary .stat .v { color:var(--accent); font-weight:600; font-size:16px; font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace; font-variant-numeric:tabular-nums; }
.summary .stat .sub { color:var(--muted); font-size:11px; }
.banks { display:grid; gap:12px; }
.bank {
background:var(--panel); border:1px solid var(--border);
border-radius:6px; overflow:hidden;
}
.bank-head {
display:flex; align-items:center; gap:14px;
padding:10px 14px; background:var(--panel2);
cursor:pointer; user-select:none;
border-bottom:1px solid var(--border);
}
.bank-head:hover { background:#333340; }
.bank-head .caret {
width:10px; height:10px; display:inline-block;
border-right:2px solid var(--accent); border-bottom:2px solid var(--accent);
transform:rotate(-45deg); transition:transform .15s;
}
.bank.open .bank-head .caret { transform:rotate(45deg); }
.bank-head .title {
color:var(--accent); font-weight:700; font-size:14px;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
min-width:110px;
}
.bank-head .range {
color:var(--muted); font-size:11px;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
}
.bank-head .bar-wrap {
flex:1; background:var(--bar-bg); border-radius:3px;
height:16px; position:relative; overflow:hidden;
border:1px solid var(--border); min-width:180px;
}
.bank-head .bar-fill {
position:absolute; left:0; top:0; height:100%;
transition:width .3s;
}
.bank-head .bar-fill.low { background:var(--bar-low); }
.bank-head .bar-fill.mid { background:var(--bar-mid); }
.bank-head .bar-fill.high { background:var(--bar-high); }
.bank-head .bar-txt {
position:absolute; left:0; right:0; top:0; bottom:0;
display:flex; align-items:center; justify-content:center;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
font-size:11px; font-weight:600; color:#000;
text-shadow:0 0 2px rgba(255,255,255,.4);
font-variant-numeric:tabular-nums;
}
.bank-head .stats {
display:flex; gap:14px; align-items:center;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
font-size:11px; font-variant-numeric:tabular-nums;
color:var(--muted); min-width:220px; justify-content:flex-end;
}
.bank-head .stats .used { color:var(--fg); }
.bank-head .stats .free { color:var(--good); }
.bank-head .stats .cnt { color:var(--accent2); }
.bank.is-ram { border-color:var(--accent2); }
.bank.is-ram .bank-head { background:#1f2833; }
.bank.is-ram .bank-head:hover { background:#25314a; }
.bank .warn-badge {
display:inline-flex; align-items:center; justify-content:center;
width:18px; height:18px; margin-left:6px;
background:var(--warn); color:#000; border-radius:50%;
font-size:11px; font-weight:700; cursor:help;
}
/* ================= Treemap ================= */
.treemap-wrap {
padding:12px 14px 4px; background:#1a1a20;
border-bottom:1px solid var(--border);
}
.treemap-svg {
display:block; width:100%; height:220px;
border-radius:4px; background:#0e0e12;
}
.treemap-svg .tm-tile { cursor:pointer; }
.treemap-svg .tm-tile rect { transition:opacity .1s; }
.treemap-svg .tm-tile:hover rect { opacity:0.75; stroke:var(--accent); stroke-width:1.5; }
.treemap-svg .tm-tile.tm-free rect { fill:#2a2a35; }
.treemap-svg .tm-tile text {
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
fill:#0e0e12; font-weight:600; pointer-events:none;
-webkit-font-smoothing:antialiased;
}
.treemap-svg .tm-tile.tm-free text { fill:var(--muted); }
#tmTooltip {
position:fixed; display:none; pointer-events:none;
background:#0e0e12; border:1px solid var(--accent);
border-radius:6px; padding:8px 10px;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
font-size:11px; line-height:1.5;
box-shadow:0 6px 24px rgba(0,0,0,.6);
z-index:1000; max-width:340px;
font-variant-numeric:tabular-nums;
}
#tmTooltip .tt-name { color:var(--accent2); font-weight:700; font-size:12px; margin-bottom:2px; }
#tmTooltip .tt-addr { color:var(--accent); }
#tmTooltip .tt-size { color:var(--fg); }
#tmTooltip .tt-pct { color:var(--muted); }
#tmTooltip .tt-area { color:var(--sym-header); font-size:10px; }
.warn-banner {
padding:10px 14px; background:#3a2e12; border:1px solid var(--warn);
border-radius:6px; margin-bottom:12px; font-size:12px;
color:#f0d080; line-height:1.5;
}
.warn-banner b { color:var(--warn); }
.warn-banner code { background:#000; padding:1px 5px; border-radius:3px; color:var(--warn); font-size:11px; }
.bank-body {
display:none; padding:0;
}
.bank.open .bank-body { display:block; }
table.syms {
width:100%; border-collapse:collapse;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
font-size:11px; font-variant-numeric:tabular-nums;
}
table.syms th {
position:sticky; top:0; background:var(--panel2); z-index:1;
color:var(--muted); font-weight:600; font-size:10px;
text-align:left; padding:6px 12px;
text-transform:uppercase; letter-spacing:.5px;
border-bottom:1px solid var(--border);
cursor:pointer; user-select:none;
}
table.syms th:hover { color:var(--accent); }
table.syms th.sort::after {
content:" ▼"; color:var(--accent); font-size:9px;
}
table.syms th.sort.asc::after { content:" ▲"; }
table.syms td {
padding:4px 12px; border-bottom:1px solid #1e1e24;
vertical-align:middle;
}
table.syms tr:hover td { background:#2e2e37; }
table.syms td.addr { color:var(--accent); width:80px; }
table.syms td.name { color:var(--fg); word-break:break-all; }
table.syms td.name.code { color:var(--sym-code); }
table.syms td.name.data { color:var(--sym-data); }
table.syms td.name.header { color:var(--sym-header); }
table.syms td.area { color:var(--muted); width:120px; font-size:10px; }
table.syms td.size {
color:var(--accent2); width:110px; text-align:right;
font-weight:600;
position:relative;
padding-right:14px;
background-image:linear-gradient(to right,
rgba(92,184,255,0.14) 0%,
rgba(92,184,255,0.14) var(--pct, 0%),
transparent var(--pct, 0%));
}
table.syms td.size .b { color:var(--muted); font-weight:400; font-size:10px; margin-left:4px; }
table.syms tr:hover td.size {
background-image:linear-gradient(to right,
rgba(240,160,32,0.22) 0%,
rgba(240,160,32,0.22) var(--pct, 0%),
transparent var(--pct, 0%));
}
table.syms tr.hidden { display:none; }
table.syms tr.end-marker td { opacity:0.55; font-style:italic; }
table.syms tr.end-marker td.name::before { content:"◆ "; color:var(--warn); }
.empty-bank {
padding:16px; text-align:center; color:var(--muted); font-style:italic;
}
.hint { color:var(--muted); font-size:11px; margin-top:6px; line-height:1.5; }
code { background:#000; padding:1px 5px; border-radius:3px; color:var(--accent); font-size:11px; }
.drop-hint {
border:2px dashed var(--border); border-radius:6px;
padding:24px; text-align:center; color:var(--muted);
background:var(--panel2); margin-bottom:12px;
}
.drop-hint.dragover {
border-color:var(--accent); background:#3a2e18; color:var(--accent);
}
.drop-hint b { color:var(--accent2); }
/* ================================================================
* RAM DIFF tab styles (scoped to #tab-rd where noted)
* ================================================================ */
#tab-rd .summary {
padding:10px 12px; background:var(--panel); border:1px solid var(--border);
border-radius:6px; margin-bottom:12px; font-size:12px;
display:flex; gap:20px; flex-wrap:wrap;
}
#tab-rd .summary b { color:var(--accent); }
#tab-rd .legend { display:flex; gap:16px; align-items:center; font-size:11px; color:var(--muted); }
#tab-rd .legend .sw { display:inline-block; width:14px; height:14px; border-radius:2px; vertical-align:middle; margin-right:4px; border:1px solid var(--border); }
#tab-rd .legend .sw.same { background:var(--same-bg); }
#tab-rd .legend .sw.diff { background:var(--diff-bg); }
#tab-rd .grid-wrap {
background:var(--panel); border:1px solid var(--border); border-radius:6px;
overflow:visible;
}
table.ram-grid {
border-collapse:separate; border-spacing:0;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
font-size:11px;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
font-variant-numeric:tabular-nums;
}
.ram-grid thead th {
position:sticky; top:0; background:var(--panel2); z-index:3;
color:var(--muted); font-weight:600; font-size:10px;
padding:6px 0; text-align:center;
border-bottom:1px solid var(--border);
width:36px;
}
.ram-grid thead th.addr-h {
position:sticky; left:0; z-index:4; width:70px;
text-align:left; padding-left:10px;
}
.ram-grid td.addr {
position:sticky; left:0; z-index:2; background:var(--panel2);
color:var(--accent); padding:0 10px;
border-right:1px solid var(--border);
font-weight:600; font-size:11px;
width:70px; text-align:left;
height:28px;
}
.ram-grid td.cell {
width:36px; height:28px; padding:0;
text-align:center; vertical-align:middle;
border-right:1px solid #1e1e24; border-bottom:1px solid #1e1e24;
cursor:default;
transition:background 60ms, transform 60ms;
}
.ram-grid td.same { background:var(--same-bg); color:var(--same-fg); }
.ram-grid td.diff {
background:var(--diff-bg);
padding:1px 0; line-height:1.05;
}
.ram-grid td.diff .v1 { color:var(--diff-v1); font-size:11px; font-weight:500; }
.ram-grid td.diff .v2 { color:var(--diff-v2); font-size:11px; font-weight:500; }
.ram-grid td.cell:hover {
outline:2px solid var(--accent); outline-offset:-2px;
position:relative; z-index:1;
}
.ram-grid td.cell.sym-hi { box-shadow:inset 0 0 0 1px var(--accent2); }
.ram-grid th.ascii-h {
text-align:left; padding-left:12px;
border-left:2px solid var(--border);
min-width:180px;
}
.ram-grid td.ascii {
padding:0 12px; height:28px;
font-family:"SF Mono","Monaco","Cascadia Mono",monospace;
font-size:12px; letter-spacing:1px;
color:var(--same-fg);
white-space:pre;
border-left:2px solid var(--border);
vertical-align:middle;
}
.ram-grid td.ascii.hasdiff {
padding:1px 12px; line-height:1.05;
}
.ram-grid td.ascii .a1 { color:var(--diff-v1); font-size:11px; font-weight:500; display:block; }
.ram-grid td.ascii .a2 { color:var(--diff-v2); font-size:11px; font-weight:500; display:block; }
.ram-grid tr.hidden { display:none; }
#rdTooltip {
position:fixed; display:none; pointer-events:none;
background:#0e0e12; border:1px solid var(--accent);
border-radius:6px; padding:8px 10px;
font-family:"Menlo","SF Mono","Cascadia Mono","Consolas",monospace;
font-size:11px; line-height:1.5;
box-shadow:0 6px 24px rgba(0,0,0,.6);
z-index:1000; max-width:340px;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
font-variant-numeric:tabular-nums;
}
#rdTooltip b { font-weight:500; }
#rdTooltip .tip-addr { color:var(--accent); font-weight:600; font-size:12px; margin-bottom:4px; }
#rdTooltip .tip-val1 { color:var(--diff-v1); }
#rdTooltip .tip-val2 { color:var(--diff-v2); }
#rdTooltip .tip-sym { color:var(--accent2); margin-top:5px; font-weight:600; }
#rdTooltip .tip-fld { color:#e0d0e0; }
#rdTooltip .tip-type { color:var(--struct); font-size:10px; }
#rdTooltip .tip-none { color:var(--muted); font-style:italic; margin-top:5px; }
#rdTooltip .tip-word { color:#f0d080; margin-top:3px; }
</style>
</head>
<body>
<div style="display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px">
<h1 style="margin:0; font-size:20px">
<span style="color:var(--accent)">smsdat</span>
<span style="color:var(--muted); font-weight:400; font-size:13px; margin-left:8px" data-i18n="appSub">— Outils données SMS/GG</span>
</h1>
<button id="btnLang" class="sec" style="min-width:52px" title="Toggle language">EN</button>
</div>
<div class="app-tabs" role="tablist">
<button class="app-tab active" data-tab="ba" role="tab" aria-selected="true">Bank Analyzer</button>
<button class="app-tab" data-tab="rd" role="tab" aria-selected="false">RAM Diff</button>
</div>
<!-- ================================================================
TAB: BANK ANALYZER
================================================================ -->
<div class="tab-content" id="tab-ba">
<div class="top">
<div class="panel">
<h2 data-i18n="h2File">Fichier symbolique (.sym WLA-DX ou .map SDCC)</h2>
<div class="row">
<input type="file" id="fileInput" accept=".sym,.map,.txt">
<div class="status" id="sFile" data-i18n="noFile">Aucun fichier chargé.</div>
</div>
<div class="hint" data-i18n="hint">
Charge un <code>.sym</code> (WLA-DX) ou un <code>.map</code> (SDCC). Le format est auto-détecté.
Chaque bank fait <b>16 384 bytes</b> (16 KiB).
</div>
</div>
</div>
<div class="controls" id="controls" style="display:none">
<input type="text" id="search" placeholder="Rechercher un symbole…" data-i18n-ph="searchPh">
<div class="filters">
<label><span data-i18n="sortLbl">Trier:</span>
<select id="sortBy" style="background:var(--panel2); color:var(--fg); border:1px solid var(--border); border-radius:4px; padding:4px 8px; font-family:inherit; font-size:12px">
<option value="addr" data-i18n="sortAddr">Adresse ↑</option>
<option value="size" data-i18n="sortSize">Taille ↓</option>
<option value="name" data-i18n="sortName">Nom ↑</option>
</select>
</label>
<label><input type="checkbox" id="chkHideEmpty"> <span data-i18n="hideEmpty">Cacher banks vides</span></label>
<label><input type="checkbox" id="chkHideZero"> <span data-i18n="hideZero">Cacher symboles taille 0</span></label>
<label><input type="checkbox" id="chkTreemap" checked> <span data-i18n="showTreemap">Treemap</span></label>
<label><input type="checkbox" id="chkExpandAll"> <span data-i18n="expandAll">Tout déplier</span></label>
</div>
<button id="btnExport" class="sec" data-i18n="btnExport">Export CSV</button>
</div>
<div class="summary" id="summary" style="display:none"></div>
<div class="warn-banner" id="warnBanner" style="display:none"></div>
<div class="banks" id="banks"></div>
</div><!-- /tab-ba -->
<!-- ================================================================
TAB: RAM DIFF
================================================================ -->
<div class="tab-content" id="tab-rd" hidden>
<div class="top">
<div class="panel">
<h2 data-i18n="h2Bin">1. Fichiers binaires (dump RAM 8 Kio)</h2>
<div class="row">
<label data-i18n="lblBin1">BIN #1 (référence)</label>
<button class="sec pick" data-pick="bin1" data-i18n="btnPick">Choisir un fichier…</button>
<div class="status" id="sBin1"></div>
</div>
<div class="row">
<label data-i18n="lblBin2">BIN #2 (à comparer)</label>
<button class="sec pick" data-pick="bin2" data-i18n="btnPick">Choisir un fichier…</button>
<div class="status" id="sBin2"></div>
</div>
</div>
<div class="panel">
<h2 data-i18n="h2Ctx">2. Fichiers de contexte SDCC (optionnels)</h2>
<div class="row">
<label data-i18n="lblMap">rom.map (SDCC linker map)</label>
<button class="sec pick" data-pick="map" data-i18n="btnPick">Choisir un fichier…</button>
<div class="status" id="sMap"></div>
</div>
<div class="row">
<label data-i18n="lblHdr">_structures.h (typedefs + extern __at)</label>
<button class="sec pick" data-pick="hdr" data-i18n="btnPick">Choisir un fichier…</button>
<div class="status" id="sHdr"></div>
</div>
<div class="hint" data-i18n="hintCtx">
Charge <code>rom.map</code> et <code>_structures.h</code> pour enrichir le tooltip.
</div>
</div>
</div>
<div class="controls">
<button id="rdBtnDiff" data-i18n="btnDiff" disabled>Générer la grille</button>
<button id="rdBtnClear" data-i18n="btnClear" class="sec">Effacer</button>
<div class="filters">
<label><input type="checkbox" id="rdChkOnlyDiff"> <span data-i18n="chkOnlyDiff">Masquer lignes sans différence</span></label>
<label><input type="checkbox" id="rdChkColorSym"> <span data-i18n="chkColorSym">Colorer par symbole</span></label>
<span class="legend">
<span><span class="sw same"></span><span data-i18n="legendSame">identique</span></span>
<span><span class="sw diff"></span><span data-i18n="legendDiff">différent (v1 / v2)</span></span>
</span>
</div>
</div>
<div class="summary" id="rdSummary" style="display:none"></div>
<div class="grid-wrap">
<table class="ram-grid" id="rdGrid"></table>
</div>
</div><!-- /tab-rd -->
<div id="tmTooltip"></div>
<div id="rdTooltip"></div>
<script>
"use strict";
/* ============================================================
* SHARED — language toggle + tab switching
* ============================================================ */
let LANG = 'fr';
const langCallbacks = [];
function applyAllI18n() {
document.documentElement.lang = LANG;
const btn = document.getElementById('btnLang');
if (btn) btn.textContent = LANG === 'fr' ? 'EN' : 'FR';
const sub = document.querySelector('[data-i18n="appSub"]');
if (sub) sub.textContent = LANG === 'fr' ? '— Outils données SMS/GG' : '— SMS/GG data tools';
document.title = LANG === 'fr' ? 'smsdat — Outils données SMS/GG' : 'smsdat — SMS/GG Data Tools';
for (const cb of langCallbacks) { try { cb(); } catch (e) { console.error(e); } }
}
document.getElementById('btnLang').addEventListener('click', () => {
LANG = LANG === 'fr' ? 'en' : 'fr';
applyAllI18n();
});
document.querySelectorAll('.app-tab').forEach(btn => {
btn.addEventListener('click', () => {
const target = btn.dataset.tab;
document.querySelectorAll('.app-tab').forEach(t => {
const active = t === btn;
t.classList.toggle('active', active);
t.setAttribute('aria-selected', String(active));
});
document.querySelectorAll('.tab-content').forEach(c => {
c.hidden = c.id !== 'tab-' + target;
});
});
});
/* ============================================================
* BANK ANALYZER module
* ============================================================ */
(() => {
/* ============================================================
* i18n
* ============================================================ */
const I18N = {
fr: {
title: "SMS ROM Bank Analyzer",
h2File: "Fichier symbolique (.sym WLA-DX ou .map SDCC)",
noFile: "Aucun fichier chargé.",
hint: `Charge un <code>.sym</code> (WLA-DX) ou un <code>.map</code> (SDCC). Le format est auto-détecté. Chaque bank fait <b>16 384 bytes</b> (16 KiB), la RAM <b>8 192 bytes</b>.<br><b>WLA-DX</b> : le fichier doit être généré avec <code>wlalink -A -S</code> (l'option <code>-S</code> écrit la section <code>[definitions]</code> avec la taille de chaque symbole).<br>Pour une occupation exacte, ajoute un label sentinelle <code>_end_bank_N:</code> à la fin des données de chaque bank (ex. <code>_end_bank_03:</code>, <code>_end_bank_04:</code>...) — sans quoi le dernier label de chaque bank aura sa taille gonflée jusqu'à la fin du bank par WLA-DX.`,
searchPh: "Rechercher un symbole…",
sortLbl: "Trier:",
sortAddr: "Adresse ↑",
sortSize: "Taille ↓",
sortName: "Nom ↑",
hideEmpty: "Cacher banks vides",
hideZero: "Cacher symboles taille 0",
showTreemap: "Treemap",
expandAll: "Tout déplier",
tmFree: "Espace libre",
btnExport: "Export CSV",
parsed: (fmt, n) => `Format <b>${fmt}</b> — ${n} symbole(s) analysé(s).`,
errFormat: "Format non reconnu.",
errNoDefs: `Fichier .sym incomplet : la section <code>[definitions]</code> est absente. Sans elle, les tailles des symboles ne peuvent pas être calculées correctement (le dernier symbole de chaque bank aurait une taille inconnue et l'occupation serait sous-estimée).<br>Régénère le fichier avec <code>wlalink -A -S</code> — l'option <code>-S</code> ajoute les tailles.`,
statBanks: "Banks utilisés",
statSyms: "Symboles",
statUsed: "ROM utilisée",
statFree: "ROM libre",
statAvg: "% moyen d'occupation",
statRam: "RAM utilisée",
ramTitle: "RAM",
bank: (n) => `Bank ${n}`,
range: (a, b) => `[${a}–${b}]`,
used: (b) => `${b} B utilisés`,
free: (b) => `${b} B libres`,
cnt: (n) => `${n} sym.`,
thAddr: "Adresse",
thName: "Symbole",
thArea: "Zone",
thSize: "Taille",
empty: "Aucun symbole dans ce bank.",
filterEmpty: "Aucun symbole ne correspond à la recherche.",
warnNoEndMarker: (list, n) => `<b>⚠ Occupation potentiellement surestimée</b> — ${n === 1 ? 'la bank' : 'les banks'} <code>${list}</code> ${n === 1 ? "n'a pas" : "n'ont pas"} de label sentinelle <code>_end_bank_N</code>. WLA-DX gonfle la taille du dernier label de chaque bank jusqu'à la fin du bank (16 KiB), ce qui fait apparaître les banks comme plus pleines qu'elles ne le sont.<br>→ Ajoute un label <code>_end_bank_N:</code> (ex. <code>_end_bank_03:</code>) juste après les dernières données de chaque bank pour un calcul exact. Alternative : utilise des blocs <code>.SECTION</code> explicites.`,
tipNoEndMarker: "Pas de label _end_bank_N détecté — occupation possiblement surestimée."
},
en: {
title: "SMS ROM Bank Analyzer",
h2File: "Symbol file (.sym WLA-DX or .map SDCC)",
noFile: "No file loaded.",
hint: `Load a <code>.sym</code> (WLA-DX) or <code>.map</code> (SDCC) file. Format is auto-detected. Each bank is <b>16,384 bytes</b> (16 KiB), RAM is <b>8,192 bytes</b>.<br><b>WLA-DX</b>: the file must be produced with <code>wlalink -A -S</code> (the <code>-S</code> flag writes the <code>[definitions]</code> section with per-symbol sizes).<br>For exact bank usage, add a sentinel label <code>_end_bank_N:</code> at the end of each bank's data (e.g. <code>_end_bank_03:</code>, <code>_end_bank_04:</code>...) — otherwise WLA-DX inflates the last label of each bank to fill to bank end.`,
searchPh: "Search symbol…",
sortLbl: "Sort:",
sortAddr: "Address ↑",
sortSize: "Size ↓",
sortName: "Name ↑",
hideEmpty: "Hide empty banks",
hideZero: "Hide zero-size symbols",
showTreemap: "Treemap",
expandAll: "Expand all",
tmFree: "Free space",
btnExport: "Export CSV",
parsed: (fmt, n) => `Format <b>${fmt}</b> — ${n} symbol(s) parsed.`,
errFormat: "Format not recognized.",
errNoDefs: `Incomplete .sym file: the <code>[definitions]</code> section is missing. Without it, symbol sizes cannot be computed correctly (the last symbol of each bank would have unknown size and occupation would be under-reported).<br>Regenerate the file with <code>wlalink -A -S</code> — the <code>-S</code> flag adds the sizes.`,
statBanks: "Banks used",
statSyms: "Symbols",
statUsed: "ROM used",
statFree: "ROM free",
statAvg: "Avg. usage %",
statRam: "RAM used",
ramTitle: "RAM",
bank: (n) => `Bank ${n}`,
range: (a, b) => `[${a}–${b}]`,
used: (b) => `${b} B used`,
free: (b) => `${b} B free`,
cnt: (n) => `${n} sym.`,
thAddr: "Address",
thName: "Symbol",
thArea: "Area",
thSize: "Size",
empty: "No symbols in this bank.",
filterEmpty: "No symbols match search.",
warnNoEndMarker: (list, n) => `<b>⚠ Occupation may be over-reported</b> — ${n === 1 ? 'bank' : 'banks'} <code>${list}</code> ${n === 1 ? "has no" : "have no"} <code>_end_bank_N</code> sentinel label. WLA-DX inflates the last label's size in each bank to reach bank end (16 KiB), making banks look fuller than they are.<br>→ Add a <code>_end_bank_N:</code> label (e.g. <code>_end_bank_03:</code>) right after the last data of each bank for exact accounting. Alternative: use explicit <code>.SECTION</code> blocks.`,
tipNoEndMarker: "No _end_bank_N label detected — usage may be over-reported."
}
};
// LANG is defined in the shared prelude above.
const t = () => I18N[LANG];
function applyI18n() {
const d = t();
// Scope to this tab to avoid touching the other module's DOM
document.querySelectorAll('#tab-ba [data-i18n]').forEach(el => {
const k = el.dataset.i18n;
if (typeof d[k] === 'string') el.innerHTML = d[k];
});
document.querySelectorAll('#tab-ba [data-i18n-ph]').forEach(el => {
const k = el.dataset.i18nPh;
if (typeof d[k] === 'string') el.placeholder = d[k];
});
// rerender if we have data
if (state.banks) render();
}
/* ============================================================
* Constants
* ============================================================ */
const BANK_SIZE = 0x4000; // 16384 bytes
const RAM_BASE = 0xC000;
const RAM_SIZE = 0x2000; // 8192 bytes (8 KiB) SMS main RAM
const state = {
format: null, // 'WLA-DX' | 'SDCC'
banks: null, // Map<bankNum, {num, base, symbols:[{addr, name, size, area}], usedBytes}>
ram: null, // {base, size, symbols, usedBytes, freeBytes, pctUsed} | null
totalSyms: 0
};
/* ============================================================
* Format detection
* ============================================================ */
function detectFormat(text) {
if (/^\s*;\s*this file was created with wlalink/i.test(text) ||
/^\s*\[labels\]\s*$/m.test(text)) {
return 'WLA-DX';
}
if (/ASxxxx Linker/i.test(text) ||
/^\s*Area\s+Addr\s+Size\s+Decimal Bytes/im.test(text)) {
return 'SDCC';
}
return null;
}
/* ============================================================
* WLA-DX .sym parser
* ============================================================
* [labels] → "BB:AAAA name"
* BB = bank in hex, AAAA = addr in slot (usually 8000-BFFF for banked,
* 0000-7FFF for fixed slots 0/1)
* [definitions] → "SSSSSSSS name" (some named "_sizeof_XXX")
* ============================================================ */
// Regex matching an "end of bank data" sentinel label. Users add these in
// their assembly to mark the true end of a bank's data (WLA-DX inflates the
// `_sizeof_` of the last real label to fill to bank end, which over-reports
// usage). Accepts: _end_bank, _end_bank_3, _end_bank_03, end_bank_boss, etc.
const END_BANK_RE = /^_?end_bank(_[a-z0-9_]+)?$/i;
function parseWlaSym(text) {
const lines = text.split(/\r?\n/);
let section = null;
const labels = []; // {bank, addr, name}
const sizeByName = new Map(); // sizeof_NAME → size
let hasDefinitionsSection = false;
for (let raw of lines) {
const line = raw.replace(/;.*$/, '').trim();
if (!line) continue;
const secMatch = line.match(/^\[([a-z]+)\]$/i);
if (secMatch) {
section = secMatch[1].toLowerCase();
if (section === 'definitions') hasDefinitionsSection = true;
continue;
}
if (section === 'labels') {
// e.g. "03:8000 background_pal"
const m = line.match(/^([0-9a-f]{1,4}):([0-9a-f]{1,4})\s+(\S.*)$/i);
if (m) {
labels.push({
bank: parseInt(m[1], 16),
addr: parseInt(m[2], 16),
name: m[3].trim()
});
}
} else if (section === 'definitions') {
// "00000010 _sizeof_level1_pal"
const m = line.match(/^([0-9a-f]{1,8})\s+(\S+)$/i);
if (m) {
const size = parseInt(m[1], 16);
const name = m[2];
if (name.startsWith('_sizeof_')) {
sizeByName.set(name.slice('_sizeof_'.length), size);
}
}
}
}
// Enforce that the .sym was built with `wlalink -A -S`. Without -S the file
// has no [definitions] block, meaning we can't know the size of the LAST
// symbol of each bank — bank occupation would be under-reported. Refuse
// to guess in that case.
if (!hasDefinitionsSection || sizeByName.size === 0) {
const err = new Error('WLA_NO_DEFINITIONS');
err.code = 'WLA_NO_DEFINITIONS';
throw err;
}
// Build per-bank map + separate RAM pseudo-bank for labels in 0xC000-0xDFFF
const banks = new Map();
const ram = { base: RAM_BASE, size: RAM_SIZE, symbols: [] };
for (const l of labels) {
// Track whether the size came from [definitions] (source of truth) or is
// unknown — labels explicitly declared as 0-size ("end" markers, container
// aliases) must stay at 0, not be overridden by delta computation.
const knownSize = sizeByName.get(l.name);
const hasKnownSize = knownSize !== undefined;
const size = hasKnownSize ? knownSize : 0;
// RAM labels
if (l.addr >= RAM_BASE && l.addr < RAM_BASE + RAM_SIZE) {
ram.symbols.push({ addr: l.addr, name: l.name, size, hasKnownSize, area: null });
continue;
}
if (!banks.has(l.bank)) {
banks.set(l.bank, { num: l.bank, base: bankBaseAddr(l.bank, l.addr), symbols: [] });
}
banks.get(l.bank).symbols.push({
addr: l.addr, name: l.name, size, hasKnownSize, area: null
});
}
finalizeBanks(banks);
finalizeRam(ram);
return { banks, ram: ram.symbols.length ? ram : null, totalSyms: labels.length };
}
/**
* For WLA-DX: bank 0 and 1 use fixed slots at 0x0000 and 0x4000.
* Any addr < 0x8000 → base is (addr & 0xC000)
* Addr >= 0x8000 → banked slot, base is 0x8000
* We keep addresses as-is; used range is computed vs the min address seen
* in the bank (fallback: 0x8000).
*/
function bankBaseAddr(bank, sampleAddr) {
if (bank === 0) return 0x0000;
if (bank === 1) return 0x4000;
// Banked slot (typically 0x8000)
if (sampleAddr >= 0x8000 && sampleAddr < 0xC000) return 0x8000;
if (sampleAddr < 0x4000) return 0x0000;
if (sampleAddr < 0x8000) return 0x4000;
return 0x8000;
}
/* ============================================================
* SDCC .map parser
* ============================================================
* Blocks:
* Area Addr Size ...
* AREA_NAME HHHHHHHH HHHHHHHH = ... bytes (ATTRS)
*
* [table header]
* ADDR SYMNAME [module]
* ADDR SYMNAME [module]
*
* Address mapping to bank/offset (devkitSMS convention):
* addr < 0x8000 → bank = addr / 0x4000, offset = addr % 0x4000
* 0x8000 ≤ addr < 0x10000 → RAM/registers, ignored for ROM view
* addr ≥ 0x10000 → bank = addr >> 16, offset = (addr & 0xFFFF) - 0x4000
* ============================================================ */
function parseSdccMap(text) {
const lines = text.split(/\r?\n/);
const areas = []; // {name, addr, size, attrs, isAbs, syms:[{addr,name,module}]}
let curArea = null;
let inSymList = false;
// ASxxxx maps split long areas across pages, re-declaring the same
// `_CODE ADDR SIZE = N. bytes (ATTRS)` header on each page. Dedup by
// (name, addr) so all symbols end up in a single area entry.
const areaByKey = new Map();
for (const line of lines) {
// Area declaration. Two forms exist:
// "_CODE 00000200 0000709E = 28830. bytes (REL,CON)"
// ". .ABS. 00000000 00000000 = 0. bytes (ABS,CON)"
// The `. .ABS.` area is where all `__at()` variables (RAM addresses) live,
// so we can't afford to miss it. Use a non-greedy name capture to allow
// internal whitespace up to the two 8-hex address/size fields.
const areaM = line.match(/^(.+?)\s+([0-9A-Fa-f]{8})\s+([0-9A-Fa-f]{8})\s*=\s*\d+\.\s*bytes\s*\(([^)]+)\)/);
if (areaM) {
const areaName = areaM[1].trim();
const key = areaName + '@' + areaM[2];
if (areaByKey.has(key)) {
curArea = areaByKey.get(key);
} else {
curArea = {
name: areaName,
addr: parseInt(areaM[2], 16),
size: parseInt(areaM[3], 16),
attrs: areaM[4],
isAbs: /ABS/i.test(areaM[4]),
syms: []
};
areaByKey.set(key, curArea);
areas.push(curArea);
}
inSymList = false;
continue;
}
if (/^\s+-+\s+-+/.test(line) || /^\s*Value\s+Global/i.test(line)) {
inSymList = true;
continue;
}
if (inSymList && curArea) {
// " 0000C0DA _map_shop_tmp banked_code_2"
const symM = line.match(/^\s+([0-9A-Fa-f]{8})\s+(\S+)\s*(.*)$/);
if (symM) {
curArea.syms.push({
addr: parseInt(symM[1], 16),
name: symM[2],
module: symM[3].trim() || null
});
} else if (/^\s*$/.test(line) || /^ASxxxx/.test(line)) {
inSymList = false;
}
}
}
// Dedup symbols within each area (same addr+name repeated across pages)
for (const a of areas) {
const seen = new Set();
a.syms = a.syms.filter(s => {
const k = s.addr + '|' + s.name;
if (seen.has(k)) return false;
seen.add(k);
return true;
});
}
// --- Compute per-symbol size at AREA level (before splitting into banks) ---
// Sort ALL symbols in area by addr (including linker-generated ones
// without a module, like `_abs`, `s__GSINIT`, etc. — these serve as
// boundary markers). Size = next_symbol.addr - cur.addr.
// Last symbol:
// REL area → size = area.addr + area.size - cur.addr
// ABS area → the area's `Addr` in the map is nominal (0); the
// real placement starts at the FIRST symbol's addr
// and spans `size` bytes. So the last symbol fills
// up to `first.addr + area.size`. For ABS areas that
// have size 0 (like `. .ABS.` catch-all), this
// degenerates to 0 (unknown), same as before.
// Then FLAG symbols with no module (`hasModule=false`) so they can be
// hidden from display while still contributing to size computation.
for (const a of areas) {
a.syms.sort((x, y) => x.addr - y.addr);
const areaAnchor = (a.isAbs && a.syms.length)
? a.syms[0].addr // first-symbol addr acts as the "real" area start
: a.addr;
for (let i = 0; i < a.syms.length; i++) {
const cur = a.syms[i];
let end;
if (i + 1 < a.syms.length) {
end = a.syms[i + 1].addr;
} else {
// Last symbol of the area.
end = areaAnchor + a.size;
}
cur.size = Math.max(0, end - cur.addr);
cur.hasModule = !!cur.module;
}
}
// --- Linear addr → bank / offset (devkitSMS convention) ---
// addr < 0x8000 → bank 0/1 (fixed slots)
// 0x8000 ≤ addr < 0x10000 → RAM/registers, ignored
// addr ≥ 0x10000 → banked: bank = addr >> 16
// offset = (addr & 0xFFFF) - 0x4000
function bankForAddr(addr) {
if (addr < 0x8000) {
return { num: addr >> 14, offset: addr & 0x3FFF };
}
if (addr < 0x10000) return null;
const num = addr >> 16;
const off = (addr & 0xFFFF) - 0x4000;
if (off < 0 || off >= BANK_SIZE) return null;
return { num, offset: off };
}
const banks = new Map();
const ram = { base: RAM_BASE, size: RAM_SIZE, symbols: [], _ranges: [] };
function getBank(num) {
if (!banks.has(num)) {
const base = num === 0 ? 0x0000 : num === 1 ? 0x4000 : 0x8000;
banks.set(num, { num, base, symbols: [], _ranges: [] });
}
return banks.get(num);
}
// --- Add each REL area's extent to bank ranges (may straddle bank boundaries) ---
// Also detect RAM areas (addr in [0xC000, 0xE000)) and feed them into
// the RAM pseudo-bank ranges.
for (const a of areas) {
if (a.isAbs || a.size === 0) continue;
// RAM area (e.g. _DATA at 0xC000)
if (a.addr >= RAM_BASE && a.addr < RAM_BASE + RAM_SIZE) {
const off = a.addr - RAM_BASE;
const end = Math.min(RAM_SIZE, off + a.size);
ram._ranges.push([off, end]);
continue;
}
const startBi = bankForAddr(a.addr);
if (!startBi) continue;
const endBi = bankForAddr(a.addr + a.size - 1);
if (!endBi) continue;
if (startBi.num === endBi.num) {
getBank(startBi.num)._ranges.push([startBi.offset, endBi.offset + 1]);
} else {
for (let bn = startBi.num; bn <= endBi.num; bn++) {
if (bn === startBi.num) getBank(bn)._ranges.push([startBi.offset, BANK_SIZE]);
else if (bn === endBi.num) getBank(bn)._ranges.push([0, endBi.offset + 1]);
else getBank(bn)._ranges.push([0, BANK_SIZE]);
}
}
}
// --- Distribute symbols to their banks or to the RAM pseudo-bank ---
// Only symbols WITH a module (real user-code from a .rel file, e.g.
// module="rom", "banked_code_2", "crt0") get displayed. Linker-internal
// symbols (no module) already served their purpose as size boundaries.
let total = 0;
for (const a of areas) {
for (const s of a.syms) {
if (!s.hasModule) continue;
// RAM symbol (0xC000-0xDFFF), regardless of the containing area
if (s.addr >= RAM_BASE && s.addr < RAM_BASE + RAM_SIZE) {
const off = s.addr - RAM_BASE;
// Clip size at RAM end (a very large size means the "next symbol" was
// outside RAM in linear-addr space, e.g. `s__BANK2 = 0x24000`)
const size = Math.min(s.size, RAM_SIZE - off);
ram.symbols.push({
addr: s.addr, name: s.name, size, area: a.name, module: s.module
});
total++;
continue;
}
const bi = bankForAddr(s.addr);
if (!bi) continue;
const bank = getBank(bi.num);
// Clip size at bank end (defensive; a symbol shouldn't straddle banks)
const maxSize = BANK_SIZE - bi.offset;
const size = Math.min(s.size, maxSize);
bank.symbols.push({
addr: bank.base + bi.offset,
name: s.name,
size,
area: a.name,
module: s.module
});
total++;
}
}
// Also, feed ABS-area symbol positions into their bank/ram ranges.
for (const b of banks.values()) {