dciabrin / ngdevkit

Open source development for Neo-Geo
GNU Lesser General Public License v3.0
273 stars 26 forks source link

Remove sprites/tiles from screen #8

Closed totologic closed 4 years ago

totologic commented 5 years ago

Hi.

If we consider the 02-sprite example, how could I remove properly a sprite from screen ? Same question for removing a single tile belonging to a sprite ?

At the beginning of the program, you use the value 255 as the rank of a transparent tile in BIOS ROM to clear the tiles of the fix map. Does it mean my 255th tile in c-ROM is compulsorily overwriten by this transparent tile ?

Using an empty tile to "clear" sprites or tiles should work but it looks like a waste of ressources for me. Maybe my point of view is wrong ?

totologic commented 5 years ago

For sprites, setting the height parameter to 0 in SCB3 for the lead sprite do the job. Do you know if we have a better choice ?

dciabrin commented 5 years ago

If we consider the 02-sprite example, how could I remove properly a sprite from screen ? Same question for removing a single tile belonging to a sprite ?

I don't know if there's a single best answer to your question, setting the height looks like a fairly fast way to do that. I was thinking of moving the offset of the sprite off-screen, but it seems an equally fast option.

At the beginning of the program, you use the value 255 as the rank of a transparent tile in BIOS ROM to clear the tiles of the fix map. Does it mean my 255th tile in c-ROM is compulsorily overwriten by this transparent tile ?

No that's a arbitrary choice on my side, because the c-ROM in the original BIOS has an empty tile at that offset. So if you use an original ROM in place of ngdevkit's nullbios, you would reuse that tile (and have a nice eyecatcher intro at boot time for free :))

Using an empty tile to "clear" sprites or tiles should work but it looks like a waste of ressources for me. Maybe my point of view is wrong ?

Yes, definitely a waste of CPU cycles.

dciabrin commented 4 years ago

For sprites, setting the height parameter to 0 in SCB3 for the lead sprite do the job. Do you know if we have a better choice ?

Obviously it's been a while since you opened the issue and you already have a full game running... but for the sake of the discussion I'm going to add two pointers to the neogeodev wiki here before closing that issue:

  1. the hello world tutorial from the wiki does exactely what you said: it cleans the sprite's hight for all sprites. So that seems a fairly quick way to achieve clean up.

  2. There's BIOS function LSP_1st dedicated to that purpose. It's doing a more thorough clean up, as explained in the wiki.

Kudos to the folks at neogeodev for their invaluable information.