calling GemDOS functions in STOS

STOS-related stuff in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

mlynn1974
Captain Atari
Captain Atari
Posts: 164
Joined: Mon Mar 03, 2008 10:33 pm
Contact:

calling GemDOS functions in STOS

Postby mlynn1974 » Mon Feb 12, 2018 1:32 am

Hi, I have written a small routine in assembly language to allow STOS to use fopen\fread\fseek and fclose.
This was necessary to write my double buffered sample player in STOS.
Bload is fine, but it doesn't allow partial loading or seeking to a part of the file and reading it into a smaller buffer.

I spent a couple of hours debugging this today. fopen should return the file handle in dreg(0) but I couldn't see it. Then I realised that dreg(0) was being overwritten by interpreter activity or other interrupts. Hence I store the file handle in the code and expose it as a word at offset 32 in the header. FREAD calls $3F in read-only mode.

In STOS:
10 hide : key off : mode 0 : curs off : flash off : click off : move off
20 S10=start(10)+28
30 FOPEN=S10
40 FREAD=S10+8
50 FSEEK=S10+16
60 FCLOSE=S10+24
70 FHAN=S10+32

open file:
TX$="MOTD12SG.SAM"
areg(0)=varptr(TX$)
call FOPEN

get file handle:
print deek($FHAN)

load buffer:
reserve as data 5,65535
areg(0)=start(5)
dreg(0)=65535
call FREAD

seek:
dreg(1)=startpos
call FSEEK

close file:
call FCLOSE

Hope someone might find it useful.
You do not have the required permissions to view the files attached to this post.
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).

Social Media

     

Return to “STOS”

Who is online

Users browsing this forum: No registered users and 3 guests