]> git.sur5r.net Git - cc65/commitdiff
Added wrappers for the kernal functions
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 22 Nov 2002 22:16:20 +0000 (22:16 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 22 Nov 2002 22:16:20 +0000 (22:16 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1587 b7a2c559-68d2-44c3-8de9-860c34a00d81

28 files changed:
libsrc/plus4/Makefile
libsrc/plus4/cgetc.s
libsrc/plus4/clrscr.s
libsrc/plus4/crt0.s
libsrc/plus4/kacptr.s [new file with mode: 0644]
libsrc/plus4/kbasin.s [new file with mode: 0644]
libsrc/plus4/kbsout.s [new file with mode: 0644]
libsrc/plus4/kchkin.s [new file with mode: 0644]
libsrc/plus4/kciout.s [new file with mode: 0644]
libsrc/plus4/kckout.s [new file with mode: 0644]
libsrc/plus4/kclall.s [new file with mode: 0644]
libsrc/plus4/kclose.s [new file with mode: 0644]
libsrc/plus4/kclrch.s [new file with mode: 0644]
libsrc/plus4/kernal.s [deleted file]
libsrc/plus4/kiobase.s [new file with mode: 0644]
libsrc/plus4/klisten.s [new file with mode: 0644]
libsrc/plus4/kload.s [new file with mode: 0644]
libsrc/plus4/kopen.s [new file with mode: 0644]
libsrc/plus4/krdtim.s [new file with mode: 0644]
libsrc/plus4/kreadst.s [new file with mode: 0644]
libsrc/plus4/ksave.s [new file with mode: 0644]
libsrc/plus4/ksetlfs.s [new file with mode: 0644]
libsrc/plus4/ksetnam.s [new file with mode: 0644]
libsrc/plus4/ksettim.s [new file with mode: 0644]
libsrc/plus4/ktalk.s [new file with mode: 0644]
libsrc/plus4/kunlsn.s [new file with mode: 0644]
libsrc/plus4/kuntlk.s [new file with mode: 0644]
libsrc/plus4/plus4.inc

index a503225afb2d82cf8370a4df3a2658ce0926acc8..8dc9004629bbe1a2abc23ed0af55fc4cc4b21e37 100644 (file)
@@ -19,8 +19,29 @@ OBJS =       _scrsize.o      \
        conio.o         \
        cputc.o         \
        crt0.o          \
+        kacptr.o        \
+        kbasin.o        \
        kbhit.o         \
-        kernal.o        \
+        kbsout.o        \
+        kchkin.o        \
+        kciout.o        \
+        kckout.o        \
+        kclall.o        \
+        kclose.o        \
+        kclrch.o        \
+        kiobase.o       \
+        klisten.o       \
+        kload.o         \
+        kopen.o         \
+        krdtim.o        \
+        kreadst.o       \
+        ksave.o         \
+        ksetlfs.o       \
+        ksetnam.o       \
+        ksettim.s       \
+        ktalk.o         \
+        kunlsn.o        \
+        kuntlk.o        \
         randomize.o     \
        readjoy.o       \
        tgi_mode_table.o
index c486767456bc093334d6b6dca3a094af5f496585..0bcd6013afc5f63fa83ac4c56a35d16358de4d2f 100644 (file)
@@ -9,9 +9,10 @@
 
                .include        "plus4.inc"
 
-
 ; --------------------------------------------------------------------------
 
+.segment        "LOWMEM"        ; Accesses the ROM - must go into low mem
+
 _cgetc:        lda     KEY_COUNT       ; Get number of characters
                ora     FKEY_COUNT      ; Or with number of function key chars
                bne     L2              ; Jump if there are already chars waiting
@@ -44,7 +45,9 @@ L1:           lda     KEY_COUNT
                sta     TED_CURSLO      ; Cursor off
                sta     TED_CURSHI
 
-L2:            jsr     KBDREAD         ; Read char and return in A
+L2:            sta     ENABLE_ROM      ; Bank in the ROM
+        jsr            KBDREAD         ; Read char and return in A (ROM routine)
+        sta     ENABLE_RAM      ; Reenable the RAM
                ldx     #0
                rts
 
@@ -56,6 +59,8 @@ L2:           jsr     KBDREAD         ; Read char and return in A
        .constructor    initkbd
        .destructor     donekbd
 
+.code                           ; Can go into the normal code segment
+
 .proc  initkbd
 
        ldy     #15
@@ -68,13 +73,17 @@ L2:         jsr     KBDREAD         ; Read char and return in A
 .endproc
 
 
+.segment        "LOWMEM"        ; Accesses the ROM - must go into low mem
+
 .proc  donekbd
 
        ldx     #$39            ; Copy the original function keys
+        sta     ENABLE_ROM      ; Bank in the ROM
 @L1:   lda     FKEY_ORIG,x
        sta     FKEY_SPACE,x
        dex
        bpl     @L1
+        sta     ENABLE_RAM      ; Bank out the ROM
        rts
 
 .endproc
index 4b6c4835518d3b598677d3599ee10e2ad307ab3f..6641c336bd367f4a91768625c0907a1300cc48f2 100644 (file)
@@ -8,7 +8,16 @@
 
        .include        "plus4.inc"
 
-_clrscr        = CLRSCR
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   _clrscr
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     CLRSCR                  ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
 
 
 
index 9c8b66feaf28e88c1a54482da80f97c54acfc14c..503d086d552442b155b074b438f36c28a9f2f7bb 100644 (file)
@@ -7,61 +7,71 @@
        .export         _exit
        .import         initlib, donelib
        .import         push0, _main, zerobss
-        .import         MEMTOP, RESTOR, BSOUT, CLRCH
+       .import         __IRQFUNC_TABLE__, __IRQFUNC_COUNT__
 
         .include        "zeropage.inc"
        .include        "plus4.inc"
 
 
 ; ------------------------------------------------------------------------
-; BASIC header with a SYS call
+; Place the startup code in a special segment to cope with the quirks of
+; plus/4 banking.
 
-.code
+.segment               "STARTUP"
 
-       .org    $0FFF
         .word   Head            ; Load address
 Head:   .word   @Next
         .word   1000            ; Line number
         .byte   $9E,"4109"     ; SYS 4109
         .byte   $00             ; End of BASIC line
 @Next:  .word   0               ; BASIC end marker
-       .reloc
 
 ; ------------------------------------------------------------------------
 ; Actual code
 
+        sei                     ; No interrupts since we're banking out the ROM
+        sta     ENABLE_RAM
                ldx     #zpspace-1
 L1:    lda     sp,x
        sta     zpsave,x        ; save the zero page locations we need
        dex
                bpl     L1
+        sta     ENABLE_ROM
+        cli
 
 ; Close open files
 
-       jsr     CLRCH
+       jsr     $FFCC           ; CLRCH
 
 ; Switch to second charset
 
        lda     #14
-       jsr     BSOUT
+       jsr     $FFD2           ; BSOUT
+
+; Setup the IRQ vector in the banked RAM and switch off the ROM
+
+        sei                     ; No ints, handler not yet in place
+        sta     ENABLE_RAM
+        lda     #<IRQ
+        sta     $FFFE           ; Install interrupt handler
+        lda     #>IRQ
+        sta     $FFFF
+        cli                     ; Allow interrupts
 
 ; Clear the BSS data
 
        jsr     zerobss
 
-; Save system stuff and setup the stack
+; Save system stuff and setup the stack. The stack starts at the top of the
+; usable RAM.
 
                tsx
                stx     spsave          ; save system stk ptr
 
-       sec
-       jsr     MEMTOP          ; Get top memory
-       cpy     #$80            ; We can only use the low 32K :-(
-       bcc     MemOk
-       ldy     #$80
-       ldx     #$00
-MemOk: stx     sp
-       sty     sp+1            ; set argument stack ptr
+        lda     #<$FD00
+        sta     sp
+        lda     #>$FD00
+        sta     sp+1
 
 ; Call module constructors
 
@@ -92,10 +102,40 @@ L2:        lda     zpsave,x
        dex
                bpl     L2
 
-; Reset changed vectors
+; Enable the ROM, reset changed vectors and return to BASIC
+
+        sta     ENABLE_ROM
+       jmp     $FF8A           ; RESTOR
 
-       jmp     RESTOR
 
+; ------------------------------------------------------------------------
+; IRQ handler
+
+.segment        "LOWCODE"
+
+IRQ:    pha
+        txa
+        pha
+        tsx                     ; Get the stack pointer
+        lda     $0103,x         ; Get the saved status register
+        tax
+        lda     #>irqret        ; Push new return address
+        pha
+        lda     #<irqret
+        pha
+        txa
+        pha
+        sta     ENABLE_ROM      ; Switch to ROM
+        jmp     ($FFFE)         ; Jump to kernal irq handler
+
+irqret: sta     ENABLE_RAM      ; Switch back to RAM
+        pla
+        tax
+        pla
+        rti
+
+; ------------------------------------------------------------------------
+; Data
 
 .data
 zpsave:        .res    zpspace
diff --git a/libsrc/plus4/kacptr.s b/libsrc/plus4/kacptr.s
new file mode 100644 (file)
index 0000000..75a43c2
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; ACPTR replacement function
+;
+
+        .export         ACPTR
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   ACPTR
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFA5                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kbasin.s b/libsrc/plus4/kbasin.s
new file mode 100644 (file)
index 0000000..5070438
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; BASIN replacement function
+;
+             
+        .export         BASIN
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   BASIN
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFCF                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kbsout.s b/libsrc/plus4/kbsout.s
new file mode 100644 (file)
index 0000000..a86a334
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; BSOUT replacement function
+;
+
+        .export         BSOUT
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   BSOUT
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFD2                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kchkin.s b/libsrc/plus4/kchkin.s
new file mode 100644 (file)
index 0000000..139e512
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; CHKIN replacement function
+;
+
+        .export         CHKIN
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   CHKIN
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFC6                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kciout.s b/libsrc/plus4/kciout.s
new file mode 100644 (file)
index 0000000..5f9f08b
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; CIOUT replacement function
+;
+
+        .export         CIOUT
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   CIOUT
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFA8                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kckout.s b/libsrc/plus4/kckout.s
new file mode 100644 (file)
index 0000000..a1d38f3
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; CKOUT replacement function
+;
+
+        .export         CKOUT
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   CKOUT
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFC9                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kclall.s b/libsrc/plus4/kclall.s
new file mode 100644 (file)
index 0000000..eb00661
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; CLALL replacement function
+;
+
+        .export         CLALL
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   CLALL
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFE7                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kclose.s b/libsrc/plus4/kclose.s
new file mode 100644 (file)
index 0000000..f5f100c
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; CLOSE replacement function
+;
+
+        .export         CLOSE
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   CLOSE
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFC3                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kclrch.s b/libsrc/plus4/kclrch.s
new file mode 100644 (file)
index 0000000..b36c044
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; CLRCH replacement function
+;
+
+        .export         CLRCH
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   CLRCH
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFCC                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kernal.s b/libsrc/plus4/kernal.s
deleted file mode 100644 (file)
index 78914c0..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-;
-; Ullrich von Bassewitz, 19.11.2002
-;
-; Plus/4 kernal functions
-;
-
-        .export         CINT
-        .export         IOINIT
-        .export         RAMTAS
-        .export         RESTOR
-        .export         VECTOR
-        .export         SETMSG
-        .export         SECOND
-        .export         TKSA
-        .export         MEMTOP
-        .export         MEMBOT
-        .export         SCNKEY
-        .export         SETTMO
-        .export         ACPTR
-        .export         CIOUT
-        .export         UNTLK
-        .export         UNLSN
-        .export         LISTEN
-        .export         TALK
-        .export         READST
-        .export         SETLFS
-        .export         SETNAM
-        .export         OPEN
-        .export         CLOSE
-        .export         CHKIN
-        .export         CKOUT
-        .export         CLRCH
-        .export         BASIN
-        .export         BSOUT
-        .export         LOAD
-        .export         SAVE
-        .export         SETTIM
-        .export         RDTIM
-        .export         STOP
-        .export         GETIN
-        .export         CLALL
-        .export         UDTIM
-        .export         SCREEN
-        .export         PLOT
-        .export         IOBASE
-
-
-;-----------------------------------------------------------------------------
-; All functions are available in the kernal jump table
-
-CINT           = $FF81
-IOINIT         = $FF84
-RAMTAS         = $FF87
-RESTOR         = $FF8A
-VECTOR         = $FF8D
-SETMSG         = $FF90
-SECOND         = $FF93
-TKSA           = $FF96
-MEMTOP         = $FF99
-MEMBOT         = $FF9C
-SCNKEY         = $FF9F
-SETTMO         = $FFA2
-ACPTR          = $FFA5
-CIOUT          = $FFA8
-UNTLK          = $FFAB
-UNLSN          = $FFAE
-LISTEN         = $FFB1
-TALK           = $FFB4
-READST         = $FFB7
-SETLFS         = $FFBA
-SETNAM         = $FFBD
-OPEN           = $FFC0
-CLOSE          = $FFC3
-CHKIN          = $FFC6
-CKOUT          = $FFC9
-CLRCH          = $FFCC
-BASIN          = $FFCF
-BSOUT          = $FFD2
-LOAD           = $FFD5
-SAVE           = $FFD8
-SETTIM         = $FFDB
-RDTIM          = $FFDE
-STOP           = $FFE1
-GETIN          = $FFE4
-CLALL          = $FFE7
-UDTIM          = $FFEA
-SCREEN         = $FFED
-PLOT           = $FFF0
-IOBASE         = $FFF3
-
diff --git a/libsrc/plus4/kiobase.s b/libsrc/plus4/kiobase.s
new file mode 100644 (file)
index 0000000..de00517
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; IOBASE replacement function
+;
+
+        .export         IOBASE
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   IOBASE
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFF3                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/klisten.s b/libsrc/plus4/klisten.s
new file mode 100644 (file)
index 0000000..06a4609
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; LISTEN replacement function
+;
+
+        .export         LISTEN
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   LISTEN
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFB1                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kload.s b/libsrc/plus4/kload.s
new file mode 100644 (file)
index 0000000..c2b62dd
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; LOAD replacement function
+;
+
+        .export         LOAD
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   LOAD
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFD5                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kopen.s b/libsrc/plus4/kopen.s
new file mode 100644 (file)
index 0000000..b7e4b1c
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; OPEN replacement function
+;
+
+        .export         OPEN
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   OPEN
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFC0                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/krdtim.s b/libsrc/plus4/krdtim.s
new file mode 100644 (file)
index 0000000..99fb74f
--- /dev/null
@@ -0,0 +1,22 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; RDTIM replacement function
+;
+
+        .export         RDTIM
+
+        .include        "plus4.inc"
+
+; Read the clock from the zero page to avoid banking in the ROM
+
+.proc   RDTIM
+        sei                             ; No interrupts
+        lda     TIME+2
+        ldx     TIME+1
+        ldy     TIME                    ; Read the time
+        cli                             ; Allow interrupts
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kreadst.s b/libsrc/plus4/kreadst.s
new file mode 100644 (file)
index 0000000..afebbc8
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; READST replacement function
+;
+
+        .export         READST
+
+        .include        "plus4.inc"
+
+; Read the status byte from the zero page instead of banking in the ROM
+
+.proc   READST
+        lda     ST                      ; Load status
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/ksave.s b/libsrc/plus4/ksave.s
new file mode 100644 (file)
index 0000000..0e69182
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; SAVE replacement function
+;
+
+        .export         SAVE
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   SAVE
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFD8                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/ksetlfs.s b/libsrc/plus4/ksetlfs.s
new file mode 100644 (file)
index 0000000..6ad7f34
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; SETLFS replacement function
+;
+
+        .export         SETLFS
+
+        .include        "plus4.inc"
+
+; Write directly to the zero page to avoid banking in the ROM
+
+.proc   SETLFS
+        sta     LFN
+        stx     DEVNUM
+        sty     SECADR
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/ksetnam.s b/libsrc/plus4/ksetnam.s
new file mode 100644 (file)
index 0000000..1d1297c
--- /dev/null
@@ -0,0 +1,62 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; SETNAM replacement function
+;
+
+        .export         SETNAM
+
+        .include        "plus4.inc"
+
+; This function is special in that the name must reside in low memory,
+; otherwise it is not accessible by the ROM code.
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   SETNAM
+
+; Limit the length of the name and store it into the zero page
+
+        cmp     #16+1
+        bcc     @L1
+        lda     #16                     ; Use a maximum of 16 chars
+@L1:    sta     FNAM_LEN
+
+; Check if we have to copy the name to low memory
+
+        cmp     #$00                    ; Length zero?
+        beq     @L3                     ; Yes: Copying not needed
+        cpy     #$00                    ; Is the name in low memory?
+        bpl     @L3                     ; Yes: Copying not needed
+
+; Store the length and the pointer to the name
+
+        stx     TMPPTR
+        sty     TMPPTR+1                ; Store pointer to name in TMPPTR
+
+; Copy the given name into DOS_FN1
+
+        ldy     #$00
+@L2:    lda     (TMPPTR),y
+        sta     DOS_FN1,y
+        iny
+        cpy     FNAM_LEN
+        bne     @L2
+
+; Load the new parameters for the low memory buffer
+
+        ldx     #<DOS_FN1
+        ldy     #>DOS_FN1
+
+; Instead of banking in the ROM, store the values directly into the zeropage
+
+@L3:    stx     FNAM_ADR
+        sty     FNAM_ADR+1
+
+; Return to caller
+
+        rts
+
+.endproc
+
+
diff --git a/libsrc/plus4/ksettim.s b/libsrc/plus4/ksettim.s
new file mode 100644 (file)
index 0000000..b3c5983
--- /dev/null
@@ -0,0 +1,22 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; SETTIM replacement function
+;
+
+        .export         SETTIM
+
+        .include        "plus4.inc"
+
+; Set the clock by writing directly to zero page to avoid banking in the ROM
+
+.proc   SETTIM
+        sei                             ; No interrupts
+        sta     TIME+2
+        stx     TIME+1
+        sty     TIME                    ; Set the time
+        cli                             ; Allow interrupts
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/ktalk.s b/libsrc/plus4/ktalk.s
new file mode 100644 (file)
index 0000000..bad693b
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; TALK replacement function
+;
+
+        .export         TALK
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   TALK
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFB4                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kunlsn.s b/libsrc/plus4/kunlsn.s
new file mode 100644 (file)
index 0000000..486bb96
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; UNLSN replacement function
+;
+
+        .export         UNLSN
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   UNLSN
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFAE                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
diff --git a/libsrc/plus4/kuntlk.s b/libsrc/plus4/kuntlk.s
new file mode 100644 (file)
index 0000000..52a5633
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Ullrich von Bassewitz, 22.11.2002
+;
+; UNTLK replacement function
+;
+
+        .export         UNTLK
+
+        .include        "plus4.inc"
+
+.segment        "LOWCODE"               ; Must go into low memory
+
+.proc   UNTLK
+        sta     ENABLE_ROM              ; Enable the ROM
+        jsr     $FFAB                   ; Call the ROM routine
+        sta     ENABLE_RAM              ; Switch back to RAM
+        rts                             ; Return to caller
+.endproc
+
+
index 259fc75400b1c55beb278bd2c1178f7d7b335bc6..680a9611a8c78499850f1a3f86b84358d7e79fa8 100644 (file)
@@ -6,18 +6,22 @@
 ; ---------------------------------------------------------------------------
 ; Zero page, Commodore stuff
 
+TMPPTR          = $22           ; Temporary ptr used by BASIC
 ST             = $90           ; IEC status byte
-
 TIME            = $A3           ; 60HZ clock
 FNAM_LEN               = $AB           ; Length of filename
+LFN             = $AC           ; Logical file number
 SECADR         = $AD           ; Secondary address
 DEVNUM         = $AE           ; Device number
+FNAM_ADR        = $AF           ; Pointer to filename for OPEN
 KEY_COUNT              = $EF           ; Number of keys in input buffer
 CURS_X         = $CA           ; Cursor column
 CURS_Y         = $CD           ; Cursor row
 SCREEN_PTR     = $C8           ; Pointer to current char in text screen
 CRAM_PTR       = $EA           ; Pointer to current char in color RAM
 
+DOS_FN1         = $25E          ; DOS filename buffer #1
+DOS_FN1LEN      = $26E          ; DOS filename length #1
 CHARCOLOR       = $53B
 FKEY_COUNT     = $55D          ; Characters for function key
 FKEY_SPACE     = $55F          ; Function key definitions
@@ -63,5 +67,10 @@ TED_HPOS     = $FF1E
 TED_ROMSEL     = $FF3E
 TED_RAMSEL     = $FF3F
 
+; ---------------------------------------------------------------------------
+; RAM/ROM selection addresses
+
+ENABLE_ROM      = $FF3E
+ENABLE_RAM      = $FF3F