mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
ZX Spectrum improvements
This commit is contained in:
parent
fe85757e00
commit
c3504a63b3
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,6 +31,8 @@ examples/lunix/
|
||||
*.a2
|
||||
*.dsk
|
||||
*.inf
|
||||
*.tap
|
||||
*.d88
|
||||
HELLO
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
;a single-load ZX Spectrum 48k program
|
||||
[compilation]
|
||||
arch=z80
|
||||
modules=default_panic
|
||||
modules=default_panic,zxspectrum
|
||||
|
||||
[allocation]
|
||||
segments=default,slowram
|
||||
|
4
include/zxspectrum.mfk
Normal file
4
include/zxspectrum.mfk
Normal file
@ -0,0 +1,4 @@
|
||||
inline asm void putchar(byte a) {
|
||||
rst $10
|
||||
? ret
|
||||
}
|
@ -50,16 +50,21 @@ class DataBlock(val inputData: Array[Byte]) extends TapBlock {
|
||||
|
||||
object ZxSpectrumBasic {
|
||||
|
||||
import scala.language.implicitConversions
|
||||
|
||||
class Snippet(val array: Array[Byte]) extends AnyVal
|
||||
|
||||
implicit def _implicit_String_to_Snippet(s: String): Snippet = new Snippet(s.getBytes(StandardCharsets.US_ASCII))
|
||||
|
||||
private def token(i: Int) = new Snippet(Array(i.toByte))
|
||||
|
||||
val PI: Snippet = token(167)
|
||||
val SCREEN$: Snippet = token(170)
|
||||
val AT: Snippet = token(172)
|
||||
val CODE: Snippet = token(175)
|
||||
val VAL: Snippet = token(176)
|
||||
val USR: Snippet = token(192)
|
||||
val NOT: Snippet = token(195)
|
||||
val INK: Snippet = token(217)
|
||||
val PAPER: Snippet = token(218)
|
||||
val BORDER: Snippet = token(231)
|
||||
@ -72,6 +77,8 @@ object ZxSpectrumBasic {
|
||||
val CLS: Snippet = token(251)
|
||||
val CLEAR: Snippet = token(253)
|
||||
|
||||
val colon: Snippet = token(':')
|
||||
|
||||
def line(number: Int, tokens: Snippet*): Array[Byte] = {
|
||||
val content = tokens.flatMap(_.array).toArray
|
||||
Array[Byte](number.>>(8).toByte, number.toByte, (content.length + 1).toByte, (content.length + 1).>>(8).toByte) ++ content :+ 13.toByte
|
||||
@ -82,10 +89,10 @@ object ZxSpectrumBasic {
|
||||
def loader(filename: String, rem: String, loadAddress: Int): Array[Byte] = {
|
||||
Array(
|
||||
line(10, REM, rem),
|
||||
line(20, BORDER, VAL, "\"0\":", INK, VAL, "\"0\":", PAPER, VAL, "\"7\":", CLS),
|
||||
line(20, BORDER, VAL, quoted(7), colon, INK, NOT, PI, colon, PAPER, VAL, quoted(7), colon, CLS),
|
||||
line(30, CLEAR, VAL, quoted(loadAddress - 1)),
|
||||
line(40, LOAD, quoted(filename), CODE),
|
||||
line(50, RANDOMIZE, USR, VAL, quoted(loadAddress))
|
||||
line(50, CLS, colon, PRINT, AT, NOT, PI, ",", NOT, PI, colon, RANDOMIZE, USR, VAL, quoted(loadAddress))
|
||||
).flatten
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user