Jump to content

Photo

Pass bB constants to assembly?


2 replies to this topic

#1 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 9,293 posts

Posted Thu Dec 20, 2018 4:57 PM

So, I'm trying to save variables yet again.  I'm thinking that a status bar color will never change during the game and want to use a constant.  How would I declare a constant in bB and have it referenced in the assembly code of a mini kernel?

 

For instance, I changed the color of the status bar to yellow (#$2F) in 6lives_statusbar.asm

 

 ifconst statusbarcolor
 ; only write COLUPF if color variable exists, otherwise use existing PF color
 lda #$2E
 sta COLUPF
 endif
 
How would I declare a constant in bB
 
 const _mystatusbarcolor = $2E
 
and have that replace the
 
 lda #$2E
 
in the code?
 
aslearning.jpg


#2 RevEng OFFLINE  

RevEng

    Bit Player

  • 5,082 posts
  • Location:bottom of the stack

Posted Thu Dec 20, 2018 5:20 PM

The "#$2E" in the original ASM isn't a memory location, it's a literal constant value. So no memory would be saved by substituting your bB constant for the #$2E.

If you want it just for convenience, then you can just put "lda #_mystatusbarcolor" in the asm code, instead of "lda #$2E".

#3 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • Topic Starter
  • 9,293 posts

Posted Thu Dec 20, 2018 5:27 PM

The "#$2E" in the original ASM isn't a memory location, it's a literal constant value. So no memory would be saved by substituting your bB constant for the #$2E.

If you want it just for convenience, then you can just put "lda #_mystatusbarcolor" in the asm code, instead of "lda #$2E".

 

Holy cow that's amazing!!  Thank you for the tip!! ^_^






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users