Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

917 Zeilen
22KB

  1. ; ===========================================================================
  2. ; BUZZ RUN - a one-button flying game for the Commodore 64
  3. ; Guide a bumblebee through the gaps in an endless row of hedge pillars.
  4. ;
  5. ; Controls: FIRE (joystick port 1 or 2) or SPACE to flap.
  6. ; Build : ca65 buzzrun.asm -o buzzrun.o && ld65 buzzrun.o -C buzzrun.cfg -o buzzrun.prg
  7. ;
  8. ; Technique notes
  9. ; - Multicolor text mode, 38-column mode, hardware X fine scroll ($D016).
  10. ; - Two raster IRQs: line 251 (score row unscrolled, frame tick, sprite
  11. ; update) and line 58 (apply fine scroll to the playfield).
  12. ; - Coarse scroll copies rows top-to-bottom starting in the lower border,
  13. ; staying ahead of the beam, so there is no tearing.
  14. ; - Sprite/background collision register $D01F gives pixel-exact hits.
  15. ; - Gap heights come from an 8-bit LFSR seeded by the frame counter
  16. ; at the moment the player presses fire.
  17. ; ===========================================================================
  18. ; ---------------------------------------------------------------- hardware
  19. SCREEN = $0400
  20. COLRAM = $D800
  21. CHARSET = $3000
  22. SPRDATA = $2000 ; sprite block $80
  23. SPRPTR = SCREEN + $03F8
  24. VIC_SPR0X = $D000
  25. VIC_SPR0Y = $D001
  26. VIC_SPRXHI = $D010
  27. VIC_CTRL1 = $D011
  28. VIC_RASTER = $D012
  29. VIC_SPREN = $D015
  30. VIC_CTRL2 = $D016
  31. VIC_MEM = $D018
  32. VIC_IRQ = $D019
  33. VIC_IRQEN = $D01A
  34. VIC_SPRMC = $D01C
  35. VIC_SBCOLL = $D01F
  36. VIC_BORDER = $D020
  37. VIC_BG0 = $D021
  38. VIC_BG1 = $D022
  39. VIC_BG2 = $D023
  40. VIC_SPRMC0 = $D025
  41. VIC_SPRMC1 = $D026
  42. VIC_SPR0COL = $D027
  43. SID = $D400
  44. CIA1_PRA = $DC00
  45. CIA1_PRB = $DC01
  46. CIA1_ICR = $DC0D
  47. CIA2_ICR = $DD0D
  48. IRQVEC = $0314
  49. KERNAL_IRQ_EXIT = $EA81
  50. ; ---------------------------------------------------------------- tuning
  51. BEE_X = 88 ; sprite X register (fixed)
  52. Y_CEIL = 56 ; topmost sprite Y (art starts 3 lines down)
  53. Y_FLOOR = 221 ; art bottom sits on the grass
  54. Y_START = 110
  55. GRAV = $0016 ; 8.8 px/frame^2 (~0.086)
  56. FLAP_VEL = $FE4D ; -1.7 px/frame (~18 px rise incl. apex hang)
  57. MAX_FALL = $0240 ; +2.25 px/frame
  58. GRAV_HANG = $000C ; gravity near the top of the arc (~0.05)
  59. HANG_WINDOW = $0080 ; "near the top" = |vel| < 0.5 px/frame
  60. .assert GRAV < $100 && GRAV_HANG < $100 && HANG_WINDOW < $100, error, "physics assumes 8-bit gravity/window"
  61. TITLE_BOB_Y = 120
  62. GAP = 6 ; gap height in rows
  63. PERIOD = 14 ; columns from one pillar to the next
  64. SCORE_COL = 7 ; screen column checked for "pillar passed"
  65. ; game states
  66. ST_TITLE = 0
  67. ST_PLAY = 1
  68. ST_DEAD = 2
  69. ; custom character codes (multicolor)
  70. CH_SKY = $20
  71. CH_BL = $40 ; pillar body left / mid / right
  72. CH_BM = $41
  73. CH_BR = $42
  74. CH_CBL = $43 ; cap at bottom end of upper pillar
  75. CH_CBM = $44
  76. CH_CBR = $45
  77. CH_CTL = $46 ; cap at top end of lower pillar
  78. CH_CTM = $47
  79. CH_CTR = $48
  80. CH_G1 = $49 ; grass row
  81. CH_G2 = $4A
  82. CH_D1 = $4B ; dirt row
  83. CH_D2 = $4C
  84. ; ---------------------------------------------------------------- macros
  85. .macro SET_PTRS row, col, str
  86. lda #<(SCREEN+(row)*40+(col))
  87. sta ptr
  88. lda #>(SCREEN+(row)*40+(col))
  89. sta ptr+1
  90. lda #<str
  91. sta ptr2
  92. lda #>str
  93. sta ptr2+1
  94. .endmacro
  95. .macro PRINT_AT row, col, str
  96. SET_PTRS row, col, str
  97. jsr print_hires
  98. .endmacro
  99. ; ---------------------------------------------------------------- zero page
  100. .segment "ZEROPAGE"
  101. ptr: .res 2
  102. ptr2: .res 2
  103. state: .res 1
  104. frame_flag: .res 1
  105. fine: .res 1
  106. fine_cur: .res 1 ; read by the line-58 IRQ
  107. spr_y: .res 1 ; written to VIC by the IRQ
  108. spr_ptr: .res 1
  109. ypos: .res 2 ; lo = fraction, hi = pixel
  110. vel: .res 2
  111. fire_prev: .res 1
  112. anim: .res 1
  113. colphase: .res 1
  114. colparity: .res 1
  115. gap_top: .res 1
  116. score_lo: .res 1 ; BCD, two lower digits
  117. score_hi: .res 1 ; BCD, hundreds digit
  118. best_lo: .res 1
  119. best_hi: .res 1
  120. timer: .res 1
  121. sfx1_t: .res 1
  122. sfx1_f: .res 1
  123. tmp: .res 1
  124. seed: .res 1
  125. ; ---------------------------------------------------------------- BASIC stub
  126. .segment "LOADADDR"
  127. .word $0801
  128. .segment "CODE"
  129. basic: .word basic_end, 10 ; 10 SYS 2061
  130. .byte $9E, "2061", 0
  131. basic_end:
  132. .word 0
  133. ; ===========================================================================
  134. start:
  135. sei
  136. cld
  137. lda #$7F ; CIA interrupts off (no KERNAL keyscan)
  138. sta CIA1_ICR
  139. sta CIA2_ICR
  140. lda CIA1_ICR
  141. lda CIA2_ICR
  142. jsr copy_charset
  143. jsr copy_sprites
  144. jsr init_sid
  145. ; --- VIC setup
  146. lda #14
  147. sta VIC_BORDER
  148. sta VIC_BG0
  149. lda #13 ; %01 multicolor: light green
  150. sta VIC_BG1
  151. lda #0 ; %10 multicolor: black outline
  152. sta VIC_BG2
  153. lda #$1C ; screen $0400, charset $3000
  154. sta VIC_MEM
  155. lda #$1B
  156. sta VIC_CTRL1
  157. lda #$10 ; multicolor, 38 columns, xscroll 0
  158. sta VIC_CTRL2
  159. lda #BEE_X
  160. sta VIC_SPR0X
  161. lda #0
  162. sta VIC_SPRXHI
  163. lda #1
  164. sta VIC_SPREN
  165. sta VIC_SPRMC
  166. lda #0
  167. sta VIC_SPRMC0 ; black
  168. lda #1
  169. sta VIC_SPRMC1 ; white
  170. lda #7
  171. sta VIC_SPR0COL ; yellow
  172. lda #0
  173. sta best_lo
  174. sta best_hi
  175. sta frame_flag
  176. lda #$10
  177. sta fire_prev ; require a fresh press
  178. ; --- raster IRQ
  179. lda #<irq_bottom
  180. sta IRQVEC
  181. lda #>irq_bottom
  182. sta IRQVEC+1
  183. lda #251
  184. sta VIC_RASTER
  185. lda #1
  186. sta VIC_IRQEN
  187. lda #$FF
  188. sta VIC_IRQ
  189. jsr new_game
  190. cli
  191. ; ===========================================================================
  192. main_loop:
  193. lda frame_flag
  194. beq main_loop
  195. lda #0
  196. sta frame_flag
  197. ; ---- scrolling (only while playing)
  198. lda state
  199. cmp #ST_PLAY
  200. bne @no_scroll
  201. dec fine
  202. bpl @fine_only
  203. lda #7
  204. sta fine
  205. sta fine_cur ; must be set before raster line 58
  206. jsr shift_screen
  207. jsr new_column
  208. jsr check_score
  209. jmp @no_scroll
  210. @fine_only:
  211. lda fine
  212. sta fine_cur
  213. @no_scroll:
  214. jsr read_fire ; A = 1 on a fresh press
  215. sta tmp
  216. .ifdef AUTOTEST ; test build: autostart + autopilot
  217. lda state
  218. cmp #ST_PLAY
  219. bne :+
  220. lda #0
  221. sta tmp
  222. lda ypos+1
  223. cmp #140
  224. bcc :+
  225. lda vel+1
  226. bmi :+
  227. inc tmp
  228. : lda state
  229. bne :+
  230. inc tmp
  231. :
  232. .endif
  233. lda state
  234. cmp #ST_TITLE
  235. beq do_title
  236. cmp #ST_PLAY
  237. beq do_play
  238. jmp do_dead
  239. ; ---------------------------------------------------------------- TITLE
  240. do_title:
  241. lda tmp
  242. beq @idle
  243. ; start the game
  244. jsr clear_playfield
  245. lda #ST_PLAY
  246. sta state
  247. lda anim ; seed the RNG from player timing
  248. ora #1
  249. sta seed
  250. lda VIC_SBCOLL ; discard stale collisions
  251. jsr flap
  252. jmp frame_end
  253. @idle:
  254. jsr physics
  255. lda ypos+1
  256. cmp #TITLE_BOB_Y
  257. bcc @noflap
  258. lda #<FLAP_VEL
  259. sta vel
  260. lda #>FLAP_VEL
  261. sta vel+1
  262. @noflap:
  263. jmp frame_end
  264. ; ---------------------------------------------------------------- PLAY
  265. do_play:
  266. lda tmp
  267. beq @nofl
  268. jsr flap
  269. @nofl:
  270. jsr physics
  271. ; ceiling
  272. lda ypos+1
  273. cmp #Y_CEIL
  274. bcs @below_ceil
  275. lda #Y_CEIL
  276. sta ypos+1
  277. lda #0
  278. sta ypos
  279. sta vel
  280. sta vel+1
  281. @below_ceil:
  282. ; floor or pillar hit?
  283. lda ypos+1
  284. cmp #Y_FLOOR
  285. bcs @die
  286. lda VIC_SBCOLL
  287. .ifdef INVINCIBLE
  288. lda #0
  289. .endif
  290. and #1
  291. beq frame_end
  292. @die:
  293. jsr kill_bee
  294. jmp frame_end
  295. ; ---------------------------------------------------------------- DEAD
  296. do_dead:
  297. jsr physics
  298. lda ypos+1
  299. cmp #Y_FLOOR
  300. bcc @air
  301. lda #Y_FLOOR
  302. sta ypos+1
  303. lda #0
  304. sta ypos
  305. sta vel
  306. sta vel+1
  307. @air:
  308. lda timer
  309. beq @ready
  310. dec timer
  311. bne @wait
  312. ; timer just expired: show game over
  313. PRINT_AT 9, 15, msg_over
  314. PRINT_AT 12, 10, msg_again
  315. @wait:
  316. jmp frame_end_noanim
  317. @ready:
  318. lda tmp
  319. beq @wait
  320. jsr new_game
  321. jmp frame_end
  322. ; ---------------------------------------------------------------- frame end
  323. frame_end:
  324. inc anim ; wing buzz
  325. lda anim
  326. lsr
  327. lsr
  328. and #1
  329. ora #(SPRDATA/64)
  330. sta spr_ptr
  331. frame_end_noanim:
  332. lda ypos+1
  333. sta spr_y
  334. jsr update_sfx
  335. jmp main_loop
  336. ; ===========================================================================
  337. ; Game helpers
  338. ; ===========================================================================
  339. new_game:
  340. lda #ST_TITLE
  341. sta state
  342. lda #0
  343. sta score_lo
  344. sta score_hi
  345. sta fine
  346. sta fine_cur
  347. sta colphase
  348. sta ypos
  349. sta vel
  350. sta vel+1
  351. lda #Y_START
  352. sta ypos+1
  353. sta spr_y
  354. lda #(SPRDATA/64)
  355. sta spr_ptr
  356. jsr clear_playfield
  357. jsr draw_hud
  358. PRINT_AT 7, 19, msg_title
  359. PRINT_AT 10, 14, msg_sub
  360. PRINT_AT 13, 14, msg_ctrl
  361. rts
  362. flap:
  363. lda #<FLAP_VEL
  364. sta vel
  365. lda #>FLAP_VEL
  366. sta vel+1
  367. ; flap sound: rising triangle chirp on voice 1
  368. lda #$00
  369. sta SID+4
  370. lda #$06
  371. sta SID+5
  372. lda #$00
  373. sta SID+6
  374. lda #$14
  375. sta sfx1_f
  376. sta SID+1
  377. lda #$11
  378. sta SID+4
  379. lda #6
  380. sta sfx1_t
  381. rts
  382. kill_bee:
  383. lda #ST_DEAD
  384. sta state
  385. lda #50
  386. sta timer
  387. lda #0
  388. sta sfx1_t
  389. sta vel
  390. sta vel+1
  391. ; crunch: noise burst on voice 1
  392. lda #$80
  393. sta SID+4
  394. lda #$0A
  395. sta SID+5
  396. lda #$00
  397. sta SID+6
  398. lda #$08
  399. sta SID+1
  400. lda #$81
  401. sta SID+4
  402. ; new best?
  403. lda score_hi
  404. cmp best_hi
  405. bcc @done
  406. bne @newbest
  407. lda score_lo
  408. cmp best_lo
  409. bcc @done
  410. beq @done
  411. @newbest:
  412. lda score_lo
  413. sta best_lo
  414. lda score_hi
  415. sta best_hi
  416. jsr draw_hud
  417. @done:
  418. rts
  419. ; vel += GRAV (clamped), ypos += vel
  420. physics:
  421. ; apex hang: weaker gravity while |vel| is small (top of the arc)
  422. ldx #<GRAV
  423. clc
  424. lda vel
  425. adc #<HANG_WINDOW
  426. lda vel+1
  427. adc #0
  428. bne :+ ; vel outside [-HANG_WINDOW, HANG_WINDOW)
  429. ldx #<GRAV_HANG
  430. : txa
  431. clc
  432. adc vel
  433. sta vel
  434. lda vel+1
  435. adc #0 ; both gravities are < 1.0 px/frame^2
  436. sta vel+1
  437. bmi @noclamp ; rising
  438. cmp #>MAX_FALL
  439. bcc @noclamp
  440. lda #<MAX_FALL
  441. sta vel
  442. lda #>MAX_FALL
  443. sta vel+1
  444. @noclamp:
  445. clc
  446. lda ypos
  447. adc vel
  448. sta ypos
  449. lda ypos+1
  450. adc vel+1
  451. sta ypos+1
  452. rts
  453. ; returns A=1 on a fresh press of fire (joy 1/2) or space
  454. read_fire:
  455. lda #$7F ; select keyboard column with SPACE
  456. sta CIA1_PRA
  457. lda CIA1_PRA ; joystick 2
  458. and CIA1_PRB ; joystick 1 fire / space
  459. and #$10
  460. eor #$10 ; $10 = pressed
  461. tax
  462. ldy fire_prev
  463. stx fire_prev
  464. cpx #$10
  465. bne @none
  466. cpy #$10
  467. beq @none
  468. lda #1
  469. rts
  470. @none:
  471. lda #0
  472. rts
  473. ; after a coarse scroll: did a pillar's right edge just pass the bee?
  474. check_score:
  475. lda SCREEN+40+SCORE_COL
  476. cmp #CH_BR
  477. bne @no
  478. sed
  479. clc
  480. lda score_lo
  481. adc #1
  482. sta score_lo
  483. lda score_hi
  484. adc #0
  485. and #$0F
  486. sta score_hi
  487. cld
  488. jsr draw_hud
  489. ; ding on voice 2
  490. lda #$10
  491. sta SID+7+4
  492. lda #$09
  493. sta SID+7+5
  494. lda #$00
  495. sta SID+7+6
  496. lda #$00
  497. sta SID+7+0
  498. lda #$38
  499. sta SID+7+1
  500. lda #$11
  501. sta SID+7+4
  502. @no:
  503. rts
  504. update_sfx:
  505. lda sfx1_t
  506. beq @off
  507. dec sfx1_t
  508. bne @sweep
  509. lda #$10 ; gate off
  510. sta SID+4
  511. rts
  512. @sweep:
  513. lda sfx1_f
  514. clc
  515. adc #$06
  516. sta sfx1_f
  517. sta SID+1
  518. @off:
  519. rts
  520. ; ===========================================================================
  521. ; Screen
  522. ; ===========================================================================
  523. ; coarse scroll: rows 1..24, columns 0..38 <- 1..39 (top to bottom)
  524. shift_screen:
  525. .repeat 24, R
  526. ldx #0
  527. : lda SCREEN+(R+1)*40+1,x
  528. sta SCREEN+(R+1)*40,x
  529. inx
  530. cpx #39
  531. bne :-
  532. .endrepeat
  533. rts
  534. ; fill column 39 of the playfield with the next slice of the world
  535. new_column:
  536. lda colphase
  537. bne @not_new
  538. ; a new pillar starts: choose the gap
  539. : jsr rand
  540. and #$0F
  541. cmp #12
  542. bcs :-
  543. clc
  544. adc #3 ; gap_top = 3..14
  545. sta gap_top
  546. @not_new:
  547. ldx colphase
  548. cpx #3
  549. bcs @sky ; phases 3.. are open sky
  550. ; pillar column x (0=left,1=mid,2=right)
  551. lda #<(SCREEN+40+39)
  552. sta ptr
  553. lda #>(SCREEN+40+39)
  554. sta ptr+1
  555. ldy #1 ; Y = screen row
  556. @row:
  557. tya
  558. sec
  559. sbc gap_top ; row - gap_top
  560. cmp #$FF
  561. beq @capb ; row = gap_top-1
  562. cmp #GAP
  563. beq @capt ; row = gap_top+GAP
  564. bcc @gap ; gap_top <= row < gap_top+GAP
  565. lda body_chars,x
  566. bne @put
  567. @capb: lda capb_chars,x
  568. bne @put
  569. @capt: lda capt_chars,x
  570. bne @put
  571. @gap: lda #CH_SKY
  572. @put: sty tmp
  573. ldy #0
  574. sta (ptr),y
  575. ldy tmp
  576. jsr ptr_next_row
  577. iny
  578. cpy #23
  579. bne @row
  580. jmp @ground
  581. @sky: lda #CH_SKY
  582. sta SCREEN+40+39
  583. sta SCREEN+40+39+40*1
  584. sta SCREEN+40+39+40*2
  585. sta SCREEN+40+39+40*3
  586. sta SCREEN+40+39+40*4
  587. sta SCREEN+40+39+40*5
  588. sta SCREEN+40+39+40*6
  589. sta SCREEN+40+39+40*7
  590. sta SCREEN+40+39+40*8
  591. sta SCREEN+40+39+40*9
  592. sta SCREEN+40+39+40*10
  593. sta SCREEN+40+39+40*11
  594. sta SCREEN+40+39+40*12
  595. sta SCREEN+40+39+40*13
  596. sta SCREEN+40+39+40*14
  597. sta SCREEN+40+39+40*15
  598. sta SCREEN+40+39+40*16
  599. sta SCREEN+40+39+40*17
  600. sta SCREEN+40+39+40*18
  601. sta SCREEN+40+39+40*19
  602. sta SCREEN+40+39+40*20
  603. sta SCREEN+40+39+40*21
  604. @ground:
  605. lda colparity
  606. eor #1
  607. sta colparity
  608. tax
  609. lda grass_chars,x
  610. sta SCREEN+23*40+39
  611. lda dirt_chars,x
  612. sta SCREEN+24*40+39
  613. inc colphase
  614. lda colphase
  615. cmp #PERIOD
  616. bcc :+
  617. lda #0
  618. sta colphase
  619. : rts
  620. ; 8-bit Galois LFSR, period 255 (seed must be non-zero)
  621. rand:
  622. lda seed
  623. asl
  624. bcc :+
  625. eor #$1D
  626. : sta seed
  627. rts
  628. ptr_next_row:
  629. lda ptr
  630. clc
  631. adc #40
  632. sta ptr
  633. bcc :+
  634. inc ptr+1
  635. : rts
  636. ; clear rows 1..22 to sky, draw ground, reset colors
  637. clear_playfield:
  638. ldx #0
  639. @c: lda #CH_SKY
  640. sta SCREEN+40,x
  641. sta SCREEN+40+220,x
  642. sta SCREEN+40+440,x
  643. sta SCREEN+40+660,x ; rows 1..22 = 880 bytes, 4 x 220
  644. lda #13 ; multicolor + green
  645. sta COLRAM+40,x
  646. sta COLRAM+40+220,x
  647. sta COLRAM+40+440,x
  648. sta COLRAM+40+660,x
  649. inx
  650. cpx #220
  651. bne @c
  652. ldx #39
  653. @g: txa
  654. and #1
  655. tay
  656. lda grass_chars,y
  657. sta SCREEN+23*40,x
  658. lda dirt_chars,y
  659. sta SCREEN+24*40,x
  660. lda #15 ; multicolor + yellow
  661. sta COLRAM+23*40,x
  662. sta COLRAM+24*40,x
  663. lda #1 ; HUD row: hi-res white
  664. sta COLRAM,x
  665. dex
  666. bpl @g
  667. lda #1
  668. sta colparity
  669. rts
  670. draw_hud:
  671. ldx #39
  672. lda #CH_SKY
  673. : sta SCREEN,x
  674. dex
  675. bpl :-
  676. SET_PTRS 0, 1, msg_score
  677. jsr print_str
  678. SET_PTRS 0, 29, msg_best
  679. jsr print_str
  680. ; score digits at col 7
  681. ldx #7
  682. lda score_hi
  683. ldy score_lo
  684. jsr put_bcd3
  685. ldx #34
  686. lda best_hi
  687. ldy best_lo
  688. jsr put_bcd3
  689. rts
  690. ; A = hundreds digit, Y = BCD tens/ones, X = column on row 0
  691. put_bcd3:
  692. ora #'0'
  693. sta SCREEN,x
  694. tya
  695. lsr
  696. lsr
  697. lsr
  698. lsr
  699. ora #'0'
  700. sta SCREEN+1,x
  701. tya
  702. and #$0F
  703. ora #'0'
  704. sta SCREEN+2,x
  705. rts
  706. ; copy ASCII string at (ptr2) to (ptr) as screen codes; returns Y = length
  707. print_str:
  708. ldy #0
  709. @l: lda (ptr2),y
  710. beq @d
  711. and #$3F
  712. sta (ptr),y
  713. iny
  714. bne @l
  715. @d: rts
  716. ; as print_str, then colour the cells yellow (hi-res, so text is readable
  717. ; inside the multicolor playfield)
  718. print_hires:
  719. jsr print_str
  720. lda ptr+1
  721. pha
  722. clc
  723. adc #>(COLRAM-SCREEN)
  724. sta ptr+1
  725. lda #7
  726. @c: dey
  727. bmi @x
  728. sta (ptr),y
  729. jmp @c
  730. @x: pla
  731. sta ptr+1
  732. rts
  733. ; ===========================================================================
  734. ; Init
  735. ; ===========================================================================
  736. copy_charset:
  737. lda #$33 ; char ROM visible at $D000
  738. sta $01
  739. ldx #0
  740. : lda $D000,x
  741. sta CHARSET,x
  742. lda $D100,x
  743. sta CHARSET+$100,x
  744. lda $D200,x
  745. sta CHARSET+$200,x
  746. lda $D300,x
  747. sta CHARSET+$300,x
  748. inx
  749. bne :-
  750. lda #$37
  751. sta $01
  752. ldx #(custom_chars_end-custom_chars-1)
  753. : lda custom_chars,x
  754. sta CHARSET+CH_BL*8,x
  755. dex
  756. bpl :-
  757. rts
  758. copy_sprites:
  759. ldx #127
  760. : lda bee_f1,x
  761. sta SPRDATA,x
  762. dex
  763. bpl :-
  764. rts
  765. init_sid:
  766. ldx #$18
  767. lda #0
  768. : sta SID,x
  769. dex
  770. bpl :-
  771. lda #$0F ; volume 15
  772. sta SID+$18
  773. rts
  774. ; ===========================================================================
  775. ; IRQs
  776. ; ===========================================================================
  777. irq_bottom:
  778. lda #$FF
  779. sta VIC_IRQ
  780. lda #$10 ; HUD row: no fine scroll
  781. sta VIC_CTRL2
  782. lda spr_y
  783. sta VIC_SPR0Y
  784. lda spr_ptr
  785. sta SPRPTR
  786. inc frame_flag
  787. lda #<irq_top
  788. sta IRQVEC
  789. lda #>irq_top
  790. sta IRQVEC+1
  791. lda #58
  792. sta VIC_RASTER
  793. jmp KERNAL_IRQ_EXIT
  794. irq_top:
  795. lda #$FF
  796. sta VIC_IRQ
  797. lda fine_cur
  798. ora #$10
  799. sta VIC_CTRL2
  800. lda #<irq_bottom
  801. sta IRQVEC
  802. lda #>irq_bottom
  803. sta IRQVEC+1
  804. lda #251
  805. sta VIC_RASTER
  806. jmp KERNAL_IRQ_EXIT
  807. ; ===========================================================================
  808. ; Data
  809. ; ===========================================================================
  810. body_chars: .byte CH_BL, CH_BM, CH_BR
  811. capb_chars: .byte CH_CBL, CH_CBM, CH_CBR
  812. capt_chars: .byte CH_CTL, CH_CTM, CH_CTR
  813. grass_chars: .byte CH_G1, CH_G2
  814. dirt_chars: .byte CH_D1, CH_D2
  815. msg_score: .byte "SCORE", 0
  816. msg_best: .byte "BEST", 0
  817. msg_title: .byte "BUZZ RUN", 0
  818. msg_sub: .byte "FLAP PAST THE HEDGES", 0
  819. msg_ctrl: .byte "FIRE OR SPACE", 0
  820. msg_over: .byte "GAME OVER", 0
  821. msg_again: .byte "PRESS FIRE TO RETRY", 0
  822. ; multicolor chars: %00 sky, %01 light green, %10 black, %11 colour RAM
  823. custom_chars:
  824. ; body L/M/R (inset one pixel on each side, narrower than the caps)
  825. .byte $27,$27,$27,$27,$27,$27,$27,$27
  826. .byte $FF,$DF,$FF,$FF,$FF,$DF,$FF,$FF
  827. .byte $FA,$F8,$FA,$F8,$FA,$F8,$FA,$F8
  828. ; cap at bottom of upper pillar L/M/R
  829. .byte $95,$95,$95,$95,$95,$95,$AA,$00
  830. .byte $7F,$7F,$7F,$7F,$7F,$7F,$AA,$00
  831. .byte $FE,$FE,$FE,$FE,$FE,$FE,$AA,$00
  832. ; cap at top of lower pillar L/M/R
  833. .byte $00,$AA,$95,$95,$95,$95,$95,$95
  834. .byte $00,$AA,$7F,$7F,$7F,$7F,$7F,$7F
  835. .byte $00,$AA,$FE,$FE,$FE,$FE,$FE,$FE
  836. ; grass 1/2
  837. .byte $55,$55,$65,$AA,$FF,$FB,$FF,$BF
  838. .byte $55,$55,$56,$AA,$FF,$BF,$FF,$FB
  839. ; dirt 1/2
  840. .byte $FF,$EF,$FF,$FE,$FF,$BF,$FF,$FF
  841. .byte $FF,$FF,$FB,$FF,$EF,$FF,$FF,$FE
  842. custom_chars_end:
  843. ; multicolor sprite: %01 black, %10 yellow, %11 white
  844. bee_f1:
  845. .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$F3,$C0,$03,$FF,$F0,$03
  846. .byte $FF,$F0,$00,$FF,$C0,$06,$9A,$50,$1A,$69,$A4,$6A,$69,$9D,$6A,$69
  847. .byte $A9,$1A,$69,$A4,$06,$9A,$50,$01,$04,$00,$00,$00,$00,$00,$00,$00
  848. .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  849. bee_f2:
  850. .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  851. .byte $00,$00,$00,$00,$00,$06,$9A,$50,$FF,$F9,$A4,$FF,$FD,$9D,$3F,$F9
  852. .byte $A9,$1F,$E9,$A4,$06,$9A,$50,$01,$04,$00,$00,$00,$00,$00,$00,$00
  853. .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  854. code_end:
  855. .assert code_end <= SPRDATA, error, "program overlaps sprite data at $2000"

Powered by TurnKey Linux.