home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************
- *
- * SERVIMEM.C
- *
- **************************************************************/
-
- #include "servimem.pif"
-
- #define max_bytes 4 /* a variable length number is composed of max.
- 4 bytes, see the MIDI file specification */
-
-
- unsigned int read_var_len
- (
- unsigned char *address ,
- unsigned long *P_read_number ,
- unsigned char *P_read_bytes
- )
- {
- register unsigned long buffer = 0 ;
- register unsigned int errors = 0 ;
-
- *P_read_bytes = 0 ;
- do
- {
- buffer = (buffer << 7) ;
- (unsigned char)buffer = (unsigned char)buffer | (*address & 0x7f) ;
- address ++ ;
- *P_read_bytes +=1 ;
- if (*P_read_bytes > max_bytes) errors = -1 ;
- }
- while ( (!errors) && (*(address-1) & 0x80) ) ;
- *P_read_number = buffer ;
- return(errors) ;
- }
-
-
- unsigned long read_long(unsigned char *address)
- {
- unsigned long buffer ;
-
- *((unsigned char *)&buffer ) = *(address ) ;
- *((unsigned char *)&buffer + 1) = *(address + 1) ;
- *((unsigned char *)&buffer + 2) = *(address + 2) ;
- *((unsigned char *)&buffer + 3) = *(address + 3) ;
- return(buffer) ;
- }
-
-
- unsigned int read_int(unsigned char *address)
- {
- unsigned int buffer ;
-
- *((unsigned char *)&buffer ) = *(address ) ;
- *((unsigned char *)&buffer + 1) = *(address + 1) ;
- return(buffer) ;
- }
-