The latest screenshot of the (super early) build of 0x10c, still apparently under the name "SpaceGame", gives away a two new details about the DCPU-16's instruction set that everyone who's been building compilers has been wanting:
- A standard way to show output to the in-game terminal.
- A way to store data that can be looped through.
It appears that std out to the terminal is performed by SETing the memory values in the 0x8000 - 0x8400 range (which gives you a 32x32 character grid) with one word per character using the lower 8 bits for text, & leaving room in the upper 8 bits for colors. I can't tell yet specifically what values correspond to what colors, other than 0x170 seems to be grey text on a dark gray (or perhaps the default black?) background.
Take a look at line 15 in the assembly code below and you can see how each character in the strings from the data subroutine end up getting set in sequence to 0x8000, 0x8001, 0x8002, etc.
Incidentally, the "dat" instruction used to set the strings and colors on line 31 was documented in a pastebin linked to from notch's tumblr, though it's not documented in the DCPU-16 specification (as of version 1.1). The format seems to be a 0 terminated and comma separated sequence of data, including support for strings. So, each of the following appear to be valid:
- dat "Hello World", 0
- dat 0x170, "Hello ", 0x2e1, "World", 0
- dat 0x170, 0x2e1, 0
Can any of you figure out how the values correspond to colors? From a quick glance, the color (stored in b) seems to be combined with the character to output (stored in a) before a's value is set to the proper 0x8000 address for the character to be displayed on the in-game terminal.
It’s Black Friday week on WonderHowTo! Don’t miss out on all of the big sales in the Gadget Hacks and Null Byte shops. And if you’ve been wanting to take some classes without going into debt, check out our best deals on online courses for a variety of skill sets. Don’t miss out on these huge discounts: