diff --git a/SniffEmu/.editorconfig b/SniffEmu/.editorconfig new file mode 100755 index 0000000..42ece7c --- /dev/null +++ b/SniffEmu/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf + +[{Makefile}] +indent_style = tab +tab_size = 4 + +[{*.c,*.h}] +indent_style = space +tab_size = 4 diff --git a/SniffEmu/.gitignore b/SniffEmu/.gitignore new file mode 100755 index 0000000..8eccdb4 --- /dev/null +++ b/SniffEmu/.gitignore @@ -0,0 +1,4 @@ +_UAEFSDB.___ +dist/*.lha +SniffEmu/Source/*.asm +SniffEmu/Source/*.o diff --git a/SniffEmu/LICENSE b/SniffEmu/LICENSE new file mode 100644 index 0000000..3fa3d9a --- /dev/null +++ b/SniffEmu/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2023-present BTHLabs (https://bthlabs.pl) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/SniffEmu/README.md b/SniffEmu/README.md new file mode 100644 index 0000000..636a0af --- /dev/null +++ b/SniffEmu/README.md @@ -0,0 +1,65 @@ +# SniffEmu + +CLI tool to "detect" if the system is running in emulator + +## Description + +SniffEmu is a small CLI tool to "detect" if the system is running in +emulation-like environment, e.g. UAE. I use it to conditionally execute parts +of Startup-Sequence, e.g. to can skip FBlit when the OS is booting on PiStorm. + +Usage: SniffEmu HELP/S RTG/S MODE + +`MODE` is one of `EMU68`, `UAE` or `MUSASHI`. `RTG/S` allows you to +specifically look for the emulator's RTG card, so you can e.g. set up the +proper screen mode. + +Example: + +``` +> SniffEmu EMU68 +SniffEmu: Looking for board: 28019:-1... NOT FOUND +``` + +``` +> SniffEmu RTG UAE +SniffEmu: Looking for board: 2011:96... FOUND +``` + +If the emulator (or RTG) was detected, the program will set the returncode to +`WARN`. Otherwise, it'll be `OK`. + +Example script: + +``` +C:SniffEmu RTG UAE >NIL: +If WARN + Echo "Found UAE RTG!" +EndIf +``` + +Note: MUSASHI support is currently untested. If anybody uses it, let me know +about the results ;). + +## Requirements + +AmigaOS 3.1+, MC68020+ + +## Changelog + +Version 1.0.0 (16.02.2023) + + * Initial release. + +## Contributing + +If you think you found a bug or want to send a patch, feel free to contact +me through e-mail. + +## Author + +ScreenSaver is developed by [Tomek WĆ³jcik](https://www.bthlabs.pl/). + +## License + +ScreenSaver is licensed under the MIT License. diff --git a/SniffEmu/SniffEmu.info b/SniffEmu/SniffEmu.info new file mode 100644 index 0000000..f9e96d4 Binary files /dev/null and b/SniffEmu/SniffEmu.info differ diff --git a/SniffEmu/SniffEmu/Readme b/SniffEmu/SniffEmu/Readme new file mode 100755 index 0000000..6898bcd --- /dev/null +++ b/SniffEmu/SniffEmu/Readme @@ -0,0 +1,44 @@ +SniffEmu by BTHLabs + +SniffEmu is a small CLI tool to "detect" if the system is running in +emulation-like environment, e.g. UAE. I use it to conditionally execute parts +of Startup-Sequence, e.g. to can skip FBlit when the OS is booting on PiStorm. + +Usage: SniffEmu HELP/S RTG/S MODE + +MODE is one of EMU68, UAE or MUSASHI. RTG/S allows you to specifically look +for the emulator's RTG card, so you can e.g. set up the proper screen mode. + +Example: + +> SniffEmu EMU68 +SniffEmu: Looking for board: 28019:-1... NOT FOUND + +> SniffEmu RTG UAE +SniffEmu: Looking for board: 2011:96... FOUND + +If the emulator (or RTG) was detected, the program will set the returncode to +WARN. Otherwise, it'll be OK. + +Example script: + +C:SniffEmu RTG UAE >NIL: +If WARN + Echo "Found UAE RTG!" +EndIf + +Note: MUSASHI support is currently untested. If anybody uses it, let me know +about the results ;). + +Requirements: AmigaOS 3.1+, MC68020+ + +SniffEmu is developed by Tomek Wójcik + +SniffEmu is licensed under the MIT License. + +Changelog +--------- + +Version 1.0.0 (16.02.2023) + + * Initial release. diff --git a/SniffEmu/SniffEmu/Readme.info b/SniffEmu/SniffEmu/Readme.info new file mode 100644 index 0000000..96c682b Binary files /dev/null and b/SniffEmu/SniffEmu/Readme.info differ diff --git a/SniffEmu/SniffEmu/SniffEmu b/SniffEmu/SniffEmu/SniffEmu new file mode 100755 index 0000000..983572f Binary files /dev/null and b/SniffEmu/SniffEmu/SniffEmu differ diff --git a/SniffEmu/SniffEmu/Source.info b/SniffEmu/SniffEmu/Source.info new file mode 100644 index 0000000..00870c5 Binary files /dev/null and b/SniffEmu/SniffEmu/Source.info differ diff --git a/SniffEmu/SniffEmu/Source/Makefile b/SniffEmu/SniffEmu/Source/Makefile new file mode 100755 index 0000000..44a1f64 --- /dev/null +++ b/SniffEmu/SniffEmu/Source/Makefile @@ -0,0 +1,18 @@ +DEVPACK := DEVPACK: +VBCC := $(DEVPACK)VBCC + +CC := $(VBCC)/bin/vc + +OUTFILE := /SniffEmu + +OBJECTS := SniffEmu.o +CFLAGS := -I$(DEVPACK)ADE/os-include +LIBS := -lamiga + +all: $(OUTFILE) + +clean: + Delete ALL FORCE $(OUTFILE) $(OBJECTS) + +$(OUTFILE): $(OBJECTS) + $(CC) $(LIBS) -o $(OUTFILE) $(OBJECTS) diff --git a/SniffEmu/SniffEmu/Source/SniffEmu.c b/SniffEmu/SniffEmu/Source/SniffEmu.c new file mode 100755 index 0000000..bb449f9 --- /dev/null +++ b/SniffEmu/SniffEmu/Source/SniffEmu.c @@ -0,0 +1,164 @@ +/* + * SniffEmu by BTHLabs + * Copyright (c) 2023-present BTHLabs (https://bthlabs.pl) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include +#include +#include +#include +#include + +#include "SniffEmu.h" + +struct ExpansionBase * ExpansionBase; + +static STRPTR verstring = APP_VSTRING; + +static char *MODE_NAME_EMU68 = "EMU68"; +static char *MODE_NAME_UAE = "UAE"; +static char *MODE_NAME_MUSASHI = "MUSASHI"; + +#define TEMPLATE "HELP/S,RTG/S,MODE" + +typedef enum { + OPT_HELP, + OPT_RTG, + OPT_MODE, + OPT_COUNT +} OPT_ARGS; + +typedef enum { + MODE_UNKNOWN, + MODE_EMU68, + MODE_UAE, + MODE_MUSASHI +} MODE; + +int help() { + printf( + "SniffEmu %s by BTHLabs\n" + "Developed by Tomek Wójcik\n" + "bthlabs.pl | MIT License\n", + VERSION + ); + + printf( + "\n" + "Usage: SniffEmu HELP/S RTG/S MODE\n" + "\n" + "HELP : Print this help\n" + "RTG : Sniff the RTG board\n" + "MODE : Specify the emulator to sniff\n" + " Valid values: EMU68, UAE, MUSASHI\n" + ); + + return RETURN_OK; +} + +int find_board(int manufacturer, int product) { + int result = RETURN_OK; + + printf("SniffEmu: Looking for board: %d:%d... ", manufacturer, product); + + if (ExpansionBase = (struct ExpansionBase *)OpenLibrary(EXPANSIONNAME, 0L)) { + struct ConfigDev* cd = NULL; + + while (cd = FindConfigDev(cd, manufacturer, product)) { + result = RETURN_WARN; + } + } + + if (result == RETURN_WARN) { + printf("FOUND\n"); + } else { + printf("NOT FOUND\n"); + } + + return result; +} + +int main(int argc, char *argv[]) { + int result = RETURN_OK; + int opts[OPT_COUNT]; + struct RDArgs *rdargs; + int manufacturer = -1; + int product = -1; + + if (argc > 1) { + memset((char *)opts, 0, sizeof(opts)); + + if (rdargs = (struct RDArgs *)ReadArgs(TEMPLATE, opts, NULL)) { + if (opts[OPT_HELP]) { + result = help(); + } else { + MODE mode = MODE_UNKNOWN; + + if (strcmp((STRPTR)opts[OPT_MODE], MODE_NAME_EMU68) == 0) { + mode = MODE_EMU68; + } else if (strcmp((STRPTR)opts[OPT_MODE], MODE_NAME_UAE) == 0) { + mode = MODE_UAE; + } else if (strcmp((STRPTR)opts[OPT_MODE], MODE_NAME_MUSASHI) == 0) { + /* MUSASHI mode is untested. */ + mode = MODE_MUSASHI; + } else { + printf("SniffEmu: Invalid MODE: `%s`\n", opts[OPT_MODE]); + result = help(); + } + + if (mode != MODE_UNKNOWN) { + if (mode == MODE_EMU68) { + manufacturer = EMU68_MANUFACTURER; + } else if (mode == MODE_UAE) { + manufacturer = UAE_MANUFACTURER; + } else if (mode == MODE_MUSASHI) { + manufacturer = MUSASHI_MANUFACTURER; + product = MUSASHI_INTERACTION; + } + + if (opts[OPT_RTG]) { + if (mode == MODE_EMU68) { + product = EMU68_RTG; + } else if (mode == MODE_UAE) { + product = UAE_RTG; + } else if (mode == MODE_MUSASHI) { + printf("SniffEmu: Can't reliably sniff RTG on Musashi :(\n"); + product = MUSASHI_RTG; + } + } + + result = find_board(manufacturer, product); + } + } + + FreeArgs(rdargs); + } else { + printf("SniffEmu: Invalid arguments.\n"); + result = help(); + } + } else { + result = help(); + } + + return result; +} diff --git a/SniffEmu/SniffEmu/Source/SniffEmu.h b/SniffEmu/SniffEmu/Source/SniffEmu.h new file mode 100755 index 0000000..9015fc8 --- /dev/null +++ b/SniffEmu/SniffEmu/Source/SniffEmu.h @@ -0,0 +1,17 @@ +#ifndef __SNIFFEMU_H__ +#define __SNIFFEMU_H__ + +#define VERSION "1.0.0" +#define DATE "16.02.2023" + +#define APP_VSTRING "$VER: SniffEmu " VERSION " (" DATE ")" + +#define EMU68_MANUFACTURER (0x6d73) +#define EMU68_RTG (0x24) +#define UAE_MANUFACTURER (0x7db) +#define UAE_RTG (0x60) +#define MUSASHI_MANUFACTURER (0x7db) +#define MUSASHI_INTERACTION (0x6b) +#define MUSASHI_RTG (0x6b) + +#endif diff --git a/SniffEmu/dist/SniffEmu.readme b/SniffEmu/dist/SniffEmu.readme new file mode 100644 index 0000000..08d6b71 --- /dev/null +++ b/SniffEmu/dist/SniffEmu.readme @@ -0,0 +1,52 @@ +Short: CLI tool to "detect" if the system is running in emulator +Author: Tomek Wójcik +Uploader: Tomek Wójcik +Type: util/sys +Version: 1.0.0 +Architecture: m68k-amigaos +Requires: AmigaOS 3.1+, MC68020+ + +SniffEmu by BTHLabs + +SniffEmu is a small CLI tool to "detect" if the system is running in +emulation-like environment, e.g. UAE. I use it to conditionally execute parts +of Startup-Sequence, e.g. to can skip FBlit when the OS is booting on PiStorm. + +Usage: SniffEmu HELP/S RTG/S MODE + +MODE is one of EMU68, UAE or MUSASHI. RTG/S allows you to specifically look +for the emulator's RTG card, so you can e.g. set up the proper screen mode. + +Example: + +> SniffEmu EMU68 +SniffEmu: Looking for board: 28019:-1... NOT FOUND + +> SniffEmu RTG UAE +SniffEmu: Looking for board: 2011:96... FOUND + +If the emulator (or RTG) was detected, the program will set the returncode to +WARN. Otherwise, it'll be OK. + +Example script: + +C:SniffEmu RTG UAE >NIL: +If WARN + Echo "Found UAE RTG!" +EndIf + +Note: MUSASHI support is currently untested. If anybody uses it, let me know +about the results ;). + +Requirements: AmigaOS 3.1+, MC68020+ + +SniffEmu is developed by Tomek Wójcik + +SniffEmu is licensed under the MIT License. + +Changelog +--------- + +Version 1.0.0 (16.02.2023) + + * Initial release.