cbm stuff from greggs pull request

This commit is contained in:
mrdudz
2017-12-11 19:49:14 +01:00
parent 947b09ad96
commit 8902730756
21 changed files with 936 additions and 7 deletions

65
libsrc/c128/cpeekc.s Normal file
View File

@@ -0,0 +1,65 @@
;
; 2016-02-28, Groepaz
; 2017-06-26, Greg King
;
; char cpeekc (void);
;
.export _cpeekc
.import plot, popa
.include "zeropage.inc"
.include "c128.inc"
_cpeekc:
lda MODE
bmi @c80
ldy CURS_X
lda (SCREEN_PTR),y ; get char
@return:
and #<~$80 ; remove reverse flag
; Convert the screen code into a PetSCII code.
; $00 - $1F: +$40
; $20 - $3F
; $40 - $7F: +$80
cmp #$20
bcs @sk1 ;(bge)
ora #$40
rts
@sk1: cmp #$40
bcc @end ;(blt)
ora #$80
@end: ldx #0
rts
@c80:
lda SCREEN_PTR
ldy SCREEN_PTR+1
clc
adc CURS_X
bcc @s
iny
; get byte from VDC mem
@s: ldx #VDC_DATA_LO
stx VDC_INDEX
@L0: bit VDC_INDEX
bpl @L0
sta VDC_DATA
dex
stx VDC_INDEX
sty VDC_DATA
ldx #VDC_RAM_RW
stx VDC_INDEX
@L1: bit VDC_INDEX
bpl @L1 ; wait for blanking
lda VDC_DATA
jmp @return

56
libsrc/c128/cpeekcolor.s Normal file
View File

@@ -0,0 +1,56 @@
;
; 2016-02-28, Groepaz
; 2017-06-26, Greg King
;
; unsigned char cpeekcolor (void);
;
.export _cpeekcolor
.include "c128.inc"
_cpeekcolor:
bit MODE
bmi @c80
ldy CURS_X
lda (CRAM_PTR),y ; get color
and #$0F
ldx #>$0000
rts
@c80: lda CRAM_PTR
ldy CRAM_PTR+1
clc
adc CURS_X
bcc @s
iny
; get byte from VDC mem
@s: ldx #VDC_DATA_LO
stx VDC_INDEX
@L0: bit VDC_INDEX
bpl @L0
sta VDC_DATA
dex
stx VDC_INDEX
sty VDC_DATA
ldx #VDC_RAM_RW
stx VDC_INDEX
@L1: bit VDC_INDEX
bpl @L1 ; wait for blanking
lda VDC_DATA
and #$0F
; translate VDC->VIC colour
vdctovic:
ldy #$0F + 1
@L2: dey
cmp $CE5C,y
bne @L2
tya
ldx #>$0000
rts

51
libsrc/c128/cpeekrevers.s Normal file
View File

@@ -0,0 +1,51 @@
;
; 2016-02-28, Groepaz
; 2017-06-26, Greg King
;
; unsigned char cpeekrevers (void);
;
.export _cpeekrevers
.include "zeropage.inc"
.include "c128.inc"
_cpeekrevers:
lda MODE
bmi @c80
ldy CURS_X
lda (SCREEN_PTR),y ; get char
@return:
and #$80 ; get reverse flag
asl a
tax ; ldx #>$0000
rol a ; return boolean value
rts
@c80:
lda SCREEN_PTR
ldy SCREEN_PTR+1
clc
adc CURS_X
bcc @s
iny
; get byte from VDC mem
@s: ldx #VDC_DATA_LO
stx VDC_INDEX
@L0: bit VDC_INDEX
bpl @L0
sta VDC_DATA
dex
stx VDC_INDEX
sty VDC_DATA
ldx #VDC_RAM_RW
stx VDC_INDEX
@L1: bit VDC_INDEX
bpl @L1 ; wait for blanking
lda VDC_DATA
jmp @return

15
libsrc/c128/cpeeks.s Normal file
View File

@@ -0,0 +1,15 @@
;
; 2017-11-23, Greg King
;
; void cpeeks (char* s, unsigned length);
;
; C128 can't use "cbm/cpeeks.s" because both 40 and 80 columns must be handled.
; Stub file, for now, so that its library can be built.
.export _cpeeks
.import popax
_cpeeks:
jmp popax ; pop s