DetectBase:
	length #result
	ifne #result, ROM_SIZE, .error
	checksha1 #result, .crystal10
	set #source, 1
	set #message, .crystal10_message
	jumpz #result, .done
	checksha1 #result, .crystal11
	decrement #source
	set #message, .crystal11_message
	jumpz #result, .done
	checksha1 #result, PrismHashes
	jumpz #result, HandleReleasePrismBase
	add #result, PrismHashes, HASH_SIZE
	checksha1 #result, #result
	jumpz #result, HandleDebugPrismBase
.error
	print InvalidROMMessage
	exit 1
.done
	print #message
	return

.crystal10_message
	string "Detected base: Pokémon Crystal v1.0"
.crystal11_message
	string "Detected base: Pokémon Crystal v1.1"

.crystal10
	hexdata f4cd194bdee0d04ca4eac29e09b8e4e9d818c133
.crystal11
	hexdata f2f52230b536214ef7c9924f483392993e226cfb

InvalidROMMessage:
	string "Invalid base ROM. Please use a US version of Pokémon Crystal v1.0 or v1.1."

SelectTarget:
	print .select_target
	menu #target, .target_menu
	retz #target
	print .confirm_debug_1
	print .confirm_debug_2
	menu #result, YesNoMenu
	retz #result
	jump SelectTarget

.select_target
	string "Select the ROM you want to build:"

.target_menu
	dw .release_target
	dw .debug_target
	dw -1
.release_target
	string "Release version"
.debug_target
	string "Debug version"

.confirm_debug_1
	string "The debug version contains no additional game features, other than debug options intended to aid the development of the game."
.confirm_debug_2
	string "Are you sure you want to build the debug version?"
