Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ; Mathematical functions
  3. ;
  4. ; Author:   Trans
  5. ; Date:     08.03.2005
  6. ; Compiler: FASM
  7. ; Target:   Hunter - MeOS game
  8. ;
  9.  
  10. rinit   dw 0
  11.  
  12. ; Randomize of 8 bits
  13. ; In:
  14. ; Out: AL - random value
  15. random_8:
  16.         push ebx
  17.         push ecx
  18.         xor eax,eax
  19.         mov ax,[rinit]
  20.         cmp ax,0
  21.         jnz rand_loc_00
  22.         mov eax,26
  23.         mov ebx,9
  24.         int 40h
  25.         mov [rinit],ax
  26.         shl eax,16
  27.         shr eax,16
  28. rand_loc_00:
  29.         mov ecx,8
  30. rand_loc_01:
  31.         mov bx,ax
  32.         and bx,002Dh
  33.         xor bh,bl
  34.         clc
  35.         jpe rand_loc_01a
  36.         stc
  37. rand_loc_01a:
  38.         rcr ax,1
  39.         loop rand_loc_01
  40.         mov [rinit],ax
  41.         xor ah,ah
  42.         pop ecx
  43.         pop ebx
  44.         retn
  45.