Page 1 of 2

Using 32x as a 3rd plane, possible?

Posted: Fri Apr 12, 2019 4:40 pm
by Miquel
1) What I want to do is:

- MD/Genesis works as you expect, as it is alone (no exception table differences, for example)
- if MD detects 32x:
-----> 32x is initialized, a program is uploaded along some graphics
-----> All 32x does it wait for a word (command) to display this or those other screen
- MD runs the main program as there was no 32x, but if there is, sends the appropriate command for this stage, changing the optional 3rd layer

Is that possible? Work alongside the 32x but without interfering a normal MD program in any way.

2) Could 32x do transparencies? For example to do shadows, that is, taking the MD-VPD output and making it darker on certain areas.

Re: Using 32x as a 3rd plane, possible?

Posted: Fri Apr 12, 2019 6:54 pm
by TmEE co.(TM)
32X output can only be above or below MD layer, it cannot do intermediates. Only way you could do some shadowing etc. is to render the output of MD itself on 32X side and apply whatever you want.

As far as other stuff goes, no, you cannot really do that. 32X changes the memory map drastically, at best you need a 2in1 game, one that works on vanilla MD and other that works as 32X game.

Re: Using 32x as a 3rd plane, possible?

Posted: Fri Apr 12, 2019 7:48 pm
by Miquel
TmEE co.(TM) wrote:
Fri Apr 12, 2019 6:54 pm
32X output can only be above or below MD layer, it cannot do intermediates. Only way you could do some shadowing etc. is to render the output of MD itself on 32X side and apply whatever you want.
I was thinking something like "Crusader of Centy"/"Solei" when the clouds obscure the scenario but are not visible themselves. Zelda for GBA also does that.

Re: Using 32x as a 3rd plane, possible?

Posted: Sat Apr 13, 2019 12:07 am
by TmEE co.(TM)
Soleil does checkerboard pattern which you could do on the 32X too, but you're not gonna get any real shadow/highlight type stuff without recreating the MD image on 32X side.

Re: Using 32x as a 3rd plane, possible?

Posted: Wed Apr 24, 2019 3:17 am
by Miquel
TmEE co.(TM) wrote:
Fri Apr 12, 2019 6:54 pm
As far as other stuff goes, no, you cannot really do that. 32X changes the memory map drastically, at best you need a 2in1 game, one that works on vanilla MD and other that works as 32X game.
I'm probably missing something because, after looking docs a little bit, the only thing I can see is the very first 0x100 bytes are reassigned, but everything else remains the same, even better: is possible to control 32x video (audio?) hardware from the 68K, so no need to code anything in SH2.

What am I missing?

Re: Using 32x as a 3rd plane, possible?

Posted: Wed Apr 24, 2019 3:29 am
by TmEE co.(TM)
When 32X is enabled the ROM is only in $880000 to $9FFFFF, the first 4MB no longer has ROM in it. See page 15 for more info : http://www.tmeeco.eu/SMD/32x_hardware_manual.pdf

Re: Using 32x as a 3rd plane, possible?

Posted: Wed Apr 24, 2019 12:59 pm
by Sik
Unless you set RV=1, in which case the 68000 mapping is mostly¹ restored (albeit the SH-2s won't be able to access cartridge area until RV becomes 0 again). Not useful if you want the SH-2s to access ROM tho.

¹The 68000 vectors keep pointing to the banked area so you still need to account for that, but at least it's easier to cope with the occasional case.

Re: Using 32x as a 3rd plane, possible?

Posted: Wed Apr 24, 2019 11:10 pm
by Miquel
Perfect! that’s exactly what I want. Now how to handle those moved vectors…

Re: Using 32x as a 3rd plane, possible?

Posted: Thu Apr 25, 2019 11:26 pm
by Miquel
My game now has a dual boot, MG/Genesis and s32X/Mars mode in one: it executes and passes ok the needed code on 0x400-0x800.
To my understanding, everything is exactly where I need it, the 68k has control of everything. Then the default mode is intended to be a mix mode, so why no game is designed to be compatible with both modes?

What I don’t know is if I need to write a program for the SH2 or them are in some sort or waiting state. How I put them to sleep? Is there a sleep command?

Re: Using 32x as a 3rd plane, possible?

Posted: Fri Apr 26, 2019 2:37 pm
by Chilly Willy
Yes, there is... it's called - "SLEEP". :wink:

SLEEP puts the SH2 in power down mode until an (enabled) interrupt arrives, which will wake the processor. Pretty standard stuff here. Oh, be sure you put the routine that sleeps in sdram as rom won't be available when RV = 0.

And no one made dual carts because they want people to have to buy separate carts if they want both versions. You make twice the money that way! :lol:

Re: Using 32x as a 3rd plane, possible?

Posted: Tue Apr 30, 2019 11:44 am
by Miquel
Roger Chilly Willy!

I expend some time reading SH2 and is pretty similar to 68k code, why Motorola didn’t do a pipelined version of the 68k then?

Anyway, the boot rom of the 32x at the end jumps at whatever is in 0x24000020, what happens if there is nothing written there?
The boot room first checks ram and the it clears it, so what is instruction 0x0000? Invalid opcode?

Another thing: is possible to force the slave cpu to only run CODE (not necessary data) from the cache only? I mean, seems the pretty obvious way to run at 100% performance.

I have accomplished to compile assembler code, but when I try with C code, bizarre results are obtained, let's see:

1) For the command:

Code: Select all

FLAGS32X := -m2 -mb -O6 -g -fomit-frame-pointer -Wall -Wextra -Wparentheses -Wno-unused -Wno-switch

bin/32x/sh-elf-gcc.exe $(FLAGS32X) -c $< -o $@ 
Result:

Code: Select all

 sh-elf-gcc.exe: Rock.mdp/main.c32: linker input file unused because linking not done 
True linkage is not done, but I didn't ask for it...??

2) The same command without the "-c" option:
Result:

Code: Select all

ld: unrecognised emulation mode: shelf
Does it mean can't compile sh2 code? because is the "sh-elf-gcc.exe" file for sure

Re: Using 32x as a 3rd plane, possible?

Posted: Tue Apr 30, 2019 2:18 pm
by TmEE co.(TM)
68040 and 68060 are the pipelined 68k series CPUs.

Re: Using 32x as a 3rd plane, possible?

Posted: Tue Apr 30, 2019 4:19 pm
by Chilly Willy
Anyway, the boot rom of the 32x at the end jumps at whatever is in 0x24000020, what happens if there is nothing written there?
I think you're misinterpreting the boot code. The boot code looks for a header in the rom that tells it things like where the data segment in the rom is, how big it is, where the vbr for each SH2 is, and a starting entry point. The header looks like this

Code: Select all

! Standard Mars Header at 0x3C0

        .ascii  "JagDoom32X      "              /* module name */
        .long   0x00000000                      /* version */
        .long   __text_end-0x02000000           /* Source (offset in ROM) */
        .long   0x00000000                      /* Destination (offset in SDRAM) */
        .long   __data_size                     /* Size */
        .long   master_start                    /* Master SH2 entry point */
        .long   slave_start                     /* Slave SH2 entry point */
        .long   master_vbr                      /* Master SH2 VBR */
        .long   slave_vbr                       /* Slave SH2 VBR */
The vbr tables are part of the data segment copied into sdram, and then the VBR in each SH2 is set, and then the starting entry is jumped to.

Re: Using 32x as a 3rd plane, possible?

Posted: Wed May 01, 2019 1:39 am
by Miquel
TmEE co.(TM) wrote:
Tue Apr 30, 2019 2:18 pm
68040 and 68060 are the pipelined 68k series CPUs.
And why end here? That bad was sales? Just around 1996 appeared plenty of cpus pushing speed around this concept
Chilly Willy wrote:
Tue Apr 30, 2019 4:19 pm
[...]
Yep, the boot room does this:

Code: Select all

org 0
	dc.l reset						; 0: POWER ON RESET PC

org 0x140
	reset:

org 0x2ea
	mov.l @(0x050, pc), r8				; 0x00000338, r8 = $24000018
	...
	mov.l @(0x008, r8), r10				; r10 = $24000020
	...
	jmp @r10

org 0x338
	dc.l $24000018
So if there is no sh2 code in the cartridge, it jumps to 0, since memory is cleared before, an it founds there a 0x00000140 value, since sh2, I believe, is big endian, it tries to execute instruction 0, and then instruction 0x140, whatever they are.

Conclusion: some sh2 code is needed even if you only want to stop/sleep it.

Re: Using 32x as a 3rd plane, possible?

Posted: Wed May 01, 2019 3:36 am
by TmEE co.(TM)
Motorola couldn't up the clocks and their chips started to lag behind others (intel, IBM etc.) who were getting faster and faster, their big flagship chips weren't competitive anymore and customers moved to new things. In the end they dropped 68k line and started doing PowerPC instead...