From b0686637292a966ae68490f63bddc77df1cf199a Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Sun, 30 Dec 2018 18:54:45 +0100 Subject: [PATCH] PET: Add oldpet and origpet encodings --- docs/lang/text.md | 6 ++- include/pet.ini | 2 + include/pet_kernal.mfk | 6 ++- .../scala/millfork/parser/TextCodec.scala | 46 +++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/docs/lang/text.md b/docs/lang/text.md index cb06a22d..d83a36aa 100644 --- a/docs/lang/text.md +++ b/docs/lang/text.md @@ -11,7 +11,11 @@ * `ascii` – standard ASCII -* `pet` or `petscii` – PETSCII (ASCII-like character set used by Commodore machines) +* `pet` or `petscii` – PETSCII (ASCII-like character set used by Commodore machines from VIC-20 onward) + +* `origpet` or `origpetscii` – old PETSCII (Commodore PET with original ROMs) + +* `oldpet` or `oldpetscii` – old PETSCII (Commodore PET with newer ROMs) * `cbmscr` or `petscr` – Commodore screencodes diff --git a/include/pet.ini b/include/pet.ini index fb5175fe..f39b40a2 100644 --- a/include/pet.ini +++ b/include/pet.ini @@ -1,5 +1,7 @@ [compilation] arch=nmos +encoding=oldpetscii +screen_encoding=petscr modules=loader_0401,pet_kernal,default_panic diff --git a/include/pet_kernal.mfk b/include/pet_kernal.mfk index 40ceb4e3..cedc40bf 100644 --- a/include/pet_kernal.mfk +++ b/include/pet_kernal.mfk @@ -6,4 +6,8 @@ // CHROUT. Write byte to default output. (If not screen, must call OPEN and CHKOUT beforehands.) // Input: A = Byte to write. -asm void putchar(byte a) @$FFD2 extern \ No newline at end of file +asm void putchar(byte a) @$FFD2 extern + +inline void new_line() { + putchar(13) +} diff --git a/src/main/scala/millfork/parser/TextCodec.scala b/src/main/scala/millfork/parser/TextCodec.scala index 8839c0c2..84527940 100644 --- a/src/main/scala/millfork/parser/TextCodec.scala +++ b/src/main/scala/millfork/parser/TextCodec.scala @@ -131,6 +131,10 @@ object TextCodec { case (_, "ascii") => TextCodec.Ascii case (_, "petscii") => TextCodec.Petscii case (_, "pet") => TextCodec.Petscii + case (_, "oldpetscii") => TextCodec.OldPetscii + case (_, "oldpet") => TextCodec.OldPetscii + case (_, "origpetscii") => TextCodec.OriginalPetscii + case (_, "origpet") => TextCodec.OriginalPetscii case (_, "cbmscr") => TextCodec.CbmScreencodes case (_, "petscr") => TextCodec.CbmScreencodes case (_, "atascii") => TextCodec.Atascii @@ -294,6 +298,48 @@ object TextCodec { ) ) + val OldPetscii = new TextCodec("Old PETSCII", + "\ufffd" * 32 + + 0x20.to(0x3f).map(_.toChar).mkString + + "@abcdefghijklmnopqrstuvwxyz[\\]↑←" + + "\ufffd" * 32 + + "\ufffd" * 32 + + "\ufffd" * 32 + + "–ABCDEFGHIJKLMNOPQRSTUVWXYZ\ufffd\ufffd\ufffdπ", + Map('^' -> 0x5E, '♥' -> 0xD3, '♡' -> 0xD3, '♠' -> 0xC1, '♣' -> 0xC8, '♢' -> 0xDA, '•' -> 0xD1), Map.empty, Map( + "n" -> List(13), + "q" -> List('\"'.toInt), + "apos" -> List('\''.toInt), + "up" -> List(0x91), + "down" -> List(0x11), + "left" -> List(0x9d), + "right" -> List(0x1d), + "reverse" -> List(0x12), + "reverseoff" -> List(0x92) + ) + ) + + val OriginalPetscii = new TextCodec("Original PETSCII", + "\ufffd" * 32 + + 0x20.to(0x3f).map(_.toChar).mkString + + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]↑←" + + "\ufffd" * 32 + + "\ufffd" * 32 + + "\ufffd" * 32 + + "–abcdefghijklmnopqrstuvwxyz\ufffd\ufffd\ufffdπ", + Map('^' -> 0x5E, '♥' -> 0xD3, '♡' -> 0xD3, '♠' -> 0xC1, '♣' -> 0xC8, '♢' -> 0xDA, '•' -> 0xD1), Map.empty, Map( + "n" -> List(13), + "q" -> List('\"'.toInt), + "apos" -> List('\''.toInt), + "up" -> List(0x91), + "down" -> List(0x11), + "left" -> List(0x9d), + "right" -> List(0x1d), + "reverse" -> List(0x12), + "reverseoff" -> List(0x92) + ) + ) + val Atascii = new TextCodec("ATASCII", "♡" + "\ufffd" * 15 +