Users browsing this thread: 2 Guest(s)
Trying to understand subroutines

#11
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
One thing that comes in my mind is that it's an event who doesn't stop your character movement, and it makes the command which pause the event for a certain number of frames


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  

#12
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
Have to have an "FE" after your subroutine command to end the routine.

Code:
Routine
CA/0003: B2 33 5E 00           Call subroutine at CA/5E33
CA/0007: FE                Return

Subroutine
CA/5E33:  A9 ** ** **
** ** ** (bunch of event code)** ** **
CA/5EA7: FE           Return to routine.
A crappy random example from the event script.

There is a way to just Jump in stead of Jump to subroutine, but requires doing a bit check which takes up more space than calling a subroutine and ending it with an FE.

There is a bit for this that is always on or always off, but as I said, takes up more space.
Code:
C0 F0 01.     If $1F0 is clear,
79 50 01.         Branch to CB/5079
FE             Return if  set
Quick example from a file I had opened. In this case it checks to see if event bit $1F0 is clear (that bit resets ever time a map loads so should be clear unless you set it at that time) if it is clear, it makes a direct jump to the address following the check and doesn't return to that point on a return. However if there is a chance that check might fail,(if $1F0 was set) it will ignore the address and continue to the following FE.

Yeah, it can be done and is done in vanilla code, usually better to stick with sub routines though.


The only true wisdom is knowing you know nothing.
  Find
Quote  

#13
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
You mean like this?

[Image: 1st_class_junk_by_kugawattan-d9jgj4t.png]

If I do that (Jump in stead of Jump to subroutine), do I still have to end the code (at 3F/F000) with FE? I have tried with both and no luck.

'cause if I do that, the event does jump to where the new code is, but still doesn't end as it's supposed to (placing me on the world of balance map, took exact copy from CB/BEA3 to CB/BEC3).

It occurs to me I could like do another jump? Like "start here, do whatever's on this subroutine, and jump to another place where the code ends". I'm not sure why it doesn't work either.


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#14
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
If anything, you would do a bit check for a direct jump if true, to your new code, then another check and jump back to the original code that opens the world map, the other option would be to jump like that to your code, then follow your code (still in 3F/) with the code that opens the world map, following that with an FE to end the code without ever returning to your start point.

What is the line that Cyan says when you talk to him? I'll look at it and see if I can provide a more clear answer.


The only true wisdom is knowing you know nothing.
  Find
Quote  

#15
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
it should be something like: "..."


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  

#16
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
CB/BE99: B5 Pause for 15 * 5 (75) units
CB/BE9B: 4B Display dialogue message $02DF, wait for button press
CYAN: ……
CB/BE9E: FE Return

CB/BE9F: 4B Display dialogue message $02DE, wait for button press
SHADOW: Leave 'em alone.
CB/BEA2: FE Return

And then the code that puts you in the world map:


CB/BEA3: 5A Fade screen at speed $04
CB/BEA5: 5C Pause execution until fade in or fade out is complete
CB/BEA6: 3B Position character in a "ready-to-go" stance
CB/BEA7: 3F Assign character $02 (Actor in stot 2) to party 1
CB/BEAA: C0 If ($1E80($18D) [$1EB1, bit 5] is set), branch to $CBBEE5
CB/BEB0: B2 Call subroutine $CB6A37
CB/BEB4: B2 Call subroutine $CACB95
CB/BEB8: 3B Position character in a "ready-to-go" stance
CB/BEB9: 31 Begin action queue for character $31 (Party Character 0), 2 bytes long (Wait until complete)
CB/BEBB: CE Turn vehicle/entity down
CB/BEBC: FF End queue
CB/BEBD: 6B Load map $0000 (World of Balance) instantly, (upper bits $2400), place party at (178, 93), facing down
CB/BEC3: FF End map script


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#17
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
Forgive the short answer, but don't have time to recap exactly what all your trying to accomplish, that being said:

CB/BE8D is where the timer is set. That line of code should run, start the timer, then continue through CB/BE93 down to CB/BE98 and return to the "source" (the code that keeps the game running). The timer is running this whole time even though that event has run through, when the timer finally runs out, it starts the code at CB/BEA3 which takes you to the world map.

Point is, in order to remove that code easily, I'd suggest leaving CB/BEA3 where it is and use talking to Cyan (the code at CB/BE9B as a trigger to activate the code at BEA3. Make a jump for custom code at CB/BE8D. If you use a bit check to JUMP, end it with a FE and end it, if you do a jump to subroutine then do your 4 byte subroutine, followed by FE (should have plenty of space) as well as having a FE at the end of your sub routine code.

Not sure if that's the goal or not, sorry if I'm mistaken on your goal. My best guess for the issue is you've removed a small piece of code that the game is trying to access in there so the game is getting lost and don't know where to continue or its just not making its way back to the "go to world map" code.

Could make your jump to free space somewhere sooner in the code, but I would still return to CB/BEA3 and run that part of code where it is however you direct a code to it.

Again, sorry if that isn't much help.


The only true wisdom is knowing you know nothing.
  Find
Quote  

#18
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
After Cyan sees his family depart, the game fades out and in another map where Cyan and Shadow are npcs and all the good stuff. You can talk to both there but to exit the scene there's a countdown that, when reaches 0, fades out and in the world of balance, continuing the game.

What I'm trying to do:
1) remove the countdown.
2) Talking to Cyan triggers a scene where the team leaves, after which it stars running the events at CB/BEA3 which leads me to the world of balance, continuing the game. It's this last part what I can't do. It plays the event just fine, even does the fade screen part.

What I did specifically is 'FD' from CB/BE8D to CB/BE92. Doing so removes the countdown just fine. You can stay there forever and nothing happens.
Then, at CB/BE99 (talk to Cyan) I ran a subroutine (or, more recently, the Code:
C0 F0 01. If $1F0 is clear,
00 F0 35. Branch to 3F/F000
FE Return if set)
to 3F/F000. I wrote my code there, and then literally copy pasted from CB/BEA3 to CB/BEC3, the "set party group and go to world of balance" code, to be clear, ending it with FE.

EDIT: Fixed the code. Derp.


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  

#19
Posts: 2,550
Threads: 98
Thanks Received: 148
Thanks Given: 160
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
(12-08-2015, 06:11 PM)Kugawattan Wrote: Then, at CB/BE99 (talk to Cyan) I ran a subroutine (or, more recently, the Code:
C0 F0 01. If $1F0 is clear,
35 F0 00. Branch to 3F/F000
FE Return if set)

You must mean 00 F0 35? If you have it like you wrote it here, that would jump to CA/F035.


We are born, live, die and then do the same thing over again.
Quote  
[-] The following 1 user says Thank You to Gi Nattak for this post:
  • Catone (12-08-2015)

#20
Posts: 378
Threads: 94
Thanks Received: 17
Thanks Given: 26
Joined: Jul 2013
Reputation: 11
Status
Charmed
Yes, I meant that. Sorry.


Step forward, spriters! We are also responsible to make hacks look new and fresh, we are no less important than code or ASM hackers! CHARGE!!
Quote  



Forum Jump:

Users browsing this thread: 2 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite