Skip to content

Script Reference

D.W edited this page Apr 24, 2020 · 1 revision

Script Reference

General notes about pixel coordinates

Since the original game was 640x480, and the new game was targeted for a resolution of 1280x960, many functions which take in, for example, a pixel coordinate of 640, will actually result in a pixel coordinate of 1280 (that is, the game will internally double a lot of arguments relating to pixel coordinates). There are also things like if you prefix ':b;' to an image's path, the image will be loaded with 1:1 scaling, but if you don't use the prefix, the image will be scaled 2x upon loading.

The lsp_var commands and smilar

After trying to fix this issue, I found the following:

  • all of the lsp_var_* (Load Sprite where the Variable is specified) commands eventually call the lspnewold_trans (Load Sprite New Old Transparent) with different arguments
  • The lspnewold_trans contains code to center sprites (called by functions like *lsp_var_center. However they've done something a bit special (which mainly affects the Question arcs):
    • To have the same lsp commands work for the base sprites AND the pachinko sprites, they made the lspNewOld_trans function do the following:
      • load the old sprite ALWAYS (even if you are on 'new sprites mode')
      • load the new sprite, only if you are on 'new sprites mode'
      • if centering is enabled and you are rendering the New Sprites (for example, from lsp_var_center with new sprites ON), the center coordinate is calculated as (XCoordinate - OldSpriteCenter + NewSpriteCenter).
      • also, normally to find the center of a sprite, you divide by 2. However, due to the pixel doubling in this new version of the game, the sprite's width and height are divided by 2 * 2 = divided by 4.
    • Functions like *lsp_var which don't center the sprites are unaffected, as they work in raw pixel coordinates (HOWEVER remember that pixel coordinates are multiplied by 2 internally by the game engine)

Transparency modes for .BMP images

I was trying to fix something in the game and couldn't get a plain white .bmp image to display. This was because I misunderstood how the transparency of images are loaded:

For .PNG files, it just uses the .png alpha channel (I think...)
For .BMP files, it uses the following (see the 'lsp' function'):

l - for 'leftup'; the color of the top-left pixel will be used as the transparent color
r - for 'rightup'; the color of the top-right pixel will be used as the transparent color
c - for 'copy'; shows the image as-is, no transparency settings
a - for 'alphablend'; the right half of the image contains alpha-level data for the left half
m(filename) - for 'mask'; uses the given file as alpha-level data for the main image

These are the tags that you have before each filename...took me until now to realize what they were for. This means that if you have a plain white .bmp image, it will show as transparent with the default settings since it uses the top left pixel value as the alpha color.

I'll have to scan through the script and check if. Also, if anyone has added some .bmp images, would be agood idea to check those too (not sure how to go about chking it...). Luckily it's mainly the GUI which uses the .bmp images.

setLangString setLangStringC / setKakeraMemoryString

These functions are used when images are language dependent. For example below:

;note: refer to the other functions in the script as they are slightly different.
*setLangString
	getparam $witchh5, $witchh6

	mov $witchh4, ":b"
	add $witchh4, $witchh6

	notif %cur_language = 1 jumpf
	add $witchh4, ";"
	~
	notif %cur_language = 0 jumpf
	add $witchh4, ";en\"
	~
	add $witchh4, $witchh5
return

The function adds ':b' to the string and the second parameter (usually just an empty string), then it adds either ";" for Japanese lines or ';en' for English lines. Finally it adds the first input parameter to get something like :b;BMP\background\efe\oct_4_1986.png for the call setLangString "BMP\background\efe\oct_4_1986.png", "" (usually a stralias is used).

Note that the stralias passed to this function is expected NOT to contain the ':b', and it is expected that there are two copies of the image - one in the root directory (japanese version) and one in the 'en' directory (english version)

set_oldnew_bg

*set_oldnew_bg
	getparam $witchh11,$witchh12,%witchh13,%witchh14

	mov %witchh15,1
	if %witchh13 = 0 mov %witchh15,0

	notif %show_cgs = 1 jumpf
	mov %hide_new_sprites,%witchh15

	mov %oldnew_bg,1
	mov $oldnew_bg,$witchh11
	mov $oldnew_bg_old,$witchh12

	gosub *displayOldNewBg
	if %witchh13 = 2 print 99,2000,"breakup.dll/lrp"
	notif %witchh13 = 2 print %witchh14
	~
	if %show_cgs = 1 jumpf
		bg $witchh12,%witchh14
	~
return
*displayOldNewBg

notif %is_old_sprites = 0 jumpf
if %hide_bgsp2_cg = 1 vsp bgsp2,0

mov $witchh12, ":b;big\"
add $witchh12, $oldnew_bg
add $witchh12, ".png"
~
if %is_old_sprites = 0 jumpf
mov $witchh12, $oldnew_bg_old
if %hide_bgsp2_cg = 1 vsp bgsp2,1

~
bg $witchh12,0

return

set_oldnew_bg cg_ep1_1,rose_1b,1,0

The function is used as follows: the CG to display, followed by regular background, then a flag on whether or not to show sprites, then the transition type to use. Note that the CG string must not include the ':b;' portion, and must not include the file extension, and is assumed to be relative to the ":b;big\" directory.

Clone this wiki locally