ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
images_load_from_buffer.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *----------------------------------------------------------------------------
16 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
17 * (la "Licenza"); è proibito usare questo file se non in conformità alla
18 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
23 * il software distribuito nei termini della Licenza è distribuito
24 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
25 * implicite. Consultare la Licenza per il testo specifico che regola le
26 * autorizzazioni e le limitazioni previste dalla medesima.
27 ****************************************************************************/
28
29/****************************************************************************
30 * INCLUDE SECTION
31 ****************************************************************************/
32
33#include "../../ugbc.h"
35#include "../../libs/msc1.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
48Variable * images_load_from_buffer( Environment * _environment, char * _buffer, int _buffer_size ) {
49
50 Variable * final = variable_temporary( _environment, VT_IMAGES, 0 );
51
52 if ( _environment->emptyProcedure ) {
53 return final;
54 }
55
56 int frames = _buffer[0];
57
58 int frame_width = 0;
59 int frame_height = 0;
60
61 IMAGE_GET_WIDTH( _buffer, 3, frame_width );
62 IMAGE_GET_HEIGHT( _buffer, 3, frame_height );
63
64 int size = image_size( _environment, frame_width, frame_height );
65
66 if ( ( size * frames ) > 0xffff ) {
68 }
69
70 final->offsettingFrames = offsetting_size_count( _environment, size, frames );
71 offsetting_add_variable_reference( _environment, final->offsettingFrames, final, 0 );
72
73 variable_store_buffer( _environment, final->name, _buffer, _buffer_size, 0 );
74 final->frameWidth = frame_width;
75 final->frameHeight = frame_height;
76 final->frameSize = size;
77 final->frameCount = frames;
78
79 final->readonly = 1;
80
81 return final;
82
83}
void offsetting_add_variable_reference(Environment *_environment, Offsetting *_first, Variable *_var, int _sequence)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Offsetting * offsetting_size_count(Environment *_environment, int _size, int _count)
Variable * variable_store_buffer(Environment *_environment, char *_destination, unsigned char *_buffer, int _size, int _at)
int size
Definition _optimizer.c:678
int image_size(Environment *_environment, int _width, int _height)
Definition image_size.c:41
int frames(Environment *_environment, char *_image)
Emit code for FRAMES(...).
Definition frames.c:160
Variable * images_load_from_buffer(Environment *_environment, char *_buffer, int _buffer_size)
Emit code for (IMAGES)#[...].
int emptyProcedure
Definition ugbc.h:2932
#define IMAGE_GET_WIDTH(buffer, offset, width)
Definition ugbc.h:6498
struct _Variable Variable
Structure of a single variable.
#define CRITICAL_IMAGES_LOAD_IMAGE_BUFFER_TOO_BIG()
Definition ugbc.h:3706
struct _Environment Environment
Structure of compilation environment.
@ VT_IMAGES
Definition ugbc.h:495
#define IMAGE_GET_HEIGHT(buffer, offset, height)
Definition ugbc.h:6504