mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
Add readkey and fix putchar for more targets.
This commit is contained in:
parent
22cdd1c768
commit
03f2bacd2b
@ -46,7 +46,7 @@
|
||||
|
||||
* Short functions can be now defined using expression syntax.
|
||||
|
||||
* C64: Printing double quote characters doesn't toggle the quotation mode anymore.
|
||||
* On most Commodore targets printing double quote characters doesn't toggle the quotation mode anymore.
|
||||
|
||||
* 6502: Fixed optimizations using index registers.
|
||||
|
||||
|
@ -13,7 +13,7 @@ Uses ROM routines, so requires the appropriate ROM to be enabled if applicable.
|
||||
|
||||
Note that this function may obey typical platform idiosyncrasies, for example:
|
||||
|
||||
* on CBM targets other than C64 the quote character toggles the quotation mode
|
||||
* on Commodore PET targets the quote character toggles the quotation mode
|
||||
|
||||
* printing past the end of line might insert a blank line below the current one
|
||||
|
||||
@ -33,9 +33,21 @@ Uses ROM routines, so requires the appropriate ROM to be enabled if applicable.
|
||||
|
||||
Waits for and reads a single keypress.
|
||||
|
||||
The returning values may vary between platforms:
|
||||
|
||||
* letters may be uppercase or lowercase
|
||||
|
||||
* modifier keys may be applied or ignored
|
||||
|
||||
Available for:
|
||||
Commodore 64 (requires KERNAL),
|
||||
ZX Spectrum.
|
||||
Commodore 16 or Plus/4 (requires KERNAL),
|
||||
Commodore 128 (requires KERNAL),
|
||||
VIC 20 (requires KERNAL),
|
||||
Atari,
|
||||
Amstrad CPC,
|
||||
ZX Spectrum,
|
||||
NEC PC-88.
|
||||
|
||||
#### `pointer readline()`
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#warn a8_kernel module should be used only on Atari computer-compatible targets
|
||||
#endif
|
||||
|
||||
asm void putchar(byte a) {
|
||||
noinline asm void putchar(byte a) {
|
||||
? tax
|
||||
lda $347
|
||||
pha
|
||||
@ -13,6 +13,16 @@ asm void putchar(byte a) {
|
||||
rts
|
||||
}
|
||||
|
||||
noinline asm byte readkey() {
|
||||
lda #$C
|
||||
sta $2A
|
||||
lda $E425
|
||||
pha
|
||||
lda $E424
|
||||
pha
|
||||
rts
|
||||
}
|
||||
|
||||
inline void new_line() {
|
||||
putchar($9b)
|
||||
}
|
||||
|
@ -6,7 +6,22 @@
|
||||
|
||||
// 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
|
||||
asm void chrout(byte a) @$FFD2 extern
|
||||
|
||||
asm void putchar(byte a) {
|
||||
JSR chrout
|
||||
LDA #0
|
||||
STA $F4
|
||||
? RTS
|
||||
}
|
||||
|
||||
noinline asm byte readkey() {
|
||||
__read_key__start:
|
||||
LDA $D0
|
||||
BEQ __read_key__start
|
||||
LDX #0
|
||||
JMP $C244
|
||||
}
|
||||
|
||||
inline void new_line() {
|
||||
putchar(13)
|
||||
|
@ -5,7 +5,22 @@
|
||||
|
||||
// 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
|
||||
asm void chrout(byte a) @$FFD2 extern
|
||||
|
||||
asm void putchar(byte a) {
|
||||
JSR chrout
|
||||
LDA #0
|
||||
STA $CB
|
||||
? RTS
|
||||
}
|
||||
|
||||
noinline asm byte readkey() {
|
||||
__read_key__start:
|
||||
LDA $EF
|
||||
BEQ __read_key__start
|
||||
LDX #0
|
||||
JMP $D8D5
|
||||
}
|
||||
|
||||
inline void new_line() {
|
||||
putchar(13)
|
||||
|
@ -24,7 +24,7 @@ asm void clrchn() @$FFCC extern
|
||||
// Output: A = Device status.
|
||||
asm byte readst() @$FFB7 extern
|
||||
|
||||
inline asm void putchar(byte a) {
|
||||
asm void putchar(byte a) {
|
||||
JSR chrout
|
||||
LDA #0
|
||||
STA $D4
|
||||
@ -32,7 +32,7 @@ inline asm void putchar(byte a) {
|
||||
}
|
||||
|
||||
noinline asm byte readkey() {
|
||||
__read_key__start
|
||||
__read_key__start:
|
||||
LDA $C6
|
||||
BEQ __read_key__start
|
||||
JMP $E5B4
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
asm void putchar(byte a) @$BB5A extern
|
||||
|
||||
asm byte readkey() @$BB06 extern
|
||||
|
||||
inline void new_line() {
|
||||
putchar(13)
|
||||
putchar(10)
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
asm void putchar(byte a) @$3e0d extern
|
||||
|
||||
asm byte readkey() @$3583 extern
|
||||
|
||||
inline void new_line() {
|
||||
putchar(13)
|
||||
putchar(10)
|
||||
|
@ -6,7 +6,21 @@
|
||||
|
||||
// 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
|
||||
asm void chrout(byte a) @$FFD2 extern
|
||||
|
||||
asm void putchar(byte a) {
|
||||
JSR chrout
|
||||
LDA #0
|
||||
STA $D4
|
||||
? RTS
|
||||
}
|
||||
|
||||
noinline asm byte readkey() {
|
||||
__read_key__start:
|
||||
LDA $C6
|
||||
BEQ __read_key__start
|
||||
JMP $E5CF
|
||||
}
|
||||
|
||||
inline void new_line() {
|
||||
putchar(13)
|
||||
|
Loading…
x
Reference in New Issue
Block a user