So I got two matrices, the modelview matrix (should only rotates on the Y axis) and a rotation matrix (only rotates on the Y axis).
Now I need to know what the angle is of the projection (the view I'm looking at) and the rotation matrix's angle then I need to assign a vallue (between 0 and 8) based on that result.
or any other way I can add two rotations together and get a value between 0 and 8.
So basically if you're looking 90d and the enemy is walking 180d you'll see the sprite of the enemy drawn going right.
Forget matrices for now, based on your picture I think all you need is:
direction = (model_view_rotation + enemy_rotation) % 360
direction = floor((direction + 22.5) / 45.0)
which should give you a value between 0 and 8
I'm assuming that view 8 is actually the same as view 0 ?