diff --git a/include/c64/kernalio.c b/include/c64/kernalio.c index d33eb51..de0961d 100644 --- a/include/c64/kernalio.c +++ b/include/c64/kernalio.c @@ -2,6 +2,20 @@ krnioerr krnio_pstatus[16]; +#if defined(__C128__) || defined(__C128B__) || defined(__C128E__) +void krnio_setbnk(char filebank, char namebank) +{ + __asm + { + lda filebank + ldx namebank + jsr $ff68 // setbnk + } +} + +#pragma native(krnio_setbnk) +#endif + void krnio_setnam(const char * name) { __asm @@ -122,6 +136,42 @@ bool krnio_load(char fnum, char device, char channel) #pragma native(krnio_load) +bool krnio_save(char device, const char* start, const char* end) +{ + __asm + { + lda start + sta accu + lda start + 1 + sta accu + 1 + + lda #0 + ldx device + ldy #0 + jsr $ffba // setlfs + + lda #accu + ldx end + ldy end+1 + jsr $FFD8 // save + + lda #0 + sta accu + sta accu + 1 + + bcc W1 + + lda #0 + jmp E2 + W1: + lda #1 + sta accu + E2: + } +} + +#pragma native(krnio_load) + bool krnio_chkout(char fnum) { __asm diff --git a/include/c64/kernalio.h b/include/c64/kernalio.h index ca2cfc2..e32405b 100644 --- a/include/c64/kernalio.h +++ b/include/c64/kernalio.h @@ -18,6 +18,11 @@ enum krnioerr extern krnioerr krnio_pstatus[16]; +#if defined(__C128__) || defined(__C128B__) || defined(__C128E__) +// C128: Set bank for load/save and filename for next file operations +void krnio_setbnk(char filebank, char namebank); +#endif + // Set filename for next krnio_open operation, make sure // that the string is still valid when calling krnio_open @@ -39,6 +44,8 @@ krnioerr krnio_status(void); bool krnio_load(char fnum, char device, char channel); +bool krnio_save(char device, const char* start, const char* end); + // select the given file for stream output bool krnio_chkout(char fnum);