From 29ed80eaf047b20d01882858d30a4ad4fbc94258 Mon Sep 17 00:00:00 2001
From: Derzsi Daniel <daniel@tohka.us>
Date: Thu, 22 May 2025 20:54:29 +0300
Subject: [PATCH] games: Add Panda3D game engine formats

This patch adds support for two binary Panda3D game engine formats. One of them is the BAM format, which is used to represent 3D models inside the Panda3D game engine. The other is the MF format, which is a game archive that can hold game assets similar to a ZIP file.

Both formats are documented on the internet. Test files for Panda3D multifiles can be found at https://github.com/toonjoey/toontown-project-bikehorn, while test files for Panda3D BAM files can be found at https://github.com/Toontown-Open-Source-Initiative/Toontown-School-House/tree/master/resources/phase_3.5/models/gui.
---
 magic/Magdir/games | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/magic/Magdir/games b/magic/Magdir/games
index e07ad60f..942cec4f 100644
--- a/magic/Magdir/games
+++ b/magic/Magdir/games
@@ -669,3 +669,42 @@
 0	string	RGSSAD\0
 >7	byte	x	RPG Maker RGSSAD asset archive. version %u
 !:ext rgssad/rgss2a/rgss3a
+
+# Panda3D BAM model format
+# From: Derzsi Daniel <daniel@tohka.us>
+# URL:  https://gist.github.com/rdb/13cb936f41e0339a9a9cf9651ea2b09f
+0	string	pbj\0\n\r	Panda3D BAM file
+>10	ubyte	x	version %u
+>12	ubyte	x	\b.%u
+# Version >= 5.0 has little-endian and big-endian formats
+>10	ubyte	>4
+>>14	ubyte	0	\b, big-endian vertex data
+>>14	ubyte	1	\b, little-endian vertex data
+>10	ubyte	<5	\b, little-endian vertex data
+# Version >= 6.27 has single-precision and double-precision floats
+>10	ubyte	=6
+>>12	ubyte	>26
+>>>15	ubyte	0	\b, single-precision floats
+>>>15	ubyte	1	\b, double-precision floats
+>>12	ubyte	<27	\b, single-precision floats
+>10	ubyte	>6
+>>15	ubyte	0	\b, single-precision floats
+>>15	ubyte	1	\b, double-precision floats
+>10	ubyte	<6	\b, single-precision floats
+
+# Panda3D Multifile archive format
+# From: Derzsi Daniel <daniel@tohka.us>
+# URL:  https://tohka.us/p/exploring-encrypted-multifiles-a-technical-overview
+0	string	pmf\0\n\r	Panda3D Multifile archive
+>6	uleshort	x	version %u
+>8	uleshort	x	\b.%u
+# Version >= 1.1 has creation date information, missing if set to zero
+>6	uleshort	=1
+>>8	uleshort	>0
+>>>14	uledate	=0	\b, unknown creation date
+>>>14	uledate	!0	\b, created: %s
+>>8	uleshort	<1	\b, unknown creation date
+>6	uleshort	>1
+>>14	uledate	=0	\b, unknown creation date
+>>14	uledate	!0	\b, created: %s
+>6	uleshort	<1	\b, unknown creation date
-- 
2.49.0

