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:
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.
This is a workable idea and quite easy (in theory) to put together. The first step would involve decrementing the value to -80 to reach the proper event Flag check and then reloading the byte and checking to see if it is negative (which it will be if it is 80) to branch to the Event Flag Check. 80 will check to see if it is On while 00 will check to see if it is Off. But again, this does require reverse-engineering as you put it. So... I'll get on that and see what I can find. Hopefully it won't be too much math.
Alright, that was easy to find...
$00/EF81 20 CB E2 JSR $E2CB [$00:E2CB] A:00EF X:0000 Y:0002 P:envMxdiZc - Jump to Event Instruction Jump Routine (Looks like this is already prepared as well)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$00/E2CB E8 INX A:00EF X:0000 Y:0002 P:envMxdiZc - +1 to X.
$00/E2CC 86 B3 STX $B3 [$00:06B3] A:00EF X:0001 Y:0002 P:envMxdizc - store X in 06B3.
$00/E2CE BD D5 09 LDA $09D5,x[$00:09D6] A:00EF X:0001 Y:0002 P:envMxdizc - Load Event Instruction Location +X (meaning next byte over) into A (in this case the Flag Number)
$00/E2D1 60 RTS A:0005 X:0001 Y:0002 P:envMxdizc - Return
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$00/EF84 20 33 F1 JSR $F133 [$00:F133] A:0005 X:0001 Y:0002 P:envMxdizc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$00/F133 20 7F F1 JSR $F17F [$00:F17F] A:0005 X:0001 Y:0002 P:envMxdizc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$00/F17F 48 PHA A:0005 X:0001 Y:0002 P:envMxdizc - Push A onto Stack
$00/F180 4A LSR A A:0005 X:0001 Y:0002 P:envMxdizc -
$00/F181 4A LSR A A:0002 X:0001 Y:0002 P:envMxdizC -
$00/F182 4A LSR A A:0001 X:0001 Y:0002 P:envMxdizc - /8
$00/F183 85 3D STA $3D [$00:063D] A:0000 X:0001 Y:0002 P:envMxdiZC - Store A in 063D.
$00/F185 64 3E STZ $3E [$00:063E] A:0000 X:0001 Y:0002 P:envMxdiZC - Store Zero in 063E.
$00/F187 68 PLA A:0000 X:0001 Y:0002 P:envMxdiZC - Pull A from Stack,
$00/F188 29 07 AND #$07 A:0005 X:0001 Y:0002 P:envMxdizC - AND 07 Only saves bits 1,2, and 4. Anything above them is set to 00.
$00/F18A A8 TAY A:0005 X:0001 Y:0002 P:envMxdizC - Transfer A to Y.
$00/F18B 60 RTS A:0005 X:0001 Y:0005 P:envMxdizC - Return
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
$00/F136 A9 01 LDA #$01 A:0005 X:0001 Y:0005 P:envMxdizC - Load 01 into A.
$00/F138 C0 00 00 CPY #$0000 A:0001 X:0001 Y:0005 P:envMxdizC - Compare Y to 00.
$00/F13B F0 05 BEQ $05 [$F142] A:0001 X:0001 Y:0005 P:envMxdizC - If so, branch to end.
$00/F13D 0A ASL A A:0001 X:0001 Y:0005 P:envMxdizC - x2 A
$00/F13E 88 DEY A:0002 X:0001 Y:0005 P:envMxdizc - 1 Y.
$00/F13F 4C 38 F1 JMP $F138 [$00:F138] A:0002 X:0001 Y:0004 P:envMxdizc - Jump back to F138.
--------------------------------------------------------------------------------------------------
$00/F142 A6 3D LDX $3D [$00:063D] A:0020 X:0001 Y:0000 P:envMxdiZC - Load X from 063D (would be the Event Flag byte to look at)
$00/F144 1D 80 12 ORA $1280,x[$00:1280] A:0020 X:0000 Y:0000 P:envMxdiZC - Add the amount of the flag present from the Event Flag Byte.
$00/F147 9D 80 12 STA $1280,x[$00:1280] A:0039 X:0000 Y:0000 P:envMxdizC - Store A in the Event Flag.
[/code]
Very nicely done Square! This is very simple and effective.
It it quite simple really, I'll explain what Square did to look at it as well as I can...
It looks at raw hex of the Event Flag. (in this case it was 05)
It then takes that 05 and divides it by 8. This is how it finds what Event Flag Byte it is meant to be changing.
From there it stores the original flag hex and puts it into the stack and quickly withdraws it after the Event Flag Byte is found.
Once it is withdrawn it is AND'd to assure that the value is correct (remember the Event Flag Byte has already been chosen) making the last valid value as 07. Which corresponds with the last bit of a boolean)
A is transferred to Y and then is set to 01. This sets it for the proper path of being put successfully into the Event Flag Byte.
Y is compared to 00 to pass the branching condition which will occur when the original value (5 in this case) is successfully reached as an Event Flag Bit, in this case 05 would be the 5th Bit, which is 20 and that is where it is stored in the first Event Flag Byte as a 20.
I would basically just have to copy this code for the proper flag checks and your idea should be rather simple to put together PinkPuff! But I don't think I can handle that tonight. I'll give it a go tomorrow though.