mirror of
https://github.com/cc65/cc65.git
synced 2024-12-22 12:30:41 +00:00
More P500 support
git-svn-id: svn://svn.cc65.org/cc65/trunk@920 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
c4a49faf48
commit
e1a9115fd4
@ -17,6 +17,8 @@ OBJS = _scrsize.o \
|
||||
cgetc.o \
|
||||
clrscr.o \
|
||||
color.o \
|
||||
conio.o \
|
||||
cputc.o \
|
||||
crt0.o \
|
||||
kbhit.o \
|
||||
kirq.o \
|
||||
|
@ -18,19 +18,26 @@
|
||||
sta CURS_Y
|
||||
jsr plot ; Set cursor to top left corner
|
||||
|
||||
ldx #4
|
||||
ldy #$00
|
||||
lda #$20 ; Screencode for blank
|
||||
L1: sta (CharPtr),y
|
||||
iny
|
||||
bne L1
|
||||
inc CharPtr+1
|
||||
dex
|
||||
bne L1
|
||||
|
||||
jmp plot ; Set screen pointer again
|
||||
ldx #$00
|
||||
ldy #$00
|
||||
jsr clearpage
|
||||
jsr clearpage
|
||||
jsr clearpage
|
||||
ldx #<(40*25)
|
||||
jsr clearpage ; Clear remainder of last page
|
||||
jmp plot ; Set screen pointer again
|
||||
|
||||
.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
|
||||
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
|
||||
|
||||
lda ExecReg
|
||||
@ -263,10 +235,52 @@ Z4:
|
||||
|
||||
; 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.
|
||||
; 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
|
||||
|
||||
; 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
|
||||
|
||||
jsr initlib
|
||||
@ -359,6 +373,25 @@ Start:
|
||||
|
||||
_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
|
||||
; (garbage) BASIC program otherwise. This is also the default entry for
|
||||
; the break vector.
|
||||
@ -373,8 +406,6 @@ Clear: sta $02,x
|
||||
; Setup the welcome code at the stack bottom in the system bank. Use
|
||||
; the F4/F5 vector to access the system bank
|
||||
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
ldy #$00
|
||||
sty $F4
|
||||
iny
|
||||
@ -445,6 +476,6 @@ k_settim:
|
||||
|
||||
.data
|
||||
spsave: .res 1
|
||||
|
||||
vidsave:.res 3
|
||||
|
||||
|
||||
|
@ -154,5 +154,5 @@ VIC_BG_COLOR3 = $24
|
||||
; Out video memory address
|
||||
|
||||
VIDEO_RAM = $F800
|
||||
|
||||
COLOR_RAM = $D400
|
||||
|
||||
|
@ -10,57 +10,32 @@
|
||||
.include "zeropage.inc"
|
||||
.include "io.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
|
||||
.proc k_plot
|
||||
|
||||
bcc set
|
||||
ldx CURS_Y
|
||||
ldy CURS_X
|
||||
rts
|
||||
bcs get
|
||||
|
||||
set: stx CURS_Y
|
||||
stx CURS_Y
|
||||
sty CURS_X
|
||||
|
||||
lda LineLSBTab,x
|
||||
sta CharPtr
|
||||
lda LineMSBTab,x
|
||||
sta CharPtr+1
|
||||
lda LineLSBTab,x
|
||||
sta SCREEN_PTR
|
||||
sta CRAM_PTR
|
||||
lda LineMSBTab,x
|
||||
sta SCREEN_PTR+1
|
||||
sub #>VIDEO_RAM
|
||||
add #>COLOR_RAM
|
||||
sta CRAM_PTR+1
|
||||
|
||||
.if 0
|
||||
lda IndReg
|
||||
pha
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
get: ldx CURS_Y
|
||||
ldy CURS_X
|
||||
|
||||
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
|
||||
|
||||
.endproc
|
||||
|
||||
; -------------------------------------------------------------------------
|
||||
|
@ -67,7 +67,7 @@ PgmKeyBuf = $C0
|
||||
PgmKeyPtr = $C2
|
||||
sedsal = $C4
|
||||
sedeal = $C6
|
||||
CharPtr = $C8
|
||||
SCREEN_PTR = $C8
|
||||
CURS_Y = $CA
|
||||
CURS_X = $CB
|
||||
GrafMode = $CC
|
||||
@ -95,7 +95,7 @@ NorKey = $E1
|
||||
BitTable = $E2
|
||||
BlinkOn = $E6
|
||||
BlinkCounter = $E7
|
||||
ColorRamPtr = $E8
|
||||
CRAM_PTR = $E8
|
||||
TempColor = $EA
|
||||
BlinkSwitch = $EB
|
||||
CHARCOLOR = $EC
|
||||
|
Loading…
Reference in New Issue
Block a user