ugBASIC
1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
image_ref.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
41
#if defined(__atari__) || defined(__atarixl__)
42
43
Variable
*
image_ref
(
Environment
* _environment,
char
* _image ) {
44
45
Variable
* image =
variable_retrieve
( _environment, _image );
46
47
Variable
* imageRef =
variable_temporary
( _environment,
VT_IMAGEREF
,
"(imageref)"
);
48
49
image->
usedImage
= 1;
50
51
switch
( image->
type
) {
52
case
VT_IMAGE
:
53
54
// BASE
55
56
outline1
(
"LDA #<%s"
, image->
realName
);
57
outline1
(
"STA %s"
, imageRef->
realName
);
58
outline1
(
"LDA #>%s"
, image->
realName
);
59
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"1"
) );
60
61
// SIZE
62
63
outline1
(
"LDA #$%2.2x"
, (
unsigned
char
)( image->
frameSize
& 0xff ) );
64
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"2"
) );
65
outline1
(
"LDA #$%2.2x"
, (
unsigned
char
)( ( image->
frameSize
>> 8 ) & 0xff ) );
66
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"3"
) );
67
68
// BANK
69
70
// outline1( "LDA #$%2.2x", image->bankAssigned );
71
// outline1( "STA %s+4", imageRef->realName );
72
73
// INFO
74
75
outline0
(
"LDA #$03"
);
76
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"5"
) );
77
78
// RESIDENT
79
80
// char bankWindowName[MAX_TEMPORARY_STORAGE];
81
// sprintf( bankWindowName, "BANKWINDOW%2.2x", image->residentAssigned );
82
83
// outline1( "LDX #%s", bankWindowName );
84
// outline1( "STX %s+6", imageRef->realName );
85
86
// TABLE1
87
88
// outline1( "LDX #%soffsetframe", image->realName );
89
// outline1( "STX %s+8", imageRef->realName );
90
91
// TABLE2
92
93
// outline1( "LDX #%soffsetsequence", image->realName );
94
// outline1( "STX %s+10", imageRef->realName );
95
96
break
;
97
98
case
VT_IMAGES
:
99
100
// BASE
101
102
outline1
(
"LDA #<%s"
, image->
realName
);
103
outline1
(
"STA %s"
, imageRef->
realName
);
104
outline1
(
"LDA #>%s"
, image->
realName
);
105
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"1"
) );
106
107
// SIZE
108
109
outline1
(
"LDA #$%2.2x"
, (
unsigned
char
)( image->
frameSize
& 0xff ) );
110
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"2"
) );
111
outline1
(
"LDA #$%2.2x"
, (
unsigned
char
)( ( image->
frameSize
>> 8 ) & 0xff ) );
112
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"3"
) );
113
114
// BANK
115
116
// outline1( "LDA #$%2.2x", image->bankAssigned );
117
// outline1( "STA %s+4", imageRef->realName );
118
119
// INFO
120
121
outline0
(
"LDA #$13"
);
122
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"5"
) );
123
124
// RESIDENT
125
126
// char bankWindowName[MAX_TEMPORARY_STORAGE];
127
// sprintf( bankWindowName, "BANKWINDOW%2.2x", image->residentAssigned );
128
129
// outline1( "LDX #%s", bankWindowName );
130
// outline1( "STX %s+6", imageRef->realName );
131
132
// TABLE1
133
134
outline1
(
"LDA #<%soffsetframe"
, image->
realName
);
135
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"8"
) );
136
outline1
(
"LDA #>%soffsetframe"
, image->
realName
);
137
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"9"
) );
138
139
// TABLE2
140
141
// outline1( "LDX #%soffsetsequence", image->realName );
142
// outline1( "STX %s+10", imageRef->realName );
143
144
break
;
145
146
case
VT_SEQUENCE
:
147
148
// BASE
149
150
outline1
(
"LDA #<%s"
, image->
realName
);
151
outline1
(
"STA %s"
, imageRef->
realName
);
152
outline1
(
"LDA #>%s"
, image->
realName
);
153
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"1"
) );
154
155
// SIZE
156
157
outline1
(
"LDA #$%2.2x"
, (
unsigned
char
)( image->
frameSize
& 0xff ) );
158
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"2"
) );
159
outline1
(
"LDA #$%2.2x"
, (
unsigned
char
)( ( image->
frameSize
>> 8 ) & 0xff ) );
160
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"3"
) );
161
162
// BANK
163
164
// outline1( "LDA #$%2.2x", image->bankAssigned );
165
// outline1( "STA %s+4", imageRef->realName );
166
167
// INFO
168
169
outline0
(
"LDA #$13"
);
170
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"5"
) );
171
172
// RESIDENT
173
174
// char bankWindowName[MAX_TEMPORARY_STORAGE];
175
// sprintf( bankWindowName, "BANKWINDOW%2.2x", image->residentAssigned );
176
177
// outline1( "LDX #%s", bankWindowName );
178
// outline1( "STX %s+6", imageRef->realName );
179
180
// TABLE1
181
182
outline1
(
"LDA #<%soffsetframe"
, image->
realName
);
183
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"8"
) );
184
outline1
(
"LDA #>%soffsetframe"
, image->
realName
);
185
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"9"
) );
186
187
// TABLE2
188
189
outline1
(
"LDA #<%soffsetsequence"
, image->
realName
);
190
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"10"
) );
191
outline1
(
"LDA #>%soffsetsequence"
, image->
realName
);
192
outline1
(
"STA %s"
,
address_displacement
( _environment, imageRef->
realName
,
"11"
) );
193
194
break
;
195
196
default
:
197
CRITICAL_IMAGEREF_ON_NON_IMAGE
( _image );
198
}
199
200
// FRAME WIDTH
201
outline1
(
"LDA #$%2.2x"
, image->
frameWidth
);
202
outline1
(
"STA %s+12"
, imageRef->
realName
);
203
204
// FRAME WIDTH
205
outline1
(
"LDA #$%2.2x"
, image->
frameHeight
);
206
outline1
(
"STA %s+13"
, imageRef->
realName
);
207
208
return
imageRef;
209
210
}
211
212
#endif
variable_retrieve
Variable * variable_retrieve(Environment *_environment, char *_name)
Definition
_infrastructure.c:988
variable_temporary
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Definition
_infrastructure.c:1388
address_displacement
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
Definition
_infrastructure.c:14516
image_ref
Variable * image_ref(Environment *_environment, char *_image)
Definition
image_ref.c:43
_Variable::usedImage
int usedImage
Definition
ugbc.h:1220
_Variable::type
VariableType type
Definition
ugbc.h:988
_Variable::frameSize
int frameSize
Definition
ugbc.h:1134
_Variable::frameWidth
int frameWidth
Definition
ugbc.h:1162
_Variable::frameHeight
int frameHeight
Definition
ugbc.h:1164
_Variable::realName
char * realName
Definition
ugbc.h:982
ugbc.h
CRITICAL_IMAGEREF_ON_NON_IMAGE
#define CRITICAL_IMAGEREF_ON_NON_IMAGE(v)
Definition
ugbc.h:3755
Variable
struct _Variable Variable
Structure of a single variable.
Environment
struct _Environment Environment
Structure of compilation environment.
VT_IMAGEREF
@ VT_IMAGEREF
Definition
ugbc.h:537
VT_IMAGES
@ VT_IMAGES
Definition
ugbc.h:495
VT_IMAGE
@ VT_IMAGE
Definition
ugbc.h:489
VT_SEQUENCE
@ VT_SEQUENCE
Definition
ugbc.h:513
outline0
#define outline0(s)
Definition
ugbc.h:4252
outline1
#define outline1(s, a)
Definition
ugbc.h:4253
Z:
ugbasic
ugbc
src
targets
common
gtia
image_ref.c
Generated by
1.16.1