From: Stephan Mühlstrasser Date: Sun, 22 Mar 2015 21:45:53 +0000 (+0100) Subject: Macro-based implementation of screen layout configuration modules. X-Git-Tag: V2.15~14^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7fb206e38162886bec5109480b84254ef31797cb;p=cc65 Macro-based implementation of screen layout configuration modules. --- diff --git a/doc/osi.sgml b/doc/osi.sgml index 1ceaec359..ab1b4cee5 100644 --- a/doc/osi.sgml +++ b/doc/osi.sgml @@ -6,7 +6,7 @@ , -2015-03-08 +2015-03-17 An overview over the Ohio Scientific runtime system as it is implemented for the cc65 C @@ -33,7 +33,7 @@ information. Targets

Currently the target "osic1p" is implemented. This works for the Ohio Scientific -Challenger 1P machine. +Challenger 1P machine and for the Briel Superboard /// replica. Program file formats

@@ -123,7 +123,7 @@ Challenger 1P, which is implicitly used via default config file ( +Default config file ( 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. +Support for different screen layouts

+ +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 +cl65 -o hello -t osic1p osic1p-screen-s3-32x28.o hello.c + + +Currently the following extra screen configuration modules are implemented: + + +osic1p-screen-s3-32x28.o: 32 columns by 28 lines mode +for Briel Superboard /// + + Limitations

stdio implementation

@@ -200,3 +230,4 @@ freely, subject to the following restrictions: + diff --git a/libsrc/osic1p/_scrsize.s b/libsrc/osic1p/_scrsize.s deleted file mode 100644 index be07234b4..000000000 --- a/libsrc/osic1p/_scrsize.s +++ /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 index db8da6912..000000000 --- a/libsrc/osic1p/clrscr.s +++ /dev/null @@ -1,31 +0,0 @@ -; -; void clrscr (void); -; - .export _clrscr - .import plot - .include "extzp.inc" - .include "osic1p.inc" - -; Adapted from the Challenger Character Graphics -; Reference Manual, "2.3.3 MACHINE LANGUAGE SCREEN CLEAR" -; This is self-modifying code! -BANKS = VIDEORAMSIZE / $100 - -_clrscr: - lda #' ' - ldy #BANKS - ldx #$00 -staloc: - sta SCRNBASE,X - inx - bne staloc - inc staloc+2 - dey - bne staloc - lda #>(SCRNBASE) ; Load high byte - sta staloc+2 ; Restore base address - - lda #$00 ; Cursor in upper left corner - sta CURS_X - sta CURS_Y - jmp plot ; Set the cursor position diff --git a/libsrc/osic1p/cputc.s b/libsrc/osic1p/cputc.s deleted file mode 100644 index 2baada465..000000000 --- a/libsrc/osic1p/cputc.s +++ /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 index 000000000..40ed24203 --- /dev/null +++ b/libsrc/osic1p/extra/screen-s3-32x28.s @@ -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 diff --git a/libsrc/osic1p/osic1p.inc b/libsrc/osic1p/osic1p.inc index 232c471aa..eabeaf79e 100644 --- a/libsrc/osic1p/osic1p.inc +++ b/libsrc/osic1p/osic1p.inc @@ -1,10 +1,4 @@ ; Addresses -SCRNBASE := $D000 ; Base of video RAM INPUTC := $FD00 ; Input character from keyboard RESET := $FF00 ; Reset address, show boot prompt KBD := $DF00 ; Polled keyboard register - -; Other definitions -VIDEORAMSIZE = $0400 ; Size of C1P video RAM (1 kB) -SCR_WIDTH = $18 ; Screen width -SCR_HEIGHT = $18 ; Screen height diff --git a/libsrc/osic1p/osiscreen.inc b/libsrc/osic1p/osiscreen.inc new file mode 100644 index 000000000..66c5e9fb0 --- /dev/null +++ b/libsrc/osic1p/osiscreen.inc @@ -0,0 +1,184 @@ +; +; Macro definitions for screen layout modules +; + + .include "extzp.inc" + +.linecont + + +; +; Internal function for screensize() +; +.macro osi_screensize ScrWidth, ScrHeight + ; Macro implementation of internal screensize + ; function for given width and height in + ; characters + + .export screensize + +.proc screensize + ldx #ScrWidth + ldy #ScrHeight + rts +.endproc +.endmacro + +; +; void clrscr (void); +; +.macro osi_clrscr ScrBase, ScrRamSize + + .export _clrscr + +.proc _clrscr + lda #ScrBase ; memset appropriately + jsr pushax + + lda #' ' + ldx #$00 + jsr pushax + + lda #ScrRamSize + jsr _memset + + lda #$00 ; Cursor in upper left corner + sta CURS_X + sta CURS_Y + + jmp plot ; Set the cursor position +.endproc + +.endmacro + +; +; cputc/cputcxy for Challenger 1P +; Based on PET/CBM implementation +; + +.macro osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ + ScrollDist, ScrLo, ScrHi + + ; Number of characters to move for scrolling + ; by one line +ScrollLength = (ScrHeight - 1) * ScrollDist + +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + .export _cputcxy, _cputc, cputdirect, putchar + .export newline, plot + +_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, register Y contains horizontal position after +; putchar + + cpy #(ScrWidth - 1) ; Check whether line is full + bne L3 + jsr newline ; New line + ldy #$FF ; + cr +L3: iny + sty CURS_X + rts + +newline: + inc CURS_Y + lda CURS_Y + cmp #ScrHeight ; Screen height + bne plot + dec CURS_Y ; Bottom of screen reached, scroll + + ; Scroll destination address + lda #<(ScrBase + ScrFirstChar) + ldx #>(ScrBase + ScrFirstChar) + jsr pushax + + ; Scroll source address + lda #<(ScrBase + ScrFirstChar + ScrollDist) + ldx #>(ScrBase + ScrFirstChar + ScrollDist) + jsr pushax + + ; Number of characters to move + lda #ScrollLength + jsr _memmove + + ; Address of first character in last line + ; of screen + lda #<(ScrBase + ScrFirstChar + ScrollLength) + sta ptr1 + lda #>(ScrBase + ScrFirstChar + ScrollLength) + sta ptr1+1 + + ldy #ScrWidth ; Fill last line with blanks + lda #' ' +clrln: sta (ptr1),y + dey + bpl clrln + +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 register Y + +putchar: + ldy CURS_X + sta (SCREEN_PTR),y ; Set char + rts + +.endmacro + +.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \ + ScrWidth, ScrHeight, ScrollDist + + .import popa, _gotoxy + .import _memmove, _memset, pushax + .importzp ptr1 + +.rodata + +; Screen address tables - offset to real screen +ScrTabLo: + .repeat ScrHeight, I + .byte <(ScrBase + ScrFirstChar + I * ScrollDist) + .endrep + +ScrTabHi: + .repeat ScrHeight, I + .byte >(ScrBase + ScrFirstChar + I * ScrollDist) + .endrep + +.code + +osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \ + ScrollDist, ScrTabLo, ScrTabHi +osi_screensize ScrWidth, ScrHeight +osi_clrscr ScrBase, ScrRamSize + +.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 index 000000000..e691c2f1f --- /dev/null +++ b/libsrc/osic1p/screen-c1p-24x24.s @@ -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