Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

EarthBound Beginnings/Objects: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
(created)
 
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''Objects''' are things on the map which respond to player actions such as talking. Objects in EB0 are organized by the area of the map sector they are in. There are three banks of object data: 20010-2200F for areas 00-19, 22010-2400F for areas 1A-2A, and 24010-25DF5 for areas 2B-3F. Each bank begins with a pointer table for with one pointer for each area; these point to a second level of pointer tables (terminated with $0000) which point to the objects themselves.
{{subpage|game=EarthBound Zero:ROM map}}
 
'''Objects''' are things on the map which respond to player actions such as talking. Objects in EB0 are organized by the area of the map sector they are in. There are three banks of object data: 20010-2200F for areas 00-19, 22010-2400F for areas 1A-2A, and 24010-25DF5 for areas 2B-3F.
 
==Pointers==
At the beginning of each bank is a painter table, which in turn points to another pointer table for each area.  All pointer tables are terminated with 2 bytes of zeroes.
 
'''Note:''' Object bank 0 has 4 zeroes after the main pointer table, but this is coincidental and because area 0 happens to not have objects in it.
 
The pointers point to something within that bank, not the beginning of the ROM.  For example, $8034 in bank 0 points to $20044 in the ROM (subtract $8000, then add $20010 for the start of the bank).


==Object header==
==Object header==
Line 10: Line 19:
**Bits 0-5: Direction
**Bits 0-5: Direction
**Bits 6-15: Y location
**Bits 6-15: Y location
*Bytes 4-5: Sprite
 
*Byte 6: Present item
==Object types==
*Byte 7: Present ID (00-49)
 
There are several types for objects, and each has its own header.  The known ones are documented below.
 
===Door-like (0x1-0x4)===
These are the objects that transport you from one place to another.  None of these effect the graphics, so if you change a door-like object's location without changing the map, it will be invisible.
 
*Bytes 4-5:
*Bytes 4-5:
**Bits 0-5: Target music
**Bits 0-5: Target music
*:The music to loop after exiting the door, see [[EarthBound Zero:Music table|the music table]] for the values.  Choosing none (0x0) causes the music to be glitched.
**Bits 6-15: Target X location
**Bits 6-15: Target X location
*Bytes 6-7:
*Bytes 6-7:
**Bits 0-5: Target direction
**Bits 0-5: Target direction
**Bits 6-15: Target Y location
**Bits 6-15: Target Y location
====Door (0x1)====
This can only be entered by going into it by the opposite of the door's direction.  For example, if its direction is up, you can only enter it from the bottom.  Diagonal directions are possible, but not actually used by any door in the game. (TODO: check what happens if you set them)
====Unknown (0x2)====
This behaves similar or the same as a door, but is unused.
====Stairs (0x3)====
Same as a door, except it plays the stairs SFX when you enter it.
====Hole (0x4)====
A door that can be entered from all sides.  All holes have their direction set to up (although it shouldn't matter).
===Stationary NPC (0x12)===
*Bytes 4-5: Sprite
This is used for some NPCs that do not "wander", including the birds outside Mother's Day/Podunk.
===Present (0x14)===
*Bytes 4-5: Sprite
*Byte 6: Present item
*Byte 7: Present ID (00-49)
===Unknown (0x20)===
*Bytes 4-5: Sprite
Script attached
===Unknown (0x29)===
*Byte 0:
**Bits 0-2: Area?
*:These seem to correspond to the area the object is in, as long as bits 3-7 are 0x1D
**Bits 3-7: Sub-type?
*Byte 1: Unused (always 0)


==Scripts==
==Scripts==
Some types of objects have a script after the object header. This script is executed whenever the object is interacted with. Script codes range from 00 to 6A; a list of the meanings of some script codes follows. Positions in scripts are offsets from the start of the object itself, not the script.
Some types of objects have a script after the object header. This script is executed whenever the object is interacted with. Script codes range from 00 to 6B; a list of the meanings of some script codes follows. Positions in scripts are offsets from the start of the object itself, not the script.


  00                end script
  00                end script
Line 30: Line 74:
  05 ff              object disappears when flag set
  05 ff              object disappears when flag set
  06 ff              object appears when flag set
  06 ff              object appears when flag set
07                (unused, freezes game)
  08 tt tt          display text
  08 tt tt          display text
  09 pp              ask yes/no, jump if "no" selected or B pressed
  09 pp              ask yes/no, jump if "no" selected or B pressed
  0A pp              jump unless TALKing
  0A pp              jump unless TALKing
  0B pp              jump unless CHECKing
  0B pp              jump unless CHECKing
  0C 01 pp          jump unless using PSI
  0C ii pp          jump unless using PSI (01=telepathy)
  0D ii pp          jump unless using item
  0D ii pp          jump unless using item
0E                (unused, freezes game)
  0F                reset NES
  0F                reset NES
  10 ff              set flag
  10 ff              set flag
Line 44: Line 90:
  15 cc              set counter to 0
  15 cc              set counter to 0
  16 cc nn pp        jump if counter less than value
  16 cc nn pp        jump if counter less than value
  18 pp              select character, jump if B pressed
17 vv nn          change map variable (1B-1E)
  18 pp              choose character, jump if B pressed
  19 cc              select specific character
  19 cc              select specific character
1A cc pp          jump unless character selected
  1B pp              jump if no money added to bank acct since last call
  1B pp              jump if no money added to bank acct since last call
1C pp              input a number, jump if B pressed
  1D nn nn          load a number
  1D nn nn          load a number
1E nn nn pp        jump if number less than value
  1F                show money
  1F                show money
  20 pp              select item from inventory, jump if B pressed
  20 pp              choose item from inventory, jump if B pressed
  21 pp              select item from closet, jump if B pressed
  21 pp              choose item from closet, jump if B pressed
  22 ii ii ii ii pp  select item from list, jump if B pressed
  22 ii ii ii ii pp  choose item from list, jump if B pressed
23 ii pp          jump unless item in character's inventory
24 ii pp          jump unless item in closet
  25 ii              select specific item
  25 ii              select specific item
  26 03 pp          jump unless item must be carried in inventory
  26 ii pp          jump unless item selected
  27 ii pp          jump unless item in inventory
  27 ii pp          jump unless item in any character's inventory
  28 pp              give money, jump if can't hold any more
  28 pp              give money, jump if can't hold any more
  29 pp              take money, jump if not enough
  29 pp              take money, jump if not enough
2A pp              add to bank account, jump if can't hold any more
2B pp              take from bank account, jump if not enough
  2C pp              jump if item unsellable
  2C pp              jump if item unsellable
  2D pp              add item to inventory, jump if full
  2D pp              add item to inventory, jump if full
Line 62: Line 116:
  2F pp              add item to closet, jump if full
  2F pp              add item to closet, jump if full
  30 pp              remove item from closet, jump if not present
  30 pp              remove item from closet, jump if not present
  31 00 pp          jump if character has no items
  31 nn pp          select character's nn'th item (first is 0), jump if empty slot
  33 cc pp          jump if character not present?
32 nn              multiply number by nn/100
  35 pp              jump if not touching object
  33 cc pp          jump if character not present
  35 pp              jump unless touching object
  37 tt tt p1 p2    show 2-option menu, jump to p1 if second option selected
  37 tt tt p1 p2    show 2-option menu, jump to p1 if second option selected
                     or jump to p2 if B selected
                     or jump to p2 if B selected
  38 pp              jump if no items in inventory
  38 pp              jump if no items in inventory
  39 pp              jump if no items in closet
  39 pp              jump if no items in closet
  3A cc pp          select cc'th character in party (first is 0)
  3A nn pp          select nn'th character in party (first is 0), jump if not present
  3B 26             run away
  3B tt              change object type (tt=type) e.g. 26=run away
  3D xx xx yy yy    teleport player
  3D xx xx yy yy    teleport player
  3E mm mm          move object (mm=pointer to movement data, after script)
  3E mm mm          move object (mm=pointer to movement data, after script)
3F oo              signal another object (oo=object number)
40 pp              jump unless signaled
41                teleport to saved game location
  42 cc pp          add character to party, jump if party full
  42 cc pp          add character to party, jump if party full
43 cc pp          remove character from party, jump if absent
  44 gg              start battle (gg=enemy group)
  44 gg              start battle (gg=enemy group)
  45                multiply by number of characters
  45                multiply by number of characters
46 dd              rocket (dd=direction)
47 dd              airplane
48 dd              tank
49 dd              boat
  4A                train
  4A                train
  50 nn             heal HP
  4B dd              elevator
  51 pp              jump if less than max HP
4C dd             no vehicle
  50 pp              jump if at less than max HP
51 nn              heal HP
  52 ss pp          jump if character has status
  52 ss pp          jump if character has status
  53 ss              remove statuses not in ss
  53 ss              remove statuses not in ss
Line 85: Line 150:
  56                save game
  56                save game
  57                load character's exp needed for next level
  57                load character's exp needed for next level
  59 ss              inflict status on lead character
58                load money
  59 ss              inflict status on character
  5A mm              change background music
  5A mm              change background music
  5C ss              play sound
5B ss              play sound (1)
  5F                teach Ninten to Teleport
  5C ss              play sound (2)
  60 nn              heal PP
5D ss              play sound (3)
61 pp              jump if less than max PP
5E                (unused, freezes game)
  62 pp              take main character's weapon, jump if none
  5F                teach characters 1 and 2 to Teleport
  60 pp              jump if at less than max PP
61 nn              heal PP
  62 pp              take weapon, jump if none
  63 pp              select confiscated weapon, jump if none
  63 pp              select confiscated weapon, jump if none
64                live show
  65 pp              jump unless all 8 melodies learned
  65 pp              jump unless all 8 melodies learned
  66                register your name
  66                register your name
67                darken palette (Magicant end)
  68                land mine
  68                land mine
69                horiz. shake (EVE?)
6A                XX crystal

Latest revision as of 12:15, 26 January 2024

This is a sub-page of EarthBound Beginnings.

Objects are things on the map which respond to player actions such as talking. Objects in EB0 are organized by the area of the map sector they are in. There are three banks of object data: 20010-2200F for areas 00-19, 22010-2400F for areas 1A-2A, and 24010-25DF5 for areas 2B-3F.

Pointers

At the beginning of each bank is a painter table, which in turn points to another pointer table for each area. All pointer tables are terminated with 2 bytes of zeroes.

Note: Object bank 0 has 4 zeroes after the main pointer table, but this is coincidental and because area 0 happens to not have objects in it.

The pointers point to something within that bank, not the beginning of the ROM. For example, $8034 in bank 0 points to $20044 in the ROM (subtract $8000, then add $20010 for the start of the bank).

Object header

The object header is 4, 6, or 8 bytes long, depending on the object type. The meaning of the first 4 bytes is always the same.

  • Bytes 0-1:
    • Bits 0-5: Type
    • Bits 6-15: X location
  • Bytes 2-3:
    • Bits 0-5: Direction
    • Bits 6-15: Y location

Object types

There are several types for objects, and each has its own header. The known ones are documented below.

Door-like (0x1-0x4)

These are the objects that transport you from one place to another. None of these effect the graphics, so if you change a door-like object's location without changing the map, it will be invisible.

  • Bytes 4-5:
    • Bits 0-5: Target music
    The music to loop after exiting the door, see the music table for the values. Choosing none (0x0) causes the music to be glitched.
    • Bits 6-15: Target X location
  • Bytes 6-7:
    • Bits 0-5: Target direction
    • Bits 6-15: Target Y location

Door (0x1)

This can only be entered by going into it by the opposite of the door's direction. For example, if its direction is up, you can only enter it from the bottom. Diagonal directions are possible, but not actually used by any door in the game. (TODO: check what happens if you set them)

Unknown (0x2)

This behaves similar or the same as a door, but is unused.

Stairs (0x3)

Same as a door, except it plays the stairs SFX when you enter it.

Hole (0x4)

A door that can be entered from all sides. All holes have their direction set to up (although it shouldn't matter).

Stationary NPC (0x12)

  • Bytes 4-5: Sprite

This is used for some NPCs that do not "wander", including the birds outside Mother's Day/Podunk.

Present (0x14)

  • Bytes 4-5: Sprite
  • Byte 6: Present item
  • Byte 7: Present ID (00-49)

Unknown (0x20)

  • Bytes 4-5: Sprite

Script attached

Unknown (0x29)

  • Byte 0:
    • Bits 0-2: Area?
    These seem to correspond to the area the object is in, as long as bits 3-7 are 0x1D
    • Bits 3-7: Sub-type?
  • Byte 1: Unused (always 0)

Scripts

Some types of objects have a script after the object header. This script is executed whenever the object is interacted with. Script codes range from 00 to 6B; a list of the meanings of some script codes follows. Positions in scripts are offsets from the start of the object itself, not the script.

00                 end script
01 pp              unconditional jump (pp=position)
02 oo oo pp        call subroutine (oo=object pointer)
03                 return from subroutine
04 tt              delay (tt=time)
05 ff              object disappears when flag set
06 ff              object appears when flag set
07                 (unused, freezes game)
08 tt tt           display text
09 pp              ask yes/no, jump if "no" selected or B pressed
0A pp              jump unless TALKing
0B pp              jump unless CHECKing
0C ii pp           jump unless using PSI (01=telepathy)
0D ii pp           jump unless using item
0E                 (unused, freezes game)
0F                 reset NES
10 ff              set flag
11 ff              clear flag
12 ff pp           jump unless flag set
13 cc              decrease counter
14 cc              increase counter
15 cc              set counter to 0
16 cc nn pp        jump if counter less than value
17 vv nn           change map variable (1B-1E)
18 pp              choose character, jump if B pressed
19 cc              select specific character
1A cc pp           jump unless character selected
1B pp              jump if no money added to bank acct since last call
1C pp              input a number, jump if B pressed
1D nn nn           load a number
1E nn nn pp        jump if number less than value
1F                 show money
20 pp              choose item from inventory, jump if B pressed
21 pp              choose item from closet, jump if B pressed
22 ii ii ii ii pp  choose item from list, jump if B pressed
23 ii pp           jump unless item in character's inventory
24 ii pp           jump unless item in closet
25 ii              select specific item
26 ii pp           jump unless item selected
27 ii pp           jump unless item in any character's inventory
28 pp              give money, jump if can't hold any more
29 pp              take money, jump if not enough
2A pp              add to bank account, jump if can't hold any more
2B pp              take from bank account, jump if not enough
2C pp              jump if item unsellable
2D pp              add item to inventory, jump if full
2E pp              remove item from inventory, jump if not present
2F pp              add item to closet, jump if full
30 pp              remove item from closet, jump if not present
31 nn pp           select character's nn'th item (first is 0), jump if empty slot
32 nn              multiply number by nn/100
33 cc pp           jump if character not present
35 pp              jump unless touching object
37 tt tt p1 p2     show 2-option menu, jump to p1 if second option selected
                   or jump to p2 if B selected
38 pp              jump if no items in inventory
39 pp              jump if no items in closet
3A nn pp           select nn'th character in party (first is 0), jump if not present
3B tt              change object type (tt=type) e.g. 26=run away
3D xx xx yy yy     teleport player
3E mm mm           move object (mm=pointer to movement data, after script)
3F oo              signal another object (oo=object number)
40 pp              jump unless signaled
41                 teleport to saved game location
42 cc pp           add character to party, jump if party full
43 cc pp           remove character from party, jump if absent
44 gg              start battle (gg=enemy group)
45                 multiply by number of characters
46 dd              rocket (dd=direction)
47 dd              airplane
48 dd              tank
49 dd              boat
4A                 train
4B dd              elevator
4C dd              no vehicle
50 pp              jump if at less than max HP
51 nn              heal HP
52 ss pp           jump if character has status
53 ss              remove statuses not in ss
54 ll pp           jump if character below level
55                 sleep
56                 save game
57                 load character's exp needed for next level
58                 load money
59 ss              inflict status on character
5A mm              change background music
5B ss              play sound (1)
5C ss              play sound (2)
5D ss              play sound (3)
5E                 (unused, freezes game)
5F                 teach characters 1 and 2 to Teleport
60 pp              jump if at less than max PP
61 nn              heal PP
62 pp              take weapon, jump if none
63 pp              select confiscated weapon, jump if none
64                 live show
65 pp              jump unless all 8 melodies learned
66                 register your name
67                 darken palette (Magicant end)
68                 land mine
69                 horiz. shake (EVE?)
6A                 XX crystal