From b66f7272af4c566df6205f55296ac365ecbf8c73 Mon Sep 17 00:00:00 2001 From: Greg King Date: Fri, 10 Jan 2020 15:17:23 -0500 Subject: [PATCH] Updated the cx16 library to the ROM's prerelease 36. --- asminc/cbm_kernal.inc | 15 +++- asminc/cx16.inc | 137 +++++++++++++++++++++++++++---------- doc/cx16.sgml | 8 +-- doc/funcref.sgml | 44 ++++++++++-- doc/library.sgml | 118 +++++++++++++++++--------------- include/cbm.h | 1 + include/cx16.h | 84 +++++++++++++++-------- libsrc/cbm/c_settim.s | 16 +++++ libsrc/cx16/clock.s | 1 - libsrc/cx16/color.s | 2 +- libsrc/cx16/crt0.s | 6 +- libsrc/cx16/get_numbanks.s | 20 ++++++ libsrc/cx16/joyref.s | 20 ------ libsrc/cx16/kbhit.s | 8 +-- libsrc/cx16/kernal.s | 14 +++- libsrc/cx16/libref.s | 4 +- libsrc/cx16/mcbdefault.s | 37 +++------- libsrc/cx16/videomode.s | 28 ++++---- libsrc/cx16/waitvsync.s | 8 +-- 19 files changed, 357 insertions(+), 214 deletions(-) create mode 100644 libsrc/cbm/c_settim.s create mode 100644 libsrc/cx16/get_numbanks.s delete mode 100644 libsrc/cx16/joyref.s diff --git a/asminc/cbm_kernal.inc b/asminc/cbm_kernal.inc index 86a60d49b..7125f1253 100644 --- a/asminc/cbm_kernal.inc +++ b/asminc/cbm_kernal.inc @@ -1,11 +1,21 @@ ; ; Olli Savia +; Greg King ; -; Commodore Kernal functions +; Commodore-compatibles Kernal functions ; .if .def(__CX16__) ; CX16 extended jump table + CONSOLE_INIT := $FEDB + CONSOLE_PUT_CHAR := $FEDE + CONSOLE_GET_CHAR := $FEE1 + MEMORY_FILL := $FEE4 + MEMORY_COPY := $FEE7 + MEMORY_CRC := $FEEA + MEMORY_DECOMPRESS := $FEED + SPRITE_SET_IMAGE := $FEF0 + SPRITE_SET_POSITION := $FEF3 FB_INIT := $FEF6 FB_GET_INFO := $FEF9 FB_SET_PALETTE := $FEFC @@ -37,7 +47,8 @@ CLOCK_GET_DATE_TIME := $FF50 JOYSTICK_SCAN := $FF53 JOYSTICK_GET := $FF56 - SCRMOD := $FF5F + SCREEN_SET_MODE := $FF5F + SCREEN_SET_CHARSET := $FF62 MOUSE_CONFIG := $FF68 MOUSE_GET := $FF6B .endif diff --git a/asminc/cx16.inc b/asminc/cx16.inc index e08215df9..06cc30199 100644 --- a/asminc/cx16.inc +++ b/asminc/cx16.inc @@ -1,5 +1,5 @@ ; -; CX16 r35 definitions +; CX16 r36 definitions ; ; --------------------------------------------------------------------------- @@ -17,7 +17,8 @@ YELLOW ORANGE BROWN - LIGHTRED + PINK + LIGHTRED = PINK GRAY1 GRAY2 LIGHTGREEN @@ -25,20 +26,81 @@ GRAY3 .endenum -; Special keys -.enum KEY - F1 = $85 - F3 - F5 - F7 - F2 - F4 - F6 - F8 - F9 = $10 - F10 = $15 - F11 - F12 +; Special characters +.enum CH +COLOR_SWAP = $01 +STOP = $03 +UNDERLINE +WHITE +BOLD +BELL +BACKSPACE +TAB +LINEFEED +ITALIC +OUTLINE +ENTER +FONT_LOWER +FONT_ISO +F9 +CURS_DOWN +REVERSE +HOME +DEL +F10 +F11 +F12 +SHIFT_TAB +RED = $1C +CURS_RIGHT +GREEN +BLUE +LIRA = $5C +ORANGE = $81 +RUN = $83 +HELP +F1 +F3 +F5 +F7 +F2 +F4 +F6 +F8 +SHIFT_ENTER +FONT_UPPER +FONT_PET +BLACK +CURS_UP +ATTR_CLEAR +SCRN_CLEAR +INS +BROWN +PINK +LIGHTRED = PINK +GRAY1 +GRAY2 +LIGHTGREEN +LIGHTBLUE +GRAY3 +PURPLE +VIOLET = PURPLE +CURS_LEFT +YELLOW +CYAN +SHIFT_SPACE +LTEE = $AB +LLCORNER = $AD +URCORNER +ULCORNER = $B0 +BTEE +TTEE +RTEE +LRCORNER = $BD +HLINE = $C0 +CROSS = $DB +VLINE = $DD +PI .endenum ; --------------------------------------------------------------------------- @@ -162,10 +224,9 @@ .endstruct ; Kernal -FNAM := $84 ; Pointer to filename -KTEMP2 := $86 ; 2 bytes for temporary storage -IMPARM := $88 ; Pointer for PRIMM function -SCREEN_PTR := $90 ; Pointer to current row on text screen (16 bits) +KTEMP2 := $80 ; 2 bytes for temporary storage +IMPARM := $82 ; Pointer for PRIMM function +FNAM := $8C ; Pointer to filename ; BASIC TXTPTR := $EE ; Pointer into BASIC source code @@ -175,23 +236,25 @@ TXTPTR := $EE ; Pointer into BASIC source code BASIC_BUF := $0200 ; Location of command-line BASIC_BUF_LEN = 81 ; Maximum length of command-line -STATUS := $0275 ; Status from previous I/O operation -IN_DEV := $0279 ; Current input device number -OUT_DEV := $027A ; Current output device number -FNAM_LEN := $027D ; Length of filename -SECADR := $027F ; Secondary address -DEVNUM := $0280 ; Device number +SCREEN_MODE := $0262 ; Current screen mode (set by SCREEN_SET_MODE) +SCREEN_PTR := $0263 ; Pointer to current row on text screen (16 bits) +STATUS := $0286 ; Status from previous I/O operation +IN_DEV := $028A ; Current input device number +OUT_DEV := $028B ; Current output device number +FNAM_LEN := $028E ; Length of filename +SECADR := $0290 ; Secondary address +DEVNUM := $0291 ; Device number CURS_COLOR := $0373 ; Color under the cursor -CHARCOLOR := $0377 ; Cursor's color nybbles (high: background, low: foreground) -RVS := $0378 ; Reverse flag -CURS_FLAG := $037C ; 1 = cursor off -CURS_BLINK := $037D ; Blink counter -CURS_CHAR := $037E ; Character under the cursor -CURS_STATE := $037F ; Cursor blink state -CURS_X := $0381 ; Cursor column -CURS_Y := $0384 ; Cursor row -LLEN := $0387 ; Line length -NLINES := $0388 ; Number of screen lines +CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground) +RVS := $0377 ; Reverse flag +CURS_FLAG := $037B ; 1 = cursor off +CURS_BLINK := $037C ; Blink counter +CURS_CHAR := $037D ; Character under the cursor +CURS_STATE := $037E ; Cursor blink state +CURS_X := $0380 ; Cursor column +CURS_Y := $0383 ; Cursor row +LLEN := $0386 ; Line length +NLINES := $0387 ; Number of screen lines ; BASIC VARTAB := $03E3 ; Pointer to start of BASIC variables @@ -453,7 +516,7 @@ NMIVec := $0318 ; --------------------------------------------------------------------------- ; Banked RAM and ROM -KEY_COUNT := $A00A ; (bank 0) Number of keys in input buffer +KEY_COUNT := $A00B ; (bank 0) Number of keys in input buffer TIMER := $A03E ; (bank 0) 60 Hz. timer (3 bytes, big-endian) .struct BANK diff --git a/doc/cx16.sgml b/doc/cx16.sgml index ca9a50ed6..20094d609 100644 --- a/doc/cx16.sgml +++ b/doc/cx16.sgml @@ -46,9 +46,9 @@ file and linker config. Memory layout

cc65-generated programs with the default setup run with the I/O area, RAM bank -zero, and the Kernal ROM visible. That means that Kernal entry points can be -called directly. The usable memory ranges are $0800 - $9EFF and -$A000 - $BFFF. +one, and the Kernal ROM being visible. That means that Kernal entry points +can be called directly. The usable memory ranges are $0800 - +$9EFF, $0400 - $07FF, and $A000 - $BFFF. Special locations: @@ -77,7 +77,7 @@ The ld65 linker comes with a default config. file for the Commander X16, which is used via Introduction

-cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO +cc65 is a C compiler for 6502-based systems. It implements a subset of the ISO C standard plus additional functions specially crafted for 6502 systems or -just some of the supported machines. This function refrence describes the +just some of the supported machines. This function reference describes the available functions together with any limitations. For an overview about the available libraries, their purpose, and any @@ -27,8 +27,8 @@ differences to the ISO standard, please have a look at the . + @@ -321,6 +322,7 @@ function.

+ @@ -2281,6 +2283,9 @@ only be used in presence of a prototype. , +, +, @@ -2302,9 +2307,34 @@ only be used in presence of a prototype. , , - +, +, + + + + + +cbm_k_settim

+ + + +/ + +The function is available only as a fastcall function; therefore, it may +be used only in the presence of a prototype. + +, + @@ -2368,6 +2398,7 @@ then that ISR must call this function, in order to keep the clock valid. , +, @@ -2585,6 +2616,7 @@ changing values. (See the description of , , for a list function by function. Since the function reference is -not complete (I'm working on that) it may happen that you don't find a -specific function. In this case, have a look into the header files. All -functions, that are not defined by the ISO C standard have a short comment in +reference"> for a function-by-function list. Because the function reference is +not complete (we're working on that), it may happen that you don't find a +specific function. In that case, have a look into the header files. All +functions, that are not defined by the ISO C standard, have a short comment in the headers, explaining their use. ISO C compatible library

-The C library contains a large subset of the ISO C library. Functions are -usually missing in areas, where there is no support on typical 6502 systems. -Wide character sets are an example for this. +The C library contains a large subset of the ISO C library. Functions usually +are missing in areas where there are no support on typical 6502 systems. +Wide-character sets are an example for that. I will not go into detail about the ISO functions. If a function is not -mentioned here explicitly, expect it to be available and to behave as defined +mentioned here explicitly, expect it to be available, and to behave as defined in the C standard. Functions that are All functions that handle floating point numbers in some manner.

- The The - All functions handling wide character strings. + All functions handling wide-character strings.

Signals and all related functions (having setbuf/setvbuf @@ -60,7 +60,7 @@ Functions not available on all supported systems: fopen/fread/fwrite/fclose/fputs/fgets/fscanf: The functions - are built on open/read/write/close. These latter functions are not available + are built on open/read/write/close. Those latter functions are not available on all systems.

ftell/fseek/fgetpos/fsetpos: Support depends on the @@ -69,94 +69,95 @@ Functions not available on all supported systems: rename/remove/rewind: Support depends on the capabilities of the target machine.

- time: Since many of the supported systems do not have a real - time clock, which means that the time: Many of the supported systems don't have a real-time + clock, which means that the Functions that are limited in any way: - strcspn/strpbrk/strspn: These functions have a length - limitation of 256 for the second string argument. Since this string gives a - character set, and there are only 256 distinct characters, this shouldn't be + strcspn/strpbrk/strspn: Those functions have a length + limitation of 256 for the second string argument. Since that string gives a + character set, and there are only 256 distinct characters, that shouldn't be a problem.

getenv: Since there is no such thing as an environment on all - supported systems, the - locale: There is no other locale than the "C" locale. The + locale: There is no locale other than the "C" locale. The native locale is identical to the "C" locale. -In addition to these limitations, some more functions are limited if inlined -versions are requested by using -Os: +In addition to those limitations, some more functions are limited if inlined +versions are requested by using the - The The - The The -CPU specific stuff - 6502.h

+CPU-specific stuff - 6502.h

-The header file 6502.h contains some functions that make only sense with the +The header file 6502.h contains some functions that make sense only with the 6502 CPU. Examples are macros to insert more or less useful instructions into your C code, or a function to call arbitrary machine language subroutines, passing registers in and out. -Target specific stuff

+Target-specific stuff

-For each supported system there's a header file that contains calls or defines -specific for this system. So, when programming for the C64, include c64.h, for -the C128, include c128.h and so on. To make the task for the Commodore systems -easier, there is also a header file named cbm.h that will define stuff common -for all CBM systems, and include the header file for the specific target -system. +For each supported system, there's a header file that contains calls or +defines specific for that system. So, when programming for the C64, include + - Defines for special keys (like function keys) + Defines for special keys (such as function keys) - Defines for special characters (like the graphics characters) + Defines for special characters (such as the graphics characters) Variables with a fixed address in memory that may be used to access - special hardware. For the C64 and C128 there is a variable struct named - Other routines that make only sense for a specific system. One example - are routines to write memory locations in the system bank for the CBM PET-II + Other routines that make sense for only a specific system. One example + is routines to write memory locations in the system bank for the CBM-II family. + Direct console I/O - The apple2 @@ -165,13 +166,13 @@ portable. conio implementations exist for the following targets: atari5200 atarixl atmos + c128 c16 (works also for the c116 with up to 32K memory) c64 - c128 - plus4 (or expanded c16/c116) - cbm510 (40 column video) - cbm610 (all CBM series-II computers with 80 column video) + cbm510 (40-column video) + cbm610 (all CBM series-II computers with 80-column video) creativision + cx16 gamate geos-apple geos-cbm @@ -179,11 +180,12 @@ portable. conio implementations exist for the following targets: osic1p pce pet (all CBM PET systems except the 2001) + plus4 (or expanded c16/c116) telestrat vic20 -The conio.h header file does also include the system specific header files +The Using the joystick - For systems that have a joystick, Using a mouse - -Some target machines support a mouse. Mouse support is currently available for +Some target machines support a mouse. Mouse support currently is available for the following targets: @@ -206,19 +208,21 @@ the following targets: apple2enh atari atarixl - c64 c128 + c64 cbm510 + cx16 The available functions are declared in Copyright

This C runtime library implementation for the cc65 compiler is (C) Copyright 1998-2002 Ullrich von Bassewitz. For usage of the binaries -and/or sources the following conditions do apply: +and/or sources, the following conditions do apply: This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held liable for any damages @@ -232,8 +236,8 @@ freely, subject to the following restrictions: The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - Altered source versions must be plainly marked as such, and must not + appreciated, but is not required. + Altered source versions must be marked plainly as such, and must not be misrepresented as being the original software. This notice may not be removed or altered from any source distribution. diff --git a/include/cbm.h b/include/cbm.h index 56b5b2947..ac3615c38 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -208,6 +208,7 @@ void __fastcall__ cbm_k_second (unsigned char addr); void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, unsigned char SA); void __fastcall__ cbm_k_setnam (const char* Name); +void __fastcall__ cbm_k_settim (unsigned long timer); void __fastcall__ cbm_k_talk (unsigned char dev); void __fastcall__ cbm_k_tksa (unsigned char addr); void cbm_k_udtim (void); diff --git a/include/cx16.h b/include/cx16.h index c6638cef4..6ceb605c9 100644 --- a/include/cx16.h +++ b/include/cx16.h @@ -47,12 +47,32 @@ /* Additional output character codes */ #define CH_COLOR_SWAP 0x01 #define CH_UNDERLINE 0x04 +#define CH_WHITE 0x05 #define CH_BOLD 0x06 #define CH_BACKSPACE 0x08 #define CH_ITALIC 0x0B #define CH_OUTLINE 0x0C #define CH_FONT_ISO 0x0F +#define CH_RED 0x1C +#define CH_GREEN 0x1E +#define CH_BLUE 0x1F +#define CH_ORANGE 0x81 #define CH_FONT_PET 0x8F +#define CH_BLACK 0x90 +#define CH_ATTR_CLEAR 0x92 +#define CH_BROWN 0x95 +#define CH_PINK 0x96 +#define CH_LIGHTRED CH_PINK +#define CH_GRAY1 0x97 +#define CH_GRAY2 0x98 +#define CH_LIGHTGREEN 0x99 +#define CH_LIGHTBLUE 0x9A +#define CH_GRAY3 0x9B +#define CH_PURPLE 0x9C +#define CH_VIOLET CH_PURPLE +#define CH_YELLOW 0x9E +#define CH_CYAN 0x9F +#define CH_SHIFT_SPACE 0xA0 /* Additional key defines */ #define CH_SHIFT_TAB 0x18 @@ -82,7 +102,8 @@ #define COLOR_YELLOW 0x07 #define COLOR_ORANGE 0x08 #define COLOR_BROWN 0x09 -#define COLOR_LIGHTRED 0x0A +#define COLOR_PINK 0x0A +#define COLOR_LIGHTRED COLOR_PINK #define COLOR_GRAY1 0x0B #define COLOR_GRAY2 0x0C #define COLOR_LIGHTGREEN 0x0D @@ -91,27 +112,27 @@ /* NES controller masks for joy_read() */ -#define JOY_BTN_1_MASK 0x80 -#define JOY_BTN_2_MASK 0x40 -#define JOY_BTN_3_MASK 0x20 -#define JOY_BTN_4_MASK 0x10 -#define JOY_UP_MASK 0x08 -#define JOY_DOWN_MASK 0x04 -#define JOY_LEFT_MASK 0x02 -#define JOY_RIGHT_MASK 0x01 +#define JOY_BTN_1_MASK 0x80 +#define JOY_BTN_2_MASK 0x40 +#define JOY_BTN_3_MASK 0x20 +#define JOY_BTN_4_MASK 0x10 +#define JOY_UP_MASK 0x08 +#define JOY_DOWN_MASK 0x04 +#define JOY_LEFT_MASK 0x02 +#define JOY_RIGHT_MASK 0x01 -#define JOY_BTN_A_MASK JOY_BTN_1_MASK -#define JOY_BTN_B_MASK JOY_BTN_2_MASK -#define JOY_SELECT_MASK JOY_BTN_3_MASK -#define JOY_START_MASK JOY_BTN_4_MASK +#define JOY_BTN_A_MASK JOY_BTN_1_MASK +#define JOY_BTN_B_MASK JOY_BTN_2_MASK +#define JOY_SELECT_MASK JOY_BTN_3_MASK +#define JOY_START_MASK JOY_BTN_4_MASK -#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) -#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) -#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK) -#define JOY_START(v) ((v) & JOY_START_MASK) +#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) +#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) +#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK) +#define JOY_START(v) ((v) & JOY_START_MASK) -#define JOY_FIRE2_MASK JOY_BTN_2_MASK -#define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK) +#define JOY_FIRE2_MASK JOY_BTN_2_MASK +#define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK) /* Additional mouse button mask */ #define MOUSE_BTN_MIDDLE 0x02 @@ -119,21 +140,21 @@ /* get_tv() return codes ** set_tv() argument codes */ -#define TV_NONE 0 -#define TV_VGA 1 -#define TV_NTSC_COLOR 2 -#define TV_RGB 3 -#define TV_NONE2 4 -#define TV_VGA2 5 -#define TV_NTSC_MONO 6 -#define TV_RGB2 7 +#define TV_NONE 0 +#define TV_VGA 1 +#define TV_NTSC_COLOR 2 +#define TV_RGB 3 +#define TV_NONE2 4 +#define TV_VGA2 5 +#define TV_NTSC_MONO 6 +#define TV_RGB2 7 /* Video modes for videomode() */ #define VIDEOMODE_40x30 0x00 #define VIDEOMODE_80x60 0x02 #define VIDEOMODE_40COL VIDEOMODE_40x30 #define VIDEOMODE_80COL VIDEOMODE_80x60 -#define VIDEOMODE_320x240 0x80 +#define VIDEOMODE_320x200 0x80 #define VIDEOMODE_SWAP (-1) /* VERA's interrupt flags */ @@ -193,6 +214,9 @@ extern void cx16_std_mou[]; /* Referred to by mouse_static_stddrv[] +unsigned char get_numbanks (void); +/* Return the number of RAM banks that the machine has. */ + signed char get_ostype (void); /* Get the ROM build version. ** -1 -- custom build @@ -201,12 +225,12 @@ signed char get_ostype (void); */ unsigned char get_tv (void); -/* Return the video type that the machine is using. +/* Return the video signal type that the machine is using. ** Return a TV_xx constant. */ void __fastcall__ set_tv (unsigned char type); -/* Set the video type that the machine will use. +/* Set the video signal type that the machine will use. ** Call with a TV_xx constant. */ diff --git a/libsrc/cbm/c_settim.s b/libsrc/cbm/c_settim.s new file mode 100644 index 000000000..5206557f4 --- /dev/null +++ b/libsrc/cbm/c_settim.s @@ -0,0 +1,16 @@ +; +; 2020-01-08, Greg King +; +; void __fastcall__ cbm_k_settim (unsigned long timer); +; + + .export _cbm_k_settim + .importzp sreg + + .include "cbm.inc" + + +.proc _cbm_k_settim + ldy sreg + jmp SETTIM +.endproc diff --git a/libsrc/cx16/clock.s b/libsrc/cx16/clock.s index 9af215e0f..a0871dbc7 100644 --- a/libsrc/cx16/clock.s +++ b/libsrc/cx16/clock.s @@ -25,7 +25,6 @@ .endproc - .proc _clock stz sreg + 1 ; Byte 3 always is zero diff --git a/libsrc/cx16/color.s b/libsrc/cx16/color.s index 1be01c473..f8d8c1ebf 100644 --- a/libsrc/cx16/color.s +++ b/libsrc/cx16/color.s @@ -36,7 +36,7 @@ _bgcolor: ora tmp1 sta CHARCOLOR ; set new values txa - lsr a ; get screen color + lsr a ; get old background color lsr a lsr a lsr a diff --git a/libsrc/cx16/crt0.s b/libsrc/cx16/crt0.s index 52deeb76f..d709ea96f 100644 --- a/libsrc/cx16/crt0.s +++ b/libsrc/cx16/crt0.s @@ -61,7 +61,7 @@ L2: lda zpsave,x ldx spsave txs ; Restore stack pointer ldx ramsave - stx VIA1::PRA2 ; Restore former RAM bank + stx VIA1::PRA ; Restore former RAM bank lda VIA1::PRB and #<~$07 ora #$04 @@ -85,10 +85,10 @@ init: ; Change to the second RAM bank. - lda VIA1::PRA2 + lda VIA1::PRA sta ramsave ; Save the current RAM bank number lda #$01 - sta VIA1::PRA2 + sta VIA1::PRA .if 0 ; We don't need to preserve zero-page space for cc65's variables. ; Save the zero-page locations that we need. diff --git a/libsrc/cx16/get_numbanks.s b/libsrc/cx16/get_numbanks.s new file mode 100644 index 000000000..00490fb72 --- /dev/null +++ b/libsrc/cx16/get_numbanks.s @@ -0,0 +1,20 @@ +; +; 2020-01-10, Greg King +; +; unsigned char 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. +; + + .export _get_numbanks + + .import MEMTOP + + +_get_numbanks: + sec + jsr MEMTOP + ldx #>$0000 + rts diff --git a/libsrc/cx16/joyref.s b/libsrc/cx16/joyref.s deleted file mode 100644 index edd89fba6..000000000 --- a/libsrc/cx16/joyref.s +++ /dev/null @@ -1,20 +0,0 @@ -; -; 2019-12-22, Greg King -; -; Link an interrupt handler if joysticks are used by a program. -; - - .interruptor joy_libref, 9 - - .include "cbm_kernal.inc" - .include "cx16.inc" - - -joy_libref: - lda VERA::IRQ_FLAGS - lsr a - bcc not_vsync - jsr JOYSTICK_SCAN ; Bit-bang game controllers - clc ; Let other Jiffy handlers run -not_vsync: - rts diff --git a/libsrc/cx16/kbhit.s b/libsrc/cx16/kbhit.s index 34afdeba4..d7e22efd1 100644 --- a/libsrc/cx16/kbhit.s +++ b/libsrc/cx16/kbhit.s @@ -1,5 +1,5 @@ ; -; 2019-12-22, Greg King +; 2020-01-08, Greg King ; ; unsigned char kbhit (void); ; /* Returns non-zero (true) if a typed character is waiting. */ @@ -11,10 +11,10 @@ .proc _kbhit - ldy VIA1::PRA2 ; (KEY_COUNT is in RAM bank 0) - stz VIA1::PRA2 + ldy VIA1::PRA ; (KEY_COUNT is in RAM bank 0) + stz VIA1::PRA lda KEY_COUNT ; Get number of characters - sty VIA1::PRA2 + sty VIA1::PRA tax ; High byte of return (only its zero/nonzero ... rts ; ... state matters) .endproc diff --git a/libsrc/cx16/kernal.s b/libsrc/cx16/kernal.s index ccd52d632..a6b65ebbd 100644 --- a/libsrc/cx16/kernal.s +++ b/libsrc/cx16/kernal.s @@ -1,11 +1,20 @@ ; -; 2019-12-22, Greg King +; 2020-01-06, Greg King ; ; CX16 Kernal functions ; .include "cbm_kernal.inc" + .export CONSOLE_INIT + .export CONSOLE_PUT_CHAR + .export CONSOLE_GET_CHAR + .export MEMORY_FILL + .export MEMORY_COPY + .export MEMORY_CRC + .export MEMORY_DECOMPRESS + .export SPRITE_SET_IMAGE + .export SPRITE_SET_POSITION .export FB_INIT .export FB_GET_INFO .export FB_SET_PALETTE @@ -37,7 +46,8 @@ .export CLOCK_GET_DATE_TIME .export JOYSTICK_SCAN .export JOYSTICK_GET - .export SCRMOD + .export SCREEN_SET_MODE + .export SCREEN_SET_CHARSET .export MOUSE_CONFIG .export MOUSE_GET diff --git a/libsrc/cx16/libref.s b/libsrc/cx16/libref.s index 0d85c7cd8..82a39c22b 100644 --- a/libsrc/cx16/libref.s +++ b/libsrc/cx16/libref.s @@ -1,9 +1,10 @@ ; ; 2013-05-31, Oliver Schmidt -; 2019-11-14, Greg King +; 2020-01-06, Greg King ; .export em_libref + .export joy_libref .export mouse_libref .export ser_libref .export tgi_libref @@ -11,6 +12,7 @@ .import _exit em_libref := _exit +joy_libref := _exit mouse_libref := _exit ser_libref := _exit tgi_libref := _exit diff --git a/libsrc/cx16/mcbdefault.s b/libsrc/cx16/mcbdefault.s index 3dda1c711..aed0e3a2d 100644 --- a/libsrc/cx16/mcbdefault.s +++ b/libsrc/cx16/mcbdefault.s @@ -1,44 +1,29 @@ ; ; Default mouse callbacks for the CX16 ; -; 2019-12-25, Greg King -; -; All functions in this module should be interrupt-safe -; because they might be called from an interrupt handler. +; 2020-01-10, Greg King ; .export _mouse_def_callbacks + .import MOUSE_GET, SPRITE_SET_POSITION .include "cx16.inc" -msprite: - stz VERA::CTRL ; set address for VERA's data port zero - lda #<(VERA::SPRITE::ATTRIB::Z_FLIP + 0 * 8) - ldx #>(VERA::SPRITE::ATTRIB::Z_FLIP + 0 * 8) - ldy #^(VERA::SPRITE::ATTRIB::Z_FLIP + 0 * 8) | VERA::INC0 - sta VERA::ADDR - stx VERA::ADDR+1 - sty VERA::ADDR+2 - rts - ; -------------------------------------------------------------------------- ; Hide the mouse pointer. -hide: jsr msprite - lda VERA::DATA0 - and #<~VERA::SPRITE::DEPTH::LAYER1 - sta VERA::DATA0 - rts +hide: ldx #%10000000 + stx gREG::r0H + bra mse ; -------------------------------------------------------------------------- ; Show the mouse pointer. -show: jsr msprite - lda VERA::DATA0 - ora #VERA::SPRITE::DEPTH::LAYER1 - sta VERA::DATA0 - rts +show: ldx #gREG::r0 + jsr MOUSE_GET +mse: lda #$00 ; mouse sprite + jmp SPRITE_SET_POSITION ; -------------------------------------------------------------------------- ; Prepare to move the mouse pointer. @@ -53,13 +38,13 @@ draw: ; Fall through ; -------------------------------------------------------------------------- ; Move the mouse pointer X position to the value in .XA . -movex: ; Already set by drivers +movex: ; Already done by Kernal ; Fall through ; -------------------------------------------------------------------------- ; Move the mouse pointer Y position to the value in .XA . -movey: rts ; Already set by drivers +movey: rts ; Already done by Kernal ; -------------------------------------------------------------------------- ; Callback structure diff --git a/libsrc/cx16/videomode.s b/libsrc/cx16/videomode.s index e3a777b8e..8fe797449 100644 --- a/libsrc/cx16/videomode.s +++ b/libsrc/cx16/videomode.s @@ -1,10 +1,10 @@ ; -; 2019-11-06, Greg King +; 2020-01-06, Greg King ; ; /* Video mode defines */ ; #define VIDEOMODE_40x30 0x00 ; #define VIDEOMODE_80x60 0x02 -; #define VIDEOMODE_320x240 0x80 +; #define VIDEOMODE_320x200 0x80 ; #define VIDEOMODE_SWAP (-1) ; ; signed char __fastcall__ videomode (signed char Mode); @@ -16,29 +16,25 @@ .export _videomode - .import SCRMOD + .import SCREEN_SET_MODE + .include "cx16.inc" .proc _videomode - tax - clc ; (Get old mode) - jsr SCRMOD - pha - txa + ldx SCREEN_MODE ; Get old mode + phx - sec ; (Set new mode) - jsr SCRMOD + jsr SCREEN_SET_MODE pla ; Get back old mode - bcs @L1 ldx #>$0000 ; Clear high byte + bcs @L1 rts -; The new mode is invalid. Go back to the old mode. Return -1. +; The new mode is invalid. Go back to the old one. Return -1. -@L1: sec - jsr SCRMOD - lda #<-1 - tax +@L1: sta SCREEN_MODE + dex + txa rts .endproc diff --git a/libsrc/cx16/waitvsync.s b/libsrc/cx16/waitvsync.s index e8176916b..6316a0483 100644 --- a/libsrc/cx16/waitvsync.s +++ b/libsrc/cx16/waitvsync.s @@ -1,5 +1,5 @@ ; -; 2019-12-23, Greg King +; 2020-01-08, Greg King ; ; void waitvsync (void); ; /* Wait for the start of the next video field. */ @@ -12,10 +12,10 @@ .include "cx16.inc" _waitvsync: - ldx VIA1::PRA2 ; (TIMER is in RAM bank 0) - stz VIA1::PRA2 + ldx VIA1::PRA ; (TIMER is in RAM bank 0) + stz VIA1::PRA lda TIMER + 2 : cmp TIMER + 2 beq :- ; Wait for next jiffy - stx VIA1::PRA2 + stx VIA1::PRA rts