Need some math help for my painting

The fun thing about that is the entire map is generated by something like 50 bytes of code. (Yes, bytes.) As far as I know, it goes through all 256 screens. I could swear there used to be a whole world map online, but I’m having difficulty locating it.

Actually, here’s a map, and if I’m reading it right, that one shows 255 unique screens.

Other sources online do seem to indicate it’s 255, not 256 screens, so it looks like you have everything.

I would be extremely surprised if it were 255, since it would take slightly more space to program for 255 screens than 256, and with space at as much of a premium as it was, there’s no way they’d do that (especially not to shrink the world).

The “rooms” are algorithmically generated. See my note about how the whole map fits in under 50 bytes.

Yes, and the algorithm is simpler for 256 rooms than for 255. With 256, every time you change screens, you can just add or subtract 1 from the seed. With 255, you’d have to add or subtract one, and then check to see if you’re on the skipped seed, and go another step if you are. There’s no way they’d put in a complication like that.

I just programmed the algorithm using the source code (and then looking up to see if someone already did the work doing it in C or C++) for Pitfall and, indeed, it loops back to the initiall value after 255. The output of “0” is not represented, so that’s the number missing.

The source I found was disassembled and commented on by Thomas Jentzsch. You can find it here.

In the top of the file, it says:

Note: 255 screens.

The seed for the scene/“random” number generator is 0xc4, or 196. Here is the result of running the generator through all its values:




OUTPUT  ITERATION
196     0 (SEED)
137	1
18	2
37	3
75	4
151	5
46	6
92	7
184	8
112	9
224	10
192	11
129	12
3	13
6	14
12	15
25	16
50	17
100	18
201	19
146	20
36	21
73	22
147	23
38	24
77	25
155	26
55	27
110	28
220	29
185	30
114	31
228	32
200	33
144	34
32	35
65	36
130	37
5	38
10	39
21	40
43	41
86	42
173	43
91	44
182	45
109	46
218	47
181	48
107	49
214	50
172	51
89	52
178	53
101	54
203	55
150	56
44	57
88	58
176	59
97	60
195	61
135	62
15	63
31	64
62	65
125	66
251	67
246	68
237	69
219	70
183	71
111	72
222	73
189	74
122	75
245	76
235	77
215	78
174	79
93	80
186	81
116	82
232	83
209	84
162	85
68	86
136	87
16	88
33	89
67	90
134	91
13	92
27	93
54	94
108	95
216	96
177	97
99	98
199	99
143	100
30	101
60	102
121	103
243	104
231	105
206	106
156	107
57	108
115	109
230	110
204	111
152	112
49	113
98	114
197	115
139	116
22	117
45	118
90	119
180	120
105	121
210	122
164	123
72	124
145	125
34	126
69	127
138	128
20	129
41	130
82	131
165	132
74	133
149	134
42	135
84	136
169	137
83	138
167	139
78	140
157	141
59	142
119	143
238	144
221	145
187	146
118	147
236	148
217	149
179	150
103	151
207	152
158	153
61	154
123	155
247	156
239	157
223	158
191	159
126	160
253	161
250	162
244	163
233	164
211	165
166	166
76	167
153	168
51	169
102	170
205	171
154	172
53	173
106	174
212	175
168	176
81	177
163	178
70	179
140	180
24	181
48	182
96	183
193	184
131	185
7	186
14	187
29	188
58	189
117	190
234	191
213	192
170	193
85	194
171	195
87	196
175	197
95	198
190	199
124	200
249	201
242	202
229	203
202	204
148	205
40	206
80	207
161	208
66	209
132	210
9	211
19	212
39	213
79	214
159	215
63	216
127	217
255	218
254	219
252	220
248	221
240	222
225	223
194	224
133	225
11	226
23	227
47	228
94	229
188	230
120	231
241	232
227	233
198	234
141	235
26	236
52	237
104	238
208	239
160	240
64	241
128	242
1	243
2	244
4	245
8	246
17	247
35	248
71	249
142	250
28	251
56	252
113	253
226	254
196	255
137	256


Note that the seed, 196, appears at count 0 and count 255, so the pattern repeats after 255, not 256 iterations. Note that “0” as an output does not appear. Entering “0” as the seed value results in constant output of 0.

And here is the C code implementation of the assembly source that I used, if you want to check. That’s 15 bytes long in assembly, but note that’s only half of the map generation code (this is what happens when you go rightward in the world), and doesn’t include some branching.

Sorry, here’s a direct text link to the assembly source.

Wait…you’re married???

She must really love you to let you paint the garage doors that way.

…Or she loves Pitfall.

It took me a couple years just to get my wife to let me paint the front door red.

My hat’s off to you!

Well she was kind of hesitant at first but it obviously meant a lot to me and I really wanted to do it, so she’s rolling with it and some of my other ideas. She only likes angry birds and bejewelled type phone games, but she is in all other ways my sweetie, so we’ll celebrate 5 years at the end of this summer :smiley:
Oh, and I talked her into doing a mostly red porch :slight_smile:

Ok, I’d like to get the Atari and the game within the next few weeks and start the painting at some point in april.
I got an art tablet that has sheets of tracing paper between thin plastic sheets you can cut stencils out of. I have 10x17 printouts I was going to use to draw/trace the objects out, then stencil. But…

I’m thinking about doing this one. The question I have is: my printouts are 10X17cm, how do I change the image to print at 12x20cm? I just have whatever program windoze 10 uses by default to print and it has some size options but not 12x20cm.

pulykamell: er, yes that Thomas Jentzsch’s descriptions are a bit confusing because he keeps using the word “random”. I do not think that word means what he thinks it means. :stuck_out_tongue: But I’ve done a few languages of programming back in the day, and I’d love to have all the original code (and many other games from back then) and analyze it. Maybe I could then make my own Pitfall sequels! :wink:

Yeah, it’s a pseudo-random generator called a linear feedback shift register (LFSR). While he does say “randomly,” he immediately says that it’s through a bi-directional LFSR, so if you know what an LFSR is, you’d know it’s more accurately referred to as a pseudo-random number generator. Perhaps he should have used that term or caged the word “random” in quotes.

As far as the code goes, that is all the Pitfall code. You can modify it, reassemble it, and run it on an Atari 2600 emulator (Stella is the one I used.) I’ve done it, but all I did was change the starting seed value for the in LFSR, so I’d get a different map (or, really, a different starting point for the map; the “random” number sequence is still the same, just starting from a different point.)

ETA: Oh, and, sorry, you’ll need a 6502 assembler to generate the machine code before you run it through the emulator. I used DASM.

Yes, but putting it in quotes would have cost him 16 bits of storage for the quote characters, and adding the pseudo- prefix would have cost him a whopping 56 bits. There’s no way he could afford that much bloat!

:wink:

^ :slight_smile:

I should add, if you are really interested, check out the Atari Age website. That has a whole mess of Atari 2600 programming resources. I don’t know if there’s any higher language level tools available out there, but most of the Atari 2600 programming I’ve seen requires knowledge of the 6502 instruction set/assembly language programming (same processor as used in the early Apples, Commodores, NES, etc.) There apparently is a BASIC compiler available, but programming the 2600 really requires knowledge of assembly. If you dig, you can find the disassemblies and commented source code versions of a number of 2600 cartridges.

Two points:

(1) You are talking about a HELLUVA lot of teensy tiny detail painting, vertical, no less. . . And you’re on disability? I hurt all over just contemplating the task! The stretching, climbing up on ladders or boxes, bending double or laying on your stomach for the bottom row. Ow!

(2) Stencil work is messy. Potentially bloody, too, if you make your own stencils. Make sure you practice A LOT before you start on the actual garage doors! I’d recommend a sponge for painting, instead of gobs of paint on a brush. The paint loves to run under the stencil.

Personally, I’d take the screenshots to a graphics shop and tell them what you want to do. Perhaps they can make a transfer or a decal. And then go to a decent paint store and get advice on the best painted surface for this decal. Don’t worry, you’ll still get a chance to measure and calculate and create and contort your body! I just think you’ll get a better finished project that would also better accommodate your disabled status.

~VOW

I personally like the free program IrfanView. The print menu has all kinds of options for custom sizes, and allows selecting the proper unit (cm vs. inches). Uncheck “aspect ratio” so that it doesn’t try to calculate it for you–although in principle the size should be 20x11.764, in practice you won’t notice the difference between that and 20x12, and it’ll just make the calculations annoying.