1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-07 19:29:18 +00:00

Merge remote-tracking branch 'upstream/master' into soft80

This commit is contained in:
mrdudz 2015-10-12 20:43:19 +02:00
commit df3549f502
28 changed files with 278 additions and 116 deletions

View File

@ -6,6 +6,8 @@
; ---------------------------------------------------------------------------
; Zero page, Commodore stuff
VARTAB := $2D ; Pointer to start of BASIC variables
MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
TXTPTR := $7A ; Pointer into BASIC source code
TIME := $A0 ; 60 HZ clock
FNAM_LEN := $B7 ; Length of filename

View File

@ -6,6 +6,7 @@
; ---------------------------------------------------------------------------
; Zero page, Commodore stuff
VARTAB := $2A ; Pointer to start of BASIC variables
MEMSIZE := $34 ; Size of memory installed
TXTPTR := $77 ; Pointer into BASIC source code
TIME := $8D ; 60HZ clock

View File

@ -7,6 +7,8 @@
; Zero page, Commodore stuff
TMPPTR := $22 ; Temporary ptr used by BASIC
VARTAB := $2D ; Pointer to start of BASIC variables
MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
TXTPTR := $3B ; Pointer into BASIC source code
TIME := $A3 ; 60HZ clock
FNAM_LEN := $AB ; Length of filename

View File

@ -6,6 +6,8 @@
; ---------------------------------------------------------------------------
; Zero page, Commodore stuff
VARTAB := $2D ; Pointer to start of BASIC variables
MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
TXTPTR := $7A ; Pointer into BASIC source code
TIME := $A0 ; 60HZ clock
FNAM_LEN := $B7 ; Length of filename

View File

@ -69,7 +69,7 @@ Programs containing NES specific code may use the <tt/nes.h/ header file.
<sect1>NES specific functions<p>
<itemize>
<item>waitvblank
<item>waitvblank - wait until the start of vblank
<item>get_tv
</itemize>
@ -123,6 +123,14 @@ No extended memory drivers are currently available for the NES.
</descrip><p>
The generic interface doesn't export the start and select buttons. To
test for those, use the defines in nes.h instead of the generic masks.
Example:
<tscreen><verb>
if (joy_read(0) & KEY_A)
</verb></tscreen>
<sect1>Mouse drivers<p>

View File

@ -122,6 +122,16 @@ struct mouse_callbacks {
/* The default mouse callbacks */
extern const struct mouse_callbacks mouse_def_callbacks;
#if defined(__CBM__)
/* The default mouse pointer shape used by the default mouse callbacks */
extern const unsigned char mouse_def_pointershape[63];
/* The default mouse pointer color used by the default mouse callbacks */
extern const unsigned char mouse_def_pointercolor;
#endif
/* The name of the standard mouse driver for a platform */
extern const char mouse_stddrv[];
@ -208,6 +218,3 @@ unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);
/* End of mouse.h */
#endif

View File

@ -90,7 +90,15 @@
/* No support for dynamically loadable drivers */
#define DYN_DRV 0
/* The joystick keys - all keys are supported */
#define KEY_A 0x01
#define KEY_B 0x02
#define KEY_SELECT 0x04
#define KEY_START 0x08
#define KEY_UP 0x10
#define KEY_DOWN 0x20
#define KEY_LEFT 0x40
#define KEY_RIGHT 0x80
/* The addresses of the static drivers */
extern void nes_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */

View File

@ -5,7 +5,7 @@
;
.include "atari.inc"
.constructor detect,26
.constructor detect, 26
.export __dos_type
; ------------------------------------------------------------------------

View File

@ -15,7 +15,7 @@ SPACE = 32 ; SPACE char.
.import __argc, __argv
.importzp ptr1
.import __dos_type
.constructor initmainargs,25
.constructor initmainargs, 25
; --------------------------------------------------------------------------
; Get command line

View File

@ -19,7 +19,7 @@
.export __getdefdev ; get default device
.export __defdev ; this is the default device string (e.g. "D1:")
.ifdef DYNAMIC_DD
.constructor __getdefdev,24
.constructor __getdefdev, 24
.endif
; Get default device (LBUF will be destroyed!!)

View File

@ -10,8 +10,8 @@
.include "atari.inc"
.importzp sp
.export _mouse_pm_callbacks
.constructor pm_init,27
.destructor pm_down,7
.constructor pm_init, 27
.destructor pm_down
; get mouse shape data
.import mouse_pm_bits

View File

@ -7,9 +7,10 @@
SCREEN_BUF_SIZE = 20 * 24
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
.code
.export screen_setup_20x24
.segment "INIT"
screen_setup_20x24:
; initialize SAVMSC
@ -79,5 +80,4 @@ dlist: .repeat 3
.assert ((* >> 10) = (dlist >> 10)), error, "Display list crosses 1K boundary"
.end

View File

@ -7,7 +7,10 @@
; be called from an interrupt handler
;
.constructor initmcb
.export _mouse_def_callbacks
.import _mouse_def_pointershape
.import _mouse_def_pointercolor
.include "mouse-kernel.inc"
.include "c128.inc"
@ -15,16 +18,45 @@
.macpack generic
; Sprite definitions. The first value can be changed to adjust the number
; of the sprite used for the mouse.
; of the sprite used for the mouse. All others depend on this value.
MOUSE_SPR = 0 ; Sprite used for the mouse
MOUSE_SPR_MEM = $0E00 ; Memory location
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
initmcb:
; Copy the mouse sprite data
ldx #64 - 1
@L0: lda _mouse_def_pointershape,x
sta MOUSE_SPR_MEM,x
dex
bpl @L0
; Set the mouse sprite pointer
lda #<(MOUSE_SPR_MEM / 64)
sta $07F8 + MOUSE_SPR
; Set the mouse sprite color
lda _mouse_def_pointercolor
sta VIC_SPR0_COLOR + MOUSE_SPR
rts
; --------------------------------------------------------------------------
; Hide the mouse pointer. Always called with interrupts disabled.
.code
hide:
lda #MOUSE_SPR_NMASK
and VIC_SPR_ENA

View File

@ -63,6 +63,7 @@ BCD2dec:tax
; Constructor that writes to the 1/10 sec register of the TOD to kick it
; into action. If this is not done, the clock hangs. We will read the register
; and write it again, ignoring a possible change in between.
.segment "INIT"
.proc initsystime
@ -78,7 +79,6 @@ BCD2dec:tax
.endproc
;----------------------------------------------------------------------------
; TM struct with date set to 1970-01-01
.data
@ -92,4 +92,3 @@ TM: .word 0 ; tm_sec
.word 0 ; tm_wday
.word 0 ; tm_yday
.word 0 ; tm_isdst

View File

@ -7,7 +7,12 @@
; be called from an interrupt handler
;
.constructor initmcb
.export _mouse_def_callbacks
.import _mouse_def_pointershape
.import _mouse_def_pointercolor
.import mcb_spritememory
.import mcb_spritepointer
.include "mouse-kernel.inc"
.include "c64.inc"
@ -22,9 +27,49 @@ MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
initmcb:
; Make all RAM accessible
lda #$30
ldy $01
sei
sta $01
; Copy the mouse sprite data
ldx #64 - 1
@L0: lda _mouse_def_pointershape,x
sta mcb_spritememory,x
dex
bpl @L0
; Set the mouse sprite pointer
lda #<(mcb_spritememory / 64)
sta mcb_spritepointer + MOUSE_SPR
; Restore memory configuration
sty $01
cli
; Set the mouse sprite color
lda _mouse_def_pointercolor
sta VIC_SPR0_COLOR + MOUSE_SPR
rts
; --------------------------------------------------------------------------
; Hide the mouse pointer. Always called with interrupts disabled.
.code
hide:
lda #MOUSE_SPR_NMASK
and VIC_SPR_ENA

View File

@ -0,0 +1,4 @@
; VIC sprite data for the mouse pointer
.export mcb_spritememory := $0340
.export mcb_spritepointer := $07F8

View File

@ -63,6 +63,7 @@ BCD2dec:tax
; Constructor that writes to the 1/10 sec register of the TOD to kick it
; into action. If this is not done, the clock hangs. We will read the register
; and write it again, ignoring a possible change in between.
.segment "INIT"
.proc initsystime
@ -81,7 +82,6 @@ BCD2dec:tax
.endproc
;----------------------------------------------------------------------------
; TM struct with date set to 1970-01-01
.data
@ -95,4 +95,3 @@ TM: .word 0 ; tm_sec
.word 0 ; tm_wday
.word 0 ; tm_yday
.word 0 ; tm_isdst

View File

@ -1,7 +1,7 @@
/*
** Program-chaining function for Commodore platforms.
**
** 2013-09-04, Greg King
** 2015-09-27, Greg King
**
** This function exploits the program-chaining feature in CBM BASIC's ROM.
**
@ -32,42 +32,46 @@
/* The struct below is a line of BASIC code. It sits in the LOWCODE segment
** to make sure that it won't be hidden by a ROM when BASIC is re-enabled.
** The line is:
** 0 LOAD""+"" ,01
** 0 CLR:LOAD""+"" ,01
** After this function has written into the line, it might look like this:
** 0 LOAD""+"program name" ,08
** 0 CLR:LOAD""+"program name" ,08
**
** When BASIC's LOAD command asks the Kernal to load a file, it gives the
** Kernal a pointer to a file-name string. CC65's CBM programs use that
** pointer to give a copy of the program's name to main()'s argv[0] parameter.
** But, when BASIC uses a string literal that's in a program, it points
** But, when BASIC uses a string literal that is in a program, it points
** directly to that literal -- in the models that don't use banked RAM
** (Pet/CBM, VIC-20, and 64). The literal is overwritten by the next program
** that's loaded. So, argv[0] would point to machine code. String operations
** that is loaded. So, argv[0] would point to machine code. String operations
** create a new result string -- even when that operation changes nothing. The
** result is put in the string space at the top of BASIC's memory. So, the ""+
** in this BASIC line guarantees that argv[0] will get a name from a safe place.
*/
#pragma data-name(push, "LOWCODE")
static struct line {
const char end_of_line;
const struct line *const next;
const char end_of_line; /* fake previous line */
const struct line* const next;
const unsigned line_num;
const char load_token, quotes[2], add_token, quote;
const char CLR_token, colon, LOAD_token, quotes[2], add_token, quote;
char name[21];
const char comma;
char unit[3];
} basic = {
'\0', &basic + 1, /* high byte of link must be non-zero */
0, 0x93, "\"\"", 0xaa, '\"',
"\" ", /* format: "123:1234567890123456\"" */
'\0', &basic + 1, /* high byte of link must be non-zero */
0, 0x9C, ':', 0x93, "\"\"", 0xAA, '\"',
"\" ", /* format: "123:1234567890123456\"" */
',', "01"
};
#pragma data-name(pop)
/* These values are platform-specific. */
extern const struct line *txtptr;
extern const void* vartab; /* points to BASIC program variables */
#pragma zpsym("vartab")
extern const void* memsize; /* points to top of BASIC RAM */
#pragma zpsym("memsize")
extern const struct line* txtptr; /* points to BASIC code */
#pragma zpsym("txtptr")
extern char basbuf[]; /* BASIC's input buffer */
extern char basbuf[]; /* BASIC's input buffer */
extern void basbuf_len[];
#pragma zpsym("basbuf_len")
@ -75,43 +79,62 @@ extern void basbuf_len[];
int __fastcall__ exec (const char* progname, const char* cmdline)
{
static int fd;
static unsigned char dv, n = 0;
static unsigned char dv, n;
/* Exclude devices that can't load files. */
/* (Use hand optimization, to make smaller code.) */
dv = getcurrentdevice ();
if (dv < 8 && dv != 1 || dv > 30) {
if (dv < 8 && __AX__ != 1 || __AX__ > 30) {
return _mappederrno (9); /* illegal device number */
}
utoa (dv, basic.unit, 10);
/* Don't try to run a program that can't be found. */
fd = open (progname, O_RDONLY);
if (fd < 0) {
return fd;
/* Tape files can be openned only once; skip this test for the Datasette. */
if (dv != 1) {
/* Don't try to run a program that can't be found. */
fd = open (progname, O_RDONLY);
if (fd < 0) {
return -1;
}
close (fd);
}
close (fd);
n = 0;
do {
if ((basic.name[n] = progname[n]) == '\0') {
break;
}
} while (++n < 20); /* truncate long names */
} while (++n < 20); /* truncate long names */
basic.name[n] = '\"';
/* This next part isn't needed by machines that put
** BASIC source and variables in different RAM banks.
*/
#if !defined(__CBM510__) && !defined(__CBM610__) && !defined(__C128__)
/* cc65 program loads might extend beyond the end of the RAM that is allowed
** for BASIC. Then, the LOAD statement would complain that it is "out of
** memory". Some pointers that say where to put BASIC program variables
** must be changed, so that we do not get that error. One pointer is
** changed here; a BASIC CLR statement changes the others.
*/
vartab = (char*)memsize - 256;
#endif
/* Build the next program's argument list. */
basbuf[0] = 0x8f; /* REM token */
basbuf[0] = 0x8F; /* REM token */
basbuf[1] = '\0';
if (cmdline != NULL) {
strncat (basbuf, cmdline, (size_t)basbuf_len - 2);
}
/* Tell the ROM where to find that BASIC program. */
#if defined(__CBM510__) || defined(__CBM610__)
pokewsys ((unsigned)&txtptr, (unsigned)&basic);
#else
txtptr = &basic;
#endif
/* (The return code, in ST, will be destroyed by LOAD.
/* (The return code, in ST [status], will be destroyed by LOAD.
** So, don't bother to set it here.)
*/
exit (__AX__);

View File

@ -20,9 +20,15 @@
.include "vic20.inc"
.endif
.export _txtptr:zp, _basbuf, _basbuf_len:zp
; exec() is written in C.
; Provide the spellings that the C compiler wants to use.
_txtptr := TXTPTR
.ifdef VARTAB
.exportzp _vartab := VARTAB
.exportzp _memsize := MEMSIZE
.endif
_basbuf := BASIC_BUF
_basbuf_len = BASIC_BUF_LEN
.exportzp _txtptr := TXTPTR
.export _basbuf := BASIC_BUF
.exportzp _basbuf_len = BASIC_BUF_LEN

View File

@ -0,0 +1,10 @@
; VIC sprite color for the mouse pointer
.export _mouse_def_pointercolor
.segment "INIT"
_mouse_def_pointercolor:
.byte $01 ; White

View File

@ -0,0 +1,30 @@
; VIC sprite data for the mouse pointer (an arrow)
.export _mouse_def_pointershape
.segment "INIT"
_mouse_def_pointershape:
.byte %11111110, %00000000, %00000000
.byte %11111100, %00000000, %00000000
.byte %11111000, %00000000, %00000000
.byte %11111100, %00000000, %00000000
.byte %11011110, %00000000, %00000000
.byte %10001111, %00000000, %00000000
.byte %00000111, %10000000, %00000000
.byte %00000011, %11000000, %00000000
.byte %00000001, %11100000, %00000000
.byte %00000000, %11110000, %00000000
.byte %00000000, %01111000, %00000000
.byte %00000000, %00111000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000
.byte %00000000, %00000000, %00000000

View File

@ -8,7 +8,10 @@
; be called from an interrupt handler.
;
.constructor initmcb
.export _mouse_def_callbacks
.import _mouse_def_pointershape
.import _mouse_def_pointercolor
.import vic:zp
.include "mouse-kernel.inc"
@ -19,14 +22,50 @@
; Sprite definitions. The first value can be changed to adjust the number
; of the sprite used for the mouse. All others depend on that value.
MOUSE_SPR = 0 ; Sprite used for the mouse
MOUSE_SPR_MEM = $F400 ; Memory location
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
initmcb:
; Copy the mouse sprite data
ldx #64 - 1
@L0: lda _mouse_def_pointershape,x
sta MOUSE_SPR_MEM,x
dex
bpl @L0
; Set the mouse sprite pointer
lda #<(MOUSE_SPR_MEM / 64)
sta $F3F8 + MOUSE_SPR
; Set the mouse sprite color
ldx IndReg
lda #15
sta IndReg
lda _mouse_def_pointercolor
ldy #VIC_SPR0_COLOR + MOUSE_SPR
sta (vic),y
stx IndReg
rts
; --------------------------------------------------------------------------
; Hide the mouse pointer. Always called with interrupts disabled.
.code
hide:
ldy #15
sty IndReg

View File

@ -11,12 +11,14 @@
.include "zeropage.inc"
; Initialize one-character buffer that is filled by kbhit()
.segment "INIT"
initcgetc:
lda #$00
sta CHARBUF ; No character in buffer initially
rts
; Input routine from 65V PROM MONITOR, show cursor if enabled
.code
_cgetc:
lda CHARBUF ; character in buffer available?
beq nobuffer

View File

@ -5,9 +5,11 @@
.include "pce.inc"
.include "extzp.inc"
.forceimport ticktock
.export _clock
.forceimport ticktock
.importzp sreg
.constructor initclock
.proc _clock
@ -21,8 +23,7 @@
.endproc
.constructor initclock, 24
.segment "INIT"
initclock:
lda #0
ldx #3

View File

@ -1,14 +1,16 @@
.include "pce.inc"
.include "extzp.inc"
.import vce_init
.import psg_init
.import vdc_init
.import vce_init
.import psg_init
.import colors
.importzp ptr1, tmp1
.constructor initconio, 24
.constructor initconio
.macpack longbranch
.segment "INIT"
initconio:
jsr vce_init
jsr psg_init
@ -20,7 +22,6 @@ initconio:
st2 #>$0088
rts
.import colors
set_palette:
stz VCE_ADDR_LO
stz VCE_ADDR_HI
@ -48,11 +49,6 @@ set_palette:
rts
;----------------------------------------------------------------------------
;
;----------------------------------------------------------------------------
.importzp ptr1, tmp1
conio_init:
; Load font
st0 #VDC_MAWR
@ -80,13 +76,11 @@ conio_init:
sta tmp1
jsr copy
ldx #0
stx BGCOLOR
inx
stx CHARCOLOR
rts
copy:

View File

@ -1,8 +1,8 @@
.include "pce.inc"
.export psg_init
.segment "INIT"
psg_init:
clx
stz PSG_GLOBAL_PAN ; Clear global balance

View File

@ -1,8 +1,8 @@
.include "pce.inc"
.export vce_init
.segment "INIT"
vce_init:
; Set CTA to zero
stz VCE_ADDR_LO

View File

@ -40,44 +40,11 @@
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
#ifdef __CBM__
/* Addresses of data for sprite 0 */
#if defined(__C64__)
# define SPRITE0_DATA ((unsigned char[64])0x0340)
# define SPRITE0_PTR ((unsigned char *)0x07F8)
#elif defined(__C128__)
# define SPRITE0_DATA ((unsigned char[64])0x0E00)
# define SPRITE0_PTR ((unsigned char *)0x07F8)
#elif defined(__CBM510__)
# define SPRITE0_DATA ((unsigned char[64])0xF400)
# define SPRITE0_PTR ((unsigned char *)0xF3F8)
#endif
/* Set dark-on-light colors. */
const unsigned char mouse_def_pointercolor = COLOR_BLACK;
/* The mouse sprite (an arrow) */
static const unsigned char MouseSprite[64] = {
0xFE, 0x00, 0x00,
0xFC, 0x00, 0x00,
0xF8, 0x00, 0x00,
0xFC, 0x00, 0x00,
0xDE, 0x00, 0x00,
0x8F, 0x00, 0x00,
0x07, 0x80, 0x00,
0x03, 0xC0, 0x00,
0x01, 0xE0, 0x00,
0x00, 0xF0, 0x00,
0x00, 0x78, 0x00,
0x00, 0x38, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00
};
#endif
@ -159,25 +126,6 @@ int main (void)
cursor (0);
clrscr ();
/* The pointer should be created before the driver is installed,
** in case a lightpen driver needs it during calibration.
*/
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
/* Copy the sprite data */
memcpy ((void*) SPRITE0_DATA, MouseSprite, sizeof (MouseSprite));
/* Set the VIC-II sprite pointer. */
*SPRITE0_PTR = ((unsigned) SPRITE0_DATA & 0x3FFF) / sizeof SPRITE0_DATA;
/* Set the color of sprite 0 */
# ifdef __CBM510__
pokebsys ((unsigned) &VIC.spr0_color, COLOR_BLACK);
# else
VIC.spr0_color = COLOR_BLACK;
# endif
#endif
/* If a lightpen driver is installed, then it can get a calibration value
** from this file (if it exists). Or, the user can adjust the pen; and,
** the value will be put into this file, for the next time.