0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-22 22:05:11 +00:00

Fixed broken example

This commit is contained in:
neauoire 2021-02-15 14:42:53 -08:00
parent 82732f161e
commit 1beb714ce1
6 changed files with 16 additions and 120 deletions

96
cli.c
View file

@ -1,96 +0,0 @@
#include <stdio.h>
/*
Copyright (c) 2021 Devine Lu Linvega
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#include "uxn.h"
int
error(char *msg, const char *err)
{
printf("Error %s: %s\n", msg, err);
return 0;
}
Uint8
consoler(Device *d, Uint8 b)
{
(void)d;
(void)b;
return 0;
}
Uint8
consolew(Device *d, Uint8 b)
{
(void)d;
if(b)
printf("%c", b);
return 0;
}
void
echos(St8 *s, Uint8 len, char *name)
{
int i;
printf("\n%s\n", name);
for(i = 0; i < len; ++i) {
if(i % 16 == 0)
printf("\n");
printf("%02x%c", s->dat[i], s->ptr == i ? '<' : ' ');
}
printf("\n\n");
}
void
echom(Memory *m, Uint16 len, char *name)
{
int i;
printf("\n%s\n", name);
for(i = 0; i < len; ++i) {
if(i % 16 == 0)
printf("\n");
printf("%02x ", m->dat[i]);
}
printf("\n\n");
}
void
echof(Uxn *c)
{
printf("\nEnded @ %d steps | hf: %x sf: %x sf: %x cf: %x\n",
c->counter,
getflag(&c->status, FLAG_HALT) != 0,
getflag(&c->status, FLAG_SHORT) != 0,
getflag(&c->status, FLAG_SIGN) != 0,
getflag(&c->status, FLAG_COND) != 0);
}
int
main(int argc, char **argv)
{
Uxn u;
if(argc < 2)
return error("Input", "Missing");
if(!bootuxn(&u))
return error("Boot", "Failed");
if(!loaduxn(&u, argv[1]))
return error("Load", "Failed");
portuxn(&u, "console", consoler, consolew);
evaluxn(&u, u.vreset);
evaluxn(&u, u.vframe);
echos(&u.wst, 0x40, "stack");
echom(&u.ram, 0x40, "ram");
echof(&u);
return 0;
}

View file

@ -271,7 +271,7 @@ spritew(Device *d, Memory *m, Uint8 b)
if(!d->mem[6])
drawchr(pixels, x, y, chr);
else
drawicn(pixels, x, y, chr, d->mem[6], 0);
drawicn(pixels, x, y, chr, d->mem[6] & 0xf, (d->mem[6] >> 4) & 0xf);
if(d->mem[7])
REQDRAW = 1;
d->ptr = 0;

View file

@ -10,14 +10,13 @@
#03 =dev/r ( set dev/read to controller )
#02 =dev/w ( set dev/write to sprite )
#0080 =x #0040 =y ( origin )
#01 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
#0101 ,cursor_icn ~x ~y ,putsprite JSR ( draw sprite )
BRK
|0200 @SPRITESHEET
@cursor_icn .80c0 .e0f0 .f8e0 .1000 .0000 .0000 .0000 .0000
@star_icn .1054 .28c6 .2854 .1000 .0000 .0000 .0000 .0000
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
BRK
@ -49,7 +48,7 @@ BRK
@end
( redraw )
#01 ,cursor_icn ~x ~y ,putsprite JSR
#0101 ,cursor_icn ~x ~y ,putsprite JSR
BRK
@ -57,7 +56,7 @@ BRK
IOW2 ( y short )
IOW2 ( x short )
IOW2 ( sprite address )
IOW ( redraw byte )
IOW2 ( redraw byte )
RTS
|d000 @ERROR BRK

View file

@ -12,9 +12,9 @@
( print to screen )
#0008 =x #0030 =y #01 =color
,string ,displaygui JSR
#0010 =x #0038 =y #02 =color
#0010 =x #0038 =y #12 =color
,string ,displaygui JSR
#0018 =x #0040 =y #03 =color
#0018 =x #0040 =y #23 =color
,string ,displaygui JSR

View file

@ -7,32 +7,24 @@
#01 =dev/w ( set dev/write to screen )
#02 =dev/w ( set dev/write to sprite )
#00 ,star_icn #0041 #0041 ,putsprite JSR
#00 ,star_icn #0031 #0021 ,putsprite JSR
#00 ,cursor_icn #0021 #0016 ,putsprite JSR
#00 ,star_icn #0055 #0042 ,putsprite JSR
#01 ,cursor_icn #0067 #0031 ,putsprite JSR
#0110 ,cursor_icn #0020 #0038 ,drawsprite JSR
#0010 ,rounds_chr #0028 #0038 ,drawsprite JSR
#3210 ,cursor_icn #0020 #0040 ,drawsprite JSR
#0010 ,rounds_chr #0028 #0040 ,drawsprite JSR
BRK
@putsprite
@drawsprite
IOW2 ( y short )
IOW2 ( x short )
IOW2 ( sprite address )
IOW ( redraw byte )
RTS
@putpixel
IOW2 ( y short )
IOW2 ( x short )
IOW ( color byte )
IOW ( redraw byte )
IOW2 ( redraw byte )
RTS
|0200 @SPRITESHEET
@cursor_icn [ 80c0 e0f0 f8e0 1000 0000 0000 0000 0000 ]
@star_icn [ 1054 28c6 2854 1000 0000 0000 0000 0000 ]
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
@rounds_chr [ 3844 92aa 9244 3800 0038 7c7c 7c38 0000 ]
BRK

1
uxn.c
View file

@ -120,6 +120,7 @@ int
haltuxn(Uxn *u, char *name, int id)
{
printf("Halted: %s#%04x, at 0x%04x\n", name, id, u->counter);
op_nop(u);
return 0;
}