2017-12-06 23:23:30 +00:00
|
|
|
// target-independent standard I/O routines
|
|
|
|
|
2018-07-12 16:30:35 +00:00
|
|
|
import string
|
|
|
|
#if ZX_SPECTRUM
|
|
|
|
import stdio_zxspectrum
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if not(ZX_SPECTRUM)
|
|
|
|
|
2017-12-06 23:23:30 +00:00
|
|
|
void putstr(pointer str, byte len) {
|
|
|
|
byte index
|
|
|
|
index = 0
|
|
|
|
while (index != len) {
|
|
|
|
putchar(str[index])
|
|
|
|
index += 1
|
|
|
|
}
|
2018-01-20 21:03:56 +00:00
|
|
|
}
|
2018-12-19 23:47:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NEC_PC_88
|
|
|
|
asm void putstrz(pointer hl) @$5550 extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if not(ZX_SPECTRUM) && not(NEC_PC_88)
|
2018-01-20 21:03:56 +00:00
|
|
|
void putstrz(pointer str) {
|
|
|
|
byte index
|
|
|
|
index = 0
|
2019-08-15 22:46:11 +00:00
|
|
|
while str[index] != nullchar {
|
2018-01-20 21:03:56 +00:00
|
|
|
putchar(str[index])
|
|
|
|
index += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-12 16:30:35 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-19 18:01:53 +00:00
|
|
|
void putword(word w) {
|
|
|
|
byte digits
|
|
|
|
byte lastdigit
|
|
|
|
digits = 0
|
|
|
|
word mask
|
|
|
|
for mask:[40000,4000,400,40,4] {
|
|
|
|
lastdigit = 0
|
|
|
|
while w >= mask {
|
|
|
|
w -= mask
|
|
|
|
lastdigit += 4
|
|
|
|
}
|
|
|
|
mask >>= 2
|
|
|
|
while w >= mask {
|
|
|
|
w -= mask
|
|
|
|
lastdigit += 1
|
|
|
|
}
|
|
|
|
if digits != 0 || lastdigit != 0 {
|
|
|
|
putchar('0' + lastdigit)
|
|
|
|
digits += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if digits == 0 {
|
|
|
|
putchar('0')
|
|
|
|
}
|
|
|
|
}
|
2018-12-30 17:59:32 +00:00
|
|
|
|
|
|
|
#if CBM_PET
|
|
|
|
inline asm void ensure_mixedcase() {
|
|
|
|
? lda #14
|
|
|
|
! sta 59468
|
|
|
|
? rts
|
|
|
|
}
|
|
|
|
#elseif CBM
|
|
|
|
inline void ensure_mixedcase() {
|
|
|
|
putchar(14)
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
inline void ensure_mixedcase() {
|
|
|
|
}
|
|
|
|
#endif
|