Hurt Tile

dale_coop

Moderator
Staff member
Because you used the wrong flag variable to check and the wrong branch out... and also, set the solidity (to SOLID) tthe beginning, before the check so in every cases... the solidity is SOLID.
I think it would be better, ike this:
Code:
	LDA Object_flags,x	;; Is it a monster?
	AND #%00001000
	BEQ notAmonster
	
	;; if it IS a monster, then make it solid: 
	LDA #TILE_SOLID
	STA tile_solidity
	
	RTS
 

dale_coop

Moderator
Staff member
Glad it works... can't wait to see the next gameplay video.

Btw, I noticed your transitions between screens are not very "clean"... look like glitchy tiles displaying for some fraction of seconds....
you could fix that, there is a fix here: http://nesmakers.com/viewtopic.php?p=15891#p15891
 

baardbi

Well-known member
Thanks for the tip. I tried FrankenGraphics fix once before and it made some weird glitches on the player graphics, but now it's working great! :)
 

Dirk

Member
dale_coop said:
Because you used the wrong flag variable to check and the wrong branch out...
Code:
	LDA Object_flags,x	;; Is it a monster?
	AND #%00001000
	BEQ notAmonster

This is a bit confusing. The fourth bit sets the object to a monster, so #%00001000 defines a monster.
Shouldn't now 00001000 AND 00001000 result in 00001000 and therefore BEQ (branch on equal) should jump to e.g. isAmonster?

I'm not doubting your code, I just don't get it. The logic seems inverted to me.
 

dale_coop

Moderator
Staff member
In this code:
Code:
	LDA Object_flags,x	;; Is it a monster?
	AND #%00001000
	BEQ notAmonster

Code:
;; Object_flags:
;; 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0
;  |   |   |   |   |   |   |   + -- PERSISTENT (especially good for player!)
;  |   |   |   |   |   |   +------- player type
;  |   |   |   |   |   + ---------- player weapon/projectile type
;  |   |   |   |   +--------------- monster type
;  |   |   |   +------------------- monster weapon/projectile type
;  |   |   +----------------------- pickup / power up
;  |   + -------------------------- target type 
;  +------------------------------- NPC type

First, you load/read the flags of the current object:
Code:
LDA Object_flags,x

Then, you filter/isolate the flag you want to check, using AND:
Code:
AND #%00001000
By doing that, you will have in the A register, a "1" (true) if it's a monster or a "0" (false) if it's not.

When you load a variable, you can check if the result of that action (loading) is EQual to "0" or NotEqual to "0".
In our example, if the result of the load and filter is 1 it means it's a monster (the bit is set) and 0, means not a monster (the bit is not set):
Code:
BEQ notAmonster
 

Dirk

Member
Ahh, thank you, thank you Dale for the detailed explanation! Branch when equal to zero...
You've just untied a huge knot in my brain ^^
It all makes sense now :D
 

dale_coop

Moderator
Staff member
Ah yeah, I need days to really get it.
Because when you use a CMP, it's the common meaning:
Code:
	LDA myVariable
	CMP #$01
	BEQ jumpYesItsEqualTo1
	;; else it's not equal to 1
 
Top Bottom