ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
slice_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
43void slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, char * _destination ) {
44
45 Variable * image = variable_retrieve( _environment, _image );
46 Variable * destination = variable_retrieve( _environment, _destination );
47 Variable * frame = NULL;
48 if ( _frame) {
49 frame = variable_retrieve_or_define( _environment, _frame, VT_BYTE, 0 );
50 }
51 Variable * sequence = NULL;
52 if ( _sequence) {
53 sequence = variable_retrieve_or_define( _environment, _sequence, VT_BYTE, 0 );
54 }
55
56 CpcSliceImageFunction cpc_slice_image = NULL;;
57 if (
58 ! _environment->sliceImageX && ! _environment->sliceImageY
59 ) {
60 cpc_slice_image = cpc_slice_image_copy;
61 } else {
62 cpc_slice_image = cpc_slice_image_extract;
63 }
64
65 switch( image->type ) {
66 case VT_SEQUENCE:
67 if ( !sequence ) {
68 if ( !frame ) {
69 cpc_slice_image( _environment, image->realName, "", "", image->frameSize, image->frameCount, destination->realName );
70 } else {
71 cpc_slice_image( _environment, image->realName, frame->realName, "", image->frameSize, image->frameCount, destination->realName );
72 }
73 } else {
74 if ( !frame ) {
75 cpc_slice_image( _environment, image->realName, "", sequence->realName, image->frameSize, image->frameCount, destination->realName );
76 } else {
77 cpc_slice_image( _environment, image->realName, frame->realName, sequence->realName, image->frameSize, image->frameCount, destination->realName );
78 }
79 }
80 break;
81 case VT_IMAGES:
82 if ( !frame ) {
83 cpc_slice_image( _environment, image->realName, "", NULL, image->frameSize, 0, destination->realName );
84 } else {
85 cpc_slice_image( _environment, image->realName, frame->realName, NULL, image->frameSize, 0, destination->realName );
86 }
87 break;
88 case VT_IMAGE:
89 cpc_slice_image( _environment, image->realName, NULL, NULL, 0, 0, destination->realName );
90 break;
91 default:
93 }
94
95}
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
void slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, char *_destination)
Definition slice_image.c:43
void cpc_slice_image_extract(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition cpc.c:2502
void cpc_slice_image_copy(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition cpc.c:2482
void(* CpcSliceImageFunction)(Environment *, char *, char *, char *, int, int, char *)
Definition cpc.h:388
char * sliceImageX
Definition ugbc.h:3075
char * sliceImageY
Definition ugbc.h:3080
VariableType type
Definition ugbc.h:988
int frameSize
Definition ugbc.h:1134
int frameCount
Definition ugbc.h:1137
char * realName
Definition ugbc.h:982
#define CRITICAL_SLICE_IMAGE_UNSUPPORTED(v, t)
Definition ugbc.h:3656
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_BYTE
Definition ugbc.h:450
@ VT_IMAGES
Definition ugbc.h:495
@ VT_IMAGE
Definition ugbc.h:489
@ VT_SEQUENCE
Definition ugbc.h:513
char DATATYPE_AS_STRING[][16]