From c28bafa581b6f3b498b9f02868955bee8b4b7723 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 13 Jun 2025 12:50:39 +0300 Subject: [PATCH] add chline, cvline functions --- include/agat.h | 9 +++++++-- libsrc/agat/chline.s | 33 +++++++++++++++++++++++++++++++++ libsrc/agat/cputc.s | 19 +++++++++++++++---- libsrc/agat/cvline.s | 29 +++++++++++++++++++++++++++++ libsrc/agat/home.s | 2 +- 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 libsrc/agat/chline.s create mode 100644 libsrc/agat/cvline.s diff --git a/include/agat.h b/include/agat.h index 2cdf24ae6..04ec16984 100644 --- a/include/agat.h +++ b/include/agat.h @@ -32,7 +32,12 @@ #define CH_CURS_UP 0x19 #define CH_CURS_DOWN 0x1A #define CH_ESC 0x1B - +#define CH_HLINE 0x1B +#define CH_VLINE 0x5C +#define CH_ULCORNER 0x10 +#define CH_URCORNER 0x12 +#define CH_LLCORNER 0x1D +#define CH_LRCORNER 0x1F /* Masks for joy_read */ #define JOY_UP_MASK 0x10 @@ -68,4 +73,4 @@ void rebootafterexit (void); /* End of agat.h */ -#endif //_AGAT_H +#endif diff --git a/libsrc/agat/chline.s b/libsrc/agat/chline.s new file mode 100644 index 000000000..bc95b2a16 --- /dev/null +++ b/libsrc/agat/chline.s @@ -0,0 +1,33 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; Colin Leroy-Mira, 26.05.2025 +; Konstantin Fedorov, 12.06.2025 +; +; void chlinexy (unsigned char x, unsigned char y, unsigned char length); +; void chline (unsigned char length); +; + + .export _chlinexy, _chline, chlinedirect + .import gotoxy, putchar + + .include "zeropage.inc" + +_chlinexy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _chline + +_chline: + ldx #$1B ; horizontal line character + +chlinedirect: + stx tmp1 + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp2 +: lda tmp1 ; Screen code + jsr putchar ; Direct output + dec tmp2 + bne :- +done: rts + diff --git a/libsrc/agat/cputc.s b/libsrc/agat/cputc.s index b8d99aaea..b82ce22e6 100644 --- a/libsrc/agat/cputc.s +++ b/libsrc/agat/cputc.s @@ -1,12 +1,13 @@ ; ; Oleg A. Odintsov, Moscow, 2024 +; Konstantin Fedorov, 12.06.2025 ; ; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); ; void __fastcall__ cputc (char c); ; .import COUT - .export _cputcxy, _cputc + .export _cputcxy, _cputc, newline, putchar,putchardirect .import gotoxy, VTABZ .include "agat.inc" @@ -15,20 +16,21 @@ _cputcxy: jsr gotoxy pla _cputc: - cmp #$0D + cmp #$0D ; Test for \r = carriage return bne notleft ldy #$00 sty CH rts notleft: - cmp #$0A + cmp #$0A ; Test for \n = line feed beq newline + putchar: ldy CH sta (BASL),Y iny lda TATTR - bmi wch + bmi wch ; Skip if t64 sta (BASL),Y iny wch: @@ -47,3 +49,12 @@ newline: : jmp VTABZ noend: rts + +putchardirect: + ldy CH + sta (BASL),Y + lda TATTR + bmi :+ + iny + sta (BASL),Y +: rts diff --git a/libsrc/agat/cvline.s b/libsrc/agat/cvline.s new file mode 100644 index 000000000..63c0d4daf --- /dev/null +++ b/libsrc/agat/cvline.s @@ -0,0 +1,29 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; Colin Leroy-Mira, 26.05.2025 +; Konstantin Fedorov, 12.06.2025 +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export _cvlinexy, _cvline + .import gotoxy, putchardirect, newline + + .include "zeropage.inc" + +_cvlinexy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_cvline: + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp2 +: lda #$5C ; vertical line character + jsr putchardirect ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp2 + bne :- +done: rts diff --git a/libsrc/agat/home.s b/libsrc/agat/home.s index 5067a782a..a0434c9bb 100644 --- a/libsrc/agat/home.s +++ b/libsrc/agat/home.s @@ -11,5 +11,5 @@ HOME: lda #$8C - jsr COUT + jmp COUT rts