Function GetGenesisRomTitle(Filename As String) 'The ROM title will be manipulated within this variable Dim RomTitle As String 'Used for all For...Next loops, etc. Dim ArrayPos As Integer, Array2Pos As Integer 'The length of SNES ROM titles is 21 characters Const TITLELENGTH = 48 'The middle position of the 16K interleved block ' assigned to a constant for readability Const MIDDLEPOS = 8192 'Fill 'RomTitle' with 21 spaces to tell ' GET to read 21 bytes RomTitle = Space$(TITLELENGTH) 'Integer for the next free file number Dim FreeFileNum As Integer 'Find the next free file number and assign it to FreeFileNum FreeFileNum = FreeFile 'Open the ROM for binary reading Open Filename For Binary As #FreeFileNum 'Check to see if ROM is the BIN format RomTitle = Space$(48) 'Attempt to read the game title from the ROM Get #FreeFileNum, 337, RomTitle 'The SMD's 512 byte header is mostly full of null ' characters (Chr(0)), So if the first character ' in RomTitle is not a null character then the ' ROM is assumed to be in the BIN format If Asc(Left(RomTitle, 1)) <> 0 Then 'Assign the title to the function GetGenesisRomTitle = RomTitle 'Close the ROM file Close #FreeFileNum 'Exit the function Exit Function End If 'The ROM title was not valid, assume ROM is SMD ' and reset the RomTitle variable RomTitle = Empty 'The header of the ROM is stored as a string variable Dim Header As String 'Fill the header variable with as many spaces ' as equals the size of the header (512) so ' Get will read the correct header size Header = Space$(512) 'Read the header from the ROM file ' and store it in the Header variable Get #FreeFileNum, 1, Header 'Block16K is used to store the interleved 16K block ' for de-interleving Dim Block16K As String 'Fill the Block16K variable with 16K of spaces ' so Get will read 16K of bytes Block16K = Space$(16384) 'Read the 16K block from the ROM and store it in ' Block16K for de-interleving Get #FreeFileNum, , Block16K Close #FreeFileNum 'Conversion of the 16K interleved will be stored in this ' ConvertedBlock string Dim ConvertedBlock As String 'Fill the variable with 16K spaces - they will be used ' as character place holders during conversion ConvertedBlock = Space$(16384) 'NextEven & NextOdd are integer counters to keep ' track of the next write positions Dim NextEven As Integer, NextOdd As Integer 'The start even write position is 2 NextEven = 2 'The start odd write position is 1 NextOdd = 1 'Loop through the entire 16K block and begin ' de-interleving the 16K block For ArrayPos = 1 To 16384 'If the current read position is lower then 8K... If ArrayPos <= MIDDLEPOS Then 'Store at the next available even position Mid$(ConvertedBlock, NextEven, 1) = Mid$(Block16K, ArrayPos, 1) 'Increment the NextEven counter to the next available ' even position NextEven = NextEven + 2 Else 'If the current read position is greater then 8K... 'Store at the next available odd position Mid$(ConvertedBlock, NextOdd, 1) = Mid$(Block16K, ArrayPos, 1) 'Increment the NextOdd counter to the next available ' odd position NextOdd = NextOdd + 2 End If Next ArrayPos 'Read the 48 byte ROM title out of the ' de-interleved block and assign it to ' the function GetGenesisRomTitle = Mid$(ConvertedBlock, 337, 48) End Function