Jump to content
Sign in to follow this  
Tempest

New Programming Questions (Cypher Help)

Recommended Posts

Now that I've got the title screen settled, I want to move on. I have a few questions though.

 

1. I need to make my player be composed of player 1 and player 2 (for size reasons). How do I go about doing this?

 

2. At the moment all the values on my title screen and hard coded (high score, current level, etc.). Assuming I store those values in a variable how do I display that variable on the screen?

 

For instance, my High Score is a 6 digit number. I want to store that number in a variable I can easiy update when the player scores. Do I store the whole number in a variable or each digit in a seperate variable? When I get the score in the variable how do I display it? At the moment the numbers are hard coded into my display list, how would I say "Take the contents of this variable and display it"?

 

Am I making any sense?

 

Tempest

Share this post


Link to post
Share on other sites

1. There is no real trick to this, just define each player with the appropriate part of the image and position them so they appear as one large image. There is one trick you can do. If you set bit 5 of the PRIOR register to 1, then the overlap of players 0/1 and 2/3 will produce a third color. So this allows you to produce 4-color players using only 2 players.

 

2. I assume your text areas are going to be character modes (like mode 2), since you can mix modes using the display list this is the way to go. As Eckhard said, using BCD is a good idea, and makes updating the score very easy. To draw each 2 digits, you would first mask off the top 4 bits, shift then down to the bottom 4 bits and add them to 16, which is the character code for '0', and put this into the screen memory at the correct location. You would then repeat this process with the bottom 4 bits of the original number.

 

Dan

Share this post


Link to post
Share on other sites

Ok, one more time in English guys. I'm still learning how to program this thing. How do I store numbers as BCD's? Also what do I put in the Display List in the place where I'm going to put the numbers directly into memory? Does it matter since I'm going to over write them anyway?

 

Tempest

Share this post


Link to post
Share on other sites

Routines for four digit scoring:

 

,NOTE : score is high byte first

,treat score like a variable

,routine can also add values >255

,put point value in POINTHI/POINTLO

SED

CLC

LDA $SCORELO (SCOREHI+1)

ADC $POINTLO

STA $SCORELO

LDA $SCOREHI

ADC $POINTHI

STA $SCOREHI

CLD

,

,

,

,transfer score from decimal value to screen

,(again, High byte first)

LDX #01

TXA

ASL

TAY

LDA $SCORE,X

PHA

AND #$F0

ASL

ASL

ASL

ASL

ADC #$10

STA $SCREEN,Y

PLA

AND #$0F

ADC #$10

INY

STA $SCREEN,Y

CLC

DEX

BCC E1 (back up to TXA)

,

,SCREEN=LEFTMOST DIGIT

,VALUE IN "ADC" LINES SHOULD BE THE VALUE FOR YOUR SYSTEM'S CHARACTER "0"

 

You could also use these routines for additional digits by lengthening the score adding routine (make more LDA-ADC-STA lines), and the LDX value (add 1 for two additional digits). I used the Y register to move the screen location to the proper digit (1 byte=2 digits). You could also change the ADC #$10 parts in the lower routine to be ADC $LOCATION. This modification would allow you to change the starting character to be displayed (like to display inverse characters when time is running out). If this is an absolute address, you would also have to change the BCC value at the end to still point to the TXA line. An interesting sidenote is that you could also set use STA $(SCREEN),Y...this pulls the screen location for the leftmost digit from a zero page address. That way, you can put an address in there before you JSR to this routine, and change that value to JSR to it again if the score is greater than the current highscore. Again, you would have to change the BCC value accordingly.

 

Dan Boris--

I think he just wants to use 2 players to make an object that is 16-bits across...to do that you just store the next player 8 bits from the location of the first player.

,

LDA $LOCATION

STA $HPOSP0

ADC #$08

STA $HPOSP1

,note : double (#$10) or quadruple (#$20) the ADC value if using larger player widths set in SIZEP0-3

 

[ 08-06-2001: Message edited by: Nukey Shay ]

Share this post


Link to post
Share on other sites

I don't know anything about the 5200 graphics system, but I think the following should work for the number display:

 

Put the display list in RAM, so that you can change the pointers for the graphics of the digits, or whatever the 5200 needs to display a number.

 

Store all numbers that are supposed to be displayed as binary coded decimals (BCD). BCD variables can hold decimal values between 00 and 99 instead of hexadecimal values between $00 and $ff. Each digit takes four bits of the byte. This makes it easy to mask out a digit and generate a display pointer from it. The 6502 allows you to do decimal calculations when set into BCD mode with the SED instruction. The CLD instruction takes the processor back to binary mode. Therefore you can easiely increase the level or add some points to the score without having to worry about converting binary values to decimal.

 

 

Ciao, Eckhard Stolberg

Share this post


Link to post
Share on other sites

EDIT -- I figured it out, but I'll leave the text as is.

 

I need some help, please. I read the above but it is tailored for scorekeeping (I'll get to that next). Right now I am trying to display the color value on-screen for various graphics on-screen, as part of a debug mode for Koffi.

 

Debug mode is activated by pressing the "5" key. Then, '*' cycles a subscribt from 0 to D to pick which of 14 ColorTable values to select. The "0" key increments the color values by 1, the '#' key decrements the color value by 1. So I can easily change any color on-screen, and I will use this on the actuall 5200 hardware soon to pick the best colors.

 

If I have a variable called ColorValue, which is 1 byte and has the value of $50, then how do I get "50" to display in an Antic 2 line on the screen, using a BCD?

 

$50 hex = %0101 0000.

 

It seems I have to do an "AND" statement or two, and some LSR's.

 

If I do this:

lda ColorValue ; a=0101 0000

AND $F0

 

,what is the value of the accumulator 'a' after this statement? I assume it makes either the left or right nibble into zeroes?

 

EDIT -- the answer is a=0101 0000, then you LSR 4 times to get 0000 0101.

 

Basically I want to convert #$50 into two bytes, one for the "5" and one for the "0", correct?

 

EDIT -- yes, I think that was correct

 

"5" = #$15 value

"0" = #$10 value. Do I add #$10 somewhere?

 

------

 

[ 01-21-2002: Message edited by: Cafeman ]

Share this post


Link to post
Share on other sites

why using BCD? i never used it...(maybe it saves a lot of code but...)

 

ldx value

lda digit1,x

sta anticline+1

lda digit2,x

sta anticline

 

digit1 dc.b 0123456789abcdef0123...

digit2 dc.b 00000000000000001111...

 

worked always perfect... and i use this code as well in senso 7800 dx.

 

heaven

Share this post


Link to post
Share on other sites

and of course if you want no hex numbers...

 

digit1 012345678901234567890...

digit2 000000000011111111112...

digit3 000000000000000000000...

 

well... for a 6 digit number i dont know

actually what is better...

 

maybe some guys can explain the bcd stuff even to me...

 

hve

Share this post


Link to post
Share on other sites

BCD numbers are really easy. They just store one decimal number per nibble. So one byte can hold numbers from 0 to 99. When the decimal bit is set you can add and subtract these numbers in decimal mode. If you have a score of $09 $99 $99 for example and you want to add $00 $00 $01 to it, the result in decimal mode would be $10 $00 $00.

 

Then you can use your method for converting these into displayable characters, or if you have more processor time than ROM space, you can mask out the 6 nibbles individually and convert them to ASCII by adding $30 (in hex mode) to them.

 

 

Ciao, Eckhard Stolberg

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...