?? interp.c
字號:
/* interp.c -- Instruction Interpreter * Copyright (C) 1996 Li-Da Lho, All right reserved. */#include "config.h"#include "ttf.h"#include "ttfutil.h"#ifdef MEMCHECK#include <dmalloc.h>#endif/* $Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */#ifndef lintstatic char vcid[] = "$Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";#endif /* lint *//* A bit about error checking: The execution of a TrueType instruction is * "atomic" which mean that we don't process the error until a single * instruction is fully decoded and exectued *//* Pushing data onto the interpreter stack */void Interp_NPUSHB (VirtualMachine *vm){ BYTE i,n; ULONG l; n = GetBYTE(vm); for (i=1;i<=n;i++) { /* unsigned extension to four bytes */ l = (ULONG) GetBYTE(vm); Push(vm, l); }}void Interp_NPUSHW(VirtualMachine *vm){ BYTE i,n; LONG l; n = GetBYTE(vm); for (i=1;i<=n;i++) { /* signed extension to four bytes */ l = (LONG) GetSHORT(vm); Push(vm, l); }}void Interp_PUSHB(VirtualMachine *vm){ BYTE opcode,n,i; ULONG l; opcode = (vm->iStream)[vm->ip]; n = opcode - 0xB0; for (i=0;i<=n;i++) { l = (ULONG) GetBYTE(vm); Push(vm, l); }}/* PUSHW[abc] Push Words * Code Range 0xB8 - 0x0BF * From IS w0,w1,...wn * Pushes w0,w1,...wn */void Interp_PUSHW(VirtualMachine *vm){ BYTE opcode,n,i; LONG l; opcode = (vm->iStream)[vm->ip]; n = opcode - 0xB8; for (i=0;i<=n;i++) { l = (LONG) GetSHORT(vm); Push(vm,l); }}/* Managing the Storage Area *//* RS[] Read Store * Code Range 0x43 * Pops location: Storage Area location (ULONG) * Pushes value: Storage Area value (ULONG) * Gets Storage Area value */void Interp_RS(VirtualMachine *vm){ ULONG location,value; location = Pop(vm); value = (vm->StorageArea)[location]; Push(vm,value);}/* WS[] Write Store * Code Range 0x42 * Pops value: Storage Area value (ULONG) * location: Storage Area location (ULONG) * Pushes - * Sets Storage Area */void Interp_WS(VirtualMachine *vm){ ULONG location,value; value = Pop(vm); location = Pop(vm); (vm->StorageArea)[location] = value;}/* Managing the Control Value Table *//* WCVTP[] Write control Value Table in Pixel units * Code Range 0x44 * Pops value: number in pixels (F26Dot6) * location: Control Value Table location (ULONG) * Pushes - * Sets Control Value Table entry */void Interp_WCVTP(VirtualMachine *vm){ F26Dot6 value; ULONG location; value = Pop(vm); location = Pop(vm); (vm->cvt)[location] = value;}/* WCVTF[] Write Control Value Table in FUnits * Code Range 0x70 * Pops value: number in FUnits (ULONG) (LONG actually,i think) * location: Control Value (ULONG) * Pushes - * Sets Control Value Table entry */void Interp_WCVTF(VirtualMachine *vm){ ULONG location; LONG value; value = Pop(vm); location = Pop(vm); value = ScaleToPoints(vm,value); (vm->cvt)[location] = value;}/* RCVT[] Read Control Value Table * Code Range 0x45 * Pops location: CVT entry number (ULONG) * Pushes value: CVT value (F26Dot6) * Gets Control Value Table entry */void Interp_RCVT(VirtualMachine *vm){ ULONG location; F26Dot6 value; location = Pop(vm); value = (vm->cvt)[location]; Push(vm,value);}/* Managing Graphics State *//* SVTCA[a] Set freedom and projection vector to Coordinate Axia * Code Range 0x00 - 0x01 * a 0: set to y axis * 1: set to x axis * Pops - * Pushes - * Sets projection_vector * freedom_vector */void Interp_SVTCA(VirtualMachine *vm){ BYTE opcode; TTFUnitVector vect; opcode = (vm->iStream)[vm->ip]; switch (opcode) { case 0x00: vect.x = 0; vect.y = F2Dot14_ONE; break; case 0x01: vect.x = F2Dot14_ONE; vect.y = 0; break; } vm->gstate.projection_vector = vm->gstate.freedom_vector = vect;}/* SPVCA[a] Set projection vector to coordinate axis * Code Range 0x02 - 0x03 * a 0: set to y axis * 1: set to x axis * Pops - * Pushes - * Sets projection vector */void Interp_SPVTCA(VirtualMachine *vm){ BYTE opcode; TTFUnitVector vect; opcode = (vm->iStream)[vm->ip]; switch (opcode) { case 0x02: vect.x = 0; vect.y = F2Dot14_ONE; break; case 0x03: vect.x = F2Dot14_ONE; vect.y = 0; break; } vm->gstate.projection_vector = vect;}/* SFVTCA[a] Set freedom vector to coordinate axis * Code Range 0x04 - 0x05 * a 0: set to y axis * 1: set to x axis * Pops - * Pushes - * Sets freedom vector */void Interp_SFVTCA(VirtualMachine *vm){ BYTE opcode; TTFUnitVector vect; opcode = (vm->iStream)[vm->ip]; switch (opcode) { case 0x04: vect.x = 0; vect.y = F2Dot14_ONE; break; case 0x05: vect.x = F2Dot14_ONE; vect.y = 0; break; } vm->gstate.freedom_vector = vect;}/* SPVTL[a] Set projection vector to line * Code Range 0x06 - 0x07 * a 0: set projection_vector to be parallel to line segment from p1 * to p2 * 1: set projection_vector to be perpendicular to line segment from * p1 to p2; the vector is retated counter clockwise 90 degrees * Pops p1: point number (ULONG) * p2: point number (ULONG) * Pushes - * Uses point p1 in the zone pointed at by zp2 * point p2 in the zone pointed at by zp1 * Sets projection vector */void Interp_SPVTL(VirtualMachine *vm){ ULONG p1,p2; BYTE opcode; TTFUnitVector vect; opcode = (vm->iStream)[vm->ip]; p1 = Pop(vm); p2 = Pop(vm); switch (opcode) { /* not finished yet */ case 0x06: break; case 0x07: break; } vm->gstate.projection_vector = vect;}/* SFVTL[a] Set freedom vector to line * Code Range 0x08 - 0x09 * a 0: set freedom_vector to be parallel to line segment from p1 * to p2 * 1: set freedom_vector to be perpendicular to line segment from * p1 to p2; the vector is retated counter clockwise 90 degrees * Pops p1: point number (ULONG) * p2: point number (ULONG) * Pushes - * Uses point p1 in the zone pointed at by zp2 * point p2 in the zone pointed at by zp1 * Sets freedom vector */void Interp_SFVTL(VirtualMachine *vm){ ULONG p1,p2; BYTE opcode; TTFUnitVector vect; opcode = (vm->iStream)[vm->ip]; p1 = Pop(vm); p2 = Pop(vm); switch (opcode) { /* not finished yet */ case 0x08: break; case 0x09: break; } vm->gstate.freedom_vector = vect;}/* SFVTPV[] Set freedom vector to projection vector * Code Range 0x0E * Pops - * Pushes - * Sets freedom vector */void Interp_SFVTPV(VirtualMachine *vm){ vm->gstate.freedom_vector = vm->gstate.projection_vector;}/* SDPVTL[a] Set dual projection vector to line * Code Range 0x86 - 0x87 * a 0: vectors are parallel to line * 1: vectors are perpendicular to line * Pops p1: first point number (ULONG) * p2: second point number (ULONG) * Pushes - * Sets dual_projection_vector and projection_vector * Uses point p1 in the zone pointed by zp2 * point p2 in the zone pointed by zp1 */void Interp_SDPVTL(VirtualMachine *vm){ ULONG p1,p2; BYTE opcode; TTFUnitVector vect; opcode = (vm->iStream)[vm->ip]; p1 = Pop(vm); p2 = Pop(vm); switch (opcode) { /* not finished yet */ case 0x86: break; case 0x87: break; } vm->gstate.dual_projection_vector = vm->gstate.projection_vector = vect;}/* SPVFS[] Set projection vector from stack * Code Range 0x0A * Pops y: y component of projection vector (2.14 padded with zeros) * x: x component of projection vector (2.14 padded with zeros) * Pushes - * Sets projection_vector */void Inpterp_SPVFS(VirtualMachine *vm){ F2Dot14 x,y; x = Pop(vm); y = Pop(vm); vm->gstate.projection_vector.x = x; vm->gstate.projection_vector.y = y; /* vm->gstate.projection = Normalize(vm->gstate.projection); ?? */}/* SFVFS[] Set freedom vector form stack * Code Range 0x0B * Pops y: y component of freedom vector (2.14 padded with zeros) * x: x component of freedom vector (2.14 padded with zeros) * Pushes - * Sets freedom_vector */void Inpterp_SFVFS(VirtualMachine *vm){ F2Dot14 x,y; x = Pop(vm); y = Pop(vm); vm->gstate.freedom_vector.x = x; vm->gstate.freedom_vector.y = y; /* vm->gstate.freedom = Normalize(vm->gstate.freedom); ?? */}/* GPV[] Get projection vector * Code Range 0x0C * Pops - * Pushes x: x component of projection vector (2.14 padded with zeros) * y: y component of projection vector (2.14 padded with zeros) * Gets projection vector */void Interp_GPV(VirtualMachine *vm){ ULONG l; l = (ULONG) vm->gstate.projection_vector.x; Push(vm,l); l = (ULONG) vm->gstate.projection_vector.y; Push(vm,l);}/* GFV[] Get freedom vector * Code Range 0x0D * Pops - * Pushes x: x component of freedom vector (2.14 padded with zeros) * y: y component of freedom vector (2.14 padded with zeros) * Gets freedom vector */void Interp_GFV(VirtualMachine *vm){ ULONG l; l = (ULONG) vm->gstate.freedom_vector.x; Push(vm,l); l = (ULONG) vm->gstate.freedom_vector.y; Push(vm,l);}/* SRP0[] Set reference point 0 * Code Range 0x10 * Pops p: point number (ULONG) * Pushes - * Sets rp0
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -