neuttower/title.jor

69 lines
2.2 KiB
Plaintext
Raw Normal View History

2020-04-08 03:20:46 +00:00
: titlec ( c -- )
textx @ texty @ 40 * + swap text-color @ rawtextc
1 textx +! ;
: textline ( w r m l )
textleft @ textx !
titlec <rot 1 for dup titlec next drop titlec
8 texty +! ;
: boxtop ( w -- ) 184 205 213 textline ;
: boxmid ( w -- ) 179 32 179 textline ;
: boxbot ( w -- ) 190 205 212 textline ;
: box ( w h x y -- )
texty ! textleft !
over boxtop
1 for dup boxmid next
boxbot ;
: strlen ( s -- n ) 0 swap begin dup b@ while 1 + swap 1 + swap repeat drop ;
: titles ( s -- ) begin dup b@ dup while titlec 1 + repeat drop drop ;
2020-04-08 16:07:40 +00:00
: optionbg ( c -- ) dup 10 textx ! titlec 27 textx ! titlec ;
2020-04-10 23:16:52 +00:00
: center ( s dx ) over strlen 1 >> - textx ! titles ;
: option ( s -- ) 19 center ;
2020-04-08 03:20:46 +00:00
2020-04-10 15:27:25 +00:00
intern save.sav
var savedlevel
2020-04-10 23:16:52 +00:00
defer redraw-menu
: show-title-bg s" title" loadscr ;
: startgame ( n -- ) show-title-bg s" start.jor" loadjor ;
: help s" help" loadscr ^ENTER wait-key show-title-bg redraw-menu ;
2020-04-10 15:27:25 +00:00
2020-04-08 03:20:46 +00:00
: menu-opts
s" New Game" :| 1 startgame |; yield
2020-04-10 15:27:25 +00:00
s" Continue" savedlevel @ if :| savedlevel @ startgame |; else 0 then yield
2020-04-10 23:16:52 +00:00
s" Help" ' help yield
s" Catalog" :| s" catalog.exe" system fuck show-title-bg redraw-menu |; yield
2020-04-08 03:20:46 +00:00
s" Quit" ' quit yield
done ;
var menu-selected
: menu-y ( i -- y ) 12 * 88 + ;
2020-04-08 03:20:46 +00:00
: draw-menu
2020-04-10 15:27:25 +00:00
0 menu-opts each
if over menu-selected @ = if LGREEN else WHITE then else RED then
text-color !
2020-04-08 16:07:40 +00:00
over menu-y texty !
2020-04-10 15:27:25 +00:00
option
2020-04-08 16:07:40 +00:00
dup menu-selected @ = if 15 else sp then optionbg
2020-04-08 03:20:46 +00:00
1 +
more drop ;
:noname WHITE text-color ! 21 10 8 72 box draw-menu ; ' redraw-menu redefine
2020-04-08 03:20:46 +00:00
: exec-selected 0 menu-opts each swap drop
2020-04-10 15:27:25 +00:00
over menu-selected @ = if
dup if sfx-confirm execute else drop then break else drop
2020-04-10 15:27:25 +00:00
then 1 +
2020-04-08 03:20:46 +00:00
more drop ;
: menu-count 0 menu-opts each drop drop 1 + more ;
: menu-select ( di -- ) menu-selected menu-count +!cycle draw-menu sfx-bink ;
2020-04-08 03:20:46 +00:00
:noname
2020-04-10 15:27:25 +00:00
save.sav open fget close savedlevel !
2020-04-10 23:16:52 +00:00
fuck 0 split-screen show-title-bg redraw-menu
2020-04-08 03:20:46 +00:00
:| ^ENTER key-pressed if exec-selected then
^UP key-pressed if -1 menu-select then
^DOWN key-pressed if 1 menu-select then
^ESC key-pressed if quit then
2020-04-10 15:27:25 +00:00
|; ' tick redefine
' noop ' draw redefine ; checkpoint title