From c8a5d137623a4e8c884fa73f1e15aa070f13c5d3 Mon Sep 17 00:00:00 2001 From: Tijn Kersjes Date: Sun, 20 Mar 2022 14:27:21 +0100 Subject: [PATCH] Add fs extension to entrypoint --- Dockerfile | 1 + gbforth | 108 +---------------------------------------------------- gbforth.fs | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 107 deletions(-) create mode 100644 gbforth.fs diff --git a/Dockerfile b/Dockerfile index 87a97ab0..c5ee739a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM oldmankris/alpine-gforth COPY gbforth /app/gbforth +COPY gbforth.fs /app/gbforth.fs COPY src /app/src COPY lib /app/lib COPY shared /app/shared diff --git a/gbforth b/gbforth index d882c010..368227ac 100755 --- a/gbforth +++ b/gbforth @@ -1,108 +1,2 @@ #! /usr/bin/env gforth -\ -*- forth -*- - -require ./src/vocabulary.fs - -also gbforth definitions -also gbforth - -require ./src/cli.fs -require ./src/rom.fs -require ./src/sym.fs -require ./src/asm.fs -require ./src/cartridge.fs -require ./src/runtime.fs -require ./src/compiler/cross.fs - -also gb-assembler-impl -' romc, IS emit -' rom-offset IS offset -' romc! IS emit-to -previous - -output-file to-symbol-file set-sym-file -s" ; Generated by gbforth " sym-write sym-cr sym-cr - -: also-path-if-set ( addr u -- ) - dup 0 > if - fpath also-path - else - 2drop - then ; - -fpath clear-path -gbforth-path also-path-if-set -fpath path+ . -fpath path+ ~+ - -require ./src/user.fs - -( We want to load the input file sealed in the GBFORTH-USER -( vocabulary. The problem is that we do not want to populate this - vocabulary with auxiliary words to load the input-file. - - Instead, we put all the words in this colon-definition to resolve - the word into addresses before we seal and load the game. -) - -: assert-empty-stack - depth 0<> abort" Stack is not empty" ; - -: assert-memory-fits - rom-unused 0< abort" ROM is full" - ram-unused 0< abort" WRAM is full" ; - -: write-game - fix-header-complement - fix-global-checksum - output-file dump-rom ; - -: %. swap 100 * swap / 1 .r ; - -:noname - assert-empty-stack - - gbforth-user definitions - seal also - - --no-kernel invert if - s" ./lib/core.fs" required - then - - --no-header invert if - ROM - s" ./lib/header.fs" included - RAM - then - - input-file included - - --no-kernel invert if - s" ./src/prelude.fs" included - then - - assert-empty-stack - assert-memory-fits - write-game - - --verbose if - CR CR - ." \ " rom-offset 5 .r ." bytes written to " output-file type CR - ." \ " rom-unused 5 .r ." bytes left, used " - rom-here rom-size %. ." % of ROM" CR CR - - ." \ " ram-here DP0 - 5 .r ." bytes allotted in memory" CR - ." \ " ram-unused 5 .r ." bytes left, used " - ram-here DP0 - ram-size %. ." % of WRAM" CR - then - - --debug if - also forth - also gbforth - else - bye - then - -; execute - -( Do not write any code after this! ) +require ./gbforth.fs diff --git a/gbforth.fs b/gbforth.fs new file mode 100644 index 00000000..d882c010 --- /dev/null +++ b/gbforth.fs @@ -0,0 +1,108 @@ +#! /usr/bin/env gforth +\ -*- forth -*- + +require ./src/vocabulary.fs + +also gbforth definitions +also gbforth + +require ./src/cli.fs +require ./src/rom.fs +require ./src/sym.fs +require ./src/asm.fs +require ./src/cartridge.fs +require ./src/runtime.fs +require ./src/compiler/cross.fs + +also gb-assembler-impl +' romc, IS emit +' rom-offset IS offset +' romc! IS emit-to +previous + +output-file to-symbol-file set-sym-file +s" ; Generated by gbforth " sym-write sym-cr sym-cr + +: also-path-if-set ( addr u -- ) + dup 0 > if + fpath also-path + else + 2drop + then ; + +fpath clear-path +gbforth-path also-path-if-set +fpath path+ . +fpath path+ ~+ + +require ./src/user.fs + +( We want to load the input file sealed in the GBFORTH-USER +( vocabulary. The problem is that we do not want to populate this + vocabulary with auxiliary words to load the input-file. + + Instead, we put all the words in this colon-definition to resolve + the word into addresses before we seal and load the game. +) + +: assert-empty-stack + depth 0<> abort" Stack is not empty" ; + +: assert-memory-fits + rom-unused 0< abort" ROM is full" + ram-unused 0< abort" WRAM is full" ; + +: write-game + fix-header-complement + fix-global-checksum + output-file dump-rom ; + +: %. swap 100 * swap / 1 .r ; + +:noname + assert-empty-stack + + gbforth-user definitions + seal also + + --no-kernel invert if + s" ./lib/core.fs" required + then + + --no-header invert if + ROM + s" ./lib/header.fs" included + RAM + then + + input-file included + + --no-kernel invert if + s" ./src/prelude.fs" included + then + + assert-empty-stack + assert-memory-fits + write-game + + --verbose if + CR CR + ." \ " rom-offset 5 .r ." bytes written to " output-file type CR + ." \ " rom-unused 5 .r ." bytes left, used " + rom-here rom-size %. ." % of ROM" CR CR + + ." \ " ram-here DP0 - 5 .r ." bytes allotted in memory" CR + ." \ " ram-unused 5 .r ." bytes left, used " + ram-here DP0 - ram-size %. ." % of WRAM" CR + then + + --debug if + also forth + also gbforth + else + bye + then + +; execute + +( Do not write any code after this! )