]> git.sur5r.net Git - cc65/commitdiff
Make screensize() fetch the values dynamically instead of using variables
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 9 Apr 2003 19:34:57 +0000 (19:34 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 9 Apr 2003 19:34:57 +0000 (19:34 +0000)
that are set on startup. This is needed to support the C128, which can switch
the screen size at runtime.

git-svn-id: svn://svn.cc65.org/cc65/trunk@2042 b7a2c559-68d2-44c3-8de9-860c34a00d81

25 files changed:
libsrc/apple2/_scrsize.s
libsrc/apple2/apple2.inc
libsrc/atari/_scrsize.s
libsrc/c128/_scrsize.s
libsrc/c16/_scrsize.s
libsrc/c16/cputc.s
libsrc/c64/_scrsize.s
libsrc/c64/c64.inc
libsrc/c64/cputc.s
libsrc/cbm510/_scrsize.s
libsrc/cbm510/cbm510.inc
libsrc/cbm510/cputc.s
libsrc/cbm610/_scrsize.s
libsrc/cbm610/cbm610.inc
libsrc/cbm610/cputc.s
libsrc/conio/scrsize.s
libsrc/pet/_scrsize.s
libsrc/pet/clrscr.s
libsrc/pet/cputc.s
libsrc/plus4/_scrsize.s
libsrc/plus4/cputc.s
libsrc/plus4/plus4.inc
libsrc/vic20/_scrsize.s
libsrc/vic20/cputc.s
libsrc/vic20/vic20.inc

index 5578c1be15c7366f522cfd70399eef0814e82646..df849510c998009c7b0f5baa24a03e7c452ae3a1 100644 (file)
@@ -4,12 +4,15 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
 
-.rodata
+        .include        "apple2.inc"
 
-xsize:         .byte   40
-ysize: .byte   24
+.proc   screensize
 
+        ldx     #XSIZE
+        ldy     #YSIZE
+        rts
 
+.endproc
 
index 78f323dd0059b9c713c0b156916916406ca21c40..7002f7aadc26d9aecad93ccf253dedfed0239475 100644 (file)
@@ -20,6 +20,12 @@ MEMSIZE      =       $73             ; Highest free RAM location
 BRKVec  =       $03F0           ; Break vector
 RESTOR =       $03D0           ; Goto Dos
 
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE           = 40
+YSIZE           = 24
+
 ;-----------------------------------------------------------------------------
 ; Hardware
 
index 5578c1be15c7366f522cfd70399eef0814e82646..420505fa53734384a5ecf8ecdbab128642b95923 100644 (file)
@@ -4,12 +4,14 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
 
-.rodata
+.proc   screensize
 
-xsize:         .byte   40
-ysize: .byte   24
+        ldx     #40
+        ldy     #24
+        rts
 
+.endproc
 
 
index dcbc4a2d9b83602fef73a046948114def65d912b..1f38ea65cc9689a98e7e9044b6f26ff18c82b0f9 100644 (file)
@@ -4,26 +4,19 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
-        .import         SCREEN
-       .constructor    initscrsize
+       .export         screensize
 
+        .include        "c128.inc"
 
-.code
-
-initscrsize:
-       jsr     SCREEN
-       inx
-       stx     xsize
-       iny
-       sty     ysize
-       rts
-
-.bss
-
-xsize:         .res    1
-ysize: .res    1
+.proc   screensize
 
+        ldx     #40             ; Assume 40 column mode
+        bit     MODE
+        bpl     C40             ; Jump if 40 column mode
+        ldx     #80
+C40:    ldy     #25
+        rts
 
+.endproc
 
 
index c63df59d234697537f3d9aaf986d49fc9713e639..c0a746198b24f5756d9b9626d1ac10c673eaae6a 100644 (file)
@@ -4,22 +4,9 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
         .import         SCREEN
-       .constructor    initscrsize
 
-
-.code
-
-initscrsize:
-       jsr     SCREEN
-       stx     xsize
-       sty     ysize
-       rts
-
-.bss
-
-xsize:         .res    1
-ysize: .res    1
+screensize      = SCREEN
 
 
index 680dc559398633f3cd0c1f9d4d62b59f90582fa8..26bc2ae5a5a37cf44e67a2fb27951f3ba3675e5c 100644 (file)
@@ -8,7 +8,6 @@
        .export         _cputcxy, _cputc, cputdirect, putchar
        .export         newline, plot
        .import         popa, _gotoxy
-       .import         xsize
         .import         PLOT
 
        .include        "../plus4/plus4.inc"
@@ -50,7 +49,7 @@ cputdirect:
 
 advance:
         iny
-        cpy     xsize
+        cpy     #XSIZE
         bne     L3
         jsr     newline         ; new line
         ldy     #0              ; + cr
@@ -59,13 +58,13 @@ L3:     sty     CURS_X
 
 newline:
        clc
-       lda     xsize
+       lda     #XSIZE
        adc     SCREEN_PTR
        sta     SCREEN_PTR
        bcc     L4
        inc     SCREEN_PTR+1
        clc
-L4:    lda     xsize
+L4:    lda     #XSIZE
        adc     CRAM_PTR
        sta     CRAM_PTR
        bcc     L5
index c63df59d234697537f3d9aaf986d49fc9713e639..c0a746198b24f5756d9b9626d1ac10c673eaae6a 100644 (file)
@@ -4,22 +4,9 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
         .import         SCREEN
-       .constructor    initscrsize
 
-
-.code
-
-initscrsize:
-       jsr     SCREEN
-       stx     xsize
-       sty     ysize
-       rts
-
-.bss
-
-xsize:         .res    1
-ysize: .res    1
+screensize      = SCREEN
 
 
index e93872f938d4b0785046d4cab86cd92c6f737a6c..471551c2629b450b62d1a7ae1009f5dddb74f361 100644 (file)
@@ -11,7 +11,7 @@ ST            = $90           ; IEC status byte
 TIME            = $A0           ; 60 HZ clock
 FNAM_LEN       = $B7           ; Length of filename
 SECADR         = $B9           ; Secondary address
-DEVNUM         = $BA           ; Device number     
+DEVNUM         = $BA           ; Device number
 FNAM            = $BB           ; Pointer to filename
 KEY_COUNT              = $C6           ; Number of keys in input buffer
 RVS             = $C7           ; Reverse flag
@@ -43,6 +43,12 @@ IRQVec               = $0314
 BRKVec         = $0316
 NMIVec         = $0318
 
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE           = 40
+YSIZE           = 25
+
 ; ---------------------------------------------------------------------------
 ; I/O: VIC
 
index 83a0c8b63f78d3b94d5a77c59a105152ac2e155f..cf4275668a7a1d258096f2f1df35311b1c5dce02 100644 (file)
@@ -8,7 +8,6 @@
        .export         _cputcxy, _cputc, cputdirect, putchar
        .export         newline, plot
        .import         popa, _gotoxy
-       .import         xsize
         .import         PLOT
 
        .include        "c64.inc"
@@ -50,7 +49,7 @@ cputdirect:
 
 advance:
        iny
-       cpy     xsize
+       cpy     #XSIZE
        bne     L3
        jsr     newline         ; new line
        ldy     #0              ; + cr
@@ -59,13 +58,13 @@ L3: sty     CURS_X
 
 newline:
        clc
-       lda     xsize
+       lda     #XSIZE
        adc     SCREEN_PTR
        sta     SCREEN_PTR
        bcc     L4
        inc     SCREEN_PTR+1
        clc
-L4:    lda     xsize
+L4:    lda     #XSIZE
        adc     CRAM_PTR
        sta     CRAM_PTR
        bcc     L5
index 5c0fb14e7ed9c1a31aeccfe77b4a4acf7c528865..99a7584553226e65ec753e9dca6d39083d6d312d 100644 (file)
@@ -4,12 +4,16 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
 
-.rodata
+        .include        "cbm510.inc"
 
-xsize:         .byte   40
-ysize: .byte   25
+.proc   screensize
 
+        ldx     #XSIZE
+        ldy     #YSIZE
+        rts
+
+.endproc
 
 
index 75ef374b7657667deb0e7923dca99d3c1413568f..1e66e2c6d7eaaba6de9b2c25b5e99f617cd7b267 100644 (file)
@@ -192,6 +192,12 @@ MoniSegSave             = $03f0
 wstvec              = $03F8
 WstFlag                     = $03FA    ; Warm start flag
 
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE           = 40
+YSIZE           = 25
+
 ;-----------------------------------------------------------------------------
 ; I/O Definitions
 
index e0c0e78374aeea20265d70f52549d2a51915e679..6e321a0172051e5ae7efa6ce9ae756cd2ea6ddd5 100644 (file)
@@ -10,7 +10,6 @@
 
         .import         PLOT
        .import         popa, _gotoxy
-       .import         xsize
 
        .include        "cbm510.inc"
 
@@ -53,7 +52,7 @@ cputdirect:
 
 advance:
        iny
-       cpy     xsize
+       cpy     #XSIZE
        bne     L3
        jsr     newline         ; new line
        ldy     #0              ; + cr
@@ -62,13 +61,13 @@ L3: sty     CURS_X
 
 newline:
        clc
-       lda     xsize
+       lda     #XSIZE
        adc     SCREEN_PTR
        sta     SCREEN_PTR
        bcc     L4
        inc     SCREEN_PTR+1
        clc
-L4:    lda     xsize
+L4:    lda     #XSIZE
        adc     CRAM_PTR
        sta     CRAM_PTR
        bcc     L5
index f7095af750def7e4c0944864aaff5b30387b482c..928972bcc82d85ee6f2a18247fd7b3e5cf139ce0 100644 (file)
@@ -4,12 +4,16 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
 
-.rodata
+        .include        "cbm610.inc"
 
-xsize:         .byte   80
-ysize: .byte   25
+.proc   screensize
 
+        ldx     #XSIZE
+        ldy     #YSIZE
+        rts
+
+.endproc
 
 
index 4f259ed2a5ca2e55e196cb9517ea6402a673b5a1..942c6bf846285c7ad6d2345ab338b89e0f0b9f00 100644 (file)
@@ -187,6 +187,12 @@ wstvec                  = $03F8
 WstFlag                     = $03FA    ; Warm start flag
 
 
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE           = 80
+YSIZE           = 25
+
 ; ---------------------------------------------------------------------------
 ; I/O definitions
 
index 64988e4fef990ecbec65566bc8b2a49c5e18ad7d..ae8bfb16fea608c1acf57d8d43cb9d83d6551b4e 100644 (file)
@@ -12,7 +12,6 @@
         .import         PLOT
        .import         _gotoxy
        .import         popa
-       .import         xsize
 
        .include        "cbm610.inc"
 
@@ -53,7 +52,7 @@ cputdirect:
 
 advance:
         iny
-        cpy     xsize
+        cpy     #XSIZE
         bne     L3
         jsr     newline         ; new line
         ldy     #0              ; + cr
@@ -62,7 +61,7 @@ L3:     sty     CURS_X
 
 newline:
        clc
-       lda     xsize
+       lda     #XSIZE
        adc     CharPtr
        sta     CharPtr
        bcc     L4
index 0779fb1e5ce1f07dd311b4186aeb7c03c7314cfa..291f42d4a7b9d7a49b65a42536f6a44bcafe3216 100644 (file)
@@ -6,24 +6,29 @@
 
        .export         _screensize
 
-       .import         popax
-       .import         xsize, ysize
-       .importzp       ptr1, ptr2
+       .import         popsreg
+       .import         screensize
+       .importzp       ptr1, sreg
 
 .proc  _screensize
 
-       sta     ptr1            ; Store the y pointer
+       sta     ptr1            ; Store the y pointer
        stx     ptr1+1
+        jsr     popsreg         ; Get the x pointer into sreg
+        jsr     screensize      ; Get screensize into X/Y
+        tya                     ; Get Y size into A
+
+.IFP02
+       ldy     #0
+        sta     (ptr1),y
+        txa
+        sta     (sreg),y
+.ELSE
+        sta     (ptr1)
+        txa
+        sta     (sreg)
+.ENDIF
 
-       jsr     popax           ; get the x pointer
-       sta     ptr2
-       stx     ptr2+1
-
-       ldy     #0
-       lda     xsize
-       sta     (ptr2),y
-       lda     ysize
-       sta     (ptr1),y
        rts
 
 .endproc
index 09c94182b66de9eb4589b235cd25d91a5d0661fd..ef8b4c56bd8a3479545032c58cd41e5ea39d90d4 100644 (file)
@@ -4,27 +4,16 @@
 ; Screen size variables
 ;
 
-
-       .export         xsize, ysize
-               .constructor    initscrsize
+       .export         screensize
 
        .include        "pet.inc"
 
-.code
+.proc   screensize
 
-initscrsize:
                ldx     SCR_LINELEN
        inx                     ; Variable is one less
-               stx     xsize
-       lda     #25
-       sta     ysize
+               ldy     #25
        rts
 
-
-.bss
-
-xsize:         .res    1
-ysize: .res    1
-
-
+.endproc
 
index 2cabcc0841f4baff216af36944d5e7e540fd30e5..426a8c5ade5c838ca7c668037260b52d03e3609b 100644 (file)
@@ -7,7 +7,6 @@
        .export         _clrscr
        .import         plot
                .importzp       ptr1
-       .import         xsize
 
        .include        "pet.inc"
 
@@ -23,9 +22,9 @@ _clrscr:
 ; Determine, how many pages to fill
 
        ldx     #4
-       lda     xsize
-       cmp     #40
-               beq     L1
+       lda     SCR_LINELEN     ; Check length of one line
+       cmp     #40+1
+               bcc     L1
        ldx     #8
 
 ; Clear the screen
index eb84305366e860399141d729dcaa776f041ab200..c9ac9928e0e6b7bd8183e840d6d44b34d8daa900 100644 (file)
@@ -8,10 +8,8 @@
        .export         _cputcxy, _cputc, cputdirect, putchar
        .export         newline, plot
        .import         popa, _gotoxy
-       .import         xsize
 
        .include        "pet.inc"
-;      .include        "../cbm/cbm.inc"
 
 _cputcxy:
        pha                     ; Save C
@@ -48,17 +46,17 @@ cputdirect:
 ; Advance cursor position
 
 advance:
-        iny
-        cpy     xsize
+        cpy     SCR_LINELEN     ; xsize-1
         bne     L3
         jsr     newline         ; new line
-        ldy     #0              ; + cr
-L3:     sty     CURS_X
+        ldy     #$FF            ; + cr
+L3:     iny
+        sty     CURS_X
         rts
 
 newline:
-       clc
-       lda     xsize
+       lda     SCR_LINELEN     ; xsize-1
+        sec                     ; Account for -1 above
        adc     SCREEN_PTR
        sta     SCREEN_PTR
        bcc     L4
@@ -84,9 +82,9 @@ plot: ldy     CURS_Y
        lda     ScrLo,y
        sta     SCREEN_PTR
        lda     ScrHi,y
-       ldy     xsize
-       cpy     #40
-               beq     @L1
+       ldy     SCR_LINELEN
+       cpy     #40+1
+               bcc     @L1
                asl     SCREEN_PTR              ; 80 column mode
        rol     a
 @L1:   ora     #$80                    ; Screen at $8000
index 15dd1f778aef5d4ae95980977017657e58a2368d..19f92d7e5b7e3c44817c77f9303b3cc434fd83ad 100644 (file)
@@ -4,11 +4,18 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
 
-.data             
+; We will return the values directly instead of banking in the ROM and calling
+; SCREEN which is a lot more overhead in code size and CPU cycles.
+
+.proc   screensize
+
+        ldx     #40
+        ldy     #25
+        rts
+
+.endproc
 
-xsize:         .byte   40
-ysize: .byte   25
 
 
index bbf4c5f12324641d829f9f25bb1e6c60b6775f8f..5788c1cb01540cb172105348bc4e4ce126d63267 100644 (file)
@@ -8,7 +8,6 @@
        .export         _cputcxy, _cputc, cputdirect, putchar
        .export         newline, plot
        .import         popa, _gotoxy
-       .import         xsize
         .import         PLOT
 
        .include        "plus4.inc"
@@ -50,7 +49,7 @@ cputdirect:
 
 advance:
         iny
-        cpy     xsize
+        cpy     #XSIZE
         bne     L3
         jsr     newline         ; new line
         ldy     #0              ; + cr
@@ -59,13 +58,13 @@ L3:     sty     CURS_X
 
 newline:
        clc
-       lda     xsize
+       lda     #XSIZE
        adc     SCREEN_PTR
        sta     SCREEN_PTR
        bcc     L4
        inc     SCREEN_PTR+1
        clc
-L4:    lda     xsize
+L4:    lda     #XSIZE
        adc     CRAM_PTR
        sta     CRAM_PTR
        bcc     L5
index e4f53a76ce9e4f0ebff4da8a5cbe10908a0d5e23..0d51f0aaf852816703c85de220bd3b1297255e70 100644 (file)
@@ -41,6 +41,12 @@ IRQVec               = $0314
 BRKVec         = $0316
 NMIVec         = $0318
 
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE           = 40
+YSIZE           = 25
+
 ; ---------------------------------------------------------------------------
 ; I/O
 
index c63df59d234697537f3d9aaf986d49fc9713e639..c0a746198b24f5756d9b9626d1ac10c673eaae6a 100644 (file)
@@ -4,22 +4,9 @@
 ; Screen size variables
 ;
 
-       .export         xsize, ysize
+       .export         screensize
         .import         SCREEN
-       .constructor    initscrsize
 
-
-.code
-
-initscrsize:
-       jsr     SCREEN
-       stx     xsize
-       sty     ysize
-       rts
-
-.bss
-
-xsize:         .res    1
-ysize: .res    1
+screensize      = SCREEN
 
 
index cf3c02fdfa2f9c3535e23a09029f882c0194c41c..2dd6f00c9c60e96028773d378f6ac5a330f57eca 100644 (file)
@@ -8,7 +8,6 @@
        .export         _cputcxy, _cputc, cputdirect, putchar
        .export         newline, plot
        .import         popa, _gotoxy
-       .import         xsize
         .import         PLOT
 
        .include        "vic20.inc"
@@ -50,7 +49,7 @@ cputdirect:
 
 advance:
        iny
-       cpy     xsize
+       cpy     #XSIZE
        bne     L3
        jsr     newline         ; new line
        ldy     #0              ; + cr
@@ -59,13 +58,13 @@ L3: sty     CURS_X
 
 newline:
        clc
-       lda     xsize
+       lda     #XSIZE
        adc     SCREEN_PTR
        sta     SCREEN_PTR
        bcc     L4
        inc     SCREEN_PTR+1
        clc
-L4:    lda     xsize
+L4:    lda     #XSIZE
        adc     CRAM_PTR
        sta     CRAM_PTR
        bcc     L5
index 3297fdbca6340be2e5903efa228b255c304d78f5..95c1f2fecf862a72bfe365061a3de1079d43e58b 100644 (file)
@@ -28,6 +28,12 @@ CURS_COLOR      = $287               ; Color under the cursor
 PALFLAG                = $2A6          ; $01 = PAL, $00 = NTSC
 
 
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE           = 22
+YSIZE           = 23                    
+
 ; ---------------------------------------------------------------------------
 ; Kernal routines