3 * coded by Ketmar // Invisible Vector
4 * Understanding is not required. Only obedience.
6 * This program is free software. It comes without any warranty, to
7 * the extent permitted by applicable law. You can redistribute it
8 * and/or modify it under the terms of the Do What The Fuck You Want
9 * To Public License, Version 2, as published by Sam Hocevar. See
10 * http://sam.zoy.org/wtfpl/COPYING for more details.
12 #ifndef LIBFDC_DSKLDR_INTERNAL_COMMON_H
13 #define LIBFDC_DSKLDR_INTERNAL_COMMON_H
16 //==========================================================================
20 //==========================================================================
21 static LIBFDC_MAYBE_UNUSED LIBFDC_INLINE
void writeui16 (uint8_t *d
, uint16_t v
) {
27 //==========================================================================
31 //==========================================================================
32 static LIBFDC_MAYBE_UNUSED LIBFDC_INLINE
void writeui32 (uint8_t *d
, uint32_t v
) {
35 d
[2] = ((v
>>16)&0xff);
36 d
[3] = ((v
>>24)&0xff);
40 //==========================================================================
44 //==========================================================================
45 static LIBFDC_MAYBE_UNUSED LIBFDC_INLINE
uint16_t getui16 (const void *buf
) {
46 return ((((const uint8_t *)buf
)[1])<<8)|(((const uint8_t *)buf
)[0]);
50 //==========================================================================
54 //==========================================================================
55 static LIBFDC_MAYBE_UNUSED
int freaduint (FILE *fl
, uint32_t *valp
, int n
) {
61 if (fread(&b
, 1, 1, fl
) != 1) return FLPERR_SHIT
;
62 val
|= ((uint32_t)b
)<<shift
;
70 //==========================================================================
74 //==========================================================================
75 static LIBFDC_MAYBE_UNUSED
int fwriteuint (FILE *fl
, uint32_t val
, int n
) {
77 uint8_t b
= (val
&0xff);
78 if (fwrite(&b
, 1, 1, fl
) != 1) return FLPERR_SHIT
;