A MBR (Master Boot Record) is always at LBA 0, the first sector of the device, the sector the (Legacy) BIOS loads. As you know, this sector has a Partition Table of at least one and (usually) not more than four valid entries. These entries indicate how the device's media is divided into partitions. A Partition may be anywhere on the device. It is up to the partitioning utility to correctly and accurately partition the device so no partition overlaps and most/all media is used/partitioned.
The MBR can and usually does contain enough code and data to parse the Partition Table, looking for the active partition (first byte of entry), then loading the first sector of the found partition to address 0x07C00. Depending on whom you ask, there is either plenty of room or not near enough room in this first sector to accomplish this task. In past history, the first 63 sectors were usually used to boot a partition, given Boot Extenders, BIOS Extenders, etc.
A partition usually started at LBA 63, using most or all of the remaining media. If it was a large media device (couple hundred meg, which was large then), you may have one ore more partitions, using Extended Partition Entries.
Each of these partitions should be self contained. i.e.: If the partition starts at LBA 63 and ends at LBA 12345, the contained code/data/filesystem within it should not require any access to any LBA outside of these two limits.
If this partition is the active partition, the booted partition, it will have code within the first LBA of its partition (usually called an LSN (Linear Sector Number)), to continue loading the OS. This LSN 0 may contain a BPB, it may not, depending on the file system contained within this partition.
It is up to the MBR code to load this LSN 0 to 0x07C00, then the code at LSN 0 to load any remaining sectors (LSN 1 to LSN n) to load a second stage boot loader.
The problem comes when the code at LSN 0 doesn't know where it is located. For example, if LSN 0 is at LBA 63, when the code at LSN 0 sends a LBA value to the BIOS read service, how does it know this LBA value? This is where the BPB comes in. Within a FAT formatted BPB, there is a Hidden Sectors field that, in this case is 63, tells the code at LSN 0 where it is located. Not all file systems use this scheme. Ext2 for example.
To summarize, if you wish to write all of this from scratch, you will need a MBR code/data file that is 512 bytes exactly and most likely will never change. This MBR simply parses the Partition Table and loads the first sector of the found active partition. Period.
Then, you will need a first stage boot code file (called the VBR in previous posts) for each file system (and type) you want to support. This first stage code/data file can be 512 to n bytes in length, where as if it is more than one sector, your code must contain, within this first sector, all of the code and data to be able to load the remaining sectors of your first stage boot code. Then with all of the first stage boot code loaded, it will, if you wish, load a second stage loader.
Now, you can have the first stage boot code do all of the loading, but this is usually not the case.
As an example, my project has two different MBR/UEFI files. The first, the MBR code, is for legacy BIOSes and simply does what I explain above with a few extra perks. For example, it will parse extended partitions as well. The UEFI file, when booted from a legacy BIOS with a GPT at LBA 1, will parse the GPT and load the first sector of the found active partition. These two files seldom change and absolutely don't care what file system is on the partition it loaded, other than the System ID field in the MBR partition table entry.
I then have a first stage boot code/data file for each file system and their variants (FAT12, FAT16, FAT32) to load a single file from the said file system, called loader.sys. It is the job of this first stage code to simply parse the said file system and load the whole file. It also does a few other things needed for the loader.sys file to function correctly. Each of these source code/data files are (as expected) file system dependent and are all written in x86 assembly.
I then have a single loader.sys file that uses multiple source files, all but 5% written in C, to continue loading the OS. This loader.sys file's project files are written so that with a single #define, I can included or exclude a given file system. Therefore, I can compile this loader.sys file (the second stage boot code) to be included with any and all file systems (loader.sys > 90k) or compile it to be single file system dependent (loader.sys < 30k).
Does this give you an idea of what you can do? The most important thing you need to remember is that, as a hobbiest OS developer, you have full control after the POST passes control to address 0x07C00. You can do anything you want, formatting the hard drive (boot device) to any format you wish, loading the OS however you wish. The only thing you need to worry about is compatibility with firmware or other software/file systems.
Ben
http://www.fysnet.net/osdesign_book_series.htm