Jump to content


Photo

drawing transparent menu backgrounds ( WIP )


  • Please log in to reply
9 replies to this topic

#1 aqrit

aqrit
  • Member
  • 132 posts

Posted 16 July 2013 - 09:05 PM

Probably nobody cares, but...

Ghostdog's UI mod sets a transparent background for some in-game menu screens ( which looks awesome! )

However, the game suspends drawing of the background when the menu is open because it doesn't expect any of the background to be visible...

So if the background isn't being drawn then we get artifacts related to double buffering...

Here is a patch to bring the background back to life while the Inventory menu is open.
4CD1v1
File OFfset: 0x00220F4F
Patch:
FF 71 04 89 C8 83 C0 30 50 6A 00 6A 03 50 E8 46
5F 1B 00 59 E8 D1 82 ED FF 89 C1 E8 1F 74 ED FF
A1 1C E8 96 00 8B 88 06 35 00 00 E8 BC 40 FA FF
59 E8 F5 8D ED FF 59 8B 01 FF 90 9C 00 00 00 C3
90 90

-----
so all the other menus still need to be done...
eip: 8248C2 calls to
620F4F - draw inv screen
6426AA - draw map screen
6871D6 - draw mage spell book
6624ED - draw priest scroll
5EC10B - draw stat screen
7D3F72 - draw not paused / pause spacebar / pause wheel

a reference implementation of the inventory patch:
push ebp
mov ebp,ecx // preserve this

mov ecx,ebp
CALL 007D6EA8 // draw area
// sub_007D6EA8 is called as a chessy way to call sub_00485B1C which draws the area...
// there is not room here to load up the args for sub_00485B1C
// sub_007D6EA8 AFAIK normally controls the scrolling during a cut-scene 

// the background is drawing every frame,but the inv menu doesn't draw every frame... ohs noes.
// so redraw the inv menu every frame.
mov ecx,ebp
push 3
add ecx, 0x30 
call 004F9239 // just a helper to get a pointer from the labyrinth ?
mov ecx,eax
push 0
call 004F838E // invalidate rect ?

//
// now do the original sub_00620F4F code... 
//
MOV EAX,DWORD PTR DS:[0x96E81C]
MOV ECX,DWORD PTR DS:[EAX+0x3506]
CALL 005C503B // ? as per original
//
mov ecx,ebp
ADD ECX,0x30
CALL 004F9D7A // draw windows
//
mov ecx,[ebp + 4]
MOV EAX,DWORD PTR DS:[ECX]
CALL DWORD PTR DS:[EAX+0x9C] // ToScreen

pop ebp
RETN


#2 aqrit

aqrit
  • Member
  • 132 posts

Posted 17 July 2013 - 09:17 PM

things I'd like to see included in the next version of Ghostdog's UI mod:

 

--attachment removed--

 

best-fit stretched movies

black bars on title screen

active menu backgrounds

 

once I get all my ducks in a row

I plan on having a new version of pst-ddrawfix

and that menu background thing will be a must.

 

If it is not something you ( Ghostdog ) want to do,  I can always roll it out with my stuff

 

currently none of the 2CD stuff is tested...

the priest menu is also not tested...

everything else is barely tested

I need testers :P

 

edit: oops forgot to unpatch the stretch movie code from Ghostdog's UI mod...

so the best-fit stretch movie code has no effect


Edited by aqrit, 22 July 2013 - 07:38 PM.


#3 ghostdog

ghostdog
  • Modder
  • 556 posts

Posted 18 July 2013 - 07:26 AM

Sorry for the absence aqrit, the transparent menus fix sounds great ! I'll test it and get back to you.

 

If you release a final version I'll whip up a new UI version adding all the stuff that have lined up.

 

 

 

 

[EDIT]

Ok, I tested it. 4CD version. The transparent menus fix seems to be working fine. Same goes for the start menu black bars for the intro movie. Stretching while keeping the apect ratio doesn't seem to work though, even if I remove the stretching code from my UI install.

 

 

 

 

 

once I get all my ducks in a row
I plan on having a new version of pst-ddrawfix

Looking forward to that ! :P


Edited by ghostdog, 18 July 2013 - 07:53 AM.


#4 aqrit

aqrit
  • Member
  • 132 posts

Posted 20 July 2013 - 09:19 PM

Are you not seeing any stretching ? or is it stretching but not keeping the aspect ratio?
It seems to work here... it is easy to see the difference on say a 1440x500 install ( windowed mode with 16-bit desktop )

here is what I'm considering for the next pst-ddrawfix
http://www.shsforums...fog-of-war-pst/
any feature requests?
The fog of war is looking kinda like a spot-light now ... I'm not sure what I want to do about it.

#5 ghostdog

ghostdog
  • Modder
  • 556 posts

Posted 21 July 2013 - 02:00 PM

The movies are stretching but they don't keep the aspect ratio. I checked it on 1280x1024. Maybe you forgot to include the 5:4 aspect ratio ?



#6 aqrit

aqrit
  • Member
  • 132 posts

Posted 21 July 2013 - 04:02 PM

I'll check that res when I get a chance.
 
I just noticed that I can't right-click anything on the inventory screen now :doh:
so it is back to the drawing board for awhile...
 
-
edit: found func that draws the item info for inv - 0062210B ... I'll try to get this nailed down tommorow
also found the store ... any other screens with transparent backgrounds?
 
these funcs call 004F9D7A:
sub_5DEDF4 // ? 
sub_5DFCD5 // chapter? 
s_draw_stat_screen 
sub_5FE962 // ? 
sub_6099C3 // ? 
s_draw_inv 
s_draw_journal
s_draw_key_mappings 
s_draw_load_sav 
s_draw_map 
s_draw_movie_select 
sub_64BDC9 // ? 
s_draw_options 
s_draw_priest 
s_draw_save_game 
s_draw_main_menu 
s_draw_store 
s_draw_mage_book 
s_draw_world_map 
s_draw_area

Edited by aqrit, 21 July 2013 - 09:37 PM.


#7 aqrit

aqrit
  • Member
  • 132 posts

Posted 22 July 2013 - 07:51 PM

The movies are getting stretched to 640x480 then stretched-to-fit... this should be easy to fix but I'll save that for later...
 

--attachment deleted---
anyways here is a fixed versions of the transparent backgrounds ( now with right-clicking! )
plus it now works with the store window

 
also included is a "Sleep CPU When Idle" patch which should probably end up in the tweak pack...
It reduces my CPU usage from 100% to 60% when the game is running and from 100% to 0% when the game is minimized.
 

If no window messages and not yet time to render frame then Sleep(1)


===
I need to black out the background on the load game screen at somepoint


Edited by aqrit, 10 September 2013 - 10:05 PM.


#8 aqrit

aqrit
  • Member
  • 132 posts

Posted 10 September 2013 - 10:16 PM

Attached File  after_ui.tp2   8.01K   499 downloads

added black bars for load and save menus

dropped movie stretching ( added movie stretching to the fog-of-war mod )

 

Any back story on the progress bar ( edit: [ loading save / loading game / saving / unloading ] screens )

it currently seems pretty broken... I'd like to fix that as well.


Edited by aqrit, 10 September 2013 - 10:19 PM.


#9 aqrit

aqrit
  • Member
  • 132 posts

Posted 11 September 2013 - 08:40 AM

/facepalm

... apparently the loading screen was something I busted locally
because the problem doesn't happen with a clean install.

so with the loading screen working properly...
black bars on the load/save menus aren't needed either...
but it doesn't hurt any.

note: I just found that the (fog-of-war mod) movie stretching is incompatible with my other movie stretching patch ( in the current ghostdog UI mod )
becuase I forgot to check if the destination rectangle is null .. this will be fixed the next time an update for that is posted.

Edited by aqrit, 11 September 2013 - 08:42 AM.


#10 aqrit

aqrit
  • Member
  • 132 posts

Posted 17 September 2013 - 11:07 PM

I got a copy of the Chinese executable so I'll be able to supply patches for that sometime.
 
With some creative abuses of EXTEND_MOS it should be possible to edit MOS files at install time. ( crop to size / append tiles / composite borders / etc. )
I'm thinking transparency when overlaying two MOS tiles would have to be very limited... like 100 transparent pixels requires the src tile to have 100 free palette entries.
This will be my next project :)
 
originally, I was thinking just drop the outside borders and center the background... but that is boring.
 
//
// allow negative x,y coords for chu panels ( 4CD 1.1 )
//
DEFINE_ARRAY sx_panel_coords // sign extend chu panel x,y coordinates
BEGIN
    0x0F 0xBF 0x51 0x06 0x90 0x90 0x89 0x55 0xCC 0x8B 0x45 0x0C 0x0F 0xBF 0x48 0x04  
    0x90 0x90
END
PATCH_PHP_EACH sx_panel_coords AS index => value BEGIN WRITE_BYTE ( 0x000F6F8D + index ) %value% END
DEFINE_ARRAY clamp_panel_coords // don't pass negative x,y coords to surface->lock()
BEGIN
    0x51 0x8B 0x4D 0x10 0x8B 0x51 0x08 0x8B 0x41 0x0C 0x50 0x52 0x8B 0x41 0x04 0x99
    0xF7 0xD2 0x21 0xD0 0x50 0x8B 0x01 0x99 0xF7 0xD2 0x21 0xD0 0x50 0x8B 0x45 0xFC
    0x51 0x52 0x50
END
PATCH_PHP_EACH clamp_panel_coords AS index => value BEGIN WRITE_BYTE ( 0x0042D459 + index ) %value% END

Edit (10/9):
here is a start on the mos rebuilding stuff, currently it only crops MOS images
it requires a development build of Weidu to use...
and a development build of NearInfinity to view.

Attached Files


Edited by aqrit, 09 October 2013 - 06:11 PM.