gint/src/render-cg/dvram.c
Lephe 7d63a1b536
r61524 render-cg: support Prizm and fx-CG Manager
This change adds a new HWCALC model, HWCALC_FXCG_MANAGER, which
identifies Casio's official fx-CG Manager software. Both the Prizm and,
to my surprise, the fx-CG Manager use the old RAM address of 88000000
(P1) and a8000000 (P2) instead of the new fx-CG 50 address of 8c000000
(P1) and ac000000 (P2).

The VRAM is hence adjusted at startup to move hardcoded pointers into
the proper space. Added to the kernel moving the VBR space dynamically
on the Prizm, this allows gint to be fully compatible with these
platforms.

The fx-CG Manager is detected by its product ID made of 0xff.

Also adds a proper interface to the R61524 driver, even though it's not
any more complete than previously, and fixes an oversight where the
HWURAM entry of the kernel data array was no longer computed since the
TLB management change.

As of now, the fx-CG Manager still has a bug regarding return-to-menu
since returning from the main menu doesn't work very well and often
loops. This has been seen occasionally on some Graph 90+E so it's
unlikely to be a platform-specific problem.
2020-07-02 15:48:19 +02:00

66 lines
2 KiB
C

#include <gint/display.h>
#include <gint/hardware.h>
#ifdef GINT_USER_VRAM
/* We want to put the VRAM in the user section, however we can't use the
virtualized P0 address as this will mess up the DMA. As the static RAM is
always fully mapped at a fixed place, we can use the target P1 address. We
just need to allocate the space for the linker. This special section ensures
that the first address of the user stack will be used */
GALIGNED(4) GSECTION(".bss.vram") int8_t _gint_vram_buffers[396*224*2];
/* In this case, we can define pointers to our user stack directly, these will
be the physical address associated with _vram_buffers */
static uint16_t *main = (void *)0xac161400;
static uint16_t *scnd = (void *)0xac18c900;
/* Shared VRAM pointer, the one exposed by <gint/display.h> */
uint16_t *gint_vram = (void *)0xac161400;
#else
/* Otherwise, just put both VRAMs in the system stack! */
static uint16_t *main = (void *)0xac0f0000;
static uint16_t *scnd = (void *)0xac11b500;
uint16_t *gint_vram = (void *)0xac0f0000;
#endif
/* On Prizm: should be: 0xa80f0000 and 0xa811b500 */
__attribute__((constructor))
static void init_vram(void)
{
/* On Prizm and fx-CG Manager, move address to 0xa8000000 */
if(gint[HWCALC] == HWCALC_PRIZM || gint[HWCALC] == HWCALC_FXCG_MANAGER)
{
main = (void *)main - 0x04000000;
scnd = (void *)scnd - 0x04000000;
gint_vram = (void *)gint_vram - 0x04000000;
}
}
/* dsetvram() - Control video RAM address and triple buffering */
void dsetvram(uint16_t *new_main, uint16_t *new_secondary)
{
if(gint_vram == main) gint_vram = new_main;
else if(gint_vram == scnd) gint_vram = new_secondary;
main = new_main;
scnd = new_secondary;
}
/* dgetvram() - Get VRAM addresses */
void dgetvram(uint16_t **ptr_main, uint16_t **ptr_scnd)
{
if(ptr_main) *ptr_main = main;
if(ptr_scnd) *ptr_scnd = scnd;
}
/* dvram_switch() - Triple buffering switch
This function is not public, it is used only by dupdate(). */
void dvram_switch(void)
{
if(gint_vram == main) gint_vram = scnd;
else gint_vram = main;
}