From fa4966261d5ab38b9827209b99617dd245fb26ba Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Sun, 16 May 2021 23:34:29 -0400 Subject: [PATCH] The start of the implementation of the init code for the babel fish translator. --- md2teach.xcodeproj/project.pbxproj | 6 +- md2teach/babelfish.mk | 2 +- md2teach/babelfish/babelfish_defs.h | 4 + md2teach/babelfish/babelfish_types.h | 113 +++++++++++++++++++++++++++ md2teach/babelfish/init.c | 84 ++++++++++++++++++++ md2teach/babelfish/init.s | 16 ---- 6 files changed, 206 insertions(+), 19 deletions(-) create mode 100644 md2teach/babelfish/babelfish_types.h create mode 100644 md2teach/babelfish/init.c delete mode 100644 md2teach/babelfish/init.s diff --git a/md2teach.xcodeproj/project.pbxproj b/md2teach.xcodeproj/project.pbxproj index 0cb2c21..1aa2055 100644 --- a/md2teach.xcodeproj/project.pbxproj +++ b/md2teach.xcodeproj/project.pbxproj @@ -45,8 +45,9 @@ 9D406AC4264A2AD400747EE9 /* babelfish_defs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_defs.h; sourceTree = ""; }; 9D406ACB264A2B5800747EE9 /* babelfish_rez.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_rez.h; sourceTree = ""; }; 9D406ACD264A2BD300747EE9 /* markdown.rez */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.rez; path = markdown.rez; sourceTree = ""; }; - 9D406AD8264C50E400747EE9 /* init.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = init.s; sourceTree = ""; }; + 9D406AD8264C50E400747EE9 /* init.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.c; }; 9D406AD9264C50F700747EE9 /* filter.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = filter.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; + 9D406B2D2652155B00747EE9 /* babelfish_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_types.h; sourceTree = ""; }; 9D6532E42626240800105D50 /* md2teach */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = md2teach; sourceTree = BUILT_PRODUCTS_DIR; }; 9D6532EA2626240800105D50 /* doNotBuild */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = doNotBuild; sourceTree = BUILT_PRODUCTS_DIR; }; 9D6532EC2626240800105D50 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; @@ -108,8 +109,9 @@ children = ( 9D406AC4264A2AD400747EE9 /* babelfish_defs.h */, 9D406ACB264A2B5800747EE9 /* babelfish_rez.h */, + 9D406B2D2652155B00747EE9 /* babelfish_types.h */, 9D406ACD264A2BD300747EE9 /* markdown.rez */, - 9D406AD8264C50E400747EE9 /* init.s */, + 9D406AD8264C50E400747EE9 /* init.c */, 9D406AD9264C50F700747EE9 /* filter.s */, ); path = babelfish; diff --git a/md2teach/babelfish.mk b/md2teach/babelfish.mk index 913b512..bf88885 100644 --- a/md2teach/babelfish.mk +++ b/md2teach/babelfish.mk @@ -185,7 +185,7 @@ $(OBJDIR)/babelfish/markdown.r: $(FILTERTARGET) $(INITTARGET) $(FILTERTARGET): $(OBJDIR)/babelfish/filter.ROOT cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/filter keep="$(abspath $@)" -$(INITTARGET): $(OBJDIR)/babelfish/init.ROOT +$(INITTARGET): $(OBJDIR)/babelfish/init.root $(OBJDIR)/md4c.a cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/init keep="$(abspath $@)" $(TARGETDIR)/Markdown: $(OBJDIR)/babelfish/markdown.r diff --git a/md2teach/babelfish/babelfish_defs.h b/md2teach/babelfish/babelfish_defs.h index 4137d7a..c06c9df 100644 --- a/md2teach/babelfish/babelfish_defs.h +++ b/md2teach/babelfish/babelfish_defs.h @@ -42,4 +42,8 @@ #define TrFormatFont 0x0005 #define TrFormatSound 0x0006 +#define TrStartUp 0x9101 +#define TrShutDown 0x9102 +#define TrRead 0x9103 + #endif /* define _GUARD_PROJECTmd2teach_FILEbabelfish_defs_ */ diff --git a/md2teach/babelfish/babelfish_types.h b/md2teach/babelfish/babelfish_types.h new file mode 100644 index 0000000..2559153 --- /dev/null +++ b/md2teach/babelfish/babelfish_types.h @@ -0,0 +1,113 @@ +/* + * babelfish_types.h + * md2teach + * + * Created by Jeremy Rand on 2021-05-16. + * + */ + +#ifndef _GUARD_PROJECTmd2teach_FILEbabelfish_types_ +#define _GUARD_PROJECTmd2teach_FILEbabelfish_types_ + +#include + + +// The actual data record varies based on the file format. +typedef struct TrDataRecord +{ + Word parmCount; +} TrDataRecord; + + +typedef struct TrTextDataRecord +{ + Word parmCount; + Word actionCode; + Word responseCode; + Long textStreamLength; + char * textStreamPtr; + Handle textStreamHandle; + Word familyId; + Word fontSize; + Word fontStyle; + Word foreColor; + Word backColor; + Word position; + Word charSpacing; + Word lineSpacing; + Word spaceBefore; + Word spaceAfter; + Word firstIndent; + Word leftIndent; + Word rightIndent; + Word justification; + unsigned char tabArray[64]; + Word options; + Long border; + Word pageLength; + Word pageWidth; + Rect sectionRect; + Word columns; + Word gutter; + Handle picHandle; +} TrTextDataRecord; + + +typedef struct TrTransferRecord +{ + Word parmCount; + Word status; + Word miscFlags; + unsigned char dataKinds[8]; + Word transNum; + Word userId; + Word progressAction; + Word fullTherm; + Word currentTherm; + char * msgPtr; + TrDataRecord * dataRecordPtr; + char * filePathPtr; /* C string*/ + char * fileNamePtr; /* P string */ +} TrTransferRecord; + + +typedef struct TrStartUpDataIn +{ + TrTransferRecord * xferRecPtr; +} TrStartUpDataIn; + + +typedef struct TrStartUpDataOut +{ + Word recvCount; + Word trResult; +} TrStartUpDataOut; + + +typedef struct TrShutDownDataIn +{ + TrTransferRecord * xferRecPtr; +} TrShutDownDataIn; + + +typedef struct TrShutDownDataOut +{ + Word recvCount; + Word trResult; +} TrShutDownDataOut; + + +typedef struct TrReadDataIn +{ + TrTransferRecord * xferRecPtr; +} TrReadDataIn; + + +typedef struct TrReadDataOut +{ + Word recvCount; + Word trResult; +} TrReadDataOut; + + +#endif /* define _GUARD_PROJECTmd2teach_FILEbabelfish_types_ */ diff --git a/md2teach/babelfish/init.c b/md2teach/babelfish/init.c new file mode 100644 index 0000000..8fbf23f --- /dev/null +++ b/md2teach/babelfish/init.c @@ -0,0 +1,84 @@ +/* + * init.c + * md2teach + * + * Created by Jeremy Rand on 2021-05-12. + * Copyright (c) 2021 Jeremy Rand. All rights reserved. + * + */ + +#include + +#include +#include + +#include "babelfish/babelfish_defs.h" +#include "babelfish/babelfish_types.h" +#include "md4c.h" + + +#pragma memorymodel 1 +#pragma rtl + + +uint16_t myUserId; + + +void DoStartUp(TrStartUpDataIn * dataIn, TrStartUpDataOut * dataOut) +{ + +} + + +void DoShutDown(TrShutDownDataIn * dataIn, TrShutDownDataOut * dataOut) +{ + +} + + +void DoRead(TrReadDataIn * dataIn, TrReadDataOut * dataOut) +{ + +} + + +#pragma databank 1 +#pragma toolparms 1 + +pascal unsigned MyRequestProc(uint16_t request, uint32_t dataIn, uint32_t dataOut) +{ + switch (request) { + case TrStartUp: + DoStartUp((TrStartUpDataIn *)dataIn, (TrStartUpDataOut *)dataOut); + break; + + case TrShutDown: + DoShutDown((TrShutDownDataIn *)dataIn, (TrShutDownDataOut *)dataOut); + break; + + case TrRead: + DoRead((TrReadDataIn *)dataIn, (TrReadDataOut *)dataOut); + break; + + default: + break; + } + + return 0; +} + +#pragma toolparms 0 + + +int main(void) +{ + static char myName[48]; + + myUserId = MMStartUp(); + sprintf(myName, "Babelfish~Jeremy~MarkdownTrans%04x", myUserId); + AcceptRequests(myName, myUserId, MyRequestProc); + + return 0; +} + +#pragma databank 0 diff --git a/md2teach/babelfish/init.s b/md2teach/babelfish/init.s deleted file mode 100644 index b07bd34..0000000 --- a/md2teach/babelfish/init.s +++ /dev/null @@ -1,16 +0,0 @@ -; -; init.s -; md2teach -; -; Created by Jeremy Rand on 2021-05-12. -; -; - - mcopy init.macros - keep init - -init start - phb - plb - rtl - end