Breaking Dracula’s Castle 101
Before delving into why the scroll glitch works and how to execute it, I recommend understanding how castlevania updates its background tiles. Once we understand this, we can find various ways to break it, as well as diagnose when the scroll glitch fails.
How are background tiles updated?
Castlevania graphics are made up of foreground sprites (simon, candles, hearts, enemies) and background tiles. The game is building up these background tiles ahead of what is actually on the screen behind the scenes so that it can scroll smoothly as Simon moves. Around half a screen offscreen, the game is drawing a column two blocks wide. When that is complete, the game moves onto the next column. It looks something like this:
Tile Update Algorithm
Step 1: Should the update algorithm run?
There is a framecounter that starts at the beginning of every screen. This is the same framecounter that powers the item drops throughout the game. The update algorithm ONLY runs every other frame. I am not certain as to why, but I would guess this is because the Nintendo is not a very powerful system and this gives it time to do other work. Even if Simon is moving forward on a non updating frame, no tile will be updated.
Step 2: Is Simon moving (left or right… doesn’t matter)?
If Simon is moving (and we are on an even frame as discussed above), the tile upgrading algorithm will run and update a tile. Otherwise, the tile updating process is skipped.
Step 3: Determine which vertical column is going to be updated
If Simon is walking left, we will select a column on the left to update. If he is walking right, the column will be to the right. Every column is 32 pixels wide. For every column, there is another set of 32 pixels around 1.5 screens away that map to that column. When Simon is walking over this set of pixels in the direction towards that column, that column will be updated. See the section “How Background Tiles are Updated” for a picture that corresponds to this mapping.
I will refer to this 32 pixel walking space as the Column Update Window.
Step 4: Determine which tiles will be updated
We are now going to choose which actual blocks on the column will be updated. The game manages a special variable called the Block Counter that determines that location. This variable maps to the tiles vertically like so:
The block counter has a value between 0 and 7, inclusive; however, only the values 1-6 actually map to blocks.
Here is how the algorithm works:
- Did I just enter a new “Column update window”? (One of those 32 pixel spaces you walk over)
- If yes, no matter WHAT ( even overriding the every other frame rule described above), reset the Block counter to 0
- Update the blocks in the selected column (the direction Simon is facing) at the vertical level marked by the block counter.
- If the counter is 0 or 7, this does nothing.
- Increment the block counter by 1
- If the block counter > 7, set the block counter to 0