]> git.sur5r.net Git - cc65/commitdiff
Enhancements for cursor calculation
authorStephan Mühlstrasser <stephan.muehlstrasser@web.de>
Sun, 23 Nov 2014 14:32:48 +0000 (15:32 +0100)
committerStephan Mühlstrasser <stephan.muehlstrasser@web.de>
Sun, 23 Nov 2014 14:32:48 +0000 (15:32 +0100)
Fix handling of newlines.
Wrap around to top of screen when newline occurs
in last line.
Initialize screen width in crt0.s.

libsrc/c1p/cputc.s
libsrc/c1p/crt0.s

index 35326d04b866d213f1846d74647c63efcc3e4fee..ca9152aa7c8492ea184bb48b3be8274cdc5e96bb 100644 (file)
@@ -44,14 +44,12 @@ L3:     iny
         rts
 
 newline:
-        lda     SCR_LINELEN     ; xsize-1
-        sec                     ; Account for -1 above
-        adc     SCREEN_PTR
-        sta     SCREEN_PTR
-        bcc     L4
-        inc     SCREEN_PTR+1
-L4:     inc     CURS_Y
-        rts
+        inc     CURS_Y
+        lda     CURS_Y
+        cmp     #24             ; screen height 25 lines hardcoded
+        bne     plot
+        lda     #0              ; wrap around to line 0
+        sta     CURS_Y
 
 plot:   ldy     CURS_Y
         lda     ScrLo,y
index 97d572608d29bf80805b9c8bcf9dac186cd308a7..8f25c2a8d605c8c817335c0fc0d4d50f99a0ebee 100644 (file)
@@ -13,6 +13,7 @@
 .import    zerobss, initlib, donelib
 
 .include  "zeropage.inc"
+.include  "extzp.inc"
 
 ; ---------------------------------------------------------------------------
 ; Place the startup code in a special segment
@@ -26,6 +27,13 @@ _init:    LDX     #$FF                 ; Initialize stack pointer to $01FF
           TXS
           CLD                          ; Clear decimal mode
 
+; ---------------------------------------------------------------------------
+; Initialize screen width
+; TODO: Can initialization be done in a more idiomatic way?
+; TODO: Create function for changing screen width
+          LDA     #$18
+          STA     SCR_LINELEN
+
 ; ---------------------------------------------------------------------------
 ; Set cc65 argument stack pointer