Animal Crossing (NES game)

From Pin Eight
Revision as of 16:03, 10 December 2009 by Tepples (talk | contribs) (RAM: on the other hand)
Jump to: navigation, search

Nintendo's Animal Crossing series was originally developed with the Nintendo 64 in mind. Some members of the nesdev.com board claim that technical limitations of a target platform do not limit gameplay possibilities. But here I show how a homebrew clone of AC for the Nintendo Entertainment System isn't too likely to happen.

PPU

The NES PPU (Picture Processing Unit) has a display list into which the CPU can load 64 instructions to draw "sprites", or small animated images, at any point on the screen. Sprites that appear earlier in this display list are drawn "in front" of later sprites. But only eight sprites can appear on each scanline at once; if there are more, the ones in back are hidden. The "flicker" that one sees in NES games comes from the game rapidly switching which sprites are in front so that important sprites don't disappear completely. Most NES games' characters are 16 pixels wide, consisting of two sprites.

NES has a backdrop color, four 3-color palettes for background tiles, and four 3-color palettes for sprites. A few games (such as Mega Man series) overlay multiple sprites on top of each other to squeeze more colors into a small space, but that increases the flicker problem, and fewer colors are available for different objects. Already, once the player walks up next to three animal neighbors, all four palettes would be in use, leaving nothing for the tools.

For a player character, the three colors might be the outline, clothes, and skin. This doesn't allow for clothes with patterns on them, unless patterns are reduced to a 1-bit pattern of clothes and outline. And even then, we'd need to build real-time texture-mapping software render the pattern onto the clothes as the player moves. That's not going to happen on an NES. The first Nintendo console designed for a fully texture-mapped environment was Nintendo 64, on which the Japanese beta version of Animal Crossing was released. So the Able Sisters would be reduced to selling solid colors.

The Game Boy Color has Harvest Moon GBC. Its sprite palettes follow the general scheme of outline, clothes, and skin, and there appears to be an overlay sprite for additional clothes. But the GBC has double the overdraw coverage (80 sprite pixels across 160 screen pixels) compared to the NES (64 sprite pixels across 256 screen pixels), making flicker less of a problem. It also has twice as many palettes (eight for backgrounds and eight for sprites).

RAM

AnimalMap is an editor for Animal Crossing: Wild World saved games. The editor's source code reveals that the game stores the state of the town in the first 0x15FE0 = 90080 bytes of a 256 KiB serial flash chip. (The rest of the save chip contains a backup copy of the last known good state of the town and numerous letters that the players have saved.) It is split up as follows:

  • 51 patterns that the players can design at 560 bytes each (28560 bytes)
    • Each pattern consists of a 48-byte header and a 32x32x4-bit bitmap.
    • 8 patterns for each of 4 players
    • 8 patterns for Able Sisters
    • 1 pattern for each of 9 neighbors
    • 1 pattern for town flag
    • 1 pattern for Blanca's face
  • 16 acre maps at 544 bytes each (8704 bytes)
    • Each is a 16x16-cell array of 16-bit entries, with a special value indicating an empty cell, followed by a bit array to state whether the item is buried.
  • 14 room maps at 1024 bytes each (14336 bytes)
    • Two 16x16-cell arrays of 16-bit entries, denoting the items on top and on bottom.
  • 59 letters at 244 bytes each (14396 bytes)
    • Each letter has an addressee, a salutation, four lines of text, a closing, an optional item, and a state (outgoing, incoming unopened, or incoming opened).
    • 10 letters in mailbox
    • 10 letters for each of four players
    • 1 letter for each of 9 neighbors (incl. neighbor in transit)
  • 128 friend codes at 28 bytes each (3584 bytes)
  • "Catalog" data, a bit for each item telling whether the player has touched it before, 288 bytes for each of four players (1152 bytes)
  • Other data that I haven't broken down yet, including the notice board, all players' closets, museum donations, player catalogs, and data about neighbors' relationships with players (19348 bytes)

Most NES boards with battery-backed PRG RAM use a 6264 SRAM chip, which provides 8192 bytes of storage. I did find a few easy cuts that one could make, but it would still need to get much smaller to fit in a typical NES save chip:

We already know from PPU above that we can completely get rid of the 50 patterns that ACWW lets players design. And removing the "catalogs" would arguably make the game more realistic as the player could mail-order any available item, even if it would diminish the "gotta catch 'em all" aspect that the game shares with Pokémon series and Katamari series.

The NES doesn't have a network connection, so we won't be able to link one town to another. This means we can do away with the room and letter for the neighbor in transit, saving 1 room and 1 letter. Nor do we need the friend codes.

We can compress the rooms. ACWW rooms are very wasteful: only an 8x8 quadrant is ever used, and the second layer is completely empty unless there's something on a table. (Haste makes waste, but haste also gets the game out the door in time for the holiday season.) To limit the geometry and textures that go into a scene, ACWW already limits how many things can be put into a room without the floor breaking. We can keep a restriction that there be 32 or fewer items in each acre or room, which would let us code each room in 96 bytes, with each item taking 4 bits for x, 4 bits for y, and 16 bits for what item. There would be no need for "layers" because two objects could be put at the same (x, y) location. NPC neighbors tend not to keep as many items in their rooms, so we can limit their rooms to 16 items. At 96 bytes each, 5 rooms and 8 half-rooms take 864 bytes.

ACWW stores 544 bytes for each acre. That's 16x16 cells by 16 bits in each cell plus a flag for whether each cell is "buried". We could encode acres similarly to rooms at the cost of things like fruit disappearing if they're left out for too long. The 16 acres would take 1536 bytes.

Nintendo promotes ACWW as a "communication" game. Players can send 244-byte letters to one another and to their animal neighbors. We could cut it down to 5 letters per human, for a total of 38. And we could probably compress letters to 128 bytes per player with a static Huffman table (adjusting "ink" accordingly) for 4864 bytes.

How well did we do so far? 864 bytes of rooms + 1536 bytes of acres + 4864 bytes of letters + 19348 bytes of "other" = 26612 bytes, which would fit in the SRAM in EWROM with a bit of room to spare. But Nintendo still didn't release games like SimCity and the English version of Mother due to replication cost, so let's stick to common boards.

With the low-hanging fruit shaken off, the rest of cutting will have to be done from the bottom up: finding specific things that we want to keep.

  • Acres: 1536 bytes
  • Rooms: 864 bytes
  • Post office: 10 letters at 128 bytes each, for a total of 1280 bytes
  • Player basic data: let's say 1024 bytes for each of 4, including a 4-byte bank balance, 4-byte reward point balance, 30-byte inventory, and five 128-byte letters, for a total of 4096 bytes
  • NPC basic data: let's say 256 bytes for each of 8, including a 128-byte letter, for a total of 2048 bytes
  • Town data (name, rivers, last play date, civic fund balance, lost and found, recycler, Tom Nook's store, etc.): let's say 512 bytes

Total: 10336 bytes, which is still over the size in common boards. And this will only grow to converge with the high water mark as the "other" things get broken down.

Further research:

  • Determine what I'm not looking at in these byte counts
  • Figure out how to keep the bottom-up figure under 8,192 bytes so that it will fit in the persistent half of PRG RAM in SOROM

Real-time clock

Apart from the public beta version of Doubutsu no mori on the Japanese Nintendo 64, all versions of Animal Crossing have run on a platform with a built-in real-time clock: GameCube, DS, and Wii. An NES version could go the route of Pokemon on Game Boy Color, including a real-time clock on the Game Pak. But again, that would have run up replication cost.