CUzeBox - The new official Uzebox emulator

The Uzebox now have a fully functional emulator! Download and discuss it here.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian »

Artcfox wrote: Sun Aug 30, 2020 7:34 pmCan you package it with the latest SDL libraries? Without them the USB game controllers don't work out of the box on Windows.
Done, replaced the files on the host!
User avatar
danboid
Posts: 1930
Joined: Sun Jun 14, 2020 12:14 am

Re: CUzeBox - The new official Uzebox emulator

Post by danboid »

Has adding (JACK) MIDI input support to cuzebox been considered? Having MIDI IN support combined with Uzesynth would make writing chiptunes for the UB notably easier.

I've tried Uzebox patch studio but that lacks MIDI support and doesn't seem to be very accurate. I'm presuming cuzebox offer more accurate sound reproduction than patch studio.

https://github.com/Jubatian/cuzebox/issues/5
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: CUzeBox - The new official Uzebox emulator

Post by D3thAdd3r »

The current MIDI in code in the kernel has issues with losing bytes. Because the instrument sending the serial stream has no concept of Uzebox rendering and interrupts, it can send multiple bytes before the code gets a chance to intervene. I think the current MIDI in code should be removed from the kernel, for a MIDI aware ROM to handle; Or update MIDI in to use the newer method.

The new UART code(primarily intended for ESP8266) does not have this missing bytes issue. It checks for new UART data every hsync, and as long as data doesn't come in faster than 1 byte per scanline, and it gets processed in time to avoid the buffer getting filled, you don't lose any data. If someone had the interest to get UzeSynth doing that, it would be ideal. Then it would just be a matter of sending serial data to CUzeBox.

I tried to hack serial into Uzem, then later dabbled with CUzeBox. It is not trivial to do it correctly/fast, but from an ESP8266 angle, I'd almost be interested to try again. If I did so, I'd strongly consider a command line option to specify the name of a serial device to open. This would allow you to use a real ESP8266, or this should easily be adaptable to MIDI, etc.

Reason I lean towards this, is that I developed a semi-working ESP8266 core which more or less simulates the AT command set, used it to connect to servers, etc. One thing I knew it would never do, is actually emulate the program running on the ESP8266(which stock, is a simple AT interpreter easy to simulate by string parsing, some state, and sockets code). Using an actual serial port in CUzeBox would allow a plethora of devices that otherwise would not be worth taking the time to implement.

Seriously I might take a stab at what I just described. At least in Linux, I think you can redirect any kind of input to serial somehow.
User avatar
danboid
Posts: 1930
Joined: Sun Jun 14, 2020 12:14 am

Re: CUzeBox - The new official Uzebox emulator

Post by danboid »

I'm not sure how what you discussed would help me write UB chiptunes?

I get that you say the UB MIDI code isn't reliable or fully working and that you may be able to add serial support to cuzebox and uzesynth but then how would I get my MIDI data from REAPER, qtractor or whatever to the serial port of cuzebox? Would a JACK MIDI to serial MIDI converter app be required to complete this theoretical chain?
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: CUzeBox - The new official Uzebox emulator

Post by D3thAdd3r »

For the bridge between a real MIDI instrument and a serial port, we could have this. Otherwise there would be simple solutions.

If you just want to use MIDI software on a PC to send to CUzeBox, maybe this

Now as far as usefulness, I mean just to fix the current notion of MIDI in on Uzebox side to work right. Then purely psychological, to equate the work of UART emulation with more than just the addition of MIDI in. Networked games is a bit more exciting in my mind, but MIDI in also cool.

Those tools should probably work for hardware or ALSA, but either way I am quite sure there is a way to do it is not. Just setting up a different tool chain.
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: CUzeBox - The new official Uzebox emulator

Post by D3thAdd3r »

Haha yes both our quick searches yielded the same results
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Artcfox »

I fixed a bug in cuzebox that's been bothering me for a long time. If you are running it on a computer that can't quite keep up at 60fps, using the hotkey to single-step it frame-by-frame will still result in dropped frames (sometimes 4 times in a row!) making it so you completely miss the frames you were trying to see by single-stepping it.

The fix is similar to how cuzebox already won't drop frames if you are using ffmpeg to record a video. It also should not drop frames if you just used the hotkey to single-step to the next video frame.

Here is the code change necessary for the fix:

Code: Select all

diff --git a/main.c b/main.c
index 102702d..fe447ca 100644
--- a/main.c
+++ b/main.c
@@ -356,16 +356,16 @@ static void main_loop(void)
 #endif
 
 #ifdef ENABLE_VCAP
-  rows = frame_run(fdrop && (!main_isvcap), main_fmerge);
+  rows = frame_run(fdrop && (!main_isadvfr) && (!main_isvcap), main_fmerge);
   audio_sendframe(frame_getaudio(), rows);
-  guicore_update(fdrop);
+  guicore_update(fdrop && (!main_isadvfr));
   if (main_isvcap){
    avconv_push(frame_getaudio(), rows);
   }
 #else
-  rows = frame_run(fdrop, main_fmerge);
+  rows = frame_run(fdrop && (!main_isadvfr), main_fmerge);
   audio_sendframe(frame_getaudio(), rows);
-  guicore_update(fdrop);
+  guicore_update(fdrop && (!main_isadvfr));
 #endif
 
  }else{
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by uze6666 »

Speaking of patches, Anyone here comfortable enough with Cuzebox source to make a patch adding the keyboard support? I looked at it a couple times and never were able to know where and what to look for.
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Artcfox »

uze6666 wrote: Fri Feb 10, 2023 1:33 am Speaking of patches, Anyone here comfortable enough with Cuzebox source to make a patch adding the keyboard support? I looked at it a couple times and never were able to know where and what to look for.
I've been trying to get it up to feature parity with Uzem for my own debugging purposes, so I'm pretty comfortable with the source code and Jubatian's coding style, though some parts are still pretty opaque to me. You can compare my debug-enhancements branch here to see the various patches that I've added to my fork: https://github.com/Jubatian/cuzebox/com ... hancements

I tried to keep things in his original coding style, and it really does make it super-clean and easy to know which file a function or variable comes from.

I can give it a shot, though I should probably build a keyboard adapter myself so I can test it properly.
Post Reply