@All To avoid derailing all the threads with unrelated content want to create one for only Foundation.
!NOTE! we can play it in e-uae, etc. But i just want my fetish to be done to make all works directly from OS4.
As it is known by anyone who tried to run that game before it is already half of working through. It has a bit of an issue like:
- broken cursor in the menu (you need to swap back to os4 and then back to the foundation screen to make it works).
- broken preferences (also can be workaround by playing with GUI prefs of OS4).
- no AUDiO-CD by default. But that is not broken you need just mount .cue via diskimage.deviсe and use Salas00's cdplayer.library and CDDAPatch.
And the last one which I want to deal with: music in the menu/intro/gametitle. Because does not matter if you use AHi it uses ahi just for sounds but Paula/CIA for mod-player.
So. i for sake of tests run firstly Hypex's unfinished Ciagent tool (on os4depot) which can catch Cia accesses and that is what we have there:
Now to find where is a player called and then external jump to some C compiled object code with ahi player. But maybe will be better to do something easier first: like maybe replace the mouse cursor on system friendly one.
Edited by kas1e on 2022/1/9 23:18:27 Edited by kas1e on 2022/1/10 20:35:47 Edited by kas1e on 2022/1/10 22:42:58
@All On EAB someone with the name "Docent" brings a bit of good help:
Quote:
It looks like the game adds a CIA interrupt handler via a system call.AddICRVector.
Search in the source code for jsr -6(A6) This defines AddICRVector. Before this call register a1 will be setup with a pointer to Interrupt struct, where.field is'_code is a pointer to actual cia interrupt handler with replay routine. You can replace it with your player
Now need to understand how to rewrite a player. Wrote one on C are easy but need to understand first how it works in original what params it takes etc.
i mean i can put just call to the external function in C code just i need to find in the code where to do so and where in the code name of the module is sent.
i.e. i will write on C that:
play_module(char *name_of_module)
{
there ahi_player
}
stop_module()
{
there drop_of_player
}
Now i need to find a place where actually call to play happens and there do that just that (for first tests):
1). take the name of a module in question 2). play that module over ahi
I have no problems with writing player on C/ahi. All I need now is to find out from where do JSR calls to my external function and from where to take the name of the module.
I can do a call to the external player right after first "jsr -6(A6)" but where to are the name of module sends to replayer
If the replay routine is done using addinvector() then this function could be patched, look for the task who did it if it is foundation put your own code if not continue. Doing it in 68k ASM might be simpler.
@All At first, to better understand how Foundation was coded, I tried to fix "FoundationPrefs" which have issues with too small width and as result all the buttons use/save/reset_prefs/quit just invisibly and to make them be at least half visibly needed to play with the GUI preferences of OS to make buttons bigger and so on.
So I just checked what size preference windows are: 600x240. I need to change the 240 value. Disassembled it with IRA and checked what function is used for open window: OpenWindow() or OpenWindowTagList() - as a result that is OpenWindow().
Next, from 68k asm pov OpenWindow takes just one argument: pointer to a window structure into A0. But that all looks like a mess from dissasemble part:
And so on. So value width and height should be closed together.
I tried immediately to find in the binary itself such a hex data: 025800F0, and nothing. How that? Created then 2 examples of OpenWindow() for 68k on asm (vasm from vbcc) and on C (also by vbcc's vc). In each of them, those values are placed the same together. So i start to think about all sorts of things, but then on EAB come one of the developers who help Paul to develop Foundation at some point, and he say that whole thing (and prefs and main binary) were written on BlitzBasic 2.1.
Now, i install BlitzBasic 2.1 on OS3.2 under E-UAE, create a simple test case to Open a window, and wtf, in the binary it is also not just 025800F0, but 0258 some_4_bytes_ 00F0. Do now know wtf is that and how, but then it was easy for me to find that in the FoundationPrefs binary, add 10 by width, and have a proper window with proper buttons.
See, before: (press open in new tab for fullscreen)
After fix: (press open in new tab for fullscreen)
Next want to deal with a cursor in the game itself being disappeared after title images show up. Probably they SetCursor via some BlitzBasic kind function new bitmap and something goes wrong there. Maybe worth just disabling and keeping system one.
And after that probably ready to deal with music.
Edited by kas1e on 2022/1/7 0:54:35 Edited by kas1e on 2022/1/7 16:53:37 Edited by kas1e on 2022/1/7 16:54:32
@all Ok, with cursor was easy enough. Checked intuition.library, and they're just 2 functions : SetPointer() (-270) and SetWindowPointerA (-816). Checked disassemble from IRA, and found only -270 there. So simple commented out JSR -270(A6), recompile back to the binary, and have system's cursor in the menu and in-game now. Maybe not that tasty as some game's fancy cursor, but it better than needs to swap back to the workbench, activate it, and swap back to foundation screen to have (not always) mouse is shown.
@khayoz :) I even found now how to made it works in 1920x1080x32bit , while originally it give only modes up to 1280 and non-system friendly screens. Through that wasn't by hacking, just setting up prefs:screen properly. I will made all info in some small article later when will done with replayer (the last thing).
For now, i already wrote 68k version of the player which takes the name of the module and plays it through ptreplay.library (on os4 it uses amigaos4 versions done by Frederik, so all works fine from 68k code). So i also made it an external function (a player I mean) and compile object files from C sources, with removing all C-libs code, so as to keep only OS3.x calls (will be easy to rewrite it on assembler if there will be needs for once that done). Now just sorting last moment about how to compile together that all via vbcc, and should have played some external module on the place where the module should start. So hope for something soon.
EDIT: ok i am able to compile into reassembled foundation binary my C player: right at the beginning do "jsr _my_player" , and on running music plays. Now need to do some crap to find out where actually put a player in (there are 7 place for 7 modules : end, enter, intro, lost, menu, start, and won). Only to find out when they should be called/stopped and that all.
You can use WinUAE with the action replay rom, put a breakpoint on the replay routine and see the parameters for each song and use the same ones on your code.
A bit of finetuning left, but all the major bits are done. What you see here is instead of cia.resource for modules i use ptreplay/ptplay librarys (native version of which for OS4 were done by Frederik aka Salas00). Player has written on C, and i link it together with main assembler code which i got by disassembling it by IRA. If some you will have any interest i can write a small article about how i have done that all, can be pretty interesting.
Update 7: OS-legal Paula access routines are now used on the 68k version for compatibility with Amithlon. (The PPC version still accesses Paula directly for extra speed.)
@amig_os I have a lot of TODO which i want to sort first for amiga projects. Payback at least in 68k version works fine on OS4. And with foundation, i was just lucky enough that it was more or less easy.
Taking into account that it was written on BlitzBasic2.1, it just luck it works at all :)
Love the work on Foundation. I was playing it via E-UAE few years ago. Once your done and post your work I'll pick it up again but natively :)
As for Payback, I've installed the latest version from Aminet and I get the audio.device error when I run either the 68K or WOS version:
14.Work:Games/3D-Games/Payback> stack 10000 14.Work:Games/3D-Games/Payback> Payback.exe InitSound: Could not open audio.device! ***Command 'Payback.exe' returned with unfreed signals 04000000! 14.Work:Games/3D-Games/Payback> Paybackwos.exe InitSound: Could not open audio.device! ***Command 'Paybackwos.exe' returned with unfreed signals 04000000!
Any other trick I need to use to get Payback running?
@tekmage I need to check if i do something non-trivial, but the 68k version surely works in software mode.
@utri007 There is nothing uploaded at the moment (in the first post it was just reassembled wip, not a patch). I hope today to upload a fully ready patch with all that installation scripts and stuff.
The version which needs it is FoundationGOLD with their last official update applied called FoundationGold151.lha (i can upload it somewhere later, or maybe will add it to the patch archive).
Why I choose "GOLD" because gold is the latest one of all the Foundation's series, includes everything from previous ones, and has some improvements over other ones.
So wait probably a few hours more and i will upload ready-to-use patches.
@All Ok, patch on os4depot in upload query. I tried to make it as good as possible (i mean patch itself), with installation script (but you of course can do it manually too), with checking if you have necessary player libs, and if not, install them, with double-checking that "GOLD + update151" version works and patches fine via installer script.
But there can be bugs of course :) So report them all there.
And don't forget (please) to read "readme.txt" in the root. It's small, but explain what was done, what TODO, and how to make Foundation runs with CD-Audio from .cue, with all music and sounds, on true-color screens, etc, etc.