words[]: type FD = { } ; const bool yes = 1 , no = 0 ; const bool true = 1 , false = 0 ; extern { uint8 msbit ( uint16 ) ; uint8 msbit ( uint32 ) ; int sign ( int16 ) ; int sign ( int32 ) ; uint16 abs ( int16 ) ; uint32 abs ( int32 ) ; uint16 swap_bytes ( uint16 ) ; uint32 revert_bytes ( uint32 ) ; uint32 swap_words ( uint32 ) ; uint16 random ( ) ; uint32 mul_wwl ( uint16 , uint16 ) ; void flip ( int8 [ to ] ) = opcode flip ; void rol ( int8 [ to ] ) = opcode rol ; void ror ( int8 [ to ] ) = opcode ror ; void sort ( int8 [ to ] ) = opcode sort ; void rsort ( int8 [ to ] ) = opcode rsort ; void shuffle ( int8 [ to ] ) = opcode shuffle ; void revert ( int8 [ to ] ) = opcode revert ; int8 [ ] join ( int8 [ ] [ ] ¢ , int8 ) = opcode join ; int8 [ ] join ( int8 [ ] [ ] ¢ , int8 [ ] ¢ ) = opcode join ; int8 [ ] [ ] split ( int8 [ ] ¢ , int8 ) = opcode split ; int8 [ ] [ ] split ( int8 [ ] ¢ , int8 [ ] ¢ ) = opcode split ; int8 min ( int8 , int8 ) ; int8 min ( int8 , int8 , int8 ) ; int8 min ( int8 [ to ] ) ; int8 max ( int8 , int8 ) ; int8 max ( int8 , int8 , int8 ) ; int8 max ( int8 [ to ] ) ; uint find ( int8 [ to ] , int8 ) = opcode find ; uint find ( int8 [ to ] , int8 [ ] ¢ ) = opcode find ; uint rfind ( int8 [ to ] , int8 ) = opcode rfind ; uint rfind ( int8 [ to ] , int8 [ ] ¢ ) = opcode rfind ; void shrinktofit ( int8 [ ] & ) ; int8 [ to ] substr ( int8 [ ] ¢ , uint a , uint e ) ; int8 [ to ] midstr ( int8 [ ] ¢ , uint i , uint n ) ; int8 [ to ] leftstr ( int8 [ ] ¢ , uint n ) ; int8 [ to ] rightstr ( int8 [ ] ¢ , uint n ) ; int8 numval ( utf8str ¢ ) ; int8 numval ( ucs1str ¢ ) ; int8 numval ( ucs2str ¢ ) ; void flip ( uint8 [ to ] ) = opcode flip ; void rol ( uint8 [ to ] ) = opcode rol ; void ror ( uint8 [ to ] ) = opcode ror ; void sort ( uint8 [ to ] ) = opcode sort ; void rsort ( uint8 [ to ] ) = opcode rsort ; void shuffle ( uint8 [ to ] ) = opcode shuffle ; void revert ( uint8 [ to ] ) = opcode revert ; uint8 [ ] join ( uint8 [ ] [ ] ¢ , uint8 ) = opcode join ; uint8 [ ] join ( uint8 [ ] [ ] ¢ , uint8 [ ] ¢ ) = opcode join ; uint8 [ ] [ ] split ( uint8 [ ] ¢ , uint8 ) = opcode split ; uint8 [ ] [ ] split ( uint8 [ ] ¢ , uint8 [ ] ¢ ) = opcode split ; uint8 min ( uint8 , uint8 ) ; uint8 min ( uint8 , uint8 , uint8 ) ; uint8 min ( uint8 [ to ] ) ; uint8 max ( uint8 , uint8 ) ; uint8 max ( uint8 , uint8 , uint8 ) ; uint8 max ( uint8 [ to ] ) ; uint find ( uint8 [ to ] , uint8 ) = opcode find ; uint find ( uint8 [ to ] , uint8 [ ] ¢ ) = opcode find ; uint rfind ( uint8 [ to ] , uint8 ) = opcode rfind ; uint rfind ( uint8 [ to ] , uint8 [ ] ¢ ) = opcode rfind ; void shrinktofit ( uint8 [ ] & ) ; uint8 [ to ] substr ( uint8 [ ] ¢ , uint a , uint e ) ; uint8 [ to ] midstr ( uint8 [ ] ¢ , uint i , uint n ) ; uint8 [ to ] leftstr ( uint8 [ ] ¢ , uint n ) ; uint8 [ to ] rightstr ( uint8 [ ] ¢ , uint n ) ; uint8 numval ( utf8str ¢ ) ; uint8 numval ( ucs1str ¢ ) ; uint8 numval ( ucs2str ¢ ) ; void flip ( int16 [ to ] ) = opcode flip ; void rol ( int16 [ to ] ) = opcode rol ; void ror ( int16 [ to ] ) = opcode ror ; void sort ( int16 [ to ] ) = opcode sort ; void rsort ( int16 [ to ] ) = opcode rsort ; void shuffle ( int16 [ to ] ) = opcode shuffle ; void revert ( int16 [ to ] ) = opcode revert ; int16 [ ] join ( int16 [ ] [ ] ¢ , int16 ) = opcode join ; int16 [ ] join ( int16 [ ] [ ] ¢ , int16 [ ] ¢ ) = opcode join ; int16 [ ] [ ] split ( int16 [ ] ¢ , int16 ) = opcode split ; int16 [ ] [ ] split ( int16 [ ] ¢ , int16 [ ] ¢ ) = opcode split ; int16 min ( int16 , int16 ) ; int16 min ( int16 , int16 , int16 ) ; int16 min ( int16 [ to ] ) ; int16 max ( int16 , int16 ) ; int16 max ( int16 , int16 , int16 ) ; int16 max ( int16 [ to ] ) ; uint find ( int16 [ to ] , int16 ) = opcode find ; uint find ( int16 [ to ] , int16 [ ] ¢ ) = opcode find ; uint rfind ( int16 [ to ] , int16 ) = opcode rfind ; uint rfind ( int16 [ to ] , int16 [ ] ¢ ) = opcode rfind ; void shrinktofit ( int16 [ ] & ) ; int16 [ to ] substr ( int16 [ ] ¢ , uint a , uint e ) ; int16 [ to ] midstr ( int16 [ ] ¢ , uint i , uint n ) ; int16 [ to ] leftstr ( int16 [ ] ¢ , uint n ) ; int16 [ to ] rightstr ( int16 [ ] ¢ , uint n ) ; int16 numval ( utf8str ¢ ) ; int16 numval ( ucs1str ¢ ) ; int16 numval ( ucs2str ¢ ) ; void flip ( uint16 [ to ] ) = opcode flip ; void rol ( uint16 [ to ] ) = opcode rol ; void ror ( uint16 [ to ] ) = opcode ror ; void sort ( uint16 [ to ] ) = opcode sort ; void rsort ( uint16 [ to ] ) = opcode rsort ; void shuffle ( uint16 [ to ] ) = opcode shuffle ; void revert ( uint16 [ to ] ) = opcode revert ; uint16 [ ] join ( uint16 [ ] [ ] ¢ , uint16 ) = opcode join ; uint16 [ ] join ( uint16 [ ] [ ] ¢ , uint16 [ ] ¢ ) = opcode join ; uint16 [ ] [ ] split ( uint16 [ ] ¢ , uint16 ) = opcode split ; uint16 [ ] [ ] split ( uint16 [ ] ¢ , uint16 [ ] ¢ ) = opcode split ; uint16 min ( uint16 , uint16 ) ; uint16 min ( uint16 , uint16 , uint16 ) ; uint16 min ( uint16 [ to ] ) ; uint16 max ( uint16 , uint16 ) ; uint16 max ( uint16 , uint16 , uint16 ) ; uint16 max ( uint16 [ to ] ) ; uint find ( uint16 [ to ] , uint16 ) = opcode find ; uint find ( uint16 [ to ] , uint16 [ ] ¢ ) = opcode find ; uint rfind ( uint16 [ to ] , uint16 ) = opcode rfind ; uint rfind ( uint16 [ to ] , uint16 [ ] ¢ ) = opcode rfind ; void shrinktofit ( uint16 [ ] & ) ; uint16 [ to ] substr ( uint16 [ ] ¢ , uint a , uint e ) ; uint16 [ to ] midstr ( uint16 [ ] ¢ , uint i , uint n ) ; uint16 [ to ] leftstr ( uint16 [ ] ¢ , uint n ) ; uint16 [ to ] rightstr ( uint16 [ ] ¢ , uint n ) ; uint16 numval ( utf8str ¢ ) ; uint16 numval ( ucs1str ¢ ) ; uint16 numval ( ucs2str ¢ ) ; void flip ( int32 [ to ] ) = opcode flip ; void rol ( int32 [ to ] ) = opcode rol ; void ror ( int32 [ to ] ) = opcode ror ; void sort ( int32 [ to ] ) = opcode sort ; void rsort ( int32 [ to ] ) = opcode rsort ; void shuffle ( int32 [ to ] ) = opcode shuffle ; void revert ( int32 [ to ] ) = opcode revert ; int32 [ ] join ( int32 [ ] [ ] ¢ , int32 ) = opcode join ; int32 [ ] join ( int32 [ ] [ ] ¢ , int32 [ ] ¢ ) = opcode join ; int32 [ ] [ ] split ( int32 [ ] ¢ , int32 ) = opcode split ; int32 [ ] [ ] split ( int32 [ ] ¢ , int32 [ ] ¢ ) = opcode split ; int32 min ( int32 , int32 ) ; int32 min ( int32 , int32 , int32 ) ; int32 min ( int32 [ to ] ) ; int32 max ( int32 , int32 ) ; int32 max ( int32 , int32 , int32 ) ; int32 max ( int32 [ to ] ) ; uint find ( int32 [ to ] , int32 ) = opcode find ; uint find ( int32 [ to ] , int32 [ ] ¢ ) = opcode find ; uint rfind ( int32 [ to ] , int32 ) = opcode rfind ; uint rfind ( int32 [ to ] , int32 [ ] ¢ ) = opcode rfind ; void shrinktofit ( int32 [ ] & ) ; int32 [ to ] substr ( int32 [ ] ¢ , uint a , uint e ) ; int32 [ to ] midstr ( int32 [ ] ¢ , uint i , uint n ) ; int32 [ to ] leftstr ( int32 [ ] ¢ , uint n ) ; int32 [ to ] rightstr ( int32 [ ] ¢ , uint n ) ; int32 numval ( utf8str ¢ ) ; int32 numval ( ucs1str ¢ ) ; int32 numval ( ucs2str ¢ ) ; void flip ( uint32 [ to ] ) = opcode flip ; void rol ( uint32 [ to ] ) = opcode rol ; void ror ( uint32 [ to ] ) = opcode ror ; void sort ( uint32 [ to ] ) = opcode sort ; void rsort ( uint32 [ to ] ) = opcode rsort ; void shuffle ( uint32 [ to ] ) = opcode shuffle ; void revert ( uint32 [ to ] ) = opcode revert ; uint32 [ ] join ( uint32 [ ] [ ] ¢ , uint32 ) = opcode join ; uint32 [ ] join ( uint32 [ ] [ ] ¢ , uint32 [ ] ¢ ) = opcode join ; uint32 [ ] [ ] split ( uint32 [ ] ¢ , uint32 ) = opcode split ; uint32 [ ] [ ] split ( uint32 [ ] ¢ , uint32 [ ] ¢ ) = opcode split ; uint32 min ( uint32 , uint32 ) ; uint32 min ( uint32 , uint32 , uint32 ) ; uint32 min ( uint32 [ to ] ) ; uint32 max ( uint32 , uint32 ) ; uint32 max ( uint32 , uint32 , uint32 ) ; uint32 max ( uint32 [ to ] ) ; uint find ( uint32 [ to ] , uint32 ) = opcode find ; uint find ( uint32 [ to ] , uint32 [ ] ¢ ) = opcode find ; uint rfind ( uint32 [ to ] , uint32 ) = opcode rfind ; uint rfind ( uint32 [ to ] , uint32 [ ] ¢ ) = opcode rfind ; void shrinktofit ( uint32 [ ] & ) ; uint32 [ to ] substr ( uint32 [ ] ¢ , uint a , uint e ) ; uint32 [ to ] midstr ( uint32 [ ] ¢ , uint i , uint n ) ; uint32 [ to ] leftstr ( uint32 [ ] ¢ , uint n ) ; uint32 [ to ] rightstr ( uint32 [ ] ¢ , uint n ) ; uint32 numval ( utf8str ¢ ) ; uint32 numval ( ucs1str ¢ ) ; uint32 numval ( ucs2str ¢ ) ; void flip ( utf8char [ to ] ) = opcode flip ; void rol ( utf8char [ to ] ) = opcode rol ; void ror ( utf8char [ to ] ) = opcode ror ; void sort ( utf8char [ to ] ) = opcode sort ; void rsort ( utf8char [ to ] ) = opcode rsort ; void shuffle ( utf8char [ to ] ) = opcode shuffle ; void revert ( utf8char [ to ] ) = opcode revert ; utf8char [ ] join ( utf8char [ ] [ ] ¢ , utf8char ) = opcode join ; utf8char [ ] join ( utf8char [ ] [ ] ¢ , utf8char [ ] ¢ ) = opcode join ; utf8char [ ] [ ] split ( utf8char [ ] ¢ , utf8char ) = opcode split ; utf8char [ ] [ ] split ( utf8char [ ] ¢ , utf8char [ ] ¢ ) = opcode split ; utf8char min ( utf8char , utf8char ) ; utf8char min ( utf8char , utf8char , utf8char ) ; utf8char min ( utf8char [ to ] ) ; utf8char max ( utf8char , utf8char ) ; utf8char max ( utf8char , utf8char , utf8char ) ; utf8char max ( utf8char [ to ] ) ; uint find ( utf8char [ to ] , utf8char ) = opcode find ; uint find ( utf8char [ to ] , utf8char [ ] ¢ ) = opcode find ; uint rfind ( utf8char [ to ] , utf8char ) = opcode rfind ; uint rfind ( utf8char [ to ] , utf8char [ ] ¢ ) = opcode rfind ; void shrinktofit ( utf8char [ ] & ) ; utf8char [ to ] substr ( utf8char [ ] ¢ , uint a , uint e ) ; utf8char [ to ] midstr ( utf8char [ ] ¢ , uint i , uint n ) ; utf8char [ to ] leftstr ( utf8char [ ] ¢ , uint n ) ; utf8char [ to ] rightstr ( utf8char [ ] ¢ , uint n ) ; utf8char numval ( utf8str ¢ ) ; utf8char numval ( ucs1str ¢ ) ; utf8char numval ( ucs2str ¢ ) ; void flip ( ucs1char [ to ] ) = opcode flip ; void rol ( ucs1char [ to ] ) = opcode rol ; void ror ( ucs1char [ to ] ) = opcode ror ; void sort ( ucs1char [ to ] ) = opcode sort ; void rsort ( ucs1char [ to ] ) = opcode rsort ; void shuffle ( ucs1char [ to ] ) = opcode shuffle ; void revert ( ucs1char [ to ] ) = opcode revert ; ucs1char [ ] join ( ucs1char [ ] [ ] ¢ , ucs1char ) = opcode join ; ucs1char [ ] join ( ucs1char [ ] [ ] ¢ , ucs1char [ ] ¢ ) = opcode join ; ucs1char [ ] [ ] split ( ucs1char [ ] ¢ , ucs1char ) = opcode split ; ucs1char [ ] [ ] split ( ucs1char [ ] ¢ , ucs1char [ ] ¢ ) = opcode split ; ucs1char min ( ucs1char , ucs1char ) ; ucs1char min ( ucs1char , ucs1char , ucs1char ) ; ucs1char min ( ucs1char [ to ] ) ; ucs1char max ( ucs1char , ucs1char ) ; ucs1char max ( ucs1char , ucs1char , ucs1char ) ; ucs1char max ( ucs1char [ to ] ) ; uint find ( ucs1char [ to ] , ucs1char ) = opcode find ; uint find ( ucs1char [ to ] , ucs1char [ ] ¢ ) = opcode find ; uint rfind ( ucs1char [ to ] , ucs1char ) = opcode rfind ; uint rfind ( ucs1char [ to ] , ucs1char [ ] ¢ ) = opcode rfind ; void shrinktofit ( ucs1char [ ] & ) ; ucs1char [ to ] substr ( ucs1char [ ] ¢ , uint a , uint e ) ; ucs1char [ to ] midstr ( ucs1char [ ] ¢ , uint i , uint n ) ; ucs1char [ to ] leftstr ( ucs1char [ ] ¢ , uint n ) ; ucs1char [ to ] rightstr ( ucs1char [ ] ¢ , uint n ) ; ucs1char numval ( utf8str ¢ ) ; ucs1char numval ( ucs1str ¢ ) ; ucs1char numval ( ucs2str ¢ ) ; void flip ( ucs2char [ to ] ) = opcode flip ; void rol ( ucs2char [ to ] ) = opcode rol ; void ror ( ucs2char [ to ] ) = opcode ror ; void sort ( ucs2char [ to ] ) = opcode sort ; void rsort ( ucs2char [ to ] ) = opcode rsort ; void shuffle ( ucs2char [ to ] ) = opcode shuffle ; void revert ( ucs2char [ to ] ) = opcode revert ; ucs2char [ ] join ( ucs2char [ ] [ ] ¢ , ucs2char ) = opcode join ; ucs2char [ ] join ( ucs2char [ ] [ ] ¢ , ucs2char [ ] ¢ ) = opcode join ; ucs2char [ ] [ ] split ( ucs2char [ ] ¢ , ucs2char ) = opcode split ; ucs2char [ ] [ ] split ( ucs2char [ ] ¢ , ucs2char [ ] ¢ ) = opcode split ; ucs2char min ( ucs2char , ucs2char ) ; ucs2char min ( ucs2char , ucs2char , ucs2char ) ; ucs2char min ( ucs2char [ to ] ) ; ucs2char max ( ucs2char , ucs2char ) ; ucs2char max ( ucs2char , ucs2char , ucs2char ) ; ucs2char max ( ucs2char [ to ] ) ; uint find ( ucs2char [ to ] , ucs2char ) = opcode find ; uint find ( ucs2char [ to ] , ucs2char [ ] ¢ ) = opcode find ; uint rfind ( ucs2char [ to ] , ucs2char ) = opcode rfind ; uint rfind ( ucs2char [ to ] , ucs2char [ ] ¢ ) = opcode rfind ; void shrinktofit ( ucs2char [ ] & ) ; ucs2char [ to ] substr ( ucs2char [ ] ¢ , uint a , uint e ) ; ucs2char [ to ] midstr ( ucs2char [ ] ¢ , uint i , uint n ) ; ucs2char [ to ] leftstr ( ucs2char [ ] ¢ , uint n ) ; ucs2char [ to ] rightstr ( ucs2char [ ] ¢ , uint n ) ; ucs2char numval ( utf8str ¢ ) ; ucs2char numval ( ucs1str ¢ ) ; ucs2char numval ( ucs2str ¢ ) ; bool is_letter ( char ) ; bool is_bin_digit ( char ) ; bool is_dec_digit ( char ) ; bool is_hex_digit ( char ) ; uint digit_value ( char ) ; } ; float64 round ( float64 ) ; float64 floor ( float64 ) ; float64 ceil ( float64 ) ; float64 integ ( float64 ) ; float64 fract ( float64 ) ; int sign ( float64 ) ; float64 abs ( float64 ) ; float64 min ( float64 , float64 ) ; float64 max ( float64 , float64 ) ; float64 min ( float64 , float64 , float64 ) ; float64 max ( float64 , float64 , float64 ) ; float64 random ( ) ; float64 random ( float64 ) ; float64 sin ( float64 ) ; float64 cos ( float64 ) ; float64 tan ( float64 ) ; float64 asin ( float64 ) ; float64 acos ( float64 ) ; float64 atan ( float64 ) ; float64 sinh ( float64 ) ; float64 cosh ( float64 ) ; float64 tanh ( float64 ) ; float64 exp10 ( float64 ) ; float64 log10 ( float64 ) ; float64 exp2 ( float64 ) ; float64 log2 ( float64 ) ; float64 expe ( float64 ) ; float64 loge ( float64 ) ; float64 exp ( float64 , float64 ) ; float64 log ( float64 , float64 ) ; float64 pow ( float64 , int ) ; float64 sqrt ( float64 ) ; str numstr ( float64 ) ; float64 numval ( str ¢ ) ; float64 min ( float64 [ ] ¢ ) ; float64 min ( float64 [ to ] ) ; float64 max ( float64 [ ] ¢ ) ; float64 max ( float64 [ to ] ) ; scope ucs2str { ucs2char [ ] spacestr ( uint ) ucs2char [ ] spacestr ( uint , ucs2char ) ucs2char [ ] charstr ( uint ) ucs2char hexchar ( uint ) ucs2char [ ] hexstr ( uint8 ) ucs2char [ ] hexstr ( uint16 ) ucs2char [ ] hexstr ( uint32 ) ucs2char [ ] hexstr ( uint , uint digits ) ucs2char [ ] hexstr ( ulong , uint digits ) ucs2char [ ] binstr ( uint8 ) ucs2char [ ] binstr ( uint16 ) ucs2char [ ] binstr ( uint32 ) ucs2char [ ] binstr ( uint , uint digits ) ucs2char [ ] binstr ( ulong , uint digits ) ucs2char [ ] binstr ( uint , ucs2char [ ] ¢ o , ucs2char [ ] ¢ l ) ucs2char [ ] binstr ( ulong , ucs2char [ ] ¢ o , ucs2char [ ] ¢ l ) ucs2char [ ] numstr ( int ) ucs2char [ ] numstr ( uint ) ucs2char [ ] numstr ( long ) ucs2char [ ] numstr ( ulong ) ucs2char [ ] toupper ( ucs2char [ ] ¢ ) ucs2char [ ] tolower ( ucs2char [ ] ¢ ) ucs2char [ ] escape ( ucs2char [ ] ¢ , ucs2char leftquote ) ucs2char [ ] unescape ( ucs2char [ ] ¢ ) ucs2char [ ] urlencode ( ucs2char [ ] ¢ ) ucs2char [ ] urldecode ( ucs2char [ ] ¢ ) ucs2char [ ] entab ( ucs2char [ ] ¢ , uint tabwidth ) ucs2char [ ] detab ( ucs2char [ ] ¢ , uint tabwidth ) ucs2char [ ] toupper ( ucs2char [ to ] ) ucs2char [ ] tolower ( ucs2char [ to ] ) ucs2char [ ] escape ( ucs2char [ to ] , ucs2char leftquote ) ucs2char [ ] unescape ( ucs2char [ to ] ) ucs2char [ ] urlencode ( ucs2char [ to ] ) ucs2char [ ] urldecode ( ucs2char [ to ] ) ucs2char [ ] entab ( ucs2char [ to ] , uint tabwidth ) ucs2char [ ] detab ( ucs2char [ to ] , uint tabwidth ) ucs1str toucs1 ( ucs2char [ ] ¢ ) ucs2str toucs2 ( ucs2char [ ] ¢ ) utf8str toutf8 ( ucs2char [ ] ¢ ) ucs1str toucs1 ( ucs2char [ to ] ) ucs2str toucs2 ( ucs2char [ to ] ) utf8str toutf8 ( ucs2char [ to ] ) ucs2char [ ] min ( ucs2char [ ] , ucs2char [ ] ) ucs2char [ ] min ( ucs2char [ ] , ucs2char [ ] ¢ ) ucs2char [ ] min ( ucs2char [ ] ¢ , ucs2char [ ] ) ucs2char [ ] ¢ min ( ucs2char [ ] ¢ , ucs2char [ ] ¢ ) ucs2char [ ] ¢ min ( ucs2char [ ] [ ] ¢ ) ucs2char [ ] ¢ min ( ucs2char [ ] [ to ] ) ucs2char [ ] max ( ucs2char [ ] , ucs2char [ ] ) ucs2char [ ] max ( ucs2char [ ] , ucs2char [ ] ¢ ) ucs2char [ ] max ( ucs2char [ ] ¢ , ucs2char [ ] ) ucs2char [ ] ¢ max ( ucs2char [ ] ¢ , ucs2char [ ] ¢ ) ucs2char [ ] ¢ max ( ucs2char [ ] [ ] ¢ ) ucs2char [ ] ¢ max ( ucs2char [ ] [ to ] ) void flip ( ucs2char [ ] [ to ] ) void rol ( ucs2char [ ] [ to ] ) void ror ( ucs2char [ ] [ to ] ) void sort ( ucs2char [ ] [ to ] ) void rsort ( ucs2char [ ] [ to ] ) void shuffle ( ucs2char [ ] [ to ] ) void revert ( ucs2char [ ] [ to ] ) } scope ucs1str { ucs1char [ ] spacestr ( uint ) ucs1char [ ] spacestr ( uint , ucs1char ) ucs1char [ ] charstr ( uint ) ucs1char hexchar ( uint ) ucs1char [ ] hexstr ( uint8 ) ucs1char [ ] hexstr ( uint16 ) ucs1char [ ] hexstr ( uint32 ) ucs1char [ ] hexstr ( uint , uint digits ) ucs1char [ ] hexstr ( ulong , uint digits ) ucs1char [ ] binstr ( uint8 ) ucs1char [ ] binstr ( uint16 ) ucs1char [ ] binstr ( uint32 ) ucs1char [ ] binstr ( uint , uint digits ) ucs1char [ ] binstr ( ulong , uint digits ) ucs1char [ ] binstr ( uint , ucs1char [ ] ¢ o , ucs1char [ ] ¢ l ) ucs1char [ ] binstr ( ulong , ucs1char [ ] ¢ o , ucs1char [ ] ¢ l ) ucs1char [ ] numstr ( int ) ucs1char [ ] numstr ( uint ) ucs1char [ ] numstr ( long ) ucs1char [ ] numstr ( ulong ) ucs1char [ ] toupper ( ucs1char [ ] ¢ ) ucs1char [ ] tolower ( ucs1char [ ] ¢ ) ucs1char [ ] escape ( ucs1char [ ] ¢ , ucs1char leftquote ) ucs1char [ ] unescape ( ucs1char [ ] ¢ ) ucs1char [ ] urlencode ( ucs1char [ ] ¢ ) ucs1char [ ] urldecode ( ucs1char [ ] ¢ ) ucs1char [ ] entab ( ucs1char [ ] ¢ , uint tabwidth ) ucs1char [ ] detab ( ucs1char [ ] ¢ , uint tabwidth ) ucs1char [ ] toupper ( ucs1char [ to ] ) ucs1char [ ] tolower ( ucs1char [ to ] ) ucs1char [ ] escape ( ucs1char [ to ] , ucs1char leftquote ) ucs1char [ ] unescape ( ucs1char [ to ] ) ucs1char [ ] urlencode ( ucs1char [ to ] ) ucs1char [ ] urldecode ( ucs1char [ to ] ) ucs1char [ ] entab ( ucs1char [ to ] , uint tabwidth ) ucs1char [ ] detab ( ucs1char [ to ] , uint tabwidth ) ucs1str toucs1 ( ucs1char [ ] ¢ ) ucs2str toucs2 ( ucs1char [ ] ¢ ) utf8str toutf8 ( ucs1char [ ] ¢ ) ucs1str toucs1 ( ucs1char [ to ] ) ucs2str toucs2 ( ucs1char [ to ] ) utf8str toutf8 ( ucs1char [ to ] ) ucs1char [ ] min ( ucs1char [ ] , ucs1char [ ] ) ucs1char [ ] min ( ucs1char [ ] , ucs1char [ ] ¢ ) ucs1char [ ] min ( ucs1char [ ] ¢ , ucs1char [ ] ) ucs1char [ ] ¢ min ( ucs1char [ ] ¢ , ucs1char [ ] ¢ ) ucs1char [ ] ¢ min ( ucs1char [ ] [ ] ¢ ) ucs1char [ ] ¢ min ( ucs1char [ ] [ to ] ) ucs1char [ ] max ( ucs1char [ ] , ucs1char [ ] ) ucs1char [ ] max ( ucs1char [ ] , ucs1char [ ] ¢ ) ucs1char [ ] max ( ucs1char [ ] ¢ , ucs1char [ ] ) ucs1char [ ] ¢ max ( ucs1char [ ] ¢ , ucs1char [ ] ¢ ) ucs1char [ ] ¢ max ( ucs1char [ ] [ ] ¢ ) ucs1char [ ] ¢ max ( ucs1char [ ] [ to ] ) void flip ( ucs1char [ ] [ to ] ) void rol ( ucs1char [ ] [ to ] ) void ror ( ucs1char [ ] [ to ] ) void sort ( ucs1char [ ] [ to ] ) void rsort ( ucs1char [ ] [ to ] ) void shuffle ( ucs1char [ ] [ to ] ) void revert ( ucs1char [ ] [ to ] ) } scope utf8str { utf8char [ ] spacestr ( uint ) utf8char [ ] spacestr ( uint , utf8char ) utf8char [ ] charstr ( uint ) char hexchar ( uint ) utf8char [ ] hexstr ( uint8 ) utf8char [ ] hexstr ( uint16 ) utf8char [ ] hexstr ( uint32 ) utf8char [ ] hexstr ( uint , uint digits ) utf8char [ ] hexstr ( ulong , uint digits ) utf8char [ ] binstr ( uint8 ) utf8char [ ] binstr ( uint16 ) utf8char [ ] binstr ( uint32 ) utf8char [ ] binstr ( uint , uint digits ) utf8char [ ] binstr ( ulong , uint digits ) utf8char [ ] binstr ( uint , utf8char [ ] ¢ o , utf8char [ ] ¢ l ) utf8char [ ] binstr ( ulong , utf8char [ ] ¢ o , utf8char [ ] ¢ l ) utf8char [ ] numstr ( int ) utf8char [ ] numstr ( uint ) utf8char [ ] numstr ( long ) utf8char [ ] numstr ( ulong ) utf8char [ ] toupper ( utf8char [ ] ¢ ) utf8char [ ] tolower ( utf8char [ ] ¢ ) utf8char [ ] escape ( utf8char [ ] ¢ , char leftquote ) utf8char [ ] unescape ( utf8char [ ] ¢ ) utf8char [ ] urlencode ( utf8char [ ] ¢ ) utf8char [ ] urldecode ( utf8char [ ] ¢ ) utf8char [ ] entab ( utf8char [ ] ¢ , uint tabwidth ) utf8char [ ] detab ( utf8char [ ] ¢ , uint tabwidth ) utf8char [ ] toupper ( utf8char [ to ] ) utf8char [ ] tolower ( utf8char [ to ] ) utf8char [ ] escape ( utf8char [ to ] , char leftquote ) utf8char [ ] unescape ( utf8char [ to ] ) utf8char [ ] urlencode ( utf8char [ to ] ) utf8char [ ] urldecode ( utf8char [ to ] ) utf8char [ ] entab ( utf8char [ to ] , uint tabwidth ) utf8char [ ] detab ( utf8char [ to ] , uint tabwidth ) ucs1str toucs1 ( utf8char [ ] ¢ ) ucs2str toucs2 ( utf8char [ ] ¢ ) utf8str toutf8 ( utf8char [ ] ¢ ) ucs1str toucs1 ( utf8char [ to ] ) ucs2str toucs2 ( utf8char [ to ] ) utf8str toutf8 ( utf8char [ to ] ) utf8char [ ] min ( utf8char [ ] , utf8char [ ] ) utf8char [ ] min ( utf8char [ ] , utf8char [ ] ¢ ) utf8char [ ] min ( utf8char [ ] ¢ , utf8char [ ] ) utf8char [ ] ¢ min ( utf8char [ ] ¢ , utf8char [ ] ¢ ) utf8char [ ] ¢ min ( utf8char [ ] [ ] ¢ ) utf8char [ ] ¢ min ( utf8char [ ] [ to ] ) utf8char [ ] max ( utf8char [ ] , utf8char [ ] ) utf8char [ ] max ( utf8char [ ] , utf8char [ ] ¢ ) utf8char [ ] max ( utf8char [ ] ¢ , utf8char [ ] ) utf8char [ ] ¢ max ( utf8char [ ] ¢ , utf8char [ ] ¢ ) utf8char [ ] ¢ max ( utf8char [ ] [ ] ¢ ) utf8char [ ] ¢ max ( utf8char [ ] [ to ] ) void flip ( utf8char [ ] [ to ] ) void rol ( utf8char [ ] [ to ] ) void ror ( utf8char [ ] [ to ] ) void sort ( utf8char [ ] [ to ] ) void rsort ( utf8char [ ] [ to ] ) void shuffle ( utf8char [ ] [ to ] ) void revert ( utf8char [ ] [ to ] ) } ucs1char [ ] spacestr ( uint ) ucs1char [ ] spacestr ( uint , ucs1char ) ucs1char [ ] charstr ( uint ) ucs1char hexchar ( uint ) ucs1char [ ] hexstr ( uint8 ) ucs1char [ ] hexstr ( uint16 ) ucs1char [ ] hexstr ( uint32 ) ucs1char [ ] hexstr ( uint , uint digits ) ucs1char [ ] hexstr ( ulong , uint digits ) ucs1char [ ] binstr ( uint8 ) ucs1char [ ] binstr ( uint16 ) ucs1char [ ] binstr ( uint32 ) ucs1char [ ] binstr ( uint , uint digits ) ucs1char [ ] binstr ( ulong , uint digits ) ucs1char [ ] binstr ( uint , ucs1char [ ] ¢ o , ucs1char [ ] ¢ l ) ucs1char [ ] binstr ( ulong , ucs1char [ ] ¢ o , ucs1char [ ] ¢ l ) ucs1char [ ] numstr ( int ) ucs1char [ ] numstr ( uint ) ucs1char [ ] numstr ( long ) ucs1char [ ] numstr ( ulong ) ucs1char [ ] toupper ( ucs1char [ ] ¢ ) ucs1char [ ] tolower ( ucs1char [ ] ¢ ) ucs1char [ ] escape ( ucs1char [ ] ¢ , ucs1char leftquote ) ucs1char [ ] unescape ( ucs1char [ ] ¢ ) ucs1char [ ] urlencode ( ucs1char [ ] ¢ ) ucs1char [ ] urldecode ( ucs1char [ ] ¢ ) ucs1char [ ] entab ( ucs1char [ ] ¢ , uint tabwidth ) ucs1char [ ] detab ( ucs1char [ ] ¢ , uint tabwidth ) ucs1char [ ] toupper ( ucs1char [ to ] ) ucs1char [ ] tolower ( ucs1char [ to ] ) ucs1char [ ] escape ( ucs1char [ to ] , ucs1char leftquote ) ucs1char [ ] unescape ( ucs1char [ to ] ) ucs1char [ ] urlencode ( ucs1char [ to ] ) ucs1char [ ] urldecode ( ucs1char [ to ] ) ucs1char [ ] entab ( ucs1char [ to ] , uint tabwidth ) ucs1char [ ] detab ( ucs1char [ to ] , uint tabwidth ) ucs1str toucs1 ( ucs1char [ ] ¢ ) ucs2str toucs2 ( ucs1char [ ] ¢ ) utf8str toutf8 ( ucs1char [ ] ¢ ) ucs1str toucs1 ( ucs1char [ to ] ) ucs2str toucs2 ( ucs1char [ to ] ) utf8str toutf8 ( ucs1char [ to ] ) ucs1char [ ] min ( ucs1char [ ] , ucs1char [ ] ) ucs1char [ ] min ( ucs1char [ ] , ucs1char [ ] ¢ ) ucs1char [ ] min ( ucs1char [ ] ¢ , ucs1char [ ] ) ucs1char [ ] ¢ min ( ucs1char [ ] ¢ , ucs1char [ ] ¢ ) ucs1char [ ] ¢ min ( ucs1char [ ] [ ] ¢ ) ucs1char [ ] ¢ min ( ucs1char [ ] [ to ] ) ucs1char [ ] max ( ucs1char [ ] , ucs1char [ ] ) ucs1char [ ] max ( ucs1char [ ] , ucs1char [ ] ¢ ) ucs1char [ ] max ( ucs1char [ ] ¢ , ucs1char [ ] ) ucs1char [ ] ¢ max ( ucs1char [ ] ¢ , ucs1char [ ] ¢ ) ucs1char [ ] ¢ max ( ucs1char [ ] [ ] ¢ ) ucs1char [ ] ¢ max ( ucs1char [ ] [ to ] ) void flip ( ucs1char [ ] [ to ] ) void rol ( ucs1char [ ] [ to ] ) void ror ( ucs1char [ ] [ to ] ) void sort ( ucs1char [ ] [ to ] ) void rsort ( ucs1char [ ] [ to ] ) void shuffle ( ucs1char [ ] [ to ] ) void revert ( ucs1char [ ] [ to ] ) enum { tm_utc = 0 , tm_localtime = 1 , tm_time = 2 , tm_date = 4 , tm_timezone = 8 , tm_sec = 16 , tm_msec = 32 } extern { float now ( ) ; str timestr ( float seconds , uint flags ) ; float timeval ( str ¢ , uint flags ) ; } enum uint8 { c_reset = 0 , c_speed = 1 , c_hwhsk = 2 , c_swhsk = 3 , c_flushin = 4 , c_availin = 4 , c_flushout = 5 , c_availout = 5 , c_clk_hsk = 6 , c_log2blocksize = 7 , c_totalblocks_lo = 8 , c_totalblocks_hi = 9 , c_reserved2 = 10 } ; enum uint8 OSErr = { ok = 0 , parameter_error = 1 , function_not_supported = 1 , io_error = 2 , device_not_responding = 3 , file_error , filesystem_invalid , device_not_found , directory_not_found , file_not_found , not_a_directory , is_a_directory , file_already_open_for_writing , file_already_open , file_exists , file_not_writable , end_of_file , disk_full , directory_corrupted , filesystem_corrupted } ; extern { OSErr errno ; OSErr error ( ) ; void clear_error ( ) ; void set_error ( OSErr ) ; bool yes_with_error ( OSErr ) ; void * null_with_error ( OSErr ) ; } enum uint8 NodeType = { t_endmarker = 0 , t_file = 1 , t_dir = 2 , t_ser = 3 , t_block = 4 , m_erased = 128 } ; scope NodeType { NodeType operator | ( NodeType , NodeType ) = opcode operator | ; NodeType operator & ( NodeType , NodeType ) = opcode operator & ; } type FD_Handlers = { uint ( FD ¢ , uint8 fu ) getctl ; void ( FD ¢ , uint8 fu , uint ) setctl ; uint ( FD ¢ ) avail_in ; uint ( FD ¢ ) avail_out ; char ( FD ¢ ) getc ; void ( FD ¢ , char ) putc ; bool ( FD ¢ , uint8 [ to ] ) read ; bool ( FD ¢ , uint8 [ to ] ) write ; bool ( FD ¢ , uint32 , uint8 [ ] ¢ ) read_block ; bool ( FD ¢ , uint32 , uint8 [ ] ¢ ) write_block ; void ( FD ¢ ) kill ; ulong ( FD ¢ ) getfpos ; bool ( FD ¢ , ulong fpos ) setfpos ; } extern { uint no_avail_in ( FD ¢ ) uint no_avail_out ( FD ¢ ) = no_avail_in ; char no_getc ( FD ¢ ) = no_avail_in ; void no_putc ( FD ¢ , char ) ulong no_getfpos ( FD ¢ ) bool no_setfpos ( FD ¢ , ulong ) bool no_read ( FD ¢ , uint8 [ to ] ) bool no_write ( FD ¢ , uint8 [ to ] ) = no_read ; bool no_read_block ( FD ¢ , uint32 , uint8 [ ] ¢ ) bool no_write_block ( FD ¢ , uint32 , uint8 [ ] ¢ ) = no_read_block ; } type FD = { FD_Handlers ¢ handlers ; NodeType nodetype ; str name ; } extern { uint avail_in ( ) ; uint avail_out ( ) ; const uint delimiters = 1 << 0 + 1 << 4 + 1 << 10 + 1 << 12 + 1 << 13 ; char getc ( ) ; void putc ( char c ) ; str gets ( uint delimiters ) ; void puts ( str ¢ ) ; void puts ( str ) ; void putnum ( uint ) ; void putnum ( int ) ; bool read ( uint8 [ to ] ) ; bool write ( uint8 [ to ] ) ; } scope FD { extern { void init ( FD ¢ , NodeType , str ¢ name , FD_Handlers ¢ ) ; void kill ( FD ¢ ) ; FD kill ( FD ) ; uint getctl ( FD ¢ , uint8 fu ) void setctl ( FD ¢ , uint8 fu , uint n ) uint avail_in ( FD ¢ ) ; uint avail_out ( FD ¢ ) ; char getc ( FD ¢ ) ; void putc ( FD ¢ , char c ) ; str gets ( FD ¢ , uint delimiters ) ; void puts ( FD ¢ , str ¢ ) ; void puts ( FD ¢ , str ) ; void putnum ( FD ¢ , uint ) ; void putnum ( FD ¢ , int ) ; bool read ( FD ¢ , uint8 [ to ] ) bool write ( FD ¢ , uint8 [ to ] ) bool read_block ( FD ¢ , uint32 blk , uint8 [ ] ¢ ) ; bool write_block ( FD ¢ , uint32 blk , uint8 [ ] ¢ ) ; ulong getfpos ( FD ¢ ) bool setfpos ( FD ¢ , ulong fpos ) bool is_dir ( FD ¢ ) ; bool is_file ( FD ¢ ) ; } } extern const { bool option_a5 = true ; uint8 bSIO_SELECT = 1 ; uint8 bIDE_SELECT = 2 ; uint8 mSIO_SELECT = 255 - 1 << bSIO_SELECT ; uint8 mIDE_SELECT = 255 - 2 << bSIO_SELECT ; } ; type FD = { } ; type BlockDevice = { } ; type IdeBlockDevice = { } ; type I2cBlockDevice = { } ; type SerialDevice = { } ; type Range = { } ; type File = { } ; type FD_Handlers = { } ; extern { uint8 k1_irpt_mask ; uint8 sysflags ; uint32 systemtime ; uint16 period ; uint32 timestamp ; uint16 tsmsec ; char * romdate ; char * romtime ; FD [ ] devs ; File [ ] fds ; FD stdin ; FD stdout ; SerialDevice sio1A ; SerialDevice sio1B ; IdeBlockDevice ide2A ; IdeBlockDevice ide2B ; I2cBlockDevice sio1rom ; I2cBlockDevice ide2rom ; OSErr errno ; void di ( ) void ei ( ) ; void ei_all ( ) ; void select ( uint8 ) uint8 in ( uint8 ) void out ( uint8 , uint8 ) void wait ( ) void memcpy ( void * z , void * q , uint cnt ) void memset ( void * z , uint c , uint cnt ) void memclr ( void * z , uint cnt ) void set_red_led ( ) ; void set_yellow_led ( ) ; void set_both_leds ( ) ; void clear_both_leds ( ) ; OSErr lock_eeprom ( ) ; OSErr unlock_eeprom ( ) ; void write_eeprom ( void * q , void * z , uint16 cnt ) ; void download_firmware ( ) ; void abort ( ) = opcode abort ; void panic ( uint8 blinkcode ) ; void assert1 ( bool ) ; void assert0 ( bool ) ; uint mem_get_free ( ) ; uint mem_get_free_total ( ) ; void download_firmware ( ) ; uint8 fd_function_not_supported ( ) ; void sio_init_channel ( SerialDevice ¢ , str ¢ name , uint8 devselbit , uint8 ch ) ; void ide_init_blockdevice ( BlockDevice ¢ ) ; void i2c_init_blockdevice ( BlockDevice ¢ ) ; } ; type File = { } ; type BlockDevice = FD + { uint blocksize ; uint blockmask ; uint8 log2blocksize ; uint32 totalblocks ; bool wide ; File [ ] open_files ; } ; scope BlockDevice { extern void init ( BlockDevice ¢ , NodeType , str ¢ name , FD_Handlers ¢ , uint8 log2blksz , uint32 totalblocks ) ; extern void kill ( BlockDevice ¢ ) = void FD . kill ( FD ¢ ) ; extern uint getctl ( BlockDevice ¢ fd , uint8 fu ) ; extern void setctl ( BlockDevice ¢ fd , uint8 fu , uint n ) ; } ; type IdeBlockDevice = BlockDevice + { uint8 drive_head ; } ; type IdentifyData = { uint16 [ 256 ] sector ; str model_name ; str serial_number ; str firmware_revision ; uint ata_version ; uint32 cmd_sets_supported ; uint32 cmd_sets_enabled ; bool supports_pio3_dma1 ; bool supports_ultra_dma ; uint8 max_rw_multiple ; bool fixed_disk ; bool removable_medium ; uint8 cfa_power_mode ; bool lba_supported ; uint32 lba_dflt_capacity ; } ; extern IdeBlockDevice new ( str ¢ name , bool master ) ; scope IdeBlockDevice { IdeBlockDevice kill ( IdeBlockDevice ) = FD FD . kill ( FD ) ; uint8 select_drive ( uint8 drive_head ) ; uint8 select_master ( ) ; uint8 select_slave ( ) ; uint8 read_status ( ) ; uint8 read_error ( ) ; uint8 command_nop ( ) ; uint8 set_feature ( uint8 ) ; uint8 set_8bit_data ( ) ; uint8 set_16bit_data ( ) ; uint8 write_sector ( uint32 lba , void * bu ) ; uint8 read_sector ( uint32 lba , void * bu ) ; uint8 identify_device ( void * bu ) ; extern uint getctl ( IdeBlockDevice ¢ , uint8 fu ) = BlockDevice . getctl ; extern void setctl ( IdeBlockDevice ¢ , uint8 fu , uint n ) = BlockDevice . setctl ; extern bool read_block ( IdeBlockDevice ¢ , uint32 blk , uint8 [ ] ¢ ) ; extern bool write_block ( IdeBlockDevice ¢ , uint32 blk , uint8 [ ] ¢ ) ; extern IdentifyData identify ( IdeBlockDevice ¢ ) ; } ; extern const uint8 CS0 = 0 << 3 + 1 << 4 , CS1 = 1 << 3 + 0 << 4 , IDE_DATA = CS0 + 0 , IDE_ERROR = CS0 + 1 , IDE_FEATURE = CS0 + 1 , IDE_SECTOR_COUNT = CS0 + 2 , IDE_SECTOR_NUMBER = CS0 + 3 , IDE_CYLINDER_LOW = CS0 + 4 , IDE_CYLINDER_HIGH = CS0 + 5 , IDE_DRIVE_HEAD = CS0 + 6 , IDE_STATUS = CS0 + 7 , IDE_COMMAND = CS0 + 7 , IDE_STATUS2 = CS1 + 4 , IDE_DEVICE_CONTROL = CS1 + 6 , IDE_ACTIVE_STATUS = CS1 + 7 , IDE_LBA_BYTE0 = IDE_SECTOR_NUMBER , IDE_LBA_BYTE1 = IDE_CYLINDER_LOW , IDE_LBA_BYTE2 = IDE_CYLINDER_HIGH , IDE_LBA_BYTE3 = IDE_DRIVE_HEAD , mIDE_MASTER = 0 , mIDE_SLAVE = 16 , mIDE_CSH = 160 , mIDE_LBA = 224 , mERR_AMNF = 1 , mERR_TRK0NF = 2 , mERR_ABORT = 4 , mERR_MEDIA_CHREQ = 8 , mERR_IDNF = 16 , mERR_MEDIA_CHANGED = 32 , mERR_UNCORR_ERROR = 64 , mERR_BAD_BLOCK = 128 , bERR_AMNF = 0 , bERR_TRK0NF = 1 , bERR_ABORT = 2 , bERR_MEDIA_CHREQ = 3 , bERR_IDNF = 4 , bERR_MEDIA_CHANGED = 5 , bERR_UNCORR_ERROR = 6 , bERR_BAD_BLOCK = 7 , mSR_ERROR = 1 , mSR_IDX_PULSe = 2 , mSR_ECC = 4 , mSR_DRQ = 8 , mSR_SEEK_COMPLETED = 16 , mSR_WRITE_FAULT = 32 , mSR_READY = 64 , mSR_BUSY = 128 , bSR_ERROR = 0 , bSR_IDX_PULSe = 1 , bSR_ECC = 2 , bSR_DRQ = 3 , bSR_SEEK_COMPLETED = 4 , bSR_WRITE_FAULT = 5 , bSR_READY = 6 , bSR_BUSY = 7 , cmd_nop = 0 , cfa_request_extended_error = 3 , cmd_read_sectors = 32 , cmd_write_sectors = 48 , cfa_write_sectors_without_erase = 56 , cmd_read_verify_sectors = 64 , cmd_seek_track = 112 , cfa_translate_sector = 135 , cmd_device_diagnostic = 144 , cmd_initialize_drive_parameters = 145 , cfa_erase_sectors = 192 , cmd_read_multiple = 196 , cmd_write_multiple = 197 , cmd_set_multiple_mode = 198 , cfa_write_multiple_without_erase = 205 , cmd_standby_immediate = 224 , cmd_idle_immediate = 225 , cmd_standby = 226 , cmd_idle = 227 , cmd_read_buffer = 228 , cmd_check_power_mode = 229 , cmd_sleep = 230 , cmd_flush_cache = 231 , cmd_write_buffer = 232 , cmd_identify_device = 236 , cmd_set_features = 239 ; const uint ide_blocksize = 512 ; const uint ide_blockmask = 511 ; const uint8 ide_log2blocksize = 9 ; FD_Handlers new_ide_handlers ( ) = asm { # assert FD_Handlers . getctl == 0 # assert FD_Handlers . setctl == 2 # assert FD_Handlers . avail_in == 4 # assert FD_Handlers . avail_out == 6 # assert FD_Handlers . getc == 8 # assert FD_Handlers . putc == 10 # assert FD_Handlers . read == 12 # assert FD_Handlers . write == 14 # assert FD_Handlers . read_block == 16 # assert FD_Handlers . write_block == 18 # assert FD_Handlers . kill == 20 # assert FD_Handlers . getfpos == 22 # assert FD_Handlers . setfpos == 24 p_enter dw ISTR dw 26 dw BlockDevice . getctl__11BlockDeviceC_5uint8_6uint16 dw BlockDevice . setctl__11BlockDeviceC_5uint8_6uint16_ dw no_avail_in__2FDC_6uint16 dw no_avail_in__2FDC_6uint16 ; avail_out dw no_avail_in__2FDC_6uint16 ; no_getc__2FDC_8ucs1char dw no_putc__2FDC_8ucs1char_ dw no_read__2FDC_5uint8ATOE_4bool dw no_read__2FDC_5uint8ATOE_4bool ; write dw IdeBlockDevice . read_block__14IdeBlockDeviceC_6uint32_5uint8AEC_4bool dw IdeBlockDevice . write_block__14IdeBlockDeviceC_6uint32_5uint8AEC_4bool dw FD . kill__2FDC_ dw no_getfpos__2FDC_6uint32 dw no_setfpos__2FDC_6uint32_4bool dw RETURN } FD_Handlers ide_handlers = new_ide_handlers ( ) ; IdeBlockDevice new ( str ¢ name , bool master ) { uint8 drive_head = master ? mIDE_MASTER + mIDE_LBA : mIDE_SLAVE + mIDE_LBA ; uint8 status ; uint8 i = 50 ; do { status = IdeBlockDevice . select_drive ( drive_head ) ; while -- i && ( status & mSR_BUSY || ! ( status & mSR_READY ) ) ; wait ( ) ; } if ( i != 0 ) { uint32 [ 128 ] bu = alloc uint32 [ 128 ] ( ) ; if ( ! ( IdeBlockDevice . set_8bit_data ( ) & mSR_ERROR || IdeBlockDevice . identify_device ( & bu [ 0 ] ) & mSR_ERROR ) ) { IdeBlockDevice this = alloc IdeBlockDevice ( ) ; BlockDevice . init ( this , t_block , name , ide_handlers , ide_log2blocksize , bu [ 120 / 4 ] ) ; this . drive_head = drive_head ; return this ; } } return null ; } scope IdeBlockDevice { bool io_block ( IdeBlockDevice ¢ fd , uint32 blk , uint8 [ ] ¢ bu , uint8 ( uint32 lba , void * bu ) io ) { assert1 ( bu . count ( ) == ide_blocksize ) ; uint8 status = select_drive ( fd . drive_head ) ; if ( status == 255 || ! ( status & mSR_READY ) ) return yes_with_error ( device_not_responding ) ; if ( status & mSR_ERROR || io ( blk , & bu [ 0 ] ) & mSR_ERROR ) return yes_with_error ( io_error ) ; return no ; } bool read_block ( IdeBlockDevice ¢ fd , uint32 blk , uint8 [ ] ¢ bu ) { return io_block ( fd , blk , bu , read_sector ) ; } bool write_block ( IdeBlockDevice ¢ fd , uint32 blk , uint8 [ ] ¢ bu ) { return io_block ( fd , blk , bu , write_sector ) ; } void swap_bytes ( uint16 [ ] bu , uint8 a , uint8 e ) { do { while -- e >= a ; bu [ e ] = swap_bytes ( bu [ e ] ) ; } } str idfstr ( char [ ] ¢ bu , uint8 a , uint8 e ) { do { while e -- > a ; until bu [ e ] > 32 ; } return bu [ a to e + 1 ] ; } IdentifyData identify ( IdeBlockDevice ¢ fd ) { uint16 [ ] sector = alloc uint16 [ 256 ] ( ) ; if ( mSR_ERROR & select_drive ( fd . drive_head ) || mSR_ERROR & identify_device ( & sector [ 0 ] ) ) { return null_with_error ( io_error ) ; } IdentifyData d = alloc IdentifyData ( ) ; d . sector = sector ; swap_bytes ( sector , 10 , 47 ) ; d . model_name = idfstr ( ( str & ) sector , 27 * 2 , 47 * 2 ) ; d . serial_number = idfstr ( ( str & ) sector , 10 * 2 , 20 * 2 ) ; d . firmware_revision = idfstr ( ( str & ) sector , 23 * 2 , 27 * 2 ) ; swap_bytes ( sector , 10 , 47 ) ; d . ata_version = sector [ 80 ] ; d . fixed_disk = ( bool ) ( sector [ 0 ] & 64 ) ; d . removable_medium = ( bool ) ( sector [ 0 ] & 128 ) ; d . supports_pio3_dma1 = ( bool ) ( sector [ 53 ] & 1 ) ; d . supports_ultra_dma = ( bool ) ( sector [ 53 ] & 2 ) ; d . lba_supported = ( bool ) ( sector [ 49 ] & 512 ) ; d . cfa_power_mode = sector [ 160 ] ; if ( sector [ 47 ] & 32768 ) d . max_rw_multiple = sector [ 47 ] . lo ; d . cmd_sets_supported = * ( uint32 * ) & sector [ 82 ] ; d . cmd_sets_enabled = * ( uint32 * ) & sector [ 85 ] ; d . lba_dflt_capacity = * ( uint32 * ) & sector [ 60 ] ; return d ; } } ""