From dd2972d6999aa93891d9e13cbcbe0673a0e49ab5 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Feb 2016 22:23:40 +0100 Subject: [PATCH 01/18] initial commit from old source --- libsrc/atari/cpeekchar.s | 41 ++++++++++++++++++++++ libsrc/atmos/cpeekchar.s | 36 +++++++++++++++++++ libsrc/c128/cpeekchar.s | 74 +++++++++++++++++++++++++++++++++++++++ libsrc/c128/cpeekcol.s | 67 +++++++++++++++++++++++++++++++++++ libsrc/cbm/cpeekchar.s | 39 +++++++++++++++++++++ libsrc/cbm/cpeekcol.s | 21 +++++++++++ libsrc/cbm510/cpeekchar.s | 32 +++++++++++++++++ libsrc/cbm510/cpeekcol.s | 31 ++++++++++++++++ libsrc/cbm610/cpeekchar.s | 45 ++++++++++++++++++++++++ libsrc/nes/cpeekchar.s | 40 +++++++++++++++++++++ 10 files changed, 426 insertions(+) create mode 100644 libsrc/atari/cpeekchar.s create mode 100644 libsrc/atmos/cpeekchar.s create mode 100644 libsrc/c128/cpeekchar.s create mode 100644 libsrc/c128/cpeekcol.s create mode 100644 libsrc/cbm/cpeekchar.s create mode 100644 libsrc/cbm/cpeekcol.s create mode 100644 libsrc/cbm510/cpeekchar.s create mode 100644 libsrc/cbm510/cpeekcol.s create mode 100644 libsrc/cbm610/cpeekchar.s create mode 100644 libsrc/nes/cpeekchar.s diff --git a/libsrc/atari/cpeekchar.s b/libsrc/atari/cpeekchar.s new file mode 100644 index 000000000..b551ed0df --- /dev/null +++ b/libsrc/atari/cpeekchar.s @@ -0,0 +1,41 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + .import mul40 + .importzp ptr4 + + .include "atari/atari.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + lda ROWCRS + jsr mul40 ; destroys tmp4 + clc + adc SAVMSC ; add start of screen memory + sta ptr4 + txa + adc SAVMSC+1 + sta ptr4+1 + + ldy COLCRS + lda (ptr4),y ; get char + tax + + ;; convert to asc + + ;; ugly hack here to make tetris fx work :=P + lda #' ' + cpx #0 + beq @l + lda #0 +@l: + ldx #0 + rts diff --git a/libsrc/atmos/cpeekchar.s b/libsrc/atmos/cpeekchar.s new file mode 100644 index 000000000..a1d6d4474 --- /dev/null +++ b/libsrc/atmos/cpeekchar.s @@ -0,0 +1,36 @@ + + .include "atmos.inc" + +.import _gotoxy +.export _cpeekchar,_cpeekcharxy + +_cpeekcharxy: + + jsr _gotoxy ; Will pop x parameter + +_cpeekchar: + + ldy CURS_Y + ldx ScrTabLo,y + stx @l+1 + ldx ScrTabHi,y + stx @l+2 + ldx CURS_X +@l: + lda $bb80,x +;; inc COORDX_TEXT + ldx #0 + rts + + ; FIXME: is that table available elsewhere? +.rodata +ScrTabLo: + .repeat 28, Line + .byte <(SCREEN + Line * 40) + .endrep + +ScrTabHi: + .repeat 28, Line + .byte >(SCREEN + Line * 40) + .endrep + diff --git a/libsrc/c128/cpeekchar.s b/libsrc/c128/cpeekchar.s new file mode 100644 index 000000000..e6e7e4a12 --- /dev/null +++ b/libsrc/c128/cpeekchar.s @@ -0,0 +1,74 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .import plot,popa + + + .include "zeropage.inc" + .include "c128/c128.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + lda MODE + bmi @c80 + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + +@return: + ; convert to asc + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + ldx #0 + rts + +@c80: + lda SCREEN_PTR + ldy SCREEN_PTR+1 + clc + adc CURS_X + bcc @s + iny +@s: + ; get byte from vdc mem + ldx #VDC_DATA_LO + stx VDC_ADDR_REG +@L0: bit VDC_ADDR_REG + bpl @L0 + sta VDC_DATA_REG + dex + tya + stx VDC_ADDR_REG + sta VDC_DATA_REG + + ldx #VDC_DATA_RW + stx VDC_ADDR_REG +@L1: bit VDC_ADDR_REG + bpl @L1 + lda VDC_DATA_REG + jmp @return diff --git a/libsrc/c128/cpeekcol.s b/libsrc/c128/cpeekcol.s new file mode 100644 index 000000000..95f31c7cb --- /dev/null +++ b/libsrc/c128/cpeekcol.s @@ -0,0 +1,67 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "c128/c128.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + bit MODE + bmi @c80 + + ldy CURS_X + lda (CRAM_PTR),y ; get col + and #$0f + ldx #0 + rts + +@c80: + lda CRAM_PTR + ldy CRAM_PTR+1 + clc + adc CURS_X + bcc @s + iny +@s: + ; get byte from vdc mem + ldx #VDC_DATA_LO + stx VDC_ADDR_REG +@L0: bit VDC_ADDR_REG + bpl @L0 + sta VDC_DATA_REG + dex + ;;tya + stx VDC_ADDR_REG + sty VDC_DATA_REG + + ldx #VDC_DATA_RW + stx VDC_ADDR_REG +@L1: bit VDC_ADDR_REG + bpl @L1 + lda VDC_DATA_REG + + + and #$0f + +; translate vdc->vic colour + +vdctovic: + ldy #16 +@L2: cmp $CE5C-1,y + beq @L3 + dey + bne @L2 +@L3: + dey + tya + + ldx #0 + rts diff --git a/libsrc/cbm/cpeekchar.s b/libsrc/cbm/cpeekchar.s new file mode 100644 index 000000000..e8ebcdbc3 --- /dev/null +++ b/libsrc/cbm/cpeekchar.s @@ -0,0 +1,39 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "cbm/cbm.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + ldx #0 + + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + rts diff --git a/libsrc/cbm/cpeekcol.s b/libsrc/cbm/cpeekcol.s new file mode 100644 index 000000000..0e88daf04 --- /dev/null +++ b/libsrc/cbm/cpeekcol.s @@ -0,0 +1,21 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "cc65/conio.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0f + ldx #0 + rts diff --git a/libsrc/cbm510/cpeekchar.s b/libsrc/cbm510/cpeekchar.s new file mode 100644 index 000000000..dc5963d2b --- /dev/null +++ b/libsrc/cbm510/cpeekchar.s @@ -0,0 +1,32 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "cbm510/cbm510.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + lda #0 + ldx #0 + rts + + ;; ?!?! + + ldx IndReg + ldy #$0F + sty IndReg + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + + stx IndReg + + ldx #0 + rts diff --git a/libsrc/cbm510/cpeekcol.s b/libsrc/cbm510/cpeekcol.s new file mode 100644 index 000000000..332d0aaf8 --- /dev/null +++ b/libsrc/cbm510/cpeekcol.s @@ -0,0 +1,31 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "cbm510/cbm510.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + lda #0 + ldx #0 + rts + + ;; why the HELL doesnt this work ?!? + lda #$0F + ldy CURS_X + sei + ldx IndReg + sta IndReg + lda (CRAM_PTR),y ; get color + stx IndReg + cli + ldx #0 + rts diff --git a/libsrc/cbm610/cpeekchar.s b/libsrc/cbm610/cpeekchar.s new file mode 100644 index 000000000..8cf4bd57d --- /dev/null +++ b/libsrc/cbm610/cpeekchar.s @@ -0,0 +1,45 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "cbm610/cbm610.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldx IndReg + ldy #$0F + sty IndReg + + ldy CURS_X + lda (CharPtr),y ; get char + ; convert to asc + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + jmp @end + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 + +@end: + stx IndReg + ldx #0 + rts diff --git a/libsrc/nes/cpeekchar.s b/libsrc/nes/cpeekchar.s new file mode 100644 index 000000000..292a4591f --- /dev/null +++ b/libsrc/nes/cpeekchar.s @@ -0,0 +1,40 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + .import ppubuf_waitempty + + .include "nes.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ; wait until all console data has been written + jsr ppubuf_waitempty + + ldy SCREEN_PTR+1 + ldx SCREEN_PTR + +; waiting for vblank is incredibly slow :// +vwait: +; lda $2002 ;wait +; bpl vwait + + lda #0 + sty $2006 + stx $2006 + ldy $2007 ; first read is invalid + ldy $2007 ; get data + sta $2006 + sta $2006 + + tya + and #$7f ; ?!?! + rts + From b523f070f3933e060f927d7d76026159b7355377 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 17 Jun 2017 03:01:31 +0200 Subject: [PATCH 02/18] fixed a few things, compiles again :) --- asminc/c128.inc | 9 +++++++-- libsrc/atari/cpeekchar.s | 2 +- libsrc/c128/cpeekchar.s | 18 +++++++++--------- libsrc/c128/cpeekcol.s | 18 +++++++++--------- libsrc/cbm/cpeekchar.s | 39 --------------------------------------- libsrc/cbm/cpeekcol.s | 21 --------------------- libsrc/cbm510/cpeekchar.s | 5 +++-- libsrc/cbm510/cpeekcol.s | 3 ++- libsrc/cbm610/cpeekchar.s | 3 ++- 9 files changed, 33 insertions(+), 85 deletions(-) delete mode 100644 libsrc/cbm/cpeekchar.s delete mode 100644 libsrc/cbm/cpeekcol.s diff --git a/asminc/c128.inc b/asminc/c128.inc index e6c89b07b..e17bae4ce 100644 --- a/asminc/c128.inc +++ b/asminc/c128.inc @@ -163,8 +163,13 @@ SID_Read3 := $D41C ; --------------------------------------------------------------------------- ; I/O: VDC (128 only) -VDC_INDEX := $D600 -VDC_DATA := $D601 +VDC_INDEX := $D600 ; VDC address +VDC_DATA := $D601 ; VDC data + +VDC_DATA_HI := 18 +VDC_DATA_LO := 19 +VDC_CSET := 28 +VDC_DATA_RW := 31 ; --------------------------------------------------------------------------- ; I/O: CIAs diff --git a/libsrc/atari/cpeekchar.s b/libsrc/atari/cpeekchar.s index b551ed0df..6697ce230 100644 --- a/libsrc/atari/cpeekchar.s +++ b/libsrc/atari/cpeekchar.s @@ -6,7 +6,7 @@ .import mul40 .importzp ptr4 - .include "atari/atari.inc" + .include "atari.inc" .segment "CODE" diff --git a/libsrc/c128/cpeekchar.s b/libsrc/c128/cpeekchar.s index e6e7e4a12..cf82dd529 100644 --- a/libsrc/c128/cpeekchar.s +++ b/libsrc/c128/cpeekchar.s @@ -8,7 +8,7 @@ .include "zeropage.inc" - .include "c128/c128.inc" + .include "c128.inc" .segment "CODE" @@ -57,18 +57,18 @@ _cpeekchar: @s: ; get byte from vdc mem ldx #VDC_DATA_LO - stx VDC_ADDR_REG -@L0: bit VDC_ADDR_REG + stx VDC_INDEX +@L0: bit VDC_INDEX bpl @L0 - sta VDC_DATA_REG + sta VDC_DATA dex tya - stx VDC_ADDR_REG - sta VDC_DATA_REG + stx VDC_INDEX + sta VDC_DATA ldx #VDC_DATA_RW - stx VDC_ADDR_REG -@L1: bit VDC_ADDR_REG + stx VDC_INDEX +@L1: bit VDC_INDEX bpl @L1 - lda VDC_DATA_REG + lda VDC_DATA jmp @return diff --git a/libsrc/c128/cpeekcol.s b/libsrc/c128/cpeekcol.s index 95f31c7cb..d96563574 100644 --- a/libsrc/c128/cpeekcol.s +++ b/libsrc/c128/cpeekcol.s @@ -4,7 +4,7 @@ .import _gotoxy - .include "c128/c128.inc" + .include "c128.inc" .segment "CODE" @@ -33,20 +33,20 @@ _cpeekcol: @s: ; get byte from vdc mem ldx #VDC_DATA_LO - stx VDC_ADDR_REG -@L0: bit VDC_ADDR_REG + stx VDC_INDEX +@L0: bit VDC_INDEX bpl @L0 - sta VDC_DATA_REG + sta VDC_DATA dex ;;tya - stx VDC_ADDR_REG - sty VDC_DATA_REG + stx VDC_INDEX + sty VDC_DATA ldx #VDC_DATA_RW - stx VDC_ADDR_REG -@L1: bit VDC_ADDR_REG + stx VDC_INDEX +@L1: bit VDC_INDEX bpl @L1 - lda VDC_DATA_REG + lda VDC_DATA and #$0f diff --git a/libsrc/cbm/cpeekchar.s b/libsrc/cbm/cpeekchar.s deleted file mode 100644 index e8ebcdbc3..000000000 --- a/libsrc/cbm/cpeekchar.s +++ /dev/null @@ -1,39 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "cbm/cbm.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - ldx #0 - - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - rts diff --git a/libsrc/cbm/cpeekcol.s b/libsrc/cbm/cpeekcol.s deleted file mode 100644 index 0e88daf04..000000000 --- a/libsrc/cbm/cpeekcol.s +++ /dev/null @@ -1,21 +0,0 @@ - - .export _cpeekcol - .export _cpeekcolxy - - .import _gotoxy - - .include "cc65/conio.inc" - - .segment "CODE" - -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - and #$0f - ldx #0 - rts diff --git a/libsrc/cbm510/cpeekchar.s b/libsrc/cbm510/cpeekchar.s index dc5963d2b..11787fe1e 100644 --- a/libsrc/cbm510/cpeekchar.s +++ b/libsrc/cbm510/cpeekchar.s @@ -3,8 +3,9 @@ .export _cpeekcharxy .import _gotoxy - - .include "cbm510/cbm510.inc" + + .include "cbm510.inc" + .include "extzp.inc" .segment "CODE" diff --git a/libsrc/cbm510/cpeekcol.s b/libsrc/cbm510/cpeekcol.s index 332d0aaf8..bbe7c5632 100644 --- a/libsrc/cbm510/cpeekcol.s +++ b/libsrc/cbm510/cpeekcol.s @@ -4,7 +4,8 @@ .import _gotoxy - .include "cbm510/cbm510.inc" + .include "cbm510.inc" + .include "extzp.inc" .segment "CODE" diff --git a/libsrc/cbm610/cpeekchar.s b/libsrc/cbm610/cpeekchar.s index 8cf4bd57d..217532ab5 100644 --- a/libsrc/cbm610/cpeekchar.s +++ b/libsrc/cbm610/cpeekchar.s @@ -4,7 +4,8 @@ .import _gotoxy - .include "cbm610/cbm610.inc" + .include "cbm610.inc" + .include "extzp.inc" .segment "CODE" From dd14f15f948b9684afe4c352a0a10d5a6777eadf Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 17 Jun 2017 03:46:53 +0200 Subject: [PATCH 03/18] added fixed files for c64/c16/plus4/vic20/pet --- libsrc/c16/cpeekchar.s | 39 ++++++++++++ libsrc/c16/cpeekcol.s | 21 +++++++ libsrc/c64/cpeekchar.s | 39 ++++++++++++ libsrc/c64/cpeekcol.s | 21 +++++++ libsrc/c64/soft80_cpeekchar.s | 113 ++++++++++++++++++++++++++++++++++ libsrc/c64/soft80_cpeekcol.s | 21 +++++++ libsrc/pet/cpeekchar.s | 39 ++++++++++++ libsrc/plus4/cpeekchar.s | 39 ++++++++++++ libsrc/plus4/cpeekcol.s | 21 +++++++ libsrc/vic20/cpeekchar.s | 39 ++++++++++++ libsrc/vic20/cpeekcol.s | 21 +++++++ 11 files changed, 413 insertions(+) create mode 100644 libsrc/c16/cpeekchar.s create mode 100644 libsrc/c16/cpeekcol.s create mode 100644 libsrc/c64/cpeekchar.s create mode 100644 libsrc/c64/cpeekcol.s create mode 100644 libsrc/c64/soft80_cpeekchar.s create mode 100644 libsrc/c64/soft80_cpeekcol.s create mode 100644 libsrc/pet/cpeekchar.s create mode 100644 libsrc/plus4/cpeekchar.s create mode 100644 libsrc/plus4/cpeekcol.s create mode 100644 libsrc/vic20/cpeekchar.s create mode 100644 libsrc/vic20/cpeekcol.s diff --git a/libsrc/c16/cpeekchar.s b/libsrc/c16/cpeekchar.s new file mode 100644 index 000000000..5d89570f1 --- /dev/null +++ b/libsrc/c16/cpeekchar.s @@ -0,0 +1,39 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "c16.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + ldx #0 + + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + rts diff --git a/libsrc/c16/cpeekcol.s b/libsrc/c16/cpeekcol.s new file mode 100644 index 000000000..41fed7b9f --- /dev/null +++ b/libsrc/c16/cpeekcol.s @@ -0,0 +1,21 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "c16.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + ldy CURS_X + lda (CRAM_PTR),y ; get color + ;and #$0f is this ok? + ldx #0 + rts diff --git a/libsrc/c64/cpeekchar.s b/libsrc/c64/cpeekchar.s new file mode 100644 index 000000000..33d0284e7 --- /dev/null +++ b/libsrc/c64/cpeekchar.s @@ -0,0 +1,39 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "c64.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + ldx #0 + + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + rts diff --git a/libsrc/c64/cpeekcol.s b/libsrc/c64/cpeekcol.s new file mode 100644 index 000000000..60fb45c7b --- /dev/null +++ b/libsrc/c64/cpeekcol.s @@ -0,0 +1,21 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "c64.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0f + ldx #0 + rts diff --git a/libsrc/c64/soft80_cpeekchar.s b/libsrc/c64/soft80_cpeekchar.s new file mode 100644 index 000000000..21a9fc5e7 --- /dev/null +++ b/libsrc/c64/soft80_cpeekchar.s @@ -0,0 +1,113 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + .import soft80_hi_charset + .import soft80_lo_charset + + .include "c64.inc" + + .macpack longbranch + + .segment "CODE" + +readdirect: +; sei +; dec $01 ;; assumed = $36 +; dec $01 ;; assumed = $36 + lda (SCREEN_PTR),y +; inc $01 +; inc $01 +; cli + rts + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + +;;rts + sei + ;;dec $01 ;; assumed = $36 + ;;dec $01 ;; assumed = $36 + lda #$34 + sta $01 + + lda CURS_X + and #$01 + + jne @l1a + +;; inc $d020 + +;;jmp * + + ldx #0 +@l2aa: + ldy #0 + +;; stx $d020 + + .repeat 8,line +;; jsr readdirect + lda (SCREEN_PTR),y + and #$f0 + sta $e100,y + cmp soft80_hi_charset+(line*$80),x +; cmp #0 + bne @l2b + .if (line < 7) + iny + .endif + .endrepeat + + +@backok: +;inc $d020 +; inc $01 +; inc $01 + lda #$36 + sta $01 + cli + txa + ; sec +; sbc #$20 + ldx #$00 + rts +@l2b: +;jmp * + inx + cpx #$80 + jne @l2aa +@backerr: + ;; inc $01 +;; inc $01 + lda #$36 + sta $01 + cli + ldx #0 + txa + rts + +@l1a: + ldx #0 +@l1aa: + ldy #0 + .repeat 8,line +;; jsr readdirect + lda (SCREEN_PTR),y + and #$0f + eor soft80_lo_charset+(line*$80),x + bne @l2bb + .if line < 7 + iny + .endif + .endrepeat + jmp @backok +@l2bb: + inx + cpx #$80 + bne @l1aa + jmp @backerr diff --git a/libsrc/c64/soft80_cpeekcol.s b/libsrc/c64/soft80_cpeekcol.s new file mode 100644 index 000000000..9891ab28a --- /dev/null +++ b/libsrc/c64/soft80_cpeekcol.s @@ -0,0 +1,21 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "c64.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + ldy #0 + lda (CRAM_PTR),y ; get char + and #$0f + ldx #0 + rts diff --git a/libsrc/pet/cpeekchar.s b/libsrc/pet/cpeekchar.s new file mode 100644 index 000000000..c846beb56 --- /dev/null +++ b/libsrc/pet/cpeekchar.s @@ -0,0 +1,39 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "pet.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + ldx #0 + + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + rts diff --git a/libsrc/plus4/cpeekchar.s b/libsrc/plus4/cpeekchar.s new file mode 100644 index 000000000..1d47c6d64 --- /dev/null +++ b/libsrc/plus4/cpeekchar.s @@ -0,0 +1,39 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "plus4.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + ldx #0 + + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + rts diff --git a/libsrc/plus4/cpeekcol.s b/libsrc/plus4/cpeekcol.s new file mode 100644 index 000000000..0f3258eb3 --- /dev/null +++ b/libsrc/plus4/cpeekcol.s @@ -0,0 +1,21 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "plus4.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + ldy CURS_X + lda (CRAM_PTR),y ; get color + ;and #$0f is this ok? + ldx #0 + rts diff --git a/libsrc/vic20/cpeekchar.s b/libsrc/vic20/cpeekchar.s new file mode 100644 index 000000000..fae7ec1b4 --- /dev/null +++ b/libsrc/vic20/cpeekchar.s @@ -0,0 +1,39 @@ + + .export _cpeekchar + .export _cpeekcharxy + + .import _gotoxy + + .include "vic20.inc" + + .segment "CODE" + +_cpeekcharxy: + + jsr _gotoxy ; Set cursor + +_cpeekchar: + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + ldx #0 + + and #$7f + + ; 0 - $1f +$40 + ; $20 - $3f + ; $40 - $7e +$80 + + cmp #$1f + bcs @sk1 +;; clc + adc #$40 + rts + +@sk1: + cmp #$40 + bcc @end + clc + adc #$80 +@end: + rts diff --git a/libsrc/vic20/cpeekcol.s b/libsrc/vic20/cpeekcol.s new file mode 100644 index 000000000..59bf057ff --- /dev/null +++ b/libsrc/vic20/cpeekcol.s @@ -0,0 +1,21 @@ + + .export _cpeekcol + .export _cpeekcolxy + + .import _gotoxy + + .include "vic20.inc" + + .segment "CODE" + +_cpeekcolxy: + + jsr _gotoxy ; Set cursor + +_cpeekcol: + + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0f + ldx #0 + rts From 74098077d3bb93be8943b45a5c8cdf6810fbd74a Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 03:36:19 +0200 Subject: [PATCH 04/18] bleh --- asminc/c128.inc | 224 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 asminc/c128.inc diff --git a/asminc/c128.inc b/asminc/c128.inc new file mode 100644 index 000000000..749b4168c --- /dev/null +++ b/asminc/c128.inc @@ -0,0 +1,224 @@ +; +; C128 generic definitions. Stolen from Elite128 +; + + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +TXTPTR := $3D ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +TIME := $A0 ; 60HZ clock +FNAM_LEN := $B7 ; Length of filename +SECADR := $B9 ; Secondary address +DEVNUM := $BA ; Device number +FNAM := $BB ; Address of filename +FNAM_BANK := $C7 ; Bank for filename +KEY_COUNT := $D0 ; Number of keys in input buffer +FKEY_COUNT := $D1 ; Characters for function key +MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns) +GRAPHM := $D8 ; Graphics mode flags (bits 5-7) +CHARDIS := $D9 ; Bit 2 shadow for location $01 +CURS_X := $EC ; Cursor column +CURS_Y := $EB ; Cursor row +SCREEN_PTR := $E0 ; Pointer to current char in text screen +CRAM_PTR := $E2 ; Pointer to current char in color RAM + +CHARCOLOR := $F1 +RVS := $F3 ; Reverse output flag +SCROLL := $F8 ; Disable scrolling flag + +BASIC_BUF := $0200 ; Location of command-line +BASIC_BUF_LEN = 162 ; Maximum length of command-line + +FETCH := $02A2 ; Fetch subroutine in RAM +FETVEC := $02AA ; Vector patch location for FETCH +STASH := $02AF ; Stash routine in RAM +STAVEC := $02B9 ; Vector patch location for STASH +IRQInd := $02FD ; JMP $0000 -- used as indirect IRQ vector +PALFLAG := $0A03 ; $FF=PAL, $00=NTSC +INIT_STATUS := $0A04 ; Flags: Reset/Restore initiation status +VM2 := $0A2D ; VIC-IIe shadow for $D018 -- graphics mode +FKEY_LEN := $1000 ; Function key lengths +FKEY_TEXT := $100A ; Function key texts + +KBDREPEAT := $028a +KBDREPEATRATE := $028b +KBDREPEATDELAY := $028c + +; --------------------------------------------------------------------------- +; Vectors + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 +KeyStoreVec := $033C + +; --------------------------------------------------------------------------- +; I/O: VIC + +VIC := $D000 +VIC_SPR0_X := $D000 +VIC_SPR0_Y := $D001 +VIC_SPR1_X := $D002 +VIC_SPR1_Y := $D003 +VIC_SPR2_X := $D004 +VIC_SPR2_Y := $D005 +VIC_SPR3_X := $D006 +VIC_SPR3_Y := $D007 +VIC_SPR4_X := $D008 +VIC_SPR4_Y := $D009 +VIC_SPR5_X := $D00A +VIC_SPR5_Y := $D00B +VIC_SPR6_X := $D00C +VIC_SPR6_Y := $D00D +VIC_SPR7_X := $D00E +VIC_SPR7_Y := $D00F +VIC_SPR_HI_X := $D010 +VIC_SPR_ENA := $D015 +VIC_SPR_EXP_Y := $D017 +VIC_SPR_EXP_X := $D01D +VIC_SPR_MCOLOR := $D01C +VIC_SPR_BG_PRIO := $D01B + +VIC_SPR_MCOLOR0 := $D025 +VIC_SPR_MCOLOR1 := $D026 + +VIC_SPR0_COLOR := $D027 +VIC_SPR1_COLOR := $D028 +VIC_SPR2_COLOR := $D029 +VIC_SPR3_COLOR := $D02A +VIC_SPR4_COLOR := $D02B +VIC_SPR5_COLOR := $D02C +VIC_SPR6_COLOR := $D02D +VIC_SPR7_COLOR := $D02E + +VIC_CTRL1 := $D011 +VIC_CTRL2 := $D016 + +VIC_HLINE := $D012 + +VIC_LPEN_X := $D013 +VIC_LPEN_Y := $D014 + +VIC_VIDEO_ADR := $D018 + +VIC_IRR := $D019 ; Interrupt request register +VIC_IMR := $D01A ; Interrupt mask register + +VIC_BORDERCOLOR := $D020 +VIC_BG_COLOR0 := $D021 +VIC_BG_COLOR1 := $D022 +VIC_BG_COLOR2 := $D023 +VIC_BG_COLOR3 := $D024 + +; 128 stuff: +VIC_KBD_128 := $D02F ; Extended kbd bits (visible in 64 mode) +VIC_CLK_128 := $D030 ; Clock rate register (visible in 64 mode) + + +; --------------------------------------------------------------------------- +; I/O: SID + +SID := $D400 +SID_S1Lo := $D400 +SID_S1Hi := $D401 +SID_PB1Lo := $D402 +SID_PB1Hi := $D403 +SID_Ctl1 := $D404 +SID_AD1 := $D405 +SID_SUR1 := $D406 + +SID_S2Lo := $D407 +SID_S2Hi := $D408 +SID_PB2Lo := $D409 +SID_PB2Hi := $D40A +SID_Ctl2 := $D40B +SID_AD2 := $D40C +SID_SUR2 := $D40D + +SID_S3Lo := $D40E +SID_S3Hi := $D40F +SID_PB3Lo := $D410 +SID_PB3Hi := $D411 +SID_Ctl3 := $D412 +SID_AD3 := $D413 +SID_SUR3 := $D414 + +SID_FltLo := $D415 +SID_FltHi := $D416 +SID_FltCtl := $D417 +SID_Amp := $D418 +SID_ADConv1 := $D419 +SID_ADConv2 := $D41A +SID_Noise := $D41B +SID_Read3 := $D41C + +; --------------------------------------------------------------------------- +; I/O: VDC (128 only) + +VDC_INDEX := $D600 ; register address port +VDC_DATA := $D601 ; data port + +; Registers +VDC_DATA_HI = 18 ; video RAM address (big endian) +VDC_DATA_LO = 19 +VDC_CSET = 28 +VDC_RAM_RW = 31 ; RAM port + +; --------------------------------------------------------------------------- +; I/O: Complex Interface Adapters + +CIA1 := $DC00 +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B + +CIA2 := $DD00 +CIA2_PRA := $DD00 +CIA2_PRB := $DD01 +CIA2_DDRA := $DD02 +CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 +CIA2_TOD10 := $DD08 +CIA2_TODSEC := $DD09 +CIA2_TODMIN := $DD0A +CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C +CIA2_ICR := $DD0D +CIA2_CRA := $DD0E +CIA2_CRB := $DD0F + +; --------------------------------------------------------------------------- +; I/O: MMU + +MMU_CR := $FF00 +MMU_CFG_CC65 := %00001110 ; Bank 0 with kernal ROM +MMU_CFG_RAM0 := %00111111 ; Bank 0 full RAM +MMU_CFG_RAM1 := %01111111 ; Bank 1 full RAM +MMU_CFG_RAM2 := %10111111 ; Bank 2 full RAM +MMU_CFG_RAM3 := %11111111 ; Bank 3 full RAM +MMU_CFG_IFROM := %01010111 ; Bank 1 with Internal Function RAM/ROM +MMU_CFG_EFROM := %01101011 ; Bank 1 with External Function RAM/ROM + +; --------------------------------------------------------------------------- +; Super CPU + +SCPU_VIC_Bank1 := $D075 +SCPU_Slow := $D07A +SCPU_Fast := $D07B +SCPU_EnableRegs := $D07E +SCPU_DisableRegs:= $D07F +SCPU_Detect := $D0BC From 6dae5324ddbea4dcbb19c913109f4bc4d5fbfde5 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 03:59:19 +0200 Subject: [PATCH 05/18] cleanup --- libsrc/c128/cpeekcol.s | 67 ------------------------------------ libsrc/c16/cpeekcol.s | 11 ++---- libsrc/c64/cpeekcol.s | 23 +++++-------- libsrc/c64/soft80_cpeekcol.s | 21 ----------- libsrc/cbm510/cpeekcol.s | 32 ----------------- libsrc/plus4/cpeekcol.s | 23 +++++-------- libsrc/vic20/cpeekcol.s | 23 +++++-------- 7 files changed, 26 insertions(+), 174 deletions(-) delete mode 100644 libsrc/c128/cpeekcol.s delete mode 100644 libsrc/c64/soft80_cpeekcol.s delete mode 100644 libsrc/cbm510/cpeekcol.s diff --git a/libsrc/c128/cpeekcol.s b/libsrc/c128/cpeekcol.s deleted file mode 100644 index d96563574..000000000 --- a/libsrc/c128/cpeekcol.s +++ /dev/null @@ -1,67 +0,0 @@ - - .export _cpeekcol - .export _cpeekcolxy - - .import _gotoxy - - .include "c128.inc" - - .segment "CODE" - -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - bit MODE - bmi @c80 - - ldy CURS_X - lda (CRAM_PTR),y ; get col - and #$0f - ldx #0 - rts - -@c80: - lda CRAM_PTR - ldy CRAM_PTR+1 - clc - adc CURS_X - bcc @s - iny -@s: - ; get byte from vdc mem - ldx #VDC_DATA_LO - stx VDC_INDEX -@L0: bit VDC_INDEX - bpl @L0 - sta VDC_DATA - dex - ;;tya - stx VDC_INDEX - sty VDC_DATA - - ldx #VDC_DATA_RW - stx VDC_INDEX -@L1: bit VDC_INDEX - bpl @L1 - lda VDC_DATA - - - and #$0f - -; translate vdc->vic colour - -vdctovic: - ldy #16 -@L2: cmp $CE5C-1,y - beq @L3 - dey - bne @L2 -@L3: - dey - tya - - ldx #0 - rts diff --git a/libsrc/c16/cpeekcol.s b/libsrc/c16/cpeekcol.s index 41fed7b9f..446079ddd 100644 --- a/libsrc/c16/cpeekcol.s +++ b/libsrc/c16/cpeekcol.s @@ -1,18 +1,11 @@ - .export _cpeekcol - .export _cpeekcolxy - - .import _gotoxy + .export _cpeekcolor .include "c16.inc" .segment "CODE" -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: +_cpeekcolor: ldy CURS_X lda (CRAM_PTR),y ; get color diff --git a/libsrc/c64/cpeekcol.s b/libsrc/c64/cpeekcol.s index 60fb45c7b..8e87cff23 100644 --- a/libsrc/c64/cpeekcol.s +++ b/libsrc/c64/cpeekcol.s @@ -1,21 +1,14 @@ - .export _cpeekcol - .export _cpeekcolxy + .export _cpeekcolor - .import _gotoxy + .include "c64.inc" - .include "c64.inc" + .segment "CODE" - .segment "CODE" +_cpeekcolor: -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - and #$0f + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0f ldx #0 - rts + rts diff --git a/libsrc/c64/soft80_cpeekcol.s b/libsrc/c64/soft80_cpeekcol.s deleted file mode 100644 index 9891ab28a..000000000 --- a/libsrc/c64/soft80_cpeekcol.s +++ /dev/null @@ -1,21 +0,0 @@ - - .export _cpeekcol - .export _cpeekcolxy - - .import _gotoxy - - .include "c64.inc" - - .segment "CODE" - -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - ldy #0 - lda (CRAM_PTR),y ; get char - and #$0f - ldx #0 - rts diff --git a/libsrc/cbm510/cpeekcol.s b/libsrc/cbm510/cpeekcol.s deleted file mode 100644 index bbe7c5632..000000000 --- a/libsrc/cbm510/cpeekcol.s +++ /dev/null @@ -1,32 +0,0 @@ - - .export _cpeekcol - .export _cpeekcolxy - - .import _gotoxy - - .include "cbm510.inc" - .include "extzp.inc" - - .segment "CODE" - -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - lda #0 - ldx #0 - rts - - ;; why the HELL doesnt this work ?!? - lda #$0F - ldy CURS_X - sei - ldx IndReg - sta IndReg - lda (CRAM_PTR),y ; get color - stx IndReg - cli - ldx #0 - rts diff --git a/libsrc/plus4/cpeekcol.s b/libsrc/plus4/cpeekcol.s index 0f3258eb3..b98b0124e 100644 --- a/libsrc/plus4/cpeekcol.s +++ b/libsrc/plus4/cpeekcol.s @@ -1,21 +1,14 @@ - .export _cpeekcol - .export _cpeekcolxy + .export _cpeekcolor - .import _gotoxy + .include "plus4.inc" - .include "plus4.inc" + .segment "CODE" - .segment "CODE" +_cpeekcolor: -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - ;and #$0f is this ok? + ldy CURS_X + lda (CRAM_PTR),y ; get color + ;and #$0f is this ok? ldx #0 - rts + rts diff --git a/libsrc/vic20/cpeekcol.s b/libsrc/vic20/cpeekcol.s index 59bf057ff..31fa4612a 100644 --- a/libsrc/vic20/cpeekcol.s +++ b/libsrc/vic20/cpeekcol.s @@ -1,21 +1,14 @@ - .export _cpeekcol - .export _cpeekcolxy + .export _cpeekcolor - .import _gotoxy + .include "vic20.inc" - .include "vic20.inc" + .segment "CODE" - .segment "CODE" +_cpeekcolor: -_cpeekcolxy: - - jsr _gotoxy ; Set cursor - -_cpeekcol: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - and #$0f + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0f ldx #0 - rts + rts From 7890f4102e30bad2d76c8888b6dcd0487598bf95 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 04:14:48 +0200 Subject: [PATCH 06/18] cleanup --- libsrc/c128/cpeekchar.s | 74 ---------------------- libsrc/c64/soft80_cpeekchar.s | 113 ---------------------------------- libsrc/cbm610/cpeekchar.s | 46 -------------- 3 files changed, 233 deletions(-) delete mode 100644 libsrc/c128/cpeekchar.s delete mode 100644 libsrc/c64/soft80_cpeekchar.s delete mode 100644 libsrc/cbm610/cpeekchar.s diff --git a/libsrc/c128/cpeekchar.s b/libsrc/c128/cpeekchar.s deleted file mode 100644 index cf82dd529..000000000 --- a/libsrc/c128/cpeekchar.s +++ /dev/null @@ -1,74 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .import plot,popa - - - .include "zeropage.inc" - .include "c128.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - lda MODE - bmi @c80 - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - -@return: - ; convert to asc - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - ldx #0 - rts - -@c80: - lda SCREEN_PTR - ldy SCREEN_PTR+1 - clc - adc CURS_X - bcc @s - iny -@s: - ; get byte from vdc mem - ldx #VDC_DATA_LO - stx VDC_INDEX -@L0: bit VDC_INDEX - bpl @L0 - sta VDC_DATA - dex - tya - stx VDC_INDEX - sta VDC_DATA - - ldx #VDC_DATA_RW - stx VDC_INDEX -@L1: bit VDC_INDEX - bpl @L1 - lda VDC_DATA - jmp @return diff --git a/libsrc/c64/soft80_cpeekchar.s b/libsrc/c64/soft80_cpeekchar.s deleted file mode 100644 index 21a9fc5e7..000000000 --- a/libsrc/c64/soft80_cpeekchar.s +++ /dev/null @@ -1,113 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - .import soft80_hi_charset - .import soft80_lo_charset - - .include "c64.inc" - - .macpack longbranch - - .segment "CODE" - -readdirect: -; sei -; dec $01 ;; assumed = $36 -; dec $01 ;; assumed = $36 - lda (SCREEN_PTR),y -; inc $01 -; inc $01 -; cli - rts - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - -;;rts - sei - ;;dec $01 ;; assumed = $36 - ;;dec $01 ;; assumed = $36 - lda #$34 - sta $01 - - lda CURS_X - and #$01 - - jne @l1a - -;; inc $d020 - -;;jmp * - - ldx #0 -@l2aa: - ldy #0 - -;; stx $d020 - - .repeat 8,line -;; jsr readdirect - lda (SCREEN_PTR),y - and #$f0 - sta $e100,y - cmp soft80_hi_charset+(line*$80),x -; cmp #0 - bne @l2b - .if (line < 7) - iny - .endif - .endrepeat - - -@backok: -;inc $d020 -; inc $01 -; inc $01 - lda #$36 - sta $01 - cli - txa - ; sec -; sbc #$20 - ldx #$00 - rts -@l2b: -;jmp * - inx - cpx #$80 - jne @l2aa -@backerr: - ;; inc $01 -;; inc $01 - lda #$36 - sta $01 - cli - ldx #0 - txa - rts - -@l1a: - ldx #0 -@l1aa: - ldy #0 - .repeat 8,line -;; jsr readdirect - lda (SCREEN_PTR),y - and #$0f - eor soft80_lo_charset+(line*$80),x - bne @l2bb - .if line < 7 - iny - .endif - .endrepeat - jmp @backok -@l2bb: - inx - cpx #$80 - bne @l1aa - jmp @backerr diff --git a/libsrc/cbm610/cpeekchar.s b/libsrc/cbm610/cpeekchar.s deleted file mode 100644 index 217532ab5..000000000 --- a/libsrc/cbm610/cpeekchar.s +++ /dev/null @@ -1,46 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "cbm610.inc" - .include "extzp.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldx IndReg - ldy #$0F - sty IndReg - - ldy CURS_X - lda (CharPtr),y ; get char - ; convert to asc - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - jmp @end - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 - -@end: - stx IndReg - ldx #0 - rts From d40def3d2d9b74eb5d326d35367f8f974a70b256 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 04:42:44 +0200 Subject: [PATCH 07/18] cleanup --- libsrc/c16/cpeekcol.s | 14 -------------- libsrc/c64/cpeekcol.s | 14 -------------- libsrc/plus4/cpeekcol.s | 14 -------------- libsrc/vic20/cpeekcol.s | 14 -------------- 4 files changed, 56 deletions(-) delete mode 100644 libsrc/c16/cpeekcol.s delete mode 100644 libsrc/c64/cpeekcol.s delete mode 100644 libsrc/plus4/cpeekcol.s delete mode 100644 libsrc/vic20/cpeekcol.s diff --git a/libsrc/c16/cpeekcol.s b/libsrc/c16/cpeekcol.s deleted file mode 100644 index 446079ddd..000000000 --- a/libsrc/c16/cpeekcol.s +++ /dev/null @@ -1,14 +0,0 @@ - - .export _cpeekcolor - - .include "c16.inc" - - .segment "CODE" - -_cpeekcolor: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - ;and #$0f is this ok? - ldx #0 - rts diff --git a/libsrc/c64/cpeekcol.s b/libsrc/c64/cpeekcol.s deleted file mode 100644 index 8e87cff23..000000000 --- a/libsrc/c64/cpeekcol.s +++ /dev/null @@ -1,14 +0,0 @@ - - .export _cpeekcolor - - .include "c64.inc" - - .segment "CODE" - -_cpeekcolor: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - and #$0f - ldx #0 - rts diff --git a/libsrc/plus4/cpeekcol.s b/libsrc/plus4/cpeekcol.s deleted file mode 100644 index b98b0124e..000000000 --- a/libsrc/plus4/cpeekcol.s +++ /dev/null @@ -1,14 +0,0 @@ - - .export _cpeekcolor - - .include "plus4.inc" - - .segment "CODE" - -_cpeekcolor: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - ;and #$0f is this ok? - ldx #0 - rts diff --git a/libsrc/vic20/cpeekcol.s b/libsrc/vic20/cpeekcol.s deleted file mode 100644 index 31fa4612a..000000000 --- a/libsrc/vic20/cpeekcol.s +++ /dev/null @@ -1,14 +0,0 @@ - - .export _cpeekcolor - - .include "vic20.inc" - - .segment "CODE" - -_cpeekcolor: - - ldy CURS_X - lda (CRAM_PTR),y ; get color - and #$0f - ldx #0 - rts From 193b7b9ee7f75c11c3ce2bbb73a2802146cf09de Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 04:54:34 +0200 Subject: [PATCH 08/18] cleanup --- libsrc/c16/cpeekchar.s | 39 --------------------------------------- libsrc/c64/cpeekchar.s | 39 --------------------------------------- libsrc/cbm510/cpeekchar.s | 33 --------------------------------- libsrc/pet/cpeekchar.s | 39 --------------------------------------- libsrc/plus4/cpeekchar.s | 39 --------------------------------------- libsrc/vic20/cpeekchar.s | 39 --------------------------------------- 6 files changed, 228 deletions(-) delete mode 100644 libsrc/c16/cpeekchar.s delete mode 100644 libsrc/c64/cpeekchar.s delete mode 100644 libsrc/cbm510/cpeekchar.s delete mode 100644 libsrc/pet/cpeekchar.s delete mode 100644 libsrc/plus4/cpeekchar.s delete mode 100644 libsrc/vic20/cpeekchar.s diff --git a/libsrc/c16/cpeekchar.s b/libsrc/c16/cpeekchar.s deleted file mode 100644 index 5d89570f1..000000000 --- a/libsrc/c16/cpeekchar.s +++ /dev/null @@ -1,39 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "c16.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - ldx #0 - - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - rts diff --git a/libsrc/c64/cpeekchar.s b/libsrc/c64/cpeekchar.s deleted file mode 100644 index 33d0284e7..000000000 --- a/libsrc/c64/cpeekchar.s +++ /dev/null @@ -1,39 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "c64.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - ldx #0 - - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - rts diff --git a/libsrc/cbm510/cpeekchar.s b/libsrc/cbm510/cpeekchar.s deleted file mode 100644 index 11787fe1e..000000000 --- a/libsrc/cbm510/cpeekchar.s +++ /dev/null @@ -1,33 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "cbm510.inc" - .include "extzp.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - lda #0 - ldx #0 - rts - - ;; ?!?! - - ldx IndReg - ldy #$0F - sty IndReg - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - - stx IndReg - - ldx #0 - rts diff --git a/libsrc/pet/cpeekchar.s b/libsrc/pet/cpeekchar.s deleted file mode 100644 index c846beb56..000000000 --- a/libsrc/pet/cpeekchar.s +++ /dev/null @@ -1,39 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "pet.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - ldx #0 - - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - rts diff --git a/libsrc/plus4/cpeekchar.s b/libsrc/plus4/cpeekchar.s deleted file mode 100644 index 1d47c6d64..000000000 --- a/libsrc/plus4/cpeekchar.s +++ /dev/null @@ -1,39 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "plus4.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - ldx #0 - - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - rts diff --git a/libsrc/vic20/cpeekchar.s b/libsrc/vic20/cpeekchar.s deleted file mode 100644 index fae7ec1b4..000000000 --- a/libsrc/vic20/cpeekchar.s +++ /dev/null @@ -1,39 +0,0 @@ - - .export _cpeekchar - .export _cpeekcharxy - - .import _gotoxy - - .include "vic20.inc" - - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor - -_cpeekchar: - - ldy CURS_X - lda (SCREEN_PTR),y ; get char - ldx #0 - - and #$7f - - ; 0 - $1f +$40 - ; $20 - $3f - ; $40 - $7e +$80 - - cmp #$1f - bcs @sk1 -;; clc - adc #$40 - rts - -@sk1: - cmp #$40 - bcc @end - clc - adc #$80 -@end: - rts From 10c2ce205b77c979ea396eb92bd503d5d9f75281 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 04:59:45 +0200 Subject: [PATCH 09/18] cleanup --- libsrc/atari/cpeekchar.s | 50 ++++++++++++++++++---------------------- libsrc/atmos/cpeekchar.s | 43 +++++++++++++++------------------- libsrc/nes/cpeekchar.s | 40 ++++++++++++++------------------ 3 files changed, 58 insertions(+), 75 deletions(-) diff --git a/libsrc/atari/cpeekchar.s b/libsrc/atari/cpeekchar.s index 6697ce230..c895059db 100644 --- a/libsrc/atari/cpeekchar.s +++ b/libsrc/atari/cpeekchar.s @@ -1,41 +1,35 @@ - .export _cpeekchar - .export _cpeekcharxy + .export _cpeekchar - .import _gotoxy - .import mul40 - .importzp ptr4 + .import mul40 + .importzp ptr4 - .include "atari.inc" + .include "atari.inc" - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor + .segment "CODE" _cpeekchar: - lda ROWCRS - jsr mul40 ; destroys tmp4 - clc - adc SAVMSC ; add start of screen memory - sta ptr4 - txa - adc SAVMSC+1 - sta ptr4+1 + lda ROWCRS + jsr mul40 ; destroys tmp4 + clc + adc SAVMSC ; add start of screen memory + sta ptr4 + txa + adc SAVMSC+1 + sta ptr4+1 - ldy COLCRS - lda (ptr4),y ; get char - tax + ldy COLCRS + lda (ptr4),y ; get char + tax - ;; convert to asc + ;; convert to asc - ;; ugly hack here to make tetris fx work :=P - lda #' ' - cpx #0 + ;; FIXME: ugly hack here to make tetris fx work :=P + lda #' ' + cpx #0 beq @l - lda #0 + lda #0 @l: ldx #0 - rts + rts diff --git a/libsrc/atmos/cpeekchar.s b/libsrc/atmos/cpeekchar.s index a1d6d4474..a03bdb6a7 100644 --- a/libsrc/atmos/cpeekchar.s +++ b/libsrc/atmos/cpeekchar.s @@ -1,36 +1,31 @@ - .include "atmos.inc" + .include "atmos.inc" -.import _gotoxy -.export _cpeekchar,_cpeekcharxy - -_cpeekcharxy: - - jsr _gotoxy ; Will pop x parameter + .export _cpeekchar _cpeekchar: - ldy CURS_Y - ldx ScrTabLo,y - stx @l+1 - ldx ScrTabHi,y - stx @l+2 - ldx CURS_X + ldy CURS_Y + ldx ScrTabLo,y + stx @l+1 + ldx ScrTabHi,y + stx @l+2 + ldx CURS_X @l: - lda $bb80,x -;; inc COORDX_TEXT - ldx #0 - rts + lda $bb80,x +;; inc COORDX_TEXT + ldx #0 + rts - ; FIXME: is that table available elsewhere? + ; FIXME: is that table available elsewhere? .rodata ScrTabLo: - .repeat 28, Line - .byte <(SCREEN + Line * 40) - .endrep + .repeat 28, Line + .byte <(SCREEN + Line * 40) + .endrep ScrTabHi: - .repeat 28, Line - .byte >(SCREEN + Line * 40) - .endrep + .repeat 28, Line + .byte >(SCREEN + Line * 40) + .endrep diff --git a/libsrc/nes/cpeekchar.s b/libsrc/nes/cpeekchar.s index 292a4591f..995e01bc1 100644 --- a/libsrc/nes/cpeekchar.s +++ b/libsrc/nes/cpeekchar.s @@ -1,40 +1,34 @@ - .export _cpeekchar - .export _cpeekcharxy + .export _cpeekchar - .import _gotoxy - .import ppubuf_waitempty + .import ppubuf_waitempty - .include "nes.inc" + .include "nes.inc" - .segment "CODE" - -_cpeekcharxy: - - jsr _gotoxy ; Set cursor + .segment "CODE" _cpeekchar: - ; wait until all console data has been written - jsr ppubuf_waitempty + ; wait until all console data has been written + jsr ppubuf_waitempty + + ldy SCREEN_PTR+1 + ldx SCREEN_PTR - ldy SCREEN_PTR+1 - ldx SCREEN_PTR - ; waiting for vblank is incredibly slow :// vwait: -; lda $2002 ;wait -; bpl vwait +; lda $2002 ;wait +; bpl vwait - lda #0 - sty $2006 + lda #0 + sty $2006 stx $2006 - ldy $2007 ; first read is invalid - ldy $2007 ; get data + ldy $2007 ; first read is invalid + ldy $2007 ; get data sta $2006 sta $2006 tya - and #$7f ; ?!?! - rts + and #$7f ; ?!?! + rts From aeb13b60a71efb71624d63b753bf828acb3fef0b Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 19:10:27 +0200 Subject: [PATCH 10/18] rename --- libsrc/atari/cpeekchar.s | 4 ++-- libsrc/atmos/cpeekchar.s | 4 ++-- libsrc/nes/cpeekchar.s | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libsrc/atari/cpeekchar.s b/libsrc/atari/cpeekchar.s index c895059db..ff502074d 100644 --- a/libsrc/atari/cpeekchar.s +++ b/libsrc/atari/cpeekchar.s @@ -1,5 +1,5 @@ - .export _cpeekchar + .export _cpeekc .import mul40 .importzp ptr4 @@ -8,7 +8,7 @@ .segment "CODE" -_cpeekchar: +_cpeekc: lda ROWCRS jsr mul40 ; destroys tmp4 diff --git a/libsrc/atmos/cpeekchar.s b/libsrc/atmos/cpeekchar.s index a03bdb6a7..2139989c3 100644 --- a/libsrc/atmos/cpeekchar.s +++ b/libsrc/atmos/cpeekchar.s @@ -1,9 +1,9 @@ .include "atmos.inc" - .export _cpeekchar + .export _cpeekc -_cpeekchar: +_cpeekc: ldy CURS_Y ldx ScrTabLo,y diff --git a/libsrc/nes/cpeekchar.s b/libsrc/nes/cpeekchar.s index 995e01bc1..b4e3c34fd 100644 --- a/libsrc/nes/cpeekchar.s +++ b/libsrc/nes/cpeekchar.s @@ -1,5 +1,5 @@ - .export _cpeekchar + .export _cpeekc .import ppubuf_waitempty @@ -7,7 +7,7 @@ .segment "CODE" -_cpeekchar: +_cpeekc: ; wait until all console data has been written jsr ppubuf_waitempty From a998d3490713e29f8ce16ecc7967cede6227a733 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 24 Jul 2022 19:16:15 +0200 Subject: [PATCH 11/18] remove tabs --- libsrc/atmos/cpeekchar.s | 3 +-- libsrc/nes/cpeekchar.s | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libsrc/atmos/cpeekchar.s b/libsrc/atmos/cpeekchar.s index 2139989c3..fba51bf72 100644 --- a/libsrc/atmos/cpeekchar.s +++ b/libsrc/atmos/cpeekchar.s @@ -1,5 +1,5 @@ - .include "atmos.inc" + .include "atmos.inc" .export _cpeekc @@ -28,4 +28,3 @@ ScrTabHi: .repeat 28, Line .byte >(SCREEN + Line * 40) .endrep - diff --git a/libsrc/nes/cpeekchar.s b/libsrc/nes/cpeekchar.s index b4e3c34fd..55230edbc 100644 --- a/libsrc/nes/cpeekchar.s +++ b/libsrc/nes/cpeekchar.s @@ -3,7 +3,7 @@ .import ppubuf_waitempty - .include "nes.inc" + .include "nes.inc" .segment "CODE" From 6628c4ff4333d82c40fa13db9b6e4356ce405951 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 24 May 2025 18:34:44 +0200 Subject: [PATCH 12/18] fix cpeekc/cpeekcolor/cpeekrevers for atari 800 --- libsrc/atari/cpeekc.s | 35 +++++++++++++++++++++++ libsrc/atari/cpeekchar.s | 35 ----------------------- libsrc/atari/cpeekcolor.s | 8 ++++++ libsrc/atari/cpeekrevers.s | 18 ++++++++++++ targettest/conio.c | 57 ++++++++++++++++++++++++++++++++------ 5 files changed, 109 insertions(+), 44 deletions(-) create mode 100644 libsrc/atari/cpeekc.s delete mode 100644 libsrc/atari/cpeekchar.s create mode 100644 libsrc/atari/cpeekcolor.s create mode 100644 libsrc/atari/cpeekrevers.s diff --git a/libsrc/atari/cpeekc.s b/libsrc/atari/cpeekc.s new file mode 100644 index 000000000..a51e477a6 --- /dev/null +++ b/libsrc/atari/cpeekc.s @@ -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 diff --git a/libsrc/atari/cpeekchar.s b/libsrc/atari/cpeekchar.s deleted file mode 100644 index ff502074d..000000000 --- a/libsrc/atari/cpeekchar.s +++ /dev/null @@ -1,35 +0,0 @@ - - .export _cpeekc - - .import mul40 - .importzp ptr4 - - .include "atari.inc" - - .segment "CODE" - -_cpeekc: - - lda ROWCRS - jsr mul40 ; destroys tmp4 - clc - adc SAVMSC ; add start of screen memory - sta ptr4 - txa - adc SAVMSC+1 - sta ptr4+1 - - ldy COLCRS - lda (ptr4),y ; get char - tax - - ;; convert to asc - - ;; FIXME: ugly hack here to make tetris fx work :=P - lda #' ' - cpx #0 - beq @l - lda #0 -@l: - ldx #0 - rts diff --git a/libsrc/atari/cpeekcolor.s b/libsrc/atari/cpeekcolor.s new file mode 100644 index 000000000..ed275ec95 --- /dev/null +++ b/libsrc/atari/cpeekcolor.s @@ -0,0 +1,8 @@ +; +; 2017-06-03, Greg King +; +; unsigned char cpeekcolor (void); +; + + .import return1 + .export _cpeekcolor := return1 ; always COLOR_WHITE diff --git a/libsrc/atari/cpeekrevers.s b/libsrc/atari/cpeekrevers.s new file mode 100644 index 000000000..15b26fcd4 --- /dev/null +++ b/libsrc/atari/cpeekrevers.s @@ -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 diff --git a/targettest/conio.c b/targettest/conio.c index efe82d7c6..f65f886c5 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -32,6 +32,48 @@ static char grid[5][5] = { {CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER} }; +void colortest(void) +{ + unsigned int i, j; + cputsxy(0, 2, "Colors:" ); + for (i = 0; i < 3; ++i) { + gotoxy(i, 3 + i); + for (j = 0; j < NUMCOLS; ++j) { + (void)textcolor(j); + cputc('X'); + } + } +} + +#define LINE_PEEKTEST 11 + +void peektest(void) +{ + int j; + char buf[NUMCOLS]; + char cbuf[NUMCOLS]; + char rbuf[NUMCOLS]; + + gotoxy(0, LINE_PEEKTEST); + for (j = 0; j < NUMCOLS; ++j) { + (void)textcolor(j); + revers((j >> 1)&1); + cputc('a' + j); + } + for (j = 0; j < NUMCOLS; ++j) { + gotoxy(j, LINE_PEEKTEST); + buf[j] = cpeekc(); + cbuf[j] = cpeekcolor(); + rbuf[j] = cpeekrevers(); + } + gotoxy(0, (LINE_PEEKTEST+1)); + for (j = 0; j < NUMCOLS; ++j) { + (void)textcolor(cbuf[j]); + revers(rbuf[j]); + cputc(buf[j]); + } +} + void main(void) { unsigned int i, j, n; @@ -52,16 +94,13 @@ void main(void) (void)bordercolor(bcol); (void)bgcolor(bgcol); - cputsxy(0, 2, "Colors:" ); - for (i = 0; i < 3; ++i) { - gotoxy(i, 3 + i); - for (j = 0; j < NUMCOLS; ++j) { - (void)textcolor(j); - cputc('X'); - } - } - (void)textcolor(tcol); + colortest(); + peektest(); + (void)textcolor(tcol); + revers(0); + + gotoxy(4,5); cprintf("\n\n\r Screensize: %ux%u", xsize, ysize); chlinexy(0, 6, xsize); From 228316ff58cd9ac7fd70727713f8a486f09b3a4c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 24 May 2025 19:19:49 +0200 Subject: [PATCH 13/18] NES complete now (tested and conio test updated), replaces what is in #532 --- libsrc/nes/color.s | 4 ++-- libsrc/nes/cpeekc.s | 37 +++++++++++++++++++++++++++++++++++++ libsrc/nes/cpeekchar.s | 34 ---------------------------------- libsrc/nes/cpeekcolor.s | 8 ++++++++ libsrc/nes/cpeekrevers.s | 37 +++++++++++++++++++++++++++++++++++++ targettest/conio.c | 1 + 6 files changed, 85 insertions(+), 36 deletions(-) create mode 100644 libsrc/nes/cpeekc.s delete mode 100644 libsrc/nes/cpeekchar.s create mode 100644 libsrc/nes/cpeekcolor.s create mode 100644 libsrc/nes/cpeekrevers.s diff --git a/libsrc/nes/color.s b/libsrc/nes/color.s index e3aef9a28..cd1a950ea 100644 --- a/libsrc/nes/color.s +++ b/libsrc/nes/color.s @@ -9,11 +9,11 @@ .export _textcolor, _bgcolor, _bordercolor - .import return0, ppubuf_put + .import return0, return1, ppubuf_put .include "nes.inc" -_textcolor = return0 +_textcolor = return1 _bordercolor = return0 .proc _bgcolor diff --git a/libsrc/nes/cpeekc.s b/libsrc/nes/cpeekc.s new file mode 100644 index 000000000..315a2df5c --- /dev/null +++ b/libsrc/nes/cpeekc.s @@ -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 diff --git a/libsrc/nes/cpeekchar.s b/libsrc/nes/cpeekchar.s deleted file mode 100644 index 55230edbc..000000000 --- a/libsrc/nes/cpeekchar.s +++ /dev/null @@ -1,34 +0,0 @@ - - .export _cpeekc - - .import ppubuf_waitempty - - .include "nes.inc" - - .segment "CODE" - -_cpeekc: - - ; wait until all console data has been written - jsr ppubuf_waitempty - - ldy SCREEN_PTR+1 - ldx SCREEN_PTR - -; waiting for vblank is incredibly slow :// -vwait: -; lda $2002 ;wait -; bpl vwait - - lda #0 - sty $2006 - stx $2006 - ldy $2007 ; first read is invalid - ldy $2007 ; get data - sta $2006 - sta $2006 - - tya - and #$7f ; ?!?! - rts - diff --git a/libsrc/nes/cpeekcolor.s b/libsrc/nes/cpeekcolor.s new file mode 100644 index 000000000..ed275ec95 --- /dev/null +++ b/libsrc/nes/cpeekcolor.s @@ -0,0 +1,8 @@ +; +; 2017-06-03, Greg King +; +; unsigned char cpeekcolor (void); +; + + .import return1 + .export _cpeekcolor := return1 ; always COLOR_WHITE diff --git a/libsrc/nes/cpeekrevers.s b/libsrc/nes/cpeekrevers.s new file mode 100644 index 000000000..8b1542bc0 --- /dev/null +++ b/libsrc/nes/cpeekrevers.s @@ -0,0 +1,37 @@ +; +; 2016-02-28, Groepaz +; 2017-08-17, Greg King +; +; char cpeekrevers (void); +; + + .export _cpeekrevers + + .import ppubuf_waitempty + .forceimport initconio + + .include "nes.inc" + + +_cpeekrevers: + ; 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 ; get reverse bit + rts diff --git a/targettest/conio.c b/targettest/conio.c index f65f886c5..e054319e5 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -59,6 +59,7 @@ void peektest(void) (void)textcolor(j); revers((j >> 1)&1); cputc('a' + j); + rbuf[j] = (j >> 1)&1; } for (j = 0; j < NUMCOLS; ++j) { gotoxy(j, LINE_PEEKTEST); From 8d42c4a8c5ea357f9c037cb466c764963545b562 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 24 May 2025 20:03:44 +0200 Subject: [PATCH 14/18] fix cpeekc/cpeekcolor/cpeekrevers/cpeeks for atmos, replaces what is in #532 --- include/atmos.h | 11 ++++++++ libsrc/atmos/cpeekc.s | 21 +++++++++++++++ libsrc/atmos/cpeekchar.s | 30 --------------------- libsrc/atmos/cpeekcolor.s | 10 +++++++ libsrc/atmos/cpeekrevers.s | 22 ++++++++++++++++ libsrc/atmos/cpeeks.s | 54 ++++++++++++++++++++++++++++++++++++++ targettest/Makefile | 3 ++- targettest/conio.c | 14 ++++++++++ 8 files changed, 134 insertions(+), 31 deletions(-) create mode 100644 libsrc/atmos/cpeekc.s delete mode 100644 libsrc/atmos/cpeekchar.s create mode 100644 libsrc/atmos/cpeekcolor.s create mode 100644 libsrc/atmos/cpeekrevers.s create mode 100644 libsrc/atmos/cpeeks.s diff --git a/include/atmos.h b/include/atmos.h index 460a0010f..9b1b021c1 100644 --- a/include/atmos.h +++ b/include/atmos.h @@ -169,6 +169,17 @@ 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 + + void waitvsync (void); /* Wait for start of next frame */ diff --git a/libsrc/atmos/cpeekc.s b/libsrc/atmos/cpeekc.s new file mode 100644 index 000000000..f0f5f99b1 --- /dev/null +++ b/libsrc/atmos/cpeekc.s @@ -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 diff --git a/libsrc/atmos/cpeekchar.s b/libsrc/atmos/cpeekchar.s deleted file mode 100644 index fba51bf72..000000000 --- a/libsrc/atmos/cpeekchar.s +++ /dev/null @@ -1,30 +0,0 @@ - - .include "atmos.inc" - - .export _cpeekc - -_cpeekc: - - ldy CURS_Y - ldx ScrTabLo,y - stx @l+1 - ldx ScrTabHi,y - stx @l+2 - ldx CURS_X -@l: - lda $bb80,x -;; inc COORDX_TEXT - ldx #0 - rts - - ; FIXME: is that table available elsewhere? -.rodata -ScrTabLo: - .repeat 28, Line - .byte <(SCREEN + Line * 40) - .endrep - -ScrTabHi: - .repeat 28, Line - .byte >(SCREEN + Line * 40) - .endrep diff --git a/libsrc/atmos/cpeekcolor.s b/libsrc/atmos/cpeekcolor.s new file mode 100644 index 000000000..307c04e96 --- /dev/null +++ b/libsrc/atmos/cpeekcolor.s @@ -0,0 +1,10 @@ +; +; 2017-06-03, Greg King +; +; unsigned char cpeekcolor (void); +; +; Atmos version +; + + .import return1 + .export _cpeekcolor := return1 ; always COLOR_WHITE diff --git a/libsrc/atmos/cpeekrevers.s b/libsrc/atmos/cpeekrevers.s new file mode 100644 index 000000000..53f907511 --- /dev/null +++ b/libsrc/atmos/cpeekrevers.s @@ -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 diff --git a/libsrc/atmos/cpeeks.s b/libsrc/atmos/cpeeks.s new file mode 100644 index 000000000..e54563e7d --- /dev/null +++ b/libsrc/atmos/cpeeks.s @@ -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 diff --git a/targettest/Makefile b/targettest/Makefile index 4d989d0df..35b767727 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -540,12 +540,13 @@ EXELIST_sym1 = \ strnlen \ strqtok-test -# omitted: clock-test cpeek-test conio deb dir-test em-test exec-test1 exec-test2 +# omitted: clock-test cpeek-test deb dir-test em-test exec-test1 exec-test2 # fileio-test ft mouse-test posixio-test rename-test seek ser-test EXELIST_atmos = \ minimal \ arg-test \ clock \ + conio \ cprintf \ cursor \ div-test \ diff --git a/targettest/conio.c b/targettest/conio.c index e054319e5..56fc5dcda 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -24,6 +24,12 @@ #define NUMCOLS 16 #endif +#if defined(__ATMOS__) +// FIXME: those should be defined elsewhere? +#define CH_HLINE '-' +#define CH_VLINE '!' +#endif + static char grid[5][5] = { {CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER}, {CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, @@ -73,6 +79,14 @@ void peektest(void) revers(rbuf[j]); cputc(buf[j]); } + gotoxy(0, LINE_PEEKTEST); + cpeeks(buf, NUMCOLS); + (void)textcolor(1); + revers(0); + gotoxy(20, LINE_PEEKTEST); + for (j = 0; j < NUMCOLS; ++j) { + cputc(buf[j]); + } } void main(void) From 5c72deb0b98ad6e71d64f446a93d3700117bb7d9 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 25 May 2025 01:38:32 +0200 Subject: [PATCH 15/18] prepare osic1p cpeekc/cpeekcolor/cpeekrevers, replaces #532 --- libsrc/osic1p/cpeekc.s | 17 +++++++++++++++++ libsrc/osic1p/cpeekcolor.s | 8 ++++++++ libsrc/osic1p/cpeekrevers.s | 9 +++++++++ targettest/Makefile | 1 + targettest/conio.c | 15 ++++++++++++--- 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 libsrc/osic1p/cpeekc.s create mode 100644 libsrc/osic1p/cpeekcolor.s create mode 100644 libsrc/osic1p/cpeekrevers.s diff --git a/libsrc/osic1p/cpeekc.s b/libsrc/osic1p/cpeekc.s new file mode 100644 index 000000000..55a170501 --- /dev/null +++ b/libsrc/osic1p/cpeekc.s @@ -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 diff --git a/libsrc/osic1p/cpeekcolor.s b/libsrc/osic1p/cpeekcolor.s new file mode 100644 index 000000000..ed275ec95 --- /dev/null +++ b/libsrc/osic1p/cpeekcolor.s @@ -0,0 +1,8 @@ +; +; 2017-06-03, Greg King +; +; unsigned char cpeekcolor (void); +; + + .import return1 + .export _cpeekcolor := return1 ; always COLOR_WHITE diff --git a/libsrc/osic1p/cpeekrevers.s b/libsrc/osic1p/cpeekrevers.s new file mode 100644 index 000000000..ab7c68b35 --- /dev/null +++ b/libsrc/osic1p/cpeekrevers.s @@ -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 diff --git a/targettest/Makefile b/targettest/Makefile index 35b767727..f78e22461 100644 --- a/targettest/Makefile +++ b/targettest/Makefile @@ -624,6 +624,7 @@ EXELIST_pce = \ # stroserror-test strqtok-test uname-test EXELIST_osic1p = \ minimal \ + conio \ cursor \ mul-test diff --git a/targettest/conio.c b/targettest/conio.c index 56fc5dcda..8ebb15bd5 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -15,12 +15,16 @@ #include #include -#if defined(__GAMATE__) +#if defined(__GAMATE__) || defined(__OSIC1P__) /* there is not enough screen space to show all 256 characters at the bottom */ #define NUMCHARS 128 -#define NUMCOLS 4 #else #define NUMCHARS 256 +#endif + +#if defined(__GAMATE__) +#define NUMCOLS 4 +#else #define NUMCOLS 16 #endif @@ -79,6 +83,7 @@ void peektest(void) revers(rbuf[j]); cputc(buf[j]); } +#if !defined (__OSIC1P__) gotoxy(0, LINE_PEEKTEST); cpeeks(buf, NUMCOLS); (void)textcolor(1); @@ -87,6 +92,7 @@ void peektest(void) for (j = 0; j < NUMCOLS; ++j) { cputc(buf[j]); } +#endif } void main(void) @@ -134,7 +140,8 @@ void main(void) } } - gotoxy(0, ysize - 2 - ((NUMCHARS + xsize) / xsize)); + gotoxy(0, ysize - 3 - ((NUMCHARS + xsize) / xsize)); + // one line with 0123..pattern revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); @@ -147,9 +154,11 @@ void main(void) cputc(' '); } } + // fill last line of the block with '#' while(wherex() > 0) { cputc('#'); } + // one more line with 0123..pattern revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); From e9a15af29b406ec9e8ea64fd58997c03f6eb6463 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 25 May 2025 02:52:03 +0200 Subject: [PATCH 16/18] cleanup/fix pce cpeekc/cpeekcolor/cpeekrevers/cpeeks, replaces #532 --- libsrc/pce/cpeekc.s | 6 +++--- libsrc/pce/cpeekcolor.s | 6 +++--- libsrc/pce/cpeekrevers.s | 15 ++++++++------- libsrc/pce/cpeeks.s | 28 +++++++++++----------------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/libsrc/pce/cpeekc.s b/libsrc/pce/cpeekc.s index e144f94ac..326fe5203 100644 --- a/libsrc/pce/cpeekc.s +++ b/libsrc/pce/cpeekc.s @@ -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 diff --git a/libsrc/pce/cpeekcolor.s b/libsrc/pce/cpeekcolor.s index 8b96d29d4..ecee91ed5 100644 --- a/libsrc/pce/cpeekcolor.s +++ b/libsrc/pce/cpeekcolor.s @@ -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 diff --git a/libsrc/pce/cpeekrevers.s b/libsrc/pce/cpeekrevers.s index 3f208fd10..8fa173202 100644 --- a/libsrc/pce/cpeekrevers.s +++ b/libsrc/pce/cpeekrevers.s @@ -14,13 +14,14 @@ _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 (bit 7 is revers bit) + and #$80 ; get reverse bit + asl a ; reverse bit to carry, A=0 + tax ; ldx #>$0000 + rol a ; reverse bit from carry rts diff --git a/libsrc/pce/cpeeks.s b/libsrc/pce/cpeeks.s index fe5e28687..322b9ba30 100644 --- a/libsrc/pce/cpeeks.s +++ b/libsrc/pce/cpeeks.s @@ -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 From c996157f0ebd5b8ccf99a66049d2bf21b1ad35cb Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 25 May 2025 02:53:34 +0200 Subject: [PATCH 17/18] update conio test to reflect the state of cpeek implementation(s) --- targettest/conio.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/targettest/conio.c b/targettest/conio.c index 8ebb15bd5..db7752857 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -42,12 +42,15 @@ static char grid[5][5] = { {CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER} }; +#define LINE_COLORTEST 3 +#define LINE_PEEKTEST 11 + void colortest(void) { unsigned int i, j; cputsxy(0, 2, "Colors:" ); for (i = 0; i < 3; ++i) { - gotoxy(i, 3 + i); + gotoxy(i, LINE_COLORTEST + i); for (j = 0; j < NUMCOLS; ++j) { (void)textcolor(j); cputc('X'); @@ -55,8 +58,6 @@ void colortest(void) } } -#define LINE_PEEKTEST 11 - void peektest(void) { int j; @@ -69,13 +70,24 @@ void peektest(void) (void)textcolor(j); revers((j >> 1)&1); cputc('a' + j); - rbuf[j] = (j >> 1)&1; + buf[j] ='#'; + cbuf[j] = 1; + rbuf[j] = 0; } for (j = 0; j < NUMCOLS; ++j) { gotoxy(j, LINE_PEEKTEST); +// TODO: cpeekc() implementation missing for those: +#if !defined(__TELESTRAT__) buf[j] = cpeekc(); +#endif +// TODO: cpeekcolor() implementation missing for those: +#if !defined(__TELESTRAT__) cbuf[j] = cpeekcolor(); +#endif +// TODO: cpeekrevers() implementation missing for those: +#if !defined(__TELESTRAT__) rbuf[j] = cpeekrevers(); +#endif } gotoxy(0, (LINE_PEEKTEST+1)); for (j = 0; j < NUMCOLS; ++j) { @@ -83,7 +95,14 @@ void peektest(void) revers(rbuf[j]); cputc(buf[j]); } -#if !defined (__OSIC1P__) +// TODO: cpeeks() implementation missing for those: +#if !defined(__APPLE2__) && \ + !defined(__APPLE2ENH__) && \ + !defined(__ATARI__) && \ + !defined(__CX16__) && \ + !defined(__NES__) && \ + !defined(__TELESTRAT__) && \ + !defined(__OSIC1P__) gotoxy(0, LINE_PEEKTEST); cpeeks(buf, NUMCOLS); (void)textcolor(1); From bd63c6aa4b424bee3113772eefb210a7e48535c2 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 25 May 2025 03:23:54 +0200 Subject: [PATCH 18/18] move char block printing into function --- targettest/conio.c | 54 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/targettest/conio.c b/targettest/conio.c index db7752857..e270d3dab 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -114,6 +114,35 @@ void peektest(void) #endif } +void allchars(int xsize, int ysize) +{ + int i; + gotoxy(0, ysize - 2 - ((NUMCHARS + (xsize-1)) / xsize)); + // one line with 0123..pattern + revers(1); + for (i = 0; i < xsize; ++i) { + cputc('0' + i % 10); + } + revers(0); + for (i = 0; i < NUMCHARS; ++i) { + if ((i != '\n') && (i != '\r')) { + cputc(i); + } else { + cputc(' '); + } + } + // fill last line of the block with '#' + while(wherex() > 0) { + cputc('#'); + } + // one more line with 0123..pattern + revers(1); + for (i = 0; i < xsize; ++i) { + cputc('0' + i % 10); + } + revers(0); +} + void main(void) { unsigned int i, j, n; @@ -159,30 +188,7 @@ void main(void) } } - gotoxy(0, ysize - 3 - ((NUMCHARS + xsize) / xsize)); - // one line with 0123..pattern - revers(1); - for (i = 0; i < xsize; ++i) { - cputc('0' + i % 10); - } - revers(0); - for (i = 0; i < NUMCHARS; ++i) { - if ((i != '\n') && (i != '\r')) { - cputc(i); - } else { - cputc(' '); - } - } - // fill last line of the block with '#' - while(wherex() > 0) { - cputc('#'); - } - // one more line with 0123..pattern - revers(1); - for (i = 0; i < xsize; ++i) { - cputc('0' + i % 10); - } - revers(0); + allchars(xsize, ysize); cursor(1); for (;;) {