For those of you who have downloaded and played any of my games over the past couple years now, You may have noticed I use a MFI file for the games resources, Graphics, Music, Sounds, ect.
Well I've cleaned it up a bit and commented it for ease of use. Version 1.0 allows for 255 files stored. Even my most ambitious game to-date, Dragon Warrior, only has 86 files stored. An idea for Version 2.0 will be to allow 32767 files (honestly though if you have that many resources then you need to rethink things!).
This Code Creates the MFI file:
'Multi-File-Index Maker Ver. 1.0
'Release Date: 3/15/2020
'UniKorn ProDucKions
'Cobalt (Aka. David)
'FileList.TXT format:
' line 1: name of MFI file to be made(or what ever extention you want)
' line 2: number of files
' line 3+: files to add
'--------Setup---------
_TITLE "Multi-File-Index Creater V1.0 @2019 UniKorn ProDucKions" '----------------------
'File Compactor
c~%%
= VAL(files$
) ' change to numeric value
'-------Get files Sizes------
'----------------------------
FOffset& = c~%% * 8 + 1 'number of files*(LONG+LONG)+ _BYTE(number of files max-255)
'-------Put the File Data into the MFI File-------
FOffset& = FOffset& + Size(i~%%)
'-------------------------------------------------
'--------Add files to the MFI file--------
PRINT F$
(i~%%
);
TAB(60); Size
(i~%%
): TS&
= TS&
+ Size
(i~%%
)'debuging and informative prints: this can be commented out for speed '-----------------------------------------
PRINT "Total bytes output:";
TAB(60); TS&
'total bytes added to MFI file
ELSE 'No file list found to process, in form user to make one. PRINT "FileList.TXT missing. Please make FileList.TXT with the following layout:" PRINT "(And make sure FileList.TXT is in correct directory.)" PRINT "## (total number of files, Maximum 255 as of V1.0)" PRINT "File #1 to include" PRINT "File #2 to include" PRINT "File #N to include"
This Code Loads the files Stored in the MFI file:
Example call:
MFI_Loader "DragonWV1.MFI"
'FN$: Name of the MFI file.
MFI
= FREEFILE 'file number for MFI file to load from, this value must be passed to SUBs. ' This avoids issues with user already having the file number open
GET #MFI
, , c~%%
'retrieve number of files GET #MFI
, , MFI_FOffset
(I~%%
) GET #MFI
, , MFI_Size
(I~%%
) MFI_FOffset&(I~%%) = MFI_FOffset&(I~%%) + 1
REM Loading Example Lines
*************************************************************** '-----------Load the files where they go here----------
' Layer(2) = LoadGFX(MFI_FOffset(4), MFI_Size(4), MFI) '_LOADIMAGE("YahtzeeSplash.BMP", 32)
'
' FFX& = LoadFFX(MFI_FOffset(8), MFI_Size(8), 24, MFI) '_LOADFONT("OBGB.ttf", 24, "MONOSPACE")
'
' BGM(1) = LoadSFX(MFI_FOffset(16), MFI_Size(16), MFI) 'Splash\Title Screen Music
'
' SFX(1) = LoadSFX(MFI_FOffset(13), MFI_Size(13), MFI) 'rolling dice'
'
'--------------------------------------------------------
REM *************************************************************************************
FUNCTION LoadGFX&
(MFI_Foff&
, MFI_Size&
, MFI
) GET #MFI
, MFI_Foff&
, dat$
FUNCTION LoadFFX&
(MFI_Foff&
, MFI_Size&
, MFI_Fize%%
, MFI
) GET #MFI
, MFI_Foff&
, dat$
LoadFFX&
= _LOADFONT("MFI_temp.dat", MFI_Fize%%
, "monospace")
FUNCTION LoadSFX&
(MFI_Foff&
, MFI_Size&
, MFI
) GET #MFI
, MFI_Foff&
, dat$
SUB LoadData
(MFI_Foff&
, MFI_Size&
, MFI
) GET #MFI
, MFI_Foff&
, dat$
'Load stored data here