2017-12-06 23:23:30 +00:00
|
|
|
// Routines from C64 KERNAL ROM
|
|
|
|
|
|
|
|
// CHROUT. Write byte to default output. (If not screen, must call OPEN and CHKOUT beforehands.)
|
|
|
|
// Input: A = Byte to write.
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void chrout(byte register(a) char) @$FFD2 extern
|
2017-12-06 23:23:30 +00:00
|
|
|
|
2019-01-05 00:19:14 +00:00
|
|
|
// CHRIN. Read byte from default input (for keyboard, read a line from the screen). (If not keyboard, must call OPEN and CHKIN beforehands.)
|
|
|
|
// Output: A = Byte read.
|
2019-06-25 16:19:33 +00:00
|
|
|
asm byte chrin() @$FFCF extern
|
|
|
|
alias getchar = chrin
|
2019-01-05 00:19:14 +00:00
|
|
|
|
|
|
|
// CHKIN. Define file as default input. (Must call OPEN beforehands.)
|
|
|
|
// Input: X = Logical number.
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void chkin(byte register(x) fd) @$FFC6 extern
|
2019-01-05 00:19:14 +00:00
|
|
|
|
|
|
|
// CHKOUT. Define file as default output. (Must call OPEN beforehands.)
|
|
|
|
// Input: X = Logical number.
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void chkout(byte register(x) fd) @$FFC9 extern
|
2019-01-05 00:19:14 +00:00
|
|
|
|
|
|
|
// CLRCHN. Close default input/output files (for serial bus, send UNTALK and/or UNLISTEN); restore default input/output to keyboard/screen.
|
|
|
|
asm void clrchn() @$FFCC extern
|
|
|
|
|
|
|
|
// READST. Fetch status of current input/output device, value of ST variable. (For RS232, status is cleared.)
|
|
|
|
// Output: A = Device status.
|
|
|
|
asm byte readst() @$FFB7 extern
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void putchar(byte register(a) char) {
|
2019-06-25 16:19:33 +00:00
|
|
|
JSR chrout
|
|
|
|
LDA #0
|
|
|
|
STA $D4
|
|
|
|
? RTS
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:18:29 +00:00
|
|
|
inline void new_line() {
|
2019-06-25 16:19:33 +00:00
|
|
|
chrout(13)
|
2018-12-17 16:18:29 +00:00
|
|
|
}
|
|
|
|
|
2017-12-06 23:23:30 +00:00
|
|
|
// OPEN. Open file. (Must call SETLFS and SETNAM beforehands.)
|
|
|
|
asm void open() @$FFC0 extern
|
|
|
|
|
|
|
|
// CLOSE. Close file.
|
|
|
|
// Input: A = Logical number.
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void close(byte register(a) fd) @$FFC3 extern
|
2017-12-06 23:23:30 +00:00
|
|
|
|
|
|
|
// SETLFS. Set file parameters.
|
|
|
|
// Input: A = Logical number; X = Device number; Y = Secondary address.
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void setlfs(byte register(a) fd, byte register(x) device, byte register(y) secondary) @$FFBA extern
|
2017-12-06 23:23:30 +00:00
|
|
|
|
|
|
|
// SETNAM. Set file name parameters.
|
|
|
|
// Input: A = File name length; X/Y = Pointer to file name.
|
2020-03-30 17:23:48 +00:00
|
|
|
asm void setnam(pointer register(xy) filename, byte register(a) len) @$FFBD extern
|
2017-12-06 23:23:30 +00:00
|
|
|
|
|
|
|
// LOAD. Load or verify file. (Must call SETLFS and SETNAM beforehands.)
|
|
|
|
// Input: A: 0 = Load, 1-255 = Verify; X/Y = Load address (if secondary address = 0).
|
|
|
|
// Output: Carry: 0 = No errors, 1 = Error; A = KERNAL error code (if Carry = 1); X/Y = Address of last byte loaded/verified (if Carry = 0).
|
2020-03-30 17:23:48 +00:00
|
|
|
asm clear_carry load(bool register(a) verify, pointer register(xy) address) @$FFD5 extern
|
2017-12-06 23:23:30 +00:00
|
|
|
|
|
|
|
// SAVE. Save file. (Must call SETLFS and SETNAM beforehands.)
|
|
|
|
// Input: A = Address of zero page register holding start address of memory area to save; X/Y = End address of memory area plus 1.
|
|
|
|
// Output: Carry: 0 = No errors, 1 = Error; A = KERNAL error code (if Carry = 1).
|
2020-03-30 17:23:48 +00:00
|
|
|
asm clear_carry save(byte register(a) address, word register(xy) past_end) @$FFD8 extern
|
2017-12-06 23:23:30 +00:00
|
|
|
|
2018-07-12 16:30:35 +00:00
|
|
|
word irq_pointer @$314
|