How to read directory and immediately output to printer?

Started by MIRKOSOFT, July 11, 2010, 06:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!

I want to read directory and through this output readed data to printer...

My code works not, this I didn't ever before, so I don't know if is something right.

Here's source:


.pc=$2000 "dir to printer"

start:
lda #4 // open file #4 device #4
ldx #4
ldy #0
jsr setlfs
lda #00
jsr setnam
jsr open
ldx #$04 // set as output
jsr ckout

lda #1 // open file #1 device #8 name $
ldx #<dirnam
ldy #>dirnam
jsr setnam
lda #1
ldx device
ldy #0
jsr setlfs
jsr open
ldx #$01 // set as input
jsr chkin

lda #8 // set device #8 as input
jsr listn
lda #4 // set device #4 as output
jsr talk

jsr getin // getin data
jsr getin
jsr getin
ragain:
jsr getin
jsr getin
pha
jsr getin
tay
pla
tax
tya
jsr bsout // not solved block size output
back: jsr getin
jsr bsout // output data
cmp #00
bne back
lda #$0d
jsr bsout
jsr getin
cmp #00
bne ragain
jsr clrch
lda #1 // close file #1
jsr close
lda #4 // close file #4
jsr close
rts

dirnam:
.text "$"

device:
.byte 8


Thanks for every help.

Miro

MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

gsteemso

Why not just do this the usual way and use the normal BASIC snippet?

(from memory, may be slightly inaccurate):

10 OPEN 4,4 : REM OPEN FILE TO PRINTER
20 CMD 4 : REM REDIRECT OUTPUT TO FILE #4
30 LOAD "$",8 : LIST : REM GET/LIST DIRECTORY
The world's only gsteemso

MIRKOSOFT

No no no!


I know how to do it in basic! It's about assembly programming...
I'm sorry, but your answer was not useful for me....
In BASIC it is simple and it goes also easier than you wrote...


Also thanks for patience.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

MIRKOSOFT

So, if I'm looking of BASIC program:


I don't want to read whole directory at once.
I want to read directory entries step-by- step and values send to printer.


It is easy to load (or dir to mem) and after output to printer, I need it:


Load byte from device #8
Send byte to printer
then again load...


Can anybody help me?


Many thanks.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

LokalHorst

Hi Mirko,
Directory again eh,

this part of your code looks wrong:
lda #8      // set device #8 as input
jsr listn
lda #4      // set device #4 as output
jsr talk

as you already did it with CHKIN/CHKOUT at the beginning.
This way you confuse the Kernal file-handling.
If you remove the above and add a final print $0d to flush the print buffer before closing files, it should work as expected.

wte

I'm not sure if I remember correctly but I fear it is not possible to use CHKIN and CKOUT at the same time on the IEC bus (it worked on the IEEE488 bus of the CBM computers and it works if the output is via centronics emulation on the user port but not with two real IEC devices - what a pitty! Shame on Commodore!).

Using one of the pair (CHKIN/CKOUT) kills the other channel. You have to send CHKIN/CKOUT for every byte you read/write (that is horrible).

There should be an other solution. It is possible (don't ask me how to do that) to make the floppy the talker and the printer the listener. Both devices will work on the IEC bus and the C128 (64) is free to do other things (but naturally not to use the IEC bus).

Regards WTE