gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Draw same sprite multiple times.. framebuffer or HW sprites?

#162347 - gusano - Mon Sep 01, 2008 4:02 am

Hi,

I am working on a Othello clone, and it requires drawing the same black piece and white piece sprites multiple times. It also requires drawing a tiled background. I have two approaches:

1. Draw everything using a framebuffer. One sprite for black piece, one for white piece and one for small background tile to be reused. I know most of the people in this forum is against using framebuffer mode, but from what I've read about hardware sprites, you can only have 128 of them and you can't draw the same one in more than one place. I might be mistaken...

2. Use built-in sprite functionality, draw the "tiled" background to a hardware background from a single image and use ALL 128 hardware sprites for the white and black pieces.

Any other approach?

Also, if I wanted to write an isometric engine for the DS, would I have to use a framebuffer, or could I use one of the graphics modes for tiles already included on the DS? (Note: some isometric styles require drawing certain tile rows before others)

#162350 - DiscoStew - Mon Sep 01, 2008 4:37 am

For an Othello (Reversi?) clone, why not try this approach...

Why not just use a single hardware layer? A tileset that makes up an empty space, a tileset that makes up a white piece on that space, and one for a black piece. The pieces aren't just as they are, but what they would look like on the play board, like a square cut-out. When a piece is added, the hardware layer is edited directly from being an empty group to a group pertaining to the right piece tileset.

One hardware layer, and no sprites needed. You just need to know where to edit the hardware layer data, and what to edit it to.
_________________
DS - It's all about DiscoStew

#162351 - gusano - Mon Sep 01, 2008 4:46 am

That's an interesting approach, I hadn't thought of that... thanks! Can you point me in the right direction in terms of code? How do you edit the hardware layer data?

#162355 - silent_code - Mon Sep 01, 2008 7:34 am

Unless you want to be able to drag pieces with the stylus, then you'd at (least) need a single sprite. ;^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#162356 - jimis - Mon Sep 01, 2008 7:35 am

If you need more than 128 sprites you can use sprite multiplexing technique (moving sprites while they are rendered in order to use them twice).
You can do this by using an interrupt (I recommend vcount).
The only problem is that the amount of sprites available to render wont be stable. If you "force" the number of sprites to be fixed some will appear half.
But for particles this doesn't really matter.

#162359 - DiscoStew - Mon Sep 01, 2008 8:19 am

silent_code wrote:
Unless you want to be able to drag pieces with the stylus, then you'd at (least) need a single sprite. ;^)


Yeah, I should have mentioned that. If you have anything planning on moving singularly, using "some" sprites would help.
_________________
DS - It's all about DiscoStew

#162375 - AntonioND - Mon Sep 01, 2008 12:41 pm

jimis wrote:
If you need more than 128 sprites you can use sprite multiplexing technique (moving sprites while they are rendered in order to use them twice).

Or he could use 3D hardware with an ortogonal projection.

#162376 - tepples - Mon Sep 01, 2008 1:03 pm

It's best to use 2D mode if you can. It's simpler to program, and you can use 3D for the other screen if needed without having to use (complicated) capture mode. So I'd recommend that you use mode 0 for the bottom screen. To show this screen that I just made in GIMP, you'll need the following graphics in VRAM:
  • Empty space: 24x24 pixels, 9 tiles
  • Space with black piece and white piece: 24x24 pixels each, 18 tiles total
  • Black dot and white dot tiles: 8x8 pixels each, 2 tiles total
  • Digits 0-9: 16x24 each, 60 tiles total
  • Border: 8x8 pixels each, 8 tiles total

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#162377 - AntonioND - Mon Sep 01, 2008 1:09 pm

tepples wrote:
It's best to use 2D mode if you can. It's simpler to program, and you can use 3D for the other screen if needed without having to use (complicated) capture mode.

Yeah, I know, but I'm a 3D lover. ;P

#162385 - jimis - Mon Sep 01, 2008 6:14 pm

AntonioND wrote:
jimis wrote:
If you need more than 128 sprites you can use sprite multiplexing technique (moving sprites while they are rendered in order to use them twice).

Or he could use 3D hardware with an ortogonal projection.


Of cource and in fact it is possible to draw more than 1000 3D sprites.
But they limmited to one screen. 3D in both screens drops the framerate at 30 fps.