From 7a33b825ba6644845100b455c656657f4d7b9580 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sun, 6 Jan 2019 22:56:45 -0800 Subject: [PATCH] WIP --- path.s | 194 +++++++++++++++++++++++++++++++++++++++++++++++------ prodos.inc | 7 ++ 2 files changed, 180 insertions(+), 21 deletions(-) diff --git a/path.s b/path.s index 9865304..1fb25d5 100644 --- a/path.s +++ b/path.s @@ -16,6 +16,9 @@ INBUF := $200 ; GETLN input buffer +cmd_load_addr := $4000 +max_cmd_size = $2000 + ;;; ============================================================ ;;; Monitor ROM routines @@ -35,6 +38,9 @@ CASE_MASK = $DF ;;; ============================================================ ;;; Install the new command +.proc installer + ptr := $06 + ;; TODO: Fail if Applesoft is not in ROM ;; Save previous external command address @@ -43,8 +49,9 @@ CASE_MASK = $DF lda EXTRNCMD+2 sta next_command+1 - ;; Request a 2-page buffer - lda #2 + ;; Request a 4-page buffer - two pages for handler, + ;; two pages for I/O buffer. + lda #4 jsr GETBUFR bcc :+ lda #$C ; NO BUFFERS AVAILABLE @@ -58,14 +65,22 @@ CASE_MASK = $DF sta page_delta ;; Relocatable routine is aligned to page boundary so only MSB changes - ldx relocation_table -: ldy relocation_table+1,x - lda handler,y + ldx #0 +: txa + asl + tay + lda relocation_table+1,y + sta ptr + lda relocation_table+2,y + sta ptr+1 + + lda (ptr),y clc adc page_delta - sta handler,y - dex - bpl :- + sta (ptr),y + inx + cpx relocation_table + bne :- ;; Relocate lda #XRETURN + sta XTRNADDR+1 + + ;; Now try to open/read/close and invoke it + jsr MLI + .byte OPEN + .addr open_params + beq :+ + lda #8 ; I/O ERROR - TODO: is this used??? + sec + rts + +: lda open_params::ref_num + sta read_params::ref_num + sta close_params::ref_num + jsr MLI + .byte READ + .addr read_params + beq :+ + lda #8 ; I/O ERROR - TODO: is this used??? + sec + rts + +: jsr MLI + .byte CLOSE + .addr close_params + + ;; Invoke command + jsr cmd_load_addr + + clc ; Success + rts ; Return to BASIC.SYSTEM + + ;;; ============================================================ ;;; ============================================================ @@ -283,6 +429,9 @@ command_string: path_buffer: .res 65, 0 +command_path_buffer: + .res 65, 0 + .endproc .assert .sizeof(handler) <= $200, error, "Must fit on two pages" handler_end := *-1 @@ -295,11 +444,14 @@ page_delta: relocation_table: .byte 5 - .byte