]> git.sur5r.net Git - cc65/commitdiff
More P500 support
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 14 Sep 2001 14:37:08 +0000 (14:37 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 14 Sep 2001 14:37:08 +0000 (14:37 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@920 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/cbm510/Makefile
libsrc/cbm510/clrscr.s
libsrc/cbm510/conio.s [new file with mode: 0644]
libsrc/cbm510/cputc.s [new file with mode: 0644]
libsrc/cbm510/crt0.s
libsrc/cbm510/io.inc
libsrc/cbm510/kplot.s
libsrc/cbm510/zeropage.inc

index 8958f4b1eb28c972778a347d0715fb8715790e0c..b518bd010a6c7627320af86d218c706c92b65e8d 100644 (file)
@@ -17,6 +17,8 @@ OBJS =        _scrsize.o      \
                cgetc.o         \
        clrscr.o        \
                color.o         \
+       conio.o         \
+       cputc.o         \
                crt0.o          \
                kbhit.o         \
                kirq.o          \
index 73a6c4be1267dee969b7aeeb14bc663994d5fc12..a2bb4e2dbe7ba655641bcbf0d6b1d8e079a36283 100644 (file)
        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
diff --git a/libsrc/cbm510/conio.s b/libsrc/cbm510/conio.s
new file mode 100644 (file)
index 0000000..2456f7b
--- /dev/null
@@ -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"
+
diff --git a/libsrc/cbm510/cputc.s b/libsrc/cbm510/cputc.s
new file mode 100644 (file)
index 0000000..c7d6940
--- /dev/null
@@ -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
+
index 3abfbbbc03c0aabef245a3f81a935906942b7dcf..076d44d3519bf7c783253795673e54d9c20e426f 100644 (file)
@@ -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
 
 
index 2e475419a8e13f39c90ee4b162cc514adca782c7..a67c4099c970ad4d14978e53e143d60828d23471 100644 (file)
@@ -154,5 +154,5 @@ VIC_BG_COLOR3       = $24
 ; Out video memory address
 
 VIDEO_RAM   = $F800
-
+COLOR_RAM   = $D400
 
index bf1dff323c119b086880812ec3b46408dd523f3f..ec7123a4fabd0832302b797163621d0d30d34c61 100644 (file)
@@ -9,58 +9,33 @@
 
        .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
-
-.if    0
-       lda     IndReg
-       pha
-       lda     #$0F
-       sta     IndReg
-
-       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
+       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
+
+get:   ldx     CURS_Y
+       ldy     CURS_X
+
        rts
+
 .endproc
 
 ; -------------------------------------------------------------------------
index b6e1be2bf237d5cc35595d3cf0f99eb991645976..922f490acd4459bc093d31bb3354efe613198d25 100644 (file)
@@ -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