Fix esp32 wait-timing race, rename wc_api.lib, keyboard: Enter-to-advance

esp32.c: two-phase esp_wait_busy() so a stale non-BUSY status right after
esp_cmd() isn't mistaken for completion (fixed a real TRACK_PLAY/0x88 race
on heavier XM files); added single-phase esp_wait_not_busy() for
esp_send_dma()'s per-chunk wait, which never actually sets BUSY and was
timing out on every chunk under the two-phase version.

vgm_wc_api.lib renamed to wc_api.lib (build.bat updated to match).

Keyboard: tried replacing wc_key_esc/pgup/pgdn/space with a raw PS/2-FIFO
reader (matching how VGMPLAY.WMF's own player reads keys) so Enter could
also advance to the next file. Reverted after two confirmed hardware
regressions (esp32 transfers failing with ESP_ERR_INV_XM, and the keyboard
going unresponsive once WC's own PS/2 scanning was disabled to stop it
competing with the raw reads) - VGMPLAY's approach relies on a full custom
interrupt handler xmplay has no equivalent need for. Back to the simple
wc_key_*() wrappers, plus wc_key_enter() so Enter now advances too, and
wc_key_wait_release() (called after wc_gedpl()) to debounce the Enter/F3
that launched the plugin itself.

Also: About window now centers dynamically for all three WC text modes
(90x36/80x25/80x30) instead of a fixed position, and matches the main
window's color scheme.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-07 12:40:36 +03:00
co-authored by Claude Sonnet 5
parent ecf52d60c8
commit 168d6a71bd
16 changed files with 4471 additions and 3841 deletions
+93 -81
View File
@@ -24,25 +24,25 @@ Area Addr Size Decimal Bytes (A
00000001 l__INITIALIZER
00000003 l__HEADER0
0000010A l__HOME
00000E21 l__CODE
0000108E l__DATA
00000F31 l__CODE
000010B2 l__DATA
00008003 s__CODE
0000A800 s__DATA
0000B88E s__INITIALIZED
0000B88F s__HOME
0000B999 s__GSFINAL
0000B999 s__GSINIT
0000B999 s__INITIALIZER
0000B99A s__BSEG
0000B99A s__BSS
0000B99A s__HEAP
0000B8B2 s__INITIALIZED
0000B8B3 s__HOME
0000B9BD s__GSFINAL
0000B9BD s__GSINIT
0000B9BD s__INITIALIZER
0000B9BE s__BSEG
0000B9BE s__BSS
0000B9BE s__HEAP
ASxxxx Linker V05.50.4-SDLD, page 2.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
_CODE 00008003 00000E21 = 3617. bytes (REL,CON)
_CODE 00008003 00000F31 = 3889. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
@@ -54,72 +54,78 @@ _CODE 00008003 00000E21 = 3617. bytes (R
000080D4 _esp_wr_reg8 main
000080EB _esp_wr_reg32 main
0000811B _esp_wr_end main
0000812A _esp_send_dma main
0000818B _esp_rd_end main
0000819A _esp_wait_status main
000081E8 _esp_wait_busy main
0000822F _esp_create_obj main
0000825A _esp_init main
00008267 _win_xm main
00008279 _win_about main
000082C1 _play_xm main
000084ED _wait_esc_key main
000084F5 _wait_frames main
000084FE _about main
00008511 _unload_and_exit main
00008542 _leave_playing_and_exit main
0000854C _wait_for_manual_exit main
00008570 _error_esp main
00008597 _stop_on_error main
000085A3 _error_oom main
000085D6 _error_playback main
00008609 _copy_file_name main
0000862E _xm_draw_static_labels main
000086AD _xm_set_status_attr main
00008711 _xm_set_status main
00008719 _xm_set_status_code main
000087D1 _put_hex2 main
0000880E _put_dec3 main
0000886B _put_time main
00008918 _xm_draw_stats_labels main
000089DA _draw_progress_bar main
00008A50 _xm_update_info main
00008BCE _main_start main
00008CA7 _main main
00008CD0 __divuchar divunsigned
00008CD2 __divu8 divunsigned
00008CD5 __divu16 divunsigned
00008CD5 __divuint divunsigned
00008D04 _wc_key_space wc_key_space
00008D0E _wc_load512 wc_load512
00008D23 __moduchar modunsigned
00008D2A __moduint modunsigned
00008D2F _wc_prsrw wc_prsrw
00008D65 _wc_prwow wc_prwow
0000812A _esp_wait_not_busy main
00008171 _esp_send_dma main
000081D2 _esp_rd_end main
000081E1 _esp_wait_status main
0000822F _esp_wait_busy main
0000826B _esp_create_obj main
00008296 _esp_init main
000082A3 _win_xm_tpl main
000082B5 _win_about_tpl main
00008312 _play_xm main
0000853E _wait_esc_key main
00008546 _wait_frames main
0000854F _wc_screen_width main
0000855C _wc_center main
00008592 _about main
000085CC _unload_and_exit main
000085FD _leave_playing_and_exit main
00008607 _wait_for_manual_exit main
00008631 _error_esp main
00008658 _stop_on_error main
00008664 _error_oom main
00008697 _error_playback main
000086CA _copy_file_name main
000086EF _xm_draw_static_labels main
0000876E _xm_set_status_attr main
000087D2 _xm_set_status main
000087DA _xm_set_status_code main
00008892 _put_hex2 main
000088CF _put_dec3 main
0000892C _put_time main
000089D9 _xm_draw_stats_labels main
00008A9B _draw_progress_bar main
00008B11 _xm_update_info main
00008C8F _main_start main
00008D99 _main main
00008DC2 __divuchar divunsigned
00008DC4 __divu8 divunsigned
00008DC7 __divu16 divunsigned
00008DC7 __divuint divunsigned
00008DF6 _wc_key_space wc_key_space
00008E00 _wc_load512 wc_load512
00008E15 __moduchar modunsigned
ASxxxx Linker V05.50.4-SDLD, page 3.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
_CODE 00008003 00000E21 = 3617. bytes (REL,CON)
_CODE 00008003 00000F31 = 3889. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
00008D72 _wc_prm_pl wc_prm_pl
00008D81 _wc_key_pgdn wc_key_pgdn
00008D8B _wc_gadrw wc_gadrw
00008DB0 _wc_prsrw_attr wc_prsrw_attr
00008DF7 _wc_rresb wc_rresb
00008E04 _strlen strlen
00008E10 _wc_key_esc wc_key_esc
00008E1A _wc_key_pgup wc_key_pgup
00008E1C __moduint modunsigned
00008E21 _wc_prsrw wc_prsrw
00008E57 _wc_prwow wc_prwow
00008E64 _wc_key_enter wc_key_enter
00008E6E _wc_prm_pl wc_prm_pl
00008E7D _wc_gedpl wc_gedpl
00008E87 _wc_key_pgdn wc_key_pgdn
00008E91 _wc_gadrw wc_gadrw
00008EB6 _wc_prsrw_attr wc_prsrw_attr
00008EFD _wc_key_wait_release wc_key_wait_release
00008F07 _wc_rresb wc_rresb
00008F14 _strlen strlen
00008F20 _wc_key_esc wc_key_esc
00008F2A _wc_key_pgup wc_key_pgup
ASxxxx Linker V05.50.4-SDLD, page 4.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
_DATA 0000A800 0000108E = 4238. bytes (REL,CON)
_DATA 0000A800 000010B2 = 4274. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
@@ -134,36 +140,39 @@ _DATA 0000A800 0000108E = 4238. bytes (R
0000B82C _total_samples main
0000B830 _xm_handle main
0000B831 _last_track_status main
0000B88C _bar_attr_ofs main
0000B832 _win_xm main
0000B844 _win_about main
0000B8B0 _bar_attr_ofs main
ASxxxx Linker V05.50.4-SDLD, page 5.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
_INITIALIZED 0000B88E 00000001 = 1. bytes (REL,CON)
_INITIALIZED 0000B8B2 00000001 = 1. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
0000B88E _state_esp main
0000B8B2 _state_esp main
ASxxxx Linker V05.50.4-SDLD, page 6.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
_HOME 0000B88F 0000010A = 266. bytes (REL,CON)
_HOME 0000B8B3 0000010A = 266. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
0000B88F __modulong _modulong
0000B916 __divulong _divulong
0000B8B3 __modulong _modulong
0000B93A __divulong _divulong
ASxxxx Linker V05.50.4-SDLD, page 7.
Hexadecimal [32-Bits]
Area Addr Size Decimal Bytes (Attributes)
-------------------------------- ---- ---- ------- ----- ------------
_INITIALIZER 0000B999 00000001 = 1. bytes (REL,CON)
_INITIALIZER 0000B9BD 00000001 = 1. bytes (REL,CON)
Value Global Global Defined In Module
----- -------------------------------- ------------------------
@@ -187,21 +196,24 @@ obj/crt0.rel [ crt0 ]
Libraries Linked [ object file ]
E:\SDCC\4.6.0\bin\..\lib\z80/z80.lib [ divunsigned.rel ]
vgm_wc_api.lib [ wc_key_space.rel ]
vgm_wc_api.lib [ wc_load512.rel ]
wc_api.lib [ wc_key_space.rel ]
wc_api.lib [ wc_load512.rel ]
E:\SDCC\4.6.0\bin\..\lib\z80/z80.lib [ modunsigned.rel ]
vgm_wc_api.lib [ wc_prsrw.rel ]
vgm_wc_api.lib [ wc_prwow.rel ]
vgm_wc_api.lib [ wc_prm_pl.rel ]
wc_api.lib [ wc_prsrw.rel ]
wc_api.lib [ wc_prwow.rel ]
wc_api.lib [ wc_key_enter.rel ]
wc_api.lib [ wc_prm_pl.rel ]
E:\SDCC\4.6.0\bin\..\lib\z80/z80.lib [ _modulong.rel ]
wc_api.lib [ wc_gedpl.rel ]
E:\SDCC\4.6.0\bin\..\lib\z80/z80.lib [ _divulong.rel ]
vgm_wc_api.lib [ wc_key_pgdn.rel ]
vgm_wc_api.lib [ wc_gadrw.rel ]
vgm_wc_api.lib [ wc_prsrw_attr.rel ]
vgm_wc_api.lib [ wc_rresb.rel ]
wc_api.lib [ wc_key_pgdn.rel ]
wc_api.lib [ wc_gadrw.rel ]
wc_api.lib [ wc_prsrw_attr.rel ]
wc_api.lib [ wc_key_wait_release.rel ]
wc_api.lib [ wc_rresb.rel ]
E:\SDCC\4.6.0\bin\..\lib\z80/z80.lib [ strlen.rel ]
vgm_wc_api.lib [ wc_key_esc.rel ]
vgm_wc_api.lib [ wc_key_pgup.rel ]
wc_api.lib [ wc_key_esc.rel ]
wc_api.lib [ wc_key_pgup.rel ]
ASxxxx Linker V05.50.4-SDLD, page 10.