move some things from targettest to samples

This commit is contained in:
mrdudz
2022-02-05 16:55:57 +01:00
parent 98bc021c5a
commit 4e5b521903
37 changed files with 231 additions and 42 deletions

View File

@@ -0,0 +1,56 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= atari5200
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
DEL = -del /f
RMDIR = rmdir /s /q
else
NULLDEV = /dev/null
DEL = $(RM)
RMDIR = $(RM) -r
endif
ifdef CC65_HOME
AS = $(CC65_HOME)/bin/ca65
CC = $(CC65_HOME)/bin/cc65
CL = $(CC65_HOME)/bin/cl65
LD = $(CC65_HOME)/bin/ld65
else
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
endif
EXELIST_atari5200 = \
hello
ifneq ($(EXELIST_$(SYS)),)
samples: $(EXELIST_$(SYS))
else
samples: notavailable
endif
# empty target used to skip systems that will not work with any program in this dir
notavailable:
ifeq ($(MAKELEVEL),0)
@echo "info: atari 5200 tests not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
hello: hello.c
$(CL) -t atari5200 -o hello hello.c
clean:
@$(DEL) hello 2>$(NULLDEV)

109
samples/atari5200/hello.c Normal file
View File

@@ -0,0 +1,109 @@
/*
** 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!";
static unsigned char colors[] = { COLOR_WHITE, COLOR_GREEN, COLOR_RED, COLOR_BLACK };
/*****************************************************************************/
/* Code */
/*****************************************************************************/
int main (void)
{
unsigned char XSize, YSize;
unsigned char PosY;
unsigned char i = 0;
/* 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);
/* Install joystick driver */
joy_install (joy_static_stddrv);
while (1) {
/* 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 ();
textcolor (colors[i]); /* switch to color #0 */
cputsxy(3, ++PosY, "COLOR 0");
textcolor ((colors[i] + 1) & 3); /* switch to color #1 */
cputsxy(3, ++PosY, "COLOR 1");
textcolor ((colors[i] + 2) & 3); /* switch to color #2 */
cputsxy(3, ++PosY, "COLOR 2");
textcolor ((colors[i] + 3) & 3); /* switch to color #3 */ /* color #3 is the background color. So written text isn't visible. */
cputsxy(3, ++PosY, "COLOR 3");
/* Wait for the user to press and release a button */
while (!joy_read (JOY_1))
;
while (joy_read (JOY_1))
;
i = (i + 1) & 3;
/* Change colors */
textcolor (colors[i]);
bgcolor ((colors[i] + 3) & 3);
/* Clear the screen again */
clrscr ();
}
/* not reached */
joy_uninstall ();
/* Done */
return EXIT_SUCCESS;
}