Page 36 of 57

Posted: Tue Sep 25, 2012 4:50 pm
by djcouchycouch
That's what I had tried last night (changing the defines and VDP_Init() and rebuilding the lib) but it didn't work. It was also the last thing I had tried before going to bed so maybe I missed something because I was tired.

Posted: Tue Sep 25, 2012 8:05 pm
by Stef
Strange, it should work if you modify both part...
In the next version vdp_init() will use the constant, also i should probably change the window location... maybe put it at same position than plan A ?

Edit: Getting hand in sega docs, the window use a fixed plan size of 32x32 tile in H32 mode and 64x32 in H40 mode so the size is not related to plan A...
So i have to keep enough place for the biggest possible window : 64x30 (we can ignore the 2 last tile lines as they are never visibles).
So WPLAN will be set to 0xA900 to not conflict with sprites nor hscroll.

Posted: Tue Sep 25, 2012 8:30 pm
by djcouchycouch
Stef wrote:In the next version vdp_init() will use the constant, also i should probably change the window location... maybe put it at same position than plan A ?
I'd say no. My current plan is to use the Window plane for UI and having them shared is going to seriously impact the Goplanes scrolling code. But if it doesn't work for me, I'll just change them.

Instead of hardcoding values, how about giving the user the option of choosing the memory locations and/or size of the planes?

something like VDP_Init(APlane_size, BPLane_Size, WPLane_size) or VDP_Init(APlane_memoryaddr, BPLane_memoryaddr, WPLane_memoryaddr)

I donno.

Posted: Tue Sep 25, 2012 8:37 pm
by Stef
djcouchycouch wrote:
Stef wrote:In the next version vdp_init() will use the constant, also i should probably change the window location... maybe put it at same position than plan A ?
I'd say no. My current plan is to use the Window plane for UI and having them shared is going to seriously impact the Goplanes scrolling code. But if it doesn't work for me, I'll just change them.

Instead of hardcoding values, how about giving the user the option of choosing the memory locations and/or size of the planes?

something like VDP_Init(APlane_size, BPLane_Size, WPLane_size) or VDP_Init(APlane_memoryaddr, BPLane_memoryaddr, WPLane_memoryaddr)

I donno.
Making non constant values for that will slow down significantly some methods :-/ But that is an idea to keep as indeed it would be more convenient this way, and using variables would limit the speed loss.
I edited my previous post, now the window will be located at 0xA900 which is enough for all case... we lost some tiles but i think that stay acceptable for almost case.

Posted: Wed Sep 26, 2012 2:40 am
by lingh
djcouchycouch, do you add compiled lib to libmd.a?

Posted: Wed Sep 26, 2012 1:43 pm
by djcouchycouch
lingh wrote:djcouchycouch, do you add compiled lib to libmd.a?
After doing the code changes, I run he suggested command for building SGDK:

%GDK_WIN%\bin\make -f %GDK_WIN%\makelib.gen

Then I build Goplanes with:

%GDK_WIN%\bin\make -f %GDK_WIN%\makefile.gen

Isn't that all I should be doing?

Posted: Sun Sep 30, 2012 10:40 pm
by djcouchycouch
Stef wrote: So WPLAN will be set to 0xA900 to not conflict with sprites nor hscroll.
what's the value used for WPLAN in VDP_Init()? You didn't change anything else?

Posted: Tue Oct 09, 2012 1:16 pm
by doragasu
Is there a tutorial/makefile/whatever about building SGDK library and tools under Linux? Right now I have working m68k-elf binutils and compiler. What's next?

Posted: Tue Oct 09, 2012 3:43 pm
by Stef
djcouchycouch wrote:
Stef wrote: So WPLAN will be set to 0xA900 to not conflict with sprites nor hscroll.
what's the value used for WPLAN in VDP_Init()? You didn't change anything else?

I modified the vdp.h like this :

Code: Select all

#define WPLAN                   0xA900
#define HSCRL                   0xB800
#define SLIST                   0xBC00
#define APLAN                   0xC000
#define BPLAN                   0xE000

...

/**
 *  \def TILE_SPACE
 *      Space in byte for tile in VRAM.
 */
#define TILE_SPACE              WPLAN


and the VDP_Init() :

Code: Select all

void VDP_init()
{
    ...

    regValues[0x00] = 0x04;             /* reg. 0 - Disable HBL */
    regValues[0x01] = 0x74;             /* reg. 1 - Enable display, VBL, DMA + VCell size */
    regValues[0x02] = APLAN / 0x400;    /* reg. 2 - Plane A =$30*$400=$C000 */
    regValues[0x03] = WPLAN / 0x400;    /* reg. 3 - Window  =$2C*$400=$B000 */
    regValues[0x04] = BPLAN / 0x2000;   /* reg. 4 - Plane B =$7*$2000=$E000 */
    regValues[0x05] = SLIST / 0x200;    /* reg. 5 - sprite table begins at $BC00=$5E*$200 */
    regValues[0x06] = 0x00;             /* reg. 6 - not used */
    regValues[0x07] = 0x00;             /* reg. 7 - Background Color number*/
    regValues[0x08] = 0x00;             /* reg. 8 - not used */
    regValues[0x09] = 0x00;             /* reg. 9 - not used */
    regValues[0x0A] = 0x01;             /* reg 10 - HInterrupt timing */
    regValues[0x0B] = 0x00;             /* reg 11 - $0000abcd a=extr.int b=vscr cd=hscr */
    regValues[0x0C] = 0x81;             /* reg 12 - hcell mode + shadow/highight + interlaced mode (40 cell, no shadow, no interlace) */
    regValues[0x0D] = HSCRL / 0x400;    /* reg 13 - HScroll Table =$2E*$400=$B800 */
    regValues[0x0E] = 0x00;             /* reg 14 - not used */
    regValues[0x0F] = 0x02;             /* reg 15 - auto increment data */
    regValues[0x10] = 0x11;             /* reg 16 - scrl screen v&h size (64x64) */
    regValues[0x11] = 0x00;             /* reg 17 - window hpos */
    regValues[0x12] = 0x00;             /* reg 18 - window vpos */

    ...
}
This is the only changes i made.

Posted: Tue Oct 09, 2012 3:46 pm
by Stef
doragasu wrote:Is there a tutorial/makefile/whatever about building SGDK library and tools under Linux? Right now I have working m68k-elf binutils and compiler. What's next?
Just use the following command to build the library :

<GDK_DIR>/bin/make -f <GDK_DIR>/makelib.gen

Unfortunately, tools are not yet all converted in C so you can't have all them...

Posted: Wed Oct 10, 2012 8:41 am
by Mixail
How to enable the Light Gun?
(How to include Light Gun support?)

Posted: Wed Oct 10, 2012 9:27 am
by doragasu
Stef wrote:Just use the following command to build the library :

<GDK_DIR>/bin/make -f <GDK_DIR>/makelib.gen

Unfortunately, tools are not yet all converted in C so you can't have all them...
Thanks. I had a look to that makefile, but I'm missing some tools and I think I'll have to modify it a bit to match tool directories in my machine.

Posted: Wed Oct 10, 2012 11:57 am
by Stef
doragasu wrote: Thanks. I had a look to that makefile, but I'm missing some tools and I think I'll have to modify it a bit to match tool directories in my machine.
You normally have some sources in the 'tools' directory but you will see that some are missing.

Posted: Wed Oct 10, 2012 7:37 pm
by Chilly Willy
Mixail wrote:How to enable the Light Gun?
(How to include Light Gun support?)
The example shows how to use the lightgun, but the general outline is:

Check for a lightgun using JOY_getPortType()

If there is a lightgun, enable support using JOY_setSupport()

The lightgun will then be read during the vblank like the controllers. Read the lightgun using the normal JOY_readJoypad() for the buttons, and use JOY_readJoypadX()/JOY_readJoypadY() to get the screen coords of the gun.

Note that the Menacer and Justifier have slightly different ranges for coords that the SDK doesn't mess with - it's up to the programmer to interpret the coords properly for different guns. Read the docs on lightguns for details on the coords, or use the joy example to see what coords return across the screen.

The Justifier sets buttons values for START and A, while the Menacer sets buttons for START, A, B, and C.

Also note that there's no way to auto-detect the extra Justifier gun - use the set support command to turn on one gun or two gun support depending on what your game needs or what the user selects in the menu.

Posted: Thu Oct 11, 2012 10:56 am
by Mixail

Code: Select all

#include "genesis.h"

int main(){
    VDP_setScreenWidth320();
    VDP_setHInterrupt(0);
    VDP_setHilightShadow(0);
    VDP_setPaletteColor(PAL1, 15, 0x0888);
    VDP_setTextPalette(0);

JOY_setSupport(PORT_1, JOY_SUPPORT_MENACER);
  
  while(1)
    {
       		
		u16 value2 = JOY_readJoypad(JOY_1);
		
switch (value2 >> JOY_TYPE_SHIFT)
        {
            case JOY_TYPE_MENACER:
				VDP_drawText("GUN", 20, 20);break;}

        VDP_waitVSync();
    }
}
not working =(

What did I do wrong?