ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
6847b.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(__d32b__) || defined(__d64b__) || defined(__cocob__)
36
37#include "../ugbc.h"
38#include <math.h>
39
40static RGBi SYSTEM_PALETTE_ALTERNATE[][4] = {
41 {
42 { 0x00, 0xcc, 0x55, 0xff, 0, "GREEN" },
43 { 0xee, 0xee, 0x77, 0xff, 1, "YELLOW" },
44 { 0x00, 0x00, 0xaa, 0xff, 2, "BLUE" },
45 { 0x88, 0x00, 0x00, 0xff, 3, "RED" }
46 },
47 {
48 { 0x00, 0x00, 0x00, 0xff, 0, "BLACK" },
49 { 0xf0, 0xf0, 0xf0, 0xff, 5, "BUFF" },
50 { 0xaa, 0xff, 0xe6, 0xff, 6, "CYAN" },
51 { 0xcc, 0x44, 0xcc, 0xff, 7, "MAGENTA" } //,
52 // { 0xa1, 0x68, 0x3c, 0xff, 8, "ORANGE" }
53 }
54};
55
56static RGBi * SYSTEM_PALETTE = &SYSTEM_PALETTE_ALTERNATE[0][0];
57
58static RGBi * commonPalette;
60
61/****************************************************************************
62 * CODE SECTION
63 ****************************************************************************/
64
76void c6847b_collision( Environment * _environment, char * _sprite_mask, char * _result ) {
77
78}
79
91void c6847b_hit( Environment * _environment, char * _sprite_mask, char * _result ) {
92
93}
94
104void c6847b_border_color( Environment * _environment, char * _border_color ) {
105
107
108 outline1( "LDA %s", _border_color );
109 outline0( "CMPA 4" );
110 outline1( "BCs %scss0", label );
111 outhead1( "%scss1", label );
112 CSS_SET;
113 outline1( "JMP %sdone", label );
114 outhead1( "%scss0", label );
115 CSS_CLR;
116 outhead1( "%sdone", label );
117
118}
119
130void c6847b_background_color( Environment * _environment, char * _index, char * _background_color ) {
131
133
134 (void) _index;
135
136 outline1( "LDA %s", _background_color );
137 outline0( "CMPA 4" );
138 outline1( "BCs %scss0", label );
139 outhead1( "%scss1", label );
140 CSS_SET;
141 outline1( "JMP %sdone", label );
142 outhead1( "%scss0", label );
143 CSS_CLR;
144 outhead1( "%sdone", label );
145
146}
147
158void c6847b_sprite_common_color( Environment * _environment, char * _index, char * _common_color ) {
159
160}
161
177void c6847b_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
178
179}
180
191void c6847b_next_raster( Environment * _environment ) {
192
193}
194
208void c6847b_next_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
209
210}
211
212void c6847b_bank_select( Environment * _environment, int _bank ) {
213
214}
215
216#define SET_VIDEOAT_ZERO SAM_F0_CLR; SAM_F1_CLR; SAM_F2_CLR; SAM_F3_CLR; SAM_F4_CLR; SAM_F5_CLR; SAM_F6_CLR;
217
218#define SET_VIDEOAT_0400 SET_VIDEOAT_ZERO; SAM_F1_SET;
219#define SET_VIDEOAT_1C00 SET_VIDEOAT_ZERO; SAM_F2_SET; SAM_F3_SET; SAM_F4_SET;
220
221void console_calculate( Environment * _environment ) {
222
223 int consoleSA = 0x0c00;
224 int consoleWB = _environment->activeConsole.width;
225 int consoleHB = _environment->activeConsole.height * 8;
226
227 switch( _environment->currentMode ) {
228 case TILEMAP_MODE_INTERNAL: // Alphanumeric Internal 32 × 16 2 512
229 case TILEMAP_MODE_EXTERNAL: // Alphanumeric External 32 × 16 2 512
230 case TILEMAP_MODE_SEMIGRAPHICS4: // Semigraphics 4 64 × 32 8 512
231 case TILEMAP_MODE_SEMIGRAPHICS6: // Semigraphics 6 64 × 48 4 512
232 case TILEMAP_MODE_SEMIGRAPHICS8: // Semigraphics 8 64 × 64 2 512
233 case TILEMAP_MODE_SEMIGRAPHICS12: // Semigraphics 6 64 × 96 1 3072
234 case TILEMAP_MODE_SEMIGRAPHICS24: // Semigraphics 6 64 × 96 1 3072
235 break;
236 case BITMAP_MODE_COLOR1: // Color Graphics 1 64 × 64 4 1024
237 consoleSA += ( _environment->activeConsole.y1 << 7 ) + ( _environment->activeConsole.x1 << 1 );
238 consoleWB = _environment->activeConsole.width * 2;
239 break;
240 case BITMAP_MODE_RESOLUTION1: // Resolution Graphics 1 128 × 64 1 + Black 1024
241 consoleSA += ( _environment->activeConsole.y1 << 7 ) + ( _environment->activeConsole.x1 << 2 );
242 break;
243 case BITMAP_MODE_COLOR2: // Color Graphics 2 128 × 64 4 2048
244 consoleSA += ( _environment->activeConsole.y1 << 8 ) + ( _environment->activeConsole.x1 << 1 );
245 consoleWB = _environment->activeConsole.width * 2;
246 break;
247 case BITMAP_MODE_RESOLUTION2: // Resolution Graphics 2 128 × 96 1 + Black 1536
248 consoleSA += ( _environment->activeConsole.y1 << 7 ) + ( _environment->activeConsole.x1 << 1 );
249 break;
250 case BITMAP_MODE_COLOR3: // Color Graphics 3 128 × 96 4 3072
251 consoleSA += ( _environment->activeConsole.y1 << 8 ) + ( _environment->activeConsole.x1 << 1 );
252 consoleWB = _environment->activeConsole.width * 2;
253 break;
254 case BITMAP_MODE_RESOLUTION3: // Resolution Graphics 3 128 × 192 1 + Black 3072
255 consoleSA += ( _environment->activeConsole.y1 << 7 ) + ( _environment->activeConsole.x1 << 2 );
256 break;
257 case BITMAP_MODE_COLOR6: // Color Graphics 6 128 × 192 4 6144
258 consoleSA += ( _environment->activeConsole.y1 << 8 ) + ( _environment->activeConsole.x1 << 1 );
259 consoleWB = _environment->activeConsole.width * 2;
260 break;
261 case BITMAP_MODE_RESOLUTION6: // Resolution Graphics 6 256 × 192 1 + Black 6144 break;
262 consoleSA += ( _environment->activeConsole.y1 << 8 ) + ( _environment->activeConsole.x1 );
263 consoleWB = _environment->activeConsole.width * 2;
264 break;
265 default:
267 }
268
269 cpu_store_16bit( _environment, "CONSOLESA", consoleSA );
270 cpu_store_8bit( _environment, "CONSOLEWB", consoleWB );
271 cpu_store_8bit( _environment, "CONSOLEHB", consoleHB );
272
273}
274
275void console_calculate_vars( Environment * _environment ) {
276
277 _environment->dynamicConsole = 1;
278
279 outline0( "JSR CONSOLECALCULATE" );
280
281}
282
283
284int c6847b_screen_mode_enable( Environment * _environment, ScreenMode * _screen_mode ) {
285
286 _screen_mode->selected = 1;
287
288 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm );
289
290 _environment->fontWidth = 8;
291 _environment->fontHeight = 8;
292 _environment->screenShades = 4;
293 _environment->screenTiles = 128;
294 switch( _screen_mode->id ) {
295 // ALPHANUMERIC DISPLAY MODES – All alphanumeric modes occupy an 8 x 12
296 // dot character matrix box and there are 32 x 16 character boxes per TV frame.
297 // Each horizontal dot (dot-clock) corresponds to one half the period duration of
298 // the 3.58 MHz clock and each vertical dot is one scan line. One of two colors
299 // for the lighted dots may be selected by the color set select pin (pin 39).
300 // An internal ROM will generate 64 ASCII display characters in a standard 5 x 7 box.
301 // Six bits of the eight-bit data word are used for the ASCII character generator
302 // and the two bits not used are used to implement inverse video and mode
303 // switching to semigraphics – 4, – 8, – 12, or – 24.
304 case TILEMAP_MODE_INTERNAL: // Alphanumeric Internal 32 × 16 2 512
305 _environment->screenWidth = 32*8;
306 _environment->screenHeight = 16*12;
307 _environment->screenTilesWidth = 32;
308 _environment->screenTilesHeight = 16;
309 _environment->screenColors = 4;
310 // Internal alphanumeric 0 X X 0 0 0 0 32x16 ( 5x7 pixel ch)
312 VDG_TEXT;
316 GM2_CLR;
317 GM1_CLR;
318 GM0_CLR;
319 cpu_store_16bit( _environment, "CLIPX1", 0 );
320 cpu_store_16bit( _environment, "CLIPX2", 31 );
321 cpu_store_16bit( _environment, "CLIPY1", 0 );
322 cpu_store_16bit( _environment, "CLIPY2", 15 );
323 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 32*16 );
324 break;
325 case TILEMAP_MODE_EXTERNAL: // Alphanumeric External 32 × 16 2 512
326 _environment->screenWidth = 32*8;
327 _environment->screenHeight = 16*12;
328 _environment->screenTilesWidth = 32;
329 _environment->screenTilesHeight = 16;
330 _environment->screenColors = 4;
331 // External alphanumeric 0 X X 1 0 0 0 32x16 (8x12 pixel ch)
333 VDG_TEXT;
337 GM2_CLR;
338 GM1_CLR;
339 GM0_SET;
340 cpu_store_16bit( _environment, "CLIPX1", 0 );
341 cpu_store_16bit( _environment, "CLIPX2", 31 );
342 cpu_store_16bit( _environment, "CLIPY1", 0 );
343 cpu_store_16bit( _environment, "CLIPY2", 15 );
344 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 32*16 );
345 break;
346 // The ALPHA SEMIGRAPHICS – 4 mode translates bits 0 through 3 into a 4 x 6 dot
347 // element in the standard 8 x 12 dot box. Three data bits may be used to select
348 // one of eight colors for the entire character box. The extra bit is used to
349 // switch to alphanumeric. A 512 byte display memory is required. A density of
350 // 64 x 32 elements is available in the display area. The element area is four
351 // dot-clocks wide by six lines high.
352 case TILEMAP_MODE_SEMIGRAPHICS4: // Semigraphics 4 64 × 32 8 512
353 _environment->screenWidth = 64;
354 _environment->screenHeight = 32;
355 _environment->screenTilesWidth = 32;
356 _environment->screenTilesHeight = 16;
357 _environment->screenColors = 4;
358 // Semigraphic-4 0 X X 0 0 0 0 32x16 ch, 64x32 pixels
360 VDG_TEXT;
364 GM2_CLR;
365 GM1_CLR;
366 GM0_CLR;
367 cpu_store_16bit( _environment, "CLIPX1", 0 );
368 cpu_store_16bit( _environment, "CLIPX2", 63 );
369 cpu_store_16bit( _environment, "CLIPY1", 0 );
370 cpu_store_16bit( _environment, "CLIPY2", 31 );
371 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 512 );
372 break;
373 // The ALPHA SEMIGRAPHICS – 6 mode maps six 4 x 4 dot elements into the standard
374 // 8 x 12 dot alphanumeric box, a screen density of 64 x 48 elements is available.
375 // Six bits are used to generate this map and two data bits may be used to select
376 // one of four colors in the display box. A 512 byte display memory is required.
377 // The element area is four dot-clocks wide by four lines high.
378 case TILEMAP_MODE_SEMIGRAPHICS6: // Semigraphics 6 64 × 48 4 512
379 _environment->screenWidth = 64;
380 _environment->screenHeight = 48;
381 _environment->screenTilesWidth = 32;
382 _environment->screenTilesHeight = 16;
383 _environment->screenColors = 4;
384 // Semigraphic-6 0 X X 1 0 0 0 64x48 pixels
386 VDG_TEXT;
390 GM2_CLR;
391 GM1_CLR;
392 GM0_SET;
393 cpu_store_16bit( _environment, "CLIPX1", 0 );
394 cpu_store_16bit( _environment, "CLIPX2", 63 );
395 cpu_store_16bit( _environment, "CLIPY1", 0 );
396 cpu_store_16bit( _environment, "CLIPY2", 47 );
397 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 512 );
398 break;
399 // The ALPHA SEMIGRAPHICS – 8 mode maps eight 4 x 3 dot elements into the
400 // standard 8 x 12 dot box. This mode requires four memory locations per box
401 // and each memory location may specify one of eight colors or black.
402 // A 2048 byte display memory is required. A density of 64 x 64 elements is
403 // available in the display area. The element area is four dot-clocks wide
404 // by three lines high.
405 case TILEMAP_MODE_SEMIGRAPHICS8: // Semigraphics 8 64 × 64 2 512
406 _environment->screenWidth = 64;
407 _environment->screenHeight = 64;
408 _environment->screenTilesWidth = 32;
409 _environment->screenTilesHeight = 16;
410 _environment->screenColors = 4;
411 cpu_store_16bit( _environment, "CLIPX1", 0 );
412 cpu_store_16bit( _environment, "CLIPX2", 63 );
413 cpu_store_16bit( _environment, "CLIPY1", 0 );
414 cpu_store_16bit( _environment, "CLIPY2", 63 );
415 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 2048 );
416 break;
417 // The ALPHA SEMIGRAPHICS – 12 mode maps twelve 4 x 2 dot elements into the
418 // standard 8 x 12 dot box. This mode requires six memory locations per box and
419 // each memory location may specify one of eight colors or black. A 3072 byte
420 // display memory is required. A density of 64 x 96 elements is available in the
421 // display area. The element area is four dot-clocks wide by two lineshigh.
422 case TILEMAP_MODE_SEMIGRAPHICS12: // Semigraphics 6 64 × 96 1 3072
423 _environment->screenWidth = 64;
424 _environment->screenHeight = 96;
425 _environment->screenTilesWidth = 32;
426 _environment->screenTilesHeight = 16;
427 _environment->screenColors = 4;
428 cpu_store_16bit( _environment, "CLIPX1", 0 );
429 cpu_store_16bit( _environment, "CLIPX2", 63 );
430 cpu_store_16bit( _environment, "CLIPY1", 0 );
431 cpu_store_16bit( _environment, "CLIPY2", 95 );
432 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 3072 );
433 break;
434 // The ALPHA SEMIGRAPHICS – 24 mode maps twenty-four 4 x 1 dot elements into
435 // the standard 8 x 12 dot box. This mode requires twelve memory locations
436 // per box and each memory location may specify one of eight colors or black.
437 // A 6144 byte display memory is required. A density of 64 x 192
438 // elements is available in the display are. The element area is four
439 // dot-clocks wide by one line high.
440 case TILEMAP_MODE_SEMIGRAPHICS24: // Semigraphics 6 64 × 96 1 3072
441 _environment->screenWidth = 64;
442 _environment->screenHeight = 96;
443 _environment->screenTilesWidth = 32;
444 _environment->screenTilesHeight = 16;
445 _environment->screenColors = 4;
446 cpu_store_16bit( _environment, "CLIPX1", 0 );
447 cpu_store_16bit( _environment, "CLIPX2", 63 );
448 cpu_store_16bit( _environment, "CLIPY1", 0 );
449 cpu_store_16bit( _environment, "CLIPY2", 191 );
450 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 6144 );
451 break;
452 // The 64 x 64 Color Graphics mode generates a display matrix of 64
453 // elements wide by 64 elements high. Each element may be one of four
454 // colors. A 1K x 8 display memory is required. Each pixel equals
455 // four dot-clocks by three scan lines.
456 case BITMAP_MODE_COLOR1: // Color Graphics 1 64 × 64 4 1024
457 _environment->screenWidth = 64;
458 _environment->screenHeight = 64;
459 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
460 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
461 _environment->screenColors = 4;
462 // Full graphic 1-C 1 0 0 0 0 0 1 64x64x4 $400(1024)
464 VDG_GRAPH;
468 GM2_CLR;
469 GM1_CLR;
470 GM0_CLR;
471 cpu_store_16bit( _environment, "CLIPX1", 0 );
472 cpu_store_16bit( _environment, "CLIPX2", 63 );
473 cpu_store_16bit( _environment, "CLIPY1", 0 );
474 cpu_store_16bit( _environment, "CLIPY2", 63 );
475 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 1024 );
476 cpu_store_8bit( _environment, "CURRENTSL", 64 / 4 );
477 break;
478 // The 128 x 64 Graphics Mode generates a matrix 128 elements wide
479 // by 64 elements high. Each element may be either ON or OFF. However,
480 // the entire display may be one of two colors, selected by using the
481 // color set select pin. A 1K x 8 display memory is required. Each
482 // pixel equals two dotclocks by three scan lines.
483 case BITMAP_MODE_RESOLUTION1: // Resolution Graphics 1 128 × 64 1 + Black 1024
484 _environment->screenWidth = 128;
485 _environment->screenHeight = 64;
486 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
487 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
488 _environment->screenColors = 2;
489 // Full graphic 1-R 1 0 0 1 0 0 1 128x64x2 $400(1024)
491 VDG_GRAPH;
495 GM2_CLR;
496 GM1_CLR;
497 GM0_SET;
498 cpu_store_16bit( _environment, "CLIPX1", 0 );
499 cpu_store_16bit( _environment, "CLIPX2", 127 );
500 cpu_store_16bit( _environment, "CLIPY1", 0 );
501 cpu_store_16bit( _environment, "CLIPY2", 63 );
502 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 1024 );
503 cpu_store_8bit( _environment, "CURRENTSL", 128 / 8 );
504 break;
505 // The 128 x 64 Color Graphics mode generates a display matrix 128
506 // elements wide by 64 elements high. Each element may be one of four
507 // colors. A 2K x 8 display memory is required. Each pixel equals
508 // two dot-clocks by three scan lines.
509 case BITMAP_MODE_COLOR2: // Color Graphics 2 128 × 64 4 2048
510 _environment->screenWidth = 128;
511 _environment->screenHeight = 64;
512 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
513 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
514 _environment->screenColors = 4;
515 // Full graphic 2-C 1 0 1 0 0 1 0 128x64x4 $800(2048)
517 VDG_GRAPH;
521 GM2_CLR;
522 GM1_SET;
523 GM0_CLR;
524 cpu_store_16bit( _environment, "CLIPX1", 0 );
525 cpu_store_16bit( _environment, "CLIPX2", 127 );
526 cpu_store_16bit( _environment, "CLIPY1", 0 );
527 cpu_store_16bit( _environment, "CLIPY2", 63 );
528 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 2048 );
529 cpu_store_8bit( _environment, "CURRENTSL", 128 / 4 );
530 break;
531 // The 128 x 96 Graphics mode generates a display matrix 128
532 // elements wide by 96 elements high. Each element may be either
533 // ON or OFF. However, the entire display may be one of two colors
534 // selected by using the color select pin. A 2K x 8 display memory
535 // is required. Each pixel equals two dot-clocks by two scan lines.
536 case BITMAP_MODE_RESOLUTION2: // Resolution Graphics 2 128 × 96 1 + Black 1536
537 _environment->screenWidth = 128;
538 _environment->screenHeight = 96;
539 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
540 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
541 _environment->screenColors = 2;
542 // Full graphic 2-R 1 0 1 1 0 1 1 128x96x2 $600(1536)
544 VDG_GRAPH;
548 GM2_CLR;
549 GM1_SET;
550 GM0_SET;
551 cpu_store_16bit( _environment, "CLIPX1", 0 );
552 cpu_store_16bit( _environment, "CLIPX2", 127 );
553 cpu_store_16bit( _environment, "CLIPY1", 0 );
554 cpu_store_16bit( _environment, "CLIPY2", 95 );
555 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 1536 );
556 cpu_store_8bit( _environment, "CURRENTSL", 128 / 8 );
557 break;
558 // The 128 x 96 Color Graphics mode generates a display 128 elements
559 // wide by 96 elements high. Each element may be one of four colors.
560 // A 3K x 8 display memory is required. Each pixel equals two
561 // dot-clocks by two scan lines.
562 case BITMAP_MODE_COLOR3: // Color Graphics 3 128 × 96 4 3072
563 _environment->screenWidth = 128;
564 _environment->screenHeight = 96;
565 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
566 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
567 _environment->screenColors = 4;
568 // Full graphic 3-C 1 1 0 0 1 0 0 128x96x4 $C00(3072)
570 VDG_GRAPH;
574 GM2_SET;
575 GM1_CLR;
576 GM0_CLR;
577 cpu_store_16bit( _environment, "CLIPX1", 0 );
578 cpu_store_16bit( _environment, "CLIPX2", 127 );
579 cpu_store_16bit( _environment, "CLIPY1", 0 );
580 cpu_store_16bit( _environment, "CLIPY2", 95 );
581 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 3072 );
582 cpu_store_8bit( _environment, "CURRENTSL", 128 / 4 );
583 break;
584 // The 128 x 192 Graphics mode generates a display matrix 128 elements
585 // wide by 192 elements high. Each element may be either ON or OFF,
586 // but the ON elements may be one of two colors selected with color
587 // set select pin. A 3K x 8 display memory is required. Each pixel
588 // equals two dot-clocks by one scan line.
589 case BITMAP_MODE_RESOLUTION3: // Resolution Graphics 3 128 × 192 1 + Black 3072
590 _environment->screenWidth = 128;
591 _environment->screenHeight = 192;
592 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
593 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
594 _environment->screenColors = 2;
595 // Full graphic 3-R 1 1 0 1 1 0 1 128x192x2 $C00(3072)
597 VDG_GRAPH;
601 GM2_SET;
602 GM1_CLR;
603 GM0_SET;
604 cpu_store_16bit( _environment, "CLIPX1", 0 );
605 cpu_store_16bit( _environment, "CLIPX2", 127 );
606 cpu_store_16bit( _environment, "CLIPY1", 0 );
607 cpu_store_16bit( _environment, "CLIPY2", 191 );
608 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 3072 );
609 cpu_store_8bit( _environment, "CURRENTSL", 128 / 8 );
610 break;
611 // The 128 x 192 Color Graphics mode generates a display 128 elements
612 // wide by 192 elements high. Each element may be one of four colors.
613 // A 6K x 8 display memory is required. Each pixel equals two dot-clocks
614 // by one scan line.
615 case BITMAP_MODE_COLOR6: // Color Graphics 6 128 × 192 4 6144
616 _environment->screenWidth = 128;
617 _environment->screenHeight = 192;
618 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
619 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
620 _environment->screenColors = 4;
621 // Full graphic 6-C 1 1 1 0 1 1 0 128x192x4 $1800(6144)
623 VDG_GRAPH;
627 GM2_SET;
628 GM1_SET;
629 GM0_CLR;
630 cpu_store_16bit( _environment, "CLIPX1", 0 );
631 cpu_store_16bit( _environment, "CLIPX2", 127 );
632 cpu_store_16bit( _environment, "CLIPY1", 0 );
633 cpu_store_16bit( _environment, "CLIPY2", 191 );
634 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 6144 );
635 cpu_store_8bit( _environment, "CURRENTSL", 128 / 4 );
636 break;
637 // The 256 x 192 Graphics mode generates a display 256 elements wide by
638 // 192 elements high. Each element may be either ON or OFF, but the ON
639 // element may be one of two colors selected with the color set select pin.
640 // A 6K x 8 display memory is required. Each pixel equals one
641 // dot-clock by one scan line.
642 case BITMAP_MODE_RESOLUTION6: // Resolution Graphics 6 256 × 192 1 + Black 6144 break;
643 _environment->screenWidth = 256;
644 _environment->screenHeight = 192;
645 _environment->screenTilesWidth = _environment->screenWidth/_environment->fontWidth;
646 _environment->screenTilesHeight = _environment->screenHeight/_environment->fontHeight;
647 _environment->screenColors = 2;
648 // Full graphic 6-R 1 1 1 1 1 1 0 256x192x2 $1800(6144)
650 VDG_GRAPH;
654 GM2_SET;
655 GM1_SET;
656 GM0_SET;
657 cpu_store_16bit( _environment, "CLIPX1", 0 );
658 cpu_store_16bit( _environment, "CLIPX2", 255 );
659 cpu_store_16bit( _environment, "CLIPY1", 0 );
660 cpu_store_16bit( _environment, "CLIPY2", 191 );
661 cpu_store_16bit( _environment, "CURRENTFRAMESIZE", 6144 );
662 cpu_store_8bit( _environment, "CURRENTSL", 256 / 8 );
663 break;
664 default:
665 CRITICAL_SCREEN_UNSUPPORTED( _screen_mode->id );
666 }
667
668 _environment->consoleTilesWidth = _environment->screenTilesWidth;
669 _environment->consoleTilesHeight = _environment->screenTilesHeight;
670
671 cpu_store_16bit( _environment, "ORIGINX", 0 );
672 cpu_store_16bit( _environment, "ORIGINY", 0 );
673 cpu_store_16bit( _environment, "CURRENTWIDTH", _environment->screenWidth );
674 cpu_store_16bit( _environment, "CURRENTHEIGHT", _environment->screenHeight );
675 cpu_move_16bit( _environment, "CURRENTWIDTH", "RESOLUTIONX" );
676 cpu_move_16bit( _environment, "CURRENTHEIGHT", "RESOLUTIONY" );
677 cpu_store_8bit( _environment, "CURRENTTILES", _environment->screenTiles );
678 cpu_store_8bit( _environment, "CURRENTTILESWIDTH", _environment->screenTilesWidth );
679 cpu_store_8bit( _environment, "CURRENTTILESHEIGHT", _environment->screenTilesHeight );
680
681 console_init( _environment );
682
683 console_calculate( _environment );
684
685 console_calculate_vars( _environment );
686
687 if (_environment->vestigialConfig.clsImplicit ) {
688 c6847b_cls( _environment );
689 }
690
691}
692
693void c6847b_bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
694
695 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 1, _width, _height, _colors, 8, 8 );
696
697 if ( mode ) {
698
699 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
700 cpu_store_8bit( _environment, "CURRENTTILEMODE", 0 );
701
702 _environment->currentMode = mode->id;
703 _environment->currentTileMode = 0;
704
705 c6847b_screen_mode_enable( _environment, mode );
706
707 } else {
709 }
710
711}
712
713void c6847b_bitmap_disable( Environment * _environment ) {
714
715}
716
717void c6847b_tilemap_enable( Environment * _environment, int _width, int _height, int _colors, int _tile_width, int _tile_height ) {
718
719 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 0, _width, _height, _colors, _tile_width, _tile_height );
720
721 if ( mode ) {
722
723 _environment->currentMode = mode->id;
724 _environment->currentTileMode = 1;
725
726 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
727 cpu_store_8bit( _environment, "CURRENTTILEMODE", 1 );
728
729 c6847b_screen_mode_enable( _environment, mode );
730
731
732 } else {
734 }
735
736}
737
738void c6847b_bitmap_at( Environment * _environment, char * _address ) {
739
740 outline1("LDD %s", _address);
741 outline0("JSR C6847bVIDEOSTARTATB" );
742
743}
744
745void c6847b_colormap_at( Environment * _environment, char * _address ) {
746
747}
748
749void c6847b_textmap_at( Environment * _environment, char * _address ) {
750
751 outline1("LDD %s", _address);
752 outline0("JSR C6847bVIDEOSTARTATT" );
753
754}
755
756void c6847b_pset_int( Environment * _environment, int _x, int _y, int *_c ) {
757
758 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm );
759 deploy_preferred( plot, src_hw_6847b_plot_asm );
760
761 outline1("LDX %4.4x", (_x & 0xffff ) );
762 outline0("STX <PLOTX");
763 outline1("LDD %4.4x", ( _y & 0xffff ) );
764 outline0("STD <PLOTY");
765 if ( _c ) {
766 outline1("LDA %2.2x", ( *_c & 0Xff ) );
767 } else {
768 Variable * c = variable_retrieve( _environment, "PEN" );
769 outline1("LDA %s", c->realName );
770 }
771 outline0("STA <PLOTCPE");
772 outline0("LDA #1");
773 outline0("STA <PLOTM");
774 outline0("JSR PLOT");
775
776
777}
778
779void c6847b_pset_vars( Environment * _environment, char *_x, char *_y, char * _c ) {
780
781 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
782 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
783 Variable * c;
784
785 if ( _c ) {
786 c = variable_retrieve_or_define( _environment, _c, VT_COLOR, 0 );
787 } else {
788 c = variable_retrieve( _environment, "PEN" );
789 }
790
791 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm );
792 deploy_preferred( plot, src_hw_6847b_plot_asm );
793
794 outline1("LDX %s", x->realName );
795 outline0("STX <PLOTX");
796 outline1("LDD %s", y->realName );
797 outline0("STD <PLOTY");
798 outline1("LDA %s", c->realName );
799 outline0("STA <PLOTCPE");
800 outline0("LDA #1");
801 outline0("STA <PLOTM");
802 outline0("JSR PLOT");
803
804}
805
806void c6847b_pget_color_vars( Environment * _environment, char *_x, char *_y, char * _result ) {
807
808 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
809 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
810 Variable * result = variable_retrieve_or_define( _environment, _result, VT_BYTE, 0 );
811
812 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm );
813 deploy_preferred( plot, src_hw_6847b_plot_asm );
814
815 outline1("LDD %s", x->realName );
816 outline0("STD <PLOTX");
817 outline1("LDD %s", y->realName );
818 outline0("STD <PLOTY");
819 outline0("LDA #3");
820 outline0("STA <PLOTM");
821 outline0("JSR PLOT");
822 outline0("LDA <PLOTM");
823 outline1("STA %s", result->realName );
824
825}
826
827void c6847b_screen_on( Environment * _environment ) {
828
829}
830
831void c6847b_screen_off( Environment * _environment ) {
832
833}
834
835void c6847b_screen_rows( Environment * _environment, char * _rows ) {
836
837}
838
839void c6847b_screen_columns( Environment * _environment, char * _columns ) {
840
841}
842
843void c6847b_sprite_data_from( Environment * _environment, char * _sprite, char * _address ) {
844
845}
846
847void c6847b_sprite_data_set( Environment * _environment, char * _sprite, char * _address ) {
848
849}
850
851void c6847b_sprite_enable( Environment * _environment, char * _sprite ) {
852
853}
854
855void c6847b_sprite_disable( Environment * _environment, char * _sprite ) {
856
857}
858
859void c6847b_sprite_at( Environment * _environment, char * _sprite, char * _x, char * _y ) {
860
861}
862
863void c6847b_sprite_priority( Environment * _environment, char * _sprite, char * _priority ) {
864
865}
866
867void c6847b_sprite_expand_vertical( Environment * _environment, char * _sprite ) {
868
869}
870
871void c6847b_sprite_expand_horizontal( Environment * _environment, char * _sprite ) {
872
873}
874
875void c6847b_sprite_compress_vertical( Environment * _environment, char * _sprite ) {
876
877}
878
879void c6847b_sprite_compress_horizontal( Environment * _environment, char * _sprite ) {
880
881}
882
883void c6847b_sprite_multicolor( Environment * _environment, char * _sprite ) {
884
885}
886
887void c6847b_sprite_monocolor( Environment * _environment, char * _sprite ) {
888
889}
890
891void c6847b_sprite_color( Environment * _environment, char * _sprite, char * _color ) {
892
893}
894
895void c6847b_tiles_at( Environment * _environment, char * _address ) {
896
897}
898
899void c6847b_vertical_scroll( Environment * _environment, char * _displacement ) {
900
901}
902
903void c6847b_horizontal_scroll( Environment * _environment, char * _displacement ) {
904
905}
906
907void c6847b_get_width( Environment * _environment, char *_result ) {
908
909 outline0("LDX CURRENTWIDTH" );
910 outline1("STX %s", _result );
911
912}
913
914void c6847b_tiles_get( Environment * _environment, char *_result ) {
915
916 outline0("LDA CURRENTTILES" );
917 outline1("STA %s", _result );
918
919}
920
921void c6847b_get_height( Environment * _environment, char *_result ) {
922
923 outline0("LDX CURRENTHEIGHT" );
924 outline1("STX %s", _result );
925
926}
927
928void c6847b_cls( Environment * _environment ) {
929
930 if ( _environment->currentMode < 7 ) {
931 deploy( clsText, src_hw_6847b_cls_text_asm );
932 outline0("JSR CLST");
933 } else {
934 deploy( clsGraphic, src_hw_6847b_cls_graphic_asm );
935 outline0("JSR CLSG");
936 }
937
938}
939
940void c6847b_cls_box( Environment * _environment, char * _x1, char * _y1, char * _w, char * _h ) {
941
942 if ( _environment->currentMode < 7 ) {
943
944 } else {
945 deploy( clsBox, src_hw_6847b_cls_box_asm );
946 outline1("LDD %s", _x1 );
947 outline0("STD <IMAGEX" );
948 outline1("LDD %s", _y1 );
949 outline0("STD <IMAGEY" );
950 outline1("LDA %s", _w );
951 outline0("STA <IMAGEW" );
952 outline1("LDA %s", _h );
953 outline0("STA <IMAGEH" );
954 outline0("JSR CLSBOX");
955 }
956
957}
958
959void c6847b_scroll_text( Environment * _environment, int _direction, int _overlap ) {
960
961 if ( _environment->currentMode < 7 ) {
962 deploy_preferred( vScrollText, src_hw_6847b_vscroll_text_asm );
963 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
964 outline0("STA <DIRECTION" );
965 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
966 outline0("STA <PORT" );
967 outline0("JSR VSCROLLT");
968 } else {
969 deploy_preferred( vScroll, src_hw_6847b_vscroll_graphic_asm );
970 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
971 outline0("STA <DIRECTION" );
972 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
973 outline0("STA <PORT" );
974 outline0("JSR VSCROLLG");
975 }
976
977}
978
979void c6847b_text( Environment * _environment, char * _text, char * _text_size, int _raw ) {
980
981 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm);
982 deploy( textEncodedAt, src_hw_6847b_text_at_asm );
983
984 outline1("LDY %s", _text);
985 outline0("STY <TEXTPTR" );
986 outline1("LDA %s", _text_size);
987 outline0("STA <TEXTSIZE" );
988
989 if ( _raw ) {
990 if ( _environment->currentMode < 7 ) {
991 deploy( clsText, src_hw_6847b_cls_text_asm );
992 deploy_preferred( vScrollText, src_hw_6847b_vscroll_text_asm );
993 deploy( textEncodedAtTextRaw, src_hw_6847b_text_at_text_raw_asm );
994 outline0("JSR TEXTATTILEMODERAW");
995 } else {
996 deploy( clsGraphic, src_hw_6847b_cls_graphic_asm );
997 deploy( vScroll, src_hw_6847b_vscroll_graphic_asm );
998 deploy( textEncodedAtGraphicRaw, src_hw_6847b_text_at_graphic_raw_asm );
999 outline0("JSR TEXTATBITMAPMODERAW");
1000 }
1001 } else {
1002 if ( _environment->currentMode < 7 ) {
1003 deploy( clsText, src_hw_6847b_cls_text_asm );
1004 deploy_preferred( vScrollText, src_hw_6847b_vscroll_text_asm );
1005 deploy( textEncodedAtText, src_hw_6847b_text_at_text_asm );
1006 outline0("JSR TEXTATTILEMODE");
1007 } else {
1008 deploy( clsGraphic, src_hw_6847b_cls_graphic_asm );
1009 deploy( vScroll, src_hw_6847b_vscroll_graphic_asm );
1010 deploy( textEncodedAtGraphic, src_hw_6847b_text_at_graphic_asm );
1011 outline0("JSR TEXTATBITMAPMODE");
1012 }
1013 }
1014
1015}
1016
1017void c6847b_initialization( Environment * _environment ) {
1018
1019 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm );
1020 deploy( c6847bstartup, src_hw_6847b_startup_asm );
1021
1022 variable_import( _environment, "CURRENTMODE", VT_BYTE, 0 );
1023 variable_global( _environment, "CURRENTMODE" );
1024 variable_import( _environment, "CURRENTTILEMODE", VT_BYTE, 1 );
1025 variable_global( _environment, "CURRENTTILEMODE" );
1026
1027 variable_import( _environment, "CURRENTWIDTH", VT_POSITION, 256 );
1028 variable_global( _environment, "CURRENTWIDTH" );
1029 variable_import( _environment, "CURRENTHEIGHT", VT_POSITION, 128 );
1030 variable_global( _environment, "CURRENTHEIGHT" );
1031 variable_import( _environment, "CURRENTTILESWIDTH", VT_SBYTE, 32 );
1032 variable_global( _environment, "CURRENTTILESWIDTH" );
1033 variable_import( _environment, "CURRENTTILESHEIGHT", VT_SBYTE, 16 );
1034 variable_global( _environment, "CURRENTTILESHEIGHT" );
1035 variable_import( _environment, "CURRENTTILES", VT_BYTE, 255 );
1036 variable_global( _environment, "CURRENTTILES" );
1037 variable_import( _environment, "FONTWIDTH", VT_BYTE, 8 );
1038 variable_global( _environment, "FONTWIDTH" );
1039 variable_import( _environment, "FONTHEIGHT", VT_BYTE, 8 );
1040 variable_global( _environment, "FONTHEIGHT" );
1041
1042 SCREEN_MODE_DEFINE( TILEMAP_MODE_INTERNAL, 0, 32, 16, 2, 8, 8, "Alphanumeric Internal");
1043 SCREEN_MODE_DEFINE( TILEMAP_MODE_EXTERNAL, 0, 32, 16, 2, 8, 8, "Alphanumeric External");
1044 SCREEN_MODE_DEFINE( TILEMAP_MODE_SEMIGRAPHICS4, 0, 64, 32, 8, 8, 8, "Semigraphics 4" );
1045 SCREEN_MODE_DEFINE( TILEMAP_MODE_SEMIGRAPHICS6, 0, 64, 48, 4, 8, 8, "Semigraphics 6" );
1046
1047 SCREEN_MODE_DEFINE( BITMAP_MODE_COLOR6, 1, 128, 192, 4, 8, 8, "Color Graphics 6" );
1048 SCREEN_MODE_DEFINE( BITMAP_MODE_RESOLUTION6, 1, 256, 192, 2, 8, 8, "Resolution Graphics 6" );
1049 SCREEN_MODE_DEFINE( BITMAP_MODE_COLOR3, 1, 128, 96, 4, 8, 8, "Color Graphics 3" );
1050 SCREEN_MODE_DEFINE( BITMAP_MODE_RESOLUTION3, 1, 128, 192, 2, 8, 8, "Resolution Graphics 3" );
1051 SCREEN_MODE_DEFINE( BITMAP_MODE_COLOR2, 1, 128, 64, 4, 8, 8, "Color Graphics 2" );
1052 SCREEN_MODE_DEFINE( BITMAP_MODE_RESOLUTION2, 1, 128, 96, 2, 8, 8, "Resolution Graphics 2" );
1053 SCREEN_MODE_DEFINE( BITMAP_MODE_COLOR1, 1, 64, 64, 4, 8, 8, "Color Graphics 1" );
1054 SCREEN_MODE_DEFINE( BITMAP_MODE_RESOLUTION1, 1, 128, 64, 2, 8, 8, "Resolution Graphics 1" );
1055
1056 outline0("JSR C6847BSTARTUP");
1057
1058 variable_import( _environment, "XGR", VT_POSITION, 0 );
1059 variable_global( _environment, "XGR" );
1060 variable_import( _environment, "YGR", VT_POSITION, 0 );
1061 variable_global( _environment, "YGR" );
1062 variable_import( _environment, "LINE", VT_WORD, (unsigned short)(0xffff) );
1063 variable_global( _environment, "LINE" );
1064 variable_import( _environment, "TABCOUNT", VT_BYTE, 4 );
1065 variable_global( _environment, "TABCOUNT" );
1066
1067 variable_import( _environment, "PLOTCPE", VT_BYTE, 0 );
1068 variable_global( _environment, "PLOTCPE" );
1069
1070 variable_import( _environment, "CLIPX1", VT_POSITION, 0 );
1071 variable_global( _environment, "CLIPX1" );
1072 variable_import( _environment, "CLIPX2", VT_POSITION, 255 );
1073 variable_global( _environment, "CLIPX2" );
1074 variable_import( _environment, "CLIPY1", VT_POSITION, 0 );
1075 variable_global( _environment, "CLIPY1" );
1076 variable_import( _environment, "CLIPY2", VT_POSITION, 127 );
1077 variable_global( _environment, "CLIPY2" );
1078
1079 variable_import( _environment, "ORIGINX", VT_POSITION, 0 );
1080 variable_global( _environment, "ORIGINX" );
1081 variable_import( _environment, "ORIGINY", VT_POSITION, 0 );
1082 variable_global( _environment, "ORIGINY" );
1083 variable_import( _environment, "RESOLUTIONX", VT_POSITION, 0 );
1084 variable_global( _environment, "RESOLUTIONX" );
1085 variable_import( _environment, "RESOLUTIONY", VT_POSITION, 0 );
1086 variable_global( _environment, "RESOLUTIONY" );
1087
1088 _environment->fontConfig.schema = FONT_SCHEMA_ASCII;
1089
1090 font_descriptors_init( _environment, 0 );
1091
1092 _environment->fontWidth = 8;
1093 _environment->fontHeight = 8;
1094 _environment->screenTilesWidth = 32;
1095 _environment->screenTilesHeight = 16;
1096 _environment->consoleTilesWidth = 32;
1097 _environment->consoleTilesHeight = 16;
1098 _environment->screenTiles = 128;
1099 _environment->screenWidth = _environment->screenTilesWidth*_environment->fontWidth;
1100 _environment->screenHeight = _environment->screenTilesHeight*_environment->fontHeight;
1101 _environment->screenShades = 4;
1102 _environment->screenColors = 4;
1103
1104 console_init( _environment );
1105
1106 if ( _environment->vestigialConfig.clsImplicit ) {
1107 c6847b_cls( _environment );
1108 }
1109
1110}
1111
1112void c6847b_finalization( Environment * _environment ) {
1113
1114 if (_environment->vestigialConfig.clsImplicit ) {
1115 deploy( clsText, src_hw_6847b_cls_text_asm );
1116 }
1117
1118 CopperList * copperList = _environment->copperList;
1119 if ( copperList ) {
1120 while(copperList) {
1121 outhead1("COPPERACTIVATE%s", copperList->name ? copperList->name : "" );
1122 outline0("RTS");
1123 copperList = copperList->next;
1124 }
1125 }
1126
1127}
1128
1129void c6847b_hscroll_line( Environment * _environment, int _direction, int _overlap ) {
1130
1131 deploy_preferred( textHScroll, src_hw_6847b_hscroll_text_asm );
1132
1133 Variable * y = variable_retrieve( _environment, "YCURSYS" );
1134 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
1135 outline0("STA <DIRECTION" );
1136 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
1137 outline0("STA <PORT" );
1138 outline1("LDA %s", y->realName );
1139 outline0("STA <CLINEY");
1140
1141 outline0("JSR HSCROLLLT");
1142
1143}
1144
1145void c6847b_hscroll_screen( Environment * _environment, int _direction, int _overlap ) {
1146
1147 deploy_preferred( textHScroll, src_hw_6847b_hscroll_text_asm );
1148
1149 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
1150 outline0("STA <DIRECTION" );
1151 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
1152 outline0("STA <PORT" );
1153
1154 outline0("JSR HSCROLLST");
1155
1156}
1157
1158void c6847b_back( Environment * _environment ) {
1159
1160}
1161
1162void c6847b_cline( Environment * _environment, char * _characters ) {
1163
1164 Variable * x = variable_retrieve( _environment, "XCURSYS" );
1165 Variable * y = variable_retrieve( _environment, "YCURSYS" );
1166
1167 if ( _characters ) {
1168 outline1("LDD %s", _characters);
1169 } else {
1170 outline0("LDD #0");
1171 }
1172 outline0("STB <CHARACTERS");
1173 outline1("LDA %s", x->realName );
1174 outline0("STA <CLINEX" );
1175 outline1("LDA %s", y->realName );
1176 outline0("STA <CLINEY");
1177
1178 if ( _environment->currentMode < 7 ) {
1179 deploy( textCline, src_hw_6847b_cline_text_asm );
1180 outline0("JSR CLINE");
1181 } else {
1182 deploy( textClineGraphic, src_hw_6847b_cline_graphic_asm );
1183 outline0("JSR CLINEG");
1184 }
1185
1186}
1187
1188int c6847b_image_size( Environment * _environment, int _width, int _height, int _mode, int _transparent ) {
1189
1190 switch( _mode ) {
1191 case TILEMAP_MODE_INTERNAL: // Alphanumeric Internal 32 × 16 2 512
1192 case TILEMAP_MODE_EXTERNAL: // Alphanumeric External 32 × 16 2 512
1193 case TILEMAP_MODE_SEMIGRAPHICS4: // Semigraphics 4 64 × 32 8 512
1194 case TILEMAP_MODE_SEMIGRAPHICS6: // Semigraphics 6 64 × 48 4 512
1195 case TILEMAP_MODE_SEMIGRAPHICS8: // Semigraphics 8 64 × 64 2 512
1196 case TILEMAP_MODE_SEMIGRAPHICS12: // Semigraphics 6 64 × 96 1 3072
1197 case TILEMAP_MODE_SEMIGRAPHICS24: // Semigraphics 6 64 × 96 1 3072
1198 break;
1199 case BITMAP_MODE_COLOR1: // Color Graphics 1 64 × 64 4 1024
1200 case BITMAP_MODE_COLOR2: // Color Graphics 2 128 × 64 4 2048
1201 case BITMAP_MODE_COLOR3: // Color Graphics 3 128 × 96 4 3072
1202 case BITMAP_MODE_COLOR6: // Color Graphics 6 128 × 192 4 6144
1203 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1204 return 3 + ( ( _width >> 2 ) * _height );
1205 } else {
1206 return 2 + ( ( _width >> 2 ) * _height );
1207 }
1208 case BITMAP_MODE_RESOLUTION1: // Resolution Graphics 1 128 × 64 1 + Black 1024
1209 case BITMAP_MODE_RESOLUTION2: // Resolution Graphics 2 128 × 96 1 + Black 1536
1210 case BITMAP_MODE_RESOLUTION3: // Resolution Graphics 3 128 × 192 1 + Black 3072
1211 case BITMAP_MODE_RESOLUTION6: // Resolution Graphics 6 256 × 192 1 + Black 6144 break;
1212 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1213 if ( _transparent ) {
1214 return 3 + 2*( ( _width >> 3 ) * _height );
1215 } else {
1216 return 3 + ( ( _width >> 3 ) * _height );
1217 }
1218 } else {
1219 return 2 + ( ( _width >> 3 ) * _height );
1220 }
1221
1222 }
1223
1224 return 0;
1225
1226}
1227
1228static int calculate_images_size( Environment * _environment, int _frames, int _width, int _height, int _mode, int _transparent ) {
1229
1230 switch( _mode ) {
1231 case TILEMAP_MODE_INTERNAL: // Alphanumeric Internal 32 × 16 2 512
1232 case TILEMAP_MODE_EXTERNAL: // Alphanumeric External 32 × 16 2 512
1233 case TILEMAP_MODE_SEMIGRAPHICS4: // Semigraphics 4 64 × 32 8 512
1234 case TILEMAP_MODE_SEMIGRAPHICS6: // Semigraphics 6 64 × 48 4 512
1235 case TILEMAP_MODE_SEMIGRAPHICS8: // Semigraphics 8 64 × 64 2 512
1236 case TILEMAP_MODE_SEMIGRAPHICS12: // Semigraphics 6 64 × 96 1 3072
1237 case TILEMAP_MODE_SEMIGRAPHICS24: // Semigraphics 6 64 × 96 1 3072
1238 break;
1239 case BITMAP_MODE_COLOR1: // Color Graphics 1 64 × 64 4 1024
1240 case BITMAP_MODE_COLOR2: // Color Graphics 2 128 × 64 4 2048
1241 case BITMAP_MODE_COLOR3: // Color Graphics 3 128 × 96 4 3072
1242 case BITMAP_MODE_COLOR6: // Color Graphics 6 128 × 192 4 6144
1243 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1244 return 3 + ( 3 + ( ( _width >> 2 ) * _height ) ) * _frames;
1245 } else {
1246 return 3 + ( 2 + ( ( _width >> 2 ) * _height ) ) * _frames;
1247 }
1248 case BITMAP_MODE_RESOLUTION1: // Resolution Graphics 1 128 × 64 1 + Black 1024
1249 case BITMAP_MODE_RESOLUTION2: // Resolution Graphics 2 128 × 96 1 + Black 1536
1250 case BITMAP_MODE_RESOLUTION3: // Resolution Graphics 3 128 × 192 1 + Black 3072
1251 case BITMAP_MODE_RESOLUTION6: // Resolution Graphics 6 256 × 192 1 + Black 6144 break;
1252 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1253 if ( _transparent ) {
1254 return 3 + ( 3 + 2* ( ( _width >> 3 ) * _height ) ) * _frames;
1255 } else {
1256 return 3 + ( 3 + ( ( _width >> 3 ) * _height ) ) * _frames;
1257 }
1258 } else {
1259 return 3 + ( 2 + ( ( _width >> 3 ) * _height ) ) * _frames;
1260 }
1261
1262 }
1263
1264 return 0;
1265
1266}
1267
1268static int calculate_sequence_size( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode, int _transparent ) {
1269
1270 switch( _mode ) {
1271 case TILEMAP_MODE_INTERNAL: // Alphanumeric Internal 32 × 16 2 512
1272 case TILEMAP_MODE_EXTERNAL: // Alphanumeric External 32 × 16 2 512
1273 case TILEMAP_MODE_SEMIGRAPHICS4: // Semigraphics 4 64 × 32 8 512
1274 case TILEMAP_MODE_SEMIGRAPHICS6: // Semigraphics 6 64 × 48 4 512
1275 case TILEMAP_MODE_SEMIGRAPHICS8: // Semigraphics 8 64 × 64 2 512
1276 case TILEMAP_MODE_SEMIGRAPHICS12: // Semigraphics 6 64 × 96 1 3072
1277 case TILEMAP_MODE_SEMIGRAPHICS24: // Semigraphics 6 64 × 96 1 3072
1278 break;
1279 case BITMAP_MODE_COLOR1: // Color Graphics 1 64 × 64 4 1024
1280 case BITMAP_MODE_COLOR2: // Color Graphics 2 128 × 64 4 2048
1281 case BITMAP_MODE_COLOR3: // Color Graphics 3 128 × 96 4 3072
1282 case BITMAP_MODE_COLOR6: // Color Graphics 6 128 × 192 4 6144
1283 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1284 return 3 + ( ( 3 + ( ( _width >> 2 ) * _height ) ) * _frames ) * _sequences;
1285 } else {
1286 return 3 + ( ( 2 + ( ( _width >> 2 ) * _height ) ) * _frames ) * _sequences;
1287 }
1288 case BITMAP_MODE_RESOLUTION1: // Resolution Graphics 1 128 × 64 1 + Black 1024
1289 case BITMAP_MODE_RESOLUTION2: // Resolution Graphics 2 128 × 96 1 + Black 1536
1290 case BITMAP_MODE_RESOLUTION3: // Resolution Graphics 3 128 × 192 1 + Black 3072
1291 case BITMAP_MODE_RESOLUTION6: // Resolution Graphics 6 256 × 192 1 + Black 6144 break;
1292 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1293 if ( _transparent ) {
1294 return 3 + ( ( 3 + 2 * ( ( _width >> 3 ) * _height ) ) * _frames ) * _sequences;
1295 } else {
1296 return 3 + ( ( 3 + ( ( _width >> 3 ) * _height ) ) * _frames ) * _sequences;
1297 }
1298 } else {
1299 return 3 + ( ( 2 + ( ( _width >> 3 ) * _height ) ) * _frames ) * _sequences;
1300 }
1301
1302 }
1303
1304 return 0;
1305
1306}
1307
1308static Variable * c6847b_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 ) {
1309
1310 // ignored on bitmap mode
1311 (void)!_transparent_color;
1312
1313 RGBi white = { 0xff, 0xff, 0xff, 0xff };
1314 RGBi black = { 0x00, 0x00, 0x00, 0xff };
1315
1316 // ignored on bitmap mode
1317 (void)!_transparent_color;
1318
1319 image_converter_asserts_free_height( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8 );
1320
1321 if ( _environment->freeImageWidth ) {
1322 if ( _width % 8 ) {
1323 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1324 }
1325 if ( _frame_width % 8 ) {
1326 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1327 }
1328 }
1329
1330 RGBi * palette = malloc_palette( MAX_PALETTE );
1331
1332 int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
1333
1334 if (paletteColorCount > 3) {
1335 CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
1336 }
1337
1338 if ( _transparent_color == 0 ) {
1339 for( int i=0; i<3; ++i ) {
1340 if ( palette[i].alpha < 255 ) {
1341 _transparent_color = 0x0f0000;
1342 break;
1343 }
1344 }
1345 }
1346
1347 int i, j, k;
1348
1349 SYSTEM_PALETTE = &SYSTEM_PALETTE_ALTERNATE[_environment->paletteSelected][0];
1350
1351 commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE_ALTERNATE[0]) / sizeof(RGBi) );
1352 commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
1353 lastUsedSlotInCommonPalette = paletteColorCount;
1354 adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
1355
1356 adilinepalette( "CPMS:%d", (int)(sizeof(SYSTEM_PALETTE_ALTERNATE[0]) / sizeof(RGBi)), SYSTEM_PALETTE );
1357
1358 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
1360 memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
1361
1362 int bufferSize = c6847b_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_RESOLUTION1, (_transparent_color & 0x0f0000 ) ? 1 : 0 );
1363 // printf("bufferSize = %d\n", bufferSize );
1364
1365 adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_RESOLUTION1 );
1366
1367 char * buffer = malloc ( bufferSize );
1368 memset( buffer, 0, bufferSize );
1369
1370 // Position of the pixel in the original image
1371 int image_x, image_y;
1372
1373 // Position of the pixel, in terms of tiles
1374 int tile_x, tile_y;
1375
1376 // Position of the pixel, in terms of offset and bitmask
1377 int offset, bitmask;
1378
1379 // Color of the pixel to convert
1380 RGBi rgb;
1381
1382 *(buffer) = _frame_width;
1383 *(buffer+1) = _frame_height;
1384 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1385 *(buffer+2) = (_transparent_color & 0x0f0000) ? 0x01 : 0x00;
1386 }
1387
1388 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1389
1390 adilinebeginbitmap("BMD");
1391
1392 int colorIndex = 0;
1393
1394 // Loop for all the source surface.
1395 for (image_y = 0; image_y < _frame_height; ++image_y) {
1396 for (image_x = 0; image_x < _frame_width; ++image_x) {
1397
1398 // Take the color of the pixel
1399 rgb.red = *_source;
1400 rgb.green = *(_source + 1);
1401 rgb.blue = *(_source + 2);
1402 if ( _depth > 3 ) {
1403 rgb.alpha = *(_source + 3);
1404 } else {
1405 rgb.alpha = 255;
1406 }
1407 if ( rgb.alpha == 0 ) {
1408 rgb.red = 0;
1409 rgb.green = 0;
1410 rgb.blue = 0;
1411 }
1412
1413 if ( rgbi_equals_rgba( &black, &rgb ) || rgb.alpha < 255 ) {
1414 colorIndex = 0;
1415 } else if ( rgbi_equals_rgba( &white, &rgb ) ) {
1416 colorIndex = 1;
1417 } else {
1418 int minDistance = 9999;
1419 for( int i=0; i<2; ++i ) {
1420 int distance = rgbi_distance(&commonPalette[i], &rgb );
1421 if ( distance < minDistance ) {
1422 minDistance = distance;
1423 colorIndex = i;
1424 }
1425 }
1426 }
1427
1428
1429 // printf("%d", i );
1430
1431 // Calculate the offset starting from the tile surface area
1432 // and the bit to set.
1433 offset = ( image_y * ( _frame_width >> 3 ) ) + ( image_x >> 3 );
1434 bitmask = 1 << ( 7 - (image_x & 0x7) );
1435
1436 if ( colorIndex > 0) {
1437 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1438 *( buffer + offset + 3) |= bitmask;
1439 } else {
1440 *( buffer + offset + 2) |= bitmask;
1441 }
1442 // printf("*");
1443 } else {
1444 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1445 *( buffer + offset + 3) &= ~bitmask;
1446 } else {
1447 *( buffer + offset + 2) &= ~bitmask;
1448 }
1449 // printf(" ");
1450 }
1451
1452 if ( _transparent_color & 0x0f0000 ) {
1453 if ( rgb.alpha == 0 ) {
1454 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1455 *( buffer + ( _frame_height * ( _frame_width >> 3 ) ) + offset + 3) |= bitmask;
1456 } else {
1457 *( buffer + ( _frame_height * ( _frame_width >> 3 ) ) + offset + 2) |= bitmask;
1458 }
1459 // printf("*");
1460 } else {
1461 if ( ! _environment->vestigialConfig.rchack_acme_1172 ) {
1462 *( buffer + ( _frame_height * ( _frame_width >> 3 ) ) + offset + 3) &= ~bitmask;
1463 } else {
1464 *( buffer + ( _frame_height * ( _frame_width >> 3 ) ) + offset + 2) &= ~bitmask;
1465 }
1466 // printf(" ");
1467 }
1468 }
1469
1470 adilinepixel(colorIndex);
1471
1472 _source += _depth;
1473
1474 }
1475
1476 _source += ( _width - _frame_width ) * _depth;
1477
1478 // printf("\n" );
1479
1480 }
1481
1483
1484 // printf("----\n");
1485
1486 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1487
1488 // printf("----\n");
1489
1490 return result;
1491
1492}
1493
1494static Variable * c6847b_image_converter_multicolor_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 ) {
1495
1496 RGBi white = { 0xff, 0xff, 0xff, 0xff };
1497 RGBi black = { 0x00, 0x00, 0x00, 0x00 };
1498
1499 // ignored on bitmap mode
1500 (void)!_transparent_color;
1501
1502 image_converter_asserts_free_height( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8 );
1503
1504 if ( _environment->freeImageWidth ) {
1505 if ( _width % 8 ) {
1506 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1507 }
1508 if ( _frame_width % 8 ) {
1509 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1510 }
1511 }
1512
1513 RGBi * palette = malloc_palette( MAX_PALETTE );
1514
1515 int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
1516
1517 if (paletteColorCount > 4) {
1518 CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
1519 }
1520
1521 int i, j, k;
1522
1523 SYSTEM_PALETTE = &SYSTEM_PALETTE_ALTERNATE[_environment->paletteSelected][0];
1524
1525 commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE_ALTERNATE[0]) / sizeof(RGBi) );
1526 commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
1527 lastUsedSlotInCommonPalette = paletteColorCount;
1528 adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
1529
1530 adilinepalette( "CPMS:%d", (int)(sizeof(SYSTEM_PALETTE_ALTERNATE[0]) / sizeof(RGBi)), SYSTEM_PALETTE );
1531
1532 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
1534 memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
1535
1536 int bufferSize = c6847b_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_COLOR1, 0 );
1537
1538 adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_RESOLUTION1 );
1539
1540 char * buffer = malloc ( bufferSize );
1541 memset( buffer, 0, bufferSize );
1542
1543 // Position of the pixel in the original image
1544 int image_x, image_y;
1545
1546 // Position of the pixel, in terms of tiles
1547 int tile_x, tile_y;
1548
1549 // Position of the pixel, in terms of offset and bitmask
1550 int offset, offsetc, bitmask;
1551
1552 // Color of the pixel to convert
1553 RGBi rgb;
1554
1555 *(buffer) = _frame_width;
1556 *(buffer+1) = _frame_height;
1557 *(buffer+2) = 0;
1558
1559 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1560
1561 adilinebeginbitmap("BMD");
1562
1563 // Loop for all the source surface.
1564 for (image_y = 0; image_y < _frame_height; ++image_y) {
1565 for (image_x = 0; image_x < _frame_width; ++image_x) {
1566
1567 // Take the color of the pixel
1568 rgb.red = *_source;
1569 rgb.green = *(_source + 1);
1570 rgb.blue = *(_source + 2);
1571 if ( _depth > 3 ) {
1572 rgb.alpha = *(_source + 3);
1573 } else {
1574 rgb.alpha = 255;
1575 }
1576 if ( rgb.alpha == 0 ) {
1577 rgb.red = 0;
1578 rgb.green = 0;
1579 rgb.blue = 0;
1580 }
1581
1582 offset = ( image_y * ( _frame_width >> 2 ) ) + ( image_x >> 2 );
1583
1584 int colorIndex = 0;
1585
1586 if ( rgb.alpha < 255 ) {
1587 colorIndex = 0;
1588 } else {
1589 int minDistance = 9999;
1590 for( int i=0; i<lastUsedSlotInCommonPalette; ++i ) {
1591 int distance = rgbi_distance(&commonPalette[i], &rgb );
1592 if ( distance < minDistance ) {
1593 minDistance = distance;
1594 colorIndex = commonPalette[i].index;
1595 }
1596 }
1597 }
1598
1599 adilinepixel(colorIndex);
1600
1601 // printf( "%1.1x", colorIndex );
1602
1603 bitmask = colorIndex << (6 - ((image_x & 0x3) * 2));
1604
1605 *(buffer + 3 + offset) |= bitmask;
1606
1607 _source += _depth;
1608
1609 }
1610
1611 _source += ( _width - _frame_width ) * _depth;
1612
1613 // printf("\n" );
1614 }
1615
1617
1618 // for(i=0; i<4; ++i ) {
1619 // printf( "%1.1x = %2.2x\n", i, palette[i].index );
1620 // }
1621
1622 // printf("\n" );
1623 // printf("\n" );
1624
1625 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1626
1627 return result;
1628
1629}
1630
1631Variable * c6847b_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 ) {
1632
1633 switch( _mode ) {
1634 case TILEMAP_MODE_INTERNAL: // Alphanumeric Internal 32 × 16 2 512
1635 case TILEMAP_MODE_EXTERNAL: // Alphanumeric External 32 × 16 2 512
1636 case TILEMAP_MODE_SEMIGRAPHICS4: // Semigraphics 4 64 × 32 8 512
1637 case TILEMAP_MODE_SEMIGRAPHICS6: // Semigraphics 6 64 × 48 4 512
1638 case TILEMAP_MODE_SEMIGRAPHICS8: // Semigraphics 8 64 × 64 2 512
1639 case TILEMAP_MODE_SEMIGRAPHICS12: // Semigraphics 6 64 × 96 1 3072
1640 case TILEMAP_MODE_SEMIGRAPHICS24: // Semigraphics 6 64 × 96 1 3072
1641 break;
1642 case BITMAP_MODE_COLOR1: // Color Graphics 1 64 × 64 4 1024
1643 case BITMAP_MODE_COLOR2: // Color Graphics 2 128 × 64 4 2048
1644 case BITMAP_MODE_COLOR3: // Color Graphics 3 128 × 96 4 3072
1645 case BITMAP_MODE_COLOR6: // Color Graphics 6 128 × 192 4 6144
1646
1647 return c6847b_image_converter_multicolor_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1648
1649 break;
1650
1651 case BITMAP_MODE_RESOLUTION1: // Resolution Graphics 1 128 × 64 1 + Black 1024
1652 case BITMAP_MODE_RESOLUTION2: // Resolution Graphics 2 128 × 96 1 + Black 1536
1653 case BITMAP_MODE_RESOLUTION3: // Resolution Graphics 3 128 × 192 1 + Black 3072
1654 case BITMAP_MODE_RESOLUTION6: // Resolution Graphics 6 256 × 192 1 + Black 6144 break;
1655
1656 return c6847b_image_converter_bitmap_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1657
1658 }
1659
1661
1662 return c6847b_new_image( _environment, 8, 8, BITMAP_MODE_RESOLUTION6 );
1663
1664}
1665
1666static void c6847b_load_image_address_to_register( Environment * _environment, char * _register, Resource * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1667
1668 if ( !_sequence && !_frame ) {
1669 if ( _source->isAddress ) {
1670 outline1("LDY %s", _source->realName );
1671 outline1("STY %s", _register );
1672 } else {
1673 outline1("LDY #%s", _source->realName );
1674 outline1("STY %s", _register );
1675 }
1676 } else {
1677
1678 if ( _source->isAddress ) {
1679 outline1("LDY %s", _source->realName );
1680 } else {
1681 outline1("LDY #%s", _source->realName );
1682 }
1683
1684 if ( _sequence ) {
1685 outline0("LEAY 3,y" );
1686 if ( strlen(_sequence) == 0 ) {
1687 } else {
1688 outline1("LDB %s", _sequence );
1689 outline1("JSR %soffsetsequence", _source->realName );
1690 }
1691 if ( _frame ) {
1692 if ( strlen(_frame) == 0 ) {
1693 } else {
1694 outline1("LDB %s", _frame );
1695 outline1("JSR %soffsetframe", _source->realName );
1696 }
1697 }
1698 } else {
1699 if ( _frame ) {
1700 outline0("LEAY 3,y" );
1701 if ( strlen(_frame) == 0 ) {
1702 } else {
1703 outline1("LDB %s", _frame );
1704 outline1("JSR %soffsetframe", _source->realName );
1705 }
1706 }
1707 }
1708
1709 outline1("STY %s", _register );
1710
1711 }
1712
1713}
1714
1715void c6847b_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 ) {
1716
1717 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm);
1718 deploy( blitimage, src_hw_6847b_blit_image_asm );
1719
1720 if ( _source_count > 2 ) {
1722 }
1723
1725
1726 outhead1("blitimage%s", label);
1727
1728 outline1("LDY #%s", _blit );
1729 outline0("STY BLITIMAGEBLITADDR" );
1730
1731 if ( _source_count > 0 ) {
1732 Resource resource;
1733 resource.realName = strdup( _sources[0] );
1734 resource.isAddress = 0;
1735 resource.type = VT_IMAGE;
1736 c6847b_load_image_address_to_register( _environment, "BLITTMPPTR", &resource, _sequence, _frame, _frame_size, _frame_count );
1737 } else {
1738 outline0( "LDY #0" );
1739 outline0( "STY BLITTMPPTR" );
1740 }
1741
1742 if ( _source_count > 1 ) {
1743 Resource resource;
1744 resource.realName = strdup( _sources[1] );
1745 resource.isAddress = 0;
1746 resource.type = VT_IMAGE;
1747 c6847b_load_image_address_to_register( _environment, "BLITTMPPTR2", &resource, _sequence, _frame, _frame_size, _frame_count );
1748 } else {
1749 outline0( "LDY #0" );
1750 outline0( "STY BLITTMPPTR2" );
1751 }
1752
1753 outline1("LDD %s", _x );
1754 outline0("STD <IMAGEX" );
1755 outline1("LDD %s", _y );
1756 outline0("STD <IMAGEY" );
1757
1758 outline1("LDA #$%2.2x", ( _flags & 0xff ) );
1759 outline0("STA <IMAGEF" );
1760 outline1("LDA #$%2.2x", ( (_flags>>8) & 0xff ) );
1761 outline0("STA <IMAGET" );
1762
1763 outline0("JSR BLITIMAGE");
1764
1765}
1766
1767void c6847b_put_image( Environment * _environment, Resource * _source, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _flags ) {
1768
1769 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm);
1770 deploy( putimage, src_hw_6847b_put_image_asm );
1771
1772 if ( _source->isAddress ) {
1773 outline1("LDY %s", _source->realName );
1774 } else {
1775 outline1("LDY #%s", _source->realName );
1776 }
1777
1778 if ( _frame_size ) {
1779 if ( !_sequence && !_frame ) {
1780 } else {
1781 if ( _sequence ) {
1782 outline0("LEAY 3,y" );
1783 if ( strlen(_sequence) == 0 ) {
1784 } else {
1785 outline1("LDB %s", _sequence );
1786 outline1("JSR %soffsetsequence", _source->realName );
1787 }
1788 if ( _frame ) {
1789 if ( strlen(_frame) == 0 ) {
1790 } else {
1791 outline1("LDB %s", _frame );
1792 outline1("JSR %soffsetframe", _source->realName );
1793 }
1794 }
1795 } else {
1796 if ( _frame ) {
1797 outline0("LEAY 3,y" );
1798 if ( strlen(_frame) == 0 ) {
1799 } else {
1800 outline1("LDB %s", _frame );
1801 outline1("JSR %soffsetframe", _source->realName );
1802 }
1803 }
1804 }
1805
1806 }
1807 }
1808
1809 outline1("LDD %s", _x );
1810 outline0("STD <IMAGEX" );
1811 outline1("LDD %s", _y );
1812 outline0("STD <IMAGEY" );
1813
1814 outline1("LDD %s", _flags );
1815 outline0("STB <IMAGEF" );
1816 outline0("STA <IMAGET" );
1817
1818 outline0("JSR PUTIMAGE");
1819
1820}
1821
1822Variable * c6847b_new_image( Environment * _environment, int _width, int _height, int _mode ) {
1823
1824 int size = c6847b_image_size( _environment, _width, _height, _mode, 0 );
1825
1826 if ( ! size ) {
1828 }
1829
1830 Variable * result = variable_temporary( _environment, VT_IMAGE, "(new image)" );
1831
1832 char * buffer = malloc ( size );
1833 memset( buffer, 0, size );
1834
1835 *(buffer) = _width;
1836 *(buffer+1) = _height;
1837 *(buffer+2) = 0;
1838
1839 result->valueBuffer = buffer;
1840 result->size = size;
1841
1842 return result;
1843
1844}
1845
1846Variable * c6847b_new_images( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
1847
1848 int size = calculate_images_size( _environment, _frames, _width, _height, _mode, 0 );
1849 int frameSize = c6847b_image_size( _environment, _width, _height, _mode, 0 );
1850
1851 if ( ! size ) {
1853 }
1854
1855 Variable * result = variable_temporary( _environment, VT_IMAGES, "(new images)" );
1856
1857 char * buffer = malloc ( size );
1858 memset( buffer, 0, size );
1859
1860 *(buffer) = _frames;
1861 *(buffer+1) = ( _width & 0xff );
1862 *(buffer+2) = ( _width >> 8 ) & 0xff;
1863 for( int i=0; i<_frames; ++i ) {
1864 *(buffer+3+(i*frameSize)) = _width;
1865 *(buffer+3+(i*frameSize)+1) = _height;
1866 }
1867
1868 result->valueBuffer = buffer;
1869 result->frameSize = frameSize;
1870 result->size = size;
1871 result->frameCount = _frames;
1872
1873 return result;
1874
1875}
1876
1877Variable * c6847b_new_sequence( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
1878
1879 int size2 = calculate_sequence_size( _environment, _sequences, _frames, _width, _height, _mode, 0 );
1880 int size = calculate_images_size( _environment, _frames, _width, _height, _mode, 0 );
1881 int frameSize = c6847b_image_size( _environment, _width, _height, _mode, 0 );
1882
1883 if ( ! size ) {
1885 }
1886
1887 Variable * result = variable_temporary( _environment, VT_SEQUENCE, "(new sequence)" );
1888
1889 char * buffer = malloc ( size2 );
1890 memset( buffer, 0, size2 );
1891
1892 *(buffer) = _frames;
1893 *(buffer+1) = _width;
1894 *(buffer+2) = _sequences;
1895 for( int i=0; i<(_frames * _sequences); ++i ) {
1896 *(buffer+3+(i*frameSize)) = _width;
1897 *(buffer+3+(i*frameSize)+1) = _height;
1898 }
1899
1900 result->valueBuffer = buffer;
1901 result->frameSize = frameSize;
1902 result->size = size2;
1903 result->frameCount = _frames;
1904
1905 return result;
1906
1907}
1908
1909void c6847b_get_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _palette ) {
1910
1911 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm);
1912 deploy( getimage, src_hw_6847b_get_image_asm );
1913
1914 outline1("LDY #%s", _image );
1915 if ( _sequence ) {
1916 outline0("LEAY 3,y" );
1917 if ( strlen(_sequence) == 0 ) {
1918 } else {
1919 outline1("LDX #OFFSETS%4.4x", _frame_count * _frame_size );
1920 outline1("LDB %s", _sequence );
1921 outline0("LDA #0" );
1922 outline0("ABX" );
1923 outline0("ABX" );
1924 outline0("LDD ,X" );
1925 outline0("LEAY D, Y" );
1926 }
1927 if ( _frame ) {
1928 if ( strlen(_frame) == 0 ) {
1929 } else {
1930 outline1("LDX #OFFSETS%4.4x", _frame_size );
1931 outline1("LDB %s", _frame );
1932 outline0("LDA #0" );
1933 outline0("ABX" );
1934 outline0("ABX" );
1935 outline0("LDD ,X" );
1936 outline0("LEAY D, Y" );
1937 }
1938 }
1939 } else {
1940 if ( _frame ) {
1941 outline0("LEAY 3,y" );
1942 if ( strlen(_frame) == 0 ) {
1943 } else {
1944 outline1("LDX #OFFSETS%4.4x", _frame_size );
1945 outline1("LDB %s", _frame );
1946 outline0("LDA #0" );
1947 outline0("ABX" );
1948 outline0("ABX" );
1949 outline0("LDD ,X" );
1950 outline0("LEAY D, Y" );
1951 }
1952 }
1953 }
1954
1955 outline1("LDD %s", _x );
1956 outline0("STD <IMAGEX" );
1957 outline1("LDD %s", _y );
1958 outline0("STD <IMAGEY" );
1959 outline1("LDA #$%2.2x", _palette );
1960 outline0("STA <IMAGET");
1961
1962 outline0("JSR GETIMAGE");
1963
1964}
1965
1966void c6847b_scroll( Environment * _environment, int _dx, int _dy ) {
1967
1968}
1969
1970void c6847b_put_tile( Environment * _environment, char * _tile, char * _x, char * _y ) {
1971
1972}
1973
1974void c6847b_tile_at( Environment * _environment, char * _x, char * _y, char * _result ) {
1975
1976}
1977
1978void c6847b_move_tiles( Environment * _environment, char * _tile, char * _x, char * _y ) {
1979
1980}
1981
1982void c6847b_put_tiles( Environment * _environment, char * _tile, char * _x, char * _y, char *_w, char *_h ) {
1983
1984
1985}
1986
1987void c6847b_use_tileset( Environment * _environment, char * _tileset ) {
1988
1989}
1990
1992
1993 Variable * result = variable_temporary( _environment, VT_WORD, "(raster line)" );
1994
1995 variable_store( _environment, result->name, 0 );
1996
1997 return result;
1998
1999}
2000
2001void c6847b_slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _destination ) {
2002
2003}
2004
2005int c6847b_palette_extract( Environment * _environment, char * _data, int _width, int _height, int _depth, int _flags, RGBi * _palette ) {
2006
2007 int paletteColorCount = rgbi_extract_palette(_environment, _data, _width, _height, _depth, _palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
2008
2009 SYSTEM_PALETTE = &SYSTEM_PALETTE_ALTERNATE[_environment->paletteSelected][0];
2010
2011 memcpy( _palette, palette_match( _palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) ), paletteColorCount * sizeof( RGBi ) );
2012
2013 int uniquePaletteCount = 0;
2014
2015 memcpy( _palette, palette_remove_duplicates( _palette, paletteColorCount, &uniquePaletteCount ), paletteColorCount * sizeof( RGBi ) );
2016
2017 return uniquePaletteCount;
2018
2019}
2020
2021void c6847b_calculate_sequence_frame_offset( Environment * _environment, char * _offset, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
2022
2023 outline0("LDY #$0" );
2024 if ( _sequence ) {
2025 outline0("LEAY 3,y" );
2026 if ( strlen(_sequence) == 0 ) {
2027 } else {
2028 outline1("LDX #OFFSETS%4.4x", _frame_count * _frame_size );
2029 outline1("LDB %s", _sequence );
2030 outline0("LDA #0" );
2031 outline0("ABX" );
2032 outline0("ABX" );
2033 outline0("LDD ,X" );
2034 outline0("LEAY D, Y" );
2035 }
2036 if ( _frame ) {
2037 if ( strlen(_frame) == 0 ) {
2038 } else {
2039 outline1("LDX #OFFSETS%4.4x", _frame_size );
2040 outline1("LDB %s", _frame );
2041 outline0("LDA #0" );
2042 outline0("ABX" );
2043 outline0("ABX" );
2044 outline0("LDD ,X" );
2045 outline0("LEAY D, Y" );
2046 }
2047 }
2048 } else {
2049 if ( _frame ) {
2050 outline0("LEAY 3,y" );
2051 if ( strlen(_frame) == 0 ) {
2052 } else {
2053 outline1("LDX #OFFSETS%4.4x", _frame_size );
2054 outline1("LDB %s", _frame );
2055 outline0("LDA #0" );
2056 outline0("ABX" );
2057 outline0("ABX" );
2058 outline0("LDD ,X" );
2059 outline0("LEAY D, Y" );
2060 }
2061 }
2062 }
2063
2064 outline1("STY %s", _offset );
2065
2066}
2067
2068void c6847b_flip_image( Environment * _environment, Resource * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _direction ) {
2069
2070 deploy_preferred( c6847bvars, src_hw_6847b_vars_asm);
2071
2072 if ( strcmp( _direction, "#FLIPIMAGEDIRECTION0001" ) == 0 || strcmp( _direction, "#FLIPIMAGEDIRECTION0003" ) == 0 ) {
2073 c6847b_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
2074 deploy( flipimagex, src_hw_6847b_flip_image_x_asm );
2075 outline0("JSR FLIPIMAGEX");
2076 } else {
2077
2079
2080 c6847b_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
2081 deploy( flipimagex, src_hw_6847b_flip_image_x_asm );
2082 outline1("LDA %s", _direction );
2083 outline1("ANDA #$%2.2x", FLAG_FLIP_X );
2084 outline1("BEQ %s", label );
2085 outline0("JSR FLIPIMAGEX");
2086 outhead1("%s", label );
2087
2088 }
2089
2090 if ( strcmp( _direction, "#FLIPIMAGEDIRECTION0002" ) == 0 || strcmp( _direction, "#FLIPIMAGEDIRECTION0003" ) == 0 ) {
2091 c6847b_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
2092 deploy( flipimagey, src_hw_6847b_flip_image_y_asm );
2093 outline0("JSR FLIPIMAGEY");
2094 } else {
2095
2097
2098 c6847b_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
2099 deploy( flipimagey, src_hw_6847b_flip_image_y_asm );
2100 outline1("LDA %s", _direction );
2101 outline1("ANDA #$%2.2x", FLAG_FLIP_Y );
2102 outline1("BEQ %s", label );
2103 outline0("JSR FLIPIMAGEY");
2104 outhead1("%s", label );
2105
2106 }
2107
2108}
2109
2110void c6847b_screen( Environment * _environment, char * _x, char * _y, char * _c ) {
2111
2112 deploy( screen, src_hw_6847b_screen_asm);
2113
2114 outline1("LDA %s", _x );
2115 outline1("LDB %s", _y );
2116 outline0("JSR SCREEN" );
2117 outline1("STA %s", _c );
2118
2119}
2120#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 SET_VIDEOAT_0400
Definition 6847.c:259
#define GM2_SET
Definition 6847.h:141
#define VDG_TEXT
Definition 6847.h:150
#define BITMAP_MODE_RESOLUTION6
Definition 6847.h:93
#define BITMAP_MODE_RESOLUTION2
Definition 6847.h:89
#define SAM_V0_SET
Definition 6847.h:116
#define BITMAP_MODE_COLOR2
Definition 6847.h:88
#define BITMAP_MODE_COLOR1
Definition 6847.h:86
#define TILEMAP_MODE_SEMIGRAPHICS6
Definition 6847.h:81
#define SAM_V2_SET
Definition 6847.h:120
#define GM1_CLR
Definition 6847.h:140
#define SAM_V0_CLR
Definition 6847.h:115
#define CSS_SET
Definition 6847.h:144
#define TILEMAP_MODE_INTERNAL
Definition 6847.h:77
#define BITMAP_MODE_COLOR6
Definition 6847.h:92
#define GM2_CLR
Definition 6847.h:142
#define TILEMAP_MODE_EXTERNAL
Definition 6847.h:78
#define BITMAP_MODE_COLOR3
Definition 6847.h:90
#define TILEMAP_MODE_SEMIGRAPHICS8
Definition 6847.h:82
#define TILEMAP_MODE_SEMIGRAPHICS4
Definition 6847.h:80
#define VDG_GRAPH
Definition 6847.h:149
#define BITMAP_MODE_RESOLUTION3
Definition 6847.h:91
#define SAM_V1_CLR
Definition 6847.h:117
#define GM1_SET
Definition 6847.h:139
#define GM0_CLR
Definition 6847.h:138
#define GM0_SET
Definition 6847.h:137
#define CSS_CLR
Definition 6847.h:145
#define TILEMAP_MODE_SEMIGRAPHICS12
Definition 6847.h:83
#define BITMAP_MODE_RESOLUTION1
Definition 6847.h:87
#define SAM_V1_SET
Definition 6847.h:118
#define SAM_V2_CLR
Definition 6847.h:119
#define TILEMAP_MODE_SEMIGRAPHICS24
Definition 6847.h:84
void c6847b_sprite_compress_horizontal(Environment *_environment, char *_sprite)
Definition 6847b.c:879
void c6847b_colormap_at(Environment *_environment, char *_address)
Definition 6847b.c:745
int c6847b_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
Definition 6847b.c:284
void c6847b_sprite_expand_vertical(Environment *_environment, char *_sprite)
Definition 6847b.c:867
void c6847b_use_tileset(Environment *_environment, char *_tileset)
Definition 6847b.c:1987
void c6847b_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
Definition 6847b.c:2021
void c6847b_sprite_monocolor(Environment *_environment, char *_sprite)
Definition 6847b.c:887
void c6847b_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition 6847b.c:2001
void c6847b_initialization(Environment *_environment)
Definition 6847b.c:1017
void c6847b_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
Definition 6847b.c:847
void c6847b_bitmap_disable(Environment *_environment)
Definition 6847b.c:713
void c6847b_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 6847b.c:1715
void c6847b_back(Environment *_environment)
Definition 6847b.c:1158
void c6847b_screen(Environment *_environment, char *_x, char *_y, char *_c)
Definition 6847b.c:2110
void c6847b_sprite_enable(Environment *_environment, char *_sprite)
Definition 6847b.c:851
Variable * c6847b_new_image(Environment *_environment, int _width, int _height, int _mode)
Definition 6847b.c:1822
void c6847b_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC-II: emit code to set raster irq
Definition 6847b.c:177
void c6847b_bank_select(Environment *_environment, int _bank)
Definition 6847b.c:212
void c6847b_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
Definition 6847b.c:806
void c6847b_pset_int(Environment *_environment, int _x, int _y, int *_c)
Definition 6847b.c:756
void c6847b_next_raster(Environment *_environment)
VIC-II: emit code to wait for next raster irq
Definition 6847b.c:191
void c6847b_screen_rows(Environment *_environment, char *_rows)
Definition 6847b.c:835
void c6847b_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
Definition 6847b.c:1978
void c6847b_horizontal_scroll(Environment *_environment, char *_displacement)
Definition 6847b.c:903
Variable * c6847b_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 6847b.c:1631
void c6847b_hscroll_line(Environment *_environment, int _direction, int _overlap)
Definition 6847b.c:1129
void c6847b_text(Environment *_environment, char *_text, char *_text_size, int _raw)
Definition 6847b.c:979
void c6847b_finalization(Environment *_environment)
Definition 6847b.c:1112
int c6847b_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
Definition 6847b.c:2005
void c6847b_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
Definition 6847b.c:863
void c6847b_textmap_at(Environment *_environment, char *_address)
Definition 6847b.c:749
Variable * c6847b_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
Definition 6847b.c:1877
void c6847b_flip_image(Environment *_environment, Resource *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_direction)
Definition 6847b.c:2068
void c6847b_get_width(Environment *_environment, char *_result)
Definition 6847b.c:907
void c6847b_vertical_scroll(Environment *_environment, char *_displacement)
Definition 6847b.c:899
void c6847b_collision(Environment *_environment, char *_sprite_mask, char *_result)
VIC-II: emit code to check for collision
Definition 6847b.c:76
void c6847b_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
Definition 6847b.c:1970
Variable * c6847b_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
Definition 6847b.c:1846
void c6847b_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
Definition 6847b.c:1982
void c6847b_screen_on(Environment *_environment)
Definition 6847b.c:827
void c6847b_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Definition 6847b.c:693
void c6847b_cls_box(Environment *_environment, char *_x1, char *_y1, char *_w, char *_h)
Definition 6847b.c:940
void c6847b_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Definition 6847b.c:717
void c6847b_screen_columns(Environment *_environment, char *_columns)
Definition 6847b.c:839
void console_calculate_vars(Environment *_environment)
Definition 6847b.c:275
void c6847b_sprite_compress_vertical(Environment *_environment, char *_sprite)
Definition 6847b.c:875
int c6847b_image_size(Environment *_environment, int _width, int _height, int _mode, int _transparent)
Definition 6847b.c:1188
void c6847b_put_image(Environment *_environment, Resource *_source, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
Definition 6847b.c:1767
void c6847b_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
VIC-II: emit code to change common sprite's color
Definition 6847b.c:158
void c6847b_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
Definition 6847b.c:859
void c6847b_hit(Environment *_environment, char *_sprite_mask, char *_result)
VIC-II: emit code to check for collision
Definition 6847b.c:91
void c6847b_hscroll_screen(Environment *_environment, int _direction, int _overlap)
Definition 6847b.c:1145
void c6847b_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
Definition 6847b.c:779
void c6847b_bitmap_at(Environment *_environment, char *_address)
Definition 6847b.c:738
void c6847b_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
Definition 6847b.c:1909
void c6847b_sprite_expand_horizontal(Environment *_environment, char *_sprite)
Definition 6847b.c:871
void c6847b_border_color(Environment *_environment, char *_border_color)
VIC-II: emit code to change border color
Definition 6847b.c:104
void c6847b_tiles_get(Environment *_environment, char *_result)
Definition 6847b.c:914
void c6847b_get_height(Environment *_environment, char *_result)
Definition 6847b.c:921
void c6847b_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC-II: emit code to wait for next raster irq at different position
Definition 6847b.c:208
void c6847b_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
Definition 6847b.c:843
void c6847b_screen_off(Environment *_environment)
Definition 6847b.c:831
Variable * c6847b_get_raster_line(Environment *_environment)
Definition 6847b.c:1991
void c6847b_sprite_disable(Environment *_environment, char *_sprite)
Definition 6847b.c:855
void c6847b_sprite_multicolor(Environment *_environment, char *_sprite)
Definition 6847b.c:883
void c6847b_scroll(Environment *_environment, int _dx, int _dy)
Definition 6847b.c:1966
void c6847b_tiles_at(Environment *_environment, char *_address)
Definition 6847b.c:895
void c6847b_sprite_color(Environment *_environment, char *_sprite, char *_color)
Definition 6847b.c:891
void c6847b_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
Definition 6847b.c:1974
void c6847b_background_color(Environment *_environment, char *_index, char *_background_color)
VIC-II: emit code to change background color
Definition 6847b.c:130
void c6847b_cline(Environment *_environment, char *_characters)
Definition 6847b.c:1162
void console_calculate(Environment *_environment)
Definition 6847b.c:221
void c6847b_scroll_text(Environment *_environment, int _direction, int _overlap)
Definition 6847b.c:959
void c6847b_cls(Environment *_environment)
Definition 6847b.c:928
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.
int rgbi_equals_rgba(RGBi *_first, RGBi *_second)
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.
Variable * variable_store(Environment *_environment, char *_destination, unsigned int _value)
Store a direct value to a variable.
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".
Variable * variable_store_buffer(Environment *_environment, char *_destination, unsigned char *_buffer, int _size, int _at)
int size
Definition _optimizer.c:678
int offset
Definition _optimizer.c:681
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
Definition plot.c:46
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
int width
Definition ugbc.h:2209
int y1
Definition ugbc.h:2206
int x1
Definition ugbc.h:2205
int height
Definition ugbc.h:2210
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
Console activeConsole
Definition ugbc.h:2910
int freeImageWidth
Definition ugbc.h:3088
int currentMode
Definition ugbc.h:2696
int screenTilesHeight
Definition ugbc.h:2885
int consoleTilesHeight
Definition ugbc.h:2895
int fontWidth
Definition ugbc.h:2900
CopperList * copperList
Definition ugbc.h:3282
int paletteSelected
Definition ugbc.h:2975
int screenColors
Definition ugbc.h:2870
int dynamicConsole
Definition ugbc.h:3298
FontConfig fontConfig
Definition ugbc.h:2415
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 screenWidth
Definition ugbc.h:2855
VestigialConfig vestigialConfig
Definition ugbc.h:2442
int schema
Definition ugbc.h:2063
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
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
int frameSize
Definition ugbc.h:1134
int frameCount
Definition ugbc.h:1137
RGBi originalPalette[MAX_PALETTE]
Definition ugbc.h:1169
char * realName
Definition ugbc.h:982
char clsImplicit
Definition ugbc.h:2008
char rchack_acme_1172
Definition ugbc.h:2015
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.
#define FLAG_FLIP_X
Definition ugbc.h:4553
@ VT_WORD
Definition ugbc.h:455
@ VT_POSITION
Definition ugbc.h:468
@ VT_BYTE
Definition ugbc.h:450
@ VT_SBYTE
Definition ugbc.h:452
@ VT_IMAGES
Definition ugbc.h:495
@ 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 CRITICAL_NEW_IMAGES_UNSUPPORTED_MODE(f)
Definition ugbc.h:3688
#define CRITICAL_SCREEN_UNSUPPORTED(v)
Definition ugbc.h:3496
#define outline0(s)
Definition ugbc.h:4252
#define FLAG_FLIP_Y
Definition ugbc.h:4554
#define outline1(s, a)
Definition ugbc.h:4253
#define WARNING_IMAGE_CONVERTER_UNSUPPORTED_MODE(f)
Definition ugbc.h:3880
#define adilinepalette(s, c, p)
Definition ugbc.h:4219
#define FONT_SCHEMA_ASCII
Definition ugbc.h:582
#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_NEW_IMAGE_UNSUPPORTED_MODE(f)
Definition ugbc.h:3540
#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