Merge branch 'master' into master

This commit is contained in:
Oliver Schmidt
2021-11-23 22:56:51 +01:00
committed by GitHub
111 changed files with 3761 additions and 2043 deletions

View File

@@ -154,7 +154,7 @@ endif
# Lists of subdirectories
# disasm depends on cpp
DIRLIST = tutorial geos
DIRLIST = tutorial geos atari2600 supervision cbm
# --------------------------------------------------------------------------
# Lists of executables
@@ -190,6 +190,9 @@ EXELIST_atarixl = $(EXELIST_atari)
EXELIST_atari2600 = \
atari2600hello
EXELIST_atari5200 = \
notavailable
EXELIST_atmos = \
ascii \
hello \
@@ -202,28 +205,22 @@ EXELIST_bbc = \
EXELIST_c64 = \
ascii \
enumdevdir \
fire \
gunzip65 \
hello \
mandelbrot \
mousedemo \
multdemo \
nachtm \
ovrldemo \
plasma \
sieve \
tgidemo
EXELIST_c128 = \
ascii \
enumdevdir \
fire \
gunzip65 \
hello \
mandelbrot \
mousedemo \
nachtm \
plasma \
sieve \
tgidemo
@@ -234,19 +231,15 @@ EXELIST_c16 = \
EXELIST_cbm510 = \
ascii \
fire \
gunzip65 \
hello \
mousedemo \
nachtm \
plasma \
sieve
EXELIST_cbm610 = \
ascii \
gunzip65 \
hello \
nachtm \
sieve
EXELIST_creativision = \
@@ -299,7 +292,6 @@ EXELIST_plus4 = \
enumdevdir \
gunzip65 \
hello \
plasma \
sieve
EXELIST_sim6502 = \
@@ -308,7 +300,7 @@ EXELIST_sim6502 = \
EXELIST_sim65c02 = $(EXELIST_sim6502)
EXELIST_supervision = \
supervisionhello
notavailable
EXELIST_sym1 = \
notavailable
@@ -347,7 +339,9 @@ samples: $(EXELIST_$(SYS))
# empty target used to skip systems that will not work with any program in this dir
notavailable:
@echo "warning: generic samples not available for" $(SYS)
ifeq ($(MAKELEVEL),0)
@echo "info: generic samples not available for" $(SYS)
endif
disk: $(DISK_$(SYS))
@@ -396,7 +390,7 @@ $(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),s >$(
endef # D64_WRITE_SEQ_recipe
samples.d64: samples
@$(C1541) -format samples,AA d64 $@ >$(NULLDEV)
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
$(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
$(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_SEQ_recipe))
@@ -458,11 +452,17 @@ install:
$(INSTALL) -d $(DESTDIR)$(samplesdir)
$(INSTALL) -d $(DESTDIR)$(samplesdir)/geos
$(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial
$(INSTALL) -d $(DESTDIR)$(samplesdir)/atari2600
$(INSTALL) -d $(DESTDIR)$(samplesdir)/cbm
$(INSTALL) -d $(DESTDIR)$(samplesdir)/supervision
$(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir)
$(INSTALL) -m0644 readme.txt $(DESTDIR)$(samplesdir)
$(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir)
$(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos
$(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial
$(INSTALL) -m0644 atari2600/*.* $(DESTDIR)$(samplesdir)/atari2600
$(INSTALL) -m0644 cbm/*.* $(DESTDIR)$(samplesdir)/cbm
$(INSTALL) -m0644 supervision/*.* $(DESTDIR)$(samplesdir)/supervision
# --------------------------------------------------------------------------
# Packaging rules

View File

@@ -0,0 +1,59 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= atari2600
# 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
SP = $(CC65_HOME)/bin/sp65
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)
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
endif
EXELIST_atari2600 = \
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 2600 samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
hello: hello.c
$(CL) -t $(SYS) -O -o hello -m hello.map hello.c
clean:
@$(DEL) $(EXELIST_atari2600) 2>$(NULLDEV)
@$(DEL) *.map 2>$(NULLDEV)

164
samples/cbm/Makefile Normal file
View File

@@ -0,0 +1,164 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= c64
# 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
SP = $(CC65_HOME)/bin/sp65
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)
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
endif
ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),)
ifdef CC65_HOME
TARGET_PATH = $(CC65_HOME)/target
else
TARGET_PATH := $(if $(wildcard ../target),../target,$(shell $(CL) --print-target-path))
endif
# If TARGET_PATH contains spaces then it is presumed to contain escaped spaces. GNU make
# has very limited support for paths containing spaces. $(wildcard) is the only function
# that is aware of escaped spaces. However, $(wildcard) never returns paths with escaped
# spaces !!! So if it e.g. finds 4 files in a path with 2 spaces then one ends up with a
# return value consisting of 12 plain words :-((
#
# Fortunately we can work around that behaviour here because we know that the files we
# are looking for have known extensions. So we can $(filter) the in our example above 12
# words for file extensions so we come up with 4 path fragments. Then we remove those
# path fragments with $(notdir) from the file names.
#
# So far so good. But here we want to process files from different paths in a single
# recipe further down below and therefore want to prepend the paths to the files with
# $(addprefix). However, $(foreach) isn't aware of escaped spaces (only $(wildcard) is).
# Therefore, we need to replace the spaces with some other character temporarily in order
# to have $(foreach) generate one invocation per file. We use the character '?' for that
# purpose here, just because it is known to not be part of file names.
#
# Inside the recipe generated per file we then replace the '?' again with a space. As we
# want to be compatible with cmd.exe for execution we're not using an escaped space but
# rather double-quote the whole path.
#
# Note: The "strange" $(wildcard) further down below just serves the purpose to unescape
# spaces for cmd.exe. This could have as well been done with another $(subst).
SUBST_TARGET_PATH := $(subst \$(SPACE),?,$(TARGET_PATH))
EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
EMD := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/emd/,$(notdir $(filter %.emd,$(EMD))))
MOU := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/mou/,$(notdir $(filter %.mou,$(MOU))))
TGI := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/tgi/,$(notdir $(filter %.tgi,$(TGI))))
# This one comes with the VICE emulator.
# See http://vice-emu.sourceforge.net/
C1541 ?= c1541
endif
DISK_c64 = samples.d64
EXELIST_c64 = \
fire \
plasma \
nachtm
EXELIST_c128 = \
fire \
plasma \
nachtm
EXELIST_cbm510 = \
fire \
plasma \
nachtm
EXELIST_cbm610 = \
nachtm
EXELIST_plus4 = \
plasma
EXELIST_c16 = \
notavailable
EXELIST_pet = \
notavailable
EXELIST_vic20 = \
notavailable
ifneq ($(EXELIST_$(SYS)),)
samples: $(EXELIST_$(SYS))
else
samples: notavailable
endif
disk: $(DISK_$(SYS))
# empty target used to skip systems that will not work with any program in this dir
notavailable:
ifeq ($(MAKELEVEL),0)
@echo "info: cbm samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
fire: fire.c
$(CL) -t $(SYS) -O -o fire -m fire.map fire.c
plasma: plasma.c
$(CL) -t $(SYS) -O -o plasma -m plasma.map plasma.c
nachtm: nachtm.c
$(CL) -t $(SYS) -O -o nachtm -m nachtm.map nachtm.c
# --------------------------------------------------------------------------
# Rule to make a CBM disk with all samples. Needs the c1541 program that comes
# with the VICE emulator.
define D64_WRITE_PRG_recipe
$(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),p >$(NULLDEV)
endef # D64_WRITE_PRG_recipe
define D64_WRITE_SEQ_recipe
$(C1541) -attach $@ -write "$(subst ?,$(SPACE),$(file))" $(notdir $(file)),s >$(NULLDEV)
endef # D64_WRITE_SEQ_recipe
samples.d64: samples
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
# $(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
# $(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_SEQ_recipe))
clean:
@$(DEL) $(EXELIST_$(SYS)) 2>$(NULLDEV)
@$(DEL) *.map 2>$(NULLDEV)
@$(DEL) $(DISK_$(SYS)) 2>$(NULLDEV)

View File

@@ -972,12 +972,12 @@ static void MakeNiceScreen (void)
/* Clear the screen hide the cursor, set colors */
#ifdef __CBM610__
textcolor (COLOR_WHITE);
(void)textcolor (COLOR_WHITE);
#else
textcolor (COLOR_GRAY3);
(void)textcolor (COLOR_GRAY3);
#endif
bordercolor (COLOR_BLACK);
bgcolor (COLOR_BLACK);
(void)bordercolor (COLOR_BLACK);
(void)bgcolor (COLOR_BLACK);
clrscr ();
cursor (0);

View File

@@ -11,36 +11,52 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <device.h>
#include <dirent.h>
#include <cc65.h>
void printdir (char *newdir)
/* returns true for error, false for OK */
bool printdir (char *newdir)
{
char olddir[FILENAME_MAX];
char curdir[FILENAME_MAX];
char *olddir;
char *curdir;
DIR *dir;
struct dirent *ent;
char *subdirs = NULL;
unsigned dirnum = 0;
unsigned num;
getcwd (olddir, sizeof (olddir));
olddir = malloc (FILENAME_MAX);
if (olddir == NULL) {
perror ("cannot allocate memory");
return true;
}
getcwd (olddir, FILENAME_MAX);
if (chdir (newdir)) {
/* If chdir() fails we just print the
** directory name - as done for files.
*/
printf (" Dir %s\n", newdir);
return;
free (olddir);
return false;
}
curdir = malloc (FILENAME_MAX);
if (curdir == NULL) {
perror ("cannot allocate memory");
return true;
}
/* We call getcwd() in order to print the
** absolute pathname for a subdirectory.
*/
getcwd (curdir, sizeof (curdir));
getcwd (curdir, FILENAME_MAX);
printf (" Dir %s:\n", curdir);
free (curdir);
/* Calling opendir() always with "." avoids
** fiddling around with pathname separators.
@@ -65,18 +81,27 @@ void printdir (char *newdir)
closedir (dir);
for (num = 0; num < dirnum; ++num) {
printdir (subdirs + FILENAME_MAX * num);
if (printdir (subdirs + FILENAME_MAX * num))
break;
}
free (subdirs);
chdir (olddir);
free (olddir);
return false;
}
void main (void)
{
unsigned char device;
char devicedir[FILENAME_MAX];
char *devicedir;
devicedir = malloc (FILENAME_MAX);
if (devicedir == NULL) {
perror ("cannot allocate memory");
return;
}
/* Calling getfirstdevice()/getnextdevice() does _not_ turn on the motor
** of a drive-type device and does _not_ check for a disk in the drive.
@@ -88,7 +113,7 @@ void main (void)
/* Calling getdevicedir() _does_ check for a (formatted) disk in a
** floppy-disk-type device and returns NULL if that check fails.
*/
if (getdevicedir (device, devicedir, sizeof (devicedir))) {
if (getdevicedir (device, devicedir, FILENAME_MAX)) {
printdir (devicedir);
} else {
printf (" N/A\n");
@@ -100,4 +125,6 @@ void main (void)
if (doesclrscrafterexit ()) {
getchar ();
}
free (devicedir);
}

View File

@@ -3,6 +3,19 @@
# var. to build for another target system.
SYS ?= geos-cbm
# If SYS was given on the commandline, redirect "c64" to "geos-cbm" and
# "apple2enh" to "geos-apple"
ifeq ($(origin SYS),command line)
ifeq ($(SYS),c64)
override SYS = geos-cbm
$(info GEOS: c64 -> geos-cbm)
endif
ifeq ($(SYS),apple2enh)
override SYS = geos-apple
$(info GEOS: apple2enh -> geos-apple)
endif
endif
# Just the usual way to find out if we're
# using cmd.exe to execute make rules.
ifneq ($(shell echo),)
@@ -69,10 +82,14 @@ samples: $(EXELIST_$(SYS))
$(foreach dir,$(DIRLIST),$(SUBDIR_recipe))
else
samples:
@echo "warning: geos samples not available for" $(SYS)
ifeq ($(MAKELEVEL),0)
@echo "info: geos samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
endif
bitmap.c: logo.pcx
$(SP) -r logo.pcx -c geos-bitmap -w bitmap.c,ident=bitmap

View File

@@ -8,8 +8,8 @@ struct window wholeScreen = {0, SC_PIX_HEIGHT-1, 0, SC_PIX_WIDTH-1};
void main (void)
{
unsigned char os = get_ostype();
unsigned char *machine = NULL;
unsigned char *version = NULL;
char *machine = NULL;
char *version = NULL;
unsigned char good = 1;
SetPattern(0);

View File

@@ -41,7 +41,12 @@ ifneq ($(EXELIST_$(SYS)),)
samples: $(EXELIST_$(SYS))
else
samples:
@echo "warning: grc sample not available for" $(SYS)
ifeq ($(MAKELEVEL),0)
@echo "info: grc sample not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
endif
test.s: test.grc

View File

@@ -10,11 +10,13 @@ Please note:
similar systems. If you're using Windows, then consider installing Cygwin
or MSys2.
* The makefile specifies the C64 as the default target system because all
but three of the programs run on that platform. When compiling for another
system, you will have to change the line that specifies the target system
at the top of the makefile, specify the system with SYS=<target> on the
make command line, or set a SYS environment variable.
* The makefile specifies the C64 as the default target system because most
of the programs run on that platform. When compiling for another system,
you will have to change the line that specifies the target system at the
top of the makefile, specify the system with SYS=<target> on the make
command line, or set a SYS environment variable. For example:
make SYS=apple2
* Use "make disk" to build a disk image with all sample programs.
@@ -31,11 +33,6 @@ Description: Shows the ASCII (or ATASCII, PETSCII) codes of typed
<greg.king5@verizon.com>.
Platforms: All platforms with conio or stdio (compile time configurable).
-----------------------------------------------------------------------------
Name: atari2600hello
Description: A "Hello world" type program.
Platforms: Runs on only the Atari 2600 Video Console System.
-----------------------------------------------------------------------------
Name: diodemo
Description: A disc copy program written and contributed by Oliver
@@ -52,12 +49,6 @@ Platforms: All systems with device enumeration and directory access
(currently the Commodore machines, the Commander X16,
and the Apple ][).
-----------------------------------------------------------------------------
Name: fire
Description: Another graphics demo written by groepaz/hitmen.
Platforms: The program currently is running on only the C64, but should
be portable to the C128 and CBM510 (and maybe more machines).
-----------------------------------------------------------------------------
Name: gunzip65
Description: A gunzip utility for 6502-based machines, written by Piotr
@@ -76,8 +67,8 @@ Platforms: Runs on all platforms that support conio, which means:
-----------------------------------------------------------------------------
Name: mandelbrot
Description: A mandelbrot demo using integer arithmetic. The demo was
written by groepaz/hitmen, and converted to cc65 using TGI
graphics by Stephan Haubenthal.
written by groepaz, and converted to cc65 using TGI graphics
by Stephan Haubenthal.
Platforms: Runs on all platforms that have TGI support:
Apple ][, Atari, C64, C128, Oric Atmos and Telestrat, GEOS,
NES, and Lynx.
@@ -97,13 +88,6 @@ Platforms: All systems with an overlay linker config., disk directory
access, and EMD support (currently the C64, the C128,
the Atari, and the Apple ][).
-----------------------------------------------------------------------------
Name: nachtm
Description: Plays "Eine kleine Nachtmusik" by Wolfgang Amadeus Mozart.
Platforms: All systems that have the Commodore SID (Sound Interface
Device):
C64, C128, CBM510, CBM610.
-----------------------------------------------------------------------------
Name: overlaydemo
Description: Shows how to load overlay files from disk. Written and
@@ -111,13 +95,6 @@ Description: Shows how to load overlay files from disk. Written and
Platforms: All systems with an overlay linker config. (currently the C64,
the C128, the Atari, and the Apple ][).
-----------------------------------------------------------------------------
Name: plasma
Description: A fancy graphics demo written by groepaz/hitmen.
Platforms: The program needs a VIC-II or a TED, so it runs on the following
systems:
C64, C128, CBM510, Plus/4.
-----------------------------------------------------------------------------
Name: sieve
Description: Implements the "Sieve of Eratosthenes" as a way to find all
@@ -128,11 +105,6 @@ Platforms: All systems with conio and clock support:
Commander X16, Apple ][ (without timing due to missing clock
support).
-----------------------------------------------------------------------------
Name: supervisionhello
Description: A "Hello world" type program.
Platforms: Runs on only the Watara Supervision game console.
-----------------------------------------------------------------------------
Name: tgidemo
Description: Shows some of the graphics capabilities of the "Tiny Graphics
@@ -140,3 +112,46 @@ Description: Shows some of the graphics capabilities of the "Tiny Graphics
Platforms: Runs on all platforms that have TGI support:
Apple ][, Atari, C64, C128, Oric Atmos and Telestrat, GEOS,
NES, and Lynx.
=============================================================================
Platform specific samples follow:
atari 2600:
-----------
Name: hello
Description: A "Hello world" type program.
Platforms: Runs on only the Atari 2600 Video Console System.
-----------------------------------------------------------------------------
cbm:
----
Name: fire
Description: Another graphics demo written by groepaz.
Platforms: C64, C128, CBM510
-----------------------------------------------------------------------------
Name: nachtm
Description: Plays "Eine kleine Nachtmusik" by Wolfgang Amadeus Mozart.
Platforms: All systems that have the Commodore SID (Sound Interface
Device):
C64, C128, CBM510, CBM610.
-----------------------------------------------------------------------------
Name: plasma
Description: A fancy graphics demo written by groepaz.
Platforms: The program needs a VIC-II or a TED, so it runs on the following
systems:
C64, C128, CBM510, Plus/4.
-----------------------------------------------------------------------------
supervision:
------------
Name: hello
Description: A "Hello world" type program.
Platforms: Runs on only the Watara Supervision game console.
----------------------------------------------------------------------------

View File

@@ -0,0 +1,59 @@
# Run 'make SYS=<target>'; or, set a SYS env.
# var. to build for another target system.
SYS ?= supervision
# 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
SP = $(CC65_HOME)/bin/sp65
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)
SP := $(if $(wildcard ../../bin/sp65*),../../bin/sp65,sp65)
endif
EXELIST_supervision = \
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: supervision samples not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
hello: hello.c
$(CL) -t $(SYS) -O -o hello -m hello.map hello.c
clean:
@$(DEL) $(EXELIST_supervision) 2>$(NULLDEV)
@$(DEL) *.map 2>$(NULLDEV)

View File

@@ -0,0 +1,95 @@
/*****************************************************************************/
/* */
/* Watara Supervision sample C program */
/* */
/* Fabrizio Caruso (fabrizio_caruso@hotmail.com), 2019 */
/* Greg King (greg.king5@verizon.net), 2021 */
/* */
/*****************************************************************************/
#include <supervision.h>
#include <string.h>
/* Number of words per screen line (Remark: Last 4 words aren't displayed) */
#define WORDS_PER_LINE (160/8+4)
struct sv_vram {
unsigned int v[160/8][8][WORDS_PER_LINE];
};
#define SV_VRAM ((*(struct sv_vram *)0x4000).v)
/* Character definitions in 8x8 format */
/* That format gives us a screen of 20 columns and 20 rows */
static const unsigned char h_char[] = {0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00};
static const unsigned char e_char[] = {0x7E,0x60,0x60,0x78,0x60,0x60,0x7E,0x00};
static const unsigned char l_char[] = {0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00};
static const unsigned char o_char[] = {0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00};
static const unsigned char w_char[] = {0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00};
static const unsigned char r_char[] = {0x7C,0x66,0x66,0x7C,0x78,0x6C,0x66,0x00};
static const unsigned char d_char[] = {0x78,0x6C,0x66,0x66,0x66,0x6C,0x78,0x00};
static void clear_screen(void)
{
memset(SV_VIDEO, 0, 0x2000);
}
/* Necessary conversion to have 2 bits per pixel with darkest hue */
/* Remark: The Supervision uses 2 bits per pixel, and bits are mapped into pixels in reversed order */
static unsigned int __fastcall__ double_reversed_bits(unsigned char)
{
__asm__("stz ptr2");
__asm__("stz ptr2+1");
__asm__("ldy #$08");
L1: __asm__("lsr a");
__asm__("php");
__asm__("rol ptr2");
__asm__("rol ptr2+1");
__asm__("plp");
__asm__("rol ptr2");
__asm__("rol ptr2+1");
__asm__("dey");
__asm__("bne %g", L1);
__asm__("lda ptr2");
__asm__("ldx ptr2+1");
return __AX__;
}
static void display_char(const unsigned char x, const unsigned char y, const unsigned char *ch)
{
unsigned char k;
for(k=0;k<8;++k)
{
SV_VRAM[y][k][x] = double_reversed_bits(ch[k]);
}
}
static void init_lcd(void)
{
SV_LCD.width = 160;
SV_LCD.height = 160;
}
static void hello(unsigned char x, unsigned char y)
{
display_char(x+ 0,y,h_char);
display_char(x+ 1,y,e_char);
display_char(x+ 2,y,l_char);
display_char(x+ 3,y,l_char);
display_char(x+ 4,y,o_char);
display_char(x+ 6,y,w_char);
display_char(x+ 7,y,o_char);
display_char(x+ 8,y,r_char);
display_char(x+ 9,y,l_char);
display_char(x+10,y,d_char);
}
void main(void)
{
init_lcd();
clear_screen();
hello(2,3);
hello(7,16);
}

View File

@@ -1,91 +0,0 @@
/*****************************************************************************/
/* */
/* Watara Supervision sample C program */
/* */
/* Fabrizio Caruso (fabrizio_caruso@hotmail.com), 2019 */
/* */
/*****************************************************************************/
#include <supervision.h>
#include <peekpoke.h>
// Number of bytes per screen line (Remark: Last 8 bytes are not displayed)
#define BYTES_PER_LINE 48
// Character definitions in 8x8 format
const unsigned char h_char[] = {0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00};
const unsigned char e_char[] = {0x7E,0x60,0x60,0x78,0x60,0x60,0x7E,0x00};
const unsigned char l_char[] = {0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00};
const unsigned char o_char[] = {0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00};
const unsigned char w_char[] = {0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00};
const unsigned char r_char[] = {0x7C,0x66,0x66,0x7C,0x78,0x6C,0x66,0x00};
const unsigned char d_char[] = {0x78,0x6C,0x66,0x66,0x66,0x6C,0x78,0x00};
void clear_screen(void)
{
unsigned short i;
for(i=0;i<0x2000;++i)
{
POKE(SV_VIDEO+i,0);
}
}
// Necessary conversion to have 2 bits per pixel with darkest hue
// Remark: The Supervision uses 2 bits per pixel and bits are mapped into pixel in reversed order
unsigned char reversed_map_one_to_two_lookup[16] =
{
0x00, 0xC0, 0x30, 0xF0, 0x0C, 0xCC, 0x3C, 0xFC,
0x03, 0xC3, 0x33, 0xF3, 0x0F, 0xCF, 0x3F, 0xFF
};
unsigned char left_map_one_to_two(unsigned char n)
{
return reversed_map_one_to_two_lookup[n >> 4];
}
unsigned char right_map_one_to_two(unsigned char n)
{
return reversed_map_one_to_two_lookup[n&0x0F];
}
void display_char(const unsigned char x, const unsigned char y, const unsigned char *ch)
{
unsigned char k;
for(k=0;k<8;++k)
{ \
SV_VIDEO[2*(y)+BYTES_PER_LINE*k+BYTES_PER_LINE*(x<<3)] = left_map_one_to_two(ch[k]);
SV_VIDEO[2*(y)+BYTES_PER_LINE*k+BYTES_PER_LINE*(x<<3)+1] = right_map_one_to_two(ch[k]);
}
}
void init_lcd(void)
{
SV_LCD.width = 160;
SV_LCD.height = 160;
}
int main()
{
init_lcd();
clear_screen();
display_char(3,2, h_char);
display_char(3,3, e_char);
display_char(3,4, l_char);
display_char(3,5, l_char);
display_char(3,6, o_char);
display_char(3,8, w_char);
display_char(3,9, o_char);
display_char(3,10,r_char);
display_char(3,11,l_char);
display_char(3,12,d_char);
while(1) {};
return 0;
}

View File

@@ -81,6 +81,12 @@ hello: hello.c text.s
# empty target used to skip systems that will not work with any program in this dir
notavailable:
@echo "warning: tutorial sample not available for" $(SYS)
ifeq ($(MAKELEVEL),0)
@echo "info: tutorial sample not available for" $(SYS)
else
# suppress the "nothing to be done for 'samples' message
@echo > $(NULLDEV)
endif
clean:
@$(DEL) hello 2>$(NULLDEV)