[+SC3000] Printing text in tile mode

Post Reply
helmha
Member
Posts: 10
Joined: Sun Sep 12, 2021 10:37 am

[+SC3000] Printing text in tile mode

Post 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.
User avatar
dom
Well known member
Posts: 1825
Joined: Sun Jul 15, 2007 10:01 pm

Re: [+SC3000] Printing text in tile mode

Post by dom »

You’ll need to switch screen modes. See this wiki page:

https://github.com/z88dk/z88dk/wiki/Classic-TMS9918
barbeque
New member
Posts: 9
Joined: Mon Nov 18, 2019 5:48 pm

Re: [+SC3000] Printing text in tile mode

Post 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.
User avatar
dom
Well known member
Posts: 1825
Joined: Sun Jul 15, 2007 10:01 pm

Re: [+SC3000] Printing text in tile mode

Post 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.
barbeque
New member
Posts: 9
Joined: Mon Nov 18, 2019 5:48 pm

Re: [+SC3000] Printing text in tile mode

Post 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!
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 1825
Joined: Sun Jul 15, 2007 10:01 pm

Re: [+SC3000] Printing text in tile mode

Post 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?
barbeque
New member
Posts: 9
Joined: Mon Nov 18, 2019 5:48 pm

Re: [+SC3000] Printing text in tile mode

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 1825
Joined: Sun Jul 15, 2007 10:01 pm

Re: [+SC3000] Printing text in tile mode

Post 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.
barbeque
New member
Posts: 9
Joined: Mon Nov 18, 2019 5:48 pm

Re: [+SC3000] Printing text in tile mode

Post 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!
Post Reply