WDC C Compiler for 65816 in action [PART IV]

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

2 Responses to “WDC C Compiler for 65816 in action [PART IV]”

  1. d4s Says:

    Hi there!
    Your blog really makes for an interesting read! Also nice to see that you mention Ultra16, keep it up! Catch ya later. =)

  2. Tomy Says:

    Lint,

    It run well on real hardware now.

    I just tested when select+start press together, the screen is flashing.
    (It is not bugs, only because not check if button released)