It is currently Fri Oct 20, 2017 2:44 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Sep 14, 2017 12:16 pm 
Offline

Joined: Tue Apr 11, 2006 4:08 am
Posts: 239
I would like to break one value (a variable in RAM) so that it can be displayed in two graphical numbers on the screen. The variable in RAM will have a value of up to 64 (40hex). Two sprites will be used for this purpose.

Showing values 0-9 is easy, but I do not know how to code so that it automatically split into two digits.

Code:
   LDA #$F0   ;this is the starting tile number in SPR CHR ROM (F0 = 0, F1 = 1 ...- F9 = 9)
   CLC
   ADC variable   ;ram byte 00-40hex)
   STA DIGIT1_T   ;one of two DIGIT SPRITE TILES  (DIGIT1_X,S,T,Y and DIGIT2_X,S,T,Y)


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 12:31 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6288
Location: Seattle
viewtopic.php?f=2&t=11341


Top
 Profile  
 
PostPosted: Thu Sep 14, 2017 5:38 pm 
Offline

Joined: Tue Apr 11, 2006 4:08 am
Posts: 239
Okay, I got it.
Now collected object (gold) increases the value in the "GOLDnumber1", which is reset upon reaching a value of 10, while increasing the value in one GOLDnumber2. The most important works ok.

Code:
GOLD_Status:

   LDA #$F0
   CLC
   ADC GOLD_Number1
   STA GOLD1_T

   LDA #$F0
   CLC
   ADC GOLD_Number2
   STA GOLD2_T

   LDA GOLD_Number1
   CMP #$0A
   BEQ GOLD_Number_Reset
   RTS

GOLD_Number_Reset:
   LDA #$00
   STA GOLD_Number1
   INC GOLD_Number2
   RTS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group