Updated the cx16 library to the Commander X16's ROM prerelease 37.

This commit is contained in:
Greg King
2020-05-02 13:46:06 -04:00
parent 31daa706b7
commit cbf0c1d1dd
17 changed files with 447 additions and 233 deletions

View File

@@ -1,5 +1,5 @@
;
; 2019-09-23, Greg King
; 2020-05-02, Greg King
;
; unsigned char __fastcall__ bordercolor (unsigned char color);
; /* Set the color for the border. The old color setting is returned. */
@@ -11,17 +11,7 @@
_bordercolor:
tax
; Point to the border color register.
stz VERA::CTRL ; Use port 0
lda #<VERA::COMPOSER::FRAME
sta VERA::ADDR
lda #>VERA::COMPOSER::FRAME
sta VERA::ADDR+1
ldy #^VERA::COMPOSER::FRAME | VERA::INC0
sty VERA::ADDR+2
lda VERA::DATA0 ; get old value
stx VERA::DATA0 ; set new value
stz VERA::CTRL ; Use display register bank 0
lda VERA::DISP::FRAME ; get old value
stx VERA::DISP::FRAME ; set new value
rts

View File

@@ -1,6 +1,6 @@
;
; 2016-02-28, Groepaz
; 2019-09-25, Greg King
; 2020-04-29, Greg King
;
; char cpeekc (void);
; /* Return the character from the current cursor position. */
@@ -12,8 +12,6 @@
_cpeekc:
php
sei ; don't let cursor blinking interfere
stz VERA::CTRL ; use port 0
lda CURS_Y
sta VERA::ADDR+1 ; set row number
@@ -22,7 +20,6 @@ _cpeekc:
asl a ; each character has two bytes
sta VERA::ADDR
lda VERA::DATA0 ; get screen code
plp
ldx #>$0000
and #<~%10000000 ; remove reverse bit

View File

@@ -1,5 +1,5 @@
;
; 2019-09-25, Greg King
; 2020-04-30, Greg King
;
; unsigned char cpeekcolor (void);
; /* Return the colors from the current cursor position. */
@@ -12,8 +12,15 @@
_cpeekcolor:
php
lda CURS_FLAG ; is the cursor currently off?
bne @L1
sei ; don't let cursor blinking interfere
stz VERA::CTRL ; use port 0
ldx CURS_STATE ; is cursor currently displayed?
beq @L1 ; jump if not
lda CURS_COLOR ; get color under cursor
bra @L2
@L1: stz VERA::CTRL ; use port 0
lda CURS_Y
sta VERA::ADDR+1 ; set row number
stz VERA::ADDR+2
@@ -21,7 +28,7 @@ _cpeekcolor:
sec ; color attribute is second byte
rol a
sta VERA::ADDR
lda VERA::DATA0 ; get color
plp
lda VERA::DATA0 ; get color of character
@L2: plp
ldx #>$0000
rts

View File

@@ -1,6 +1,6 @@
;
; 2016-02-28, Groepaz
; 2019-09-25, Greg King
; 2020-04-30, Greg King
;
; unsigned char cpeekrevers (void);
; /* Return the reverse attribute from the current cursor position.
@@ -15,8 +15,15 @@
_cpeekrevers:
php
lda CURS_FLAG ; is the cursor currently off?
bne @L1
sei ; don't let cursor blinking interfere
stz VERA::CTRL ; use port 0
ldx CURS_STATE ; is cursor currently displayed?
beq @L1 ; jump if not
lda CURS_CHAR ; get screen code under cursor
bra @L2
@L1: stz VERA::CTRL ; use port 0
lda CURS_Y
sta VERA::ADDR+1 ; set row number
stz VERA::ADDR+2
@@ -24,7 +31,7 @@ _cpeekrevers:
asl a ; each character has two bytes
sta VERA::ADDR
lda VERA::DATA0 ; get screen code
plp
@L2: plp
and #%10000000 ; get reverse bit
asl a
tax ; ldx #>$0000

View File

@@ -86,9 +86,9 @@ putchar:
stz VERA::CTRL ; Use port 0
lda CURS_Y
sta VERA::ADDR+1 ; Set row number
lda #VERA::INC1 ; Increment address by one
lda #VERA::INC1 ; Address increments by one
sta VERA::ADDR+2
ldy CURS_X ; Get character column
ldy CURS_X ; Get character column into .Y
tya
asl a ; Each character has two bytes
sta VERA::ADDR

View File

@@ -22,7 +22,7 @@
Start: tsx
stx spsave ; Save the system stack ptr
; Save space by putting some of the start-up code in the ONCE segment,
; Save space by putting some of the start-up code in the ONCE segment
; which will be re-used by the BSS segment, the heap, and the C stack.
jsr init
@@ -31,7 +31,7 @@ Start: tsx
jsr zerobss
; Push the command-line arguments; and, call main().
; Push the command-line arguments, and call main().
jsr callmain
@@ -46,7 +46,7 @@ _exit:
jsr donelib
.if 0 ; We don't need to preserve zero-page space for cc65's variables.
.if 0 ; (We don't need to preserve zero-page space for cc65's variables.)
; Copy back the zero-page stuff.
ldx #zpspace-1
@@ -90,7 +90,7 @@ init:
lda #$01
sta VIA1::PRA
.if 0 ; We don't need to preserve zero-page space for cc65's variables.
.if 0 ; (We don't need to preserve zero-page space for cc65's variables.)
; Save the zero-page locations that we need.
ldx #zpspace-1

View File

@@ -1,7 +1,7 @@
/*
** Program-chaining function for Commodore platforms.
**
** 2019-12-25, Greg King
** 2020-04-27, Greg King
**
** This function exploits the program-chaining feature in Commander X16 BASIC's ROM.
**
@@ -71,26 +71,28 @@ extern void basbuf_len[];
int __fastcall__ exec (const char* progname, const char* cmdline)
{
#if 0
static int fd;
#endif
static unsigned char dv, n;
/* Exclude devices that can't load files. */
/* (Use hand optimization, to make smaller code.) */
dv = getcurrentdevice ();
if (dv < 8 && __AX__ != 1 || __AX__ > 30) {
if (dv < 8 || __A__ > 30) {
return _mappederrno (9); /* illegal device number */
}
utoa (dv, basic.unit, 10);
/* The emulator supports only loading and saving on its file-system. */
if (dv != 1) {
/* Don't try to run a program that doesn't exist. */
fd = open (progname, O_RDONLY);
if (fd < 0) {
return _mappederrno (4); /* file not found */
}
close (fd);
#if 0
/* Don't try to run a program that doesn't exist. */
fd = open (progname, O_RDONLY);
if (fd < 0) {
return _mappederrno (4); /* file not found */
}
close (fd);
#endif
n = 0;
do {

View File

@@ -1,11 +1,12 @@
;
; 2020-01-10, Greg King
; 2020-01-29, Greg King
;
; unsigned char get_numbanks (void);
; unsigned short get_numbanks (void);
; /* Return the number of RAM banks that the machine has. */
;
; The Commander X16 version of MEMTOP returns with an extra value:
; The accumulator describes the number of RAM banks that exist on the hardware.
; A zero accumulator means that there are 256 RAM banks.
;
.export _get_numbanks
@@ -17,4 +18,7 @@ _get_numbanks:
sec
jsr MEMTOP
ldx #>$0000
rts
cmp #<$0100 ; are there 256 banks?
bne :+
inx ; yes
: rts

View File

@@ -1,5 +1,5 @@
;
; 2019-12-22, Greg King
; 2020-05-02, Greg King
;
; unsigned char get_tv (void);
; /* Return the video mode the machine is using. */
@@ -11,17 +11,9 @@
.proc _get_tv
; Point to the video output register.
stz VERA::CTRL ; Use port 0
lda #<VERA::COMPOSER::VIDEO
ldx #>VERA::COMPOSER::VIDEO
ldy #^VERA::COMPOSER::VIDEO
sta VERA::ADDR
stx VERA::ADDR+1
sty VERA::ADDR+2
lda VERA::DATA0
and #$07 ; Get the type of output signal
stz VERA::CTRL ; Use display register bank 0
lda VERA::DISP::VIDEO
and #%00000111 ; Get the type of output signal
ldx #>$0000 ; Promote to unsigned int
rts
.endproc

View File

@@ -1,11 +1,15 @@
;
; 2020-01-06, Greg King
; 2020-04-27, Greg King
;
; CX16 Kernal functions
;
.include "cbm_kernal.inc"
.export ENTROPY_GET
.export KEYBRD_BUF_PUT
.export CONSOLE_SET_PAGE_MSG
.export CONSOLE_PUT_IMAGE
.export CONSOLE_INIT
.export CONSOLE_PUT_CHAR
.export CONSOLE_GET_CHAR

View File

@@ -0,0 +1,39 @@
;
; 2020-05-02, Greg King
;
; unsigned char __fastcall__ vera_layer_enable (unsigned char layers);
; /* Display the layers that are "named" by the bit flags in layers.
; ** A value of 0b01 shows layer 0, a value of 0b10 shows layer 1,
; ** a value of 0b11 shows both layers. Return the previous value.
; */
;
.export _vera_layer_enable
.include "cx16.inc"
mask = VERA::DISP::ENABLE::LAYER1 | VERA::DISP::ENABLE::LAYER0
.proc _vera_layer_enable
stz VERA::CTRL ; Use display register bank 0
asl a
asl a ; Shift new flags into position
asl a
asl a
ldy VERA::DISP::VIDEO
eor VERA::DISP::VIDEO
and #mask
eor VERA::DISP::VIDEO ; Replace old flags with new flags
sta VERA::DISP::VIDEO
tya
and #mask ; Get old flags
lsr a
lsr a
lsr a
lsr a
ldx #>$0000
rts
.endproc

14
libsrc/cx16/randomize.s Normal file
View File

@@ -0,0 +1,14 @@
;
; 2020-05-02, Greg King
;
; void _randomize (void);
; /* Initialize the random number generator */
;
.export __randomize
.import ENTROPY_GET, _srand
__randomize:
jsr ENTROPY_GET
jmp _srand ; Initialize generator

View File

@@ -1,5 +1,5 @@
;
; 2019-12-22, Greg King
; 2020-05-02, Greg King
;
; void __fastcall__ set_tv (unsigned char);
; /* Set the video mode the machine will use. */
@@ -11,16 +11,10 @@
.proc _set_tv
; Point to the video output register.
stz VERA::CTRL ; Use port 0
ldx #<VERA::COMPOSER::VIDEO
ldy #>VERA::COMPOSER::VIDEO
stx VERA::ADDR
sty VERA::ADDR+1
ldx #^VERA::COMPOSER::VIDEO
stx VERA::ADDR+2
sta VERA::DATA0
stz VERA::CTRL ; Use display register bank 0
eor VERA::DISP::VIDEO
and #%00000111
eor VERA::DISP::VIDEO ; Replace old mode with new mode
sta VERA::DISP::VIDEO
rts
.endproc

View File

@@ -0,0 +1,34 @@
;
; 2020-05-02, Greg King
;
; unsigned char __fastcall__ vera_sprites_enable (unsigned char mode);
; /* Enable the sprite engine when mode is non-zero (true);
; ** disable sprites when mode is zero. Return the previous mode.
; */
;
.export _vera_sprites_enable
.include "cx16.inc"
.proc _vera_sprites_enable
stz VERA::CTRL ; Use display register bank 0
tax ; Is mode true?
beq :+
lda #VERA::DISP::ENABLE::SPRITES ; Yes
: ldy VERA::DISP::VIDEO
eor VERA::DISP::VIDEO
and #VERA::DISP::ENABLE::SPRITES
eor VERA::DISP::VIDEO ; Replace old flag with new flag
sta VERA::DISP::VIDEO
tya
and #VERA::DISP::ENABLE::SPRITES ; Get old value
asl a
asl a
rol a ; Make it boolean
ldx #>$0000
rts
.endproc