Fusion-C Split Screen

By Wolverine_nl

Paragon (1052)

Wolverine_nl's picture

04-12-2019, 22:05

Hello all,

Did anybody achieve to create a split screen using Fusion-C?

I am busy trying to convert a few of the examples out there, MAP and some from this forum.
But with no luck yet..

Login or register to post comments

By Grauw

Ascended (8610)

Grauw's picture

05-12-2019, 16:47

A split screen by itself should be totally doable even with a simple H.KEYI hook. The trick will be to get it tight, stable and ideally also CPU speed independent.

I think it could be a good approach to write an ISR in assembly which on the split point does an OTIR to I/O port 99H from a buffer that is prepared in C. So let C queue up the registers to write in the split, and have a little assembly interrupt routine dispatch it.

﹡﹡﹡

For more advanced types of splits you probably also want some control over when it polls for HR sync, and which I/O port it outputs to (e.g. 9AH for palette). Using the same approach, instead of a plain OTIR you prepare a custom-tailored handler routine for each type of split (like I do here⁽¹⁾ with assembly macros), but still pass it the data in a struct from C for it to OUTI (like this one⁽²⁾).

The most advanced approach would be to generate the assembly code, but I don’t think the added complexity of that outweighs the benefit of full C control, and you lose some flexibility compared to hand tailored assembly code which for splits you kinda want.

⁽¹⁾ VDPRegister_SetDI_M and PaletteColor_SetDI_M are just two OUTIs, Split_PollHRStart_M, Split_PollHREnd_M and Split_PollHR_M do a little polling loop (or two in the last case).
⁽²⁾ VDPRegister and PaletteColor are two-byte structs (with my Glass assembler I use macros for structs).

By Grauw

Ascended (8610)

Grauw's picture

04-12-2019, 23:32

For a full-screen split effect you could take a similar approach. On the ISR runs an assembly routine which takes a buffer and on each line polls for HR and then outputs the next buffer value to 9BH (indirect register write). When VBlank is reached the ISR ends and control returns to C, which then has some (reasonably short) amount of time to prepare the buffer for the next screen.

By Wolverine_nl

Paragon (1052)

Wolverine_nl's picture

05-12-2019, 12:53

good read, thanks Grauw, will try something out this weekend. Wink