diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 335270b3..358c53c8 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -17,6 +17,17 @@ cmd_load: lda #$00 ; LOAD not verify ldx #<$0801 ; LOAD address = $0801 ldy #>$0801 + + ;; Set filename and length + lda #$24 + sta $0400 + lda #$01 + sta current_filename_length + lda #<$0400 + sta current_filename_ptr+0 + lda #>$0401 + sta current_filename_ptr+1 + jsr $ffd5 bcc + diff --git a/c64/basic/under_rom_routines.s b/c64/basic/under_rom_routines.s index 26ad0cee..afcfb87e 100644 --- a/c64/basic/under_rom_routines.s +++ b/c64/basic/under_rom_routines.s @@ -23,9 +23,45 @@ install_ram_routines: ram_routines_start: + ;; XXX - Routine order must match that of the KERNAL version of the file. + ;; (since it has fewer routines) tiny_nmi_handler_routine: inc missed_nmi_flag rti +peek_under_roms_routine: + php + ; Offset of arg of lda ($00),y + stx peek_under_roms+pa-peek_under_roms_routine+1 + jsr memmap_allram +pa: lda ($00),y + jsr memmap_normal + plp + rts + +poke_under_roms_routine: + php + ; Offset of arg of lda ($00),y + stx poke_under_roms+pb-poke_under_roms_routine+1 + jsr memmap_allram +pb: sta ($00),y + jsr memmap_normal_routine + plp + rts + +memmap_normal_routine: + pha + lda #$37 + sta $01 + pla + rts + +memmap_allram_routine: + sei + pha + lda #$04 + sta $01 + pla + rts shift_mem_up_routine: ;; Move memmove_size bytes from memmove_src to memmove_dst, @@ -68,33 +104,6 @@ smd1: jmp memmap_normal -peek_under_roms_routine: - stx peek_under_roms+7 ;Offset of arg of lda ($00),y - jsr memmap_allram - lda ($00),y - jmp memmap_normal - -poke_under_roms_routine: - stx poke_under_roms+7 ;Offset of arg of lda ($00),y - jsr memmap_allram - sta ($00),y - ;; FALL THROUGH -memmap_normal_routine: - pha - lda #$37 - sta $01 - pla - cli - rts - -memmap_allram_routine: - sei - pha - lda #$04 - sta $01 - pla - rts - ram_routines_end: .alias ram_routines_len ram_routines_end-ram_routines_start diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 7504ed42..4dc694f1 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -75,3 +75,14 @@ .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 .alias pal_or_ntsc $02A6 + + ;; Under-ROM routines + ;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) + .alias missed_nmi_flag $2A7 + .alias tiny_nmi_handler $2A8 + .alias peek_under_roms tiny_nmi_handler+peek_under_roms_routine-tiny_nmi_handler_routine + .alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine + .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine + .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine + + diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 67e5b29c..764764c9 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -22,6 +22,9 @@ load: ;; Store start address of LOAD stx load_save_start_ptr+0 sty load_save_start_ptr+1 + + ;; We need our helpers to get to filenames under ROMs or IO area + jsr install_ram_routines ;; Disable IRQs, since timing matters! SEI @@ -62,9 +65,28 @@ load: jsr iec_release_atn ;; Send filename (p16) - lda #$24 ; $ = directory + ldy #0 + +send_filename: + cpy current_filename_length + beq sent_filename + + ldx #tiny_nmi_handler + sta $FFFF + + rts + +ram_routines_start: + +tiny_nmi_handler_routine: + inc missed_nmi_flag + rti +peek_under_roms_routine: + php + ; Offset of arg of lda ($00),y + stx peek_under_roms+pa-peek_under_roms_routine+1 + jsr memmap_allram +pa: lda ($00),y + jsr memmap_normal + plp + rts + +poke_under_roms_routine: + php + ; Offset of arg of lda ($00),y + stx poke_under_roms+pb-poke_under_roms_routine+1 + jsr memmap_allram +pb: sta ($00),y + jsr memmap_normal_routine + plp + rts + +memmap_normal_routine: + pha + lda #$37 + sta $01 + pla + rts + +memmap_allram_routine: + sei + pha + lda #$04 + sta $01 + pla + rts + +ram_routines_end: + .alias ram_routines_len ram_routines_end-ram_routines_start +