One of the main reasons for using Y-MODEM (or X-MODEM) is that it is supported by just about every terminal application or serial comms library around - so it's very rare that you actually need to implement it yourself!
However, if you really do need to implement it yourself, it's not difficult - see:
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.