missing fd_management and cleaning

This commit is contained in:
jede 2022-04-24 00:39:04 +02:00
parent 451acb3423
commit c48df98145
4 changed files with 59 additions and 50 deletions

View File

@ -1,7 +1,7 @@
;
; Oric TELEMON definition
; TELEMON 2.4 & TELEMON 3.x
; For TELEMON 3.x check http://orix.oric.org
; TELEMON 2.4 & Orix
; For TOrix check http://orix.oric.org
;
; ---------------------------------------------------------------------------
@ -59,7 +59,7 @@ SCRNB := $28 ; Id of the current window
ADKBD := $2A ; Address ASCII conversion table
PTR_READ_DEST := $2C ; Used for XFREAD and XWRITE only in TELEMON 3.x
PTR_READ_DEST := $2C ; Used for XFREAD and XWRITE only in Orix
ADCLK := $40 ; Address for clock display
TIMEUS := $42
@ -249,10 +249,10 @@ XHIRES = $1A
XEFFHI = $1B ; Clear hires screen
XFILLM = $1C
XMINMA = $1F
XVARS = $24 ; Only in TELEMON 3.x, in TELEMON 2.4, it's XNOMFI ($24)
XVARS = $24 ; Only in Orix, in TELEMON 2.4, it's XNOMFI ($24)
XCRLF = $25 ; Jump a line and return to the beginning of the line
XDECAY = $26
XFREAD = $27 ; Only in TELEMON 3.x (bank 7 of Orix)
XFREAD = $27 ; Only in Orix
XBINDX = $28 ; Convert a number into hex and displays on channel 0
XDECIM = $29
XHEXA = $2A ; Convert a number into hex
@ -261,7 +261,7 @@ XEDT = $2D ; Launch editor
XINSER = $2E
XSCELG = $2F ; Search a line in editor mode
XOPEN = $30 ; Only in TELEMON 3.x (bank 7 of Orix)
XOPEN = $30 ; Only in Orix
XECRPR = $33 ; Displays prompt
XCOSCR = $34 ; Switch off cursor
XCSSCR = $35 ; Switch on cursor
@ -269,8 +269,8 @@ XSCRSE = $36
XSCROH = $37 ; Scroll up text screen
XSCROB = $38 ; Scroll down text screen
XSCRNE = $39 ; Load charset from rom to ram
XCLOSE = $3A ; Only in TELEMON 3.x close file (bank 7 of Orix)
XFWRITE = $3B ; Only in TELEMON 3.x write file (bank 7 of Orix)
XCLOSE = $3A ; Only in Orix close file
XFWRITE = $3B ; Only in Orix write file
; Clock primitive
XRECLK = $3C ; Reset clock
@ -291,14 +291,14 @@ XGETCWD = $48 ; Get current CWD
XPUTCWD = $49 ; Chdir
; File management
XMKDIR = $4B ; Create a folder. Only available in TELEMON 3.x (bank 7 of Orix)
XMKDIR = $4B ; Create a folder. Only available in Orix
XHCHRS = $4C ; Hard copy hires
; File management
XRM = $4D ; Remove a folder or a file. Only available in TELEMON 3.x (bank 7 of Orix)
XRM = $4D ; Remove a folder or a file. Only available in Orix
XFWR = $4E ; Put a char on the first screen. Only available in TELEMON 3.x (bank 7 of Orix)
XFWR = $4E ; Put a char on the first screen. Only available in Orix
; Keyboard primitives
XALLKB = $50 ; Read Keyboard, and populate KBDCOL
@ -314,7 +314,7 @@ XINIBU = $58 ; Initialize the buffer X
XDEFBU = $59 ; Reset all value of the buffer
XBUSY = $5A ; Test if the buffer is empty
XMALLOC = $5B ; Only in TELEMON 3.x (bank 7 of Orix)
XMALLOC = $5B ; Only in Orix
; RS232 primitives
XSDUMP = $5C ; RS232 input dump
@ -326,7 +326,9 @@ XSSAVE = $5F ; Write a file to RS232
XMLOAD = $60 ; Read a file from Minitel
XMSAVE = $61 ; Write a file to Minitel
XFREE = $62 ; Only in TELEMON 3.x (bank 7 of Orix)
XFREE = $62 ; Only in Orix
XEXEC = $63 ; Only in Orix
; Next Minitel primitives
XWCXFI = $63 ; Wait connection
@ -334,7 +336,7 @@ XLIGNE = $64 ;
XDECON = $65 ; Minitel disconnection
XMOUT = $66 ; Send a byte to minitel (from A)
XSOUT = $67 ; Send accumulator value (A) to RS232, available in TELEMON 2.4 & 3.x : if RS232 buffer is full, the Oric Telestrat freezes
XSOUT = $67 ; Send accumulator value (A) to RS232, available in TELEMON 2.4 : if RS232 buffer is full, the Oric Telestrat freezes
XHRSSE = $8C ; Set hires position cursor
XDRAWA = $8D ; Draw a line absolute

View File

@ -1,16 +1,16 @@
; jede jede@oric.org 2017-01-22
.export _close
.export _close
.import addysp,popax
.import addysp,popax
.include "zeropage.inc"
.include "telestrat.inc"
.include "errno.inc"
.include "fcntl.inc"
.include "zeropage.inc"
.include "telestrat.inc"
.include "errno.inc"
.include "fcntl.inc"
; int open (const char* name, int flags, ...); /* May take a mode argument */
; int __fastcall__ close (int fd);
.proc _close
BRK_TELEMON XCLOSE ; launch primitive ROM
rts
BRK_TELEMON XCLOSE ; Launch primitive ROM
rts
.endproc

View File

@ -2,38 +2,41 @@
; jede jede@oric.org 2017-01-22
;
.export _read
.export _read
.import popax
.import popax
.include "zeropage.inc"
.include "telestrat.inc"
.include "zeropage.inc"
.include "telestrat.inc"
;int read (int fd, void* buf, unsigned count);
.proc _read
sta ptr1 ; Count
stx ptr1+1 ; Count
jsr popax ; Get buf
sta ptr1 ; count
stx ptr1+1 ; count
jsr popax ; get buf
sta PTR_READ_DEST
stx PTR_READ_DEST+1
sta ptr2 ; In order to calculate nb of bytes read
stx ptr2+1 ;
sta PTR_READ_DEST
stx PTR_READ_DEST+1
sta ptr2 ; in order to calculate nb of bytes read
stx ptr2+1
jsr popax ; get FD
lda ptr1 ;
ldy ptr1+1 ;
BRK_TELEMON XFREAD ; calls telemon30 routine
; Compute nb of bytes read
lda PTR_READ_DEST+1
sec
sbc ptr2+1
tax
lda PTR_READ_DEST
sec
sbc ptr2
; Here A and X contains number of bytes read
rts
tax ; send FD to X
lda ptr1
ldy ptr1+1
BRK_TELEMON XFREAD
; compute nb of bytes read
lda PTR_READ_DEST+1
sec
sbc ptr2+1
tax
lda PTR_READ_DEST
sec
sbc ptr2
; here A and X contains number of bytes read
rts
.endproc

View File

@ -3,8 +3,8 @@
.export _write
.import popax, popptr1
.importzp ptr1, ptr2, ptr3, tmp1
.include "zeropage.inc"
.include "telestrat.inc"
; int write (int fd, const void* buf, int count);
@ -20,7 +20,10 @@
stx ptr2 ; save count with each byte incremented separately
jsr popptr1 ; get buf
jsr popax ; get fd and discard
jsr popax ; get fd
sta tmp1 ; save fd
; if fd=0001 then it stdout
cpx #0
@ -37,6 +40,7 @@ next:
sta PTR_READ_DEST+1
lda ptr3
ldy ptr3+1
ldx tmp1 ; send fd in X
BRK_TELEMON XFWRITE
; compute nb of bytes written
@ -74,7 +78,7 @@ L3:
inc ptr1+1
jmp L1
; No error, return count
; no error, return count
L9: lda ptr3
ldx ptr3+1