move some things from targettest to samples
This commit is contained in:
@@ -174,7 +174,7 @@ endif
|
||||
# --------------------------------------------------------------------------
|
||||
# Lists of subdirectories
|
||||
|
||||
DIRLIST = accelerator apple2 atari atari5200 cbm gamate pce sym1
|
||||
DIRLIST = accelerator atari cbm gamate pce
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Lists of executables
|
||||
@@ -211,7 +211,6 @@ EXELIST_c64 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: seek
|
||||
@@ -246,7 +245,6 @@ EXELIST_c128 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
|
||||
@@ -278,7 +276,6 @@ EXELIST_c16 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: seek ser-test
|
||||
@@ -312,7 +309,6 @@ EXELIST_cbm510 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: joy-test mouse-test seek
|
||||
@@ -345,7 +341,6 @@ EXELIST_cbm610 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: clock-test em-test mouse-test seek ser-test
|
||||
@@ -376,7 +371,6 @@ EXELIST_pet = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: clock-test em-test mouse-test seek
|
||||
@@ -408,7 +402,6 @@ EXELIST_plus4 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: seek clock-test mouse-test ser-test
|
||||
@@ -440,7 +433,6 @@ EXELIST_vic20 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: cpeek-test, clock
|
||||
@@ -474,7 +466,6 @@ EXELIST_apple2 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
EXELIST_apple2enh = $(EXELIST_apple2)
|
||||
@@ -511,13 +502,12 @@ EXELIST_atari = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
EXELIST_atarixl = $(EXELIST_atari)
|
||||
|
||||
# omitted: clock-test cpeek-test deb dir-test em-test exec-test1 exec-test2
|
||||
# joy-test mouse-test rename-test seek ser-test stroserror-test tinyshell
|
||||
# joy-test mouse-test rename-test seek ser-test stroserror-test
|
||||
EXELIST_telestrat = \
|
||||
minimal \
|
||||
arg-test \
|
||||
@@ -542,7 +532,7 @@ EXELIST_telestrat = \
|
||||
# omitted: arg-test clock-test clock cpeek-test conio cprintf cursor deb dir-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test
|
||||
# mouse-test mul-test posixio-test rename-test scanf-test seek ser-test strdup-test
|
||||
# stroserror-test tinyshell uname-test
|
||||
# stroserror-test uname-test
|
||||
EXELIST_sym1 = \
|
||||
minimal \
|
||||
div-test \
|
||||
@@ -551,7 +541,7 @@ EXELIST_sym1 = \
|
||||
strqtok-test
|
||||
|
||||
# omitted: clock-test cpeek-test conio deb dir-test em-test exec-test1 exec-test2
|
||||
# fileio-test ft mouse-test posixio-test rename-test seek ser-test tinyshell
|
||||
# fileio-test ft mouse-test posixio-test rename-test seek ser-test
|
||||
EXELIST_atmos = \
|
||||
minimal \
|
||||
arg-test \
|
||||
@@ -574,7 +564,7 @@ EXELIST_atmos = \
|
||||
# omitted: arg-test clock-test clock cpeek-test conio cprintf deb dir-test div-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test moddiv-test
|
||||
# mouse-test mul-test posixio-test rename-test scanf-test seek ser-test strdup-test
|
||||
# strnlen stroserror-test strqtok-test tinyshell uname-test
|
||||
# strnlen stroserror-test strqtok-test uname-test
|
||||
EXELIST_creativision = \
|
||||
minimal \
|
||||
cursor
|
||||
@@ -609,13 +599,12 @@ EXELIST_cx16 = \
|
||||
strnlen \
|
||||
stroserror-test \
|
||||
strqtok-test \
|
||||
tinyshell \
|
||||
uname-test
|
||||
|
||||
# omitted: arg-test clock-test clock cpeek-test cprintf cursor deb dir-test div-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test moddiv-test
|
||||
# mouse-test mul-test posixio-test rename-test scanf-test seek ser-test strdup-test
|
||||
# strnlen stroserror-test strqtok-test tinyshell uname-test
|
||||
# strnlen stroserror-test strqtok-test uname-test
|
||||
EXELIST_nes = \
|
||||
minimal \
|
||||
conio
|
||||
@@ -623,7 +612,7 @@ EXELIST_nes = \
|
||||
# omitted: arg-test clock-test clock cpeek-test cprintf cursor deb dir-test div-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test moddiv-test
|
||||
# mouse-test mul-test posixio-test rename-test scanf-test seek ser-test strdup-test
|
||||
# strnlen stroserror-test strqtok-test tinyshell uname-test
|
||||
# strnlen stroserror-test strqtok-test uname-test
|
||||
EXELIST_pce = \
|
||||
minimal \
|
||||
conio
|
||||
@@ -631,7 +620,7 @@ EXELIST_pce = \
|
||||
# omitted: arg-test clock-test clock cpeek-test conio cprintf deb dir-test div-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test moddiv-test
|
||||
# mouse-test posixio-test rename-test scanf-test seek ser-test strdup-test strnlen
|
||||
# stroserror-test strqtok-test tinyshell uname-test
|
||||
# stroserror-test strqtok-test uname-test
|
||||
EXELIST_osic1p = \
|
||||
minimal \
|
||||
cursor \
|
||||
@@ -640,7 +629,7 @@ EXELIST_osic1p = \
|
||||
# omitted: arg-test clock-test clock cpeek-test conio cprintf deb dir-test div-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test moddiv-test
|
||||
# mouse-test posixio-test rename-test scanf-test seek ser-test strdup-test strnlen
|
||||
# stroserror-test strqtok-test tinyshell uname-test
|
||||
# stroserror-test strqtok-test uname-test
|
||||
EXELIST_geos-apple = \
|
||||
minimal \
|
||||
cursor \
|
||||
@@ -649,7 +638,7 @@ EXELIST_geos-apple = \
|
||||
# omitted: arg-test clock-test clock cpeek-test conio cprintf deb dir-test div-test
|
||||
# em-test exec-test1 exec-test2 fileio-test ft getopt-test heaptest joy-test moddiv-test
|
||||
# mouse-test posixio-test rename-test scanf-test seek ser-test strdup-test strnlen
|
||||
# stroserror-test strqtok-test tinyshell uname-test
|
||||
# stroserror-test strqtok-test uname-test
|
||||
|
||||
EXELIST_geos-cbm = \
|
||||
minimal \
|
||||
@@ -658,7 +647,7 @@ EXELIST_geos-cbm = \
|
||||
|
||||
# omitted: clock clock-test conio cpeek-test cprintf cursor deb dir-test em-test
|
||||
# exec-test1 exec-test2 ft heaptest joy-test mouse-test mul-test rename-test seek
|
||||
# ser-test strdup-test stroserror-test tinyshell uname-test
|
||||
# ser-test strdup-test stroserror-test uname-test
|
||||
EXELIST_sim6502 = \
|
||||
minimal \
|
||||
arg-test \
|
||||
@@ -739,9 +728,6 @@ mouse-test: mouse-test.o getsp.o
|
||||
ifneq ($(SYS),vic20)
|
||||
ft: ft.o getsp.o
|
||||
$(LD) $(LDFLAGS) -t $(SYS) -o $@ $^ $(SYS).lib
|
||||
|
||||
tinyshell: tinyshell.o getsp.o
|
||||
$(LD) $(LDFLAGS) -t $(SYS) -o $@ $^ $(SYS).lib
|
||||
endif
|
||||
|
||||
# some programs need more memory on the vic20
|
||||
@@ -749,9 +735,6 @@ endif
|
||||
ifeq ($(SYS),vic20)
|
||||
ft: ft.o getsp.o
|
||||
$(LD) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib
|
||||
|
||||
tinyshell: tinyshell.o getsp.o
|
||||
$(LD) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib
|
||||
endif
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
# For this one see https://applecommander.github.io/
|
||||
AC ?= ac.jar
|
||||
|
||||
# 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_apple2 = \
|
||||
hgrshow \
|
||||
hgrtest \
|
||||
dhgrshow
|
||||
|
||||
ifneq ($(EXELIST_$(SYS)),)
|
||||
testcode: $(EXELIST_$(SYS))
|
||||
else
|
||||
testcode: notavailable
|
||||
endif
|
||||
|
||||
# empty target used to skip systems that will not work with any program in this dir
|
||||
notavailable:
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
@echo "info: apple2 tests not available for" $(SYS)
|
||||
else
|
||||
# suppress the "nothing to be done for 'testcode' message
|
||||
@echo > $(NULLDEV)
|
||||
endif
|
||||
|
||||
disk: hgr.dsk dhgr.dsk
|
||||
|
||||
hgr.dsk: hgrshow hgrtest
|
||||
cp prodos.dsk $@
|
||||
java -jar $(AC) -as $@ hgrshow <hgrshow
|
||||
java -jar $(AC) -as $@ hgrtest <hgrtest
|
||||
java -jar $(AC) -p $@ astronaut.hgr bin 0x2000 <astronaut.hgr
|
||||
java -jar $(AC) -p $@ chips.hgr bin 0x2000 <chips.hgr
|
||||
java -jar $(AC) -p $@ macrometer.hgr bin 0x2000 <macrometer.hgr
|
||||
java -jar $(AC) -p $@ mariner.hgr bin 0x2000 <mariner.hgr
|
||||
java -jar $(AC) -p $@ rose.hgr bin 0x2000 <rose.hgr
|
||||
java -jar $(AC) -p $@ werner.hgr bin 0x2000 <werner.hgr
|
||||
java -jar $(AC) -p $@ winston.hgr bin 0x2000 <winston.hgr
|
||||
|
||||
hgrshow: hgrshow.c
|
||||
$(CL) -Oirs -t apple2 --start-addr 0x4000 -m hgrshow.map $^
|
||||
|
||||
hgrtest: hgrtest.c werner.s
|
||||
$(CL) -Oirs -t apple2 -C apple2-hgr.cfg -m hgrtest.map $^
|
||||
|
||||
dhgr.dsk: dhgrshow
|
||||
cp prodos.dsk $@
|
||||
java -jar $(AC) -as $@ dhgrshow <dhgrshow
|
||||
java -jar $(AC) -p $@ catface.dhgr bin 0x2000 <catface.dhgr
|
||||
java -jar $(AC) -p $@ gatsby.dhgr bin 0x2000 <gatsby.dhgr
|
||||
java -jar $(AC) -p $@ girl.dhgr bin 0x2000 <girl.dhgr
|
||||
java -jar $(AC) -p $@ monarch.dhgr bin 0x2000 <monarch.dhgr
|
||||
java -jar $(AC) -p $@ superman.dhgr bin 0x2000 <superman.dhgr
|
||||
java -jar $(AC) -p $@ venice.dhgr bin 0x2000 <venice.dhgr
|
||||
|
||||
dhgrshow: dhgrshow.c
|
||||
$(CL) -Oirs -t apple2enh --start-addr 0x4000 -m dhgrshow.map $^
|
||||
|
||||
clean:
|
||||
@$(DEL) hgr.dsk dhgr.dsk 2>$(NULLDEV)
|
||||
@$(DEL) hgrshow hgrshow.map 2>$(NULLDEV)
|
||||
@$(DEL) hgrtest hgrtest.map 2>$(NULLDEV)
|
||||
@$(DEL) dhgrshow dhgrshow.map 2>$(NULLDEV)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,46 +0,0 @@
|
||||
// cl65 -t apple2enh --start-addr 0x4000 dhgrshow.c
|
||||
|
||||
#include <tgi.h>
|
||||
#include <conio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <peekpoke.h>
|
||||
|
||||
void main (void)
|
||||
{
|
||||
unsigned old;
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
|
||||
old = videomode (VIDEOMODE_80x24);
|
||||
tgi_install (a2e_hi_tgi);
|
||||
tgi_init ();
|
||||
POKE (0xC05E, 0);
|
||||
|
||||
dir = opendir (".");
|
||||
while (ent = readdir (dir)) {
|
||||
char *ext;
|
||||
int hgr;
|
||||
|
||||
ext = strrchr (ent->d_name, '.');
|
||||
if (!ext || strcasecmp (ext, ".dhgr"))
|
||||
continue;
|
||||
|
||||
hgr = open (ent->d_name, O_RDONLY);
|
||||
POKE (0xC055, 0);
|
||||
read (hgr, (void*)0x2000, 0x2000);
|
||||
POKE (0xC054, 0);
|
||||
read (hgr, (void*)0x2000, 0x2000);
|
||||
close (hgr);
|
||||
|
||||
if (cgetc () == '\r')
|
||||
break;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
POKE (0xC05F, 0);
|
||||
tgi_uninstall ();
|
||||
videomode (old);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,37 +0,0 @@
|
||||
// cl65 -t apple2 --start-addr 0x4000 hgrshow.c
|
||||
|
||||
#include <tgi.h>
|
||||
#include <conio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
||||
void main (void)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
|
||||
tgi_install (a2_hi_tgi);
|
||||
tgi_init ();
|
||||
|
||||
dir = opendir (".");
|
||||
while (ent = readdir (dir)) {
|
||||
char *ext;
|
||||
int hgr;
|
||||
|
||||
ext = strrchr (ent->d_name, '.');
|
||||
if (!ext || strcasecmp (ext, ".hgr"))
|
||||
continue;
|
||||
|
||||
hgr = open (ent->d_name, O_RDONLY);
|
||||
read (hgr, (void*)0x2000, 0x2000);
|
||||
close (hgr);
|
||||
|
||||
if (cgetc () == '\r')
|
||||
break;
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
tgi_uninstall ();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// cl65 -t apple2 -C apple2-hgr.cfg hgrtest.c werner.s
|
||||
|
||||
#include <tgi.h>
|
||||
#include <conio.h>
|
||||
|
||||
#pragma code-name (push, "LOWCODE")
|
||||
|
||||
void say (const char* text)
|
||||
{
|
||||
tgi_setcolor (TGI_COLOR_BLACK);
|
||||
tgi_outtextxy (41, 33, text);
|
||||
}
|
||||
|
||||
#pragma code-name (pop)
|
||||
|
||||
void main (void)
|
||||
{
|
||||
tgi_install (a2_hi_tgi);
|
||||
tgi_init ();
|
||||
cgetc ();
|
||||
|
||||
say ("Hi Dude !");
|
||||
cgetc ();
|
||||
|
||||
tgi_uninstall ();
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
.segment "HGR"
|
||||
.incbin "werner.hgr"
|
||||
Binary file not shown.
@@ -1,4 +1,8 @@
|
||||
|
||||
# Run 'make SYS=<target>'; or, set a SYS env.
|
||||
# var. to build for another target system.
|
||||
SYS ?= atari
|
||||
|
||||
# Just the usual way to find out if we're
|
||||
# using cmd.exe to execute make rules.
|
||||
ifneq ($(shell echo),)
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
|
||||
# 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)),)
|
||||
testcode: $(EXELIST_$(SYS))
|
||||
else
|
||||
testcode: 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 'testcode' message
|
||||
@echo > $(NULLDEV)
|
||||
endif
|
||||
|
||||
hello: hello.c
|
||||
$(CL) -t atari5200 -o hello hello.c
|
||||
|
||||
clean:
|
||||
@$(DEL) hello 2>$(NULLDEV)
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
** 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;
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
|
||||
# Run 'make SYS=<target>'; or, set a SYS env.
|
||||
# var. to build for another target system.
|
||||
SYS ?= gamate
|
||||
|
||||
# Just the usual way to find out if we're
|
||||
# using cmd.exe to execute make rules.
|
||||
ifneq ($(shell echo),)
|
||||
@@ -51,9 +55,6 @@ lcdtest.bin: lcdtest.s
|
||||
$(CL) -l lcdtest.lst -t gamate -o lcdtest.bin lcdtest.s
|
||||
ctest.bin: ctest.c
|
||||
$(CL) -l ctest.lst -t gamate -o ctest.bin ctest.c
|
||||
nachtm.bin: nachtm.c
|
||||
$(CL) -Os -l nachtm.lst -t gamate -o nachtm.bin nachtm.c
|
||||
gamate-fixcart nachtm.bin
|
||||
|
||||
clean:
|
||||
@$(DEL) lcdtest.o audiotest.o ctest.o 2>$(NULLDEV)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,8 @@
|
||||
|
||||
# Run 'make SYS=<target>'; or, set a SYS env.
|
||||
# var. to build for another target system.
|
||||
SYS ?= pce
|
||||
|
||||
# Just the usual way to find out if we're
|
||||
# using cmd.exe to execute make rules.
|
||||
ifneq ($(shell echo),)
|
||||
|
||||
9
targettest/readme.txt
Normal file
9
targettest/readme.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
This directory contains test programs for the cc65 compiler.
|
||||
|
||||
The programs contained here are
|
||||
- NOT to be referenced in the documentation
|
||||
- compiled (but NOT run) by the CI test (this is their main purpose)
|
||||
- some programs can be used interactively to check certain library features
|
||||
|
||||
Sample programs ment for endusers should be placed in the samples directory.
|
||||
@@ -1,67 +0,0 @@
|
||||
# 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_sym1 = \
|
||||
symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin
|
||||
|
||||
ifneq ($(EXELIST_$(SYS)),)
|
||||
testcode: $(EXELIST_$(SYS))
|
||||
else
|
||||
testcode: notavailable
|
||||
endif
|
||||
|
||||
# empty target used to skip systems that will not work with any program in this dir
|
||||
notavailable:
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
@echo "info: sym1 tests not available for" $(SYS)
|
||||
else
|
||||
# suppress the "nothing to be done for 'testcode' message
|
||||
@echo > $(NULLDEV)
|
||||
endif
|
||||
|
||||
symHello.bin: symHello.c
|
||||
$(CL) -t sym1 -O -o symHello.bin symHello.c
|
||||
|
||||
symTiny.bin: symTiny.c
|
||||
$(CL) -t sym1 -O -o symTiny.bin symTiny.c
|
||||
|
||||
symDisplay.bin: symDisplay.c
|
||||
$(CL) -t sym1 -O -o symDisplay.bin symDisplay.c
|
||||
|
||||
symIO.bin: symIO.c
|
||||
$(CL) -t sym1 -C sym1-32k.cfg -O -o symIO.bin symIO.c
|
||||
|
||||
symNotepad.bin: symNotepad.c
|
||||
$(CL) -t sym1 -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c
|
||||
|
||||
clean:
|
||||
@$(DEL) symHello.bin 2>$(NULLDEV)
|
||||
@$(DEL) symTiny.bin 2>$(NULLDEV)
|
||||
@$(DEL) symDisplay.bin 2>$(NULLDEV)
|
||||
@$(DEL) symIO.bin 2>$(NULLDEV)
|
||||
@$(DEL) symNotepad.bin 2>$(NULLDEV)
|
||||
@@ -1,358 +0,0 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Sym-1 front panel display example
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sym1.h>
|
||||
|
||||
int main (void) {
|
||||
int delay = 10;
|
||||
int flashes = 255;
|
||||
int displayable = 1;
|
||||
int e = 0;
|
||||
int r = 0;
|
||||
int d = 0;
|
||||
int i = 0;
|
||||
int l = 0;
|
||||
int t = 0;
|
||||
int z = 0;
|
||||
char c = 0x00;
|
||||
char buffer[41] = { 0x00 };
|
||||
|
||||
puts ("\nType a message (40 chars max) and press ENTER, please:\n");
|
||||
|
||||
while ( (c != '\n') && (i < 40) ) {
|
||||
c = getchar();
|
||||
buffer[i] = c;
|
||||
i++;
|
||||
if ( i == 40 ) {
|
||||
puts ("\n\n--- Reached 40 character limit. ---");
|
||||
}
|
||||
}
|
||||
|
||||
i--; // index is one past end
|
||||
|
||||
while ( z == 0 ) {
|
||||
puts ("\n\nHow many times (0 for forever) to repeat?");
|
||||
c = getchar();
|
||||
if ( (c >= '0') && (c <= '9') ) {// between 1 and 9 loops allowed
|
||||
z = 1; // a number was pressed
|
||||
t = c - '0'; // convert char to int
|
||||
puts ("\n\nLook at the front panel.\n");
|
||||
}
|
||||
else {
|
||||
puts ("\nWhat?");
|
||||
z = 0; // keep asking for a number
|
||||
}
|
||||
}
|
||||
|
||||
z = 0;
|
||||
while ( (z < t) || (t == 0) ) {
|
||||
|
||||
z++;
|
||||
|
||||
putchar ( '\r' ); // Send CR to console
|
||||
|
||||
DISPLAY.d0 = DISP_SPACE; // Clear the display
|
||||
DISPLAY.d1 = DISP_SPACE;
|
||||
DISPLAY.d2 = DISP_SPACE;
|
||||
DISPLAY.d3 = DISP_SPACE;
|
||||
DISPLAY.d4 = DISP_SPACE;
|
||||
DISPLAY.d5 = DISP_SPACE;
|
||||
DISPLAY.d6 = DISP_SPACE;
|
||||
|
||||
for ( d = 0; d < flashes ; d++ ) {
|
||||
fdisp(); // Display
|
||||
}
|
||||
|
||||
for ( l = 0; l <= i; l++ ) {
|
||||
|
||||
displayable = 1; // Assume character is mapped
|
||||
|
||||
switch ( buffer[l] ) { // Put the typed charaters
|
||||
case '1': // into the display buffer
|
||||
DISPLAY.d6 = DISP_1; // one at a time
|
||||
break;
|
||||
case '2':
|
||||
DISPLAY.d6 = DISP_2;
|
||||
break;
|
||||
case '3':
|
||||
DISPLAY.d6 = DISP_3;
|
||||
break;
|
||||
case '4':
|
||||
DISPLAY.d6 = DISP_4;
|
||||
break;
|
||||
case '5':
|
||||
DISPLAY.d6 = DISP_5;
|
||||
break;
|
||||
case '6':
|
||||
DISPLAY.d6 = DISP_6;
|
||||
break;
|
||||
case '7':
|
||||
DISPLAY.d6 = DISP_7;
|
||||
break;
|
||||
case '8':
|
||||
DISPLAY.d6 = DISP_8;
|
||||
break;
|
||||
case '9':
|
||||
DISPLAY.d6 = DISP_9;
|
||||
break;
|
||||
case '0':
|
||||
DISPLAY.d6 = DISP_0;
|
||||
break;
|
||||
case 'A':
|
||||
DISPLAY.d6 = DISP_A;
|
||||
break;
|
||||
case 'a':
|
||||
DISPLAY.d6 = DISP_A;
|
||||
break;
|
||||
case 'B':
|
||||
DISPLAY.d6 = DISP_b;
|
||||
break;
|
||||
case 'b':
|
||||
DISPLAY.d6 = DISP_b;
|
||||
break;
|
||||
case 'C':
|
||||
DISPLAY.d6 = DISP_C;
|
||||
break;
|
||||
case 'c':
|
||||
DISPLAY.d6 = DISP_c;
|
||||
break;
|
||||
case 'D':
|
||||
DISPLAY.d6 = DISP_d;
|
||||
break;
|
||||
case 'd':
|
||||
DISPLAY.d6 = DISP_d;
|
||||
break;
|
||||
case 'E':
|
||||
DISPLAY.d6 = DISP_E;
|
||||
break;
|
||||
case 'e':
|
||||
DISPLAY.d6 = DISP_e;
|
||||
break;
|
||||
case 'F':
|
||||
DISPLAY.d6 = DISP_F;
|
||||
break;
|
||||
case 'f':
|
||||
DISPLAY.d6 = DISP_F;
|
||||
break;
|
||||
case 'G':
|
||||
DISPLAY.d6 = DISP_G;
|
||||
break;
|
||||
case 'g':
|
||||
DISPLAY.d6 = DISP_g;
|
||||
break;
|
||||
case 'H':
|
||||
DISPLAY.d6 = DISP_H;
|
||||
break;
|
||||
case 'h':
|
||||
DISPLAY.d6 = DISP_h;
|
||||
break;
|
||||
case 'I':
|
||||
DISPLAY.d6 = DISP_I;
|
||||
break;
|
||||
case 'i':
|
||||
DISPLAY.d6 = DISP_i;
|
||||
break;
|
||||
case 'J':
|
||||
DISPLAY.d6 = DISP_J;
|
||||
break;
|
||||
case 'j':
|
||||
DISPLAY.d6 = DISP_J;
|
||||
break;
|
||||
case 'K':
|
||||
DISPLAY.d6 = DISP_K;
|
||||
break;
|
||||
case 'k':
|
||||
DISPLAY.d6 = DISP_K;
|
||||
break;
|
||||
case 'L':
|
||||
DISPLAY.d6 = DISP_L;
|
||||
break;
|
||||
case 'l':
|
||||
DISPLAY.d6 = DISP_L;
|
||||
break;
|
||||
case 'M':
|
||||
DISPLAY.d0 = DISPLAY.d1;
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_M_1;
|
||||
DISPLAY.d6 = DISP_M_2;
|
||||
break;
|
||||
case 'm':
|
||||
DISPLAY.d0 = DISPLAY.d1;
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_M_1;
|
||||
DISPLAY.d6 = DISP_M_2;
|
||||
break;
|
||||
case 'N':
|
||||
DISPLAY.d6 = DISP_n;
|
||||
break;
|
||||
case 'n':
|
||||
DISPLAY.d6 = DISP_n;
|
||||
break;
|
||||
case 'O':
|
||||
DISPLAY.d6 = DISP_O;
|
||||
break;
|
||||
case 'o':
|
||||
DISPLAY.d6 = DISP_o;
|
||||
break;
|
||||
case 'P':
|
||||
DISPLAY.d6 = DISP_P;
|
||||
break;
|
||||
case 'p':
|
||||
DISPLAY.d6 = DISP_P;
|
||||
break;
|
||||
case 'Q':
|
||||
DISPLAY.d6 = DISP_q;
|
||||
break;
|
||||
case 'q':
|
||||
DISPLAY.d6 = DISP_q;
|
||||
break;
|
||||
case 'R':
|
||||
DISPLAY.d6 = DISP_r;
|
||||
break;
|
||||
case 'r':
|
||||
DISPLAY.d6 = DISP_r;
|
||||
break;
|
||||
case 'S':
|
||||
DISPLAY.d6 = DISP_S;
|
||||
break;
|
||||
case 's':
|
||||
DISPLAY.d6 = DISP_S;
|
||||
break;
|
||||
case 'T':
|
||||
DISPLAY.d6 = DISP_t;
|
||||
break;
|
||||
case 't':
|
||||
DISPLAY.d6 = DISP_t;
|
||||
break;
|
||||
case 'U':
|
||||
DISPLAY.d6 = DISP_U;
|
||||
break;
|
||||
case 'u':
|
||||
DISPLAY.d6 = DISP_u;
|
||||
break;
|
||||
case 'V':
|
||||
DISPLAY.d0 = DISPLAY.d1;
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_V_1;
|
||||
DISPLAY.d6 = DISP_V_2;
|
||||
break;
|
||||
case 'v':
|
||||
DISPLAY.d0 = DISPLAY.d1;
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_V_1;
|
||||
DISPLAY.d6 = DISP_V_2;
|
||||
break;
|
||||
case 'W':
|
||||
DISPLAY.d0 = DISPLAY.d1;
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_W_1;
|
||||
DISPLAY.d6 = DISP_W_2;
|
||||
break;
|
||||
case 'w':
|
||||
DISPLAY.d0 = DISPLAY.d1;
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_W_1;
|
||||
DISPLAY.d6 = DISP_W_2;
|
||||
break;
|
||||
case 'Y':
|
||||
DISPLAY.d6 = DISP_Y;
|
||||
break;
|
||||
case 'y':
|
||||
DISPLAY.d6 = DISP_Y;
|
||||
break;
|
||||
case 'Z':
|
||||
DISPLAY.d6 = DISP_Z;
|
||||
break;
|
||||
case 'z':
|
||||
DISPLAY.d6 = DISP_Z;
|
||||
break;
|
||||
case ' ':
|
||||
DISPLAY.d6 = DISP_SPACE;
|
||||
break;
|
||||
case '.':
|
||||
DISPLAY.d6 = DISP_PERIOD;
|
||||
break;
|
||||
case '-':
|
||||
DISPLAY.d6 = DISP_HYPHEN;
|
||||
break;
|
||||
case '\'':
|
||||
DISPLAY.d6 = DISP_APOSTR;
|
||||
break;
|
||||
case '"':
|
||||
DISPLAY.d6 = DISP_APOSTR;
|
||||
break;
|
||||
case '=':
|
||||
DISPLAY.d6 = DISP_EQUAL;
|
||||
break;
|
||||
case '_':
|
||||
DISPLAY.d6 = DISP_BOTTOM;
|
||||
break;
|
||||
case '/':
|
||||
DISPLAY.d6 = DISP_SLASH;
|
||||
break;
|
||||
case '\\':
|
||||
DISPLAY.d6 = DISP_BACKSLASH;
|
||||
break;
|
||||
default:
|
||||
displayable = 0; // Character not mapped
|
||||
}
|
||||
|
||||
if ( displayable ) {
|
||||
|
||||
putchar ( buffer[l] ); // Send it to the console
|
||||
|
||||
DISPLAY.d0 = DISPLAY.d1; // Scroll to the left
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISPLAY.d6;
|
||||
|
||||
for ( d = 0; d < flashes ; d++ ) {
|
||||
fdisp(); // Display
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( e = 0; e < 6; e++ ) { // Gradually fill the
|
||||
DISPLAY.d0 = DISPLAY.d1; // display with spaces
|
||||
DISPLAY.d1 = DISPLAY.d2;
|
||||
DISPLAY.d2 = DISPLAY.d3;
|
||||
DISPLAY.d3 = DISPLAY.d4;
|
||||
DISPLAY.d4 = DISPLAY.d5;
|
||||
DISPLAY.d5 = DISP_SPACE;
|
||||
DISPLAY.d6 = DISP_SPACE;
|
||||
for ( d = 0; d < flashes ; d++ ) {
|
||||
fdisp(); // Display
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
puts ("\n\nEnjoy your day!\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Hello World for Sym-1
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sym1.h>
|
||||
|
||||
int main (void) {
|
||||
char c = 0x00;
|
||||
int d = 0x00;
|
||||
int l = 0x00;
|
||||
|
||||
printf ("\nHello World!\n\n");
|
||||
|
||||
for ( l = 0; l < 2; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
printf ("Type a line and press ENTER, please.\n\n");
|
||||
|
||||
while ( c != '\n' ) {
|
||||
c = getchar();
|
||||
}
|
||||
|
||||
printf ("\n\nThanks!\n\n");
|
||||
|
||||
for ( l = 0; l < 5; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Sym-1 digital I/O interface example
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <sym1.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main (void) {
|
||||
unsigned char ddr1a = 0x00;
|
||||
unsigned char ior1a = 0x00;
|
||||
unsigned char ddr1b = 0x00;
|
||||
unsigned char ior1b = 0x00;
|
||||
unsigned char ddr2a = 0x00;
|
||||
unsigned char ior2a = 0x00;
|
||||
unsigned char ddr2b = 0x00;
|
||||
unsigned char ior2b = 0x00;
|
||||
unsigned char ddr3a = 0x00;
|
||||
unsigned char ior3a = 0x00;
|
||||
unsigned char ddr3b = 0x00;
|
||||
unsigned char ior3b = 0x00;
|
||||
unsigned char val = 0x00;
|
||||
int going = 0x01;
|
||||
int instr = 0x01;
|
||||
int l = 0x00;
|
||||
char* vp = 0x00;
|
||||
char cmd[20] = { 0x00 };
|
||||
|
||||
while ( going ) {
|
||||
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
|
||||
ddr1a = VIA1.ddra;
|
||||
ior1a = VIA1.pra;
|
||||
ddr1b = VIA1.ddrb;
|
||||
ior1b = VIA1.prb;
|
||||
ddr2a = VIA2.ddra;
|
||||
ior2a = VIA2.pra;
|
||||
ddr2b = VIA2.ddrb;
|
||||
ior2b = VIA2.prb;
|
||||
ddr3a = VIA3.ddra;
|
||||
ior3a = VIA3.pra;
|
||||
ddr3b = VIA3.ddrb;
|
||||
ior3b = VIA3.prb;
|
||||
|
||||
puts ("================== Digital I/O Status ==================");
|
||||
puts (" Port1A Port1B Port2A Port2B Port3A Port3B" );
|
||||
printf ("DDR %02X %02X %02X %02X %02X %02X\n\r",ddr1a,ddr1b,ddr2a,ddr2b,ddr3a,ddr3b);
|
||||
printf ("IOR %02X %02X %02X %02X %02X %02X\n\r",ior1a,ior1b,ior2a,ior2b,ior3a,ior3b);
|
||||
puts ("========================================================\n");
|
||||
|
||||
if ( instr ) {
|
||||
puts ("You can set any register by typing 'register value' so");
|
||||
puts ("as an example, to set register IOR2A with the top five");
|
||||
puts ("bits off and the bottom three on, type 'IOR2A 07'.");
|
||||
puts ("Press ENTER without any command to see register values");
|
||||
puts ("without changing any of them. Type 'help' to see these");
|
||||
puts ("instructions again and type 'quit' to end the program.\n");
|
||||
puts ("Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A");
|
||||
puts ("IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B.");
|
||||
instr = 0;
|
||||
}
|
||||
|
||||
printf ("\n Command: ");
|
||||
|
||||
fgets ( cmd, sizeof(cmd)-1, stdin );
|
||||
cmd[strlen(cmd)-1] = '\0';
|
||||
|
||||
if ( strncasecmp(cmd, "quit", 4) == 0 ) {
|
||||
going = 0;
|
||||
}
|
||||
else if ( strncasecmp(cmd, "help", 4) == 0 ) {
|
||||
instr = 1;
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr1a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.ddra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior1a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.pra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr1b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.ddrb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior1b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.prb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr2a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.ddra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior2a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.pra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr2b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.ddrb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior2b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.prb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr3a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.ddra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior3a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.pra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr3b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.ddrb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior3b", 5) == 0 ) {
|
||||
vp = strchr (cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.prb = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
puts ("\n\nEnjoy your day!\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Sym-1 Notepad
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
//
|
||||
// Note: This program requires RAM memory in locations 0xE000 - 0xEFFF
|
||||
// Alternatively, the tape I/O buffer location and size can be
|
||||
// changed by altering the defined TAPIO values below.
|
||||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <sym1.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TAPIO_ADDRESS 0xE000
|
||||
#define TAPIO_MAX_SIZE 0x0FFF
|
||||
|
||||
int main (void) {
|
||||
char c = 0x00;
|
||||
int l = 0x00;
|
||||
int p = 0x00;
|
||||
int error = 0x00;
|
||||
int running = 0x01;
|
||||
int writing = 0x01;
|
||||
int instruction_needed = 0x01;
|
||||
int heap_size = 0x00;
|
||||
char* tapio = (char*) TAPIO_ADDRESS;
|
||||
char* buffer;
|
||||
|
||||
heap_size = _heapmaxavail();
|
||||
|
||||
if ( heap_size > TAPIO_MAX_SIZE ) { // No need to malloc more than
|
||||
heap_size = TAPIO_MAX_SIZE; // the interface allows
|
||||
}
|
||||
|
||||
buffer = malloc ( heap_size );
|
||||
memset ( buffer, 0x00, heap_size );
|
||||
|
||||
if ( buffer == 0x00 ) {
|
||||
puts ("Memory full.");
|
||||
running = 0;
|
||||
}
|
||||
|
||||
tapio[0] = 0x00; // Check tape interface memory
|
||||
if ( tapio[0] != 0x00 )
|
||||
error = 1;
|
||||
|
||||
tapio[0] = 0xFF;
|
||||
if ( tapio[0] != 0xFF )
|
||||
error = 1;
|
||||
|
||||
tapio[TAPIO_MAX_SIZE] = 0x00;
|
||||
if ( tapio[TAPIO_MAX_SIZE] != 0x00 )
|
||||
error = 1;
|
||||
|
||||
tapio[TAPIO_MAX_SIZE] = 0xFF;
|
||||
if ( tapio[TAPIO_MAX_SIZE] != 0xFF )
|
||||
error = 1;
|
||||
|
||||
if ( error ) {
|
||||
printf ("\nNo memory at location %p, aborting.\n", tapio);
|
||||
running = 0;
|
||||
}
|
||||
else {
|
||||
memset ( tapio, 0, TAPIO_MAX_SIZE );
|
||||
}
|
||||
|
||||
|
||||
while ( running ) {
|
||||
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
|
||||
puts ("===================== Sym-1 Notepad ====================");
|
||||
|
||||
if ( instruction_needed ) {
|
||||
puts ("Enter text and you can save it to tape for reloading");
|
||||
puts ("later. There are four special 'command' characters:\n");
|
||||
puts (" Control-S Save to tape");
|
||||
puts (" Control-L Load from tape");
|
||||
puts (" Control-C Clear memory");
|
||||
puts (" Control-X Exit");
|
||||
puts ("========================================================\n");
|
||||
}
|
||||
|
||||
while ( writing ) {
|
||||
|
||||
c = getchar();
|
||||
|
||||
if ( c == 0x08 ) { // Backspace
|
||||
if ( p > 0 ) {
|
||||
buffer[p] = 0x00;
|
||||
p--;
|
||||
}
|
||||
}
|
||||
else if ( c == 0x13 ) { // Save
|
||||
puts ("\n========================= Save =========================");
|
||||
puts ("\nPress any key to save.");
|
||||
c = getchar();
|
||||
for ( l = 0; l <= p; l++ ) {
|
||||
tapio[l] = buffer[l];
|
||||
}
|
||||
l++;
|
||||
tapio[l] = 0x00;
|
||||
puts ("Saving to tape.");
|
||||
error = dumpt ( 'N', tapio, tapio+p );
|
||||
if ( error ) {
|
||||
puts ("\nTape error.");
|
||||
}
|
||||
else
|
||||
{
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
}
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
for ( l = 0; l <= p; l++ ) {
|
||||
putchar ( buffer[l] );
|
||||
}
|
||||
}
|
||||
else if ( c == 0x0C ) { // Load
|
||||
p = 0;
|
||||
puts ("\nLoading from tape.");
|
||||
memset ( buffer, 0, heap_size );
|
||||
memset ( tapio, 0, TAPIO_MAX_SIZE );
|
||||
error = loadt ( 'N' );
|
||||
if ( error ) {
|
||||
puts ("\nTape error.");
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( l = 0; l <= heap_size; l++ ) {
|
||||
buffer[l] = tapio[l];
|
||||
}
|
||||
|
||||
p = strlen ( buffer );
|
||||
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
|
||||
for ( l = 0; l <= p; l++ ) {
|
||||
putchar ( buffer[l] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( c == 0x03 ) { // Clear
|
||||
p = 0;
|
||||
memset ( buffer, 0, heap_size );
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
}
|
||||
else if ( c == 0x18 ) { // Exit
|
||||
writing = 0;
|
||||
running = 0;
|
||||
}
|
||||
else {
|
||||
if ( p >= heap_size - 1 ) {
|
||||
puts ("\n========================= End =========================");
|
||||
puts ("Buffer full.");
|
||||
}
|
||||
else {
|
||||
if ( c == '\n' ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
buffer[p] = c;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free ( buffer );
|
||||
|
||||
puts ("\nEnjoy your day!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Hello World for Sym-1
|
||||
//
|
||||
// Uses only getchar, putchar and puts, generating smaller code than printf
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sym1.h>
|
||||
|
||||
int main (void) {
|
||||
char c = 0x00;
|
||||
int d = 0x00;
|
||||
int l = 0x00;
|
||||
|
||||
puts ("Hello World!\n");
|
||||
|
||||
puts ("Type a line and press ENTER, please:\n");
|
||||
|
||||
for ( l = 0; l < 2; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
|
||||
while ( c != '\n' ) {
|
||||
c = getchar();
|
||||
}
|
||||
|
||||
puts ("\n\nThanks!\n");
|
||||
|
||||
for ( l = 0; l < 5; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,503 +0,0 @@
|
||||
/*
|
||||
** Simple ("tiny") shell to test filename and directory functions.
|
||||
** Copyright (c) 2013,2016 Christian Groessler, chris@groessler.org
|
||||
*/
|
||||
|
||||
#define VERSION_ASC "0.91"
|
||||
|
||||
#ifdef __ATARI__
|
||||
#define UPPERCASE /* define (e.g. for Atari) to convert filenames etc. to upper case */
|
||||
#define HAVE_SUBDIRS
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE2__
|
||||
#define HAVE_SUBDIRS
|
||||
#endif
|
||||
|
||||
#ifdef __CC65__
|
||||
#define CHECK_SP
|
||||
#endif
|
||||
|
||||
#define KEYB_BUFSZ 127
|
||||
#define PROMPT ">>> "
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#ifndef __CC65__
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#define HAVE_SUBDIRS
|
||||
#else
|
||||
#define MAXPATHLEN 64
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#ifdef CHECK_SP
|
||||
extern unsigned int getsp(void); /* comes from getsp.s */
|
||||
#endif
|
||||
|
||||
#define CMD_NOTHING 0
|
||||
#define CMD_INVALID 1
|
||||
#define CMD_HELP 2
|
||||
#define CMD_QUIT 3
|
||||
#define CMD_LS 4
|
||||
#define CMD_MKDIR 5
|
||||
#define CMD_RMDIR 6
|
||||
#define CMD_CHDIR 7
|
||||
#define CMD_RM 8
|
||||
#define CMD_RENAME 9
|
||||
#define CMD_COPY 10
|
||||
#define CMD_PWD 11
|
||||
#define CMD_CLS 12
|
||||
#define CMD_VERBOSE 13
|
||||
#define CMD_EXEC 14
|
||||
|
||||
static unsigned char verbose;
|
||||
static unsigned char terminate;
|
||||
static unsigned char cmd;
|
||||
static char *cmd_asc, *arg1, *arg2, *arg3, *args; /* 'args': everything after command */
|
||||
static char keyb_buf[KEYB_BUFSZ + 1];
|
||||
static char keyb_buf2[KEYB_BUFSZ + 1];
|
||||
static size_t cpbuf_sz = 4096;
|
||||
|
||||
struct cmd_table {
|
||||
char *name;
|
||||
unsigned char code;
|
||||
} cmd_table[] = {
|
||||
{ "help", CMD_HELP },
|
||||
{ "quit", CMD_QUIT },
|
||||
{ "q", CMD_QUIT },
|
||||
{ "exit", CMD_QUIT },
|
||||
{ "ls", CMD_LS },
|
||||
{ "dir", CMD_LS },
|
||||
{ "md", CMD_MKDIR },
|
||||
#ifdef HAVE_SUBDIRS
|
||||
{ "mkdir", CMD_MKDIR },
|
||||
{ "rd", CMD_RMDIR },
|
||||
{ "rmdir", CMD_RMDIR },
|
||||
{ "cd", CMD_CHDIR },
|
||||
{ "chdir", CMD_CHDIR },
|
||||
#endif
|
||||
{ "rm", CMD_RM },
|
||||
{ "del", CMD_RM },
|
||||
{ "cp", CMD_COPY },
|
||||
{ "copy", CMD_COPY },
|
||||
{ "mv", CMD_RENAME },
|
||||
{ "ren", CMD_RENAME },
|
||||
{ "pwd", CMD_PWD },
|
||||
{ "exec", CMD_EXEC },
|
||||
#ifdef __ATARI__
|
||||
{ "cls", CMD_CLS },
|
||||
#endif
|
||||
{ "verbose", CMD_VERBOSE },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static void banner(void)
|
||||
{
|
||||
puts("\"tiny\" command line shell, v" VERSION_ASC);
|
||||
puts("written by chris@groessler.org");
|
||||
puts("type 'help' for help\n");
|
||||
}
|
||||
|
||||
static void get_command(void)
|
||||
{
|
||||
unsigned char i = 0;
|
||||
|
||||
#ifdef CHECK_SP
|
||||
static char firstcall = 1;
|
||||
static unsigned int good_sp;
|
||||
unsigned int sp;
|
||||
if (firstcall)
|
||||
sp = good_sp = getsp();
|
||||
else
|
||||
sp = getsp();
|
||||
|
||||
if (sp != good_sp) {
|
||||
printf("SP: 0x%04X ***MISMATCH*** 0x%04X\n", sp, good_sp);
|
||||
}
|
||||
else if (verbose)
|
||||
printf("SP: 0x%04X\n", sp);
|
||||
#endif
|
||||
|
||||
arg1 = arg2 = arg3 = NULL;
|
||||
|
||||
/* issue prompt */
|
||||
printf(PROMPT);
|
||||
|
||||
/* get input from the user */
|
||||
if (! fgets(keyb_buf, KEYB_BUFSZ, stdin)) {
|
||||
puts("");
|
||||
cmd = CMD_QUIT;
|
||||
return;
|
||||
}
|
||||
|
||||
/* put everything after first string into 'args' */
|
||||
|
||||
strcpy(keyb_buf2, keyb_buf); /* use a backup copy for 'args' */
|
||||
|
||||
/* skip over the first non-whitespace item */
|
||||
cmd_asc = strtok(keyb_buf2, " \t\n");
|
||||
if (cmd_asc)
|
||||
args = strtok(NULL, ""); /* get everything */
|
||||
else
|
||||
*args = 0; /* no arguments */
|
||||
|
||||
/* split input into cmd, arg1, arg2, arg3 */
|
||||
|
||||
/* get and parse command */
|
||||
cmd_asc = strtok(keyb_buf, " \t\n");
|
||||
if (! cmd_asc) {
|
||||
cmd = CMD_NOTHING;
|
||||
return;
|
||||
}
|
||||
cmd = CMD_INVALID;
|
||||
while (cmd_table[i].name) {
|
||||
if (! strcmp(cmd_table[i].name, cmd_asc)) {
|
||||
cmd = cmd_table[i].code;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* get arguments */
|
||||
arg1 = strtok(NULL, " \t\n");
|
||||
if (! arg1)
|
||||
return;
|
||||
arg2 = strtok(NULL, " \t\n");
|
||||
if (! arg2)
|
||||
return;
|
||||
arg3 = strtok(NULL, " \t\n");
|
||||
}
|
||||
|
||||
static void cmd_help(void)
|
||||
{
|
||||
puts("quit, exit - exit shell");
|
||||
puts("ls, dir - display current directory");
|
||||
puts(" and drive contents");
|
||||
puts("rm, del - delete file");
|
||||
puts("cp, copy - copy file");
|
||||
puts("mv, ren - rename file");
|
||||
puts("cd, chdir - change directory or drive");
|
||||
puts("md, mkdir - make directory or drive");
|
||||
puts("rd, rmdir - remove directory or drive");
|
||||
puts("exec - run program");
|
||||
#ifdef __ATARI__
|
||||
puts("cls - clear screen");
|
||||
#endif
|
||||
puts("verbose - set verbosity level");
|
||||
}
|
||||
|
||||
static void cmd_ls(void)
|
||||
{
|
||||
DIR *dir;
|
||||
char *arg;
|
||||
struct dirent *dirent;
|
||||
#ifdef __ATARI__
|
||||
char need_free = 0;
|
||||
#endif
|
||||
|
||||
if (arg2) {
|
||||
puts("usage: ls [dir]");
|
||||
return;
|
||||
}
|
||||
|
||||
/* print directory listing */
|
||||
if (arg1) {
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
#endif
|
||||
#ifdef __ATARI__
|
||||
/* not sure if this shouldn't be done by the runtime lib */
|
||||
if (*(arg1 + strlen(arg1) - 1) == ':' || *(arg1 + strlen(arg1) - 1) == '>') {
|
||||
arg = malloc(strlen(arg1) + 4);
|
||||
if (! arg) {
|
||||
printf("malloc failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
need_free = 1;
|
||||
memcpy(arg, arg1, strlen(arg1) + 1);
|
||||
strcat(arg, "*.*");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
arg = arg1;
|
||||
}
|
||||
else
|
||||
arg = ".";
|
||||
|
||||
if (verbose)
|
||||
printf("Buffer addr: %p\n", arg);
|
||||
dir = opendir(arg);
|
||||
#ifdef __ATARI__
|
||||
if (need_free) free(arg);
|
||||
#endif
|
||||
if (! dir) {
|
||||
puts("opendir failed");
|
||||
return;
|
||||
}
|
||||
|
||||
while (dirent = readdir(dir))
|
||||
puts(dirent->d_name);
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
static void cmd_rm(void)
|
||||
{
|
||||
if (!arg1 || arg2) {
|
||||
puts("usage: rm <file>");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
#endif
|
||||
|
||||
if (unlink(arg1))
|
||||
printf("remove failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBDIRS
|
||||
|
||||
static void cmd_mkdir(void)
|
||||
{
|
||||
if (!arg1 || arg2) {
|
||||
puts("usage: mkdir <dir>");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
#endif
|
||||
|
||||
if (mkdir(arg1, 0777))
|
||||
printf("mkdir failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
static void cmd_rmdir(void)
|
||||
{
|
||||
if (!arg1 || arg2) {
|
||||
puts("usage: rmdir <dir>");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
#endif
|
||||
|
||||
if (rmdir(arg1))
|
||||
printf("rmdir failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
static void cmd_chdir(void)
|
||||
{
|
||||
if (!arg1 || arg2) {
|
||||
puts("usage: cddir <dir>");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
#endif
|
||||
|
||||
if (chdir(arg1))
|
||||
printf("chdir failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
static void cmd_pwd(void)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
if (arg1) {
|
||||
puts("usage: pwd");
|
||||
return;
|
||||
}
|
||||
|
||||
buf = malloc(MAXPATHLEN);
|
||||
if (! buf) {
|
||||
printf("malloc %u bytes failed: %s\n", MAXPATHLEN, strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (verbose)
|
||||
printf("Buffer addr: %p\n", buf);
|
||||
if (!getcwd(buf, MAXPATHLEN)) {
|
||||
printf("getcwd failed: %s\n", strerror(errno));
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
puts(buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
#endif /* #ifdef HAVE_SUBDIRS */
|
||||
|
||||
static void cmd_rename(void)
|
||||
{
|
||||
if (!arg2 || arg3) {
|
||||
puts("usage: mv <oldname> <newname>");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
strupr(arg2);
|
||||
#endif
|
||||
|
||||
if (rename(arg1, arg2))
|
||||
printf("rename failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
static void cmd_exec(void)
|
||||
{
|
||||
char *progname, *arguments;
|
||||
|
||||
progname = strtok(args, " \t\n");
|
||||
if (! progname) {
|
||||
puts("usage: exec <progname> [arguments]");
|
||||
return;
|
||||
}
|
||||
arguments = strtok(NULL, "");
|
||||
|
||||
/*printf("exec: %s %s\n", progname, arguments ? arguments : "");*/
|
||||
(void)exec(progname, arguments);
|
||||
printf("exec error: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
static void cmd_copy(void)
|
||||
{
|
||||
int srcfd = -1, dstfd = -1;
|
||||
char *buf;
|
||||
int readsz, writesz;
|
||||
|
||||
if (!arg2 || arg3) {
|
||||
puts("usage: cp <src> <dest>");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UPPERCASE
|
||||
strupr(arg1);
|
||||
strupr(arg2);
|
||||
#endif
|
||||
|
||||
buf = malloc(cpbuf_sz);
|
||||
if (! buf) {
|
||||
printf("malloc %u bytes failed: %s\n", cpbuf_sz, strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (verbose)
|
||||
printf("Buffer addr: %p\n", buf);
|
||||
|
||||
while (1) {
|
||||
if (srcfd == -1) {
|
||||
srcfd = open(arg1, O_RDONLY);
|
||||
if (srcfd < 0) {
|
||||
printf("open(%s) failed: %s\n", arg1, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
readsz = read(srcfd, buf, cpbuf_sz);
|
||||
if (readsz < 0) {
|
||||
printf("read error: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
if (! readsz)
|
||||
break;
|
||||
|
||||
if (dstfd == -1) {
|
||||
dstfd = open(arg2, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
||||
if (dstfd < 0) {
|
||||
printf("open(%s) failed: %s\n", arg2, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
writesz = write(dstfd, buf, readsz);
|
||||
if (writesz < 0 || writesz != readsz) {
|
||||
printf("write error: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
if (readsz != cpbuf_sz)
|
||||
break;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
if (srcfd >= 0) close(srcfd);
|
||||
if (dstfd >= 0) close(dstfd);
|
||||
}
|
||||
|
||||
#ifdef __ATARI__
|
||||
static void cmd_cls(void)
|
||||
{
|
||||
printf("\f");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void cmd_verbose(void)
|
||||
{
|
||||
unsigned long verb;
|
||||
char *endptr;
|
||||
|
||||
if (!arg1 || arg2) {
|
||||
puts("usage: verbose <level>");
|
||||
return;
|
||||
}
|
||||
|
||||
verb = strtoul(arg1, &endptr, 10);
|
||||
if (verb > 255 || *endptr) {
|
||||
puts("invalid verbosity level");
|
||||
return;
|
||||
}
|
||||
|
||||
verbose = verb;
|
||||
printf("verbosity level set to %d\n", verbose);
|
||||
}
|
||||
|
||||
static void run_command(void)
|
||||
{
|
||||
switch (cmd) {
|
||||
default: puts("internal error"); return;
|
||||
case CMD_NOTHING: return;
|
||||
case CMD_INVALID: puts("invalid command"); return;
|
||||
case CMD_HELP: cmd_help(); return;
|
||||
case CMD_QUIT: terminate = 1; return;
|
||||
case CMD_LS: cmd_ls(); return;
|
||||
case CMD_RM: cmd_rm(); return;
|
||||
#ifdef HAVE_SUBDIRS
|
||||
case CMD_CHDIR: cmd_chdir(); return;
|
||||
case CMD_MKDIR: cmd_mkdir(); return;
|
||||
case CMD_RMDIR: cmd_rmdir(); return;
|
||||
case CMD_PWD: cmd_pwd(); return;
|
||||
#endif
|
||||
case CMD_EXEC: cmd_exec(); return;
|
||||
case CMD_RENAME: cmd_rename(); return;
|
||||
case CMD_COPY: cmd_copy(); return;
|
||||
#ifdef __ATARI__
|
||||
case CMD_CLS: cmd_cls(); return;
|
||||
#endif
|
||||
case CMD_VERBOSE: cmd_verbose(); return;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
banner();
|
||||
|
||||
while (! terminate) {
|
||||
get_command();
|
||||
run_command();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Local Variables: */
|
||||
/* c-file-style: "cpg" */
|
||||
/* c-basic-offset: 4 */
|
||||
/* End: */
|
||||
Reference in New Issue
Block a user