all repos — xrxs @ ad433236001195e8449c430a14ffe0855f133aef

experimental networked application/game server with 9p

uxn-client/xrxs.tal (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
( utility macros )

%INC-X { .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 } ( -- )
%INC-Y { .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 } ( -- )

%CENTER-X { .Screen/width DEI2 #01 SFT2 }
%CENTER-Y { .Screen/height DEI2 #01 SFT2 }

%MOD { DIVk MUL SUB }
%MOD2 { DIV2k MUL2 SUB2 }

%NEXT-TILE { DUP2 #0010 ADD2 }

%RTN { JMP2r }

( devices )

|00 @System     [ &vector $2 &wst      $1 &rst    $1 &pad   $4 &r      $2 &g      $2 &b    $2 &debug  $1 &halt $1 ]
|10 @Console    [ &vector $2 &read     $1 &pad    $5 &write $1 &error  $1 ]
|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &pixel  $1 &sprite $1 ]
|30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|50 @Audio2     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|60 @Audio3     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller [ &vector $2 &button   $1 &key    $1 ]
|90 @Mouse      [ &vector $2 &x        $2 &y      $2 &state $1 &wheel  $1 ]
|a0 @File       [ &vector $2 &success  $2 &offset $2 &pad   $2 &name   $2 &length $2 &load $2 &save   $2 ]
|b0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour  $1 &minute $1 &second $1 &dotw $1 &doty   $2 &isdst $1 ]

( variables )

|0000

@state $1
@ticker $1
@anim-speed $1

@logo-coords [
  &x $2
  &y $2
]

@cart $64
@realm $64

( program )

|0100 
@init ( -> )

  ( steppewnolf-dark theme ) 
  #02c1 .System/r DEO2 
  #02cd .System/g DEO2 
  #02cb .System/b DEO2

  ;spritesheet .File/name DEO2
  #0100 .File/length DEO2
	
  #0000 .File/offset DEO2
  ;uxnlogo .File/load DEO2
  
  #0200 .File/offset DEO2
  ;xrxslogo .File/load DEO2

  #00 .ticker STZ
  #00 .state STZ
  #20 .anim-speed STZ
  
  CENTER-X .logo-coords/x STZ2
  CENTER-Y .logo-coords/y STZ2
  
  ;on-frame .Screen/vector DEO2
  
BRK

@on-frame ( -> )

  ( draw a piece of the logos ~ every half second )
  
  .ticker LDZ #01 ADD
  DUP .anim-speed LDZ EQU ,&next-render JCN
  .ticker STZ
  BRK
  
  
  
  &next-render
  POP #00 .ticker STZ
  .state LDZ
  
  DUP #00 NEQ ,&state1 JCN
    ;draw-uxn-logo JSR2
    #01 ADD .state STZ
  BRK
  &state1 DUP #01 NEQ ,&state2 JCN
    ;draw-xrxs-logo-xr JSR2
    #01 ADD .state STZ
  BRK
  &state2 DUP #02 NEQ ,&state3 JCN
    ;draw-xrxs-logo-xs JSR2
    
    #01 ADD .state STZ
  BRK
  &state3
    ;clear-screen JSR2
    DUP #03 NEQ ,&state4 JCN
    #04 .anim-speed STZ
    ;scoot-logos JSR2
    ;draw-uxn-logo JSR2
    ;draw-xrxs-logo-xr JSR2
    ;draw-xrxs-logo-xs JSR2
    .logo-coords/x LDZ2 #0020 GTH2 ,&keep-state JCN
      #01 ADD .state STZ BRK
    &keep-state POP
  BRK
  &state4 DUP #04 NEQ ,&state5 JCN
    ;draw-uxn-logo JSR2
    ;draw-xrxs-logo-xr JSR2
    ;draw-xrxs-logo-xs JSR2
    POP
  BRK
  &state5 POP
BRK

@clear-screen ( -> )
  ( fix this to clear the animation AND fix the overflow! )
  
  .Screen/width DEI2 #0000 &whilex EQU2k ,&endx JCN
    DUP2 ,&x STR2
    .Screen/height DEI2 #0000 &whiley EQU2k ,&endy JCN
      DUP2 ,&y STR2
      ,&x LDR2 .Screen/x DEO2
      ,&y LDR2 .Screen/y DEO2
      ;blank .Screen/addr DEO2
      #80 .Screen/sprite DEO
    #0008 ADD2 ,&whiley JMP &endy POP2 POP2
  #0008 ADD2 ,&whilex JMP &endx POP2 POP2
  RTN
  
  &x $2
  &y $2 
RTN
      
@scoot-logos ( -> )
  .logo-coords/x LDZ2 #0021 LTH2 ,&no-scoot-x JCN
    .logo-coords/x LDZ2 #01 SFT2
    .logo-coords/x STZ2
  &no-scoot-x
  
  .logo-coords/y LDZ2 #0021 LTH2 ,&no-scoot-y JCN
    .logo-coords/y LDZ2 #01 SFT2
    .logo-coords/y STZ2
  &no-scoot-y
RTN

@draw-uxn-logo ( -> )

  .logo-coords/x LDZ2 #0020 SUB2 .Screen/x DEO2
  .logo-coords/y LDZ2 #0010 SUB2 .Screen/y DEO2
  
  #0100 #0000 &while EQU2k ,&end JCN
    DUP2 ;uxnlogo ADD2 .Screen/addr DEO2
    #81 .Screen/sprite DEO INC-X
    
    NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
      .logo-coords/x LDZ2 #0020 SUB2 .Screen/x DEO2
      INC-Y
    &no-inc-y
  #0010 ADD2 ,&while JMP &end POP2 POP2
  
RTN

@draw-xrxs-logo-xr ( -> )

  .logo-coords/x LDZ2 .Screen/x DEO2
  .logo-coords/y LDZ2 #0010 SUB2 .Screen/y DEO2
  
  #0080 #0000 &while EQU2k ,&end JCN
    DUP2 ;xrxslogo ADD2 .Screen/addr DEO2
    #81 .Screen/sprite DEO INC-X
    
    NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
      .logo-coords/x LDZ2 .Screen/x DEO2
      INC-Y
    &no-inc-y
  #0010 ADD2 ,&while JMP &end POP2 POP2
  
RTN

@draw-xrxs-logo-xs ( -> )

  .logo-coords/x LDZ2 .Screen/x DEO2
  .logo-coords/y LDZ2 .Screen/y DEO2
  
  #0100 #0080 &while EQU2k ,&end JCN
    DUP2 ;xrxslogo ADD2 .Screen/addr DEO2
    #81 .Screen/sprite DEO INC-X
    
    NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
      .logo-coords/x LDZ2 .Screen/x DEO2
      INC-Y
    &no-inc-y
  #0010 ADD2 ,&while JMP &end POP2 POP2
  
RTN

( constants )
@spritesheet "xrxs.chr 00

( sprites )
@blank $16
@uxnlogo $128
@xrxslogo $128