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 2021-10-13 07:12:14

freshdeus
New member
Registered: 2021-08-31
Posts: 4

ZGB Engine: Issue with functions.

https://pbs.twimg.com/media/FBkv-veWYAQChJm?format=png&name=900x900

I get this error, when projectiles are spawned via functions. It only happens when my tileset / map exceed the number of 35 tiles. Under this number, the function works properly. Memory issue? Bad coding? Did I miss something? Iīm using the latest release of ZGB.

This is the code of the enemy, which will spawn a bullet.

 

Code:

if(data->DIR_Y == -1)
            {
            SPAWN_BULLET(THIS->x+6, THIS->y, 0, -1);
            }

This is the code of the bullet.


Code:

void SPAWN_BULLET(UINT16 x, UINT16 y, INT8 vx, INT8 vy)
{
    
    
    Sprite* bullet = SpriteManagerAdd(SpriteBullet, x, y);
    struct BULLET_DATA* data = (struct BULLET_DATA*)bullet -> custom_data;
    
    data-> vx = vx;
    data-> vy = vy;
    data-> DAMAGE = 1;
    
}

Offline

 

#2 2021-10-14 03:10:31

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

Re: ZGB Engine: Issue with functions.

what BGB shows you above is, obviously, execution of data. that might happen because of some sort of overflow/corrupting WRAM. what version of ZGB do you use? is it latest?

Offline

 

#3 2021-10-14 16:30:27

freshdeus
New member
Registered: 2021-08-31
Posts: 4

Re: ZGB Engine: Issue with functions.

Yeah,  2021.2 Version. I changed how the projectiles are spawned and now it works fine.

Thanks for your interest, toxa.  When you see this message, maybe you can tell me something about the VRAM. Is it possible to "clean" or to remove certain tiles from the VRAM to make up space for new sprites? Different levels, different enemies. Thatīs the idea. Is the limit really 256 non-BG tiles for the whole game?

Last edited by freshdeus (2021-10-14 16:31:10)

Offline

 

#4 2021-10-15 09:35:12

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

Re: ZGB Engine: Issue with functions.

just overwrite old data with new

Offline

 

#5 2021-10-16 17:29:49

freshdeus
New member
Registered: 2021-08-31
Posts: 4

Re: ZGB Engine: Issue with functions.

I donīt wanna sound like an annoying first-grader, but how can I force old data to be overwritten in ZGB? I am a absolute novice when it comes to coding and old machines...

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson