system location in build screen patch

General Modding Information/Questions; support/discussion/questions

Moderator: thunderchero

Forum rules
:idea: Please search before starting new topic. :idea:
There is a good chance it has already been asked.
Post Reply
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

system location in build screen patch

Post by thunderchero »

Hi Everyone,

I have a patch to display the X Y of a system in the F2 screen
here is a short video of how it displays


This patch uses the Literal mod code (alpha-number -> number-number for xy) that was developed for larger maps.
Literal mod is required and is part of this patch.
if the Literal mod is already installed the patch will display red (conflicts) this would be expected.
as always make a backup of your trek.exe before applying this patch.

here is patch for uses with botf patcher
xy_in_f2.patch
(3.04 KiB) Downloaded 103 times
NOTE this will not work on current beta version of Galaxy mod

here is code changes

changes in 4F7320 (F2 screen sub)
at 4F73A1 I shifted code 2 bytes to duplicate registry of systinfo (mov edi, eax) so new code would always have system info
at 4F73B3 I removed code for lexicon id ("SYSTEM") and get lexicon terms and added call to new code (call loc_4B6640)

Code: Select all

4F73A1 89 C7                                         mov     edi, eax      (get systinfo for new code)
4F73A3 83 C0 08                                      add     eax, 8
4F73A6 89 54 24 10                                   mov     [esp+10h], edx
4F73AA E8 11 43 F9 FF                                call    sub_48B6C0
4F73AF 89 44 24 30                                   mov     [esp+30h], eax
4F73B3 E8 88 F2 FB FF                                call    loc_4B6640      (call new code to display X Y)
4F73B8 90                                            nop
4F73B9 90                                            nop
4F73BA 90                                            nop
code changes at 4B6640 (within Star_names sub section)
This code is basically the same code as 4B64A0 and 4B64D8 but with many changes
first the code for anomaly name was removed.
code was changed to call systinfo instead of stellInfo
I borrowed a wildcard %d.%d from AI diag sub routine (should not be missed)
4B6642 - 4B6660 calculates X Y
4B6662 - 4B6667 pushes calculated info into wildcards
4B6668 wildcard offset
4B666D - 4B6674 moves string into esp for sprintf
4B6675 call sprintf sub section
4B667A mov string from esp to eax to use in F2 screen code
4B6681 resets offset of esp for font
4B6684 - 4B668E resets registries to values before entering sub 4B6640
4B6693 return to F2 sub section to continue with vanilla code for F2 screen

Code: Select all

4B6640                               loc_4B6640:
4B6640 89 F9                         mov     ecx, edi
4B6642 8B 57 78                      mov     edx, [edi+78h]    
4B6645 BB 05 00 00 00                mov     ebx, 5
4B664A 89 D0                         mov     eax, edx
4B664C C1 FA 1F                      sar     edx, 1Fh
4B664F F7 FB                         idiv    ebx
4B6651 8B 77 7C                      mov     esi, [edi+7Ch]
4B6654 89 C3                         mov     ebx, eax
4B6656 89 F0                         mov     eax, esi
4B6658 C1 FA 1F                      sar     edx, 1Fh
4B665B BE 05 00 00 00                mov     esi, 5
4B6660 F7 FE                         idiv    esi
4B6662 40                            inc     eax
4B6663 50                            push    eax
4B6664 83 C3 01                      add     ebx, 1
4B6667 53                            push    ebx
4B6668 68 08 81 57 00                push    offset aD_D_0   ; "%d.%d"
4B666D 8D 84 24 88 00 00 00          lea     eax, [esp+0Ch+arg_78]
4B6674 50                            push    eax
4B6675 E8 1F D7 05 00                call    sprintf_
4B667A 8D 84 24 8C 00 00 00          lea     eax, [esp+10h+arg_78]
4B6681 83 C4 10                      add     esp, 10h
4B6684 BB 1C 00 00 00                mov     ebx, 1Ch
4B6689 BA 40 00 00 00                mov     edx, 40h
4B668E BE 02 00 00 00                mov     esi, 2
4B6693 C3                            retn
Location of borrowed a wildcard %d.%d from AI diag sub routine

Code: Select all

578108 25 64 2E 25 64 00             aD_D_0          db '%d.%d',0
so far in all my tests this code changes have ran very smoothly with no errors.
If you encounter any issues let me know

enjoy
thunderchero


(original development post)
Hi Everyone,

While playing I was thinking it would be helpful to have the sector location in system screens.

I am hoping it will be possible to change "SYSTEM" to location?

here is what I am looking to do.
change this
wish.jpg
wish.jpg (248.41 KiB) Viewed 4291 times
to this
wish1.jpg
wish1.jpg (231.03 KiB) Viewed 4291 times
the lexicon "SYSTEM" is called at 4F73B1

and we have documented the sector info here;
viewtopic.php?f=107&t=618&p=8910#p8910

any ideas on how or if this is possible?

thunderchero
User avatar
slickrcbd
Lieutenant-Commander
Lieutenant-Commander
Posts: 199
Joined: Tue Sep 08, 2015 9:22 pm
Location: in front of a computer

Re: system location in build screen?

Post by slickrcbd »

That would be nice, but I've been unable to find a mod like this and I looked for years.
It gets frustrating when you can't recall where a system is located in your vast empire on large maps.
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1883
Joined: Sun Apr 27, 2008 2:00 am

Re: system location in build screen?

Post by Spocks-cuddly-tribble »

Unfortunately, I can't see any prepared functions you could use for this. You have to write your own code with the help of a GUI/string guy like QD/DCER.

Subs you can use for reference or call:

sub_446CB0 CoordinatesStarIdEaxToAdrEsi

sub_4B6B00 Literal_mod 2 by DCER (the first from your link is just for anomalies i.e. stellInfo)
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: system location in build screen?

Post by thunderchero »

yeah i don't understand most of the code to do anything myself either, I doubt QD or Dcer will be any help they have not been active lately.

but it would be a nice patch.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

152 (0x98) Free Bytes (patch)

Post by Tethys »

This frees up 152 bytes in star_names_ procedure, the first step to (potentially) adding real X,Y coordinates to star names. From the looks of it, major and minor race home systems should not be too difficult to append X,Y function after starname generation. I have knowledge of what most Lexicon_Term perform in their functions, as well as major and minor race home system lexicon. So far it appears that there are no Lexicon_Term for the rest of the systems, since uninhabited/non-home star system names are not needing to be changed after galaxy generation like inhabited home systems. For these it may be a little more tricky (help would be needed here), but I do think it may be possible and would not take much effort, since the code to append sector X,Y already exists (anomalies use it), I just don't know how to hook it to the starname bin ?

I only tested the patch quickly, but I anticipate no issues. When one whole section is noped, the home system name failed to display in any location (including on the map and F2 screen). All names still display properly with patch.

Code: Select all

NAME: 152 (0x98) Free Bytes (patch)
AUTHOR: Tethys
DESC: This patch frees up duplicate bytes in the star_name_ procedure (INTENDED FOR MOD DEVS! Use only if you understand!)
DESC: patch file name: Star_Name_152_Free_Bytes.patch
URL: 
TAG: 

# >>  = current value

# <<  = new value

>> 0x00b5a20 B9 28 00 00 00 E8 B6 4C FD FF 8D 7A 08 89 C6 57 89 C8 C1 E9 02 F2 A5 8A C8 80 E1 03 F2 A4 5F E9 4B FF FF FF B8 65 01 00 00 B9 28 00 00 00 E8 8D 4C FD FF 8D 7A 08 89 C6 57 89 C8 C1 E9 02 F2 A5 8A C8 80 E1 03 F2 A4 5F E9 22 FF FF FF B8 BE 03 00 00 B9 28 00 00 00 E8 64 4C FD FF 8D 7A 08 89 C6 57 89 C8 C1 E9 02 F2 A5 8A C8 80 E1 03 F2 A4 5F E9 F9 FE FF FF B8 44 04 00 00 B9 28 00 00 00 E8 3B 4C FD FF 8D 7A 08 89 C6 57 89 C8 C1 E9 02 F2 A5 8A C8 80 E1 03 F2 A4 5F E9 D0 FE FF FF
>> 0x00b5b2e 57 89 C8 C1 E9 02 F2 A5 8A C8 80 E1 03 F2 A4 5F E9 4C FE FF FF

<< 0x00b5a20 EB D5 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 65 01 00 00 EB D5 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 BE 03 00 00 EB D5 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 44 04 00 00 EB D5 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
<< 0x00b5b2e E9 D3 FE FF FF 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
Here is another patch I just made that frees up 75 more bytes:

Code: Select all

NAME: 75 (0x4b) Free Bytes (patch)
AUTHOR: Tethys
DESC: This patch frees up duplicate bytes in the star_name_ procedure (INTENDED FOR MOD DEVS! Use only if you understand!)
DESC: patch file name: Star_Name_75_Free_Bytes.patch
URL: 
TAG: 

# >>  = current value

# <<  = new value

>> 0x00b5c49 E8 92 4A FD FF 89 84 24 A0 00 00 00 E9 7E FC FF FF B8 22 03 00 00 E8 7C 4A FD FF 89 84 24 A0 00 00 00 E9 68 FC FF FF B8 2A 03 00 00 E8 66 4A FD FF 89 84 24 A0 00 00 00 E9 52 FC FF FF B8 A7 05 00 00 E8 50 4A FD FF 89 84 24 A0 00 00 00 E9 3C FC FF FF B8 C8 03 00 00 E8 3A 4A FD FF 89 84 24 A0 00 00 00 E9 26 FC FF FF

<< 0x00b5c49 EB E8 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 22 03 00 00 EB E8 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 2A 03 00 00 EB E8 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 A7 05 00 00 EB E8 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 B8 C8 03 00 00 EB E8 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
Thunderchero, you realize that appending X,Y may also add sector info to star name on map? Apparently all anomalies (except Nebula?) show sector X,Y at the end of their names. Is this something we can live with?
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Build Screen system name with X Y location

Post by thunderchero »

Hi Everyone,

I want to post my attempts to make this happen.

personally I would be happy with any of the following combinations
X Y
"system name" X Y
"system" X Y
basically any combination as long as it has X Y

Here is the info I have accumulated. I am hopeful with some help this will still be able to become reality.

fast call at loc_4F736E this is called with F2 or when switching systems with arrow buttons and dropdown system menu

Code: Select all

4F736E                                                 loc_4F736E:
4F736E BB 1C 00 00 00                                  mov     ebx, 1Ch
4F7373 31 C0                                           xor     eax, eax
4F7375 89 E2                                           mov     edx, esp
4F7377 A0 2A 2B 5A 00                                  mov     al, ds:player_empire
4F737C C7 45 24 00 00 00 00                            mov     dword ptr [ebp+24h], 0
4F7383 E8 A8 3B F4 FF                                  call    empire_color1b_cur_fnt_files
4F7388 31 C0                                           xor     eax, eax
4F738A A0 2A 2B 5A 00                                  mov     al, ds:player_empire
4F738F E8 6C 39 F4 FF                                  call    emps_colors_2
4F7394 89 44 24 14                                     mov     [esp+14h], eax
4F7398 8B 44 24 38                                     mov     eax, [esp+38h]
4F739C BA 40 00 00 00                                  mov     edx, 40h
4F73A1 83 C0 08                                        add     eax, 8
4F73A4 89 54 24 10                                     mov     [esp+10h], edx
4F73A8 E8 13 43 F9 FF                                  call    sub_48B6C0
4F73AD 89 44 24 30                                     mov     [esp+30h], eax
4F73B1 B8 BE 04 00 00                                  mov     eax, 4BEh
4F73B6 E8 25 3F F9 FF                                  call    Lexicon_Term
4F73BB E8 00 43 F9 FF                                  call    sub_48B6C0
4F73C0 50                                              push    eax (push "System")
4F73C1 8B 4C 24 34                                     mov     ecx, [esp+34h]
4F73C5 51                                              push    ecx (push "system name")
4F73C6 68 7C 22 58 00                                  push    offset aSS_0    ; "%s %s"
4F73CB 8D 74 24 0C                                     lea     esi, [esp+0Ch]
4F73CF 83 EC 18                                        sub     esp, 18h
4F73D2 B9 06 00 00 00                                  mov     ecx, 6
4F73D7 89 E7                                           mov     edi, esp
4F73D9 89 C3                                           mov     ebx, eax
4F73DB F3 A5                                           rep movsd
4F73DD E8 DE 68 02 00                                  call    after_some_letter?
4F73E2 89 C1                                           mov     ecx, eax
4F73E4 83 C4 24                                        add     esp, 24h
4F73E7 89 CA                                           mov     edx, ecx
4F73E9 8B 85 F4 00 00 00                               mov     eax, [ebp+0F4h]
4F73EF E8 6C A7 04 00                                  call    textbox_unknown_file_?
4F73F4 8B 44 24 30                                     mov     eax, [esp+30h]
4F73F8 E8 37 64 02 00                                  call    some_Popup_GUI_stuff
4F73FD 89 D8                                           mov     eax, ebx
4F73FF E8 30 64 02 00                                  call    some_Popup_GUI_stuff
4F7404 89 C8                                           mov     eax, ecx
4F7406 E8 29 64 02 00                                  call    some_Popup_GUI_stuff
4F740B 31 C0                                           xor     eax, eax
4F740D 31 D2                                           xor     edx, edx
4F740F A0 2A 2B 5A 00                                  mov     al, ds:player_empire
4F7414 E8 1B 30 F4 FF                                  call    EmpireTabulateResources_Cheat_if_edx1
4F7419 31 C0                                           xor     eax, eax
4F741B A0 2A 2B 5A 00                                  mov     al, ds:player_empire
4F7420 E8 0B A5 F6 FF                                  call    SystemOutputPreview
4F7425 8B 5D 20                                        mov     ebx, [ebp+20h]
4F7428 85 DB                                           test    ebx, ebx
4F742A 0F 85 C4 03 00 00                               jnz     loc_4F77F4
This Loc will get new system id to get "system name" then add lecicon BE 04 "system"
I feel this is where changes need to happen.
4F739C BA 40 00 00 00 mov edx, 40h color of text (nop seems to have no effect)
4F73A1 83 C0 08 add eax, 8 (if 4F73A1 - 4F73AD moved up 5 bytes has ill effects)
4F73A4 89 54 24 10 mov [esp+10h], edx (if 4F73A1 - 4F73AD moved up 5 bytes has ill effects)
4F73A8 E8 13 43 F9 FF call sub_48B6C0 (if 4F73A1 - 4F73AD moved up 5 bytes has ill effects)
4F73AD 89 44 24 30 mov [esp+30h], eax (if 4F73A1 - 4F73AD moved up 5 bytes has ill effects)
4F73A1 83 C0 08 add eax, 8 systinfo + 8 to get name of system to use (if 4F73A1 - 4F73AD moved up 5 bytes has ill effects)
4F73B1 B8 BE 04 00 00 mov eax, 4BEh calls lexicon "system" (if 4F73B1 & 4F73B6 nop will cause double system name)
4F73B6 E8 25 3F F9 FF call Lexicon_Term (if 4F73B1 & 4F73B6 nop will cause double system name)

Now in sub 4B6454 "star_names" there is code to read "stellInfo" to get X Y info.
code section at 4B64A0

Code: Select all

4B64A0 8B 3D CC 36 5A 00                               mov     edi, ds:save_stellInfo
4B64A6 8B 54 39 44                                     mov     edx, [ecx+edi+44h]
4B64AA BB 05 00 00 00                                  mov     ebx, 5
4B64AF 89 D0                                           mov     eax, edx
4B64B1 C1 FA 1F                                        sar     edx, 1Fh
4B64B4 F7 FB                                           idiv    ebx
4B64B6 8B 74 39 48                                     mov     esi, [ecx+edi+48h]
4B64BA 89 C3                                           mov     ebx, eax
4B64BC 89 F2                                           mov     edx, esi
4B64BE 89 F0                                           mov     eax, esi
4B64C0 C1 FA 1F                                        sar     edx, 1Fh
4B64C3 BE 05 00 00 00                                  mov     esi, 5
4B64C8 F7 FE                                           idiv    esi
4B64CA 89 C2                                           mov     edx, eax
4B64CC 8B 04 39                                        mov     eax, [ecx+edi]
4B64CF 83 F8 0B                                        cmp     eax, 0Bh
4B64D2 0F 86 4F 03 00 00                               jbe     loc_4B6827
this code will load stellInfo (can be changed to load systinfo) and read the tga locations on the map to calculate the X Y of a sector.

after that there is a second section 4B64D8 that will use X Y info from 4B6454 to convert to a useable text.

Code: Select all

4B64D8 42                                              inc     edx
4B64D9 52                                              push    edx
4B64DA 83 C3 41                                        add     ebx, 41h
4B64DD 53                                              push    ebx
4B64DE 8B B4 24 A8 00 00 00                            mov     esi, [esp+0A8h]
4B64E5 56                                              push    esi
4B64E6 68 58 F9 57 00                                  push    offset Literal_aSCD ; "%s %c%d"
4B64EB 8D 84 24 84 00 00 00                            lea     eax, [esp+84h]
4B64F2 50                                              push    eax
4B64F3 E8 A1 D8 05 00                                  call    sprintf__add_race_letter_for_filename
4B64F8 A1 CC 36 5A 00                                  mov     eax, ds:save_stellInfo
4B64FD 8D B4 24 88 00 00 00                            lea     esi, [esp+88h]
4B6504 01 C8                                           add     eax, ecx
4B6506 83 C4 14                                        add     esp, 14h
4B6509 8D 78 04                                        lea     edi, [eax+4]
4B650C 45                                              inc     ebp
4B650D 57                                              push    edi
4B650E                                                 loc_4B650E:
4B650E 8A 06                                           mov     al, [esi]
4B6510 88 07                                           mov     [edi], al
4B6512 3C 00                                           cmp     al, 0
4B6514 74 10                                           jz      short loc_4B6526
4B6516 8A 46 01                                        mov     al, [esi+1]
4B6519 83 C6 02                                        add     esi, 2
4B651C 88 47 01                                        mov     [edi+1], al
4B651F 83 C7 02                                        add     edi, 2
4B6522 3C 00                                           cmp     al, 0
4B6524 75 E8                                           jnz     short loc_4B650E
4B6526 5F                                              pop     edi
4B6527 83 C1 58                                        add     ecx, 58h
4B652A E9 61 FF FF FF                                  jmp     loc_4B6490
this is part of what SCT calls the "Literal_mod" that changes alpha/number to number/number for larger galaxies.
This code is used to add X Y to planet section at bottom for stellar object (blackhole 1.2)

With the removal redundant code in Star_name section that Tethys did and some other modification I made I was able to create a sub-section within the Star_Name section that is independant and is not called or used by Star_Name section.

here is a patch with my changes
xy_project.patch
(2.71 KiB) Downloaded 112 times
at 4b663d is new code I hope can be used to X Y to F2 screens?

Code: Select all

4B6637 90                      nop
4B6638 90                      nop
4B6639 90                      nop
4B663A 90                      nop
4B663B 90                      nop
4B663C 90                      nop
4B663D 8B 3D C8 36 5A 00       mov     edi, ds:dword_5A36C8 (edited to call systinfo)
4B6643 8B 54 39 78             mov     edx, [ecx+edi+78h] (edited to systinfo offset of tga location 1)
4B6647 BB 05 00 00 00          mov     ebx, 5
4B664C 89 D0                   mov     eax, edx
4B664E C1 FA 1F                sar     edx, 1Fh
4B6651 F7 FB                   idiv    ebx
4B6653 8B 74 39 7C             mov     esi, [ecx+edi+7Ch] (edited to systinfo offset of tga location 2)
4B6657 89 C3                   mov     ebx, eax
4B6659 89 F2                   mov     edx, esi
4B665B 89 F0                   mov     eax, esi
4B665D C1 FA 1F                sar     edx, 1Fh
4B6660 BE 05 00 00 00          mov     esi, 5
4B6665 F7 FE                   idiv    esi
4B6667 89 C2                   mov     edx, eax (may not be needed part of anomaly check?)
4B6669 8B 04 39                mov     eax, [ecx+edi] (may not be needed part of anomaly check?)
4B666C 90                      nop
4B666D 90                      nop
4B666E 90                      nop
4B666F 90                      nop
4B6670 90                      nop
4B6671 90                      nop
4B6672 90                      nop
4B6673 90                      nop
4B6674 90                      nop
4B6675 90                      nop
4B6676 90                      nop
4B6677 42                      inc     edx
4B6678 52                      push    edx
4B6679 83 C3 01                add     ebx, 1
4B667C 53                      push    ebx
4B667D 8B B4 24 A8 00 00 00    mov     esi, [esp+8+arg_9C]
4B6684 56                      push    esi
4B6685 68 57 F9 57 00          push    offset aSD_D    ; "%s %d.%d"
4B668A 8D 84 24 84 00 00 00    lea     eax, [esp+10h+arg_70]
4B6691 50                      push    eax
4B6692 E8 02 D7 05 00          call    sprintf_ (edited to correct offset)
4B6697 A1 C8 36 5A 00          mov     eax, ds:dword_5A36C8 (edited to call systinfo)
4B669C 8D B4 24 88 00 00 00    lea     esi, [esp+14h+arg_70]
4B66A3 01 C8                   add     eax, ecx
4B66A5 83 C4 14                add     esp, 14h
4B66A8 8D 78 08                lea     edi, [eax+8] (edited for systinfo "name" offset may not be needed)
4B66AB 45                      inc     ebp
4B66AC 57                      push    edi
4B66AD E9 CE 01 00 00          jmp     loc_4B6880 (jump to convert to text 13 bytes open if needed)
4B6880 8A 06                   mov     al, [esi]
4B6882 88 07                   mov     [edi], al
4B6884 3C 00                   cmp     al, 0
4B6886 74 10                   jz      short loc 4B6898 (add next letter or exit)
4B6888 8A 46 01                mov     al, [esi+1]
4B688B 83 C6 02                add     esi, 2
4B688E 88 47 01                mov     [edi+1], al
4B6891 83 C7 02                add     edi, 2
4B6894 3C 00                   cmp     al, 0
4B6896 75 E8                   jnz     short loc 4B6880 (add next letter or exit)
4B6898 5F                      pop     edi (this should be a push, we don't want it to write to systinfo)
4B6899 C3                      retn (21 bytes open if needed)
I think with all my attempts I am having issues with registry conflicts either it is already being used or has wrong info.
I have left nop space for editing at beginning, middle and end of code.

thanks for reading
thunderchero
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: system location in build screen?

Post by thunderchero »

Hi Everyone,

I have been attempting this project myself and had some slight progress. Here is a screenshot of what I have achieved so far.
stage1.jpg
stage1.jpg (192.47 KiB) Viewed 3751 times
As you see I have gotten it to display system name and correct location. :grin: But....

there is issues, you will notice in planet area at bottom it displays X Y only (system name missing) this is due to the code I had to use is writing the systinfo saved file. :shock: This causes multiple issue example X Y will start displaying twice and no system name.

next issue when selecting F2 or from system menu game will crash.

Here is the code I am calling at 4f73b1 0x0f67b1

Code: Select all

004F73B1 B8 BE 04 00 00  -> E8 8B F2 FB FF        mov     eax, 4BEh (call new code)
004F73B6 E8 25 3F F9 FF  -> 90 90 90 90 90        call    Lexicon_Lexicon_GetEntry (nop)

Code: Select all

004B6641 8B 57 78                      mov     edx, [edi+78h]
004B6644 BB 05 00 00 00                mov     ebx, 5
004B6649 89 D0                         mov     eax, edx
004B664B C1 FA 1F                      sar     edx, 1Fh
004B664E F7 FB                         idiv    ebx
004B6650 8B 77 7C                      mov     esi, [edi+7Ch]
004B6653 89 C3                         mov     ebx, eax
004B6655 89 F0                         mov     eax, esi
004B6657 C1 FA 1F                      sar     edx, 1Fh
004B665A BE 05 00 00 00                mov     esi, 5
004B665F F7 FE                         idiv    esi
004B6661 89 C2                         mov     edx, eax
004B6663 89 E6                         mov     esi, esp
004B6665 56                            push    esi
004B6666 42                            inc     edx
004B6667 52                            push    edx
004B6668 83 C3 01                      add     ebx, 1
004B666B 53                            push    ebx
004B666C 68 08 81 57 00                push    offset aD_D_0   ; "%d.%d"
004B6671 8D 46 74                      lea     eax, [esi+74h]
004B6674 50                            push    eax
004B6675 E8 1F D7 05 00                call    sprintf_
004B667A 8B C7                         mov     eax, edi
004B667C 8D 76 74                      lea     esi, [esi+74h]
004B667F 83 C4 14                      add     esp, 14h
004B6682 8D 78 08                      lea     edi, [eax+8]
004B6685 57                            push    edi
004B6686 8A 06                         mov     al, [esi]
004B6688 88 07                         mov     [edi], al
004B668A 3C 00                         cmp     al, 0
004B668C 74 10                         jz      short loc_4B669E
004B668E 8A 46 01                      mov     al, [esi+1]
004B6691 83 C6 02                      add     esi, 2
004B6694 88 47 01                      mov     [edi+1], al
004B6697 83 C7 02                      add     edi, 2
004B669A 3C 00                         cmp     al, 0
004B669C 75 E8                         jnz     short loc_4B6686
004B669E 89 F8                         mov     eax, edi
004B66A0 58                            pop     eax
004B66A1 C3                            retn
I think my writing to systinfo issue starts at 4B6686 it was the only code I could find to get code to work.

I still think the format of stack is not correct, but have no idea how to correct format.

here is what both stacks look like. The one on left is what it should be and the one on right is what I am using.
stack1.jpg
stack1.jpg (67.25 KiB) Viewed 3751 times
tomorrow I will look at it a little more and see if I can restore some of the registry value to see if this helps with switching and F2 issue.

But if anyone knows how to fix the stack issue without writing systinfo it would help. I think it starts the writing process at 4B6686?

thanks for reading
thunderchero
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: system location in build screen?

Post by thunderchero »

Just a quick update on my progress.

1. I was able to prevent writing to systinfo file
2. now I am able to double click systems and use arrow buttons to move to next system, with X Y in F2 screen on all systems
3. using summary screen/systems to go to F2 screen is buggy (hit or miss if it will load or crash)
4. using system menu in F2 screen will always crash still
5. no other "system name" locations are displaying X Y

I have made several code changes and will post if I make any more progress or if they are requested.

thunderchero
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Patch for system location in build screen?

Post by thunderchero »

Hi Everyone,

I have a patch to display the X Y of a system in the F2 screen
here is a short video of how it displays


This patch uses the Literal mod code (alpha-number -> number-number for xy) that was developed for larger maps.
Literal mod is required and is part of this patch.
if the Literal mod is already installed the patch will display red (conflicts) this would be expected.
as always make a backup of your trek.exe before applying this patch.

here is patch for uses with botf patcher
xy_in_f2.patch
(3.04 KiB) Downloaded 103 times
NOTE this will not work on current beta version of Galaxy mod

here is code changes

changes in 4F7320 (F2 screen sub)
at 4F73A1 I shifted code 2 bytes to duplicate registry of systinfo (mov edi, eax) so new code would always have system info
at 4F73B3 I removed code for lexicon id ("SYSTEM") and get lexicon terms and added call to new code (call loc_4B6640)

Code: Select all

4F73A1 89 C7                                         mov     edi, eax      (get systinfo for new code)
4F73A3 83 C0 08                                      add     eax, 8
4F73A6 89 54 24 10                                   mov     [esp+10h], edx
4F73AA E8 11 43 F9 FF                                call    sub_48B6C0
4F73AF 89 44 24 30                                   mov     [esp+30h], eax
4F73B3 E8 88 F2 FB FF                                call    loc_4B6640      (call new code to display X Y)
4F73B8 90                                            nop
4F73B9 90                                            nop
4F73BA 90                                            nop
code changes at 4B6640 (within Star_names sub section)
This code is basically the same code as 4B64A0 and 4B64D8 but with many changes
first the code for anomaly name was removed.
code was changed to call systinfo instead of stellInfo
I borrowed a wildcard %d.%d from AI diag sub routine (should not be missed)
4B6642 - 4B6660 calculates X Y
4B6662 - 4B6667 pushes calculated info into wildcards
4B6668 wildcard offset
4B666D - 4B6674 moves string into esp for sprintf
4B6675 call sprintf sub section
4B667A mov string from esp to eax to use in F2 screen code
4B6681 resets offset of esp for font
4B6684 - 4B668E resets registries to values before entering sub 4B6640
4B6693 return to F2 sub section to continue with vanilla code for F2 screen

Code: Select all

4B6640                               loc_4B6640:
4B6640 89 F9                         mov     ecx, edi
4B6642 8B 57 78                      mov     edx, [edi+78h]    
4B6645 BB 05 00 00 00                mov     ebx, 5
4B664A 89 D0                         mov     eax, edx
4B664C C1 FA 1F                      sar     edx, 1Fh
4B664F F7 FB                         idiv    ebx
4B6651 8B 77 7C                      mov     esi, [edi+7Ch]
4B6654 89 C3                         mov     ebx, eax
4B6656 89 F0                         mov     eax, esi
4B6658 C1 FA 1F                      sar     edx, 1Fh
4B665B BE 05 00 00 00                mov     esi, 5
4B6660 F7 FE                         idiv    esi
4B6662 40                            inc     eax
4B6663 50                            push    eax
4B6664 83 C3 01                      add     ebx, 1
4B6667 53                            push    ebx
4B6668 68 08 81 57 00                push    offset aD_D_0   ; "%d.%d"
4B666D 8D 84 24 88 00 00 00          lea     eax, [esp+0Ch+arg_78]
4B6674 50                            push    eax
4B6675 E8 1F D7 05 00                call    sprintf_
4B667A 8D 84 24 8C 00 00 00          lea     eax, [esp+10h+arg_78]
4B6681 83 C4 10                      add     esp, 10h
4B6684 BB 1C 00 00 00                mov     ebx, 1Ch
4B6689 BA 40 00 00 00                mov     edx, 40h
4B668E BE 02 00 00 00                mov     esi, 2
4B6693 C3                            retn
Location of borrowed a wildcard %d.%d from AI diag sub routine

Code: Select all

578108 25 64 2E 25 64 00             aD_D_0          db '%d.%d',0
so far in all my tests this code changes have ran very smoothly with no errors.
If you encounter any issues let me know

enjoy
thunderchero
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1883
Joined: Sun Apr 27, 2008 2:00 am

Re: system location in build screen?

Post by Spocks-cuddly-tribble »

Congratulations, thunderchero, outstanding work!

You didn't use sub_446CB0 and sub_4B6B00 (parts of BotF standard code for this procedure) but instead optimized and simplified your own code by learnig how to compose an askii string in asm. So, in the end, it was good that you first missed my and Tethys' notes that the stellInfo code example stores the position as part of the anomaly name. Simply because learning from this code seems easier than adapting the standard code.

May I ask how many working hours you needed in total?
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: system location in build screen?

Post by thunderchero »

Spocks-cuddly-tribble wrote: Thu Apr 01, 2021 1:36 pm Congratulations, thunderchero, outstanding work!

You didn't use sub_446CB0 and sub_4B6B00 (parts of BotF standard code for this procedure) but instead optimized and simplified your own code by learnig how to compose an askii string in asm. So, in the end, it was good that you first missed my and Tethys' notes that the stellInfo code example stores the position as part of the anomaly name. Simply because learning from this code seems easier than adapting the standard code.

May I ask how many working hours you needed in total?
Thank you,

It took too many hours lol
but if I was to guess about 80 hours, most of that time was spent studying how the registry moved data and what data was in each.

I did not miss your's and Tethys' notes, I studied 4B64A0 and 4B64D8 the most. but did also study those subs also.

I had so many failed attempt and crashes before I even got any results.

But I have learned from this and better understand how the de-bug mode works in ida and it's value in coding this type of changes.

thunderchero
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: system location in build screen?

Post by Tethys »

Pleased to report that I've got this working on latest version of GALM. Some values were not being adjusted and it was having a complete fit. It may be a good idea to add to the patch these locations in question (use same values for both vanilla and modded values):

Code: Select all

0x000B5A04          89 C6
0x000B5A56          89
New patch code
► Show Spoiler
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: system location in build screen?

Post by thunderchero »

Tethys wrote: Thu Apr 01, 2021 5:36 pm It may be a good idea to add to the patch these locations in question (use same values for both vanilla and modded values):
while I agree it would not hurt to add extra bytes to patch, but the patcher has the ability to show conflicts vs vanilla and if you add those extra bytes conflict would not display.

if any thing I should have packaged 2 patches XY patch for F2 screen and separate file for Literal mod patch.

it is just best to have a special patch in this case for galaxy mod beta. any way your mod will be updated next week and your patch will no longer be needed :grin:
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7848
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: system location in build screen?

Post by thunderchero »

added patch to first post of topic.
Post Reply

Return to “General Modding Information/Questions”