/* Paramix Studio UI. Everything stays in this browser tab: the ROM is read with
* FileReader and the new ROM is offered as a download. Author: mameise */
(function () {
'use strict';
const C = window.ParamixCore;
const E = window.ParamixEmu;
const D = window.ParamixDoom;
const F = window.ParamixFeld;
const S6 = window.ParamixSix;
const $ = (id) => document.getElementById(id);
// ------------------------------------------------------------------ texts
const T = {
de: {
open: 'ROM öffnen', save: 'Neues ROM speichern',
startTitle: 'Mehr aus deinem Tamagotchi Paradise',
startText: 'Paramix Studio baut dein eigenes Paradise-ROM um. Lade dein Paradise-Abbild (16 MB Flash-Dump) oder lies es direkt vom Gerät aus, wähl aus, was dazukommen soll, und schreib das neue ROM zurück.',
featHead: 'Was du damit machen kannst',
g1t: 'Tamagotchi-Emulatoren', g1: 'Farb-Tamas (iD, iD L, Plus Color, P\'s, 4U, 4U+), Tama-Go mit Figuren, Friends, Meets und On, Connection V3, P1, P2, Angel und weitere erste Tamagotchis sowie Digimon V1 und V2. Mehrere zusammen im Menü, jeder mit eigenem Spielstand. Die ROMs bringst du selbst mit.',
g2t: 'DOOM und Wolfenstein 3D', g2: 'DOOM, Wolfenstein 3D und Spear of Destiny auf dem Paradise, mit eigener Tastenbelegung. Die Spieldateien bringst du selbst mit.',
g7t: 'Spielkonsolen', g7: 'Game Boy, Game Boy Color, Master System, Game Gear, Pokémon mini und Arduboy, mit Ton und Spielständen. Deine eigenen Spiele kommen ins Menü.',
g3t: 'Alle Felder', g3: 'Alle sechs Felder in einem ROM, mit Bildern, Spezialfiguren, passendem Planeten und den Lab-Spielen des Felds.',
g4t: 'Menü auf dem Gerät', g4: 'Felder wechseln, Items in die Tasche legen, Tamapoints setzen, Tama wechseln und mehrere Spielstände, direkt am Paradise. Spielzeit in den Spielen gibt Tamapoints.',
g8t: 'Startgerät ohne Paradise', g8: 'Fast die ganzen 16 MB für Emulatoren und Spiele. Jedes Programm kann zuerst starten, die Uhr stellst du im Menü.',
g5t: 'Gerät auslesen und beschreiben', g5: 'Mit einem USB-UART-Dongle das ROM sichern und das neue zurückschreiben. Spielstände bleiben, nur Geändertes wird geschrieben. Ein Schreibschutz hilft, wenn ein Schreiben abbricht.',
g6t: 'Eigene Figuren', g6: 'Jede Figur als Bild-Sheet zum Bearbeiten, auch Digimon von DIM-Karten. Farben und Augen werden automatisch angepasst.',
g9t: 'Spielstände und Besuche', g9: 'Spielstände sichern, einspielen und bearbeiten, Download-Inhalte einfügen. Besuche zwischen zwei Paradise über den Stecker oben, oder mit einem simulierten Besuch über den Dongle.',
dropTitle: 'ROM hierher ziehen oder klicken',
dropText: 'Land, Water, Sky, Jade Forest, Tropical und Glacier werden erkannt.',
f1t: 'Bearbeitung und Sicherung', f1: 'Dateien werden lokal bearbeitet. Beim Auslesen wird eine noch fehlende Edition zuerst privat auf dem Server gesichert, dann auf dem PC gespeichert.',
f2t: 'Nichts Fremdes dabei', f2: 'Paramix Studio enthält kein ROM, keine Firmware und keine WAD. Alles kommt von deinen eigenen Geräten und Dateien.',
f3t: 'Geprüft', f3: 'Prüfsummen werden neu gerechnet, geänderte Bilder vor dem Speichern noch einmal gelesen und jeder geschriebene Sektor auf dem Gerät gegengelesen.',
planTitle: 'Dein neues ROM', planFig: 'Figuren', planEmu: 'Emulator', planEmus: 'Emulatoren', planDoom: 'DOOM', planWolf: 'Wolfenstein 3D', planGb: 'Game Boy', planSms: 'Master System / Game Gear', planPm: 'Pokémon mini', planMenu: 'Menü', planApps: 'Weitere Emulatoren',
stNone: 'nicht dabei', stKeep: 'bleibt', stNew: 'neu', stDel: 'wird entfernt', stChanged: '{n} geändert', stSame: 'unverändert',
segFw: 'Firmware und Figuren', segEmu: 'Emulator', segDoom: 'DOOM', segWolf: 'Wolfenstein 3D', segGb: 'Game Boy', segSms: 'Master System / Game Gear', segPm: 'Pokémon mini', segSlots: 'Spielstände der Felder', segSave: 'Spielstand', segFree: 'frei', segResv: 'reserviert',
ruleBoth: 'Emulator oder DOOM: es passt nur eines von beiden ins ROM. Das Menü passt zu beidem.',
ruleNoRoom: 'In dieser Ausgabe ist kein Platz für Emulator und DOOM (die Figuren-Daten sind grösser). Das Menü geht.',
emuVsDoom: 'Achtung: DOOM ist gewählt oder eingebaut. Mit einer Firmware hier fällt DOOM weg.',
doomVsEmu: 'Achtung: ein Emulator ist gewählt oder eingebaut. Mit einer WAD hier fällt der Emulator weg.',
noRoomApp: 'In dieser Ausgabe ist kein Platz dafür.', a0Menu: 'Diese Ausgabe hat keinen Platz für ein Hauptprogramm bei 0x0A0000: alle Programme kommen ins Menü. Der Stern wählt, was beim Einschalten startet.', a0MenuN: 'Diese Ausgabe hat keinen Platz für ein Hauptprogramm bei 0x0A0000. Tama-Go, Friends, die alten Tamas und das V3 kommen ins Menü (A und C, dafür im Tab Menü Feldwechsel oder Items einschalten). Farb-Tamas und TG18 gehen hier nur im Startgerät.', a0NoMain: '{f}: Farb-Tamas und TG18 gehen bei dieser Ausgabe nur im Startgerät (Tab Menü).',
doomHas: 'In diesem ROM ist DOOM eingebaut.', doomOff: 'DOOM entfernen', doomGone: 'DOOM wird beim Speichern entfernt.',
keysTitle: 'Tasten', kFire: 'Schiessen', kFwd: 'Vorwärts', kBack: 'Zurück', kUse: 'Benutzen', kMod: 'Waffe wechseln: halten + Rad',
kWheel: 'Rad drücken', kRun: 'Laufen mit 2x Vorwärts', kInv: 'Rad andersherum', kFixed: 'Immer gleich: A+C Menü, B+C Karte. Ton an/aus: die Taste von "Waffe wechseln" halten und kurz aufs Rad drücken. Zurück: wie im Tab Menü unter "Zurück aus Programmen".',
kOld: 'Dieses DOOM ist älter und kennt noch keine eigene Tastenbelegung. Mit der WAD neu einbauen.',
help: 'Hilfe', helpTitle: 'So geht\'s', h1t: 'Ablauf', h1: '1. ROM öffnen (Datei vom eigenen Paradise) oder mit "Gerät" direkt auslesen.\n2. In den Tabs wählen, was hinein soll: Figuren, Emulatoren, Game Boy, Master System, Pokémon mini, DOOM, Wolfenstein, Menü.\n3. Speichern oder mit "Gerät" aufs Paradise schreiben. Mit "Spielstände behalten" bleibt der Spielstand auf dem Gerät.', h2t: 'Tasten am Paradise', hk1: 'A und C', hv1: 'auf dem Heimbildschirm: Menü oder Emulator starten', hk2: 'Rad lange (Tab Menü: änderbar)', hv2: 'Stand speichern und zurück ins Paradise', hk3: 'Rad kurz', hv3: 'T7Emu: Einstellungen und Figur', hk4: 'Rad in den ersten 3 s', hv4: 'gespeicherten Stand verwerfen (mit A bestätigen), der nächste Start beginnt frisch ab dem eigenen Spielstand des Tamas', hk5: 'B beim Einschalten', hv5: 'mit Autostart: Paradise oder Menü statt Hauptprogramm', hk6: 'Reset-Knopf', hv6: 'mit Autostart: das Hauptprogramm startet wieder', hk7: 'C beim Einschalten', hv7: 'Flash-App: das Gerät lässt sich mit "Gerät" neu schreiben (Notausgang)', h3t: 'Uhr', h3: 'Mit "Uhr beim Start vom Paradise übernehmen" (Tab Emulator) stellt der Emulator bei jedem Start seine Uhr auf die Zeit des Paradise. Was dazwischen war, wird nicht nachgespielt. Die Uhr also am Paradise stellen.', h4t: 'Wieder reingehen', h4: 'Der Emulator macht genau dort weiter, wo du mit dem Rad rausgegangen bist. Der eigene Spielstand des Tamas bleibt auch dann, wenn der gespeicherte Stand verworfen wird.', h5t: 'Menü und Felder', h5: 'A und C auf dem Heimbildschirm. Rad wählt, B bestätigt, C geht zurück. Beim Feldwechsel wird der Spielstand des alten Felds gepackt und der des neuen zurückgeholt.\n6 Felder: Tropical und Glacier bekommen Land, Water und Sky aus deinem eigenen ROM, Jade Forest bekommt Sky. Im Spiel wechselt das Tama über Planet, Felder. DNA und Bewohner gehören zum jeweiligen Feld.', h8t: 'Startgerät', h8: 'Tab Menü, Startgerät: das Gerät startet ins Menü mit allen Programmen. Ohne Paradise bleibt fast der ganze Speicher für Programme, die Uhr wird im Menü gestellt. Der Stern wählt das Hauptprogramm, mit Autostart startet es beim Einschalten.', h9t: 'Notausgang', h9: 'Bleibt der Bildschirm schwarz oder hängt ein Programm: C halten und Batterien einsetzen (oder Reset-Knopf drücken). Die Flash-App startet, das Gerät lässt sich mit "Gerät" auslesen und neu schreiben. Bricht ein Schreiben ab, startet die Flash-App von selbst.', h6t: 'Spielstände sichern', h7t: 'Spielstand einspielen', h7: '1. ROM mit "Gerät" frisch auslesen (oder das zuletzt gelesene öffnen).\n2. Tab Spielstand: einspielen. Der Spielstand kommt zum passenden Programm.\n3. Mit "Spielstände behalten" aufs Gerät schreiben. Nur dieser Spielstand wird ersetzt, der Paradise-Spielstand und die der anderen Programme bleiben wie auf dem Gerät.\nOhne "Spielstände behalten" kommen alle Spielstände aus der Datei. Programme dazu oder weg besser in einem eigenen Schreiben, vorher alle Spielstände sichern.', h6: 'Tab Spielstand oder Gerät, "Spielstand sichern". Vor einem Wechsel des Emulators sichern, der alte Spielstand geht dabei verloren.', device: 'Gerät', devTitle: 'Gerät über UART', devHint: 'UART-Dongle mit 3,3 V an die drei Kontakte: links RX vom Dongle, Mitte GND, rechts TX vom Dongle. Am Paradise den Download-Bildschirm öffnen (Planet, A, Connect, Download, Download), dann Verbinden. Braucht Chrome oder Edge am Computer.',
devConnect: 'Verbinden', devDump: 'ROM sichern und herunterladen', devWrite: 'Neues ROM aufs Gerät schreiben', devOnly: 'Nur Änderungen schreiben', devKeep: 'Spielstände behalten', devStop: 'Abbrechen',
devNoSerial: 'Dieser Browser kann nicht mit dem Dongle reden. Bitte Chrome oder Edge am Computer verwenden.', devNone: 'Nicht verbunden.',
devOn: 'Verbunden: {ed}, {mb} MB{l}', devLoaded: ', Flash-App geladen', devReady: 'Bereit.', devNeedRom: 'Zum Schreiben zuerst ein ROM öffnen (oder auslesen).',
visTitle: 'Besuch simulieren (Paradise)', visStart: 'Starten', visStop: 'Beenden',
visHint: 'Das Studio spielt ein zweites Paradise. Dongle an die Kontakte, das Paradise läuft normal.\n1. Edition wählen, Starten, Dongle wählen.\n2. Am Paradise: Planet-Menü, VERBINDUNG, PLAYDATE, dann B.\nOben "Verbinden" ist nur fürs ROM, für den Besuch nicht drücken.',
visWait: 'Bereit als {ed}. Am Paradise PLAYDATE wählen und B drücken.', visRun: 'Verbunden, Daten werden getauscht…', visPlay: 'Die beiden spielen…',
visDone: 'Besuch fertig ({ed}). Für den nächsten wieder B am Paradise.', visErr: 'Abgebrochen: {e}. Am Paradise nochmals B.', visBadKey: 'Das Paradise versteht die Daten nicht.',
phload: 'Flash-App laden', phread: 'Auslesen', phcompare: 'Vergleichen', phwrite: 'Schreiben', phcheck: 'Prüfen', phprepare: 'Vorbereiten',
devDumped: 'ROM ausgelesen und als {n} gespeichert. Es ist jetzt im Studio geöffnet.',
devSure: 'Das neue ROM wird jetzt aufs Gerät geschrieben. Gerät während des Schreibens eingeschaltet lassen. Auf eigene Gefahr schreiben?',
devSureFull: 'Ohne "Spielstände behalten" wird auch der Spielstand mit dem aus dem ROM überschrieben. Trotzdem schreiben?',
carryUnknown: 'Das Gerät hat nicht das geladene ROM. Ein Programm zieht um und sein Spielstand auf dem Gerät kann nicht mitgenommen werden. Zuerst das ROM vom Gerät lesen. Trotzdem schreiben?', carryMiss: 'Ein Programm zieht um und sein Spielstand auf dem Gerät kann nicht mitgenommen werden. Vorher im Tab Spielstand sichern. Trotzdem schreiben?', devEmuLost: 'Hauptprogramm auf dem Gerät: {o}. Im neuen ROM: {n}. Der Spielstand von {o} als Hauptprogramm fängt deshalb neu an. Zum Behalten vorher unter "Spielstand" sichern. Trotzdem schreiben?', devEmuNone: 'keinen Emulator', devEmuNew: '{o} mit einer neu gewählten Firmware',
devDone: 'Fertig und geprüft: {w} Sektoren geschrieben{k}. Das Gerät kann neu gestartet werden (Reset oder Batterie).', devKept: ', {k} Sektoren Spielstand behalten',
devSame: 'Nichts zu schreiben, das Gerät hat schon dieses ROM.', devErr: 'Fehler: {e}', devCancelled: 'Abgebrochen.',
fl_timeout: 'keine Antwort vom Gerät ({c} {a})', fl_noAck: 'das Gerät antwortet nicht. Steht es auf dem Download-Bildschirm?', fl_repeats: 'zu viele Wiederholungen beim Laden',
fl_devCancel: 'das Gerät hat das Laden abgebrochen', fl_unexpected: 'unerwartete Antwort: {r}', fl_hello: 'unerwartete Antwort auf HELLO', fl_notReady: 'Flash nicht bereit',
fl_readErr: 'Lesefehler bei {a}', fl_noCrc: 'keine Prüfsumme bei {a}', fl_cancelled: 'abgebrochen', fl_size: 'das Abbild muss genau 16 MB gross sein',
fl_notParadise: 'kein Paradise-Abbild (SONIXDEV fehlt)', fl_cancelledWrite: 'abgebrochen. Gerät eingeschaltet lassen und nochmals schreiben',
fl_notAccepted: 'Sektor {a} nicht angenommen. Gerät eingeschaltet lassen und nochmals schreiben', fl_differs: 'Sektor {a} weicht nach dem Schreiben ab. Gerät eingeschaltet lassen und nochmals schreiben',
fl_checkFail: 'Prüfung bei {a} falsch. Gerät eingeschaltet lassen und nochmals schreiben', fl_rescueBusy: 'der Rettungsbereich (0xFF0000) ist belegt', fl_noRescueRoom: 'Kein Platz für den Schreibschutz (Rettungsstart, oberste 64 KB im Flash). Es wurde nichts geschrieben. Ein Programm im Startgerät entfernen und nochmals schreiben.', fl_rescueMode: 'Das letzte Schreiben wurde unterbrochen. Das Gerät wartet im Flash-Bildschirm: nochmals schreiben.', resOn: 'Schreibschutz aktiv: bricht ein Schreiben ab, startet das Gerät im Flash-Bildschirm.', resModeGo: 'Das letzte Schreiben wurde unterbrochen. Das Gerät ist im Flash-Bildschirm und wartet. "Schreiben fortsetzen" drücken.', resModeRom: 'Das letzte Schreiben wurde unterbrochen. Das Gerät ist im Flash-Bildschirm und wartet. Das ROM nochmals öffnen (oder deinen Abzug) und aufs Gerät schreiben.', resResume: 'Schreiben fortsetzen', resHalf: 'Das letzte Schreiben wurde nicht fertig. "Schreiben fortsetzen" drücken, damit alles wieder zusammenpasst.', resResumed: 'Fertig: {w} Sektoren geschrieben. Paradise aus- und einschalten.', fl_rescueFail: 'der Rettungsstart wurde nicht richtig geschrieben', fl_noRescue: 'kein Rettungsstart: 0xFF0000 ist belegt', resTest: 'Rettungsstart testen', resBack: 'Kopf zurückschreiben', resSure: 'Test: Der Rettungsstart kommt nach 0xFF0000, dann wird der Kopf des Geräts (Sektor 0) gelöscht. Danach Paradise aus- und einschalten. Erscheint der Flash-Bildschirm, hier verbinden und "Kopf zurückschreiben". Erscheint er nicht, ist das Gerät ohne eigenes Flash-Werkzeug nicht mehr startbar. Weiter?', resCleared: 'Kopf gelöscht. Paradise aus- und einschalten. Flash-Bildschirm da? Dann verbinden und "Kopf zurückschreiben".', resBackDone: 'Kopf zurückgeschrieben. Paradise aus- und einschalten: es startet wieder normal.', resNoHdr: 'Kein gemerkter Kopf.', fl_noAnswer: 'keine Antwort. Gerät auf den Download-Bildschirm stellen und nochmals versuchen', fl_noData: 'keine Antwort, vom Adapter kommen gar keine Daten an. Gerät auf den Download-Bildschirm stellen und nochmals versuchen. Kommt weiter nichts: Kabel und Treiber des Adapters prüfen', fl_garbled: 'es kommen Daten an, aber unlesbar ({n} Bytes: {h}). Kabel (TX und RX) und Treiber des Adapters prüfen', plHint: 'Prolific-Adapter (PL2303): Neuere Windows-Treiber sperren ältere und nachgebaute PL2303-Chips. Dann kommen keine Daten durch. Abhilfe: im Geräte-Manager den älteren Prolific-Treiber 3.3.2.x wählen oder einen Adapter mit CH340 oder CP2102 nehmen.', fl_lost: 'das Gerät antwortet vor dem Schreiben nicht mehr. Geschrieben wurde nichts. Paradise aus- und einschalten, Download-Bildschirm, neu verbinden und nochmals schreiben',
fl_appSilent: 'die Flash-App ist gesendet, antwortet aber nicht. Nochmals versuchen', fl_unknownEd: 'Ausgabe des neuen ROMs unbekannt, "Spielstände behalten" abwählen',
fl_otherEd: 'das Gerät ist {d}, das neue ROM ist {r}. Zum Wechseln der Ausgabe "Spielstände behalten" abwählen',
fl_noteNoFit: 'Feld {f} passt nicht ins neue Fach und wird nicht behalten', fl_noteMoved: 'Feld {f} ist ins neue Fach umgezogen', fl_noteSaveMoved: 'Spielstand von {n} mitgenommen',
fl_noteDropped: 'das neue ROM hat kein Feld-Menü, die gespeicherten Felder auf dem Gerät fallen weg', fl_noteEdKept: 'das Gerät ist {d}, das neue ROM ist {r}: gleiche Firmware, Spielstand und Feld vom Gerät bleiben ({d})', fl_noteEmu: 'TamaEmu-Firmware neu gewählt, der Emulator startet frisch. Für ein Update das ROM nur öffnen und speichern',
cleanOn: 'Ohne Paradise (Clean ROM)', cleanClock: 'Uhr beim Start stellen', cleanClockHint: 'Fehlt die Uhr (neue Batterien), fragt das Menü beim Einschalten danach. Ohne: Die Uhr stellst du im Menü unter SETTINGS oder in jedem Emulator selbst.', emuClockOff: 'Geht nur mit "Uhr beim Start stellen" (Tab Menü).', emuSess: 'Spielstand beim Verlassen merken', emuSessHint: 'Beim nächsten Start geht es genau dort weiter. Ohne: Das Spiel startet neu und lädt seinen eigenen Spielstand, wie das echte Gerät.', ruleClean: 'Ohne Paradise: alle Programme kommen ins Menü, fast der ganze Speicher ist für sie da.', cleanHint: 'Kein Paradise mehr auf dem Gerät, nur das Menü mit deinen Programmen. Fast die ganzen 16 MB sind frei.', cleanUse: 'Nach dem Einschalten kommt gleich das Menü. Beim ersten Start stellst du die Uhr, später unter SETTINGS. Zurück aus einem Programm wie gewohnt.', cleanWarn: 'Das Paradise und sein Spielstand gehen beim Schreiben verloren. Mach vorher eine Sicherung.', cleanNoDoom: 'DOOM geht noch nicht ohne Paradise. Bitte DOOM entfernen.', doomOne: 'DOOM geht nur einmal ins Menü.', cleanSure: 'Auf dem Gerät ist das Paradise. Es wird gelöscht, mit seinem Spielstand. Hast du eine Sicherung des Geräts? Weiter?', cleanLoaded: 'ROM ohne Paradise ({ed}) geladen: {n} Programme.',
launchOn: 'Nur Startgerät für Programme', launchHint: 'Vom Paradise bleibt nur die Einrichtung (Sprache, Uhr, Weiter oder Neu). Danach kommt immer das Menü mit deinen Emulatoren und DOOM. Alle Bilder des Spiels fallen weg, das gibt etwa 5 MB mehr Platz.', launchUse: 'Nach dem Einschalten und dem Stellen der Uhr kommt das Menü. Rad wählt, B startet. Zurück aus einem Programm wie gewohnt, dann kommt wieder das Menü.', launchOld: 'Dieses ROM ist ein Startgerät. Für ein normales Paradise das Original-ROM laden.', launchNeed: 'Ein Startgerät braucht mindestens ein Programm (Emulator oder DOOM).', launchSix: 'Startgerät geht nicht mit eingebauten sechs Feldern. Bitte das Original-ROM laden.', planLaunch: 'Startgerät',
tabFeld: 'Menü', feldOn: 'Mehrere Spielstände (mit Feldwahl)', bagOn: 'Items und Tamapoints', tamaOn: 'Tama ändern (Stufe, Pflege, Figur)', gplayOn: 'Spielzeit gibt Tamapoints', gplayHint: 'DOOM, Wolfenstein, Game Boy, Master System, Pokémon mini und Arduboy: 10 Tamapoints pro Minute Spielzeit, beim Zurückkehren ins Paradise.', saveSlot: 'Spielstand {n}',
sixOn: 'Alle 6 Felder', sixPick: 'Land-, Water- oder Sky-ROM wählen', sixHint: 'Holt Land, Water und Sky zu Tropical und Glacier dazu. Die Feldbilder kommen aus deinem eigenen Land-, Water- oder Sky-ROM. Die Lab-Spiele richten sich nach dem Feld, mit dem der Tama im Menü startet.',
sixNeed: 'Für alle 6 Felder fehlt noch ein Land-, Water- oder Sky-ROM.', sixOk: 'Feldbilder aus {n} übernommen.', sixBad: '{n} ist kein Land-, Water- oder Sky-ROM.', sixIn: 'Alle 6 Felder sind eingebaut.', sixOff: 'Beim Speichern kommen Land, Water und Sky wieder raus. Mehrere Spielstände gehen weiterhin.', sixOffJ: 'Beim Speichern kommt Sky wieder raus. Mehrere Spielstände gehen weiterhin.', sixOffField: 'Das Gerät ist gerade auf {f}. Erst im Menü auf {s} wechseln.', sixOffSlots: 'Die im Menü gespeicherten Spielstände werden dabei gelöscht. Weiter?', sixFail: 'Felder nicht eingebaut: {e}', sixNoFw: 'Die Firmware dieses ROMs ist verändert, weitere Felder gehen hier nicht.', planSix: 'Mehr Felder', sixOnJ: 'Sky als 4. Feld', sixHintJ: 'Jade Forest hat die Sky-Bilder schon dabei.', sixInJ: 'Sky ist als 4. Feld eingebaut.', sixOld: 'Alle 6 Felder sind eingebaut, aber in einer älteren Version. Wähl dein Land-, Water- oder Sky-ROM, dann wird beim Speichern alles nachgerüstet.', sixOldJ: 'Sky ist eingebaut und wird beim Speichern auf den neuen Stand gebracht.', sixPlanet: 'Planet passend zum Feld', sixMenu: 'Spielmenü Felder: alle Felder ab Stufe 4', sixPlanetNeed: 'Zum Ändern dieser Einstellung braucht es nochmals dein Land-, Water- oder Sky-ROM.', sixApp: 'DOOM und Emulator passen nicht dazu',
exitKey: 'Zurück aus Programmen', exitHint: 'Wie man aus allen Programmen (Emulatoren und Spiele) zum Paradise oder ins Menü zurückkommt.', exit0: 'Rad lange drücken', exit1: 'Rad und A halten', exit2: 'Rad und C halten', exit3: 'Rad 5 s drücken', feldHint: 'Kleines Menü im ROM: zwischen Spielständen wechseln (neuer Spielstand auf einem Feld nach Wahl), Items in die Tasche legen, Tamapoints setzen, Tama ändern.',
feldUse: 'Öffnen: auf dem Heimbildschirm A und C zusammen halten. Rad wählt, B bestätigt, C zurück.',
feldNo: 'Feldwahl geht mit Land, Water, Sky (untereinander) und Tropical, Glacier (untereinander).', feldMissing: 'In dieser Ausgabe fehlt das Menü.',
feldCur: 'Aktives Feld: {f}.', feldList: 'Wählbar: {s}.', feldStored: 'Gespeichert: {s}.', feldFail: 'Menü nicht eingebaut: {e}', feldUnknown: 'Ausgabe nicht erkannt.',
tabWolf: 'Wolf3D', wolfPick: 'Spieldateien wählen', wolfHint: 'Alle Dateien von Wolfenstein 3D zusammen wählen: Shareware (.WL1), Vollversion (.WL6) oder Spear of Destiny (.SOD). Das Spiel kommt ins Paramix-Menü.', wolfNone: 'Noch keine Spieldateien gewählt.', wolfShare: 'Shareware', wolfFull: 'Vollversion', wolfEps: '{n} Episoden', wolfEp1: '1 Episode', wolfBad: 'Wolfenstein 3D: {e}', wolfNoMain: 'Wolfenstein 3D nur im Menü', wolfTurn: 'Drehen pro Radstufe', wolfFixed: 'Immer gleich: A+C Menü. Zurück (das Spiel wird gespeichert): wie im Tab Menü unter "Zurück aus Programmen".', wolfOne: 'Es gibt nur ein Wolfenstein 3D und ein Spear of Destiny im Menü, das neue ersetzt das alte.', wolfSodN: '21 Level',
tabGb: 'Game Boy / Color', gbNoMain: 'Game Boy nur im Menü', gbPick: 'Spiele wählen (.gb, .gbc)', gbHint: 'Die Spiele kommen ins Paramix-Menü. Am Gerät: A+B+C zusammen öffnet die Einstellungen (dort auch Select und Ton). Rad 2 s halten speichert und führt zurück, beim nächsten Start geht es dort weiter. Zwei Paradise oben zusammengesteckt sind wie mit einem Link-Kabel verbunden, z. B. zum Pokémon tauschen.', gbNone2: 'Noch kein Spiel gewählt.', gbKeysTitle: 'Tasten', gbKeysDef: 'Standard', gbKeysMiss: 'Nicht belegt: {n}', gbNone: '–', gbRight: 'Rechts', gbLeft: 'Links', gbUp: 'Hoch', gbDown: 'Runter', gbInA: 'Taste A', gbInB: 'Taste B', gbInC: 'Taste C', gbInWp: 'Rad drücken', gbInWu: 'Rad hoch', gbInWd: 'Rad runter', gbInAC: 'A + C', gbInBC: 'B + C', gbInAB: 'A + B', gbBad: '{f}: kein Game-Boy-Spiel', gbColor: '{f}: nur für Game Boy Color, das geht nicht', gbNeedRom: 'Zuerst ein ROM öffnen (oder vom Gerät lesen).', t7Old: '{n}: veraltete Version, der Spielstand kann beim Batteriewechsel verloren gehen. Jetzt mit "Spielstände behalten" neu schreiben.', t18Broken: 'Tama Meets ist beschädigt. Tama Meets entfernen und die Firmware neu hinzufügen, dann ohne "Spielstände behalten" schreiben.', t18Clash: 'das Hauptprogramm bräuchte den Platz von Tama Meets. Tama Meets zuerst entfernen.', tabSms: 'Master System / Game Gear', tabPm: 'Pokémon mini', smsNoMain: 'Master System und Game Gear nur im Menü', pmNoMain: 'Pokémon mini nur im Menü', abNoMain: 'Arduboy nur im Menü', planAb: 'Arduboy', segAb: 'Arduboy', tabAb: 'Arduboy', abPick: 'Spiele wählen (.hex, .zip)', abHint: 'Die Spiele kommen ins Paramix-Menü. Am Gerät: A+B+C zusammen öffnet die Einstellungen (dort auch Bildgrösse und Ton). Rad 2 s halten speichert und führt zurück, beim nächsten Start geht es dort weiter.', abBad: '{f}: kein Arduboy-Spiel', abBig: '{f}: zu gross für den Arduboy', smsPick: 'Spiele wählen (.sms, .gg)', smsHint: 'Die Spiele kommen ins Paramix-Menü. Am Gerät: A+B+C zusammen öffnet die Einstellungen (dort auch Pause und Ton). Rad 2 s halten speichert und führt zurück, beim nächsten Start geht es dort weiter.', smsBad: '{f}: kein Master-System- oder Game-Gear-Spiel', smsGG: '{f}: Game-Gear-Spiel, das geht nicht', smsB1: 'Knopf 1', smsB2: 'Knopf 2', smsPause: 'Pause / Start', pmPick: 'Spiele wählen (.min, .zip)', pmHint: 'Die Spiele kommen ins Paramix-Menü. Am Gerät: A+B+C zusammen öffnet die Einstellungen (dort auch Power und Ton). Rad 2 s halten speichert und führt zurück, beim nächsten Start geht es dort weiter.', pmBad: '{f}: kein Pokémon-mini-Spiel', pmBig: '{f}: grösser als 1 MB, das geht nicht', pmBiosPick: 'Eigenes BIOS wählen', pmBiosDel: 'Eigenes BIOS entfernen', pmBiosFree: 'Ohne eigenes BIOS läuft das freie BIOS von PokeMini. Mit dem echten BIOS laufen manche Spiele besser.', pmBiosOwn: 'Eigenes BIOS gewählt, es gilt für alle Pokémon-mini-Spiele.', pmBiosBad: '{f}: kein Pokémon-mini-BIOS', pmA: 'A', pmB: 'B', pmC: 'C', pmPower: 'Power', pmShake: 'Schütteln',
tabFigs: 'Figuren', tabAll: 'Alle Sprites', tabDim: 'Karte', tabEmu: 'Emulator', tabDoom: 'DOOM',
doomPick: 'DOOM.WAD wählen', doomEp: 'Episode', doomMusic: 'Musik',
doomHint: 'Baut DOOM ins ROM. Die WAD bringst du selbst mit, sie bleibt auf deinem Computer.',
doomUse: 'Starten: im Paramix-Menü, mit Paradise auch auf dem Heimbildschirm A und C zusammen halten. Zurück: wie im Tab Menü unter "Zurück aus Programmen".',
doomNone: 'Keine WAD gewählt.', doomOk: 'WAD erkannt ({eps}). DOOM wird beim Speichern eingebaut.', doomEpsHint: 'Ohne Paradise: jede angehakte Episode kommt als eigener Eintrag ins Menü (DOOM E1, DOOM E2 ...), mit eigenem Spielstand.', doomWhole: 'Ganze WAD als ein Eintrag', pwadPick: 'Zusatz-WAD wählen', pwadOff: 'Zusatz-WADs entfernen', doomPwads: 'Dazu: {n}.', pwadNeedD2: '{n} ist für DOOM II: zuerst DOOM2.WAD wählen.', pwadNeedD1: '{n} ist für DOOM oder Ultimate DOOM: zuerst DOOM.WAD wählen.', doomPwadPara: 'Eigene Episoden (wie Sigil) gehen nur ohne Paradise.', doomPwadBig: '{n}: die Karten {m} sind wahrscheinlich zu gross für den Speicher des Paradise. DOOM zeigt dann eine Zeile mit einer 9, Rad 2 s halten führt zurück ins Menü.', doomPwadHint: 'Eigene Episoden (wie Sigil) kommen als eigener Eintrag ins Menü, dafür den Haken setzen. Zusammen mit der ganzen WAD sind sie meist zu gross.', doomD2Clean: 'DOOM II geht nur in ein ROM ohne Paradise.', doomD2Hint: 'DOOM II kommt als ein Eintrag ins Menü. Es braucht fast den ganzen Platz und passt nur ohne Musik.', doomWholeHint: 'Alle Episoden in einem Eintrag "DOOM", die Episode wählt man im Spiel. Braucht viel weniger Platz als einzeln.',
doomBad: 'WAD nicht erkannt: {e}', doomFail: 'DOOM nicht eingebaut: {e}', doomMissing: 'In dieser Ausgabe fehlt das DOOM-Programm.',
doomBoth: 'Emulator und DOOM zusammen passen nicht in ein ROM. Bitte nur eines wählen.',
doomBig: 'Keine Episode dieser WAD passt ins ROM.', doomNoMusic: 'Diese Episode passt nur ohne Musik.',
emuPick: 'Firmware oder ROM wählen', emuOff: 'Emulator entfernen',
emuHint: 'Farb-Tamas (TamaEmu), Tama-Go und Friends (T7Emu), Meets und On (T18Emu), erste Tamagotchis und Digimon (V1Emu), Connection V3 (V3Emu). Das erste ist das Hauptprogramm, jedes weitere kommt ins Menü. Der volle Stern zeigt das Hauptprogramm, ein Klick auf einen leeren Stern macht ein anderes dazu. Die Dateien bringst du selbst mit.', t7Ok: 'V7-ROM erkannt (T7Emu). Es wird beim Speichern eingebaut.', t7OkFr: 'Tamagotchi Friends erkannt (T7Emu, Test). Es wird beim Speichern eingebaut. Figuren gibt es dafür keine.', t7Has: 'In diesem ROM ist T7Emu eingebaut.', t7HasFr: 'In diesem ROM ist T7Emu mit Tamagotchi Friends eingebaut.', t7Use: 'Starten: auf dem Heimbildschirm A und C zusammen halten. Zurück: Rad lange drücken (speichert). Rad kurz: Einstellungen und Figur. Hängt T7Emu: mit A und C starten, loslassen und in den ersten 3 Sekunden das Rad drücken und mit A bestätigen.', t7FigPick: 'Figuren hinzufügen', t7FigNone: 'Noch keine Figuren.', t7FigBad: '{f}: keine Figur.', t7FigFull: 'Kein Platz mehr für {f}.', t7FigMax: 'Kein Platz für weitere Figuren.', t7FigDup: '{f} ist schon dabei.', appPick: 'Weiteren Emulator dazu', appHint: 'Noch ein Tama-Go- oder Friends-ROM (T7Emu). Start über das Menü (A und C), dafür muss im Tab Menü etwas eingeschaltet sein.', appNone: 'Keine weiteren Emulatoren.', appBad: '{f}: kein Tama-Go- oder Friends-ROM.', appBadL: '{f}: weder Tama-Go-, Friends-ROM noch Farb-Tama- oder TG18-Firmware.', appT18One: 'T18Emu geht nur einmal pro ROM.', appHintL: 'Im Startgerät: Tama-Go- oder Friends-ROM, Farb-Tama-Firmware (TamaEmu) oder TG18-Firmware (T18Emu, nur einmal).', ruleLaunch: 'Startgerät: Emulatoren und DOOM passen zusammen, solange Platz frei ist.', appMax: 'Höchstens 12 weitere Emulatoren.', appNeedMenu: 'Weitere Emulatoren starten über das Menü: im Tab Menü Feldwechsel oder Items einschalten.', appFail: 'Weitere Emulatoren: {e}', appSix: 'Sechs Felder gehen nicht zusammen mit weiteren Emulatoren.', t7SaveBtn: 'T7Emu-Spielstand (.bin)', saveFor: 'Programm', saveMain: 'Haupt-Emulator', v1SaveBtn: 'V1Emu-Spielstand (.bin)', saveT18No: 'T18Emu: Spielstand sichern geht hier noch nicht.', saveNoBatt: 'Dieses Spiel hat keinen Spielstand auf dem Modul.', saveNone: 'Noch kein Spielstand.', saveWrongFile: 'Diese Datei passt nicht zu {n}.', saveCartIn: 'Spielstand für {n} übernommen. Jetzt das ROM speichern oder aufs Gerät schreiben. Ein gemerkter Spielzustand wird verworfen.', t7SaveXDone: 'Spielstand für {n} übernommen. Jetzt das ROM speichern oder aufs Gerät schreiben.', t7NoSave: 'Das Tama hat noch keinen Spielstand.', t7SaveInDone: 'T7Emu-Spielstand übernommen. Jetzt das ROM speichern oder aufs Gerät schreiben.', t7SaveNeed: 'T7Emu fehlt im ROM: zuerst im Tab Emulator das Tama-Go-ROM hinzufügen.', saveT18Need: 'T18Emu fehlt im ROM: zuerst im Tab Emulator die TG18-Firmware hinzufügen.', saveEmuAny: 'Emulator-Spielstand (.sav / .bin)',
emuUse: 'Starten: auf dem Heimbildschirm A und C zusammen halten. Zurück: Rad lange drücken (speichert). Hängt TamaEmu: mit A und C starten, loslassen und in den ersten 3 Sekunden das Rad drücken und mit A bestätigen. Dann beginnt er neu ab dem eigenen Spielstand des Tamas.',
emuNone: 'Kein Emulator gewählt.', petT: 'Spielstand ändern', petOpen: 'Paradise-Spielstand öffnen', petRom: 'Spielstand im ROM', petClose: 'Schliessen', petRomDone: 'Im ROM geändert. Jetzt das ROM speichern oder aufs Gerät schreiben (ohne "Spielstände behalten", sonst bleibt der Spielstand des Geräts).', petLevel: 'Stufe', petChar: 'Tama', petCare: 'Satt, glücklich, gesund', petSave: 'Geänderten Spielstand speichern', petKeep: 'unverändert', petKid: 'Kind', petYoung: 'Teen', petAdult: 'Erwachsen', petNow: 'Im Spielstand: Stufe {l}, Tama {c}, Hunger {h}/6, Laune {j}/20{s}.', petSick: ', krank', petOther: 'Der Spielstand ist für eine andere Ausgabe als das geladene ROM.', petNoSet: 'Im Spielstand fehlt der Einstellungsblock.', petDone: '{n} gespeichert. Mit "Spielstand aufs Gerät" übertragen.', petNothing: 'Nichts geändert.', tabSave: 'Spielstand', tabNames: 'Namen', cardNoChars: 'keine Figuren auf dieser Karte', noRoomFrag: 'Passt nicht zusammen: insgesamt wäre genug frei, aber nicht in einem Stück (die WAD von DOOM braucht ein grosses Stück am Stück). Ein Programm entfernen oder DOOM ohne Musik.', noRoomKB: 'Zu wenig Platz: es fehlen etwa {k} KB. Ein Programm entfernen. (Oben bleiben 64 KB für den Schreibschutz frei.)', noRoomAdd: '{n} hat keinen Platz mehr: es fehlen etwa {k} KB. (Oben bleiben 64 KB für den Schreibschutz frei.)', eyeMvT: 'Augen verschieben', mouthMvT: 'Mund verschieben', poseNr: 'Pose {i} von {n}', faceBig: 'Gross', faceSmall: 'Klein', poseOnly: 'Nur diese Pose', poseOnlyHint: 'Die Pfeile verschieben Augen oder Mund nur in der gezeigten Pose. Für eigene Figuren, bei denen einzelne Posen nicht passen.', eyeMvHint: 'Gilt auf dem Feld für Tamas, die nach dem Schreiben schlüpfen oder sich entwickeln. Die kleine Figur rückt halb so weit.', planEyes: 'Augen und Mund', namesHint: 'Namen ändern: Grossbuchstaben, Ziffern, Leerzeichen und . & \' ! ? /. Gilt für alle Sprachen mit lateinischer Schrift auf dem Gerät.', namesFields: 'Felder', namesChars: 'Tamas', namesItems: 'Items', namesFind: 'Suchen', namesUndo: 'Alle zurücksetzen', planNames: 'Namen', planNamesN: '{n} geändert', saveParaOut: 'Paradise-Spielstand (.tamasave)', saveEmuOut: 'TamaEmu-Spielstand (.sav)', saveInfo: 'Exportieren holt die Spielstände aus diesem ROM. Ein Emulator-Spielstand (TamaEmu .sav oder T7Emu .bin) kommt ins ROM, danach das ROM speichern oder aufs Gerät schreiben. Ein Paradise-Spielstand geht direkt aufs Gerät, dafür oben das Gerät verbinden.', saveOutT: 'Exportieren', saveInT: 'Einspielen', saveSecProg: 'Programme', saveSecPara: 'Paradise', saveParaOutB: 'Exportieren (.tamasave)', saveParaInB: 'Aufs Gerät schreiben (.tamasave)', saveProgInfo: 'Exportieren holt den Spielstand des gewählten Programms aus diesem ROM. Einspielen bringt ihn ins ROM, danach das ROM speichern oder aufs Gerät schreiben.', saveParaInfo: 'Exportieren holt den Paradise-Spielstand aus diesem ROM. Aufs Gerät schreiben geht direkt, dafür oben das Gerät verbinden. Platz: welcher Spielstand.', saveSlotL: 'Platz', slotLive: '{n} (aktiv)', slotEmpty: '{n} (leer)', slotNone: 'Auf diesem Platz ist kein Spielstand.', slotField: 'Der Spielstand ist für {a}, der Platz für {b}.', slotDevOther: 'Das Menü auf dem Gerät passt nicht zum geladenen ROM. Zuerst das ROM vom Gerät laden.', slotSure: 'Der Spielstand kommt auf dem Gerät nach {n} und ersetzt den dortigen. Weiter?', slotDone: 'Fertig: {n} auf dem Gerät ersetzt.', saveNoProg: 'Noch kein Programm im ROM. Ein TamaEmu-Spielstand bringt seinen Emulator mit, T7Emu und T18Emu zuerst im Tab Emulator hinzufügen.', saveBtnOut: 'Exportieren ({f})', saveBtnIn: 'Einspielen ({f})', saveEmuInDone: 'TamaEmu-Spielstand übernommen ({d}). Jetzt das ROM speichern oder aufs Gerät schreiben.', saveEmuOther: 'Im ROM ist TamaEmu für {a}, der Spielstand ist für {b}. Trotzdem übernehmen?', saveNoRoom: 'Für TamaEmu ist in diesem ROM kein Platz.', saveEmuBad: 'Das ist kein passender Spielstand für dieses Programm.', saveNoEmu: 'In diesem ROM ist kein Emulator.', saveDone: '{n} gespeichert.', saveNoClock: '{n} gespeichert. Die Uhr ist nicht dabei, in der App eventuell neu stellen.', devSaveRead: 'Spielstand sichern', devSaveWrite: 'Spielstand aufs Gerät', devSaveHint: 'Sichern holt den Paradise-Spielstand mit Uhr und den Spielstand von TamaEmu oder T7Emu. Aufs Gerät geht nur der Paradise-Spielstand.', devSaveSure: 'Der Spielstand wird auf das Gerät ({ed}) geschrieben und ersetzt den jetzigen. Weiter?', devSaveDone: 'Fertig: {w} Seiten geschrieben. {c} Das Gerät kann neu gestartet werden.', devSaveClock: 'Uhr übernommen.', devSaveClockNo: 'Die Uhr bitte am Gerät stellen.', devSaveGot: 'Gesichert: {n}.', fl_saveOtherEd: 'der Spielstand ist von einer anderen Ausgabe ({s}), das Gerät ist {d}', fl_saveFamily: 'der Spielstand passt nicht zu dieser Ausgabe', fl_saveNoSettings: 'im Spielstand fehlt der Einstellungsblock, das ist kein vollständiger Paradise-Spielstand', fl_saveOutside: '{n} Seiten liegen ausserhalb des Spielstands und werden nicht geschrieben', fl_saveIncomplete: 'der Spielstand enthält nicht alle Seiten, fehlende bleiben wie auf dem Gerät', emuUndo: 'Auswahl zurücknehmen', progMain: 'Start mit A und C', progMainL: 'Erster Eintrag im Menü', progMenu: 'Start im Menü', progGone: 'wird entfernt', progUndo: 'Zurücknehmen', progDel: 'Entfernen', progNone: 'Noch kein Emulator. Firmware oder ROM wählen, jedes weitere kommt ins Menü.', appBadMain: '{f}: Farb-Tama- und TG18-Firmware gehen als weiteres Programm nur im Startgerät. Sonst erst den Emulator oben mit × entfernen.', emuInList: 'Im ROM als weitere Programme: {n}. Nicht nochmals wählen.', doomLinkLess: ', mit DOOM {m} MB weniger', emuPack: 'Firmware packen', emuPackHint: 'Spart Platz (bei iD L rund 1 MB), dafür können manche Orte im Spiel langsamer laufen, zum Beispiel das Restaurant.', packNeed: 'Diese Firmware passt hier nur gepackt: in der Zeile von TamaEmu "Firmware packen" einschalten.', packTip: ' Tipp: bei TamaEmu "Firmware packen" einschalten spart Platz.', emuNfc: '4U: NFC-Chip nachbilden', emuNfcHint: 'Das Menü reagiert auf einen Druck. Ohne Haken wie bisher.', emuClock: 'Uhr beim Start vom Paradise übernehmen', emuClockHint: 'Bei jedem Start gilt die Zeit des Paradise. Die Zeit dazwischen wird nicht nachgespielt.', emuAuto: 'Beim Einschalten starten', emuAutoHint: 'Rad lange drücken: zurück ins Paradise, es bleibt dort. Wieder in den Emulator: A und C oder Reset-Knopf.', autoHintL: 'Startet beim Einschalten statt des Menüs. B beim Einschalten halten: Menü.', emuHas: 'In diesem ROM ist ein Emulator eingebaut.', emuBig: 'Diese Firmware ist gross: der Feldwechsel im Menü hat daneben keinen Platz.', emuUp: 'Beim Speichern kommt die neue Emulator-Version hinein. Mit "Spielstände behalten" bleibt der Spielstand.',
emuOk: 'Firmware erkannt ({size}). Sie wird beim Speichern eingebaut.', emuBad: 'Firmware nicht erkannt: {e}', t18Ok: 'TG18-Firmware erkannt (T18Emu, Meets/On). Sie wird beim Speichern eingebaut.', t18Has: 'In diesem ROM ist T18Emu eingebaut.', t18Use: 'Starten: auf dem Heimbildschirm A und C zusammen halten. Zurück: Rad lange drücken (speichert). Hängt T18Emu: mit A und C starten, loslassen, in den ersten 3 Sekunden das Rad drücken und mit A bestätigen. Dann startet die Firmware neu ab ihrem eigenen Spielstand. Experimentell: das Tama läuft noch langsamer als echt.',
emuGone: 'Emulator wird beim Speichern entfernt.', emuMissing: 'In dieser Ausgabe fehlt das Emulator-Programm.',
emuFail: 'Emulator nicht eingebaut: {e}', savedEmu: 'Gespeichert: {name}',
t18Pics: 'Bilder für Erwachsen', t18PicsPick: 'Bilder wählen', t18PicsDel: 'Bilder entfernen', t18PicsOk: '{n} Bilder übernommen.', t18PicsUnknown: '{f}: unbekannter Name', t18PicsHint: 'Am Gerät zeigt Erwachsen dann das Bild der Wahl. PNG-Dateien, Name = Figur (z.B. Mametchi.png, Kuchipatchi.png) oder ihre Nummer (16.png). Der Ordner erwachsen aus dem Android-T18Emu geht auch: alle Dateien samt erwachsen.json wählen. Jede Grösse, wird auf 64x64 verkleinert.', t18Items: 'Items', t18ItemsPick: 'MyMeets-Dateien wählen', t18ItemsNoSave: 'Items gehen, sobald das Spiel einmal gelaufen ist (ROM vom Gerät lesen).', t18ItemsHint: 'Items, Raum und Tamapoints kommen in den Spielstand des Spiels. Beim Schreiben ersetzt das den Spielstand von T18Emu auf dem Gerät, auch mit «Spielstände behalten». Das Tama bleibt, der laufende Stand fängt neu an.', t18ItemsNone: 'Keine Items in den Dateien gefunden.', t18ItemsOther: '{n} ist für {m}, nicht für die Meets/On. Ob es dort geht, ist nicht sicher.', t18ItemsFull: 'kein Platz mehr', mmTitle: 'MixingMeets (Besuch, Heirat)', uartBusy: 'Paramix Studio ist noch mit dem Dongle verbunden. So lange geht die Brücke nicht.', uartFree: 'UART freigeben', uartFreed: 'Dongle freigegeben. Das Paradise neu starten, damit das Spiel wieder läuft.', uartRun: 'Erst warten, bis das Gerät fertig ist.', pairTitle: 'Zwei Paradise verbinden (Besuch, Spiel)', pairHint: 'Beide Paradise oben zusammenstecken, an beiden T18Emu starten. Dann an beiden CONNECTION, TAMAGOTCHI und weiter wie bei zwei Tamas.', pairHintDigi: 'Beide Paradise oben zusammenstecken, an beiden V1Emu mit Digimon starten. Dann den Kampf wählen und starten wie bei zwei echten Digimon.', pairHintPs: 'Beide Paradise oben zusammenstecken, an beiden TamaEmu (P\'s) starten. Dann an beiden Verbindung, たまごっちP\'s, あそぶ. Am einen あそびにいく, am anderen ともだちをよぶ, ふたりで, ein Spiel, dann B.', pairHintIdl: 'Beide Paradise oben zusammenstecken, an beiden TamaEmu (iD L) starten. Dann an beiden die Verbindung im Spiel wählen wie bei zwei echten iD L.', pairHintV3: 'Beide Paradise oben zusammenstecken, an beiden V3Emu starten. Dann an beiden die Verbindung im Spiel wählen wie bei zwei echten V3.', pairHintT7: 'Beide Paradise oben zusammenstecken, an beiden T7Emu (Tama-Go) starten. Dann an beiden Verbindung, TAMA-GO, VISIT oder GAME. Am Gerät, das besuchen geht, B drücken.', mmLink: 'Paramix-Brücke', mmDrag: 'In die Lesezeichenleiste ziehen, dann auf mixing-meets.com anklicken.', mmHint: '1. Den Knopf Paramix-Brücke einmal in die Lesezeichenleiste ziehen (Chrome oder Edge).\n2. Paramix Studio vom Dongle trennen (UART freigeben oder das Studio schliessen). Dongle an die Kontakte wie beim Flashen. Am Tama: CONNECTION, APP, VISIT (zum Zurückholen: A drücken, GO BACK, YES).\n3. Auf mixing-meets.com Connect oder Return öffnen, das Lesezeichen anklicken, dann Select Tamagotchi und den Dongle wählen.\nNach jedem Seitenwechsel das Lesezeichen nochmals anklicken.', t7Gp: 'Gotchi Points', t7GpHint: 'Kommt wie ein eingespielter Spielstand ins ROM: das Tama bleibt, der laufende Stand fängt neu an (am Gerät DOWNLOAD wählen).', t18KeepAsk: 'T18Emu: Items oder Tamapoints geändert. Sein Spielstand auf dem Gerät wird durch den aus dem ROM ersetzt (Stand beim Auslesen), auch mit «Spielstände behalten». Weiter?', t18ItemNo: 'Nr. {n}', t18ItemOk: '{n} liegt jetzt bei {k}.', t18Points: 'Tamapoints', t18A_food: 'Essen', t18A_item: 'Gegenstände', t18A_acc: 'Accessoires', t18A_room: 'Raum', t18RoomBack: 'eigener Raum weg', t18RoomBuiltin: 'eingebauter Raum', dlcPick: 'Download-Inhalte hinzufügen', dlcInfo: 'Belegte Plätze zeigen', progMore: 'Einstellungen und Inhalt', progMakeMain: 'Zum Hauptprogramm machen', progIsMain: 'Hauptprogramm', v1Ok: 'Erstes Tamagotchi oder Digimon erkannt (V1Emu).', v3Ok: 'Tamagotchi Connection V3 erkannt (V3Emu).', v3Use: 'Starten: auf dem Heimbildschirm A und C zusammen halten. Rad kurz: Einstellungen. Zurück: Rad lange drücken.', optVol: 'Lautstärke', optVolN: 'normal', optVolQ: 'leise', optVolL: 'laut', optOff: 'aus', optDim: 'Helligkeit', optScr: 'Bild aus nach', optDev: 'Auch am Gerät: Rad kurz drücken. Dort Geändertes gilt, bis du es hier wieder änderst.', optScrToy: 'wie am Tama', v1Use: 'Starten: auf dem Heimbildschirm A und C zusammen halten. Rad kurz: Einstellungen. Rad drehen: schütteln. Zurück: Rad lange drücken.', progNoMainDoom: 'DOOM ist das Hauptprogramm. Für ein anderes zuerst DOOM entfernen (×).', doomAutoHint: 'Rad 2 s drücken: zurück ins Paradise, es bleibt dort.', progReplaced: '{n} ist jetzt das Hauptprogramm statt {o}.', mainAuto: '{n} ist jetzt der erste Eintrag im Menü, nur so passt alles.', mainNoRoom: 'Als erster Eintrag fehlen etwa {k} KB Platz. Es bleibt wie es war.', appTwice: '{n} ist schon dabei.', progNoMainV1: 'V1Emu startet nur aus dem Menü', progNoMain: 'Geht nur im Startgerät', progMainNow: '{n} ist jetzt das Hauptprogramm. Die Spielstände der getauschten Programme fangen neu an.', dlcLoading: 'Wird gelesen…', dlcNewArea: 'Der Speicher dieses Emulators wird dafür neu eingeteilt. Sein Spielstand fängt nach dem Schreiben neu an.', dlcHint: 'Essen, Kleider, Accessoires, Spiele usw. als .jpg-Download-Dateien oder .zip. Mehrere Dateien auf einmal gehen, bei P\'s einen VDP-Satz immer ganz.', dlcFreeN: '{n} frei', dlcDel: 'entfernen', dlcK0: 'Mahlzeiten', dlcK1: 'Snacks', dlcK2: 'Kleider', dlcK3: 'Accessoires', dlcK4: 'Gegenstände', dlcK5: 'Alltagsdinge', dlcK6: 'Hintergründe', dlcK7: 'Spiele', dlcK8: 'Ausflugsziele', dlcK10: 'VDP-Rezepte', dlcK15: 'Dekorationen', dlcK16: 'Gutscheine', dlcK17: 'Bingo', dlcK18: 'Gashapon', dlcK19: 'Figuren', dlcOk: '{n} liegt jetzt in {k}, Platz {s}.', dlcBad: '{f}: {e}', dlcGone: '{n} entfernt.',
figField: 'Feld:', figAll: 'alle', zipField: 'Feld als ZIP', fieldZipOk: '{f}: {n} Figuren und {s} Bilder als ZIP.', fieldIn: 'Feld aus ZIP übernehmen', fieldInBad: 'Kein Feld-ZIP (field.json fehlt).', fieldInOk: '{src} in {dst} übernommen: {n} Teile.', fieldInEyes: '{k} Figuren bleiben original, ihre Augenbilder sind hier zu gross.',
zipFigs: 'Alle Figuren als ZIP', zipAll: 'Alle Sprites als ZIP', upload: 'Sheets hochladen (PNG oder ZIP)',
numbers: 'Nummern-Test-ROM',
figHint: 'Eine Figur besteht aus Körper, Augen und Mund, je gross und klein. Klick auf eine Figur für ihr Sheet.',
allHint: 'Hintergründe, Menüs, Gegenstände, Schriften.',
moreColors: 'Mehr Farben erlauben (bis 256)',
dimLoad: 'Karte laden', dimHint: 'Abbild einer Figurenkarte (4 MB) oder einer TamaSma-Karte (1 oder 2 MB). Kartenfiguren ersetzen am besten Erwachsene. Baby, Kind und Teen teilen sich die Augen und bleiben original.',
dimPick: 'Kartenfigur', dimTarget: 'ersetzt Figur', dimApply: 'Einsetzen', dimEgg: 'Ei der Karte einsetzen',
dimBaby: 'Baby', dimNone: 'Lade eine Karte, um ihre Figuren zu sehen.',
download: 'Sheet herunterladen', uploadOne: 'Sheet hochladen', reset: 'Original wiederherstellen', close: 'Schliessen',
working: 'Einen Moment …',
dimNr: 'Nr.', stUpd: 'wird aktualisiert',
disclaimer: 'Benutzung auf eigene Gefahr. Das Ändern und Beschreiben des Geräts kann es unbrauchbar machen oder Spielstände löschen. Lies vorher ein Backup aus und nutze das Tool nur, wenn du weisst, was du tust. Es gibt keine Garantie und keine Haftung für Schäden an Geräten oder Daten.',
trademarks: 'Tamagotchi und Digimon sind Marken von BANDAI. DOOM und Wolfenstein sind Marken von id Software (ZeniMax Media). Game Boy und Pokémon mini sind Marken von Nintendo, SEGA und Master System sind Marken von SEGA. Arduboy ist eine Marke von Arduboy Inc. Alle Marken, Spiele und Figuren gehören ihren jeweiligen Inhabern und werden nur genannt, um zu beschreiben, wofür das Tool gedacht ist. Kein offizielles Produkt, keine Verbindung zu diesen Firmen. Das Tool enthält keine Spiele, Firmware oder Spieldaten: du verwendest nur deine eigenen Dateien.',
devWarn: 'Schreiben auf das Gerät geschieht auf eigene Gefahr und ohne Haftung. Vorher ein Backup auslesen und das Gerät während des Schreibens eingeschaltet lassen.',
footer: 'Läuft lokal im Browser. Von mameise.',
edition: 'Edition', sprites: 'Sprites', figures: 'Figuren', changed: 'geändert', space: 'Platz für Figuren',
figure: 'Figur', sprite: 'Sprite',
mSize: 'Zelle {w}×{h}, {n} Bilder, Raster {iw}×{ih}', mColors: '{c}, Palettensätze: {p}',
mDirect: 'Direktfarbe RGB565', mPal: '{n} Farben', mKeep: 'Mehrere Palettensätze (Farbvarianten): beim Hochladen werden die Originalfarben benutzt.',
mSheet: 'Sheet {w}×{h} px. Grösse nicht ändern, sonst passt das Raster nicht mehr.',
mGroupRows: 'Zeilen: Körper (20), Augen (20), Mund (18), Körper klein (24), Augen klein (14), Mund klein (14).',
notRom: 'Das ist kein Paradise-Abbild: {e}', loaded: '{ed} geladen: {s} Sprites, {f} Figuren.',
saved: 'Gespeichert: {name}\n{n} Sprites geändert, noch {kb} KB frei.', nothing: 'Noch nichts geändert.',
tooBig: 'Zu gross für den freien Platz. {e}',
upOk: 'Übernommen: {n}', upSkip: 'Übersprungen: {list}', upNone: 'Keine passenden Dateien gefunden. Erwartet: figur_0237.png oder sprite_0014.png.', sprSix: 'Feldbild der zusätzlichen Felder, nicht änderbar.',
wrongSize: '{f}: {e}', resetOk: 'Original wiederhergestellt.', dimOk: 'Kartenfigur {d} sitzt jetzt in Figur {g}.', eggOk: 'Ei ersetzt.',
numOk: 'Jede Figur zeigt jetzt ihre Nummer. Speichern, aufspielen, aufziehen und notieren, welche Nummer in welcher Stufe kommt.',
notDim: 'Diese Karte kenne ich nicht: {e}', leave: 'Es gibt ungespeicherte Änderungen.',
roleFallback: 'Ersatzfigur', roleBaby: 'Baby', roleAdult: 'erster Erwachsener',
eyeHint: 'Pinker Rahmen = Auge. Es wandert in die Augenebene, damit die Figur blinzelt und die Zelle Augen hat. Falsch? Aufs Auge klicken.',
eyeNone: 'Figur hat keine sichtbaren Augen', dimEyesTooBig: 'Die Augen waren zu detailreich, die Figur bleibt ohne Augenebene.',
roleFallbackText: 'erscheint, wenn das Spiel eine Figur nicht laden kann. Am besten unverändert lassen.',
roleBabyText: 'schlüpft aus dem Ei.', roleAdultText: 'ab hier hat jede Figur eigene Augen.',
mEyes: 'Augen behalten ihre Bytegrösse, sonst schlüpft die Ersatzfigur. Zu detailreiche Augen werden abgelehnt.',
mColorsFig: 'Bleiben alle Farben aus dem Original, färbt das Spiel die Figur weiter je nach Tama um. Neue Farben werden fest (bis 8 Farben plus Umriss).',
},
en: {
open: 'Open ROM', save: 'Save new ROM',
startTitle: 'Get more out of your Tamagotchi Paradise',
startText: 'Paramix Studio rebuilds your own Paradise ROM. Load your Paradise dump (16 MB flash image) or read it straight from the device, pick what to add, and write the new ROM back.',
featHead: 'What you can do',
g1t: 'Tamagotchi emulators', g1: 'Colour tamas (iD, iD L, Plus Color, P\'s, 4U, 4U+), Tama-Go with figures, Friends, Meets and On, Connection V3, P1, P2, Angel and more first Tamagotchis plus Digimon V1 and V2. Several together in the menu, each with its own save. Bring your own ROMs.',
g2t: 'DOOM and Wolfenstein 3D', g2: 'DOOM, Wolfenstein 3D and Spear of Destiny on the Paradise, with your own key layout. Bring your own game files.',
g7t: 'Game consoles', g7: 'Game Boy, Game Boy Color, Master System, Game Gear, Pokémon mini and Arduboy, with sound and saves. Your own games go into the menu.',
g3t: 'All fields', g3: 'All six fields in one ROM, with pictures, special characters, the matching planet and the field\'s lab games.',
g4t: 'Menu on the device', g4: 'Switch fields, put items in the bag, set Tamapoints, change the Tama and keep several saves, right on the Paradise. Play time in the games earns Tamapoints.',
g8t: 'Start device without the Paradise', g8: 'Almost the whole 16 MB for emulators and games. Any program can start first, the clock is set in the menu.',
g5t: 'Read and write the device', g5: 'Back up the ROM and write the new one with a USB UART dongle. Saves are kept, only changes are written. A write protection helps when writing is cut off.',
g6t: 'Your own characters', g6: 'Every character as an image sheet to edit, Digimon from DIM cards too. Colours and eyes are fitted automatically.',
g9t: 'Saves and visits', g9: 'Back up, restore and edit saves, add download content. Visits between two Paradise through the plug at the top, or a simulated visit over the dongle.',
dropTitle: 'Drop a ROM here or click',
dropText: 'Land, Water, Sky, Jade Forest, Tropical and Glacier are recognised.',
f1t: 'Editing and backups', f1: 'Files are edited locally. Reading a full ROM privately backs up missing editions on the server before downloading to your PC. One per edition; publication requires administrator approval.',
f2t: 'Nothing borrowed inside', f2: 'Paramix Studio contains no ROM, no firmware and no WAD. Everything comes from your own devices and files.',
f3t: 'Checked', f3: 'Checksums are recalculated, changed images are read back before saving and every sector written to the device is verified.',
planTitle: 'Your new ROM', planFig: 'Characters', planEmu: 'Emulator', planEmus: 'Emulators', planDoom: 'DOOM', planWolf: 'Wolfenstein 3D', planGb: 'Game Boy', planSms: 'Master System / Game Gear', planPm: 'Pokémon mini', planMenu: 'Menu', planApps: 'More emulators',
stNone: 'not included', stKeep: 'stays', stNew: 'new', stDel: 'will be removed', stChanged: '{n} changed', stSame: 'unchanged',
segFw: 'Firmware and characters', segEmu: 'Emulator', segDoom: 'DOOM', segWolf: 'Wolfenstein 3D', segGb: 'Game Boy', segSms: 'Master System / Game Gear', segPm: 'Pokémon mini', segSlots: 'Field saves', segSave: 'Save', segFree: 'free', segResv: 'reserved',
ruleBoth: 'Emulator or DOOM: only one of the two fits into the ROM. The menu works with both.',
ruleNoRoom: 'This edition has no room for emulator and DOOM (its character data is larger). The menu works.',
emuVsDoom: 'Note: DOOM is chosen or built in. Choosing a firmware here drops DOOM.',
doomVsEmu: 'Note: an emulator is chosen or built in. Choosing a WAD here drops the emulator.',
noRoomApp: 'This edition has no room for it.', a0Menu: 'This edition has no room for a main program at 0x0A0000: every program goes to the menu. The star chooses what starts when switched on.', a0MenuN: 'This edition has no room for a main program at 0x0A0000. Tama-Go, Friends, the old Tamas and the V3 go to the menu (A and C; switch on field switch or items in the Menu tab). Colour Tamas and TG18 work here in a start device only.', a0NoMain: '{f}: colour Tamas and TG18 work in this edition in a start device only (Menu tab).',
doomHas: 'This ROM contains DOOM.', doomOff: 'Remove DOOM', doomGone: 'DOOM is removed on save.',
keysTitle: 'Buttons', kFire: 'Fire', kFwd: 'Forward', kBack: 'Back', kUse: 'Use', kMod: 'Change weapon: hold + wheel',
kWheel: 'Wheel press', kRun: 'Run with 2x forward', kInv: 'Wheel reversed', kFixed: 'Always the same: A+C menu, B+C map. Sound on/off: hold the "Change weapon" key and press the wheel briefly. Back: as set in the Menu tab under "Back from programs".',
kOld: 'This DOOM is older and has no own button layout yet. Build it in again with the WAD.',
help: 'Help', helpTitle: 'How it works', h1t: 'Steps', h1: '1. Open a ROM (file of your own Paradise) or read it straight from the device with "Device".\n2. Choose in the tabs what goes in: figures, emulators, Game Boy, Master System, Pokémon mini, DOOM, Wolfenstein, menu.\n3. Save, or write it to the Paradise with "Device". With "Keep saves" the save on the device stays.', h2t: 'Buttons on the Paradise', hk1: 'A and C', hv1: 'on the home screen: start the menu or the emulator', hk2: 'Wheel long (tab Menu: can be changed)', hv2: 'save the state and go back to the Paradise', hk3: 'Wheel short', hv3: 'T7Emu: settings and figure', hk4: 'Wheel in the first 3 s', hv4: 'drop the saved state (confirm with A), the next start begins fresh from the Tama\'s own save', hk5: 'B when switching on', hv5: 'with autostart: Paradise or menu instead of the main program', hk6: 'Reset button', hv6: 'with autostart: the main program starts again', hk7: 'C when switching on', hv7: 'flash app: the device can be written again with "Device" (way back)', h3t: 'Clock', h3: 'With "Take the clock from the Paradise at the start" (tab Emulator) the emulator sets its clock to the Paradise\'s time at every start. The time in between is not played through. So set the clock on the Paradise.', h4t: 'Coming back', h4: 'The emulator continues exactly where you left with the wheel. The Tama\'s own save stays even when the saved state is dropped.', h5t: 'Menu and fields', h5: 'A and C on the home screen. The wheel selects, B confirms, C goes back. Switching the field packs the save of the old field and brings back the one of the new field.\n6 fields: Tropical and Glacier get Land, Water and Sky from your own ROM, Jade Forest gets Sky. In the game the Tama moves through Planet, Fields. DNA and residents belong to their field.', h8t: 'Start device', h8: 'Tab Menu, start device: the device starts into the menu with all programs. Without the Paradise almost the whole memory is for programs, the clock is set in the menu. The star picks the main program, with autostart it starts when switching on.', h9t: 'Way back', h9: 'If the screen stays black or a program hangs: hold C and put the batteries in (or press the reset button). The flash app starts, the device can be read and written again with "Device". If a write is cut off, the flash app starts by itself.', h6t: 'Backing up saves', h7t: 'Importing a save', h7: '1. Read the ROM fresh with "Device" (or open the one you read last).\n2. Tab Save: import. The save goes to the program it belongs to.\n3. Write to the device with "Keep saves". Only this save is replaced, the Paradise save and those of the other programs stay as on the device.\nWithout "Keep saves" every save comes from the file. Add or remove programs in a write of its own, back up all saves first.', h6: 'Tab Save, or Device, "Back up save". Back up before changing the emulator, the old save is lost then.', device: 'Device', devTitle: 'Device over UART', devHint: 'UART dongle with 3.3 V on the three contacts: left RX from the dongle, middle GND, right TX from the dongle. Open the download screen on the Paradise (Planet, A, Connect, Download, Download), then Connect. Needs Chrome or Edge on a computer.',
devConnect: 'Connect', devDump: 'Back up ROM, then download', devWrite: 'Write new ROM to the device', devOnly: 'Only write changes', devKeep: 'Keep saves', devStop: 'Cancel',
devNoSerial: 'This browser cannot talk to the dongle. Please use Chrome or Edge on a computer.', devNone: 'Not connected.',
fl_noRescueRoom: 'No room for the write protection (rescue start, top 64 KB of the flash). Nothing was written. Remove a program from the start device and write again.', plHint: 'Prolific adapter (PL2303): newer Windows drivers block older and copied PL2303 chips, then no data gets through. Fix: pick the older Prolific driver 3.3.2.x in the Device Manager, or use an adapter with CH340 or CP2102.', resOn: 'Write protection on: if a write is cut off, the device starts in the flash screen.', resModeGo: 'The last write was cut off. The device is in the flash screen and waits. Press "Continue writing".', resModeRom: 'The last write was cut off. The device is in the flash screen and waits. Open the ROM again (or your backup) and write it to the device.', resResume: 'Continue writing', resHalf: 'The last write did not finish. Press "Continue writing" so everything fits together again.', resResumed: 'Done: {w} sectors written. Switch the Paradise off and on.', resTest: 'Test rescue start', resBack: 'Write header back', resSure: 'Test: the rescue start goes to 0xFF0000, then the device header (sector 0) is cleared. Then switch the Paradise off and on. If the flash screen appears, connect here and "Write header back". If it does not, the device will not start without your own flash tool. Go on?', resCleared: 'Header cleared. Switch the Paradise off and on. Flash screen there? Then connect and "Write header back".', resBackDone: 'Header written back. Switch the Paradise off and on: it starts normally again.', resNoHdr: 'No header kept.', devOn: 'Connected: {ed}, {mb} MB{l}', devLoaded: ', flash app loaded', devReady: 'Ready.', devNeedRom: 'To write, open a ROM first (or read one).',
visTitle: 'Simulate a visit (Paradise)', visStart: 'Start', visStop: 'Stop',
visHint: 'The Studio plays a second Paradise. Dongle on the contacts, the Paradise runs normally.\n1. Choose the edition, Start, choose the dongle.\n2. On the Paradise: planet menu, CONNECTION, PLAYDATE, then B.\n"Connect" above is only for the ROM, do not press it for a visit.',
visWait: 'Ready as {ed}. On the Paradise choose PLAYDATE and press B.', visRun: 'Connected, exchanging data…', visPlay: 'The two are playing…',
visDone: 'Visit done ({ed}). For the next one press B on the Paradise again.', visErr: 'Stopped: {e}. Press B on the Paradise again.', visBadKey: 'The Paradise does not understand the data.',
phload: 'Loading flash app', phread: 'Reading', phcompare: 'Comparing', phwrite: 'Writing', phcheck: 'Checking', phprepare: 'Preparing',
devDumped: 'ROM read and saved as {n}. It is now open in the Studio.',
devSure: 'The new ROM is written to the device now. Keep the device switched on while writing. Write at your own risk?',
devSureFull: 'Without "Keep saves" the save on the device is replaced by the one in the ROM. Write anyway?',
carryUnknown: 'The device does not hold the loaded ROM. A program moves and its save on the device cannot be taken along. Read the ROM from the device first. Write anyway?', carryMiss: 'A program moves and its save on the device cannot be taken along. Back it up in the tab Save first. Write anyway?', devEmuLost: 'Main program on the device: {o}. In the new ROM: {n}. So the save of {o} as the main program starts anew. To keep it, back it up first under "Save". Write anyway?', devEmuNone: 'no emulator', devEmuNew: '{o} with a newly chosen firmware',
devDone: 'Done and checked: {w} sectors written{k}. Restart the device (reset or battery).', devKept: ', {k} save sectors kept',
devSame: 'Nothing to write, the device already has this ROM.', devErr: 'Error: {e}', devCancelled: 'Cancelled.',
cleanOn: 'Without the Paradise (clean ROM)', cleanClock: 'Set the clock at the start', cleanClockHint: 'When the clock is missing (new batteries), the menu asks for it when switched on. Without: set the clock in the menu under SETTINGS or in each emulator itself.', emuClockOff: 'Only with "Set the clock at the start" (tab Menu).', emuSess: 'Remember where you left off', emuSessHint: 'The next start continues right there. Without: the game starts anew and loads its own save, as the real device does.', ruleClean: 'Without the Paradise: all programs go to the menu, almost the whole flash is theirs.', cleanHint: 'No Paradise on the device any more, only the menu with your programs. Almost the whole 16 MB is free.', cleanUse: 'After switching on the menu comes up right away. On the first start you set the clock, later under SETTINGS. Leave a program as usual.', cleanWarn: 'The Paradise and its save are lost when writing. Make a backup first.', cleanNoDoom: 'DOOM does not work without the Paradise yet. Please remove DOOM.', doomOne: 'DOOM goes into the menu only once.', cleanSure: 'The device has the Paradise on it. It is deleted, with its save. Do you have a backup of the device? Go on?', cleanLoaded: 'ROM without the Paradise ({ed}) loaded: {n} programs.',
launchOn: 'Start device for programs only', launchHint: 'Only the setup of the Paradise stays (language, clock, continue or new). After it the menu with your emulators and DOOM always comes up. All pictures of the game go, which gives about 5 MB more room.', launchUse: 'After switching on and setting the clock the menu comes up. Wheel selects, B starts. Leave a program as usual, then the menu comes up again.', launchOld: 'This ROM is a start device. Load the original ROM for a normal Paradise.', launchNeed: 'A start device needs at least one program (emulator or DOOM).', launchSix: 'A start device does not go with six fields built in. Please load the original ROM.', planLaunch: 'Start device',
tabFeld: 'Menu', feldOn: 'Several saves (with field choice)', bagOn: 'Items and Tamapoints', tamaOn: 'Change Tama (level, care, character)', gplayOn: 'Play time earns Tamapoints', gplayHint: 'DOOM, Wolfenstein, Game Boy, Master System, Pokémon mini and Arduboy: 10 Tamapoints per minute of play, when going back to the Paradise.', saveSlot: 'Save {n}',
sixOn: 'All 6 fields', sixPick: 'Choose Land, Water or Sky ROM', sixHint: 'Adds Land, Water and Sky to Tropical and Glacier. The field pictures come from your own Land, Water or Sky ROM. The lab games follow the field the Tama starts with in the menu.',
sixNeed: 'All 6 fields still need a Land, Water or Sky ROM.', sixOk: 'Field pictures taken from {n}.', sixBad: '{n} is not a Land, Water or Sky ROM.', sixIn: 'All 6 fields are built in.', sixOff: 'Saving takes Land, Water and Sky out again. Several saves keep working.', sixOffJ: 'Saving takes Sky out again. Several saves keep working.', sixOffField: 'The device is on {f} now. First switch to {s} in the menu.', sixOffSlots: 'The saves stored in the menu are deleted. Continue?', sixFail: 'Fields not built in: {e}', sixNoFw: 'The firmware of this ROM is changed, more fields do not work here.', planSix: 'More fields', sixOnJ: 'Sky as 4th field', sixHintJ: 'Jade Forest already has the Sky pictures.', sixInJ: 'Sky is built in as the 4th field.', sixOld: 'All 6 fields are built in, but an older version. Choose your Land, Water or Sky ROM and everything is updated when you save.', sixOldJ: 'Sky is built in and is updated when you save.', sixPlanet: 'Planet to match the field', sixMenu: 'Game menu Fields: all fields from level 4', sixPlanetNeed: 'Changing this setting needs your Land, Water or Sky ROM again.', sixApp: 'DOOM and the emulator do not fit with it',
exitKey: 'Back from programs', exitHint: 'How to get from all programs (emulators and games) back to the Paradise or the menu.', exit0: 'Hold the wheel', exit1: 'Hold wheel and A', exit2: 'Hold wheel and C', exit3: 'Hold the wheel 5 s', feldHint: 'Small menu in the ROM: switch between saves (a new save on a field of your choice), put items in the bag, set Tamapoints, change the Tama.',
feldUse: 'Open: hold A and C together on the home screen. Wheel selects, B confirms, C goes back.',
feldNo: 'Field switch works with Land, Water, Sky (among each other) and Tropical, Glacier (among each other).', feldMissing: 'This build does not contain the menu.',
feldCur: 'Active field: {f}.', feldList: 'Selectable: {s}.', feldStored: 'Saved: {s}.', feldFail: 'Menu not built in: {e}', feldUnknown: 'Edition not recognised.',
tabWolf: 'Wolf3D', wolfPick: 'Choose game files', wolfHint: 'Choose all files of Wolfenstein 3D together: shareware (.WL1), full version (.WL6) or Spear of Destiny (.SOD). The game goes into the Paramix menu.', wolfNone: 'No game files chosen yet.', wolfShare: 'Shareware', wolfFull: 'Full version', wolfEps: '{n} episodes', wolfEp1: '1 episode', wolfBad: 'Wolfenstein 3D: {e}', wolfNoMain: 'Wolfenstein 3D only in the menu', wolfTurn: 'Turn per wheel step', wolfFixed: 'Always the same: A+C menu. Back (the game is saved): as set in the Menu tab under "Back from programs".', wolfOne: 'There is only one Wolfenstein 3D and one Spear of Destiny in the menu, the new one replaces the old one.', wolfSodN: '21 floors',
tabGb: 'Game Boy / Color', gbNoMain: 'Game Boy only in the menu', gbPick: 'Choose games (.gb, .gbc)', gbHint: 'The games go into the Paramix menu. On the device: A+B+C together opens the settings (also Select and sound). Hold the wheel for 2 s to save and go back, the next start continues there. Two Paradise plugged together at the top work like a link cable, e.g. to trade Pokémon.', gbNone2: 'No game chosen yet.', gbKeysTitle: 'Keys', gbKeysDef: 'Default', gbKeysMiss: 'Not assigned: {n}', gbNone: '–', gbRight: 'Right', gbLeft: 'Left', gbUp: 'Up', gbDown: 'Down', gbInA: 'Key A', gbInB: 'Key B', gbInC: 'Key C', gbInWp: 'Wheel press', gbInWu: 'Wheel up', gbInWd: 'Wheel down', gbInAC: 'A + C', gbInBC: 'B + C', gbInAB: 'A + B', gbBad: '{f}: not a Game Boy game', gbColor: '{f}: Game Boy Color only, that does not work', gbNeedRom: 'Open a ROM first (or read it from the device).', t7Old: '{n}: old version, the save can be lost when the battery is changed. Write it again now with "Keep saves".', t18Broken: 'Tama Meets is damaged. Remove Tama Meets and add the firmware again, then write without "Keep saves".', t18Clash: 'the main program would need the room of Tama Meets. Remove Tama Meets first.', tabSms: 'Master System / Game Gear', tabPm: 'Pokémon mini', smsNoMain: 'Master System and Game Gear only in the menu', pmNoMain: 'Pokémon mini only in the menu', abNoMain: 'Arduboy only in the menu', planAb: 'Arduboy', segAb: 'Arduboy', tabAb: 'Arduboy', abPick: 'Choose games (.hex, .zip)', abHint: 'The games go into the Paramix menu. On the device: A+B+C together opens the settings (also picture size and sound). Hold the wheel for 2 s to save and go back, the next start continues there.', abBad: '{f}: not an Arduboy game', abBig: '{f}: too big for the Arduboy', smsPick: 'Choose games (.sms, .gg)', smsHint: 'The games go into the Paramix menu. On the device: A+B+C together opens the settings (also Pause and sound). Hold the wheel for 2 s to save and go back, the next start continues there.', smsBad: '{f}: not a Master System or Game Gear game', smsGG: '{f}: Game Gear game, that does not work', smsB1: 'Button 1', smsB2: 'Button 2', smsPause: 'Pause / Start', pmPick: 'Choose games (.min, .zip)', pmHint: 'The games go into the Paramix menu. On the device: A+B+C together opens the settings (also Power and sound). Hold the wheel for 2 s to save and go back, the next start continues there.', pmBad: '{f}: not a Pokémon mini game', pmBig: '{f}: bigger than 1 MB, that does not work', pmBiosPick: 'Choose own BIOS', pmBiosDel: 'Remove own BIOS', pmBiosFree: 'Without an own BIOS the free BIOS of PokeMini runs. Some games run better with the real BIOS.', pmBiosOwn: 'Own BIOS chosen, it is used for all Pokémon mini games.', pmBiosBad: '{f}: not a Pokémon mini BIOS', pmA: 'A', pmB: 'B', pmC: 'C', pmPower: 'Power', pmShake: 'Shake',
tabFigs: 'Characters', tabAll: 'All sprites', tabDim: 'Card', tabEmu: 'Emulator', tabDoom: 'DOOM',
doomPick: 'Choose DOOM.WAD', doomEp: 'Episode', doomMusic: 'Music',
doomHint: 'Builds DOOM into the ROM. Bring your own WAD, it stays on your computer.',
doomUse: 'Start: in the Paramix menu, with the Paradise also by holding A and C together on the home screen. Back: as set in the Menu tab under "Back from programs".',
doomNone: 'No WAD chosen.', doomOk: 'WAD recognised ({eps}). DOOM is built in on save.', doomEpsHint: 'Without the Paradise: each ticked episode goes into the menu as its own entry (DOOM E1, DOOM E2 ...), with its own save.', doomWhole: 'Whole WAD as one entry', pwadPick: 'Choose extra WAD', pwadOff: 'Remove extra WADs', doomPwads: 'With: {n}.', pwadNeedD2: '{n} is for DOOM II: choose DOOM2.WAD first.', pwadNeedD1: '{n} is for DOOM or Ultimate DOOM: choose DOOM.WAD first.', doomPwadPara: 'Own episodes (like Sigil) only go without the Paradise.', doomPwadBig: '{n}: the maps {m} are probably too big for the Paradise\'s memory. DOOM then shows a line with a 9, holding the wheel 2 s goes back to the menu.', doomPwadHint: 'Own episodes (like Sigil) go into the menu as their own entry, tick them for that. Together with the whole WAD they are mostly too big.', doomD2Clean: 'DOOM II only goes into a ROM without the Paradise.', doomD2Hint: 'DOOM II goes into the menu as one entry. It needs almost all the room and only fits without music.', doomWholeHint: 'All episodes in one entry "DOOM", the episode is chosen in the game. Needs much less room than one by one.',
doomBad: 'WAD not recognised: {e}', doomFail: 'DOOM not built in: {e}', doomMissing: 'This build does not contain the DOOM program.',
doomBoth: 'Emulator and DOOM do not fit into one ROM together. Please choose only one.',
doomBig: 'No episode of this WAD fits into the ROM.', doomNoMusic: 'This episode only fits without music.',
emuPick: 'Choose firmware or ROM', emuOff: 'Remove emulator',
emuHint: 'Colour tamas (TamaEmu), Tama-Go and Friends (T7Emu), Meets and On (T18Emu), first Tamagotchis and Digimon (V1Emu), Connection V3 (V3Emu). The first is the main program, every further one goes to the menu. The filled star marks the main program, a click on an empty star makes another one the main program. Bring your own files.', t7Ok: 'V7 ROM recognised (T7Emu). It is built in on save.', t7OkFr: 'Tamagotchi Friends recognised (T7Emu, test). It is built in on save. There are no figures for it.', t7Has: 'This ROM contains T7Emu.', t7HasFr: 'This ROM contains T7Emu with Tamagotchi Friends.', t7Use: 'Start: hold A and C together on the home screen. Back: hold the wheel (saves). Wheel short: settings and figure. If T7Emu hangs: start with A and C, release them and press the wheel within the first 3 seconds and confirm with A.', t7FigPick: 'Add figures', t7FigNone: 'No figures yet.', t7FigBad: '{f}: not a figure.', t7FigFull: 'No room left for {f}.', t7FigMax: 'No room for more figures.', t7FigDup: '{f} is already in.', appPick: 'Add another emulator', appHint: 'One more Tama-Go or Friends ROM (T7Emu). Started from the menu (A and C), so something in the Menu tab must be switched on.', appNone: 'No other emulators.', appBad: '{f}: not a Tama-Go or Friends ROM.', appBadL: '{f}: neither a Tama-Go or Friends ROM nor a colour Tama or TG18 firmware.', appT18One: 'T18Emu goes only once per ROM.', appHintL: 'In a start device: Tama-Go or Friends ROM, colour Tama firmware (TamaEmu) or TG18 firmware (T18Emu, once only).', ruleLaunch: 'Start device: emulators and DOOM fit together as long as there is room.', appMax: 'At most 12 more emulators.', appNeedMenu: 'More emulators start from the menu: switch on the field switch or items in the Menu tab.', appFail: 'More emulators: {e}', appSix: 'Six fields do not go together with more emulators.', t7SaveBtn: 'T7Emu save (.bin)', saveFor: 'Program', saveMain: 'Main emulator', v1SaveBtn: 'V1Emu save (.bin)', saveT18No: 'T18Emu: backing up its save is not possible here yet.', saveNoBatt: 'This game keeps no save on its cartridge.', saveNone: 'No save yet.', saveWrongFile: 'This file does not fit {n}.', saveCartIn: 'Save for {n} taken over. Now save the ROM or write it to the device. A kept game state is dropped.', t7SaveXDone: 'Save for {n} taken over. Now save the ROM or write it to the device.', t7NoSave: 'The Tama has no save yet.', t7SaveInDone: 'T7Emu save taken over. Now save the ROM or write it to the device.', t7SaveNeed: 'T7Emu is missing in the ROM: add the Tama-Go ROM in the Emulator tab first.', saveT18Need: 'T18Emu is missing in the ROM: add the TG18 firmware in the Emulator tab first.', saveEmuAny: 'Emulator save (.sav / .bin)',
emuUse: 'Start: hold A and C together on the home screen. Back: hold the wheel (saves). If TamaEmu hangs: start with A and C, release them and press the wheel within the first 3 seconds and confirm with A. It then starts over from the save the Tama keeps itself.',
emuNone: 'No emulator chosen.', petT: 'Change save', petOpen: 'Open Paradise save', petRom: 'Save in the ROM', petClose: 'Close', petRomDone: 'Changed in the ROM. Now save the ROM or write it to the device (without "Keep saves", otherwise the device keeps its save).', petLevel: 'Level', petChar: 'Tama', petCare: 'Fed, happy, healthy', petSave: 'Save changed save', petKeep: 'unchanged', petKid: 'Kid', petYoung: 'Teen', petAdult: 'Adult', petNow: 'In the save: level {l}, Tama {c}, hunger {h}/6, happiness {j}/20{s}.', petSick: ', sick', petOther: 'The save is for another edition than the loaded ROM.', petNoSet: 'The settings block is missing in the save.', petDone: '{n} saved. Send it with "Save to device".', petNothing: 'Nothing changed.', tabSave: 'Save', tabNames: 'Names', cardNoChars: 'no characters on this card', noRoomFrag: 'Does not fit together: there would be enough room in total, but not in one piece (the DOOM WAD needs one big piece). Remove a program or build DOOM without music.', noRoomKB: 'Not enough room: about {k} KB missing. Remove a program. (The top 64 KB stay free for the write protection.)', noRoomAdd: 'No room left for {n}: about {k} KB missing. (The top 64 KB stay free for the write protection.)', eyeMvT: 'Move the eyes', mouthMvT: 'Move the mouth', poseNr: 'Pose {i} of {n}', faceBig: 'Big', faceSmall: 'Small', poseOnly: 'This pose only', poseOnlyHint: 'The arrows move eyes or mouth only in the pose shown. For your own figures where single poses do not fit.', eyeMvHint: 'Applies on the field to Tamas that hatch or grow after writing. The small figure moves half as far.', planEyes: 'Eyes and mouth', namesHint: 'Change names: capitals, digits, space and . & \' ! ? /. Applies to every language with Latin letters on the device.', namesFields: 'Fields', namesChars: 'Tamas', namesItems: 'Items', namesFind: 'Search', namesUndo: 'Reset all', planNames: 'Names', planNamesN: '{n} changed', saveParaOut: 'Paradise save (.tamasave)', saveEmuOut: 'TamaEmu save (.sav)', saveInfo: 'Export takes the saves out of this ROM. An emulator save (TamaEmu .sav or T7Emu .bin) goes into the ROM, then save the ROM or write it to the device. A Paradise save goes straight to the device, connect it above for that.', saveOutT: 'Export', saveInT: 'Import', saveSecProg: 'Programs', saveSecPara: 'Paradise', saveParaOutB: 'Export (.tamasave)', saveParaInB: 'Write to device (.tamasave)', saveProgInfo: 'Export takes the save of the chosen program out of this ROM. Import puts it into the ROM, then save the ROM or write it to the device.', saveParaInfo: 'Export takes the Paradise save out of this ROM. Write to device goes straight to the device, connect it above for that. Slot: which save.', saveSlotL: 'Slot', slotLive: '{n} (active)', slotEmpty: '{n} (empty)', slotNone: 'There is no save in this slot.', slotField: 'The save is for {a}, the slot for {b}.', slotDevOther: 'The menu on the device does not match the loaded ROM. Load the ROM from the device first.', slotSure: 'The save goes into {n} on the device and replaces the one there. Continue?', slotDone: 'Done: {n} replaced on the device.', saveNoProg: 'No program in this ROM yet. A TamaEmu save brings its emulator along, add T7Emu and T18Emu in the Emulator tab first.', saveBtnOut: 'Export ({f})', saveBtnIn: 'Import ({f})', saveEmuInDone: 'TamaEmu save taken over ({d}). Now save the ROM or write it to the device.', saveEmuOther: 'The ROM has TamaEmu for {a}, the save is for {b}. Take it anyway?', saveNoRoom: 'This ROM has no room for TamaEmu.', saveEmuBad: 'This is not a fitting save for this program.', saveNoEmu: 'This ROM has no emulator.', saveDone: '{n} saved.', saveNoClock: '{n} saved. The clock is not included, set it in the app if needed.', devSaveRead: 'Back up save', devSaveWrite: 'Save to device', devSaveHint: 'Back up takes the Paradise save with the clock and the save of TamaEmu or T7Emu. Only the Paradise save goes to the device.', devSaveSure: 'The save is written to the device ({ed}) and replaces the current one. Continue?', devSaveDone: 'Done: {w} pages written. {c} The device can be restarted.', devSaveClock: 'Clock taken over.', devSaveClockNo: 'Please set the clock on the device.', devSaveGot: 'Backed up: {n}.', fl_saveOtherEd: 'the save is from another edition ({s}), the device is {d}', fl_saveFamily: 'the save does not fit this edition', fl_saveNoSettings: 'the settings block is missing, this is not a complete Paradise save', fl_saveOutside: '{n} pages lie outside the save and are not written', fl_saveIncomplete: 'the save does not hold every page, missing ones stay as on the device', emuUndo: 'Undo choice', progMain: 'Starts with A and C', progMainL: 'First entry of the menu', progMenu: 'Starts from the menu', progGone: 'will be removed', progUndo: 'Undo', progDel: 'Remove', progNone: 'No emulator yet. Choose firmware or ROM, every further one goes to the menu.', appBadMain: '{f}: colour Tama and TG18 firmware go as a further program only in a start device. Otherwise remove the emulator above with × first.', emuInList: 'In the ROM as further programs: {n}. No need to choose them again.', doomLinkLess: ', {m} MB less with DOOM', emuPack: 'Pack the firmware', emuPackHint: 'Saves room (about 1 MB for an iD L), but some places in the game can run slower, for example the restaurant.', packNeed: 'This firmware only fits here packed: switch on "Pack the firmware" in the row of TamaEmu.', packTip: ' Tip: "Pack the firmware" for TamaEmu saves room.', emuNfc: '4U: emulate the NFC chip', emuNfcHint: 'The menu reacts to one press. Unticked it works as before.', emuClock: 'Take the clock from the Paradise at the start', emuClockHint: 'At every start the Paradise\'s time applies. The time in between is not played through.', emuAuto: 'Start when switched on', emuAutoHint: 'Hold the wheel: back to the Paradise, it stays there. Back into the emulator: A and C, or the reset button.', autoHintL: 'Starts at switching on instead of the menu. Hold B while switching on: menu.', emuHas: 'This ROM contains an emulator.', emuBig: 'This firmware is big: the field switch of the menu has no room next to it.', emuUp: 'Saving puts in the new emulator version. With "Keep saves" the save stays.',
emuOk: 'Firmware recognised ({size}). It is built in on save.', emuBad: 'Firmware not recognised: {e}', t18Ok: 'TG18 firmware recognised (T18Emu, Meets/On). It is built in on save.', t18Has: 'This ROM contains T18Emu.', t18Use: 'Start: hold A and C together on the home screen. Back: hold the wheel (saves). If T18Emu hangs: start with A and C, release them, press the wheel within the first 3 seconds and confirm with A. The firmware then starts over from its own save. Experimental: the Tama still runs slower than the real one.',
emuGone: 'The emulator is removed on save.', emuMissing: 'This build does not contain the emulator program.',
emuFail: 'Emulator not built in: {e}', savedEmu: 'Saved: {name}',
t18Pics: 'Pictures for grow up', t18PicsPick: 'Choose pictures', t18PicsDel: 'Remove pictures', t18PicsOk: '{n} pictures taken.', t18PicsUnknown: '{f}: unknown name', t18PicsHint: 'On the device grow up then shows the picture of the choice. PNG files, name = character (e.g. Mametchi.png, Kuchipatchi.png) or its number (16.png). The folder erwachsen of the Android T18Emu works too: choose all files with erwachsen.json. Any size, scaled to 64x64.', t18Items: 'Items', t18ItemsPick: 'Choose MyMeets files', t18ItemsNoSave: 'Items work once the game has run (read the ROM from the device).', t18ItemsHint: 'Items, room and Tamapoints go into the game\'s save. When written it replaces T18Emu\'s save on the device, even with "Keep saves". The Tama stays, the running state starts anew.', t18ItemsNone: 'No items found in the files.', t18ItemsOther: '{n} is for {m}, not for the Meets/On. It may not work there.', t18ItemsFull: 'no room left', mmTitle: 'MixingMeets (visit, marriage)', uartBusy: 'Paramix Studio is still connected to the dongle. The bridge does not work meanwhile.', uartFree: 'Release UART', uartFreed: 'Dongle released. Restart the Paradise so the game runs again.', uartRun: 'Wait until the device is done.', pairTitle: 'Connect two Paradise (visit, game)', pairHint: 'Plug both Paradise together at the top and start T18Emu on both. Then on both CONNECTION, TAMAGOTCHI and on as with two Tamas.', pairHintDigi: 'Plug both Paradise together at the top and start V1Emu with Digimon on both. Then choose and start the battle as with two real Digimon.', pairHintPs: 'Plug both Paradise together at the top and start TamaEmu (P\'s) on both. Then on both connection, たまごっちP\'s, あそぶ. On one あそびにいく, on the other ともだちをよぶ, ふたりで, a game, then B.', pairHintIdl: 'Plug both Paradise together at the top and start TamaEmu (iD L) on both. Then choose the connection in the game on both as with two real iD L.', pairHintV3: 'Plug both Paradise together at the top and start V3Emu on both. Then choose the connection in the game on both as with two real V3.', pairHintT7: 'Plug both Paradise together at the top and start T7Emu (Tama-Go) on both. Then on both connection, TAMA-GO, VISIT or GAME. Press B on the device that goes visiting.', mmLink: 'Paramix bridge', mmDrag: 'Drag it to the bookmarks bar, then click it on mixing-meets.com.', mmHint: '1. Drag the Paramix bridge button to the bookmarks bar once (Chrome or Edge).\n2. Disconnect Paramix Studio from the dongle (Release UART or close the Studio). Dongle on the contacts as for flashing. On the Tama: CONNECTION, APP, VISIT (to bring it back: press A, GO BACK, YES).\n3. On mixing-meets.com open Connect or Return, click the bookmark, then Select Tamagotchi and choose the dongle.\nClick the bookmark again after every page change.', t7Gp: 'Gotchi Points', t7GpHint: 'Goes into the ROM like an imported save: the Tama stays, the running state starts anew (choose DOWNLOAD on the device).', t18KeepAsk: 'T18Emu: items or Tamapoints changed. Its save on the device is replaced by the one in the ROM (as read), even with "Keep saves". Go on?', t18ItemNo: 'No. {n}', t18ItemOk: '{n} is now in {k}.', t18Points: 'Tamapoints', t18A_food: 'Food', t18A_item: 'Items', t18A_acc: 'Accessories', t18A_room: 'Room', t18RoomBack: 'remove own room', t18RoomBuiltin: 'built-in room', dlcPick: 'Add download content', dlcInfo: 'Show used slots', progMore: 'Settings and content', progMakeMain: 'Make it the main program', progIsMain: 'Main program', v1Ok: 'First Tamagotchi or Digimon recognised (V1Emu).', v3Ok: 'Tamagotchi Connection V3 recognised (V3Emu).', v3Use: 'Start: hold A and C together on the home screen. Wheel short: settings. Back: hold the wheel.', optVol: 'Volume', optVolN: 'normal', optVolQ: 'quiet', optVolL: 'loud', optOff: 'off', optDim: 'Brightness', optScr: 'Screen off after', optDev: 'Also on the device: press the wheel briefly. A change made there applies until you change it here again.', optScrToy: 'as on the Tama', v1Use: 'Start: hold A and C together on the home screen. Wheel short: settings. Turn the wheel: shake. Back: hold the wheel.', progNoMainDoom: 'DOOM is the main program. For another one remove DOOM first (×).', doomAutoHint: 'Hold the wheel for 2 s: back to the Paradise, it stays there.', progReplaced: '{n} is now the main program instead of {o}.', mainAuto: '{n} is now the first entry of the menu, only this way everything fits.', mainNoRoom: 'As the first entry about {k} KB of room are missing. It stays as it was.', appTwice: '{n} is already in.', progNoMainV1: 'V1Emu starts from the menu only', progNoMain: 'Only in a start device', progMainNow: '{n} is now the main program. The saves of the swapped programs start anew.', dlcLoading: 'Reading…', dlcNewArea: 'The memory of this emulator is laid out anew for it. Its save starts anew after writing.', dlcHint: 'Food, clothes, accessories, games etc. as .jpg download files or .zip. Several files at once work, on the P\'s always a whole VDP set.', dlcFreeN: '{n} free', dlcDel: 'remove', dlcK0: 'Meals', dlcK1: 'Snacks', dlcK2: 'Clothing', dlcK3: 'Accessories', dlcK4: 'Items', dlcK5: 'Daily items', dlcK6: 'Wallpapers', dlcK7: 'Games', dlcK8: 'Destinations', dlcK10: 'VDP recipes', dlcK15: 'Decorations', dlcK16: 'Coupons', dlcK17: 'Bingo', dlcK18: 'Gashapon', dlcK19: 'Characters', dlcOk: '{n} now sits in {k}, slot {s}.', dlcBad: '{f}: {e}', dlcGone: '{n} removed.',
figField: 'Field:', figAll: 'all', zipField: 'Field as ZIP', fieldZipOk: '{f}: {n} characters and {s} pictures as ZIP.', fieldIn: 'Load field from ZIP', fieldInBad: 'Not a field ZIP (field.json missing).', fieldInOk: '{src} applied to {dst}: {n} parts.', fieldInEyes: '{k} characters stay original, their eye images are too big here.',
zipFigs: 'All characters as ZIP', zipAll: 'All sprites as ZIP', upload: 'Upload sheets (PNG or ZIP)',
numbers: 'Number test ROM',
figHint: 'A character is made of body, eyes and mouth, each large and small. Click a character for its sheet.',
allHint: 'Backgrounds, menus, items, fonts.',
moreColors: 'Allow more colours (up to 256)',
dimLoad: 'Load card', dimHint: 'Dump of a character card (4 MB) or a TamaSma card (1 or 2 MB). Card characters best replace adults. Baby, child and teen share their eyes and stay original.',
dimPick: 'Card character', dimTarget: 'replaces character', dimApply: 'Insert', dimEgg: 'Insert the card’s egg',
dimBaby: 'Baby', dimNone: 'Load a card to see its characters.',
download: 'Download sheet', uploadOne: 'Upload sheet', reset: 'Restore original', close: 'Close',
working: 'One moment …',
dimNr: 'No.', stUpd: 'gets updated',
disclaimer: 'Use at your own risk. Changing and writing the device can make it unusable or erase saves. Read a backup first and only use the tool if you know what you are doing. There is no warranty and no liability for damage to devices or data.',
trademarks: 'Tamagotchi and Digimon are trademarks of BANDAI. DOOM and Wolfenstein are trademarks of id Software (ZeniMax Media). Game Boy and Pokémon mini are trademarks of Nintendo, SEGA and Master System are trademarks of SEGA. Arduboy is a trademark of Arduboy Inc. All trademarks, games and characters belong to their owners and are only named to describe what the tool is for. Not an official product, not affiliated with these companies. The tool contains no games, firmware or game data: you only use your own files.',
devWarn: 'Writing to the device is at your own risk and without liability. Read a backup first and keep the device switched on while writing.',
footer: 'Runs locally in your browser. By mameise.',
edition: 'Edition', sprites: 'Sprites', figures: 'Characters', changed: 'changed', space: 'Room for characters',
figure: 'Character', sprite: 'Sprite',
mSize: 'Cell {w}×{h}, {n} images, grid {iw}×{ih}', mColors: '{c}, palette sets: {p}',
mDirect: 'Direct colour RGB565', mPal: '{n} colours', mKeep: 'Several palette sets (colour variants): uploads use the original colours.',
mSheet: 'Sheet {w}×{h} px. Keep the size, otherwise the grid no longer fits.',
mGroupRows: 'Rows: body (20), eyes (20), mouth (18), small body (24), small eyes (14), small mouth (14).',
notRom: 'This is not a Paradise dump: {e}', loaded: '{ed} loaded: {s} sprites, {f} characters.',
saved: 'Saved: {name}\n{n} sprites changed, {kb} KB still free.', nothing: 'Nothing changed yet.',
tooBig: 'Too big for the free space. {e}',
upOk: 'Applied: {n}', upSkip: 'Skipped: {list}', upNone: 'No matching files. Expected: figur_0237.png or sprite_0014.png.', sprSix: 'Field picture of the extra fields, cannot be changed.',
wrongSize: '{f}: {e}', resetOk: 'Original restored.', dimOk: 'Card character {d} now sits in character {g}.', eggOk: 'Egg replaced.',
numOk: 'Every character now shows its number. Save, flash, raise and note which number shows up at which stage.',
notDim: 'Unknown card: {e}', leave: 'There are unsaved changes.',
roleFallback: 'Fallback', roleBaby: 'Baby', roleAdult: 'first adult',
eyeHint: 'Pink frame = eye. It moves into the eye layer so the character blinks and the cell has eyes. Wrong? Click on the eye.',
eyeNone: 'Character has no visible eyes', dimEyesTooBig: 'The eyes were too detailed, the character keeps no eye layer.',
roleFallbackText: 'appears when the game cannot load a character. Best left unchanged.',
roleBabyText: 'hatches from the egg.', roleAdultText: 'from here on every character has its own eyes.',
mEyes: 'Eyes keep their byte size, otherwise the fallback character hatches. Eyes that are too detailed are rejected.',
mColorsFig: 'If all colours come from the original, the game keeps recolouring the character per tama. New colours become fixed (up to 8 colours plus outline).',
},
};
/* ITOSM_KO_BEGIN */
T.ko = {
"open": "ROM 열기",
"save": "새 ROM 저장",
"startTitle": "다마고치 파라다이스를 더 다양하게",
"startText": "내 파라다이스 ROM으로 원하는 기능을 구성하세요. 16 MB 원본 파일을 열거나 기기에서 직접 읽으세요. 기능을 선택한 뒤 새 ROM을 저장하거나 기기에 기록할 수 있습니다.",
"featHead": "이런 일을 할 수 있어요",
"g1t": "다마고치 에뮬레이터",
"g1": "컬러 다마고치(iD, iD L, Plus Color, P's, 4U, 4U+), 타마고와 피규어, 프렌즈, 미츠·온, 커넥션 V3, P1·P2·엔젤 등의 초기 다마고치와 디지몬 V1·V2를 지원합니다. 여러 프로그램을 넣고 각각 저장할 수 있습니다. ROM은 직접 준비하세요.",
"g2t": "DOOM과 Wolfenstein 3D",
"g2": "파라다이스에서 DOOM, Wolfenstein 3D, Spear of Destiny를 실행하고 버튼을 설정할 수 있습니다. 게임 파일은 직접 준비하세요.",
"g7t": "게임기 에뮬레이터",
"g7": "게임보이·컬러, 마스터 시스템, 게임기어, 포켓몬 미니, Arduboy를 지원합니다. 직접 준비한 게임을 메뉴에 추가하고 소리와 저장 기능을 사용할 수 있습니다.",
"g3t": "지역 확장",
"g3": "지원되는 ROM에 여섯 지역과 배경, 비밀 캐릭터, 지역별 행성 및 연구소 게임을 구성합니다.",
"g4t": "본체 편집 메뉴",
"g4": "본체에서 지역을 바꾸고 아이템과 다마포인트 및 다마고치를 수정합니다. 저장 슬롯별로 육성 데이터를 보관할 수 있습니다.",
"g8t": "파라다이스 없는 실행 전용 기기",
"g8": "약 16 MB 전체를 에뮬레이터와 게임에 활용합니다. 시작 프로그램을 지정하고 메뉴에서 시간을 설정합니다.",
"g5t": "기기 읽기·기록",
"g5": "USB-UART 어댑터로 원본을 백업하고 새 ROM을 기록합니다. 저장 데이터를 유지하거나 변경한 부분만 기록할 수 있습니다. 기록 중단에 대비한 복구 시작 기능도 있습니다.",
"g6t": "나만의 캐릭터",
"g6": "다마고치의 모습을 이미지로 내보내 편집합니다. 수정한 이미지를 가져와 캐릭터에 적용하고 눈과 입의 위치를 조정할 수 있습니다.",
"g9t": "저장 관리와 방문",
"g9": "저장 데이터를 백업·복원·편집하고 다운로드 콘텐츠를 추가합니다. 상단 단자로 두 기기를 연결하거나 어댑터로 가상 방문을 실행합니다.",
"dropTitle": "ROM을 여기에 놓거나 클릭하세요",
"dropText": "랜드, 워터, 스카이, 제이드 포레스트, 트로피컬, 글레이셔를 인식합니다.",
"f1t": "내 PC 편집·기종별 백업",
"f1": "파일 열기와 편집은 PC 브라우저에서 처리합니다. 기기에서 읽은 ROM을 보관하고 필요한 기능을 편집할 수 있습니다.",
"f2t": "게임 파일은 직접 준비",
"f2": "도구에는 ROM, 펌웨어, WAD가 포함되지 않습니다. 본인 기기와 파일을 사용하세요.",
"f3t": "변경 내용 검증",
"f3": "체크섬을 다시 계산하고 저장 전 수정 이미지를 확인합니다. 기기에 기록한 각 섹터도 검증합니다.",
"planTitle": "새 ROM 구성",
"planFig": "캐릭터",
"planEmu": "에뮬레이터",
"planEmus": "에뮬레이터",
"planDoom": "DOOM",
"planWolf": "Wolfenstein 3D",
"planGb": "게임보이",
"planSms": "마스터 시스템 / 게임기어",
"planPm": "포켓몬 미니",
"planMenu": "본체 메뉴",
"planApps": "추가 에뮬레이터",
"stNone": "없음",
"stKeep": "유지",
"stNew": "추가",
"stDel": "저장 시 삭제",
"stChanged": "{n}개 변경",
"stSame": "변경 없음",
"segFw": "펌웨어와 캐릭터",
"segEmu": "에뮬레이터",
"segDoom": "DOOM",
"segWolf": "Wolfenstein 3D",
"segGb": "게임보이",
"segSms": "마스터 시스템 / 게임기어",
"segPm": "포켓몬 미니",
"segSlots": "지역별 저장",
"segSave": "저장 데이터",
"segFree": "사용 가능",
"segResv": "예약 영역",
"ruleBoth": "에뮬레이터와 DOOM 중 하나만 넣을 수 있습니다. 본체 메뉴는 둘 다 지원합니다.",
"ruleNoRoom": "이 에디션은 캐릭터 데이터가 커서 에뮬레이터나 DOOM을 넣을 공간이 없습니다. 본체 메뉴는 사용할 수 있습니다.",
"emuVsDoom": "DOOM이 선택되거나 설치되어 있습니다. 여기서 펌웨어를 선택하면 DOOM을 제거합니다.",
"doomVsEmu": "에뮬레이터가 선택되거나 설치되어 있습니다. 여기서 WAD를 선택하면 에뮬레이터를 제거합니다.",
"noRoomApp": "이 에디션에는 필요한 공간이 없습니다.",
"a0Menu": "이 에디션은 0x0A0000에 주 프로그램을 넣을 공간이 없어 모든 프로그램을 메뉴에 넣습니다. 별표로 전원을 켤 때 실행할 프로그램을 선택합니다.",
"a0MenuN": "이 에디션은 0x0A0000에 주 프로그램을 넣을 공간이 없습니다. 타마고·프렌즈·초기 다마고치·V3는 메뉴에서 실행합니다(메뉴 탭에서 지역 전환 또는 아이템을 활성화한 뒤 A+C로 실행). 컬러 다마고치와 TG18은 실행 전용 구성에서만 지원됩니다.",
"a0NoMain": "{f}: 이 에디션의 컬러 다마고치와 TG18은 실행 전용 구성에서만 지원됩니다(메뉴 탭).",
"doomHas": "이 ROM에 DOOM이 들어 있습니다.",
"doomOff": "DOOM 제거",
"doomGone": "저장할 때 DOOM을 제거합니다.",
"keysTitle": "버튼 설정",
"kFire": "발사",
"kFwd": "앞으로",
"kBack": "뒤로",
"kUse": "사용",
"kMod": "무기 변경: 버튼을 누른 채 휠",
"kWheel": "휠 누르기",
"kRun": "앞으로 두 번 눌러 달리기",
"kInv": "휠 방향 반전",
"kFixed": "A+C를 누르면 메뉴가 열립니다. B+C를 누르면 지도가 열립니다. 소리를 켜거나 끄려면 무기 변경 버튼을 누른 채 휠을 짧게 누르세요. 종료 방법은 메뉴 탭의 ‘프로그램에서 돌아오기’ 설정을 따릅니다.",
"kOld": "이 DOOM은 개별 버튼 설정을 지원하지 않는 이전 버전입니다. WAD로 다시 추가하세요.",
"help": "도움말",
"helpTitle": "사용 방법",
"h1t": "진행 순서",
"h1": "1. ROM 파일을 열거나 기기에서 읽습니다.\n2. 캐릭터와 이름 및 본체 메뉴를 편집합니다.\n3. 새 ROM을 저장하거나 기기에 기록합니다.",
"h2t": "파라다이스 버튼 조작",
"hk1": "A+C",
"hv1": "홈 화면에서 본체 편집 메뉴 열기",
"hk2": "A",
"hv2": "항목 이동 또는 분류 변경",
"hk3": "B",
"hv3": "선택과 확인",
"hk4": "C",
"hv4": "이전 화면으로 돌아가기",
"hk5": "휠 돌리기",
"hv5": "대상 선택과 숫자 변경",
"hk6": "RESET",
"hv6": "본체 다시 시작하기. 기록 중에는 누르지 마세요.",
"hk7": "C+RESET",
"hv7": "복구 기능이 설치된 기기에서 복구 화면 열기",
"h3t": "시계",
"h3": "에뮬레이터 탭의 ‘시작할 때 파라다이스 시간 가져오기’를 켜면 실행할 때마다 기기의 시간으로 맞춥니다. 실행하지 않은 시간 동안의 플레이를 재현하지는 않습니다. 파라다이스 시계를 먼저 맞추세요.",
"h4t": "다시 실행하기",
"h4": "휠로 종료한 시점부터 이어집니다. 실행 상태를 초기화해도 게임 자체의 저장 데이터는 유지됩니다.",
"h5t": "메뉴와 지역",
"h5": "홈 화면에서 A+C를 누릅니다. 휠로 항목을 선택하고 B로 확인하세요. C를 누르면 이전 화면으로 돌아갑니다. 지역을 바꾸면 이전 지역의 저장 데이터를 보관하고 새 지역의 저장을 불러옵니다.\n트로피컬·글레이셔에는 내 ROM에서 랜드·워터·스카이를 추가하고 제이드 포레스트에는 스카이를 추가합니다. 게임에서는 행성 → 지역으로 이동합니다. DNA와 주민은 해당 지역에 속합니다.",
"h8t": "실행 전용 구성",
"h8": "메뉴 탭에서 실행 전용 구성을 선택하면 프로그램 목록으로 시작합니다. 파라다이스를 제거하면 거의 전체 공간을 프로그램에 쓰며 메뉴에서 시계를 맞춥니다. 별표로 주 프로그램을 정하고 자동 시작을 켤 수 있습니다.",
"h9t": "복구 화면으로 돌아가기",
"h9": "복구 기능이 설치된 기기에서는 C 버튼을 누른 채 RESET을 짧게 눌렀다 놓으면 복구 화면으로 들어갑니다. 화면이 나타나면 C 버튼을 놓고 기기 메뉴에서 연결하세요. 기록이나 검증이 진행 중일 때는 RESET을 누르지 말고 화면의 이어 쓰기 안내를 따르세요.",
"h6t": "저장 데이터 백업",
"h7t": "저장 데이터 가져오기",
"h7": "1. ‘기기’에서 최신 ROM을 읽거나 최근 읽은 파일을 엽니다.\n2. 저장 탭에서 데이터를 가져옵니다. 해당 프로그램의 저장에 적용됩니다.\n3. ‘저장 데이터 유지’를 켜고 기록합니다. 가져온 저장만 교체하고 다른 저장은 기기의 것을 유지합니다.\n‘저장 데이터 유지’를 끄면 모든 저장을 파일의 것으로 교체합니다. 프로그램 추가·삭제는 별도 기록으로 진행하고 먼저 모든 저장을 백업하세요.",
"h6": "기기의 현재 상태를 보관하려면 기기 → 저장 데이터 백업을 선택하세요. 열어 둔 ROM에서 저장 데이터를 꺼내려면 저장 관리 → 내보내기를 선택하세요.",
"device": "기기",
"devTitle": "UART 기기 연결",
"devHint": "3.3 V 신호의 USB-UART 어댑터를 사용합니다. 원본 안내의 접점 방향은 왼쪽: 어댑터 RX, 가운데: GND, 오른쪽: 어댑터 TX입니다. 실제 기기 방향과 배선을 확인하세요. 본체의 다마 우주 → A → 통신 → 다운로드 → 다운로드 화면을 연 뒤 연결하세요. PC의 Chrome 또는 Edge가 필요합니다.",
"devConnect": "연결",
"devDump": "ROM 추출·백업 후 다운로드",
"devWrite": "새 ROM을 기기에 기록",
"devOnly": "변경 부분만 기록",
"devKeep": "저장 데이터 유지",
"devStop": "취소",
"devNoSerial": "이 브라우저는 어댑터 연결을 지원하지 않습니다. PC의 Chrome 또는 Edge를 사용하세요.",
"devNone": "연결되지 않았습니다.",
"fl_noRescueRoom": "복구 시작 영역(플래시 마지막 64 KB)에 공간이 없어 기록하지 않았습니다. 실행 전용 구성에서 프로그램을 하나 제거한 뒤 다시 기록하세요.",
"plHint": "PL2303 어댑터: 최신 Windows 드라이버는 구형·호환 칩을 차단할 수 있습니다. 장치 관리자에서 구형 Prolific 3.3.2.x 드라이버를 선택하거나 CH340·CP2102 어댑터를 사용하세요.",
"resOn": "기록 중단 복구 기능 활성화: 중단 시 기기가 기록 화면으로 시작합니다.",
"resModeGo": "이전 기록이 중단되었습니다. 본체의 기록 화면에서 대기 중입니다. ‘기록 이어하기’를 누르세요.",
"resModeRom": "이전 기록이 중단되었습니다. 본체가 기록 화면에서 대기 중입니다. ROM 또는 백업 파일을 다시 열고 기록하세요.",
"resResume": "기록 이어하기",
"resHalf": "이전 기록이 끝나지 않았습니다. ‘기록 이어하기’로 완료하세요.",
"resResumed": "{w}개 섹터 기록 완료. 본체 전원을 껐다 켜세요.",
"resTest": "복구 시작 테스트",
"resBack": "헤더 복원",
"resSure": "테스트: 0xFF0000에 복구 프로그램을 기록한 뒤 기기 헤더(섹터 0)를 지웁니다. 전원을 껐다 켜고 기록 화면이 나오면 연결 후 ‘헤더 복원’을 누르세요. 화면이 나오지 않으면 별도 플래시 도구 없이 부팅할 수 없습니다. 계속할까요?",
"resCleared": "헤더를 지웠습니다. 전원을 껐다 켜세요. 기록 화면이 나오면 연결 후 ‘헤더 복원’을 누르세요.",
"resBackDone": "헤더를 복원했습니다. 전원을 껐다 켜면 정상 시작합니다.",
"resNoHdr": "보관된 헤더가 없습니다.",
"devOn": "연결됨: {ed} · {mb} MB{l}",
"devLoaded": " · 기록 프로그램을 불러왔습니다",
"devReady": "준비되었습니다.",
"devNeedRom": "기록할 ROM을 먼저 열거나 기기에서 읽으세요.",
"visTitle": "가상 방문(파라다이스)",
"visStart": "시작",
"visStop": "중지",
"visHint": "도구가 두 번째 파라다이스 역할을 합니다. 어댑터를 접점에 연결하고 본체는 일반 실행 상태로 두세요.\n1. 에디션 선택 → 시작 → 어댑터 선택.\n2. 본체의 다마 우주 → A → 통신 → 놀기 → B.\n위의 ‘연결’ 버튼은 ROM 작업용이므로 방문할 때는 누르지 마세요.",
"visWait": "{ed} 방문 준비 완료. 본체에서 통신 → 놀기를 선택하고 B를 누르세요.",
"visRun": "연결되었습니다. 데이터를 주고받고 있습니다…",
"visPlay": "두 다마고치가 놀고 있습니다…",
"visDone": "방문 완료({ed}). 다음 방문은 본체에서 B를 다시 누르세요.",
"visErr": "중단됨: {e}. 본체에서 B를 다시 누르세요.",
"visBadKey": "본체가 데이터를 인식하지 못했습니다.",
"phload": "기록 프로그램 로드 중",
"phread": "읽는 중",
"phcompare": "비교 중",
"phwrite": "기록 중",
"phcheck": "검증 중",
"phprepare": "준비 중",
"devDumped": "ROM을 읽어 {n}으로 저장했습니다. 도구에서도 해당 ROM을 열었습니다.",
"devSure": "새 ROM을 기기에 기록합니다. 기록 중 전원을 유지하세요. 변경에 따른 위험을 이해하고 기록할까요?",
"devSureFull": "‘저장 데이터 유지’가 꺼져 있어 기기의 저장을 ROM 파일의 저장으로 교체합니다. 기록할까요?",
"carryUnknown": "기기와 현재 파일의 ROM이 다릅니다. 이동하는 프로그램의 저장을 보존할 수 없습니다. 먼저 기기의 ROM을 읽으세요. 그래도 기록할까요?",
"carryMiss": "이동하는 프로그램의 저장을 보존할 수 없습니다. 저장 탭에서 먼저 백업하세요. 그래도 기록할까요?",
"devEmuLost": "기기의 주 프로그램: {o}. 새 ROM: {n}. {o}의 주 프로그램 저장이 초기화됩니다. 유지하려면 저장 탭에서 먼저 백업하세요. 기록할까요?",
"devEmuNone": "에뮬레이터 없음",
"devEmuNew": "새 펌웨어를 선택한 {o}",
"devDone": "기록·검증 완료: {w}개 섹터 기록{k}. 본체를 리셋하거나 배터리로 재시작하세요.",
"devKept": " · 저장 섹터 {k}개 유지",
"devSame": "기기에 이미 같은 ROM이 있어 기록할 내용이 없습니다.",
"devErr": "오류: {e}",
"devCancelled": "취소했습니다.",
"cleanOn": "파라다이스 제거(클린 ROM)",
"cleanClock": "시작할 때 시계 설정",
"cleanClockHint": "배터리 교체 등으로 시간이 없으면 시작 시 설정합니다. 이 옵션을 끄면 본체 메뉴의 설정 또는 각 에뮬레이터에서 시간을 맞추세요.",
"emuClockOff": "메뉴 탭의 ‘시작할 때 시계 설정’을 켜야 합니다.",
"emuSess": "종료 시 실행 상태 저장",
"emuSessHint": "다음 실행 시 종료한 지점부터 이어집니다. 끄면 실제 기기처럼 새로 시작해 게임 자체의 저장을 불러옵니다.",
"ruleClean": "파라다이스 제거: 모든 프로그램을 메뉴에 넣고 거의 전체 플래시 공간을 활용합니다.",
"cleanHint": "파라다이스 게임을 제거하고 프로그램 메뉴만 남깁니다. 거의 16 MB 전체를 사용할 수 있습니다.",
"cleanUse": "전원을 켜면 메뉴가 바로 나옵니다. 처음에는 시계를 설정하고 이후에는 설정 메뉴에서 변경합니다. 프로그램 종료 방법은 같습니다.",
"cleanWarn": "기록하면 파라다이스와 그 저장 데이터가 삭제됩니다. 먼저 백업하세요.",
"cleanNoDoom": "이 구성에서는 DOOM을 사용할 수 없습니다. DOOM을 제거하세요.",
"doomOne": "DOOM은 메뉴에 한 번만 추가할 수 있습니다.",
"cleanSure": "기기의 파라다이스 게임과 저장 데이터가 삭제됩니다. 기기를 백업했나요? 계속할까요?",
"cleanLoaded": "파라다이스 없는 ROM({ed})을 열었습니다: 프로그램 {n}개.",
"launchOn": "프로그램 실행 전용 구성",
"launchHint": "파라다이스의 초기 설정(언어·시간·이어하기·새 게임)만 남기고 이후에는 프로그램 메뉴로 시작합니다. 게임 이미지를 제거해 약 5 MB를 추가로 확보합니다.",
"launchUse": "전원을 켜고 시간을 맞추면 메뉴가 나옵니다. 휠로 선택하고 B로 실행합니다. 프로그램을 종료하면 메뉴로 돌아옵니다.",
"launchOld": "실행 전용 ROM입니다. 일반 파라다이스로 돌아가려면 원본 ROM을 여세요.",
"launchNeed": "실행 전용 구성에는 에뮬레이터 또는 DOOM 등 프로그램이 하나 이상 필요합니다.",
"launchSix": "여섯 지역 확장이 설치된 ROM은 실행 전용으로 바꿀 수 없습니다. 원본 ROM을 여세요.",
"planLaunch": "실행 전용 구성",
"tabFeld": "본체 메뉴",
"feldOn": "여러 저장 슬롯(지역 선택)",
"bagOn": "아이템과 다마포인트",
"tamaOn": "다마고치 수정(레벨·돌봄·캐릭터)",
"gplayOn": "플레이 시간으로 다마포인트 획득",
"gplayHint": "DOOM, Wolfenstein, 게임보이, 마스터 시스템, 포켓몬 미니, Arduboy를 플레이한 뒤 파라다이스로 돌아오면 1분당 10포인트를 받습니다.",
"saveSlot": "저장 {n}",
"sixOn": "여섯 지역 모두 추가",
"sixPick": "랜드·워터·스카이 ROM 선택",
"sixHint": "트로피컬·글레이셔에 랜드·워터·스카이를 추가합니다. 지역 이미지는 직접 준비한 해당 ROM에서 가져옵니다. 연구소 게임은 메뉴에서 다마고치를 시작한 지역을 따릅니다.",
"sixNeed": "여섯 지역 확장을 위해 랜드·워터·스카이 중 하나의 ROM이 필요합니다.",
"sixOk": "{n}에서 지역 이미지를 가져왔습니다.",
"sixBad": "{n}은 랜드·워터·스카이 ROM이 아닙니다.",
"sixIn": "여섯 지역이 설치되어 있습니다.",
"sixOff": "저장 시 랜드·워터·스카이를 제거합니다. 여러 저장 슬롯은 유지됩니다.",
"sixOffJ": "저장 시 스카이를 제거합니다. 여러 저장 슬롯은 유지됩니다.",
"sixOffField": "현재 기기의 지역은 {f}입니다. 먼저 본체 메뉴에서 {s}로 이동하세요.",
"sixOffSlots": "본체 메뉴에 보관된 저장 데이터가 삭제됩니다. 계속할까요?",
"sixFail": "지역 추가 실패: {e}",
"sixNoFw": "ROM의 펌웨어가 변경되어 지역 확장을 적용할 수 없습니다.",
"planSix": "지역 확장",
"sixOnJ": "스카이를 네 번째 지역으로 추가",
"sixHintJ": "제이드 포레스트에는 스카이 이미지가 이미 들어 있습니다.",
"sixInJ": "스카이가 네 번째 지역으로 설치되어 있습니다.",
"sixOld": "이전 버전의 여섯 지역 확장이 설치되어 있습니다. 랜드·워터·스카이 ROM을 선택하면 저장 시 업데이트합니다.",
"sixOldJ": "스카이가 설치되어 있으며 저장할 때 업데이트합니다.",
"sixPlanet": "지역에 맞는 행성",
"sixMenu": "게임의 지역 메뉴: 레벨 4부터 모든 지역",
"sixPlanetNeed": "이 설정을 바꾸려면 랜드·워터·스카이 ROM이 다시 필요합니다.",
"sixApp": "DOOM·에뮬레이터와 함께 넣을 공간이 없습니다",
"exitKey": "프로그램에서 돌아오기",
"exitHint": "에뮬레이터와 게임에서 파라다이스 또는 본체 메뉴로 돌아오는 조작입니다.",
"exit0": "휠 길게 누르기",
"exit1": "휠과 A 길게 누르기",
"exit2": "휠과 C 길게 누르기",
"exit3": "휠 5초 누르기",
"feldHint": "본체에서 저장 슬롯 전환, 새 지역 시작, 아이템 추가, 포인트 설정, 다마고치 수정을 할 수 있는 메뉴입니다.",
"feldUse": "홈 화면에서 A+C를 길게 누르세요. 휠로 항목을 선택하고 B로 확인하세요. C를 누르면 이전 화면으로 돌아갑니다.",
"feldNo": "지역 전환은 랜드·워터·스카이 사이 또는 트로피컬·글레이셔 사이에서 지원합니다.",
"feldMissing": "이 배포본에는 본체 메뉴가 없습니다.",
"feldCur": "현재 지역: {f}.",
"feldList": "선택 가능: {s}.",
"feldStored": "보관 중: {s}.",
"feldFail": "메뉴 설치 실패: {e}",
"feldUnknown": "에디션을 인식하지 못했습니다.",
"tabWolf": "Wolf3D",
"wolfPick": "게임 파일 선택",
"wolfHint": "Wolfenstein 3D 파일을 모두 함께 선택하세요: 셰어웨어(.WL1), 정식판(.WL6), Spear of Destiny(.SOD). 본체 메뉴에 추가합니다.",
"wolfNone": "선택한 게임 파일이 없습니다.",
"wolfShare": "셰어웨어",
"wolfFull": "정식판",
"wolfEps": "에피소드 {n}개",
"wolfEp1": "에피소드 1개",
"wolfBad": "Wolfenstein 3D: {e}",
"wolfNoMain": "Wolfenstein 3D는 본체 메뉴에서만 실행",
"wolfTurn": "휠 한 칸당 회전",
"wolfFixed": "A+C: 메뉴. 종료·저장은 본체 메뉴 탭의 ‘프로그램에서 돌아오기’ 설정을 따릅니다.",
"wolfOne": "Wolfenstein 3D와 Spear of Destiny는 각각 하나씩만 넣을 수 있습니다. 새 파일을 선택하면 이전 것을 교체합니다.",
"wolfSodN": "21개 층",
"tabGb": "게임보이 / 컬러",
"gbNoMain": "게임보이는 본체 메뉴에서만 실행",
"gbPick": "게임 선택(.gb, .gbc)",
"gbHint": "게임을 본체 메뉴에 추가합니다. A+B+C로 설정(Select·소리 포함)을 열고 휠을 2초 누르면 저장 후 종료합니다. 다음 실행 시 이어집니다. 두 파라다이스의 상단 단자를 연결하면 포켓몬 교환 등 통신 케이블 기능을 사용할 수 있습니다.",
"gbNone2": "선택한 게임이 없습니다.",
"gbKeysTitle": "버튼",
"gbKeysDef": "기본값",
"gbKeysMiss": "미지정: {n}",
"gbNone": "–",
"gbRight": "오른쪽",
"gbLeft": "왼쪽",
"gbUp": "위",
"gbDown": "아래",
"gbInA": "A 버튼",
"gbInB": "B 버튼",
"gbInC": "C 버튼",
"gbInWp": "휠 누르기",
"gbInWu": "휠 위로",
"gbInWd": "휠 아래로",
"gbInAC": "A + C",
"gbInBC": "B + C",
"gbInAB": "A + B",
"gbBad": "{f}: 게임보이 게임이 아닙니다",
"gbColor": "{f}: 게임보이 컬러 전용이므로 이 구성에서 지원하지 않습니다",
"gbNeedRom": "먼저 ROM을 열거나 기기에서 읽으세요.",
"t7Old": "{n}: 구버전은 배터리 교체 시 저장이 유실될 수 있습니다. ‘저장 데이터 유지’를 켜고 다시 기록하세요.",
"t18Broken": "Tama Meets가 손상되었습니다. 제거 후 펌웨어를 다시 추가하고 ‘저장 데이터 유지’를 끈 상태로 기록하세요.",
"t18Clash": "주 프로그램과 Tama Meets의 공간이 겹칩니다. Tama Meets를 먼저 제거하세요.",
"tabSms": "마스터 시스템 / 게임기어",
"tabPm": "포켓몬 미니",
"smsNoMain": "마스터 시스템·게임기어는 본체 메뉴에서만 실행",
"pmNoMain": "포켓몬 미니는 본체 메뉴에서만 실행",
"abNoMain": "Arduboy는 본체 메뉴에서만 실행",
"planAb": "Arduboy",
"segAb": "Arduboy",
"tabAb": "Arduboy",
"abPick": "게임 선택(.hex, .zip)",
"abHint": "게임을 본체 메뉴에 추가합니다. A+B+C로 화면 크기·소리 등을 설정합니다. 휠을 2초 누르면 저장 후 종료합니다. 다음 실행 시 이어집니다.",
"abBad": "{f}: Arduboy 게임이 아닙니다",
"abBig": "{f}: Arduboy 용량을 초과합니다",
"smsPick": "게임 선택(.sms, .gg)",
"smsHint": "게임을 본체 메뉴에 추가합니다. A+B+C로 일시정지·소리 등을 설정합니다. 휠을 2초 누르면 저장 후 종료합니다. 다음 실행 시 이어집니다.",
"smsBad": "{f}: 마스터 시스템·게임기어 게임이 아닙니다",
"smsGG": "{f}: 이 구성에서는 게임기어 게임을 지원하지 않습니다",
"smsB1": "버튼 1",
"smsB2": "버튼 2",
"smsPause": "일시정지 / 시작",
"pmPick": "게임 선택(.min, .zip)",
"pmHint": "게임을 본체 메뉴에 추가합니다. A+B+C로 전원·소리 등을 설정합니다. 휠을 2초 누르면 저장 후 종료합니다. 다음 실행 시 이어집니다.",
"pmBad": "{f}: 포켓몬 미니 게임이 아닙니다",
"pmBig": "{f}: 1 MB를 초과해 지원하지 않습니다",
"pmBiosPick": "내 BIOS 선택",
"pmBiosDel": "내 BIOS 제거",
"pmBiosFree": "직접 선택하지 않으면 PokeMini의 자유 BIOS를 사용합니다. 실제 BIOS로 더 잘 실행되는 게임도 있습니다.",
"pmBiosOwn": "선택한 BIOS를 모든 포켓몬 미니 게임에 사용합니다.",
"pmBiosBad": "{f}: 포켓몬 미니 BIOS가 아닙니다",
"pmA": "A",
"pmB": "B",
"pmC": "C",
"pmPower": "전원",
"pmShake": "흔들기",
"tabFigs": "캐릭터",
"tabAll": "전체 이미지",
"tabDim": "카드",
"tabEmu": "에뮬레이터",
"tabDoom": "DOOM",
"doomPick": "DOOM.WAD 선택",
"doomEp": "에피소드",
"doomMusic": "음악",
"doomHint": "직접 준비한 WAD로 ROM에 DOOM을 추가합니다. 파일은 내 PC에서 처리합니다.",
"doomUse": "본체 메뉴에서 실행합니다. 일반 파라다이스에서는 홈 화면에서 A+C로도 실행합니다. 종료는 ‘프로그램에서 돌아오기’ 설정을 따릅니다.",
"doomNone": "선택한 WAD가 없습니다.",
"doomOk": "WAD 인식됨({eps}). 저장할 때 DOOM을 추가합니다.",
"doomEpsHint": "파라다이스 없는 구성에서는 선택한 에피소드를 DOOM E1, E2 등 각각의 메뉴와 저장으로 추가합니다.",
"doomWhole": "전체 WAD를 한 항목으로",
"pwadPick": "추가 WAD 선택",
"pwadOff": "추가 WAD 제거",
"doomPwads": "함께 사용: {n}.",
"pwadNeedD2": "{n}은 DOOM II용입니다. 먼저 DOOM2.WAD를 선택하세요.",
"pwadNeedD1": "{n}은 DOOM·Ultimate DOOM용입니다. 먼저 DOOM.WAD를 선택하세요.",
"doomPwadPara": "Sigil 같은 추가 에피소드는 파라다이스 없는 구성에서만 지원합니다.",
"doomPwadBig": "{n}: {m} 지도는 본체 메모리보다 클 수 있습니다. 실행 중 9가 표시되면 휠을 2초 눌러 메뉴로 돌아가세요.",
"doomPwadHint": "추가 에피소드를 선택하면 개별 메뉴로 추가합니다. 전체 WAD와 함께 넣으면 공간이 부족할 수 있습니다.",
"doomD2Clean": "DOOM II는 파라다이스 없는 ROM에만 추가할 수 있습니다.",
"doomD2Hint": "DOOM II는 메뉴 한 항목으로 추가합니다. 거의 전체 공간을 사용하며 음악을 꺼야 들어갑니다.",
"doomWholeHint": "모든 에피소드를 DOOM 한 항목에 넣고 게임 안에서 선택합니다. 개별 추가보다 공간을 적게 사용합니다.",
"doomBad": "WAD 인식 실패: {e}",
"doomFail": "DOOM 추가 실패: {e}",
"doomMissing": "이 배포본에는 DOOM 프로그램이 없습니다.",
"doomBoth": "에뮬레이터와 DOOM을 함께 넣을 공간이 없습니다. 하나만 선택하세요.",
"doomBig": "이 WAD의 에피소드를 넣을 공간이 없습니다.",
"doomNoMusic": "음악을 꺼야 이 에피소드가 들어갑니다.",
"emuPick": "펌웨어 또는 ROM 선택",
"emuOff": "에뮬레이터 제거",
"emuHint": "컬러 다마고치(TamaEmu), 타마고·프렌즈(T7Emu), 미츠·온(T18Emu), 초기 다마고치·디지몬(V1Emu), 커넥션 V3(V3Emu)를 지원합니다. 첫 파일은 주 프로그램으로 지정합니다. 이후 파일은 본체 메뉴에 추가합니다. 채워진 별표가 주 프로그램이며 빈 별표를 누르면 바뀝니다. 파일은 직접 준비하세요.",
"t7Ok": "V7 ROM 인식됨(T7Emu). 저장할 때 추가합니다.",
"t7OkFr": "다마고치 프렌즈를 불러왔습니다. 저장할 때 추가합니다. 피규어는 지원하지 않습니다.",
"t7Has": "이 ROM에 T7Emu가 들어 있습니다.",
"t7HasFr": "이 ROM에 다마고치 프렌즈 T7Emu가 들어 있습니다.",
"t7Use": "홈 화면에서 A+C를 누르면 실행합니다. 휠을 길게 누르면 저장하고 종료합니다. 짧게 누르면 설정과 피규어 메뉴가 열립니다. 멈췄다면 A+C로 실행하고 버튼을 놓은 뒤 3초 안에 휠을 누르세요. A를 눌러 확인하세요.",
"t7FigPick": "피규어 추가",
"t7FigNone": "추가한 피규어가 없습니다.",
"t7FigBad": "{f}: 피규어 파일이 아닙니다.",
"t7FigFull": "{f}을 넣을 공간이 없습니다.",
"t7FigMax": "피규어를 더 넣을 공간이 없습니다.",
"t7FigDup": "{f}은 이미 들어 있습니다.",
"appPick": "다른 에뮬레이터 추가",
"appHint": "타마고·프렌즈 ROM(T7Emu)을 추가합니다. A+C로 여는 메뉴에서 실행하므로 본체 메뉴 탭의 기능을 하나 이상 켜야 합니다.",
"appNone": "추가 에뮬레이터가 없습니다.",
"appBad": "{f}: 타마고·프렌즈 ROM이 아닙니다.",
"appBadL": "{f}: 타마고·프렌즈 ROM이나 컬러 다마고치·TG18 펌웨어가 아닙니다.",
"appT18One": "T18Emu는 ROM마다 하나만 추가할 수 있습니다.",
"appHintL": "실행 전용 구성: 타마고·프렌즈 ROM, 컬러 다마고치 펌웨어(TamaEmu), TG18 펌웨어(T18Emu는 하나만 추가 가능)를 지원합니다.",
"ruleLaunch": "실행 전용 구성에서는 공간이 있으면 에뮬레이터와 DOOM을 함께 넣을 수 있습니다.",
"appMax": "추가 에뮬레이터는 최대 12개입니다.",
"appNeedMenu": "추가 에뮬레이터를 실행하려면 본체 메뉴 탭에서 지역 전환 또는 아이템을 켜세요.",
"appFail": "추가 에뮬레이터: {e}",
"appSix": "여섯 지역 확장과 추가 에뮬레이터를 함께 사용할 수 없습니다.",
"t7SaveBtn": "T7Emu 저장(.bin)",
"saveFor": "프로그램",
"saveMain": "주 에뮬레이터",
"v1SaveBtn": "V1Emu 저장(.bin)",
"saveT18No": "이 프로그램의 저장 데이터는 백업할 수 없습니다.",
"saveNoBatt": "이 게임은 카트리지에 저장 데이터를 남기지 않습니다.",
"saveNone": "저장 데이터가 없습니다.",
"saveWrongFile": "{n}에 맞는 파일이 아닙니다.",
"saveCartIn": "{n}의 저장을 가져왔습니다. ROM을 저장하거나 기기에 기록하세요. 이전 실행 상태는 초기화됩니다.",
"t7SaveXDone": "{n}의 저장을 가져왔습니다. ROM을 저장하거나 기기에 기록하세요.",
"t7NoSave": "다마고치의 저장 데이터가 없습니다.",
"t7SaveInDone": "T7Emu 저장을 가져왔습니다. ROM을 저장하거나 기기에 기록하세요.",
"t7SaveNeed": "ROM에 T7Emu가 없습니다. 에뮬레이터 탭에서 타마고 ROM을 먼저 추가하세요.",
"saveT18Need": "ROM에 T18Emu가 없습니다. 에뮬레이터 탭에서 TG18 펌웨어를 먼저 추가하세요.",
"saveEmuAny": "에뮬레이터 저장(.sav / .bin)",
"emuUse": "홈 화면에서 A+C로 실행하고 휠을 길게 눌러 저장·종료합니다. TamaEmu가 멈췄다면 A+C로 실행하고 버튼을 놓은 뒤 3초 안에 휠을 누르고 A로 확인하세요. 게임 자체의 저장에서 다시 시작합니다.",
"emuNone": "선택한 에뮬레이터가 없습니다.",
"petT": "저장 데이터 편집",
"petOpen": "파라다이스 저장 열기",
"petRom": "ROM 내부 저장",
"petClose": "닫기",
"petRomDone": "변경 사항을 적용했습니다. 새 ROM을 저장하거나 기기에 기록하세요.",
"petLevel": "레벨",
"petChar": "다마고치",
"petCare": "배부름·행복·건강 회복",
"petSave": "수정한 저장 파일 저장",
"petKeep": "변경 없음",
"petKid": "유아기",
"petYoung": "성장기",
"petAdult": "성체",
"petNow": "저장 상태: 레벨 {l}, 다마고치 {c}, 배부름 {h}/6, 행복 {j}/20{s}.",
"petSick": " · 아픔",
"petOther": "현재 ROM과 다른 에디션의 저장입니다.",
"petNoSet": "저장 데이터에 설정 영역이 없습니다.",
"petDone": "{n} 저장 완료. ‘저장 데이터를 기기에 기록’으로 전송하세요.",
"petNothing": "변경한 내용이 없습니다.",
"tabSave": "저장 관리",
"tabNames": "이름",
"cardNoChars": "이 카드에는 캐릭터가 없습니다",
"noRoomFrag": "전체 여유 공간은 있지만 연속 공간이 부족합니다(DOOM WAD에는 큰 연속 공간이 필요합니다). 프로그램을 제거하거나 DOOM 음악을 끄세요.",
"noRoomKB": "약 {k} KB가 부족합니다. 프로그램을 제거하세요. 마지막 64 KB는 기록 중단 복구용으로 남겨 둡니다.",
"noRoomAdd": "{n}을 넣으려면 약 {k} KB가 더 필요합니다. 마지막 64 KB는 기록 중단 복구용입니다.",
"eyeMvT": "눈 위치 이동",
"mouthMvT": "입 위치 이동",
"poseNr": "자세 {i} / {n}",
"faceBig": "큰 캐릭터",
"faceSmall": "작은 캐릭터",
"poseOnly": "현재 자세만",
"poseOnlyHint": "화살표로 현재 표시된 자세의 눈·입만 이동합니다. 직접 만든 캐릭터의 특정 자세를 맞출 때 사용하세요.",
"eyeMvHint": "기록 후 해당 지역에서 새로 부화하거나 성장한 다마고치에 적용합니다. 작은 캐릭터는 이동량이 절반입니다.",
"planEyes": "눈과 입",
"namesHint": "본체에서 사용할 지역 이름과 다마고치 이름 및 아이템 이름을 수정합니다.",
"namesFields": "지역",
"namesChars": "다마고치",
"namesItems": "아이템",
"namesFind": "검색",
"namesUndo": "모두 초기화",
"planNames": "이름",
"planNamesN": "{n}개 변경",
"saveParaOut": "파라다이스 저장(.tamasave)",
"saveEmuOut": "TamaEmu 저장(.sav)",
"saveInfo": "내보내기는 현재 ROM에서 저장 데이터를 추출합니다. 에뮬레이터 저장은 ROM에 가져온 뒤 파일로 저장하거나 기기에 기록합니다. 파라다이스 저장은 기기로 직접 기록하므로 먼저 연결하세요.",
"saveOutT": "내보내기",
"saveInT": "가져오기",
"saveSecProg": "프로그램",
"saveSecPara": "파라다이스",
"saveParaOutB": "내보내기(.tamasave)",
"saveParaInB": "기기에 기록(.tamasave)",
"saveProgInfo": "선택한 프로그램의 저장을 현재 ROM에서 내보냅니다. 가져온 저장은 ROM 파일을 저장하거나 기기에 기록해야 적용됩니다.",
"saveParaInfo": "현재 ROM에서 파라다이스 저장을 내보냅니다. ‘기기에 기록’은 연결한 기기에 직접 적용합니다. 슬롯으로 대상을 선택하세요.",
"saveSlotL": "슬롯",
"slotLive": "{n}(사용 중)",
"slotEmpty": "{n}(비어 있음)",
"slotNone": "이 슬롯에는 저장 데이터가 없습니다.",
"slotField": "저장은 {a}용이고 슬롯은 {b}용입니다.",
"slotDevOther": "기기의 메뉴가 현재 ROM과 다릅니다. 먼저 기기에서 ROM을 읽으세요.",
"slotSure": "기기의 {n} 슬롯에 기록하며 기존 저장을 교체합니다. 계속할까요?",
"slotDone": "기기의 {n} 슬롯 교체 완료.",
"saveNoProg": "ROM에 프로그램이 없습니다. TamaEmu 저장에는 에뮬레이터가 함께 들어 있습니다. T7Emu·T18Emu는 에뮬레이터 탭에서 먼저 추가하세요.",
"saveBtnOut": "내보내기({f})",
"saveBtnIn": "가져오기({f})",
"saveEmuInDone": "TamaEmu 저장을 가져왔습니다({d}). ROM을 저장하거나 기기에 기록하세요.",
"saveEmuOther": "ROM의 TamaEmu는 {a}용이며 저장 데이터는 {b}용입니다. 그래도 가져올까요?",
"saveNoRoom": "이 ROM에는 TamaEmu를 넣을 공간이 없습니다.",
"saveEmuBad": "이 프로그램에 맞는 저장 파일이 아닙니다.",
"saveNoEmu": "ROM에 에뮬레이터가 없습니다.",
"saveDone": "{n} 저장 완료.",
"saveNoClock": "{n} 저장 완료. 시계는 포함되지 않으므로 필요하면 앱에서 설정하세요.",
"devSaveRead": "저장 데이터 백업",
"devSaveWrite": "저장 데이터를 기기에 기록",
"devSaveHint": "백업에는 파라다이스 저장·시계와 TamaEmu 또는 T7Emu 저장이 포함됩니다. 이 버튼으로는 파라다이스 저장만 기기에 기록합니다.",
"devSaveSure": "기기({ed})의 현재 저장을 선택한 데이터로 교체합니다. 계속할까요?",
"devSaveDone": "{w}개 페이지 기록 완료. {c} 본체를 재시작할 수 있습니다.",
"devSaveClock": "시계를 적용했습니다.",
"devSaveClockNo": "본체에서 시계를 맞추세요.",
"devSaveGot": "백업 완료: {n}.",
"fl_saveOtherEd": "다른 에디션의 저장입니다(파일: {s}, 기기: {d})",
"fl_saveFamily": "이 에디션에 맞는 저장이 아닙니다",
"fl_saveNoSettings": "설정 영역이 없어 완전한 파라다이스 저장이 아닙니다",
"fl_saveOutside": "저장 영역 밖의 {n}개 페이지는 기록하지 않습니다",
"fl_saveIncomplete": "일부 페이지가 없습니다. 누락된 부분은 기기의 데이터를 유지합니다",
"emuUndo": "선택 취소",
"progMain": "A+C로 실행",
"progMainL": "메뉴의 첫 항목",
"progMenu": "메뉴에서 실행",
"progGone": "저장 시 삭제",
"progUndo": "되돌리기",
"progDel": "제거",
"progNone": "펌웨어 또는 ROM을 선택하세요. 이후 추가한 프로그램은 본체 메뉴에 들어갑니다.",
"appBadMain": "{f}: 컬러 다마고치·TG18은 실행 전용 구성에서만 추가 프로그램으로 넣을 수 있습니다. 다른 구성에서는 위 에뮬레이터를 ×로 먼저 제거하세요.",
"emuInList": "ROM의 추가 프로그램: {n}. 다시 선택할 필요가 없습니다.",
"doomLinkLess": " · DOOM과 함께 사용하면 {m} MB 감소",
"emuPack": "펌웨어 압축",
"emuPackHint": "공간을 절약합니다(iD L 약 1 MB). 식당 등 일부 화면은 느려질 수 있습니다.",
"packNeed": "이 펌웨어는 압축해야 들어갑니다. TamaEmu 항목의 ‘펌웨어 압축’을 켜세요.",
"packTip": " 팁: TamaEmu의 ‘펌웨어 압축’으로 공간을 절약할 수 있습니다.",
"emuNfc": "4U: NFC 칩 에뮬레이션",
"emuNfcHint": "메뉴가 버튼 한 번에 반응합니다. 끄면 이전 방식으로 동작합니다.",
"emuClock": "시작할 때 파라다이스 시간 가져오기",
"emuClockHint": "실행할 때마다 파라다이스의 시간으로 맞춥니다. 실행하지 않은 시간의 플레이는 재현하지 않습니다.",
"emuAuto": "전원을 켜면 자동 실행",
"emuAutoHint": "휠을 길게 누르면 파라다이스로 돌아갑니다. A+C 또는 리셋 버튼으로 다시 실행합니다.",
"autoHintL": "전원을 켤 때 메뉴 대신 실행합니다. B를 누른 채 켜면 메뉴가 나옵니다.",
"emuHas": "이 ROM에 에뮬레이터가 들어 있습니다.",
"emuBig": "펌웨어가 커서 지역 전환 기능을 함께 넣을 공간이 없습니다.",
"emuUp": "저장할 때 새 에뮬레이터 버전을 넣습니다. ‘저장 데이터 유지’를 켜면 저장을 유지합니다.",
"emuOk": "펌웨어 인식됨({size}). 저장할 때 추가합니다.",
"emuBad": "펌웨어 인식 실패: {e}",
"t18Ok": "미츠·온용 TG18 펌웨어를 인식했습니다(T18Emu). 저장할 때 추가합니다.",
"t18Has": "이 ROM에 T18Emu가 들어 있습니다.",
"t18Use": "홈 화면에서 A+C로 실행합니다. 휠을 길게 누르면 저장하고 종료합니다. 실행이 멈추면 A+C로 다시 시작한 뒤 3초 안에 휠을 누르세요. A로 확인하면 저장한 게임에서 다시 시작합니다.",
"emuGone": "저장할 때 에뮬레이터를 제거합니다.",
"emuMissing": "이 배포본에는 에뮬레이터 프로그램이 없습니다.",
"emuFail": "에뮬레이터 추가 실패: {e}",
"savedEmu": "저장 완료: {name}",
"t18Pics": "성장 화면 이미지",
"t18PicsPick": "이미지 선택",
"t18PicsDel": "이미지 제거",
"t18PicsOk": "이미지 {n}개 적용.",
"t18PicsUnknown": "{f}: 알 수 없는 이름",
"t18PicsHint": "성장 화면에 표시할 PNG입니다. 파일 이름은 캐릭터 이름(Mametchi.png 등) 또는 번호(16.png)로 지정하세요. Android T18Emu의 erwachsen 폴더도 지원합니다(erwachsen.json 포함 전체 선택). 64×64로 조정합니다.",
"t18Items": "아이템",
"t18ItemsPick": "MyMeets 파일 선택",
"t18ItemsNoSave": "게임을 한 번 실행한 뒤 기기에서 ROM을 읽어야 아이템을 적용할 수 있습니다.",
"t18ItemsHint": "아이템·방·포인트를 게임 저장에 적용합니다. ‘저장 데이터 유지’를 켜도 기기의 T18Emu 저장을 파일의 것으로 교체합니다. 다마고치는 유지하고 실행 상태는 초기화합니다.",
"t18ItemsNone": "파일에 아이템이 없습니다.",
"t18ItemsOther": "{n}은 미츠·온이 아닌 {m}용입니다. 동작하지 않을 수 있습니다.",
"t18ItemsFull": "공간 부족",
"mmTitle": "MixingMeets(방문·결혼)",
"uartBusy": "도구가 어댑터에 연결되어 있어 브리지를 사용할 수 없습니다.",
"uartFree": "UART 연결 해제",
"uartFreed": "어댑터를 해제했습니다. 게임을 실행하려면 본체를 재시작하세요.",
"uartRun": "기기 작업이 끝날 때까지 기다리세요.",
"pairTitle": "파라다이스 두 대 연결(방문·게임)",
"pairHint": "두 기기의 상단 단자를 연결하고 모두 T18Emu를 실행합니다. 양쪽에서 CONNECTION → TAMAGOTCHI를 선택한 뒤 실제 기기처럼 진행하세요.",
"pairHintDigi": "두 기기의 상단 단자를 연결하고 모두 V1Emu의 디지몬을 실행합니다. 실제 디지몬 두 대처럼 배틀을 선택하고 시작하세요.",
"pairHintPs": "두 기기를 상단으로 연결하고 TamaEmu(P's)를 실행합니다. 양쪽에서 연결 → たまごっちP's → あそぶ. 한쪽에서는 あそびにいく를 선택하세요. 다른 쪽에서는 ともだちをよぶ → ふたりで → 게임 → B를 선택하세요.",
"pairHintIdl": "두 기기를 상단으로 연결하고 TamaEmu(iD L)를 실행합니다. 양쪽 게임의 연결 메뉴에서 실제 iD L처럼 진행하세요.",
"pairHintV3": "두 기기를 상단으로 연결하고 V3Emu를 실행합니다. 양쪽 게임의 연결 메뉴에서 실제 V3처럼 진행하세요.",
"pairHintT7": "두 기기를 상단으로 연결하고 T7Emu(타마고)를 실행합니다. 양쪽에서 연결 → TAMA-GO → VISIT 또는 GAME. 방문하는 기기에서 B를 누르세요.",
"mmLink": "Paramix 브리지",
"mmDrag": "북마크 바로 끌어 놓은 뒤 mixing-meets.com에서 클릭하세요.",
"mmHint": "1. Paramix 브리지 버튼을 Chrome·Edge 북마크 바로 끌어 놓습니다.\n2. UART 연결을 해제하거나 도구를 닫습니다. 기록할 때처럼 어댑터를 연결하고 본체에서 CONNECTION → APP → VISIT를 선택합니다. 돌아올 때는 A → GO BACK → YES.\n3. mixing-meets.com의 Connect 또는 Return에서 북마크를 누른 뒤 Select Tamagotchi로 어댑터를 선택합니다.\n페이지를 이동할 때마다 북마크를 다시 누르세요.",
"t7Gp": "고치 포인트",
"t7GpHint": "저장 가져오기처럼 ROM에 적용합니다. 다마고치는 유지하고 실행 상태는 초기화합니다. 본체에서 DOWNLOAD를 선택하세요.",
"t18KeepAsk": "T18Emu 아이템 또는 포인트가 변경되었습니다. ‘저장 데이터 유지’를 켜도 기기의 해당 저장을 ROM을 읽은 시점의 저장으로 교체합니다. 계속할까요?",
"t18ItemNo": "번호 {n}",
"t18ItemOk": "{n}을 {k}에 넣었습니다.",
"t18Points": "다마포인트",
"t18A_food": "음식",
"t18A_item": "아이템",
"t18A_acc": "액세서리",
"t18A_room": "방",
"t18RoomBack": "사용자 방 제거",
"t18RoomBuiltin": "기본 방",
"dlcPick": "다운로드 콘텐츠 추가",
"dlcInfo": "사용 중인 슬롯 보기",
"progMore": "설정과 콘텐츠",
"progMakeMain": "주 프로그램으로 지정",
"progIsMain": "주 프로그램",
"v1Ok": "초기 다마고치 또는 디지몬을 인식했습니다(V1Emu).",
"v3Ok": "다마고치 커넥션 V3를 인식했습니다(V3Emu).",
"v3Use": "홈 화면에서 A+C를 누르면 실행합니다. 휠을 짧게 누르면 설정이 열립니다. 길게 누르면 파라다이스로 돌아갑니다.",
"optVol": "소리 크기",
"optVolN": "보통",
"optVolQ": "작게",
"optVolL": "크게",
"optOff": "끔",
"optDim": "밝기",
"optScr": "화면 자동 꺼짐",
"optDev": "본체에서도 휠을 짧게 눌러 설정할 수 있습니다. 본체 설정은 웹에서 다시 변경하기 전까지 유지됩니다.",
"optScrToy": "원래 기기 설정",
"v1Use": "홈 화면에서 A+C를 누르면 실행합니다. 휠을 짧게 누르면 설정이 열립니다. 휠을 돌리면 흔들고 길게 누르면 파라다이스로 돌아갑니다.",
"progNoMainDoom": "DOOM이 주 프로그램입니다. 바꾸려면 DOOM을 ×로 먼저 제거하세요.",
"doomAutoHint": "휠을 2초 누르면 파라다이스로 돌아가 그대로 유지됩니다.",
"progReplaced": "주 프로그램을 {o}에서 {n}으로 바꿨습니다.",
"mainAuto": "모든 프로그램이 들어가도록 {n}을 메뉴의 첫 항목으로 바꿨습니다.",
"mainNoRoom": "첫 항목으로 바꾸려면 약 {k} KB가 더 필요합니다. 기존 구성을 유지합니다.",
"appTwice": "{n}은 이미 들어 있습니다.",
"progNoMainV1": "V1Emu는 본체 메뉴에서만 실행합니다",
"progNoMain": "실행 전용 구성에서만 가능",
"progMainNow": "{n}이 주 프로그램입니다. 위치가 바뀐 프로그램들의 저장이 초기화됩니다.",
"dlcLoading": "읽는 중…",
"dlcNewArea": "에뮬레이터의 메모리 배치를 다시 구성합니다. 기록 후 해당 저장이 초기화됩니다.",
"dlcHint": "음식·옷·액세서리·게임 등의 .jpg 다운로드 파일 또는 .zip을 선택하세요. 여러 파일을 함께 선택할 수 있습니다. P's의 VDP는 세트 전체를 선택하세요.",
"dlcFreeN": "{n}개 남음",
"dlcDel": "제거",
"dlcK0": "식사",
"dlcK1": "간식",
"dlcK2": "의상",
"dlcK3": "액세서리",
"dlcK4": "아이템",
"dlcK5": "일상용품",
"dlcK6": "배경",
"dlcK7": "게임",
"dlcK8": "방문 장소",
"dlcK10": "VDP 레시피",
"dlcK15": "장식",
"dlcK16": "쿠폰",
"dlcK17": "빙고",
"dlcK18": "가챠",
"dlcK19": "캐릭터",
"dlcOk": "{n}을 {k}의 {s}번 슬롯에 넣었습니다.",
"dlcBad": "{f}: {e}",
"dlcGone": "{n} 제거 완료.",
"figField": "지역:",
"figAll": "전체",
"zipField": "지역을 ZIP으로 내보내기",
"fieldZipOk": "{f}: 캐릭터 {n}개와 이미지 {s}개를 ZIP으로 내보냈습니다.",
"fieldIn": "지역 ZIP 가져오기",
"fieldInBad": "지역 ZIP이 아닙니다(field.json 없음).",
"fieldInOk": "{src} → {dst}: {n}개 부분 적용.",
"fieldInEyes": "눈 이미지가 너무 큰 캐릭터 {k}개는 원본을 유지합니다.",
"zipFigs": "모든 캐릭터 ZIP",
"zipAll": "전체 이미지 ZIP",
"upload": "이미지 시트 가져오기(PNG·ZIP)",
"numbers": "번호 확인용 ROM",
"figHint": "캐릭터는 큰 모습·작은 모습 각각의 몸·눈·입으로 구성됩니다. 캐릭터를 누르면 이미지 시트를 볼 수 있습니다.",
"allHint": "배경, 메뉴, 아이템, 글꼴 이미지입니다.",
"moreColors": "더 많은 색상 허용(최대 256색)",
"dimLoad": "카드 열기",
"dimHint": "캐릭터 카드(4 MB) 또는 TamaSma 카드(1·2 MB) 덤프를 엽니다. 성체 교체에 적합합니다. 아기·유아·성장기는 눈을 공유하므로 원본을 유지합니다.",
"dimPick": "카드 캐릭터",
"dimTarget": "교체할 캐릭터",
"dimApply": "적용",
"dimEgg": "카드의 알 적용",
"dimBaby": "아기",
"dimNone": "카드를 열면 캐릭터가 표시됩니다.",
"download": "이미지 시트 다운로드",
"uploadOne": "이미지 시트 가져오기",
"reset": "원본으로 복원",
"close": "닫기",
"working": "잠시만 기다려 주세요…",
"dimNr": "번호",
"stUpd": "저장 시 업데이트",
"disclaimer": "기기 변경·기록으로 기기가 동작하지 않거나 저장 데이터가 지워질 수 있습니다. 먼저 원본을 백업하고 작업 내용을 이해한 뒤 사용하세요. 도구는 보증 없이 제공되며 기기·데이터 손상에 대한 책임을 지지 않습니다.",
"trademarks": "Tamagotchi·Digimon은 BANDAI의 상표입니다. DOOM·Wolfenstein은 id Software(ZeniMax Media)의 상표입니다. Game Boy·Pokémon mini는 Nintendo의 상표입니다. SEGA·Master System은 SEGA의 상표입니다. Arduboy는 Arduboy Inc.의 상표입니다. 상표·게임·캐릭터는 각 권리자의 소유이며 호환성 설명을 위해 언급합니다. 공식 제품이 아니며 해당 회사와 관련이 없습니다. 도구에 게임·펌웨어·게임 데이터는 포함되지 않습니다. 본인의 파일을 사용하세요.",
"devWarn": "기록 전 원본을 백업하고 기록 중에는 전원을 유지하세요. 기기 기록에 대한 보증은 제공되지 않습니다.",
"footer": "파일 열기와 편집은 브라우저에서 처리합니다. 원작: mameise · 한국어판: ITOSM.",
"edition": "에디션",
"sprites": "이미지",
"figures": "캐릭터",
"changed": "변경됨",
"space": "캐릭터 여유 공간",
"figure": "캐릭터",
"sprite": "이미지",
"mSize": "칸 {w}×{h}, 이미지 {n}개, 격자 {iw}×{ih}",
"mColors": "{c}, 팔레트 세트: {p}",
"mDirect": "직접 색상 RGB565",
"mPal": "{n}색",
"mKeep": "여러 팔레트 세트(색상 변형): 가져오는 이미지에 원본 색상을 사용합니다.",
"mSheet": "시트 {w}×{h}px. 격자가 맞도록 크기를 유지하세요.",
"mGroupRows": "행 순서: 몸(20), 눈(20), 입(18), 작은 몸(24), 작은 눈(14), 작은 입(14).",
"notRom": "파라다이스 덤프가 아닙니다: {e}",
"loaded": "{ed} 열기 완료: 이미지 {s}개, 캐릭터 {f}개.",
"saved": "저장 완료: {name}\n이미지 {n}개를 변경했습니다. 남은 공간은 {kb} KB입니다.",
"nothing": "변경한 내용이 없습니다.",
"tooBig": "여유 공간을 초과합니다. {e}",
"upOk": "적용됨: {n}",
"upSkip": "건너뜀: {list}",
"upNone": "일치하는 파일이 없습니다. figur_0237.png 또는 sprite_0014.png 형식이어야 합니다.",
"sprSix": "추가 지역의 이미지는 수정할 수 없습니다.",
"wrongSize": "{f}: {e}",
"resetOk": "원본으로 복원했습니다.",
"dimOk": "카드 캐릭터 {d}을 캐릭터 {g}에 적용했습니다.",
"eggOk": "알을 교체했습니다.",
"numOk": "캐릭터마다 번호를 표시하도록 바꿨습니다. ROM을 저장·기록한 뒤 성장 단계별로 표시되는 번호를 확인하세요.",
"notDim": "알 수 없는 카드: {e}",
"leave": "저장하지 않은 변경 사항이 있습니다.",
"roleFallback": "대체 캐릭터",
"roleBaby": "아기",
"roleAdult": "첫 성체",
"eyeHint": "분홍 테두리는 눈입니다. 눈 레이어로 옮겨 깜빡임과 눈 표시를 유지합니다. 잘못 잡혔다면 눈을 클릭하세요.",
"eyeNone": "보이는 눈이 없는 캐릭터",
"dimEyesTooBig": "눈 이미지가 너무 복잡해 눈 레이어를 적용하지 않았습니다.",
"roleFallbackText": "캐릭터를 불러오지 못할 때 표시됩니다. 원본 유지를 권장합니다.",
"roleBabyText": "알에서 부화합니다.",
"roleAdultText": "여기부터 각 캐릭터가 고유한 눈을 사용합니다.",
"mEyes": "눈 이미지의 바이트 크기를 유지해야 합니다. 너무 복잡한 눈은 거부하며 크기가 맞지 않으면 대체 캐릭터가 부화할 수 있습니다.",
"mColorsFig": "원본 색상만 사용하면 게임의 개체별 색상 변경을 유지합니다. 새 색상은 고정 색상으로 적용합니다(최대 8색과 외곽선).",
"fl_timeout": "기기 응답 시간 초과({c} {a})",
"fl_noAck": "기기가 응답하지 않습니다. 다운로드 화면인지 확인하세요.",
"fl_repeats": "로드 재시도가 너무 많습니다",
"fl_devCancel": "기기에서 로드를 취소했습니다",
"fl_unexpected": "예상하지 못한 응답: {r}",
"fl_hello": "HELLO에 대한 응답이 올바르지 않습니다",
"fl_notReady": "플래시가 준비되지 않았습니다",
"fl_readErr": "{a} 읽기 오류",
"fl_noCrc": "{a}의 체크섬이 없습니다",
"fl_cancelled": "취소됨",
"fl_size": "ROM 이미지 크기는 정확히 16 MB여야 합니다",
"fl_notParadise": "파라다이스 이미지가 아닙니다(SONIXDEV 없음)",
"fl_cancelledWrite": "기록 취소됨. 본체 전원을 유지하고 다시 기록하세요",
"fl_notAccepted": "섹터 {a}을 받지 못했습니다. 전원을 유지하고 다시 기록하세요",
"fl_differs": "기록 후 섹터 {a}이 일치하지 않습니다. 전원을 유지하고 다시 기록하세요",
"fl_checkFail": "{a} 검증 실패. 전원을 유지하고 다시 기록하세요",
"fl_rescueBusy": "복구 영역(0xFF0000)이 사용 중입니다",
"fl_rescueMode": "이전 기록이 중단되었습니다. 본체의 기록 화면에서 다시 기록하세요.",
"fl_rescueFail": "복구 시작 프로그램 기록이 올바르지 않습니다",
"fl_noRescue": "복구 시작 불가: 0xFF0000이 사용 중입니다",
"fl_noAnswer": "응답이 없습니다. 본체를 다운로드 화면으로 전환하고 다시 시도하세요",
"fl_noData": "어댑터에서 데이터가 전혀 들어오지 않습니다. 다운로드 화면에서 다시 시도하고 케이블·드라이버를 확인하세요",
"fl_garbled": "데이터를 읽을 수 없습니다({n}바이트: {h}). TX·RX 배선과 어댑터 드라이버를 확인하세요",
"fl_lost": "기록 전에 기기 응답이 끊겨 아무것도 기록하지 않았습니다. 전원을 껐다 켜고 다운로드 화면에서 다시 연결하세요",
"fl_appSilent": "기록 프로그램을 전송했지만 응답하지 않습니다. 다시 시도하세요",
"fl_unknownEd": "새 ROM의 에디션을 알 수 없습니다. ‘저장 데이터 유지’를 해제하세요",
"fl_otherEd": "기기는 {d}입니다. 새 ROM은 {r}입니다. 에디션을 바꾸려면 ‘저장 데이터 유지’를 해제하세요",
"fl_noteNoFit": "지역 {f}의 저장이 새 슬롯에 맞지 않아 유지하지 않습니다",
"fl_noteMoved": "지역 {f}의 저장을 새 슬롯으로 옮겼습니다",
"fl_noteSaveMoved": "{n}의 저장을 보존했습니다",
"fl_noteDropped": "새 ROM에 지역 메뉴가 없어 기기에 보관된 지역별 저장이 삭제됩니다",
"fl_noteEdKept": "기기({d})와 새 ROM({r})은 같은 펌웨어를 사용합니다. 기기의 저장 데이터와 지역({d})을 유지합니다",
"fl_noteEmu": "TamaEmu 펌웨어를 새로 선택해 초기 상태로 시작합니다. 업데이트만 하려면 기존 ROM을 열고 저장하세요",
"menuKo": "본체 A+C 메뉴를 한국어로 만들기",
"menuKoHint": "A+C 메뉴의 화면과 다마고치 및 아이템 이름을 한국어로 표시합니다."
};
T.en.menuKo="Korean A+C device menu";
T.en.menuKoHint="Experimental Korean device menu: PC preview and build checks only; hardware, save and restore are not yet verified. Back up your ROM and saves before applying. Original game, emulator settings and names read from your ROM remain unchanged.";
T.de.menuKo=T.en.menuKo;T.de.menuKoHint=T.en.menuKoHint;
/* ITOSM_KO_END */
let lang = 'de';
try { lang = localStorage.getItem('paramix-lang') || 'ko'; } catch (e) {}
if (!T[lang]) lang = 'en';
function t(k, vars) { let s = (T[lang][k] ?? T.en[k] ?? k); if (vars) for (const [a, b] of Object.entries(vars)) s = s.split('{' + a + '}').join(b); return s; }
/* Messages of the modules (core, emu, doom, feld) are English; the German page
translates them here. Placeholders ($1, $2) carry numbers and names. */
const MSG_KO = [
[/^no ARC2 archive at (\S+)$/, '$1에 ARC2 아카이브가 없습니다'],
[/^unknown bpp (\S+)$/, '알 수 없는 색상 깊이: $1'],
[/^subimage count does not match$/, '부분 이미지 개수가 다릅니다'],
[/^subimage size does not match$/, '부분 이미지 크기가 다릅니다'],
[/^eye image too detailed: (\d+) bytes, at most (\d+) allowed$/, '눈 이미지가 너무 큽니다: $1바이트, 최대 $2바이트'],
[/^not a Paradise flash dump \(SONIXDEV header missing\)$/, '파라다이스 덤프가 아닙니다(SONIXDEV 헤더 없음)'],
[/^unexpected asset archive \((\d+) files\)$/, '예상하지 못한 자료 구성(파일 $1개)'],
[/^too big: assets would end at (\S+), free space ends at (\S+)$/, '데이터가 $1까지 필요하지만 여유 공간은 $2까지입니다'],
[/^checksum wrong at (\S+)$/, '$1 체크섬 오류'],
[/^(?:character )?sheet must be (\S+) px, got (\S+)$/, '시트 크기는 $1px여야 합니다(현재 $2)'],
[/^no sprite package$/, '이미지 패키지가 없습니다'],
[/^not a ZIP file$/, 'ZIP 파일이 아닙니다'],
[/^unsupported ZIP compression in (.+)$/, '$1: 지원하지 않는 ZIP 압축 방식'],
[/^firmware not recognised \(expected a 4 MB or 8 MB image of a colour Tamagotchi\)$/, '컬러 다마고치의 4 MB 또는 8 MB 펌웨어가 필요합니다'],
[/^scene table not found$/, '장면 표를 찾지 못했습니다'],
[/^firmware too big: (\d+) blocks$/, '펌웨어가 너무 큽니다: $1블록'],
[/^no room for the spare pages$/, '여분 페이지를 넣을 공간이 없습니다'],
[/^launcher template does not fit$/, '실행 프로그램 형식이 맞지 않습니다'],
[/^the Paradise image must be 16 MB$/, '파라다이스 이미지 크기는 16 MB여야 합니다'],
[/^home screen not found$/, '홈 화면을 찾지 못했습니다'],
[/^area (\S+) is in use$/, '$1 영역이 사용 중입니다'],
[/^emulator program too big$/, '에뮬레이터 프로그램이 너무 큽니다'],
[/^program too big$/, '프로그램이 너무 큽니다'],
[/^settings block missing in the program$/, '프로그램의 설정 영역이 없습니다'],
[/^no emulator built in$/, '설치된 에뮬레이터가 없습니다'],
[/^no download content in the file$/, '파일에 다운로드 콘텐츠가 없습니다'],
[/^content checksum does not match$/, '콘텐츠 체크섬이 다릅니다'],
[/^this content fits no store of this firmware$/, '이 펌웨어에 맞는 콘텐츠 저장 영역이 없습니다'],
[/^content too big for its store$/, '콘텐츠가 저장 영역보다 큽니다'],
[/^only for the 8 MB firmware$/, '8 MB 펌웨어에서만 지원합니다'],
[/^no matching store$/, '맞는 저장 영역이 없습니다'],
[/^already added$/, '이미 추가했습니다'],
[/^(.+): all slots used, remove one first$/, '$1: 슬롯이 가득 찼습니다. 하나를 먼저 제거하세요'],
[/^no such slot$/, '해당 슬롯이 없습니다'],
[/^not a TG18 firmware \(8 MB\)$/, 'TG18 펌웨어(8 MB)가 아닙니다'],
[/^not enough room: the firmware needs (\d+) blocks of 64 KB, (\d+) are free$/, '64 KB 블록 $1개가 필요하지만 $2개만 비어 있습니다'],
[/^T18Emu program incomplete \(flash part missing\)$/, 'T18Emu 프로그램이 불완전합니다(플래시 부분 없음)'],
[/^the menu is already built in$/, '본체 메뉴가 이미 설치되어 있습니다'],
[/^more fields need a Tropical, Glacier or Jade Forest ROM with the original firmware$/, '지역 확장에는 원본 펌웨어의 트로피컬·글레이셔·제이드 포레스트 ROM이 필요합니다'],
[/^rain pictures too big$/, '비 이미지가 너무 큽니다'],
[/^unexpected Jade Forest data$/, '예상하지 못한 제이드 포레스트 데이터'],
[/^helper page full$/, '보조 페이지가 가득 찼습니다'],
[/^table (\S+) missing$/, '$1 표가 없습니다'],
[/^the second ROM must be a Land, Water or Sky ROM$/, '두 번째 파일은 랜드·워터·스카이 ROM이어야 합니다'],
[/^six fields program missing$/, '여섯 지역 프로그램이 없습니다'],
[/^unexpected map picture$/, '예상하지 못한 지역 이미지'],
[/^unexpected Land picture (\d+)$/, '예상하지 못한 랜드 이미지 $1'],
[/^composite table full$/, '합성 이미지 표가 가득 찼습니다'],
[/^menu program too old for six fields$/, '여섯 지역을 지원하지 않는 구버전 메뉴입니다'],
[/^edition not recognised$/, '에디션을 인식하지 못했습니다'],
[/^nothing chosen$/, '선택한 내용이 없습니다'],
[/^no room for the launcher$/, '실행 프로그램을 넣을 공간이 없습니다'],
[/^no room for the menu next to DOOM$/, 'DOOM과 함께 메뉴를 넣을 공간이 없습니다'],
[/^no room for the saves next to DOOM$/, 'DOOM과 함께 저장 데이터를 넣을 공간이 없습니다'],
[/^menu program too big$/, '본체 메뉴가 허용 용량을 초과합니다'],
[/^the area for the menu is in use$/, '메뉴 영역이 사용 중입니다'],
[/^no room for the saves$/, '저장 데이터를 넣을 공간이 없습니다'],
[/^the area for the saves is in use$/, '저장 영역이 사용 중입니다'],
[/^settings block of the menu missing$/, '메뉴의 설정 영역이 없습니다'],
[/^the stored save of (.+) does not fit here$/, '$1의 저장이 이 영역에 맞지 않습니다'],
[/^not a WAD file$/, 'WAD 파일이 아닙니다'],
[/^no DOOM maps in the WAD \(DOOM 2 is not supported\)$/, 'WAD에 DOOM 지도가 없습니다(이 구성에서는 DOOM 2 미지원)'],
[/^no picture$/, '이미지가 없습니다'],
[/^broken$/, '손상된 데이터입니다'],
[/^WAD conversion failed$/, 'WAD 변환 실패'],
[/^the character data reaches (\S+), DOOM needs 0x830000 onwards$/, '캐릭터 데이터가 $1까지 사용합니다. DOOM은 0x830000 이후가 필요합니다'],
[/^DOOM program too big$/, 'DOOM 프로그램이 너무 큽니다'],
[/^WAD too big: (\d+) KB, room (\d+) KB \(try without music\)$/, 'WAD $1 KB, 여유 공간 $2 KB. 음악을 끄고 시도하세요'],
[/^this DOOM has no key layout of its own yet$/, '이 DOOM은 개별 버튼 설정을 지원하지 않습니다'],
[/^fire, forward and back need three different buttons$/, '발사·전진·후진은 서로 다른 버튼이어야 합니다'],
[/^use needs its own button or the wheel$/, '사용은 별도의 버튼 또는 휠이어야 합니다'],
[/^no room for the field saves next to this emulator firmware$/, '이 펌웨어와 함께 지역 저장을 넣을 공간이 없습니다'],
[/^the character data reaches (\S+), the emulator needs 0x830000 onwards$/, '캐릭터 데이터가 $1까지 사용합니다. 에뮬레이터는 0x830000 이후가 필요합니다'],
[/^the stored saves do not fit into the room for the fields$/, '보관한 저장이 지역 저장 공간을 초과합니다'],
[/^unexpected planet table in the Land ROM$/, '랜드 ROM의 행성 표가 예상과 다릅니다'],
[/^not a Paradise save \(\.tamasave\)$/, '파라다이스 저장(.tamasave)이 아닙니다'],
[/^unknown save version (\S+)$/, '알 수 없는 저장 버전: $1'],
[/^save is cut off$/, '저장 데이터가 잘렸습니다'],
[/^no room for (.+) \((\d+) KB\)$/, '$1을 넣을 공간이 없습니다($2 KB)'],
[/^no room for (.+)$/, '$1을 넣을 공간이 없습니다'],
[/^only one T18Emu$/, 'T18Emu는 하나만 추가할 수 있습니다'],
[/^T18Emu needs the area at 0x0F0000, the main program uses it: choose T18Emu in the Emulator tab$/, 'T18Emu가 필요한 0x0F0000 영역을 주 프로그램이 사용합니다. 에뮬레이터 탭에서 T18Emu를 선택하세요'],
[/^(.+): only in a start device$/, '$1: 실행 전용 구성에서만 가능합니다'],
[/^too many scenes$/, '장면이 너무 많습니다']
];
const MSG_DE = [
[/^no ARC2 archive at (\S+)$/, 'kein ARC2-Archiv bei $1'],
[/^unknown bpp (\S+)$/, 'unbekannte Farbtiefe $1'],
[/^subimage count does not match$/, 'Anzahl der Teilbilder passt nicht'],
[/^subimage size does not match$/, 'Grösse der Teilbilder passt nicht'],
[/^eye image too detailed: (\d+) bytes, at most (\d+) allowed$/, 'Augenbild zu detailliert: $1 Byte, höchstens $2 erlaubt'],
[/^not a Paradise flash dump \(SONIXDEV header missing\)$/, 'kein Paradise-Flash-Dump (SONIXDEV-Kopf fehlt)'],
[/^unexpected asset archive \((\d+) files\)$/, 'unerwartetes Archiv ($1 Dateien)'],
[/^too big: assets would end at (\S+), free space ends at (\S+)$/, 'zu gross: die Daten würden bei $1 enden, der freie Platz endet bei $2'],
[/^checksum wrong at (\S+)$/, 'Prüfsumme falsch bei $1'],
[/^sheet must be (\S+) px, got (\S+)$/, 'das Sheet muss $1 px gross sein, ist aber $2'],
[/^character sheet must be (\S+) px, got (\S+)$/, 'das Figuren-Sheet muss $1 px gross sein, ist aber $2'],
[/^no sprite package$/, 'kein Sprite-Paket'],
[/^not a ZIP file$/, 'keine ZIP-Datei'],
[/^unsupported ZIP compression in (.+)$/, 'nicht unterstützte ZIP-Kompression in $1'],
[/^firmware not recognised \(expected a 4 MB or 8 MB image of a colour Tamagotchi\)$/, 'Firmware nicht erkannt (erwartet: 4-MB- oder 8-MB-Abbild eines Farb-Tamas)'],
[/^scene table not found$/, 'Szenentabelle nicht gefunden'],
[/^firmware too big: (\d+) blocks$/, 'Firmware zu gross: $1 Blöcke'],
[/^no room for the spare pages$/, 'kein Platz für die Ersatzseiten'],
[/^launcher template does not fit$/, 'Starter-Vorlage passt nicht'],
[/^the Paradise image must be 16 MB$/, 'das Paradise-Abbild muss 16 MB gross sein'],
[/^home screen not found$/, 'Heimbildschirm nicht gefunden'],
[/^area (\S+) is in use$/, 'Bereich $1 ist belegt'],
[/^emulator program too big$/, 'Emulator-Programm zu gross'],
[/^program too big$/, 'Programm zu gross'],
[/^settings block missing in the program$/, 'Einstellungsblock im Programm fehlt'],
[/^no emulator built in$/, 'kein Emulator eingebaut'],
[/^no download content in the file$/, 'kein Download-Inhalt in der Datei'],
[/^content checksum does not match$/, 'Prüfsumme des Inhalts stimmt nicht'],
[/^this content fits no store of this firmware$/, 'dieser Inhalt passt in kein Fach dieser Firmware'],
[/^content too big for its store$/, 'Inhalt zu gross für sein Fach'],
[/^only for the 8 MB firmware$/, 'nur für 8-MB-Firmware'],
[/^no matching store$/, 'kein passendes Fach'],
[/^already added$/, 'schon drin'],
[/^(.+): all slots used, remove one first$/, (m, a) => storeDe(a) + ': alle Plätze belegt, zuerst einen entfernen'],
[/^no such slot$/, 'kein solcher Platz'],
[/^not a TG18 firmware \(8 MB\)$/, 'keine TG18-Firmware (8 MB)'],
[/^not enough room: the firmware needs (\d+) blocks of 64 KB, (\d+) are free$/, 'zu wenig Platz: die Firmware braucht $1 Blöcke zu 64 KB, frei sind $2'],
[/^T18Emu program incomplete \(flash part missing\)$/, 'T18Emu-Programm unvollständig (Flash-Teil fehlt)'],
[/^the menu is already built in$/, 'das Menü ist schon eingebaut'],
[/^more fields need a Tropical, Glacier or Jade Forest ROM with the original firmware$/, 'mehr Felder gehen nur mit einem Tropical-, Glacier- oder Jade-Forest-ROM mit Original-Firmware'],
[/^rain pictures too big$/, 'Regenbilder zu gross'], [/^area 0xF00000 is in use$/, 'Bereich 0xF00000 ist belegt'], [/^unexpected Jade Forest data$/, 'unerwartete Jade-Forest-Daten'], [/^helper page full$/, 'Hilfsseite voll'], [/^table (\S+) missing$/, 'Tabelle $1 fehlt'],
[/^the second ROM must be a Land, Water or Sky ROM$/, 'das zweite ROM muss ein Land-, Water- oder Sky-ROM sein'],
[/^six fields program missing$/, 'Programm für 6 Felder fehlt'],
[/^unexpected map picture$/, 'unerwartetes Feldbild'],
[/^unexpected Land picture (\d+)$/, 'unerwartetes Land-Bild $1'],
[/^composite table full$/, 'Bildtabelle voll'],
[/^menu program too old for six fields$/, 'Menüprogramm zu alt für 6 Felder'],
[/^edition not recognised$/, 'Ausgabe nicht erkannt'],
[/^nothing chosen$/, 'nichts gewählt'],
[/^no room for the launcher$/, 'kein Platz für den Starter'],
[/^no room for the menu next to DOOM$/, 'neben DOOM ist kein Platz für das Menü'],
[/^no room for the saves next to DOOM$/, 'neben DOOM ist kein Platz für die Spielstände'],
[/^menu program too big$/, 'Menü-Programm zu gross'],
[/^the area for the menu is in use$/, 'der Bereich für das Menü ist belegt'],
[/^no room for the saves$/, 'kein Platz für die Spielstände'],
[/^the area for the saves is in use$/, 'der Bereich für die Spielstände ist belegt'],
[/^settings block of the menu missing$/, 'Einstellungsblock des Menüs fehlt'],
[/^the stored save of (.+) does not fit here$/, 'der gespeicherte Spielstand von $1 passt hier nicht hinein'],
[/^not a WAD file$/, 'keine WAD-Datei'],
[/^no DOOM maps in the WAD \(DOOM 2 is not supported\)$/, 'keine DOOM-Karten in der WAD (DOOM 2 wird nicht unterstützt)'],
[/^no picture$/, 'kein Bild'],
[/^broken$/, 'beschädigt'],
[/^WAD conversion failed$/, 'WAD-Umwandlung fehlgeschlagen'],
[/^the character data reaches (\S+), DOOM needs 0x830000 onwards$/, 'die Figuren-Daten reichen bis $1, DOOM braucht den Platz ab 0x830000'],
[/^DOOM program too big$/, 'DOOM-Programm zu gross'],
[/^WAD too big: (\d+) KB, room (\d+) KB \(try without music\)$/, 'WAD zu gross: $1 KB, Platz $2 KB (ohne Musik versuchen)'],
[/^this DOOM has no key layout of its own yet$/, 'dieses DOOM kennt noch keine eigene Tastenbelegung'],
[/^fire, forward and back need three different buttons$/, 'Schiessen, Vor und Zurück brauchen drei verschiedene Tasten'],
[/^use needs its own button or the wheel$/, 'Benutzen braucht eine eigene Taste oder das Rad'],
[/^no room for the field saves next to this emulator firmware$/, 'neben dieser Emulator-Firmware haben die Spielstände der Felder keinen Platz'],
[/^the character data reaches (\S+), the emulator needs 0x830000 onwards$/, 'die Figuren-Daten reichen bis $1, der Emulator braucht den Platz ab 0x830000'],
[/^the stored saves do not fit into the room for the fields$/, 'die gespeicherten Spielstände passen nicht in den Platz für die Felder'],
[/^script table full$/, 'Skripttabelle voll'],
[/^unexpected Land planet table$/, 'unerwartete Planetentabelle im Land-ROM'],
[/^not a Paradise save \(\.tamasave\)$/, 'kein Paradise-Spielstand (.tamasave)'],
[/^unknown save version (\S+)$/, 'unbekannte Spielstand-Version $1'],
[/^save is cut off$/, 'der Spielstand ist abgeschnitten'],
[/^no room for (.+) \((\d+) KB\)$/, 'kein Platz für $1 ($2 KB)'],
[/^no room for (.+)$/, 'kein Platz für $1'],
[/^only one T18Emu$/, 'T18Emu geht nur einmal'],
[/^T18Emu needs the area at 0x0F0000, the main program uses it: choose T18Emu in the Emulator tab$/, 'T18Emu braucht den Bereich ab 0x0F0000, das Hauptprogramm belegt ihn: T18Emu im Tab Emulator wählen'],
[/^(.+): only in a start device$/, '$1: nur im Startgerät'],
[/^launcher template does not fit$/, 'Starter-Vorlage passt nicht'],
[/^too many scenes$/, 'zu viele Szenen'],
];
function storeDe(label) { const k = ['Meals', 'Snacks', 'Clothing', 'Accessories', 'Items', 'Daily items', 'Wallpapers', 'Games', 'Destinations', '', 'VDP recipes', '', '', '', '', 'Decorations', 'Coupon', 'Bingo', 'Gashapon', 'Characters'].indexOf(label); return k < 0 ? label : t('dlcK' + k); }
function em(x) {
const s = x && typeof x === 'object' ? (x.message || String(x)) : String(x || '');
if (lang === 'en') return s;
if (lang === 'ko') { for (const [re, ko] of MSG_KO) if(re.test(s)) return s.replace(re,ko); return s; }
for (const [re, de] of MSG_DE) if (re.test(s)) return s.replace(re, de);
return s;
}
function applyLang() {
document.documentElement.lang = lang;
document.querySelectorAll('[data-t]').forEach(el => { el.textContent = t(el.dataset.t); });
document.querySelectorAll('[data-lang]').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.lang === lang)));
if (state.ctx) {
renderInfo(); renderDim(); renderFieldPick(); renderNames(); renderEmu(); renderDoom(); renderFeld(); renderSave();
{const chars=C.charTable(state.ctx.files[0]).filter(c=>c.id>1000&&c.id<9000);chars.forEach((c,i)=>state.charNames.set(state.ctx.groups[i+1],C.textGet(state.ctx.rom,c.name,lang)));}
document.querySelectorAll('#gridFigs .tile').forEach((b) => { const g = +b.dataset.idx; b.querySelector('.cap span').textContent = [state.charNames.get(g), groupRole(g)].filter(Boolean).join(' '); });
if (state.open) openDrawer(state.open.kind, state.open.idx);
}
try { if (!dv.run) devRender(); } catch (e) {} // dv does not exist yet on the first call
}
document.querySelectorAll('[data-lang]').forEach(b => b.onclick = () => { lang = b.dataset.lang; try { localStorage.setItem('paramix-lang', lang); } catch (e) {} applyLang(); });
// ------------------------------------------------------------------ state
const featureKeys=['emu','gb','sms','pm','ab','doom','wolf','standalone','cards'];
let siteFeatures=Object.fromEntries(featureKeys.map(k=>[k,false]));
function featureEnabled(key){if(key==='extras')return featureKeys.some(k=>k!=='cards'&&siteFeatures[k]);if(key==='games')return siteFeatures.doom||siteFeatures.wolf;if(key==='consoles')return ['gb','sms','pm','ab'].some(k=>siteFeatures[k]);return siteFeatures[key]===true;}
function applyFeatures(flags={}){siteFeatures=Object.fromEntries(featureKeys.map(k=>[k,flags[k]===true]));for(const k of [...featureKeys,'extras','games','consoles'])document.documentElement.setAttribute('data-feature-'+k,featureEnabled(k)?'on':'off');const active=document.querySelector('.tab[aria-selected="true"][data-feature]');if(active&&!featureEnabled(active.dataset.feature))document.querySelector('[data-tab="figs"]').click();if(state.ctx)renderPlan();}
document.addEventListener('click',e=>{const el=e.target.closest('[data-feature]');if(el&&!featureEnabled(el.dataset.feature)){e.preventDefault();e.stopImmediatePropagation();}},true);
const state = { ctx: null, name: '', changed: new Map(), dim: null, open: null, zoom: 2, decoded: new Map(), eyeOffsets: new Map(), eyeRects: new Map(), eyeLayer: false, fields: [], charNames: new Map() };
const entry = (i) => state.changed.get(i) || (state.launch && state.launchMap && state.launchMap.get(i)) || state.ctx.entries[i];
/* 1.7.2 CLEAN_ROM: start device without any Paradise code (Menu tab); the menu starts right away, sets the clock
* itself, and almost the whole flash is for programs */
const CLEAN_ROM = true;
const menuWanted = () => !!(state.feld || state.bag || state.tama || state.gplay || state.launch);
/* launcher ROM (1.6.8): the small images, computed once per ROM */
function launchMapGet() { if (!state.launchMap) state.launchMap = C.launcherChanges(state.ctx); return state.launchMap; }
function decode(i) {
const e = entry(i);
let d = state.decoded.get(i);
if (!d || d.src !== e) { d = { src: e, dec: C.spriteDecode(e) }; state.decoded.set(i, d); }
return d.dec;
}
// ------------------------------------------------------------ helpers
function toast(msg, err) { if (toast.mute) { if (err) toast.mute.err = msg; return; } const el = $('toast'); el.textContent = msg; el.className = 'toast on' + (err ? ' err' : ''); clearTimeout(toast.t); toast.t = setTimeout(() => el.className = 'toast', err ? 9000 : 5000); }
async function busy(fn) { $('busy').classList.add('on'); await new Promise(r => setTimeout(r, 30)); try { return await fn(); } finally { $('busy').classList.remove('on'); } }
function imgToCanvas(img, scale = 1, cv) {
cv = cv || document.createElement('canvas'); cv.width = img.w * scale; cv.height = img.h * scale;
const tmp = document.createElement('canvas'); tmp.width = img.w; tmp.height = img.h;
tmp.getContext('2d').putImageData(new ImageData(img.data, img.w, img.h), 0, 0);
const g = cv.getContext('2d'); g.imageSmoothingEnabled = false; g.clearRect(0, 0, cv.width, cv.height); g.drawImage(tmp, 0, 0, cv.width, cv.height);
return cv;
}
function pngBlob(img) { return new Promise(r => imgToCanvas(img).toBlob(r, 'image/png')); }
async function pngBytes(img) { return new Uint8Array(await (await pngBlob(img)).arrayBuffer()); }
async function decodePng(blob) {
const bmp = await createImageBitmap(blob, { premultiplyAlpha: 'none', colorSpaceConversion: 'none' });
const cv = document.createElement('canvas'); cv.width = bmp.width; cv.height = bmp.height;
const g = cv.getContext('2d', { willReadFrequently: true }); g.drawImage(bmp, 0, 0);
const d = g.getImageData(0, 0, bmp.width, bmp.height);
return { w: d.width, h: d.height, data: d.data };
}
function download(data, name, type) {
const url = URL.createObjectURL(data instanceof Blob ? data : new Blob([data], { type: type || 'application/octet-stream' }));
const a = document.createElement('a'); a.href = url; a.download = name; document.body.appendChild(a); a.click(); a.remove();
setTimeout(() => URL.revokeObjectURL(url), 4000);
}
async function inflateRaw(bytes) {
const ds = new DecompressionStream('deflate-raw');
const out = await new Response(new Blob([bytes]).stream().pipeThrough(ds)).arrayBuffer();
return new Uint8Array(out);
}
const pad4 = (n) => String(n).padStart(4, '0');
const baseName = () => state.name.replace(/\.[^.]+$/, '').replace(/(_paramix|_emu|_t7|_t18|_doom_E\d|_felder|_fields|_4fields|_6fields|_items|_start|_clean)+$/, '');
// ------------------------------------------------------------- loading
async function loadRom(file) {
const buf = new Uint8Array(await file.arrayBuffer());
let ctx;
// CLEAN_ROM: a ROM without the Paradise (start device of this Studio): only the programs, no pictures or texts
const clean = CLEAN_ROM && F.isClean(buf);
if (clean) { const ed = F.edition(buf); ctx = { rom: buf, entries: [], files: [], groups: [], edition: ed ? (FL.EDITIONS[ed.id] || ed.id) : '?', limit: 0, clean: true }; }
else try { ctx = C.openRom(buf); } catch (e) { toast(t('notRom', { e: em(e) }), true); return; }
state.clean = clean; state.cleanInit = clean;
Object.assign(state, { ctx, name: file.name, changed: new Map(), decoded: new Map(), open: null, eyeOffsets: new Map() });
// 1.7.3 test21 SPR_ALIGN: own Tama pictures of older versions with an odd length are padded (playdates failed at 90 %)
if (!clean) for (const g of ctx.groups) for (let k = 0; k < 6; k++) { const f = C.spriteAlign(ctx.entries[g + k]); if (f) state.changed.set(g + k, f); }
$('start').hidden = true; $('work').classList.add('on'); $('btnSave').disabled = false;
$('romname').textContent = file.name;
state.pmBios = undefined; state.pmKeys = null; state.abKeys = null;
state.emu = null; state.t7save = null; state.t7saveX = null; state.saveIn = null; state.emuRemove = false; state.doom = null; state.doomKeys = null; state.six = null; state.sixName = ''; state.sixWant = false; state.sixOff = false; state.petDirty = false; state.petChanges=null; state.petOriginalId=null; state.texts = new Map(); state.eyeShift = new Map(); state.mouthShift = new Map(); state.poseAdj = new Map(); state.poseCache = null; face.g = -1; state.dlcT = 'main'; state.figT = 'main'; state.dlcOpen = false; state.mainGuest = null; state.emuPack = (() => { const c = romEmuCfg(buf); return !!(c && c.version >= 5 && c.lzOff); })(); state.t18Main = null; state.t18Dirty = false; state.t18Pics = E.t18PicsRead(buf); state.t18PicsDirty = false; state.itemT = 'main'; state.progOpen = new Set(); state.mainPick = null; state.mainDirty = false; state.roomFree = null; state.paraMainTaken = false;
{ const si = S6.sixInfo(buf); state.sixPlanet = si && si.version >= 5 ? si.planet : true; state.sixMenu = si && si.version >= 6 ? si.fieldMenu : true; }
{ const l = stubList(buf); const g = E.autoGet(buf, l); state.emuAuto = g === null ? E.autoGetOld(buf, l) : g; }
{ const c = E.emuClockGet(buf); state.emuClock = c === null ? true : c; }
{ const c = E.emuSessGet(buf); state.emuSess = c === null ? true : c; } // 1.7.3 test7
{ const c = E.emuNfcGet(buf); state.emuNfc = c === null ? true : c; }
state.emuOpt = E.emuOptGet(buf) || { vol: 0, dim: 0, off: 0 };
if(!clean && lang==='ko')for(const it of F.itemCatalog(buf,'ko'))if(it.name==='GASHAPON'){state.texts.set(it.text,'가샤폰');state.textLanguage='ko';}
$('menuKo').checked = F.koreanMenu(buf) || lang==='ko';
{ const fe = F.embedded(), f = fe && F.feldFind(buf, fe.stub);
state.feld = !!(f && (f.flags & F.F_FIELDS)); state.bag = !!(f && (f.flags & F.F_BAG)); state.tama = !!(f && (f.flags & F.F_TAMA)); state.gplay = !!(f && (f.flags & F.F_GPLAY)); state.saves = true;
state.feldInit = state.feld; state.bagInit = state.bag; state.tamaInit = state.tama; state.gplayInit = state.gplay; state.savesInit = true;
state.launch = !!(f && f.version >= 2 && (f.flags & F.F_LAUNCH)); state.launchInit = state.launch; state.launchMap = null;
state.t18Few = false; state.exitKey = EXIT_KEY ? exitGet(buf) : 0; state.exitKeyInit = state.exitKey; if ($('exitKey')) $('exitKey').value = String(state.exitKey);
state.extras = f ? E.appsRead(buf, F.feldApps(buf, fe.stub).apps).map((x) => sessKeep(x, x.kind === 'tama' ? { kind: 'tama', guest: x.guest, dev: x.dev, clock: x.clock, nfc: x.nfc, opt: x.opt, pack: x.pack } : x.kind === 't18' ? { kind: 't18', fw: x.fw, clock: x.clock, opt: x.opt, keepOff: x.off } : x.kind === 'v1' ? { kind: 'v1', rom: x.rom, clock: x.clock } : x.kind === 'gb' ? { kind: 'gb', rom: x.rom, keys: x.keys, inv: x.inv, save: x.save } : x.kind === 'sms' ? { kind: 'sms', rom: x.rom, title: x.title, gg: x.gg, keys: x.keys, inv: x.inv, save: x.save } : x.kind === 'ab' ? { kind: 'ab', rom: x.rom, title: x.title, keys: x.keys, inv: x.inv, save: x.save } : x.kind === 'pm' ? { kind: 'pm', rom: x.rom, title: x.title, keys: x.keys, inv: x.inv, save: x.save, bios: x.bios } : x.kind === 'wolf' ? { kind: 'wolf', pack: x.pack, keys: x.keys, save: x.save } : x.kind === 'doom' ? { kind: 'doom', mcu: x.mcu, keys: x.keys, keys0: JSON.stringify(x.keys), save: x.save, name: x.name, region: x.region } : { rom: x.rom, figs: x.figs || [], clock: x.clock })) : []; state.extrasDirty = false;
state.extrasUp = f ? extrasOld(buf, F.feldApps(buf, fe.stub).apps) : false;
state.wolfInit = state.extras.some((x) => x.kind === 'wolf'); state.wolfKeysDirty = false;
// test5: a T18Emu in the menu whose blocks were emptied (fault up to test4: main program removed in a start device)
// 1.6.11 test2: a T7Emu that can lose the pet's save (old build): named in red until it is written anew
state.oldT7 = []; if (F.emuType(buf) === 't7' && E.t7Outdated(buf)) state.oldT7.push(mainName(buf) || 'TAMA-GO');
if (f) for (const x of E.appsRead(buf, F.feldApps(buf, fe.stub).apps)) if (E.extraKind(x) === 't7' && E.t7Outdated(buf, x.off)) state.oldT7.push(x.name);
state.t18Broken = state.extras.some((x) => { if (x.kind !== 't18' || x.keepOff === undefined) return false; const c = E.t18Cfg(buf, x.keepOff); if (!c) return false;
let n = 0; for (const b of c.map) if (b !== 0xFFFF && buf.subarray(b << 16, (b + 1) << 16).every((v) => v === 0xFF)) n++; return n >= 8; });
state.sig0 = { emu: groupSig('emu'), gb: groupSig('gb'), sms: groupSig('sms'), pm: groupSig('pm'), ab: groupSig('ab') }; // 1.6.10 test4: each tab its own chip // 1.6.8: programs of an older Studio are renewed on save
// 1.6.9 test13: start device with DOOM, the main program out of the menu's list and its autostart
state.cleanClock = true; if (f && clean) try { state.cleanClock = !F.feldApps(buf, fe.stub).noClock; } catch (e) {} // 1.7.3 test7
if (f && state.launch) { const fa = F.feldApps(buf, fe.stub);
if (fa.v9) { state.emuAuto = !!fa.auto; const k = fa.mainSrc ? E.appsRead(buf, fa.apps).findIndex((x) => x.off === fa.mainSrc - 0x10000000 + 0x11000) : -1; state.mainPick = k >= 0 ? state.extras[k] || null : null; } }
// A menu from an older Studio version is rebuilt on save (e.g. 0.9.5 had no item pictures)
state.feldStale = lang==='ko' && !F.koreanMenu(buf);
if (f) {
if (clean) try { const fa = F.feldApps(buf, fe.stub), re = fe.feldc ? F.cleanApply(buf, { apps: fa.apps, dl: fa.dl, mainSrc: fa.mainSrc, auto: fa.auto, noClock: fa.noClock, spot: F.cleanInfo(buf) }, { feld: fe.feldc, stub: fe.stub }) : buf; state.feldStale = re.some((v, i) => v !== buf[i]); } catch (e) { state.feldStale = lang==='ko' && !F.koreanMenu(buf); }
else try {
const embOld = { stub: fe.stub, oldStub: E.embedded() && E.embedded().stub };
const fa = F.feldApps(buf, fe.stub), low = fa.apps.length ? Math.min(...fa.apps.map((a) => a.src - 0x10000000 + 0x11000)) : 0;
const dl = f.version >= 7 ? (buf[f.off + 0x334] | buf[f.off + 0x335] << 8 | buf[f.off + 0x336] << 16 | buf[f.off + 0x337] << 24) >>> 0 : 0, dlo = dl ? dl - 0x10000000 + 0x11000 : 0;
const re = F.feldApply(F.feldStrip(buf, embOld, E), { fields: state.feld, bag: state.bag, tama: state.tama, gplay: state.gplay, saves: state.saves, launch: state.launch, apps: fa.apps, name0: fa.name0, appsLow: low, dl, mainSrc: fa.mainSrc, auto: fa.auto, fieldNames: fieldTexts(buf).map((x) => x.name) }, F.feldSlots(buf, fe.stub), { feld: fe.feld, stub: fe.stub }, E);
if (dlo) re.set(buf.subarray(dlo, dlo + 0x10000), dlo); // the flash app stays where it is
state.feldStale = re.length !== buf.length || re.some((v, i) => v !== buf[i]);
} catch (e) { state.feldStale = lang==='ko' && !F.koreanMenu(buf); }
} }
// fields and character names (from the ROM's character table and text table)
state.fields = []; state.charNames = new Map();
try {
state.fields = C.fieldSets(ctx);
const tt = F.textTabelle(buf), chars = C.charTable(ctx.files[0]).filter((c) => c.id > 1000 && c.id < 9000);
if (tt >= 0 && chars.length + 1 === ctx.groups.length) chars.forEach((c, i) => { const n = C.textGet(buf,c.name,lang); if (n) state.charNames.set(ctx.groups[i + 1], n); });
} catch (e) { state.fields = []; }
cleanTabs();
renderInfo(); if (!clean) { renderGrids(); renderNames(); renderDim(); } renderEmu(); renderDoom(); renderFeld(); renderSave(); if (!dv.run) devRender();
toast(clean ? t('cleanLoaded', { ed: ctx.edition, n: state.extras.length }) : t('loaded', { ed: ctx.edition, s: ctx.entries.length, f: ctx.groups.length }));
}
// ------------------------------------------------------------------ names (1.6.8)
/* Field names: text numbers per field (the field's own one, and 64..66 where LAND/WATER/SKY stand a second time) */
/* 1.6.8: the extra fields (Land, Water, Sky) are part of the ROM being made: when six fields are switched on in the
* Menu tab, their names can be changed before they are built in */
const sixActive = () => !!state.ctx && !state.launch && ((!!S6.sixInfo(state.ctx.rom) && !state.sixOff) || !!state.six || !!state.sixWant);
function fieldTexts(rom, six) {
let fn = F.fieldNames(rom).map((s) => s.toUpperCase()); const lws = ['LAND', 'WATER', 'SKY'], out = [];
if (six !== undefined) {
const id = F.feldId(rom);
if (!six) fn = fn.slice(0, 3);
else if (fn.length <= 3) fn = fn.concat(id === 4 ? ['SKY'] : id >= 5 ? lws : []);
}
fn.forEach((nm, i) => {
const k = lws.indexOf(nm), own = i < 3 ? 14 + i : k >= 0 ? 64 + k : -1;
if (own < 0) return;
const idx = [own]; if (i < 3 && k >= 0 && C.textGet(rom, 64 + k, lang) === C.textGet(rom, own, lang)) idx.push(64 + k);
out.push({ idx, name: C.textGet(rom, own, lang) });
});
return out;
}
function nameRow(box, label, cur, idx, max) {
const l = document.createElement('label'), sp = document.createElement('span'), inp = document.createElement('input');
sp.textContent = label; sp.title = label; inp.maxLength = max;
if(state.texts.size && state.textLanguage!==lang){inp.disabled=true;inp.title='수정한 이름을 저장하거나 초기화한 뒤 다른 언어를 편집하세요.';}
const ed = state.texts.get(idx[0]); inp.value = ed !== undefined ? ed : cur; inp.classList.toggle('chg', ed !== undefined);
inp.onchange = () => {
let v; try { v = C.textClean(inp.value, lang); } catch(error){inp.setCustomValidity(error.message);inp.reportValidity();return;} inp.setCustomValidity('');
state.textLanguage=lang;
for (const i of idx) { if (!v || v === cur) state.texts.delete(i); else state.texts.set(i, v); }
inp.value = v && v !== cur ? v : cur; inp.classList.toggle('chg', !!v && v !== cur); renderPlan();
};
l.append(sp, inp); box.appendChild(l);
}
function fieldLabel(name){return lang==='ko'?({LAND:'육지',WATER:'수중',SKY:'하늘',FOREST:'숲',TROPICAL:'트로피컬',GLACIER:'글레이셔'}[String(name).toUpperCase()]||name):name;}
function renderNames() {
if (!state.ctx) return;
if (!state.texts) state.texts = new Map();
const rom = state.ctx.rom, fb = $('namesFields'), cb = $('namesChars'), ib = $('namesItems');
fb.innerHTML = ''; cb.innerHTML = ''; ib.innerHTML = '';
$('namesFind').placeholder = t('namesFind');
for (const f of fieldTexts(rom, sixActive())) nameRow(fb, f.name, f.name, f.idx, 11);
const seen = new Set();
try {
for (const c of C.charTable(state.ctx.files[0]).filter((c) => c.id > 1000 && c.id < 9000)) {
if (seen.has(c.name)) continue; const nm = C.textGet(rom, c.name, lang); if (!nm) continue; seen.add(c.name);
nameRow(cb, nm, nm, [c.name], 12);
}
} catch (e) { /* no character table */ }
const q = ($('namesFind').value || '').toUpperCase();
for (const it of F.itemCatalog(rom, lang)) {
if (seen.has(it.text)) continue; const nm = C.textGet(rom, it.text, lang); if (!nm) continue; seen.add(it.text);
if (q && !nm.includes(q) && !(state.texts.get(it.text) || '').includes(q)) continue;
nameRow(ib, lang==='ko'&&nm==='GASHAPON'?'가샤폰':nm, nm, [it.text], 22);
}
}
$('namesFind').oninput = () => renderNames();
$('namesUndo').onclick = () => { state.texts = new Map(); renderNames(); renderPlan(); };
function estimateEnd() {
const ctx = state.ctx; if (ctx.clean) return C.ASSET_BASE; // CLEAN_ROM: no pictures
let pack = 4 * ctx.entries.length;
for (let i = 0; i < ctx.entries.length; i++) { pack += (4 - pack % 4) % 4; pack += entry(i).length; }
const al = (n) => n + ((4 - n % 4) % 4);
return C.ASSET_BASE + 16 + 48 + al(ctx.files[0].length) + al(pack) + al(ctx.files[2].length);
}
function renderInfo() {
const ctx = state.ctx; if (!ctx) return;
if (ctx.clean) { $('info').innerHTML = ''; const s = document.createElement('span'); s.innerHTML = t('edition') + ': '; s.lastChild.textContent = ctx.edition + ' · ' + t('cleanOn'); $('info').appendChild(s); renderPlan(); return; }
const end = estimateEnd(), total = ctx.limit - C.ASSET_BASE, used = end - C.ASSET_BASE, free = ctx.limit - end;
const pct = Math.min(100, used / total * 100);
$('info').innerHTML = '';
const add = (label, html) => { const s = document.createElement('span'); s.innerHTML = label + ': ' + html + ''; $('info').appendChild(s); };
add(t('edition'), ctx.edition); add(t('sprites'), ctx.entries.length); add(t('figures'), ctx.groups.length); add(t('changed'), state.changed.size);
const s = document.createElement('span');
s.innerHTML = t('space') + ': ' + (free / 1024 | 0) + ' KB';
$('info').appendChild(s);
renderPlan();
}
// --------------------------------------------------------------- grids
let observer;
function tile(kind, idx, label) {
const b = document.createElement('button'); b.className = 'tile'; b.dataset.kind = kind; b.dataset.idx = idx;
b.innerHTML = '
#' + idx + '
';
b.querySelector('.cap span').textContent = label || '';
b.onclick = () => openDrawer(kind, idx);
observer.observe(b);
return b;
}
function paintTile(b) {
const i = +b.dataset.idx, kind = b.dataset.kind;
let img;
try { const d = decode(i); img = d.subs[0]; } catch (e) { return; }
const box = 96, sc = Math.max(1, Math.min(2, Math.floor(box / Math.max(img.w, img.h)) || 1));
const cv = imgToCanvas(img, sc);
if (img.w * sc > box || img.h * sc > box) { cv.style.width = '100%'; cv.style.height = 'auto'; }
const st = b.querySelector('.stage'); st.innerHTML = ''; st.appendChild(cv);
const ch = kind === 'fig' ? [0, 1, 2, 3, 4, 5].some(k => state.changed.has(i + k)) : state.changed.has(i);
b.classList.toggle('changed', ch);
}
function renderGrids() {
if (observer) observer.disconnect();
observer = new IntersectionObserver((es) => es.forEach(e => { if (e.isIntersecting) { paintTile(e.target); observer.unobserve(e.target); } }), { rootMargin: '300px' });
const ctx = state.ctx, gf = $('gridFigs'), ga = $('gridAll'); gf.innerHTML = ''; ga.innerHTML = '';
for (const g of ctx.groups) gf.appendChild(tile('fig', g, [state.charNames.get(g), groupRole(g)].filter(Boolean).join(' ')));
renderFieldPick();
ctx.entries.forEach((e, i) => { const h = C.spriteHeader(e); const tl = tile('spr', i, h.sw * Math.max(1, h.iw) + '×' + h.sh * Math.max(1, h.ih)); if (sixAdded(i)) { tl.classList.add('locked'); tl.title = t('sprSix'); } ga.appendChild(tl); });
}
function refreshTile(kind, idx) {
document.querySelectorAll('.tile[data-idx="' + idx + '"][data-kind="' + kind + '"]').forEach(paintTile);
if (kind === 'spr') { const g = state.ctx.groups.find(g => idx >= g && idx < g + 6); if (g !== undefined) refreshTile('fig', g); }
else for (let k = 0; k < 6; k++) document.querySelectorAll('.tile[data-idx="' + (idx + k) + '"][data-kind="spr"]').forEach(paintTile);
renderInfo();
}
/* CLEAN_ROM: without the Paradise its tabs (pictures, names, size, DOOM) have nothing to show */
const CLEAN_TABS = ['figs', 'all', 'names', 'dim'];
function cleanTabs() {
const off = !!state.clean;
document.querySelectorAll('.tab').forEach((b) => { b.hidden = off && CLEAN_TABS.includes(b.dataset.tab); });
const sel = document.querySelector('.tab[aria-selected="true"]');
if (off && sel && sel.hidden) document.querySelector('.tab[data-tab="emu"]').click();
}
document.querySelectorAll('.tab').forEach(b => b.onclick = () => {
document.querySelectorAll('.tab').forEach(x => x.setAttribute('aria-selected', String(x === b)));
['figs', 'all', 'names', 'dim', 'emu', 'doom', 'gb', 'sms', 'pm', 'ab', 'wolf', 'feld', 'save'].forEach(k => $('pane-' + k).hidden = k !== b.dataset.tab);
});
// Options for a sprite that belongs to a character group (eyes keep their length,
// colours avoid the slots the game recolours). Empty for other sprites.
function partOpts(i) {
const g = state.ctx.groups.find(g => i >= g && i < g + 6);
return g === undefined ? {} : C.partOptions(i - g);
}
function groupRole(g) {
const ctx = state.ctx;
if (g === ctx.groups[0]) return t('roleFallback');
if (ctx.egg >= 0 && g === ctx.egg + 6) return t('roleBaby');
if (g === ctx.adult) return t('roleAdult');
return '';
}
// --------------------------------------------------------------- sheets
function sheetOf(kind, idx) {
if (kind === 'fig') return C.groupSheet([0, 1, 2, 3, 4, 5].map(k => decode(idx + k).subs));
return C.sheetFromSubs(decode(idx).subs);
}
const sheetName = (kind, idx) => (kind === 'fig' ? 'figur_' : 'sprite_') + pad4(idx) + '.png';
/** Apply an edited sheet. Unchanged parts keep their original bytes. */
/* 1.6.8: pictures the six fields added (they share their data and are made again when the fields are updated) */
function sixAdded(i) { const si = S6.sixInfo(state.ctx.rom); return !!si && si.kind === 'gen3' && i >= si.sprites; }
function applySheet(kind, idx, img) {
if (kind === 'spr' && sixAdded(idx)) throw new Error(t('sprSix'));
const opts = { allowMoreColors: $('optColors').checked };
// encode first, change nothing until every part is accepted (a character is never half replaced)
const plan = [];
const setEntry = (i, subs) => {
const cur = decode(i).subs;
if (subs.length === cur.length && subs.every((s, k) => C.sameImage(s, cur[k]))) return;
const orig = state.ctx.entries[i];
const od = C.spriteDecode(orig).subs;
if (subs.every((s, k) => C.sameImage(s, od[k]))) { plan.push([i, null]); return; }
plan.push([i, C.spriteEncode(orig, subs, Object.assign({}, opts, partOpts(i)))]);
};
const commit = () => plan.forEach(([i, e]) => { if (e) state.changed.set(i, e); else state.changed.delete(i); });
if (kind === 'fig') { C.groupFromSheet(img).forEach((subs, k) => setEntry(idx + k, subs)); commit(); return; }
const d = decode(idx); setEntry(idx, C.subsFromSheet(img, d.subs[0].w, d.subs[0].h, d.subs.length)); commit();
}
function parseName(name) {
const m = /(figur|figure|sprite)_(\d+)\.png$/i.exec(name.split('/').pop());
if (!m) return null;
return { kind: /sprite/i.test(m[1]) ? 'spr' : 'fig', idx: +m[2] };
}
async function uploadFiles(files) {
const items = [];
for (const f of files) {
if (/\.zip$/i.test(f.name)) {
const z = await C.zipRead(new Uint8Array(await f.arrayBuffer()), inflateRaw);
for (const e of z) items.push({ name: e.name, blob: new Blob([e.data], { type: 'image/png' }) });
} else items.push({ name: f.name, blob: f });
}
let ok = 0; const skip = [];
for (const it of items) {
const p = parseName(it.name);
if (!p) { if (/\.png$/i.test(it.name)) skip.push(it.name.split('/').pop()); continue; }
if (p.kind === 'fig' && !state.ctx.groups.includes(p.idx)) { skip.push(it.name.split('/').pop()); continue; }
if (p.kind === 'spr' && !(p.idx >= 0 && p.idx < state.ctx.entries.length)) { skip.push(it.name.split('/').pop()); continue; }
try { applySheet(p.kind, p.idx, await decodePng(it.blob)); ok++; refreshTile(p.kind, p.idx); }
catch (e) { skip.push(t('wrongSize', { f: it.name.split('/').pop(), e: em(e) })); }
}
if (!ok && !skip.length) toast(t('upNone'), true);
else toast(t('upOk', { n: ok }) + (skip.length ? '\n' + t('upSkip', { list: skip.slice(0, 6).join(', ') + (skip.length > 6 ? ' …' : '') }) : ''), skip.length > 0 && !ok);
if (state.open) openDrawer(state.open.kind, state.open.idx);
}
/* Fields (worlds): filter the character grid and export everything of one field */
function renderFieldPick() {
const sel = $('figField'), cur = sel.value; sel.innerHTML = '';
const o = document.createElement('option'); o.value = ''; o.textContent = t('figAll'); sel.appendChild(o);
state.fields.forEach((f) => { const x = document.createElement('option'); x.value = f.type; x.textContent = fieldLabel(f.name); sel.appendChild(x); });
sel.value = state.fields.some((f) => String(f.type) === cur) ? cur : '';
applyFieldPick();
}
function applyFieldPick() {
const f = state.fields.find((x) => String(x.type) === $('figField').value);
const set = f ? new Set(f.chars.map((c) => c.group)) : null;
{const chars=C.charTable(state.ctx.files[0]).filter(c=>c.id>1000&&c.id<9000);chars.forEach((c,i)=>state.charNames.set(state.ctx.groups[i+1],C.textGet(state.ctx.rom,c.name,lang)));}
document.querySelectorAll('#gridFigs .tile').forEach((b) => { b.hidden = !!set && !set.has(+b.dataset.idx); });
$('btnZipField').hidden = !f; $('btnFieldIn').hidden = !f;
}
$('figField').onchange = applyFieldPick;
$('btnZipField').onclick = () => busy(async () => {
const f = state.fields.find((x) => String(x.type) === $('figField').value); if (!f) return;
const files = [], lines = ['Paramix Studio: ' + f.name + ' (' + state.ctx.edition + ')', ''];
for (const c of f.chars) { files.push({ name: sheetName('fig', c.group), data: await pngBytes(sheetOf('fig', c.group)) }); lines.push(sheetName('fig', c.group) + ' stage ' + c.stage + ' ' + (state.charNames.get(c.group) || '')); }
const pics = [...f.maps, ...f.overlays, ...f.closeups];
for (const i of pics) files.push({ name: sheetName('spr', i), data: await pngBytes(sheetOf('spr', i)) });
if (f.maps.length) lines.push('', 'field map: ' + f.maps.map((i) => sheetName('spr', i)).join(' '));
if (f.overlays.length) lines.push('map overlays: ' + f.overlays.map((i) => sheetName('spr', i)).join(' '));
if (f.closeups.length) lines.push('close-up backgrounds: ' + f.closeups.map((i) => sheetName('spr', i)).join(' '));
files.push({ name: 'contents.txt', data: new TextEncoder().encode(lines.join('\n') + '\n') });
const meta = { paramix: 'field', edition: state.ctx.edition, type: f.type, name: f.name, chars: f.chars.map((c) => ({ id: c.id, stage: c.stage, group: c.group })), maps: f.maps, overlays: f.overlays, closeups: f.closeups };
files.push({ name: 'field.json', data: new TextEncoder().encode(JSON.stringify(meta, null, 1)) });
download(C.zipBuild(files), baseName() + '_' + f.name.toLowerCase() + '.zip', 'application/zip');
toast(t('fieldZipOk', { f: f.name, n: f.chars.length, s: pics.length }));
});
/* Load a field ZIP (from this or another ROM) into the selected field: characters in
the same order (child, teens, adults), field map, overlays and close-ups one to one. */
$('btnFieldIn').onclick = () => $('fileField').click();
$('fileField').onchange = (e) => {
const file = e.target.files[0]; e.target.value = ''; if (!file) return;
busy(async () => {
const dst = state.fields.find((x) => String(x.type) === $('figField').value); if (!dst) return;
const z = await C.zipRead(new Uint8Array(await file.arrayBuffer()), inflateRaw);
const by = new Map(z.map((x) => [x.name.split('/').pop(), x.data]));
let meta = null; try { meta = JSON.parse(new TextDecoder().decode(by.get('field.json'))); } catch (err) { meta = null; }
if (!meta || meta.paramix !== 'field') { toast(t('fieldInBad'), true); return; }
let n = 0, eyes = 0; const skip = [];
const put = async (kind, srcIdx, dstIdx) => {
const nm = sheetName(kind, srcIdx), data = by.get(nm); if (!data || dstIdx === undefined) return;
try { applySheet(kind, dstIdx, await decodePng(new Blob([data], { type: 'image/png' }))); n++; refreshTile(kind, dstIdx); }
catch (err) { if (/^eye image too detailed/.test(err.message)) eyes++; else skip.push(t('wrongSize', { f: nm, e: em(err) })); }
};
for (let i = 0; i < meta.chars.length && i < dst.chars.length; i++) await put('fig', meta.chars[i].group, dst.chars[i].group);
for (let i = 0; i < meta.maps.length && i < dst.maps.length; i++) await put('spr', meta.maps[i], dst.maps[i]);
for (let i = 0; i < meta.overlays.length && i < dst.overlays.length; i++) await put('spr', meta.overlays[i], dst.overlays[i]);
for (let i = 0; i < meta.closeups.length && i < dst.closeups.length; i++) await put('spr', meta.closeups[i], dst.closeups[i]);
toast(t('fieldInOk', { src: meta.name + ' (' + meta.edition + ')', dst: dst.name, n }) + (eyes ? '\n' + t('fieldInEyes', { k: eyes }) : '') + (skip.length ? '\n' + t('upSkip', { list: skip.slice(0, 4).join(', ') + (skip.length > 4 ? ' …' : '') }) : ''), skip.length > 0 && !n);
});
};
async function zipSheets(kind) {
const list = kind === 'fig' ? state.ctx.groups : state.ctx.entries.map((e, i) => i);
const files = [];
for (const i of list) files.push({ name: sheetName(kind, i), data: await pngBytes(sheetOf(kind, i)) });
download(C.zipBuild(files), baseName() + (kind === 'fig' ? '_figuren.zip' : '_sprites.zip'), 'application/zip');
}
// --------------------------------------------------------------- drawer
function openDrawer(kind, idx) {
state.open = { kind, idx };
const img = sheetOf(kind, idx);
$('dTitle').textContent = (kind === 'fig' ? t('figure') : t('sprite')) + ' #' + idx;
imgToCanvas(img, state.zoom, $('dCanvas'));
const meta = $('dMeta'); meta.innerHTML = '';
const li = (s) => { const x = document.createElement('li'); x.textContent = s; meta.appendChild(x); };
li(t('mSheet', { w: img.w, h: img.h }));
if (kind === 'fig') { li(t('mGroupRows')); li(t('mEyes')); li(t('mColorsFig')); if (groupRole(idx)) li(groupRole(idx) + ': ' + t(idx === state.ctx.groups[0] ? 'roleFallbackText' : idx === state.ctx.adult ? 'roleAdultText' : 'roleBabyText')); }
else {
const h = C.spriteHeader(state.ctx.entries[idx]);
li(t('mSize', { w: h.sw, h: h.sh, n: h.numSprites / (Math.max(1, h.iw) * Math.max(1, h.ih)), iw: Math.max(1, h.iw), ih: Math.max(1, h.ih) }));
li(t('mColors', { c: h.bpp >= 0x10 ? t('mDirect') : t('mPal', { n: 1 << [1, 2, 4, 8][h.bpp] }), p: h.bpp >= 0x10 ? 0 : Math.max(1, h.numPal) }));
if (sixAdded(idx)) li(t('sprSix'));
if (h.numPal > 1) li(t('mKeep'));
}
const ch = kind === 'fig' ? [0, 1, 2, 3, 4, 5].some(k => state.changed.has(idx + k)) : state.changed.has(idx);
$('dReset').disabled = !ch;
$('dEyes').hidden = kind !== 'fig'; if (kind === 'fig') { if (face.g !== idx) $('dPoseOnly').checked = false; eyePreview(idx); }
$('dUp').disabled = kind === 'spr' && sixAdded(idx);
$('drawer').classList.add('open'); $('drawer').setAttribute('aria-hidden', 'false'); $('scrim').classList.add('on');
}
/* 1.6.8: move a character's eyes and mouth (composite entries of the field). The preview shows every pose of the big
* or the small figure. Arrows move eyes or mouth in all poses (small figure half as far) or, with "this pose only",
* the layers of the pose shown (state.poseAdj: figure -> word positions -> extra offset). */
const shTxt = (sh) => (sh[0] || sh[1] ? (sh[0] > 0 ? '+' : '') + sh[0] + ' / ' + (sh[1] > 0 ? '+' : '') + sh[1] : '');
const face = { g: -1, pose: 0, small: false };
function posesOf(g, small) {
if (!state.poseCache) state.poseCache = new Map();
const base = small ? g + 3 : g, k = state.ctx.files[0].length + ':' + base;
if (!state.poseCache.has(k)) state.poseCache.set(k, C.facePoses(state.ctx.files[0], base, base + 1, base + 2));
return state.poseCache.get(k);
}
const poseKey = (l) => l.ox + ':' + l.oy;
function poseAdjGet(g, l) { const m = state.poseAdj && state.poseAdj.get(g), v = l && m && m.get(poseKey(l)); return v ? v.d : [0, 0]; }
function firstPose(ps) { const i = ps.findIndex((p) => p.eye && p.eye.sub === 0 && p.mouth && p.mouth.sub === 0); return i >= 0 ? i : Math.max(0, ps.findIndex((p) => p.eye && p.eye.sub === 0)); }
function eyePreview(g) {
if (face.g !== g) { face.g = g; face.small = false; face.pose = firstPose(posesOf(g, false)); }
const ps = posesOf(g, face.small), only = $('dPoseOnly').checked, cv = $('dEyeCv'), x = cv.getContext('2d');
const ge = (state.eyeShift && state.eyeShift.get(g)) || [0, 0], gm = (state.mouthShift && state.mouthShift.get(g)) || [0, 0];
const sc = (v) => (face.small ? [half(v[0]), half(v[1])] : v);
$('dFaceBig').classList.toggle('on', !face.small); $('dFaceSmall').classList.toggle('on', face.small);
$('dFaceHint').textContent = t(only ? 'poseOnlyHint' : 'eyeMvHint');
x.clearRect(0, 0, 64, 64);
let f;
if (ps.length) { face.pose = Math.min(Math.max(0, face.pose), ps.length - 1); f = ps[face.pose]; }
else { const o = C.eyeFirst(state.ctx.files[0], g, g + 1); if (!o) return; f = { bs: o.bs, eye: { sub: o.es, dx: o.dx, dy: o.dy, ox: -1, oy: -1 }, mouth: null }; }
$('dPoseNr').textContent = ps.length ? t('poseNr', { i: face.pose + 1, n: ps.length }) : '';
$('dPosePrev').disabled = $('dPoseNext').disabled = ps.length < 2;
$('dPoseOnly').disabled = !ps.length;
$('dMouthRow').hidden = !f.mouth;
const ea = poseAdjGet(g, f.eye), ma = poseAdjGet(g, f.mouth);
$('dEyeVal').textContent = shTxt(only ? ea : ge); $('dMouthVal').textContent = shTxt(only ? ma : gm);
const base = face.small ? g + 3 : g, B = decode(base), b = B.subs[f.bs] || B.subs[0];
const img = new ImageData(new Uint8ClampedArray(b.data), b.w, b.h);
const put = (part, lay, sh) => {
if (!lay) return; let P; try { P = decode(base + part); } catch (e) { return; }
const e = P.subs[lay.sub] || P.subs[0]; if (!e) return;
const ox = lay.dx + ((b.w - e.w) >> 1) + sh[0], oy = lay.dy + ((b.h - e.h) >> 1) + sh[1];
for (let y = 0; y < e.h; y++) for (let xx = 0; xx < e.w; xx++) {
const s = (y * e.w + xx) * 4; if (e.data[s + 3] < 128) continue;
const X = xx + ox, Y = y + oy; if (X < 0 || Y < 0 || X >= b.w || Y >= b.h) continue;
const t = (Y * b.w + X) * 4; img.data[t] = e.data[s]; img.data[t + 1] = e.data[s + 1]; img.data[t + 2] = e.data[s + 2]; img.data[t + 3] = 255;
}
};
const se = sc(ge), sm = sc(gm);
put(1, f.eye, [se[0] + ea[0], se[1] + ea[1]]); put(2, f.mouth, [sm[0] + ma[0], sm[1] + ma[1]]);
cv.width = b.w; cv.height = b.h; x.putImageData(img, 0, 0);
// FACE_SCALE (1.7.2 test15): every sprite at 3x (big 192 px, small 96 px), before the small one was blown up to 192 px
if (FACE_SCALE) { cv.style.width = (b.w * 3) + 'px'; cv.style.height = (b.h * 3) + 'px'; cv.style.margin = ((192 - b.h * 3) >> 1) + 'px ' + ((192 - b.w * 3) >> 1) + 'px'; }
}
const FACE_SCALE = true;
const clamp16 = (v) => Math.max(-16, Math.min(16, v));
function curLayer(which) { const ps = posesOf(face.g, face.small); const f = ps[face.pose]; return f ? f[which] : null; }
function faceMove(which, dx, dy, reset) {
if (!state.open || state.open.kind !== 'fig') return;
const g = state.open.idx;
if ($('dPoseOnly').checked) {
const l = curLayer(which); if (!l || l.ox < 0) return;
if (!state.poseAdj) state.poseAdj = new Map();
const m = state.poseAdj.get(g) || new Map(), k = poseKey(l), c = (m.get(k) || { d: [0, 0] }).d, n = reset ? [0, 0] : [clamp16(c[0] + dx), clamp16(c[1] + dy)];
if (n[0] || n[1]) m.set(k, { ox: l.ox, oy: l.oy, d: n }); else m.delete(k);
if (m.size) state.poseAdj.set(g, m); else state.poseAdj.delete(g);
} else {
const key = which === 'eye' ? 'eyeShift' : 'mouthShift';
if (!state[key]) state[key] = new Map();
const c = state[key].get(g) || [0, 0], n = reset ? [0, 0] : [clamp16(c[0] + dx), clamp16(c[1] + dy)];
if (n[0] || n[1]) state[key].set(g, n); else state[key].delete(g);
}
eyePreview(g); renderPlan();
}
document.querySelectorAll('[data-eye]').forEach((bt) => bt.onclick = () => { const [dx, dy] = bt.dataset.eye.split(',').map(Number); faceMove('eye', dx, dy); });
document.querySelectorAll('[data-mouth]').forEach((bt) => bt.onclick = () => { const [dx, dy] = bt.dataset.mouth.split(',').map(Number); faceMove('mouth', dx, dy); });
$('dEyeReset').onclick = () => faceMove('eye', 0, 0, true);
$('dMouthReset').onclick = () => faceMove('mouth', 0, 0, true);
const poseStep = (k) => { if (!state.open) return; const n = posesOf(face.g, face.small).length; if (n) face.pose = (face.pose + k + n) % n; eyePreview(state.open.idx); };
$('dPosePrev').onclick = () => poseStep(-1); $('dPoseNext').onclick = () => poseStep(1);
const faceSize = (small) => { if (!state.open) return; face.small = small; face.pose = firstPose(posesOf(face.g, small)); eyePreview(state.open.idx); };
$('dFaceBig').onclick = () => faceSize(false); $('dFaceSmall').onclick = () => faceSize(true);
$('dPoseOnly').onchange = () => { if (state.open) eyePreview(state.open.idx); };
function closeDrawer() { state.open = null; $('drawer').classList.remove('open'); $('drawer').setAttribute('aria-hidden', 'true'); $('scrim').classList.remove('on'); }
$('dClose').onclick = closeDrawer; $('scrim').onclick = closeDrawer;
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeDrawer(); });
document.querySelectorAll('[data-z]').forEach(b => b.onclick = () => { state.zoom = +b.dataset.z; if (state.open) openDrawer(state.open.kind, state.open.idx); });
$('dDown').onclick = async () => { const { kind, idx } = state.open; download(await pngBlob(sheetOf(kind, idx)), sheetName(kind, idx)); };
$('dUp').onclick = () => $('fileOne').click();
$('fileOne').onchange = async (e) => {
const f = e.target.files[0]; e.target.value = ''; if (!f || !state.open) return;
const { kind, idx } = state.open;
try { await busy(async () => applySheet(kind, idx, await decodePng(f))); refreshTile(kind, idx); openDrawer(kind, idx); toast(t('upOk', { n: 1 })); }
catch (err) { toast(t('wrongSize', { f: f.name, e: em(err) }), true); }
};
$('dReset').onclick = () => {
const { kind, idx } = state.open;
if (kind === 'fig') for (let k = 0; k < 6; k++) state.changed.delete(idx + k); else state.changed.delete(idx);
refreshTile(kind, idx); openDrawer(kind, idx); toast(t('resetOk'));
};
// ------------------------------------------------------------------ card
function eyeRectFor(ch) {
if (!state.eyeRects) state.eyeRects = new Map();
if (state.eyeRects.has(ch)) return state.eyeRects.get(ch);
const pre = C.dimEyePreset(ch);
const r = pre === undefined ? C.dimGuessEye(ch) : pre;
state.eyeRects.set(ch, r); return r;
}
/** Insert a card character into group g (body, eye layer, blank mouth). */
function insertDim(ch, g) {
const ctx = state.ctx;
if (!state.eyeLayer) {
// Standard: the card character keeps its own eyes in the body. The game draws the eye
// image of the current character on top (field and cell), so it stays empty.
const parts = C.dimCharParts(ch);
[0, 1, 2, 3, 4, 5].forEach(k => {
const orig = ctx.entries[g + k];
state.changed.set(g + k, k === 0 || k === 3 ? C.spriteEncode(orig, parts[k], C.partOptions(k)) : C.spriteBlank(orig, C.partOptions(k)));
});
state.eyeOffsets.delete(g);
return true;
}
const rect = eyeRectFor(ch);
let res = rect ? C.dimCharPartsWithEyes(ch, rect) : null;
const parts = res ? res.parts : C.dimCharParts(ch);
[0, 2, 3, 5].forEach(k => {
const orig = ctx.entries[g + k];
state.changed.set(g + k, k === 0 || k === 3 ? C.spriteEncode(orig, parts[k], C.partOptions(k)) : C.spriteBlank(orig, C.partOptions(k)));
});
let eyesOk = !!res;
for (const [k, layer] of [[1, res && res.big], [4, res && res.small]]) {
const orig = ctx.entries[g + k]; let enc = null;
if (layer) for (const v of C.eyeVariants(layer, k === 1)) { try { enc = C.spriteEncode(orig, v, C.partOptions(k)); break; } catch (e) { /* too big, fewer open eyes */ } }
if (!enc) eyesOk = false;
state.changed.set(g + k, enc || C.spriteBlank(orig, C.partOptions(k)));
}
if (!state.eyeOffsets) state.eyeOffsets = new Map();
if (eyesOk) state.eyeOffsets.set(g, [res.eyeBig, res.eyeSmall]); else state.eyeOffsets.delete(g);
return eyesOk;
}
/** Data pack with the eye layer placed for every inserted character still changed. */
const half = (v) => Math.sign(v) * Math.round(Math.abs(v) / 2); // symmetric: -1 and 1 both move one pixel
function currentDataPack() {
let dp = state.ctx.files[0];
if (!state.eyeOffsets) return null;
let any = false;
for (const [g, v] of state.eyeOffsets) {
if (v === 'hide') {
if (!state.changed.has(g)) continue;
dp = C.hideEyes(dp, g, g + 1).dataPack; dp = C.hideEyes(dp, g + 3, g + 4).dataPack;
any = true; continue;
}
const [b, sm] = v;
if (!state.changed.has(g + 1)) continue;
dp = C.setEyeOffset(dp, g, g + 1, 64, 32, b[0], b[1]).dataPack;
dp = C.setEyeOffset(dp, g + 3, g + 4, 32, 16, sm[0], sm[1]).dataPack;
any = true;
}
// 1.6.8: eyes moved in the drawer (small figure: half the way)
for (const [g, [dx, dy]] of state.mouthShift || []) { // mouth: the same way as the eyes
dp = C.shiftEyes(dp, g, g + 2, dx, dy).dataPack; dp = C.shiftEyes(dp, g + 3, g + 5, half(dx), half(dy)).dataPack;
any = true;
}
for (const [, m] of state.poseAdj || []) { if (m.size) { dp = C.layersMove(dp, [...m.values()]); any = true; } } // single poses
for (const [g, [dx, dy]] of state.eyeShift || []) {
dp = C.shiftEyes(dp, g, g + 1, dx, dy).dataPack; dp = C.shiftEyes(dp, g + 3, g + 4, half(dx), half(dy)).dataPack;
any = true;
}
return any ? dp : null;
}
function renderDim() {
const area = $('dimArea'); area.innerHTML = '';
if (!state.dim) { const p = document.createElement('p'); p.className = 'hint'; p.textContent = t('dimNone'); area.appendChild(p); return; }
const dim = state.dim, ctx = state.ctx;
const bar = document.createElement('div'); bar.className = 'assign';
const selD = document.createElement('select'); dim.chars.forEach(c => { const o = document.createElement('option'); o.value = c.index; o.textContent = t('dimNr') + ' ' + c.index + (c.baby ? ' (' + t('dimBaby') + ')' : ''); selD.appendChild(o); });
const selG = document.createElement('select'); ctx.groups.forEach(g => { const o = document.createElement('option'); o.value = g; o.textContent = t('figure') + ' #' + g + (groupRole(g) ? ' (' + groupRole(g) + ')' : ''); selG.appendChild(o); }); if (ctx.groups.includes(ctx.adult)) selG.value = ctx.adult;
const go = document.createElement('button'); go.className = 'btn primary small'; go.textContent = t('dimApply');
go.onclick = () => busy(async () => {
const ch = dim.chars[+selD.value], g = +selG.value;
const ok = insertDim(ch, g);
refreshTile('fig', g); toast(t('dimOk', { d: ch.index, g }) + (state.eyeLayer && eyeRectFor(ch) && !ok ? '\n' + t('dimEyesTooBig') : ''));
});
const l1 = document.createElement('span'); l1.textContent = t('dimPick');
const l2 = document.createElement('span'); l2.textContent = t('dimTarget');
bar.append(l1, selD, l2, selG, go);
if (dim.eggs.length && ctx.egg >= 0) {
const eg = document.createElement('button'); eg.className = 'btn small'; eg.textContent = t('dimEgg');
eg.onclick = () => {
const e = C.dimEggSubs(dim.eggs);
state.changed.set(ctx.egg, C.spriteEncode(ctx.entries[ctx.egg], e.small, {}));
state.changed.set(ctx.egg + 3, C.spriteEncode(ctx.entries[ctx.egg + 3], e.big, {}));
refreshTile('spr', ctx.egg); refreshTile('spr', ctx.egg + 3); toast(t('eggOk'));
};
bar.appendChild(eg);
}
area.appendChild(bar);
// eye editor: the chosen card character large, the eye frame drawn, click to move it
const ed = document.createElement('div'); ed.className = 'eyeed';
const cv = document.createElement('canvas'); cv.className = 'eyecv';
const side = document.createElement('div');
const hint = document.createElement('p'); hint.className = 'hint'; hint.textContent = t('eyeHint');
const none = document.createElement('label'); none.className = 'check';
const cb = document.createElement('input'); cb.type = 'checkbox'; none.append(cb, document.createTextNode(' ' + t('eyeNone')));
side.append(hint, none); ed.append(cv, side); if (state.eyeLayer) area.appendChild(ed);
const S = 5;
const draw = () => {
const ch = dim.chars[+selD.value], im = ch.frames.idle1, r = eyeRectFor(ch);
imgToCanvas(im, S, cv);
const g2 = cv.getContext('2d');
if (r) { g2.strokeStyle = '#ff2fa0'; g2.lineWidth = 2; g2.strokeRect(r[0] * S - 1, r[1] * S - 1, (r[2] - r[0] + 1) * S + 2, (r[3] - r[1] + 1) * S + 2); }
cb.checked = !r;
};
cv.onclick = (e) => {
const ch = dim.chars[+selD.value], b = cv.getBoundingClientRect();
const x = Math.floor((e.clientX - b.left) / b.width * ch.frames.idle1.w), y = Math.floor((e.clientY - b.top) / b.height * ch.frames.idle1.h);
state.eyeRects.set(ch, C.eyeRectAt(ch, x, y)); draw();
};
cb.onchange = () => { const ch = dim.chars[+selD.value]; state.eyeRects.set(ch, cb.checked ? null : (C.dimEyePreset(ch) || C.dimGuessEye(ch))); draw(); };
selD.onchange = () => { state.dimSel = selD.value; draw(); };
if (state.dimSel === undefined) { const c = dim.chars.find(x => !x.baby); if (c) state.dimSel = String(c.index); }
if (state.dimSel !== undefined) selD.value = state.dimSel;
const grid = document.createElement('div'); grid.className = 'dimgrid';
dim.chars.forEach(c => {
const b = document.createElement('button'); b.className = 'tile';
b.innerHTML = '' + t('dimNr') + ' ' + c.index + '' + (c.baby ? ' ' + t('dimBaby') : '') + '
';
b.querySelector('.stage').appendChild(imgToCanvas(c.frames.idle1, c.baby ? 3 : 1));
b.onclick = () => { selD.value = c.index; state.dimSel = selD.value; grid.querySelectorAll('.tile').forEach(x => x.classList.toggle('sel', x === b)); draw(); };
grid.appendChild(b);
});
area.appendChild(grid);
draw();
}
$('btnDim').onclick = () => $('fileDim').click();
$('fileDim').onchange = async (e) => {
const f = e.target.files[0]; e.target.value = ''; if (!f) return;
try { const raw = new Uint8Array(await f.arrayBuffer()); state.dim = C.smaDetect(raw) ? C.smaLoad(raw) : C.dimLoad(raw); state.dimSel = undefined; renderDim(); if (!state.dim.chars.length) toast(t('notDim', { e: t('cardNoChars') }), true); }
catch (err) { toast(t('notDim', { e: em(err) }), true); }
};
// ------------------------------------------------------------ overview
/* 1.6.8: one chip for all emulators, the main one (A and C, or the first entry) in bold */
function planEmus(emuOn, kind) {
const em = state.emu, xs = state.extras || [];
const oldNm = () => (F.embedded() && F.feldApps(state.ctx.rom, F.embedded().stub).name0) || mainName(state.ctx.rom) || 'EMU';
const mainNm = em ? emuNm(em) : emuOn ? oldNm() : '';
const v = [];
if (mainNm) v.push([mainNm, !doomMain()]); // with DOOM as the main program the emulator goes to the menu
if (!em && kind === 2 && state.emuRemove && !state.paraMainTaken) v.push([oldNm() + ' ' + t('stDel'), false]);
xs.filter((x) => !OWN_CHIP.has(x.kind) && x.kind !== 'doom').forEach((x) => v.push([(v.length ? ', ' : '') + E.extraName(x), false]));
if (!v.length) return [t('planEmus'), t('stNone'), 'off'];
const isNew = !!em || xs.some((x) => !OWN_CHIP.has(x.kind) && x.fresh) || (!!state.extrasDirty && groupSig('emu') !== (state.sig0 || {}).emu), upd = emuUpPending() || emuAutoDirty() || !!(state.extrasUp && state.extrasUp.has('emu')), gone = !em && kind === 2 && state.emuRemove;
if (isNew || upd || !gone) v.push([' · ' + (isNew ? t('stNew') : upd ? t('stUpd') : t('stKeep')), false]);
return [t('planEmus'), v, isNew || upd ? 'new' : gone ? 'del' : 'keep'];
}
/* 1.6.10 test2: Wolfenstein 3D with its own chip and its own part of the flash bar */
function planWolf() {
const xs = (state.extras || []).filter((y) => y.kind === 'wolf');
if (!xs.length) return [t('planWolf'), state.wolfInit ? t('stDel') : t('stNone'), state.wolfInit ? 'del' : 'off'];
const what = xs.map((x) => {
const inf = E.wolfInfo(x.pack) || { shareware: true, episodes: 1 };
return inf.sod ? 'Spear of Destiny' : t(inf.shareware ? 'wolfShare' : 'wolfFull') + (inf.episodes > 1 ? ', ' + t('wolfEps', { n: inf.episodes }) : '');
}).join(' + ');
const fresh = xs.some((x) => x.fresh);
return [t('planWolf'), (fresh ? t('stNew') : state.wolfKeysDirty ? t('stUpd') : t('stKeep')) + ', ' + what, fresh || state.wolfKeysDirty ? 'new' : 'keep'];
}
/* 1.6.10 test4: Game Boy and Master System with their own chip and their own part of the flash bar */
const OWN_CHIP = new Set(['wolf', 'gb', 'sms', 'pm', 'ab']);
function groupKind(x) { return OWN_CHIP.has(x.kind) ? x.kind : 'emu'; }
function groupSig(g) {
return JSON.stringify((state.extras || []).filter((x) => groupKind(x) === g).map((x) => [E.extraName(x), x.keys || null, !!x.inv, x.clock, x.nfc, x.opt, x.sess !== false]));
}
function planGroup(g, label) {
const xs = (state.extras || []).filter((x) => x.kind === g), sig0 = (state.sig0 || {})[g], was = !!sig0 && sig0 !== '[]';
if (!xs.length) return [label, was ? t('stDel') : t('stNone'), was ? 'del' : 'off'];
const isNew = xs.some((x) => x.fresh), upd = !isNew && (groupSig(g) !== sig0 || !!(state.extrasUp && state.extrasUp.has(g)));
return [label, xs.map((x) => E.extraName(x)).join(', ') + ' · ' + (isNew ? t('stNew') : upd ? t('stUpd') : t('stKeep')), isNew || upd ? 'new' : 'keep'];
}
const MB = (n) => (n / 1048576).toFixed(n < 1048576 ? 2 : 1).replace(/\.?0+$/, '') + ' MB';
/* test17: the overview's free room from a quiet trial build (after removing a program, after loading) */
let roomSoonT = 0, roomSoonRun = false;
function roomSoon() {
clearTimeout(roomSoonT);
roomSoonT = setTimeout(async () => {
if (roomSoonRun || toast.mute || !state.ctx || state.sixOff) return;
const sig = roomSig(); if (state.roomFree && state.roomFree.sig === sig) return;
roomSoonRun = true;
try { const m = await roomTry(); if (!state.roomFree || state.roomFree.sig !== sig) state.roomFree = { sig, kb: -1 }; } finally { roomSoonRun = false; } // 1.7.3 test13: a trial that failed (no programs, no room) says nothing about the room (it showed all as "reserved")
if (roomSig() === sig) renderPlan();
}, 400);
}
function renderPlan() {
const el = $('plan'); if (!el || !state.ctx) return;
const rom = state.ctx.rom, kind = appInstalled();
const emuOn = !!state.emu || (kind === 2 && !state.emuRemove && !state.doom), doomOn = !!state.doom || (doomFree() && doomXs().length > 0) || (kind === 1 && !state.emuRemove && (!state.emu || !!state.launch));
const fe = F.embedded(), menuOld = fe && F.feldFind(rom, fe.stub);
const st = (on, isNew, old, extra) => on ? (isNew ? t('stNew') : t('stKeep')) + (extra ? ', ' + extra : '') : (old ? t('stDel') : t('stNone'));
const chips = [
[t('planFig'), state.changed.size ? t('stChanged', { n: state.changed.size }) : t('stSame'), state.changed.size ? 'new' : 'keep'],
planEmus(emuOn, kind),
planGroup('gb', t('planGb')),
planGroup('sms', t('planSms')),
planGroup('pm', t('planPm')),
planGroup('ab', t('planAb')),
planWolf(),
[t('planDoom'), st(doomOn, !!state.doom, kind === 1, state.doom ? (DOOM_EPS && doomFree() && state.doom.sel ? doomChip(state.doom) : 'E' + $('doomEp').value) + ($('doomMusic').checked ? ' + ' + t('doomMusic') : '') : ''), state.doom ? 'new' : doomOn ? 'keep' : kind === 1 ? 'del' : 'off'],
];
const menuOn = menuWanted(), parts = [state.launch ? t('planLaunch') : '', state.feld ? t('feldOn') : '', state.bag ? t('bagOn') : '', state.tama ? t('tamaOn') : '', state.gplay ? t('gplayOn') : ''].filter(Boolean).join(', ');
const menuSame = state.feld === state.feldInit && state.bag === state.bagInit && state.tama === state.tamaInit && !!state.gplay === !!state.gplayInit && state.saves === state.savesInit && state.launch === state.launchInit;
if (state.clean) chips[0] = [t('planFig'), t('cleanOn'), state.cleanInit ? 'keep' : 'new'];
chips.push([t('planMenu'), menuOn ? parts + (state.feldStale && menuSame ? ' (' + t('stUpd') + ')' : '') : (menuOld ? t('stDel') : t('stNone')), menuOn ? ((menuSame && !state.feldStale) ? 'keep' : 'new') : menuOld ? 'del' : 'off']);
const sixIn = !!S6.sixInfo(rom);
{ const n = new Set([...(state.eyeShift || new Map()).keys(), ...(state.mouthShift || new Map()).keys(), ...(state.poseAdj || new Map()).keys()]).size; if (n) chips.push([t('planEyes'), t('planNamesN', { n }), 'new']); }
if (state.texts && state.texts.size) chips.push([t('planNames'), t('planNamesN', { n: state.texts.size }), 'new']);
if (sixIn || state.six || state.sixWant) chips.push([t('planSix'), sixIn ? t('stKeep') : t('stNew'), sixIn ? 'keep' : 'new']);
// Flash: from 0x111000 to the end
const base = state.clean ? 0x10000 : 0x111000, end = 0x1000000, total = end - base, segs = [];
const assets = state.clean ? 0 : estimateEnd() - base + (state.six && !sixIn ? 0xB9000 : 0); if (assets) segs.push(['fw', t('segFw'), assets]);
let doomSize = 0, emuSize = 0;
if (doomFree()) doomSize = doomXs().reduce((n, x) => n + E.extraSize(x), 0);
else if (state.doom) { const f = state.doom.fit[$('doomEp').value]; doomSize = (f ? ($('doomMusic').checked && f.music ? f.sizeM : f.sizeP) : 0) + (0xD48000 - 0xCA0000); }
else if (doomOn) doomSize = (rom[0x830000] | rom[0x830001] << 8 | rom[0x830002] << 16 | rom[0x830003] << 24) + (0xD48000 - 0xCA0000);
if (state.emu) emuSize = state.emu.size || 0;
else if (emuOn) { const c7 = E.t7Cfg(rom), c18 = E.t18Cfg(rom); if (c18) emuSize = c18.map.filter((b) => b !== 0xFFFF).length << 16; else if (c7) emuSize = c7.romLen + c7.figs.reduce((n, f) => n + f.len, 0); else { const o = 0xA0000 + 0x140 + 12; emuSize = rom[o] | rom[o + 1] << 8 | rom[o + 2] << 16 | rom[o + 3] << 24; } }
const gs = { wolf: 0, gb: 0, sms: 0, pm: 0, ab: 0 };
for (const x of state.extras || []) if (x.kind === 'doom') continue; else if (OWN_CHIP.has(x.kind)) gs[x.kind] += E.extraSize(x); else emuSize += E.extraSize(x); // more emulators: program, save, data
const wolfSize = gs.wolf;
if (doomOn) segs.push(['doom', t('segDoom'), doomSize]);
if (emuOn || (state.extras || []).some((x) => !OWN_CHIP.has(x.kind))) segs.push(['emu', t('segEmu'), emuSize]);
if (gs.gb) segs.push(['gb', t('segGb'), gs.gb]);
if (gs.sms) segs.push(['sms', t('segSms'), gs.sms]);
if (gs.pm) segs.push(['pm', t('segPm'), gs.pm]);
if (gs.ab) segs.push(['ab', t('segAb'), gs.ab]);
if (wolfSize) segs.push(['wolf', t('segWolf'), wolfSize]);
if (state.feld && !doomOn) { const ed = F.edition(rom); segs.push(['slots', t('segSlots'), ed ? ed.profile.names.length * 0x58000 : 0]); }
const save = state.clean ? 0 : (state.launch ? 0xF00000 : end) - 0xD29000; if (save) segs.push(['save', t('segSave'), save]); // start device: the MB behind the save is free for programs
let used = segs.reduce((a, x) => a + x[2], 0);
// test17 ROOM_REAL: in a start device the free part is what the last trial build really left (program parts need
// whole, partly aligned blocks; the write protection block and the flash app count as used); the rest is programs
const rfOk = ROOM_AUTO && state.launch && state.roomFree && state.roomFree.sig === roomSig(), rf = rfOk && state.roomFree.kb >= 0 ? state.roomFree.kb * 1024 : -1;
if (rf >= 0) { const fix = total - used - rf, e = segs.find((x) => x[0] === 'emu'); if (fix > 0) segs.push(['resv', t('segResv'), fix]); else if (e) e[2] = Math.max(0, e[2] + fix); used = total - rf; } // test18: what programs keep empty (spares, saves, gaps) apart
else if (ROOM_AUTO && state.launch && state.ctx && !rfOk) roomSoon();
segs.push(['free', t('segFree'), Math.max(0, total - used)]);
el.innerHTML = '';
const h = document.createElement('div'); h.className = 'plan-h'; h.textContent = t('planTitle'); el.appendChild(h);
const row = document.createElement('div'); row.className = 'chips';
chips.forEach(([l, v, c]) => {
const feature=new Map([[t('planEmus'),'emu'],[t('planGb'),'gb'],[t('planSms'),'sms'],[t('planPm'),'pm'],[t('planAb'),'ab'],[t('planWolf'),'wolf'],[t('planDoom'),'doom']]).get(l);if(feature&&!featureEnabled(feature))return;
const d = document.createElement('span'); d.className = 'chip ' + c; d.innerHTML = ' '; d.firstChild.textContent = l;
if (Array.isArray(v)) for (const [txt, bold] of v) { const e = document.createElement(bold ? 'strong' : 'span'); e.textContent = txt; d.lastChild.appendChild(e); } // 1.6.8: the main emulator in bold
else d.lastChild.textContent = v;
row.appendChild(d);
});
el.appendChild(row);
const bar = document.createElement('div'); bar.className = 'flash';
const leg = document.createElement('div'); leg.className = 'legend';
segs.forEach(([k, l, n]) => {
if (n <= 0) return;
const i = document.createElement('i'); i.className = 'seg ' + k; i.style.width = (n / total * 100).toFixed(2) + '%'; i.title = l + ': ' + MB(n); bar.appendChild(i);
const g = document.createElement('span'); g.innerHTML = ''; g.appendChild(document.createTextNode(l + ' ' + MB(n))); leg.appendChild(g);
});
el.appendChild(bar); el.appendChild(leg);
if ((state.oldT7 || []).length) { const w = document.createElement('div'); w.className = 'rule warn'; w.textContent = t('t7Old', { n: state.oldT7.join(', ') }); el.appendChild(w); }
if (state.t18Broken && (state.extras || []).some((x) => x.kind === 't18' && x.keepOff !== undefined)) { const w = document.createElement('div'); w.className = 'rule warn'; w.textContent = t('t18Broken'); el.appendChild(w); }
const r = document.createElement('div'); r.className = 'rule'; r.hidden=!featureEnabled('extras'); r.textContent = state.clean ? t('ruleClean') : state.launch ? t('ruleLaunch') : appRoom() ? t('ruleBoth') : t('ruleNoRoom'); el.appendChild(r);
}
// ------------------------------------------------------------ emulator
function appInstalled() {
try {
const r = state.ctx.rom, fe = F.embedded();
if (state.ctx.clean) return 0; // CLEAN_ROM: no main program at 0x0A0000, every program is in the menu (DOOM too, test3)
if (fe && F.isLaunch(r, fe.stub)) return F.appKind(r); // 1.6.8: start device, the home screen hooks point to the trampolines
return E.installedOrigs(r, E.sceneTable(r)) ? F.appKind(r) : 0;
} catch (e) { return 0; }
}
function emuInstalled() { return appInstalled() === 2; }
function doomInstalled() { return appInstalled() === 1; }
/* Where the stub can sit: the emulator's own at 0x0B0000, or the menu's (also elsewhere) */
function stubList(rom) {
const ee = E.embedded(), fe = F.embedded(), l = [];
if (ee) l.push([E.STUB_OFF, ee.stub]);
if (fe) { l.push([E.STUB_OFF, fe.stub]); const f = F.feldFind(rom, fe.stub); if (f && f.stubOff !== E.STUB_OFF) l.push([f.stubOff, fe.stub]); }
return l;
}
function emuAutoDirty() { return (emuInstalled() || (doomInstalled() && !state.launch)) && !state.emu && !state.emuRemove && !state.doom && (!!E.autoGet(state.ctx.rom, stubList(state.ctx.rom)) !== !!state.emuAuto || (emuInstalled() && emuClockDirty())); }
function emuClockDirty() { const sv = E.emuSessGet(state.ctx.rom); if (sv !== null && sv !== (state.emuSess !== false)) return true; const c = E.emuClockGet(state.ctx.rom), n = E.emuNfcGet(state.ctx.rom), o = E.emuOptGet(state.ctx.rom), w = state.emuOpt || {}; return (c !== null && c !== !!state.emuClock) || (n !== null && n !== (state.emuNfc !== false)) || (!!o && (o.vol !== w.vol || o.dim !== w.dim || o.off !== w.off)); }
function emuUpPending() {
const emb = E.embedded();
if (state.emu || state.emuRemove || state.doom || !emb || !emuInstalled()) return false;
try {
if (F.emuType(state.ctx.rom) === 't7') return !!(E.t7Embedded() && E.t7Upgrade(state.ctx.rom, E.t7Embedded()));
if (F.emuType(state.ctx.rom) === 'v1') return !!(E.v1Embedded() && E.v1Upgrade(state.ctx.rom, E.v1Embedded()));
if (F.emuType(state.ctx.rom) === 't18') return !!(E.t18Embedded() && E.t18Upgrade(state.ctx.rom, E.t18Embedded(), E.embedded() && E.embedded().stub));
return !!E.emuUpgrade(state.ctx.rom, emb.app);
} catch (e) { return false; }
}
/* Room for emulator and DOOM: both need the area after the characters from 0x830000 and the program space at 0x0A0000 */
/* 1.6.9 test25: firmware that reaches past 0x0A0000 (Jade Forest wave 2 up to 0x0A1683, GitHub issue; Tropical, Glacier):
* no main program there, but a start device puts every program into the menu (appsPlace, anywhere free) */
function a0Free() { const r = state.ctx.rom; return !!F.appKind(r) || r.subarray(0xA0000, 0xA1000).every(b => b === 0xFF); }
function appRoom() { return !a0Free() || estimateEnd() <= 0x830000; } // without a main program the trial build decides (roomMissing)
function renderEmu() {
if (!state.ctx) return;
renderGb();
renderSms();
renderPm();
renderAb();
renderWolf();
const has = emuInstalled();
$('btnEmuOff').hidden = true; $('btnEmuUndo').hidden = true; // 1.6.8: in the list of programs (×, ↺)
let s;
if (!E.embedded()) s = t('emuMissing');
const t7In = has && F.emuType(state.ctx.rom) === 't7', t7 = state.emu ? !!state.emu.t7 : t7In && !state.emuRemove;
const t18In = has && F.emuType(state.ctx.rom) === 't18', t18 = state.emu ? !!state.emu.t18 : t18In && !state.emuRemove;
const t7Fr = state.emu ? !!state.emu.t7 && E.t7Kind(state.emu.rom) === 'friends' : t7In && !!E.t7Cfg(state.ctx.rom) && E.t7Cfg(state.ctx.rom).romLen === 0xC0000;
if (state.emu) s = state.emu.v1 ? t(E.v3Detect(state.emu.rom) ? 'v3Ok' : 'v1Ok') : state.emu.t7 ? t(t7Fr ? 't7OkFr' : 't7Ok') : state.emu.t18 ? t('t18Ok') : t('emuOk', { size: E.DEVICES[state.emu.dev].label });
else if (state.emuRemove) s = t('emuGone');
else s = has ? t(t7In ? (t7Fr ? 't7HasFr' : 't7Has') : t18In ? 't18Has' : 'emuHas') + (emuUpPending() ? ' ' + t('emuUp') : '') : (state.extras && state.extras.length ? t('emuInList', { n: state.extras.map((x) => E.extraName(x)).join(', ') }) : t('emuNone'));
const v1 = state.emu ? !!state.emu.v1 : has && F.emuType(state.ctx.rom) === 'v1' && !state.emuRemove;
const v3 = v1 && E.v3Detect(state.emu ? state.emu.rom : E.v1FromRom(state.ctx.rom));
s += (state.emu || (has && !state.emuRemove) ? '\n' + t(v3 ? 'v3Use' : v1 ? 'v1Use' : t7 ? 't7Use' : t18 ? 't18Use' : 'emuUse') : '');
const bigIn = has && !state.emu && !state.emuRemove && state.ctx.rom[0xA0148] === 0 && state.ctx.rom[0xA014A] === 0x84;
if ((state.emu && state.emu.big) || bigIn) s += '\n' + t('emuBig');
const room = appRoom();
$('btnEmu').disabled = !room;
if (!room) s = t('noRoomApp');
else if (!a0Free()) s += '\n' + t(state.launch ? 'a0Menu' : 'a0MenuN');
else if (!state.launch && !state.emu && (state.doom || (doomInstalled() && !state.emuRemove))) s += '\n' + t('emuVsDoom');
$('emuStat').textContent = s;
renderT7Figs(t7 && room && !t7Fr);
renderApps();
$('emuAutoRow').hidden = true; $('emuClockRow').hidden = true; // 1.6.8: in the main program's row
{ const is4u = state.emu ? (state.emu.dev === '4u' || state.emu.dev === '4u-plain') : (!state.emuRemove && E.emuNfcGet(state.ctx.rom) !== null); $('emuNfcRow').hidden = true; void is4u; $('emuNfc').checked = state.emuNfc !== false; }
$('emuAuto').checked = !!state.emuAuto;
$('emuClock').checked = state.emuClock !== false;
renderPlan();
$('emuDlc').hidden = true; // 1.6.8: settings, figures and download slots open per program in the list (▾)
$('btnT7Fig').hidden = true;
}
/* T7Emu figures: list with remove buttons */
function t7State() {
if (state.emu && state.emu.t7) return state.emu;
const cur = E.t7FromRom(state.ctx.rom); if (!cur) return null;
return { t7: true, dev: 't7', rom: cur.rom, figs: cur.figs, size: 0 };
}
function t7Size(st) { return st.rom.length + st.figs.reduce((n, f) => n + f.data.length, 0); }
/* 1.6.8: download items and figures also for the programs in the menu. Target: 'main' or the index in state.extras */
const DLC_DEV = ['idl', 'ps', '4u', '4u-plain'];
/* tg: 'main' or the index in state.extras (default: the file dialog's target state.dlcT) */
function dlcTarget(tg = state.dlcT) {
if (typeof tg === 'number') { const x = (state.extras || [])[tg]; return x && x.kind === 'tama' && DLC_DEV.includes(x.dev) ? { guest: x.guest, dev: x.dev, set: (g) => { x.guest = g; state.extrasDirty = true; } } : null; }
const em = state.emu;
if (em) return !em.t7 && !em.t18 && !em.v1 && DLC_DEV.includes(em.dev) ? { guest: em.guest, dev: em.dev, set: (g) => { em.guest = g; } } : null;
// the installed main TamaEmu: its firmware with the save, read from the ROM; it goes into the work on the first change
const mg = state.mainGuest;
if (mg && !state.emuRemove) return { guest: mg.g, dev: mg.dev, set: (g) => { const pk = E.packMain(g, mg.dev, null, !!state.emuPack); state.emu = { guest: g, dev: mg.dev, size: pk.blob.length, big: pk.big, kept: true }; state.mainGuest = null; } };
return null;
}
/* test5: Gotchi Points of a Tama-Go (T7Emu): EEPROM 0x030-0x034, 5 bytes BCD lowest digits first, no checksum
* (save.bin: behind the 2 byte page mask). Goes in like an imported save: the running state starts anew. */
function t7GpSave(tg) {
const rom = state.ctx.rom;
if (tg === 'main') return state.t7save || SV.t7SaveOut(rom);
const x = state.extras[tg]; if (!x || x.kind || x.fresh) return null;
if (state.t7saveX && state.t7saveX.i === tg) return state.t7saveX.save;
const o = romExtras(rom).find((r) => E.extraKind(r) === 't7' && r.rom.length === x.rom.length && r.rom.every((v, k) => v === x.rom[k]));
return o ? SV.t7SaveOut(rom, o.saveOff) : null;
}
function t7GpGet(sv) {
let n = 0;
for (let i = 4; i >= 0; i--) { const v = sv[0x32 + i], hi = v >> 4, lo = v & 15; if (hi > 9 || lo > 9) return -1; n = n * 100 + hi * 10 + lo; }
return n;
}
function t7GpInto(box, tg) {
const sv = t7GpSave(tg); if (!sv || !(sv[0] & 1)) return; // page 0 of the EEPROM must be there
const n = t7GpGet(sv); if (n < 0) return;
const l = document.createElement('label'); l.className = 'check'; const sp = document.createElement('span'); sp.textContent = t('t7Gp') + ' ';
const inp = document.createElement('input'); inp.type = 'number'; inp.min = 0; inp.max = 999999; inp.value = String(n); inp.style.width = '7em';
inp.onchange = () => {
let v = Math.max(0, Math.min(999999, Math.floor(+inp.value || 0)));
const g = new Uint8Array(sv);
for (let i = 0; i < 5; i++) { const d = v % 100; g[0x32 + i] = ((d / 10 | 0) << 4) | (d % 10); v = Math.floor(v / 100); }
if (tg === 'main') state.t7save = g; else state.t7saveX = { i: tg, save: g };
renderPlan(); renderEmu();
};
l.append(sp, inp); box.appendChild(l);
const w = document.createElement('div'); w.className = 'hint'; w.textContent = t('t7GpHint'); box.appendChild(w);
}
/* 1.6.8 (test47): items of T18Emu (MyMeets files) go straight into its firmware's save; the running state starts anew */
function t18Target(tg) {
if (typeof tg === 'number') { const x = (state.extras || [])[tg]; return x && x.kind === 't18' ? { fw: x.fw, set: () => { x.items = true; state.extrasDirty = true; } } : null; }
const em = state.emu;
if (em) return em.t18 ? { fw: em.rom, set: () => { em.items = true; } } : null;
if (!emuInstalled() || state.emuRemove || F.emuType(state.ctx.rom) !== 't18') return null;
if (!state.t18Main) state.t18Main = E.t18FromRom(state.ctx.rom);
const fw = state.t18Main; if (!fw) return null;
return { fw, set: () => { state.t18Dirty = true; } }; // written into the installed program on save (E.t18RomWriteGuest)
}
function picCanvas(pic, sc) {
const c = document.createElement('canvas'); c.className = 'itempic';
if (!pic) { c.width = c.height = 1; return c; }
c.width = pic.w; c.height = pic.h; c.style.width = (pic.w * sc) + 'px'; c.style.height = (pic.h * sc) + 'px';
c.getContext('2d').putImageData(new ImageData(pic.rgba, pic.w, pic.h), 0, 0); return c;
}
/* test47: pictures for "grow up" (the user's own files: .png, .png or the Android T18Emu set with erwachsen.json) */
function t18PicsInto(box) {
const h = document.createElement('h4'); h.className = 'subhead'; h.textContent = t('t18Pics'); box.appendChild(h);
const tools = document.createElement('div'); tools.className = 'tools';
const pick = document.createElement('button'); pick.className = 'btn small'; pick.textContent = t('t18PicsPick'); pick.onclick = () => $('fileT18Pic').click();
tools.appendChild(pick);
if (state.t18Pics && state.t18Pics.size) { const del = document.createElement('button'); del.className = 'btn small'; del.textContent = t('t18PicsDel'); del.onclick = () => { state.t18Pics = new Map(); state.t18PicsDirty = true; renderEmu(); }; tools.appendChild(del); }
box.appendChild(tools);
if (state.t18Pics && state.t18Pics.size) {
const g = document.createElement('div'); g.className = 'picgrid';
for (const [id, p] of state.t18Pics) { const f = document.createElement('figure'); const c = picCanvas(E.t18PicRgba(p), 1); const cap = document.createElement('figcaption'); cap.textContent = (E.T18_ADULTS.find((a) => a[0] === id) || [0, '#' + id])[1]; f.append(c, cap); g.appendChild(f); }
box.appendChild(g);
}
const w = document.createElement('div'); w.className = 'hint'; w.textContent = t('t18PicsHint'); box.appendChild(w);
}
async function pngRgba(bytes) {
const bm = await createImageBitmap(new Blob([bytes], { type: 'image/png' }));
const c = document.createElement('canvas'); c.width = bm.width; c.height = bm.height; const x = c.getContext('2d'); x.drawImage(bm, 0, 0);
return { w: bm.width, h: bm.height, rgba: x.getImageData(0, 0, bm.width, bm.height).data };
}
/* test3: items or Tamapoints changed: with "keep saves" the device would bring back its own T18 save (session, sector
* tables, spare blocks) over the changed one. The whole T18 save comes from the image then (it is the device's state at
* reading plus the change). */
function t18Fresh(rom, off, fresh) {
const c = E.extraCfg(rom, off); if (!c || c.kind !== 't18') return;
fresh.push([c.saveOff, c.saveOff + 0x24000]);
for (const b of c.spare) if (b !== 0xFFFF) fresh.push([b << 16, (b + 1) << 16]);
}
/* test2: a name the Studio cannot read (Japanese letters) shows as its number */
function t18Nm(r) { return r.readable !== false || !r.cat ? r.name : t('t18ItemNo', { n: r.cat }); }
/* test6: MixingMeets for T18Emu on the Paradise. The page (mixing-meets.com, Connect and Return) speaks Web Bluetooth
* with "TMGC_meets" (service fff0, fff1 notify, fff2 write). This bookmarklet replaces navigator.bluetooth on that page:
* "Select Tamagotchi" then opens the serial port of the UART dongle on the Paradise's contacts, and T18Emu hands the data
* to the firmware's Bluetooth module, as the Android T18Emu does. Frames: see t18/src/app/main.c (T18_LINK). */
function pmxBridge() {
if (window.__pmxBridge) { alert('Paramix: bridge already on'); return; }
if (!navigator.serial) { alert('Paramix: this browser has no Web Serial (Chrome or Edge on a computer)'); return; }
window.__pmxBridge = 1;
const bn = document.createElement('div');
bn.style.cssText = 'position:fixed;left:8px;bottom:8px;z-index:2147483647;background:#1d2b44;color:#fff;padding:8px 12px;border-radius:8px;font:13px/1.3 sans-serif;max-width:320px';
const st = (m) => { bn.textContent = 'Paramix: ' + m; };
st('bridge on. Select Tamagotchi, then choose the dongle.'); document.body.appendChild(bn);
const FFF0 = '0000fff0-0000-1000-8000-00805f9b34fb', FFF1 = '0000fff1-0000-1000-8000-00805f9b34fb', FFF2 = '0000fff2-0000-1000-8000-00805f9b34fb';
let port = null, reader = null, writer = null, hello = 0, ack = null, ping = null, live = false;
const notes = [], gone = [];
let fs = 0, fty = 0, flen = 0, fbuf = [], fsum = 0;
const frame = (ty, d) => { const a = new Uint8Array(4 + d.length); a[0] = 0x5A; a[1] = ty; a[2] = d.length; let s = ty + d.length; for (let i = 0; i < d.length; i++) { a[3 + i] = d[i]; s += d[i]; } a[3 + d.length] = s & 255; return a; };
const send = (ty, d) => writer.write(frame(ty, d || []));
const R = { uuid: FFF1, properties: { notify: true, read: false, write: false, writeWithoutResponse: false }, value: null,
addEventListener: (ty, fn) => { if (ty === 'characteristicvaluechanged') notes.push(fn); }, removeEventListener: () => {},
startNotifications: async () => R, stopNotifications: async () => R };
const got = (ty, d) => {
if (ty === 0x48) { hello = Date.now(); return; }
if (ty === 0x4B) { const a = ack; ack = null; if (a) a(); return; }
if (ty === 0x4E) { const u = new Uint8Array(d); R.value = new DataView(u.buffer); for (const fn of notes) { try { fn({ target: R }); } catch (e) { console.error(e); } } }
};
const feed = (b) => {
if (fs === 0) { if (b === 0xA5) fs = 1; return; }
if (fs === 1) { fty = b; fsum = b; fs = 2; return; }
if (fs === 2) { if (b > 64) { fs = 0; return; } flen = b; fsum += b; fbuf = []; fs = flen ? 3 : 4; return; }
if (fs === 3) { fbuf.push(b); fsum += b; if (fbuf.length >= flen) fs = 4; return; }
fs = 0; if ((fsum & 255) === b) got(fty, fbuf);
};
const down = () => { if (!live) return; live = false; dev.gatt.connected = false; clearInterval(ping); for (const fn of gone) { try { fn({ target: dev }); } catch (e) {} } };
const readLoop = async () => { try { for (;;) { const { value, done } = await reader.read(); if (done) break; for (const b of value) feed(b); } } catch (e) {} st('dongle closed'); down(); };
const write = async (data) => {
if (!live) throw new Error('Your Tama disconnected');
const u = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
for (let o = 0; o < u.length; o += 60) {
const p = new Promise((res, rej) => { ack = res; setTimeout(() => { if (ack === res) { ack = null; rej(new Error('Paradise did not answer')); } }, 15000); });
await send(0x57, Array.from(u.subarray(o, o + 60))); await p;
}
};
const T = { uuid: FFF2, properties: { write: true, writeWithoutResponse: false, notify: false, read: false },
writeValueWithResponse: write, writeValue: write, writeValueWithoutResponse: write };
const svc = { uuid: FFF0, isPrimary: true, getCharacteristic: async (u) => { u = String(u).toLowerCase(); if (u.indexOf('fff1') >= 0) return R; if (u.indexOf('fff2') >= 0) return T; throw new Error('No characteristic ' + u); } };
const dev = { id: 'paramix', name: 'TMGC_meets', addEventListener: (ty, fn) => { if (ty === 'gattserverdisconnected') gone.push(fn); }, removeEventListener: () => {} };
dev.gatt = { device: dev, connected: false,
connect: async () => { await send(0x43, [1]); live = true; dev.gatt.connected = true; clearInterval(ping); ping = setInterval(() => { send(0x50, []).catch(() => {}); }, 1000); st('connected to the Paradise'); return dev.gatt; },
disconnect: () => { if (writer) send(0x43, [0]).catch(() => {}); down(); },
getPrimaryService: async (u) => { if (String(u).toLowerCase().indexOf('fff0') < 0) throw new Error('No services matching UUID ' + u); return svc; } };
const requestDevice = async () => {
if (!port) {
const pp = await navigator.serial.requestPort();
try { await pp.open({ baudRate: 460800, bufferSize: 4096 }); }
catch (e) { st('the dongle is busy. In Paramix Studio press "UART freigeben" (or close the Studio), then try again.'); alert('Paramix: the dongle is busy.\nParamix Studio still holds it: press "UART freigeben" there or close the Studio, then try again.'); throw e; }
port = pp;
reader = port.readable.getReader(); writer = port.writable.getWriter(); readLoop();
}
st('looking for T18Emu on the Paradise...');
const t0 = Date.now(); while (!hello && Date.now() - t0 < 4000) await new Promise((r) => setTimeout(r, 100));
if (!hello) { st('no answer from the Paradise'); throw new Error('Paradise not found: start T18Emu and check the dongle'); }
st('Paradise found'); return dev;
};
try { Object.defineProperty(navigator, 'bluetooth', { configurable: true, value: { requestDevice, getAvailability: async () => true } }); }
catch (e) { alert('Paramix: could not take over Bluetooth on this page'); }
window.addEventListener('pagehide', () => { try { if (writer) writer.write(frame(0x43, [0])); } catch (e) {} });
}
function pmxBridgeHref() { return 'javascript:' + encodeURIComponent('(' + pmxBridge.toString() + ')()'); }
window.pmxBridgeHref = pmxBridgeHref; // for the test
window.pmxTest = { uartWarnInto: (b) => uartWarnInto(b), devFree: () => devFree(), devRender: () => devRender(), dv: () => dv };
function t18BridgeInto(box) {
const h = document.createElement('h4'); h.className = 'subhead'; h.textContent = t('mmTitle'); box.appendChild(h);
const a = document.createElement('a'); a.className = 'btn small'; a.href = pmxBridgeHref(); a.textContent = t('mmLink'); a.onclick = (e) => { e.preventDefault(); toast(t('mmDrag')); };
box.appendChild(a);
const w = document.createElement('div'); w.className = 'hint'; w.style.whiteSpace = 'pre-line'; w.textContent = t('mmHint'); box.appendChild(w);
uartWarnInto(box);
pairInto(box, 'pairHint');
}
/* 1.6.9: visits over the contacts for the other emulators (T7Emu Tama-Go so far) */
const IR_HINT = { ps: 'pairHintPs', idl: 'pairHintIdl' }; /* TamaEmu with the infrared link (1.6.9) */
function linkInto(box, hint) { pairInto(box, hint); }
/* test7: the bridge page needs the dongle for themselves. While the Studio holds it, say so and
* offer to let it go. */
const uartWarns = [];
function uartWarnRender() {
for (const b of uartWarns) { if (!b.isConnected) continue; b.hidden = !dv.io; }
}
function uartWarnInto(box) {
const d = document.createElement('div'); d.className = 'uartwarn';
const m = document.createElement('span'); m.textContent = t('uartBusy') + ' ';
const k = document.createElement('button'); k.className = 'btn small'; k.textContent = t('uartFree'); k.onclick = () => devFree();
d.append(m, k); box.appendChild(d); uartWarns.push(d); d.hidden = !dv.io;
}
async function devFree() {
if (dv.run) { toast(t('uartRun')); return; }
try { if (dv.io) await dv.io.close(); } catch (e) {}
dv.io = null; dv.d = null; dv.loaded = false; devRender(t('devNone')); toast(t('uartFreed'));
}
/* 1.6.9: visits between two Paradise: plugged together at the top, the programs talk over the contacts themselves */
function pairInto(box, hint) {
const h = document.createElement('h4'); h.className = 'subhead'; h.textContent = t('pairTitle'); box.appendChild(h);
const w = document.createElement('div'); w.className = 'hint'; w.style.whiteSpace = 'pre-line'; w.textContent = t(hint); box.appendChild(w);
}
function t18ItemsInto(box, tg) {
const T = t18Target(tg); if (!T) return;
const it = E.t18Items(T.fw);
const h = document.createElement('h4'); h.className = 'subhead'; h.textContent = t('t18Items'); box.appendChild(h);
if (!it.save) { const w = document.createElement('div'); w.className = 'hint'; w.textContent = t('t18ItemsNoSave'); box.appendChild(w); return; }
const tools = document.createElement('div'); tools.className = 'tools';
const pick = document.createElement('button'); pick.className = 'btn small'; pick.textContent = t('t18ItemsPick');
pick.onclick = () => { state.itemT = tg; $('fileT18Item').click(); };
const pl = document.createElement('label'); pl.className = 'check'; const ps = document.createElement('span'); ps.textContent = t('t18Points') + ' ';
const pi = document.createElement('input'); pi.type = 'number'; pi.min = 0; pi.max = 65535; pi.value = String(it.points); pi.style.width = '7em';
pi.onchange = () => { E.t18Points(T.fw, +pi.value || 0); T.set(); renderEmu(); };
pl.append(ps, pi); tools.append(pick, pl); box.appendChild(tools);
const grid = document.createElement('div'); grid.className = 'dlcgrid';
for (const a of it.areas) {
const d = document.createElement('div'); d.className = 'dlcbox';
const used = a.slots.filter((x) => x.rec);
const hh = document.createElement('h4'); hh.textContent = t('t18A_' + a.key) + ' ' + used.length + '/' + (used.length + a.free); d.appendChild(hh);
for (const x of used) {
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.className = 'itemname'; n.append(picCanvas(x.rec.pic, 1), document.createTextNode(' ' + t18Nm(x.rec)));
const sel = document.createElement('select'); [1, 2, 3].forEach((v) => { const o = document.createElement('option'); o.value = String(v); o.textContent = v + '×'; sel.appendChild(o); });
sel.value = String(x.count); sel.onchange = () => { E.t18ItemCount(T.fw, a.key, x.n, +sel.value); T.set(); renderEmu(); };
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = t('dlcDel');
b.onclick = () => { E.t18ItemDel(T.fw, a.key, x.n); T.set(); toast(t('dlcGone', { n: t18Nm(x.rec) })); renderEmu(); };
const ctl = document.createElement('span'); ctl.className = 'itemctl'; ctl.append(sel, b); r.append(n, ctl); d.appendChild(r);
}
const f = document.createElement('div'); f.className = 'dlcrow free'; f.textContent = t('dlcFreeN', { n: a.free }); d.appendChild(f);
grid.appendChild(d);
}
{ const d = document.createElement('div'); d.className = 'dlcbox';
const hh = document.createElement('h4'); hh.textContent = t('t18A_room'); d.appendChild(hh);
const r = document.createElement('div'); r.className = 'dlcrow';
if (it.room) {
const n = document.createElement('span'); n.className = 'itemname'; n.append(picCanvas(it.room.pic, 0.5), document.createTextNode(' ' + t18Nm(it.room)));
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = t('t18RoomBack');
b.onclick = () => { E.t18RoomReset(T.fw); T.set(); renderEmu(); };
r.append(n, b);
} else r.textContent = t('t18RoomBuiltin');
d.appendChild(r); grid.appendChild(d); }
box.appendChild(grid);
const w = document.createElement('div'); w.className = 'hint'; w.textContent = t('t18ItemsHint'); box.appendChild(w);
}
function figTarget(tg = state.figT) {
if (typeof tg === 'number') { const x = (state.extras || [])[tg]; if (!x || x.kind || E.t7Kind(x.rom) !== 'go') return null; x.figs = x.figs || []; return x; }
return t7State();
}
async function mainGuestLoad() {
if (state.mainGuest) return true;
const cfg = romEmuCfg(state.ctx.rom); if (!cfg) return false;
const g = await SV.emuGuestAsync((a, n) => state.ctx.rom.subarray(a, a + n), cfg);
state.mainGuest = { g, dev: cfg.dev };
return true;
}
function renderT7Figs() { $('btnT7Fig').hidden = true; $('t7Figs').hidden = true; } // 1.6.8: the figures are in the program's row
/* list of the figures of one T7Emu, each with × */
function figsInto(box, tg) {
const st = figTarget(tg); if (!st) return;
if (!st.figs.length) { const d = document.createElement('span'); d.className = 'hint'; d.textContent = t('t7FigNone'); box.appendChild(d); return; }
const wrap = document.createElement('div'); wrap.className = 'chips';
st.figs.forEach((f, i) => {
const c = document.createElement('span'); c.className = 'chip keep'; c.textContent = E.t7FigName(f.name) + ' ';
const x = document.createElement('button'); x.className = 'btn small'; x.textContent = '×';
x.onclick = () => { const s2 = figTarget(tg); s2.figs.splice(i, 1); if (typeof tg === 'number') state.extrasDirty = true; else { s2.size = t7Size(s2); state.emu = s2; emuRemoveClear(); } renderEmu(); };
c.appendChild(x); wrap.appendChild(c);
});
box.appendChild(wrap);
}
/* the download content stores of one TamaEmu, each slot with its name */
function dlcInto(box, tg) {
const g0 = dlcTarget(tg); if (!g0) return;
const grid = document.createElement('div'); grid.className = 'dlcgrid';
for (const st of E.dlcStores(g0.guest)) {
const used = st.slots.filter(x => x.name).length;
const d = document.createElement('div'); d.className = 'dlcbox';
const h = document.createElement('h4'); h.textContent = t('dlcK' + st.kind) + ' ' + used + '/' + st.slots.length; d.appendChild(h);
for (const x of st.slots) {
if (!x.name) continue;
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.textContent = x.name;
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = t('dlcDel');
b.onclick = () => { const g = dlcTarget(tg); g.set(E.dlcFree(g.guest, st.kind, x.slot)); toast(t('dlcGone', { n: x.name })); renderEmu(); };
r.append(n, b); d.appendChild(r);
}
const f = document.createElement('div'); f.className = 'dlcrow free'; f.textContent = t('dlcFreeN', { n: st.slots.length - used }); d.appendChild(f);
grid.appendChild(d);
}
box.appendChild(grid);
}
function selectInto(box, label, items, val, fn) {
const r = document.createElement('div'); r.className = 'tools';
const l = document.createElement('label'); l.className = 'check';
const sp = document.createElement('span'); sp.textContent = label + ' ';
const sel = document.createElement('select'); items.forEach((txt, i) => { const o = document.createElement('option'); o.value = String(i); o.textContent = txt; sel.appendChild(o); });
sel.value = String(val || 0); sel.onchange = () => fn(+sel.value);
l.append(sp, sel); r.appendChild(l); box.appendChild(r);
}
/* 1.6.8: TamaEmu and T18Emu options (set here, the toy has no menu for them) */
function optInto(box, o, set) {
selectInto(box, t('optVol'), [t('optVolN'), t('optVolQ'), t('optVolL'), t('optOff')], o.vol, (v) => { o.vol = v; set(); });
{ const U = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]; // 5 % .. 100 %
selectInto(box, t('optDim'), U.map((i) => E.OPT_LV[i] + ' %'), Math.max(0, U.indexOf(o.dim)), (v) => { o.dim = U[v]; set(); }); }
selectInto(box, t('optScr'), [t('optScrToy'), '10 s', '20 s', '30 s', '1 Min', '2 Min', '5 Min', '10 Min'], o.off, (v) => { o.off = v; set(); });
const h = document.createElement('p'); h.className = 'hint'; h.textContent = t('optDev'); box.appendChild(h);
}
/* 1.7.3 test7: the program's "remember where you left off" taken over from the ROM */
function sessKeep(x, y) { if (x.sess === false) y.sess = false; return y; }
const SESS_KINDS = new Set(['tama', 't18', 't7', 'v1', 'gb', 'sms', 'pm', 'ab']);
function clockOff() { return !!state.clean && state.cleanClock === false; }
function checkInto(box, label, hint, on, fn, off) {
const r = document.createElement('div'); r.className = 'tools';
const l = document.createElement('label'); l.className = 'check';
const c = document.createElement('input'); c.type = 'checkbox'; c.checked = on; c.disabled = !!off; c.onchange = () => fn(c.checked);
const sp = document.createElement('span'); sp.textContent = label;
l.append(c, ' ', sp); r.appendChild(l);
if (hint) { const h = document.createElement('span'); h.className = 'hint'; h.textContent = hint; r.appendChild(h); }
box.appendChild(r);
}
/* All programs in one list (1.6.8). Each row opens with ▾: its settings, figures or download slots. */
function renderApps() {
const box = $('appsList'); box.innerHTML = '';
const room = appRoom();
$('btnApp').disabled = !room || !E.t7Embedded();
state.progOpen = state.progOpen || new Set();
const row = (key, name, tag, cls, btns, detail) => {
const r = document.createElement('div'); r.className = 'prow ' + (cls || '');
const open = !!detail && state.progOpen.has(key);
if (detail) { const tb = document.createElement('button'); tb.className = 'btn small ptog'; tb.textContent = open ? '▴' : '▾'; tb.title = t('progMore'); tb.onclick = () => { if (open) state.progOpen.delete(key); else state.progOpen.add(key); renderEmu(); }; r.appendChild(tb); }
const n = document.createElement('span'); n.className = 'pname'; n.textContent = name;
const g = document.createElement('span'); g.className = 'ptag'; g.textContent = tag;
r.append(n, g);
for (const [txt, fn, title, c, off] of btns) { const b = document.createElement('button'); b.className = 'btn small' + (c ? ' ' + c : ''); b.textContent = txt; if (title) b.title = title; if (fn) b.onclick = fn; if (off) b.disabled = true; r.appendChild(b); }
box.appendChild(r);
if (open) { const d = document.createElement('div'); d.className = 'pdet'; detail(d); box.appendChild(d); }
};
const has = emuInstalled(), em = state.emu, tagMain = t(state.launch ? 'progMainL' : 'progMain');
// DOOM at 0x0A0000 is the main program then (in a start device the emulators all go to the menu)
const dm = doomMain();
const dIn = doomInstalled(), dGone = dIn && !state.doom && (state.emuRemove || (!state.launch && !!state.emu));
const doomOut = () => { if (state.doom) state.doom = null; else { state.emuRemove = true; if (!state.launch) state.emu = null; } renderEmu(); renderDoom(); };
const doomBack = () => { state.emuRemove = false; if (!state.launch) state.emu = null; renderEmu(); renderDoom(); };
// 1.6.9 test13: in the start device DOOM stays at 0x0A0000, but the main program (first in the menu, can start when
// switched on) can be any program of the list (switch FELD_AUTO in the menu)
const lp = !!state.launch && (dm || !!state.clean) && mainV9();
if (lp && state.mainPick && state.mainPick !== 'emu' && !(state.extras || []).includes(state.mainPick)) state.mainPick = null;
if (lp && state.mainPick === 'emu' && !em) state.mainPick = null;
const pick = (v) => { state.mainPick = v; state.mainDirty = true; renderEmu(); };
const autoL = (d) => checkInto(d, t('emuAuto'), t('autoHintL'), !!state.emuAuto, (v) => { state.emuAuto = v; state.mainDirty = true; renderEmu(); });
const star = (on, v) => on ? ['★', null, t('progIsMain'), 'pstar on', true] : ['☆', () => pick(v), t('progMakeMain'), 'pstar'];
const doomIsMain = dm && !(lp && state.mainPick);
if (dm) row('doom', 'DOOM', (doomIsMain ? tagMain : t('progMenu')) + (state.doom ? ' · ' + t('stNew') : ''), doomIsMain ? 'main' : '', [lp ? star(doomIsMain, null) : ['★', null, t('progIsMain'), 'pstar on', true], ['×', doomOut, t('doomOff')]],
state.launch ? (lp && doomIsMain && !state.clean ? autoL : null) : (d) => checkInto(d, t('emuAuto'), t('doomAutoHint'), !!state.emuAuto, (v) => { state.emuAuto = v; renderEmu(); }));
else if (dGone) row('doom', 'DOOM', t('progGone'), 'main gone', [['↺', doomBack, t('progUndo')]]);
const undo = () => { state.emu = null; emuRemoveClear(); state.t7save = null; renderEmu(); renderDoom(); };
// settings of the main program (they are in the program at 0x0A0000)
const mainSet = (d, dev) => {
if (!dm && !state.clean) checkInto(d, t('emuAuto'), t(state.launch && mainV9() ? 'autoHintL' : 'emuAutoHint'), !!state.emuAuto, (v) => { state.emuAuto = v; if (state.launch) state.mainDirty = true; renderEmu(); });
else if (lp && state.mainPick === 'emu') autoL(d);
checkInto(d, t('emuClock'), t(clockOff() ? 'emuClockOff' : 'emuClockHint'), !clockOff() && state.emuClock !== false, (v) => { state.emuClock = v; renderEmu(); }, clockOff());
checkInto(d, t('emuSess'), t('emuSessHint'), state.emuSess !== false, (v) => { state.emuSess = v; renderEmu(); });
if (dev === '4u' || dev === '4u-plain') checkInto(d, t('emuNfc'), t('emuNfcHint'), state.emuNfc !== false, (v) => { state.emuNfc = v; renderEmu(); });
// 1.7.3 test20 PACK_OPT: pack the firmware (less room, some places slower); an installed one is read back and built anew
if (E.PACK_OPT && dev && E.DEVICES[dev]) checkInto(d, t('emuPack'), t('emuPackHint'), !!state.emuPack, (v) => {
state.emuPack = v;
if (state.emu && state.emu.guest) { const pk = E.packMain(state.emu.guest, state.emu.dev, null, v); state.emu = Object.assign({}, state.emu, { size: pk.blob.length, big: pk.big }); renderEmu(); return; }
busy(async () => { if (await mainGuestLoad()) { const mg = state.mainGuest, pk = E.packMain(mg.g, mg.dev, null, v); state.emu = { guest: mg.g, dev: mg.dev, size: pk.blob.length, big: pk.big, kept: true }; state.mainGuest = null; } renderEmu(); });
});
if (dev !== 't7' && dev !== 'v1' && dev) { state.emuOpt = state.emuOpt || { vol: 0, dim: 0, off: 0 }; optInto(d, state.emuOpt, () => renderEmu()); }
};
const xRow = (x, i) => {
const b = [], go = !x.kind && E.t7Kind(x.rom) === 'go', big = x.kind === 'tama' && DLC_DEV.includes(x.dev);
if (go) b.push([t('t7FigPick') + (x.figs && x.figs.length ? ' (' + x.figs.length + ')' : ''), () => { state.figT = i; $('fileT7Fig').click(); }]);
if (big) b.push([t('dlcPick'), () => { state.dlcT = i; $('fileDlc').click(); }]);
const xMain = lp && state.mainPick === x;
if (lp) b.push(star(xMain, x));
else { const ok = !dm && canMain(x); b.push(['☆', ok ? () => busy(() => mainChecked(i)) : null, t(ok ? 'progMakeMain' : x.kind === 'gb' ? 'gbNoMain' : x.kind === 'sms' ? 'smsNoMain' : x.kind === 'pm' ? 'pmNoMain' : x.kind === 'ab' ? 'abNoMain' : x.kind === 'wolf' ? 'wolfNoMain' : dm ? 'progNoMainDoom' : 'progNoMain'), 'pstar', !ok]); }
b.push(['×', () => { if (state.mainPick === x) { state.mainPick = null; state.mainDirty = true; } if (x.fromPara) state.emuRemove = true; if (x.wadSrc) state.doom = null; state.extras.splice(i, 1); state.extrasDirty = true; state.t7saveX = null; state.dlcT = 'main'; state.figT = 'main'; state.progOpen = new Set(); renderEmu(); }, t('progDel')]);
const det = (x.kind === 'wolf' || x.kind === 'doom') && !xMain ? null : (d) => { // 1.7.3 test7: every emulator has "remember where you left off" // test37: the Game Boy has no clock
if (xMain) autoL(d);
if (!(x.kind === 'v1' && !E.v1Clock(x.rom)) && x.kind !== 'gb' && x.kind !== 'sms' && x.kind !== 'pm' && x.kind !== 'ab' && x.kind !== 'wolf' && x.kind !== 'doom') checkInto(d, t('emuClock'), t(clockOff() ? 'emuClockOff' : 'emuClockHint'), !clockOff() && x.clock !== false, (v) => { x.clock = v; state.extrasDirty = true; renderEmu(); }, clockOff());
if (SESS_KINDS.has(E.extraKind(x))) checkInto(d, t('emuSess'), t('emuSessHint'), x.sess !== false, (v) => { x.sess = v; state.extrasDirty = true; renderEmu(); });
if (x.kind === 'tama' || x.kind === 't18') { x.opt = x.opt || { vol: 0, dim: 0, off: 0 }; optInto(d, x.opt, () => { state.extrasDirty = true; renderEmu(); }); }
if (x.kind === 'tama' && (x.dev === '4u' || x.dev === '4u-plain')) checkInto(d, t('emuNfc'), t('emuNfcHint'), x.nfc !== false, (v) => { x.nfc = v; state.extrasDirty = true; renderEmu(); });
if (E.PACK_OPT && x.kind === 'tama') checkInto(d, t('emuPack'), t('emuPackHint'), !!x.pack, (v) => { x.pack = v; state.extrasDirty = true; renderEmu(); }); // 1.7.3 test20
if (go) { figsInto(d, i); t7GpInto(d, i); linkInto(d, 'pairHintT7'); }
if (big) dlcInto(d, i);
if (x.kind === 'tama' && IR_HINT[x.dev]) linkInto(d, IR_HINT[x.dev]);
if (x.kind === 'v1' && E.v1Name(x.rom).startsWith('DIGIMON')) linkInto(d, 'pairHintDigi');
if (x.kind === 'v1' && E.v3Detect(x.rom)) linkInto(d, 'pairHintV3');
if (x.kind === 't18') { t18ItemsInto(d, i); t18BridgeInto(d); }
};
row('x' + i, E.extraName(x), xMain ? tagMain : t('progMenu'), xMain ? 'main' : '', b, det);
};
const xFirst = lp && state.mainPick && state.mainPick !== 'emu' ? (state.extras || []).indexOf(state.mainPick) : -1;
if (xFirst >= 0) xRow(state.extras[xFirst], xFirst);
if (em) {
const nm = emuNm(em);
const b = [], go = em.t7 && E.t7Kind(em.rom) === 'go', big = !em.t7 && !em.t18 && !em.v1 && DLC_DEV.includes(em.dev);
if (go) b.push([t('t7FigPick') + (em.figs.length ? ' (' + em.figs.length + ')' : ''), () => { state.figT = 'main'; $('fileT7Fig').click(); }]);
if (big) b.push([t('dlcPick'), () => { state.dlcT = 'main'; $('fileDlc').click(); }]);
const emMain = lp && state.mainPick === 'emu';
b.push(lp ? star(emMain, 'emu') : dm ? ['☆', null, t('progNoMainDoom'), 'pstar', true] : ['★', null, t('progIsMain'), 'pstar on', true]);
b.push(['×', undo, t('progUndo')]);
row('main', nm, dm ? (emMain ? tagMain : t('progMenu')) + ' · ' + t('stNew') : em.kept ? tagMain : tagMain + ' · ' + t('stNew'), dm && !emMain ? '' : 'main', b, (d) => { mainSet(d, em.dev); if (go) { figsInto(d, 'main'); linkInto(d, 'pairHintT7'); } if (big) dlcInto(d, 'main'); if (!em.t7 && !em.t18 && !em.v1 && IR_HINT[em.dev]) linkInto(d, IR_HINT[em.dev]); if (em.v1 && E.v3Detect(em.rom)) linkInto(d, 'pairHintV3'); if (em.t18) { t18ItemsInto(d, 'main'); t18PicsInto(d); t18BridgeInto(d); } });
} else if (has && !state.emuRemove) {
const nm = (F.embedded() && F.feldApps(state.ctx.rom, F.embedded().stub).name0) || mainName(state.ctx.rom) || 'EMU';
const b = [], c7 = F.emuType(state.ctx.rom) === 't7' && E.t7Cfg(state.ctx.rom), go = c7 && c7.romLen !== 0xC0000, cfg = romEmuCfg(state.ctx.rom), big = cfg && DLC_DEV.includes(cfg.dev);
if (go) b.push([t('t7FigPick') + (c7.figs.length ? ' (' + c7.figs.length + ')' : ''), () => { state.figT = 'main'; $('fileT7Fig').click(); }]);
if (big) b.push([t('dlcPick'), () => busy(async () => { if (await mainGuestLoad()) { state.dlcT = 'main'; $('fileDlc').click(); } })]);
b.push(['★', null, t('progIsMain'), 'pstar on', true]);
b.push(['×', () => { state.emu = null; state.emuRemove = true; renderEmu(); }, t('emuOff')]);
row('main', nm, tagMain, 'main', b, (d) => {
mainSet(d, cfg ? cfg.dev : F.emuType(state.ctx.rom));
if (go) { figsInto(d, 'main'); t7GpInto(d, 'main'); linkInto(d, 'pairHintT7'); }
if (cfg && IR_HINT[cfg.dev]) linkInto(d, IR_HINT[cfg.dev]);
if (F.emuType(state.ctx.rom) === 't18') { t18ItemsInto(d, 'main'); t18PicsInto(d); t18BridgeInto(d); }
if (big) { if (state.mainGuest) dlcInto(d, 'main'); else { const w = document.createElement('div'); w.className = 'hint'; w.textContent = t('dlcLoading'); d.appendChild(w); busy(async () => { await mainGuestLoad(); renderEmu(); }); } }
});
} else if (has && state.emuRemove && !state.paraMainTaken) {
const nm = (F.embedded() && F.feldApps(state.ctx.rom, F.embedded().stub).name0) || mainName(state.ctx.rom) || 'EMU';
row('main', nm, t('progGone'), 'main gone', [['↺', undo, t('progUndo')]]);
}
// further programs (started from the menu): each with its own clock setting; 1.7.2 test4: the main one first
(state.extras || []).forEach((x, i) => { if (i !== xFirst) xRow(x, i); });
if (!box.children.length) { const d = document.createElement('span'); d.className = 'hint'; d.textContent = t('progNone'); box.appendChild(d); }
else if ((state.extras || []).length && !menuWanted()) { const d = document.createElement('span'); d.className = 'hint'; d.textContent = t('appNeedMenu'); box.appendChild(d); }
}
/* 1.6.8: choose which program is the main one (A and C, or the first entry of the start device) */
/* does a program in the menu come from an older Studio? (vectors and code differ from the program in this one) */
/* test24 EXIT_KEY: how to go back from a program, for all of them (tab Menu): "EX" << 16 | mode in the last word of
* each program's vector table (IRQ 63, never used); 0 = as before (the word stays the program's own). */
const EXIT_KEY = true, EXIT_AT = 0x13C, EXIT_MAGIC = 0x5845;
function exitOffs(rom) {
const offs = F.isClean(rom) ? [] : [0xA0000]; try { for (const x of romExtras(rom)) offs.push(x.off); } catch (e) {}
return offs.filter((o) => { const w = rd32(rom, o + EXIT_AT); return (w >>> 16) === EXIT_MAGIC || (w === rd32(rom, o + EXIT_AT - 4) && (w & 1) && w < 0x10000); });
}
function exitGet(rom) { for (const o of exitOffs(rom)) { const w = rd32(rom, o + EXIT_AT); if ((w >>> 16) === EXIT_MAGIC) return w & 3; } return 0; }
function exitSet(rom, mode) {
let out = rom;
for (const o of exitOffs(rom)) {
const w = mode ? ((EXIT_MAGIC << 16) | mode) >>> 0 : rd32(rom, o + EXIT_AT - 4);
if (rd32(out, o + EXIT_AT) === w) continue;
if (out === rom) out = new Uint8Array(rom);
out[o + EXIT_AT] = w & 255; out[o + EXIT_AT + 1] = (w >>> 8) & 255; out[o + EXIT_AT + 2] = (w >>> 16) & 255; out[o + EXIT_AT + 3] = (w >>> 24) & 255;
}
return out;
}
function extrasOld(rom, apps) {
const up = new Set();
try {
const progs = { t7: E.t7Embedded(), tama: E.embedded() && E.embedded().app, t18: E.t18Embedded(), v1: E.v1Embedded(), gb: E.gbEmbedded(), sms: E.smsEmbedded(), pm: E.pmEmbedded(), ab: E.abEmbedded() }; // 1.7.3 test5: ArduboyEmu too
for (const x of E.appsRead(rom, apps)) {
const k = E.extraKind(x), img = k === 't18' ? null : k === 'v1' && E.v3Detect(x.rom) ? E.v3Embedded() : k === 'gb' && E.gbIsColor(x.rom) ? E.gbcEmbedded() : progs[k]; if (!img) continue; // 1.7.2: Game Boy Color games against GBCEmu // T18Emu: its image is patched all over; test4: V3Emu against its own program
const at = x.off, same = (a, z) => { for (let i = a; i < z; i++) if (rom[at + i] !== img[i]) return false; return true; };
if (!same(0, EXIT_AT) || !same(0x800, Math.min(img.length, 0x10000))) up.add(groupKind({ kind: k }));
}
} catch (e) { return false; }
return up.size ? up : false; // 1.7.3 test6: the groups (chips) whose program is older
}
/* 1.6.8: choosing or dropping an emulator does not bring back a DOOM the user took out (emuRemove means "take the
* program at 0x0A0000 out", which is DOOM when DOOM is built in) */
function emuRemoveClear() { if (!doomInstalled()) state.emuRemove = false; }
/* 1.6.9 test13: the Studio's menu program knows the main program out of its list (version 9) */
function mainV9() { const fe = F.embedded(); if (!fe) return false; const f = fe.feld; for (let i = 0; i + 8 <= f.length; i += 4) if ((f[i] | f[i + 1] << 8 | f[i + 2] << 16 | f[i + 3] << 24) >>> 0 === 0x444C4546) return (f[i + 4] | f[i + 5] << 8) >= 9; return false; }
function doomMain() { if (doomFree()) return false; return !!state.doom || (doomInstalled() && !state.emuRemove && (!!state.launch || !state.emu)); }
/* 1.7.2 test3 DOOM_FREE: without the Paradise DOOM is a program of the menu like the others: placed anywhere, any program
* can be the main one (star) and start when switched on. The DOOM tab's WAD, or the DOOM of a start device with the
* Paradise, become an entry of the list. */
const DOOM_FREE = true;
const DOOM_EPS = true;
const DOOM_E4 = true;
const PWAD_ON = true; // 1.7.3 test17: extra WADs (Sigil as its own entry, map packs merged) // 1.7.3 test14: Ultimate DOOM, episode 4
const DOOM_WHOLE = true; // 1.7.3 test15: without the Paradise the whole WAD as one entry (the DOOM program reaches a WAD over 8 MB)
const DOOM_WHOLE_REGION = 0xA0000; // level data room of the whole WAD (a cache: what does not fit is read from the WAD; 640 KB so that DOOM II fits)
const DOOM_MUSSZ = true; // 1.7.3 test14: the sizes and the room follow the music box
/** Size of one episode as it will be written: with music if ticked and it fits */
function doomEpSize(f) { return !f ? 0 : DOOM_MUSSZ && $('doomMusic').checked && f.music ? f.sizeM : f.sizeP; } // 1.7.3 test12: without the Paradise several DOOM episodes, each its own menu entry
/* test18: what the DOOM chip of the overview says: the episodes, the own entries of extra WADs (Sigil) and the map packs
* in it (one-humanity) */
function doomChip(d) {
const sel = d.ok.filter((e) => d.sel.has(e)), base = sel.filter((e) => !'PQ'.includes(e[0])), own = sel.filter((e) => 'PQ'.includes(e[0])).map((e) => (d.titles || {})[e]);
const main = d.d2 ? (DOOM_WHOLE && d.whole ? 'DOOM II' : '') : (DOOM_WHOLE && d.whole ? 'E' + d.eps.join(', E') : base.length ? 'E' + base.join(', E') : '');
const packs = (d.pwads || []).filter((p) => !p.info.eps.length).map((p) => p.info.title);
return [main && packs.length && (d.whole || base.length) ? main + ' (' + packs.join(', ') + ')' : main].concat(own).filter(Boolean).join(', ');
}
function doomFree() { return DOOM_FREE && !!state.clean; }
function doomXs() { return (state.extras || []).filter((x) => x.kind === 'doom'); }
function doomMcuOf(x) {
const d = x.wadSrc; if (!d) return x.mcu || null;
const f = d.fit[x.ep || $('doomEp').value] || (x.ep !== 'all' && d.fit[d.ok[0]]); if (!f || !f.plain) return null; // 1.7.3 test12: x.ep (several episodes)
return $('doomMusic').checked && f.music ? f.mcuM : f.mcuP;
}
function doomParaX(src) {
const len = rd32(src, D.WAD_OFF); if (!len || len > D.REGION_OFF - D.WAD_OFF - 4) return null;
const keys = D.doomKeysGet(src) || Object.assign({}, D.KEYS_DEFAULT);
return { kind: 'doom', mcu: src.slice(D.WAD_OFF + 4, D.WAD_OFF + 4 + len), keys, keys0: JSON.stringify(keys), save: src.slice(D.SAVE_OFF, D.SAVE_END), fromPara: true };
}
/* 1.7.2 test4: the main program of a start device with the Paradise (at 0x0A0000) becomes an entry of the list too, so
* there is only one star: it keeps it until another program gets it */
async function paraMainSync() {
if (!DOOM_FREE) return;
if (!doomFree()) {
if (state.paraMainTaken) { if (state.mainPick && state.mainPick.fromParaMain) state.mainPick = null; state.extras = (state.extras || []).filter((x) => !x.fromParaMain); state.emuRemove = false; state.paraMainTaken = false; }
return;
}
if (state.ctx.clean || state.paraMainTaken || state.emu || state.emuRemove || !emuInstalled()) return;
const x = await installedX(state.ctx.rom); if (!x) return;
Object.assign(x, { fromParaMain: true, clock: state.emuClock !== false, nfc: state.emuNfc !== false, opt: state.emuOpt, sess: state.emuSess !== false });
state.extras.unshift(x); if (!state.mainPick) state.mainPick = x;
state.emuRemove = true; state.paraMainTaken = true; state.extrasDirty = true;
}
function doomFreeSync() {
if (!DOOM_FREE) return;
if (!doomFree()) { // back to the Paradise: DOOM of the DOOM tab or of the start device as before
const out = (x) => x.fromPara || x.wadSrc;
if (state.mainPick && state.mainPick.kind === 'doom' && out(state.mainPick)) state.mainPick = null;
state.extras = (state.extras || []).filter((x) => !out(x)); return;
}
const old = doomXs(), wasMain = old.includes(state.mainPick);
if (state.doom && DOOM_EPS && state.doom.sel) { // 1.7.3 test12: each chosen episode its own entry in the menu
const d = state.doom, want = (DOOM_WHOLE && d.whole ? ['all'] : d.ok.filter((e) => d.sel.has(e) && !'PQ'.includes(e[0]))).concat(d.ok.filter((e) => 'PQ'.includes(e[0]) && d.sel.has(e))), gone = old.filter((x) => x.wadSrc !== d);
// a new WAD replaces the DOOM of the ROM (as before); a save of the same episode (menu name "DOOM E2") goes along
for (const x of old) if (x.wadSrc !== d || !want.includes(x.ep)) { if (state.mainPick === x) state.mainPick = null; state.extras.splice(state.extras.indexOf(x), 1); state.extrasDirty = true; }
for (const e of want) if (!doomXs().some((x) => x.wadSrc === d && x.ep === e)) {
const x = { kind: 'doom', wadSrc: d, ep: e, size: (DOOM_MUSSZ ? doomEpSize(d.fit[e]) : (d.fit[e] || {}).sizeP) || 0x300000, keys: Object.assign({}, state.doomKeys || D.KEYS_DEFAULT) };
if (e === 'all') { x.region = DOOM_WHOLE_REGION; if (d.d2) x.d2 = true; }
if ('PQ'.includes(e[0])) x.title = (d.titles || {})[e] || 'DOOM';
const prev = gone.find((g) => g.name === (e === 'all' ? (d.d2 ? 'DOOM II' : 'DOOM') : 'PQ'.includes(e[0]) ? x.title : 'DOOM E' + e)); if (prev && prev.save) x.save = prev.save;
const i = state.extras.findIndex((y) => y.kind === 'doom' && y.wadSrc === d && y.ep > e && !'PQ'.includes(e[0]));
state.extras.splice(i >= 0 ? i : state.extras.length, 0, x); state.extrasDirty = true;
if (wasMain && !doomXs().includes(state.mainPick)) state.mainPick = x;
}
if (wasMain && !state.mainPick && doomXs().length) state.mainPick = doomXs()[0]; // the star stays with DOOM
} else if (state.doom && !old.some((x) => x.wadSrc === state.doom)) {
const f = state.doom.fit[state.doom.ok[0]] || {};
const x = { kind: 'doom', wadSrc: state.doom, size: f.sizeP || 0x300000, keys: Object.assign({}, state.doomKeys || D.KEYS_DEFAULT) };
const i = state.extras.findIndex((y) => y.kind === 'doom');
state.extras = state.extras.filter((y) => y.kind !== 'doom'); state.extras.splice(i >= 0 ? i : state.extras.length, 0, x);
if (wasMain) state.mainPick = x;
state.extrasDirty = true;
} else if (!state.doom && !state.ctx.clean && doomInstalled() && !state.emuRemove && !old.length) {
const x = doomParaX(state.ctx.rom);
if (x) { state.extras.push(x); if (!state.mainPick) state.mainPick = x; state.extrasDirty = true; } // it was the main program (shown first while it has the star)
}
}
function curMainX() {
const em = state.emu;
if (em) return emuX(em);
return null;
}
function canMain(x) {
if (x.kind === 'gb' || x.kind === 'sms' || x.kind === 'pm' || x.kind === 'ab' || x.kind === 'wolf') return false; // 1.6.9 test36: GBEmu only in the menu (and Wolf3D)
// outside a start device only T7Emu goes to the menu, so the old main program must be a T7Emu (or none)
if (state.launch) return true;
if (!a0Free()) return false; // test25: no main program at 0x0A0000 in this edition
const em = state.emu, ty = em ? (em.v1 ? 'v1' : em.t7 ? 't7' : em.t18 ? 't18' : 'tama') : (emuInstalled() && !state.emuRemove ? F.emuType(state.ctx.rom) : null);
return !ty || ty === 't7' || ty === 'v1';
}
async function makeMain(i) {
const x = state.extras[i]; if (!x) return;
let old = curMainX();
if (!old && emuInstalled() && !state.emuRemove) old = await installedX(state.ctx.rom);
let em;
if (x.kind === 't18') { let n = 0; for (let k = 0; k < 128; k++) if (!x.fw.subarray(k << 16, (k + 1) << 16).every((v) => v === 0xFF)) n++; em = { t18: true, dev: 't18', rom: x.fw, size: n << 16 }; }
else if (x.kind === 'tama') { const pk = E.packMain(x.guest, x.dev, null, !!state.emuPack); em = { guest: x.guest, dev: x.dev, size: pk.blob.length, big: pk.big }; }
else if (x.kind === 'v1') em = { v1: true, dev: 'v1', rom: x.rom, size: x.rom.length + 0x2000 };
else { em = { t7: true, dev: 't7', rom: x.rom, figs: x.figs || [] }; em.size = t7Size(em); }
state.extras.splice(i, 1);
if (old) old.opt = state.emuOpt;
state.emuOpt = x.opt || { vol: 0, dim: 0, off: 0 };
// outside a start device only T7Emu and V1Emu go to the menu; another main program is replaced
if (old && !state.launch && (old.kind === 'tama' || old.kind === 't18')) { toast(t('progReplaced', { n: E.extraName(x), o: E.extraName(old) })); old = null; }
if (old) state.extras.unshift(old);
state.emu = em; emuRemoveClear(); state.extrasDirty = true; state.t7saveX = null; state.progOpen = new Set(); state.dlcT = 'main'; state.figT = 'main'; state.mainGuest = null;
if (!state.launch) state.doom = null;
if (!x.fresh) toast(t('progMainNow', { n: E.extraName(x) }));
renderDoom(); renderEmu();
}
/* test17: the star in a start device: only if it still fits, otherwise the old order stays */
async function mainChecked(i) {
if (!ROOM_AUTO || !state.launch) return makeMain(i);
const snap = { emu: state.emu, extras: state.extras.slice(), emuRemove: state.emuRemove, mainPick: state.mainPick, emuOpt: state.emuOpt, mainGuest: state.mainGuest };
await makeMain(i);
const m = await roomTry();
if (m.k || m.err) { Object.assign(state, snap); state.extras = snap.extras.slice(); state.extrasDirty = true; renderDoom(); renderEmu(); toast(m.k ? t('mainNoRoom', { k: m.k }) : t('appFail', { e: m.err }), true); }
}
/* 1.6.8: the main program (state.emu) in the form of a further program, its name; the installed one read from the ROM */
function emuX(em) { return !em ? null : em.v1 ? { kind: 'v1', rom: em.rom } : em.t18 ? { kind: 't18', fw: em.rom } : em.t7 ? { rom: em.rom, figs: em.figs } : { kind: 'tama', guest: em.guest, dev: em.dev }; }
function emuNm(em) { return em.v1 ? E.v1Name(em.rom) : em.t7 ? E.t7XName(em.rom) : em.t18 ? E.extraName({ kind: 't18' }) : E.tamaName(em.guest, em.dev); }
async function installedX(r0) {
const ty = F.emuType(r0);
if (ty === 't7') { const c7 = E.t7FromRom(r0); return c7 ? { rom: c7.rom, figs: c7.figs } : null; }
if (ty === 't18') { const fw = E.t18FromRom(r0); return fw ? { kind: 't18', fw } : null; }
if (ty === 'v1') { const r = E.v1FromRom(r0); return r ? { kind: 'v1', rom: r } : null; }
const cfg = romEmuCfg(r0); return cfg ? { kind: 'tama', guest: await SV.emuGuestAsync((a, n) => r0.subarray(a, a + n), cfg), dev: cfg.dev } : null;
}
function hasOldSave() { return typeof state.dlcT === 'number' ? !!state.extras[state.dlcT] && !state.extras[state.dlcT].fresh : !!(state.emu && state.emu.kept) || !!state.mainGuest; }
$('btnApp').onclick = () => $('fileApp').click();
$('fileApp').onchange = async (e) => {
const f = e.target.files[0]; e.target.value = ''; if (!f) return;
await addExtra(new Uint8Array(await f.arrayBuffer()), f.name);
};
/* 1.6.8: trial build of the ROM as it would be saved now; KB missing for the programs, 0 if they fit */
let lastRoom = 0, lastFree = -1;
async function roomMissing() {
const m = await roomTry(); return m.k;
}
/* test17 ROOM_AUTO: a trial build that also reports other failures (before: "T18Emu needs 0x0F0000" counted as
* fitting when adding and only came up when writing), and the room really left afterwards */
const ROOM_AUTO = true;
async function roomTry() {
lastRoom = 0; lastFree = -1; const mute = toast.mute = {};
let ok = false;
try { ok = !!(await composeRom()); } catch (e) { mute.err = em(e); } finally { toast.mute = null; }
if (ok && lastFree >= 0) state.roomFree = { sig: roomSig(), kb: lastFree };
return { k: lastRoom, err: !ok && !lastRoom ? (mute.err || '?') : '' };
}
/* which programs are in, and which one is the main one (the overview's real free room belongs to that) */
/* 1.7.2 ROOM_FIGS: figures and the firmware data (download content) change the room too, not only the program list */
const ROOM_FIGS = true, roomIds = new WeakMap(); let roomIdN = 0;
function roomId(a) { if (!a || typeof a !== 'object') return 0; if (!roomIds.has(a)) roomIds.set(a, ++roomIdN); return roomIds.get(a); }
function roomCont(x) { return !x ? '' : [(x.figs || []).reduce((n, f) => n + ((f.data && f.data.length) || f.len || 0), 0) + '/' + (x.figs || []).length, roomId(x.guest), roomId(x.rom), roomId(x.fw)].join(':'); }
function roomSig() { return JSON.stringify([state.emu ? emuNm(state.emu) : '', !!state.emuRemove, !!state.doom, !!state.launch, (state.extras || []).map((x) => E.extraName(x))].concat(DOOM_MUSSZ && state.doom ? [$('doomMusic').checked] : []).concat(ROOM_FIGS ? [roomCont(state.emu), (state.extras || []).map(roomCont)] : [])); }
/* test17: in a start device the first program (at 0x0A0000) changes how much room the others need (TamaEmu and
* T18Emu use the fixed areas there, T18Emu's part at 0x0F0000 is fixed). When the choice does not fit, every other
* program is tried as the first one; the smallest shortfall of all is the one reported, so the message is the same
* whatever order the programs were added in. */
/* test25 T18_FEW: T18Emu takes 10 spare blocks and a TamaEmu in the menu 576 KB for spare pages when they can; when the
* programs do not fit then (T18Emu with iD L in the menu was 256 KB short), it is tried again with 6 blocks for T18Emu
* and 256 KB for each TamaEmu (as the main TamaEmu has), T18Emu's blocks into the small gaps first (a TamaEmu needs one
* piece), before saying "no room" */
const T18_FEW = true, T18_FEW_N = 6;
const HI_ORPHAN = true;
function t18Here() { return !!(state.emu && (state.emu.t18 || state.emu.guest)) || (state.extras || []).some((x) => E.extraKind(x) === 't18' || E.extraKind(x) === 'tama') || (emuInstalled() && /t18|tama/.test(F.emuType(state.ctx.rom))); }
async function roomFit() {
const r = await roomFit1();
if (!T18_FEW || !r.k || state.t18Few || !t18Here()) return r;
state.t18Few = true;
const r2 = await roomFit1();
if (!r2.k && !r2.err) return r2;
state.t18Few = false; return r;
}
async function roomFit1() {
const m0 = await roomTry(); if (!m0.k && !m0.err) return { k: 0 };
if (!ROOM_AUTO || !state.launch) return { k: m0.k }; // outside a start device only the room counts (the menu may still be off)
if (doomMain() || state.clean) return m0;
const snap = { emu: state.emu, extras: state.extras.slice(), emuRemove: state.emuRemove, mainPick: state.mainPick, emuOpt: state.emuOpt, mainGuest: state.mainGuest, progOpen: state.progOpen };
const back = () => { Object.assign(state, snap); state.extras = snap.extras.slice(); state.extrasDirty = true; };
let best = m0.k || Infinity, err = m0.err;
const names = snap.extras.map((x) => E.extraName(x));
for (let i = 0; i < snap.extras.length; i++) {
if (!canMain(snap.extras[i])) continue;
back(); toast.mute = {}; try { await makeMain(i); } finally { toast.mute = null; }
const m = await roomTry();
if (!m.k && !m.err) { toast(t('mainAuto', { n: names[i] })); renderEmu(); return { k: 0 }; }
if (m.k && m.k < best) best = m.k;
}
back(); renderEmu();
return best < Infinity ? { k: best } : { k: 0, err };
}
async function addExtra(g, fname, preset) {
let x = preset || null;
if (x) { /* 1.7.3: made by its tab (Arduboy) */ }
else if (E.gbDetect(g)) { if (E.gbColorOnly(g) && !E.gbIsColor(g)) { toast(t('gbColor', { f: fname }), true); return; } x = { kind: 'gb', rom: g, keys: gbKeysNow().slice(), inv: state.gbInv !== false }; } // 1.6.9 test36: GBEmu
else if (E.pmDetect(g)) x = { kind: 'pm', rom: g, title: E.pmTitle(fname), keys: pmKeysNow().slice(), inv: state.pmInv !== false, bios: state.pmBios || null }; // 1.7.3 PokeMiniEmu
else if (E.smsDetect(g, fname)) x = { kind: 'sms', rom: g, title: E.smsTitle(fname), gg: E.smsGameGear(g, fname), keys: smsKeysNow().slice(), inv: state.smsInv !== false }; // 1.6.10 test2: SMSEmu
else if (E.v1Detect(g)) x = { kind: 'v1', rom: g }; // 1.6.8: V1Emu (first Tamagotchis, Digital Monster)
else if (E.t7Detect(g)) x = { rom: g };
else if (E.t18Detect(g)) x = { kind: 't18', fw: g };
else { try { const dev = E.emuDetect(g); try { E.packGuest(g, dev); } catch (e1) { E.packGuest(g, dev, { lz: true }); } x = { kind: 'tama', guest: g, dev }; } catch (err) { x = null; } }
if (!x) {
let main = false; try { main = !!E.t18Detect(g) || (E.emuDetect(g) && true); } catch (err) { main = false; }
toast(t(main && !state.launch ? 'appBadMain' : state.launch ? 'appBadL' : 'appBad', { f: fname }), true); return;
}
state.extras = state.extras || [];
if (state.extras.length >= E.APPX_MAX) { toast(t('appMax'), true); return; }
{ let m = curMainX(); if (!m && emuInstalled() && !state.emuRemove) { const r0 = state.ctx.rom, ty = F.emuType(r0); if (ty === 't7') { const c7 = E.t7FromRom(r0); if (c7) m = { rom: c7.rom }; } else if (ty === 't18') { const fw = E.t18FromRom(r0); if (fw) m = { kind: 't18', fw }; } else if (ty === 'v1') { const r = E.v1FromRom(r0); if (r) m = { kind: 'v1', rom: r }; } else if (x.kind === 'tama') { await mainGuestLoad(); if (state.mainGuest) m = { kind: 'tama', guest: state.mainGuest.g, dev: state.mainGuest.dev }; } } if ((m && sameFw(x, m)) || state.extras.some((y) => sameFw(x, y))) { toast(t('appTwice', { n: E.extraName(x) }), true); return; } } // 1.6.8: each program once
if (x.kind === 't18' && (state.extras.some((y) => y.kind === 't18') || (state.emu && state.emu.t18) || (!state.emu && F.emuType(state.ctx.rom) === 't18' && !state.emuRemove))) { toast(t('appT18One'), true); return; }
x.fresh = true; state.extras.push(x); state.extrasDirty = true; state.t7saveX = null;
// test25: no room at 0x0A0000 and no start device: a colour Tama or TG18 cannot go anywhere
if (!state.launch && !a0Free() && (x.kind === 'tama' || x.kind === 't18')) { state.extras = state.extras.filter((y) => y !== x); toast(t('a0NoMain', { f: fname }), true); renderEmu(); return; }
// outside a start device a colour Tama or TG18 only runs as the main program (A and C): it becomes the main one
if (!state.launch && (x.kind === 'tama' || x.kind === 't18')) { busy(() => makeMain(state.extras.length - 1)); return; }
// 1.6.8: does it still fit? A trial build right away, not only when writing
const f = await busy(roomFit), k = f.k;
if (k || f.err) { state.extras = state.extras.filter((y) => y !== x); state.extrasDirty = true; renderEmu(); toast(k ? t('noRoomAdd', { n: E.extraName(x), k }) + (E.PACK_OPT && (state.extras || []).some((y) => y.kind === 'tama' && !y.pack) ? t('packTip') : '') : t('appFail', { e: f.err }), true); return; }
renderEmu();
}
$('btnT7Fig').onclick = () => $('fileT7Fig').click();
$('fileT7Fig').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = ''; if (!files.length) return;
const st = figTarget(); if (!st) return;
const xi = typeof state.figT === 'number';
for (const f of files) {
const raw = new Uint8Array(await f.arrayBuffer());
if (!E.t7FigDetect(raw)) { toast(t('t7FigBad', { f: f.name }), true); continue; }
const d = E.t7FigData(raw);
if (st.figs.length >= 16) { toast(t('t7FigMax'), true); break; }
if (st.figs.some((x) => E.t7FigName(x.name) === E.t7FigName(f.name))) { toast(t('t7FigDup', { f: E.t7FigName(f.name) }), true); continue; }
if (!xi && E.t7Room(st.figs.concat([{ name: f.name, data: d }]), st.rom.length) < 0) { toast(t('t7FigFull', { f: E.t7FigName(f.name) }), true); continue; }
st.figs = st.figs || []; st.figs.push({ name: f.name, data: d });
}
if (xi) { state.extrasDirty = true; state.t7saveX = null; renderEmu(); return; }
st.size = t7Size(st); state.emu = st; emuRemoveClear(); if (!state.launch) state.doom = null;
renderDoom(); renderEmu();
};
/* Download content of the 8 MB guest firmware: one box per store, every slot with its name */
function renderDlc() { $('dlcList').innerHTML = ''; } // 1.6.8: the slots are in the program's row
const DLC_ZIP = true;
$('btnDlc').onclick = () => $('fileDlc').click();
$('fileDlc').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = ''; if (!files.length || !dlcTarget()) return;
let nb0 = -1; try { const t0 = dlcTarget(); nb0 = E.packGuest(t0.guest, t0.dev).blocks; } catch (err) { nb0 = -1; }
// DLC_ZIP (1.7.2 test13): .zip files (as the VDPs come) bring their .jpg files; items for another device stay out
const ents = [];
for (const f of files) {
const d = new Uint8Array(await f.arrayBuffer());
if (DLC_ZIP && f.name.toLowerCase().endsWith('.zip')) {
try { for (const x of await C.zipRead(d, inflateRaw)) { const nm = x.name.split('/').pop(); if (/\.jpe?g$/i.test(nm)) ents.push({ name: nm, data: x.data, zip: true }); } }
catch (err) { toast(t('dlcBad', { f: f.name, e: em(err) }), true); }
} else ents.push({ name: f.name, data: d });
}
for (const f of ents) {
try {
const tg = dlcTarget();
const rec = E.dlcRecord(f.data, tg.dev);
if (f.zip && /^t4u_/.test(String.fromCharCode(...rec.subarray(0x34, 0x3B))) && !/^4u/.test(tg.dev)) continue;
const r = E.dlcAdd(tg.guest, rec);
tg.set(r.guest);
toast(t('dlcOk', { n: E.dlcName(rec), k: t('dlcK' + r.store.kind), s: r.slot + 1 }));
} catch (err) { toast(t('dlcBad', { f: f.name, e: em(err) }), true); }
}
// the first item in a still empty store needs a new block: the emulator's layout changes, its save starts anew
try { const t1 = dlcTarget(); const c0 = state.dlcT === 'main' ? romEmuCfg(state.ctx.rom) : null, relay = !!(c0 && c0.version < 5 && E.packMain(t1.guest, t1.dev, null, !!state.emuPack).lzOff !== undefined); // MAIN_LZ: an older main TamaEmu gets the packed layout
if (((nb0 >= 0 && E.packGuest(t1.guest, t1.dev).blocks !== nb0) || relay) && hasOldSave()) toast(t('dlcNewArea'), true); } catch (err) { /* only a hint */ }
renderEmu();
};
$('fileT18Item').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = ''; const T = t18Target(state.itemT); if (!files.length || !T) return;
const recs = [];
for (const f of files) {
try {
const b = new Uint8Array(await f.arrayBuffer());
if (f.name.toLowerCase().endsWith('.zip')) { const z = await C.zipRead(b, inflateRaw); for (const x of z) recs.push(...E.t18iScan(x.data)); }
else recs.push(...E.t18iScan(b));
} catch (err) { toast(t('dlcBad', { f: f.name, e: em(err) }), true); }
}
if (!recs.length) { toast(t('t18ItemsNone'), true); return; }
let n = 0;
for (const r of recs) {
if (r.model && r.model !== 'tg18') toast(t('t18ItemsOther', { n: t18Nm(r), m: r.model.toUpperCase() }), true);
try { const x = E.t18ItemAdd(T.fw, r, 1); n++; toast(t('t18ItemOk', { n: t18Nm(r), k: t('t18A_' + x.area) })); }
catch (err) { toast(t('dlcBad', { f: t18Nm(r), e: err.message === 'full' ? t('t18ItemsFull') : em(err) }), true); }
}
if (n) T.set();
renderEmu();
};
$('fileT18Pic').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = ''; if (!files.length) return;
const ents = [];
for (const f of files) {
const b = new Uint8Array(await f.arrayBuffer());
if (f.name.toLowerCase().endsWith('.zip')) { try { for (const x of await C.zipRead(b, inflateRaw)) ents.push({ name: x.name.split('/').pop(), data: x.data }); } catch (err) { toast(t('dlcBad', { f: f.name, e: em(err) }), true); } }
else ents.push({ name: f.name, data: b });
}
const byImg = new Map(); // the Android set: erwachsen.json names every picture
// English firmwares (Param block at 0xF800D864) take the pictures of the English ones first, the others the Japanese ones
const fw0 = state.emu && state.emu.t18 ? state.emu.rom : null, pa = fw0 ? E.t18Addrs(fw0).param : (state.ctx.rom[0xA0140 + 428] | state.ctx.rom[0xA0140 + 429] << 8 | state.ctx.rom[0xA0140 + 430] << 16 | state.ctx.rom[0xA0140 + 431] << 24) >>> 0;
const EN = new Set(['34525147dbe95eb512760981a07f5c30', '1a7d362f6f31b637e0a3b34ba6b6d110', '190a9d6801ed709f9a090a74f95039af']), wantEn = !pa || pa === 0xF800D864;
const rank = new Map();
for (const x of ents) if (/\.json$/i.test(x.name)) { try { const j = JSON.parse(new TextDecoder().decode(x.data)); for (const k in j) for (const a of j[k] || []) if (a.img) { byImg.set(a.img, a.id); rank.set(a.img, EN.has(k) === wantEn ? 0 : 1); } } catch (err) { /* not that file */ } }
ents.sort((a, b) => (rank.has(b.name) ? rank.get(b.name) : 0) - (rank.has(a.name) ? rank.get(a.name) : 0)); // the wanted ones last: they win
state.t18Pics = state.t18Pics || new Map(); let n = 0;
for (const x of ents) {
if (!/\.png$/i.test(x.name)) continue;
const id = byImg.has(x.name) ? byImg.get(x.name) : E.t18AdultFind(x.name);
if (id < 0 || !E.T18_ADULTS.some((a) => a[0] === id)) { toast(t('t18PicsUnknown', { f: x.name }), true); continue; }
try { state.t18Pics.set(id, E.t18PicMake(await pngRgba(x.data))); n++; } catch (err) { toast(t('dlcBad', { f: x.name, e: em(err) }), true); }
}
if (n) { state.t18PicsDirty = true; toast(t('t18PicsOk', { n })); }
renderEmu();
};
$('btnEmu').onclick = () => $('fileEmu').click();
$('fileEmu').onchange = async (e) => {
const f = e.target.files[0]; e.target.value = ''; if (!f) return;
const g = new Uint8Array(await f.arrayBuffer());
// 1.6.8: one button for everything: the first program is the main one (A and C), every further one goes to the menu
if (E.gbDetect(g)) { await addExtra(g, f.name); renderGb(); return; }
if (E.smsDetect(g, f.name)) { await addExtra(g, f.name); renderSms(); return; } // 1.6.10 test2 // 1.6.9 test36: Game Boy games go to the menu
if (state.emu || (emuInstalled() && !state.emuRemove) || (state.extras || []).length || (E.v1Detect(g) && doomMain()) || !a0Free()) { await addExtra(g, f.name); return; } // test25: no room at 0x0A0000: the menu // the first program stays the main one
if (E.v1Detect(g)) { state.emu = { v1: true, dev: 'v1', rom: g, size: g.length + 0x2000 }; extrasDedupe(null); emuRemoveClear(); if (!state.launch) state.doom = null; renderDoom(); }
else if (E.t18Detect(g)) {
let n = 0; for (let i = 0; i < 128; i++) if (!g.subarray(i << 16, (i + 1) << 16).every((v) => v === 0xFF)) n++;
state.emu = { t18: true, dev: 't18', rom: g, size: n << 16 }; extrasDedupe(null); emuRemoveClear(); if (!state.launch) state.doom = null; renderDoom();
} else if (E.t7Detect(g)) {
const old = state.emu && state.emu.t7 ? state.emu : t7State(); // the figures stay
const st = { t7: true, dev: 't7', rom: g, figs: old && E.t7Kind(g) === 'go' ? old.figs : [] };
st.size = t7Size(st); state.emu = st; extrasDedupe(null); emuRemoveClear(); if (!state.launch) state.doom = null; renderDoom();
} else
try { const dev = E.emuDetect(g); const pk = E.packMain(g, dev, null, !!state.emuPack); state.emu = { guest: g, dev, size: pk.blob.length, big: pk.big }; extrasDedupe(null); emuRemoveClear(); if (!state.launch) state.doom = null; renderDoom(); }
catch (err) { toast(t('emuBad', { e: em(err) }), true); }
renderEmu();
};
$('emuAuto').onchange = (e) => { state.emuAuto = e.target.checked; renderEmu(); };
$('emuClock').onchange = (e) => { state.emuClock = e.target.checked; renderEmu(); };
$('emuNfc').onchange = (e) => { state.emuNfc = e.target.checked; renderEmu(); };
$('btnEmuOff').onclick = () => { state.emu = null; state.emuRemove = true; renderEmu(); };
$('btnEmuUndo').onclick = () => { state.emu = null; emuRemoveClear(); state.t7save = null; renderEmu(); renderDoom(); };
// ---------------------------------------------------------------- DOOM
function keySel(id, val, wheel) {
const sel = $(id); sel.innerHTML = '';
[[1, 'A'], [2, 'B'], [4, 'C']].concat(wheel ? [[8, t('kWheel')]] : []).forEach(([v, l]) => { const o = document.createElement('option'); o.value = v; o.textContent = l; sel.appendChild(o); });
sel.value = String(val);
}
/* 1.6.9 test36: tab Game Boy. The games go into the menu (GBEmu, kind 'gb' in state.extras); one key layout for all. */
const GB_BTNS = [[0, 'gbNone'], [1, 'A'], [2, 'B'], [8, 'Start'], [4, 'Select'], [16, 'gbRight'], [32, 'gbLeft'], [64, 'gbUp'], [128, 'gbDown']];
const GB_INS = ['gbInA', 'gbInB', 'gbInC', 'gbInWp', 'gbInWu', 'gbInWd', 'gbInAC', 'gbInBC', 'gbInAB'];
function gbKeysNow() { if (!state.gbKeys) { const x = (state.extras || []).find((y) => y.kind === 'gb' && y.keys && y.keys.length === 9); state.gbKeys = x ? x.keys.slice() : E.GB_KEYS_DEFAULT.slice(); state.gbInv = x ? !!x.inv : true; } return state.gbKeys; } // 1.6.10 test1: wheel reversed by default
function gbKeysApply() { for (const x of state.extras || []) if (x.kind === 'gb') { x.keys = state.gbKeys.slice(); x.inv = !!state.gbInv; } state.extrasDirty = true; renderPlan(); }
function renderGb() {
if (!$('gbList')) return;
const xs = (state.extras || []).map((x, i) => [x, i]).filter(([x]) => x.kind === 'gb');
const box = $('gbList'); box.innerHTML = '';
if (!xs.length) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('gbNone2'); box.appendChild(d); }
for (const [x, i] of xs) {
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.className = 'itemname'; n.textContent = E.extraName(x) + ' (' + (x.rom.length >> 10) + ' KB)';
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = '×'; b.title = t('progDel');
b.onclick = () => { state.extras.splice(i, 1); state.extrasDirty = true; renderEmu(); };
r.append(n, b); box.appendChild(r);
}
if (xs.length && !menuWanted()) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('appNeedMenu'); box.appendChild(d); }
const k = gbKeysNow(), g = $('gbKeyGrid'); g.innerHTML = '';
GB_INS.forEach((nm, i) => {
const l = document.createElement('label'); const sp = document.createElement('span'); sp.textContent = t(nm);
const sel = document.createElement('select');
for (const [v, tn] of GB_BTNS) { const o = document.createElement('option'); o.value = String(v); o.textContent = tn.startsWith('gb') ? t(tn) : tn; sel.appendChild(o); }
sel.value = String(GB_BTNS.some(([v]) => v === k[i]) ? k[i] : 0);
sel.onchange = () => { state.gbKeys[i] = +sel.value; gbKeysApply(); renderGb(); };
l.append(sp, sel); g.appendChild(l);
});
$('gbInv').checked = !!state.gbInv;
const used = new Set(k.filter((v) => v)); const miss = [[1, 'A'], [2, 'B'], [8, 'Start']].filter(([v]) => !used.has(v)).map(([, n]) => n);
$('gbKeysStat').textContent = miss.length ? t('gbKeysMiss', { n: miss.join(', ') }) : '';
}
$('btnGb').onclick = () => { if (!state.ctx) { toast(t('gbNeedRom'), true); return; } $('fileGb').click(); };
$('fileGb').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = '';
for (const f of files) {
const g = new Uint8Array(await f.arrayBuffer());
if (!E.gbDetect(g)) { toast(t('gbBad', { f: f.name }), true); continue; }
await addExtra(g, f.name);
}
renderGb();
};
$('gbInv').onchange = () => { gbKeysNow(); state.gbInv = $('gbInv').checked; gbKeysApply(); };
$('btnGbKeysDef').onclick = () => { state.gbKeys = E.GB_KEYS_DEFAULT.slice(); state.gbInv = true; gbKeysApply(); renderGb(); };
/* 1.6.10 test2: tab Master System. As the Game Boy: the games go into the menu (SMSEmu, kind 'sms'); one key layout. */
const SMS_BTNS = [[0, 'gbNone'], [16, 'smsB1'], [32, 'smsB2'], [64, 'smsPause'], [8, 'gbRight'], [4, 'gbLeft'], [1, 'gbUp'], [2, 'gbDown']];
function smsKeysNow() { if (!state.smsKeys) { const x = (state.extras || []).find((y) => y.kind === 'sms' && y.keys && y.keys.length === 9); state.smsKeys = x ? x.keys.slice() : E.SMS_KEYS_DEFAULT.slice(); state.smsInv = x ? !!x.inv : true; } return state.smsKeys; }
function smsKeysApply() { for (const x of state.extras || []) if (x.kind === 'sms') { x.keys = state.smsKeys.slice(); x.inv = !!state.smsInv; } state.extrasDirty = true; renderPlan(); }
function renderSms() {
if (!$('smsList')) return;
const xs = (state.extras || []).map((x, i) => [x, i]).filter(([x]) => x.kind === 'sms');
const box = $('smsList'); box.innerHTML = '';
if (!xs.length) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('gbNone2'); box.appendChild(d); }
for (const [x, i] of xs) {
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.className = 'itemname'; n.textContent = E.extraName(x) + ' (' + (x.rom.length >> 10) + ' KB)';
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = '×'; b.title = t('progDel');
b.onclick = () => { state.extras.splice(i, 1); state.extrasDirty = true; renderEmu(); };
r.append(n, b); box.appendChild(r);
}
if (xs.length && !menuWanted()) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('appNeedMenu'); box.appendChild(d); }
const k = smsKeysNow(), g = $('smsKeyGrid'); g.innerHTML = '';
GB_INS.forEach((nm, i) => {
const l = document.createElement('label'); const sp = document.createElement('span'); sp.textContent = t(nm);
const sel = document.createElement('select');
for (const [v, tn] of SMS_BTNS) { const o = document.createElement('option'); o.value = String(v); o.textContent = t(tn); sel.appendChild(o); }
sel.value = String(SMS_BTNS.some(([v]) => v === k[i]) ? k[i] : 0);
sel.onchange = () => { state.smsKeys[i] = +sel.value; smsKeysApply(); renderSms(); };
l.append(sp, sel); g.appendChild(l);
});
$('smsInv').checked = !!state.smsInv;
const used = new Set(k.filter((v) => v)); const miss = [[16, t('smsB1')], [32, t('smsB2')]].filter(([v]) => !used.has(v)).map(([, n]) => n);
$('smsKeysStat').textContent = miss.length ? t('gbKeysMiss', { n: miss.join(', ') }) : '';
}
$('btnSms').onclick = () => { if (!state.ctx) { toast(t('gbNeedRom'), true); return; } $('fileSms').click(); };
$('fileSms').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = '';
for (const f of files) {
const g = new Uint8Array(await f.arrayBuffer());
if (!E.smsDetect(g, f.name)) { toast(t('smsBad', { f: f.name }), true); continue; }
await addExtra(g, f.name);
}
renderSms();
};
$('smsInv').onchange = () => { smsKeysNow(); state.smsInv = $('smsInv').checked; smsKeysApply(); };
$('btnSmsKeysDef').onclick = () => { state.smsKeys = E.SMS_KEYS_DEFAULT.slice(); state.smsInv = true; smsKeysApply(); renderSms(); };
/* 1.7.3: tab Pokemon mini. As the Master System: the games go into the menu (PokeMiniEmu, kind 'pm'); one key layout;
* an own BIOS (optional) for all of them, else PokeMini's free one. Games also in .zip files. */
const PM_BTNS = [[0, 'gbNone'], [1, 'pmA'], [2, 'pmB'], [4, 'pmC'], [64, 'gbRight'], [32, 'gbLeft'], [8, 'gbUp'], [16, 'gbDown'], [128, 'pmPower'], [256, 'pmShake']];
function pmKeysNow() { if (!state.pmKeys) { const x = (state.extras || []).find((y) => y.kind === 'pm' && y.keys && y.keys.length === 9); state.pmKeys = x ? x.keys.slice() : E.PM_KEYS_DEFAULT.slice(); state.pmInv = x ? !!x.inv : true; } return state.pmKeys; }
function pmKeysApply() { for (const x of state.extras || []) if (x.kind === 'pm') { x.keys = state.pmKeys.slice(); x.inv = !!state.pmInv; } state.extrasDirty = true; renderPlan(); }
function pmBiosNow() { if (state.pmBios === undefined) { const x = (state.extras || []).find((y) => y.kind === 'pm' && y.bios); state.pmBios = x ? x.bios : null; } return state.pmBios; }
function pmBiosApply() { for (const x of state.extras || []) if (x.kind === 'pm') x.bios = state.pmBios || null; state.extrasDirty = true; renderPlan(); }
function renderPm() {
if (!$('pmList')) return;
const xs = (state.extras || []).map((x, i) => [x, i]).filter(([x]) => x.kind === 'pm');
const box = $('pmList'); box.innerHTML = '';
if (!xs.length) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('gbNone2'); box.appendChild(d); }
for (const [x, i] of xs) {
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.className = 'itemname'; n.textContent = E.extraName(x) + ' (' + (x.rom.length >> 10) + ' KB)';
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = '×'; b.title = t('progDel');
b.onclick = () => { state.extras.splice(i, 1); state.extrasDirty = true; renderEmu(); };
r.append(n, b); box.appendChild(r);
}
if (xs.length && !menuWanted()) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('appNeedMenu'); box.appendChild(d); }
const bios = pmBiosNow(); $('pmBiosStat').textContent = t(bios ? 'pmBiosOwn' : 'pmBiosFree'); $('btnPmBiosDel').hidden = !bios;
const k = pmKeysNow(), g = $('pmKeyGrid'); g.innerHTML = '';
GB_INS.forEach((nm, i) => {
const l = document.createElement('label'); const sp = document.createElement('span'); sp.textContent = t(nm);
const sel = document.createElement('select');
for (const [v, tn] of PM_BTNS) { const o = document.createElement('option'); o.value = String(v); o.textContent = t(tn); sel.appendChild(o); }
sel.value = String(PM_BTNS.some(([v]) => v === k[i]) ? k[i] : 0);
sel.onchange = () => { state.pmKeys[i] = +sel.value; pmKeysApply(); renderPm(); };
l.append(sp, sel); g.appendChild(l);
});
$('pmInv').checked = !!state.pmInv;
const used = new Set(k.filter((v) => v)); const miss = [[1, 'A'], [2, 'B'], [4, 'C'], [64, t('gbRight')], [32, t('gbLeft')], [8, t('gbUp')], [16, t('gbDown')]].filter(([v]) => !used.has(v)).map(([, n]) => n);
$('pmKeysStat').textContent = miss.length ? t('gbKeysMiss', { n: miss.join(', ') }) : '';
}
/* the files of a pick: .min directly, .zip opened (a BIOS among them is taken as the own BIOS) */
async function pmFiles(files) {
const out = [];
for (const f of files) {
const b = new Uint8Array(await f.arrayBuffer());
if (/\.zip$/i.test(f.name)) { try { for (const z of await C.zipRead(b, inflateRaw)) { const nm = z.name.split('/').pop(); if (nm) out.push({ name: nm, data: z.data }); } } catch (err) { toast(t('dlcBad', { f: f.name, e: em(err) }), true); } }
else out.push({ name: f.name, data: b });
}
return out;
}
$('btnPm').onclick = () => { if (!state.ctx) { toast(t('gbNeedRom'), true); return; } $('filePm').click(); };
$('filePm').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = '';
for (const f of await pmFiles(files)) {
if (E.pmBiosDetect(f.data)) { state.pmBios = f.data; pmBiosApply(); continue; }
if (E.pmTooBig(f.data)) { toast(t('pmBig', { f: f.name }), true); continue; }
if (!E.pmDetect(f.data)) { toast(t('pmBad', { f: f.name }), true); continue; }
pmBiosNow(); await addExtra(f.data, f.name);
}
renderPm();
};
$('btnPmBios').onclick = () => { if (!state.ctx) { toast(t('gbNeedRom'), true); return; } $('filePmBios').click(); };
$('filePmBios').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = '';
for (const f of await pmFiles(files)) { if (E.pmBiosDetect(f.data)) { state.pmBios = f.data; pmBiosApply(); renderPm(); return; } }
toast(t('pmBiosBad', { f: files.map((f) => f.name).join(', ') }), true);
};
$('btnPmBiosDel').onclick = () => { state.pmBios = null; pmBiosApply(); renderPm(); };
$('pmInv').onchange = () => { pmKeysNow(); state.pmInv = $('pmInv').checked; pmKeysApply(); };
$('btnPmKeysDef').onclick = () => { state.pmKeys = E.PM_KEYS_DEFAULT.slice(); state.pmInv = true; pmKeysApply(); renderPm(); };
/* 1.7.3: tab Arduboy. As the Pokemon mini: the games (.hex, also in .zip files) go into the menu (ArduboyEmu, kind
* 'ab'); one key layout for all of them. */
const AB_BTNS = [[0, 'gbNone'], [16, 'pmA'], [32, 'pmB'], [8, 'gbRight'], [4, 'gbLeft'], [1, 'gbUp'], [2, 'gbDown']];
function abKeysNow() { if (!state.abKeys) { const x = (state.extras || []).find((y) => y.kind === 'ab' && y.keys && y.keys.length === 9); state.abKeys = x ? x.keys.slice() : E.AB_KEYS_DEFAULT.slice(); state.abInv = x ? !!x.inv : true; } return state.abKeys; }
function abKeysApply() { for (const x of state.extras || []) if (x.kind === 'ab') { x.keys = state.abKeys.slice(); x.inv = !!state.abInv; } state.extrasDirty = true; renderPlan(); }
function renderAb() {
if (!$('abList')) return;
const xs = (state.extras || []).map((x, i) => [x, i]).filter(([x]) => x.kind === 'ab');
const box = $('abList'); box.innerHTML = '';
if (!xs.length) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('gbNone2'); box.appendChild(d); }
for (const [x, i] of xs) {
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.className = 'itemname'; n.textContent = E.extraName(x) + ' (' + Math.ceil(x.rom.length / 1024) + ' KB)';
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = '×'; b.title = t('progDel');
b.onclick = () => { state.extras.splice(i, 1); state.extrasDirty = true; renderEmu(); };
r.append(n, b); box.appendChild(r);
}
if (xs.length && !menuWanted()) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('appNeedMenu'); box.appendChild(d); }
const k = abKeysNow(), g = $('abKeyGrid'); g.innerHTML = '';
GB_INS.forEach((nm, i) => {
const l = document.createElement('label'); const sp = document.createElement('span'); sp.textContent = t(nm);
const sel = document.createElement('select');
for (const [v, tn] of AB_BTNS) { const o = document.createElement('option'); o.value = String(v); o.textContent = t(tn); sel.appendChild(o); }
sel.value = String(AB_BTNS.some(([v]) => v === k[i]) ? k[i] : 0);
sel.onchange = () => { state.abKeys[i] = +sel.value; abKeysApply(); renderAb(); };
l.append(sp, sel); g.appendChild(l);
});
$('abInv').checked = !!state.abInv;
const used = new Set(k.filter((v) => v)); const miss = [[16, 'A'], [32, 'B'], [8, t('gbRight')], [4, t('gbLeft')], [1, t('gbUp')], [2, t('gbDown')]].filter(([v]) => !used.has(v)).map(([, n]) => n);
$('abKeysStat').textContent = miss.length ? t('gbKeysMiss', { n: miss.join(', ') }) : '';
}
$('btnAb').onclick = () => { if (!state.ctx) { toast(t('gbNeedRom'), true); return; } $('fileAb').click(); };
$('fileAb').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = '';
for (const f of await pmFiles(files)) {
if (!/\.hex$/i.test(f.name)) continue;
const bin = E.abHex(f.data);
if (!bin) { toast(t(f.data.length > 0x16000 ? 'abBig' : 'abBad', { f: f.name }), true); continue; }
abKeysNow();
await addExtra(bin, f.name, { kind: 'ab', rom: bin, title: E.abTitle(f.name), keys: state.abKeys.slice(), inv: state.abInv !== false });
}
renderAb();
};
$('abInv').onchange = () => { abKeysNow(); state.abInv = $('abInv').checked; abKeysApply(); };
$('btnAbKeysDef').onclick = () => { state.abKeys = E.AB_KEYS_DEFAULT.slice(); state.abInv = true; abKeysApply(); renderAb(); };
/* 1.6.10 test1: tab Wolf3D. The user's game files become one pack (wolf.js) in the browser; Wolf3D goes into the menu
* (kind 'wolf' in state.extras, only one). Keys like DOOM on the Paradise. */
const W = window.ParamixWolf;
function wolfX() { return (state.extras || []).find((y) => y.kind === 'wolf'); }
function wolfKeysNow() { if (!state.wolfKeys) { const x = wolfX(); state.wolfKeys = Object.assign({}, E.WOLF_KEYS_DEFAULT, (x && x.keys) || {}); } return state.wolfKeys; }
function wolfKeysCheck(k) { return (k.fire === k.fwd || k.fire === k.back || k.fwd === k.back) ? t('wolfBad', { e: 'fire, forward and back need three different buttons' }) : ''; }
function wolfKeysApply() { const xs = (state.extras || []).filter((y) => y.kind === 'wolf'); for (const x of xs) x.keys = Object.assign({}, state.wolfKeys); if (xs.length) { state.extrasDirty = true; state.wolfKeysDirty = true; } renderPlan(); }
function renderWolf() {
if (!$('wolfList')) return;
const box = $('wolfList'); box.innerHTML = '';
const xs = (state.extras || []).map((x, i) => [x, i]).filter(([x]) => x.kind === 'wolf');
if (!xs.length) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('wolfNone'); box.appendChild(d); }
for (const [x, i] of xs) {
const inf = E.wolfInfo(x.pack) || { shareware: true, episodes: 1 };
const r = document.createElement('div'); r.className = 'dlcrow';
const n = document.createElement('span'); n.className = 'itemname';
n.textContent = (inf.sod ? 'SPEAR OF DESTINY ' + t('wolfSodN') : 'WOLFENSTEIN 3D ' + t(inf.shareware ? 'wolfShare' : 'wolfFull') + ', ' + (inf.episodes > 1 ? t('wolfEps', { n: inf.episodes }) : t('wolfEp1'))) + ' (' + (x.pack.length >> 10) + ' KB)';
const b = document.createElement('button'); b.className = 'btn small'; b.textContent = '×'; b.title = t('progDel');
b.onclick = () => { state.extras.splice(i, 1); state.extrasDirty = true; renderEmu(); };
r.append(n, b); box.appendChild(r);
}
if (xs.length && !menuWanted()) { const d = document.createElement('div'); d.className = 'hint'; d.textContent = t('appNeedMenu'); box.appendChild(d); }
const k = wolfKeysNow();
keySel('wkFire', k.fire); keySel('wkFwd', k.fwd); keySel('wkBack', k.back); keySel('wkUse', k.use, true); keySel('wkMod', k.mod);
const ts = $('wkTurn'); ts.innerHTML = '';
for (const v of [5, 10, 15, 20, 30, 45]) { const o = document.createElement('option'); o.value = String(v); o.textContent = v + '°'; ts.appendChild(o); }
ts.value = String(k.turn);
$('wkRun').checked = !!k.run; $('wkInv').checked = !!k.invert;
$('wolfKeysStat').textContent = wolfKeysCheck(k);
}
[['wkFire', 'fire'], ['wkFwd', 'fwd'], ['wkBack', 'back'], ['wkUse', 'use'], ['wkMod', 'mod'], ['wkTurn', 'turn']].forEach(([id, f]) => {
$(id).onchange = () => { wolfKeysNow()[f] = +$(id).value; wolfKeysApply(); renderWolf(); };
});
$('wkRun').onchange = () => { wolfKeysNow().run = $('wkRun').checked; wolfKeysApply(); };
$('wkInv').onchange = () => { wolfKeysNow().invert = $('wkInv').checked; wolfKeysApply(); };
$('btnWolfKeysDef').onclick = () => { state.wolfKeys = Object.assign({}, E.WOLF_KEYS_DEFAULT); wolfKeysApply(); renderWolf(); };
$('btnWolf').onclick = () => { if (!state.ctx) { toast(t('gbNeedRom'), true); return; } $('fileWolf').click(); };
$('fileWolf').onchange = async (e) => {
const files = [...e.target.files]; e.target.value = '';
const set = {};
for (const f of files) set[f.name] = new Uint8Array(await f.arrayBuffer());
let r;
try { r = W.build(set); } catch (err) { toast(t('wolfBad', { e: err.message }), true); return; }
const old = (state.extras || []).findIndex((y) => y.kind === 'wolf' && E.wolfSod(y.pack) === !!r.sod); // 1.6.11 test2: Wolf3D and SOD side by side
const x = { kind: 'wolf', pack: r.pack, keys: Object.assign({}, wolfKeysNow()), fresh: true };
state.extras = state.extras || [];
if (old < 0 && state.extras.length >= E.APPX_MAX) { toast(t('appMax'), true); return; }
const prev = old >= 0 ? state.extras[old] : null;
if (old >= 0) { state.extras[old] = x; toast(t('wolfOne')); } else state.extras.push(x);
state.extrasDirty = true;
// does it still fit? a trial build right away (as addExtra)
const f = await busy(roomFit), k = f.k;
if (k || f.err) { if (prev) state.extras[state.extras.indexOf(x)] = prev; else state.extras = state.extras.filter((y) => y !== x); state.extrasDirty = true; renderEmu(); toast(k ? t('noRoomAdd', { n: E.extraName(x), k }) + (E.PACK_OPT && (state.extras || []).some((y) => y.kind === 'tama' && !y.pack) ? t('packTip') : '') : t('appFail', { e: f.err }), true); return; }
renderEmu();
};
function renderDoom() {
if (!state.ctx) return;
let s;
const d = state.doom, has = doomFree() ? doomXs().some((x) => !x.wadSrc) : doomInstalled();
if (!D.embedded()) s = t('doomMissing');
else if (d && !d.ok.length && !(d.fit.all && d.fit.all.plain)) s = t('doomBig');
else if (d) s = t('doomOk', { eps: d.d2 ? 'DOOM II' : 'E' + d.eps.join(', E') }) + (PWAD_ON && d.pwads.length ? '\n' + t('doomPwads', { n: d.pwads.map((p) => p.info.title).join(', ') }) + (!doomFree() && d.pwads.some((p) => p.info.eps.length) ? ' ' + t('doomPwadPara') : doomFree() && d.pwads.some((p) => p.info.eps.length) ? ' ' + t('doomPwadHint') : '') + d.pwads.filter((p) => p.info.big && p.info.big.length).map((p) => '\n' + t('doomPwadBig', { n: p.info.title, m: p.info.big.join(', ') })).join('') : '') + '\n' + t('doomUse');
else if (has && state.emuRemove) s = t('doomGone');
else if (has) s = t('doomHas') + '\n' + t('doomUse');
else s = t('doomNone');
// 1.7.3 test12: without the Paradise a box per episode (each its own menu entry), else the one episode as before
const multi = DOOM_EPS && doomFree() && !!d && (d.ok.length > 1 || d.ok.some((e) => 'PQ'.includes(e[0])) || (DOOM_WHOLE && !!d.fit.all && d.fit.all.plain)), box = $('doomEpsBox');
if (PWAD_ON) { $('btnPwad').hidden = !d; $('btnPwadOff').hidden = !d || !d.pwads.length; }
$('doomEpLbl').hidden = multi; box.hidden = !multi; box.innerHTML = '';
if (multi && DOOM_WHOLE && d.fit.all) { // 1.7.3 test15: whole WAD as one entry
const l = document.createElement('label'); l.className = 'check'; const c = document.createElement('input'); c.type = 'checkbox'; c.checked = !!d.whole; c.disabled = !!d.d2; // DOOM II: only whole
c.onchange = () => { d.whole = c.checked; doomFreeSync(); renderEmu(); renderDoom(); };
l.append(c, ' ' + t('doomWhole') + ' (' + (Math.round(doomEpSize(d.fit.all) / 104857.6) / 10) + ' MB)'); box.appendChild(l); box.appendChild(document.createElement('br'));
}
if (multi) for (const e of d.ok) { if (DOOM_WHOLE && d.whole && !'PQ'.includes(e[0])) continue;
const l = document.createElement('label'); l.className = 'check'; const c = document.createElement('input'); c.type = 'checkbox'; c.checked = d.sel.has(e);
c.onchange = () => { if (c.checked) d.sel.add(e); else d.sel.delete(e); doomFreeSync(); renderEmu(); renderDoom(); };
const lsv = (d.fit[e] || {}).linkSaved, lnk = lsv >= 0x100000 ? t('doomLinkLess', { m: Math.round(lsv / 104857.6) / 10 }) : ''; // DOOM_LINK
l.append(c, ' ' + ('PQ'.includes(e[0]) ? (d.titles || {})[e] : 'E' + e) + ' (' + (Math.round((DOOM_MUSSZ ? doomEpSize(d.fit[e]) : ((d.fit[e] || {}).sizeP || 0)) / 104857.6) / 10) + ' MB' + lnk + ')'); box.appendChild(l);
}
if (multi) s += '\n' + t(d.d2 ? 'doomD2Hint' : DOOM_WHOLE && d.whole ? 'doomWholeHint' : 'doomEpsHint');
const sel = $('doomEp'), cur = sel.value; sel.innerHTML = '';
(d && d.ok.some((e) => !'PQ'.includes(e[0])) ? d.ok.filter((e) => !'PQ'.includes(e[0])) : ['1']).forEach(e => { const o = document.createElement('option'); o.value = e; o.textContent = 'E' + e; sel.appendChild(o); });
if (cur && [...sel.options].some(o => o.value === cur)) sel.value = cur;
const f = d && d.fit[sel.value];
const mus = $('doomMusic'); mus.onchange = DOOM_MUSSZ ? () => { // 1.7.3 test14: with or without music changes the size of each entry and the room
for (const x of doomXs()) if (x.wadSrc) { x.size = doomEpSize(x.wadSrc.fit[x.ep || x.wadSrc.ok[0]]) || x.size; x.mcu = null; }
state.extrasDirty = true; renderEmu(); renderDoom(); } : () => renderPlan();
const fm = DOOM_MUSSZ && multi ? (DOOM_WHOLE && d.whole ? d.fit.all : d.ok.filter((e) => d.sel.has(e)).map((e) => d.fit[e]).find((g) => g && g.music)) : f; // several episodes: music if one of them has room for it
mus.disabled = !fm || !fm.music; if (fm && !fm.music) mus.checked = false;
if (fm && !fm.music) s += '\n' + t('doomNoMusic');
const room = appRoom();
$('btnWad').disabled = !room;
$('btnDoomOff').hidden = doomFree() ? !doomXs().length : (!has || state.emuRemove || !!d);
if (!room) s = t('noRoomApp');
else if (!state.launch && !d && (state.emu || (emuInstalled() && !state.emuRemove))) s += '\n' + t('doomVsEmu');
$('doomStat').textContent = s;
// Keys: for a new WAD or an installed DOOM
const showKeys = !!d || (has && (doomFree() || !state.emuRemove));
$('doomKeys').hidden = !showKeys;
if (showKeys) {
if (!state.doomKeys) state.doomKeys = Object.assign({}, (doomFree() ? (doomXs()[0] || {}).keys : has && D.doomKeysGet(state.ctx.rom)) || D.KEYS_DEFAULT);
const k = state.doomKeys, old = !doomFree() && has && !d && !D.doomKeysGet(state.ctx.rom);
keySel('kFire', k.fire); keySel('kFwd', k.fwd); keySel('kBack', k.back); keySel('kUse', k.use, true); keySel('kMod', k.mod);
$('kRun').checked = k.run; $('kInv').checked = k.invert;
['kFire', 'kFwd', 'kBack', 'kUse', 'kMod', 'kRun', 'kInv'].forEach(id => { $(id).disabled = old; });
const err = D.doomKeysCheck(k);
$('keysStat').textContent = old ? t('kOld') : (err ? em(err) : t('kFixed'));
$('keysStat').classList.toggle('bad', !!err && !old);
}
renderPlan();
}
function keysChanged() {
const k = state.doomKeys; if (!k) return;
k.fire = +$('kFire').value; k.fwd = +$('kFwd').value; k.back = +$('kBack').value; k.use = +$('kUse').value; k.mod = +$('kMod').value;
k.run = $('kRun').checked; k.invert = $('kInv').checked;
renderDoom();
}
['kFire', 'kFwd', 'kBack', 'kUse', 'kMod', 'kRun', 'kInv'].forEach(id => { $(id).onchange = keysChanged; });
$('btnDoomOff').onclick = () => {
if (doomFree()) { for (const x of doomXs()) { if (state.mainPick === x) { state.mainPick = null; state.mainDirty = true; } if (x.fromPara) state.emuRemove = true; } state.extras = state.extras.filter((x) => x.kind !== 'doom'); state.extrasDirty = true; state.doom = null; renderEmu(); renderDoom(); return; }
state.doom = null; if (!state.launch) state.emu = null; state.emuRemove = true; renderEmu(); renderDoom(); };
$('doomEp').onchange = () => renderDoom();
$('btnWad').onclick = () => $('fileWad').click();
/* 1.7.3 test17: the conversions of a WAD (and its extra WADs) in one place: the base with map packs merged, each episode,
* the whole WAD, and each own episode of an extra WAD (Sigil) as its own entry */
async function doomCompute(w, pwads, keepSel) {
const emb = D.embedded(); if (!emb) throw new Error(t('doomMissing'));
const mapPw = (pwads || []).filter((p) => !p.info.eps.length), epPw = (pwads || []).filter((p) => p.info.eps.length);
const wm = mapPw.length ? D.wadMerge(w, mapPw.map((p) => ({ data: p.data, slot: false }))) : w;
const eps = D.wadEpisodes(wm).filter(x => x === 'M' || (DOOM_E4 ? x <= '4' : x !== '4')); if (!eps.length) throw new Error(DOOM_E4 ? 'E1 bis E4 fehlen' : 'E1 bis E3 fehlen'); // 1.7.3 test14: E4 (Ultimate DOOM) too
// Does the episode fit in the ROM? With music, otherwise without.
// test15 DOOM_PKREG: without the Paradise an episode may be as big as the biggest free piece (0x111000..0xEFD000)
const big = 0xEFD000 - 0x111000 - 4;
const room = doomFree() ? (PWAD_ON ? big : 0x800000 - 0xA8000 - 0x1000) : D.REGION_OFF - D.WAD_OFF - 4, fit = {}, ok = [];
const d2 = eps[0] === 'M'; // 1.7.3 test15: DOOM II, only as a whole WAD without the Paradise
if (d2 && !doomFree()) throw new Error(t('doomD2Clean'));
const one = async (src, ep, only) => {
const conv = async (m) => { const sub = D.wadSub(src, ep, m, only); return D.convert(sub, D.gbaExtras(sub), emb.wasm); };
const cm = await conv(true), sm = cm.length, music = sm <= room, cp = music && !doomFree() ? cm : await conv(false), sp = cp.length, plain = sp <= room; // 1.7.3 test13: without the Paradise the version without music too
return { music, plain, sizeM: sm, sizeP: sp, mcuM: DOOM_FREE ? cm : null, mcuP: DOOM_FREE ? cp : null }; // test3: kept for DOOM in the menu
};
for (const ep of d2 ? [] : eps) { fit[ep] = await one(wm, ep); if (fit[ep].plain) ok.push(ep); }
// 1.7.3 test15: the whole WAD in one piece (without the Paradise; about the size of the WAD instead of the sum of the episodes)
if (DOOM_WHOLE && doomFree() && (eps.length > 1 || d2)) {
const conv = async (m) => { const sub = D.wadSub(wm, eps.join(''), m); return D.convert(sub, D.gbaExtras(sub), emb.wasm); };
const cm = await conv(true), cp = await conv(false);
fit.all = { music: cm.length <= big, plain: cp.length <= big, sizeM: cm.length, sizeP: cp.length, mcuM: cm, mcuP: cp };
}
// 1.7.3 test17: an own episode of an extra WAD (Sigil E5, Sigil II E6) in the place of E4, its own entry (only without the Paradise)
const titles = {};
if (PWAD_ON && doomFree() && !d2) for (let i = 0; i < epPw.length; i++) {
const k = 'P' + i, src = D.wadMerge(wm, [{ data: epPw[i].data, slot: true }]);
fit[k] = await one(src, '4'); titles[k] = epPw[i].info.title; if (fit[k].plain) ok.push(k);
// 1.7.3 test21 DOOM_LINK: shared with DOOM in the same ROM (pictures, sounds), the room needed is that much less
if (E.DOOM_LINK && fit[k].mcuP) { const ref = fit.all && fit.all.mcuP ? fit.all.mcuP : eps.map((e) => fit[e] && fit[e].mcuP).filter(Boolean).sort((a, b) => b.length - a.length)[0];
if (ref) { let sv = 0; for (const [, l] of E.doomLinks([{ kind: 'doom', mcu: ref }, { kind: 'doom', mcu: fit[k].mcuP }])) sv += l.saved; fit[k].linkSaved = sv; } }
}
// 1.7.3 test17: a DOOM II map pack (one-humanity) also alone, only its maps, as its own entry
if (PWAD_ON && doomFree() && d2) for (let i = 0; i < mapPw.length; i++) {
const k = 'Q' + i, only = new Set(mapPw[i].info.maps.filter((m) => /^MAP\d\d$/.test(m)));
if (!only.size || !only.has('MAP01')) continue; // a new game starts at MAP01
fit[k] = await one(wm, 'M', only); titles[k] = mapPw[i].info.title; if (fit[k].plain) ok.push(k);
}
const sel = keepSel ? new Set([...keepSel].filter((k) => ok.includes(k))) : new Set(ok.slice(0, 1));
return { wad: w, wadM: wm, pwads: pwads || [], eps, fit, ok, sel, titles, whole: !!(fit.all && fit.all.plain), d2 };
}
$('fileWad').onchange = (e) => {
const f = e.target.files[0]; e.target.value = ''; if (!f) return;
busy(async () => {
const w = new Uint8Array(await f.arrayBuffer());
try {
state.doom = await doomCompute(w, []); if (!state.launch) state.emu = null; if (!doomFree()) state.emuRemove = false; doomFreeSync(); renderEmu();
} catch (err) { state.doom = null; toast(t('doomBad', { e: em(err) }), true); }
renderDoom();
});
};
// 1.7.3 test17: extra WADs (Sigil, map packs) on top of the chosen WAD
$('btnPwad').onclick = () => $('filePwad').click();
$('filePwad').onchange = (e) => {
const fs = [...e.target.files]; e.target.value = ''; const d = state.doom; if (!fs.length || !d) return;
busy(async () => {
try {
const add = [];
for (const f of fs) { const data = new Uint8Array(await f.arrayBuffer()); add.push({ name: f.name, data, info: D.pwadInfo(data, f.name) }); }
// test18: an extra WAD only with the game it is made for (Bernd: one-humanity, a DOOM II map, went in with Ultimate DOOM)
for (const a of add) {
const d2maps = a.info.maps.some((m) => /^MAP/.test(m)), d1 = a.info.eps.length || a.info.maps.some((m) => /^E/.test(m));
if (d.d2 && d1) throw Object.assign(new Error(t('pwadNeedD1', { n: a.info.title })), { plain: true });
if (!d.d2 && d2maps) throw Object.assign(new Error(t('pwadNeedD2', { n: a.info.title })), { plain: true });
}
const pw = d.pwads.filter((p) => !add.some((a) => a.name === p.name)).concat(add);
const nd = await doomCompute(d.wad, pw, d.sel); nd.whole = d.whole && !!(nd.fit.all && nd.fit.all.plain);
state.doom = nd; doomFreeSync(); renderEmu();
} catch (err) { toast(err && err.plain ? err.message : t('doomBad', { e: em(err) }), true); }
renderDoom();
});
};
$('btnPwadOff').onclick = () => { const d = state.doom; if (!d || !d.pwads.length) return;
busy(async () => { try { const nd = await doomCompute(d.wad, [], d.sel); nd.whole = d.whole && !!(nd.fit.all && nd.fit.all.plain); state.doom = nd; doomFreeSync(); renderEmu(); } catch (err) { toast(t('doomBad', { e: em(err) }), true); } renderDoom(); }); };
// ------------------------------------------------------------- actions
$('btnOpen').onclick = () => $('fileRom').click();
$('fileRom').onchange = (e) => { const f = e.target.files[0]; e.target.value = ''; if (f) busy(() => loadRom(f)); };
const drop = $('drop');
drop.onclick = () => $('fileRom').click();
drop.onkeydown = (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); $('fileRom').click(); } };
['dragenter', 'dragover'].forEach(ev => document.addEventListener(ev, (e) => { e.preventDefault(); drop.classList.add('over'); }));
['dragleave', 'drop'].forEach(ev => document.addEventListener(ev, (e) => { e.preventDefault(); drop.classList.remove('over'); }));
document.addEventListener('drop', (e) => {
const files = [...(e.dataTransfer?.files || [])]; if (!files.length) return;
const rom = files.find(f => f.size === 16777216 || /\.bin$/i.test(f.name) && f.size > 4194304);
if (rom) busy(() => loadRom(rom));
else if (state.ctx) busy(() => uploadFiles(files));
});
$('btnUpload').onclick = $('btnUpload2').onclick = () => $('fileSheets').click();
$('fileSheets').onchange = (e) => { const fs = [...e.target.files]; e.target.value = ''; if (fs.length) busy(() => uploadFiles(fs)); };
$('btnZipFigs').onclick = () => busy(() => zipSheets('fig'));
$('btnZipAll').onclick = () => busy(() => zipSheets('spr'));
$('btnNumbers').onclick = () => busy(async () => {
for (const g of state.ctx.groups) {
const big = C.numberImage(String(g), 64, 64, 4), small = C.numberImage(String(g), 32, 32, 2);
[Array(20).fill(big), null, null, Array(24).fill(small), null, null].forEach((subs, k) => {
const i = g + k, orig = state.ctx.entries[i];
state.changed.set(i, subs ? C.spriteEncode(orig, subs, C.partOptions(k)) : C.spriteBlank(orig, C.partOptions(k)));
});
refreshTile('fig', g);
}
toast(t('numOk'));
});
// ------------------------------------------------------------ field select
// installed six fields with the options chosen now?
const sixSame = (si) => !!si && si.planet === (state.sixPlanet !== false) && si.fieldMenu === (state.sixMenu !== false);
const sixPublicModule = {...S6};
const memberSix = {ready:false, loading:null};
const sixAllowed = () => !state.ctx || S6.kindOf(state.ctx.rom) !== 'gen3' || memberSix.ready;
function renderSixMembership() {
$('memberSixCard').classList.toggle('locked', !memberSix.ready);
$('sixPreview').inert = !memberSix.ready;
$('sixPreview').toggleAttribute('inert', !memberSix.ready);
$('memberSixShade').hidden = memberSix.ready;
renderDeviceSix();
if (state.ctx) renderFeld();
}
function lockSixMembership(message) {
memberSix.ready = false;
Object.assign(S6, sixPublicModule); window.ParamixSix = S6;
$('memberLink').textContent = '로그인';
$('memberRestore').hidden = true;
$('memberAdmin').hidden = true;
$('memberSixStatus').textContent = message || '로그인 후 이용할 수 있습니다.';
renderSixMembership();
}
async function ensureSixMembership() {
if (location.protocol === 'file:') {lockSixMembership('여섯 지역 통합은 온라인 홈페이지에 로그인해서 이용하세요.');return false;}
if (memberSix.loading) return memberSix.loading;
memberSix.loading = (async () => {
try {
const me = await window.TamaArchive.request('/api/member/me');
if (!me.authenticated) {lockSixMembership(); return false;}
if (!memberSix.ready) {
await new Promise((resolve, reject) => {
const script = document.createElement('script'); script.src = '/api/member/six.js';
script.onload = () => {Object.assign(S6, window.ParamixSix);window.ParamixSix=S6;script.remove();resolve();};
script.onerror = () => {script.remove();reject(new Error('회원 전용 확장 코드를 불러오지 못했습니다. 다시 로그인하세요.'));};
document.head.appendChild(script);
});
}
memberSix.ready = true;
$('memberLink').textContent = '내 보관함';
$('memberLink').title = me.username;
$('memberRestore').hidden = false;
$('memberAdmin').hidden = !me.isAdmin;
renderSixMembership();return true;
} catch(e) {lockSixMembership(e.message);return false;}
})();
try {return await memberSix.loading;} finally {memberSix.loading=null;}
}
function renderDeviceSix() {
const ready = memberSix.ready && !!dv.d && !dv.run;
$('btnSixStart').disabled = !ready;
$('btnSixRead').disabled = !ready;
const current = !!state.ctx && dv.readCtx === state.ctx;
const supported = current && S6.kindOf(state.ctx.rom) === 'gen3';
$('btnSixWrite').disabled = !ready || !supported || !(state.six || S6.sixInfo(state.ctx.rom)) || !state.sixWant && !S6.sixInfo(state.ctx.rom);
if (memberSix.ready) $('memberSixStatus').textContent = !dv.d ? '기기를 연결한 뒤 이용하세요.' : dv.run ? '기기 작업 중…' : '회원 전용 · 연결된 기기의 여섯 지역 설정';
if (!ready) { $('deviceSixPanel').hidden = true; $('btnSixStart').setAttribute('aria-expanded','false'); }
$('deviceSixStatus').textContent = !current ? '먼저 위 버튼으로 연결 기기의 ROM을 읽고 백업하세요.' : !supported ? '이 기종은 여섯 지역 확장 대상이 아닙니다. 트로피컬·글레이셔 기기가 필요합니다.' : state.six ? '추가 원본을 선택했습니다. 설정을 확인한 뒤 기기에 기록하세요.' : '아래 여섯 지역 옵션을 켜고 추가 원본을 선택하세요.';
}
$('btnSixStart').onclick = async () => {
if (!await ensureSixMembership() || !dv.d || dv.run) return;
$('deviceSixPanel').hidden = !$('deviceSixPanel').hidden;
$('btnSixStart').setAttribute('aria-expanded', String(!$('deviceSixPanel').hidden));
renderDeviceSix();
};
$('btnSixRead').onclick = async () => {
if (!memberSix.ready || !dv.d || dv.run) return;
await $('btnDump').onclick();
if (memberSix.ready && dv.d && dv.readCtx === state.ctx) {
$('deviceSixPanel').hidden = false; $('btnSixStart').setAttribute('aria-expanded','true');
renderFeld(); renderDeviceSix();
}
};
$('btnSixWrite').onclick = () => { if (!$('btnSixWrite').disabled) return $('btnWrite').onclick(); };
// 1.7.2: DNA per field comes to every ROM with six fields (no Land ROM needed)
const sixDnaUp = (si) => sixAllowed() && !!S6.DNA && !!si && !si.dna && si.version >= 7 && !state.sixOff && S6.sixDnaCan(state.ctx.rom);
function renderFeld() {
if (!state.ctx) return;
if (EXIT_KEY) { const sx = $('exitKey'), v = String(state.exitKey || 0); sx.innerHTML = ''; for (let i = 0; i < 4; i++) { const o = document.createElement('option'); o.value = String(i); o.textContent = t('exit' + i); sx.appendChild(o); } sx.value = v; }
const fe = F.embedded(), rom = state.ctx.rom, ed = F.edition(rom), can = F.canFields(rom);
const box = $('feldOn'), bag = $('bagOn'), tm = $('tamaOn'), la = !!state.launch;
$('launchOn').checked = la; $('launchOn').disabled = !fe || !ed || !!state.ctx.clean || (state.launchInit && C.isLauncher(state.ctx)) || !!S6.sixInfo(rom); $('launchOn').parentNode.title = S6.sixInfo(rom) ? t('launchSix') : '';
$('cleanRow').hidden = !CLEAN_ROM || !la; $('cleanClockRow').hidden = !state.clean; $('cleanClock').checked = state.cleanClock !== false; $('cleanOn').checked = !!state.clean; $('cleanOn').disabled = !fe || !ed || !!state.ctx.clean || !FL.embedded() || !cleanCan();
box.checked = !!state.feld && can && !la; box.disabled = !fe || !can || la;
bag.checked = !!state.bag && !la; bag.disabled = !fe || !ed || la;
tm.checked = !!state.tama && !la; tm.disabled = !fe || !ed || la;
{ const g = $('gplayOn'), off = la || !!state.clean || !!state.ctx.clean; $('gplayRow').hidden = !F.GPLAY; g.checked = !!state.gplay && !off; g.disabled = !fe || !ed || off; }
let s;
// six fields (Tropical/Glacier): row visible there only
const si = S6.sixInfo(rom), sixIn = !!si, sixOld = !!si && si.version < S6.VERSION, sixCan = !!S6.kindOf(rom), jade = S6.kindOf(rom) === 'jade';
$('sixRow').hidden = !sixCan || la;
for (const [id, k] of [['sixOnTxt', jade ? 'sixOnJ' : 'sixOn'], ['sixHintTxt', jade ? 'sixHintJ' : 'sixHint']]) { $(id).dataset.t = k; $(id).textContent = t(k); }
$('sixOn').checked = (sixIn && !state.sixOff) || !!state.six || !!state.sixWant; $('sixOn').disabled = !fe || !S6.embedded();
$('btnSix').hidden = jade || (sixIn && !sixOld && sixSame(si));
$('sixPlanetRow').hidden = !sixCan || la || !((sixIn && !state.sixOff) || state.six || state.sixWant);
$('sixPlanet').checked = state.sixPlanet !== false; $('sixPlanet').disabled = !fe || !S6.embedded();
$('sixMenu').checked = state.sixMenu !== false; $('sixMenu').disabled = !fe || !S6.embedded();
const gen3 = S6.kindOf(rom) === 'gen3';
const target = $(gen3 ? 'deviceSixControls' : 'sixControlsHome');
if ($('sixControls').parentNode !== target) target.appendChild($('sixControls'));
const sixLocked = !sixAllowed() || (gen3 && (!dv.d || dv.run || dv.readCtx !== state.ctx));
$('sixMemberGate').hidden = !sixLocked || la;
$('sixRow').classList.toggle('six-locked', sixLocked);
$('sixPlanetRow').classList.toggle('six-locked', sixLocked);
$('btnSix').disabled = sixLocked;
if (sixLocked) for (const id of ['sixOn','sixPlanet','sixMenu']) $(id).disabled = true;
if (!fe) s = t('feldMissing');
else if (!ed) s = t('feldUnknown');
else if (state.clean) s = t('cleanUse') + (state.ctx.clean ? '' : '\n' + t('cleanWarn'));
else if (la) s = t('launchUse') + (state.launchInit && C.isLauncher(state.ctx) ? '\n' + t('launchOld') : '');
else {
s = t('feldCur', { f: F.fieldNow(rom) });
if (can) {
s += ' ' + t('feldList', { s: F.fieldNames(rom).slice(0, sixIn && state.sixOff ? 3 : 99).concat(!sixIn && (state.six || (jade && state.sixWant)) ? (jade ? ['Sky'] : ['Land', 'Water', 'Sky']) : []).join(', ') });
const ff = F.feldFind(rom, fe.stub), sm = ff && ff.version >= 6 && (ff.flags & F.F_SAVES);
const sl = F.feldSlots(rom, fe.stub).map(x => sm ? t('saveSlot', { n: x.index + 1 }) : F.NAMES[x.field]);
if (sl.length) s += ' ' + t('feldStored', { s: sl.join(', ') });
} else s += '\n' + t('feldNo');
if (sixCan && sixIn && state.sixOff) s += '\n' + t(jade ? 'sixOffJ' : 'sixOff');
else if (sixCan) {
if (jade) { if (sixOld) s += '\n' + t('sixOldJ'); else if (sixIn) s += '\n' + t('sixInJ'); else if (!S6.sixCan(rom)) s += '\n' + t('sixNoFw'); }
else if (sixOld && state.six) s += '\n' + t('sixOk', { n: state.sixName });
else if (sixOld) s += '\n' + t('sixOld');
else if (sixIn && !sixSame(si) && !state.six) s += '\n' + t('sixPlanetNeed');
else if (sixIn) s += '\n' + t('sixIn');
else if (!S6.sixCan(rom)) s += '\n' + t('sixNoFw');
else if (state.sixWant && !state.six) s += '\n' + t('sixNeed');
else if (state.six) s += '\n' + t('sixOk', { n: state.sixName });
}
if (state.feld || state.bag || state.tama) s += '\n' + t('feldUse');
}
$('feldStat').textContent = s;
renderDeviceSix();
renderPlan();
}
$('feldOn').onchange = (e) => { state.feld = e.target.checked; renderFeld(); };
$('menuKo').onchange = () => { if (!state.ctx) return; state.feldStale = true; renderFeld(); };
$('exitKey').onchange = (e) => { state.exitKey = +e.target.value; renderPlan(); };
$('launchOn').onchange = (e) => busy(async () => {
state.launch = e.target.checked;
if (!state.launch) { state.clean = false; await paraMainSync(); doomFreeSync(); cleanTabs(); }
if (state.launch) { launchMapGet(); state.feld = state.bag = state.tama = state.gplay = false; state.sixWant = false; state.six = null; }
renderInfo(); renderFeld(); renderEmu(); renderNames();
});
/* CLEAN_ROM: the feld build of this Studio knows the clock sector (menu version 10) */
function cleanCan() { const fe = F.embedded(); if (!fe || !fe.feldc) return false; const f = fe.feldc; for (let i = 0; i + 8 <= f.length; i += 4) if ((f[i] | f[i + 1] << 8 | f[i + 2] << 16 | f[i + 3] << 24) >>> 0 === 0x444C4546) return (f[i + 4] | f[i + 5] << 8) >= 10; return false; }
$('cleanOn').onchange = (e) => busy(async () => {
state.clean = e.target.checked;
if (state.clean) { state.six = null; state.sixWant = false; }
await paraMainSync(); doomFreeSync();
state.roomFree = null; cleanTabs();
renderInfo(); renderFeld(); renderEmu(); renderDoom();
});
$('cleanClock').onchange = (e) => { state.cleanClock = e.target.checked; state.mainDirty = true; renderFeld(); renderEmu(); }; // 1.7.3 test7
$('sixOn').onchange = (e) => {
if (!sixAllowed()) {renderFeld();toast('여섯 지역 통합은 로그인 후 이용하세요.',true);return;}
state.sixOff = !e.target.checked && !!S6.sixInfo(state.ctx.rom); // 1.6.8: take the extra fields out again
state.sixWant = e.target.checked;
if (!e.target.checked) state.six = null;
else { state.feld = true; if (!state.six && S6.sixNeedsSource(state.ctx.rom)) $('fileSix').click(); }
renderFeld(); renderNames();
};
$('btnSix').onclick = () => {if (sixAllowed()) $('fileSix').click();};
$('sixPlanet').onchange = (e) => { if (sixAllowed()) state.sixPlanet = e.target.checked; renderFeld(); };
$('sixMenu').onchange = (e) => { if (sixAllowed()) state.sixMenu = e.target.checked; renderFeld(); };
$('fileSix').onchange = async (e) => {
const f = e.target.files[0]; e.target.value = '';
if (!sixAllowed()) {toast('여섯 지역 통합은 로그인 후 이용하세요.',true);return;}
if (!f) return;
const buf = new Uint8Array(await f.arrayBuffer());
if (!S6.sixSource(buf)) { toast(t('sixBad', { n: f.name }), true); renderFeld(); return; }
state.six = buf; state.sixName = f.name; state.sixWant = true; state.feld = true;
toast(t('sixOk', { n: f.name }));
renderFeld(); renderNames();
};
$('bagOn').onchange = (e) => { state.bag = e.target.checked; renderFeld(); };
$('tamaOn').onchange = (e) => { state.tama = e.target.checked; renderFeld(); };
$('gplayOn').onchange = (e) => { state.gplay = e.target.checked; renderFeld(); };
/* Build the new ROM from the loaded one and everything chosen in the tabs.
Returns { rom, name, res } or null (the reason is shown). same: nothing chosen. */
/** test5: the flash of a further T18Emu that stays in place (its blocks, spares, program and save) */
function keptT18Ranges(xs, rom) {
const r = [];
for (const x of xs) {
if (x.kind !== 't18' || x.keepOff === undefined) continue;
const c = E.t18Cfg(rom, x.keepOff); if (!c) continue;
for (const b of c.map.concat(c.spare)) if (b !== 0xFFFF) r.push([b << 16, (b + 1) << 16]);
r.push([x.keepOff, x.keepOff + 0x10000]);
}
return r;
}
const APPS_CLEAR_FIRST = true;
/* test20 DL_RESCUE: in the start device DOWNLOAD starts the flash app of the write protection (0xFF0000) instead of a
* copy of its own (64 KB less). dlStrip: the copy an earlier write placed stayed in the flash every time (each write
* put a new one elsewhere, 11 copies = 704 KB on one device); copies of it are emptied before placing anew. */
const DL_SIG = true, DL_RESCUE = true, DL_AT = 0x10000000 + 0xFF0000 - 0x11000;
function dlStrip(rom, fe) {
const fa = F.feldApps(state.ctx.rom, fe.stub), src = state.ctx.rom;
const pats = [];
if (fa.dl && fa.dl !== DL_AT) { const o = fa.dl - 0x10000000 + 0x11000; if (o >= 0x100000 && o + 0x10000 <= 0xFF0000) pats.push(src.subarray(o, o + 0x10000)); }
{ const r = src.subarray(0xFF0000, 0x1000000), app = r.subarray(0, 0xE000); if (String.fromCharCode(...r.subarray(0xE000, 0xE008)) === 'SONIXDEV') { const b = new Uint8Array(0x10000); let n = 0xE000; while (n > 0 && app[n - 1] === 0xFF) n--; b.set(app.subarray(0, n)); pats.push(b); } }
// 1.7.2 DL_SIG: copies of older flash app versions differ from both patterns; they all start with the same 64 bytes
const sig = DL_SIG && FL.embedded() ? FL.embedded().subarray(0, 64) : null;
if (!pats.length && !sig) return rom;
let out = rom;
for (let o = 0x100000; o < 0xFF0000; o += 0x10000) {
const blk = out.subarray(o, o + 0x10000);
const hit = pats.some((p) => { for (let i = 0; i < 0x10000; i++) if (blk[i] !== p[i]) return false; return true; }) || (sig && sig.every((v, i) => blk[i] === v));
if (hit) { if (out === rom) out = new Uint8Array(rom); out.fill(0xFF, o, o + 0x10000); }
}
return out;
}
/* CLEAN_ROM: the programs placed from 0x10000, then the menu, the restart routine and the load table; the device's
* ID page stays (edition), DOWNLOAD starts the flash app of the rescue start */
async function composeClean() {
const fe = F.embedded(), emb = FL.embedded(), src = state.ctx.rom;
if (!fe || !emb || !cleanCan()) { toast(t('emuMissing'), true); return null; }
// test3 DOOM_FREE: DOOM is a program of the list like the others (no fixed places, any program can be the main one)
await paraMainSync(); doomFreeSync();
const dxs = doomXs();
if (dxs.length > 1 && !DOOM_EPS) { toast(t('doomOne'), true); return null; }
const keysDirty = !!state.doomKeys && dxs.some((x) => JSON.stringify(state.doomKeys) !== (x.keys0 || JSON.stringify(x.keys)));
const emuUp = !state.ctx.clean && emuUpPending();
if (state.ctx.clean && !state.emu && !state.doom && !keysDirty && !state.extrasDirty && !state.mainDirty && !state.extrasUp && !state.feldStale && !state.t7saveX && !state.saveIn && (state.exitKey || 0) === (state.exitKeyInit || 0) && !emuUp) return { rom: src, name: state.name, res: null, same: true };
let mainX = null;
if (state.emu) mainX = emuX(state.emu);
else if (!state.ctx.clean && emuInstalled() && !state.emuRemove && !state.paraMainTaken) mainX = await installedX(src);
if (mainX) { mainX.clock = state.emuClock !== false; mainX.nfc = state.emuNfc !== false; mainX.opt = state.emuOpt; mainX.sess = state.emuSess !== false; }
extrasDedupe(mainX);
const extrasL = mainX ? [mainX].concat(state.extras || []) : (state.extras || []);
if (!extrasL.length) { toast(t('launchNeed'), true); return null; }
if (!E.t7Embedded()) { toast(t('emuMissing'), true); return null; }
const ed = F.edition(src); if (!ed) { toast(t('feldUnknown'), true); return null; }
const fresh = [];
let rom = F.cleanBase(src), apps = [];
const de = D.embedded();
for (const x of dxs) {
if (!de || !de.appF) { toast(t('doomMissing'), true); return null; }
if (state.doomKeys) x.keys = Object.assign({}, state.doomKeys);
const err = x.keys && D.doomKeysCheck(x.keys); if (err) { toast(em(err), true); return null; }
if (x.wadSrc) { const m = doomMcuOf(x); if (!m) { toast(t('doomBig'), true); return null; } x.mcu = m; }
}
// a T18Emu that stays where it is keeps its blocks, spares and save (as in the start device with the Paradise)
if (state.ctx.clean) for (const [a, b] of keptT18Ranges(extrasL, src)) rom.set(src.subarray(a, b), a);
const progs = { t7: E.t7Embedded(), tama: E.embedded() && E.embedded().app, t18: E.t18Embedded(), v1: E.v1Embedded(), doom: de && de.appF ? { app: de.appF, xip: de.xipF } : null };
try {
const r = E.appsPlace(rom, extrasL, progs, { lang, clock: state.emuClock !== false, nfc: state.emuNfc !== false, launch: true, clean: true, noClock: clockOff(), txSpare: T18_FEW && state.t18Few ? 0x40000 : undefined, keep: F.cleanReserved(), dlApp: null });
rom = r.rom; apps = r.list; lastFree = r.freeKB; state.tamaPacked = !!r.lzUsed; // 1.7.3 test18 TAMA_RAW: packed only for lack of room
const at = (k) => apps[k + (mainX ? 1 : 0)];
if (state.t7saveX && at(state.t7saveX.i)) rom = SV.t7SaveIn(rom, state.t7saveX.save, at(state.t7saveX.i).off + 0x10000);
const si = state.saveIn, sk = !si ? null : si.key === 'm' ? (mainX ? -1 : null) : si.key;
if (typeof sk === 'number' && (sk === -1 ? apps[0] : at(sk))) {
const a = sk === -1 ? apps[0] : at(sk), cx = E.extraCfg(rom, a.off);
if (si.kind === 'v1' && cx) { rom = new Uint8Array(rom); rom.set(si.data, cx.saveOff); fresh.push([cx.saveOff, cx.saveOff + 0x2000]); }
if (si.kind === 'tama' && cx) fresh.push([cx.saveOff, cx.saveOff + 0x50000], [cx.guestOff, cx.spareEnd]);
}
extrasL.forEach((x, i) => { if (x.carry && apps[i]) { const cx = E.extraCfg(rom, apps[i].off); if (cx && cx.kind === 'tama') fresh.push([cx.saveOff, cx.saveOff + 0x50000], [cx.guestOff, cx.spareEnd]); } });
for (const x of extrasL) if (x.kind === 't18' && x.items && x.keepOff !== undefined) { const k = extrasL.indexOf(x); if (apps[k]) t18Fresh(rom, apps[k].off, fresh); }
} catch (e) { lastRoom = e && e.room ? e.missing : 0; toast(e && e.room ? t(e.frag ? 'noRoomFrag' : 'noRoomKB', { k: e.missing }) + (e.packHint ? t('packTip') : '') : t('appFail', { e: em(e) }), true); return null; }
// the main program: the one chosen with the star, or the main program of the Paradise taken along
const k = state.mainPick === 'emu' ? (mainX ? 0 : -1) : state.mainPick ? extrasL.indexOf(state.mainPick) : (mainX && !state.ctx.clean ? 0 : -1);
const mainSrc = k >= 0 && apps[k] ? apps[k].src : 0;
try { rom = F.cleanApply(rom, { apps, dl: DL_AT, mainSrc, auto: !!state.emuAuto && !!mainSrc, noClock: state.cleanClock === false }, { feld: fe.feldc, stub: fe.stub }); }
catch (e) { toast(t('feldFail', { e: em(e) }), true); return null; }
{ const w = FL.withRescue(rom, emb); if (!w) { toast(t('feldFail', { e: 'rescue' }), true); return null; } rom = w; }
if (EXIT_KEY && (state.exitKey || exitGet(rom))) rom = exitSet(rom, state.exitKey || 0);
return { rom, name: baseName() + (state.doom ? '_doom_E' + $('doomEp').value : '') + '_clean.bin', res: null, fresh };
}
async function composeRom() {
if (state.ctx && S6.kindOf(state.ctx.rom) === 'gen3') {
const si = S6.sixInfo(state.ctx.rom);
const explicit = !!state.six || !!state.sixWant || !!state.sixOff || (!!si && !sixSame(si));
if ((explicit || memberSix.ready) && !await ensureSixMembership() && explicit) {toast('여섯 지역 확장 결과를 저장하려면 다시 로그인하세요.',true);return null;}
}
if (CLEAN_ROM && state.clean) return composeClean();
const keysDirty = !state.doom && doomInstalled() && state.doomKeys && D.doomKeysGet(state.ctx.rom) && JSON.stringify(state.doomKeys) !== JSON.stringify(D.doomKeysGet(state.ctx.rom));
const si0 = S6.sixInfo(state.ctx.rom), sixUp = (!!si0 && (si0.version < S6.VERSION || !sixSame(si0)) && !S6.sixNeedsSource(state.ctx.rom)) || sixDnaUp(si0);
const emuUp = emuUpPending();
if (!state.changed.size && !state.t7save && !state.emu && !state.emuRemove && !state.doom && !keysDirty && !emuUp && !emuAutoDirty() && !state.six && !sixUp && !(state.sixWant && !S6.sixInfo(state.ctx.rom)) && state.feld === state.feldInit && state.bag === state.bagInit && state.tama === state.tamaInit && !!state.gplay === !!state.gplayInit && state.saves === state.savesInit && state.launch === state.launchInit && (state.exitKey || 0) === (state.exitKeyInit || 0) && !state.feldStale && !state.extrasDirty && !state.mainDirty && !state.extrasUp && !state.t7saveX && !state.saveIn && !state.sixOff && !state.petDirty && !state.t18Dirty && !state.t18PicsDirty && !(state.texts && state.texts.size) && !(state.eyeShift && state.eyeShift.size) && !(state.mouthShift && state.mouthShift.size) && !(state.poseAdj && state.poseAdj.size)) return { rom: state.ctx.rom, name: state.name, res: null, same: true };
const fe = F.embedded(); let feldSaved = fe ? F.feldSlots(state.ctx.rom, fe.stub) : [];
// start device with DOOM (1.6.8): DOOM is the program at 0x0A0000, the emulator of the Emulator tab goes along as a further program
const doomL = !!state.launch && (!!state.doom || (doomInstalled() && !state.emuRemove));
let mainX = null;
if (doomL && state.emu) mainX = emuX(state.emu);
else if (doomL && state.doom && emuInstalled()) mainX = await installedX(state.ctx.rom);
// 1.6.8: an extra that is the same firmware as the main emulator only once (a start device read back shows its
// emulator as a further program; choosing it again in the Emulator tab must not put it in twice)
if (mainX) { mainX.clock = state.emuClock !== false; mainX.nfc = state.emuNfc !== false; mainX.opt = state.emuOpt; mainX.sess = state.emuSess !== false; }
extrasDedupe(mainX);
const extrasL = mainX ? [mainX].concat(state.extras || []) : (state.extras || []);
if (state.emu && state.doom && !doomL) { toast(t('doomBoth'), true); return null; }
if (state.doom && state.doomKeys && D.doomKeysCheck(state.doomKeys)) { toast(em(D.doomKeysCheck(state.doomKeys)), true); return null; }
let rom = state.ctx.rom, res = null;
const fresh = []; // 1.6.8: ranges taken from the image even with "keep saves" (imported saves)
if (state.launch && !FL.embedded()) { toast(t('emuMissing'), true); return null; }
if (state.launch && !(state.emu || state.doom || (state.extras && state.extras.length) || (appInstalled() && !state.emuRemove))) { toast(t('launchNeed'), true); return null; }
const lmap = state.launch ? launchMapGet() : null;
if (state.changed.size || (lmap && lmap.size) || (state.eyeShift && state.eyeShift.size) || (state.mouthShift && state.mouthShift.size) || (state.poseAdj && state.poseAdj.size)) {
const all = lmap ? new Map([...lmap, ...state.changed]) : state.changed;
try { res = C.buildRom(state.ctx, all, currentDataPack()); rom = res.rom; }
catch (e) { toast(t('tooBig', { e: em(e) }), true); return null; }
}
// 1.6.8: names of fields, Tamas and items (text tables)
if (state.texts && state.texts.size) { try { rom = C.textApply(rom, state.texts, state.textLanguage || lang); } catch (e) { toast(t('tooBig', { e: em(e) }), true); return null; } }
if (fe) rom = F.feldStrip(rom, { stub: fe.stub, oldStub: E.embedded() && E.embedded().stub }, E);
// Emulator instead of installed DOOM: remove DOOM completely first (program part, WAD), then install the emulator
// test5: a further T18Emu that stays where it is (start device) has blocks in the area the main program's removal
// empties (0x830000..0xD48000): they are put back; a new main program must not take them
// test6 APPS_CLEAR_FIRST: the further programs of the old ROM go before the main program is built in (they are
// placed again afterwards); before, a new main program (T18Emu needs 91 blocks) only saw the room they left
if (fe && APPS_CLEAR_FIRST) { const old = E.appsRead(state.ctx.rom, F.feldApps(state.ctx.rom, fe.stub).apps); if (old.length) rom = E.appsClear(rom, old.filter((o) => !extrasL.some((x) => x.kind === 't18' && x.keepOff === o.off))); }
// test25 HI_ORPHAN: start device: what removed programs left behind the Paradise's save becomes free (see E.hiFree)
if (HI_ORPHAN && fe && state.launch && APPS_CLEAR_FIRST) { const ff = F.feldFind(rom, fe.stub); rom = E.hiFree(rom, extrasL.filter((x) => x.kind === 't18' && x.keepOff !== undefined).map((x) => x.keepOff), ff ? ff.off : 0); }
const t18Keep = keptT18Ranges(extrasL, rom), t18Back = (r) => { for (const [a, b] of t18Keep) r.set(rom.subarray(a, b), a); return r; };
const romMain0 = rom;
if (state.emu && doomInstalled() && !doomL) { try { rom = t18Back(E.emuRemove(rom)); } catch (e) { toast(t('emuFail', { e: em(e) }), true); return null; } }
if ((state.emu && !doomL) || state.emuRemove) {
const emb = E.embedded();
try {
if (state.emu && doomL) { /* goes along as a further program */ }
else if (state.emu && state.emu.v1) { if (!emb || !E.v1Embedded()) throw new Error(t('emuMissing')); rom = E.v1Patch(rom, state.emu.rom, E.v1Embedded(), emb.stub, { lang, clock: state.emuClock !== false }); }
else if (state.emu && state.emu.t7) { if (!emb || !E.t7Embedded()) throw new Error(t('emuMissing')); rom = E.t7Patch(rom, state.emu.rom, state.emu.figs, E.t7Embedded(), emb.stub, { lang }); }
else if (state.emu && state.emu.t18) { if (!emb || !E.t18Embedded()) throw new Error(t('emuMissing')); rom = E.t18Patch(rom, state.emu.rom, E.t18Embedded(), emb.stub, { lang, launch: !!state.launch, spares: T18_FEW && state.t18Few ? T18_FEW_N : undefined, holes: T18_FEW && state.t18Few }).rom; }
else if (state.emu) { if (!emb) throw new Error(t('emuMissing')); rom = E.emuPatch(rom, state.emu.guest, emb.app, emb.stub, { lang, pack: !!state.emuPack }).rom; }
else rom = t18Back(E.emuRemove(rom));
} catch (e) { toast(e && e.needPack ? t('packNeed') : t('emuFail', { e: em(e) }), true); return null; }
if (t18Keep.some(([a, b]) => rom.subarray(a, b).some((v, i) => v !== romMain0[a + i]))) { toast(t('emuFail', { e: t('t18Clash') }), true); return null; }
}
if (state.t7save && F.emuType(rom) === 't7' && !doomL) rom = SV.t7SaveIn(rom, state.t7save);
if (state.saveIn && state.saveIn.key === 'm' && !doomL) {
if (state.saveIn.kind === 'v1' && F.emuType(rom) === 'v1') { rom = new Uint8Array(rom); rom.set(state.saveIn.data, 0xC0000); fresh.push([0xC0000, 0xC2000]); }
if (state.saveIn.kind === 'tama' && F.emuType(rom) === 'tama') { const g0 = rd32(rom, 0xA0148), se = rd32(rom, 0xA0144) >= 3 ? rd32(rom, 0xA0140 + 152) : g0 + rd32(rom, 0xA014C); fresh.push([0xC0000, 0x110000], [g0, se]); }
}
// newer emulator program: only the program changes, the Tamagotchi's save stays
if (emuUp && F.appKind(rom) === 2) { const ty = F.emuType(rom), u = ty === 'v1' ? E.v1Upgrade(rom, E.v1Embedded()) : ty === 't7' ? E.t7Upgrade(rom, E.t7Embedded()) : ty === 't18' ? E.t18Upgrade(rom, E.t18Embedded(), E.embedded() && E.embedded().stub) : E.emuUpgrade(rom, E.embedded().app); if (u) rom = u; }
if (state.t18Dirty && state.t18Main && !state.emu && !state.emuRemove && F.emuType(rom) === 't18') { try { rom = E.t18RomWriteGuest(rom, state.t18Main); t18Fresh(rom, 0xA0000, fresh); } catch (e) { toast(t('emuFail', { e: em(e) }), true); return null; } } // test47: items
if (F.emuType(rom) === 't18' && state.t18Pics && (state.t18Pics.size || state.t18PicsDirty)) rom = E.t18PicsWrite(rom, state.t18Pics); // test47: grow-up pictures
if (state.doom && !state.doom.ok.length && !(state.doom.fit.all && state.doom.fit.all.plain)) { toast(t('doomBig'), true); return null; }
if (state.doom) {
const emb = D.embedded(), embE = E.embedded();
try {
if (!emb || !embE) throw new Error(t('doomMissing'));
rom = (await D.doomBuild(rom, state.doom.wadM || state.doom.wad, { episode: $('doomEp').value, music: $('doomMusic').checked, keys: state.doomKeys || D.KEYS_DEFAULT }, { app: emb.app, xip: emb.xip, wasm: emb.wasm, stub: embE.stub }, E)).rom;
} catch (e) { toast(t('doomFail', { e: em(e) }), true); return null; }
}
// Change the keys of an already installed DOOM
if (!state.doom && doomInstalled() && !state.emuRemove && state.doomKeys && D.doomKeysGet(rom)) {
const k = state.doomKeys, err = D.doomKeysCheck(k);
if (err) { toast(em(err), true); return null; }
rom = D.doomKeysSet(rom, k);
}
// 1.6.8: extra fields out again (several saves with the edition's own fields only)
if (state.sixOff && S6.sixInfo(rom)) {
const base = F.fieldNames(S6.sixStrip(state.ctx.rom)), now = F.fieldNow(state.ctx.rom);
if (now && base.length && !base.includes(now)) { toast(t('sixOffField', { f: now, s: base.join(', ') }), true); return null; }
if (feldSaved.length && !confirm(t('sixOffSlots'))) return null;
rom = S6.sixStrip(rom); feldSaved = [];
}
const needSrc = S6.sixNeedsSource(rom);
if (state.sixWant && needSrc && !state.six && !S6.sixInfo(rom)) { toast(t('sixNeed'), true); return null; }
const sixHave = S6.sixInfo(rom);
if (sixHave && needSrc && !state.six && sixHave.version >= S6.VERSION && !sixSame(sixHave)) { toast(t('sixPlanetNeed'), true); return null; }
if ((state.six || (state.sixWant && !needSrc) || (!needSrc && sixHave)) && !(sixHave && sixHave.version >= S6.VERSION && sixSame(sixHave))) {
if (state.doom || doomInstalled() || state.emu) { toast(t('sixFail', { e: t('sixApp') }), true); return null; }
if (state.extras && state.extras.length) { toast(t('appSix'), true); return null; }
try { rom = S6.sixApply(rom, state.six, S6.embedded(), { planet: state.sixPlanet !== false, fieldMenu: state.sixMenu !== false }); }
catch (e) { toast(t('sixFail', { e: em(e) }), true); return null; }
}
if (sixAllowed() && S6.DNA && S6.sixInfo(rom)) rom = S6.sixDna(rom, S6.embedded(), true);
if (sixAllowed() && S6.HUNT && S6.sixInfo(rom)) rom = S6.sixHunt(rom); // 1.7.3 test23: egg hunt per field
if (S6.sixInfo(rom)) rom = S6.sixFix(rom); // the archive may have moved: rain pictures point to 0xF00000
// more emulators (1.6.0): the old blocks go, the list is placed again from the top of the emulator area
let apps = [], appsLow = 0;
if (fe && !APPS_CLEAR_FIRST) { const old = E.appsRead(state.ctx.rom, F.feldApps(state.ctx.rom, fe.stub).apps); if (old.length) rom = E.appsClear(rom, old.filter((o) => !extrasL.some((x) => x.kind === 't18' && x.keepOff === o.off))); } // test2: an installed T18Emu stays
let dl = 0;
if (extrasL.length || state.launch) {
if (!fe || !menuWanted()) { toast(t('appNeedMenu'), true); return null; }
if (!E.t7Embedded()) { toast(t('emuMissing'), true); return null; }
const progs = { t7: E.t7Embedded(), tama: E.embedded() && E.embedded().app, t18: E.t18Embedded(), v1: E.v1Embedded() };
let dlRes = false;
if (state.launch) { rom = dlStrip(rom, fe); if (DL_RESCUE && FL.embedded()) { const w = FL.withRescue(rom, FL.embedded()); if (w) { rom = w; dlRes = true; } } }
try { const r = E.appsPlace(rom, extrasL, progs, { lang, clock: state.emuClock !== false, nfc: state.emuNfc !== false, launch: !!state.launch, txSpare: T18_FEW && state.t18Few ? 0x40000 : undefined, keep: F.appKind(rom) === 1 ? [[0x830000, 0xD48000]] : [], dlApp: state.launch && !dlRes ? FL.embedded() : null }); rom = r.rom; apps = r.list; appsLow = r.low; dl = dlRes ? DL_AT : r.dl; lastFree = r.freeKB;
for (const x of extrasL) if (x.kind === 't18' && x.items && x.keepOff !== undefined) t18Fresh(rom, x.keepOff, fresh); // test3
if (state.t7saveX && apps[state.t7saveX.i + (mainX ? 1 : 0)]) rom = SV.t7SaveIn(rom, state.t7saveX.save, apps[state.t7saveX.i + (mainX ? 1 : 0)].off + 0x10000);
if (state.saveIn && typeof state.saveIn.key === 'number' && apps[state.saveIn.key + (mainX ? 1 : 0)]) {
const at = apps[state.saveIn.key + (mainX ? 1 : 0)].off, cx = E.extraCfg(rom, at);
if (state.saveIn.kind === 'v1' && cx) { rom = new Uint8Array(rom); rom.set(state.saveIn.data, cx.saveOff); fresh.push([cx.saveOff, cx.saveOff + 0x2000]); }
if (state.saveIn.kind === 'tama' && cx) fresh.push([cx.saveOff, cx.saveOff + 0x50000], [cx.guestOff, cx.spareEnd]); // the imported pet: no run state of the device
}
extrasL.forEach((x, i) => { if (!x.carry || !apps[i + (mainX ? 1 : 0)]) return; const cx = E.extraCfg(rom, apps[i + (mainX ? 1 : 0)].off); if (cx && cx.kind === 'tama') fresh.push([cx.saveOff, cx.saveOff + 0x50000], [cx.guestOff, cx.spareEnd]); }); // test26: a save taken along from the device
}
catch (e) { lastRoom = e && e.room ? e.missing : 0; toast(e && e.room ? t(e.frag ? 'noRoomFrag' : 'noRoomKB', { k: e.missing }) + (e.packHint ? t('packTip') : '') : t('appFail', { e: em(e) }), true); return null; }
}
// 1.6.8: always the firmware's name (TAMA-GO, FRIENDS, ID L, 4U+ ...), not the emulator's
// 1.6.9 test13: the chosen main program's place in the list (0 = the program at 0x0A0000)
const mainSrcOf = () => { if (!state.launch || !state.mainPick || !doomL) return 0; const k = state.mainPick === 'emu' ? (mainX ? 0 : -1) : extrasL.indexOf(state.mainPick); return k >= 0 && apps[k] ? apps[k].src : 0; };
const name0 = F.appKind(rom) === 1 ? 'DOOM' : state.emu && state.emu.guest ? E.tamaName(state.emu.guest, state.emu.dev) : (!state.emu && !state.emuRemove && fe && F.appKind(state.ctx.rom) === F.appKind(rom) && F.feldApps(state.ctx.rom, fe.stub).name0) || mainName(rom);
if (fe && menuWanted()) {
try { rom = F.feldApply(rom, { fields: state.feld, bag: state.bag, tama: state.tama, gplay: state.gplay && !state.clean, saves: state.saves, launch: !!state.launch, apps, name0, appsLow, dl, mainSrc: mainSrcOf(), auto: !!state.emuAuto, fieldNames: fieldTexts(rom).map((x) => x.name) }, feldSaved, { feld: fe.feld, stub: fe.stub }, E); }
catch (e) { toast(t('feldFail', { e: em(e) }), true); return null; }
}
// autostart of the emulator (the stubs above were written with it off), clock switch (1.5.1)
if (F.appKind(rom) === 2) rom = E.emuSessSet(E.emuOptSet(E.emuNfcSet(E.emuClockSet(rom, state.emuClock !== false), state.emuNfc !== false), state.emuOpt), state.emuSess !== false);
if (F.appKind(rom) === 2 || (F.appKind(rom) === 1 && !state.launch)) { // 1.6.8: DOOM as the main program can start right away too
let a = E.autoSet(rom, stubList(rom), !!state.emuAuto);
const fe2 = F.embedded();
// stub of an older Studio (no switch): put in the current one
if (!a && state.emuAuto && E.embedded() && !(fe2 && F.feldFind(rom, fe2.stub))) {
try { rom = E.installApp(rom, rom.slice(0xA0000, 0xB0000), E.embedded().stub); a = E.autoSet(rom, stubList(rom), true); } catch (e) { a = null; }
}
if (a) rom = a;
}
if (EXIT_KEY && (state.exitKey || exitGet(rom))) rom = exitSet(rom, state.exitKey || 0);
const name = baseName() + (state.changed.size ? '_paramix' : '') + (state.emu ? (state.emu.v1 ? '_v1' : state.emu.t7 ? '_t7' : state.emu.t18 ? '_t18' : '_emu') : '') + (state.doom ? '_doom_E' + $('doomEp').value : '') + (S6.sixInfo(rom) ? (S6.kindOf(rom) === 'jade' ? '_4fields' : '_6fields') : state.feld ? '_fields' : '') + (state.bag ? '_items' : '') + (state.launch ? '_start' : '') + '.bin';
return { rom, name, res, fresh };
}
$('btnSave').onclick = () => busy(async () => {
const c = await composeRom(); if (!c) return;
if (c.same) { toast(t('nothing')); return; }
download(c.rom, c.name);
state.saved = state.changed.size;
toast(c.res ? t('saved', { name: c.name, n: state.changed.size, kb: c.res.free / 1024 | 0 }) : t('savedEmu', { name: c.name }));
});
// ------------------------------------------------------------- device (UART)
const FL = window.ParamixFlash;
const dv = { io: null, d: null, loaded: false, run: false, cancel: false };
function devRender(msg) {
$('btnBackupRetry').hidden=!window.TamaArchive.hasPending();$('btnBackupRetry').disabled=!!dv.run;
$('start').hidden = !!state.ctx || !$('device').hidden || !!dv.d || dv.run;
const ser = !!(navigator.serial && FL.embedded());
$('btnConn').disabled = !ser || dv.run;
$('btnDump').disabled = window.TamaArchive.hasPending() || !dv.d || dv.run;
$('btnWrite').disabled = !dv.d || dv.run || !state.ctx;
$('btnSaveRead').disabled = window.TamaArchive.hasPending() || !dv.d || dv.run;
$('btnSaveWrite').disabled = $('btnParaIn').disabled = !dv.d || dv.run;
$('devOnly').disabled = $('devKeep').disabled = dv.run;
$('btnDevStop').hidden = !dv.run;
$('btnRescueTest').disabled = $('btnRescueBack').disabled = !dv.d || dv.run;
$('devInfo').textContent = dv.d ? t('devOn', { ed: dv.d.info.name, mb: dv.d.info.capacity >> 20, l: dv.loaded ? t('devLoaded') : '' }) : t('devNone');
if (msg !== undefined) $('devStat').textContent = msg;
else if (!ser) $('devStat').textContent = t('devNoSerial');
else if (dv.d && !state.ctx && !dv.run) $('devStat').textContent = t('devNeedRom');
uartWarnRender();
renderDeviceSix();
if (state.ctx) renderFeld();
}
/* Flasher errors and notes carry a code; German has its own texts, English uses the module's */
function flMsg(x) { return x && x.code && lang !== 'en' && T[lang]['fl_' + x.code] ? t('fl_' + x.code, x.p) : (x.message || x.text || String(x)); }
function devProg(ph, done, total) {
$('devBar').style.width = (total ? Math.min(100, done / total * 100) : 0).toFixed(1) + '%';
const big = total >= 0x400000, u = big ? 1 << 20 : 1024;
const n = ph === 'write' ? done + ' / ' + total : (done / u | 0) + ' / ' + (total / u | 0) + (big ? ' MB' : ' KB');
$('devStat').textContent = t('ph' + ph) + ' ' + n;
}
async function devTask(fn) {
dv.run = true; dv.cancel = false; devRender('');
let msg;
try { await fn(); msg = $('devStat').textContent; }
catch (e) { msg = dv.cancel ? t('devCancelled') : t('devErr', { e: flMsg(e) }); }
dv.run = false; devRender(msg);
}
$('btnDevice').onclick = () => { $('device').hidden = !$('device').hidden; devRender(); };
$('btnHelp').onclick = () => { $('helpBox').hidden = !$('helpBox').hidden; };
$('helpClose').onclick = () => { $('helpBox').hidden = true; };
$('btnDevStop').onclick = () => { dv.cancel = true; };
/* 1.6.9: simulated playdate partner for the Paradise (src/visit.js). Same link key and serial transport as the
* flash app loader (src/flash.js). */
const VS = { io: null, v: null };
const VIS_ED = [['land', 'Land'], ['water', 'Water'], ['sky', 'Sky'], ['jade', 'Jade Forest'], ['tropics', 'Tropics'], ['glacier', 'Glacier']];
function visKey() { return window.ParamixVisit.parseKey(FL.linkKey); }
function visStat(m) { $('visStat').textContent = m; }
function visEdName() { const e = $('visEd').value; const x = VIS_ED.find((a) => a[0] === e); return x ? x[1] : e; }
function visRender() {
$('btnVis').textContent = t(VS.io ? 'visStop' : 'visStart');
$('btnVis').disabled = !navigator.serial;
}
{
const sel = $('visEd');
for (const [v, n] of VIS_ED) { const o = document.createElement('option'); o.value = v; o.textContent = lang==='ko'?({land:'랜드',water:'워터',sky:'스카이',jade:'제이드 포레스트',tropics:'트로피컬',glacier:'글레이셔'}[v]||n):n; sel.appendChild(o); }
try { const e = localStorage.getItem('pmxVisitEd'); if (e) sel.value = e; } catch (e) {}
if (!sel.value) sel.value = 'water';
sel.onchange = () => { try { localStorage.setItem('pmxVisitEd', sel.value); } catch (e) {} if (VS.io && (!VS.v || VS.v.state.phase === 'wait' || VS.v.state.phase === 'done' || VS.v.state.phase === 'error')) visArm(); };
visRender();
}
function visArm() {
if (VS.v) VS.v.stop();
const ed = visEdName();
VS.v = window.ParamixVisit.createVisitor({
edition: $('visEd').value, key: visKey(),
send: (b) => VS.io.write(b),
log: (e, i) => {
if (e === 'start') visStat(t('visRun'));
else if (e === 'sent') visStat(t('visPlay'));
else if (e === 'done') { visStat(t('visDone', { ed })); setTimeout(() => { if (VS.io) visArm(); visStat(t('visDone', { ed })); }, 500); }
else if (e === 'error') { visStat(i.text === 'key' ? t('visBadKey') : t('visErr', { e: i.text })); if (i.text !== 'key') setTimeout(() => { if (VS.io) visArm(); }, 1000); }
},
});
visStat(t('visWait', { ed }));
}
async function visClose() {
const io = VS.io; VS.io = null;
if (VS.v) VS.v.stop(); VS.v = null;
try { if (io) await io.close(); } catch (e) {}
visRender();
}
$('btnVis').onclick = async () => {
if (VS.io) { await visClose(); visStat(''); return; }
if (!navigator.serial) { visStat(t('devNoSerial')); return; }
if (dv.io) { visStat(t('uartBusy')); return; }
let port;
try { port = await navigator.serial.requestPort(); } catch (e) { return; }
try { VS.io = await FL.serialOpen(port); } catch (e) { visStat(t('visErr', { e: e.message })); return; }
VS.io.onData = (d) => { if (VS.v) VS.v.feed(d); };
visRender(); visArm();
};
const PL_HINT = true;
$('btnConn').onclick = async () => {
if (VS.io) await visClose();
let port;
try { port = await navigator.serial.requestPort(); } catch (e) { return; }
devTask(async () => {
if (dv.io) { await dv.io.close(); dv.io = null; dv.d = null; }
dv.io = await FL.serialOpen(port);
/* 1.7.3 PL_HINT: a Prolific adapter (USB vendor 0x067B) that gets no readable answer: say what usually helps */
let r;
try { r = await FL.connect(dv.io, FL.embedded(), {}, devProg); }
catch (e) {
let pl = false; try { pl = PL_HINT && port.getInfo().usbVendorId === 0x067B; } catch (x) {}
if (pl && e && (e.code === 'noData' || e.code === 'noAnswer')) e.message = flMsg(e) + '. ' + t('plHint'), e.code = null;
throw e;
}
dv.d = r.dev; dv.loaded = r.loaded; dv.readCtx = null;
devRender(t('devReady'));
await rescueCheck();
});
};
$('btnBackupRetry').onclick=()=>devTask(async()=>{const img=await window.TamaArchive.retry();if(img.length===0x1000000){await loadRom(new File([img],'paradise-recovered-backup.bin'));dv.readCtx=state.ctx;}});
$('btnDump').onclick = () => devTask(async () => {
const img = await dv.d.dump(devProg, () => dv.cancel);
const st = new Date().toISOString().slice(0, 19).replace(/[-:]/g, '').replace('T', '-');
const name = 'paradise-' + dv.d.info.name.toLowerCase().replace(/ /g, '-') + '-' + st + '.bin';
// Collection is limited to explicit full-ROM extraction; local file opens and saves are never uploaded.
await window.TamaArchive.deliver(img,name,download,msg=>{$('archiveStatus').textContent=msg;});
await loadRom(new File([img], name));
dv.readCtx = state.ctx;
devRender(t('devDumped', { n: name }));
});
if (location.protocol !== 'file:') window.TamaArchive.request('/api/catalog').then(c => {
$('siteTitle').textContent = c.title; $('siteDescription').textContent = c.description; applyFeatures(c.features);
}).catch(() => {});
ensureSixMembership();
window.addEventListener('focus', () => {ensureSixMembership();});
// A user-selected private backup opens locally in the editor; it is not re-uploaded.
if (location.protocol !== 'file:' && new URLSearchParams(location.search).has('backup')) {
window.addEventListener('load', () => busy(async () => {
try {
const {img, item} = await window.TamaArchive.memberFile(new URLSearchParams(location.search).get('backup'));
await loadRom(new File([img], item.label + '.bin'));
} catch (e) { alert(e.message); }
}), {once:true});
}
/*
* test26 SAVE_CARRY: a TamaEmu or T18Emu that gets another place (main program <-> menu, or another place in the menu)
* takes the device's save along when writing with "Keep saves". The device's layout is the loaded ROM's (checked by
* the programs' settings sectors); only the sectors of its flash that differ on the device are read. The save then goes
* into the new ROM like an imported one. Returns { changed, carried: Set of offsets in the loaded ROM } or null when
* the user stops (the device could not be checked and a save might be lost).
*/
const SAVE_CARRY = true;
async function saveCarry(d, c1) {
const r0 = state.ctx.rom, fe = F.embedded(), out = { changed: false, carried: new Set() };
const progs = [];
if (emuInstalled() && /tama|t18/.test(F.emuType(r0))) progs.push(0xA0000);
for (const x of romExtras(r0)) if (E.extraKind(x) === 'tama' || E.extraKind(x) === 't18') progs.push(x.off);
if (!progs.length) return out;
// the same place: same program and the same layout there (firmware place, save place, block map); flags may change
const nr = c1.rom, sameAt = (off) => { const m = rd32(r0, off + 0x140), to = m === 0x38584D50 ? 0x140 + 400 : 0x1DC; if (rd32(nr, off + 0x140) !== m) return false; for (let i = 0x148; i < to; i++) if (nr[off + i] !== r0[off + i]) return false; return true; };
const moved = progs.filter((o) => !sameAt(o));
if (!moved.length) return out;
let ok = true;
for (const o of [0xA0000].concat(romExtras(r0).map((x) => x.off))) { try { if (await d.crc(o, 0x1000) !== FL.crc32(r0, o, 0x1000)) ok = false; } catch (e) { ok = false; } }
if (!ok) return confirm(t('carryUnknown')) ? out : null;
const base = new Uint8Array(r0);
const pull = async (a, b) => { for (const s of await d.changed(r0, null, () => dv.cancel, a & ~0xFFFF, (b + 0xFFFF) & ~0xFFFF)) { base.set(await d.read(s, 0x1000), s); out.changed = true; } };
for (const o of moved) {
const m = rd32(r0, o + 0x140);
if (m === 0x43584D50) { // TamaEmu: its firmware with the pet's own writes, spare pages, from the device
const cfg = o === 0xA0000 ? romEmuCfg(r0) : SV.emuCfg(r0.subarray(o, o + 0x1000)); if (!cfg) continue;
const end = cfg.spareEnd || cfg.guestOff + cfg.guestSize; await pull(cfg.guestOff, end);
const g = await SV.emuGuestAsync((a, n) => base.subarray(a, a + n), cfg), me = { kind: 'tama', guest: g, dev: cfg.dev };
if (state.emu && state.emu.guest && sameFw({ kind: 'tama', guest: state.emu.guest, dev: state.emu.dev }, me)) { const pk = E.packMain(g, cfg.dev, null, !!state.emuPack); state.emu = Object.assign({}, state.emu, { guest: g, size: pk.blob.length, big: pk.big }); out.carried.add(o); }
else if (o === 0xA0000 && state.clean) { const x = (state.extras || []).find((y) => y.fromParaMain && y.kind === 'tama'); if (x) { x.guest = g; x.carry = true; state.extrasDirty = true; out.carried.add(o); } } // CLEAN_ROM: the main program went to the menu
else { const x = (state.extras || []).find((y) => E.extraKind(y) === 'tama' && sameFw(y, me)); if (x) { x.guest = g; x.carry = true; state.extrasDirty = true; out.carried.add(o); } }
} else if (m === 0x38584D50) { // T18Emu: its firmware with its save
const tc = E.t18Cfg(r0, o); if (!tc) continue;
for (const b of tc.map.concat(tc.spare)) if (b !== 0xFFFF && b < 0x100) await pull(b << 16, (b + 1) << 16);
await pull(tc.saveOff, tc.saveOff + 0x24000);
const fw = E.t18FromRom(base, o); if (!fw) continue;
const me = { kind: 't18', fw };
if (state.emu && state.emu.t18) { state.emu = Object.assign({}, state.emu, { rom: fw }); out.carried.add(o); }
else if (o === 0xA0000 && state.clean) { const x = (state.extras || []).find((y) => y.fromParaMain && y.kind === 't18'); if (x) { x.fw = fw; delete x.keepOff; x.saveImp = true; state.extrasDirty = true; out.carried.add(o); } }
else { const x = (state.extras || []).find((y) => E.extraKind(y) === 't18'); if (x) { x.fw = fw; delete x.keepOff; x.saveImp = true; state.extrasDirty = true; out.carried.add(o); } }
void me;
}
}
if (out.carried.size < moved.length && !confirm(t('carryMiss'))) return null;
return out;
}
$('btnWrite').onclick = async () => {
let c = await busy(composeRom); if (!c) return;
const keep = $('devKeep').checked;
if (!confirm(t('devSure')) || (!keep && !confirm(t('devSureFull')))) return;
// CLEAN_ROM: a device with the Paradise becomes one without: its game and save go (a backup first)
const cleanNew = CLEAN_ROM && F.isClean(c.rom);
if (cleanNew && dv.d) { let dc = false; try { const h = await dv.d.read(0, 0x1000); dc = String.fromCharCode(...h.subarray(0, 8)) === 'SONIXDEV' && (h[8] & 1) === 0; /* our table: not encrypted */ } catch (e) { dc = false; } if (!dc && !confirm(t('cleanSure'))) return; }
// test26: a TamaEmu or T18Emu that moves takes the device's save along
let carried = new Set();
if (keep && SAVE_CARRY && dv.d) {
let cr = null; try { cr = await busy(() => saveCarry(dv.d, c)); } catch (e) { cr = confirm(t('carryUnknown')) ? { changed: false, carried: new Set() } : null; }
if (!cr) return;
carried = cr.carried;
if (cr.changed && cr.carried.size) { c = await busy(composeRom); if (!c) return; }
}
// an emulator save on the device that the new ROM cannot keep: say so before (1.5.1)
let emuSame = false;
if (keep && !cleanNew) {
const EMU = { 0x43584D50: 'TamaEmu', 0x37584D50: 'T7Emu', 0x38584D50: 'T18Emu', 0x31584D50: 'V1Emu' };
let dm = 0;
try { const p = await dv.d.read(0xA0000, 0x1000); dm = (p[0x140] | p[0x141] << 8 | p[0x142] << 16 | p[0x143] << 24) >>> 0; } catch (e) { dm = 0; }
const im = (c.rom[0xA0140] | c.rom[0xA0141] << 8 | c.rom[0xA0142] << 16 | c.rom[0xA0143] << 24) >>> 0;
// 1.6.8: the same firmware chosen again (same layout and data as on the device) keeps the save
if (EMU[dm] && dm === im && state.emu) { try { emuSame = await emuSameDev(dv.d, c.rom, dm); } catch (e) { emuSame = false; } }
// 1.6.8: a T7Emu or V1Emu that goes from the main program to the menu takes its save along (keepPlan): no question
let moved = false;
if (EMU[dm] && dm !== im && (dm === 0x37584D50 || dm === 0x31584D50)) {
try {
const p = await dv.d.read(0xA0000, 0x1000), u = (b, o) => (b[o] | b[o + 1] << 8 | b[o + 2] << 16 | b[o + 3] << 24) >>> 0;
const ro = u(p, 0x148), rl = u(p, 0x14C), dc = await dv.d.crc(ro, rl);
const fe0 = F.embedded();
if (fe0) for (const x of E.appsRead(c.rom, F.feldApps(c.rom, fe0.stub).apps)) { const cx = E.extraCfg(c.rom, x.off); if (cx && cx.romLen === rl && FL.crc32(c.rom, cx.romOff, cx.romLen) === dc) moved = true; }
} catch (e) { moved = false; }
}
if (carried.has(0xA0000)) moved = true; // test26: its save goes along
if (EMU[dm] && !moved && (dm !== im || (state.emu && !emuSame))) {
const n = EMU[im] ? (dm === im ? t('devEmuNew', { o: EMU[im] }) : EMU[im]) : t('devEmuNone');
if (!confirm(t('devEmuLost', { o: EMU[dm], n }))) return;
}
}
// test4: items or Tamapoints of T18Emu: its save on the device is replaced by the one in the ROM, "keep saves" or not
if (keep && (state.t18Dirty || (state.extras || []).some((x) => x.kind === 't18' && x.items)) && !confirm(t('t18KeepAsk'))) return;
devTask(async () => {
const fe = F.embedded();
let plan = keep ? FL.keepPlan(F, E, fe && { stub: fe.stub }, { emuChanged: !!state.emu && !emuSame, t7Save: !!state.t7save, t7SaveX: state.t7saveX ? state.t7saveX.i : -1, t18Imp: !!(state.extras || []).some((x) => x.saveImp), mine: studioSecs(state.ctx.rom, c.rom), fresh: c.fresh || [] }) : null;
if(plan && !cleanNew){
const names=new Map();
if(state.texts?.size && (state.textLanguage||lang)==='ko')for(const def of C.charTable(state.ctx.files[0]))if(state.texts.has(def.name))names.set(def.id,C.textGet(c.rom,def.name,'ko'));
if(names.size || state.petChanges)plan=SV.keepEdits(plan,state.ctx.editionId,names,state.petChanges,state.petOriginalId);
}
let img = c.rom;
if (!cleanNew && F.emuType(img) === 't7') { const ck = await dv.d.clockRead(); if (ck && (ck.ctrl & 0x80)) img = E.t7Wall(img, ck.counter, new Date()); }
if (!cleanNew && F.emuType(img) === 't18') { const ck = await dv.d.clockRead(); if (ck && (ck.ctrl & 0x80)) img = E.t18Wall(img, ck.counter, new Date()); } // T18Emu: local time for the first start // T7Emu: local time for the first time setting
let r;
try { r = await dv.d.write(img, { onlyChanged: $('devOnly').checked, keep: plan, rescueApp: FL.embedded(), t18Bases: t18Bases(img, fe), onImage: (x) => stashPut(x) }, devProg, () => dv.cancel); }
catch (e) { if (e && e.code === 'noRescueRoom') alert(t('fl_noRescueRoom')); else if (e && e.code === 'cancelledWrite') await rescueCheck(); throw e; }
await stashDel();
let m = r.written ? t('devDone', { w: r.written, k: r.kept ? t('devKept', { k: r.kept }) : '' }) : t('devSame');
if (r.rescue) m += '\n' + t('resOn');
if (r.notes.length) m += '\n' + r.notes.map(flMsg).join('\n');
devRender(m);
});
};
/* test15: the T18Emu settings blocks in an image (main program and start device), for moving its block at 0xFF0000 */
function t18Bases(img, fe) {
const out = [];
if (rd32(img, 0xA0140) === 0x38584D50) out.push(0xA0000);
try { if (fe) for (const a of E.appsRead(img, F.feldApps(img, fe.stub).apps)) if (rd32(img, a.off + 0x140) === 0x38584D50) out.push(a.off); } catch (e) {}
return out;
}
/* test15: the image being written, kept in the browser until the write is done (a cut write goes on from there) */
const STASH_DB = 'pmxStash';
function stashDb() { return new Promise((ok, no) => { try { const q = indexedDB.open(STASH_DB, 1); q.onupgradeneeded = () => q.result.createObjectStore('img'); q.onsuccess = () => ok(q.result); q.onerror = () => no(q.error); } catch (e) { no(e); } }); }
async function stashOp(mode, fn) { try { const db = await stashDb(); return await new Promise((ok, no) => { const tx = db.transaction('img', mode), st = tx.objectStore('img'), q = fn(st); tx.oncomplete = () => ok(q && q.result); tx.onerror = () => no(tx.error); }); } catch (e) { return null; } }
const stashPut = (img) => stashOp('readwrite', (st) => st.put({ img, time: Date.now() }, 'last'));
const stashGet = () => stashOp('readonly', (st) => st.get('last'));
const stashDel = () => stashOp('readwrite', (st) => st.delete('last'));
/* test15: after connecting: a device without its table is in the rescue start (a write was cut off) */
async function rescueCheck() {
let h; try { h = await dv.d.read(0, 16); } catch (e) { return; }
dv.rescue = String.fromCharCode(...h.subarray(0, 8)) !== 'SONIXDEV';
const st = await stashGet();
dv.stash = st && st.img && st.img.length === 0x1000000 ? st.img : null;
$('rescueResume').hidden = !dv.stash;
// a write that did not finish (cut before the device's table went off): the device starts, but go on anyway
const k = dv.rescue ? (dv.stash ? 'resModeGo' : 'resModeRom') : dv.stash ? 'resHalf' : '';
if (k) { devRender(t(k)); alert(t(k)); }
}
$('btnResume').onclick = () => devTask(async () => {
if (!dv.stash) return;
const r = await dv.d.write(dv.stash, { onlyChanged: true, keep: null, rescueApp: FL.embedded() }, devProg, () => dv.cancel);
await stashDel(); dv.rescue = false; dv.stash = null; $('rescueResume').hidden = true;
devRender(t('resResumed', { w: r.written }));
});
/* 1.6.13 test13: test of the rescue start on the device (only with #rettung in the address, see flash.js) */
$('rescueBox').hidden = !/rettung|rescue/.test(location.hash);
const RES_KEY = 'pmxRescueHdr';
$('btnRescueTest').onclick = () => { if (!confirm(t('resSure'))) return; devTask(async () => {
const hdr = await dv.d.rescueTest(FL.embedded(), devProg, () => dv.cancel);
try { localStorage.setItem(RES_KEY, Array.from(hdr, (b) => b.toString(16).padStart(2, '0')).join('')); } catch (e) {}
download(hdr, 'paradise-kopf-' + new Date().toISOString().slice(0, 10) + '.bin');
devRender(t('resCleared'));
}); };
$('btnRescueBack').onclick = () => devTask(async () => {
let h = null; try { h = localStorage.getItem(RES_KEY); } catch (e) {}
if (!h || h.length !== 0x2000) { devRender(t('resNoHdr')); return; }
const hdr = new Uint8Array(0x1000); for (let i = 0; i < 0x1000; i++) hdr[i] = parseInt(h.substr(2 * i, 2), 16);
await dv.d.rescueRestore(hdr, devProg, () => dv.cancel);
devRender(t('resBackDone'));
});
// ------------------------------------------------------------- save games
const SV = window.ParamixSaves;
const stamp = () => { const d = new Date(), z = (n) => String(n).padStart(2, '0'); return d.getFullYear() + z(d.getMonth() + 1) + z(d.getDate()) + '-' + z(d.getHours()) + z(d.getMinutes()); };
const edSlug = (id) => (FL.EDITIONS[id] || 'paradise').toLowerCase().replace(/ /g, '-');
function saveMsg(x) { return t('fl_' + x.code, x.p); }
function mainName(r) {
const ty = F.emuType(r);
if (ty === 't7') return E.t7XName(E.t7FromRom(r).rom);
if (ty === 't18') return E.extraName({ kind: 't18' });
if (ty === 'v1') { const v = E.v1FromRom(r); return v ? E.v1Name(v) : 'V1'; }
const c = romEmuCfg(r); if (c) return E.extraName({ kind: 'tama', dev: c.dev });
return '';
}
/* 1.6.8: an extra that is the same firmware as the main emulator only once */
function sameFw(a, b) {
// 1.6.8: colour Tamas by their code blocks (the rest of the flash holds the pet's own writes)
if (E.extraKind(a) === 'tama' && E.extraKind(b) === 'tama') {
if (a.dev !== b.dev) return false;
for (const k of [0, 1, 0x40, 0x41]) { const o = k << 16; if (o + 0x10000 > a.guest.length || o + 0x10000 > b.guest.length) continue; for (let i = o; i < o + 0x10000; i++) if (a.guest[i] !== b.guest[i]) return false; }
return true;
}
const ka = E.extraKind(a), kb = E.extraKind(b); if (ka !== kb) return false; const x = ka === 'tama' ? [a.guest, b.guest] : ka === 't18' ? [a.fw, b.fw] : [a.rom, b.rom]; if (!x[0] || !x[1]) return false; const [p0, p1] = x[0].length <= x[1].length ? x : [x[1], x[0]]; for (let i = 0; i < p0.length; i += 4093) if (p0[i] !== p1[i]) return false; for (let i = 0; i < p0.length; i++) if (p0[i] !== p1[i]) return false; for (let i = p0.length; i < p1.length; i++) if (p1[i] !== 0xFF) return false; return true;
}
function extrasDedupe(mainX) {
const mainE = mainX || emuX(state.emu);
if (mainE && state.extras && state.extras.some((x) => sameFw(x, mainE))) { state.extras = state.extras.filter((x) => !sameFw(x, mainE)); state.extrasDirty = true; }
// the same firmware twice in the menu: once is enough (it would share nothing, only take room)
const xs = state.extras || [], keep = xs.filter((x, i) => !xs.slice(0, i).some((y) => sameFw(x, y)));
if (keep.length !== xs.length) { state.extras = keep; state.extrasDirty = true; }
}
/* 1.6.8: does the device hold the same emulator firmware (layout and data) as the image? */
/* 1.6.8: the sectors the Studio changed against the loaded ROM (download items in an emulator's firmware) */
const rd32 = (b, o) => (b[o] | b[o + 1] << 8 | b[o + 2] << 16 | b[o + 3] << 24) >>> 0;
function studioSecs(a, b) {
const out = new Set(), n = Math.max(a.length, b.length);
for (let s = 0; s < n; s += 0x1000) {
if (s + 0x1000 > a.length || s + 0x1000 > b.length) { out.add(s); continue; }
for (let i = s; i < s + 0x1000; i++) if (a[i] !== b[i]) { out.add(s); break; }
}
return out;
}
async function emuSameDev(d, img, m) {
const p = await d.read(0xA0000, 0x1000), u = (b, o) => (b[o] | b[o + 1] << 8 | b[o + 2] << 16 | b[o + 3] << 24) >>> 0;
const eq = (a, z) => { for (let i = a; i < z; i++) if (p[i] !== img[0xA0000 + i]) return false; return true; };
const crcEq = async (a, n) => n > 0 && a + n <= img.length && (await d.crc(a, n)) === FL.crc32(img, a, n);
// TamaEmu: layout and block map, and the code blocks at the reset vector (the guest writes into other blocks
// of its flash, those are kept from the device anyway)
if (m === 0x43584D50) {
if (!eq(0x148, 0x140 + 156)) return false;
const rv = u(img, 0xA0140 + 20) === 0 ? 0 : 0x40, g = u(img, 0xA0148);
for (const b of [rv, rv + 1]) { const k = img[0xA0140 + 24 + b]; if (k !== 0xFF && !(await crcEq(g + k * 0x10000, 0x10000))) return false; }
return true;
}
if (m === 0x37584D50) return eq(0x148, 0x140 + 24 + 16 * 24) && crcEq(u(img, 0xA0148), u(img, 0xA014C));
if (m === 0x31584D50) return eq(0x148, 0x154) && crcEq(u(img, 0xA0148), u(img, 0xA014C)); // V1Emu: ROM and its place // T7Emu: ROM, figures
if (m === 0x38584D50) { // T18Emu: block map and blocks
if (!eq(0x14C, 0x140 + 400)) return false;
const b0 = img[0xA0150] | img[0xA0151] << 8; // the firmware's first block (code; it writes its save elsewhere)
return b0 === 0xFFFF || crcEq(b0 << 16, 0x10000);
}
return false;
}
function romEmuCfg(rom) { return F.appKind(rom) === 2 && F.emuType(rom) === 'tama' ? SV.emuCfg(rom.subarray(0xA0000, 0xA1000)) : null; }
function romT7(rom) { return F.emuType(rom) === 't7'; }
/* Further T7Emus of the loaded ROM (1.6.0): [{ name, saveOff }] */
function romExtras(rom) { const fe = F.embedded(); return fe ? E.appsRead(rom, F.feldApps(rom, fe.stub).apps) : []; }
/* Which T7Emu the save buttons are for: -1 the main one, otherwise the further one with this index */
/* 1.6.8: every program with a save, the main one ('m') and the ones in the menu (index in romExtras) */
/* 1.6.11 test2: every kind has an export and import: T18Emu the firmware with its save (as the T18Emu app), Game Boy and
* Master System the cartridge RAM (.sav as other emulators), Wolf3D its saved game */
const SAVE_KINDS = new Set(['tama', 't7', 'v1', 't18', 'gb', 'sms', 'pm', 'ab', 'wolf']);
function saveExt(k) { return k === 'tama' || k === 'gb' || k === 'sms' ? '.sav' : k === 'pm' || k === 'ab' ? '.eep' : '.bin'; }
function savePrograms() {
const rom = state.ctx.rom, out = [];
if (emuInstalled()) { const ty = F.emuType(rom); if (SAVE_KINDS.has(ty)) out.push({ key: 'm', kind: ty, name: mainName(rom) || 'EMU', saveOff: 0xC0000, off: 0xA0000 }); }
romExtras(rom).forEach((x, i) => { const k = E.extraKind(x); if (SAVE_KINDS.has(k)) out.push({ key: i, kind: k, name: x.name, saveOff: x.saveOff, off: x.off }); });
return out;
}
/* Game Boy: the size of the cartridge RAM from the header (as Peanut-GB; MBC2 512 bytes), at most 32 KB */
function gbSaveLen(r) { if (!r || r.length < 0x150) return 0; if (r[0x147] === 5 || r[0x147] === 6) return 0x200; return Math.min([0, 0x800, 0x2000, 0x8000, 0x20000, 0x10000][r[0x149]] || 0, 0x8000); }
/* Master System: 32 KB cartridge RAM; 8 KB when the rest was never written */
function smsSaveLen(sv) { for (let i = 0x3000; i < 0x9000; i++) if (sv[i] !== 0xFF) return 0x8000; return 0x2000; }
/* an extra of state.extras for a program of the loaded ROM (same kind and place in the list of its kind) */
function extraFor(p) {
const xs = romExtras(state.ctx.rom), x0 = xs[p.key]; if (!x0) return null;
const same = (a, b) => a && b && a.length === b.length && a.every((v, i) => v === b[i]);
if (x0.kind === 'gb' || x0.kind === 'sms' || x0.kind === 'pm' || x0.kind === 'ab') return (state.extras || []).find((y) => y.kind === x0.kind && same(y.rom, x0.rom)) || null;
const k = E.extraKind(x0), nth = xs.slice(0, p.key).filter((y) => E.extraKind(y) === k && (k !== 'wolf' || E.wolfSod(y.pack) === E.wolfSod(x0.pack))).length;
return (state.extras || []).filter((y) => E.extraKind(y) === k && (k !== 'wolf' || E.wolfSod(y.pack) === E.wolfSod(x0.pack)))[nth] || null;
}
function saveFor() { const v = $('saveFor').value; return v === 'm' || v === '' || v === undefined ? -1 : +v; }
function saveProg() { const v = $('saveFor').value; return savePrograms().find((p) => String(p.key) === v) || null; }
function renderSave() {
if (!state.ctx) return;
const ps = savePrograms(), sel = $('saveFor'), cur = sel.value;
sel.innerHTML = '';
for (const p of ps) { const o = document.createElement('option'); o.value = String(p.key); o.textContent = p.name + (p.key === 'm' ? ' (' + t('progIsMain') + ')' : ''); sel.appendChild(o); }
if ([...sel.options].some((o) => o.value === cur)) sel.value = cur;
$('saveForRow').hidden = !ps.length;
const p = saveProg(), f = !p ? '.sav / .bin' : saveExt(p.kind);
$('btnEmuOut').textContent = t('saveBtnOut', { f }); $('btnEmuIn').textContent = t('saveBtnIn', { f });
$('btnEmuOut').disabled = !p; $('btnEmuIn').disabled = false; $('btnEmuOut').title = '';
$('saveStat').textContent = !p ? t('saveNoProg') : t('saveProgInfo');
let con = false; try { con = !!dv.d && !dv.run; } catch (e) {}
$('btnParaIn').disabled = !con;
// 1.6.8: which save (the menu keeps several)
const ss = paraSlots(), sl = $('paraSlot'), sc = sl.value;
sl.innerHTML = '';
$('paraSlotRow').hidden = !ss;
if (ss) {
const add = (v, txt) => { const o = document.createElement('option'); o.value = v; o.textContent = txt; sl.appendChild(o); };
if (ss.live < 0) add('live', t('slotLive', { n: F.fieldNow(state.ctx.rom) }));
for (const x of ss.list) add(x.i === ss.live ? 'live' : String(x.i), x.i === ss.live ? t('slotLive', { n: slotLabel(ss, x.i) }) : x.used ? slotLabel(ss, x.i) : t('slotEmpty', { n: slotLabel(ss, x.i) }));
if ([...sl.options].some((o) => o.value === sc)) sl.value = sc;
}
}
function paraSlots() { const fe = F.embedded(); try { return state.ctx && fe ? F.saveSlots(state.ctx.rom, fe.stub) : null; } catch (e) { return null; } }
function slotLabel(ss, i) { return ss.saves ? t('saveSlot', { n: i + 1 }) : (F.fieldNames(state.ctx.rom)[i] || t('saveSlot', { n: i + 1 })); }
function paraSlotPick() { return $('paraSlotRow').hidden ? 'live' : $('paraSlot').value; }
function t7SaveOutSel() {
const p = saveProg(); if (!p || p.kind !== 't7') return null;
return p.key === 'm' ? SV.t7SaveOut(state.ctx.rom) : SV.t7SaveOut(state.ctx.rom, p.saveOff);
}
$('saveFor').onchange = () => renderSave();
let g_slotIn = 'live';
$('btnParaIn').onclick = () => { g_slotIn = paraSlotPick(); $('fileSave').value = ''; $('fileSave').click(); };
$('btnEmuIn').onclick = () => $('fileEmuSav').click();
/* test23 SAVE_PICK: a save file goes to the program of its kind, whatever the list shows (with T7Emu in the menu and
* another program chosen the import said "T7Emu has to be in the ROM"), also to an emulator added but not yet saved.
* T18Emu: also the save of the T18Emu app (flash from 0x570000 or 0x5E0000, or its .zip with flash.bin). */
const SAVE_PICK = true;
const T18_PART = [[0x290000, 0, 0x570000], [0x220000, 0, 0x5E0000], [0x220010, 16, 0x5E0000]];
async function t18Part(g) {
for (const [n, skip, at] of T18_PART) if (g.length === n) return { data: g.subarray(skip), at };
if (g.length > 22 && g[0] === 0x50 && g[1] === 0x4B) {
try { const z = await C.zipRead(g, inflateRaw); const fl = z.find((x) => x.name === 'flash.bin' && x.data.length === 0x800000); if (fl) return { data: fl.data.subarray(0x570000), at: 0x570000 }; } catch (err) {}
}
return null;
}
function saveKindOf(g) {
if (SV.t7SaveCheck(g)) return 't7';
if (E.t18Detect(g)) return 't18';
if (g.length === 0x400000 || g.length === 0x800000 || g.length === 0x7FF800) { try { return { tama: E.emuDetect(g) }; } catch (err) {} }
return null;
}
function progDev(p) {
const rom = state.ctx.rom;
if (p.key === 'm') { const c = romEmuCfg(rom); return c && c.dev; }
const c = SV.emuCfg(rom.subarray(p.off, p.off + 0x1000)); return c && c.dev;
}
$('fileEmuSav').onchange = async (e) => {
const f = e.target.files[0]; e.target.value = ''; if (!f) return;
let g = new Uint8Array(await f.arrayBuffer()), p = saveProg();
let part = null;
if (SAVE_PICK) {
let k = saveKindOf(g), dev = null;
if (!k && (part = await t18Part(g))) k = 't18';
if (k && k.tama) { dev = k.tama; k = 'tama'; }
if (k && !(p && p.kind === k && (k !== 'tama' || progDev(p) === dev))) {
const q = savePrograms().filter((x) => x.kind === k && (k !== 'tama' || progDev(x) === dev));
if (q.length) { p = q[0]; $('saveFor').value = String(p.key); }
else if (k === 't7' && state.emu && state.emu.t7) p = null; // added, not saved yet: the main program
else if (k === 't18' && state.emu && state.emu.t18) p = { key: 'm', kind: 't18', name: 'T18Emu', pend: true };
}
if (part && (!p || p.kind !== 't18')) { toast(t('saveT18Need'), true); return; }
}
// 1.6.11 test2: Game Boy, Master System (cartridge RAM), Wolf3D (its saved game), T18Emu (firmware with its save)
if (p && p.kind === 'ab') { // 1.7.3: the Arduboy's EEPROM (1 KB, .eep); the kept game state goes
const x = extraFor(p); if (!x) { toast(t('saveEmuBad'), true); return; }
if (g.length !== 0x400) { toast(t('saveWrongFile', { n: p.name }), true); return; }
const sv = new Uint8Array(E.AB_SAVE).fill(0xFF); if (x.save && x.save.length) sv.set(x.save.subarray(0, 0x1000));
sv.set(g, 0x1000); x.save = sv; state.extrasDirty = true; renderEmu(); renderPlan();
$('saveStat').textContent = t('saveCartIn', { n: p.name }); return;
}
if (p && p.kind === 'pm') { // 1.7.3: the EEPROM (8 KB, .eep as PokeMini keeps it); the kept game state goes
const x = extraFor(p); if (!x) { toast(t('saveEmuBad'), true); return; }
if (g.length !== 0x2000) { toast(t('saveWrongFile', { n: p.name }), true); return; }
const sv = new Uint8Array(E.PM_BIOS_AT).fill(0xFF); if (x.save && x.save.length) sv.set(x.save.subarray(0, 0x1000));
sv.set(g, 0x1000); x.save = sv; state.extrasDirty = true; renderEmu(); renderPlan();
$('saveStat').textContent = t('saveCartIn', { n: p.name }); return;
}
if (p && (p.kind === 'gb' || p.kind === 'sms' || p.kind === 'wolf')) {
const x = extraFor(p); if (!x) { toast(t('saveEmuBad'), true); return; }
const sv = new Uint8Array(0x10000).fill(0xFF); if (x.save && x.save.length) sv.set(x.save.subarray(0, 0x10000));
if (p.kind === 'wolf') {
if (g.length !== 0x10000 || (g[0x1000] | g[0x1001] << 8 | g[0x1002] << 16 | g[0x1003] << 24) >>> 0 !== 0x56533357) { toast(t('saveWrongFile', { n: p.name }), true); return; }
sv.set(g.subarray(0x1000), 0x1000);
} else {
const n = p.kind === 'gb' ? gbSaveLen(x.rom) : Math.min(g.length, 0x8000);
if (!n) { toast(t('saveNoBatt'), true); return; }
if (g.length < n || g.length > 0x20000 + 64) { toast(t('saveWrongFile', { n: p.name }), true); return; }
sv.fill(0xFF, 0x1000, 0x10000); sv.set(g.subarray(0, n), 0x1000); // the kept game state (behind the RAM) goes
}
x.save = sv; state.extrasDirty = true; renderEmu(); renderPlan();
$('saveStat').textContent = t('saveCartIn', { n: p.name }); return;
}
if (p && p.kind === 't18') {
if (SAVE_PICK && part) { // the T18Emu app's save: into the firmware the ROM has (or the one just added)
const x0 = p.key === 'm' ? null : extraFor(p);
const fw0 = p.key === 'm' ? (state.emu && state.emu.t18 ? state.emu.rom : E.t18FromRom(state.ctx.rom)) : x0 && (x0.fw || E.t18FromRom(state.ctx.rom, p.off));
if (!fw0) { toast(t('saveT18Need'), true); return; }
const fw = new Uint8Array(fw0); fw.set(part.data.subarray(0, 0x800000 - part.at), part.at); g = fw;
}
if (!E.t18Detect(g)) { toast(t('saveWrongFile', { n: p.name }), true); return; }
const undo = { emu: state.emu, rem: state.emuRemove, x: null };
if (p.key === 'm') { let n = 0; for (let i = 0; i < 128; i++) if (!g.subarray(i << 16, (i + 1) << 16).every((v) => v === 0xFF)) n++; state.emu = { t18: true, dev: 't18', rom: g, size: n << 16 }; emuRemoveClear(); }
else { const x = extraFor(p); if (!x) { toast(t('saveEmuBad'), true); return; } undo.x = [x, x.fw, x.keepOff, x.saveImp]; x.fw = g; delete x.keepOff; x.saveImp = true; state.extrasDirty = true; }
// does it fit? (a saved firmware may use more blocks than the fresh one) a trial build right away
const err = await busy(async () => { toast.mute = {}; try { await composeRom(); } catch (e) { toast.mute.err = toast.mute.err || em(e); } const m = toast.mute.err; toast.mute = null; return m; });
if (err) {
state.emu = undo.emu; state.emuRemove = undo.rem;
if (undo.x) { const [x, fw, ko, si] = undo.x; x.fw = fw; if (ko !== undefined) x.keepOff = ko; if (!si) delete x.saveImp; }
renderEmu(); toast(err, true); return;
}
renderEmu(); renderPlan();
$('saveStat').textContent = t('t7SaveXDone', { n: p.name }); return;
}
if (SV.t7SaveCheck(g)) {
if (p && p.kind === 't7' && p.key !== 'm') { state.t7saveX = { i: p.key, save: g }; renderPlan(); $('saveStat').textContent = t('t7SaveXDone', { n: p.name }); return; }
if (!romT7(state.ctx.rom) && !(SAVE_PICK && state.emu && state.emu.t7)) { toast(t('t7SaveNeed'), true); return; }
state.t7save = g; renderPlan();
$('saveStat').textContent = t('t7SaveInDone');
return;
}
// V1Emu: session and settings (8 KB, "V1ST" at the start or an empty session)
if (g.length === 0x2000 && p && p.kind === 'v1') {
state.saveIn = { key: p.key, kind: 'v1', data: g }; renderPlan();
$('saveStat').textContent = t('t7SaveXDone', { n: p.name }); return;
}
let dev, pk;
try { dev = E.emuDetect(g); pk = E.packMain(g, dev); } catch (err) { toast(t('saveEmuBad'), true); return; }
// a colour Tama in the menu: its firmware with the save replaces the one in the ROM
if (p && p.kind === 'tama' && p.key !== 'm') {
const x = (state.extras || [])[p.key];
if (!x || x.kind !== 'tama' || x.dev !== dev) { toast(t('saveEmuBad'), true); return; }
x.guest = g; state.extrasDirty = true; state.saveIn = { key: p.key, kind: 'tama' }; renderEmu();
$('saveStat').textContent = t('t7SaveXDone', { n: p.name }); return;
}
if (!appRoom()) { toast(t('saveNoRoom'), true); return; }
const cfg = romEmuCfg(state.ctx.rom), was = state.emu ? state.emu.dev : cfg && cfg.dev;
if (was && was !== dev && !confirm(t('saveEmuOther', { a: E.DEVICES[was].label, b: E.DEVICES[dev].label }))) return;
state.emu = { guest: g, dev, size: pk.blob.length, big: pk.big }; emuRemoveClear(); if (!state.launch) state.doom = null;
state.saveIn = { key: 'm', kind: 'tama' };
renderDoom(); renderEmu();
$('saveStat').textContent = t('saveEmuInDone', { d: E.DEVICES[dev].label });
};
/* Change a Paradise save (1.6.8): level, character, care. Names come from the loaded ROM. */
let petSave = null, petName = '';
$('btnPetOpen').onclick = () => { $('filePet').value = ''; $('filePet').click(); };
$('filePet').onchange = async (e) => {
const f = e.target.files[0]; if (!f || !state.ctx) return;
let save; try { save = SV.paraDecode(new Uint8Array(await f.arrayBuffer())); } catch (err) { toast(em(err), true); return; }
petOpen(save, f.name, false);
};
/* 1.6.8: the save of the loaded ROM itself; the change goes back into the ROM */
$('btnPetRom').onclick = () => {
if (!state.ctx) return;
const ed = state.ctx.editionId;
petOpen({ stamp: 0, counter: 0, alarm: 0, status: 0, regs: [], pages: SV.paraFromImage(state.ctx.rom, ed), edition: ed }, '', true);
};
$('btnPetClose').onclick = () => { petSave = null; $('petRow').hidden = true; $('petStat').textContent = ''; };
let petFromRom = false;
function petOpen(save, name, fromRom) {
const ed = save.edition || state.ctx.editionId;
if (SV.family(ed) !== SV.family(state.ctx.editionId)) { toast(t('petOther'), true); return; }
const pet = SV.paraPet(save, ed);
if (!pet) { toast(t('petNoSet'), true); return; }
petSave = save; petSave.edition = ed; petName = name; petFromRom = fromRom;
const lv = $('petLevel'); lv.innerHTML = '';
for (let i = 0; i <= 10; i++) { const o = document.createElement('option'); o.value = i; o.textContent = i; if (i === pet.level) o.selected = true; lv.appendChild(o); }
const sel = $('petChar'); sel.innerHTML = '';
const keep = document.createElement('option'); keep.value = ''; keep.textContent = t('petKeep'); sel.appendChild(keep);
const chars = F.characters(state.ctx.rom, lang), fn = F.fieldNames(state.ctx.rom).map(fieldLabel);
let cur = chars.find(c=>c.id===pet.id)?.name || '';
for (const [st, k] of [[3, 'petKid'], [4, 'petYoung'], [5, 'petAdult']]) {
const g = document.createElement('optgroup'); g.label = t(k);
for (const c of chars.filter((x) => x.stage === st)) {
const o = document.createElement('option'); o.value = c.id + ':' + c.stage;
const nm = c.name.charAt(0) + c.name.slice(1).toLowerCase();
o.textContent = nm + (c.field >= 0 && fn[c.field] ? ' (' + fn[c.field] + ')' : '');
if (c.id === pet.id) cur = nm;
g.appendChild(o);
}
sel.appendChild(g);
}
$('petStage').value='';$('petHunger').value=pet.hunger;$('petHappy').value=pet.happy;$('petHealth').value=pet.sick?'keep':'0';
$('petCare').checked = false;
$('petRow').hidden = false;
$('petStat').textContent = t('petNow', { l: pet.level, c: cur || pet.id, h: pet.hunger, j: pet.happy, s: pet.sick ? t('petSick') : '' });
}
$('petStage').onchange=()=>{const stage=$('petStage').value;$('petChar').value='';[...$('petChar').options].forEach(o=>{o.hidden=!!stage&&!!o.value&&!o.value.endsWith(':'+stage);});};
$('btnPetSave').onclick = () => {
if (!petSave) return;
const ed = petSave.edition, pet = SV.paraPet(petSave, ed), ch = {};
const lv = +$('petLevel').value; if (lv !== pet.level) ch.level = lv;
const v = $('petChar').value; if (v) { const [id, st] = v.split(':').map(Number); if (id !== pet.id || st !== pet.stage) { ch.id = id; ch.stage = st; } }
for(const [key,id]of [['hunger','petHunger'],['happy','petHappy']]){const v=Number($(id).value);if(!$(id).checkValidity()){ $(id).reportValidity();return;}if(v!==pet[key])ch[key]=v;}
if($('petHealth').value==='0' && pet.sick)ch.sick=0;
if(ch.id){const def=C.charTable(state.ctx.files[0]).find(c=>c.id===ch.id);if(def)ch.koreanName=C.textGet(state.ctx.rom,def.name,'ko');}
if ($('petCare').checked) ch.care = true;
if (!Object.keys(ch).length) { toast(t('petNothing')); return; }
if (petFromRom) {
const nw = SV.paraPetSet(petSave, ed, ch), r = new Uint8Array(state.ctx.rom);
for (const [a, d] of nw.pages) if (d.length === 0x1000) r.set(d, a);
if(!state.petChanges)state.petOriginalId=pet.id;state.petChanges={...state.petChanges,...ch};
state.ctx.rom = r; state.petDirty = true; petSave = nw; petSave.edition = ed;
$('petStat').textContent = t('petRomDone'); renderPlan(); return;
}
const out = SV.paraWrite(SV.paraPetSet(petSave, ed, ch), ed);
const name = petName.replace(/\.tamasave$/i, '') + '-' + stamp() + '.tamasave';
download(out, name);
$('petStat').textContent = t('petDone', { n: name });
};
$('btnParaOut').onclick = () => busy(async () => {
const ed = state.ctx.editionId, v = paraSlotPick(), rom = state.ctx.rom;
let pages = SV.paraFromImage(rom, ed), tag = '';
if (v !== 'live') { // 1.6.8: a save the menu keeps in a slot
const ss = paraSlots(), i = +v, sv = ss && await F.slotReadAsync((a, n) => rom.subarray(a, a + n), ss.f, i);
if (!sv) { toast(t('slotNone'), true); return; }
const [a, b] = SV.region(ed), got = F.slotPages(sv);
pages = new Map(); for (let p = a; p < b; p += 0x1000) pages.set(p, got.get(p) || new Uint8Array(0x1000).fill(0xFF));
tag = '-' + slotLabel(ss, i).toLowerCase().replace(/[^a-z0-9]+/g, '');
}
const name = edSlug(ed) + tag + '-' + stamp() + '.tamasave';
download(SV.paraEncode(pages, ed, null), name);
$('saveStat').textContent = t('saveNoClock', { n: name });
});
$('btnEmuOut').onclick = () => busy(async () => {
const p = saveProg(); if (!p) { toast(t('saveNoEmu'), true); return; }
const rom = state.ctx.rom, slug = p.name.toLowerCase().replace(/[^a-z0-9]+/g, '-');
if (p.kind === 't7') {
const sv = t7SaveOutSel(); if (!sv) { toast(t('t7NoSave'), true); return; }
const name = 't7emu-' + slug + '-' + stamp() + '-save.bin'; download(sv, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
if (p.kind === 'v1') {
const sv = rom.slice(p.saveOff, p.saveOff + 0x2000);
if (sv.subarray(0, 0x1000).every((v) => v === 0xFF)) { toast(t('t7NoSave'), true); return; }
const name = 'v1emu-' + slug + '-' + stamp() + '-save.bin'; download(sv, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
if (p.kind === 'tama') {
const cfg = p.key === 'm' ? romEmuCfg(rom) : SV.emuCfg(rom.subarray(p.off, p.off + 0x1000)); if (!cfg) { toast(t('saveNoEmu'), true); return; }
const g = await SV.emuGuestAsync((a, n) => rom.subarray(a, a + n), cfg);
const name = cfg.app + '-' + (p.key === 'm' ? '' : slug + '-') + stamp() + '.sav';
download(g, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
const slug2 = (k) => k + '-' + slug + '-' + stamp();
if (p.kind === 't18') {
const fw = p.key === 'm' ? E.t18FromRom(rom) : E.t18FromRom(rom, p.off); if (!fw) { toast(t('saveNone'), true); return; }
const name = 't18emu-' + stamp() + '-save.bin'; download(fw, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
if (p.kind === 'ab') {
const x = romExtras(rom)[p.key], sv = x && x.save;
if (!sv || sv.length < 0x1400) { toast(t('saveNone'), true); return; }
const out = sv.slice(0x1000, 0x1400); if (out.every((v) => v === 0xFF)) { toast(t('saveNone'), true); return; }
const name = slug + '-' + stamp() + '.eep'; download(out, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
if (p.kind === 'pm') {
const x = romExtras(rom)[p.key], sv = x && x.save;
if (!sv || sv.length < 0x3000) { toast(t('saveNone'), true); return; }
const out = sv.slice(0x1000, 0x3000); if (out.every((v) => v === 0xFF)) { toast(t('saveNone'), true); return; }
const name = slug + '-' + stamp() + '.eep'; download(out, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
if (p.kind === 'gb' || p.kind === 'sms' || p.kind === 'wolf') {
const x = romExtras(rom)[p.key], sv = x && x.save;
if (!sv) { toast(t('saveNone'), true); return; }
let out, name;
if (p.kind === 'wolf') { if ((sv[0x1000] | sv[0x1001] << 8 | sv[0x1002] << 16 | sv[0x1003] << 24) >>> 0 !== 0x56533357) { toast(t('saveNone'), true); return; } out = sv.slice(0, 0x10000); name = slug2(E.wolfSod(x.pack) ? 'sod' : 'wolf3d') + '-save.bin'; }
else {
const n = p.kind === 'gb' ? gbSaveLen(x.rom) : smsSaveLen(sv);
if (!n) { toast(t('saveNoBatt'), true); return; }
out = sv.slice(0x1000, 0x1000 + n);
if (out.every((v) => v === 0xFF)) { toast(t('saveNone'), true); return; }
name = slug + '-' + stamp() + '.sav';
}
download(out, name);
$('saveStat').textContent = t('saveDone', { n: name }); return;
}
toast(t('saveEmuBad'), true);
});
/* From the device: Paradise save with its clock, and the TamaEmu save if the device has the emulator */
$('btnSaveRead').onclick = () => devTask(async () => {
const d = dv.d, ed = d.info.edition, [a, b] = SV.region(ed), cancel = () => dv.cancel;
const used = await d.usedSectors(a, b, devProg, cancel);
const pages = new Map(), ff = new Uint8Array(0x1000).fill(0xFF);
for (let p = a; p < b; p += 0x1000) pages.set(p, ff);
let n = 0;
for (const s of used) { if (cancel()) throw new Error('cancelled'); pages.set(s, await d.read(s, 0x1000)); devProg('read', ++n * 0x1000, used.length * 0x1000); }
const clock = await d.clockRead();
const names = [edSlug(ed) + '-' + stamp() + '.tamasave'];
await window.TamaArchive.deliver(SV.paraEncode(pages,ed,clock && (clock.ctrl & 0x80)?clock:null),names[0],download,msg=>{$('archiveStatus').textContent=msg;},'save');
if(!siteFeatures.emu){devRender(t('devSaveGot',{n:names.join(' · ')}));return;}
// TamaEmu on the device?
const sec = await d.read(0xA0000, 0x1000);
const kindDoom = (() => { for (let i = 0x140; i < 0x400; i += 4) if ((sec[i] | sec[i + 1] << 8 | sec[i + 2] << 16 | sec[i + 3] << 24) >>> 0 === 0x434D4450) return true; return false; })();
const cfg = kindDoom ? null : SV.emuCfg(sec);
if ((sec[0x140] | sec[0x141] << 8 | sec[0x142] << 16 | sec[0x143] << 24) >>> 0 === E.T7_MAGIC) {
// T7Emu: the pet's EEPROM (two slots) as save.bin of the T7Emu app
const part = new Uint8Array(SV.T7_EE + 0x4000);
part.set(await d.read(SV.T7_EE, 0x4000), SV.T7_EE);
const sv = SV.t7SaveOut(part);
if (sv) { names.push('t7emu-' + stamp() + '-save.bin'); await window.TamaArchive.deliver(sv,names[names.length-1],download,msg=>{$('archiveStatus').textContent=msg;},'aux'); }
}
// further T7Emus (1.6.0): where the loaded ROM has them, if the device has the same program there
if (state.ctx) for (const x of romExtras(state.ctx.rom)) {
const h = await d.read(x.off, 0x1000);
if ((h[0x140] | h[0x141] << 8 | h[0x142] << 16 | h[0x143] << 24) >>> 0 !== E.T7_MAGIC || (h[0x150] | h[0x151] << 8 | h[0x152] << 16 | h[0x153] << 24) >>> 0 !== x.saveOff) continue;
const part = new Uint8Array(x.saveOff + 0x5000);
part.set(await d.read(x.saveOff + 0x1000, 0x4000), x.saveOff + 0x1000);
const sv = SV.t7SaveOut(part, x.saveOff);
if (sv) { names.push('t7emu-' + x.name.toLowerCase() + '-' + stamp() + '-save.bin'); await window.TamaArchive.deliver(sv,names[names.length-1],download,msg=>{$('archiveStatus').textContent=msg;},'aux'); }
}
if (cfg) {
// read less: if the loaded ROM has the same firmware layout, only the sectors that differ
let base = null;
const rc = state.ctx && romEmuCfg(state.ctx.rom);
if (rc && rc.guestOff === cfg.guestOff && rc.guestSize === cfg.guestSize && rc.kind === cfg.kind && rc.map.every((v, i) => v === cfg.map[i])) {
const end = Math.max(cfg.spareEnd || 0, (cfg.guestOff + cfg.guestSize + 0xFFFF) & ~0xFFFF);
const diff = await d.changed(state.ctx.rom, devProg, cancel, cfg.guestOff & ~0xFFFF, Math.min(end, 0x1000000));
base = new Uint8Array(state.ctx.rom);
for (const s of diff) base.set(await d.read(s, 0x1000), s);
}
const read = base ? (x, k) => base.subarray(x, x + k) : (x, k) => d.read(x, k);
const g = await SV.emuGuestAsync(read, cfg, base ? null : devProg);
names.push(cfg.app + '-' + stamp() + '.sav');
await window.TamaArchive.deliver(g,names[names.length-1],download,msg=>{$('archiveStatus').textContent=msg;},'aux');
}
devRender(t('devSaveGot', { n: names.join(', ') }) + (clock ? '' : ' ' + t('devSaveClockNo')));
});
$('btnSaveWrite').onclick = () => { g_slotIn = 'live'; $('fileSave').value = ''; $('fileSave').click(); };
$('fileSave').onchange = async (e) => {
const f = e.target.files[0]; if (!f || !dv.d) return;
let save;
try { save = SV.paraDecode(new Uint8Array(await f.arrayBuffer())); } catch (err) { toast(em(err), true); return; }
const ed = dv.d.info.edition;
const chk = SV.paraCheck(save, ed);
chk.errors.forEach((x) => { if (x.p) { x.p.s = FL.EDITIONS[x.p.s] || x.p.s; x.p.d = FL.EDITIONS[x.p.d] || x.p.d; } });
if (chk.errors.length) { devRender(t('devErr', { e: chk.errors.map(saveMsg).join(', ') })); return; }
const warn = chk.warnings.map(saveMsg).join('\n');
if (g_slotIn !== 'live') { slotWrite(save, chk, +g_slotIn, warn); return; }
if (!confirm(t('devSaveSure', { ed: dv.d.info.name }) + (warn ? '\n\n' + warn : ''))) return;
devTask(async () => {
const d = dv.d, [a, b] = SV.region(ed);
// only pages that differ from the device
const img = new Uint8Array(0x1000000).fill(0xFF);
for (const [p, data] of chk.pages) img.set(data, p);
const diff = await d.changed(img, devProg, () => dv.cancel, a & ~0xFFFF, b);
const map = new Map();
for (const [p, data] of chk.pages) if (diff.has(p)) map.set(p, data);
const w = map.size ? await d.writeSectors(map, devProg, () => dv.cancel, FL.embedded()) : 0;
const v = SV.paraClock(save);
const cl = v !== null && await d.clockSet(v);
devRender(t('devSaveDone', { w, c: cl ? t('devSaveClock') : t('devSaveClockNo') }));
});
};
/* 1.6.8: a save into a slot of the menu on the device (packed like the menu does it, header page last) */
function slotWrite(save, chk, i, warn) {
const ss = paraSlots(), rom = state.ctx.rom, ed = dv.d.info.edition;
if (!ss) return;
if (!ss.saves) {
const set = chk.pages.get(0xEFE000), fi = F.fieldOfSettings(rom, set);
if (fi !== i) { devRender(t('devErr', { e: t('slotField', { a: F.fieldNames(rom)[fi] || '?', b: slotLabel(ss, i) }) })); return; }
}
if (!confirm(t('slotSure', { n: slotLabel(ss, i) }) + (warn ? '\n\n' + warn : ''))) return;
devTask(async () => {
const d = dv.d, f = ss.f, [a, b] = SV.region(ed);
const mine = rom.subarray(f.off + 0x140, f.off + 0x140 + 0x180), dev = (await d.read(f.off, 0x1000)).subarray(0x140, 0x140 + 0x180);
for (const o of [0, 8, 12, 16, 364, 368]) if (mine[o] !== dev[o] || mine[o + 1] !== dev[o + 1] || mine[o + 2] !== dev[o + 2] || mine[o + 3] !== dev[o + 3]) throw new Error(t('slotDevOther'));
const heads = [];
for (let j = 0; j < f.nslots; j++) heads.push(new Uint8Array(await d.read(F.slotAddr(f, j), 0x1000)));
const s = F.slotBuild(chk.pages, i, a, b), img = new Uint8Array(0x1000000).fill(0xFF);
const written = F.slotPlace(img, f, i, s, F.poolUsed(f, heads, i));
const first = new Map([[written[0], new Uint8Array(0x1000).fill(0xFF)]]);
for (const p of written.slice(1)) first.set(p, img.slice(p, p + 0x1000));
let w = await d.writeSectors(first, devProg, () => dv.cancel, FL.embedded());
w += await d.writeSectors(new Map([[written[0], img.slice(written[0], written[0] + 0x1000)]]), devProg, () => dv.cancel, FL.embedded());
devRender(t('slotDone', { n: slotLabel(ss, i) }));
});
}
window.addEventListener('beforeunload', (e) => { if (window.TamaArchive.hasPending() || (state.ctx && state.changed.size && state.saved !== state.changed.size)) { e.preventDefault(); e.returnValue = t('leave'); } });
applyLang(); devRender();
window.__paramix = state; // for tests
})();