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 2017-02-02 00:23:15

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Help with the sprite tiles

Hello everyone, i'm new in this forum and in the programing of gameboy (really too newest) and i have a problem for the sprites tiles.
I create a sprite with 10 tiles of 8x8, i have compiling and i tried in the emulator, but the last 2 tiles are not visible. Both in the emulator, and in the vram viewer.
So, if someone know what is the problem plz tell me, thanks :"^)

p.s: sorry if the english are bad, it's not my native launguage

Offline

 

#2 2017-02-02 05:44:33

svendahlstrand
Member
Registered: 2016-12-07
Posts: 17
Website

Re: Help with the sprite tiles

Hello! I'm also new in the Game Boy development world. smile There's a lot of constraints you have to work around. You've probably run into this one:

Only 10 sprites can be displayed on any one line. When this limit is exceeded, the lower priority sprites (priorities listed above) won't be displayed. To keep unused sprites from affecting onscreen sprites set their Y coordinate to Y=0 or Y=>144+16. Just setting the X coordinate to X=0 or X=>160+8 on a sprite will hide it but it will still affect other sprites sharing the same lines.

http://bgb.bircd.org/pandocs.htm

Offline

 

#3 2017-02-02 11:50:59

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

hmm but i don't exceeded the limit...
well, really i create a sprite with 3 tiles of 16x16 following this tutorial: http://gbdev.gg8.se/wiki/articles/GBDK_Sprite_Tutorial

i suposse the limit of sprites in 16x16 it's of 2 tiles hmm

Offline

 

#4 2017-02-02 17:00:11

svendahlstrand
Member
Registered: 2016-12-07
Posts: 17
Website

Re: Help with the sprite tiles

No, I don't think thats the case. Is your source code available somewhere? Maybe I could help you spot the problem. smile

Offline

 

#5 2017-02-02 17:01:59

AntonioND
Member
Registered: 2014-06-17
Posts: 134
Website

Re: Help with the sprite tiles

The limit is 10 hardware sprites per line, so that means that you can have up to 80 pixels (transparent or not) of sprites in one line. Could you show code or something? It should work, there must be something else wrong... Just yesterday I placed 40 8x16 sprites in a 10x4 grid, so it can be done.

Offline

 

#6 2017-02-02 22:11:16

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

that's the code:

Code:

#include <gb/gb.h>
#include <gb/cgb.h>
#include "edd.c"

void main(){
    SPRITES_8x16;
    set_sprite_data(0, 8, edd);
    set_sprite_tile(0, 0);
    move_sprite(75, 75);
    set_sprite_tile(1, 2);
    move_sprite(1, 75 + 8, 75 - 11);
    set_sprite_tile(3, 4);
    move_sprite(3, 75, 75 + 5);
    set_sprite_tile(5, 6);
    move_sprite(5, 75 + 8, 75 + 5);
    set_sprite_tile(7, 8);
    move_sprite(7, 75, 75 + 11);
    SHOW_SPRITES;
}

Last edited by l130 (2017-02-02 22:13:44)

Offline

 

#7 2017-02-02 22:12:17

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

that's the code with the 2 last tiles

Offline

 

#8 2017-02-03 03:18:51

svendahlstrand
Member
Registered: 2016-12-07
Posts: 17
Website

Re: Help with the sprite tiles

That code shouldn't compile:

move_sprite(75, 75);

move_sprite takes three arguments but you're just passing two at this line.

http://gbdk.sourceforge.net/doc/html/c0504.html

Offline

 

#9 2017-02-03 12:18:18

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

hmm....well yeah, but even so the last 2 tiles don't look yet sad

Offline

 

#10 2017-02-03 14:25:44

svendahlstrand
Member
Registered: 2016-12-07
Posts: 17
Website

Re: Help with the sprite tiles

It's a challenge when I don't have the complete source. smile Could you post edd.c aswell? Anyhow, here a couple of more things that looks a bit strange (see my comments):

Code:

void main(){
  SPRITES_8x16;
  
  // You push 8 tiles here but on the last call to set_sprite_tile(7, 8) you reference a ninth tile (index 8).
  set_sprite_data(0, 8, tiles); 

  // 1st 16x16 sprite...
  set_sprite_tile(0, 0);
  move_sprite(0, 75, 75);
  set_sprite_tile(1, 2);
  move_sprite(1, 75 + 8, 75 - 11);

  // 2nd 16x16 sprite
  set_sprite_tile(3, 4);
  move_sprite(3, 75, 75 + 5);
  set_sprite_tile(5, 6);
  move_sprite(5, 75 + 8, 75 + 5);

  // 8x16 sprite (this is not a complete 16x16 sprite.
  set_sprite_tile(7, 8);
  move_sprite(7, 75, 75 + 11);

  SHOW_SPRITES;
}

Offline

 

#11 2017-02-17 01:21:43

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

sorry for being late...

that's the code:

Code:

/* CGBpalette entries. */
unsigned char eddCGB[] =     // i was try to put color in the rom, it does thing matter
  0x00,0x00,0x00
};
/* Start of tile array. */
unsigned char edd[] =
{
  0xD7,0xD7,0xA8,0xFF,0x40,0x7F,0x5F,0x60,
  0x7F,0x40,0x7D,0x5F,0x5F,0x77,0x5F,0x70,
  0x58,0x70,0x58,0x70,0x78,0x70,0x38,0x30,
  0x1E,0x18,0x0F,0x0F,0x06,0x06,0x09,0x0F,
  0xF0,0xF0,0x1C,0xFC,0x02,0xFE,0xFE,0x02,
  0xFF,0x01,0xDB,0xFD,0xFE,0x6E,0xCE,0x4A,
  0x4A,0x4A,0x4A,0x4A,0x12,0x12,0x76,0x76,
  0x0C,0x0C,0xF8,0xF8,0x20,0x20,0xF0,0xD0,
  0x19,0x1F,0x23,0x3D,0x27,0x39,0x2F,0x39,
  0x2F,0x39,0x2F,0x39,0x2F,0x38,0x4F,0x78,
  0x4F,0x79,0x4E,0x7B,0x4F,0x7A,0x7F,0x7F,
  0x58,0x5F,0x78,0x7F,0x09,0x0F,0x08,0x0F,
  0xF8,0x58,0xF4,0x5C,0xFC,0x54,0xFC,0x54,
  0xFC,0x14,0xFC,0x14,0xFC,0x14,0xFA,0x16,
  0xFE,0xD2,0xBE,0x72,0xFA,0x36,0xFE,0xFE,
  0x1A,0xFA,0x1E,0xFE,0xD0,0xF0,0x90,0xF0,
  0x08,0x0F,0x08,0x0F,0x08,0x0F,0x08,0x0F,
  0x08,0x0F,0x08,0x0F,0x08,0x0F,0x0F,0x0F,
  0x0F,0x08,0x18,0x10,0x1F,0x1F,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x90,0xF0,0x90,0xF0,0x90,0xF0,0x90,0xF0,
  0x90,0xF0,0x90,0xF0,0x90,0xF0,0xF0,0xF0,
  0xFC,0x8C,0xF2,0x42,0xFE,0xFE,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

/* End of EDD.C */

Offline

 

#12 2017-02-17 01:44:08

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

i suppose that this is an error or something of the gbdk, i read that the gbdk it's not good for programing gb games because this is a complier too oldest, so...if someone can suggest me a tutorial of other compiler or assembler (that i suppose is to port the games on a cartridge if i'm not mistaken) or something like that i would thank a lot smile

Offline

 

#13 2017-02-18 07:29:59

svendahlstrand
Member
Registered: 2016-12-07
Posts: 17
Website

Re: Help with the sprite tiles

Hello again! Yes, gbdk is old, and if you'd like to use C, you should start using gbdk-n. It's an effort to modernize gbdk and make it compatible with the latest version of sdcc (the compiler).

Anyway, I've modified your code once again to make it compile (the edd.c file you provided had a missing {). Here follows the complete working example and a screenshot. I hope this answer helps you. smile

Code:

#include <gb/gb.h>

// Removed unused eddCGB.

unsigned char edd[] = {
  0xD7,0xD7,0xA8,0xFF,0x40,0x7F,0x5F,0x60,
  0x7F,0x40,0x7D,0x5F,0x5F,0x77,0x5F,0x70,
  0x58,0x70,0x58,0x70,0x78,0x70,0x38,0x30,
  0x1E,0x18,0x0F,0x0F,0x06,0x06,0x09,0x0F,
  0xF0,0xF0,0x1C,0xFC,0x02,0xFE,0xFE,0x02,
  0xFF,0x01,0xDB,0xFD,0xFE,0x6E,0xCE,0x4A,
  0x4A,0x4A,0x4A,0x4A,0x12,0x12,0x76,0x76,
  0x0C,0x0C,0xF8,0xF8,0x20,0x20,0xF0,0xD0,
  0x19,0x1F,0x23,0x3D,0x27,0x39,0x2F,0x39,
  0x2F,0x39,0x2F,0x39,0x2F,0x38,0x4F,0x78,
  0x4F,0x79,0x4E,0x7B,0x4F,0x7A,0x7F,0x7F,
  0x58,0x5F,0x78,0x7F,0x09,0x0F,0x08,0x0F,
  0xF8,0x58,0xF4,0x5C,0xFC,0x54,0xFC,0x54,
  0xFC,0x14,0xFC,0x14,0xFC,0x14,0xFA,0x16,
  0xFE,0xD2,0xBE,0x72,0xFA,0x36,0xFE,0xFE,
  0x1A,0xFA,0x1E,0xFE,0xD0,0xF0,0x90,0xF0,
  0x08,0x0F,0x08,0x0F,0x08,0x0F,0x08,0x0F,
  0x08,0x0F,0x08,0x0F,0x08,0x0F,0x0F,0x0F,
  0x0F,0x08,0x18,0x10,0x1F,0x1F,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x90,0xF0,0x90,0xF0,0x90,0xF0,0x90,0xF0,
  0x90,0xF0,0x90,0xF0,0x90,0xF0,0xF0,0xF0,
  0xFC,0x8C,0xF2,0x42,0xFE,0xFE,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

void main(){
  SPRITES_8x16;

  // You push 8 tiles here but on the last call to set_sprite_tile(7, 8) you reference a ninth tile (index 8).
  set_sprite_data(0, 8, edd);

  // 1st 16x16 sprite...
  set_sprite_tile(0, 0);
  move_sprite(0, 75, 75 - 11); // I've adjusted this value.
  set_sprite_tile(1, 2);
  move_sprite(1, 75 + 8, 75 - 11);

  // 2nd 16x16 sprite
  set_sprite_tile(3, 4);
  move_sprite(3, 75, 75 + 5);
  set_sprite_tile(5, 6);
  move_sprite(5, 75 + 8, 75 + 5);

  // 8x16 sprite (this is not a complete 16x16 sprite.
  set_sprite_tile(7, 8);
  move_sprite(7, 75, 75 + 11);

  SHOW_SPRITES;
}

https://i.imgur.com/zyuXbRt.png

Offline

 

#14 2017-02-23 11:51:58

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

well this is not the problem, the problem it's that the last 2 sprites has this sprites:
https://i.imgur.com/h7YCa6m.png

something curious it's this:

Code:

nsigned char edd[] =
{
  0xD7,0xD7,0xA8,0xFF,0x40,0x7F,0x5F,0x60,
  0x7F,0x40,0x7D,0x5F,0x5F,0x77,0x5F,0x70,
  0x58,0x70,0x58,0x70,0x78,0x70,0x38,0x30,
  0x1E,0x18,0x0F,0x0F,0x06,0x06,0x09,0x0F,
  0xF0,0xF0,0x1C,0xFC,0x02,0xFE,0xFE,0x02,
  0xFF,0x01,0xDB,0xFD,0xFE,0x6E,0xCE,0x4A,
  0x4A,0x4A,0x4A,0x4A,0x12,0x12,0x76,0x76,
  0x0C,0x0C,0xF8,0xF8,0x20,0x20,0xF0,0xD0,
  0x19,0x1F,0x23,0x3D,0x27,0x39,0x2F,0x39,
  0x2F,0x39,0x2F,0x39,0x2F,0x38,0x4F,0x78,
  0x4F,0x79,0x4E,0x7B,0x4F,0x7A,0x7F,0x7F,
  0x58,0x5F,0x78,0x7F,0x09,0x0F,0x08,0x0F,
  0xF8,0x58,0xF4,0x5C,0xFC,0x54,0xFC,0x54,
  0xFC,0x14,0xFC,0x14,0xFC,0x14,0xFA,0x16,
  0xFE,0xD2,0xBE,0x72,0xFA,0x36,0xFE,0xFE,
  0x1A,0xFA,0x1E,0xFE,0xD0,0xF0,0x90,0xF0,
  0x08,0x0F,0x08,0x0F,0x08,0x0F,0x08,0x0F,
  0x08,0x0F,0x08,0x0F,0x08,0x0F,0x0F,0x0F,
  0x0F,0x08,0x18,0x10,0x1F,0x1F,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x90,0xF0,0x90,0xF0,0x90,0xF0,0x90,0xF0,
  0x90,0xF0,0x90,0xF0,0x90,0xF0,0xF0,0xF0,
  0xFC,0x8C,0xF2,0x42,0xFE,0xFE,0x00,0x00, //since here the sprites are 0x00, how like this is are in blank
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

Last edited by l130 (2017-02-23 11:53:02)

Offline

 

#15 2017-02-25 14:38:50

Tag365
Member
Registered: 2016-06-01
Posts: 41

Re: Help with the sprite tiles

I already found a problem. As shown before, the bottom row is too wide to be shown in a single 8x16 sprite. So you need six 8x16 sprites to represent that object, not five as you were attempting to do before.

Offline

 

#16 2017-02-26 15:52:07

l130
Member
From: Mexico
Registered: 2016-12-24
Posts: 13

Re: Help with the sprite tiles

oh well, also i feel the sprite it's big for be a character playable, so i'm go to reduce the sprite a little bit, well..thanks for their help smile

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson