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

ZDI support broken because of PS2Controller default config #247

Open
mikolajmikolajczyk opened this issue Aug 16, 2024 · 2 comments
Open

Comments

@mikolajmikolajczyk
Copy link
Contributor

mikolajmikolajczyk commented Aug 16, 2024

In newest Console8 VDP (and classic 1.0.4) ZDI interface is broken.

This is caused by ZDI pins (26 and 27 on VDP) being also used by fabgl::PS2Controller default configuration.

static void begin(PS2Preset preset = PS2Preset::KeyboardPort0_MousePort1, KbdMode keyboardMode = KbdMode::CreateVirtualKeysQueue);

https://github.com/AgonConsole8/vdp-gl/blob/c16101479337e9967aa5c61b06b3fc0447e56f64/src/comdrivers/ps2controller.cpp#L1209

Simple solution I found is to recompile VDP soft with mouse disabled like this:

fabgl::PS2Controller::begin(fabgl::PS2Preset::KeyboardPort0, fabgl::KbdMode::CreateVirtualKeysQueue);

in this line:
fabgl::PS2Controller::begin();

I tried to disable mouse to make ZDI work again while agon is working but either I'm missing something or it cannot be done after CPU already started.

I tried these in vdu_sys.h (as test only):

		case VDP_CONSOLEMODE: {			// VDU 23, 0, &FE, n
			fabgl::PS2Controller::end();
			fabgl::PS2Controller::begin(fabgl::PS2Preset::KeyboardPort0, fabgl::KbdMode::CreateVirtualKeysQueue);
			rtc_gpio_deinit(GPIO_NUM_26);
			rtc_gpio_deinit(GPIO_NUM_27);
			auto b = readByte_t();
			setConsoleMode((bool) b);
		}

This works for me on my fork: https://github.com/mikolajmikolajczyk/agon-vdp/pull/2/files

@stevesims
Copy link
Contributor

interesting

a while back I experimented with only starting up the PS/2 mouse support when a "mouse enable" command is received. as noted against #126 this did not work, and would crash the VDP

I suspect the approach you've used here will suffer with essentially the same issues, i.e. you'll have a VDP where you can never use the mouse

attempting to fix the issues inside vdp-gl that prevent fabgl::PS2Controller::begin from being called twice is hard. back in April when I looked into this, I tried to look into that, and didn't manage to spot any reason why it would crash. ideally this would be possible (i.e. to be able to at will enable/disable the mouse port), but for now this isn't a practical possibility

one potential solution to this issue, and #126, is via #36 - i.e. support a persistent configuration option for dictating that the VDP should start up with the mouse port disabled. changing the config to enable the mouse port would require a reboot, but that's probably an acceptable compromise.

for this issue, i.e. allowing ZDI to work, I suspect the better solution may be to just use different GPIO pins on the ESP32. those seem to be configured on lines 12 and 13 of zdi.h. perhaps using pins ESP37 and ESP38?
(I've never tried to set up and use ZDI debugging on either of my Agon systems, so I've not worked out how to set this up and test it)

pins ESP26 and ESP27 are defined as the default PS/2 mouse port for fab-gl system boards, so that's the model that Bernado used when designing the Console8, as the Agon hardware design builds on the fab-gl design. this is therefore what the firmware will use for any Agon model to attempt to support a mouse. i don't understand enough about how the ZDI support in the VDP works to know if there's a reason why different ESP pins can't be used

@stevesims
Copy link
Contributor

I did look into this further, and discussed this on Discord. ESP26 and ESP27 are the only two GPIO pins on the ESP32 chip that are bi-directional, and thus the only two that are suitable to be used for ZDI

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

2 participants