This makes it so srand is not always the same value on boot.
; inits the random seed
rand_init:
- ld a, SRAND_INITIAL
+ call mbc1_ram_enable
+
+ ld a, [sram_srand]
ld [srand], a
+
+ call mbc1_ram_disable
ret
+ ; saves srand in sram
+rand_save_srand:
+ call mbc1_ram_enable
+
+ ld a, [srand]
+ ld [sram_srand], a
+
+ call mbc1_ram_disable
+ ret
; gets a pseudo-random number
; and advances to the next seed
; flag for init of sram
sram_magic: .adv 1
-
+sram_srand: .adv 1
save_game1: .adv save_game_size
update_game:
; tick rng every frame
- call rand
+ call rand
+ call rand_save_srand
; update player
ld hl, player