]> git.sur5r.net Git - cc65/commitdiff
Macro-based implementation of screen layout configuration modules.
authorStephan Mühlstrasser <stephan.muehlstrasser@web.de>
Sun, 22 Mar 2015 21:45:53 +0000 (22:45 +0100)
committerStephan Mühlstrasser <stephan.muehlstrasser@web.de>
Mon, 23 Mar 2015 18:02:45 +0000 (19:02 +0100)
doc/osi.sgml
libsrc/osic1p/_scrsize.s [deleted file]
libsrc/osic1p/clrscr.s [deleted file]
libsrc/osic1p/cputc.s [deleted file]
libsrc/osic1p/extra/screen-s3-32x28.s [new file with mode: 0644]
libsrc/osic1p/osic1p.inc
libsrc/osic1p/osiscreen.inc [new file with mode: 0644]
libsrc/osic1p/screen-c1p-24x24.s [new file with mode: 0644]

index 1ceaec359d5b904fc9f3844a30ebf75c8bfdc83b..ab1b4cee5c473623806cfeeaf75a8a8d11f8929f 100644 (file)
@@ -6,7 +6,7 @@
 <author>
 <url url="mailto:stephan.muehlstrasser@web.de" name="Stephan M&uuml;hlstrasser">,<newline>
 <url url="mailto:greg.king5@verizon.net" name="Greg King">
-<date>2015-03-08
+<date>2015-03-17
 
 <abstract>
 An overview over the Ohio Scientific runtime system as it is implemented for the cc65 C
@@ -33,7 +33,7 @@ information.
 <sect>Targets<p>
 
 Currently the target "osic1p" is implemented. This works for the Ohio Scientific
-Challenger 1P machine.
+Challenger 1P machine and for the Briel Superboard /// replica.
 
 <sect>Program file formats<p>
 
@@ -123,7 +123,7 @@ Challenger 1P, which is implicitly used via <tt/-t osic1p/. The
 osic1p package comes with additional secondary linker config files, which are
 used via <tt/-t osic1p -C &lt;configfile&gt;/.
 
-<sect1>default config file (<tt/osic1p.cfg/)<p>
+<sect1>Default config file (<tt/osic1p.cfg/)<p>
 
 The default configuration is tailored to C programs.
 
@@ -161,6 +161,36 @@ There is no specific support for direct hardware access.
 
 There are no loadable drivers available.
 
+<sect>Support for different screen layouts<p>
+
+By default the conio library uses a 24 columns by 24 lines screen layout
+for the Challenger 1P, like under BASIC. In addition to that there is support
+for other screen layouts with extra modules.
+
+There is a module <tt/screen-c1p-24x24.o/ in the OSI-specific
+cc65 runtime library that contains all conio functions that depend
+on the screen layout. No further configuration is needed for using the
+default screen layout of the Challenger 1P.
+
+For other screen layouts additional versions of the screen module are
+available. The linker finds these modules without further configuration
+if they are specified on the compiler or linker command line. The
+extra module then overrides the default module.
+
+Sample <tt/cl65/ command line to override the default screen
+module with the module <tt/osic1p-screen-s3-32x28.o/:
+
+<tscreen><verb>
+cl65 -o hello -t osic1p osic1p-screen-s3-32x28.o hello.c
+</verb></tscreen>
+
+Currently the following extra screen configuration modules are implemented:
+
+<itemize>
+<item><tt>osic1p-screen-s3-32x28.o</tt>: 32 columns by 28 lines mode
+for Briel Superboard ///</item>
+</itemize>
+
 <sect>Limitations<p>
 
 <sect1>stdio implementation<p>
@@ -200,3 +230,4 @@ freely, subject to the following restrictions:
 </enum>
 
 </article>
+
diff --git a/libsrc/osic1p/_scrsize.s b/libsrc/osic1p/_scrsize.s
deleted file mode 100644 (file)
index be07234..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-;
-; based on PET implementation
-;
-; originally by:
-; Ullrich von Bassewitz, 26.10.2000
-;
-; Screen size variables
-;
-
-        .export         screensize
-
-        .include        "extzp.inc"
-        .include        "osic1p.inc"
-
-.proc   screensize
-        ldx     #SCR_WIDTH
-        ldy     #SCR_HEIGHT
-        rts
-.endproc
diff --git a/libsrc/osic1p/clrscr.s b/libsrc/osic1p/clrscr.s
deleted file mode 100644 (file)
index db8da69..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-;\r
-; void clrscr (void);\r
-;\r
-        .export         _clrscr\r
-        .import         plot\r
-        .include        "extzp.inc"\r
-        .include        "osic1p.inc"\r
-\r
-; Adapted from the Challenger Character Graphics\r
-; Reference Manual, "2.3.3 MACHINE LANGUAGE SCREEN CLEAR"\r
-; This is self-modifying code!\r
-BANKS = VIDEORAMSIZE / $100\r
-\r
-_clrscr:\r
-        lda       #' '\r
-        ldy       #BANKS\r
-        ldx       #$00\r
-staloc:\r
-        sta       SCRNBASE,X\r
-        inx\r
-        bne       staloc\r
-        inc       staloc+2\r
-        dey\r
-        bne       staloc\r
-        lda       #>(SCRNBASE)  ; Load high byte\r
-        sta       staloc+2      ; Restore base address\r
-\r
-        lda       #$00          ; Cursor in upper left corner\r
-        sta       CURS_X\r
-        sta       CURS_Y\r
-        jmp       plot          ; Set the cursor position\r
diff --git a/libsrc/osic1p/cputc.s b/libsrc/osic1p/cputc.s
deleted file mode 100644 (file)
index 2baada4..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-;
-; cputc/cputcxy for Challenger 1P
-; Based on PET/CBM implementation
-;
-; void cputcxy (unsigned char x, unsigned char y, char c);
-; void cputc (char c);
-;
-        .export         _cputcxy, _cputc, cputdirect, putchar
-        .export         newline, plot
-        .import         popa, _gotoxy
-
-        .include        "osic1p.inc"
-        .include        "extzp.inc"
-
-FIRSTVISC       = $85           ; Offset of first visible character in video RAM
-LINEDIST        = $20           ; Offset in video RAM between two lines
-BLOCKSIZE       = $100          ; Size of block to scroll
-
-_cputcxy:
-        pha                     ; Save C
-        jsr     popa            ; Get Y
-        jsr     _gotoxy         ; Set cursor, drop x
-        pla                     ; Restore C
-
-; Plot a character - also used as internal function
-
-_cputc: cmp     #$0A            ; CR?
-        bne     L1
-        lda     #0
-        sta     CURS_X
-        beq     plot            ; Recalculate pointers
-
-L1:     cmp     #$0D            ; LF?
-        beq     newline         ; Recalculate pointers
-
-cputdirect:
-        jsr     putchar         ; Write the character to the screen
-
-; Advance cursor position
-
-advance:
-        cpy     #(SCR_WIDTH - 1)
-        bne     L3
-        jsr     newline         ; New line
-        ldy     #$FF            ; + cr
-L3:     iny
-        sty     CURS_X
-        rts
-
-newline:
-        inc     CURS_Y
-        lda     CURS_Y
-        cmp     #SCR_HEIGHT     ; Screen height
-        bne     plot
-        dec     CURS_Y          ; Bottom of screen reached, scroll
-        ldx     #0
-scroll:
-.repeat 3, I                    ; Scroll screen in three blocks of size
-                                ; BLOCKSIZE
-        lda     SCRNBASE+(I*BLOCKSIZE)+FIRSTVISC+LINEDIST,x
-        sta     SCRNBASE+(I*BLOCKSIZE)+FIRSTVISC,x
-.endrepeat
-        inx
-        bne scroll
-
-        lda     #' '            ; Clear bottom line of screen
-bottom:
-        sta     SCRNBASE+(3*BLOCKSIZE)+FIRSTVISC,x
-        inx
-        cpx     #SCR_WIDTH
-        bne     bottom
-
-plot:   ldy     CURS_Y
-        lda     ScrLo,y
-        sta     SCREEN_PTR
-        lda     ScrHi,y
-        sta     SCREEN_PTR+1
-        rts
-
-; Write one character to the screen without doing anything else, return X
-; position in Y
-
-putchar:
-        ldy     CURS_X
-        sta     (SCREEN_PTR),y  ; Set char
-        rts
-
-; Screen address tables - offset to real screen
-
-.rodata
-
-ScrLo:  .byte   $85, $A5, $C5, $E5, $05, $25, $45, $65
-        .byte   $85, $A5, $C5, $E5, $05, $25, $45, $65
-        .byte   $85, $A5, $C5, $E5, $05, $25, $45, $65
-        .byte   $85
-
-ScrHi:  .byte   $D0, $D0, $D0, $D0, $D1, $D1, $D1, $D1
-        .byte   $D1, $D1, $D1, $D1, $D2, $D2, $D2, $D2
-        .byte   $D2, $D2, $D2, $D2, $D3, $D3, $D3, $D3
-        .byte   $D3
diff --git a/libsrc/osic1p/extra/screen-s3-32x28.s b/libsrc/osic1p/extra/screen-s3-32x28.s
new file mode 100644 (file)
index 0000000..40ed242
--- /dev/null
@@ -0,0 +1,16 @@
+;
+; Implementation of screen-layout related functions for Superboard ///
+;
+
+        .include        "../osiscreen.inc"
+
+S3_SCR_BASE     := $D000        ; Base of Superboard /// video RAM
+S3_VRAM_SIZE    = $0400         ; Size of Superboard /// video RAM (1 kB)
+S3_SCR_WIDTH    = $20           ; Screen width
+S3_SCR_HEIGHT   = $1C           ; Screen height
+S3_SCR_FIRSTCHAR = $80          ; Offset of cursor position (0, 0) from base
+                                ; of video RAM
+S3_SCROLL_DIST  = $20           ; Memory distance for scrolling by one line
+
+osi_screen_funcs S3_SCR_BASE, S3_VRAM_SIZE, S3_SCR_FIRSTCHAR, \
+                        S3_SCR_WIDTH, S3_SCR_HEIGHT, S3_SCROLL_DIST
index 232c471aa11e7e949d39b4597fa6e07141a2a954..eabeaf79e7ea61cae53ab85ee6adf3180f128f04 100644 (file)
@@ -1,10 +1,4 @@
 ; Addresses\r
-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
-SCR_WIDTH       = $18           ; Screen width\r
-SCR_HEIGHT      = $18           ; Screen height\r
diff --git a/libsrc/osic1p/osiscreen.inc b/libsrc/osic1p/osiscreen.inc
new file mode 100644 (file)
index 0000000..66c5e9f
--- /dev/null
@@ -0,0 +1,184 @@
+;\r
+; Macro definitions for screen layout modules\r
+;\r
+\r
+        .include        "extzp.inc"\r
+        \r
+.linecont +\r
+\r
+;\r
+; Internal function for screensize()\r
+;\r
+.macro  osi_screensize ScrWidth, ScrHeight\r
+                                ; Macro implementation of internal screensize\r
+                                ; function for given width and height in\r
+                                ; characters\r
+                                \r
+        .export         screensize\r
+\r
+.proc   screensize\r
+        ldx     #ScrWidth\r
+        ldy     #ScrHeight\r
+        rts\r
+.endproc\r
+.endmacro\r
+\r
+;\r
+; void clrscr (void);\r
+;\r
+.macro  osi_clrscr ScrBase, ScrRamSize\r
+\r
+        .export         _clrscr\r
+\r
+.proc   _clrscr\r
+        lda     #<ScrBase       ; Fill whole video RAM with blanks by calling\r
+        ldx     #>ScrBase       ; memset appropriately\r
+        jsr     pushax\r
+        \r
+        lda     #' '\r
+        ldx     #$00\r
+        jsr     pushax\r
+        \r
+        lda     #<ScrRamSize\r
+        ldx     #>ScrRamSize\r
+        jsr     _memset\r
+\r
+        lda     #$00            ; Cursor in upper left corner\r
+        sta     CURS_X\r
+        sta     CURS_Y\r
+        \r
+        jmp     plot            ; Set the cursor position\r
+.endproc\r
+\r
+.endmacro\r
+\r
+;\r
+; cputc/cputcxy for Challenger 1P\r
+; Based on PET/CBM implementation\r
+;\r
+\r
+.macro  osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \\r
+                         ScrollDist, ScrLo, ScrHi\r
+\r
+                                ; Number of characters to move for scrolling\r
+                                ; by one line\r
+ScrollLength    = (ScrHeight - 1) * ScrollDist\r
+\r
+;\r
+; void cputcxy (unsigned char x, unsigned char y, char c);\r
+; void cputc (char c);\r
+;\r
+        .export         _cputcxy, _cputc, cputdirect, putchar\r
+        .export         newline, plot\r
+\r
+_cputcxy:\r
+        pha                     ; Save C\r
+        jsr     popa            ; Get Y\r
+        jsr     _gotoxy         ; Set cursor, drop x\r
+        pla                     ; Restore C\r
+\r
+; Plot a character - also used as internal function\r
+\r
+_cputc: cmp     #$0A            ; CR?\r
+        bne     L1\r
+        lda     #0\r
+        sta     CURS_X\r
+        beq     plot            ; Recalculate pointers\r
+\r
+L1:     cmp     #$0D            ; LF?\r
+        beq     newline         ; Recalculate pointers\r
+\r
+cputdirect:\r
+        jsr     putchar         ; Write the character to the screen\r
+\r
+; Advance cursor position, register Y contains horizontal position after\r
+; putchar\r
+\r
+        cpy     #(ScrWidth - 1) ; Check whether line is full\r
+        bne     L3\r
+        jsr     newline         ; New line\r
+        ldy     #$FF            ; + cr\r
+L3:     iny\r
+        sty     CURS_X\r
+        rts\r
+\r
+newline:\r
+        inc     CURS_Y\r
+        lda     CURS_Y\r
+        cmp     #ScrHeight      ; Screen height\r
+        bne     plot\r
+        dec     CURS_Y          ; Bottom of screen reached, scroll\r
+\r
+                                ; Scroll destination address\r
+        lda     #<(ScrBase + ScrFirstChar)\r
+        ldx     #>(ScrBase + ScrFirstChar)\r
+        jsr     pushax\r
+        \r
+                                ; Scroll source address\r
+        lda     #<(ScrBase + ScrFirstChar + ScrollDist)\r
+        ldx     #>(ScrBase + ScrFirstChar + ScrollDist)\r
+        jsr     pushax\r
+        \r
+                                ; Number of characters to move\r
+        lda     #<ScrollLength\r
+        ldx     #>ScrollLength\r
+        jsr     _memmove\r
+\r
+                                ; Address of first character in last line\r
+                                ; of screen\r
+        lda     #<(ScrBase + ScrFirstChar + ScrollLength)\r
+        sta     ptr1\r
+        lda     #>(ScrBase + ScrFirstChar + ScrollLength)\r
+        sta     ptr1+1\r
+        \r
+        ldy     #ScrWidth       ; Fill last line with blanks\r
+        lda     #' '\r
+clrln:  sta     (ptr1),y\r
+        dey\r
+        bpl     clrln\r
+\r
+plot:   ldy     CURS_Y\r
+        lda     ScrLo,y\r
+        sta     SCREEN_PTR\r
+        lda     ScrHi,y\r
+        sta     SCREEN_PTR+1\r
+        rts\r
+\r
+; Write one character to the screen without doing anything else, return X\r
+; position in register Y\r
+\r
+putchar:\r
+        ldy     CURS_X\r
+        sta     (SCREEN_PTR),y  ; Set char\r
+        rts\r
+        \r
+.endmacro\r
+\r
+.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \\r
+                        ScrWidth, ScrHeight, ScrollDist\r
+\r
+        .import         popa, _gotoxy\r
+        .import         _memmove, _memset, pushax\r
+        .importzp       ptr1\r
+\r
+.rodata\r
+\r
+; Screen address tables - offset to real screen\r
+ScrTabLo:\r
+        .repeat ScrHeight, I\r
+        .byte <(ScrBase + ScrFirstChar + I * ScrollDist)\r
+        .endrep\r
+        \r
+ScrTabHi:\r
+        .repeat ScrHeight, I\r
+        .byte >(ScrBase + ScrFirstChar + I * ScrollDist)\r
+        .endrep\r
+\r
+.code\r
+\r
+osi_cputfuncs   ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \\r
+                         ScrollDist, ScrTabLo, ScrTabHi\r
+osi_screensize  ScrWidth, ScrHeight\r
+osi_clrscr      ScrBase, ScrRamSize\r
+\r
+.endmacro
\ No newline at end of file
diff --git a/libsrc/osic1p/screen-c1p-24x24.s b/libsrc/osic1p/screen-c1p-24x24.s
new file mode 100644 (file)
index 0000000..e691c2f
--- /dev/null
@@ -0,0 +1,16 @@
+;
+; Implementation of screen-layout related functions for Challenger 1P
+;
+
+        .include        "osiscreen.inc"
+
+C1P_SCR_BASE    := $D000        ; Base of C1P video RAM
+C1P_VRAM_SIZE   = $0400         ; Size of C1P video RAM (1 kB)
+C1P_SCR_WIDTH   = $18           ; Screen width
+C1P_SCR_HEIGHT  = $18           ; Screen height
+C1P_SCR_FIRSTCHAR = $85         ; Offset of cursor position (0, 0) from base
+                                ; of video RAM
+C1P_SCROLL_DIST = $20           ; Memory distance for scrolling by one line
+
+osi_screen_funcs C1P_SCR_BASE, C1P_VRAM_SIZE, C1P_SCR_FIRSTCHAR, \
+                        C1P_SCR_WIDTH, C1P_SCR_HEIGHT, C1P_SCROLL_DIST