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:
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
|
||||
|
||||
Reference in New Issue
Block a user