Jump to content
IGNORED

What might be causing this weird character display issue?


Tickled_Pink

Recommended Posts

I'm trying to add a score display to my game but getting some weird results. It's as if the character set is inverted:

This should show T90 (it's a timer)

image.png.fde574e906afdc04c319b907ce7dc145.png

I'm using the font graphic in the helloworld.bas sample in the 7800Basic Github repo. This has been copied directly:

 

image.png.127dcd88ebbba0ba41f793548c546c40.png
And it's drawn with this:
 

 image.png.bd30e82c5427101a31151a91a9941f43.png

image.png.7edc90c4bfb27f6aa8abb51e56c664df.png

image.png

Link to comment
Share on other sites

7 minutes ago, Tickled_Pink said:

Still have issues with the numbers. Hell with it. The font/character system is a little sketchy. Wasted an entire day on this so I'll try rolling my own.

It seems to work for the rest of us. 🙂 Usually when getting help from the community you will need to share code that can be compiled and tested to get useful troubleshooting advice. In cases where I'm not ready to share my code, I put the problematic part in a simple test case to demonstrate the problem, and share that instead. Sometimes in the course of doing so I figure out for myself what I did wrong.

  • Like 3
Link to comment
Share on other sites

3 minutes ago, Muddyfunster said:

What KarG said, plus if you post it in the programming subforum, it's more likely to get folks who can help to notice it.

 

If you want to zip up your project and post it, likely that someone can take a look :)

 

That was the original idea but ended up posting it in the wrong forum.

 

Zipping it up sounds like a plan. 👍

Link to comment
Share on other sites

Pretty sure plotvalue expects the digits to be at the start of the graphic you're using, which isn't the case for the one you're using.  You'll notice those 2 numbers being plotted by the plotvalue are sprites found very close to the start of atascii.png.

 

Perhaps the easiest way around this is to have a secondary tile set with just the digits included, call it digits.png or something. Then use that for the graphic used in the plotvalues.

  • Like 1
Link to comment
Share on other sites

Yeah, I've tried that as well but despite providing the name of the graphic in the plot value, it seems to get confused and displays special characters, suggesting it's still using the same character set as the plot chars.

 

Hmmm ... perhaps if I tried displaying with plotvalue first.

Edited by Tickled_Pink
Link to comment
Share on other sites

I believe it's not the start of the graphic but the start of the character set. When you use the 'characterset' command, internally the 7800 is being pointed to the page in memory where the graphics data sits, and all 'indirect' graphics (tiles) are offset from that value. 

What I like to do is make sure the first characters in the set are 0-9 then A-Z so that the offsets match any hex values I might use for testing.

Link to comment
Share on other sites

On 7/8/2023 at 10:24 PM, SmittyB said:

I believe it's not the start of the graphic but the start of the character set. When you use the 'characterset' command, internally the 7800 is being pointed to the page in memory where the graphics data sits, and all 'indirect' graphics (tiles) are offset from that value. 

What I like to do is make sure the first characters in the set are 0-9 then A-Z so that the offsets match any hex values I might use for testing.

Honestly, I've given up with it. The manual isn't great on this. Makes it seem far easier than it actually is. I finally figured out what my initial issues with Plotchars was but I cannot for the life of me get plotvalue to work. At all.

 

I noticed what it seemed to be doing. It was offsetting the values against the first special character in the character set. So I though, okay, I'll copy the numbers over the top of the first 10 special characters. Job done. Except NO. Although those special characters no longer exist in the PNG, it's STILL displaying them. WTAF?? I've removed the cache files from VS Code. Still the same. I've now created a new font image with just the numbers and uppercase. Now it's displaying weird characters.

 

So, yeah. Only way I'm going to get this working is to write my own code to convert the numbers into text and use plotchars as that's the only thing I can get working.

Link to comment
Share on other sites

  • 2 weeks later...

Don't give up! This one trips everyone up at first.

 

I updated the atascii.png file and renamed it to atascii2.png. See the limited characters below. This helps with defining the characters and limiting the amount of memory used defining characters.

 

image.png.cc5eeb6c76c825251da8333862e3e839.png

 

Then, in your code adding the graphic and declaring the font, change it to this:

 rem **import the characterset png...
 incgraphic atascii2.png 320A 1 0
 rem incgraphic digits.png

 rem **set the current character set...
 characterset atascii2
 alphachars '0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_*'

 rem **set the letters represent each graphic character...
 ;alphachars ASCII - this gets replaced with the code above

The numbers are at the beginning of the image and the alphachars command allows you to map the characters to the 8x8 pixel image blocks in the atascii2.png image.

 

If you need to add any additional characters, just add an additional 8x8 pixels to the end of the graphic and then add the extra character in the alphachars definition. (Remember to escape characters such as quotes to prevent errors.)

 

And then update your timer display:

 rem ** Draws the timer **
_drawTimer

 plotchars 'T' 0 0 0
 plotvalue atascii2 0 timer 2 4 0
 
 return

 

This seems to work for me. But I'm seeing the following:

image.png.fe7b1b8c01fa572e50d7291d5c79e88f.png

 

Now, getting the value of the timer may be a different challenge. The value is supposed to be 90 here, correct? Looking at the documentation, the formatting for plotvalue is:

 

plotvalue digit_gfx palette_# variable #_of_digits x y [extrawide]

 

And it appears you have this formatting correct, but the plotvalue command apparently only displays BCD encoded numbers. According to the documentation: "variable is the variable containing the BCD value you wish to display on the screen."

So the value needs to be converted to BCD format or the variable needs to be declared as a BCD format. Look under the section https://www.randomterrain.com/7800basic.html#score_variables_and_bcd_variables The limitations of 8-bit architecture aren't natural to modern-day programmers used to unlimited 64-bit memory spaces. We are spoiled! 

 

So change 

 timer = 90

to

 timer = $90

and that should fix the values (see below).

image.png.cb9e78fa7754c262bcdd87e3b4f1837c.png

Just don't forget to also subtract using BCD so instead of "timer = timer - 1" it would be "timer = timer - $1"

 

@Muddyfunster and @Karl G, thanks for taking the time to help out those beginning the journey. 7800BASIC is a great tool that speeds up development and makes the entire ecosystem more accessible.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...