+Karl G Posted December 19, 2019 Share Posted December 19, 2019 Normally if you wanted to set one of the player graphics to display a number, you would do something like an "on ... goto" statement, defining a new digit for each of the digits. To save time and code, you can instead make use of the built-in graphics for the score digits with just a few lines of code. First, in your program's definitions, you will want to define a couple of constants that contain the two bytes of the ROM address where the score digits are defined: const score_table_high = >scoretable const score_table_low = <scoretable The code to change the player graphic to a number follows. This example uses player 0, but you can change the 0s to 1s if you wish to use player 1. Also, I use the variable DisplayNumber here, which you will want to change to whatever variable holds the number to be displayed: temp1 = DisplayNumber player0height = 7 player0pointerhi = score_table_high temp1 = temp1 * 8 player0pointerlo = temp1 + score_table_low That's all that's needed. You will set the color, position, and NUSIZx value as normal. Note that you will probably want to use a double-width NUSIZx value for the number to look the same proportionally as the score digits (larger, but the same dimensions). 3 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 19, 2019 Share Posted December 19, 2019 (edited) Three and a half questions: 1. Does this work with all kernels? (Would the numbers be upside down when using some kernels?) 2. Since bB uses the lower temp variables for various jobs will there be any problems using temp1? 3. Is it OK if I adapt your post and put it on the bB page? Edited December 19, 2019 by Random Terrain Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 19, 2019 Author Share Posted December 19, 2019 What is the half question? 1) I've only tested this with the standard kernel so far. I am pretty sure it won't work with the DPC+ kernel. it will probably work with the Multisprite kernel, but I need to check variable names, and test it. 2) it didn't cause any problems when I used it, but feel free to change it to something like temp4 if you post it. 3) Sure. 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 19, 2019 Share Posted December 19, 2019 Just tried it with DPC+ and you're right. Doesn't work. Is there anything that could be changed to make it work? Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 19, 2019 Author Share Posted December 19, 2019 I honestly don't know the internals of the DPC+ kernel that well. I'll take a look at how the score itself is done to see if there's an easy way to do that. 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 20, 2019 Share Posted December 20, 2019 (edited) I stuck this in an existing example program. Double click the fire button to change the number: ex_numbers_standard_kernel_with_coordinates_2019y_12m_22d_0019t.bin (To change the size of a selected object, hold down the fire button and press left or right to cycle through the different sizes.) Edited December 22, 2019 by Random Terrain 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 20, 2019 Share Posted December 20, 2019 The multisprite kernel has a long bar connected to the number: ex_numbers_with_multisprite_9_objects_2019y_12m_19d_2241t.bin Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 20, 2019 Author Share Posted December 20, 2019 It seems to work with the Multisprite kernel for any of the virtual sprites, but not P0. I've made an example program showing the difference. I'm wondering if @RevEng might have any ideas why P0 won't work in this case? hellomulti.bas hellomulti.bas.bin 1 Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 20, 2019 Share Posted December 20, 2019 It looks like the multisprite always puts out the player0 first/bottom-most data line. The bB interpreter always inserts an extra zeroed line for graphics for it, but not the virtual sprites. The player0 pointer is updated on each kernel line to maintain this. I'm thinking batari didn't have enough kernel time where he needed the player graphic update to happen, so he used this technique as a trade-off. I don't think you'll get your technique to work here, without adding a bunch of otherwise unused zeroes to the top of each score digit. If you decide to do this, you'll need to adjust the starting position of the score graphics to allow for the padding. 2 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 20, 2019 Author Share Posted December 20, 2019 Thanks. I think this could still be a useful trick for users of the multisprite kernel to use with the virtual sprites, at least. It's probably not worth hacking the score graphic data just to make it work with P0, however, but it's good to know why that one did not work. 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 20, 2019 Author Share Posted December 20, 2019 I need to test it when I am in front of my computer again, but I think this might also mean that the documented trick to make sprites Melt Away by decreasing the height variable might also not work with P0 and the multisptite kernel. If this is true, then that would also be worth documenting. 2 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 20, 2019 Share Posted December 20, 2019 Just in case somebody asks in the future, is there any way to shoehorn a two digit number into a sprite using this technique? For Tone Toy 2008, the numbers had to be drawn and placed in sprite data. If it could be done without making a custom strip of numbers, that would be very handy. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted December 20, 2019 Author Share Posted December 20, 2019 If you made a custom score font, and made use of hex digits, you could do 0 through 15 that way, but not above that. 1 Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 20, 2019 Share Posted December 20, 2019 1 hour ago, Karl G said: I need to test it when I am in front of my computer again, but I think this might also mean that the documented trick to make sprites Melt Away by decreasing the height variable might also not work with P0 and the multisptite kernel. If this is true, then that would also be worth documenting. I just tried it out. It works fine, since the sprite data is upside down. The last P0 data to be displayed is actually the first byte in the table. i.e the zero value. To make it stay in place and "melt" you need to also add to player0y as you decrease player0height, otherwise it rolls up like a roller blind. 2 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 22, 2019 Share Posted December 22, 2019 I finally got the multisprite version working correctly: ex_numbers_with_multisprite_9_objects_2019y_12m_22d_0043t.bin I'll post a link to the new section on the bB page as soon as it's done. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 22, 2019 Share Posted December 22, 2019 It's on the bB page now: https://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#easy_way_to_set_player_graphic_to_number 2 Quote Link to comment Share on other sites More sharing options...
+KaeruYojimbo Posted March 18, 2020 Share Posted March 18, 2020 I want to thank you guys for posting this. I just used it to create a 3-2-1 countdown for the game I'm working on. 1 Quote Link to comment Share on other sites More sharing options...
KevKelley Posted April 19, 2020 Share Posted April 19, 2020 Curious. I was playing around with this to swap player1 for a number. Is it possible to perform this in reverse? And have it to where you swap a sprite into the score? As an example, say the game starts. Instead of a score it scrolls "PRESS FIRE!" and when you do it changes the data back to numbers. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted April 19, 2020 Author Share Posted April 19, 2020 I'll have to take a look, but I think the pointer to the graphics for the score is hardcoded somewhere, and is set each frame from non-persistant variables, so it's not just a simple matter of changing a pointer to point at new data. I'll look at this sometime later to confirm. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted April 19, 2020 Author Share Posted April 19, 2020 I checked, and it was as I suspected. The scoretable is hardcoded in a couple of places, and there's no permanent pointer to the scoretable graphics. It could be hacked to use a persistent pointer and allow the graphics to be used to change on the fly, but it would require sacrificing two variables for that purpose. If it were done, it might not work the way you were picturing. You would define graphics to replace the normal score digits, and set the score to load the appropriate graphics. You can fit two skinny letters in each digit, so for your "PRESS FIRE!" example, you would make the graphics for digit 0 be "PR" and digit 1 be "ES", and so on all the way through digit 5 just being the "!". You could then set the pointer to use the new graphics, and set the score=012345 to get the message you want, then change the pointer and the score back after you no longer need that. If you or anyone else has a specific need for that kind of hacked solution, I can whip something up. Keep in mind that it will take a lot of ROM if you have a lot of messages due to needing to create every letter combo as its own unique graphic as opposed to using something like the text minikernel for this functionality. Quote Link to comment Share on other sites More sharing options...
KevKelley Posted April 19, 2020 Share Posted April 19, 2020 That is very interesting. I don't really have a particular use for that. I was just curious if it was a simple swap. That would be an interesting effect if you had the free space for it. But then it might be better to just use the text minikernel at that point. 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.