Post Reply 
Thread for 67FUN2 game rom program development
11-23-2016, 01:58 PM (This post was last modified: 11-23-2016 02:07 PM by Dieter.)
Post: #4
RE: Thread for 67FUN2 game rom program development
(11-22-2016 10:37 PM)I Wrote:  The program uses a very compact evaluation routine – no flags, no elaborate tests

Maybe I should explain how this works.

Let Paper=3, Rock=2 and Scissors=1. If a and b are the moves of the two players, then (a–b) mod 3 returns 1 or 2 if the first resp. second player wins. Zero represents a tie. This works if –2 mod 3 is evaluated as 1, like the 41 does it (on the 34s use MOD, not RMDR). On calculators without mod function you simply add 3 if a–b is negative. You can even go one step further and calculate 2x this minus 3 to get –1 or +1 for the score counter (a tie has to be handled separately).

If you prefer Paper=1, Rock=2 and Scissors=3, as in the original program, simply replace a–b with b–a. Or change the logic (1 = player 1 loses, 2 = player 2 loses).

So the score evaluation in PRS2a can be done in just three steps (51...53): Y and X hold the player's and HP's move, and "– 3 MOD" yields 1 (player wins) or 2 (HP wins) or 0 (a tie). In the latter case the program jumps to LBL 04, else the test whether X is 1 or 2 is done with a DSE X. This yields 0 or 1, and if it's 1, DSE tests true and jumps to LBL 05 (HP wins), else the player wins.

Another elegant option could be a simple indirect jump. This method is used in the following variation of the game. Here also the original definition Paper=1, Rock=2 and Scissors=3 was used and the both players' moves are displayed in one line. Here is the listing:

Code:
 01 LBL "PRS"
 02 RCL 00
 03 "SEED?"
 04 PROMPT
 05 ABS
 06 FRC
 07 STO 00
 08 SF 27
 09 LBL E
 10 CLX
 11 STO 01
 12 LBL 10
 13 RCL d
 14 FIX 0
 15 CF 29
 16 "SCORE: "
 17 ARCL 01
 18 STO d
 19 RDN
 20 RCL 01
 21 AVIEW
 22 RTN
 23 LBL A
 24 1
 25 GTO 00
 26 LBL B
 27 2
 28 GTO 00
 29 LBL C
 30 3
 31 LBL 00
 32 CLA
 33 XEQ IND X
 34 AVIEW
 35 PSE
 36 RCL 00
 37 PI
 38 +
 39 X^2
 40 FRC
 41 STO 00
 42 3
 43 *
 44 1
 45 +
 46 INT
 47 >" : "
 48 XEQ IND X
 49 AVIEW
 50 PSE
 51 -
 52 3
 53 MOD
 54 4
 55 +
 56 XEQ IND X
 57 ST+ 01
 58 AVIEW
 59 PSE
 60 PSE
 61 GTO 10
 62 LBL 04
 63 "A TIE"
 64 CLX
 65 RTN
 66 LBL 05
 67 "YOU LOSE"
 68 -1
 69 RTN
 70 LBL 06
 71 "YOU WIN"
 72 1
 73 RTN
 74 LBL 01
 75 >"PAPER"
 76 RTN
 77 LBL 02
 78 >"ROCK"
 79 RTN
 80 LBL 03
 81 >"SCISS"
 82 END

That's 161 Bytes including seed prompt, RNG and an additional restart label E.

If you don't know how to enter the synthetic RCL d and STO d commands, simply replace line 18/19 with FIX 4  SF 29 and omit the RCL d in line 13.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Thread for 67FUN2 game rom program development - Dieter - 11-23-2016 01:58 PM



User(s) browsing this thread: 1 Guest(s)