fix cpeekc/cpeekcolor/cpeekrevers for atari 800
This commit is contained in:
35
libsrc/atari/cpeekc.s
Normal file
35
libsrc/atari/cpeekc.s
Normal file
@@ -0,0 +1,35 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-21, Greg King
|
||||
;
|
||||
; char cpeekc (void);
|
||||
;
|
||||
|
||||
.export _cpeekc
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
|
||||
_cpeekc:
|
||||
lda OLDCHR ; get char under cursor
|
||||
and #<~$80 ; remove reverse bit
|
||||
|
||||
;; convert internal screen code to AtSCII
|
||||
|
||||
tay
|
||||
and #%01100000
|
||||
asl a
|
||||
asl a
|
||||
rol a
|
||||
rol a
|
||||
tax
|
||||
tya
|
||||
eor intats,x
|
||||
ldx #>$0000
|
||||
rts
|
||||
|
||||
.rodata
|
||||
intats: .byte %00100000 ; -> %001xxxxx
|
||||
.byte %01100000 ; -> %010xxxxx
|
||||
.byte %01000000 ; -> %000xxxxx
|
||||
.byte %00000000 ; -> %011xxxxx
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
.export _cpeekc
|
||||
|
||||
.import mul40
|
||||
.importzp ptr4
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
_cpeekc:
|
||||
|
||||
lda ROWCRS
|
||||
jsr mul40 ; destroys tmp4
|
||||
clc
|
||||
adc SAVMSC ; add start of screen memory
|
||||
sta ptr4
|
||||
txa
|
||||
adc SAVMSC+1
|
||||
sta ptr4+1
|
||||
|
||||
ldy COLCRS
|
||||
lda (ptr4),y ; get char
|
||||
tax
|
||||
|
||||
;; convert to asc
|
||||
|
||||
;; FIXME: ugly hack here to make tetris fx work :=P
|
||||
lda #' '
|
||||
cpx #0
|
||||
beq @l
|
||||
lda #0
|
||||
@l:
|
||||
ldx #0
|
||||
rts
|
||||
8
libsrc/atari/cpeekcolor.s
Normal file
8
libsrc/atari/cpeekcolor.s
Normal file
@@ -0,0 +1,8 @@
|
||||
;
|
||||
; 2017-06-03, Greg King
|
||||
;
|
||||
; unsigned char cpeekcolor (void);
|
||||
;
|
||||
|
||||
.import return1
|
||||
.export _cpeekcolor := return1 ; always COLOR_WHITE
|
||||
18
libsrc/atari/cpeekrevers.s
Normal file
18
libsrc/atari/cpeekrevers.s
Normal file
@@ -0,0 +1,18 @@
|
||||
;
|
||||
; 2017-06-21, Greg King
|
||||
;
|
||||
; unsigned char cpeekrevers (void);
|
||||
;
|
||||
|
||||
.export _cpeekrevers
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
|
||||
_cpeekrevers:
|
||||
lda OLDCHR ; get char under cursor
|
||||
and #$80 ; get reverse bit
|
||||
asl a
|
||||
tax ; ldx #>$0000
|
||||
rol a ; return boolean value
|
||||
rts
|
||||
@@ -32,6 +32,48 @@ static char grid[5][5] = {
|
||||
{CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER}
|
||||
};
|
||||
|
||||
void colortest(void)
|
||||
{
|
||||
unsigned int i, j;
|
||||
cputsxy(0, 2, "Colors:" );
|
||||
for (i = 0; i < 3; ++i) {
|
||||
gotoxy(i, 3 + i);
|
||||
for (j = 0; j < NUMCOLS; ++j) {
|
||||
(void)textcolor(j);
|
||||
cputc('X');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define LINE_PEEKTEST 11
|
||||
|
||||
void peektest(void)
|
||||
{
|
||||
int j;
|
||||
char buf[NUMCOLS];
|
||||
char cbuf[NUMCOLS];
|
||||
char rbuf[NUMCOLS];
|
||||
|
||||
gotoxy(0, LINE_PEEKTEST);
|
||||
for (j = 0; j < NUMCOLS; ++j) {
|
||||
(void)textcolor(j);
|
||||
revers((j >> 1)&1);
|
||||
cputc('a' + j);
|
||||
}
|
||||
for (j = 0; j < NUMCOLS; ++j) {
|
||||
gotoxy(j, LINE_PEEKTEST);
|
||||
buf[j] = cpeekc();
|
||||
cbuf[j] = cpeekcolor();
|
||||
rbuf[j] = cpeekrevers();
|
||||
}
|
||||
gotoxy(0, (LINE_PEEKTEST+1));
|
||||
for (j = 0; j < NUMCOLS; ++j) {
|
||||
(void)textcolor(cbuf[j]);
|
||||
revers(rbuf[j]);
|
||||
cputc(buf[j]);
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
unsigned int i, j, n;
|
||||
@@ -52,16 +94,13 @@ void main(void)
|
||||
(void)bordercolor(bcol);
|
||||
(void)bgcolor(bgcol);
|
||||
|
||||
cputsxy(0, 2, "Colors:" );
|
||||
for (i = 0; i < 3; ++i) {
|
||||
gotoxy(i, 3 + i);
|
||||
for (j = 0; j < NUMCOLS; ++j) {
|
||||
(void)textcolor(j);
|
||||
cputc('X');
|
||||
}
|
||||
}
|
||||
(void)textcolor(tcol);
|
||||
colortest();
|
||||
peektest();
|
||||
|
||||
(void)textcolor(tcol);
|
||||
revers(0);
|
||||
|
||||
gotoxy(4,5);
|
||||
cprintf("\n\n\r Screensize: %ux%u", xsize, ysize);
|
||||
|
||||
chlinexy(0, 6, xsize);
|
||||
|
||||
Reference in New Issue
Block a user