Guest User

optimize-2 http://habrahabr.ru/blogs/asm/121999/

a guest
Jun 17th, 2011
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Swirl by k06a
  2. ; Dedicated to my wife 9ka
  3. org   100h
  4. ; [106h] == 0
  5.  
  6. main:
  7.     mov si, 0A000h
  8.     mov es, si
  9.     mov di, RRR
  10.     mov bp, 13 ; kruch
  11.  
  12.     ; ????????? ????? ?????? 320x200x256
  13.     mov al, 13h
  14.     int 10h
  15.  
  16.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.     ; ?????????? ??? ????? ?????? ????????? ;
  18.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19.     paint:
  20.         mov bh, 0FAh
  21.         lp1:
  22.             mov  ax, bx
  23.             xor  dx, dx
  24.             div  word [_320+di-RRR]
  25.             sub  ax, 100
  26.             sub  dx, 160
  27.  
  28.                 ; ?????? ? [sin] ??????? ???? ?? K2
  29.                
  30.                 fninit
  31.                 mov   word [si], ax    ; COS
  32.                 fild  word [si]
  33.                 mov   word [si], dx    ; SIN
  34.                 fild  word [si]
  35.                 fpatan
  36.                 fimul word [vnum+di-RRR]
  37.                 fmul  dword [glad+di-RRR]
  38.                 fistp word [si]
  39.  
  40.                 imul  ax, ax
  41.                 imul  dx, dx
  42.                 add   ax, dx
  43.                 xor   dx, dx
  44.                 div   bp
  45.                 add   ax, [si]
  46.                
  47.                 ; ?????? ???????
  48.                 dec  bx                
  49.                 mov  byte [es:bx], al
  50.                 jnz  lp1
  51.  
  52.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  53.  
  54.     ; ??????????? ????? ???????
  55.     ; CL - ???????, ???????? ??????? ?? ?????
  56.     ; CH - ?????!!! ???????? ????????
  57.     loop_pal_out:
  58.         add  ch, cl ; [DELTA]
  59.        
  60.         ;;;;;;;;;;;;;;;;;;;;;;;;
  61.         ; CL - Cycled Shifting ;
  62.         ; AL := 0, AH := XXh   ;
  63.         ;;;;;;;;;;;;;;;;;;;;;;;;
  64.         setPalette:
  65.             xor  al, al ; ??? ????????? ?????
  66.             setPalette_loop:
  67.                 mov  ah, al            
  68.                
  69.                 shr  ah, 1
  70.                 ;call setColor
  71.                
  72.                 ;;;;;;;;;;;;;;;;;;;;;;;;
  73.                 ; AL - ????? ? ??????? ;
  74.                 ; AH - Grayscale color ;
  75.                 ;;;;;;;;;;;;;;;;;;;;;;;;
  76.                 setColor:
  77.                 pusha
  78.                 add  al, ch ; + ??????
  79.  
  80.                     mov dx, 03c8h
  81.                     out dx, al
  82.                     inc dx
  83.                    
  84.                     mmm:              
  85.                         mov al, ah
  86.                         and al, [di+bx]
  87.                         out dx, al
  88.                         inc bx
  89.                         jnp mmm
  90.  
  91.                        
  92.                 popa
  93.                 xor al, 0xFF
  94.                 js  setColor
  95.                 ;;;;;;;;;;;;;;;;;;;;;;;;    
  96.                
  97.                 inc  al
  98.             jns  setPalette_loop
  99.         ;;;;;;;;;;;;;;;;;;;;;;;;
  100.    
  101.         ; ???????? ?? ??????? ???????
  102.         mov  ah, 0Bh ; AX := 0B00h
  103.         int  21h
  104.         cmp  al, 0ffh
  105.  
  106.         jmp_loop_pal_out:
  107.         jne  loop_pal_out
  108.  
  109.         ; ??????? ???????
  110.         mov  ah, 08h
  111.         int  21h
  112.  
  113.         label_push_down:
  114.             cmp  al, 80
  115.             jne  label_push_up
  116.             dec  bp
  117.             jnz  paint_me
  118.             inc_kruch_paint_me:
  119.             inc  bp
  120.             paint_me:
  121.             jmp  paint
  122.  
  123.         label_push_up:
  124.             cmp  al, 72
  125.             je   inc_kruch_paint_me
  126.    
  127.         label_push_space:
  128.             cmp  al, ' '
  129.             jne  label_push_left
  130.             mov  cl, 0
  131.  
  132.         label_push_left:
  133.             cmp  al, 75
  134.             jne  label_push_right
  135.             dec  cx
  136.  
  137.         label_push_right:
  138.             cmp  al, 77
  139.             jne  label_push_R
  140.             inc  cx
  141.    
  142.         label_push_R:
  143.             cmp  al, 'r'
  144.             je   change_color
  145.             inc  bx
  146.             cmp  al, 'g'
  147.             je   change_color
  148.             inc  bx
  149.             cmp  al, 'b'
  150.             jne  label_push_digit
  151.         change_color:
  152.             not  byte [di+bx]
  153.        
  154.         label_push_digit:
  155.             xor  bx, bx
  156.             sub  al, '0'
  157.             cmp  al, 9
  158.             ja   label_push_esc
  159.             mov  byte [vnum], al
  160.             jmp  paint_me
  161.        
  162.         label_push_esc:
  163.             cmp  al, 27-'0'
  164.             jne  jmp_loop_pal_out
  165.             ret
  166. ;main   endp
  167.  
  168. RRR   db 0
  169. GGG   db 255
  170. BBB   db 0
  171.  
  172. glad  dd 40.75 ; 163/4
  173. vnum  dw 3
  174. _320  dw 320
  175.  
  176. ;sign  db 'Dedicated to my wife 9'
Add Comment
Please, Sign In to add comment