mirror of
https://github.com/cc65/cc65.git
synced 2024-12-26 08:32:00 +00:00
atari5200: implement bgcolor() and textcolor()
Includes some other small fixes/cleanups.
This commit is contained in:
parent
edd596b2a4
commit
ec5e38617a
@ -10,6 +10,16 @@
|
||||
|
||||
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
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -9,11 +9,7 @@
|
||||
.import gotoxy, cputdirect, setcursor
|
||||
.importzp tmp1
|
||||
|
||||
.ifdef __ATARI5200__
|
||||
CHRCODE = 14
|
||||
.else
|
||||
CHRCODE = $12+64
|
||||
.endif
|
||||
|
||||
_chlinexy:
|
||||
pha ; Save the length
|
||||
|
@ -10,11 +10,7 @@
|
||||
.import gotoxy, putchar, setcursor
|
||||
.importzp tmp1
|
||||
|
||||
.ifdef __ATARI5200__
|
||||
CHRCODE = 1 ; exclamation mark
|
||||
.else
|
||||
CHRCODE = $7C ; Vertical bar
|
||||
.endif
|
||||
|
||||
_cvlinexy:
|
||||
pha ; Save the length
|
||||
|
1
libsrc/atari5200/bgcolor.s
Normal file
1
libsrc/atari5200/bgcolor.s
Normal file
@ -0,0 +1 @@
|
||||
.include "../atari/bgcolor.s"
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
.include "atari5200.inc"
|
||||
.export _gotox
|
||||
.import setcursor
|
||||
|
||||
_gotox:
|
||||
sta COLCRS_5200 ; Set X
|
||||
jmp setcursor
|
||||
rts
|
||||
|
@ -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
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
.include "atari5200.inc"
|
||||
.export _gotoy
|
||||
.import setcursor
|
||||
|
||||
_gotoy:
|
||||
sta ROWCRS_5200 ; Set Y
|
||||
jmp setcursor
|
||||
rts
|
||||
|
28
libsrc/atari5200/textcolor.s
Normal file
28
libsrc/atari5200/textcolor.s
Normal file
@ -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
|
13
libsrc/atari5200/wherex.s
Normal file
13
libsrc/atari5200/wherex.s
Normal file
@ -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
|
13
libsrc/atari5200/wherey.s
Normal file
13
libsrc/atari5200/wherey.s
Normal file
@ -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
|
@ -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);
|
||||
|
101
testcode/lib/atari5200/hello.c
Normal file
101
testcode/lib/atari5200/hello.c
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user