Guest User

Matrix digital rain

a guest
Apr 7th, 2012
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set z, 0x1234 ; rand_seed
  2. set y, z ; cur_rand
  3. set pc, main_loop
  4.  
  5. :next_rand
  6. mul y, 10061
  7. add y, 1
  8. set pc, pop
  9.  
  10. :main_loop
  11. set i, 0
  12. set x, y
  13. set y, z
  14. set a, 0x8000
  15.  
  16. :next_row1
  17.   set j, 0
  18.   :next_char1
  19.     jsr next_rand
  20.     ife [a], 0
  21.     set pc, skip1
  22.     ifb y, 0x7000
  23.     set pc, skip1
  24.  
  25.     ; mutate char at [a] (j, i)
  26.     set push, y
  27.     set y, x
  28.     jsr next_rand
  29.     and [a], 0xff00 ; reset char
  30.     and y, 0x003f
  31.     bor [a], [code+y] ; set letter
  32.     set x, y
  33.     set y, pop
  34.    
  35.     :skip1
  36.     add j, 1
  37.     add a, 1
  38.     ifg 32, j
  39.     set pc, next_char1
  40.   add i, 1
  41.   ifg 12, i
  42.   set pc, next_row1
  43. set y, x
  44.  
  45. ; step 2: move all columns down
  46. set i, 12
  47. set a, 0x817f
  48.  
  49. :next_row2
  50.   set j, 32
  51.   :next_char2
  52.     ife [a], 0
  53.     set pc, empty_char
  54.     ifb [a+32], 0xffff
  55.     set pc, move_down
  56.  
  57.     ; add new char at [a+32] (j, i+1)
  58.     jsr next_rand
  59.     set [a+32], [a]
  60.     and [a+32], 0xff00
  61.     set x, y
  62.     and x, 0x003f
  63.     bor [a+32], [code+x]
  64.     and [a], 0x7fff
  65.     set pc, skip2
  66.    
  67.     :empty_char
  68.     set [a+32], 0
  69.  
  70.     :move_down
  71.     and [a+32], 0x7fff
  72.  
  73.     :skip2
  74.     sub j, 1
  75.     sub a, 1
  76.     ifg j, 0
  77.     set pc, next_char2
  78.   sub i, 1
  79.   ifg i, 0
  80.   set pc, next_row2
  81. set y, x
  82.  
  83. ; step 3: update top layer
  84. set a, 0x8000
  85. set j, 0
  86. :next_char3
  87.   jsr next_rand
  88.   ifb y, 0x0700
  89.   set pc, skip3
  90.   ifb [a], 0xffff
  91.   set pc, empty_char2
  92.  
  93.   set [a], 0x2000
  94.   ifb y, 0x0800
  95.   set [a], 0xa000
  96.   set x, y
  97.   and x, 0x003f
  98.   bor [a], [code+x]
  99.   set pc, skip3
  100.  
  101.   :empty_char2
  102.   set [a], 0
  103.  
  104.   :skip3
  105.   add j, 1
  106.   add a, 1
  107.   ifg 32, j
  108.   set pc, next_char3
  109.  
  110. set PC, main_loop
  111.  
  112. sub PC, 1
  113.  
  114. :code dat "00112334567889&||!!@==::**##<>>__TYYUDQZJJIX- ~~oiwlrkm//\\'[]^)`"
Advertisement
Add Comment
Please, Sign In to add comment