From ec64853155865cbb9c56bbcf4997f4e2c3c0e021 Mon Sep 17 00:00:00 2001 From: alephnull42 Date: Fri, 2 Jun 2023 20:54:24 +0200 Subject: [PATCH] Update mos_api.asm for non-blocking mos_ugetc Update mos_api.asm for non-blocking mos_ugetc This is not backwards compatible, I was scratching my head for a use-case where blocking would be needed. Alternatively create an additional function mos_ugetch (with an "h") Created for my serial terminal https://youtu.be/dYVpXgn82Fk?t=68 --- src/mos_api.asm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mos_api.asm b/src/mos_api.asm index 64c0fc8..6052ef5 100644 --- a/src/mos_api.asm +++ b/src/mos_api.asm @@ -21,6 +21,7 @@ ; 14/04/2023: Added ffs_api_fopen, ffs_api_fclose, ffs_api_stat, ffs_api_fread, ffs_api_fwrite, ffs_api_feof, ffs_api_flseek ; 15/04/2023: Added mos_api_getfil, mos_api_fread, mos_api_fwrite and mos_api_flseek ; 30/05/2023: Fixed mos_api_fgetc to set carry if at end of file +; 02/06/2023: [LuzrBum] redirected mos_ugetc to UART1_serial_RX, to achieve a non-blocking UART1 read. Breaks backwards compatibility for apps that require block .ASSUME ADL = 1 @@ -65,6 +66,7 @@ XREF UART1_serial_GETCH ; In serial.asm XREF UART1_serial_PUTCH + XREF UART1_serial_RX ; For non-blocking read XREF _keyascii ; In globals.asm XREF _keycount @@ -647,13 +649,13 @@ mos_api_uopen: LEA HL, IX + 0 ; HLU: Pointer to struct ; mos_api_uclose: JP _close_UART1 -; Get a character from UART1 +; Get a character from UART1 (non-blocking) ; Returns: ; A: Character read ; F: C if successful ; F: NC if the UART is not open ; -mos_api_ugetc JP UART1_serial_GETCH +mos_api_ugetc JP UART1_serial_RX ; For non-blocking read - original value was UART1_serial_GETCH ; Write a character to UART1 ; C: Character to write @@ -939,4 +941,4 @@ ffs_api_getfree: ffs_api_getlabel: ffs_api_setlabel: ffs_api_setcp: - RET \ No newline at end of file + RET