Move building the disk image & patching rom into cmake
This fixes a problem I kept causing myself: the patched ROM files were not per build directory, meaning that I'd build a wrong ROM and wonder why nothing was working.
This commit is contained in:
parent
7d815b8fd3
commit
082f3175f0
4 changed files with 35 additions and 32 deletions
|
|
@ -73,6 +73,8 @@ set(PIN_AUDIO_PWM 41 CACHE STRING "Pin for PWM audio")
|
||||||
# overriding defaults.
|
# overriding defaults.
|
||||||
set(MEMSIZE 128 CACHE STRING "Memory size, in KB")
|
set(MEMSIZE 128 CACHE STRING "Memory size, in KB")
|
||||||
|
|
||||||
|
set(DISC_IMAGE ${CMAKE_CURRENT_SOURCE_DIR}/umac0ro.img CACHE FILEPATH "Built-in disk image")
|
||||||
|
|
||||||
if (USE_HSTX)
|
if (USE_HSTX)
|
||||||
add_compile_definitions(USE_VGA_RES=1)
|
add_compile_definitions(USE_VGA_RES=1)
|
||||||
add_compile_definitions(HSTX_CKP=${HSTX_CKP} HSTX_D0P=${HSTX_D0P} HSTX_D1P=${HSTX_D1P} HSTX_D2P=${HSTX_D2P})
|
add_compile_definitions(HSTX_CKP=${HSTX_CKP} HSTX_D0P=${HSTX_D0P} HSTX_D1P=${HSTX_D1P} HSTX_D2P=${HSTX_D2P})
|
||||||
|
|
@ -87,10 +89,12 @@ if (USE_VGA_RES)
|
||||||
add_compile_definitions(DISP_WIDTH=640)
|
add_compile_definitions(DISP_WIDTH=640)
|
||||||
add_compile_definitions(DISP_HEIGHT=480)
|
add_compile_definitions(DISP_HEIGHT=480)
|
||||||
set(RES "640x480")
|
set(RES "640x480")
|
||||||
|
set(RESFLAG "-v")
|
||||||
else()
|
else()
|
||||||
add_compile_definitions(DISP_WIDTH=512)
|
add_compile_definitions(DISP_WIDTH=512)
|
||||||
add_compile_definitions(DISP_HEIGHT=342)
|
add_compile_definitions(DISP_HEIGHT=342)
|
||||||
set(RES "512x342")
|
set(RES "512x342")
|
||||||
|
set(RESFLAG "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_PSRAM)
|
if (USE_PSRAM)
|
||||||
|
|
@ -187,6 +191,21 @@ if (TARGET tinyusb_device)
|
||||||
)
|
)
|
||||||
|
|
||||||
# The umac sources need to prepare Musashi (some sources are generated):
|
# The umac sources need to prepare Musashi (some sources are generated):
|
||||||
|
add_custom_command(OUTPUT incbin/umac-rom.h
|
||||||
|
COMMAND echo "*** Patching ROM ***"
|
||||||
|
COMMAND set -xe && mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/incbin && make -C ${UMAC_PATH} patcher && ${UMAC_PATH}/patcher ${RESFLAG} -m ${MEMSIZE} -r "${CMAKE_CURRENT_LIST_DIR}/rom.bin" -w ${CMAKE_CURRENT_BINARY_DIR}/incbin/umac-rom.h
|
||||||
|
)
|
||||||
|
add_custom_target(prepare_rom
|
||||||
|
DEPENDS incbin/umac-rom.h
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT incbin/umac-disc.h
|
||||||
|
COMMAND echo "DISC_IMAGE is ${DISC_IMAGE}" && mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/incbin && xxd -i < "${DISC_IMAGE}" > ${CMAKE_CURRENT_BINARY_DIR}/incbin/umac-disc.h
|
||||||
|
)
|
||||||
|
add_custom_target(prepare_disc
|
||||||
|
DEPENDS incbin/umac-disc.h
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${UMAC_MUSASHI_PATH}/m68kops.c
|
add_custom_command(OUTPUT ${UMAC_MUSASHI_PATH}/m68kops.c
|
||||||
COMMAND echo "*** Preparing umac source ***"
|
COMMAND echo "*** Preparing umac source ***"
|
||||||
COMMAND make -C ${UMAC_PATH} prepare
|
COMMAND make -C ${UMAC_PATH} prepare
|
||||||
|
|
@ -194,7 +213,7 @@ if (TARGET tinyusb_device)
|
||||||
add_custom_target(prepare_umac
|
add_custom_target(prepare_umac
|
||||||
DEPENDS ${UMAC_MUSASHI_PATH}/m68kops.c
|
DEPENDS ${UMAC_MUSASHI_PATH}/m68kops.c
|
||||||
)
|
)
|
||||||
add_dependencies(${FIRMWARE} prepare_umac)
|
add_dependencies(${FIRMWARE} prepare_umac prepare_rom prepare_disc)
|
||||||
|
|
||||||
target_link_libraries(${FIRMWARE}
|
target_link_libraries(${FIRMWARE}
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
|
|
@ -214,7 +233,7 @@ if (TARGET tinyusb_device)
|
||||||
${PICO_TINYUSB_PATH}/src
|
${PICO_TINYUSB_PATH}/src
|
||||||
${UMAC_INCLUDE_PATHS}
|
${UMAC_INCLUDE_PATHS}
|
||||||
${PIOUSB_PATH}/src
|
${PIOUSB_PATH}/src
|
||||||
incbin
|
${CMAKE_CURRENT_BINARY_DIR}/incbin
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
2
external/umac
vendored
2
external/umac
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit ce55830a1babd681d0e9a639c9b23f10cd9e3c96
|
Subproject commit 431e905354e975cd942eb4c1c5ea5a39237691ab
|
||||||
|
|
@ -1,21 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p incbin
|
set -xe
|
||||||
|
|
||||||
if ! [ -f rom.bin ]; then
|
if ! [ -f rom.bin ]; then
|
||||||
if ! [ -f '4D1F8172 - MacPlus v3.ROM' ]; then
|
curl -L 'https://ia902205.us.archive.org/view_archive.php?archive=/18/items/mac_rom_archive_-_as_of_8-19-2011/mac_rom_archive_-_as_of_8-19-2011.zip&file=4D1F8172%20-%20MacPlus%20v3.ROM' > rom.bin
|
||||||
curl -L 'https://ia902205.us.archive.org/view_archive.php?archive=/18/items/mac_rom_archive_-_as_of_8-19-2011/mac_rom_archive_-_as_of_8-19-2011.zip&file=4D1F8172%20-%20MacPlus%20v3.ROM' > '4D1F8172 - MacPlus v3.ROM'
|
|
||||||
fi
|
|
||||||
make -C external/umac clean
|
|
||||||
make -C external/umac DISP_WIDTH=512 DISP_HEIGHT=342
|
|
||||||
./external/umac/main -r '4D1F8172 - MacPlus v3.ROM' -W rom.bin
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
xxd -i < rom.bin > incbin/umac-rom.h
|
|
||||||
|
|
||||||
if ! [ -f umac0ro.img ]; then
|
if ! [ -f umac0ro.img ]; then
|
||||||
curl -L 'https://archive.org/download/apple-mac-os-system-3.2-finder-5.3-system-tools-1.0-512-ke-jun-1986-3.5-800k.-7z/Apple%20Mac%20OS%20%28System%203.2%20Finder%205.3%29%20%28System%20Tools%201.0%20Mac%20128%2C%20512K%29%20%28Jun%201986%29%20%283.5-400k%29.7z' > 'Apple Mac OS (System 3.2 Finder 5.3) (System Tools 1.1 Mac Plus) (Jun 1986) (3.5-800k).7z'
|
if ! [ -f os.7z ]; then
|
||||||
7z x -so 'Apple Mac OS (System 3.2 Finder 5.3) (System Tools 1.1 Mac Plus) (Jun 1986) (3.5-800k).7z' 'Apple Mac OS (System 3.2 Finder 5.3) (System Tools 1.0 Mac 128, 512K) (Jun 1986) (3.5-400k)/System Installation.img' > umac0ro.img
|
curl -L 'https://archive.org/download/apple-mac-os-system-3.2-finder-5.3-system-tools-1.0-512-ke-jun-1986-3.5-800k.-7z/Apple%20Mac%20OS%20%28System%203.2%20Finder%205.3%29%20%28System%20Tools%201.0%20Mac%20128%2C%20512K%29%20%28Jun%201986%29%20%283.5-400k%29.7z' > 'os.7z'
|
||||||
|
fi
|
||||||
|
7z x -so 'os.7z' 'Apple Mac OS (System 3.2 Finder 5.3) (System Tools 1.0 Mac 128, 512K) (Jun 1986) (3.5-400k)/System Installation.img' > umac0ro.img
|
||||||
fi
|
fi
|
||||||
|
|
||||||
xxd -i < umac0ro.img > incbin/umac-disc.h
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ set -e
|
||||||
DISP_WIDTH=512
|
DISP_WIDTH=512
|
||||||
DISP_HEIGHT=342
|
DISP_HEIGHT=342
|
||||||
MEMSIZE=400
|
MEMSIZE=400
|
||||||
DISK_IMAGE=""
|
DISC_IMAGE=
|
||||||
CMAKE_ARGS=""
|
CMAKE_ARGS=""
|
||||||
|
|
||||||
while getopts "hvd:m:" o; do
|
while getopts "hvd:m:" o; do
|
||||||
|
|
@ -24,14 +24,14 @@ while getopts "hvd:m:" o; do
|
||||||
MEMSIZE=$OPTARG
|
MEMSIZE=$OPTARG
|
||||||
;;
|
;;
|
||||||
(d)
|
(d)
|
||||||
DISK_IMAGE=$OPTARG
|
DISC_IMAGE=$OPTARG
|
||||||
;;
|
;;
|
||||||
(h|?)
|
(h|?)
|
||||||
echo "Usage: $0 [-v] [-m KiB] [-d diskimage]"
|
echo "Usage: $0 [-v] [-m KiB] [-d diskimage]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -v: Use framebuffer resolution 640x480 instead of 512x342"
|
echo " -v: Use framebuffer resolution 640x480 instead of 512x342"
|
||||||
echo " -m: Set memory size in KiB"
|
echo " -m: Set memory size in KiB"
|
||||||
echo " -d: Specify disk image to include"
|
echo " -d: Specify disc image to include"
|
||||||
echo ""
|
echo ""
|
||||||
echo "PSRAM is automatically set depending on memory & framebuffer details"
|
echo "PSRAM is automatically set depending on memory & framebuffer details"
|
||||||
exit
|
exit
|
||||||
|
|
@ -54,22 +54,14 @@ if [ "$MIRROR_FRAMEBUFFER" -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append disk name to build directory if disk image is specified
|
# Append disk name to build directory if disk image is specified
|
||||||
if [ -n "$DISK_IMAGE" ] && [ -f "$DISK_IMAGE" ]; then
|
if [ -n "$DISC_IMAGE" ] && [ -f "$DISC_IMAGE" ]; then
|
||||||
# Extract filename without extension
|
# Extract filename without extension
|
||||||
DISK_NAME=$(basename "$DISK_IMAGE" | sed 's/\.[^.]*$//')
|
DISC_IMAGE=$(basename "$DISC_IMAGE" | sed 's/\.[^.]*$//')
|
||||||
TAG=${TAG}_${DISK_NAME}
|
CMAKE_ARGS="$CMAKE_ARGS -DDISK_IMAGE=${DISC_IMAGE}"
|
||||||
|
TAG=${TAG}_${DISC_IMAGE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
make -C external/umac clean
|
|
||||||
make -C external/umac DISP_WIDTH=${DISP_WIDTH} DISP_HEIGHT=${DISP_HEIGHT} MEMSIZE=${MEMSIZE}
|
|
||||||
rm -f rom.bin
|
|
||||||
./external/umac/main -r '4D1F8172 - MacPlus v3.ROM' -W rom.bin || true
|
|
||||||
[ -f rom.bin ]
|
|
||||||
xxd -i < rom.bin > incbin/umac-rom.h
|
|
||||||
if [ -n "$DISK_IMAGE" ] && [ -f "$DISK_IMAGE" ]; then
|
|
||||||
xxd -i < "$DISK_IMAGE" > incbin/umac-disc.h
|
|
||||||
fi
|
|
||||||
rm -rf build_${TAG}
|
rm -rf build_${TAG}
|
||||||
cmake -S . -B build_${TAG} \
|
cmake -S . -B build_${TAG} \
|
||||||
-DPICO_SDK_PATH=../pico-sdk \
|
-DPICO_SDK_PATH=../pico-sdk \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue