Sedoric or not, overlay or not

This is the best place to discuss about the various Oric operating systems like Sedoric, Randos, FT-Dos, and others.
Post Reply
User avatar
Symoon
Archivist
Posts: 1597
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France
Contact:

Sedoric or not, overlay or not

Post by Symoon » Sun Jan 13, 2019 11:37 pm

Hi,

I'm currently working at faster CSAVE routines, but I would love them to work:
- on Oric-1
- on Atmos
- with or without Sedoric

As these routines are making calls to the oric ROM, I'd need to test before it runs:
- if Sedoric is loaded (any version!)
- if so, if the overlay RAM is set
- so I can finally set the Oric ROM and check if it's a ROM 1.0 or 1.1.

Has anyone ever been this road before?
Which RAM/ROM locations could I check that would give me reliable information for these tests ? Is there a "magical" byte that could work for all situations?
Last edited by Symoon on Mon Jan 14, 2019 12:22 am, edited 1 time in total.

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

Re: Sedoric or not, overlay or not

Post by Symoon » Mon Jan 14, 2019 12:21 am

OK, found something: $C800 seems a good candidate.
= 00 => ROM 1.0
= 4E => ROM 1.1
= 07 => Sedoric 3 or 4 overlay
= 09 => Sedoric 1 overlay
mmmmh, haven't checked Sedoric 2 yet, but I'd prefer finding the same value whatever Sedoric is running.

$C980
AA => ROM 1.0
A5 => ROM 1.1
48 => Any Sedoric overlay RAM.

Now, just need a reliable test to be sure Sedoric is running (and not some other DOS)

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

Re: Sedoric or not, overlay or not

Post by Symoon » Thu Jan 17, 2019 2:22 pm

Symoon wrote:
Mon Jan 14, 2019 12:21 am
Now, just need a reliable test to be sure Sedoric is running (and not some other DOS)
Well, no time to check other DOS, but I'll rely on this to check if Sedoric is in RAM:

Code: Select all

LDA $0477	
CMP #$08
This checks if the 'PHP' op-code is in RAM in $0477. It's the 1st byte of the Sedoric routine to switch to overlay RAM.
I guess it's specific enough not to be used by another DOS.

User avatar
iss
Squad Leader
Posts: 836
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Sedoric or not, overlay or not

Post by iss » Thu Jan 17, 2019 6:28 pm

My first idea was to check the IRQ vector, but this check will be not reliable and may easily fail.
The best option to detect the RAM overlay is to check if some address is writable - something like this:

Code: Select all

    lda $c000
    eor #$ff
    sta $c000
    cmp $c000
    bne rom_activ
    ; ram active -> restore the value
    eor #$ff
    sta $c000
    jsr switch_to_rom

rom_activ
    rts
Maybe you will not like it because it's too long, but it will definitely work :).

... and now when I think again ... are you sure you really need to detect RAM?
In theory it's possible, but in practice how this would happen that your code is called with RAM enabled?

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

Re: Sedoric or not, overlay or not

Post by Symoon » Thu Jan 17, 2019 7:42 pm

Actually when exectuing my prrogram, I have no idea if the Overlay RAM is ON or not. Depends on what Sedoric just did before, I think.

So here's a draft of code written in a rush (as usual, forgive the syntax, I'm only slowly adopting standards ;) )

Code: Select all

--- Check if RAM overlay is ON, and ROM type (1.0 or 1.1)
LDA #$00             'initialize overlay RAM flag
STA xx                 
LDA $C980          'AA=ROM 1.0; A5=ROM 1.1; 48=Any Sedoric overlay RAM
CMP #$48           'Overlay RAM ON ?
BNE +xy
STA xx                  'set overlay RAM flag <> 0
JSR $04F2            'set ROM
LDA $C980      'load byte again, with ROM this time
CMP #$AA          'Oric-1 ?
BNE +xy
JSR xxxx              'adapt code to Oric-1

--- Check if Sedoric is in RAM
LDA $0477           'check the 'PHP' command is in RAM
CMP #$08           '(Sedoric program to swith to overlay RAM)
BEQ +x                 'found: continue program
else display error message and RTS  ('SEDORIC only')

--- Oric-1 adaptation
...
 
--- end of program
LDA xx                  'get overlay RAM flag
CMP #$48           'Overlay RAM was ON before executing the program ?
BNE +3
JSR $04F2            'if yes, set RAM Overlay back
RTS
This is not very reliable, and I should especially check with other DOS what values are in the locations I'm using.
Oh and BTW, this time, code size doesn't really matter ;)

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

Re: Sedoric or not, overlay or not

Post by Symoon » Wed Mar 27, 2019 9:35 am

Back to the subject.
ISS, your solution is, I think, the most reliable! The same idea is used in Oric ROMs to check if it's a 16K or 48K model.

User avatar
iss
Squad Leader
Posts: 836
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Sedoric or not, overlay or not

Post by iss » Wed Mar 27, 2019 10:22 am

... and shorter version: :)

Code: Select all

    lda $c000
    inc $c000
    cmp $c000
    beq rom_activ
    ; ram active -> restore the value
    sta $c000
    jsr switch_to_rom

rom_activ
    rts

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

Re: Sedoric or not, overlay or not

Post by Symoon » Wed Mar 27, 2019 11:21 am

Thanks, I had programmed a shorter version too, with INC and DEC :D

Post Reply