Coolcrab Posted December 5, 2017 Share Posted December 5, 2017 I am quite confused about math in batari. I want to set the score to a certain value as X+n*Y. With n being the nth level that the player is in. So lets say the game starts with score=1000, then in the next level I would like it to be set to 1050, then 1100, 1150, etc. I tried doing this as: if score then m=m+1 : score = 1000 + 64 * m But that doesn't work. I assume that this doesn't work because it only lets you do one operation after the equal sign? You also can't make the m go up by 50 at a time, as it will go over 265 very fast. (And as far as I understand that is the limit for all variables apart from score?) Is there some way to do this? I want something that ads roughly 50 each time. Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/ Share on other sites More sharing options...
+Random Terrain Posted December 5, 2017 Share Posted December 5, 2017 Have you looked at this section of the bB page yet? randomterrain.com/atari-2600-memories-batari-basic-commands.html#bcd Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-3905102 Share on other sites More sharing options...
Coolcrab Posted December 5, 2017 Author Share Posted December 5, 2017 Hmm, I'm sill not sure. This would still overflow the a if its over 256 right? if s{3} then dec a = a + $20 score = score + a Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-3905203 Share on other sites More sharing options...
+Random Terrain Posted December 5, 2017 Share Posted December 5, 2017 If nobody pops up with a better idea, you might have to do a loop. Maybe something like this: score = 1000 for temp5 = 0 to m score = score + 50 next 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-3905207 Share on other sites More sharing options...
RevEng Posted December 5, 2017 Share Posted December 5, 2017 Multiplying by arbitrary numbers and mixing in BCD numbers can get a bit complicated on the 6502. I like the iterative adding loop RT, as it's small and simple. An alternative way to do it, is to do each step of the multiplication on new frames, by adding something like the following to your vblank or game loop code... dim fifties=m if fifties>0 then fifties=fifties-1:score=score+50 Then a simple "fifties=fifties+level" (or "fifties=fifties+(level*3)") whenever you want to add to the score should work fine. The main bit of care you need to take is when you change "fifties", you should add to it rather than setting it, in case it's currently in the process of draining. You also might need to take a bit of care not to overflow it too, if you allow a lot of quick scoring. I rather like the rolling score effect this results in. I did something similar in 21 Blue. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-3905266 Share on other sites More sharing options...
Coolcrab Posted December 6, 2017 Author Share Posted December 6, 2017 This worked, thanks! I went for the loop solution. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-3905956 Share on other sites More sharing options...
freshbrood Posted March 16, 2021 Share Posted March 16, 2021 On 12/5/2017 at 1:36 PM, Coolcrab said: Hmm, I'm sill not sure. This would still overflow the a if its over 256 right? if s{3} then dec a = a + $20 score = score + a What is the $ sign in front of the 20 for? I recall somewhere reading that it's simple to change the indivibual numbers in the score/it has it's own built in 3 variables? But I can't find where I read that anywhere. I simply want to be able to toggle individual numbers in the score off and on without affecting the overall score or other numbers in it. I know this is easy but I can't remember where I saw how to do it. Please help Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4780135 Share on other sites More sharing options...
+Gemintronic Posted March 17, 2021 Share Posted March 17, 2021 To be safe I always keep my score related math to: "score = score + var" or "score = score - var". Basically, perform your more complicated math on var beforehand. Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4780200 Share on other sites More sharing options...
bogax Posted March 17, 2021 Share Posted March 17, 2021 (edited) 2 hours ago, freshbrood said: What is the $ sign in front of the 20 for? I recall somewhere reading that it's simple to change the indivibual numbers in the score/it has it's own built in 3 variables? But I can't find where I read that anywhere. I simply want to be able to toggle individual numbers in the score off and on without affecting the overall score or other numbers in it. I know this is easy but I can't remember where I saw how to do it. Please help The $ indicates a hexadecimal number In decimal the digits are 0..9 in hexidecimal the digits are 0..15 except we don't use decimal numbers for 10..15 we use A..F So the hexidecimal digits are 0..F normally you'd get a carry from the lo digit to the hi digit at F in hexadecimal 1 + F = $10 which is 16 in decimal With bcd (binary coded decimal) the digits only go from 0..9 and the carry comes from any number over 9 So $20 is hexadecimal for (decimal) 32 (2 * 16) which is interpreted as 20 decimal in bcd (normally 20 decimal would be $14 in hexadecimal ie 1*16 + 4) The score is six bcd digits in three bytes except they are backwards in memory score[0] to score[2] from HIGHEST to lowest each bcd digit is a 4 bit nibble RT has some stuff about dealing with nibbles Edited March 17, 2021 by bogax 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4780266 Share on other sites More sharing options...
+Random Terrain Posted March 17, 2021 Share Posted March 17, 2021 11 hours ago, freshbrood said: What is the $ sign in front of the 20 for? Have you looked at these sections: Decimal Numbers Hexadecimal Numbers What is a BCD Compliant Number? 11 hours ago, freshbrood said: I recall somewhere reading that it's simple to change the individual numbers in the score/it has it's own built in 3 variables? But I can't find where I read that anywhere. I simply want to be able to toggle individual numbers in the score off and on without affecting the overall score or other numbers in it. I know this is easy but I can't remember where I saw how to do it. Please help That nybble example program that bogax linked to should help. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4780439 Share on other sites More sharing options...
freshbrood Posted March 18, 2021 Share Posted March 18, 2021 Thanks. Also I noticed in batari only 7 pixels of the score numbers display, at least in the first number on the right. The editor allows for changing all 8 pixels but the furthest left column doesn't display. Is there any way to get all 8 pixels of the score # to show in batari? Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4781002 Share on other sites More sharing options...
+Gemintronic Posted March 18, 2021 Share Posted March 18, 2021 2 minutes ago, freshbrood said: Thanks. Also I noticed in batari only 7 pixels of the score numbers display, at least in the first number on the right. The editor allows for changing all 8 pixels but the furthest left column doesn't display. Is there any way to get all 8 pixels of the score # to show in batari? The far left and right columns of the score font can sometimes bleed into other digits. It's a safety padding thing 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4781005 Share on other sites More sharing options...
freshbrood Posted March 18, 2021 Share Posted March 18, 2021 17 minutes ago, Gemintronic said: The far left and right columns of the score font can sometimes bleed into other digits. It's a safety padding thing Annnnd I also just noticed that it does not seem centered in batari, but off by a few pixels (about one digit) to the right. Is there any way to center it and/or make sure all 8 pixels display? -in batari standars kernel? Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4781013 Share on other sites More sharing options...
+Karl G Posted March 18, 2021 Share Posted March 18, 2021 1 minute ago, freshbrood said: Annnnd I also just noticed that it does not seem centered in batari, but off by a few pixels (about one digit) to the right. Is there any way to center it and/or make sure all 8 pixels display? -in batari standars kernel? That can't be helped, either, and for the same reason. The score kernel manages to draw the score, and part of the playfield on either side of the score to be the pfscore bars. There's not quite enough time to do everything, so a small amount of the score gets cut off as you have seen, and the bB score fonts are designed with this limitation in mind. The placement of the score is a result of where the graphics updates need to happen in the score kernel based on the rest of the timing, so any shifting of this will cause digit corruption. So - known issue, but there's no real fix for it. It's just a quirk of bB. ? 1 2 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4781015 Share on other sites More sharing options...
+Gemintronic Posted March 20, 2021 Share Posted March 20, 2021 You can think of the CPU as an artist with a small set of crayons labeled player0, player1, missile0, missile1, ball and playfield. The artist can only draw by dragging a crayon line by line across the paper. When he reaches the far end of the page he can go down a row and start draggin' those crayons again. To further constrain him each crayon can only be dragged so far. So, if he runs out of player0 crayon he must choose another available crayon for a longer run. Any other action by the artist makes the crayon stop dragging BUT the next place he could draw still moves across the page. That includes the thought process to switch crayons. The bB score kernel switches between player0 and player1 to get 6 digits. It also needs to start drawing the score as close to the center as possible. All this requires the CPUs full attention before even trying to process game logic. This is a bad explanation by someone who doesn't understand what he's talking about. Should check out this book: https://www.amazon.com/Racing-Beam-Computer-Platform-Studies/dp/026201257X More accurate description here: https://atariage.com/forums/topic/32481-session-21-sprites/ Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-4783081 Share on other sites More sharing options...
alfredtdk Posted February 25 Share Posted February 25 Resurrecting this topic, I'm having difficulty setting the score at 000000, if I make a target worth -1, in this subtraction it already drops to the maximum score that the Atari supports, 999,999 points.What would be the command to fix? So that subtraction does not occur below 000000. I'm on the standard Batari Basic kernel. Taking advantage of the opportunity in Batari Basic, I can freeze the game image when I reach a certain score, in this case the maximum score is 999,999. And what happened in most Activision games, in some like the classic Enduro, the odometer score was restart after reaching 999,999. Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5417502 Share on other sites More sharing options...
RevEng Posted February 25 Share Posted February 25 The first part of this is to break out the score into 3 different variables... dim sc1 = score dim sc2 = score+1 dim sc3 = score+2 Then you can do one of two things... 1. you can test if the score is zero prior to subtraction scorepenatyroutine if sc1=0 && sc2=0 && sc3=0 then return score=score-1 return 2. you can bump any negative scores back to zero checknegativescore if sc1=$99 && sc2=$99 && sc3=$99 then score=0 return If there are penalties greater than -1, you'll need to adjust how you handle sc3 for values less than -100, or sc3+sc2 for values less than -10000. If my reason for using hex numbers in the example isn't clear, check out the docs on BCD numbers. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5417512 Share on other sites More sharing options...
alfredtdk Posted February 26 Share Posted February 26 batari Basic v1.7 (c)2022 2600 Basic compilation complete. --- Unresolved Symbol List sc1 0000 ???? (R ) sc2 0000 ???? (R ) sc3 0000 ???? (R ) qtcontroller 0000 ???? (R ) 1389 bytes of ROM space left Fatal assembly error: Source is not resolvable. Build complete. Exit code: 1 Cleaning up files generated during compilation... I'm having a problem getting these dim variables to be recognized when compiling. Subroutines were added before the main loop. Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5418170 Share on other sites More sharing options...
RevEng Posted February 26 Share Posted February 26 For some reason some weird underscore characters got added to my post, for those dim statements. I've edited my post now to remove them. If you have them in your source, remove them and try again. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5418255 Share on other sites More sharing options...
alfredtdk Posted February 26 Share Posted February 26 I carried out some quick tests, it compiles after removing the underscores, but the first subroutine applied breaks the code or gives a blue screen if you are not in developer mode in Stella. The second routine applied also did not have the desired effect. I think there may be a conflict with another scoring routine. I'm attaching the source code for analysis, sorry if it looks chaotic. Steamboat_VS_Red_Button_FAST.bas Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5418301 Share on other sites More sharing options...
RevEng Posted February 26 Share Posted February 26 No idea about the blue screen. Maybe you put the subroutine in the code flow? Here's the integrated routine. You're subtracting more than 1 in another area, so I updated it to only look at the top 4 score digits. Steamboat_VS_Red_Button_FAST.bas 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5418310 Share on other sites More sharing options...
alfredtdk Posted February 27 Share Posted February 27 WOW. Worked perfectly. Thanks RevEng for the help. Can I clear another doubt? It has nothing to do with punctuation and I don't know if it's a redundant question. The Atari has this resolution of 160x192, but it is possible to add black bars on the edgesI wanted to know if it is possible to remove the edges that exceed the limits of the standard playfield. Something like the photos below. Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5418971 Share on other sites More sharing options...
RevEng Posted February 27 Share Posted February 27 You're welcome! Unfortunately there's no way to crop the screen or have black bars covering up those non-playfield area. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5418989 Share on other sites More sharing options...
alfredtdk Posted February 29 Share Posted February 29 (edited) RevEng I'm almost finished with this game and I wanted to add a special touch to this game. As it is more of a mathematical game than an adventure, so to speak, I think it would be interesting to have addition and subtraction values appearing on the screen. As I am in the learning phase of programming, I consider myself an amateur in this area. I know that the numbers presented share with the players (0,1) or the sprites, better said. Is there a way to add this subroutine to the standard kernel? Thanks A graphical representation of the game image with the addition and subtraction values appearing on the screen. ************************************************************************************************************************************** I currently have 940 bytes of available R0M. I made some subroutines on the title screen and a new graphic animation for player0. Updated source code. Steamboat_VS_Red_Button_Release.bas Edited February 29 by alfredtdk Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5420241 Share on other sites More sharing options...
RevEng Posted February 29 Share Posted February 29 The standard kernel is full, in terms of cycles per scanline, but also in terms of display objects. To display other items, like your values, you'd need to flicker them, using one frame to display a game object, and another frame to display the math value. 1 Quote Link to comment https://forums.atariage.com/topic/272809-score-variables-and-mathematics-question/#findComment-5420291 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.