Added VERA peek() and poke() to the cx16 library.

They simplify C programs' direct access to VERA's internal address space.
This commit is contained in:
Greg King
2019-10-24 05:15:42 -04:00
parent 1074d35a15
commit 9fa90e2265
4 changed files with 74 additions and 5 deletions

19
libsrc/cx16/vpeek.s Normal file
View File

@@ -0,0 +1,19 @@
;
; 2019-10-22, Greg King
;
; unsigned char fastcall vpeek (unsigned long addr);
; /* Get a byte from a location in VERA's internal address space. */
;
.export _vpeek
.import vset
.include "cx16.inc"
_vpeek: php ; (vset blocks interrupts)
jsr vset ; put VERA's address
ldx #>$0000
lda VERA::DATA0 ; read VERA port zero
plp
rts

21
libsrc/cx16/vpoke.s Normal file
View File

@@ -0,0 +1,21 @@
;
; 2019-10-22, Greg King
;
; void fastcall vpoke (unsigned char data, unsigned long addr);
; /* Put a byte into a location in VERA's internal address space.
; ** (addr is second instead of first for the sake of code efficiency.)
; */
;
.export _vpoke
.import vset, popa
.include "cx16.inc"
_vpoke: php ; (vset blocks interrupts)
jsr vset ; put VERA's address
jsr popa
sta VERA::DATA0 ; write data to VERA port zero
plp
rts

20
libsrc/cx16/vset.s Normal file
View File

@@ -0,0 +1,20 @@
;
; 2019-10-22, Greg King
;
; Set the __far__ address that VERA will use for data access.
; This is a support function for the fastcall functions vpeek() and vpoke().
;
.export vset
.importzp sreg
.include "cx16.inc"
vset: ldy sreg
sei ; don't let interrupt handlers interfere
stz VERA::CTRL ; set address for VERA's data port zero
sta VERA::ADDR
stx VERA::ADDR+1
sty VERA::ADDR+2
rts