Mercurial > hg > sidinfo
comparison sidlib.c @ 162:7359170fbb7f
Clarify some comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 16 Feb 2018 21:24:28 +0200 |
parents | 27365eae837b |
children | 179ffe97599c |
comparison
equal
deleted
inserted
replaced
161:58fe784a6e48 | 162:7359170fbb7f |
---|---|
137 do | 137 do |
138 { | 138 { |
139 read = thfread(data, sizeof(uint8_t), PSID_BUFFER_SIZE, ctx); | 139 read = thfread(data, sizeof(uint8_t), PSID_BUFFER_SIZE, ctx); |
140 psid->dataSize += read; | 140 psid->dataSize += read; |
141 | 141 |
142 // If load address is 0 in header and we have the first block, grab it | |
142 if (first && psid->loadAddress == 0) | 143 if (first && psid->loadAddress == 0) |
143 { | 144 { |
144 if (read < 4) | 145 if (read < 4) |
145 { | 146 { |
146 th_io_error(ctx, THERR_FREAD, | 147 th_io_error(ctx, THERR_FREAD, |
147 "Error reading song data, unexpectedly small file.\n"); | 148 "Error reading song data, unexpectedly small file.\n"); |
148 goto error; | 149 goto error; |
149 } | 150 } |
150 | 151 |
151 // Grab the actual load address | 152 // Grab the load address |
152 psid->loadAddress = TH_LE16_TO_NATIVE(*(uint16_t *) data); | 153 psid->loadAddress = TH_LE16_TO_NATIVE(*(uint16_t *) data); |
153 | 154 |
154 // Strip load address (2 first bytes) | 155 // .. do not include the load address to the hash |
155 th_md5_append(&state, &data[2], read - 2); | 156 th_md5_append(&state, &data[2], read - 2); |
156 first = FALSE; | 157 first = FALSE; |
157 } | 158 } |
158 else | 159 else |
159 if (read > 0) | 160 if (read > 0) |
160 { | 161 { |
161 // Append "as is" | 162 // Append data "as is" |
162 th_md5_append(&state, data, read); | 163 th_md5_append(&state, data, read); |
163 } | 164 } |
164 } while (read > 0 && !thfeof(ctx)); | 165 } while (read > 0 && !thfeof(ctx)); |
165 | 166 |
166 // Append header data to hash | 167 // Append header data to hash |