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-08 03:20:46 +00:00
|
|
|
: option ( s -- ) dup strlen 1 >> 19 swap - textx ! titles ;
|
|
|
|
|
|
|
|
: startgame ( n -- ) s" title" loadscr s" start.jor" loadjor ;
|
|
|
|
: menu-opts
|
|
|
|
s" New Game" :| 1 startgame |; yield
|
|
|
|
s" Continue" ' noop yield
|
2020-04-08 16:07:40 +00:00
|
|
|
s" Help" ' noop yield
|
|
|
|
s" Register" ' noop yield
|
2020-04-08 03:20:46 +00:00
|
|
|
s" Quit" ' quit yield
|
|
|
|
done ;
|
|
|
|
var menu-selected
|
2020-04-08 16:07:40 +00:00
|
|
|
: menu-y ( i -- y ) 12 * 90 + ;
|
2020-04-08 03:20:46 +00:00
|
|
|
: draw-menu
|
|
|
|
0 menu-opts each drop
|
2020-04-08 16:07:40 +00:00
|
|
|
over menu-y texty !
|
|
|
|
over menu-selected @ = if LGREEN else WHITE then text-color ! option
|
|
|
|
dup menu-selected @ = if 15 else sp then optionbg
|
2020-04-08 03:20:46 +00:00
|
|
|
1 +
|
|
|
|
more drop ;
|
2020-04-08 16:07:40 +00:00
|
|
|
: redraw-menu 21 11 8 72 box draw-menu ;
|
2020-04-08 03:20:46 +00:00
|
|
|
|
|
|
|
: exec-selected 0 menu-opts each swap drop
|
|
|
|
over menu-selected @ = if execute break else drop then
|
|
|
|
1 +
|
|
|
|
more drop ;
|
|
|
|
|
|
|
|
: menu-count 0 menu-opts each drop drop 1 + more ;
|
|
|
|
: menu-select ( di -- ) menu-selected menu-count +!cycle draw-menu ;
|
|
|
|
|
|
|
|
:noname
|
2020-04-08 16:07:40 +00:00
|
|
|
fuck s" title" loadscr 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
|
|
|
|
|; ' tick redefine ; checkpoint title
|