1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 12:28:06 +11:00

Merge remote-tracking branch 'origin/master' into forth

This commit is contained in:
Virgil Dupras 2020-04-07 19:32:30 -04:00
commit d4324292fb
6 changed files with 62 additions and 16 deletions

6
emul/.gitignore vendored
View File

@ -1,14 +1,8 @@
/shell/shell
/forth/stage1 /forth/stage1
/forth/stage1dbg /forth/stage1dbg
/forth/stage2 /forth/stage2
/forth/stage2dbg /forth/stage2dbg
/forth/forth /forth/forth
/zasm/zasm
/zasm/avra
/runbin/runbin /runbin/runbin
/*/*-bin.h /*/*-bin.h
/*/*.bin /*/*.bin
/cfsin/zasm
/cfsin/ed
/cfsin/user.h

View File

@ -1,4 +1,5 @@
TARGETS = runbin/runbin forth/forth TARGETS = runbin/runbin forth/forth
BIN2C = ../tools/bin2c
# Those Forth source files are in a particular order # Those Forth source files are in a particular order
FORTHSRCS = core.fs cmp.fs print.fs str.fs parse.fs readln.fs fmt.fs z80a.fs \ FORTHSRCS = core.fs cmp.fs print.fs str.fs parse.fs readln.fs fmt.fs z80a.fs \
link.fs link.fs
@ -12,6 +13,7 @@ all: $(TARGETS)
$(STRIPFC): $(STRIPFC):
$(SLATEST): $(SLATEST):
$(BIN2C):
$(MAKE) -C ../tools $(MAKE) -C ../tools
# z80c.bin and boot.bin are not in the prerequisites because they're bootstrap # z80c.bin and boot.bin are not in the prerequisites because they're bootstrap
@ -21,8 +23,8 @@ forth/forth0.bin: $(SLATEST)
$(SLATEST) $@ $(SLATEST) $@
cat forth/emul.fs >> $@ cat forth/emul.fs >> $@
forth/forth0-bin.h: forth/forth0.bin forth/forth0-bin.h: forth/forth0.bin $(BIN2C)
./bin2c.sh KERNEL < forth/forth0.bin | tee $@ > /dev/null $(BIN2C) KERNEL < forth/forth0.bin | tee $@ > /dev/null
forth/stage1: forth/stage.c $(OBJS) forth/forth0-bin.h forth/stage1: forth/stage.c $(OBJS) forth/forth0-bin.h
$(CC) forth/stage.c $(OBJS) -o $@ $(CC) forth/stage.c $(OBJS) -o $@
@ -39,8 +41,8 @@ forth/forth1.bin: forth/core.bin $(SLATEST)
cat forth/boot.bin forth/z80c.bin forth/core.bin > $@ cat forth/boot.bin forth/z80c.bin forth/core.bin > $@
$(SLATEST) $@ $(SLATEST) $@
forth/forth1-bin.h: forth/forth1.bin forth/forth1-bin.h: forth/forth1.bin $(BIN2C)
./bin2c.sh KERNEL < forth/forth1.bin | tee $@ > /dev/null $(BIN2C) KERNEL < forth/forth1.bin | tee $@ > /dev/null
forth/stage2: forth/stage.c $(OBJS) forth/forth1-bin.h forth/stage2: forth/stage.c $(OBJS) forth/forth1-bin.h
$(CC) -DSTAGE2 forth/stage.c $(OBJS) -o $@ $(CC) -DSTAGE2 forth/stage.c $(OBJS) -o $@
@ -67,3 +69,4 @@ updatebootstrap: forth/stage2
.PHONY: clean .PHONY: clean
clean: clean:
rm -f $(TARGETS) emul.o forth/*-bin.h forth/forth?.bin rm -f $(TARGETS) emul.o forth/*-bin.h forth/forth?.bin
$(MAKE) -C ../tools clean

View File

@ -1,5 +0,0 @@
#!/bin/sh
echo "unsigned char $1[] = { "
xxd -i -
echo " };"

1
tools/.gitignore vendored
View File

@ -6,3 +6,4 @@
/pingpong /pingpong
/slatest /slatest
/stripfc /stripfc
/bin2c

View File

@ -6,8 +6,10 @@ TTYSAFE_TGT = ttysafe
PINGPONG_TGT = pingpong PINGPONG_TGT = pingpong
SLATEST_TGT = slatest SLATEST_TGT = slatest
STRIPFC_TGT = stripfc STRIPFC_TGT = stripfc
BIN2C_TGT = bin2c
TARGETS = $(MEMDUMP_TGT) $(BLKDUMP_TGT) $(UPLOAD_TGT) $(FONTCOMPILE_TGT) \ TARGETS = $(MEMDUMP_TGT) $(BLKDUMP_TGT) $(UPLOAD_TGT) $(FONTCOMPILE_TGT) \
$(TTYSAFE_TGT) $(PINGPONG_TGT) $(SLATEST_TGT) $(STRIPFC_TGT) $(TTYSAFE_TGT) $(PINGPONG_TGT) $(SLATEST_TGT) $(STRIPFC_TGT) \
$(BIN2C_TGT)
OBJS = common.o OBJS = common.o
all: $(TARGETS) all: $(TARGETS)
@ -24,6 +26,7 @@ $(TTYSAFE_TGT): $(TTYSAFE_TGT).c
$(PINGPONG_TGT): $(PINGPONG_TGT).c $(PINGPONG_TGT): $(PINGPONG_TGT).c
$(SLATEST_TGT): $(SLATEST_TGT).c $(SLATEST_TGT): $(SLATEST_TGT).c
$(STRIPFC_TGT): $(STRIPFC_TGT).c $(STRIPFC_TGT): $(STRIPFC_TGT).c
$(BIN2C_TGT): $(BIN2C_TGT).c
$(TARGETS): $(OBJS) $(TARGETS): $(OBJS)
$(CC) $(CFLAGS) $@.c $(OBJS) -o $@ $(CC) $(CFLAGS) $@.c $(OBJS) -o $@

50
tools/bin2c.c Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2020 Byron Grobe
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define BUFSZ 32
static const char intro[] = "static const unsigned char %s[] = {\n ";
int main(int argc, char **argv) {
int n;
int col = 0;
uint8_t buf[BUFSZ];
if (argc < 2) {
fprintf(stderr, "Specify a name for the data structure...\n");
return 1;
}
printf(intro, argv[1]);
while(!feof(stdin)) {
n = fread(buf, 1, BUFSZ, stdin);
for(int i = 0; i < n; ++i) {
if (col+4 >= 76) {
printf("\n ");
col = 0;
}
printf("0x%.2x, ", buf[i]);
col += 6;
}
}
printf("};\n");
}