The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

wp34s Version 1.18 Rev 875 Backup and Restore
Message #1 Posted by Jeff O. on 11 May 2011, 9:38 a.m.

Marcus,
I see that you have added confirmation to the ON+ key commands. That's a good thing, as I worried that at some point I would hit ON+S instead of ON+R as they are right next to each other. Not a disaster, but would require firing up SAM-BA to get things running again. In any case, I assume that the confirmation is to press the key again while holding ON down, i.e. Restore would be ON+5, hold ON, release 5, keep holding ON, press 5, correct? If so, then there may be a problem as I now get "Invalid" when I attempt to restore from a state file that worked with previous versions.

      
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #2 Posted by Marcus von Cube, Germany on 11 May 2011, 3:30 p.m.,
in response to message #1 by Jeff O.

Quote:
If so, then there may be a problem as I now get "Invalid" when I attempt to restore from a state file that worked with previous versions.

1.17 is not compatible with 1.18. We changed the number of program steps and therefore the checksum is no longer valid. The keyboard sequence is exactly as you describe.

            
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #3 Posted by Jeff O. on 11 May 2011, 4:01 p.m.,
in response to message #2 by Marcus von Cube, Germany

Any way to get around this? When you provided back-up and restore capability, I finally decided to try entering a longer program since I would not lose it with the next revision. Not a big deal if not, I'll just re-enter it.

                  
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #4 Posted by Marcus von Cube, Germany on 11 May 2011, 4:10 p.m.,
in response to message #3 by Jeff O.

Send me your state file, I may create an upgrade path. You find me under marcus at mvcsys dot de.

                        
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #5 Posted by Jeff O. on 11 May 2011, 10:14 p.m.,
in response to message #4 by Marcus von Cube, Germany

State file sent, fixed, and returned. Thanks Marcus!

Edited: 13 May 2011, 12:17 p.m.

                  
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #6 Posted by Paul Dale on 11 May 2011, 9:42 p.m.,
in response to message #3 by Jeff O.

Out of interest, what program?

- Pauli

                        
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #7 Posted by Jeff O. on 11 May 2011, 10:13 p.m.,
in response to message #6 by Paul Dale

Nothing special, just my old four-digit number guessing game that I have ported to various machines over the years.

                              
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #8 Posted by Jeff O. on 13 May 2011, 12:47 p.m.,
in response to message #7 by Jeff O.

Here is the wp34s state file with the program in case anyone is interested:

wp34s state file with number guessing game

Once you get the state file into your calculator and restore it to main memory, game play is as follows:

To play: Press C to execute program label C. The calculator will generate a random four digit number with no repeated digits, zero not allowed, then stop and display 0.0. Key in a four digit guess, (e.g. 1234, 9753, etc.) and press R/S. The calculator will compare your guess to the secret number it generated and return a score in the following format:

x.y

where x is the number of digits in your guess that are both in the secret number and in the correct position, and y is the number of digits which are in the secret number but not in the correct position. So, for example, if the secret number is 3214 and you guess 1234, the score will be 2.2, as the 2 and 4 are in the correct positions and the 1 and 3 are in the number but in the incorrect position in your guess. After each guess, pressing x<>y will show the number of guesses so far. Keep entering guesses until 4.0 is displayed, indicating you have solved the puzzle.

Wp34s program listing:
Step # Command	       Comment				
001	LBL C	 Label C for "Code Breaker"			
002	Cl x	 clear x to get zero to store in 1 - 5, 10	
003	STO 01							
004	STO 02							
005	STO 03							
006	STO 04							
007	STO 05							
008	STO 10					
009	FIX 01	 set display mode Fix 1 so scores are presented as x.x			
010	1	 enter 1 for first digit of 10			
011	0	 enter 0 for second digit of 10			
012	STO 06	 Store constant 10 in register 6		
013	4	 enter 4					
014	STO I	 Store 4 in I for loop index and indirect storage.
015	LBL 02	 Label 2					
016	RAN#	 generate random number				
017	RCL x 06 Multiply times 10 to get a digit left of decimal point					
018	INT	 drop fractional portion			
019	RCL 01	 Recall register 1				
020	XEQ 10	 execute subroutine that checks against random number
021	RCL 02	 Recall register 2				
022	XEQ 10	 execute subroutine that checks against random number
023	RCL 03	 Recall register 3				
024	XEQ 10	 execute subroutine that checks against random number
025	RCL 04	 Recall register 4				
026	XEQ 10	 execute subroutine that checks against random number
027	STO->I	 If random number is not equal to any existing digit, 
                 store in register pointed to by I		
028	DSE I	 Decrement index				
029	GTO 02	 Go back to random number generator to store next digit				
030	LBL 03	 Label 3					
031	RCL 10	 Recall 10, count of guesses for guessing portion
032	RCL 05	 Recall 5, score of guess for guessing portion	
033	STOP	 Stop						
034	STO 09	 Store 4 digit guess in register 9		
035	CL x	 Clear x for 0 in x				
036	STO 05	 Store in register 5, which will hold score for the current guess				
037	4	 Enter 4 					
038	STO I	 Store 4 in I for loop index and indirect recalling.
039	LBL 08	 Label 8					
040	RCL 09	 Recall guess					
041	RCL / 06 Divide guess by 10			
042	STO 09	 Store back in register 9			
043	FRAC	 Take fractional part				
044	RCL x 06 Multiply times 10 to get a digit left of decimal point					
045	INT	 drop fractional portion			
046	RCL->I	 Recall register pointed to by I		
047	x=y?	 Compare to digit extracted from guess for the I position				
048	GTO 04	 If equal, go to scoring for correct digit in correct location				
049	Rv	 Roll down to get extracted digit back		
050	RCL 04	 Recall digit 4					
051	x=y?	 Compare to extracted digit from guess		
052	GTO 05	 if equal, go to scoring for correct digit in incorrect location				
053	Rv	 Roll down to get extracted digit back		
054	RCL 03	 Recall digit 3					
055	x=y?	 Compare to extracted digit from guess		
056	GTO 05	 if equal, go to scoring for correct digit in incorrect location				
057	Rv	 Roll down to get extracted digit back		
058	RCL 02	 Recall digit 2					
059	x=y?	 Compare to extracted digit from guess		
060	GTO 05	 if equal, go to scoring for correct digit in incorrect location				
061	Rv	 Roll down to get extracted digit back		
062	RCL 01	 Recall digit 1					
063	x=y?	 Compare to extracted digit from guess		
064	GTO 05	 if equal, go to scoring for correct digit in incorrect location				
065	0	 enter 0 to indicate digit not in number	
066	GTO 06	 Go to scoring					
067	LBL 04	 Label 4					
068	1	 Enter 1 for correct digit in correct location	
069	GTO 06	 Go to scoring					
070	LBL 05	 Label 5					
071	.	 enter decimal point				
072	1	 enter 1 (for .1) for guess digit in number in incorrect location				
073	LBL 06	 Label 6						
074	STO + 05 Add 1, .1 or 0 to score			
075	DSE I	 Decrement index				
076	GTO 08	 Go to Label 8 to extract next guess digit	
077	1	 Enter 1					
078	STO + 10 Add to register .0, count of guesses	
079	EEX	 Enter power of 10 exponent			
080	4	 Enter 4 for 1E4				
081	RCL x 09 Multiply register 9 by 10,000 to get guess back
082	GTO 03	 Go to 3					
083	LBL 10	 Label 3, test routine to generate non-repeating, non-zero 
                 digits in secret number		
084	x=y?	 compare randomly generated digit to existing secret
                 number digit			
085	GTO 02	 go to random number generator if random number is equal to 
                 any existing digit of secret number
086	x<>y	 swap if not equal to get randomly generated digit back for 
                 next test			
087	RTN	 subroutine return				

...

                                    
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #9 Posted by Gerson W. Barbosa on 15 May 2011, 8:25 p.m.,
in response to message #8 by Jeff O.

Thanks for posting it!

I liked to play this game on my TI-59, in '82 (there was a listing in the manual). Unfortunately it was stolen two months after I had purchased it. The first thing I did when I replaced it with an HP-15C was writing an RPN version, or to what I thought an RPN version was:

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv014.cgi?read=68346

As I was not acquainted to the HP-15C, it was a slow and long program but it ran fast on the HP-32SII. Even faster on the PC :-)


---------------------------------------------- 

Program Guessing_Game; var c,e,i,j,nt,tmp: byte; ad,adv: integer; op: char; a,n: array [1..4] of byte; begin repeat nt:=0; ClrScr; Write(' ':9,'G U E S S I N G G A M E'); GoToXY(14,5); Write('Guess C I'); repeat for i:=1 to 4 do n[i]:=Random(9)+1 until (n[1]<>n[2]) and (n[1]<>n[3]) and (n[1]<>n[4]) and (n[2]<>n[3]) and (n[2]<>n[4]) and (n[3]<>n[4]); repeat c:=0; e:=0; nt:=nt+1; GoToXY(10,3); Write('Enter your guess: '); repeat repeat GoToXY(30,3); Read (adv); GoToXY(30,3); ClrEol until (adv>1233) and (adv<9877) and (IOresult=0); ad:=adv; for i:=4 downto 1 do begin a[i]:=adv mod 10; adv:=adv div 10 end until (a[1]<>a[2]) and (a[1]<>a[3]) and (a[1]<>a[4]) and (a[2]<>a[3]) and (a[2]<>a[4]) and (a[3]<>a[4]) and (a[1]*a[2]*a[3]*a[4]<>0); for i:=1 to 4 do if a[i]=n[i] then c:=c+1; for i:=1 to 3 do begin tmp:=a[1]; for j:=1 to 3 do a[j]:=a[j+1]; a[4]:=tmp; for j:=1 to 4 do if a[j]=n[j] then e:=e+1 end; GoToXY(10,nt+6); WriteLn(nt:2,': ',ad:4,' ',c:1,' ',e:1) until (c=4) or (nt=10); GoToXY(15,20); if c=4 then case nt of 1: Write('That',#39,'s witchcraft!'); 2,3: Write('Excellent!'); 4: Write('Good!'); 5,6: Write('Fair.'); 7,8: Write('Poor.'); 9: Write('Bad.'); 10: Write('Better luck next time!') end else Write('Secret number: ',n[1]:1,n[2]:1,n[3]:1,n[4]:1); GoToXY(10,3); ClrEol; GoToXY(15,22); Write('New game? <Y,N> '); repeat Read(kbd,op); op:=UpCase(op) until (op='Y') or (op='N') until op='N' end.

----------------------------------------------

G U E S S I N G G A M E

Guess C I

1: 1234 1 0 2: 5678 0 2 3: 9287 0 3 4: 2986 0 2 5: 7893 3 0 6: 7894 4 0

Fair.

New game? <Y,N>

----------------------------------------------

                                          
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #10 Posted by Jeff O. on 16 May 2011, 7:49 a.m.,
in response to message #9 by Gerson W. Barbosa

Quote:
Thanks for posting it!

You are welcome!

Quote:
I liked to play this game on my TI-59, in '82 (there was a listing in the manual).

I also first encountered TI-59 version of the program. I had a 29C at the time and was able to create playable version for it.

Quote:
The first thing I did when I replaced it with an HP-15C was writing an RPN version, or to what I thought an RPN version...As I was not acquainted to the HP-15C, it was a slow and long program but it ran fast on the HP-32SII.

I can't believe I missed your post from 2005. My 15C version is also very slow. The wp34s version is lightning fast.

                                    
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #11 Posted by Paul Dale on 15 May 2011, 8:46 p.m.,
in response to message #8 by Jeff O.

Nice program. If you're agreeable, I'll add it to the library of programs.

A couple of minor comments (well more taking advantage of features of the 34s).

Lines 77/78 can be replaced by "INC 10".

The checking for duplicate digits code can be simplified. Lines 19-26 can be changed to

019: x=? 01
020: GTO 02
021: x=? 02
022: GTO 02
023: x=? 03
024: GTO 02
025: x=? 04
026: GTO 02

and lines 83 - 87 removed. This will be shorter, faster and not abuse the return stack so badly :-)

This section of code can be streamlined further by making it a loop:

015: 4
016: RAN#
017: RCL* 06
018: INT
019: LBL 99
020: x=?->Y
021: GTO 02
022: DSZ Y
023: GTO 99

and an extra step saved by deleting the label and using BACK instead.

The 34s really is a programmers' machine :-)

- Pauli

                                          
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #12 Posted by Jeff O. on 16 May 2011, 8:04 a.m.,
in response to message #11 by Paul Dale

Thanks Pauli. You may certainly add it (or preferably an improved version) to the library of programs.

I am not surprised that it can be improved, thanks for your suggestions, I'll check them out. I'd also like to take advantage of the alpha capabilities of wp34s by adding some prompts or messages.

...

                                          
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #13 Posted by Jeff O. on 16 May 2011, 1:13 p.m.,
in response to message #11 by Paul Dale

Quote:
A couple of minor comments (well more taking advantage of features of the 34s).

Lines 77/78 can be replaced by "INC 10".

The checking for duplicate digits code can be simplified...This section of code can be streamlined further by making it a loop...and an extra step saved by deleting the label and using BACK instead.


Which would look like this, I presume:

015: 4
016: RAN#
017: RCL* 06
018: INT
019: x=?->Y
020: GTO 02
021: DSZ Y
023: BACK 03

A similar improvement can be made to the digit checking routine, replacing steps 46 to 64 of the original program with:

x=?->I
GTO 04
4
x<>y
x=?->Y
GTO 05
DSZ Y
BACK 03

I'm sure there are other improvements that could be made, but the above changes plus a couple of skips get the program down to 64 steps, listed below. Oh yes, I forgot to say that after each guess is scored, the guess will be in register Z in case you forget what you just guessed.

Quote:
The 34s really is a programmers' machine :-)

Yes, it certainly is!

Improved wp34s version	

State file

Program Listing Step # Command Comment 001 LBL C Label C for "Code Breaker" 002 CLx clear x to get zero to store in 1 - 5, 10 003 STO 01 004 STO 02 005 STO 03 006 STO 04 007 STO 05 008 STO 10 009 FIX 01 set display mode Fix 1 so scores are presented as x.x 010 1 enter 1 for first digit of 10 011 0 enter 0 for second digit of 10 012 STO 06 Store constant 10 in register 6 013 4 enter 4 014 STO I Store 4 in I for loop index and indirect storage. 015 LBL 02 Label 02 016 4 enter 4 017 RAN# generate random number, 4 pushed to Y 018 RCLx 06 Multiply times 10 to get a digit left of decimal point 019 IP drop fractional portion 020 x=?->Y check random number against register pointed to ny Y 021 GTO 02 if equal, go back and generate new number 022 DSZ Y decrement Y register, skip when zero 023 BACK 03 jump back three steps to compare digit to next register pointed to by Y 024 STO->I If random number is not equal to any existing digit, store in register pointed to by I 025 DSE I Decrement index 026 GTO 02 Go back to random number generator to store next digit 027 LBL 03 Label 03 028 RCL 10 Recall 10, count of guesses for guessing portion 029 RCL 05 Recall 5, score of guess for guessing portion 030 STOP Stop, display 0.0 after start or score after guess 031 STO 09 Store 4 digit guess in register 9 032 STO 08 Store second copy of guess 033 CLx Clear x for 0 in x 034 STO 05 Store in register 5, which will hold score for the current guess 035 4 Enter 4 036 STO I Store 4 in I for loop index and indirect recalling 037 LBL 08 Label 08 038 RCL 09 Recall guess 039 RCL/ 06 Divide guess by 10 040 STO 09 Store back in register 9 041 FP Take fractional part 042 RCLx 06 Multiply times 10 to get a digit left of decimal point 043 IP drop fractional portion 044 x=?->I Compare to digit pointed to by I 045 GTO 04 If equal, go to scoring for correct digit in correct location 046 4 enter 4 047 x<>y 048 x=?->Y Compare to digit pointed to by Y 049 GTO 05 if equal, go to scoring for correct digit in incorrect location 050 DSZ Y decrement Y register, skip when zero 051 BACK 03 jump back three steps to compare digit to next register pointed to by Y 052 0 enter 0 to indicate digit not in number 053 SKIP 05 Go to scoring 054 LBL 04 Label 04 055 SKIP 02 skip two steps to enter 1 for correct digit in correct location 056 LBL 05 Label 05 057 . enter decimal point 058 1 enter 1 (for .1 for guess digit in number in incorrect location, 1 for correct digit in correct location.) 059 STO+ 05 Add 1, .1 or 0 to score 060 DSE I Decrement index 061 GTO 08 Go to Label 08 to extract next guess digit 062 INC 10 Increment register 10, count of guesses 063 RCL 08 Recall original guess 064 GTO 03 Go to label 03 to display score and count of guesses

edited to add state file and listing of further improved version of program

Edited: 16 May 2011, 8:50 p.m.

      
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #14 Posted by Paul Dale on 11 May 2011, 5:33 p.m.,
in response to message #1 by Jeff O.

Quote:
That's a good thing, as I worried that at some point I would hit ON+S instead of ON+R as they are right next to each other.

I've done exactly this :-( Caused a little confusion.

- Pauli

      
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #15 Posted by Paul Dale on 11 May 2011, 5:41 p.m.,
in response to message #1 by Jeff O.

Please bear in mind that the internal op-codes for commands are not yet set in stone. Of course, we're not going to make changes for the sake of it and we'll try to stay backwards compatible but there is no absolute guarantee of this.

One future we're discussing is user program libraries in flash. Before this can be done we must fix the existing op-codes. Retyping the limited RAM program memory is painful and a bit annoying but not really that much of chore. Retyping multiple kb's of libraries would be.

- Pauli

            
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #16 Posted by Marcus von Cube, Germany on 12 May 2011, 1:55 a.m.,
in response to message #15 by Paul Dale

We should add a disassembler and an assembler to the emulator. This would make programming much easier. The state file or its program part can then be easily transfered to the real machine.

                  
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #17 Posted by Paul Dale on 12 May 2011, 2:30 a.m.,
in response to message #16 by Marcus von Cube, Germany

This would be great. I'd use an assembler to compile the internal key stroke programs e.g. :-)

There is a kind of disassembler for the internals. Build the console version and run "calc xrom"

- Pauli

Edited: 12 May 2011, 2:31 a.m.

                        
Re: wp34s Version 1.18 Rev 875 Backup and Restore
Message #18 Posted by Walter B on 12 May 2011, 5:39 a.m.,
in response to message #17 by Paul Dale

Our baby's going to get wings :-) IMHO, however, it should learn walking and safely riding a bike first ;-)

Walter


[ Return to Index | Top of Index ]

Go back to the main exhibit hall