ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
cline.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
47/* <usermanual>
48@keyword CLINE
49
50@target c16
51</usermanual> */
52void cline( Environment * _environment, char * _characters ) {
53
54 Variable * characters = NULL;
55 if ( _characters ) {
56 characters = variable_retrieve( _environment, _characters );
57 outline1("LDA %s", characters->realName);
58 } else {
59 outline0("LDA #0");
60 }
61 outline0("STA CHARACTERS");
62
63 if ( !_environment->deployed.textCline ) {
64
65 Variable * colormapAddress = variable_retrieve( _environment, "COLORMAPADDRESS" );
66 Variable * TEXTADDRESS = variable_retrieve( _environment, "TEXTADDRESS" );
67 Variable * x = variable_retrieve( _environment, "XCURSYS" );
68 Variable * y = variable_retrieve( _environment, "YCURSYS" );
69
70 outline0("JMP lib_cline_after");
71
72 outline0("lib_cline:");
73 outline1("LDA %s", x->realName );
74 outline0("STA CLINEX" );
75 outline1("LDA %s", y->realName );
76 outline0("STA CLINEY");
77
78 // Use the current bitmap address as starting address for filling routine.
79 outline1("LDA %s", TEXTADDRESS->realName);
80 outline0("STA COPYOFTEXTADDRESS");
81 outline1("LDA %s", address_displacement(_environment, TEXTADDRESS->realName, "1"));
82 outline0("STA COPYOFTEXTADDRESS+1");
83 outline1("LDA %s", colormapAddress->realName );
84 outline0("STA COPYOFCOLORMAPADDRESS");
85 outline1("LDA %s", address_displacement(_environment, colormapAddress->realName, "1") );
86 outline0("STA COPYOFCOLORMAPADDRESS+1");
87
88 outline0("LDX CLINEY" ); // y
89 outline0("BEQ lib_cline_skip" );
90 outhead0("lib_cline_loop1:" );
91 outline0("CLC"); // x
92 outline0("LDA #40"); // width (lo)
93 outline0("ADC COPYOFTEXTADDRESS");
94 outline0("STA COPYOFTEXTADDRESS");
95 outline0("LDA #0"); // width (hi)
96 outline0("ADC COPYOFTEXTADDRESS+1");
97 outline0("STA COPYOFTEXTADDRESS+1");
98 outline0("DEX" );
99 outline0("BNE lib_cline_loop1" );
100
101 outline0("LDX CLINEY" ); // y
102 outhead0("lib_cline_loopc1:" );
103 outline0("CLC"); // x
104 outline0("LDA #40"); // width (lo)
105 outline0("ADC COPYOFCOLORMAPADDRESS");
106 outline0("STA COPYOFCOLORMAPADDRESS");
107 outline0("LDA #0"); // width (hi)
108 outline0("ADC COPYOFCOLORMAPADDRESS+1");
109 outline0("STA COPYOFCOLORMAPADDRESS+1");
110 outline0("DEX" );
111 outline0("BNE lib_cline_loopc1" );
112
113 outhead0("lib_cline_skip:" );
114
115 outline0("LDA CHARACTERS");
116 outline0("BEQ lib_cline_entire_linex");
117 outline0("JMP lib_cline_entire_line");
118
119 outhead0("lib_cline_entire_linex:" );
120 outline0("CLC"); // x
121 outline0("LDA CLINEX"); // x
122 outline0("ADC COPYOFTEXTADDRESS");
123 outline0("STA COPYOFTEXTADDRESS");
124 outline0("LDA #0");
125 outline0("ADC COPYOFTEXTADDRESS+1");
126 outline0("STA COPYOFTEXTADDRESS+1");
127
128 outline0("CLC"); // x
129 outline0("LDA CLINEX"); // x
130 outline0("ADC COPYOFCOLORMAPADDRESS");
131 outline0("STA COPYOFCOLORMAPADDRESS");
132 outline0("LDA #0");
133 outline0("ADC COPYOFCOLORMAPADDRESS+1");
134 outline0("STA COPYOFCOLORMAPADDRESS+1");
135
136 outline0("LDX CHARACTERS");
137 outline0("LDY #0");
138
139
140 outhead0("lib_cline_increment_x:");
141 outline0("LDA #32");
142 outline0("STA (COPYOFTEXTADDRESS),y");
143
144 outline0("INC CLINEX"); // x
145 outline0("LDA CLINEX"); // x
146 outline0("CMP #40"); // x
147 outline0("BEQ lib_cline_nextx"); // x
148 outline0("JMP lib_cline_next"); // x
149 outline0("lib_cline_nextx:");
150 outline0("LDA #0"); // x
151 outline0("STA CLINEX"); // x
152 outline0("INC CLINEY"); // y
153 outline0("LDA CLINEY"); // y
154 outline0("CMP #24"); // h
155 outline0("BEQ lib_cline_nextxx"); // x
156 outline0("JMP lib_cline_next"); // x
157 outhead0("lib_cline_nextxx:");
158
159 text_vscroll_screen( _environment, -1, 0 );
160
161 outline0("DEC CLINEY"); // y
162 outline0("SEC");
163 outline0("LDA COPYOFTEXTADDRESS");
164 outline0("SBC #40");
165 outline0("STA COPYOFTEXTADDRESS");
166 outline0("LDA COPYOFTEXTADDRESS+1");
167 outline0("SBC #0");
168 outline0("STA COPYOFTEXTADDRESS+1");
169
170 outline0("SEC");
171 outline0("LDA COPYOFCOLORMAPADDRESS");
172 outline0("SBC #40");
173 outline0("STA COPYOFCOLORMAPADDRESS");
174 outline0("LDA COPYOFCOLORMAPADDRESS+1");
175 outline0("SBC #0");
176 outline0("STA COPYOFCOLORMAPADDRESS+1");
177
178 outhead0("lib_cline_next:");
179 outline0("INY");
180 outline0("DEX");
181 outline0("BEQ lib_cline_increment_xx");
182 outline0("JMP lib_cline_increment_x");
183 outhead0("lib_cline_increment_xx:");
184 outline0("RTS");
185
186 outhead0("lib_cline_entire_line:");
187
188 outline0("LDY #0");
189
190 outhead0("lib_cline_increment2_x:");
191
192 outline0("LDA #32");
193 outline0("STA (COPYOFTEXTADDRESS),y");
194
195 outline0("INY"); // x
196 outline0("INC CLINEX"); // x
197 outline0("LDA CLINEX"); // x
198 outline0("CMP #40"); // x
199 outline0("BNE lib_cline_increment2_x"); // x
200 outline0("RTS");
201
202 outhead0("lib_cline_after:");
203
204 _environment->deployed.textCline = 1;
205
206 }
207
208 outline0("JSR lib_cline");
209
210}
Variable * variable_retrieve(Environment *_environment, char *_name)
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
void cline(Environment *_environment, char *_characters)
Emit code for CLINE ....
Definition cline.c:52
void text_vscroll_screen(Environment *_environment, int _direction, int _overlap)
int textCline
Definition ugbc.h:1807
Deployed deployed
Definition ugbc.h:2921
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
#define outhead0(s)
Definition ugbc.h:4246
#define outline0(s)
Definition ugbc.h:4252
#define outline1(s, a)
Definition ugbc.h:4253
@ TEXTADDRESS
Definition ugbc.tab.h:855