mirror of
https://github.com/cc65/cc65.git
synced 2024-06-26 05:29:30 +00:00
Added VIC20 port changes from Steve Schmidtke
git-svn-id: svn://svn.cc65.org/cc65/trunk@1376 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
195feebc00
commit
f0d89e09bc
|
@ -73,6 +73,10 @@ More special thanks to:
|
||||||
|
|
||||||
for help with preliminary Oric Atmos support.
|
for help with preliminary Oric Atmos support.
|
||||||
|
|
||||||
|
* Steve Schmidtke <steve_schmidtke@hotmail.com>
|
||||||
|
|
||||||
|
Steve contributed the VIC20 port.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Thanks to
|
Thanks to
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
/* Load the system specific files here, if needed */
|
/* Load the system specific files here, if needed */
|
||||||
#if defined(__C64__) && !defined(_C64_H)
|
#if defined(__C64__) && !defined(_C64_H)
|
||||||
# include <c64.h>
|
# include <c64.h>
|
||||||
|
#elif defined(__VIC20__) && !defined(_VIC20_H)
|
||||||
|
# include <vic20.h>
|
||||||
#elif defined(__C128__) && !defined(_C128_H)
|
#elif defined(__C128__) && !defined(_C128_H)
|
||||||
# include <c128.h>
|
# include <c128.h>
|
||||||
#elif defined(__PLUS4__) && !defined(_PLUS4_H)
|
#elif defined(__PLUS4__) && !defined(_PLUS4_H)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* Define __JOYSTICK__ for systems that support a joystick */
|
/* Define __JOYSTICK__ for systems that support a joystick */
|
||||||
#if defined(__ATARI__) || defined(__C64__) || defined(__C128__) || defined(__PLUS4__) || defined(__CBM510__)
|
#if defined(__ATARI__) || defined(__C64__) || defined(__C128__) || defined(__PLUS4__) || defined(__CBM510__) || defined(__VIC20__)
|
||||||
# define __JOYSTICK__
|
# define __JOYSTICK__
|
||||||
#else
|
#else
|
||||||
# error The target system does not support a joystick!
|
# error The target system does not support a joystick!
|
||||||
|
|
89
include/vic20.h
Normal file
89
include/vic20.h
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* vic20.h */
|
||||||
|
/* */
|
||||||
|
/* vic20 system specific definitions */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||||
|
/* Wacholderweg 14 */
|
||||||
|
/* D-70597 Stuttgart */
|
||||||
|
/* EMail: uz@musoftware.de */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
/* warranty. In no event will the authors be held liable for any damages */
|
||||||
|
/* arising from the use of this software. */
|
||||||
|
/* */
|
||||||
|
/* Permission is granted to anyone to use this software for any purpose, */
|
||||||
|
/* including commercial applications, and to alter it and redistribute it */
|
||||||
|
/* freely, subject to the following restrictions: */
|
||||||
|
/* */
|
||||||
|
/* 1. 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. */
|
||||||
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||||
|
/* be misrepresented as being the original software. */
|
||||||
|
/* 3. This notice may not be removed or altered from any source */
|
||||||
|
/* distribution. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _VIC20_H
|
||||||
|
#define _VIC20_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Check for errors */
|
||||||
|
#if !defined(__VIC20__)
|
||||||
|
# error This module may only be used when compiling for the Vic20!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Additional key defines */
|
||||||
|
#define CH_F1 133
|
||||||
|
#define CH_F2 137
|
||||||
|
#define CH_F3 134
|
||||||
|
#define CH_F4 138
|
||||||
|
#define CH_F5 135
|
||||||
|
#define CH_F6 139
|
||||||
|
#define CH_F7 136
|
||||||
|
#define CH_F8 140
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Color defines */
|
||||||
|
#define COLOR_BLACK 0x00
|
||||||
|
#define COLOR_WHITE 0x01
|
||||||
|
#define COLOR_RED 0x02
|
||||||
|
#define COLOR_CYAN 0x03
|
||||||
|
#define COLOR_VIOLET 0x04
|
||||||
|
#define COLOR_GREEN 0x05
|
||||||
|
#define COLOR_BLUE 0x06
|
||||||
|
#define COLOR_YELLOW 0x07
|
||||||
|
#define COLOR_ORANGE 0x08
|
||||||
|
#define COLOR_BROWN 0x09
|
||||||
|
#define COLOR_LIGHTRED 0x0A
|
||||||
|
#define COLOR_GRAY1 0x0B
|
||||||
|
#define COLOR_GRAY2 0x0C
|
||||||
|
#define COLOR_LIGHTGREEN 0x0D
|
||||||
|
#define COLOR_LIGHTBLUE 0x0E
|
||||||
|
#define COLOR_GRAY3 0x0F
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Define special memory areas */
|
||||||
|
#define COLOR_RAM ((unsigned char*)0x9600)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of vic20.h */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ LD = ../../src/ld65/ld65
|
||||||
ALLTARGETS = apple2lib \
|
ALLTARGETS = apple2lib \
|
||||||
atarilib \
|
atarilib \
|
||||||
atmoslib \
|
atmoslib \
|
||||||
|
vic20lib \
|
||||||
c64lib \
|
c64lib \
|
||||||
c128lib \
|
c128lib \
|
||||||
cbm510lib \
|
cbm510lib \
|
||||||
|
@ -78,6 +79,22 @@ atmoslib:
|
||||||
$(AR) a atmos.lib $$i/*.o;\
|
$(AR) a atmos.lib $$i/*.o;\
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Vic20
|
||||||
|
|
||||||
|
vic20lib:
|
||||||
|
for i in vic20 cbm common runtime conio dbg; do \
|
||||||
|
CC=$(CC) \
|
||||||
|
AS=$(AS) \
|
||||||
|
CFLAGS="-Osir -g -T -t c64 -I../../include" \
|
||||||
|
AFLAGS="-t c64" \
|
||||||
|
$(MAKE) -C $$i || exit 1; \
|
||||||
|
done
|
||||||
|
mv vic20/crt0.o vic20.o
|
||||||
|
for i in vic20 cbm common runtime conio dbg; do \
|
||||||
|
$(AR) a vic20.lib $$i/*.o;\
|
||||||
|
done
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# C64
|
# C64
|
||||||
|
|
||||||
|
|
1
libsrc/vic20/.cvsignore
Normal file
1
libsrc/vic20/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.tgi
|
30
libsrc/vic20/Makefile
Normal file
30
libsrc/vic20/Makefile
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# makefile for CC65 runtime library
|
||||||
|
#
|
||||||
|
|
||||||
|
.SUFFIXES: .o .s .c
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
@$(CC) $(CFLAGS) $<
|
||||||
|
@$(AS) -o $@ $(AFLAGS) $(*).s
|
||||||
|
|
||||||
|
%.o: %.s
|
||||||
|
@$(AS) -g -o $@ $(AFLAGS) $<
|
||||||
|
|
||||||
|
OBJS = _scrsize.o \
|
||||||
|
break.o \
|
||||||
|
crt0.o \
|
||||||
|
cgetc.o \
|
||||||
|
clrscr.o \
|
||||||
|
color.o \
|
||||||
|
conio.o \
|
||||||
|
cputc.o \
|
||||||
|
kbhit.o \
|
||||||
|
readjoy.o \
|
||||||
|
write.o
|
||||||
|
|
||||||
|
all: $(OBJS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -f $(OBJS)
|
||||||
|
|
25
libsrc/vic20/_scrsize.s
Normal file
25
libsrc/vic20/_scrsize.s
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 26.10.2000
|
||||||
|
;
|
||||||
|
; Screen size variables
|
||||||
|
;
|
||||||
|
|
||||||
|
.export xsize, ysize
|
||||||
|
.constructor initscrsize
|
||||||
|
|
||||||
|
.include "../cbm/cbm.inc"
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
initscrsize:
|
||||||
|
jsr SCREEN
|
||||||
|
stx xsize
|
||||||
|
sty ysize
|
||||||
|
rts
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
xsize: .res 1
|
||||||
|
ysize: .res 1
|
||||||
|
|
||||||
|
|
108
libsrc/vic20/break.s
Normal file
108
libsrc/vic20/break.s
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 27.09.1998
|
||||||
|
;
|
||||||
|
; void set_brk (unsigned Addr);
|
||||||
|
; void reset_brk (void);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _set_brk, _reset_brk
|
||||||
|
.destructor _reset_brk
|
||||||
|
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
||||||
|
|
||||||
|
.bss
|
||||||
|
_brk_a: .res 1
|
||||||
|
_brk_x: .res 1
|
||||||
|
_brk_y: .res 1
|
||||||
|
_brk_sr: .res 1
|
||||||
|
_brk_pc: .res 2
|
||||||
|
|
||||||
|
oldvec: .res 2 ; Old vector
|
||||||
|
|
||||||
|
|
||||||
|
.data
|
||||||
|
uservec: jmp $FFFF ; Patched at runtime
|
||||||
|
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
; Set the break vector
|
||||||
|
.proc _set_brk
|
||||||
|
|
||||||
|
sta uservec+1
|
||||||
|
stx uservec+2 ; Set the user vector
|
||||||
|
|
||||||
|
lda oldvec
|
||||||
|
ora oldvec+1 ; Did we save the vector already?
|
||||||
|
bne L1 ; Jump if we installed the handler already
|
||||||
|
|
||||||
|
lda BRKVec
|
||||||
|
sta oldvec
|
||||||
|
lda BRKVec+1
|
||||||
|
sta oldvec+1 ; Save the old vector
|
||||||
|
|
||||||
|
L1: lda #<brk_handler ; Set the break vector to our routine
|
||||||
|
ldx #>brk_handler
|
||||||
|
sta BRKVec
|
||||||
|
stx BRKVec+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
; Reset the break vector
|
||||||
|
.proc _reset_brk
|
||||||
|
|
||||||
|
lda oldvec
|
||||||
|
ldx oldvec+1
|
||||||
|
beq @L9 ; Jump if vector not installed
|
||||||
|
sta BRKVec
|
||||||
|
stx BRKVec+1
|
||||||
|
lda #$00
|
||||||
|
sta oldvec ; Clear the old vector
|
||||||
|
stx oldvec+1
|
||||||
|
@L9: rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; Break handler, called if a break occurs
|
||||||
|
|
||||||
|
.proc brk_handler
|
||||||
|
|
||||||
|
pla
|
||||||
|
sta _brk_y
|
||||||
|
pla
|
||||||
|
sta _brk_x
|
||||||
|
pla
|
||||||
|
sta _brk_a
|
||||||
|
pla
|
||||||
|
and #$EF ; Clear break bit
|
||||||
|
sta _brk_sr
|
||||||
|
pla ; PC low
|
||||||
|
sec
|
||||||
|
sbc #2 ; Point to start of brk
|
||||||
|
sta _brk_pc
|
||||||
|
pla ; PC high
|
||||||
|
sbc #0
|
||||||
|
sta _brk_pc+1
|
||||||
|
|
||||||
|
jsr uservec ; Call the user's routine
|
||||||
|
|
||||||
|
lda _brk_pc+1
|
||||||
|
pha
|
||||||
|
lda _brk_pc
|
||||||
|
pha
|
||||||
|
lda _brk_sr
|
||||||
|
pha
|
||||||
|
ldx _brk_x
|
||||||
|
ldy _brk_y
|
||||||
|
lda _brk_a
|
||||||
|
rti ; Jump back...
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
61
libsrc/vic20/cgetc.s
Normal file
61
libsrc/vic20/cgetc.s
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 06.08.1998
|
||||||
|
;
|
||||||
|
; char cgetc (void);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _cgetc
|
||||||
|
.import cursor
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
||||||
|
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||||
|
bne L3 ; Jump if there are already chars waiting
|
||||||
|
|
||||||
|
; Switch on the cursor if needed
|
||||||
|
|
||||||
|
lda CURS_FLAG
|
||||||
|
pha
|
||||||
|
lda cursor
|
||||||
|
jsr setcursor
|
||||||
|
L1: lda KEY_COUNT
|
||||||
|
beq L1
|
||||||
|
ldx #0
|
||||||
|
pla
|
||||||
|
bne L2
|
||||||
|
inx
|
||||||
|
L2: txa
|
||||||
|
jsr setcursor
|
||||||
|
|
||||||
|
L3: jsr KBDREAD ; Read char and return in A
|
||||||
|
ldx #0
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
; Switch the cursor on or off
|
||||||
|
|
||||||
|
.proc setcursor
|
||||||
|
|
||||||
|
tax ; On or off?
|
||||||
|
bne seton ; Go set it on
|
||||||
|
lda CURS_FLAG ; Is the cursor currently off?
|
||||||
|
bne crs9 ; Jump if yes
|
||||||
|
lda #1
|
||||||
|
sta CURS_FLAG ; Mark it as off
|
||||||
|
lda CURS_STATE ; Cursor currently displayed?
|
||||||
|
beq crs8 ; Jump if no
|
||||||
|
ldy CURS_X ; Get the character column
|
||||||
|
lda (SCREEN_PTR),y ; Get character
|
||||||
|
eor #$80
|
||||||
|
sta (SCREEN_PTR),y ; Store character back
|
||||||
|
lda CURS_COLOR
|
||||||
|
sta (CRAM_PTR),y ; Store color back
|
||||||
|
crs8: lda #0
|
||||||
|
sta CURS_STATE ; Cursor not displayed
|
||||||
|
crs9: rts
|
||||||
|
|
||||||
|
seton: lda #0
|
||||||
|
sta CURS_FLAG
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
14
libsrc/vic20/clrscr.s
Normal file
14
libsrc/vic20/clrscr.s
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 06.08.1998
|
||||||
|
;
|
||||||
|
; void clrscr (void);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _clrscr
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
||||||
|
_clrscr = CLRSCR
|
||||||
|
|
||||||
|
|
||||||
|
|
61
libsrc/vic20/color.s
Normal file
61
libsrc/vic20/color.s
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 06.08.1998
|
||||||
|
; Adapted for Vic20 by Steve Schmidtke 05.08.2002
|
||||||
|
;
|
||||||
|
; unsigned char __fastcall__ textcolor (unsigned char color);
|
||||||
|
; unsigned char __fastcall__ bgcolor (unsigned char color);
|
||||||
|
; unsigned char __fastcall__ bordercolor (unsigned char color);
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
.export _textcolor, _bgcolor, _bordercolor
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
clr_tmp: .res 1 ; tempory storage for bitfield ops
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
_textcolor:
|
||||||
|
ldx CHARCOLOR ; get old value
|
||||||
|
sta CHARCOLOR ; set new value
|
||||||
|
txa
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
_bgcolor:
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
sei ; don't want anything messing around while we update
|
||||||
|
sta clr_tmp
|
||||||
|
lda VIC_COLOR ; get old value
|
||||||
|
and #$0F
|
||||||
|
tax
|
||||||
|
ora clr_tmp
|
||||||
|
sta VIC_COLOR ; set new value
|
||||||
|
cli
|
||||||
|
txa
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
_bordercolor:
|
||||||
|
and #$07
|
||||||
|
sei ; don't want anything messing around while we update
|
||||||
|
sta clr_tmp
|
||||||
|
lda VIC_COLOR ; get old value
|
||||||
|
and #$F8
|
||||||
|
tax
|
||||||
|
ora clr_tmp
|
||||||
|
sta VIC_COLOR ; set new value
|
||||||
|
cli
|
||||||
|
txa
|
||||||
|
rts
|
||||||
|
|
10
libsrc/vic20/conio.s
Normal file
10
libsrc/vic20/conio.s
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 06.08.1998
|
||||||
|
;
|
||||||
|
; Low level stuff for screen output/console input
|
||||||
|
;
|
||||||
|
|
||||||
|
.exportzp CURS_X, CURS_Y
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
105
libsrc/vic20/cputc.s
Normal file
105
libsrc/vic20/cputc.s
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 06.08.1998
|
||||||
|
;
|
||||||
|
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||||
|
; void cputc (char c);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _cputcxy, _cputc, cputdirect, putchar
|
||||||
|
.export newline, plot
|
||||||
|
.import popa, _gotoxy
|
||||||
|
.import xsize, revers
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
.include "../cbm/cbm.inc"
|
||||||
|
|
||||||
|
_cputcxy:
|
||||||
|
pha ; Save C
|
||||||
|
jsr popa ; Get Y
|
||||||
|
jsr _gotoxy ; Set cursor, drop x
|
||||||
|
pla ; Restore C
|
||||||
|
|
||||||
|
; Plot a character - also used as internal function
|
||||||
|
|
||||||
|
_cputc: cmp #$0A ; CR?
|
||||||
|
bne L1
|
||||||
|
lda #0
|
||||||
|
sta CURS_X
|
||||||
|
beq plot ; Recalculate pointers
|
||||||
|
|
||||||
|
L1: cmp #$0D ; LF?
|
||||||
|
beq newline ; Recalculate pointers
|
||||||
|
|
||||||
|
; Printable char of some sort
|
||||||
|
|
||||||
|
cmp #' '
|
||||||
|
bcc cputdirect ; Other control char
|
||||||
|
tay
|
||||||
|
bmi L10
|
||||||
|
cmp #$60
|
||||||
|
bcc L2
|
||||||
|
and #$DF
|
||||||
|
bne cputdirect ; Branch always
|
||||||
|
L2: and #$3F
|
||||||
|
|
||||||
|
cputdirect:
|
||||||
|
jsr putchar ; Write the character to the screen
|
||||||
|
|
||||||
|
; Advance cursor position
|
||||||
|
|
||||||
|
advance:
|
||||||
|
iny
|
||||||
|
cpy xsize
|
||||||
|
bne L3
|
||||||
|
jsr newline ; new line
|
||||||
|
ldy #0 ; + cr
|
||||||
|
L3: sty CURS_X
|
||||||
|
rts
|
||||||
|
|
||||||
|
newline:
|
||||||
|
clc
|
||||||
|
lda xsize
|
||||||
|
adc SCREEN_PTR
|
||||||
|
sta SCREEN_PTR
|
||||||
|
bcc L4
|
||||||
|
inc SCREEN_PTR+1
|
||||||
|
clc
|
||||||
|
L4: lda xsize
|
||||||
|
adc CRAM_PTR
|
||||||
|
sta CRAM_PTR
|
||||||
|
bcc L5
|
||||||
|
inc CRAM_PTR+1
|
||||||
|
L5: inc CURS_Y
|
||||||
|
rts
|
||||||
|
|
||||||
|
; Handle character if high bit set
|
||||||
|
|
||||||
|
L10: and #$7F
|
||||||
|
cmp #$7E ; PI?
|
||||||
|
bne L11
|
||||||
|
lda #$5E ; Load screen code for PI
|
||||||
|
bne cputdirect
|
||||||
|
L11: ora #$40
|
||||||
|
bne cputdirect
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; Set cursor position, calculate RAM pointers
|
||||||
|
|
||||||
|
plot: ldy CURS_X
|
||||||
|
ldx CURS_Y
|
||||||
|
clc
|
||||||
|
jmp PLOT ; Set the new cursor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; Write one character to the screen without doing anything else, return X
|
||||||
|
; position in Y
|
||||||
|
|
||||||
|
putchar:
|
||||||
|
ora revers ; Set revers bit
|
||||||
|
ldy CURS_X
|
||||||
|
sta (SCREEN_PTR),y ; Set char
|
||||||
|
lda CHARCOLOR
|
||||||
|
sta (CRAM_PTR),y ; Set color
|
||||||
|
rts
|
137
libsrc/vic20/crt0.s
Normal file
137
libsrc/vic20/crt0.s
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
;
|
||||||
|
; Startup code for cc65 (Vic20 version)
|
||||||
|
;
|
||||||
|
; This must be the *first* file on the linker command line
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _exit
|
||||||
|
.import initlib, donelib
|
||||||
|
.import zerobss, push0
|
||||||
|
.import _main
|
||||||
|
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
.include "../cbm/cbm.inc"
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; Define and export the ZP variables for the Vic20 runtime
|
||||||
|
|
||||||
|
.exportzp sp, sreg, regsave
|
||||||
|
.exportzp ptr1, ptr2, ptr3, ptr4
|
||||||
|
.exportzp tmp1, tmp2, tmp3, tmp4
|
||||||
|
.exportzp regbank, zpspace
|
||||||
|
|
||||||
|
.zeropage
|
||||||
|
|
||||||
|
zpstart = *
|
||||||
|
sp: .res 2 ; Stack pointer
|
||||||
|
sreg: .res 2 ; Secondary register/high 16 bit for longs
|
||||||
|
regsave: .res 4 ; slot to save/restore (E)AX into
|
||||||
|
ptr1: .res 2
|
||||||
|
ptr2: .res 2
|
||||||
|
ptr3: .res 2
|
||||||
|
ptr4: .res 2
|
||||||
|
tmp1: .res 1
|
||||||
|
tmp2: .res 1
|
||||||
|
tmp3: .res 1
|
||||||
|
tmp4: .res 1
|
||||||
|
regbank: .res 6 ; 6 byte register bank
|
||||||
|
|
||||||
|
zpspace = * - zpstart ; Zero page space allocated
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; BASIC header with a SYS call
|
||||||
|
|
||||||
|
.org $FFF
|
||||||
|
.word Head ; Load address
|
||||||
|
Head: .word @Next
|
||||||
|
.word 1000 ; Line number
|
||||||
|
.byte $9E,"4109" ; SYS 2061
|
||||||
|
.byte $00 ; End of BASIC line
|
||||||
|
@Next: .word 0 ; BASIC end marker
|
||||||
|
.reloc
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; Actual code
|
||||||
|
|
||||||
|
ldx #zpspace-1
|
||||||
|
L1: lda sp,x
|
||||||
|
sta zpsave,x ; Save the zero page locations we need
|
||||||
|
dex
|
||||||
|
bpl L1
|
||||||
|
|
||||||
|
; Close open files
|
||||||
|
|
||||||
|
jsr CLRCH
|
||||||
|
|
||||||
|
; Switch to second charset
|
||||||
|
|
||||||
|
lda #14
|
||||||
|
jsr BSOUT
|
||||||
|
|
||||||
|
; Clear the BSS data
|
||||||
|
|
||||||
|
jsr zerobss
|
||||||
|
|
||||||
|
; Save system stuff and setup the stack
|
||||||
|
|
||||||
|
tsx
|
||||||
|
stx spsave ; Save the system stack ptr
|
||||||
|
|
||||||
|
; lda $01
|
||||||
|
; sta mmusave ; Save the memory configuration
|
||||||
|
; and #$F8
|
||||||
|
; ora #$06 ; Enable kernal+I/O, disable basic
|
||||||
|
; sta $01
|
||||||
|
|
||||||
|
lda #<(__RAM_START__ + __RAM_SIZE__)
|
||||||
|
sta sp
|
||||||
|
lda #>(__RAM_START__ + __RAM_SIZE__)
|
||||||
|
sta sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
|
; Call module constructors
|
||||||
|
|
||||||
|
jsr initlib
|
||||||
|
|
||||||
|
; Pass an empty command line
|
||||||
|
|
||||||
|
jsr push0 ; argc
|
||||||
|
jsr push0 ; argv
|
||||||
|
|
||||||
|
ldy #4 ; Argument size
|
||||||
|
jsr _main ; call the users code
|
||||||
|
|
||||||
|
; Call module destructors. This is also the _exit entry.
|
||||||
|
|
||||||
|
_exit: jsr donelib ; Run module destructors
|
||||||
|
|
||||||
|
; Restore system stuff
|
||||||
|
|
||||||
|
ldx spsave
|
||||||
|
txs ; Restore stack pointer
|
||||||
|
; lda mmusave
|
||||||
|
; sta $01 ; Restore memory configuration
|
||||||
|
|
||||||
|
; Copy back the zero page stuff
|
||||||
|
|
||||||
|
ldx #zpspace-1
|
||||||
|
L2: lda zpsave,x
|
||||||
|
sta sp,x
|
||||||
|
dex
|
||||||
|
bpl L2
|
||||||
|
|
||||||
|
; Reset changed vectors, back to basic
|
||||||
|
|
||||||
|
jmp RESTOR
|
||||||
|
|
||||||
|
|
||||||
|
.data
|
||||||
|
|
||||||
|
zpsave: .res zpspace
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
spsave: .res 1
|
||||||
|
mmusave:.res 1
|
20
libsrc/vic20/kbhit.s
Normal file
20
libsrc/vic20/kbhit.s
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 06.08.1998
|
||||||
|
;
|
||||||
|
; int kbhit (void);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _kbhit
|
||||||
|
.import return0, return1
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
||||||
|
_kbhit:
|
||||||
|
lda KEY_COUNT ; Get number of characters
|
||||||
|
bne L1
|
||||||
|
jmp return0
|
||||||
|
L1: jmp return1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
51
libsrc/vic20/read.s
Normal file
51
libsrc/vic20/read.s
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 30.05.1998
|
||||||
|
;
|
||||||
|
; int read (int fd, void* buf, int count);
|
||||||
|
;
|
||||||
|
; THIS IS A HACK!
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _read
|
||||||
|
.import popax
|
||||||
|
.importzp ptr1, ptr2, ptr3
|
||||||
|
|
||||||
|
.include "../cbm/cbm.inc"
|
||||||
|
|
||||||
|
_read: jsr popax ; get count
|
||||||
|
sta ptr2
|
||||||
|
stx ptr2+1 ; save it for later
|
||||||
|
jsr popax ; get buf
|
||||||
|
sta ptr1
|
||||||
|
stx ptr1+1
|
||||||
|
jsr popax ; get fd and discard it
|
||||||
|
lda #0
|
||||||
|
sta ptr3
|
||||||
|
sta ptr3+1 ; set count
|
||||||
|
|
||||||
|
L1: lda ptr2
|
||||||
|
ora ptr2+1 ; count zero?
|
||||||
|
beq L9
|
||||||
|
dec ptr2
|
||||||
|
bne L1a
|
||||||
|
dec ptr2+1
|
||||||
|
L1a: jsr BASIN
|
||||||
|
ldy #0
|
||||||
|
sta (ptr1),y ; save char
|
||||||
|
inc ptr1
|
||||||
|
bne L2
|
||||||
|
inc ptr1+1
|
||||||
|
L2: inc ptr3 ; increment count
|
||||||
|
bne L3
|
||||||
|
inc ptr3+1
|
||||||
|
L3: cmp #$0D ; CR?
|
||||||
|
bne L1
|
||||||
|
|
||||||
|
; Done, return the count
|
||||||
|
|
||||||
|
L9: lda ptr3
|
||||||
|
ldx ptr3+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
73
libsrc/vic20/readjoy.s
Normal file
73
libsrc/vic20/readjoy.s
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 23.09.1998
|
||||||
|
; Adapted for Vic20 by Steve Schmidtke 05.08.2002
|
||||||
|
;
|
||||||
|
; unsigned readjoy (unsigned char joy);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _readjoy
|
||||||
|
|
||||||
|
.include "vic20.inc"
|
||||||
|
|
||||||
|
|
||||||
|
.proc _readjoy
|
||||||
|
|
||||||
|
tax ; Joystick number into X
|
||||||
|
bne joy2
|
||||||
|
|
||||||
|
; Read joystick 1
|
||||||
|
|
||||||
|
joy1: lda #$7F
|
||||||
|
ldx #$C3
|
||||||
|
sei ; necessary?
|
||||||
|
ldy VIA1_DDRA
|
||||||
|
stx VIA1_DDRA
|
||||||
|
ldx VIA1_JOY
|
||||||
|
sty VIA1_DDRA
|
||||||
|
ldy VIA2_DDRB
|
||||||
|
sta VIA2_DDRB
|
||||||
|
lda VIA2_JOY ; sw3 happens to be the 7th bit (i.e negative)
|
||||||
|
sty VIA2_DDRB
|
||||||
|
cli ; necessary?
|
||||||
|
; all this mess below tries to normalize the returned results (see joystick.h)
|
||||||
|
; by shifting bits around and inserting switch3 (right).
|
||||||
|
; easier (and far smaller) would have been just to return the bits where they
|
||||||
|
; lay and just #ifdef different joystick constants for the Vic20.
|
||||||
|
bmi s3_off ; must stay valid from the VIA2_JOY load
|
||||||
|
txa ; state: sw3 on, fire ?
|
||||||
|
and #$20 ; find out if fire has been pressed
|
||||||
|
bne f_off1
|
||||||
|
txa ; state: sw3 on, fire on
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
and #$07
|
||||||
|
eor #$1F
|
||||||
|
rts
|
||||||
|
f_off1: txa ; state: sw3 on, fire off
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
and #$07
|
||||||
|
eor #$0F
|
||||||
|
rts
|
||||||
|
s3_off: txa ; state: sw3 off, fire ?
|
||||||
|
and #$20 ; find out if fire has been pressed
|
||||||
|
bne f_off2 ; yeah, that's just about my sentiment by now
|
||||||
|
txa ; state: sw3 off, fire on
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
and #$07
|
||||||
|
eor #$17
|
||||||
|
rts
|
||||||
|
f_off2: txa ; state: sw3 off, fire off
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
and #$07
|
||||||
|
eor #$07
|
||||||
|
rts
|
||||||
|
|
||||||
|
; Read joystick 2 + (just return joy1)
|
||||||
|
|
||||||
|
joy2: jmp joy1 ; stub for more joysticks (pointless?)
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
67
libsrc/vic20/vic20.inc
Normal file
67
libsrc/vic20/vic20.inc
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
;
|
||||||
|
; Vic20 generic definitions. Stolen mostly from c64.inc - Steve Schmidtke
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Zero page, Commodore stuff
|
||||||
|
|
||||||
|
ST = $90 ; IEC status byte
|
||||||
|
|
||||||
|
FNAM_LEN = $B7 ; Length of filename
|
||||||
|
SECADR = $B9 ; Secondary address
|
||||||
|
DEVNUM = $BA ; Device number
|
||||||
|
KEY_COUNT = $C6 ; Number of keys in input buffer
|
||||||
|
CURS_FLAG = $CC ; 1 = cursor off
|
||||||
|
CURS_BLINK = $CD ; Blink counter
|
||||||
|
CURS_CHAR = $CE ; Character under the cursor
|
||||||
|
CURS_COLOR = $287 ; Color under the cursor
|
||||||
|
CURS_STATE = $CF ; Cursor blink state
|
||||||
|
SCREEN_PTR = $D1 ; Pointer to current char in text screen
|
||||||
|
CURS_X = $D3 ; Cursor column
|
||||||
|
CURS_Y = $D6 ; Cursor row
|
||||||
|
CRAM_PTR = $F3 ; Pointer to current char in color RAM
|
||||||
|
|
||||||
|
CHARCOLOR = $286
|
||||||
|
PALFLAG = $2A6 ; $01 = PAL, $00 = NTSC
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Kernal routines
|
||||||
|
|
||||||
|
; Direct entries
|
||||||
|
CLRSCR = $E55F
|
||||||
|
KBDREAD = $E5CF
|
||||||
|
NAMED_OPEN = $F495
|
||||||
|
NAMED_CLOSE = $F6DA
|
||||||
|
PLOTCHAR = $EAAA ; Char in A, color in X
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Vector and other locations
|
||||||
|
|
||||||
|
IRQVec = $0314
|
||||||
|
BRKVec = $0316
|
||||||
|
NMIVec = $0318
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; I/O: 6560 VIC
|
||||||
|
|
||||||
|
VIC = $9000
|
||||||
|
VIC_COLOR = $900F
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; I/O: 6522 VIA1
|
||||||
|
|
||||||
|
VIA1 = $9110
|
||||||
|
VIA1_JOY = $9111
|
||||||
|
VIA1_DDRB = $9112
|
||||||
|
VIA1_DDRA = $9113
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; I/O: 6522 VIA2
|
||||||
|
|
||||||
|
VIA2 = $9120
|
||||||
|
VIA2_JOY = $9120
|
||||||
|
VIA2_DDRB = $9122
|
||||||
|
VIA2_DDRA = $9123
|
||||||
|
|
47
libsrc/vic20/write.s
Normal file
47
libsrc/vic20/write.s
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 30.05.1998
|
||||||
|
;
|
||||||
|
; int write (int fd, const void* buf, int count);
|
||||||
|
;
|
||||||
|
; THIS IS A HACK!
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _write
|
||||||
|
.import popax
|
||||||
|
.importzp ptr1, ptr2, ptr3
|
||||||
|
|
||||||
|
.include "../cbm/cbm.inc"
|
||||||
|
|
||||||
|
_write: jsr popax ; get count
|
||||||
|
sta ptr2
|
||||||
|
stx ptr2+1 ; save it for later
|
||||||
|
sta ptr3
|
||||||
|
stx ptr3+1 ; save for function result
|
||||||
|
jsr popax ; get buf
|
||||||
|
sta ptr1
|
||||||
|
stx ptr1+1
|
||||||
|
jsr popax ; get fd and discard it
|
||||||
|
|
||||||
|
L1: lda ptr2
|
||||||
|
ora ptr2+1 ; count zero?
|
||||||
|
beq L9
|
||||||
|
ldy #0
|
||||||
|
lda (ptr1),y
|
||||||
|
jsr BSOUT
|
||||||
|
inc ptr1
|
||||||
|
bne L2
|
||||||
|
inc ptr1+1
|
||||||
|
L2: lda ptr2
|
||||||
|
bne L3
|
||||||
|
dec ptr2
|
||||||
|
dec ptr2+1
|
||||||
|
jmp L1
|
||||||
|
L3: dec ptr2
|
||||||
|
jmp L1
|
||||||
|
|
||||||
|
; No error, return count
|
||||||
|
|
||||||
|
L9: lda ptr3
|
||||||
|
ldx ptr3+1
|
||||||
|
rts
|
||||||
|
|
|
@ -152,6 +152,10 @@ static void SetSys (const char* Sys)
|
||||||
cbmsys ("__C64__");
|
cbmsys ("__C64__");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TGT_VIC20:
|
||||||
|
cbmsys ("__VIC20__");
|
||||||
|
break;
|
||||||
|
|
||||||
case TGT_C128:
|
case TGT_C128:
|
||||||
cbmsys ("__C128__");
|
cbmsys ("__C128__");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -55,6 +55,7 @@ const char* TargetNames [TGT_COUNT] = {
|
||||||
"none",
|
"none",
|
||||||
"module",
|
"module",
|
||||||
"atari",
|
"atari",
|
||||||
|
"vic20",
|
||||||
"c64",
|
"c64",
|
||||||
"c128",
|
"c128",
|
||||||
"ace",
|
"ace",
|
||||||
|
@ -106,4 +107,4 @@ target_t FindTarget (const char* Name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef enum {
|
||||||
TGT_NONE,
|
TGT_NONE,
|
||||||
TGT_MODULE,
|
TGT_MODULE,
|
||||||
TGT_ATARI,
|
TGT_ATARI,
|
||||||
|
TGT_VIC20,
|
||||||
TGT_C64,
|
TGT_C64,
|
||||||
TGT_C128,
|
TGT_C128,
|
||||||
TGT_ACE,
|
TGT_ACE,
|
||||||
|
|
|
@ -143,6 +143,7 @@ void TgtTranslateInit (void)
|
||||||
case TGT_NONE: memcpy (Tab, CTNone, sizeof (Tab)); break;
|
case TGT_NONE: memcpy (Tab, CTNone, sizeof (Tab)); break;
|
||||||
case TGT_MODULE: memcpy (Tab, CTNone, sizeof (Tab)); break;
|
case TGT_MODULE: memcpy (Tab, CTNone, sizeof (Tab)); break;
|
||||||
case TGT_ATARI: memcpy (Tab, CTAtari, sizeof (Tab)); break;
|
case TGT_ATARI: memcpy (Tab, CTAtari, sizeof (Tab)); break;
|
||||||
|
case TGT_VIC20: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
||||||
case TGT_C64: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
case TGT_C64: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
||||||
case TGT_C128: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
case TGT_C128: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
||||||
case TGT_ACE: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
case TGT_ACE: memcpy (Tab, CTPET, sizeof (Tab)); break;
|
||||||
|
|
|
@ -16,3 +16,4 @@ lunix.inc
|
||||||
none.inc
|
none.inc
|
||||||
pet.inc
|
pet.inc
|
||||||
plus4.inc
|
plus4.inc
|
||||||
|
vic20.inc
|
||||||
|
|
27
src/ld65/cfg/vic20.cfg
Normal file
27
src/ld65/cfg/vic20.cfg
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
MEMORY {
|
||||||
|
ZP: start = $02, size = $1A, type = rw, define = yes;
|
||||||
|
RAM: start = $FFF, size = $0E01, define = yes, file = %O;
|
||||||
|
}
|
||||||
|
SEGMENTS {
|
||||||
|
CODE: load = RAM, type = wprot;
|
||||||
|
RODATA: load = RAM, type = wprot;
|
||||||
|
DATA: load = RAM, type = rw;
|
||||||
|
BSS: load = RAM, type = bss, define = yes;
|
||||||
|
ZEROPAGE: load = ZP, type = zp;
|
||||||
|
}
|
||||||
|
FEATURES {
|
||||||
|
CONDES: segment = RODATA,
|
||||||
|
type = constructor,
|
||||||
|
label = __CONSTRUCTOR_TABLE__,
|
||||||
|
count = __CONSTRUCTOR_COUNT__;
|
||||||
|
CONDES: segment = RODATA,
|
||||||
|
type = destructor,
|
||||||
|
label = __DESTRUCTOR_TABLE__,
|
||||||
|
count = __DESTRUCTOR_COUNT__;
|
||||||
|
}
|
||||||
|
SYMBOLS {
|
||||||
|
__STACKSIZE__ = $400; # 1K stack
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,8 @@ INCS = apple2.inc \
|
||||||
module.inc \
|
module.inc \
|
||||||
none.inc \
|
none.inc \
|
||||||
pet.inc \
|
pet.inc \
|
||||||
plus4.inc
|
plus4.inc \
|
||||||
|
vic20.inc
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -146,4 +147,7 @@ pet.inc: cfg/pet.cfg
|
||||||
plus4.inc: cfg/plus4.cfg
|
plus4.inc: cfg/plus4.cfg
|
||||||
@$(CVT) $< $@ CfgPlus4
|
@$(CVT) $< $@ CfgPlus4
|
||||||
|
|
||||||
|
vic20.inc: cfg/vic20.cfg
|
||||||
|
@$(CVT) $< $@ CfgVic20
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ static const char CfgEmpty[] = "";
|
||||||
#include "none.inc"
|
#include "none.inc"
|
||||||
#include "pet.inc"
|
#include "pet.inc"
|
||||||
#include "plus4.inc"
|
#include "plus4.inc"
|
||||||
|
#include "vic20.inc"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ const TargetDesc Targets [TGT_COUNT] = {
|
||||||
{ BINFMT_BINARY, CfgNone },
|
{ BINFMT_BINARY, CfgNone },
|
||||||
{ BINFMT_O65, CfgModule },
|
{ BINFMT_O65, CfgModule },
|
||||||
{ BINFMT_BINARY, CfgAtari },
|
{ BINFMT_BINARY, CfgAtari },
|
||||||
|
{ BINFMT_BINARY, CfgVic20 },
|
||||||
{ BINFMT_BINARY, CfgC64 },
|
{ BINFMT_BINARY, CfgC64 },
|
||||||
{ BINFMT_BINARY, CfgC128 },
|
{ BINFMT_BINARY, CfgC128 },
|
||||||
{ BINFMT_BINARY, CfgEmpty }, /* Ace */
|
{ BINFMT_BINARY, CfgEmpty }, /* Ace */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user