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#if defined(__coco__) || defined(__coco3__) || defined(__d32__) || defined(__d64__) || defined(__mo5__) || defined(__pc128op__) || defined(__to8__)
38
39/****************************************************************************
40 * CODE SECTION
41 ****************************************************************************/
42
43void flip_image_vars_direction( Environment * _environment, char * _image, char * _frame, char * _sequence, int _direction ) {
44
45 char directionConstantName[MAX_TEMPORARY_STORAGE]; sprintf( directionConstantName, "FLIPIMAGEDIRECTION%4.4x", _direction );
46 char directionConstantParameter[MAX_TEMPORARY_STORAGE]; sprintf( directionConstantParameter, "#FLIPIMAGEDIRECTION%4.4x", _direction );
47
48 Constant * directionConstant = constant_find( _environment, directionConstantName );
49
50 if ( !directionConstant ) {
51 directionConstant = malloc( sizeof( Constant ) );
52 memset( directionConstant, 0, sizeof( Constant ) );
53 directionConstant->name = strdup( directionConstantName );
54 directionConstant->realName = strdup( directionConstantName );
55 directionConstant->value = _direction;
56 directionConstant->type = CT_INTEGER;
57 directionConstant->next = _environment->constants;
58 _environment->constants = directionConstant;
59 }
60
61 flip_image_vars( _environment, _image, _frame, _sequence, directionConstantParameter );
62
63}
64
65void flip_image_vars_indirection( Environment * _environment, char * _image, char * _frame, char * _sequence, char * _direction ) {
66 Variable * direction = variable_retrieve_or_define( _environment, _direction, VT_BYTE, 0 );
67 flip_image_vars( _environment, _image, _frame, _sequence, direction->realName );
68}
69
70#endif
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Constant * constant_find(Environment *_environment, char *_name)
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
void flip_image_vars_indirection(Environment *_environment, char *_image, char *_frame, char *_sequence, char *_direction)
Definition flip_image.c:66
void flip_image_vars_direction(Environment *_environment, char *_image, char *_frame, char *_sequence, int _direction)
Definition flip_image.c:44
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
char * realName
Definition ugbc.h:982
void * malloc(YYSIZE_T)
#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_BYTE
Definition ugbc.h:450
struct _Constant Constant
Structure of a single constant.