A solution to the synacor challenge implemented in C.
This project is a possible answer to the synacor challenge: https://challenge.synacor.com.
The goal of this challenge is to code a virtual machine able to read and execute the challenge.bin file.
The arch-spec file specifies all the characteristics the machine should have.
All the sources are in the vm folder.
main.cdefines the memory array, the registers, initializes the stack and contains the main event loopstack.cdefines the structure used for the stack and its associated functions (push and pop)utils.cdefines- the read function which read the memory, executes the proper operation following the opcode listing and returns the next operation adress
- the load function which fill the memory array with the challenge.bin content
- some debugging functions which show the state of the stack, the memory and the registers
save.cdefines the save and load functionsdecipher.cdefines the function which translates the memory into a readable program
In order to solve the teleporter enigma, I implemented some commands which can be used inside the game itself.
Each command must begin with the $ character.
regshow the values in every registerssetreg a bset the value of the register a to bmemshow the different values of the memorymemv ashow the a-th value of the memorystackshow the values stored in the stacksourcewrite into the filesources.txtthe content of the memory in a more readable way than just with opcodessavesave the current game (create asave.txtfile)loadload the game state saved in thesave.txtfiledebugtoggle the debug mode. When it is on, every memory operation is stored in thedebugging.txtfile under the same format as insources.txt