More P500 support
git-svn-id: svn://svn.cc65.org/cc65/trunk@920 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -17,6 +17,8 @@ OBJS = _scrsize.o \
|
|||||||
cgetc.o \
|
cgetc.o \
|
||||||
clrscr.o \
|
clrscr.o \
|
||||||
color.o \
|
color.o \
|
||||||
|
conio.o \
|
||||||
|
cputc.o \
|
||||||
crt0.o \
|
crt0.o \
|
||||||
kbhit.o \
|
kbhit.o \
|
||||||
kirq.o \
|
kirq.o \
|
||||||
|
|||||||
@@ -18,19 +18,26 @@
|
|||||||
sta CURS_Y
|
sta CURS_Y
|
||||||
jsr plot ; Set cursor to top left corner
|
jsr plot ; Set cursor to top left corner
|
||||||
|
|
||||||
ldx #4
|
|
||||||
ldy #$00
|
|
||||||
lda #$20 ; Screencode for blank
|
lda #$20 ; Screencode for blank
|
||||||
L1: sta (CharPtr),y
|
ldx #$00
|
||||||
iny
|
ldy #$00
|
||||||
bne L1
|
jsr clearpage
|
||||||
inc CharPtr+1
|
jsr clearpage
|
||||||
dex
|
jsr clearpage
|
||||||
bne L1
|
ldx #<(40*25)
|
||||||
|
jsr clearpage ; Clear remainder of last page
|
||||||
jmp plot ; Set screen pointer again
|
jmp plot ; Set screen pointer again
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
.proc clearpage
|
||||||
|
|
||||||
|
@L1: sta (SCREEN_PTR),y
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bne @L1
|
||||||
|
inc SCREEN_PTR+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|||||||
10
libsrc/cbm510/conio.s
Normal file
10
libsrc/cbm510/conio.s
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 14.09.2001
|
||||||
|
;
|
||||||
|
; Low level stuff for screen output/console input
|
||||||
|
;
|
||||||
|
|
||||||
|
.exportzp CURS_X, CURS_Y
|
||||||
|
|
||||||
|
.include "zeropage.inc"
|
||||||
|
|
||||||
109
libsrc/cbm510/cputc.s
Normal file
109
libsrc/cbm510/cputc.s
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 14.09.2001
|
||||||
|
;
|
||||||
|
; 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 "zeropage.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
|
||||||
|
ldx IndReg
|
||||||
|
lda #$0F
|
||||||
|
sta IndReg
|
||||||
|
lda CHARCOLOR
|
||||||
|
sta (CRAM_PTR),y ; Set color
|
||||||
|
stx IndReg
|
||||||
|
rts
|
||||||
|
|
||||||
@@ -176,34 +176,6 @@ L3: lda (ptr1),y
|
|||||||
iny
|
iny
|
||||||
bne L3
|
bne L3
|
||||||
|
|
||||||
; Reprogram the VIC so that the text screen is at $F800 in the execution bank
|
|
||||||
|
|
||||||
; Place the VIC video RAM into bank 0
|
|
||||||
; CA (STATVID) = 0
|
|
||||||
|
|
||||||
ldy #tpiCtrlReg
|
|
||||||
lda (tpi1),y
|
|
||||||
and #$CF
|
|
||||||
ora #$20
|
|
||||||
sta (tpi1),y
|
|
||||||
|
|
||||||
; Set bit 14/15 of the VIC address range to the high bits of VIDEO_RAM
|
|
||||||
; PC6/PC7 (VICBANKSEL 0/1) = 11
|
|
||||||
|
|
||||||
ldy #tpiPortC
|
|
||||||
lda (tpi2),y
|
|
||||||
and #$3F
|
|
||||||
ora #((>VIDEO_RAM) & $C0)
|
|
||||||
sta (tpi2),y
|
|
||||||
|
|
||||||
; Set bits 10-13 of the VIC address range to address F800
|
|
||||||
|
|
||||||
ldy #VIC_VIDEO_ADR
|
|
||||||
lda (vic),y
|
|
||||||
and #$0F
|
|
||||||
ora #(((>VIDEO_RAM) & $3F) << 2)
|
|
||||||
sta (vic),y
|
|
||||||
|
|
||||||
; Set the indirect segment to bank we're executing in
|
; Set the indirect segment to bank we're executing in
|
||||||
|
|
||||||
lda ExecReg
|
lda ExecReg
|
||||||
@@ -263,10 +235,52 @@ Z4:
|
|||||||
|
|
||||||
; This code is in page 2, so we may now start calling subroutines safely,
|
; This code is in page 2, so we may now start calling subroutines safely,
|
||||||
; since the code we execute is no longer in the stack page.
|
; since the code we execute is no longer in the stack page.
|
||||||
; Clear the video memory
|
|
||||||
|
; Clear the video memory. We will do this before switching the video to bank 0
|
||||||
|
; to avoid garbage when doing so.
|
||||||
|
|
||||||
jsr _clrscr
|
jsr _clrscr
|
||||||
|
|
||||||
|
; Reprogram the VIC so that the text screen is at $F800 in the execution bank
|
||||||
|
; This is done in three steps:
|
||||||
|
|
||||||
|
lda #$0F ; We need access to the system bank
|
||||||
|
sta IndReg
|
||||||
|
|
||||||
|
; Place the VIC video RAM into bank 0
|
||||||
|
; CA (STATVID) = 0
|
||||||
|
|
||||||
|
ldy #tpiCtrlReg
|
||||||
|
lda (tpi1),y
|
||||||
|
sta vidsave+0
|
||||||
|
and #$CF
|
||||||
|
ora #$20
|
||||||
|
sta (tpi1),y
|
||||||
|
|
||||||
|
; Set bit 14/15 of the VIC address range to the high bits of VIDEO_RAM
|
||||||
|
; PC6/PC7 (VICBANKSEL 0/1) = 11
|
||||||
|
|
||||||
|
ldy #tpiPortC
|
||||||
|
lda (tpi2),y
|
||||||
|
sta vidsave+1
|
||||||
|
and #$3F
|
||||||
|
ora #((>VIDEO_RAM) & $C0)
|
||||||
|
sta (tpi2),y
|
||||||
|
|
||||||
|
; Set bits 10-13 of the VIC address range to address F800
|
||||||
|
|
||||||
|
ldy #VIC_VIDEO_ADR
|
||||||
|
lda (vic),y
|
||||||
|
sta vidsave+2
|
||||||
|
and #$0F
|
||||||
|
ora #(((>VIDEO_RAM) & $3F) << 2)
|
||||||
|
sta (vic),y
|
||||||
|
|
||||||
|
; Switch back to the execution bank
|
||||||
|
|
||||||
|
lda ExecReg
|
||||||
|
sta IndReg
|
||||||
|
|
||||||
; Call module constructors
|
; Call module constructors
|
||||||
|
|
||||||
jsr initlib
|
jsr initlib
|
||||||
@@ -359,6 +373,25 @@ Start:
|
|||||||
|
|
||||||
_exit: jsr donelib ; Run module destructors
|
_exit: jsr donelib ; Run module destructors
|
||||||
|
|
||||||
|
; We need access to the system bank now
|
||||||
|
|
||||||
|
lda #$0F
|
||||||
|
sta IndReg
|
||||||
|
|
||||||
|
; Switch back the video to the system bank
|
||||||
|
|
||||||
|
ldy #tpiCtrlReg
|
||||||
|
lda vidsave+0
|
||||||
|
sta (tpi1),y
|
||||||
|
|
||||||
|
ldy #tpiPortC
|
||||||
|
lda vidsave+1
|
||||||
|
sta (tpi2),y
|
||||||
|
|
||||||
|
ldy #VIC_VIDEO_ADR
|
||||||
|
lda vidsave+2
|
||||||
|
sta (vic),y
|
||||||
|
|
||||||
; Clear the start of the zero page, since it will be interpreted as a
|
; Clear the start of the zero page, since it will be interpreted as a
|
||||||
; (garbage) BASIC program otherwise. This is also the default entry for
|
; (garbage) BASIC program otherwise. This is also the default entry for
|
||||||
; the break vector.
|
; the break vector.
|
||||||
@@ -373,8 +406,6 @@ Clear: sta $02,x
|
|||||||
; Setup the welcome code at the stack bottom in the system bank. Use
|
; Setup the welcome code at the stack bottom in the system bank. Use
|
||||||
; the F4/F5 vector to access the system bank
|
; the F4/F5 vector to access the system bank
|
||||||
|
|
||||||
lda #$0F
|
|
||||||
sta IndReg
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
sty $F4
|
sty $F4
|
||||||
iny
|
iny
|
||||||
@@ -445,6 +476,6 @@ k_settim:
|
|||||||
|
|
||||||
.data
|
.data
|
||||||
spsave: .res 1
|
spsave: .res 1
|
||||||
|
vidsave:.res 3
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -154,5 +154,5 @@ VIC_BG_COLOR3 = $24
|
|||||||
; Out video memory address
|
; Out video memory address
|
||||||
|
|
||||||
VIDEO_RAM = $F800
|
VIDEO_RAM = $F800
|
||||||
|
COLOR_RAM = $D400
|
||||||
|
|
||||||
|
|||||||
@@ -10,57 +10,32 @@
|
|||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
.include "io.inc"
|
.include "io.inc"
|
||||||
|
|
||||||
|
.macpack generic
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
|
|
||||||
.proc k_plot
|
.proc k_plot
|
||||||
|
|
||||||
bcc set
|
bcs get
|
||||||
ldx CURS_Y
|
|
||||||
ldy CURS_X
|
|
||||||
rts
|
|
||||||
|
|
||||||
set: stx CURS_Y
|
stx CURS_Y
|
||||||
sty CURS_X
|
sty CURS_X
|
||||||
|
|
||||||
lda LineLSBTab,x
|
lda LineLSBTab,x
|
||||||
sta CharPtr
|
sta SCREEN_PTR
|
||||||
|
sta CRAM_PTR
|
||||||
lda LineMSBTab,x
|
lda LineMSBTab,x
|
||||||
sta CharPtr+1
|
sta SCREEN_PTR+1
|
||||||
|
sub #>VIDEO_RAM
|
||||||
|
add #>COLOR_RAM
|
||||||
|
sta CRAM_PTR+1
|
||||||
|
|
||||||
.if 0
|
get: ldx CURS_Y
|
||||||
lda IndReg
|
ldy CURS_X
|
||||||
pha
|
|
||||||
lda #$0F
|
|
||||||
sta IndReg
|
|
||||||
|
|
||||||
ldy #$00
|
|
||||||
clc
|
|
||||||
sei
|
|
||||||
sta (crtc),y
|
|
||||||
lda CharPtr
|
|
||||||
adc CURS_X
|
|
||||||
iny
|
|
||||||
sta (crtc),y
|
|
||||||
dey
|
|
||||||
lda #$0E
|
|
||||||
sta (crtc),y
|
|
||||||
iny
|
|
||||||
lda (crtc),y
|
|
||||||
and #$F8
|
|
||||||
sta sedt1
|
|
||||||
lda CharPtr+1
|
|
||||||
adc #$00
|
|
||||||
and #$07
|
|
||||||
ora sedt1
|
|
||||||
sta (crtc),y
|
|
||||||
cli
|
|
||||||
|
|
||||||
pla
|
|
||||||
sta IndReg
|
|
||||||
.endif
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ PgmKeyBuf = $C0
|
|||||||
PgmKeyPtr = $C2
|
PgmKeyPtr = $C2
|
||||||
sedsal = $C4
|
sedsal = $C4
|
||||||
sedeal = $C6
|
sedeal = $C6
|
||||||
CharPtr = $C8
|
SCREEN_PTR = $C8
|
||||||
CURS_Y = $CA
|
CURS_Y = $CA
|
||||||
CURS_X = $CB
|
CURS_X = $CB
|
||||||
GrafMode = $CC
|
GrafMode = $CC
|
||||||
@@ -95,7 +95,7 @@ NorKey = $E1
|
|||||||
BitTable = $E2
|
BitTable = $E2
|
||||||
BlinkOn = $E6
|
BlinkOn = $E6
|
||||||
BlinkCounter = $E7
|
BlinkCounter = $E7
|
||||||
ColorRamPtr = $E8
|
CRAM_PTR = $E8
|
||||||
TempColor = $EA
|
TempColor = $EA
|
||||||
BlinkSwitch = $EB
|
BlinkSwitch = $EB
|
||||||
CHARCOLOR = $EC
|
CHARCOLOR = $EC
|
||||||
|
|||||||
Reference in New Issue
Block a user