Skip to content

Commit

Permalink
Add fs extension to entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tkers committed Mar 20, 2022
1 parent 711501e commit e769c31
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 107 deletions.
108 changes: 1 addition & 107 deletions gbforth
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
108 changes: 108 additions & 0 deletions gbforth.fs
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! )

0 comments on commit e769c31

Please sign in to comment.