für lineare Vesamodi mit 256 Farben. (Kann auch leicht auf 65526 Farben(2 Byte) oder Truecolor(4 Byte) geändert werden.)
A 2D projection of a 3D projection of a 4D Pentachoron performing a double rotation about two orthogonal planes.
...
Aber es geht auch anders (leider nicht mit solchen durchsichtigen Flächen), dafür aber unter purem DOS und selbst entwickelt.
Die Subroutinen müssen in eine Anwendung die in einen lineraren Vesamode schaltet eingebettet werden.
Code: Alles auswählen
START:
; ---- In einen linearen Vesamode schalten---
; Informationen über den verwendeten Vesamode(Modinfo) nach "VINF" holen!
;-------------------------
call Pixoff ; Es wird einmalig eine Tabelle der Zeilenanfänge des verwendeten linearen Frambuffers angelegt.
;-------------------------
;----Hauptschleife---
mov ebx, X1 ; Hier gültige Koordinaten für X1+Y1 und X2+Y2 eintragen.
mov esi, Y1
mov cx, X2
mov di, X2
call LINE ; Linie zum Bildschirm
;----Programm Ende ---
;----------------------------------------------------------------------------
; L I N I E Anfangspunkt: EBX, ESI Endpunkt: CX, DI Farbe: AL
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16 ; Code-Alignment
;----------------------------------------------------------------------------
LINE: mov dx, di
sub cx, bx
jl T0
add ebx, [esi*4]
sub dx, si
jl T1
mov si, [XMP1]
cmp cx, dx
jl T2
add dx, dx
mov bp, dx
sub dx, cx
mov di, dx
sub dx, cx
;-------------------------------------
M00: mov [ebx], al
and di, di
jge short M01
inc ebx
add di, bp
dec cx
jnz M00
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M01: add ebx, esi
add di, dx
dec cx
jnz M00
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T0: neg cx
add ebx, [esi*4]
sub dx, si
mov si, [XMP1]
jl T01
mov si, [XMM1]
cmp cx, dx
jl short T21
add dx, dx
mov bp, dx
sub dx, cx
mov di, dx
sub dx, cx
;-------------------------------------
M02: mov [ebx], al
and di, di
jge short M03
dec ebx
add di, bp
dec cx
jnz M02
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M03: add ebx, esi
add di, dx
dec cx
jnz M02
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T21: add cx, cx
mov bp, cx
sub cx, dx
mov di, cx
sub cx, dx
;-------------------------------------
M04: mov [ebx], al
and di, di
jge short M05
add ebx, DWORD PTR[XMAX]
add di, bp
dec dx
jnz M04
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M05: add ebx, esi
add di, cx
dec dx
jnz M04
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T01: neg dx
cmp cx, dx
jl short T22
add dx, dx
mov bp, dx
sub dx, cx
mov di, dx
sub dx, cx
;-------------------------------------
M06: mov [ebx], al
and di, di
jge short M07
dec ebx
add di, bp
dec cx
jnz M06
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M07: sub ebx, esi
add di, dx
dec cx
jnz M06
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T22: add cx, cx
mov bp, cx
sub cx, dx
mov di, cx
sub cx, dx
;-------------------------------------
M08: mov [ebx], al
and di, di
jge short M09
sub ebx, DWORD PTR[XMAX]
add di, bp
dec dx
jnz M08
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M09: sub ebx, esi
add di, cx
dec dx
jnz M08
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T1: neg dx
mov si, [XMM1]
cmp cx, dx
jl short T12
add dx, dx
mov bp, dx
sub dx, cx
mov di, dx
sub dx, cx
;-------------------------------------
M10: mov [ebx], al
and di, di
jge short M11
inc ebx
add di, bp
dec cx
jnz M10
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M11: sub ebx, esi
add di, dx
dec cx
jnz M10
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T12: add cx, cx
mov bp, cx
sub cx, dx
mov di, cx
sub cx, dx
;-------------------------------------
M12: mov [ebx], al
and di, di
jge short M13
sub ebx, DWORD PTR[XMAX]
add di, bp
dec dx
jnz M12
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M13: sub ebx, esi
add di, cx
dec dx
jnz M12
ret
;----------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
T2: add cx, cx
mov bp, cx
sub cx, dx
mov di, cx
sub cx, dx
;-------------------------------------
M14: mov [ebx], al
and di, di
jge short M15
add ebx, DWORD PTR[XMAX]
add di, bp
dec dx
jnz M14
ret
;-------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
M15: add ebx, esi
add di, cx
dec dx
jnz M14
ret
;---------------------------------------------------------------------------
; T a b e l l e d e r Z e i l e n - A n f ä n g e
;---------------------------------------------------------------------------
org START + ((($-START)/16)*16)+16
;-------------------------------------
PIXOFF: xor ebx, ebx
mov si, OFFSET VINF
mov bx, ds
mov eax, [si+28h] ; linearen Bild-Offset
shl ebx, 4
xor di, di ; Pointer auf Anfang des Datensegments
sub eax, ebx ; lineare Bild-Adresse (ds:reg32)
xor edx, edx
mov dx, [si+10h] ; Zeilen-Länge holen (Xmax)
mov DWORD PTR[XMAX], edx
mov bx, dx
inc bx
mov [XMP1], bx
sub bx, 2
mov [XMM1], bx
xor ecx, ecx
mov cx, [si+14h] ; Ymax
shl cx, 2 ; Max_Y * 4
AGAIN: mov [di], eax
add di, 4
add eax, edx ; plus Max_X
cmp di, cx ; schon (Max_Y * 4) ?
jb AGAIN
ret
;---------------------------------------------------------------------------
; Beginn des Daten-Segments
;---------------------------------------------------------------------------
PIXTAB DD 1200+16 dup (0) ; Tabelle der Zeilen-Anfänge(lineare Adressen) (max. 1200 Bildzeilen)
VINF DB 100h dup (0) ; Video-Mode-Information
XMAX DD 0 ; Xmax
XMP1 DW 0 ; Xmax + 1
XMM1 DW 0 ; Xmax - 1
(Einen Geschwindigkeitsvergleichstest mit anderen Linienroutinen über "rdtsc" habe ich noch nicht vorgenommen.)