diff --git a/bass1.sbi b/bass1.sbi new file mode 100755 index 0000000..00fa94b Binary files /dev/null and b/bass1.sbi differ diff --git a/bink.sbi b/bink.sbi new file mode 100755 index 0000000..dfb4ee8 Binary files /dev/null and b/bink.sbi differ diff --git a/boot.jim b/boot.jim index da58d90..40999d6 100755 Binary files a/boot.jim and b/boot.jim differ diff --git a/catalog.exe b/catalog.exe new file mode 100755 index 0000000..c63addd Binary files /dev/null and b/catalog.exe differ diff --git a/debug.jim b/debug.jim index 8b03b7c..c54b916 100755 Binary files a/debug.jim and b/debug.jim differ diff --git a/debug.jor b/debug.jor index 22d94de..9fcf75a 100755 --- a/debug.jor +++ b/debug.jor @@ -5,6 +5,7 @@ var brk-xp var dbg-ip var dbg-task +var dbg-emit defer dbg-cmd : dbg-first-ip ( xp -- [ip|0] ) @@ -27,8 +28,10 @@ defer dbg-cmd ' dbg-cmd tail : .dbg ( ip -- ip ) + task-emit @ >r dbg-emit @ dup if task-emit ! else drop then cr dup .wordin s" ip: " type dup . dup get-dbg-xp ` type cr - >r .s r .s : door-listener ( ev -- ) dup entering-door? if move-player then - DOOR-OPENED DOOR-CLOSED handle-onoff ; + DOOR-CLOSED responder>tile? swap + DOOR-OPENED DOOR-CLOSED handle-onoff + DOOR-CLOSED responder>tile? != if + DOOR-CLOSED responder>tile? if sfx-doorclose else sfx-dooropen then + then ; : door create-object ' door-listener listener! ; @@ -416,6 +421,7 @@ does> EVTOUCH = isneut? and COMP-ON responder>tile? and if linked-entity dup computer-on? if entity>pos Neut entity.pos! + sfx-zoop else drop then then ; diff --git a/gameboot.jor b/gameboot.jor index d263603..143680f 100755 --- a/gameboot.jor +++ b/gameboot.jor @@ -27,6 +27,7 @@ s" input.jor" loadfile s" timer.jor" loadfile s" entity.jor" loadfile s" footer.jor" loadfile +s" sound.jor" loadfile s" title.jor" loadfile ; execute diff --git a/garbage.sbi b/garbage.sbi new file mode 100755 index 0000000..f6cdae5 Binary files /dev/null and b/garbage.sbi differ diff --git a/input.jim b/input.jim index 91b9ec3..3a2e5aa 100755 Binary files a/input.jim and b/input.jim differ diff --git a/jiles.jim b/jiles.jim index d2cc609..e35a220 100755 Binary files a/jiles.jim and b/jiles.jim differ diff --git a/job.jim b/job.jim index cbb34c6..0d39e25 100755 Binary files a/job.jim and b/job.jim differ diff --git a/jopl.jim b/jopl.jim index 578785f..bf43818 100755 Binary files a/jopl.jim and b/jopl.jim differ diff --git a/jopl.jor b/jopl.jor index bb6b551..ebccb69 100755 --- a/jopl.jor +++ b/jopl.jor @@ -1,7 +1,8 @@ ' putc task-emit ! :noname s" debug.jor" loadfile ; execute +' seremit dbg-emit ! -s" jopl.log" open seekend fdeactivate const LOGFILE +-1 const LOGFILE : emit-log fdeactivate LOGFILE factivate fputc fdeactivate drop factivate ; : quit LOGFILE factivate close _quit ; @@ -14,7 +15,6 @@ s" jopl.log" open seekend fdeactivate const LOGFILE s" .:: J O P L ( jean OPL2 print loop) ::." type cr dorepl ; task const REPL -REPL start-repl : start-dbg activate ' seremit task-emit ! s" .:: J D B G ( jean debugger) ::." type cr @@ -109,7 +109,7 @@ array semitones current loadinst ; userword : write-sbi-op-reg ( offset -- ) - dup current + b@ fputc current + 5 + b@ fputc ; + dup current + 5 + b@ fputc current + b@ fputc ; : writezeros ( n -- ) 0 for 0 fputc next ; : savesbi ( filename -- ) @@ -131,20 +131,23 @@ array semitones var songticks +var beatcount +4 beatcount ! + var notestate var octave : oct+ octave @ 12 * + ; userword : rest songticks @ begin suspend dup songticks @ != until drop ; userword -: beat begin dup songticks @ swap % 0 != while rest repeat drop ; userword +: beat begin dup songticks @ beatcount @ % 0 != while rest repeat drop ; userword : %O octave ! ; userword : %V voice ! ; userword -: mknote create b, does> ub@ oct+ notestate @ if b, else noteon rest then ; -: %loop 0xfe b, , ; userword +: %loop 0xfe b, ; userword : mod % ; : % notestate @ if 0xf0 b, else rest then ; userword : %% 0 for % next ; userword : %- notestate @ if 0xfd b, else noteoff then ; userword -: %do 0xff b, , ; userword + +: mknote create b, does> ub@ oct+ notestate @ if b, else noteon rest then ; 11 mknote G# userword 10 mknote G userword @@ -160,21 +163,37 @@ var octave 0 mknote A userword array tracks 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , +array tracks-start 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , : track ( i -- p ) cells tracks + ; -: dotrack ( ip -- ip ) - dup if dup 1 + swap ub@ >r - r@ 0xff = if dup @ swap cell + swap execute then - r@ 0xfe = if @ dotrack then - r@ 0xfd = if noteoff then - r@ 0xf0 < if r@ noteon then - rdrop then ; +: vtrack ( -- p ) voice @ track ; -: track-tick ( i -- ) - track dup @ dotrack swap ! ; +: curr-track-start voice @ cells tracks-start + ; +: track-tick ( -- ) + vtrack @ >r r@ if ( r: track ) + songticks @ curr-track-start @ - ( -- index ) -: :track create here 1 notestate ! does> voice @ track ! ; userword -: ;track %loop 0 notestate ! ; userword + ( call instrument word if start of track ) + dup not if r@ cell + @ execute then ( index -- index ) + + ( call "tick" word ) + dup r@ @ execute ( index -- index ) + + 2 cells + r@ + ub@ ( index -- note ) + dup 0xf0 < if noteon + else dup 0xfd = if noteoff + else 0xfe = if songticks @ curr-track-start ! track-tick ( loop ) + then then then + then rdrop ; + +: pad-track ( start end -- ) + swap - beatcount @ mod ( s e -- cpad ) + dup if 0 for % next else drop then ; + +: :track create ' drop , ' noop , here 1 notestate ! does> + beat vtrack ! songticks @ curr-track-start ! ; userword + +: ;track here pad-track %loop 0 notestate ! ; userword : shush 0 voice @ track ! %- ; userword : prev-name ( wordname -- wordname ) @@ -198,6 +217,9 @@ array tracks 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 'name :track type bl swap type bl begin dup ub@ emit-cmd while 1 + repeat drop ; userword +: emit-inst ( pinst -- ) + 11 -1 for dup i + ub@ . next drop s" instrument XXX" type cr ; + ( T E X T ) : setattr-to ( w -- ) 0 for attremit next ; @@ -242,7 +264,7 @@ var tempo userword 1 tempo ! 1 songticks +! songticks @ tempo @ mod 0 = if voice @ - 0 10 for i voice ! i track-tick next + 0 10 for i voice ! track-tick next voice ! then ; @@ -329,10 +351,11 @@ var menuw defer onselect : menu-at ( cp x y w -- ) - :| menuw ! texty ! dup textx ! textleft ! ' emit-direct task-emit ! + :| menuw ! texty ! dup textx ! textleft ! + ' emit-direct task-emit ! 0 task-echo ! 0 menuscroll ! 0 menuy ! execute ' noop ' onselect redefine |; - 0 textleft task-emit preserving ; + 0 textleft task-emit task-echo preserving ; : menu-lines ( -- count ) 24 texty @ - ; : menu-skip menuscroll @ 0 max ; @@ -424,8 +447,6 @@ wordchain opbits 0 0x03 bitfield @wave opbits ' opbits endwordchain -array instreg ' ar-wave , ' ar-sr , ' ar-ad , ' ar-level , ' ar-flags , - : c+op current op @ not if 5 + then ; : count-links 0 swap links each swap 1 + swap more ; @@ -488,7 +509,13 @@ algbits count-links const #algbits :noname + s" jopl.log" open seekend fdeactivate ' LOGFILE redefine + REPL start-repl + 9 -1 for i voice ! default loadinst next startt2 ' emit-direct task-emit ! ; ' onload redefine + +2 %O +:track bassline C % % C % % % G % % % G % % G % % C % % C % % % G 8 %% ;track diff --git a/lev00001.jim b/lev00001.jim index 8dd1ee3..7e5e12a 100755 Binary files a/lev00001.jim and b/lev00001.jim differ diff --git a/lev00001.jor b/lev00001.jor index 1c3bdc4..a1319bc 100755 --- a/lev00001.jor +++ b/lev00001.jor @@ -1,6 +1,10 @@ ( L E V E L 0 0 0 0 1 ) +202 13 128 0 17 244 0 39 201 241 18 0 instrument quake +: sfx-quake quake 0 loadsfx %D ; + : intro + sfx-quake 30 sleep 1 quaking ! 30 sleep @@ -8,6 +12,7 @@ hide-footer 10 sleep 0 quaking ! + noteoff jaye say" That was an earthquake!" ; diff --git a/lev00002.jim b/lev00002.jim index d505077..a4ccca2 100755 Binary files a/lev00002.jim and b/lev00002.jim differ diff --git a/lev00003.jim b/lev00003.jim index c5ab01b..d41a474 100755 Binary files a/lev00003.jim and b/lev00003.jim differ diff --git a/level.jim b/level.jim index 8f49fef..7b106d9 100755 Binary files a/level.jim and b/level.jim differ diff --git a/map.jim b/map.jim index 5224eae..58b6a37 100755 Binary files a/map.jim and b/map.jim differ diff --git a/neuttowr.exe b/neuttowr.exe index e7d5b68..d34b68a 100755 Binary files a/neuttowr.exe and b/neuttowr.exe differ diff --git a/neuttowr.prj b/neuttowr.prj index b5277a5..ecf67a7 100755 Binary files a/neuttowr.prj and b/neuttowr.prj differ diff --git a/save.sav b/save.sav index ac7ac5f..5407bf3 100755 Binary files a/save.sav and b/save.sav differ diff --git a/sound.jim b/sound.jim new file mode 100755 index 0000000..9770fa9 Binary files /dev/null and b/sound.jim differ diff --git a/sound.jor b/sound.jor new file mode 100755 index 0000000..1369ce5 --- /dev/null +++ b/sound.jor @@ -0,0 +1,95 @@ +var voice +var op + +: op-with-voice voice @ + dup 5 > if 5 + then + dup 2 > if 5 + then + + op @ + ; +: opreg create b, does> ub@ op-with-voice ; +: voicereg create b, does> ub@ voice @ + ; + +0x20 opreg ar-flags +0x40 opreg ar-level +0x60 opreg ar-ad +0x80 opreg ar-sr +0xe0 opreg ar-wave +0xc0 voicereg ar-alg + +0xa0 voicereg ar-freq +0xb0 voicereg ar-note + +: op2 3 op ! ; +: op1 0 op ! ; +: loadop ( flags level ad sr wave -- ) + ar-wave adlib! + ar-sr adlib! + ar-ad adlib! + ar-level adlib! + ar-flags adlib! ; + +: readop ( v -- ) + >r r@ 4 + b@ r@ 3 + b@ r@ 2 + b@ r@ 1 + b@ > 0x03 & swap 2 << | 0x20 | ar-note adlib! ; +: noteoff ( -- ) 0 ar-note adlib! ; userword + +array semitones +3520 3520 />ratio , +3729 3520 />ratio , +3951 3520 />ratio , +4186 3520 />ratio , +4435 3520 />ratio , +4699 3520 />ratio , +4978 3520 />ratio , +5274 3520 />ratio , +5588 3520 />ratio , +5920 3520 />ratio , +6272 3520 />ratio , +6645 3520 />ratio , + +: note dup 12 / 8 % swap 12 % cells semitones + @ 440 swap * ub@ oct+ noteon ; + +11 mknote %G# userword +10 mknote %G userword +9 mknote %F# userword +8 mknote %F userword +7 mknote %E userword +6 mknote %D# userword +5 mknote %D userword +4 mknote %C# userword +3 mknote %C userword +2 mknote %B userword +1 mknote %A# userword +0 mknote %A userword + +202 14 24 0 244 2 3 16 3 52 119 1 instrument garbinst +202 1 4 0 248 190 0 0 39 214 79 0 instrument bink +202 4 37 0 67 52 3 1 80 54 119 0 instrument zoop +202 10 134 129 239 1 0 1 3 152 241 0 instrument doorinst + +task const SFX +SFX :noname activate begin receive execute again ; execute + +: loadsfx ( inst oct -- ) octave ! loadinst ; +: sfx-garbage garbinst 4 loadsfx %C ; +: sfx-bink bink 6 loadsfx %C ; +: sfx-confirm bink 6 loadsfx %C rest %E rest %C rest %G rest ; +: sfx-zoop zoop 5 loadsfx %C ; +: sfx-dooropen :| doorinst 4 loadsfx %C rest %E |; SFX send ; +: sfx-doorclose :| doorinst 4 loadsfx %E rest %C |; SFX send ; \ No newline at end of file diff --git a/state.jim b/state.jim index 98ce09e..6e16d38 100755 Binary files a/state.jim and b/state.jim differ diff --git a/testbed.c b/testbed.c index 0cce2dd..3d0f78f 100755 --- a/testbed.c +++ b/testbed.c @@ -269,6 +269,7 @@ void game_init() { kbd_init(); timer_init(TIMER_30HZ); text_init(); + adlib_init(); loadscr("title"); /* f = fopen("TITLE.TIF", "rb"); @@ -439,6 +440,13 @@ void f_loadscr() { DROP(1); } +void f_system() { + kbd_cleanup(); + system(TOP().s); + DROP(1); + kbd_init(); +} + /* JILES */ #define SCREEN_STRIDE 40 @@ -817,6 +825,8 @@ void game_f_init(char *exe, char *bootjor) { CDEF("loadscr", f_loadscr); CDEF("fuck", f_resetvideo); CDEF("boss", f_showboss); + CDEF("system", f_system); + CDEF("adlib!", f_adlib); CDEF("mouseshow", f_mouseshow); CDEF("mousehide", f_mousehide); @@ -858,23 +868,6 @@ void f_poll() { } } -void do_repl(char *exe) { - char buf[128]; - - f_init(exe); - CDEF("quit", f_quit); - CDEF("adlib", f_adlib); - - f_loadfile("repl.jor"); - f_taskloop(); - - while (!DONE) { - PUSHS(gets(buf)); - f_runstring("REPL send"); - f_taskloop(); - } -} - int main(int argc, char *argv[]) { char *bootjor = "gameboot.jor"; diff --git a/timer.jim b/timer.jim index fa15999..3091507 100755 Binary files a/timer.jim and b/timer.jim differ diff --git a/title.jim b/title.jim index 77e6864..2e784e4 100755 Binary files a/title.jim and b/title.jim differ diff --git a/title.jor b/title.jor index 8ca0e08..240558e 100755 --- a/title.jor +++ b/title.jor @@ -32,10 +32,11 @@ defer redraw-menu s" New Game" :| 1 startgame |; yield s" Continue" savedlevel @ if :| savedlevel @ startgame |; else 0 then yield s" Help" ' help yield + s" Catalog" :| s" catalog.exe" system fuck show-title-bg redraw-menu |; yield s" Quit" ' quit yield done ; var menu-selected -: menu-y ( i -- y ) 12 * 90 + ; +: menu-y ( i -- y ) 12 * 88 + ; : draw-menu 0 menu-opts each if over menu-selected @ = if LGREEN else WHITE then else RED then @@ -45,16 +46,16 @@ var menu-selected dup menu-selected @ = if 15 else sp then optionbg 1 + more drop ; -:noname WHITE text-color ! 21 9 8 72 box draw-menu ; ' redraw-menu redefine +:noname WHITE text-color ! 21 10 8 72 box draw-menu ; ' redraw-menu redefine : exec-selected 0 menu-opts each swap drop over menu-selected @ = if - dup if execute else drop then break else drop + dup if sfx-confirm execute else drop then 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 ; +: menu-select ( di -- ) menu-selected menu-count +!cycle draw-menu sfx-bink ; :noname save.sav open fget close savedlevel !