The uncompressed string (with # replaced with \n for clarity) is:
!!!-. ! |:! |:!-' !!!
!!!~.--------. !~| |:!~| |:!~'--------' !!!
!!!~~~~~~~~~~.--------.!~~~~~~~~~~| |!~~~~~~~~~~| |!~~~~~~~~~~'--------'!!!
!!-------. ! | '.! | |! | |! | .'!-------' !!
!!~~~~~~~.--------------.!~~~~~~~| |!~~~~~~~| |!~~~~~~~| |!~~~~~~~| |!~~~~~~~'--------------'!!
__ ! |'. ! | '.! | |! | |! | |! | |! | .'!__|.' !
~~ ________________________ !~~| |!~~| |!~~| |!~~| |!~~| |!~~| |!~~| |!~~|________________________|!
'. ! |! |! |! |! |! |! |! |!.'
This encodes the left-side versions of the different screen components with ! instead of newlines, and ~ instead of ?, which are then right-padded with ~ to 30 characters before having themselves and their line-reversals added to a lookup list.
The rest of the code simply handles coordinate lookup with out-of-bounds cases ignored.