diff --git a/adlib.c b/adlib.c new file mode 100755 index 0000000..5547a4e --- /dev/null +++ b/adlib.c @@ -0,0 +1,14 @@ +#include + +static void adlib_wait(int delay) { + int i; + for (i = 0; i < delay; i ++) inp(0x388); +} + +void adlib_write(int reg, int val) { + int i; + outp(0x388, reg); + adlib_wait(6); + outp(0x389, val); + adlib_wait(35); +} diff --git a/adlib.h b/adlib.h new file mode 100755 index 0000000..ab352f5 --- /dev/null +++ b/adlib.h @@ -0,0 +1 @@ +void adlib_write(int reg, int val); \ No newline at end of file diff --git a/boot.jim b/boot.jim index 9cb5a8c..d20f40f 100755 Binary files a/boot.jim and b/boot.jim differ diff --git a/defs.jim b/defs.jim index d3c7ee0..6af2d25 100755 Binary files a/defs.jim and b/defs.jim differ diff --git a/defs.jor b/defs.jor index 0c3491c..027036e 100755 --- a/defs.jor +++ b/defs.jor @@ -5,17 +5,20 @@ : 2dup over over ; : 3dup r> 2dup r@ >rot r< ; : 4dup r> r> 2dup r@ >rot rswap r@ >rot r< r< swap ; +: nip swap drop ; : 2= ( a b c d -- a=c&b=d ) r> dup @ ( b v val r: flag ) - rot r> r@ @ >rot ( val flag b r: v ) + if | else ~ & then r< ! ; : f@ ( v flag -- ) swap @ & ; -: fnot! 2dup f@ not f! ; +: fnot! ( v flag -- ) over @ ^ swap ! ; : expile state if , else execute then ; diff --git a/entity.jim b/entity.jim index a54d05a..a03576f 100755 Binary files a/entity.jim and b/entity.jim differ diff --git a/footer.jim b/footer.jim index 88c1d82..495c985 100755 Binary files a/footer.jim and b/footer.jim differ diff --git a/game.exe b/game.exe index 53ffb0b..2211ecc 100755 Binary files a/game.exe and b/game.exe differ diff --git a/game.jim b/game.jim index eb69e54..d58ed85 100755 Binary files a/game.jim and b/game.jim differ diff --git a/game.jor b/game.jor index 83252cc..07826d2 100755 --- a/game.jor +++ b/game.jor @@ -30,15 +30,19 @@ defer player 1 const MOVING 2 const DRIVING +4 const NOCLIP + +: player.driving? player.state DRIVING f@ ; : {player} - player.state DRIVING f@ if {car} + player.driving? if {car} else player.state MOVING f@ if {pete-walk} else {pete-stand} then then ; -: player.driving? player.state DRIVING f@ ; : player.canmove? ( x y -- ) - player.driving? if DRIVABLE else WALKABLE then mapflag? ; + player.state NOCLIP f@ not if + player.driving? if DRIVABLE else WALKABLE then mapflag? + else drop drop 1 then ; 12 9 N ' {player} defentity player @@ -111,6 +115,10 @@ player :tick : hello-world player.state DRIVING fnot! ; +: reset-level + :| player yield 0 |; ' entities redefine + :| drop drop 0 |; ' player-touch redefine ; + : mode-move entities each EVTICK entity>do more tick-mapedit @@ -120,6 +128,7 @@ player :tick tick-debounce q-level @ dup if 0 q-level ! + reset-level loadlevel q-player.x @ q-player.y @ tile>world player entity.pos! else drop then ; @@ -142,10 +151,6 @@ player :tick draw-screen draw-footer ; -: reset-level - :| player yield 0 |; ' entities redefine - :| drop drop 0 |; ' player-touch redefine ; - :noname reset-level MODE-MOVE @ ' tick redefine diff --git a/game.prj b/game.prj index 9a79db0..892a749 100755 Binary files a/game.prj and b/game.prj differ diff --git a/gameboot.jor b/gameboot.jor index f4660c6..8fd38bc 100755 --- a/gameboot.jor +++ b/gameboot.jor @@ -18,12 +18,14 @@ s" timer.jor" loadfile s" footer.jor" loadfile s" map.jor" loadfile s" game.jor" loadfile +s" state.jor" loadfile ; execute intern pete.jor intern petehous.jor intern road.jor intern jeanne.jor +intern trail1.jor :noname loadfile ; checkpoint _loadlevel ' _loadlevel ' loadlevel redefine diff --git a/input.jim b/input.jim index 80ccb2e..6b942a2 100755 Binary files a/input.jim and b/input.jim differ diff --git a/jeanne.jim b/jeanne.jim index e375245..64854b2 100755 Binary files a/jeanne.jim and b/jeanne.jim differ diff --git a/jeanne.jor b/jeanne.jor index f623628..8bdb685 100755 --- a/jeanne.jor +++ b/jeanne.jor @@ -13,10 +13,9 @@ car :touch ;entity :noname - reset-level 0 player.state DRIVING f! :| player yield - e_chuck yield + chuck.state @ CHUCK-HOME = if e_chuck yield then player.driving? not if car yield then 0 |; ' entities redefine diff --git a/jorth.c b/jorth.c index 8526c8c..4e649d0 100755 --- a/jorth.c +++ b/jorth.c @@ -525,7 +525,10 @@ void f_lit_() { void f_number() { // str -- (num 1 | str 0) int num = 0, result; - result = sscanf(TOP().s, "%d", &num); + result = sscanf(TOP().s, "0x%x", &num); + if (result != 1) { + result = sscanf(TOP().s, "%d", &num); + } if (result == 1) { TOP().i = num; PUSHI(result == 1); diff --git a/jorts.map b/jorts.map deleted file mode 100755 index f099756..0000000 Binary files a/jorts.map and /dev/null differ diff --git a/map.jim b/map.jim index cc4b58a..81329f3 100755 Binary files a/map.jim and b/map.jim differ diff --git a/map.jor b/map.jor index fb8c1e4..d71e645 100755 --- a/map.jor +++ b/map.jor @@ -66,6 +66,25 @@ here tileflags - 1 - const MAXTILE for 2dup i copy-mapseg next drop swap mapsize! ; +: mapw mapsize drop ; +: maph mapsize nip ; + +: offset-map ( p d -- p ) dup 0 < if drop else + then ; + +: shift-map ( dx dy -- ) + maph over abs - r> ( dx dy r: h ) + swap mapw over abs - >rot ( w dy dx r: h ) + 2dup map swap offset-map + swap mapw * offset-map >rot ( w end dy dx r: h ) + map swap negate offset-map + swap mapw * negate offset-map ( w end start r: h ) + 2dup > if r@ mapw * + swap r@ mapw * + swap then + r< 0 for + 3dup