summaryrefslogtreecommitdiff
blob: c21d13e8b8abecfc1e9195faa84079ce3a9d80b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/******************************* LICENCE **************************************
* Any code in this file may be redistributed or modified under the terms of
* the GNU General Public Licence as published by the Free Software 
* Foundation; version 2 of the licence.
****************************** END LICENCE ***********************************/

/******************************************************************************
* Author:
* Andrew Smith, http://littlesvr.ca/misc/contactandrew.php
*
* Contributors:
* 
******************************************************************************/

#include <stdio.h>

#include "bkRead7x.h"
#include "bk.h"
#include "bkIoWrappers.h"

int read711(VolInfo* volInfo, unsigned char* value)
{
    return readRead(volInfo, value, 1);
}

int read721(VolInfo* volInfo, unsigned short* value)
{
    int rc;
    unsigned char array[2];
    
    rc = readRead(volInfo, array, 2);
    if(rc != 2)
        return rc;
    
    *value = array[1];
    *value <<= 8;
    *value |= array[0];
    
    return rc;
}

int read731(VolInfo* volInfo, unsigned* value)
{
    int rc;
    unsigned char array[4];
    
    rc = readRead(volInfo, array, 4);
    if(rc != 4)
        return rc;
    
    *value = array[3];
    *value <<= 8;
    *value |= array[2];
    *value <<= 8;
    *value |= array[1];
    *value <<= 8;
    *value |= array[0];
    
    return rc;
}

int read733(VolInfo* volInfo, unsigned* value)
{
    int rc;
    unsigned char both[8];
    
    rc = readRead(volInfo, both, 8);
    if(rc != 8)
        return rc;
    
    read733FromCharArray(both, value);
    
    return rc;
}

void read733FromCharArray(unsigned char* array, unsigned* value)
{
    *value = array[3];
    *value <<= 8;
    *value |= array[2];
    *value <<= 8;
    *value |= array[1];
    *value <<= 8;
    *value |= array[0];
}