JNI (Java Native Interface) allows implementing methods in C/C++, and use them in Java.
class JNIExample {
// Native method, no body.| #include <unistd.h> | |
| #include <string> | |
| #include <cinttypes> | |
| #include <android/log.h> | |
| #include <sys/system_properties.h> | |
| using namespace std; | |
| extern "C" { |
| .segment "HEADER" | |
| .byte "NES", $1A ; Constant | |
| .byte 2 ; 2 x 16KB PRG ROM | |
| .byte 1 ; 1 x 8KB CHR ROM | |
| .segment "CHARS" | |
| ;------------------------------------------------------------- | |
| ; CREATE SPRITES | |
| ;------------------------------------------------------------- | |
| ; The following creates one sprite. The following two bitmaps |
| ; ___ _ __ ___ __ ___ | |
| ; / __|_ _ __ _| |_____ / /| __|/ \_ ) | |
| ; \__ \ ' \/ _` | / / -_) _ \__ \ () / / | |
| ; |___/_||_\__,_|_\_\___\___/___/\__/___| | |
| ; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial | |
| ; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself | |
| ; to learn a little bit about assembly. I **think** I understood everything, but I may | |
| ; also be completely wrong :-) |
| /** | |
| * Educational "Free-list" memory allocator. | |
| * | |
| * Maintains explicit list of free memory blocks, reuses blocks on free. | |
| * Implements "first-fit" strategy. Uses pre-allocated heap of 64 bytes, | |
| * with 32-bit machine word size. | |
| * | |
| * TODO: | |
| * | |
| * - Implement "best-fit" strategy |
| /** | |
| * Writing a Mark-Sweep Garbage Collector in C++. | |
| * | |
| * This is a source code for the Lecture 9 from the | |
| * Essentials of Garbage Collectors course: | |
| * | |
| * http://dmitrysoshnikov.com/courses/essentials-of-garbage-collectors/ | |
| * | |
| * See full details in: | |
| * |
| let offset = 20000; | |
| let chunk_size = 10000; | |
| // File handle: | |
| let mut handle = BufReader::new(File::open("data.bin").await?); | |
| // Set cursor to needed chunk: | |
| let mut chunk_stream = handle | |
| .bytes() | |
| .skip(offset) |
| /** | |
| * Basic Array class, similar to std::array. | |
| * | |
| * by Dmitry Soshnikov <[email protected]> | |
| * MIT Style License (C) 2020 | |
| */ | |
| #ifndef __Array_h | |
| #define __Array_h |
| /* | |
| * Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved. | |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| * | |
| * This code is free software; you can redistribute it and/or modify it | |
| * under the terms of the GNU General Public License version 2 only, as | |
| * published by the Free Software Foundation. Oracle designates this | |
| * particular file as subject to the "Classpath" exception as provided | |
| * by Oracle in the LICENSE file that accompanied this code. | |
| * |