Bill Brendling's version of MEMU

Everything about Andy Key's great Emulator MEMU
Martin A
Posts: 840
Joined: 09 Nov 2013 21:03

Re: Bill Brendling's version of MEMU

Post by Martin A »

Should that be the other way around ? MFX uses #90 to 93, NFX used #A0 to A3.

Floating point on ReMemotech and my fat Cyclone 4 equipped MFX board uses #A0 to A5
Bill B
Posts: 641
Joined: 26 Jan 2014 16:31

Re: Bill Brendling's version of MEMU

Post by Bill B »

Martin A wrote: 25 Jan 2025 19:23 Should that be the other way around ? MFX uses #90 to 93, NFX used #A0 to A3.
Probably, my memory is terrible. Correction pushed.
User avatar
gunrock
Posts: 276
Joined: 28 Oct 2020 21:17

Re: Bill Brendling's version of MEMU

Post by gunrock »

Wow, I wasn't expecting such quick action!

If I get a chance, later this week I'll attempt to build the SDL windows version and report back.
Steve G
Danish Memotech MTX 512, MFX and loving it
Bill B
Posts: 641
Joined: 26 Jan 2014 16:31

Re: Bill Brendling's version of MEMU

Post by Bill B »

This discussion prompted me to revisit this.

I have revised the SDL version to use SDL v3, which has better Wayland support.

SDL3_net turns out to be a total re-write compared with SDL2_net. Unfortunately the new version is not suitable for Wiznet emulation. In particular the new library has no way of using a known (numeric) IP address without doing a DNS lookup.

Fortunately, reading some of the documentation around the re-write lead me to a site which gave hints on how to write network code which works on both Linux and Windows. So I used this information to revise the coding of the NFX emulation. This now works on both Linux or Windows, using either the native or SDL builds.

The emulation of the WizNet chip is very incomplete. It only supports TCP connections, not UDP or other protocols. But it should be sufficient to support the existing network programs for the MTX.

Note that unless the program is run as Administrator or Root, it will not be possible to open low-numbered ports (less than 1024). The work around for this is to use the switch -nfx-port-offset <offset>. This adds the specified offset to any requested port number less than 1024.

On Windows, the FTP command line client is not able to connect to non-standard port numbers (the Linux command line client can), but FileZilla can.

By specifying an offset of 10000, and using FileZila to connect to port 10021, it is possible to talk to ftpd on MEMU running on Windows.
MEMU_ftpd_on_Windows.png
MEMU_ftpd_on_Windows.png (91.72 KiB) Viewed 46880 times
I have published a release on GitHub including compiled versions of MEMU for both Windows and Linux. Note that this release defaults to MFX emulation, and includes the switch -nfx-port-offset 10000 in memu0.cfg, where it will not get overwritten by the configuration menu.
stephen_usher
Posts: 341
Joined: 27 Nov 2016 19:58

Re: Bill Brendling's version of MEMU

Post by stephen_usher »

Hmm... I'm trying to get it to build under macOS using MacPorts.

Installed clang-17 and SDL3 but it looks like the memu-sdl CMake file requires SDL3::SDL3 Perl module in addition to SDL3.

Update:

After fixing nfx.c and hacking some CMake files (and the link.txt so that it actually tried to link in the SDL3 library) I've managed to build memu-sdl! Yay!

It SEGVs as soon as it starts... now installing gdb so I can try to debug.

Update 2:

I added some debug code to dirmap.c and:

Code: Select all

% ./memu-sdl 
Debug: PMapRootDir: bCopy pmap = 2.
Debug: PMapRootDir: rootdir[2] = /Users/steve
Debug: PMapRootDir: Setting rootdir[3] to point to psDir: /Users/steve/Desktop/Retro/Memotech/MEMU-25_01/run_time
Debug: PMapRootDir: bCopy pmap = 0.
Debug: PMapRootDir: rootdir[0] = .
Debug: PMapRootDir: Freeing pmap = 0.
Debug: PMapRootDir: bCopy pmap = 0.
Debug: PMapRootDir: rootdir[0] = .
pmap = 1, psPath = '~E/roms/boot-type07.rom', rootdir[pmap] = '(null)'
Segmentation fault
Somehow rootdir[1] never gets set.
stephen_usher
Posts: 341
Joined: 27 Nov 2016 19:58

Re: Bill Brendling's version of MEMU

Post by stephen_usher »

Changed memu.cfg and replaced '~E' with '.' and no crash and a booted MTX emulation!

The colours in the MTX window look a bit odd though.

memu-sdl.jpg
memu-sdl.jpg (802.83 KiB) Viewed 46831 times

Sound works. A bit problematic without a numeric keypad though as no "fire" etc. and trying to set MTX mode doesn't work as I can't "hold down" M at reset.

Patches for dirmap.c, nfx.c and the top level CMakeLists.txt attached. I don't know enough about cmake to be able to fix adding an include path for /opt/local/include and library path for /opt/local/lib and adding -lSDL3 to the link stage.
Attachments
MEMU-25_01-patches.zip
(1.72 KiB) Downloaded 148 times
Bill B
Posts: 641
Joined: 26 Jan 2014 16:31

Re: Bill Brendling's version of MEMU

Post by Bill B »

I don't have the hardware to test building on MacOS. I am surprised Perl is needed. While my Linux distro probably has Perl installed, I am fairly certain I don't have it installed on Windows.

Compiling on Windows uses MSVC and on Linux uses GCC. I have never tried with CLang.

The fact that you are trying to reference /opt/local/include and /opt/local/lib suggests that you are trying to use a globally installed version of SDL3 rather than compiling it as part of building MEMU. For that, you want the CMake find_package command, see here.

Setting rootdir requires finding the path where the executable is installed. I don't know whether that works on MacOS.

With regards to the colours, I think there is a typo in the MFX palette. It used to exist in the FPGA as well, that got fixed but possibly not copied to MEMU.

I will review your patches.
stephen_usher
Posts: 341
Joined: 27 Nov 2016 19:58

Re: Bill Brendling's version of MEMU

Post by stephen_usher »

macOS (or Darwin as the base UNIX OS is/was called) is a derivative of BSD 4.3 really so the system calls and C library are very similar.

Yes, as I mentioned, I'm using the MacPorts installation of SDL3 (and compilers) which are installed as packages. Better to have someone else debug them than struggling myself. :-)

Given the number of people trying to run things on laptops these days it may be a good idea to look at the keyboard mapping and maybe have a separate one for laptops. I'll see if I can find the code and look into it.
Bill B
Posts: 641
Joined: 26 Jan 2014 16:31

Re: Bill Brendling's version of MEMU

Post by Bill B »

I have pushed some modifications to support MacOS, but I have no way of testing them.

nfx.c has been modified so that (hopefully) the opened network sockets are set to non-blocking as required.

main.c has been modified to (hopefully) set the path to to the executable for MacOS. I am not sure whether this will require linking to an additional library.

I have modified the CMakeLists.txt file so that it can be linked against a copy of SDL3 installed by a package manager, rather than compiling SDL3 from source. To do this build as:

Code: Select all

git clone https://github.com/Memotech-Bill/MEMU.git
cd MEMU
mkdir build-sdl
cd build-sdl
cmake -DSDL_SHARED=Y -DTARGET=SDL ..
make
stephen_usher
Posts: 341
Joined: 27 Nov 2016 19:58

Re: Bill Brendling's version of MEMU

Post by stephen_usher »

Doesn't quite work, src/memu/CMakeLists.txt needs editing around line 220 to add an entry for Darwin.

Now I'm going down the rabbit hole of "find_package" which seems to be overly complex. Why can't it just use environment variables as as "EXTRALIBS" and "EXTRAINCLUDES" ? *sigh*
Post Reply