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
77 jsr _gotoxy ; Set cursor, drop x
\r
80 ; Plot a character - also used as internal function
\r
82 _cputc: cmp #$0A ; CR?
\r
86 beq plot ; Recalculate pointers
\r
89 beq newline ; Recalculate pointers
\r
92 jsr putchar ; Write the character to the screen
\r
94 ; Advance cursor position, register Y contains horizontal position after
\r
97 cpy #(ScrWidth - 1) ; Check whether line is full
\r
99 jsr newline ; New line
\r
108 cmp #ScrHeight ; Screen height
\r
110 dec CURS_Y ; Bottom of screen reached, scroll
\r
112 ; Scroll destination address
\r
113 lda #<(ScrBase + ScrFirstChar)
\r
114 ldx #>(ScrBase + ScrFirstChar)
\r
117 ; Scroll source address
\r
118 lda #<(ScrBase + ScrFirstChar + ScrollDist)
\r
119 ldx #>(ScrBase + ScrFirstChar + ScrollDist)
\r
122 ; Number of characters to move
\r
127 ; Address of first character in last line
\r
129 lda #<(ScrBase + ScrFirstChar + ScrollLength)
\r
131 lda #>(ScrBase + ScrFirstChar + ScrollLength)
\r
134 ldy #ScrWidth ; Fill last line with blanks
\r
136 clrln: sta (ptr1),y
\r
147 ; Write one character to the screen without doing anything else, return X
\r
148 ; position in register Y
\r
152 sta (SCREEN_PTR),y ; Set char
\r
157 .macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \
\r
158 ScrWidth, ScrHeight, ScrollDist
\r
160 .import popa, _gotoxy
\r
161 .import _memmove, _memset, pushax
\r
166 ; Screen address tables - offset to real screen
\r
168 .repeat ScrHeight, I
\r
169 .byte <(ScrBase + ScrFirstChar + I * ScrollDist)
\r
173 .repeat ScrHeight, I
\r
174 .byte >(ScrBase + ScrFirstChar + I * ScrollDist)
\r
179 osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
\r
180 ScrollDist, ScrTabLo, ScrTabHi
\r
181 osi_screensize ScrWidth, ScrHeight
\r
182 osi_clrscr ScrBase, ScrRamSize
\r