SDL_Surface format

In my opinion, one of the most serious limitations of Matrix Brandy is not being able to display proportional-spaced text, in an arbitrary font.

I thought I had found a neat solution: now the native SDL_Surface pointer is exposed, and there is support for calling shared objects (e.g. DLLs in Windows), I should be able to use the functions in SDL2_ttf to blit proportional-spaced characters to Matrix Brandy's canvas.

But it doesn't work. After some frustrating debugging I discovered why: annoyingly (and for no obvious reason) SDL 1.2's surfaces are in a different format from SDL 2.0's surfaces! So the blit operation inevitably fails, because it's trying to blit a SDL 2.0 surface onto a SDL 1.2 surface. :(

Trying to munge an SDL 2.0 surface into an SDL 1.2 surface, in BASIC, would be messy and probably hit performance too severely. So I've come to rather a dead end - unless Matrix Brandy could be modified. I think porting it to SDL 2.0 has been discussed, so is that a possibility?

Comments

  • I have briefly looked at it, though graphsdl.c will need a considerable rewrite as will keyboard.c.

    There is also an SDL_ttf library which I believe is intended to be used against libSDL-1.2 but to be fair I have never played with it.

    The display architecture of Matrix Brandy uses two layers, one is "modescreen", which has the pixel dimensions of the mode being displayed (e.g. MODE 2 has a 160x256 surface), and the actual surface that is blitted to the screen is a scaled up version such that MODEs 0, 1, 2, 4, 5 (and others) use 640x512 and blit_scaled does the upscaling based on the screen mode. if you write directly to the outermost layer it is likely to get splatted by the blit-scaler from modescreen, and writing to modescreen needs to take into account any scaling. (MODEs 18-21, 25-28 are mapped 1:1)
  • Soruk wrote: »
    There is also an SDL_ttf library which I believe is intended to be used against libSDL-1.2
    I know, but it hasn't been updated in years and is no longer a viable option in my opinion. Even SDL2_ttf has changed significantly over time, and in its latest incarnation integrates HarfBuzz in order to support rendering complex scripts (e.g. Arabic). I am trying to move forwards, not backwards!
    The display architecture of Matrix Brandy uses two layers
    Am I right in thinking that this is only to support MODEs 3 and 6, i.e. the ones which, on the BBC Micro, have (hardware generated) 'gaps' between the rows? In every other mode, in which the final display is simply a scaled version of what's in the bitmap, you could get SDL2 to do that for free in the GPU without an extra layer.

    That's one of the reasons why in my BASICs (which of course are not designed to be 'emulators') MODEs 3 and 6 do not have 'gaps', and indeed you can happily draw graphics in them! They only differ from the other modes in having an artificially-increased row spacing.
    if you write directly to the outermost layer it is likely to get splatted by the blit-scaler
    I understood, from what you said when you exposed the native SDL_Surface pointer, that I can stop that happening by using *REFRESH OFF. So for example to label graph axes using proportional-spaced (and anti-aliased, in a suitable MODE) text I would first draw the BASIC graphics, then disable automatic refresh, then blit the text.

    There's not a lot of point exposing the surface pointer if you can't actually use it to blit to the 'screen'!