Ported examples to new devices addr

This commit is contained in:
neauoire 2021-03-21 14:16:19 -07:00
parent 8fd39ecf7e
commit 6cea4d8c4a
12 changed files with 92 additions and 84 deletions

View File

@ -35,7 +35,7 @@ typedef struct {
typedef struct {
Uint8 data[256 * 256], llen, mlen;
Uint16 ptr, count;
Uint16 ptr;
Label labels[256];
Macro macros[256];
} Program;
@ -69,7 +69,6 @@ pushbyte(Uint8 b, int lit)
{
if(lit) pushbyte(0x02, 0);
p.data[p.ptr++] = b;
p.count++;
}
void
@ -425,7 +424,7 @@ void
cleanup(char *filename)
{
int i;
printf("Assembled %s(%0.2fkb), %d labels, %d macros.\n\n", filename, p.count / 1000.0, p.llen, p.mlen);
printf("Assembled %s(%0.2fkb), %d labels, %d macros.\n\n", filename, p.ptr / 1000.0, p.llen, p.mlen);
for(i = 0; i < p.llen; ++i)
if(!p.labels[i].refs)
printf("--- Unused label: %s\n", p.labels[i].name);
@ -450,7 +449,7 @@ main(int argc, char *argv[])
error("Assembly", "Failed");
return 1;
}
fwrite(p.data, sizeof(p.data), 1, fopen(argv[2], "wb"));
fwrite(p.data, p.ptr, 1, fopen(argv[2], "wb"));
fclose(f);
cleanup(argv[2]);
return 0;

View File

@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
# run
./bin/assembler projects/software/left.usm bin/boot.rom
./bin/assembler projects/software/nasu.usm bin/boot.rom
./bin/emulator bin/boot.rom

View File

@ -2,7 +2,15 @@
%RTN { JMP2r }
@RESET
( devices )
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 13fd 1ef3 1bf2 ] ( palette )
( program )
|0200 @RESET
,text1 ,print-label JSR2
,text2 ,print-label JSR2
@ -27,7 +35,3 @@ RTN
|c000 @FRAME
|d000 @ERROR
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

View File

@ -4,9 +4,19 @@
%-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
( variables )
;slime { color 1 }
|0100 @RESET
( devices )
|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0130 ;Controller { buttons 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 0daf 02ff 035f ] ( palette )
|0200 @RESET
( set origin )
~Screen.width 2/ =Sprite.x
@ -60,11 +70,4 @@ BRK
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
@slime_icn [ 0000 183c 3c18 0000 ]
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FF30 ;Controller { buttons 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0daf 02ff 035f ] ( palette )
@ERROR BRK

View File

@ -8,7 +8,17 @@
;color { byte 1 }
;timer { byte 1 }
|0100 @RESET
( devices )
|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 0f85 0fd5 0fb5 ] ( palette )
( program )
|0200 @RESET
( position cat )
~Screen.width #0002 DIV2 =cat.x
@ -219,12 +229,5 @@ RTN
@mouse1_text [ mouse 1_ 00 ]
@mouse2_text [ mouse _2 00 ]
@mouse12_text [ mouse 12 00 ]
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0f85 0fd5 0fb5 ] ( palette )
@ERROR BRK

View File

@ -3,7 +3,16 @@
;center { x 2 y 2 }
;timer { byte 1 }
|0100 @RESET
( devices )
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ f0ac f0bb f053 ] ( palette )
( program )
|0200 @RESET
( find screen center )
~Screen.width #0002 DIV2 =center.x
@ -60,10 +69,4 @@ BRK
@icon [ 3c7e e7c3 c3e7 7e3c ]
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ f0ac f0bb f053 ] ( palette )
@ERROR BRK

View File

@ -10,7 +10,14 @@
;rect { x1 2 y1 2 x2 2 y2 2 }
;color { byte 1 }
|0100 @RESET
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0130 ;Controller { buttons 1 }
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 0fcf 0fc4 0fc4 ] ( palette )
|0200 @RESET
#0030 =window.x1 #0030 =window.y1 #0090 =window.x2 #0090 =window.y2
@ -223,12 +230,4 @@ RTN
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
]
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FF30 ;Controller { buttons 1 }
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0fcf 0fc4 0fc4 ] ( palette )
@ERROR BRK

View File

@ -9,7 +9,14 @@
;r2 { x1 2 y1 2 x2 2 y2 2 }
;r3 { x1 2 y1 2 x2 2 y2 2 }
|0100 @RESET
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 0f0f 0fff 0ff0 ] ( palette )
|0200 @RESET
#0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1
#0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1
@ -93,11 +100,4 @@ RTN
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
@hand_icn [ 4040 4070 f8f8 f870 ]
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
@ERROR BRK

View File

@ -7,7 +7,12 @@
;center { x 2 y 2 }
;i { short 2 }
|0100 @RESET
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 0f0f 0fff 0ff0 ] ( palette )
|0200 @RESET
( find screen center )
~Screen.width #0002 DIV2 =center.x
@ -121,11 +126,5 @@ RTN
@text4 [ even 00 ]
@text5 [ odd 00 ]
|c000 @FRAME BRK
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
@FRAME BRK
@ERROR BRK

View File

@ -4,7 +4,11 @@
;pict { x 2 y 2 width 2 height 2 color 1 addr 2 }
|0100 @RESET
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 0ffc 0f0b 0f03 ] ( palette )
|0200 @RESET
#0000 #0000 #0100 #0100 #01 ,pict_large ,draw-picture JSR2
#0098 #0060 #0080 #0080 #01 ,pict_medium ,draw-picture JSR2
@ -302,10 +306,5 @@ RTN
]
|c000 @FRAME BRK
|d000 @ERROR BRK
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0ffc 0f0b 0f03 ] ( palette )
@FRAME BRK
@ERROR BRK

View File

@ -11,7 +11,12 @@
;line { x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
;color { byte 1 }
|0100 @RESET
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|01F0 .RESET .FRAME .ERROR ( vectors )
|01F8 [ 13fd 1ef3 1bf2 ] ( palette )
|0200 @RESET
#0010 #0020 #0040 #0060 #01 ,fill-rect JSR2
#0020 #0030 #0050 #0070 #02 ,fill-rect JSR2
@ -171,11 +176,5 @@ RTN
@text [ Label 20 Text 00 ] ( add characters to memory )
|c000 @FRAME BRK
|d000 @ERROR BRK
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
@FRAME BRK
@ERROR BRK

View File

@ -525,6 +525,6 @@ RTN
007c 8280 f080 827c 007c 8280 f080 8080
]
|E000 @bank [ ]
@ERROR BRK
|FE00 @ERROR BRK
@bank [ ]