News: 11 March 2016 - Forum Rules

Author Topic: GBA Raycaster modification  (Read 2737 times)

YukiNa

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
GBA Raycaster modification
« on: April 23, 2021, 04:09:54 am »
I think this is the hardest part of my Driver 2 Advance modification. What I wish to achieve is to make the game Full Screen, or, if it wouldn't be possible, 16:9 with black bars. I'll try explaining as much as I can.


The normal in-game screen.

In-game, there is a part of the screen displaying the raycaster, and the upper part is displaying the UI and Mini-map. Under the UI and the upper half of the mini-map, there is the first tile of the visible raycaster screen repeated ; also, the tiles for the pause menu. Under the lower half of the mini-map, there are hidden Raycaster tiles :



I would like to get rid of the UI (which I can do already) and "add" the missing raycasting tiles in the UI area. Or shift the visible raycaster 2 rows of tiles up and make black bars up and down to make a cinematic effect, if raycasting tiles can't be "added" to complete the upper part.



In the RAM, I could find the adresses where the tiles described above are being injected - these tiles are always changing and updated to display 2 different frames found in the ROM - like an animated drawing while flipping pages. Also, in the ROM, I found the adresses where the visible raycasting tiles are "created" - 1st frame is found from 0806E930 and 2nd frame is found from 0806ED30. It works this way :



What I think I didn't find yet, is the part of the ROM which indicates where to inject the Raycaster into the RAM (what row of tiles). Also, I'm not sure if new tiles can be created to complete the Raycaster under the UI.

So, if someone know about Raycasting on the GBA, I need some help to understand what can be done and how.
« Last Edit: April 23, 2021, 04:31:03 am by YukiNa »

FAST6191

  • Hero Member
  • *****
  • Posts: 3239
    • View Profile
Re: GBA Raycaster modification
« Reply #1 on: April 24, 2021, 01:17:43 pm »
I don't know if raycasting is strictly the correct term, or at least it is a rare one that few will recognise.

Anyway.
So in simpler terms you want to remove the UI and what looks like a minimap and hopefully have the rest of the screen filled in but if not then you will settle for black bars top and bottom, though doing that will see you have to shuffle the data up the screen a bit to make it even on both sides.

The GBA is primarily a 2d console (3d hardware in earnest would appear with the DS). However it does have a perspective transformation option, something most gamers would likely know as mode7 as that is what it was called on the SNES which first popularised the effect (the GBA being something of a mini SNES for a lot of people too) even if it is a meaningless term on the GBA.

http://www.coranac.com/tonc/text/mode7.htm for a nice overview, http://problemkaputt.de/gbatek.htm#lcdiobgrotationscaling for the tech stuff and might as well have https://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#Graphics%20Hardware%20Overview

I would first check to see if the game renders the whole thing somewhere in there. Easiest way there is to use whatever emulator has a bg viewer, sprite viewer, map viewer and other things (various builds of VBA will, as will no$gba debug, mgba might have something but have not checked out its new debug options) and seeing if it is there in those.
9 times out of 10 the game will have the version needed for at least black bars version there and just overwrite it when it comes time to display things. However some times they will be tricky and remove things or overwrite the good data you want with something you want to get rid of ( http://pineight.com/gba/managing-sprite-vram.txt ) so be prepared for that. If it is black bars you will have to find what handles the final location on screen of the thing and shift that up ( http://problemkaputt.de/gbatek.htm#lcdiobgrotationscaling , though I don't know which of the following sections from that link it will use here to pull it off)
Whether it will have enough for a full screen I don't know. Technically it should have something or you might be able to set a background but who knows what they did.

YukiNa

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: GBA Raycaster modification
« Reply #2 on: April 28, 2021, 06:20:21 am »
Thanks again FAST for your reply.

The Raycaster walls are displayed on Background 1 according to the Map data in emualtors. Background 0 is at least the pause menu and some UI text overlayed on the "3D" Background, Background 2 is the floor (updated 1024*1024 map).

I saw in other games using Raycasting like Ecks Vs Sever or Duke Nukem Advance that Backgrounds data can't be seen on emulators and there's only Frame 0 and Frame 1 ; which seem to be similar to what I explained in the case of Driver 2 Advance about the 2 flipping frames.

I'm not sure about what you're explaining when it comes to how things are displayed, but indeed Driver 2 Advance seem to display things differently than the other games I named - the Raycaster doesn't seem to be something that can be "streched" in this game for example (because of the 1024*1024 floor map ?). In Ecks Vs Sever and Duke Nukem Advance, the Map shown in emulators is for both games rotated counter-clockwise and displayed as a square, so it should be rotatable and stretchable I suppose. Everything seem to be displayed on Background 2 (except UIs ?), where on Driver 2 Advance different things are displayed on 3 backgrounds.

I just wondered if the displayed tiles source data can't be found by calculating how many "Raycaster tiles" are displayed - which is a "resolution" of 240 by 128, or 8 * 30 of Width + 8 * 16 of Height = 46 different tiles. Hexadecimal values being different, it would be a value of 2E for 46 tiles, while a full screen would be 50 tiles - 30 + 20 * 8 - or a value of 32 in Hex. That's the only clue I see for now.
« Last Edit: April 28, 2021, 06:51:30 am by YukiNa »

YukiNa

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: GBA Raycaster modification
« Reply #3 on: May 08, 2021, 03:14:05 am »
I'm adding a small update after following the Minish Cap tutorial using VBA-SDL-H. The breakpoint I set at 0806E930 points at one correct element (in green : 06008000 - which is "Char Base" of the raycaster background in the Map Viewer). I found the values from the adress 080788b8, in orange, to be interesting as the vertical raycasting lines can be shifted up or down individually.



Otherwise, I still haven't found what adress is setting the raycaster tiles 4 rows lower. :banghead:

May 10, 2021, 04:49:29 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Small update : I found some interesting values in the RAM. 03001580 seem to be the raycast screen coverage, with a value of 100. When set to under 100, tiles stop getting updated from bottom-right to top-left. When set over 100, they get override as if superimposed - including tiles outside the screen coverage. When set to 0 tho, among all the tiles flickering, it's still possible to see in the Map Viewer the normal screen coverage at one particular frame... so it may not be the good thing. The other values after this adress are also things from the raycaster and the floor backgrounds.

Here the 03001582 adress's value is set to 20.



« Last Edit: May 10, 2021, 11:37:14 am by YukiNa »

FAST6191

  • Hero Member
  • *****
  • Posts: 3239
    • View Profile
Re: GBA Raycaster modification
« Reply #4 on: May 10, 2021, 03:18:57 pm »
Interesting. That would be in the middle of the on chip WRAM ( http://problemkaputt.de/gbatek.htm#gbamemorymap ) which is used often enough that is it not exactly rare but usually reserved for the faster sections of code where performance is critical (which I suppose if you are persuading the GBA to do 3d it kind of is).

Right now that address is probably only much use for cart tilting type things (though might make a nice "drunk" cheat for the game) but if you can understand what the code does with it then you probably have your code doing what you want.

YukiNa

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: GBA Raycaster modification
« Reply #5 on: September 15, 2021, 08:22:37 am »
Bump !

I could finally change the first tile of the raycaster. It was so easy ! I just didn't realize the values could just be... adresses (pointers ?). Again, I'm a noob in rom modding so I'm slow to understand.



Only problem : It lacks rows of tiles in the lower part of the screen while it was up under the UI before. And the raycaster's offset isn't alligned to the floor, but I could change that more easily I think.

I'm yet not sure if I can create new tiles for the raycaster as they are logically set in the loops for the frames 0 and 1 in the ROM... Like switching the offset between the Frame 0 and Frame 1 to create blank space and add the logical values for Frame 0, and same for Frame 1.

Below, the last adress is where Frame 1 starts and before it it's all Frame 0 tiles. 4 bits = 1 Tile. Each 4 rows start with 00000000s as the 2 collumns of tiles on the right are outside of the screen.


« Last Edit: September 20, 2021, 10:17:23 am by YukiNa »