banking.o \
break.o \
cgetc.o \
+ clrscr.o \
color.o \
crt0.o \
kbhit.o \
kplot.o \
kscnkey.o \
kudtim.o \
+ peeksys.o \
pokesys.o
all: $(OBJS)
--- /dev/null
+;
+; Ullrich von Bassewitz, 14.09.2001
+;
+
+ .export _clrscr
+ .import plot
+
+ .include "zeropage.inc"
+ .include "io.inc"
+
+; ------------------------------------------------------------------------
+; void __fastcall__ clrscr (void);
+
+.proc _clrscr
+
+ lda #0
+ sta CURS_X
+ 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
+
+.endproc
+
+
+
;
.export _exit
- .import initlib, donelib
- .import push0, _main
- .import __BSS_RUN__, __BSS_SIZE__
- .import irq, nmi
+ .import _clrscr, initlib, donelib
+ .import push0, _main
+ .import __BSS_RUN__, __BSS_SIZE__
+ .import irq, nmi
.import k_irq, k_nmi, k_plot, k_udtim, k_scnkey
- .include "zeropage.inc"
- .include "io.inc"
+ .include "zeropage.inc"
+ .include "io.inc"
; ------------------------------------------------------------------------
; Define and export the ZP variables for the CBM510 runtime
- .exportzp sp, sreg, regsave
- .exportzp ptr1, ptr2, ptr3, ptr4
- .exportzp tmp1, tmp2, tmp3, tmp4
- .exportzp regbank, zpspace
- .exportzp vic, sid, IPCcia, cia, acia, tpi1, tpi2
+ .exportzp sp, sreg, regsave
+ .exportzp ptr1, ptr2, ptr3, ptr4
+ .exportzp tmp1, tmp2, tmp3, tmp4
+ .exportzp regbank, zpspace
+ .exportzp vic, sid, cia1, cia2, acia, tpi1, tpi2
.exportzp ktab1, ktab2, ktab3, ktab4, time, RecvBuf, SendBuf
.zeropage
vic: .word $d800
sid: .word $da00
-IPCcia: .word $db00
-cia: .word $dc00
+cia1: .word $db00
+cia2: .word $dc00
acia: .word $dd00
tpi1: .word $de00
tpi2: .word $df00
; actually used here:
sei
- lda #$01
+ lda #$00
sta ExecReg
; This is the actual starting point of our code after switching banks for
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
+ lda ExecReg
sta IndReg
; Zero the BSS segment. We will do that here instead calling the routine
; Setup the C stack
lda #<$FF81
- sta sp
- lda #>$FF81
- sta sp+1
+ sta sp
+ lda #>$FF81
+ sta sp+1
; We expect to be in page 2 now
; 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
+
+ jsr _clrscr
+
; Call module constructors
jsr initlib
; Code for a few simpler kernal calls goes here
k_iobase:
- ldx cia
- ldy cia+1
+ ldx cia2
+ ldy cia2+1
rts
k_screen:
+; Out video memory address
+
+VIDEO_RAM = $F800
+
;
.export irq, nmi, k_irq, k_nmi
- .import k_scnkey, k_udtim, k_rs232
- .importzp tpi1
+ .import k_scnkey, k_udtim, k_rs232
+ .importzp tpi1
- .include "zeropage.inc"
- .include "io.inc"
- .include "page3.inc"
+ .include "zeropage.inc"
+ .include "io.inc"
+ .include "page3.inc"
; -------------------------------------------------------------------------
; Bit 7 6 5 4 3 2 1 0
; | | | | ^ 50 Hz
; | | | ^ SRQ IEEE 488
-; | | ^ cia
-; | ^ IRQB ext. Port
+; | | ^ cia2
+; | ^ cia1 IRQB ext. Port
; ^ acia
.importzp crtc
.include "zeropage.inc"
-
+ .include "io.inc"
+
+
+; ------------------------------------------------------------------------
+;
.proc k_plot
- bcc set
- ldx CURS_Y
- ldy CURS_X
+ bcc set
+ ldx CURS_Y
+ ldy CURS_X
rts
-set: stx CURS_Y
- sty CURS_X
-
-.if 0
- lda LineLSBTab,x
- sta CharPtr
- lda LineMSBTab,x
- sta CharPtr+1
+set: stx CURS_Y
+ sty CURS_X
+
+ lda LineLSBTab,x
+ sta CharPtr
+ lda LineMSBTab,x
+ sta CharPtr+1
- lda IndReg
+.if 0
+ lda IndReg
pha
- lda #$0F
- sta IndReg
+ lda #$0F
+ sta IndReg
- ldy #$00
+ ldy #$00
clc
sei
- sta (crtc),y
- lda CharPtr
- adc CURS_X
+ sta (crtc),y
+ lda CharPtr
+ adc CURS_X
iny
- sta (crtc),y
+ sta (crtc),y
dey
- lda #$0E
- sta (crtc),y
+ 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
+ lda (crtc),y
+ and #$F8
+ sta sedt1
+ lda CharPtr+1
+ adc #$00
+ and #$07
+ ora sedt1
+ sta (crtc),y
cli
pla
- sta IndReg
-.endif
+ sta IndReg
+.endif
rts
.endproc
.rodata
-LineLSBTab:
- .byte $00,$50,$A0,$F0,$40,$90,$E0,$30
- .byte $80,$D0,$20,$70,$C0,$10,$60,$B0
- .byte $00,$50,$A0,$F0,$40,$90,$E0,$30
- .byte $80
+.macro LineLoTab
+ .repeat 25, I
+ .byte <(VIDEO_RAM + I * 40)
+ .endrep
+.endmacro
+
+LineLSBTab: LineLoTab
+
; -------------------------------------------------------------------------
; High bytes of the start address of the screen lines
-LineMSBTab:
- .byte $D0,$D0,$D0,$D0,$D1,$D1,$D1,$D2
- .byte $D2,$D2,$D3,$D3,$D3,$D4,$D4,$D4
- .byte $D5,$D5,$D5,$D5,$D6,$D6,$D6,$D7
- .byte $D7
+.macro LineHiTab
+ .repeat 25, I
+ .byte >(VIDEO_RAM + I * 40)
+ .endrep
+.endmacro
+
+LineMSBTab: LineHiTab
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 14.09.2001
+;
+
+ .export _peekbsys, _peekwsys
+ .importzp ptr1
+
+ .include "zeropage.inc"
+
+
+; ------------------------------------------------------------------------
+; unsigned char __fastcall__ peekbsys (unsigned addr);
+
+.proc _peekbsys
+
+ sta ptr1 ; Store argument pointer
+ stx ptr1+1
+ ldx IndReg
+ lda #$0F
+ sta IndReg
+ ldy #$00
+ lda (ptr1),y
+ stx IndReg
+ ldx #$00 ; Extend to word
+ rts
+
+.endproc
+
+; ------------------------------------------------------------------------
+; unsigned __fastcall__ peekwsys (unsigned addr);
+
+.proc _peekwsys
+
+ sta ptr1 ; Store argument pointer
+ stx ptr1+1
+ ldx IndReg
+ lda #$0F
+ sta IndReg
+ ldy #$00
+ lda (ptr1),y ; Get low byte
+ pha
+ iny
+ lda (ptr1),y ; Get high byte
+ stx IndReg
+ tax ; High byte -> X
+ pla ; Low byte -> A
+ rts
+
+.endproc
+