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