Author Topic: Map event triggers  (Read 489 times)

Madsiur

  • Octomammoth
  • *
  • Posts: 24
    • View Profile
Map event triggers
« on: December 10, 2011, 11:13:45 AM »
I would like to be able to create more event trigger or event tiles than FF6LE limit us by moving that data in the ROM. That can be easily done and movin the pointers also but I have a few questions:

1) how does the game recognize which event trigger goes on which map since that data is only 5 bytes long ( X position, y position and 3 bytes for the event offset)? I ask that because if I add a new trigger manually, I suppose I can't just put it at the end of all the others. It must be regrouped with the others triggers who are on the same map... So how does the game recognize or calculate the number of triggers on the same map?

2) my second question is related to the function that loads the pointers and go to the correct event trigger and then loads the correct event. I suspect that function would be in the C0 bank but since my knowledge of that kind of coding is limited I would just like know if I found the correct function where the pointer of a event trigger is loaded:

Code: [Select]
C0/BC6F: A584    LDA $84        (from C0/00D4)
C0/BC71: D05C    BNE $BCCF
C0/BC73: A559    LDA $59
C0/BC75: D058    BNE $BCCF
C0/BC77: AC0308  LDY $0803
C0/BC7A: B96A08  LDA $086A,Y
C0/BC7D: 290F    AND #$0F
C0/BC7F: D04E    BNE $BCCF
C0/BC81: B96908  LDA $0869,Y
C0/BC84: D049    BNE $BCCF
C0/BC86: B96D08  LDA $086D,Y
C0/BC89: 290F    AND #$0F
C0/BC8B: D042    BNE $BCCF
C0/BC8D: B96C08  LDA $086C,Y
C0/BC90: D03D    BNE $BCCF
C0/BC92: A6E5    LDX $E5
C0/BC94: E00000  CPX #$0000
C0/BC97: D036    BNE $BCCF
C0/BC99: A5E7    LDA $E7
C0/BC9B: C9CA    CMP #$CA
C0/BC9D: D030    BNE $BCCF
C0/BC9F: B97C08  LDA $087C,Y
C0/BCA2: 290F    AND #$0F
C0/BCA4: C902    CMP #$02
C0/BCA6: D027    BNE $BCCF
C0/BCA8: C220    REP #$20      (16 bit accum./memory)
C0/BCAA: A582    LDA $82
C0/BCAC: 0A      ASL A
C0/BCAD: AA      TAX
C0/BCAE: BF0200C4 LDA $C40002,X
C0/BCB2: 851E    STA $1E
C0/BCB4: BF0000C4 LDA $C40000,X
C0/BCB8: C51E    CMP $1E
C0/BCBA: F013    BEQ $BCCF
C0/BCBC: AA      TAX
C0/BCBD: BF0000C4 LDA $C40000,X
C0/BCC1: C5AF    CMP $AF
C0/BCC3: F00E    BEQ $BCD3
C0/BCC5: 8A      TXA
C0/BCC6: 18      CLC
C0/BCC7: 690500  ADC #$0005
C0/BCCA: AA      TAX
C0/BCCB: E41E    CPX $1E
C0/BCCD: D0EE    BNE $BCBD
C0/BCCF: 7B      TDC
C0/BCD0: E220    SEP #$20      (8 bit accum./memory)
C0/BCD2: 60      RTS

From what I think I understand, near the end of the function (C0/BCAE) the value of two pointers are compared to each other then if they are equals we branch at $BCCF, if not there is a transfer from A to X and then the value of the pointer loaded from the same place is compared to AF$ and I really don't know what $AF hold as data. Anyway I'm not even sure if I'm looking at the right thing. So a little bit of help in assembly would be appreciated...

I'm not even at south figaro in my hack and I have no more event trigger to use so I really would like to be able to do more event creations...

Thanks in advance

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,426
  • Gender: Male
  • The return of the sombrero!
    • View Profile
    • Slick Productions
Re: Map event triggers
« Reply #1 on: December 10, 2011, 11:57:26 AM »
1) how does the game recognize which event trigger goes on which map since that data is only 5 bytes long ( X position, y position and 3 bytes for the event offset)? I ask that because if I add a new trigger manually, I suppose I can't just put it at the end of all the others. It must be regrouped with the others triggers who are on the same map... So how does the game recognize or calculate the number of triggers on the same map?
It knows by looking at the differences in the pointers.
Code: [Select]
C0/BCAE: BF0200C4 LDA $C40002,X  (load next event trigger pointer)
C0/BCB2: 851E    STA $1E
C0/BCB4: BF0000C4 LDA $C40000,X  (load current map's event trigger pointer)
C0/BCB8: C51E    CMP $1E        (do they match?)
C0/BCBA: F013    BEQ $BCCF      (if so, no event triggers for this map)
C0/BCBC: AA      TAX            (no match, so there is at least 1 trigger for this map)
C0/BCBD: BF0000C4 LDA $C40000,X  (load trigger)
C0/BCC1: C5AF    CMP $AF        (compare to current X and Y position)
C0/BCC3: F00E    BEQ $BCD3      (branch if it matches your current position)
C0/BCC5: 8A      TXA            (no match, move on to the next trigger)
C0/BCC6: 18      CLC
C0/BCC7: 690500  ADC #$0005     (add this to move to the next pointer)
C0/BCCA: AA      TAX
C0/BCCB: E41E    CPX $1E        (does the current pointer match the next map's pointer?)
C0/BCCD: D0EE    BNE $BCBD      (branch if not, there's more triggers!)
C0/BCCF: 7B      TDC
C0/BCD0: E220    SEP #$20      (8 bit accum./memory)
C0/BCD2: 60      RTS
So you can't simply just plop a pointer anywhere you wish, you need to manually adjust the pointer for the map you want, and every map afterwards. Not something to be done by hand.

119 bugs fixed and counting.

Madsiur

  • Octomammoth
  • *
  • Posts: 24
    • View Profile
Re: Map event triggers
« Reply #2 on: December 10, 2011, 10:07:28 PM »
So you can't simply just plop a pointer anywhere you wish, you need to manually adjust the pointer for the map you want, and every map afterwards. Not something to be done by hand.

I understand. I think I will put a hold on moving the pointers and the data. Thanks for commenting the code. It is much appreciated.