2 ; Macro definitions for screen layout modules
\r
10 ; Internal function for screensize()
\r
12 .macro osi_screensize ScrWidth, ScrHeight
\r
13 ; Macro implementation of internal screensize
\r
14 ; function for given width and height in
\r
27 ; void clrscr (void);
\r
29 .macro osi_clrscr ScrBase, ScrRamSize
\r
34 lda #<ScrBase ; Fill whole video RAM with blanks by calling
\r
35 ldx #>ScrBase ; memset appropriately
\r
46 lda #$00 ; Cursor in upper left corner
\r
50 jmp plot ; Set the cursor position
\r
56 ; cputc/cputcxy for Challenger 1P
\r
57 ; Based on PET/CBM implementation
\r
60 .macro osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
\r
61 ScrollDist, ScrLo, ScrHi
\r
63 ; Number of characters to move for scrolling
\r
65 ScrollLength = (ScrHeight - 1) * ScrollDist
\r
68 ; void cputcxy (unsigned char x, unsigned char y, char c);
\r
69 ; void cputc (char c);
\r
71 .export _cputcxy, _cputc, cputdirect, putchar
\r
72 .export newline, plot
\r
76 jsr gotoxy ; Set cursor, drop x and y
\r
79 ; Plot a character - also used as internal function
\r
81 _cputc: cmp #$0A ; CR?
\r
85 beq plot ; Recalculate pointers
\r
88 beq newline ; Recalculate pointers
\r
91 jsr putchar ; Write the character to the screen
\r
93 ; Advance cursor position, register Y contains horizontal position after
\r
96 cpy #(ScrWidth - 1) ; Check whether line is full
\r
98 jsr newline ; New line
\r
107 cmp #ScrHeight ; Screen height
\r
109 dec CURS_Y ; Bottom of screen reached, scroll
\r
111 ; Scroll destination address
\r
112 lda #<(ScrBase + ScrFirstChar)
\r
113 ldx #>(ScrBase + ScrFirstChar)
\r
116 ; Scroll source address
\r
117 lda #<(ScrBase + ScrFirstChar + ScrollDist)
\r
118 ldx #>(ScrBase + ScrFirstChar + ScrollDist)
\r
121 ; Number of characters to move
\r
126 ; Address of first character in last line
\r
128 lda #<(ScrBase + ScrFirstChar + ScrollLength)
\r
130 lda #>(ScrBase + ScrFirstChar + ScrollLength)
\r
133 ldy #ScrWidth ; Fill last line with blanks
\r
135 clrln: sta (ptr1),y
\r
146 ; Write one character to the screen without doing anything else, return X
\r
147 ; position in register Y
\r
151 sta (SCREEN_PTR),y ; Set char
\r
156 .macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \
\r
157 ScrWidth, ScrHeight, ScrollDist
\r
160 .import _memmove, _memset, pushax
\r
165 ; Screen address tables - offset to real screen
\r
167 .repeat ScrHeight, I
\r
168 .byte <(ScrBase + ScrFirstChar + I * ScrollDist)
\r
172 .repeat ScrHeight, I
\r
173 .byte >(ScrBase + ScrFirstChar + I * ScrollDist)
\r
178 osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
\r
179 ScrollDist, ScrTabLo, ScrTabHi
\r
180 osi_screensize ScrWidth, ScrHeight
\r
181 osi_clrscr ScrBase, ScrRamSize
\r