From 02fbcad6973e5c8b5f69595110f072cdc53118a6 Mon Sep 17 00:00:00 2001 From: Karri Kaksonen Date: Sat, 16 Apr 2022 21:13:51 +0300 Subject: [PATCH] Split files --- libsrc/atari7800/clrscr.s | 48 ++++++++++++++--------------- libsrc/atari7800/cputc.s | 44 ++------------------------- libsrc/atari7800/setcursor.s | 27 +---------------- libsrc/atari7800/textcolor.s | 58 ++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 92 deletions(-) create mode 100644 libsrc/atari7800/textcolor.s diff --git a/libsrc/atari7800/clrscr.s b/libsrc/atari7800/clrscr.s index 36af7cce2..b5b3a1ebf 100644 --- a/libsrc/atari7800/clrscr.s +++ b/libsrc/atari7800/clrscr.s @@ -3,34 +3,34 @@ .export _clrscr - .import _screen - .import pusha0,pushax - .include "extzp.inc" + .import _screen + .import pusha0,pushax + .include "extzp.inc" - .code + .code - .proc _clrscr + .proc _clrscr - lda #<(_screen) - ldx #>(_screen) - sta ptr7800 - stx ptr7800+1 - ldx #screenrows -@L1: ldy #charsperline - lda #0 -@L2: sta (ptr7800),y - dey - bne @L2 - lda ptr7800 - clc - adc #charsperline - bcc @L3 - inc ptr7800+1 -@L3: dex - bne @L1 - rts + lda #<(_screen) + ldx #>(_screen) + sta ptr7800 + stx ptr7800+1 + ldx #screenrows +@L1: ldy #charsperline + lda #0 +@L2: sta (ptr7800),y + dey + bne @L2 + lda ptr7800 + clc + adc #charsperline + bcc @L3 + inc ptr7800+1 +@L3: dex + bne @L1 + rts - .endproc + .endproc ;------------------------------------------------------------------------------- ; force the init constructor to be imported diff --git a/libsrc/atari7800/cputc.s b/libsrc/atari7800/cputc.s index 7266190ee..4d2b8dbf6 100644 --- a/libsrc/atari7800/cputc.s +++ b/libsrc/atari7800/cputc.s @@ -6,23 +6,16 @@ ; .export _cputc - .export _textcolor + .export umula0 .import _gotoxy, gotox, gotoy, pusha0 .import pushax .import _screen .import CURS_X, CURS_Y + .import txtcolor .include "atari7800.inc" .include "extzp.inc" - .data -;----------------------------------------------------------------------------- -; Holder of the text colour offset -; 0 = red, 42 = green, 84 = white -; -txtcolor: - .byte 0 - .code ;--------------------------------------------------------------------------- @@ -52,39 +45,6 @@ umula0: lda ptr7800 ; Load the result rts -;----------------------------------------------------------------------------- -; Change the text colour -; -; Logical colour names are -; 0 = red -; 1 = green -; 2 = white -; -; The routine will also return the previous textcolor -; - .proc _textcolor - - beq @L2 - sec - sbc #1 - beq @L1 - lda #84 - jmp @L2 -@L1: lda #42 -@L2: ldy txtcolor - sta txtcolor ; Store new textcolor - tya - bne @L3 - rts ; Old colour was 0 -@L3: sec - sbc #42 - bne @L4 - lda #1 - rts ; Old colour was 1 -@L4: lda #2 - rts ; Old colour was 2 - .endproc - ;----------------------------------------------------------------------------- ; Put a character on screen ; diff --git a/libsrc/atari7800/setcursor.s b/libsrc/atari7800/setcursor.s index 30151820a..caaa9c1d5 100644 --- a/libsrc/atari7800/setcursor.s +++ b/libsrc/atari7800/setcursor.s @@ -32,6 +32,7 @@ .import _zones .import cursor .import pusha, incsp1, pusha0, pushax, popa + .import umula0 .include "atari7800.inc" .include "extzp.inc" @@ -51,32 +52,6 @@ blink_time: .code -;--------------------------------------------------------------------------- -; 8x16 routine - -umula0: - ldy #8 ; Number of bits - lda #0 - lsr ptr7800 ; Get first bit into carry -@L0: bcc @L1 - - clc - adc ptrtmp - tax - lda ptrtmp+1 ; hi byte of left op - adc ptr7800+1 - sta ptr7800+1 - txa - -@L1: ror ptr7800+1 - ror a - ror ptr7800 - dey - bne @L0 - tax - lda ptr7800 ; Load the result - rts - ;----------------------------------------------------------------------------- ; Calculate cursorzone address ; You also need to set the cursorzone to point to the correct cursor Header diff --git a/libsrc/atari7800/textcolor.s b/libsrc/atari7800/textcolor.s new file mode 100644 index 000000000..6ccbcf491 --- /dev/null +++ b/libsrc/atari7800/textcolor.s @@ -0,0 +1,58 @@ +; +; Karri Kaksonen, 2022-04-16 +; +; + + .export _textcolor + .export txtcolor + + .include "atari7800.inc" + + .data +;----------------------------------------------------------------------------- +; Holder of the text colour offset +; 0 = red, 42 = green, 84 = white +; +txtcolor: + .byte 0 + + .code + +;----------------------------------------------------------------------------- +; Change the text colour +; +; Logical colour names are +; 0 = red +; 1 = green +; 2 = white +; +; The routine will also return the previous textcolor +; + .proc _textcolor + + beq @L2 + sec + sbc #1 + beq @L1 + lda #84 + jmp @L2 +@L1: lda #42 +@L2: ldy txtcolor + sta txtcolor ; Store new textcolor + tya + bne @L3 + rts ; Old colour was 0 +@L3: sec + sbc #42 + bne @L4 + lda #1 + rts ; Old colour was 1 +@L4: lda #2 + rts ; Old colour was 2 + .endproc + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio