That code you posted immediately struck me as wrong--not real C64 code. It took me a minute to realize why: it's in lowercase.
(The C64 defaulted to a character set with only capital letters, to leave more space for graphical characters. There was a mixed-case set available, but no one ever used it except for word processing and text adventures.)