SCREEN_PTR does only contain the offset apparently (unlike on other cbm systems), so we need extra handling
This commit is contained in:
45
libsrc/c65/cpeekc.s
Normal file
45
libsrc/c65/cpeekc.s
Normal file
@@ -0,0 +1,45 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-22, Greg King
|
||||
;
|
||||
; char cpeekc (void);
|
||||
;
|
||||
|
||||
.include "c65.inc"
|
||||
|
||||
.export _cpeekc
|
||||
.importzp ptr1
|
||||
|
||||
_cpeekc:
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta ptr1 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr1
|
||||
|
||||
ldy CURS_X
|
||||
lda (ptr1),y ; get screen code
|
||||
ldx #>$0000
|
||||
and #<~$80 ; remove reverse bit
|
||||
|
||||
; Convert the screen code into a PetSCII code.
|
||||
; $00 - $1F: +$40
|
||||
; $20 - $3F
|
||||
; $40 - $5f: +$20
|
||||
; $60 - $7F: +$40
|
||||
|
||||
cmp #$20
|
||||
bcs @sk1 ;(bge)
|
||||
ora #$40
|
||||
rts
|
||||
|
||||
@sk1: cmp #$40
|
||||
bcc @end ;(blt)
|
||||
cmp #$60
|
||||
bcc @sk2 ;(blt)
|
||||
;sec
|
||||
adc #$20 - $01
|
||||
@sk2: ;clc ; both above cmp and adc clear carry flag
|
||||
adc #$20
|
||||
@end: rts
|
||||
25
libsrc/c65/cpeekcolor.s
Normal file
25
libsrc/c65/cpeekcolor.s
Normal file
@@ -0,0 +1,25 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-22, Greg King
|
||||
;
|
||||
; unsigned char cpeekcolor (void);
|
||||
;
|
||||
|
||||
.include "c65.inc"
|
||||
|
||||
.export _cpeekcolor
|
||||
.importzp ptr1
|
||||
|
||||
_cpeekcolor:
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$D800
|
||||
sta ptr1 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr1
|
||||
|
||||
ldy #0
|
||||
lda (ptr1),y
|
||||
|
||||
ldx #>$0000
|
||||
rts
|
||||
80
libsrc/c65/cpeeks.s
Normal file
80
libsrc/c65/cpeeks.s
Normal file
@@ -0,0 +1,80 @@
|
||||
;
|
||||
; 2017-07-05, Greg King
|
||||
;
|
||||
; void cpeeks (char* s, unsigned length);
|
||||
;
|
||||
|
||||
.include "c65.inc"
|
||||
|
||||
.export _cpeeks
|
||||
|
||||
.import 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
|
||||
|
||||
lda SCREEN_PTR
|
||||
sta ptr2
|
||||
lda SCREEN_PTR+1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta ptr2+1
|
||||
|
||||
ldy CURS_X
|
||||
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
|
||||
|
||||
; Convert the screen code into a PetSCII code.
|
||||
; $00 - $1F: +$40
|
||||
; $20 - $3F
|
||||
; $40 - $5f: +$20
|
||||
; $60 - $7F: +$40
|
||||
|
||||
cmp #$20
|
||||
blt @sk1 ;(bcc)
|
||||
cmp #$40
|
||||
blt L5
|
||||
cmp #$60
|
||||
blt @sk2 ;(bcc)
|
||||
clc
|
||||
@sk1: adc #$20
|
||||
@sk2: ;clc ; both above cmp and adc clear carry flag
|
||||
adc #$20
|
||||
|
||||
L5: 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
|
||||
@@ -96,23 +96,25 @@ plot: ldy CURS_X
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
|
||||
pha
|
||||
tay
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta SCREEN_PTR + 1
|
||||
pla
|
||||
sta ptr4 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr4
|
||||
tya
|
||||
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
ldy CURS_X
|
||||
sta (ptr4),y ; Set char
|
||||
|
||||
lda SCREEN_PTR + 1
|
||||
sec
|
||||
sbc #>$0800
|
||||
sta SCREEN_PTR + 1
|
||||
lda ptr4 + 1
|
||||
clc
|
||||
adc #>$d000
|
||||
sta ptr4 + 1
|
||||
|
||||
lda CHARCOLOR
|
||||
; lda #$88
|
||||
; sta (CRAM_PTR),y ; Set color
|
||||
sta (ptr4),y ; Set color
|
||||
|
||||
rts
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
.include "pet.inc"
|
||||
.elseif .def(__VIC20__)
|
||||
.include "vic20.inc"
|
||||
.elseif .def(__C65__)
|
||||
.include "c65.inc"
|
||||
.elseif .def(__MEGA65__)
|
||||
.include "mega65.inc"
|
||||
.endif
|
||||
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
.include "c64.inc"
|
||||
.elseif .def(__VIC20__)
|
||||
.include "vic20.inc"
|
||||
.elseif .def(__C65__)
|
||||
.include "c65.inc"
|
||||
.elseif .def(__MEGA65__)
|
||||
.include "mega65.inc"
|
||||
.endif
|
||||
|
||||
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
.include "pet.inc"
|
||||
.elseif .def(__VIC20__)
|
||||
.include "vic20.inc"
|
||||
.elseif .def(__C65__)
|
||||
.include "c65.inc"
|
||||
.elseif .def(__MEGA65__)
|
||||
.include "mega65.inc"
|
||||
.endif
|
||||
|
||||
|
||||
|
||||
45
libsrc/mega65/cpeekc.s
Normal file
45
libsrc/mega65/cpeekc.s
Normal file
@@ -0,0 +1,45 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-22, Greg King
|
||||
;
|
||||
; char cpeekc (void);
|
||||
;
|
||||
|
||||
.include "mega65.inc"
|
||||
|
||||
.export _cpeekc
|
||||
.importzp ptr1
|
||||
|
||||
_cpeekc:
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta ptr1 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr1
|
||||
|
||||
ldy CURS_X
|
||||
lda (ptr1),y ; get screen code
|
||||
ldx #>$0000
|
||||
and #<~$80 ; remove reverse bit
|
||||
|
||||
; Convert the screen code into a PetSCII code.
|
||||
; $00 - $1F: +$40
|
||||
; $20 - $3F
|
||||
; $40 - $5f: +$20
|
||||
; $60 - $7F: +$40
|
||||
|
||||
cmp #$20
|
||||
bcs @sk1 ;(bge)
|
||||
ora #$40
|
||||
rts
|
||||
|
||||
@sk1: cmp #$40
|
||||
bcc @end ;(blt)
|
||||
cmp #$60
|
||||
bcc @sk2 ;(blt)
|
||||
;sec
|
||||
adc #$20 - $01
|
||||
@sk2: ;clc ; both above cmp and adc clear carry flag
|
||||
adc #$20
|
||||
@end: rts
|
||||
25
libsrc/mega65/cpeekcolor.s
Normal file
25
libsrc/mega65/cpeekcolor.s
Normal file
@@ -0,0 +1,25 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-22, Greg King
|
||||
;
|
||||
; unsigned char cpeekcolor (void);
|
||||
;
|
||||
|
||||
.include "mega65.inc"
|
||||
|
||||
.export _cpeekcolor
|
||||
.importzp ptr1
|
||||
|
||||
_cpeekcolor:
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$d800
|
||||
sta ptr1 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr1
|
||||
|
||||
ldy CURS_X
|
||||
lda (ptr1),y
|
||||
|
||||
ldx #>$0000
|
||||
rts
|
||||
28
libsrc/mega65/cpeekrevers.s
Normal file
28
libsrc/mega65/cpeekrevers.s
Normal file
@@ -0,0 +1,28 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-15, Greg King
|
||||
;
|
||||
; unsigned char cpeekrevers (void);
|
||||
;
|
||||
|
||||
.include "mega65.inc"
|
||||
|
||||
.export _cpeekrevers
|
||||
.importzp ptr1
|
||||
|
||||
_cpeekrevers:
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta ptr1 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr1
|
||||
|
||||
ldy CURS_X
|
||||
lda (ptr1),y ; get screen code
|
||||
and #$80 ; get reverse bit
|
||||
asl a
|
||||
tax ; ldx #>$0000
|
||||
rol a ; return boolean value
|
||||
|
||||
rts
|
||||
80
libsrc/mega65/cpeeks.s
Normal file
80
libsrc/mega65/cpeeks.s
Normal file
@@ -0,0 +1,80 @@
|
||||
;
|
||||
; 2017-07-05, Greg King
|
||||
;
|
||||
; void cpeeks (char* s, unsigned length);
|
||||
;
|
||||
|
||||
.include "c65.inc"
|
||||
|
||||
.export _cpeeks
|
||||
|
||||
.import 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
|
||||
|
||||
lda SCREEN_PTR
|
||||
sta ptr2
|
||||
lda SCREEN_PTR+1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta ptr2+1
|
||||
|
||||
ldy CURS_X
|
||||
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
|
||||
|
||||
; Convert the screen code into a PetSCII code.
|
||||
; $00 - $1F: +$40
|
||||
; $20 - $3F
|
||||
; $40 - $5f: +$20
|
||||
; $60 - $7F: +$40
|
||||
|
||||
cmp #$20
|
||||
blt @sk1 ;(bcc)
|
||||
cmp #$40
|
||||
blt L5
|
||||
cmp #$60
|
||||
blt @sk2 ;(bcc)
|
||||
clc
|
||||
@sk1: adc #$20
|
||||
@sk2: ;clc ; both above cmp and adc clear carry flag
|
||||
adc #$20
|
||||
|
||||
L5: 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
|
||||
@@ -9,10 +9,10 @@
|
||||
.export newline, plot
|
||||
.import gotoxy
|
||||
.import PLOT
|
||||
.importzp ptr4
|
||||
|
||||
.include "mega65.inc"
|
||||
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr gotoxy ; Set cursor, drop x and y
|
||||
@@ -96,23 +96,25 @@ plot: ldy CURS_X
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
|
||||
pha
|
||||
tay
|
||||
lda SCREEN_PTR + 1
|
||||
clc
|
||||
adc #>$0800
|
||||
sta SCREEN_PTR + 1
|
||||
pla
|
||||
sta ptr4 + 1
|
||||
lda SCREEN_PTR
|
||||
sta ptr4
|
||||
tya
|
||||
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
ldy CURS_X
|
||||
sta (ptr4),y ; Set char
|
||||
|
||||
lda SCREEN_PTR + 1
|
||||
sec
|
||||
sbc #>$0800
|
||||
sta SCREEN_PTR + 1
|
||||
lda ptr4 + 1
|
||||
clc
|
||||
adc #>$d000
|
||||
sta ptr4 + 1
|
||||
|
||||
lda CHARCOLOR
|
||||
; lda #$88
|
||||
; sta (CRAM_PTR),y ; Set color
|
||||
sta (ptr4),y ; Set color
|
||||
|
||||
rts
|
||||
|
||||
@@ -19,6 +19,6 @@ _kbhit:
|
||||
|
||||
lda #1
|
||||
:
|
||||
ldx #0
|
||||
ldx #>$0000
|
||||
rts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user