'file$ = MID$(COMMAND$, 1, INSTR(COMMAND$, " "))
'temp$ = LTRIM$(MID$(COMMAND$, INSTR(COMMAND$, " ")))
'file2$ = temp$
 CLS

'OR O MANUAL WAY
file$ = "d:\temp\mesh\cube.c"
file2$ = "d:\czn\study\cube.asm"

 OPEN file$ FOR INPUT AS 1
 OPEN file2$ FOR OUTPUT AS 2

LINE INPUT #1, line$
 DO WHILE NOT (EOF(1))
vtxcount! = 0
 IF (INSTR(line$, "Vtx_tn")) <> 0 THEN
vertexd$ = LTRIM$(MID$(line$, INSTR(line$, " ")))
vertexd$ = MID$(vertexd$, 1, INSTR(vertexd$, "[") - 1)
 PRINT #2, " CNOP 0,8"
 PRINT #2, vertexd$

LINE INPUT #1, line$
 DO WHILE (INSTR(line$, "};")) = 0

 IF (INSTR(line$, "{")) <> 0 THEN
 line$ = MID$(line$, INSTR(line$, "{") + 1)
 PRINT #2, " DH ";
 FOR i = 1 TO 5
PRINT #2, MID$(line$, 1, INSTR(line$, ","));
line$ = MID$(line$, INSTR(line$, ",") + 1)
 NEXT i
PRINT #2, MID$(line$, 1, INSTR(line$, ",") - 1) + " ;" + LTRIM$(STR$(vtxcount!))
line$ = MID$(line$, INSTR(line$, ",") + 1)
vtxcount! = vtxcount! + 1

 PRINT #2, " DB ";
 FOR i = 1 TO 3
PRINT #2, MID$(line$, 1, INSTR(line$, ","));
line$ = MID$(line$, INSTR(line$, ",") + 1)
 NEXT i
PRINT #2, MID$(line$, 1, INSTR(line$, "}") - 1)

 END IF

 LINE INPUT #1, line$
 LOOP
 END IF                 'VTX_TN loop

 IF (MID$(line$, 1, 3) = "Gfx") THEN
label$ = MID$(line$, INSTR(line$, " ") + 1)
label$ = MID$(label$, 1, INSTR(label$, "[") - 1)
 PRINT #2, " CNOP 0,8"
 PRINT #2, label$

100
LINE INPUT #1, line$
 DO WHILE ((INSTR(line$, "};")) = 0)

  IF INSTR(line$, "gsSPVertex") <> 0 THEN
  PRINT #2, " gsVertex ";
  addy$ = MID$(line$, (INSTR(line$, "&") + 1))
  addy$ = LTRIM$(MID$(addy$, 1, INSTR(addy$, "[") - 1))
  number$ = MID$(line$, INSTR(line$, "[") + 1)
  number$ = MID$(number$, 1, INSTR(number$, "]") - 1)
  offset! = VAL(number$) '* 16
  number$ = LTRIM$(STR$(offset!)) + "*16"
  line$ = MID$(line$, INSTR(line$, ","))
  PRINT #2, addy$ + "+" + number$ + MID$(line$, 1, (INSTR(line$, ")") - 1))
  GOTO 100
  END IF    'end gspvertex

  IF INSTR(line$, "gsSP1Triangle") <> 0 THEN
  PRINT #2, " gsTRI1 ";
  line$ = MID$(line$, INSTR(line$, "(") + 1)
  line$ = MID$(line$, 1, INSTR(line$, ")") - 1)
  PRINT #2, line$
  GOTO 100
  END IF    'end gsptriangle

  IF INSTR(line$, "gsSPEndDisplayList") <> 0 THEN
  PRINT #2, " gsEndDisplaylist"
  GOTO 100
  END IF    'end gspenddisplaylist

  IF INSTR(line$, "gsSPDisplayList") <> 0 THEN
  PRINT #2, " gsDisplaylist ";
  line$ = MID$(line$, INSTR(line$, "(") + 1)
  line$ = MID$(line$, 1, INSTR(line$, ")") - 1)
  PRINT #2, line$
  GOTO 100
  END IF    'end gspdisplaylist

  IF INSTR(line$, "gsDPLoadTextureBlock") <> 0 THEN
  PRINT #2, " gsLoadTextureBlock ";
  line$ = MID$(line$, INSTR(line$, "(") + 1)
  line$ = MID$(line$, 1, INSTR(line$, ","))
  PRINT #2, line$;
LINE INPUT #1, line$
  line$ = LTRIM$(line$)
  numbera$ = MID$(line$, 1, INSTR(line$, ","))
  numberb$ = MID$(line$, INSTR(line$, ",") + 1)
  numberb$ = LTRIM$(MID$(numberb$, 1, INSTR(numberb$, ",") - 1))
  PRINT #2, numbera$ + numberb$
  GOTO 100
  END IF    'end gdploadtextureblock



LINE INPUT #1, line$
 LOOP
 END IF                 'end of GFX loop


 LINE INPUT #1, line$
 LOOP                   'end of main loop


CLOSE #1
CLOSE #2

