From dd2972d6999aa93891d9e13cbcbe0673a0e49ab5 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Feb 2016 22:23:40 +0100 Subject: [PATCH] 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 +