santaslabyrinth

Moodboard for an imaginary game

In January 2023 every day I made a room with a robot in it, and maybe wrote a little program for the robot in the room. This was also mixed in with rules, lore and rechosted inspirations. Nowadays this is just posts that evoke a particular feeling. Probably like 80% rechosts from @randochrontendo


part of Santa's Labyrinth, a #Dungeon32 thing

The following library provides simple, #v0-style commands for interfacing with the robot from (v1) code.

(v1)
(
    Defines the robot device for the runtime.
    the robot device is single threaded, and
    every operation will trigger the vector when
    complete. The effect of multiple simultaneous
    operations is undefined, so the safest way to
    interact with the robot's move or mark
    operations is to set a vector and BRK.

    detect is two bytes: a distance in tiles between
    the closest object in the robot's line of sight and
    the robot itself, and a byte indicating the type of
    object detected.  If nothing is seen both bytes
    are 0xFF.  Distance #00 indicates an object sharing
    the same tile as the robot.
)
|d0 @Robot  [
    &vector $2
    &status $1
    &reserved $5
    &actuate $1
    &detect [&detect-object $1 &detect-dist $1]
]

(operation codes for the Robot/move device)
%RLIB-OP-FORWARD { #02 }
%RLIB-OP-BACKWARD { #03 }
%RLIB-OP-LEFT { #08 }
%RLIB-OP-RIGHT { #0c }
%RLIB-OP-SET-MARK { #10 }
%RLIB-OP-ERASE-MARK { #11 }

(result codes readable from Robot/detect)
%RLIB-OBJ-TREASURE { #01 }
%RLIB-OBJ-HAZARD { #02 }
%RLIB-OBJ-WALL { #04 }
%RLIB-OBJ-DOOR { #08 }
%RLIB-OBJ-MARK { #10 }
%RLIB-OBJ-NOTHING { #ff }

|d000
@rlib-operate (op -- )
    .Robot/operate DE0
    STH2r .Robot/vector DEO2
BRK

@rlib-detect ( -- distance object )
    .Robot/detect DEI2
JMP2r

(#v0 compatibility commands)
@rlib-forward ( -- )
    RLIB-OP-FORWARD ;rlib-operate JSI
JMP2r

@rlib-backward ( -- )
    RLIB-OP-BACKWARD ;rlib-operate JSI
JMP2r

@rlib-left ( -- )
    RLIB-OP-LEFT JSI ;rlib-operate
JMP2r
    
@rlib-right ( -- )
    RLIB-OP-RIGHT JSI ;rlib-operate
JMP2r

@rlib-setmark ( -- )
    RLIB-OP-SET-MARK JSI ;rlib-operate 
JMP2r

@rlib-erasemark ( -- )
    RLIB-OP-ERASE-MARK JSI ;rlib-operate
JMP2r

@rlib-look (goal -- bool)
    .Robot/detect-object DEI
    EQU
JMP2r

@rlib-touch (goal -- bool)
    .Robot/detect DEI (goal saw distance)
    #01 EQU (goal saw distance-is-one)
    ,&check-obj JCN
    POP2 JMP2r
    &check-obj
    EQU
JMP2r


You must log in to comment.