Jump to content
IGNORED

Game Score routine Mac/65 assembler


Recommended Posts

So my game Dracula homegrounds have had some progress and at some point i want to add a score rotuine in Mac/65 asembler.

 

I know how to put the numbers on screen by storing the apropiate vaule in the correct screen memory adress so that the numbers appear where i want them to.

 

But im not exactly sure on how to have a proper score routine work so that when the score is added then its added up in a way that it will show correctly on the screen.

 

Sutch a routine would need the ability to add scores as it increases and the link it to the screen memory adress so that the correct values appears at the correct screen memory adresses.

 

So i propably could create somehting like that but im realy not that good in math so if could have some examples on how this is most easily done that would very helpful for me.

 

Thank You.

Edited by Grevle
Link to comment
Share on other sites

I'd also recommend BCD. The conversion to make it displayable isn't a lot of processing and is much quicker/easier than doing it for binary. Plus 16-bit binary doesn't give much range.

You don't need to worry about sign or exponent so the operations are pretty simple.

Just note that screen codes don't usually match Ascii on Atari due to how the character set is mapped out.

Link to comment
Share on other sites

Do you need to keep score, or to update the numbers on the screen? The optimal approach may depend on which you choose.

The games should keep score as the player gets more score added along the way and also a hiscore, the hiscore bit is the easy part i think.

Link to comment
Share on other sites

Also need to link the sceen adresses so that the decimal values to apears at the right screen adresses, so i l,try to do my best with it. Thanks.. some code examples from other score routines would help a lot..

Edited by Grevle
Link to comment
Share on other sites

BCD math uses nibbles (4 bits) for each decimal number.
It's a question of indexing through the number one digit at a time, masking odd or even nibble, and that gives you the raw, unshifted decimal digit.
Once you have a nibble mased off, use a table to convert from decimal digit to Atari ASCII.

Be aware that I haven't checked this, it's just a rough suggestion and I'm not even sure I have the nibble masks in the right order.
Notice that I'm storing the score bytes left to right like it's printed, but they could be right to left
You could also use a smaller array if you shift the upper nibble 4 times.

;first two digits
LDY #0

LDA SCOREADDRESS
AND #!11110000
TAX

LDA CHARACTERLOOKUP,X
STA SCREENADDRESS,Y
INY

LDA SCOREADDRESS
AND #!00001111
TAX

LDA CHARACTERLOOKUP,X
STA SCREENADDRESS,Y
INY

;second two digits

LDA SCOREADDRESS+1
AND #!11110000
TAX

LDA CHARACTERLOOKUP,X
STA SCREENADDRESS,Y
INY

LDA SCOREADDRESS+1
AND #!00001111
TAX

LDA CHARACTERLOOKUP,X

STA SCREENADDRESS,Y
INY
etc...

Link to comment
Share on other sites

My preference with High Score is that it gets left alone until the game ends.

That way you can easily compare how you're going with the previous best.

Yes i agree. This is just like i would do when programming Basic.

 

Ok thanks for you help, i will get it to work somehow when the times come to add the score routine.

Edited by Grevle
Link to comment
Share on other sites

Jan,

Did you manage to get the book "Atari Graphics and Arcade Game Design" By Jeffrey Stanton with Dan Pinal? I've found this invaluable. (It covers scoring [two methods] and has some example games [and code]). You can read it on http://www.atariarchives.org/agagd/

 

Jason

Edited by therealbountybob
  • Like 1
Link to comment
Share on other sites

Jan,

Did you manage to get the book "Atari Graphics and Arcade Game Design" By Jeffrey Stanton with Dan Pinal? I've found this invaluable. (It covers scoring and has some example games). You can read it on http://www.atariarchives.org/agagd/

 

Jason

 

Thank you . im gonna take a look at it, i can get some ideas how to have a score routine that suits my game.

 

Btw heres some screenshots from work in progress : )

 

post-32232-0-90013200-1472348446_thumb.png

 

 

post-32232-0-91869800-1472348462_thumb.png

Edited by Grevle
  • Like 5
Link to comment
Share on other sites

  • 3 years later...

im almost getting it to work now.. but it adds only 1 point at the time even tough i want to add like 10 or 50 Points etc. whatever i do it only adds 1 point to the score.

 

This is the code im working With, mostly from the book "Atari Graphics and Arcade Game Design". But i had to make some small changes to make it compile With atasm

most noticeble is probably these lines "STA (WINDOW),Y" would not compile in atasm changed to "STA WINDOW,Y".

 

The screen adress is correct and number are on screen so it's in the upper part of the score routine something is not right it seems.

 

 

 

my code:


EQUATES

SCORE   = 30739
POINTS  = 30741
WINDOW  = 39971 ; SCREEN ADRESS

 

; TRYING TO ADD SCORE HERE

 

LDX #10 ; INCREASE SCORE BY 10

STX POINTS    

 

JSR SCOREK ; SUBROUTINE TO ADD AND PUT SCORE ON SCREEN

    
REST OF PROGRAM HERE, THIS IS JUST A EXAMPLE    
    
    
    
    ; THE SCORE SUBROUTINE    
    
    
    SCOREK
    SED
    
    LDA SCORE+1   ;LOAD TWO LOW DIGITS
    ADC POINTS,X  ;ADD POINT VALUE OF BRICK
    STA SCORE+1
    LDA #0        ;WILL ALSO ADD CARRY BIT IF NECESSARY
    ADC SCORE
    STA SCORE
    CLD
                 ; NOW PRINT NEW SCORE ON SCREEN
DOSCORE
    LDX #0
    LDY #35
ONE
    LDA SCORE,X
    LSR ;EACH BYTE HOLDS 2 NUMBERS
    LSR ;SHIFT UPPER NIBBLE OVER
    LSR ;AND DO IT
    LSR ;FIRST.
    ORA #16 ; TRANSLATE NUMBER INTO INTERNAL CHARACTER
    STA  WINDOW,Y ;STORE HIGHER DIGIT OF PAIR ON SCREEN
    INY ; NEXT
    LDA SCORE ,X
    AND #$0F ; NOW DO LOWER NIBBLE
    ORA #16 ; MAKE A CHR
    STA  WINDOW,Y ;STORE LOWER DIGIT OF PAIR ON SCREEN 
    INY
    INX
    CPX #2 ; DONE BOTH BYTES? (ALL 4 SCORE DIGITS)
    BNE ONE
    
    RTS
    

 

 

 

Edited by Grevle
Link to comment
Share on other sites

I see a few suspicious things in this code.  

First, you are loading points with decimal 10 ($0A), but in your add routine you are using BCD.  You need to be consistent in your number representation.  Try loading points with $10 (which is 10 in BCD).

 

Second, this line looks wrong as well: ADC POINTS,X  ;ADD POINT VALUE OF BRICK

I suspect that you don't really mean to use the indirect addressing mode and what you really want to do is just ADC POINTS.

 

Good Luck!

 

 

  • Like 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...
 Share

  • Recently Browsing   0 members

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