In MSXgl (my MSX game library) it is the INIT_P1_TO_P2 macro that handle this.
I haven't analyzed in detail this one but at first sight, it has some parts that seem to be corrected. It is better to use the routines advised by ASCII to select slots.
And even if you prefer to make direct accesses, there is simpler. For example your routine might start like this:
crt0_p1_to_p02: in a, (PPI_A) ; A=[P3|P2|P1|P0] Get primary slots info and a, #0b00001111 ; A=[00|00|P1|00] ld c, a ; C=[00|00|P1|P0] Keep P1 slot ID to C and a, #0b00001100 ; A=[00|00|P1|00] rlca rlca or a, c ; A=[00|P1|P1|P0] rlca rlca or a, c ; A=[P1|P1|P1|P0] out (PPI_A), a ; Set primary slots info . . .
The point is not whether my version of the 32 KB ROM crt0 is the best, but it is functional and MattyT & DamnedAngel can try the macro easily to see if it solves their problem.
My goal is not to say that I have a better routine than you but they seem to me very complicated and even possibly buggy or at least there are useless things. These are fairly new libraries and many people can use them. It would be a shame to make their programs on a bad basis. There are already proven routines for decades. Why do something so exotic? I'm not saying that to annoy you.
I only half agree with you on my crt0, but that's not the point here. ^^
I just posted this code here to help...
I like the idea that there have already been proven ROM initialisation routines for decades. It does show how well we have preserved this kind of information, as three people here who are making libraries for the current generation of games don't know what these routines would be.
Good news, soon it won't matter any more as everyone will be using these newly designed routines instead.
And everyone will have games with bugged routines and that take up more space than necessary. I tried this crt0 routine for a 48K ROM and this one didn't work on MSX 16Ks (slot 0) with an extension of RAM. I haven't tried it on a 32K ROM, but the routine seems really suspicious to me.
If you want to try a 48K ROM, use the 48K ROM's ctr0... ¯\_(ツ)_/¯
You can find all the crt0 here: https://github.com/aoineko-fr/MSXgl/tree/main/engine/src/crt0
I have a test process that allow to check all those supported ROM format (8-64K plain ROM + 64K-4M mapped-ROM).
All the test ROM work on OpenMSX on primary or secondary slot.
You can test them here: https://github.com/aoineko-fr/MSXgl/tree/main/projects/targe...
I don't have the real hardware to test all possible MSX configurations so I can't certify that it works 100% in any case, but I don't really feel that they can be considered as "bugged routines"...
When I tested crt0, it was for a ROM that uses the 64KB of RAM. I had to override the slot selection routines to make it work. I thought maybe I used an old version but I just tried s_target_ROM_48K_ISR.rom on openMSX and it crash (F1 no longer respond). Believe what you want, I do not insist.
I'll check again, maybe I broke something...
I checked again and s_target_ROM_48K_ISR.rom
works just fine on OpenMSX 0.16 with the cartridge in subslot 1-1 on a Panasonic FS-A1ST (as in your test). I tested with other subslot or other machine (Phillips NMS 8235 or Canon V20) and everything work fine.
If someone else want to test the ROM: https://github.com/aoineko-fr/MSXgl/raw/main/projects/target...
And sorry to MattyT for these digressions on its topic...