I think we need to see the code for
init and
strlen, the header file they are declared in, and your Makefile and linker script.
Or, you know, you could give us a link to your cloud repo. The one you probably don't have yet because you never listen to advice. Go, drop everything, head over to GitHub or CloudForge and make one
right now, and get your code under version control before you do anything else. You are sitting on a bomb that is about to go off and you don't even realize it.
Seriously, you really are the fool we have been taking you for if you don't do this right away.
Speaking of which:
NunoLava1998 wrote:
Code: Select all
enum vga_color {
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15,
};
You do know that
enum will automagically set the values in a fixed order starting at zero for you if you don't set an explicit value, right? That's the whole point of enumerations. Change it to this and it will actually be
more readable to most C programmers:
Code: Select all
enum vga_color {
VGA_COLOR_BLACK,
VGA_COLOR_BLUE,
VGA_COLOR_GREEN,
VGA_COLOR_CYAN,
VGA_COLOR_RED,
VGA_COLOR_MAGENTA,
VGA_COLOR_BROWN,
VGA_COLOR_LIGHT_GREY,
VGA_COLOR_DARK_GREY,
VGA_COLOR_LIGHT_BLUE,
VGA_COLOR_LIGHT_GREEN,
VGA_COLOR_LIGHT_CYAN ,
VGA_COLOR_LIGHT_RED,
VGA_COLOR_LIGHT_MAGENTA,
VGA_COLOR_LIGHT_BROWN,
VGA_COLOR_WHITE
};
As I said in the other thread, the values of an enumeration are more or less a side effect of how they are implemented. Using them for those values is sort of off-brand, but permissible in C, but the whole idea of an enum is to define the
order of the constants, not the specific values. If the order doesn't matter, use
const or
#define for general constants. In this case, it really isn't, so using an enumeration for it is a Bad Idea. This is really a better solution all around:
Code: Select all
const uint8_t VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15;
I won't bother mentioning that this isn't a good way to do that anyway, because VGA palettes aren't fixed, but whatever.