]> git.sur5r.net Git - cc65/blobdiff - libsrc/em/em-kernel.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / em / em-kernel.s
index d2920b354a123f0eace09e7c18262001c1018864..9c134296400e7fa3e751c88504028db2051c29bd 100644 (file)
@@ -4,8 +4,6 @@
 ; Common functions of the extended memory API.
 ;
 
-        .export         _em_install, _em_deinstall
-
         .import         return0
         .importzp       ptr1
 
 
 
 .bss
-_em_drv:        .res    2                      ; Pointer to driver
+_em_drv:        .res    2               ; Pointer to driver
 
 ; Jump table for the driver functions.
 .data
 emd_vectors:
-emd_install:           jmp     $0000
-emd_deinstall:         jmp     $0000
-emd_pagecount:  jmp     $0000
-emd_map:        jmp     $0000
-emd_commit:     jmp     $0000
-emd_copyfrom:  jmp     $0000
-emd_copyto:     jmp     $0000
+emd_install:    jmp     return0
+emd_uninstall:  jmp     return0
+emd_pagecount:  jmp     return0
+emd_map:        jmp     return0
+emd_use:        jmp     return0
+emd_commit:     jmp     return0
+emd_copyfrom:   jmp     return0
+emd_copyto:     jmp     return0
 
 ; Driver header signature
 .rodata
-emd_sig:        .byte   $65, $6d, $64, $00      ; "emd", version
-emd_sig_len     = * - emd_sig
+emd_sig:        .byte   $65, $6d, $64, EMD_API_VERSION  ; "emd", version
 
 
 ;----------------------------------------------------------------------------
@@ -43,14 +41,14 @@ emd_sig_len     = * - emd_sig
 
 
 _em_install:
-               sta     _em_drv
-       sta     ptr1
-       stx     _em_drv+1
-       stx     ptr1+1
+        sta     _em_drv
+        sta     ptr1
+        stx     _em_drv+1
+        stx     ptr1+1
 
 ; Check the driver signature
 
-        ldy     #emd_sig_len-1
+        ldy     #.sizeof(emd_sig)-1
 @L0:    lda     (ptr1),y
         cmp     emd_sig,y
         bne     inv_drv
@@ -59,12 +57,12 @@ _em_install:
 
 ; Copy the jump vectors
 
-        ldy     #EMD_HDR_JUMPTAB
+        ldy     #EMD_HDR::JUMPTAB
         ldx     #0
 @L1:    inx                             ; Skip the JMP opcode
         jsr     copy                    ; Copy one byte
         jsr     copy                    ; Copy one byte
-        cpx     #(EMD_HDR_JUMPCOUNT*3)
+        cpy     #(EMD_HDR::JUMPTAB + .sizeof(EMD_HDR::JUMPTAB))
         bne     @L1
 
         jmp     emd_install             ; Call driver install routine
@@ -79,29 +77,24 @@ inv_drv:
 ; Copy one byte from the jump vectors
 
 copy:   lda     (ptr1),y
+        sta     emd_vectors,x
         iny
-set:    sta     emd_vectors,x
         inx
         rts
 
 ;----------------------------------------------------------------------------
-; void __fastcall__ em_deinstall (void);
-; /* Deinstall the driver before unloading it */
-
-_em_deinstall:
-        jsr     emd_deinstall           ; Call driver routine
+; unsigned char em_uninstall (void);
+; /* Uninstall the currently loaded driver and return an error code.
+;  * Note: This call does not free allocated memory.
+;  */
 
-; Point all jump vectors to return0
-
-        ldx     #0
-@L1:    inx                             ; Skip JMP opcode
-        lda     #<return0
-        jsr     set
-        lda     #>return0
-        jsr     set
-        cpx     #(EMD_HDR_JUMPCOUNT*3)
-        bne     @L1
-
-        rts
+_em_uninstall:
+        jsr     emd_uninstall           ; Call driver routine
 
+em_clear_ptr:                           ; External entry point
+        lda     #0
+        sta     _em_drv
+        sta     _em_drv+1               ; Clear the driver pointer
 
+        tax
+        rts                             ; Return zero