Archive for the ‘Snes’ Category

VRAMLoad + CGRAMLoad updates

Tuesday, July 8th, 2008

Yesterday I returned to the PPU.c code. I knew that the VRAMLoad and CGRAMLoad needed to be reworked. The DMA transfer routine we were always getting data from bank $01. Since I start to having lots of ressource, I got stuck while implementing the score/status board. Here is the revised code :

void VRAMLoad(word far *src, word vramDst, word size) {
	// set address in VRam for read or write ($2116) 
	// + block size transfer ($2115)
	*(byte*)0x2115 = 0x80;
	*(word*)0x2116 = vramDst;
	
	// set DMA control register (1 word inc)
	// and destination ($21xx xx -> 0x18)
	*(word*)0x4300 = 0x1801;	

	// DMA channel x source address offset 
	// (low $4302 and high $4303 optimisation)
#asm
	lda %%src;					
	sta $4302;					
#endasm
	// DMA channel x source address bank
#asm
	lda %%src+2;				
	sta $4304;
#endasm

	// DMA channel x transfer size 
	// (low $4305 and high $4306 optimisation)
	*(word*)0x4305 = size;	

	// Turn on DMA transfer for this channel
	setINIDSPDirectValue(0x80);
	*(byte*)0x420b = 0x01;
	setINIDSPDirectValue(0x00);
}

I’m now using far pointer, here is a part of the ressource.h :

extern word far score_pic[];
extern word far score_pal[];
extern word far score_map[];

So now I can copy from anywhere in ROM to VRAM or CGRAM  without any problem.

++ Lint

Level 1 is ready to scroll

Friday, July 4th, 2008

I finished the level 1 map this morning and really wanted to share it with you (click for full level) :

Level 1 teaser

It’s now been a few days that I’m mostly playing with MAME and Gimp to rip the gfx and create the tiles to use on my Kung Fu Master port for the SNES. I still need to do some work in the score to create the tile and be ready to write them on the screen.

I just discovered that the tool I use to convert my pcx isnt supporting big files like the one i show you here. Anybody know a good map editor compatible with the SNES ? I will anyway first concentrate on the scoring part.

NSF Replayer status : The code is now more stable but i still have issue with the NES code that is accessing some part of memory that should remain untouched. I need to trace it more deeply … I keep you updated anyway but I will not work on that issue that much or I will never have something to show on the end of July.

++ Lint

Full screen redesign

Thursday, July 3rd, 2008

A received a few suggestion after yesterday post. The switching of player and ennemy life bar was causing some trouble to some of my friends, so I switched it back and changed the life counting. Here is the full screen redesign of the Level 1 start.

Level 1 screen redesign

 

I will now start to rip the full Level 1 gfx and start to implement the background scroll and update of the score and status. I think it can be done for start of next week.

See ya, Lint

Redesigning the screen to fit.

Wednesday, July 2nd, 2008

Yesterday night I redesigned the top part of the game screen si the whole play area fit in the SNES screen. The original arcade title have a 256 x 256 screen while the SNSE have 256 x 224. I need to crop 32 pixels. SO here is the result of my work :

Original score

Redesigned score

I still need to finish the map of the first level. I hope to finish that by tomorow or later if i decide to implement the score part first.

See ya,

Lint

Native Vs Emulation mode

Tuesday, July 1st, 2008

This morning I think I finally found why the NSF Replayer isn’t working. Here is the piece of code :

        sec
        xce             ; 6502 mode
        ldx #0
        txy
        ;jsr ($1013,x) <- commented for testing purpose
        clc
        xce             ; native mode

The problem is when I switch the 65816 execution mode from native to emulation (6502). This code is part of a routine that is called in memory at address 7F5006 with a jsl instruction and the routine return with a rtl to code in bank 0. When I’m removing the xce instruction everything run fine, with the xce instruction the rtl return in the middle of nowhere. Is there something that xce instruction modify that I’m not aware of ?

I will continue to investigate, but usual shoot your ideas in the comments section.

++ Lint

EDIT: The problem is that when comming back emultation mode the stack address is modified. So now as a quick patch I’m saving it somewhere in RAM and restore it. Thanks D4S for spotting this. 

SNES Central news + NSF Replayer status

Monday, June 30th, 2008

This morning I discovered that one of the site that I consider as the best SNES ressource (especially about proto and alpha/beta release) did a small news on myself. Go check it : www.snescentral.com

Thanks guys, it is a good gift for me. Yeps, It’s my birthday today. I’m 34 years old today.

A little update on my SNES work : sound engine is soon going to be able to run. I already corrected many lines of code that were causing trouble. The whole NSF init process is almost finished (I hope tonight or tomorow morning 😉 ). Then I will attack the player itself, but since it’s based on the same process so it will be painless.

I still hope to finish this week my NSF Replayer work. I will try to make a package and a small doc so anybody can use it or improve it.

++ Lint

SNES Sound engine hell …

Thursday, June 26th, 2008

It’s been almost 2 weeks that I’m in a battle with sound engines on SNES. The sound CPU in the SNES is a SPC-700 chip designed by Sony. After my last post, I said to myself : “It would be nice to setup music now”. I tough it was a great idea since sound was almost the last thing that I hadn’t yet implemented on the SNES (except from some PPU feature).

I started looking after sound engine and tracker that suport the SPC-700 chip.

To my big surprise, there is no tracker available at all. No sound engine packaged and usable out of the box. After a small discussion with D4S, he told me a few facts about SPC-700 :

  • It’s not easy to understand
  • Transfer routine making it not easy to play other format
  • Definitively no dedicated tracker

While digging for sound engine I found out 3 engine that might be usefull to look at :

XMSNES

This engine is supposed to take .xm and transform it to another format to make it playable on the SNES. The problem is that the file that are being converted need to contains almost no effects and have many other limitation. Then the main problem is that it don’t really sound nice on the real SNES hardware. Since real hardware support is for my a pre-requisite, I left that engine out.

CDOTY / SME Engine by Nevitsky

Cdoty realeased a while ago the source code for his “frog feast” game on the SNES. In this game he used the SME Engine coded by Nevitsky. The problem is that there is absolutely no documentation at all and that the sounds need to be converted and I didnt found out the software to convert them. Once again I left out that one.

NSF Replayer

Sometimes google help you to find stuff on the internet. This timegoogle wasn’t my best friend while searching SNES sound engine. YouTube was a good buddy with me making me discovering the NSF Replayer for SNES. The NSF Replayer is NSF player for the SNES that playback music from NES game on the SNES. The engine is playing quite well on real hardware and after a few serach I found some forum posts that were talking about it. There is no real doc but the code is quite explicit.

I’m currently implementing the engine in the WDC sdk. I’m having isuue with code relocation but it should be fixed quite soon. So yes I’m loosing time for my 26th July deadline to implemnting the first level of kung fu master on the SNES, but at least I will have a sound engine.

One other great thing with this engine is that I have the NSF kung fu master soundtrack already ready to be played by the engine. The NES soundtrack sound really like the arcade version.

As soon as the engine is running I will make a new release, I promise. I hope to have it running by middle of next week.

See ya,

Lint

WDC C Compiler for 65816 in action [PART IV]

Friday, June 13th, 2008

Finally i take some time to describe what’s new in the fourth release.

First i wanna give you the rom and source code archive.

The code have patched since the pre release and now it should work on real hardware without any flow. There is just some sprite priority problems with ZNES. I will fix that sometimes. Since past stable realease I have corrected a lot of bad code in te event handling functions.

The biggest improvement is the sprite handling. I have ripped a part of the Kung Fu Master sprite and descide to implement walk, down and punch hit. I declared the whole sprite table in memory and i have a function that transfer it by DMA. Here is the structure in C :

typedef struct OBJECTData {
    byte HPos;
    byte VPos;
    byte nameLow;
    byte nameHigh:1;
    byte color:3;
    byte priority:2;
    byte HFlip:1;
    byte VFlip:1;
} OBJECTData;

typedef struct OBJECTProp {
    byte size:1;    // Size Large/Small
    byte HPos:1;    // H-Position MSB
} OBJECTProp;

typedef struct OAMData {
    OBJECTData data[0x80];
    OBJECTProp prop[0x80];
} OAMData;

So now it’s very easy to modify and setup sprite table. Then the OAMLoad() function do the DMA transfer. That function is called on NMI Interrupt by a dedicated event.

One other big work that I have done in this release is the work on PPURegister. Here is the list of functions that I have already implemented :

ppuRegisterStatus PPUStatus;

void initRegisters(void);

void savePPUContext(ppuRegisterStatus *PPUStatus_src,
                    ppuRegisterStatus *PPUStatus_dst);
void restorePPUContext(ppuRegisterStatus PPUStatus);

void setINIDSP(word blanking, word fade);
void setINIDSPDirectValue(word value);
byte getINIDSP(void);
void setOBJSEL(word objsize, word objnameselect,
               word objnameaddrbase);
void setOBJSELDirectValue(word value);
byte getOBJSEL(void);
void setOAMADDR(word oamadrr, word oampriority);
void setOAMADDRDirectValue(word value);
word getOAMADDR(void);
void setOAMDATA(word oamdata);
void setOAMDATADirectValue(word value);
byte getOAMDATA(void);
void setBGMODE(word bgsize, word bg3, word bgmode);
void setBGMODEDirectValue(word value);
byte getBGMODE(void);
void setMOSAIC(word mosaicsize, word mosaicenable);
void setMOSAICDirectValue(word value);
byte getMOSAIC(void);
void setBG1SC(word vramDst, word screenProp);
void setBG1SCDirectValue(word value);
byte getBG1SC(void);
void setBG12NBA(word vramDstBG1, word vramDstBG2);
void setBG12NBADirectValue(word value);
byte getBG12NBA(void);
void setBG34NBA(word vramDstBG3, word vramDstBG4);
void setBG34NBADirectValue(word value);
byte getBG34NBA(void);

It’s now very simple to setup those registers without the need to play for the bit position for certain of them. Everything is handled in C, the code is really not efficient, I’m totally aware of that but the code will be optimised at a later stage of the development. As you see also I have a variable that contain a erference to all PPU registers allowing me to save and restore them. Nice feature when entering to debug screen and not having to worry about saving thing and setings them back before leaving. (The only think you need to care is VRAM, but I will try to restore that too).

I’m very pleased with this relaese, I got all I needed to get work done in a couple of days. From now on I will really focus on the Kung Fu Master port on the SNES from the Arcade version. I already have everything I need in place for doing that, except for the sound engine. I will try to integrate XMSNES to my work.

I will anyway post on a regular basis about the progress I made on the port. And whatever i see a problem that I should expose to you I will make a post about it.

See ya,

++ Lint

Early release…

Wednesday, June 11th, 2008

Why early ?!? Because I think many people wait for relaese of the new source code and ROM. I will not have time to write a post describing what I have done and how I have done it. This will come in a few days (I really hope before the weekend).

Biggest new feature is sprite handling.

So here is the ROM and source code.

++ Lint

PS : The code might be refactored when official release. As usual don’t hesitate to send a comment for any questions, bugs, suggestions …

UPDATE Status

Thursday, June 5th, 2008

Hi all,

I took time to analyse why the code wasnt’t running correctly on the SNES hardware. It’s mostly the event handling code. The addEvent and removeEvent functions were causing multiple problems when there was more than 2 events. Now everything should be fixed.

At the start of this week, I did a small TODO list with 12 items. In 4 days I cleared 10 of them. Here is the list :

Events :

  • DONE !!! review add/remove comments
  • DONE !!! add priority (0xff -> 0x00)
  • DONE !!! Allow to stop some events during debug

PPU-registers :

  • DONE !!! make a NO_VALUE define (0xffff)
  • DONE !!! implement BGMODE, MOSAIC and INIDSP
  • DONE !!! implement save_context and restore_context

DEBUG DISPLAY :

  • DONE !!! [DONT WORK IN BSNES] trigger on L+R+Start
  • DONE !!! display register value A, X and Y) before jump to debug
  • DONE !!! display event queue information
  • DONE !!! display BGMODE / MOSAIC / FADE value before debug
  • DONE !!! save and restore context on enter debug.

SPRITE :

  • POC with main character on title screen (left, right, hit)
  • add up and down control

For next release I may not release a full sprite code, but a least I hope to being able to display a sprite on the screen.

Kung fu master first draft sprite

++ Lint