Recent

Author Topic: ZX Spectrum emulator  (Read 1893 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
ZX Spectrum emulator
« on: November 06, 2022, 01:43:56 am »
ZX spectrum emulator

It's named Swan... I have had hard time with thinking of a cool name, so during development I named it SWAN (Still Without A Name), until I would find a real name. Eventualy letters only got lower shapes and... now it is the name.

Sorces in Github page.

I made some quick notes in the wiki page, take a look.

To compile, you need BGRA bitmap (BGRA was faster than any other way mentioned in the wiki page about fast pixel access).

For a start, I made Windows (64 and 32 bit) releases (https://github.com/zoran-vucenovic/swan/releases). I am going to release Linux builds soon.
You can compile for Linux yourself.

To have sound you need portaudio library (see the notes in project front page, or wiki)


cappe

  • Full Member
  • ***
  • Posts: 191
Re: ZX Spectrum emulator
« Reply #1 on: November 06, 2022, 08:41:33 am »
nice, as soon as I have time I try it

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: ZX Spectrum emulator
« Reply #2 on: November 06, 2022, 11:39:47 am »
I tried on MacOS. It works  :)

Some remarks: when pressing a key, the system sound for unhandled key is played. You can void this by setting Key to 0 in the event handlers. You may want to do something more subtle, like setting to 0 if the key is recognized. Otherwise shortcut to menus don't work anymore.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DoOnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.   AddKeyEventToQueue(Key, True);
  4.   Key := 0;
  5. end;
  6.  
  7. procedure TForm1.DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  8. begin
  9.   AddKeyEventToQueue(Key, False);
  10.   Key := 0;
  11. end;  

To get sound, I installed PortAudio using brew:
Code: Bash  [Select][+][-]
  1. brew install portaudio

The screen size is not saved, and on my screen, the starting size is too small. I suggest either to set a bigger size on startup for MacOS or to save the size of the screen in the config.

I am glad you used my library BGRABitmap.  :)
Conscience is the debugger of the mind

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: ZX Spectrum emulator
« Reply #3 on: November 06, 2022, 05:39:35 pm »
I tried on MacOS. It works  :)

I am very glad to hear that. I don't have Mac, so cannot test for myself.

Some remarks: when pressing a key, the system sound for unhandled key is played. You can void this by setting Key to 0 in the event handlers. You may want to do something more subtle, like setting to 0 if the key is recognized. Otherwise shortcut to menus don't work anymore.

I understand the problem. I'll see to fix it. I haven't experienced it on Windows/Linux. I think I am going to handle the keys for menu myself (instead of built-in menu shortcuts) and then set key to zero.

To get sound, I installed PortAudio using brew:
Code: Bash  [Select][+][-]
  1. brew install portaudio

Ok

The screen size is not saved, and on my screen, the starting size is too small. I suggest either to set a bigger size on startup for MacOS or to save the size of the screen in the config.

Fixed. Screen size is saved in config now.

I am glad you used my library BGRABitmap.  :)

Thank you very much for creating and maintaining it all these years.

Okoba

  • Hero Member
  • *****
  • Posts: 533
Re: ZX Spectrum emulator
« Reply #4 on: November 07, 2022, 07:47:47 am »
Very cool project and even cooler name :D
P.S. Thank you to Circular for BGRABitmap indeed.

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: ZX Spectrum emulator
« Reply #5 on: November 07, 2022, 04:04:05 pm »
Some remarks: when pressing a key, the system sound for unhandled key is played.

What happens on Mac if you set key to zero only in DoOnKeyUp, but not in DoOnKeyDown? Is this system sound played? Do menu shortcuts still work then?
I understand that it is probably too simple to really solve this, but who knows... I can hope.

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: ZX Spectrum emulator
« Reply #6 on: November 08, 2022, 02:50:34 pm »
Thank you for sharing it.

It compiled and run on my Linux system.

mdalacu

  • Full Member
  • ***
  • Posts: 233
    • dmSimpleApps
Re: ZX Spectrum emulator
« Reply #7 on: November 08, 2022, 02:57:55 pm »
Wow! Congrats!

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: ZX Spectrum emulator
« Reply #8 on: November 11, 2022, 11:22:35 am »
Thank you very much for creating and maintaining it all these years.
You're very welcome. :)

Quote
What happens on Mac if you set key to zero only in DoOnKeyUp, but not in DoOnKeyDown? Is this system sound played? Do menu shortcuts still work then?
I understand that it is probably too simple to really solve this, but who knows... I can hope.
That doesn't solve it. The sound is emitted as soon as the key is pressed. Maybe just a simple test on which key is pressed can be enough, if there is no overlap.
Conscience is the debugger of the mind

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: ZX Spectrum emulator
« Reply #9 on: December 29, 2022, 05:10:32 pm »
Some remarks: when pressing a key, the system sound for unhandled key is played.

Please try now.

To all: New version 0.9.2 released.

Improved accuracy, redcodes tests collection helped a lot there.

Several features added since initial release:
  • Autosaving snapshots, quick going back in time and browsing saved snapshots (see more here).
  • Loading and saving of SZX format snapshot files.
  • Files can be opened by drag and drop to emulator.

Github repository: https://github.com/zoran-vucenovic/swan

Precompiled binaries for
- Windows 64 and 32 bit.
- Linux 64 bit, Gtk2 and Qt5 (note that for Qt5 you need libQt5pas).

For sound to work, portaudio library is needed, as explained on wiki page.
« Last Edit: December 29, 2022, 05:13:33 pm by Zoran »

 

TinyPortal © 2005-2018