Since v2.0 is published, an advertisement function has been added. While it is usually treated as a nuisance, it can be modified to provide customized advertisement and external links.
Overview
Advertisement editing is a independent field of modification from exe editing, since it does not involve hex editing and using resource hacker. A common text editor and image editor are enough. The editing is solely done by modifying ad0.txt in data folder, and ad0.bmp in sprite/sys folder.
Note: ad1.txt is a "safe" copy of ad0.txt in the same folder, while ad1.bmp is safe copy of ad0.bmp. It is recommended to retain both safe files as backups at their original locations.
Via editing advertisement, you can change the links to desired website such as your homepage, game forum or wiki. You can change the graphics so they fit in your game. You can also feed information in the navigation panel just like vanilla LF2 using it to advertise.
P.S. There are _ad0.txt, _ad1.txt and _adinfo.txt in data folder. They are read by lf2.exe but should not be edited.
adinfo.txt dictates which adX.txt and adX.bmp is read. Refer to the adinfo.txt chapter for details.
ad0.bmp
Below is a modified ad0.bmp paired with a LF2 screen incorporated with the image. The A, B, C, D letters are added and rectangles are added to show area of reference:
The regions that ad0.bmp is referenced are shown with colored boundary and a number besides each of them:
1. Blinking banner on the top of screen
It uses two portions of image for blinking effect.
The external link and image can be edited, but currently no method is found to change interval of blinking.
2. Navigable panel on the right of screen
Four square image blocks on ad0.bmp are referenced to build the panel. The left/right arrows are not included in ad0.bmp but referenced from an image inside lf2.exe. You will need to use resource hacker to edit the arrows.
The yellow rectangle indicates the full area which ad0.bmp is referenced to build the panel. The letters A, B, C and D are added to indicate the positions of 4 unused slots which can be customized to show maximum of 8 panel blocks instead of the default 4.
The external link, image, probability of which image is showing when game starts, and how long will that advertisement will show until the panel retracts can be edited. There is also a gimmick that allows the default image to be blank.
3. External links at the bottom (and possibly the whole lower half) of screen
The external link, image and respective position of link can be modified. A maximum of 25 links can be placed via ba tag. All regions of links must be rectangle, also if it overlaps area of copyright claim on the bottom right corner of screen, the link provided by copyright claim will override a ba tag, therefore it's not useful to use a different url than copyright claim at its position, but you can still modify ad0.bmp to "erase" the existence of copyright claim, although you can still click it.
The green rectangle indicates the whole area which ad0.bmp is referenced for graphic for external links.
ad0.txt
A default ad0.txt (updated to last version of ads) should look like followed.
The file can be divided into 5 parts:
1. Beginning - informs about last update
2. ba tags - defines external links at the bottom (and possibly the whole lower half) of screen
3. ta tags - defines external links and appearance of the navigable panel on the right of screen
4. un tag - defines external link of blinking banner on the top of screen
5. y tag - defined vertical displacement of menu graphics and copyright claim
Beginning section
Beginning section consists of the very first line of ad0.txt:
The 8-digit number in form of YYYYMMDD indicates time of last update of advertisement system.
If the date is later than 20140201 (1 Feb, 2014), advertisement won't update because there is no patch afterwards.
To make it safe, set it to a far future time like 99991231.
The number and "en" afterwards are currently unknown of their use.
ba tags
ad0.txt consists of ba tags that define external links at the bottom half of the screen.
Although the links in vanilla LF2 are all at bottom of screen, they can be placed literally everywhere, but for convenience, I will explain how external link blocks work first.
The screen is composed of three parts: images stored in lf2.exe, images referenced from ad0.bmp and generated characters from exe code (copyright claim). As seen in the paired image, the lower rectangle covers the lower part of the screen which also blocks the upper half of copyright claim. The top of lower white rectangle indicates the upper boundary of advertisement you can place by modifying ad0.bmp. It does not mean you cannot place link blocks on the upper half, but doing so requires you to use resource hacker to replace menu images.
The link locations are managed by ad0.txt independent from ad0.bmp. As long as an appropriate image that indicates external link is placed, ad0.txt can be modified to suit the need.
Back to ba tags, they look like these:
A ba tag starts with ba and ends with bae. It has 4 number and 1 url parameters.
The first two are x and y-axis top-left corner position of external tag, and last two are length and height of tag. The position is relative to the absolute top-left corner of the screen, not the top-left corner of green rectangle. The top-left corner of green rectangle is (0,422), which is also written on the first ba tag:
The url indicates the external link, it can instead be set to ? and disable the external link.
While the area of ba tags can overlap with each other, I have never tried on this and even so the indication that a tag is hovered on will always be a rectangle. Therefore it is better to make sure all tags do not have overlapped area. The default ad0.txt has already done this, you can enable the links and move cursor around the game screen to see how they are placed.
The position of "Advertisement:" wording above the external links is determined by the first two parameters of first enabled ba tag. It will always be above the intended position of this tag. The wording can only be edited via resource hacker, which is a better way than using ad0.txt to make it off screen, due to size limit of the wording in menu graphic inside lf2.exe.
There must be exactly 25 ba tags in ad0.txt, otherwise the whole ba tag system will fail. Make use of disabled tags (url is ?) to limit external link used.
ta tags
ta tags define external links of retractable panel at the right side of screen.
A ta tag has 3 number and 1 url parameters. The first two defines the probability of this particular advertisement being shown when game starts.
It appears the game reads the largest number out of all second parameters in ta tag (abbr maxta2nd) and rolls a rand() mod maxta2nd. If the number is between the first and second number of that ta tag, the starting advertisement will be that tag. (More precisely should be not less than first and less than second) If two or more tags are qualified to be shown, the first one in ad0.txt is always shown.
The third parameter indicates how long will the panel last before it retracts without mouse cursor moving over it. It is calculated in tick unit, that is 1/30s per frame. Therefore 30 is equivalent to 1 second. Putting it below 10 will cause the panel to glitch, quickly retracting and expanding repeatedly.
If a ta tag is disabled, the whole middle part of ad0.txt will still show all graphics in loading screen. However if the tag is disabled but forced to shown when game starts (details below) that portion of graphic will not show.
Important: All advertisement graphics will be shown in loading screen at the same time. This could become crowded if you use more than 4 panel images:
The "Advertisement:" is automatically placed above the first active advertisement.
ta tags - in depth study
There are 8 ta tags but only the last 4 are typically used, the first 4 are disabled by default, but can be enabled which then use the blocks located at A, B, C and D in the paired image.
The tags can be modified to show blank image at the beginning. This requires disabling a tag despite increasing its appearance chance as much as possible.
The first tag has 0 99999996 as probability parameter. It means it has 99999996/99999999 chance to shown when the game starts, but because it is disabled, when clicking on left/right arrow, it will not be navigable afterwards. Make sure that the disabled tag has first parameter equal to 0 so it will not fail to show blank slate.
To use all advertisement but to show blank image when game starts, put the first parameter to very high value instead. This will cause the image loading to (very probably) fail when game starts.
This can even be used to allow all eight advertisements to show when navigated, but show blank image at startup:
Also note that you must make second parameter larger than first parameter to enable a tag.
un tag
un tag defines external link of blinking banner on the top of screen.
There is only one url parameter that is usable. The number parameter doesn't seem of any use, and it is recommended to leave it alone at 31, since if it is lower than 31, the banner will fail.
y tags
Credits to Silverthorn.
y tag has two number parameters. The second is the vertical displacement of copyright claim and the first is vertical displacement of all graphics excluding advertisement and copyright claim.
Both numbers are 0 by default. However, background image has top-left corner equivalent to top-left corner of screen (other graphics are arranged accordingly), while copyright claim is at bottom-right corner by default. Both numbers can be positive or negative, therefore copyright claim can be place out of screen, at center-right or top-right. Beware that putting -99 at any number in ad0.txt will result in a code break and prematurely end the file reading.
Unfortunately there is no tag to change x-axis position of either of them. Such x tag doesn't exist and attempting to add x tag will cause the whole advertisement system to fail.
adinfo.txt
Credits to Silverthorn.
adinfo.txt only contains a line, below is an example:
The first date-like parameter is the last time lf2.exe has updated its advertisement, in form of YYYY/MM/DD/HH/MM/SS.
The second parameter dictates which adX.txt and adX.bmp is referenced. When the game starts, it checks if adX.bmp and adX.txt exists, where X is the second parameter. If either of them doesn't exist, they will be downloaded from the server.
Frequently asked questions
Q. What if I wanted to remove all advertisements altogether?
A. Replace all url in ad0.txt/ad1.txt with ?, and replace the whole ad0.bmp/ad1.bmp with a black (#000000) image of same size.
Q. Can I edit the copyright claim:
A. You cannot change the link even with ba tags. The only way to do this is to modify lf2.exe to change the link. However, I showed how to erase the claim visually, therefore you should be able to place other images onto it as well.
Q. Can I show an image in panel but not in loading screen, and the other way around:
A. You must make use of color masking to make images having same color as the loading screen to fool the players into believing nothing is shown in the screen. (Transparency is applied to #000000 pitch black, use it at your advantage) The other way is easy, just use resource editor to replace loading image.
Q. My game screen shows black blocks!
A. The lf2 graphics including ad0.bmp/ad1.bmp are compressed in optimized 256 color. Use an image editor to save it in RGB mode first, do your edits and then compress. Pay attention to the palette and the background color. Alternatively you can leave it alone at RGB, it doesn't bother much since modern computers loads the game at a whim.
Q. When I save ad0.bmp, it shows bad graphics! What should I do?
A. Refer to the last question, Microsoft paint has a bad habit to reset the palette if you save an optimized 256-color image into 256-color format again. Please make a copy in RGB first and compress once you have finished.
Q. I have edited and edited and nothing changed when I started the game!
A. Refer to adinfo.txt, find the second number which indicates which image will be used: 0 means ad0.txt and ad0.bmp will be used.
Q. There is no mirror images for ad0.bmp and ad1.bmp.
A. There is no need for the game to generate mirror images of advertisement.
Q. Can I make an advertisement not in a shape of rectangle?
A. Theoretically yes. You will need to align multiple ba tags for area of external link and also an image that fits will with the white rectangle bracket when cursor is hovered above it though.
Q. Does messing with advertisement make Marti unhappy?
A. You should not claim LF2 is owned and created by yourself. As a rule of thumb I retain a modified version of copyright claim in my LF2 version. Apart from this, please also support Marti and Starsky's new products.
Overview
Advertisement editing is a independent field of modification from exe editing, since it does not involve hex editing and using resource hacker. A common text editor and image editor are enough. The editing is solely done by modifying ad0.txt in data folder, and ad0.bmp in sprite/sys folder.
Note: ad1.txt is a "safe" copy of ad0.txt in the same folder, while ad1.bmp is safe copy of ad0.bmp. It is recommended to retain both safe files as backups at their original locations.
Via editing advertisement, you can change the links to desired website such as your homepage, game forum or wiki. You can change the graphics so they fit in your game. You can also feed information in the navigation panel just like vanilla LF2 using it to advertise.
P.S. There are _ad0.txt, _ad1.txt and _adinfo.txt in data folder. They are read by lf2.exe but should not be edited.
adinfo.txt dictates which adX.txt and adX.bmp is read. Refer to the adinfo.txt chapter for details.
ad0.bmp
Below is a modified ad0.bmp paired with a LF2 screen incorporated with the image. The A, B, C, D letters are added and rectangles are added to show area of reference:
The regions that ad0.bmp is referenced are shown with colored boundary and a number besides each of them:
1. Blinking banner on the top of screen
It uses two portions of image for blinking effect.
The external link and image can be edited, but currently no method is found to change interval of blinking.
2. Navigable panel on the right of screen
Four square image blocks on ad0.bmp are referenced to build the panel. The left/right arrows are not included in ad0.bmp but referenced from an image inside lf2.exe. You will need to use resource hacker to edit the arrows.
The yellow rectangle indicates the full area which ad0.bmp is referenced to build the panel. The letters A, B, C and D are added to indicate the positions of 4 unused slots which can be customized to show maximum of 8 panel blocks instead of the default 4.
The external link, image, probability of which image is showing when game starts, and how long will that advertisement will show until the panel retracts can be edited. There is also a gimmick that allows the default image to be blank.
3. External links at the bottom (and possibly the whole lower half) of screen
The external link, image and respective position of link can be modified. A maximum of 25 links can be placed via ba tag. All regions of links must be rectangle, also if it overlaps area of copyright claim on the bottom right corner of screen, the link provided by copyright claim will override a ba tag, therefore it's not useful to use a different url than copyright claim at its position, but you can still modify ad0.bmp to "erase" the existence of copyright claim, although you can still click it.
The green rectangle indicates the whole area which ad0.bmp is referenced for graphic for external links.
ad0.txt
A default ad0.txt (updated to last version of ads) should look like followed.
Code:
20140201 10 en
ba 0 422 132 32 ? bae
ba 132 422 132 32 ? bae
ba 264 422 132 32 ? bae
ba 396 422 132 32 ? bae
ba 528 422 132 32 ? bae
ba 660 422 132 32 ? bae
ba 0 454 132 32 ? bae
ba 132 454 132 32 ? bae
ba 264 454 132 32 ? bae
ba 396 454 132 32 ? bae
ba 528 454 132 32 ? bae
ba 660 454 132 32 ? bae
ba 0 486 132 32 ? bae
ba 132 486 132 32 ? bae
ba 264 486 132 32 ? bae
ba 396 486 132 32 ? bae
ba 528 486 132 32 ? bae
ba 660 486 132 32 ? bae
ba 0 518 462 32 http://www.ztage.com/ bae
ba 467 520 108 28 http://www.ztage.com/forum/ bae
ba 264 518 132 32 ? bae
ba 396 518 132 32 ? bae
ba 528 518 132 32 ? bae
ba 660 518 132 32 ? bae
ta 0 0 0 ? tae
ta 0 0 0 ? tae
ta 0 0 0 ? tae
ta 0 0 0 ? tae
ta 0 196 580 http://www.herofighter.com/?utm_source=lf2exe&utm_medium=cpm&utm_campaign=lf2exe tae
ta 196 198 580 http://www.littlefighter.com/figure_index.html tae
ta 198 400 580 http://www.phygame.com tae
ta 400 5800 3000 http://chickiebear.com tae
un 31 http://www.herofighter.com/?utm_source=lf2exe&utm_medium=cpm&utm_campaign=lf2exe une
y 0 100 ye
<end>
The file can be divided into 5 parts:
1. Beginning - informs about last update
2. ba tags - defines external links at the bottom (and possibly the whole lower half) of screen
3. ta tags - defines external links and appearance of the navigable panel on the right of screen
4. un tag - defines external link of blinking banner on the top of screen
5. y tag - defined vertical displacement of menu graphics and copyright claim
Beginning section
Beginning section consists of the very first line of ad0.txt:
Code:
20140201 10 en
The 8-digit number in form of YYYYMMDD indicates time of last update of advertisement system.
If the date is later than 20140201 (1 Feb, 2014), advertisement won't update because there is no patch afterwards.
To make it safe, set it to a far future time like 99991231.
The number and "en" afterwards are currently unknown of their use.
ba tags
ad0.txt consists of ba tags that define external links at the bottom half of the screen.
Although the links in vanilla LF2 are all at bottom of screen, they can be placed literally everywhere, but for convenience, I will explain how external link blocks work first.
The screen is composed of three parts: images stored in lf2.exe, images referenced from ad0.bmp and generated characters from exe code (copyright claim). As seen in the paired image, the lower rectangle covers the lower part of the screen which also blocks the upper half of copyright claim. The top of lower white rectangle indicates the upper boundary of advertisement you can place by modifying ad0.bmp. It does not mean you cannot place link blocks on the upper half, but doing so requires you to use resource hacker to replace menu images.
The link locations are managed by ad0.txt independent from ad0.bmp. As long as an appropriate image that indicates external link is placed, ad0.txt can be modified to suit the need.
Back to ba tags, they look like these:
Code:
ba 660 486 132 32 ? bae
ba 0 518 462 32 http://www.ztage.com/ bae
A ba tag starts with ba and ends with bae. It has 4 number and 1 url parameters.
The first two are x and y-axis top-left corner position of external tag, and last two are length and height of tag. The position is relative to the absolute top-left corner of the screen, not the top-left corner of green rectangle. The top-left corner of green rectangle is (0,422), which is also written on the first ba tag:
Code:
ba 0 422 132 32 ? bae
The url indicates the external link, it can instead be set to ? and disable the external link.
While the area of ba tags can overlap with each other, I have never tried on this and even so the indication that a tag is hovered on will always be a rectangle. Therefore it is better to make sure all tags do not have overlapped area. The default ad0.txt has already done this, you can enable the links and move cursor around the game screen to see how they are placed.
The position of "Advertisement:" wording above the external links is determined by the first two parameters of first enabled ba tag. It will always be above the intended position of this tag. The wording can only be edited via resource hacker, which is a better way than using ad0.txt to make it off screen, due to size limit of the wording in menu graphic inside lf2.exe.
There must be exactly 25 ba tags in ad0.txt, otherwise the whole ba tag system will fail. Make use of disabled tags (url is ?) to limit external link used.
ta tags
ta tags define external links of retractable panel at the right side of screen.
A ta tag has 3 number and 1 url parameters. The first two defines the probability of this particular advertisement being shown when game starts.
It appears the game reads the largest number out of all second parameters in ta tag (abbr maxta2nd) and rolls a rand() mod maxta2nd. If the number is between the first and second number of that ta tag, the starting advertisement will be that tag. (More precisely should be not less than first and less than second) If two or more tags are qualified to be shown, the first one in ad0.txt is always shown.
The third parameter indicates how long will the panel last before it retracts without mouse cursor moving over it. It is calculated in tick unit, that is 1/30s per frame. Therefore 30 is equivalent to 1 second. Putting it below 10 will cause the panel to glitch, quickly retracting and expanding repeatedly.
If a ta tag is disabled, the whole middle part of ad0.txt will still show all graphics in loading screen. However if the tag is disabled but forced to shown when game starts (details below) that portion of graphic will not show.
Important: All advertisement graphics will be shown in loading screen at the same time. This could become crowded if you use more than 4 panel images:
The "Advertisement:" is automatically placed above the first active advertisement.
ta tags - in depth study
There are 8 ta tags but only the last 4 are typically used, the first 4 are disabled by default, but can be enabled which then use the blocks located at A, B, C and D in the paired image.
The tags can be modified to show blank image at the beginning. This requires disabling a tag despite increasing its appearance chance as much as possible.
Code:
ta 0 99999996 3000 ? tae
ta 99999996 99999997 580 http://www.herofighter.com/?utm_source=lf2exe&utm_medium=cpm&utm_campaign=lf2exe tae
ta 99999997 99999998 580 http://www.littlefighter.com/figure_index.html tae
ta 99999998 99999999 580 http://www.phygame.com tae
The first tag has 0 99999996 as probability parameter. It means it has 99999996/99999999 chance to shown when the game starts, but because it is disabled, when clicking on left/right arrow, it will not be navigable afterwards. Make sure that the disabled tag has first parameter equal to 0 so it will not fail to show blank slate.
To use all advertisement but to show blank image when game starts, put the first parameter to very high value instead. This will cause the image loading to (very probably) fail when game starts.
Code:
ta 99999996 99999997 580 http://www.herofighter.com/?utm_source=lf2exe&utm_medium=cpm&utm_campaign=lf2exe tae
ta 99999997 99999998 580 http://www.littlefighter.com/figure_index.html tae
ta 99999998 99999999 580 http://www.phygame.com tae
ta 99999995 99999999 3000 http://chickiebear.com tae
This can even be used to allow all eight advertisements to show when navigated, but show blank image at startup:
Code:
ta 99999991 99999992 90 http://1.org tae
ta 99999992 99999993 90 http://2.org tae
ta 99999993 99999994 90 http://3.org tae
ta 99999994 99999995 580 http:/41.org tae
ta 99999995 99999996 580 http://www.herofighter.com/?utm_source=lf2exe&utm_medium=cpm&utm_campaign=lf2exe tae
ta 99999996 99999997 580 http://www.littlefighter.com/figure_index.html tae
ta 99999997 99999998 580 http://www.phygame.com tae
ta 99999998 99999999 3000 http://chickiebear.com tae
Also note that you must make second parameter larger than first parameter to enable a tag.
un tag
un tag defines external link of blinking banner on the top of screen.
There is only one url parameter that is usable. The number parameter doesn't seem of any use, and it is recommended to leave it alone at 31, since if it is lower than 31, the banner will fail.
y tags
Credits to Silverthorn.
y tag has two number parameters. The second is the vertical displacement of copyright claim and the first is vertical displacement of all graphics excluding advertisement and copyright claim.
Both numbers are 0 by default. However, background image has top-left corner equivalent to top-left corner of screen (other graphics are arranged accordingly), while copyright claim is at bottom-right corner by default. Both numbers can be positive or negative, therefore copyright claim can be place out of screen, at center-right or top-right. Beware that putting -99 at any number in ad0.txt will result in a code break and prematurely end the file reading.
Unfortunately there is no tag to change x-axis position of either of them. Such x tag doesn't exist and attempting to add x tag will cause the whole advertisement system to fail.
adinfo.txt
Credits to Silverthorn.
adinfo.txt only contains a line, below is an example:
Code:
2018/11/08/19/06/46 0 10 <end>
The first date-like parameter is the last time lf2.exe has updated its advertisement, in form of YYYY/MM/DD/HH/MM/SS.
The second parameter dictates which adX.txt and adX.bmp is referenced. When the game starts, it checks if adX.bmp and adX.txt exists, where X is the second parameter. If either of them doesn't exist, they will be downloaded from the server.
Frequently asked questions
Q. What if I wanted to remove all advertisements altogether?
A. Replace all url in ad0.txt/ad1.txt with ?, and replace the whole ad0.bmp/ad1.bmp with a black (#000000) image of same size.
Q. Can I edit the copyright claim:
A. You cannot change the link even with ba tags. The only way to do this is to modify lf2.exe to change the link. However, I showed how to erase the claim visually, therefore you should be able to place other images onto it as well.
Q. Can I show an image in panel but not in loading screen, and the other way around:
A. You must make use of color masking to make images having same color as the loading screen to fool the players into believing nothing is shown in the screen. (Transparency is applied to #000000 pitch black, use it at your advantage) The other way is easy, just use resource editor to replace loading image.
Q. My game screen shows black blocks!
A. The lf2 graphics including ad0.bmp/ad1.bmp are compressed in optimized 256 color. Use an image editor to save it in RGB mode first, do your edits and then compress. Pay attention to the palette and the background color. Alternatively you can leave it alone at RGB, it doesn't bother much since modern computers loads the game at a whim.
Q. When I save ad0.bmp, it shows bad graphics! What should I do?
A. Refer to the last question, Microsoft paint has a bad habit to reset the palette if you save an optimized 256-color image into 256-color format again. Please make a copy in RGB first and compress once you have finished.
Q. I have edited and edited and nothing changed when I started the game!
A. Refer to adinfo.txt, find the second number which indicates which image will be used: 0 means ad0.txt and ad0.bmp will be used.
Q. There is no mirror images for ad0.bmp and ad1.bmp.
A. There is no need for the game to generate mirror images of advertisement.
Q. Can I make an advertisement not in a shape of rectangle?
A. Theoretically yes. You will need to align multiple ba tags for area of external link and also an image that fits will with the white rectangle bracket when cursor is hovered above it though.
Q. Does messing with advertisement make Marti unhappy?
A. You should not claim LF2 is owned and created by yourself. As a rule of thumb I retain a modified version of copyright claim in my LF2 version. Apart from this, please also support Marti and Starsky's new products.