Mac Arculator

ask about 32-bit emulators like ArcEm, Red Squirrel, Arculator or RPCEmu here
User avatar
geraldholdsworth
Posts: 384
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Mac Arculator

Post by geraldholdsworth » Sat Jan 14, 2017 7:39 pm

Hi all,

A while ago Jon Welch sent me the source to the Mac version of Arculator in order for me to attempt to update it (you may have seen my posts in these forums). My idea was to make it look and feel like RPCEmu, but for Archimedes. However, this is going to take me forever to do, mainly because I need to learn X-Code, and how to write MacOS X applications.

Therefore, what I am proposing, is that I make the source available for others (who do know what they're doing) to contribute towards improving this version.

Anyone interested?

Cheers,

Gerald.
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

sfdNut
Posts: 61
Joined: Fri Jul 08, 2016 10:13 am
Contact:

Re: Mac Arculator

Post by sfdNut » Thu Oct 19, 2017 4:22 pm

I'm interested.
I have a Mac and X-Code and am currently learning Swift programming, although I suspect the current code will be in Objective-C?

I'd like to get involved at least :D

g7jjf
Posts: 361
Joined: Sun Aug 07, 2005 7:29 pm
Location: Notts, England
Contact:

Re: Mac Arculator

Post by g7jjf » Fri Oct 20, 2017 10:21 am

The code is in straight C using the Allegro libraries.

You can download the source and libraries by ftpping to g7jjf.synology.me

Log in as arculator, password riscos and the files are in the home directory.

Jon

User avatar
geraldholdsworth
Posts: 384
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Mac Arculator

Post by geraldholdsworth » Fri Oct 20, 2017 3:46 pm

I think I went in too deep, volunteering to update Arculator on the Mac. Baptism by fire, I think they call it, learning to program a new language on a different platform.
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Thu May 17, 2018 8:35 pm

How did this go? I'm poking at porting it to Allegro 5 at the moment, working with Sarah's official sources (https://bitbucket.org/pcem_emulator/arculator), which I assume are the most up to date. I'm not touching any of the GUI side of things, just trying to get the basics working. Looks like quite a few convenience functions (al_findfirst, append_filename, etc) disappeared from Allegro between 4 and 5, and the graphics code changed rather a lot, so it looks like a big job...
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
danielj
Posts: 6486
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Mac Arculator

Post by danielj » Thu May 17, 2018 8:48 pm

Allegro 4 won't compile on the mac at all anymore. If someone's managed it I'd love to know?

d.

User avatar
geraldholdsworth
Posts: 384
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Mac Arculator

Post by geraldholdsworth » Fri May 18, 2018 8:08 am

myelin wrote:How did this go?
Haven't got far.
I was hoping to make Arculator like RPCemu, but it looks like the whole thing needs to be overhauled, as Allegro 4 won't compile. For me, this has ended up as a project (one of many) for a another day. Work and life are getting in the way! :lol:
That link is to the PC version. Attached is Jon's Mac version.
Attachments
Arculator SRC.zip
Mac Arculator 0.8 source
(4.49 MiB) Downloaded 13 times
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

User avatar
Elminster
Posts: 2929
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: Mac Arculator

Post by Elminster » Fri May 18, 2018 4:34 pm

After reading this I thought I would have a play, As Mac version seemed busted I thought I would try compiling Linux Arculator to see how it works, but while it compiled (I after I fudged shift4 and shiftmem to static) that seems to stack dump, will have to go chase davidb why that is happening at some point.

Failed 2 out of 2.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Fri May 18, 2018 4:50 pm

I spent a while adding function definitions, moving things around, and disabling huge amount of code with #ifdef blocks, and I have it compiling under Allegro 5 on a Mac using clang in C++ mode (i.e. a lot stricter than the default). The shift4 problem just disappeared at some point, which is puzzling, but I assume it was connected to one of the many redefinition errors. It doesn't really run at all yet, because I had to completely disable video, but that shouldn't be too terrible to at least basically fix :) Need Sarah to put a LICENSE or COPYING file in the repo root before work will let me release my changes, but I'll start pushing them to bitbucket as soon as that happens.

I see RPCEmu ripped out Allegro entirely and replaced it with Qt5... that looks worth investigating too, because it would give us a cross-platform UI too.
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Fri May 18, 2018 6:13 pm

My other (only?) active emulator, PCem, recently switched to wxWidgets + SDL2 for cross-platform UI goodness. I'd personally prefer that to Qt5, for the entirely selfish reason that I only have to learn one UI library :)

VincentVega
Posts: 274
Joined: Thu Sep 11, 2008 9:19 pm
Contact:

Re: Mac Arculator

Post by VincentVega » Fri May 18, 2018 9:08 pm

myelin wrote: I see RPCEmu ripped out Allegro entirely and replaced it with Qt5... that looks worth investigating too, because it would give us a cross-platform UI too.
The last time I tried compiling one of the beta versions of RPCEmu against QT5, the keyboard didn't work, as there's apparently no way to get native scan codes on OS X (though how does Allegro manage?). QT took an age to compile as well, even on a 2017-vintage iMac.

I ported RPCEmu to Allegro 5 a while ago (there's probably a thread around here somewhere with a download link). My strategy was to make an Xcode project, hit "Build" and start going through the list of errors one by one. Sound was a bit of a pain, as that's even more different than the rest of Allegro 5, and I seem to recall having lots of fun with the video side of things. It all worked once I'd finished, but I lost interest after that. I did also think about porting it to SDL2, but that's something else that got put on the "perhaps some other time" pile.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Fri May 18, 2018 9:37 pm

VincentVega wrote:My strategy was to make an Xcode project, hit "Build" and start going through the list of errors one by one.
That's what I've been doing for Allegro 5 + Arculator. Allegro 5 seems to have a less 'raw' bitmap/display interface, though, and my experience with Qt5 seems similar to yours, so I feel like neither of those is going to make for a convenient porting process. I'll go take a look at SDL2's 2D graphics code (and Sarah's PCem graphics code) and see if that would be an easier port!
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Sat May 19, 2018 3:19 am

Looking at the PCem code, I'm thinking that the best thing to do might be to lift as much as possible from there, or merge Arculator into it... it looks like it has a nice degree of separation between the emulator code and the platform code, so it should be feasible to remove all the PC specific stuff (x86 processors, all the various graphics and sound interfaces) and wire in Arculator.
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Mon May 21, 2018 5:23 pm

Sarah pinged me over the weekend to say she's starting work on porting Arculator over to SDL. I pushed my current work for reference... my code removes the Allegro dependency, but doesn't replace it with anything, so Arculator will run but have no I/O capability.

To avoid duplicating work, I'm going to pause this for now, and maybe spend some time documenting the PCem architecture (which has a Direct3D frontend for Windows, and SDL for Linux and macOS, plus a whole lot of pluggable things). Hopefully that'll come in handy for us down the line.
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Mon May 21, 2018 6:00 pm

One thing to be aware of is that the guy who did the wxWidgets code for PCem implemented a sort of 'compatibility layer' in wx-utils.cc, to aid porting the GUI from Win32. I'd personally advice that Arculator _doesn't_ use this - I've found it to be quite confusing when trying to modify the GUI further. Since Arculator doesn't have that much GUI to port, it probably won't be that much work to just use the new toolkit directly.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Tue May 22, 2018 8:26 am

Thanks for the SDL update, Sarah! I've been trying to get it running on macOS... progress so far is to get it built, added a simple event loop, and it appears to run, although I seem to be running into some kind of display issue. I've verified that the data from 'buffer' is getting to the texture and being drawn on the window (I can poke pixels in 'buffer' and they show up), and I've verified that it reads the CMOS. I don't have a good way of verifying that the problem is with the display and not somewhere else in the system, though, so I'm scratching my head about how to debug further. It appears to be rapidly flipping between line-doubled and non-doubled mode, if that's any help. I just realized that memc_videodma_enable never gets set to anything other than 0. Forcing this to 1 results in some regular-looking garbage on the screen (super flickery because the update/present calls seem to be running rather a lot more often than they should).

BTW some odd stuff happens on startup with vidcgetcycs() -- it looks like vidc.htot is sometimes less than displen, which results in it returning a negative value for the # of cycles during the blanking period.
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Tue May 22, 2018 4:21 pm

What's in arc.cfg? There are a few bugs in the video code currently, and you may be using one of the configurations that currently doesn't work. It's entirely possible that 'configurations that don't work' includes whatever's set as default...

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Tue May 22, 2018 4:31 pm

SarahWalker wrote:What's in arc.cfg? There are a few bugs in the video code currently, and you may be using one of the configurations that currently doesn't work. It's entirely possible that 'configurations that don't work' includes whatever's set as default...
I don't think I provided an arc.cfg, but Arculator seems to write this one out into the current directory when it runs:

Code: Select all

disc_name_0 = 
disc_name_1 = 
disc_name_2 = 
disc_name_3 = 
limit_speed = 1
sound_enable = 1
mem_size = 4096
cpu_type = 0
memc_type = 0
fpa = 0
hires = 0
full_borders = 0
first_fullscreen = 1
double_scan = 1
hardware_blit = 0
fast_disc = 1
fdc_type = 1
rom_set = 3
stereo = 1
no_borders = 0
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Tue May 22, 2018 6:25 pm

Try setting either 'full_borders' or 'no_borders' to one. Having neither enabled is not currently supported - pity it's the default :)

You could also try setting 'double_scan' to zero and see if that helps anything.

I'm reworking this part of the video code though, so if you wait half an hour it might magically start working anyway!

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Tue May 22, 2018 7:01 pm

Rev 39 has the video code updates; these may help!

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Tue May 22, 2018 7:08 pm

I gave all those a try, without much luck :) Each one gave an interesting new kind of glitch display, aside from no_borders = 1, which gave me a blank screen. I'll pull your latest updates and give it a try!

It seems likely that my issue lies with whatever's (not) setting memc_videodma_enable... I assume something's causing RISC OS to fail to start up. Uncommenting the logging in writememc() shows that VINIT/VSTART/VEND aren't being written, and memc_videodma_enable is only being set to 0.
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Tue May 22, 2018 8:08 pm

If the POST is failing, RISC OS will put the failure code in fiq_r12 - this is printed as 'f12' in Arculator's register dump, and might give a clue as to what's going wrong?

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Tue May 22, 2018 9:06 pm

Looks like f12 is staying at zero, so maybe the POST isn't failing.

Trying to merge in your latest changes -- is video.h missing from the commit?
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Tue May 22, 2018 9:08 pm

I keep doing that...

Fixed in rev 46.

What's the value of R15?

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Tue May 22, 2018 10:50 pm

Here's the current dump on shutdown (with the latest updates pulled in) --

Code: Select all

R 0=228C0F6A R 4=00000000 R 8=7FFFFFB6 R12=2F802B0F
R 1=03400000 R 5=08000000 R 9=036E018C R13=00400000
R 2=03816098 R 6=20000000 R10=0F802C9F R14=5F81158F
R 3=FFFFFFFF R 7=00001F3C R11=80000003 R15=3F8115A3
2834004 E4920004 E3700001
f 8=00000000 f 9=00000000 f10=00400000 f11=036E010C
f12=00000000 f13=00000000 f14=00000000
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Wed May 23, 2018 1:31 am

Here's what I think is happening. This is the code that's running:

Code: Select all

.data:0381158c 0d 15 a0 e3                      mov	r1, #54525952	; 0x3400000     ; r1 = vidc
.data:03811590 b8 20 4f e2                      sub	r2, pc, #184	; 0xb8          ; r2 = pc-184

.data:03811594 04 00 92 e4                      ldr	r0, [r2], #4
.data:03811598 01 00 70 e3                      cmn	r0, #1  ; exit when we read ffffffff
.data:0381159c 00 00 81 14                      strne	r0, [r1], #0  ; copy word from *r2 to vidc
.data:038115a0 fb ff ff 1a                      bne	0x03811594
This code reads words from the table at 0x038114e0 - 0x03811578 and writes them to 03400000. It's meant to stop at the 0xffffffff value at 0x03811578, but it doesn't -- cmn r0, #1 isn't matching r0 with -1 (maybe it's doing a 64-bit compare between 0xffffffff_ffffffff and 0x00000000_ffffffff, or maybe there's a signed/unsigned issue).

You run into the weirdest stuff when building on a new compiler! (This one identifies as "Apple LLVM version 9.1.0 (clang-902.0.39.1)" with "Target: x86_64-apple-darwin17.5.0").
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Wed May 23, 2018 4:15 pm

I'm unclear as to what I changed (something trivial like putting braces around something to add debug output, I'm guessing) but last night it started getting to the purple/blue POST screen, then crashing with a data abort as soon as doosmouse() ran (its writes to 0x5B8 and 0x5B4 failed), which sent PC to 0x14.

After disabling mousehack in arc.h, it now boots to the RO3.11 desktop! The screen has some horizontal banding (some kind of scaling artifact -- maybe the window needs to be made a few pixels taller) and the mouse doesn't work yet, but it's not far off now! :)
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Wed May 23, 2018 5:00 pm

Excellent!

I did think of 64-bit incompatibilities as I went for a run this morning. I'm pretty sure I've had it working in the past, but I haven't done a 64-bit build for a while now - I need to give it a try and look for any issues!

User avatar
myelin
Posts: 430
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Mac Arculator

Post by myelin » Wed May 23, 2018 8:20 pm

I added in the SDL_SetRelativeMouseMode/SDL_SetWindowGrab calls from PCem, and now it captures and releases the mouse.

I'll start looking at tidying up the diffs and pushing this to BitBucket over the next few days :)

This self-extracting SparkPlug archive worked, after editing !Run and commenting out the System$Dir check, and I managed to run !SICK, although it died with a division by zero after a while. Results attached!

I expect the timing is a bit off right now... I need to calibrate the delay loop, but right now I have it running around 3-4x realtime. The numbers look a bit low in the !SICK report, so I'm guessing that I need to look at the CMOS clock.
Attachments
2018-05-23 Arculator SICK result.txt
(3.34 KiB) Downloaded 9 times
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
SarahWalker
Posts: 1098
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Mac Arculator

Post by SarahWalker » Wed May 23, 2018 8:23 pm

The !SICK numbers look about right for an ARM2 machine. The divide by zero error is most likely screen memory being too small - bumping that up to 480kb should fix it. It will probably also error out later on if ARCROM has been loaded, as it can't read the support ROM podule type.

Post Reply