io.inc (2647B)
1 ;;; -*- asm -*- 2 3 ;;; Copyright 2021 Gerd Beuster (gerd@frombelow.net). This is free 4 ;;; software under the GNU GPL v3 license or any later version. See 5 ;;; COPYING in the root directory for details. 6 7 .namespace io 8 9 ;;; SETUP 10 ;;; Setup serial connection: Initialize ACIA and clear screen. 11 ;;; Input: 12 ;;; - 13 ;;; Output: 14 ;;; - 15 ;;; Changes: 16 ;;; a, x, y, acia registers, io, pus_str 17 18 SETUP .macro 19 jsr io.init_acia 20 ;; Terminal program on PC needs some time to start up 21 ldy #$ff 22 ldx #$ff 23 io_setup_delay_delay: 24 dex 25 bne io_setup_delay_delay 26 dey 27 bne io_setup_delay_delay 28 jsr term.clear_screen 29 #term.SET_CURSOR #$01, #$01 30 .endm 31 32 ;;; PRINT(addr) 33 ;;; Send zero terminated string at addr via acia. 34 ;;; Input: 35 ;;; addr: 36 ;;; Address of zero terminated string (<= 256 characters) 37 ;;; Output: 38 ;;; - 39 ;;; Changes: 40 ;;; a, x, y, puts_str, put_str+1 41 42 PRINT .macro 43 lda #<\1 44 sta io.puts_str 45 lda #>\1 46 sta io.puts_str+1 47 jsr io.puts 48 .endm 49 50 ;;; PRINTS(string) (<= 255 characters) 51 ;;; Send string via acia 52 ;;; Input: 53 ;;; string: 54 ;;; String to be send. 55 ;;; Output: 56 ;;; - 57 ;;; Changes: 58 ;;; a, x, y, puts_str, put_str+1 59 60 PRINTS .macro 61 #io.PRINT saddr 62 jmp cont_PRINTS 63 saddr: 64 .null \1 65 cont_PRINTS: 66 .endm 67 68 ;;; PRINTSNL(string) (<= 253 characters) 69 ;;; Send string and newline via acia 70 ;;; Input: 71 ;;; string: 72 ;;; String to be send. 73 ;;; Output: 74 ;;; - 75 ;;; Changes: 76 ;;; a, x, y, puts_str, put_str+1 77 78 PRINTSNL .macro 79 #io.PRINT saddr 80 jmp cont_PRINTSNL 81 saddr: 82 .null \1, $0d, $0a 83 cont_PRINTSNL: 84 .endm 85 86 ;;; INPUTS(addr, len) 87 ;;; Read up to len characters from acai and store them at addr 88 ;;; This is a wrapper for gets 89 ;;; Input: 90 ;;; addr: 91 ;;; Target address for zero-terminated string 92 ;;; len: 93 ;;; Maximal length of string to be read (not terminating zero!) 94 ;;; +-------------------------------------------------------+ 95 ;;; |IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! | 96 ;;; +-------------------------------------------------------+ 97 ;;; Note that a terminating zero is added to the string. 98 ;;; Therefore len+1 bytes may be written! 99 ;;; Output: 100 ;;; - 101 ;;; Changes: 102 ;;; a, y, ACAI registers 103 104 INPUTS .macro 105 lda #<\1 106 sta io.gets_str 107 lda #>\1 108 sta io.gets_str+1 109 lda \2 110 sta io.gets_len 111 jsr io.gets 112 .endm 113 114 ;;; PRINTNL 115 ;;; Send newline via acia 116 ;;; Input: 117 ;;; - 118 ;;; Output: 119 ;;; - 120 ;;; Changes: 121 ;;; a, x, acai registers 122 123 PRINTNL .macro 124 lda #$0d 125 jsr io.putc 126 lda #$0a 127 jsr io.putc 128 .endm 129 130 .endn