SH SERIES C Compiler (Ver. 5.0(Release10))       06-Jul-1998 19:10:09  PAGE    1

************ SOURCE LISTING ************

FILE NAME: .\ninjaBNF.c

  Seq       File  Line   0----+----1----+----2----+----3----+----4----+----5----
    1 ninjaBNF.c     1    
    2 ninjaBNF.c     2    #include <Shinobi.h>
 4757 ninjaBNF.c     3    #include <NjDef.h>
 5722 ninjaBNF.c     4    #include "NinjaBNF.h"
 5746 ninjaBNF.c     5    
 5747 ninjaBNF.c     6    /*-- Read File from GD & Create Work Buff ------------
                         +----------*/
 5748 ninjaBNF.c     7    Uint8 *nuOpenBNF(char *fname)
 5749 ninjaBNF.c     8    {
 5750 ninjaBNF.c     9        GDFS fid;
 5751 ninjaBNF.c    10        Sint32 sn;
 5752 ninjaBNF.c    11        Uint8 *wbuff;
 5753 ninjaBNF.c    12        Uint8 *rptr;
 5754 ninjaBNF.c    13        
 5755 ninjaBNF.c    14  E     fid = gdFsOpen(fname, ((void *)0));
 5756 ninjaBNF.c    15        gdFsGetFileSctSize(fid, &sn);
 5757 ninjaBNF.c    16        wbuff = (Uint8 *)syMalloc(sn*2048+8);
 5758 ninjaBNF.c    17        gdFsRead(fid, sn, wbuff);
 5759 ninjaBNF.c    18        gdFsClose(fid);
 5760 ninjaBNF.c    19        return wbuff;
 5761 ninjaBNF.c    20    }
 5762 ninjaBNF.c    21    
 5763 ninjaBNF.c    22    void nuCloseBNF(Uint8 *wbuff)
 5764 ninjaBNF.c    23    {
 5765 ninjaBNF.c    24        syFree(wbuff);
 5766 ninjaBNF.c    25    }
 5767 ninjaBNF.c    26    
 5768 ninjaBNF.c    27    /*-- General Funtion for Read Binary CNK NJA ---------
                         +----------*/
 5769 ninjaBNF.c    28    Uint32 nuSwapCNK(Uint32 cnk)
 5770 ninjaBNF.c    29    {
 5771 ninjaBNF.c    30        Uint32 rv;
 5772 ninjaBNF.c    31        rv = (cnk&0x000000ff)<<24|(cnk&0x0000ff00)<<8|(cnk
                         +&0x00ff0000)>>8|(cnk&0xff000000)>>24;
 5773 ninjaBNF.c    32        return rv;
 5774 ninjaBNF.c    33    }
 5775 ninjaBNF.c    34    
 5776 ninjaBNF.c    35    /*-- Read Binary CNK NJA from Work Buff---------------
                         +----------*/
 5777 ninjaBNF.c    36    void *nuReadBNF(Uint8 *wbuff, Uint32 *fpos, Uint32 *pt
                         +ype)
 5778 ninjaBNF.c    37    {
 5779 ninjaBNF.c    38        Uint8 *current;
 5780 ninjaBNF.c    39        Uint8 *tmp;
 5781 ninjaBNF.c    40        Uint8 buf0, buf1, buf2, buf3;
 5782 ninjaBNF.c    41        Uint32 *addr;
 5783 ninjaBNF.c    42        Uint32 cnk, size;
 5784 ninjaBNF.c    43        Uint32 offset,  offset_from_base = 0;
 5785 ninjaBNF.c    44    
 5786 ninjaBNF.c    45    
 5787 ninjaBNF.c    46        current = &wbuff[*fpos];
 5788 ninjaBNF.c    47        
 5789 ninjaBNF.c    48        memcpy(&cnk, current, 4);
 5790 ninjaBNF.c    49        current += 4;
 5791 ninjaBNF.c    50        
 5792 ninjaBNF.c    51        memcpy(&size, current, 4);
 5793 ninjaBNF.c    52        current += 4;
 5794 ninjaBNF.c    53    
 5795 ninjaBNF.c    54    
 5796 ninjaBNF.c    55        *fpos += 8;
 5797 ninjaBNF.c    56        cnk = nuSwapCNK(cnk);
 5798 ninjaBNF.c    57        switch(cnk){
 5799 ninjaBNF.c    58  E         case 'NJIN' :
 5800 ninjaBNF.c    59  E             *ptype = 'NJIN' ;
 5801 ninjaBNF.c    60                goto _allocate_data_area_;
 5802 ninjaBNF.c    61  E         case 'NJCM' :
 5803 ninjaBNF.c    62  E             *ptype = 'NJCM' ;
 5804 ninjaBNF.c    63                goto _allocate_data_area_;
 5805 ninjaBNF.c    64  E         case 'NJBM' :
 5806 ninjaBNF.c    65  E             *ptype = 'NJBM' ;
 5807 ninjaBNF.c    66                goto _allocate_data_area_;
 5808 ninjaBNF.c    67  E         case 'NJTL' :
 5809 ninjaBNF.c    68  E             *ptype = 'NJTL' ;
 5810 ninjaBNF.c    69                goto _allocate_data_area_;
 5811 ninjaBNF.c    70  E         case 'NJLI' :
 5812 ninjaBNF.c    71  E             *ptype = 'NJLI' ;
 5813 ninjaBNF.c    72                goto _allocate_data_area_;
 5814 ninjaBNF.c    73  E         case 'NJCA' :
 5815 ninjaBNF.c    74  E             *ptype = 'NJCA' ;
 5816 ninjaBNF.c    75                goto _allocate_data_area_;
 5817 ninjaBNF.c    76  E         case 'NMDM' :
 5818 ninjaBNF.c    77  E             *ptype = 'NMDM' ;
 5819 ninjaBNF.c    78                goto _allocate_data_area_;
 5820 ninjaBNF.c    79  E         case 'NLIM' :
 5821 ninjaBNF.c    80  E             *ptype = 'NLIM' ;
 5822 ninjaBNF.c    81                goto _allocate_data_area_;
 5823 ninjaBNF.c    82  E         case 'NCAM' :
 5824 ninjaBNF.c    83  E             *ptype = 'NCAM' ;
 5825 ninjaBNF.c    84                goto _allocate_data_area_;
 5826 ninjaBNF.c    85  E         case 'NSSM' :
 5827 ninjaBNF.c    86  E             *ptype = 'NSSM' ;
 5828 ninjaBNF.c    87            _allocate_data_area_:
 5829 ninjaBNF.c    88                tmp = (Uint8 *)syMalloc(size);
 5830 ninjaBNF.c    89                memcpy(tmp, current, size);
 5831 ninjaBNF.c    90                current += size;
 5832 ninjaBNF.c    91                *fpos += size;
 5833 ninjaBNF.c    92                break;
 5834 ninjaBNF.c    93            default:
 5835 ninjaBNF.c    94                *ptype = '****';
 5836 ninjaBNF.c    95  E             return ((void *)0);
 5837 ninjaBNF.c    96        }
 5838 ninjaBNF.c    97        /*-- Add BaseAddr --------------------------------
                         +-------*/
 5839 ninjaBNF.c    98        memcpy(&cnk, current, 4);
 5840 ninjaBNF.c    99        current += 4;
 5841 ninjaBNF.c   100        *fpos += 4;
 5842 ninjaBNF.c   101        cnk = nuSwapCNK(cnk);
 5843 ninjaBNF.c   102        if(cnk == 'POF0'){
 5844 ninjaBNF.c   103            memcpy(&size, current, 4);
 5845 ninjaBNF.c   104            current += 4;
 5846 ninjaBNF.c   105            *fpos += 4;
 5847 ninjaBNF.c   106            while(size > 0){
 5848 ninjaBNF.c   107                memcpy(&buf0, current, 1);
 5849 ninjaBNF.c   108                current += 1;
 5850 ninjaBNF.c   109                *fpos += 1;
 5851 ninjaBNF.c   110                size--;
 5852 ninjaBNF.c   111  E             switch(buf0&0xc0){
 5853 ninjaBNF.c   112  E                 case 0x00:
 5854 ninjaBNF.c   113                        break;
 5855 ninjaBNF.c   114  E                 case 0x40:
 5856 ninjaBNF.c   115  E                     offset = (Uint32)(buf0&0x3f);
 5857 ninjaBNF.c   116                        goto _ADD_BASE_ADDRESS_;
 5858 ninjaBNF.c   117  E                 case 0x80:
 5859 ninjaBNF.c   118                        memcpy(&buf1, current, 1);
 5860 ninjaBNF.c   119                        current += 1;
 5861 ninjaBNF.c   120                        size--;
 5862 ninjaBNF.c   121                        *fpos += 1;
 5863 ninjaBNF.c   122  E                     offset = (Uint32)((buf0&0x3f)<<8|b
                         +uf1);
 5864 ninjaBNF.c   123                        goto _ADD_BASE_ADDRESS_;
 5865 ninjaBNF.c   124  E                 case 0xc0:
 5866 ninjaBNF.c   125                        memcpy(&buf1, current, 1);
 5867 ninjaBNF.c   126                        current += 1;
 5868 ninjaBNF.c   127                        size--;
 5869 ninjaBNF.c   128                        memcpy(&buf2, current, 1);
 5870 ninjaBNF.c   129                        current += 1;
 5871 ninjaBNF.c   130                        size--;
 5872 ninjaBNF.c   131                        memcpy(&buf3, current, 1);
 5873 ninjaBNF.c   132                        current += 1;
 5874 ninjaBNF.c   133                        size--;
 5875 ninjaBNF.c   134                        *fpos += 3;
 5876 ninjaBNF.c   135  E                     offset = (Uint32)((buf0&0x3f)<<24|
                         +(buf1<<16)|(buf2<<8)|buf3);
 5877 ninjaBNF.c   136                    _ADD_BASE_ADDRESS_:
 5878 ninjaBNF.c   137                        offset *= 4;
 5879 ninjaBNF.c   138                        offset_from_base += offset;
 5880 ninjaBNF.c   139                        addr = (Uint32 *)(tmp+offset_from_
                         +base);
 5881 ninjaBNF.c   140                        if(*addr)
 5882 ninjaBNF.c   141                            *addr += (Uint32)tmp;
 5883 ninjaBNF.c   142                        break;
 5884 ninjaBNF.c   143                }
 5885 ninjaBNF.c   144            }
 5886 ninjaBNF.c   145        }
 5887 ninjaBNF.c   146        return tmp;
 5888 ninjaBNF.c   147    }
 5889 ninjaBNF.c   148    
 5890 ninjaBNF.c   149    
 5891 ninjaBNF.c   150    /*----------------------------------------------------
                         +---------*/
SH SERIES C Compiler (Ver. 5.0(Release10))       06-Jul-1998 19:10:09  PAGE    1


******** STATISTICS INFORMATION ********


********** ERROR INFORMATION ***********

NUMBER OF ERRORS:           0
NUMBER OF WARNINGS:        22




******* SOURCE LINE INFORMATION ********

COMPILED SOURCE LINE:      150



******* SECTION SIZE INFORMATION *******

PROGRAM  SECTION (P):                               000002E4 Byte(s)
PROGRAM  SECTION (P$8):                             00000000 Byte(s)
CONSTANT SECTION (C):                               00000000 Byte(s)
CONSTANT SECTION (C$8):                             00000000 Byte(s)
DATA     SECTION (D):                               00000000 Byte(s)
DATA     SECTION (D$8):                             00000000 Byte(s)
BSS      SECTION (B):                               00000000 Byte(s)
BSS      SECTION (B$8):                             00000000 Byte(s)

 TOTAL PROGRAM SIZE: 000002E4 Byte(s)



********** LABEL INFORMATION ***********

NUMBER OF EXTERNAL REFERENCE SYMBOLS:            7
NUMBER OF EXTERNAL DEFINITION SYMBOLS:           4
NUMBER OF INTERNAL/EXTERNAL SYMBOLS:            11
*** COMMAND PARAMETER ***


  .\ninjaBNF.c -ob=output\ninjaBNF.obj -define=__SHC__,__SET4__ -debug -sub=shc.
sub 

