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
format: 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 H
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 HRGB
color format as cells.
Example to set the border to red: SET A, 3; SET B, 1; HWI <address of
display>
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 *
2), and <base> + (v * 2) + 1, where v is the character's ASCII
value and <base> is the location in memory where the font is mapped.
These two words store the pixels in the format aaaaaaaabbbbbbbb
ccccccccdddddddd, where 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
top-to-bottom.
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, b sets a to bADD a, b sets a to a+b, sets O to 0x0001 if there's an overflow, 0x0 otherwiseSUB a, b sets a to a-b, sets O to 0xffff if there's an underflow, 0x0 otherwiseMUL a, b sets a to a*b, sets O to ((a*b)>>16)&0xffffDIV a, b sets a to a/b, sets O to ((a<<16)/b)&0xffff. if b==0, sets a and O to 0 instead.MOD a, b sets a to a%b. if b==0, sets a to 0 instead.SHL a, b sets a to a<>b)&0xffffSHR a, b sets a to a>>b, sets O to ((a<<16)>>b)&0xffffAND a, b sets a to a&bBOR a, b sets a to a|bXOR a, b sets a to a^bIFE a, b performs next instruction only if a==bIFN a, b performs next instruction only if a!=bIFG a, b performs next instruction only if a>bIFB a, b performs next instruction only if (a&b)!=0JSR a pushes the address of the next instruction to the stack, then sets PC to aBRK stops execution (non-standard)A, B, C, X, Y, Z, I, JPOP / [SP++]PEEK / [SP]PUSH / [--SP]SP, PC, O© Matt Bell (mappum) 2012 - DCPU16 code - Site code - Report bugs