Author |
Message |
- Joined: 23 May 2017
- Posts: 3
|
Drawing circles, lines, dots, & other 2d geometry?
Posted: Tue May 23, 2017 5:54 am
|
Greetings! First time poster here.
I used the search function to try to find something on this topic but it was rather fruitless.
I'm attempting to develop a game that mimics the master system perfectly (though it wouldn't actually run on the original hardware by any means, but I would like it to appear as though it would), and I'm pretty well versed in how tile and sprite graphics work on the system. However, I have some instances in my game where it would be beneficial to be able to draw circles or lines (such as selecting a destination on a map and drawing a simple 1-pixel line from point A to point B, or in other instances drawing a circle or oval in the same way, though they wouldn't have to work particularly fast or even move or scroll on screen or anything).
Would it be possible for someone to program in the ability to draw these sorts of things on-screen on the master system? And if so, what would be the limitations of it?
|
|
|
- Joined: 01 Feb 2014
- Posts: 877
|
Posted: Tue May 23, 2017 6:01 am
|
FatBit wrote Would it be possible for someone to program in the ability to draw these sorts of things on-screen on the master system? And if so, what would be the limitations of it?
It wouldn't be impossible, but the limitations would be severe. Basically, you'd need to draw the line inside a copy of the tile data of the tiles it crosses, then replace the relevant tile numbers in the name table with those of the modified copies.
|
|
|
- Site Admin
- Joined: 19 Oct 1999
- Posts: 14745
- Location: London
|
Posted: Tue May 23, 2017 7:50 am
|
It's sometimes called Any Pixel Addressable (APA). It's not easy at all and requires the game to be built around it. Limitations are the number of tiles and the very slow speed.
|
|
|
- Joined: 05 Sep 2013
- Posts: 3828
- Location: Stockholm, Sweden
|
Posted: Tue May 23, 2017 8:19 am
|
If dots are enough for your needs, you could try using sprites and a single tile with just one dot in it, likely the one in the upper left corner, and leaving empty (transparent) all the rest of the tile.
Then you could make a dotted line (even "animated") using that 'trick', which would work as long as you don't try to put more than 64 dots on screen (sprites are 64 max) and you're not drawing a perfectly horizontal line using more than 8 dots (more than 8 sprites on a single screen line won't be drawn)
|
|
|
- Site Admin
- Joined: 19 Oct 1999
- Posts: 14745
- Location: London
|
Posted: Tue May 23, 2017 8:47 pm
|
Sprite overflow applies to transparent pixels too so the dots would have to be at a steep angle to avoid overflowing.
Some games draw lines into sprites, for rope swinging effects for example, and can use the same tile for all the sprites because it's a straight line.
|
|
|
- Joined: 05 Sep 2013
- Posts: 3828
- Location: Stockholm, Sweden
|
Posted: Wed May 24, 2017 8:50 am
|
Maxim wrote Sprite overflow applies to transparent pixels too so the dots would have to be at a steep angle to avoid overflowing.
Drawing the dots in the 'correct' order is enough. If the "almost horizontal" line goes down on the right, you should draw the sprites from right to left, the opposite otherwise. This way the 'dots' would have higher priority over the transparent pixels.
Maxim wrote Some games draw lines into sprites, for rope swinging effects for example, and can use the same tile for all the sprites because it's a straight line.
- this didn't occur to me. Nice idea!
|
|
|
- Joined: 17 Jan 2020
- Posts: 118
- Location: Brisbane, AU
|
Posted: Thu Jul 02, 2020 12:23 am
|
A small demo showing line rendering on the SG-1000
|
|
|
- Joined: 23 Aug 2009
- Posts: 213
- Location: Seattle, WA
|
Posted: Thu Jul 02, 2020 3:36 am
|
Another old trick: dedicate half of your palette (say, $8 thru $F, to your line color. This way, you only have to set one bit when “painting” lines onto BG patterns.
You’re still stuck with Bresenham, and some division lookups.
|
|
|