Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
193 user(s) are online (184 user(s) are browsing Forums)

Members: 0
Guests: 193

more...

Support us!

Headlines

 
  Register To Post  

(1) 2 »
Foundation patching: v0.1 patch on os4depot
Home away from home
Home away from home


See User information
@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:

Quote:

CIAgent Spy Monitor
- API: CIA B: AddICRVector() ICRBit: 1=TIMER B Interrupt: $5F39243E "Protracker MusicInt" Result: $00000000
! Hit: CIA B: ?:TBLO ($BFD600) Data: 236 ($EC) Task: $60B25AA0 "Foundation"
! Hit: CIA B: ?:TBHI ($BFD700) Data: 236 ($EC) Task: $60B25AA0 "Foundation"
! Hit: CIA B: R:CRB ($BFDF00) Data: 0 ($00) Task: $60B25AA0 "Foundation"
! Hit: CIA B: W:CRB ($BFDF00) Data: 1 ($01) Task: $60B25AA0 "Foundation"
! Hit: CIA B: R:CRB ($BFDF00) Data: 1 ($01) Task: $60B25AA0 "Foundation"
! Hit: CIA B: W:CRB ($BFDF00) Data: 0 ($00) Task: $60B25AA0 "Foundation"
- API: CIA B: RemICRVector() ICRBit: 0=TIMER A Interrupt: $5F39243E "Protracker MusicInt" Result: $00000000


So everything is right - Paula-CIA for music. Even "Protracker MusicInt" words can be seen.

Next, I go hacking way: trying to understand how to disassemble binary and assembly it back to binary.

Good for us we have IRA (os4depot) and VASM68k from Frank (http://sun.hasenbraten.de/vasm/index.php?view=binrel).

After reading briefly tutorial to ira i was able to disassemble binary by just:

Quote:

ram:> ira -a -preproc Foundation


And make a working binary of the same size from that disassemble by vasm:

Quote:

ram:> vasmm68k_mot -no-opt -Fhunkexe -nosym -o Foundation_new Foundation.asm




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
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@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


So there is that part:

LAB_1D30:
    
MOVE.L    D7,LAB_1D3E        ;722c223c70007241c
    DIVU    
#$007d,D7        ;722c8: 8efc007d
    
JSR    (_LVOCloseLibrary,A6)    ;722cc4eaefe62 exec.library (off=-414)
    
MOVEA.L    LAB_1D3B(PC),A6        ;722d02c7a0140
    CMPI
.W    #$0001,D6        ;722d4: 0c460001
    
BEQ.W    LAB_1D31        ;722d86700003e
    LEA    LAB_1D41
(PC),A1        ;722dc43fa0158
    MOVEQ    
#1,D0            ;722e0: 7001
    
JSR    -6(A6)            ;722e24eaefffa (UNKNOWN)
    
MOVE.L    #$00000001,LAB_1D3D    ;722e6: 23fc0000000100072418
    
TST.L    D0            ;722f04a80
    BNE
.W    LAB_1D32        ;722f266000060
    MOVE
.L    A5,LAB_1D38        ;722f623cd00072400
    MOVE
.B    D7,1536(A5)        ;722fc1b470600
    LSR
.W    #8,D7            ;72300: e04f
    
MOVE.B    D7,1792(A5)        ;723021b470700
    BSET    
#0,3840(A5)        ;72306: 08ed00000f00
    
MOVE.B    #$01,LAB_1D3C        ;7230c: 13fc000100072416
    
BRA.W    LAB_1D33        ;7231460000058
LAB_1D31
:
    
LEA    LAB_1D41(PC),A1        ;7231843fa011c
    MOVEQ    
#0,D0            ;7231c: 7000
    
JSR    -6(A6)            ;7231e4eaefffa (UNKNOWN)
    
MOVE.L    #$00000000,LAB_1D3D    ;72322: 23fc0000000000072418
    
TST.L    D0            ;7232c4a80
    BNE
.W    LAB_1D32        ;7232e66000024
    MOVE
.L    A5,LAB_1D38        ;7233223cd00072400
    MOVE
.B    D7,1024(A5)        ;723381b470400
    LSR
.W    #8,D7            ;7233c: e04f
    
MOVE.B    D7,1280(A5)        ;7233e1b470500
    BSET    
#0,3584(A5)        ;72342: 08ed00000e00
    
MOVE.B    #$01,LAB_1D3C        ;72348: 13fc000100072416
    
BRA.W    LAB_1D33        ;723506000001c


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

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Just popping in
Just popping in


See User information
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.

Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@kas1e

1). take the name of a module in question

should be "LAB_1E56" easy to find in a hex editor.
Sadly, the decompile do not understand ASCII, so dumps it as Long Hex values.

Now you need to make sense of what it does with that string.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Foundation music patch: progress
Just popping in
Just popping in


See User information
You can specify in the config file of Ira a range that you know is ascii for example and it will disassemble it in the correct data format.

Go to top
Re: Foundation music patch: progress
Just popping in
Just popping in


See User information

Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@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:

MOVE.W    -(A2),(A4)        ;13ade38a2
    MOVE
.W    -(A2),2(A4)        ;13ae039620002
    MOVE
.W    -(A2),4(A4)        ;13ae439620004
    MOVE
.W    -(A2),6(A4)        ;13ae839620006
    BTST    
#4,LAB_05DA        ;13aec: 0839000400012ddf
    
BEQ.W    LAB_065D        ;13af467000006
    BSET    
#9,D1            ;13af8: 08c10009
LAB_065D:
    
BTST    #7,D1            ;13afc: 08010007
    
BEQ.W    LAB_065E        ;13b006700000c
    MOVE
.L    LAB_0666(PC),34(A4)    ;13b04297a01f80022
    BSET    
#17,D1            ;13b0a: 08c10011
LAB_065E:
    
MOVE.L    D1,14(A4)        ;13b0e2941000e
    MOVE
.L    -(A2),D1        ;13b122222
    MOVE
.L    D2,D0            ;13b142002
    JSR    LAB_0312        
;13b164eb90000cc14
    MOVE
.L    D0,26(A4)        ;13b1c2940001a
    MOVE
.B    D3,8(A4)        ;13b2019430008
    MOVE
.B    D4,9(A4)        ;13b2419440009
    MOVEA
.L    (A1),A1            ;13b282251
    MOVE
.L    A1,30(A4)        ;13b2a2949001e
    MOVE
.W    20(A1),D0        ;13b2e30290014
    
AND.W    #$000f,D0        ;13b32: c07c000f
    
MOVE.W    D0,46(A4)        ;13b363940002e
    MOVEA
.L    A4,A0            ;13b3a204c
    MOVEA
.L    (A7)+,A4        ;13b3c285f
    JSR    
-204(A6)        ;13b3e4eaeff34


Then i go easy route : if that a window structure, then it should be as in includes :


Quote:

x_pos: dc.w 0 ;X-position
y_pos: dc.w 0 ;Y-position
width: dc.w 600 ;width
height: dc.w 240 ;height


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)

Resized Image


After fix:
(press open in new tab for fullscreen)

Resized Image


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
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@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.

So now to the music part..

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Not too shy to talk
Not too shy to talk


See User information
@kas1e

Good progress, keep on hacking!

1989-> A500, A600, A3000, A4000, A1200, CD32, µA1, PegII, A1XE, CDTV, Amy/416D79, A1X5000, Vampire 500 V2+, Vampire 600 V2, Amy-ITX, Denise ITX <-2024
Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@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.


Edited by kas1e on 2022/1/7 22:56:17
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Not too shy to talk
Not too shy to talk


See User information
@kas1e

Kool progress!

1989-> A500, A600, A3000, A4000, A1200, CD32, µA1, PegII, A1XE, CDTV, Amy/416D79, A1X5000, Vampire 500 V2+, Vampire 600 V2, Amy-ITX, Denise ITX <-2024
Go to top
Re: Foundation music patch: progress
Just popping in
Just popping in


See User information
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.

Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@All
Ok, done! Check this out:

https://youtu.be/J4zWR_Y8uto


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.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Just popping in
Just popping in


See User information
Great !

Can You fix Payback PPC version with Warp3D ?

https://www.apex-designs.net/payback_update_amiga.html

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.)



Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@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 :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation music patch: progress
Home away from home
Home away from home


See User information
@kas1e

Thanks a lot! :)

Go to top
Re: Foundation patching: progress
Just popping in
Just popping in


See User information
@kas1e

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?

Thanks!
Bill "tekmage" Borsari

Go to top
Re: Foundation patching: progress
Not too shy to talk
Not too shy to talk


See User information
Wich version of Foundation is needed to get this running? I tried this with Foundation I have, but it said something about newer prefs etc.

Go to top
Re: Foundation patching: progress
Home away from home
Home away from home


See User information
@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.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Foundation patching: progress
Home away from home
Home away from home


See User information
@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.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project