Pipeworks Spigot Engine

== History ==
The Spigot engine appears to have been developed for Pipeworks Studios' second game, Godzilla: Destroy All Monsters Melee (Gamecube, 2002). The June 3rd, 2002 copy of Pipework's Gallery page calls the engine Spigot, confirming the name. 
It was expanded and ported to multiple platforms, being used as late as 2012 (Wheel of Fortune for the Wii U) by Pipeworks, and 2014 by external developers (Colossal Kaiju Combat: Kaijuland Battles, by Sunstone Games) 
== Games possibly using the Spigot Engine ==
Title 	Year	Platform 	Bundle version	Game version 	Build date	Internal name	Game folder (in debug info)
Godzilla: Destroy All Monsters Melee 	2002	GameCube 	1.18 	No version.txt file	? 	? 	
Godzilla: Destroy All Monsters Melee 	2003	Xbox 	? 	? 	? 	? 	
Godzilla: Save the Earth 	2004	PS2 	1.3 	No version.txt file	? 	? 	
Godzilla: Save the Earth 	2004	Xbox 	1.3 	4.670 (from XBE) 	09/09/2004	? 	
Rampage: Total Destruction 	2006	GameCube 	1.3 	6.1.0.25 	02/24/2006	? 	
Rampage: Total Destruction 	2006	Wii 	1.4 	7.1.0.54 	10/16/2006	? 	
Rampage: Total Destruction 	2006	PS2 	1.3 	6.1.0.24 	02/23/2006	RAMPAGE 	
NHRA Drag Racing: Countdown to the Championship 	2007	PSP 	1.4 	No version.txt file	? 	? 	
NHRA Drag Racing: Countdown to the Championship 	2007	PS2 	1.4 	2.8.7.626 	06/01/2007	DRAGRACE 	
Godzilla: Unleashed 	2007	PS2 	1.4 	1.0.0.0135 	10/12/2007	GZ3PS2 	
Godzilla: Unleashed 	2007	Wii 	1.4 	6.12.0.0267 	10/18/2007	Godzilla3 	
Boogie 	2007	PS2 	1.4 	5.1.1.398 	10/15/2007	Boogie 	
Are You Smarter Than a 5th Grader?: Make the Grade 	2008	Wii 	1.4 	1.1.0.554 	08/01/2008	FifthGrader 	
Merv Griffin's Crosswords 	2008	Wii 	1.03 	6.0.0.402 	09/26/2008	Crossword 	
Night at the Museum: Battle of the Smithsonian 	2009	Wii 	1.03 	1.0.0.779 	03/07/2009	Night 	
Night at the Museum: Battle of the Smithsonian 	2009	Xbox 360 	1.03 	No version.txt file	? 	Night 	
Charm Girls Club: Pajama Party 	2009	Wii 	1.03 	1.0.0.512 	08/04/2009	GirlsClub 	E:\Build\GirlsClub\GirlsClub
GeoStorm 	2009	Windows (32bit)	? 	? 	? 	? 	
Monopoly 	2010	PSP 	1.13 	No version.txt file	? 	Monopoly 	
Jeopardy 	2010	Wii 	1.20 	1.0.0.430 	08/11/2010	Jeopardy 	E:\Build\WheelJeopardy\Jeopardy
Wheel of Fortune 	2010	Wii 	1.20 	1.0.0.415 	08/11/2010	Wheel 	E:\Build\WheelJeopardy\Wheel
Deadliest Warrior 	2010	PS3 	? 	? 	? 	? 	
Deadliest Warrior 	2010	Xbox 360 	? 	? 	? 	? 	
Zumba Fitness 	2010	PS3 	v1.20 	? 	? 	Zumba 	
Zumba Fitness 	2010	Wii 	1.20 	1.0.0.508 	10/11/2010	Zumba 	E:\Build\Zumba\Zumba
UDraw Studio 	2010	Wii 	1.20 	1.0.0.129 	09/11/2010	TabletPaint 	E:\Build\TabletPaint\TabletPaint
Haunted House 	2010	Wii 	1.20 	1.0.0.100 	08/19/2010	HauntedHouse 	P:\ImaginEngine\HauntedHouse\HauntedHouse
UDraw Studio: Instant Artist 	2011	Wii 	1.30 	1.0.0.213 	09/05/2011	TabletPaint2 	D:\build\TabletPaint2\TabletPaint2
Deadliest Warrior: Legends 	2011	PS3 	? 	? 	? 	? 	
Deadliest Warrior: Legends 	2011	Xbox 360 	? 	? 	? 	? 	
Gremlins: Gizmo 	2011	Wii 	1.30 	1.0.0.309 	08/29/2011	GForce 	E:\Build\GForce\GForce
Monster High: Ghoul Spirit 	2011	Wii 	1.30 	1.0.0.272 	01/11/2013	Monster 	C:\projects\MonsterHigh_2011\Wii\Monster
Devil May Cry: HD Collection 	2012	PS3 	? 	? 	? 	? 	
Devil May Cry: HD CollectionPossibly only uses Spigot for the menu system between the games	2012	Xbox 360 	1.30 	No version.txt file	? 	X360DMC 	
Wheel of Fortune 	2012	PS3 	? 	? 	? 	? 	
Wheel of Fortune 	2012	Wii U 	1.30 	1.0.0.076 	11/19/2012	Wheel 	
Wheel of Fortune 	2012	Xbox 360 	1.30 	1.0.0.565 	09/03/2012	Wheel 	
Jeopardy! 	2012	PS3 	? 	? 	? 	? 	
Jeopardy! 	2012	Wii U 	1.30 	1.0.0.073 	11/14/2012	Jeopardy 	
Jeopardy! 	2012	Xbox 360 	1.30 	1.0.0.537 	08/21/2012	Jeopardy 	
Deadliest Warrior: Ancient Combat 	2012	PS3 	? 	? 	? 	? 	
Deadliest Warrior: Ancient Combat 	2012	Xbox 360 	v1.20 	1.0.0.046 	10/14/2011	DWarrior 	
Colossal Kaiju Combat™: Kaijuland Battles 	2014	Windows (32bit)	1.30 	1.0.0.467 	09/24/2015	Kaiju 	
== Pipeworks games NOT using the Spigot Engine ==
Title 	Year	Platforms 	Engine
GLOM 	2001	PalmOS 	?
Prince of Persia: Revelations 	2005	PSP 	?
Godzilla: Unleashed: Double Smash	2007	DS 	?
Prince of Persia: Rival Swords 	2007	PSP/Wii 	?
Zumba Fitness 	2010	Xbox 360 	Fabric
Wreck-It Ralph 	2012	Wii/DS/3DS 	?
Godzilla: Smash 3 	2014	Android/iOS 	Unity
Prominence Poker 	2016	Windows (32bit)/PS4/Xbox One	Unreal
Magic Spellslingers 	2022	Windows/MacOS/iOS/Android 	Unity
== Virtual Machine ==
Spigot uses a "PWK Virtual Machine", version 3.01 in Wheel of Fortune (2010, Wii). It appears to be used for scripting, and the scripts are contained in matching .pvd and .pvm files.
== Debug info ==
Some games have shipped with debugging information included, allowing for function/class names to be extracted. 
Known games with debugging info:
*Godzilla: Unleashed (2007, Wii) (partially stripped)
* Wheel of Fortune (2010, Wii)
* Jeopardy (2010, Wii)
* Night at the Museum: Battle of the Smithsonian (2009, Wii) (partially stripped)
* Zumba Fitness (2010, Wii)
* Merv Griffin's Crosswords (2008, Wii) (partially stripped)
* Gremlins: Gizmo (2011, Wii)
* UDraw Studio (2010, Wii)
* Monster High: Ghoul Spirit (2011, Wii)
* Haunted House (2010, Wii)
* Are You Smarter Than a 5th Grader?: Make the Grade (2008, Wii)
As for the debug information itself, it's included in a "default.elf" file. This file is not used by the retail game, although supposedly it is a perfect match for the retail executable if stripped and converted. There's no legitimate reason for this file to be left on the disk, so it was presumably included by mistake. 
The debugging information in the file is not fully loaded by Ghidra (which seems to just get symbol names). LLVM-dwarfdump can be used to get significantly more of it, though not all of it is decodable, and the output will include a lot of "decoding failed" errors. 
== Bundle files ==
A key part of the Spigot engine are Pipeworks bundle files. These contain named, typed, and compressed resources for the game to use. 
Bundle files are stored in .bdg files, although some games use alternate extensions, such as .bdx (Wheel of Fortune, 2012, Xbox) or .bd9 (Colossal Kaiju Combat™: Kaijuland Battles, 2014, Windows).
Sometimes there is an accompanying .jnl file, but this doesn't appear to be neccessary, and is more of a log file of the tool used to compile the bundle file. 
The bundle file comes in many versions, with the most well analyzed at the moment being v1.20. 
=== Bundle v1.20 format ===
Header definition (BundleFileHeader)
Offset	Official Name 	Size	Type 	Value/Notes
0 	szSigString 	40 	String	"Pipeworks bundle v1.20 (big endian)   \x1a\0"
40 	szProjectName 	32 	String	Zero-terminated, padded with random bytes
72 	bBigEndian 	1 	byte 	01 if the file is big endian, 00 if little-endian
76 	nTotalSize 	4 	BE Int	
80 	nTypeNames 	4 	BE Int	Count of type names
84 	nTypesOffset 	4 	BE Int	Offset to the directory of resource types.
88 	nTypesSize 	4 	BE int	Length of the directory of resource types
92 	nResEntries 	4 	BE int	
96 	nResLocsOffset 	4 	BE int	
100 	nResReqs 	4 	BE int	
104 	nResReqsOffset 	4 	BE Int	
108 	nForkPairs 	4 	BE int	
112 	nForkPairsOffset	4 	BE Int	
116 	nNameInfoOffset 	4 	BE Int	
120 	nNameInfoSize 	4 	BE Int	
Resource directory entry (variable length)
Offset	Name 	Size	Type 	Value/Notes
0 	unknown 	1 	byte 	seems to be 0x00 or 0x10 in all examples
1 	flags/type?	1 	byte 	Unknown purpose. Seen values: 00, 01, 03, 04, 05, 06, 08, 0x0A, 0x11,
2 	Type name 	n 	string	Zero-terminated. Sometimes ends with '\0\xFF' for unknown reasons. (padding/off by one error?)
Resource chunk index entry (BREntry)
Offset	Name 	Size	Type 	Value/Notes
0 	nOffset 	4 	BE int 	Offset to where the resource begins
4 	nSizeAndType 	4 	TypedInt	Size of the chunk, uncompressed
8 	nSizeAndCompression	4 	TypedInt	Size of the chunk, compressed
12 	nResourceId 	4 	BE int 	Resource ID of the chunk
TypedInt is a weird data structure used in a view places: It's a 32bit integer, but it's masked with 0x3ffffff on every use. So it's a 26-bit integer. 
The top 6 bits are used for type information. The bottom 3 of the top 6 are the compression type (1=compressed, 0=uncompressed), and the top-3 encode how many buffers are needed for loading (0-7) 
== Other software ==
at least Wheel of Fortune (2010, Wii) has a separate engine called "RockNRoll" which appears to be used for collision/physics.
It also uses the Fonix middleware for speech (recognition or lip-syncing?), and FMOD for audio playback. Videos are encoded in the THP format.