i have made some cool demo with Gendev ( PCM , Sprite , joypad , etc.. ).
But i'm looking a way to apply a Raster effect in picture with this SDK.
maybe someone have a source exemple ?
Thanks a lot

Moderator: Stef

 You can simulate a rotation effect (with a limited angle amplitude though). You can even improve the 2 cells vertical resolution by combining 2 plans and so get cell based vertical scroll.
 You can simulate a rotation effect (with a limited angle amplitude though). You can even improve the 2 cells vertical resolution by combining 2 plans and so get cell based vertical scroll.


Code: Select all
u32 vscroll;
...
void myHBlankFunction()
{
   // modify V scroll value
   VDP_setVerticalScroll(APLAN, 0, vscroll >> 8);
   vscroll += 0x30;
}
...
void main() {
   ...
  // define method to call on HInt / HBlank
  setHBlankCallback(myHBlankFunction);
  // want H Int on each scanline
  VDP_setHIntCounter(1);
  // enable H Int
  VDP_setHInterrupt(1);
  vscroll = 0;
  ...
  while(1);
}
Code: Select all
#include "genesis.h"
#include "prelude.h"
extern u16 title_pal[];
extern u32 title_tiles[];
u32 vscroll;
void intro()
{
    VDP_resetScreen();
    VDP_setPalette(0, (u16 *) title_pal);
    VDP_doVRamDMA( (u32) title_tiles, 32, 21760);
    VDP_fillTileMapRectInc(BPLAN, TILE_ATTR(0, 0, 0, 0) + (32/32),0,0,320/8,136/8);
    startPlay_4PCM(prelude, sizeof(prelude), AUDIO_PCM_CH1, 1);//
}
void myHBlankFunction()
{
    // modify V scroll value
    VDP_setVerticalScroll(APLAN, 0, vscroll >> 8);
    vscroll += 0x30;
}
int main()
{
    intro();
    // define method to call on HInt / HBlank
    setHBlankCallback(myHBlankFunction);
    // want H Int on each scanline
    VDP_setHIntCounter(1);
    // enable H Int
    VDP_setHInterrupt(1);
    vscroll = 0;
    while(1)
    {
        VDP_waitVSync();
    }
    return 0;
}
Code: Select all
    vu16 *pw;
    vu32 *pl;
    u16 addr;
    for (counter = 0; counter < 224; counter+=2)
    {
        pw = (u16 *) GFX_DATA_PORT;
        pl = (u32 *) GFX_CTRL_PORT;
        addr=counter+1;//lets say counter is zero this will tell it to pick line 1 to become line zero in the end
    *pl = GFX_WRITE_VSRAM_ADDR(addr);
    *pw = counter;
    }
Code: Select all
const u32 vscroll_data[] =
{
//line 0
0,
//line 1
2047,
//line 1 realy 2
2047,
//line 3
2046,
//line 3
2046,
//line 5
2045,
//line 5
2045,
//line 7
2044,
//line 7
2044,
//line 9
2043,
//line 9
2043,
//line 11
2042,
//line 11
2042,
//line 13
2041,
//line 13
2041,
//line 15
2040,
//line 15
2040,
//line 17
2039,
//line 17
2039,
//line 19
2038,
//line 19
2038,
//line 21
2037,
//line 21
2037,
//line 23
2036,
//line 23
2036,
//line 25
2035,
//line 25
2035,
//line 27
2034,
//line 27
2034,
//line 29
2033,
//line 29
2033,
//line 31
2032,
//line 31
2032,
//line 33
2031,
//line 33
2031,
//line 35
2030,
//line 35
2030,
//line 37
2029,
//line 37
2029,
//line 39
2028,
//line 39
2028,
//line 41
2027,
//line 41
2027,
//line 43
2026,
//line 43
2026,
//line 45
2025,
//line 45
2025,
//line 47
2024,
//line 47
2024,
//line 49
2023,
//line 49
2023,
//line 51
2022,
//line 51
2022,
//line 53
2021,
//line 53
2021,
//line 55
2020,
//line 55
2020,
//line 57
2019,
//line 57
2019,
//line 59
2018,
//line 59
2018,
//line 61
2017,
//line 61
2017,
//line 63
2016,
//line 63
2016,
//line 65
2015,
//line 65
2015,
//line 67
2014,
//line 67
2014,
//line 69
2013,
//line 69
2013,
//line 71
2012,
//line 71
2012,
//line 73
2011,
//line 73
2011,
//line 75
2010,
//line 75
2010,
//line 77
2009,
//line 77
2009,
//line 79
2008,
//line 79
2008,
//line 81
2007,
//line 81
2007,
//line 83
2006,
//line 83
2006,
//line 85
2005,
//line 85
2005,
//line 87
2004,
//line 87
2004,
//line 89
2003,
//line 89
2003,
//line 91
2002,
//line 91
2002,
//line 93
2001,
//line 93
2001,
//line 95
2000,
//line 95
2000,
//line 97
1999,
//line 97
1999,
//line 99
1998,
//line 99
1998,
//line 101
1997,
//line 101
1997,
//line 103
1996,
//line 103
1996,
//line 105
1995,
//line 105
1995,
//line 107
1994,
//line 107
1994,
//line 109
1993,
//line 109
1993,
//line 111
1992,
//line 111
1992
};
    for (counter = 1; counter <= 112; counter++)
    {
    pw = (u16 *) GFX_DATA_PORT;
    pl = (u32 *) GFX_CTRL_PORT;
    addr=counter;
    *pl = GFX_WRITE_VSRAM_ADDR(addr);
    *pw = vscroll_data[counter];
    }
Yep, the void what i stupid typo i left when i copied the function name from the header file :pbastien wrote:Thanks for this code, but i have tested it with a simple code exemple and it's do nothing...
maybe i have missed something ?
i have removed the void before "setHBlankCallback(myHBlankFunction);" for deleted a warning in compliation message.Code: Select all
#include "genesis.h" #include "prelude.h" ....

Code: Select all
void myHBlankFunction()
{
    if (line == 224)
    {
        line=0;
        vscroll=0x800;
        the_scroll=0;
    }
    if (the_scroll == 1)
    {
        the_scroll=0;
        vscroll--;
    }
    else
    {
        the_scroll=1;
    }
   //VDP_setVerticalScroll(APLAN, 0, 0x07A0);
    vu16 *pw;
    vu32 *pl;
    //u16 addr;
    /* Point to vdp port */
    pw = (u16 *) GFX_DATA_PORT;
    pl = (u32 *) GFX_CTRL_PORT;
    //addr = (cell & 0x1F) * 4;
    //if (plan == BPLAN) addr += 2;
    *pl = GFX_WRITE_VSRAM_ADDR(/*addr*/0);
    //*pw = vscroll;
    *pw = vscroll;
    line++;
}