Advertisement
Hafixie93

Lab outside watermelon

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