]> git.sur5r.net Git - cc65/commitdiff
Move the initialization code from conio.s as constructor/destructor code
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 19 Dec 2002 22:53:13 +0000 (22:53 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 19 Dec 2002 22:53:13 +0000 (22:53 +0000)
into the cgetc and cputc modules.
Fix color routines using additional snippets from MagerValp.

git-svn-id: svn://svn.cc65.org/cc65/trunk@1789 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/c128/cgetc.s
libsrc/c128/color.s
libsrc/c128/conio.s
libsrc/c128/cputc.s
libsrc/c128/crt0.s

index 391a25fd2dfbb66b215f7d0fdbd16fd02dfb9e1e..aea20f983e7bacf6a40a13a7310822ea4500d284 100644 (file)
@@ -5,10 +5,15 @@
 ;
 
        .export         _cgetc
+        .constructor    initcgetc
+        .destructor     donecgetc
+
        .import         cursor
 
        .include        "c128.inc"
 
+;--------------------------------------------------------------------------
+
 _cgetc:        lda     KEY_COUNT       ; Get number of characters
        bne     L2              ; Jump if there are already chars waiting
 
@@ -28,4 +33,38 @@ L2:          lda     KEY_COUNT       ; Check characters again
        ldx     #0
        rts
 
-          
+;--------------------------------------------------------------------------
+; Module constructor/destructor
+
+.bss
+keyvec:        .res    2
+
+.code
+initcgetc:
+
+; Save the old vector
+
+       lda     KeyStoreVec
+       sta     keyvec
+       lda     KeyStoreVec+1
+       sta     keyvec+1
+
+; Set the new vector. I can only hope that this works for other C128
+; versions...
+
+       lda     #<$C6B7
+       ldx     #>$C6B7
+
+SetVec:        sei
+       sta     KeyStoreVec
+       stx     KeyStoreVec+1
+       cli
+       rts
+
+donecgetc:
+        lda     #$00
+        sta     SCROLL
+       lda     keyvec
+       ldx     keyvec+1
+       bne     SetVec
+
index 1e7d577b2a0549088c42f4c049497334d3665313..e6a488245469b708c6417620dbd6e8754ef3e9f6 100644 (file)
@@ -7,19 +7,24 @@
 ;
 
        .export         _textcolor, _bgcolor, _bordercolor
+        .import         return0
 
        .include        "c128.inc"
 
 
-.proc   _textcolor
-
+_textcolor:
        bit     MODE            ; Check 80/40 column mode
-               bmi     @L1             ; Jump if 40 columns
-        ldx    CHARCOLOR       ; get old value
-       sta     CHARCOLOR       ; set new value
-       txa
-        ldx     #$00
-       rts
+               bmi     @L1             ; Jump if 80 columns
+
+; 40 column mode
+
+        ldx     CHARCOLOR       ; Get the old color
+        sta     CHARCOLOR       ; Set the new color
+        txa                     ; Old color -> A
+        ldx     #$00            ; Load high byte
+        rts
+
+; 80 column mode
 
 @L1:    tax                     ; Move new color to X
         lda     CHARCOLOR       ; Get old color + attributes
         txa                     ; Old color -> A
         and     #$0F            ; Mask out attributes
         ldx     #$00            ; Load high byte
-        rts
 
-.endproc
+; translate vdc->vic colour
+
+vdctovic:
+               ldy     #15
+@L2:    cmp    $CE5C,y
+        beq    @L3
+        dey
+        bpl    @L2
+@L3:   tya
+       rts
 
 
-.proc   _bgcolor
+_bgcolor:
+        bit     MODE
+        bmi     @L1
+
+; 40 column mode
 
        ldx     VIC_BG_COLOR0   ; get old value
        sta     VIC_BG_COLOR0   ; set new value
         ldx     #$00
        rts
 
-.endproc
+; 80 column mode
+
+@L1:    tax                     ; Move new color to X
+               lda     $CE5C,x         ; Translate VIC color -> VDC color
+       pha
+       ldx     #26
+               jsr     $CDDA           ; Read vdc register 26
+       jsr     vdctovic
+       tay
+       pla
+       ldx     #26
+               jsr     $CDCC           ; Write vdc register 26
+       tya
+        ldx     #$00
+       rts
+
 
+_bordercolor:
+        bit     MODE
+        bmi     @L1
 
-.proc   _bordercolor
+; 40 column mode
 
                ldx     VIC_BORDERCOLOR ; get old value
        sta     VIC_BORDERCOLOR ; set new value
@@ -54,5 +89,7 @@
         ldx     #$00
        rts
 
-.endproc
+; 80 column mode
+
+@L1:    jmp     return0
 
index 11da9294158b19bc79b80d264a4b2a3fdbaeadd3..42df1437a4f1c8e1bc855887261b4887a1fe605f 100644 (file)
@@ -4,45 +4,7 @@
 ; Low level stuff for screen output/console input
 ;
 
-       .export         initconio, doneconio
        .exportzp       CURS_X, CURS_Y
-       .import         xsize, ysize
 
        .include        "c128.inc"
-       .include        "../cbm/cbm.inc"
-
-.bss
-keyvec:        .res    2
-
-
-.code
-
-initconio:
-
-       lda     #$80
-       sta     SCROLL
-
-; Save the old vector
-
-       lda     KeyStoreVec
-       sta     keyvec
-       lda     KeyStoreVec+1
-       sta     keyvec+1
-
-; Set the new vector. I can only hope that this works for other C128
-; versions...
-
-       lda     #<$C6B7
-       ldx     #>$C6B7
-
-SetVec:        sei
-       sta     KeyStoreVec
-       stx     KeyStoreVec+1
-       cli
-       rts
-
-doneconio:
-       lda     keyvec
-       ldx     keyvec+1
-       bne     SetVec
 
index c3b835e13a19b04869a7a69cdf77eac196f30f40..d5ee8046da1598d4efb9467b026fffa3277940fe 100644 (file)
@@ -7,6 +7,8 @@
 
        .export         _cputcxy, _cputc, cputdirect, putchar
        .export         newline, plot
+        .constructor    initcputc
+        .destructor     donecputc
        .import         popa, _gotoxy
         .import         PLOT
 
@@ -41,3 +43,15 @@ plot:        ldy     CURS_X
 ; position in Y
 
 putchar        = $CC2F
+
+;--------------------------------------------------------------------------
+; Module constructor/destructor
+
+initcputc:
+       lda     #$80
+        .byte   $2C
+donecputc:
+        lda     #$00
+       sta     SCROLL
+        rts
+
index 62501722af180110d6b6816d6a3dcebc518e1317..2e09a3f73159b7cf0b072a1410e33b2fce1698a7 100644 (file)
@@ -6,7 +6,7 @@
 
        .export         _exit
        .import         condes, initlib, donelib
-       .import         initconio, doneconio, zerobss
+       .import         zerobss
        .import         push0, _main
         .import         RESTOR, BSOUT, CLRCH
        .import         __IRQFUNC_TABLE__, __IRQFUNC_COUNT__
@@ -93,10 +93,6 @@ L1:  lda     sp,x
 
        jsr     initlib
 
-; Initialize conio stuff
-
-       jsr     initconio
-
 ; If we have IRQ functions, chain our stub into the IRQ vector
 
         lda     #<__IRQFUNC_COUNT__
@@ -136,10 +132,6 @@ _exit:  lda     #<__IRQFUNC_COUNT__
 
 NoIRQ2: jsr            donelib
 
-; Reset the conio stuff
-
-       jsr     doneconio
-
 ; Reset the stack
 
        ldx     spsave