Bank switch to Next OS

Discuss ZX Spectrum Next Games, Tools and more.
User avatar
Maziac
Posts: 46
Joined: Sun Jul 09, 2017 5:56 am

Bank switch to Next OS

Postby Maziac » Sat Nov 10, 2018 5:52 pm

Hi,

I have a problem with the bank switching.
I would like to use some Next OS/esxdos function (load/save) then switch in the original Spectrum ROM and later
when I need load/save again then switch back to Next OS.

However I can't find a way to do this.
So what register do I have to fill to switch to Next OS?

How can I switch in the original ROM? I tried to use 'NEXTREG 0x50 0xFF" and "NEXTREG 0x51 0xFF" but without success.

User avatar
Timbucus
Posts: 207
Joined: Tue May 30, 2017 7:43 pm

Re: Bank switch to Next OS

Postby Timbucus » Sun Nov 11, 2018 7:05 pm

NextOS runs with a Spectrum ROM in place? Or at least very close based on the 128K rom set I believe.
I'm Infinite Imaginations when not in work... PAWS for thought.

Alcoholics Anonymous
Posts: 398
Joined: Mon May 29, 2017 7:00 pm

Re: Bank switch to Next OS

Postby Alcoholics Anonymous » Mon Nov 12, 2018 5:28 am

For the esxdos api, only rom3 (the 48k rom) must be present in the bottom 16k. This is the case after a program is started from NextZXOS. If you overlay the bottom 16k then the main thing you should have to do is write 0xff to mmu0 and mmu1 before calling the api, as you've mentioned. If you overlay the bottom 16k with layer 2 in write only mode via port 0x123b, then that must be disabled as well.

User avatar
Maziac
Posts: 46
Joined: Sun Jul 09, 2017 5:56 am

Re: Bank switch to Next OS

Postby Maziac » Mon Nov 12, 2018 3:54 pm

- Ahh, I see. My writing of 0xFF to mmu0 and mmu1 may not have worked because I need to disable writing in port 0x123B first.
- To switch to esxdos/ROM3: what do I have to do? Is it writing 0x04 to port 0x1FFD and 0x10 to port 0x7FFD?

Alcoholics Anonymous
Posts: 398
Joined: Mon May 29, 2017 7:00 pm

Re: Bank switch to Next OS

Postby Alcoholics Anonymous » Mon Nov 12, 2018 5:14 pm

Maziac wrote:
Mon Nov 12, 2018 3:54 pm
- Ahh, I see. My writing of 0xFF to mmu0 and mmu1 may not have worked because I need to disable writing in port 0x123B first.
- To switch to esxdos/ROM3: what do I have to do? Is it writing 0x04 to port 0x1FFD and 0x10 to port 0x7FFD?
You shouldn't have to do anything unless you've changed which rom is present in the bottom 16k with a previous out to 0x7ffd. When your program starts, rom3 will be there and if you stick to banking using next features (mmu aka nextreg instructions or port 0x123b mapping) then rom3 will always underlie 0-16k. So if you write 0xff into mmu0 and mmu1, rom3 will be uncovered in the bottom 16k. Making sure layer 2 write only mapping in the bottom 16k is disabled in port 0x123b will make sure the bottom 16k is writable which esxdos needs to write its data structures. Layer 2 mapping will be disabled when your program starts so you only have to disable it via port 0x123b if you've changed that.

If you did change which rom is mapped in the lower 16k via out to 0x7ffd, then you will have to put rom3 back with port 0x7ffd. Writes to ports 7ffd,dffd and 1ffd will also affect which pages are mapped at the top of memory in mmu6/mmu7. Usually you won't have to touch the +3 port 0x1ffd as its value should not change unless you changed it.

User avatar
Maziac
Posts: 46
Joined: Sun Jul 09, 2017 5:56 am

Re: Bank switch to Next OS

Postby Maziac » Sat Nov 17, 2018 4:58 pm

Thanks for the info but I still haven't been able to switch to the original 48k ROM.

Could you maybe tell me exactly what bits I have to set in 0x7FFD and 0x1FFD.

My situation is that I start a sna file from the browser. Then when my program got control I disable the interrupts, setup a stack and then I change 7FFD and 1FFD to access the original 48k ROM.

I think I tried all combinations. Without any success.

Alcoholics Anonymous
Posts: 398
Joined: Mon May 29, 2017 7:00 pm

Re: Bank switch to Next OS

Postby Alcoholics Anonymous » Sun Nov 18, 2018 3:44 pm

Maziac wrote:
Sat Nov 17, 2018 4:58 pm
My situation is that I start a sna file from the browser. Then when my program got control I disable the interrupts, setup a stack and then I change 7FFD and 1FFD to access the original 48k ROM.
Are you generating a 48k sna (49152 bytes)? If so, the sna launcher will lock port 0x7ffd so that the machine behaves like a 48k spectrum. You can generate a 128k sna to get past this or you can unlock port 0x7ffd via nextreg 8 bit 7.

HOWEVER, when an sna starts you already have port 0x7ffd and 0x1ffd set up properly so that the 48k rom is present in the bottom 16k. If you never use 0x7ffd to bank memory in the top 16k and instead do it all with mmus then you don't have to do anything except make sure the rom is visible in the bottom 16k (mmu0, mmu1 = 0xff) and port 0x123b has layer 2 write disabled (the default so you may not have to worry about this either) before making an esx api call.

If you do use port 0x7ffd for banking in the top 16k then making sure bit 4 is set for all outs will keep the 48k rom selected. See https://www.worldofspectrum.org/faq/ref ... erence.htm .

Using port 0x1ffd would be unusual and you'd only really need to use it if you are calling the +3dos api when you might need rom2 paged in but this is unnecessary for esx api calls. The "special" all ram modes of the +3 will override mmus as well and would normally almost never be used. So most programs would never use port 0x1ffd.


Who is online

Users browsing this forum: No registered users and 0 guests