int nropen(char *name, int flags, mode_t mode, char *buf, size_t len) { #asm INCLUDE "fileio.def" ld ix,0 add ix,sp ld l,(ix+10) ;lower 16 of filename ld h,(ix+11) ld b,0 ld a,(ix+8) ;access flags ld c,(ix+9) ;top 8 of flags bit 0,c ;append! jr z,l_open1 ld a,2 ;OZ append mode-1 .l_open1 inc a ;convert from UNIX mode to OZ flags ld e,(ix+4) ;buf ld d,(ix+5) ld c,(ix+2) ;maximum length of expanded filename call_oz(gn_opf) ld hl,-1 ret c ;open error push ix ;get filedescriptor in ix into hl pop hl #endasm }
int parseseg(far char *seg, far char **end) { /* NB far char * is 3 bytes, far char ** is two */ #asm INCLUDE "#fileio.def" ld ix,0 add ix,sp ld l,(ix+4) ;seg ld h,(ix+5) ld b,(ix+6) call_oz(gn_pfs) ld hl,-1 ret c ex af,af ;keep it safe ex de,hl ld l,(ix+2) ;**end (i.e. address of &end) ld h,(ix+3) ld a,l or l jr z,getout ld (hl),e ;keep end inc hl ld (hl),d inc hl ld (hl),b .getout ex af,af ;get it back ld l,a ld h,0 #endasm }
void nameapp(const char *name) { #asm INCLUDE "director.def" pop bc pop hl push hl push bc call_oz(dc_nam) ;preserves ix #endasm }
void sleep(int secs) { #ifndef __Z88__ long start = clock(); long per = secs * CLOCKS_PER_SEC; #ifdef __ZX80__ gen_tv_field_init(0); #endif while ( (clock() - start) < per ) #ifdef __ZX80__ { gen_tv_field(); FRAMES++; } #else ; #endif #else #asm INCLUDE "time.def" EXTERN l_mult EXTERN l_div_u ex de,hl ; __FASTCALL__ put number of seconds in HL ld hl,100 call l_mult ld c,l ld b,h call_oz(os_dly) ld hl,0 ret nc ;NULL - normal ; Now found out how long is left to sleep for.. ld e,c ld d,b ld hl,100 call l_div_u ld c,l ld b,h #endasm #endif }
int brotherdor(int handle, char *type) { #asm INCLUDE "dor.def" pop de pop ix push ix push de ld a,dr_sib call_oz(os_dor) pop de pop hl ld (hl),a ;store minor type push hl push de push ix pop hl ;return SON dor #endasm }
/* * Name a z88 application */ #include <z88.h> void nameapp(char *name) { #asm INCLUDE "director.def" pop bc pop hl push hl push bc call_oz(dc_nam) #endasm }
/* * Close a DOR * * void deletedor(int handle) * * djm 13/3/2000 * * ----- * $Id: deletedor.c,v 1.2 2001/04/18 14:59:40 stefano Exp $ */ #include <z88.h> void deletedor(int handle) { #asm INCLUDE "#dor.def" pop de pop ix push ix push de ld a,DR_Del call_oz(os_dor) #endasm }