void write_char(char x, char y, char ch, char attb) {
This is
function definition. It defines a function
that does not return anything and takes
4 characters as it's parameters (x, y, ch, attb).
char far * vdu = (char far *)MK_FP(0xb800,00);
This statement creates
char array/pointer (far is probably a preprocessor definition, hard to tell what it means, it can be
const
,
static
,
volatile
, etc).
Value of this char array/pointer is assigned by
function or by
preprocessor definition MK_FP, which takes in one
char
value & one
int
value, first value represented in hexadecimals & second value as an ordinary number in decimals. The result of
MK_FP is then converted into char array/pointer with C-style type cast.
1 2 3
|
*(vdu +(y*160)+(x*2))=ch;
*(vdu +(y*160)+(x*2)+1)=attb;
}
|
Even though
x &
y are both characters (
char
), it is possible to make arithmetic operations
(+ & *) with them. After all, they are like
int
s, but with smaller range
(-128 - 128 or 0 - 255 if dealing with unsigned chars). In this statement, the address of
vdu is increased by the value of y multiplied by 160, which is increased x multiplied by 2. Then, ch is assigned to address of address of
vdu. The following statement is very similiar, it does almost the same thing with minor differences.
If you didn't understand what I told you (I explained the best I could), then I recommend you to learn more C before going to advanced level like this. I admit, my explanation is not the most beginner-friendly, but I hope it is useful. If you want to ask me something, please feel free to do so.