]> git.sur5r.net Git - cc65/commitdiff
Added EMD drivers for the Commodore B machines.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 10 Dec 2002 10:30:01 +0000 (10:30 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 10 Dec 2002 10:30:01 +0000 (10:30 +0000)
Note: These drivers are currently untested because I didn't realize that
using the drivers would need file routines, which are not available right
now. So in fact the drivers are not only untested, they are also unusable
on the target platforms, because they cannot be loaded.

git-svn-id: svn://svn.cc65.org/cc65/trunk@1732 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/Makefile
libsrc/cbm510/.cvsignore [new file with mode: 0644]
libsrc/cbm510/Makefile
libsrc/cbm510/cbm510-ram.s [new file with mode: 0644]
libsrc/cbm610/.cvsignore [new file with mode: 0644]
libsrc/cbm610/Makefile
libsrc/cbm610/cbm610-ram.s [new file with mode: 0644]

index 6d77ab1a35d73899487e637508d711bb3e59bd71..7622c42691d4210df50271cb06fb7f545510065c 100644 (file)
@@ -155,12 +155,13 @@ cbm510lib:
            $(AR) a cbm510.lib $$i/*.o;\
        done
        mv cbm510/crt0.o cbm510.o
+       cp cbm510/*.emd .
 
 #-----------------------------------------------------------------------------
 # PET-II series
 
 cbm610lib:
-       for i in cbm610 cbm common runtime conio dbg; do \
+       for i in cbm610 cbm common runtime conio dbg em; do \
            CC=$(CC) \
            AS=$(AS) \
            LD=$(LD) \
@@ -170,6 +171,7 @@ cbm610lib:
            $(AR) a cbm610.lib $$i/*.o;\
        done
        mv cbm610/crt0.o cbm610.o
+       cp cbm610/*.emd .
 
 #-----------------------------------------------------------------------------
 # GEOS on the C64/128
diff --git a/libsrc/cbm510/.cvsignore b/libsrc/cbm510/.cvsignore
new file mode 100644 (file)
index 0000000..7cbbb3d
--- /dev/null
@@ -0,0 +1,3 @@
+*.emd
+*.tgi
+     
index e7e1b8494441cee07c14bce48dff21399f0a9e21..e37d72bbe00c7c85a95e859e09baceedc6dd630f 100644 (file)
@@ -4,6 +4,25 @@
 
 .SUFFIXES: .o .s .c
 
+#--------------------------------------------------------------------------
+# Rules
+
+%.o:           %.c
+       @$(CC) $(CFLAGS) $<
+       @$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o:   %.s
+       @$(AS) -g -o $@ $(AFLAGS) $<
+
+%.emd: %.o ../runtime/zeropage.o
+       @$(LD) -t module -o $@ $^
+
+%.tgi: %.o ../runtime/zeropage.o
+       @$(LD) -t module -o $@ $^
+
+#--------------------------------------------------------------------------
+# Object files
+
 %.o:           %.c
        @$(CC) $(CFLAGS) $<
        @$(AS) -o $@ $(AFLAGS) $(*).s
@@ -33,8 +52,21 @@ OBJS =       _scrsize.o      \
        rs232.o         \
        tgi_mode_table.o
 
-all:   $(OBJS)
+#--------------------------------------------------------------------------
+# Drivers
+
+TGIS =
+
+EMDS = cbm510-ram.emd
+
+#--------------------------------------------------------------------------
+# Targets
+
+all:   $(OBJS) $(EMDS) $(TGIS)
+
+../runtime/zeropage.o:
+       $(MAKE) -C $(dir $@) $(notdir $@)
 
 clean:
-       @rm -f $(OBJS)
+       @rm -f $(OBJS) $(EMDS:.emd=.o) $(TGIS:.tgi=.o)
 
diff --git a/libsrc/cbm510/cbm510-ram.s b/libsrc/cbm510/cbm510-ram.s
new file mode 100644 (file)
index 0000000..885e0f5
--- /dev/null
@@ -0,0 +1,319 @@
+;
+; Extended memory driver for the CBM510 additional RAM banks
+;
+; Ullrich von Bassewitz, 2002-12-09        !!! UNTESTED !!!
+;
+
+       .include        "zeropage.inc"
+
+       .include        "em-kernel.inc"
+        .include        "em-error.inc"
+        .include        "cbm510.inc"
+
+        .macpack        generic
+
+
+; ------------------------------------------------------------------------
+; Header. Includes jump table
+
+.segment        "JUMPTABLE"
+
+; Driver signature
+
+        .byte   $65, $6d, $64           ; "emd"
+        .byte   $00                     ; EM API version number
+
+; Jump table.
+
+        .word   INSTALL
+        .word   DEINSTALL
+        .word   PAGECOUNT
+        .word   MAP
+        .word   USE
+        .word   COMMIT
+       .word   COPYFROM
+        .word   COPYTO
+
+; ------------------------------------------------------------------------
+; Constants
+
+RAMBANK = 2
+OFFS    = 2
+
+; ------------------------------------------------------------------------
+; Data.
+
+.data
+curpage:        .byte  $FF             ; Current page number (invalid)
+
+.bss
+window:         .res    256             ; Memory "window"
+pagecount:     .res    1               ; Number of available pages
+
+
+.code
+
+; ------------------------------------------------------------------------
+; INSTALL routine. Is called after the driver is loaded into memory. If
+; possible, check if the hardware is present and determine the amount of
+; memory available.
+; Must return an EM_ERR_xx code in a/x.
+;
+
+INSTALL:
+               lda     #$FF
+
+       ldx     UsrMemTop+2
+       cpx     #RAMBANK                ; Top of memory in bank 2?
+        bne     @L1                     ; No: We can use all the memory
+        clc
+        adc     UsrMemTop+1
+@L1:    sta     pagecount
+
+        lda     #<EM_ERR_OK
+        ldx     #>EM_ERR_OK
+        rts
+
+; ------------------------------------------------------------------------
+; DEINSTALL routine. Is called before the driver is removed from memory.
+; Can do cleanup or whatever. Must not return anything.
+;
+
+DEINSTALL:
+        rts
+
+
+; ------------------------------------------------------------------------
+; PAGECOUNT: Return the total number of available pages in a/x.
+;
+
+PAGECOUNT:
+        lda     pagecount
+        ldx     #0
+        rts
+
+; ------------------------------------------------------------------------
+; MAP: Map the page in a/x into memory and return a pointer to the page in
+; a/x. The contents of the currently mapped page (if any) may be discarded
+; by the driver.
+;
+
+MAP:    sta     curpage                        ; Remember the new page
+
+        sta    ptr1+1
+        lda    #OFFS
+        sta            ptr1
+
+; Transfer one page
+
+        ldx     IndReg
+        lda     #RAMBANK
+        sta     IndReg
+
+        ldy     #$00
+@L1:    lda     (ptr1),y
+        sta     window,y
+        iny
+        lda     (ptr1),y
+        sta     window,y
+        iny
+        bne     @L1
+
+        stx     IndReg
+
+; Return the memory window
+
+        lda     #<window
+        ldx     #>window                ; Return the window address
+        rts
+
+; ------------------------------------------------------------------------
+; USE: Tell the driver that the window is now associated with a given page.
+
+USE:    sta     curpage                 ; Remember the page
+        lda     #<window
+        ldx     #>window                ; Return the window
+        rts
+
+; ------------------------------------------------------------------------
+; COMMIT: Commit changes in the memory window to extended storage.
+
+COMMIT: lda     curpage                        ; Get the current page
+        cmp     #$FF
+        beq     done                    ; Jump if no page mapped
+
+        sta     ptr1+1
+        lda     #OFFS
+        sta     ptr1
+
+; Transfer one page
+
+        ldx     IndReg
+        lda     #RAMBANK
+        sta     IndReg
+
+        ldy     #$00
+@L1:    lda     window,y
+        sta     (ptr1),y
+        iny
+        lda     window,y
+        sta     (ptr1),y
+        iny
+        bne     @L1
+
+        stx     IndReg
+
+; Done
+
+done:   rts
+
+; ------------------------------------------------------------------------
+; COPYFROM: Copy from extended into linear memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYFROM:
+        jsr     setup
+
+; Setup the buffer address in this bank.
+
+        sta     copyfrom_buf
+        stx     copyfrom_buf+1
+
+; Check if we must copy full pages
+
+        ldx     ptr2+1
+        beq     @L2
+
+; Copy full pages
+
+        ldx     #$00
+@L1:    jsr     copyfrom
+        inc     ptr1+1
+        inc     copyfrom_buf+1
+@L2:    dec     ptr2+1
+        bne     @L1
+
+; Copy the remaining page
+
+        ldx     ptr2
+        beq     @L3
+
+        jsr     copyfrom
+
+; Restore the indirect segment
+
+@L3:    lda     ExecReg
+        sta     IndReg
+
+; Done
+
+        rts
+
+
+; ------------------------------------------------------------------------
+; COPYTO: Copy from linear into extended memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYTO: jsr     setup
+
+; Setup the buffer address in this bank.
+
+        sta     copyto_buf
+        stx     copyto_buf+1
+
+; Check if we must copy full pages
+
+        ldx     ptr2+1
+        beq     @L2
+
+; Copy full pages
+
+        ldx     #$00
+@L1:    jsr     copyto
+        inc     ptr1+1
+        inc     copyto_buf+1
+@L2:    dec     ptr2+1
+        bne     @L1
+
+; Copy the remaining page
+
+        ldx     ptr2
+        beq     @L3
+
+        jsr     copyto
+
+; Restore the indirect segment
+
+@L3:    lda     ExecReg
+        sta     IndReg
+
+; Done
+
+        rts
+
+; ------------------------------------------------------------------------
+; setup: Helper function for COPYFROM and COPYTO, will setup parameters.
+;
+
+setup:  sta     ptr3
+        stx     ptr3+1                  ; Save the passed em_copy pointer
+
+        ldy     #EM_COPY_OFFS
+        lda     (ptr3),y
+        add     #OFFS
+        sta     ptr1
+        ldy     #EM_COPY_PAGE
+        lda     (ptr3),y
+        adc     #$00
+        sta     ptr1+1
+
+        ldy     #EM_COPY_COUNT
+        lda     (ptr3),y
+        sta     ptr2
+        iny
+        lda     (ptr3),y
+        sta     ptr2+1                  ; Get count into ptr2
+
+        ldy     #EM_COPY_BUF+1
+        lda     (ptr1),y
+        tax
+        dey
+        lda     (ptr1),y                ; Get the buffer pointer into a/x
+
+        ldy     #RAMBANK
+        sty     IndReg
+
+        ldy     #$00
+
+        rts
+
+; ------------------------------------------------------------------------
+; copyfrom
+
+.data
+copyfrom:
+        lda     (ptr1),y
+copyfrom_buf = * + 1
+        sta     $0000,y
+        iny
+        dex
+        bne     copyfrom
+        rts
+
+; ------------------------------------------------------------------------
+; copyto
+
+.data
+copyto:
+copyto_buf = * + 1
+        lda     $0000,y
+        sta     (ptr1),y
+        iny
+        dex
+        bne     copyto
+        rts
+
diff --git a/libsrc/cbm610/.cvsignore b/libsrc/cbm610/.cvsignore
new file mode 100644 (file)
index 0000000..7cbbb3d
--- /dev/null
@@ -0,0 +1,3 @@
+*.emd
+*.tgi
+     
index 4967dd7bb27fae11f3d824727a1a2e6ab7c6ac0c..ccd841b2cbdbc94324c93137a40252e2a3c51685 100644 (file)
@@ -4,6 +4,9 @@
 
 .SUFFIXES: .o .s .c
 
+#--------------------------------------------------------------------------
+# Rules
+
 %.o:           %.c
        @$(CC) $(CFLAGS) $<
        @$(AS) -o $@ $(AFLAGS) $(*).s
 %.o:   %.s
        @$(AS) -g -o $@ $(AFLAGS) $<
 
+%.emd: %.o ../runtime/zeropage.o
+       @$(LD) -t module -o $@ $^
+
+%.tgi: %.o ../runtime/zeropage.o
+       @$(LD) -t module -o $@ $^
+
+#--------------------------------------------------------------------------
+# Object files
+
 OBJS = _scrsize.o      \
        banking.o       \
                break.o         \
@@ -30,8 +42,21 @@ OBJS =       _scrsize.o      \
         randomize.o     \
        rs232.o
 
-all:   $(OBJS)
+#--------------------------------------------------------------------------
+# Drivers
+
+TGIS =
+
+EMDS = cbm610-ram.emd
+
+#--------------------------------------------------------------------------
+# Targets
+
+all:   $(OBJS) $(EMDS) $(TGIS)
+
+../runtime/zeropage.o:
+       $(MAKE) -C $(dir $@) $(notdir $@)
 
 clean:
-       @rm -f $(OBJS)
+       @rm -f $(OBJS) $(EMDS:.emd=.o) $(TGIS:.tgi=.o)
 
diff --git a/libsrc/cbm610/cbm610-ram.s b/libsrc/cbm610/cbm610-ram.s
new file mode 100644 (file)
index 0000000..79a496d
--- /dev/null
@@ -0,0 +1,319 @@
+;
+; Extended memory driver for the CBM610 additional RAM banks
+;
+; Ullrich von Bassewitz, 2002-12-09        !!! UNTESTED !!!
+;
+
+       .include        "zeropage.inc"
+
+       .include        "em-kernel.inc"
+        .include        "em-error.inc"
+        .include        "cbm610.inc"
+
+        .macpack        generic
+
+
+; ------------------------------------------------------------------------
+; Header. Includes jump table
+
+.segment        "JUMPTABLE"
+
+; Driver signature
+
+        .byte   $65, $6d, $64           ; "emd"
+        .byte   $00                     ; EM API version number
+
+; Jump table.
+
+        .word   INSTALL
+        .word   DEINSTALL
+        .word   PAGECOUNT
+        .word   MAP
+        .word   USE
+        .word   COMMIT
+       .word   COPYFROM
+        .word   COPYTO
+
+; ------------------------------------------------------------------------
+; Constants
+
+RAMBANK = 2
+OFFS    = 2
+
+; ------------------------------------------------------------------------
+; Data.
+
+.data
+curpage:        .byte  $FF             ; Current page number (invalid)
+
+.bss
+window:         .res    256             ; Memory "window"
+pagecount:     .res    1               ; Number of available pages
+
+
+.code
+
+; ------------------------------------------------------------------------
+; INSTALL routine. Is called after the driver is loaded into memory. If
+; possible, check if the hardware is present and determine the amount of
+; memory available.
+; Must return an EM_ERR_xx code in a/x.
+;
+
+INSTALL:
+               lda     #$FF
+
+       ldx     UsrMemTop+2
+       cpx     #RAMBANK                ; Top of memory in bank 2?
+        bne     @L1                     ; No: We can use all the memory
+        clc
+        adc     UsrMemTop+1
+@L1:    sta     pagecount
+
+        lda     #<EM_ERR_OK
+        ldx     #>EM_ERR_OK
+        rts
+
+; ------------------------------------------------------------------------
+; DEINSTALL routine. Is called before the driver is removed from memory.
+; Can do cleanup or whatever. Must not return anything.
+;
+
+DEINSTALL:
+        rts
+
+
+; ------------------------------------------------------------------------
+; PAGECOUNT: Return the total number of available pages in a/x.
+;
+
+PAGECOUNT:
+        lda     pagecount
+        ldx     #0
+        rts
+
+; ------------------------------------------------------------------------
+; MAP: Map the page in a/x into memory and return a pointer to the page in
+; a/x. The contents of the currently mapped page (if any) may be discarded
+; by the driver.
+;
+
+MAP:    sta     curpage                        ; Remember the new page
+
+        sta    ptr1+1
+        lda    #OFFS
+        sta            ptr1
+
+; Transfer one page
+
+        ldx     IndReg
+        lda     #RAMBANK
+        sta     IndReg
+
+        ldy     #$00
+@L1:    lda     (ptr1),y
+        sta     window,y
+        iny
+        lda     (ptr1),y
+        sta     window,y
+        iny
+        bne     @L1
+
+        stx     IndReg
+
+; Return the memory window
+
+        lda     #<window
+        ldx     #>window                ; Return the window address
+        rts
+
+; ------------------------------------------------------------------------
+; USE: Tell the driver that the window is now associated with a given page.
+
+USE:    sta     curpage                 ; Remember the page
+        lda     #<window
+        ldx     #>window                ; Return the window
+        rts
+
+; ------------------------------------------------------------------------
+; COMMIT: Commit changes in the memory window to extended storage.
+
+COMMIT: lda     curpage                        ; Get the current page
+        cmp     #$FF
+        beq     done                    ; Jump if no page mapped
+
+        sta     ptr1+1
+        lda     #OFFS
+        sta     ptr1
+
+; Transfer one page
+
+        ldx     IndReg
+        lda     #RAMBANK
+        sta     IndReg
+
+        ldy     #$00
+@L1:    lda     window,y
+        sta     (ptr1),y
+        iny
+        lda     window,y
+        sta     (ptr1),y
+        iny
+        bne     @L1
+
+        stx     IndReg
+
+; Done
+
+done:   rts
+
+; ------------------------------------------------------------------------
+; COPYFROM: Copy from extended into linear memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYFROM:
+        jsr     setup
+
+; Setup the buffer address in this bank.
+
+        sta     copyfrom_buf
+        stx     copyfrom_buf+1
+
+; Check if we must copy full pages
+
+        ldx     ptr2+1
+        beq     @L2
+
+; Copy full pages
+
+        ldx     #$00
+@L1:    jsr     copyfrom
+        inc     ptr1+1
+        inc     copyfrom_buf+1
+@L2:    dec     ptr2+1
+        bne     @L1
+
+; Copy the remaining page
+
+        ldx     ptr2
+        beq     @L3
+
+        jsr     copyfrom
+
+; Restore the indirect segment
+
+@L3:    lda     ExecReg
+        sta     IndReg
+
+; Done
+
+        rts
+
+
+; ------------------------------------------------------------------------
+; COPYTO: Copy from linear into extended memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYTO: jsr     setup
+
+; Setup the buffer address in this bank.
+
+        sta     copyto_buf
+        stx     copyto_buf+1
+
+; Check if we must copy full pages
+
+        ldx     ptr2+1
+        beq     @L2
+
+; Copy full pages
+
+        ldx     #$00
+@L1:    jsr     copyto
+        inc     ptr1+1
+        inc     copyto_buf+1
+@L2:    dec     ptr2+1
+        bne     @L1
+
+; Copy the remaining page
+
+        ldx     ptr2
+        beq     @L3
+
+        jsr     copyto
+
+; Restore the indirect segment
+
+@L3:    lda     ExecReg
+        sta     IndReg
+
+; Done
+
+        rts
+
+; ------------------------------------------------------------------------
+; setup: Helper function for COPYFROM and COPYTO, will setup parameters.
+;
+
+setup:  sta     ptr3
+        stx     ptr3+1                  ; Save the passed em_copy pointer
+
+        ldy     #EM_COPY_OFFS
+        lda     (ptr3),y
+        add     #OFFS
+        sta     ptr1
+        ldy     #EM_COPY_PAGE
+        lda     (ptr3),y
+        adc     #$00
+        sta     ptr1+1
+
+        ldy     #EM_COPY_COUNT
+        lda     (ptr3),y
+        sta     ptr2
+        iny
+        lda     (ptr3),y
+        sta     ptr2+1                  ; Get count into ptr2
+
+        ldy     #EM_COPY_BUF+1
+        lda     (ptr1),y
+        tax
+        dey
+        lda     (ptr1),y                ; Get the buffer pointer into a/x
+
+        ldy     #RAMBANK
+        sty     IndReg
+
+        ldy     #$00
+
+        rts
+
+; ------------------------------------------------------------------------
+; copyfrom
+
+.data
+copyfrom:
+        lda     (ptr1),y
+copyfrom_buf = * + 1
+        sta     $0000,y
+        iny
+        dex
+        bne     copyfrom
+        rts
+
+; ------------------------------------------------------------------------
+; copyto
+
+.data
+copyto:
+copyto_buf = * + 1
+        lda     $0000,y
+        sta     (ptr1),y
+        iny
+        dex
+        bne     copyto
+        rts
+