View Page Source

Back to Page
Revision 17 (current)
Edited by adelikat on 9/2/2023 2:53 PM
The purpose of this page is to document all of the known tricks
of the NES Contra game so far.

Because of the nature of this site, we concentrate here on tricks
that are extremely difficult to execute in real play, but are useful
in the making of tool-assisted speedruns. For most of the tricks,
a [Glossary|frame advance] feature in an emulator is a definite must-have.
%%%
%%%
%%TAB Table of contents%%
%%TOC%%
%%TAB Movies%%
__Currently Published Movies__
[module:displaymovie|game=18]
%%TAB RAM Addresses List%%

See also [http://acmlm.kafuka.org/board/thread.php?pid=126023#126023|Trax's disassembly]
([https://www.bwass.org/romhack/contra/|home page]),
especially [https://www.bwass.org/romhack/contra/contrarammap.txt|contrarammap.txt].
It is for the North American release.

BizHawk .wch file: [UserFiles/Info/637936906459604210]

Known enemy sprite codes:
|7A|Arm segment of Gromaides (Level 3 boss)|
|7B|Hand segment of Gromaides (Level 3 boss)|

%%TAB_END%%
----
!! The Jump Glitch
[module:youtube|v=kXKniEJDXBM|start=145|loop=150|align=right|w=197|h=148|hidelink]
In Stage 3 it is possible to jump to ledges normally impossible by taking advantage of vertical scrolling.  To perform it you jump, then press left, then hold right.  It seems random, but if you press right at the right frame, you will stay in air for longer than usual and can land on ledges that would normally take 2 jumps.  

Conversely, this can also be used to jump shorter than normal.  This should be used on all other jumps in order to shave a frame from each one.  (In reality many of them can not be shaved this way).
%%%%
----
!! Spread Gun Optimization - Horizontal levels
%%%%
----
!! Spread Gun optimization - 3D levels
%%%%
----
!! Gradual Spread Gun pattern substitution
%%%%
----
!! Boss Behavior

Boss HP can only drop 1 HP per frame.  This means the strategy isn't as much about unloading bullets as fast as possible, but instead trying to make sure damage is registered every frame.

! Gromaides (Level 3 Boss)

The arms of Gromaides occupy 10 enemy slots,
one for each segment.
The following enemy variable arrays have special meanings for this boss:

|05A8|0x00 = segment belongs to the left arm, 0x01 = segment belongs to the right arm (relative to the screen).|
|05C8|Frame counter for each segment. Counts up to 16; then spawns the next arm segment and becomes 0xFF.|
|05D8|Enemy slot index of the next arm segment, moving inward. 0xFF if this is the innermost segment (the "shoulder").|
|05E8|Enemy slot index of the next arm segment, moving outward. 0xFF if this is the outermost segment (the "hand").|

The enemy variable arrays at 05D8 and 05E8
form doubly linked lists of arm segments,
one list for each arm.

Some subroutine addresses:

|9B7E|Update function for initial arm extension. Has delay counters for spawning in each arm segment successively. Calls 9BDA to update the position of each spawned segment.|
|9BDA|Arm segment position update function during initial extension. Adds ±0x0.B5 pixels to the ''x''-coordinate (depending on whether left or right arm) and −0x0.B5 pixels to the ''y''-coordinate of each spawned arm segment.|
|9C11|Stores the sprite code to use for an arm segment in the corresponding slot in the 030A enemy variable array: 0x7A for an "arm" segment or 0x7B for a "hand" segment.|

!! RNG

The RNG variable at address 0034
is updated by repeatedly adding to it the current frame counter (and carry flag),
in an infinite loop
until an [https://wiki.nesdev.com/w/index.php?title=NMI|NMI] (vblank) occurs.

 07:F880: A5 1A    LDA $1A    ; frame counter
 07:F882: 65 34    ADC $34    ; RNG
 07:F884: 85 34    STA $34
 07:F886: 4C 80 F8 JMP $F880

!! External links

* Series of articles by Allan Blomquist:
*# [https://tomorrowcorporation.com/posts/retro-game-internals|Introduction] – object model, level types, scrolling
*# [https://tomorrowcorporation.com/posts/retro-game-internals-contra-levels|Levels] – screens, supertiles, collision data, enemies
*# [https://tomorrowcorporation.com/posts/retro-game-internals-contra-random-enemies|Random Enemies] – random enemy spawns, respawn counter, weapon levels
*# [https://tomorrowcorporation.com/posts/contra-base-enemies|Base Enemies] – static enemies, sequenced enemies, power-up enemies
*# [https://tomorrowcorporation.com/posts/retro-game-internals-contra-collision-detection|Collision Detection] – object vs. object, object vs. level, 3D collision
*# [https://tomorrowcorporation.com/posts/retro-game-internals-contra-player-control|Player Control] – player physics, player states, control details
*# [https://tomorrowcorporation.com/posts/retro-game-internals-contra-conclusion|Conclusion] – RNG, structure of arrays, screen space coordinates, formulas for enemy HP and behavior, changes after multiple playthroughs

*[https://www.youtube.com/watch?v=8LnwsYL7Apk|Contra - Behind the Code] – Konami code, "R" weapon upgrade, player bullet speed

*https://github.com/vermiceli/nes-contra-us/ - An annotated disassembly with supplemental materials of the Contra (US) NES game.

%%%%