FUNCTION DrawPic (cumulative, fill_in_black : Boolean; default_palette: Integer; visual_map, priority_map, control_map, aux_map : Map): Map^4
VAR
palette : Array [0..3] of Palette;
drawenable, priority, col1, col2, pattern_nr, pattern_code : Integer;
BEGIN
palette := (default_palette × 4);
drawenable := DRAW_ENABLE_VISUAL | DRAW_ENABLE_PRIORITY
priority := 0;
col1 := col2 := 0;
pattern_nr := 0;
pattern_code := 0;
IF (!cumulative) THEN BEGIN
visual_map := (0xf × 320 × 200);
map control := map priority := map aux := (0 × 320 × 200);
END
FOREVER DO BEGIN
opcode := get_input();
COND opcode:
0xf0 → /* PIC_OP_SET_COLOR */
code := get_input();
(col1, col2) := palette[default_palette + (code / 40)][code % 40];
drawenable |= DRAW_ENABLE_VISUAL;
0xf1 → /* PIC_OP_DISABLE_VISUAL */
drawenable &= ~DRAW_ENABLE_VISUAL;
0xf2 → /* PIC_OP_SET_PRIORITY */
code := get_input();
priority := code & 0xf;
drawenable |= DRAW_ENABLE_PRIORITY;
0xf3 → /* PIC_OP_DISABLE_PRIORITY */
drawenable &= ~DRAW_ENABLE_PRIORITY;
0xf4 → /* PIC_OP_RELATIVE_PATTERNS */
IF (pattern_code & PATTERN_FLAG_USE_PATTERN) THEN
pattern_nr := (get_input() >> 1) & 0x7f
FI
(x,y) := GetAbsCoordinates();
DrawPattern(x, y, col1, col2, priority, control, drawenable,
pattern_code & PATTERN_FLAG_USE_PATTERN,
pattern_size, pattern_nr, pattern_code & PATTERN_FLAG_RECTANGLE);
WHILE (peek_input() < 0xf0) DO BEGIN
IF (pattern_code & PATTERN_FLAG_USE_PATTERN) THEN
pattern_nr := (get_input() >> 1) & 0x7f
FI
(x,y) = GetRelCoordinates(x,y);
DrawPattern(x, y, col1, col2, priority, control, drawenable,
pattern_code & PATTERN_FLAG_USE_PATTERN,
pattern_size, pattern_nr, pattern_code & PATTERN_FLAG_RECTANGLE);
END
0xf5 → /* PIC_OP_RELATIVE_MEDIUM_LINES */
(oldx, oldy) := GetAbsCoordinates();
WHILE (peek_input() < 0xf0) DO BEGIN
temp := get_input();
IF (temp & 0x80) THEN
y := oldy - (temp & 0x7f)
ELSE
y := oldy + temp
FI
x = oldx + get_input();
DitherLine(oldx, oldy, x, y, col1, col2, priority, special, drawenable);
(oldx, oldy) := (x, y);
END
0xf6 → /* PIC_OP_RELATIVE_LONG_LINES */
(oldx, oldy) := GetAbsCoordinates()
WHILE (peek_input() < 0xf0) DO BEGIN
(x, y) := GetAbsCoordinates();
DitherLine(oldx, oldy, x, y, col1, col2, priority, special, drawenable);
(oldx, oldy) := (x, y);
END
0xf7 → /* PIC_OP_RELATIVE_SHORT_LINES */
(oldx, oldy) = GetAbsCoordinates()
WHILE (peek_input() < 0xf0) DO BEGIN
(x, y) := GetRelCoordinates(oldx, oldy);
DitherLine(oldx, oldy, x, y, col1, col2, priority, special, drawenable);
(oldx, oldy) := (x, y);
END
0xf8 → /* PIC_OP_FILL */
IF (fill_in_black) THEN
(oldc1, oldc2) := (c1, c2);
FI
WHILE (peek_unput() < 0xf0) DO BEGIN
(x, y) := GetAbsCoordinates();
DitherFill(x, y, col1, col2, priority, special, drawenable);
END
IF (fill_in_black) THEN
(c1, c2) := (oldc1, oldc2);
FI
0xf9 → /* PIC_OP_SET_PATTERN */
pattern_code := get_input() & 0x37;
pattern_size := pattern_code & 0x7;
0xfa → /* PIC_OP_ABSOLUTE_PATTERNS */
WHILE (peek_input() < 0xf0) DO
IF (pattern_code & PATTERN_FLAG_USE_PATTERN)
pattern_nr := (get_input() >> 1) & 0x7f
FI
(x, y) := GetAbsCoordinates();
DrawPattern(x, y, col1, col2, priority, control, drawenable,
pattern_code & PATTERN_FLAG_USE_PATTERN,
pattern_size, pattern_nr, pattern_code & PATTERN_FLAG_RECTANGLE);
END
0xfb → /* PIC_OP_SET_CONTROL */
control := get_input() & 0x0f;
drawenable |= DRAW_ENABLE_CONTROL;
0xfc → /* PIC_OP_DISABLE_CONTROL */
drawenable &= ~DRAW_ENABLE_CONTROL;
0xfd → /* PIC_OP_RELATIVE_MEDIUM_PATTERNS */
IF (pattern_code & PATTERN_FLAG_USE_PATTERN) THEN
pattern_nr := (get_input() >> 1) & 0x7f;
FI
(oldx, oldy) := GetAbsCoordinates();
DrawPattern(x, y, col1, col2, priority, control, drawenable,
pattern_code & PATTERN_FLAG_USE_PATTERN,
pattern_size, pattern_nr, pattern_code & PATTERN_FLAG_RECTANGLE);
WHILE (peek_input() < 0xf0) DO BEGIN
IF (pattern_code & PATTERN_FLAG_USE_PATTERN) THEN
pattern_nr := (get_input() >> 1) & 0x7f;
FI
temp := get_input();
IF (temp & 0x80)
y := oldy - (temp & 0x7f)
ELSE
y := oldy + temp
FI
x := oldx + get_input();
DrawPattern(x, y, col1, col2, priority, control, drawenable,
pattern_code & PATTERN_FLAG_USE_PATTERN,
pattern_size, pattern_nr, pattern_code & PATTERN_FLAG_RECTANGLE);
END
0xfd → /* PIC_OP_OPX */
COND get_input():
0x00 → /* PIC_OPX_SET_PALETTE_ENTRY */
WHILE peek_input() < 0xf0 DO BEGIN
index := get_input();
color := get_input();
palette[index / 40][color % 40] := color;
END
0x01 → /* PIC_OPX_SET_PALETTE */
palette_number := get_input();
FOR i := 0 TO 39 DO
palette[palette_number][i] := get_input();
OD
0x02 → /* PIC_OPX_MONO0 */
skip_input(41);
0x03 → /* PIC_OPX_MONO1 */
skip_input(1);
0x04 → /* PIC_OPX_MONO2 */
0x05 → /* PIC_OPX_MONO3 */
skip_input(1);
0x06 → /* PIC_OPX_MONO4 */
0x07 → /* PIC_OPX_EMBEDDED_VIEW */ /* SCI01 operation */
0x08 → /* PIC_OPX_SET_PRIORITY_TABLE */ /* SCI01 operation */
0xff → return (visual, control, priority, aux);
END OF COND
END
END
|