i'm glad you're not using the sgl and or sbl libraries! ugh, i don't understand the vram cycle patterns at all! i have written some code to make use of the nbg2... it probably doesn't run on real hardware due to the fact that i didn't set any of the cycle patterns up. note, this is my 100% code: Code: | | | #include "vdp2.h" #define NBG2_CEL_ADR (VDP2_VRAM_A0 + 0x02000) #define NBG2_MAP_ADR (VDP2_VRAM_A0 + 0x10000) #define NBG2_COL_ADR (VDP2_COLRAM) void vblank(struct VDP2 *io) { while((io->reg[TVSTAT] & (1<<3)) == 8); while((io->reg[TVSTAT] & (1<<3)) == 0); } int main(void) { unsigned long i,x=0; unsigned char *video_bank_a = (unsigned char *)VDP2_VRAM_A0; unsigned char *video_bank_b = (unsigned char *)VDP2_VRAM_B0; unsigned short *map = (unsigned short *)NBG2_MAP_ADR; unsigned short *cram = (unsigned short *)NBG2_COL_ADR; /* Point to the VDP2 IO address */ struct VDP1 *vdp1 = (struct VDP1 *)VDP1_IO; struct VDP2 *vdp2 = (struct VDP2 *)VDP2_IO; /* VRAM - Tiles*/ for(i = 0; i < 0x8000; i++) { video_bank_a[i] = 0x0000; video_bank_b[i] = 0x0000; } /* Clear Map */ for(i = 0; i < (1024 * 256); i++) { map[i] = 0x0000; } /* clear CRAM */ for(i = 0; i <0x1000; i++) { cram[i] = 0x0000; } /* Clear VDP1 */ for(i = 0; i < 72; i++) { vdp1->reg[i] = 0x0000; } /* Clear VDP2 */ for(i = 0; i < 72; i++) { vdp2->reg[i] = 0x0000; } /* Copy stuff, Add DMA support later */ Cel2VRAM(pad_cel,(void *)NBG2_CEL_ADR,31808); Map2VRAM(pad_map,(void *)NBG2_MAP_ADR,32,23,0,256); Pal2CRAM(pad_pal,(void *)NBG2_COL_ADR,256); vdp2->reg[TVMD] = (1<<15); vdp2->reg[VRSIZE] = 0x0000; vdp2->reg[RAMCTL] = 0x0000; vdp2->reg[PLSZ] = 0x0000; vdp2->reg[CYCA0L] = 0x0123; vdp2->reg[CYCA0U] = 0xFFFF; /* unused? */ vdp2->reg[BGON] = (1<<2); vdp2->reg[CHCTLB] = (1<<1); vdp2->reg[PNCN2] = (1<<14)|(1<<15); /* ((NBG2_MAP_ADR>>16)&0x1F)|((NBG2_MAP_ADR>>8)&0x1FFF) */ vdp2->reg[MPABN2] = ((NBG2_MAP_ADR>>5)&0xFFF)|((NBG2_MAP_ADR>>13)&0xFF); vdp2->reg[MPCDN2] = ((NBG2_MAP_ADR>>5)&0xFFF)|((NBG2_MAP_ADR>>13)&0xFF); vdp2->reg[MPOFN] = 0x0000; /* no map offset */ /* Loop forever */ while(1) { vblank(vdp2); *(volatile unsigned short *)0x25F80090 = x & 0x1FF; x++; } /* We'll never get here */ return 0; } /* EOF */ |
any corrections would be great! |