commit abdf01d

zzo38  ·  2023-04-12 00:18:04 +0000 UTC
parent 0b3585a
Implement fill mode.
2 files changed,  +30, -6
M main.c
M main.c
+16, -3
 1@@ -629,6 +629,15 @@ static void set_screen_mode(int w,int h) {
 2   fglayer=bglayer+w*h;
 3 }
 4 
 5+static void screen_fill(Uint8*p,Uint8 v,Uint16 x0,Uint16 y0,Uint16 x1,Uint16 y1) {
 6+  if(y1>scr_h) y1=scr_h;
 7+  if(x1>scr_w) x1=scr_w;
 8+  if(y0>=y1 || x0>=x1) return;
 9+  p+=y0*scr_w+x0;
10+  x1-=x0;
11+  while(y0++<y1) memset(p,v,x1),p+=scr_w;
12+}
13+
14 static void draw_sprite(Uint16 x,Uint16 y,Uint16 addr,Uint8 v) {
15   Uint8 b=v&0x80;
16   Uint8 u;
17@@ -671,9 +680,13 @@ static void screen_out(Device*dev,Uint8 id) {
18     case 14:
19       if(size_changed) set_screen_mode(scr_w,scr_h);
20       picture_changed=1;
21-      if(x<scr_w && y<scr_h) (z&0x40?fglayer:bglayer)[x+y*scr_w]=z&3;
22-      if(dev->d[6]&0x01) PUT16(dev->d+8,x+1);
23-      if(dev->d[6]&0x02) PUT16(dev->d+10,y+1);
24+      if(z<0x80) {
25+        if(x<scr_w && y<scr_h) (z&0x40?fglayer:bglayer)[x+y*scr_w]=z&3;
26+        if(dev->d[6]&0x01) PUT16(dev->d+8,x+1);
27+        if(dev->d[6]&0x02) PUT16(dev->d+10,y+1);
28+      } else {
29+        screen_fill(z&0x40?fglayer:bglayer,z&3,dev->d[14]&0x10?0:x,dev->d[14]&0x20?0:y,dev->d[14]&0x10?x:scr_w,dev->d[14]&0x20?y:scr_h);
30+      }
31       break;
32     case 15:
33       if(size_changed) set_screen_mode(scr_w,scr_h);
+14, -3
 1@@ -110,9 +110,20 @@ The auto port works as follows:
 2   bit0 = X
 3 
 4 Writing to the pixel command port will change the pixel at the specified
 5-coordinates. The low 2-bits specify what colour to use, and bit6 specifies
 6-the layer (set for foreground, clear for background). It will automatically
 7-increment X and/or Y if the corresponding bits of the auto port are set.
 8+coordinates, and will automatically increment X and/or Y if the
 9+corresponding bits of the auto port are set. The bits of pixel port are:
10+  bit7 = Set for fill mode
11+  bit6 = Set for foreground layer, clear for background layer
12+  bit5-bit4 = Specify corner for fill mode (unused if not fill mode)
13+  bit3-bit2 = Unused (should be clear)
14+  bit1-bit0 = Colour
15+
16+If fill mode is set, then it will fill a part of the screen, in a rectangle
17+from the specified X and Y coordinates to one of the corners of the screen.
18+In this case, the X and Y are not automatically incremented. The corners of
19+the screen are numbered as follows:
20+  3 2
21+  1 0
22 
23 Writing to the sprite command port will draw one or more sprites. The bits
24 are as follows: