Guest User

Disassembly of Pitfall! Atari 2600 6502 Assembly

a guest
Jun 20th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 115.04 KB | None | 0 0
  1. ; *** P I T F A L L ! ***
  2. ; Copyright 1982 Activision
  3. ; Designer: David Crane
  4.  
  5. ; Analyzed, labeled and commented
  6. ; by Thomas Jentzsch (JTZ)
  7. ; Last Update: 09.10.2001 (v0.9)
  8.  
  9. ; Scene generation:
  10. ; The 255 scenes are randomly generated through a "bidirecional" LFSR. This
  11. ; means, that the process of generating the next random number is reversible,
  12. ; which is necessary to allow traveling though the jungle in both directions.
  13. ; The random number defines the scene with the following bits:
  14. ; - 0..2: type of object(s) on the ground (logs, fire, cobra, treasure etc.)
  15. ; - 3..5: type of scene (holes, pits, crocdiles, treasures etc.)
  16. ; - 6..7: type of the tree pattern
  17. ; - 7 : position of the wall (left or right)
  18. ;
  19. ; Kernel:
  20. ; The kernel is very large. There are special loops for several horizontal
  21. ; stripes. Before the main kernel the game draws the score and the lives with
  22. ; the timer. Then follow nine stripes, which do:
  23. ; 1. draw the trees and the branches
  24. ; 2. draw the top of the liana and x-position Harry and the ground object
  25. ; 3. draw Harry and the middle of the liana
  26. ; 4. draw Harry and the bottom of the liana
  27. ; 5. draw Harry and the top of the ground object
  28. ; 6. draw the bottom of the ground object and the top of the holes/pits (no Harry)
  29. ; 7. draw Harry, holes/pits and the top of the ladder
  30. ; 8. draw Harry, the ladder and the top of the wall
  31. ; 9. draw Harry, the bottom of the ladder and the wall or the scorpion
  32. ; Finally after that, the copyright message is drawn.
  33. ;
  34. ; Misc:
  35. ; - The game speeds aren't adjusted for PAL, the PAL game run's about 16% slower.
  36. ; (This seems to be true for most PAL conversions.).
  37. ; - The timer is also running slower, it would have been quite easy to adjust
  38. ; that (s. FRAMERATE etc.).
  39.  
  40.  
  41. processor 6502
  42. include vcs.h
  43.  
  44.  
  45. ;===============================================================================
  46. ; A S S E M B L E R - S W I T C H E S
  47. ;===============================================================================
  48.  
  49. OPTIMIZE = 0 ; enable some possible optimizations
  50. FILL_OPT = 1 ; fill optimized bytes with NOPs
  51. SCREENSAVER = 1 ; compile with screensaver code
  52. TRAINER = 0 ; enable training mode
  53. NTSC = 1 ; compile for NTSC
  54. IF NTSC
  55. FRAMERATE = 60
  56. STARTTIME = $20
  57. ELSE
  58. FRAMERATE = 60 ; 50 use these values to..
  59. STARTTIME = $20 ; $24 ..adjust the PAL timer
  60. ENDIF
  61.  
  62.  
  63. ;===============================================================================
  64. ; C O N S T A N T S
  65. ;===============================================================================
  66.  
  67. ; initial value for the random number generator:
  68. RAND_SEED = $c4 ; defines the start scene of the game
  69.  
  70. ; color constants:
  71. IF NTSC
  72. BROWN = $12
  73. YELLOW = $1e
  74. ORANGE = $3e
  75. RED = $48
  76. GREEN = $d6
  77. BLUE = $a4
  78. YELLOW_GREEN = $c8
  79. PINK = $4a
  80. ELSE
  81. BROWN = $22
  82. YELLOW = $2e
  83. ORANGE = $4e
  84. RED = $68
  85. GREEN = $56
  86. BLUE = $b4
  87. YELLOW_GREEN = $78
  88. PINK = $4a
  89. ENDIF
  90. BLACK = $00
  91. GREY = $06
  92. WHITE = $0e
  93. DARK_GREEN = GREEN - $04
  94. DARK_RED = RED - $06
  95.  
  96. ; x constants:
  97. SCREENWIDTH = 160
  98. XMIN_HARRY = 8 ; minimal position before next left scene
  99. XMAX_HARRY = 148 ; maximal position before next right scene
  100.  
  101. ; y-size constants:
  102. HARRY_H = 22 ; height of Harry
  103. OBJECT_H = 16 ; maximum object height
  104. DIGIT_H = 8 ; height of the score and time digits
  105. COPYRIGHT_H = 16 ; height of copyright message
  106.  
  107. ; some defined y-positions of Harry:
  108. JUNGLE_GROUND = 32
  109. UNDER_GROUND = 86
  110.  
  111. ; positions of Harry at ladder:
  112. LADDER_TOP = 11
  113. LADDER_BOTTOM = 22
  114.  
  115. ; lenght of a jump:
  116. JUMP_LEN = 32
  117.  
  118. ; Harry pattern ids:
  119. ID_KNEEING = 0
  120. ID_RUNNING4 = 4 ; 0..3 are running ids too
  121. ID_STANDING = 5
  122. ID_SWINGING = 6
  123. ID_CLIMBING = 7
  124.  
  125. ; objectType ids:
  126. ID_STATIONARY = 4 ; stationary logs (0..5 are log types)
  127. ID_FIRE = 6
  128. ID_COBRA = 7
  129. ID_TREASURES = 8 ; 8..11 are treasures
  130. ID_NOTHING = 12
  131.  
  132. ; sceneType constants:
  133. HOLE1_SCENE = 0
  134. HOLE3_SCENE = 1
  135. CROCO_SCENE = 4
  136. TREASURE_SCENE = 5
  137.  
  138. ; flags for ladder:
  139. NOLADDER = %00000000
  140. WITHLADDER = %11111111
  141.  
  142. ; flags for pit color:
  143. BLUEPIT = %00000000
  144. BLACKPIT = %10000000
  145.  
  146. ; offsets in SoundTab for tunes:
  147. SOUND_JUMP = $20 ; Harry is jumping
  148. SOUND_TREASURE = $25 ; Harry is collecting a treasure
  149. SOUND_DEAD = $31 ; Harry is killed
  150. SOUND_FALLING = $53 ; Harry is falling into a hole
  151.  
  152. ; values for NUSIZx:
  153. ONE_COPY = %000
  154. TWO_COPIES = %001
  155. TWO_WIDE_COPIES = %010
  156. THREE_COPIES = %011
  157. DOUBLE_SIZE = %101
  158. THREE_MED_COPIES = %110
  159. QUAD_SIZE = %111
  160.  
  161. ; mask for SWCHB:
  162. BW_MASK = %1000 ; black and white bit
  163.  
  164. ; SWCHA joystick bits:
  165. MOVE_RIGHT = %0111
  166. MOVE_LEFT = %1011
  167. MOVE_DOWN = %1101
  168. MOVE_UP = %1110
  169. NO_MOVE = %1111
  170. JOY_RIGHT = ~MOVE_RIGHT & NO_MOVE
  171. JOY_LEFT = ~MOVE_LEFT & NO_MOVE
  172. JOY_DOWN = ~MOVE_DOWN & NO_MOVE
  173. JOY_UP = ~MOVE_UP & NO_MOVE
  174. JOY_HORZ = JOY_RIGHT|JOY_LEFT
  175. JOY_VERT = JOY_DOWN |JOY_UP
  176.  
  177. ; values for ENAxy:
  178. DISABLE = %00
  179. ENABLE = %10 ; value for enabling a missile
  180.  
  181. ; values for REFPx:
  182. NOREFLECT = %0000
  183. REFLECT = %1000
  184.  
  185.  
  186. ;===============================================================================
  187. ; Z P - V A R I A B L E S
  188. ;===============================================================================
  189.  
  190. SEG.U Variables
  191. ORG $80
  192.  
  193. livesPat .byte ; number of lives, stored as displayed pattern ($a0 = 3, $80 = 2, $00 = 1)
  194. random .byte ; all scenes are generated randomly with this
  195. random2 .byte ; used for random object animation
  196. joystick .byte ; stores joystick directions
  197. fireButton .byte ; stores fire button state
  198. hitLiana .byte ; Harry collided with liana? (bit 6 = 1 -> yes)
  199. cxHarry .byte ; Harry's collisions (stored but _never_ read!)
  200. IF SCREENSAVER
  201. SS_XOR .byte ; change colors in screensaver mode (0/$01..$ff)
  202. SS_Mask .byte ; darker colors in screensaver mode ($ff/$f7)
  203. ELSE
  204. dummy .word
  205. ENDIF
  206. colorLst ds 9 ; some (mostly constant!?) colors
  207. lianaBottom .byte ; bottom row of liana
  208. objectType .byte ; type of the objects on the ground (hazards & treasures)
  209. sceneType .byte ; type of the scene (0..7
  210. HMFineLst ds 3 ; fine positioning value for: Harry, ground-object, underground-object
  211. HMCoarseLst ds 3 ; coars positioning value for: Harry, ground-object, underground-object
  212. posLeftBranch .byte ; values for positioning left branch graphics
  213. posRightBranch .byte ; values for positioning right branch graphics
  214. ladderFlag .byte ; 0 = no ladder, $ff = with ladder
  215. noGameScroll .byte ; 0 = game is running
  216. PF2QuickSand .byte ; PF2 data for top quicksand row
  217. PF2Lst ds 7 ; copied pit pattern data
  218. objColLst ds 7 ; copied object colors
  219. objPatLst ds 7 ; copied object patterns
  220. harryPatPtr .word ; = $b5 pointer to Pitfall Harry patterns
  221. objPatPtr .word ; pointer to object (hazards, treasure) patterns
  222. harryColPtr .word ; pointer to Pitfall Harry colors
  223. objColPtr .word ; pointer to object (hazards, treasure) colors
  224. wallPatPtr .word ; pointer to wall patterns
  225. wallColPtr .word ; pointer to wall colors
  226. undrPatPtr .word ; pointer to underground object (wall, scorpion) patterns
  227. undrColPtr .word ; pointer to underground object (wall, scorpion) colors
  228. digitPtr ds.w 6 ; pointers for score display
  229. IF SCREENSAVER
  230. SS_Delay .byte ; = $d1
  231. SS_DelayLo .byte
  232. ENDIF
  233. frameCnt .byte ; frame counter (increased every frame)
  234. nusize1 .byte ; number of ground-objects
  235. scoreHi .byte ; 3 BCD score bytes
  236. scoreMed .byte
  237. scoreLo .byte
  238. timerHi .byte ; 2 BCD timer bytes
  239. timerMed .byte
  240. timerLo .byte ; decease timer every 60th frame
  241. hmblSum .byte ; used to generate liana line
  242. hmblAdd .byte ; depends on the liana angle
  243. hmblDir .byte ; move liana +/-1
  244. lianaPosHi .byte ; high x-position of liana bottom
  245. lianaPosLo .byte ; low x-position of liana bottom
  246. soundIdx .byte ; index of sound-table (0 = no sound)
  247. xPosHarry .byte ; x-position of Pitfall Harry
  248. xPosObject .byte ; x-position of hazards & treasures
  249. xPosScorpion .byte ; x-position of the scorpion (and the wall)
  250. patIdHarry .byte ; id of the animation for Harry
  251. reflectHarry .byte ; reflect Harry graphics
  252. reflectScorpion .byte ; reflect scorpion graphics
  253. jumpIndex .byte ; index of jump-table (0..32)
  254. oldJoystick .byte ; saved old joystick direction
  255. yPosHarry .byte ; y-position of Pitfall Harry
  256. atLiana .byte ; Harry at liana? (0 = no, -1 = yes)
  257. treePat .byte ; id of the leaves pattern (0..3)
  258. climbPos .byte ; position of Harry at ladder (0/11..22)
  259. treasureBits ds 4 ; remember which treasures haven't been found
  260. treasureCnt .byte ; = $f1 number of remaining treasures-1
  261. patOfsHarry .byte ; pattern offset (5 while kneeing, 0 else)
  262. soundDelay .byte ; play a new note every 4th frame
  263. xPosQuickSand .byte ; border of quicksand
  264. jumpMode .byte ; = $f5 similar to jumpIndex (JTZ: superfluous?)
  265. temp1 .byte
  266. temp2 .byte
  267. temp3 .byte
  268.  
  269.  
  270. ;===============================================================================
  271. ; M A C R O S
  272. ;===============================================================================
  273.  
  274. MAC FILL_NOP
  275. IF FILL_OPT
  276. REPEAT {1}
  277. NOP
  278. REPEND
  279. ENDIF
  280. ENDM
  281.  
  282.  
  283. ;===============================================================================
  284. ; R O M - C O D E (Part 1)
  285. ;===============================================================================
  286.  
  287. SEG Code
  288. ORG $f000, 0
  289.  
  290. START:
  291. sei ; 2
  292. cld ; 2
  293. ldx #$00 ; 2
  294. Reset:
  295. lda #$00 ; 2
  296. .loopClear:
  297. sta $00,x ; 4
  298. txs ; 2
  299. inx ; 2
  300. bne .loopClear ; 2³
  301.  
  302. jsr InitGame ; 6
  303.  
  304. MainLoop:
  305. ldx #8 ; 2
  306. .loopColors:
  307. lda ColorTab,x ; 4
  308. IF SCREENSAVER
  309. eor SS_XOR ; 3
  310. and SS_Mask ; 3
  311. ELSE
  312. FILL_NOP 4
  313. ENDIF
  314. sta colorLst,x ; 4 store color in list
  315. cpx #4 ; 2
  316. bcs .skipTIA ; 2³
  317. sta COLUP0,x ; 4 store color in TIA too
  318. .skipTIA:
  319. dex ; 2
  320. bpl .loopColors ; 2³
  321.  
  322. ; process underground objects (scorpion, wall):
  323. ; Only one object at a time is visible, but two different
  324. ; pointer sets are used, because the wall is much taller than
  325. ; the scorpion.
  326. ; JTZ: two color pointers aren't necessary!
  327. ldy #<ScorpionColor ; 2
  328. ldx #<Scorpion0 ; 2
  329. lda xPosScorpion ; 3
  330. lsr ; 2 animate scorpion
  331. bcc .scorpion0 ; 2³
  332. ldx #<Scorpion1 ; 2
  333. .scorpion0:
  334. lda #<Nothing ; 2
  335. sta wallPatPtr ; 3 clear ladder data pointer
  336.  
  337. lda ladderFlag ; 3 ladder in scene
  338. beq .noLadder ; 2³ no, skip
  339. ldy #<WallColor ; 2 yes,..
  340. ldx #<Wall ; 2
  341. stx wallPatPtr ; 3 ..load pointers at ladder data
  342. sty wallColPtr ; 3
  343. .noLadder:
  344. stx undrPatPtr ; 3 set scorpion or ladder pointers
  345. sty undrColPtr ; 3
  346.  
  347. ; calculate pits, quicksand etc.:
  348. ldx sceneType ; 3
  349. lda LadderTab,x ; 4 blue swamp?
  350. bpl .noPit ; 2³ yes, skip
  351. lda colorLst+4 ; 3 no, black tar pit
  352. sta colorLst+8 ; 3
  353. .noPit:
  354. ldy #0 ; 2 disable quicksand
  355. lda GroundTypeTab,x ; 4
  356. bpl .noQuickSand ; 2³
  357. lda yPosHarry ; 3
  358. cmp #55 ; 2 Harry in underground?
  359. bcs .doQuickSand ; 2³ yes, animate quicksand
  360. cmp #JUNGLE_GROUND+1 ; 2 stop quicksand animation when..
  361. bcs .stopQuickSand ; 2³ ..Harry is falling into the pit
  362. .doQuickSand:
  363. lda noGameScroll ; 3 game running?
  364. bne .stopQuickSand ; 2³ no, skip
  365. lda frameCnt ; 3
  366. lsr ; 2
  367. lsr ; 2
  368. pha ; 3
  369. lsr ; 2
  370. lsr ; 2
  371. lsr ; 2
  372. lsr ; 2
  373. tax ; 2 x = framecount / 64
  374. pla ; 4 only bits 2..5 of framecounter used
  375. and QuickSandTab+2,x ; 4 calculate size of the quicksand pit
  376. eor QuickSandTab,x ; 4
  377. pha ; 3
  378. tay ; 2
  379. lda QuickSandSize,y ; 4
  380. tay ; 2
  381. pla ; 4
  382. clc ; 2
  383. adc #16 ; 2
  384. .noQuickSand:
  385. clc ; 2
  386. sty xPosQuickSand ; 3
  387. adc #6 ; 2
  388. tay ; 2
  389. ldx #6 ; 2
  390. lda ladderFlag ; 3 no swamp etc. when ladder
  391. eor #$ff ; 2
  392. sta temp1 ; 3
  393. .loopPF2Lst:
  394. lda PF2PatTab,y ; 4
  395. sta PF2Lst,x ; 4
  396. ora temp1 ; 3
  397. sta PF2QuickSand ; 3
  398. dey ; 2
  399. dex ; 2
  400. bpl .loopPF2Lst ; 2³
  401. .stopQuickSand:
  402.  
  403. ; calculate x-positioning values:
  404. ldx #2 ; 2
  405. lda #0 ; 2
  406. IF SCREENSAVER
  407. ldy SS_Delay ; 3 game running?
  408. bmi .skipHarryPos ; 2³ no, don't draw Harry
  409. ELSE
  410. ldy noGameScroll ; TODO: bugfix, wall isn't drawn
  411. bne .skipHarryPos ; 2³ no, don't draw Harry
  412. ENDIF
  413.  
  414. .loopPos:
  415. lda xPosHarry,x ; 4
  416. .skipHarryPos:
  417. jsr CalcPosX ; 6
  418. sta HMFineLst,x ; 4
  419. sty HMCoarseLst,x ; 4
  420. stx hmblSum ; 3 -> hmblSum = 0
  421. dex ; 2
  422. bpl .loopPos ; 2³
  423.  
  424. ; load branches x-positioning values:
  425. ldx treePat ; 3
  426. lda BranchPosLTab,x ; 4
  427. sta posLeftBranch ; 3
  428. lda BranchPosRTab,x ; 4
  429. sta posRightBranch ; 3
  430.  
  431. ; copy bottom object data:
  432. ldy #14 ; 2
  433. ldx #6 ; 2
  434. .loopObjLst:
  435. lda (objColPtr),y ; 5
  436. IF SCREENSAVER
  437. eor SS_XOR ; 3
  438. and SS_Mask ; 3
  439. ELSE
  440. FILL_NOP 4
  441. ENDIF
  442. sta objColLst,x ; 4
  443. lda (objPatPtr),y ; 5
  444. sta objPatLst,x ; 4
  445. dey ; 2
  446. dex ; 2
  447. bpl .loopObjLst ; 2³
  448.  
  449. .waitTim:
  450. lda INTIM ; 4
  451. bne .waitTim ; 2³
  452. sta WSYNC ; 3
  453. ;---------------------------------------
  454. sta HMOVE ; 3
  455. sta VBLANK ; 3
  456. sta CXCLR ; 3
  457. sta temp3 ; 3 don't show anything before score
  458. jsr ShowDigits ; 6 draw score
  459.  
  460. ; set digitPtrs for timer:
  461. ldx #timerHi-scoreHi ; 2
  462. ldy #2 ; 2 minutes
  463. jsr BCD2DigitPtrs ; 6
  464. inx ; 2 seconds
  465. ldy #8 ; 2
  466. jsr BCD2DigitPtrs ; 6
  467. lda livesPat ; 3 show lives before time
  468. sta temp3 ; 3
  469. lda #<Space ; 2
  470. sta digitPtr ; 3
  471. ldy digitPtr+2 ; 3
  472. bne .noSpace ; 2³ replaced leading zero in timer with space
  473. sta digitPtr+2 ; 3
  474. .noSpace:
  475. lda #<DoublePoint ; 2
  476. sta digitPtr+6 ; 3
  477. jsr ShowDigits ; 6 draw lives and timer
  478. sta WSYNC ; 3
  479. ;---------------------------------------
  480. ; Here starts the main kernel. Actually there are nine(!)
  481. ; specialized kernel loops. Together with extra code before and
  482. ; after the loops, this makes the kernel very huge [~900 bytes).
  483.  
  484. ; draw branches at top of the logs:
  485. sta HMOVE ; 3
  486. lda #$00 ; 2
  487. sta VDELP1 ; 3 disable vertical delay for object
  488. sta GRP0 ; 3
  489. sta GRP1 ; 3
  490. lda colorLst+5 ; 3 branches color (always BROWN-2)
  491. sta COLUP0 ; 3
  492. sta COLUP1 ; 3
  493. lda #TWO_WIDE_COPIES ; 2 draw four branches
  494. sta NUSIZ0 ; 3
  495. sta NUSIZ1 ; 3
  496. lda posLeftBranch ; 3
  497. and #$0f ; 2
  498. tax ; 2 x = coarse x-positioning value of left branch
  499. lda posRightBranch ; 3
  500. and #$0f ; 2
  501. tay ; 2 y = coarse x-positioning value of right branch
  502. sta WSYNC ; 3
  503. ;---------------------------------------
  504. sta HMOVE ; 3
  505. nop ; 2
  506. .waitPos0:
  507. dex ; 2
  508. bpl .waitPos0 ; 2³
  509. sta RESP0 ; 3
  510. lda posLeftBranch ; 3
  511. sta HMP0 ; 3
  512. lda posRightBranch ; 3
  513. sta HMP1 ; 3
  514. .waitPos1:
  515. dey ; 2
  516. bpl .waitPos1 ; 2³
  517. sta RESP1 ; 3
  518. sta WSYNC ; 3
  519. ;---------------------------------------
  520. sta HMOVE ; 3
  521. lda #%101 ; 2 enable playfield priority, now..
  522. sta CTRLPF ; 3 ..the leaves overlap the branches
  523. ldy #31 ; 2
  524. lda treePat ; 3
  525. asl ; 2
  526. asl ; 2
  527. tax ; 2
  528.  
  529. ; Kernel 1 (31 lines): draw liana, branches and bottom of leaves:
  530. .loopBranches:
  531. clc ; 2
  532. lda hmblSum ; 3
  533. adc hmblAdd ; 3
  534. sta hmblSum ; 3
  535. sta HMCLR ; 3
  536. bcc .noMove0 ; 2³
  537. lda hmblDir ; 3
  538. sta HMBL ; 3
  539. .noMove0:
  540. lda #0 ; 2
  541. cpy #9 ; 2 draw branches in lower 9 lines
  542. bcs .noBranch ; 2³
  543. tya ; 2
  544. lsr ; 2
  545. lda BranchTab,y ; 4
  546. .noBranch:
  547. sta WSYNC ; 3
  548. ;---------------------------------------
  549. sta HMOVE ; 3
  550. sta GRP0 ; 3
  551. sta GRP1 ; 3
  552. bcs .noChangePF ; 2³ two line resolution for leaves
  553. lda PFLeavesTab,x ; 4 x = 0..3
  554. inx ; 2
  555. sta PF0 ; 3
  556. sta PF1 ; 3
  557. sta PF2 ; 3
  558. .noChangePF:
  559. dey ; 2
  560. bne .loopBranches ; 2³
  561.  
  562. ; prepare Kernel 2: draw liana, disable branches, draw logs:
  563. ldx treePat ; 3
  564. clc ; 2
  565. lda hmblSum ; 3
  566. adc hmblAdd ; 3
  567. sta hmblSum ; 3
  568. bcc .noMove1 ; 2³
  569. ldy hmblDir ; 3
  570. .noMove1:
  571. sty HMBL ; 3
  572. lda #%001 ; 2
  573. sta CTRLPF ; 3 disable playfield priority
  574. lda PF1LogTab,x ; 4
  575. ldy PF2LogTab,x ; 4
  576. ldx nusize1 ; 3
  577. sta WSYNC ; 3
  578. ;---------------------------------------
  579. sta HMOVE ; 3
  580. sta PF1 ; 3 draw outer logs
  581. lda colorLst+5 ; 3 always BROWN-2
  582. sta COLUPF ; 3
  583. lda #0 ; 2
  584. sta GRP0 ; 3
  585. sta GRP1 ; 3
  586. sta NUSIZ0 ; 3
  587. sta PF0 ; 3
  588. sty PF2 ; 3 draw inner logs
  589. stx NUSIZ1 ; 3
  590.  
  591. ; Kernel 2 (4 lines): draw liana, position Harry and other object:
  592. ldx #1 ; 2
  593. .loopLianaPos:
  594. clc ; 2
  595. lda hmblSum ; 3
  596. adc hmblAdd ; 3
  597. sta hmblSum ; 3
  598. lda #$00 ; 2
  599. bcc .noMove2 ; 2³
  600. lda hmblDir ; 3
  601. .noMove2:
  602. sta HMBL ; 3
  603. clc ; 2 precalc liana for next line
  604. lda hmblSum ; 3
  605. adc hmblAdd ; 3
  606. sta hmblSum ; 3
  607. lda #$00 ; 2
  608. bcc .noMove3 ; 2³
  609. lda hmblDir ; 3
  610. .noMove3:
  611. sta WSYNC ; 3
  612. ;---------------------------------------
  613. sta HMOVE ; 3
  614. ldy #0 ; 2 do the coarse positions
  615. sty temp1,x ; 4
  616. ldy HMCoarseLst,x ; 4 position at the very left?
  617. bne .waitPos ; 2³ no, skip
  618. ldy #$60 ; 2 yes, use special code
  619. sty temp1,x ; 4
  620. sta RESP0,x ; 4
  621. sta HMBL ; 3
  622. bne .endPos0 ; 3
  623.  
  624. .waitPos:
  625. dey ; 2 "normal" position
  626. bne .waitPos ; 2³
  627. sta.w HMBL ; 4
  628. sta RESP0,x ; 4
  629. .endPos0:
  630. sta WSYNC ; 3
  631. ;---------------------------------------
  632. sta HMOVE ; 3
  633. dex ; 2
  634. bpl .loopLianaPos ; 2³
  635.  
  636. jsr DrawLiana ;31/33
  637. lda HMFineLst ; 3
  638. sta HMP0 ; 3 do the fine positions
  639. lda HMFineLst+1 ; 3
  640. sta HMP1 ; 3
  641. sta WSYNC ; 3
  642. ;---------------------------------------
  643. sta HMOVE ; 3
  644. jsr DrawLiana ;31/33
  645. lda temp1 ; 3
  646. sta HMP0 ; 3
  647. lda temp2 ; 3
  648. sta HMP1 ; 3
  649. lda yPosHarry ; 3 calculate offset for Harry's pattern
  650. clc ; 2
  651. adc patOfsHarry ; 3
  652. adc #21 ; 2
  653. tay ; 2
  654. lda reflectHarry ; 3
  655. sta REFP0 ; 3
  656. sta WSYNC ; 3
  657. ;---------------------------------------
  658. sta HMOVE ; 3
  659. sta CXCLR ; 3
  660. ldx #20 ; 2
  661. stx VDELP0 ; 3 disable vertical delay for Harry
  662.  
  663. ; Kernel 3 (21 lines): draw liana and Harry:
  664. .loopLianaHarry:
  665. clc ; 2
  666. lda hmblSum ; 3
  667. adc hmblAdd ; 3
  668. sta hmblSum ; 3
  669. lda #$00 ; 2
  670. sta HMCLR ; 3
  671. bcc .noMove4 ; 2³
  672. lda hmblDir ; 3
  673. .noMove4:
  674. sta HMBL ; 3
  675. jsr DrawHarry ;27/37
  676. sta WSYNC ; 3
  677. ;---------------------------------------
  678. sta HMOVE ; 3
  679. sta COLUP0 ; 3
  680. dex ; 2
  681. bpl .loopLianaHarry ; 2³
  682.  
  683. stx VDELP0 ; 3 enable vertical delay for Harry
  684. inx ; 2
  685. stx GRP1 ; 3
  686. beq .endLiana ; 3
  687.  
  688. .skipHarry:
  689. lda #0 ; 2
  690. sta GRP0 ; 3
  691. beq .contendLiana ; 3
  692.  
  693. .endLiana:
  694. ldx #23 ; 2
  695. ; Kernel 4 (24 lines): draw end of liana, draw Harry:
  696. .loopEndLiana:
  697. clc ; 2
  698. lda hmblSum ; 3
  699. adc hmblAdd ; 3
  700. sta hmblSum ; 3
  701. lda #$00 ; 2
  702. bcc .noMove5 ; 2³
  703. lda hmblDir ; 3
  704. .noMove5:
  705. sta HMBL ; 3
  706. dey ; 2
  707. cpy #HARRY_H ; 2
  708. bcs .skipHarry ; 2³
  709. lda (harryPatPtr),y ; 5
  710. sta GRP0 ; 3
  711. lda (harryColPtr),y ; 5
  712. IF SCREENSAVER
  713. eor SS_XOR ; 3
  714. and SS_Mask ; 3
  715. ELSE
  716. FILL_NOP 4
  717. ENDIF
  718. .contendLiana:
  719. sta WSYNC ; 3
  720. ;---------------------------------------
  721. sta HMOVE ; 3
  722. sta COLUP0 ; 3
  723. lda #DISABLE ; 2
  724. cpx lianaBottom ; 3 bottom of liana reached?
  725. bcs .skipDisable ; 2³ no, skip
  726. sta ENABL ; 3 yes, disable liana
  727. .skipDisable:
  728. sta GRP1 ; 3
  729. dex ; 2
  730. bpl .loopEndLiana ; 2³
  731.  
  732. jsr DrawHarry ;27/37
  733. ldx CXP0FB-$30 ; 3
  734. stx hitLiana ; 3
  735. sta WSYNC ; 3
  736. ;---------------------------------------
  737. sta HMOVE ; 3
  738. sta COLUP0 ; 3
  739. lda colorLst+7 ; 3
  740. sta COLUPF ; 3
  741. ldx #$ff ; 2 draw the jungle ground
  742. stx PF0 ; 3
  743. stx PF1 ; 3
  744. stx PF2 ; 3
  745. lda colorLst+8 ; 3
  746. sta COLUBK ; 3
  747. inx ; 2
  748. stx GRP1 ; 3
  749.  
  750. ldx #6 ; 2
  751. ; Kernel 5: draw Harry, holes, top of object on the ground:
  752. .loopGround:
  753. jsr DrawHarry ;27/37
  754. sta WSYNC ; 3
  755. ;---------------------------------------
  756. sta HMOVE ; 3
  757. sta COLUP0 ; 3
  758. lda objColLst,x ; 4
  759. sta COLUP1 ; 3
  760. lda objPatLst,x ; 4 draw object (crocodiles, logs, snake...)
  761. sta GRP1 ; 3
  762. lda PF2Lst,x ; 4 draw pits
  763. sta PF2 ; 3
  764. dex ; 2
  765. bpl .loopGround ; 2³=31/32
  766.  
  767. tya ; 2 calculate and save..
  768. sec ; 2 ..Harry's pattern..
  769. sbc #8 ; 2 ..offset for kernel 7
  770. sta temp1 ; 3
  771.  
  772. ldx #0 ; 2
  773. ldy #7 ; 2
  774. ; Kernel 6 (8 lines): draw bottom of object on the ground, holes in the ground:
  775. .loopHoles:
  776. lda #0 ; 2
  777. sta GRP0 ; 3
  778. lda (objColPtr),y ; 5
  779. IF SCREENSAVER
  780. eor SS_XOR ; 3
  781. and SS_Mask ; 3
  782. ELSE
  783. FILL_NOP 4
  784. ENDIF
  785. sta WSYNC ; 3
  786. ;---------------------------------------
  787. sta HMOVE ; 3
  788. sta COLUP1 ; 3
  789. lda (objPatPtr),y ; 5
  790. sta GRP1 ; 3
  791. dey ; 2
  792. bmi .exitHoles ; 2³ exit loop here
  793. lda PF2Lst,x ; 4
  794. sta PF2 ; 3
  795. inx ; 2
  796. bne .loopHoles ; 3 loop always
  797.  
  798. .exitHoles:
  799. lda #0 ; 2
  800. sta GRP0 ; 3 clear Harry again (JTZ: superfluous)
  801. ldx HMCoarseLst+2 ; 3
  802. bne .notZero ; 2³
  803. lda #$60 ; 2 special HMOV when scorpion is at the very left
  804. .notZero:
  805. sta temp3 ; 3
  806.  
  807. ; check Harry's collisions (JTZ: superfluous code!)
  808. lda CXPPMM-$30 ; 3 Harry collided with other objects?
  809. asl ; 2
  810. lda CXP0FB-$30 ; 3 Harry collided with playfield?
  811. ror ; 2
  812. sta cxHarry ; 3 store here (this variable isn't used somewhere else!)
  813.  
  814. ; prepare some underground data:
  815. lda reflectScorpion ; 3 set player 1 reflection
  816. sta REFP1 ; 3
  817. lda ladderFlag ; 3 calculate playfield reflection
  818. and #%000100 ; 2
  819. eor #%100101 ; 2 ball is 4 clocks wide (ladder)
  820. tax ; 2
  821. ldy colorLst+6 ; 3 underground color (always BROWN+2)
  822. lda colorLst+4 ; 3 hole, blackground and tar pit color
  823. sta WSYNC ; 3
  824. ;---------------------------------------
  825. sta HMOVE ; 3
  826. jmp ContKernel ; 3
  827.  
  828. ShowDigits SUBROUTINE
  829. sta WSYNC ; 3
  830. ;---------------------------------------
  831. sta HMOVE ; 3
  832. lda colorLst ; 3
  833. sta COLUP0 ; 3
  834. sta COLUP1 ; 3
  835. ldy #0 ; 2
  836. sty REFP0 ; 3
  837. sty REFP1 ; 3
  838. ldx #$10|THREE_COPIES; 2
  839. stx NUSIZ0 ; 3
  840. sta RESP0 ; 3
  841. sta RESP1 ; 3
  842. stx HMP1 ; 3
  843. sta WSYNC ; 3
  844. ;---------------------------------------
  845. sta HMOVE ; 3
  846. stx NUSIZ1 ; 3
  847. iny ; 2
  848. sty CTRLPF ; 3 enable playfield reflection
  849. lda #DIGIT_H-1 ; 2
  850. sta VDELP0 ; 3
  851. sta VDELP1 ; 3
  852. sta temp2 ; 3
  853. sta HMCLR ; 3
  854. jsr SkipIny ;22 just waste 22 cycles
  855. lda temp3 ; 3 just waste three cycles
  856. .loopDigits:
  857. ldy temp2 ; 3
  858. lda (digitPtr+10),y ; 5
  859. sta temp1 ; 3
  860. lda (digitPtr+8),y ; 5
  861. tax ; 2
  862. lda (digitPtr),y ; 5
  863. ora temp3 ; 3 show lives when drawing time
  864. sta HMOVE ; 3 produce HMOVE blanks
  865. sta GRP0 ; 3
  866. lda (digitPtr+2),y ; 5
  867. sta GRP1 ; 3
  868. lda (digitPtr+4),y ; 5
  869. sta GRP0 ; 3
  870. lda (digitPtr+6),y ; 5
  871. ldy temp1 ; 3
  872. sta GRP1 ; 3
  873. stx GRP0 ; 3
  874. sty GRP1 ; 3
  875. sta GRP0 ; 3
  876. dec temp2 ; 5
  877. bpl .loopDigits ; 2³
  878.  
  879. sta WSYNC ; 3
  880. ;---------------------------------------
  881. sta HMOVE ; 3
  882. lda #0 ; 2
  883. sta GRP0 ; 3
  884. sta GRP1 ; 3
  885. sta GRP0 ; 3
  886. rts ; 6
  887.  
  888. DrawHarry SUBROUTINE
  889. ; called from kernel:
  890. dey ; 2
  891. cpy #HARRY_H ; 2
  892. bcs .skipDraw ; 2³
  893. lda (harryPatPtr),y ; 5
  894. sta GRP0 ; 3
  895. lda (harryColPtr),y ; 5
  896. IF SCREENSAVER
  897. eor SS_XOR ; 3
  898. and SS_Mask ; 3
  899. ELSE
  900. FILL_NOP 3
  901. ENDIF
  902. .exitDraw:
  903. rts ; 6 = 21/31
  904.  
  905. IF SCREENSAVER = 0
  906. ; do some missing nops:
  907. FILL_NOP 2
  908. ENDIF
  909.  
  910. .skipDraw: ; 7
  911. lda #0 ; 2
  912. sta GRP0 ; 3
  913. beq .exitDraw ; 3
  914.  
  915. CalcPosX SUBROUTINE
  916. ; calculate coarse and fine x-positioning values:
  917. tay ; 2
  918. iny ; 2
  919. tya ; 2
  920. and #$0f ; 2
  921. sta temp1 ; 3
  922. tya ; 2
  923. lsr ; 2
  924. lsr ; 2
  925. lsr ; 2
  926. lsr ; 2
  927. tay ; 2
  928. clc ; 2
  929. adc temp1 ; 3
  930. cmp #$0f ; 2
  931. bcc SkipIny ; 2³
  932. sbc #$0f ; 2
  933. iny ; 2
  934. SkipIny:
  935. eor #$07 ; 2
  936. asl ; 2
  937. asl ; 2
  938. asl ; 2
  939. asl ; 2
  940. rts ; 6
  941.  
  942. DrawLiana SUBROUTINE
  943. clc ; 2
  944. lda hmblSum ; 3
  945. adc hmblAdd ; 3
  946. sta hmblSum ; 3
  947. lda #$00 ; 2
  948. bcc .noMove6 ; 2³
  949. lda hmblDir ; 3
  950. .noMove6:
  951. sta HMBL ; 3
  952. rts ; 6 = 25/27
  953.  
  954. BCD2DigitPtrs SUBROUTINE
  955. lda scoreHi,x ; 4
  956. and #$f0 ; 2
  957. lsr ; 2
  958. sta digitPtr,y ; 5
  959. lda scoreHi,x ; 4
  960. and #$0f ; 2
  961. asl ; 2
  962. asl ; 2
  963. asl ; 2
  964. sta digitPtr+2,y ; 5
  965. sta WSYNC ; 3
  966. sta HMOVE ; 3
  967. rts ; 6
  968.  
  969. DecScoreLo SUBROUTINE
  970. lda #$07 ; 2
  971. sta AUDC1 ; 3
  972. lda #$99 ; 2 decrease scoreLo by 1
  973. DecScoreHi: ; decrease scoreHi by 1
  974. sed ; 2
  975. clc ; 2
  976. adc scoreLo ; 3
  977. sta scoreLo ; 3
  978. lda scoreMed ; 3
  979. sbc #$00 ; 2
  980. sta scoreMed ; 3
  981. lda scoreHi ; 3
  982. sbc #$00 ; 2
  983. bcs .notZero ; 2³
  984. lda #$00 ; 2 limit score at zero
  985. sta scoreMed ; 3
  986. sta scoreLo ; 3
  987. .notZero:
  988. sta scoreHi ; 3
  989. cld ; 2
  990. rts ; 6
  991.  
  992. PFLeavesTab:
  993. .byte %11111111 ; |XXXXXXXX|
  994. .byte %11001111 ; |XX XXXX|
  995. .byte %10000011 ; |X XX|
  996. .byte %00000001 ; | X|
  997.  
  998. .byte %01111111 ; | XXXXXXX|
  999. .byte %00111101 ; | XXXX X|
  1000. .byte %00011000 ; | XX |
  1001. .byte %00000000 ; | |
  1002.  
  1003. .byte %11111111 ; |XXXXXXXX|
  1004. .byte %11111110 ; |XXXXXXX |
  1005. .byte %10111100 ; |X XXXX |
  1006. .byte %00011000 ; | XX |
  1007.  
  1008. .byte %11111110 ; |XXXXXXX |
  1009. .byte %11111100 ; |XXXXXX |
  1010. .byte %01111000 ; | XXXX |
  1011. .byte %00110000 ; | XX |
  1012.  
  1013. Kernel2 SUBROUTINE
  1014. .skipHarry1:
  1015. lda #0 ; 2
  1016. sta GRP0 ; 3
  1017. beq .conrHarry ; 3
  1018.  
  1019. ContKernel:
  1020. sta COLUBK ; 3
  1021. sty COLUPF ; 3
  1022. lda #0 ; 2
  1023. sta GRP1 ; 3
  1024. lda #$ff ; 2
  1025. sta PF1 ; 3
  1026. lda PF2QuickSand ; 3
  1027. sta PF2 ; 3
  1028. stx CTRLPF ; 3
  1029. ldy temp1 ; 3
  1030. lda #$90 ; 2
  1031. sta.w HMBL ; 4
  1032. cpy #HARRY_H ; 2
  1033. sta RESBL ; 3
  1034. bcs .skipHarry1 ; 2³+1
  1035. lda (harryPatPtr),y ; 5
  1036. sta GRP0 ; 3
  1037. lda (harryColPtr),y ; 5
  1038. IF SCREENSAVER
  1039. eor SS_XOR ; 3
  1040. and SS_Mask ; 3
  1041. ELSE
  1042. FILL_NOP 4
  1043. ENDIF
  1044. .conrHarry:
  1045. ldx HMCoarseLst+2 ; 3
  1046. sta WSYNC ; 3
  1047. ;---------------------------------------
  1048. sta HMOVE ; 3
  1049. sta COLUP0 ; 3
  1050. beq .wait1 ; 2³
  1051. .wait1:
  1052. beq .wait2 ; 2³
  1053. .wait2:
  1054. lda #0 ; 2
  1055. sta GRP1 ; 3
  1056. .loopWait:
  1057. dex ; 2
  1058. bpl .loopWait ; 2³
  1059. sta.w RESP1 ; 4
  1060. sta HMCLR ; 3
  1061. sta WSYNC ; 3
  1062. ;---------------------------------------
  1063. sta HMOVE ; 3
  1064. dey ; 2
  1065. cpy #HARRY_H ; 2
  1066. bcs .skipHarry2 ; 2³
  1067. lda (harryColPtr),y ; 5
  1068. IF SCREENSAVER
  1069. eor SS_XOR ; 3
  1070. and SS_Mask ; 3
  1071. ELSE
  1072. FILL_NOP 3
  1073. ENDIF
  1074. sta COLUP0 ; 3
  1075. lda (harryPatPtr),y ; 5
  1076. sta GRP0 ; 3
  1077. .skipHarry2:
  1078. lda #0 ; 2
  1079. sta GRP1 ; 3
  1080. lda HMFineLst+2 ; 3
  1081. sta HMP1 ; 3 position scorpion or wall
  1082. ldx #11 ; 2
  1083. dey ; 2
  1084. ; Kernel 7 (12 lines): draw top of ladder, draw Harry:
  1085. .loopLadderTop:
  1086. dey ; 2
  1087. cpy #HARRY_H ; 2
  1088. bcs .skipHarry3 ; 2³
  1089. lda (harryPatPtr),y ; 5
  1090. sta GRP0 ; 3
  1091. lda (harryColPtr),y ; 5
  1092. IF SCREENSAVER
  1093. eor SS_XOR ; 3
  1094. and SS_Mask ; 3
  1095. ELSE
  1096. FILL_NOP 4
  1097. ENDIF
  1098. .contHarry3:
  1099. sta WSYNC ; 3
  1100. ;---------------------------------------
  1101. sta HMOVE ; 3
  1102. sta COLUP0 ; 3
  1103. lda #0 ; 2
  1104. sta GRP1 ; 3
  1105. lda LadderTab,x ; 4
  1106. and ladderFlag ; 3
  1107. sta ENABL ; 3
  1108. dex ; 2
  1109. bmi .exitLadderTop ; 2³ exit loop
  1110. lda temp3 ; 3
  1111. sta HMCLR ; 3
  1112. sta HMP1 ; 3 position scorpion at the very left
  1113. lda #15 ; 2 clear hmove value, prepare height of a later loop
  1114. sta temp3 ; 3
  1115. bne .loopLadderTop ; 3 loop always
  1116.  
  1117. .skipHarry3:
  1118. lda #0 ; 2
  1119. sta GRP0 ; 3
  1120. beq .contHarry3 ; 3
  1121.  
  1122. .skipHarry4:
  1123. lda #0 ; 2
  1124. sta GRP0 ; 3
  1125. beq .contHarry4 ; 3
  1126.  
  1127. .exitLadderTop:
  1128. dey ; 2
  1129. sty temp1 ; 3
  1130. cpy #HARRY_H ; 2
  1131. bcs .skipHarry4 ; 2³
  1132. lda (harryPatPtr),y ; 5
  1133. sta GRP0 ; 3
  1134. lda (harryColPtr),y ; 5
  1135. IF SCREENSAVER
  1136. eor SS_XOR ; 3
  1137. and SS_Mask ; 3
  1138. ELSE
  1139. FILL_NOP 4
  1140. ENDIF
  1141. .contHarry4:
  1142. ldy #15 ; 2
  1143. sta temp2 ; 3
  1144. lda (wallPatPtr),y ; 5
  1145. ldx #ONE_COPY ; 2 = 0
  1146. stx NUSIZ1 ; 3
  1147. sta WSYNC ; 3
  1148. ;---------------------------------------
  1149. sta HMOVE ; 3
  1150. sta GRP1 ; 3
  1151. lda temp2 ; 3
  1152. sta COLUP0 ; 3
  1153. stx PF0 ; 3 clear playfield
  1154. lda #DARK_RED ; 2 wall color
  1155. IF SCREENSAVER
  1156. and SS_Mask ; 3
  1157. ELSE
  1158. FILL_NOP 2
  1159. ENDIF
  1160. sta COLUP1 ; 3
  1161. stx PF1 ; 3
  1162. stx PF2 ; 3
  1163. lda ladderFlag ; 3
  1164. sta ENABL ; 3
  1165. dey ; 2
  1166. sty temp2 ; 3
  1167. ldx temp1 ; 3
  1168. ; Kernel 8 (15 lines): draw Harry, ladder and wall:
  1169. .loopLadder:
  1170. dex ; 2
  1171. txa ; 2
  1172. tay ; 2
  1173. cpy #HARRY_H ; 2
  1174. bcs .skipHarry5 ; 2³+1
  1175. lda (harryPatPtr),y ; 5
  1176. sta GRP0 ; 3
  1177. lda (harryColPtr),y ; 5
  1178. .contHarry5:
  1179. IF SCREENSAVER
  1180. eor SS_XOR ; 3
  1181. and SS_Mask ; 3
  1182. ELSE
  1183. bit $00
  1184. bit $00
  1185. ENDIF
  1186. ldy temp2 ; 3
  1187. sta HMOVE ; 3
  1188. sta COLUP0 ; 3
  1189. lda (wallPatPtr),y ; 5
  1190. sta GRP1 ; 3
  1191. lda (wallColPtr),y ; 5
  1192. IF SCREENSAVER
  1193. and SS_Mask ; 3
  1194. ELSE
  1195. bit $00
  1196. ENDIF
  1197. sta COLUP1 ; 3
  1198. lda LadderTab,y ; 4
  1199. and ladderFlag ; 3
  1200. sta ENABL ; 3
  1201. dec temp2 ; 5
  1202. bpl .loopLadder ; 2³+1
  1203. nop ; 2
  1204. ; Kernel 9 (16 lines): draw Harry, scorpion or the bottom of wall and ladder:
  1205. .loopUnderground:
  1206. dex ; 2
  1207. txa ; 2
  1208. tay ; 2
  1209. cpy #HARRY_H ; 2
  1210. bcs .skipHarry6 ; 2³
  1211. lda (harryPatPtr),y ; 5
  1212. sta GRP0 ; 3
  1213. lda (harryColPtr),y ; 5
  1214. .contHarry6:
  1215. IF SCREENSAVER
  1216. eor SS_XOR ; 3
  1217. and SS_Mask ; 3
  1218. ELSE
  1219. bit $00
  1220. bit $00
  1221. ENDIF
  1222. ldy temp3 ; 3
  1223. sta HMOVE ; 3
  1224. sta COLUP0 ; 3
  1225. lda (undrPatPtr),y ; 5
  1226. sta GRP1 ; 3
  1227. lda (undrColPtr),y ; 5
  1228. IF SCREENSAVER
  1229. and SS_Mask ; 3
  1230. ELSE
  1231. bit $00
  1232. ENDIF
  1233. sta COLUP1 ; 3
  1234. lda LadderTab,y ; 4
  1235. and ladderFlag ; 3
  1236. sta.w ENABL ; 4
  1237. dec temp3 ; 5
  1238. bpl .loopUnderground ; 2³
  1239. bmi .exitKernel ; 3
  1240.  
  1241. .skipHarry5:
  1242. lda #0 ; 2
  1243. sta GRP0 ; 3
  1244. nop ; 2
  1245. beq .contHarry5 ; 4 page crossed!
  1246.  
  1247. .skipHarry6:
  1248. lda #0 ; 2
  1249. sta GRP0 ; 3
  1250. nop ; 2
  1251. nop ; 2
  1252. beq .contHarry6 ; 3
  1253.  
  1254. .exitKernel:
  1255. ldx #$ff ; 2
  1256. sta WSYNC ; 3
  1257. ;---------------------------------------
  1258. sta HMOVE ; 3
  1259. stx PF0 ; 3 fill playfield registers
  1260. stx PF1 ; 3
  1261. stx PF2 ; 3
  1262. inx ; 2 x = 0
  1263. stx ENABL ; 3 clear ball and graphics registers
  1264. stx GRP0 ; 3
  1265. stx GRP1 ; 3
  1266. stx GRP0 ; 3
  1267.  
  1268. ; show animated copyright:
  1269. stx temp3 ; 3 show nothing before copyright
  1270. ldy #COPYRIGHT_H/2 ; 2
  1271. lda noGameScroll ; 3
  1272. ldx soundIdx ; 3
  1273. beq .noSound0 ; 2³
  1274. lda #0 ; 2
  1275. .noSound0:
  1276. lsr ; 2
  1277. lsr ; 2
  1278. lsr ; 2
  1279. cmp #20 ; 2 scroll-animation
  1280. bcs .ok ; 2³
  1281. ldy #0 ; 2
  1282. cmp #12 ; 2
  1283. bcc .ok ; 2³
  1284. sbc #12 ; 2
  1285. tay ; 2
  1286. .ok:
  1287. tya ; 2
  1288. clc ; 2
  1289. adc #<CopyRight5-COPYRIGHT_H/2; 2
  1290. ldx #12-2 ; 2
  1291. .loopCopyright:
  1292. sta WSYNC ; 3
  1293. sta HMOVE ; 3
  1294. sta digitPtr,x ; 4
  1295. sec ; 2
  1296. sbc #COPYRIGHT_H ; 2
  1297. dex ; 2
  1298. dex ; 2
  1299. bpl .loopCopyright ; 2³
  1300.  
  1301. lda colorLst+4 ; 3
  1302. sta COLUPF ; 3
  1303. jsr ShowDigits ; 6
  1304. lda noGameScroll ; 3 game running?
  1305. beq .endCopyright ; 2³ yes, no more scrolling
  1306. dec noGameScroll ; 5 no, scoll message
  1307. bne .endCopyright ; 2³
  1308. dec noGameScroll ; 5 avoid #0
  1309. .endCopyright:
  1310.  
  1311. ; start timer and vertical blank:
  1312. IF NTSC
  1313. lda #32 ; 2
  1314. ELSE
  1315. lda #60
  1316. ENDIF
  1317. ldx #%10000010 ; 2
  1318. sta WSYNC ; 3
  1319. sta TIM64T ; 4
  1320. stx VBLANK ; 3
  1321.  
  1322. ; check for killed Harry:
  1323. lda soundIdx ; 3
  1324. cmp #SOUND_FALLING-1 ; 2 dead tune at end of playing?
  1325. bne .slipDecrease ; 2³ no, skip decrease
  1326. ; Harry is loosing a live:
  1327. lda livesPat ; 3 any more lives?
  1328. beq .slipDecrease ; 2³ no, skip decrease
  1329. IF TRAINER
  1330. FILL_NOP 4
  1331. ELSE
  1332. asl ; 2 yes, decrease lives
  1333. asl ; 2
  1334. sta livesPat ; 3
  1335. ENDIF
  1336. lda #NOREFLECT ; 2
  1337. sta reflectHarry ; 3
  1338. sta noGameScroll ; 3
  1339. sta CXCLR ; 3
  1340. ldy #$d0|NO_MOVE ; 2 upper Harry restart y-position
  1341. sty oldJoystick ; 3 clear joystick
  1342. lda #20 ; 2
  1343. sta xPosHarry ; 3
  1344. ldx #JUMP_LEN ; 2
  1345. lda yPosHarry ; 3
  1346. cmp #71 ; 2 Harry at underground?
  1347. bcc LF5D2 ; 2³ no, skip
  1348. ldy #64 ; 2 yes, lower Harry restart y-position
  1349. lda #SCREENWIDTH/2-4 ; 2 position scorpion at center..
  1350. sta xPosScorpion ; 3 ..when Harry restarts at underground
  1351. LF5D2:
  1352. stx jumpIndex ; 3
  1353. sty yPosHarry ; 3
  1354. .slipDecrease:
  1355.  
  1356. ; *** sound routines: ***
  1357. ldy #0 ; 2
  1358. ldx soundIdx ; 3
  1359. beq .noSound ; 2³
  1360. inc soundDelay ; 5
  1361. lda soundDelay ; 3
  1362. and #$03 ; 2 next note every 4th frame
  1363. bne .skipNext ; 2³
  1364. inc soundIdx ; 5 play next note
  1365. .skipNext:
  1366. lda SoundTab-1,x ; 4
  1367. bpl .contSound ; 2³
  1368. sty soundIdx ; 3 stop current sound
  1369. .contSound:
  1370. sta AUDF0 ; 3
  1371. ldy #1 ; 2
  1372. .noSound:
  1373. sty AUDC0 ; 3
  1374. lda #4 ; 2
  1375. sta AUDV0 ; 3
  1376.  
  1377. ; check if Harry has fallen into a hole or pit:
  1378. lda climbPos ; 3 Harry at ladder?
  1379. bne .exitBounds ; 2³+1 yes, skip bounds check
  1380. lda yPosHarry ; 3
  1381. cmp #JUNGLE_GROUND ; 2 Harry at ground?
  1382. bne .exitBounds ; 2³ no, skip bounds check
  1383. ldx sceneType ; 3
  1384. cpx #CROCO_SCENE ; 2 croco scene?
  1385. bne .noCroco1 ; 2³ no, skip
  1386. bit frameCnt ; 3 open croco jaws?
  1387. bpl .contCroco ; 2³ yes, skip
  1388. dex ; 2 no, use other values
  1389. bne .contCroco ; 3
  1390.  
  1391. .noCroco1:
  1392. cpx #HOLE3_SCENE+2 ; 2 scene with hole(s) or ???? ?
  1393. bcc .contCroco ; 2³ yes, skip
  1394. ldx #HOLE3_SCENE+1 ; 2 no, limit scene type
  1395. .contCroco:
  1396. txa ; 2
  1397. asl ; 2
  1398. asl ; 2
  1399. asl ; 2
  1400. tax ; 2
  1401. ldy #3 ; 2 check up to 4 bounds
  1402. .loopBounds:
  1403. lda HoleBoundsTab,x ; 4
  1404. beq .exitBounds ; 2³ no more bounds!
  1405. clc ; 2
  1406. adc xPosQuickSand ; 3
  1407. cmp xPosHarry ; 3 Harry left of hole/pit?
  1408. bcs .inBounds ; 2³ yes, bound ok
  1409. lda HoleBoundsTab+1,x; 4
  1410. sec ; 2
  1411. sbc xPosQuickSand ; 3
  1412. cmp xPosHarry ; 3 Harry right of hole/pit?
  1413. bcs .outOfBounds ; 2³ no, Harry is falling into
  1414. .inBounds:
  1415. inx ; 2
  1416. inx ; 2
  1417. dey ; 2
  1418. bpl .loopBounds ; 2³
  1419. bmi .exitBounds ; 3
  1420.  
  1421. .outOfBounds:
  1422. inc yPosHarry ; 5 Harry is falling down
  1423. ldx #JUMP_LEN ; 2
  1424. stx jumpIndex ; 3
  1425. dex ; 2
  1426. stx oldJoystick ; 3 x=$1f -> no direction
  1427. .exitBounds:
  1428. lda jumpMode ; 3 JTZ: superfluous code?
  1429. bne .waitTim ; 2³
  1430. bit hitLiana ; 3 collison with liana
  1431. bvc .waitTim ; 2³ no, skip
  1432. lda jumpIndex ; 3 currently jumping?
  1433. beq .waitTim ; 2³ no, skip
  1434. ldx atLiana ; 3 Harry already at liana?
  1435. bne .waitTim ; 2³ yes, skip
  1436. stx jumpIndex ; 3 no, stop jump
  1437. inx ; 2
  1438. stx atLiana ; 3 enter "liana mode"
  1439. stx soundIdx ; 3 start tarzan sound (=0)
  1440.  
  1441. ; wait for end of vertical blank:
  1442. .waitTim:
  1443. lda INTIM ; 4
  1444. bne .waitTim ; 2³
  1445.  
  1446. ; start vertical sync:
  1447. sta AUDC1 ; 3
  1448. ldy #%10000010 ; 2 enable vertical sync and dump ports (JTZ: why?)
  1449. sty WSYNC ; 3
  1450. sty VSYNC ; 3
  1451. sty WSYNC ; 3
  1452. sty WSYNC ; 3
  1453. sty WSYNC ; 3
  1454. sta VSYNC ; 3
  1455.  
  1456. IF SCREENSAVER
  1457. ; process screensaver code:
  1458. inc SS_DelayLo ; 5
  1459. bne .skipSS_Delay ; 2³
  1460. inc SS_Delay ; 5
  1461. bne .skipSS_Delay ; 2³
  1462. sec ; 2
  1463. ror SS_Delay ; 5
  1464. .skipSS_Delay:
  1465. ldy #$ff ; 2
  1466. lda SWCHB ; 4
  1467. and #BW_MASK ; 2
  1468. bne .colorMode ; 2³
  1469. ldy #$0f ; 2
  1470. .colorMode:
  1471. tya ; 2
  1472. ldy #$00 ; 2 disable changing colors
  1473. bit SS_Delay ; 3
  1474. bpl .noScreenSaver ; 2³
  1475. and #$f7 ; 2 avoid bright colors in screensaver mode
  1476. ldy SS_Delay ; 3
  1477. .noScreenSaver:
  1478. sty SS_XOR ; 3
  1479. asl SS_XOR ; 5
  1480. sta SS_Mask ; 3
  1481. ELSE
  1482. FILL_NOP 39
  1483. ENDIF
  1484.  
  1485. ; start timer for vertical sync:
  1486. IF NTSC
  1487. lda #47 ; 2
  1488. ELSE
  1489. lda #79
  1490. ENDIF
  1491. sta WSYNC ; 3
  1492. sta TIM64T ; 4
  1493.  
  1494. ; read joystick:
  1495. lda SWCHA ; 4
  1496. lsr ; 2
  1497. lsr ; 2
  1498. lsr ; 2
  1499. lsr ; 2
  1500. sta joystick ; 3
  1501. cmp #NO_MOVE ; 2
  1502. beq .noMove ; 2³
  1503. ldx #0 ; 2
  1504. IF SCREENSAVER
  1505. stx SS_Delay ; 3 reset screensaver
  1506. ELSE
  1507. FILL_NOP 2
  1508. ENDIF
  1509. lda timerHi ; 3
  1510. cmp #STARTTIME ; 2 timer at 20:00?
  1511. bne .noMove ; 2³ no, skip
  1512. stx noGameScroll ; 3 yes, game is running
  1513. .noMove:
  1514.  
  1515. ; read RESET switch:
  1516. lda SWCHB ; 4
  1517. lsr ; 2 RESET pressed?
  1518. bcs .noReset ; 2³ no, skip
  1519. IF SCREENSAVER
  1520. ldx #SS_Delay ; 2 yes, load init-values offset..
  1521. ELSE
  1522. ldx #frameCnt ; 2 yes, load init-values offset..
  1523. ENDIF
  1524. jmp Reset ; 3 ..and jump to Reset
  1525.  
  1526. .noReset:
  1527. lda noGameScroll ; 3 game running?
  1528. beq .processHarry ; 2³ yes, process Harry
  1529. jmp ProcessObjects ; 3 no, skip Harry, goto objects
  1530.  
  1531. ; *** process Harry: ***
  1532. .processHarry:
  1533. inc frameCnt ; 5
  1534. lda random2 ; 3
  1535. asl ; 2
  1536. eor random2 ; 3
  1537. asl ; 2
  1538. rol random2 ; 5
  1539. lda climbPos ; 3 Harry at ladder?
  1540. bne .endDoJump ; 2³+1 no, skip continue jump
  1541. ldx jumpIndex ; 3 currently jumping?
  1542. beq .endDoJump ; 2³+1 no, skip continue jump
  1543. lda yPosHarry ; 3 yes, calculate..
  1544. sec ; 2 ..new y-position of Harry
  1545. sbc JumpTab-1,x ; 4
  1546. sta yPosHarry ; 3
  1547. inc jumpIndex ; 5
  1548. lda jumpIndex ; 3
  1549. cmp #JUMP_LEN+1 ; 2
  1550. bcc .indexOk ; 2³
  1551. lda #JUMP_LEN ; 2
  1552. sta jumpIndex ; 3
  1553. .indexOk:
  1554.  
  1555. ldx yPosHarry ; 3
  1556. cpx #JUNGLE_GROUND ; 2 Harry at jungle ground?
  1557. beq .stopJump ; 2³+1 yes, stop any jump
  1558. ldy ladderFlag ; 3 ladder in scene?
  1559. beq .skipFalling ; 2³+1 no, skip falling
  1560. cpx #JUNGLE_GROUND+2 ; 2
  1561. bne .skipFalling ; 2³+1
  1562. lda #SOUND_FALLING ; 2 Harry is falling into a hole
  1563. sta soundIdx ; 3 start falling-sound
  1564. lda #$00 ; 2
  1565. jsr DecScoreHi ; 6 subtract 100 points from score
  1566. .skipFalling:
  1567. cpx #UNDER_GROUND ; 2 is Harry at underground bottom?
  1568. beq .stopJump ; 2³ yes, stop any jump
  1569. cpx #54 ; 2 has Harry reached the falling limit?
  1570. bne .endDoJump ; 2³ no, skip
  1571. tya ; 2 ladder in scene?
  1572. bne .endDoJump ; 2³ no, skip kill
  1573. jmp KilledHarry ; 3 yes, Harry is killed
  1574.  
  1575. .stopJump:
  1576. lda #0 ; 2
  1577. sta jumpIndex ; 3
  1578. sta jumpMode ; 3
  1579. .endDoJump:
  1580.  
  1581. ; countdown timer:
  1582. dec timerLo ; 5
  1583. bpl .inTime ; 2³
  1584. lda #FRAMERATE-1 ; 2
  1585. sta timerLo ; 3
  1586. sed ; 2
  1587. lda timerMed ; 3
  1588. sec ; 2
  1589. sbc #$01 ; 2
  1590. bcs .contMinute ; 2³
  1591. lda #$59 ; 2 start next minute
  1592. .contMinute:
  1593. sta timerMed ; 3
  1594. lda timerHi ; 3
  1595. IF TRAINER
  1596. lda #$19 ; 2
  1597. ELSE
  1598. sbc #$00 ; 2
  1599. ENDIF
  1600. sta timerHi ; 3
  1601. cld ; 2
  1602. lda timerHi ; 3 any more..
  1603. ora timerMed ; 3 ..time left?
  1604. bne .inTime ; 2³ yes, continue
  1605. dec noGameScroll ; 5 no, stop game
  1606. .inTime:
  1607.  
  1608. ; check collisions between Harry and object:
  1609. lda CXPPMM-$30 ; 3 Harry collided?
  1610. bmi .contCollision ; 2³ yes, process collisions
  1611. lda #0 ; 2 no, skip collisions
  1612. sta patOfsHarry ; 3
  1613. beq .endCollision ; 3
  1614.  
  1615. .contCollision:
  1616. lda yPosHarry ; 3
  1617. cmp #64 ; 2 Harry at underground?
  1618. bcs .checkWallHit ; 2³ yes, check wall
  1619. lda atLiana ; 3 no, Harry at liana?
  1620. bne .endCollision ; 2³ yes, skip
  1621. lda sceneType ; 3
  1622. cmp #CROCO_SCENE ; 2 croco in scene?
  1623. beq .endCollision ; 2³ yes, skip
  1624. cmp #TREASURE_SCENE ; 2 treasue in scene?
  1625. bne .noTreasure1 ; 2³ no, skip
  1626. jsr CheckTreasures ; 6 yes, check if treasure was found before
  1627. bne .endCollision ; 2³
  1628. sta treasureBits,x ; 4 clear treasure bit
  1629. dec treasureCnt ; 5 all treasures found
  1630. bpl .incScore ; 2³ no, skip
  1631. dec noGameScroll ; 5 yes, game finished!!!
  1632.  
  1633. ; treasure found, increase score:
  1634. .incScore:
  1635. lda objectType ; 3
  1636. and #$03 ; 2
  1637. asl ; 2
  1638. asl ; 2
  1639. asl ; 2
  1640. asl ; 2
  1641. adc #$20 ; 2 add at least 2000 points
  1642. sed ; 2
  1643. adc scoreMed ; 3
  1644. sta scoreMed ; 3
  1645. lda #$00 ; 2
  1646. adc scoreHi ; 3
  1647. sta scoreHi ; 3
  1648. cld ; 2
  1649. lda #SOUND_TREASURE ; 2
  1650. sta soundIdx ; 3
  1651. bne .endCollision ; 3
  1652.  
  1653. .noTreasure1:
  1654. lda objectType ; 3
  1655. cmp #ID_FIRE ; 2 fire or cobra?
  1656. bcc .hitLogs ; 2³ no, hit by rolling logs
  1657. .noWallHit:
  1658. jmp KilledHarry ; 3 Harry is killed
  1659.  
  1660. .hitLogs:
  1661. lda climbPos ; 3 Harry at ladder?
  1662. beq .notAtLadder ; 2³ no, skip push
  1663. inc climbPos ; 5 yes, push down Harry
  1664. bne .decScore ; 3
  1665.  
  1666. .notAtLadder:
  1667. lda yPosHarry ; 3
  1668. cmp #JUNGLE_GROUND+1 ; 2
  1669. bcs .endCollision ; 2³
  1670. lda #5 ; 2
  1671. sta patOfsHarry ; 3
  1672. lda objectType ; 3
  1673. and #$04 ; 2
  1674. bne .decScore ; 2³
  1675. lda #NO_MOVE ; 2
  1676. sta joystick ; 3
  1677. .decScore:
  1678. jsr DecScoreLo ; 6
  1679. .endCollision:
  1680. jmp .swingLiana ; 3
  1681.  
  1682. .checkWallHit:
  1683. lda wallPatPtr ; 3
  1684. cmp #<Wall ; 2 wall displayed in scene?
  1685. bne .noWallHit ; 2³ no, skip
  1686. lda #$01 ; 2 yes, make some noise
  1687. sta AUDC1 ; 3
  1688. lda xPosHarry ; 3 determine where Harry hit the wall
  1689. cmp #140 ; 2 right wall from the right?
  1690. bcs .hitFromRight ; 2³ yes, continue
  1691. cmp #13 ; 2 left wall from the left?
  1692. bcc .hitFromLeft ; 2³ yes, continue
  1693. cmp #80 ; 2 left or right wall?
  1694. bcs .hitFromLeft ; 2³
  1695. .hitFromRight:
  1696. inc xPosHarry ; 5 bounce back one pixel and..
  1697. ldx #MOVE_RIGHT ; 2 ..change direction to right
  1698. bne .contWallHit ; 3
  1699.  
  1700. .hitFromLeft:
  1701. dec xPosHarry ; 5 bounce back one pixel and..
  1702. ldx #MOVE_LEFT ; 2 ..change direction to left
  1703. .contWallHit:
  1704. stx oldJoystick ; 3
  1705.  
  1706. ; let the liana swing:
  1707. .swingLiana:
  1708. ; calculate absolute position:
  1709. lda lianaPosLo ; 3
  1710. asl ; 2
  1711. lda lianaPosHi ; 3
  1712. rol ; 2
  1713. bpl .skipNeg ; 2³
  1714. eor #$ff ; 2
  1715. .skipNeg:
  1716. sta hmblAdd ; 3 store absolute value (-> angle of liana)
  1717. ldy #$f0 ; 2 liana moves right
  1718. IF OPTIMIZE
  1719. bcs .skipMoveLeft ; 2³
  1720. FILL_NOP 2
  1721. ELSE
  1722. lda lianaPosHi ; 3
  1723. bmi .skipMoveLeft ; 2³
  1724. ENDIF
  1725. ldy #$10 ; 2 liana moves left
  1726. .skipMoveLeft:
  1727. sty hmblDir ; 3
  1728. sec ; 2
  1729. lda #143 ; 2
  1730. sbc hmblAdd ; 3
  1731. clc ; 2
  1732. adc lianaPosLo ; 3
  1733. sta lianaPosLo ; 3
  1734. bcc .skipAddHi ; 2³
  1735. lda lianaPosHi ; 3
  1736. adc #3 ; 2
  1737. sta lianaPosHi ; 3
  1738. .skipAddHi:
  1739. ; calculate bottom of liana:
  1740. lda hmblAdd ; 3 this are no exactly maths,..
  1741. lsr ; 2 ..but who cares, as long..
  1742. lsr ; 2 ..as it's looking ok :)
  1743. lsr ; 2
  1744. cmp #6-1 ; 2
  1745. bcs .limitBottom ; 2³ limit bottom of liana to 6
  1746. lda #6 ; 2
  1747. .limitBottom:
  1748. adc #4 ; 2
  1749. sta lianaBottom ; 3
  1750.  
  1751. ; check for a new jump:
  1752. lda jumpIndex ; 3 currently jumping?
  1753. beq .notJumping ; 2³ no,
  1754. cmp #3 ; 2 jump just started?
  1755. bcc .saveDir ; 2³ yes, save joystick direction
  1756. .notJumping:
  1757. ora climbPos ; 3 Harry at ladder..
  1758. ora patOfsHarry ; 3 ..or Harry kneeing..
  1759. ora atLiana ; 3 ..or Harry at liana?
  1760. bne .noFire ; 2³ yes, skip new jump
  1761. lda INPT4-$30 ; 3
  1762. and #%10000000 ; 2
  1763. cmp fireButton ; 3
  1764. sta fireButton ; 3
  1765. beq .noFire ; 2³
  1766. tax ; 2
  1767. bmi .noFire ; 2³
  1768. ; start jump:
  1769. lda #1 ; 2 start jumping sequence
  1770. sta jumpIndex ; 3
  1771. IF SCREENSAVER
  1772. sta SS_Delay ; 3
  1773. ELSE
  1774. FILL_NOP 2
  1775. ENDIF
  1776. lda #SOUND_JUMP ; 2
  1777. sta soundIdx ; 3
  1778. dec yPosHarry ; 5 move Harry up
  1779. .saveDir:
  1780. lda joystick ; 3
  1781. sta oldJoystick ; 3
  1782. .noFire:
  1783.  
  1784. ; check for jumping of liana:
  1785. lda atLiana ; 3 Harry at liana?
  1786. beq .skipJumpOff ; 2³ no, skip jump of liana
  1787. lda joystick ; 3
  1788. and #~[$f0|MOVE_DOWN]; 2 joystick down?
  1789. bne .skipJumpOff ; 2³ no, skip
  1790. sta atLiana ; 3 yes, leave "liana mode"
  1791. lda #JUMP_LEN/2 ; 2 start jump down
  1792. sta jumpIndex ; 3
  1793. sta jumpMode ; 3
  1794. ldy #MOVE_RIGHT ; 2
  1795. lda hmblDir ; 3 jump in liana direction
  1796. bmi .jumpRight ; 2³
  1797. ldy #MOVE_LEFT ; 2
  1798. .jumpRight:
  1799. sty oldJoystick ; 3
  1800. .skipJumpOff:
  1801.  
  1802. ; check for starting climbing ladder:
  1803. lda climbPos ; 3 Harry at ladder?
  1804. bne .endStartClimb ; 2³ yes, skip
  1805. lda ladderFlag ; 3 ladder in scene?
  1806. beq .endStartClimb ; 2³ no, skip
  1807. lda xPosHarry ; 3
  1808. sec ; 2
  1809. sbc #68 ; 2
  1810. cmp #15 ; 2 Harry at x-position of ladder (+/-7)?
  1811. bcs .endStartClimb ; 2³ no, skip
  1812. lda yPosHarry ; 3 yes,
  1813. cmp #84 ; 2 Harry near bottom of underground
  1814. bcc .skipClimbUp ; 2³ no, skip
  1815. lda joystick ; 3 yes,
  1816. lsr ; 2 joystick up?
  1817. bcs .skipClimbUp ; 2³ no, skip
  1818. lda #LADDER_BOTTOM-1 ; 2 yes, start climbing up the ladder
  1819. bne .contClimbUp ; 3
  1820.  
  1821. .skipClimbUp:
  1822. lda yPosHarry ; 3
  1823. cmp #JUNGLE_GROUND ; 2 Harry at jungle-ground?
  1824. bne .endStartClimb ; 2³ no, skip
  1825. lda joystick ; 3
  1826. and #~[$f0|MOVE_DOWN]; 2 joystick down?
  1827. bne .endStartClimb ; 2³ no, skip
  1828. lda #LADDER_TOP+1 ; 2 yes, start climbing down the ladder
  1829. .contClimbUp:
  1830. sta climbPos ; 3
  1831. lda #SCREENWIDTH/2-4 ; 2 set x-position of..
  1832. sta xPosHarry ; 3 ..Harry at ladder
  1833. .endStartClimb:
  1834.  
  1835. ; move Harry when swinging at liana:
  1836. lda atLiana ; 3 Harry at liana?
  1837. beq .skipSwingHarry ; 2³ no, skip moving Harry
  1838. ; set x-position of Harry:
  1839. lda hmblAdd ; 3
  1840. lsr ; 2
  1841. lsr ; 2
  1842. clc ; 2
  1843. ldy hmblDir ; 3
  1844. bmi .isNeg ; 2³
  1845. eor #$ff ; 2 negate
  1846. sec ; 2
  1847. .isNeg:
  1848. adc #75 ; 2
  1849. sta xPosHarry ; 3
  1850. ; set y-position of Harry:
  1851. lda #$29 ; 2
  1852. sec ; 2
  1853. sbc lianaBottom ; 3
  1854. sta yPosHarry ; 3
  1855. .skipSwingHarry:
  1856.  
  1857. ; check Harry climbing ladder:
  1858. lda climbPos ; 3 Harry at ladder?
  1859. beq .endClimbLadder ; 2³ no, skip
  1860. lda #0 ; 2
  1861. sta jumpIndex ; 3
  1862. lda frameCnt ; 3
  1863. and #$07 ; 2 climb every 8th frame
  1864. bne .skipAnimClimb ; 2³
  1865. lda joystick ; 3
  1866. lsr ; 2 joystick up?
  1867. bcs .notClimbUp ; 2³ no, skip
  1868. dec climbPos ; 5 yes, climb up
  1869. .notClimbUp:
  1870. lsr ; 2 joystick down?
  1871. bcs .notClimbDown ; 2³ no, skip
  1872. inc climbPos ; 5 yes, climb down
  1873. .notClimbDown:
  1874. lda climbPos ; 3
  1875. cmp #LADDER_TOP ; 2 top reached?
  1876. bcs .skipLadderTop ; 2³ no, skip
  1877. lda #NO_MOVE ; 2
  1878. sta oldJoystick ; 3
  1879. lda #LADDER_TOP ; 2
  1880. .skipLadderTop:
  1881. cmp #LADDER_BOTTOM ; 2 bottom reached?
  1882. bcc .skipLadderBottom; 2³ no, skip
  1883. lda #0 ; 2 remove Harry from ladder
  1884. ldx #ID_STANDING ; 2
  1885. stx patIdHarry ; 3
  1886. ldx #SCREENWIDTH/2+6 ; 2
  1887. stx yPosHarry ; 3
  1888. .skipLadderBottom:
  1889. sta climbPos ; 3
  1890. .skipAnimClimb:
  1891. lda climbPos ; 3 Harry at ladder?
  1892. beq .endClimbLadder ; 2³ no, skip
  1893. asl ; 2 yes, calculate y-position of Harry
  1894. sec ; 2
  1895. rol ; 2
  1896. adc #1 ; 2
  1897. sta yPosHarry ; 3
  1898. .endClimbLadder:
  1899.  
  1900. ; animate running Harry:
  1901. lda atLiana ; 3 Harry at liana?
  1902. bne .endHarryId ; 2³+1 yes, skip running
  1903. lda climbPos ; 3
  1904. cmp #LADDER_TOP+1 ; 2 Harry at ladder bottom?
  1905. bcs .endHarryId ; 2³+1 no, skip running
  1906. lda frameCnt ; 3 animate Harry (every 4th frame)
  1907. and #$03 ; 2
  1908. tax ; 2
  1909. lsr ; 2
  1910. bcs .endHarryId ; 2³+1
  1911. lda oldJoystick ; 3
  1912. ldy jumpIndex ; 3 currently jumping?
  1913. bne .isJumping ; 2³ yes, use old joystick input
  1914. lda joystick ; 3 no, use new joystick input
  1915. .isJumping:
  1916. lsr ; 2
  1917. lsr ; 2
  1918. lsr ; 2 joystick left?
  1919. bcs .skipLeft ; 2³+1 no, skip
  1920. dec xPosHarry ; 5
  1921. ldy #REFLECT ; 2
  1922. sty reflectHarry ; 3
  1923. cpx #0 ; 2 4th frame?
  1924. bne .skipAnimLeft ; 2³ no, skip animation
  1925. dec patIdHarry ; 5
  1926. .skipAnimLeft:
  1927. jmp .endAnimHarry ; 3
  1928.  
  1929. .skipLeft:
  1930. lsr ; 2 joystick right?
  1931. bcs .endAnimHarry ; 2³ no, skip
  1932. inc xPosHarry ; 5
  1933. ldy #NOREFLECT ; 2
  1934. sty reflectHarry ; 3
  1935. cpx #0 ; 2 4th frame?
  1936. bne .endAnimHarry ; 2³ no, skip animation
  1937. dec patIdHarry ; 5
  1938. .endAnimHarry:
  1939.  
  1940. ; goto next scene, if Harry has reached border of current scene:
  1941. ldx #0 ; 2 move one scene
  1942. lda yPosHarry ; 3
  1943. cmp #64 ; 2 Harry at underground?
  1944. bcc .oneScene ; 2³ yes, move one scene
  1945. ldx #2 ; 2 no, move three scenes
  1946. .oneScene:
  1947. lda xPosHarry ; 3
  1948. cmp #XMIN_HARRY ; 2
  1949. bcs .notAtLeft ; 2³
  1950. jsr LeftRandom ; 6
  1951. lda #XMAX_HARRY ; 2
  1952. sta xPosHarry ; 3
  1953. .notAtLeft:
  1954. cmp #XMAX_HARRY+1 ; 2
  1955. bcc .notAtRight ; 2³
  1956. jsr RightRandom ; 6
  1957. lda #XMIN_HARRY ; 2
  1958. sta xPosHarry ; 3
  1959. .notAtRight:
  1960. lda patIdHarry ; 3 illegal animation id?
  1961. bpl .endHarryId ; 2³ no, skip
  1962. lda #ID_RUNNING4 ; 2 yes, start new animation sequence
  1963. sta patIdHarry ; 3
  1964. .endHarryId:
  1965.  
  1966. ; move the scorpion towards harry:
  1967. lda ladderFlag ; 3 ladder in scene?
  1968. bne .noMoveScorpion ; 2³ yes, skip scorpion
  1969. ldx #NOREFLECT ; 2
  1970. lda xPosHarry ; 3
  1971. sec ; 2
  1972. sbc xPosScorpion ; 3
  1973. beq .noMoveScorpion ; 2³
  1974. bcs .rightOfScorpion ; 2³
  1975. ldx #REFLECT ; 2
  1976. .rightOfScorpion:
  1977. lda frameCnt ; 3
  1978. and #$07 ; 2 move scorpion every 8th frame
  1979. bne .endMoveScorpion ; 2³
  1980. inc xPosScorpion ; 5
  1981. bcs .endMoveScorpion ; 2³
  1982. dec xPosScorpion ; 5
  1983. dec xPosScorpion ; 5
  1984. .endMoveScorpion:
  1985. stx reflectScorpion ; 3
  1986. .noMoveScorpion:
  1987.  
  1988. lda climbPos ; 3
  1989. cmp #LADDER_TOP ; 2 Harry at ladder top?
  1990. bne .notAtTop ; 2³ no, skip horizontal move
  1991. lda joystick ; 3
  1992. and #JOY_HORZ ; 2
  1993. cmp #JOY_HORZ ; 2 joystick left or right?
  1994. beq .notAtTop ; 2³ no, skip
  1995. lda joystick ; 3
  1996. sta oldJoystick ; 3
  1997. lda #1 ; 2
  1998. sta jumpIndex ; 3
  1999. lsr ; 2
  2000. sta climbPos ; 3 remove Harry from ladder (=0)
  2001. lda #31 ; 2 ..and remark this state
  2002. sta yPosHarry ; 3
  2003. .notAtTop:
  2004. ldx patIdHarry ; 3
  2005. lda joystick ; 3
  2006. and #JOY_HORZ ; 2
  2007. cmp #JOY_HORZ ; 2 joystick left or right??
  2008. bne .skipStanding ; 2³ yes, skip
  2009. ldx #ID_STANDING ; 2 no, draw standing Harry
  2010. .skipStanding:
  2011. lda yPosHarry ; 3
  2012. cmp #31 ; 2 Harry just jumping of top of ladder?
  2013. bne .notOfTop ; 2³ no, skip
  2014. ldx #3 ; 2 yes, draw diffenret shape
  2015. bne .contPatId ; 3
  2016.  
  2017. .notOfTop:
  2018. cmp #UNDER_GROUND ; 2
  2019. beq .contPatId ; 2³
  2020. cmp #JUNGLE_GROUND ; 2
  2021. beq .contPatId ; 2³
  2022. ldx #ID_KNEEING ; 2
  2023. bcc .contPatId ; 2³
  2024. cmp #60 ; 2
  2025. bcs .contPatId ; 2³
  2026. lda climbPos ; 3 Harry at ladder?
  2027. bne .contPatId ; 2³ yes, skip
  2028. ldx #ID_STANDING ; 2 no, draw standing Harry
  2029. .contPatId:
  2030. lda atLiana ; 3 Harry at liana?
  2031. beq .skipStanding2 ; 2³ no, skip
  2032. ldx #ID_SWINGING ; 2 yes, draw swinging Harry
  2033. .skipStanding2:
  2034. lda climbPos ; 3 Harry at ladder?
  2035. beq .noAnimClimb ; 2³ no, skip
  2036. and #%1 ; 2 yes, animate climbing
  2037. clc ; 2
  2038. adc #ID_CLIMBING ; 2
  2039. tax ; 2
  2040. .noAnimClimb:
  2041. lda patOfsHarry ; 3 Harry hit by logs (kneeing)?
  2042. beq .skipKneeing ; 2³ no, skip
  2043. ldx #ID_KNEEING ; 2 yes, draw kneeing Harry
  2044. .skipKneeing:
  2045. stx patIdHarry ; 3
  2046. lda HarryPtrTab,x ; 4
  2047. sta harryPatPtr ; 3
  2048. lda #>Harry0 ; 2
  2049. sta harryPatPtr+1 ; 3
  2050. lda #<RunColTab ; 2
  2051. cpx #ID_SWINGING+1 ; 2
  2052. bcc .runColors ; 2³
  2053. lda #<ClimbColTab ; 2
  2054. .runColors:
  2055. sta harryColPtr ; 3
  2056.  
  2057. ProcessObjects SUBROUTINE
  2058. lda objectType ; 3
  2059. tax ; 2
  2060. ldy sceneType ; 3
  2061. lda LianaTab,y ; 4
  2062. sta ENABL ; 3
  2063. cpy #TREASURE_SCENE ; 2 treasure in scene?
  2064. bne .noTreasure ; 2³ yes, skip
  2065. jsr CheckTreasures ; 6
  2066. beq .withTreasure ; 2³
  2067. ldx #ID_NOTHING ; 2
  2068. bne .noTreasure ; 3
  2069.  
  2070. .withTreasure:
  2071. lda objectType ; 3
  2072. and #$03 ; 2
  2073. ora #$08 ; 2 treasures only
  2074. tax ; 2
  2075. .noTreasure:
  2076.  
  2077. ; animate some treasures and hazards:
  2078. lda random2 ; 3
  2079. and AnimateTab,x ; 4
  2080. sta temp1 ; 3
  2081. lda ObjectPtrTab,x ; 4
  2082. clc ; 2
  2083. adc temp1 ; 3
  2084. sta objPatPtr ; 3
  2085.  
  2086. lda NuSize1Tab,x ; 4
  2087. sta nusize1 ; 3 save number of object copies
  2088. lda Color1PtrTab,x ; 4
  2089. sta objColPtr ; 3
  2090. ; special processing for crocodiles:
  2091. ldy sceneType ; 3
  2092. lda CrocoTab,y ; 4
  2093. beq .noCroco ; 2³
  2094. lda #<Croco0 ; 2
  2095. bit frameCnt ; 3 open croco jaws?
  2096. bpl .skipClosed ; 2³ yes, skip
  2097. lda #<Croco1 ; 2 no, use other shape
  2098. .skipClosed:
  2099. sta objPatPtr ; 3
  2100. lda #<CrocoColor ; 2
  2101. sta objColPtr ; 3
  2102. lda objectType ; 3
  2103. sta ENABL ; 3
  2104. lda #THREE_COPIES ; 2
  2105. sta nusize1 ; 3
  2106. .noCroco:
  2107. lda noGameScroll ; 3 game running?
  2108. bne .skipLogs ; 2³ no, skip
  2109. lda CrocoTab,y ; 4 crocos in scene?
  2110. bne .skipLogs ; 2³ no, skip
  2111. cpy #TREASURE_SCENE ; 2 treasure in scene?
  2112. beq .skipLogs ; 2³ yes, skip
  2113.  
  2114. ; animate, bounce and move rolling logs:
  2115. lda xPosObject ; 3
  2116. asl ; 2
  2117. asl ; 2
  2118. asl ; 2
  2119. and #$30 ; 2 rolling logs bounce for..
  2120. cmp #$30 ; 2 ..2 pixel every 8th x-position
  2121. and #$10 ; 2
  2122. adc objPatPtr ; 3
  2123. sta objPatPtr ; 3
  2124. lda frameCnt ; 3
  2125. lsr ; 2 move logs every 2nd frame
  2126. bcs .skipLogs ; 2³
  2127. lda objectType ; 3
  2128. cmp #ID_STATIONARY ; 2 rolling logs scene?
  2129. bcs .skipLogs ; 2³ no, skip move
  2130. ldx xPosObject ; 3
  2131. bne .skipResetLogs ; 2³
  2132. ldx #SCREENWIDTH ; 2
  2133. .skipResetLogs:
  2134. dex ; 2
  2135. stx xPosObject ; 3
  2136. .skipLogs:
  2137.  
  2138. ; set score pointers, replace leading zeros with space:
  2139. jsr SetDigitPtrs ; 6
  2140. inx ; 2 x = 0
  2141. .loopSpace:
  2142. lda digitPtr,x ; 4
  2143. bne .exitSpace ; 2³
  2144. lda #<Space ; 2
  2145. sta digitPtr,x ; 4
  2146. inx ; 2
  2147. inx ; 2
  2148. cpx #9 ; 2
  2149. bcc .loopSpace ; 2³
  2150. .exitSpace:
  2151. jmp MainLoop ; 3
  2152.  
  2153.  
  2154. InitGame SUBROUTINE
  2155. ldx #1 ; 2
  2156. stx random2 ; 3
  2157. .loopInitSound:
  2158. lda #$04 ; 2 init both sound channels
  2159. sta AUDV0,x ; 4
  2160. lda #$10 ; 2
  2161. sta AUDF0,x ; 4
  2162. dex ; 2
  2163. bpl .loopInitSound ; 2³
  2164.  
  2165. stx noGameScroll ; 3 game is stopped
  2166. sta xPosHarry ; 3
  2167. asl ; 2
  2168. sta yPosHarry ; 3
  2169. sta scoreMed ; 3 = $20
  2170. IF STARTTIME != $20
  2171. lda #STARTTIME
  2172. ENDIF
  2173. sta timerHi ; 3
  2174.  
  2175. ldx #27 ; 2
  2176. .loopInit:
  2177. lda InitTab,x ; 4
  2178. sta harryPatPtr,x ; 4
  2179. dex ; 2
  2180. bpl .loopInit ; 2³
  2181.  
  2182. lda #FRAMERATE-1 ; 2
  2183. sta timerLo ; 3
  2184. lda #31 ; 2
  2185. sta treasureCnt ; 3
  2186. lda #%10100000 ; 2 3 lives
  2187. sta livesPat ; 3
  2188. lda #RAND_SEED ; 2 set starting scene
  2189. sta random ; 3
  2190. bne ContRandom ; 3
  2191.  
  2192. LeftRandom SUBROUTINE
  2193. ; generate new random scene on the left:
  2194. .loopRandom:
  2195. ; random' = random >> 1 | (bit4^bit5^bit6^bit1) * $80
  2196. lda random ; 3
  2197. asl ; 2
  2198. eor random ; 3
  2199. asl ; 2
  2200. eor random ; 3
  2201. asl ; 2
  2202. asl ; 2
  2203. rol ; 2
  2204. eor random ; 3
  2205. lsr ; 2
  2206. ror random ; 5
  2207. dex ; 2
  2208. bpl .loopRandom ; 2³
  2209. ContRandom:
  2210. lda #124 ; 2 x-position of logs, fire, cobra or treasure
  2211. sta xPosObject ; 3
  2212. lda random ; 3
  2213. lsr ; 2
  2214. lsr ; 2
  2215. lsr ; 2
  2216. pha ; 3
  2217. and #%111 ; 2
  2218. sta sceneType ; 3 bits 3..5
  2219. pla ; 4
  2220. lsr ; 2
  2221. lsr ; 2
  2222. lsr ; 2
  2223. sta treePat ; 3 bits 6 & 7
  2224. lda random ; 3
  2225. and #%111 ; 2
  2226. sta objectType ; 3 bits 0..2
  2227. ldx #SCREENWIDTH/2-4 ; 2 center x-position of scorpion
  2228. ldy #NOLADDER ; 2
  2229. lda sceneType ; 3
  2230. cmp #HOLE3_SCENE+1 ; 2 scene with hole(s)?
  2231. bcs .setFlag ; 2³ no, skip
  2232. ldy #WITHLADDER ; 2 yes, enable ladder
  2233. ldx #17 ; 2 left wall x-position
  2234. lda random ; 3
  2235. asl ; 2 position of the wall? (bit 7)
  2236. bcc .setFlag ; 2³ left, skip
  2237. ldx #136 ; 2 right wall x-position
  2238. .setFlag:
  2239. sty ladderFlag ; 3
  2240. stx xPosScorpion ; 3 also used for wall position
  2241.  
  2242. ldx sceneType ; 3
  2243. lda CrocoTab,x ; 4
  2244. beq .noCrocos ; 2³
  2245. lda #60 ; 2 x-position crocos
  2246. sta xPosObject ; 3
  2247. .noCrocos:
  2248. rts ; 6
  2249.  
  2250.  
  2251. align 256
  2252.  
  2253. Harry0:
  2254. .byte %00000000 ; | |
  2255. .byte %00000000 ; | |
  2256. .byte %00000000 ; | |
  2257. .byte %00000000 ; | |
  2258. .byte %00000000 ; | |
  2259. .byte %00110011 ; | XX XX|
  2260. .byte %01110010 ; | XXX X |
  2261. .byte %11011010 ; |XX XX X |
  2262. .byte %00011110 ; | XXXX |
  2263. .byte %00011100 ; | XXX |
  2264. .byte %00011000 ; | XX |
  2265. .byte %01011000 ; | X XX |
  2266. .byte %01011000 ; | X XX |
  2267. .byte %01111100 ; | XXXXX |
  2268. .byte %00111110 ; | XXXXX |
  2269. .byte %00011010 ; | XX X |
  2270. .byte %00011000 ; | XX |
  2271. .byte %00010000 ; | X |
  2272. .byte %00011000 ; | XX |
  2273. .byte %00011000 ; | XX |
  2274. .byte %00011000 ; | XX |
  2275. .byte %00000000 ; | |
  2276. Harry1:
  2277. .byte %00000000 ; | |
  2278. .byte %10000000 ; |X |
  2279. .byte %10000000 ; |X |
  2280. .byte %11000011 ; |XX XX|
  2281. .byte %01100010 ; | XX X |
  2282. .byte %01100010 ; | XX X |
  2283. .byte %00110110 ; | XX XX |
  2284. .byte %00111110 ; | XXXXX |
  2285. .byte %00011100 ; | XXX |
  2286. .byte %00011000 ; | XX |
  2287. .byte %00011000 ; | XX |
  2288. .byte %00111100 ; | XXXX |
  2289. .byte %00111110 ; | XXXXX |
  2290. .byte %00111010 ; | XXX X |
  2291. .byte %00111000 ; | XXX |
  2292. .byte %00011000 ; | XX |
  2293. .byte %00011000 ; | XX |
  2294. .byte %00010000 ; | X |
  2295. .byte %00011000 ; | XX |
  2296. .byte %00011000 ; | XX |
  2297. .byte %00011000 ; | XX |
  2298. .byte %00000000 ; | |
  2299. Harry2:
  2300. .byte %00010000 ; | X |
  2301. .byte %00100000 ; | X |
  2302. .byte %00100010 ; | X X |
  2303. .byte %00100100 ; | X X |
  2304. .byte %00110100 ; | XX X |
  2305. .byte %00110010 ; | XX X |
  2306. .byte %00010110 ; | X XX |
  2307. .byte %00011110 ; | XXXX |
  2308. .byte %00011100 ; | XXX |
  2309. .byte %00011000 ; | XX |
  2310. .byte %00011000 ; | XX |
  2311. .byte %00011100 ; | XXX |
  2312. .byte %00011100 ; | XXX |
  2313. .byte %00011000 ; | XX |
  2314. .byte %00011000 ; | XX |
  2315. .byte %00011000 ; | XX |
  2316. .byte %00011000 ; | XX |
  2317. .byte %00010000 ; | X |
  2318. .byte %00011000 ; | XX |
  2319. .byte %00011000 ; | XX |
  2320. .byte %00011000 ; | XX |
  2321. .byte %00000000 ; | |
  2322. Harry3:
  2323. .byte %00001100 ; | XX |
  2324. .byte %00001000 ; | X |
  2325. .byte %00101000 ; | X X |
  2326. .byte %00101000 ; | X X |
  2327. .byte %00111110 ; | XXXXX |
  2328. .byte %00001010 ; | X X |
  2329. .byte %00001110 ; | XXX |
  2330. .byte %00011100 ; | XXX |
  2331. .byte %00011000 ; | XX |
  2332. .byte %00011000 ; | XX |
  2333. .byte %00011100 ; | XXX |
  2334. .byte %00011100 ; | XXX |
  2335. .byte %00011000 ; | XX |
  2336. .byte %00011000 ; | XX |
  2337. .byte %00011000 ; | XX |
  2338. .byte %00011000 ; | XX |
  2339. .byte %00011000 ; | XX |
  2340. .byte %00010000 ; | X |
  2341. .byte %00011000 ; | XX |
  2342. .byte %00011000 ; | XX |
  2343. .byte %00011000 ; | XX |
  2344. .byte %00000000 ; | |
  2345. Harry4:
  2346. .byte %00000000 ; | |
  2347. .byte %00000010 ; | X |
  2348. .byte %01000011 ; | X XX|
  2349. .byte %01000100 ; | X X |
  2350. .byte %01110100 ; | XXX X |
  2351. .byte %00010100 ; | X X |
  2352. .byte %00011100 ; | XXX |
  2353. .byte %00011100 ; | XXX |
  2354. .byte %00011000 ; | XX |
  2355. .byte %00011000 ; | XX |
  2356. .byte %00011000 ; | XX |
  2357. .byte %00111100 ; | XXXX |
  2358. .byte %00111110 ; | XXXXX |
  2359. .byte %00111010 ; | XXX X |
  2360. .byte %00111000 ; | XXX |
  2361. .byte %00011000 ; | XX |
  2362. .byte %00011000 ; | XX |
  2363. .byte %00010000 ; | X |
  2364. .byte %00011000 ; | XX |
  2365. .byte %00011000 ; | XX |
  2366. .byte %00011000 ; | XX |
  2367. .byte %00000000 ; | |
  2368. Harry5:
  2369. .byte %00011000 ; | XX |
  2370. .byte %00010000 ; | X |
  2371. .byte %00011100 ; | XXX |
  2372. .byte %00011000 ; | XX |
  2373. .byte %00011000 ; | XX |
  2374. .byte %00011000 ; | XX |
  2375. .byte %00011000 ; | XX |
  2376. .byte %00011000 ; | XX |
  2377. .byte %00011000 ; | XX |
  2378. .byte %00011000 ; | XX |
  2379. .byte %00011000 ; | XX |
  2380. .byte %00011000 ; | XX |
  2381. .byte %00011100 ; | XXX |
  2382. .byte %00011110 ; | XXXX |
  2383. .byte %00011010 ; | XX X |
  2384. .byte %00011000 ; | XX |
  2385. .byte %00011000 ; | XX |
  2386. .byte %00010000 ; | X |
  2387. .byte %00011000 ; | XX |
  2388. .byte %00011000 ; | XX |
  2389. .byte %00011000 ; | XX |
  2390. .byte %00000000 ; | |
  2391. Harry6:
  2392. .byte %00000000 ; | |
  2393. .byte %00000000 ; | |
  2394. .byte %00000000 ; | |
  2395. .byte %00000000 ; | |
  2396. .byte %00000000 ; | |
  2397. .byte %00000000 ; | |
  2398. .byte %01100011 ; | XX XX|
  2399. .byte %11110010 ; |XXXX X |
  2400. .byte %11110110 ; |XXXX XX |
  2401. .byte %11011100 ; |XX XXX |
  2402. .byte %11000000 ; |XX |
  2403. .byte %11000000 ; |XX |
  2404. .byte %11000000 ; |XX |
  2405. .byte %11000000 ; |XX |
  2406. .byte %11000000 ; |XX |
  2407. .byte %11110000 ; |XXXX |
  2408. .byte %11010000 ; |XX X |
  2409. .byte %10010000 ; |X X |
  2410. .byte %11010000 ; |XX X |
  2411. .byte %11010000 ; |XX X |
  2412. .byte %11000000 ; |XX |
  2413. .byte %00000000 ; | |
  2414. Harry7:
  2415. .byte %00110000 ; | XX |
  2416. .byte %00010000 ; | X |
  2417. .byte %00010000 ; | X |
  2418. .byte %00010000 ; | X |
  2419. .byte %00010110 ; | X XX |
  2420. .byte %00010100 ; | X X |
  2421. .byte %00010100 ; | X X |
  2422. .byte %00010110 ; | X XX |
  2423. .byte %00010010 ; | X X |
  2424. .byte %00010110 ; | X XX |
  2425. .byte %00011110 ; | XXXX |
  2426. .byte %00011100 ; | XXX |
  2427. .byte %00011000 ; | XX |
  2428. .byte %00111000 ; | XXX |
  2429. .byte %00111000 ; | XXX |
  2430. .byte %00111100 ; | XXXX |
  2431. .byte %00011110 ; | XXXX |
  2432. .byte %00011010 ; | XX X |
  2433. .byte %00000010 ; | X |
  2434. .byte %00011000 ; | XX |
  2435. .byte %00011000 ; | XX |
  2436. .byte %00011000 ; | XX |
  2437. Harry8:
  2438. .byte %00001100 ; | XX |
  2439. .byte %00001000 ; | X |
  2440. .byte %00001000 ; | X |
  2441. .byte %00001000 ; | X |
  2442. .byte %01101000 ; | XX X |
  2443. .byte %00101000 ; | X X |
  2444. .byte %00101000 ; | X X |
  2445. .byte %01101000 ; | XX X |
  2446. .byte %01001000 ; | X X |
  2447. .byte %01101000 ; | XX X |
  2448. .byte %01111000 ; | XXXX |
  2449. .byte %00111000 ; | XXX |
  2450. .byte %00011000 ; | XX |
  2451. .byte %00011100 ; | XXX |
  2452. .byte %00011100 ; | XXX |
  2453. .byte %00111100 ; | XXXX |
  2454. .byte %01111000 ; | XXXX |
  2455. .byte %01011000 ; | X XX |
  2456. .byte %01000000 ; | X |
  2457. .byte %00011000 ; | XX |
  2458. .byte %00011000 ; | XX |
  2459.  
  2460. BranchTab:
  2461. .byte %00011000 ; | XX |
  2462. .byte %01111110 ; | XXXXXX |
  2463. .byte %11011011 ; |XX XX XX|
  2464. .byte %10011001 ; |X XX X|
  2465. .byte %10011001 ; |X XX X|
  2466. .byte %10011001 ; |X XX X|
  2467. .byte %10011001 ; |X XX X|
  2468. .byte %10011001 ; |X XX X|
  2469. .byte %10011001 ; |X XX X|
  2470. PF1LogTab:
  2471. .byte %10000000 ; |X |
  2472. .byte %00100000 ; | X |
  2473. .byte %00001000 ; | X |
  2474. .byte %00000100 ; | X |
  2475. PF2LogTab:
  2476. .byte %00000001 ; | X|
  2477. .byte %00000100 ; | X |
  2478. .byte %00010000 ; | X |
  2479. .byte %00100000 ; | X |
  2480.  
  2481. ; values for positioning branches (fine and coarse):
  2482. BranchPosLTab:
  2483. .byte $43, $c3, $34, $f4
  2484. BranchPosRTab:
  2485. .byte $f2, $72, $00, $40
  2486.  
  2487. ; pattern for different the jungle grounds:
  2488. PF2PatTab:
  2489. OneHole:
  2490. .byte %01111111 ; | XXXXXXX| one hole
  2491. .byte %01111111 ; | XXXXXXX|
  2492. .byte %01111111 ; | XXXXXXX|
  2493. .byte %11111111 ; |XXXXXXXX|
  2494. .byte %11111111 ; |XXXXXXXX|
  2495. .byte %11111111 ; |XXXXXXXX|
  2496. .byte %11111111 ; |XXXXXXXX|
  2497. .byte %11111111 ; |XXXXXXXX|
  2498. ThreeHoles:
  2499. .byte %01111000 ; | XXXX | three holes
  2500. .byte %01111000 ; | XXXX |
  2501. .byte %01111000 ; | XXXX |
  2502. .byte %11111111 ; |XXXXXXXX|
  2503. .byte %11111111 ; |XXXXXXXX|
  2504. .byte %11111111 ; |XXXXXXXX|
  2505. .byte %11111111 ; |XXXXXXXX|
  2506. .byte %11111111 ; |XXXXXXXX|
  2507. Pit:
  2508. .byte %00000000 ; | | pits
  2509. .byte %00000001 ; | X|
  2510. .byte %00000011 ; | XX|
  2511. .byte %00001111 ; | XXXX|
  2512. .byte %01111111 ; | XXXXXXX|
  2513. .byte %11111111 ; |XXXXXXXX|
  2514. .byte %11111111 ; |XXXXXXXX|
  2515. .byte %11111111 ; |XXXXXXXX|
  2516.  
  2517. .byte %11111111 ; |XXXXXXXX|
  2518. .byte %11111111 ; |XXXXXXXX|
  2519. .byte %11111111 ; |XXXXXXXX|
  2520. .byte %11111111 ; |XXXXXXXX|
  2521. .byte %11111111 ; |XXXXXXXX|
  2522. .byte %11111111 ; |XXXXXXXX|
  2523. .byte %11111111 ; |XXXXXXXX|
  2524. .byte %11111111 ; |XXXXXXXX|
  2525.  
  2526. .byte %11111111 ; |XXXXXXXX|
  2527. .byte %11111111 ; |XXXXXXXX|
  2528. .byte %11111111 ; |XXXXXXXX|
  2529. .byte %11111111 ; |XXXXXXXX|
  2530. .byte %11111111 ; |XXXXXXXX|
  2531. .byte %11111111 ; |XXXXXXXX|
  2532. .byte %11111111 ; |XXXXXXXX|
  2533. .byte %11111111 ; |XXXXXXXX|
  2534.  
  2535. QuickSandSize:
  2536. .byte 0, 4, 8, 16, 28
  2537.  
  2538. ; Harry's colors while climbing:
  2539. ClimbColTab:
  2540. .byte DARK_GREEN
  2541. .byte DARK_GREEN
  2542. .byte DARK_GREEN
  2543. .byte DARK_GREEN
  2544. .byte DARK_GREEN
  2545. .byte DARK_GREEN
  2546. .byte DARK_GREEN
  2547. .byte DARK_GREEN
  2548. .byte DARK_GREEN
  2549. .byte DARK_GREEN
  2550. .byte DARK_GREEN
  2551. .byte DARK_GREEN
  2552. .byte YELLOW_GREEN
  2553. .byte YELLOW_GREEN
  2554. .byte YELLOW_GREEN
  2555. .byte YELLOW_GREEN
  2556. .byte YELLOW_GREEN
  2557. .byte YELLOW_GREEN
  2558. .byte PINK
  2559. .byte PINK
  2560. .byte PINK
  2561. .byte BROWN
  2562. ; Harry's colors while running:
  2563. RunColTab:
  2564. .byte DARK_GREEN
  2565. .byte DARK_GREEN
  2566. .byte DARK_GREEN
  2567. .byte DARK_GREEN
  2568. .byte DARK_GREEN
  2569. .byte DARK_GREEN
  2570. .byte DARK_GREEN
  2571. .byte DARK_GREEN
  2572. .byte DARK_GREEN
  2573. .byte DARK_GREEN
  2574. .byte YELLOW_GREEN
  2575. .byte YELLOW_GREEN
  2576. .byte YELLOW_GREEN
  2577. .byte YELLOW_GREEN
  2578. .byte YELLOW_GREEN
  2579. .byte YELLOW_GREEN
  2580. .byte YELLOW_GREEN
  2581. .byte PINK
  2582. .byte PINK
  2583. .byte PINK
  2584. .byte BROWN
  2585.  
  2586. SoundTab:
  2587. .byte $13, $13, $13, $13, $13, $13, $13, $09, $0b, $0b, $0b, $0b, $0b, $0b, $0b, $0b
  2588. .byte $0b, $0b, $0b, $0b, $09, $0b, $09, $0b, $0b, $0b, $0b, $0b, $0b, $0b, $8b, $06
  2589. .byte $04, $03, $02, $84
  2590. .byte $13, $13, $0e, $0b, $09, $09, $09, $0b, $09, $09, $09, $89
  2591. .byte $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1a, $1a, $19, $19, $19, $19, $19
  2592. .byte $19, $1d, $1d, $1d, $1d, $1d, $14, $15, $14, $15, $14, $15, $14, $15, $14, $15
  2593. .byte $14, $95
  2594. .byte $18, $19, $1a, $1b, $1c, $1d, $1e, $9f
  2595.  
  2596. QuickSandTab:
  2597. .byte %00000000 ; | |
  2598. .byte %00001111 ; | XXXX|
  2599. .byte %00001111 ; | XXXX|
  2600. .byte %00000000 ; | |
  2601. .byte %00001111 ; | XXXX| next byte (0) overlaps
  2602.  
  2603. LadderTab:
  2604. .byte BLACKPIT|DISABLE, BLACKPIT|DISABLE, BLACKPIT|ENABLE, BLUEPIT|ENABLE
  2605. .byte BLUEPIT |DISABLE, BLACKPIT|DISABLE, BLACKPIT|ENABLE, BLUEPIT|ENABLE
  2606. .byte DISABLE, DISABLE, ENABLE, ENABLE ; some bytes overlap
  2607. LianaTab:
  2608. .byte DISABLE, DISABLE, ENABLE, ENABLE, ENABLE, DISABLE, ENABLE, DISABLE
  2609.  
  2610. CheckTreasures:
  2611. lda random ; 3
  2612. rol ; 2
  2613. rol ; 2
  2614. rol ; 2
  2615. and #$03 ; 2
  2616. tax ; 2 bits 7 & 8
  2617. ldy objectType ; 3
  2618. lda TreasureMask,y ; 4
  2619. tay ; 2
  2620. and treasureBits,x ; 4
  2621. php ; 3
  2622. tya ; 2
  2623. ora treasureBits,x ; 4
  2624. plp ; 4
  2625. rts ; 6
  2626.  
  2627. SetDigitPtrs SUBROUTINE
  2628. ldx #2 ; 2 -> 8
  2629. .loopSet:
  2630. txa ; 2
  2631. asl ; 2
  2632. asl ; 2
  2633. tay ; 2
  2634. jsr BCD2DigitPtrs ; 6
  2635. dex ; 2
  2636. bpl .loopSet ; 2³
  2637. rts ; 6
  2638.  
  2639. KilledHarry SUBROUTINE
  2640. lda #SOUND_DEAD ; 2
  2641. sta soundIdx ; 3
  2642. lda #$84 ; 2 start copyright..
  2643. sta noGameScroll ; 3 ..animation
  2644. jmp ProcessObjects ; 3
  2645.  
  2646. ; the bounds of the holes and pits where Harry falls down:
  2647. HoleBoundsTab:
  2648. .byte 72, 79, 0, 0, 0, 0, 0, 0 ; single hole
  2649. .byte 44, 55, 72, 79, 96,107, 0, 0 ; triple hole
  2650. .byte 44,107, 0, 0, 0, 0, 0, 0 ; pit
  2651. .byte 44, 55, 64, 71, 80, 87, 96,107 ; closed croco jaws
  2652. .byte 44, 61, 64, 77, 80, 93, 96,107 ; open croco jaws
  2653.  
  2654. align 256
  2655.  
  2656. Log0:
  2657. .byte %00000000; | |
  2658. .byte %00011000; | XX |
  2659. .byte %00100100; | X X |
  2660. .byte %01011010; | X XX X |
  2661. .byte %01011010; | X XX X |
  2662. .byte %01011010; | X XX X |
  2663. .byte %01100110; | XX XX |
  2664. .byte %01111110; | XXXXXX |
  2665. .byte %01011110; | X XXXX |
  2666. .byte %01110110; | XXX XX |
  2667. .byte %01111110; | XXXXXX |
  2668. .byte %01011110; | X XXXX |
  2669. .byte %01110110; | XXX XX |
  2670. .byte %00111100; | XXXX |
  2671. .byte %00011000; | XX |
  2672. .byte %00000000; | |
  2673. Log1:
  2674. .byte %00000000; | |
  2675. .byte %00011000; | XX |
  2676. .byte %00100100; | X X |
  2677. .byte %01011010; | X XX X |
  2678. .byte %01011010; | X XX X |
  2679. .byte %01011010; | X XX X |
  2680. .byte %01100110; | XX XX |
  2681. .byte %01111110; | XXXXXX |
  2682. .byte %01111010; | XXXX X |
  2683. .byte %01101110; | XX XXX |
  2684. .byte %01111110; | XXXXXX |
  2685. .byte %01111010; | XXXX X |
  2686. .byte %01101110; | XX XXX |
  2687. .byte %00111100; | XXXX |
  2688. .byte %00011000; | XX |
  2689. .byte %00000000; | |
  2690. Fire0:
  2691. .byte %00000000; | |
  2692. .byte %11000011; |XX XX|
  2693. .byte %11100111; |XXX XXX|
  2694. .byte %01111110; | XXXXXX |
  2695. .byte %00111100; | XXXX |
  2696. .byte %00011000; | XX |
  2697. .byte %00111100; | XXXX |
  2698. .byte %01111100; | XXXXX |
  2699. .byte %01111100; | XXXXX |
  2700. .byte %01111000; | XXXX |
  2701. .byte %00111000; | XXX |
  2702. .byte %00111000; | XXX |
  2703. .byte %00110000; | XX |
  2704. .byte %00110000; | XX |
  2705. .byte %00010000; | X |
  2706. .byte %00010000; | X |
  2707. Fire1:
  2708. .byte %00000000; | |
  2709. .byte %11000011; |XX XX|
  2710. .byte %11100111; |XXX XXX|
  2711. .byte %01111110; | XXXXXX |
  2712. .byte %00111100; | XXXX |
  2713. .byte %00011000; | XX |
  2714. .byte %00111100; | XXXX |
  2715. .byte %00111110; | XXXXX |
  2716. .byte %00111110; | XXXXX |
  2717. .byte %00011110; | XXXX |
  2718. .byte %00011100; | XXX |
  2719. .byte %00011100; | XXX |
  2720. .byte %00001100; | XX |
  2721. .byte %00001100; | XX |
  2722. .byte %00001000; | X |
  2723. .byte %00001000; | X |
  2724. Cobra0:
  2725. .byte %00000000; | |
  2726. .byte %11111110; |XXXXXXX |
  2727. .byte %11111001; |XXXXX X|
  2728. .byte %11111001; |XXXXX X|
  2729. .byte %11111001; |XXXXX X|
  2730. .byte %11111001; |XXXXX X|
  2731. .byte %01100000; | XX |
  2732. .byte %00010000; | X |
  2733. .byte %00001000; | X |
  2734. .byte %00001100; | XX |
  2735. .byte %00001100; | XX |
  2736. .byte %00001000; | X |
  2737. .byte %00111000; | XXX |
  2738. .byte %00110000; | XX |
  2739. .byte %01000000; | X |
  2740. .byte %00000000; | |
  2741. Cobra1:
  2742. .byte %00000000; | |
  2743. .byte %11111110; |XXXXXXX |
  2744. .byte %11111001; |XXXXX X|
  2745. .byte %11111001; |XXXXX X|
  2746. .byte %11111010; |XXXXX X |
  2747. .byte %11111010; |XXXXX X |
  2748. .byte %01100000; | XX |
  2749. .byte %00010000; | X |
  2750. .byte %00001000; | X |
  2751. .byte %00001100; | XX |
  2752. .byte %00001100; | XX |
  2753. .byte %00001000; | X |
  2754. .byte %00111000; | XXX |
  2755. .byte %00110000; | XX |
  2756. .byte %10000000; |X |
  2757. .byte %00000000; | |
  2758. Croco0:
  2759. .byte %00000000; | |
  2760. .byte %00000000; | |
  2761. .byte %00000000; | |
  2762. .byte %00000000; | |
  2763. .byte %00000000; | |
  2764. .byte %11111111; |XXXXXXXX|
  2765. .byte %10101011; |X X X XX|
  2766. .byte %00000011; | XX|
  2767. .byte %00000011; | XX|
  2768. .byte %00001011; | X XX|
  2769. .byte %00101110; | X XXX |
  2770. .byte %10111010; |X XXX X |
  2771. .byte %11100000; |XXX |
  2772. .byte %10000000; |X |
  2773. .byte %00000000; | |
  2774. .byte %00000000; | |
  2775. Croco1:
  2776. .byte %00000000; | |
  2777. .byte %00000000; | |
  2778. .byte %00000000; | |
  2779. .byte %00000000; | |
  2780. .byte %00000000; | |
  2781. .byte %11111111; |XXXXXXXX|
  2782. .byte %10101011; |X X X XX|
  2783. .byte %01010101; | X X X X|
  2784. .byte %11111111; |XXXXXXXX|
  2785. .byte %00000110; | XX |
  2786. .byte %00000100; | X |
  2787. .byte %00000000; | |
  2788. .byte %00000000; | |
  2789. .byte %00000000; | |
  2790. .byte %00000000; | |
  2791. .byte %00000000; | |
  2792. MoneyBag:
  2793. .byte %00000000; | |
  2794. .byte %00111110; | XXXXX |
  2795. .byte %01110111; | XXX XXX|
  2796. .byte %01110111; | XXX XXX|
  2797. .byte %01100011; | XX XX|
  2798. .byte %01111011; | XXXX XX|
  2799. .byte %01100011; | XX XX|
  2800. .byte %01101111; | XX XXXX|
  2801. .byte %01100011; | XX XX|
  2802. .byte %00110110; | XX XX |
  2803. .byte %00110110; | XX XX |
  2804. .byte %00011100; | XXX |
  2805. .byte %00001000; | X |
  2806. .byte %00011100; | XXX |
  2807. .byte %00110110; | XX XX |
  2808. .byte %00000000; | |
  2809. Scorpion0:
  2810. .byte %10000101; |X X X|
  2811. .byte %00110010; | XX X |
  2812. .byte %00111101; | XXXX X|
  2813. .byte %01111000; | XXXX |
  2814. .byte %11111000; |XXXXX |
  2815. .byte %11000110; |XX XX |
  2816. .byte %10000010; |X X |
  2817. .byte %10010000; |X X |
  2818. .byte %10001000; |X X |
  2819. .byte %11011000; |XX XX |
  2820. .byte %01110000; | XXX |
  2821. .byte %00000000; | |
  2822. .byte %00000000; | |
  2823. .byte %00000000; | |
  2824. .byte %00000000; | |
  2825. .byte %00000000; | |
  2826. Scorpion1:
  2827. .byte %01001001; | X X X|
  2828. .byte %00110011; | XX XX|
  2829. .byte %00111100; | XXXX |
  2830. .byte %01111000; | XXXX |
  2831. .byte %11111010; |XXXXX X |
  2832. .byte %11000100; |XX X |
  2833. .byte %10010010; |X X X |
  2834. .byte %10001000; |X X |
  2835. .byte %11011000; |XX XX |
  2836. .byte %01110000; | XXX |
  2837. .byte %00000000; | |
  2838. .byte %00000000; | |
  2839. .byte %00000000; | |
  2840. .byte %00000000; | |
  2841. .byte %00000000; | |
  2842. .byte %00000000; | |
  2843. Wall:
  2844. .byte %11111110; |XXXXXXX |
  2845. .byte %10111010; |X XXX X |
  2846. .byte %10111010; |X XXX X |
  2847. .byte %10111010; |X XXX X |
  2848. .byte %11111110; |XXXXXXX |
  2849. .byte %11101110; |XXX XXX |
  2850. .byte %11101110; |XXX XXX |
  2851. .byte %11101110; |XXX XXX |
  2852. .byte %11111110; |XXXXXXX |
  2853. .byte %10111010; |X XXX X |
  2854. .byte %10111010; |X XXX X |
  2855. .byte %10111010; |X XXX X |
  2856. .byte %11111110; |XXXXXXX |
  2857. .byte %11101110; |XXX XXX |
  2858. .byte %11101110; |XXX XXX |
  2859. .byte %11101110; |XXX XXX |
  2860. Bar0:
  2861. .byte %00000000; | |
  2862. .byte %11111000; |XXXXX |
  2863. .byte %11111100; |XXXXXX |
  2864. .byte %11111110; |XXXXXXX |
  2865. .byte %11111110; |XXXXXXX |
  2866. .byte %01111110; | XXXXXX |
  2867. .byte %00111110; | XXXXX |
  2868. .byte %00000000; | |
  2869. .byte %00010000; | X |
  2870. .byte %00000000; | |
  2871. .byte %01010100; | X X X |
  2872. .byte %00000000; | |
  2873. .byte %10010010; |X X X |
  2874. .byte %00000000; | |
  2875. .byte %00010000; | X |
  2876. .byte %00000000; | |
  2877. Bar1:
  2878. .byte %00000000; | |
  2879. .byte %11111000; |XXXXX |
  2880. .byte %11111100; |XXXXXX |
  2881. .byte %11111110; |XXXXXXX |
  2882. .byte %11111110; |XXXXXXX |
  2883. .byte %01111110; | XXXXXX |
  2884. .byte %00111110; | XXXXX |
  2885. .byte %00000000; | |
  2886. .byte %00000000; | |
  2887. .byte %00101000; | X X |
  2888. .byte %00000000; | |
  2889. .byte %01010100; | X X X |
  2890. .byte %00000000; | |
  2891. .byte %00010000; | X |
  2892. .byte %00000000; | |
  2893. .byte %00000000; | |
  2894. Ring:
  2895. .byte %00000000; | |
  2896. .byte %00000000; | |
  2897. .byte %00111000; | XXX |
  2898. .byte %01101100; | XX XX |
  2899. .byte %01000100; | X X |
  2900. .byte %01000100; | X X |
  2901. .byte %01000100; | X X |
  2902. .byte %01101100; | XX XX |
  2903. .byte %00111000; | XXX |
  2904. .byte %00010000; | X |
  2905. .byte %00111000; | XXX |
  2906. .byte %01111100; | XXXXX |
  2907. .byte %00111000; | XXX |
  2908. .byte %00000000; | |
  2909. .byte %00000000; | |
  2910. .byte %00000000; | |
  2911. Nothing:
  2912. .byte %00000000; | |
  2913. .byte %00000000; | |
  2914. .byte %00000000; | |
  2915. .byte %00000000; | |
  2916. .byte %00000000; | |
  2917. .byte %00000000; | |
  2918. .byte %00000000; | |
  2919. .byte %00000000; | |
  2920. .byte %00000000; | |
  2921. .byte %00000000; | |
  2922. .byte %00000000; | |
  2923. .byte %00000000; | |
  2924. .byte %00000000; | |
  2925. .byte %00000000; | |
  2926. .byte %00000000; | |
  2927. .byte %00000000; | |
  2928.  
  2929. align 256
  2930.  
  2931. IF OPTIMIZE
  2932. LogColor:
  2933. .byte BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
  2934. .byte BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
  2935. FILL_NOP 1 ; JTZ: the logs are only 15 lines tall
  2936. .pcFire:
  2937. FireColor = .pcFire - 1
  2938. .byte BROWN-2, BROWN-2, BROWN-2, BROWN-2, ORANGE, ORANGE, ORANGE
  2939. .byte $2e, $2e, $2e, $2e, $2e, $2e, $2e
  2940. FILL_NOP 2 ; JTZ: the fire is only 14 lines tall
  2941. .pcCobra:
  2942. CobraColor = .pcCobra-1
  2943. .byte BLACK, GREY-2, BLACK, GREY-2, BLACK, BLACK, BLACK
  2944. .byte BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, DARK_RED
  2945. FILL_NOP 2 ; JTZ: the cobra is only 14 bytes tall
  2946. .pcCroco:
  2947. CrocoColor = .pcCroco-5
  2948. .byte DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2
  2949. .byte DARK_GREEN-2
  2950. FILL_NOP 7 ; JTZ: the crocos are only 9 lines tall
  2951. .pcMoneyBag:
  2952. MoneyBagColor = .pcMoneyBag-1
  2953. .byte GREY-2, GREY-2, GREY-2, GREY-2, GREY-2, GREY-2, GREY-2
  2954. .byte GREY-2, GREY-2, GREY-2, GREY-2, BROWN, GREY-2, GREY-2
  2955. FILL_NOP 2 ; JTZ: the moneybag is only 9 lines tall
  2956. ScorpionColor:
  2957. .byte WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE
  2958. .byte WHITE, WHITE, WHITE
  2959. FILL_NOP 5 ; JTZ: the scorpion is only 11 lines tall
  2960. ELSE
  2961. LogColor:
  2962. .byte BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
  2963. .byte BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
  2964. FireColor:
  2965. .byte BROWN-2, BROWN-2, BROWN-2, BROWN-2, BROWN-2, ORANGE, ORANGE, ORANGE
  2966. .byte $2e, $2e, $2e, $2e, $2e, $2e, $2e, $2e
  2967. CobraColor:
  2968. .byte BLACK, BLACK, GREY-2, BLACK, GREY-2, BLACK, BLACK, BLACK
  2969. .byte BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, DARK_RED, DARK_RED
  2970. CrocoColor:
  2971. .byte DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2
  2972. .byte DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2, DARK_GREEN-2
  2973. MoneyBagColor:
  2974. .byte GREY-2, GREY-2, GREY-2, GREY-2, GREY-2, GREY-2, GREY-2, GREY-2
  2975. .byte GREY-2, GREY-2, GREY-2, GREY-2, BROWN, GREY-2, GREY-2, GREY-2
  2976. ScorpionColor:
  2977. .byte WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE
  2978. .byte WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE
  2979. ENDIF
  2980. WallColor:
  2981. .byte GREY, DARK_RED, DARK_RED, DARK_RED, GREY, DARK_RED, DARK_RED, DARK_RED
  2982. .byte GREY, DARK_RED, DARK_RED, DARK_RED, GREY, DARK_RED
  2983. RingColor:
  2984. .byte DARK_RED, DARK_RED
  2985. GoldBarColor:
  2986. .byte YELLOW, YELLOW, YELLOW, YELLOW, YELLOW, YELLOW, YELLOW, YELLOW
  2987. .byte WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE
  2988. .byte WHITE
  2989. SilverBarColor:
  2990. .byte GREY, GREY, GREY, GREY, GREY, GREY, GREY, WHITE
  2991. .byte WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE
  2992.  
  2993. InitTab:
  2994. .word Harry5 ; harryPatPtr
  2995. .word Log0 ; objPatPtr
  2996. .word RunColTab ; harryColPtr
  2997. .word LogColor ; objColPtr
  2998. .word Wall
  2999. .word WallColor
  3000. .word Wall
  3001. .word WallColor
  3002. .word Space
  3003. .word Space
  3004. .word Two
  3005. .word Zero
  3006. .word Zero
  3007. .word Zero
  3008.  
  3009.  
  3010. RightRandom SUBROUTINE
  3011. ; generate new random scene on the right:
  3012. .loopRandom:
  3013. ; random' = random << 1 | (bit3^bit4^bit5^bit7)
  3014. lda random ; 3
  3015. asl ; 2
  3016. eor random ; 3
  3017. asl ; 2
  3018. eor random ; 3
  3019. asl ; 2
  3020. asl ; 2
  3021. eor random ; 3
  3022. asl ; 2
  3023. rol random ; 5
  3024. dex ; 2
  3025. bpl .loopRandom ; 2³
  3026. jmp ContRandom ; 3
  3027.  
  3028. ; low pointer to harry data:
  3029. HarryPtrTab:
  3030. .byte <Harry0
  3031. .byte <Harry1
  3032. .byte <Harry2
  3033. .byte <Harry3
  3034. .byte <Harry4
  3035. .byte <Harry5
  3036. .byte <Harry6
  3037. .byte <Harry7
  3038. .byte <Harry8
  3039.  
  3040. JumpTab:
  3041. ; increase/decrease y-position of jumping Harry:
  3042. .byte 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1
  3043. .byte -1, 0, 0, 0,-1, 0, 0,-1, 0,-1,-1,-1,-1,-1,-1,-1
  3044.  
  3045. ObjectPtrTab:
  3046. .byte <Log0
  3047. .byte <Log0
  3048. .byte <Log0
  3049. .byte <Log0
  3050. .byte <Log0
  3051. .byte <Log0
  3052. .byte <Fire0
  3053. .byte <Cobra0
  3054. .byte <MoneyBag
  3055. .byte <Bar0 ; silver bar
  3056. .byte <Bar0 ; gold bar
  3057. .byte <Ring
  3058. .byte <Nothing
  3059.  
  3060. TreasureMask:
  3061. .byte %10000000
  3062. .byte %01000000
  3063. .byte %00100000
  3064. .byte %00010000
  3065. .byte %00001000
  3066. .byte %00000100
  3067. .byte %00000010
  3068. .byte %00000001
  3069.  
  3070. align 256
  3071.  
  3072. Zero:
  3073. .byte %00111100; | XXXX |
  3074. .byte %01100110; | XX XX |
  3075. .byte %01100110; | XX XX |
  3076. .byte %01100110; | XX XX |
  3077. .byte %01100110; | XX XX |
  3078. .byte %01100110; | XX XX |
  3079. .byte %01100110; | XX XX |
  3080. .byte %00111100; | XXXX |
  3081. One:
  3082. .byte %00111100; | XXXX |
  3083. .byte %00011000; | XX |
  3084. .byte %00011000; | XX |
  3085. .byte %00011000; | XX |
  3086. .byte %00011000; | XX |
  3087. .byte %00011000; | XX |
  3088. .byte %00111000; | XXX |
  3089. .byte %00011000; | XX |
  3090. Two:
  3091. .byte %01111110; | XXXXXX |
  3092. .byte %01100000; | XX |
  3093. .byte %01100000; | XX |
  3094. .byte %00111100; | XXXX |
  3095. .byte %00000110; | XX |
  3096. .byte %00000110; | XX |
  3097. .byte %01000110; | X XX |
  3098. .byte %00111100; | XXXX |
  3099. Three:
  3100. .byte %00111100; | XXXX |
  3101. .byte %01000110; | X XX |
  3102. .byte %00000110; | XX |
  3103. .byte %00001100; | XX |
  3104. .byte %00001100; | XX |
  3105. .byte %00000110; | XX |
  3106. .byte %01000110; | X XX |
  3107. .byte %00111100; | XXXX |
  3108. Four:
  3109. .byte %00001100; | XX |
  3110. .byte %00001100; | XX |
  3111. .byte %00001100; | XX |
  3112. .byte %01111110; | XXXXXX |
  3113. .byte %01001100; | X XX |
  3114. .byte %00101100; | X XX |
  3115. .byte %00011100; | XXX |
  3116. .byte %00001100; | XX |
  3117. Five
  3118. .byte %01111100; | XXXXX |
  3119. .byte %01000110; | X XX |
  3120. .byte %00000110; | XX |
  3121. .byte %00000110; | XX |
  3122. .byte %01111100; | XXXXX |
  3123. .byte %01100000; | XX |
  3124. .byte %01100000; | XX |
  3125. .byte %01111110; | XXXXXX |
  3126. Six:
  3127. .byte %00111100; | XXXX |
  3128. .byte %01100110; | XX XX |
  3129. .byte %01100110; | XX XX |
  3130. .byte %01100110; | XX XX |
  3131. .byte %01111100; | XXXXX |
  3132. .byte %01100000; | XX |
  3133. .byte %01100010; | XX X |
  3134. .byte %00111100; | XXXX |
  3135. Seven:
  3136. .byte %00011000; | XX |
  3137. .byte %00011000; | XX |
  3138. .byte %00011000; | XX |
  3139. .byte %00011000; | XX |
  3140. .byte %00001100; | XX |
  3141. .byte %00000110; | XX |
  3142. .byte %01000010; | X X |
  3143. .byte %01111110; | XXXXXX |
  3144. Eight:
  3145. .byte %00111100; | XXXX |
  3146. .byte %01100110; | XX XX |
  3147. .byte %01100110; | XX XX |
  3148. .byte %00111100; | XXXX |
  3149. .byte %00111100; | XXXX |
  3150. .byte %01100110; | XX XX |
  3151. .byte %01100110; | XX XX |
  3152. .byte %00111100; | XXXX |
  3153. Nine:
  3154. .byte %00111100; | XXXX |
  3155. .byte %01000110; | X XX |
  3156. .byte %00000110; | XX |
  3157. .byte %00111110; | XXXXX |
  3158. .byte %01100110; | XX XX |
  3159. .byte %01100110; | XX XX |
  3160. .byte %01100110; | XX XX |
  3161. .byte %00111100; | XXXX |
  3162. DoublePoint:
  3163. .byte %00000000; | |
  3164. .byte %00011000; | XX |
  3165. .byte %00011000; | XX |
  3166. .byte %00000000; | |
  3167. .byte %00000000; | |
  3168. .byte %00011000; | XX |
  3169. .byte %00011000; | XX |
  3170. .byte %00000000; | |
  3171. Space:
  3172. .byte %00000000; | |
  3173. .byte %00000000; | |
  3174. .byte %00000000; | |
  3175. .byte %00000000; | |
  3176. .byte %00000000; | |
  3177. .byte %00000000; | |
  3178. .byte %00000000; | |
  3179. .byte %00000000; | |
  3180. CopyRight0:
  3181. .byte %00000000; | |
  3182. .byte %00000000; | |
  3183. .byte %11110111; |XXXX XXX|
  3184. .byte %10010101; |X X X X|
  3185. .byte %10000111; |X XXX|
  3186. .byte %10000000; |X |
  3187. .byte %10010000; |X X |
  3188. .byte %11110000; |XXXX |
  3189. .byte %10101101; |X X XX X|
  3190. .byte %10101001; |X X X X|
  3191. .byte %11101001; |XXX X X|
  3192. .byte %10101001; |X X X X|
  3193. .byte %11101101; |XXX XX X|
  3194. .byte %01000001; | X X|
  3195. .byte %00001111; | XXXX|
  3196. .byte %00000000; | |
  3197. CopyRight1:
  3198. .byte %01000111; | X XXX|
  3199. .byte %01000001; | X X|
  3200. .byte %01110111; | XXX XXX|
  3201. .byte %01010101; | X X X X|
  3202. .byte %01110101; | XXX X X|
  3203. .byte %00000000; | |
  3204. .byte %00000000; | |
  3205. .byte %00000000; | |
  3206. .byte %01010000; | X X |
  3207. .byte %01011000; | X XX |
  3208. .byte %01011100; | X XXX |
  3209. .byte %01010110; | X X XX |
  3210. .byte %01010011; | X X XX|
  3211. .byte %00010001; | X X|
  3212. .byte %11110000; |XXXX |
  3213. .byte %00000000; | |
  3214. CopyRight2:
  3215. .byte %00000011; | XX|
  3216. .byte %00000000; | |
  3217. .byte %01001011; | X X XX|
  3218. .byte %01001010; | X X X |
  3219. .byte %01101011; | XX X XX|
  3220. .byte %00000000; | |
  3221. .byte %00001000; | X |
  3222. .byte %00000000; | |
  3223. .byte %10111010; |X XXX X |
  3224. .byte %10001010; |X X X |
  3225. .byte %10111010; |X XXX X |
  3226. .byte %10100010; |X X X |
  3227. .byte %00111010; | XXX X |
  3228. .byte %10000000; |X |
  3229. .byte %11111110; |XXXXXXX |
  3230. .byte %00000000; | |
  3231. CopyRight3:
  3232. .byte %10000000; |X |
  3233. .byte %10000000; |X |
  3234. .byte %10101010; |X X X X |
  3235. .byte %10101010; |X X X X |
  3236. .byte %10111010; |X XXX X |
  3237. .byte %00100010; | X X |
  3238. .byte %00100111; | X XXX|
  3239. .byte %00000010; | X |
  3240. .byte %11101001; |XXX X X|
  3241. .byte %10101011; |X X X XX|
  3242. .byte %10101111; |X X XXXX|
  3243. .byte %10101101; |X X XX X|
  3244. .byte %11101001; |XXX X X|
  3245. .byte %00000000; | |
  3246. .byte %00000000; | |
  3247. .byte %00000000; | |
  3248. CopyRight4:
  3249. .byte %00000000; | |
  3250. .byte %00000000; | |
  3251. .byte %00010001; | X X|
  3252. .byte %00010001; | X X|
  3253. .byte %00010111; | X XXX|
  3254. .byte %00010101; | X X X|
  3255. .byte %00010111; | X XXX|
  3256. .byte %00000000; | |
  3257. .byte %00000000; | |
  3258. .byte %00000000; | |
  3259. .byte %00000000; | |
  3260. .byte %00000000; | |
  3261. .byte %00000000; | |
  3262. .byte %00000000; | |
  3263. .byte %00000000; | |
  3264. .byte %00000000; | |
  3265. CopyRight5:
  3266. .byte %00000000; | |
  3267. .byte %00000000; | |
  3268. .byte %01110111; | XXX XXX|
  3269. .byte %01010100; | X X X |
  3270. .byte %01110111; | XXX XXX|
  3271. .byte %01010001; | X X X|
  3272. .byte %01110111; | XXX XXX|
  3273. .byte %00000000; | |
  3274.  
  3275. ColorTab:
  3276. .byte $0C ; score and copyright color
  3277. .byte $0C ; unused
  3278. .byte DARK_GREEN ; leaves color
  3279. .byte GREEN ; jungle color
  3280. .byte BLACK ; hole, background and tar pit color
  3281. .byte BROWN-2 ; branches and log color
  3282. .byte BROWN+2 ; underground color
  3283. .byte YELLOW-6 ; ground color
  3284. .byte BLUE ; swamp color
  3285.  
  3286. Color1PtrTab:
  3287. .byte <LogColor
  3288. .byte <LogColor
  3289. .byte <LogColor
  3290. .byte <LogColor
  3291. .byte <LogColor
  3292. .byte <LogColor
  3293. .byte <FireColor
  3294. .byte <CobraColor
  3295. .byte <MoneyBagColor
  3296. .byte <SilverBarColor
  3297. .byte <GoldBarColor+1
  3298. .byte <RingColor
  3299.  
  3300. NuSize1Tab:
  3301. .byte ONE_COPY ; one rolling logs
  3302. .byte TWO_COPIES ; two rolling logs
  3303. .byte TWO_WIDE_COPIES ; two wide rolling logs
  3304. .byte THREE_MED_COPIES ; three rolling logs
  3305. .byte ONE_COPY ; one stationary log
  3306. .byte THREE_MED_COPIES ; three stationary logs
  3307. .byte ONE_COPY ; fire
  3308. .byte ONE_COPY ; cobra
  3309. .byte ONE_COPY ; money bag
  3310. .byte ONE_COPY ; silver bar
  3311. .byte ONE_COPY ; gold bar
  3312. .byte ONE_COPY ; ring
  3313.  
  3314. ; used to animate some of the hazards:
  3315. AnimateTab:
  3316. .byte 0 ; logs
  3317. .byte 0
  3318. .byte 0
  3319. .byte 0
  3320. .byte 0
  3321. .byte 0
  3322. .byte OBJECT_H ; fire
  3323. .byte OBJECT_H ; cobra
  3324. .byte 0 ; money bag
  3325. .byte OBJECT_H ; silver bar
  3326. .byte OBJECT_H ; gold bar
  3327. .byte 0 ; ring
  3328. .byte 0 ; nothing (treasure collected)
  3329.  
  3330. GroundTypeTab:
  3331. .byte <[OneHole - PF2PatTab] ; one hole
  3332. .byte <[ThreeHoles - PF2PatTab] ; three holes
  3333. .byte <[Pit - PF2PatTab] ; tar pit
  3334. .byte <[Pit - PF2PatTab] ; swamp
  3335. .byte <[Pit - PF2PatTab] ; swamp with crocodiles
  3336. .byte $80 ; black quicksand with treasure
  3337. .byte $80 ; black quicksand
  3338. .byte $80 ; blue quicksand
  3339.  
  3340. ; crocodile in scene?
  3341. CrocoTab:
  3342. .ds CROCO_SCENE, 0
  3343. .byte 1
  3344. .ds 7-CROCO_SCENE, 0
  3345.  
  3346.  
  3347. org $fffc
  3348.  
  3349. .word $f000
  3350. .word 0
Advertisement
Add Comment
Please, Sign In to add comment