bsnes v0.042 released

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

byuu wrote: I believe it was _Demo_ who speculated that it'd take at least a 10GHz processor to achieve this. Then again, it's been so long I could be attributing the quote to the wrong person. Don't even remember the exact words anymore. Anyone recall?
It was 4 GHz IIRC.
You should however try some of the really heavy games.

Code: Select all

-------------------------Container--------------------------
       File: Jikkyou Oshaberi Parodius (J).gz
   Sub File: Jikkyou Oshaberi Parodius (J)
---------------------Internal ROM Info----------------------
       Name: OSHABERI PARODIUS        Company: Konami
     Header: None                        Bank: LoROM
Interleaved: None                         ROM: 24 Mb
       Type: SA-1                        SRAM: 64 Kb
  Expansion: None                     Battery: Present
    Country: Japan                      Video: NTSC
  ROM Speed: 200ns (SlowROM)         Revision: 1.0
   Checksum: Good 0x58D2            Game Code: Marked, AJOJ
---------------------------Hashes---------------------------
      CRC32: 177937AB
--------------------------Database--------------------------
       Name: Jikkyou Oshaberi Parodius
    Country: Japan                   Revision: 1.0
     Port 1: Gamepad                   Port 2: Gamepad
    Genre 1: Shooter                  Genre 2: Horizontal Scrolling
Also try the Kirby Super Star intro.

BTW, congrads.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
byuu

Post by byuu »

Nach wrote:It was 4 GHz IIRC.
Wow, he really called that, didn't he? In P4 speeds, that was pretty much dead-on. I'd get about 40fps there, so you figure with some good optimizations that'd be about right for consistent 60fps.
Nach wrote:You should however try some of the really heavy games.
Ah, I always heard Kirby 3 was the all-time worst. Parodius doesn't run in-game yet. I still don't understand how the interrupt mechanism works.
Nach wrote:BTW, congrads.
Thank you. Apologies if I seemed braggy or anything. It's more I'm in shock that it's as fast as it is for the rate it's actually syncing. According to my stand-alone libco tests, it should be running at ~60fps before actually emulating anything (just from the context switches), and yet it's at ~90-120 with emulation.

But that's good news for everyone, as single-level state machines are quite a bit faster still. If ZSNES v2 makes the SA-1 cycle-level as well, it should be many times faster than this.

And two more things (SFX+PPU) and I'll have nothing left to brag about adding :P

"This revolutionary new RISC core allows Quick-move Shogi Match with Nidan Rank-holder Morita II to run with cycle-level computer move computations!"
Gil_Hamilton
Buzzkill Gil
Posts: 4294
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

I want pictures of SRW Gaiden!
byuu

Post by byuu »

New WIP. Copy-paste:
Working on SA-1, still a long way to go. Fixed a bug where I was clearing MA after multiplication / cumulative sum when I wasn't supposed to. Fixes Kirby 3 Pop Star scene.

Added normal DMA, along with full support for DPRIO (allowing DMA to run alongside the SA-1 CPU) and blocking of invalid transfer types / modes. This fixes sprites in Marvelous.

Also added BW-RAM bitmap mirroring to $[60-6f]:[0000-ffff], proper mapping for the bitmap mode to the $[00-3f|80-bf]:[6000-7fff] regions, variable-length bit read data port, and I now at least cache the register settings for IRQs (though I still do nothing with them.)

I added support for BW-RAM and I-RAM write protection, but when it's enabled, most games will no longer load. So I'm forced to leave that off for now. Maybe the protection didn't actually work on the real hardware? Hmm ...

No idea what the bitmap registers $2240-$224f are for, and I don't see how it's supposed to be possible to trigger IRQs as needed by Super Mario RPG and Parodius. But at least three of five games should now be fully playable with no issues. Speed remains the same as yesterday. No hit for the SA-1 CPU+DMA simultaneous transfer mode support.
Image Image
I want pictures of SRW Gaiden!
Can always try it and see what happens ... after I get some sleep :D
byuu

Post by byuu »

Code: Select all

(DCNT) DMA control register:
Set DPRIO to assign priority between SA-1 CPU and DMA.
DPRIO=0: SA-1 CPU priority (instructions can be executed during transmission.)
DPRIO=1: DMA priority (SA-1 CPU waits during DMA.)
NOTE: DPRIO is only valid during normal DMA between BW-RAM and SA-1 I-RAM.

Character conversion DMA:
STEP 1:
Set DCNT char conversion DMA enable = 1.
...
STEP 7:
The SA-1 CPU can return to program processing after STEP 1 has been performed,
However, it must wait during any simultaneous access to BW-RAM or SA-1 I-RAM as DMA has priority.
...

So the control register says the SA-1 is paused until the DMA completes with DMA priority, and that char conversion can only use DMA priority.

Then it says the SA-1 CPU can run during char conversion in the next section.

Yet Marvelous churns out successive 64-byte DMA transfers back-to-back. If I force allow both to run, even with DMA priority + CPU stalls (cycle interleaving), the transfers would overlap each other and break. 110 CPU cycles (changing other DMA regs during that) to 256 DMA cycles. So the CPU definitely has to be stopped completely with DPRIO=1.

If DMA priority meant it kept priority during the entire transfer, then step 7 above would not be possible.

Maybe it's best to just avoid asynchronous DMA transfers for now. Not sure if it's a good idea to emulate a behavior that I don't understand and no game uses. Would likely just screw it up anyway.

CPU priority mode between BW-RAM and I-RAM would be limited to 2048 bytes * 4 = 8,192 cycles anyway @ 21,477,272Hz anyway.

Marvelous:

Code: Select all

//start 64-byte DMA
00d29c sta $37       [$002237] A:0040 X:0000 Y:2080 S:37f5 D:2200 DB:00 nvMxdizc V:141 H: 960
//counter jumps by +~256 due to DMA being synchronous
00d29e plx                     A:0040 X:0000 Y:2080 S:37f5 D:2200 DB:00 nvMxdizc V:141 H:1100
00d29f lda #$c4                A:0040 X:0000 Y:2080 S:37f7 D:2200 DB:00 nvMxdiZc V:141 H:1112
//already modifying DMA regs ~18 cycles later
00d2a1 sta $30       [$002230] A:00c4 X:0000 Y:2080 S:37f7 D:2200 DB:00 NvMxdizc V:141 H:1118
00d2a3 ldy $ca0d,x   [$00ca0d] A:00c4 X:0000 Y:2080 S:37f7 D:2200 DB:00 NvMxdizc V:141 H:1126
00d2a6 sty $32       [$002232] A:00c4 X:0000 Y:8200 S:37f7 D:2200 DB:00 NvMxdizc V:141 H:1140
00d2a8 lda #$90                A:00c4 X:0000 Y:8200 S:37f7 D:2200 DB:00 NvMxdizc V:141 H:1154
00d2aa sta $34       [$002234] A:0090 X:0000 Y:8200 S:37f7 D:2200 DB:00 NvMxdizc V:141 H:1162
00d2ac ldy #$0040              A:0090 X:0000 Y:8200 S:37f7 D:2200 DB:00 NvMxdizc V:141 H:1170
00d2af sty $38       [$002238] A:0090 X:0000 Y:0040 S:37f7 D:2200 DB:00 nvMxdizc V:141 H:1176
00d2b1 ldy #$2280              A:0090 X:0000 Y:0040 S:37f7 D:2200 DB:00 nvMxdizc V:141 H:1192
00d2b4 sty $35       [$002235] A:0090 X:0000 Y:2280 S:37f7 D:2200 DB:00 nvMxdizc V:141 H:1198
00d2b6 lda #$40                A:0090 X:0000 Y:2280 S:37f7 D:2200 DB:00 nvMxdizc V:141 H:1212
//next DMA, ~110 CPU (non-sync-DMA) clocks after last
//if asynchronous, even interleaved 1:1, old DMA would still be active
//if completely synchronous, STEP 7 above is meaningless
00d2b8 sta $37       [$002237] A:0040 X:0000 Y:2280 S:37f7 D:2200 DB:00 nvMxdizc V:141 H:1220
Panzer88
Inmate
Posts: 1485
Joined: Thu Jan 11, 2007 4:28 am
Location: Salem, Oregon
Contact:

Post by Panzer88 »

well hot damn, look what happens when I go away on spring break for awhile, Jesus Byuu....

EDIT:

the newest wip plus the newest no-intro set playing kirby 3 feels oh so sexy
[quote="byuu"]Seriously, what kind of asshole makes an old-school 2D emulator that requires a Core 2 to get full speed? [i]>:([/i] [/quote]
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

byuu wrote:Not sure if it's a good idea to emulate a behavior that I don't understand and no game uses.
Would it be possible to run tests on the hardware?
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
byuu

Post by byuu »

Finally figured out how SA-1 IRQs work. They don't trigger based on the SNES' /IRQ line, they simply trigger when the SNES writes to an SA-1 reg to trigger them.

Awesome, so IRQ support won't cause any speed hit over the current WIP, and Parodius is now playable. Still something wrong with Mario RPG (I know! Patience ...) but we're up to four out of fine running fine now :D

Image
Would it be possible to run tests on the hardware?
Yes, thanks to blargg's serial cable + stop'n'swop. But unfortunately all of my legally owned and personally dumped SA-1 cartridges that I'm using for the above screenshots have SA-1 chips that aren't working. Water damage. I'd need another SA-1 cart.
powerspike
Regular
Posts: 236
Joined: Mon Nov 21, 2005 3:43 am

Post by powerspike »

byuu wrote:I'd need another SA-1 cart.
I'll loan you my mario rpg cart as long as you back up my saved game before experimenting. Just PM me any shipping details.

Matsuri loev mario rpg..
Image
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

He can just get his own on ebay for cheap. PGA European Tour is like $5 shipped.
powerspike
Regular
Posts: 236
Joined: Mon Nov 21, 2005 3:43 am

Post by powerspike »

Or since I live in the US he could pay nothing at all for it. I never said he had to pay for the shipping, I'd even pay to have it shipped back. :P The cart is verified working and in pristine condition too.
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

Right, but then he's dicking with someone else's $40 property to save $5. There's also the possibility that a problem is found well after he's sent it back to you, and he won't have it to run tests on anymore.
powerspike
Regular
Posts: 236
Joined: Mon Nov 21, 2005 3:43 am

Post by powerspike »

Well just offering, if he doesn't need it that's fine. Also I doubt anything bad would happen to it. Worst case his testing on the game would erase my save I figure which is why I'd want it backed up. It's from 1997 or something.. I haven't played the game since then.
byuu

Post by byuu »

Yeah I appreciate the offer definitely. But I hate taking things for free, and I can't say if I'd need it two years from now for instance. I should be okay without a cart.

Anyway, IRQ code in case I forget:

Code: Select all

//TODO: test this during last_cycle() instead
    if(mmio.sa1_irq == 1 && mmio.irqcl == 0) {
      if(!regs.p.i) interrupt(mmio.civ);
    }

    if(mmio.sa1_nmi == 1 && mmio.nmicl == 0) {
      if(!regs.p.i) interrupt(mmio.cnv);
    }

    (this->*opcode_table[op_readpc()])();

Code: Select all

void SA1::mmio_w2200(uint8_t data) {
  mmio.sa1_irq  = (data & 0x80);
  mmio.sa1_nmi  = (data & 0x10);
  ...
  if(mmio.sa1_irq) {
    mmio.irq_flag = true;
    if(mmio.cpu_irqen == true) mmio.irqcl = 0;
  }

  if(mmio.sa1_nmi) {
    mmio.nmi_flag = true;
    if(mmio.cpu_nmien == true) mmio.nmicl = 0;
  }
}

Code: Select all

void SA1::mmio_w220a(uint8_t data) {
  if(mmio.cpu_irqen == 0 && (data & 0x80)) {
    if(mmio.irq_flag) mmio.irqcl = 0;
  }

  mmio.cpu_irqen   = (data & 0x80);
...

Code: Select all

void SA1::mmio_w220b(uint8_t data) {
  mmio.irqcl = (data & 0x80);
  mmio.nmicl = (data & 0x10);

  if(mmio.irqcl) mmio.irq_flag = false;
  if(mmio.nmicl) mmio.nmi_flag = false;
}

Code: Select all

uint8_t SA1::mmio_r2301() {
  return (mmio.irq_flag << 7) | (mmio.nmi_flag << 6) | mmio.smeg;
}
powerspike
Regular
Posts: 236
Joined: Mon Nov 21, 2005 3:43 am

Post by powerspike »

byuu wrote:Yeah I appreciate the offer definitely. But I hate taking things for free,
Oh okay, I just felt bad for screwing up with that copier before. Plus I figured it'd give people a chance to enjoy playing mario rpg in an emulator with out all those bugs. If you can get it working with out the cart though that's cool.
byuu

Post by byuu »

Gil_Hamilton wrote:I want pictures of SRW Gaiden!
Lucky you. It didn't get past the Banpresto logo until I got the IRQs working :)

That makes five out of six. Mario RPG fans are quite unlucky :/

Image

Get Gideon to release a UPS patch and I'll post English screenshots :D
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

powerspike wrote:Also I doubt anything bad would happen to it.
As do I, but it's possible. It could get stolen, lost in the mail, or byuu's neighbor could be a paranoid schizophrenic who thinks he's stealing his energy and cuts him down in the parking lot with a decorative sword before he can send it back to you.

http://www.madison.com/wsj/topstories/445676
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

byuu wrote:

Code: Select all

if(mmio.sa1_irq) {
    mmio.irq_flag = true;
    if(mmio.cpu_irqen == true) mmio.irqcl = 0;
  }
Mmmh, explicitly testing for true? Seems inconsistent... :?:
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
adventure_of_link
Locksmith of Hyrule
Posts: 3634
Joined: Sun Aug 08, 2004 7:49 am
Location: 255.255.255.255
Contact:

Post by adventure_of_link »

FitzRoy wrote:Right, but then he's dicking with someone else's $40 property to save $5. There's also the possibility that a problem is found well after he's sent it back to you, and he won't have it to run tests on anymore.
I'm not sure if this'd help or hurt the SA-1 case, but maybe byuu could run tests on the SMRPG cart specifically to see if there's something particular that this game uses? :?
<Nach> so why don't the two of you get your own room and leave us alone with this stupidity of yours?
NSRT here.
Gil_Hamilton
Buzzkill Gil
Posts: 4294
Joined: Wed Jan 12, 2005 7:14 pm

Post by Gil_Hamilton »

powerspike wrote:
byuu wrote:I'd need another SA-1 cart.
I'll loan you my mario rpg cart as long as you back up my saved game before experimenting. Just PM me any shipping details.

Matsuri loev mario rpg..
Image
She loves it enough to give it an upskirt shot, even.

byuu wrote:
Gil_Hamilton wrote:I want pictures of SRW Gaiden!
Lucky you. It didn't get past the Banpresto logo until I got the IRQs working :)

That makes five out of six. Mario RPG fans are quite unlucky :/

Image

Get Gideon to release a UPS patch and I'll post English screenshots :D
Hooray! GOGOGO!


If I could get Gid to release ANY patch, I would.
...
Which I guess means I need to start whipping his translator/proofreader.
YAH! MUSH!
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

adventure_of_link wrote:I'm not sure if this'd help or hurt the SA-1 case, but maybe byuu could run tests on the SMRPG cart specifically to see if there's something particular that this game uses? :?
Maybe, but he expressed desire for a generic cart, so I didn't think it mattered.
powerspike
Regular
Posts: 236
Joined: Mon Nov 21, 2005 3:43 am

Post by powerspike »

Gil_Hamilton wrote: She loves it enough to give it an upskirt shot, even.
Just some fan service for a boring photo. :P :D

FritzRoy wrote: As do I, but it's possible. It could get stolen, lost in the mail, or byuu's neighbor could be a paranoid schizophrenic who thinks he's stealing his energy and cuts him down in the parking lot with a decorative sword before he can send it back to you.

http://www.madison.com/wsj/topstories/445676
*Makes a note to insure his snes carts* Haha god damn that guy is loon. I'll be more careful with my own property from now on. :wink:
Killa B
♥ Love Freak FlonneZilla ♥
Posts: 111
Joined: Sun Apr 01, 2007 12:59 am
Location: USA
Contact:

Post by Killa B »

Wow, how does one even go about obtaining so much ninja contraband? :o
franpa
Gecko snack
Posts: 2374
Joined: Sun Aug 21, 2005 11:06 am
Location: Australia, QLD
Contact:

Post by franpa »

Killa B wrote:
Wow, how does one even go about obtaining so much ninja contraband? :o
Yo suspectin' someone stealin' yo energy too?
Core i7 920 @ 2.66GHZ | ASUS P6T Motherboard | 8GB DDR3 1600 RAM | Gigabyte Geforce 760 4GB | Windows 10 Pro x64
Killa B
♥ Love Freak FlonneZilla ♥
Posts: 111
Joined: Sun Apr 01, 2007 12:59 am
Location: USA
Contact:

Post by Killa B »

Yes, that is precisely why I asked that question. :roll:
Locked