Advertisement
maximinus

Untitled

Apr 9th, 2012
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. ;Video memory goes from 0x8000 to 0x8400
  2.  
  3. ;draw a pretty pattern
  4. ;the pattern is (x^2 + y^2) & 3
  5.  
  6. ;we need 2 loops, for y and x
  7.  
  8. set y, 0
  9. set i, chars
  10. :loopy set x, 0
  11. :loopx set b, x
  12. mul b, b ;b = x^2
  13. set c, y
  14. mul c, c ;c = y^2
  15. add b, c ;b = x^2 + y^2
  16. and b, 3 ;b = (x^2 + y^2) & 3
  17. add i, b
  18. set z, [i] ;short of registers, so we add and then reset
  19. sub i, b
  20. jsr plot
  21. add x, 1
  22. ifn x, 32
  23. set PC, loopx ;inner loop complete
  24. add y, 1
  25. ifn y, 16
  26. set PC, loopy
  27. :end sub PC, 1
  28.  
  29. :chars dat " .oO"
  30.  
  31. ;a function to 'plot' a character on the screen
  32. ;pass the co-rds in the x and y registers, and what to plot in z
  33. ;destroys the a register
  34. ;call with set PC, plot
  35.  
  36. :plot set a, y
  37. mul a, 32
  38. add a, x
  39. add a, 0x8000
  40. set [a], z
  41. set PC, POP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement