| 2324 | */ |
| 2325 | |
| 2326 | void early_raw_print(const char *s) |
| 2327 | { |
| 2328 | if (console.hConOut == NULL) |
| 2329 | return; |
| 2330 | |
| 2331 | nhassert(console.cursor.X >= 0 && console.cursor.X < console.width); |
| 2332 | nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height); |
| 2333 | |
| 2334 | WORD attribute = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; |
| 2335 | DWORD unused; |
| 2336 | |
| 2337 | while (*s != '\0') { |
| 2338 | switch (*s) { |
| 2339 | case '\n': |
| 2340 | if (console.cursor.Y < console.height - 1) |
| 2341 | console.cursor.Y++; |
| 2342 | /* fall through */ |
| 2343 | case '\r': |
| 2344 | console.cursor.X = 1; |
| 2345 | break; |
| 2346 | case '\b': |
| 2347 | if (console.cursor.X > 1) { |
| 2348 | console.cursor.X--; |
| 2349 | } else if(console.cursor.Y > 0) { |
| 2350 | console.cursor.X = console.width - 1; |
| 2351 | console.cursor.Y--; |
| 2352 | } |
| 2353 | break; |
| 2354 | default: |
| 2355 | WriteConsoleOutputAttribute(console.hConOut, &attribute, |
| 2356 | 1, console.cursor, &unused); |
| 2357 | WriteConsoleOutputCharacterA(console.hConOut, s, |
| 2358 | 1, console.cursor, &unused); |
| 2359 | if (console.cursor.X == console.width - 1) { |
| 2360 | if (console.cursor.Y < console.height - 1) { |
| 2361 | console.cursor.X = 1; |
| 2362 | console.cursor.Y++; |
| 2363 | } |
| 2364 | } else { |
| 2365 | console.cursor.X++; |
| 2366 | } |
| 2367 | } |
| 2368 | s++; |
| 2369 | } |
| 2370 | |
| 2371 | nhassert(console.cursor.X >= 0 && console.cursor.X < console.width); |
| 2372 | nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height); |
| 2373 | |
| 2374 | SetConsoleCursorPosition(console.hConOut, console.cursor); |
| 2375 | |
| 2376 | } |
| 2377 | #endif |
| 2378 | |
| 2379 | /* nethack_enter_consoletty() is the first thing that is called from main |
nothing calls this directly
no outgoing calls
no test coverage detected