@echo off

@rem Cancella eventuali file rimasti dopo pmud
@del /F /A /Q BuildOs\temp\dump\.VM
@del /F /A /Q BuildOs\temp\dump\.ROM
@rd /s /q .\BuildOs\temp\dump\.VM
@rd /s /q .\BuildOs\temp\dump\.ROM


@rem Extreloc vuole .VM e .ROM in questo formato
mkdir BuildOs\temp\dump\.VM
mkdir BuildOs\temp\dump\.ROM
@echo f | xcopy /H /Q /Y BuildOs\SYS\.VM BuildOs\temp\dump\.VM\imageinfo.bin
@echo f | xcopy /H /Q /Y BuildOs\SYS\.ROM BuildOs\temp\dump\.ROM\imageinfo.bin

cd ExtReloc
@del /F /AS xip.bin
@del /F /AS xip_out.bin
xcopy /H /Q /Y ..\src\3\xip.bin .\

@echo **********************
@echo * [xipport] Dump xip *
@echo * [xipport] Close    *
@echo **********************
xipport.exe

@rem ONLY FOR RELEASE VERSION del OUT\FILES\boot.hv
@rem ONLY FOR RELEASE VERSION @rem del OUT\FILES\boot.hv.imageinfo.txt
@rem ONLY FOR RELEASE VERSION del OUT\FILES\boot.rgu
@rem ONLY FOR RELEASE VERSION del OUT\FILES\boot.rgu.imageinfo.txt
@rem ONLY FOR RELEASE VERSION @rem del OUT\FILES\*.imageinfo.txt
@rem ONLY FOR RELEASE VERSION del OUT\FILES\*.rgu
@rem ONLY FOR RELEASE VERSION del OUT\FILES\*.rgu.imageinfo.txt
@rem ONLY FOR RELEASE VERSION @rem del OUT\FILES\*.dsm
xcopy /H /Q /Y ..\BuildOs\temp\boot.hv .\OUT\FILES\
rem xcopy /H /Q /Y ..\BuildOs\temp\boot.rgu .\

@echo ********************************************************
@echo * [extreloc]  Import xipport                           *
@echo * [extreloc]  ReallocV                                 *
@echo * [xipport]   Realoc P                                 *
@echo * [xipport]   Write maps                               *
@echo * [extreloc]  Realloc nk.exe, gsiir, ... button        *
@echo * [xipport]   Realloc P again                          *
@echo * [xipport]   Write maps (verificare se serve davvero) *
@echo * [extreloc]  Drag the vertical white line to the left *
@echo * [extreloc]  Realloc imgfs                            *
@echo * [xipport]   Build xip_out.bin                        *
@echo * [extreloc]  Close xipport and extreloc               *
@echo ********************************************************
EXTReloc.exe



@echo f | xcopy /H /Q /Y xip_out.bin ..\new\1\xip.bin

cd ..

move BuildOs\temp\dump\.VM BuildOs\temp\dump\VM.tmp
move BuildOs\temp\dump\.ROM BuildOs\temp\dump\ROM.tmp
@echo f | xcopy /H /Q /Y BuildOs\temp\dump\VM.tmp\imageinfo.bin BuildOs\temp\dump\.VM
@echo f | xcopy /H /Q /Y BuildOs\temp\dump\ROM.tmp\imageinfo.bin BuildOs\temp\dump\.ROM

rem Viene fatto in automatico da imgfsfromdump
@rd /s /q .\BuildOs\temp\dump\VM.tmp
@rd /s /q .\BuildOs\temp\dump\ROM.tmp
