]> git.sur5r.net Git - cc65/commitdiff
kbhit() function and scrolling.
authorStephan Mühlstrasser <stephan.muehlstrasser@web.de>
Thu, 19 Feb 2015 21:19:21 +0000 (22:19 +0100)
committerStephan Mühlstrasser <stephan.muehlstrasser@web.de>
Thu, 19 Feb 2015 21:19:21 +0000 (22:19 +0100)
Patch provided by Jeff Tranter.

libsrc/osic1p/cputc.s
libsrc/osic1p/kbhit.s [new file with mode: 0644]
libsrc/osic1p/osic1p.inc

index f6f285301b05b192fb3dd70a4f02eec154b0763c..47969df152d66c12cb364259ca8418ef1621f94a 100644 (file)
@@ -48,8 +48,16 @@ newline:
         lda     CURS_Y
         cmp     #SCR_HEIGHT     ; screen height
         bne     plot
-        lda     #0              ; wrap around to line 0
-        sta     CURS_Y
+        dec     CURS_Y          ; bottom of screen reached, scroll
+        ldx     #0
+scroll: lda     SCRNBASE+$00A5,x
+        sta     SCRNBASE+$0085,x
+        lda     SCRNBASE+$01A5,x
+        sta     SCRNBASE+$0185,x
+        lda     SCRNBASE+$02A5,x
+        sta     SCRNBASE+$0285,x
+        inx
+        bne scroll
 
 plot:   ldy     CURS_Y
         lda     ScrLo,y
diff --git a/libsrc/osic1p/kbhit.s b/libsrc/osic1p/kbhit.s
new file mode 100644 (file)
index 0000000..c064fec
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; unsigned char kbhit (void);
+;
+
+        .export _kbhit
+        .include "osic1p.inc"
+
+_kbhit:
+        lda     #%11111110      ; Select first keyboard row
+scan:
+        sta     KBD             ; Select keyboard row
+        tax                     ; Save A
+        lda     KBD             ; Read keyboard columns
+        ora     #$01            ; Mask out lsb (Shift Lock), since we ignore it
+        cmp     #$FF            ; No keys pressed?
+        bne     keypressed
+        txa                     ; Restore A
+        sec                     ; Want to shift in ones
+        rol     a               ; Rotate row select to next bit position
+        cmp     #$FF            ; Done?
+        bne     scan            ; If not, continue
+        ldx     #$00            ; High byte of return is always zero
+        lda     #$00            ; Return false
+        rts
+keypressed:
+        ldx     #$00            ; High byte of return is always zero
+        lda     #$01            ; Return true
+        rts
index 9a0c346b6756c013196074d652069f68d89d53a6..e95db637eee34b133f7293a0ccfed87740a1431f 100644 (file)
@@ -2,6 +2,7 @@
 SCRNBASE        := $D000        ; Base of video RAM\r
 INPUTC          := $FD00        ; Input character from keyboard\r
 RESET           := $FF00        ; Reset address, show boot prompt\r
+KBD             := $DF00        ; Polled keyboard register\r
 \r
 ; Other definitions\r
 VIDEORAMSIZE    = $0400         ; Size of C1P video RAM (1 kB)\r