Jump to content
IGNORED

Score, variables and mathematics question


Coolcrab

Recommended Posts

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.

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 3 years later...
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

Link to comment
Share on other sites

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 by bogax
  • Thanks 1
Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

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 :)

  • Thanks 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.  ? 

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

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/

 

Link to comment
Share on other sites

  • 2 years later...

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.

 

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

 

 

 
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. 

Captura de tela em 2024-02-26 22-59-54.png

Captura de tela em 2024-02-26 23-00-20.png

Link to comment
Share on other sites

 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.

Sem título.png

Steamboat_VS_Red_Button_Release.bas

Edited by alfredtdk
Link to comment
Share on other sites

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.

  • Thanks 1
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...