'Programm: Texture-Mapping mit Integerzahlen 'Sprache: PowerBASIC 3.0 'Autor: Holger Fillbrandt screen 7 reg 1,&h0013 'Modus 13 ein call interrupt &H10 call printstr(10,2,125,"Texture-") 'Schrift ausgeben call printstr(18,2,123,"Mapping") call getpic(80,15,122,12,bild$) 'Bild holen s%=strseg(bild$) : o%=strptr(bild$) call tm(s%,o%,122,12,40,30,200,15) call tm(s%,o%,122,12,100,50,80,11) '2 Beispiele und for l%=5 to 270 'eine Animation wait &h3da,&h08 call tm(s%,o%,122,12,20,100,l%,15) next l% for h%=15 to 50 step 2 wait &h3da,&h08 'Synchronisation mit dem Bildschirm-Aufbau call tm(s%,o%,122,12,20,100,270,h%) next h% while inkey$="" : wend end sub printstr(x%,y%,f%,text$) 'Ausgeben eines Strings l%=len(text$) 'ber Bios-Interrupt s=strseg(text$) o=strptr(text$) reg 1,&h13*256+1 reg 2,f% mod 256 reg 3,l% reg 4,y%*256+x% reg 7,o : reg 9,s call interrupt &H10 end sub sub getpic(x%,y%,b%,h%,s$) 'Bildausschnitt in einen s$="" 'String kopieren adresse=y%*320+x% def seg=&ha000 for i%=1 to h% s$=s$+peek$(adresse,b%) adresse=adresse+320 next i% end sub sub tm(byval s%,byval o%,byval l1%,byval h1%,byval x%,byval y%,byval l2%,byval h2%) ! push ds ! push si ! push es ! push di ! mov ds,s% ;ds:si - Adresse des Strings ! mov si,o% ; mit den Bilddaten ! mov ax,&ha000 ! mov es,ax ! mov ax,y% ! mov dx,320 ! mul dx ! add ax,x% ! mov di,ax ;es:di - Adresse auf dem Bildschirm ! mov ax,h1% ! dec ax ;h1 kleiner, um Speicherchaos bei ! dec ax ;Ungenauigkeiten zu vermeiden ! mov bx,h2% ! mov cx,bx ;cx - Z„hler fr die H”he ! xor dx,dx ;dx - yz„hler ! cmp ax,bx ! jb label1 ! inc dx label1: ! push ax ! push bx ! push cx ! push dx ! push di ! push si ! mov ax,l1% ! mov bx,l2% ! mov cx,bx ;cx - Z„hler fr die Breite ! xor dx,dx ;dx - xz„hler ! cmp ax,bx ! jb label2 ! inc dx label2: ! cmp dx,0 ;wenn xz„hler <=0 dann ! jg label3 ! inc si ;erh”he den x-Wert des gespeicherten Ausschnitts ! add dx,bx ;erh”he xz„hler um l2 ! jmp label2 label3: ! inc di ;x-Koordinate erh”hen ! push ax ! mov al,ds:[si] ;Punkt setzen ! mov es:[di],al ! pop ax ! sub dx,ax ;xz„hler um l1 erniedrigen ! loop label2 ! pop si ! pop di ! pop dx ! pop cx ! pop bx ! pop ax label4: 'Nach Durchlauf einer Zeile ! cmp dx,0 ;den „hnlichen Vorgang mit den y-Werten ! jg label5 ! add si,l1% ! add dx,bx ! jmp label4 label5: ! add di,320 ! sub dx,ax ! loop label1 ! pop di ! pop es ! pop si ! pop ds end sub