Page 1 of 1
why not open...fopen.....load "test.bin" with asm..???
Posted: Thu Dec 10, 2009 1:37 pm
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);
....
Posted: Thu Dec 10, 2009 8:51 pm
by stefano
Duh.. I don't remember, have to check.. they do work in CP/M mode anyway, right ?
Posted: Thu Dec 10, 2009 8:56 pm
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 ?
Posted: Thu Dec 10, 2009 8:57 pm
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 *);
Posted: Thu Dec 10, 2009 9:02 pm
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
Posted: Fri Dec 11, 2009 9:39 am
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.
Posted: Mon Dec 14, 2009 8:39 pm
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 ?
Posted: Tue Dec 15, 2009 1:28 pm
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:
Posted: Tue Dec 15, 2009 1:29 pm
by funkheld
You're including the 'cpcfs' lib, aren't you ?
yes !
Posted: Thu Dec 17, 2009 6:43 pm
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