4 ; This function reads the directory entry for file "name".
6 ; The name is actually plain ASCII string starting from
7 ; "0", "1", up to "4095" which is the largest file number we can handle.
9 ; open() does not take part in what kind of cart we have. If it is RAM
10 ; you may also be able to write into it. Therefore we allow both reads
11 ; and writes in this routine.
13 ; int open(const char *name, int flags, ...)
15 ; As helper functions we also provide.
16 ; void openn(int fileno)
23 .import addysp,popax,pushax,decsp6,pusha0,pusheax,ldaxysp
24 .import aslax3,axlong,tosaddeax,steaxysp,stax0sp,incsp8
26 .import lynxskip0, lynxblock
28 .importzp _FileStartBlock
29 .importzp _FileCurrBlock
30 .importzp _FileBlockOffset
31 .import __STARTOFDIRECTORY__
41 .dword __STARTOFDIRECTORY__
43 ; ---------------------------------------------------------------
44 ; int __near__ open (__near__ const unsigned char*, int)
45 ; ---------------------------------------------------------------
62 and #(O_RDWR | O_CREAT)
65 cmp #(O_WRONLY | O_CREAT)
82 ; ---------------------------------------------------------------
83 ; void __near__ __fastcall__ openn (int)
84 ; ---------------------------------------------------------------
96 lda _startofdirectory+3
98 lda _startofdirectory+2
100 ldx _startofdirectory+1
101 lda _startofdirectory
126 ldx _FileBlockOffset+1
127 phx ; The BLL kit uses negative offsets
128 plx ; while tha basic Lynx uses positive
129 bmi @1 ; Make all offsets negative