Liniensubroutine zeichnet krumme Linien



  • Hatte letzten Monat schon mal in dieses Forum ein Thema gesetzt.
    Aber leider hatte niemand Lust, sich meinen Code genauer anzusehen.
    Vielleicht ist ja heute jemand online gegangen, der auch so begeistert von Assembler ist, wie ich.

    Mein Linienprogramm zeichnet krumme Linien.
    Das Demonstrationsprogramm zeichnet Linien vom linken oberen Punkt angefangen an durchgehend bis zum rechten oberen Punkt lauter Linien, die alle am Mittelpunkt des Bildschirmes enden. Es muesste also nach dem Zeichnen ein Dreieck zu sehen sein, das von der Mitte des Bildschirmes bis zum oberen Rand verlaeuft.
    Aber in der Mitte bei X-Koordinate 160 werden die Linien krum und schwanken von links nach rechts, so dass lauter Luecken entstehen.
    Wer findet den Fehler, der die Linien krumm macht?

    COMMENT ~ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

    Datei: Punkt.ASM

    setzt Punkte einer Linie in der Farbe Gelb auf den VGA Videoschirm
    mit der Restmethode - schwankungen bei linien mit negativer steigung

    Copyright: (c) 2005 Eric N. Falbe

    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ-~

    Code SEGMENT BYTE PUBLIC 'CODE'
    .386

    ; Meldungen:

    Msg1 DB 'Textausgabe ist OK! Supeeeeeer!! Duper!!! Schwankungen',13,10,'$'
    Oben DB 0,1,2,3
    x DW 012h,0a0h,070h,0
    y DW 030h,064h,0a0h,0
    x1 DW 0
    y1 DW 0
    deltax DW 0,0,0,0
    deltay DW 0,0,0,0
    m DW 0,1
    Rest DW 0

    ASSUME CS:CODE, DS:CODE

    Start:
    mov ax,CODE ; Segmentadresse in
    mov ds,ax ; ds laden, da assume kein Programmcode ist ??
    Msg_1: mov ah,009h ; Funktion 9 = Textausgabe
    mov dx,OFFSET Msg1 ; Text an Offset Msg2
    int 021h ; DOS-Funktion aufrufen
    mov ah,009h ; Funktion 9 = Textausgabe
    mov dx,OFFSET Msg1 ; Text an Offset Msg2
    int 021h ; DOS-Funktion aufrufen

    xor ah,ah ; Wait for a keypress
    int 16h

    mov ax,13h ; 320x200x256
    int 10h

    Call Linie

    xor ah,ah ; Wait for a keypress
    int 16h

    mov x,48
    mov y,38
    Call Linie

    xor ah,ah ; Wait for a keypress
    int 16h

    mov x,308
    mov y,6
    Call Linie

    xor ah,ah ; Wait for a keypress
    int 16h

    Linien: Call Linie
    xor ah,ah ; Wait for a keypress
    int 16h
    add x1,1
    mov ax,x1
    mov x,ax
    mov bx,y1
    mov y,bx
    cmp x,320
    jle Linien

    xor ah,ah ; Wait for a keypress
    int 16h

    mov bx,0070h ; 110h x Position
    mov ax,080h ; 050h y Position
    mov cx,ax
    shl ax,8 ; mal 256
    shl cx,6 ; mal 64 (= mal 320)
    add ax,bx
    add ax,cx
    mov di,ax
    mov al,0eh ;
    mov es:di,al

    xor ah,ah ; Wait for a keypress
    int 16h

    mov bx,00a0h ; 110h x Position
    mov ax,064h ; 050h y Position
    mov cx,ax
    shl ax,8 ; mal 256
    shl cx,6 ; mal 64 (= mal 320)
    add ax,bx
    add ax,cx
    mov di,ax
    mov al,0eh ;
    mov es:di,al

    xor ah,ah ; Wait for a keypress
    int 16h

    xor ah,ah ; Wait for a keypress
    int 16h

    mov ax,3 ; 80x25x16 text mode
    int 10h

    mov ax,4c00h ; Terminate and back to DOS
    int 21h

    Linie proc near
    mov bx,y+2
    sub bx,y
    jnz Nully
    mov m,0
    mov m+2,1
    Nully: mov deltay,bx
    mov eax,0
    mov ax,x+2
    sub ax,x
    cwd
    mov deltax,ax
    idiv deltay
    mov m,ax
    mov Rest,dx

    mov x+6,0
    mov ax,0a000h ; Set ES to VGA segment (0a000h)
    mov es,ax
    Punkte: mov bx,x ; 110h x Position
    mov ax,y ; 050h y Position
    mov cx,ax
    shl ax,8 ; mal 256
    shl cx,6 ; mal 64 (= mal 320)
    add ax,bx
    add ax,cx
    mov di,ax
    mov al,0eh ;
    mov es:di,al
    mov ax,m+2
    add y,ax
    mov ax,m
    add x,ax
    mov ax,Rest
    add x+6,ax
    mov ax,x+6
    cmp ax,0
    jge positiv
    cmp ax,deltay
    jg noX
    moreX1: sub ax,deltay
    sub x,1
    cmp ax,deltay
    jle moreX1
    mov x+6,ax
    jmp noX
    positiv: cmp ax,deltay
    jl noX
    moreX: sub ax,deltay
    add x,1
    cmp ax,deltay
    jge moreX
    mov x+6,ax
    noX: mov ax,y
    cmp ax,y+2
    jle Punkte
    ret
    endp
    Code ENDS

    END Start



  • Wenn du schon meinst, nicht auf die im alten Thread genannten Kritikpunkte eingehen zu muessen, dann pushe doch zumindest deinen alten Thread. 👎


Anmelden zum Antworten