Time

From Boktai Hacking Wiki

The Boktai games have many game mechanics that depend on the current date and time. The cartridges contain an RTC chip and a battery, which will keep track of the time even when the system is powered off. The games use the following values:

  • Date
  • Time
  • Sunrise/Sunset times in the player's selected region
  • Moon phase (based on current knowledge, only full moons are used currently. But the games track every moon phase, not just full moons)
  • Seasons

Region selection

When creating a save file (Boktai 1), or when starting the game with an uninitialized RTC (Boktai 2/3), the game will ask the player for their current location. This will affect the sunrise/sunset time calculation.

The list of regions is stored as a string in the game's script directory. Even though this is stored in the string list, the region list is stored as bytecode.

Example:

; Boktai 2 (U). String ID = 0x1b43
; Dumping from 0xce3dfb

i32 0x0 ; page number
	i32 0x1 ; number of regions in this page
		; region id
		i32 0x0
		; time zone offset (signed): 0x40 = +1 hour
		; When copying Japanese regions to an USA ROM, set this to -0x40 (c0 ff in hex editor)
		i32 0x0
		; longitude:
		;   in the eastern hemisphere: longitude_degrees * 2^16
		;   in the western hemisphere: (360 - longitude_degrees) * 2^16
		i32 0x0
		; latitude: latitude_degrees * 2^16
		i32 0x0
i32 0x1
	i32 0x1
		i32 0x1 ; St. John's
		i16 -0x320
		i32 0x13391ec
		i32 0x2f570a
i32 0x2
	i32 0x2
		i32 0x2 ; Labrador City
		i16 -0x340
		i32 0x1257333
		i32 0x3491ec
		i32 0x3 ; Halifax
		i16 -0x340
		i32 0x128a666 ; ≈ (360 - 63.59...) * 2^16
		i32 0x2c6148  ; ≈ 44.64... * 2^16
; etc...

i32 -0x1 ; done
i32 0x0
i32 0x0
i32 0x0
i32 0x0
i32 0x0
end

Japanese releases omit the time zone offset field (Japan only has a single time zone, JST). The region list is stored at these locations:

Boktai 2 (U) Boktai 2 (J) Boktai 3
String ID 0x1b43 0x19bd 0x247c
Address 0x08ce3dfb 0x08d10af2 0x08dd3aa9

A map of all regions of Boktai 2 is available here: https://geojson.io/#id=gist:raphaelr/3b6f066014f8a5f6f84e9b50118c2c2c