Post Reply 
[HP42] bounching ball
09-30-2024, 07:41 PM
Post: #1
[HP42] bounching ball
Hi all,

just to share an amusement program I've done to learn a bit of HP42 programming, in particular for the PIXEL function. It's just a 3 pixels diameter ball bounching in the screen.

I've tested on Free42 and Plus42.
For Plus42 the number of pixels available in Y direction should be changed from 16 to 64 to span all the display area (row 05).
The number in row 02 should be changed, increased or decreased, to let the ball moving faster or slower.

Bye,
Davide


Code:

00 { 326-Byte Prgm }
01▸LBL "BNG2"
02 2ᴇ3
03 STO "CDS"
04 STO "CD"
05 16
06 STO "MAXY"
07 131
08 STO "MAXX"
09 1
10 STO "dY"
11 STO "dX"
12 FIX 00
13 RAN
14 RCL "MAXY"
15 2
16 -
17 ×
18 1
19 +
20 RND
21 STO "Y"
22 RAN
23 RCL "MAXX"
24 2
25 -
26 ×
27 1
28 +
29 RND
30 STO "X"
31 CLLCD
32▸LBL "START"
33 RCL "Y"
34 RCL "X"
35 XEQ "PUTB"
36▸LBL "COUNT"
37 DSE "CD"
38 GTO "COUNT"
39 RCL "CDS"
40 STO "CD"
41 CLLCD
42 RCL "MAXY"
43 1
44 -
45 RCL "Y"
46 X=Y?
47 XEQ "CSY"
48 2
49 -
50 X=0?
51 XEQ "CSY"
52 XEQ "STY"
53 RCL "MAXX"
54 2
55 -
56 RCL "X"
57 X=Y?
58 XEQ "CSX"
59 2
60 -
61 X=0?
62 XEQ "CSX"
63 XEQ "STX"
64 GTO "START"
65▸LBL "CSY"
66 RCL "dY"
67 +/-
68 STO "dY"
69 RTN
70▸LBL "CSX"
71 RCL "dX"
72 +/-
73 STO "dX"
74 RTN
75▸LBL "STY"
76 RCL "Y"
77 RCL+ "dY"
78 STO "Y"
79 RTN
80▸LBL "STX"
81 RCL "X"
82 RCL+ "dX"
83 STO "X"
84 RTN
85▸LBL "PUTB"
86 1
87 +
88 PIXEL
89 1
90 -
91 X<>Y
92 1
93 -
94 X<>Y
95 PIXEL
96 X<>Y
97 2
98 +
99 X<>Y
100 PIXEL
101 X<>Y
102 1
103 -
104 X<>Y
105 1
106 -
107 PIXEL
108 RTN
109 END


Attached File(s) Thumbnail(s)
   

.zip  BNG2.raw.zip (Size: 364 bytes / Downloads: 6)
Find all posts by this user
Quote this message in a reply
09-30-2024, 08:29 PM
Post: #2
RE: [HP42] bounching ball
A very cool demo program!

A couple of tips to the user.
1. Installing this adds 8 programs to the XEQ menu in the calculator. You want to XEQ the program named "BNG2" which will be on the second page of programs (use down-arrow to see).
2. Make sure you are in "4STK" mode. Using "NSTK" unlimited stack mode will cause items to be added to the stack indefinitely.
3. I had to change the value in step 02 to 5E4 to slow down the ball movement enough to see it when running Free42 on my PC.
Visit this user's website Find all posts by this user
Quote this message in a reply
10-01-2024, 04:21 PM
Post: #3
RE: [HP42] bounching ball
(09-30-2024 08:29 PM)Steve Simpkin Wrote:  A very cool demo program!

A couple of tips to the user.
1. Installing this adds 8 programs to the XEQ menu in the calculator. You want to XEQ the program named "BNG2" which will be on the second page of programs (use down-arrow to see).
2. Make sure you are in "4STK" mode. Using "NSTK" unlimited stack mode will cause items to be added to the stack indefinitely.
3. I had to change the value in step 02 to 5E4 to slow down the ball movement enough to see it when running Free42 on my PC.

Thank you Steve for the useful tips!

Actually, I did not realize the impact of unlimited stack versus standard stack, so thanks twice!
Find all posts by this user
Quote this message in a reply
Post Reply 




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