EarthBound Beginnings/Objects

From Data Crystal
< EarthBound Beginnings
Revision as of 16:21, 20 May 2006 by Goplat (talk | contribs) (created)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

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
  • Bytes 4-5: Sprite
  • Byte 6: Present item
  • Byte 7: Present ID (00-49)
  • Bytes 4-5:
    • Bits 0-5: Target music
    • Bits 6-15: Target X location
  • Bytes 6-7:
    • Bits 0-5: Target direction
    • Bits 6-15: Target Y location

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.

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
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 01 pp           jump unless using PSI
0D ii pp           jump unless using item
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
18 pp              select character, jump if B pressed
19 cc              select specific character
1B pp              jump if no money added to bank acct since last call
1D nn nn           load a number
1F                 show money
20 pp              select item from inventory, jump if B pressed
21 pp              select item from closet, jump if B pressed
22 ii ii ii ii pp  select item from list, jump if B pressed
25 ii              select specific item
26 03 pp           jump unless item must be carried in inventory
27 ii pp           jump unless item in inventory
28 pp              give money, jump if can't hold any more
29 pp              take money, 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 00 pp           jump if character has no items
33 cc pp           jump if character not present?
35 pp              jump if not 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 cc pp           select cc'th character in party (first is 0)
3B 26              run away
3D xx xx yy yy     teleport player
3E mm mm           move object (mm=pointer to movement data, after script)
42 cc pp           add character to party, jump if party full
44 gg              start battle (gg=enemy group)
45                 multiply by number of characters
4A                 train
50 nn              heal HP
51 pp              jump if less than max 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
59 ss              inflict status on lead character
5A mm              change background music
5C ss              play sound
5F                 teach Ninten to Teleport
60 nn              heal PP
61 pp              jump if less than max PP
62 pp              take main character's weapon, jump if none
63 pp              select confiscated weapon, jump if none
65 pp              jump unless all 8 melodies learned
66                 register your name
68                 land mine