ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
pc1403.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../ugbc.h"
36#include <math.h>
37
38static RGBi SYSTEM_PALETTE[] = {
39 { 0x00, 0x00, 0x00, 0xff, 0, "BLACK" },
40 { 0x00, 0x00, 0xff, 0xff, 1, "BLUE" },
41 { 0x88, 0x00, 0x00, 0xff, 2, "RED" },
42 { 0xff, 0x00, 0xff, 0xff, 3, "MAGENTA" },
43 { 0x00, 0xcc, 0x00, 0xff, 4, "GREEN" },
44 { 0xaa, 0xff, 0xe6, 0xff, 5, "CYAN" },
45 { 0xee, 0xee, 0x77, 0xff, 6, "YELLOW" },
46 { 0xff, 0xff, 0xff, 0xff, 7, "WHITE" }
47};
48
49/****************************************************************************
50 * CODE SECTION
51 ****************************************************************************/
52
53#ifdef __pc1403__
54
55int pc1403_image_size( Environment * _environment, int _width, int _height, int _mode ) {
56
57 CRITICAL_UNIMPLEMENTED("pc1403_image_size");
58
59}
60
61static int calculate_images_size( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
62
63 CRITICAL_UNIMPLEMENTED("calculate_images_size");
64
65}
66
67static int calculate_sequence_size( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
68
69 CRITICAL_UNIMPLEMENTED("calculate_sequence_size");
70
71}
72
73void pc1403_color_border( Environment * _environment, char * _color ) {
74
75 CRITICAL_UNIMPLEMENTED("pc1403_color_border");
76
77}
78
79void pc1403_pset_int( Environment * _environment, int _x, int _y, int *_c ) {
80
81 deploy( plot, src_hw_pc1403_plot_asm );
82
83 outline1("LIA 0x%2.2x", (_x & 0xff ) );
84 outline0("LP 8" );
85 outline0("EXAM" );
86
87 outline1("LIA 0x%2.2x", (_y & 0xff ) );
88 outline0("LP 9" );
89 outline0("EXAM" );
90
91 outline0("LIA #1");
92 outline0("CALL PLOT");
93
94}
95
96void pc1403_pset_vars( Environment * _environment, char *_x, char *_y, char *_c ) {
97
98 deploy( plot, src_hw_pc1403_plot_asm );
99
100 Variable * x = variable_retrieve_or_define( _environment, _x, VT_BYTE, 0 );
101 Variable * y = variable_retrieve_or_define( _environment, _y, VT_BYTE, 0 );
102 // Variable * c;
103
104 // if ( _c ) {
105 // c = variable_retrieve_or_define( _environment, _c, VT_COLOR, 0 );
106 // } else {
107 // c = variable_retrieve( _environment, "PEN" );
108 // }
109
110 outline0("LII 0x00" );
111 outline1("LIDP %s", x->realName );
112 outline0("LP 8" );
113 outline0("MVWD");
114
115 outline1("LIDP %s", y->realName );
116 outline0("LP 9" );
117 outline0("MVWD");
118
119 outline0("LIA #1");
120 outline0("CALL PLOT");
121
122}
123
124void pc1403_pget_color_vars( Environment * _environment, char *_x, char *_y, char * _result ) {
125
126 deploy( plot, src_hw_pc1403_plot_asm );
127
128 Variable * x = variable_retrieve( _environment, _x );
129 Variable * y = variable_retrieve( _environment, _y );
130 Variable * result = variable_retrieve( _environment, _result );
131
132 outline0("LII 0x00" );
133 outline1("LIDP %s", x->realName );
134 outline0("LP 8" );
135 outline0("MVWD");
136
137 outline1("LIDP %s", y->realName );
138 outline0("LP 9" );
139 outline0("MVWD");
140
141 outline0("LIA #3");
142 outline0("CALL PLOT");
143 outline1("LIDP %s", result->realName );
144 outline0("STD");
145
146}
147
148void pc1403_vscroll( Environment * _environment, int _displacement ) {
149
150 CRITICAL_UNIMPLEMENTED("pc1403_vscroll");
151
152}
153
154void pc1403_text( Environment * _environment, char * _text, char * _text_size, int _raw ) {
155
156 deploy( textEncodedAtText, src_hw_pc1403_text_asm );
157
158 outline0( "LIP 0x0c" );
159 outline1( "LIDP %s", _text );
160 outline0( "LDD");
161 outline0( "EXAM");
162
163 outline0( "LIP 0x0d" );
164 outline1( "LIDP %s", address_displacement( _environment, _text, "1" ) );
165 outline0( "LDD");
166 outline0( "EXAM");
167
168 outline0( "LIP 0x01" );
169 outline1( "LIDP %s", _text_size );
170 outline0( "LDD");
171 outline0( "EXAM");
172
173 outline0("CALL TEXTBM");
174
175}
176
177void pc1403_cls( Environment * _environment ) {
178
179 deploy( cls, src_hw_pc1403_cls_asm );
180
181 cpu_call( _environment, "CLS" );
182
183}
184
185void pc1403_cls_box( Environment * _environment, char * _x1, char * _y1, char * _x2, char * _y2 ) {
186
187}
188
189void pc1403_inkey( Environment * _environment, char * _key ) {
190
191 CRITICAL_UNIMPLEMENTED("pc1403_inkey");
192
193}
194
195void pc1403_wait_key( Environment * _environment, int _release ) {
196
197 CRITICAL_UNIMPLEMENTED("pc1403_wait_key");
198
199}
200
201void pc1403_wait_key_or_fire( Environment * _environment, int _port, int _release ) {
202
203 CRITICAL_UNIMPLEMENTED("pc1403_wait_key_or_fire");
204
205}
206
207void pc1403_wait_key_or_fire_semivar( Environment * _environment, char * _port, int _release ) {
208
209 CRITICAL_UNIMPLEMENTED("pc1403_wait_key_or_fire_semivar");
210
211}
212
213void pc1403_wait_fire( Environment * _environment, int _port, int _release ) {
214
215 CRITICAL_UNIMPLEMENTED("pc1403_wait_fire");
216
217}
218
219void pc1403_wait_fire_semivar( Environment * _environment, char * _port, int _release ) {
220
221 CRITICAL_UNIMPLEMENTED("pc1403_wait_fire_semivar");
222
223}
224
225void pc1403_key_state( Environment * _environment, char *_scancode, char * _result ) {
226
227 CRITICAL_UNIMPLEMENTED("pc1403_key_state");
228
229}
230
231void pc1403_scancode( Environment * _environment, char * _result ) {
232
233 CRITICAL_UNIMPLEMENTED("pc1403_scancode");
234
235}
236
237void pc1403_asciicode( Environment * _environment, char * _result ) {
238
239 CRITICAL_UNIMPLEMENTED("pc1403_asciicode");
240
241
242}
243
244void pc1403_key_pressed( Environment * _environment, char *_scancode, char * _result ) {
245
246 CRITICAL_UNIMPLEMENTED("pc1403_key_pressed");
247
248}
249
250void pc1403_scanshift( Environment * _environment, char * _shifts ) {
251
252 CRITICAL_UNIMPLEMENTED("pc1403_scanshift");
253
254}
255
256void pc1403_keyshift( Environment * _environment, char * _shifts ) {
257
258 CRITICAL_UNIMPLEMENTED("pc1403_keyshift");
259
260}
261
262void pc1403_clear_key( Environment * _environment ) {
263
264 CRITICAL_UNIMPLEMENTED("pc1403_clear_key");
265
266}
267
268static int rgbConverterFunction( int _red, int _green, int _blue ) {
269
270 return 0;
271
272}
273
274void pc1403_initialization( Environment * _environment ) {
275
276 // variable_import( _environment, "CURRENTWIDTH", VT_POSITION, 256);
277 // variable_global( _environment, "CURRENTWIDTH" );
278 // variable_import( _environment, "CURRENTHEIGHT", VT_POSITION, 192 );
279 // variable_global( _environment, "CURRENTHEIGHT" );
280 // variable_import( _environment, "CURRENTTILES", VT_BYTE, 255 );
281 // variable_global( _environment, "CURRENTTILES" );
282 // variable_import( _environment, "CURRENTTILESWIDTH", VT_SBYTE, 32 );
283 // variable_global( _environment, "CURRENTTILESWIDTH" );
284 // variable_import( _environment, "CURRENTTILESHEIGHT", VT_SBYTE, 24 );
285 // variable_global( _environment, "CURRENTTILESHEIGHT" );
286 // variable_import( _environment, "FONTWIDTH", VT_BYTE, 8 );
287 // variable_global( _environment, "FONTWIDTH" );
288 // variable_import( _environment, "FONTHEIGHT", VT_BYTE, 8 );
289 // variable_global( _environment, "FONTHEIGHT" );
290
291 SCREEN_MODE_DEFINE( BITMAP_MODE_STANDARD, 1, 120, 8, 2, 8, 8, "Standard Bitmap Mode (LCD)" );
292 SCREEN_MODE_DEFINE( TILEMAP_MODE_STANDARD, 0, 24, 1, 5, 8, 8, "(emulated) Standard Character Mode" );
293
294 variable_import( _environment, "XGR", VT_BYTE, 0 );
295 variable_global( _environment, "XGR" );
296 variable_import( _environment, "YGR", VT_BYTE, 0 );
297 variable_global( _environment, "YGR" );
298 variable_import( _environment, "LINE", VT_WORD, (unsigned short)(0xffff) );
299 variable_global( _environment, "LINE" );
300 // variable_import( _environment, "TABCOUNT", VT_BYTE, 4 );
301 // variable_global( _environment, "TABCOUNT" );
302
303 variable_import( _environment, "CLIPX1", VT_BYTE, 0 );
304 variable_global( _environment, "CLIPX1" );
305 variable_import( _environment, "CLIPX2", VT_BYTE, 120 );
306 variable_global( _environment, "CLIPX2" );
307 variable_import( _environment, "CLIPY1", VT_BYTE, 0 );
308 variable_global( _environment, "CLIPY1" );
309 variable_import( _environment, "CLIPY2", VT_BYTE, 7 );
310 variable_global( _environment, "CLIPY2" );
311
312 // variable_import( _environment, "ORIGINX", VT_POSITION, 0 );
313 // variable_global( _environment, "ORIGINX" );
314 // variable_import( _environment, "ORIGINY", VT_POSITION, 0 );
315 // variable_global( _environment, "ORIGINY" );
316
317 // variable_import( _environment, "RESOLUTIONX", VT_POSITION, 0 );
318 // variable_global( _environment, "RESOLUTIONX" );
319 // variable_import( _environment, "RESOLUTIONY", VT_POSITION, 0 );
320 // variable_global( _environment, "RESOLUTIONY" );
321
322 // variable_import( _environment, "TABCOUNT", VT_BYTE, 4 );
323 // variable_global( _environment, "TABCOUNT" );
324
325 // variable_import( _environment, "TILEX", VT_BYTE, 0 );
326 // variable_global( _environment, "TILEX" );
327 // variable_import( _environment, "TILEY", VT_BYTE, 0 );
328 // variable_global( _environment, "TILEY" );
329 // variable_import( _environment, "TILEX2", VT_BYTE, 0 );
330 // variable_global( _environment, "TILEX2" );
331 // variable_import( _environment, "TILET", VT_BYTE, 0 );
332 // variable_global( _environment, "TILET" );
333 // variable_import( _environment, "TILEW", VT_BYTE, 0 );
334 // variable_global( _environment, "TILEW" );
335 // variable_import( _environment, "TILEH", VT_BYTE, 0 );
336 // variable_global( _environment, "TILEH" );
337 // variable_import( _environment, "TILEW2", VT_BYTE, 0 );
338 // variable_global( _environment, "TILEW2" );
339 // variable_import( _environment, "TILEH2", VT_BYTE, 0 );
340 // variable_global( _environment, "TILEH2" );
341 // variable_import( _environment, "TILEA", VT_BYTE, 0 );
342 // variable_global( _environment, "TILEA" );
343 // variable_import( _environment, "TILEO", VT_WORD, 0 );
344 // variable_global( _environment, "TILEO" );
345
346 // variable_import( _environment, "CURRENTMODE", VT_BYTE, 0 );
347 // variable_global( _environment, "CURRENTMODE" );
348 // variable_import( _environment, "CURRENTTILEMODE", VT_BYTE, 1 );
349 // variable_global( _environment, "CURRENTTILEMODE" );
350
351 // cpu_move_16bit( _environment, "CURRENTWIDTH", "RESOLUTIONX" );
352 // cpu_move_16bit( _environment, "CURRENTHEIGHT", "RESOLUTIONY" );
353
354 // variable_import( _environment, "BLITIMAGEBLITTINGADDR", VT_ADDRESS, 0 );
355 // variable_global( _environment, "BLITIMAGEBLITTINGADDR" );
356 // variable_import( _environment, "BLITTMPPTR", VT_ADDRESS, 0 );
357 // variable_global( _environment, "BLITTMPPTR" );
358 // variable_import( _environment, "BLITTMPPTR2", VT_ADDRESS, 0 );
359 // variable_global( _environment, "BLITTMPPTR2" );
360
361 // variable_import( _environment, "TEXTADDRESS", VT_ADDRESS, 0 );
362 // variable_global( _environment, "TEXTADDRESS" );
363
364 // _environment->currentRgbConverterFunction = rgbConverterFunction;
365
366 _environment->screenWidth = 120;
367 _environment->screenHeight = 8;
368 _environment->fontWidth = 5;
369 _environment->fontHeight = 8;
370 _environment->screenColors = COLOR_COUNT;
371 _environment->screenTilesWidth = _environment->screenWidth / _environment->fontWidth;
372 _environment->screenTilesHeight = _environment->screenHeight / _environment->fontHeight;
373 _environment->consoleTilesWidth = _environment->screenTilesWidth;
374 _environment->consoleTilesHeight = _environment->screenTilesHeight;
375
376 // cpu_store_16bit( _environment, "CURRENTWIDTH", _environment->screenWidth );
377 // cpu_store_16bit( _environment, "CURRENTHEIGHT", _environment->screenHeight );
378 // cpu_move_16bit( _environment, "CURRENTWIDTH", "RESOLUTIONX" );
379 // cpu_move_16bit( _environment, "CURRENTHEIGHT", "RESOLUTIONY" );
380 // cpu_store_8bit( _environment, "CURRENTTILES", _environment->screenTiles );
381 // cpu_store_8bit( _environment, "CURRENTTILESWIDTH", _environment->screenTilesWidth );
382 // cpu_store_8bit( _environment, "CURRENTTILESHEIGHT", _environment->screenTilesHeight );
383 // cpu_store_8bit( _environment, "FONTWIDTH", _environment->fontWidth );
384 // cpu_store_8bit( _environment, "FONTHEIGHT", _environment->fontHeight );
385
386 // console_init( _environment );
387
388 // if (_environment->vestigialConfig.clsImplicit ) {
389 // pc1403_cls( _environment, NULL, NULL );
390 // }
391
392}
393
394void pc1403_finalization( Environment * _environment ) {
395
396 // if (_environment->vestigialConfig.clsImplicit ) {
397 // pc1403_cls( _environment, NULL, NULL );
398 // }
399
400}
401
402void pc1403_screen_rows( Environment * _environment, char * _rows ) {
403
404}
405
406void pc1403_screen_columns( Environment * _environment, char * _columns ) {
407
408}
409
410void console_calculate( Environment * _environment ) {
411
412}
413
414void console_calculate_vars( Environment * _environment ) {
415
416}
417
418int pc1403_screen_mode_enable( Environment * _environment, ScreenMode * _screen_mode ) {
419 // _environment->screenWidth = 256;
420 // _environment->screenHeight = 192;
421 // _environment->fontWidth = 8;
422 // _environment->fontHeight = 8;
423 // _environment->screenColors = 8;
424 // console_init( _environment );
425 // if (_environment->vestigialConfig.clsImplicit ) {
426 // pc1403_cls( _environment, NULL, NULL );
427 // }
428
429}
430
431void pc1403_bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
432
433 // deploy( vars, src_hw_pc1403_vars_asm );
434
435}
436
437void pc1403_tilemap_enable( Environment * _environment, int _width, int _height, int _colors, int _tile_width, int _tile_height ) {
438
439}
440
441void pc1403_back( Environment * _environment ) {
442
443 // deploy( back, src_hw_pc1403_back_asm );
444
445 // outline0("CALL BACK");
446
447}
448
449static Variable * pc1403_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 ) {
450
451 // (void)!_transparent_color;
452
453 // image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height );
454
455 // if ( _environment->freeImageWidth ) {
456 // if ( _width % 8 ) {
457 // _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
458 // }
459 // if ( _frame_width % 8 ) {
460 // _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
461 // }
462 // }
463
464 // if ( _environment->freeImageHeight ) {
465 // if ( _height % 8 ) {
466 // _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
467 // }
468 // if ( _frame_height % 8 ) {
469 // _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
470 // }
471 // }
472
473 // RGBi * palette = malloc_palette( MAX_PALETTE );
474
475 // int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
476
477 // if (paletteColorCount > 16) {
478 // CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
479 // }
480
481 // int i, j, k;
482
483 // commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) );
484 // commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
485
486 // if ( _transparent_color & 0x0f0000 ) {
487 // commonPalette = palette_promote_color_as_background( _transparent_color & 0xff, commonPalette, paletteColorCount );
488 // }
489 // if ( _transparent_color & 0xf00000 ) {
490 // commonPalette = palette_promote_color_as_foreground( ( _transparent_color >> 8 ) & 0xff, commonPalette, paletteColorCount, 8 );
491 // paletteColorCount = 8;
492 // }
493
494 // lastUsedSlotInCommonPalette = paletteColorCount;
495 // adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
496
497 // adilinepalette( "CPMS:%ld", sizeof(SYSTEM_PALETTE) / sizeof(RGBi), SYSTEM_PALETTE );
498
499 // Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
500 // result->originalColors = lastUsedSlotInCommonPalette;
501 // memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
502
503 // int bufferSize = pc1403_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_STANDARD );
504 // // printf("bufferSize = %d\n", bufferSize );
505
506 // adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_DEFAULT );
507
508 // adilinebeginbitmap("BMD");
509
510 // char * buffer = malloc ( bufferSize );
511 // memset( buffer, 0, bufferSize );
512
513 // // Position of the pixel in the original image
514 // int image_x, image_y;
515
516 // // Position of the pixel, in terms of tiles
517 // int tile_x, tile_y;
518
519 // // Position of the pixel, in terms of offset and bitmask
520 // int offset, bitmask;
521
522 // // Color of the pixel to convert
523 // RGBi rgb;
524
525 // *(buffer) = ( _frame_width & 0xff );
526 // *(buffer+1) = ( _frame_width >> 8 ) & 0xff;
527 // *(buffer+2) = _frame_height;
528
529 // char * source = _source;
530
531 // _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
532
533 // int colorIndexCount[ MAX_PALETTE ];
534
535 // char * colorBackgroundCells = malloc( ( _frame_height >> 3 ) * ( _frame_width >> 3 ) );
536
537 // memset( colorBackgroundCells, 0, ( _frame_height >> 3 ) * ( _frame_width >> 3 ) );
538
539 // char * colorForegroundCells = malloc( ( _frame_height >> 3 ) * ( _frame_width >> 3 ) );
540
541 // memset( colorForegroundCells, 0, ( _frame_height >> 3 ) * ( _frame_width >> 3 ) );
542
543 // int colorIndex;
544
545 // int xx;
546
547 // int step = 0;
548
549 // if ( paletteColorCount > 2 ) {
550
551 // // Loop for all the source surface, in order to calculate colors.
552 // // We do it in one pass only.
553 // for (image_y = 0; image_y < _frame_height; image_y+=8) {
554
555 // for (image_x = 0; image_x < _frame_width; image_x+=8) {
556
557 // memset( colorIndexCount, 0, MAX_PALETTE * sizeof( int ) );
558
559 // for( int y = 0; y<8; ++y ) {
560
561 // _source = source + ( ( _offset_y * _width ) + _offset_x ) * _depth +
562 // ( ( image_y * _frame_width + image_x ) * _depth ) +
563 // ( ( y * _frame_width ) * _depth );
564
565 // for( int x = 0; x<8; ++x ) {
566
567 // // Take the color of the pixel
568 // rgb.red = *_source;
569 // rgb.green = *(_source + 1);
570 // rgb.blue = *(_source + 2);
571 // if ( _depth > 3 ) {
572 // rgb.alpha = *(_source + 3);
573 // } else {
574 // rgb.alpha = 255;
575 // }
576 // if ( rgb.alpha == 0 ) {
577 // rgb.red = 0;
578 // rgb.green = 0;
579 // rgb.blue = 0;
580 // }
581
582 // colorIndex = 0;
583
584 // int minDistance = 9999;
585 // for( int index = 0; index <16; ++index ) {
586 // int distance = rgbi_distance(&SYSTEM_PALETTE[index], &rgb );
587 // if ( distance < minDistance ) {
588 // minDistance = distance;
589 // colorIndex = SYSTEM_PALETTE[index].index;
590 // }
591 // }
592
593 // // printf( "%2.2x%2.2x%2.2x = %d ", rgb.red, rgb.green, rgb.blue, colorIndex );
594
595 // ++colorIndexCount[colorIndex];
596
597 // _source += _depth;
598
599 // }
600
601 // // printf( "\n" );
602
603 // }
604
605 // // printf( "\n---\n" );
606
607 // int colorBackgroundMax = 0;
608 // int colorBackground = 0;
609 // int colorForegroundMax = 0;
610 // int colorForeground = 0;
611
612 // if ( _transparent_color & 0x0f0000 ) {
613 // colorBackground = ( _transparent_color & 0xff );
614 // } else {
615 // for( int xx = 0; xx<16; ++xx ) {
616 // if ( colorIndexCount[xx] > colorBackgroundMax ) {
617 // colorBackground = xx;
618 // colorBackgroundMax = colorIndexCount[xx];
619 // };
620 // }
621 // colorIndexCount[colorBackground] = 0;
622 // }
623
624 // if ( _transparent_color & 0xf00000 ) {
625 // colorForeground = ( _transparent_color & 0xff00 ) >> 8;
626 // } else {
627 // for( int xx = 0; xx<16; ++xx ) {
628 // if ( colorIndexCount[xx] > colorForegroundMax ) {
629 // colorForeground = xx;
630 // colorForegroundMax = colorIndexCount[xx];
631 // };
632 // }
633 // if ( colorForeground == colorBackground ) {
634 // colorForeground = ( colorBackground == 0 ) ? 1 : 0;
635 // }
636 // colorIndexCount[colorForeground] = 0;
637 // }
638
639 // // printf( "cell (%d,%d) = %2.2x, %2.2x\n", image_x>>3, image_y>>3, colorForeground, colorBackground );
640
641 // *(colorForegroundCells + (image_y>>3)*(_frame_width>>3) + (image_x>>3)) = colorForeground;
642 // *(colorBackgroundCells + (image_y>>3)*(_frame_width>>3) + (image_x>>3)) = colorBackground;
643
644 // }
645
646 // // printf("\n");
647
648 // }
649
650 // }
651
652 // // printf("\n\n");
653
654 // _source = source + ( ( _offset_y * _width ) + _offset_x ) * _depth;
655
656 // // Loop for all the source surface.
657 // for (image_y = 0; image_y < _frame_height; ++image_y) {
658
659 // for (image_x = 0; image_x < _frame_width; image_x+=8) {
660
661 // for( xx = 0; xx < 8; ++xx ) {
662 // // Take the color of the pixel
663 // rgb.red = *_source;
664 // rgb.green = *(_source + 1);
665 // rgb.blue = *(_source + 2);
666 // if ( _depth > 3 ) {
667 // rgb.alpha = *(_source + 3);
668 // } else {
669 // rgb.alpha = 255;
670 // }
671 // if ( rgb.alpha == 0 ) {
672 // rgb.red = 0;
673 // rgb.green = 0;
674 // rgb.blue = 0;
675 // }
676
677 // colorIndex = 0;
678
679 // int minDistance = 9999;
680 // for( int i=0; i<paletteColorCount; ++i ) {
681 // int distance = rgbi_distance(&commonPalette[i], &rgb );
682 // if ( distance < minDistance ) {
683 // minDistance = distance;
684 // colorIndex = commonPalette[i].index;
685 // }
686 // }
687
688 // int offset = ( image_y * _frame_width>>3 ) + (image_x>>3);
689 // int bitmask = 1 << ( 7 - xx );
690 // int colorForeground = 0;
691 // int colorBackground = 0;
692
693 // if ( paletteColorCount > 2 ) {
694
695 // colorForeground = *(colorForegroundCells + (image_y>>3)*(_frame_width>>3) + (image_x>>3));
696 // colorBackground = *(colorBackgroundCells + (image_y>>3)*(_frame_width>>3) + (image_x>>3));
697
698 // } else {
699
700 // colorBackground = commonPalette[0].index;
701 // colorForeground = commonPalette[1].index;
702
703 // }
704
705 // // printf( "> cell (%d,%d) = %2.2x, %2.2x\n", image_x>>3, image_y>>3, colorForeground, colorBackground );
706
707 // if ( colorIndex != colorBackground ) {
708 // adilinepixel(colorForeground);
709 // *( buffer + offset + 3) |= bitmask;
710 // } else {
711 // adilinepixel(colorBackground);
712 // *( buffer + offset + 3) &= ~bitmask;
713 // }
714
715 // offset = ( ( image_y >> 3 ) * _frame_width>>3 ) + (image_x>>3);
716 // // printf( "%d+(%d,%d)=%d\n", 3 + ( ( _frame_width >> 3 ) * _frame_height ), image_x, image_y, offset );
717
718 // *( buffer + 3 + ( ( _frame_width >> 3 ) * _frame_height ) + offset ) = ( colorBackground << 3 ) | ( colorForeground );
719
720 // // if ( ! *( buffer + 2 + ( ( _frame_width >> 3 ) * _frame_height ) + offset ) ) {
721 // // ++step;
722 // // }
723 // // *( buffer + 2 + ( ( _frame_width >> 3 ) * _frame_height ) + offset ) = (step&0xff);
724
725 // _source += _depth;
726
727 // }
728
729 // }
730
731 // _source += _depth * ( _width - _frame_width );
732
733 // }
734
735 // adilineendbitmap();
736
737 // // printf("----\n");
738
739 // // printf( "buffer size = %d\n", bufferSize );
740
741 // variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
742
743 // // printf("----\n");
744
745 // return result;
746
747}
748
749Variable * pc1403_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 ) {
750
751 // switch( _mode ) {
752
753 // case BITMAP_MODE_STANDARD:
754 // case TILEMAP_MODE_STANDARD:
755
756 // return pc1403_image_converter_bitmap_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
757
758 // break;
759 // }
760
761 // WARNING_IMAGE_CONVERTER_UNSUPPORTED_MODE( _mode );
762
763 // return pc1403_new_image( _environment, 8, 8, BITMAP_MODE_STANDARD );
764
765}
766
767static void pc1403_load_image_address_to_other_register( Environment * _environment, char * _register, char * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
768
769 // outline2("LD %s, %s", _register, _source );
770 // if ( _sequence ) {
771
772 // outline0("LD DE, $0003" );
773 // outline0("ADD HL, DE" );
774 // if ( strlen(_sequence) == 0 ) {
775
776 // } else {
777 // outline0("PUSH HL" );
778 // outline1("LD A, (%s)", _sequence );
779 // outline0("LD L, A" );
780 // outline0("LD H, 0" );
781 // outline0("ADD HL, HL" );
782 // outline0("LD DE, HL" );
783 // outline1("LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
784 // outline0("ADD HL, DE" );
785 // outline0("LD A, (HL)" );
786 // outline0("LD E, A" );
787 // outline0("INC HL" );
788 // outline0("LD A, (HL)" );
789 // outline0("LD D, A" );
790 // outline0("POP HL" );
791 // outline0("ADD HL, DE" );
792 // }
793
794 // if ( _frame ) {
795 // if ( strlen(_frame) == 0 ) {
796
797 // } else {
798 // outline0("PUSH HL" );
799 // outline1("LD A, (%s)", _frame );
800 // outline0("LD L, A" );
801 // outline0("LD H, 0" );
802 // outline0("ADD HL, HL" );
803 // outline0("LD DE, HL" );
804 // outline1("LD HL, OFFSETS%4.4x", _frame_size );
805 // outline0("ADD HL, DE" );
806 // outline0("LD A, (HL)" );
807 // outline0("LD E, A" );
808 // outline0("INC HL" );
809 // outline0("LD A, (HL)" );
810 // outline0("LD D, A" );
811 // outline0("POP HL" );
812 // outline0("ADD HL, DE" );
813 // }
814 // }
815
816 // } else {
817
818 // if ( _frame ) {
819 // outline0("LD DE, $0003" );
820 // outline0("ADD HL, DE" );
821 // if ( strlen(_frame) == 0 ) {
822
823 // } else {
824 // outline0("PUSH HL" );
825 // outline1("LD A, (%s)", _frame );
826 // outline0("LD L, A" );
827 // outline0("LD H, 0" );
828 // outline0("ADD HL, HL" );
829 // outline0("LD DE, HL" );
830 // outline1("LD HL, OFFSETS%4.4x", _frame_size );
831 // outline0("ADD HL, DE" );
832 // outline0("LD A, (HL)" );
833 // outline0("LD E, A" );
834 // outline0("INC HL" );
835 // outline0("LD A, (HL)" );
836 // outline0("LD D, A" );
837 // outline0("POP HL" );
838 // outline0("ADD HL, DE" );
839 // }
840 // }
841
842 // }
843
844}
845
846void pc1403_calculate_sequence_frame_offset( Environment * _environment, char * _offset, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
847
848 // outline0("LD HL, 0" );
849 // outline1("LD (%s), HL", _offset );
850
851 // if ( _sequence ) {
852
853 // outline0("LD DE, $0003" );
854 // outline0("ADD HL, DE" );
855 // if ( strlen(_sequence) == 0 ) {
856
857 // } else {
858 // outline0("PUSH HL" );
859 // outline1("LD A, (%s)", _sequence );
860 // outline0("LD L, A" );
861 // outline0("LD H, 0" );
862 // outline0("ADD HL, HL" );
863 // outline0("LD DE, HL" );
864 // outline1("LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
865 // outline0("ADD HL, DE" );
866 // outline0("LD A, (HL)" );
867 // outline0("LD E, A" );
868 // outline0("INC HL" );
869 // outline0("LD A, (HL)" );
870 // outline0("LD D, A" );
871 // outline0("POP HL" );
872 // outline0("ADD HL, DE" );
873 // }
874
875 // if ( _frame ) {
876 // if ( strlen(_frame) == 0 ) {
877
878 // } else {
879 // outline0("PUSH HL" );
880 // outline1("LD A, (%s)", _frame );
881 // outline0("LD L, A" );
882 // outline0("LD H, 0" );
883 // outline0("ADD HL, HL" );
884 // outline0("LD DE, HL" );
885 // outline1("LD HL, OFFSETS%4.4x", _frame_size );
886 // outline0("ADD HL, DE" );
887 // outline0("LD A, (HL)" );
888 // outline0("LD E, A" );
889 // outline0("INC HL" );
890 // outline0("LD A, (HL)" );
891 // outline0("LD D, A" );
892 // outline0("POP HL" );
893 // outline0("ADD HL, DE" );
894 // }
895 // }
896
897 // } else {
898
899 // if ( _frame ) {
900 // outline0("LD DE, $0003" );
901 // outline0("ADD HL, DE" );
902 // if ( strlen(_frame) == 0 ) {
903
904 // } else {
905 // outline0("PUSH HL" );
906 // outline1("LD A, (%s)", _frame );
907 // outline0("LD L, A" );
908 // outline0("LD H, 0" );
909 // outline0("ADD HL, HL" );
910 // outline0("LD DE, HL" );
911 // outline1("LD HL, OFFSETS%4.4x", _frame_size );
912 // outline0("ADD HL, DE" );
913 // outline0("LD A, (HL)" );
914 // outline0("LD E, A" );
915 // outline0("INC HL" );
916 // outline0("LD A, (HL)" );
917 // outline0("LD D, A" );
918 // outline0("POP HL" );
919 // outline0("ADD HL, DE" );
920 // }
921 // }
922
923 // }
924
925}
926
927static void pc1403_load_image_address_to_register( Environment * _environment, char * _register, Resource * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
928
929 // if ( !_sequence && !_frame ) {
930 // if ( _source->isAddress ) {
931 // outline1("LD HL, (%s)", _source->realName );
932 // } else {
933 // outline1("LD HL, %s", _source->realName );
934 // }
935 // } else {
936 // if ( _source->isAddress ) {
937 // outline1("LD HL, (%s)", _source->realName );
938 // } else {
939 // outline1("LD HL, %s", _source->realName );
940 // }
941
942 // if ( _sequence ) {
943 // outline0("LD DE, $0003" );
944 // outline0("ADD HL, DE" );
945 // if ( strlen(_sequence) == 0 ) {
946
947 // } else {
948 // outline1("LD A, (%s)", _sequence );
949 // outline0("PUSH HL" );
950 // outline0("POP IX" );
951 // outline1("CALL %soffsetsequence", _source->realName );
952 // }
953 // if ( _frame ) {
954 // if ( strlen(_frame) == 0 ) {
955
956 // } else {
957 // outline1("LD A, (%s)", _frame );
958 // outline0("PUSH HL" );
959 // outline0("POP IX" );
960 // outline1("CALL %soffsetframe", _source->realName );
961 // }
962 // }
963
964 // } else {
965
966 // if ( _frame ) {
967 // outline0("LD DE, $0003" );
968 // outline0("ADD HL, DE" );
969 // if ( strlen(_frame) == 0 ) {
970
971 // } else {
972 // outline0("PUSH HL" );
973 // outline0("POP IX" );
974 // outline1("LD A, (%s)", _frame );
975 // outline1("CALL %soffsetframe", _source->realName );
976 // }
977 // }
978
979 // }
980
981 // }
982 // if ( _register ) {
983 // outline1("LD (%s), HL", _register );
984 // }
985
986}
987
988void pc1403_put_image( Environment * _environment, Resource * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _flags ) {
989
990 // // currently unused
991 // (void)!_flags;
992
993 // MAKE_LABEL
994
995 // deploy( vars, src_hw_pc1403_vars_asm);
996 // deploy( putimage, src_hw_pc1403_put_image_asm );
997
998 // if ( _frame_size ) {
999 // pc1403_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
1000 // }
1001
1002 // outline1("LD A, (%s)", _x );
1003 // outline0("LD (IMAGEX), A" );
1004 // outline1("LD A, (%s)", _y );
1005 // outline0("LD (IMAGEY), A" );
1006
1007 // outline0("PUSH HL" );
1008 // outline1("LD HL, %s", _flags );
1009 // outline0("LD A, L" );
1010 // outline0("LD (IMAGEF), A" );
1011 // outline0("LD A, H" );
1012 // outline0("LD (IMAGET), A" );
1013 // outline0("POP HL" );
1014
1015 // outline0("CALL PUTIMAGE");
1016
1017}
1018
1019void pc1403_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 ) {
1020
1021 // deploy( zxvars, src_hw_pc1403_vars_asm);
1022 // deploy( blitimage, src_hw_pc1403_blit_image_asm );
1023
1024 // if ( _source_count > 2 ) {
1025 // CRITICAL_BLIT_TOO_MUCH_SOURCES( );
1026 // }
1027
1028 // MAKE_LABEL
1029
1030 // outhead1("blitimage%s:", label);
1031 // if ( _source_count > 0 ) {
1032 // Resource resource;
1033 // resource.realName = strdup( _sources[0] );
1034 // resource.type = VT_IMAGE;
1035 // pc1403_load_image_address_to_register( _environment, NULL, &resource, _sequence, _frame, _frame_size, _frame_count );
1036 // } else {
1037 // outline0( "LD HL, 0" );
1038 // }
1039
1040 // outline0("DI");
1041 // outline0("EXX");
1042 // outline0("EI");
1043
1044 // if ( _source_count > 1 ) {
1045 // Resource resource;
1046 // resource.realName = strdup( _sources[1] );
1047 // resource.type = VT_IMAGE;
1048 // pc1403_load_image_address_to_register( _environment, NULL, &resource, _sequence, _frame, _frame_size, _frame_count );
1049 // } else {
1050 // outline0( "LD HL, 0" );
1051 // }
1052
1053 // outline1("LD DE, %s", _blit );
1054
1055 // outline0("DI");
1056 // outline0("EXX");
1057 // outline0("EI");
1058
1059 // outline1("LD A, (%s)", _x );
1060 // outline0("LD (IMAGEX), A" );
1061 // outline1("LD A, (%s)", _y );
1062 // outline0("LD (IMAGEY), A" );
1063 // outline1("LD A, $%2.2x", (_flags & 0Xff) );
1064 // outline0("LD (IMAGEF), A" );
1065 // outline1("LD A, $%2.2x", ((_flags>>8) & 0Xff) );
1066 // outline0("LD (IMAGET), A" );
1067
1068 // outline0("CALL BLITIMAGE");
1069
1070}
1071
1072
1073Variable * pc1403_new_image( Environment * _environment, int _width, int _height, int _mode ) {
1074
1075 // deploy( vars, src_hw_pc1403_vars_asm );
1076
1077 // int size = pc1403_image_size( _environment, _width, _height, _mode );
1078
1079 // if ( ! size ) {
1080 // CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE( _mode );
1081 // }
1082
1083 // Variable * result = variable_temporary( _environment, VT_IMAGE, "(new image)" );
1084
1085 // char * buffer = malloc ( size );
1086 // memset( buffer, 0, size );
1087
1088 // *(buffer) = ( _width & 0xff );
1089 // *(buffer+1) = ( ( _width >> 8 ) & 0xff );
1090 // *(buffer+2) = _height;
1091
1092 // result->valueBuffer = buffer;
1093 // result->size = size;
1094
1095 // return result;
1096
1097}
1098
1099Variable * pc1403_new_images( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
1100
1101 // deploy( vars, src_hw_pc1403_vars_asm );
1102
1103 // int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
1104 // int frameSize = pc1403_image_size( _environment, _width, _height, _mode );
1105
1106 // if ( ! size ) {
1107 // CRITICAL_NEW_IMAGES_UNSUPPORTED_MODE( _mode );
1108 // }
1109
1110 // Variable * result = variable_temporary( _environment, VT_IMAGES, "(new images)" );
1111
1112 // char * buffer = malloc ( size );
1113 // memset( buffer, 0, size );
1114
1115 // *(buffer) = _frames;
1116 // *(buffer+1) = ( _width & 0xff );
1117 // *(buffer+2) = ( _width >> 8 ) & 0xff;
1118 // for( int i=0; i<_frames; ++i ) {
1119 // *(buffer+3+(i*frameSize)) = ( _width & 0xff );
1120 // *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
1121 // *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
1122 // }
1123
1124 // result->valueBuffer = buffer;
1125 // result->frameSize = frameSize;
1126 // result->size = size;
1127 // result->frameCount = _frames;
1128
1129 // return result;
1130
1131}
1132
1133Variable * pc1403_new_sequence( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
1134
1135 // deploy( vars, src_hw_pc1403_vars_asm );
1136
1137 // int size2 = calculate_sequence_size( _environment, _sequences, _frames, _width, _height, _mode );
1138 // int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
1139 // int frameSize = pc1403_image_size( _environment, _width, _height, _mode );
1140
1141 // if ( ! size ) {
1142 // CRITICAL_NEW_IMAGES_UNSUPPORTED_MODE( _mode );
1143 // }
1144
1145 // Variable * result = variable_temporary( _environment, VT_SEQUENCE, "(new sequence)" );
1146
1147 // char * buffer = malloc ( size2 );
1148 // memset( buffer, 0, size2 );
1149
1150 // *(buffer) = _frames;
1151 // *(buffer+1) = _width;
1152 // *(buffer+2) = _sequences;
1153 // for( int i=0; i<(_frames*_sequences); ++i ) {
1154 // *(buffer+3+(i*frameSize)) = ( _width & 0xff );
1155 // *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
1156 // *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
1157 // }
1158
1159 // result->valueBuffer = buffer;
1160 // result->frameSize = frameSize;
1161 // result->size = size;
1162 // result->frameCount = _frames;
1163
1164 // return result;
1165
1166}
1167
1168void pc1403_get_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _palette ) {
1169
1170 // MAKE_LABEL
1171
1172 // deploy( vars, src_hw_pc1403_vars_asm);
1173 // deploy( getimage, src_hw_pc1403_get_image_asm );
1174
1175 // pc1403_load_image_address_to_other_register( _environment, "HL", _image, _sequence, _frame, _frame_size, _frame_count );
1176
1177 // outline1("LD A, (%s)", _x );
1178 // outline0("LD (IMAGEX), A" );
1179 // outline1("LD A, (%s)", _y );
1180 // outline0("LD (IMAGEY), A" );
1181 // outline1("LD A, $%2.2x", _palette & 0xff );
1182 // outline0("LD (IMAGET), A" );
1183
1184 // outline0("CALL GETIMAGE");
1185
1186}
1187
1188void pc1403_scroll( Environment * _environment, int _dx, int _dy ) {
1189
1190};
1191
1192void pc1403_put_tile( Environment * _environment, char * _tile, char * _x, char * _y ) {
1193
1194 // deploy( zxvars, src_hw_pc1403_vars_asm);
1195 // deploy( tiles, src_hw_pc1403_tiles_asm );
1196
1197 // outline1("LD A, (%s)", _tile );
1198 // outline0("LD (TILET), A" );
1199 // outline1("LD A, (%s)", _x );
1200 // outline0("LD (TILEX), A" );
1201 // outline1("LD A, (%s)", _y );
1202 // outline0("LD (TILEY), A" );
1203 // outline0("LD A, 1" );
1204 // outline0("LD (TILEW), A" );
1205 // outline0("LD (TILEH), A" );
1206 // outline0("LD (TILEW2), A" );
1207 // outline0("LD (TILEH2), A" );
1208
1209 // outline0("CALL PUTTILE");
1210
1211}
1212
1213void pc1403_move_tiles( Environment * _environment, char * _tile, char * _x, char * _y ) {
1214
1215 // Variable * tile = variable_retrieve( _environment, _tile );
1216 // Variable * x = variable_retrieve( _environment, _x );
1217 // Variable * y = variable_retrieve( _environment, _y );
1218
1219 // deploy( zxvars, src_hw_pc1403_vars_asm);
1220 // deploy( tiles, src_hw_pc1403_tiles_asm );
1221
1222 // int size = ( tile->originalWidth >> 3 ) * ( tile->originalHeight >> 3 );
1223
1224 // if ( size ) {
1225 // outline1("LD HL, OFFSETS%4.4x", size );
1226 // outline0("LD A, L" );
1227 // outline0("LD (TILEO), A" );
1228 // outline0("LD A, H" );
1229 // outline0("LD (TILEO+1), A" );
1230 // } else {
1231 // outline0("LD A, 0" );
1232 // outline0("LD (TILEO), A" );
1233 // outline0("LD (TILEO+1), A" );
1234 // }
1235
1236 // outline1("LD A, (%s)", tile->realName );
1237 // outline0("LD (TILET), A" );
1238 // outline1("LD A, (%s)", x->realName );
1239 // outline0("LD (TILEX), A" );
1240 // outline1("LD A, (%s)", y->realName );
1241 // outline0("LD (TILEY), A" );
1242 // outline1("LD A, (%s)", address_displacement(_environment, tile->realName, "1") );
1243 // outline0("LD (TILEW), A" );
1244 // outline0("LD (TILEW2), A" );
1245 // outline1("LD A, (%s)", address_displacement(_environment, tile->realName, "2") );
1246 // outline0("LD (TILEH), A" );
1247 // outline0("LD (TILEH2), A" );
1248 // outline1("LD A, (%s)", address_displacement(_environment, tile->realName, "3") );
1249 // outline0("LD (TILEA), A" );
1250
1251 // outline0("CALL MOVETILE");
1252
1253}
1254
1255void pc1403_put_tiles( Environment * _environment, char * _tile, char * _x, char * _y, char *_w, char *_h ) {
1256
1257 // deploy( zxvars, src_hw_pc1403_vars_asm);
1258 // deploy( tiles, src_hw_pc1403_tiles_asm );
1259
1260 // outline1("LD A, (%s)", _tile );
1261 // outline0("LD (TILET), A" );
1262 // outline1("LD A, (%s)", _x );
1263 // outline0("LD (TILEX), A" );
1264 // outline1("LD A, (%s)", _y );
1265 // outline0("LD (TILEY), A" );
1266 // outline1("LD A, (%s)", address_displacement(_environment, _tile, "1") );
1267 // outline0("LD (TILEW), A" );
1268 // if ( _w ) {
1269 // outline1("LD A, (%s)", _w );
1270 // }
1271 // outline0("LD (TILEW2), A" );
1272 // outline1("LD A, (%s)", address_displacement(_environment, _tile, "2") );
1273 // outline0("LD (TILEH), A" );
1274 // if ( _h ) {
1275 // outline1("LD A, (%s)", _h );
1276 // }
1277 // outline0("LD (TILEH2), A" );
1278
1279 // outline0("CALL PUTTILE");
1280
1281}
1282
1283void pc1403_tile_at( Environment * _environment, char * _x, char * _y, char * _result ) {
1284
1285 // deploy( zxvars, src_hw_pc1403_vars_asm);
1286 // deploy( tiles, src_hw_pc1403_tiles_asm );
1287
1288 // outline1("LD A, (%s)", _x );
1289 // outline0("LD (TILEX), A" );
1290 // outline1("LD A, (%s)", _y );
1291 // outline0("LD (TILEY), A" );
1292
1293 // outline0("CALL TILEAT");
1294
1295 // outline0("LD A, (TILET)" );
1296 // outline1("LD (%s), A", _result );
1297
1298}
1299
1300void pc1403_use_tileset( Environment * _environment, char * _tileset ) {
1301
1302 // deploy( zxvars, src_hw_pc1403_vars_asm);
1303 // deploy( tiles, src_hw_pc1403_tiles_asm );
1304
1305 // outline1("LD A, (%s)", _tileset );
1306
1307 // outline0("CALL USETILESET");
1308
1309}
1310
1312
1313 // Variable * result = variable_temporary( _environment, VT_WORD, "(raster line)" );
1314
1315 // variable_store( _environment, result->name, 261 );
1316
1317 // return result;
1318
1319}
1320
1321void pc1403_slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _destination ) {
1322
1323}
1324
1325void pc1403_sys_call( Environment * _environment, int _destination ) {
1326
1327 // outline1("CALL $%4.4x", _destination );
1328
1329}
1330
1331int pc1403_palette_extract( Environment * _environment, char * _data, int _width, int _height, int _depth, int _flags, RGBi * _palette ) {
1332
1333 // int paletteColorCount = rgbi_extract_palette(_environment, _data, _width, _height, _depth, _palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
1334
1335 // memcpy( _palette, palette_match( _palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) ), paletteColorCount * sizeof( RGBi ) );
1336
1337 // int uniquePaletteCount = 0;
1338
1339 // memcpy( _palette, palette_remove_duplicates( _palette, paletteColorCount, &uniquePaletteCount ), paletteColorCount * sizeof( RGBi ) );
1340
1341 // return uniquePaletteCount;
1342
1343}
1344
1345void pc1403_hscroll_line( Environment * _environment, int _direction, int _overlap ) {
1346
1347 // deploy( textHScrollLine, src_hw_pc1403_hscroll_asm);
1348
1349 // outline0("LD A, (YCURSYS)" );
1350 // outline0("LD B, A" );
1351 // outline1("LD A, $%2.2x", ( _direction & 0xff ) );
1352
1353 // outline0("CALL HSCROLLLINE");
1354
1355}
1356
1357void pc1403_timer_set_status_on( Environment * _environment, char * _timer ) {
1358
1359 // deploy( timer, src_hw_sc61860_timer_asm);
1360
1361 // if ( _timer ) {
1362 // outline1("LD A, (%s)", _timer );
1363 // outline0("LD A, B" );
1364 // } else {
1365 // outline0("LD B, 0" );
1366 // }
1367 // outline0("LD A, 1" );
1368 // outline0("LD C, A" );
1369 // outline0("CALL TIMERSETSTATUS" );
1370
1371}
1372
1373void pc1403_timer_set_status_off( Environment * _environment, char * _timer ) {
1374
1375 // deploy( timer, src_hw_sc61860_timer_asm);
1376
1377 // if ( _timer ) {
1378 // outline1("LD A, (%s)", _timer );
1379 // outline0("LD A, B" );
1380 // } else {
1381 // outline0("LD B, 0" );
1382 // }
1383 // outline0("LD A, 0" );
1384 // outline0("LD C, A" );
1385 // outline0("CALL TIMERSETSTATUS" );
1386
1387}
1388
1389void pc1403_timer_set_counter( Environment * _environment, char * _timer, char * _counter ) {
1390
1391 // deploy( timer, src_hw_sc61860_timer_asm);
1392
1393 // if ( _counter ) {
1394 // outline1("LD A, (%s)", _counter );
1395 // outline0("LD IXL, A" );
1396 // outline1("LD A, (%s)", address_displacement( _environment, _counter, "1" ) );
1397 // outline0("LD IXH, A" );
1398 // } else {
1399 // outline0("LD IX, 0" );
1400 // }
1401 // if ( _timer ) {
1402 // outline1("LD A, (%s)", _timer );
1403 // outline0("LD B, A" );
1404 // } else {
1405 // outline0("LD B, 0" );
1406 // }
1407 // outline0("CALL TIMERSETCOUNTER" );
1408
1409}
1410
1411void pc1403_timer_set_init( Environment * _environment, char * _timer, char * _init ) {
1412
1413 // deploy( timer, src_hw_sc61860_timer_asm);
1414
1415 // if ( _init ) {
1416 // outline1("LD A, (%s)", _init );
1417 // outline0("LD IXL, A" );
1418 // outline1("LD A, (%s)", address_displacement( _environment, _init, "1" ) );
1419 // outline0("LD IXH, A" );
1420 // } else {
1421 // outline0("LD IX, 0" );
1422 // }
1423 // if ( _timer ) {
1424 // outline1("LD A, (%s)", _timer );
1425 // outline0("LD B, A" );
1426 // } else {
1427 // outline0("LD B, 0" );
1428 // }
1429 // outline0("CALL TIMERSETINIT" );
1430
1431}
1432
1433void pc1403_timer_set_address( Environment * _environment, char * _timer, char * _address ) {
1434
1435 // deploy( timer, src_hw_sc61860_timer_asm);
1436
1437 // if ( _address ) {
1438 // outline1("LD HL, %s", _address );
1439 // outline0("LD A, L" );
1440 // outline0("LD IXL, A" );
1441 // outline0("LD A, H" );
1442 // outline0("LD IXH, A" );
1443 // } else {
1444 // outline0("LD IX, 0" );
1445 // }
1446 // if ( _timer ) {
1447 // outline1("LD A, (%s)", _timer );
1448 // outline0("LD B, A" );
1449 // } else {
1450 // outline0("LD B, 0" );
1451 // }
1452 // outline0("CALL TIMERSETADDRESS" );
1453
1454}
1455
1456void pc1403_put_key( Environment * _environment, char *_string, char * _size ) {
1457
1458 // _environment->bitmaskNeeded = 1;
1459
1460 // deploy( keyboard, src_hw_pc1403_keyboard_asm);
1461
1462 // outline1("LD HL, (%s)", _string );
1463 // outline1("LD A, (%s)", _size );
1464 // outline0("CALL PUTKEY" );
1465
1466}
1467
1468void pc1403_dload( Environment * _environment, char * _filename, char * _offset, char * _address, char * _size ) {
1469
1470}
1471
1472void pc1403_dsave( Environment * _environment, char * _filename, char * _offset, char * _address, char * _size ) {
1473
1474}
1475
1476void pc1403_joy( Environment * _environment, int _port, char * _value ) {
1477
1478}
1479
1480void pc1403_joy_vars( Environment * _environment, char * _port, char * _value ) {
1481
1482}
1483
1484#endif
void cpu_call(Environment *_environment, char *_label)
Definition 6309.c:3755
#define COLOR_COUNT
Definition 6847.h:72
#define BITMAP_MODE_STANDARD
Definition 6847.h:96
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Variable * variable_import(Environment *_environment, char *_name, VariableType _type, int _size_or_value)
void variable_global(Environment *_environment, char *_pattern)
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
void cls(Environment *_environment, char *_paper)
Emit code for CLS.
Definition cls.c:48
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
Definition plot.c:46
#define TILEMAP_MODE_STANDARD
Definition cga.h:80
Variable * pc1403_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 pc1403.c:749
void pc1403_scroll(Environment *_environment, int _dx, int _dy)
Definition pc1403.c:1188
void pc1403_clear_key(Environment *_environment)
Definition pc1403.c:262
void pc1403_dload(Environment *_environment, char *_filename, char *_offset, char *_address, char *_size)
Definition pc1403.c:1468
void pc1403_joy_vars(Environment *_environment, char *_port, char *_value)
Definition pc1403.c:1480
void pc1403_inkey(Environment *_environment, char *_key)
Definition pc1403.c:189
void pc1403_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
Definition pc1403.c:1213
void pc1403_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
Definition pc1403.c:1168
void pc1403_text(Environment *_environment, char *_text, char *_text_size, int _raw)
Definition pc1403.c:154
void pc1403_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 pc1403.c:1019
void pc1403_pset_int(Environment *_environment, int _x, int _y, int *_c)
Definition pc1403.c:79
void pc1403_finalization(Environment *_environment)
Definition pc1403.c:394
int pc1403_image_size(Environment *_environment, int _width, int _height, int _mode)
Definition pc1403.c:55
void pc1403_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
Definition pc1403.c:1255
void pc1403_dsave(Environment *_environment, char *_filename, char *_offset, char *_address, char *_size)
Definition pc1403.c:1472
void pc1403_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition pc1403.c:1321
Variable * pc1403_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
Definition pc1403.c:1099
void pc1403_wait_key_or_fire(Environment *_environment, int _port, int _release)
Definition pc1403.c:201
void pc1403_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
Definition pc1403.c:1283
void pc1403_screen_columns(Environment *_environment, char *_columns)
Definition pc1403.c:406
void pc1403_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Definition pc1403.c:431
void pc1403_back(Environment *_environment)
Definition pc1403.c:441
void pc1403_color_border(Environment *_environment, char *_color)
Definition pc1403.c:73
void pc1403_vscroll(Environment *_environment, int _displacement)
Definition pc1403.c:148
int pc1403_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
Definition pc1403.c:1331
void pc1403_scanshift(Environment *_environment, char *_shifts)
Definition pc1403.c:250
void pc1403_key_pressed(Environment *_environment, char *_scancode, char *_result)
Definition pc1403.c:244
void pc1403_sys_call(Environment *_environment, int _destination)
Definition pc1403.c:1325
void pc1403_cls_box(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Definition pc1403.c:185
void pc1403_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
Definition pc1403.c:846
void pc1403_timer_set_address(Environment *_environment, char *_timer, char *_address)
Definition pc1403.c:1433
void pc1403_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
Definition pc1403.c:988
void pc1403_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
Definition pc1403.c:96
void pc1403_put_key(Environment *_environment, char *_string, char *_size)
Definition pc1403.c:1456
void pc1403_timer_set_status_on(Environment *_environment, char *_timer)
Definition pc1403.c:1357
void pc1403_asciicode(Environment *_environment, char *_result)
Definition pc1403.c:237
void pc1403_wait_key_or_fire_semivar(Environment *_environment, char *_port, int _release)
Definition pc1403.c:207
void pc1403_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Definition pc1403.c:437
void pc1403_hscroll_line(Environment *_environment, int _direction, int _overlap)
Definition pc1403.c:1345
void console_calculate_vars(Environment *_environment)
Definition pc1403.c:414
void pc1403_keyshift(Environment *_environment, char *_shifts)
Definition pc1403.c:256
Variable * pc1403_new_image(Environment *_environment, int _width, int _height, int _mode)
Definition pc1403.c:1073
void pc1403_wait_key(Environment *_environment, int _release)
Definition pc1403.c:195
void pc1403_use_tileset(Environment *_environment, char *_tileset)
Definition pc1403.c:1300
void pc1403_screen_rows(Environment *_environment, char *_rows)
Definition pc1403.c:402
void pc1403_key_state(Environment *_environment, char *_scancode, char *_result)
Definition pc1403.c:225
Variable * pc1403_get_raster_line(Environment *_environment)
Definition pc1403.c:1311
void pc1403_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
Definition pc1403.c:124
void pc1403_timer_set_init(Environment *_environment, char *_timer, char *_init)
Definition pc1403.c:1411
void pc1403_cls(Environment *_environment)
Definition pc1403.c:177
void pc1403_wait_fire_semivar(Environment *_environment, char *_port, int _release)
Definition pc1403.c:219
void pc1403_timer_set_counter(Environment *_environment, char *_timer, char *_counter)
Definition pc1403.c:1389
void pc1403_wait_fire(Environment *_environment, int _port, int _release)
Definition pc1403.c:213
void pc1403_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
Definition pc1403.c:1192
void pc1403_timer_set_status_off(Environment *_environment, char *_timer)
Definition pc1403.c:1373
void pc1403_joy(Environment *_environment, int _port, char *_value)
Definition pc1403.c:1476
int pc1403_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
Definition pc1403.c:418
Variable * pc1403_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
Definition pc1403.c:1133
void pc1403_scancode(Environment *_environment, char *_result)
Definition pc1403.c:231
void console_calculate(Environment *_environment)
Definition pc1403.c:410
void pc1403_initialization(Environment *_environment)
Definition pc1403.c:274
int screenTilesWidth
Definition ugbc.h:2880
int fontHeight
Definition ugbc.h:2905
int screenTilesHeight
Definition ugbc.h:2885
int consoleTilesHeight
Definition ugbc.h:2895
int fontWidth
Definition ugbc.h:2900
int screenColors
Definition ugbc.h:2870
int screenHeight
Definition ugbc.h:2860
int consoleTilesWidth
Definition ugbc.h:2890
int screenWidth
Definition ugbc.h:2855
char * realName
Definition ugbc.h:982
struct _ScreenMode ScreenMode
struct _Resource Resource
struct _RGBi RGBi
Structure to store color components (red, green and blue).
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_WORD
Definition ugbc.h:455
@ VT_BYTE
Definition ugbc.h:450
#define SCREEN_MODE_DEFINE(_id, _bitmap, _width, _height, _colors, _tile_width, _tile_height, _description)
Definition ugbc.h:1516
#define outline0(s)
Definition ugbc.h:4252
#define outline1(s, a)
Definition ugbc.h:4253
#define CRITICAL_UNIMPLEMENTED(v)
Definition ugbc.h:3444
#define deploy(s, e)
Definition ugbc.h:4288