Advertisement
Guest User

Benny Bunny Returns

a guest
Apr 29th, 2018
108
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 mushroom 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 mushroom 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. ; now check that there isn't a mushroom in the way.
  105.     ld bc,(plx) ; current coords.
  106.     dec c ; look 1 square up.
  107.     call atadd ; get address of attribute at this position.
  108.     cp 68 ; mushrooms are bright (64) + green (4).
  109.     ret z ; there's a mushroom - we can't move there.
  110.    
  111.     dec (hl)
  112.     ret
  113. mpd ld hl,plx
  114.     ld a,(hl)
  115.     cp 21
  116.     ret z
  117.    
  118. ; now check that there isn't a mushroom in the way.
  119.     ld bc,(plx) ; current coords.
  120.     inc c ; look 1 square down.
  121.     call atadd ; get address of attribute at this position.
  122.     cp 68 ; mushrooms are bright (64) + green (4).
  123.     ret z ; there's a mushroom - we can't move there.
  124.    
  125.     inc (hl)
  126.     ret
  127.    
  128. ; Calculate address of attribute for character at (dispx, dispy).
  129. atadd   ld a,c ; vertical coordinate.
  130.         rrca ; multiply by 32.
  131.         rrca ; Shifting right with carry 3 times is
  132.         rrca ; quicker than shifting left 5 times.
  133.         ld e,a
  134.         and 3
  135.         add a,88 ; 88x256=address of attributes.
  136.         ld d,a
  137.         ld a,e
  138.         and 224
  139.         ld e,a
  140.         ld a,b ; horizontal position.
  141.         add a,e
  142.         ld e,a ; de=address of attributes.
  143.         ld a,(de)
  144.         ret ; return with attribute in accumulator.
  145.    
  146. ;Character Printing Routines
  147. basexy  ld a,22
  148.         rst 16
  149.         ld a,(plx)
  150.         rst 16
  151.         ld a,(ply)
  152.         rst 16
  153.         ret
  154.        
  155. splayr  ld a,69
  156.         ld (23695),a
  157.         ld a,145
  158.         rst 16
  159.         ret
  160.  
  161. splayr2 ld a,69
  162.         ld (23695),a
  163.         ld a,144
  164.         rst 16
  165.         ret
  166.        
  167. wspace  ld a,71
  168.         ld (23695),a
  169.         ld a,32
  170.         rst 16
  171.         ret
  172.        
  173. ladder  ld a,76
  174.         ld (23695),a
  175.         ld a,149
  176.         rst 16
  177.         ret
  178.  
  179. ;draw the bunny characters at the bottom of the screen
  180. draw   
  181.         ld a,66
  182.         ld (23695),a
  183.         ld de,string
  184.         ld bc,eostr-string
  185.         call 8252
  186.         ret
  187.  
  188. ;draw the bunny characters at the bottom of the screen (facing the other direction) (Not currently called)
  189. draw4  
  190.         ld a,67
  191.         ld (23695),a
  192.         ld de,string4
  193.         ld bc,eostr4-string4
  194.         call 8252
  195.         ret
  196.  
  197. ;draw the UDGs
  198. draw2   ld a,67
  199.         ld (23695),a
  200.         ld de,string2
  201.         ld bc,eostr2-string2
  202.         call 8252
  203.         ret
  204.  
  205. screen 
  206.         ld de,string3
  207.         ld bc,eostr3-string3
  208.         call 8252
  209.         ret
  210.  
  211.  
  212. plx     defb 0
  213. ply     defb 0
  214.  
  215.  
  216. ;UDG definitions
  217. udgs   
  218.     defb 112,154,159,61,93,117,124,56 ;UDG 144 (A)
  219.     defb 8,62,93,157,21,116,119,7 ;UDG 145 (B)
  220.     defb 14,89,249,188,186,174,62,28 ;UDG 146(C)
  221.     defb 16,124,186,185,168,46,238,224 ;UDG 147(D)
  222.     defb 239,239,239,0,254,254,254,0 ;UDG 148 (E)
  223.     defb 126,66,126,66,126,66,126,66 ;UDG 149 (F)
  224.     defb 255,255,255,252,240,240,224,224 ;UDG 150 (G)
  225.     defb 255,231,255,0,0,0,0,0 ;UDG 151 (H)
  226.     defb 255,255,255,63,15,15,7,7 ;UDG 152 (I)
  227.     defb 255,255,183,221,107,170,84,0 ;UDG 153 (J)
  228.     defb 60,126,219,255,195,195,126,60 ;UDG 154 (K)
  229.  
  230. ;Printing the bunnies!
  231. 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
  232. eostr equ $
  233.  
  234. ;Printing the bunnies2!
  235. 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
  236. eostr4 equ $
  237.  
  238. ;Printing the UDGs!
  239. 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
  240. eostr2 equ $
  241.  
  242.  
  243. string3 defb 16,2,17,6,22,3,8,148,148,148,148,148,148
  244.     defb 22,3,14,148,148,148,148,148,148
  245.     defb 22,3,26,148,148,148,148,148,148
  246.     defb 22,6,1,148,148,148,148,148,148
  247.     defb 22,9,6,148,148,148,148,148,148
  248.     defb 22,9,12,148,148,148,148,148,148
  249.     defb 22,9,20,148,148,148,148,148,148
  250.     defb 22,15,6,148,148,148,148,148,148
  251.     defb 22,15,12,148,148,148,148,148,148
  252.     defb 22,15,2,148,148,148,148,148,148
  253.  
  254.     defb 16,3,17,6,22,6,20,148,148,148,148,148,148
  255.     defb 22,6,26,148,148,148,148,148,148
  256.     defb 22,12,0,148,148,148,148,148,148
  257.     defb 22,12,6,148,148,148,148,148,148
  258.     defb 22,12,9,148,148,148,148,148,148
  259.     defb 22,12,20,148,148,148,148,148,148
  260.     defb 22,12,26,148,148,148,148,148,148
  261.     defb 22,15,23,148,148,148,148,148,148
  262.     defb 22,15,26,148,148,148,148,148,148
  263.     defb 22,18,0,148,148,148,148,148,148
  264.     defb 22,18,6,148,148,148,148,148,148
  265.     defb 22,18,10,148,148,148,148,148,148
  266.     defb 22,18,18,148,148,148,148,148,148
  267.     defb 22,18,26,148,148,148,148,148,148
  268.  
  269.     defb 16,4,17,1,22,3,20,153,153,153,153,153,153
  270.     defb 22,3,22,153,153,153,153,153,153
  271.     defb 22,6,7,153,153,153,153,153,153
  272.     defb 22,15,9,153,153,153,153,153,153
  273.  
  274.     defb 16,5,22,9,15,150,151,151,151,152
  275.     defb 22,18,9,150,151,151,151,152
  276.     defb 22,18,21,150,151,151,151,152
  277.  
  278.     defb 16,4,17,1,22,3,27,149 ;ladder
  279.     defb 22,4,27,149
  280.     defb 22,5,27,149
  281.  
  282.     defb 22,6,10,149
  283.     defb 22,7,10,149
  284.     defb 22,8,10,149
  285.  
  286.     defb 22,6,23,149
  287.     defb 22,7,23,149
  288.     defb 22,8,23,149
  289.  
  290.     defb 22,9,7,149
  291.     defb 22,10,7,149
  292.     defb 22,11,7,149
  293.  
  294.     defb 22,12,12,149
  295.     defb 22,13,12,149
  296.     defb 22,14,12,149
  297.  
  298.     defb 22,12,24,149
  299.     defb 22,13,24,149
  300.     defb 22,14,24,149
  301.  
  302.     defb 22,15,4,149
  303.     defb 22,16,4,149
  304.     defb 22,17,4,149
  305.  
  306.     defb 22,15,29,149
  307.     defb 22,16,29,149
  308.     defb 22,17,29,149
  309.  
  310.     defb 22,18,8,149
  311.     defb 22,19,8,149
  312.     defb 22,20,8,149
  313.  
  314.     defb 22,18,20,149
  315.     defb 22,19,20,149
  316.     defb 22,20,20,149
  317.  
  318.     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
  319.  
  320.    
  321.    
  322. eostr3 equ $
  323.  
  324. END $6000 ;Used to autostart the .tap file with Pasmo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement