Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SCR3 #3

Open
fabiensanglard opened this issue Apr 18, 2022 · 5 comments
Open

Add support for SCR3 #3

fabiensanglard opened this issue Apr 18, 2022 · 5 comments

Comments

@fabiensanglard
Copy link
Owner

No description provided.

@ggnkua
Copy link

ggnkua commented Feb 15, 2023

Hello, is there any chance of implementing this? I am trying to port a small demo to this platform, I've got all the sprites working as I want them to, but whatever I tried so far didn't mange to turn on the SCROLL3 layer (or any other layer in fact!)

So far I've tried the following in a project derived from post (by mostly reading the book):

  • I've put the background I want to use in the project's gfx/scr3 folder. (actually I have 2 and put them both inside the folder but I think that should be ok)
  • I've set up a struct for the SCROLL3 layer:
#define MAXSCROLL 64*64
typedef struct {
    WORD	tile;		// Sprite tile

    // 0..2 CB[0..3] Palette ID used to render the tile
    // 3 X Flip Mirrored horizontally
    // 4 Y Flip Mirrored vertically
    // 5-6 Priority group (See priority mask)
    // 7 Unused
    WORD	attributes;   	// Sprite attribute
} Scroll3;
GFXRAM Scroll3 scroll3 [MAXSCROLL] __attribute__ ((aligned (0x100))) = {};
  • I defined the layer control define:
#define CPSA_REG_SCROLL3_BASE (0x6 / 2)
// Layer control
// bit 3: Enable SCROLL1
// bit 4: Enable SCROLL2
// bit 5: Enable SCROLL3
// Cannot control STAR1
// Cannot control STAR2
// Bit 6-7: Layer to draw first
// Bit 8-9: Layer to draw second
// Bit 10-11: Layer to draw third
// Bit 12-13: Layer to draw last
// Layer IDs : OBJ=0 , SCROLL1=1 , SCROLL2=2 , SRCOLL3=3
  • In OnVsync() I added a line that (at least from what I gather from the book) should turn SCROLL3 on:
   cpsb_reg[CPSB_REG_LAYER_CONTROL] = (1 << 5) | (0 << 6) | (3 << 8);

(I also set OBJ as first layer, then SCROLL3 as second layer)

  • Then inside Draw() I added something like:
    setPalette(8, 2, &pdeka);
    int i = 0;
    for (; i < deka.numTiles; i++) {
        Scroll3* s = &scroll3[i];
        GFXShapeTile* t = &(deka.tiles[i]);
        //s->x = 196 + t->x * 16;
        //s->y = 100 + t->y * 16;
        s->tile = t->id;
        s->attributes = 2;//|  0x7 << 1 | 0x3 << 1; // Use palette 2 dim 5+1x3+1 = 6x4 tiles
    }
    scroll3[i].attributes	= 0xFF00; // Last sprite marker
  • Lastly, I modified setPalette to actually use the page parameter:
void setPalette(int page, int paletteID, const Palette* palette) {

   for (int j = 0 ; j < 16 ; j++) {
  	  palettes[paletteID].colors[j] = (*palette).colors[j];
   }

   // Request upload palette page to sprites
   cpsb_reg[CPSB_REG_PALETTE_CONTROL] = page;

   // Set palette base
   cpsa_reg[CPSA_REG_PALETTE_BASE] = (WORD)(((DWORD)palettes) >> 8);
}

Unfortunately, this still leaves me with... darkness. Only the sprite layer is visible. I am not sure if I am setting the correct palette, or the format I use for palette3 is correct, or anything other really.

Thanks in advance! I also wrote a palette fader, if you are interested I can share it with you so you can add it as a utility function.

@fabiensanglard
Copy link
Owner Author

fabiensanglard commented Feb 15, 2023 via email

@ggnkua
Copy link

ggnkua commented Feb 19, 2023

Hi again,

I made a few more experiments, so this is where I got so far:

  1. I took your advice and used dumpgfx and then inspected the generated files. Most were empty (white tiles), in a few all the tiles were filled with black colour. But the two images I used were not present anywhere
  2. As an experiment I moved my PNG images over to scr1 folder. This time dumpgfx showed the tiles from one of the images in 1-0.svg. I don't think the second image's tiles are shown. But fair enough, if I can get one image to show it would be at least progress
  3. I added some more code, equivalent to the above but relevant to SCROLL1. No luck
  4. I tried setting all palettes of the hardware to non-black. Still nothing
  5. I tried filling the SCROLL1 buffer with all tiles from 0 to 64*64-1 in hopes of it showing something, even if skewed. Sadly no luck again

This is where I'm at right now and I'm out of ideas. I suppose that the next thing to try would be to manually fill the rom files with junk, see if I can get it to show anything at all on screen.

@fabiensanglard
Copy link
Owner Author

  1. I can take a look at ccps this weekend and see why the tile are not making their way to the GFX Rom.

  2. I propose that you reduce the scope of "things that may not work" and get ccps out for now. Use the project generated from post and make sure you get Ryu to show up in mame like this.

Ryu

Since post only generates a m68k rom, you can focus on getting this working while being sure the gfxrom is good. Now tweak your code until you manage to show a background tile from eithersrc1, scr2, or scr3. Again, put some printf or use mame debugger to verify that what you are doing is picked up properly.

Once you have a post project able to handle sc1/2/3 with sf2 gfxrom, we can focus on debugging further.

@ggnkua
Copy link

ggnkua commented Feb 27, 2023

Hi,

As suggested, I tried to modify the post example in order to enable scroll1/2/3, but unfortunately I didn't manage to succeed. Just to be sure, my modifications include:

  • Setting all palettes to non-black
  • Fill in a tileset for scroll1/2/3 and point the graphics pointers to it
  • Tried enabling all 3 layers
  • Set the scrollx/y registers
  • Set the layer order

I also tried various other things like changing the tiles attributes, writing to the hardware registers as addresses, etc. I still didn't get far.

I'm attaching the modified main.c here in hopes of someone picking up where I left it and try to fix it (or learn from my mistakes): main.zip. Otherwise, I'm afraid I'm stumped here (and don't have the time to start fiddling with the mame source code to debug this).

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants