ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
memorize.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
41/* <usermanual>
42@keyword MEMORIZE
43
44@english
45The ''MEMORIZE'' command allows you to store the current position of the cursor,
46in terms of coordinates, relative to the current console. The cursor coordinates
47can be restored with the ''REMEMBER'' command. Note that the two commands operate on
48the current console. If there are no consoles defined, using this method implicitly
49defines ''CONSOLE 0'' as the entire screen.
50
51@italian
52Il comando ''MEMORIZE'' permette di memorizzare l'attuale posizione del cursore,
53in termini di coordinate, relativo alla console attuale. Le coordinate del cursorse
54possono essere ripristinate con il comando ''REMEMBER''. Da notare che i due comandi
55operano sulla console attuale. Se non vi sono console definite, usare questo metodo
56definisce in modo implicito la ''CONSOLE 0''.
57
58@syntax MEMORIZE
59
60@example MEMORIZE
61
62@usedInExample texts_tracking_02.bas
63
64@seeAlso REMEMBER
65</usermanual> */
66
67void memorize( Environment * _environment ) {
68
70
72
73 char doNothingLabel2[MAX_TEMPORARY_STORAGE];
74 sprintf( doNothingLabel2, "%sdonothing", label );
75
76 cpu_compare_and_branch_8bit_const( _environment, "CONSOLEID", 0xff, doNothingLabel2, 0 );
77 // console( _environment, 0, 0, _environment->screenTilesWidth - 1, _environment->screenTilesHeight - 1 );
78 // console_save( _environment, 0 );
79 cpu_store_8bit( _environment, "CONSOLEID", 0 );
80 cpu_label( _environment, doNothingLabel2 );
81
82 Variable * xcursys = variable_retrieve( _environment, "XCURSYS" );
83 Variable * ycursys = variable_retrieve( _environment, "YCURSYS" );
84
85 Variable * address = variable_temporary( _environment, VT_ADDRESS, "(consoles)" );
86 cpu_addressof_16bit( _environment, "CONSOLES2", address->realName );
87
88 Variable * displacement = variable_temporary( _environment, VT_BYTE, "(displacement)" );
89
90 cpu_move_8bit( _environment, "CONSOLEID", displacement->realName );
91 cpu_math_mul2_const_8bit( _environment, displacement->realName, 1, 0 );
92 cpu_math_add_16bit_with_8bit( _environment, address->realName, displacement->realName, address->realName );
93
94 cpu_move_8bit_indirect( _environment, xcursys->realName, address->realName );
95 cpu_inc_16bit( _environment, address->realName );
96 cpu_move_8bit_indirect( _environment, ycursys->realName, address->realName );
97
98 cpu_return( _environment );
99
101
102 cpu_call( _environment, "lib_memorize");
103
104}
void cpu_math_mul2_const_8bit(Environment *_environment, char *_source, int _steps, int _signed)
CPU 6309: emit code to double for several times a 8 bit value
Definition 6309.c:1397
void cpu_math_add_16bit_with_8bit(Environment *_environment, char *_source, char *_destination, char *_other)
Definition 6309.c:1708
void cpu_move_8bit_indirect(Environment *_environment, char *_source, char *_value)
Definition 6309.c:5239
void cpu_addressof_16bit(Environment *_environment, char *_source, char *_destination)
Definition 6309.c:1485
void cpu_label(Environment *_environment, char *_label)
Definition 6309.c:356
void cpu_call(Environment *_environment, char *_label)
Definition 6309.c:3755
void cpu_store_8bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 8 bit
Definition 6309.c:761
void cpu_return(Environment *_environment)
Definition 6309.c:4030
void cpu_inc_16bit(Environment *_environment, char *_variable)
Definition 6309.c:4565
void cpu_move_8bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 8 bit
Definition 6309.c:743
void cpu_compare_and_branch_8bit_const(Environment *_environment, char *_source, int _destination, char *_label, int _positive)
CPU 6309: emit code to compare two 8 bit values and jump if they are equal/different
Definition 6309.c:876
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
void memorize(Environment *_environment)
Definition memorize.c:67
char * realName
Definition ugbc.h:982
#define deploy_end(s)
Definition ugbc.h:4365
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_BYTE
Definition ugbc.h:450
@ VT_ADDRESS
Definition ugbc.h:465
#define deploy_begin(s)
Definition ugbc.h:4356
#define MAKE_LABEL
Definition ugbc.h:3351