Includes some other small fixes/cleanups.
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
#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.
*/
#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
#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
.import gotoxy, cputdirect, setcursor
.importzp tmp1
-.ifdef __ATARI5200__
-CHRCODE = 14
-.else
CHRCODE = $12+64
-.endif
_chlinexy:
pha ; Save the length
.import gotoxy, putchar, setcursor
.importzp tmp1
-.ifdef __ATARI5200__
-CHRCODE = 1 ; exclamation mark
-.else
CHRCODE = $7C ; Vertical bar
-.endif
_cvlinexy:
pha ; Save the length
--- /dev/null
+.include "../atari/bgcolor.s"
-.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
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"
rts
+ .data
+
+conio_color: .byte 0
.segment "DLIST"
.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
and #3
tax
tya
- and #$9f
+ and #$9F
ora ataint,x
cputdirect: ; accepts screen code
; advance cursor
inc COLCRS_5200
lda COLCRS_5200
- cmp #20
+ cmp #screen_width
bcc plot
lda #0
sta COLCRS_5200
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
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
-
-.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
.include "atari5200.inc"
.export _gotox
- .import setcursor
_gotox:
sta COLCRS_5200 ; Set X
- jmp setcursor
+ rts
.export gotoxy, _gotoxy
.import popa
- .import setcursor
gotoxy:
jsr popa ; Get Y
sta ROWCRS_5200 ; Set Y
jsr popa ; Get X
sta COLCRS_5200 ; Set X
- jmp setcursor
+ rts
.include "atari5200.inc"
.export _gotoy
- .import setcursor
_gotoy:
sta ROWCRS_5200 ; Set Y
- jmp setcursor
+ rts
--- /dev/null
+;
+; 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
--- /dev/null
+;
+; Carsten Strotmann, 30.12.2002
+;
+; unsigned char wherex (void);
+;
+
+ .export _wherex
+ .include "atari5200.inc"
+
+_wherex:
+ lda COLCRS_5200
+ ldx #0
+ rts
--- /dev/null
+;
+; Carsten Strotmann, 30.12.2002
+;
+; unsigned char wherey (void);
+;
+
+ .export _wherey
+ .include "atari5200.inc"
+
+_wherey:
+ lda ROWCRS_5200
+ ldx #0
+ rts
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);
--- /dev/null
+/*
+** 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;
+}