øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1883.msg22709e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index3bec.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1883.405e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index3bec.html.zxÇ!g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ P,ð³OKtext/htmlISO-8859-1gzip(¾Öð³ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 05:29:01 GMT0ó°° ®0®P®€§²ð®Æ!g^ÿÿÿÿÿÿÿÿÚ@ð³ Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)

Author Topic: Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)  (Read 78678 times)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Here is the patch. It's as basic as basic can be only including the new routines, allowing Rosa, Porom, FuSoYa, and Tellah to have the three dummied spells, giving Asura Protect back, changing the MP cost of Protect and Shell to 25 and changing the targeting of those spells to a single person and reimplementing the weapons to have those dummied spells, and allowing Cecil to learn those spells...

Alright so not As basic as can be, but it will give it a standalone feel that doesn't seem useless without additional modding.


koala_knight

  • Tunnel Armor
  • *
  • Posts: 166
  • Gender: Male
    • View Profile
Awesome!! It just so happens that I recently read an article about how working with limited resources can lead to impressive feats of creativity.
Thanks a bunch for working on the stand alone patch. :)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
I've started work on figuring out the Event Instructions Routines and my focus is primarily on the unused ones at the moment for some future plans.

Subtract XX *  100 Gil

Code: [Select]
$00/E97E 20 CB E2 JSR $E2CB  [$00:E2CB] A:00E9 X:0000 Y:0002 P:envMxdiZc - Jump to Event Progression Routine
$00/E981 85 18 STA $18    [$00:0618] A:0001 X:0001 Y:0002 P:envMxdizc - Store Event Variable in to 0618.
$00/E983 64 19 STZ $19    [$00:0619] A:0001 X:0001 Y:0002 P:envMxdizc - Store Zero in 0619.
$00/E985 A9 64 LDA #$64 A:0001 X:0001 Y:0002 P:envMxdizc - Load 100 into A (Remove 100 Gil)
$00/E987 85 1A STA $1A    [$00:061A] A:0064 X:0001 Y:0002 P:envMxdizc - Store a in Event Variable(2)
$00/E989 64 1B STZ $1B    [$00:061B] A:0064 X:0001 Y:0002 P:envMxdizc - Store Zero in 1B.
$00/E98B 22 95 C3 15 JSL $15C395[$15:C395] A:0064 X:0001 Y:0002 P:envMxdizc - Jump to Subroutine (?)
$00/E98F AD A0 16 LDA $16A0  [$00:16A0] A:0000 X:0001 Y:0000 P:envMxdiZc - Load Gil Total (Byte 1)
$00/E992 38 SEC A:00DB X:0001 Y:0000 P:eNvMxdizc - Set Carry Flag
$00/E993 E5 30 SBC $30    [$00:0630] A:00DB X:0001 Y:0000 P:eNvMxdizC - Subtract it by the value in 0630 (event designated value)
$00/E995 8D A0 16 STA $16A0  [$00:16A0] A:003F X:0001 Y:0000 P:envMxdizC - Store A in Gil Total (Byte 1)
$00/E998 AD A1 16 LDA $16A1  [$00:16A1] A:003F X:0001 Y:0000 P:envMxdizC - Load Gil Total (Byte 2)
$00/E99B E5 31 SBC $31    [$00:0631] A:0000 X:0001 Y:0000 P:envMxdiZC - Subtract it by the value in 0631.
$00/E99D 8D A1 16 STA $16A1  [$00:16A1] A:009D X:0001 Y:0000 P:eNvMxdizc - Store A in Gil Total (Byte 2)
$00/E9A0 AD A2 16 LDA $16A2  [$00:16A2] A:009D X:0001 Y:0000 P:eNvMxdizc - Load A from Gil Total (Byte 3)
$00/E9A3 E5 32 SBC $32    [$00:0632] A:0000 X:0001 Y:0000 P:envMxdiZc - Subtract it by the value in 0632.
$00/E9A5 8D A2 16 STA $16A2  [$00:16A2] A:00FF X:0001 Y:0000 P:eNvMxdizc - Store A in Gil Total (Byte 3)
$00/E9A8 B0 09 BCS $09    [$E9B3] A:00FF X:0001 Y:0000 P:eNvMxdizc - If above 00, skip to End.
---------------------------------------------------------------------------------------------------------------------------------
$00/E9AA 9C A0 16 STZ $16A0  [$00:16A0] A:00FF X:0001 Y:0000 P:eNvMxdizc - Store Zero in Gil Total 1,2, and 3.
$00/E9AD 9C A1 16 STZ $16A1  [$00:16A1] A:00FF X:0001 Y:0000 P:eNvMxdizc
$00/E9B0 9C A2 16 STZ $16A2  [$00:16A2] A:00FF X:0001 Y:0000 P:eNvMxdizc
$00/E9B3 4C D3 E0 JMP $E0D3  [$00:E0D3] A:00FF X:0001 Y:0000 P:eNvMxdizc - Jump to rest of routine


For such an unused command it came with a fair amount of space 37 Bytes all in all which is a nice tidy sum and may be enough room to set further functionalities of events. FFII for instance has a rather strange one-time event where at the top of the Mysidia Tower there are four orbs which increase Stats. Surely FFIV could have such a thing as well, no? The best way to handle this idea would be to make the value a stat can increase from 1-4 (10,20,40,80 bit booleans) and use the second value as the functional "X" value (7E100F/7E1014 for the start) To simplify things it would probably be the character in Slot 1 that would get the stat boosts. This is all in theory of course, but it seems like it should work.

Despite the Event Instruction of Add 100 * GP never being used in-game the routine it links to is used by Treasure Chests with Gil in them as well. The objective then would be to change that link to unused space.

$00/E978   20 DD 97   JSR $97DD  [$00:97DD]   A:0000   X:0001   Y:0000   P:envMxdiZc - Jump to Gil Acquisition Routine. Called by events...

Though I seem to have found the basic routines for events so I should probably set those first...

Code: [Select]
$00/E01A A2 00 00 LDX #$0000 A:00FF X:4B0E Y:0002 P:eNvMxdizc - Load 0000 into X.
$00/E01D 86 B3 STX $B3    [$00:06B3] A:00FF X:0000 Y:0002 P:envMxdiZc - Store X in B3.
$00/E01F BD D5 09 LDA $09D5,x[$00:09D5] A:00FF X:0000 Y:0002 P:envMxdiZc - Load A from Event Instruction ID.
$00/E022 8D 16 0A STA $0A16  [$00:0A16] A:00E5 X:0000 Y:0002 P:eNvMxdizc -  Store A in 0A16.
$00/E025 C9 D0 CMP #$D0 A:00E5 X:0000 Y:0002 P:eNvMxdizc - Is this event ID Below Toggle Screen Shake? (Meaning Movement)
$00/E027 90 03 BCC $03    [$E02C] A:00E5 X:0000 Y:0002 P:envMxdizC - Then branch to Movement Patterns.
--------------------------------------------------------------------------------
$00/E029 4C B8 E0 JMP $E0B8  [$00:E0B8] A:00E5 X:0000 Y:0002 P:envMxdizC - Jump to Rest of Event ID's Routines.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$00/E0B8 38 SEC A:00E5 X:0000 Y:0002 P:envMxdizC - Set Carry Flag
$00/E0B9 E9 D0 SBC #$D0 A:00E5 X:0000 Y:0002 P:envMxdizC - Subtract D0
$00/E0BB 64 3E STZ $3E    [$00:063E] A:0015 X:0000 Y:0002 P:envMxdizC - Store Zero in 3E.
$00/E0BD 0A ASL A A:0015 X:0000 Y:0002 P:envMxdizC - x2 A.
$00/E0BE 26 3E ROL $3E    [$00:063E] A:002A X:0000 Y:0002 P:envMxdizc
$00/E0C0 85 3D STA $3D    [$00:063D] A:002A X:0000 Y:0002 P:envMxdiZc - Store A in 063D.
$00/E0C2 A6 3D LDX $3D    [$00:063D] A:002A X:0000 Y:0002 P:envMxdiZc - Load X from x2 Event ID -D0
$00/E0C4 BD E6 E2 LDA $E2E6,x[$00:E310] A:002A X:002A Y:0002 P:envMxdizc - Load A from E2E6+X (Event ID Table)
$00/E0C7 85 3D STA $3D    [$00:063D] A:0067 X:002A Y:0002 P:envMxdizc - Store A in 063D.
$00/E0C9 BD E7 E2 LDA $E2E7,x[$00:E311] A:0067 X:002A Y:0002 P:envMxdizc - Load A from E2E7 +  (Event ID Table)
$00/E0CC 85 3E STA $3E    [$00:063E] A:00E9 X:002A Y:0002 P:eNvMxdizc - Store A in 063E.
$00/E0CE A6 B3 LDX $B3    [$00:06B3] A:00E9 X:002A Y:0002 P:eNvMxdizc - Load X from B3.
$00/E0D0 6C 3D 06 JMP ($063D)[$00:E967] A:00E9 X:0000 Y:0002 P:envMx - Jump to portion in designated table...


And there it is! The Event ID Table, similar to any other pointer table we've found thus far. I'll list them in order, though I probably won't tackle their contents for a while.


EB94 - Toggle Screen Shake D0
EB9D - Screen Flash D1
EBD4 - Screen blur and unblur D2
EBEF - Travel to/from Moon D3
E351 - Open Fat Chocobo Screen D4
EC17 - Open a Door D5
EB65 - Screen moves up 1 tile and down 1 tile D6
E54B - Toggle Running D7
E38B - Toggle Music Fade D8
E344 - Open Namingway Screen D9 (Judging from the amount of bytes here I imagine this is just a jump to another Jump)
E7C4 - Toggle Screen Fade DA
E90A - Toggle Status Ailments XX DB
E9E6 - Inn DC
E9B6 - Change Character Graphic to XX DD
E7FF - Restore HP (10 * XX HP) DE
E85F - Restore MP (10 * XX MP) DF
E8BF - Add Item XX to Inventory E0
E8CB - Remove Item XX from Inventory E1
E7D8 - Put in Spell List XX' SpellBook, Spell YY E2
E929 - Remove All Status Ailments but XX E3
E948 - Add Status Ailments XX E4
E967 - Add 100 * XX GP to Party E5
E97E - Subtract 100 * XX GP to Party E6
E578 - Add XX Character to Party E7
E6AF - Remove XX Character from Party E8
EAB5 - Pause XX Cycles E9
E379 - Fade Song XX in EA
0000 - Repeat Xx Time the Following YY Actions EB (blank because this is looked at in respect to the Movement Patterns)
E391 - Fight Battle with Enemy Set XX EC
E35E - Bring Up Shop XX ED
E339 - Show Message from Bank 02 (Event Call) EE
EF28 - Show Message from Bank 02 (Map Call) EF
EF4E - Show Message 0XX from Bank 01. F0
EF5F - Show Message 1XX from Bank 01. F1
EF81 - Set Event Flag XX F2
EF8A - Clear Event Flag XX F3
EF93 - Activate NPC XX F4
EF9C - Deactivate NPC XX F5
EF70 - Show Message XX (from Bank 3) F6
EB0E - Bring up Item Selection Window F7
EAE9 - Show Message 1XX (Yes/No Box) F8
E731 - Toggle Screen Tint XX F9
E559 - Play Song XX FA
E56F - Play Sound Effect XX FB
0000 - Load Some Type of Graphic FC (Actually Nothing)
C17C - Play Visual Effect FD
EDB1 - Load Map FE
EA20 - End Event FF

So we now know that "Load Some Type of Graphic?" is literally "Crash the Game". Why they would put it so high up is beyond me. Maybe they had an idea for an event function that just did not pan out as planned... so that alone is a free event slot.
« Last Edit: March 22, 2015, 09:31:09 PM by Grimoire LD »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
I actually had no idea there was an unused event code.
I was thinking to myself recently that I wished there was, but then I just shrugged it off. Now I can't remember what I wanted it for... Oh well, good to know.
Good stuff, Grimoire.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
I'd love to see an event instruction of the form:

Change character graphic to graphic of character at slot XX in party

So for example, 01 would, instead of changing the graphic to Dark Knight Cecil necessarily, would change to the graphic of the character in the 1st slot, whoever it is.
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
I'm curious as to what the presumed function of that instruction would be, PinkPuff, considering the fluidity of party slots?

I remember what I wanted as an event instruction now. It was, "reduce HP by XX."
I ended up putting some event-specific ASM in my hack to reduce party HP whenever a particular event occurs instead.
Wouldn't it make sense, for example, for the "Ouch!" event to reduce HP? That's not what I wanted it for, but it's a relatable example.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Upon reflection, it wouldn't do what I wanted anyway.

The situation I'm thinking of is this:

Suppose you have a scenario involving the twins, but it could be done while Cecil is still a Dark Knight, or it could be done while he's a Paladin. Furthermore, you don't have any guarantees over who else might be in the party when the scenario is executed.

So I guess it would make more sense to have a function like,
"Change character graphic to DK Cecil if the 'became a paladin' flag is off, otherwise change character graphic to Paladin Cecil"

 :edit: ACTUALLY!! How about this:

"If Flag XX is on, do the following YY actions; otherwise skip past them"
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Patches, and Hacks (New Event Instructions!)
« Reply #412 on: March 17, 2015, 05:56:25 PM »
I'm curious as to what the presumed function of that instruction would be, PinkPuff, considering the fluidity of party slots?

I remember what I wanted as an event instruction now. It was, "reduce HP by XX."
I ended up putting some event-specific ASM in my hack to reduce party HP whenever a particular event occurs instead.
Wouldn't it make sense, for example, for the "Ouch!" event to reduce HP? That's not what I wanted it for, but it's a relatable example.

That's some good thinking there Chillyfeez, I personally would like the first option more you described by using an event instruction to do that.

Upon reflection, it wouldn't do what I wanted anyway.

The situation I'm thinking of is this:

Suppose you have a scenario involving the twins, but it could be done while Cecil is still a Dark Knight, or it could be done while he's a Paladin. Furthermore, you don't have any guarantees over who else might be in the party when the scenario is executed.

So I guess it would make more sense to have a function like,
"Change character graphic to DK Cecil if the 'became a paladin' flag is off, otherwise change character graphic to Paladin Cecil"

 :edit: ACTUALLY!! How about this:

"If Flag XX is on, do the following YY actions; otherwise skip past them"

This will require disassembly of the Yes/No Option for optimal use, while I would assume that your method here would work, there is no YY option allowed here because the instruction only has a single variable and that would be some heavily advanced hacking to get the game to read another variable for event instruction. While if you tie it into the  Yes/No Option of "If Flag XX is on keep following this event, if not, go to second event" would work much better I'd imagine.

So let's get to disassembling the Yes/No option and see how it works!

EAE9 - Show Message 1XX (Yes/No Box) F8

Or at least that was the plan, but this is doing so many functions I can't keep them straight, nor do I understand much about the graphics processing part, so I will skip to the important part to purely create another event instruction which can skip to the next event.

Alright, I understand now... that is rather simple and should be easy to manipulate. It looks like the game has a built in "check" there already, when the cursor is on Yes, it is 00 which means nothing special, all normal events proceed off of this. But when the cursor is on No, the game changes a certain value to 01 and through a series of code uses the game will skip to the next event through this instruction.

Here is what is being done...

$00/AC53   A5 8C   LDA $8C    [$00:068C]   A:0011   X:3745   Y:00D0   P:envMxdiZC - Load A from 068C (Cursor Choice)
$00/AC55   85 DB   STA $DB    [$00:06DB]   A:0001   X:3745   Y:00D0   P:envMxdizC - Store A in in Event Switcher
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
$00/EB00   A5 DB   LDA $DB    [$00:06DB]   A:0000   X:0010   Y:00D0   P:envMxdiZC - Load A from Event Switcher.
$00/EB02   F0 07   BEQ $07    [$EB0B]   A:0000   X:0010   Y:00D0   P:envMxdiZC - Branch if 00 past Event Switching.
----------------------------------------------------------------------------------
00/EB04   20 D2 E2   JSR $E2D2  [$00:E2D2]   A:00FF   X:006C   Y:00D0   P:envMxdiZC - Jump to Event Switching Routine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
$00/E2D2   AE D3 09   LDX $09D3  [$00:09D3]   A:0001   X:0010   Y:00D0   P:envMxdizC - Load X from Event Position
$00/E2D5   E8    INX   A:0001   X:006B   Y:00D0   P:envMxdizC - +1 X.
$00/E2D6   BF 00 82 12   LDA $128200,x[$12:826C]   A:0001   X:006C   Y:00D0   P:envMxdizC - Load Event Instruction ID.
$00/E2DA   C9 FF   CMP #$FF   A:00FF   X:006C   Y:00D0   P:eNvMxdizC - Is it End Event?
$00/E2DC   F0 04   BEQ $04    [$E2E2]   A:00FF   X:006C   Y:00D0   P:envMxdiZC - If so, branch
----------------------------------------------------------------------------------------------------
$00/E2DE   E8    INX   A:00FF   X:006C   Y:00D0   P:envMxdiZC + 1 X
$00/E2DF   4C D6 E2   JMP $E2D6  [$00:E2D6]   A:00FF   X:006C   Y:00D0   P:envMxdiZC - Jump (backwards) to E2D6 to +1 X again to look for the end of the event.
-------------------------------------------------------------------------------------------------------
$00/E2E2   8E D3 09   STX $09D3  [$00:09D3]   A:00FF   X:006C   Y:00D0   P:envMxdiZC - Store X in Event Position
$00/E2E5   60    RTS   A:00FF   X:006C   Y:00D0   P:envMxdiZC - Return


And that's all it seems to take. If the new instruction looks at an Event Flag instead of at a cursor position to use the same Event Switch code everything should work properly.

This would also be the way to set up branching paths in a way where Actions in addition to Yes/No Options could influence the course of gameplay

My thinking is to make this two-pronged...

Say I wanted a scenario where a battle could be won, but didn't have to be and the outcome would be the way the game would branch to two different scenarios. To The first would be this... "Is Characters 1-5 Dead?" IF so, play Event Switcher"  That would accomplish this. Then in the code, do as you suggest; "Is Event Flag XX on? If so, branch to next event". In normal gameplay all characters can't be dead so the first part would never play, but that scenario can happen in events and event battles.

I will try an experiment shortly to see if I can put theory into practice...

Changing Event Instruction FC (Nothing) to (If All Characters are Dead move to next event)

First thing is first, we will need to go to the Pointer Table and make sure that FC's instruction start is read properly, so change the 0000 at E33E to 71FD (free space at the end of Bank 0)

And it worked in such an easy manner, I'm somewhat shocked! I created a custom Event Instruction as a test using my "dead party" idea and it was flawless. It jumped to the next event once it saw that the entire party was dead and if a party member was alive it would not use the Event Switcher.

$00/FD71   BD 03 10   LDA $1003,x[$00:1003]   A:00FD   X:0000   Y:0002   P:envMxdiZc - Load Character 1's Status Byte 1.
$00/FD74   10 17   BPL $17    [$FD8D]   A:0000   X:0000   Y:0002   P:envMxdiZc - If they are not dead, branch to End.
$00/FD71   BD 03 10   LDA $1003,x[$00:1003]   A:00FD   X:0000   Y:0002   P:envMxdiZc - Do this for the rest of the Slots.
$00/FD74   10 17   BPL $17    [$FD8D]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD76   BD 43 10   LDA $1043,x[$00:1043]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD79   10 12   BPL $12    [$FD8D]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD7B   BD 83 10   LDA $1083,x[$00:1083]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD7E   10 0D   BPL $0D    [$FD8D]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD80   BD C3 10   LDA $10C3,x[$00:10C3]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD83   10 08   BPL $08    [$FD8D]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD85   BD 03 11   LDA $1103,x[$00:1103]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD88   10 03   BPL $03    [$FD8D]   A:0080   X:0000   Y:0002   P:eNvMxdizc
$00/FD8A   20 04 EB   JSR $EB04  [$00:EB04]   A:0080   X:0000   Y:0002   P:eNvMxdizc - Jump to Subroutine (Event Switcher)
$00/FD8D   60    RTS   A:0000   X:0000   Y:0002   P:envMxdiZc

That's all it took.

Now as for the rest of your idea Pinkpuff, that is a bit more complicated... while I can easily set F8's variable to act as an event flag searcher, I do not know how the game actually tells if an event flag is off or on in a numerical fashion since the Event Flags are booleans (I think that's the right term) and they comprise of much more than one byte. So how the game turns them on and off, I do not know. Once that is found though your idea would work fine.

Though there is another suggestion I would make...

I would suggest looking for Dark Knight Cecil or Paladin Cecil rather than holding to Event Flag dealings. It would be something as simple as above...

Look through the each slots. If the slot is Dark Knight Cecil keep on with the current event.  If the slot is Paladin Cecil switch events. If neither, move on to the next slot.

Something like this would be really easy to build especially with all of the free space at the end of Bank 1, but from what you described the event would not be too terribly different. In such a case I think modifying the "Change Character Graphic" to look only at the two Cecil's (it doesn't ever use it for anything else in the default game) and using the pattern I mentioned above should do the trick.

« Last Edit: March 17, 2015, 07:47:03 PM by Grimoire LD »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Can anyone think of any events that use the "move camera up one space then down again" instruction?

That seems like a silly one that could be easily changed to something else with very few consequences...
Though it has no natural parameters...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Can anyone think of any events that use the "move camera up one space then down again" instruction?

That seems like a silly one that could be easily changed to something else with very few consequences...
Though it has no natural parameters...

Haha! I had a post written up a few days ago about useless or unused event codes.

That "move camera up one space then down again" one was the very first one I mentioned due to its absurd uselessness.

From there I addressed the the two Add/Subtract Gils... then I noticed that was it so I never made the post.

All in all we have four event instructions to change as we will without disrupting anything the game normally does.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
So, with the code you posted that uses the Yes/No routine... would that replace the Yes/No routine? So you could have a game that has yes/no boxes or you could have a game that has flag-based branches, but not both? Also, can you only have one branch in an event with this method?

How does the "Repeat the next XX actions YY times" work? I was picturing the branch instruction to work more similar to that one where you could have code that uses multiple branches like

Code: [Select]
Show Message: "Elder: There are many paths ahead of you."
Show Message: " You can go to the moon using the Lunar Whale..."
If "awakened Yang" is off do the next 1 actions:
 Show Message: "Elder: Your friend Yang may still be alive"
If "found Yang" is on do the next 1 actions:
 Show Message: "Elder: Perhaps his wife knows how to wake him"
If "found Adamant" is off do the next 1 actions:
 Show Message: "Elder: A blacksmith in the underworld needs a rare ore, perhaps he can make something useful with it!"
If "found Tail" is on do the next 1 actions:
 Show Message: "Elder: There is a miner that collects tails, perhaps he will trade that one for something useful"
If "defeated Odin" is off do the next 1 actions:
 Show Message: "Elder: The ghost of Odin waits for you in Baron's basement"
Show Message: "Elder: Good luck, Cecil!"

So I take it it isn't as simple as "check flag value, compare to 0, if equal load A with YY, skip ahead bytes in the event code while decrementing A until 0"?

In any case, I guess something like that would involve hijacking an instruction that took two parameters, wouldn't it?
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
So, with the code you posted that uses the Yes/No routine... would that replace the Yes/No routine? So you could have a game that has yes/no boxes or you could have a game that has flag-based branches, but not both? Also, can you only have one branch in an event with this method?

How does the "Repeat the next XX actions YY times" work? I was picturing the branch instruction to work more similar to that one where you could have code that uses multiple branches like

Code: [Select]
Show Message: "Elder: There are many paths ahead of you."
Show Message: " You can go to the moon using the Lunar Whale..."
If "awakened Yang" is off do the next 1 actions:
 Show Message: "Elder: Your friend Yang may still be alive"
If "found Yang" is on do the next 1 actions:
 Show Message: "Elder: Perhaps his wife knows how to wake him"
If "found Adamant" is off do the next 1 actions:
 Show Message: "Elder: A blacksmith in the underworld needs a rare ore, perhaps he can make something useful with it!"
If "found Tail" is on do the next 1 actions:
 Show Message: "Elder: There is a miner that collects tails, perhaps he will trade that one for something useful"
If "defeated Odin" is off do the next 1 actions:
 Show Message: "Elder: The ghost of Odin waits for you in Baron's basement"
Show Message: "Elder: Good luck, Cecil!"

So I take it it isn't as simple as "check flag value, compare to 0, if equal load A with YY, skip ahead bytes in the event code while decrementing A until 0"?

In any case, I guess something like that would involve hijacking an instruction that took two parameters, wouldn't it?

Slight misunderstanding... this custom code I made actually jumps into the final portion of the Yes/No routine without disrupting the original at all, as it uses the original jump's content within its entirety. (I didn't account for petrify though, which means I'll need to rewrite my custom code to make it a little lengthier for the purposes of covering all bases)

The idea you present would work, IF there was a YY portion. None of the four unused/redundant Event Instructions have a YY portion to draw from and to add a YY portion to an instruction that did not originally have it to any of the existing Event Instructions would need a large rewrite to Events all together.

While it is rather neat idea, it would not be usable in the basic sense, perhaps the custom code could have a table of its own to make it work. In any event I have not yet checked how the game accurately switches on and off booleans using a numeric value to jump into the flags and switch bits on and off. Once that portion is researched that part of it should be able to be done.
« Last Edit: March 18, 2015, 06:13:45 AM by Grimoire LD »

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
The idea you present would work, IF there was a YY portion. None of the four unused/redundant Event Instructions have a YY portion to draw from and to add a YY portion to an instruction that did not originally have it to any of the existing Event Instructions would need a large rewrite to Events all together.

Hm, well if that's the only problem (besides the issue of deciphering how to read flag values) I have a very hack-ish solution:

"Do the following action if Flag XX is (on/off)"

Top bit of XX indicates whether you're looking for on or off, the rest indicate the flag number (since it seems all the used flags besides 255 are under 128 ^_^)

That way if you want multiple conditional instructions, it can still be done, though rather tediously:

Code: [Select]
If "saved Yang" is ON do the next action
 Placement 4: Yang toggles visibility
If "saved Yang" is ON do the next action
 Placement 4: Yang moves up
If "saved Yang" is ON do the next action
 Show Message: "Yang: Leave it to me"
If "saved Yang" is OFF do the next action
 Show Message: "Cecil: If only Yang were here"

Also I do like the stop-gap solution you proposed for my more immediate problem of switching to paladin/DK cecil, but I think if we can somehow swing a more general "conditional" instruction, it would vastly improve the expressiveness of the event code generally and open a lot of new doors.
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
A small amount of custom ASM could also be written that tells the default "change character graphic to xx" instruction that, if the parameter indicates DK Cecil, P Cecil is an acceptable alternative.
I actually did something like that for my hack, though not exactly that.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 924
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
A small amount of custom ASM could also be written that tells the default "change character graphic to xx" instruction that, if the parameter indicates DK Cecil, P Cecil is an acceptable alternative.
I actually did something like that for my hack, though not exactly that.

That's exactly my plan for now.

If we have the pointers to the code for "set event flag" and "clear event flag", can't we just reverse-engineer whatever those are doing to figure out how to read an event flag?
Let's dance!