Doggies

Type
Game
Category
Logic puzzle (swap the pieces)
Author
Stan Ockers (modified by Garry Francis)
Published in
Eugene A.C.E. Newsletter, January 1982; reprinted by A.C.E. (N.S.W.), February 1983, and in Page 6 issue 4
Year
1982
Language
Atari BASIC
Requirements
Any 8-bit Atari with 16K+ and Atari BASIC; joystick in port 1
Three white dogs on the left and three brown dogs on the right with an empty space between, under the title DOGGIES and a move counter

About the program

Seven kennels in a row hold three white dogs on the left, an empty space in the middle and three brown dogs on the right. Your job is to swap the two packs over. A dog may step into the empty space next to it, or jump over one other dog into it, and that's all. It's the old "frogs and toads" puzzle, and the program tells you it can be done in 15 moves. What makes Stan Ockers' version charming is the animation. The dogs are redefined characters in GRAPHICS 2, and they wag their tails, bark (with a two-voice "woof"), hop when they move and shake their heads at an illegal choice.

The REM banner records an international career: written for the Eugene A.C.E. Newsletter in January 1982, modified by Garry Francis, and reprinted by A.C.E. (N.S.W.), the Australian club, in February 1983. The British magazine Page 6 also printed it, in issue 4.

Typing it in

  • The dog shapes are text strings in the DATA lines 1000–1113. Each one is six characters, drawn as three rows of two. Lines 1100–1113 are the brown dogs: the same strings typed entirely in inverse video ({inverse}…{/inverse}; press the Atari/inverse key before and after). In GRAPHICS 2, inverse selects a different colour. Lines 1010–1013 end in two or four inverse spaces, and line 1012 has four plain spaces after XQ. Keep them exactly.
  • The other inverse words (great stuff, good going, start…) are only messages.
  • Lines 2210–2540 redefine characters for the dogs. Each line starts with the character's offset into the font, followed by its eight bytes. The list ends with -1.

How to play

RUN, read the instructions and press START (the inverse "START" blinks while it waits). Move the bone (a player-missile shape under the kennels) left or right with the joystick and press fire under the dog you want to move. The move counter is at the top. Finish in 15 moves for "great stuff", under 20 for "good going". Press START to play again.

How it works

  • Smooth bone: a 43-byte vertical-blank routine at $0600 (line 2110), installed with SETVBV, reads the joystick bits in PORTA every frame and moves player 0 by changing location 209 and HPOSP0. BASIC just reads 209 to see which kennel the bone is under.
  • Animation by RESTORE: each dog pose is one DATA line. To animate, the program points RESTORE at the pose it wants (LINE+5 is barking, +6/+7 are the head turned left/right, and so on) and redraws the dog's six characters.
  • Font in RAM: a 32-byte machine-language mover copies the ROM character set below RAMTOP (lowered by four pages in line 2000), and the DATA then patches individual characters.

Changes from the published listing

One change, so the program also runs under Altirra BASIC, the free replacement BASIC built into many emulators. Altirra BASIC adds a command called MOVE, so it rejected the published lines that use that word as the start of a variable name. The variable is renamed everywhere in the program. The new name is the same length, so the memory layout is unchanged and the program behaves exactly as published on genuine Atari BASIC. If you type it in from the magazine, the original names work fine on a real Atari.

Published Now Lines
MOVE MOVX 40, 430, 450, 460
MOVE$ MOVX$ 430, 2070

Listing

1 REM ###############################
2 REM # DOGGIES #
3 REM # by Stan Ockers #
4 REM # Eugene A.C.E. Newsletter #
5 REM # January 1982 #
6 REM # Modified by Garry Francis #
7 REM # Reprinted by A.C.E.(N.S.W.) #
8 REM # February 1983 #
9 REM ###############################
10 GOSUB 2000
19 REM *** Main loop ***
20 POKE 77,0:? #6;CHR$(125);" doggies":? #6:? #6;" number of moves ";CHR$(16)
30 P$="1110222":FOR C=1 TO 7:GOSUB 100:IF A THEN GOSUB 210
40 NEXT C:POKE 209,120:POKE 53248,120:MOVX=0:ATTRACT=0
50 IF STRIG(0)=0 THEN GOSUB 300:GOTO 50
60 IF PEEK(53279)=6 THEN POKE 209,0:POKE 53248,0:GOTO 20
70 C=INT(7*RND(0))+1:GOSUB 100:IF A THEN GOSUB 500+100*INT(3*RND(0))
80 GOTO 50+ATTRACT
99 REM *** Which doggie? ***
100 A=VAL(P$(C,C)):IF A=1 THEN LINE=1000
110 IF A=2 THEN LINE=1100
120 X=3*C-3:RETURN
199 REM *** Draw doggie ***
200 FOR J=1 TO 14:NEXT J
210 RESTORE LINE:READ DOG$:POSITION X,6:? #6;DOG$(1,2)
220 POSITION X,7:? #6;DOG$(3,4):POSITION X,8:? #6;DOG$(5,6):RETURN
299 REM *** Process player's move ***
300 POKE 77,0:B=0:C=INT(PEEK(209)/24-0.5):IF C<1 THEN C=1
310 IF C>7 THEN C=7
320 B=B+1:IF VAL(P$(B,B)) THEN 320
330 IF B=C THEN RETURN
340 IF C<B-2 OR C>B+2 THEN GOSUB 100:GOSUB 800:RETURN
350 TEMP=C:FOR C=1 TO 7:IF C=TEMP THEN 400
360 GOSUB 100:IF A=0 THEN 400
370 IF C<TEMP THEN LINE=LINE+6
380 IF C>TEMP THEN LINE=LINE+7
390 GOSUB 210
400 NEXT C:C=TEMP:GOSUB 100:GOSUB 500:GOSUB 600:LINE=LINE+8:V=8:INC=0:GOSUB 900:LINE=LINE+2:INC=-1:GOSUB 900
410 LINE=LINE+2:GOSUB 900:POSITION X,6:? #6;" ":P$(B,B)=P$(C,C):P$(C,C)="0":C=B
420 GOSUB 100:LINE=LINE+12:V=1:INC=1:GOSUB 900:LINE=LINE-2:GOSUB 900:LINE=LINE-10:GOSUB 700:GOSUB 600
430 MOVX=MOVX+1:MOVX$=STR$(MOVX):POSITION 17,2:FOR I=1 TO LEN(MOVX$):? #6;CHR$(ASC(MOVX$(I,I))-32);:NEXT I
440 IF P$<>F$ THEN RETURN
450 POSITION 2,4:IF MOVX=15 THEN ? #6;" {inverse}great stuff{/inverse}":GOTO 480
460 IF MOVX<20 THEN ? #6;" {inverse}good going{/inverse}":GOTO 480
470 ? #6;"{inverse}could be better{/inverse}"
480 POSITION 0,11:? #6;"press {inverse}start{/inverse} to begin";:ATTRACT=10:RETURN
499 REM *** Bark ***
500 LINE=LINE+5:GOSUB 210:FOR I=1 TO 6:SOUND 0,ASC(BARK$(I)),12,14-I*2:SOUND 1,ASC(BARK$(I)),14,I*2:NEXT I
510 LINE=LINE-5:GOSUB 210:SOUND 0,0,0,0:SOUND 1,0,0,0:RETURN
599 REM *** Wag tail ***
600 LINE=LINE+1:FOR I=1 TO 3:LINE=LINE+1:GOSUB 200:LINE=LINE-1:GOSUB 200:NEXT I:LINE=LINE-1:GOSUB 200:RETURN
699 REM *** Hop ***
700 LINE=LINE+3:V=8:INC=0:GOSUB 900:LINE=LINE-3:GOSUB 200:RETURN
799 REM *** Shake head ***
800 FOR I=1 TO 3:LINE=LINE+6:GOSUB 200:LINE=LINE-6:GOSUB 200
810 LINE=LINE+7:GOSUB 200:LINE=LINE-7:GOSUB 200:NEXT I:RETURN
899 REM *** Footsteps sound ***
900 FOR I=1 TO 3:V=V+INC:LINE=LINE+1:GOSUB 200:SOUND 0,6,13,V:SOUND 0,0,0,0
910 LINE=LINE-1:GOSUB 200:SOUND 0,11,13,V:SOUND 0,0,0,0:NEXT I:RETURN
999 REM *** Shapes of doggies ***
1000 DATA '()*%&
1001 DATA '()\%&
1002 DATA '([*%&
1003 DATA '([*%-
1004 DATA '()\+&
1005 DATA !"#$%&
1006 DATA ./:;%&
1007 DATA WY<=%&
1008 DATA >?Z^+&
1009 DATA >?]_%-
1010 DATA @HJK{inverse}  {/inverse}
1011 DATA @HJK{inverse}  {/inverse}
1012 DATA XQ{inverse}    {/inverse}
1013 DATA XQ{inverse}    {/inverse}
1100 DATA {inverse}'()*%&{/inverse}
1101 DATA {inverse}'()\%&{/inverse}
1102 DATA {inverse}'([*%&{/inverse}
1103 DATA {inverse}'([*%-{/inverse}
1104 DATA {inverse}'()\+&{/inverse}
1105 DATA {inverse}!"#$%&{/inverse}
1106 DATA {inverse}./:;%&{/inverse}
1107 DATA {inverse}WY<=%&{/inverse}
1108 DATA {inverse}>?Z^+&{/inverse}
1109 DATA {inverse}>?]_%-{/inverse}
1110 DATA {inverse}@HJK  {/inverse}
1111 DATA {inverse}@HJK  {/inverse}
1112 DATA {inverse}XQ    {/inverse}
1113 DATA {inverse}XQ    {/inverse}
1999 REM *** Initialisation ***
2000 GRAPHICS 21:START=PEEK(106)-4:POKE 106,START-1:GRAPHICS 0:POKE 710,0:POKE 709,12:POKE 752,1:POKE 82,1
2009 REM *** Instructions ***
2010 POSITION 16,1:? "DOGGIES":?:? "There are 3 white doggies on the left"
2020 ? "side of the screen and 3 brown doggies":? "on the right side. You must reverse"
2030 ? "their position by moving one doggie at":? "a time.":?:? "Use the joystick in Port 1 to put the"
2040 ? "bone under the doggie you wish to":? "move, then press the fire button. The"
2050 ? "doggie will move into the empty space,":? "but only if he is next to it or no"
2060 ? "more than one doggie away.":?:? "It can be done in 15 moves! Can you":? "do it?"
2070 POSITION 13,22:? "{inverse} INITIALISING {/inverse}":DIM BARK$(6),ML$(32),DOG$(6),MOVX$(3),F$(7),P$(7):F$="2220111"
2079 REM *** Data for barking ***
2080 RESTORE 2090:FOR I=1 TO 6:READ A:BARK$(I)=CHR$(A):NEXT I
2090 DATA 97,109,97,9,5,5
2099 REM *** VBI service routine ***
2100 FOR I=1536 TO 1578:READ A:POKE I,A:NEXT I
2110 DATA 104,160,10,162,6,169,7,76,92,228,173,0,211,72,41,8,208,6,230,209,104,24,144,7,104,41,4,208,11,198,209
2120 DATA 169,0,133,77,165,209,141,0,208,76,98,228
2129 REM *** P-M Graphics ***
2130 POKE 54279,START:POKE 53256,1:PM=256*START:POKE 53248,0:POKE 209,0:POKE 704,30
2140 FOR I=PM+602 TO PM+604:READ A:POKE I,A:NEXT I
2150 DATA 195,255,195
2159 REM *** Move character set ***
2160 FOR I=1 TO 32:READ A:ML$(I)=CHR$(A):NEXT I:CH=256*START:X=USR(ADR(ML$),57344,CH)
2170 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,162,2
2180 DATA 160,0,177,203,145,205,136,208,249,230,204,230,206,202,208,240,96
2189 REM *** Redefine characters ***
2190 READ X:IF X=-1 THEN 2560
2200 FOR I=CH+X TO CH+X+7:READ A:POKE I,A:NEXT I:GOTO 2190
2210 DATA 8,7,15,31,61,109,111,110,111
2220 DATA 16,224,240,248,188,182,246,118,246
2230 DATA 24,12,12,7,3,3,7,15,31
2240 DATA 32,48,48,224,192,192,224,240,248
2250 DATA 40,31,31,31,31,31,24,248,248
2260 DATA 48,248,248,248,248,248,24,31,31
2270 DATA 56,0,7,31,63,125,237,239,206
2280 DATA 64,0,224,248,252,190,183,247,115
2290 DATA 72,15,12,15,7,3,7,15,31
2300 DATA 80,240,48,240,224,192,224,240,248
2310 DATA 88,31,31,31,31,27,248,248,0
2320 DATA 104,248,248,248,248,216,31,31,0
2330 DATA 112,0,7,15,31,63,63,55,55
2340 DATA 120,0,128,192,192,64,127,255,255
2350 DATA 208,55,7,7,3,3,7,15,31
2360 DATA 216,254,224,254,252,192,224,240,248
2370 DATA 224,127,7,127,63,3,7,15,31
2380 DATA 232,236,224,224,192,192,224,240,248
2390 DATA 240,0,7,31,63,127,239,239,207
2400 DATA 248,0,224,248,252,254,247,247,243
2410 DATA 256,1,7,15,11,3,1,3,7
2420 DATA 320,128,224,240,208,192,128,192,224
2430 DATA 336,7,7,7,7,7,4,28,0
2440 DATA 344,224,224,224,224,224,32,56,0
2450 DATA 392,192,192,128,192,192,192,192,96
2460 DATA 440,0,1,3,3,2,254,255,255
2470 DATA 448,3,3,1,3,3,3,3,6
2480 DATA 456,0,224,240,248,252,252,236,236
2490 DATA 464,15,15,15,7,3,7,15,31
2500 DATA 472,15,12,15,71,67,71,47,31
2510 DATA 480,240,48,240,226,194,226,244,248
2520 DATA 488,15,15,15,71,67,71,47,31
2530 DATA 496,240,240,240,226,194,226,244,248
2540 DATA 504,240,240,240,224,192,224,240,248
2550 DATA -1
2559 REM *** Return to user ***
2560 POSITION 9,22:? "Press {inverse} START {/inverse} to begin":POKE 53279,8
2570 FOR I=1 TO 20:IF PEEK(53279)<>6 THEN NEXT I:POKE 755,2-PEEK(755):GOTO 2570
2580 POP:GRAPHICS 18:POKE 16,64:POKE 53774,119:POKE 756,START:POKE 559,46:POKE 53277,3
2590 POKE 708,14:POKE 709,184:POKE 710,20:POKE 711,136:A=USR(1536):RETURN

Credits