maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   BBC Micro (https://talk.maemo.org/showthread.php?t=31696)

marnanel 2009-09-15 17:11

BBC Micro
 
http://spectrum.myriadcolours.com/~marnanel/bbc-maemo

Ten minutes' hacking around brings the Beeb to the N900. It has some keyboard focus issues which need seeing to. Also, beebem uses f12 to bring up an emulator menu, and the N900 has no f12. But with a little work we could see Elite running on this thing.

(If this was ever a serious project, some serious thought would have to be given to copyright issues about the MOS, the DFS, and BASIC: you can't do anything without the MOS, you can't do much without BASIC, and life without the DFS is painful. But they are all still © Acorn, whoever that is these days.)

javispedro 2009-09-15 17:16

Re: BBC Micro
 
Quote:

Originally Posted by marnanel (Post 327293)
It has some keyboard focus issues which need seeing to.

I'm also having those (DOSBox), and for now I have not yet identified the reason (to be honest I've not put too much though into the issue yet). So if you can guess why it seems to affect some apps only please tell :)

Other than that, it's a cool app :D

marnanel 2009-09-15 17:18

Re: BBC Micro
 
Quote:

Originally Posted by javispedro (Post 327297)
I'm also having those (DOSBox), and for now I have not yet identified the reason (to be honest I've not put too much though into the issue yet). So if you can guess why it seems to affect some apps only please tell :)

Other than that, it's a cool app :D

Thanks. Fixing window managers is rather an obsession of mine, so I'm certainly going to be looking at that after work tonight. :)

TA-t3 2009-09-15 19:58

Re: BBC Micro
 
Quote:

Originally Posted by marnanel (Post 327293)
[...] some serious thought would have to be given to copyright issues about the MOS, the DFS, and BASIC: you can't do anything without the MOS, you can't do much without BASIC, and life without the DFS is painful. But they are all still © Acorn, whoever that is these days.)

Well, we have an ARM CPU in our toys, and ARM used to mean "Acorn Risc Machine", so maybe we have an implicit license to use Acorn material :)

Just kidding (about the implicit license), but Acorn was behind not only the beloved Beeb but also the incredibly successful ARM CPU (almost 3 billion a year sold.. quite a lot more than Intel has managed so far).

marnanel 2009-09-16 12:47

Re: BBC Micro
 
Quote:

Originally Posted by javispedro (Post 327297)
I'm also having those (DOSBox), and for now I have not yet identified the reason (to be honest I've not put too much though into the issue yet). So if you can guess why it seems to affect some apps only please tell :)

Other than that, it's a cool app :D

Thank you :)

The problem is that there's a bit in WM_HINTS which (in both apps) isn't set. You can see this using "xprop -id 0x...":

For Beebem:
WM_HINTS(WM_HINTS):
bitmap id # to use for icon: 0x300000d
bitmap id # of mask for icon: 0x300000b
whereas for, say, mediaplayer we'd get:
WM_HINTS(WM_HINTS):
Client accepts input or input focus: True
Initial state is Normal State.
window id # of group leader: 0x2c00001
I believe this is a problem with libsdl, but I haven't dug down any further to find why it's not setting this bit.

deadmalc 2009-09-16 13:38

Re: BBC Micro
 
Whooa! Exile on the n900, that would be so cool!

javispedro 2009-09-16 17:16

Re: BBC Micro
 
Quote:

Originally Posted by marnanel (Post 327824)
The problem is that there's a bit in WM_HINTS which (in both apps) isn't set. You can see this using "xprop -id 0x..."

No, thank you instead, you're completely right (and sorry for dirtying your thread, but at least now I know I should probably file a bug about this...). The problem seems to be the missing WM_HINTS bit, but, while on DOSBox that bit is not set:
Code:

...
WM_CLASS(STRING) = "dosbox", "dosbox"
WM_HINTS(WM_HINTS):
                bitmap id # to use for icon: 0xc0000d
                bitmap id # of mask for icon: 0xc0000b

It is definitely set on a simpler SDL testcase I made:
Code:

...
WM_CLASS(STRING) = "test-i386", "test-i386"
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True

I have this suspicion this may be related to the window icon, but this is a wild guess just by looking at the above.

Yay, confirming: adding SDL_WM_SetIcon call makes the test case lose the input focus.

marnanel 2009-09-16 17:40

Re: BBC Micro
 
Quote:

Originally Posted by javispedro (Post 327964)
The problem seems to be the missing WM_HINTS bit, but, while on DOSBox that bit is not set:

DOSBox (and BeebEm) have neither InputHint nor WM_TAKE_FOCUS, and the ICCCM says explicitly that this means "the client never expects keyboard input".

One rather interesting point is that a very quick perusal of Metacity's sources seems to indicate that Metacity will give focus if WM_TAKE_FOCUS is present or InputHint is set. Matchbox2, however, appears to give focus if and only if InputHint is set (it only checks WM_TAKE_FOCUS in order to tell whether to send WM_TAKE_FOCUS when focussing a window).

According to the ICCCM, having WM_TAKE_FOCUS present but not InputHint means that a client "wants to prevent the window manager from setting the input focus to any of its windows", so Matchbox2 is technically correct here. It is possible, of course, that Metacity behaves that way because it solves some problem in a particular subset of clients, so perhaps it would be good to change Matchbox2's behaviour.

Either way, it wouldn't solve the current problem, since the SDL apps in question set neither WM_TAKE_FOCUS nor InputHint.

marnanel 2009-09-16 17:41

Re: BBC Micro
 
Quote:

Originally Posted by javispedro (Post 327964)
Yay, confirming: adding SDL_WM_SetIcon call makes the test case lose the input focus.

Woot, good catch!

javispedro 2009-09-16 17:55

Re: BBC Micro
 
I believe this is "our man":
SDL_x11wm.c, line 232

As a workaround, ifdef'ing the SDL_WM_SetIcon call out will work, since Maemo gets the icons from other sources either way.

If you believe Matchbox is right here, then this is a SDL bug :S

marnanel 2009-09-16 18:06

Re: BBC Micro
 
Quote:

Originally Posted by javispedro (Post 327980)
If you believe Matchbox is right here, then this is a SDL bug :S

Matchbox is doing the right thing here, yes. Looks like that
Code:

wmhints->flags =
... should have been a
Code:

wmhints->flags |=
... .

javispedro 2009-09-16 18:07

Re: BBC Micro
 
Wow. I should've google'd harder. It is a SDL bug, and it was already filed in 2008!

http://bugzilla.libsdl.org/show_bug.cgi?id=586

*sigh*

Thanks marnanel for the hints (and keywords to search!)!

marnanel 2009-09-16 18:12

Re: BBC Micro
 
Quote:

Originally Posted by javispedro (Post 327988)
Wow. I should've google'd harder. It is a SDL bug, and it was already filed in 2008!

Think we should file a Maemo bug to get it fixed downstream if they won't get on with fixing it upstream? It seems a pretty easy bug to run into.

javispedro 2009-09-16 18:26

Re: BBC Micro
 
Yeah, or probably document it in the wiki (with all the other Maemo SDL "nuisances" ;)).

marnanel 2009-09-16 20:53

Re: BBC Micro
 
Quote:

Originally Posted by deadmalc (Post 327853)
Whooa! Exile on the n900, that would be so cool!

Well, since you asked:

http://spectrum.myriadcolours.com/~m...bc-maemo-exile

And the obligatory Elite:

http://spectrum.myriadcolours.com/~m...bc-maemo-elite

I don't think I'll play with this much more, though, because:
  1. Beebem is not to my knowledge free-as-in-speech software, only free-as-in-beer, and I don't know of another good Beeb emulator for *nix;
  2. Even if Beebem was free software, it's still unclear about the legality of distributing the Beeb's MOS and BASIC roms, without which the emulator would be useless;
  3. Beebem updates the screen for every scanline, which causes it to be very slow on modern computers (on my laptop as well as the N900): slower than a real BBC Micro, in fact. This could be fixed by doing things with OpenGL, but that's not really my area;
  4. I have a whole lot of other things to do :)

Still, it's nice to have demonstrated that it's possible.

KristianW 2009-09-17 15:46

Re: BBC Micro
 
I'd love to have some version of ARM RISC OS
(originally on the Acorn Archimedes 12 MHz ARM)
on my NIT.

But I suppose it takes to much work ?

---just a thought.

marnanel 2009-09-17 16:16

Re: BBC Micro
 
Quote:

Originally Posted by KristianW (Post 328561)
I'd love to have some version of ARM RISC OS
(originally on the Acorn Archimedes 12 MHz ARM)
on my NIT.

But I suppose it takes to much work ?

---just a thought.

I don't know-- do you know of any good Archimedes emulators for *nix that could be ported? I never used one myself (despite having grown up with the BBC Micro), so I don't know much about it.

lcuk 2009-09-17 21:49

Re: BBC Micro
 
i see this app is on fremantle.

what other input focus bugs are you seeing.
because when i started with liqbase on n900 every keypress would result in other apps being opened and getting input keystrokes.

i could not enter any text for a while.

lcuk 2009-09-17 22:07

Re: BBC Micro
 
i will just explain the noticed bug and fix that was made


using fremantle,
when i started to run liqbase, i discovered that pressing any key in my app would mysteriously open up one of the search apps.
this was not what was wanted and meant i could not enter any text in liqbase for a while.

on the n810 it worked perfectly without this fix:


this code is at the end of the open window function, it simply forces focus back to the app itself.

http://github.com/lcuk/libliqbase/bl...x11info.c#L250


since you did not explain the problem and javispedro hasnt actually reproduced the error i think its at least something to consider and see.

let me know if its the same error, or describe the actual effect more clearly so we may try to help :)

marnanel 2009-09-18 00:56

Re: BBC Micro
 
Quote:

Originally Posted by lcuk (Post 328807)
using fremantle,
when i started to run liqbase, i discovered that pressing any key in my app would mysteriously open up one of the search apps.

When an app refuses focus, the focus ends up on the desktop. When a keypress is received by the desktop, this is interpreted as a request to look up contacts beginning with that letter.

Quote:

Originally Posted by lcuk (Post 328807)
this code is at the end of the open window function, it simply forces focus back to the app itself.

I would be a whole lot happier if applications did not attempt to mess with focus and left this to the window manager. That's what we have a window manager for. The ICCCM actually forbids you to do this unilaterally (4.2.7); you're also not supposed to be using RevertToPointerRoot or CurrentTime (see the footnotes of 4.2.7).

Quote:

Originally Posted by lcuk (Post 328807)
since you did not explain the problem and javispedro hasnt actually reproduced the error i think its at least something to consider and see.

I'm not sure why you think I didn't explain the problem, since I went into some detail here.

To recap:
  • A window can have a field called WM_HINTS.
  • One of the bits in this field is called InputHint.
  • If this bit is not set, the window is saying that it never wants input focus. If the window manager was to give such a window focus, the window manager would be broken.
  • libsdl contains a bug which clears this bit if you set an icon on your window.
  • Therefore, if you set an icon on an SDL window, the window manager will never give that window focus.
  • This is correct behaviour on the part of the window manager.
  • On the other hand, if you don't set an icon on the window, it doesn't matter, because Maemo is clever and will get the icon from elsewhere.
  • Therefore, not setting an icon is a perfect workaround until the libsdl bug is fixed.

I don't know whether your program is suffering from a similar bug, but I can check if you like. Or you can check, if you want, by running xprop against your toplevel window.

lcuk 2009-09-18 01:33

Re: BBC Micro
 
Quote:

Originally Posted by marnanel (Post 328944)
When an app refuses focus, the focus ends up on the desktop. When a keypress is received by the desktop, this is interpreted as a request to look up contacts beginning with that letter.

yes

Quote:


I would be a whole lot happier if applications did not attempt to mess with focus and left this to the window manager. That's what we have a window manager for. The ICCCM actually forbids you to do this unilaterally (4.2.7); you're also not supposed to be using RevertToPointerRoot or CurrentTime (see the footnotes of 4.2.7).

cool, i see.
so the workaround as suggested to me originally is due to a generic problem that has been there all along in fremantle, but was obviously handled differently by the n8x0 window manager?


Quote:


I'm not sure why you think I didn't explain the problem, since I went into some detail here.

To recap:
  • A window can have a field called WM_HINTS.
  • One of the bits in this field is called InputHint.
  • If this bit is not set, the window is saying that it never wants input focus. If the window manager was to give such a window focus, the window manager would be broken.
  • libsdl contains a bug which clears this bit if you set an icon on your window.
  • Therefore, if you set an icon on an SDL window, the window manager will never give that window focus.
  • This is correct behaviour on the part of the window manager.
  • On the other hand, if you don't set an icon on the window, it doesn't matter, because Maemo is clever and will get the icon from elsewhere.
  • Therefore, not setting an icon is a perfect workaround until the libsdl bug is fixed.

yes, but the same code in liqbase runs perfectly on diablo, i gather likewise for yourself the code seem to work properly for SDL on diablo too?

Quote:


I don't know whether your program is suffering from a similar bug, but I can check if you like. Or you can check, if you want, by running xprop against your toplevel window.
thanks :)

the version in extras-devel is unstable atm, its just waiting for me to push some updates after a short trip, but since you know what you are looking for, if you identify the patch point, I would be most appreciative.
if it can be solved in a similar way to your fix - ie once for the entire app run, it will hopefully cure the other secondary liqbase problem where the symptoms of no text input return after minimizing.

i'm sorry i didnt see the reasoning beforehand, i just saw the same symptoms and knew a fairly simple workaround existed.

marnanel 2009-09-18 13:14

Re: BBC Micro
 
Quote:

Originally Posted by lcuk (Post 328965)
so the workaround as suggested to me originally is due to a generic problem that has been there all along in fremantle, but was obviously handled differently by the n8x0 window manager?

I don't know how the N8x0 window manager handled it, but I imagine it was in a similar way. The fault is not with the window manager but with libsdl. It is possible (probable, indeed) that the version of libsdl on the N8x0 did not contain the bug, and so the issue never came up.

Quote:

Originally Posted by lcuk (Post 328965)
yes, but the same code in liqbase runs perfectly on diablo, i gather likewise for yourself the code seem to work properly for SDL on diablo too?

I don't know whether it worked on diablo. I'm afraid I've never used any Nseries operating system but fremantle.

Quote:

Originally Posted by lcuk (Post 328965)
the version in extras-devel is unstable atm, its just waiting for me to push some updates after a short trip, but since you know what you are looking for, if you identify the patch point, I would be most appreciative.
if it can be solved in a similar way to your fix - ie once for the entire app run, it will hopefully cure the other secondary liqbase problem where the symptoms of no text input return after minimizing.

Thanks, I'll take a look.

Jaffa 2009-09-21 11:11

Re: BBC Micro
 
Quote:

Originally Posted by marnanel (Post 328123)
[*]Even if Beebem was free software, it's still unclear about the legality of distributing the Beeb's MOS and BASIC roms, without which the emulator would be useless;

IIRC, RISCOS Ltd. have given permission for the distribution of BBC MOS and RISC OS 3.1 ROMs for the use of emulators.

The problem with Elite would be the keys - the keyboard of an N900 is better than an N810's, but it ain't that good.

Perhaps emulators (including DrNokSnes) could have a mapping from the accelerometers to keys on a game-by-game basis :-)

marnanel 2009-11-28 22:26

Re: BBC Micro
 
I have modified the emulator a bit so it runs more smoothly on the device. So there are four things I want to sort out before I release anything.
  1. The upstream licensing of Beebem. But this has been verified to be GPL, so we're okay.
  2. What to do about the ROMs which the emulator needs to boot. I might add a screen on first running the emulator which explains that they need to be downloaded, and requires the user to consent to doing so. (That could be extended to a generalised disc image downloader, later.) On the other hand, I might release an early version and require people to find the ROMs themselves and install them manually.
  3. Remapping the hardware keyboard to match the BBC's somehow.
  4. Replacing the beebem menu system with Hildon menu widgets.

For the hardware keys, I'm thinking of turning the N900's comma key into an extra shift (I'll call it "ultra" here), so that the keystrokes which don't exist on the N900 can be typed for the Beeb (most importantly, so that ultra-[P/0] can be f0, ultra-[Q/1] can be f1, etc.

Here, have another screenshot. This has the processor speed of the Beeb turned right down so that the FPS will be higher.
http://marnanel.org/pics/lj/elite

marnanel 2009-11-28 22:28

Re: BBC Micro
 
Quote:

Originally Posted by Jaffa (Post 330622)
IIRC, RISCOS Ltd. have given permission for the distribution of BBC MOS and RISC OS 3.1 ROMs for the use of emulators.

Really‽ That's wonderful! Do you have a link I can point people to, or anything like that?

Jaffa 2009-11-29 13:47

Re: BBC Micro
 
Quote:

Originally Posted by marnanel (Post 398169)
Really‽ That's wonderful! Do you have a link I can point people to, or anything like that?

Unfortunately, Googling for anything involving "ROM" isn't very productive and I can't find any source.

marnanel 2010-01-07 03:28

Re: BBC Micro
 
I've now put a few minutes into packaging the thing; it's here:

http://people.collabora.co.uk/~tthur...01-1_armel.deb

It works well enough to boot and load discs, but not well enough to do much else. I've turned off AMX (mouse) support and made the main menu come up instead when you tap the screen, because beforehand it came up on F12.

Try this: boot the BBC. Touch the screen. Choose "Discs". Choose "Select, load, and run a disc". Select "welcome.ssd". Press OK. You will be running the Welcome disk.

Note that the default screen size cuts off the bottom of the menus and the screen on the N900, unless you run in fullscreen mode, when it fits exactly. This can be a nuisance, because you might not be able to press the OK button on the menus. See points 3 and 4 below.

Things which fairly urgently need doing with this:

1) I've found copies of Beebem which say they're GPL and copies which say they aren't. I'd like to know for sure when its status changed.

2) Really, I'd like it to download the MOS/BASIC/DFS roms on first boot, to save us having to package them.

3) It would be better if the main window was a GTK window than an SDL window. Then we could put a conventional Hildon menu on it and do away with the tapping-the-screen thing.

4) A screen mode that scaled the BBC's output onto the size of the screen *minus* the titlebar would be very useful.

5) The keyboard setup is a bit crappy at the moment. The N900's alt key doesn't work at all, so you can't type numbers. I meant to have it so that the comma key was a "hyper" key to let you use QWE... as f1, f2, f3... but that seems not to be working at present.

6) It should default to a sensible speed; the current default slows down the BBC too much, making everything sluggish.

7) What I would really like is a menu when you started up which listed a few dozen games, and if you chose one it didn't already have installed it would download it.

8) An onscreen virtual keyboard would be lovely.

KristianW 2010-01-29 20:56

Re: BBC Micro
 
Quote:

Originally Posted by Jaffa (Post 330622)
IIRC, RISCOS Ltd. have given permission for the distribution of BBC MOS and RISC OS 3.1 ROMs for the use of emulators.
- - -

http://www.riscosopen.org/wiki/docum...Cortex-A8+port
>>
Documentation: Cortex-A8 port
This section of the wiki documents contains information about the port of the shared-source branch of RISC OS to the new ARM Cortex-A8 processors.

http://www.riscosopen.org/news/artic...o-beagle-board
>>
Info on beagleboard port of RISC OS.

Jaffa 2010-01-31 16:27

Re: BBC Micro
 
Indeed, taking RISC OS Open's branch and running it on an RPCemu port would be good (hell, even porting RISC OS directly ;-))

But this isn't a thread about RISC OS :-)

Might be worth checking if !65host (including the BBC MOS ROMs) is included in the RISC OS Open shared source bundle.


All times are GMT. The time now is 13:48.

vBulletin® Version 3.8.8