/* sg4term.h - CoCo 32x16 SG4 mode (6847) terminal functions. Copyright (C) 2021-2025 Pierre Sarrazin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* These functions implement a terminal compliant with the specs in Ebitor.h in a sub-window of a CoCo 32x16 screen (SG4 mode). */ #ifndef _H_sg4term #define _H_sg4term #include "Window.h" // Defines a window in a 6847 screen in 32x16 (SG4) mode. // Does NOT clear the window. // screenBuffer: Address of the 32x16 screen. // width: 2..32. // height: 2..16. // winLeftCol: 0..30. // winTopRow: 0..14. // inkeyFuncPtr: Must return 0 (and not block) if no key pressed. // inkeyFuncCookie: Will be passed to inkeyFuncPtr. // timerPtr: Address of an unsigned 16-bit integer that gets incremented 60 times per second. // If NULL, the cursor will not be animated. // void sg4term_init(char *screenBuffer, const ebitor_Window *window, byte (*inkeyFuncPtr)(void *cookie), void *inkeyFuncCookie, word *timerPtr); // Fills the window defined by sg4term_init() with spaces. // void sg4term_clear(void); // column, row: Coordinates relative to the window defined by sg4term_init(). // Does not check if the parameters are valid. // This may be useful to write outside the window, as long as no carriage return is written. // void sg4term_locate(byte column, byte row); // column, row: Receive coordinates relative to the window defined by sg4term_init(). // void sg4term_getCursorPos(byte *column, byte *row); // Returns FALSE the string could not be printed entirely because the printing reached end of window. // BOOL sg4term_print(const char *str); // Returns FALSE the string could not be printed entirely because the printing reached end of window. // BOOL sg4term_printPrefix(const char *str, size_t prefixLength); // Use inverted colors for the next print operations. // void sg4term_invertColors(void); void sg4term_clrtoeol(void); void sg4term_scrollWindowUp(byte numRows); void sg4term_scrollWindowDown(byte numRows); // Fills the line where the cursor is with spaces and puts the cursor at the start of this line. // void sg4term_eraseCurrentLine(void); // Animates a cursor while waiting. // Returns an ASCII code or an ebitor_KEY_* code. // word sg4term_waitEditorKey(void); // Converts an ASCII code to a 6847 SG4 character code. // Negative codes (graphics characters) are returned unmodified. // char sg4term_convertASCIIToScreenByte(char c); // Returns ASCII codes in dest[0..len-1]. Does nothing if len is 0. // void sg4term_getChars(byte column, byte row, char *dest, size_t len); #endif /* _H_sg4term */