Outils pour utilisateurs

Outils du site


back2root:archives:denthor:part-08

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
back2root:archives:denthor:part-08 [2021/09/05 14:05] – [C] fraterback2root:archives:denthor:part-08 [2024/08/27 09:04] (Version actuelle) – [Drawing a 3D point to screen] frater
Ligne 24: Ligne 24:
 ==== Optimisation ==== ==== Optimisation ====
  
-Before I begin with the note on 3-D, I would like to stress that many of these routines, and probably most of your own, could be sped up quite a bit with a little optimisation. One must realise, however, that you must +Before I begin with the note on 3-D, I would like to stress that many of these routines, and probably most of your own, could be sped up quite a bit with a little optimisation.  
-take a look at WHAT to optimise ... converting a routine that is only called once at startup into a tightly coded assembler routine may show off your merits as a coder, but does absolutely nothing to speed up your program. Something that is called often per frame is something that needs to be as fast as possible. For some, a much used procedure is the PutPixel procedure. Here is the putpixel procedure I gave you last week:+ 
 +One must realise, however, that you must take a look at WHAT to optimise ... converting a routine that is only called once at startup into a tightly coded assembler routine may show off your merits as a coder, but does absolutely nothing to speed up your program.   
 +  
 +Something that is called often per frame is something that needs to be as fast as possible. For some, a much used procedure is the PutPixel procedure. Here is the putpixel procedure I gave you last week:
  
 <code pascal> <code pascal>
Ligne 62: Ligne 65:
 Total = 153 clock ticks Total = 153 clock ticks
                                                          
-<WRAP center round important 60%>+<WRAP center round important>
 Don't take my clock ticks as gospel, I probably got one or two wrong. Don't take my clock ticks as gospel, I probably got one or two wrong.
 </WRAP> </WRAP>
  
-Right, now for some optimising. Firstly, if you have 286 instructions turned on, you may replace the 6 shl,1 with shl,6. Secondly, the Pascal compiler automatically pushes and pops ES, so those two lines may be removed. DS:[SI] is not altered in this procedure, so we may remove those too. Also, instead of moving COL into ah, we move it into AL and call stosb (es:[di]:=al; inc di). Let's have a look at the routine now :+Right, now for some optimising. Firstly, if you have 286 instructions turned on, you may replace the 6 shl,1 with shl,6.  
 + 
 +Secondly, the Pascal compiler automatically pushes and pops ES, so those two lines may be removed. DS:[SI] is not altered in this procedure, so we may remove those too. Also, instead of moving COL into ah, we move it into AL and call stosb (es:[di]:=al; inc di). Let's have a look at the routine now :
  
 <code pascal> <code pascal>
Ligne 92: Ligne 97:
 Total = 95 clock ticks Total = 95 clock ticks
  
-Now, let us move the value of BX directly into DI, thereby removing a costly push and pop. The MOV and the XOR of DX can be replaced by it's equivalent, SHL DX,8+Now, let us move the value of BX directly into DI, thereby removing a costly push and pop. The MOV and the XOR of DX can be replaced by it's equivalent, **SHL DX,8**
  
 <code pascal> <code pascal>
Ligne 113: Ligne 118:
 Total = 71 clock ticks Total = 71 clock ticks
  
-As you can see, we have brought the clock ticks down from 153 ticks to 71 ticks ... quite an improvement. (The current ASPHYXIA putpixel takes 48 clock ticks) . As you can see, by going through your routines a few times, you can spot and remove unnecessary instructions, thereby greatly increasing the speed of your program.+As you can see, we have brought the clock ticks down from 153 ticks to 71 ticks ... quite an improvement. (The current ASPHYXIA putpixel takes 48 clock ticks). 
 +  
 +As you can see, by going through your routines a few times, you can spot and remove unnecessary instructions, thereby greatly increasing the speed of your program.
  
 ==== Defining a 3-D object ==== ==== Defining a 3-D object ====
Ligne 139: Ligne 146:
 ==== Rotating a point with matrixes ==== ==== Rotating a point with matrixes ====
  
-<WRAP center round tip 60%>+<WRAP center round tip>
 I thought that more then one matix are matrisese (sp), but my spellchecker insists it is matrixes, so I let it have it's way ;-) I thought that more then one matix are matrisese (sp), but my spellchecker insists it is matrixes, so I let it have it's way ;-)
 </WRAP> </WRAP>
Ligne 220: Ligne 227:
 </code> </code>
  
-<WRAP center round info 60%>+<WRAP center round info>
 Zoff is how far away the entire object is, Xoff is the objects X value, and Yoff is the objects Y value. In the sample program, Xoff start off at 160 and Yoff starts off at 100, so that the object is in the middle of the screen. Zoff is how far away the entire object is, Xoff is the objects X value, and Yoff is the objects Y value. In the sample program, Xoff start off at 160 and Yoff starts off at 100, so that the object is in the middle of the screen.
 </WRAP> </WRAP>
back2root/archives/denthor/part-08.1630843504.txt.gz · Dernière modification : 2021/09/05 14:05 de frater