# N64 CI TextureEditor Plug-In SDK

Japanese

1. The Plug-Ins

   1. Initialization process at start-up

      The plug-ins use the DLL interface.
      When the texture editor starts up, it searches the DLLs in the PlugIns directory of the application's directory, checks the name, version and type of each plug-in, and automatically links them.

      The name and version information is obtained from the VS_VERSION_INFO of the DLL resource, so be sure to include the version resource in the DLL.
      Please prepare a Japanese-language resource (041104b0) and an English-language resource (040904e4) of VS_VERSION_INFO.
      Comment is used for detailed information, CompanyName for the company name, FileVersion for the plug-in version, and InternalName for the menu name.

      On the DLL side, first int TEPI_getType() is called, and the plug-in type is returned.
      Next, BOOL TEPI_isAvail(DWORD version) is called, and the application's 4-byte version is passed as the parameter (0x0100000f in the case of 1.0.0.15). If supported in the application, return TRUE. If not supported, return FALSE.

   2. Import process

      If the type is Import (the TEPIT_IMPORT flag is up) then a name should be registered in Import of the File menu
      When the user calls the Import plug-in, the corresponding DLL BOOL TEPI_import(Pic* pInput, Pic* pOutput) is called.

   3. Export process

      If the type is Export (the TEPIT_EXPORT flag is up) then a name should be registered in Export of the File menu.
      When the user calls the Export plug-in, the corresponding DLL BOOL TEPI_export(Pic* pInput) is called.

   4. Preview process

      If the type if Preview (the TEPIT_PREVIEW flag is up) then a call is made from Preview of the View menu.
      However, older versions of the texture editor (before 1.0.1.4) support only one preview plug-in, and it cannot be used at the same time as another preview plug-in.
      When the user calls the Preview plug-in, the corresponding DLL BOOL TEPI_preview(Pic* pInput) is called.

      Up to two Previews are possible from version 1.0.1.5 of the texture editor.
      When the user calls the Preview plug-in, the corresponding DLL BOOL TEPI_preview2(Pic* pInput, int no) is called.

2. Plug-in Development Environment

   1. Language: C/C++
   2. Environment: Visual C++ 5.0
   3. File format: Windows 32bit DLL

3. Type information handled by plug-ins

   struct TMF {
     int m_width;
     int m_height;
     int m_bits;
     u32* m_pBitmap;
     };
   m_width is the image width, m_height is the image height, and m_bits is the image bit depth (4 or 8).
   m_pBitmap is the exact same binary image data as BMP
   In 4bit mode, 1 byte has 2 pixels of image data: the higher 4bits is the left pixel and the lower 4bits is the right pixel.
   In 8bit mode, 1 byte has 1 pixel, so they are in order from left to right.
   Because 1 line has 32bit alignment, the fractional gap on the right end is filled with 0.
   Size is equal to ((((m_width * m_bits / 8) + 3) & ~3) * m_height) bytes.
   Note that, like with BMP, pixels are arranged from the bottom of the image to the top, and the Y axis is reversed.
   struct TLF {
     u32 m_type;
     s32 m_num;
     u16* m_color_array;
     };
   m_typeis the palette type (0 = 16bit RGBA/1 = 16bit IA)
   m_numis the number of palettes (16/256)
   m_color_array is the palette array.
   struct Pic {
     TMF* m_pTMF;
     TLF* m_pTLF;
     void* m_pReserved;
     int m_palette;
     };
   m_pTMF is the TMF pointer
   m_pTLF is the TLF pointer
   m_pReserved is for a future attribute table pointer.
   m_palette is the palette block number for a 4bit image + 256 palettes.

4. The Plug-In Interface

   - int TEPI_getType()

     Returns the type (TEPIT_IMPORT | TEPIT_EXPORT | TEPIT_PREVIEW)
     Depending on the plug-in, TEPI_import() | TEPI_export() | TEPI_preview() is called.
     This function is only called the first time at start-up.

   - BOOL TEPI_isAvail(DWORD version)

     From the version number of the texture editor (e.g., 1.0.0.15 = 0x0100000f) the validity or invalidity of the plug-in is returned.
     If valid, return TRUE. If invalid, return FALSE.
     This function is only called the first time at start-up.

   - BOOL TEPI_property()

     This is planned for future implementation.
     Quit on TRUE.

   - BOOL TEPI_about()

     This is planned for future implementation.
     Please display a dialog with DLL information using AfxMessageBox() etc. Quit on TRUE.

   - BOOL TEPI_import(Pic* pInput, Pic* pOutput)

     Called on request from the user when the TEPIT_IMPORT flag is up for type.
     A copy of the current image on the texture editor is included in pInput
     By passing an image to pOutput you can paste an image imported on the texture editor side.
     If the import is successful, return TRUE. If it is cancelled or fails, return FALSE.

     Notes:

     - pInput->m_pTLF can be NULL.
     - pOutput->m_pTMF and pOutput->m_pTLF are initially NULL, but upon normal termination, please make new and reserve memory.
       Ultimately, it will be removed on the calling side, so delete is unnecessary.
     - By directly editing the contents of pInput->m_pTMF the image can be updated without using paste mode.
   - BOOL TEPI_export(Pic* pInput)

     Called on request from the user when the TEPIT_EXPORT flag is up for the type.
     Since a copy of the current image in the texture editor is included in pInput, please use this to perform the Export process.
     If the export is successful, return TRUE. I fit is cancelled or fails, return FALSE.

   - BOOL TEPI_preview(Pic* pInput)

     This is called on request from the user when the TEPIT_PREVIEW flag is up for the type.
     Called when preview is ON for the texture editor, and when changes are made to images and palettes.
     If the preview is successful, return TRUE. If it is cancelled or fails, return FALSE.

5. Header file for declaring plug-in DLLs

   <tePlugIn.h>
   #ifndef __tePlugIn_H__ #define __tePlugIn_H__ #ifdef __cplusplus extern "C" { #endif
   #pragma pack(1)
   struct TMF {
     int m_width;
     int m_height;
     int m_bits;
     u32* m_pBitmap;
     };
     struct TLF {
     u32 m_type;
     s32 m_num;
     u16* m_color_array;
     };
     /* Picture */
     struct Pic {
     TMF* m_pTMF;
     TLF* m_pTLF;
     void* m_pReserved;
     int m_palette;
     };
     #pragma pack()
     //// TextureEditor Plug-In Type
     enum TEPIT {
     TEPIT_IMPORT = 1,
     TEPIT_EXPORT = 2,
     TEPIT_PREVIEW = 4,
     };
     #define DLLEXPORT __declspec(dllexport)
     /*
     //// YOU MUST IMPLEMENT THE BELOW FUNCTIONS ////
     // get type of plug-in
     // ex) return TEPIT_IMPORT | TEPIT_EXPORT;
     // caution: preview type plug-in is only one.
     */
     DLLEXPORT int PASCAL EXPORT TEPI_getType();
     /* check application version. If available then return TRUE. */
     DLLEXPORT BOOL PASCAL EXPORT TEPI_isAvail(DWORD version);
     DLLEXPORT BOOL PASCAL EXPORT TEPI_property();
     DLLEXPORT BOOL PASCAL EXPORT TEPI_about();
     DLLEXPORT BOOL PASCAL EXPORT TEPI_import(Pic* pInput, Pic* pOutput); /* called on import. */
     DLLEXPORT BOOL PASCAL EXPORT TEPI_export(Pic* pInput); /* called on export. */
     DLLEXPORT BOOL PASCAL EXPORT TEPI_preview(Pic* pInput); /* called on update time of TMF/TLF. */
     #ifdef __cplusplus
     };
     #endif

English

| Copyright (C) 1998 NINTENDO Co.,Ltd. Copyright (C) 1998 NINTENDO OF AMERICA, Inc. Copyright (C) 1998 MONEGI CORPORATION. Copyright (C) 1998 INTELLIGENT SYSTEMS Co.,Ltd. All rights reserved.