Change custom screen bitmap's doesn't work on MorphOS
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Hi.

    I'm writting a simple game engine, aimed to be compatible with classic Amiga and MorphOS (and probably ported for iPhone also). My first implementation use a bitmap for rendering, this bitmap is copied to screen bitmap when all operations are performed, but it doesn't work too fast on my A600 with ACA 630/25mhz. I have tested examples of double buffering from Amiga developer cd and aminet, and i'm getting problems to make it work on MorphOS, i know that exists other methods to perform double buffering, but this method works on AOS 2.0, the problem is that it doesn't work on MorphOS, but it works perfectly on EUAE with WB3.1.

    I have opened a screen, allocated a bitmap for double buffering, and then i tried to change screen structure from my custom screen, but the bitmap isn't changed, the example from Amiga developer cd that uses this system to perform double buffer doesn't work on MorphOS.

    This is the code that changes the screen bitmap.

    Code:

    scr->RastPort.BitMap = fb->bm->bitmap;
    MakeScreen(scr);
    RethinkDisplay();


    This double buffering system doesn't work for some reason?

    EDITED:

    I just finished to implement the double buffer on my code, and it works perfectly on my Amiga 600 and EUAE, but on MorphOS i got corrupted bitmaps, but it's strange, because i made a screenshot with Personal Paint, and the screen isn't corrupted.

    Here is the code if anyone wants to try it.

    engine.lha

    [ Edited by BalrogSoft 14.11.2011 - 17:39 ]
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »14.11.11 - 13:01
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    Such hack (poking the bitmap pointer inside the screen's rastport) was never supported by RTG. I think it would also fail on EUAE if you were running P96 there.

    If you want to support AmigaOS 2.x and up, the usual method to achieve multibuffering is to use ScrollVPort() on a double height screen.
    It should also be faster than calling RethinkDisplay().
  • »14.11.11 - 18:47
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Aha, so this hack isn't supported, i will test another double buffer system like ScrollVPort, but this technique is used also on doublebuffer example found on NDK 2.0.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »14.11.11 - 18:53
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1516 from 2003/2/24
    From: Finland
    Quote:


    bm->bitmap = AllocBitMap(w, h, d, 0, (struct BitMap*)bf);
    InitBitMap(bm->bitmap,d,w,h);



    I dont think it is good idea at all call InitBitMap() after AllocBitMap(). You dont need InitBitMap() here at all.
    1 + 1 = 3 with very large values of 1
  • »14.11.11 - 20:40
    Profile
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    I know CBM documented that as the way to go but this is really madness... Even the autodoc warns RethinkDisplay() can take up to several milliseconds! I guess this happen when you have many screens and/or complex copperlists.

    While ScrollVPort() is nearly instant. But you need to synchronize yourself using WaitBOVP().

    NB: do not use WaitTOF() as it lacks a viewport argument and you can't predict how it will be implemented when running on non-50Hz displays.

    NB2: And, of course, better use v39 multibuffering functions if you don't want to support AmigaOS v2.0 :) As they give you even better synchronisation, triple-buffering and so even higher possible framerate.
  • »14.11.11 - 20:57
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Yes, InitBitmap isn't need anymore, thanks.

    I have implemented double buffer with ScrollVPort, and it works everywhere and very fast on my Amiga 600.

    At the moment i will not change the double buffer system, but maybe i will update it for wb 3.0 in the future.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »14.11.11 - 22:30
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    I'm having problems yet. The double buffer with ScrollVPort isn't working on MorphOS. It works perfectly on my Amiga 600 and EUAE, but i can't change the viewport position on MorphOS. I will explain how i made it because i'm not sure if it's the correct way to implement double buffer. I have created a displayable bitmap with the screen height doubled, and then i have opened a screen with these flags: CUSTOMSCREEN|SCREENQUIET|CUSTOMBITMAP

    Code:

    fb->bm = bm_create_disp(width, height*2, depth);

    newScreen.LeftEdge = 0;
    newScreen.TopEdge = 0;
    newScreen.Width = width;
    newScreen.Height = height;
    newScreen.Depth = depth;
    newScreen.DetailPen = 0;
    newScreen.BlockPen = 0;
    newScreen.ViewModes = NULL;
    newScreen.Type = CUSTOMSCREEN | SCREENQUIET | CUSTOMBITMAP;
    newScreen.Font = NULL;
    newScreen.DefaultTitle = NULL;
    newScreen.Gadgets = NULL;
    newScreen.CustomBitMap = fb->bm->bitmap;

    fb->screen = OpenScreen(&newScreen);


    The screen height is not doubled, here is my first doubt, i'm not sure if this is correct, because the viewport structure of the screen haven't double height.

    Then i have made the double buffer changing the RasInfo->RyOffset value, and executing ScrollVPort and WaitBOVP, but it don't work on MorphOS. Here is the code:

    Code:

    fb->screen->ViewPort.RasInfo->RyOffset = fb->frame*fb->height;

    fb->frame ^= 1;
    fb->frameOffset = fb->frame*fb->height;

    ScrollVPort(&fb->screen->ViewPort);
    WaitBOVP(&fb->screen->ViewPort);
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »16.11.11 - 00:46
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Crumb
    Posts: 730 from 2003/2/24
    From: aGaS & CUAZ Al...
    @balrog

    you should add an "if" to check if you are using a cgx bitmap and lock it before writting code. It's simply because CGX may move the bitmap to fastram in some situations and your bitmap pointer may be different in some moments I guess.
  • »16.11.11 - 11:47
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Hi Crumb.

    I think that the scrollvport is not working on MorphOS, i'm making something wrong, i have changed viewport to a fixed viewport position and it doesn't work. I have tested the bitmap with GetCyberMapAttr with parameter CYBERMATTR_ISCYBERGFX and returns false, should it return true?
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »16.11.11 - 15:33
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Crumb
    Posts: 730 from 2003/2/24
    From: aGaS & CUAZ Al...
    I think CYBERMATTR_ISCYBERGFX should be true.

    To get bitmap pointer I use:
    bloqueo=(APTR)LockBitMapTags(*rastportptr->BitMap,LBMI_BASEADDRESS, &direccionbase,TAG_DONE);
  • »16.11.11 - 16:14
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    ScrollVPort() of course works in MorphOS.

    Do not allocate a custom bitmap. You probably badly allocated it anyway and it may be misaligned, using the wrong format or not located in video ram... etc

    Just open a double height screen and scroll into it.
    Something like struct Screen *screen = OpenScreenTags() with SA_HEIGHT equal to 960
    Then screen->Viewport->RasInfo->RyOffset = 480; ScrollVport(screen->ViewPort); WaitBOVP(screen->ViewPort);

    It is that simple.
  • »16.11.11 - 19:26
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Ok, It's working on MorphOS, but i have a strange issue on real Amiga and EUAE, i have doubled the screen height, the height of one buffer is 256 pixels (low pal resolution 320x256) but it shows 262 pixels, another problem to solve...
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »16.11.11 - 20:50
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Crumb
    Posts: 730 from 2003/2/24
    From: aGaS & CUAZ Al...
    check out that you have overscan disabled.
  • »16.11.11 - 21:29
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    I hadn't set the overscan mode, now it works as expected. Thanks a lot.

    [ Edited by BalrogSoft 16.11.2011 - 21:48 ]
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »16.11.11 - 21:48
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Crumb
    Posts: 730 from 2003/2/24
    From: aGaS & CUAZ Al...
    looking forward to a small preview/demo of your game :-)

    perhaps you could write a small diary with a few lines like Andrew Braybrook did with Uridium2? :-)
  • »17.11.11 - 14:29
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Of course, but it is not a game, it's an engine on this moment, i have developed another engine for iPhone, that i have ported to MorphOS also using TinyGL, and i have my game ported also to MorphOS, but this one is propietary source, and i will not release any beta until i finish the game for iPhone. I had to stop development of this game because i had another work to port a j2me game to iPhone, and i have another project for a interactive book for iPad, so i don't have a lot of time to write a blog...

    About the engine, i have a small engine that handles screens, bitmaps, protracker mods, joystick, it can be used for simple games, i will release the source when i have a mature version, but here is a preview demo running a tilemap.

    Engine.lha

    [ Edited by BalrogSoft 17.11.2011 - 15:55 ]
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »17.11.11 - 15:53
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    maybe u can release something "usable" before the deadline of Cammy's "annual amiga competition" ?

    i want to create something for os3.x in c and don't want to learn amos/blitz/E languages :D

    Maybe only the doublebuffer sorces :D

    for the joy and mod replay i can get away myself :)
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »17.11.11 - 17:22
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Crumb
    Posts: 730 from 2003/2/24
    From: aGaS & CUAZ Al...
    The engine requires:
    iff.library
    ptreplay.library
    ptplay.library (because ptreplay.library depends on it)

    Works fine on my Mac Mini :-)

    The scroll is smooth although on real Amigas I always get the feeling it's smoother
  • »17.11.11 - 19:27
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Raistlin: Check pm.

    Crumb:

    I forget to mention the required libs. And yes, the scroll works nice, but i didn't tested on real Amiga yet because i have my A600 CF harddisk unvalidated, and i have lent my mediator to a friend that has his mediator broken. I'm making a backup of my A600 CF with WinUAE, so at the moment i can't test it on real Amiga.

    [ Edited by BalrogSoft 17.11.2011 - 20:34 ]
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »17.11.11 - 20:33
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    thanks again :D
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »18.11.11 - 00:38
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Just one question not related with original topic. I can't get SimpleSprites working on MorphOS, i can change mouse pointer sprite, but it works with all sprites on EUAE. I have added a NewScreen object for OpenScreenTags to modify ViewModes and set it to SPRITES. This is the code:

    Code:


    UWORD chip my_sprite_data[36]=
    {
    0x0000, 0x0000,

    0x0180, 0x0000,
    0x03C0, 0x0000,
    0x07E0, 0x0000,
    0x0FF0, 0x0000,
    0x1FF8, 0x0000,
    0x3FFC, 0x0000,
    0x7FFE, 0x0000,
    0x0000, 0xFFFF,
    0x0000, 0xFFFF,
    0x7FFE, 0x7FFE,
    0x3FFC, 0x3FFC,
    0x1FF8, 0x1FF8,
    0x0FF0, 0x0FF0,
    0x07E0, 0x07E0,
    0x03C0, 0x03C0,
    0x0180, 0x0180,

    0x0000, 0x0000
    };

    struct SimpleSprite my_sprite =
    {
    my_sprite_data,
    16,
    40, 60,
    -1,
    };

    struct SimpleSprite sprite = {0};

    sprite_num = GetSprite(&my_sprite,1);

    .......

    MoveSprite(0, &my_sprite, 40, 50);

    ......

    FreeSprite((WORD)sprite_num);



    [ Edited by BalrogSoft 18.11.2011 - 12:24 ]
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »18.11.11 - 12:13
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Crumb
    Posts: 730 from 2003/2/24
    From: aGaS & CUAZ Al...
    Sprites on RTG? I don't think that will work, you could try with BltMaskBitMapRastPort()
  • »18.11.11 - 12:33
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    I don't know if sprites are supported, but sprite 0 can be used, i have a small sprite running on MorphOS, but i can't get it working other sprites.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »18.11.11 - 12:50
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    Modern (har har) graphic chips only support one "sprite" and it's used for the mouse pointer.
    That may be your sprite 0.

    As a matter of fact, RTG implies not using sprites at all.
    Use the BltBitMap family of functions.
  • »18.11.11 - 15:02
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Thanks Henes, it should be the reason, it was a bit confusing because GetSprite returns the expected result.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »18.11.11 - 21:08
    Profile Visit Website