# Apply all appropriate patches to the V3D Distribution rk05 image
# to create a new image that is the basis for our boot image.

copy $os8mo/v3d-dist.rk05 $os8mo/v3d-patched.rk05
mount rk0 $os8mo/v3d-patched.rk05 required

boot rk0

# Most of these patches have been verified
# by reading the source code.
# The patches that remain commented out are not recommended
# and the reason why appears in the line above it.
#
# ABSLDR-21.29.1M is against v6A but we have v4A.
# v6A came with OS/8 Devices Extension kit QF026
# Binary DECtape: AL-H525A-BA, Source not on DECtape
# DO NOT APPLY THIS PATCH.
## ABSLDR-21.29.1M-v6C.patch8
patch $src/patches/os8/v3d/BASIC.UF-31.5.1M-V5B.patch8
patch $src/patches/os8/v3d/BATCH-31.23.1M-v7B.patch8
patch $src/patches/os8/v3d/BLOAD-31.10.1M-v5B.patch8
patch $src/patches/os8/v3d/BRTS-31.11.1M-v5B.patch8
# patch $src/patches/os8/v3d/BRTS 31.11.2O disables 8th bit parity. Recommended.
patch $src/patches/os8/v3d/BRTS-31.11.2-O.patch8
# patch $src/patches/os8/v3d/BRTS 31.11.3O enables 132 column output. Recommended.
patch $src/patches/os8/v3d/BRTS-31.11.3-O.patch8
patch $src/patches/os8/v3d/BRTS-31.11.5-x.patch8
patch $src/patches/os8/v3d/CREF-21.15.1M-v5B.patch8
patch $src/patches/os8/v3d/CREF-21.15.2M-v5C.patch8
patch $src/patches/os8/v3d/EDIT-21.17.1M-v12B.patch8
patch $src/patches/os8/v3d/EDIT-21.17.2M-v12C.patch8
patch $src/patches/os8/v3d/EDIT-21.17.3M-v12D.patch8
# patch $src/patches/os8/v3d/EDIT 21.17.4 overwrites patch in 21.17.2. DO NOT APPLY THIS PATCH
# patch $src/patches/os8/v3d/EDIT-21.17.4M-V12C.patch8

begin default fortran-iv
patch $src/patches/os8/v3d/F4-21.1.2M-v4B.patch8
patch $src/patches/os8/v3d/F4-51.3.1M-v4C.patch8
patch $src/patches/os8/v3d/F4-51.3.2M-v4x.patch8
# FRTS-51.3.3-O is to enable FRTS to work with 2-page system
# handlers.  I've read the code but do not fully understand it.
# It is plausable that it generalizes on the code that makes
# the 2-page TD8E handler work.  But it could also be a
# patch tha tONLY works with the OS/8 Devices Extension kit QF026.
# We are enabling the patch for not.  If further testing shows
# that it breaks TD8E support, we will turn it off.
patch $src/patches/os8/v3d/FRTS-51.3.3-O.patch8

# FORLIB.RL is also patched.
# FORLIB 51.10.1M creates a new FORLIB.RL with a patch
# applied to DLOG.RA.
# The source tree contains a FORLIB.RL made with instructions from the patch.
# So the patch will not apply but is listed here for completeness.
# We could build a forlib-patch.tu56 image from source now if we chose
# For now we'll just copy in the hand-built binary.
## FORLIB-51.10.1M.patch8
os8 DEL SYS:FORLIB.RL
cpto $src/src/os8/v3d/LANGUAGE/FORTRAN4/FORLIB.RL SYS:FORLIB.RL /I

end default fortran-iv

patch $src/patches/os8/v3d/FOTP-21.19.1M-V9B.patch8

# MACREL is enabled by default with no settings.
# We need to avoid patching FUTIL in that default case
# So we have to set a disablement of that action
# Conditional on macrel default as well.

begin default macrel
disable futil_patch
end default macrel

begin default futil_patch
# The two FUTIL patches only get applied to FUTIL V7 which comes with
# OS/8 V3D to bring it up to V7D.
# MACREL V2 comes with FUTIL V8B, so these patches are skipped 
# unless the user passes --disable-os8-macrel to configure.
patch $src/patches/os8/v3d/FUTIL-31.21.1M-v7B.patch8
patch $src/patches/os8/v3d/FUTIL-31.21.2M-v7D.patch8
# patch $src/patches/os8/v3d/FUTIL 31.21.3O switches XS format. Recommend to leave it out.
# patch $src/patches/os8/v3d/FUTIL-31.21.3O.patch8
end default futil_patch

# LQP 21.49.1 consists of commands run in BUILD.
# The auto-apply system won't apply it.
# It has not been validated. It uses hardware we don't have.
## patch $src/patches/os8/v3d/LQP-21.49.1M-vB.patch8
patch $src/patches/os8/v3d/MCPIP-21.21M-v6B.patch8
patch $src/patches/os8/v3d/MSBAT-31.22.1M-v3B.patch8
patch $src/patches/os8/v3d/PAL8-21.22.1M-v10B.patch8
patch $src/patches/os8/v3d/PAL8-21.22.2M-v10C.patch8
patch $src/patches/os8/v3d/PAL8-21.22.3M-v10D.patch8
# PAL8 21.22.4M is for V12 PAL8. It BREAKS LS output in V10!
# DO NOT APPLY THIS PATCH!
# patch $src/patches/os8/v3d/PAL8-21.22.4M.patch8
patch $src/patches/os8/v3d/PIP-21.23.1M-v12B.patch8
patch $src/patches/os8/v3d/PIP10-21.24.1M-v3B.patch8

# We need SABR for C compiler. Patch it unconditionally.
# begin default fortran-ii
patch $src/patches/os8/v3d/SABR-21.91.1M-v18B.patch8
# end default fortran-ii

patch $src/patches/os8/v3d/SET-21.26.1M-v1C.patch8
patch $src/patches/os8/v3d/SET-21.26.2M-v1D.patch8
patch $src/patches/os8/v3d/SET-21.26.3M-v1E.patch8
# patch $src/patches/os8/v3d/TECO 31.20.1 Unconditional no case flagging. Not recommended
# patch $src/patches/os8/v3d/TECO-31.20.01O.patch8
# patch $src/patches/os8/v3d/TECO 31.20.2 Turns off verbose errors. Not recommended.
# patch $src/patches/os8/v3d/TECO-31.20.02O.patch8
# patch $src/patches/os8/v3d/TECO 31.20.3 Turns off Yank overwrite warning. Not recommended.
# patch $src/patches/os8/v3d/TECO-31.20.03O.patch8
# patch $src/patches/os8/v3d/TECO 31.20.4 Special support for VT05. Not recommended.
# patch $src/patches/os8/v3d/TECO-31.20.04O.patch8
patch $src/patches/os8/v3d/TECO-31.20.05M-v5A.patch8
patch $src/patches/os8/v3d/TECO-31.20.06M-v5B.patch8
patch $src/patches/os8/v3d/TECO-31.20.07M.v5C.patch8
patch $src/patches/os8/v3d/TECO-31.20.08M-v5.04.patch8
patch $src/patches/os8/v3d/TECO-31.20.10M-v5.05.patch8
patch $src/patches/os8/v3d/TECO-31.20.11M-v5.06.patch8
patch $src/patches/os8/v3d/TECO-31.20.12M-v5.07.patch8
patch $src/patches/os8/v3d/TECO-31.20.13M-v5.08.patch8
#
# MACREL, LINK, and OVDRV patches have not been validated.
# The Version numbers don't all match. Some won't apply.
# More work is needed before they are deemed safe.
# NOT Recommended.
## MACREL-40.5.1M-v1D.patch8
## MACREL-40.5.2M-v1E.patch8
## LINK-40.2.1M-v1D.patch8
## LINK-40.2.2M-v1E.patch8
## LINK-40.2.3M-v1F.patch8
# OVRDRV 40.6.1 is a source level patch
## OVRDRV-40.6.1M-v1B-8srccom

# Squish our device as our last step!

os8 SQUISH DSK:/O
os8 SQUISH SYS:/O
