EarthBound Beginnings/Objects: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
(created)
 
(→‎Scripts: add more codes)
Line 21: Line 21:


==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 30:
  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 46:
  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
17 vv nn          change map variable (1B-1E)
  18 pp              select character, jump if B pressed
  18 pp              select 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              select item from inventory, jump if B pressed
Line 53: Line 59:
  22 ii ii ii ii pp  select item from list, jump if B pressed
  22 ii ii ii ii pp  select item from list, jump if B pressed
  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 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 70:
  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?
  33 cc pp          jump if character not present
  35 pp              jump if not touching object
  35 pp              jump if not 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
Line 69: Line 77:
  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)
  3B 26              run away
  3B 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
40 pp              jump unless signalled
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
  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
4B dd              elevator
4C dd              no vehicle
  50 nn              heal HP
  50 nn              heal HP
  51 pp              jump if less than max HP
  51 pp              jump if less than max HP
Line 85: Line 103:
  56                save game
  56                save game
  57                load character's exp needed for next level
  57                load character's exp needed for next level
58                load money
  59 ss              inflict status on lead character
  59 ss              inflict status on lead character
  5A mm              change background music
  5A mm              change background music
  5C ss              play sound
5B ss              play sound (1)
  5C ss              play sound (2)
5D ss              play sound (3)
5E                (unused, freezes game)
  5F                teach Ninten to Teleport
  5F                teach Ninten to Teleport
  60 nn              heal PP
  60 nn              heal PP
  61 pp              jump if less than max PP
  61 pp              jump if less than max PP
  62 pp              take main character's weapon, jump if none
  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

Revision as of 07:12, 24 May 2006

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 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              select 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              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 ii pp           jump unless item selected
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
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
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 nn pp           select nn'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)
3F oo              signal another object 
40 pp              jump unless signalled
41                 teleport to saved game location
42 cc pp           add character to party, jump if party full
43 cc pp           remove character from party
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 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
58                 load money
59 ss              inflict status on lead 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 Ninten to Teleport
60 nn              heal PP
61 pp              jump if less than max 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