Skip to content

ullenius/megaman2-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mega Man 2 Password Generator

Overview

A command-line Mega Man 2 password generator written in C. Implements the Shekleton algorithm.

🖥️ Usage

Usage: mm2pwd [option]

[--etanks <number>]

Defeated robot master:
	[--airman]
	[--bubbleman]
	[--crashman]
	[--flashman]
	[--heatman]
	[--metalman]
	[--quickman]
	[--woodman]

--debug	 Print password as hex integer only
--help	 Print help text

For example:

$ ./mm2pwd --airman --bubbleman --etanks 2
A3 B1 C2 D1 D3 E2 E3 E4 E5

Will generate the password for Air Man and Bubble Man defeated and give the player 2 etanks.

🔧 How it Works

The password can be represented as 25 bits stored in 5 words of 5 bits each. A is stored first. Then words B-E are stored in little-endian format, that is:

[ A, E, D, C, B ]

A password always has exactly 9 bits set.

The A-word represents the number of e-tanks. This word only has 1 bit set.

The other words (E-B) are used to represent the robot masters (alive/defeated). The program then performs a bit rotating left-shift operation on the E-B words depending on how many etanks there are.

See Kevin Shekelton's excellent original Ruby-version for a more detailed explanation.

💾 Build

A Makefile is provided. Simply run:

$ make mm2pwd

to build the binary mm2pwd.

To compile and run the unit tests:

$ make test

Requirements

  1. C99
  2. glibc (for command-line options)

Credits

The bitmasks for the bosses are copied from the original Ruby version.The algorithm and the rest of the code is implemented manually through clean-room design based on the original documentation. The original program was used for debugging the algorithm.

📜 Licence

Copyright 2020 Anosh D. Ullenius

Copyright 2013 Kevin Shekleton

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.