6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 1:05 am

All times are UTC




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Nov 10, 2020 8:11 pm 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
Druzyek wrote:
vbt wrote:
Druzyek wrote:
vbt, where did you get the copyright message you have in your files on github?
Most are from the original FBA (final burn alpha), it no more exists and became FBNeo)
I will steal this for my own projects if you have no objections.

ok for me, if you make some changes, tell me :)

Druzyek wrote:
Looks like the Sega Master System had a 4MHz Z80, so it's in the same ballpark! I recently looked into the SH4 variant that comes in a calculator I bought a few weeks ago, which is a descendant of the SH2. Single cycle instructions on 32 bit registers should be really fast!


yes it should be fast, i may check some sh4 asm version of 6502 but it's not so easy to convert, i did that on faze (Z80 sh4 asm little endian) and it's a bad souvenir.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 12, 2020 1:42 pm 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
BigEd wrote:
However, I'd suggest you take a look at Ian Piumarta's lib6502, as that has always looked good to me. There's a slightly enhanced fork here:
https://github.com/ZornsLemma/lib6502-sf
and the original is here:
https://www.piumarta.com/software/lib6502/

lib6502 is nice but contains some asm part, i won't be able to rewrite them.
Another great 6502 emulator is :
https://github.com/Embedfire/ebf_linux_ ... /K6502.cpp

I didn't test it yet just found the nice lookup tables .


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 12, 2020 1:48 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Hmm, are you looking at something different from what I'm familiar with? I feel pretty confident in saying lib6502 is written entirely in C.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 12, 2020 5:17 pm 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
BigEd wrote:
Hmm, are you looking at something different from what I'm familiar with? I feel pretty confident in saying lib6502 is written entirely in C.

oops i've confused with https://github.com/scarybeasts/beebjit :(


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 12, 2020 5:24 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Hee hee - no problem! (There's also a fancy library format called lib6502)


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 12, 2020 5:28 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
BTW as the Saturn CPU has a small cache, a code-only approach like lib6502 might be a win compared to a table-driven approach. But you can only check this by benchmarking both.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 12, 2020 11:57 pm 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
BigEd wrote:
BTW as the Saturn CPU has a small cache, a code-only approach like lib6502 might be a win compared to a table-driven approach. But you can only check this by benchmarking both.

you seem to be sure of the different approach, so i will try it, I have 1 game as benchmark tool :

Image

first m6502 ran at 20 fps, i'll tell you the results :)


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 13, 2020 7:38 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
I am holding my breath! (In any case, it will be interesting to hear)


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 13, 2020 8:25 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
BTW one of the easiest improvements to make, if it's applicable, is this: instead of having the emulator check for interrupts and/or service peripheral modelling on every instruction, run several instructions between checks. If you presently run one instruction at a time, and increase that to four, for example, that can make a huge reduction in the per-instruction overhead, and make a correspondingly healthy performance increase. (When instructions read or write peripheral registers, of course that will usually need to be handled at once. But most instructions don't.)


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 15, 2020 1:54 am 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
BigEd wrote:
BTW one of the easiest improvements to make, if it's applicable, is this: instead of having the emulator check for interrupts and/or service peripheral modelling on every instruction, run several instructions between checks. If you presently run one instruction at a time, and increase that to four, for example, that can make a huge reduction in the per-instruction overhead, and make a correspondingly healthy performance increase. (When instructions read or write peripheral registers, of course that will usually need to be handled at once. But most instructions don't.)

I did something like that, that's such great hint i'm looking for :mrgreen:

The interrupt part was moved before the loop, i won 8-10 fps with that trick :

Image


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 23, 2020 1:12 am 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
trying to do an interface over lib6502 :

Code:
#include "../burnint.h"
#include "lib6502.h"

#define M6502_READ   1
#define M6502_WRITE   2
#define M6502_FETCH   4
M6502 *mpu = NULL

INT32 libM6502Init(INT32 cpu, INT32 type)
{
   mpu = M6502_new(0, 0, 0);
   return 0;
}

void libM6502SetIRQLine(UINT32 vector, UINT32 status)
{
   if (status == 0)
   {
      M6502_setVector(mpu, NMI, status);
      M6502_setVector(mpu, IRQ, status);
   }
   if (status == 1)
   {
      M6502_setVector(mpu, IRQ, status);
   }
}

void libM6502_Reset(void)
{
   M6502_reset(mpu);
}

INT32 libM6502MapMemory(UINT8* pMemory, UINT16 nStart, UINT16 nEnd, INT32 nType)
{
   UINT32 cStart = (nStart>>0);

   for (UINT32 i = cStart; i <= (nEnd>>0); i++) {
      if (nType & M6502_READ)   {
         mpu->memory[i] = pMemory + ((i - cStart) << 0);
      }
      if (nType & M6502_WRITE) {
         mpu->memory[i] = pMemory + ((i - cStart) << 0);
      }
      if (nType & M6502_FETCH) {
         mpu->memory[i] = pMemory + ((i - cStart) << 0);
      }
   }
   return 0;
}

void libM6502SetReadHandler(UINT16 nStart, UINT16 nEnd,UINT8 (*pHandler)(UINT16))
{
   UINT8 cStart = (nStart >> 8);
   
   for (UINT32 i = cStart; i <= (nEnd >> 8); i++)
   {   
      mpu->callbacks->read[i] = pHandler;
   }   
}

void libM6502SetWriteHandler(UINT16 nStart, UINT16 nEnd,void (*pHandler)(UINT16, UINT8))
{
   UINT8 cStart = (nStart >> 8);
   
   for (UINT32 i = cStart; i <= (nEnd >> 8); i++)
   {   
      mpu->callbacks->write[i] = pHandler;
   }
}

int libM6502_Execute(int cycles)
{
   M6502_run(mpu,cycles);
}


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 24, 2020 1:08 am 
Offline

Joined: Mon Nov 09, 2020 11:24 am
Posts: 12
well, for now, just black screen, i don't see how it manages cycles (no m6502_icount) and interrupt waits like other cores.
i tried to add a loop without success :

# define begin(cycles) for (int i=0;i<cycles;i++){ fetch(); next(); }


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 24, 2020 7:35 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Hmm, not sure what's happening. Are you able to add some printfs, or use a debugger, to see what's happening?

I don't quite understand what you're doing with the nStart and cStart - could you explain?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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:  
cron