How I Made A 6502 Processor Run in Minecraft
In the last video, I showcased a C++ application that shows a concept for a 6502 based microcontroller to be used in Minecraft. It is now time to bring it into the real deal by turning this into a Fabric mod!
I wasn't easy, especially with the decision of using C++ code alongside Java, yet it was worthwhile since this allows for better performance. Right? Let's find out!
Try this mod yourself! (Currently only works for x64 platforms)
CurseForge:
www.curseforge.com/minecraft/...
Modrinth:
modrinth.com/mod/cnmcu
Join our Discord!
/ discord
World download:
drive.google.com/file/d/11j1T...
Пікірлер: 173
top sentences you dont want to hear from programmer: 1) "It works on mine machine"
@elmfer
19 күн бұрын
Correct, I am no professional 🤣
@HyperDevv
15 күн бұрын
Its even worse when i have to make it work on a locked down school pc running on a server 💀
@elmfer
15 күн бұрын
@@HyperDevv Nahhhhh 🤣🤣🤣
Step 1: learn assembly
@codexed-i
19 күн бұрын
luckily 6502 assembly is easy compared to x86
@zackbuildit88
19 күн бұрын
Not just any assembly, an assembly language actually made to be used to write real code for real people to understand and use
@semydev
18 күн бұрын
@@zackbuildit88I don’t get your point
@TheRealMangoDev
18 күн бұрын
@@codexed-ii mean x86 isnt rly difficult either
@zackbuildit88
18 күн бұрын
@@semydev my point is really just that 6502 assembly isn't anything close to as bad as what most high level programmers mean when they joke about assembly being hard, it's honestly an easier language than most modern ones in my opinion
8:08 Ah yes, the classic "It works on my machine" moment 😂
Time to recreate old computers in minecraft
@elmfer
19 күн бұрын
Heck yeah!
@SadKris
19 күн бұрын
Still need a display block for it to work. Most old computers used the VGA protocol which allowed each pixel to be addressable in video memory. Wouldn't be too bad to implement since you just need to reserve a memory array to act as a VRAM for each instance of the display block, resized for whatever size monitor you make (preferably 2:1 ratio)
@elmfer
19 күн бұрын
@@SadKris For sure, a display could be placed next to a mcu and its vram can be mapped to the cpu's memory, pretty cool to have a display for machine 👍
@BastetFurry
16 күн бұрын
@@elmfer think simpler for a start, a display block that receives a UART signal and is essentially a terminal output. Bonus points for basic VT100 escape character support, but ADM3A would be sufficient enough, would even fit better with the 70s theme as that was the terminal of home users of the time. Then have a serial keyboard and you have your BASIC (heh) 70s home computer setup. For simplicity and QoL reasons have the keyboard check if there is a screen attached to the machine and have it display it as an UI element, much like CC and OC do. Add some sort of storage, could use either magnetic tape or even paper tape to stay with the theme, and you have your retro computing setup done. Could place some premade media in dungeon chests loot tables, like finding a BASIC or a FORTH tape. The Apple 1 wasn't much more by the way. A simple 6502 system, the lower half of the board, connected to a simple terminal controller, the upper half of the board, that could generate a composite signal. It even had just one control character, clear the screen. The boot monitor was a very simple affair that fit into 256 bytes, all it could do was show and manipulate memory and run something in memory. The tape reader module came with its own little ROM. And another thing you could look into, have compatibility with Project Red bundled cables, that way one can have up to 16 IO per side. And think about persistence if you haven't already, what happens when a CPU unloads, do you save its state and reload it on chunk load, what OC does, or do you issue a reset, what CC does. You could also make it load its own chunk, but that comes with its own sack of fleas, especially if the machine is used as a controller for some industrial installation. EDIT: Maybe an option for the future especially for modpacks, being able to disable the editor UI so that one would have to program these the old fashioned way. Write program on ingame development machine, burn to EPROM, add EPROM to MCU version, let it run. If it doesn't work, erase EPROM, fix bug, burn, insert, rinse, repeat. First you have to find a KERNEL EPROM for the computer tough... or toggle in your own boot ROM on a hand EPROMer 😁
Holy crap! This could mod bring a revolution to every kind of redstone contraption out there!
@angeldude101
19 күн бұрын
The main thing it adds over previous mods is the fact that it's based on a real ISA rather than using a lua interpreter. Otherwise I don't think it can do anything that those couldn't. Also, serious redstoners would _easily_ consider it cheating and would stick with vanilla, or _sometimes_ more limited redstone mods. It's great for learning about the 6502 and assembly though!
@fenix5fire
19 күн бұрын
@@angeldude101I suggest to check out mod Redstone Pen. It adds basically programmable comparator. Very far from assembly, but it can execute kinda complex instructions based on the given inputs. A cluster of these blocks may become an actual redstone CPU
@saiv46
17 күн бұрын
555 timer would be more useful for applicational redstone. This is for computional redstone only
@JanBebendorf
12 күн бұрын
@@angeldude101 Take a look at oc2, it's running on a RISC V emulator that has been written solely for this mod and is even able to boot linux
"AimGooey" Ah yes, i love AimGooey... my favorite GUI
@elmfer
17 күн бұрын
🤣🤣🤣
I have no more words then sick
Amazing work! Compressing complex redstone logic to a single block is quite something. I imagine people will be sharing code snippets to add to the controller and make all sorts of cool stuff. Subscribed!
I've no words, this looks amazing to start learning assembly
very cool project my friend, thx for the video
Wow! This is finally out? I have been waiting for it ever since the first concept video! Great work and I hope you keep developing it.
@elmfer
19 күн бұрын
Thanks, will do!
Holy shit. I was literally doing research on making this happen. Nice work!!!
very epic video i loved the animations
About time -this is awsome!
Amazing amount of work; keep up the good videos!
@elmfer
17 күн бұрын
Thanks, will do!
Went down 3 times to like the video forgetting I already did, Man you're crazy
Can already tell your gonna become famous bro keep going!
@elmfer
17 күн бұрын
I appreciate that!
Nice Projekt and congratulations that it works so well. I have 2 questions for you: 1. Did you know about the new java ffm/ffi that allows easier access to native functions? If so, why did you decide to use the "old" jni approach? 2. Why did you decide to use imgui instead of a minecraft native gui library?
@elmfer
8 күн бұрын
Thanks! I didn't know about about java's ffm 🤔, and JNI is something I am familiar with for the longest time. And I used ImGui because its design allows me to add UI elements without much effort, so this makes it easier to create intricate IDE for the mod.
My guy using a 6502 as an OR gate, thats absolutely hilarious Incredible work! although i wonder if it would be worth it to port the emulator over to java lol
I'm not sure how you're importing the imgui library exactly, but you should shadow them into a fatjar using a gradle plugin, that way multiple mods can use the same libraries, (mostly) without conflicts, even when using a different version compared to another mod! This works by moving all the library packages to a subpackage of your mod, you'll have seen this behaviour before if you've ever seen multiple instances of a class like "Gson" in the autocomplete list, because multiple libraries depend on it and shadow them separately.
@elmfer
19 күн бұрын
You are right! I did try use the shadow plugin, but the fat jar file it generates uses unobfuscated Minecraft code with it .This is not going to work outside of development environment, so I have to figure out on how to fix that
@blastygamez
19 күн бұрын
What happens when u rename the imgui lib to something like imguifor6502proc would the functions etc in it be only accessible from the package name like a namespace (Idk for sure because as u can see I am not sure how Java works) if so then why don’t u donthat insteaf
@feintha
19 күн бұрын
You would need to refactor the namespace @@blastygamez
@Juloass
13 күн бұрын
@@elmfer make the shadowing depends on reobf task, dont exaclty remember how to do this but i've done it before with other libs ^^
great video!
Interesting, I have long planned to create a Minecraft mod for something similar. However I want to run way more CPUs with high-bandwidth peripherals, and so I want to implement a network protocol to access such an emulator, and just implement a "client mod" for minecraft(-servers). You can distribute screen images etc. via a side-channel(not necessarily via the Minecraft protocol). This also would make it easy to change the emulated CPU architecture, and implement the client mod in a cross-platform way.
Nice work! thats it that i can say.. i'm confused about your things but nice edit and yeah... lol
damn i wanted to do that for a long time but u deserve the win
There was a 6502 emulator computer in Minecraft back in 1.2.5 in the Redpower 2 mod.
Awesome project! It does feel funny seeing imgui in minecraft lol
@elmfer
18 күн бұрын
Bro no joke! So out of place 🤣
@nolram
18 күн бұрын
Axiom actually does that too!
@elmfer
17 күн бұрын
@@nolram Just checked out axiom, it looks legit!
Awesome!!
This is super cool
My hardcore world is on Forge, using Minecraft 1.19.3. It's about 400 days old. And it also has the CC: Tweaked mod installed.
Thanks to the serial communication you can use 4 microcontrollers as three inputs each and use serial communication to talk to a 5th microcontroller. That way you have 12 GPIO instead of 4.
When you used imgui for displaying the colorful texts, what methods did you use to show the styled/colored text in the text editor field? Can't seem to find any way other than implementing that manually or writing JNI code for java to work with a library that does that in C
@elmfer
18 күн бұрын
The code editor can syntax highlight (color text) based on what language is selected, and it uses regex to find keywords and color them. Currently, C++ is selected, but obviously it doesn't work well with Assembly. I do have to create a custom syntax highlighter for it at some point
Incredible
We are so back
This is really cool, I personally like it more than computer craft computers that run lua because I found those to be a bit overpowered for minecraft, but this seems way more balanced. 👍
@elmfer
18 күн бұрын
Yeah honestly that is one of the outlooks of this mod!
Will you concider having more form of the mcus? Like a turtle with 1 to N cores for exemples? Especially the N core part to recreate parallelism using UART as cross MCU communication
@elmfer
19 күн бұрын
There will defiantly be more mcu variants! Also the multi-core idea is a very interesting challenge to implement 💡
I say it, this is the next gen mod for Minecraft
Congratulations! KZread actually managed to recommend this to someone who cares about this kind of stuff (me)!
ImGUI is actually in the Bedrock Developer versions by default.
amazing
Nice, we can create an Addressble led rgb (aka Neopixel) on Minecraft!
Cant you compile the emulator part of mod to WASM? There is GraalWASM project which allows embedding WASM code in Java applications.
@celdaemon
19 күн бұрын
might be possible, but you'd need to port imgui to wasm as well, because the native apis for creating the draw context and loading opengl functions are different, as well as compiling the native 6502 library to wasm as well.
@elmfer
19 күн бұрын
I didn't know you could run WASM in Java 🤔, luckily GitHub automatically compiles C++ code into many platforms for us so I think we're good
Ben eater plays Minecraft
I wonder if it would he possible to use cc95 to write c code and either transpile it to vasm or just load the bytes in directly. On another note, getting super mario bros sounds like something fun. Just ideas flowing from this mod!
@elmfer
13 күн бұрын
Members in our Discord are actually working on that! I believe there are already a few working examples on programming this MCU with C that you could try
@no-ld3hz
12 күн бұрын
@@elmfer ooh i might join soon™
do syscalls work?
next video: making a fully fledged flappy bird with 1 block
Next video: I programmed Rollercoaster Tycoon in Minecraft 😂
So... You made a mod for Minecraft JAVA, That uses C++ code IN the mod, AND uses C++ code on an emulated processor, While the emulated processor was originally an ASSEMBLY-BASIC only type deal... what
wait a minute. why didnt u use the in-built fabric screen system to create a minecraft looking gui for this?
@elmfer
18 күн бұрын
ImGui is super versatile, and it also has a code editor along with it so that I can focus on the main features of the mod
Next step is making a mod for making your own silicon wafers using photolitography for making asics
@elmfer
16 күн бұрын
Yeah that would be cool because the mod should be usable in survival mode aswell
To the Famicom/NES!
why not use the more modern 65c02? they support not only the legacy mos6502 instruction set but can use newer instructions such as: "stz" (stores $00 at an address) or "bra" (similar to "jmp" but uses 1 less byte, also faster)
@elmfer
13 күн бұрын
Those are valid points! From the start of the project, I had an outlook for the microcontrollers to use the original 6502 because of its cool history with 80s computers. Nevertheless, this could be an idea for creating a new MCU variant
i know that that computer i think so is not compatible but pls make wireless connection between them
4:30 you could make 3 different downloads for each type
@elmfer
18 күн бұрын
The goal is to have one jar file for the mod, and then it downloads all of its dependencies automatically depending on what platform you are using
next step is to make a Zachtronics game inspired map
@Shywizz
17 күн бұрын
there's TIS-3D which is a port of Zach's TIS game
Can it run doom?
So now we can have a working C64 in Minecraft?
you could use an installer
Noice
2:46 what is the background img?
@elmfer
12 күн бұрын
From ths video: kzread.info/dash/bejne/kWmep66lpMnPabg.html
@noobnuby
12 күн бұрын
@elmfer thank you! Have a nice day 😊
Not trying to be rude, it's cool actually but many here don't seem to be aware that something like this, with even FORTH as the language has been made ALL the way back as to 2012, 1.2.5. The mod Redpower 2 actually brought that in place, it was a miracle it ran so good and because the code was Closed nobody knew how it ran that good either.
@elmfer
16 күн бұрын
Gotcha, there is also a mod called Microprocessors that does this as well (with a custom 8-bit processor), but I still made this project because it's fun to make and wanted to apply what I learned from the 6502
@hariranormal5584
16 күн бұрын
@@elmfer That's still pretty cool. Nice to always implement your own ways and you anyways learn and get experience. I didn't mean to sound of as rude even though I re read and it sounds like it..I'm a IT like guy who absolutely is very poor at coding. I just can't and absolutely suck at it. So good job regardless :)
Are u gonna port it to Bedrock/pe?
@elmfer
16 күн бұрын
Not anytime soon I'm afraid 😬
You missed the opportunity to make a DCPU-16 emulator instead of a 6502. DCPU-16 is the Notch's "CPU" for 0x10c.
See pluh pluh
Make a LCD for minecraft so i can run games i make
@elmfer
18 күн бұрын
Will do soon!
Це дуже круто!
@elmfer
18 күн бұрын
Дякую тобі!
You r a fucking genius By the way, can u write in the description links, which you read, to work in C++? ( I'm good in C, but not in Java, so) ) Ty in advance
@elmfer
17 күн бұрын
For sure, are you referring to the resources I used for JNI or for using C++?
@dmitry_mandi
17 күн бұрын
@@elmfer Umm, maybe both?😅 Just, u know Im unsucc mod developer in java. U know I love to learn programm languages, but java is my weak point. You showed that is possible to normally write mods in C++, so I interested in
yo what linux do you use?
@elmfer
15 күн бұрын
Linux mint
@aleksandersobczak8398
15 күн бұрын
and what about the thing you program in visual studio or what
@aleksandersobczak8398
15 күн бұрын
@@elmfer because I wanna start programming in mc
@aleksandersobczak8398
15 күн бұрын
and also how to test it
@elmfer
15 күн бұрын
@@aleksandersobczak8398 I used eclipse for programming in java (and run MC in mod development environment) and I use vscode to program in C++
Can't wait for the CVE to release for this mod 😅 (I'm joking..)
How do I obtain it?
@elmfer
18 күн бұрын
It is available on modrinth: modrinth.com/mod/cnmcu
@GamingEpic71
18 күн бұрын
@@elmfer I meant to say how do I get the item in the mod
@elmfer
18 күн бұрын
@@GamingEpic71 The only way to obtain it currently is by using the give command /give you cnmcu:nano
next video: "...i coded a game engine in minecraft to code minecraft in game engine in minecraft..."
Bruh, I was working on a 6502 too
run Doom on it lol
@elmfer
19 күн бұрын
Once displays are added, nothing is stopping us!
wait... how to use it ?
@elmfer
16 күн бұрын
Once you have installed the mod, the docs has a Getting Started page that will help you out: elmfrain.github.io/code-node-docs/getting-started
Here before 100k views
ASM means C C means stupid other stuff that means Python, that means easy programming that means idk but probaply Python on minecraft
I would like to play this mod, but it is a fabric mod, so i can't run it with forge, the only trustable ModLoader.
@elmfer
18 күн бұрын
I do plan to make a poll to see if others will be interested for this mod to be ported to Forge. Although it will be kinda hard to maintain both versions at the same time, so I honestly don't think this will be happening any time soon
@Hellscaped
17 күн бұрын
why? forge is the least trustworthy modloader at this point in time
huh.
you read GUI wrong
@elmfer
16 күн бұрын
I'm "gooey"
PLEASE PORT TO FORGE. (If possible)
@Larandar
19 күн бұрын
Why tho? Forge is dead, NeoForge is new Forge... IMO until NeoForge is more in-sync with with Fabric things will be even more fragmented, while Fabric just work
@elmfer
19 күн бұрын
I will put a poll at some point because I know there are Forge only mods that could work very well with this mod, but it is going to be hard to maintain both Fabric and Forge at the same time
@drewhailstones4106
19 күн бұрын
@@Larandar Not in my opinion. But if you think so then good for you.
noooooooooo my video idea (probably wouldn't have had the skills to do it anyway)
@SashaL_music
19 күн бұрын
my bad it wasn't fully redstone
@elmfer
19 күн бұрын
Nah don't you worry bro! You got this!
some1 tell him about computercraft
@elmfer
17 күн бұрын
About what?
ok commodore 64 emulator for minecraft
???? Having two mods that have the same library in them does nothing, fabric just loads the first one that was loaded and ignores the other one. Please do research before claiming things like this.
@elmfer
17 күн бұрын
Might of been my mistake, are there any sources that cites this?
@bluetintedchromee3881
17 күн бұрын
@@elmfer 1. Erm actually it's "might have" 🤓☝️ 2. I have tested this myself, you can test it yourself to confirm it's true
basic OS development be like:
support python for funzies
if ur using imgui in JNI… well lets just say… ur ignoring macos
@elmfer
18 күн бұрын
No need to worry, if Java works, then JNI will work aswell as long as you have the binaries targeted for that platform
nerd
@zackbuildit88
19 күн бұрын
nerd! ❤ :3
@elmfer
19 күн бұрын
Ackchyually ☝️🤓
1171
@elmfer
16 күн бұрын
1171?
Im getting an error when i try to load into minecraft saying the .jar file is an invalid mod
@elmfer
18 күн бұрын
This is a Fabric mod, if you are using Forge, it will not work
@skypetical5763
18 күн бұрын
@@elmfer didn't see that on the page, thanks