ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
screen_horizontal_scroll.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
53/* <usermanual>
54@keyword SCREEN HORIZONTAL SCROLL
55
56@english
57
58The ''SCREEN HORIZONTAL SCROLL'' command is designed to scroll the screen
59horizontally, but its interpretation and the meaning of the parameter supplied
60vary significantly depending on the hardware platform on which the program is
61running. This peculiarity makes it essential to understand the specifics of each
62system to correctly use this command and achieve the desired effect.
63
64On Commodore computers, the numeric parameter supplied to the
65''SCREEN HORIZONTAL SCROLL'' command takes integer values between 0 and 7.
66In this range, the value 4 represents the center position of the scroll.
67Values less than 4 move the screen content to the left, while values greater
68than 4 move it to the right. The amount of scrolling is proportional to the
69distance from the center value of 4. For example, a value of 0 or 7 will
70produce maximum scrolling to the left or right, respectively, while a value
71of 3 will cause a slight shift to the left of the center.
72
73The ''SCREEN HORIZONTAL SCROLL'' command behaves differently on the TRS-80
74Color Computer 3. On this platform, the numeric parameter indicates the starting
75position of the screen. A value of 0 specifies that the display begins at the
76leftmost available column. As the parameter value increases, the screen is
77progressively moved to the left, revealing portions of the screen that were
78previously located to the right of the visible area. In other words, a larger parameter
79value causes the displayed content to scroll to the left, revealing what was
80beyond the right edge of the screen. This approach is more intuitive for those
81who expect an increasing value to correspond to a movement in a specific direction.
82
83This divergence in the semantics of the ''SCREEN HORIZONTAL SCROLL'' command across
84platforms highlights one of the inherent challenges in developing cross-platform
85software such as ugBASIC. The developer must be aware of the target machine in
86order to properly use this command and achieve the desired horizontal scrolling
87effect. Often, in ugBASIC programs that aim for cross-platform compatibility,
88conditional procedures (''PROCEDURE ... ON target'') are used to apply different
89parameter values to the ''SCREEN HORIZONTAL SCROLL'' command, adapting the behavior
90to the specifics of each system and thus ensuring a consistent user experience
91or desired visual effect on each machine.
92
93@italian
94
95Il comando ''SCREEN HORIZONTAL SCROLL'' è progettato per scorrere lo schermo in orizzontale, ma la sua interpretazione e il significato del parametro fornito variano significativamente a seconda della piattaforma hardware su cui il programma viene eseguito. Questa peculiarità rende essenziale comprendere le specifiche di ciascun sistema per utilizzare correttamente questo comando e ottenere l'effetto desiderato.
96
97Sui computer Commodore, il parametro numerico fornito al comando ''SCREEN HORIZONTAL SCROLL'' accetta valori interi compresi tra 0 e 7.
98In questo intervallo, il valore 4 rappresenta la posizione centrale dello scorrimento.
99Valori inferiori a 4 spostano il contenuto dello schermo a sinistra, mentre valori superiori a 4 lo spostano a destra. La quantità di scorrimento è proporzionale alla distanza dal centro, pari a 4. Ad esempio, un valore pari a 0 o 7 produrrà il massimo scorrimento rispettivamente a sinistra o a destra, mentre un valore pari a 3 causerà un leggero spostamento a sinistra rispetto al centro. Il comando ''SCREEN HORIZONTAL SCROLL'' si comporta diversamente sul computer a colori TRS-80 3. Su questa piattaforma, il parametro numerico indica la posizione iniziale dello schermo. Un valore pari a 0 specifica che la visualizzazione inizia dalla colonna disponibile più a sinistra. All'aumentare del valore del parametro, lo schermo viene progressivamente spostato a sinistra, rivelando parti dello schermo che in precedenza si trovavano a destra dell'area visibile. In altre parole, un valore del parametro maggiore fa scorrere il contenuto visualizzato verso sinistra, rivelando ciò che si trovava oltre il bordo destro dello schermo. Questo approccio è più intuitivo per coloro che si aspettano che un valore crescente corrisponda a un movimento in una direzione specifica. Questa divergenza nella semantica del comando ''SCREEN HORIZONTAL SCROLL'' tra le diverse piattaforme evidenzia una delle sfide intrinseche nello sviluppo di software multipiattaforma come ugBASIC. Lo sviluppatore deve conoscere il computer di destinazione per utilizzare correttamente questo comando e ottenere l'effetto di scorrimento orizzontale desiderato. Spesso, nei programmi ugBASIC che mirano alla compatibilità multipiattaforma, vengono utilizzate procedure condizionali (''PROCEDURE ... ON target'') per applicare diversi valori di parametro al comando ''SCREEN HORIZONTAL SCROLL'', adattandone il comportamento alle specifiche di ciascun sistema e garantendo così un'esperienza utente coerente o l'effetto visivo desiderato su ogni macchina.
100
101@syntax SCREEN HORIZONTAL SCROLL offset
102
103@example SCREEN HORIZONTAL SCROLL 3
104
105@target c128
106@target c128
107@target c128reu
108@target coco3
109
110</usermanual> */
111void screen_horizontal_scroll( Environment * _environment, int _displacement ) {
112
113 char displacementString[MAX_TEMPORARY_STORAGE]; sprintf( displacementString, "#$%2.2x", _displacement );
114
115 vic2_horizontal_scroll( _environment, displacementString );
116
117}
118
131void screen_horizontal_scroll_var( Environment * _environment, char * _displacement ) {
132
133
134
135 Variable * displacement = variable_retrieve( _environment, _displacement );
136
137 vic2_horizontal_scroll( _environment, displacement->realName );
138
139}
Variable * variable_retrieve(Environment *_environment, char *_name)
void screen_horizontal_scroll_var(Environment *_environment, char *_displacement)
Emit ASM code for SCREEN HORIZONTAL SCROLL [expression[.
void screen_horizontal_scroll(Environment *_environment, int _displacement)
Emit ASM code for SCREEN HORIZONTAL SCROLL [int]x.
char * realName
Definition ugbc.h:982
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
void vic2_horizontal_scroll(Environment *_environment, char *_displacement)
Definition vic2.c:2016