+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  SMB - Castle Structure?
Pages: [1] 2
Author Topic: SMB - Castle Structure?  (Read 2 times)
Darkdata
Guest
« on: December 16, 2007, 05:09:12 pm »

When you beat a level you go from the flag to the castle, but I was wondering how the castle is made up? How would one change it to say.. just have the door? Or change what it looks like entirely?

Does anyone know?
Archon276
Guest
« Reply #1 on: December 16, 2007, 08:23:49 pm »

delete the sprites of the castle.
Griff Morivan
Guest
« Reply #2 on: December 16, 2007, 10:12:34 pm »

Several SMB editors allow you to remove the castle sprites. Or edit them, for greater effect, using TLP.
Dr. Floppy
Guest
« Reply #3 on: December 17, 2007, 04:09:52 am »

The castles are interesting... You can basically edit as much or as little as you want. Tiles are arranged into macros, which are themselves subsequently arranged in certain patterns to comprise the end-of-level X-1/X-2 castle, as well as the larger ones at the end of X-3. Put simply, one section of the game code lets you assign specific tiles to 2x2 macro blocks, while another section lets you decide how those 2x2 blocks are arranged. 

I'd give you the location info now, but I just got back from the airport after a connecting flight (the latter of which was delayed), only to find my front left tire was flat so I had to change that in the dark. Then I find out I'm working midshift tomorrow which means I'll get about six hours of sleep tonight (if I'm lucky). Not to mention all the running around I have to do tomorrow after work...

If it's super-critical, feel free to PM me.
frantik
Guest
« Reply #4 on: December 17, 2007, 04:38:20 am »

The castle "metatile" data is starts at 0x17df in the rom file.  Metatiles are made up of 4 CHR-ROM tiles. The data which assigns each CHR-ROM tile to a metatile starts at 0x0b20. You can also use the program SMBED to edit the metatiles.. it's much more convenient.

Note the castle metatile data is stored backwards.. what you see on the left in the table will appear on the right.
Quote
; $97cf-$9805 ( 0x17df - 0x1815 ) castle object metatile data
CastleMetatiles:
      .db $00, $45, $45, $45, $00
      .db $00, $48, $47, $46, $00
      .db $45, $49, $49, $49, $45
      .db $47, $47, $4a, $47, $47
      .db $47, $47, $4b, $47, $47    ------- Bottom of small castle
      .db $49, $49, $49, $49, $49   
      .db $47, $4a, $47, $4a, $47
      .db $47, $4b, $47, $4b, $47
      .db $47, $47, $47, $47, $47
      .db $4a, $47, $4a, $47, $4a
      .db $4b, $47, $4b, $47, $4b

here is the metatile data.  The castle tiles are in the 40s range but you can use any metatile at all
Quote
; $8b10-$8ca3 ( 0x0b20 - 0x0cb3 ) metatile graphics table
Palette0_MTiles:
  .db $24, $24, $24, $24 ;blank 00
  .db $27, $27, $27, $27 ;black metatile 01
  .db $24, $24, $24, $35 ;bush left 02
  .db $36, $25, $37, $25 ;bush middle 03
  .db $24, $38, $24, $24 ;bush right 04
  .db $24, $30, $30, $26 ;mountain left 5
  .db $26, $26, $34, $26 ;mountain left bottom/middle center 6
  .db $24, $31, $24, $32 ;mountain middle top 7
  .db $33, $26, $24, $33 ;mountain right 8
  .db $34, $26, $26, $26 ;mountain right bottom 9
  .db $26, $26, $26, $26 ;mountain middle bottom a
  .db $24, $c0, $24, $c0 ;bridge guardrail b
  .db $24, $7f, $7f, $24 ;chain c
  .db $b8, $ba, $b9, $bb ;tall tree top, top half d
  .db $b8, $bc, $b9, $bd ;short tree top e
  .db $ba, $bc, $bb, $bd ;tall tree top, bottom half f
  .db $60, $64, $61, $65 ;warp pipe end left, points up 10
  .db $62, $66, $63, $67 ;warp pipe end right, points up 11
  .db $60, $64, $61, $65 ;decoration pipe end left, points up 12
  .db $62, $66, $63, $67 ;decoration pipe end right, points up 13
  .db $68, $68, $69, $69 ;pipe shaft left 14
  .db $26, $26, $6a, $6a ;pipe shaft right 15
  .db $4b, $4c, $4d, $4e ;tree ledge left edge 16
  .db $4d, $4f, $4d, $4f ;tree ledge middle 17
  .db $4d, $4e, $50, $51 ;tree ledge right edge 18
  .db $6b, $70, $2c, $2d ;mushroom left edge 19
  .db $6c, $71, $6d, $72 ;mushroom middle 1a
  .db $6e, $73, $6f, $74 ;mushroom right edge 1b
  .db $86, $8a, $87, $8b ;sideways pipe end top 1c
  .db $88, $8c, $88, $8c ;sideways pipe shaft top 1d
  .db $89, $8d, $69, $69 ;sideways pipe joint top 1e
  .db $8e, $91, $8f, $92 ;sideways pipe end bottom 1f
  .db $26, $93, $26, $93 ;sideways pipe shaft bottom 20
  .db $90, $94, $69, $69 ;sideways pipe joint bottom 21
  .db $a4, $e9, $ea, $eb ;seaplant 22
  .db $24, $24, $24, $24 ;blank, used on bricks or blocks that are hit 23
  .db $24, $2f, $24, $3d ;flagpole ball 24
  .db $a2, $a2, $a3, $a3 ;flagpole shaft 25
  .db $24, $24, $24, $24 ;blank, used in conjunction with vines 26

Palette1_MTiles:
  .db $a2, $a2, $a3, $a3 ;vertical rope 40
  .db $99, $24, $99, $24 ;horizontal rope 41
  .db $24, $a2, $3e, $3f ;left pulley 42
  .db $5b, $5c, $24, $a3 ;right pulley 43
  .db $24, $24, $24, $24 ;blank used for balance rope 44
  .db $9d, $47, $9e, $47 ;castle top 45
  .db $47, $47, $27, $27 ;castle window left 46
  .db $47, $47, $47, $47 ;castle brick wall 47
  .db $27, $27, $47, $47 ;castle window right 48
  .db $a9, $47, $aa, $47 ;castle top w/ brick 49
  .db $9b, $27, $9c, $27 ;entrance top 4a
  .db $27, $27, $27, $27 ;entrance bottom 4b


...

here's an example of the castle modified in Super Mario Unlimited Smiley

« Last Edit: December 17, 2007, 09:00:53 am by frantik »
Darkdata
Guest
« Reply #5 on: December 17, 2007, 02:32:36 pm »

I know about the metatiles.. let me rephrase my question...

How are the metatiles arranged to build the castle?

(Whenever you get back Dr. Floppy I will gladly take the information that you have.)

I really need to look at that disassembly...
doppelganger
Guest
« Reply #6 on: December 17, 2007, 05:33:28 pm »

The metatiles are arranged in a 5-column grid and rendered backwards horizontally (the offset used for each row is a length counter that decrements, so it has to be arranged backwards horizontally).  The arrangement is under CastleMetatiles in the disassembly I made ($97cf-$9805 or file offset 0x17df-01815).  The metatiles are rendered from the top down starting at the row specified in the lower nybble of the object byte (the second one).

I should point out that the castle object ($2x in row $xf where x = don't care) only contains enough information to render the small castles used in most of the levels, and the center of the big castles used in levels -3.  In order to completely render the big castles the way they are in the game, the game uses an area object in row $xe (again, x = don't care) with the object byte set to %x1xxx010 to draw the lower castle walls.

I should also point out that the lower nybble of the castle object's object byte should never be set above $0a, or else the game will crash.
frantik
Guest
« Reply #7 on: December 17, 2007, 06:09:36 pm »

Quote from: Darkdata on December 17, 2007, 02:32:36 pm
I know about the metatiles.. let me rephrase my question...

How are the metatiles arranged to build the castle?

I really need to look at that disassembly...

the bit of information in the first quote box shows the data and how it is arranged

and the disassembly is in the docs section
Dr. Floppy
Guest
« Reply #8 on: December 18, 2007, 12:07:57 am »

Quote from: Darkdata on December 17, 2007, 02:32:36 pm
I know about the metatiles.. let me rephrase my question...

How are the metatiles arranged to build the castle?

(Whenever you get back Dr. Floppy I will gladly take the information that you have.)



Okay, tire's fixed; Floppy's happy. Let's spread some holiday cheer!  :angel:

My methods are more visually-oriented, but they get the job done:


1) Get some graphing paper, and start cordoning 2x2 squares. Make a 5x5 block of such squares (10x10 overall).

2) Reading right-to-left, from the top row down, you've got the metatile defined by $17DF, $17E0, $17E1, etc......, $17F7.

3) This linear string of 25 bytes can be represented on your graph paper like this:

5 4 3 2 1
10 9 8 7 6
15 14 13 12 11
20 19 18 17 16
25 24 23 22 21

(In other words, the first byte in this string codes for the upper-rightmost metatile, the second byte codes for the metatile directly to #1's left, etc.)

4) The large castles at the end of every X-3 level (and the beginning of most X-1 levels) are simply the small castle stacked on top of another, slightly taller one. This taller castle is 6 metatiles high and five metatiles wide, and is coded in a similar right-to-left, top-down fashion. Its linear byte sequence begins at $17F8.

5) The little side-sections on the X-3 castle type are actually the same background image that occurs throughout World 8-3. This image is 1 metatile wide and eleven metatiles high (although it only appears to be six metatiles high since the first five bytes are assigned transparent "00" values). Its coding begins at $13CE and ends at $13D8.


Here are some metatile values to keep handy:

00: Nothing/Transparent
45: Castle Top, sky background
46: Castle Window (left)
47: Castle Brickwork (generic filler)
48: Castle Window (right)
49: Castle Top, brick background
4A: Castle Entrance (top)
4B: Castle Entrance (bottom)


It's also possible to redefine the 2x2 tile layouts of each of the aforementioned metatiles. Do you need these locations as well?
Darkdata
Guest
« Reply #9 on: December 18, 2007, 08:15:06 am »

No, I think I see now... (And I feel sorta like an idiot Embarrassed)

However, I am having a small bit of trouble with the solid block that appears beside the door, can you change it? (I might have overlooked something a bit obvious... )

[] <-- Door
[][]<-- Solid block that covers the tile behind it, used to hold Mario in place when he walks inside of the door.

I would really like to be able to change it... If not I can work around it..
frantik
Guest
« Reply #10 on: December 18, 2007, 12:54:32 pm »

that block near the door is metatile #52.  Not only does it keep mario in place, when mario touches the side of that block is when the mario sprite is switched to be drawn behind the background, making it appear as if mario went in the castle.  The end of level routine will just have mario keep walking forever until he touches the side of a brick so you have to have some kind of solid brick to walk into after the flag pole

You can either change the 4 tiles which make up that metatile or use a different one.  You can edit the value at 0x187a to another number to change which block goes there, or change both 1879 and 187a to EA which will cause the block not to be drawn
Darkdata
Guest
« Reply #11 on: December 18, 2007, 02:03:41 pm »

Quote from: frantik on December 18, 2007, 12:54:32 pm
that block near the door is metatile #52.  Not only does it keep mario in place, when mario touches the side of that block is when the mario sprite is switched to be drawn behind the background, making it appear as if mario went in the castle.  The end of level routine will just have mario keep walking forever until he touches the side of a brick so you have to have some kind of solid brick to walk into after the flag pole

You can either change the 4 tiles which make up that metatile or use a different one.  You can edit the value at 0x187a to another number to change which block goes there, or change both 1879 and 187a to EA which will cause the block not to be drawn


Thank you all for all the help! This helps me solve one major problem I was having.
frantik
Guest
« Reply #12 on: December 18, 2007, 08:56:03 pm »

actually you should EA out the 3 bytes after 0x187a cause thats the code that actually puts the tile on the screen

0x1879: A0 52 8C AB 06 60

to not display the block:
0x1879: A0 52 EA EA EA 60
Darkdata
Guest
« Reply #13 on: December 19, 2007, 05:40:47 pm »

I have another simple or maybe stupid question, how can I change the palette that a metatile uses? Not edit the palette, that is simple, I mean as an example... change metatiles 16, 17, 18, 19, 1a, 1b to use "Palette1" and not "Palette0" This may very well be a one small change, or it could be not practical. Any help would be really welcome. (again)
frantik
Guest
« Reply #14 on: December 19, 2007, 06:51:14 pm »

you cannot change the palette of the metatile, but you can use a metatile from a different palette Smiley 
Pages: [1] 2  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC