Skip to content

Use libzedmd for ZeDMD#450

Merged
freezy merged 26 commits intofreezy:masterfrom
PPUC:libzedmd
Feb 4, 2024
Merged

Use libzedmd for ZeDMD#450
freezy merged 26 commits intofreezy:masterfrom
PPUC:libzedmd

Conversation

@mkalkbrenner
Copy link
Copy Markdown
Contributor

This eases the code within DMDext and avoid the redundant implementation of new features.
libzedmd is the platform independent communication library for ZeDMD which is also used by PPUC and VPX Standalone.

@mkalkbrenner mkalkbrenner marked this pull request as draft December 9, 2023 12:23
@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@freezy I got all modes to work. It would be nice if you can review the PR and ideally merge it.
https://www.youtube.com/watch?v=B6D00oB4Co8

@endeemillr
Copy link
Copy Markdown

I tried this out after updating my ZeDMD and am getting errors. "No external DMD driver found" The old dll is working just fine. I'm hoping to iron out the issues when I run non-colorized stern roms.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@endeemillr You need ZeDMD firmware v3.4.1 and ensure to have the right settings in DmdDevice.ini.
Others reported, that everything works.

@freezy I think the PR is ready to be merged.

Maybe @zesinger can post if this version works for him.

For everyone who wants to test it, I built these DLLs:
https://github.com/PPUC/dmd-extensions/releases/tag/v2.2.2-zedmd.beta.2

@endeemillr
Copy link
Copy Markdown

Thanks! I found a com= (blank) line that I commented out and that seemed to do the trick. Would it be possible to share a new .ini file? I've pasted what I could find in the discord, but must be missing something. My Stern 16 shade dmds still act strange. I can control them a little, but usually the main text goes black, and I have to do a full restart to make any color changes effective,and usually only showing in the Stern logo page.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@endeemillr the DmdDevice.ini changes are part of this PR. You can see them here:
https://github.com/freezy/dmd-extensions/pull/450/files#diff-88e3d2463904a53acc621a133a122746310960b6e6278a3bbd275a72f033c3ae

Ideally you contact me on discord and we can go through your issues.

@freezy
Copy link
Copy Markdown
Owner

freezy commented Dec 31, 2023

Awesome! I'll go through it in the next days.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@endeemillr The last commit should fix custom colors for 16 color games.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

Here's a build for those who want to test:
https://github.com/PPUC/dmd-extensions/releases/tag/v2.2.2-zedmd.beta.3

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@endeemillr reported on discord, that the 16 colors custom palette is working now.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@freezy it would be great if you find some time to review and ideally merge this PR.
Since I only provided new DLLs of DMDExt for testing purposes, people start complaining about PinUp Popper because it requires the EXE ;-)

@freezy
Copy link
Copy Markdown
Owner

freezy commented Jan 12, 2024

Well, you keep adding commits, so I'm assuming it's not for prime time yet?

Which .exe do you mean?

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@freezy We're done :-)

I don't use PinUp Popper. But I have been told that it uses DmdDevice.exe which I don't build for the testers.

@freezy
Copy link
Copy Markdown
Owner

freezy commented Jan 13, 2024

Ah, dmdext.exe, gotcha.

I'll try to have a go at it tomorrow.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@zesinger also tested the current version of the PR.

Comment thread LibDmd/DmdDevice/DmdDevice.cs
@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

mkalkbrenner commented Jan 21, 2024

@freezy no code change. I just updated libzedmd to the latest version v0.5.0.
(people could do so by just putting new DLLs in the VPinMAME folder after you merged this PR)

Copy link
Copy Markdown
Owner

@freezy freezy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry it took so long to review.

I figure you'd like to have another release after that?

Comment thread LibDmd/DmdDevice/DmdDevice.cs
Comment thread LibDmd/Output/ZeDMD/ZeDMD.cs
Comment thread LibDmd/Output/ZeDMD/ZeDMD.cs Outdated
Comment thread LibDmd/Output/ZeDMD/ZeDMD.cs Outdated
Comment thread LibDmd/Output/ZeDMD/ZeDMD.cs Outdated
Comment thread LibDmd/Output/ZeDMD/ZeDMDBase.cs Outdated
// 2 colors (1 bit) is not supported by ZeDMD.
if (numOfColors == 2) { numOfColors = 4; }

while (numOfColors > 0) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this loop works and its break conditions. Any way to simplify?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this feature should be elsewhere in dmdext. But it is the bugfix for @endeemillr report.
it converts a 4 color custom palette into a 16 and a 64 color custom palette. And it sets all, the 4 color and the 16 color and the 64 color palette in ZeDMD which could hold different palettes at the same time.
So it works if DMDext only calls SetPalette() once and then switches between Gray2, Grey4 and Grey6 for different frames.

Copy link
Copy Markdown
Owner

@freezy freezy Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is lacking too much readability for me. How about this? I assume the _pZeDMD pointer doesn't change during the loop?

if (_pZeDMD == IntPtr.Zero) {
	return;
}
if (numOfColors != 4 && numOfColors != 16 && numOfColors != 64) {
	return;
}

while (numOfColors <= 64) {
	var palette = ColorUtil.GetPalette(colors, numOfColors);
	var pos = 0;

	foreach (var color in palette) {
		paletteBuffer[pos++] = color.R;
		paletteBuffer[pos++] = color.G;
		paletteBuffer[pos++] = color.B;
	}
	ZeDMD_SetPalette(_pZeDMD, paletteBuffer, numOfColors);

	numOfColors *= 4; 
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this version of the code is easier to read and understand.

Comment thread LibDmd/Output/ZeDMD/ZeDMDHD.cs Outdated
Comment thread LibDmd/Output/ZeDMD/ZeDMDHD.cs
Comment thread LibDmd/Output/ZeDMD/ZeDMDHDWiFi.cs Outdated
Comment thread LibDmd/Output/ZeDMD/ZeDMDWiFi.cs Outdated
@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

mkalkbrenner commented Jan 23, 2024

Thanks! Sorry it took so long to review.

No problem.

I figure you'd like to have another release after that?

Yes, another DMDext release would be great.
But a CI dev build would also be OK to let people test it. At the moment it is difficult because of the missing installer in my test builds.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@freezy I addressed all your concerns. I think the code looks much better now.

@freezy
Copy link
Copy Markdown
Owner

freezy commented Jan 27, 2024

If you give me write access to PPUC/dmd-extensions, I'll push some cleanup that you can test before we merge.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

If you give me write access to PPUC/dmd-extensions, I'll push some cleanup that you can test before we merge.

@freezy access granted

@freezy
Copy link
Copy Markdown
Owner

freezy commented Jan 28, 2024

Thanks! Pushed my changes.

The only remaining part now is the rewrite of the palette function. Did you have a chance to have a look?

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@freezy I tested you changes. ZeDMD and ZeDMD HD are working. (Actually, I didn't change the code back again after my experiments to let ZeDMD HD inherit from ZeDMD. So you're changes are correct and simplify the code.)

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

@freezy I refactored SetPalette() and tested it with Avatar.

@mkalkbrenner
Copy link
Copy Markdown
Contributor Author

So, I think everything is addressed now.

@freezy
Copy link
Copy Markdown
Owner

freezy commented Feb 4, 2024

All good, thanks for bearing with me!

@freezy freezy merged commit 93d3c52 into freezy:master Feb 4, 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

Successfully merging this pull request may close these issues.

3 participants