]> git.sur5r.net Git - cc65/commitdiff
atari5200: implement bgcolor() and textcolor()
authorChristian Groessler <chris@groessler.org>
Tue, 2 Apr 2019 19:11:11 +0000 (21:11 +0200)
committerOliver Schmidt <ol.sc@web.de>
Fri, 12 Apr 2019 10:49:38 +0000 (12:49 +0200)
Includes some other small fixes/cleanups.

18 files changed:
asminc/atari5200.inc
include/atari.h
include/atari5200.h
libsrc/atari/chline.s
libsrc/atari/cvline.s
libsrc/atari5200/bgcolor.s [new file with mode: 0644]
libsrc/atari5200/chline.s
libsrc/atari5200/conioscreen.s
libsrc/atari5200/cputc.s
libsrc/atari5200/cvline.s
libsrc/atari5200/gotox.s
libsrc/atari5200/gotoxy.s
libsrc/atari5200/gotoy.s
libsrc/atari5200/textcolor.s [new file with mode: 0644]
libsrc/atari5200/wherex.s [new file with mode: 0644]
libsrc/atari5200/wherey.s [new file with mode: 0644]
samples/hello.c
testcode/lib/atari5200/hello.c [new file with mode: 0644]

index 91fae4a9a1db30269552842f49aebd67760d7b48..a1fe624e6c2b50ff80e266f8b987f3cffd77cde2 100644 (file)
  
 ATEOL   = $9B      ; END-OF-LINE, used by CONIO
 
+;-------------------------------------------------------------------------
+; CONIO CHARACTER DEFS
+;-------------------------------------------------------------------------
+
+CH_ULCORNER = $0B  ; '+' sign
+CH_URCORNER = $0B
+CH_LLCORNER = $0B
+CH_LRCORNER = $0B
+CH_HLINE    = $0D  ; dash
+CH_VLINE    = $01  ; exclamation mark
 
 ;-------------------------------------------------------------------------
 ; Zero Page
index 899a6ac51ca6cdd556dae2d52afa5036fe6bd38b..455c43260436254d71a906ef272b4df91d073e6e 100644 (file)
@@ -491,7 +491,7 @@ extern void atrx15p2_tgi[];
 #define PxCTL_IRQ_STATUS         0x80
 
 
-/* The following #defines will cause the matching functions calls in conio.h
+/* The following #define will cause the matching function calls in conio.h
 ** to be overlaid by macros with the same names, saving the function call
 ** overhead.
 */
index 67c11c1df5f30ec37c230ee078efc20250908aca..10cd32fe979e65a950b652070d6af1da5e93fc1a 100644 (file)
@@ -53,6 +53,14 @@ extern void atr5200std_joy[];        /* referred to by joy_static_stddrv[] */
 #define JOY_RIGHT_MASK  0x08
 #define JOY_BTN_1_MASK  0x10
 
+/* Character codes */
+#define CH_ULCORNER     0x0B         /* '+' sign */
+#define CH_URCORNER     0x0B
+#define CH_LLCORNER     0x0B
+#define CH_LRCORNER     0x0B
+#define CH_HLINE        0x0D         /* dash */
+#define CH_VLINE        0x01         /* exclamation mark */
+
 /* get_tv return values */
 #define AT_NTSC     0
 #define AT_PAL      1
@@ -69,5 +77,11 @@ extern void atr5200std_joy[];        /* referred to by joy_static_stddrv[] */
 #include <_antic.h>
 #define ANTIC (*(struct __antic*)0xD400)
 
+/* The following #define will cause the matching function calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _bordercolor(color) 0
+
 /* End of atari5200.h */
 #endif
index 194fe0bb30f95d524218f59b132e4a8662e2161b..f4931dd4f5d36412d3d8c38acc4f316a4d04ae52 100644 (file)
@@ -9,11 +9,7 @@
         .import         gotoxy, cputdirect, setcursor
         .importzp       tmp1
 
-.ifdef __ATARI5200__
-CHRCODE =       14
-.else
 CHRCODE =       $12+64
-.endif
 
 _chlinexy:
         pha                     ; Save the length
index 1b4ba0b1b4ce99c3ccd23b1d5c50ec5aaece73f7..735e47dd2d04eab55382d8170beaadbb9d584eeb 100644 (file)
         .import         gotoxy, putchar, setcursor
         .importzp       tmp1
 
-.ifdef __ATARI5200__
-CHRCODE =       1               ; exclamation mark
-.else
 CHRCODE =       $7C             ; Vertical bar
-.endif
 
 _cvlinexy:
         pha                     ; Save the length
diff --git a/libsrc/atari5200/bgcolor.s b/libsrc/atari5200/bgcolor.s
new file mode 100644 (file)
index 0000000..1f9f772
--- /dev/null
@@ -0,0 +1 @@
+.include "../atari/bgcolor.s"
index d5872f149dc59c62eafb25e8369722d1d4fbc725..47c57966bc84cd77585085699d0cfc40d3a2e161 100644 (file)
@@ -1 +1,26 @@
-.include "../atari/chline.s"
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void chline (unsigned char length);
+;
+
+        .export         _chlinexy, _chline
+        .import         gotoxy, cputdirect
+        .importzp       tmp1
+        .include        "atari5200.inc"
+
+_chlinexy:
+        pha                     ; Save the length
+        jsr     gotoxy          ; Call this one, will pop params
+        pla                     ; Restore the length
+
+_chline:
+        cmp     #0              ; Is the length zero?
+        beq     L9              ; Jump if done
+        sta     tmp1
+L1:     lda     #CH_HLINE       ; Horizontal line, screen code
+        jsr     cputdirect      ; Direct output
+        dec     tmp1
+        bne     L1
+L9:     rts
index 30c0e0788febf883cf323e98b333565db8965c24..2c6a8a4e472790bdae703d0792dc32b68a2f739b 100644 (file)
@@ -8,6 +8,12 @@ SCREEN_BUF_SIZE =       20 * 24
 SCREEN_BUF      =       $4000 - SCREEN_BUF_SIZE
 
                 .export screen_setup_20x24
+                .export screen_width, screen_height
+                .export conio_color
+
+screen_width    =       20
+screen_height   =       24
+
 
                 .segment "ONCE"
 
@@ -57,6 +63,9 @@ clrscr:         sta     (SAVMSC),y
 
                 rts
 
+                .data
+
+conio_color:    .byte   0
 
                 .segment "DLIST"
 
index 185ad8da8ecb7fde1ce52818a3da55e9c2981f49..8fc00fcdcc3853e0d611b4de3d4619b94a176c38 100644 (file)
@@ -11,8 +11,9 @@
         .export         _cputcxy, _cputc
         .export         plot, cputdirect, putchar
         .import         gotoxy, _mul20
+        .import         conio_color
+        .importzp       screen_width, screen_height
         .importzp       ptr4
-        .import         setcursor
 
         .constructor    screen_setup, 26
         .import         screen_setup_20x24
@@ -44,7 +45,7 @@ L4:     cmp     #$0A            ; LF
         and     #3
         tax
         tya
-        and     #$9f
+        and     #$9F
         ora     ataint,x
 
 cputdirect:                     ; accepts screen code
@@ -53,7 +54,7 @@ cputdirect:                     ; accepts screen code
 ; advance cursor
         inc     COLCRS_5200
         lda     COLCRS_5200
-        cmp     #20
+        cmp     #screen_width
         bcc     plot
         lda     #0
         sta     COLCRS_5200
@@ -62,12 +63,11 @@ cputdirect:                     ; accepts screen code
 newline:
         inc     ROWCRS_5200
         lda     ROWCRS_5200
-        cmp     #24
+        cmp     #screen_height
         bne     plot
         lda     #0
         sta     ROWCRS_5200
-plot:   jsr     setcursor
-        ldy     COLCRS_5200
+plot:   ldy     COLCRS_5200
         ldx     ROWCRS_5200
         rts
 
@@ -83,10 +83,12 @@ putchar:
         sta     ptr4+1
         pla                     ; get char again
 
+;       and     #$C0            ; without this we are compatible with the old version. user must not try to output a char >= $3F
+        ora     conio_color
+
         ldy     COLCRS_5200
         sta     (ptr4),y
-        jmp     setcursor
+        rts
 
         .rodata
 ataint: .byte   64,0,32,96
-
index d987bcb62e2b5599c85fe00d484aece4d8e7c0ca..204d903823b51450cf6eb7ac8ed441b53f96b70a 100644 (file)
@@ -1 +1,31 @@
-.include "../atari/cvline.s"
+;
+; Ullrich von Bassewitz, 08.08.1998
+;
+; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+; void cvline (unsigned char length);
+;
+        .include "atari5200.inc"
+        
+        .export         _cvlinexy, _cvline
+        .import         gotoxy, putchar
+        .importzp       tmp1
+
+_cvlinexy:
+        pha                     ; Save the length
+        jsr     gotoxy          ; Call this one, will pop params
+        pla                     ; Restore the length and run into _cvline
+
+_cvline:
+        cmp     #0              ; Is the length zero?
+        beq     L9              ; Jump if done
+        sta     tmp1
+L1:     lda     COLCRS_5200
+        pha
+        lda     #CH_VLINE       ; Vertical bar
+        jsr     putchar         ; Write, no cursor advance
+        pla
+        sta     COLCRS_5200
+        inc     ROWCRS_5200
+        dec     tmp1
+        bne     L1
+L9:     rts
index 99f7cfd22cf2f58fc95258f4098aa86906717cda..04fc4622337f414700c4f9e67241a3b4a7e80625 100644 (file)
@@ -6,8 +6,7 @@
 
         .include        "atari5200.inc"
         .export         _gotox
-        .import         setcursor
 
 _gotox:
         sta     COLCRS_5200     ; Set X
-        jmp     setcursor
+        rts
index 24e2c2e35ab0edb40111e2d720f3934b707f708a..dce5b6c2a593b9fc42147e93a7254a7aa7a8daef 100644 (file)
@@ -8,7 +8,6 @@
 
         .export         gotoxy, _gotoxy
         .import         popa
-        .import         setcursor
 
 gotoxy:
         jsr     popa            ; Get Y
@@ -17,4 +16,4 @@ _gotoxy:                        ; Set the cursor position
         sta     ROWCRS_5200     ; Set Y
         jsr     popa            ; Get X
         sta     COLCRS_5200     ; Set X
-        jmp     setcursor
+        rts
index fcdd05e4c90fa35eddd2b0c10ed16daf5ae25853..ef7c2e5652df63bb22fca5747267d889d1ade462 100644 (file)
@@ -6,8 +6,7 @@
 
         .include        "atari5200.inc"
         .export         _gotoy
-        .import         setcursor
 
 _gotoy:
         sta     ROWCRS_5200     ; Set Y
-        jmp     setcursor
+        rts
diff --git a/libsrc/atari5200/textcolor.s b/libsrc/atari5200/textcolor.s
new file mode 100644 (file)
index 0000000..061e840
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Christian Groessler, 02-Apr-2019
+;
+; unsigned char __fastcall__ textcolor (unsigned char color);
+
+        .export         _textcolor
+        .import         conio_color
+
+        .include        "atari.inc"
+
+
+_textcolor:
+        ; move bits #0 and #1 to bits #6 and #7
+        and     #3
+        clc
+        ror     a
+        ror     a
+        ror     a               ; new conio_color value
+        ldx     conio_color     ; get old value
+        sta     conio_color     ; store new value
+        txa
+        ; move bits #6 and #7 to bits #0 and #1
+        clc
+        rol     a
+        rol     a
+        rol     a
+        ldx     #0
+        rts
diff --git a/libsrc/atari5200/wherex.s b/libsrc/atari5200/wherex.s
new file mode 100644 (file)
index 0000000..77f099d
--- /dev/null
@@ -0,0 +1,13 @@
+;
+; Carsten Strotmann, 30.12.2002
+;
+; unsigned char wherex (void);
+;
+
+        .export  _wherex
+        .include "atari5200.inc"
+
+_wherex:
+        lda     COLCRS_5200
+        ldx     #0
+        rts
diff --git a/libsrc/atari5200/wherey.s b/libsrc/atari5200/wherey.s
new file mode 100644 (file)
index 0000000..d2c5042
--- /dev/null
@@ -0,0 +1,13 @@
+;
+; Carsten Strotmann, 30.12.2002
+;
+; unsigned char wherey (void);
+;
+
+        .export  _wherey
+        .include "atari5200.inc"
+
+_wherey:
+        lda     ROWCRS_5200
+        ldx     #0
+        rts
index dd15128d2b4410efdf30ba68ea0d3f1aac1a851c..255dccd001c2c084fcfc98f555a7797cec10b458 100644 (file)
@@ -67,7 +67,7 @@ int main (void)
     gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
     cprintf ("%s", Text);
 
-#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
+#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)
 
     /* Wait for the user to press a button */
     joy_install (joy_static_stddrv);
diff --git a/testcode/lib/atari5200/hello.c b/testcode/lib/atari5200/hello.c
new file mode 100644 (file)
index 0000000..b208846
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+** Fancy hello world program using cc65.
+**
+** Ullrich von Bassewitz (ullrich@von-bassewitz.de)
+**
+** TEST version for atari5200 conio, using all four colors
+*/
+
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <conio.h>
+#include <joystick.h>
+
+
+
+/*****************************************************************************/
+/*                                   Data                                    */
+/*****************************************************************************/
+
+
+
+static const char Text [] = "Hello world!";
+
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+int main (void)
+{
+    unsigned char XSize, YSize;
+    unsigned char PosY;
+
+    /* Set screen colors */
+    (void) textcolor (COLOR_WHITE);
+    (void) bordercolor (COLOR_BLACK);
+    (void) bgcolor (COLOR_BLACK);
+
+    /* Clear the screen, put cursor in upper left corner */
+    clrscr ();
+
+    /* Ask for the screen size */
+    screensize (&XSize, &YSize);
+
+    /* Draw a border around the screen */
+
+    /* Top line */
+    cputc (CH_ULCORNER);
+    chline (XSize - 2);
+    cputc (CH_URCORNER);
+
+    /* Vertical line, left side */
+    cvlinexy (0, 1, YSize - 2);
+
+    /* Bottom line */
+    cputc (CH_LLCORNER);
+    chline (XSize - 2);
+    cputc (CH_LRCORNER);
+
+    /* Vertical line, right side */
+    cvlinexy (XSize - 1, 1, YSize - 2);
+
+    /* Write the greeting in the mid of the screen */
+    gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
+    cprintf ("%s", Text);
+
+    PosY = wherey () + 1;
+    textcolor (0); /* switch to color #0 */
+    cputsxy(3, PosY++, "COLOR 0");
+    textcolor (1); /* switch to color #1 */
+    cputsxy(3, PosY++, "COLOR 1");
+    textcolor (2); /* switch to color #2 */
+    cputsxy(3, PosY++, "COLOR 2");
+    textcolor (3); /* switch to color #3 */
+    cputsxy(3, PosY, "COLOR 3");
+
+#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)
+
+    /* Wait for the user to press a button */
+    joy_install (joy_static_stddrv);
+    while (!joy_read (JOY_1)) ;
+    joy_uninstall ();
+
+#else
+
+    /* Wait for the user to press a key */
+    cgetc ();
+
+#endif
+
+    /* Clear the screen again */
+    clrscr ();
+
+    /* Done */
+    return EXIT_SUCCESS;
+}