Browse code

Fixed broken example

neauoire authored on 15/02/2021 22:42:53
Showing 6 changed files
1 1
deleted file mode 100644
... ...
@@ -1,96 +0,0 @@
1
-#include <stdio.h>
2
-
3
-/*
4
-Copyright (c) 2021 Devine Lu Linvega
5
-
6
-Permission to use, copy, modify, and distribute this software for any
7
-purpose with or without fee is hereby granted, provided that the above
8
-copyright notice and this permission notice appear in all copies.
9
-
10
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
-WITH REGARD TO THIS SOFTWARE.
12
-*/
13
-
14
-#include "uxn.h"
15
-
16
-int
17
-error(char *msg, const char *err)
18
-{
19
-	printf("Error %s: %s\n", msg, err);
20
-	return 0;
21
-}
22
-
23
-Uint8
24
-consoler(Device *d, Uint8 b)
25
-{
26
-	(void)d;
27
-	(void)b;
28
-	return 0;
29
-}
30
-
31
-Uint8
32
-consolew(Device *d, Uint8 b)
33
-{
34
-	(void)d;
35
-	if(b)
36
-		printf("%c", b);
37
-	return 0;
38
-}
39
-
40
-void
41
-echos(St8 *s, Uint8 len, char *name)
42
-{
43
-	int i;
44
-	printf("\n%s\n", name);
45
-	for(i = 0; i < len; ++i) {
46
-		if(i % 16 == 0)
47
-			printf("\n");
48
-		printf("%02x%c", s->dat[i], s->ptr == i ? '<' : ' ');
49
-	}
50
-	printf("\n\n");
51
-}
52
-
53
-void
54
-echom(Memory *m, Uint16 len, char *name)
55
-{
56
-	int i;
57
-	printf("\n%s\n", name);
58
-	for(i = 0; i < len; ++i) {
59
-		if(i % 16 == 0)
60
-			printf("\n");
61
-		printf("%02x ", m->dat[i]);
62
-	}
63
-	printf("\n\n");
64
-}
65
-
66
-void
67
-echof(Uxn *c)
68
-{
69
-	printf("\nEnded @ %d steps | hf: %x sf: %x sf: %x cf: %x\n",
70
-		c->counter,
71
-		getflag(&c->status, FLAG_HALT) != 0,
72
-		getflag(&c->status, FLAG_SHORT) != 0,
73
-		getflag(&c->status, FLAG_SIGN) != 0,
74
-		getflag(&c->status, FLAG_COND) != 0);
75
-}
76
-
77
-int
78
-main(int argc, char **argv)
79
-{
80
-	Uxn u;
81
-	if(argc < 2)
82
-		return error("Input", "Missing");
83
-	if(!bootuxn(&u))
84
-		return error("Boot", "Failed");
85
-	if(!loaduxn(&u, argv[1]))
86
-		return error("Load", "Failed");
87
-	portuxn(&u, "console", consoler, consolew);
88
-	evaluxn(&u, u.vreset);
89
-	evaluxn(&u, u.vframe);
90
-
91
-	echos(&u.wst, 0x40, "stack");
92
-	echom(&u.ram, 0x40, "ram");
93
-
94
-	echof(&u);
95
-	return 0;
96
-}
... ...
@@ -271,7 +271,7 @@ spritew(Device *d, Memory *m, Uint8 b)
271 271
 		if(!d->mem[6])
272 272
 			drawchr(pixels, x, y, chr);
273 273
 		else
274
-			drawicn(pixels, x, y, chr, d->mem[6], 0);
274
+			drawicn(pixels, x, y, chr, d->mem[6] & 0xf, (d->mem[6] >> 4) & 0xf);
275 275
 		if(d->mem[7])
276 276
 			REQDRAW = 1;
277 277
 		d->ptr = 0;
... ...
@@ -10,14 +10,13 @@
10 10
 	#03 =dev/r ( set dev/read to controller ) 
11 11
 	#02 =dev/w ( set dev/write to sprite ) 
12 12
 	#0080 =x #0040 =y ( origin )
13
-	#01 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
13
+	#0101 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
14 14
 
15 15
 BRK
16 16
 
17 17
 |0200 @SPRITESHEET
18 18
 
19
-@cursor_icn .80c0 .e0f0 .f8e0 .1000 .0000 .0000 .0000 .0000
20
-@star_icn   .1054 .28c6 .2854 .1000 .0000 .0000 .0000 .0000
19
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
21 20
 
22 21
 BRK
23 22
 
... ...
@@ -49,7 +48,7 @@ BRK
49 48
 
50 49
 	@end
51 50
 	( redraw )
52
-	#01 ,cursor_icn ~x ~y ,putsprite JSR
51
+	#0101 ,cursor_icn ~x ~y ,putsprite JSR
53 52
 
54 53
 BRK
55 54
 
... ...
@@ -57,7 +56,7 @@ BRK
57 56
 	IOW2 ( y short )
58 57
 	IOW2 ( x short )
59 58
 	IOW2 ( sprite address )
60
-	IOW  ( redraw byte )
59
+	IOW2  ( redraw byte )
61 60
 	RTS
62 61
 
63 62
 |d000 @ERROR BRK 
... ...
@@ -12,9 +12,9 @@
12 12
 	( print to screen )
13 13
 	#0008 =x #0030 =y #01 =color
14 14
 	,string ,displaygui JSR 
15
-	#0010 =x #0038 =y #02 =color
15
+	#0010 =x #0038 =y #12 =color
16 16
 	,string ,displaygui JSR 
17
-	#0018 =x #0040 =y #03 =color
17
+	#0018 =x #0040 =y #23 =color
18 18
 	,string ,displaygui JSR 
19 19
 	
20 20
 
... ...
@@ -7,32 +7,24 @@
7 7
 	#01 =dev/w                           ( set dev/write to screen ) 
8 8
 	#02 =dev/w                           ( set dev/write to sprite ) 
9 9
 
10
-	#00 ,star_icn #0041 #0041 ,putsprite JSR
11
-	#00 ,star_icn #0031 #0021 ,putsprite JSR
12
-	#00 ,cursor_icn #0021 #0016 ,putsprite JSR
13
-	#00 ,star_icn #0055 #0042 ,putsprite JSR
14
-	#01 ,cursor_icn #0067 #0031 ,putsprite JSR
10
+	#0110 ,cursor_icn #0020 #0038 ,drawsprite JSR
11
+	#0010 ,rounds_chr #0028 #0038 ,drawsprite JSR
12
+	#3210 ,cursor_icn #0020 #0040 ,drawsprite JSR
13
+	#0010 ,rounds_chr #0028 #0040 ,drawsprite JSR
15 14
 
16 15
 BRK
17 16
 
18
-@putsprite
17
+@drawsprite
19 18
 	IOW2 ( y short )
20 19
 	IOW2 ( x short )
21 20
 	IOW2 ( sprite address )
22
-	IOW  ( redraw byte )
23
-	RTS
24
-
25
-@putpixel 
26
-	IOW2 ( y short )
27
-	IOW2 ( x short )
28
-	IOW  ( color byte )
29
-	IOW  ( redraw byte )
21
+	IOW2 ( redraw byte )
30 22
 	RTS
31 23
 
32 24
 |0200 @SPRITESHEET
33 25
 
34
-@cursor_icn [ 80c0 e0f0 f8e0 1000 0000 0000 0000 0000 ]
35
-@star_icn   [ 1054 28c6 2854 1000 0000 0000 0000 0000 ]
26
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
27
+@rounds_chr [ 3844 92aa 9244 3800 0038 7c7c 7c38 0000 ]
36 28
 
37 29
 BRK
38 30
 
... ...
@@ -120,6 +120,7 @@ int
120 120
 haltuxn(Uxn *u, char *name, int id)
121 121
 {
122 122
 	printf("Halted: %s#%04x, at 0x%04x\n", name, id, u->counter);
123
+	op_nop(u);
123 124
 	return 0;
124 125
 }
125 126