Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2020-02-15 06:04:50

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Sprite priority

It's been a while. Since the last time I visited, the wiki has been modified to the point where I can't navigate through it. So I'm asking here. I'm having a problem with sprite priority. Why does this happen? When the sprite is left, the hand covers the fly, but when it's right, it doesn't? This is driving me crazy.
http://www.atari2600land.com/gameboy/ishouldnothavethisproblem.png
Code is here:
http://www.atari2600land.com/gameboy/flies2.zip


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#2 2020-02-15 08:58:48

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

here is a discussion: https://gbdev.gg8.se/forums/viewtopic.php?id=418
on GB it seems that nothing you can do, rather to render the correct sprite intersection manually.

Offline

 

#3 2020-02-15 09:19:37

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

ps: "rgbfix.exe -v -C flies2.gb" fixes your issue by making rom GBC-only

Offline

 

#4 2020-02-15 17:29:12

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

you may also make your "fly" a part of background, using a technique, similar to drawing "graphical" mouse in DOS textmode, using the redefinition of 4 font characters, when moving mouse cursor pixel by pixel. like in DOS "Norton Utilities 6". should I explain the method?

Offline

 

#5 2020-02-16 05:26:22

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Sprite priority

I was going to have a different background than just plain white.
http://www.atari2600land.com/gameboy/flies4.png
Here is the ROM. By the way, please listen to my title screen music and let me know what you think.
http://www.atari2600land.com/gameboy/flies4.zip


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#6 2020-02-16 14:44:49

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

chris wrote:

I was going to have a different background than just plain white.

it does not matter. here is a proof-of-concept: https://www.dropbox.com/s/eiaw6ooc7jinm … 3.zip?dl=0

this code is not optimal, I tried to make it as simple as possible, so it is very far from being called "fast". please ask, if you have questions.

it would be great, if someone can help with optimization of this code.

Offline

 

#7 2020-02-16 15:05:20

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

about the music... may be this: https://en.wikipedia.org/wiki/Flight_of_the_Bumblebee ?

Last edited by toxa (2020-02-16 15:13:05)

Offline

 

#8 2020-02-17 06:56:02

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Sprite priority

Thanks for trying, but I can't get it to compile on my computer. I'm not all that talented in C.
http://www.atari2600land.com/gameboy/fliesattempt.zip


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#9 2020-02-17 07:28:23

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

neither me smile but I managed to make my code faster and re-usable, please download it once again: https://www.dropbox.com/s/eiaw6ooc7jinm … 3.zip?dl=0

I also added some comments to make it more readable.

Offline

 

#10 2020-02-17 08:39:41

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

ps: I think, that it is better to use arrays of pointers for animations.
pps: for masks you should leave zeros in both bit planes for transparent pixel, and both zeros for non-transparent. if you do not do so, your sprite will change color for that pixel (on one plane it is reset, on the other it is a result od OR with a bit of your background.

Offline

 

#11 2020-02-17 10:44:28

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Sprite priority

Your code won't compile.


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#12 2020-02-17 11:18:49

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

what's the error? what compiler version do you use?

Offline

 

#13 2020-02-17 11:47:03

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Sprite priority

It's odd because there is no error. It acts as though it compiled but there's no new .gb file made. I'm using GBDK.


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#14 2020-02-17 12:00:53

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

i recommend you to use gbdk-n from here: https://github.com/andreasjhkarlsson/gbdk-n.
and a new sdcc v4.0 from here: https://sourceforge.net/projects/sdcc/f … n64/4.0.0/

Offline

 

#15 2020-02-17 12:53:48

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

I also put some bat-files to compile using sdcc4 and gbdk-n, please download the updated file again.

Offline

 

#16 2020-02-18 03:27:24

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Sprite priority

Your gbdk-n link doesn't work.


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#17 2020-02-18 03:38:11

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

remove the trailing dot from the url; don't forget to build it using Make.bat

Last edited by toxa (2020-02-18 03:41:51)

Offline

 

#18 2020-02-18 06:18:46

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Sprite priority

I got it working but it's ultra SLOW.


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#19 2020-02-18 06:30:53

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

you might see it without compiling, just running the *.gb from my archive smile anyway, it's better to use modern sdcc, it's more reliable.

Offline

 

#20 2020-02-20 02:59:59

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

throw that all away. just use a window instead of your swatter sprite. setting the sprite priority allows you to put yout sprites in front or behind the window. your case - always behind.

Last edited by toxa (2020-02-25 11:33:10)

Offline

 

#21 2020-02-21 03:28:44

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: Sprite priority

ps: there is even an exelent example already: https://gbdev.gg8.se/forums/viewtopic.php?id=620

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson