bonimy / MushROMs

Super Nintendo game editing libraries and tools
GNU Affero General Public License v3.0
31 stars 1 forks source link

Organizing controls and editors #38

Open bonimy opened 6 years ago

bonimy commented 6 years ago

Issue

The primary purpose of the last rewrite was that a lot of code was becoming tangled in an unsavory way. Code for windows controls would have editor and tilemap logic in them. And GUI-agnostic code would try to accommodate too much for GUI features. The source code upload is now at a stage where there is danger of this happening again. Therefore, it would be helpful to discuss what exactly these controls should do, and with that, where the logic for each feature belongs.

Features

Tilemaps

My personal definition of a "tilemap" has changed a lot since developing MushROMs. At its most basic, I should define it simply as a map of tiles. Some examples are given below:

Figure 1: A Palette TileMap

palettetilemap1

Figure 2: A GFX TileMap

gfxtilemap1

Figure 3: A Map16 TileMap

map16tilemap1

These are all One-Dimensional tilemaps. Their data is stored in a single array. This may seem confusing since we've all been familiar with all of the above mentioned being 16x16 or 16x8 in almost any experience. However, a single Palette row defined in a rom could be 2 colors, 4, 8, 16, or 256. And legend of zelda, link to the past loads its palettes every 15 colors, ignoring the transparent first color. So there are several exceptions that merit these being 1D tilemaps.

For a 1D tilemap, the main parameter we have is its length, how many tiles it has. In each case, it's 256. Every 16 tiles, the image wraps to the next row. The utility of a 1D tilemap is that if we change the width of the view area, the data will wrap accordingly, as shown in the following examples:

Figure 4: A Palette tilemap with width reduced to 15 tiles

palettetilemap2

Figure 5: A GFX tilemap with width reduced to 9 tiles

gfxtilemap2

Figure 6: A Map16 TileMap with width increased to 18 tiles

map16tilemap2

In each case, the data wraps according to the size of the view area. A good example of a 1D tilemap would be a line of text in a text editor that has word wrap turned on.

2D TileMaps

A 2D tilemap is one that has a defined height and width. In this case, change the view area doesn't change the layout. A good example would be a picture in an image editing program, or several lines of text in a text editor with no word wrapping.

In our case, a 2D tilemap would be a level editor (Lunar Magic has an obviously good example of this).

Properties of TileMaps

Properties that 1D and 2D tilemaps share are:

Properties that 1D tilemaps have are

The 2D tilemap properties are analagous

Resolution