=================================================== Dragon Warrior IV Speedrun RNG Manipulation Notes =================================================== I did some experimentation tonight (10/18/2016) and it looks like manipulations ain't happening. tl;dr, the file you're playing on seeds the RNG. Unless you have the same stats, exp, etc you're not manipulation nothing. Here's the deets: I wrote a script today that would hold A until the priest starts talking, then hold directional arrows (letting the text box dismiss on its own) to move outside Endor with consistent timing. This does not produce consistent results. The first time I turned the script on, it would cycle between four different encounters (but two were Metal Slimes!). I wasn't paying attention to whether the encounters were random or if it did cycle, but from what else I've seen tonight, I imagine it was cycling through them. Previous experimentation left me thinking File 1 always seeded the RNG (not entirely true) so I tried changing the encounters I found by changing the message speed on file 1 and loading file 2. It worked, but I soon found out that changing the message speeds on the other files also changed the results. At that point I realized manipulations weren't happening, because of randomized stat gains making the checksum of the file you're playing impossible to guess. In Dragon Warrior II you could theoretically generate a mapping of EXP to gold values that would turn the RNG off, but that won't work in DW4. By this I mean, you have a script that finds files that turn off the RNG with certain gold and EXP values (possibly inventory setups, too, to reduce reproduction steps) and then during your run (after Gremlins) you look up a gold value based on your current EXP totals, buy/sell things until you reach that gold value, and then save the game. This is way less feasible in DW4 because you have four characters (Ragnar, Alena, Cristo, Brey) with variable EXP totals, stats, and inventories. All of these would be inputs to whatever program you're using to spit out the "solution", though the answer could be to create two files with certain filenames -- no shop transactions. Ultimately, this is the only problem. You should be able to use file 1 so there shouldn't be any frame-perfect inputs. And the unpredictability of the lag isn't an issue because you theoretically could find a seed where all encounters you run into are metal slimes (Less likely if you have to generate a billion methods of getting a metal slime). Hey but here's a last-minute idea... What if you practiced the manipulation and the movement and all that, and then get your run to Endor, do the manip to see what the encounter is, then reset immediately and change a message speed on a file and try again? If you find the slime, it'll be repeatable. This game upsets me. ======================================================================================== Old, Unhelpful Notes (I now know a bit more about what's going on beneath this line) ======================================================================================== Anyway, it's kinda like DW3? Apparently? Quoting Vaxherd (DW3 RNG notes): Dragon Warrior IV uses the same RNG as DW3. The RNG seed is stored at $12, and the output counter is stored at $050D. ^^^^^^^^^^^^^ This statement is GARBAGE and is more hurt than help hngh DQ4 TAS: http://www.nicovideo.jp/watch/sm6316849 5/5 http://www.nicovideo.jp/watch/sm6305143 2/5 (Chapter 2) http://www.nicovideo.jp/watch/sm6306438 3/5 (Chapter 5) http://www.nicovideo.jp/watch/sm6307243 4/5 http://www.nicovideo.jp/watch/sm6344030 1/5 DW4 TAS: https://www.youtube.com/watch?v=vsk3UXaPiD8 TASVideoes thread: http://tasvideos.org/forum/viewtopic.php?t=1187&postdays=0&postorder=asc&start=0 ======================= Important memory addresses: - 0012: Normal RNG seed (Two bytes) - One byte (0013) acts like DW3's RNG - Other byte (0012) changes every frame - Every time a savefile is saved, the checksum gets stored here (Is this true?) - 050D: RNG "Counter" (Increments each time a number is generated) - Reset to 0 upon reset - Counter does NOT increment constantly -- only when it's needed - ????: Discard Counter - Not 100% sure this is a thing, or where it is. - It's definitely not the same address. - ????: I don't know - Something in the SRAM must affect RNG - When you make a new savefile, hit reset, hold A, reset, repeat, you get different results??? While idling on the world map... Seed: E1XX Counter: 59 XX Pattern: E5 3B B3 3B D0 60 38 55 C4 26 BE 59 Note: 3B (X) 3B (Y) ? - There must be another factor... ======================================== Assembly opcode reference: http://6502.org/tutorials/6502opcodes.html ======================================== This is the disgusting creature that messes with 0x0012: 1F:FF74:AD 0C 05 LDA $050C = #$2F //Load 050C (NOTE: NOT 050D!!) 1F:FF77:EA NOP 1F:FF78:EA NOP >1F:FF79:E6 12 INC $0012 = #$80 //Increment 0012 1F:FF7B:CD 0C 05 CMP $050C = #$2F //Compare 050C to... (?) 1F:FF7E:F0 F7 BEQ $FF77 //Jump to FF77 "if equal" (If not equal?) ("Branch if equal") 1F:FF80:EA NOP 1F:FF81:EA NOP 1F:FF82:20 13 C9 JSR $C913 1F:FF85:60 RTS ----------------------------------------- =================================================== I think this is part of the main RNG function: 1F:C890:60 RTS ----------------------------------------- 1F:C891:98 TYA 1F:C892:48 PHA 1F:C893:A9 FF LDA #$FF 1F:C895:85 16 STA $0016 = #$0A 1F:C897:20 AD C8 JSR $C8AD 1F:C89A:A9 FF LDA #$FF 1F:C89C:85 16 STA $0016 = #$0A 1F:C89E:20 AD C8 JSR $C8AD 1F:C8A1:EE 0D 05 INC $050D = #$D1 //Increment the counter 1F:C8A4:68 PLA 1F:C8A5:A8 TAY 1F:C8A6:A5 12 LDA $0012 = #$C2 1F:C8A8:18 CLC 1F:C8A9:6D 0D 05 ADC $050D = #$D1 1F:C8AC:60 RTS ----------------------------------------- 1F:C8AD:A0 08 LDY #$08 1F:C8AF:A5 13 LDA $0013 = #$83 1F:C8B1:45 16 EOR $0016 = #$00 1F:C8B3:06 12 ASL $0012 = #$37 1F:C8B5:26 13 ROL $0013 = #$83 //Rotate Left (Bit shift left) 1F:C8B7:06 16 ASL $0016 = #$00 1F:C8B9:0A ASL 1F:C8BA:90 0C BCC $C8C8 //Branch on Carry Clear //Next six lines: RNG seed at 0x12 1F:C8BC:A5 12 LDA $0012 = #$37 //Load 0x0012 1F:C8BE:49 21 EOR #$21 //XOR 1F:C8C0:85 12 STA $0012 = #$37 //"Store Accumulator" = Save result ($12 = $12 XOR 0x21) 1F:C8C2:A5 13 LDA $0013 = #$83 //Load 0x0013 1F:C8C4:49 10 EOR #$10 //XOR >1F:C8C6:85 13 STA $0013 = #$83 //"Store Accumulator" = Save result ($13 = $13 XOR 0x10) 1F:C8C8:88 DEY 1F:C8C9:D0 E4 BNE $C8AF 1F:C8CB:60 RTS ----------------------------------------- ==================================== Random DW4 memory addresses: 16: Changes randomly, but is referenced in the RNG function? 17: ??? 18: Encounter rate of the tile I'm standing on...? ==================================== DW4 save addresses: File 1: 0x62EF - 0x65DE File 2: 0x65DF - 0x68CE File 3: 0x68CF - 0x6BBE 0x6000 - 0x62EE = "Current File", party stats and gold etc - Freezing these doesn't seem to stop the RNG from changing