It is currently Mon Oct 16, 2017 11:11 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Mon Oct 09, 2017 3:36 pm 
Offline

Joined: Mon Dec 12, 2011 8:15 pm
Posts: 304
lidnariq wrote:
zxbdragon wrote:
emu....Failure
How did you implement the IRQ?

f000 count = count & 0x00FF | data ^ 0xFF <<8
f008 enabled = data &0x01;
clock:
count=(count-1)&0xFFFF;
return count<enabled;


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Mon Oct 09, 2017 4:08 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6273
Location: Seattle
Flipping around the direction it counts makes that more confusing...
I'm probably making mistakes, but at the very least, you'd need to add:
f008 enabled = data & 0x01; if (!enabled) { count |= 0xFF }
clock: if (enabled) {count--; }

and that's probably still missing something.


I'd personally do this with two unsigned 8-bit types instead of trying to stuff both into the same 16-bit integer:
WF000: count = data;
WF008: enabled = (data & 1); if (!enabled) { prescaler = 0; }
M2: if (enabled) { prescaler++; if (0x80 == (prescaler & 0xFF)) { count++ }}
IRQ: if (enabled && 0xFF == count && prescaler < 128) return ASSERTED;


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Tue Oct 10, 2017 1:09 am 
Offline

Joined: Mon Dec 12, 2011 8:15 pm
Posts: 304
@Fisher

shop screen in hareware.
cg in hareware.


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Tue Oct 10, 2017 3:15 am 
Offline

Joined: Mon Dec 12, 2011 8:15 pm
Posts: 304
lidnariq wrote:
Flipping around the direction it counts makes that more confusing...
I'm probably making mistakes, but at the very least, you'd need to add:
f008 enabled = data & 0x01; if (!enabled) { count |= 0xFF }
clock: if (enabled) {count--; }

and that's probably still missing something.


I'd personally do this with two unsigned 8-bit types instead of trying to stuff both into the same 16-bit integer:
WF000: count = data;
WF008: enabled = (data & 1); if (!enabled) { prescaler = 0; }
M2: if (enabled) { prescaler++; if (0x80 == (prescaler & 0xFF)) { count++ }}
IRQ: if (enabled && 0xFF == count && prescaler < 128) return ASSERTED;


not working!


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Wed Oct 11, 2017 3:59 pm 
Offline
User avatar

Joined: Sat Jul 04, 2015 9:58 am
Posts: 526
Location: -29.794229 -55.795374
I've created some videos and uploaded to YouTube, to serve as reference:

The beginig of the game, including the 1st stage animation. I stopped a little after the store.
End of 1st stage, mainly the animation.
Hope this helps anyone that wishes to implement this mapper on an emulator.

This was captured using the Phantom System, a NES clone I have.
It's the same one I got fixed here.
Unfortunatelly, I don't have a (working) original NES, the sound may be a little different.
This one gave me the best video and audio output on my cheap capture card. :lol:


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Wed Oct 11, 2017 4:50 pm 
Offline

Joined: Sun Jun 12, 2011 12:06 pm
Posts: 217
Location: Poland
So it's another game (after Gimmick) ported from FME7 to VRC2 (orVRC4?)
While the gimmick uses AX5208C and does not need additional IRQ circuitry, this one uses VRC2 without IRQ?

I did small test and put the AX5208C (VRC4?) to KidDracula and it worked fine. However, the 23C3662 (VRC2?) from dracula put to Gimmick does not want him to work.

I wonder what would happen if the whole additional IRQ circuitry from the Gremlins2 would be removed and its DIL40 chip would be changed into AX5208C.


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Wed Oct 11, 2017 5:02 pm 
Offline
User avatar

Joined: Sat Jul 04, 2015 9:58 am
Posts: 526
Location: -29.794229 -55.795374
krzysiobal wrote:
I wonder what would happen if the whole additional IRQ circuitry from the Gremlins2 would be removed and its DIL40 chip would be changed into AX5208C.

If it helps, I tried to dump the game with mapper 22 option of TapeDump and got wrong CHR ROM.
It also runs on Nestopia with mapper 22 set, but with grabled graphics.

I think the Gradius 2 I have should also be the same case, since it has an aditional ROM to patch it.
What about this Batman?
Any tips of where I can buy some of these chips?
I tried to find an MMC3 clone on Aliexpress, but found some very negative commets and give up.


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Thu Oct 12, 2017 6:14 pm 
Offline

Joined: Sun Jun 12, 2011 12:06 pm
Posts: 217
Location: Poland
This one works:
https://youtu.be/F2poX2bMhWM

Lidnariq - could you explain why when writing 0 to $f00c, IRQ is deasserted?


Code:
#include "mapinc.h"

static int prg[2];
static int mirr;
static int chr[8];
static int counter;
static int counting_enabled;
static int m2_prescaler;
static int first_phase;
static int counterchanged;

static SFORMAT StateRegs[] =
{
   { 0 }
};


//shifts bit from position `bit` into position `pos` of expression `exp`
#define shi(exp, bit, pos) \
   ((((exp) & (1 << (bit))) >> (bit)) << (pos))

static int vrc_addr_mix(int A) {
   //this game wires A0 to VRC_A0 and A1 to VRC_A1
   return (A & 0xf000) | shi(A, 2, 0) | shi(A, 3, 1);
}

static void M273IRQHook(int a)  {
   if (counting_enabled) {
      m2_prescaler += a;
      if (m2_prescaler >= (first_phase ? 128 : 256)) {
         first_phase = 0;
         m2_prescaler -= (first_phase ? 128 : 256);
         counter++;
         counterchanged=1;
      }
      else {
         counterchanged=0;
      }
      
      if (counterchanged) {
         if (counter >= 256) {
            counter -= 256;
            X6502_IRQBegin(FCEU_IQEXT);
         }
         else {
            X6502_IRQEnd(FCEU_IQEXT);
         }
      }
      
   }
}

static void Sync(void) {
   setprg8(0x8000, prg[0]);
   setprg8(0xa000, prg[1]);
   setprg16(0xc000, -1);   
   for (int i = 0; i < 8; ++i) {
      setchr1(0x400 * i, chr[i]);
   }
   
   
   switch (mirr) {
   case 0: setmirror(MI_V); break;
   case 1: setmirror(MI_H); break;
   }
   
}

static DECLFW(M273Write) {
   //writes to VRC chip
   switch (vrc_addr_mix(A)) {
   case 0x8000:
   case 0x8001:
   case 0x8002:
   case 0x8003:
      prg[0] = V;
      break;
   case 0xA000:
   case 0xA001:
   case 0xA002:
   case 0xA003:
      prg[1] = V;
      break;
   case 0x9000:
   case 0x9001:
   case 0x9002:
   case 0x9003:
      mirr = V & 1;
      break;
   case 0xb000: chr[0] = (chr[0] & 0xF0) | (V & 0xF); break;
   case 0xb001: chr[0] = (chr[0] & 0xF) | ((V & 0xF) << 4); break;
   case 0xb002: chr[1] = (chr[1] & 0xF0) | (V & 0xF); break;
   case 0xb003: chr[1] = (chr[1] & 0xF) | ((V & 0xF) << 4); break;
   case 0xc000: chr[2] = (chr[2] & 0xF0) | (V & 0xF); break;
   case 0xc001: chr[2] = (chr[2] & 0xF) | ((V & 0xF) << 4); break;
   case 0xc002: chr[3] = (chr[3] & 0xF0) | (V & 0xF); break;
   case 0xc003: chr[3] = (chr[3] & 0xF) | ((V & 0xF) << 4); break;
   case 0xd000: chr[4] = (chr[4] & 0xF0) | (V & 0xF); break;
   case 0xd001: chr[4] = (chr[4] & 0xF) | ((V & 0xF) << 4); break;
   case 0xd002: chr[5] = (chr[5] & 0xF0) | (V & 0xF); break;
   case 0xd003: chr[5] = (chr[5] & 0xF) | ((V & 0xF) << 4); break;
   case 0xe000: chr[6] = (chr[6] & 0xF0) | (V & 0xF); break;
   case 0xe001: chr[6] = (chr[6] & 0xF) | ((V & 0xF) << 4); break;
   case 0xe002: chr[7] = (chr[7] & 0xF0) | (V & 0xF); break;
   case 0xe003: chr[7] = (chr[7] & 0xF) | ((V & 0xF) << 4); break;
      
   default:
      break;
   }
   
   switch (A & 0xf00c) {
   case 0xf000: counter = V; X6502_IRQEnd(FCEU_IQEXT); break;
   case 0xf008: if ((V & 1) == 0) {counting_enabled = 0; m2_prescaler = 0; first_phase = 1; X6502_IRQEnd(FCEU_IQEXT);}
               else            {counting_enabled = 1; }
            break;
   }

   Sync();
}

static void M273Power(void) {
   SetWriteHandler(0x8000, 0xFFFF, M273Write);
   SetReadHandler(0x8000, 0xFFFF, CartBR);
   Sync();
   
   counter = 0;
}

static void M273Reset(void) {
   counter = 0;
   Sync();
}

void Mapper273_Init(CartInfo *info) {
   info->Power = M273Power;
   info->Reset = M273Reset;
   MapIRQHook = M273IRQHook;

   AddExState(&StateRegs, ~0, 0, 0);
}


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Thu Oct 12, 2017 7:06 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6273
Location: Seattle
krzysiobal wrote:
Lidnariq - could you explain why when writing 0 to $f00c, IRQ is deasserted?
O_o

... Let me triple-check our work.

Nope, no explanation for it.

(I assume that's not a typo)



I just copied/pasted your source code into my checkout of fceux and rebuilt, and used the same PRG/CHR from earlier, and ... my title screen is all wrong.


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Fri Oct 13, 2017 3:19 am 
Offline

Joined: Sun Jun 12, 2011 12:06 pm
Posts: 217
Location: Poland
Maybe you have something wrong in iNES header in ROM, because this game does not even user IRQ at title screen and in game (first time it does is the shop screen).


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Fri Oct 13, 2017 5:45 am 
Offline

Joined: Mon Dec 12, 2011 8:15 pm
Posts: 304
nestopia not working....


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Fri Oct 13, 2017 11:07 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6273
Location: Seattle
krzysiobal wrote:
Maybe you have something wrong in iNES header in ROM, because this game does not even user IRQ at title screen and in game (first time it does is the shop screen).
(embarrassed) I'd made a UNIF image for testing and forgot to include a MIRR block.

krzysiobal wrote:
m2_prescaler += a;
Oh, right, duh. That's why my example didn't work; FCEUX doesn't give a callback on every M2 cycle, but instead a number of M2 cycles to advance. I need to do something silly like ((m2_prescaler + a)& 128 ) && !(m2_prescaler&128) to detect the edge.

I think your code emits an IRQ 128cy too early? But, then again, when I change the timing to how I think the hardware is supposed to work, it's even later than what Fisher shows in his video, so I'm clearly wrong.

Not certain how to adjust the software to both implement what I think the hardware does and what I see, though.


Top
 Profile  
 
 Post subject: Re: Pirate Gemlins 2 RE
PostPosted: Sat Oct 14, 2017 4:43 am 
Offline

Joined: Mon Dec 12, 2011 8:15 pm
Posts: 304
How to working in Nestopia ?

nestopia using this code ,shop ok,but stage cg not working


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group