
Making a baby player file for use with the Baby player
======================================================

Unfortunately P.F.Magic never made a tool for making .bly files before 
they stopped supporting the game.  This means that we can download the 
large "Baby player" file, and install it, but all for nothing much since 
we have only the one baby (up at Babyz.net) to play with.  So here's how 
to make it so that your own babyz can be played with online :-)

It requires use of a hex editor.  If you don't have one, there are loads 
of them available for download, and they all do the same basic tasks, 
although some of them have complicated "bells and whistles" too for 
power-users.  You can get various freeware ones, such as: 

Axe: downloadable from my site or from Daniel Wright's Odd-Petz site amongst others.
Hexedit: http://www.okinfoweb.com/moe/files/hexedit.zip
Hexedit	(yes, same name, different program):
http://www-physics.mps.ohio-state.edu/~prewett/hexedit/index.html

If none of these suit you, do a search in one of the Internet search-engines 
for "Hex Editor" and "freeware".  All of them are pretty straightforward to 
install, I think.  Then, if you have the shortcut to your chosen one on your 
desktop, you can  drag-and-drop any file you want to investigate onto it.  
They all show files in a similar way: there are three sections, the left-hand 
one being the "Address" section and containing numbers which show which byte 
you're looking at (in Hex numbers usually), and it starts at 00.  The middle 
section is the meat of the thing, being the actual data of the file shown 
as hexadecimal numbers.  The right-hand side shows the file itself also, 
but in this case as raw ASCII so that you see it as a mix of weird symbols 
or dots and text.  Most of the time you will be looking at that right-hand 
section in order to find or fiddle with bits of text.

Okay, you can construct a .bly file from scratch if you like, or you can start 
with an existing .bly file.  You can either use the single one which is up at 
the babyz.net site, or you can use one of the two included with this tutorial.  
I include a normal baby, Jack, and one of my wee monkey babies, Vesuvius, 
for your enjoyment and assistance.

The .bly file is constructed like this: 

1) The Header, including names and sizes of included files (Baby, clothes)

2) The Baby file itself

3) The clothes

I haven't found a way of making backgrounds show up, so the items which 
follow the header are simply the .baby file followed by clothes files.

NOTE: if you want to see the player-babyz on a different carpet in your
browser (of course you must have the player installed), you can edit the 
npBabyz.dll file which is in your browser's Plugins directory.  The simplest
way to do this, after putting a copy of npBabyz.dll somewhere safe, is to
open the original one into ResHacker.  Navigate via the crosses in the
left-hand pane to Bitmap, 508 and then place the cursor on 1033.  Now
choose Action from the main menu, then Replace bitmap.  Use the dialogue
box that pops up to locate and choose your replacement bitmap, then 
hit Replace, then close the dialogue.  Now choose Save from ResHacker's
file menu.  The next time you play with a baby online you will have your
own background behind the baby.  If you need ResHacker, it's downloadable from
http://www.users.on.net/johnson/resourcehacker/


Header
======

This is what the start of a .bly file looks like in the hex editor:

00000000 | 0070 6C79 4865 6400 6F14 0100 0200 0000 | .plyHed.o.......
00000010 | 4A61 636B 2E62 6162 7900 BC0F 0100 436C | Jack.baby.....Cl
00000020 | 6F74 5F43 6F76 6572 616C 6C73 4465 6E69 | ot_CoverallsDeni
00000030 | 6D2E 636C 7A00 6104 0000 B90B 4A61 636B | m.clz.a.....Jack

Let's just break this down so you can see what it all means; I'll explain about 
the numbering system afterwards.  So we have, reading from top left:

<null byte> <--in other words, hexadecimal 00

plyHed 

<null byte>

<size of finished .bly file in Hex numbers> <--in this example, 6F140100

0200 0000 <--number of items in the file; in this case 2 -- one baby, one item of clothing.

<name of baby> <--in this example, Jack.baby

<size of actual .baby file, in hex> <--in this example, BC0F0100

<name of clothing item>

<size of clothing item, in hex> <--in this example, 61040000

(After that, you get the actual baby file.)

Okay, I think all that is pretty straightforward, but the numbers which show the 
sizes of things can be a bit confusing.  They appear to be the "wrong" way round, 
but it's just a different way of looking at hexadecimal numbers.  There's the Intel 
way, and the Motorola way.  Your hex editor will show you the size of a selected 
area of file one way round; unfortunately it's probably not the way round that the 
information is actually stored within the header.  So, when you highlight the whole 
of your file (in this example, Jack.bly), your hex editor will probably tell you 
that the file is 01146F bytes long  However, your size of file is stored as 6F1401 
in the header.  Look closely, and you will see that the hexadecimal numbers have 
been reversed:

6F 14 01

instead of

01 14 6F

I'm afraid you'll have to get used to that quirk if you're going to make your babyz 
playable online, at least until some programming guru out there makes a utility to 
do the job.

If you're altering a .bly file to suit yourself, then you can put in the items that 
you want in the relevant places and then alter the header to fit the contents.  If 
you're starting from scratch, then put null bytes for the real numbers, finish building 
the whole file, then change the null bytes to give the correct numbers.

The Baby
========

This is simple; open your .baby file into the hex editor, select the whole file, choose 
"copy", then close the baby file.  Now if you're starting from scratch, go to the end 
of your newly-built header and paste it. add a null byte to the end, then the text string 
plySep, then another null byte.  You are now ready to add the clothing.

Or, if you're starting with a ready-made .bly file, select the whole of the baby file 
that's already there -- in this example, from the B90B ID number before Jack -- to the 
first item of clothing (or the end of file, if you have no clothing, I suppose).  You 
must select from the beginning of that ID and finish one byte before plySep.  The word 
plySep always has one null byte before it and one null byte after it, as does plyEOF.

The clothes and end.
====================


00010FF0 0000 0000 0000 0070 6C79 5365 7000 5B46 .......plySep.[F
00011000 6C61 7420 436C 6F74 6869 6E67 5D20 3B20 lat Clothing] ; 

These are a little more complicated.  If you are using a pre-made .bly file and are happy 
to use the same clothing, then you don't have to bother with this.  But if you are starting 
from scratch or wish to change the clothes, then you do need to.

Find the item of clothing that you want to use.  Open it in your hex editor.  Find the 
start of the .clz section; it will start either with [Add Clothing] (for hats or tails etc) 
or with [Flat Clothing] (sweaters, pants etc).  Select the whole of the .clz section -- 
it's the part which contains the numbers and text of clothing which people alter when hexing 
clothes, and usually ends with 

; linez 

or 

; paintballs.

Choose Copy.  

Now, if you're starting from scratch, go to the end of the .baby file which you added earlier 
and paste this .clz section right at the end, after the null byte after plySep.  Add another 
null byte and plySep and nuull byte.  If you're adding more clothes, do them in the same way; 
if you've finished, then add another null byte, then plyEOF, then a final null byte.

If you're using a previous .by file, then you want to go to the clothing section which starts 
after the null byte which comes after the first plySep.  Highlight from there to just before 
the null byte which comes before the next plySep.  Choose Paste.  Do this for each of the items 
of clothing which you wish to replace.

Now you need to make sure that you put the correct sizes -- and the correct number of files 
included -- into that header at the top of the file.

00011450 203B 2070 6169 6E74 6261 6C6C 730D 0A00  ; paintballs...
00011460 706C 7953 6570 0000 706C 7945 4F46 00   plySep..plyEOF.

The html file
=============

This is the same as for the petz .ply files, really.  I'm not a whizz at html, but I've found 
that this works:

<html>
<head>
<title>Babyz Player</title>

      <div align="center">

 
		<EMBED src="Jack.bly" TYPE="application/x-PFM Babyz" width=400 height=400 units=pixels border=1>

</body>
</html>

And that's it; you can now put your special adoptees or mascot babyz or whatever up at 
your website for others to play with.

Enjoy!

Carolyn Horn

P.S. an answer to a confused question:

>I've read your tutorial on making "bly" files, but I can't quite follow
>where exactly to copy and paste my baby into the file.  Can you give me
>instructions on the exact number of bytes to replace?

Well, it depends on the baby!  Each baby is a different length, so the 
number of bytes to replace varies.  Each bly file has the same length of 
header, however, and the only way I know how to explain it is by showing 
you what I see in my copy of Hex Workshop when I look at my Jack .bly
file (included in the blymaking tutorial zipfile):

00000000 0070 6C79 4865 6400 6F14 0100 0200 0000 .plyHed.o.......
00000010 4A61 636B 2E62 6162 7900 BC0F 0100 436C Jack.baby.....Cl
00000020 6F74 5F43 6F76 6572 616C 6C73 4465 6E69 ot_CoverallsDeni
00000030 6E2E 636C 7A00 6104 0000 B90B 4A61 636B n.clz.a.....Jack

I'd recommend starting with an already-made .bly file, and you should
have a couple if you've got my tutorial -- plus you can get one from the
babyz.net site, a few more from my own site, also Littlefeet started 
making Player babyz using my info; her site is no longer there, but 
others may have her player babyz.

So, find the two bytes which are the start of the baby within the .bly
file; as you can see here, it's at offset 3A, where you see B9 in this 
example.  The end of the baby file inside the .bly you'll need to find 
yourself; but it's fairly simple, it's got a plySep after it, so in the 
case of my Jack .bly file it's 69564 bytes long.  Just paste your own 
complete baby over that; doesn't matter that it's longer or shorter, 
but you _will_ have to alter the relevant information in the .bly file 
header to suit.  See my tutorial for details, I go into it very carefully.



