ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
put_image.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
41extern char DATATYPE_AS_STRING[][16];
42
53void put_image_vars( Environment * _environment, char * _image, char * _x1, char * _y1, char * _x2, char * _y2, char * _frame, char * _sequence, char * _flags ) {
54
55 if ( _environment->emptyProcedure ) {
56 return;
57 }
58
59 Variable * image = variable_retrieve( _environment, _image );
60
61 Resource * resource = build_resource_for_sequence( _environment, _image, _frame, _sequence );
62
63 Variable * x1 = variable_retrieve_or_define( _environment, _x1, VT_POSITION, 0 );
64 Variable * y1 = variable_retrieve_or_define( _environment, _y1, VT_POSITION, 0 );
65 Variable * flags = variable_retrieve_or_define( _environment, _flags, VT_WORD, 0 );
66 Variable * realFrame = NULL;
67 Variable * frame = NULL;
68 if ( _frame) {
69 frame = variable_retrieve_or_define( _environment, _frame, VT_BYTE, 0 );
70 }
71 Variable * sequence = NULL;
72 if ( _sequence) {
73 sequence = variable_retrieve_or_define( _environment, _sequence, VT_BYTE, 0 );
74 realFrame = frame;
75 }
76
77 switch( resource->type ) {
78 case VT_SEQUENCE:
79 if ( !sequence ) {
80 if ( !frame ) {
81 ef9345_put_image( _environment, resource, x1->realName, y1->realName, "", "", image->frameSize, image->frameCount, _flags );
82 } else {
83 ef9345_put_image( _environment, resource, x1->realName, y1->realName, frame->realName, "", image->frameSize, image->frameCount, _flags );
84 }
85 } else {
86 if ( !frame ) {
87 ef9345_put_image( _environment, resource, x1->realName, y1->realName, "", sequence->realName, image->frameSize, image->frameCount, _flags );
88 } else {
89 ef9345_put_image( _environment, resource, x1->realName, y1->realName, frame->realName, sequence->realName, image->frameSize, image->frameCount, _flags );
90 }
91 }
92 break;
93 case VT_IMAGES:
94
95 if ( sequence ) {
96 if ( image->strips ) {
97 realFrame = variable_temporary( _environment, VT_BYTE, "(real frame)" );
98 // outline0("PUSH HL");
99 // outline0("PUSH AF");
100 // outline1("LD HL, %sstrip", image->realName );
101 // outline1("LD A, (%s)", sequence->realName );
102 // outline0("SLA A" );
103 // outline0("LD E, A" );
104 // outline0("LD D, 0" );
105 // outline0("ADD HL, DE");
106 // outline0("LD A, (HL)");
107 // outline0("LD E, A");
108 // outline0("INC HL");
109 // outline0("LD A, (HL)");
110 // outline0("LD E, A");
111 // outline0("LD A, (DE)");
112 // outline0("LD L, A");
113 // outline0("INC DE");
114 // outline0("LD A, (DE)");
115 // outline0("LD H, A");
116 // outline1("LD A, (%s)", frame->realName );
117 // outline0("LD E, A" );
118 // outline0("LD D, 0" );
119 // outline0("ADD HL, DE");
120 // outline0("LD A, (HL)");
121 // outline1("LD (%s), A", realFrame->realName );
122 // outline0("POP AF");
123 // outline0("POP HL");
124 } else {
126 }
127 }
128
129 if ( !frame ) {
130 ef9345_put_image( _environment, resource, x1->realName, y1->realName, "", NULL, image->frameSize, 0, _flags );
131 } else {
132 ef9345_put_image( _environment, resource, x1->realName, y1->realName, frame->realName, NULL, image->frameSize, 0, _flags );
133 }
134 break;
135 case VT_IMAGE:
136 case VT_TARRAY:
137 ef9345_put_image( _environment, resource, x1->realName, y1->realName, NULL, NULL, 1, 0, _flags );
138 break;
139 default:
141 }
142}
143
144void put_image_vars_flags( Environment * _environment, char * _image, char * _x1, char * _y1, char * _x2, char * _y2, char * _frame, char * _sequence, int _flags ) {
145
146 char flagsConstantName[MAX_TEMPORARY_STORAGE]; sprintf( flagsConstantName, "PUTIMAGEFLAGS%4.4x", _flags );
147 char flagsConstantParameter[MAX_TEMPORARY_STORAGE]; sprintf( flagsConstantParameter, "PUTIMAGEFLAGS%4.4x", _flags );
148
149 Constant * flagsConstant = constant_find( _environment, flagsConstantName );
150
151 if ( !flagsConstant ) {
152 flagsConstant = malloc( sizeof( Constant ) );
153 memset( flagsConstant, 0, sizeof( Constant ) );
154 flagsConstant->name = strdup( flagsConstantName );
155 flagsConstant->realName = strdup( flagsConstantName );
156 flagsConstant->value = _flags;
157 flagsConstant->type = CT_INTEGER;
158 flagsConstant->next = _environment->constants;
159 _environment->constants = flagsConstant;
160 }
161
162 put_image_vars( _environment, _image, _x1, _y1, _x2, _y2, _frame, _sequence, flagsConstantParameter );
163}
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Resource * build_resource_for_sequence(Environment *_environment, char *_image, char *_frame, char *_sequence)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Constant * constant_find(Environment *_environment, char *_name)
int flags
Definition _optimizer.c:677
void put_image_vars_flags(Environment *_environment, char *_image, char *_x1, char *_y1, char *_x2, char *_y2, char *_frame, char *_sequence, int _flags)
Definition put_image.c:430
void put_image_vars(Environment *_environment, char *_image, char *_x1, char *_y1, char *_x2, char *_y2, char *_frame, char *_sequence, char *_flags)
Definition put_image.c:406
void ef9345_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
Definition ef9345.c:1070
char * name
Definition ugbc.h:800
int value
Definition ugbc.h:815
ConstantType type
Definition ugbc.h:805
struct _Constant * next
Definition ugbc.h:832
char * realName
Definition ugbc.h:803
Constant * constants
Definition ugbc.h:2611
int emptyProcedure
Definition ugbc.h:2932
VariableType type
Definition ugbc.h:559
Strip * strips
Definition ugbc.h:1215
char * name
Definition ugbc.h:979
VariableType type
Definition ugbc.h:988
int frameSize
Definition ugbc.h:1134
int frameCount
Definition ugbc.h:1137
char * realName
Definition ugbc.h:982
void * malloc(YYSIZE_T)
struct _Resource Resource
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
@ CT_INTEGER
Definition ugbc.h:788
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_TARRAY
Definition ugbc.h:480
@ VT_WORD
Definition ugbc.h:455
@ VT_POSITION
Definition ugbc.h:468
@ VT_BYTE
Definition ugbc.h:450
@ VT_IMAGES
Definition ugbc.h:495
@ VT_IMAGE
Definition ugbc.h:489
@ VT_SEQUENCE
Definition ugbc.h:513
struct _Constant Constant
Structure of a single constant.
#define CRITICAL_CANNOT_PUT_IMAGE_WITHOUT_STRIP(s)
Definition ugbc.h:3855
#define CRITICAL_PUT_IMAGE_UNSUPPORTED(v, t)
Definition ugbc.h:3532
char DATATYPE_AS_STRING[][16]