Door Prize
- Type
- Utility
- Category
- Raffle number picker
- Author
- Bill Marquardt
- Published in
- Antic, January 1987 (Vol. 5, No. 9)
- Year
- 1987
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit computer, any memory size, Atari BASIC; disk or cassette
- Tags
- antic, utility, random, raffle, user-group, player-missile, display-list, mixed-mode, 1987
About the program
Atari user-group meetings in the 1980s usually ended with a raffle, and Antic technical assistant Bill Marquardt had seen it go wrong. At one meeting a member hurriedly typed in a random-number program that "finally worked after a few crashes". More often someone wrote out duplicate tickets and drew from a box, to good-natured heckling about their honesty. Since meetings already had computers with monitors facing the room, Marquardt wrote Door Prize to make the Atari do the drawing, in digits large enough to read from the back.
The magazine also printed a Listing 2 that announced each winning digit aloud through the TV speaker. It needed the Talking Typewriter speech circuit described in the same issue, and the disk carried that version as DOORPRIZ.TLK. Only the standard program is given here.
Typing it in
The listing is plain BASIC apart from a few lines. {inv}LOWEST{/inv} and {inv}HIGHEST{/inv} (lines 920 and 931) are inverse words: press the Atari key before and after. {CTRL-M} in line 921 is CTRL with M (the REM says so). The DATA strings in lines 366–369 are screen-code values for the title. Antic printed TYPO II checksums beside each line of the magazine listing. They are not part of the program.
How to use it
RUN it and enter the lowest and highest ticket numbers (anything from 0 to 9999, with the high number above the low one). Then press any key, or the joystick button, for each winner. Marquardt deliberately didn't check for repeats, because raffle rules vary. To add the check, keep the winners in an array (filled with −1 at the start) and reject any number already in it.
How it works
- Two text sizes on a graphics screen. The screen is GRAPHICS 3+16 (ANTIC mode 8). Lines 320–336 alter the display list so that a few lines show text in two sizes. Line 340 finds the screen address
W, and lines 350–369 POKE the title's screen codes straight into screen memory. - Giant digits. Each of the four digits of the winning number is a player. Line 800 finds the ROM character set and adds 128 to reach the definition of "0". Each digit's eight bytes are copied into player memory, subtracting each from 255 so the digits appear in inverse (lines 403–421).
- The odometer effect. The digits don't just appear. Lines 400–721 click all four players up from 0 to the first digit's value, then three of them on to the next digit's value, then two, then one. The number rolls up like a meter and settles one digit at a time, with a click for each step.
- No wasted draws. The random number is scaled straight into your range, so the program never has to throw away out-of-range values.
Listing
10 REM DOOR PRIZE
20 REM BY BILL MARQUARDT
30 REM (c) 1986, ANTIC PUBLISHING
32 BRK=1:IF PEEK(53279)=5 THEN BRK=0
33 GOTO 100
35 POKE 77,0:IF BRK THEN POKE 16,112:POKE 53774,112
36 RETURN
100 DIM A$(38),B$(1),NUM$(4),X(3)
140 POKE 53251,90:POKE 53250,110
150 POKE 53249,130:POKE 53248,150
170 POKE 53256,1:POKE 53257,1
180 POKE 53258,1:POKE 53259,1
196 POKE 623,4:GOSUB 900
200 BASE=PEEK(106)-4:POKE 106,BASE
210 GRAPHICS 3+16:POKE 559,46
215 FOR I=704 TO 710:POKE I,0:NEXT I
220 GOSUB 35:POKE 708,0
240 POKE 54279,BASE
250 POKE 53277,3:GOSUB 2000
260 P0BASE=BASE*256+512
270 P1BASE=P0BASE+128:P2BASE=P0BASE+256:P3BASE=P0BASE+384
290 FOR I=0 TO 511:POKE P0BASE+I,0
310 NEXT I
320 DL=PEEK(560)+256*PEEK(561)
330 POKE DL+8,7:POKE DL+9,6
336 POKE DL+10,7
340 W=PEEK(88)+256*PEEK(89)
350 READ A$:FOR I=1 TO 14:B$=A$(I,I)
354 POKE W+I+32,ASC(B$)-32:NEXT I
358 READ A$:FOR I=1 TO 8:B$=A$(I,I)
360 POKE W+I+55,ASC(B$)+64:NEXT I
362 READ A$:FOR I=1 TO 10:B$=A$(I,I)
364 POKE W+I+74,ASC(B$)-32:NEXT I
366 DATA ANTIC MAGAZINE,presents
369 DATA DOOR PRIZE
370 FOR I=704 TO 707:POKE I,15:NEXT I:POKE 708,40:POKE 709,72:POKE 710,148:GOSUB 800
380 GOSUB 960:GOSUB 400:GOSUB 500:GOSUB 600:GOSUB 700
395 POKE 764,255
396 IF PEEK(764)=255 AND STRIG(0) THEN 396
397 GOTO 370
400 FOR J=0 TO X(3)
401 SOUND 0,1,0,14:SOUND 0,0,0,0
403 FOR I=73 TO 80
405 P=255-PEEK(START+J*8+I-72)
410 POKE P0BASE+I,P:POKE P1BASE+I,P
412 POKE P2BASE+I,P:POKE P3BASE+I,P
421 NEXT I:NEXT J:RETURN
500 FOR J=0 TO X(2)
502 SOUND 0,25,10,10:SOUND 0,0,0,0
503 FOR I=73 TO 80
505 P=255-PEEK(START+J*8+I-72)
510 POKE P0BASE+I,P:POKE P1BASE+I,P
512 POKE P2BASE+I,P
521 NEXT I:NEXT J:RETURN
600 FOR J=0 TO X(1)
601 SOUND 0,25,10,10:SOUND 0,0,0,0
603 FOR I=73 TO 80
605 P=255-PEEK(START+J*8+I-72)
610 POKE P0BASE+I,P:POKE P1BASE+I,P
621 NEXT I:NEXT J:RETURN
700 FOR J=0 TO X(0)
701 SOUND 0,25,10,10:SOUND 0,0,0,0
703 FOR I=73 TO 80
705 P=255-PEEK(START+J*8+I-72)
710 POKE P0BASE+I,P
721 NEXT I:NEXT J:RETURN
800 START=PEEK(756)*256+128
810 FOR I=0 TO 7
820 P=255-PEEK(START+I)
830 POKE P0BASE+72+I,P
840 POKE P1BASE+72+I,P
850 POKE P2BASE+72+I,P
860 POKE P3BASE+72+I,P
870 NEXT I:RETURN
900 GRAPHICS 0:GOSUB 35
915 TRAP 915:POSITION 2,9
920 ? "Enter {inv}LOWEST{/inv} possible winning number."
921 POSITION 18,12:? "{CTRL-M}{CTRL-M}{CTRL-M}{CTRL-M}":REM ^M
923 POSITION 17,11:? " "
927 POSITION 17,11:INPUT LO
929 IF LO<0 OR LO>9999 THEN 923
930 POSITION 1,9
931 ? "Enter {inv}HIGHEST{/inv} possible winning number."
932 TRAP 932
933 POSITION 17,11:? " "
935 POSITION 17,11:INPUT HI
950 IF HI>9999 OR HI<=LO THEN 933
952 TRAP 40000
955 RETURN
960 X=INT(RND(0)*(HI-LO+1))+LO:NUM$="0000"
970 IF X>0 THEN NUM$(4-INT(CLOG(X)),4)=STR$(X)
985 FOR Y=0 TO 3:X(Y)=VAL(NUM$(4-Y,4-Y)):NEXT Y:RETURN
2000 COLOR 1:PLOT 9,14:DRAWTO 30,14
2010 DRAWTO 30,17:DRAWTO 9,17
2020 DRAWTO 9,14:RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: DOORPRIZ.BAS.
Credits
- Program listing: Door Prize — program listing (Antic, January 1987 (Vol. 5, No. 9)) — Bill Marquardt
- Antic, January 1987 - Vol. 5 No. 9: article (atarimagazines.com) — Bill Marquardt, 1987
- Antic disk, January 1987 - Vol. 5 No. 9: DOORPRIZ.BAS (detokenized listing) — AtariMagazines.com (Kevin Savetz), 1987
