Users browsing this thread: 2 Guest(s)
Assembly Programming

#31
Posts: 3,971
Threads: 279
Thanks Received: 238
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Edit: Due to a non-extensive testing there was a problem with the float check and thanks to someone on romhacking.net I became aware of the problem and fixed it. The command has been now tested with all the status plus multiple status. I haven'T done ALL the possibilities but enough to be sure it fully work. I updated the code and the download link.


I created a new event command that checks if status X (passed as a parameter) is set on the party leader of th active party. If the status is set, the game will branch at the offset passed a a second parameter and if not, it will continue the event after the command. I used command 83 which had no purpose prior to that. I'll try to explain what I have done:
The first thing is to change the pointer of the command and make a jump where there is empty space, like in the F1 bank:

Code:
C0/9960        9B DF                            (Action 83 pointer)

C0/DF9B        5C 00 A0 F1        JMP $F1A000     (jump to offset F1/A000)

The next part load the character position (a value from thr RAM), and then get the party number of the character and compare it to the active party number. It's the way to know if the character is in the active party. Then the character position is compared to a value and depending of the result of the check, it will end up storing the actor number (0 to 15) of character who is in slot 1. If nobody is in slot 1, it will take slot 2. This process is repeated 16 times to check every character:

Code:
F1/A000        A9 20        LDA #$20        (Load #$20 in A)
F1/A002        85 1A        STA $1A            (Store #$20 in $1A)
F1/A004        A4 00        LDY $00            (Load $00 in Y)
F1/A006        BB          TYX                (Transfer Y to X, to zero X)
F1/A007        B9 50 18      LDA $1850,Y        (Load place of the Actor Y in the parties)
F1/A00A        29 07        AND #$07        (Get Actor's party number)
F1/A00C        CD 6D 1A      CMP $1A6D        (compare with active party number)
F1/A00F        D0 0D        BNE $A01E        (Branch if not the current party)
F1/A011        B9 50 18      LDA $1850,Y        (Load place of the Actor Y in the active party)                        
F1/A014        29 18        AND #$18        
F1/A016        C5 1A        CMP $1A            (Check if the Actor is the leader of the party)
F1/A018        B0 04        BCS $A01E        (Branch if not)                                     
F1/A01A        85 1A        STA $1A            (Store A in $1A)
F1/A01C        86 1E        STX $1E            (Store character number in $1E)
F1/A01E        E8          INX                (increment X by 1)
F1/A01F        C8          INY                (Increment Y by 1)
F1/A020        C0 10 00      CPY #$0010        (Y - 16)
F1/A023        D0 E2        BNE $A007        (branch if we didn't looped 16 times)

Once we have the actor number of the leader, we perform a status check by comparing the status set for that character in his data in the RAM to a status number passed as a parameter. If none f the status is set , it loads in differents parameters a value of 000005, which represent the jump to continue the event right after the command and parameters. If a status is checked, it will load the offset of the jump passed as parameters 2, 3 and 4. In both case it will jump to the same subroutine in bank CO which will perform the appropriate jump:

Code:
F1/A025        A5 1E        LDA $1E         (Load party Leader actor number in A)
F1/A027        8D 02 42     STA $4202       (store as multiplier A)
F1/A02A        A9 25        LDA #$25        (character data length)
F1/A02C        8D 03 42     STA $4203       (store as multiplier B)
F1/A02F        C2 20        REP #$20        (16 bit accum./memory)
F1/A031        EA           NOP             (wait for the multiplication to be done)
F1/A032        EA           NOP             (wait for the multiplication to be done)
F1/A033        EA           NOP             (wait for the multiplication to be done)
F1/A034        A4 16 42     LDY $4216       (store the result of the multiplication in Y)
F1/A037        E2 20        SEP #$20        (8 bit accum./memory)                
F1/A039        B9 14 16     LDA $1614,Y     (load byte 1 of status set)
F1/A03C        24 EB        BIT $EB         (compare to parameter)
F1/A03E        D0 21        BNE $A061       (branch if status match)
F1/A040        B9 15 16     LDA $1615,Y     (load byte 4 of status set)
F1/A043        89 80        BIT #$80        (check if float is set)                            
F1/A045        F0 06        BEQ $A04D       (Branch if float not set)
F1/A047          69 40    ADC #$40        (Add #$40 to A)
F1/A049          24 EB   BIT $EB            (are we looking for float?)
F1/A04B          D0 14     BNE $A061        (branch if not equal to parameter)
F1/A04D        C2 21        REP #$21            
F1/A04F        A5 E5        LDA $E5         (Load low and middle byte of current offset)
F1/A051       69 05 00      ADC #$0005     (Command + parameters length)
F1/A054        85 E5        STA $E5         (Save in $E5)
F1/A056        7B           TDC             (Transfer D to C)
F1/A057        E2 20        SEP #$20        (8 bit accum./memory)
F1/A059        65 E7        ADC $E7         (Add to A $E7)
F1/A05B        85 E7        STA $E7         (Store A in $E7)
F1/A05D        5C 6D 9A C0  JMP $C09A6D     (Make a 5 bytes jump from the command number in the event)
F1/A061        C2 20        REP #$20        (16 bit accum./memory)
F1/A063        A6 EC        LDX $EC         (Load parameter 2 and 3)
F1/A065        86 E5        STX $E5         (store the low and middle byte of the offset in $E5)
F1/A067        E2 20        SEP #$20        (8 bit accum./memory)
F1/A069        A5 EE        LDA $EE         (Load parameter 4)
F1/A06B        18           CLC             (clear carry)
F1/A06C        69 CA        ADC #$CA        (Add #$CA to the high byte of the offset)
F1/A06E        85 E7        STA $E7         (Stre high byte of the offset in $E7)
F1/A070        5C 6D 9A C0  JMP $C09A6D     (Make the event branching/jumping effective)

Here are the values used for the first parameter:
Code:
Blind      01
Zombie     02
Poison     04    
magitek    08
Vanish     10
Imp        20
Petrify    40
Wounded    80
Float      C0

I made a patch available here. (download link updated)

Here's an example:http://www.youtube.com/watch?v=GNeQqGZM5k8

I'm planning to make other commands based on this model to check other infos related to one character or the whole party. There is a couple of other unused event command.

  Find
Quote  



Messages In This Thread
Assembly Programming - by the_randomizer - 01-06-2012, 05:51 PM
RE: Assembly Programming - by Angelo26 - 01-12-2012, 08:50 PM
RE: Assembly Programming - by the_randomizer - 01-12-2012, 09:33 PM
RE: Assembly Programming - by madsiur - 01-15-2012, 03:01 AM
RE: Assembly Programming - by JCE3000GT - 01-16-2012, 04:40 PM
RE: Assembly Programming - by madsiur - 01-16-2012, 05:32 PM
RE: Assembly Programming - by JCE3000GT - 01-16-2012, 08:17 PM
RE: Assembly Programming - by madsiur - 01-23-2012, 02:47 AM
RE: Assembly Programming - by madsiur - 02-04-2012, 02:38 PM
RE: Assembly Programming - by madsiur - 03-25-2012, 04:32 AM
RE: Assembly Programming - by SSJ Rick - 03-25-2012, 01:05 PM
RE: Assembly Programming - by madsiur - 04-20-2012, 01:56 AM
RE: Assembly Programming - by Marketa Lazarova - 08-16-2016, 11:17 AM
RE: Assembly Programming - by seibaby - 08-16-2016, 01:21 PM
RE: Assembly Programming - by PinkMawile - 09-24-2016, 03:55 PM

Forum Jump:

Users browsing this thread: 2 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite