/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t C S   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 0 9   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 u s i n g   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e ; 
 
 u s i n g   j p . n y a t l a . n y a r t o o l k i t . c s . n y i d m a r k e r ; 
 
 u s i n g   S y s t e m . D i a g n o s t i c s ; 
 
 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . p s a r p l a y c a r d 
 
 { 
 
 
 
 
 
 
 
         / * * 
 
           *   S0n0000o00000;uPk0[W0_0n0Nawb_K000P s A R P l a y C a r d 0000n000000S0~0Y00
 
           * 
 
           * / 
 
         p u b l i c   c l a s s   P s A R P l a y C a r d P i c k u p 
 
         { 
 
                 p u b l i c   c l a s s   P s A r I d P a r a m 
 
                 { 
 
                         p u b l i c   i n t   i d ; 
 
                         p u b l i c   i n t   d i r e c t i o n ; 
 
                 } 
 
                 p r i v a t e   P e r s p e c t i v e P i x e l R e a d e r   _ p e r s p e c t i v e _ r e a d e r ; 
 
                 p r i v a t e   M a r k e r P a t t D e c o d e r   _ d e c o d e r   =   n e w   M a r k e r P a t t D e c o d e r ( ) ; 
 
 
 
                 / * * 
 
                   *   0000000g0Y000000000ubW0~0Y00
 
                   *   @ t h r o w s   N y A R E x c e p t i o n   
 
                   * / 
 
                 p u b l i c   P s A R P l a y C a r d P i c k u p ( ) 
 
                 { 
 
                         t h i s . _ p e r s p e c t i v e _ r e a d e r   =   n e w   P e r s p e c t i v e P i x e l R e a d e r ( ) ; 
 
                         r e t u r n ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   S0n0peo000000000K00;uP00QW0~0Y00
 
                   *   @ p a r a m   i _ p i x _ d r v 
 
                   *   @ p a r a m   i _ s i z e 
 
                   *   @ p a r a m   i _ v e r t e x 
 
                   *   @ p a r a m   o _ d a t a 
 
                   *   @ p a r a m   o _ p a r a m 
 
                   *   @ r e t u r n 
 
                   *   @ t h r o w s   N y A R E x c e p t i o n 
 
                   * / 
 
                 p u b l i c   b o o l   g e t A R P l a y C a r d I d ( I N y A R G s P i x e l D r i v e r   i _ p i x _ d r v ,   N y A R I n t P o i n t 2 d [ ]   i _ v e r t e x ,   P s A r I d P a r a m   i _ r e s u l t ) 
 
                 { 
 
                         i f   ( ! t h i s . _ p e r s p e c t i v e _ r e a d e r . s e t S o u r c e S q u a r e ( i _ v e r t e x ) ) 
 
                         { 
 
                                 r e t u r n   f a l s e ; 
 
                         } 
 
                         r e t u r n   t h i s . _ p i c k F r o m R a s t e r ( i _ p i x _ d r v ,   i _ r e s u l t ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo000000000K00;uP00QW0~0Y00
 
                   *   @ p a r a m   i _ p i x _ d r v 
 
                   *   @ p a r a m   i _ s i z e 
 
                   *   @ p a r a m   i _ v e r t e x 
 
                   *   @ p a r a m   o _ d a t a 
 
                   *   @ p a r a m   o _ p a r a m 
 
                   *   @ r e t u r n 
 
                   *   @ t h r o w s   N y A R E x c e p t i o n 
 
                   * / 
 
                 p u b l i c   b o o l   g e t A R P l a y C a r d I d ( I N y A R G s P i x e l D r i v e r   i _ p i x _ d r v ,   N y A R D o u b l e P o i n t 2 d [ ]   i _ v e r t e x ,   P s A r I d P a r a m   i _ r e s u l t ) 
 
                 { 
 
                         i f   ( ! t h i s . _ p e r s p e c t i v e _ r e a d e r . s e t S o u r c e S q u a r e ( i _ v e r t e x ) ) 
 
                         { 
 
                                 r e t u r n   f a l s e ; 
 
                         } 
 
                         r e t u r n   t h i s . _ p i c k F r o m R a s t e r ( i _ p i x _ d r v ,   i _ r e s u l t ) ; 
 
                 } 
 
                 / * * 
 
                   *   i _ i m a g e K000i d 00000`0W0~0Y00
 
                   *   o _ d a t a k0o00000000o _ p a r a m k0o0000n0000000ԏtSW0~0Y00
 
                   *   @ p a r a m   i m a g e 
 
                   *   @ p a r a m   i _ v e r t e x 
 
                   *   @ p a r a m   o _ d a t a 
 
                   *   @ p a r a m   o _ p a r a m 
 
                   *   @ r e t u r n 
 
                   *   @ t h r o w s   N y A R E x c e p t i o n 
 
                   * / 
 
                 p r i v a t e   b o o l   _ p i c k F r o m R a s t e r ( I N y A R G s P i x e l D r i v e r   i _ p i x _ d r v ,   P s A r I d P a r a m   i _ r e s u l t ) 
 
                 { 
 
                         i f   ( ! t h i s . _ p e r s p e c t i v e _ r e a d e r . r e a d D a t a B i t s ( i _ p i x _ d r v ,   i _ p i x _ d r v . g e t S i z e ( ) ,   t h i s . _ d e c o d e r ) ) 
 
                         { 
 
                                 r e t u r n   f a l s e ; 
 
                         } 
 
                         / / weE\$Pi"}
 
                         r e t u r n   t h i s . _ d e c o d e r . d e c o d e P a t t ( i _ r e s u l t ) ; 
 
                 } 
 
         } 
 
 
 
 
 
 
 
         / * * 
 
           *   P S A R I d 01 0 0 x 1 0 0 ;uPh0W0f00QY00
 
           * / 
 
         s e a l e d   c l a s s   P e r s p e c t i v e P i x e l R e a d e r 
 
         { 
 
                 p r i v a t e   s t a t i c   i n t   R E A D _ R E S O L U T I O N   =   1 0 0 ; 
 
                 p r i v a t e   N y A R P e r s p e c t i v e P a r a m G e n e r a t o r   _ p a r a m _ g e n   =   n e w   N y A R P e r s p e c t i v e P a r a m G e n e r a t o r _ O 1 ( 1 ,   1 ) ; 
 
                 p r i v a t e   d o u b l e [ ]   _ c p a r a m   =   n e w   d o u b l e [ 8 ] ; 
 
 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   * / 
 
                 p u b l i c   P e r s p e c t i v e P i x e l R e a d e r ( ) 
 
                 { 
 
                         r e t u r n ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000V҉b_0000000k0000W0~0Y00
 
                   *   @ p a r a m   i _ v e r t e x 
 
                   *   000Y00V҉b_p^j04  }g0B00_L0B00~0Y00
 
                   *   @ r e t u r n 
 
                   *   bRY00h0t r u e g0Y00
 
                   *   @ t h r o w s   N y A R E x c e p t i o n 
 
                   * / 
 
                 p u b l i c   b o o l   s e t S o u r c e S q u a r e ( N y A R I n t P o i n t 2 d [ ]   i _ v e r t e x ) 
 
                 { 
 
                         r e t u r n   t h i s . _ p a r a m _ g e n . g e t P a r a m ( R E A D _ R E S O L U T I O N ,   R E A D _ R E S O L U T I O N ,   i _ v e r t e x ,   t h i s . _ c p a r a m ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000V҉b_0000000k0000W0~0Y00
 
                   *   @ p a r a m   i _ v e r t e x 
 
                   *   000Y00V҉b_p^j04  }g0B00_L0B00~0Y00
 
                   *   @ r e t u r n 
 
                   *   bRY00h0t r u e g0Y00
 
                   *   @ t h r o w s   N y A R E x c e p t i o n 
 
                   * / 
 
                 p u b l i c   b o o l   s e t S o u r c e S q u a r e ( N y A R D o u b l e P o i n t 2 d [ ]   i _ v e r t e x ) 
 
                 { 
 
                         r e t u r n   t h i s . _ p a r a m _ g e n . g e t P a r a m ( R E A D _ R E S O L U T I O N ,   R E A D _ R E S O L U T I O N ,   i _ v e r t e x ,   t h i s . _ c p a r a m ) ; 
 
                 } 
 
 
 
 
 
                 / / 000000000(un00000( F R Q _ P O I N T S * F R Q _ S T E P L01 0 0 0H0j0D00F0k0Y00S0h0) 
 
 
 
                 p r i v a t e   c o n s t   i n t   M A X _ F R E Q   =   1 0 ; 
 
                 p r i v a t e   c o n s t   i n t   M A X _ D A T A _ B I T S   =   M A X _ F R E Q   +   M A X _ F R E Q   -   1 ; 
 
 
 
                 p r i v a t e   i n t [ ]   _ r e f _ x   =   n e w   i n t [ 1 0 8 ] ; 
 
                 p r i v a t e   i n t [ ]   _ r e f _ y   =   n e w   i n t [ 1 0 8 ] ; 
 
                 / / ( m o d e l + 1 ) * 4 h0T H R E S H O L D _ P I X E L n0i0a00K0'YM0D0e
 
                 p r i v a t e   i n t [ ]   _ p i x c e l _ t e m p   =   n e w   i n t [ 1 0 8 ] ; 
 
 
 
 
 
                 p r i v a t e   v o i d   d e t e c t D a t a B i t s I n d e x ( d o u b l e [ ]   o _ i n d e x _ r o w ,   d o u b l e [ ]   o _ i n d e x _ c o l ) 
 
                 { 
 
                         f o r   ( i n t   i   =   0 ;   i   <   3 ;   i + + ) 
 
                         { 
 
                                 o _ i n d e x _ r o w [ i   *   2 ]   =   2 5   +   i   *   2 0 ; 
 
                                 o _ i n d e x _ r o w [ i   *   2   +   1 ]   =   3 5   +   i   *   2 0 ; 
 
                                 o _ i n d e x _ c o l [ i   *   2 ]   =   2 5   +   i   *   2 0 ; 
 
                                 o _ i n d e x _ c o l [ i   *   2   +   1 ]   =   3 5   +   i   *   2 0 ; 
 
                         } 
 
                 } 
 
                 p r i v a t e   d o u b l e [ ]   _ _ r e a d D a t a B i t s _ i n d e x _ b i t _ x   =   n e w   d o u b l e [ M A X _ D A T A _ B I T S   *   2 ] ; 
 
                 p r i v a t e   d o u b l e [ ]   _ _ r e a d D a t a B i t s _ i n d e x _ b i t _ y   =   n e w   d o u b l e [ M A X _ D A T A _ B I T S   *   2 ] ; 
 
                 / * * 
 
                   *   S0n0peo000000000K0000000S0~0Y00
 
                   *   @ p a r a m   i _ r e a d e r 
 
                   *   000000
 
                   *   @ p a r a m   i _ r a s t e r _ s i z e 
 
                   *   000n0000
 
                   *   @ p a r a m   o _ b i t b u f f e r 
 
                   *   000000n0QRHQ
 
                   *   @ r e t u r n 
 
                   *   bRY00h0t r u e 
 
                   *   @ t h r o w s   N y A R E x c e p t i o n 
 
                   * / 
 
                 p u b l i c   b o o l   r e a d D a t a B i t s ( I N y A R G s P i x e l D r i v e r   i _ r e a d e r ,   N y A R I n t S i z e   i _ r a s t e r _ s i z e ,   M a r k e r P a t t D e c o d e r   o _ b i t b u f f e r ) 
 
                 { 
 
                         i n t   r a s t e r _ w i d t h   =   i _ r a s t e r _ s i z e . w ; 
 
                         i n t   r a s t e r _ h e i g h t   =   i _ r a s t e r _ s i z e . h ; 
 
 
 
                         d o u b l e [ ]   i n d e x _ x   =   t h i s . _ _ r e a d D a t a B i t s _ i n d e x _ b i t _ x ; 
 
                         d o u b l e [ ]   i n d e x _ y   =   t h i s . _ _ r e a d D a t a B i t s _ i n d e x _ b i t _ y ; 
 
 
 
 
 
                         / / 0QW0MOn0S_
 
                         d e t e c t D a t a B i t s I n d e x ( i n d e x _ x ,   i n d e x _ y ) ; 
 
                         i n t   r e s o l u t i o n   =   3 ; 
 
 
 
                         d o u b l e [ ]   c p a r a   =   t h i s . _ c p a r a m ; 
 
                         i n t [ ]   r e f _ x   =   t h i s . _ r e f _ x ; 
 
                         i n t [ ]   r e f _ y   =   t h i s . _ r e f _ y ; 
 
                         i n t [ ]   p i x c e l _ t e m p   =   t h i s . _ p i x c e l _ t e m p ; 
 
 
 
                         d o u b l e   c p a r a _ 0   =   c p a r a [ 0 ] ; 
 
                         d o u b l e   c p a r a _ 1   =   c p a r a [ 1 ] ; 
 
                         d o u b l e   c p a r a _ 3   =   c p a r a [ 3 ] ; 
 
                         d o u b l e   c p a r a _ 6   =   c p a r a [ 6 ] ; 
 
 
 
 
 
                         i n t   p   =   0 ; 
 
                         f o r   ( i n t   i   =   0 ;   i   <   r e s o l u t i o n ;   i + + ) 
 
                         { 
 
                                 / / 1 RRn00000n0000000$P0{Y000
 
                                 d o u b l e   c y 0   =   1   +   i n d e x _ y [ i   *   2   +   0 ] ; 
 
                                 d o u b l e   c y 1   =   1   +   i n d e x _ y [ i   *   2   +   1 ] ; 
 
                                 d o u b l e   c p y 0 _ 1 2   =   c p a r a _ 1   *   c y 0   +   c p a r a [ 2 ] ; 
 
                                 d o u b l e   c p y 0 _ 4 5   =   c p a r a [ 4 ]   *   c y 0   +   c p a r a [ 5 ] ; 
 
                                 d o u b l e   c p y 0 _ 7   =   c p a r a [ 7 ]   *   c y 0   +   1 . 0 ; 
 
                                 d o u b l e   c p y 1 _ 1 2   =   c p a r a _ 1   *   c y 1   +   c p a r a [ 2 ] ; 
 
                                 d o u b l e   c p y 1 _ 4 5   =   c p a r a [ 4 ]   *   c y 1   +   c p a r a [ 5 ] ; 
 
                                 d o u b l e   c p y 1 _ 7   =   c p a r a [ 7 ]   *   c y 1   +   1 . 0 ; 
 
 
 
                                 i n t   p t   =   0 ; 
 
                                 f o r   ( i n t   i 2   =   0 ;   i 2   <   r e s o l u t i o n ;   i 2 + + ) 
 
                                 { 
 
                                         i n t   x x ,   y y ; 
 
                                         d o u b l e   d ; 
 
                                         d o u b l e   c x 0   =   1   +   i n d e x _ x [ i 2   *   2   +   0 ] ; 
 
                                         d o u b l e   c x 1   =   1   +   i n d e x _ x [ i 2   *   2   +   1 ] ; 
 
 
 
                                         d o u b l e   c p 6 _ 0   =   c p a r a _ 6   *   c x 0 ; 
 
                                         d o u b l e   c p x 0 _ 0   =   c p a r a _ 0   *   c x 0 ; 
 
                                         d o u b l e   c p x 3 _ 0   =   c p a r a _ 3   *   c x 0 ; 
 
 
 
                                         d o u b l e   c p 6 _ 1   =   c p a r a _ 6   *   c x 1 ; 
 
                                         d o u b l e   c p x 0 _ 1   =   c p a r a _ 0   *   c x 1 ; 
 
                                         d o u b l e   c p x 3 _ 1   =   c p a r a _ 3   *   c x 1 ; 
 
 
 
                                         d   =   c p 6 _ 0   +   c p y 0 _ 7 ; 
 
                                         r e f _ x [ p t ]   =   x x   =   ( i n t ) ( ( c p x 0 _ 0   +   c p y 0 _ 1 2 )   /   d ) ; 
 
                                         r e f _ y [ p t ]   =   y y   =   ( i n t ) ( ( c p x 3 _ 0   +   c p y 0 _ 4 5 )   /   d ) ; 
 
                                         i f   ( x x   <   0   | |   x x   > =   r a s t e r _ w i d t h   | |   y y   <   0   | |   y y   > =   r a s t e r _ h e i g h t ) 
 
                                         { 
 
                                                 r e f _ x [ p t ]   =   x x   <   0   ?   0   :   ( x x   > =   r a s t e r _ w i d t h   ?   r a s t e r _ w i d t h   -   1   :   x x ) ; 
 
                                                 r e f _ y [ p t ]   =   y y   <   0   ?   0   :   ( y y   > =   r a s t e r _ h e i g h t   ?   r a s t e r _ h e i g h t   -   1   :   y y ) ; 
 
                                         } 
 
                                         p t + + ; 
 
 
 
                                         d   =   c p 6 _ 0   +   c p y 1 _ 7 ; 
 
                                         r e f _ x [ p t ]   =   x x   =   ( i n t ) ( ( c p x 0 _ 0   +   c p y 1 _ 1 2 )   /   d ) ; 
 
                                         r e f _ y [ p t ]   =   y y   =   ( i n t ) ( ( c p x 3 _ 0   +   c p y 1 _ 4 5 )   /   d ) ; 
 
                                         i f   ( x x   <   0   | |   x x   > =   r a s t e r _ w i d t h   | |   y y   <   0   | |   y y   > =   r a s t e r _ h e i g h t ) 
 
                                         { 
 
                                                 r e f _ x [ p t ]   =   x x   <   0   ?   0   :   ( x x   > =   r a s t e r _ w i d t h   ?   r a s t e r _ w i d t h   -   1   :   x x ) ; 
 
                                                 r e f _ y [ p t ]   =   y y   <   0   ?   0   :   ( y y   > =   r a s t e r _ h e i g h t   ?   r a s t e r _ h e i g h t   -   1   :   y y ) ; 
 
                                         } 
 
                                         p t + + ; 
 
 
 
                                         d   =   c p 6 _ 1   +   c p y 0 _ 7 ; 
 
                                         r e f _ x [ p t ]   =   x x   =   ( i n t ) ( ( c p x 0 _ 1   +   c p y 0 _ 1 2 )   /   d ) ; 
 
                                         r e f _ y [ p t ]   =   y y   =   ( i n t ) ( ( c p x 3 _ 1   +   c p y 0 _ 4 5 )   /   d ) ; 
 
                                         i f   ( x x   <   0   | |   x x   > =   r a s t e r _ w i d t h   | |   y y   <   0   | |   y y   > =   r a s t e r _ h e i g h t ) 
 
                                         { 
 
                                                 r e f _ x [ p t ]   =   x x   <   0   ?   0   :   ( x x   > =   r a s t e r _ w i d t h   ?   r a s t e r _ w i d t h   -   1   :   x x ) ; 
 
                                                 r e f _ y [ p t ]   =   y y   <   0   ?   0   :   ( y y   > =   r a s t e r _ h e i g h t   ?   r a s t e r _ h e i g h t   -   1   :   y y ) ; 
 
                                         } 
 
                                         p t + + ; 
 
 
 
                                         d   =   c p 6 _ 1   +   c p y 1 _ 7 ; 
 
                                         r e f _ x [ p t ]   =   x x   =   ( i n t ) ( ( c p x 0 _ 1   +   c p y 1 _ 1 2 )   /   d ) ; 
 
                                         r e f _ y [ p t ]   =   y y   =   ( i n t ) ( ( c p x 3 _ 1   +   c p y 1 _ 4 5 )   /   d ) ; 
 
                                         i f   ( x x   <   0   | |   x x   > =   r a s t e r _ w i d t h   | |   y y   <   0   | |   y y   > =   r a s t e r _ h e i g h t ) 
 
                                         { 
 
                                                 r e f _ x [ p t ]   =   x x   <   0   ?   0   :   ( x x   > =   r a s t e r _ w i d t h   ?   r a s t e r _ w i d t h   -   1   :   x x ) ; 
 
                                                 r e f _ y [ p t ]   =   y y   <   0   ?   0   :   ( y y   > =   r a s t e r _ h e i g h t   ?   r a s t e r _ h e i g h t   -   1   :   y y ) ; 
 
                                         } 
 
                                         p t + + ; 
 
                                 } 
 
                                 / / 1 LRn000000S_( 4XTk00c0f0o0\(u00000fD0_0eL0D0D0) 
 
                                 i _ r e a d e r . g e t P i x e l S e t ( r e f _ x ,   r e f _ y ,   r e s o l u t i o n   *   4 ,   p i x c e l _ t e m p ,   0 ) ; 
 
                                 / / 0000000k0W0j0L000l i n e !m a p x0n0⎙Q
 
                                 f o r   ( i n t   i 2   =   0 ;   i 2   <   r e s o l u t i o n ;   i 2 + + ) 
 
                                 { 
 
                                         i n t   i n d e x   =   i 2   *   4 ; 
 
                                         o _ b i t b u f f e r . s e t B i t ( p ,   ( p i x c e l _ t e m p [ i n d e x   +   0 ]   +   p i x c e l _ t e m p [ i n d e x   +   1 ]   +   p i x c e l _ t e m p [ i n d e x   +   2 ]   +   p i x c e l _ t e m p [ i n d e x   +   3 ] )   /   4 ) ; 
 
                                         p + + ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   t r u e ; 
 
                 } 
 
 
 
 
 
         } 
 
 
 
 
 
         / * * 
 
           *   A R P l a y C a r d   p a t t   d e c o d e r 
 
           * / 
 
         c l a s s   M a r k e r P a t t D e c o d e r 
 
         { 
 
                 / * * 
 
                   *   000MOnn00000( 0 n0MOnL01 - 4 aPg0SBfV0) 
 
                   * / 
 
                 p r i v a t e   s t a t i c   i n t [ ] [ ]   _ b i t _ i n d e x   = { 
 
 	 	       n e w   i n t [ ] { 	 6 , 3 , 0 , 
 
 	 	 	         7 , 4 , 1 , 
 
 	 	 	         8 , 5 , 2 } , 
 
 	 	         n e w   i n t [ ] { 	 0 , 1 , 2 , 
 
 	 	 	         3 , 4 , 5 , 
 
 	 	 	         6 , 7 , 8 } , 
 
 	 	         n e w   i n t [ ] { 	 2 , 5 , 8 , 
 
 	 	 	         1 , 4 , 7 , 
 
 	 	 	         0 , 3 , 6 } , 
 
 	 	         n e w   i n t [ ] { 	 8 , 7 , 6 , 
 
 	 	 	         5 , 4 , 3 , 
 
 	 	 	         2 , 1 , 0 } 
 
 	         } ; 
 
                 / * * 
 
                   *   0000000
 
                   * / 
 
                 p r i v a t e   s t a t i c   i n t [ ] [ ]   _ m k _ p a t t   = { 
 
 	 	         n e w   i n t [ ] { 	 0 , 0 , 1 , 
 
 	 	 	         1 , 0 , 1 , 
 
 	 	 	         1 , 1 , 0 } , 
 
 	 	         n e w   i n t [ ] { 	 0 , 0 , 0 , 
 
 	 	 	         1 , 1 , 1 , 
 
 	 	 	         0 , 0 , 1 } , 
 
 	 	         n e w   i n t [ ] { 	 0 , 0 , 0 , 
 
 	 	 	         1 , 0 , 1 , 
 
 	 	 	         0 , 1 , 0 } , 
 
 	 	         n e w   i n t [ ] { 	 1 , 0 , 1 , 
 
 	 	 	         1 , 1 , 1 , 
 
 	 	 	         1 , 1 , 1 } , 
 
 	 	         n e w   i n t [ ] { 	 1 , 0 , 0 , 
 
 	 	 	         1 , 1 , 1 , 
 
 	 	 	         1 , 0 , 1 } , 
 
 	 	         n e w   i n t [ ] { 	 0 , 0 , 1 , 
 
 	 	 	         1 , 0 , 0 , 
 
 	 	 	         1 , 0 , 1 } 
 
 	         } ; 
 
                 p r i v a t e   i n t [ ]   _ b i t s   =   n e w   i n t [ 9 ] ; 
 
                 / * * 
 
                   *   S0n0peo000000000{ @ l i n k   # _ b i t s } n0n 000vk00$P0000W0~0Y00
 
                   *   @ p a r a m   i _ b i t _ n o 
 
                   *   0000000n000000
 
                   *   @ p a r a m   i _ v a l u e 
 
                   *   000Y00$P0
 
                   * / 
 
                 p u b l i c   v o i d   s e t B i t ( i n t   i _ b i t _ n o ,   i n t   i _ v a l u e ) 
 
                 { 
 
                         t h i s . _ b i t s [ i _ b i t _ n o ]   =   i _ v a l u e ; 
 
                         r e t u r n ; 
 
                 } 
 
                 p r i v a t e   s t a t i c   b o o l   i s M a t c h B i t s ( i n t [ ]   i _ i n _ b i t s ,   i n t [ ]   i _ b i t _ m a p ,   i n t [ ]   i _ b i t _ i n d e x ,   i n t   i _ t h ) 
 
                 { 
 
                         f o r   ( i n t   i   =   8 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
 
 
                                 i f   ( ( ( i _ i n _ b i t s [ i ]   >   i _ t h )   ?   1   :   0 )   ! =   i _ b i t _ m a p [ i _ b i t _ i n d e x [ i ] ] ) 
 
                                 { 
 
                                         r e t u r n   f a l s e ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   t r u e ; 
 
                 } 
 
                 p r i v a t e   s t a t i c   i n t   g e t T h r e s h o l d ( i n t [ ]   i _ i n _ b i t s ) 
 
                 { 
 
                         i n t   m i n   =   i _ i n _ b i t s [ 0 ] ; 
 
                         i n t   m a x   =   i _ i n _ b i t s [ 0 ] ; 
 
                         f o r   ( i n t   i   =   i _ i n _ b i t s . L e n g t h   -   1 ;   i   >   0 ;   i - - ) 
 
                         { 
 
                                 i f   ( m i n   >   i _ i n _ b i t s [ i ] ) 
 
                                 { 
 
                                         m i n   =   i _ i n _ b i t s [ i ] ; 
 
                                 } 
 
                                 e l s e   i f   ( m a x   <   i _ i n _ b i t s [ i ] ) 
 
                                 { 
 
                                         m a x   =   i _ i n _ b i t s [ i ] ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   ( m a x   +   m i n )   /   2 ; 
 
                 } 
 
                 p u b l i c   b o o l   d e c o d e P a t t ( P s A R P l a y C a r d P i c k u p . P s A r I d P a r a m   i _ r e s u l t ) 
 
                 { 
 
                         i n t   t h   =   g e t T h r e s h o l d ( t h i s . _ b i t s ) ; 
 
                         f o r   ( i n t   i   =   _ m k _ p a t t . L e n g t h   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 f o r   ( i n t   i 2   =   _ b i t _ i n d e x . L e n g t h   -   1 ;   i 2   > =   0 ;   i 2 - - ) 
 
                                 { 
 
                                         i f   ( i s M a t c h B i t s ( t h i s . _ b i t s ,   _ m k _ p a t t [ i ] ,   _ b i t _ i n d e x [ i 2 ] ,   t h ) ) 
 
                                         { 
 
                                                 i _ r e s u l t . d i r e c t i o n   =   i 2 ; 
 
                                                 i _ r e s u l t . i d   =   i   +   1 ; 
 
                                                 r e t u r n   t r u e ; 
 
                                         } 
 
                                 } 
 
                         } 
 
                         r e t u r n   f a l s e ; 
 
                 } 
 
         } 
 
 } 