mirror of
https://github.com/jeremysrand/md2teach.git
synced 2024-08-31 19:29:17 +00:00
Improve the pure text output of the converter. It now handles numbered and unnumbered lists. It adds a horizontal line for HR. Spacing is better between blocks. It no longer inserts a leading blank line at the top of the document.
I have extended the execution rule to put the resulting text file onto a disk image and launch an emulator so I can see the text file on the target machine. This should make iteration easier. Even though I am asking to print carriage returns in the output, I am getting line feeds. Now sure what is doing the translation. It could be the ORCA standard library (not likely) or Golden Gate (maybe). I should next change to direct use of GS/OS for the writes and avoid the ORCA library anyway.
This commit is contained in:
parent
04233b2621
commit
effa777037
@ -52,6 +52,12 @@
|
||||
9DDFC7B026269D23006D6E71 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
9DDFC7B126269D3F006D6E71 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
9DDFC7B42627E081006D6E71 /* test.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = test.md; sourceTree = "<group>"; };
|
||||
9DDFC7C1262FD50C006D6E71 /* system601.2mg */ = {isa = PBXFileReference; lastKnownFileType = file; path = system601.2mg; sourceTree = "<group>"; };
|
||||
9DDFC7C2262FD50C006D6E71 /* launchEmulator */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = launchEmulator; sourceTree = "<group>"; };
|
||||
9DDFC7C3262FD50C006D6E71 /* empty.2mg */ = {isa = PBXFileReference; lastKnownFileType = file; path = empty.2mg; sourceTree = "<group>"; };
|
||||
9DDFC7C4262FD50C006D6E71 /* createDiskImage */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = createDiskImage; sourceTree = "<group>"; };
|
||||
9DDFC7C5262FD50D006D6E71 /* config.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = config.txt; sourceTree = "<group>"; };
|
||||
9DDFC7CA262FD7DD006D6E71 /* tar */ = {isa = PBXFileReference; lastKnownFileType = file; path = tar; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -91,9 +97,9 @@
|
||||
9D65330C2626246700105D50 /* md4c.c */,
|
||||
9D65330B2626246700105D50 /* md4c.h */,
|
||||
9D6532EE2626240800105D50 /* Makefile */,
|
||||
9DDFC7B42627E081006D6E71 /* test.md */,
|
||||
9D6532F02626240800105D50 /* make */,
|
||||
9D6532FB2626240800105D50 /* Supporting Files */,
|
||||
9DDFC7B42627E081006D6E71 /* test.md */,
|
||||
);
|
||||
path = md2teach;
|
||||
sourceTree = "<group>";
|
||||
@ -106,6 +112,12 @@
|
||||
9D6532F52626240800105D50 /* orca-cc */,
|
||||
9D6532F72626240800105D50 /* orca-rez */,
|
||||
9D6532F92626240800105D50 /* tail.mk */,
|
||||
9DDFC7C5262FD50D006D6E71 /* config.txt */,
|
||||
9DDFC7C4262FD50C006D6E71 /* createDiskImage */,
|
||||
9DDFC7C3262FD50C006D6E71 /* empty.2mg */,
|
||||
9DDFC7C2262FD50C006D6E71 /* launchEmulator */,
|
||||
9DDFC7C1262FD50C006D6E71 /* system601.2mg */,
|
||||
9DDFC7CA262FD7DD006D6E71 /* tar */,
|
||||
);
|
||||
path = make;
|
||||
sourceTree = "<group>";
|
||||
|
@ -36,13 +36,14 @@
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
customWorkingDirectory = "$PROJECT_DIR/md2teach"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<PathRunnable
|
||||
runnableDebuggingMode = "0"
|
||||
FilePath = "/usr/local/bin/orca">
|
||||
FilePath = "/usr/bin/make">
|
||||
</PathRunnable>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
@ -55,24 +56,28 @@
|
||||
</MacroExpansion>
|
||||
<CommandLineArguments>
|
||||
<CommandLineArgument
|
||||
argument = "$TARGET_BUILD_DIR/md2teach"
|
||||
argument = "-C"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "-d"
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "$PROJECT_DIR/md2teach/test.md"
|
||||
argument = "$PROJECT_DIR/md2teach"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "$TARGET_BUILD_DIR/outfile.txt"
|
||||
argument = "TARGET_BUILD_DIR=$TARGET_BUILD_DIR"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "blah"
|
||||
isEnabled = "NO">
|
||||
argument = "DERIVED_SOURCES_DIR=$DERIVED_SOURCES_DIR"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "OBJECT_FILE_DIR=$OBJECT_FILE_DIR"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "execute"
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
</CommandLineArguments>
|
||||
</LaunchAction>
|
||||
|
137
md2teach/main.c
137
md2teach/main.c
@ -32,6 +32,21 @@
|
||||
// Leaving the stack very big for now at 32K.
|
||||
#pragma stacksize 32768
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef struct tBlockListItem
|
||||
{
|
||||
MD_BLOCKTYPE type;
|
||||
union {
|
||||
MD_BLOCK_UL_DETAIL ulDetail;
|
||||
MD_BLOCK_OL_DETAIL olDetail;
|
||||
MD_BLOCK_H_DETAIL hDetail;
|
||||
MD_BLOCK_CODE_DETAIL codeDetail;
|
||||
} u;
|
||||
int numTabs;
|
||||
|
||||
struct tBlockListItem * next;
|
||||
} tBlockListItem;
|
||||
|
||||
// Forward declarations
|
||||
|
||||
@ -61,6 +76,9 @@ void * lowestStackSeen;
|
||||
char * commandName;
|
||||
int debugIndentLevel = 0;
|
||||
int debugEnabled = 0;
|
||||
int isFirstNonDocumentBlock = 1;
|
||||
|
||||
tBlockListItem * blockList = NULL;
|
||||
|
||||
FILE * outputFile;
|
||||
|
||||
@ -69,6 +87,21 @@ FILE * outputFile;
|
||||
|
||||
static int enterBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
{
|
||||
tBlockListItem * newBlock = malloc(sizeof(tBlockListItem));
|
||||
|
||||
if (newBlock == NULL) {
|
||||
fprintf(stderr, "%s: Out of memory", commandName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
newBlock->type = type;
|
||||
if (blockList == NULL)
|
||||
newBlock->numTabs = 0;
|
||||
else
|
||||
newBlock->numTabs = blockList->numTabs;
|
||||
newBlock->next = blockList;
|
||||
blockList = newBlock;
|
||||
|
||||
if ((detail != NULL) &&
|
||||
(detail < lowestStackSeen))
|
||||
lowestStackSeen = detail;
|
||||
@ -82,13 +115,19 @@ static int enterBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
case MD_BLOCK_QUOTE:
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sQUOTE {\n", debugIndentLevel, "");
|
||||
fprintf(outputFile, "\r");
|
||||
|
||||
break;
|
||||
|
||||
case MD_BLOCK_UL: {
|
||||
MD_BLOCK_UL_DETAIL * ulDetail = (MD_BLOCK_UL_DETAIL *)detail;
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sUL (is_tight=%d, mark=%c) {\n", debugIndentLevel, "", ulDetail->is_tight, ulDetail->mark);
|
||||
|
||||
memcpy(&(newBlock->u.ulDetail), ulDetail, sizeof(*ulDetail));
|
||||
newBlock->numTabs++;
|
||||
|
||||
if (!isFirstNonDocumentBlock)
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -96,24 +135,75 @@ static int enterBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
MD_BLOCK_OL_DETAIL * olDetail = (MD_BLOCK_OL_DETAIL *)detail;
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sOL (start=%u, is_tight=%d, mark_delimiter=%c) {\n", debugIndentLevel, "", olDetail->start, olDetail->is_tight, olDetail->mark_delimiter);
|
||||
|
||||
memcpy(&(newBlock->u.olDetail), olDetail, sizeof(*olDetail));
|
||||
newBlock->numTabs++;
|
||||
|
||||
if (!isFirstNonDocumentBlock)
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
}
|
||||
|
||||
case MD_BLOCK_LI:
|
||||
case MD_BLOCK_LI: {
|
||||
int i;
|
||||
tBlockListItem * enclosingBlock = newBlock->next;
|
||||
int isNumbered = 0;
|
||||
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sLI {\n", debugIndentLevel, "");
|
||||
break;
|
||||
|
||||
case MD_BLOCK_HR:
|
||||
if (enclosingBlock == NULL) {
|
||||
fprintf(stderr, "%s: Got a list item block without an enclosing block\n", commandName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (enclosingBlock->type == MD_BLOCK_OL) {
|
||||
isNumbered = 1;
|
||||
if ((!enclosingBlock->u.olDetail.is_tight) &&
|
||||
(!isFirstNonDocumentBlock))
|
||||
fputc('\r', outputFile);
|
||||
} else if (enclosingBlock->type == MD_BLOCK_UL) {
|
||||
if ((!enclosingBlock->u.ulDetail.is_tight) &&
|
||||
(!isFirstNonDocumentBlock))
|
||||
fputc('\r', outputFile);
|
||||
}
|
||||
|
||||
for (i = 0; i < newBlock->numTabs; i++)
|
||||
fputc('\t', outputFile);
|
||||
|
||||
if (isNumbered) {
|
||||
fprintf(outputFile, "%u%c ", enclosingBlock->u.olDetail.start, enclosingBlock->u.olDetail.mark_delimiter);
|
||||
enclosingBlock->u.olDetail.start++;
|
||||
} else {
|
||||
fprintf(outputFile, "%c ", 0xd7); // 0xd7 is a diamond looking character which is good for a bullet
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MD_BLOCK_HR: {
|
||||
int i;
|
||||
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sHR {\n", debugIndentLevel, "");
|
||||
fprintf(outputFile, "\r");
|
||||
|
||||
if (!isFirstNonDocumentBlock)
|
||||
fputc('\r', outputFile);
|
||||
|
||||
for (i = 0; i < 30; i++)
|
||||
fputc('_', outputFile); // 0xd1 is a horizontal line
|
||||
break;
|
||||
}
|
||||
|
||||
case MD_BLOCK_H: {
|
||||
MD_BLOCK_H_DETAIL * hDetail = (MD_BLOCK_H_DETAIL *)detail;
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sH (level=%u) {\n", debugIndentLevel, "", hDetail->level);
|
||||
|
||||
memcpy(&(newBlock->u.hDetail), hDetail, sizeof(*hDetail));
|
||||
|
||||
if (!isFirstNonDocumentBlock)
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -127,14 +217,19 @@ static int enterBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
fprintf(stderr, "{\n");
|
||||
}
|
||||
|
||||
fprintf(outputFile, "\r");
|
||||
memcpy(&(newBlock->u.codeDetail), codeDetail, sizeof(*codeDetail));
|
||||
|
||||
if (!isFirstNonDocumentBlock)
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
}
|
||||
|
||||
case MD_BLOCK_P:
|
||||
if (debugEnabled)
|
||||
fprintf(stderr, "%*sP {\n", debugIndentLevel, "");
|
||||
fprintf(outputFile, "\r");
|
||||
|
||||
if (!isFirstNonDocumentBlock)
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -143,6 +238,10 @@ static int enterBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (type != MD_BLOCK_DOC)
|
||||
isFirstNonDocumentBlock = 0;
|
||||
|
||||
debugIndentLevel+=2;
|
||||
return 0;
|
||||
}
|
||||
@ -150,6 +249,21 @@ static int enterBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
|
||||
static int leaveBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
{
|
||||
tBlockListItem * oldBlock = blockList;
|
||||
|
||||
if (oldBlock == NULL) {
|
||||
fprintf(stderr, "%s: Block list is empty but leaving block of type %d\n", commandName, (int)type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (oldBlock->type != type) {
|
||||
fprintf(stderr, "%s: Expected to leave block of type %d but got type %d\n", commandName, (int)oldBlock->type, (int)type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
blockList = oldBlock->next;
|
||||
free(oldBlock);
|
||||
|
||||
if ((detail != NULL) &&
|
||||
(detail < lowestStackSeen))
|
||||
lowestStackSeen = detail;
|
||||
@ -162,26 +276,31 @@ static int leaveBlockHook(MD_BLOCKTYPE type, void * detail, void * userdata)
|
||||
break;
|
||||
|
||||
case MD_BLOCK_UL:
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
case MD_BLOCK_OL:
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
case MD_BLOCK_LI:
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
case MD_BLOCK_HR:
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
case MD_BLOCK_H:
|
||||
fprintf(outputFile, "\r");
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
case MD_BLOCK_CODE:
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
case MD_BLOCK_P:
|
||||
fprintf(outputFile, "\r");
|
||||
fputc('\r', outputFile);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
47
md2teach/make/config.txt
Normal file
47
md2teach/make/config.txt
Normal file
@ -0,0 +1,47 @@
|
||||
# GSport configuration file version 0.31
|
||||
|
||||
s5d1 =
|
||||
s5d2 =
|
||||
|
||||
s6d1 =
|
||||
s6d2 =
|
||||
|
||||
s7d1 =
|
||||
|
||||
g_joystick_type = 0
|
||||
g_limit_speed = 0
|
||||
|
||||
|
||||
bram1[00] = 00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00
|
||||
bram1[10] = 00 00 07 06 02 01 01 00 00 00 0f 06 06 00 05 06
|
||||
bram1[20] = 01 00 00 00 00 00 00 01 00 00 00 00 03 02 02 02
|
||||
bram1[30] = 00 00 00 00 00 00 00 00 08 00 01 02 03 04 05 06
|
||||
bram1[40] = 07 0a 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
|
||||
bram1[50] = 0e 0f ff ff ff ff ff ff ff 00 ff ff ff ff ff 81
|
||||
bram1[60] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[70] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[80] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[90] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[a0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[b0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[c0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[d0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[e0] = ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
||||
bram1[f0] = ff ff ff ff ff ff ff ff ff ff ff ff 52 06 f8 ac
|
||||
|
||||
bram3[00] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[10] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[20] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[30] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[40] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[50] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[60] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[70] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[80] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[90] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[a0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[b0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[c0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[d0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[e0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
bram3[f0] = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
248
md2teach/make/createDiskImage
Executable file
248
md2teach/make/createDiskImage
Executable file
@ -0,0 +1,248 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -
|
||||
if [ $# -lt 3 ]
|
||||
then
|
||||
echo USAGE: $0 diskimage bootimage file [bootdest]
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DISKIMAGE="$1"
|
||||
shift
|
||||
|
||||
DESTBOOTIMAGE="$1"
|
||||
shift
|
||||
|
||||
FILE="$1"
|
||||
shift
|
||||
|
||||
BOOTCOPYPATH="$1"
|
||||
|
||||
PROGRAM=`basename "$FILE"`
|
||||
TMPDIR=/tmp/a2gs_mount.$$
|
||||
MOUNTDIR="${TMPDIR}/$PROGRAM"
|
||||
TMPDISKIMAGE=/tmp/a2gs_diskimage_$$.2mg
|
||||
TMPBOOTIMAGE=/tmp/a2gs_bootimage_$$.2mg
|
||||
TMPARCHIVE=/tmp/s2gs_archive_$$.shk
|
||||
TEMPLATEDISKIMAGE="make/empty.2mg"
|
||||
TEMPLATEBOOTIMAGE="make/$BOOTIMAGE"
|
||||
ARCHIVE=`dirname "$DISKIMAGE"`/"${PROGRAM}.shk"
|
||||
|
||||
# It looks like on Linux, the cp command needs a special argument to preserve the resource fork. This isn't ideal
|
||||
# but for now, if uname is Darwin, then this is MacOS and we don't need any cp args. If not Darwin, then assume
|
||||
# this is Linux and ask for extended attributes to be preserved through the copy.
|
||||
#
|
||||
# Ultimately, it could be that other platforms (BSD, does Solaris still exist?) or even other Linux versions or
|
||||
# distributions need different arguments for this rather special thing. If true, this may need to be a build time
|
||||
# option which can be set.
|
||||
if [ "`uname`" = Darwin ]
|
||||
then
|
||||
CPARGS=""
|
||||
else
|
||||
CPARGS="--preserve=xattr"
|
||||
fi
|
||||
|
||||
cleanupAndExit()
|
||||
{
|
||||
umount "$MOUNTDIR" 2> /dev/null
|
||||
rm -f "$TMPDISKIMAGE" 2> /dev/null
|
||||
rm -f "$TMPBOOTIMAGE" 2> /dev/null
|
||||
rm -f "$TMPARCHIVE" 2> /dev/null
|
||||
rm -f "$DISKIMAGE" 2> /dev/null
|
||||
rm -f "$DESTBOOTIMAGE" 2> /dev/null
|
||||
rm -rf "$TMPDIR" 2> /dev/null
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -f "$TEMPLATEDISKIMAGE" ]
|
||||
then
|
||||
echo Unable to find the template disk image, $TEMPLATEDISKIMAGE
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
if [ ! -f "$TEMPLATEBOOTIMAGE" ]
|
||||
then
|
||||
echo Unable to find the template boot image, $TEMPLATEBOOTIMAGE
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
mkdir "$TMPDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to create the mount directory.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
mkdir "$MOUNTDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to create the mount directory.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
cp "$TEMPLATEBOOTIMAGE" "$TMPBOOTIMAGE"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy template boot image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
if [ ! -z "$COPYBOOTDIRS" ] || [ ! -z "BOOTCOPYPATH" ]
|
||||
then
|
||||
/usr/local/bin/profuse -orw "$TMPBOOTIMAGE" "$MOUNTDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to mount the boot image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
if [ ! -z "$BOOTCOPYPATH" ]
|
||||
then
|
||||
cp $CPARGS "$FILE" "$MOUNTDIR/$BOOTCOPYPATH"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy the file to the boot image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
fi
|
||||
|
||||
OLDDIR=`pwd`
|
||||
for COPYDIR in $COPYBOOTDIRS
|
||||
do
|
||||
cd "$COPYDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to find $COPYDIR
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
find . -print | while read FILEORDIR
|
||||
do
|
||||
if [ -d "$FILEORDIR" ]
|
||||
then
|
||||
mkdir -p "${MOUNTDIR}/$FILEORDIR"
|
||||
elif [ -f "$FILEORDIR" ]
|
||||
then
|
||||
cp $CPARGS "$FILEORDIR" "${MOUNTDIR}/$FILEORDIR"
|
||||
fi
|
||||
done
|
||||
cd "$OLDDIR"
|
||||
done
|
||||
|
||||
RETRIES=0
|
||||
while [ $RETRIES -lt 5 ]
|
||||
do
|
||||
umount "$MOUNTDIR"
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
RETRIES=`expr $RETRIES + 1`
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ $RETRIES -ge 5 ]
|
||||
then
|
||||
echo Unable to unmount the boot image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
fi
|
||||
|
||||
cp "$TEMPLATEDISKIMAGE" "$TMPDISKIMAGE"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy template disk image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
/usr/local/bin/profuse -orw "$TMPDISKIMAGE" "$MOUNTDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to mount the disk image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
cp $CPARGS "$FILE" "$MOUNTDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy the file to the disk image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
OLDDIR=`pwd`
|
||||
for COPYDIR in $COPYDIRS
|
||||
do
|
||||
cd "$COPYDIR"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to find $COPYDIR
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
find . -print | while read FILEORDIR
|
||||
do
|
||||
if [ -d "$FILEORDIR" ]
|
||||
then
|
||||
mkdir -p "${MOUNTDIR}/$FILEORDIR"
|
||||
elif [ -f "$FILEORDIR" ]
|
||||
then
|
||||
cp $CPARGS "$FILEORDIR" "${MOUNTDIR}/$FILEORDIR"
|
||||
fi
|
||||
done
|
||||
cd "$OLDDIR"
|
||||
done
|
||||
|
||||
cd "$TMPDIR"
|
||||
$ORCA "$OLDDIR/make/tar" cf "$TMPARCHIVE" "$PROGRAM"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to create archive.
|
||||
cleanupAndExit
|
||||
fi
|
||||
cd "$OLDDIR"
|
||||
|
||||
RETRIES=0
|
||||
while [ $RETRIES -lt 5 ]
|
||||
do
|
||||
umount "$MOUNTDIR"
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
RETRIES=`expr $RETRIES + 1`
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ $RETRIES -ge 5 ]
|
||||
then
|
||||
echo Unable to unmount the disk image.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
cp "$TMPDISKIMAGE" "$DISKIMAGE"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy the disk image to the destination.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
cp "$TMPBOOTIMAGE" "$DESTBOOTIMAGE"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy the boot image to the destination.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
cp "$TMPARCHIVE" "$ARCHIVE"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo Unable to copy the archive to the destination.
|
||||
cleanupAndExit
|
||||
fi
|
||||
|
||||
rm -f "$TMPDISKIMAGE"
|
||||
rm -f "$TMPBOOTIMAGE"
|
||||
rm -f "$TMPARCHIVE"
|
||||
rm -rf "$TMPDIR"
|
||||
exit 0
|
BIN
md2teach/make/empty.2mg
Normal file
BIN
md2teach/make/empty.2mg
Normal file
Binary file not shown.
84
md2teach/make/launchEmulator
Executable file
84
md2teach/make/launchEmulator
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
TMPDIR="/tmp/a2gs_emulator.$$"
|
||||
|
||||
cleanupAndExit()
|
||||
{
|
||||
cd
|
||||
if [ ! -z $PID ]
|
||||
then
|
||||
kill $PID 2> /dev/null
|
||||
fi
|
||||
rm -rf $TMPDIR
|
||||
exit 0
|
||||
}
|
||||
|
||||
createConfigTxt()
|
||||
{
|
||||
mkdir "$TMPDIR"
|
||||
sed "s:^s7d1 *=.*$:s7d1 = $BOOTIMAGE:
|
||||
s:^s5d1 *=.*:s5d1 = $DISKIMAGE:" < make/config.txt > "$TMPDIR/config.txt"
|
||||
|
||||
}
|
||||
|
||||
if [ $# -ne 2 ]
|
||||
then
|
||||
echo USAGE $0: diskimage bootimage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DISKIMAGE="$1"
|
||||
if echo $DISKIMAGE | grep -v '^/' > /dev/null
|
||||
then
|
||||
DISKIMAGE="$PWD/$DISKIMAGE"
|
||||
fi
|
||||
|
||||
BOOTIMAGE="$2"
|
||||
if echo $BOOTIMAGE | grep -v '^/' > /dev/null
|
||||
then
|
||||
BOOTIMAGE="$PWD/$BOOTIMAGE"
|
||||
fi
|
||||
|
||||
case "$EMULATOR" in
|
||||
gsplus)
|
||||
EMULATORPATH="$GSPLUS"
|
||||
EMULATORARGS="$GSPLUSARGS"
|
||||
EMULATORDIR="$TMPDIR"
|
||||
createConfigTxt
|
||||
;;
|
||||
gsport)
|
||||
EMULATORPATH="$GSPORT"
|
||||
EMULATORARGS="$GSPORTARGS"
|
||||
EMULATORDIR="$TMPDIR"
|
||||
createConfigTxt
|
||||
;;
|
||||
mame)
|
||||
EMULATORPATH="$MAME"
|
||||
EMULATORARGS="$MAMEARGS -hard1 "$BOOTIMAGE" -flop3 "$DISKIMAGE""
|
||||
EMULATORDIR="$MAMELIB"
|
||||
;;
|
||||
*)
|
||||
echo Invalid emulator specified, \"$EMULATOR\"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -x "$EMULATORPATH" ]
|
||||
then
|
||||
echo Unable to find $EMULATOR at $EMULATORPATH
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$EMULATORDIR" ]
|
||||
then
|
||||
echo Unable to find $EMULATOR library at $EMULATORDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$EMULATORDIR"
|
||||
# This magic ensure that clicking stop in Xcode results in the emulator terminating.
|
||||
"$EMULATORPATH" $EMULATORARGS &
|
||||
PID=$!
|
||||
|
||||
trap cleanupAndExit SIGTERM SIGINT SIGHUP EXIT
|
||||
wait
|
BIN
md2teach/make/system601.2mg
Normal file
BIN
md2teach/make/system601.2mg
Normal file
Binary file not shown.
@ -191,7 +191,9 @@ executeGUI: all
|
||||
make/launchEmulator "$(DISKIMAGE)" "$(DESTBOOTIMAGE)"
|
||||
|
||||
executeShell: all
|
||||
$(ORCA) $(TARGETDIR)/$(PGM)
|
||||
$(ORCA) $(TARGETDIR)/$(PGM) -d test.md $(TARGETDIR)/outfile.txt
|
||||
make/createDiskImage "$(DISKIMAGE)" $(DESTBOOTIMAGE) "$(TARGETDIR)/outfile.txt"
|
||||
make/launchEmulator "$(DISKIMAGE)" "$(DESTBOOTIMAGE)"
|
||||
|
||||
$(OBJDIR)/%.a: %.c
|
||||
$(COMPILE) $< $(@:.a=) $(CFLAGS) --noroot
|
||||
|
BIN
md2teach/make/tar
Normal file
BIN
md2teach/make/tar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user