997d539cc7
FossilOrigin-Name: 0418f2e3f8a33a2642b8a7a587632aa5f4bb03e08889e4dd037e7fb1839f5fa6
41 lines
815 B
Text
41 lines
815 B
Text
# Amalgamate
|
|
|
|
The standard RETRO system is built using the Nga VM[1] and a
|
|
copy of the image exported as a C source file[2]. I sometimes
|
|
prefer to have these as a single file for easier sharing. This
|
|
is a quick little tool to combine them.
|
|
|
|
Output will be written to stdout.
|
|
|
|
## References
|
|
|
|
[1] vm/nga-c/retro-unix.c
|
|
[2] vm/nga-c/retro-image.c
|
|
|
|
## Code
|
|
|
|
Include compilation instructions.
|
|
|
|
~~~
|
|
'/*_Build_with_`cc_-lm_-O2_retro-unix.c_-o_retro`_*/ s:put nl nl
|
|
~~~
|
|
|
|
Then extract and generate the single file source.
|
|
|
|
~~~
|
|
{{
|
|
:image:inline
|
|
'vm/nga-c/retro-image.c [ s:put nl ] file:for-each-line ;
|
|
|
|
:source:line
|
|
dup '#include_"retro-image.c" s:eq?
|
|
[ drop image:inline ] [ s:put nl ] choose ;
|
|
|
|
---reveal---
|
|
|
|
:amalgamate
|
|
'vm/nga-c/retro-unix.c [ source:line ] file:for-each-line ;
|
|
}}
|
|
|
|
amalgamate
|
|
~~~
|