The DCPU does not have built-in I/O hardware, but 0x10code provides standard peripherals for interacting with users.
The display is that weird little grey box you see to the right of your code. How do you write stuff to it?
In a nutshell, 0x10code implements a standard LEM1802 display. In order to write to the display, first map the display to an appropriate location in memory, then write to that memory location.
When you write to one of these cells, you do it in the following bit
HRGB HRGB B CCCCCCC where the first set of HRGB is the color
of the text, the next
HRGB is the color of the background (with
being 'highlight', making the colors brighter),
B is whether or not
to blink the cell, and
C is the ASCII character value.
The color of the border of the display may also be set by calling a
hardware interrupt. The interrupt key is
SET_BORDER_COLOR, which is
the number 3 on the LEM1802. The interrupt value in the same
color format as cells.
Example to set the border to red:
SET A, 3; SET B, 1; HWI <address of
You can even set the font used when writing to the display. This could come in handy for making game sprites, tiles, interfaces, etc.
The pixels for a character are stored in two words,
<base> + (v *
<base> + (v * 2) + 1, where
v is the character's ASCII
<base> is the location in memory where the font is mapped.
These two words store the pixels in the format
a is the leftmost column,
b is the next,
c is the third, and
d is the rightmost, and each bit defines
whether or not a pixel is visible. The columns are stored going from
You can also get keyboard input. The system may seem confusing at first, but once you get the hang of it, you will be able to make some sweet games, or maybe a text editor.
The keyboard is a generic keyboard and is largely interrupt-driven.
We will certainly be adding more I/O as Notch announces it, or as we figure it out. For instance, disk storage will be here shortly. Also, by the time the real game comes out, we will know how to control the systems of your ship (weapons, engines, communication, etc.). Until then, work with what you have, and show us something awesome!
SET a, bsets a to b
ADD a, bsets a to a+b, sets O to 0x0001 if there's an overflow, 0x0 otherwise
SUB a, bsets a to a-b, sets O to 0xffff if there's an underflow, 0x0 otherwise
MUL a, bsets a to a*b, sets O to ((a*b)>>16)&0xffff
DIV a, bsets a to a/b, sets O to ((a<<16)/b)&0xffff. if b==0, sets a and O to 0 instead.
MOD a, bsets a to a%b. if b==0, sets a to 0 instead.
SHL a, bsets a to a<>b)&0xffff
SHR a, bsets a to a>>b, sets O to ((a<<16)>>b)&0xffff
AND a, bsets a to a&b
BOR a, bsets a to a|b
XOR a, bsets a to a^b
IFE a, bperforms next instruction only if a==b
IFN a, bperforms next instruction only if a!=b
IFG a, bperforms next instruction only if a>b
IFB a, bperforms next instruction only if (a&b)!=0
JSR apushes the address of the next instruction to the stack, then sets PC to a
BRKstops execution (non-standard)
POP / [SP++]
PEEK / [SP]
PUSH / [--SP]