Advertisement
Guest User

Benny Bunny Returns

a guest
Apr 29th, 2018
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org $6000 ; RANDOMIZE USR 24576
  2.  
  3. ;set paper and border colours
  4.     ld a,71 ;(white ink (7) on black paper (0) & bright (64)
  5.     ld (23693),a
  6.     ld a,1
  7.     call 8859 ;set border colour
  8.  
  9. ;set-up UDGs
  10.     ld hl,udgs
  11.     ld (23675),hl
  12.  
  13. ;open main screen
  14.     call 3503 ;Clear Screen & Open Channel 2
  15.  
  16. ;initialise coordinates
  17.     ld hl,20+(17*256)
  18.     ld (plx),hl
  19.  
  20.     call basexy
  21.     call splayr
  22.     ;call draw
  23.     ;call draw2 ;draw our UDGs
  24.     call screen
  25.    
  26. mloop equ $
  27.  
  28.  
  29.     call basexy
  30.     call wspace
  31.     call mpu
  32.     call basexy
  33.     call wspace
  34.     call mpd
  35.  
  36.  
  37.  
  38.     ;Key Press Checking
  39.     ld bc,63486 ; keyboard row 1-5/joystick port 2.
  40.     in a,(c) ; see what keys are pressed.
  41.     rra ; outermost bit = key 1.
  42.     push af ; remember the value.
  43.     call nc,mpl ; it's being pressed, move left.
  44.     pop af ; restore accumulator.
  45.     rra ; next bit along (value 2) = key 2.
  46.     push af ; remember the value.
  47.     call nc,mpr ; being pressed, so move right.
  48.     pop af ; restore accumulator.
  49.     rra ; next bit (value 4) = key 3.
  50.     push af ; remember the value.
  51.     call nc,mpd ; being pressed, so return to BASIC
  52.     pop af ; restore accumulator.
  53.     rra ; next bit (value 8) reads key 4
  54.     call nc,mpu ; being pressed, so move up.
  55.    
  56.     call basexy
  57.     call splayr
  58.     call mpu
  59.     call basexy
  60.     call splayr2
  61.     call mpd
  62.  
  63.     halt
  64.     jp mloop
  65.  
  66.  
  67. ;labels for key presses
  68. mpl ld hl,ply
  69.     ld a,(hl)
  70.     and a
  71.     ret z
  72. ; now check that there isn't a ladder in the way.
  73.     ld bc,(plx) ; current coords.
  74.     dec b ; look one square to the left
  75.     call atadd ; get address of attribute at this position.
  76.  
  77.    
  78.     ;dec (hl)
  79.     cp 76; ladder is bright (64) + blue paper (1) + green ink (4).
  80.     jp z,ladder; there was a ladder - we need to redraw it.
  81.     dec (hl)
  82.     ret
  83.  
  84. mpr ld hl,ply
  85.     ld a,(hl)
  86.     cp 31
  87.     ret z
  88.    
  89. ; now check that there isn't a ladder in the way.
  90.     ld bc,(plx) ; current coords.
  91.     inc b ; look 1 square to the right.
  92.     call atadd ; get address of attribute at this position.
  93.     cp 76 ;  ladder is bright (64) + blue paper (1) + green ink (4).
  94.     ret z ; there's a ladder - we can't move there.
  95.    
  96.     inc (hl)
  97.     ret
  98.    
  99. mpu ld hl,plx
  100.     ld a,(hl)
  101.     cp 4
  102.     ret z
  103.    
  104.     ld bc,(plx) ; current coords.
  105.     dec c ; look 1 square up.
  106.     call atadd ; get address of attribute at this position.
  107.     cp 68 ;
  108.     ret z ;
  109.    
  110.     dec (hl)
  111.     ret
  112. mpd ld hl,plx
  113.     ld a,(hl)
  114.     cp 21
  115.     ret z
  116.    
  117.     ld bc,(plx) ; current coords.
  118.     inc c ; look 1 square down.
  119.     call atadd ; get address of attribute at this position.
  120.     cp 68
  121.     ret z
  122.    
  123.     inc (hl)
  124.     ret
  125.    
  126. ; Calculate address of attribute for character at (dispx, dispy).
  127. atadd   ld a,c ; vertical coordinate.
  128.         rrca ; multiply by 32.
  129.         rrca ; Shifting right with carry 3 times is
  130.         rrca ; quicker than shifting left 5 times.
  131.         ld e,a
  132.         and 3
  133.         add a,88 ; 88x256=address of attributes.
  134.         ld d,a
  135.         ld a,e
  136.         and 224
  137.         ld e,a
  138.         ld a,b ; horizontal position.
  139.         add a,e
  140.         ld e,a ; de=address of attributes.
  141.         ld a,(de)
  142.         ret ; return with attribute in accumulator.
  143.    
  144. ;Character Printing Routines
  145. basexy  ld a,22
  146.         rst 16
  147.         ld a,(plx)
  148.         rst 16
  149.         ld a,(ply)
  150.         rst 16
  151.         ret
  152.        
  153. splayr  ld a,69
  154.         ld (23695),a
  155.         ld a,145
  156.         rst 16
  157.         ret
  158.  
  159. splayr2 ld a,69
  160.         ld (23695),a
  161.         ld a,144
  162.         rst 16
  163.         ret
  164.        
  165. wspace  ld a,71
  166.         ld (23695),a
  167.         ld a,32
  168.         rst 16
  169.         ret
  170.        
  171. ladder  ld a,76
  172.         ld (23695),a
  173.         ld a,149
  174.         rst 16
  175.         ret
  176.  
  177. ;draw the bunny characters at the bottom of the screen
  178. draw   
  179.         ld a,66
  180.         ld (23695),a
  181.         ld de,string
  182.         ld bc,eostr-string
  183.         call 8252
  184.         ret
  185.  
  186. ;draw the bunny characters at the bottom of the screen (facing the other direction) (Not currently called)
  187. draw4  
  188.         ld a,67
  189.         ld (23695),a
  190.         ld de,string4
  191.         ld bc,eostr4-string4
  192.         call 8252
  193.         ret
  194.  
  195. ;draw the UDGs
  196. draw2   ld a,67
  197.         ld (23695),a
  198.         ld de,string2
  199.         ld bc,eostr2-string2
  200.         call 8252
  201.         ret
  202.  
  203. screen 
  204.         ld de,string3
  205.         ld bc,eostr3-string3
  206.         call 8252
  207.         ret
  208.  
  209.  
  210. plx     defb 0
  211. ply     defb 0
  212.  
  213.  
  214. ;UDG definitions
  215. udgs   
  216.     defb 112,154,159,61,93,117,124,56 ;UDG 144 (A)
  217.     defb 8,62,93,157,21,116,119,7 ;UDG 145 (B)
  218.     defb 14,89,249,188,186,174,62,28 ;UDG 146(C)
  219.     defb 16,124,186,185,168,46,238,224 ;UDG 147(D)
  220.     defb 239,239,239,0,254,254,254,0 ;UDG 148 (E)
  221.     defb 126,66,126,66,126,66,126,66 ;UDG 149 (F)
  222.     defb 255,255,255,252,240,240,224,224 ;UDG 150 (G)
  223.     defb 255,231,255,0,0,0,0,0 ;UDG 151 (H)
  224.     defb 255,255,255,63,15,15,7,7 ;UDG 152 (I)
  225.     defb 255,255,183,221,107,170,84,0 ;UDG 153 (J)
  226.     defb 60,126,219,255,195,195,126,60 ;UDG 154 (K)
  227.  
  228. ;Printing the bunnies!
  229. string defb 22,20,30,144,22,21,30,145,22,20,28,144,22,21,28,145,22,20,26,144,22,21,26,145
  230. eostr equ $
  231.  
  232. ;Printing the bunnies2!
  233. string4 defb 22,20,30,146,22,21,30,147,22,20,28,146,22,21,28,147,22,20,26,146,22,21,26,147
  234. eostr4 equ $
  235.  
  236. ;Printing the UDGs!
  237. string2 defb 22,1,1,144,32,145,32,146,32,147,32,148,32,149,32,150,32,151,32,152,32,153,32,154
  238. eostr2 equ $
  239.  
  240.  
  241. string3 defb 16,2,17,6,22,3,8,148,148,148,148,148,148
  242.     defb 22,3,14,148,148,148,148,148,148
  243.     defb 22,3,26,148,148,148,148,148,148
  244.     defb 22,6,1,148,148,148,148,148,148
  245.     defb 22,9,6,148,148,148,148,148,148
  246.     defb 22,9,12,148,148,148,148,148,148
  247.     defb 22,9,20,148,148,148,148,148,148
  248.     defb 22,15,6,148,148,148,148,148,148
  249.     defb 22,15,12,148,148,148,148,148,148
  250.     defb 22,15,2,148,148,148,148,148,148
  251.  
  252.     defb 16,3,17,6,22,6,20,148,148,148,148,148,148
  253.     defb 22,6,26,148,148,148,148,148,148
  254.     defb 22,12,0,148,148,148,148,148,148
  255.     defb 22,12,6,148,148,148,148,148,148
  256.     defb 22,12,9,148,148,148,148,148,148
  257.     defb 22,12,20,148,148,148,148,148,148
  258.     defb 22,12,26,148,148,148,148,148,148
  259.     defb 22,15,23,148,148,148,148,148,148
  260.     defb 22,15,26,148,148,148,148,148,148
  261.     defb 22,18,0,148,148,148,148,148,148
  262.     defb 22,18,6,148,148,148,148,148,148
  263.     defb 22,18,10,148,148,148,148,148,148
  264.     defb 22,18,18,148,148,148,148,148,148
  265.     defb 22,18,26,148,148,148,148,148,148
  266.  
  267.     defb 16,4,17,1,22,3,20,153,153,153,153,153,153
  268.     defb 22,3,22,153,153,153,153,153,153
  269.     defb 22,6,7,153,153,153,153,153,153
  270.     defb 22,15,9,153,153,153,153,153,153
  271.  
  272.     defb 16,5,22,9,15,150,151,151,151,152
  273.     defb 22,18,9,150,151,151,151,152
  274.     defb 22,18,21,150,151,151,151,152
  275.  
  276.     defb 16,4,17,1,22,3,27,149 ;ladder
  277.     defb 22,4,27,149
  278.     defb 22,5,27,149
  279.  
  280.     defb 22,6,10,149
  281.     defb 22,7,10,149
  282.     defb 22,8,10,149
  283.  
  284.     defb 22,6,23,149
  285.     defb 22,7,23,149
  286.     defb 22,8,23,149
  287.  
  288.     defb 22,9,7,149
  289.     defb 22,10,7,149
  290.     defb 22,11,7,149
  291.  
  292.     defb 22,12,12,149
  293.     defb 22,13,12,149
  294.     defb 22,14,12,149
  295.  
  296.     defb 22,12,24,149
  297.     defb 22,13,24,149
  298.     defb 22,14,24,149
  299.  
  300.     defb 22,15,4,149
  301.     defb 22,16,4,149
  302.     defb 22,17,4,149
  303.  
  304.     defb 22,15,29,149
  305.     defb 22,16,29,149
  306.     defb 22,17,29,149
  307.  
  308.     defb 22,18,8,149
  309.     defb 22,19,8,149
  310.     defb 22,20,8,149
  311.  
  312.     defb 22,18,20,149
  313.     defb 22,19,20,149
  314.     defb 22,20,20,149
  315.  
  316.     defb 16,2,17,6,22,21,0,148,148,148,148,148,148,148,148,148,148,16,3,148,148,148,148,148,148,148,148,148,148,16,2,148,148,148,148,148,148,148,148,148,148,148,148
  317.  
  318.    
  319.    
  320. eostr3 equ $
  321.  
  322. END $6000 ;Used to autostart the .tap file with Pasmo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement