From: cuz Date: Thu, 13 Sep 2001 21:37:59 +0000 (+0000) Subject: Adding CBM510 support X-Git-Tag: V2.12.0~2668 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=14f2349ea1d8f24eec6bc0240b81a3396b1d67c2;p=cc65 Adding CBM510 support git-svn-id: svn://svn.cc65.org/cc65/trunk@913 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/cbm510/cgetc.s b/libsrc/cbm510/cgetc.s new file mode 100644 index 000000000..971d66db2 --- /dev/null +++ b/libsrc/cbm510/cgetc.s @@ -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 + diff --git a/libsrc/cbm510/color.s b/libsrc/cbm510/color.s new file mode 100644 index 000000000..04332121f --- /dev/null +++ b/libsrc/cbm510/color.s @@ -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 + + + diff --git a/libsrc/cbm510/crt0.s b/libsrc/cbm510/crt0.s index 1d3f96d28..1b0deb8c9 100644 --- a/libsrc/cbm510/crt0.s +++ b/libsrc/cbm510/crt0.s @@ -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 diff --git a/libsrc/cbm510/kirq.s b/libsrc/cbm510/kirq.s new file mode 100644 index 000000000..25af77784 --- /dev/null +++ b/libsrc/cbm510/kirq.s @@ -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 + + diff --git a/libsrc/cbm510/kscnkey.s b/libsrc/cbm510/kscnkey.s new file mode 100644 index 000000000..d29845d02 --- /dev/null +++ b/libsrc/cbm510/kscnkey.s @@ -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 + + diff --git a/libsrc/cbm510/page3.inc b/libsrc/cbm510/page3.inc new file mode 100644 index 000000000..7095a1348 --- /dev/null +++ b/libsrc/cbm510/page3.inc @@ -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 + + diff --git a/libsrc/cbm510/pokesys.s b/libsrc/cbm510/pokesys.s new file mode 100644 index 000000000..6e94eec46 --- /dev/null +++ b/libsrc/cbm510/pokesys.s @@ -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 + diff --git a/libsrc/cbm510/zeropage.inc b/libsrc/cbm510/zeropage.inc index 161df1174..b6e1be2bf 100644 --- a/libsrc/cbm510/zeropage.inc +++ b/libsrc/cbm510/zeropage.inc @@ -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