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:
@@ -144,9 +144,10 @@ struct __emul {
|
|||||||
unsigned char debug; /* Boolean: debugging enabled */
|
unsigned char debug; /* Boolean: debugging enabled */
|
||||||
unsigned char vera_action; /* Boolean: displaying VERA activity */
|
unsigned char vera_action; /* Boolean: displaying VERA activity */
|
||||||
unsigned char keyboard; /* Boolean: displaying typed keys */
|
unsigned char keyboard; /* Boolean: displaying typed keys */
|
||||||
unsigned char echo; /* Boolean: Kernal output echoed to host */
|
unsigned char echo; /* How Kernal output should be echoed to host */
|
||||||
unsigned char save_on_exit; /* Boolean: save SD card when quitting */
|
unsigned char save_on_exit; /* Boolean: save SD card when quitting */
|
||||||
unsigned char unused[0xD - 0x5];
|
unsigned char gif_method; /* How GIF movie is being recorded */
|
||||||
|
unsigned char unused[0xD - 0x6];
|
||||||
unsigned char keymap; /* Keyboard layout number */
|
unsigned char keymap; /* Keyboard layout number */
|
||||||
const char detect[2]; /* "16" if running on x16emu */
|
const char detect[2]; /* "16" if running on x16emu */
|
||||||
};
|
};
|
||||||
@@ -173,16 +174,24 @@ signed char get_ostype (void);
|
|||||||
** Positive -- release build
|
** Positive -- release build
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void __fastcall__ set_tv (unsigned char);
|
void __fastcall__ set_tv (unsigned char type);
|
||||||
/* Set the video mode the machine will use.
|
/* Set the video type that the machine will use.
|
||||||
** Call with a TV_xx constant.
|
** Call with a TV_xx constant.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned char __fastcall__ videomode (unsigned char Mode);
|
unsigned char __fastcall__ videomode (unsigned char mode);
|
||||||
/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
|
/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
|
||||||
** constants.
|
** constants.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
unsigned char __fastcall__ vpeek (unsigned long addr);
|
||||||
|
/* Get a byte from a location in VERA's internal address space. */
|
||||||
|
|
||||||
|
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.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of cX16.h */
|
/* End of cX16.h */
|
||||||
|
|||||||
19
libsrc/cx16/vpeek.s
Normal file
19
libsrc/cx16/vpeek.s
Normal 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
21
libsrc/cx16/vpoke.s
Normal 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
20
libsrc/cx16/vset.s
Normal 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
|
||||||
Reference in New Issue
Block a user