Grevle Posted August 26, 2016 Share Posted August 26, 2016 (edited) 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 August 26, 2016 by Grevle Quote Link to comment Share on other sites More sharing options...
JamesD Posted August 26, 2016 Share Posted August 26, 2016 You could use BCD math, it simplifies converting from the numeric score to text. Quote Link to comment Share on other sites More sharing options...
JamesD Posted August 26, 2016 Share Posted August 26, 2016 (edited) http://www.6502.org/tutorials/decimal_mode.htmlJust remember the quirks.http://www.liquisearch.com/mos_technology_6502/bugs_and_quirks Edited August 26, 2016 by JamesD Quote Link to comment Share on other sites More sharing options...
+David_P Posted August 26, 2016 Share Posted August 26, 2016 Do you need to keep score, or to update the numbers on the screen? The optimal approach may depend on which you choose. Quote Link to comment Share on other sites More sharing options...
Rybags Posted August 26, 2016 Share Posted August 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
Grevle Posted August 26, 2016 Author Share Posted August 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
Grevle Posted August 26, 2016 Author Share Posted August 26, 2016 (edited) 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 August 26, 2016 by Grevle Quote Link to comment Share on other sites More sharing options...
JamesD Posted August 26, 2016 Share Posted August 26, 2016 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 leftYou could also use a smaller array if you shift the upper nibble 4 times.;first two digitsLDY #0LDA SCOREADDRESSAND #!11110000TAX LDA CHARACTERLOOKUP,XSTA SCREENADDRESS,YINY LDA SCOREADDRESSAND #!00001111TAX LDA CHARACTERLOOKUP,XSTA SCREENADDRESS,YINY;second two digits LDA SCOREADDRESS+1AND #!11110000TAX LDA CHARACTERLOOKUP,XSTA SCREENADDRESS,YINY LDA SCOREADDRESS+1AND #!00001111TAX LDA CHARACTERLOOKUP,X STA SCREENADDRESS,YINYetc... Quote Link to comment Share on other sites More sharing options...
Rybags Posted August 26, 2016 Share Posted August 26, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
JamesD Posted August 26, 2016 Share Posted August 26, 2016 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. I like the idea from the game in the movie Hackers. Quote Link to comment Share on other sites More sharing options...
Grevle Posted August 26, 2016 Author Share Posted August 26, 2016 (edited) 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 August 26, 2016 by Grevle Quote Link to comment Share on other sites More sharing options...
+therealbountybob Posted August 27, 2016 Share Posted August 27, 2016 (edited) 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 August 28, 2016 by therealbountybob 1 Quote Link to comment Share on other sites More sharing options...
Grevle Posted August 28, 2016 Author Share Posted August 28, 2016 (edited) 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 : ) Edited August 28, 2016 by Grevle 5 Quote Link to comment Share on other sites More sharing options...
José Pereira Posted August 28, 2016 Share Posted August 28, 2016 (edited) There is love in the air in one screen and an arcebisp on the other, humm... I think it is to say that something else can only be after they marry... Edited August 28, 2016 by José Pereira 1 Quote Link to comment Share on other sites More sharing options...
sup8pdct Posted August 28, 2016 Share Posted August 28, 2016 I did a score box program. heaps of numbers all over the screen. I kept them in memory as BCD. Used the math routines do multiply and divide for percentage and to convert to ATASCII then AND with $1F to put directly into screen memory. James Quote Link to comment Share on other sites More sharing options...
Grevle Posted April 10, 2020 Author Share Posted April 10, 2020 (edited) 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 April 10, 2020 by Grevle Quote Link to comment Share on other sites More sharing options...
+DjayBee Posted April 10, 2020 Share Posted April 10, 2020 44 minutes ago, Grevle said: LDX #10 ; INCREASE SCORE BY 10 Since you are in decimal mode this has to be LDA #$10. The high-nibble becomes the 10s and the low-nibble becomes the 1s. 1 Quote Link to comment Share on other sites More sharing options...
StickJock Posted April 10, 2020 Share Posted April 10, 2020 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! 1 Quote Link to comment Share on other sites More sharing options...
Grevle Posted April 10, 2020 Author Share Posted April 10, 2020 Thank you, its working now, decimal mode make more sense now… thanks for the help. ? 1 Quote Link to comment Share on other sites More sharing options...
StickJock Posted April 10, 2020 Share Posted April 10, 2020 You can save some instructions & cycles if you just pass the add value in A instead of saving it in POINTS. 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 11, 2020 Share Posted April 11, 2020 You're using X as the # of points to add but also as the index as to what address to add from. So unless you have a table setup (which isn't needed) you'd get indeterminate values being added. 1 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.