some cleanup

This commit is contained in:
mrdudz
2022-07-21 03:43:54 +02:00
parent a55807f682
commit 86091ac6bf

View File

@@ -3,34 +3,48 @@
;should work for ActionReplay as well...
;
;
;Version 1.0
;
;Johannes Braun 2006-08-22
;hannenz@freenet.de
; original Version 1.0 by Johannes Braun 2006-08-22 <hannenz@freenet.de>
;
;use the functions described in "usr/lib/cc65/include/em.h" to make use of this driver.
;-------------------------------------------------------------------------------------------------------------------------
; ------------------------------------------------------------------------
;NOTE: If called from ROM the Lo_Code routines must exit with LDA #$00 / STA $DE00!!! just change and recompile!
.include "em-kernel.inc"
.importzp ptr1,ptr2,ptr3,ptr4,tmp1
.macpack generic
.include "zeropage.inc"
c64_ram = ptr1 ;use some more expressive identifiers...
.include "em-kernel.inc"
.include "em-error.inc"
.macpack generic
.macpack module
; ------------------------------------------------------------------------
c64_ram = ptr1 ; use some more expressive identifiers...
rr_ram = ptr2
len = ptr3
aux = ptr4
temp = tmp1
Lo_Mem = $0100 ;location of Lo_Code (must be below $1000 or above $e000)
Lo_Mem = $0100 ; location of Lo_Code (must be below $1000 or above $e000)
.segment "JUMPTABLE"
; ------------------------------------------------------------------------
; Header. Includes jump table
.byte $65,$6d,$64 ;Driver signature
.byte EMD_API_VERSION
module_header _c64_rrr_emd
.addr INSTALL ;Jump Table
; Driver signature
.byte $65, $6d, $64 ; "emd"
.byte EMD_API_VERSION ; EM API version number
; Library reference
.addr $0000
; Jump table
.addr INSTALL
.addr UNINSTALL
.addr PAGECOUNT
.addr MAP
@@ -39,13 +53,17 @@ Lo_Mem = $0100 ;location of Lo_Code (must be below $1000 or above
.addr COPYFROM
.addr COPYTO
; ------------------------------------------------------------------------
.bss
window: .res 256 ;the memory window (256 bytes)
window: .res 256 ; the memory window (256 bytes)
.rodata
dummy: .word window ;a "pseudo"-em_copy_struct, used by em_map/ em_commit
.byte 0 ;to pass over to COPYTO/COPYFROM
curpage: .byte $ff ;just this byte is changed according to the desired page
dummy:
.word window ; a "pseudo"-em_copy_struct, used by em_map/ em_commit
.byte 0 ; to pass over to COPYTO/COPYFROM
curpage:
.byte $ff ; just this byte is changed according to the desired page
.byte 0
.word 256
@@ -61,37 +79,37 @@ INSTALL:
sta Lo_Mem,x
dex
bpl :-
stx curpage ;invalidate current page ($ff)
stx curpage ; invalidate current page ($ff)
ldx #$23 ;$de00 value for rr-ram
ldy #$02 ;$de00 value for c64-ram, CHANGE TO LDA #$00 if driver is called from ROM!
ldx #$23 ; $de00 value for rr-ram
ldy #$02 ; $de00 value for c64-ram, CHANGE TO LDA #$00 if driver is called from ROM!
bne COMMON
c1: stx $de00 ;try accessing rr-ram
c1: stx $de00 ; try accessing rr-ram
lda $8888
pha
lda $9999 ;remember old content of $8888 and $9999
lda $9999 ; remember old content of $8888 and $9999
pha
lda #$55
sta $8888 ;write test values
sta $8888 ; write test values
asl
sta $9999
sty $de00 ;switch to c64 ram
sty $de00 ; switch to c64 ram
stx $8888
stx $9999
stx $de00 ;switch to rr-ram again (if present)
ldx $8888 ;read the values
stx $de00 ; switch to rr-ram again (if present)
ldx $8888 ; read the values
ldy $9999
pla
sta $9999 ;and write the old values back
sta $9999 ; and write the old values back
pla
sta $8888
lda #2
sta $de00 ;c64 ram again
sta $de00 ; c64 ram again
cli
cpx #$55
@@ -100,7 +118,7 @@ c1: stx $de00 ;try accessing rr-ram
bne no
lda #0
rts
no: asl ;.A still has #2, so return #4: error code for "device not present"
no: asl ; A still has #2, so return #4: error code for "device not present"
rts
c2:
;----------------------------------------------------------------------------------------
@@ -108,7 +126,8 @@ c2:
;----------------------------------------------------------------------------------------
UNINSTALL:
return_null:
lda #$00 ;always return 32kb (128 pages)
lda #$00 ; always return 32kb (128 pages)
; fall through, skip the LDA
.byte $2c
;----------------------------------------------------------------------------------------
@@ -123,10 +142,11 @@ PAGECOUNT:
;void* __fastcall__ em_use(unsigned page);
;----------------------------------------------------------------------------------------
USE:
cmp #$80 ;valid page?
bcs return_null ;no, return NULL pointer
sta curpage ;set to current page
return_win: lda #<window ;return pointer to window
cmp #$80 ; valid page?
bcs return_null ; no, return NULL pointer
sta curpage ; set to current page
return_win:
lda #<window ; return pointer to window
ldx #>window
return: rts
@@ -137,10 +157,10 @@ MAP:
cmp #$80
bcs return_null
sta curpage
lda #<dummy ;load .A/.X with adress of data for COPYFROM-call (which expects the
ldx #>dummy ;adress in .A/.X)
lda #<dummy ; load .A/.X with adress of data for COPYFROM-call (which expects the
ldx #>dummy ; adress in .A/.X)
jsr COPYFROM
bcs return_win ;function returns pointer to window (returns always with carry set!)
bcs return_win ; function returns pointer to window (returns always with carry set!)
;----------------------------------------------------------------------------------------
;void __fastcall__ em_commit(void);
@@ -149,8 +169,8 @@ COMMIT:
lda curpage
cmp #$80
bcs return
lda #<dummy ;load .A/.X with adress of data for COPYTO-call (which expects the
ldx #>dummy ;adress in .A/.X)
lda #<dummy ; load .A/.X with adress of data for COPYTO-call (which expects the
ldx #>dummy ; adress in .A/.X)
;----------------------------------------------------------------------------------------
;void __fastcall__ em_copyto (struct em_copy *copy_data);
@@ -281,5 +301,6 @@ get_struct_data:
lda (aux),y ;length hi-byte
adc c64_ram+1
sta len+1 ;tmp2: length, tmp3 contains end adress of transfer in c64-ram.
rts ;55 bytes
rts
;55 bytes