Language…
9 users online: Aeon, dacin, DashGamer, DixyNL, GRIMMKIN, JezJitzu, Nemesis1407,  Segment1Zone2, toady - Guests: 239 - Bots: 339
Users: 64,795 (2,376 active)
Latest user: mathew

! instead of $

Hi!

I have seen in some ASM files the prefix ! instead of $ to reference some addresses. For example, instead of $150C, !150C. I'm sure it's a super simple question, but what is the difference between using each one? Thanks in advance.
! is used to access an address locally rather than globally. Take $14C8 for example--if you wanted to program an enemy to kill itself, you would do STZ !14C8 so that it affects only its own status.
I'm not sure if I understand... I don't see the difference between STZ $14C8,x and STZ !14C8 then (which I don't think it's correct, because I have seen indexed addresses with the exclamation mark, ie !14C8,x), because both of them will kill only the sprite in question, and not the others. What do you mean by "locally"?
Not quite sure what Meirdent is talking about either. #tb{''}

! is used for defines, which are basically placeholders for any value:

Code
!some_value = #$01
!some_address = $0DBF
LDA !some_value
STA !some_address


(they're much more versatile in Asar than this snippet gives them credit for, but you get the idea.)

Defines have always been really useful to make programming and customizing patches easier, but another reason many addresses like this are outsourced to defines nowadays is probably because of the SA-1 patch, which remaps a lot of them. With defines, you can just tell Asar "if SA-1 is on, let !some_address equal $14C8, otherwise, let it equal $1234 or whatever." (Or it's needed because of sprite insertion tools? I'm not quite up to date on those.)

You can name the defines anything you want, but in the case of SA-1 and/or sprite addresses the convention is to name them like the original address, so you can still tell at a glance what a piece of code does.


 
Yeah I know about defines. I was talking about, to take a random example, the use of the exclamation marks in the following code (some part of the Ball n' Chain dissasembly):

Code
CODE_02D643:		CLC				;\ update angle depending on direction of rotation
			ADC !1602,x			; | $1602,x is used to store the low byte of the ball n' chain angle


Here, the exclamation mark is not used as a define... (I think)
Originally posted by Darolac
Yeah I know about defines.

Ah, okay.

Still, I'm pretty sure those are just regular defines - it's just that they're not defined by the sprite itself, but by PIXI. (asm/sa1def.asm is where it happens.)


 
That could be an explanation. I'll take a look at that file. Thanks! Such a simple thing was driving me crazy :)
my b, im just a big dumb
The SA-1 patch more or less remaps all of the RAM related to sprites to other locations within the RAM bank(s), so PIXI will detect if the ROM is enabled for SA-1 or not, and offset the addresses accordingly. $14C8,x will address $14C8,x always. !14C8,x will address $14C8,x if the ROM is not SA-1 enabled, or $3242,x if the ROM *is* SA-1 enabled.

It vastly increases the compatibility of sprites that can be used on SA-1 ROMs.

The reason that the defines are !14C8,x for example instead of !sprite_status,x is mostly for simplicity's sake. However, I believe that !sprite_status,x itself can be also used in place of !14C8,x and it'll assemble identically, so it's your choice.