forked from dcrespo3d/zx-spectrum-snake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.c
113 lines (102 loc) · 3.03 KB
/
frame.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
////////////////////////////////////////////////////////////////////////////////
//
// Snake for ZX Spectrum 48K
//
// (C) 2019, 2020 David Crespo - https://github.com/dcrespo3d/zx-spectrum-snake
//
////////////////////////////////////////////////////////////////////////////////
#include "frame.h"
extern ubyte frame_corner_tl, frame_corner_tr, frame_corner_bl, frame_corner_br;
extern ubyte frame_segment_lr, frame_segment_tb;
void draw_frame(char x, char w, char y, char h, char attr)
{
char x1, y1, x2, y2, i;
x1 = x;
y1 = y;
x2 = x + w - 1;
y2 = y + h - 1;
uword bmap_addr, attr_addr;
screen_print_user(x1, y1, &frame_corner_tl);
screen_print_user(x2, y1, &frame_corner_tr);
screen_print_user(x2, y2, &frame_corner_br);
screen_print_user(x1, y2, &frame_corner_bl);
attr_addr = screen_get_attr_addr(x1, y1);
for (i = 0; i < w; i++) *((ubyte*)(attr_addr++)) = attr;
attr_addr = screen_get_attr_addr(x1, y2);
for (i = 0; i < w; i++) *((ubyte*)(attr_addr++)) = attr;
char ww = w - 2;
char hh = h - 2;
bmap_addr = screen_get_bmap_addr(x1+1, y1);
for (i = 0; i < ww; i++) screen_print_user_raw(bmap_addr++, &frame_segment_lr);
bmap_addr = screen_get_bmap_addr(x1+1, y2);
for (i = 0; i < ww; i++) screen_print_user_raw(bmap_addr++, &frame_segment_lr);
char y1a = y1 + 1;
for (i = 0; i < hh; i++) {
bmap_addr = screen_get_bmap_addr(x1, y1a+i);
screen_print_user_raw(bmap_addr, &frame_segment_tb);
attr_addr = screen_get_attr_addr(x1, y1a+i);
*((ubyte*)(attr_addr)) = attr;
}
for (i = 0; i < hh; i++) {
bmap_addr = screen_get_bmap_addr(x2, y1a+i);
screen_print_user_raw(bmap_addr, &frame_segment_tb);
attr_addr = screen_get_attr_addr(x2, y1a+i);
*((ubyte*)(attr_addr)) = attr;
}
}
__asm
._frame_corner_tl
DEFB %00000000
DEFB %00000111
DEFB %00011111
DEFB %00111111
DEFB %00111111
DEFB %01111111
DEFB %01111111
DEFB %01111111
._frame_corner_tr
DEFB %00000000
DEFB %11100000
DEFB %11111000
DEFB %11111100
DEFB %11111100
DEFB %11111110
DEFB %11111110
DEFB %11111110
._frame_corner_bl
DEFB %01111111
DEFB %01111111
DEFB %01111111
DEFB %00111111
DEFB %00111111
DEFB %00011111
DEFB %00000111
DEFB %00000000
._frame_corner_br
DEFB %11111110
DEFB %11111110
DEFB %11111110
DEFB %11111100
DEFB %11111100
DEFB %11111000
DEFB %11100000
DEFB %00000000
._frame_segment_lr
DEFB %00000000
DEFB %11111111
DEFB %11111111
DEFB %11111111
DEFB %11111111
DEFB %11111111
DEFB %11111111
DEFB %00000000
._frame_segment_tb
DEFB %01111110
DEFB %01111110
DEFB %01111110
DEFB %01111110
DEFB %01111110
DEFB %01111110
DEFB %01111110
DEFB %01111110
__endasm