ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
vdcz.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#if defined(__c128z__)
36
37#include "../ugbc.h"
38#include <math.h>
39
40static RGBi SYSTEM_PALETTE[] = {
41 { 0x00, 0x00, 0x00, 0xFF, 0, "BLACK" },
42 { 0x22, 0x22, 0x22, 0xFF, 1, "LIGHT BLACK" },
43 { 0x00, 0x00, 0x88, 0xFF, 2, "DARK BLUE" },
44 { 0x00, 0x00, 0xFF, 0xFF, 3, "LIGHT BLUE" },
45 { 0x00, 0x88, 0x00, 0xFF, 4, "DARK GREEN" },
46 { 0x00, 0xFF, 0x00, 0xFF, 5, "LIGHT GREEN" },
47 { 0x00, 0x88, 0x88, 0xFF, 6, "DARK CYAN" },
48 { 0x00, 0xFF, 0xFF, 0xFF, 7, "LIGHT CYAN" },
49 { 0x88, 0x00, 0x00, 0xFF, 8, "DARK RED" },
50 { 0xFF, 0x00, 0x00, 0xFF, 9, "LIGHT RED" },
51 { 0x80, 0x40, 0x80, 0xFF, 10, "DARK PURPLE" },
52 { 0xFF, 0x80, 0xFF, 0xFF, 11, "LIGHT PURPLE" },
53 { 0x80, 0x80, 0x40, 0xFF, 12, "DARK YELLOW" },
54 { 0xFF, 0xFF, 0x80, 0xFF, 13, "LIGHT YELLOW" },
55 { 0x80, 0x80, 0x80, 0xFF, 14, "DARK WHITE" },
56 { 0xFF, 0xFF, 0xFF, 0xFF, 15, "LIGHT WHITE" },
57};
58
59static RGBi * commonPalette;
61
62/****************************************************************************
63 * CODE SECTION
64 ****************************************************************************/
65
67
68 unsigned int minDistance = 0xffff;
69 int colorIndex = 0;
70 for (int j = 0; j < COLOR_COUNT; ++j) {
71 int distance = rgbi_distance(&SYSTEM_PALETTE[j], _color);
72 if (distance < minDistance) {
73 minDistance = distance;
74 colorIndex = j;
75 }
76 }
77
78 return &SYSTEM_PALETTE[colorIndex];
79
80}
81
82int vdcz_image_size( Environment * _environment, int _width, int _height, int _mode ) {
83
84 switch( _mode ) {
87 return 3 + ( ( _width >> 3 ) * _height ) + 1;
90 return 3 + ( ( _width >> 3 ) * _height ) + ( ( _width >> 3 ) * ( _height >> 3 ) );
91 }
92 return 0;
93
94}
95
96static Variable * vcdz_image_converter_bitmap_mode_standard( Environment * _environment, char * _source, int _width, int _height, int _depth, int _offset_x, int _offset_y, int _frame_width, int _frame_height, int _transparent_color, int _flags ) {
97
98 // ignored on bitmap mode
99 (void)!_transparent_color;
100
101 image_converter_asserts_free_height( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8 );
102
103 if ( _environment->freeImageWidth ) {
104 if ( _width % 8 ) {
105 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
106 }
107 if ( _frame_width % 8 ) {
108 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
109 }
110 }
111
112 RGBi * palette = malloc_palette( MAX_PALETTE );
113
114 int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
115
116 if (paletteColorCount > 2) {
117 CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
118 }
119
120 int i, j, k;
121
122 commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) );
123 commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
124 lastUsedSlotInCommonPalette = paletteColorCount;
125 adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
126 adilinepalette( "CPMS:%ld", sizeof(SYSTEM_PALETTE) / sizeof(RGBi), SYSTEM_PALETTE );
127
128 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
130 memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
131
132 int bufferSize = vdcz_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_STANDARD );
133 // printf("bufferSize = %d\n", bufferSize );
134
135 adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_STANDARD );
136
137 char * buffer = malloc ( bufferSize );
138 memset( buffer, 0, bufferSize );
139
140 // Position of the pixel in the original image
141 int image_x, image_y;
142
143 // Position of the pixel, in terms of tiles
144 int tile_x, tile_y;
145
146 // Position of the pixel, in terms of offset and bitmask
147 int offset, bitmask;
148
149 // Color of the pixel to convert
150 RGBi rgb;
151
152 *(buffer) = (_frame_width & 0XFF );
153 *(buffer+1) = ( (_frame_width>>8) & 0XFF );
154 *(buffer+2) = _frame_height;
155
156 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
157
158 adilinebeginbitmap("BMD");
159
160 int colorIndex = 0;
161
162 // Loop for all the source surface.
163 for (image_y = 0; image_y < _frame_height; ++image_y) {
164 for (image_x = 0; image_x < _frame_width; ++image_x) {
165
166 // Take the color of the pixel
167 rgb.red = *_source;
168 rgb.green = *(_source + 1);
169 rgb.blue = *(_source + 2);
170 if ( _depth > 3 ) {
171 rgb.alpha = *(_source + 3);
172 } else {
173 rgb.alpha = 255;
174 }
175 if ( rgb.alpha == 0 ) {
176 rgb.red = 0;
177 rgb.green = 0;
178 rgb.blue = 0;
179 }
180
181 int minDistance = 9999;
182 for( int i=0; i<2; ++i ) {
183 int distance = rgbi_distance(&commonPalette[i], &rgb );
184 if ( distance < minDistance ) {
185 minDistance = distance;
186 colorIndex = commonPalette[i].index;
187 }
188 }
189
190 offset = ( image_y * ( _frame_width >> 3 ) ) + ( image_x >> 3 );
191 bitmask = 1 << ( 7 - (image_x & 0x7) );
192
193 if ( colorIndex == commonPalette[1].index) {
194 *( buffer + offset + 3) |= bitmask;
195 } else {
196 *( buffer + offset + 3) &= ~bitmask;
197 }
198
199 adilinepixel(colorIndex);
200
201 _source += _depth;
202
203 }
204
205 _source += ( _width - _frame_width ) * _depth;
206
207 // printf("\n" );
208
209 }
210
211 *( buffer + 3 + ( ( _frame_width >> 3 ) * _frame_height ) ) = ( commonPalette[1].index << 4 ) | commonPalette[0].index;
212
214
215 // printf("----\n");
216
217 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
218
219 // printf("----\n");
220
221 return result;
222
223}
224
235static void vdcz_image_converter_tile( Environment * _environment, char * _source, char * _dest, int _width, int _depth, int _source_width ) {
236
237 int colorIndexesCount[COLOR_COUNT];
238 memset(colorIndexesCount, 0, COLOR_COUNT * sizeof( int ) );
239 int trans = 0;
240
241 char * source = _source;
242
243 // Clear the colors
244 *_dest = 0;
245
246 // Loop for all the box surface
247 for (int y=0; y<8; ++y) {
248 for (int x=0; x<8; ++x) {
249
250 RGBi rgb;
251
252 memset( &rgb, 0, sizeof( RGBi ) );
253
254 // Take the color of the pixel
255 rgb.red = *source;
256 rgb.green = *(source + 1);
257 rgb.blue = *(source + 2);
258 if ( _depth > 3 ) {
259 rgb.alpha = *(_source + 3);
260 } else {
261 rgb.alpha = 255;
262 }
263 if ( rgb.alpha == 0 ) {
264 rgb.red = 0;
265 rgb.green = 0;
266 rgb.blue = 0;
267 }
268
269 if ( rgb.alpha < 255 ) {
270 trans = 1;
271 } else {
272 RGBi *systemRgb = vdcz_image_nearest_system_color( &rgb );
273 ++colorIndexesCount[systemRgb->index];
274 }
275
276 source += _depth;
277
278 }
279
280 source += _depth * ( _source_width - 8 );
281
282 }
283
284 int colorBackground = 0;
285 int colorBackgroundMax = 0;
286 int colorForeground = 0;
287 int colorForegroundMax = 0;
288 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
289 if ( colorIndexesCount[xx] > colorBackgroundMax ) {
290 colorBackground = xx;
291 colorBackgroundMax = colorIndexesCount[xx];
292 };
293 }
294
295 colorIndexesCount[colorBackground] = 0;
296
297 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
298 if ( colorIndexesCount[xx] > colorForegroundMax ) {
299 colorForeground = xx;
300 colorForegroundMax = colorIndexesCount[xx];
301 };
302 }
303
304 if ( trans ) {
305 if ( colorForeground == 0 ) {
306 colorForeground = colorBackground;
307 colorBackground = 0;
308 } else {
309 colorBackground = 0;
310 }
311 }
312
313 if ( colorForeground == colorBackground ) {
314 colorForeground = ( colorBackground == 0 ) ? 1 : 0;
315 }
316
317 *( _dest ) = ( colorForeground << 4 ) | colorBackground ;
318
319}
320
332static void vdcz_image_converter_tiles( Environment * _environment, char * _source, char * _dest, int _width, int _height, int _depth, int _source_width ) {
333
334 int bitmapSize = ( _width>>3 ) * _height;
335 int colormapSize = ( _width>>3 ) * (_height>>3);
336
337 char * destBitmap = _dest;
338 char * destColormap = _dest + bitmapSize;
339
340 memset( _dest, 0, bitmapSize + colormapSize );
341
342 adilinebeginbitmap("BMD3");
343
344 for( int y=0; y<_height; y+=8 ) {
345 for( int x=0; x<_width; x+=8 ) {
346
347 char * source = _source + ( ( y * _source_width ) + x ) * _depth;
348 char tile;
349
350 vdcz_image_converter_tile( _environment, source, &tile, _width, _depth, _source_width );
351
352 int offset = ((y>>3) * 8 *( _width >> 3 ) ) + ((x>>3) * 8) + ((y) & 0x07);
353
354 destColormap[offset] = tile;
355 }
356 }
357
358 // Color of the pixel to convert
359 RGBi rgb;
360
361 int offset, bitmask;
362
363 int colorIndex = 0;
364
365 // Loop for all the source surface.
366 for (int image_y = 0; image_y < _height; ++image_y) {
367 for (int image_x = 0; image_x < _width; ++image_x) {
368
369 int offsetColor = ((image_y>>3) * 8 *( _width >> 3 ) ) + ((image_x>>3) * 8) + ((image_y) & 0x07);
370
371 // Take the color of the pixel
372 rgb.red = *_source;
373 rgb.green = *(_source + 1);
374 rgb.blue = *(_source + 2);
375 if ( _depth > 3 ) {
376 rgb.alpha = *(_source + 3);
377 } else {
378 rgb.alpha = 255;
379 }
380 if ( rgb.alpha == 0 ) {
381 rgb.red = 0;
382 rgb.green = 0;
383 rgb.blue = 0;
384 }
385
386 int minDistance = 9999;
387 for( int i=0; i<2; ++i ) {
388 int distance = rgbi_distance(&commonPalette[i], &rgb );
389 if ( distance < minDistance ) {
390 minDistance = distance;
391 colorIndex = rgb.index;
392 }
393 }
394
395 offset = ( image_y * ( _width >> 3 ) ) + ( image_x >> 3 );
396 bitmask = 1 << ( 7 - (image_x & 0x7) );
397
398 if ( colorIndex != ( ( destColormap[offsetColor] >> 4 ) & 0x0f ) ) {
399 *( destBitmap + offset + 3) |= bitmask;
400 adilinepixel( destColormap[offsetColor] & 0x0f );
401 } else {
402 *( destBitmap + offset + 3) &= ~bitmask;
403 adilinepixel( ( destColormap[offsetColor] >> 4 ) & 0x0f );
404 }
405
406 _source += _depth;
407
408 }
409 }
410
412
413}
414
415static Variable * vdcz_image_converter_bitmap_mode_multicolor( Environment * _environment, char * _source, int _width, int _height, int _depth, int _offset_x, int _offset_y, int _frame_width, int _frame_height, int _transparent_color, int _flags ) {
416
417 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
418
419 if ( _environment->freeImageWidth ) {
420 if ( _width % 8 ) {
421 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
422 }
423 if ( _frame_width % 8 ) {
424 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
425 }
426 }
427
428 if ( _environment->freeImageHeight ) {
429 if ( _height % 8 ) {
430 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
431 }
432 if ( _frame_height % 8 ) {
433 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
434 }
435 }
436
437 RGBi * palette = malloc_palette( MAX_PALETTE );
438
439 int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
440
441 if (paletteColorCount > 16) {
442 CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
443 }
444
445 int i, j, k;
446
447 commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) );
448 commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
449 lastUsedSlotInCommonPalette = paletteColorCount;
450 adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
451
452 adilinepalette( "CPMS:%ld", sizeof(SYSTEM_PALETTE) / sizeof(RGBi), SYSTEM_PALETTE );
453
454 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
456 memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
457
458 int bufferSize = vdcz_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_MULTICOLOR );
459
460 adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_MULTICOLOR );
461
462 // printf("bufferSize = %d\n", bufferSize );
463
464 char * buffer = malloc ( bufferSize );
465 memset( buffer, 0, bufferSize );
466
467 // Position of the pixel in the original image
468 int image_x, image_y;
469
470 // Position of the pixel, in terms of tiles
471 int tile_x, tile_y;
472
473 // Position of the pixel, in terms of offset and bitmask
474 int offset, bitmask;
475
476 // Color of the pixel to convert
477 RGBi rgb;
478
479 *(buffer) = ( _frame_width & 0xff );
480 *(buffer+1) = ( (_frame_width>>8) & 0xff );
481 *(buffer+2) = _frame_height;
482
483 _source += ( ( _offset_y * _width ) + _offset_x ) * 3;
484
485 vdcz_image_converter_tiles( _environment, _source, buffer+3, _frame_width, _frame_height, _depth, _width );
486
487 // printf("----\n");
488
489 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
490
491 // printf("----\n");
492
493 return result;
494
495}
496
508Variable * vdcz_collision( Environment * _environment, char * _sprite ) {
509
510 Variable * result = variable_temporary( _environment, VT_BYTE, "(collision result)");
511
512 return result;
513
514}
515
527void vdcz_hit( Environment * _environment, char * _sprite_mask, char * _result ) {
528
529 // Generate unique label for ASM code.
531
532}
533
543void vdcz_border_color( Environment * _environment, char * _border_color ) {
544
545}
546
557void vdcz_background_color( Environment * _environment, int _index, int _background_color ) {
558
559 outline1("LD A, $%2.2x", _background_color & 0x0f );
560 outline0("LD B, A" );
561 outline0("LD A, 26");
562 outline0("LD IXH, A");
563 outline0("CALL VDCZREAD");
564 outline0("AND $F0" );
565 outline0("OR B" );
566 outline0("LD IXL, A");
567 outline0("CALL VDCZWRITE");
568
569
570}
571
582void vdcz_background_color_vars( Environment * _environment, char * _index, char * _background_color ) {
583
584 outline1("LD A, (%s)", _background_color );
585 outline0("LD B, A" );
586 outline0("LD A, 26");
587 outline0("LD IXH, A");
588 outline0("CALL VDCZREAD");
589 outline0("AND $F0" );
590 outline0("OR B" );
591 outline0("LD IXL, A");
592 outline0("CALL VDCZWRITE");
593
594}
595
606void vdcz_background_color_semivars( Environment * _environment, int _index, char * _background_color ) {
607
608 outline1("LD A, (%s)", _background_color );
609 outline0("SLA A" );
610 outline0("SLA A" );
611 outline0("SLA A" );
612 outline0("SLA A" );
613 outline0("LD B, A" );
614 outline0("LD A, 26");
615 outline0("LD IXH, A");
616 outline0("CALL VDCZREAD");
617 outline0("AND $F0" );
618 outline0("OR B" );
619 outline0("LD IXL, A");
620 outline0("CALL VDCZWRITE");
621
622}
623
634void vdcz_background_color_get_vars( Environment * _environment, char * _index, char * _background_color ) {
635
636 outline0("LD A, 26");
637 outline0("LD IXH, A");
638 outline0("CALL VDCZREAD");
639 outline1("LD (%s), A", _background_color );
640
641}
642
653void vdcz_sprite_common_color( Environment * _environment, char * _index, char * _common_color ) {
654
655}
656
672void vdcz_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
673
674}
675
686void vdcz_next_raster( Environment * _environment ) {
687
688}
689
703void vdcz_next_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
704
705}
706
707void vdcz_bank_select( Environment * _environment, int _bank ) {
708
709}
710
711static int rgbConverterFunction( int _red, int _green, int _blue ) {
712
713 int colorIndex = 0;
714 unsigned int minDistance = 0xffffffff;
715 int j;
716
717 RGBi rgb;
718 rgb.red = _red;
719 rgb.green = _green;
720 rgb.blue = _blue;
721
722 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
723 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &rgb);
724 if (distance < minDistance) {
725 minDistance = distance;
726 colorIndex = j;
727 }
728 }
729
730 return colorIndex;
731
732}
733
734void console_calculate( Environment * _environment ) {
735
736}
737
738void console_calculate_vars( Environment * _environment ) {
739
740}
741
742
743int vdcz_screen_mode_enable( Environment * _environment, ScreenMode * _screen_mode ) {
744
745 _screen_mode->selected = 1;
746
747 cpu_store_8bit( _environment, "_PEN", _environment->defaultPenColor );
748 cpu_store_8bit( _environment, "_PAPER", _environment->defaultPaperColor );
749
750 int horizontalCharactersPositions = 127;
751 int horizontalVerticalSyncWidth = 0x49;
752 int horizontalSyncPosition = 102;
753 int totalNumberOfScreenRows = 39;
754 int verticalFineAdjustment = 0;
755 int numberOfVisibleScreenRows;
756 int verticalSyncPosition = 32;
757 int interlaceModeControl = 0;
758 int totalScanLinePerCharacter = 7;
759 int verticalSmoothScrollingAndControl = 8;
760 int horizontalSmoothScrollingAndControl = 0;
761 int addressIncrementPerRowOfChars = 0;
762 int characterPatternAddress = 1;
763
764 switch( _screen_mode->id ) {
766 _environment->fontWidth = 8;
767 _environment->fontHeight = 8;
768 _environment->screenTilesWidth = 80;
769 _environment->screenTilesHeight = 25;
770 _environment->screenTiles = 255;
771 _environment->screenWidth = _environment->screenTilesWidth * _environment->fontWidth;
772 _environment->screenHeight = _environment->screenTilesHeight * _environment->fontHeight;
773 _environment->screenColors = 16;
774 _environment->currentModeBW = 0;
775
776 numberOfVisibleScreenRows = _environment->screenTilesHeight;
777 horizontalSmoothScrollingAndControl = 0x47;
778
779 cpu_store_16bit( _environment, "TEXTADDRESS", 0x0000 );
780 cpu_store_16bit( _environment, "COLORMAPADDRESS", 0x0800 );
781
782 break;
783
785 _environment->fontWidth = 8;
786 _environment->fontHeight = 8;
787 _environment->screenTilesWidth = 80;
788 _environment->screenTilesHeight = 25;
789 _environment->screenTiles = 255;
790 _environment->screenWidth = _environment->screenTilesWidth * _environment->fontWidth;
791 _environment->screenHeight = _environment->screenTilesHeight * _environment->fontHeight;
792 _environment->screenColors = 2;
793 _environment->currentModeBW = 1;
794
795 numberOfVisibleScreenRows = _environment->screenTilesHeight;
796 horizontalSmoothScrollingAndControl = 0x87;
797
798 cpu_store_16bit( _environment, "TEXTADDRESS", 0x0000 );
799 cpu_store_16bit( _environment, "COLORMAPADDRESS", 0x4000 );
800
801 break;
802
804 _environment->fontWidth = 8;
805 _environment->fontHeight = 8;
806 _environment->screenTilesWidth = 80;
807 _environment->screenTilesHeight = 22;
808 _environment->screenTiles = 255;
809 _environment->screenWidth = _environment->screenTilesWidth * _environment->fontWidth;
810 _environment->screenHeight = _environment->screenTilesHeight * _environment->fontHeight;
811 _environment->screenColors = 16;
812 _environment->currentModeBW = 1;
813
814 numberOfVisibleScreenRows = _environment->screenTilesHeight;
815 horizontalSmoothScrollingAndControl = 0xC7;
816
817 cpu_store_16bit( _environment, "TEXTADDRESS", 0x0000 );
818 cpu_store_16bit( _environment, "COLORMAPADDRESS", 0x3700 );
819
820 outline0("LD A, $08");
821 outline0("LD IXH, A");
822 outline0("LD A, 0");
823 outline0("LD IXL, A");
824 outline0("CALL VDCZWRITE");
825
826 break;
827
829 _environment->fontWidth = 8;
830 _environment->fontHeight = 8;
831 _environment->screenTilesWidth = 80;
832 _environment->screenTilesHeight = 50;
833 _environment->screenTiles = 255;
834 _environment->screenWidth = _environment->screenTilesWidth * _environment->fontWidth;
835 _environment->screenHeight = _environment->screenTilesHeight * _environment->fontHeight;
836 _environment->screenColors = 2;
837 _environment->currentModeBW = 1;
838
839 horizontalCharactersPositions = 0x7e;
840 horizontalVerticalSyncWidth = 0x89;
841 horizontalSyncPosition = 0x66;
842 totalNumberOfScreenRows = 0x4c;
843 verticalFineAdjustment = 6;
844 numberOfVisibleScreenRows = 0x4c;
845 verticalSyncPosition = 0x47;
846 interlaceModeControl = 3;
847 totalScanLinePerCharacter = 6;
848 verticalSmoothScrollingAndControl = 0;
849 horizontalSmoothScrollingAndControl = 0x87;
850 addressIncrementPerRowOfChars = 0;
851 characterPatternAddress = 16;
852
853 cpu_store_16bit( _environment, "TEXTADDRESS", 0x0000 );
854 cpu_store_16bit( _environment, "COLORMAPADDRESS", 0x4000 );
855
856 break;
857
859 _environment->fontWidth = 8;
860 _environment->fontHeight = 8;
861 _environment->screenTilesWidth = 80;
862 _environment->screenTilesHeight = 44;
863 _environment->screenTiles = 255;
864 _environment->screenWidth = _environment->screenTilesWidth * _environment->fontWidth;
865 _environment->screenHeight = _environment->screenTilesHeight * _environment->fontHeight;
866 _environment->screenColors = 16;
867 _environment->currentModeBW = 1;
868
869 horizontalCharactersPositions = 0x7e;
870 horizontalVerticalSyncWidth = 0x89;
871 horizontalSyncPosition = 0x66;
872 totalNumberOfScreenRows = 0x4c;
873 verticalFineAdjustment = 6;
874 numberOfVisibleScreenRows = 0x4c;
875 verticalSyncPosition = 0x47;
876 interlaceModeControl = 3;
877 totalScanLinePerCharacter = 6;
878 verticalSmoothScrollingAndControl = 0;
879 horizontalSmoothScrollingAndControl = 0xC7;
880 addressIncrementPerRowOfChars = 0;
881 characterPatternAddress = 16;
882
883 cpu_store_16bit( _environment, "TEXTADDRESS", 0x0000 );
884 cpu_store_16bit( _environment, "COLORMAPADDRESS", 0x3700 );
885
886 break;
887
888 }
889
890 _environment->consoleTilesWidth = _environment->screenTilesWidth;
891 _environment->consoleTilesHeight = _environment->screenTilesHeight;
892
894 // -- [ $00 ] --
896
897 // Total number of horizontal character positions
898
899 // The value in this register determines the total width (in character
900 // positions) of each horizontal line of the display. The
901 // value stored here should be one less than the desired number
902 // of horizontal character positions. This total includes the active
903 // portion of the display (where characters can be displayed), the
904 // left and right borders, and the horizontal sync width. The total
905 // number of horizontal pixels is given by multiplying the value
906 // here (plus 1) by the total number of pixels per character position
907 // (the value in bits 4-7 of register 22/$16 plus 1).
908
909 // The default value for this register, established during the
910 // IO1NIT routine [$E109], is 126/$7E, This provides 127 horizontal
911 // character positions. You'll need to reduce this by half if
912 // you enable the pixel double feature (see the entry for bit 4 of
913 // register 25/$19). You may need to increase the value here
914 // slightly if you use one of the interlaced modes.
915
916 outline0("LD A, $00");
917 outline0("LD IXH, A");
918 outline1("LD A, $%2.2x", horizontalCharactersPositions );
919 outline0("LD IXL, A");
920 outline0("CALL VDCZWRITE");
921
923 // -- [ $01 ] --
925
926 // Number of active horizontal character positions
927
928 // The value in this register determines how many of the horizontal
929 // character positions specified in register 0/$00 can actually
930 // be used to display characters. The value stored here
931 // should be the desired number of columns for the display. The
932 // value here must be less than the value in register 0/$00. The
933 // default value for this register is 80/$50, since the default VDC
934 // display is an 80-column text screen. The value here also determines
935 // the width of the bitmap when the VDC is set for graphic
936 // mode. The bitmap width is given by multiplying the number
937 // of character positions by the character-position width specified
938 // in bits 0-3 of register 22/$16.
939
940 outline0("LD A, $01");
941 outline0("LD IXH, A");
942 outline1("LD A, $%2.2x", _environment->screenTilesWidth );
943 outline0("LD IXL, A");
944 outline0("CALL VDCZWRITE");
945
947 // -- [ $02 ] --
949
950 // Horizontal sync position
951
952 // The value in this register determines the character position at
953 // which the vertical sync pulse begins. The value here also determines
954 // the horizontal position of the active portion of the
955 // screen within the total display. The default value here is
956 // 102/$66. Increasing this value moves the active screen area to
957 // the left; decreasing it moves the active area to the right.
958
959 outline0("LD A, $02");
960 outline0("LD IXH, A");
961 outline1("LD A, $%2.2x", horizontalSyncPosition );
962 outline0("LD IXL, A");
963 outline0("CALL VDCZWRITE");
964
966 // -- [ $03 ] --
968
969 // Horizontal and vertical sync width
970
971 // Bits 0-3: These bits specify the width of the horizontal sync
972 // pulse. The value here should be one greater than the desired
973 // number of character positions for the pulse. The default value
974 // for these bits is 9/$9, for a pulse eight character positions wide.
975 // Bits 4-7: These bits specify the width of the vertical sync
976 // pulse. The bit value here should be equal to the desired number
977 // of scan lines for the pulse, unless the interlaced sync and
978 // video mode is being used (in that case, use a value that is
979 // twice the desired number of scan lines). The default value for
980 // these bits is 4/$4, for a pulse four scan lines wide.
981
982 outline0("LD A, $03");
983 outline0("LD IXH, A");
984 outline1("LD A, $%2.2x", horizontalVerticalSyncWidth );
985 outline0("LD IXL, A");
986 outline0("CALL VDCZWRITE");
987
989 // -- [ $04 ] --
991
992 // Total number of screen rows
993
994 // This register specifies the total height (in character positions)
995 // of the VDC display. The value stored here should be one less
996 // than the desired number of vertical character positions. The
997 // total includes the rows for the active display, the top and bottom
998 // portions of the border, and the vertical sync width. To determine
999 // the height of the raster in scan lines, multiply the
1000 // value in this register (plus 1) by the number of scan lines per
1001 // character position (the value in register 9/S09 plus 1) and add
1002 // any additional scan lines specified in register 5/$05.
1003
1004 // The proper number of scan lines for the display is a function
1005 // of the video system being used; it's different for NTSC
1006 // (North American) and PAL (European) systems. During the
1007 // IOINIT routine [$E109], the 128 checks the VIC chip to deter-
1008 // mine which system is being used (since the VIC isn't programmable
1009 // like the VDC, there is a different version of the
1010 // VIC for each of the two video systems). This register is then
1011 // initialized accordingly: to 32/$20 for NTSC systems or 39/$27
1012 // for PAL systems, selecting 33 or 40 rows, respectively. Since
1013 // the default character-position height is eight scan lines, the respective
1014 // total heights are 33 * 8, or 264 lines, for NTSC, and
1015 // 40 * 8, or 320 scan lines, for PAL. These scan-line totals
1016 // should remain constant, so if you increase the character height
1017 // you must decrease the total number of rows, and vice versa.
1018
1019 outline0("LD A, $04");
1020 outline0("LD IXH, A");
1021 outline1("LD A, $%2.2x", totalNumberOfScreenRows );
1022 outline0("LD IXL, A");
1023 outline0("CALL VDCZWRITE");
1024
1026 // -- [ $05 ] --
1028
1029 // Vertical fine adjustment
1030
1031 // Bits 0-4: The total number of scan lines in the VDC's video
1032 // display should be 264 for an NTSC (North American) system
1033 // or 320 for a PAL (European) system. The number of scan lines
1034 // used in the VDC display is given by the total number of vertical
1035 // positions (specified in register 4/S04) multiplied by the
1036 // number of scan lines per character position (specified in register
1037 // 9/$09). If the result doesn't come out exactly equal to the
1038 // required 264 or 320, the VDC can add a few extra scan lines at
1039 // the end to achieve the proper result. The value in this register
1040 // specifies the number of extra scan lines to add. The available
1041 // five bits allow up to % 11111 = 31 / $1f additional scan lines.
1042 // The default character height of eight scan lines is an exact
1043 // multiple of both 264 and 320 (33 * 8 = 264 and 40 * 8 =
1044 // 320). Thus, no extra scan lines are required, so this register is
1045 // initialized to 0/$00 by the Kernal IOINIT routine [$E109]. As
1046 // an example of the use of this register, assume that you increased
1047 // the character height to nine scan lines. For an NTSC
1048 // system, 264 / 9 = 29 with a remainder of 3. Thus, for this
1049 // case you should specify 29 for the total number of vertical
1050 // character positions and store a 3 in this register to provide the
1051 // required additional scan lines.
1052
1053 outline0("LD A, $05");
1054 outline0("LD IXH, A");
1055 outline1("LD A, $%2.2x", verticalFineAdjustment );
1056 outline0("LD IXL, A");
1057 outline0("CALL VDCZWRITE");
1058
1060 // -- [ $06 ] --
1062
1063 // Number of visible screen rows
1064
1065 // The value in this register determines how many of the vertical
1066 // character positions specified in register 4/S04 can actually be
1067 // used to display characters. The value here must be less than
1068 // the total number specified in register 4/$04. The default value
1069 // established for this register by the Kernal IOINIT routine
1070 // [$E109] is 25/$19, which sets up the standard 25-row display.
1071
1072 outline0("LD A, $06");
1073 outline0("LD IXH, A");
1074 outline1("LD A, $%2.2x", numberOfVisibleScreenRows );
1075 outline0("LD IXL, A");
1076 outline0("CALL VDCZWRITE");
1077
1079 // -- [ $07 ] --
1081
1082 // Vertical sync position
1083
1084 // The value in this register determines the vertical character position
1085 // at which the vertical sync signal will be generated. This
1086 // register can be used to adjust the vertical location of the active
1087 // display area within the screen. The default value for this register,
1088 // established by the IOINIT routine [$E109], is 29/S1D for
1089 // NTSC (North American) systems or 32/S20 for PAL (European)
1090 // systems. Decreasing the value here will move the active
1091 // display area down the screen, while increasing the value will
1092 // move the active display area upwards. However, you should
1093 // not increase the value here above the maximum number of
1094 // rows specified in register 4/$04.
1095
1096 outline0("LD A, $07");
1097 outline0("LD IXH, A");
1098 outline1("LD A, $%2.2x", verticalSyncPosition );
1099 outline0("LD IXL, A");
1100 outline0("CALL VDCZWRITE");
1101
1103 // -- [ $08 ] --
1105
1106 // Interlace mode control
1107
1108 // Bits 0-1: The value in these bits controls the interlace mode of
1109 // the screen. The complete standard for NTSC video calls for a
1110 // frame (raster) of 525 lines to be redrawn 30 times per second,
1111 // while the PAL standard calls for 625 lines redrawn 25 times
1112 // per second. The full screen isn't drawn all at once; instead, it's
1113 // drawn in two passes with half the lines for the frame drawn
1114 // on each pass. The lines for the second pass of the frame are
1115 // 439 drawn between the lines for the first. Like most computer displays,
1116 // the VDC normally takes a shortcut and draws half the
1117 // full number of lines at twice the rate. This noninterlaced display
1118 // provides sufficiently sharp output for most uses. However,
1119 // the VDC is also capable of producing two interlaced
1120 // display modes. The modes are selected as follows:
1121
1122 // Bits
1123 // 1 0 Value Interlace mode
1124 // x 0 0 or 2 noninterlaced
1125 // 0 1 1 interlaced sync
1126 // 1 1 3 interlaced sync and video
1127
1128 // The default value is 0/$00, which selects the standard
1129 // noninterlaced mode. The system never uses any other mode.
1130 // In the interlaced sync mode, the number of scan lines is doubled.
1131 // Each horizontal scan line is drawn twice, once on the
1132 // first pass and very slightly lower on the second pass. The result
1133 // should be greatly improved vertical resolution, but you'll
1134 // probably be disappointed. Remember that each tiny dot on the
1135 // screen glows only very briefly after being struck by the raster
1136 // video beam. Since this mode must draw twice as many lines,
1137 // it draws each line only half as often. On most video monitors,
1138 // the first set of lines will have started to fade before the second
1139 // set is completely drawn. As a result, the screen will appear to
1140 // jitter annoyingly in this mode.
1141
1142 outline0("LD A, $08");
1143 outline0("LD IXH, A");
1144 outline1("LD A, $%2.2x", interlaceModeControl );
1145 outline0("LD IXL, A");
1146 outline0("CALL VDCZWRITE");
1147
1149 // -- [ $09 ] --
1151
1152 // Total number of scan lines per character
1153
1154 // Bits 0-4: These bits determine the total vertical height (in scan
1155 // lines) of each character position. The value stored here should
1156 // be one less than the desired number of scan lines. The total
1157 // vertical height value includes the scan lines for the active portion
1158 // of each character position, plus any desired number of
1159 // blank scan lines for intercharacter vertical spacing. The height
1160 // of the active portion of the character position is determined by
1161 // the value in register 23/$17.
1162
1163 // The default value for this register, established during the
1164 // IOINIT routine [SE109], is 7/$07, for a total character-position
1165 // height of eight scan lines. In this case, there will be no vertical
1166 // intercharacter spacing because this is less than the active character
1167 // height. (In the default character set, intercharacter spacing
1168 // is achieved by leaving the bottom row of the character pattern
1169 // blank.) The five available bits allow values up to %11111 =
1170 // 31/$IF, for character-position heights of up to 32 scan lines.
1171 // However, when changing this value to allow for greater vertical
1172 // resolution, you must keep in mind that the value here multiplied
1173 // by the total number of rows specified in register 4/$04
1174 // (and plus the number of extra scan lines specified in register
1175 // 5/$05) determines the number of scan lines in the display.
1176 // This total should always be 264 lines for NTSC (North American)
1177 // systems or 320 lines for PAL (European) systems.
1178 // The value here also determines how much memory is required
1179 // for character pattern memory. While the value here is
1180 // less than or equal to 15 (while the character height is 16 or
1181 // fewer scan lines), each character pattern is allocated 16 bytes.
1182 // Since the VDC supports two complete 256-character sets, a total
1183 // of 512 * 16, or 8192 bytes, are required for character memory'
1184 // However, if the character height exceeds 16 scan lines (if
1185 // the value here is greater than 15), then 32 bytes are allocated
1186 // for each character pattern. In this case, 512 * 32, or 16,384
1187 // bytes, are required for character memory. Note that this is all
1188 // the memory available to the VDC.
1189
1190 outline0("LD A, $09");
1191 outline0("LD IXH, A");
1192 outline1("LD A, $%2.2x", totalScanLinePerCharacter );
1193 outline0("LD IXL, A");
1194 outline0("CALL VDCZWRITE");
1195
1197 // -- [ $0A ] --
1199
1200 // Cursor mode control
1201
1202 // Bits 0-4: The value in these bits determines the scan line
1203 // within each character position for the top of the cursor. Scan
1204 // lines within character positions are numbered beginning with
1205 // 0 for the top line of the position. Bits 0-4 of register ll/$0B
1206 // determine the bottom line, and together these registers determine
1207 // the height of the cursor. The available five bits allow
1208 // starting row numbers as large as %11111 = 31/$1F. The default
1209 // value for these bits is %00000, to start the cursor at character
1210 // scan line 0, the top line of the character, for the standard
1211 // full-height block cursor. The operating system also supports
1212 // an underline cursor, selected by printing ESC U [$CAFE], In
1213 // this case, the value here is changed to %00111 (7) to start the
1214 // cursor on the bottom line of the standard character position.
1215 // The value for the top scan line should be no greater than the
1216 // maximum number of scan lines specified in register 9/$09, or
1217 // else the cursor will not be visible.
1218
1219 // Bits 5-6: These bits control the type of cursor provided. Unlike
1220 // the VIC, where the cursor is an effect maintained by software,
1221 // the VDC has hardware to generate a cursor automatically. The
1222 // possible modes are as follows:
1223
1224 // Bit values Cursor mode
1225 // 0/$00 solid {nonblinking) cursor
1226 // 32/S20 no cursor
1227 // 64/$40 blinking at 1/16 screen refresh rate
1228 // 96/$60 blinking at 1/32 screen refresh rate
1229
1230 // The default setting for these bits is %11, specifying a cursor
1231 // blinking at the slower of the two rates. The operating system
1232 // also supports a nonblinking cursor, selected by printing ESC E
1233 // [$CB0B]. In this case, the bits are changed to %00. To rum the
1234 // cursor off when the system is not accepting input (as when a
1235 // program is running), these bits are reset to %01 [$CD9F].
1236
1237 outline0("LD A, $0a");
1238 outline0("LD IXH, A");
1239 outline1("LD A, $%2.2x", 0x20 );
1240 outline0("LD IXL, A");
1241 outline0("CALL VDCZWRITE");
1242
1244 // -- [ $0B ] --
1246
1247 // Bottom scan line for cursor
1248
1249 // Bits 0-4: These bits determine the scan line within a character
1250 // position for the bottom of the cursor. Together with bits 0-4
1251 // of register 10/$0A, this serves to determine the height of the
1252 // cursor. The value here should be one greater than the desired
1253 // bottom scan line (scan-line numbering starts with 0 for the top
1254 // scan line of the character position). The five available bits
1255 // allow values up to % 11111 = 31/$1F, so the cursor can go as
1256 // low as scan line 30, However, the actual displayed cursor
1257 // height will never be greater than the character-position height
1258 // specified in register 9/$09. The default value for this register,
1259 // established by the IOINIT routine [$E109], is 7/$07, so the
1260 // normal bottom scan line of the cursor is scan line 6 of the
1261 // character position.
1262
1263 outline0("LD A, $0b");
1264 outline0("LD IXH, A");
1265 outline1("LD A, $%2.2x", 7 );
1266 outline0("LD IXL, A");
1267 outline0("CALL VDCZWRITE");
1268
1270 // -- [ $0C+$0D ] --
1272
1273 // Starting address for screen memory
1274
1275 // For standard text mode, the value in this register pair determines
1276 // the starting address for screen memory, the area which
1277 // holds screen codes specifying which character will be displayed
1278 // in each screen position. The size of the screen memory area is
1279 // determined by the number of active horizontal positions (specified
1280 // in register l/$01) multiplied by the number of active rows
1281 // (specified in register 6/$06) and the address increment per
1282 // row (specified in register 27/$lB). The order of bytes for the
1283 // pair is opposite that normally used in the 128 system: The first
1284 // register (12/$0C) holds the high byte and the second (13/$0D)
1285 // holds the low byte. Unlike VIC screen memory, which must
1286 // begin on an even IK address boundary, VDC screen memory
1287 // can begin at any address in the VDC's address space.
1288
1289 // For graphic mode, the value in this register pair determines
1290 // the starting address for the bitmap of the graphic
1291 // screen. The amount of memory required for the bitmap is
1292 // found by multiplying the number of horizontal character positions
1293 // (from register l/$01) by the number of vertical character
1294 // positions (in register 6/$06) times the total height of each
1295 // character position (from register 9/$09 plus 1). The bitmap
1296 // can be started at any address in the VDC address space.
1297 // Even if you change the value here, the screen editor ROM
1298 // routines will continue to assume that screen memory is located
1299 // in its default position unless you also change the value in the
1300 // screen memory starting-page pointer at 2606/$0A2E.
1301
1302 outline0("LD A, $0c");
1303 outline0("LD IXH, A");
1304 outline0("LD A, (TEXTADDRESS+1)" );
1305 outline0("LD IXL, A");
1306 outline0("CALL VDCZWRITE");
1307 outline0("LD A, $0d");
1308 outline0("LD IXH, A");
1309 outline0("LD A, (TEXTADDRESS)" );
1310 outline0("LD IXL, A");
1311 outline0("CALL VDCZWRITE");
1312
1314 // -- [ $0E+$0F ] --
1316
1317 // Address of current cursor position
1318
1319 // For the VIC chip's display, the cursor is an effect laboriously
1320 // maintained by software. The VDC, by contrast, has hardware
1321 // to maintain the cursor for its display automatically. The cursor
1322 // will appear at the character position with the screen memory
1323 // location specified in this register pair. If the address specified
1324 // here is outside the area of VDC memory currently being used
1325 // for screen memory, no cursor will be visible. Other characteristics
1326 // of the cursor such as its blinking status and position within
1327 // the character are specified in registers 10/$OA and 11/$OB.
1328 // 444
1329
1330 // outline0("LD A, $0e");
1331 // outline0("LD IXH, A");
1332 // outline0("LD A, $%2.2x", 0 );
1333 // outline0("LD IXL, A");
1334 // outline0("CALL VDCZWRITE");
1335 // outline0("LD A, $0f");
1336 // outline0("LD IXH, A");
1337 // outline0("LD A, $%2.2x", 0 );
1338 // outline0("LD IXL, A");
1339 // outline0("CALL VDCZWRITE");
1340
1342 // -- [ $10-$11 ] --
1344
1345 // Light pen vertical and horizontal positions
1346
1347 // Whenever the LP input line to the VDC chip is brought to a
1348 // low (0 volts) state, the row and column values for the current
1349 // position of the raster beam are latched into these registers. The
1350 // vertical (row) number will be latched into register 16/$10, and
1351 // the horizontal (column) number will be latched into register
1352 // 17/$11. To signal that a value has been latched, the LP flag
1353 // (bit 6 of the external register at 54784/SD600) will be set to
1354 // %1. That bit will remain at %1 until either of these registers is
1355 // read, at which time it will be reset to %0. However, reading
1356 // these registers does not clear them; the latched values will be
1357 // retained until the LP line is brought low again.
1358
1359 // The VDC's LP line is connected to pin 6 of control port 1
1360 // (control port 2 does not support a light pen). A light pen has
1361 // at its tip an electronic device known as a phototransistor,
1362 // which is connected so as to cause a low pulse whenever the
1363 // video beam moves past the pen. Note that the pen will not be
1364 // triggered if the screen position is black or one of the other
1365 // dark colors. Only positions which have bright characters can
1366 // be read. The ideal character to read with a light pen is a white
1367 // reverse video space.
1368
1369 // When a light pen is used, the range of values in these
1370 // registers depends on the screen width and height selected by
1371 // other VDC registers. Unlike the VIC chip, whose light pen
1372 // registers return scan line and dot position values, these registers
1373 // return row and column numbers corresponding to the
1374 // light pen position. This makes the results much easier to interpret,
1375 // but does not allow precise positioning, so it is unlikely
1376 // that you'll see any 80-column drawing programs using the
1377 // light pen as an input device. For the standard 80-column X
1378 // 25-line screen, the value in register 16/$ 10 corresponds very
1379 // closely to the row number: ranging from l/$01 at the top of
1380 // the screen to 25/$19 at the bottom. Actually, you may find
1381 // that if you position the pen slightly below the bottom screen
1382 // line you can get a reading of 26/S1A.
1383
1384 // While the vertical resolution is good, the horizontal resolution
1385 // is quite poor. The horizontal reading won't correspond
1386 // to the row number (1-80). Instead, it corresponds approximately
1387 // to the absolute horizontal character position, which includes
1388 // the border areas on the left and right edges of the
1389 // screen. You should find that when the pen is pointed at the
1390 // leftmost character position, you get a reading of about 27-29
1391 // in register 17/$11. This implies that the rightmost character
1392 // position should give readings of about 106-108. Actually, you
1393 // may get higher readings—120 or more. In fact, even if you
1394 // hold the pen perfectly stil] you may see the character position
1395 // vary up or down by 4 or 5. The moral is that the light pen is
1396 // much better at reading vertical than horizontal positions.
1397 // You'll have better luck if you limit yourself to checking
1398 // whether the pen is within a range of horizontal positions. For
1399 // example, if you read the horizontal position and store the result
1400 // in the variable H, then an expression such as H = INT({H
1401 // — 30) / 8) will return a range of values 0-9 indicating
1402 // roughly which one of ten eight-column horizontal areas the
1403 // pen is pointing to.
1404
1405 // You should be aware that these registers can be tricked
1406 // into reading false values. Pin 6 of control port 1 is also used
1407 // for light pen input for the VIC chip, and a light pen signal
1408 // generated on the 40-column screen will latch meaningless values
1409 // in these registers. In lieu of a light pen, several other
1410 // events can cause a pulse on the LP line. That control port pin
1411 // is also used for the joystick fire button, so pressing the button
1412 // of a joystick plugged into port 1 will also latch values in these
1413 // registers. Because of this joystick button function, the port line
1414 // is also connected to the line from row 4 of the keyboard matrix.
1415 // This has two consequences. First, pressing any of the following
1416 // keys with no light pen connected will latch meaningless
1417 // values: Fl, Z, C, B, M, period, right SHIFT, space, the 2 and
1418 // ENTER keys on the numeric keypad, and the ^ key in the
1419 // cursor group. More significantly, while a light pen is connected,
1420 // all of these keys will be "dead," and cannot be typed.
1421
1422 // outline0("LD A, $10");
1423 // outline0("LD IXH, A");
1424 // outline0("CALL VDCZREAD");
1425 // outline0("LD A, $11");
1426 // outline0("LD IXH, A");
1427 // outline0("CALL VDCZREAD");
1428
1430 // -- [ $12-$13 ] --
1432
1433 // Current memory address
1434
1435 // This register pair specifies which address in the VDC's private
1436 // block of RAM will be referenced by the next read or store operation
1437 // involving register 31/S1F. As with the other VDC address
1438 // register pairs, the first register (18/$12) holds the high
1439 // byte of the address and the second (19/$13) holds the low
1440 // byte. A value stored in register 31/$1F is transferred to the
1441 // VDC memory location specified in this register pair. Reading
1442 // register 31/$1F returns the value in the location in VDC memory
1443 // with the address specified in this register pair. For copy or
1444 // fill operations, the value in these registers determines the destination
1445 // address for the operation. These registers are autoincrementing,
1446 // meaning that the address value here is automatically
1447 // increased by 1 after each read or store to register
1448 // 31/S1F. Thus, when you wish to read or load a continuous series
1449 // of VDC memory locations you only need to set the memory
1450 // address in these registers before the first read or store.
1451 // After that, you can just read from or write to register 31/$1F
1452 // and the address will be handled automatically.
1453
1454 // outline0("LD A, $12");
1455 // outline0("LD IXH, A");
1456 // outline0("LD A, $%2.2x", 0 );
1457 // outline0("LD IXL, A");
1458 // outline0("CALL VDCZWRITE");
1459 // outline0("LD A, $13");
1460 // outline0("LD IXH, A");
1461 // outline0("LD A, $%2.2x", 0 );
1462 // outline0("LD IXL, A");
1463 // outline0("CALL VDCZWRITE");
1464
1466 // -- [ $14-$15 ] --
1468
1469 // Starting address for attribute memory
1470
1471 // When attributes are activated, this register pair determines the
1472 // starting address for attribute memory, the area which holds
1473 // attribute values for each active character position on the
1474 // screen. (Attributes can be turned on and off by setting bit 6 of
1475 // register 25/$19.) The size of the attribute memory area depends
1476 // on the number of active rows and columns specified in
1477 // registers 2/$02 and 6/$06, and will be the same as the size of
1478 // the screen memory area. See the discussion of attributes in the
1479 // introduction to this section for more information.
1480
1481 // These locations are initialized to 2048/S0800, the default
1482 // starting address for attribute memory. Like the other address
1483 // pairs in the VDC, the first register (20/$14) holds the high
1484 // byte and the second (21/$15) holds the low byte. Attribute
1485 // memory can start at any address within the VDC's address
1486 // space. Even if you change the value here, the screen editor
1487 // ROM routines will continue to assume that attribute memory
1488 // is in its default position unless you also change the value in
1489 // the attribute starting-page pointer at 2607/$0A2F.
1490
1491 outline0("LD A, $14");
1492 outline0("LD IXH, A");
1493 outline0("LD A, (COLORMAPADDRESS+1)" );
1494 outline0("LD IXL, A");
1495 outline0("CALL VDCZWRITE");
1496 outline0("LD A, $15");
1497 outline0("LD IXH, A");
1498 outline0("LD A, (COLORMAPADDRESS)" );
1499 outline0("LD IXL, A");
1500 outline0("CALL VDCZWRITE");
1501
1503 // -- [ $16 ] --
1505
1506 // Character horizontal size control
1507
1508 // Bits 0-3: The value in these bits determines how many of the
1509 // total horizontal pixels in the character position will be used to
1510 // display character pattern data. (The total number is specified
1511 // in bits 4-7 of this register.) If the number of active pixels is
1512 // less than the total number of pixels, the extra pixels will be
1513 // blank for intercharacter spacing. If you specify a value here
1514 // that is greater than the total number of pixels available for the
1515 // position, only the specified total number of pixels will be visible.
1516 // However, the value here should not exceed 8, since a
1517 // maximum of eight bits are available per byte of character pattern
1518 // data. Even for values greater than 8, no more than eight
1519 // pixels will be active per horizontal scan line within the character
1520 // position. For graphic mode, the value here should be equal
1521 // to the total number of pixels; otherwise there will be gaps in
1522 // the display.
1523
1524 // The default value for these bits is 8, for eight active horizontal
1525 // pixels per character-position scan line. This is the same
1526 // as the total number of pixels per position, so there will be no
1527 // intercharacter spacing. (For the default character set, the
1528 // rightmost column of each character pattern is left blank to provide
1529 // the effect of intercharacter spacing,)
1530
1531 // Bits 4-7: The value in these bits determines the width of each
1532 // character position (in pixels). The value stored here should be
1533 // one less than the desired total number of pixels. If the total is
1534 // greater than the number of active pixels specified in bits 0-3
1535 // of this register, the extra pixels will be blank for intercharacter
1536 // spacing. The default value for these bits is 7, for eight total
1537 // pixels per character position. The total number of horizontal
1538 // pixels is determined by multiplying the value here (plus 1) by
1539 // the total number of character positions (from register 0/$00).
1540
1541 outline0("LD A, $16");
1542 outline0("LD IXH, A");
1543 outline1("LD A, $%2.2x", ( ( _environment->fontWidth - 1 ) << 4 ) | ( _environment->fontWidth ) );
1544 outline0("LD IXL, A");
1545 outline0("CALL VDCZWRITE");
1546
1548 // -- [ $17 ] --
1550
1551 // Character vertical size control
1552
1553 // Bits 0-4: The value in these bits determines how many of the
1554 // total scan lines for each character position (specified in register
1555 // 9/$09) will be used to display character pattern data. The
1556 // available five bits allow you to specify values up to % 11111
1557 // = 31/$1F. If the value here is less than the total number of
1558 // scan lines for the character position, the extra lines will be
1559 // blank for intercharacter spacing. If the value here is greater
1560 // than the total number of scan lines, only the total number of
1561 // scan lines will be displayed. For graphic mode, the value here
1562 // should be at least equal to the total number of scan lines (the
1563 // value in register 9/$09 plus 1); otherwise there will be gaps in
1564 // the display.
1565
1566 // The default value stored in this register is 8/$08, for eight
1567 // active scan lines per character position. This is equal to the default
1568 // total number of scan lines for the position, so there will
1569 // be no intercharacter spacing. (For the standard character set,
1570 // intercharacter spacing is achieved by leaving the bottom row
1571 // of most character definition patterns blank.)
1572
1573 outline0("LD A, $17");
1574 outline0("LD IXH, A");
1575 outline1("LD A, $%2.2x", _environment->fontHeight );
1576 outline0("LD IXL, A");
1577 outline0("CALL VDCZWRITE");
1578
1580 // -- [ $18 ] --
1582
1583 // Vertical smooth scrolling and control
1584
1585 // Bits 0-4; These bits can be used to smoothly scroll the screen
1586 // vertically upward. The value here specifies the number of scan
1587 // lines the display should be shifted upward. Although five bits
1588 // are available, the value here should not exceed the value in
1589 // register 9/$09.
1590
1591 // Bit 5: This bit controls the blinking rate for all characters on
1592 // the screen with the flash attribute. A character position has the
1593 // flash attribute when bit 4 of its corresponding attribute memory
1594 // is set to %1. The two available blinking rates are once
1595 // each 16 times the screen is refreshed (selected when this bit is
1596 // set to %0) or once each 32 times (selected when this bit is set
1597 // to %l). For NTSC (North American) systems, the screen is redrawn
1598 // 60 times per second, so the corresponding blinking
1599 // rates are about four times per second when the bit is %0 and
1600 // about twice per second when the bit is %1.
1601
1602 // The default setting for this bit is %1, for the slower blinking
1603 // rate. This is established during the IOINIT routine [$E109],
1604 // part of both the reset and RUN/STOP-RE STORE sequences.
1605 // This setting is not changed by any other ROM routine.
1606
1607 // Bit 6: This bit controls a special VDC feature known as reverse
1608 // mode. While this bit is %0, all pixels on the screen represented
1609 // by %0 bits in character patterns or the graphic screen
1610 // bitmap take the background color specified in bits 0-3 of register
1611 // 26/$lA, and all pixels represented by %1 bits take the
1612 // foreground color specified in a corresponding attribute memory
1613 // location (or in bits 4-7 of register 26/$lA if attributes are
1614 // disabled). Setting this bit to %1 reverses the color sources, so
1615 // that all pixels for %0 bits take the foreground color and all
1616 // pixels for %1 bits take the background color.
1617 // This bit is initialized to %0 for a normal screen display.
1618 // The screen editor ROM supports escape sequences to change
1619 // this bit. The ESC R sequence will set the bit to %1, reversing
1620 // the screen display. The ESC N sequence will clear the bit to
1621 // %0, returning the display to normal.
1622
1623 // Bit 7: This bit determines whether the next block operation
1624 // initiated by writing to register 3O/$1E will be a copy or a fill.
1625 // Setting this bit to %0 specifies a fill operation, while setting it
1626 // to %1 specifies a copy operation. See the entry for register
1627 // 3O/$1E for more information on VDC block operations. This
1628 // bit is set to %0 when the register is initialized during the
1629 // IOINIT routine [$E109].
1630
1631 outline0("LD A, $18");
1632 outline0("LD IXH, A");
1633 outline1("LD A, $%2.2x", verticalSmoothScrollingAndControl );
1634 outline0("LD IXL, A");
1635 outline0("CALL VDCZWRITE");
1636
1638 // -- [ $19 ] --
1640
1641 // Horizontal smooth scrolling and control
1642
1643 // Bits 0-3: These bits can be used to smoothly scroll the screen
1644 // horizontally. The use of these bits depends on the version of
1645 // the VDC in your 128. (The version number can be determined
1646 // by reading bits 0-2 of the external communications register at
1647 // 54784/$D600.) For version 1 of the VDC, which includes most
1648 // 128s, this register should be initialized to the maximum character
1649 // width (in bits 4-7 of register 22/$16). Each decrement of
1650 // this register shifts the display one pixel to the left. For the
1651 // older version 0 of the VDC, these bits should be initialized to
1652 // %0000. In this case, each increment of these bits shifts the display
1653 // one pixel to the right.
1654
1655 // Bit 4: This bit controls the VDC's pixel double feature. While
1656 // this bit is %0, pixels will be their normal size. Setting this bit
1657 // to %1 will double the size of all horizontal screen pixels. Since
1658 // each pixel is twice as large, there will be room for only half as
1659 // many on the screen. Thus, you must reduce the values in the
1660 // horizontal screen width registers (0-2/$00-$02) to half their
1661 // normal values.
1662
1663 // Bit 5: This bit controls a special VDC feature called
1664 // semigraphic mode. When semigraphic mode is activated
1665 // (when this bit is %1), the rightmost active pixel will be repeated
1666 // through the intercharacter spacing pixels. For this
1667 // mode to have any visible effect, there must be some
1668 // intercharacter spacing (the value in bits 0-3 of register 22/$16
1669 // must be less than the total number of pixels specified in bits
1670 // 4-7 of that register). This mode has no effect in graphic mode.
1671 // One use of this mode is to create a simple "digital" character
1672 // effect.
1673
1674 // Bit 6: The VDC has two methods of supplying foreground
1675 // information for its display. When this attribute enable bit is set
1676 // to %1, each character position will have a corresponding
1677 // attribute memory location. Refer to the introduction to this
1678 // section for details on attributes. The starting address of attribute
1679 // memory is determined by the value in registers 20-21/$14-
1680 // $15, When this bit is %0, attribute memory is not used. Instead,
1681 // all character positions take the foreground color specified
1682 // in bits 4-7 of register 26/$lA. In this case, the character positions
1683 // cannot have the flash, underline, or reverse attributes,
1684 // and only the first of the two character sets will be available.
1685 // Bit 7: This bit determines whether the VDC will operate as a
1686 // text or graphics display. Text mode, selected when the bit is
1687 // set to %0, is the only one supported by the 128 operating system
1688 // (%0 is the default value for this bit). In that mode, each
1689 // screen memory position holds a screen code which serves as
1690 // an index into character memory to specify the pattern to be
1691 // displayed in that position.
1692 // When this bit is set to %1, graphics mode is selected. In
1693 // that mode, screen memory is replaced with a bitmap. (There is
1694 // no cursor on the graphic display.) Each bit in the bitmap controls
1695 // the state of one pixel in the display. The layout of the
1696 // bitmap is much simpler than that for'the VIC screen. Each
1697 // horizontal scan line is controlled by a sequential series of
1698 // bytes. The size of the bitmap (in bytes) is determined by the
1699 // number of active horizontal positions times the number of vertical
1700 // positions times the number of scan lines per vertical position.
1701 // For the standard screen setup, this means that 80 * 25 *
1702 // 8, or 16,000 bytes, are required—almost all of the available
1703 // VDC memory. At eight pixels per byte, there are 128,000 individual
1704 // pixels on the graphic display.
1705
1706 // The graphic display can use attribute memory for color
1707 // information. In this case, the relationship of attribute locations
1708 // to bitmap positions is similar to that for the VIC screen. Each
1709 // attribute memory location controls the color for all pixeis
1710 // within a character-position area on the screen. However, there
1711 // isn't enough free memory available for a full bitmap and a full
1712 // attribute memory area. One solution is to turn off attributes
1713 // (set bit 6 of register 25/$19 to %0). This limits all screen positions
1714 // to the same foreground and background colors (as specified
1715 // in register 26/$lA). The other solution is to reduce the
1716 // size of the active screen area to free up enough memory for an
1717 // attribute area. For example, if you reduce the number of active
1718 // rows to 22, then 80 * 22 * 8, or 14,080 bytes, will be required
1719 // for the bitmap, and 80 * 22, or 1760 bytes, will be required for
1720 // attribute memory, so there will be enough room within VDC
1721 // memory for both bitmap and attributes.
1722 // When attribute memory is enabled for a graphic display,
1723 // the lower four bits of each attribute memory location determine
1724 // the color of all foreground (%1) pixels in the corresponding
1725 // character-position area, and the upper four bits determine
1726 // the color of all background (%0) pixels in the character
1727 // position.
1728
1729 outline0("LD A, $19");
1730 outline0("LD IXH, A");
1731 outline1("LD A, $%2.2x", horizontalSmoothScrollingAndControl );
1732 outline0("LD IXL, A");
1733 outline0("CALL VDCZWRITE");
1734
1736 // -- [ $1a ] --
1738
1739 // Background and foreground colors
1740
1741 // Bits 0-3: The value in these bits determines the background
1742 // color of the display. For text mode, this is the color of all
1743 // pixels represented by %0 bits in the pattern definition for the
1744 // character in each screen position. For graphic mode with
1745 // attribute memory disabled, the value here determines the color
1746 // all pixels represented by %0 bits in the bitmap. The correspondence
1747 // between register value and background color is
1748 // as shown in Table 8-5. For graphic mode with attribute memory
1749 // enabled, the value here determines the color of the screen
1750 // border only.
1751
1752 // The default background color value, 0/$00 (black), is established
1753 // by the Kernal IOINIT routine [$E109], part of both
1754 // the reset and RUN/STOP-RESTORE sequences.
1755
1756 // Bits 4-7: When attributes are disabled (by setting bit 6 of register
1757 // 25/$19 to %0), the value in these bits specifies the foreground
1758 // color for the display. For text mode, this is the color
1759 // for all pixels represented by %1 bits in the pattern definitions
1760 // for all screen positions. For graphic mode, the value here determines
1761 // the color of all pixels represented by %1 bits in the
1762 // bitmap. For either mode, if the screen is switched to reverse
1763 // mode (by setting bit 6 of register 24/S18), the value here will
1764 // instead determine the color for all pixels represented by %0
1765 // bits in the character pattern or bitmap. The correspondence
1766 // between bit values and colors is as shown in Table 8-5.
1767
1768 outline0("LD A, $1a");
1769 outline0("LD IXH, A");
1770 outline1("LD A, $%2.2x", 0xf0 );
1771 outline0("LD IXL, A");
1772 outline0("CALL VDCZWRITE");
1773
1775 // -- [ $1b ] --
1777
1778 // Address increment per row of characters
1779
1780 // The value in this register will be added to the value in register
1781 // 1/S01 to determine the amount by which to increase the screen
1782 // memory address for each new row of the display. This allows
1783 // you to set up a virtual screen wider than the actual screen.
1784 // You can scroll back and forth across the virtual screen by adjusting
1785 // the screen starting address in registers 12-13/$0C-$0D.
1786 // The default value for this register is 0/$00, since no extra
1787 // columns are used with the 80-column text display. The screen
1788 // editor routines that support printing to the VDC screen all assume
1789 // an 80-column screen line. If you reduce the number of
1790 // active columns in register l/$01, you should increase the value
1791 // in this register correspondingly so that the total remains 80.
1792
1793 outline0("LD A, $1b");
1794 outline0("LD IXH, A");
1795 outline1("LD A, $%2.2x", addressIncrementPerRowOfChars );
1796 outline0("LD IXL, A");
1797 outline0("CALL VDCZWRITE");
1798
1800 // -- [ $1c ] --
1802
1803 // Character pattern address and memory type
1804
1805 // Bit 4: This bit specifies the type of RAM chip used for VDC
1806 // video memory. When the bit is %0, the VDC is configured for
1807 // 4416 chips (16K X 4 bits). When the bit is %1, the VDC is
1808 // configured for 4164 chips (64K X 1 bit). Since the 16K VDC
1809 // video memory space in the 128 is provided by two 4416 chips,
1810 // this bit is initialized to %0 by the Kernal IO1NIT routine
1811 // [$E109]. It is theoretically possible to replace the existing chips
1812 // with the 64K variety to quadruple the amount of available
1813 // VDC RAM. However, the swap involves unsoldering the existing
1814 // chips from the circuit board and soldering the new ones in
1815 // their place. This is not a task for the inexperienced, and will
1816 // most certainly void any warranty on your 128.
1817
1818 // Bits 5-7: These bits determine where within VDC memory the
1819 // character pattern definitions will be located. The amount of
1820 // memory required for the character set depends on the value in
1821 // register 9/$09. If the character height is 16 or fewer scan lines,
1822 // each character set requires 4K (4096 bytes). Character heights
1823 // of 17-32 scan lines require 8K (8192-b'yte) character sets. The
1824 // VDC normally supports a pair of character sets, using bit 7 of
1825 // the attribute memory location to select between them for each
1826 // character position. Thus, 8K is normally used for character sets
1827 // when the character height is 16 or fewer scan lines, and 16K is
1828 // used when the character height is greater than 16 scan lines.
1829
1830 // In the latter case, bit 5 is not used in the address selection.
1831 // The possible starting addresses for character patterns are as
1832 // follows (the asterisks indicate valid selections for 16K-character
1833 // set pairs):
1834
1835 // Bits Character memory
1836 // 7 6 5 starting address
1837 // 0 0 0 0/$0000 *
1838 // 0 0 1 8192/$2000
1839 // 0 1 0 16384/$4000 *
1840 // 0 1 1 24576/$6000
1841 // 1 0 0 32768/$8000 *
1842 // 1 0 1 40960/SAOOO
1843 // 1 1 0 39152/SC0O0 *
1844 // 1 1 1 57344/$E000
1845
1846 // Since the 128 has only 16K of RAM for the VDC, only the
1847 // first two settings are currently valid. (Note that there is insufficient
1848 // room in the 128's 16K of VDC video memory for a 16K
1849 // character set plus screen and attribute memory.) These bits are
1850 // initialized to %001 by the IOINIT routine [$E109], part of the
1851 // reset and RUN/STOP-RESTORE sequences, so the default
1852 // character set starting address is 8192/$2000. Since this area is
1853 // RAM, not ROM, it is necessary to copy character patterns into
1854 // this area of memory if the VDC is to display recognizable
1855 // characters. This step is performed during the IOINIT routine
1856 // by calling the screen editor INIT80 routine [$CE0C].
1857
1858 outline0("LD A, $1c");
1859 outline0("LD IXH, A");
1860 outline0("CALL VDCZREAD");
1861 outline0("AND $1F");
1862 outline1("OR $%2.2x", ( characterPatternAddress << 5 ) );
1863 outline0("LD IXL, A");
1864 outline0("CALL VDCZWRITE");
1865
1867 // -- [ $1d ] --
1869
1870 // Underline scan-line control
1871
1872 // Bits 0-4: The value in these bits determines which scan line
1873 // within the character position will be filled for any characters
1874 // with the underline attribute. (A character position has the underline
1875 // attribute when the corresponding attribute memory position
1876 // has bit 5 set to %1.) Since the line can appear on any
1877 // horizontal scan line of the character position, it's not strictly
1878 // correct to call it an underline. For example, you could move
1879 // the line to the top line of the position to be an overbar, or to
1880 // the middle line of the position to serve as an overstrike. Scan
1881 // line 0 is the top line of the character position. The available
1882 // five bits allow a maximum scan-line value of %11111 = 31/
1883 // $1F. However, the underline will not be visible if the value is
1884 // greater than the maximum character-position height in bits
1885 // 4-7 of register 22/$16.
1886
1887 // outline0("LD A, $1d");
1888 // outline0("LD IXH, A");
1889 // outline0("LD A, $%2.2x", 0x08 );
1890 // outline0("LD IXL, A");
1891 // outline0("CALL VDCZWRITE");
1892
1894 // -- [ $1e ] --
1896
1897 // Number of bytes to copy or fill
1898
1899 // The VDC has the capability to copy blocks of data up to 255
1900 // characters long from one area of VDC memory to another, and
1901 // to fill areas up to 255 bytes long with a specified value. The
1902 // value in this register determines the number of bytes to be
1903 // copied or filled. The copy or fill operation begins immediately
1904 // after the count value is stored here. The setting of bit 7 of register
1905 // 24/$18 determines whether the operation will be a copy
1906 // or a fill.
1907
1908 // outline0("LD A, $1e");
1909 // outline0("LD IXH, A");
1910 // outline0("LD A, $%2.2x", 0x00 );
1911 // outline0("LD IXL, A");
1912 // outline0("CALL VDCZWRITE");
1913
1915 // -- [ $1f ] --
1917
1918 // Memory read/write
1919
1920 // This register is the gateway between the VDC's private block
1921 // of RAM and the rest of the 128 system. When read, this
1922 // location reflects the contents of the VDC memory location addressed
1923 // in registers IS—19/$12—$13. Writing a value to this
1924 // register will cause the value to be transferred to the location
1925 // addressed in registers 18—19/$12—13. For both reading and
1926 // writing, the address in registers 18-19/$12-$13 will automatically
1927 // be incremented after this register is accessed. Thus, to
1928 // read or write a sequential series of locations you need only
1929 // load the starting address of the series into registers 18—19/
1930 // $12—$13. You can then read or write repeatedly to register
1931 // 31/$1F; the destination address will automatically increment
1932 // after each read or write.
1933
1934 // outline0("LD A, $1f");
1935 // outline0("LD IXH, A");
1936 // outline0("LD A, $%2.2x", 0x00 );
1937 // outline0("LD IXL, A");
1938 // outline0("CALL VDCZWRITE");
1939
1941 // -- [ $20-$21 ] --
1943
1944 // Source address for block copy
1945
1946 // The VDC has the capability to copy blocks of data up to 255
1947 // bytes long from one area of memory to another (see the entry
1948 // for register 3O/$1E for details). The value in this register pair
1949 // determines the source address for copy operations, the address
1950 // from which data will be copied. Like all other address register
1951 // pairs in the VDC, the first register (32/$20) holds the high
1952 // byte of the address and the second (33/$21) holds the low
1953 // byte—the opposite of the normal 8502 address format. The
1954 // registers should be loaded with the desired source starting address
1955 // before the copy operation is initiated. Upon completion
1956 // of the operation, the registers will hold the address of the next
1957 // location beyond the last one involved in the operation. Thus,
1958 // it is possible to copy blocks of more than 255 successive bytes
1959 // by using repeated copy operations without reloading these
1960 // registers.
1961
1962 // outline0("LD A, $20");
1963 // outline0("LD IXH, A");
1964 // outline0("LD A, $%2.2x", 0x00 );
1965 // outline0("LD IXL, A");
1966 // outline0("CALL VDCZWRITE");
1967 // outline0("LD A, $21");
1968 // outline0("LD IXH, A");
1969 // outline0("LD A, $%2.2x", 0x00 );
1970 // outline0("LD IXL, A");
1971 // outline0("CALL VDCZWRITE");
1972
1974 // -- [ $22-$23 ] --
1976
1977 // Horizontal blanking positions
1978
1979 // The VDC can adjust its horizontal blanking interval to blank a
1980 // portion of the screen. These locations control the horizontal
1981 // width and position of the blanked area. If the blanked area extends
1982 // onto the active portion of the screen, any text under the
1983 // blanked area is only covered, not erased. The value in register
1984 // 34/$22 determines the rightmost blanked column, and the
1985 // value in register 35/$23 determines the leftmost blanked column.
1986 // The blanked area extends the entire height of the screen.
1987 // The value in register 34/$22 must be less than the value
1988 // in register 0/$00; otherwise, the entire display will be
1989 // blanked. The value in 34/$22 here must also be greater than
1990 // the value in register 35/$23 to prevent an entirely blank display.
1991 // The default values for these locations are 125/S7D and
1992 // 100/$64, respectively. This positions the blanking interval entirely
1993 // outside the active screen area. For purposes of blanking
1994 // an area of the screen, a value of 6/$06 in these registers corresponds
1995 // to the leftmost column of the standard screen and a
1996 // value of 85/$55 corresponds to the rightmost column.
1997
1998 // outline0("LD A, $22");
1999 // outline0("LD IXH, A");
2000 // outline0("LD A, $%2.2x", 0x06 );
2001 // outline0("LD IXL, A");
2002 // outline0("CALL VDCZWRITE");
2003 // outline0("LD A, $23");
2004 // outline0("LD IXH, A");
2005 // outline0("LD A, $%2.2x", 0x55 );
2006 // outline0("LD IXL, A");
2007 // outline0("CALL VDCZWRITE");
2008
2010 // -- [ $24 ] --
2012
2013 // Number of memory refresh cycles per scan line
2014
2015 // Bits 0-3: The value in these bits determines the number of
2016 // memory refresh cycles per scan line. The RAM chip used for
2017 // the VDC's video memory is a type known as dynamic RAM.
2018 // A dynamic RAM can hold data only briefly without external
2019 // support. Just as the image on the video screen must be constantly
2020 // redrawn to keep it from fading away, dynamic RAM
2021 // must be constantly refreshed to keep it from losing its contents.
2022 // The VDC handles this refresh function automatically for
2023 // its video RAM, just as the VIC automatically handles the refreshing
2024 // of system RAM. However, for the VDC, the number
2025 // of refresh cycles provided during each scan line is programmable.
2026 // The IOINIT routine [SE109] initializes these bits to %0101
2027 // for five refresh cycles per scan line, and there's no reason to
2028 // change that setting.
2029
2030 // outline0("LD A, $24");
2031 // outline0("LD IXH, A");
2032 // outline0("LD A, $%2.2x", 0x05 );
2033 // outline0("LD IXL, A");
2034 // outline0("CALL VDCZWRITE");
2035
2036 cpu_store_16bit( _environment, "CLIPX1", 0 );
2037 cpu_store_16bit( _environment, "CLIPX2", (_environment->screenWidth-1) );
2038 cpu_store_16bit( _environment, "CLIPY1", 0 );
2039 cpu_store_16bit( _environment, "CLIPY2", (_environment->screenHeight-1) );
2040
2041 cpu_store_16bit( _environment, "ORIGINX", 0 );
2042 cpu_store_16bit( _environment, "ORIGINY", 0 );
2043
2044 cpu_store_16bit( _environment, "CURRENTWIDTH", _environment->screenWidth );
2045 cpu_store_16bit( _environment, "CURRENTHEIGHT", _environment->screenHeight );
2046 cpu_move_16bit( _environment, "CURRENTWIDTH", "RESOLUTIONX" );
2047 cpu_move_16bit( _environment, "CURRENTHEIGHT", "RESOLUTIONY" );
2048 cpu_store_8bit( _environment, "CURRENTTILES", _environment->screenTiles );
2049 cpu_store_8bit( _environment, "CURRENTTILESWIDTH", _environment->screenTilesWidth );
2050 cpu_store_8bit( _environment, "CURRENTTILESHEIGHT", _environment->screenTilesHeight );
2051 cpu_store_8bit( _environment, "FONTWIDTH", _environment->fontWidth );
2052 cpu_store_8bit( _environment, "FONTHEIGHT", _environment->fontHeight );
2053
2054 console_init( _environment );
2055
2056 _environment->screenShades = 16;
2057 _environment->screenColors = 2;
2058
2059 if (_environment->vestigialConfig.clsImplicit ) {
2060 vdcz_cls( _environment );
2061 }
2062
2063}
2064
2065void vdcz_bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
2066
2067 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 1, _width, _height, _colors, 8, 8 );
2068
2069 if ( mode ) {
2070 vdcz_screen_mode_enable( _environment, mode );
2071
2072 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
2073 cpu_store_8bit( _environment, "CURRENTTILEMODE", 0 );
2074
2075 _environment->currentMode = mode->id;
2076 _environment->currentTileMode = 0;
2077
2078 vdcz_cls( _environment );
2079
2080 } else {
2081 WARNING_SCREEN_MODE( -1 );
2082 }
2083
2084}
2085
2086void vdcz_bitmap_disable( Environment * _environment ) {
2087
2088}
2089
2090void vdcz_tilemap_enable( Environment * _environment, int _width, int _height, int _colors, int _tile_width, int _tile_height ) {
2091
2092 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 0, _width, _height, _colors, _tile_width, _tile_height );
2093
2094 if ( mode ) {
2095
2096 vdcz_screen_mode_enable( _environment, mode );
2097
2098 _environment->currentMode = mode->id;
2099 _environment->currentTileMode = 1;
2100
2101 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
2102 cpu_store_8bit( _environment, "CURRENTTILEMODE", 1 );
2103
2104 vdcz_cls( _environment );
2105
2106 } else {
2107 WARNING_SCREEN_MODE( -1 );
2108 }
2109
2110}
2111
2112void vdcz_bitmap_at( Environment * _environment, char * _address ) {
2113
2114}
2115
2116void vdcz_colormap_at( Environment * _environment, char * _address ) {
2117
2118}
2119
2120void vdcz_textmap_at( Environment * _environment, char * _address ) {
2121
2122}
2123
2124void vdcz_pset_int( Environment * _environment, int _x, int _y, int *_c ) {
2125
2126 deploy( vdczvars, src_hw_vdcz_vars_asm);
2127 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
2128 deploy( plot, src_hw_vdcz_plot_asm );
2129
2130 if ( _c ) {
2131 outline1("LD A, $%2.2x", ( *_c & 0xff ) );
2132 } else {
2133 Variable * c = variable_retrieve( _environment, "PEN" );
2134 outline1("LD A, (%s)", c->realName );
2135 }
2136 outline0( "LD (PLOTCPE), A" );
2137 outline1( "LD A, $%2.2x", ( _x & 0xff ) );
2138 outline0( "LD E, A" );
2139 outline1( "LD A, $%2.2x", ( ( _x >> 8 ) & 0xff ) );
2140 outline0( "LD D, A" );
2141 outline1( "LD A, $%2.2x", ( _y & 0xff ) );
2142 outline0( "LD IYL, A" );
2143 outline1( "LD A, $%2.2x", ( ( _y >> 8 ) & 0xff ) );
2144 outline0( "LD IYH, A" );
2145 outline0( "LD A, 1" );
2146 outline0( "CALL PLOT" );
2147
2148}
2149
2150void vdcz_pset_vars( Environment * _environment, char *_x, char *_y, char *_c ) {
2151
2152 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
2153 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
2154 Variable * c;
2155
2156 if ( _c ) {
2157 c = variable_retrieve_or_define( _environment, _c, VT_COLOR, 0 );
2158 } else {
2159 c = variable_retrieve( _environment, "PEN" );
2160 }
2161
2162 deploy( vdczvars, src_hw_vdcz_vars_asm);
2163 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
2164 deploy( plot, src_hw_vdcz_plot_asm );
2165
2166 outline1( "LD A, (%s)", c->realName );
2167 outline0( "LD (PLOTCPE), A" );
2168 outline1( "LD A, (%s)", x->realName );
2169 outline0( "LD E, A" );
2170 outline1( "LD A, (%s+1)", x->realName );
2171 outline0( "LD D, A" );
2172 outline1( "LD A, (%s)", y->realName );
2173 outline0( "LD IYL, A" );
2174 outline1( "LD A, (%s+1)", y->realName );
2175 outline0( "LD IYH, A" );
2176 outline0( "LD A, 1" );
2177 outline0( "CALL PLOT" );
2178
2179}
2180
2181void vdcz_pget_color_vars( Environment * _environment, char *_x, char *_y, char * _result ) {
2182
2183 Variable * x = variable_retrieve( _environment, _x );
2184 Variable * y = variable_retrieve( _environment, _y );
2185 Variable * result = variable_retrieve( _environment, _result );
2186
2187 deploy( vdczvars, src_hw_vdcz_vars_asm);
2188 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
2189 deploy( plot, src_hw_vdcz_plot_asm );
2190
2191 outline1( "LD A, (%s)", x->realName );
2192 outline0( "LD E, A" );
2193 outline1( "LD A, (%s+1)", x->realName );
2194 outline0( "LD D, A" );
2195 outline1( "LD A, (%s)", y->realName );
2196 outline0( "LD IYL, A" );
2197 outline1( "LD A, (%s+1)", y->realName );
2198 outline0( "LD IYH, A" );
2199 outline0( "LD A, 3" );
2200 outline0( "CALL PLOT" );
2201 outline1( "LD (%s), A", result->realName );
2202
2203}
2204
2205void vdcz_screen_on( Environment * _environment ) {
2206
2207}
2208
2209void vdcz_screen_off( Environment * _environment ) {
2210
2211}
2212
2213void vdcz_screen_rows( Environment * _environment, char * _rows ) {
2214
2215}
2216
2217void vdcz_screen_columns( Environment * _environment, char * _columns ) {
2218
2219}
2220
2221void vdcz_sprite_data_set( Environment * _environment, char * _sprite, char * _address ) {
2222
2223}
2224
2225void vdcz_sprite_data_from( Environment * _environment, char * _sprite, char * _address ) {
2226
2227 _environment->bitmaskNeeded = 1;
2228
2229 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2230 Variable * image = variable_retrieve_or_define( _environment, _sprite, VT_IMAGE, 0 );
2231
2232}
2233
2234void vdcz_sprite_enable( Environment * _environment, char * _sprite ) {
2235
2236 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2237
2238}
2239
2240void vdcz_sprite_disable( Environment * _environment, char * _sprite ) {
2241
2242 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2243
2244}
2245
2246void vdcz_sprite_at( Environment * _environment, char * _sprite, char * _x, char * _y ) {
2247
2248 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2249 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
2250 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
2251
2252}
2253
2254void vdcz_sprite_expand_vertical( Environment * _environment, char * _sprite ) {
2255
2256 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2257
2258}
2259
2260void vdcz_sprite_expand_horizontal( Environment * _environment, char * _sprite ) {
2261
2262 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2263
2264}
2265
2266void vdcz_sprite_compress_vertical( Environment * _environment, char * _sprite ) {
2267
2268 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2269
2270}
2271
2272void vdcz_sprite_compress_horizontal( Environment * _environment, char * _sprite ) {
2273
2274 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2275
2276}
2277
2278void vdcz_sprite_multicolor( Environment * _environment, char * _sprite ) {
2279
2280 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2281
2282}
2283
2284void vdcz_sprite_monocolor( Environment * _environment, char * _sprite ) {
2285
2286 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2287
2288}
2289
2290void vdcz_sprite_color( Environment * _environment, char * _sprite, char * _color ) {
2291
2292 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2293 Variable * color = variable_retrieve_or_define( _environment, _color, VT_COLOR, COLOR_WHITE );
2294
2295}
2296
2297void vdcz_sprite_priority( Environment * _environment, char * _sprite, char * _priority ) {
2298
2299 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
2300 Variable * priority = variable_retrieve_or_define( _environment, _priority, VT_BYTE, 0 );
2301
2302}
2303
2304void vdcz_tiles_at( Environment * _environment, char * _address ) {
2305
2306}
2307
2308void vdcz_vertical_scroll( Environment * _environment, char * _displacement ) {
2309
2310}
2311
2312void vdcz_horizontal_scroll( Environment * _environment, char * _displacement ) {
2313
2314 // outline0("LD A, 2");
2315 // outline0("LD IXH, A");
2316 // outline0("LD A, $%2.2x", 102 );
2317 // outline0("LD IXL, A");
2318 // outline0("CALL VDCZWRITE");
2319
2320}
2321
2322void vdcz_busy_wait( Environment * _environment, char * _timing ) {
2323
2324}
2325
2326void vdcz_get_width( Environment * _environment, char *_result ) {
2327
2328}
2329
2330void vdcz_tiles_get( Environment * _environment, char *_result ) {
2331
2332}
2333
2334void vdcz_get_height( Environment * _environment, char *_result ) {
2335
2336}
2337
2338void vdcz_cls( Environment * _environment ) {
2339
2340 if ( _environment->currentMode != TILEMAP_MODE_STANDARD ) {
2341 deploy( clsGraphic, src_hw_vdcz_cls_graphic_asm );
2342 outline0("CALL CLSG");
2343 } else {
2344 deploy( clsText, src_hw_vdcz_cls_text_asm );
2345 outline0("CALL CLST");
2346 }
2347
2348}
2349
2350void vdcz_cls_box( Environment * _environment, char * _x1, char * _y1, char * _w, char * _h ) {
2351
2352 if ( _environment->currentMode != TILEMAP_MODE_STANDARD ) {
2353 deploy( clsBox, src_hw_vdcz_cls_box_asm );
2354 outline1("LD DE, (%s)", _x1 );
2355 outline1("LD IY, (%s)", _y1 );
2356 outline1("LD A, (%s)", _w );
2357 outline0("LD C, A");
2358 outline1("LD A, (%s)", address_displacement( _environment, _w, "1" ) );
2359 outline0("LD IXH, A");
2360 outline1("LD A, (%s)", _h);
2361 outline0("LD B, A");
2362 outline0("CALL CLSBOX");
2363 } else {
2364
2365 }
2366
2367}
2368
2369void vdcz_scroll_text( Environment * _environment, int _direction, int _overlap ) {
2370
2371 if ( _direction > 0 ) {
2372 deploy( vScrollTextDown, src_hw_vdcz_vscroll_text_down_asm );
2373 outline0("CALL VSCROLLTDOWN");
2374 } else {
2375 deploy( vScrollTextUp, src_hw_vdcz_vscroll_text_up_asm );
2376 outline0("CALL VSCROLLTUP");
2377 }
2378
2379}
2380
2381void vdcz_text( Environment * _environment, char * _text, char * _text_size, int _raw ) {
2382
2383 deploy( vdczvars, src_hw_vdcz_vars_asm);
2384 deploy( textEncodedAt, src_hw_vdcz_text_at_asm );
2385
2386 outline1("LD DE, (%s)", _text);
2387 outline1("LD A, (%s)", _text_size);
2388 outline0("LD C, A");
2389
2390 if ( _raw ) {
2391 if ( _environment->currentMode != TILEMAP_MODE_STANDARD ) {
2392 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm);
2393 deploy( vScroll, src_hw_vdcz_vscroll_asm );
2394 deploy( clsGraphic, src_hw_vdcz_cls_graphic_asm );
2395 deploy( textEncodedAtGraphicRaw, src_hw_vdcz_text_at_graphic_raw_asm );
2396 outline0("CALL TEXTATBITMAPMODERAW");
2397 } else {
2398 deploy( vScrollTextUp, src_hw_vdcz_vscroll_text_up_asm );
2399 deploy( clsText, src_hw_vdcz_cls_text_asm );
2400 deploy( textEncodedAtTextRaw, src_hw_vdcz_text_at_text_raw_asm );
2401 outline0("CALL TEXTATTILEMODERAW");
2402 }
2403 } else {
2404 if ( _environment->currentMode != TILEMAP_MODE_STANDARD ) {
2405 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm);
2406 deploy( vScroll, src_hw_vdcz_vscroll_asm );
2407 deploy( clsGraphic, src_hw_vdcz_cls_graphic_asm );
2408 deploy( textEncodedAtGraphic, src_hw_vdcz_text_at_graphic_asm );
2409 outline0("CALL TEXTATBITMAPMODE");
2410 } else {
2411 deploy( vScrollTextUp, src_hw_vdcz_vscroll_text_up_asm );
2412 deploy( clsText, src_hw_vdcz_cls_text_asm );
2413 deploy( textEncodedAtText, src_hw_vdcz_text_at_text_asm );
2414 outline0("CALL TEXTATTILEMODE");
2415 }
2416 }
2417
2418
2419}
2420
2421void vdcz_initialization( Environment * _environment ) {
2422
2423 deploy( vdczvars, src_hw_vdcz_vars_asm );
2424 deploy_preferred( vdczstartup, src_hw_vdcz_startup_asm );
2425
2426 variable_import( _environment, "CURRENTWIDTH", VT_POSITION, 256 );
2427 variable_global( _environment, "CURRENTWIDTH" );
2428 variable_import( _environment, "CURRENTHEIGHT", VT_POSITION, 192 );
2429 variable_global( _environment, "CURRENTHEIGHT" );
2430 variable_import( _environment, "CURRENTTILES", VT_BYTE, 255 );
2431 variable_global( _environment, "CURRENTTILES" );
2432 variable_import( _environment, "CURRENTTILESWIDTH", VT_SBYTE, 40 );
2433 variable_global( _environment, "CURRENTTILESWIDTH" );
2434 variable_import( _environment, "CURRENTTILESHEIGHT", VT_SBYTE, 24 );
2435 variable_global( _environment, "CURRENTTILESHEIGHT" );
2436 variable_import( _environment, "FONTWIDTH", VT_BYTE, 8 );
2437 variable_global( _environment, "FONTWIDTH" );
2438 variable_import( _environment, "FONTHEIGHT", VT_BYTE, 8 );
2439 variable_global( _environment, "FONTHEIGHT" );
2440 variable_import( _environment, "SPRITEADDRESS", VT_ADDRESS, 0x0000 );
2441 variable_global( _environment, "SPRITEADDRESS" );
2442 variable_import( _environment, "SPRITEAADDRESS", VT_ADDRESS, 0x1000 );
2443 variable_global( _environment, "SPRITEAADDRESS" );
2444 variable_import( _environment, "TEXTADDRESS", VT_ADDRESS, 0x1800 );
2445 variable_global( _environment, "TEXTADDRESS" );
2446 variable_import( _environment, "COLORMAPADDRESS", VT_ADDRESS, 0x3800 );
2447 variable_global( _environment, "COLORMAPADDRESS" );
2448 variable_import( _environment, "PATTERNADDRESS", VT_ADDRESS, 0x0000 );
2449 variable_global( _environment, "PATTERNADDRESS" );
2450 variable_import( _environment, "PALETTE", VT_BUFFER, 16 );
2451 variable_global( _environment, "PALETTE" );
2452
2453 SCREEN_MODE_DEFINE( TILEMAP_MODE_STANDARD, 0, 80, 25, 8, 8, 8, "Text Mode" );
2454 SCREEN_MODE_DEFINE( BITMAP_MODE_STANDARD, 1, 640, 200, 1, 8, 8, "Bitmap Mode" );
2455 // SCREEN_MODE_DEFINE( BITMAP_MODE_MULTICOLOR, 1, 640, 200, 16, 8, 8, "Multicolor Mode" );
2456 // SCREEN_MODE_DEFINE( BITMAP_MODE_STANDARD_INT, 1, 640, 176, 1, 8, 8, "Interlaced bitmap Mode" );
2457 // SCREEN_MODE_DEFINE( BITMAP_MODE_MULTICOLOR_INT, 1, 640, 352, 1, 8, 8, "Interlaced multicolor Mode" );
2458
2459 outline0("CALL VDCZSTARTUP");
2460
2461 variable_import( _environment, "XGR", VT_POSITION, 0 );
2462 variable_global( _environment, "XGR" );
2463 variable_import( _environment, "YGR", VT_POSITION, 0 );
2464 variable_global( _environment, "YGR" );
2465 variable_import( _environment, "LINE", VT_WORD, (unsigned short)(0xffff) );
2466 variable_global( _environment, "LINE" );
2467
2468 variable_import( _environment, "CLIPX1", VT_POSITION, 0 );
2469 variable_global( _environment, "CLIPX1" );
2470 variable_import( _environment, "CLIPX2", VT_POSITION, 255 );
2471 variable_global( _environment, "CLIPX2" );
2472 variable_import( _environment, "CLIPY1", VT_POSITION, 0 );
2473 variable_global( _environment, "CLIPY1" );
2474 variable_import( _environment, "CLIPY2", VT_POSITION, 191 );
2475 variable_global( _environment, "CLIPY2" );
2476
2477 variable_import( _environment, "ORIGINX", VT_POSITION, 0 );
2478 variable_global( _environment, "ORIGINX" );
2479 variable_import( _environment, "ORIGINY", VT_POSITION, 0 );
2480 variable_global( _environment, "ORIGINY" );
2481
2482 variable_import( _environment, "RESOLUTIONX", VT_POSITION, 0 );
2483 variable_global( _environment, "RESOLUTIONX" );
2484 variable_import( _environment, "RESOLUTIONY", VT_POSITION, 0 );
2485 variable_global( _environment, "RESOLUTIONY" );
2486
2487 variable_import( _environment, "TABCOUNT", VT_BYTE, 4 );
2488 variable_global( _environment, "TABCOUNT" );
2489
2490 variable_import( _environment, "CLINEX", VT_BYTE, 0 );
2491 variable_global( _environment, "CLINEX" );
2492
2493 variable_import( _environment, "CLINEY", VT_BYTE, 0 );
2494 variable_global( _environment, "CLINEY" );
2495
2496 variable_import( _environment, "TABSTODRAW", VT_BYTE, 0 );
2497 variable_global( _environment, "TABSTODRAW" );
2498
2499 variable_import( _environment, "CURRENTMODE", VT_BYTE, 0 );
2500 variable_global( _environment, "CURRENTMODE" );
2501 variable_import( _environment, "CURRENTTILEMODE", VT_BYTE, 1 );
2502 variable_global( _environment, "CURRENTTILEMODE" );
2503
2504 variable_import( _environment, "SPRITECOUNT", VT_SPRITE, 0 );
2505 variable_global( _environment, "SPRITECOUNT" );
2506
2507 variable_import( _environment, "TILEX", VT_BYTE, 0 );
2508 variable_global( _environment, "TILEX" );
2509 variable_import( _environment, "TILEY", VT_BYTE, 0 );
2510 variable_global( _environment, "TILEY" );
2511 variable_import( _environment, "TILEX2", VT_BYTE, 0 );
2512 variable_global( _environment, "TILEX2" );
2513 variable_import( _environment, "TILET", VT_BYTE, 0 );
2514 variable_global( _environment, "TILET" );
2515 variable_import( _environment, "TILEW", VT_BYTE, 0 );
2516 variable_global( _environment, "TILEW" );
2517 variable_import( _environment, "TILEH", VT_BYTE, 0 );
2518 variable_global( _environment, "TILEH" );
2519 variable_import( _environment, "TILEW2", VT_BYTE, 0 );
2520 variable_global( _environment, "TILEW2" );
2521 variable_import( _environment, "TILEH2", VT_BYTE, 0 );
2522 variable_global( _environment, "TILEH2" );
2523 variable_import( _environment, "TILEA", VT_BYTE, 0 );
2524 variable_global( _environment, "TILEA" );
2525 variable_import( _environment, "TILEO", VT_WORD, 0 );
2526 variable_global( _environment, "TILEO" );
2527
2528 variable_import( _environment, "XSCROLLPOS", VT_BYTE, 0 );
2529 variable_global( _environment, "XSCROLLPOS" );
2530 variable_import( _environment, "YSCROLLPOS", VT_BYTE, 0 );
2531 variable_global( _environment, "YSCROLLPOS" );
2532 variable_import( _environment, "XSCROLL", VT_BYTE, 0 );
2533 variable_global( _environment, "XSCROLL" );
2534 variable_import( _environment, "YSCROLL", VT_BYTE, 0 );
2535 variable_global( _environment, "YSCROLL" );
2536 variable_import( _environment, "DIRECTION", VT_BYTE, 0 );
2537 variable_global( _environment, "DIRECTION" );
2538
2539 variable_import( _environment, "ONSCROLLUP", VT_BUFFER, 3 );
2540 variable_global( _environment, "ONSCROLLUP" );
2541
2542 variable_import( _environment, "ONSCROLLDOWN", VT_BUFFER, 3 );
2543 variable_global( _environment, "ONSCROLLDOWN" );
2544
2545 variable_import( _environment, "ONSCROLLLEFT", VT_BUFFER, 3 );
2546 variable_global( _environment, "ONSCROLLLEFT" );
2547
2548 variable_import( _environment, "ONSCROLLRIGHT", VT_BUFFER, 3 );
2549 variable_global( _environment, "ONSCROLLRIGHT" );
2550
2551 variable_import( _environment, "IMAGEF", VT_BYTE, 0 );
2552 variable_global( _environment, "IMAGEF" );
2553
2554 variable_import( _environment, "IMAGET", VT_BYTE, 0 );
2555 variable_global( _environment, "IMAGET" );
2556
2557 variable_import( _environment, "BLITIMAGEBLITTINGADDR", VT_ADDRESS, 0 );
2558 variable_global( _environment, "BLITIMAGEBLITTINGADDR" );
2559 variable_import( _environment, "BLITTMPPTR", VT_ADDRESS, 0 );
2560 variable_global( _environment, "BLITTMPPTR" );
2561 variable_import( _environment, "BLITTMPPTR2", VT_ADDRESS, 0 );
2562 variable_global( _environment, "BLITTMPPTR2" );
2563
2564 variable_import( _environment, "VBLFLAG", VT_BYTE, 0 );
2565 variable_global( _environment, "VBLFLAG" );
2566
2567 vdcz_tilemap_enable( _environment, 80, 25, 8, 8, 8 );
2568
2569 font_descriptors_init( _environment, 0 );
2570
2571 _environment->currentRgbConverterFunction = rgbConverterFunction;
2572 _environment->screenShades = 16;
2573
2574}
2575
2576static RGBi * multicolorSpritePalette[2];
2577
2578void vdcz_finalization( Environment * _environment ) {
2579
2580 if ( _environment->vestigialConfig.clsImplicit ) {
2581 deploy( clsText, src_hw_vdcz_cls_text_asm );
2582 }
2583
2584 CopperList * copperList = _environment->copperList;
2585 if ( copperList ) {
2586 while(copperList) {
2587 outhead1("COPPERACTIVATE%s:", copperList->name ? copperList->name : "" );
2588 outline0("RET");
2589 copperList = copperList->next;
2590 }
2591 }
2592
2593}
2594
2595void vdcz_hscroll_line( Environment * _environment, int _direction, int _overlap ) {
2596
2597 deploy( textHScroll, src_hw_vdcz_hscroll_text_asm );
2598
2599}
2600
2601void vdcz_hscroll_screen( Environment * _environment, int _direction, int _overlap ) {
2602
2603 deploy( textHScroll, src_hw_vdcz_hscroll_text_asm );
2604
2605}
2606
2607void vdcz_back( Environment * _environment ) {
2608
2609 deploy( back, src_hw_vdcz_back_asm );
2610
2611}
2612
2613void vdcz_cline( Environment * _environment, char * _characters ) {
2614
2615 deploy( textCline, src_hw_vdcz_cline_asm );
2616
2617 if ( _characters ) {
2618 outline1("LD A, (%s)", _characters);
2619 outline0("LD C, A");
2620 } else {
2621 outline0("LD A, 0");
2622 outline0("LD C, A");
2623 }
2624 outline0("CALL CLINE");
2625
2626}
2627
2628Variable * vdcz_image_converter( Environment * _environment, char * _data, int _width, int _height, int _depth, int _offset_x, int _offset_y, int _frame_width, int _frame_height, int _mode, int _transparent_color, int _flags ) {
2629
2630 switch( _mode ) {
2631
2634
2635 return vcdz_image_converter_bitmap_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
2636
2639
2640 return vdcz_image_converter_bitmap_mode_multicolor( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
2641
2642 }
2643
2644 return vdcz_new_image( _environment, 8, 8, _mode );
2645
2646}
2647
2648Variable * vdcz_sprite_converter( Environment * _environment, char * _source, int _width, int _height, int _depth, RGBi * _color, int _flags ) {
2649
2650 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
2651
2652 return result;
2653
2654}
2655
2656static void vdcz_load_image_address_to_other_register( Environment * _environment, char * _register, char * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
2657
2658 outline1("LD HL, %s", _source );
2659 if ( _sequence ) {
2660
2661 outline0("LD DE, $0003" );
2662 outline0("ADD HL, DE" );
2663 if ( strlen(_sequence) == 0 ) {
2664
2665 } else {
2666 outline0("PUSH HL" );
2667 outline1("LD A, (%s)", _sequence );
2668 outline0("LD L, A" );
2669 outline0("LD H, 0" );
2670 outline0("ADD HL, HL" );
2671 outline0("LD DE, HL" );
2672 outline1("LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
2673 outline0("ADD HL, DE" );
2674 outline0("LD A, (HL)" );
2675 outline0("LD E, A" );
2676 outline0("INC HL" );
2677 outline0("LD A, (HL)" );
2678 outline0("LD D, A" );
2679 outline0("POP HL" );
2680 outline0("ADD HL, DE" );
2681 }
2682
2683 if ( _frame ) {
2684 if ( strlen(_frame) == 0 ) {
2685
2686 } else {
2687 outline0("PUSH HL" );
2688 outline1("LD A, (%s)", _frame );
2689 outline0("LD L, A" );
2690 outline0("LD H, 0" );
2691 outline0("ADD HL, HL" );
2692 outline0("LD DE, HL" );
2693 outline1("LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
2694 outline0("ADD HL, DE" );
2695 outline0("LD A, (HL)" );
2696 outline0("LD E, A" );
2697 outline0("INC HL" );
2698 outline0("LD A, (HL)" );
2699 outline0("LD D, A" );
2700 outline0("POP HL" );
2701 outline0("ADD HL, DE" );
2702 }
2703 }
2704
2705 } else {
2706
2707 if ( _frame ) {
2708 outline0("LD DE, $0003" );
2709 outline0("ADD HL, DE" );
2710 if ( strlen(_frame) == 0 ) {
2711
2712 } else {
2713 outline0("PUSH HL" );
2714 outline1("LD A, (%s)", _frame );
2715 outline0("LD L, A" );
2716 outline0("LD H, 0" );
2717 outline0("ADD HL, HL" );
2718 outline0("LD DE, HL" );
2719 outline1("LD HL, OFFSETS%4.4x", _frame_size );
2720 outline0("ADD HL, DE" );
2721 outline0("LD A, (HL)" );
2722 outline0("LD E, A" );
2723 outline0("INC HL" );
2724 outline0("LD A, (HL)" );
2725 outline0("LD D, A" );
2726 outline0("POP HL" );
2727 outline0("ADD HL, DE" );
2728 }
2729 }
2730
2731 }
2732
2733 if ( _register ) {
2734 outline1("LD (%s), HL", _register );
2735 }
2736
2737}
2738
2739void vdcz_calculate_sequence_frame_offset( Environment * _environment, char * _offset, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
2740
2741 outline0("LD HL, 0");
2742
2743 if ( _sequence ) {
2744
2745 outline0("LD DE, $0003" );
2746 outline0("ADD HL, DE" );
2747 if ( strlen(_sequence) == 0 ) {
2748
2749 } else {
2750 outline0("PUSH HL" );
2751 outline1("LD A, (%s)", _sequence );
2752 outline0("LD L, A" );
2753 outline0("LD H, 0" );
2754 outline0("ADD HL, HL" );
2755 outline0("LD DE, HL" );
2756 outline1("LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
2757 outline0("ADD HL, DE" );
2758 outline0("LD A, (HL)" );
2759 outline0("LD E, A" );
2760 outline0("INC HL" );
2761 outline0("LD A, (HL)" );
2762 outline0("LD D, A" );
2763 outline0("POP HL" );
2764 outline0("ADD HL, DE" );
2765 }
2766
2767 if ( _frame ) {
2768 if ( strlen(_frame) == 0 ) {
2769
2770 } else {
2771 outline0("PUSH HL" );
2772 outline1("LD A, (%s)", _frame );
2773 outline0("LD L, A" );
2774 outline0("LD H, 0" );
2775 outline0("ADD HL, HL" );
2776 outline0("LD DE, HL" );
2777 outline1("LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
2778 outline0("ADD HL, DE" );
2779 outline0("LD A, (HL)" );
2780 outline0("LD E, A" );
2781 outline0("INC HL" );
2782 outline0("LD A, (HL)" );
2783 outline0("LD D, A" );
2784 outline0("POP HL" );
2785 outline0("ADD HL, DE" );
2786 }
2787 }
2788
2789 } else {
2790
2791 if ( _frame ) {
2792 outline0("LD DE, $0003" );
2793 outline0("ADD HL, DE" );
2794 if ( strlen(_frame) == 0 ) {
2795
2796 } else {
2797 outline0("PUSH HL" );
2798 outline1("LD A, (%s)", _frame );
2799 outline0("LD L, A" );
2800 outline0("LD H, 0" );
2801 outline0("ADD HL, HL" );
2802 outline0("LD DE, HL" );
2803 outline1("LD HL, OFFSETS%4.4x", _frame_size );
2804 outline0("ADD HL, DE" );
2805 outline0("LD A, (HL)" );
2806 outline0("LD E, A" );
2807 outline0("INC HL" );
2808 outline0("LD A, (HL)" );
2809 outline0("LD D, A" );
2810 outline0("POP HL" );
2811 outline0("ADD HL, DE" );
2812 }
2813 }
2814
2815 }
2816
2817}
2818
2819static void vdcz_load_image_address_to_register( Environment * _environment, char * _register, Resource * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
2820
2821 if ( !_sequence && !_frame ) {
2822 if ( _source->isAddress ) {
2823 outline1("LD HL, (%s)", _source->realName );
2824 } else {
2825 outline1("LD HL, %s", _source->realName );
2826 }
2827 } else {
2828 if ( _source->isAddress ) {
2829 outline1("LD HL, (%s)", _source->realName );
2830 } else {
2831 outline1("LD HL, %s", _source->realName );
2832 }
2833
2834 if ( _sequence ) {
2835 outline0("LD DE, $0003" );
2836 outline0("ADD HL, DE" );
2837 if ( strlen(_sequence) == 0 ) {
2838
2839 } else {
2840 outline1("LD A, (%s)", _sequence );
2841 outline0("PUSH HL" );
2842 outline0("POP IX" );
2843 outline1("CALL %soffsetsequence", _source->realName );
2844 }
2845 if ( _frame ) {
2846 if ( strlen(_frame) == 0 ) {
2847
2848 } else {
2849 outline1("LD A, (%s)", _frame );
2850 outline0("PUSH HL" );
2851 outline0("POP IX" );
2852 outline1("CALL %soffsetframe", _source->realName );
2853 }
2854 }
2855
2856 } else {
2857
2858 if ( _frame ) {
2859 outline0("LD DE, $0003" );
2860 outline0("ADD HL, DE" );
2861 if ( strlen(_frame) == 0 ) {
2862
2863 } else {
2864 outline0("PUSH HL" );
2865 outline0("POP IX" );
2866 outline1("LD A, (%s)", _frame );
2867 outline1("CALL %soffsetframe", _source->realName );
2868 }
2869 }
2870
2871 }
2872
2873 }
2874 if ( _register ) {
2875 outline1("LD (%s), HL", _register );
2876 }
2877
2878}
2879
2880void vdcz_put_image( Environment * _environment, Resource * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _flags ) {
2881
2882 deploy( vdczvars, src_hw_vdcz_vars_asm);
2883 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
2884 deploy( putimage, src_hw_vdcz_put_image_asm );
2885
2887
2888 outhead1("putimage%s:", label);
2889
2890 if ( _frame_size ) {
2891 vdcz_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2892 }
2893
2894 outline1("LD DE, (%s)", _x );
2895 outline1("LD IY, (%s)", _y );
2896 outline0("PUSH HL" );
2897 outline1("LD HL, %s", _flags );
2898 outline0("LD A, L" );
2899 outline0("LD (IMAGEF), A" );
2900 outline0("LD A, H" );
2901 outline0("LD (IMAGET), A" );
2902 outline0("POP HL" );
2903
2904 outline0("CALL PUTIMAGE");
2905
2906}
2907
2908void vdcz_blit_image( Environment * _environment, char * _sources[], int _source_count, char * _blit, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _flags ) {
2909
2910 deploy( vdczvars, src_hw_vdcz_vars_asm);
2911 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
2912 deploy( blitimage, src_hw_vdcz_blit_image_asm );
2913
2914 if ( _source_count > 2 ) {
2916 }
2917
2919
2920 outline1("LD HL, %s", _blit );
2921 outline0("LD (BLITIMAGEBLITTINGADDR), HL");
2922
2923 outhead1("blitimage%s:", label);
2924 if ( _source_count > 0 ) {
2925 Resource resource;
2926 resource.realName = strdup( _sources[0] );
2927 resource.type = VT_IMAGE;
2928 vdcz_load_image_address_to_register( _environment, "BLITTMPPTR", &resource, _sequence, _frame, _frame_size, _frame_count );
2929 } else {
2930 outline0( "LD HL, 0" );
2931 outline0( "LD (BLITTMPPTR), HL" );
2932 }
2933
2934 if ( _source_count > 1 ) {
2935 Resource resource;
2936 resource.realName = strdup( _sources[0] );
2937 resource.type = VT_IMAGE;
2938 vdcz_load_image_address_to_register( _environment, "BLITTMPPTR2", &resource, _sequence, _frame, _frame_size, _frame_count );
2939 } else {
2940 outline0( "LD HL, 0" );
2941 outline0( "LD (BLITTMPPTR2), HL" );
2942 }
2943
2944 outline1("LD A, (%s)", _x );
2945 outline0("LD E, A" );
2946 outline1("LD A, (%s)", _y );
2947 outline0("LD D, A" );
2948 outline1("LD A, $%2.2x", ( _flags & 0xff ) );
2949 outline0("LD (IMAGEF), A" );
2950 outline1("LD A, $%2.2x", ( (_flags>>8) & 0xff ) );
2951 outline0("LD (IMAGET), A" );
2952
2953 outline0("CALL BLITIMAGE");
2954
2955}
2956
2957void vdcz_wait_vbl( Environment * _environment, char * _raster_line ) {
2958
2959 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
2960 deploy( vbl, src_hw_vdcz_vbl_asm);
2961
2962}
2963
2964Variable * vdcz_new_image( Environment * _environment, int _width, int _height, int _mode ) {
2965
2966 Variable * result = variable_temporary( _environment, VT_IMAGE, "(new image)" );
2967
2968 result->size = 1;
2969 result->valueBuffer = malloc(1);
2970
2971 return result;
2972
2973}
2974
2975Variable * vdcz_new_images( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
2976
2977 Variable * result = variable_temporary( _environment, VT_IMAGES, "(new images)" );
2978
2979 result->size = 1;
2980 result->valueBuffer = malloc(1);
2981
2982 return result;
2983
2984}
2985
2986Variable * vdcz_new_sequence( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
2987
2988 Variable * result = variable_temporary( _environment, VT_SEQUENCE, "(new sequence)" );
2989
2990 result->size = 1;
2991 result->valueBuffer = malloc(1);
2992
2993 return result;
2994
2995}
2996
2997void vdcz_get_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _palette ) {
2998
2999 deploy( vdczvars, src_hw_vdcz_vars_asm);
3000 deploy( vdczvarsGraphic, src_hw_vdcz_vars_graphic_asm );
3001 deploy( getimage, src_hw_vdcz_get_image_asm );
3002
3004
3005 vdcz_load_image_address_to_other_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
3006
3007 outline1("LD DE, (%s)", _x );
3008 outline1("LD iy, (%s)", _y );
3009 outline1("LD A, $%2.2x", _palette );
3010 outline0("LD IXH, A" );
3011
3012 outline0("CALL GETIMAGE");
3013
3014}
3015
3016void vdcz_scroll( Environment * _environment, int _dx, int _dy ) {
3017
3018 deploy( vdczvars, src_hw_vdcz_vars_asm);
3019 deploy( scroll, src_hw_vdcz_scroll_asm);
3020 deploy( textHScroll, src_hw_vdcz_hscroll_text_asm );
3021 deploy( vScrollTextDown, src_hw_vdcz_vscroll_text_down_asm );
3022 deploy( vScrollTextUp, src_hw_vdcz_vscroll_text_up_asm );
3023
3024}
3025
3026void vdcz_put_tile( Environment * _environment, char * _tile, char * _x, char * _y ) {
3027
3028 deploy( vdczvars, src_hw_vdcz_vars_asm);
3029 deploy( tiles, src_hw_vdcz_tiles_asm );
3030
3031}
3032
3033void vdcz_move_tiles( Environment * _environment, char * _tile, char * _x, char * _y ) {
3034
3035 Variable * tile = variable_retrieve( _environment, _tile );
3036 Variable * x = variable_retrieve( _environment, _x );
3037 Variable * y = variable_retrieve( _environment, _y );
3038
3039 deploy( vdczvars, src_hw_vdcz_vars_asm);
3040 deploy( tiles, src_hw_vdcz_tiles_asm );
3041
3042}
3043
3044void vdcz_put_tiles( Environment * _environment, char * _tile, char * _x, char * _y, char *_w, char *_h ) {
3045
3046 deploy( vdczvars, src_hw_vdcz_vars_asm);
3047 deploy( tiles, src_hw_vdcz_tiles_asm );
3048
3049}
3050
3051void vdcz_tile_at( Environment * _environment, char * _x, char * _y, char * _result ) {
3052
3053 deploy( vdczvars, src_hw_vdcz_vars_asm);
3054 deploy( tiles, src_hw_vdcz_tiles_asm );
3055
3056}
3057
3058void vdcz_use_tileset( Environment * _environment, char * _tileset ) {
3059
3060 deploy( vdczvars, src_hw_vdcz_vars_asm);
3061 deploy( tiles, src_hw_vdcz_tiles_asm );
3062
3063}
3064
3066
3067 Variable * result = variable_temporary( _environment, VT_WORD, "(raster line)" );
3068
3069 return result;
3070
3071}
3072
3073void vdcz_slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _destination ) {
3074
3075}
3076
3077int vdcz_palette_extract( Environment * _environment, char * _data, int _width, int _height, int _depth, int _flags, RGBi * _palette ) {
3078
3079 int paletteColorCount = rgbi_extract_palette(_environment, _data, _width, _height, _depth, _palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
3080
3081 memcpy( _palette, palette_match( _palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) ), paletteColorCount * sizeof( RGBi ) );
3082
3083 int uniquePaletteCount = 0;
3084
3085 memcpy( _palette, palette_remove_duplicates( _palette, paletteColorCount, &uniquePaletteCount ), paletteColorCount * sizeof( RGBi ) );
3086
3087 return uniquePaletteCount;
3088
3089}
3090
3091void vdcz_screen( Environment * _environment, char * _x, char * _y, char * _c ) {
3092
3093 deploy( screen, src_hw_vdcz_screen_asm);
3094
3095 outline1("LD A, (%s)", _x );
3096 outline0("LD C, A" );
3097 outline1("LD A, (%s)", _y );
3098 outline0("LD B, A" );
3099 outline0("CALL SCREEN" );
3100 outline1("LD (%s), A", _c );
3101
3102}
3103
3104#endif
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 16 bit
Definition 6309.c:1503
void cpu_move_16bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 16 bit
Definition 6309.c:1474
void cpu_store_8bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 8 bit
Definition 6309.c:761
int lastUsedSlotInCommonPalette
Definition 6847.c:100
#define COLOR_COUNT
Definition 6847.h:72
#define BITMAP_MODE_STANDARD
Definition 6847.h:96
#define COLOR_WHITE
Definition 6847.h:39
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
int rgbi_distance(RGBi *_e1, RGBi *_e2)
Calculate the distance between two colors.
void image_converter_asserts_free_height(Environment *_environment, int _width, int _height, int _offset_x, int _offset_y, int *_frame_width, int *_frame_height, int _modulo_x)
Variable * variable_import(Environment *_environment, char *_name, VariableType _type, int _size_or_value)
RGBi * malloc_palette(int _size)
Allocate a palette space.
void variable_global(Environment *_environment, char *_pattern)
ScreenMode * find_screen_mode_by_suggestion(Environment *_environment, int _bitmap, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
int rgbi_extract_palette(Environment *_environment, unsigned char *_source, int _width, int _height, int _depth, RGBi _palette[], int _palette_size, int _sorted)
Extract the color palette from the given image.
RGBi * palette_remove_duplicates(RGBi *_source, int _source_size, int *_unique_size)
Remove duplicates from a palette.
void font_descriptors_init(Environment *_environment, int _embedded_present)
RGBi * palette_match(RGBi *_source, int _source_size, RGBi *_system, int _system_size)
Make a "palette match".
void image_converter_asserts(Environment *_environment, int _width, int _height, int _offset_x, int _offset_y, int *_frame_width, int *_frame_height, int _modulo_x, int _modulo_y)
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
Variable * variable_store_buffer(Environment *_environment, char *_destination, unsigned char *_buffer, int _size, int _at)
int offset
Definition _optimizer.c:681
void back(Environment *_environment, char *_color)
Emit ASM code to fill background color.
Definition back.c:53
void color(Environment *_environment, int _index, int _shade)
Emit ASM code for instruction COLOR [int], [int].
Definition color.c:59
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
Definition plot.c:46
void scroll(Environment *_environment, int _dx, int _dy)
Definition scroll.c:41
#define TILEMAP_MODE_STANDARD
Definition cga.h:80
void console_init(Environment *_environment)
Definition console.c:41
Variable * distance(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Return the distance between two (screen) positions.
Definition distance.c:76
char * name
Definition ugbc.h:2252
struct _CopperList * next
Definition ugbc.h:2255
int screenTilesWidth
Definition ugbc.h:2880
int screenShades
Definition ugbc.h:2865
int fontHeight
Definition ugbc.h:2905
int freeImageWidth
Definition ugbc.h:3088
int currentMode
Definition ugbc.h:2696
int screenTilesHeight
Definition ugbc.h:2885
int consoleTilesHeight
Definition ugbc.h:2895
RgbConverterFunction currentRgbConverterFunction
Definition ugbc.h:2711
int fontWidth
Definition ugbc.h:2900
int bitmaskNeeded
Definition ugbc.h:2659
CopperList * copperList
Definition ugbc.h:3282
int screenColors
Definition ugbc.h:2870
int currentModeBW
Definition ugbc.h:2701
int screenHeight
Definition ugbc.h:2860
int consoleTilesWidth
Definition ugbc.h:2890
int currentTileMode
Definition ugbc.h:2706
int screenTiles
Definition ugbc.h:2875
int freeImageHeight
Definition ugbc.h:3086
int screenWidth
Definition ugbc.h:2855
int defaultPaperColor
Definition ugbc.h:3226
int defaultPenColor
Definition ugbc.h:3225
VestigialConfig vestigialConfig
Definition ugbc.h:2442
unsigned char red
Definition ugbc.h:433
unsigned char green
Definition ugbc.h:434
unsigned char blue
Definition ugbc.h:435
unsigned char alpha
Definition ugbc.h:436
unsigned char index
Definition ugbc.h:437
int isAddress
Definition ugbc.h:557
VariableType type
Definition ugbc.h:559
char * realName
Definition ugbc.h:555
int selected
Definition ugbc.h:1510
unsigned char * valueBuffer
Definition ugbc.h:1061
int size
Definition ugbc.h:1077
char * name
Definition ugbc.h:979
int originalColors
Definition ugbc.h:1154
RGBi originalPalette[MAX_PALETTE]
Definition ugbc.h:1169
char * realName
Definition ugbc.h:982
char clsImplicit
Definition ugbc.h:2008
#define BITMAP_MODE_MULTICOLOR
Definition ted.h:77
void * malloc(YYSIZE_T)
struct _ScreenMode ScreenMode
#define CRITICAL_IMAGE_CONVERTER_TOO_COLORS(f)
Definition ugbc.h:3502
struct _Resource Resource
struct _RGBi RGBi
Structure to store color components (red, green and blue).
#define adilineendbitmap()
Definition ugbc.h:4241
#define WARNING_SCREEN_MODE(v1)
Definition ugbc.h:3878
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_WORD
Definition ugbc.h:455
@ VT_POSITION
Definition ugbc.h:468
@ VT_BYTE
Definition ugbc.h:450
@ VT_BUFFER
Definition ugbc.h:477
@ VT_SPRITE
Definition ugbc.h:501
@ VT_SBYTE
Definition ugbc.h:452
@ VT_IMAGES
Definition ugbc.h:495
@ VT_ADDRESS
Definition ugbc.h:465
@ VT_COLOR
Definition ugbc.h:471
@ VT_IMAGE
Definition ugbc.h:489
@ VT_SEQUENCE
Definition ugbc.h:513
#define adiline3(s, a, b, c)
Definition ugbc.h:4197
#define deploy_preferred(s, e)
Definition ugbc.h:4299
#define SCREEN_MODE_DEFINE(_id, _bitmap, _width, _height, _colors, _tile_width, _tile_height, _description)
Definition ugbc.h:1516
#define MAX_PALETTE
Definition ugbc.h:568
#define outline0(s)
Definition ugbc.h:4252
#define outline1(s, a)
Definition ugbc.h:4253
#define adilinepalette(s, c, p)
Definition ugbc.h:4219
#define adilinebeginbitmap(s)
Definition ugbc.h:4231
struct _CopperList CopperList
#define FLAG_EXACT
Definition ugbc.h:4569
#define adilinepixel(p)
Definition ugbc.h:4236
#define CRITICAL_BLIT_TOO_MUCH_SOURCES()
Definition ugbc.h:3613
#define deploy(s, e)
Definition ugbc.h:4288
#define MAKE_LABEL
Definition ugbc.h:3351
#define outhead1(s, a)
Definition ugbc.h:4247
void vdcz_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition vdcz.c:3073
void vdcz_hit(Environment *_environment, char *_sprite_mask, char *_result)
VDCZ: emit code to check for collision
Definition vdcz.c:527
void vdcz_horizontal_scroll(Environment *_environment, char *_displacement)
Definition vdcz.c:2312
void vdcz_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
Definition vdcz.c:2221
void vdcz_colormap_at(Environment *_environment, char *_address)
Definition vdcz.c:2116
void vdcz_screen_rows(Environment *_environment, char *_rows)
Definition vdcz.c:2213
void vdcz_textmap_at(Environment *_environment, char *_address)
Definition vdcz.c:2120
void vdcz_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
Definition vdcz.c:3026
void vdcz_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VDCZ: emit code to wait for next raster irq at different position
Definition vdcz.c:703
void vdcz_finalization(Environment *_environment)
Definition vdcz.c:2578
void vdcz_blit_image(Environment *_environment, char *_sources[], int _source_count, char *_blit, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _flags)
Definition vdcz.c:2908
void vdcz_sprite_monocolor(Environment *_environment, char *_sprite)
Definition vdcz.c:2284
Variable * vdcz_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
Definition vdcz.c:2986
void vdcz_scroll(Environment *_environment, int _dx, int _dy)
Definition vdcz.c:3016
void vdcz_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
Definition vdcz.c:3033
void vdcz_pset_int(Environment *_environment, int _x, int _y, int *_c)
Definition vdcz.c:2124
void vdcz_screen_columns(Environment *_environment, char *_columns)
Definition vdcz.c:2217
Variable * vdcz_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
Definition vdcz.c:2975
void vdcz_tiles_get(Environment *_environment, char *_result)
Definition vdcz.c:2330
void vdcz_background_color_get_vars(Environment *_environment, char *_index, char *_background_color)
VDCZ: emit code to retrieve background color
Definition vdcz.c:634
int vdcz_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
Definition vdcz.c:743
void vdcz_get_height(Environment *_environment, char *_result)
Definition vdcz.c:2334
void vdcz_sprite_expand_vertical(Environment *_environment, char *_sprite)
Definition vdcz.c:2254
void vdcz_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
Definition vdcz.c:2997
void vdcz_bitmap_disable(Environment *_environment)
Definition vdcz.c:2086
Variable * vdcz_collision(Environment *_environment, char *_sprite)
VDCZ: emit code to check for collision
Definition vdcz.c:508
Variable * vdcz_image_converter(Environment *_environment, char *_data, int _width, int _height, int _depth, int _offset_x, int _offset_y, int _frame_width, int _frame_height, int _mode, int _transparent_color, int _flags)
Definition vdcz.c:2628
void vdcz_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
Definition vdcz.c:2739
void vdcz_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
Definition vdcz.c:2297
int vdcz_image_size(Environment *_environment, int _width, int _height, int _mode)
Definition vdcz.c:82
void vdcz_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Definition vdcz.c:2090
void vdcz_cls(Environment *_environment)
Definition vdcz.c:2338
void vdcz_border_color(Environment *_environment, char *_border_color)
VDCZ: emit code to change border color
Definition vdcz.c:543
void vdcz_background_color_semivars(Environment *_environment, int _index, char *_background_color)
VDCZ: emit code to change background color
Definition vdcz.c:606
void vdcz_cline(Environment *_environment, char *_characters)
Definition vdcz.c:2613
void vdcz_scroll_text(Environment *_environment, int _direction, int _overlap)
Definition vdcz.c:2369
void vdcz_vertical_scroll(Environment *_environment, char *_displacement)
Definition vdcz.c:2308
RGBi * vdcz_image_nearest_system_color(RGBi *_color)
Definition vdcz.c:66
void vdcz_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
Definition vdcz.c:3051
void vdcz_screen_off(Environment *_environment)
Definition vdcz.c:2209
void vdcz_sprite_compress_vertical(Environment *_environment, char *_sprite)
Definition vdcz.c:2266
void vdcz_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
Definition vdcz.c:2246
void vdcz_screen(Environment *_environment, char *_x, char *_y, char *_c)
Definition vdcz.c:3091
Variable * vdcz_sprite_converter(Environment *_environment, char *_source, int _width, int _height, int _depth, RGBi *_color, int _flags)
Definition vdcz.c:2648
void vdcz_bank_select(Environment *_environment, int _bank)
Definition vdcz.c:707
void vdcz_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
Definition vdcz.c:2150
void vdcz_background_color_vars(Environment *_environment, char *_index, char *_background_color)
VDCZ: emit code to change background color
Definition vdcz.c:582
void vdcz_sprite_color(Environment *_environment, char *_sprite, char *_color)
Definition vdcz.c:2290
void vdcz_sprite_disable(Environment *_environment, char *_sprite)
Definition vdcz.c:2240
void vdcz_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VDCZ: emit code to set raster irq
Definition vdcz.c:672
void vdcz_sprite_compress_horizontal(Environment *_environment, char *_sprite)
Definition vdcz.c:2272
void console_calculate_vars(Environment *_environment)
Definition vdcz.c:738
void vdcz_back(Environment *_environment)
Definition vdcz.c:2607
void vdcz_initialization(Environment *_environment)
Definition vdcz.c:2421
void vdcz_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
VDCZ: emit code to change common sprite's color
Definition vdcz.c:653
void vdcz_hscroll_screen(Environment *_environment, int _direction, int _overlap)
Definition vdcz.c:2601
void vdcz_get_width(Environment *_environment, char *_result)
Definition vdcz.c:2326
void vdcz_sprite_expand_horizontal(Environment *_environment, char *_sprite)
Definition vdcz.c:2260
Variable * vdcz_get_raster_line(Environment *_environment)
Definition vdcz.c:3065
void vdcz_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
Definition vdcz.c:3044
void vdcz_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
Definition vdcz.c:2880
void vdcz_busy_wait(Environment *_environment, char *_timing)
Definition vdcz.c:2322
void vdcz_cls_box(Environment *_environment, char *_x1, char *_y1, char *_w, char *_h)
Definition vdcz.c:2350
void vdcz_hscroll_line(Environment *_environment, int _direction, int _overlap)
Definition vdcz.c:2595
void vdcz_screen_on(Environment *_environment)
Definition vdcz.c:2205
Variable * vdcz_new_image(Environment *_environment, int _width, int _height, int _mode)
Definition vdcz.c:2964
void vdcz_sprite_multicolor(Environment *_environment, char *_sprite)
Definition vdcz.c:2278
void vdcz_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
Definition vdcz.c:2225
void vdcz_use_tileset(Environment *_environment, char *_tileset)
Definition vdcz.c:3058
void vdcz_bitmap_at(Environment *_environment, char *_address)
Definition vdcz.c:2112
void vdcz_text(Environment *_environment, char *_text, char *_text_size, int _raw)
Definition vdcz.c:2381
int vdcz_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
Definition vdcz.c:3077
void vdcz_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
Definition vdcz.c:2181
void vdcz_next_raster(Environment *_environment)
VDCZ: emit code to wait for next raster irq
Definition vdcz.c:686
void vdcz_sprite_enable(Environment *_environment, char *_sprite)
Definition vdcz.c:2234
void vdcz_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Definition vdcz.c:2065
void vdcz_tiles_at(Environment *_environment, char *_address)
Definition vdcz.c:2304
void console_calculate(Environment *_environment)
Definition vdcz.c:734
void vdcz_background_color(Environment *_environment, int _index, int _background_color)
VDCZ: emit code to change background color
Definition vdcz.c:557
void vdcz_wait_vbl(Environment *_environment, char *_raster_line)
Definition vdcz.c:2957
#define BITMAP_MODE_STANDARD_INT
Definition vdcz.h:82
#define BITMAP_MODE_MULTICOLOR_INT
Definition vdcz.h:83