1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00
cc65/libsrc/c64/soft80_cpeekc.s

149 lines
2.4 KiB
ArmAsm
Raw Normal View History

2017-12-28 01:26:23 +00:00
;
; 2017-12-28, Groepaz
;
; char cpeekc (void);
;
2017-12-28 00:58:03 +00:00
.export soft80_cpeekc, soft80_cpeekchar
.include "c64.inc"
.include "soft80.inc"
.macpack longbranch
.segment "CODE"
soft80_cpeekc:
jsr soft80_cpeekchar
2017-12-28 16:52:27 +00:00
; 0-1F -> A0-BF
; 20-7F -> 20-7F
cmp #$20
bcs @sk
;clc
adc #$a0
@sk:
2017-12-28 00:58:03 +00:00
ldx #0
rts
soft80_cpeekchar:
sei
lda #$34
sta $01
lda CURS_X
and #$01
jne @l1a
; test non-inverted character (left side)
ldx #0
@l2aa:
ldy #0
.repeat 8,line
lda (SCREEN_PTR),y
and #$f0
cmp soft80_hi_charset+(line*$80),x
bne @l2b
.if (line < 7)
iny
.endif
.endrepeat
@backok:
lda #$36
sta $01
cli
txa ; return char in A
ldx #$00 ; revers flag
rts
@l2b:
inx
cpx #$80
jne @l2aa
; test inverted character (left side)
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
ldx #0
@l2aa2:
ldy #0
.repeat 8,line
lda (SCREEN_PTR),y
and #$f0
eor #$f0
cmp soft80_hi_charset+(line*$80),x
bne @l2b2
.if (line < 7)
iny
.endif
.endrepeat
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
@backokrevers:
lda #$36
sta $01
cli
txa ; return char in A
ldx #$01 ; revers flag
rts
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
@l2b2:
inx
cpx #$80
jne @l2aa2
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
@backerr:
lda #$36
sta $01
cli
ldx #0
txa
rts
; test non-inverted character (right side)
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
@l1a:
ldx #0
@l1aa:
ldy #0
.repeat 8,line
lda (SCREEN_PTR),y
and #$0f
eor soft80_lo_charset+(line*$80),x
2017-12-28 01:26:23 +00:00
bne @l2bb
2017-12-28 00:58:03 +00:00
.if line < 7
iny
.endif
.endrepeat
jmp @backok
@l2bb:
inx
cpx #$80
bne @l1aa
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
; test inverted character (right side)
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
ldx #0
@l1aa2:
ldy #0
.repeat 8,line
lda (SCREEN_PTR),y
and #$0f
eor #$0f
eor soft80_lo_charset+(line*$80),x
2017-12-28 01:26:23 +00:00
bne @l2bb2
2017-12-28 00:58:03 +00:00
.if line < 7
iny
.endif
.endrepeat
jmp @backokrevers
@l2bb2:
inx
cpx #$80
bne @l1aa2
2017-12-28 01:26:23 +00:00
2017-12-28 00:58:03 +00:00
jmp @backerr