/* * hello — smoke test for the two output APIs: * * stdio (printf/puts/putchar) — FAST, no attribute (ambient colour) * conio (cprintf/cputs/putch) — SLOWER, applies textcolor/textbackground * * Demonstrates textcolor/textbackground (Turbo-C-compatible names). */ #include #include #include #include #include #include static uint8_t buff[] = {0xE4, 0x1B}; uint8_t get_style(uint32_t idx) { return (uint8_t)((buff[idx >> 2] >> ((idx & 3) << 1)) & 3u); } void set_style(uint32_t idx, uint8_t style) { buff[idx >> 2] = buff[idx >> 2] & ~(3u << ((idx & 3) << 1)) | ((style & 3u) << ((idx & 3) << 1)); } int main(void) { for(int i = 0; i < 8; i++) { dec8(get_style(i)); puts(""); } for(int i = 0; i < 8; i++) { set_style(i, (i + 1) & 3); } puts(""); for(int i = 0; i < 8; i++) { dec8(get_style(i)); puts(""); } cputs("Press any key to exit..."); (void)getchar(); return 0; }