ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
remember.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 REMEMBER
43
44@english
45The ''REMEMBER'' command restores the cursor position previously stored by
46the ''MEMORIZE'' command. The ''REMEMBER'' command can be executed multiple
47times, and this will restore the cursor position to the last stored position.
48Note that the stored position refers to the current console. If there are no
49consoles defined, one equal to full screen will be defined.
50
51@italian
52Il comando ''REMEMBER'' ripristina la posizione del cursore precedentemente
53memorizzata dal comando ''MEMORIZE''. Il comando ''REMEMBER'' può essere
54eseguito più volte, e questo ripristinerà la posizione del cursore alla
55posizione memorizzata per ultima. Da notare che la posizione memorizzata
56è riferita alla console attuale. Se non vi sono console definite, ne
57sarà definita una pari allo schermo intero.
58
59@syntax REMEMBER
60
61@example REMEMBER
62
63@usedInExample texts_tracking_02.bas
64
65@seeAlso MEMORIZE
66@target all
67</usermanual> */
68void remember( Environment * _environment ) {
69
71
73
74 char doNothingLabel2[MAX_TEMPORARY_STORAGE];
75 sprintf( doNothingLabel2, "%sdonothing", label );
76
77 cpu_compare_and_branch_8bit_const( _environment, "CONSOLEID", 0xff, doNothingLabel2, 0 );
78 console( _environment, 0, 0, _environment->screenTilesWidth - 1, _environment->screenTilesHeight - 1 );
79 console_save( _environment, 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 * actualNumber = variable_temporary( _environment, VT_BYTE, 0 );
89 cpu_move_8bit( _environment, "CONSOLEID", actualNumber->realName );
90 cpu_math_mul2_const_8bit( _environment, actualNumber->realName, 1, 0 );
91 cpu_math_add_16bit_with_8bit( _environment, address->realName, actualNumber->realName, address->realName );
92
93 cpu_move_8bit_indirect2( _environment, address->realName, xcursys->realName );
94 cpu_inc_16bit( _environment, address->realName );
95 cpu_move_8bit_indirect2( _environment, address->realName, ycursys->realName );
96
97 cpu_return( _environment );
98
100
101 cpu_call( _environment, "lib_remember");
102
103}
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_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_return(Environment *_environment)
Definition 6309.c:4030
void cpu_move_8bit_indirect2(Environment *_environment, char *_value, char *_source)
Definition 6309.c:5294
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 console(Environment *_environment, int _x1, int _y1, int _x2, int _y2)
Emit code for CONSOLE.
Definition console.c:118
void console_save(Environment *_environment, int _number)
Emit code for CONSOLE.
void remember(Environment *_environment)
Definition remember.c:68
int screenTilesWidth
Definition ugbc.h:2880
int screenTilesHeight
Definition ugbc.h:2885
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