This commit is contained in:
greg-king5 2024-02-15 11:21:23 +01:00 committed by GitHub
commit e93107b766
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 285 additions and 46 deletions

View File

@ -169,6 +169,15 @@ void atmos_tock (void);
void atmos_zap (void);
/* 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
/* End of atmos.h */

View File

@ -35,16 +35,16 @@
/*
** This is the direct console interface for cc65. I do not like the function
** names very much, but the first version started as a rewrite of Borland's
** conio, and, even if the interface has changed, the names did not.
** names very much; but, the first version started as a rewrite of Borland's
** conio; and, even if the interface has changed, the names did not.
**
** The interface does direct screen I/O, so it is fast enough for most
** programs. I did not implement text windows, since many applications do
** not need them and should not pay for the additional overhead. It should
** be easy to add text windows on a higher level if needed,
** The interface does direct screen I/O; so, it is fast enough for most
** programs. I did not implement text windows because many applications do
** not need them, and should not pay for the additional overhead. It should
** be easy to add text windows on a higher level if needed.
**
** Most routines do not check the parameters. This may be unfortunate but is
** also related to speed. The coordinates are always 0/0 based.
** Most routines do not check the parameters. That might be unfortunate;
** but also is related to speed. The coordinates are always (0,0)-based.
*/
@ -191,10 +191,10 @@ void __fastcall__ cputhex16 (unsigned val);
/* On some platforms, functions are not available or are dummys. To suppress
** the call to these functions completely, the platform header files may
** define macros for these functions that start with an underline. If such a
** macro exists, a new macro is defined here, that expands to the one with the
** underline. The reason for this two stepped approach is that it is sometimes
** the call to those functions completely, the platform header files may
** define macros for those functions that start with an underscore. If such a
** macro exists, a new macro is defined here that expands to the one with the
** underscore. The reason for this two-stepped approach is that it is sometimes
** necessary to take the address of the function, which is not possible when
** using a macro. Since the function prototype is still present, #undefining
** the macro will give access to the actual function.

35
libsrc/atari/cpeekc.s Normal file
View 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

View File

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

View 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

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

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

@ -11,9 +11,6 @@
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.macpack generic
; FIXME c128 needs special version that handles the 80-column VDC.
.include "c128.inc"
_cpeeks:
@ -97,7 +94,7 @@ c80:
stx ptr1+1
ldx #<$0000
stx ptr1
bze L3a ; branch always
bze L3a ; branch always
L4a:
lda ptr2

37
libsrc/nes/cpeekc.s Normal file
View File

@ -0,0 +1,37 @@
;
; 2016-02-28, Groepaz
; 2017-08-17, Greg King
;
; char cpeekc (void);
;
.export _cpeekc
.import ppubuf_waitempty
.forceimport initconio
.include "nes.inc"
_cpeekc:
; wait until all console data has been written
jsr ppubuf_waitempty
ldy SCREEN_PTR+1
lda SCREEN_PTR
; waiting for vblank is incredibly slow ://
vwait:
; ldx PPU_STATUS
; bpl vwait
ldx #>$0000
sty PPU_VRAM_ADDR2
sta PPU_VRAM_ADDR2
lda PPU_VRAM_IO ; first read is invalid
lda PPU_VRAM_IO ; get data
stx PPU_VRAM_ADDR2
stx PPU_VRAM_ADDR2
and #<~$80 ; remove reverse bit
rts

17
libsrc/osic1p/cpeekc.s Normal file
View File

@ -0,0 +1,17 @@
;
; 2017-06-21, Greg King
;
; char cpeekc (void);
;
; Get a character from OSI C1P screen RAM.
;
.export _cpeekc
.include "extzp.inc"
_cpeekc:
ldy CURS_X
lda (SCREEN_PTR),y
ldx #>$0000
rts

View File

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

View File

@ -0,0 +1,9 @@
;
; 2017-06-15, Greg King
;
; unsigned char cpeekrevers (void);
;
; Get a reverse attribute from screen RAM
;
.import return0
.export _cpeekrevers := return0 ; No attribute

View File

@ -14,11 +14,11 @@ _cpeekc:
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
sty a:VDC_DATA_LO
stx a:VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
lda VDC_DATA_LO ; character
lda a:VDC_DATA_LO ; character
and #<~$80 ; remove reverse bit
ldx #0
rts

View File

@ -14,11 +14,11 @@ _cpeekcolor:
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
sty a:VDC_DATA_LO
stx a:VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
lda VDC_DATA_HI
lda a:VDC_DATA_HI
and #<~$02
lsr a
lsr a

View File

@ -14,13 +14,13 @@ _cpeekrevers:
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
sty a:VDC_DATA_LO
stx a:VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
lda VDC_DATA_LO ; character (bit 7 is revers bit)
rol a
rol a
and #1
ldx #0
lda a:VDC_DATA_LO ; character
and #$80 ; get reverse bit
asl a
tax ; ldx #>$0000
rol a ; return boolean value
rts

View File

@ -1,5 +1,6 @@
;
; 2020-07-14, Groepaz
; 2020-07-15, Greg King
;
; void cpeeks (char* s, unsigned length);
;
@ -8,9 +9,7 @@
.export _cpeeks
.import popax
.importzp ptr1, ptr2, tmp1, tmp2
.macpack generic
.importzp ptr1, ptr2
.include "pce.inc"
.include "extzp.inc"
@ -22,35 +21,31 @@ _cpeeks:
eor #>$FFFF
sta ptr2+1
st0 #VDC_CR ; Control Register
st2 #>$0088 ; make VRAM address increment by one
st0 #VDC_MARR ; Memory-Address Read
ldy SCREEN_PTR
ldx SCREEN_PTR+1
sty VDC_DATA_LO
stx VDC_DATA_HI
sty a:VDC_DATA_LO
stx a:VDC_DATA_HI
st0 #VDC_VRR ; VRAM Read Register
jsr popax
sta tmp1 ; (will be a .Y index)
tay ; low byte of address will be used as index
stx ptr1+1
ldx #<$0000
stx ptr1
beq L2 ; branch always
L3: ldy tmp2
lda VDC_DATA_LO ; get character
bit VDC_DATA_HI ; we need to "read" the highbyte to advance the address
iny
sty tmp2
L3: lda a:VDC_DATA_LO ; get character
bit a:VDC_DATA_HI ; need to read high byte to advance VDC address
and #<~$80 ; remove reverse bit
ldy tmp1
sta (ptr1),y
iny
bne L1
bne L2
inc ptr1+1
L1: sty tmp1
L2: inc ptr2 ; count length
bne L3
@ -58,6 +53,5 @@ L2: inc ptr2 ; count length
bne L3
txa ; terminate the string
ldy tmp1
sta (ptr1),y
rts