精華區beta Programming 關於我們 聯絡資訊
==> lonewolf (妳還好嗎...) 提到: : 請問... : 用組合語言寫的話,要怎要再螢幕上畫一個圓ㄚ..(vga or svga) : 謝謝.. 組合語言畫圓副程式 extrn s364kpoint:near ; s364kpoint S3 顯示卡畫點副程式請參考文魁出版的 ; "滑鼠驅動程式設計實務" vcolor dw 7070h TOTALXRES DW 1024 TOTALYRES DW 768 mov ax,76h ;S3 775/785 1024*768 65536 color INT 10H mov word ptr totalxres,1024 mov ax,0a000h mov es,ax push 60 push 500 push 500 call circle add sp,6 public circle circle proc near push si push di enter 2,0 mov di,word ptr [bp+12] ;radius xor si,si mov ax,di shl ax,1 mov dx,3 sub dx,ax mov word ptr [bp-2],dx circle2: cmp si,di jl circle6 jmp circle3 circle6: push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,di push ax mov ax,word ptr [bp+8] ;center x add ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,di push ax mov ax,word ptr [bp+8] ;center x sub ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,di push ax mov ax,word ptr [bp+8] ;center x add ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,di push ax mov ax,word ptr [bp+8] ;center x sub ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,si push ax mov ax,word ptr [bp+8] ;center x add ax,di push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,si push ax mov ax,word ptr [bp+8] ;center x sub ax,di push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,si push ax mov ax,word ptr [bp+8] ;center x add ax,di push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,si push ax mov ax,word ptr [bp+8] ;center x sub ax,di push ax call near ptr s364kpoint add sp,6 pop di mov ax,si shl ax,2 add ax,word ptr [bp-2] add ax,6 mov word ptr [bp-2],ax cmp word ptr [bp-2],0 jle circle4 mov ax,di shl ax,2 mov dx,word ptr [bp-2] sub dx,ax add dx,4 mov word ptr [bp-2],dx mov ax,di dec ax mov di,ax circle4: mov ax,si inc ax mov si,ax jmp circle2 circle3: cmp si,di je circle7 jmp circle5 circle7: push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,di push ax mov ax,word ptr [bp+8] ;center x add ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,di push ax mov ax,word ptr [bp+8] ;center x sub ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,di push ax mov ax,word ptr [bp+8] ;center x add ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,di push ax mov ax,word ptr [bp+8] ;center x sub ax,si push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,si push ax mov ax,word ptr [bp+8] ;center x add ax,di push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y add ax,si push ax mov ax,word ptr [bp+8] ;center x sub ax,di push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,si push ax mov ax,word ptr [bp+8] ;center x add ax,di push ax call near ptr s364kpoint add sp,6 pop di push di mov ax,vcolor push ax mov ax,word ptr [bp+10] ;center y sub ax,si push ax mov ax,word ptr [bp+8] ;center x sub ax,di push ax call near ptr s364kpoint add sp,6 pop di circle5: leave pop di pop si ret circle endp -- ◎(bbs.mgt.ncu.edu.tw) ◎[ddjmgmc]來自: 139.175.193.57 > -------------------------------------------------------------------------- < 發信人: PAUL.bbs@bbs.cs.nthu.edu.tw (不事修飾), 看板: Programming 標 題: Re: 請問有關組合語言.... 發信站: 清華資訊(楓橋驛站) (Thu Dec 17 14:23:47 1998) 轉信站: Ptt!news.ntu!ctu-gate!news.nctu!newsfeed.nthu!news.cs.nthu!maple ※ 引述《lonewolf.bbs@bbs.mgt.ncu.edu.tw (妳還好嗎...)》之銘言: > 請問... > 用組合語言寫的話,要怎要再螢幕上畫一個圓ㄚ..(vga or svga) > 謝謝.. 以下是在以前DOS下的組合語言寫法(很多年了吧!! 我是從以前的backup挖出來了, 那時我才高二) 這個Algorithm不用任何乘除法只用加減法畫圓, 有興趣可以再進一步speed up它, 下面的只是初稿. 週邊的副程度自己寫吧! 我想會問這個問題的人 應該早就會用assembly切換繪圖模式, 以及畫上一 個點了,.....:) -------------------------------------------- ; cx : 為圓心x座標 ; dx : 為圓心y座標 ; bx : 半徑 circle proc near push bx push cx push dx mov centerx,cx mov centery,dx xor cx,cx mov dx,bx shl bx,1 neg bx add bx,3 step1: cmp cx,dx jg step4 call dot8 cmp bx,0 jge step2 mov ax,cx shl ax,2 add bx,ax add bx,6 jmp step3 step2: mov ax,cx sub ax,dx shl ax,2 add bx,ax add bx,10 dec dx step3: inc cx jmp step1 step4: pop dx pop cx pop bx ret circle endp dot8 proc near push cx push dx call dot1 xchg cx,dx call dot1 neg dx call dot1 xchg cx,dx call dot1 neg dx call dot1 xchg cx,dx call dot1 neg dx call dot1 xchg cx,dx call dot1 pop dx pop cx dot8 endp dot1 proc near push cx push dx add cx,centerx add dx,centery call dot ; 假設以已經寫好了一個在 ; 螢幕上畫一個點的proc了 ; 名稱是 dot而且(cx,dx) ; 為其座標 pop dx pop cx dot1 endp -- If you love a girl very very much, let she goes free. If she doesn't come back, she is never yours If she comes back, love her forever. -- ※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: paul.cs.nthu.edu.tw