Add some code to filter files to those which match "*.md". This code is untested as yet but it compiles so that is something. I suspect I may have maybe messed up the stack but I will test it when I get closer to something that I can install.

This commit is contained in:
Jeremy Rand 2021-05-12 23:56:05 -04:00
parent 9e8e470ed9
commit 1572698a42
5 changed files with 134 additions and 3 deletions

View File

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

View File

@ -175,7 +175,10 @@ gen:
# clean your build.
genclean:
target:
$(TARGETDIR)/filter.bin: $(OBJDIR)/babelfish/filter.ROOT
cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/filter keep="$(abspath $@)"
target: $(TARGETDIR)/filter.bin
true
# Do not change anything else below here...

110
md2teach/babelfish/filter.s Normal file
View File

@ -0,0 +1,110 @@
;
; filter.s
; md2teach
;
; Created by Jeremy Rand on 2021-05-12.
; Based on bfish_asoft by Kelvin Sherlock.
;
mcopy filter.macros
keep filter
offset_fileName gequ 10
; SFFilter
;
; in stack:
;
; (3) |rtl
; |----
; (4) |DirEntryRecPtr
; |----
; (2) |returnval
; |----
; |.........
; out stack:
;
; |returnval
; |----
; |.........
;
; Returns 0 if it's not an markdown file, or 4 if it is.
;
filter start
_d equ 1
ptr equ 5
_rtlb equ 7
DirPtr equ 11
retval equ 15
phb ;even up the stack
phd
pha
pha
tsc
tcd
stz <retval ;; assume no
ldy #offset_fileName
lda [<DirPtr],y
sta <ptr
iny
iny
lda [<DirPtr],y
sta <ptr+2
lda [<ptr]
cmp #4
blt exit
tay
short m
dey
lda [<ptr],y
cmp #'d'
beq checkM
cmp #'D'
bne noMatch
checkM anop
dey
lda [<ptr],y
cmp #'m'
beq checkDot
cmp #'M'
bne noMatch
checkDot anop
dey
lda [<ptr],y
cmp #'m'
bne noMatch
long m
lda #4
sta <retval ;; I handle it
bra exit
noMatch anop
long m
exit anop
pla
pla
pld
pla
sta 3,s
pla
sta 3,s
plb
rtl
end

14
md2teach/babelfish/init.s Normal file
View File

@ -0,0 +1,14 @@
;
; init.s
; md2teach
;
; Created by Jeremy Rand on 2021-05-12.
;
;
mcopy init.macros
keep init
init start
rtl
end

View File

@ -43,8 +43,8 @@ resource rTrData(TrData)
};
read rCodeResource(TrFilter, locked, convert) "filter_code";
read rCodeResource(TrInit, locked, convert) "init_code";
read rCodeResource(TrFilter, locked, convert) "filter.bin";
read rCodeResource(TrInit, locked, convert) "init.bin";
resource rText(TrImportInfo)