@@ -5,7 +5,7 @@
import sys , os , glob , json , math , re , struct , hashlib , argparse , datetime
# Configuration
app_version = " 0.3 "
app_version = " 0.6 "
default_file = " LK_MULTIMENU_<CODE>.gba "
################################
@@ -84,13 +84,19 @@ if not os.path.exists(args.config):
cartridge_type = 1
battery_present = False
for file in files :
games . append ( {
d = {
" enabled " : True ,
" file " : os . path . split ( file ) [ 1 ] ,
" title " : os . path . splitext ( os . path . split ( file ) [ 1 ] ) [ 0 ] ,
" title_font " : 1 ,
" save_slot " : save_slot ,
} )
}
with open ( file , " rb " ) as f :
f . seek ( 0xAC )
code = f . read ( 0x4 )
if code [ : 3 ] in ( b " BPG " , b " BPR " ) :
d [ " map_256m " ] = True
games . append ( d )
save_slot + = 1
obj = {
" cartridge " : {
@@ -166,6 +172,11 @@ for game in games:
x = 0x80000
while ( x < size ) : x * = 2
size = x
if size < 0x400000 :
with open ( f " roms/ { game [ ' file ' ] } " , " rb " ) as f :
buffer = f . read ( )
if b " Batteryless mod by Lesserkuma " in buffer :
size = 0x400000
game [ " index " ] = index
game [ " size " ] = size
if " title_font " in game :
@@ -310,7 +321,7 @@ logp("Menu ROM: 0x{:07X}– 0x{:07X}".format(0, len(menu_rom)))
logp ( " Game List: 0x {:07X} – 0x{:07X} " . format ( item_list_offset * sector_size , item_list_offset * sector_size + len ( item_list ) ) )
logp ( " Status Area: 0x {:07X} – 0x{:07X} " . format ( status_offset * sector_size , status_offset * sector_size + 0x1000 ) )
logp ( " " )
logp ( " Cartridge Type: {:d} ( {:s} {:s} ) ". format ( cartridge_type , cartridge_types [ cartridge_type ] [ " name " ] , " with battery " if battery_present else " without battery " ) )
logp ( " Cartridge Type: {:d} ( {:s} ) {:s} " . format ( cartridge_type + 1 , cartridge_types [ cartridge_type ] [ " name " ] , " with battery " if battery_present else " without battery " ) )
logp ( " Output ROM Size: {:.2f} MiB " . format ( rom_size / 1024 / 1024 ) )
logp ( " Output ROM Code: {:s} " . format ( rom_code ) )
output_file = output_file . replace ( " <CODE> " , rom_code )
@@ -320,7 +331,7 @@ if args.split:
size = 0x2000000
if pos > len ( compilation [ : rom_size ] ) : break
if pos + size > rom_size : size = rom_size - pos
output_file_part = " {:s} _part {:d} {:s} " . format ( os . path . splitext ( output_file ) [ 0 ] , i + 1 , os . path . splitext ( output_file ) [ 1 ] )
output_file_part = " {:s} _part {:d} {:s} " . format ( os . path . splitext ( output_file ) [ 0 ] , i , os . path . splitext ( output_file ) [ 1 ] )
with open ( output_file_part , " wb " ) as f : f . write ( compilation [ pos : pos + size ] )
else :
with open ( output_file , " wb " ) as f : f . write ( compilation [ : rom_size ] )