This is the module which i wrote for Xipe (my custom HD44780 display app). It has a dependency: dlportio from scientific software which lets you read and write directly to an address (the parallel port), and it assumes that you have your LCD wired up in "winamp" style wiring.
It won't work for your 40x4 LCD without modifications, you have to set one of the Parport pins high to alternate between the two HD44780 controllers on your LCD.
It's ported from Markus's Winamp LCD plugin, so it's a derivative work and hence falls under GPL.
How to use it:
You can create custom chars as well, just put in ascii characters 0 to 7 in the string.
Custom chars are created like this:
LCD_CreateCustomChar(Char number between 0 to 7, strChar)
strChar is a comma delimited set of 8 numbers (one for each line), with the least significant 5 bits representing the cell row data.
You may need to change:
depending on how fast your CPU is and how fast your HD44780 controllers read, so you don't write to the device faster than it can grab the data.