How to display text on the screen?
-
- DCEmu Fast Newbie
- Posts: 19
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Mon Aug 30, 2021 6:42 pm
- Has thanked: 0
- Been thanked: 0
How to display text on the screen?
Hey everyone, I have a question, so I want make a program that displays “Hello, Dreamcast!” on the screen, but how do I display text on the screen?
- BlueCrab
- The Crabby Overlord
- Posts: 5659
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: How to display text on the screen?
Assuming you're using a relatively modern version of KOS, the easiest way to do a simple "hello world" type thing with text on the screen is to use fb_console, and then just printf as normal. Essentially, this is all you need:
Now, if you wanted to go fancier, you could use the biosfont functionality directly. For that, I'd refer you to this example which shows the basic approach to using it to draw to the framebuffer.
Code: Select all
#include <stdio.h>
#include <kos/dbgio.h>
int main(int argc, char *argv[]) {
/* Switch printf to draw to the screen with fb_console */
dbgio_dev_select("fb");
/* The requisite line... */
printf("Hello, Dreamcast!\n");
return 0;
}
-
- DCEmu Fast Newbie
- Posts: 19
- Joined: Mon Aug 30, 2021 6:42 pm
- Has thanked: 0
- Been thanked: 0
Re: How to display text on the screen?
UDATE: it compiled successfully, but when I try to test it on real hardware it just goes to a black screen. what should i do now?
- BlueCrab
- The Crabby Overlord
- Posts: 5659
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: How to display text on the screen?
It probably isn't actually going to a blank screen, but rather exiting quickly... This version will sit around a bit longer after the text appears, in this case 10 seconds:
Code: Select all
#include <stdio.h>
#include <kos/dbgio.h>
#include <kos/thread.h>
int main(int argc, char *argv[]) {
/* Switch printf to draw to the screen with fb_console */
dbgio_dev_select("fb");
/* The requisite line... */
printf("Hello, Dreamcast!\n");
/* Sleep for a bit to see the results. The amount here is in milliseconds. */
thd_sleep(10 * 1000);
return 0;
}
-
- DCEmu Fast Newbie
- Posts: 19
- Joined: Mon Aug 30, 2021 6:42 pm
- Has thanked: 0
- Been thanked: 0
Re: How to display text on the screen?
Thanks I will try that when I get home, also is there and sdl for the Dreamcast that I can follow?
- BlueCrab
- The Crabby Overlord
- Posts: 5659
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: How to display text on the screen?
SDL? Yes, there's a port of version 1.2.x of SDL in kos-ports. It's not great (because it isn't really designed for how the Dreamcast hardware works), but it is there and you can use it if you really want.
I wouldn't recommend it, though.
There is not a port of SDL 2.x, and I wouldn't expect a full port of that to ever be available (once again, because it is designed for a much different hardware target than what the Dreamcast is).
I wouldn't recommend it, though.
There is not a port of SDL 2.x, and I wouldn't expect a full port of that to ever be available (once again, because it is designed for a much different hardware target than what the Dreamcast is).
-
- DCEmu Newbie
- Posts: 7
- Joined: Tue Nov 29, 2022 7:09 am
- Location: Where sailors hang out
- Has thanked: 9 times
- Been thanked: 3 times
Re: How to display text on the screen?
Is there a way to remove the black background behind the text? I just want to display the game score without importing complex libraries and lowering frame rate.