1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-08 06:25:17 +00:00

Working in P500 code

git-svn-id: svn://svn.cc65.org/cc65/trunk@919 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-09-14 09:52:30 +00:00
parent cd1598fa89
commit c4a49faf48
7 changed files with 204 additions and 69 deletions

View File

@@ -15,6 +15,7 @@ OBJS = _scrsize.o \
banking.o \ banking.o \
break.o \ break.o \
cgetc.o \ cgetc.o \
clrscr.o \
color.o \ color.o \
crt0.o \ crt0.o \
kbhit.o \ kbhit.o \
@@ -22,6 +23,7 @@ OBJS = _scrsize.o \
kplot.o \ kplot.o \
kscnkey.o \ kscnkey.o \
kudtim.o \ kudtim.o \
peeksys.o \
pokesys.o pokesys.o
all: $(OBJS) all: $(OBJS)

36
libsrc/cbm510/clrscr.s Normal file
View File

@@ -0,0 +1,36 @@
;
; 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

View File

@@ -5,24 +5,24 @@
; ;
.export _exit .export _exit
.import initlib, donelib .import _clrscr, initlib, donelib
.import push0, _main .import push0, _main
.import __BSS_RUN__, __BSS_SIZE__ .import __BSS_RUN__, __BSS_SIZE__
.import irq, nmi .import irq, nmi
.import k_irq, k_nmi, k_plot, k_udtim, k_scnkey .import k_irq, k_nmi, k_plot, k_udtim, k_scnkey
.include "zeropage.inc" .include "zeropage.inc"
.include "io.inc" .include "io.inc"
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; Define and export the ZP variables for the CBM510 runtime ; Define and export the ZP variables for the CBM510 runtime
.exportzp sp, sreg, regsave .exportzp sp, sreg, regsave
.exportzp ptr1, ptr2, ptr3, ptr4 .exportzp ptr1, ptr2, ptr3, ptr4
.exportzp tmp1, tmp2, tmp3, tmp4 .exportzp tmp1, tmp2, tmp3, tmp4
.exportzp regbank, zpspace .exportzp regbank, zpspace
.exportzp vic, sid, IPCcia, cia, acia, tpi1, tpi2 .exportzp vic, sid, cia1, cia2, acia, tpi1, tpi2
.exportzp ktab1, ktab2, ktab3, ktab4, time, RecvBuf, SendBuf .exportzp ktab1, ktab2, ktab3, ktab4, time, RecvBuf, SendBuf
.zeropage .zeropage
@@ -90,8 +90,8 @@ Head: .byte $03,$00,$11,$00,$0a,$00,$81,$20,$49,$b2,$30,$20,$a4,$20,$34,$00
vic: .word $d800 vic: .word $d800
sid: .word $da00 sid: .word $da00
IPCcia: .word $db00 cia1: .word $db00
cia: .word $dc00 cia2: .word $dc00
acia: .word $dd00 acia: .word $dd00
tpi1: .word $de00 tpi1: .word $de00
tpi2: .word $df00 tpi2: .word $df00
@@ -119,7 +119,7 @@ Back: ldx spsave
; actually used here: ; actually used here:
sei sei
lda #$01 lda #$00
sta ExecReg sta ExecReg
; This is the actual starting point of our code after switching banks for ; This is the actual starting point of our code after switching banks for
@@ -176,9 +176,37 @@ 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
sta IndReg sta IndReg
; Zero the BSS segment. We will do that here instead calling the routine ; Zero the BSS segment. We will do that here instead calling the routine
@@ -216,9 +244,9 @@ Z4:
; Setup the C stack ; Setup the C stack
lda #<$FF81 lda #<$FF81
sta sp sta sp
lda #>$FF81 lda #>$FF81
sta sp+1 sta sp+1
; We expect to be in page 2 now ; We expect to be in page 2 now
@@ -235,6 +263,10 @@ 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
jsr _clrscr
; Call module constructors ; Call module constructors
jsr initlib jsr initlib
@@ -365,8 +397,8 @@ reset_size = * - reset
; Code for a few simpler kernal calls goes here ; Code for a few simpler kernal calls goes here
k_iobase: k_iobase:
ldx cia ldx cia2
ldy cia+1 ldy cia2+1
rts rts
k_screen: k_screen:

View File

@@ -151,4 +151,8 @@ VIC_BG_COLOR3 = $24
; Out video memory address
VIDEO_RAM = $F800

View File

@@ -5,12 +5,12 @@
; ;
.export irq, nmi, k_irq, k_nmi .export irq, nmi, k_irq, k_nmi
.import k_scnkey, k_udtim, k_rs232 .import k_scnkey, k_udtim, k_rs232
.importzp tpi1 .importzp tpi1
.include "zeropage.inc" .include "zeropage.inc"
.include "io.inc" .include "io.inc"
.include "page3.inc" .include "page3.inc"
; ------------------------------------------------------------------------- ; -------------------------------------------------------------------------
@@ -19,8 +19,8 @@
; Bit 7 6 5 4 3 2 1 0 ; Bit 7 6 5 4 3 2 1 0
; | | | | ^ 50 Hz ; | | | | ^ 50 Hz
; | | | ^ SRQ IEEE 488 ; | | | ^ SRQ IEEE 488
; | | ^ cia ; | | ^ cia2
; | ^ IRQB ext. Port ; | ^ cia1 IRQB ext. Port
; ^ acia ; ^ acia

View File

@@ -8,54 +8,58 @@
.importzp crtc .importzp crtc
.include "zeropage.inc" .include "zeropage.inc"
.include "io.inc"
; ------------------------------------------------------------------------
;
.proc k_plot .proc k_plot
bcc set bcc set
ldx CURS_Y ldx CURS_Y
ldy CURS_X ldy CURS_X
rts rts
set: stx CURS_Y set: stx CURS_Y
sty CURS_X sty CURS_X
lda LineLSBTab,x
sta CharPtr
lda LineMSBTab,x
sta CharPtr+1
.if 0 .if 0
lda LineLSBTab,x lda IndReg
sta CharPtr
lda LineMSBTab,x
sta CharPtr+1
lda IndReg
pha pha
lda #$0F lda #$0F
sta IndReg sta IndReg
ldy #$00 ldy #$00
clc clc
sei sei
sta (crtc),y sta (crtc),y
lda CharPtr lda CharPtr
adc CURS_X adc CURS_X
iny iny
sta (crtc),y sta (crtc),y
dey dey
lda #$0E lda #$0E
sta (crtc),y sta (crtc),y
iny iny
lda (crtc),y lda (crtc),y
and #$F8 and #$F8
sta sedt1 sta sedt1
lda CharPtr+1 lda CharPtr+1
adc #$00 adc #$00
and #$07 and #$07
ora sedt1 ora sedt1
sta (crtc),y sta (crtc),y
cli cli
pla pla
sta IndReg sta IndReg
.endif .endif
rts rts
.endproc .endproc
@@ -64,16 +68,23 @@ set: stx CURS_Y
.rodata .rodata
LineLSBTab: .macro LineLoTab
.byte $00,$50,$A0,$F0,$40,$90,$E0,$30 .repeat 25, I
.byte $80,$D0,$20,$70,$C0,$10,$60,$B0 .byte <(VIDEO_RAM + I * 40)
.byte $00,$50,$A0,$F0,$40,$90,$E0,$30 .endrep
.byte $80 .endmacro
LineLSBTab: LineLoTab
; ------------------------------------------------------------------------- ; -------------------------------------------------------------------------
; High bytes of the start address of the screen lines ; High bytes of the start address of the screen lines
LineMSBTab: .macro LineHiTab
.byte $D0,$D0,$D0,$D0,$D1,$D1,$D1,$D2 .repeat 25, I
.byte $D2,$D2,$D3,$D3,$D3,$D4,$D4,$D4 .byte >(VIDEO_RAM + I * 40)
.byte $D5,$D5,$D5,$D5,$D6,$D6,$D6,$D7 .endrep
.byte $D7 .endmacro
LineMSBTab: LineHiTab

50
libsrc/cbm510/peeksys.s Normal file
View File

@@ -0,0 +1,50 @@
;
; 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