Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal debugger for ZX81 developments #128

Closed
stevexyz opened this issue Jul 27, 2024 · 69 comments
Closed

Internal debugger for ZX81 developments #128

stevexyz opened this issue Jul 27, 2024 · 69 comments

Comments

@stevexyz
Copy link

Recently I was trying to come back to some ZX81 development, but discovered that for some reason current version of Zesarux is not working with DeZog.
Unfortunately for ZX81 seems there are no other compatibilities, and I was wondering if it would be possible to extend the internal debugger to support also this machine.
I think it would also greatly simplify the setup of the development environment needing just VSCode and Dezog, and even without init files if you find a ".p" file with the same name as ".asm" everything could be setup automatically (looking also for sld etc).

@andrivet
Copy link
Contributor

There is a fork with what you need. This is explained in the Readme of DeZog: https://github.com/maziac/DeZog#fork
(i am the author of the fork)

@maziac
Copy link
Owner

maziac commented Jul 27, 2024

Yes, please try the fork and see if it fits your needs.
I was also thinking of adding zx81 in the future, but with that fork I think there is little need for it...

@andrivet
Copy link
Contributor

I was also thinking of making my fork more compatible with DeZog but I am not sure it is worth the effort. So many ideas, so many projects and not enough time.

@stevexyz
Copy link
Author

WOW, this is the way!!
The main limitation I see is related to the assembler, unfortunately way too simple for anything more than very basic programs, and surely very much underpowered for my needs (e.g. I’m trying to create a new version of the 1K Real Chess for ZX81). Without reimplementing things (standard undocumented instructions, powerful directives, etc), would it be possible to integrate a more powerful ready one as for example sjasmplus (https://github.com/z00m128/sjasmplus) or fasm/fasmg (https://github.com/jacobly0/fasmg-z80)?

@andrivet
Copy link
Contributor

Post your question in the fork repository if it relates to the fork.

@andrivet
Copy link
Contributor

andrivet commented Aug 2, 2024

I have backported my code for the ZX81 into the latest version of DeZog and submitted a PR. It does not use my own Z80 assembler but an external one so this should solve your problems @stevexyz . I do not know when Maziac will have the time to review the PR so in the meantime, you can use my (second) fork: https://github.com/andrivet/DeZog/tree/zx81-publish. I have published a VSIX under Releases.

@maziac
Copy link
Owner

maziac commented Aug 4, 2024

Hi, thanks very much for the back port. I very much appreciate your work.
As I already mentioned it will probably take some time until I can re-use your work.
Here is my current plan for a "roadmap" just to give you an idea:

  1. dezog 3.4.0 (zxndma): in 1 week
  2. some other project: Time = ?
  3. dezog 3.5.0: zsimremote re-factored as web view: 2 months
  4. dezog 3.6.0: zx81 integration

My thoughts so far:
The zsim is a z80 simulator. I.e. the ZX Spectrum additions are just additional HW simulations that can be enabled one by one. If you put the right "HW" together you get the ZX Spectrum (i.e. ula + keyboard + zxbeeper mainly).
I would like to keep it the same for the zx81. I.e. rather than having a separate "zx81sim" I will try to set this inside the current "zsim".
Maybe I'll add something like a "collection" (inside "zsim") where you can just type "zx81" or "zxspectrum" and it enables the defaults with the right HW for you.

@maziac
Copy link
Owner

maziac commented Aug 20, 2024

I changed my plans/schedule and directly started with the zx81 development for dezog.
Please check this release candidate
dezog-3.5.0-rc1.vsix.zip
The internal simulator (zsim) has been improved by zx81 features.
Changes are:

  • Simulation of ZX81.
  • Removed "vsyncInterrupt". A VSYNC interrupt is now generated if the Spectrum ULA is enabled.
  • "ulaScreen":
    • Type changed from boolean to 'spectrum' | 'zx81'.
  • Z80 CPU simulation fix: HALT instruction: r is now incremented on each instruction.
  • New debug command, "-ml address filepath", to load binary data into the memory.
  • Fixed setting of A' from the UI.
  • The "zxKeyboard"
    • now supports reading several rows at the same time.
    • type changed to string. "zx81" and "spectrum" style keyboard supported.
    • keyboard visualization improved.
  • The "kempstonJoy" now decodes only the lower 8 bits of the address.
  • A new "costumJoy" type: You can assign the bits and ports yourself.
  • Added "preset" to easily configure a spectrum or zx81 device.

Bildschirmfoto 2024-08-20 um 17 22 26

@maziac
Copy link
Owner

maziac commented Aug 21, 2024

Here is the updated documentation:
https://github.com/maziac/DeZog/blob/zx81/documentation/Usage.md
https://github.com/maziac/DeZog/blob/zx81/documentation/Migration.md

For a zx81 project you could use the following launch.json:

{
	"version": "0.2.0",
	"configurations": [
		{
			"type": "dezog",
			"request": "launch",
			"name": "zsim - ZX81-16K",
			"remoteType": "zsim",
			"zsim": {
				"preset": "zx81"
			},
			"commandsAfterLaunch": [],
			"history": {
				"reverseDebugInstructionCount": 1000000,
				"spotCount": 10,
				"codeCoverageEnabled": true
			},
			"startAutomatically": false,
			"rootFolder": "${workspaceFolder}",
			"load": "Mazogs.p81",
		}
         ]
}

@andrivet
Copy link
Contributor

Very nice work. A few remarks:

  • The frequency for the ZX81 is wrong, it should be 3.25 MHz, not 3.5.
  • The image of the keyboard is blurry (low resolution). I have recreated the keyboard in a vector format. I put a version below in SVG. I can try to do the same for the ZX Spectrum if you find this useful.

ZX81_keyboard

@maziac
Copy link
Owner

maziac commented Aug 25, 2024

"The frequency for the ZX81 is wrong, it should be 3.25 MHz, not 3.5."
Good hint, will change it.

"The image of the keyboard is blurry (low resolution). I have recreated the keyboard in a vector format. I put a version below in SVG."
That is great. If you put that in MIT license (or any free Common license) I would be happy to use it (of course with a credit).

" I can try to do the same for the ZX Spectrum if you find this useful."
Yes, same for this. An SVG image would be great.

@maziac
Copy link
Owner

maziac commented Aug 25, 2024

I'm adding a "zx81-hires" simulation for the "ulaScreen".
It is working (the zx81 branch) but it does flicker a little bit.
Especially the (ula) line counter seems to be off by 1 or 2, but not constant.
Do you have any idea what could be wrong with the simulation (Zx81UlaHiscreen)?
I must be missing some detail...

@andrivet
Copy link
Contributor

andrivet commented Aug 26, 2024

Here is the ZX Spectrum keyboard in SVG.

48k_kbd

Both (ZX81 and ZX Spectrum keyboards SVG) are under CC BY-SA 4.0

For Zx81UlaHiscreen, I will look at it when I get some time.

@maziac
Copy link
Owner

maziac commented Aug 27, 2024

The keyboard looks great!

"For Zx81UlaHiscreen, I will look at it when I get some time."
I looked into the implementation of zxsp. Probably the timing is not as accurate as required.
I will try to use the zxsp implementation.

@maziac
Copy link
Owner

maziac commented Aug 27, 2024

Please check this commit for adding the keyboard files and the attribution: 003bb1b

@andrivet
Copy link
Contributor

andrivet commented Aug 27, 2024

👍 perfect, thanks

@maziac
Copy link
Owner

maziac commented Aug 27, 2024

I was just thinking: The keypress boxes are now not aligned anymore with the svg.
Is there a way that I could directly use some svg id of the keys to get the size and draw the button press highlight with the size of the svg element. Not sure how to do that or integrate it with the html/js...
Maybe it is also possible to add the 'onClick' directly to the svg.
Would be more straightforward then to overlay it with html elements for the key presses.

@andrivet
Copy link
Contributor

I don’t think it is possible.
What I can do is to modify the SVG to place keys exactly where they where in the PNG.

@maziac
Copy link
Owner

maziac commented Aug 27, 2024

You don't have to. I probably have to adjust just a few offsets.

@andrivet
Copy link
Contributor

And why not adding the QL like Spectrum keyboard, and the ZX80 one! Half joking…. One day, i am a little busy these days.

@maziac
Copy link
Owner

maziac commented Aug 27, 2024

Could you please have a look. Seems the newline key is a little bit off the right margin.
Bildschirmfoto 2024-08-27 um 22 08 46
I have changed the css so that it displays a red border around the available space.

@ped7g
Copy link

ped7g commented Aug 28, 2024

How about source level debug (SLD) data? I have on sjasmplus open issue #232 about what virtual device to use for zx80/81, and I'm not deeply familiar with these machines, but it still feels to me like classic ZXSPECTRUM48 should cover this use case too?

Maziac: I guess you will test DeZog with SLD for the ZX81? Let me know in case you are missing anything on sjasmplus side, and if you have some recommendation which sj virtual device to use for ZX80/81, so I close this thing and put it off my mind. :) TY.

@andrivet
Copy link
Contributor

@ped7g use NOSLOT64K, it works for the ZX81

@maziac
Copy link
Owner

maziac commented Aug 28, 2024

Yes, agree.

@andrivet
Copy link
Contributor

This should be better:
ZX81_keyboard

I can do the same for the Spectrum if you need it.

@maziac
Copy link
Owner

maziac commented Aug 29, 2024

Everything fine, thanks. Both keyboards work now.

@andrivet
Copy link
Contributor

andrivet commented Sep 1, 2024

I see you have solved the flickering in HiRes mode. I played with it a little (with PacMan in Pseudo HiRes for example), it works nicely.

@maziac
Copy link
Owner

maziac commented Sep 1, 2024

Flickering is almost solved, but there is still a little bit remaining in Battlestar Galactica. Ist's non-hires, but if you play that with either hires or normal, there is sometimes still a little flicker.

@maziac
Copy link
Owner

maziac commented Sep 2, 2024

I have analyzed this a bit. After starting Galactica there is sometimes a little flickering when the 2nd or 3rd screen is created.
The screen is a dfile in collapsed format although this is using 16k or more.
Bildschirmfoto 2024-09-02 um 18 39 59
I'm not sure how this can happen.
Maybe I'm initializing something wrong.

For a collapsed dfile I would think that some flickering is OK, because to extend a line there is some copying within the dfile required.
But the question is: why is the dfile collapsed?

@maziac
Copy link
Owner

maziac commented Sep 2, 2024

OK, found it. It was hack I did for one game. Removed it and no flickering anymore.

@maziac
Copy link
Owner

maziac commented Sep 23, 2024

Meanwhile I also integrated ARX and chroma81 support.
Currently I'm working on chr$128/UDG.
There are quite a number of graphics modes...

@maziac
Copy link
Owner

maziac commented Sep 29, 2024

@stevexyz I would like to use part of your code in z00m128/sjasmplus#239 (comment) in a loader wrapper I would like to publish on GitHub.
Is it MIT license?

@stevexyz
Copy link
Author

@stevexyz I would like to use part of your code in z00m128/sjasmplus#239 (comment) in a loader wrapper I would like to publish on GitHub. Is it MIT license?

For my part you can use the license you prefere, but let me ask also the original author if he is ok with it. Let you posted.

@stevexyz
Copy link
Author

MIT license fine also for Lardo, even if he do not remeber furher the code origins. cfr: https://sinclairzxworld.com/viewtopic.php?p=56796#p56796
What I can say is that is so simple program that should not be a problem.

@maziac
Copy link
Owner

maziac commented Sep 30, 2024

Fine. Thanks.

@maziac
Copy link
Owner

maziac commented Sep 30, 2024

Here is a release candidate for the 3.5.0 DeZog (ZX81):
https://github.com/maziac/DeZog/releases/tag/untagged-3e63a966abeac6bdde0f

The ZX81 sample project (with the BASIC wrapper to create a p-file) is here:
https://github.com/maziac/zx81-sample-program

If you would like to test it I would be happy get your error reports (or success stories :-) ).

@andrivet
Copy link
Contributor

andrivet commented Oct 5, 2024

It is working pretty well.

The only cases where the simulation is not working 100% are with binaries that push the ZX81 to its limits. A notable example is 25THANNI, a demo that includes source code. ZesarUX is working a little better but not completely. The only simulator I am aware of that works 100% is the iPadOS / macOS ZX81 simulator.

In this part of the demo, some text is drawn outside of the regular area:
Screenshot 2024-10-05 at 16 11 07

Your simulated display is cropped so it does not show those lines:
Screenshot 2024-10-05 at 16 14 10

Another step displays a bouncing ball (press Space to go from one step to the next):
Screenshot 2024-10-05 at 16 11 35

Your simulation does display it but the ball is confined to the left:
Screenshot 2024-10-05 at 16 15 41

It is the same for the other steps.

@andrivet
Copy link
Contributor

andrivet commented Oct 5, 2024

On the success side, my game is working very well in your simulator. I wrote the original version in 1985; seeing it running in modern tools is a particular feeling.

Screenshot 2024-10-05 at 16 21 37

@maziac
Copy link
Owner

maziac commented Oct 5, 2024

Thanks for the thoroughly testing.
I will have a look.

@maziac
Copy link
Owner

maziac commented Oct 5, 2024

About yor game: you still have the assembler code?
And you had an assembler those days?

@andrivet
Copy link
Contributor

andrivet commented Oct 5, 2024

I have reversed engineered it some years ago (it was published in a journal in the ‘80 so I can get the binary back thanks to that). Last year, I documented the assembly and was able to fix a bug I was not able to fix 40 years ago. And yes in the ‘80, I had an assembler for this processor and machine.

@maziac
Copy link
Owner

maziac commented Oct 5, 2024

"And yes in the ‘80, I had an assembler for this processor and machine."
Lucky you. Those days I created my games by just using an hex editor.
I didn't even know that something like assemblers exist.
Some of the opcode numbers I still do remember...

@andrivet
Copy link
Contributor

andrivet commented Oct 6, 2024

At some point, I decided to buy an assembler. Before that, I computed opcodes by hand, on paper. I think it was this one: http://www.zx81stuff.org.uk/zx81/tape/ZXAssembler

@stevexyz
Copy link
Author

Here is a release candidate for the 3.5.0 DeZog (ZX81): https://github.com/maziac/DeZog/releases/tag/untagged-3e63a966abeac6bdde0f

I tried to install it, but not sure why debugger is not starting.
After Run->Start Debugging and selecting dezog nothing happen...

There is a way to enable and see some trace?

Since it might depend on the launch.json configuration, can you please provide an example compatible with the helloworld discussed above? (surely useful to complete the sample package!)

@maziac
Copy link
Owner

maziac commented Oct 13, 2024

Sure. you can find an example here:
https://github.com/maziac/zx81-sample-program
It is re-faactored but working very similar to the helloworld.zip.
It also comes with a readme/explanations.

@stevexyz
Copy link
Author

Sample program is working fine!!
With the internal debugger Dezog has become a gorgeous ZX81 IDE!!
Compliment for the superb work!!

@maziac
Copy link
Owner

maziac commented Oct 13, 2024

🙏

@maziac
Copy link
Owner

maziac commented Oct 20, 2024

Hi @stevexyz , Hi @andrivet ,

I have worked for some time on something else for ZX81 development.
Maybe you are interested to test.
It is another extension that allows to view p-files, convert to .bas (BASIC) files and convert back to .p files.

Please find here some screenshots:

Bildschirmfoto 2024-10-20 um 12 38 21
Bildschirmfoto 2024-10-20 um 12 38 46

Convert to BASIC:
Bildschirmfoto 2024-10-20 um 12 38 59
Bildschirmfoto 2024-10-20 um 12 39 17
Bildschirmfoto 2024-10-20 um 12 39 47

Modify the BASIC:
Bildschirmfoto 2024-10-20 um 13 04 47
Bildschirmfoto 2024-10-20 um 13 05 13

Convert back to .p:
Bildschirmfoto 2024-10-20 um 12 40 02

And load into dezog:
Bildschirmfoto 2024-10-20 um 13 07 23

I have tested already with a few files and it seem to work quite well. E.g Mazogs, 3D Monster Maze. Not working is "Against the elements" but I guess it uses some special hack.

If you would like to try:
zx81-bastop-1.0.0-rc1.vsix.zip

Any feedback appreciated...

@maziac
Copy link
Owner

maziac commented Oct 21, 2024

Here is an updated version:
zx81-bastop-1.0.0-rc2.vsix.zip

@stevexyz
Copy link
Author

I'm not into Basic, but there are many people that like it.
Surely what I see from the screenshots is really nice!!
I'll let other people know in the forum.

As a side note, looking at the implementation, I always preferred ZX80 implementation of the BASIC: much more efficient even if it is missing FP (in some use case mitigated using Q numbers). The same exact program will run much faster (around 350% faster probably even if using ZX81 in fast mode), and will occupy much less memory (really important for 1k).

@maziac
Copy link
Owner

maziac commented Oct 22, 2024

I didn't do much with the BASIC either but I wanted an option to "disassemble" one of my old projects, do changes and "reassemble" it.

@andrivet
Copy link
Contributor

This is really awesome. I will test it.

@maziac
Copy link
Owner

maziac commented Nov 1, 2024

@andrivet Had a hard time with 25thanni, but now it seems to work.
Please see here for the rc3 release: https://github.com/maziac/DeZog/releases/tag/untagged-3e63a966abeac6bdde0f
and let me know if you still see issues.
(Please note that a few launch.json parameters have changed, please have a look at the [zx81-zsim.md](https://github.com/maziac/DeZog/blob/main/documentation/zx81/zx81-zsim.md].

Bildschirmfoto 2024-11-01 um 13 39 10

Bildschirmfoto 2024-11-01 um 15 08 33

@andrivet
Copy link
Contributor

andrivet commented Nov 2, 2024

The simulation of the ULA display is so good now. Mind blowing!

@maziac
Copy link
Owner

maziac commented Nov 2, 2024

Thanks. It took me a while. For this demo to work I really had to go down to the single t-states.
Longest time took me the simulation of the "wait circuit". Not the simulation itself, but to understand that it was missing.

I'm about to release the 3.5 dezog, do you think anything is missing?

(BTW today I also released the p-file viewer (BASIC to P converter).)

@andrivet
Copy link
Contributor

andrivet commented Nov 2, 2024

I have in my (long) list of future projects the idea to recreate the ULA in an FPGA and make it open source (such ULAs do already exist but are closed source). Your wonderful work will help me with those tiny details.

I'm about to release the 3.5 dezog, do you think anything is missing?

I think it is ready.

(BTW today I also released the p-file viewer (BASIC to P converter).)

I just star it.

@andrivet
Copy link
Contributor

andrivet commented Nov 3, 2024

Something that is currently missing is the copyright for the ZX81 ROM in the Readme. Here is the authorization I get from John Grant of Nine Tiles:

Feel free to use the ROM code in any "free and open" projects.

@maziac
Copy link
Owner

maziac commented Nov 3, 2024

Thanks, for the hint.

@maziac
Copy link
Owner

maziac commented Nov 5, 2024

I close the Issue now.
The ZX81 simulation is integrated in DeZog v3.5.0 and has been released today.
If you find anything else please report a new issue.

Thank you both for all the help and testing.

@maziac maziac closed this as completed Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants