Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: print to memory?

by athomason (Curate)
on Sep 10, 2000 at 00:06 UTC ( #31768=note: print w/ replies, xml ) Need Help??


in reply to print to memory?

...writing TNT2 opengl drivers in perl.

Whoa! That's a strange undertaking. I hope it's only an academic exercise. In any case, accessing raw memory is largely what Perl is designed to shield you from. So as far as core Perl is concerned, you can't do that (and shouldn't be able to). A quick search didn't turn up an existing module to do this, but you could write a small XS extension (a Perl module written in C) which had routines to read to and write from specific memory locations, and then just call those in your program. Keep in mind this would most likely be insanely slow. But perhaps you could accelerate Commander Keen :-).

As far as the printing goes, you might not be far off. Provided your /dev/lp0 is configured to correctly handle raw text dumped to it, you should be able to use what you have if you make the handle writable (open(PRINTER,'>>/dev/lp0')) before printing to it. You may need to figure out how to send a page-feed, though, or just press the button yourself on the printer.


Comment on Re: print to memory?
Select or Download Code
RE: Re: print to memory?
by Rydor (Scribe) on Sep 10, 2000 at 02:00 UTC
    i was hoping something like the printer thing would work, and i think i couldn't spend my time more productively than accelerating commander keen. That game rocks!! seriously, it was the game that got me interested in computer games. I owe it my life (or perhaps it owes me my life back... i'll have to think about that) I wonder if there is commander keen for linux.......

    @:::::::((==========Rydor====>
RE: Re: print to memory?
by spudzeppelin (Pilgrim) on Sep 10, 2000 at 19:11 UTC

    Generally, \x0c (that's ctrl-L or ^L) is a page-feed to most printers.

    I've written ofs in perl for the lpd before, it's not a difficult task :) However, I'd strongly recommend using the lpd (or at least, one of the new non-spooling print programs, such as pdq) rather than trying to write raw text to the hardware device.

    Spud Zeppelin * spud@spudzeppelin.com

      In Perl (and usually "C") string handling you can use "\f" for the formfeeds. As long as you are playing with teletype commands, you should remember that one.

      • \t ab
      • \n ewline
      • \r eturn
      • \f ormfeed
      • \b ackspace
      • \a larm
      • \e scape (also handy but a perl only idiom AFAIK)

      --
      $you = new YOU;
      honk() if $you->love(perl)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://31768]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-08-21 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls