-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
109 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! ) |