Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - General Scroll Library (GSLib)

Reply to topic
Author Message
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
General Scroll Library (GSLib)
Post Posted: Tue Sep 12, 2017 4:58 am
Last edited by psidum on Sat Sep 30, 2017 11:56 am; edited 4 times in total
Hi,

I wrote z80 code for a generic scroll engine for use in games / demos. Specifications are as follows...

- 16x16 pixel metatiles.
- 8 way scrolling.
- Supports tile and metatile lookup given an (x, y).
- Supports updating metatile on screen (vdp nametable). Think rings or destructable environment.
- Released under creative commons, free to include in all projects including commercial.

My intention was to stitch up some parser converting Tiled files (the app) to required data for engine however after further inspection I am finding it not the best solution. So I ask the community if they have some tools more fitting? I imagine this problem is not so uncommon for those who have been writing homebrew / hacking tools.

Ideally the tool would support some if not all...

- ordering of metatiles (controlling id for jump tables etc).
- use of metatile sets across multiple stages.
- priority property on nametable entries.
- ui to construct stages using above metatiles.
- export metatile tables and scrolltables (metatile arrays making map).

This project has been sitting around for a while, putting it out there to hopefully the ball moving again. Any thoughts or assistance is appreciated. Attached is the library and a demo ROM.

Psidum


EDIT: I will release documentation on library usage shortly. Currently fishing for potential front ends.

edit: made available via git https://bitbucket.org/Psidum/gslib
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 308
  • Location: Spain
Reply with quote
Post Posted: Tue Sep 12, 2017 8:10 am
wow! nice idea! I'll take a look at it when I have some hours to play with!
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1902
Reply with quote
Post Posted: Tue Sep 12, 2017 8:44 am
psidum wrote
My intention was to stitch up some parser converting Tiled files (the app) to required data for engine however after further inspection I am finding it not the best solution.


why not?

Also, is the library supporting smooth scroll?
  View user's profile Send private message Visit poster's website
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Tue Sep 12, 2017 9:30 am
Last edited by psidum on Tue Sep 12, 2017 10:50 pm; edited 1 time in total
Reasons I found Tiled app not a good fit...

- it is not possible to attach attributes to a tile use reference (array of tiles references forming map).
* not possible to mark nametable entry as priority set (in front)
* not able to add metadata using the unused 3 most significant bits in nametable entry.

- need to use additional layers to add meta information and its quite hard to do this in a generic fashion.
- need external tools for ordering tiles / metatiles for jumpt tables etc.

It supports scrolling of 1-8 pixels per axis. It sometimes looks jerky on emulators due to differences in monitor refresh rate but looks fine on real hardware and tv.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1902
Reply with quote
Post Posted: Tue Sep 12, 2017 10:01 am
as for the priority, you could have two layers and place tiles on either one or the other, merging them later with a separate tool or eventually at run time (which is what I did in my Anguna abandoned port...)

BTW the Mojon Twins should have some tools, hopefully they might share them with us...
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 232
  • Location: Málaga, Spain
Reply with quote
Post Posted: Tue Sep 12, 2017 10:09 am
LOL i had to limit the speed to 8 pixels per frame too, the repaint of a 8 pixels row or column in a frame is near from limit if you want to do something more... but it could be useful a mappy->csv->bin converter which i use for my own tilemap lib
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1902
Reply with quote
Post Posted: Tue Sep 12, 2017 1:40 pm
eruiz00 wrote
it could be useful a mappy->csv->bin converter which i use for my own tilemap lib


check out fmp2gba, it can create .c sources from mappy files.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Feb 2006
  • Posts: 453
  • Location: Belo Horizonte, MG, Brazil
Reply with quote
Post Posted: Tue Sep 12, 2017 10:39 pm
Good idea! One less technical detail to worry about. ;)
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 308
  • Location: Spain
Reply with quote
Post Posted: Wed Sep 13, 2017 7:44 am
Psidum, will you upload the library to github or other platforms? it would be useful for sharing the code.

BTW, a c fronted to be used from SDCC should be quite straightforward, shouldn't it?
  View user's profile Send private message
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Wed Sep 13, 2017 9:05 am
Last edited by psidum on Sun Oct 01, 2017 11:26 am; edited 1 time in total
Made Git project public https://bitbucket.org/Psidum/gslib

In example folder you can find an example z80 project displaying how the engine works.
- In main.asm, look for InitializeSMS to see how calls are made.
- In the resources folder you can see the two tables needed in ScrollData.inc. A bit of documentation on formats, will expand on this.

I will document more over the coming days including a rundown of all calls and document formats.

I consider this a bit of a community project so if you have questions or suggestions let me know. I am particularly interested in perspective from people writing games.

psidum.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1902
Reply with quote
Post Posted: Wed Sep 13, 2017 3:39 pm
Quote
Default location of Metatiles (on rom) is $4000. If another location is needed change GSE_METATILE_TABLE and GSE_METATILE_TABLE_HIGH_BYTE to desired location (must be on 2k boundary)


I was wondering... what if we need the location of the Metatiles to be absolutely free instead?
  View user's profile Send private message Visit poster's website
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Thu Sep 14, 2017 12:43 am
Postion was locked for speed. I imagined the metatiles and scrolltables would be decompressed to RAM so in this case you could decompress metatiles at say $C000.

Looking back the engine is faster than I expected. The peek performance cost for pure scrolling in 8 directions is 30 scanlines in active display and 17 in vblank. It is less for single axis only.

If this limitation proves to be a problem I could switch to flexible position for about 4-5 extra scanlines in active display.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1902
Reply with quote
Post Posted: Thu Sep 14, 2017 7:58 am
not that I need it at the moment, it's just that I was wondering what if one had the metatiles somewhere in (banked) ROM. I see your point :)
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 232
  • Location: Málaga, Spain
Reply with quote
Post Posted: Thu Sep 14, 2017 9:10 pm
Ummm... appart of this, could be interesting a c interface, if could be compatible with smsdevkit, by example.

Next thing could be a flixel like engine with scene object managing (simplified) which could be a boost for sms homebrew.
  View user's profile Send private message
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Fri Sep 15, 2017 4:04 am
I updated with some more documentation. I have copies it below. I plan to make another pass in around 2 weeks taking in any suggestion from forums.

I agree with your points sverx about flexible metatile table positioning and will switch this in next version. The plan is to create a c interface once the project has settled.
  View user's profile Send private message
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Fri Sep 15, 2017 4:09 am
Last edited by psidum on Sat Sep 30, 2017 2:31 am; edited 1 time in total
edit: documents can be found in project.
  View user's profile Send private message
  • Joined: 23 Mar 2013
  • Posts: 520
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Fri Sep 15, 2017 8:24 am
Thanks for putting this work out in the open! I don't have anything to add or suggest at the moment - but just wanted to say that I get a lot of sms-programming education from studying how you approach this problem of scrolling.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Sat Sep 30, 2017 2:36 am
Project Updated.

- Removed 2k boundary requirement for metatile table. Can now be positioned anywhere.
- Changed name of project.
- Added documentation of file formats.


Apologies to anyone who has been playing with it, you will need to update git repository address.

Next on list of things is to re purpose some internal graphics tools for basic parsing then implementing a c interface.

Psidum
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 308
  • Location: Spain
Reply with quote
Post Posted: Sat Sep 30, 2017 2:06 pm
Thanks for the great work psidum!!
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1902
Reply with quote
Post Posted: Sun Oct 01, 2017 3:01 pm
once we get a C interface we should see if it's easy to integrate with devkitSMS - hopefully it should be :)
  View user's profile Send private message Visit poster's website
  • Joined: 01 Jan 2014
  • Posts: 290
Reply with quote
Post Posted: Sat Oct 14, 2017 3:24 am
Hey,

I put together a tool for parsing images / tiled documents to data for the scroll engine.

Not going to lie, the tiled doc paring stuff works but it is not great. I spoke about the issues associated with tiled documents previously in this thread, the tool expects the xml doc to be in a specific format, you can find documentation about this with the tool. There is a base document to help get started, alternatively you can turn an image in to a tiled document with the tool which will have everything in place.

On the other hand, the image to scroll data is very straight forward and easy to use. The tool can also parse nametables, tiles, palettes etc.

The tool requires the latest version of java installed. For macintosh users you will need to manually install the latest version (osx is bundled with an older version). If nothing happens when you start up the app this is probably the issue.

Like the z80 engine this is a work in progress. If run in to issues, have questions or can think of a better way to integrate the tiled doc stuff please post here or contact me on the sms power irc channel.

Psidum.
UGT.zip (91.92 KB)

  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!