Compiling B-em with Visual Studio 2010

want to talk about MESS/model b/beebem/b-em/electrem/elkulator? do it here!
Post Reply
User avatar
PitfallJones
Posts: 452
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Compiling B-em with Visual Studio 2010

Post by PitfallJones » Sun Feb 22, 2015 9:27 am

Hi,

So I finally got B-em compiling with Visual Studio 2010

That was arduous!

It the end I had to compile it with these extra libraries:

allegro-4.2.3
freealut-1.1.0
openal 1.1
zlib 1.2.3

And the exe now runs although al_findfirst() failed and appeared to return garbage - I don't know why....

I hardwired the code in the meantime:

Code: Select all

void mem_loadswroms()
{
        FILE *f;
        int c = 15;
        struct al_ffblk ffblk;
//        memset(rom,0,16*16384);
						f = fopen("BASIC.ROM", "rb");
                        fread(rom + (c * 16384), 16384, 1, f);
                        fclose(f);
                        romused[c] = 1;
                        c--;
							f = fopen("DFS-0.9.ROM", "rb");
                        fread(rom + (c * 16384), 16384, 1, f);
                        fclose(f);
                        romused[c] = 1;
                        c--;
						return;



Does anyone have any ideas why that would fail?

Am I using the correct versions of the libraries?

Anyone else get it compiling?

Thanks for any help

-PJ

User avatar
tricky
Posts: 3818
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by tricky » Sun Feb 22, 2015 10:59 am

Can't help, but I did spend a couple of days trying to get it to compile with vs2012 and never got it running as I couldn't find a combination of the library versions that worked.
I would be very interested in a version that did build as I have a few tweaks to add myself.
Beebem was easy to build, so I use that if I need custom debugging features, but I would love to have them in b-em; maybe I should brush up my javascript and do it in jsbeeb http://bbc.godbolt.org.
If you post your solution and project files along with links for the libraries, I'll have a look.
EDIT: Sorry, I completely missed the version numbers the first time, but the project and solution files would still be useful.

PS Is the issue on win8.1 or win7 too?

User avatar
tricky
Posts: 3818
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by tricky » Sun Feb 22, 2015 2:28 pm

Got it building! Allegro was as big a pain as I remembered DX3!

Will post bits as I find them:

zlib seems to default to Windows RT, so I disabled it!
zlib-1.2.8\contrib\minizip\iowin32.c(31)://#define IOWIN32_USING_WINRT_API 1

B-em just crashed without an error message when there was no roms directory.
copied it from the normal install.

B-Em works, at least in default config - this list was shorter than I thought!

I did do quite a bit of monkeying around with the project files and renamed Allegro's BITMAP to AL_BITMAP (There was a WINDOWS_BITMAP bodge in Allegro, but it didn't work for me), added ZLIB_DLL to zlib's defines and ZLIB_WINAPI and ZLIB_DLL to B-em's.

I have attached a zip (actually a 7zip compressed file) of the solution and project files I am using. Everything should be relative to the dir where the solution is. There is also a dir_tree.txt with the complete directory structure.

PS Sorry, just remembered, I used VS 2013 Community edition (same as 2013 Professional, but free for non-commercial and some restricted commercial use)
Attachments
b-em_sln_proj_dirs.7z
(11.96 KiB) Downloaded 85 times

User avatar
PitfallJones
Posts: 452
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by PitfallJones » Sun Mar 08, 2015 12:53 pm

Hi Tricky,

Thanks for that - very helpful.

Well after many more hours of pain I finally have it all compiling again - this time under 2013.

I'd like to upload the whole source tree somewhere (it's 43MB zipped) - any ideas?

I made a number of fixes:

The menu fix is this:

Code: Select all

 if (key[KEY_ALT] && key[KEY_ENTER] && fullscreen && !oldf)
                {
                        EnterCriticalSection(&cs);
                        fullscreen = 0;
                        video_leavefullscreen();
						SetMenu(hwnd, hmenu);
                        LeaveCriticalSection(&cs);
                }
                else if (key[KEY_ALT] && key[KEY_ENTER] && !fullscreen && !oldf)
                {
                        EnterCriticalSection(&cs);
                        fullscreen = 1;
						hmenu = GetMenu(hwnd);
                        video_enterfullscreen();
						SetMenu(hwnd, NULL);
						LeaveCriticalSection(&cs);
                }

The fix where is losses PAL interlaced is here:

Code: Select all

	if (vid_pal && vid_interlace) CheckMenuItem(hmenu, IDM_VIDEO_PALI, MF_CHECKED);
        else if (vid_scanlines)      CheckMenuItem(hmenu, IDM_VIDEO_SCANLINES,  MF_CHECKED);
        else if (vid_interlace) CheckMenuItem(hmenu, IDM_VIDEO_INTERLACED, MF_CHECKED);
        else if (vid_linedbl)   CheckMenuItem(hmenu, IDM_VIDEO_SLINEDBL,   MF_CHECKED);
        else if (vid_pal)       CheckMenuItem(hmenu, IDM_VIDEO_PAL,        MF_CHECKED);
        else                    CheckMenuItem(hmenu, IDM_VIDEO_LINEDBL,    MF_CHECKED);

The fix where is forgets what model it is ..is:

Code: Select all

                      case IDM_SPD_10: case IDM_SPD_25: case IDM_SPD_50: case IDM_SPD_75: case IDM_SPD_100:
                        case IDM_SPD_150: case IDM_SPD_200: case IDM_SPD_300: case IDM_SPD_400: case IDM_SPD_500:
                        CheckMenuItem(hmenu, IDM_SPD_10 + emuspeed, MF_UNCHECKED);
                        emuspeed = LOWORD(wParam) - IDM_SPD_10;
The fix for where it saves those $#%$%ing hd4 and hd5 files all over my hard drive is this:

Code: Select all

void ide_init(void)
{
	if (!ide_enable)
		return;
And finally I added a decent icon!

I've found if you change the DPI settings in Windows8.1 (to make the icons and text bigger on hirez small displays) that messes up the switch to fullscreen but I don't have a solution to that yet...

- PJ

User avatar
tricky
Posts: 3818
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by tricky » Sun Mar 08, 2015 1:34 pm

I've never really had much luck with open source projects, that is why I just post my whole source ;) but that is a bit easier when the zip is a few KB.
Thanks for the fixes, I kept getting caught by the speed/model bug when debugging my games. Now, I have debug set to run beeb-em as I prefer the windowed debugger and release set to b-em as it is a little more accurate for some things.

User avatar
PitfallJones
Posts: 452
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by PitfallJones » Sat Mar 14, 2015 2:42 am

I've fixed the DPI problem so now B-em is Windows 8.1 happy:

From Microsofts site:

https://msdn.microsoft.com/en-us/library/dn469266.aspx

Partial Rendering of a Full-screen Application

DPI virtualization sometimes causes partial rendering of a full screen application. In most cases, this side effect of DPI virtualization occurs in full-screen gaming applications because they commonly do programmatic screen resolution mode changes. This issue affects only Windows Vista or later applications that do not declare themselves as DPI–aware. Because virtualized applications get scaled system metrics, an application that changes the display mode based on these metrics may change the display to an incorrect mode while virtualized. Since full screen applications like games are natively resolution-independent, in most cases this means they are also natively DPI independent. The recommended solution for this class of applications is to declare themselves as per monitor-DPI aware. Note that some applications may have windowed-mode installers and uninstallers, so it is important to do an application test pass according to the DPI testing guidelines to ensure that the application behaves properly at high DPI.
That's a lot of talk - but it reduces to be adding this line of code to B-em:

Code: Select all

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
        HWND hwnd;               /* This is the handle for our window */
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
        int c;
        int oldf = 0;
        char *p;


		SetProcessDPIAware();
        
        for (c = 0; c < 128; c++) keylookup[c] = c;
And now the screen is scaled correctly... Score!

- PJ

User avatar
tricky
Posts: 3818
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by tricky » Sat Mar 14, 2015 9:35 am

Thanks for the update.

User avatar
fordp
Posts: 1033
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by fordp » Mon Mar 07, 2016 9:50 pm

PitfallJones wrote:I've fixed the DPI problem so now B-em is Windows 8.1 happy:

- PJ
Hi did you post your source somewhere or is that line the only change?

I would like to add 32016 support ;)

P.S. Put the code on Github if you have not already! It is a good place for GPL'd code :D
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

ThomasHarte
Posts: 475
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by ThomasHarte » Tue Mar 08, 2016 3:03 pm

PitfallJones wrote:And the exe now runs although al_findfirst() failed and appeared to return garbage - I don't know why....
Odds on it's doing something stupid with unicode; probably easiest to ditch the Allegro attempt and just use Microsoft's FindFirstFile/FindNextFile/FindClose directly.

It's not breaking portability if the code already doesn't build across multiple targets.

User avatar
kieranhj
Posts: 835
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by kieranhj » Fri Mar 11, 2016 8:21 pm

Yes, if someone could get a repeatable VS build source on GitHub that would be very helpful! I managed to get it compiled on VS2013 with OpenAL 1.1 but without alut, alas the audio had gained an occasional stutter. I also had all sorts of nightmares with conflicting defines in different headers between the libraries and Windows.

I should do a complete fresh build again and see where I can get to. (Was re-adding VGM support.)
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
Matt Godbolt
Posts: 187
Joined: Mon Jul 31, 2006 10:02 am
Location: Chicago
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by Matt Godbolt » Sat Mar 12, 2016 1:27 pm

tricky wrote:Beebem was easy to build, so I use that if I need custom debugging features, but I would love to have them in b-em; maybe I should brush up my javascript and do it in jsbeeb http://bbc.godbolt.org.
What kind of debug features are you thinking? All suggestions welcomed on the jsbeeb bug/feature list :)

ThomasHarte
Posts: 475
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by ThomasHarte » Mon Mar 14, 2016 2:37 pm

Matt Godbolt wrote:
tricky wrote:Beebem was easy to build, so I use that if I need custom debugging features, but I would love to have them in b-em; maybe I should brush up my javascript and do it in jsbeeb http://bbc.godbolt.org.
What kind of debug features are you thinking? All suggestions welcomed on the jsbeeb bug/feature list :)
I'd always intended to add an HTTP server to one of my emulators supporting single step, query for state, set breakpoint/watchpoint, read/write from memory, etc, then to write an assembler with step debugging that supports patch-at-runtime for trying code variations.

The benefit of the HTTP step would be twofold: a million of them are available, so it's easy to drop one in and most languages and frameworks find it easy to make HTTP calls, so it'd just be the easiest off-the-shelf solution to cross-platform inter-process communication. The assembler could even itself be a web app.

Either building an emulator into an assembler or else building an assembler into an emulator feels like a worse solution because even though every emulator aims to match the same specification, assemblers don't.

Having a well-defined interface for external debugger control would also reduce the problem of writing emulator unit tests.

... of course, this idea has never proceeded far off the drawing board. I can no longer locate it now but at one point had the start of a live assembler — i.e. one that assembles as you type, giving you instant feedback on errors, footprint, etc. If you could link that to an emulator so that you get instant feedback on errors, footprint and output, I think you'd be lightyears ahead of the current level of tools.

User avatar
tricky
Posts: 3818
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by tricky » Mon Mar 14, 2016 4:46 pm

I've started a couple of times writing an editor along similar lines, the idea was to incorporate the 6502 optimiser so that the editor would show you known values in registeres and flags and then swap jmp for branch remove redundant loads out swap them for Inc/Dec and show how close toa branch limit you were.

ThomasHarte
Posts: 475
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by ThomasHarte » Mon Mar 14, 2016 5:22 pm

I admit I hadn't put much thought into an optimiser, but an assembler that also is or else can communicate with an emulator would also work quite well as a profiler, which is good for value judgments that are hard to make a priori. Even more so if you can live preview the results, allowing you to perform a subjective profiling: e.g. to what extent can I decrease the precision on this before it produces an intolerable output?

But at that point maybe it's appropriate to start trying to think in terms of version control, as a natural way to encapsulate branches and therefore to perform comparative assessments between solutions.

... and then maybe you've crossed the line where the tool becomes so much of a monolith that it never actually gets developed or, if it does, becomes unmaintained almost immediately.

User avatar
Matt Godbolt
Posts: 187
Joined: Mon Jul 31, 2006 10:02 am
Location: Chicago
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by Matt Godbolt » Mon Mar 14, 2016 7:04 pm

ThomasHarte wrote:
Matt Godbolt wrote:
tricky wrote:Beebem was easy to build, so I use that if I need custom debugging features, but I would love to have them in b-em; maybe I should brush up my javascript and do it in jsbeeb http://bbc.godbolt.org.
What kind of debug features are you thinking? All suggestions welcomed on the jsbeeb bug/feature list :)
I'd always intended to add an HTTP server to one of my emulators supporting single step, query for state, set breakpoint/watchpoint, read/write from memory, etc, then to write an assembler with step debugging that supports patch-at-runtime for trying code variations.
(plug) Might I suggest seasocks if you do go the C++ way :)

User avatar
fordp
Posts: 1033
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by fordp » Mon Mar 14, 2016 8:51 pm

Well I have it building on:

Code: Select all

Microsoft Visual Studio Community 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Professional

Team Explorer for Visual Studio 2013   06177-004-0444002-02009
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02009
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02009
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02009
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02009
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02009
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.
But it does not link it is looking for "alleg.lib" which does not exist.

I am no Windows programmer, I write deep embedded code for living. I rarely use libraries for that ;)
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

ThomasHarte
Posts: 475
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by ThomasHarte » Mon Mar 14, 2016 9:15 pm

fordp wrote:But it does not link it is looking for "alleg.lib" which does not exist.

I am no Windows programmer, I write deep embedded code for living. I rarely use libraries for that ;)
https://www.allegro.cc/files/?v=4.4 contains built libraries of 4.x-era Allegro for up to "MSVC 10" (which, coincidentally, probably is MSVC 2010 per a quick internet search; it's unclear to me why that site is using the now-obscure version numbers) — any idea whether 2013 can still build against older libraries?

It's also possible that Allegro 4 doesn't work under modern Windows, I guess. It seems perpetually to have compatibility issues elsewhere.

User avatar
fordp
Posts: 1033
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by fordp » Mon Mar 14, 2016 9:37 pm

I guess B-em needs a caretaker maintainer who can at least make it build on modern platforms.

I do not have the skills for that.

I am pretty sure we will get Pandora, BAS32 and BAS32f working on it if we can just get it to build.

On the other hand is there any point if it will not get packaged so others can use it?
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
hoglet
Posts: 8693
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by hoglet » Mon Mar 14, 2016 10:03 pm

Maybe this is a stupid question, but why the focus on building B-em with Visual Studio?

I've just managed to build it in about 30s using the same tool chain we use for Atomulator, and it works just fine on my Windows 7-64 bit system.

Not surprising though I guess, as I think Tom Walker was responsible for both of of these.

Edit: Scratch that, there are some "issues" :lol:

Dave

User avatar
kieranhj
Posts: 835
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by kieranhj » Tue Dec 27, 2016 8:43 pm

Bump!

So I had another go at doing this from scratch using the standard B-Em 2.2 source and documenting my progress as I went. Dev environment is Windows 10 + Visual Studio 2015 + DirectX8 but targeting Win32/x86. Libraries required:

OpenAL 1.1 - installed SDK
Allegro 4.2.3 - built from sources in VS - had to set some defines/configs carefully and small code changes for DirectInput8 API
freealut (taken from GitHub repo) - built from sources in VS - just needed correct incude/library paths
zlib 1.2.3 - built from sources in VS - had to comment out unistd.h include

It now builds and runs (yay!) but the sound stutters badly (as happened to me when I tried ~6 months ago.) It sounds like the sample buffer being filled by B-Em with the generated waveform from the Beeb is not always being filled in time, so the part of the buffer gets reused (stutters) before the correct data arrives and the sound continues. I don't suppose anyone has experienced this or has any thoughts..? :-k
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
kieranhj
Posts: 835
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by kieranhj » Tue Dec 27, 2016 10:41 pm

I debugged a bit (using all the profiling tools in VS) and it doesn't appear to be anything to do with the sound but the graphics, specifically DirectX surface locking. If I have the video display option set to anything other than "Hardware line doubling" then I get the stutter and the profiler shows 64Mb memory blocks repeatedly allocated / deallocated when Allegro is attempting to lock the DirectX surface that represents the screen and blit the bitmap that represents the Beeb to it.

If I select the "PAL" video display option then everything goes crazy and runs about 2Hz! The plot thickens but I've spent long enough on this for tonight...
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
kieranhj
Posts: 835
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by kieranhj » Wed Dec 28, 2016 8:56 am

Ah, some more early morning bug hunting. I get stutter and repeated memory alloc/deallocs in the original built version 2.2 of B-Em.exe if I *don't* have the "Resizeable window" video option checked. Does anyone else see this?

(This is on a Dell XPS 15 laptop, so i7 + 2x gfx cards + 16Gb RAM + 4k screen.)
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
simonm
Posts: 303
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by simonm » Wed Dec 28, 2016 12:19 pm

This might be a windows 10 issue Kieran - I have the same audio issue with B-Em on my laptop, but I'm using a release binary from the website.

User avatar
simonm
Posts: 303
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by simonm » Wed Dec 28, 2016 12:22 pm

Also - there's a B-Em repo in the stardot GitHub org, would it make sense to treat that as the "official" development source? (assuming thats ok with the original authors)

User avatar
kieranhj
Posts: 835
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Compiling B-em with Visual Studio 2010

Post by kieranhj » Wed Dec 28, 2016 4:54 pm

Yes, I think the non-resizeable window is a Windows 10 issue. There seems to be some surface locking contention when attempting to blit the Beeb screen from a palette bitmap directly to a 32-bit bitmap in use by the GPU. I'm guessing this is all going through the CPU to access video card memory in some way. The other versions go via a temporary bitmap (for the resize) and then blit this to screen.

Anyway, the good news is that I have successfully built B-Em and have a fork in my own repo on GitHub. Just added VGM logging as threatened about 9 months ago. :)

Sarah did say she was happy for the Stardot repo to become the official one in a previous thread IIRC.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

Post Reply