tests: add hello2, simple, banktest smoke tests
hello2 — stdio vs conio output API comparison (fast/no-attr vs
slower/attributed), also exercises textcolor/textbackground.
simple — packed 2-bit style array bit-twiddling smoke test.
banktest — __banked function calls across two explicit banks in huge
memory mode.
hello2.c updated to call the renamed gettextmode/settextmode (see the
conio rename in 5e5e70d).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <gfx.h>
|
||||
#include <sprinter.h>
|
||||
#include <sprinter_exit.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
errno = -1;
|
||||
int16_t a0 = 0, a1 = 0;
|
||||
a0 = get_text_attr();
|
||||
|
||||
uint8_t vMode = gettextmode();
|
||||
settextmode(TEXT_MODE_80x32);
|
||||
|
||||
/* Wipe the screen with a known attribute so stdio printf/puts inherit
|
||||
* a clean colour for the cursor. */
|
||||
clrscr_attr(COLOR(COLOR_LIGHTGRAY, COLOR_BLACK));
|
||||
|
||||
/* --- stdio set: fast, no attribute ------------------------------- */
|
||||
puts("hello (stdio) - fast PCHARS, ambient colour");
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
/* --- conio set: applies textcolor / textbackground --------------- */
|
||||
textcolor(COLOR_YELLOW);
|
||||
textbackground(COLOR_BLUE);
|
||||
cputs("conio: yellow on blue\r\n");
|
||||
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
textcolor(COLOR_LIGHTRED);
|
||||
textbackground(COLOR_BLACK);
|
||||
cprintf("cprintf %d %d %s\r\n", 42, -7, "args");
|
||||
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
/* set_text_attr / textattr replace the whole byte. */
|
||||
textattr(COLOR(COLOR_LIGHTGREEN, COLOR_BLACK));
|
||||
cputs("conio: light-green via textattr\r\n");
|
||||
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
/* Opting out of attribute control — conio falls back to fast path. */
|
||||
set_text_attr(KEEP_EXIST_ATTR);
|
||||
cputs("conio with KEEP_EXIST_ATTR (fast path)\r\n");
|
||||
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
a1 = get_text_attr();
|
||||
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
/* Back to a normal attribute so the goodbye reads cleanly. */
|
||||
textattr(COLOR(COLOR_LIGHTCYAN, COLOR_BLACK));
|
||||
|
||||
printf("printf: a0=%d (initial attr)\n", a0);
|
||||
|
||||
cprintf("a0=%d a1=%d now=%d errno=%d\n\r",
|
||||
a0, a1, get_text_attr(), errno);
|
||||
// cprintf("a0=%d a1=%d",
|
||||
// a0, a1);
|
||||
// cprintf(" now=%d errno=%d\n\r",
|
||||
// get_text_attr(), errno);
|
||||
#ifdef DEBUG_RT
|
||||
printf("w2_self_allocated = %u\n", w2_self_allocated);
|
||||
#endif
|
||||
cputs("Press any key to exit...");
|
||||
|
||||
(void)getchar();
|
||||
settextmode(vMode);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user