fix cpeekc/cpeekcolor/cpeekrevers/cpeeks for atmos, replaces what is in #532

This commit is contained in:
mrdudz
2025-05-24 20:03:44 +02:00
parent 228316ff58
commit 8d42c4a8c5
8 changed files with 134 additions and 31 deletions

View File

@@ -169,6 +169,17 @@ void atmos_tock (void);
void atmos_zap (void); void atmos_zap (void);
/* Raygun sound effect */ /* Raygun sound effect */
/* The following #defines will cause the matching function prototypes
** in conio.h to be overlaid by macroes with the same names,
** thereby saving the function call overhead.
*/
#define _textcolor(color) COLOR_WHITE
#define _bgcolor(color) COLOR_BLACK
#define _bordercolor(color) COLOR_BLACK
#define _cpeekcolor(color) COLOR_WHITE
void waitvsync (void); void waitvsync (void);
/* Wait for start of next frame */ /* Wait for start of next frame */

21
libsrc/atmos/cpeekc.s Normal file
View File

@@ -0,0 +1,21 @@
;
; 2016-02-28, Groepaz
; 2017-06-19, Greg King
;
; char cpeekc (void);
;
; Atmos version
;
.export _cpeekc
.import setscrptr
.importzp ptr2
_cpeekc:
jsr setscrptr ; Set ptr2 and .Y to the cursor's address
lda (ptr2),y ; Get char
and #<~$80 ; Remove revers() bit
ldx #>$0000
rts

View File

@@ -1,30 +0,0 @@
.include "atmos.inc"
.export _cpeekc
_cpeekc:
ldy CURS_Y
ldx ScrTabLo,y
stx @l+1
ldx ScrTabHi,y
stx @l+2
ldx CURS_X
@l:
lda $bb80,x
;; inc COORDX_TEXT
ldx #0
rts
; FIXME: is that table available elsewhere?
.rodata
ScrTabLo:
.repeat 28, Line
.byte <(SCREEN + Line * 40)
.endrep
ScrTabHi:
.repeat 28, Line
.byte >(SCREEN + Line * 40)
.endrep

10
libsrc/atmos/cpeekcolor.s Normal file
View File

@@ -0,0 +1,10 @@
;
; 2017-06-03, Greg King
;
; unsigned char cpeekcolor (void);
;
; Atmos version
;
.import return1
.export _cpeekcolor := return1 ; always COLOR_WHITE

View File

@@ -0,0 +1,22 @@
;
; 2017-06-08, Greg King
;
; unsigned char cpeekrevers (void);
;
; Atmos version
;
.export _cpeekrevers
.import setscrptr
.importzp ptr2
_cpeekrevers:
jsr setscrptr ; Set ptr2 and .Y to the cursor's address
lda (ptr2),y ; Get char
and #$80 ; get reverse bit
asl a
tax ; ldx #>$0000
rol a ; return boolean value
rts

54
libsrc/atmos/cpeeks.s Normal file
View File

@@ -0,0 +1,54 @@
;
; 2017-06-20, Greg King
;
; void cpeeks (char* s, unsigned length);
;
.export _cpeeks
.import setscrptr, popax
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.macpack generic
_cpeeks:
eor #<$FFFF ; counting a word upward is faster
sta ptr3 ; so, we use -(length + 1)
txa
eor #>$FFFF
sta ptr3+1
jsr setscrptr ; Set ptr2 and .Y to the cursor's address
sty tmp2
jsr popax
sta tmp1 ; (will be a .Y index)
stx ptr1+1
ldx #<$0000
stx ptr1
bze L3 ; branch always
L4: ldy tmp2
lda (ptr2),y ; Get char
iny
bnz L2
inc ptr2+1
L2: sty tmp2
and #<~$80 ; Remove reverse bit
ldy tmp1
sta (ptr1),y
iny
bnz L1
inc ptr1+1
L1: sty tmp1
L3: inc ptr3 ; count length
bnz L4
inc ptr3+1
bnz L4
txa ; terminate the string
ldy tmp1
sta (ptr1),y
rts

View File

@@ -540,12 +540,13 @@ EXELIST_sym1 = \
strnlen \ strnlen \
strqtok-test strqtok-test
# omitted: clock-test cpeek-test conio deb dir-test em-test exec-test1 exec-test2 # omitted: clock-test cpeek-test deb dir-test em-test exec-test1 exec-test2
# fileio-test ft mouse-test posixio-test rename-test seek ser-test # fileio-test ft mouse-test posixio-test rename-test seek ser-test
EXELIST_atmos = \ EXELIST_atmos = \
minimal \ minimal \
arg-test \ arg-test \
clock \ clock \
conio \
cprintf \ cprintf \
cursor \ cursor \
div-test \ div-test \

View File

@@ -24,6 +24,12 @@
#define NUMCOLS 16 #define NUMCOLS 16
#endif #endif
#if defined(__ATMOS__)
// FIXME: those should be defined elsewhere?
#define CH_HLINE '-'
#define CH_VLINE '!'
#endif
static char grid[5][5] = { static char grid[5][5] = {
{CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER}, {CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER},
{CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, {CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE },
@@ -73,6 +79,14 @@ void peektest(void)
revers(rbuf[j]); revers(rbuf[j]);
cputc(buf[j]); cputc(buf[j]);
} }
gotoxy(0, LINE_PEEKTEST);
cpeeks(buf, NUMCOLS);
(void)textcolor(1);
revers(0);
gotoxy(20, LINE_PEEKTEST);
for (j = 0; j < NUMCOLS; ++j) {
cputc(buf[j]);
}
} }
void main(void) void main(void)