From f0e16514e02addee05371f38e0ef66cf9b119477 Mon Sep 17 00:00:00 2001 From: Karri Kaksonen Date: Sat, 16 Apr 2022 19:15:19 +0300 Subject: [PATCH] Split files --- libsrc/atari7800/cputc.s | 186 +++++++++++++++++------------------ libsrc/atari7800/setcursor.s | 181 +++++++++++++++------------------- libsrc/atari7800/wherex.s | 11 ++- 3 files changed, 181 insertions(+), 197 deletions(-) diff --git a/libsrc/atari7800/cputc.s b/libsrc/atari7800/cputc.s index 607940332..7266190ee 100644 --- a/libsrc/atari7800/cputc.s +++ b/libsrc/atari7800/cputc.s @@ -6,31 +6,31 @@ ; .export _cputc - .export _textcolor - .import _gotoxy, _gotox, _gotoy, pusha0 - .import pushax - .import _screen - .import CURS_X, CURS_Y + .export _textcolor + .import _gotoxy, gotox, gotoy, pusha0 + .import pushax + .import _screen + .import CURS_X, CURS_Y .include "atari7800.inc" .include "extzp.inc" - .data + .data ;----------------------------------------------------------------------------- ; Holder of the text colour offset ; 0 = red, 42 = green, 84 = white ; txtcolor: - .byte 0 + .byte 0 - .code + .code ;--------------------------------------------------------------------------- ; 8x16 routine umula0: ldy #8 ; Number of bits - lda #0 + lda #0 lsr ptr7800 ; Get first bit into carry @L0: bcc @L1 @@ -38,7 +38,7 @@ umula0: adc ptrtmp tax lda ptrtmp+1 ; hi byte of left op - clc + clc adc ptr7800+1 sta ptr7800+1 txa @@ -64,25 +64,25 @@ umula0: ; .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 + 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 ;----------------------------------------------------------------------------- @@ -92,83 +92,83 @@ umula0: ; .proc _cputc - cmp #$0A ; LF + cmp #$0A ; LF bne @L4 -@L1: lda CURS_Y ; newline - cmp #(screenrows-1) +@L1: lda CURS_Y ; newline + cmp #(screenrows-1) bne @L2 - lda #0 - beq @L3 -@L2: clc - adc #1 -@L3: jsr _gotoy - lda #0 - jmp _gotox + lda #0 + beq @L3 +@L2: clc + adc #1 +@L3: jsr gotoy + lda #0 + jmp gotox @L4: - cmp #$20 ; ' ' - bne @L5 - lda #$00 - jmp @L10 + cmp #$20 ; ' ' + bne @L5 + lda #$00 + jmp @L10 @L5: - cmp #$3F ; '?' - bne @L6 - lda #$02 - jmp @L9 + cmp #$3F ; '?' + bne @L6 + lda #$02 + jmp @L9 @L6: - cmp #$7C ; '|' - bne @L7 - lda #$06 - jmp @L9 + cmp #$7C ; '|' + bne @L7 + lda #$06 + jmp @L9 @L7: - cmp #$41 ; >= 'A' - bcc @L8 - and #$5F ; make upper case - sec - sbc #($41 - 17) - jmp @L9 + cmp #$41 ; >= 'A' + bcc @L8 + and #$5F ; make upper case + sec + sbc #($41 - 17) + jmp @L9 @L8: - sec ; >= '*' - sbc #($2A - 1) + sec ; >= '*' + sbc #($2A - 1) @L9: - clc - adc txtcolor + clc + adc txtcolor @L10: - asl - pha + asl + pha - lda #0 - sta ptr7800+1 - sta ptrtmp+1 - lda CURS_Y ; Find position on screen buffer - sta ptr7800 - lda #charsperline - sta ptrtmp - jsr umula0 - clc - adc CURS_X - bcc @L11 - inx -@L11: clc - adc #<(_screen) - sta ptr7800 - bcc @L12 - inx -@L12: txa - clc - adc #>(_screen) - sta ptr7800+1 + lda #0 + sta ptr7800+1 + sta ptrtmp+1 + lda CURS_Y ; Find position on screen buffer + sta ptr7800 + lda #charsperline + sta ptrtmp + jsr umula0 + clc + adc CURS_X + bcc @L11 + inx +@L11: clc + adc #<(_screen) + sta ptr7800 + bcc @L12 + inx +@L12: txa + clc + adc #>(_screen) + sta ptr7800+1 - pla ; Print character on screen - ldy #0 - sta (ptr7800),y + pla ; Print character on screen + ldy #0 + sta (ptr7800),y - lda CURS_X ; Increment cursor - cmp #(charsperline-1) - beq @L1 - clc - adc #1 - jmp _gotox + lda CURS_X ; Increment cursor + cmp #(charsperline-1) + beq @L1 + clc + adc #1 + jmp gotox .endproc diff --git a/libsrc/atari7800/setcursor.s b/libsrc/atari7800/setcursor.s index 34c7562ab..30151820a 100644 --- a/libsrc/atari7800/setcursor.s +++ b/libsrc/atari7800/setcursor.s @@ -23,40 +23,40 @@ ; definitely not allow direct access to the variables. ; - .export gotoxy, _gotoxy, _gotox, _gotoy, _wherex, _wherey - .export CURS_X, CURS_Y + .export gotoxy, _gotoxy, gotox, gotoy + .export CURS_X, CURS_Y .constructor init_cursor .interruptor blink_cursor - .importzp sp - .import _zones - .import cursor - .import pusha, incsp1, pusha0, pushax, popa + .importzp sp + .import _zones + .import cursor + .import pusha, incsp1, pusha0, pushax, popa .include "atari7800.inc" .include "extzp.inc" .macpack generic - .data + .data ;----------------------------------------------------------------------------- ; The variables used by cursor functions ; CURS_X: - .byte 0 + .byte 0 CURS_Y: - .byte 0 + .byte 0 blink_time: - .byte 140 + .byte 140 - .code + .code ;--------------------------------------------------------------------------- ; 8x16 routine umula0: ldy #8 ; Number of bits - lda #0 + lda #0 lsr ptr7800 ; Get first bit into carry @L0: bcc @L1 @@ -86,24 +86,24 @@ umula0: ; A = CURS_Y .proc calccursorzone - sta ptr7800 - lda #11 - sta ptrtmp - lda #0 - sta ptr7800+1 - sta ptrtmp+1 - jsr umula0 - clc - adc #5 - bcc @L1 - inx -@L1: clc - adc #<_zones - sta cursorzone ; calculate new cursorzone - txa - adc #>_zones - sta cursorzone+1 - rts + sta ptr7800 + lda #11 + sta ptrtmp + lda #0 + sta ptr7800+1 + sta ptrtmp+1 + jsr umula0 + clc + adc #5 + bcc @L1 + inx +@L1: clc + adc #<_zones + sta cursorzone ; calculate new cursorzone + txa + adc #>_zones + sta cursorzone+1 + rts .endproc @@ -122,23 +122,23 @@ umula0: ; Enable cursor ; if showcursor cursorzone[1] = 30 ; - .proc _gotoy + .proc gotoy - pha - lda CURS_Y - jsr calccursorzone - ldy #1 - lda #0 - sta (cursorzone),y ; disable cursor - pla - sta CURS_Y - jsr calccursorzone - lda cursor - beq @L1 - lda #30 ; enable cursor -@L1: ldy #1 - sta (cursorzone),y - rts + pha + lda CURS_Y + jsr calccursorzone + ldy #1 + lda #0 + sta (cursorzone),y ; disable cursor + pla + sta CURS_Y + jsr calccursorzone + lda cursor + beq @L1 + lda #30 ; enable cursor +@L1: ldy #1 + sta (cursorzone),y + rts .endproc @@ -147,70 +147,53 @@ umula0: ; You also need to set the hpos offset to the correct value on this line ; cursorzone[3] = 8 * CURS_X ; - .proc _gotox + .proc gotox - sta CURS_X - ldy #3 - clc - rol - rol - rol - sta (cursorzone),y - rts + sta CURS_X + ldy #3 + clc + rol + rol + rol + sta (cursorzone),y + rts .endproc ;----------------------------------------------------------------------------- ; Set cursor to desired position (X,Y) ; - .proc _gotoxy + .proc _gotoxy - jsr _gotoy - jsr popa - jsr _gotox - rts - .endproc + jsr gotoy + jsr popa + jsr gotox + rts + .endproc - .proc gotoxy - jsr popa - jmp _gotoxy - .endproc -;----------------------------------------------------------------------------- -; Get cursor X position -; - .proc _wherex - - lda CURS_X - rts - .endproc - -;----------------------------------------------------------------------------- -; Get cursor Y position -; - .proc _wherey - - lda CURS_Y - rts - .endproc + .proc gotoxy + jsr popa + jmp _gotoxy + .endproc ;----------------------------------------------------------------------------- ; Initialize cursorzone at startup ; Offset to cursor zone 5. ; - .proc blink_cursor - inc blink_time - bne @L3 - lda #140 - sta blink_time - ldy #0 - lda (cursorzone),y - bne @L1 - lda #254 - bne @L2 -@L1: lda #0 -@L2: sta (cursorzone),y -@L3: rts - .endproc + .proc blink_cursor + inc blink_time + bne @L3 + lda #140 + sta blink_time + ldy #0 + lda (cursorzone),y + bne @L1 + lda #254 + bne @L2 +@L1: lda #0 +@L2: sta (cursorzone),y +@L3: rts + .endproc ;----------------------------------------------------------------------------- ; Initialize cursorzone at startup @@ -218,9 +201,9 @@ umula0: ; .segment "ONCE" init_cursor: - lda #0 - jsr calccursorzone - rts + lda #0 + jsr calccursorzone + rts ;----------------------------------------------------------------------------- ; force the init constructor to be imported diff --git a/libsrc/atari7800/wherex.s b/libsrc/atari7800/wherex.s index 3215302ac..f90105c46 100644 --- a/libsrc/atari7800/wherex.s +++ b/libsrc/atari7800/wherex.s @@ -5,14 +5,15 @@ ; .export _wherex - .import CURS_X + .import CURS_X ;----------------------------------------------------------------------------- ; Get cursor X position ; - .proc _wherex + .proc _wherex - lda CURS_X - rts - .endproc + ldx #0 + lda CURS_X + rts + .endproc