Proposals for krnio additions: setbnk and save

This commit is contained in:
Xander Mol 2024-01-09 23:50:46 +01:00
parent 5634abdba4
commit 299374aa50
2 changed files with 57 additions and 0 deletions

View File

@ -2,6 +2,20 @@
krnioerr krnio_pstatus[16]; 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) void krnio_setnam(const char * name)
{ {
__asm __asm
@ -122,6 +136,42 @@ bool krnio_load(char fnum, char device, char channel)
#pragma native(krnio_load) #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) bool krnio_chkout(char fnum)
{ {
__asm __asm

View File

@ -18,6 +18,11 @@ enum krnioerr
extern krnioerr krnio_pstatus[16]; 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 // Set filename for next krnio_open operation, make sure
// that the string is still valid when calling krnio_open // 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_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 // select the given file for stream output
bool krnio_chkout(char fnum); bool krnio_chkout(char fnum);