Skip to content

Commit

Permalink
Update AoE for new Debuffs (#485)
Browse files Browse the repository at this point in the history
Co-authored-by: Veslyquix <[email protected]>
  • Loading branch information
Vesly01 and Veslyquix authored May 20, 2023
1 parent 878d544 commit c22a375
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 127 deletions.
34 changes: 19 additions & 15 deletions EngineHacks/ExternalHacks/AoE/AoE.lyn.event
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ORG CURRENTOFFSET+$60;AoE_StartBlockingProc:
ORG CURRENTOFFSET+$40;AoE_PauseForAnimation:
ORG CURRENTOFFSET+$30;AoE_GenericEffect:
ORG CURRENTOFFSET+$9c;AoE_EventForUnitsInRange:
ORG CURRENTOFFSET+$14c;AoE_TryEventLoop:
ORG CURRENTOFFSET+$a8;AoE_GetTableEntryPointer:
ORG CURRENTOFFSET+$a8;AoE_TryEventLoop:
ORG CURRENTOFFSET+$ac;AoE_GetTableEntryPointer:
ORG CURRENTOFFSET+$20;AoE_ClearGraphics:
ORG CURRENTOFFSET+$30;AoE_ClearRangeMap:
ORG CURRENTOFFSET+$20;AoE_ClearMoveMap:
Expand All @@ -49,52 +49,56 @@ WORD $1C04B5F0 $681B4B4B $D00C2B00 $290079A1 $29FFD009 $4848D007 $469E6800 $2800
POIN AoE_SkillTester
WORD $3004E50
POIN AoE_Pokemblem_MoveTester
WORD $203A958 $8083DA8 $801756C $8016574 $80167A4 $8017548 $80176B8 $46C046C0 $480FB500 $21006800 $469E4B0E $BC01F800 $46C04700 $46C046C0 $46C046C0 $46C046C0 $1C04B570 $1C161C0D $FC52F000 $1C201C02 $1C331C29 $F92CF000 $BC01BC70 $4700 $2024CB0 $8001220 $4644B5F0 $464DB410 $4656B420 $4680B440
WORD $203A958 $8083DA8 $801756C $8016574 $80167A4 $8017548 $80176B8 $46C046C0 $480FB500 $21006800 $469E4B0E $BC01F800 $46C04700 $46C046C0 $46C046C0 $46C046C0 $1C04B570 $1C161C0D $FC02F000 $1C201C02 $1C331C29 $F92CF000 $BC01BC70 $4700 $2024CB0 $8001220 $4644B5F0 $464DB410 $4656B420 $4680B440
SHORT ((Draw_LoadNumbers-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((Draw_LoadNumbers-4-CURRENTOFFSET>>1)&$7FF)|$F800
WORD $68244C32 $4B3246A1 $885F881E $3D012500 $42BD3501 $2400DA51 $A83C01 $5819464B $42B43401 $5D08DAF4 $D0F928FF $1C291C20 $68124A28 $18520089 $18126812 $28007810 $4B25D0EB $F800469E $D0E62800 $48234682 $46516800 $7A5B4643 $42132201 $4642D009 $F0002301 $4653FE99 $42987C9B $1C18DD08 $4642E006 $F0002301 $2800FCE5 $2000DA00 $7C9B4653 $D0114283 $D00D2800 $46531A1B $1C0B7C99 $1C181A1B $4350220B $29004653 $DF06D0BB $E0031C02 $E001220B $E7FF220C $1C291C20
WORD $68244C32 $4B3246A1 $885F881E $3D012500 $42BD3501 $2400DA51 $A83C01 $5819464B $42B43401 $5D08DAF4 $D0F928FF $1C291C20 $68124A28 $18520089 $18126812 $28007810 $4B25D0EB $F800469E $D0E62800 $48234682 $46516800 $7A5B4643 $42132201 $4642D009 $F0002301 $4653FE49 $42987C9B $1C18DD08 $4642E006 $F0002301 $2800FC95 $2000DA00 $7C9B4653 $D0114283 $D00D2800 $46531A1B $1C0B7C99 $1C181A1B $4350220B $29004653 $DF06D0BB $E0031C02 $E001220B $E7FF220C $1C291C20
SHORT ((Draw_HPBar_AoE-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((Draw_HPBar_AoE-4-CURRENTOFFSET>>1)&$7FF)|$F800
WORD $BC40E7AF $BC2046B2 $BC1046A9 $BCF046A0 $4700BC01 $202E4E0 $202E4D4 $202E4D8 $8019430 $3004E50 $4644B5F0 $464DB410 $4656B420 $465FB440 $4680B480 $7A40468B $42082101
SHORT $D002
SHORT ((LoadBlueNumbers-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((LoadBlueNumbers-4-CURRENTOFFSET>>1)&$7FF)|$F800
SHORT $E001
SHORT ((Draw_LoadNumbers-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((Draw_LoadNumbers-4-CURRENTOFFSET>>1)&$7FF)|$F800
WORD $68244C29 $4B2946A1 $885F881E $3D012500 $42BD3501 $2400DA3C $A83C01 $5819464B $42B43401 $5D08DAF4 $D0F928FF $1C291C20 $68124A1F $18520089 $18126812 $28007810 $4B1CD0EB $F800469E $D0E62800 $481A4682 $46516800 $7A5B4643 $42132201 $4642D00A $F0002301 $4653FE15 $7CDB7C9A $D0D4429A $E0061AC3 $23014642 $FC60F000 $7CDB4653 $465A1A1B $1C206AD2
WORD $68244C29 $4B2946A1 $885F881E $3D012500 $42BD3501 $2400DA3C $A83C01 $5819464B $42B43401 $5D08DAF4 $D0F928FF $1C291C20 $68124A1F $18520089 $18126812 $28007810 $4B1CD0EB $F800469E $D0E62800 $481A4682 $46516800 $7A5B4643 $42132201 $4642D00A $F0002301 $4653FDC5 $7CDB7C9A $D0D4429A $E0061AC3 $23014642 $FC10F000 $7CDB4653 $465A1A1B $1C206AD2
SHORT $1C29
SHORT ((Draw_NumberDuringAoE-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((Draw_NumberDuringAoE-4-CURRENTOFFSET>>1)&$7FF)|$F800
SHORT $E7C4
WORD $46BBBC80 $46B2BC40 $46A9BC20 $46A0BC10 $BC01BCF0 $4700 $202E4E0 $202E4D4 $202E4D8 $8019430 $3004E50 $1C04B510 $332C4B0C $28006818 $F000D005 $1C21FB4F $FF82F7FF $1C20E005 $4B072101 $F800469E $2100E004 $4B041C20 $F800469E $BC01BC10 $4700 $30004B8 $8002F24 $2103B500 $4B064805 $F800469E $4B05B401 $F800469E $62C8BC02 $4700BC01
WORD $46BBBC80 $46B2BC40 $46A9BC20 $46A0BC10 $BC01BCF0 $4700 $202E4E0 $202E4D4 $202E4D8 $8019430 $3004E50 $1C04B510 $332C4B0C $28006818 $F000D005 $1C21FAFF $FF82F7FF $1C20E005 $4B072101 $F800469E $2100E004 $4B041C20 $F800469E $BC01BC10 $4700 $30004B8 $8002F24 $2103B500 $4B064805 $F800469E $4B05B401 $F800469E $62C8BC02 $4700BC01
POIN AoE_DrawDamageProc
WORD $8002C7C $8000D28 $46C046C0 $46C046C0 $1C04B5F0 $1C161C0D $489C1C1F $21FF6800 $469E4B9B $489BF800 $21FF6800 $469E4B98 $7BB2F800 $19D20092 $49970092 $1C20588A
SHORT $1C29
SHORT ((CreateMoveMapFromTemplate-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((CreateMoveMapFromTemplate-4-CURRENTOFFSET>>1)&$7FF)|$F800
SHORT $7A71
WORD $40082001 $D0012800 $E0002044 $4B912042 $F800469E $F7FF1C30 $BCF0FEB3 $4700BC01 $46C046C0 $46C046C0 $1C04B5F0 $F866F000 $1C0E1C05 $D00E28FF $F0002202 $2801F835 $B081DD09 $1C299000 $23021C32 $4F821C20 $F80046BE $BCF0B001 $4700BC01 $46C046C0 $46C046C0 $46C046C0 $1C04B5F0 $F87CF000 $1C0E1C05 $D00E28FF $F0002201 $2801F815 $B081DD09 $1C299000 $23011C32 $4F721C20 $F80046BE $BCF0B001 $4700BC01 $46C046C0 $46C046C0 $46C046C0 $1C15B5F0 $881E4B6B $4C64885F $2D026824 $2D01D00E $2500D119 $30013501 $DA1542B0 $191B008B $181B681B $2AFF781A $E00DD1F4 $35012500 $42B93101 $8BDA08 $681B191B $781A181B $D1F42AFF $2500E000 $BCF01C28 $4718BC08 $4647B5F0 $4B56B480 $885B881E $4B554698 $2700685D $49532000 $60083130 $68244C4A $3B012300 $45433301 $98DA19 $22005821 $32013A01 $DAF542B2 $28FF5C88 $3701D0F9 $DBF642AF $5C081C50 $D00128FF $E0002001 $49442000 $60083130 $1C191C10 $20FFE001 $BC8021FF $BCF046B8 $4718BC08 $4647B5F0 $4B3BB480 $885B881E $4B3A4698 $2700685D $49382000 $60083130 $68244C2F $3A012200 $42B23201 $2300DA1B $33013B01 $DAF74543 $58210098 $28FF5C88 $3701D0F7 $DBF442AF $801C58 $5C885821 $D00128FF $E0002001 $49282000 $60083130 $1C191C10 $20FFE001 $BC8021FF $BCF046B8 $4718BC08 $4C22B5F0 $F0006824 $1C05FA13 $FA48F000 $20017A69 $42084B1E $4B1ED000 $491E1C20 $FD26F000 $BC01BCF0 $46C04700 $46C046C0 $1C07B5F0 $F9FCF000 $7BE01C04 $8000C1 $1C051840 $59704E15 $D0022800 $1C384686 $BCF0F800 $4700BC01 $1C04B510 $469E4B10 $62E0F800 $BC01BC10 $4700 $202E4E0 $80197E4 $202E4F0
WORD $40082001 $D0012800 $E0002044 $4B912042 $F800469E $F7FF1C30 $BCF0FEB3 $4700BC01 $46C046C0 $46C046C0 $1C04B5F0 $F866F000 $1C0E1C05 $D00E28FF $F0002202 $2801F835 $B081DD09 $1C299000 $23021C32 $4F821C20 $F80046BE $BCF0B001 $4700BC01 $46C046C0 $46C046C0 $46C046C0 $1C04B5F0 $F87CF000 $1C0E1C05 $D00E28FF $F0002201 $2801F815 $B081DD09 $1C299000 $23011C32 $4F721C20 $F80046BE $BCF0B001 $4700BC01 $46C046C0 $46C046C0 $46C046C0 $1C15B5F0 $881E4B6B $4C64885F $2D026824 $2D01D00E $2500D119 $30013501 $DA1542B0 $191B008B $181B681B $2AFF781A $E00DD1F4 $35012500 $42B93101 $8BDA08 $681B191B $781A181B $D1F42AFF $2500E000 $BCF01C28 $4718BC08 $4647B5F0 $4B56B480 $885B881E $4B554698 $2700685D $49532000 $60083130 $68244C4A $3B012300 $45433301 $98DA19 $22005821 $32013A01 $DAF542B2 $28FF5C88 $3701D0F9 $DBF642AF $5C081C50 $D00128FF $E0002001 $49442000 $60083130 $1C191C10 $20FFE001 $BC8021FF $BCF046B8 $4718BC08 $4647B5F0 $4B3BB480 $885B881E $4B3A4698 $2700685D $49382000 $60083130 $68244C2F $3A012200 $42B23201 $2300DA1B $33013B01 $DAF74543 $58210098 $28FF5C88 $3701D0F7 $DBF442AF $801C58 $5C885821 $D00128FF $E0002001 $49282000 $60083130 $1C191C10 $20FFE001 $BC8021FF $BCF046B8 $4718BC08 $4C22B5F0 $F0006824 $1C05F9C3 $F9F8F000 $20017A69 $42084B1E $4B1ED000 $491E1C20 $FCD6F000 $BC01BCF0 $46C04700 $46C046C0 $1C07B5F0 $F9ACF000 $7BE01C04 $8000C1 $1C051840 $59704E15 $D0022800 $1C384686 $BCF0F800 $4700BC01 $1C04B510 $469E4B10 $62E0F800 $BC01BC10 $4700 $202E4E0 $80197E4 $202E4F0
POIN RangeTemplateIndexList
WORD $801DA98 $801F780 $202E4D4 $30004B8 $3004E50
POIN AoE_FreeSelect
POIN AoE_HealFreeSelect
POIN CURRENTOFFSET+2585
POIN CURRENTOFFSET+2425
POIN AoE_Animation_Table
WORD $8000D28 $4B27B500 $7819332C $2000789A $469E4B25 $2000F800 $4708BC02 $4B21B500 $7819332C $4B21789A $F800469E $4708BC02 $4B1CB5F0 $6099491E $F9AAF000 $7BE01C04 $60584B18 $2101481B $469E4B1B $7BE0F800 $8000C1 $1C051840 $35044E18 $28005970 $2101D003 $469E4B14 $3504F800 $28005B70 $2100D003 $469E4B12 $4812F800 $4B0E2101 $F800469E $BC01BCF0 $46C04700 $46C046C0 $1C04B530 $480C1C21 $469E4B0C $BC30F800 $4700BC01 $30004B8 $8015E0D $8015E0C $FFFFFFFF
WORD $8000D28 $4B27B500 $7819332C $2000789A $469E4B25 $2000F800 $4708BC02 $4B21B500 $7819332C $4B21789A $F800469E $4708BC02 $4B1CB5F0 $6099491E $F95AF000 $7BE01C04 $60584B18 $2101481B $469E4B1B $7BE0F800 $8000C1 $1C051840 $35044E18 $28005970 $2101D003 $469E4B14 $3504F800 $28005B70 $2100D003 $469E4B12 $4812F800 $4B0E2101 $F800469E $BC01BCF0 $46C04700 $46C046C0 $1C04B530 $480C1C21 $469E4B0C $BC30F800 $4700BC01 $30004B8 $8015E0D $8015E0C $FFFFFFFF
POIN Call_AoE_ExternalAnimationEvent
WORD $800D07C
POIN AoE_Animation_Table
WORD $80D01FC
POIN Clear_sBEvent
POIN AoE_MainProc
WORD $8002CE0 $1C04B530 $4B282000 $6818332C $D0002800 $1C20E004 $469E4B25 $2001F800 $BC02BC30 $46C04708 $46C046C0 $46C046C0 $46C046C0 $1C05B530 $681B4B1E $D02F2B00 $F940F000 $7BA21C04 $4B180092 $79B7B1B $18D20F9B $49180092 $F0005888 $7A61F97B $42082020 $1C20D002 $F9ECF000 $28007A20 $4B10D008 $7CD9681B $DC014281 $38011C08 $74D91A09 $20017A61 $D0014208 $E000480B $4B0C480B $F800469E $4B0A480B $F800469E $2001490A $BC307448 $4700BC01 $30004B8 $8002E94 $3004E50
WORD $8002CE0 $1C04B530 $4B282000 $6818332C $D0002800 $1C20E004 $469E4B25 $2001F800 $BC02BC30 $46C04708 $46C046C0 $46C046C0 $46C046C0 $1C05B530 $681B4B1E $D02F2B00 $F8F0F000 $7BA21C04 $4B180092 $79B7B1B $18D20F9B $49180092 $F0005888 $7A61F92B $42082020 $1C20D002 $F99CF000 $28007A20 $4B10D008 $7CD9681B $DC014281 $38011C08 $74D91A09 $20017A61 $D0014208 $E000480B $4B0C480B $F800469E $4B0A480B $F800469E $2001490A $BC307448 $4700BC01 $30004B8 $8002E94 $3004E50
POIN RangeTemplateIndexList
POIN CURRENTOFFSET+1929
POIN CURRENTOFFSET+2313
POIN CURRENTOFFSET+1769
POIN CURRENTOFFSET+2153
WORD $8024EAC
POIN CURRENTOFFSET+9
WORD $203A958 $1C04B5F0 $F8F6F000 $1C201C05 $681B4B49 $D0572B00 $F800469E $7CA81C06 $21044B46 $181B4348 $139681F $79720F09 $4013230F $DB034299 $401323F0 $71714319 $1C017830 $4011220F $4291403A $21F0DC03 $43104008 $78307030 $22F01C01 $403A4011 $DC034291 $4008210F $70304310 $78700A3F $220F1C01 $403A4011 $DC034291 $400821F0 $70704310 $1C017870 $401122F0 $4291403A $210FDC03 $43104008 $A3F7070 $1C0178B0 $4011220F $4291403A $21F0DC03 $43104008 $78B070B0 $22F01C01 $403A4011 $DC034291 $4008210F $70B04310 $4B1E481D $F800469E $D0002800 $481CE020 $469E4B1A $2800F800 $1C01D026 $4B194816 $F800469E $1C022100 $70513228 $70D17091 $60916051 $611160D1 $61916151 $621161D1 $62916251 $631162D1 $63916351 $641163D1 $30291C06 $31017801 $39017001 $DC032940 $332C1C33 $54587AE0 $BC01BCF0 $4700
WORD $203A958 $1C04B5F0 $F8A6F000 $1C201C05 $681B4B20 $D0062B00 $F800469E $491E1C06
SHORT $7CAA
SHORT ((DebuffGivenTableEntry-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((DebuffGivenTableEntry-4-CURRENTOFFSET>>1)&$7FF)|$F800
SHORT $481D
WORD $469E4B1D $2800F800 $E020D000 $4B1A481B $F800469E $D0262800 $48161C01 $469E4B18 $2100F800 $32281C02 $70917051 $605170D1 $60D16091 $61516111 $61D16191 $62516211 $62D16291 $63516311 $63D16391 $1C066411 $78013029 $70013101 $29403901 $1C33DC03 $7AE0332C $BCF05458 $4700BC01
POIN AoE_GetDebuffs
POIN AoE_DebuffTable
POIN AoE_EventQueueProc
WORD $8002E9C $859AAD8 $8002CE0 $1C07B5F0 $4B20481F $F800469E $D1312800 $30291C38 $29407841 $3101DC26 $39017041 $302C1C38 $2A005C42 $1C10D01E $469E4B17 $2800F800 $1C04D01E $F836F000 $7CE81C05 $4E130080 $4B131836 $79006820 $332C6098 $7C617C20 $80598018 $28006830 $2101D00A $469E4B0D $E005F800 $21011C38 $469E4B0B $E004F800 $21001C38 $469E4B08 $BCF0F800 $4700BC01 $8591AC0 $8002E9C $8019430
WORD $8002E9C $859AAD8 $8002CE0 $1C07B5F0 $4B20481F $F800469E $D1312800 $30291C38 $29407841 $3101DC26 $39017041 $302C1C38 $2A005C42 $1C10D01E $469E4B17 $2800F800 $1C04D01E $F838F000 $7CE81C05 $4E130080 $4B131836 $79006820 $332C6098 $7C617C20 $80598018 $28006830 $2101D00A $469E4B0D $E005F800 $21011C38 $469E4B0B $E004F800 $21001C38 $469E4B08 $BCF0F800 $4700BC01 $8591AC0 $8002E9C $8019430
POIN AoE_EventsTable
WORD $30004B8 $800D07C $8002F24 $46C046C0 $46C046C0 $484EB500 $78006800 $781B4B4D $484D4343 $BC0218C0 $46C04708 $46C046C0 $46C046C0 $F000B500 $4B48F815 $F800469E $FB80F7FF $469E4B46 $4B46F800 $F800469E
WORD $30004B8 $800D07C $8002F24 $46C046C0 $46C046C0 $46C046C0 $484EB500 $78006800 $781B4B4D $484D4343 $BC0218C0 $46C04708 $46C046C0 $46C046C0 $F000B500 $4B48F815 $F800469E $FBD0F7FF $469E4B46 $4B46F800 $F800469E
SHORT ((Draw_RoundCleanup-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((Draw_RoundCleanup-4-CURRENTOFFSET>>1)&$7FF)|$F800
WORD $4700BC01 $46C046C0 $46C046C0 $46C046C0 $4840B500 $21006800 $469E4B3F $BC01F800 $46C04700 $46C046C0 $46C046C0 $46C046C0 $483AB500 $21006800 $4B373901 $F800469E $4700BC01 $46C046C0 $46C046C0 $46C046C0 $1C05B5F0 $FFDCF7FF $68044831 $7CD84B31 $1C2A7D19
SHORT ((CreateRangeMapFromTemplate-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((CreateRangeMapFromTemplate-4-CURRENTOFFSET>>1)&$7FF)|$F800
Expand Down
116 changes: 6 additions & 110 deletions EngineHacks/ExternalHacks/AoE/AoE.s
Original file line number Diff line number Diff line change
Expand Up @@ -1418,116 +1418,12 @@ beq NoDebuffsPossible
mov lr, r3
.short 0xF800 @ blh
mov r6, r0 @ debuffs pointer
ldrb r0, [r5, #DebuffID]
ldr r3, =AoE_DebuffTable
mov r1, #4 @ 4 bytes per entry
mul r0, r1
add r3, r0 @ Specific entry
ldr r7, [r3]
lsl r1, r7, #4 @ mag only
lsr r1, #28 @ mag only
ldrb r2, [r6, #5] @ RallyMag/Mag
mov r3, #0xF
and r3, r2 @ mag debuff only
cmp r1, r3
blt NoMagDebuff @ they have a worse debuff already
mov r3, #0xF0
and r3, r2 @ rally mag only
orr r1, r3 @ rally mag/mag debuff
strb r1, [r6, #5] @ mag stored back in
NoMagDebuff:



ldrb r0, [r6] @ str
mov r1, r0
mov r2, #0xF
and r1, r2
and r2, r7 @ str only
cmp r1, r2
bgt NoStrDebuff
mov r1, #0xF0
and r0, r1
orr r0, r2
strb r0, [r6]
NoStrDebuff:

ldrb r0, [r6] @ str
mov r1, r0
mov r2, #0xF0
and r1, r2
and r2, r7 @ str only
cmp r1, r2
bgt NoSklDebuff
mov r1, #0xF
and r0, r1
orr r0, r2
strb r0, [r6]
NoSklDebuff:



lsr r7, #8

ldrb r0, [r6, #1] @ str
mov r1, r0
mov r2, #0xF
and r1, r2
and r2, r7 @ str only
cmp r1, r2
bgt NoSpdDebuff
mov r1, #0xF0
and r0, r1
orr r0, r2
strb r0, [r6, #1]
NoSpdDebuff:

ldrb r0, [r6, #1]
mov r1, r0
mov r2, #0xF0
and r1, r2
and r2, r7
cmp r1, r2
bgt NoDefDebuff
mov r1, #0xF
and r0, r1
orr r0, r2
strb r0, [r6, #1]
NoDefDebuff:

lsr r7, #8

ldrb r0, [r6, #2]
mov r1, r0
mov r2, #0xF
and r1, r2
and r2, r7
cmp r1, r2
bgt NoResDebuff
mov r1, #0xF0
and r0, r1
orr r0, r2
strb r0, [r6, #2]
NoResDebuff:

ldrb r0, [r6, #2]
mov r1, r0
mov r2, #0xF0
and r1, r2
and r2, r7
cmp r1, r2
bgt NoLukDebuff
mov r1, #0xF
and r0, r1
orr r0, r2
strb r0, [r6, #2]
NoLukDebuff:


@0-2: Debuffs, 4 bits each (str/skl/spd/def/res/luk)
@3: Rallys (bit 7 = rally move, bit 8 = rally spectrum)
@4: Str/Skl Silver Debuff (6 bits), bit 7 = half strength, HO bit = Hexing Rod
@5: (RallyMag<<4)||MagDebuff
ldr r1, =AoE_DebuffTable
ldrb r2, [r5, #DebuffID]
@r0 @ debuff entry
@r1 debuff table to use
@r2 entry ID of the given table
bl DebuffGivenTableEntry

NoDebuffsPossible:

Expand Down
4 changes: 2 additions & 2 deletions EngineHacks/ExternalHacks/AoE/Installer.event
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ ENDA
ALIGN 4
AoE_DebuffTable:
WORD 0
WORD 0x1234567 // Mag, Luk, Res, Def, Spd, Skl, Str
WORD 0x2345678
//DebuffUnitEntry(mag, str, skl, spd, def, res, luk, mov)
DebuffUnitEntry(5, 5, 0,0,0,0,0,0)// -5 mag/str from this AoE

#define Sword 0
#define Lance 1
Expand Down
1 change: 1 addition & 0 deletions EngineHacks/Necessary/Debuffs/Debuffs.event
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ TeamDebuffTables:
#include "asm/GetUnitDebuffEntry.lyn.event"
#include "asm/ProcessDebuffs.lyn.event"
#include "asm/SetUnitDebuffASMC.lyn.event"
#include "asm/DebuffGivenTableEntry.lyn.event"


ALIGN 4
Expand Down
13 changes: 13 additions & 0 deletions EngineHacks/Necessary/Debuffs/asm/DebuffGivenTableEntry.lyn.event
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALIGN 4
PUSH
ORG CURRENTOFFSET+$1;DebuffGivenTableEntry:
POP
WORD $1C06B5F0 $188900D2 $4A1A1C0F $1C0C6811 $25002240 $35013D01 $DA2842A5 $4A161C30 $1C296812
SHORT $4351
SHORT ((UnpackData_Signed-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((UnpackData_Signed-4-CURRENTOFFSET>>1)&$7FF)|$F800
SHORT $2240
WORD $29005D79 $2980D0F1 $1C0BDA09 $28004393 $4143DA00 $DBE84283 $D00A4211 $233FE011 $425B400B $DD002800 $42834143 $4211DCDD $1C30D007 $68124A05 $43511C29
SHORT ((PackData_Signed-4-CURRENTOFFSET>>12)&$7FF)|$F000 ((PackData_Signed-4-CURRENTOFFSET>>1)&$7FF)|$F800
WORD $BCF0E7D3 $4700BC01
POIN DebuffNumberOfStats_Link
POIN DebuffStatNumberOfBits_Link
102 changes: 102 additions & 0 deletions EngineHacks/Necessary/Debuffs/asm/DebuffGivenTableEntry.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
.thumb

.global DebuffGivenTableEntry
.type DebuffGivenTableEntry, %function
DebuffGivenTableEntry:
push {r4-r7, lr}
mov r6, r0 @ debuff entry
@r1 debuff table to use
@r2 entry ID of the given table

lsl r2, #3 @ 8 bytes per entry
add r1, r2 @ table entry we desire
mov r7, r1 @ table entry

@ r5 = counter of which stat we're on
ldr r2, =DebuffNumberOfStats_Link
ldr r1, [r2] @ max
mov r4, r1

mov r2, #0x40 @ no 0x40 bitflag of Swap

mov r5, #0 @ counter
sub r5, #1

Loop:
add r5, #1
cmp r5, r4
bge End

mov r0, r6 @ debuff entry
ldr r2, =DebuffStatNumberOfBits_Link
ldr r2, [r2]
mov r1, r5 @ counter
mul r1, r2 @ bit offset
bl UnpackData_Signed
@ r0 as data
mov r2, #0x40
ldrb r1, [r7, r5] @ table data uses a byte per stat


@ positive affects user
@ positive swap affects opponent
@ negative affects enemy
@ negative swap affects self

@ if new value is positive
@ > positive old value, replace
@ < positive old value, ignore
@ negative old value, add

@ if new value is negative
@ > old value, ignore
@ < old value, replace
@ positive old value, add

cmp r1, #0
beq Loop
cmp r1, #0x80
bge NegativeA

@ new value is positive
mov r3, r1
bic r3, r2 @ remove 0x40 swap bitflag
cmp r0, #0
bge DontAddToValue
adc r3, r0 @ to remove negatives first
DontAddToValue:
cmp r3, r0
blt Loop @ if buffed stat is worse than what we already had, do nothing
tst r1, r2
beq AffectUser
b End

NegativeA: @ new value will be negative
mov r3, #0x3F
and r3, r1
neg r3, r3
cmp r0, #0
ble DontAddToValue_Negative
adc r3, r0 @ to remove positives first
DontAddToValue_Negative:
cmp r3, r0
bgt Loop @ if debuffed stat is less bad than before (a higher # since we're negative), do nothing
tst r1, r2
beq End

AffectUser:
mov r0, r6 @ debuff entry
ldr r2, =DebuffStatNumberOfBits_Link
ldr r2, [r2]
mov r1, r5 @ counter
mul r1, r2 @ bit offset
bl PackData_Signed
b Loop

End:

pop {r4-r7}
pop {r0}
bx r0
.ltorg

2 changes: 2 additions & 0 deletions Tables/ExternalTables.event
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#define WepDebuffEntry(mag, str, skl, spd, def, res, luk, mov) "BYTE (mag|DebuffEnemy) (str|DebuffEnemy) (skl|DebuffEnemy) (spd|DebuffEnemy) (def|DebuffEnemy) (res|DebuffEnemy) (luk|DebuffEnemy) (mov|DebuffEnemy)"
#define WepBuffEntry(mag, str, skl, spd, def, res, luk, mov) "BYTE mag str skl spd def res luk mov"
#define DebuffSelfEntry(mag, str, skl, spd, def, res, luk, mov) "BYTE mag|DebuffSelf str|DebuffSelf skl|DebuffSelf spd|DebuffSelf def|DebuffSelf res|DebuffSelf luk|DebuffSelf mov|DebuffSelf"
#define DebuffUnitEntry(mag, str, skl, spd, def, res, luk, mov) "BYTE mag|DebuffSelf str|DebuffSelf skl|DebuffSelf spd|DebuffSelf def|DebuffSelf res|DebuffSelf luk|DebuffSelf mov|DebuffSelf"
// optional macros

// max boost is +63/-63 and is definable based on # of bits (31 and 15 also work)
Expand Down

0 comments on commit c22a375

Please sign in to comment.