2018-07-12 16:30:35 +00:00
|
|
|
|
|
|
|
#if not(ZX_SPECTRUM)
|
|
|
|
#warn zxspectrum module should be only used on ZX Spectrum-compatible targets
|
|
|
|
#endif
|
|
|
|
|
2018-08-03 11:23:37 +00:00
|
|
|
#pragma zilog_syntax
|
|
|
|
|
2018-07-04 22:50:13 +00:00
|
|
|
inline asm void putchar(byte a) {
|
|
|
|
rst $10
|
|
|
|
? ret
|
|
|
|
}
|
2018-07-12 16:30:35 +00:00
|
|
|
|
2018-12-17 16:18:29 +00:00
|
|
|
inline void new_line() {
|
|
|
|
putchar(13)
|
|
|
|
}
|
|
|
|
|
2019-06-25 16:19:33 +00:00
|
|
|
asm byte readkey() {
|
|
|
|
ld hl,23560
|
|
|
|
ld (hl),0
|
|
|
|
__readkey__start:
|
|
|
|
ld a,(hl)
|
|
|
|
or a
|
|
|
|
jr z,__readkey__start
|
|
|
|
? ret
|
|
|
|
}
|
|
|
|
|
2018-07-12 16:30:35 +00:00
|
|
|
inline asm void set_border(byte a) {
|
|
|
|
out (254),a
|
|
|
|
? ret
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:18:29 +00:00
|
|
|
inline asm void bell() {
|
|
|
|
? ld hl,$6A
|
|
|
|
? ld de,$105
|
|
|
|
? call $3B5
|
|
|
|
? ret
|
|
|
|
}
|
|
|
|
|
2018-12-19 21:30:12 +00:00
|
|
|
array __readline_out[45]
|
|
|
|
const pointer readline_out = __readline_out.addr
|
|
|
|
|
|
|
|
pointer readline() {
|
|
|
|
asm {
|
|
|
|
ld a, 1
|
|
|
|
call $1601
|
|
|
|
ld hl, $5c71
|
|
|
|
set 7, (hl)
|
|
|
|
set 5, (hl)
|
|
|
|
call $16b0
|
|
|
|
ld bc, 1
|
|
|
|
rst $30
|
|
|
|
ld (hl), 13
|
|
|
|
ld ($5c5b), hl
|
|
|
|
ld hl, __readline_exit
|
|
|
|
push hl
|
|
|
|
ld ($5c2d), sp
|
|
|
|
call $0f2c
|
|
|
|
pop hl
|
|
|
|
ld hl, ($5c61)
|
|
|
|
ld de, __readline_out.addr
|
|
|
|
ld b, __readline_out.length - 1
|
|
|
|
__readline_copy:
|
|
|
|
ld a, (hl)
|
|
|
|
cp 13
|
|
|
|
jr z, __readline_exit
|
|
|
|
ld (de), a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
djnz __readline_copy
|
|
|
|
__readline_exit:
|
|
|
|
ld a, 0
|
|
|
|
ld (de), a
|
|
|
|
ld a,2
|
|
|
|
call $1601
|
|
|
|
call $16b0
|
|
|
|
}
|
|
|
|
putstrz(__readline_out)
|
|
|
|
new_line()
|
|
|
|
return __readline_out.addr
|
|
|
|
}
|
|
|
|
|
2018-07-12 16:30:35 +00:00
|
|
|
const byte black = 0
|
|
|
|
const byte blue = 1
|
|
|
|
const byte red = 2
|
|
|
|
const byte purple = 3
|
|
|
|
const byte green = 4
|
|
|
|
const byte cyan = 5
|
|
|
|
const byte yellow = 6
|
|
|
|
const byte white = 7
|