Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

I found somewhere (can't remember where) assembly code for the Sedoric functions READ and WRITE (as shown below).
But I cannot find anywhere assembly code for OPEN, TAKE, PUT, CLOSE (there is some old documentation, but it is extremely complex to read).
Has anyone come across ready made assembly code for these functions before?

Code: Select all

_exvec =  $02f5
_dosrom =  $04f2
_dosflag =  $04fc
_doserr =  $04fd

.code
_sed_fname: .byte 0,0
_sed_begin: .byte 0,0
_sed_end: .byte 0,0
_sed_size: .byte 0,0
_sed_err: .byte 0,0
savebuf_zp: .res 256

_sed_savefile:
	tya
	pha
	jsr sed_savezp
	lda _sed_fname
	sta $e9
	lda _sed_fname+1
	sta $ea
	jsr _dosrom
	lda #1
	sta $0b
	lda #$00
	sta $c018
	clc
	lda #$00
	jsr $d454
	lda _sed_begin
	sta $c052
	lda _sed_begin+1
	sta $c053
	lda _sed_end
	sta $c054
	lda _sed_end+1
	sta $c055
	lda _sed_begin
	sta $c056
	lda _sed_begin+1
	sta $c057
	lda #$00
	sta $c04d
	lda #$40
	sta $c04e
	lda #$40
	sta $c051
	jsr $de0b
	jsr _dosrom
	jsr sed_restorezp
	lda _doserr
	sta _sed_err
	lda _doserr+1
	sta _sed_err+1
	pla
	tay
	rts

_sed_loadfile:
	tya
	pha
	jsr sed_savezp
	lda _sed_fname
	sta $e9
	lda _sed_fname+1
	sta $ea
	jsr _dosrom
	lda #1
	sta $0b
	lda #$00
	sta $c018
	clc
	lda #$00
	jsr $d454
	lda _sed_begin
	sta $c052
	lda _sed_begin+1
	sta $c053
	lda #$00
	sta $c04d
	lda #$40
	sta $c04e
	jsr $e0e5
	lda $c052
	sta _sed_begin
	lda $c053
	sta _sed_begin+1
	clc
	lda $c04f
	sta _sed_size
	adc _sed_begin
	sta _sed_end
	lda $c050
	sta _sed_size+1
	adc _sed_begin+1
	sta _sed_end+1
	jsr _dosrom
	jsr sed_restorezp
	lda _doserr
	sta _sed_err
	lda _doserr+1
	sta _sed_err+1
	pla
	tay

sed_savezp:
	ldx #00
	L_139_loop:
	lda $00,x
	sta savebuf_zp,x
	dex
	bne L_139_loop
	rts

sed_restorezp:
	ldx #00

L_150_loop:
	lda savebuf_zp,x
	sta $00,x
	dex
	bne L_150_loop
	rts

_cls:
	jmp $ccce

User avatar
Chema
Game master
Posts: 2724
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Chema »

EDIT: Sorry I misread your message, and thought you wanted to CALL the functions from within your code, not the actual disassembly. Please, ignore my answer.

It's monday morning, you know... :roll:
In the OSDK library there is a sedoric function, but I am not sure if it works correctly for what you want to do.

The prototype is in lib.h

Code: Select all

/* sedoric(): Please use the exclamation mark as well, e.g. sedoric("!DIR") */
/*	      Bear in mind that this might well be broken. I don't know     */
/*	      much about SEDORIC yet... No error handling! Anything wrong   */
/*	      happens, and you get an error, and go back to the 'Ready'     */
/*	      prompt. Can anyone fix things here? I declare my ignorance.   */

void sedoric(char *command);		/* invoke a sedoric command */
And the code is:

Code: Select all

_sedoric		; invoke a SEDORIC command using black magic
			; Watch it! I have reasons to believe this is broken
        ldy #$0         ; grab string pointer
        lda (sp),y
        sta tmp
        iny
        lda (sp),y
        sta tmp+1
        dey

sedoricloop1            ; copy the string to #35..#84
        lda (tmp),y
        sta $35,y
        iny
        ora #$0
        bne sedoricloop1

        sta $ea         ; update the line start pointer
        lda #$35;
        sta $e9

        jsr $00e2       ; get next token
        jmp ($02f5)     ; call the ! command handler
The first part takes the parameter (string pointer) from the C Stack (sp).

User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

Yeah, I have seen this function. But it is just "passing through" sedoric DOS commands...
I am looking for something more similar to the assembly code of the READ/WRITE function, that bypass the sedoric DOS commands.

User avatar
Dbug
Site Admin
Posts: 3460
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Dbug »

The Sedoric expert is André Cheramy who wrote "Sedoric a Nu", a complete commented disassembly of Sedoric and how it works, not sure if there was any English version of it.

I've been frustrated by the whole "sedoric()" thing because it was basically unusable for anything other that run a load command really, which is kind of why I switched on making the FloppyBuilder system.

That being said, if you can come up with some proper sedoric api that can be called from assembler and C, I would gladly add that to the OSDK, I'm probably not going to use it for games or demos, but for tools that would be useful.

User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

I have been playing around with SEDORIC, but files processed with header.exe cannot be opened with OPEN S,filename,0.
I suppose that SEDORIC detects them as TAP files, and don't want to touch them with OPEN.

But the trouble is, tap2dsk only works with TAP files (even when adding extra files).
I suppose that I need to modify tap2dsk, so it lets me add raw data files...

Any clues you may have would be most welcome!

User avatar
Dbug
Site Admin
Posts: 3460
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Dbug »

I don't think they exist as "tap" anymore, but the important thing is that files on the Oric, both on TAP and DSK formats, knows which address they need to be loaded to (that's why you can save a HIRES screen to disk and when loading it will automatically loads in A000).

I've never used OPEN, so no idea how that works, the farther I've been in using Sedoric was to load and save files... Since Tap2Dsk was made by Fabrice Francès, may be you could poke him and ask him if he knows about the issue?

User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

Dbug wrote:
Wed May 20, 2020 7:01 am
I've never used OPEN, so no idea how that works, the farther I've been in using Sedoric was to load and save files... Since Tap2Dsk was made by Fabrice Francès, may be you could poke him and ask him if he knows about the issue?
I tried OPEN, PUT, CLOSE, and found that the files generated have no header. That's why I would like tap2dsk to allow me to save files without a header. Where is Fabrice these days?

User avatar
Symoon
Archivist
Posts: 1900
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Symoon »

I haven't worked with Sedoric for years now, but I think flies you use with OPEN, TAKE etc. are a specific type (something like sequential recordings files, which don't exist in TAP format).
You should confirm that by reading Sedoric manual, and Sedoric à Nu which are the two book you need if you want to understand Sedoric.

I may be mistaken but don't think TAP2DSK converts the TAP file into a file you can OPEN. It's using the TAP header to determine the file type and addresses.
BTW files in Sedoric don't have a "header". There's a file catalog with 16-bytes entries for each file holding their name, type, and descriptor sector address.

User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

Symoon wrote:
Wed May 20, 2020 8:47 am
BTW files in Sedoric don't have a "header". There's a file catalog with 16-bytes entries for each file holding their name, type, and descriptor sector address.
AH! Then the file catalog is probably where I need to look!

User avatar
Symoon
Archivist
Posts: 1900
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Symoon »

Go for track 20 (#14) sector 4, if memory serves. That's up to Sedoric 3; beware that Sedoric 4 allows multiple catalogs to simulate folders ;)

User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

I found some information on RetroWiki...

I tried modifying the protection attribute (0F), and that has no effect.
Next, I tried modifying the type of file type from 0x41 (block, exec) to 0x80 (no block, no exec), and that also has no effect.
The serial attribute must be somewhere else, but I can't find it... (and Sedoric a Nu is a book for sadomasochists).

Don't really know where to look...

Code: Select all

Each directory "entry" is structured as follows:

Bytes nº00 to 08 name completing to the right with blanks (# 20)
Bytes nº09 to 0B extension (idem)
Byte nº0C Track number of its descriptor
Byte nº0D Sector number of its descriptor
Byte nº0E number of sectors for the files (including the (s) descriptors)
Byte nº0F protection attribute (b6 = 1, Protected if b7 = 1, Unprotected if b7 = 0) (# 40 = 0100 0000 for Protected and # C0 = 1100 0000 for Protected. b0-b5 = HH = The upper part is the number of sectors, rarely used except for very large files "mergers."

The descriptors are structured as follows:

C100- bytes nº00 / 01 "link" (coordinates of the next descriptor). If it points to # 0000. There is no sector 0 on track # 0, indicating that there is no other descriptor, since a sector number can never be zero.
C102- Byte nº02 contains #FF (only if it is the first descriptor sector)
(The pointer X is positioned in this #FF, and allows other readings)
C103- Byte nº03 (C101 + X) type of file (see manual of the page 100). Here # 40 or 0100 0000 indicates that it is a "data block" file type (b6 = 1).
C104- Bytes nº04 / 05 (C102 + X and C103 + X) (normal) start address (or number of direct file access tabs). # C400 Here is the beginning of BANK # 7, RAM Overlay.
C106- bytes nº06 / 07 (C104 + X and C105 + X) address (normal) of the end (or the length of a file direct access tab). # C7FF Here is the end of BANK # 7 overlay in RAM.
C108- bytes nº08 / 09 (C106 + X and C107 + X) are the execution addresses if AUTO, # 0000 if not AUTO.
C10A- bytes nº0A / 0B (C108 + X and C109 + X) number of sectors to load. BANK # 7 includes 4 sectors, hence # 0004 shown here.
C10C- bytes nº0C / FF (C100 + Y and C101 + Y) list coordinates of tracks / sectors to load. Here the first sector of BANK No. 7 is located in sector 11 (# 0B) on track # 5 (# 05), and the last sector at No. 14 (# 0E) of the same track. There is space in the first descriptor for 122 two-byte pairs. If the number of sectors to load exceeds 122, when it reaches the position # 00 (end BUF1), load the following descriptor whose structure is simplified:
C100- bytes nº00 / 01 "link" (coordinates of the next descriptor)
C102- bytes nº02 / FF (C100 + Y and C101 + Y) list of track / sector coordinates to other sectors to load (Y from # 02 to #EF maximum), 127 pairs of 2 bytes. If the number of sectors to load exceeds 122 + 127 = 249, load the following descriptor etc ...

User avatar
Chema
Game master
Posts: 2724
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Chema »

8bit-Dude wrote:
Wed May 20, 2020 4:57 am

I suppose that I need to modify tap2dsk, so it lets me add raw data files...

Any clues you may have would be most welcome!
I am not sure what you are trying to do, but if you don't mind installing java, there is a took that lets you add files to a dsk with drag&drop. I am not sure if they need to be tap files, but most probably not.

https://github.com/teiram/oric-dsk-manager

User avatar
Symoon
Archivist
Posts: 1900
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Symoon »

Chema wrote:
Wed May 20, 2020 12:28 pm
8bit-Dude wrote:
Wed May 20, 2020 4:57 am

I suppose that I need to modify tap2dsk, so it lets me add raw data files...

Any clues you may have would be most welcome!
I am not sure what you are trying to do, but if you don't mind installing java, there is a took that lets you add files to a dsk with drag&drop. I am not sure if they need to be tap files, but most probably not.

https://github.com/teiram/oric-dsk-manager
It certainly does, or requires asking for memory start address to the least ;)

User avatar
8bit-Dude
Pilot Officer
Posts: 123
Joined: Tue Mar 14, 2017 1:33 pm
Location: Japan

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by 8bit-Dude »

Chema wrote:
Wed May 20, 2020 12:28 pm
https://github.com/teiram/oric-dsk-manager
I already have this app. But it is not really useful for what I am trying to do (plus it is buggy).
For now, I can generate files with OPEN in Oricutron, and save the Disk again. By I am having a hard time figuring out what exactly is different between tap2disk files, and OPEN files...

User avatar
Dbug
Site Admin
Posts: 3460
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Assembly functions for Sedoric OPEN, TAKE, PUT, CLOSE

Post by Dbug »

Have you tried a binary diff between the two DSK files?

Post Reply