R Register Slot 2 Mapping Flat Code in $00000 - $0bfff [1]

ROM Version Differences

The following code is present in the ROM "Alex Kidd in Miracle World [v1]" but not in "Alex Kidd in Miracle World [v0]":

 3AC7: 7A           LD A,D
 3AC8: DD 86 0E     ADD (IX+0Eh)
 3ACB: FE BF        CP BFh
 3ACD: D0           RET NC

This code is executed when Alex is falling. If the RET NC at $3acd is not taken, the fall may end: Alex's falling sprite may be replaced by his walking sprite.

When the code runs, the D register contains Alex's height (24 pixels) plus the distance to fall this frame (0-4 pixels). (IX+0Eh) contains the the Y-coordinate of Alex's sprite (recall that this will be 0 for scanline 1, etc). Their sum, calculated at $3ac8, is the Y-coordinate of the bottom of the sprite at the end of this frame. If this is greater than or equal to $bf (191 decimal), the bottom of Alex's sprite will be below the bottom of the screen (Y-coordinate 190, scanline 191).

The code above, therefore, forces Alex to continue falling when he reaches the bottom of the screen. The effect of this can be seen only on those levels where it is possible to fall from one room to another. In v0, Alex will fall to the bottom of the screen and then the fall will end: the transition to the next room will occur with Alex's walking sprite shown. Once the transition is complete, Alex will resume falling correctly. In v1, thanks to the above code, the fall uses the correct animation frames throughout.

Room Transition [v0]Room Transition [v1]
(MEKA savestate)(MEKA savestate)

This is believed to be the only difference between the v0 and v1 ROMs.

The above bug fix is also present in "Alex Kidd in Miracle World [BIOS]", but not in "Alex Kidd in Miracle World [SMS-GG] (TW)", "Alex Kidd no Miracle World (JP)" nor "Alex Kidd in Miracle World [BIOS] (KR)".

Game State

Alex Kidd in Miracle World maintains a master "game state" variable[2] in the low 4 bits of the byte at $c01f. The valid values are:

ValueState
$0, $1Title Screen ($1 is never used)
$2Demo
$3Start the level specified at $c023
$4Level Completed
$5Shop
$6Life Lost
$7Text Box
$8Bonus Level
$9[3]Janken Game (Rock, Paper, Scissors)
$aGameplay
$bMap

For all states except state $6, bit 7 of the same byte is used to distinguish a change of state (bit 7 reset) from a continuation of the current state (bit 7 set). The main loop of the game looks up a pointer to the gamestate's main code from a table of pointers to gamestates and executes it.

Scoring

The score[4] in Alex Kidd in Miracle World is always a multiple of 10. Internally, therefore, the game stores a value of score / 10 and simply adds a trailing zero for display. This value is stored as a group of three bytes in (little-endian) BCD format. The highest score attainable is thus 9,999,990.

The score value is stored in RAM at address $c020. The value for the top score is stored at $c000.

There are 8 ways to gain points during play. Each of these achievements will increase the player's score by a certain amount of points. These amounts are stored (in the same format as the score) in a lookup table at ROM address $489.

Money

Money in Alex Kidd in Miracle World is always a multiple of 10. Internally, therefore, the game stores values of money / 10 and simply adds a trailing zero for display. This value is stored as a group of three bytes in (little-endian) BCD format. The highest amount of money attainable is thus 9,999,990.

The money value is stored in RAM at address $c030.

There are 2 different kinds of money bags. A small one and a big one. Both of these bags will increase the player's money by a certain amount. These amounts are stored (in the same format as the money) in a lookup table at ROM address $483.

Demo

If no buttons are pressed on the title screen, one of four demos will begin. Alex's movements during the demo are driven by simulated input - the data for this is in "TransBot" format and is located at $14d35-$1508d in the v1 ROM. In between the data for each demo is an unreferenced zero byte.

Level Structure

Levels are stored as a sequence of screens, each 256x192 pixels in size. The screens are described by arrays of 16x12 bytes, where each byte is the index of a 16x16 pixel metatile. These arrays are compressed individually, using the "Phantasy Star" RLE format (without deinterleaving), and located in the v1 ROM within $18000 - $1bdb8. At runtime, one array at a time is decompressed to RAM at $d700 - $d7bf.

Each metatile index is used to access a table of pointers. There are two of these tables, one at $14000 - $141ff and a second at $14200 - $143ff (used only for levels 14, 16 and 17). Each address in these tables is a slot 2 pointer into $14450 - $14d34; this region contains the four name table entries (8 bytes) to use for each metatile.

Level Descriptors

There are 17 pointers, one per level, at $066d6 - $066f7 within the v1 ROM. These point into $066f8 - $067c3, where there is a 12 byte descriptor for each level. Each descriptor contains the following information:

OffsetLengthContents
01 byteBank number containing the level layout data (Always $86) [5]
12 bytesSlot 2 pointer into the level layout data
32 bytesA second slot 2 pointer into the level layout data
51 byteStart screen horizontal number
61 byteStart screen vertical number
71 byteWidth in screens
81 byteHeight in screens
91 byteScrollability
102 bytesSlot 2 address of metatile name table entry pointer table

Entity Data

There are 17 pointers, one per level, at $0b505 - $0b526 within the v1 ROM. These point into $0b527 - $0b6ec, where there are several pointers, one per screen of the level, into $0b6ed - $0be87, where there are entity descriptors for each entity. Each descriptor contains the following information:

OffsetLengthContents
01 byteNumber of entities for the current screen
1 + 4i1 byteType of entity i
1 + 4i + 11 byteVertical screen position of entity i
1 + 4i + 21 byteHorizontal screen position of entity i
1 + 4i + 31 byteEntity specific data of entity i

A descriptor is loaded whenever a new screen is entered. The game uses an array of structs to maintain entity data in RAM from $c300 - $c6bf. Each struct is 32 bytes long. The size of the array is stored at $c0f8. Ingame the size is frequently set to $1e. Each struct contains the following information:

OffsetLengthContents
$01 byteType of the entity
$11 byteFlags of the entity
$21 byteUnknown
$31 byteEntity specific data[6]
$41 byteCurrent Animation Frame Number[7]
$51 byteAnimation Timer
$61 byteAnimation Timer Reset Value[8]
$72 bytesPointer to sprite descriptor
$92 bytesFlags indicating if the entity is off screen.
$b2 bytesHorizontal position of the entity
$d2 bytesVertical position of the entity
$f2 bytesHorizontal velocity of the entity
$112 bytesVertical velocity of the entity
$134 bytesUnknown
$171 byteDecision in Janken Match
$182 bytesUnknown
$1a1 byteState of the entity
$1b1 byteTimer for the State of the entity
$1c4 bytesUnknown

Each gamestate containing entities calls a function updating its entities (located at $2694) in its main loop. This function loops through the list of entities in RAM and per entity executes the entitiy's script, updates its position according to its velocity and calls a function to update its sprites (for details on this function see Sprite Handling section below).

Sprite Handling

The script/code of every entity either sets the pointer to sprite descriptor (ix+7 and ix+8) directly or by calling a function that handles the animation (located at $280e). This function takes the address of an animation descriptor as parameter in register hl. An animation descriptor is nothing more than an array of pointers to sprite descriptors. The length of this array is stored in the first byte of the animation descriptor which is then directly followed by its entries. The animation handler function is quite simple: It first decreases the animation timer (ix+5). If the result is zero it loads the animation timer reset value (ix+6) into the animation timer (ix+5) then increases the current animation frame number (ix+4). If the current animation frame number (ix+4) is greater or equal to the array's length it is set to 0. In every case the pointer to the sprite descriptor indexed by the current animation frame number (ix+4) is then loaded from the array into the entity data structure at the corresponding position (ix+7 and ix+8). The structure of a sprite descriptor looks as follows:

OffsetLengthContents
01 byteNumber of sprites (:= n)
11 byteCollision data
2 + i1 byteSigned vertical position of sprite i relative to the vertical entity position
2 + n + 2i1 byteSigned horizontal position of sprite i relative to the horizontal entity position
2 + n + 2i + 11 byteCharacter code of sprite i

Before calling the function updating an entitys' sprites (located at $26d7) the function that updates the entites clears the SAT in RAM (Starting from $c700) by setting the pointer to sprite terminator ($c009 and $c00a) to $c706[9]. After clearing the SAT in RAM the function starts filling it with the data of the sprite descriptor pointed to by the entity's pointer to sprite descriptor (ix+7 and ix+8). The interrupt handler will then copy the SAT in RAM (excluding the unused hole) to the SAT in VRAM by calling the function located at $1f7. To handle sprite flicker the interrupt handler behaves differently for odd and even frames. For odd frames it stores a direct copy in VRAM. For even frames it copies Alex's sprites in order and the rest of sprites in reverse order by copying from the end of sprites pointed to by the pointer to sprite terminator ($c009 and $c00a) down to Alex's sprites.

Sound Engine

The sound engine of Alex Kidd maintains 7 software channels using structs starting from $c118. Each struct is 32 bytes long. They contain the following information:

OffsetLengthContents
$01 byteFlags of the software channel
$11 byteHardware channel used by the software channel
$21 byteDuration multiplier
$32 bytesPointer to sound data
$51 byteTransposition Value
$61 byteVibrato Index
$71 byteEnvelope Index
$81 byteVolume of the software channel
$91 byteUnknown
$a2 bytesNote duration
$c2 bytesCurrent play duration
$e1 byteEnvelope Counter
$f1 byteVibrato Counter
$102 byteNote PSG Frequency Value
$122 bytePSG Frequency Value to write to the hardware channel
$142 byteNote PSG Frequency Value 2
$161 bytePSG Volume Value to write to the hardware channel
$179 bytesRepetition Counters

The first 4 software channels are used for the music and the other 3 are used for sound effects.

The sound control is located at $c110. When the top most bit of the sound control is set the engine is activated. Values from $81 to $b0 request playing a sound, $b1 to $b3 request effects. For example $b2 requests a sound fade out. Values greater than $b3 are considered invalid and will disable the engine. Sound effects have priorities associated with them. The priority of the sound effect that is currently is stored at $c113. If a sound effect with higher priority is requested the current sound effect will be canceled. To synchronize the Janken Match to the music a value is stored at $c115 when its music ends.

Each sound request has its own header pointed to by a table starting from $98dd. A header consists of a variable amount of bytes depending on the value of its first byte. The first byte indicates how many software channels to use and is followed by 9 bytes per software channel that will be loaded directly into the first 9 bytes of the software channel's struct. The software channels will be loaded with data consecutively. The first software channel to start loading to is decided by the responsible request handling code.

The sound data contains indices into a table of PSG Frequency Values[10]:

PSG Frequency ValueIndexFrequencyNoteDeviation
$0000000Hz  
$03FF01109.346HzA2-10.329 cents
$03C702115.678HzA#2-12.867 cents
$039003122.654HzB2-11.489 cents
$035D04129.920HzC3-11.864 cents
$032D05137.590HzC#3-12.555 cents
$02FF06145.842HzD3-11.720 cents
$02D407154.504HzD#3-11.836 cents
$02AB08163.779HzE3-10.911 cents
$028509173.428HzF3-11.807 cents
$02610A183.679HzF#3-12.379 cents
$023F0B194.540HzG3-12.923 cents
$021E0C206.385HzG#3-10.600 cents
$02000D218.478HzA3-12.021 cents
$01E30E231.596HzA#3-11.076 cents
$01C80F245.309HzB3-11.489 cents
$01AF10259.538HzC4-13.874 cents
$019611275.519HzC#4-10.424 cents
$018012291.304HzD4-13.976 cents
$016A13309.008HzD#4-11.836 cents
$015614327.078HzE4-13.444 cents
$014315346.318HzF4-14.489 cents
$013016367.963HzF#4-9.534 cents
$011F17389.759HzG4-9.909 cents
$010F18412.770HzG#4-10.600 cents
$010019436.956HzA4-12.021 cents
$00F21A462.235HzA#4-14.657 cents
$00E41B490.617HzB4-11.489 cents
$00D71C520.283HzC5-9.852 cents
$00CB1D551.038HzC#5-10.424 cents
$00C01E582.608HzD5-13.976 cents
$00B51F618.015HzD#5-11.836 cents
$00AB20654.157HzE5-13.444 cents
$00A121694.787HzF5-9.121 cents
$009822735.926HzF#5-9.534 cents
$009023776.811HzG5-15.931 cents
$008824822.506HzG#5-16.976 cents
$008025873.912HzA5-12.021 cents
$007926924.469HzA#5-14.657 cents
$007227981.235HzB5-11.489 cents
$006C281035.748HzC6-17.886 cents
$0066291096.674HzC#6-18.931 cents
$00602A1165.216HzD6-13.976 cents
$005B2B1229.239HzD#6-21.374 cents
$00552C1316.009HzE6-3.290 cents
$00512D1380.997HzF6-19.841 cents
$004C2E1471.852HzF#6-9.534 cents
$00482F1553.622HzG6-15.931 cents
$0044301645.011HzG#6-16.976 cents
$0040311747.825HzA6-12.021 cents
$003C321864.346HzA#6-0.290 cents
$0039331962.470HzB6-11.489 cents
$0036342071.496HzC7-17.886 cents
$0033352193.349HzC#7-18.931 cents
$0030362330.433HzD7-13.976 cents
$002D372485.795HzD#7-2.245 cents
$002B382601.414HzE7-23.538 cents
$0028392796.520HzF7+1.665 cents
$00263A2943.705HzF#7-9.534 cents
$00243B3107.244HzG7-15.931 cents
$00223C3290.023HzG#7-16.976 cents
$00203D3495.649HzA7-12.021 cents
$001E3E3728.693HzA#7-0.290 cents
$001C3F3995.028HzB7+19.153 cents
$001B404142.992HzC8-17.886 cents
$0019414474.431HzC#8+15.352 cents
$0018424660.866HzD8-13.976 cents
$0016435084.581HzD#8+36.661 cents
$0015445326.704HzE8+17.198 cents
$0014455593.039HzF8+1.665 cents
$0013465887.410HzF#8-9.534 cents
$0012476214.488HzG8-15.931 cents
$0011486580.046HzG#8-16.976 cents

The sound data also contains control commands executed by values starting from $e0. These are commands like "repeat n times starting from nnnn", "set pointer to nnnn", "start playing underwater music", "set Janken Match variable", "set/reset a bit in the data structure of the software channel", ...

Ending sequence text encoding

The ending sequence text is encoded as follows:

ROM Map

This table summarises the contents of the Alex Kidd in Miracle World [v1] ROM (Size: 128KB; CRC32: aed9aac4):

Address RangeContents
$00000 - $00007Unknown Code
$00008 - $0000eCode: Set VRAM Address to the value stored in register DE
$0000fUnused
$00010 - $00019Code: Load Ath[11] entry of table pointed to by register HL into register HL
$0001aUnused
$0001b - $0001fUnknown Code
$00020 - $00029Code: Jump to Ath[11] entry of jump table pointed to by register HL
$0002a - $0002fUnused
$00030 - $00037Code: Write value of register B bytes from memory location pointed to by register HL to the VRAM address pointed to by register DE
$00038 - $0003aCode: jp $00c0
$0003b - $00052Jump Table (12 entries, indexed by game state) (Jump instruction at $0029)
$00053 - $00056Code: Sets game state ($c01f) to $0
$00057 - $00064Code: Main loop
$00065Unused
$00066 - $00084Pause Button Code: Toggle map if possible
$00085 - $0009eUnknown Code
$0009f - $000bfReset Code
$000c0 - $00126Interrupt handling Code
$00127 - $0013eJump Table (12 entries, indexed by game state) (Jump instruction at $0029[12])
$0013f - $00144Code: Write the value of register A to the VRAM address pointed to by register DE
$00145 - $00158Code: Write value of register BC bytes from memory location pointed to by register HL to the VRAM address pointed to by register DE
$00159 - $00167Code: Write value of register B name table entries from memory location pointed to by register HL to the VRAM address pointed to by register DE using the value stored at $c10a as flags
$00168 - $0017bUnused Code: Dump value of register BC bytes from VRAM pointed to by register DE to the memory location pointed to by register HL
$0017c - $00192Code: Clear Name Table
$00184 - $00192[13]Code: Write the value of register L to VRAM starting from the address pointed to by register DE the value of register BC times
$00193 - $001a6Code: Load Name Table from memory location pointed to by HL to VRAM address pointed to by DE
$001a7 - $001c4Unused Code: Similar to the code above
$001c5 - $001d5Code: Clear rectangle with width C and height B from Name Table at DE
$001d6 - $001f6Code: Load 1 BPP Tile from HL to VRAM address DE using the value stored in register A as color (Identical to 1BPPTileLoader)
$001f7 - $00223Code: Update Sprites
$00224 - $0026aCode: Prevent Sprite Flicker
$0026b - $0027cCode: Initialize VDP
$0027d - $00292Initial Data for VDP Registers 0-9
$00293 - $002c3Code: Load Tiles 4 Bit RLE from HL to VRAM address DE (Identical to PhantasyStarTileDecoder)
$002c4Unknown
$002c5 - $002d6Code: Load Tile mirrored from memory location pointed to by HL to the current VRAM address
$002d7 - $002e5Unused Code: Clear Sprite Attribute Table
$002e6 - $002eeCode: Wait for interrupt
$002ef - $00302Code: Disable Screen
$002f6 - $00302[14]Code: Enable Screen
$00303 - $00310Code: Clear Scroll
$00311 - $00340Code: Clear Sprite Attribute Table and Name Table and disable Screen
$00341 - $0034fUnknown Code
$00350 - $00366Code: Detect Keyboard Peripheral
$00367 - $003ceCode: Read Input
$003cf - $003ecCode: Take Money
$003ed - $0040aCode: Update Score
$0040b - $0041bCode: Add the 3 byte value pointed to by register HL to the 3 byte value pointed to by register BC in BCD format and store the result at BC
$0041c - $0042cCode: Subtract the 3 byte value pointed to by register HL from the 3 byte value pointed to by register BC in BCD format and store the result at BC
$0042d - $0043aCode: Subtract the 3 byte value pointed to by register HL from the 3 byte value pointed to by register BC in BCD format and store the result in register A
$0043b - $00453Code: Update High Score
$00454 - $00482Code: Print the 3 Byte BCD number pointed to by register HL to the Name Table address pointed to by register DE
$00456 - $00482[15]Code: Print the value of register C Byte BCD number pointed to by register HL to the Name Table address pointed to by register DE
$00483 - $00488Money Bag Value Lookup table
$00489 - $004a0Score Lookup table
$004a1 - $004cdUnused Unknown Code
$004ce - $004edUnknown Code
$004ee - $004fdJump Table (8 entries) (Jump instruction at $04ed)
$004fe - $006c9Unknown Code
$006ca - $0074bUnknown
$0074c - $00758Unknown Code
$00759 - $0076cUnused Code: Divide HL by E and store the result into Quotient: HL, Remainder: A
$0076d - $0080bCode: Title Screen (Game State $0 and $1) Main Code
$0080c - $00823Code: Initialize RAM for gameplay
$00824 - $00841Initialisers for RAM locations $c01f - $c037 at start of gameplay
$00842 - $00863Code: Title Screen (Game State $0 and $1) Interrupt Code
$00866 - $0086fCode: Update Title Screen
$00870 - $00880Code: Show Title Screen 0
$00881 - $0088fCode: Show Title Screen 1
$00890 - $0089bCode: Show Title Screen 2
$0089c - $008aaCode: Show Title Screen 3
$008ab - $008b9Code: Show Title Screen 4
$008ba - $008c5Code: Show Title Screen 5
$008c6 - $008e5Palette: Title screen
$008e6 - $008f1Jump Table (6 entries, indexed by current title screen) (Jump instruction at $0029)
$008f2 - $008f5Color Table: Title Screen Logo Effect
$008f6 - $009d8Unknown Code
$009d9 - $009e4Code: Clear Entity Data
$009e5 - $00a33Code: Demo (Game State $2) Main Code
$00a34Unknown
$00a35 - $00a7bCode: Demo (Game State $2) Interrupt Code
$00a7c - $00a7fDemo Level Table
$00a80 - $00a87Demo Input Data Pointer Table
$00a88 - $00ab0Code: Gameplay (Game State $9 and $a) Main Code
$00ab1 - $00abcCode: First part of Gameplay (Game State $9 and $a) Interrupt Code
$00abd - $00c42Code: Gameplay (Game State $9 and $a) Initialization Code
$00c43 - $00d09Unknown Code
$00d0a - $00d2bJump Table (17 entries, indexed by level) (Entry for current level stored at $c085)
$00d2c - $00d4dJump Table (17 entries, indexed by level) (Entry for current level stored at $c00e)
$00d4e - $00d6fJump Table (17 entries, indexed by level) (Entry for current level stored at $c089)
$00d70 - $00dc4Unknown
$00dc5 - $00dd5Sound Control Table (17 entries, indexed by level)
$00dd6 - $00e40Unknown
$00e41 - $00e6bUnknown Code
$00e6c - $00e7cCode: Load Level Tilesets for current level
$00e7d - $00e9eJump Table (17 entries, indexed by level) (Jump instruction at $0029)
$00e9f - $00ec8Code: Load Level 1 Tilesets
$00ec9 - $00edeCode: Load Level 8 Tilesets
$00edf - $00effCode: Load Level 16 Tilesets
$00f00 - $00e20Code: Load Level 10 and 15 Tilesets
$00f21 - $00e53Code: Load Level 3 Tilesets
$00f54 - $00e6bCode: Load Level 4 and 11 Tilesets
$00f6c - $00e98Code: Load Level 6 and 12 Tilesets
$00f99 - $00eadCode: Load Level 5 Tilesets
$00fae - $00ec5Code: Load Level 7 Tilesets
$00fc6 - $00ef8Code: Load Level 9 Tilesets
$00ff9 - $01021Code: Load Level 2 and 13 Tilesets
$01022 - $01057Code: Load Level 17 Tilesets
$01058 - $0107bCode: Load Level 14 Tilesets
$0107c - $010d5Unknown Code
$010d6 - $010ddUnknown
$010de - $010feUnknown Code
$010ff - $01111Code: Load Level Palette for current level
$01112 - $01133Level Palette Pointer Table
$01134 - $01141Unknown Code
$01142 - $01163Jump Table (17 entries, indexed by level) (Jump instruction at $0029)
$01164 - $0156cUnknown Code
$0156d - $0158eJump Table (17 entries, indexed by level) (Jump instruction at $15ae)
$0158f - $0161fUnknown Code
$01620 - $0164fUnknown
$01650 - $016a5Code: Bonus Level (Game State $8) Main Code
$016a6 - $01734Code: Bonus Level (Game State $8) Interrupt Code
$01735 - $018ccCode: Bonus Level (Game State $8) Initialization Code
$018cdCode: Level Completed (Game State $4) Interrupt Code: ret
$018ce - $018ecCode: Level Completed (Game State $4) Main Code
$018ed - $0194eCode: Level Completed (Game State $4) Initialization Code
$0194f - $01a00Code: Start Level (Game State $3) Main Code
$01a01 - $01a45Code: Start Level (Game State $3) Interrupt Code
$01a46 - $01b40Code: Start Level (Game State $3) Initialization Code
$01b41 - $01b96Unknown Code
$01b97 - $01ba6Palette: Start Level
$01ba7 - $01bc8Unknown
$01bc9 - $023fcUnknown
$023fd - $025fcPalette: Map
$025fd - $02673Unknown
$02674 - $02873Palette: Hirotta Stone close-up
$02874 - $066d5Unknown
$066d6 - $067c3Level Descriptors
$067c4 - $07fffUnknown
  
$08000 - $097dcSprite Descriptors (see here)
$097dd - $0984eUnknown
$0984f - $09eccSound Engine (see here)
$09ecd - $0b304Sound Data
$0b305 - $0b5041bpp Tiles: ASCII Characters $20 - $5a, ©SEGA [16]
$0b505 - $0b526Entity Data Pointer Table
$0b527 - $0b6ecEntity Data Pointers
$0b6ed - $0be87Entity Data (see here)
$0be88 - $0bfffUnused
  
$0c000 - $0c47f4bpp Tiles: Boxes
$0c480 - $0c4a1Level Main Tile Set Pointer Table
$0c4a2 - $0c582Compressed 4bpp Tiles: Bag of Gold Coins, Cloud
$0c583 - $0c9e0Compressed 4bpp Tiles: Additional Set for Levels 1, 3, 5, 9, 16 and 17
$0c9e1 - $0ce64Compressed 4bpp Tiles: Additional Set for Levels 2, 6, 8, 10, 12, 13 and 15
$0ce65 - $0cecdCompressed 4bpp Tiles: Additional Set for Levels 2, 5, 9 and 13
$0cece - $0d157Compressed 4bpp Tiles: Main Set for Levels 1, 5 and 9
$0d158 - $0d316Compressed 4bpp Tiles: Main Set for Levels 2, 10, 13 and 15 (Also used for levels 6 & 12)
$0d317 - $0d569Compressed 4bpp Tiles: Main Set for Level 3 (Also used for level 17)
$0d56a - $0db81Compressed 4bpp Tiles: Main Set for Level 4
$0db82 - $0df1cCompressed 4bpp Tiles: Main Set for Levels 6 and 12
$0df1d - $0e24bCompressed 4bpp Tiles: Main Set for Level 7
$0e24c - $0ea04Compressed 4bpp Tiles: Main Set for Level 8
$0ea05 - $0ee32Compressed 4bpp Tiles: Main Set for Level 11 (Also used for level 14)
$0ee33 - $0f116Compressed 4bpp Tiles: Main Set for Level 16
$0f117 - $0f49aCompressed 4bpp Tiles: Main Set for Level 17
$0f49b - $0f75bCompressed 4bpp Tiles: Main Set for Level 14
$0f75c - $0f7f5Compressed 4bpp Tiles: Additional Set for Level 17
$0f7f6 - $0f8954bpp Tiles: Additional Set for Levels 1, 3 and 5
$0f896 - $0f969Compressed 4bpp Tiles: Additional Set for Levels 3, 5 and 9
$0f96a - $0fc67Ending Sequence Text Data
$0fc68Unused
$0fc69 - $0ffdbCompressed 4bpp Tiles: Alex Kidd Eating Rice Ball
$0ffdc - $0ffffUnused
  
$10000 - $1005fAlex Kidd Frame Description Pointers
$10060 - $10340Alex Kidd Frame Descriptions (Including pointers to tiles) [17]
$10341 - $118e83bpp Tiles: Alex Kidd
$118e9 - $11bb4Compressed 4bpp Tiles: Janken Match
$11bb5 - $11e66Compressed 4bpp Tiles: Stone Head
$11e67 - $120a7Compressed 4bpp Tiles: Scissors Head
$120a8 - $12356Compressed 4bpp Tiles: Paper Head
$12357 - $12ac1Compressed 4bpp Tiles: Janken the Great
$12ac2 - $12d9dJanken the Great Petrifaction Data
$12d9e - $13331Name Table Entries: Title Screen
$13332 - $13edaCompressed 4bpp Tiles: Title Screen
$13edb - $13fba1bpp Tiles: Sega Mark III Logo [18]
$13fbb - $13fffUnused
  
$14000 - $143ffMetatile Name Table Entry Pointer Tables
$14400 - $1441fName Table Entries: Empty Octopus Pots
$14420 - $1444fName Table Entries: Open Door (Cragg Lake)
$14450 - $14d34Metatile Name Table Entries [19]
$14d35 - $1508dDemo Simulated Input Data
$1508e - $153f2Compressed Name Table Entries: Shop Interior
$153f3 - $157ffCompressed 4bpp Tiles: Shop Interior
$15800 - $1583fName Table Entries: Shop Exit Door
$15840 - $15923Compressed 4bpp Tiles: Shop Exit Door
$15924 - $15ad3Name Table Entries: Hirotta Stone Close-up
$15ad4 - $15e44Compressed 4bpp Tiles: Hirotta Stone Close-up
$15e45 - $161d4Map Data
$161d5 - $16f10Compressed 4bpp Tiles: Map
$16f11 - $172b04bpp Tiles: Shop Items, Currency Symbol
$172b1 - $17852Compressed 4bpp Tiles: ASCII Characters $20 - $5a, ©SEGA
$17853 - $17ed24bpp Tiles: Water, Mud, Level 4 Lava, Level 16 Foam, Level 7 Lava
$17ed3 - $17fffUnused
  
$18000 - $1bdb8Level Layout Data
$1bdb9 - $1be44Subscreen Item Data
$1be45 - $1bfaaShop Data
$1bfab - $1bfffUnused
  
$1c000 - $1c068Compressed 4bpp Tiles: "Score"
$1c069 - $1f1084bpp Tiles
$1f109 - $1fc9dText Box Data
$1fc9e - $1fe9dLevel Palettes [20]
$1fe9e - $1ff85Name Table Entries
$1ff86 - $1ffffUnused

RAM Map

This table summarises the RAM usage of the Alex Kidd in Miracle World [v1] ROM (Size: 128KB; CRC32: aed9aac4):

Address RangeContents
$c000 - $c002High Score
$c003Unknown
$c004Value of VDP register 1
$c005Input flags[21]
$c006Input data (Inverse of Port $DC)
$c007Input data Changes
$c008Interrupt flags[22]
$c009 - $c00aPointer to the next free space in the temporary Sprite Attribute Table
$c00b - $c00dUnknown
$c00e - $c00fPointer to the code that is responsible for updating the tile colors (e.g. the water color)
$c010Unknown
$c011Message to show in the text box
$c012 - $c014Unknown
$c015Flag to disable the opening of the map
$c016Next Demo to play
$c017 - $c01eUnknown
$c01fGame State
$c020Score (BCD)
$c023Level
$c024Unknown
$c025Lives (BCD)
$c026 - $c02fUnknown
$c030 - $c032Money (BCD)
$c033 - $c037Unknown
$c038 - $c039Pointer to current map/text data
$c03a - $c03bPointer to current nametable destination for the map
$c03cState of loading the map
$c03dFlag indicating if the nametable of the map should be updated
$c03eTimer for the next update of the nametable of the map
$c03fTimer for starting the current level
$c040 - $c045Unknown
$c046 - $c04fInventory[23]
$c050 - $c052Unknown
$c053Selection State of the items in the inventory
$c054Unknown
$c055Shop Flags
$c056Index of the item selected in the shop
$c057Index of the item being bought
$c058 - $c059Pointer to the nametable address of the selected item
$c05a - $c05bTimer for the invincibility
$c05cFlag indicating if the leftmost column should be blanked (only used in level $11)
$c05d - $c05eTimer for the color of the invincibility
$c05fValue of VDP register 0
$c060Unknown
$c061 - $c062Pointer to entity data pointers of the current level
$c063Flag indicating if added entities will be horizontaly offscreen
$c064Flag indicating if added entities will be verticaly offscreen
$c065Entity Index (used in non-linear levels)
$c066Flag indicating if the game is currently scrolling down to the next screen
$c067Vertical offset to apply to new entities
$c068Unknown
$c069Horizontal Position of the shop entrance
$c06a - $c06bPointer to the nametable of the shop entrance door
$c06cHorizontal Position the shop has been entered from
$c06d - $c06ePointer to the nametable of the shop entrance door where it has been entered from
$c06fFlag indicating if Alex should start walking to the next screen
$c070 - $c071Temporary pointer to the entity of Nurari or the Old Man
$c072 - $c073Temporary pointer to the animation descriptor of Nurari or the Old Man
$c074 - $c075Unknown
$c076Flag indicating if Nurari/the Old Man should be shown
$c077Flag indicating a special level scrollability
$c078 - $c07bUnknown
$c07cQuestion Mark Box Index
$c07dText Box Counter
$c07eText Box Flags
$c07fUnknown
$c080Level scrollability
$c081Level bank number
$c082 - $c084Unknown
$c085 - $c086Pointer to code that is responsible for updating the scroll flags
$c087 - $c088Pointer to the meta tile name table
$c089 - $c08aPointer to code that is responsible for loading new entities of the level
$c08b - $c08cUnknown
$c08dCurrent screen number
$c08eUnknown
$c08fCounter of power bracelets that have been picked up
$c090Alex's State before he got hit
$c091Horizontal offset to apply to new entities
$c092Flag indicating if the current level is a bonus level
$c093Trigger variable to trigger toggling the map screen
$c094 - $c095Pointer to the ending sequence
$c096State of the reset button
$c097 - $c09fUnknown
$c0a0Level width
$c0a1Lines to load to the nametable
$c0a2Unknown
$c0a3 - $c0a4Level layout pointer
$c0a5Level height
$c0a6Columns to load to the nametable
$c0a7Unknown
$c0a8 - $c0a92nd level layout pointer
$c0aaUpdateNameTable Flags
$c0ab - $c0acVelocity of horizontal scroll
$c0ad - $c0aeUnknown
$c0af - $c0b0Horizontal scroll
$c0b1 - $c0b5Unknown
$c0b6Horizontal screen number
$c0b7 - $c0b8Unknown
$c0b9 - $c0baVelocity of vertical scroll
$c0bb - $c0bcUnknown
$c0bd - $c0beVertical scroll
$c0bf - $c0c3Unknown
$c0c4Vertical screen number
$c0c5 - $c0c8Unknown
$c0c9Scroll Flags
$c0ca - $c0f3Temporary copy of level data from $c0a0 - $c0c9
$c0f4 - $c0f7Unknown
$c0f8Length of entity data array
$c0f9 - $c0faPointer to entity data array
$c0fb - $c0fcUnknown
$c0fd - $c0fePointer the nametable address of the shop door
$c0ffUnknown
$c100 - $c101Timer for the color of the water
$c102Unknown
$c103 - $c104Timer for the intro
$c105 - $c106Pointer to the input data for the demo
$c107Current input data of the demo
$c10aTemporary Variable used for the nametable flags in the code starting from $159
$c10bTemporary Variable used for the color in the 1BPPTileLoader starting from $1d6
$c10cUnknown
$c10dCounter used for the code to prevent sprite flickering starting from $224
$c10e - $c10fUnknown
$c110Sound Control Variable
$c111Sound Fade Out Volume
$c112Sound Fade Out Timer
$c113Sound Effect Priority
$c114Sound Software Channel 7 state
$c115Sound Flags for Janken Match
$c116Sound Number
$c117Unused
$c118 - $c197Sound Software Channels for music
$c198 - $c1f7Sound Software Channels for sound effects
$c1f8 - $c1ffUnused
$c200Index of Alex Tiles
$c201Index of Previous Alex Tiles
$c202Nametable Change Request
$c203Unknown
$c204 - $c205Destination for Nametable Change
$c206 - $c207Source for Nametable Change
$c208 - $c20bUnknown
$c20c - $c20dTemporary copy of Alex Horizontal Velocity
$c20e - $c20fTemporary copy of Alex Vertical Velocity
$c210Temporary copy of Alex State
$c211 - $c212Address of the nametable entry being interacted with
$c213Bit 5 of the flags of the nametable entry being interacted with
$c214Timer for the next spawn of a ghost
$c215Flag indicating if the Janken Match has started
$c216Unknown
$c217Janken Match Opponent Decision Index
$c218 - $c21fUnknown
$c220Timer for the update of level tiles
$c221Index of an animated level tile with 4 frames
$c222Index of an animated level tile with 6 frames
$c223 - $c224Pointer to the code responsible for updating level tiles
$c225Flag indicating if level tiles should be updated
$c226Timer for the progress of the titlescreen
$c227Index of the current titlescreen
$c228Timer for the color of the logo in the titlescreen
$c229Index of the riddle
$c22aPrevious decision in the riddle
$c22b - $c22fUnknown
$c230 - $c231Pointer to the sprite descriptor of the Janken Match Opponent
$c232 - $c233Pointer to the tiles of the Janken Match Opponent
$c234 - $c235Unknown
$c236 - $c237Pointer to the animation descriptor of the Janken Match Opponent
$c238 - $c239Pointer to the countdown animation descriptor of the Janken Match Opponent
$c23a - $c23bPointer to the show-decision sprite descriptor of the Janken Match Opponent
$c23c - $c23dPointer to the decisions of the Janken Match Opponent
$c23eIndex of the message to show for the Janken Match Opponent
$c23fUnknown
$c240 - $c260Temporary copy of the Alex entity
$c261 - $c29fUnknown
$c2a0 - $c2abTemporary sprite descriptor (used in Janken Match)
$c2ac - $c2ffUnknown
$c300 - $c6bfEntity Data[24]
$c6c0 - $c6ffUnknown
$c700 - $c7ffTemporary Sprite Attribute Table[25]
$c800 - $ceffName Table
$cf00 - $cf77Metatile Name Table Entries
$cf78 - $cfdfUnknown
$cfe0 - $cfffText Box Cursor
$d000 - $d6ffCopy of Name Table[26]
$d700 - $d7bfDecompressed Level Layout Data
$d7c0 - $dfcfUnknown
$d7d0 - $d7ffTemporary Nametable Descriptors for the Shop Window
$d800 - $dfffUnknown

Editor

There's an editor in development which can be found at http://kidded.emulicious.net. See also KiddEd.


  1. ^ All address ranges on this page are inclusive.
  2. ^ Similar to Teddy Boy, Transbot, Fantasy Zone, ...
  3. ^ This state uses the same code as state $a, the only difference is that in this state the map cannot be opened.
  4. ^ Similar to Teddy Boy.
  5. ^ Bank numbers used by Alex Kidd in Miracle World often have bit 7 set.
  6. ^ E.g. hits taken for monsters that survive more than 1 hit
  7. ^ When the Animation Timer hits 0 this number gets increased.
  8. ^ When the Animation Timer hits 0 this value is loaded into the Animation Timer.
  9. ^ The engine uses 6 offscreen dummy sprites. Not verified: This might be to align their sprites for their sprite flicker handling code to make sure that Alex's sprites don't flicker
  10. ^ This table was provided by VectorKiwi
  11. ^ a b Register A is used to index the table
  12. ^ Called from the interrupt handling code.
  13. ^ This code is shared with the Clear Name Table Code.
  14. ^ This code is shared with the Disable Screen Code.
  15. ^ This code is shared with the Code above.
  16. ^ Only the digits 0-9 are used in-game (for the score and shop prices).
  17. ^ There is at least one pointer to every tile in the range $10341 - $118e8, except for those in $108e1 - $109a0 and $115e9 - $11678.
  18. ^ Not used in-game.
  19. ^ There is an unused zero byte at $1464b.
  20. ^ Each palette contains 32 colours. They are stored in the following level order: 1, 15, 3, 4, 5, 6, 7, 8, 11, 9, 10, 12, 2 & 13, 14, 16, 17.
  21. ^ Bit 0 indicates that a keyboard is used for input. If Bit 5 is set input is provided by the Demo.
  22. ^ Indicate what has to be done in the interrupt handler. E.g. if bit 0 is set sprites will be updated (The Temporary Sprite Attribute Table is copied to the Sprite Attribute Table in VRAM).
  23. ^ Each of these variables is one item and a number > 0 indicates that the item is owned. The variables are in the following order: Magic Capsule A, Magic Capsule B, Telepathy Ball, Cane of Flight, Teleport Powder, Moonstone Medallion, Letter to Nibana, Power Bracelet, Hirotta Stone, Sunstone Medallion
  24. ^ An array of structs, 32 bytes each. The size of this array is stored at $c0f8. Ingame the size is frequently set to $1e.
  25. ^ This data is periodically written to the Sprite Attribute Table.
  26. ^ This copy is created when entering the pause screen and is used to restore the Name Table when returning to the game.

Researched by Paul Baker and Calindro




Return to top
0.41s