Tickled_Pink Posted July 8, 2023 Share Posted July 8, 2023 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) I'm using the font graphic in the helloworld.bas sample in the 7800Basic Github repo. This has been copied directly: And it's drawn with this: Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted July 8, 2023 Author Share Posted July 8, 2023 Ugh. Forget what I said. I'd copied the wrong font png. D'oh. Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted July 8, 2023 Author Share Posted July 8, 2023 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. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted July 8, 2023 Share Posted July 8, 2023 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. 3 Quote Link to comment Share on other sites More sharing options...
+Muddyfunster Posted July 8, 2023 Share Posted July 8, 2023 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 3 Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted July 8, 2023 Author Share Posted July 8, 2023 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. 👍 Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted July 8, 2023 Author Share Posted July 8, 2023 Here's the zip. Arcadia78.zip Quote Link to comment Share on other sites More sharing options...
Mord Posted July 8, 2023 Share Posted July 8, 2023 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. 1 Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted July 8, 2023 Author Share Posted July 8, 2023 (edited) 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 July 8, 2023 by Tickled_Pink Quote Link to comment Share on other sites More sharing options...
+SmittyB Posted July 8, 2023 Share Posted July 8, 2023 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. Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted July 11, 2023 Author Share Posted July 11, 2023 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. Quote Link to comment Share on other sites More sharing options...
+saxmeister Posted July 25, 2023 Share Posted July 25, 2023 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. 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: 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). 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.