1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

Adding CBM510 support

git-svn-id: svn://svn.cc65.org/cc65/trunk@913 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-09-13 21:37:59 +00:00
parent 7f88d979f6
commit 14f2349ea1
8 changed files with 498 additions and 6 deletions

38
libsrc/cbm510/cgetc.s Normal file
View File

@ -0,0 +1,38 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; char cgetc (void);
;
.export _cgetc
.import plot, write_crtc
.import cursor
.include "zeropage.inc"
.include "page3.inc"
; ------------------------------------------------------------------------
.proc _cgetc
L1: lda KeyIndex
beq L1
L2: ldx #$00 ; Get index
ldy KeyBuf ; Get first character in the buffer
sei
L3: lda KeyBuf+1,x ; Move up the remaining chars
sta KeyBuf,x
inx
cpx KeyIndex
bne L3
dec KeyIndex
cli
ldx #$00 ; High byte
tya ; First char from buffer
rts
.endproc

65
libsrc/cbm510/color.s Normal file
View File

@ -0,0 +1,65 @@
;
; Ullrich von Bassewitz, 13.09.2001
;
.export _textcolor, _bgcolor, _bordercolor
.import sys_bank, restore_bank
.importzp vic
.include "zeropage.inc"
.include "io.inc"
; ------------------------------------------------------------------------
; unsigned char __fastcall__ textcolor (unsigned char color);
; /* Set the color for text output. The old color setting is returned. */
;
.proc _textcolor
ldx CHARCOLOR ; get old value
sta CHARCOLOR ; set new value
txa
rts
.endproc
; ------------------------------------------------------------------------
; unsigned char __fastcall__ bgcolor (unsigned char color);
; /* Set the color for the background. The old color setting is returned. */
;
.proc _bgcolor
jsr sys_bank ; Switch to the system bank
pha ; Save new color
ldy #VIC_BG_COLOR0
lda (vic),y ; Get current color...
tax ; ...into X
pla ; Get new color
sta (vic),y ; Set new color
txa ; Get old color into X
jmp restore_bank ; Restore the old color
.endproc
; ------------------------------------------------------------------------
; unsigned char __fastcall__ bordercolor (unsigned char color);
; /* Set the color for the border. The old color setting is returned. */
.proc _bordercolor
jsr sys_bank ; Switch to the system bank
pha ; Save new color
ldy #VIC_BORDERCOLOR
lda (vic),y ; Get current color...
tax ; ...into X
pla ; Get new color
sta (vic),y ; Set new color
txa ; Get old color into X
jmp restore_bank ; Restore the old color
.endproc

View File

@ -95,10 +95,10 @@ cia: .word $dc00
acia: .word $dd00
tpi1: .word $de00
tpi2: .word $df00
ktab1: .word $ea29
ktab2: .word $ea89
ktab3: .word $eae9
ktab4: .word $eb49
ktab1: .word $eab1
ktab2: .word $eb11
ktab3: .word $eb71
ktab4: .word $ebd1
time: .dword $0000
RecvBuf: .word $0100 ; RS232 received buffer
SendBuf: .word $0200 ; RS232 send buffer
@ -244,7 +244,7 @@ Z4:
jsr push0 ; argc
jsr push0 ; argv
; Execute the program code
; Execute the program code
jmp Start

100
libsrc/cbm510/kirq.s Normal file
View File

@ -0,0 +1,100 @@
;
; Ullrich von Bassewitz, 28.09.1998
;
; IRQ routine for the 510.
;
.export irq, nmi, k_irq, k_nmi
.import k_scnkey, k_udtim, k_rs232
.importzp tpi1
.include "zeropage.inc"
.include "io.inc"
.include "page3.inc"
; -------------------------------------------------------------------------
; This is the mapping of the active irq register of the 6525 (tpi1):
;
; Bit 7 6 5 4 3 2 1 0
; | | | | ^ 50 Hz
; | | | ^ SRQ IEEE 488
; | | ^ cia
; | ^ IRQB ext. Port
; ^ acia
; -------------------------------------------------------------------------
; IRQ entry point
.proc irq
pha
txa
pha
tya
pha
tsx
lda $104,x ; Get the flags from the stack
and #$10 ; Test break flag
bne L1
jmp (IRQVec)
L1: jmp (BRKVec)
.endproc
; -------------------------------------------------------------------------
; NMI entry point
.proc nmi
jmp (NMIVec)
.endproc
; -------------------------------------------------------------------------
; Kernal irq entry point. The IRQvec points here (usually).
k_irq:
lda IndReg ; Ind. Segment retten
pha
cld
lda #$0F
sta IndReg
ldy #tpiActIntReg
lda (tpi1),y ; Interrupt Register 6525
beq noirq
; -------------------------------------------------------------------------
; 50/60Hz interrupt
cmp #%00000001 ; ticker irq?
bne irq1
jsr k_scnkey ; Poll the keyboard
jsr k_udtim ; Bump the time
; -------------------------------------------------------------------------
; UART interrupt
irq1: cmp #%00010000 ; interrupt from uart?
bne irqend
jsr k_rs232 ; Read character from uart
; -------------------------------------------------------------------------
; Done
irqend: ldy #tpiActIntReg
sta (tpi1),y ; Clear interrupt
noirq: pla
sta IndReg
pla
tay
pla
tax
pla
k_nmi: rti

146
libsrc/cbm510/kscnkey.s Normal file
View File

@ -0,0 +1,146 @@
;
; Ullrich von Bassewitz, 13.09.2001
;
; Keyboard polling stuff for the 510.
;
.export k_scnkey
.importzp tpi2, ktab1, ktab2, ktab3, ktab4
.include "zeropage.inc"
.include "io.inc"
.include "page3.inc"
.proc k_scnkey
lda #$FF
sta ModKey
sta NorKey
lda #$00
sta KbdScanBuf
ldy #tpiPortB
sta (tpi2),y
ldy #tpiPortA
sta (tpi2),y
jsr Poll
and #$3F
eor #$3F
bne L1
jmp NoKey
L1: lda #$FF
ldy #tpiPortA
sta (tpi2),y
asl a
ldy #tpiPortB
sta (tpi2),y
jsr Poll
pha
sta ModKey
ora #$30
bne L3 ; Branch always
L2: jsr Poll
L3: ldx #$05
ldy #$00
L4: lsr a
bcc L5
inc KbdScanBuf
dex
bpl L4
sec
ldy #tpiPortB
lda (tpi2),y
rol a
sta (tpi2),y
ldy #tpiPortA
lda (tpi2),y
rol a
sta (tpi2),y
bcs L2
pla
bcc NoKey ; Branch always
L5: ldy KbdScanBuf
sty NorKey
pla
asl a
asl a
asl a
bcc L6
bmi L7
lda (ktab2),y ; Shifted normal key
ldx GrafMode
beq L8
lda (ktab3),y ; Shifted key in graph mode
bne L8
L6: lda (ktab4),y ; Key with ctrl pressed
bne L8
L7: lda (ktab1),y ; Normal key
L8: tax
cpx #$FF ; Valid key?
beq Done
cpy LastIndex
beq Repeat
ldx #$13
stx RepeatDelay
ldx KeyIndex
cpx #$09
beq NoKey
cpy #$59
bne PutKey
cpx #$08
beq NoKey
sta KeyBuf,x
inx
bne PutKey
NoKey: ldy #$FF
Done: sty LastIndex
End: lda #$7F
ldy #tpiPortA
sta (tpi2),y
ldy #tpiPortB
lda #$FF
sta (tpi2),y
rts
Repeat: dec RepeatDelay
bpl End
inc RepeatDelay
dec RepeatCount
bpl End
inc RepeatCount
ldx KeyIndex
bne End
PutKey: sta KeyBuf,x
inx
stx KeyIndex
ldx #$03
stx RepeatCount
bne Done
.endproc
; Poll the keyboard port until it's stable
.proc Poll
ldy #tpiPortC
L1: lda (tpi2),y
sta KeySave
lda (tpi2),y
cmp KeySave
bne L1
rts
.endproc
.bss
KeySave: .res 1

94
libsrc/cbm510/page3.inc Normal file
View File

@ -0,0 +1,94 @@
;
; Page 3 variables for the CBM 610
;
; Taken from a kernal disassembly done by myself in 1987.
;
; Ullrich von Bassewitz, 28.09.1998
;
; system ram vectors
;
IRQVec = $0300
BRKVec = $0302
NMIVec = $0304
openVec = $0306
closeVec = $0308
chkinVec = $030A
ckoutVec = $030C
clrchVec = $030E
basinVec = $0310
bsoutVec = $0312
stopVec = $0314
getinVec = $0316
clallVec = $0318
loadVec = $031A
saveVec = $031C
usrcmd = $031E
escvec = $0320
ctrlvec = $0322
secndVec = $0324
tksaVec = $0326
acptrVec = $0328
cioutVec = $032A
untlkVec = $032C
unlsnVec = $032E
listnVec = $0330
talkVec = $0332
;
;
;
LogicalAdrTable = $0334
FirstAdrTable = $033E
SecondAdrTable = $0348
SysMemBot = $0352
SysMemTop = $0355
UsrMemBot = $0358
UsrMemTop = $035B
TimOut = $035E
VerifyFlag = $035F
DevTabIndex = $0360
MsgFlag = $0361
CassBufPtr = $0362
t1 = $0363
t2 = $0364
XSave = $0365
SaveX = $0366
SaveXt = $0367
temp = $0368
alarm = $0369
TapeVec = $036A
LoadStAdr = $036F
CassMotFlag = $0375
m6551Ctrl = $0376
m6551Cmd = $0377
rs232status = $037A
dcddsr = $037B
rs232head = $037C
rs232tail = $037D
PgmKeyEnd = $0380
PgmKeySeg = $0382
PgmKeySize = $0383
rvsFlag = $0397
linetmp = $0398
LastPrtChar = $0399
InsertFlag = $039A
ScrollFlag = $039B
FktTemp = $039C
PgmKeyIdx = $039D
LogScrollFlag = $039E
BellMode = $039F ; Bell on/off 00 = an
SegSave = $03A0
TabStopTable = $03A1 ; 80 bits for tabstops
KeyBuf = $03AB ; Keyboard buffer
funvec = $03B5 ; Vector for function key handline
FunKeyTmp = $03B7
sedt3 = $03B9
MoniSegSave = $03f0
wstvec = $03F8
WstFlag = $03FA ; Warm start flag

49
libsrc/cbm510/pokesys.s Normal file
View File

@ -0,0 +1,49 @@
;
; Ullrich von Bassewitz, 13.09.2001
;
; void pokebsys (unsigned Addr, unsigned char Val);
; void pokewsys (unsigned Addr, unsigned Val);
.export _pokebsys, _pokewsys
.import popsreg
.importzp sreg, tmp1
.include "zeropage.inc"
; ------------------------------------------------------------------------
;
.proc _pokebsys
jsr popsreg ; Get the address
ldx IndReg
ldy #$0F
sty IndReg ; Switch to the system bank
ldy #$00
sta (sreg),y
stx IndReg
rts
.endproc
; ------------------------------------------------------------------------
;
.proc _pokewsys
stx tmp1 ; Save high byte
jsr popsreg ; Get the address
ldx IndReg
ldy #$0F
sty IndReg ; Switch to the system bank
ldy #$00
sta (sreg),y
iny
lda tmp1
sta (sreg),y
stx IndReg
rts
.endproc

View File

@ -98,7 +98,7 @@ BlinkCounter = $E7
ColorRamPtr = $E8
TempColor = $EA
BlinkSwitch = $EB
CharColor = $EC
CHARCOLOR = $EC
CursBackColor = $ED ; Color behind cursor
OutCharTmp = $EE
ScreenSeq = $EF ; Segment of video RAM