I’m spearheading an emulator initiative to bring good VB emulation to 3DS and a good reverse engineering and TAS application to desktop.
This is a work post.
I am having a blast. At first, the plan was to take the existing Java code and move it over into a new project, passing it through a mental filter to make sure everything is looking good. But then I started optimizing and refactoring and improving and… Well, the scope grew a bit larger than what I intended for the week.
Instead, I’m gonna add one more week for the same basic goals from last week. This isn’t the same as a missed deadline: what I’m doing is absolutely productive and under control. It’s just more in-depth than I originally thought I was going to do. But it’s all for the better.
As for what I’ve been up to…
• New Java base – I started a brand-new Java project from scratch, with the intention of reviewing the old files as I moved them over. I ended up doing it all again from the ground up. Once the improvements started becoming apparent, it suddenly became a lot of fun and I kept going with it. The new code is as good as it’s ever been.
• Emulation core – The Java application communicates with an emulation core context that this time is implemented as an interface rather than an abstract class. There’s a static factory method that will produce a valid emulation state for the application to work with. For now, it’s only backed by the generic Java implementation of the emulation core, but the final product will also have native modules on supported systems.
• Bus and CPU access – The emulation context interface supplies methods for accessing data from the simulated Virtual Boy state. You can read and write CPU registers as well as memory from the bus in any applicable format. Internal memory buffers and component functionality are automatically routed trough a simple mapping routine that ties the whole thing together.
• Debug accesses – The application is allowed to do things that the emulated program is not, and these are handled through special debug accesses. Any reads or writes that would have no effect on the hardware can have an effect when used in a debugging context. For example: storing new values in ECR, writing to ROM, and reading from the VSU are all possible as debug accesses.
• New disassembly – While implementing a new instruction decoder, I took a minimalist approach and used a simple, generic field for instruction operands. This necessitated gutting and rebuilding the disassembler class, which also saw the benefits of knowing what-all needed to get done. The implementations of both classes are far leaner and more concise than ever before, and I’m very pleased with it.
Going forward, I’m going to start up a new GUI project to get the Debugger and Memory windows up and running again. From the user’s perspective, it should look more or less like it did before, but the improvements on the back-end will make it so much more convenient and efficient as additional features are implemented.
Attachments:
Splatoon 2 updates are traditionally dropped on Fridays, and the big honkin’ version 3.0.0 was announced for April. Since there was only one Friday left in April (today), I was thinking I could get my emulator stuff done by the end of the week, then do some Splatoon 2 stuff over the weekend.
But then they pushed the update on Tuesday night.
I’m one of the principal content managers at Inkipedia, the resident Splatoon wiki, and I had to shift my priorities a bit during the week to make sure everything got done properly. Website traffic jumped from around 7,000 visitors to 12,000 on Wednesday, and that’s a lot of people wanting to learn about new game features. In particular, I’m the one with all the fancy programs and tools to collect and process game information, so my attention was in high demand. (-:
For more information on the update, check out the Version 3.0.0 page.
Basically what this means is my weekend got pushed up three days. Instead, I’ll work through the weekend on the emulator thing and post my status on Sunday.
This is a work post.
Welcome to Guy Perfect Hour, where Guy Perfect talks to himself! Today on Guy Perfect Hour, we’re going to begin proper development on the emulator’s code base using the document we prepared earlier.
To Do – Week of April 23, 2018
This week’s goal is to start from scratch and produce the program code necessary to get back to where the most recent emulator build is. Why do that? Starting things from scratch multiple times helps me hone in on the best way to do it, and last time I did this I felt pretty good about how it went together.
• Establish an infrastructure for the Java emulation core.
Yes, the 3DS thing will be running on the C emulation core, but I’m going to focus on the Java code first. The reason for this is because it’s easier to develop/test and if the module’s structure needs to be changed, it’s easier to do that to only one module than two parallel modules.
Once the emulation implementation is up and running in Java, it will be a rather short task to move it over to C. Then the fun begins.
• Implement CPU operations.
All CPU operations except the instruction cache and floating-point instructions are targeted for this week. The instruction cache doesn’t affect a program’s execution, and I’m not aware of any commercial games that use floating-point instructions, so this should be sufficient to get existing software simulated.
The CPU accounts for something like 60%-70% of the entire emulation core.
• Implement disassembler, register list and memory controls for the GUI.
The GUI controls are all linked into the same debugger context, even if they’re not presented in the same window. Redoing them from scratch using what I learned before will make better versions of everything.
One day I wish to do electronics. Skills like this seem to be extremely useful.
This is a work post.
We have results!
You may recall that I mentioned having a draft of v1.0 of the Sacred Tech Scroll in the works, but I discarded it and started a brand-new document instead. And that new document is already 8000 words long! I intended to have it in its current state yesterday, but the new content and formatting took a bit longer than I expected.
The current, work-in-progress draft of the new Tech Scroll can be found here:
http://perfectkiosk.net/stsvb1.html
It currently contains most of the CPU documentation. A few editor’s notes are strewn here and there for things that need additional research, and the instruction cache isn’t documented at all. But otherwise, I believe the rest is in there. There aren’t very many blanks left to fill in: CPU Workshop was an invaluable tool for getting lots of tricky things figured out.
Quite a bit has changed from the original Sacred Tech Scroll document, not the least of which involves innumerable corrections. I encourage you to take a look and let me know what you think.
This is enough to get started designing and implementing a formal emulation core. I realize a big wordy document isn’t as fun as a flashy emulator, but I trust you can appreciate just how much of a benefit it is to have this available.
HorvatM wrote:
Interesting! Did you test all 2^32 values?
I did not, but I checked enough test cases to be confident that its operation is what it appears to be.
If you want to write up a program to test every value, I’d be happy to run it on the hardware. For science.
Yay, the site’s back. I have one more section to prepare in the first batch of content for the new tech scroll document, and I’ll have that ready for presentation sometime tomorrow.
StinkerB06 wrote:
Now do VIP Workshop.
I can’t promise this one’s gonna happen. The VIP has enough moving parts that I expect it’s more likely to make test programs for individual features rather than one giant program encompassing everything.
You should be able to specify the register with the number 31, rather than the symbol “sr31”.
This is a work post.
Attached to this post is a preliminary CPU Workshop ROM that has been tested on the hardware. It provides binary-level control over the instructions being tested and accounts for most scenarios regarding CPU behavior. A few things to keep in mind:
• Instructions that disrupt program flow will be ignored when attempting to test them. These include [font=Courier New]JAL[/font], [font=Courier New]JMP[/font], [font=Courier New]JR[/font], [font=Courier New]RETI[/font], [font=Courier New]SEI[/font] and any form of [font=Courier New]Bcond[/font] that isn’t [font=Courier New]NOP[/font].
• Despite the above precaution, [font=Courier New]LDSR[/font] into [font=Courier New]PSW[/font] can still crash the program, so be careful with it.
• Exceptions are handled, so testing things like division by zero, invalid opcodes or the [font=Courier New]TRAP[/font] instruction work just fine.
The program is arranged with a sort of tab strip at the top, with four distinct views. Use the L and R buttons to switch between them.
Instruction
The primary dialog that allows you to configure an instruction to test. When the Test command is invoked, the instruction will be tested in the context of a function call with the following arguments:
• r6 = Specified by user
• r7 = Specified by user
• r9 = 32 bytes of scratch memory available to the user
The values of r6 and r7, as well as the bits of the instruction to test, can be configured. The left D-Pad moves the cursor to select individual digits, then Up and Down on the right D-Pad will change the digit.
Moving the cursor down below the “Bits” field will select the Test command. Press the A button to perform a test, but bear in mind that the test is performed in the background and you will not see any effects until you look at the other menus.
A disassembly is provided as a courtesy to help make sure the instruction that’s going to be tested aligns with the instruction you intend to test. The program requires you to have a good working knowledge of V810 instruction formats. For more information, refer to the Sacred Tech Scroll’s list of instructions by mnemonic.
The left 16 digits of the Bits field are used for 16-bit instructions, and all 32 are used in order for 32-bit instructions. If a 16-bit instruction is specified, the second 16 bits are ignored during the test, so you don’t need to configure them.
System, Program
Displays two snapshots of system registers and program registers, respectively. These views are for display only and have no functionality.
For each register, there are two values shown: the top one is the register’s value before the test, and the bottom one is the register’s value after the test.
All system register indexes from 0 to 31 are displayed. This seems unnecessary at first, but it was discovered that system registers 29, 30 and 31 do in fact exist.
Misc.
Displays additional information regarding the test.
The bit-packed fields in system register PSW are decoded for easier assessment of the status flags.
There are 32 bytes of scratch memory available for testing read/write instructions with, pointed to by r9. The “before” and “after” states of these bytes are displayed here.
Another round of shout-outs to all supporters. You’re gonna make this all worthwhile. (-:
This is a work post.
Let’s take a look at what needs to get done going forward.
Project Outline
Development in the initiative is broken up into four main sections with the following hierarchy:
┌ Emulation core
│ ├ 3DS software
│ └ Desktop application
└ Technical documentation
The emulation core needs to be done before either the 3DS or Java applications can exist. The technical documentation can be maintained alongside development regardless of what’s being worked on.
In previous iterations of the project, I found that starting development in C is an uphill climb. It’s much easier to do rapid prototyping and debugging in Java, which is a highly substantial benefit for productivity. The Debugger and Memory windows in the Java application already give me a CPU’s-eye view of what’s going on so I can verify it’s working correctly. Additionally, due to C’s flexibility, it’s likewise easier to make a C analog of something written in Java than the other way around.
The order of operations, then, becomes only slightly more involved:
┌ Java emulation core
│ ├ C emulation core
│ │ ├ 3DS software
│ │ └ Desktop native modules
│ └ Desktop application
└ Technical documentation
In terms of priority:
1) Technical documentation
2) Java emulation core
3) C emulation core
4) 3DS software, Desktop application
5) Desktop native modules
This is the guide I will be using as I work on things, so now there’s a plan of action. I’ll make an effort to develop the 3DS software and desktop application fairly, since I feel both target audiences are equally important. The desktop native modules are not necessary for the desktop application to function, so their development is not urgent.
To Do – Week of April 16, 2018
• Establish the groundwork for “VB Sacred Tech Scroll v1.0” and begin migrating content.
While I do already have a draft of v1.0 in the works, it’s still based on the Nocash-style formatting and lately I’m thinking improved usability is more important than a cheeky homage.
Specifically, I want to incorporate content as it is implemented into the emulation core. Since right now the emulation core only consists of the CPU, the initial state of the new document will likewise only consist of the CPU. As additional components are incorporated into the emulation core, they will be cross-checked against the hardware and added to the document.
Critically, nothing will be implemented in the emulation core without first being verified on the hardware and documented. We’re gonna do this the right way.
• Produce “CPU Workshop” Virtual Boy software for verifying CPU functionality.
This will be a simple program that can be used to test individual instructions. A before-and-after snapshot of all registers will be recorded when testing instructions. Certain instructions cannot be tested this way (HALT, RETI, etc.), but most can.
The remaining CPU functionality will need special-purpose routines, and hopefully I can get it all sorted out in this one program.
This is a work post.
Truth be told, I started working on this project about a week before the 3DS thing came up. The two ideas merged together to form into what we have today. What this means for us is that we’re not starting from square one–we’ve already got some progress to go off of.
In this post, we’ll take a look at the current state of the project as of the start of the initiative.
Where We’re At
Attached to this post is a ZIP file containing a JAR file containing the source code of the current build of the emulator. And the JAR file itself is the current build of the emulator. If you have a Java Runtime Environment installed (Linux users will want OpenJDK), you can try it out! If you don’t have a Java Runtime Environment installed and have interest in this project, you might consider installing it. The desktop application will only be available on the Java platform.
When you load it up, you’ll have an empty window with a File menu, which you can use to load a Virtual Boy ROM. Once you select something, you’ll be presented with a Debugger window and a Memory window. The Debugger is the main attraction today, but if you want to navigate around the Memory window you can use Ctrl+G to go to any address you please.
The Debugger window looks like this:
On the left is the disassembler, and on the right are the registers. You can navigate around the disassembler with the arrow keys, Page Up/Page Down and the mouse wheel, or use Ctrl+G to go to a specific address.
Program execution is managed with the following keys:
• F11 – Single Step (aka Step Into). Executes the current instruction.
• F10 – Step Over. Attempts to execute until the following instruction is reached, which works as a traditional Step Over but is also useful for breaking out of the warm-up loop at the beginning of the crt0 routine. If one frame’s worth of CPU cycles is processed without reaching the target instruction, it will stop in order to prevent running endlessly.
The top panel of registers is for system registers, and the bottom panel is for program registers (aka general registers). All those numbers are in fact text boxes, allowing the user to change their values directly (no pop-up window). I couldn’t think of a cleaner way to present the 46 registers on the CPU, but if anyone has a better idea, now’s a great time to try something out.
See those + signs next to several of the registers in the image? You can click on those to “expand” the corresponding register for more options:
For system registers, this gives controls for configuring the individual bit-packed fields within the 32-bit value. PSW is demonstrated here, where there are check boxes for all of the flags and a text field for “I”, the interrupt masking level.
All program registers can be displayed with one of four presentation formats, depending on what you’re debugging. “Signed” and “Unsigned” are decimal representations.
Most instructions are implemented, but not bit string or floating-point instructions, since they will be miniature projects in and of themselves. There are also no implementations for hardware components, meaning interrupts will never occur. This means most games will eventually enter an endless loop waiting for a global variable to be changed that will never change.
Technical Stuff
Why Java? Because it’s available on most operating systems and the geniuses who maintain it have done all of the heavy lifting for things like localization, networking, GUI stuff, etc. I’ve been around the block two or three times looking for solutions to the cross-platform problem and Java is the best one I’ve come across.
Naturally, Java isn’t going to be the language used in the 3DS build, so how pray tell will this work? The answer isn’t ideal, but it gets the job done: there will be two implementations of the emulation core. One in Java, and the other in C.
The emulation core is a module that handles only the bare minimum necessary to manage a simulated Virtual Boy. It’s pure program code: it relies on the encapsulating application for things like timing, user input and presenting output. A C core will be used by the 3DS build, and the Java application will use… well, that’s where it gets interesting.
At the heart of the Java application is a class that represents the emulation core. It’s currently an abstract class, but I’m thinking of turning it into an interface… In either case, it doesn’t contain any actual program code of its own, but acts as a sort of stand-in template for other classes to implement. It looks like a duck and quacks like a duck, but it’s just the hollow shell of a duck.
Classes that implement the methods of this core interface are the meat of the internal engine. Currently I’ve set up a class that provides a generic Java implementation of the emulation core. In the future, at least one more implementation will be provided that makes use of the C version of the emulation core, which will offer improved efficiency and performance.
Java can use C code through the Java Native Interface (JNI), which loads shared object/DLL files at runtime. The drawback is that we need to produce those library files for every single operating system that we want native support for. Fortunately, those systems that don’t receive native libraries will be able to fall back on the Java implementation instead, and everything will still work just fine.
When it’s all said and done, the C emulation core module itself will be one of the products of the initiative. Other development teams the world over will be able to use it to easily integrate Virtual Boy emulation into their projects.
-
This reply was modified 7 years, 1 month ago by
Guy Perfect.
Thanks for the warm reception, guys. Never know what to expect when one of these goes up. (-:
Big thanks to those who, on the first day, have already pledged financial support. The world runs on people like you. <3
Nes Freak wrote:
you are going to need more coverage for this to work.
Reaching out is going to be the best way to increase awareness of the initiative. I’m going to ask that if you or anyone else has any ideas for which communities we can get in touch with, speak up!
I’ll also ask that someone other than me makes the actual announcements in those communities, since otherwise it will look like I’m barging in asking for money, which isn’t the case. (-:
Dreammary wrote:
I’d actually buy a 3DS if such an emulation became possible as it would be so cool.
Start saving your pennies, then!
__________
On that note, I’m going to go to bed. Gotta get all rested up for my first day at my new job tomorrow. (-:
I have such a Hello World program that I use for personal development, but it’s written against a devkit that isn’t public and never got finalized, so sending it to you won’t be too helpful… What you want to do is get a compiler set up so you can turn C source files into Virtual Boy ROMs. From there, I can assist in getting a Hello World program up and running.
Take a look at the Sacred Tech Scroll, which is a fairly accurate account of the system from the CPU’s perspective. What you ultimately want to do is store some kind of font graphics into character memory, arrange them on a background segment for the message you want to display, then set up a window containing that segment as its background. It sounds a bit complicated, but I’d be happy to walk you through it when the time comes.
I’ve attached the font I most commonly use for these programs.
Attachments:
Now sell it on eBay for like three thousand dollars?
That looks like it’ll do the trick! I’ve thought about the possibility of a Virtual Boy music file in the past, but never really settled on a “best solution”. I’m not sure if there’s anything akin to a universal video game audio format out there or not…
If a new one needs to be implemented, we might as well make it a community effort, right? (-:

retronintendonerd wrote:
Paypal.me is usually much easier for donations.
Ah, so that’s how to do it! Many thanks. The PayPal website is fairly straightforward, but it’s missing some key information and features that one has to look up elsewhere.
One thing that irks me, and I confirmed this over the phone, is that PayPal doesn’t believe in privacy… For any given transaction, the identities of both parties will be made visible. This by itself might be negotiable, but it’s not giving me any options to receive payments from non-PayPal users (via credit card, etc.), so I’m looking at Patreon again.
For experimental purposes, I’ve reactivated the Patreon page:
https://www.patreon.com/GuyPerfect
While Patreon doesn’t support one-time payments out of the box, they made an official statement that you can effectively do it by canceling your pledge at the beginning of the month after the transaction is processed. Otherwise, a recurring payment is scheduled.
If anyone has further insights on using Patreon in this way, don’t be afraid to speak up! Otherwise, this is probably the route we’re gonna take.

No, I removed it because it turns out that Patreon is not at all adequate as a donation platform. And that’s ironic, since half of YouTube apparently runs on it. It’s actually a subscription platform, and they do not facilitate one-time payments in any way. The proverbial last straw was when the first donator tried to donate and couldn’t because he didn’t have a credit card associated with his PayPal account, and Patreon requires payment methods to support recurring payments (and PayPal requires a credit card for those).
So instead, I’m just getting PayPal set up. I was on the phone with them a handful of times yesterday to figure out what went wrong with an ancient account and finally got that closed, freeing up my bank account to be used once again. As soon as their transactions are processed, I should be able to finalize it.
Fire-WSP: I sent you a file on Discord. Not sure if you regularly check Discord, but check Discord. (-:
-
This reply was modified 7 years, 2 months ago by
Guy Perfect.
-
This reply was modified 7 years, 2 months ago by
Guy Perfect.

I set up a Patreon page, available immediately: [redacted].
Where do we want to go from here? Main page of PVB? Set up a comprehensive thread and solicit interest from other communities?
-
This reply was modified 7 years, 2 months ago by
Guy Perfect.
-
This reply was modified 7 years, 2 months ago by
Guy Perfect.