Sega Genesis Dev Kit (SGDK)
Moderator: Stef
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
You don't necessarily need the tiles in different layers, but they need to go in different places in the tile buffer. Overwriting the old tiles WILL result in tearing if it can't be done in the vblank... and it can't. So the tiles need to be double-buffered over everything else. But your palette handling looks okay now.
Thank you
Ok I double buffered the tiles and it worked perfectly thank you chilly willy and tmEE.
here is the final code:
here is the final code:
Code: Select all
#include "genesis.h"
#include "global.h"
#include "Tubelec.h"
const u8 even = 0;//dma will gltich without this (somehow the program got un-aligned)
#include "road_tiles.h"
#include "road_palletes.h"
void VDP_waitnotVSync()
{
vu16 *pw;
u16 vdp_state;
vdp_state = VDP_VBLANK_FLAG;
pw = (u16 *) GFX_CTRL_PORT;
while (!(vdp_state & VDP_VBLANK_FLAG)) vdp_state = *pw;
while (vdp_state & VDP_VBLANK_FLAG) vdp_state = *pw;
}
void robotnik_3d()
{
stopPlay_2ADPCM(AUDIO_PCM_CH1);
startPlay_2ADPCM((const u8 *)Tubelec, sizeof(Tubelec), AUDIO_PCM_CH1,1);
u8 frame;
frame=0;
//right now all it will be doing is moving the road
VDP_resetScreen();//clear all stuff on the screen
//now put this in a loop
//draw the tiles
while (1)
{
if (frame == 4)
{
frame = 0;
}
//VDP_setPalette(PAL0, (const u16 *)road_palletes+(frame*16));
//VDP_loadTileData( (const u32 *)road_tiles+(frame*5440), 1, 1120, 1);
VDP_waitnotVSync();//dma is faster during vblank I think wait for the vblank (i just edited the vysnc code)
//
//VDP_doVRamDMA((const u32 *)road_tiles+(frame*5440), 32, 21760);
switch (frame)// looks slightly better when I put this after dmaing the tiles
{
case 0:
VDP_doCRamDMA((const u32 *)road_palletes, 0,32);
VDP_doVRamDMA((const u32 *)road_tiles, 32, 21760);
VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(0,0,0,0,1), 0, 11, 40, 17);
break;
case 1:
VDP_doCRamDMA((const u32 *)road_palletes+8, 32,32);
VDP_doVRamDMA((const u32 *)road_tiles+5440, 21792, 21760);
VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(1,0,0,0,681), 0, 11, 40, 17);
break;
case 2:
VDP_doCRamDMA((const u32 *)road_palletes+16, 0,32);
VDP_doVRamDMA((const u32 *)road_tiles+10880, 32, 21760);
VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(0,0,0,0,1), 0, 11, 40, 17);
break;
case 3:
VDP_doCRamDMA((const u32 *)road_palletes+24, 32,32);
VDP_doVRamDMA((const u32 *)road_tiles+16320, 21792, 21760);
VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(1,0,0,0,681), 0, 11, 40, 17);
break;
}
//#define TILE_ATTR_FULL(pal, pri, flipV, flipH, index)
//VDP_fillTileMapRectInc(APLAN, 1, 0, 11, 40, 17);
VDP_waitVSync();
frame++;
}
}
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
Todo so I must edit the makelib.gen and makefile.gen to reflect the changed executable's name (gcc, ar, etc) correct?Chilly Willy wrote:If you're using linux, I suggest making the toolchain in my thread on the topic. Then copy just the SDK source from this mini devkit and use the linux toolchain to compile it.
Were can I find the tools that are included on the SGDK but not on Willy's toolchain?
SHELL=$(BIN)/sh
AR= $(BIN)/m68k-elf-ar
CC= $(BIN)/m68k-elf-gcc
OBJCPY= $(BIN)/m68k-elf-objcopy
ASMZ80= $(BIN)/sjasm
MACCER= $(BIN)/mac68k
SIZEBND= $(BIN)/m68k-elf-size
BINTOC= $(BIN)/bintoc
BINTOS= $(BIN)/bintos
WAVTORAW= $(BIN)/wavtoraw
PCMTORAW= $(BIN)/pcmtoraw
GENRES= $(BIN)/genres
NM= $(BIN)/m68k-elf-nm
NM2WCH= $(BIN)/nm2wch
RM= $(BIN)/rm
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
My own makefile that turns the mini devkit files into a lib looks like this
That assumes GENDEV and the PATH environment vars set as explained in my toolchain thread.
Done that way, you would link md.o first, then the object files for the program, then the libs (including libmd).
bintoc is made by compiling the bintoc source from the devkit and coying the executable to the toolchain binary directory. Zasm is one of a couple Z80 compilers that work fairly well, the other being sjasmplus.
I currently use zasm 3.0.18... the current is 3.0.20. I need to update or move to sjasmplus sometime...
Code: Select all
CC = m68k-elf-gcc
AR = m68k-elf-ar
RANLIB = m68k-elf-ranlib
OBJC = m68k-elf-objcopy
RM = rm -f
ASMZ80 = zasm
BINTOC = bin2c
OPTION= -Dnologo_
libmd.a_OBJS = base.o tools.o vdp.o font.o vdp_bg.o vdp_dma.o \
vdp_pal.o vdp_spr.o vdp_tile.o bitmap.o bitmapx.o z80_ctrl.o \
tab_sin.o tab_log2.o tab_pow2.o maths.o maths3D.o ym2612.o \
psg.o audio.o joy.o timer.o logo_lib.o z80_drv1.o z80_drv2.o \
z80_mvst.o
INCS = -I./include
FLAGS = $(OPTION) -m68000 -Wall -O1 -c -fomit-frame-pointer $(INCS)
FLAGSZ80 = -vb2
all: z80_drv1.o80 z80_drv1.c z80_drv2.o80 z80_drv2.c md.o $(libmd.a_OBJS) libmd.a
%.a: $(libmd.a_OBJS)
$(RM) $@
$(AR) cru $@ $($@_OBJS)
$(RANLIB) $@
%.o80: %.s80
$(ASMZ80) $(FLAGSZ80) -o $@ -i $<
%.c: %.o80
$(BINTOC) $<
%.o: %.c
$(CC) $(FLAGS) -c $< -o $@
%.o: %.s
$(CC) $(FLAGS) -c $< -o $@
clean:
$(RM) -rf *.o *.a *.o80 *.log
$(RM) -f z80_drv1.c z80_drv1.h z80_drv2.c z80_drv2.h
install: all
cp include/*.h $(GENDEV)/include
cp libmd.a $(GENDEV)/lib
cp md.o $(GENDEV)/lib
Done that way, you would link md.o first, then the object files for the program, then the libs (including libmd).
bintoc is made by compiling the bintoc source from the devkit and coying the executable to the toolchain binary directory. Zasm is one of a couple Z80 compilers that work fairly well, the other being sjasmplus.
I currently use zasm 3.0.18... the current is 3.0.20. I need to update or move to sjasmplus sometime...

Is your makefile correct on line 12? when running it i get
Code: Select all
jaerder@jaerder-G50V:~/development/MD_sgdk/TMP/sgdk$ make
Makefile:12: *** missing separator. Stop.
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
I was looking into using the vblank for updating the screen and anyways is it posible to set _VBL to goto a c function
what does _vblank_callback do I searched for it in sega.s but that was the only reference were is it jumping to?
_VBL:
movem.l %d0-%d1/%a0-%a1,-(%sp)
jsr _vblank_callback
movem.l (%sp)+,%d0-%d1/%a0-%a1
rte
what does _vblank_callback do I searched for it in sega.s but that was the only reference were is it jumping to?
_VBL:
movem.l %d0-%d1/%a0-%a1,-(%sp)
jsr _vblank_callback
movem.l (%sp)+,%d0-%d1/%a0-%a1
rte
you should look at
the cube_flat demo uses it, if you want to see how it works
Code: Select all
void setVBlankCallback(_voidCallback *CB)
GLITCH
I just found a glitch and a fix to VDP_setTileMapRect
while (j--) *pwdata = basetile | *src++;
should be:
while (j--) *pwdata = basetile + *src++;
that fixed the tile map drawing problem were the tiles mess up
while (j--) *pwdata = basetile | *src++;
should be:
while (j--) *pwdata = basetile + *src++;
that fixed the tile map drawing problem were the tiles mess up
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Someone already reported me this as a bug, but that's definitely not.
"basetile" is intented to be a default mask to define defaut tile property (palette, flip, priority...) and not a base tile index. I guess i should rename that parameter to avoid confusion.
*src should contain specific tile property and the complete index number.
Maybe i should redesign this method to add an extra parameter so we have "baseTileValue" and "baseTileIndex" so you can define your fixed properties (palette, flip etc...) and the base tile index.
"basetile" is intented to be a default mask to define defaut tile property (palette, flip, priority...) and not a base tile index. I guess i should rename that parameter to avoid confusion.
*src should contain specific tile property and the complete index number.
Maybe i should redesign this method to add an extra parameter so we have "baseTileValue" and "baseTileIndex" so you can define your fixed properties (palette, flip etc...) and the base tile index.
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
Leave the current function alone and make a new one that takes a separate arguments for flags and tileoffset.Stef wrote:Someone already reported me this as a bug, but that's definitely not.
"basetile" is intented to be a default mask to define defaut tile property (palette, flip, priority...) and not a base tile index. I guess i should rename that parameter to avoid confusion.
*src should contain specific tile property and the complete index number.
Maybe i should redesign this method to add an extra parameter so we have "baseTileValue" and "baseTileIndex" so you can define your fixed properties (palette, flip etc...) and the base tile index.