Guest User

pacman.bas

a guest
Oct 21st, 2026
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.24 KB | Source Code | 0 0
  1. 1 for x=0 to 15
  2. 2 vol(x,0)
  3. 3 next x
  4. 4 for x=0 to 127
  5. 5 spena(x,0)
  6. 6 next x
  7. 7 gmode(15)
  8. 8 cursoff()
  9. 10 mload("pactile.mem",0x8000,8192)
  10. 11 mload("pacsprites.mem",0xC000,16384)
  11. 20 dim mx(6);dim my(6);dim mmode(6)
  12. 21 dim mdir(6);dim mcango(6);dim mcangop(6)
  13. 22 dim mmvcnt(6);dim mspeed(6);dim moncent(6)
  14. 23 dim mtargx(6);dim mtargy(6);dim moffy(6)
  15. 24 dim lastdir(6)
  16. 31 for x = 0 to 5
  17. 32 mx(x)=0;my(x)=0
  18. 33 mmode(x)=0;mdir(x)=0
  19. 34 mcango(x)=0;mcangop(x)=0
  20. 35 mmvcnt(x)=0;mspeed(x)=256
  21. 36 moncent(x)=0;lastdir(x)=0
  22. 37 mtargx(x)=0;mtargy(x)=0
  23. 38 moffy(x)=0
  24. 39 next x
  25. 40 seed=12345;lives=3;score=0;lastbonus=0;level=1
  26. 41 for x = 10 to 19
  27. 42 spena(x,0);spimg(x,2,1);spflr(x,0)
  28. 43 sptcolor(x,0);splayer(x,3)
  29. 44 spmove(x,(x-10)*16,224)
  30. 45 next x
  31. 46 for x = 0 to 6
  32. 47 spena(x+20,0);spimg(x+20,16,1);spflr(x+20,0)
  33. 48 sptcolor(x+20,0);splayer(x+20,3);spmove(x+20,(19-x)*16,224)
  34. 49 next x
  35. 50 gosub 20000
  36. 52 gosub 2000
  37. 90 spena(4,0);REM NEW SCREEN STARTS HERE
  38. 100 if level<8 then lghosttime=180-15*level else lghosttime=60
  39. 101 if level<8 then rghosttime=330-30*level else rghosttime=90
  40. 110 fleetime=0;chasetime=0;disptime=420
  41. 200 eyes=0;eatencount=0;pacanim=0;pacstage=0
  42. 201 for x = 17 to 22
  43. 202 tset(0,x,18,0,0,0x08,0x00)
  44. 203 next x
  45. 205 spflr(5,0);sptcolor(5,0);splayer(5,3);spena(5,0)
  46. 206 spimg(4,0,1);spflr(4,0);sptcolor(4,0);splayer(4,3);spena(4,1)
  47. 207 mx(4)=152
  48. 210 if tget(0,19,23)=10 then my(4)=180;goto 220;REM CHOOSE PLAYER START LOCATION
  49. 211 if tget(0,19,26)=10 then my(4)=204;goto 220
  50. 212 if tget(0,19,9)=10 then my(4)=68;goto 220
  51. 213 if tget(0,19,7)=10 then my(4)=52;goto 220
  52. 215 if tget(0,19,6)=10 then my(4)=44;goto 220
  53. 216 if tget(0,19,4)=10 then my(4)=28;goto 220
  54. 220 my(4)=140;mdir(4)=0
  55. 221 mmode(4)=1
  56. 230 spmove(4,mx(4),my(4))
  57. 240 wave(2,1,128);vol(2,32);REM SET UP VOICES
  58. 241 wave(3,1,128);vol(3,0);note(3,2.667)
  59. 242 amod(2,1,3,1502);note(2,675)
  60. 243 wave(4,2,128);vol(4,128)
  61. 244 wave(5,1,128);vol(5,0);note(5,3.703)
  62. 245 amod(4,1,5,2185)
  63. 246 adsr(4,250,0,255,200)
  64. 250 gosub 3250
  65. 300 vsync();REM GAME LOOP STARTS HERE
  66. 301 gosub 19000
  67. 302 gosub 2400
  68. 309 if mmode(4)!=1 then goto 330
  69. 310 goaldir=0;REM PLAYER INPUT
  70. 313 if keypress("w") then goaldir=1
  71. 314 if keypress("d") then goaldir=2
  72. 315 if keypress("s") then goaldir=4
  73. 316 if keypress("a") then goaldir=8
  74. 317 if my(4)=116 and (mx(x)<=28 or mx(x)>276) then goaldir=(goaldir&10)
  75. 318 goaldir=(goaldir&mcango(4))
  76. 319 if goaldir!=0x00 then mdir(4)=goaldir
  77. 320 if (mdir(4)&0x01)!=0x00 then mdir(4)=1;REM NO DIAGONAL MOVEMENT ALLOWED
  78. 321 if (mdir(4)&0x02)!=0x00 then mdir(4)=2
  79. 322 if (mdir(4)&0x04)!=0x00 then mdir(4)=4
  80. 323 if (mdir(4)&0x08)!=0x00 then mdir(4)=8
  81. 325 if moncent(4)=0 then goto 330
  82. 326 xt=floor((mx(4)+4)/8);REM CHECK IF PLAYER ATE A DOT
  83. 327 yt=floor((my(4)+4)/8)
  84. 328 if tget(0,xt,yt)=10 then tset(0,xt,yt,0,0,0x08,0x00);dots=dots-1;note(4,700,0.085);score=score+10
  85. 329 if tget(0,xt,yt)=12 then gosub 1100
  86. 330 if mdir(4)=0 then goto 350
  87. 331 pacanim=pacanim+64;REM PAC-MAN SPRITE ANIMATION
  88. 332 if pacanim<256 then goto 340
  89. 333 pacanim=pacanim-256
  90. 334 pacstage=pacstage+1
  91. 335 if pacstage>3 then pacstage=0
  92. 336 if pacstage=0 then spimg(4,0,1);goto 340
  93. 337 if pacstage=1 then spimg(4,1,1);goto 340
  94. 338 if pacstage=2 then spimg(4,2,1);goto 340
  95. 339 spimg(4,1,1)
  96. 340 if mdir(4)=0x01 then spflr(4,6);goto 350
  97. 341 if mdir(4)=0x02 then spflr(4,0);goto 350
  98. 342 if mdir(4)=0x04 then spflr(4,4);goto 350
  99. 343 if mdir(4)=0x08 then spflr(4,1);goto 350
  100. 350 if eyes>0 then wave(3,1,0);note(2,1500);note(3,4);amod(2,1,3,5464);goto 360;REM GHOST EYES SOUND
  101. 351 if fleetime>0 then wave(3,1,255);note(2,1250);note(3,7.692);amod(2,1,3,5738);goto 360;REM FLEEING GHOST SOUND
  102. 352 wave(3,1,128)
  103. 353 if dots<50 then note(2,1225);note(3,3.636);amod(2,1,3,2049);goto 360;REM FASTEST SIREN
  104. 354 if dots<100 then note(2,937.5);note(3,3.077);amod(2,1,3,1980);goto 360;REM FASTER SIREN
  105. 355 if dots<200 then note(2,800);note(3,2.857);amod(2,1,3,1639);goto 360;REM FAST SIREN
  106. 356 note(2,675);note(3,2.667);amod(2,1,3,1502);REM NORMAL SIREN
  107. 360 if lghosttime>0 then lghosttime=lghosttime-1
  108. 361 if rghosttime>0 then rghosttime=rghosttime-1
  109. 362 if fleetime>0 then fleetime=fleetime-1
  110. 363 if disptime>0 then goto 400 else goto 500
  111. 400 disptime=disptime-1;REM GHOST SCATTER MODE
  112. 401 if disptime=0 then chasetime=1200
  113. 402 if mmode(0)=4 then mtargx(0)=20;mtargy(0)=44
  114. 403 if mmode(1)=4 then mtargx(1)=284;mtargy(1)=44
  115. 404 if mmode(2)=4 then mtargx(2)=20;mtargy(2)=188
  116. 405 if mmode(3)=4 then mtargx(3)=284;mtargy(3)=188
  117. 409 goto 520
  118. 500 if chasetime>0 then chasetime=chasetime-1 else disptime=420;REM GHOST CHASE MODE
  119. 501 if mmode(0)=4 then mtargx(0)=mx(4);mtargy(0)=my(4)
  120. 502 if mmode(2)!=4 then goto 510
  121. 503 if lastdir(4)=1 then mtargx(2)=mx(4);mtargy(2)=my(4)-16;goto 510
  122. 504 if lastdir(4)=2 then mtargx(2)=mx(4)+16;mtargy(2)=my(4);goto 510
  123. 505 if lastdir(4)=4 then mtargx(2)=mx(4);mtargy(2)=my(4)+16;goto 510
  124. 506 if lastdir(4)=8 then mtargx(2)=mx(4)-16;mtargy(2)=my(4);goto 510
  125. 507 mtargx(2)=mx(4);mtargy(2)=my(4)
  126. 510 if mmode(1)=4 then mtargx(1)=mtargx(2)+(mtargx(2)-mx(0));mtargy(1)=mtargy(2)+(mtargy(2)-my(0))
  127. 511 if mmode(3)!=4 then goto 520
  128. 512 if abs(mx(4)-mx(3))+abs(my(4)-my(3))<64 then goto 405
  129. 513 mtargx(3)=mx(4);mtargy(3)=my(4)
  130. 520 eyes=0;playerhit=0
  131. 521 for x = 0 to 3;REM GHOST SPEED AND HIT DETECTION
  132. 522 if mmode(x)=6 then mspeed(x)=512;eyes=eyes+1;mtargx(x)=152;mtargy(x)=116;goto 550
  133. 523 if mmode(x)=5 then mspeed(x)=128;goto 525
  134. 524 if level<8 then mspeed(x)=256+8*level else mspeed(x)=320
  135. 525 if my(x)=116 and (mx(x)<=28 or mx(x)>276) then mspeed(x)=floor(mspeed(x)/2)
  136. 526 if abs(mx(x)-mx(4))>4 or abs(my(x)-my(4))>4 then goto 550
  137. 527 if mmode(x)<5 then playerhit=1;goto 550
  138. 528 if mmode(x)>5 then goto 550
  139. 530 spanim(x,0,0);REM GHOST GOT EATEN
  140. 531 if eatencount=3 then score=score+1600;spimg(x,63,1);goto 535
  141. 532 if eatencount=2 then score=score+800;spimg(x,23,1);eatencount=3;goto 535
  142. 533 if eatencount=1 then score=score+400;spimg(x,15,1);eatencount=2;goto 535
  143. 534 if eatencount=0 then score=score+200;spimg(x,14,1);eatencount=1
  144. 535 wave(6,1,255);vol(6,0);wave(7,2,128);vol(7,255);amod(7,1,6,4098);REM RISING WHOOP
  145. 536 note(6,2,0.5);note(7,750,0.5)
  146. 537 sleep(500)
  147. 538 mmode(x)=6
  148. 550 next x
  149. 555 if playerhit then goto 2650
  150. 560 if mmode(5)>0 and bonusstage<3 and abs(mx(5)-mx(4))<=4 and abs(my(5)-my(4))<=4 then gosub 3500
  151. 600 scorecopy=score;REM DISPLAY SCORE
  152. 601 x=22
  153. 610 c=48+(scorecopy%10)
  154. 611 drawchar(x,2,c,15,0)
  155. 612 scorecopy=floor(scorecopy/10);x=x-1
  156. 613 if scorecopy>0 then goto 610
  157. 614 drawchar(x,2," ",15,0)
  158. 615 x=x-1
  159. 616 if x>10 then goto 614
  160. 700 bonus=floor(score/10000);REM BONUS LIFE EVERY 10000 POINTS
  161. 701 if bonus<=lastbonus then goto 720
  162. 702 lives=lives+1;lastbonus=bonus
  163. 703 wave(9,1,0);vol(9,0);wave(10,1,0);vol(10,100);amod(10,0,9,32767)
  164. 704 note(9,5.4945,1.82);note(10,300,1.82);REM CLANG CLANG CLANG
  165. 705 gosub 3250
  166. 720 if bonustimer=0 then goto 750
  167. 721 bonustimer=bonustimer-1
  168. 722 if bonustimer>0 then goto 750
  169. 723 on bonusstage goto 725,730,800,740,800
  170. 725 mmode(5)=4;mx(5)=-15;my(5)=116;mdir(5)=2;REM BONUS ITEM ENTERS THE SCREEN
  171. 726 mtargx(5)=152;mtargy(5)=116;spmove(5,-15,116)
  172. 727 mspeed(5)=128;bonusstage=1;bonustimer=1200
  173. 728 goto 750
  174. 730 mtargx(5)=336;mtargy(5)=116;REM BONUS ITEM HEADS TOWARDS EXIT
  175. 731 bonusstage=2
  176. 732 goto 750
  177. 740 mmode(5)=0;mx(5)=336;my(5)=116;REM ERASE BONUS SCORE INDICATION
  178. 750 if mmode(5)=0 or bonusstage=3 then goto 800
  179. 751 bonusanim=bonusanim+1;REM BONUS ITEM BOUNCE ANIMATION
  180. 752 if bonusanim>=15 then bonusanim=0;wave(8,3,128);vol(8,64);note(8,50,.085)
  181. 753 if bonusanim<1 then moffy(5)=0;goto 800
  182. 754 if bonusanim<3 or bonusanim>12 then moffy(5)=1;goto 800
  183. 755 moffy(5)=2
  184. 800 if dots>0 then goto 300
  185. 801 vol(2,0);REM LEVEL COMPLETED
  186. 802 spimg(4,0,1)
  187. 803 mdir(4)=0
  188. 804 for x = 0 to 3
  189. 805 spena(x,0)
  190. 806 next x
  191. 808 sleep(250)
  192. 810 for x = 1 to 4
  193. 811 setcolor(20,200,200,200);REM FLASH MAZE
  194. 812 sleep(183)
  195. 813 setcolor(20,0,0,215)
  196. 814 sleep(183)
  197. 815 next x
  198. 818 sleep(250)
  199. 850 level=level+1
  200. 901 gosub 40000
  201. 902 gosub 20000
  202. 903 goto 90
  203. 1100 tset(0,xt,yt,0,0,0x08,0x00);REM PLAYER ATE A POWER PELLET
  204. 1101 if level<8 then fleetime=660-60*level else fleetime=180
  205. 1102 for x = 0 to 3
  206. 1103 if mmode(x)=4 then mmode(x)=5;mdir(x)=0;lastdir(x)=0;REM GHOSTS SET TO FLEE
  207. 1104 next x
  208. 1105 eatencount=0
  209. 1110 return
  210. 2000 vol(255);REM NEW GAME MUSIC
  211. 2010 wave(0,2,128)
  212. 2011 vol(0,255)
  213. 2012 adsr(0,250,0,255,200)
  214. 2013 wave(1,2,128)
  215. 2014 vol(1,127)
  216. 2015 adsr(1,200,0,255,100)
  217. 2040 note(0,"B4",0.0625);note(1,"E3",0.1875);sleep(125)
  218. 2041 note(0,"B5",0.0625);sleep(125)
  219. 2043 note(0,"F#5",0.0625);sleep(125)
  220. 2044 note(0,"D#5",0.0625);note(1,"B3",0.125);sleep(125)
  221. 2045 note(0,"B5",0.0625);note(1,"E3",0.1875);sleep(63)
  222. 2046 note(0,"F#5",0.0625);sleep(188)
  223. 2047 note(0,"D#5",0.125);sleep(125)
  224. 2048 note(1,"B3",0.125);sleep(125)
  225. 2050 note(0,"C5",0.0625);note(1,"F3",0.1875);sleep(125)
  226. 2051 note(0,"C6",0.0625);sleep(125)
  227. 2053 note(0,"G5",0.0625);sleep(125)
  228. 2054 note(0,"E5",0.0625);note(1,"A3",0.125);sleep(125)
  229. 2055 note(0,"C6",0.0625);note(1,"F3",0.1875);sleep(63)
  230. 2056 note(0,"G5",0.0625);sleep(188)
  231. 2057 note(0,"E5",0.125);sleep(125)
  232. 2058 note(1,"A3",0.125);sleep(125)
  233. 2060 note(0,"B4",0.0625);note(1,"E3",0.1875);sleep(125)
  234. 2061 note(0,"B5",0.0625);sleep(125)
  235. 2063 note(0,"F#5",0.0625);sleep(125)
  236. 2064 note(0,"D#5",0.0625);note(1,"B3",0.125);sleep(125)
  237. 2065 note(0,"B5",0.0625);note(1,"E3",0.1875);sleep(63)
  238. 2066 note(0,"F#5",0.0625);sleep(188)
  239. 2067 note(0,"D#5",0.125);sleep(125)
  240. 2068 note(1,"B3",0.125);sleep(125)
  241. 2070 note(0,"D#4",0.0625);note(1,"F#3",0.1875);sleep(63)
  242. 2071 note(0,"E5",0.0625);sleep(63)
  243. 2072 note(0,"F5",0.0625);sleep(125)
  244. 2073 note(0,"F5",0.0625);note(1,"G#3",0.1875);sleep(63)
  245. 2074 note(0,"F#5",0.0625);sleep(63)
  246. 2075 note(0,"G5",0.0625);sleep(125)
  247. 2076 note(0,"G5",0.0625);note(1,"A#3",0.1875);sleep(63)
  248. 2077 note(0,"G#5",0.0625);sleep(63)
  249. 2078 note(0,"A5",0.0625);sleep(125)
  250. 2079 note(0,"B5",0.125);note(1,"B3",0.1875);sleep(250)
  251. 2080 return
  252. 2400 for x = 0 to 3;REM GHOST SPRITE DISPLAY LOGIC
  253. 2401 if mmode(x)=0 then spena(x,0);goto 2440
  254. 2402 spena(x,1);splayer(x,3)
  255. 2403 if mmode(x)<5 then goto 2410
  256. 2404 if mmode(x)=5 then goto 2420
  257. 2405 if mmode(x)=6 then goto 2430
  258. 2406 goto 2440
  259. 2410 if mdir(x)=1 then spimg(x,34+x*8,1);spanim(x,1,3);spflr(x,0);goto 2440;REM NORMAL GHOST
  260. 2411 if mdir(x)=2 then spimg(x,32+x*8,1);spanim(x,1,3);spflr(x,0);goto 2440
  261. 2412 if mdir(x)=4 then spimg(x,36+x*8,1);spanim(x,1,3);spflr(x,0);goto 2440
  262. 2413 if mdir(x)=8 then spimg(x,32+x*8,1);spanim(x,1,3);spflr(x,1);goto 2440
  263. 2414 goto 2440
  264. 2420 if fleetime=0 then mmode(x)=4;goto 2410;REM FLEEING GHOST
  265. 2421 if fleetime>120 then goto 2425
  266. 2423 spimg(x,24,1);spanim(x,2,3);spflr(x,0);goto 2440
  267. 2425 spimg(x,24,1);spanim(x,1,3);spflr(x,0);goto 2440
  268. 2430 if mdir(x)=1 then spimg(x,30,1);spanim(x,0,0);spflr(x,0);goto 2440;REM EYES
  269. 2431 if mdir(x)=2 then spimg(x,28,1);spanim(x,0,0);spflr(x,0);goto 2440
  270. 2432 if mdir(x)=4 then spimg(x,31,1);spanim(x,0,0);spflr(x,0);goto 2440
  271. 2433 if mdir(x)=8 then spimg(x,29,1);spanim(x,0,0);spflr(x,0)
  272. 2440 next x
  273. 2441 return
  274. 2500 on mmode(x) goto 2590,2560,2570,2575,2505,2580,2585,2590;REM GHOST AND BONUS ITEM MOVEMENT
  275. 2505 if mcangop(x)=mcango(x) and mdir(x)!=0 then goto 2590
  276. 2506 deltax=mtargx(x)-mx(x);REM SEEK TARGET LOCATION
  277. 2507 deltay=mtargy(x)-my(x)
  278. 2508 abdx=abs(deltax)
  279. 2509 abdy=abs(deltay)
  280. 2510 if deltay<0 and abdy>=abdx then goto 2520;REM WANTS TO MOVE UP
  281. 2511 if deltay>0 and abdy>=abdx then goto 2530;REM WANTS TO MOVE DOWN
  282. 2512 if deltax<0 and abdy<=abdx then goto 2540;REM WANTS TO MOVE LEFT
  283. 2513 if deltax>0 and abdy<=abdx then goto 2550;REM WANTS TO MOVE RIGHT
  284. 2514 goto 2590
  285. 2520 if lastdir(x)!=4 and (mcango(x)&0x01)!=0x00 then mdir(x)=1;goto 2590
  286. 2521 if deltax>=0 and lastdir(x)!=8 and (mcango(x)&0x02)!=0x00 then mdir(x)=2;goto 2590
  287. 2522 if deltax<=0 and lastdir(x)!=2 and (mcango(x)&0x08)!=0x00 then mdir(x)=8;goto 2590
  288. 2523 if lastdir(x)!=8 and (mcango(x)&0x02)!=0x00 then mdir(x)=2;goto 2590
  289. 2524 if lastdir(x)!=2 and (mcango(x)&0x08)!=0x00 then mdir(x)=8;goto 2590
  290. 2525 if (mcango(x)&0x04)!=0x00 then mdir(x)=4;goto 2590
  291. 2526 goto 2590
  292. 2530 if lastdir(x)!=1 and (mcango(x)&0x04)!=0x00 then mdir(x)=4;goto 2590
  293. 2531 if deltax>=0 and lastdir(x)!=8 and (mcango(x)&0x02)!=0x00 then mdir(x)=2;goto 2590
  294. 2532 if deltax<=0 and lastdir(x)!=2 and (mcango(x)&0x08)!=0x00 then mdir(x)=8;goto 2590
  295. 2533 if lastdir(x)!=8 and (mcango(x)&0x02)!=0x00 then mdir(x)=2;goto 2590
  296. 2534 if lastdir(x)!=2 and (mcango(x)&0x08)!=0x00 then mdir(x)=8;goto 2590
  297. 2535 if (mcango(x)&0x01)!=0x00 then mdir(x)=1;goto 2590
  298. 2536 goto 2590
  299. 2540 if lastdir(x)!=2 and (mcango(x)&0x08)!=0x00 then mdir(x)=8;goto 2590
  300. 2541 if deltay>=0 and lastdir(x)!=1 and (mcango(x)&0x04)!=0x00 then mdir(x)=4;goto 2590
  301. 2542 if deltay<=0 and lastdir(x)!=4 and (mcango(x)&0x01)!=0x00 then mdir(x)=1;goto 2590
  302. 2543 if lastdir(x)!=1 and (mcango(x)&0x04)!=0x00 then mdir(x)=4;goto 2590
  303. 2544 if lastdir(x)!=4 and (mcango(x)&0x01)!=0x00 then mdir(x)=1;goto 2590
  304. 2545 if (mcango(x)&0x02)!=0x00 then mdir(x)=2;goto 2590
  305. 2546 goto 2590
  306. 2550 if lastdir(x)!=8 and (mcango(x)&0x02)!=0x00 then mdir(x)=2;goto 2590
  307. 2551 if deltay>=0 and lastdir(x)!=1 and (mcango(x)&0x04)!=0x00 then mdir(x)=4;goto 2590
  308. 2552 if deltay<=0 and lastdir(x)!=4 and (mcango(x)&0x01)!=0x00 then mdir(x)=1;goto 2590
  309. 2553 if lastdir(x)!=1 and (mcango(x)&0x04)!=0x00 then mdir(x)=4;goto 2590
  310. 2554 if lastdir(x)!=4 and (mcango(x)&0x01)!=0x00 then mdir(x)=1;goto 2590
  311. 2555 if (mcango(x)&0x08)!=0x00 then mdir(x)=8;goto 2590
  312. 2556 goto 2590
  313. 2560 if mx(x)<152 and lghosttime=0 and my(x)=116 then mdir(x)=2;mmode(x)=2;goto 2590;REM GHOST HOUSE SIDES
  314. 2561 if mx(x)>152 and rghosttime=0 and my(x)=116 then mdir(x)=8;mmode(x)=2;goto 2590
  315. 2562 if mdir(x)!=0 then goto 2590
  316. 2563 if lastdir(x)=1 then mdir(x)=4;goto 2590
  317. 2564 if lastdir(x)=2 then mdir(x)=8;goto 2590
  318. 2565 if lastdir(x)=4 then mdir(x)=1;goto 2590
  319. 2566 if lastdir(x)=8 then mdir(x)=2;goto 2590
  320. 2567 goto 2590
  321. 2570 if mx(x)=152 then mdir(x)=1;mmode(x)=3;REM GHOST HOUSE MOVE TO CENTER
  322. 2571 goto 2590
  323. 2575 if my(x)!=92 then goto 2562;REM GHOST HOUSE EXIT CENTER
  324. 2576 mmode(x)=4
  325. 2577 if mtargx(x)<mx(x) then mdir(x)=8 else mdir(x)=2
  326. 2578 goto 2590
  327. 2580 deltax=mx(x)-mx(4);REM GHOSTS FLEE THE PLAYER
  328. 2581 deltay=my(x)-my(4)
  329. 2582 goto 2508
  330. 2585 if mx(x)!=152 then goto 2505;REM EYES RETURN TO THE GHOST HOUSE
  331. 2586 if my(x)>=92 and my(x)<116 then mdir(x)=4;goto 2590
  332. 2587 if my(x)>=116 and my(x)<124 then mdir(x)=1;mmode(x)=3;goto 2590
  333. 2588 goto 2505
  334. 2590 return
  335. 2650 vol(2,0);REM PLAYER CAUGHT BY GHOST ANIMATION
  336. 2652 for x = 0 to 3
  337. 2653 spena(x,0)
  338. 2654 next x
  339. 2655 spflr(4,0);spanim(4,0,0);spimg(4,0,1)
  340. 2656 note(3,0,0);note(2,0,0);wave(2,1,255);wave(3,1,128);amod(2,1,3,273)
  341. 2657 sleep(50)
  342. 2658 note(3,5.4)
  343. 2659 sleep(92.5);vol(2,127)
  344. 2670 note(2,700);sleep(92.5);spimg(4,0,1);sleep(92.5);spimg(4,3,1)
  345. 2671 note(2,650);sleep(92.5);spimg(4,4,1);sleep(92.5);spimg(4,5,1)
  346. 2672 note(2,600);sleep(92.5);spimg(4,6,1);sleep(92.5);spimg(4,7,1)
  347. 2673 note(2,550);sleep(92.5);spimg(4,8,1);sleep(92.5);spimg(4,9,1)
  348. 2674 note(2,500);sleep(92.5);spimg(4,10,1);sleep(92.5);spimg(4,11,1)
  349. 2675 note(2,450);sleep(92.5);spimg(4,12,1);sleep(92.5);spimg(4,13,1)
  350. 2677 note(3,0,0);note(2,0,0);wave(2,2,0);wave(3,1,255)
  351. 2678 sleep(50)
  352. 2679 note(3,5.4);note(2,1100,0.370);amod(2,1,3,6011);vol(2,93)
  353. 2680 sleep(370)
  354. 2681 vol(2,0);spena(4,0)
  355. 2682 lives=lives-1
  356. 2683 if lives<0 then goto 4000
  357. 2684 gosub 3000
  358. 2685 gosub 3100
  359. 2686 gosub 3250
  360. 2687 sleep(1000)
  361. 2688 goto 90
  362. 3000 mmode(0)=4;mdir(0)=8;mx(0)=152;my(0)=92;REM GHOST SETUP
  363. 3001 mmode(1)=3;mdir(1)=4;mx(1)=152;my(1)=116
  364. 3002 mmode(2)=1;mdir(2)=1;mx(2)=136;my(2)=116
  365. 3003 mmode(3)=1;mdir(3)=1;mx(3)=168;my(3)=116
  366. 3004 for x = 0 to 3
  367. 3005 spmove(x,mx(x),my(x))
  368. 3006 next x
  369. 3007 return
  370. 3100 tset(0,17,18,16,0,0x08,0x00);REM DRAW READY MESSAGE
  371. 3101 tset(0,18,18,17,0,0x08,0x00)
  372. 3102 tset(0,19,18,18,0,0x08,0x00)
  373. 3103 tset(0,20,18,19,0,0x08,0x00)
  374. 3104 tset(0,21,18,20,0,0x08,0x00)
  375. 3105 tset(0,22,18,21,0,0x08,0x00)
  376. 3110 for x = 0 to 6;REM DRAW LEVEL INDICATION
  377. 3111 if level>x then spena(x+20,1) else spena(x+20,0)
  378. 3112 if level<8 then spimg(x+20,16+x,1);goto 3115
  379. 3113 if x+level<14 then spimg(x+20,9+x+level,1);goto 3115
  380. 3114 spimg(x+20,22,1)
  381. 3115 next x
  382. 3116 if level<8 then spimg(5,level+15,1) else spimg(5,22,1)
  383. 3120 return
  384. 3250 for x = 0 to 9;REM DRAW LIVES
  385. 3251 if x<lives then spena(x+10,1) else spena(x+10,0)
  386. 3252 next x
  387. 3253 return
  388. 3500 mdir(5)=0;mtargx(5)=mx(5);mtargy(5)=my(5);REM PLAYER ATE THE BONUS ITEM
  389. 3501 bonustimer=60;bonusanim=0;moffy(5)=0;bonusstage=3
  390. 3502 on level goto 3503,3503,3504,3505,3506,3507,3508,3509
  391. 3503 spimg(5,38,1);score=score+100;goto 3510
  392. 3504 spimg(5,39,1);score=score+200;goto 3510
  393. 3505 spimg(5,46,1);score=score+500;goto 3510
  394. 3506 spimg(5,47,1);score=score+700;goto 3510
  395. 3507 spimg(5,54,1);score=score+1000;goto 3510
  396. 3508 spimg(5,55,1);score=score+2000;goto 3510
  397. 3509 spimg(5,62,1);score=score+5000;goto 3510
  398. 3510 wave(6,1,255);vol(6,0);wave(7,2,128);vol(7,255);amod(7,1,6,4098);REM RISING WHOOP
  399. 3511 note(6,2,0.5);note(7,750,0.5)
  400. 3512 return
  401. 4000 drawchar(15,15,"GAME OVER",9,0);REM GAME OVER
  402. 4001 for x = 15 to 25
  403. 4002 tset(0,x,15,0,0,0,0)
  404. 4003 next x
  405. 4004 goto 4004
  406. 19000 for x = 0 to 5;REM SPRITE MOVEMENT AND MAZE COLLISION DETECTION
  407. 19001 if mmode(x)=0 then spena(x,0);goto 19099
  408. 19002 spena(x,1)
  409. 19003 mmvcnt(x)=mmvcnt(x)+mspeed(x)
  410. 19004 mcangop(x)=mcango(x)
  411. 19005 if mmvcnt(x)<256 then goto 19099
  412. 19007 mmvcnt(x)=mmvcnt(x)-256
  413. 19008 if mdir(x)=0 then goto 19020
  414. 19009 if (mdir(x)&0x01)!=0x00 then my(x)=my(x)-1
  415. 19010 if (mdir(x)&0x02)!=0x00 then mx(x)=mx(x)+1
  416. 19011 if (mdir(x)&0x04)!=0x00 then my(x)=my(x)+1
  417. 19012 if (mdir(x)&0x08)!=0x00 then mx(x)=mx(x)-1
  418. 19013 if mx(x)<-16 then mx(x)=mx(x)+336;REM SCREEN WRAP
  419. 19014 if my(x)<-16 then my(x)=my(x)+256
  420. 19015 if mx(x)>=320 and x=5 then mmode(x)=0;goto 19099;REM BONUS ITEM DOESN'T WRAP
  421. 19016 if mx(x)>=320 then mx(x)=mx(x)-336
  422. 19017 if my(x)>=240 then my(x)=my(x)-256
  423. 19019 spmove(x,mx(x),my(x)-moffy(x))
  424. 19020 mcango(x)=0
  425. 19021 xt=floor((mx(x)+4)/8);REM CHECK IF WE'RE CENTERED ON A TILE
  426. 19022 xo=(mx(x)-xt*8)+4
  427. 19023 yt=floor((my(x)+4)/8)
  428. 19024 yo=(my(x)-yt*8)+4
  429. 19025 moncent(x)=0
  430. 19026 if x<4 and mmode(x)<4 then goto 19080
  431. 19030 if xo!=0 then mcango(x)=mcango(x)+10
  432. 19031 if yo!=0 then mcango(x)=mcango(x)+5
  433. 19032 if xo!=0 or yo!=0 then goto 19060
  434. 19040 moncent(x)=1
  435. 19041 tcheck=tget(0,xt,yt-1);REM CHECK ADJACENT TILES FOR WALLS
  436. 19042 if tcheck=0 or tcheck=10 or tcheck=12 then mcango(x)=mcango(x)+1
  437. 19045 tcheck=tget(0,xt+1,yt)
  438. 19046 if tcheck=0 or tcheck=10 or tcheck=12 then mcango(x)=mcango(x)+2
  439. 19050 tcheck=tget(0,xt,yt+1)
  440. 19051 if tcheck=0 or tcheck=10 or tcheck=12 then mcango(x)=mcango(x)+4
  441. 19055 tcheck=tget(0,xt-1,yt)
  442. 19056 if tcheck=0 or tcheck=10 or tcheck=12 then mcango(x)=mcango(x)+8
  443. 19060 if my(x)=116 and (mx(x)<=28 or mx(x)>276) then mcango(x)=(mcango(x)&10)
  444. 19061 mdir(x)=(mdir(x)&mcango(x))
  445. 19062 if (mdir(x)&0x01)!=0 then mdir(x)=1;REM NO DIAGONAL MOVEMENT ALLOWED
  446. 19063 if (mdir(x)&0x02)!=0 then mdir(x)=2
  447. 19064 if (mdir(x)&0x04)!=0 then mdir(x)=4
  448. 19065 if (mdir(x)&0x08)!=0 then mdir(x)=8
  449. 19066 if mdir(x)!=0 then lastdir(x)=mdir(x)
  450. 19068 if x!=4 then gosub 2500
  451. 19070 goto 19005
  452. 19080 if my(x)>112 or (my(x)>92 and mmode(x)=3) then mcango(x)=mcango(x)+1;REM GHOST HOUSE MOVEMENT
  453. 19081 if my(x)<120 then mcango(x)=mcango(x)+4
  454. 19082 if mx(x)<152 then mcango(x)=mcango(x)+2
  455. 19083 if mx(x)>152 then mcango(x)=mcango(x)+8
  456. 19085 goto 19060
  457. 19099 next x
  458. 19100 return
  459. 20000 gmode(0);REM DRAW NEW MAZE SCREEN
  460. 20001 for x = 0 to 39
  461. 20002 for y = 0 to 29
  462. 20003 drawchar(x,y," ",15,0)
  463. 20004 next y
  464. 20005 next x
  465. 20006 drawchar(18,1,"SCORE",15,0)
  466. 20009 mload("pacscreen.mem",0x4000,8192)
  467. 20010 if (seed&0x01)=0x00 then goto 20015;REM PLACE DOTS PROCEDURALLY BASED ON SEED
  468. 20011 tset(0,5,24,10,0,0x08,0);tset(0,5,25,10,0,0x08,0)
  469. 20012 tset(0,9,24,10,0,0x08,0);tset(0,9,25,10,0,0x08,0)
  470. 20013 goto 20020
  471. 20015 tset(0,7,24,10,0,0x08,0);tset(0,7,25,10,0,0x08,0)
  472. 20020 if (seed&0x06)=0x00 then goto 20030
  473. 20021 if (seed&0x06)=0x02 then goto 20035
  474. 20022 if (seed&0x06)=0x04 then goto 20040
  475. 20025 tset(0,6,13,10,0,0x08,0);tset(0,7,13,10,0,0x08,0);tset(0,8,13,10,0,0x08,0)
  476. 20026 tset(0,6,17,10,0,0x08,0);tset(0,7,17,10,0,0x08,0);tset(0,8,17,10,0,0x08,0)
  477. 20027 goto 20050
  478. 20030 tset(0,6,15,10,0,0x08,0);tset(0,7,15,10,0,0x08,0);tset(0,8,15,10,0,0x08,0)
  479. 20031 tset(0,6,20,10,0,0x08,0);tset(0,7,20,10,0,0x08,0);tset(0,8,20,10,0,0x08,0)
  480. 20032 goto 20050
  481. 20035 tset(0,6,13,10,0,0x08,0);tset(0,7,13,10,0,0x08,0);tset(0,8,13,10,0,0x08,0)
  482. 20036 tset(0,6,20,10,0,0x08,0);tset(0,7,20,10,0,0x08,0);tset(0,8,20,10,0,0x08,0)
  483. 20037 goto 20050
  484. 20040 tset(0,6,17,10,0,0x08,0);tset(0,7,17,10,0,0x08,0);tset(0,8,17,10,0,0x08,0)
  485. 20050 if (seed&0x08)=0x00 then goto 20055
  486. 20051 tset(0,10,23,10,0,0x08,0);tset(0,11,23,10,0,0x08,0)
  487. 20052 tset(0,13,21,10,0,0x08,0);tset(0,14,21,10,0,0x08,0)
  488. 20053 goto 20060
  489. 20055 tset(0,13,23,10,0,0x08,0);tset(0,14,23,10,0,0x08,0)
  490. 20056 tset(0,10,21,10,0,0x08,0);tset(0,11,21,10,0,0x08,0)
  491. 20060 tset(0,12,21,10,0,0x08,0);tset(0,12,22,10,0,0x08,0);tset(0,12,23,10,0,0x08,0)
  492. 20070 if (seed&0x10)=0x00 then goto 20075
  493. 20071 tset(0,10,18,10,0,0x08,0);tset(0,11,18,10,0,0x08,0)
  494. 20072 tset(0,13,15,10,0,0x08,0);tset(0,14,15,10,0,0x08,0)
  495. 20073 goto 20080
  496. 20075 tset(0,13,18,10,0,0x08,0);tset(0,14,18,10,0,0x08,0)
  497. 20076 tset(0,10,15,10,0,0x08,0);tset(0,11,15,10,0,0x08,0)
  498. 20080 tset(0,12,15,10,0,0x08,0);tset(0,12,16,10,0,0x08,0)
  499. 20081 tset(0,12,17,10,0,0x08,0);tset(0,12,18,10,0,0x08,0)
  500. 20090 if (seed&0x20)=0x00 then goto 20095
  501. 20091 tset(0,12,19,10,0,0x08,0);tset(0,12,20,10,0,0x08,0)
  502. 20095 if (seed&0x40)=0x00 then goto 20100
  503. 20096 tset(0,12,13,10,0,0x08,0);tset(0,12,14,10,0,0x08,0)
  504. 20097 tset(0,12,24,10,0,0x08,0);tset(0,12,25,10,0,0x08,0)
  505. 20100 if (seed&0x80)=0x00 then goto 20105
  506. 20101 for x = 16 to 23
  507. 20102 tset(0,x,26,10,0,0x08,0)
  508. 20103 next x
  509. 20105 if (seed&0x100)=0x000 then goto 20110
  510. 20106 for x = 16 to 23
  511. 20107 tset(0,x,23,10,0,0x08,0)
  512. 20108 next x
  513. 20109 goto 20120
  514. 20110 for x = 16 to 18
  515. 20111 tset(0,x,23,10,0,0x08,0)
  516. 20112 tset(0,39-x,23,10,0,0x08,0)
  517. 20113 next x
  518. 20114 for y = 19 to 22
  519. 20115 tset(0,18,y,10,0,0x08,0)
  520. 20116 tset(0,21,y,10,0,0x08,0)
  521. 20117 next y
  522. 20120 if (seed&0x600)=0x000 then goto 20130
  523. 20121 if (seed&0x600)=0x200 then goto 20135
  524. 20122 if (seed&0x600)=0x400 then goto 20140
  525. 20123 tset(0,19,4,0,0,0x08,0);tset(0,20,4,0,0,0x08,0)
  526. 20124 tset(0,18,5,10,0,0x08,0);tset(0,18,6,10,0,0x08,0);tset(0,19,6,10,0,0x08,0)
  527. 20127 goto 20150
  528. 20130 tset(0,18,8,10,0,0x08,0);tset(0,18,7,10,0,0x08,0);tset(0,19,7,10,0,0x08,0)
  529. 20133 goto 20150
  530. 20135 tset(0,19,4,0,0,0x08,0);tset(0,20,4,0,0,0x08,0)
  531. 20136 tset(0,19,6,10,0,0x08,0);tset(0,20,6,10,0,0x08,0)
  532. 20140 for y = 5 to 8
  533. 20141 tset(0,18,y,10,0,0x08,0);tset(0,21,y,10,0,0x08,0)
  534. 20142 next y
  535. 20150 if (seed&0x800)=0x000 then goto 20155
  536. 20151 tset(0,13,7,10,0,0x08,0);tset(0,14,7,10,0,0x08,0)
  537. 20152 tset(0,15,10,10,0,0x08,0);tset(0,15,11,10,0,0x08,0)
  538. 20153 goto 20160
  539. 20155 tset(0,13,9,10,0,0x08,0);tset(0,14,9,10,0,0x08,0)
  540. 20156 tset(0,18,10,10,0,0x08,0);tset(0,18,11,10,0,0x08,0)
  541. 20160 tset(0,10,10,10,0,0x08,0);tset(0,11,10,10,0,0x08,0)
  542. 20161 for y = 5 to 9
  543. 20162 tset(0,15,y,10,0,0x08,0)
  544. 20163 next y
  545. 20164 tset(0,16,9,10,0,0x08,0);tset(0,17,9,10,0,0x08,0);tset(0,18,9,10,0,0x08,0)
  546. 20170 if (seed&0x1000)=0x0000 then goto 20175
  547. 20171 tset(0,19,9,10,0,0x08,0)
  548. 20172 goto 20180
  549. 20175 tset(0,18,10,10,0,0x08,0);tset(0,18,11,10,0,0x08,0)
  550. 20180 if tget(0,19,7)=10 then tset(0,19,9,0,0,0x08,0);tset(0,20,9,0,0,0x08,0)
  551. 21000 for x = 0 to 19
  552. 21010 for y = 3 to 27
  553. 21020 if tget(0,x,y)=10 then tset(0,39-x,y,10,0,0x08,0);REM MIRROR DOTS
  554. 21030 next y
  555. 21040 next x
  556. 29000 for x = 0 to 39;REM DRAW WALLS BASED ON DOT POSITIONS
  557. 29001 for y = 3 to 27
  558. 29002 if tget(0,x,y)!=0 then goto 29050
  559. 29003 if tget(0,x,y-1)=10 then goto 29020
  560. 29004 if tget(0,x,y+1)=10 then goto 29030
  561. 29005 if tget(0,x-1,y)=10 then tset(0,x,y,6,0,0xA8,0);goto 29100
  562. 29006 if tget(0,x+1,y)=10 then tset(0,x,y,6,0,0x88,0);goto 29100
  563. 29010 if tget(0,x-1,y-1)=10 then tset(0,x,y,5,0,0x08,0);goto 29100
  564. 29011 if tget(0,x+1,y-1)=10 then tset(0,x,y,5,0,0x28,0);goto 29100
  565. 29012 if tget(0,x-1,y+1)=10 then tset(0,x,y,5,0,0x48,0);goto 29100
  566. 29013 if tget(0,x+1,y+1)=10 then tset(0,x,y,5,0,0x68,0);goto 29100
  567. 29015 goto 29100
  568. 29020 if tget(0,x-1,y)=10 then tset(0,x,y,4,0,0x68,0);goto 29100
  569. 29021 if tget(0,x+1,y)=10 then tset(0,x,y,4,0,0x48,0);goto 29100
  570. 29022 tset(0,x,y,6,0,0x48,0);goto 29100
  571. 29030 if tget(0,x-1,y)=10 then tset(0,x,y,4,0,0x28,0);goto 29100
  572. 29031 if tget(0,x+1,y)=10 then tset(0,x,y,4,0,0x08,0);goto 29100
  573. 29032 tset(0,x,y,6,0,0x08,0);goto 29100
  574. 29050 if tget(0,x,y)!=2 then goto 29100
  575. 29051 if y=3 then goto 29060
  576. 29052 if y=27 then goto 29070
  577. 29053 goto 29100
  578. 29060 if tget(0,x,4)=10 then goto 29070
  579. 29061 if tget(0,x-1,4)=10 then tset(0,x,3,3,0,0x08,0);goto 29100
  580. 29062 if tget(0,x+1,4)=10 then tset(0,x,3,3,0,0x28,0);goto 29100
  581. 29063 if tget(0,x,4)=0 then tset(0,x,3,11,0,0x08,0);goto 29100
  582. 29064 goto 29100
  583. 29070 if tget(0,x,26)=10 then goto 29100
  584. 29071 if tget(0,x-1,26)=10 then tset(0,x,27,3,0,0x48,0);goto 29100
  585. 29072 if tget(0,x+1,26)=10 then tset(0,x,27,3,0,0x68,0);goto 29100
  586. 29073 if tget(0,x,26)=0 then tset(0,x,27,11,0,0x48,0);goto 29100
  587. 29100 next y
  588. 29110 next x
  589. 29400 for x = 0 to 4;REM CLEAR DOTS FROM SIDE PASSAGES
  590. 29410 tset(0,x,15,0,0,0x08,0)
  591. 29420 tset(0,39-x,15,0,0,0x08,0)
  592. 29430 next x
  593. 29500 for x = 13 to 26;REM CLEAR DOTS FROM AROUND GHOST HOUSE
  594. 29510 for y = 10 to 20
  595. 29520 if tget(0,x,y)=10 then tset(0,x,y,0,0,0x08,0)
  596. 29530 next y
  597. 29540 next x
  598. 29600 tset(0,1,6,12,0,0x09,0x31);REM PLACE POWER PELLETS
  599. 29601 tset(0,38,6,12,0,0x09,0x31)
  600. 29602 tset(0,1,24,12,0,0x09,0x31)
  601. 29603 tset(0,38,24,12,0,0x09,0x31)
  602. 29604 for x = 40 to 63
  603. 29605 tset(0,x,14,2,0,0x08,0x00)
  604. 29606 tset(0,x,16,2,0,0x18,0x00)
  605. 29607 next x
  606. 29700 gosub 3100
  607. 29800 dots = 0;REM COUNT DOTS TO EAT
  608. 29801 for x = 0 to 39
  609. 29802 for y = 0 to 29
  610. 29803 if tget(0,x,y)=10 then dots=dots+1
  611. 29804 next y
  612. 29805 next x
  613. 29900 gosub 3000
  614. 29910 bonustimer=1800;bonusstage=0;bonusanim=0
  615. 29996 vsync()
  616. 29997 gmode(15)
  617. 29998 gosub 2400
  618. 29999 return
  619. 40000 bit=0;REM PSEUDO-RANDOM NUMBER FOR MAZE GENERATION
  620. 40001 if (seed&0x0001)!=0 then bit=(bit xor 1)
  621. 40002 if (seed&0x0004)!=0 then bit=(bit xor 1)
  622. 40003 if (seed&0x0008)!=0 then bit=(bit xor 1)
  623. 40004 if (seed&0x0020)!=0 then bit=(bit xor 1)
  624. 40005 seed=(seed>>1)
  625. 40006 if bit then seed=seed+0x8000
  626. 40007 return
Advertisement
Add Comment
Please, Sign In to add comment