why not open...fopen.....load "test.bin" with asm..???

Amstrad CPC and NC systems
Post Reply
funkheld
New member
Posts: 5
Joined: Thu Dec 10, 2009 1:03 pm

why not open...fopen.....load "test.bin" with asm..???

Post by funkheld »

i'am german..
why not...#inlcude <fcntl.h> loop with cpc6128 ??:(

cpc nix open, nix creat, nix read...

not funktion with cpc...

gruss

Code: Select all

open(far char *name, int flags, mode_t mode);
creat(far char *name, mode_t mode);
close(int fd);
read(int fd, void *ptr, size_t len);
write(int fd, void *ptr, size_t len);
lseek(int fd,long posn, int whence);
....
Last edited by funkheld on Thu Dec 10, 2009 8:44 pm, edited 1 time in total.
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Duh.. I don't remember, have to check.. they do work in CP/M mode anyway, right ?
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

What about the following:
http://www.z88dk.org/wiki/doku.php?id=p ... cpc_target
see "additional functions".. don't they work with CPC 6128 ?

I also remember that there should be a nice trick to directly make the pipe (|) calls activating the BIOS extensions with z88dk... interested ?
funkheld
New member
Posts: 5
Joined: Thu Dec 10, 2009 1:03 pm

Post by funkheld »

no, not cpm i'm with amsdos.

with #include <stdio.h> i'm not loop....why...?:(

Code: Select all

*fopen(far char *name, unsigned char *mode);
*fgets(unsigned char *s, int, FILE *fp);
fputs(unsigned char *s,  FILE *fp);
fputc(int c, FILE *fp);
fgetc(FILE *fp);
ungetc(int c, FILE *);
feof(FILE *fp);
puts(unsigned char *);
funkheld
New member
Posts: 5
Joined: Thu Dec 10, 2009 1:03 pm

Post by funkheld »

You for mi i'm programm with loop to cpc6128?:):)

open...
readbyte,writebyte ..?

don't they work with CPC 6128 ? not works..

calls activating the BIOS extensions with z88dk... interested ?
yes...:) yes...:)


can you one funktional demo for the cpc6128?:)

gruss
Last edited by funkheld on Thu Dec 10, 2009 9:10 pm, edited 1 time in total.
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

When I read the firmware docs it looked like you could only have one file open for reading and one file for writing at any point in time (using the cas_ interface).

Fitting these into the fcntl interface seemed a bit fiddly and limiting so I just left as fopen/fclose.

If there's another interface into AMSDOS which supports more files being open then the fnctl routines could be written to use those instead.
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

As usual Dom has to correct me :)
Well, yes I wrongly remembered to have added almost all the missing fcntl stuff.
And the trick I talked about for the 'BAR' commands never saw the light as a C interface and is still only in assembler.
A good example is the 'rename' call:
http://z88dk.cvs.sourceforge.net/viewvc ... iew=markup

Now, since writebyte and readbyte commands do exist, shouldn't it be just necessary to make the CPC CAS stream device to point to the disk device or similar ? I vaguely remeber it so I might be totally wrong.

Anyway, there's surely space for improvements.. what do you prefer us to begin with ? ;)

P.S.
You're including the 'cpcfs' lib, aren't you ?
funkheld
New member
Posts: 5
Joined: Thu Dec 10, 2009 1:03 pm

Post by funkheld »

why go this z88dk ?? :

tanks.

Code: Select all

CAS_IN_OPEN equ &BC77
CAS_IN_DIRECT equ &BC83
CAS_IN_CLOSE equ &BC7A

ld b, dateinameende-dateiname ;Laenge des Dateinamens in Bytes
ld hl,dateiname
ld de, &8000 ;2k Speicherplatz fuer Dateipuffer
call CAS_IN_OPEN

;Rueckgabe von CAS_IN_OPEN:
;Wenn alles ok, dann
; - carry ist gesetzt
; - HL zeigt auf die Adresse mit dem AMSDOS Header
; - DE enthaelt die Speicheradresse der Datei (aus dem AMSDOS Header)
; - BC enthaelt die Dateigroesse
; - A enthaelt den Dateityp (2 fuer Binaerdateien)

;Datei komplett laden
ld hl, &C000 ;Zieladresse fuer die Datei (hier Bildschirmspeicher)
call CAS_IN_DIRECT

;Datei geladen, also kann sie jetzt geschlossen werden
call CAS_IN_CLOSE

ret

dateiname:
db "test.bin"
dateinameende:
funkheld
New member
Posts: 5
Joined: Thu Dec 10, 2009 1:03 pm

Post by funkheld »

You're including the 'cpcfs' lib, aren't you ?
yes !
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Beginning in the right way.. first of all the CPC definitions are already in "{z88dk}/lib/cpcfirm.def".
CAS_IN_OPEN and CAS_IN_CLOSE are here:
http://z88dk.cvs.sourceforge.net/viewvc ... iew=markup
http://z88dk.cvs.sourceforge.net/viewvc ... iew=markup

The filename can already be passed as a parameter.
CAS_IN_DIRECT can probably be called in the middle of your C program as follows:
#asm
INCLUDE "#cpcfirm.def";Datei komplett laden
ld hl, &C000 ;Zieladresse fuer die Datei (hier Bildschirmspeicher)
call cas_in_direct
#endasm
Post Reply