Giter Club home page Giter Club logo

snescityeditor's Introduction

snescityeditor

snescityeditor is a small program designed to create/edit maps for the NES and Super NES versions of SimCity by modifying SRAM save files.

Compilation/Installation

Binaries for Windows users

For Windows users, statically-compiled binaries for both the NES and SNES editors and available in the "releases" section. The ZIP file labeled snescityeditor-win32.zip should include both nescityeditor.exe and snescityeditor.exe.

Download for Windows

Compiling from source

snescityeditor's primary functionality only depends on one library, which is libpng. It should be easily available in any distribution's repositories. The graphical interface also depends on SDL2 and SDL_image (2.0.1 or later). It's enabled by default, but can be removed by editing the Makefile.cfg file and setting "SDL_UI" to 0.

To pick whether the SNES or NES game should be used, set the "NESMODE" variable inside the Makefile.cfg file to an empty string or 1 respectively.

The program compiles into a single executable file that doesn't require installation. Users that want to do so are welcome to copy the resulting file into /usr/local/bin or an equivalent directory manually.

(Even if the program is compiled with the graphical interface, the command line parameters will still work.)

Usage

General

The game provides a way to convert maps either between the SRAM formats of the NES or SNES game (typically saved as .sav files for NES and .srm files for SNES) and user-readable PNG images.

The SNES game's maps are 120 tiles wide and 100 tiles tall. The NES game's maps are 76 tiles long both horizontally and vertically. The PNG map files fit each tile in one pixel and should therefore have a resolution of either 120x100 or 76x76.

Different pixel colors represent different tiles (the pngmap.c file contains a list of tiles, along with their RGB values), but the most important ones are water (#0030AC), land (#B59273) and forest (#008300). Certain variations on these colors are used to refer to different varieties of tiles.

These maps can either be created in a graphics editor (good for converting real-world maps) or in the program's graphical interface.

Graphical interface

By default, the program opens with a menu providing different operations. This menu is still a work in progress, and there might be bugs, but it should work for the most basic needs.

The graphical interface is operated with a mouse. A keyboard can also be used (but isn't necessary) on the city rename screen.

The user can either open the map editor to create a new map from scratch or load an existing map from an SRAM file or a PNG map file. To load existing SRAM or PNG files into the program, their icons have to be dropped into the window. (This was the easiest to implement cross-platform way of getting a file path that didn't involve implementing a file picker dialog.)

In the map editor, left-clicking places tiles and right-clicking scrolls the map around.

The options screen (shown on loading a map and accessible by clicking the gear-shaped icon in the editor) allows to set the city's in-game name, as well as apply several transformations to the map to improve its appearance.

After all the parameters are specified and a "save" option is chosen, the program will report either "success" or "error", with an error description if one is available.

Screenshots

Title Screen

Map Options Screen

Editor Screen

Command line

The program can also run on a command line, in which case it takes arguments in a following format:

snescityeditor -<ceif> [-2] [-x] sramfile.srm mapfile.png

The first argument sets the mode in which the program operates:

  • -c will import a map from the PNG file and create an SRAM file from scratch based on said map. (WARNING: if an SRAM file under the specified name already exists, it will be overwritten!)

  • -e will extract a map from the specified SRAM file and save it into the specified PNG file, overwriting it.

  • -i will import a map from the PNG file and use it to replace the city map in the SRAM file.

  • -f will update the checksums in an SRAM file to ensure it opens in the game. (The program also does this when using the -i switch. This switch is useful in case the user wants to manually modify the SRAM file.)

Optional switches are as follows:

  • -2 will make the program operate on the second city in the SRAM file. This switch is unnecessary when using -f, as it updates all checksums. This switch doesn't work with the -c command due to being unnecessary.

  • -n allows to specify a city name (max. 8 (SNES) or 10(NES) characters) that will be used when creating a new SRAM file. If not specified, the city name will be based on the PNG map file name.

  • -x will tell the game that the map needs to be "improved" before being imported into the game. This involves redrawing the roads, bridges, the coastline and the forests to make sure they look smooth. Given that, most of the time, the map is drawn with solid colors, this is practically necessary to achieve a good-looking map.

  • -I allows to specify binary flags that can change how the improvement process works. To select the flags, add up the numbers listed below:

    1: draw a coastline from scratch instead of fixing the already existing one.

    2: draw a thicker, better-looking coastline (requires 1). Might result in small islands being shrunk or removed.

    4: (experimental algorithm) try to draw a thick coastline w/o overwriting sea tiles (requires 1). Maps imported this way may need manual editing.

    8: when drawing a thick coastline, check if the shore tiles fit each other. When using flags 1 and 2, results in less island shrinkage, but weirder- -looking maps.

Bugs

Mac OS: using drag-and-drop to import files requires additional modifications involving the info.plist file. In addition, this program hasn't been tested on Mac OS.

SNES: The program only performs a simplified compression routine on maps when importing them into the game. This means that a complex map, including lots of buildings or complex river/forest patterns, might be impossible to import back.

The program doesn't report every single error when importing a map. If the map is malformed, it might result in a glitched city in the game.

It only modifies the city map and none of the other variables, so it might cause glitches when replacing a city map that already had buildings/citizens/etc.

Acknowledgments

NES: Information on how the data in the SRAM file is located is, in part, based on Cah4e3's disassembly of the game.

Disclaimer

The program shouldn't cause your computer to melt, but there's no definitive evidence it can't. Use it at your own risk.

snescityeditor's People

Contributors

usrshare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

snescityeditor's Issues

Trouble Compiling on Mac

Hello!

Wondering if you could help me get this working on Mac. I'm not very familiar with C, but I'm getting this error:

make: sdl2-config: Command not found

src/snescity.c:839:4: warning: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Wimplicit-function-declaration]

snprintf(ci ? city2 : city1, 17, "%d. %4d %-8s",ci+1,year,name);

src/snescity.c:839:4: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'

1 warning generated.

make: sdl2-config: Command not found

src/pngmap.c:3:10: fatal error: 'malloc.h' file not found

#include <malloc.h>

1 error generated.

make: *** [obj/pngmap.o] Error 1

Is this something you could help me with? Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.