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

53
libsrc/cbm/cpeekc.s Normal file
View File

@@ -0,0 +1,53 @@
;
; 2016-02-28, Groepaz
; 2017-06-22, Greg King
;
; char cpeekc (void);
;
.export _cpeekc
; Get a system-specific file.
; Note: The cbm610, and c128 targets need special
; versions that handle RAM banking and the 80-column VDC.
.if .def(__C16__)
.include "plus4.inc" ; both C16 and Plus4
.elseif .def(__C64__)
.include "c64.inc"
.elseif .def(__CBM510__)
.import CURS_X: zp, SCREEN_PTR: zp
.include "cbm510.inc"
.elseif .def(__PET__)
.include "pet.inc"
.elseif .def(__VIC20__)
.include "vic20.inc"
.endif
_cpeekc:
ldy CURS_X
lda (SCREEN_PTR),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

28
libsrc/cbm/cpeekcolor.s Normal file
View File

@@ -0,0 +1,28 @@
;
; 2016-02-28, Groepaz
; 2017-06-22, Greg King
;
; unsigned char cpeekcolor (void);
;
.export _cpeekcolor
; Get a system-specific file.
; Note: The cbm510, cbm610, c128, and Pet targets need special
; versions that handle RAM banking, the 80-column VDC, and monochrome.
.if .def(__C16__)
.include "plus4.inc" ; both C16 and Plus4
.elseif .def(__C64__)
.include "c64.inc"
.elseif .def(__VIC20__)
.include "vic20.inc"
.endif
_cpeekcolor:
ldy CURS_X
lda (CRAM_PTR),y ; get color
and #$0F
ldx #>$0000
rts

35
libsrc/cbm/cpeekrevers.s Normal file
View File

@@ -0,0 +1,35 @@
;
; 2016-02-28, Groepaz
; 2017-06-15, Greg King
;
; unsigned char cpeekrevers (void);
;
.export _cpeekrevers
; Get a system-specific file.
; Note: The cbm610, and c128 targets need special
; versions that handle RAM banking and the 80-column VDC.
.if .def(__C16__)
.include "plus4.inc" ; both C16 and Plus4
.elseif .def(__C64__)
.include "c64.inc"
.elseif .def(__CBM510__)
.import CURS_X: zp, SCREEN_PTR: zp
.include "cbm510.inc"
.elseif .def(__PET__)
.include "pet.inc"
.elseif .def(__VIC20__)
.include "vic20.inc"
.endif
_cpeekrevers:
ldy CURS_X
lda (SCREEN_PTR),y ; get screen code
and #$80 ; get reverse bit
asl a
tax ; ldx #>$0000
rol a ; return boolean value
rts

93
libsrc/cbm/cpeeks.s Normal file
View File

@@ -0,0 +1,93 @@
;
; 2017-07-05, Greg King
;
; void cpeeks (char* s, unsigned length);
;
.export _cpeeks
.import popax
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.macpack generic
; Get a system-specific file.
; Note: The cbm610, and c128 targets need special
; versions that handle RAM banking and the 80-column VDC.
.if .def(__C16__)
.include "plus4.inc" ; both C16 and Plus4
.elseif .def(__C64__)
.include "c64.inc"
.elseif .def(__CBM510__)
.import CURS_X: zp, SCREEN_PTR: zp
.include "cbm510.inc"
.elseif .def(__PET__)
.include "pet.inc"
.elseif .def(__VIC20__)
.include "vic20.inc"
.endif
_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
ldx SCREEN_PTR+1
sta ptr2
stx 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

View File

@@ -0,0 +1,24 @@
;
; 2016-02-28, Groepaz
; 2017-06-19, Greg King
;
; unsigned char cpeekcolor (void);
;
.export _cpeekcolor
.import CURS_X: zp, CRAM_PTR: zp
.include "cbm510.inc"
_cpeekcolor:
ldx IndReg
lda #$0F
sta IndReg
ldy CURS_X
lda (CRAM_PTR),y ; get color
stx IndReg
and #$0F
ldx #>$0000
rts

View File

@@ -0,0 +1,16 @@
;
; 2016-06, Christian Groessler
; 2017-07-05, Greg King
;
; unsigned char doesclrscrafterexit (void);
;
; Returns 0/1 if, after program termination, the screen isn't/is cleared.
;
.import return1
; cc65's CBM510 programs switch to a display screen in the program RAM bank;
; then, they switch back to the system bank when they exit.
; The screen is cleared.
.export _doesclrscrafterexit := return1

45
libsrc/cbm610/cpeekc.s Normal file
View File

@@ -0,0 +1,45 @@
;
; 2016-02-28, Groepaz
; 2017-06-19, Greg King
;
; char cpeekc (void);
;
.export _cpeekc
.import CURS_X: zp, CharPtr: zp
.include "cbm610.inc"
_cpeekc:
ldx IndReg
ldy #$0F
sty IndReg
ldy CURS_X
lda (CharPtr),y ; get char from system bank
stx IndReg
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

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,29 @@
;
; 2016-02-28, Groepaz
; 2017-06-19, Greg King
;
; unsigned char cpeekrevers (void);
;
.export _cpeekrevers
.import plot
.import CURS_X: zp, CharPtr: zp
.include "cbm610.inc"
_cpeekrevers:
ldx IndReg
ldy #$0F
sty IndReg
ldy CURS_X
lda (CharPtr),y ; get char from system bank
stx IndReg
ldx #>$0000
and #$80 ; get reverse bit
asl a
tax ; ldx #>$0000
rol a ; return boolean value
rts

82
libsrc/cbm610/cpeeks.s Normal file
View File

@@ -0,0 +1,82 @@
;
; 2017-07-05, Greg King
;
; void cpeeks (char* s, unsigned length);
;
.export _cpeeks
.import popax
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.importzp CURS_X, SCREEN_PTR
.include "cbm610.inc"
.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
ldx SCREEN_PTR+1
sta ptr2
stx ptr2+1
ldy CURS_X
sty tmp2
jsr popax
sta tmp1 ; (will be a .Y index)
stx ptr1+1
ldx IndReg
ldy #<$0000
sty ptr1
bze L3 ; branch always
L4: ldy #$0F
sty IndReg
ldy tmp2
lda (ptr2),y ; get char from system bank
stx IndReg
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
lda #$00 ; terminate the string
ldy tmp1
sta (ptr1),y
rts

8
libsrc/pet/cpeekcolor.s Normal file
View File

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