Don't know about 4k but if you can settle for 64kb then my game engine "ZGameEditor" is written in Delphi/Freepascal and is open source.

Also Benjamin "BeRo" makes extremely impressive demo-tools (compressor, musicplayer etc) in Pascal. Some with source included.