News: 11 March 2016 - Forum Rules

Author Topic: Ridge Racer Type 4 help needed  (Read 2074 times)

GuillermoTell

  • Newbie
  • *
  • Posts: 1
    • View Profile
Ridge Racer Type 4 help needed
« on: July 02, 2020, 06:49:27 pm »
Hi guys,
I'm new here and in hacking in general. I'm looking for the car files, but I've already had a look at R4 files and I'm stuck.  :banghead:
Here is what I've found so far:

Inside the disk (USA version) there are the following files:
-FILE.DAT : looks like the PSX boot.
-R4.BIN : here are the resources.
-R4.STR : looks like the sounds and videos are here.
-SLUS_007.97 : looks like the title ID.
-SYSTEM.CNF : looks like the boot config.

After having a look inside R4.BIN and cleaning the sector info, I found what I think are the cars code blocks. Looks like all of them are the same length. However, the only info I've gotten from them is described for the example below.

I'm struggling to get all the other info like faces, UVs, etc. If you can help, I really appreciate it.  :thumbsup:

There's another example for the Bisonte car.

Thanks.

Info for R4.BIN:

-File count?:
--Start:   0x00
--Value:   0x3a6 (934)

-File offsets?:
--Start:   0x08
--End:      0xea0
--Length:   0xe98

Promessa example:

-? offset:
--Start:   0x04
--End:      0x08
--Value:   0x18

-? offset:
--Start:   0x0c
--End:      0x10
--Value:   0x240
--Extra:   points to header of value 0x0a000000

-? offset:
--Start:   0x10
--End:      0x14
--Value:   0x338c
--Extra:   points to header of value 0x07000000

-Header:   0x05000000

-Texture offset?:
--Start:   0x14
--End:      0x18
--Value:   0x35e0

-Name:
--Name:      PROMESSA
--Start:   0x20d

-Vertices:
--Start:   0x236c
--Count:   290? (measured by trial and error)
--Padding:   2

-Normals?:
--Start:   0x2c7c
--End:      0x333a
--Count:   216?
--Padding:   2

-Lights?:
--Start:   0x34e0
--End:      0x35e0
--Count:   32
--Padding:   2

Here you can get the files:
R4.BIN :   -- link to copyrighted material removed --
Promessa : -- link to copyrighted material removed --
Bisonte :  -- link to copyrighted material removed --

« Last Edit: July 16, 2020, 10:50:55 pm by MathOnNapkins »

aybe

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Ridge Racer Type 4 help needed
« Reply #1 on: May 05, 2021, 04:34:35 am »
Here some code to extract R4 blobs, and also blob #1 which is nothing more than a TMS file like in Ridge Racer 1, a bunch of TIM files.


Code: [Select]
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RidgeRacerType4
{
    [TestClass]
    public class UnitTest1
    {
        private const string R4 = @"c:\temp\r4.bin";

        public TestContext TestContext { get; set; }

        [TestMethod]
        public void Test_FILE_DAT()
        {
        }

        [TestMethod]
        public void Test_R4_BIN()
        {
            using var stream = new MemoryStream(File.ReadAllBytes(R4));
            using var reader = new BinaryReader(stream);

            // read FAT

            var count = reader.ReadInt32();

            var positions = new int[count + 1]; // in 2048 byte sector units

            for (var i = 0; i < positions.Length; i++)
            {
                positions[i] = reader.ReadInt32();
            }

            // print FAT

            TestContext.WriteLine("FAT:");

            for (var i = 0; i < count; i++)
            {
                var p1 = positions[i];
                var p2 = positions[i + 1];

                var positionBytes = p1 * 2048;
                var lengthSectors = p2 - p1;
                var lengthBytes = lengthSectors * 2048;

                TestContext.WriteLine(
                    $"\tFile {i} @ Sector = {p1}, Byte = {positionBytes}, Length Sectors = {lengthSectors}, Length Bytes = {lengthBytes}");

                // export files

                // stream.Position = positionBytes;
                // var bytes = reader.ReadBytes(lengthBytes);
                // File.WriteAllBytes($"{r4}.{i:D3}.bin", bytes);
            }
        }

        [TestMethod]
        public void TestR4_000()
        {
            var path = $"{R4}.000.bin";

            using var stream = File.OpenRead(path);
            using var reader = new BinaryReader(stream);

            // read FAT

            var count = reader.ReadInt32();

            var positions = new int[count + 1]; // next - current = size

            for (var i = 0; i < count; i++)
            {
                positions[i] = reader.ReadInt32();
            }

            positions[count] = (int) stream.Length; // so we can grab last item size

            // read items

            for (var i = 0; i < count; i++)
            {
                var position1 = positions[i];
                var position2 = positions[i + 1];
                var length = position2 - position1;
                stream.Position = position1;
                var bytes = reader.ReadBytes(length);

                // read TMS file

                using var ms = new MemoryStream(bytes);
                using var br = new BinaryReader(ms);

                var magic = br.ReadInt32();
                Assert.AreEqual(256, magic);

                var index = 0;

                while (ms.Position < ms.Length) // extract TIMs
                {
                    var len = br.ReadInt32();
                    if (len == 0)
                        break;

                    var tim = br.ReadBytes(len);
                    File.WriteAllBytes($"{path}{index:D5}.tim", tim);
                    index++;
                }
            }
        }
    }
}




PS here are some polygons: