Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ; to compile: nasm -f bin fillscr.asm -o fillscr ;
  2. ; to generate  random  colors use "fillscr rnd"  ;
  3. ; otherwise use "filscr r,g,b, r,g,b, r,g,b,..." ;
  4. ORG 0
  5. BITS 32
  6. ; ---------------------------- ;
  7. points         equ END
  8. POINTS_SIZE    equ 108
  9. PARAMS_SIZE    equ 256
  10. ; ---------------------------- ;
  11. MENUET01       db 'MENUET01'
  12. version        dd 1
  13. program.start  dd START
  14. program.end    dd END
  15. program.memory dd END + POINTS_SIZE + PARAMS_SIZE
  16. program.stack  dd 0
  17. program.params dd END + POINTS_SIZE
  18. program.path   dd 0
  19. ; ---------------------------- ;
  20. points_count   dd 0
  21. rnd            dd 0
  22. ; ---------------------------- ;
  23. START:
  24.         mov    edi, points
  25.         mov    esi, [program.params]
  26.         cmp    [esi], dword "rnd"
  27.         jne    .not_rnd
  28.         mov    [points_count], dword POINTS_SIZE / 3
  29.         mov    ecx, POINTS_SIZE / 2
  30. .next_rnd:
  31.         rdtsc
  32.         xor    eax, edx
  33.         xor    [rnd], eax
  34.         imul   eax, [rnd], 134775813
  35.         add    eax, 2531011
  36.         mov    [rnd], eax
  37.         shr    eax, 16
  38.         mov    [edi], ax
  39.         inc    edi
  40.         inc    edi
  41.         loop   .next_rnd
  42.         jmp    .exit
  43. .not_rnd:
  44.         xor    ebp, ebp
  45. .next:
  46. .skip_spaces:
  47.         cmp    [esi], byte " "
  48.         jne    .spaces_skipped
  49.         inc    esi
  50.         jmp    .skip_spaces
  51. .spaces_skipped:
  52. ;         cmp [esi], byte 0
  53. ;         je .exit
  54.         mov    eax, esi
  55. .find_end_or_comma:
  56.         cmp    [esi], byte ","
  57.         je     .end_or_comma_found
  58.         cmp    [esi], byte 0
  59.         je     .end_or_comma_found
  60.         inc    esi
  61.         jmp    .find_end_or_comma
  62. .end_or_comma_found:
  63. ; in eax start   of number
  64. ; in esi pointer to comma or end after number
  65.         mov    ecx, esi
  66.         sub    ecx, eax
  67.         xor    ebx, ebx
  68.         cmp    cl, 1
  69.         jne    .cmp2
  70.         xor    cl, cl
  71.         jmp    .1
  72. .cmp2:
  73.         cmp    cl, 2
  74.         jne    .cmp3
  75.         xor    cl, cl
  76.         jmp    .2
  77. .cmp3:
  78.         cmp    cl, 3
  79.         jne    .exit
  80.         xor    cl, cl
  81. .3:
  82.         movzx  edx, byte[eax + ecx]
  83.         sub    dl, 48
  84.         shl    dl, 2
  85.         lea    edx, [edx * 4 + edx]
  86.         lea    edx, [edx * 4 + edx]
  87.         add    bl, dl
  88.         inc    ecx
  89. .2:
  90.         movzx  edx, byte[eax + ecx]
  91.         sub    dl, 48
  92.         shl    dl,  1
  93.         lea    edx, [edx * 4 + edx]
  94.         add    bl, dl
  95.         inc    ecx
  96. .1:
  97.         movzx  edx, byte[eax + ecx]
  98.         sub    dl, 48
  99.         add    bl, dl
  100.         test   ebp, ebp
  101.         jnz    .cmp_next
  102.         mov    [edi + 2], bl
  103.         jmp    .putted
  104. .cmp_next:
  105.         cmp    ebp, 2
  106.         jne    .cmp_next1
  107.         mov    [edi - 2], bl
  108.         jmp    .putted
  109. .cmp_next1:
  110.         mov    [edi], bl
  111. .putted:
  112.         inc    ebp
  113.         cmp    ebp, 3
  114.         jne    .not_3
  115.         xor    ebp, ebp
  116.         inc    dword[points_count]
  117. .not_3:
  118.         inc    edi
  119.         inc    esi
  120.         jmp    .next
  121. .exit:
  122. ; width = height = sqrt(points_count)
  123.         mov    eax, [points_count]
  124.         or     edx, -1
  125. @@:
  126.         add    edx, 2
  127.         sub    eax, edx
  128.         jnle   @@
  129.         sbb    edx, -1
  130.         shr    edx, 1
  131. ; set width, height
  132.         mov    eax, 15
  133.         mov    ebx, 1
  134.         mov    ecx, edx
  135.         int    64
  136. ; set "stretch"
  137. ;         mov eax, 15
  138.         mov    ebx, 4
  139.         mov    ecx, 2
  140.         int    64
  141. ; put pixels
  142. ;         mov eax, 15
  143.         mov    ebx,  5
  144.         mov    ecx, points       ; BBGGRRBBGGRR...
  145.         xor    edx, edx
  146.         mov    esi, [points_count] ; size of data = count * 3
  147.         lea    esi, [esi * 2 + esi]
  148.         int    64
  149. ; refresh screen
  150. ;         mov eax, 15
  151.         mov    ebx, 3
  152.         int    64
  153. ; thread terminate
  154.         mov    eax, -1
  155.         int    64
  156. END: