Post Reply 
4K HP 67 Games rom attached for testing
11-11-2016, 09:10 PM
Post: #121
RE: 4K HP 67 Games rom attached for testing
Great. Here is a link to a .zip file containing all 15 programs and a LBL R and S file for the random number and seed program.

raw files

Here is what I put in for the R and S routine:

01 LBL "R"
02 PI
03 ST+ 00
04 X<> 00
05 X^2
06 ST* L
07 X<> L
08 FRC
09 STO 00
10 RTN
11 LBL "S"
12 RCL 00
13 "SEED?"
14 PROMPT
15 ABS
16 FRC
17 STO 00
18 END




If we have room (and we might), then the next one to go in is Sum of the Digits (SD).

.raw file that runs on emulators includes seed prompt and RN generator internal to program: SD.raw


.raw file with proper xroms: SD with xrom

The program with xroms is 92 bytes. It may just make it. If there is room, it goes in. Not enough room, it stays out.
Find all posts by this user
Quote this message in a reply
11-11-2016, 09:21 PM (This post was last modified: 11-11-2016 09:22 PM by Dieter.)
Post: #122
RE: 4K HP 67 Games rom attached for testing
(11-11-2016 09:10 PM)Gene Wrote:  Here is what I put in for the R and S routine:

Gene, please put an ABS in the R routine before STO 00. It is always possible that somehow R00 holds a negative value, maybe inadvertently stored by the user or another program. OTOH the ABS and FRC in the seed routine is not essential for this RNG, it can be omitted. But it does not have to. ;-)

If you prefer the single-stack-level version please double-check if this causes andy stack problems. I don't think so, but just in case...

Dieter
Find all posts by this user
Quote this message in a reply
11-11-2016, 09:33 PM
Post: #123
RE: 4K HP 67 Games rom attached for testing
I'll drop in the ABS, no problem.
Find all posts by this user
Quote this message in a reply
11-12-2016, 02:27 AM
Post: #124
RE: 4K HP 67 Games rom attached for testing
(11-11-2016 07:12 PM)Dieter Wrote:  That's what I also suggested earlier.

Ángel: if implementing a buffer that holds the seed is too complicated, would you say that using R00 with an MCode RNG that does the 9821x+0,211327 thing is a possible option?

Sorry, I must have missed your earlier suggestion. Writing a buffer based solution would be a lot more work, but a version that uses R00 is pretty simple:
Code:
;**********************************************************
; RRAN function
; Takes a seed from R00 and generates the next random number,
; placing the new seed back in R00 and returning it in X.
; Adapted from MCode for Beginners, Ken Emery.
;**********************************************************
.NAME "RRAN"
[RRAN]          C=REG   13/c            ; Get status reg c (contains address of R00)
                RCR     3               ; move into C:X
                RAMSLCT                 ; Select the RAM register of the pointer in C:X
                RDATA                   ; Read the data
                NCXQ    14D8            ; [CHK#S] Checks C for alpha, SETDEC. So C contains seed
                A=0     ALL             ; 
                A<>C    ALL             ; Save seed into A for multiply later
                PT=     12              ; Set the pointer to the first digit of the mantissa
                LC      9               ; Load in bcd rep of 9821
                LC      8
                LC      2
                LC      1
                LDI     003             ; C now contains 9.821E3
                NCXQ    [MP2_10]        ; Multiplies C=C*A
                A=C     ALL             ; Save into A 
                C=0     ALL             
                PT=     12              ; Load C with .211321
                LC      2
                LC      1
                LC      1
                LC      3
                LC      2
                LC      7
                C=C-1   X               ; Load the exponent
                CXQ     [AD2_10]        ; C=C+A (carry is set by the previous line)
                CF      5               ; Use the OS routine as FRC (not INT)
                NCXQ    [INTFRC]        ; C=FRC(C)
                WDATA                   ; Write back the new seed
                A=0     ALL
                A<>C    ALL
                RAMSLCT                 ; select chip 0
                A<>C    ALL
                REG=C   3/X             ; Write it (the random number) to X
                RTN

Might want to add stack lift handling instead of just overwriting X, but that wouldn't take much either. This does take a few more words of ROM (maybe 40 instead of maybe 25, but executes much faster.
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2016, 06:52 AM (This post was last modified: 11-12-2016 07:24 AM by Dieter.)
Post: #125
RE: 4K HP 67 Games rom attached for testing
(11-12-2016 02:27 AM)RobertM Wrote:  Writing a buffer based solution would be a lot more work, but a version that uses R00 is pretty simple:

Fine. So let's do it this way.

(11-12-2016 02:27 AM)RobertM Wrote:  Might want to add stack lift handling instead of just overwriting X, but that wouldn't take much either.

Yes, stack lift should be implemented. Not only because it is required by some of the programs.
And do not forget the final ABS. ;-)

BTW, what happens if R00 contains alpha data? Could this be converted to some kind of numeric value?

I wonder if we could squeeze out some more digits if the multiplication is done with 13-digit precision. This does not mean the RNG gets a longer period, it still is 10^6. But I think we should get three more digits if we change the increment to 0,211327003 or 0,211327157 (10^9 times this prime). As far as I understand the theory of linear congruential RNGs (cf. Knuth) this should yield the maximum period, i.e. 10^9.

Dieter
Find all posts by this user
Quote this message in a reply
11-17-2016, 10:15 PM (This post was last modified: 11-17-2016 10:17 PM by Dieter.)
Post: #126
RE: 4K HP 67 Games rom attached for testing
(11-11-2016 09:10 PM)Gene Wrote:  Great. Here is a link to a .zip file containing all 15 programs and a LBL R and S file for the random number and seed program.

Raw files are hard ro read by humans... ;-)

Anyway, I just noticed that this thread has not seen a lot of traffic over the last days. So let me add that I have been working on the STW program, but it's a bit harder than I thought (not sure if the version we have now is working as it is supposed to). Changing the code so that R00 is free for the random seed is easy, and I think this part already works. But there are still some issues, e.g. the program may stop with pending subroutine calls, which is something that should be avoided.

BTW, the chess program can be shortened by a few bytes: there are several XEQ 16 calls that simply add 10 to X. Since the XEQ requires three bytes just as a simple "10 +", the former should be replaced by the latter. This saves the bytes for the subroutine itself – and the program will even run faster.

Over the last days I have been thinking about random number generators and related stuff, so there is a delay with the STW program. But maybe someone else may give it a try. Robert ?-)

Dieter
Find all posts by this user
Quote this message in a reply
11-17-2016, 10:27 PM
Post: #127
RE: 4K HP 67 Games rom attached for testing
Do you mean the SPW SpaceWar program? Robert indicated he thought it worked well.

The code for the games have been sent to Angel for 3 days or so now. He has not yet responded so there may be a chance to adjust some items, but the random number cycling issues are one reason I had originally wanted to go with the 9821 generator whether slow or not. It is much faster these days than it was in the past on emulators or 41CL units, so I don't see speed as an issue.

However, the PI + ^ 5 generator that was pushed in the thread here is the one that was sent off to Angel.

Saving a byte or five in the chess program won't add much space to the availability in the rom, but it is certainly faster to add 10 than XEQ XY to add 10. :-)
Find all posts by this user
Quote this message in a reply
11-17-2016, 10:43 PM
Post: #128
RE: 4K HP 67 Games rom attached for testing
(11-17-2016 10:27 PM)Gene Wrote:  Do you mean the SPW SpaceWar program? Robert indicated he thought it worked well.

Err... sorry, I obviously mixed up "SPW" and "ST". #-) Here the ST program was meant.
But good to hear that SPW seems to work.

(11-17-2016 10:27 PM)Gene Wrote:  The code for the games have been sent to Angel for 3 days or so now.

So you already have corrected / R00 adjusted versions of the remaining three programs, including ST? Or maybe two programs since a BSP version should already be available.

(11-17-2016 10:27 PM)Gene Wrote:  He has not yet responded so there may be a chance to adjust some items, but the random number cycling issues are one reason I had originally wanted to go with the 9821 generator whether slow or not. It is much faster these days than it was in the past on emulators or 41CL units, so I don't see speed as an issue.

I had the same thoughts lately. The 41C natively runs 3x as fast as the 67/97. The only problem may be 130-random-number "2636" game. But compared to the 67...

But then – I really like the idea of having the 9821 generator in MCode, using R00 for the seed.

(11-17-2016 10:27 PM)Gene Wrote:  However, the PI + ^ 5 generator that was pushed in the thread here is the one that was sent off to Angel.

There are also issues with the (x+pi)^5 generator. I posted an example in the RNG thread.

(11-17-2016 10:27 PM)Gene Wrote:  Saving a byte or five in the chess program won't add much space to the availability in the rom, but it is certainly faster to add 10 than XEQ XY to add 10. :-)

Hmmm... I remember some person suggesting to remove the final RTN in a program as this saves one (!) byte. ;-)))

Dieter
Find all posts by this user
Quote this message in a reply
11-18-2016, 05:52 AM
Post: #129
RE: 4K HP 67 Games rom attached for testing
(11-17-2016 10:43 PM)Dieter Wrote:  Err... sorry, I obviously mixed up "SPW" and "ST". #-) Here the ST program was meant.
But good to hear that SPW seems to work.
(11-17-2016 10:27 PM)Gene Wrote:  The code for the games have been sent to Angel for 3 days or so now.

busy week, will get it done this week-end....
Find all posts by this user
Quote this message in a reply
11-18-2016, 03:23 PM
Post: #130
RE: 4K HP 67 Games rom attached for testing
Dieter: So you already have corrected / R00 adjusted versions of the remaining three programs, including ST? Or maybe two programs since a BSP version should already be available.

Gene: Which are these? I will go through them shortly.


Diether: Hmmm... I remember some person suggesting to remove the final RTN in a program as this saves one (!) byte. ;-)))


Gene: :-) True, but that was back EARLY in the process when we were not sure how much room the programs would take. We will end up with perhaps 10-20 bytes free so 1 or 2 extra won't allow room to put in another program.

Although that Othello program posted yesterday for the HP 67 looks really cool... but no, behave Gene! That will have to be for 67FUN2 sometime.

More later.
Find all posts by this user
Quote this message in a reply
11-18-2016, 04:56 PM (This post was last modified: 11-18-2016 05:18 PM by Gene.)
Post: #131
RE: 4K HP 67 Games rom attached for testing
Ok, here we go. I want to get these to Angel tomorrow USA time and hopefully he will be able to convert these to a .rom and .mod over the weekend.

Link to .zip including PDF and text file of program listings: program listings

This .zip includes the .raw files below: .raw file zip file

RandomNumberSeed.RAW
BattleShip.RAW
StarTrek.RAW
CHESS.RAW
SpaceWar.raw
G1130.raw
G2636.raw
AOS.raw
Artillery.raw
Chuckaluck.raw
Golf.raw
JiveTurkey.raw
MoonLander.raw
TicTacToe.raw
OABandit.raw
FollowMe.RAW

and

SumDigits.RAW


Notes:

1) SumDigits.RAW is the filler material. It is a small program that will be inserted as XROM 23,27 if there is room. If there is not enough room, it does not make the cut.

2) All files use the random number and seed prompting routines R and S. The updated StarTrek program is included as is the updated BattleShip program. Dieter, I also got rid of XEQ 16 in the Chess program and replaced it throughout with 10 +. Thank you.

3) The LBL R routine in the RandomNumberSeed.RAW file does this. We won't be using an Mcode routine. Angel prefers keeping this all FOCAL.


01 LBL "S"
02 RCL 00
03 "SEED?"
04 PROMPT
05 ABS
06 FRC
07 STO 00
08 RTN
09 LBL "R"
10 RCL 00
11 9821
12 *
13 .211327
14 +
15 FRC
16 ABS
17 STO 00
18 END



Test and review one last time if you can. I want to put these in Angel's patient hands shortly. :-)
Find all posts by this user
Quote this message in a reply
11-18-2016, 07:28 PM (This post was last modified: 11-18-2016 07:49 PM by Dieter.)
Post: #132
RE: 4K HP 67 Games rom attached for testing
(11-18-2016 03:23 PM)Gene Wrote:  Dieter: So you already have corrected / R00 adjusted versions of the remaining three programs, including ST? Or maybe two programs since a BSP version should already be available.

Gene: Which are these? I will go through them shortly.

The three programs that were missing in my 12-progam-zip are F67, ST and BSP.

BSP: I think I recently posted an adjusted version of this. Here is a version with one or two small cleanups. An unnecessary label was removed, flag 27 set and after "game over" a simple R/S restarts the program. I also don't like the "KILLED" message since you can't kill ships, so I reverted this to *DESTROYED*. But I'm not a native speaker, so the decision is up to you. Anyway, here it is:

.zip  Battleship.zip (Size: 828 bytes / Downloads: 2)

BTW, I'd prefer LBL "BSP" instead of calling the program "BS". ;-)))

ST: I did the conversion to R00 but I'm not yet satisfied with the result, cf. my previous posts. I also would like to fix a problem that in the 67 version probably was not addressed due to memory restrictions: it is possible that two or even all three Klingon ships are located on the same position (R01/02/03 are not necessarily different). This can be easily fixed. More important, the version in your zip file has a serious bug: after calling the RNG in line 53 the following LastX will return the same RN again (positive or maybe negative) since LastX holds the last value before the final ABS in the RNG: The original RNG had an ATAN here so that LastX returns the original angle (0...45°). So this LastX has to be replaced with an ATAN. Or a "45 *" which will also generate a random damage value between 0 and 45. And be sure to also include a DEG command, else the max. damage will be 0,785. ;-)

If it goes into a ROM it should be perfect, or at least close to this. I'll see what I can do.

F67: Haven't touched this yet.

(11-18-2016 03:23 PM)Gene Wrote:  Although that Othello program posted yesterday for the HP 67 looks really cool... but no, behave Gene! That will have to be for 67FUN2 sometime.

In a way I like the "Master Scientist" program from the '25 PPC collection you posted. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
11-18-2016, 07:32 PM
Post: #133
RE: 4K HP 67 Games rom attached for testing
No problem and thank you. Your non-native English is wonderful.

The StarTrek program I posted has been adjusted to R00.

I will look through the BS program and include it unless something jumps out.

F67 (FollowMe) works and needs no R00 adjustment. It might be able to shrunk a few bytes, but it does work.

Again, I will send off what we have to Angel shortly. I think this is a great collection because of your and Robert's efforts!
Find all posts by this user
Quote this message in a reply
11-18-2016, 07:52 PM (This post was last modified: 11-18-2016 08:03 PM by Gene.)
Post: #134
RE: 4K HP 67 Games rom attached for testing
.zip file updated to include Dieter's BattleShip version with *DESTROYED* :-) and with the ATAN after RN bug fixed in StarTrek.


.zip of .raw files for 4K rom
Find all posts by this user
Quote this message in a reply
11-18-2016, 10:08 PM (This post was last modified: 11-18-2016 10:37 PM by Dieter.)
Post: #135
RE: 4K HP 67 Games rom attached for testing
Oops... this was a duplicate post, so I'll delete this ...except the following update:

I think I now have an ST version that runs correctly. However, the structure of the original program is a bit complex (and thus error prone) so that I have to do some more testing. At least some errors have been fixed, and the program now even correctly handles the damage update after a Klingon ship has been destroyed (cf. original documentation).

Dieter
Find all posts by this user
Quote this message in a reply
11-18-2016, 10:13 PM (This post was last modified: 11-18-2016 10:14 PM by Gene.)
Post: #136
RE: 4K HP 67 Games rom attached for testing
Good. Post it here when you are confident. :-)
Find all posts by this user
Quote this message in a reply
11-19-2016, 11:05 AM
Post: #137
RE: 4K HP 67 Games rom attached for testing
(11-18-2016 10:13 PM)Gene Wrote:  Good. Post it here when you are confident. :-)

On standby - just say when...
Find all posts by this user
Quote this message in a reply
11-19-2016, 07:14 PM (This post was last modified: 11-19-2016 10:36 PM by Dieter.)
Post: #138
RE: 4K HP 67 Games rom attached for testing
(11-18-2016 10:13 PM)Gene Wrote:  Good. Post it here when you are confident. :-)

I cannot say anything for sure, but the attached version (less than 30 minutes old) seems to run OK. It even does some things right that the original 67 program (and its documentation) did not. The four ships (Klingons and Enterprise) now are always on different positions and there is just one flag test left. With the RNG and seed of the 67 documentation the program returns the same results (except one error in the original document where a wrong value of the Enterprise's damage is given). To repair a damage there is no need to enter the ship number in I or R09 (I assume you do not want to repair Klingon ships ;-)) and the value also does not have to be negative – simply enter the repair units and press [shift][C]. If the Enterprise is destroyed the final display shows its last position with negative sign.

And now – Gene, Robert, Ángel and whoever wants to give it a try – do your own tests and see if there still are any bugs or glitches left. I fixed several problems, but we all know: errare humanum est.

Dieter


Attached File(s)
.zip  ST3.zip (Size: 1.86 KB / Downloads: 2)
Find all posts by this user
Quote this message in a reply
11-19-2016, 08:06 PM (This post was last modified: 11-19-2016 08:38 PM by Gene.)
Post: #139
RE: 4K HP 67 Games rom attached for testing
Testing

Something does not seem right with LBL E (attack). I try to attack ship 2 let's say and I get hit by ship 2 but with various levels of power in my attack at them (30 units, 50, 100), I get no status update of any hit / damage. The program simply runs and shows my coords again.
Find all posts by this user
Quote this message in a reply
11-19-2016, 09:08 PM (This post was last modified: 11-19-2016 10:13 PM by Dieter.)
Post: #140
RE: 4K HP 67 Games rom attached for testing
(11-19-2016 08:06 PM)Gene Wrote:  Testing

Something does not seem right with LBL E (attack). I try to attack ship 2 let's say and I get hit by ship 2 but with various levels of power in my attack at them (30 units, 50, 100), I get no status update of any hit / damage. The program simply runs and shows my coords again.

30, 50 or 100 units of phaser power? I think the maximum is 9. ;-)

If the attacked Klingon ship is out of range nothing happens and only the Enterprise's position is returned. You may try the original RNG (RCL 00 ATAN FRC STO 00) and the example in the documentation. The results should match. At least they do here.

Or simply recall your own position from R04 (e.g.25,40) , store a similar value (e.g. 27,42) in R01 and then try 1 [E].

Here is an example with the 9821 generator and a seed of zero.
(Note: "<" represents the angle symbol)

Code:
XEQ "ST"     SEED?
 0 [R/S]     POS=21,13

Do a scan:
  [B]        2: d13 <135
             4: DMG=6,82
             POS=21,13

Move closer to ship #2:
135 [ENTER] 1 [C]
             POS=14,20

Prepare shields:
100 [D]      SHLDS=100,00

Attack ship #2:
  2 [E]      SHLDS=80,89
             POWER?
Use phaser with max. power:
  9 [R/S]    2: DMG=37,53
             4: DMG=4,78
             POS=14,20

A second attack:
  2 [E]      SHLDS=48,95
             POWER?
  9 [R/S]    2: DMG=2,51
             4: DMG=7,99
             POS=14,20

This did not produce much damage.
Replenish shields...

100 [D]      SHLDS=148,95

...and do another attack:

  2 [E]      SHLDS=119,54
             POWER?
  9 [R/S]    2: DMG=5,90
             4: DMG=7,35
             POS=14,20

Not much damage again,
so try one more attack:

  2 [E]      SHLDS=97,53
             POWER?
  9 [R/S]    2: DMG=57,62
             2: DESTROYED
             4: DMG=5,50
             POS=14,20

This time the damage destroyed ship #2.

Review your own damage:

  4 [f][B]   4: DMG=32,44

Repair this amount of damage.
32,44 is in X, so simply press
    [f][C]   4: DMG=-32,44
             POS=14,20
etc. etc.

P.S.: Please insert a FIX 2 after LBL 80 ST+06.

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




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