The start of the implementation of the init code for the babel fish translator.

This commit is contained in:
Jeremy Rand 2021-05-16 23:34:29 -04:00
parent b89ad278dc
commit fa4966261d
6 changed files with 206 additions and 19 deletions

View File

@ -45,8 +45,9 @@
9D406AC4264A2AD400747EE9 /* babelfish_defs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_defs.h; sourceTree = "<group>"; };
9D406ACB264A2B5800747EE9 /* babelfish_rez.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_rez.h; sourceTree = "<group>"; };
9D406ACD264A2BD300747EE9 /* markdown.rez */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.rez; path = markdown.rez; sourceTree = "<group>"; };
9D406AD8264C50E400747EE9 /* init.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = init.s; sourceTree = "<group>"; };
9D406AD8264C50E400747EE9 /* init.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.c; };
9D406AD9264C50F700747EE9 /* filter.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = filter.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
9D406B2D2652155B00747EE9 /* babelfish_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_types.h; sourceTree = "<group>"; };
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 = "<group>"; };
@ -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;

View File

@ -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

View File

@ -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_ */

View File

@ -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 <Types.h>
// 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_ */

84
md2teach/babelfish/init.c Normal file
View File

@ -0,0 +1,84 @@
/*
* init.c
* md2teach
*
* Created by Jeremy Rand on 2021-05-12.
* Copyright (c) 2021 Jeremy Rand. All rights reserved.
*
*/
#include <stdio.h>
#include <Locator.h>
#include <Memory.h>
#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

View File

@ -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