; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; Get the page number from the struct and adjust it so that it may be used
; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
- ldy #EM_COPY_PAGE+1
+ ldy #EM_COPY::PAGE+1
lda (ptr1),y
sta tmp2
dey
; Get the buffer pointer into ptr2
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr1),y
sta ptr2
iny
lda (ptr1),y
- sta ptr2+1
+ sta ptr2+1
; Get the count, calculate -(count-1) and store it into ptr3
- ldy #EM_COPY_COUNT
+ ldy #EM_COPY::COUNT
lda (ptr1),y
eor #$FF
sta ptr3
; Get the page offset into X and clear Y
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr1),y
tax
ldy #$00
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
clc
adc #>BASE
sta ptr1+1 ; From
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr2
iny
lda #<ptr1
sta FETVEC
- ldy #EM_COPY_COUNT+1
+ ldy #EM_COPY::COUNT+1
lda (ptr3),y ; Get number of pages
beq @L2 ; Skip if no full pages
sta tmp1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
sta tmp1
COPYTO: sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
clc
adc #>BASE
sta ptr1+1 ; To
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr2
iny
lda #<ptr1
sta STAVEC
- ldy #EM_COPY_COUNT+1
+ ldy #EM_COPY::COUNT+1
lda (ptr3),y ; Get number of pages
beq @L2 ; Skip if no full pages
sta tmp1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
sta tmp1
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; Get the page number from the struct and adjust it so that it may be used
; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
- ldy #EM_COPY_PAGE+1
+ ldy #EM_COPY::PAGE+1
lda (ptr1),y
sta tmp2
dey
; Get the buffer pointer into ptr2
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr1),y
sta ptr2
iny
; Get the count, calculate -(count-1) and store it into ptr3
- ldy #EM_COPY_COUNT
+ ldy #EM_COPY::COUNT
lda (ptr1),y
eor #$FF
sta ptr3
; Get the page offset into X and clear Y
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr1),y
tax
ldy #$00
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
jsr setup
beq @L2 ; Skip if no full pages
-; Copy full pages
+; Copy full pages
@L1: jsr transferin
inc ptr1+1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
sta tmp1
jsr setup
beq @L2 ; Skip if no full pages
-; Copy full pages
+; Copy full pages
@L1: jsr transferout
inc ptr1+1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
sta tmp1
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
sta ptr1+1 ; From
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr2
iny
lda (ptr3),y
sta ptr2+1 ; To
- ldy #EM_COPY_COUNT+1
+ ldy #EM_COPY::COUNT+1
lda (ptr3),y ; Get number of pages
sta tmp1
rts
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
add #>BASE
sta ptr1+1 ; From
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr2
iny
lda (ptr3),y
sta ptr2+1 ; To
-common: ldy #EM_COPY_COUNT+1
+common: ldy #EM_COPY::COUNT+1
lda (ptr3),y ; Get number of pages
beq @L2 ; Skip if no full pages
sta tmp1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
tax
COPYTO: sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr2
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
add #>BASE
sta ptr2+1 ; To
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr1
iny
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; The GeoRAM cartridge does not copy but actually map the window, so USE is
; identical to MAP.
-USE = MAP
+USE = MAP
; ------------------------------------------------------------------------
; MAP: Map the page in a/x into memory and return a pointer to the page in
; Get the page number from the struct and adjust it so that it may be used
; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
- ldy #EM_COPY_PAGE+1
+ ldy #EM_COPY::PAGE+1
lda (ptr1),y
sta tmp2
dey
; Get the buffer pointer into ptr2
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr1),y
sta ptr2
iny
; Get the count, calculate -(count-1) and store it into ptr3
- ldy #EM_COPY_COUNT
+ ldy #EM_COPY::COUNT
lda (ptr1),y
eor #$FF
sta ptr3
; Get the page offset into X and clear Y
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr1),y
tax
ldy #$00
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; Done
-done: rts
+done: rts
; ------------------------------------------------------------------------
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
COPYFROM:
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
-
- ldy #EM_COPY_OFFS
+
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
clc
adc #>BASE
sta ptr1+1 ; From
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr2
iny
lda (ptr3),y
sta ptr2+1 ; To
-common: ldy #EM_COPY_COUNT+1
+common: ldy #EM_COPY::COUNT+1
lda (ptr3),y ; Get number of pages
beq @L2 ; Skip if no full pages
sta tmp1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
tax
COPYTO: sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr2
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
clc
adc #>BASE
sta ptr2+1 ; To
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr1
iny
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; Get the page number from the struct and adjust it so that it may be used
; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
- ldy #EM_COPY_PAGE+1
+ ldy #EM_COPY::PAGE+1
lda (ptr1),y
sta tmp2
dey
; Get the buffer pointer into ptr2
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr1),y
sta ptr2
iny
; Get the count, calculate -(count-1) and store it into ptr3
- ldy #EM_COPY_COUNT
+ ldy #EM_COPY::COUNT
lda (ptr1),y
eor #$FF
sta ptr3
; Get the page offset into X and clear Y
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr1),y
tax
ldy #$00
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; ------------------------------------------------------------------------
; USE: Tell the driver that the window is now associated with a given page.
-
+
USE: sta curpage
stx curpage+1 ; Remember the page
lda #<window
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
sta tmp1
; Copy the remainder of the page
-@L2: ldy #EM_COPY_COUNT
+@L2: ldy #EM_COPY::COUNT
lda (ptr3),y ; Get bytes in last page
beq @L4
sta tmp1
sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
sta ptr1+1 ; From
- ldy #EM_COPY_BUF
+ ldy #EM_COPY::BUF
lda (ptr3),y
sta ptr2
iny
lda (ptr3),y
sta ptr2+1 ; To
- ldy #EM_COPY_COUNT+1
+ ldy #EM_COPY::COUNT+1
lda (ptr3),y ; Get number of pages
sta tmp1
rts
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
lda #<EM_ERR_OK
ldx #>EM_ERR_OK
- rts
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
setup: sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
add #OFFS
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
adc #$00
sta ptr1+1
- ldy #EM_COPY_COUNT
+ 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
+ ldy #EM_COPY::BUF+1
lda (ptr1),y
tax
dey
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
lda #<EM_ERR_OK
ldx #>EM_ERR_OK
- rts
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
setup: sta ptr3
stx ptr3+1 ; Save the passed em_copy pointer
- ldy #EM_COPY_OFFS
+ ldy #EM_COPY::OFFS
lda (ptr3),y
add #OFFS
sta ptr1
- ldy #EM_COPY_PAGE
+ ldy #EM_COPY::PAGE
lda (ptr3),y
adc #$00
sta ptr1+1
- ldy #EM_COPY_COUNT
+ 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
+ ldy #EM_COPY::BUF+1
lda (ptr1),y
tax
dey
; 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
;----------------------------------------------------------------------------
; 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
; 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