Users browsing this thread: 1 Guest(s)
Rock-paper-scissors mini-game

#1
Posts: 2,569
Threads: 99
Thanks Received: 160
Thanks Given: 169
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
I want to post this breakdown of the Rock-paper-scissors mini-game code to show what all went in to making it work.
video of RPS event: https://www.youtube.com/watch?v=5iGdupamiEQ&t=

multipurpose bits usage:
179 player chooses rock
17B player chooses paper
17C player chooses scissors
17D npc chooses rock
17E npc chooses paper
180 npc chooses scissors

33D6B0-33D6BE (initiate event)
B2 90 D7 29 (clears multipurpose bits for use)
4B 03 0D ("Wanna play Rock-paper-scissors?")
B6 70 D8 29 B3 5E 00 (if yes, goto 33D870, if no, do nothing)
FE (end)

33D870-33D8B1:
85 64 00 (take 100 gp from party, is given back after if draw or x2 if win)
C0 BE 81 FF 69 01 (check if have enough gp, if not say "not enough gp" and exit)
4B 04 0D ("Choose one...")
93 (pause)
22 11 48 E0 02 CD E0 01 48 E0 02 CD E0 01 48 E0 08 CD FF (npc doing rps actions)
31 91 08 E0 02 CD E0 01 08 E0 02 CD E0 01 08 E0 08 CD FF (player doing rps actions)
B6 (branch for player choosing rock, paper, or scissors.)
D0 D6 29 (rock goto 33D6D0)
D0 D7 29 (paper goto 33D7D0)
F0 D7 29 (scissors goto 33D7F0)
FE (end)

33D6D0-33D6E2 (rock)
D2 79 (sets multipurpose bit 179)
BD 60 ED 29 (Pseudo-randomly jump to 33ED60)
BD B0 ED 29 (Pseudo-randomly jump to 33EDB0)
BD C0 D7 29 (Pseudo-randomly jump to 33EE00)
C0 27 01 D2 D6 29 (branches back to 1st one in case it didn't do any of them.)
FE (end)

33D7D0-33D7E2 (paper)
D2 7B (sets multipurpose bit 17B)
BD 60 ED 29 (Pseudo-randomly jump to 33ED60)
BD B0 ED 29 (Pseudo-randomly jump to 33EDB0)
BD C0 D7 29 (Pseudo-randomly jump to 33EE00)
C0 27 01 D2 D7 29 (branches back to 1st one in case it didn't do any of them.)
FE (end)

33D7F0-33D802 (scissors)
D2 7C (sets multipurpose bit 17C)
BD 60 ED 29 (Pseudo-randomly jump to 33ED60)
BD B0 ED 29 (Pseudo-randomly jump to 33EDB0)
BD C0 D7 29 (Pseudo-randomly jump to 33EE00)
C0 27 01 F2 D7 29 (branches back to 1st one in case it didn't do any of them.)
FE (end)

33ED60-33EDAA (1st Pseudo-random jump path)
D2 7D (sets multipurpose bit 17D)
(rock-paper-scissors logic bit check for correct outcomes)
C9 79 81 7D 81 E0 D9 29 (if multipurpose bit 179 and 17D are set goto 33D9E0)
C9 79 81 7E 81 60 D7 29 (if multipurpose bit 179 and 17E are set goto 33D760)
C9 79 81 80 81 10 DA 29 (if multipurpose bit 179 and 180 are set goto 33DA10)
C9 7B 81 7D 81 40 DA 29 (if multipurpose bit 17B and 17D are set goto 33DA40)
C9 7B 81 7E 81 C0 D8 29 (if multipurpose bit 17B and 17E are set goto 33D8C0)
C9 7B 81 80 81 10 D8 29 (if multipurpose bit 17B and 180 are set goto 33D810)
C9 7C 81 7D 81 F0 D8 29 (if multipurpose bit 17C and 17D are set goto 33D8F0)
C9 7C 81 7E 81 70 DA 29 (if multipurpose bit 17C and 17E are set goto 33DA70)
C9 7C 81 80 81 40 D8 29 (if multipurpose bit 17C and 180 are set goto 33D840)
FE (end)

33EDB0-33EDFA (2nd Pseudo-random jump path)
D2 7E (sets multipurpose bit 17E)
(rock-paper-scissors logic bit check for correct outcomes)
C9 79 81 7D 81 E0 D9 29 (if multipurpose bit 179 and 17D are set goto 33D9E0)
C9 79 81 7E 81 60 D7 29 (if multipurpose bit 179 and 17E are set goto 33D760)
C9 79 81 80 81 10 DA 29 (if multipurpose bit 179 and 180 are set goto 33DA10)
C9 7B 81 7D 81 40 DA 29 (if multipurpose bit 17B and 17D are set goto 33DA40)
C9 7B 81 7E 81 C0 D8 29 (if multipurpose bit 17B and 17E are set goto 33D8C0)
C9 7B 81 80 81 10 D8 29 (if multipurpose bit 17B and 180 are set goto 33D810)
C9 7C 81 7D 81 F0 D8 29 (if multipurpose bit 17C and 17D are set goto 33D8F0)
C9 7C 81 7E 81 70 DA 29 (if multipurpose bit 17C and 17E are set goto 33DA70)
C9 7C 81 80 81 40 D8 29 (if multipurpose bit 17C and 180 are set goto 33D840)
FE (end)

33EE00-33EE4a (3rd Pseudo-random jump path)
D2 80 (sets multipurpose bit 180)
(rock-paper-scissors logic bit check for correct outcomes)
C9 79 81 7D 81 E0 D9 29 (if multipurpose bit 179 and 17D are set goto 33D9E0)
C9 79 81 7E 81 60 D7 29 (if multipurpose bit 179 and 17E are set goto 33D760)
C9 79 81 80 81 10 DA 29 (if multipurpose bit 179 and 180 are set goto 33DA10)
C9 7B 81 7D 81 40 DA 29 (if multipurpose bit 17B and 17D are set goto 33DA40)
C9 7B 81 7E 81 C0 D8 29 (if multipurpose bit 17B and 17E are set goto 33D8C0)
C9 7B 81 80 81 10 D8 29 (if multipurpose bit 17B and 180 are set goto 33D810)
C9 7C 81 7D 81 F0 D8 29 (if multipurpose bit 17C and 17D are set goto 33D8F0)
C9 7C 81 7E 81 70 DA 29 (if multipurpose bit 17C and 17E are set goto 33DA70)
C9 7C 81 80 81 40 D8 29 (if multipurpose bit 17C and 180 are set goto 33D840)
FE (end)

33D9E0-33DA0C
4B 08 0D ("I chose... rock!")
92 (pause)
4B 05 0D ("It's a draw.")
84 64 00 (give party 100 gp back)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D760-33D78B
4B 09 0D ("I chose... paper!")
92 (pause)
4B 06 0D ("You lose.")
F4 DD (loosing sfx)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33DA10-33DA3E
4B 0A 0D ("I chose... scissors!")
92 (pause)
4B 07 0D ("You win.")
F4 BF (winning sfx)
84 C8 00 (give party 200 gp, 200 because 100 gp was deducted from the party at the start in order to play)
E9 07 01 00 (Increment word $1FC2($07) [$1FD0] by $0001)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33DA40-33DA6B
4B 0A 0D ("I chose... scissors!")
92 (pause)
4B 06 0D ("You lose.")
F4 DD (loosing sfx)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D8C0-33D8EE
4B 08 0D ("I chose... rock!")
92 (pause)
4B 07 0D ("You win.")
F4 BF (winning sfx)
84 C8 00 (give party 200 gp, 200 because 100 gp was deducted from the party at the start in order to play)
E9 07 01 00 (Increment word $1FC2($07) [$1FD0] by $0001)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D810-33D83C
4B 09 0D ("I chose... paper!")
92 (pause)
4B 05 0D ("It's a draw.")
84 64 00 (give party back 100 gp)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D8F0-33D91E
4B 09 0D ("I chose... paper!")
92 (pause)
4B 07 0D ("You win.")
F4 BF (winning sfx)
84 C8 00 (give party 200 gp, 200 because 100 gp was deducted from the party at the start in order to play)
E9 07 01 00 (Increment word $1FC2($07) [$1FD0] by $0001)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33DA70
4B 0A 0D ("I chose... scissors!")
92 (pause)
4B 05 0D ("It's a draw.")
84 64 00 (give party back 100 gp)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D840-33DA9C
4B 08 0D ("I chose... rock!")
92 (pause)
4B 06 0D ("You lose.")
F4 DD (loosing sfx)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D960
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than)
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 80 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D980-33D9D1
C0 E6 81 60 D9 29 (if bit 1E6 is set (received RPS Badge) goto 33D870)
EB 07 05 00 (Compare word $1FC2($07) [$1FD0] to $0005, set $1A0 for equal to, $1A1 for greater than, $1A2 for less than
C0 A0 81 F0 D6 29 (if bit 1A0 is set goto 33D6F0)
85 64 00 (take 100 gp from party, is given back later if draw or x2 if win)
C0 BE 81 FF 69 01 (check if have enough gp, if not say "not enough gp" and exit)
B2 90 D7 29 (clears multipurpose bits)
4B 04 0D ("Choose one...")
93 (pause)
22 11 48 E0 02 CD E0 01 48 E0 02 CD E0 01 48 E0 08 CD FF (npc doing rps actions)
31 91 08 E0 02 CD E0 01 08 E0 02 CD E0 01 08 E0 08 CD FF (player doing rps actions)
B6 (branch for player choosing rock, paper, or scissors.)
D0 D6 29 (rock goto 33D6D0)
D0 D7 29 (paper goto 33D7D0)
F0 D7 29 (scissors goto 33D7F0)
FE (end)

33D930-33D934 (clears the word)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
FE (end)

33D6F0-33D705 (5 wins in a row routine)
F4 BF (winning sfx)
93 (pause)
F4 D0 (cheering sfx)
4B 0C 0D ("Wow, that's five wins in a row!")
92 (pause)
F4 8D (received item sfx)
4B 0D 0D (Received [RPS Badge]!)
E8 07 00 00 (Set word $1FC2($07) [$1FD0] to $0000)
D2 E6 (set bit 1E6, RPG Badge Rare Item)
B2 90 D7 29 (clears multipurpose bits)
FE (end)

33D960-33D96E
B2 90 D7 29 (clears multipurpose bits)
4B 0B 0D ("Wanna go again?")
B6 50 D6 29 30 D9 29 (branch dialog, if yes goto 33D980, if no goto 33D930)
FE (end)

33D790-33D79C
D3 79 D3 7B D3 7C D3 7D D3 7E D3 80 (clears multipurpose bits)
FE (end)

The reason I duplicated the RPS logic bit check code three times, is because when I called it with a subroutine it would eventually push the stack over the limit and crash the game due to how the event is constructed as a whole. It took me three reconstructions of the code to get it working 100%, eventually opting to have as little subroutines as possible, which meant I had to duplicate some code for each outcome.


We are born, live, die and then do the same thing over again.
Quote  
[-] The following 2 users say Thank You to Gi Nattak for this post:
  • madsiur (05-26-2019), Robo Jesus (05-27-2019)

#2
Posts: 3,974
Threads: 279
Thanks Received: 240
Thanks Given: 62
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Will the RPS Badge have any use?
  Find
Quote  

#3
Posts: 133
Threads: 17
Thanks Received: 1
Thanks Given: 0
Joined: Sep 2014
Reputation: 14
Status
Sadness
hey fred

is this mini game gonna be in the new ROTDS 2.0 mod at all?
  Find
Quote  

#4
Posts: 2,569
Threads: 99
Thanks Received: 160
Thanks Given: 169
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
(05-26-2019, 06:01 PM)madsiur Wrote: Will the RPS Badge have any use?

I'll probably have some NPC(s) notice if you have it, and then maybe they'll challenge you in RPS for it and get some item or something if you win.

@Mac Yes, yes it is.


We are born, live, die and then do the same thing over again.
Quote  

#5
Posts: 3,974
Threads: 279
Thanks Received: 240
Thanks Given: 62
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(05-26-2019, 07:08 PM)Gi Nattak Wrote: I'll probably have some NPC(s) notice if you have it, and then maybe they'll challenge you in RPS for it and get some item or something if you win.

RotDS RPS mini-game > FF8 Triple Triad
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite