Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>The Trivia Monster Converter</title>
- </head>
- <body style="width: 50em; margin: 2em;">
- <noscript style="color: red;"><strong>Attention:</strong> The converter
- needs JavaScript enabled.</noscript>
- <h1>The Trivia Monster Converter</h1>
- <p>Converter for question files of the game „The Trivia Monster“ by Paul
- Norman, published 1984 by Cosmi, for the C64.</p>
- <p>The program displays general hints for the answers while loading the main
- program:</p>
- <pre>
- HINTS FOR ANSWERING QUESTIONS:
- DO NOT USE 'THE' IN YOUR ANSWERS
- UNLESS IT IS A BOOK OR FILM TITLE.
- SPELL ALL NUMBER ANSWERS AND HYPHENATE
- TWO-DIGIT NUMBERS. UNLESS OTHERWISE
- INDICATED BY (NO.)
- USE FULL NAMES AS COMMONLY KNOWN
- UNLESS THE QUESTION ASKS FOR (LST.NM)
- OR IF ONLY LAST NAMES ARE IN USED TRIVIA
- </pre>
- <p>So it makes sense to write the questions and answers accordingly.</p>
- <h2>Example of an entry</h2>
- <pre>
- 2AWHAT IS THE BEST, MOST SELLING HOME
- COMPUTER OF ALL TIMES?
- COMMODORE SIXTY-FOUR
- </pre>
- <p>Lines are max. 40 characters long. Three lines per entry.</p>
- <p><code>2</code> is the category. Followed by a character between
- <code>A</code> and <code>C</code> which I don't know the meaning of yet.
- Then follows the question in the first two lines. And finally the answer in
- the last line.</p>
- <p>Each file has 135 entries with three lines each = 135·3 =
- 405 lines in total.</p>
- <h2>Categories</h2>
- <p>
- <ol>
- <li>Science</li>
- <li>History</li>
- <li>Sports</li>
- <li>Grabbag</li>
- <li>The Arts</li>
- <li>Showbizz</li>
- </ol>
- </p>
- <h2>Converter</h2>
- <p>Enter/copy 405 lines of ASCII text in the expected format. Upper or
- lower case doesn't matter, it ends up being upper case after the
- conversion.</p>
- <p>
- <textarea id="text" cols="40" rows="25" placeholder="Questions and Answers…">
- </textarea>
- <button onclick="convert()">Convert</button>
- </p>
- <hr>
- <small>Version 0.1 • © 2026 by BlackJack/Civitas • HTML5
- & Vanilla JS</small>
- <script>
- const START_ADDRESS = 0x6000;
- const END_ADDRESS = 0x9F80;
- const ENTRY_COUNT = 135;
- const LINES_PER_ENTRY = 3;
- const LINE_COUNT = ENTRY_COUNT * LINES_PER_ENTRY;
- function convert() {
- let lines = document.getElementById("text").value.trim().split("\n");
- if (lines.length != LINE_COUNT) {
- alert(`Expected ${LINE_COUNT} lines, got ${lines.length} instead!`);
- return;
- }
- for (let i = 0; i < lines.length; i += 3) {
- const line = lines[i];
- const category = line[0];
- if (category < 1 || category > 6) {
- alert(`Line ${i + 1}: Unexpected category: ${category}!`);
- return;
- }
- // TODO: Check unkown second character.
- }
- lines = lines.map((line) => line.trim());
- for (let i = 0; i < lines.length; i++) {
- const line = lines[i];
- if (line.length > 40) {
- alert(`Line ${i + 1}: length limit exceeded: ${line.length}.`);
- return;
- }
- }
- const data = (new Uint8Array(END_ADDRESS - START_ADDRESS + 2)).fill(32);
- data[0] = START_ADDRESS % 256;
- data[1] = Math.floor(START_ADDRESS / 256);
- const encoder = new TextEncoder();
- for (let i = 0; i < lines.length; i++) {
- const line = encoder.encode(lines[i]);
- for (let j = 0; j < line.length; j++) {
- let value = line[j];
- if (value >= 128) {
- alert(`Line ${i + 1}: character outside ASCII.`);
- return;
- } else if (value >= 96) {
- value -= 96;
- } else if (value >= 64) {
- value -= 64;
- }
- line[j] = value;
- }
- data.set(line, 2 + i * 40);
- }
- const blob = new Blob([data], { type: "application/octet-stream" });
- const url = URL.createObjectURL(blob);
- const link = document.createElement("a");
- link.href = url;
- link.download = "1prg";
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- URL.revokeObjectURL(url);
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment