Page 1 of 1

[+SC3000] Printing text in tile mode

Posted: Wed Dec 15, 2021 1:38 pm
by helmha
Hello there.

I cannot get (c)printf to work in tile mode but it does work in bitmap mode. putch etc isn't what I'm looking for because I need (c)printf to print out some debugging information on the screen.

Is there another way to print text in tile mode? I'm making a ROM if that matters.

Thanks in advance.

Re: [+SC3000] Printing text in tile mode

Posted: Thu Dec 16, 2021 12:25 am
by dom
You’ll need to switch screen modes. See this wiki page:

https://github.com/z88dk/z88dk/wiki/Classic-TMS9918

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 4:15 am
by barbeque
Hi, I'm having a similar problem even after switching screen modes. Here is my program:

Code: Select all

#include <stdio.h>
#include <conio.h>
#include <sys/ioctl.h>

void main() {
        // Setup
        textcolor(BLACK);
        textbackground(WHITE);
        int mode = 1;
        console_ioctl(IOCTL_GENCON_SET_MODE, &mode);

        // Actual program begins
        printf("Hello World\n");
}                
I'm building with the following command line:

Code: Select all

zcc +sc3000 -subtype=rom -pragma-redirect:CRT_FONT=_font_8x8_clairsys -ohello.sc hello.c
When I load it in MAME 0227, the screen mode does appear to change (the display becomes a white rectangle with a black border) but the text I printed is not visible. If I try it without the call to console_ioctl, I get what looks like text entered into the tile map, but it's garbage, likely because the font hasn't loaded.

I suspect I'm missing a setup step, but I haven't figured it out yet. Maybe conio and the TMS9918 libraries aren't meant to mingle? The MSX examples in example/msx also don't seem to work for the SC-3000 under MAME if I change the platform in the Makefile to sc3000, but I may be passing a bad option to the compiler there, so it's probably less of a concern.

I'm on z88dk-osx-latest as of a few hours ago.

Thanks in advance for any help! This is a great toolset with such ambitious goals.

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 2:37 pm
by dom
Everything should work together - so I've probably mucked something up somewhere. Normally I test with takeda rather than mame so that might be the cause of the problem as well.

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 3:42 pm
by barbeque
Unfortunately, I had no luck with the eSC-3000 emulator either - in fact, it seems to be even more (realistically?) broken, with the same garbage tile everywhere and no evidence of having text in the console at all.

Will investigate a little further - do you have a known-good Hello World program I can try out, to rule out my own noobishness? :)

Thank you for the quick reply!

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 7:19 pm
by dom
As I said it's probably something silly I did....and sure enough it turned out to be an off by one in the tile position calculation.

Row 0 was ending up somewhere random in VDP memory I've corrected the repo now, but can you just try inserting an extra line feed before the "Hello world" bit?

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 7:37 pm
by barbeque
Thanks for the quick fix, I know it can be hard to keep track of what in TMS9918 memory is where, especially if you're trying to do fast multiplication on a z80.

I tried inserting an extra ZX-protocol line-feed like this:

Code: Select all

printf("%cHello World\n", 10);
It made no difference on MAME, but on eSC-3000 it now shows some garbled text in the corner where I would expect the text to have appeared. I think we're on the right track.

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 8:39 pm
by dom
One valuable thing that I really should do is to actually run your command line!

Can you add -create-app onto the command line and load the generated 32k file - that certainly makes the difference in takeda.

Edit: I've just corrected the wiki documentation since it omitted that option for some reason.

Re: [+SC3000] Printing text in tile mode

Posted: Tue Apr 12, 2022 10:41 pm
by barbeque
That worked, thanks. It took me a little bit to realize there was now a file called "hello.rom" produced from -create-app, but running that made it work properly in MAME!

I will upgrade to tomorrow's nightly when it comes out, thank you again for your swift help!