ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
flip_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
51 /* <usermanual>
52@keyword FLIP IMAGE
53
54@english
55This command allows you to flip an image on the same image,
56along the X axis or the Y axis.
57The programmer can flip a single image (''IMAGE''), a
58frame of a series of images (''IMAGES'') or a frame of a pose of a
59sequence of images (''SEQUENCES''). In all cases the syntax changes
60slightly.
61
62It is possible to flip an image either programmatically, directly indicating
63the ''X'' or ''Y'' direction, or by delegating these operations to the
64value of a variable. In this case, this value will be preceded by the
65''DIRECTION'' keyword. Acceptable values are ''1'' for the horizontal
66direction, ''2'' for the vertical direction, ''3'' for both directions.
67
68@italian
69Questa capovolge una immagine.
70Il programmatore può capovolgere una singola immagine
71(''IMAGE''), un frame di una serie di immagini (''IMAGES'') oppure
72un frame di una posa di una sequenza di immagini (''SEQUENCES'').
73In tutti i casi la sintassi cambia leggermente.
74
75E' possibile capovolgere una immagine sia in modo programmatico, indicando
76direttamente la direzione ''X'' oppure ''Y'', oppure delegando tale operazioni al
77valore di una variabile. In tal caso, tale valore andrà previsso dalla
78parola chiave ''DIRECTION''.
79
80I valori accettabili sono ''1'' per la direzione orizzontale, ''2'' per
81quella verticale, ''3'' per entrambe le direzioni.
82
83@syntax FLIP IMAGE resource [X|Y|XY|YX]
84@syntax FLIP IMAGE resource FRAME frame [X|Y|XY|YX]
85@syntax FLIP IMAGE resource STRIP sequence FRAME frame [X|Y|XY|YX]
86@syntax FLIP [X|Y|XY|YX] IMAGE resource
87@syntax FLIP [X|Y|XY|YX] IMAGE resource FRAME frame
88@syntax FLIP [X|Y|XY|YX] IMAGE resource STRIP sequence FRAME frame
89@syntax FLIP IMAGE resource DIRECTION direction
90@syntax FLIP IMAGE resource FRAME frame DIRECTION direction
91@syntax FLIP IMAGE resource STRIP sequence FRAME frame DIRECTION direction
92@syntax FLIP DIRECTION direction IMAGE resource
93@syntax FLIP DIRECTION direction IMAGE resource FRAME frame
94@syntax FLIP DIRECTION direction IMAGE resource STRIP sequence FRAME frame
95
96@example FLIP X IMAGE object
97
98@target c64
99</usermanual> */
100void flip_image_vars( Environment * _environment, char * _image, char * _frame, char * _sequence, char * _direction ) {
101
102 if ( _environment->emptyProcedure ) {
103 return;
104 }
105
106 Variable * image = variable_retrieve( _environment, _image );
107
108 if ( image->bankAssigned != -1 ) {
110 }
111
112 Resource * resource = build_resource_for_sequence( _environment, _image, _frame, _sequence );
113
114 Variable * frame = NULL;
115 if ( _frame) {
116 frame = variable_retrieve_or_define( _environment, _frame, VT_BYTE, 0 );
117 }
118 Variable * sequence = NULL;
119 if ( _sequence) {
120 sequence = variable_retrieve_or_define( _environment, _sequence, VT_BYTE, 0 );
121 }
122
123 switch( resource->type ) {
124 case VT_SEQUENCE:
125 if ( !sequence ) {
126 if ( !frame ) {
127 vic2_flip_image( _environment, resource, "", "", image->frameSize, image->frameCount, _direction );
128 } else {
129 vic2_flip_image( _environment, resource, "", frame->realName, image->frameSize, image->frameCount, _direction );
130 }
131 } else {
132 if ( !frame ) {
133 vic2_flip_image( _environment, resource, "", sequence->realName, image->frameSize, image->frameCount, _direction );
134 } else {
135 vic2_flip_image( _environment, resource, frame->realName, sequence->realName, image->frameSize, image->frameCount, _direction );
136 }
137 }
138 break;
139 case VT_IMAGES:
140 if ( !frame ) {
141 vic2_flip_image( _environment, resource, "", NULL, image->frameSize, 0, _direction );
142 } else {
143 vic2_flip_image( _environment, resource, frame->realName, NULL, image->frameSize, 0, _direction );
144 }
145 break;
146 case VT_IMAGE:
147 case VT_TARRAY:
148 vic2_flip_image( _environment, resource, NULL, NULL, 0, 0, _direction );
149 break;
150 default:
152 }
153
154
155}
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)
void flip_image_vars(Environment *_environment, char *_image, char *_frame, char *_sequence, char *_direction)
Emit ASM code for FLIP IMAGE X/Y/XY/YX [image].
Definition flip_image.c:56
int emptyProcedure
Definition ugbc.h:2932
VariableType type
Definition ugbc.h:559
int bankAssigned
Definition ugbc.h:1172
VariableType type
Definition ugbc.h:988
int frameSize
Definition ugbc.h:1134
int frameCount
Definition ugbc.h:1137
char * realName
Definition ugbc.h:982
struct _Resource Resource
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_TARRAY
Definition ugbc.h:480
@ VT_BYTE
Definition ugbc.h:450
@ VT_IMAGES
Definition ugbc.h:495
@ VT_IMAGE
Definition ugbc.h:489
@ VT_SEQUENCE
Definition ugbc.h:513
#define CRITICAL_CANNOT_FLIP_BANKED_IMAGE(v)
Definition ugbc.h:3724
#define CRITICAL_FLIP_IMAGE_UNSUPPORTED(v, t)
Definition ugbc.h:3723
char DATATYPE_AS_STRING[][16]
void vic2_flip_image(Environment *_environment, Resource *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_direction)
Definition vic2.c:4388