Re: [hatari-devel] Problem with printer output?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On perjantai 03 helmikuu 2012, Matthias Arndt wrote:
> > This works fine for TOS v1.00, v3.06, v4.04
> > and EmuTOS.
> > 
> > However, Hatari creates no printer output file
> > when same test program is run within TOS versions
> > v1.02 - v2.06.
> 
> I can't remember on which TOSes I tested the output back then.
> For the moment I cannot confirm v2.06. It works here for TOS v2.06 with
> my standard Satandisk config. 
>
> I only clicked on "Print" on the desktop for NEWDESK.INF

Ah, that's a good test.

If I use TOS "Print screen" option after running MINIMAL.PRG,
then I get "printer-out" file, which grows very slowly, 4KB
at the time.


When looking at the code, printer.c has a minor issue
compared to midi.c:
* It buffers the output for 2kB which is flushed at every VBL
  and when Hatari is exited normally.
* However, it doesn't tell C-library to disable buffering, so
  writes will be buffered also in the C-library, for whatever
  amount is the optimal size for the filesystem.  In my case
  that's apparently 4kB.

-> The code should either let C-library do the buffering
   (i.e. data will be flushed automatically at fclose(),
   or disable C-library buffering.


And the init code is peculiar:
---------
        if (strlen(ConfigureParams.Printer.szPrintToFileName) <= 1)
        {
                const char *psHomeDir;
                psHomeDir = Paths_GetHatariHome();

                /* construct filename for printing.... */
                if (strlen(psHomeDir)+1+strlen(PRINTER_FILENAME) < 
sizeof(ConfigureParams.Printer.szPrintToFileName))
---------

I.e. user can use a filename with one letter or one that's longer
than home+hatari.prn.   E.g. /tmp/print.out isn't tolerated.


However, these don't explain why the file isn't even opened with
TOS versions v1.02 - v2.06.

On assumption that they do some internal buffering, I replaced
the TEXT file with Hatari's "video.c" (144kB), but that didn't
help anything.  There's still no printer-out file with TOS v2.


Then I tried Gdb.

In TOS v2, running MINIMAL.PRG didn't result in any
Printer_TransferByteTo() calls, but "Print screen" did.


On the listed working TOS versions, MINIMAL.PRG running results
in Printer_TransferByteTo() calls though.

When I printed in psg.c, the PORTA value, during the printing...

In TOS v3 & v4, I get:
PSG_REG_IO_PORTA=0x27
PSG_REG_IO_PORTA=0x7
PSG_REG_IO_PORTA=0x7
PSG_REG_IO_PORTA=0x27
PSG_REG_IO_PORTA=0x7
PSG_REG_IO_PORTA=0x7
PSG_REG_IO_PORTA=0x27

In TOS v1.00, I get:
PSG_REG_IO_PORTA=0x25
PSG_REG_IO_PORTA=0x5
PSG_REG_IO_PORTA=0x5
PSG_REG_IO_PORTA=0x25
PSG_REG_IO_PORTA=0x5
PSG_REG_IO_PORTA=0x5
PSG_REG_IO_PORTA=0x25

However, in TOS v1.04 - v2.06 I get this with MINIMAL.PRG[1]:
PSG_REG_IO_PORTA=0x25
PSG_REG_IO_PORTA=0x27
PSG_REG_IO_PORTA=0x23
PSG_REG_IO_PORTA=0x27
PSG_REG_IO_PORTA=0x25
PSG_REG_IO_PORTA=0x27
PSG_REG_IO_PORTA=0x23
PSG_REG_IO_PORTA=0x27

I.e. the bits 0x4 and 0x2 are being toggled, although the code checks
for bit 0x20 being toggled:
-------------
                if (ConfigureParams.Printer.bEnablePrinting)                                                                                                         
                {                                                                                                                                                    
                        /* Bit 5 - Centronics strobe? If STROBE is low and 
the LastStrobe was high,                                                                  
                                        then print/transfer to the emulated 
Centronics port.                                                                         
                         */                                                                                                                                          
                        if (LastStrobe && ( 
(PSGRegisters[PSG_REG_IO_PORTA]&(1<<5)) == 0 ))                                                                          
                        {                                                                                                                                            
                                /* Seems like we want to print something... 
*/                                                                                       
                                Printer_TransferByteTo(PSGRegisters[PSG_REG_IO_PORTB]); 
-------------


[1] TOS Print screen gives same PORTA output as I get for Fwrites
to PRN: in the working TOS versions. 


Any idea what's wrong?


	- Eero




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/