Nes emulator with Harbour

124 views
Skip to first unread message

vag...@gmail.com

unread,
Jul 5, 2021, 1:56:53 AM7/5/21
to Harbour Developers
Hi Guys, I ported this emulator from Go to Harbor, it's slow and could be a great reference for optimizing the Harbor.

https://github.com/vagucs/harbournes

Hugs
Wagner Nunes

Aleksander Czajczynski

unread,
Jul 5, 2021, 3:56:50 AM7/5/21
to harbou...@googlegroups.com
vag...@gmail.com wrote:
> Hi Guys, I ported this emulator from Go to Harbor, it's slow and could
> be a great reference for optimizing the Harbor.
>
> https://github.com/vagucs/harbournes
Nice to see something done purely for fun ;-)

The huge optimizations known to the world are typed variables - so the
code has much less runtime checks.
If it's not what you like, then some form of runtime code path analysis
(see JIT techniques for JavaScript in browsers).

Should Harbour support typed variables eventually? Yes, I think so.
Should it support C types directly? I have doubts here and there. If you
looked for statically (or mixed) typed xBase, you had CAVO. See also
XSharp, if you like the size of .NET runtime.

You have mentioned Go - which I think points to the right direction in
case of how the statically typed variables should look like.

Best regards, Aleksander

Francesco Perillo

unread,
Jul 5, 2021, 4:58:16 AM7/5/21
to harbou...@googlegroups.com
Hi,
congratulations with this project, it seems really interesting to see how far Harbour can stretch its capabilities.

I went to have a look at the code and saw some things that - my idea - make the program slower.

First of all, the use of classes. Classes are great, I use them as much as I can, but how they are implemented in harbour, due to the dynamic nature of the language, are not quick. Not at all compared to c++ and other static languages.

If you have only one instance of a class, you may try to change the source code in a module with STATIC variables and functions instead of DATA and METHODS... Harbour should invoke them quicker.

Then I went to cpu.prg and saw your tests for handling cpu instructions. The go implementations uses a table of function pointers. It seemes like you tried to do the same thing but then opted for a standard anda probably slower DO CASE... Was the array method not working properly?


Your code is clean, easy to read and follow, well organized, and classes help a lot. Unfortunately they make the code slower.

Francesco

PS: I understand you were trying to mimick StepInfo with {address, ::PC, mode} but I think that creating a codeblock makes the code slower. You should trying to pass the parameters as  ::nop( address, ::PC, mode ) 



--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/ffec0f4e-da24-4a04-885a-3e1633cfab07n%40googlegroups.com.

cnavarro

unread,
Jul 5, 2021, 4:38:49 PM7/5/21
to Harbour Developers
Congratulations on the initiative and development.
Reply all
Reply to author
Forward
0 new messages