Advertisement
yugorin

sinus sprite z funkcją młody

Sep 29th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :BasicUpstart2(main)
  2.  
  3. //./var brkFile = createFile("breakpoints.txt")
  4.  
  5. //.macro break() {
  6.  // .eval brkFile.writeln("break " + toHexString(*))
  7. //}
  8.  
  9. main:
  10.  
  11.     lda #CYAN
  12.     sta $d027
  13.     jsr opoznienie
  14.  
  15.    
  16. ruszaj:
  17.     lda #$00
  18.     sta $d010
  19.  
  20.     lda #$01            // bit 0 zapalony
  21.     sta $d015           // sprite 0 wyświetlony
  22.     ldx #$00            // ustawienie licznika pętli dla sinusa oraz liniowego przemieszczania sprite
  23.  
  24. ruszaj2:
  25.     lda #$01            // bit 0 zapalony
  26.     sta $d015           // sprite 0 wyświetlony
  27.  
  28.     lda sinus(x*10)//,x     // załaduj kolejną wartość z sinusa
  29.     sta $d001           // kooordynaty z sinusa
  30.     sta $0400
  31.     stx $d000           // kooordynaty x+1
  32.     txa                 // zapamiętanie x
  33.     pha                 // na stos przed wykonaniem pętli opóźniającej
  34.     jsr opoznienie 
  35.     pla                 // przywrócenie x ze stosu
  36.     tax                 //
  37.     inx                 // zwiększenie x
  38.     cpx #$00
  39.     beq dodatkowy_bit_dla_sprite
  40.     jmp ruszaj2
  41.  
  42. dodatkowy_bit_dla_sprite:
  43.     lda #$01
  44.     sta $d010
  45.  
  46. ruszaj3:
  47.     lda #$01            // bit 0 zapalony
  48.     sta $d015           // sprite 0 wyświetlony
  49.  
  50.     lda sinus2,x        // załaduj kolejną wartość z sinusa
  51.     sta $d001           // kooordynaty z sinusa
  52.     stx $d000           // kooordynaty x+1
  53.     txa                 // zapamiętanie x
  54.     pha                 // na stos przed wykonaniem pętli opóźniającej
  55.     jsr opoznienie 
  56.     pla                 // przywrócenie x ze stosu
  57.     tax                 //
  58.     inx                 // zwiększenie x
  59.     cpx #$ff
  60.     beq ruszaj
  61. //  :break()
  62.     jmp ruszaj3
  63.  
  64.    
  65. opoznienie:
  66.             ldx #$00   
  67.  
  68. petla1:
  69.             ldy #$00
  70.  
  71. petla2:
  72.             iny
  73.             cpy #$60
  74.             bne petla2
  75.             inx
  76.             cpx #$20
  77.             bne petla1
  78.             rts
  79.    
  80.    
  81. .pc = 64*255 "Default Sprite Bitmap"
  82. //----------------------------------------------------------
  83.  
  84.  
  85.  
  86.  
  87. //.import binary "sprajt1.spr"
  88.  
  89. .byte %01111111, %11111111, %11111110
  90. .byte %11111111, %11111111, %11111111
  91. .byte %11111111, %11111111, %11111111
  92. .byte %11111111, %00000000, %11111111
  93. .byte %11111111, %00000000, %11111111
  94. .byte %11111111, %00000000, %11111111
  95. .byte %11111111, %00000000, %11111111
  96. .byte %11111111, %00000000, %11111111
  97. .byte %11111111, %00000000, %11111111
  98. .byte %11111111, %00000000, %11111111
  99. .byte %11111111, %00000000, %11111111
  100. .byte %11111111, %00000000, %11111111
  101. .byte %11111111, %00000000, %11111111
  102. .byte %11111111, %00000000, %11111111
  103. .byte %11111111, %00000000, %11111111
  104. .byte %11111111, %00000000, %11111111
  105. .byte %11111111, %00000000, %11111111
  106. .byte %11111111, %00000000, %11111111
  107. .byte %11111111, %11111111, %11111111
  108. .byte %11111111, %11111111, %11111111
  109. .byte %01111111, %11111111, %11111110
  110.  
  111.  
  112.  
  113. .pc = $c000
  114. //sinus:
  115.  
  116. //.fill 512,<round(0+16256*sin(toRadians(i*360/256+360/512)))
  117.  
  118. //.fill 512,>round(0+16256*sin(toRadians(i*360/256+360/512)))
  119.  
  120.  
  121.  
  122. // sinus:
  123.  
  124. .byte $78,$76,$75,$73,$72,$70,$6F,$6D,$6C,$6A,$69,$68,$66,$65,$64,$62
  125. .byte $61,$60,$5F,$5E,$5D,$5C,$5A,$59,$59,$58,$57,$56,$55,$54,$54,$53
  126. .byte $53,$52,$51,$51,$51,$50,$50,$50,$50,$50,$50,$50,$50,$50,$50,$50
  127. .byte $50,$51,$51,$51,$52,$52,$53,$54,$54,$55,$56,$57,$57,$58,$59,$5A
  128. .byte $5B,$5C,$5E,$5F,$60,$61,$62,$64,$65,$66,$67,$69,$6A,$6C,$6D,$6E
  129. .byte $70,$71,$73,$74,$76,$77,$79,$7A,$7C,$7D,$7F,$80,$81,$83,$84,$86
  130. .byte $87,$88,$8A,$8B,$8C,$8E,$8F,$90,$91,$92,$93,$94,$95,$96,$97,$98
  131. .byte $99,$9A,$9A,$9B,$9C,$9C,$9D,$9D,$9E,$9E,$9F,$9F,$9F,$9F,$9F,$9F
  132. .byte $9F,$9F,$9F,$9F,$9F,$9F,$9E,$9E,$9E,$9D,$9D,$9C,$9B,$9B,$9A,$99
  133. .byte $99,$98,$97,$96,$95,$94,$93,$92,$91,$8F,$8E,$8D,$8C,$8A,$89,$88
  134. .byte $86,$85,$84,$82,$81,$7F,$7E,$7C,$7B,$79,$78,$77,$75,$74,$72,$71
  135. .byte $6F,$6E,$6C,$6B,$6A,$68,$67,$65,$64,$63,$62,$60,$5F,$5E,$5D,$5C
  136. .byte $5B,$5A,$59,$58,$57,$56,$55,$55,$54,$53,$53,$52,$52,$51,$51,$50
  137. .byte $50,$50,$50,$50,$50,$50,$50,$50,$50,$50,$50,$51,$51,$51,$52,$52
  138. .byte $53,$53,$54,$55,$56,$56,$57,$58,$59,$5A,$5B,$5C,$5D,$5E,$5F,$61
  139. .byte $62,$63,$64,$66,$67,$68,$6A,$6B,$6D,$6E,$6F,$71,$72,$74,$75,$77
  140.  
  141.  
  142. sinus2:
  143. .byte $78,$7A,$7B,$7D,$7E,$80,$81,$82,$84,$85,$87,$88,$89,$8B,$8C,$8D
  144. .byte $8E,$90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$99,$9A,$9B,$9C,$9C
  145. .byte $9D,$9D,$9E,$9E,$9E,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F
  146. .byte $9F,$9E,$9E,$9D,$9D,$9C,$9C,$9B,$9A,$9A,$99,$98,$97,$96,$95,$94
  147. .byte $93,$92,$91,$90,$8F,$8D,$8C,$8B,$8A,$88,$87,$85,$84,$83,$81,$80
  148. .byte $7E,$7D,$7B,$7A,$78,$77,$76,$74,$73,$71,$70,$6E,$6D,$6B,$6A,$69
  149. //.byte $67,$66,$65,$63,$62,$61,$60,$5E,$5D,$5C,$5B,$5A,$59,$58,$57,$56
  150. //.byte $56,$55,$54,$54,$53,$52,$52,$51,$51,$51,$50,$50,$50,$50,$50,$50
  151. //.byte $50,$50,$50,$50,$50,$50,$51,$51,$52,$52,$53,$53,$54,$55,$55,$56
  152. //.byte $57,$58,$59,$5A,$5B,$5C,$5D,$5E,$5F,$60,$61,$63,$64,$65,$67,$68
  153. //.byte $69,$6B,$6C,$6E,$6F,$70,$72,$73,$75,$76,$78,$79,$7B,$7C,$7E,$7F
  154. //.byte $81,$82,$83,$85,$86,$88,$89,$8A,$8B,$8D,$8E,$8F,$90,$91,$93,$94
  155. //.byte $95,$96,$97,$98,$98,$99,$9A,$9B,$9B,$9C,$9D,$9D,$9E,$9E,$9E,$9F
  156. //.byte $9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9F,$9E,$9E,$9E,$9D,$9C
  157. // .byte $9C,$9B,$9B,$9A,$99,$98,$97,$96,$96,$95,$93,$92,$91,$90,$8F,$8E
  158. //.byte $8D,$8B,$8A,$89,$87,$86,$85,$83,$82,$80,$7F,$7D,$7C,$7A,$79,$78
  159.  
  160.  
  161. .function sinus(kat) {
  162.  .var y = kat
  163.  .var s = -1
  164.  .for (var i=3; i<=100; i+=2)
  165.  {
  166.   .eval y = y + s * ( pow(kat,i) / silnia(i) )
  167.    .eval s = s * s - 1
  168.  }
  169.  .return y
  170. }
  171.  
  172. .function silnia(liczba)
  173. {
  174.    .if (liczba == 0)
  175.    {
  176.      .return 1
  177.    }
  178.    .return (liczba * silnia(liczba - 1))
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement