| 1 | /* Code from Exomizer distributed under the zlib License |
| 2 | * by kind permission of the original author |
| 3 | * Magnus Lind. |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2002 - 2023 Magnus Lind. |
| 8 | * |
| 9 | * |
| 10 | * This software is provided 'as-is', without any express or implied |
| 11 | * warranty. In no event will the authors be held liable for any damages |
| 12 | * arising from the use of this software. |
| 13 | * |
| 14 | * Permission is granted to anyone to use this software for any purpose, |
| 15 | * including commercial applications, and to alter it and redistribute it |
| 16 | * freely, subject to the following restrictions: |
| 17 | * |
| 18 | * 1. The origin of this software must not be misrepresented; you must not |
| 19 | * claim that you wrote the original software. If you use this software |
| 20 | * in a product, an acknowledgment in the product documentation would be |
| 21 | * appreciated but is not required. |
| 22 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 23 | * misrepresented as being the original software. |
| 24 | * 3. This notice may not be removed or altered from any source distribution. |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | C++ version based on code adapted to ScummVM by Avijeet Maurya |
| 30 | */ |
| 31 | |
| 32 | #ifndef UNP64_EXO_UTIL_H |
| 33 | #define UNP64_EXO_UTIL_H |
| 34 | |
| 35 | #include "types.h" |
| 36 | |
| 37 | namespace Unp64 { |
| 38 | |
| 39 | struct LoadInfo { |
| 40 | int _basicTxtStart; /* in */ |
| 41 | int _basicVarStart; /* out */ |
| 42 | int _run; /* out */ |
| 43 | int _start; /* out */ |
| 44 | int _end; /* out */ |
| 45 | }; |
| 46 | |
| 47 | int findSys(const uint8_t *buf, int target); |
| 48 | |
| 49 | void loadData(uint8_t *data, size_t dataLength, uint8_t mem[65536], LoadInfo *info); |
| 50 | |
| 51 | int strToInt(const char *str, int *value); |
| 52 | |
| 53 | bool u32eq(const unsigned char *addr, uint32_t val); |
| 54 | bool u16eq(const unsigned char *addr, uint16_t val); |
| 55 | bool u16gteq(const unsigned char *addr, uint16_t val); |
| 56 | bool u16lteq(const unsigned char *addr, uint16_t val); |
| 57 | bool u32eqmasked(const unsigned char *addr, uint32_t mask, uint32_t val); |
| 58 | bool u32eqxored(const unsigned char *addr, uint32_t ormask, uint32_t val); |
| 59 | bool u16eqmasked(const unsigned char *addr, uint16_t mask, uint16_t val); |
| 60 | |
| 61 | } // End of namespace Unp64 |
| 62 | |
| 63 | #endif |