BltTemplate strange problem..
  • o1i
  • Cocoon
    Cocoon
    Posts: 53 from 2003/2/25
    I admit that I have never done anything with MorphOS before, but maybe it's not too late.

    I have some old software that should actually run under MorphOS, but it causes problems if it doesn't run on its own screen.

    I have narrowed it down to a problem with a BltTemplate() call, but I don't understand why it shouldn't work.

    This is how I would expect it to work: AmigaOS 3.1 screenshot

    And this in with MorphOS: MorphOS screenshot

    Sorry for the long listing, but I am hunting down that problem now for quite some time..

    Code:

    #include <exec/types.h>
    #include <intuition/intuition.h>
    #include <graphics/gfx.h>
    #include <graphics/rastport.h>
    #include <graphics/gfxbase.h>
    #include <proto/intuition.h>
    #include <proto/graphics.h>
    #include <proto/exec.h>

    /* 16x16 1-bit template pattern */
    UWORD pattern[] =
    {
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555,
    0xAAAA,
    0x5555
    };

    int main()
    {
    struct Window *win;

    win = OpenWindowTags(NULL,
    WA_Title, "BltTemplate Example",
    WA_Width, 320,
    WA_Height, 200,
    WA_CloseGadget, TRUE,
    WA_DepthGadget, TRUE,
    WA_DragBar, TRUE,
    WA_Activate, TRUE,
    WA_IDCMP, IDCMP_CLOSEWINDOW,
    WA_Flags, WFLG_SMART_REFRESH | WFLG_GIMMEZEROZERO,
    TAG_DONE);

    if (!win)
    return 0;

    struct RastPort *rp = win->RPort;
    /* Set drawing colors */
    SetAPen(rp, 1);
    SetBPen(rp, 0);

    /* Draw template at (50,50) */
    BltTemplate(
    pattern, /* template */
    0, /* source x offset */
    16/8, /* bytes per row */
    rp,
    50, 50, /* destination */
    16, 16 /* width, height */
    );

    /* Wait until window close */
    BOOL running = TRUE;
    while (running)
    {
    struct IntuiMessage *msg;

    WaitPort(win->UserPort);

    while ((msg = (struct IntuiMessage *)GetMsg(win->UserPort)))
    {
    if (msg->Class == IDCMP_CLOSEWINDOW)
    running = FALSE;

    ReplyMsg((struct Message *)msg);
    }
    }

    CloseWindow(win);

    return 0;
    }


    Of course one can write cleaner code, but I wanted to come up with some minimal code to test. There is a major thing going wrong here, I can't figure out.

    Any ideas?

    (I guess I am doing something really stupid..)

    If it makes any difference: AmigaOS runs in WinUAE, MorphOS in qemu.
  • »05.03.26 - 14:30
    Profile
  • o1i
  • Cocoon
    Cocoon
    Posts: 53 from 2003/2/25
    One other thing:

    This program works surprisingly, if another application opened a screen before (Flowstudio on its own screen).

    I don't touch the new screen, same executable as above. The program still opens on the Amibient screen as before, but it now works:

    blt-morphos-ok.png

    !?!?
  • »05.03.26 - 14:56
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3265 from 2003/3/5
    From: Canada
    We've tried this on real unemulated hardware and it looks as expected. Emulated sm501 seems fine as well. I'm guessing you're using Radeon emulation? That'd be something to take up with the QEmu maintainer.
  • »05.03.26 - 16:13
    Profile Visit Website
  • o1i
  • Cocoon
    Cocoon
    Posts: 53 from 2003/2/25
    So simple it can be .. facepalm. Thanks for testing and your quick reply!

    Starting emulation with -device sm501 seems really to fix it.

    I would have not expected such a bug having such a small impact to the normal system. It only seems to affect BltBitmap(), which seems not to be used much if at all in normal MorphOS code (understandable). But it is used for rendering old style gadgets, not even the text of the gadgets (radio buttons, listviews..) gets blitted correctly..

    I'll report the bug.
  • »05.03.26 - 18:14
    Profile