From 67e9be437277d284c18b5c4690e61abea6f76e2e Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 14 Feb 2021 16:19:00 +0100 Subject: [PATCH] fixed LOAD command for CBDOS --- src/kernal/iec/load_iec.s | 17 +++++++++ src/kernal/iec_fast/m65dos_load.s | 57 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/kernal/iec_fast/m65dos_load.s diff --git a/src/kernal/iec/load_iec.s b/src/kernal/iec/load_iec.s index 8210267d..e006b001 100644 --- a/src/kernal/iec/load_iec.s +++ b/src/kernal/iec/load_iec.s @@ -7,6 +7,9 @@ ; +; XXX This is suspiciously complicated, most likely something is really wrong with the IEC support + + !ifdef CONFIG_IEC { @@ -57,6 +60,11 @@ load_iec: jsr TALK bcs load_iec_error +!ifdef CONFIG_MB_M65 { + jsr m65dos_check + +bcc m65dos_load_part ; branch if device is handeld by internal DOS +} + !ifdef HAS_IEC_BURST { jsr burst_advertise } @@ -83,6 +91,10 @@ load_iec: jsr load_iec_get_addr_byte sta EAL+1 +!ifdef CONFIG_MB_M65 { + load_iec_m65cont: +} + ; If secondary address is 0, override EAL with STAL lda SA @@ -126,6 +138,11 @@ load_iec: load_iec_loop: +!ifdef CONFIG_MB_M65 { + jsr m65dos_check + +bcc m65dos_load_loop ; branch if device is handeld by internal DOS +} + ; We are now ready to receive bytes !ifdef CONFIG_IEC_JIFFYDOS { jsr iec_rx_dispatch diff --git a/src/kernal/iec_fast/m65dos_load.s b/src/kernal/iec_fast/m65dos_load.s new file mode 100644 index 00000000..d2716c61 --- /dev/null +++ b/src/kernal/iec_fast/m65dos_load.s @@ -0,0 +1,57 @@ +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE + +; +; MEGA65 pseudo-IEC internal DOS support - part of the LOAD routine +; + + +m65dos_load_part: + + ; Open channel for loading + + lda #$60 + jsr m65dos_tksa + + jsr m65dos_get_addr_byte + sta EAL+0 + + jsr m65dos_get_addr_byte + sta EAL+1 + + jmp load_iec_m65cont + +m65dos_get_addr_byte: + + jsr m65dos_acptr + bcs @1 + lda IOSTATUS + and #K_STS_EOI + bne @1 + lda TBTCNT + rts +@1: + pla + pla + + jmp load_iec_file_not_found + +m65dos_load_loop: + + jsr m65dos_acptr + + ; Handle the byte (store in memory / verify) + jsr lvs_handle_byte_load_verify + +bcs load_iec_error + + ; Advance pointer to data; it is OK if it advances past $FFFF, + ; one autostart technique does exactly this + inw EAL+0 + + ; Check for EOI - if so, this was the last byte + bit IOSTATUS + bvc m65dos_load_loop + + ; FALLTROUGH + + jmp load_iec_loop_end