0 Members and 1 Guest are viewing this topic.
rbrazCBM 128 Posts: 152(29/3/06 23:48)Reply | Edit  Assembly - Draw 2D sine wave-------------------------------------------------------------------------------- Here a code for a simple sine wave (VGA mode X). Compile with FASMW 1.65 Hope its useful for someone...;--------------------------------------------------------------------org 100h;-------------VGA mode X - 320x200x256kmov al,13hint 10hpush 0a000h ; Vga memorypop es ;;-------------- Palettemov dx,3c8hmov al,32 ;[col]out dx,alinc dxmov al,63 ;[ r ]out dx,almov al,40 ;[ g ]out dx,almov al,0 ;[ b ]out dx,al;--------------Main:;-------------Wait for vertical retracemov dx,03DAh.wait_for_retrace:in al,dxtest al,8jz .wait_for_retrace;-------------Clear Screenxor ax,axxor di,dimov cx,16000rep stosd.draw:;-------------Sine wave functionfld [angle]fadd [one]fst [angle]fdiv [twopi]fsinfmul [mult]fadd [ center ]fistp [y]mov ax,word [y]mov bx,[x] ; bx = x;-------------WritePixelFast :); vgamemory[x + (y*320)] = color ; bx=x, ax=y, cl=colorimul ax,320add ax,bxmov di,axmov byte [es:di],32 ; color = 32 or clmov ax,0 ; clear axmov bx,0 ; clear bx;-------------Increments x posinc [x]cmp [x],319je .lp1jmp .draw.lp1:mov [x],0; mov [angle],0;-------------Loop (While not key hit)mov ah,01int 16hjz Main;-------------Return to text modemov al,03hint 10h;-------------Exit to DOSmov ax,4c00hint 21h;-------------Some variablesangle dd 0.0one dd 0.25mult dd 20.0center dd 100.0y dd 0.0x dw 0twopi dd 6.2830Edited by: rbraz at: 29/3/06 23:51
Thygrion DBF: Coder Posts: 353(10/4/06 2:54)Reply  Re: Assembly - Draw 2D sine wave-------------------------------------------------------------------------------- you really need to begin tinycoding (try 256 or 512 bytes - nothing less is worth the time IMO) !! --------------------------------------------------------------------------------Finally 14!!
rbrazCBM 128 Posts: 159(10/4/06 19:06)Reply | Edit  Re: Assembly - Draw 2D sine wave-------------------------------------------------------------------------------- I just love tinycoding Did you see my two ogl 1K prods?I just need a good idea, and something that I can code in asm, of course
Clyde Radcliffe Fuzzy Wuzzy Posts: 18231(10/4/06 21:41)Reply  Re: Assembly - Draw 2D sine wave-------------------------------------------------------------------------------- We'll if its ideas then Ive plenty in store for us in Gravity land ;)Â