Skip to content

Instantly share code, notes, and snippets.

View Oxore's full-sized avatar

Vladimir Novikov Oxore

  • Saint Petersburg, Russia
View GitHub Profile
@Oxore
Oxore / binsearch.c
Last active February 24, 2024 07:40
Binary search implemented in C99 with visualization
/* SPDX-License-Identifier: Unlicense */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define LEN 20
/*
stty -F /dev/ttyUSB0 38400 \
clocal cread cs8 cstopb -parenb -crtscts \
-ignbrk -brkint -parmrk -istrip -inlcr -igncr -icrnl -ixon \
-echo -echonl -icanon -isig -iexten \
-opost \
min 1 time 1
*/
#include <fcntl.h>
@Oxore
Oxore / xdg-open.sh
Last active September 24, 2023 17:46
xdg-open.sh
xdg-mime default feh.desktop image/webp
xdg-mime default feh.desktop image/jpeg
xdg-mime default feh.desktop image/png
xdg-mime default feh.desktop image/x-tga
xdg-mime default mupdf.desktop application/pdf
xdg-mime default mpv.desktop audio/ogg
xdg-mime default mpv.desktop audio/x-opus+ogg
@Oxore
Oxore / nnn_qna.md
Last active August 22, 2023 19:11
NNN file manager Q&A

My questions to NNN file manager, that arise as I use it.

Q: How to make "Filter" (invoked by /) do not automatically open unambiguous single item and allow further typing? Instead I want it to select item only by Enter.

A: Use nnn -A

Q: Usually I am able to open bookmarks (invoked by b) with "Filter" mode enabled automatically.

@Oxore
Oxore / blastem-pc-trace-on-277e4a62668597d4f59cadda1cbafb844f981d45.patch
Last active May 27, 2023 17:43
A patch for Blastem emulator to obtain all values that program counter had through the game that you were playing. Very handy for disassembling Sega Mega Drive / Genesis games. https://github.com/libretro/blastem, commit 277e4a62668597d4f59cadda1cbafb844f981d45.
diff --git a/bindings.c b/bindings.c
index 2921aa8..bdacf0e 100644
--- a/bindings.c
+++ b/bindings.c
@@ -292,6 +292,40 @@ https://github.com/libretro/blastem, commit 277e4a62668597d4f59cadda1cbafb844f981d45
return path;
}
+#define ROM_SIZE ((size_t)(4*1024*1024))
+static unsigned char pc_map[ROM_SIZE] = {0};
@Oxore
Oxore / picodrive-pc-trace-on-8cd962d14d7a866c69ebc82b9679a426c7709adb.patch
Last active May 27, 2023 17:44
A patch for Picodrive emulator to obtain all values that program counter had through the game that you were playing. Very handy for disassembling Sega Mega Drive / Genesis games. https://github.com/notaz/picodrive, commit 8cd962d14d7a866c69ebc82b9679a426c7709adb
diff --git a/cpu/fame/famec.c b/cpu/fame/famec.c
index 9e832bc4..f598797a 100644
--- a/cpu/fame/famec.c
+++ b/cpu/fame/famec.c
@@ -222,8 +222,11 @@ https://github.com/notaz/picodrive, commit 8cd962d14d7a866c69ebc82b9679a426c7709adb
#define ROR_32(A, C) (LSR_32(A, C) | LSL_32(A, 32-(C)))
#define ROR_33(A, C) (LSR_32(A, C) | LSL_32(A, 33-(C)))
+extern void trace_pc(unsigned);
+
@Oxore
Oxore / Readme.md
Last active July 12, 2023 15:56
C++17 в микроконтроллерах (в прошивках)

Причины использовать C++17 в разработке прошивок вместо более старых стандартов

  • std::string_view
  • std::optional<T>
  • std::variant
  • Починено некоторое странное поведение constexpr при использовании std::chrono (надо уточнить, а то я поздабыл)
  • Аттрибуты [[fallthrough]], [[nodiscard]] и [[maybe_unused]]
  • inline для constextpr объектов
  • "init-statement in selection statements". Например можно писать так:
@Oxore
Oxore / dune2u-pc-trace-reduced.txt
Last active March 9, 2024 15:30
sha1sum 0f7c1c130cb39abc97f57545933e1ef6c481783d dune2u.bin
512
2240
2430
6132
24722
25076
25080
25084
25092
25096
@Oxore
Oxore / firmware-project-structure.md
Created March 6, 2023 08:08
My idea of MCU firmware project structure

My idea of MCU firmware project structure

- app/
  - some_module/
  - another_module/
  - main.cpp
  - common.h
  - platform/
 - stm32f103-gcc-newlib/
#include <cstdio>
#include <cstdint>
#include <cassert>
template <typename T, T Min, T Len>
struct Range {
using Self = Range<T, Min, Len>;
constexpr Range(T offset, T length): offset(offset), length(length) {}
constexpr T Intersection(Self other) const { return Intersection(*this, other); }
constexpr static T Intersection(Self a, Self b)