Hurt Tile

Having trouble compiling code? Getting an unexpected error? Player not appearing on screen? Seeking answers on how to do a particular thing? This is the forum you're looking for, to ask other NESmaker users for assistance.
User avatar
dale_coop
Posts: 5146
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Hurt Tile

Post by dale_coop » Sun Mar 22, 2020 10:37 am

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: Select all

	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
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
baardbi
Posts: 126
Joined: Sun Jul 07, 2019 2:28 pm
Location: Norge

Re: Hurt Tile

Post by baardbi » Sun Mar 22, 2020 1:15 pm

Hey! That's cool! It works great. Even better than what I had planned :) Thank you as always :)
User avatar
dale_coop
Posts: 5146
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Hurt Tile

Post by dale_coop » Sun Mar 22, 2020 7:42 pm

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: viewtopic.php?p=15891#p15891
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
baardbi
Posts: 126
Joined: Sun Jul 07, 2019 2:28 pm
Location: Norge

Re: Hurt Tile

Post by baardbi » Sun Mar 22, 2020 11:40 pm

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! :)
User avatar
Dirk
Posts: 585
Joined: Fri Mar 09, 2018 5:30 am

Re: Hurt Tile

Post by Dirk » Mon Mar 23, 2020 12:21 pm

dale_coop wrote:
Sun Mar 22, 2020 10:37 am
Because you used the wrong flag variable to check and the wrong branch out...

Code: Select all

	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.
-----
Disclaimer: English is not my first language, so mistakes are bound to happen.
User avatar
dale_coop
Posts: 5146
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Hurt Tile

Post by dale_coop » Mon Mar 23, 2020 7:22 pm

In this code:

Code: Select all

	LDA Object_flags,x	;; Is it a monster?
	AND #%00001000
	BEQ notAmonster

Code: Select all

;; 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: Select all

LDA Object_flags,x
Then, you filter/isolate the flag you want to check, using AND:

Code: Select all

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: Select all

BEQ notAmonster
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
Dirk
Posts: 585
Joined: Fri Mar 09, 2018 5:30 am

Re: Hurt Tile

Post by Dirk » Mon Mar 23, 2020 7:40 pm

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
-----
Disclaimer: English is not my first language, so mistakes are bound to happen.
User avatar
dale_coop
Posts: 5146
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Hurt Tile

Post by dale_coop » Tue Mar 24, 2020 5:01 pm

Ah yeah, I need days to really get it.
Because when you use a CMP, it's the common meaning:

Code: Select all

	LDA myVariable
	CMP #$01
	BEQ jumpYesItsEqualTo1
	;; else it's not equal to 1
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
Dirk
Posts: 585
Joined: Fri Mar 09, 2018 5:30 am

Re: Hurt Tile

Post by Dirk » Tue Mar 24, 2020 5:03 pm

Oh, thank you again! You saved me from stepping into the next beginner's trap XD
-----
Disclaimer: English is not my first language, so mistakes are bound to happen.
Post Reply