Advertisement
Armakuni

simple asm animation of a jumping sprite on a watermelon background

Aug 15th, 2020 (edited)
4,747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;"ferragosto" greetings, with a recreated sprite from bubble bobble and a watermelon background
  2. ;code by Francesco Clementoni aka Arturo Dente, for Retro Programmers Inside facebook group,  with big thanks to Bed Time Coding lessons from Phaze101
  3. ;launch with SYS49152
  4.  
  5. ScrBase                 = $0400
  6. ColBase                 = $d800
  7. startcol                = $d027
  8. pointer0                = 2040  
  9. bubstart                = 60
  10.  
  11. pointer0val             = 254                          
  12. pointer1val             = 255
  13. spritelocation0         = 16256          
  14. vic                     = $d000    
  15. spriteEnable            = $d015
  16.  
  17.  
  18.  
  19. ;Temp Memory Locations in Page Zero
  20. ZeroTmpMem01            = $02
  21. ZeroTmpMem02            = $2a
  22. ZeroTmpMem03            = $52
  23. ZeroTmpMem04            = $5a
  24. ZeroPtr1Low             = $03
  25. ZeroPtr1High            = $04
  26. ZeroPtr2Low             = $05
  27. ZeroPtr2High            = $06
  28.  
  29.  
  30. ;C64 colours Definitions
  31. Black           =       0
  32. White           =       1
  33. Red             =       2
  34. Cyan            =       3
  35. Purple          =       4
  36. Green           =       5
  37. Blue            =       6
  38. Yellow          =       7
  39. Orange          =       8
  40. Brown           =       9
  41. LightRed        =       10
  42. DarkGray        =       11
  43. MediumGray      =       12
  44. LightGreen      =       13
  45. LightBlue       =       14
  46. LightGray       =       15
  47.  
  48.  
  49. *=$c000
  50.  
  51.  
  52.                         printbackground logochar,logocol
  53.                         jsr     makebub
  54.  
  55.        
  56. ; animation
  57.  
  58. firstanim
  59.  
  60.                 lda     $d012
  61.                 clc
  62.                 cmp     #0
  63.                 bne     firstanim
  64.                
  65. secondwait
  66.                 lda     $d012
  67.                 clc
  68.                 cmp     #200
  69.                 bne     secondwait
  70.  
  71.  
  72.                 lda     direction      
  73.                 beq     dirup
  74. dirdown
  75.                 inx
  76.                 cpx     #180
  77.                 beq     invup
  78.                 lda     #0
  79.                 jsr     setspritey
  80.                 jmp     firstanim
  81. dirup
  82.  
  83.                 dex
  84.                 cpx     #125
  85.                 beq     invdown
  86.                 lda     #0
  87.                 jsr     setspritey
  88.                 jmp     firstanim    
  89.  
  90. invup
  91.                 lda     #0
  92.                 sta     direction
  93.                 jmp     firstanim
  94. invdown  
  95.                 lda     #1
  96.                 sta     direction
  97.                 jmp     firstanim
  98.  
  99. direction
  100.                 byte    1;0=is going up
  101.  
  102.  
  103.  
  104.  
  105.  
  106.                         rts
  107.  
  108. ;=============================================
  109. ;sprites libs
  110. ;=============================================
  111. ;--------------------------------------------
  112. ;fn init sprite: initialize sprite number 'y'
  113. ;where 'y' is the register and y in 0-7
  114. ;and 'a' is the sprite's shape location /64
  115. ;--------------------------------------------
  116. initsprite
  117.                         sta                     pointer0,y;POKE 204x, 192
  118.                         rts
  119. ;-----------------------------------------
  120. ;fn init sprites: initialize sprites based
  121. ;on binary bits of a
  122. ;-----------------------------------------
  123. ;example a=00000011: sprite 0 and 1 initialized
  124. initsprites
  125.                         ldy                     #0
  126.                        
  127.                         sta                     initcache; contains initial argument
  128.                         lda                     #%00000001
  129.                         sta                     ZeroTmpMem01; contains actual bitmask
  130. initspritesloop                        
  131.                         and                     initcache; bitwise and
  132.                         beq                     afterspriteinit; if it's not to init, go further
  133.                         lda                     #pointer0val
  134.                         sty                     ZeroTmpMem02
  135.                         clc
  136.                         adc                     ZeroTmpMem02
  137.                         sta                     pointer0,y
  138.                        
  139. afterspriteinit                        
  140.                         asl                     ZeroTmpMem01;moving bitmask
  141.                         sta                     ZeroTmpMem01
  142.                         iny    
  143.                         tya
  144.                         cmp                     #8
  145.                         beq                     endinitsprites
  146.                         lda                     initcache
  147.                         jmp                     initspritesloop
  148. endinitsprites
  149.  
  150.                         rts
  151.  
  152.  
  153. initcache
  154.                         byte    $0
  155. ;--------------------------------------------
  156. ;fn colorSprite: colours sprite num. y with
  157. ;colour x
  158. ;--------------------------------------------
  159. colorsprite
  160.                         lda                     #<startcol
  161.                         sta                     $fb
  162.                         lda                     #>startcol
  163.                         sta                     $fc
  164.                         txa
  165.                         sta                     ($fb),y
  166.                         rts
  167. ;--------------------------------------------
  168. ;fn setspritex: sets x of sprite numb. a with x value
  169. ;--------------------------------------------
  170. setspritex
  171.  
  172. ;devo memorizzare x in vic+ (2*a)
  173.                         asl     ;a=a*2
  174.                         tay     ;offset pronto
  175.                         txa     ;valore di x pronto
  176.                         sta                     vic,y
  177.                         rts
  178. ;--------------------------------------------
  179. ;fn setspritey: sets y sprite numb. a with x value
  180. ;--------------------------------------------
  181. setspritey
  182.  
  183. ;devo memorizzare y in vic+1+ (2*a)
  184.                         asl     ;a=a*2
  185.                         tay     ;offset = a*2
  186.                         txa     ;valore di x pronto
  187.                         iny     ;offset=2a+1
  188.                         sta                     vic,y
  189.                         rts
  190. ;---------------------------------------------
  191. ;get position x of sprite a. changes a value
  192. ;with result
  193. ;---------------------------------------------
  194. getspritex
  195.                         asl
  196.                         tay
  197.                         lda                     vic,y   ;now a=position x of sprite
  198.                         rts
  199.  
  200. ;---------------------------------------------
  201. ;get position y of sprite a. changes a value
  202. ;with result
  203. ;---------------------------------------------
  204. getspritey
  205.                         asl
  206.                         tay
  207.                         iny
  208.                         lda                     vic,y   ;now a=position x of sprite
  209.                         rts
  210.  
  211.  
  212. ;---------------------------------------------
  213. ;set "big" setting horizontal for sprite pattern in a
  214. ;---------------------------------------------
  215. setBigX
  216.                                                         ;example: lda  #%00000001 for first sprite
  217.                         STA                     $D01D
  218.                         rts
  219. ;---------------------------------------------
  220. ;set "big" setting vertical for sprite pattern in a
  221. ;---------------------------------------------
  222. setBigY
  223.                                                         ;example: lda  #%00000001 for first sprite
  224.                         STA                     $D017
  225.                         rts
  226. ;------------------------------------------------------
  227. ;setMultiColSpr
  228. ;------------------------------------------------------
  229. setMultiColSpr
  230.                                                         ;example: lda  #%00000001 for first sprite
  231.                         STA                     $D01C
  232.                         rts
  233.  
  234. ;------------------------------------------------------
  235. ;setSpriteColorA
  236. ;------------------------------------------------------
  237. setSpriteColorA
  238.                         sta                     $D025
  239.                         rts
  240.  
  241.  
  242. ;------------------------------------------------------
  243. ;setSpriteColorB
  244. ;------------------------------------------------------
  245. setSpriteColorB
  246.                         sta                     $D026
  247.                         rts
  248.  
  249.  
  250. ;------------------------------------------
  251. ;Macro printbackground from data
  252. ;/1 = label for pic data
  253. ;/2 = label for pic colors data
  254. ;------------------------------------------
  255. defm                    printbackground
  256.                         ;jsr                     saveregisters
  257.                         ldx                     #0
  258. @fill
  259.                         lda                     /1,x
  260.                         sta                     ScrBase,x
  261.                         lda                     /2,x
  262.                         sta                     ColBase,x
  263.                         inx
  264.                         cpx                     #200
  265.                         bne                     @fill
  266.                         ldx                     #0
  267. @fill2
  268.                         lda                     /1+#200,x
  269.                         sta                     ScrBase+#200,x
  270.                         lda                     /2+#200,x
  271.                         sta                     ColBase+#200,x
  272.                         inx
  273.                         cpx                     #200
  274.                         bne                     @fill2
  275.                         ldx                     #0
  276. @fill3
  277.                         lda                     /1+#400,x
  278.                         sta                     ScrBase+#400,x
  279.                         lda                     /2+#400,x
  280.                         sta                     ColBase+#400,x
  281.                         inx
  282.                         cpx                     #200
  283.                         bne                     @fill3
  284.                         ldx                     #0
  285. @fill4
  286.                         lda                     /1+#600,x
  287.                         sta                     ScrBase+#600,x
  288.                         lda                     /2+#600,x
  289.                         sta                     ColBase+#600,x
  290.                         inx
  291.                         cpx                     #200
  292.                         bne                     @fill4
  293.                         ldx                     #0
  294. @fill5
  295.                         lda                     /1+#800,x
  296.                         sta                     ScrBase+#800,x
  297.                         lda                     /2+#800,x
  298.                         sta                     ColBase+#800,x
  299.                         inx
  300.                         cpx                     #200
  301.                         bne                     @fill5  ;end logo
  302.                         ;jsr                     loadregisters
  303.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement