[N64] Video Interface (VI) Register hacking (Patches, Filters, Color depth)

Started by Goemon, March 01, 2020, 12:24:38 PM

Previous topic - Next topic

Goemon

Hi folks,

I am a long term member from the now closed ASSEMblerGames Board.
A couple of years ago a user there started a thread about modifying the VI Filters of N64 games
to switch off AA and some other stuff in order to get a much sharper picture on real hardware.
The topic in question is saved here for those who are interested:
https://www.assembler-games.com/threads/is-it-possible-to-disable-anti-aliasing-in-n64-games-via-gameshark-cheats.59916/
I contributed quite some codes myself.
Last week I came back to it and made some more codes. You can follow this here:
https://www.obscuregamers.com/threads/n64-vi-filter-manipulation-gameshark-cheats-revival.1794/

The reasons I am posting this here are the following:
On the topics above we are using Gameshark Cheats and modify the code at runtime.
Some people asked if it is possible to also create APS or XDelta patches from this in order to apply
the filter changes directly to each rom. I believe a few APS patches were made back then but I have no idea how this works.
But I think patches should be possible and this brings us to the rom hacking part.
The instructions to use a certain set of filters on the game must be stored somewhere in each rom
and therefore it should be possible to manipulate this and create patches.

Now I also want to go more advanced here:
Basically all N64 games are using 16Bit color depth.
The downside of this is dithering. Some games suffer from this very much.
StarFox 64 for example or Goldeneye.
Now if you switch off certain VI filters you get sharper picture but the dither can be even more visible.
This is the downside of the cheats we made.
With a higher color depth the dither could disappear entirely.

We can change the VI Filters already so that in theory the game uses 32Bit color depth.
That would be 00003302.
But when doing this, the picture of the game is shown 4 times on the screen with totally wrong colors.
This has something to do with the Framebuffer.
According to docs here:
http://n64.icequake.net/mirror/www.jimb.de/Projects/N64TEK.htm#videointerface
http://en64.shoutwiki.com/wiki/VI_Registers_Detailed
There must be a dedicated 32Bit framebuffer and this needs more DRAM

While I was working on more cheats, the game Quake 2 got me thinking.
Quake 2 is using the Expansion Pak but not for higher resolution.
This game uses the Expansion Pak just for a better color depth.
I have monitored the VI Registers of Quake 2 with the PJ64 Emulator/Debugger
while using no expansion pak and with expansion pak.
Only a few registers got changed.
I could be wrong but it looks like that only a few changes would be needed
to let a N64 Game run in higher color depth when using the expansion pak.

Now the ultimate question is:
Would it be possible to hack the Video Interface (VI) Register of N64 Games which do not use the expansion pak so far
to
- detect and use the Expansion Pak and its additional DRAM in order to
- change/expand the Framebuffer to use higher color depth (32Bit) and
- adjust the VI filters to 00003302

This is a lot of theory here and it would be nice if somebody with
with more understanding of the N64 could contribute some
information.
While this is propably not possible for all N64 games, it would be nice to make some games like StarFox64
better and give the Expansion Pak more use.
I hope something can be done :)

sharksnack

I can't contribute anything myself regarding this topic, but just want to mention that there's a N64 discord server called Discord64 where you might find knowledgeable people too. (Emu/dev talk - should be listed at n64dev.org).