Author Topic: Modding Expeditions (KF)  (Read 45989 times)

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Modding Expeditions (KF)
« Reply #70 on: August 24, 2018, 02:12:28 am »
:biggrin: Untangling the address space of the texture memory is the most important thing in all of this. Good job!

Are you putting these textures into memory by hand? That's not a bad strategy at all if so. I assume that somewhere there is code that coordinates the memory, but don't know if it's a file or code if so. (I wonder if Sony had a format for orchestrating memory transfers.)

It's possible too that parts of the memory are simply designated for different things. In which case it should be easy to spot patterns after a while of trying different combinations.

In any case, publishing a tool for matching models to textures, and exporting to normalized UV maps so they can be worked with reasonably well in sculpting software is absolutely the most productive thing that can be done at this stage.

What is the blue and black pixels in your mini map?

Quote
The first is where you get the skull key, the second is hard to spot and I can't give any more information than the stair case going down to the first save point, in the area with the broken knight sword and 2 - 3 krakens.

Have you attempted to change the brightness of these tiles? in these cases? By inserting different values into the memory where they are located? Like you changed the model that time. BTW, whenever you have a moment, I'd like to know what you found out about the collision model.

P.S. I planned to investigate/reply further on some of the subjects in your previous post, however I'm blown away by this new one, so that has to wait. If you want though, what did you mean by "Since all of the files are on the disc, I want to see if I can find some beta goodies" exactly? Is there something particularly special about that disc?

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Modding Expeditions (KF)
« Reply #71 on: August 24, 2018, 02:55:27 am »
I can't remember where the skull key is... I assume it's deep in the pirate cave. I started a game, with a save slot in the janky emulator. So I can gradually get further in, if nothing else. It's always fun to reexperience this game, though I can never seem to get back to my original experience of a very cerebral, plodding game. I am half convinced my memory of the original game is filtered through a younger person's mind, but my brother who's played it relatively recently on an actual PlayStation (and has a far better episodic memory than I... a dweller on the past) says that it is the way I remember it. I think that when it moves fast, it's not the same game. And even if I misremember it, I would prefer a very slow moving game if limited to a single speed.

IN ANY EVENT! I guessed that there was some kind of directional lighting in the game, or else it would appear very flat, but I've never looked for it, and so could not be 100% certain. I'm not one of these people who's played King's Field 50 times or more. Despite being an ardent advocate.

After you pointed it out to me, I find lighting is particularly noticeable if you hang a left in the first room with two supporting columns. I don't mean the fountain room, but the one that leads to the villages, waterfall, etc. Where the door is, the left wall is clearly much darker, and this continues on into the room...

However, it doesn't seem to me as if there is a zone-wide directional light, as SOM would have it. It seems more like there is an invisible lamp in this room, casting a soft light. But it seems to carry on into the foyer. I'm not convinced the stairs are not a different, darker texture. I've seen these darker textures for both the wall and the stairs among the level textures. The other staircases have tiled walls, whereas this one is the marble or stone pattern, which I don't know of another stairway like it to compare model numbers with.

It is interesting. The entry hall is a more compelling case for the presence of lighting however. I can confirm its part numbers are identical.
« Last Edit: August 24, 2018, 05:21:26 pm by Holy_Diver »

Offline TheStolenBattenberg

  • Capricorn Crusher
  • **
  • Posts: 192
Re: Modding Expeditions (KF)
« Reply #72 on: August 24, 2018, 01:45:48 pm »
It's pretty nice to emulate the behavior of the playstation texture page system. I'm just using a shader which takes in 4 * 32 values, which have the offset and size of texture pages on one big 2048 x 1024 image. It ends out pretty optimized because there aren't any texture swaps; but that's engine design not KF reversing.

I am putting the textures in memory myself, using the atlas system described above, but I feel as if the RTIM files are the key to automating that process, and if that's the case it should be possible to export texture atlases for the tile sets.

From what I can see, parts of the memory are most certainly set aside for specific types of textures. I loaded all the maps and most of the time it would display the correct textures with this system, and the system pretty closely emulates that of the PS1, other than the increased resolution. This also carried over to KF3.

The 'MIX' files containing Tims on the KFJ disc are a large part of my current thinking, since they use the same coordinates as these textures, and fit a total texture page size of 256x256, identical to these.

Quote
What is the blue and black pixels in your mini map?
Blue is my Layer2, and Black is where there is no tile, or 'Mesh ID 0xFF'.

Quote
Have you attempted to change the brightness of these tiles? in these cases? By inserting different values into the memory where they are located? Like you changed the model that time. BTW, whenever you have a moment, I'd like to know what you found out about the collision model.
Not these tiles, but I've done the same with others and had a darkening effect. Objects and Items also have a similar flag that does the same thing, but they have some more in depth flags I can't figured out, too.

Quote
"Since all of the files are on the disc, I want to see if I can find some beta goodies" exactly? Is there something particularly special about that disc?
There's a date difference of about 8 months for quiet a few of the resource files, and size differences. I feel like it might be possible to find a lot of debug stuff or even in progress areas, and the file formats are the same, so it's pretty easy for me to extract and take a look.


Ashes to ashes, Dust to dust...
Honor to glory; And iron to rust.
Hate to bloodshed, From rise to fall.
If I never have to die; Am I alive at all?

Offline TheStolenBattenberg

  • Capricorn Crusher
  • **
  • Posts: 192
Re: Modding Expeditions (KF)
« Reply #73 on: August 24, 2018, 02:14:22 pm »
Quick Update:

I cracked into Pilot Style and I'm honestly amazed; nearly everything is very different from layouts to features. The town after the Maze in KF3 had a massive mountain, a cave path (where I presume the blood herb would've been) and a water fall and lake instead of Lava. Lake Noal is also substantially different:


It's really weird to think that we're the first people to see this in over 20 years. Modern day archaeology I guess.
Ashes to ashes, Dust to dust...
Honor to glory; And iron to rust.
Hate to bloodshed, From rise to fall.
If I never have to die; Am I alive at all?

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Modding Expeditions (KF)
« Reply #74 on: August 24, 2018, 06:13:11 pm »
 :doh:

Quote
Blue is my Layer2, and Black is where there is no tile, or 'Mesh ID 0xFF'.

So in other words, exactly like the light.zip images I attached earlier! It's funny, I saw the black as part of the labyrinth, and the green as negative space... owing to most of it being water. I will have to take a look at that wedge where the fishermen sits. I saw it in the other data, and wondered what it is. I guess it's shoreline, but for some reason on the secondary layer. It can't be mountaintops.

Quote
I am putting the textures in memory myself, using the atlas system described above, but I feel as if the RTIM files are the key to automating that process, and if that's the case it should be possible to export texture atlases for the tile sets.

This looked plausible for level data, but I could not a see a connection for items. That is why I sent you an email yesterday. My guess is the in-menu items have textures in standard places, although the memory is probably entirely swapped out at least once per frame. (I noticed the background of the menus is black in ePSXe. I guess I need to enable a graphics feature or something... I think the PlayStation could read the frame buffer back into the CPU. The texture memory and frame buffer are essentially the same thing as I recall.)

As for placed items/objects, I wonder where their textures go. I could be overlooking something, but I'm pretty well versed in these things. The MDL format simulates the way the PlayStation work, so that it's as if each model has its own PlayStation video memory, and textures are addressed likewise.

Keep it up. These are things I'd prefer to avoid myself, so I don't have to do a project that detracts from SOM. If you can focus on the main things, I can try to figure out the leftovers that might be particularly vexing or of particular interest only to a full reproduction project like my own. The more parts we are able to identify the smaller the search space for the particularly hard parts becomes.

P.S. Please publish/post as soon as you figure out any of the texture assignments, whether you know only for level data or items, etc. EDITED: I've never looked at the Pilot Style demo. Maybe I've seen a video of it played. I understand now what you mean, that it has data for parts of the demo that are inaccessible. I think.


EDITED: Out of curiosity, does KF3 have 2 layers? Its world seems very flat. I can't think of any parts that really require two layers. So I'm wondering if the layers were removed simply to reduce overhead.

FYI: You can hold Alt to take a screenshot of just the foreground window.
« Last Edit: August 24, 2018, 08:01:35 pm by Holy_Diver »

Offline TheStolenBattenberg

  • Capricorn Crusher
  • **
  • Posts: 192
Re: Modding Expeditions (KF)
« Reply #75 on: August 24, 2018, 10:40:03 pm »
Exactly like them, I find the colours easy to distinguish, so it was the obvious choice.

Haven't looked into Item Textures yet, but that's the next battle. I want to finish off my work on the maps first though, since I feel like it will narrow down a lot of possibilities with the textures.

Honestly I'd recommend Retroarch and it's madnafen core for exploring KF. EPSXE does a horrible job with it. I believe it's down to one of my comments earlier, about it being similar to KFJs engine. They would've been using early dev kits and libraries to make it with, probably going blind with a lot of it. (which is probably why we have their custom animation format, I don't think early libraries had functionality for HMD or TOD). This makes it awkward to run. No$PSX, a PS1 debugger I like to use won't launch KF2, nor KF3 due to some form of I/O issue. That's why I had to use CheatEngine. EPSXE has a lot of rendering and timing problems. Madnafen only gets away with it because it's really close to the PlayStation hardware with it's emulation, but even that has its issues.

I only wish this work didn't take as long as it did. Scrolling through hex editors for hours on end gets really tiring.

KF3 does does have support for 2 layers in the file format, but I'm not sure if it works in game. No map makes use of it though.

On the Alt PrintScreen thing, I've been using that, but the window goes beyond my taskbar, making it still capture it.
Ashes to ashes, Dust to dust...
Honor to glory; And iron to rust.
Hate to bloodshed, From rise to fall.
If I never have to die; Am I alive at all?

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Modding Expeditions (KF)
« Reply #76 on: August 25, 2018, 09:30:06 am »
Funny, I would think those libraries are strictly CPU beast, and the emulators would reproduce the CPU's instructions set.

Off-topic: That's weird if the taskbar is in Alt+PrintScreen shots. If you put the taskbar on the side, you can have very wide titlebars. Just set it to auto-hide. I don't know why it doesn't work that way out of the box. I hate that the date/clock/language bar take up 5 slots for absolutely no reason. (I've learned to do without the bar, and tried using Live Tiles instead of a clock/calendar, but they don't work for people who imported Windows 7 into 10 and Microsoft won't fix it. So I use a clock now. )

Quote
I only wish this work didn't take as long as it did. Scrolling through hex editors for hours on end gets really tiring.

Do you look at the code? If your monitor has an "Eye Saver" feature, use it. I think it's similar to the yellow glasses you can buy. Also, buy a wrist brace, and sleep with it on your mouse hand. You don't have to wear it, just sleep in it. It will save your wrist(s).

For what it's worth, I don't think I would ever had worked with assembly language/machine code if not for SOM. I think it's a very interesting part of how computers work, that having insight into is enriching if not invaluable.

Offline TheStolenBattenberg

  • Capricorn Crusher
  • **
  • Posts: 192
Re: Modding Expeditions (KF)
« Reply #77 on: August 25, 2018, 05:24:25 pm »
I might try the task bar on the left, it'd probably more convenient while I'm using this low resolution monitor.

By looking at the code I presuming you're talking about the decompiled exes? I honestly haven't decompiled them, I can't find a decompiler that does a good job for MIPS3000 / PS1, so I'm just looking at file formats or memory/decompiled x86 in cheat engine (but since EPSXE uses JIT, I don't know if the code is accurate or not when converted). Luckily I've had a lot of experience with that. no$psx does have a full featured disassembler that's quite a joy to use, but as I said it doesn't work for King's Field.

I don't have an eye saver feature, nor the glasses. But I can get the same effect by reducing the brightness of the blue channel in the nvidia control panel. Might've looked into wrist braces if I'd of known of them earlier, but my wrists are already far too disfigured now.

I have a vauge understanding of Assembly, but not nearly as much as I should, it goes about as far as being able to follow the path a program takes, but I won't be able to calculate the result in my head if that makes sense?
Ashes to ashes, Dust to dust...
Honor to glory; And iron to rust.
Hate to bloodshed, From rise to fall.
If I never have to die; Am I alive at all?

Offline TheStolenBattenberg

  • Capricorn Crusher
  • **
  • Posts: 192
Re: Modding Expeditions (KF)
« Reply #78 on: August 25, 2018, 08:57:52 pm »
Found the object and item data:


I'm also using the value I thought was a collision mesh to render that map now, to try and figure out what it is. They don't seem particularly useful for anything other than rendering maps like I've done here, though they could be something to do with how the data is streamed into the engine, but I doubt it.

Anyway, I'm not sure what the difference in object types are, but purple represents items and some other intractable objects, yellow seems to be more intractable types and some static types. I haven't figured out all the data yet, but it seems to be much like SOMs object system, where you can place something within a tile, then apply an offset to it within those bounds.

King's field allowed a total of three hundred and fifty objects.
Ashes to ashes, Dust to dust...
Honor to glory; And iron to rust.
Hate to bloodshed, From rise to fall.
If I never have to die; Am I alive at all?

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Modding Expeditions (KF)
« Reply #79 on: August 26, 2018, 02:54:27 am »
Please don't post about finding something without a full explanation. It makes no difference to me that you found it.

I noticed that the 4th byte looks like it is shifted as well. Your image looks like it's applied the shift, but also associated it with opposite planes. Is that right? The image clearly doesn't match the planes. It's a strange way to store data though. Maybe I'm missing the obvious.

I'm having a hard time seeing how these dots relate to things in the game. The purples look like monsters or NPCs to me. The yellows are objects, but maybe items also, if they are one-in-the-same. What do mean by "intractable"? The purples around the lighthouse look like they must be the lamps and the elementals. But there must be an item there also. Likewise on the island. Are the purples directly on top of the yellows?

Publish your findings ASAP. Maybe wait until you are sure about what everything is, but not very long. If you think you know where monsters/NPCs are, it would be good to include them in the same post. But if not, I would like to know about the objects and items in the meantime.

Quote
By looking at the code I presuming you're talking about the decompiled exes?


I mean disassembled. I don't know what exists out there. I've made a note to try that emulator tonight, unless I can't get around to it.


EDITED: I didn't get far with RetroArch (why is it so huge?) It would crash a lot, and has an awful UI. I think it needs obscure BIOS files that won't load through the UI. And the version of Mednafen that works with it (I recognize it from Linux now) is called Beetle. But I don't want to join the underground resistance or ask around for basic ROM images.
« Last Edit: August 26, 2018, 04:40:12 am by Holy_Diver »