olivieryuyu / N64-Microcode-

Testing - Phase 1
3 stars 0 forks source link

G_MTX #7

Open olivieryuyu opened 2 years ago

olivieryuyu commented 2 years ago

G_MTX

Header of the command: 0x04

Function:

This command multiplies two different designated matrixes and stores the results in a designated place in DMEM. On the contrary of Fast3D, this command does not load any matrix from RDRAM. For a better understanding of this command, it is better to explain its structure at microcode level.

STRUCTURE:

HH___RRR _MMM_NNN

HH: Header of the command (8 bits)

RRR: place in DMEM where to store the results of the multiplication

MMM: place in DMEM of the one of the matrix to be multiplied

NNN: place in DMEM of the second matrix to be multiplied

You may find the defined place of the potential existing matrix in DMEM in gbi.h:

DMEM indices

  #define D_SCRATCH                     0x8F8
  #define D_G_MTX_MVP           0x290
  #define D_G_MTX_MODELVIEW     0x210
  #define D_G_MTX_PROJECTION        0x250

D_SCRATCH is a scratch buffer was previously loaded. This scratch buffer is used for other purposes (notably when loading vertices or using TRIs command) so it is better to use such a matrix as soon as it is loaded.

MTX_MVP is the ModelViewProjection Matrix

MTX_MODELVIEW is the ModelView Matrix

MTX_PROJECTION is the Projection Matrix

Related GBI macros:

gSPMatrix/gsSPMatrix (same function and parameters than Fast3D GBI macro but actually an emulation of this latter) gSPPopMatrix/gsSPPopMatrix/gSPPopMatrixN/gsSPPopMatrixN (see command G_PMTX for more info)