Browse code

(draft) Add looping functionality to Screen/auto.

Andrew Alderwick authored on 06/03/2022 13:36:47
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,30 @@
1
+( devices )
2
+
3
+|00 @System     &vector $2 &wst      $1 &rst    $1 &swsz   $1 &swap   $1 &pad     $2 &r       $2 &g      $2 &b     $2 &debug  $1 &halt $1
4
+|20 @Screen     &vector $2 &width    $2 &height $2 &auto   $1 &pad    $1 &x       $2 &y       $2 &addr   $2 &pixel $1 &sprite $1
5
+
6
+( variables )
7
+
8
+|0000
9
+
10
+( program )
11
+
12
+|0100 ( -> )
13
+	( theme ) 
14
+	#0fe5 .System/r DEO2 
15
+	#0fc5 .System/g DEO2 
16
+	#0f25 .System/b DEO2
17
+
18
+	#35 .Screen/auto DEO
19
+
20
+	;font #0210 ADD2 .Screen/addr DEO2
21
+	#3400 &loop
22
+		#04 .Screen/sprite DEO
23
+		INC
24
+		GTHk ,&loop JCN
25
+
26
+BRK
27
+
28
+~projects/assets/msx01x02.tal
29
+
30
+
... ...
@@ -157,7 +157,7 @@ screen_deo(Device *d, Uint8 port)
157 157
 		break;
158 158
 	}
159 159
 	case 0xf: {
160
-		Uint16 x, y, addr;
160
+		Uint16 x, y, addr, auto_i;
161 161
 		Uint8 twobpp = !!(d->dat[0xf] & 0x80);
162 162
 		Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
163 163
 		DEVPEEK16(x, 0x8);
... ...
@@ -166,9 +166,17 @@ screen_deo(Device *d, Uint8 port)
166 166
 		if(addr > 0xfff8 - twobpp * 8)
167 167
 			return;
168 168
 		screen_blit(&uxn_screen, layer, x, y, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp);
169
-		if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */
170
-		if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8);                 /* auto x+8 */
171
-		if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8);                 /* auto y+8 */
169
+		auto_i = d->dat[0x6] + 0x40;
170
+		if((auto_i >> 6) > ((auto_i & 0x30) >> 4)) {
171
+			d->dat[0x6] = auto_i & 0x3f;
172
+			DEVPOKE16(0x8, x + ((auto_i & 0x01) << 3) - ((auto_i & 0x02) * (auto_i & 0x30) >> 2));
173
+			DEVPOKE16(0xa, y + ((auto_i & 0x02) << 2) - ((auto_i & 0x01) * (auto_i & 0x30) >> 1));
174
+		} else {
175
+			d->dat[0x6] = auto_i;
176
+			DEVPOKE16(0x8, x + ((auto_i & 0x02) << 2));
177
+			DEVPOKE16(0xa, y + ((auto_i & 0x01) << 3));
178
+		}
179
+		if(auto_i & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */
172 180
 		break;
173 181
 	}
174 182
 	}