Advertisement
aNdy-AL-Cosine

chiller2

Dec 19th, 2020
4,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ; chiller 2 - the return of the jackal
  3. ;
  4. ; released by cosine systems in 2020
  5. ;
  6. ; cosine.org.uk
  7. ;
  8. ; code, graphics and music by
  9. ; andy 'aNdy' vaisey (CSDb id=6404)
  10. ;
  11. ; help and support by
  12. ; jason 'T.M.R' kelk (CSDb id=987)
  13. ;
  14. ; playtesting by
  15. ; jonathan 'moloch' mines (CSDb id=930)
  16. ; ryley 'w0rm' james (CSDb id=32190)
  17. ;
  18. ; special thanks to
  19. ; vinny mainolfi
  20. ; andrew fisher
  21. ; sailor/triad
  22. ;
  23. ; kindly sponsored by FREEZE64.com fanzine
  24. ;
  25. ; questions about this code or about how the binaries
  26. ; were created can be asked by emailing aNdy...
  27. ;
  28. ; andy@cosine.org.uk
  29. ;
  30. ; this source is formatted for the acme cross assembler
  31. ; which can be downloaded from...
  32. ;
  33. ; http://sourceforge.net/projects/acme-crossass/
  34. ;
  35. ; the final build was compressed and squished using
  36. ; exomizer 2 which can be downloaded from...
  37. ;
  38. ; http://hem.bredband.net/magli143/exo/
  39.  
  40. ; the name and file format for the assembled program
  41.  
  42.         !to "chiller2.prg",cbm
  43.  
  44. ; assimilate the binary data, resistance is futile...
  45.  
  46.         * = $0900
  47. music   !binary "data\music.prg",,2
  48.  
  49.         * = $2000
  50.         !binary "data\charset.bin"
  51.  
  52.         * = $2800
  53.         !binary "data\sprites.bin"
  54.        
  55. ; position of the raster interrupt(s) on-screen
  56. ; 'rp' is short for 'raster position'! duh!
  57.  
  58. raster_1_pos        = $00               ; very top of screen and colour hack for ntsc
  59. raster_2_pos        = $0f               ; changes top border colour for screens
  60. raster_3_pos        = $32               ; start of main screen
  61. raster_4_pos        = $5f               ; title screen split for sprite recycling
  62. raster_5_pos        = $f9               ; bottom split to open borders
  63.  
  64. ; label assignments for joystick and keyboard control
  65.  
  66. cpra                = $dc00             ; cia #1, port register a
  67. cprb                = $dc01             ; cia #1, port register b
  68.  
  69. ; some more label assignments (zp variables)
  70.  
  71. raster_num          = $50           ; raster counter stores which split we are working in
  72. sync                = $51           ; interrupt sync variable
  73.  
  74. colourwash_count    = $53           ; colour pulse counter for wash effect
  75. colourwash_timer    = $54           ; colour pulse timer for wash effect
  76.  
  77. scroll_x            = $55           ; title scroller screen position
  78. scroll_pos          = $56           ; titles scroller position - $02 bytes used
  79.  
  80. ply_type            = $58           ; store for player select - boy (1) or girl (0)
  81. anim_timer          = $59           ; animation timer for game sprites
  82. title_mode          = $5a           ; is titles mode enabled?
  83. bounce_timer        = $5b           ; bounce timer for title screen logo top sprites
  84. anim_timer_b        = $5c           ; animation timer for title screen bottom sprites
  85. last_level          = $5d           ; last level reached variable
  86. level_num           = $5e           ; level number variable
  87.  
  88. ply_move_flag       = $5f           ; player move flag - player is moving or not!
  89. ply_move_timer      = $60           ; player move timer - delay x movement so visible!
  90. ply_strength        = $61           ; girl or boy strength variable
  91. ply_jumppwr         = $62           ; girl or boy jump power variable
  92. ply_colls_flag      = $63           ; flag for player death initiation! WHAAAA!
  93. colls_timer         = $64           ; timer for player -> enemy collision
  94. ply_energy          = $65           ; player energy store
  95. coll_temp           = $66           ; collision workspace - $04 bytes used
  96. gravity_strength    = $6a           ; gravity strength store
  97. gravity_timer       = $6b           ; gravity timer store
  98. gravity_on          = $6c           ; gravity on/off flag
  99. bkgd_coll_timer     = $6d           ; timer for player -> background collisions
  100.  
  101. level_comp_flag     = $6e           ; flag for level complete
  102. cross_num           = $6f           ; crosses collected store
  103.  
  104. bkgd_timer          = $70           ; animation timer for background chars
  105. bkgd_lvl_tmr        = $71           ; anim 'speed' for indiv level background anim
  106. enemy_timer         = $72           ; timer for enemy movement - slow them!
  107. raindrop            = $73           ; raindrop counter
  108. cinescrn            = $74           ; cinema screen counter
  109. snowstrip           = $75           ; snow strip store
  110.  
  111. tbordblue           = $76           ; flag for black or blue top border in-game
  112. video_type          = $77           ; 0=pal, 1=ntsc
  113. music_tmr           = $78           ; timer for music frame skip on ntsc
  114. intro_mode          = $79           ; additional flag for intro mode at start
  115.  
  116. ; add a BASIC startline (SYS 16384) for auto-run after loading
  117.  
  118.         * = $0801
  119.         !word code_entry-2
  120.         !byte $00,$00,$9e
  121.         !text "16384"
  122.         !byte $00,$00,$00
  123.  
  124. ; entry point for the code
  125.  
  126.         * = $4000                   ; hence sys 16384!
  127.                
  128. code_entry
  129.  
  130. ; stop interrupts, disable the roms and set up nmi and irq interrupt pointers  
  131.  
  132.         sei                         ; poke the interrupts in the eye temporarily
  133.                
  134.         lda #<nmi                   ; some nmi interrupt stuff
  135.         sta $fffa
  136.         lda #>nmi
  137.         sta $fffb
  138.  
  139.         lda #<int                   ; some irq stuff
  140.         sta $fffe
  141.         lda #>int
  142.         sta $ffff
  143.        
  144.         ldx #$00
  145.         lda #$00
  146. clr_mem                             ; clear out memory between $0200 and $02ff 
  147.         sta $0200,x                 ; not doing this makes the game bug slighty
  148.         inx                         ; when using the fast loader on an action
  149.         bne clr_mem                 ; replay cartridge.  dunno why it bugs....     
  150.  
  151.         lda #$35                    ; bin the roms and kernal, we're flying solo
  152.         sta $01    
  153.        
  154.         lda #$7f                    ; disable timer interrupts which can be generated by the two CIA chips
  155.         sta $dc0d                   ; the kernal uses such an interrupt to flash the cursor and scan
  156.         sta $dd0d                   ; the keyboard, so we better stop it
  157.  
  158.         lda $dc0d                   ; by reading these two registers we kill any pending CIA irqs.
  159.         lda $dd0d                   ; if we don't do this, a pending CIA irq might occur after we
  160.                                     ; finish setting up our irq and we don't want that to happen do we!?
  161.  
  162.         lda #raster_1_pos           ; starting point of raster on screen ($00)
  163.         sta $d012
  164.  
  165.         lda #$1b                    ; as there are more than 256 rasterlines, the topmost bit of $d011 serves as
  166.         sta $d011                   ; the 9th bit for the rasterline we want our irq to be triggered.
  167.        
  168.         lda #$01                    ; acknowledge any interrupts
  169.         sta $d019                   ; clear interrupt bit
  170.         sta $d01a                   ; tell vic-ii to generate interrupt
  171.  
  172.         lda #$03                    ; select video bank
  173.         sta $dd00      
  174.                        
  175.         lda #$18                    ; use our custom charset at $2000
  176.         sta $d018
  177.  
  178.         cli                         ; unleash those interrupts again
  179.  
  180. ; detect what machine type is being used...
  181.  
  182. start_scan
  183.         lda $d012
  184. chkntsc
  185.         cmp $d012
  186.         beq chkntsc
  187.         bmi start_scan
  188.         adc #$00
  189.         lsr
  190.         bcs isntsc
  191.         lsr
  192.         bcs isoldntsc
  193.         ldx #$00                    ; check drean or pal
  194.         lda #$10
  195. chkpal
  196.         inx
  197.         cmp $d012
  198.         bne chkpal
  199.         cpx #$70
  200.         bcc ispal
  201. isdrean
  202.         lda #$01
  203.         sta video_type              ; video = ntsc
  204.         jmp detect_dun
  205. isntsc 
  206.         lda #$01
  207.         sta video_type              ; video = ntsc
  208.         jmp detect_dun
  209. isoldntsc
  210.         lda #$01
  211.         sta video_type              ; video = ntsc
  212.         jmp detect_dun
  213. ispal
  214.         lda #$00
  215.         sta video_type              ; video = pal
  216.  
  217. detect_dun 
  218.                
  219. ; ready the irq code for the first run
  220.        
  221.         lda #$01                    ; set irq code handler to 1
  222.         sta raster_num              ; for top of screen
  223.        
  224. ; set up the intro screen
  225.  
  226.         lda #$01                    ; set to
  227.         sta title_mode              ; title screen mode!
  228.         sta intro_mode              ; hack on the intro mode!
  229.        
  230.         lda #$00                    ; load 0 for black
  231.         sta $d021                   ; store to background! change colour!
  232.         sta $d020                   ; store to border! change colour!      
  233.        
  234.         jsr clear_screen            ; clear screen with subroutine
  235.        
  236. ; prepare the intro sound, which is a blank tune!
  237.  
  238.         lda #$0a                    ; ready a blank tune
  239.         jsr music+$00               ; insert into music driver
  240.        
  241. ; print intro message for either pal or ntsc and 8580 sid
  242.  
  243.         ldx #$00
  244. in_text_loop
  245.         lda video_type
  246.         cmp #$00
  247.         bne print_ntsc
  248.  
  249.         lda intro_1,x               ; this is a pal machine?
  250.         sta $05b8,x                 ; print the pal message!
  251.         lda #$02
  252.         sta $d9b8,x
  253.        
  254.         jmp print_8580
  255.        
  256. print_ntsc                          ; this is an ntsc machine?
  257.         lda intro_2,x               ; print the ntsc message!
  258.         sta $05b8,x
  259.         lda #$02
  260.         sta $d9b8,x    
  261.  
  262. print_8580                          ; the music sounds best on     
  263.         lda intro_3,x               ; an 8580 sid machine
  264.         sta $0608,x                 ; so tell the player!
  265.         lda #$02
  266.         sta $da08,x                
  267.         inx
  268.         cpx #$28
  269.         bne in_text_loop
  270.  
  271. ; ready the sprites for the intro 'cosine' logo
  272.                
  273.         ldx #$00
  274. i_sprite_set                        ; read the definitions,
  275.         lda i_spr_x_dflt,x          ; colours, positions, etc
  276.         sta sprite_x,x              ; of the cosine logo
  277.         lda i_spr_y_dflt,x          ; sprites used in the 'intro'
  278.         sta sprite_y,x              ; and pass them to the main
  279.         lda i_spr_col_dflt,x        ; sprite table so the irq's
  280.         sta sprite_col,x            ; can print them on the screen
  281.         lda i_spr_def_dflt,x
  282.         sta sprite_def,x
  283.         lda i_spr_anims_dflt,x
  284.         sta sprite_anims,x
  285.         lda i_spr_anime_dflt,x
  286.         sta sprite_anime,x     
  287.         inx
  288.         cpx #$08
  289.         bne i_sprite_set       
  290.        
  291. ; give player time to read the intro   
  292.                        
  293.         ldy #$ff                    ; wait a bit...
  294.         jsr sync_wait_long             
  295.        
  296.         lda #$00                    ; switch the hack for
  297.         sta intro_mode              ; intro mode off       
  298.  
  299. ; set up some labels for very first run of the actual game
  300.  
  301.         sta ply_type                ; make player type 0, which is the girl
  302.  
  303.         sta music_tmr               ; zero the ntsc music timer
  304.        
  305.         lda #$09                    ; girls strength
  306.         sta ply_strength            ; is 9 to start
  307.        
  308.         lda #$fe                    ; the girl's jump
  309.         sta ply_jumppwr             ; distance power!
  310.        
  311.         lda #$01                    ; last level reached should
  312.         sta last_level              ; be '1' on very first run!
  313.  
  314. ; now for the actual game itself...                
  315.        
  316. ; set up and display the title screen
  317.    
  318. title_setup
  319.  
  320.         lda #$00                    ; set code to
  321.         sta title_mode              ; title screen mode and
  322.         sta intro_mode              ; intro mode off!
  323.                                     ; and set the flag for ntsc    
  324.         sta tbordblue               ; black top border hack!       
  325.  
  326.         jsr clear_screen            ; clear screen with subroutine
  327.        
  328. ; ready the sprites for the bouncing title logo 'chiller 2'
  329.        
  330.         ldx #$00
  331. t_sprite_set1
  332.         lda t_spr_x_dflt,x          ; call up the definitions,
  333.         sta sprite_x,x              ; colours, positions, etc
  334.         lda t_spr_y_dflt,x          ; of the title screen sprites
  335.         sta sprite_y,x              ; and pass them to the main
  336.         lda t_spr_col_dflt,x        ; sprite table so the irq's
  337.         sta sprite_col,x            ; can dump them on the screen
  338.         lda t_spr_def_dflt,x
  339.         sta sprite_def,x
  340.         lda t_spr_anims_dflt,x
  341.         sta sprite_anims,x
  342.         lda t_spr_anime_dflt,x
  343.         sta sprite_anime,x     
  344.         inx
  345.         cpx #$08
  346.         bne t_sprite_set1
  347.  
  348. ; then ready the sprites for the title screen bottom sprites
  349. ; for the boy, girl and ghost...
  350.            
  351.         ldx #$00
  352. t_sprite_set2
  353.         lda t_spr_x_dflt2,x         ; same as above!
  354.         sta t_sprite_x,x
  355.         lda t_spr_y_dflt2,x
  356.         sta t_sprite_y,x
  357.         lda t_spr_col_dflt2,x
  358.         sta t_sprite_col,x
  359.         lda t_spr_def_dflt2,x
  360.         sta t_sprite_def,x
  361.         lda t_spr_dflt2_anims,x
  362.         sta t_sprite_anims,x
  363.         lda t_spr_dflt2_anime,x
  364.         sta t_sprite_anime,x
  365.         inx
  366.         cpx #$08
  367.         bne t_sprite_set2
  368.        
  369. ; print the title screen text and layout to screen ram     
  370.        
  371.         ldx #$00                    ; zero x register
  372. t_scrnram_loop                      ; load up whatver is in the title screen
  373.         lda t_screen_ram,x          ; ram table and write to the
  374.         sta $0400,x                 ; actual screen ram
  375.         lda t_screen_ram+250,x
  376.         sta $0400+250,x
  377.         lda t_screen_ram+500,x
  378.         sta $0400+500,x
  379.         lda t_screen_ram+750,x
  380.         sta $0400+750,x
  381.         inx
  382.         cpx #$fa                    ; done 250 writes?
  383.         bne t_scrnram_loop          ; all written? no? loop back!
  384.  
  385. ; print the compressed title screen colour data to colour ram
  386.            
  387.         ldx #$00                    ; zero x register
  388.         ldy #$00                    ; zero y register
  389. t_colram_loop
  390.         lda t_colour_ram,x          ; load up a byte
  391.         sta $d800+1,y               ; store a colour nybble to screen
  392.         lsr                         ; bit shift to the right
  393.         lsr                         ; 4 times so we can read
  394.         lsr                         ; the other colour nybble
  395.         lsr                         ; stored in the byte then
  396.         sta $d800,y                 ; store the other nybble!
  397.  
  398.         lda t_colour_ram+115,x
  399.         sta $d800+231,y
  400.         lsr
  401.         lsr
  402.         lsr
  403.         lsr
  404.         sta $d800+230,y
  405.  
  406.         lda t_colour_ram+230,x
  407.         sta $d800+461,y
  408.         lsr
  409.         lsr
  410.         lsr
  411.         lsr
  412.         sta $d800+460,y
  413.  
  414.         lda t_colour_ram+345,x
  415.         sta $d800+691,y
  416.         lsr
  417.         lsr
  418.         lsr
  419.         lsr
  420.         sta $d800+690,y
  421.  
  422.         iny
  423.         iny
  424.         inx
  425.         cpx #$73
  426.         bne t_colram_loop                              
  427.        
  428. ; print previous score and high score onto screen
  429.  
  430.         ldx #$00
  431. score_print_t
  432.         lda score,x                 ; load up what's in the
  433.         ora #$30                    ; score table and
  434.         sta $07a8,x                 ; print it on screen!
  435.         lda high_score,x            ; then the same for the
  436.         ora #$30                    ; high score table!
  437.         sta $07ba,x    
  438.         inx
  439.         cpx #$06
  440.         bne score_print_t
  441.        
  442. ; reset the message scroller
  443.  
  444.         jsr scroll_reset            ; reset 'scroller' subroutine
  445.        
  446.         lda #$50
  447.         sta scroll_x
  448.  
  449. ; prepare the title music  
  450.  
  451.         lda #$00                    ; ready the title music tune
  452.         jsr music+$00               ; throw it at the music driver!
  453.        
  454. ; set flag for title screen mode to 1 (on)
  455.        
  456.         lda #$01
  457.         sta title_mode
  458.        
  459. ; which player is selected? colour word and prep dancing sprites!
  460.  
  461.         lda ply_type                ; which character is selected?
  462.         cmp #$00                    ; girl?
  463.         beq prep_girl               ; yes? then branch to prep_girl
  464.                                     ; no?
  465.         jsr boy_select              ; then prep the boy!
  466.        
  467.         jmp title_loop              ; jump to title screen loop below!
  468.        
  469. prep_girl
  470.         jsr girl_select    
  471.        
  472. ; everything for the title screen is now on-screen
  473. ; so 'lock' the main title screen in a loop until
  474. ; the player presses a key or inputs the joystick
  475.  
  476. title_loop
  477.  
  478.         jsr sync_wait               ; wait until irq finishes!
  479.  
  480. ; check if 'f7' is pressed for continue from last level feature
  481.  
  482.         lda #$fe                    ; load $dc00...
  483.         sta cpra                    ; ...with bit row 0
  484.        
  485.         lda cprb                    ; load $dc01 to test...
  486.         cmp #$f7                    ; key 'f7' pressed?
  487.         bne ps_left                 ; no? check joystick...
  488.  
  489. ; press 'f7' is detected
  490.                
  491.         jsr key_debounce            ; debounce keyboard
  492.        
  493.         lda last_level              ; load last level played...
  494.         sta level_num               ; ...into current level!
  495.  
  496.         jmp kill_title              ; then start game init!
  497.                    
  498. ; no 'f7' press detected, so check if player uses joystick...
  499.  
  500. ps_left
  501.         lda cpra                    ; load 'joystick' port 2 register
  502.         and #$04                    ; pull left bit activated?
  503.         bne ps_right                ; nope? test right!
  504.                                     ; yes?
  505.         jsr girl_select             ; select girl subroutine!
  506.        
  507. ps_right                            ; etc
  508.         lda cpra
  509.         and #$08
  510.         bne ps_fire
  511.        
  512.         jsr boy_select
  513.    
  514. ps_fire
  515.         lda cpra
  516.         and #$10
  517.         bne title_loop              ; nothing detected, restart title loop!
  518.                                     ; make sure player isn't holding
  519.         jsr fire_debounce           ; down the fire button!
  520.        
  521. ; fire button pressed for brand new game, set the level number to '1'!
  522.                
  523.         lda #$01
  524.         sta level_num
  525.  
  526. ; kill title screen mode
  527.  
  528. kill_title
  529.         lda #$00                    ; switch off the ghost and girl/boy
  530.         sta title_mode              ; sprites on the title screen
  531.  
  532. ; reset the score to '000000'
  533.                
  534.         ldx #$00
  535.         lda #$00                   
  536. score_reset            
  537.         sta score,x                 ; score table set to '000000'
  538.         inx
  539.         cpx #$06
  540.         bne score_reset
  541.        
  542. ; initialise the get ready sequence and
  543. ; set-up the next level behind the scenes
  544.                
  545. get_ready_setup
  546.  
  547.         lda #$00                    ; set the flag for
  548.         sta tbordblue               ; a black top border!
  549.    
  550.         jsr hide_sprites            ; move the sprites off-screen!
  551.        
  552.         jsr clear_screen            ; clear the screen
  553.  
  554.         lda #$01                    ; the get ready tune (1)
  555.         jsr music+$00               ; init the music driver
  556.        
  557.         lda #$21                    ; give player full energy
  558.         sta ply_energy              ; at the start of each level!  
  559.        
  560.         lda level_num               ; load the level number
  561.    
  562.         cmp #$02                    ; is it level 2?
  563.         bne *+$08                   ; no? check for level 3
  564.         jsr level2_setup_subrout    ; otherwise setup l2!                              
  565.         jmp get_ready_display       ; jump to get ready!
  566.        
  567.         cmp #$03                    ; is it level 3?
  568.         bne *+$08                   ; no? check for level 4
  569.         jsr level3_setup_subrout    ; otherwise setup l3!                                  
  570.         jmp get_ready_display       ; jump to get ready!
  571.        
  572.         cmp #$04                    ; level 4
  573.         bne *+$08                   ; etc!
  574.         jsr level4_setup_subrout                               
  575.         jmp get_ready_display
  576.  
  577.         cmp #$05
  578.         bne *+$08
  579.         jsr level5_setup_subrout                               
  580.         jmp get_ready_display
  581.        
  582.         cmp #$06
  583.         bne *+$08
  584.         jsr level6_setup_subrout                               
  585.         jmp get_ready_display
  586.        
  587.         cmp #$07
  588.         bne *+$08
  589.         jsr level7_setup_subrout                               
  590.         jmp get_ready_display
  591.        
  592.         cmp #$08
  593.         bne *+$08
  594.         jsr level8_setup_subrout                               
  595.         jmp get_ready_display
  596.        
  597.         cmp #$09
  598.         bne *+$08
  599.         jsr level9_setup_subrout                               
  600.         jmp get_ready_display
  601.        
  602.         cmp #$0a
  603.         bne *+$08
  604.         jsr level10_setup_subrout                              
  605.         jmp get_ready_display
  606.        
  607.         cmp #$0b
  608.         bne *+$08
  609.         jsr level11_setup_subrout                              
  610.         jmp get_ready_display
  611.        
  612.         cmp #$0c
  613.         bne *+$08
  614.         jsr level12_setup_subrout                              
  615.         jmp get_ready_display                                                  
  616.  
  617.         jsr level1_setup_subrout    ; none of the above? setup l1 then!!!                              
  618.  
  619. ; next level has been prepared, let's get ready for the game!  
  620.        
  621. get_ready_display  
  622.  
  623. ; print level info for get ready screen
  624.  
  625.         ldx #$00
  626. gr_text_loop
  627.         lda get_ready_des1,x        ; print level number / title
  628.         sta $0590,x
  629.         lda #$02                    ; make that text red
  630.         sta $d990,x
  631.         lda get_ready_des2,x        ; print rhyme couplet first line
  632.         sta $05e0,x
  633.         lda #$06                    ; make that text blue
  634.         sta $d9e0,x
  635.         lda get_ready_des3,x        ; print rhyme couplet second line
  636.         sta $0608,x
  637.         lda #$06                    ; make that text blue
  638.         sta $da08,x                
  639.         inx
  640.         cpx #$28
  641.         bne gr_text_loop
  642.  
  643. ; give player time to read the level description!      
  644.                        
  645.         ldy #$ff                    ; wait a bit...
  646.         jsr sync_wait_long
  647.  
  648. ; initialise the in-game music based on the level      
  649.        
  650.         jsr lmusic_setup
  651.        
  652. ; set top border colour depending on level number...
  653.  
  654.         lda level_num               ; which level are we on?
  655.        
  656.         cmp #$03                    ; level 3?
  657.         bne *+$05                   ; no? branch to next check
  658.         jmp set_bluebord            ; yes? set blue border flag
  659.  
  660.         cmp #$07                    ; level 7?
  661.         bne *+$05                   ; no? branch to next check
  662.         jmp set_bluebord            ; yes? set blue border flag
  663.    
  664.         cmp #$0c                    ; level 12?
  665.         bne *+$05                   ; no? branch to next check
  666.         jmp set_bluebord            ; yes? set blue border flag                
  667.        
  668.         lda #$00                    ; otherwise set the flag for
  669.         sta tbordblue               ; a black top border!
  670.        
  671.         jmp print_gamescrn
  672.        
  673. set_bluebord       
  674.         lda #$01                    ; set flag for a blue border
  675.         sta tbordblue               ; for levels 3 and 7!
  676.                
  677. ; now print the level layout!
  678.  
  679. print_gamescrn                      ; the screen chars and colour!
  680.         ldx #$00                    ; zero x register
  681. l_scrnram_loop                      ; load up whatver is in the screen
  682.         lda l_screen_ram,x          ; ram table and write to the
  683.         sta $0400,x                 ; screen ram
  684.         lda l_screen_ram+230,x
  685.         sta $0400+230,x
  686.         lda l_screen_ram+460,x
  687.         sta $0400+460,x
  688.         lda l_screen_ram+690,x
  689.         sta $0400+690,x
  690.         inx
  691.         cpx #$e6                        ; done 250 writes?
  692.         bne l_scrnram_loop              ; all written? no? loop back!
  693.                                         ; yes? then...
  694.         ldx #$00                        ; zero x register
  695. l_colram_loop                           ; load whatever is in the colour
  696.         lda l_colour_ram,x              ; ram table and write to the
  697.         sta $d800,x                     ; colour ram
  698.         lda l_colour_ram+230,x
  699.         sta $d800+230,x
  700.         lda l_colour_ram+460,x
  701.         sta $d800+460,x
  702.         lda l_colour_ram+690,x
  703.         sta $d800+690,x
  704.         inx
  705.         cpx #$e6                        ; done 250 writes?
  706.         bne l_colram_loop               ; all written? no? loop back!
  707.  
  708. ; print up the status bar
  709.  
  710.         jsr status_bar                  ; use subroutine!
  711.        
  712. ; update the energy bar to correct level       
  713.                
  714.         jsr energy_bar                  ; use subroutine!
  715.        
  716. ; get those game sprites printed on the screen!
  717.        
  718.         ldx #$00
  719. game_sprite_set
  720.         lda sprite_x_buf,x
  721.         sta sprite_x,x
  722.         lda sprite_y_buf,x
  723.         sta sprite_y,x
  724.         lda sprite_col_buf,x
  725.         sta sprite_col,x
  726.         lda sprite_def_buf,x
  727.         sta sprite_def,x
  728.         lda sprite_anims_buf,x
  729.         sta sprite_anims,x
  730.         lda sprite_anime_buf,x
  731.         sta sprite_anime,x
  732.         lda sprite_dir_buf,x
  733.         sta sprite_dir,x
  734.         lda sprite_spd_buf,x
  735.         sta sprite_spd,x
  736.         lda sprite_min_buf,x
  737.         sta sprite_min,x
  738.         lda sprite_max_buf,x           
  739.         sta sprite_max,x   
  740.         inx
  741.         cpx #$08
  742.         bne game_sprite_set
  743.  
  744. ; reset cross counter to 0
  745.  
  746.         ldx #$00
  747.         lda #$00                           
  748. cross_reset                             ; reset the cross counter                  
  749.         sta cross_score,x               ; to 00
  750.         inx
  751.         cpx #$02
  752.         bne cross_reset
  753.        
  754.         sta cross_num                   ; reset cross variable to 0        
  755.        
  756. ; print the status bar scores/counters     
  757.        
  758.         jsr update_status               ; use subroutine!
  759.        
  760. ; reset the in-game gravity
  761.  
  762.         lda #$00                        ; load accumalator with '0'
  763.                        
  764.         sta gravity_strength            ; grav strength to 0
  765.         sta gravity_timer               ; grav timer to 0
  766.         sta gravity_on                  ; gravity_on is 0 (off!)
  767.        
  768. ; reset some timers and counters
  769.  
  770.         sta colls_timer                 ; sprite collision timer to 0
  771.         sta bkgd_coll_timer             ; background collision timer to 0
  772.         sta bkgd_timer                  ; background animation timer to 0
  773.         sta enemy_timer                 ; enemy movement timer to 0
  774.         sta raindrop                    ; raindrop anim counter to 0
  775.         sta cinescrn                    ; cinema screen anim counter to 0
  776.         sta snowstrip                   ; snow anim counter to 0
  777.    
  778. ; reset level complete flag to 0!      
  779.            
  780.         sta level_comp_flag    
  781.    
  782. ; now begin main game loop...      
  783.        
  784. main_game_loop
  785.  
  786.         jsr sync_wait                   ; wait for screen sync
  787.         jsr player_move                 ; check joystick and move player
  788.         jsr player_collision            ; check for sprite collisions
  789.        
  790.         lda ply_colls_flag              ; check if collision flag is 2
  791.         cmp #$02                        ; if so, energy has run out so
  792.         beq death_init                  ; begin death sequence
  793.        
  794.         cmp #$01                        ; check if collision flag is 1
  795.         bne process_rest                ; if not, branch down to 'process_rest'
  796.                                         ; if it is 1, carry on to code below...
  797.         jsr score_accrue_100            ; give the player 100 points!
  798.         jsr cross_accrue                ; add a cross to cross counter
  799.         jsr update_status               ; update status bar (add a cross!)
  800.        
  801.         lda #<sfx_collect               ; start address of 'collect' sfx
  802.         ldy #>sfx_collect               ; end address of 'collect' sfx
  803.         ldx #$0e                        ; play sfx on channel 3 please!
  804.         jsr music+$06                   ; call sfx driver to play sound
  805.        
  806.         lda level_comp_flag             ; load up level complete flag
  807.         cmp #$01                        ; is it '1'?
  808.         bne process_rest                ; no? branch to 'process_rest'
  809.                                         ; yes?
  810.         jmp level_complete              ; jump to level complete sequence!
  811.                
  812. process_rest
  813.         jsr process_enemies             ; update enemy positions
  814.        
  815.         jsr process_bkgd_anims          ; animate the background for current level
  816.        
  817.         jmp main_game_loop              ; jump back to start of main game loop!
  818.  
  819. ; energy is gone, start death sequence!            
  820.        
  821. death_init
  822.  
  823.         lda #$00                        ; set the flag for
  824.         sta tbordblue                   ; a black top border!
  825.  
  826.         lda #$03                        ; game over tune number is '3'
  827.         jsr music+$00                   ; init the music driver!
  828.        
  829.         jsr hide_sprites                ; hide the sprites off-screen!
  830.        
  831.         jsr clear_screen                ; clear the screen
  832.        
  833.         ldx #$00
  834. print_gover                             ; print the game over message
  835.         lda game_over_txt,x
  836.         sta $0568,x
  837.         lda #$02
  838.         sta $d968,x
  839.         inx
  840.         cpx #$f0
  841.         bne print_gover
  842.  
  843. ; load current level number into last level variable for 'continue' feature    
  844.                
  845.         lda level_num                   ; load current level number
  846.         sta last_level                  ; store to last level reached variable
  847.  
  848. ; give player time to read the game over message!  
  849.                        
  850.         ldy #$ff                        ; wait a bit...
  851.         jsr sync_wait_long
  852.    
  853.         jmp title_setup                 ; set up the title screen
  854.        
  855. ; level is complete! initiate level complete sequence...
  856.  
  857. level_complete
  858.         jsr score_accrue_1000           ; give player 1000 points
  859.        
  860.         lda level_num                   ; load current level number
  861.         inc level_num                   ; increase it by 1
  862.         sta last_level                  ; store to last level reached variable
  863.        
  864.         cmp #$0c                        ; is the level number 12
  865.         bne level_comp_end              ; no? branch to level comp end
  866.                                         ; yes?
  867.         jmp comp_init                   ; initiate game complete sequence!
  868.        
  869. level_comp_end
  870.         jmp get_ready_setup             ; set up the next level
  871.        
  872. ; game is complete, initiate the game complete sequence
  873.  
  874. comp_init
  875.         lda #$00                        ; set the flag for
  876.         sta tbordblue                   ; a black top border!
  877.  
  878.         lda #$08                        ; some game complete music!
  879.         jsr music+$00                   ; init the music driver with tune 8
  880.        
  881.         jsr hide_sprites                ; move the sprites off-screen!
  882.         jsr clear_screen                ; clear the screen
  883.  
  884.         jsr score_accrue_1000           ; give player 1000 points
  885.         jsr score_accrue_1000           ; and another 1000 points              
  886.                
  887.         ldy #$0f                        ; wait a bit...
  888.         jsr sync_wait_long     
  889.        
  890.         jsr status_bar                  ; print status bar
  891.        
  892.         jsr update_status               ; update new score and energy      
  893.  
  894. ; print game complete message!     
  895.        
  896.         ldx #$00
  897. print_gcomp1
  898.         lda game_comp_txt,x
  899.         sta $04a0,x
  900.         lda #$02
  901.         sta $d8a0,x
  902.         inx
  903.         cpx #$a0
  904.         bne print_gcomp1
  905.    
  906. ; print the game complete graphic display      
  907.            
  908.         ldx #$00
  909. print_gcomp2
  910.         lda comp_screen_ram,x
  911.         sta $05ea,x
  912.         lda comp_screen_ram+19,x
  913.         sta $05ea+40,x
  914.         lda comp_screen_ram+38,x
  915.         sta $05ea+80,x                 
  916.         lda comp_screen_ram+57,x
  917.         sta $05ea+120,x    
  918.         lda comp_screen_ram+76,x
  919.         sta $05ea+160,x    
  920.         lda comp_screen_ram+95,x
  921.         sta $05ea+200,x    
  922.         lda comp_screen_ram+114,x
  923.         sta $05ea+240,x    
  924.         lda comp_screen_ram+133,x
  925.         sta $05ea+280,x    
  926.        
  927.         lda comp_colour_ram,x
  928.         sta $d9ea,x
  929.         lda comp_colour_ram+19,x
  930.         sta $d9ea+40,x
  931.         lda comp_colour_ram+38,x
  932.         sta $d9ea+80,x                 
  933.         lda comp_colour_ram+57,x
  934.         sta $d9ea+120,x        
  935.         lda comp_colour_ram+76,x
  936.         sta $d9ea+160,x
  937.         lda comp_colour_ram+95,x
  938.         sta $d9ea+200,x        
  939.         lda comp_colour_ram+114,x
  940.         sta $d9ea+240,x        
  941.         lda comp_colour_ram+133,x
  942.         sta $d9ea+280,x                
  943.        
  944.         inx
  945.         cpx #$13
  946.         bne print_gcomp2
  947.        
  948. ; throw some game complete sprites at the screen...
  949.  
  950. ; ready the sprites for the title screen bottom sprites
  951.            
  952.         ldx #$00
  953. gc_sprites
  954.         lda gc_sprite_x ,x
  955.         sta sprite_x,x
  956.         lda gc_sprite_y ,x
  957.         sta sprite_y,x
  958.         lda gc_sprite_col,x
  959.         sta sprite_col,x
  960.         lda gc_sprite_def,x
  961.         sta sprite_def,x
  962.         lda gc_sprite_anims,x
  963.         sta sprite_anims,x
  964.         lda gc_sprite_anime,x
  965.         sta sprite_anime,x
  966.         inx
  967.         cpx #$03
  968.         bne gc_sprites             
  969.  
  970. ; now the game complete loop...    
  971.                        
  972. comp_loop
  973.         lda cpra                        ; load port 2 register
  974.         and #$10                        ; wait for fire button press
  975.         bne comp_loop
  976.        
  977.         jsr fire_debounce               ; debounce the button
  978.        
  979. ; swap the player characters over
  980.  
  981.         lda ply_type                    ; which player character at moment?
  982.         cmp #$00                        ; girl?
  983.         beq chnge2_boy                  ; yes? change to boy!
  984.                                         ; no?
  985.  
  986.         jsr girl_sprites                ; insert girl sprites
  987.        
  988.         jmp restart_game                ; restart game!
  989.        
  990. chnge2_boy                              ; change to boy!
  991.  
  992.         jsr boy_sprites                 ; insert boy sprites
  993.                
  994. restart_game       
  995.         lda #01
  996.         sta level_num                   ; reset level to 1
  997.         sta last_level                  ; and last level to 1
  998.        
  999.         jmp get_ready_setup             ; back to get ready setup!
  1000.        
  1001.                                                                                
  1002. ; subroutines called from above code =====================     
  1003.  
  1004.  
  1005. ; clear screen subroutine ----------------------------------       
  1006.  
  1007. clear_screen
  1008.         ldx #$00                        ; zero x register      
  1009. clsloop
  1010.         lda #$20                        ; value for 'empty space'
  1011.         sta $0400,x                     ; clear screen ram
  1012.         sta $0500,x
  1013.         sta $0600,x
  1014.         sta $0700,x
  1015.         lda #$00                        ; value for black
  1016.         sta $d800,x                     ; clear colour ram
  1017.         sta $d900,x
  1018.         sta $da00,x
  1019.         sta $db00,x    
  1020.         inx
  1021.         bne clsloop
  1022.        
  1023.         rts                             ; return to where this was called from
  1024.                        
  1025. ; debounce subroutines for the joystick and keyboard -------------------
  1026.  
  1027. fire_debounce
  1028.         lda cpra                        ; keep looping here until the
  1029.         and #$10                        ; player decides to let the
  1030.         beq fire_debounce               ; fire button go
  1031.        
  1032.         rts
  1033.        
  1034. key_debounce       
  1035.         lda cprb                        ; is there a keypress still?
  1036.         cmp #$ff                        ; an idiot is still pressing something???
  1037.         bne key_debounce                ; lock them in a loop till they stop!!
  1038.        
  1039.         rts
  1040.    
  1041. ; irq sync wait subroutine ----------------------------------
  1042.          
  1043. sync_wait                               ; wait for sync update in irq code!
  1044.         lda #$00                        ; waits until the sync flag is
  1045.         sta sync                        ; set at the end of the interrupt
  1046. sw_loop                                 ; code further down.
  1047.         cmp sync                        ; no code in the main loop above
  1048.         beq sw_loop                     ; is executed until the interrupt
  1049.                                         ; has run it's course!
  1050.         rts
  1051.        
  1052. ; sync wait with fire button debounce  
  1053.  
  1054. sync_wait_long                     
  1055.         jsr sync_wait
  1056.    
  1057.         lda cpra
  1058.         and #$10
  1059.        
  1060.         bne dec_wait_tmr   
  1061.  
  1062.         jsr fire_debounce
  1063.         ldy #$01
  1064.        
  1065. dec_wait_tmr       
  1066.         dey
  1067.         bne sync_wait_long
  1068.    
  1069.         rts    
  1070.        
  1071. ; update 'rolling' message subroutine ---------------------
  1072.        
  1073. write_message
  1074.         ldx scroll_x
  1075.         cpx #$28
  1076.         bcs scroll_cnt
  1077.  
  1078. ; fetch a character from the text table
  1079.  
  1080. scroll_read
  1081.         ldy #$00
  1082.         lda (scroll_pos),y
  1083.         bne scroll_write
  1084.        
  1085.         jsr scroll_reset
  1086.        
  1087.         jmp scroll_read
  1088.  
  1089. ; write that character to the screen
  1090.        
  1091. scroll_write
  1092.         sta $06a8,x
  1093.        
  1094. ; move ghost sprite a little   
  1095.                
  1096.         lda t_sprite_x+$00
  1097.         clc
  1098.         adc #$04
  1099.         sta t_sprite_x+$00
  1100.         ldx scroll_x
  1101.         cpx #$27
  1102.         beq reset_ghost
  1103.        
  1104.         jmp update_txt_pos
  1105.        
  1106. reset_ghost
  1107.         lda #$00
  1108.         sta t_sprite_x+$00         
  1109.  
  1110. ; update the text position
  1111.  
  1112. update_txt_pos
  1113.         inc scroll_pos+$00
  1114.         bne *+$04
  1115.         inc scroll_pos+$01
  1116.  
  1117. ; store the current text position      
  1118.        
  1119. scroll_cnt
  1120.         inx
  1121.         stx scroll_x
  1122.        
  1123.         rts                             ; return to where this was called from
  1124.  
  1125. ; reset the scroll message     
  1126.                
  1127. scroll_reset
  1128.         lda #<mess_text
  1129.         sta scroll_pos+$00
  1130.         lda #>mess_text
  1131.         sta scroll_pos+$01
  1132.        
  1133.         rts                             ; return to where this was called from
  1134.            
  1135. ; title screen player select subroutine ------------------------
  1136.    
  1137. boy_select
  1138.  
  1139. ; first, insert sprites to make the boy dance
  1140. ; and the girl static on the title screen
  1141.  
  1142.         ldx #$d8
  1143.         stx t_sprite_def+$02            ; insert the values for the dancing boy
  1144.         stx t_sprite_anims+$02          ; animation!
  1145.         ldx #$dc
  1146.         stx t_sprite_anime+$02
  1147.        
  1148.         ldx #$dc
  1149.         stx t_sprite_def+$01            ; insert the values for still girl!
  1150.         stx t_sprite_anims+$01
  1151.         ldx #$dd
  1152.         stx t_sprite_anime+$01
  1153.  
  1154. ; now highlight the word boy and grey the word girl!       
  1155.                
  1156.         ldx #$00                        ; zero x register
  1157. boy_sel_loop                       
  1158.         lda #$0b                        ; load white
  1159.         sta $db51,x                     ; write 'boy' in white
  1160.         lda #$01                        ; load dark grey
  1161.         sta $db5d,x                     ; write 'girl' in dk grey
  1162.         inx
  1163.         cpx #$05                        ; done 5 writes?
  1164.         bne boy_sel_loop                ; all written? no? loop back!
  1165.        
  1166.         lda #$00                        ; make player store 0
  1167.         sta ply_type                    ; so boy is selected
  1168.  
  1169. ; finally, insert all the game sprites for the boy into
  1170. ; the sprite store to be used by the movement routine      
  1171.  
  1172. boy_sprites            
  1173.         lda #$ac
  1174.         sta playwalkleft_def
  1175.         sta playwalkleft_anims
  1176.         lda #$b0
  1177.         sta playwalkleft_anime
  1178.        
  1179.         lda #$a7
  1180.         sta playwalkright_def
  1181.         sta playwalkright_anims
  1182.         lda #$ab
  1183.         sta playwalkright_anime
  1184.        
  1185.         lda #$b1
  1186.         sta playjumpleft_def
  1187.         sta playjumpleft_anims
  1188.         lda #$b2
  1189.         sta playjumpleft_anime
  1190.        
  1191.         lda #$b0
  1192.         sta playjumpright_def
  1193.         sta playjumpright_anims
  1194.         lda #$b1
  1195.         sta playjumpright_anime
  1196.        
  1197.         lda #$ab
  1198.         sta playstatic_def
  1199.         sta playstatic_anims
  1200.         lda #$ac
  1201.         sta playstatic_anime
  1202.        
  1203.         lda #$b2
  1204.         sta playfall_def
  1205.         sta playfall_anims
  1206.         lda #$b3
  1207.         sta playfall_anime     
  1208.        
  1209.         lda #$01                        ; make player type 1
  1210.         sta ply_type                    ; which is the boy
  1211.        
  1212.         lda #$0a                        ; boy is 'stronger'...
  1213.         sta ply_strength
  1214.        
  1215.         lda #$ff                        ; ...but can't jump
  1216.         sta ply_jumppwr                 ; quite as far!
  1217.        
  1218.         rts
  1219.        
  1220. girl_select
  1221.  
  1222. ; first, insert sprites to make the girl dance
  1223. ; and the boy static on the title screen
  1224.  
  1225.         ldx #$d8
  1226.         stx t_sprite_def+$02            ; insert the values for a
  1227.         stx t_sprite_anims+$02          ; still boy
  1228.         ldx #$d9
  1229.         stx t_sprite_anime+$02
  1230.        
  1231.         ldx #$dc                        ; and values for a dancing
  1232.         stx t_sprite_def+$01            ; girl animation!
  1233.         stx t_sprite_anims+$01
  1234.         ldx #$e0
  1235.         stx t_sprite_anime+$01
  1236.  
  1237. ; now highlight the word girl and grey the word boy!       
  1238.                
  1239.         ldx #$00                        ; zero x register
  1240. girl_sel_loop                      
  1241.         lda #$01                        ; load white
  1242.         sta $db51,x                     ; write 'boy' in white
  1243.         lda #$0b                        ; load dark grey
  1244.         sta $db5d,x                     ; write 'girl' in dk grey
  1245.         inx
  1246.         cpx #$05                        ; done 5 writes?
  1247.         bne girl_sel_loop               ; all written? no? loop back!          
  1248.        
  1249.         lda #$01                        ; make player store 1
  1250.         sta ply_type                    ; so girl is selected
  1251.    
  1252. ; finally, insert all the game sprites for the girl into
  1253. ; the sprite store to be used by the movement routine
  1254.  
  1255. girl_sprites       
  1256.         lda #$b8
  1257.         sta playwalkleft_def
  1258.         sta playwalkleft_anims
  1259.         lda #$bc
  1260.         sta playwalkleft_anime
  1261.        
  1262.         lda #$b3
  1263.         sta playwalkright_def
  1264.         sta playwalkright_anims
  1265.         lda #$b7
  1266.         sta playwalkright_anime
  1267.        
  1268.         lda #$bd
  1269.         sta playjumpleft_def
  1270.         sta playjumpleft_anims
  1271.         lda #$be
  1272.         sta playjumpleft_anime
  1273.        
  1274.         lda #$bc
  1275.         sta playjumpright_def
  1276.         sta playjumpright_anims
  1277.         lda #$bd
  1278.         sta playjumpright_anime
  1279.        
  1280.         lda #$b7
  1281.         sta playstatic_def
  1282.         sta playstatic_anims
  1283.         lda #$b8
  1284.         sta playstatic_anime
  1285.        
  1286.         lda #$be
  1287.         sta playfall_def
  1288.         sta playfall_anims
  1289.         lda #$bf
  1290.         sta playfall_anime         
  1291.        
  1292.         lda #$00                        ; make player type 0
  1293.         sta ply_type                    ; which is the girl
  1294.        
  1295.         lda #$09                        ; girl is 'weaker'...
  1296.         sta ply_strength           
  1297.        
  1298.         lda #$fe                        ; ...but can jump
  1299.         sta ply_jumppwr                 ; a bit further!
  1300.                    
  1301.         rts    
  1302.                
  1303. ; hide sprites subroutine ---------------------------------------
  1304.  
  1305. hide_sprites
  1306.         ldx #$00                        ; load x register with 0
  1307. hide_sprites_loop                       ; now loop through all 8
  1308.         lda sprite_x_hide,x             ; hardware sprites and write
  1309.         sta sprite_x,x                  ; 0's into x and y positions
  1310.         lda sprite_y_hide,x             ; to hide the sprites
  1311.         sta sprite_y,x                  ; off-screen
  1312.         inx
  1313.         cpx #$08
  1314.         bne hide_sprites_loop
  1315.        
  1316.         rts
  1317.  
  1318. ; player movement subroutine ---------------------------------------       
  1319.                
  1320. player_move
  1321.         lda #$00                        ; start with loading 0
  1322.         sta ply_move_flag               ; into the move flag
  1323.        
  1324. ; press fire on joystick test...
  1325.  
  1326. joy_fire
  1327.         lda #$7f
  1328.         sta cpra
  1329.  
  1330.         lda cpra                        ; stick button pressed?
  1331.         and #$10
  1332.         bne joy_left                    ; nope? go and check left!
  1333.                                         ; yes?
  1334.         ldx gravity_on                  ; is gravity already on?
  1335.         cpx #$01                        ; yes?
  1336.         beq joy_left                    ; then go and check left!
  1337.        
  1338.         lda #<sfx_jump                  ; start address of the jump sound effect
  1339.         ldy #>sfx_jump
  1340.         ldx #$0e                        ; use channel 3
  1341.         jsr music+$06                   ; call the sfx driver and play effect!
  1342.  
  1343.         ldx #$fd
  1344.         stx gravity_strength
  1345.         ldx ply_jumppwr
  1346.         stx gravity_timer
  1347.         ldx #$01
  1348.         stx gravity_on     
  1349.  
  1350. ; pull left on joystick test...
  1351.  
  1352. joy_left
  1353.         lda cpra                        ; stick being pushed left?
  1354.         and #$04
  1355.         bne joy_right                   ; nope? go and check right!
  1356.                                         ; it is being pushed left?
  1357.         ldx gravity_on                  ; ok, lets see if the gravity...
  1358.         cpx #$01                        ; ...is active first!
  1359.         beq do_jump_left                ; it's active? jump left then!
  1360.                                         ; no gravity? ok, then...
  1361.         ldx sprite_def+$00              ; load the current player sprite def
  1362.         cpx playstatic_def              ; is it the static sprite? we're still?
  1363.         beq setup_move_left             ; yes? better sort the left walk animation!
  1364.                                         ; what if we're not still?
  1365.         ldx sprite_def+$00         
  1366.         cpx playjumpleft_def
  1367.         bne joy_left_move
  1368.        
  1369. setup_move_left    
  1370.         ldx playwalkleft_def
  1371.         stx sprite_def+$00
  1372.         stx sprite_anims+$00
  1373.         ldx playwalkleft_anime
  1374.         stx sprite_anime+$00
  1375.        
  1376.         jmp joy_left_move
  1377.        
  1378. do_jump_left
  1379.         ldx playjumpleft_def
  1380.         stx sprite_def+$00
  1381.         stx sprite_anims+$00
  1382.         ldx playjumpleft_anime
  1383.         stx sprite_anime+$00   
  1384.        
  1385. joy_left_move
  1386.  
  1387.         ldx sprite_x
  1388.         dex
  1389.         cpx #$0a
  1390.         bcc *+$05
  1391.         stx sprite_x
  1392.  
  1393.         inc ply_move_flag
  1394.  
  1395. ; pull right on joystick test...
  1396.  
  1397. joy_right
  1398.         lda cpra
  1399.         and #$08
  1400.         bne joy_exit
  1401.  
  1402.         ldx gravity_on
  1403.         cpx #$01
  1404.         beq do_jump_right
  1405.  
  1406.         ldx sprite_def+$00
  1407.         cpx playstatic_def
  1408.         beq setup_move_right
  1409.        
  1410.         ldx sprite_def+$00
  1411.         cpx playjumpright_def
  1412.         bne joy_right_move
  1413.  
  1414. setup_move_right
  1415.         ldx playwalkright_def
  1416.         stx sprite_def+$00
  1417.         stx sprite_anims+$00
  1418.         ldx playwalkright_anime
  1419.         stx sprite_anime+$00
  1420.        
  1421.         jmp joy_right_move     
  1422.        
  1423. do_jump_right
  1424.         ldx playjumpright_def
  1425.         stx sprite_def+$00
  1426.         stx sprite_anims+$00
  1427.         ldx playjumpright_anime
  1428.         stx sprite_anime+$00           
  1429.  
  1430. joy_right_move
  1431.         ldx sprite_x
  1432.         inx
  1433.         cpx #$a2
  1434.         bcs *+$05
  1435.         stx sprite_x
  1436.  
  1437.         inc ply_move_flag
  1438.        
  1439. ; check if gravity is on, if so perform gravity magic!
  1440.                
  1441. joy_exit
  1442.         lda gravity_on
  1443.         cmp #$01
  1444.         bne slow_player
  1445.  
  1446.         lda sprite_y+$00
  1447.         clc
  1448.         adc gravity_strength
  1449.         sta sprite_y+$00
  1450.  
  1451.         ldx gravity_timer
  1452.         inx
  1453.         cpx #$04
  1454.         bne exit_gravity
  1455.  
  1456.         ldx gravity_strength
  1457.         inx
  1458.         cpx #$05
  1459.         bne *+$04
  1460.         ldx #$04
  1461.         stx gravity_strength
  1462.        
  1463.         ldx #$00
  1464. exit_gravity
  1465.         stx gravity_timer
  1466.        
  1467. ; check if the player moving, if so slow 'x' movement
  1468. ; otherwise display static player sprite
  1469.  
  1470. slow_player
  1471.         lda ply_move_flag
  1472.         cmp #$00
  1473.         beq ply_no_anim
  1474.  
  1475.         lda ply_move_timer
  1476.         adc #$01
  1477.         and #$07
  1478.         sta ply_move_timer
  1479.         cmp #$04
  1480.         bcc ply_move_exit
  1481.        
  1482.         jmp ply_move_exit  
  1483.            
  1484. ply_no_anim                             ; the player isn't moving the joystick?
  1485.         lda gravity_on                  ; let's check if gravity is on!
  1486.         cmp #$01           
  1487.         beq ply_freefall                ; yes, gravity is active? goto to freefall!
  1488.                                         ; gravity is not active?
  1489.         lda playstatic_def              ; the static player sprite...
  1490.         sta sprite_def+$00              ; ...needs to be shown then
  1491.         sta sprite_anims+$00            ; because there is no input
  1492.         lda playstatic_anime            ; from the player!
  1493.         sta sprite_anime+$00
  1494.        
  1495.         jmp ply_move_exit               ; exit the the movement routines!
  1496.  
  1497. ply_freefall                            ; ok, we have some gravity because         
  1498.         lda playfall_def                ; the player is in the air either
  1499.         sta sprite_def+$00              ; falling or jumping!
  1500.         sta sprite_anims+$00            ; therefore, show the fall/jump
  1501.         lda playfall_anime              ; sprite frame!
  1502.         sta sprite_anime+$00       
  1503.        
  1504. ply_move_exit                           ; all movement checks complete
  1505.  
  1506.         rts                             ; go back to main game loop!
  1507.  
  1508. ; player to enemy sprites subroutine ----------------------------
  1509.  
  1510. player_collision
  1511.         lda #$00                        ; set the colls flag to 0
  1512.         sta ply_colls_flag
  1513.  
  1514.         lda sprite_x+$00                ; setup a 'bounding box'
  1515.         sec                             ; around the player sprite
  1516.         sbc #$04                        ; for software collision
  1517.         sta coll_temp+$00               ; detection
  1518.         clc                             ; grab the some x positions
  1519.         adc #$09                        ; for our player sprite which  
  1520.         sta coll_temp+$01               ; is sprite 0! 
  1521.  
  1522.         lda sprite_y+$00                ; and do the same for some y
  1523.         sec                             ; positions of sprite 0
  1524.         sbc #$0a
  1525.         sta coll_temp+$02               ; the x and y positions are
  1526.         clc                             ; stored in the 'coll_temp'
  1527.         adc #$16                        ; labels
  1528.         sta coll_temp+$03
  1529.  
  1530. ; check for collision with the cross       
  1531.  
  1532.         lda sprite_x+$01                ; now grab the x postion of the cross
  1533.         cmp coll_temp+$00               ; from the sprite table
  1534.         bcc enemy_colls_chk             ; and check against our 'bounding box'
  1535.         cmp coll_temp+$01               ; coordinates to see if they   
  1536.         bcs enemy_colls_chk             ; overlap...
  1537.  
  1538.         lda sprite_y+$01                ; and do the same for the y coordinates
  1539.         cmp coll_temp+$02
  1540.         bcc enemy_colls_chk             ; if no coordinates overlap, skip down
  1541.         cmp coll_temp+$03               ; to 'enem_colls_skip'
  1542.         bcs enemy_colls_chk
  1543.                                         ; if coordinates ARE overlapping       
  1544.         lda #$01                        ; load the player colls flag with 1
  1545.         sta ply_colls_flag              ; as cross has been touched
  1546.        
  1547. ; check for collision with the meanies
  1548.                
  1549. enemy_colls_chk
  1550.         ldx #$00
  1551. enem_colls_loop
  1552.         ldy colls_timer                 ; first load up the collision timer
  1553.         iny                             ; and increase it by '1'
  1554.         cpy ply_strength                ; is the timer equal to 'ply_strength' yet?
  1555.         bne coll_tmr_skip               ; no? go down to coll_tmr_skip
  1556.                                         ; and skip collision checking
  1557.                                
  1558.         lda sprite_x+$02,x              ; now grab the x postion of each sprite
  1559.         cmp coll_temp+$00               ; from the sprite table
  1560.         bcc enem_colls_skip             ; and check against our 'bounding box'
  1561.         cmp coll_temp+$01               ; coordinates to see if they   
  1562.         bcs enem_colls_skip             ; overlap...
  1563.  
  1564.         lda sprite_y+$02,x              ; and do the same for the y coordinates
  1565.         cmp coll_temp+$02
  1566.         bcc enem_colls_skip             ; if no coordinates overlap, skip down
  1567.         cmp coll_temp+$03               ; to 'enem_colls_skip'
  1568.         bcs enem_colls_skip
  1569.                                         ; if some coordinates overlap, collision!
  1570.         dec ply_energy                  ; decrease the player energy flag by 1
  1571.        
  1572.         jsr energy_bar                  ; redraw the energy bar
  1573.        
  1574.         lda ply_energy                  ; is the player out of energy?
  1575.         cmp #$00                         
  1576.         bne enem_colls_skip             ; no? go down to 'enem_colls_skip'
  1577.        
  1578.         jmp energy_out                  ; yes? go down to 'energy_out'
  1579.  
  1580. enem_colls_skip
  1581.         inx
  1582.         cpx #$07
  1583.         bne enem_colls_loop
  1584.  
  1585.         ldy #$00                        ; load x register with '0' 
  1586. coll_tmr_skip                           ; to reset collision timer and...              
  1587.         sty colls_timer                 ; store x register to colls_timer
  1588.  
  1589.         lda sprite_y+$00                ; load up the player y position
  1590.         cmp #$01                        ; is it off the ground?
  1591.         bcs bkgrd_coll_start            ; yes? better check background collisions
  1592.  
  1593.         rts                             ;  go back to main game loop
  1594.  
  1595. ; check for collision with the background
  1596.  
  1597.         lda sprite_x+$00
  1598.         cmp #$22
  1599.         bcs bkgrd_coll_start
  1600.  
  1601.         rts
  1602.  
  1603. ; sprite y coord higher than $32 so do background collision checks
  1604.  
  1605. bkgrd_coll_start   
  1606.         sec
  1607.         sbc #$1c
  1608.         lsr
  1609.         lsr
  1610.         lsr
  1611.         tax
  1612.         lda screen_low,x
  1613.         sta pcol_read+$01
  1614.         lda screen_high,x
  1615.         sta pcol_read+$02
  1616.  
  1617.         lda sprite_x+$00
  1618.         sec
  1619.         sbc #$09
  1620.         lsr
  1621.         lsr
  1622.         tax
  1623.         jsr pcol_read
  1624.         sta coll_temp+$00
  1625.         inx
  1626.         jsr pcol_read
  1627.         sta coll_temp+$01
  1628.  
  1629.         ldy coll_temp+$00
  1630.         lda chargrav_data,y
  1631.         cmp #$01
  1632.         beq grav_kill
  1633.        
  1634.         ldy coll_temp+$01
  1635.         lda chargrav_data,y
  1636.         cmp #$01
  1637.         beq grav_kill
  1638.                        
  1639.         lda #$01
  1640.         sta gravity_on
  1641.        
  1642.         jmp grav_chk_finish
  1643.  
  1644. ; self modifying code for player background collision
  1645.  
  1646. pcol_read
  1647.         lda $6464,x                     ; black magic and evil spirits... :D
  1648.         rts
  1649.  
  1650. ; player sprite is "standing" on something, so kill gravity effect
  1651.  
  1652. grav_kill
  1653.         lda gravity_strength
  1654.         cmp #$80
  1655.         bcc *+$03
  1656.        
  1657.         rts
  1658.  
  1659.         lda #$00
  1660.         sta gravity_timer
  1661.         sta gravity_strength
  1662.         sta gravity_on
  1663.        
  1664.         lda sprite_y+$00
  1665.         and #$f8
  1666.         clc
  1667.         adc #$05
  1668.         sta sprite_y+$00
  1669.  
  1670. ; gravity check is over, now check for other background collisions
  1671.                
  1672. grav_chk_finish
  1673.  
  1674.         ldy coll_temp+$00
  1675.         lda chardrain_data,y
  1676.         cmp #$01
  1677.         beq bkgrd_colls_loop
  1678.        
  1679.         ldy coll_temp+$01
  1680.         lda chardrain_data,y
  1681.         cmp #$01
  1682.         beq bkgrd_colls_loop
  1683.        
  1684.         jmp bkgrd_chk_end               ; no collision detected? end checks!
  1685.        
  1686. ; collision detected, so drain energy but with a timer to limit drain      
  1687.  
  1688. bkgrd_colls_loop
  1689.         ldy bkgd_coll_timer             ; first load up the collision timer
  1690.         iny                             ; and increase it by '1'
  1691.         cpy ply_strength                ; is the timer equal to player strength?
  1692.         bne bkgrd_colls_skip            ; no? go down to bkgrd_colls_skip
  1693.                                         ; and skip collision checking
  1694.         lda ply_energy
  1695.         dec ply_energy
  1696.         jsr energy_bar
  1697.        
  1698.         lda ply_energy                  ; is the player out of energy?
  1699.         cmp #$00
  1700.         bne reset_bacoll_tmr            ; no? go down to 'reset_bacoll_tmr'
  1701.        
  1702.         jmp energy_out                  ; yes? skip down to 'energy_out'
  1703.  
  1704. reset_bacoll_tmr                        ; reset the background collision timer             
  1705.         ldy #$00
  1706. bkgrd_colls_skip
  1707.         sty bkgd_coll_timer             ; store y register to bkgd_coll_timer
  1708.        
  1709. ; end of background checks!    
  1710.        
  1711. bkgrd_chk_end                           ; all background checks are complete...
  1712.  
  1713.         rts                             ; ...return to main game loop!
  1714.  
  1715. ; energy depleted/set death flag subroutine ----------------------
  1716.                    
  1717. energy_out
  1718.         lda #$02                        ; load the player colls flag with  
  1719.         sta ply_colls_flag              ; 2 because all the energy is gone!
  1720.                                         ; then...
  1721.         rts                             ; go back to main game loop where
  1722.                                         ; player will be killed!!!! MWHAAAA!   
  1723.                                                
  1724. ; energy bar drawing subroutine ----------------------------------
  1725.  
  1726. energy_bar
  1727.         ldy #$00                        ; update the energy bar!
  1728.         lda #$20
  1729. clr_energy_loop                         ; clear the row of chars that display the
  1730.         sta $07c7,y                     ; energy bar by printing a line of
  1731.         iny                             ; blank spaces!
  1732.         cpy #$21
  1733.         bne clr_energy_loop
  1734.        
  1735.         ldy #$00               
  1736.         lda #$40
  1737. drw_energy_loop                         ; now redraw the energy bar with char $40
  1738.         sta $07c7,y                     ; (the block making up the bar)
  1739.         iny                             ; equal to the amount of energy
  1740.         cpy ply_energy                  ; remaining
  1741.         bne drw_energy_loop
  1742.        
  1743.         rts                             ; go back to wherever this was called from!
  1744.        
  1745. ; in-game status bar initial print routine ------------------------
  1746.  
  1747. status_bar
  1748.         ldx #$00
  1749. status_print
  1750.         lda status_screen_ram,x
  1751.         sta $0798,x
  1752.         lda status_colour_ram,x
  1753.         sta $db98,x    
  1754.         inx
  1755.         cpx #$50
  1756.         bne status_print
  1757.        
  1758.         rts                    
  1759.  
  1760. ; in-game status bar update subroutine ----------------------------    
  1761.        
  1762. update_status
  1763.         ldx #$00                        ; load x register with 0
  1764. score_print_g
  1765.         lda score,x                     ; read each digit of the score table
  1766.         ora #$30
  1767.         sta $079f,x                     ; write to the screen
  1768.         lda high_score,x                ; read each digit of high socre table
  1769.         ora #$30
  1770.         sta $07ba,x                     ; write to screen
  1771.         inx
  1772.         cpx #$06                        ; do this 6 times for 6 digit score!
  1773.         bne score_print_g
  1774.  
  1775.         ldx #$00                        ; load x register with 0   
  1776. cross_print
  1777.         lda cross_score,x               ; read each digit of the cross table
  1778.         ora #$30
  1779.         sta $07ae,x                     ; write to the screen
  1780.         inx
  1781.         cpx #$02                        ; repeat twice because 2 digit number!
  1782.         bne cross_print    
  1783.        
  1784.         rts                             ; return to main loop
  1785.        
  1786. ; cross accrue subroutine ------------------------------------         
  1787.        
  1788. cross_accrue
  1789.  
  1790.         lda cross_num
  1791.         inc cross_num                   ; increase cross variable by 1
  1792.  
  1793.         ldx #$01                        ; give the player 1 cross!
  1794. ca_loop
  1795.         lda cross_score,x
  1796.         clc
  1797.         adc #$01
  1798.         cmp #$0a
  1799.         beq ca_cnt
  1800.         sta cross_score,x
  1801.        
  1802.         jmp cross_check
  1803.        
  1804. ca_cnt 
  1805.         lda #$00
  1806.         sta cross_score,x
  1807.         dex
  1808.         cpx #$ff
  1809.         bne ca_loop
  1810.        
  1811. ; now check if 20 crosses have been collected!
  1812.                
  1813. cross_check                    
  1814.         ldx #$00
  1815.         lda cross_score,x               ; load up the tens column of the cross score
  1816.        
  1817.         cmp #$02                        ; is there a '2' in the tens?
  1818.         bne cross_move                  ; no? go down to 'cross_move'
  1819.                                         ; yes?
  1820.         lda #$01                        ; set the level complete flag to 1
  1821.         sta level_comp_flag             ; and go back to main game loop
  1822.                                         ; where level will be completed!
  1823.         rts
  1824.        
  1825. ; move the cross to next position on the screen
  1826.    
  1827. cross_move                     
  1828.         ldx cross_num           ; load the cross_num variable into x register
  1829.         lda cross_x,x           ; grab x-reg value from cross x coord table
  1830.         sta sprite_x+$01        ; store table value in sprite 1 x coord table
  1831.         lda cross_y,x           ; grab x-reg value from cross y coord table
  1832.         sta sprite_y+$01        ; store table value in sprite 1 y coord table
  1833.        
  1834.         rts                     ; return to main loop
  1835.        
  1836. ; score accrue subroutine ------------------------------------         
  1837.  
  1838. score_accrue_100                ; give player 100 points
  1839.         ldx #$03                ; load 3 to x register
  1840.        
  1841.         jmp sa_loop             ; jump down to sa_loop
  1842.  
  1843. score_accrue_1000               ; give players 1000 points
  1844.         ldx #$02                ; load 2 to x register
  1845.        
  1846. sa_loop
  1847.         lda score,x             ; jump to x reg position in score table
  1848.         clc                     ; clear carry
  1849.         adc #$01                ; add 1
  1850.         cmp #$0a                ; compare to 10
  1851.         beq sa_cnt              ; if 10, go down to sa_cnt to change column
  1852.         sta score,x             ; else store to x reg position in score table
  1853.  
  1854.         jmp score_compare       ; jump down to score_compare
  1855.  
  1856. sa_cnt 
  1857.         lda #$00
  1858.         sta score,x
  1859.         dex
  1860.         cpx #$ff
  1861.         bne sa_loop
  1862.  
  1863. ; now compare current score to high score
  1864.  
  1865. score_compare
  1866.         ldx #$00
  1867. score_chk
  1868.         lda score,x
  1869.         cmp high_score,x
  1870.         beq score_chk_cnt
  1871.         bcc score_chk_end
  1872.         bcs hi_score_update
  1873. score_chk_cnt  
  1874.         inx
  1875.         cpx #$06
  1876.         bne score_chk
  1877. score_chk_end
  1878.  
  1879.         rts
  1880.  
  1881. ; current score is a high score???
  1882.  
  1883. hi_score_update
  1884.         ldx #$00                ; start at first digit
  1885. hi_up_loop
  1886.         lda score,x             ; copy current digit score table to...
  1887.         sta high_score,x        ; ...current digit high score table
  1888.         inx                     ; now next digit
  1889.         cpx #$06                ; repeat 6 times because 6 digit scores
  1890.         bne hi_up_loop          ; 6 done yet? no? up to hi_up_loop
  1891.                                 ; yes?
  1892.         rts                     ; return to main loop
  1893.        
  1894. ; update title sprites 'y' position to 'bounce' them
  1895.  
  1896. bounce_title
  1897.  
  1898.         ldx bounce_timer            ; load up the bounce_timer
  1899.         inx                         ; increase it by '1'
  1900.         cpx #$03                    ; is the timer equal to '4' yet?
  1901.         bne bounce_skip             ; no? don't update movement
  1902.                                     ; yes? better do some moving then!
  1903.         ldx #$00
  1904. t_sprite_y_upd
  1905.         lda t_spr_y_dir,x
  1906.         cmp #$01
  1907.         beq t_sprite_up
  1908.        
  1909.         lda sprite_y,x
  1910.         clc
  1911.         adc #$02
  1912.         sta sprite_y,x
  1913.         cmp #$4a
  1914.         bcc t_next_sprite
  1915.         lda #$01
  1916.         sta t_spr_y_dir,x
  1917.         jmp t_next_sprite
  1918.                    
  1919. t_sprite_up
  1920.         lda sprite_y,x
  1921.         sec
  1922.         sbc #$02
  1923.         sta sprite_y,x     
  1924.         cmp #$3e
  1925.         bcs t_next_sprite
  1926.         lda #$00
  1927.         sta t_spr_y_dir,x
  1928.  
  1929. t_next_sprite
  1930.         inx
  1931.         cpx #$08
  1932.         bne t_sprite_y_upd
  1933.        
  1934.         ldx #$00                    ; load x register with '0'
  1935. bounce_skip                         ; to reset anim_timer and...   
  1936.         stx bounce_timer            ; store x register to anim_timer
  1937.        
  1938.         rts    
  1939.  
  1940. ; enemy movement processor subroutine ------------------------     
  1941.  
  1942. process_enemies
  1943.  
  1944.         ldy enemy_timer             ; load up the enemy timer
  1945.         iny                         ; increase it by '1'
  1946.         cpy #$02                    ; is the timer equal to '3' yet?
  1947.         beq move_enemies            ; yes? then 'move_enemies'
  1948.                                     ; no?
  1949.         jmp enemy_move_skip         ; jump down to enemy_move_skip!
  1950.        
  1951. move_enemies
  1952.                
  1953. ; deal with the vertical moving enemies first
  1954. ; spider 1 and 2 (sprites 2 and 3)
  1955.  
  1956.         ldx #$02                    ; start on sprite 2
  1957. enemy_vert_check
  1958.         lda sprite_dir,x            ; which direction is it moving?
  1959.         cmp #$01                    ; down?
  1960.         beq enemy_vert1             ; yes, go down to enemy_vert1  
  1961.                                     ; no?
  1962.         lda sprite_y,x              ; load sprites y postion from table
  1963.         clc                         ; clear carry flag
  1964.         adc sprite_spd,x            ; add sprites speed table to y position
  1965.         sta sprite_y,x              ; store new y position
  1966.         cmp sprite_max,x            ; load sprites max y position
  1967.         bcc next_vert_enemy         ; not reached end of path? goto next_vert_enemy
  1968.         lda #$01                    ; reached end of path? change direction
  1969.         sta sprite_dir,x            ; store direction
  1970.         lda left_enm_def,x          ; load sprite defs and animation for up
  1971.         sta sprite_def,x
  1972.         sta sprite_anims,x
  1973.         lda left_enm_anime,x
  1974.         sta sprite_anime,x
  1975.         jmp next_vert_enemy         ; do next sprite!
  1976.  
  1977. enemy_vert1
  1978.         lda sprite_y,x
  1979.         sec
  1980.         sbc sprite_spd,x
  1981.         sta sprite_y,x     
  1982.         cmp sprite_min,x
  1983.         bcs next_vert_enemy
  1984.         lda #$00
  1985.         sta sprite_dir,x
  1986.         lda rite_enm_def,x
  1987.         sta sprite_def,x
  1988.         sta sprite_anims,x
  1989.         lda rite_enm_anime,x
  1990.         sta sprite_anime,x     
  1991.        
  1992. next_vert_enemy
  1993.         inx
  1994.         cpx #$04
  1995.         bne enemy_vert_check
  1996.        
  1997. ; now deal with the horizontal moving enemies
  1998. ; zombie, ghost, bat, witch (sprites 4 - 7)    
  1999.                
  2000. enemy_hori_check
  2001.         lda sprite_dir,x
  2002.         cmp #$01
  2003.         beq enemy_hori1
  2004.        
  2005.         lda sprite_x,x
  2006.         clc
  2007.         adc sprite_spd,x
  2008.         sta sprite_x,x
  2009.         cmp sprite_max,x
  2010.         bcc next_hori_enemy
  2011.         lda #$01
  2012.         sta sprite_dir,x
  2013.         lda left_enm_def,x
  2014.         sta sprite_def,x
  2015.         sta sprite_anims,x
  2016.         lda left_enm_anime,x
  2017.         sta sprite_anime,x
  2018.         jmp next_hori_enemy
  2019.  
  2020. enemy_hori1
  2021.         lda sprite_x,x
  2022.         sec
  2023.         sbc sprite_spd,x
  2024.         sta sprite_x,x     
  2025.         cmp sprite_min,x
  2026.         bcs next_hori_enemy
  2027.         lda #$00
  2028.         sta sprite_dir,x
  2029.         lda rite_enm_def,x
  2030.         sta sprite_def,x
  2031.         sta sprite_anims,x
  2032.         lda rite_enm_anime,x
  2033.         sta sprite_anime,x     
  2034.        
  2035. next_hori_enemy
  2036.         inx
  2037.         cpx #$08
  2038.         bne enemy_hori_check
  2039.  
  2040.         ldy #$00                    ; load x register with 0
  2041. enemy_move_skip                     ; to reset enemy move timer
  2042.         sty enemy_timer             ; and store to timer!
  2043.        
  2044.         rts                         ; go back to main loop!
  2045.        
  2046. ; background animations subroutine ----------------------------------      
  2047.  
  2048. process_bkgd_anims
  2049.        
  2050.         ldy bkgd_timer              ; load up the bkgrd anim timer
  2051.         iny                         ; increase it by '1'
  2052.         tya                         ; transfer to accum
  2053.         cmp bkgd_lvl_tmr            ; compare to level specific anim speed
  2054.         beq bkgd_anim_chk           ; it's time to animate? animate then!
  2055.            
  2056.         jmp bkgrd_anim_skip         ; no? skip background anims
  2057.                                
  2058. bkgd_anim_chk
  2059.  
  2060.         lda level_num               ; which level are we on?
  2061.        
  2062.         cmp #$02                    ; level 2?
  2063.         bne *+$05                   ; no? branch to level 3 check
  2064.         jmp flame_anim              ; yes? jump to flame animation!
  2065.            
  2066.         cmp #$03                    ; level 3?
  2067.         bne *+$05                   ; no? branch to next check
  2068.         jmp rain_anim               ; yes? jump to rain anim!
  2069.        
  2070.         cmp #$04                    ; etc, etc!
  2071.         bne *+$05
  2072.         jmp flame_anim
  2073.        
  2074.         cmp #$05                    ; etc, etc!
  2075.         bne *+$05
  2076.         jmp slime_anim
  2077.        
  2078.         cmp #$06                    ; etc, etc!
  2079.         bne *+$05
  2080.         jmp cinema_anim
  2081.        
  2082.         cmp #$07                    ; etc, etc!
  2083.         bne *+$05
  2084.         jmp rain_anim
  2085.        
  2086.         cmp #$08                    ; etc, etc!
  2087.         bne *+$05
  2088.         jmp slime_anim
  2089.        
  2090.         cmp #$09                    ; etc, etc!
  2091.         bne *+$05
  2092.         jmp snow_anim      
  2093.        
  2094.         cmp #$0a                    ; etc, etc!
  2095.         bne *+$05
  2096.         jmp slime_anim
  2097.        
  2098.         cmp #$0b                    ; etc, etc!
  2099.         bne *+$05
  2100.         jmp flame_anim
  2101.        
  2102.         cmp #$0c                    ; etc, etc!
  2103.         bne *+$05
  2104.         jmp slime_anim                                                                     
  2105.        
  2106.         jmp reset_bkgrd_anim_tmr    ; no anim? reset the timer!
  2107.        
  2108. ; flame anim subroutine                                            
  2109.                                    
  2110. flame_anim                          ; flame animation                              
  2111.                                    
  2112.         ldx #$00                    ; zero x register
  2113. flame_ror
  2114.         lda $2390,x                 ; load mem location of the flame char
  2115.         lsr
  2116.         lsr
  2117.         lsr
  2118.         ror $2390,x                 ; shift byte of the char to the right
  2119.         ror $2390,x                 ; shift byte of the char to the right
  2120.         ror $2390,x                 ; shift byte of the char to the right              
  2121.         inx
  2122.         cpx #$08                    ; all 8 bytes done?
  2123.         bne flame_ror               ; no? do the next byte then!
  2124.        
  2125.         jmp reset_bkgrd_anim_tmr
  2126.  
  2127. ; slime anim subroutine
  2128.                        
  2129. slime_anim                          ; slime animation                              
  2130.  
  2131. ; horizontal slime
  2132.                                    
  2133.         ldx #$00                    ; zero x register
  2134. slime_rol
  2135.         lda $2738,x                 ; load mem location of the slime char
  2136.         asl
  2137.         rol $2738,x                 ; shift byte of the char to the left       
  2138.         inx
  2139.         cpx #$08                    ; all 8 bytes done?
  2140.         bne slime_rol               ; no? do the next byte then!
  2141.  
  2142. ; vertical slime (char location $2550 to $2557)
  2143.  
  2144.         lda $2557
  2145.         sta chardown_temp
  2146.        
  2147. slime_down
  2148.         lda $2550-1,x
  2149.         sta $2550,x
  2150.         dex
  2151.         bpl slime_down
  2152.        
  2153.         lda chardown_temp
  2154.         sta $2550
  2155.                
  2156.         jmp reset_bkgrd_anim_tmr
  2157.        
  2158. ; snowfall anim subroutine
  2159.  
  2160. snow_anim
  2161.         lda snowstrip           ; which snow strip should move?
  2162.         cmp #$01                ; strip 2?
  2163.         beq snow_fall2          ; yes? do strip 2 then!
  2164.                                 ; no? then do strip 1!
  2165. ; move snow strip 1...
  2166. ; shift snow char 196 a pixel down!
  2167. ; (char location $2620 to $2627)       
  2168.  
  2169. snow_fall1                      ; move strip 1         
  2170.         lda $2627               ; load up the last byte of the char
  2171.         sta chardown_temp       ; put it in a temporary byte store
  2172.  
  2173. snow_move1
  2174.         lda $2620-$01,x         ; now shift each byte down
  2175.         sta $2620,x             ; until 7 of the bytes are done
  2176.         dex
  2177.         bpl snow_move1
  2178.    
  2179.         lda chardown_temp       ; now put the byte that was originally
  2180.         sta $2620               ; last into in the first byte of the char
  2181.        
  2182.         lda #$01                ; next time, do snow strip 2!
  2183.         sta snowstrip
  2184.        
  2185.         jmp reset_bkgrd_anim_tmr       
  2186.  
  2187. ; move snow strip 2...
  2188. ; shift snow char 197 a pixel down!
  2189. ; (char location $2628 to $262f)   
  2190.  
  2191. snow_fall2                      ; as above, but for snow strip 2!
  2192.         lda $262f
  2193.         sta chardown_temp
  2194.        
  2195. snow_move2
  2196.         lda $2628-$01,x
  2197.         sta $2628,x
  2198.         dex
  2199.         bpl snow_move2
  2200.        
  2201.         lda chardown_temp
  2202.         sta $2628
  2203.                
  2204.         lda #$00                ; next time, do snow strip 1!
  2205.         sta snowstrip
  2206.  
  2207.         jmp reset_bkgrd_anim_tmr           
  2208.  
  2209. ; cinema screen anim subroutine (screen noise flicker animation)
  2210.            
  2211. cinema_anim
  2212.  
  2213.         lda cinescrn                ; which screen to draw to produce 'flicker'?
  2214.  
  2215.         cmp #$01                    ; turn of screen 1?
  2216.         bne *+$05                   ; no? go down and draw screen 0!                   
  2217.         jmp draw_scrn1              ; yes? draw screen 1!
  2218.        
  2219. draw_scrn0                          ; drawn screen 0
  2220.         ldx #$00                    ; zero the x register
  2221. scrn0_loop
  2222.         lda scrn0_patt,x            ; load a byte of screen 0 pattern
  2223.         sta $24f0,x                 ; shove it into the screen char
  2224.         inx                         ; increase x register by 1
  2225.         cpx #$08                    ; all 8 bytes done?
  2226.         bne scrn0_loop              ; no? go back and do next byte please...
  2227.                                     ; all 8 bytes of char are done! YAY!
  2228.         lda #$01                    ; next time around...
  2229.         sta cinescrn                ; ... screen 1 must be drawn!
  2230.  
  2231.         jmp draw_scrn_dun           ; screen 0 drawing all complete
  2232.        
  2233. draw_scrn1                          ; draw screen 1
  2234.         ldx #$00                    ; zero the x register
  2235. scrn1_loop
  2236.         lda scrn1_patt,x            ; load a byte of screen 1 patterm  
  2237.         sta $24f0,x                 ; shove it into the screen char
  2238.         inx                         ; increase x register by 1
  2239.         cpx #$08                    ; all 8 bytes are read and stored?
  2240.         bne scrn1_loop              ; wot? no? read another byte please!
  2241.                                     ; all 8 bytes are done! thanks mr. 6510!
  2242.         lda #$00                    ; next time through...
  2243.         sta cinescrn                ; ...screen 0 must be drawn!
  2244.            
  2245. draw_scrn_dun                       ; cinema screen drawing down
  2246.                                     ; so...
  2247.         jmp reset_bkgrd_anim_tmr    ; ...reset the background anim timer please!
  2248.                                                    
  2249. ; "i'm singing in that there rain..." anim subroutine
  2250.  
  2251. rain_anim                           ; cats and dogs animation
  2252.  
  2253. ; clear all raindrops first
  2254.  
  2255.         ldx #$00
  2256.         lda #$ff                    ; char needs to be solid!
  2257. clear_rain     
  2258.         sta $2400,x                 ; raindrop 1
  2259.         sta $2408,x                 ; raindrop 2
  2260.         sta $2410,x                 ; etc
  2261.         sta $2418,x
  2262.         sta $2420,x
  2263.         inx
  2264.         cpx #$08                    ; all 8 bytes of each char cleared?
  2265.         bne clear_rain              ; no? branch back
  2266.        
  2267. ; now check which raindrop should be drawn (rain_patt)
  2268.  
  2269.         lda raindrop
  2270.  
  2271.         cmp #$01
  2272.         bne *+$05
  2273.         jmp draw_rain1
  2274.        
  2275.         cmp #$02
  2276.         bne *+$05
  2277.         jmp draw_rain2
  2278.        
  2279.         cmp #$03
  2280.         bne *+$05
  2281.         jmp draw_rain3
  2282.        
  2283.         cmp #$04
  2284.         bne *+$05
  2285.         jmp draw_rain4                         
  2286.        
  2287. draw_rain0 
  2288.         ldx #$00
  2289. rain0_loop
  2290.         lda rain_patt,x    
  2291.         sta $2400,x
  2292.         inx
  2293.         cpx #$08
  2294.         bne rain0_loop
  2295.        
  2296.         jmp draw_rain_dun
  2297.        
  2298. draw_rain1 
  2299.         ldx #$00
  2300. rain1_loop
  2301.         lda rain_patt,x    
  2302.         sta $2408,x
  2303.         inx
  2304.         cpx #$08
  2305.         bne rain1_loop
  2306.        
  2307.         jmp draw_rain_dun
  2308.        
  2309. draw_rain2
  2310.         ldx #$00
  2311. rain2_loop
  2312.         lda rain_patt,x    
  2313.         sta $2410,x
  2314.         inx
  2315.         cpx #$08
  2316.         bne rain2_loop
  2317.        
  2318.         jmp draw_rain_dun
  2319.        
  2320. draw_rain3
  2321.         ldx #$00
  2322. rain3_loop
  2323.         lda rain_patt,x    
  2324.         sta $2418,x
  2325.         inx
  2326.         cpx #$08
  2327.         bne rain3_loop
  2328.        
  2329.         jmp draw_rain_dun
  2330.        
  2331. draw_rain4
  2332.         ldx #$00
  2333. rain4_loop
  2334.         lda rain_patt,x    
  2335.         sta $2420,x
  2336.         inx
  2337.         cpx #$08
  2338.         bne rain4_loop
  2339.        
  2340. draw_rain_dun
  2341.         lda raindrop
  2342.         inc raindrop
  2343.         cmp #$04
  2344.         bne reset_bkgrd_anim_tmr
  2345.         lda #$00
  2346.         sta raindrop
  2347.        
  2348.        
  2349. reset_bkgrd_anim_tmr                               
  2350.         ldy #$00                    ; load y register with '0'
  2351. bkgrd_anim_skip                     ; to reset bkgrd anim timer and... 
  2352.         sty bkgd_timer              ; store y register to bkgrd anim timer
  2353.    
  2354.         rts
  2355.  
  2356. ; in-game level music init subroutine -------------------------------      
  2357.  
  2358. lmusic_setup
  2359.  
  2360.         lda level_num               ; load the level number
  2361.        
  2362.         cmp #$01                    ; is it 1?
  2363.         bne *+$07                   ; no? check for level 2
  2364.         lda #$04                    ; yes? init level 1 music
  2365.         jmp lmusic_init_dun         ; insert into player!
  2366.        
  2367.         cmp #$02                    ; is it 2?
  2368.         bne *+$07                   ; no? check for level 3
  2369.         lda #$05                    ; yes? init level 2 music      
  2370.         jmp lmusic_init_dun         ; insert into player!
  2371.        
  2372.         cmp #$03                    ; etc, etc!
  2373.         bne *+$07
  2374.         lda #$02           
  2375.         jmp lmusic_init_dun
  2376.        
  2377.         cmp #$04
  2378.         bne *+$07
  2379.         lda #$06       
  2380.         jmp lmusic_init_dun
  2381.        
  2382.         cmp #$05
  2383.         bne *+$07
  2384.         lda #$07           
  2385.         jmp lmusic_init_dun
  2386.        
  2387.         cmp #$06
  2388.         bne *+$07
  2389.         lda #$09           
  2390.         jmp lmusic_init_dun
  2391.        
  2392.         cmp #$07                    ; is it 7
  2393.         bne *+$07
  2394.         lda #$04                    ; yes? resuse level 1 music
  2395.         jmp lmusic_init_dun         ; insert into player!      
  2396.  
  2397.         cmp #$08                    ; is it 8?
  2398.         bne *+$07
  2399.         lda #$05                    ; yes? reuse level 2 music     
  2400.         jmp lmusic_init_dun         ; insert into player!      
  2401.        
  2402.         cmp #$09                    ; etc, etc!
  2403.         bne *+$07
  2404.         lda #$02           
  2405.         jmp lmusic_init_dun
  2406.        
  2407.         cmp #$0a
  2408.         bne *+$07
  2409.         lda #$06       
  2410.         jmp lmusic_init_dun
  2411.  
  2412.         cmp #$0a
  2413.         bne *+$07
  2414.         lda #$07       
  2415.         jmp lmusic_init_dun
  2416.  
  2417.         cmp #$0c
  2418.         lda #$09       
  2419.        
  2420. lmusic_init_dun
  2421.         jsr music+$00               ; shove tune number into the music player
  2422.                
  2423.         rts                         ; go back to main loop!
  2424.                
  2425. ; end subroutines =====================================    
  2426.            
  2427.  
  2428. ; IRQ interrupt code =================================
  2429.  
  2430. int
  2431.         pha  
  2432.         txa
  2433.         pha
  2434.         tya
  2435.         pha
  2436.        
  2437.         lda $d019
  2438.         and #$01
  2439.         sta $d019
  2440.         bne intr_trigd
  2441.        
  2442.         jmp irq_exit                ; no interrupt triggered? exit irq code!
  2443.        
  2444. ; an interrupt has triggered!?!
  2445. ; which split should we run? let's check...
  2446.  
  2447. intr_trigd
  2448.  
  2449.         lda raster_num              ; load up the raster_num variable
  2450.        
  2451.         cmp #$02                    ; is it set to '2'?
  2452.         bne *+$05                   ; no? then jump down to check for '3'
  2453.         jmp irq_rout2               ; yes? jump down to irq_rout2!
  2454.  
  2455.         cmp #$03                    ; is the raster_num set to '3'?
  2456.         bne *+$05                   ; no? then jump down to check for '4'
  2457.         jmp irq_rout3               ; yes? jump down to irq_rout3!
  2458.        
  2459.         cmp #$04                    ; is the raster_num set to '4'?
  2460.         bne *+$05                   ; no? then jump down to check for '5'
  2461.         jmp irq_rout4               ; yes? jump down to irq_rout4!
  2462.        
  2463.         cmp #$05                    ; is the raster_num set to '5'?
  2464.         bne *+$05                   ; no? jump down and run irq_rout1!
  2465.         jmp irq_rout5               ; yes? jump down to irq_rout5!     
  2466.                
  2467. ; raster split 1 code -------------------------------
  2468.  
  2469. irq_rout1
  2470.  
  2471. ; set background to black
  2472. ; n.b. this split is small and black so that in levels
  2473. ; where the top 'border' is blue, the blue doesn't show
  2474. ; at the bottom of the screen when running under NTSC
  2475.  
  2476.         lda #$00                    ; change colour to black background
  2477.         sta $d021                   ; for top part of screen
  2478.        
  2479. ; set interrupt handler ready for split 2
  2480.  
  2481.         lda #$02                    ; next run through this interrupt code,
  2482.         sta raster_num              ; split 2 should execute, a bit
  2483.         lda #raster_2_pos           ; further down...
  2484.         sta $d012
  2485.        
  2486.         jmp irq_exit
  2487.        
  2488. ; raster split 2 code -------------------------------
  2489.  
  2490. irq_rout2
  2491.  
  2492. ; should top border be blue or black?
  2493.  
  2494.         lda tbordblue               ; is the top border flag set
  2495.         cmp #$01                    ; to 0 or 1?
  2496.         bne blackbord               ; it's not 1? set to black then!
  2497.                                     ; it is 1? ok then...
  2498.         lda #$06                    ; ...change colour to blue border
  2499.         sta $d021                   ; for top part of screen
  2500.        
  2501.         jmp split1_cont             ; continue split
  2502.  
  2503. blackbord      
  2504.         lda #$00                    ; change colour to black border
  2505.         sta $d021                   ; for top part of screen       
  2506.        
  2507. split1_cont    
  2508.        
  2509. ; set interrupt handler ready for split 3
  2510.  
  2511.         lda #$03                    ; next run through this interrupt code,
  2512.         sta raster_num              ; split 2 should execute, a bit
  2513.         lda #raster_3_pos           ; further down...
  2514.         sta $d012
  2515.        
  2516. ; set up and position the hardware sprites
  2517.        
  2518.         lda #$ff                    ; turn on..
  2519.         sta $d015                   ; all 8 sprites!
  2520.  
  2521.         lda title_mode
  2522.         cmp #$01
  2523.         bne game_sprites   
  2524.        
  2525. ; title_sprites    
  2526.        
  2527.         lda #$00                    ; make these sprites
  2528.         sta $d01c                   ; hires
  2529.  
  2530.         lda intro_mode
  2531.         cmp #$01
  2532.         beq skip_bounce
  2533.        
  2534.         jsr bounce_title
  2535.        
  2536. skip_bounce            
  2537.         jmp sprite_plotter     
  2538.  
  2539. ; game sprites     
  2540.                
  2541. game_sprites
  2542.         lda #$ff                    ; make these sprites
  2543.         sta $d01c                   ; multi-colour
  2544.                
  2545.         lda #$0b                    ; and add some colours
  2546.         sta $d025                   ; a nice grey and a
  2547.         lda #$01                    ; splash of white
  2548.         sta $d026                   ; will do nicely!
  2549.  
  2550. ; in-game sprite plotter!      
  2551.        
  2552. sprite_plotter     
  2553.         ldx #$00
  2554.         ldy #$00
  2555. sprite_plot
  2556.         lda sprite_x,x
  2557.         asl
  2558.         ror $d010
  2559.         sta $d000,y
  2560.         lda sprite_y,x
  2561.         sta $d001,y
  2562.         iny
  2563.         iny
  2564.         lda sprite_col,x
  2565.         sta $d027,x
  2566.         lda sprite_def,x
  2567.         sta $07f8,x    
  2568.         inx
  2569.         cpx #$08
  2570.         bne sprite_plot
  2571.        
  2572. ; in-game sprite animation routine!
  2573.                
  2574.         ldx anim_timer              ; load up the anim_timer
  2575.         inx                         ; increase it by '1'
  2576.         cpx #$04                    ; is the timer equal to '4' yet?
  2577.         bne game_anim_skip          ; no? don't update animation!
  2578.                                     ; yes? better do some animation then!
  2579.         ldx #$00
  2580. gau_loop
  2581.         lda sprite_def,x
  2582.         clc
  2583.         adc #$01
  2584.         cmp sprite_anime,x
  2585.         bne gau_skip
  2586.         lda sprite_anims,x
  2587. gau_skip
  2588.         sta sprite_def,x
  2589.         inx
  2590.         cpx #$08
  2591.         bne gau_loop                               
  2592.                                     ; yes?
  2593.         ldx #$00                    ; load x register with '0'
  2594. game_anim_skip                      ; to reset anim_timer and...   
  2595.         stx anim_timer              ; store x register to anim_timer       
  2596.  
  2597.         jmp irq_exit
  2598.        
  2599.    
  2600. ; raster split 3 code ------------------------------------
  2601.  
  2602. irq_rout3
  2603.  
  2604. ; set interrupt handler ready for split 3
  2605.    
  2606.         lda #$04
  2607.         sta raster_num
  2608.         lda #raster_4_pos
  2609.         sta $d012
  2610.  
  2611.         lda #$00                    ; black background
  2612.         sta $d021
  2613.        
  2614. ; play some music!
  2615.  
  2616.         lda video_type              ; what machine is being used
  2617.         cmp #$00                    ; PAL?
  2618.         beq call_music_driver       ; yes? play the music!
  2619.                                     ; no?
  2620.         ldx music_tmr               ; load music timer
  2621.         inx                         ; increase it
  2622.         cpx #$08                    ; is it 8?
  2623.         bne music_play              ; no? play music!
  2624.                                     ; yes?
  2625.         ldx #$00                    ; reset the timer
  2626.         stx music_tmr               ; then skip playing
  2627.                                     ; the music on this occasion
  2628.         jmp irq_exit                ; to slow it for ntsc!
  2629.  
  2630. music_play
  2631.         stx music_tmr
  2632. call_music_driver
  2633.         jsr music+$03              
  2634.  
  2635.         jmp irq_exit       
  2636.  
  2637. ; raster split 4 code ------------------------------------
  2638.  
  2639. irq_rout4
  2640.  
  2641. ; set interrupt handler ready for split 5
  2642.    
  2643.         lda #$05
  2644.         sta raster_num
  2645.         lda #raster_5_pos
  2646.         sta $d012  
  2647.                
  2648. ; are we in title screen mode?
  2649.  
  2650.         lda title_mode
  2651.         cmp #$01
  2652.         beq intro_chk               ; yes? skip down to 't_mode_do'
  2653.        
  2654.         jmp irq_exit
  2655.  
  2656. intro_chk      
  2657.         lda intro_mode
  2658.         cmp #$01
  2659.         bne t_mode_do
  2660.        
  2661.         jmp irq_exit
  2662.        
  2663. t_mode_do      
  2664.                
  2665. ; write the title screen rolling message
  2666.  
  2667.         jsr write_message      
  2668.        
  2669. ; set up recycled sprites for the bottom
  2670. ; of the title screen
  2671.  
  2672.         lda #$ff                    ; make these sprites
  2673.         sta $d01c                   ; multi-colour
  2674.                
  2675.         lda #$0b
  2676.         sta $d025
  2677.         lda #$01
  2678.         sta $d026
  2679.        
  2680.         ldx #$00
  2681.         ldy #$00
  2682. sprite_plot_2
  2683.         lda t_sprite_x,x
  2684.         asl
  2685.         ror $d010
  2686.         sta $d000,y
  2687.         lda t_sprite_y,x
  2688.         sta $d001,y
  2689.         iny
  2690.         iny
  2691.         lda t_sprite_col,x
  2692.         sta $d027,x
  2693.         lda t_sprite_def,x
  2694.         sta $07f8,x    
  2695.         inx
  2696.         cpx #$08
  2697.         bne sprite_plot_2
  2698.  
  2699. ; animate the bottom sprites on the title screen       
  2700.                
  2701.         ldx anim_timer_b            ; load up the anim_timer
  2702.         inx                         ; increase it by '1'
  2703.         cpx #$0c                    ; is the timer equal to '4' yet?
  2704.         bne bot_anim_skip           ; no? don't update animation!
  2705.                                     ; yes? better do some animation then!
  2706.         ldx #$00
  2707. au_loop
  2708.         lda t_sprite_def,x
  2709.         clc
  2710.         adc #$01
  2711.         cmp t_sprite_anime,x
  2712.         bne au_skip
  2713.         lda t_sprite_anims,x
  2714. au_skip
  2715.         sta t_sprite_def,x
  2716.         inx
  2717.         cpx #$08
  2718.         bne au_loop                            
  2719.                                     ; yes?
  2720.         ldx #$00                    ; load x register with '0'
  2721. bot_anim_skip                       ; to reset anim_timer and...   
  2722.         stx anim_timer_b            ; store x register to anim_timer
  2723.        
  2724. ; colour wash effect for certain title screen lines
  2725.  
  2726.         ldx #$00
  2727. colourwash_loop
  2728.         lda colourwash_off,x
  2729.         clc
  2730.         adc colourwash_count
  2731.         and #$0f
  2732.         tay
  2733.        
  2734.         lda colourwash_rainbow,y       
  2735.         sta $d800,x                 ; cosine systems
  2736.         sta $daa8,x                 ; rolling message
  2737.  
  2738.         lda colourwash_reds,y
  2739.         sta $d918,x                 ; sub-title    
  2740.         sta $db98,x                 ; last/best score
  2741.                
  2742.         lda colourwash_greys,y
  2743.         sta $d968,x                 ; based on chiller
  2744.         sta $da08,x                 ; by jason
  2745.         sta $da30,x                 ; by jon / ryley           
  2746.  
  2747.         lda colourwash_blues,y
  2748.         sta $d9b8,x                 ; by andy
  2749.  
  2750.         inx
  2751.         cpx #$28
  2752.         bne colourwash_loop
  2753.  
  2754.         ldx colourwash_timer
  2755.         inx
  2756.         cpx #$03
  2757.         bcc exit_wash
  2758.         inc colourwash_count
  2759.         ldx #$00
  2760. exit_wash  
  2761.         stx colourwash_timer                                           
  2762.    
  2763. ; split 4 is done, exit irq interrupt
  2764.  
  2765.         jmp irq_exit
  2766.                
  2767. ; raster split 5 code ------------------------------------
  2768.  
  2769. irq_rout5
  2770.  
  2771. ; set interrupt handler ready for split 1
  2772.        
  2773.         lda #$01
  2774.         sta raster_num
  2775.         lda #raster_1_pos
  2776.         sta $d012
  2777.        
  2778. ; open the upper and lower borders
  2779.  
  2780.         lda #$14
  2781.         sta $d011
  2782.  
  2783.         lda #$fc
  2784.         cmp $d012
  2785.         bne *-$03
  2786.         lda #$1b
  2787.         sta $d011              
  2788.        
  2789.         lda #$00                    ; turn off
  2790.         sta $d015                   ; all 8 sprites!
  2791.                
  2792. ; set sync variable for main line code synchronisation
  2793.  
  2794. set_sync
  2795.         lda #$01                    ; set the sync flag to '1'     
  2796.         sta sync                    ; so the main code runs!
  2797.        
  2798. ; restore registers and exit irq interrupt
  2799.  
  2800. irq_exit
  2801.         pla
  2802.         tay
  2803.         pla
  2804.         tax
  2805.         pla
  2806. nmi     rti
  2807.  
  2808. ; end irq interrupt code =============================
  2809.  
  2810.  
  2811. ; all data tables live here! ===============================
  2812.  
  2813.  
  2814. ; screen low/high byte offset tables
  2815.  
  2816. screen_low
  2817.         !byte $00,$28,$50,$78,$a0,$c8,$f0,$18
  2818.         !byte $40,$68,$90,$b8,$e0,$08,$30,$58
  2819.         !byte $80,$a8,$d0,$f8,$20,$48,$70,$98
  2820.         !byte $c0
  2821.        
  2822. screen_high
  2823.         !byte $04,$04,$04,$04,$04,$04,$04,$05
  2824.         !byte $05,$05,$05,$05,$05,$06,$06,$06
  2825.         !byte $06,$06,$06,$06,$07,$07,$07,$07
  2826.         !byte $07
  2827.  
  2828. ; colour wash data tables for text colour cycling
  2829.  
  2830. colourwash_off
  2831.         !byte $00,$01,$02,$01,$00,$01,$02,$01
  2832.         !byte $08,$07,$06,$05,$04,$03,$02,$04
  2833.         !byte $06,$08,$0a,$0c,$0e,$00,$0f,$0e
  2834.         !byte $0d,$0c,$0b,$0a,$09,$08,$07,$06
  2835.         !byte $0c,$0c,$0b,$0a,$0b,$0c,$0c,$0e      
  2836.  
  2837. colourwash_blues
  2838.         !byte $06,$04,$0e,$0e,$03,$01,$0f,$03
  2839.         !byte $0f,$01,$03,$0e,$0e,$04,$06,$0f
  2840.        
  2841. colourwash_greys
  2842.         !byte $0b,$0b,$0c,$0f,$0f,$0d,$01,$0d
  2843.         !byte $0d,$01,$01,$0d,$0f,$01,$0c,$0b
  2844.        
  2845. colourwash_reds
  2846.         !byte $09,$02,$08,$08,$0a,$07,$0f,$0a
  2847.         !byte $0f,$07,$0a,$08,$08,$02,$09,$0f      
  2848.                    
  2849. colourwash_rainbow
  2850.         !byte $06,$02,$04,$05,$03,$07,$01,$01
  2851.         !byte $01,$01,$01,$07,$03,$05,$04,$06
  2852.  
  2853. ; text data for intro message      
  2854.        
  2855. intro_1     !scr "           pal  c64 detected!           "
  2856. intro_2     !scr "           ntsc c64 detected!           "
  2857. intro_3     !scr "      please use an 8580 sid chip!      "
  2858.  
  2859. ; text data for the rolling message
  2860.  
  2861. mess_text
  2862.         !scr "   *  c o s i n e    s y s t e m s  *   "
  2863.         !scr "         p r e s e n t s . . .          "    
  2864.         !scr "       c  h  i  l  l  e  r      2       "
  2865.         !scr "                                        "
  2866.         !scr "    press * fire * to start the game    "
  2867.         !scr "    from the beginning of level 1...    "
  2868.         !scr "    hit * f7 * to play the game from    "
  2869.         !scr " the level reached during the last game "
  2870.         !scr "                                        "        
  2871.         !scr "  pull left on the joystick to select   "
  2872.         !scr "     and play as the girl michaela!     "
  2873.         !scr "  pull right on the joystick to select  "
  2874.         !scr "      and play as the boy michael!      "                
  2875.         !scr "                                        "
  2876.         !scr " guide your character around each level "
  2877.         !scr "   collecting 20 magic crosses, while   "
  2878.         !scr "  avoiding the nasty meanies who drain  "
  2879.         !scr " your limited energy supply on contact! "
  2880.         !scr "                                        "
  2881.         !scr "  the boy is a little stronger and can  "
  2882.         !scr " stand more contact before energy loss. "
  2883.         !scr "  the girl is a little lighter and can  "
  2884.         !scr "   make slightly longer length jumps.   "
  2885.         !scr "                                        "
  2886.         !scr "   based on chiller from mastertronic   "
  2887.         !scr "      by richard and david darling      "      
  2888.         !scr "                                        "
  2889.         !scr "     coding, graphics and music by      "
  2890.         !scr "      *  a n d y    v a i s e y  *      "
  2891.         !scr "                                        "
  2892.         !scr " copious amounts of help and support by "
  2893.         !scr "       *  j a s o n    k e l k  *       "
  2894.         !scr "                                        "
  2895.         !scr "     quality control and testing by     "
  2896.         !scr "    * j o n a t h a n    m i n e s *    "
  2897.         !scr "                 a n d                  "
  2898.         !scr "       * r y l e y    j a m e s *       "
  2899.         !scr "                                        "
  2900.         !scr " kindly sponsored by freeze64.com /zine "
  2901.         !scr "                                        "            
  2902.         !scr "          special thanks to...          "            
  2903.         !scr "   artstate digital    vinny mainolfi   "
  2904.         !scr "     ray lejuez     dustin chambers     "
  2905.         !scr "     andrew fisher    david darling     "
  2906.         !scr "       and of course chantelle...       "
  2907.         !scr "                                        "
  2908.         !scr "for more cosine games and demos visit..."
  2909.         !scr "           www.cosine.org.uk            "
  2910.         !scr "                                        "                                                                                
  2911.         !byte $00       ; end of text marker
  2912.                    
  2913.         !scr "hi vinny! thought I might find you here!"
  2914.                        
  2915. ; text data for get ready messages
  2916.  
  2917. gr_lvl1_des1    !scr "         level 1  -  the forest         "
  2918. gr_lvl1_des2    !scr " darkness falls across the land         "
  2919. gr_lvl1_des3    !scr "    the midnight hour is close at hand! "
  2920.  
  2921. gr_lvl2_des1    !scr "         level 2  -  the church         "
  2922. gr_lvl2_des2    !scr " grizzly ghouls from every tomb         "
  2923. gr_lvl2_des3    !scr "      are closing in to seal your doom! "
  2924.  
  2925. gr_lvl3_des1    !scr "       level 3  -  the apartments       "
  2926. gr_lvl3_des2    !scr " creatures crawl in search of blood     "
  2927. gr_lvl3_des3    !scr "     to terrorize y/all/s neighborhood! "
  2928.  
  2929. gr_lvl4_des1    !scr "     level 4  -  the haunted house      "
  2930. gr_lvl4_des2    !scr " demons squeal in sheer delight         "
  2931. gr_lvl4_des3    !scr "      you they spy, so plump, so right! "
  2932.  
  2933. gr_lvl5_des1    !scr "        level 5  -  the cemetery        "
  2934. gr_lvl5_des2    !scr " evil reaches out from the crypt        "
  2935. gr_lvl5_des3    !scr "         to crush you in it/s icy grip! "
  2936.  
  2937. gr_lvl6_des1    !scr "         level 6  -  the cinema         "
  2938. gr_lvl6_des2    !scr " you try to run, you try to scream      "
  2939. gr_lvl6_des3    !scr "       but no more sun you/ll ever see! "
  2940.  
  2941. gr_lvl7_des1    !scr "          level 7  -  the park          "
  2942. gr_lvl7_des2    !scr " ghosts and ghouls are hard to beat     "
  2943. gr_lvl7_des3    !scr "      still you stand with frozen feet! "
  2944.  
  2945. gr_lvl8_des1    !scr "         level 8  -  the sewers         "
  2946. gr_lvl8_des2    !scr " the foulest stench is in the air       "
  2947. gr_lvl8_des3    !scr "      the funk of forty thousand years! "
  2948.  
  2949. gr_lvl9_des1    !scr "       level 9  -  the log cabin        "
  2950. gr_lvl9_des2    !scr " you try to scream, but terror          "
  2951. gr_lvl9_des3    !scr "    takes the sound before you make it! "
  2952.  
  2953. gr_lvl10_des1   !scr "       level 10  -  the basement        "
  2954. gr_lvl10_des2   !scr " you hear the door slam but             "
  2955. gr_lvl10_des3   !scr "   realise there/s nowhere left to run! "
  2956.  
  2957. gr_lvl11_des1   !scr "       level 11  -  the scrapyard       "
  2958. gr_lvl11_des2   !scr " creatures are creepin/ up behind...    "
  2959. gr_lvl11_des3   !scr "                 ...you/re out of time! "  
  2960.  
  2961. gr_lvl12_des1   !scr "         level 12  -  the cave          "
  2962. gr_lvl12_des2   !scr " you/re fighting for your life...       "
  2963. gr_lvl12_des3   !scr "   ...inside a killer, chiller tonight! "
  2964.  
  2965. ; text data for game over message
  2966.  
  2967. game_over_txt
  2968.         !scr "  and though you fought to stay alive   "
  2969.         !scr "        you begin to shiver...          "
  2970.         !scr "   /cause no mere mortal can escape     "
  2971.         !scr "       the evil of the chiller!         "
  2972.         !scr "                                        "
  2973.         !scr "               game over!               "
  2974.        
  2975. ; text data for game complete message
  2976.  
  2977. game_comp_txt
  2978.         !scr "  great!  you have finished chiller 2!  "
  2979.         !scr " now play through again, with the other "
  2980.         !scr "   character!  keep your score so far   "
  2981.         !scr "   and try to achieve a higher score!   "
  2982.        
  2983. ; graphics data for game complete screen
  2984.  
  2985. comp_screen_ram
  2986. !byte $20,$00,$00,$55,$20,$4F,$20,$20,$20,$20,$4F,$00,$20,$20,$20,$4F,$5B,$5C,$5D
  2987. !byte $20,$5B,$5C,$5D,$00,$00,$4F,$00,$00,$00,$00,$00,$4F,$20,$5B,$5C,$5C,$5D,$20
  2988. !byte $4F,$00,$00,$5B,$5C,$5D,$00,$00,$00,$00,$4F,$00,$00,$4F,$00,$5B,$5D,$20,$20
  2989. !byte $20,$4F,$00,$4F,$00,$00,$20,$4F,$20,$20,$20,$20,$4F,$20,$20,$20,$20,$20,$20
  2990. !byte $20,$20,$20,$20,$20,$41,$54,$41,$42,$41,$42,$41,$41,$42,$54,$4F,$20,$20,$20
  2991. !byte $20,$20,$20,$20,$20,$73,$F7,$F4,$F5,$F6,$F7,$F4,$F7,$F7,$73,$20,$20,$20,$20
  2992. !byte $20,$20,$20,$20,$20,$20,$20,$4B,$F3,$F6,$F4,$F7,$C6,$20,$20,$20,$20,$20,$20
  2993. !byte $20,$20,$20,$20,$20,$20,$20,$20,$20,$4C,$C6,$20,$20,$20,$20,$20,$20,$20,$20
  2994.  
  2995. comp_colour_ram
  2996. !byte $01,$01,$01,$01,$0B,$01,$00,$00,$00,$00,$0B,$01,$00,$00,$00,$01,$0B,$0B,$0B
  2997. !byte $01,$0B,$0B,$0B,$01,$01,$0C,$01,$01,$01,$01,$01,$01,$00,$0C,$0C,$0C,$0C,$00
  2998. !byte $01,$01,$01,$0C,$0C,$0C,$01,$01,$01,$01,$0B,$01,$01,$0C,$01,$0B,$0B,$00,$00
  2999. !byte $0C,$0C,$01,$01,$01,$01,$00,$0B,$01,$00,$00,$00,$0B,$00,$00,$00,$00,$00,$00
  3000. !byte $00,$00,$00,$00,$00,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$01,$00,$00,$00
  3001. !byte $00,$00,$00,$00,$00,$0C,$0B,$0C,$0F,$0F,$0B,$0C,$0C,$0F,$0C,$00,$00,$00,$00
  3002. !byte $00,$00,$00,$00,$00,$00,$00,$05,$0B,$0B,$0C,$0F,$05,$00,$00,$00,$00,$00,$00
  3003. !byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$05,$05,$00,$00,$00,$00,$00,$00,$00,$00
  3004.  
  3005. ; intro screen default sprite positions, colours and definitions
  3006.  
  3007. ; cosine logo
  3008.  
  3009. i_spr_x_dflt        !byte $4b,$59,$65,$00,$00,$00,$00,$00
  3010. i_spr_y_dflt        !byte $6a,$6a,$6a,$00,$00,$00,$00,$00
  3011. i_spr_col_dflt      !byte $02,$02,$02,$00,$00,$00,$00,$00
  3012. i_spr_def_dflt      !byte $c0,$c1,$c2,$a3,$a3,$a4,$a5,$a6
  3013. i_spr_y_dir         !byte $00,$01,$00,$01,$00,$01,$00,$01
  3014. i_spr_anims_dflt    !byte $c0,$c1,$c2,$a3,$a3,$a4,$a5,$a6
  3015. i_spr_anime_dflt    !byte $c1,$c2,$c3,$a4,$a4,$a5,$a6,$a7      
  3016.                    
  3017. ; titles screen default sprite positions, colours and definitions
  3018.  
  3019. ; title logo 'chiller 2'
  3020.  
  3021. t_spr_x_dflt        !byte $27,$33,$3f,$4b,$57,$63,$6f,$85
  3022. t_spr_y_dflt        !byte $3e,$4a,$3e,$4a,$3e,$4a,$3e,$4a
  3023. t_spr_col_dflt      !byte $02,$02,$02,$02,$02,$02,$02,$02
  3024. t_spr_def_dflt      !byte $a0,$a1,$a2,$a3,$a3,$a4,$a5,$a6
  3025. t_spr_y_dir         !byte $00,$01,$00,$01,$00,$01,$00,$01
  3026. t_spr_anims_dflt    !byte $a0,$a1,$a2,$a3,$a3,$a4,$a5,$a6
  3027. t_spr_anime_dflt    !byte $a1,$a2,$a3,$a4,$a4,$a5,$a6,$a7
  3028.  
  3029. ; title screen bottom sprites (ghost, boy, girl)
  3030.  
  3031. t_spr_x_dflt2       !byte $00,$46,$55,$00,$00,$00,$00,$00
  3032. t_spr_y_dflt2       !byte $b2,$d3,$d3,$b2,$b2,$b2,$b2,$b2
  3033. t_spr_col_dflt2     !byte $0f,$0a,$0a,$0f,$0f,$0f,$0f,$0f
  3034. t_spr_def_dflt2     !byte $c3,$d8,$d8,$c3,$c3,$c3,$c3,$c3
  3035. t_spr_dflt2_anims   !byte $c3,$d8,$d8,$c3,$c3,$c3,$c3,$c3
  3036. t_spr_dflt2_anime   !byte $c7,$dc,$d9,$c3,$c3,$c3,$c3,$c3
  3037.  
  3038. ; game complete sprites (hearts, boy, girl)
  3039.  
  3040. gc_sprite_x         !byte $56,$4f,$5e,$94,$90,$6f,$5a,$0d
  3041. gc_sprite_y         !byte $8d,$a5,$a5,$a4,$cd,$a8,$54,$85
  3042. gc_sprite_col       !byte $02,$0a,$0a,$05,$0c,$0c,$0c,$0c
  3043. gc_sprite_def       !byte $f0,$d8,$dc,$ec,$cf,$c7,$d3,$e8
  3044. gc_sprite_anims     !byte $f0,$d8,$dc,$ec,$cf,$c7,$d3,$e8
  3045. gc_sprite_anime     !byte $f5,$d9,$dd,$ee,$d3,$cb,$d7,$eb
  3046.  
  3047. ; hide sprites off screen
  3048.  
  3049. sprite_x_hide       !byte $00,$00,$00,$00,$00,$00,$00,$00
  3050. sprite_y_hide       !byte $00,$00,$00,$00,$00,$00,$00,$00
  3051.  
  3052. ; level 1 sprite default sprite positions, colours and definitions
  3053. ; animations start/stop, direction, speed and max/min move pattern
  3054.  
  3055. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3056.  
  3057. l1_sprite_x     !byte $19,$20,$4c,$94,$90,$6f,$5a,$0d
  3058. l1_sprite_y     !byte $cd,$9e,$4f,$a4,$cd,$a8,$54,$85
  3059. l1_sprite_col   !byte $0a,$07,$0c,$05,$0c,$0c,$0c,$0c
  3060. l1_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$d3,$e8
  3061. l1_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$d3,$e8
  3062. l1_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$d7,$eb
  3063. l1_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$00,$00
  3064. l1_sprite_spd   !byte $00,$00,$02,$03,$01,$02,$01,$02
  3065. l1_sprite_min   !byte $00,$00,$53,$53,$19,$5a,$5a,$0d
  3066. l1_sprite_max   !byte $00,$00,$b8,$a7,$90,$85,$85,$3a
  3067.  
  3068. ; level 2 sprite default sprite positions, colours and definitions
  3069. ; animations start/stop, direction, speed and max/min move pattern
  3070.  
  3071. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3072.  
  3073. l2_sprite_x     !byte $12,$80,$18,$94,$9b,$8b,$68,$0d
  3074. l2_sprite_y     !byte $cd,$59,$55,$b6,$cd,$34,$5e,$1b
  3075. l2_sprite_col   !byte $0a,$07,$0c,$0c,$0c,$0c,$0c,$0c
  3076. l2_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3077. l2_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3078. l2_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3079. l2_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$00,$00
  3080. l2_sprite_spd   !byte $00,$00,$02,$01,$01,$02,$02,$03
  3081. l2_sprite_min   !byte $00,$00,$55,$82,$0d,$0d,$2a,$0d
  3082. l2_sprite_max   !byte $00,$00,$8d,$b6,$9b,$8b,$93,$9f
  3083.  
  3084. ; level 3 sprite default sprite positions, colours and definitions
  3085. ; animations start/stop, direction, speed and max/min move pattern
  3086.  
  3087. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3088.  
  3089. l3_sprite_x     !byte $10,$10,$58,$70,$4b,$8c,$33,$33
  3090. l3_sprite_y     !byte $cd,$7c,$5b,$af,$cd,$3b,$5c,$9c
  3091. l3_sprite_col   !byte $0a,$07,$05,$05,$0c,$0c,$0c,$0c
  3092. l3_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3093. l3_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3094. l3_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3095. l3_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3096. l3_sprite_spd   !byte $00,$00,$03,$03,$02,$03,$02,$03
  3097. l3_sprite_min   !byte $00,$00,$5b,$5b,$3b,$3c,$0f,$0f
  3098. l3_sprite_max   !byte $00,$00,$af,$af,$9f,$8c,$33,$33
  3099.  
  3100. ; level 4 sprite default sprite positions, colours and definitions
  3101. ; animations start/stop, direction, speed and max/min move pattern
  3102.  
  3103. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3104.  
  3105. l4_sprite_x     !byte $10,$46,$24,$30,$4b,$8c,$3d,$8f
  3106. l4_sprite_y     !byte $cd,$9d,$5b,$af,$cd,$32,$54,$9f
  3107. l4_sprite_col   !byte $0a,$07,$0c,$05,$0c,$0c,$0c,$0c
  3108. l4_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3109. l4_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3110. l4_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3111. l4_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3112. l4_sprite_spd   !byte $00,$00,$03,$03,$02,$04,$03,$04
  3113. l4_sprite_min   !byte $00,$00,$5b,$5b,$10,$10,$3d,$3f
  3114. l4_sprite_max   !byte $00,$00,$af,$af,$9f,$9f,$9f,$9f
  3115.  
  3116. ; level 5 sprite default sprite positions, colours and definitions
  3117. ; animations start/stop, direction, speed and max/min move pattern
  3118.  
  3119. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3120.  
  3121. l5_sprite_x     !byte $10,$9c,$20,$50,$4b,$8c,$3d,$8f
  3122. l5_sprite_y     !byte $cd,$cb,$5b,$82,$cd,$32,$5d,$a3
  3123. l5_sprite_col   !byte $0a,$07,$0c,$05,$0c,$0c,$0c,$0c
  3124. l5_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3125. l5_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3126. l5_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3127. l5_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3128. l5_sprite_spd   !byte $00,$00,$03,$02,$02,$04,$02,$02
  3129. l5_sprite_min   !byte $00,$00,$5b,$50,$10,$10,$5f,$65
  3130. l5_sprite_max   !byte $00,$00,$92,$82,$9f,$9f,$8d,$98
  3131.  
  3132. ; level 6 sprite default sprite positions, colours and definitions
  3133. ; animations start/stop, direction, speed and max/min move pattern
  3134.  
  3135. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3136.  
  3137. l6_sprite_x     !byte $10,$9e,$34,$78,$4b,$8c,$3d,$55
  3138. l6_sprite_y     !byte $cd,$c5,$7c,$a5,$cd,$32,$5a,$83
  3139. l6_sprite_col   !byte $0a,$07,$0c,$0c,$0c,$0c,$0c,$0c
  3140. l6_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3141. l6_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3142. l6_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3143. l6_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3144. l6_sprite_spd   !byte $00,$00,$03,$03,$02,$04,$05,$02
  3145. l6_sprite_min   !byte $00,$00,$7c,$7c,$10,$10,$10,$44
  3146. l6_sprite_max   !byte $00,$00,$b3,$a5,$9f,$9f,$9f,$65
  3147.  
  3148. ; level 7 sprite default sprite positions, colours and definitions
  3149. ; animations start/stop, direction, speed and max/min move pattern
  3150.  
  3151. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3152.  
  3153. l7_sprite_x     !byte $10,$87,$2d,$4d,$4b,$69,$3d,$8c
  3154. l7_sprite_y     !byte $cd,$1d,$58,$95,$cd,$95,$5d,$32
  3155. l7_sprite_col   !byte $0a,$07,$0c,$0c,$0c,$0c,$0c,$0c
  3156. l7_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3157. l7_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3158. l7_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3159. l7_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3160. l7_sprite_spd   !byte $00,$00,$03,$03,$02,$03,$03,$04
  3161. l7_sprite_min   !byte $00,$00,$58,$85,$10,$5e,$3f,$10
  3162. l7_sprite_max   !byte $00,$00,$7c,$b1,$9f,$7c,$9f,$9f
  3163.  
  3164. ; level 8 sprite default sprite positions, colours and definitions
  3165. ; animations start/stop, direction, speed and max/min move pattern
  3166.  
  3167. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3168.  
  3169. l8_sprite_x     !byte $10,$84,$1c,$90,$4b,$8c,$4f,$68
  3170. l8_sprite_y     !byte $c5,$bd,$5d,$82,$c5,$32,$69,$95
  3171. l8_sprite_col   !byte $0a,$07,$0c,$0c,$0c,$0c,$0c,$0c
  3172. l8_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3173. l8_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3174. l8_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3175. l8_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3176. l8_sprite_spd   !byte $00,$00,$03,$03,$01,$04,$03,$02
  3177. l8_sprite_min   !byte $00,$00,$5d,$54,$3b,$10,$28,$30
  3178. l8_sprite_max   !byte $00,$00,$a8,$b6,$59,$9f,$80,$82
  3179.  
  3180. ; level 9 sprite default sprite positions, colours and definitions
  3181. ; animations start/stop, direction, speed and max/min move pattern
  3182.  
  3183. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3184.  
  3185. l9_sprite_x     !byte $10,$48,$1c,$90,$4b,$69,$3d,$8c
  3186. l9_sprite_y     !byte $cd,$83,$78,$93,$4e,$cb,$83,$32
  3187. l9_sprite_col   !byte $0a,$07,$0c,$0c,$0c,$0c,$05,$0c
  3188. l9_sprite_def   !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3189. l9_sprite_anims !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3190. l9_sprite_anime !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3191. l9_sprite_dir   !byte $00,$00,$00,$01,$01,$01,$01,$00
  3192. l9_sprite_spd   !byte $00,$00,$03,$03,$02,$03,$03,$04
  3193. l9_sprite_min   !byte $00,$00,$6a,$6a,$1f,$10,$41,$10
  3194. l9_sprite_max   !byte $00,$00,$b5,$a8,$9f,$9f,$7f,$9f
  3195.  
  3196. ; level 10 sprite default sprite positions, colours and definitions
  3197. ; animations start/stop, direction, speed and max/min move pattern
  3198.  
  3199. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3200.  
  3201. l10_sprite_x        !byte $10,$48,$28,$80,$4b,$8c,$60,$55
  3202. l10_sprite_y        !byte $cd,$a7,$53,$73,$cd,$32,$a6,$7d
  3203. l10_sprite_col      !byte $0a,$07,$0c,$0c,$0c,$0c,$0c,$0c
  3204. l10_sprite_def      !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3205. l10_sprite_anims    !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3206. l10_sprite_anime    !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3207. l10_sprite_dir      !byte $00,$00,$00,$01,$01,$01,$01,$00
  3208. l10_sprite_spd      !byte $00,$00,$03,$03,$02,$04,$03,$03
  3209. l10_sprite_min      !byte $00,$00,$53,$53,$10,$10,$44,$3c
  3210. l10_sprite_max      !byte $00,$00,$aa,$8d,$9f,$9f,$7b,$6c
  3211.  
  3212. ; level 11 sprite default sprite positions, colours and definitions
  3213. ; animations start/stop, direction, speed and max/min move pattern
  3214.  
  3215. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3216.  
  3217. l11_sprite_x        !byte $10,$5c,$28,$80,$4b,$8c,$60,$55
  3218. l11_sprite_y        !byte $cd,$ca,$53,$73,$cd,$32,$a1,$77
  3219. l11_sprite_col      !byte $0a,$07,$0c,$0c,$0c,$0c,$0c,$0c
  3220. l11_sprite_def      !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3221. l11_sprite_anims    !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3222. l11_sprite_anime    !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3223. l11_sprite_dir      !byte $00,$00,$00,$01,$01,$01,$01,$00
  3224. l11_sprite_spd      !byte $00,$00,$04,$02,$02,$04,$03,$02
  3225. l11_sprite_min      !byte $00,$00,$56,$56,$10,$10,$46,$37
  3226. l11_sprite_max      !byte $00,$00,$a2,$80,$9f,$9f,$9f,$67
  3227.  
  3228. ; level 12 sprite default sprite positions, colours and definitions
  3229. ; animations start/stop, direction, speed and max/min move pattern
  3230.  
  3231. ; sprites - player, cross, spider1, spider2, zombie, ghost, bat, witch
  3232.  
  3233. l12_sprite_x        !byte $10,$a0,$78,$94,$4b,$8c,$60,$80
  3234. l12_sprite_y        !byte $cd,$cb,$83,$64,$cd,$32,$a2,$5a
  3235. l12_sprite_col      !byte $0a,$07,$05,$05,$0c,$0c,$0c,$0c
  3236. l12_sprite_def      !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3237. l12_sprite_anims    !byte $ab,$bf,$ee,$ec,$cf,$c7,$e0,$e8
  3238. l12_sprite_anime    !byte $ac,$c0,$f0,$ee,$d3,$cb,$e4,$ec
  3239. l12_sprite_dir      !byte $00,$00,$00,$00,$01,$01,$01,$00
  3240. l12_sprite_spd      !byte $00,$00,$02,$03,$02,$04,$04,$03
  3241. l12_sprite_min      !byte $00,$00,$83,$64,$10,$10,$10,$38
  3242. l12_sprite_max      !byte $00,$00,$c0,$a0,$9f,$9f,$6b,$85
  3243.  
  3244. ; enemy movement animation defs
  3245.  
  3246. left_enm_def    !byte $00,$00,$ee,$ec,$cf,$c7,$e0,$e4
  3247. left_enm_anims  !byte $00,$00,$ee,$ec,$cf,$c7,$e0,$e4
  3248. left_enm_anime  !byte $00,$00,$f0,$ee,$d3,$cb,$e4,$e8
  3249.  
  3250. rite_enm_def    !byte $00,$00,$ee,$ec,$cb,$c3,$d3,$e8
  3251. rite_enm_anims  !byte $00,$00,$ee,$ec,$cb,$c3,$d3,$e8
  3252. rite_enm_anime  !byte $00,$00,$f0,$ee,$ce,$c7,$d7,$ec  
  3253.  
  3254. ; level 1 cross positions
  3255.  
  3256. l1_cross_x      !byte $20,$43,$8f,$39,$6e,$9f,$11,$79,$40,$37,$a3,$11,$8f,$6d,$6e,$a1,$70,$20,$8c,$39
  3257. l1_cross_y      !byte $9e,$50,$7f,$cd,$40,$90,$b6,$86,$6a,$b6,$ba,$86,$ae,$95,$57,$65,$98,$9e,$cb,$86
  3258.  
  3259. ; level 2 cross positions
  3260.  
  3261. l2_cross_x      !byte $80,$38,$0e,$38,$31,$9f,$42,$5d,$9f,$0e,$24,$5f,$50,$9f,$0b,$0b,$5d,$86,$82,$29
  3262. l2_cross_y      !byte $59,$cb,$a2,$5f,$cd,$cb,$1b,$cb,$1b,$cb,$8a,$1b,$9e,$8b,$6a,$1b,$8c,$1b,$8b,$3a
  3263.  
  3264. ; level 3 cross positions
  3265.  
  3266. l3_cross_x      !byte $10,$51,$8e,$8d,$4c,$10,$3d,$58,$10,$65,$10,$64,$10,$7c,$4c,$71,$7c,$4c,$79,$4c
  3267. l3_cross_y      !byte $7c,$cd,$3b,$cd,$8b,$5c,$cd,$1c,$9c,$cd,$15,$8b,$bc,$6c,$ac,$1b,$ac,$1c,$cd,$6a
  3268.  
  3269. ; level 4 cross positions
  3270.  
  3271. l4_cross_x      !byte $46,$78,$31,$9e,$38,$10,$68,$9e,$0d,$13,$7a,$29,$9c,$9c,$53,$2a,$3e,$7e,$2a,$69
  3272. l4_cross_y      !byte $9d,$1e,$cd,$76,$c4,$1e,$51,$ce,$87,$4b,$ce,$1e,$99,$1e,$5b,$93,$7c,$a1,$54,$7c
  3273.  
  3274. ; level 5 cross positions
  3275.  
  3276. l5_cross_x      !byte $9c,$2c,$99,$0e,$9f,$36,$42,$67,$72,$6b,$89,$0e,$12,$86,$30,$84,$6c,$10,$3c,$60
  3277. l5_cross_y      !byte $cb,$85,$87,$63,$1b,$9b,$1b,$bc,$1b,$94,$1b,$98,$21,$51,$32,$c6,$5e,$c4,$56,$1b
  3278.  
  3279. ; level 6 cross positions
  3280.  
  3281. l6_cross_x      !byte $9e,$16,$78,$80,$46,$76,$0e,$0e,$66,$9f,$0e,$9e,$2c,$46,$96,$36,$96,$4b,$0a,$56
  3282. l6_cross_y      !byte $c5,$55,$b9,$1d,$cb,$35,$a8,$1d,$6a,$1d,$7b,$7b,$1d,$a8,$55,$35,$9a,$6a,$c9,$35
  3283.  
  3284. ; level 7 cross positions
  3285.  
  3286. l7_cross_x      !byte $87,$0d,$0d,$54,$56,$0d,$7a,$36,$58,$94,$97,$3f,$a2,$57,$10,$6a,$9c,$94,$26,$7b
  3287. l7_cross_y      !byte $1d,$c0,$53,$1d,$cc,$1d,$4f,$81,$51,$ca,$39,$55,$7b,$8c,$8c,$cc,$5d,$a8,$35,$81
  3288.  
  3289. ; level 8 cross positions
  3290.  
  3291. l8_cross_x      !byte $84,$58,$0c,$5a,$0f,$32,$3c,$4a,$24,$9e,$a0,$a1,$10,$9e,$5e,$0a,$a1,$4e,$70,$28
  3292. l8_cross_y      !byte $bd,$94,$5c,$1c,$bd,$94,$54,$ad,$1c,$4a,$c2,$68,$1c,$1c,$5d,$93,$94,$68,$1c,$68
  3293.  
  3294. ; level 9 cross positions
  3295.  
  3296. l9_cross_x      !byte $48,$2e,$0a,$7c,$60,$0e,$a2,$78,$5c,$a2,$2a,$78,$0a,$6c,$48,$9f,$30,$92,$a2,$0a
  3297. l9_cross_y      !byte $83,$32,$cb,$1e,$b8,$1e,$ad,$83,$1e,$6b,$88,$a4,$8c,$65,$a4,$32,$cb,$cb,$8c,$53
  3298.  
  3299. ; level 10 cross positions
  3300.  
  3301. l10_cross_x     !byte $48,$2c,$11,$a0,$42,$9b,$12,$57,$8a,$0b,$6f,$54,$9e,$10,$31,$72,$28,$a0,$74,$76
  3302. l10_cross_y     !byte $a7,$1e,$cd,$a7,$5f,$56,$80,$1e,$cd,$98,$7e,$cd,$1e,$3f,$cd,$5f,$98,$71,$1e,$96
  3303.  
  3304. ; level 11 cross positions
  3305.  
  3306. l11_cross_x     !byte $5c,$4c,$12,$53,$0e,$3e,$7a,$86,$98,$80,$a2,$0f,$4c,$98,$6e,$98,$73,$3c,$5e,$14
  3307. l11_cross_y     !byte $ca,$a1,$55,$1d,$a1,$5d,$a1,$1d,$58,$ca,$1d,$ca,$5d,$a1,$1d,$ca,$5d,$1d,$78,$1d
  3308.  
  3309. ; level 12 cross positions
  3310.  
  3311. l12_cross_x     !byte $a0,$a2,$0e,$47,$0e,$37,$2c,$4e,$77,$82,$25,$0e,$78,$60,$8b,$60,$50,$2d,$0b,$9e
  3312. l12_cross_y     !byte $cb,$55,$1d,$cb,$61,$5a,$cb,$93,$32,$86,$44,$a1,$c2,$5a,$1d,$82,$32,$79,$cb,$1d
  3313.  
  3314. ; byte stores that are updated during play
  3315.  
  3316. ; *main* sprite default sprite positions, colours and definitions
  3317. ; animations start/stop, direction, speed and max/min move pattern
  3318.  
  3319. sprite_x        !byte $00,$00,$00,$00,$00,$00,$00,$00
  3320. sprite_y        !byte $00,$00,$00,$00,$00,$00,$00,$00
  3321. sprite_col      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3322. sprite_def      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3323. sprite_anims    !byte $00,$00,$00,$00,$00,$00,$00,$00
  3324. sprite_anime    !byte $00,$00,$00,$00,$00,$00,$00,$00
  3325. sprite_dir      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3326. sprite_spd      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3327. sprite_min      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3328. sprite_max      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3329.  
  3330. ; sprite store that is populated when girl or boy player
  3331. ; is selected - player movement routines then pull data
  3332. ; in from here!
  3333.  
  3334. playwalkleft_def    !byte $00
  3335. playwalkleft_anims  !byte $00
  3336. playwalkleft_anime  !byte $00
  3337.  
  3338. playwalkright_def   !byte $00
  3339. playwalkright_anims !byte $00
  3340. playwalkright_anime !byte $00
  3341.  
  3342. playjumpleft_def    !byte $00
  3343. playjumpleft_anims  !byte $00
  3344. playjumpleft_anime  !byte $00
  3345.  
  3346. playjumpright_def   !byte $00
  3347. playjumpright_anims !byte $00
  3348. playjumpright_anime !byte $00
  3349.  
  3350. playstatic_def      !byte $00
  3351. playstatic_anims    !byte $00
  3352. playstatic_anime    !byte $00
  3353.  
  3354. playfall_def        !byte $00
  3355. playfall_anims      !byte $00
  3356. playfall_anime      !byte $00
  3357.  
  3358. ; *buffer* sprite default sprite positions, colours and definitions
  3359. ; animations start/stop, direction, speed and max/min move pattern
  3360. ; used during level setup only
  3361.  
  3362. sprite_x_buf        !byte $00,$00,$00,$00,$00,$00,$00,$00
  3363. sprite_y_buf        !byte $00,$00,$00,$00,$00,$00,$00,$00
  3364. sprite_col_buf      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3365. sprite_def_buf      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3366. sprite_anims_buf    !byte $00,$00,$00,$00,$00,$00,$00,$00
  3367. sprite_anime_buf    !byte $00,$00,$00,$00,$00,$00,$00,$00
  3368. sprite_dir_buf      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3369. sprite_spd_buf      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3370. sprite_min_buf      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3371. sprite_max_buf      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3372.  
  3373. ; sprite positions, colours and definitions - title screen bottom
  3374.  
  3375. t_sprite_x      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3376. t_sprite_y      !byte $00,$00,$00,$00,$00,$00,$00,$00
  3377. t_sprite_col    !byte $00,$00,$00,$00,$00,$00,$00,$00
  3378. t_sprite_def    !byte $00,$00,$00,$00,$00,$00,$00,$00
  3379. t_sprite_anims  !byte $00,$00,$00,$00,$00,$00,$00,$00
  3380. t_sprite_anime  !byte $00,$00,$00,$00,$00,$00,$00,$00
  3381.  
  3382. ; cross x-y positions in game copied to during level setup
  3383.  
  3384. cross_x     !byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  3385. cross_y     !byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  3386.  
  3387.  
  3388. ; byte store tables for various things in the next section
  3389. ; these stores are populated during the game
  3390.  
  3391. ; byte store for get ready message printing
  3392.  
  3393. get_ready_des1 !scr "                                        " 
  3394. get_ready_des2 !scr "                                        " 
  3395. get_ready_des3 !scr "                                        "
  3396.  
  3397. ; byte store for current and high scores and cross counter
  3398.  
  3399. score       !byte $00,$00,$00,$00,$00,$00
  3400. high_score  !byte $00,$00,$01,$00,$00,$00
  3401. cross_score !byte $00,$00
  3402.  
  3403. ; status bar screen and colour data
  3404.  
  3405. status_screen_ram
  3406. !byte $20,$13,$03,$0F,$12,$05,$20,$20,$20,$20,$20,$20,$20,$20,$03,$12,$0F,$13,$13,$05
  3407. !byte $13,$20,$20,$20,$20,$08,$09,$2D,$13,$03,$0F,$12,$05,$20,$20,$20,$20,$20,$20,$20
  3408. !byte $05,$0E,$05,$12,$07,$19,$20,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40
  3409. !byte $40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40
  3410.  
  3411. status_colour_ram
  3412. !byte $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$00,$07,$07,$07,$07,$07,$07
  3413. !byte $07,$00,$07,$07,$00,$01,$01,$01,$01,$01,$01,$01,$01,$00,$01,$01,$01,$01,$01,$01
  3414. !byte $02,$02,$02,$02,$02,$02,$01,$02,$02,$02,$02,$02,$07,$07,$07,$07,$07,$07,$05,$05
  3415. !byte $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05
  3416.  
  3417. ; raindrop pattern data
  3418.  
  3419. rain_patt   !byte $ff,$ef,$ff,$ff,$ef,$ff,$ef,$ff
  3420.  
  3421. ; temporary store for downward animating chars
  3422.  
  3423. chardown_temp   !byte $00
  3424.  
  3425. ; cinema screen 'noise' anim pattern data
  3426.  
  3427. scrn0_patt      !byte $54,$ae,$55,$8a,$d5,$aa,$5d,$b0
  3428. scrn1_patt      !byte $a2,$55,$8e,$54,$2a,$51,$ba,$15
  3429.  
  3430. ; sfx data (lower the sfx data, the higher play priority it has)
  3431.  
  3432. sfx_jump
  3433.         !byte $38,$F6,$04,$A0,$21,$A0,$A0,$A6,$A6,$A6,$20,$A9,$A9,$A9,$A2,$A2
  3434.         !byte $A2,$A6,$A6,$A6,$A9,$A9,$A9,$A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9
  3435.         !byte $A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9,$00
  3436.        
  3437. sfx_collect
  3438.         !byte $00,$89,$04,$A2,$41,$A2,$A2,$A6,$A6,$A6,$40,$A9,$A9,$A9,$A2,$A2
  3439.         !byte $A2,$A6,$A6,$A6,$A9,$A9,$A9,$A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9
  3440.         !byte $A2,$A2,$A2,$A6,$A6,$A6,$A9,$A9,$A9,$00
  3441.  
  3442. ; includes to import additional data
  3443.  
  3444.         !src "includes/screen_data.asm"         ; screen / colour ram data
  3445.         !src "includes/chartype_data.asm"       ; chartype for collision detection
  3446.         !src "includes/level_setup_data.asm"    ; level setup subroutines data
  3447.        
  3448. ; end of code!!! ========================================================================
  3449.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement