Page 1 of 1

Pixel,circle,square and line draw

Posted: Fri Jun 15, 2018 2:07 am
by Cristiano Sword
hello guys, :D
I'm trying to create lines, pixels, circles and squares that appear on screen by sgdk, I know there's a function, but nn I'm getting it, could anyone help me :?: :(

Re: Pixel,circle,square and line draw

Posted: Fri Jun 15, 2018 2:27 am
by Chilly Willy
Look at the BMP commands. You can set pixels, draw lines, or draw polygons. If you use enough sides in the polygon, it'll appear circular.

Re: Pixel,circle,square and line draw

Posted: Sat Jun 16, 2018 12:59 pm
by Miquel
Or just draw circles and lines through tiles (sprites or planes) were Geny excels on. MD hardware wasn't designed to draw using bitmaps, Stef simulated it but with a performance penalty.

Re: Pixel,circle,square and line draw

Posted: Mon Jun 18, 2018 5:45 pm
by Cristiano Sword
I'm doing rain and snow effects for my rpg, I'll analyze if I get more perfomance like this or with tiles.
Although I have already seen that the functions are very different from the "line" of the Amiga and Msx.

Re: Pixel,circle,square and line draw

Posted: Mon Jun 18, 2018 8:46 pm
by Miquel
On a bitmap device (like a traditional PC) drawing lines and circles it's a very easy/basic arithmetic operation probably convenient for starters, but no on tile devices like MD.

I also recently pondered this functionality for my game and I can tell you the drawbacks of bitmap 'mode' on MD are:
- It uses a plane
- It uses a significant part of the vram
- Effectively lowers the resolution
- Takes a lot of cpu (it depends on how many raster ops)
- Lower fps
- Takes all (or a loooooot) bandwidth with vdp

The advantage is as long you have cpu available you can draw unlimitless.

You can reproduce rain/snow with sprites but with a 80 unit limit; or also you can use a plane with repeated pattern plus scroll(s) for better results and much less pain.

Re: Pixel,circle,square and line draw

Posted: Mon Jun 18, 2018 9:59 pm
by Sik
Cristiano Sword wrote:
Mon Jun 18, 2018 5:45 pm
I'm doing rain and snow effects for my rpg, I'll analyze if I get more perfomance like this or with tiles.
Although I have already seen that the functions are very different from the "line" of the Amiga and Msx.
There's a game (forgot the name now) that multiplexes two sprites across the screen and uses them to do snow (the multiplexing is needed to avoid hogging the whole sprite table with snow sprites).

If you don't need a separate plane for background (e.g. no parallax, or only linescroll or software-rendered parallax) you'd be better off using one of the tilemap layers for the job instead.

Re: Pixel,circle,square and line draw

Posted: Tue Jun 19, 2018 12:01 am
by Miquel
Sik wrote:
Mon Jun 18, 2018 9:59 pm
There's a game (forgot the name now) that multiplexes two sprites across the screen and uses them to do snow (the multiplexing is needed to avoid hogging the whole sprite table with snow sprites).
And do you know how they did it ?
Perhaps using h-blank time to change x and y of sprites.. or maybe changing the address of the sprite table...

Re: Pixel,circle,square and line draw

Posted: Tue Jun 19, 2018 2:12 am
by Sik
It just rewrites those sprite entries during hblank interrupts (possibly just the X and Y coordinates - an autoincrement of 6 can help here).

Note that you don't need to rewrite them every line (that'd be slow), just fast enough that it matches the difference between two uses of the same sprite (which was 8 lines in that case I think? would need to look up which game it was again to tell you). You don't even need to rewrite both sprites in the same line, you could alternate between each of them every time.

Re: Pixel,circle,square and line draw

Posted: Tue Jun 19, 2018 11:48 pm
by Cristiano Sword
I will try with sprites or a plan, thanks for the information, so I have managed to do post here in the forum :mrgreen: