Sorry but I can't see anything directly, immediately, wrong with your code as such.
Some "style" comments: This is not WRONG as such, but...
change code like this
Code:
write_cursor(++cursorY, cursor);
to something like this:
Code:
++cursorY;
write_cursor(cursorY, cursor);
(Obviously likewise for the cursor up code)
That way, the increment/decrement is much more obvious, and if you ever change write_cursor to be a macro or some such, it won't affect the update of the actual position. It also helps if you ever try to debug the code - you can check the value before you call the function, rather than having the function call and increment as one line which you can't (triivally) separate into different steps.
Following that a step further, you can do:
Code:
oldCursorY = cursorY;
... check if cursor key pressed; update cursorY....
if (oldCursorY != cursorY)
{
write_cursor(oldCursorY, clear_cursor);
write_cursor(cursorY, cursor);
}
This would make smaller code, and easier to follow/debug/understand.
--
Mats